diff --git a/framebuffer.c b/framebuffer.c index ac7cc29..301d626 100644 --- a/framebuffer.c +++ b/framebuffer.c @@ -6,6 +6,7 @@ // | 15-8 | 7-4 | 0-3 // | Asci | FG | BG #include "framebuffer.h" +#include "io.h" static char* Frame_Buffer = (char*)FRAME_BUFFER_ADDR; //static char* Frame_Buffer_End = (char*)(FRAME_BUFFER_ADDR + AREA); @@ -26,10 +27,20 @@ void clear_fb() { } } +void fb_move_cursor(unsigned short position) { + out_buffer(FB_CMD, FB_HIGH_CMD); + out_buffer(FB_DATA, ((position >> 8) & 0x00ff) ); + out_buffer(FB_CMD, FB_LOW_CMD); + out_buffer(FB_DATA, position & 0x00ff); +} /* generic test func for this module */ void test_fb() { clear_fb(); write_cell_fb(FRAME_CELL(0), 'a', Green, White); write_cell_fb(FRAME_CELL(1), 'b', Green, White); write_cell_fb(FRAME_CELL(2), 'c', Green, White); + write_cell_fb(FRAME_CELL(3), 'c', Green, White); + write_cell_fb(FRAME_CELL(4), 'c', Green, White); + write_cell_fb(FRAME_CELL(5), 'c', Green, White); + fb_move_cursor(5); } diff --git a/framebuffer.h b/framebuffer.h index 0a5ecb9..4771c5f 100644 --- a/framebuffer.h +++ b/framebuffer.h @@ -1,9 +1,19 @@ #include "stl/string.h" +#include "io.h" #define COLUMNS 80 #define ROWS 25 #define AREA ( COLUMNS * ROWS ) +// frame buffer port commansd +#define FB_CMD 0x3d4 +#define FB_DATA 0x3d5 + +#define FB_HIGH_CMD 14 +#define FB_LOW_CMD 15 + +void fb_move_cursor(unsigned short position); + // address of our frame buffer #define FRAME_BUFFER_ADDR 0x000B8000 diff --git a/io.asm b/io.asm new file mode 100644 index 0000000..8170dac --- /dev/null +++ b/io.asm @@ -0,0 +1,7 @@ +global out_buffer + +out_buffer: + mov al, [esp+8] + mov dx, [esp+4] + out dx, al + ret diff --git a/io.h b/io.h new file mode 100644 index 0000000..737f665 --- /dev/null +++ b/io.h @@ -0,0 +1,6 @@ +#ifndef INCLUDE_IO_H +#define INCLUDE_IO_H + +void out_buffer(unsigned short port, unsigned char data); + +#endif diff --git a/loader.asm b/loader.asm index 334f0e1..7a65bdf 100644 --- a/loader.asm +++ b/loader.asm @@ -20,22 +20,6 @@ align 4 dd CHECKSUM loader: - mov al, 14 - mov dx, 0x3d4 - out dx, al ; 14 tells the framebuffer to expect the highest 8 bits of the position - - mov al, 0 - mov dx, 0x3d5 - out dx, al ; sending the highest 8 bits of 0x0050 - - mov al, 15 - mov dx, 0x3d4 - out dx, al ; 15 tells the framebuffer to expect the lowest 8 bits of the position - - mov al, 0 - mov dx, 0x3d5 - out dx, al ; sending the lowest 8 bits of 0x0050 - call test_fb .loop: