Implemented a software cursor of sorts and updated the function that draws a string to honor that cursor position.
This commit is contained in:
+25
-12
@@ -1,9 +1,11 @@
|
||||
#include "../includes/screen.h"
|
||||
#include "../build_numbers.c"
|
||||
|
||||
unsigned char row = 1;
|
||||
unsigned char column = 0;
|
||||
unsigned char cursor_x = 0;
|
||||
unsigned char cursor_y = 0;
|
||||
unsigned char screen_width = 80;
|
||||
char column = -1;
|
||||
unsigned char row = 0;
|
||||
|
||||
|
||||
void print_banner(){
|
||||
@@ -55,32 +57,43 @@ void draw_rect(int start_x, int start_y, int end_x, int end_y, unsigned char fg,
|
||||
for(unsigned char i = 0; i < y; i++){
|
||||
for(unsigned char j = 0; j < x; j++){
|
||||
unsigned short *where = (unsigned short*) buffer + (i * 80) + j;
|
||||
*where = 0x23 | (attr << 8);
|
||||
*where = ' ' | (attr << 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void draw_s(char* string, unsigned char fg, unsigned char bg)
|
||||
{
|
||||
char *video_buffer = 0x000B8000;
|
||||
|
||||
unsigned short *video_buffer = 0x000B8000;
|
||||
int attr = ((bg << 4) | (fg & 0x0F));
|
||||
for(int i = 0; i < strlen(string); i++)
|
||||
{
|
||||
char current_char = string[i];
|
||||
unsigned char current_char = string[i];
|
||||
unsigned short *where = (unsigned short *) video_buffer + (cursor_y * 80) + i + cursor_x;
|
||||
|
||||
if(current_char == '\n'){
|
||||
//row++;
|
||||
column = row * column;
|
||||
row++;
|
||||
cursor_y++;
|
||||
continue;
|
||||
}
|
||||
|
||||
video_buffer[i*2 + (row * column)] = string[i];
|
||||
video_buffer[i * 2 + 1 + (row * column)] = ((fg & 0x0f) << 4) | (bg & 0x0F);
|
||||
//column++;
|
||||
*where = string[i] | attr << 8;
|
||||
}
|
||||
}
|
||||
|
||||
void set_cursor(unsigned char x, unsigned char y){
|
||||
cursor_x = x;
|
||||
cursor_y = y;
|
||||
}
|
||||
|
||||
void move_cursor(unsigned char x, unsigned char y){
|
||||
if(column != -1) draw_rect(cursor_x, cursor_y, cursor_x + 1, cursor_y + 1, 0x2, 0x8);
|
||||
|
||||
cursor_x = x;
|
||||
cursor_y = y;
|
||||
|
||||
draw_rect(x, y, x + 1, y + 1, 0x0, 0xF);
|
||||
}
|
||||
|
||||
void clear_screen(){
|
||||
char *video_buffer = 0x000B8000;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user