37 lines
1.1 KiB
C
37 lines
1.1 KiB
C
// Driver implementation for Jank's text frame buffer
|
|
|
|
// Buffer can display 80 columns by 25 Rows
|
|
// Start of buffer is at (real)address 0x000B8000
|
|
// Memory at this section is divided into 16-bit cells
|
|
// | 15-8 | 7-4 | 0-3
|
|
// | Asci | FG | BG
|
|
#include "types.h"
|
|
#include "framebuffer.h"
|
|
|
|
// State trackers from header
|
|
static u8* Frame_Buffer = (u8*)FRAME_BUFFER_ADDR;
|
|
s32 Frame_Buffer_Cursor = 0;
|
|
|
|
// Writes character to a given cell in the framebuffer
|
|
// @cell parameter is the logical (linear)index into the buffer
|
|
void write_cell_fb(u16 cell, u8 c, u8 fg, u8 bg) {
|
|
Frame_Buffer[cell] = c;
|
|
Frame_Buffer[cell+1] = (fg & 0x0f << 4) | (bg & 0x0f);
|
|
Frame_Buffer_Cursor++;
|
|
}
|
|
|
|
void clear_fb(void) {
|
|
for(unsigned cell=0;cell<AREA; cell+=2) {
|
|
write_cell_fb(cell, ' ', 0x00, 0x00);
|
|
}
|
|
}
|
|
|
|
// Takes the linear indexed position to move the cursos, if there is nothing at that position we should still have something there
|
|
void fb_move_cursor(u16 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);
|
|
}
|
|
|