Moving components modules to a more proper directory

This commit is contained in:
2023-03-30 22:40:08 -07:00
parent 044d5a75b5
commit cc1bb63e27
26 changed files with 11 additions and 148 deletions

View File

@@ -0,0 +1,48 @@
// 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 = 0x0000;
void frame_buffer_newline() {
while(Frame_Buffer_Cursor != (AREA*8)) {
if((Frame_Buffer_Cursor % 160) == 0) {
break;
Frame_Buffer_Cursor+=160;
}
else {
Frame_Buffer_Cursor+=2;
}
}
}
// Writes character to a given cell in the framebuffer
// @cell parameter is the logical (linear)index into the buffer
void write_cell_fb(u8 c, u8 fg, u8 bg) {
Frame_Buffer[Frame_Buffer_Cursor] = c;
Frame_Buffer[Frame_Buffer_Cursor+1] = (fg & 0x0f << 4) | (bg & 0x0f);
Frame_Buffer_Cursor += 2;
}
void clear_fb(void) {
for(unsigned cell=0;cell<AREA; cell+=2) {
write_cell_fb(' ', 0x00, 0x00);
}
Frame_Buffer_Cursor = 0x0000;
}
// 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) {
serialport_write_byte(FB_CMD, FB_HIGH_CMD);
serialport_write_byte(FB_DATA, ((position >> 8) & 0x00ff) );
serialport_write_byte(FB_CMD, FB_LOW_CMD);
serialport_write_byte(FB_DATA, position & 0x00ff);
}

View File

@@ -0,0 +1,52 @@
#include "types.h"
#include "serial.h"
#include "ports.h"
#ifndef FRAMEBUFFER_H
#define FRAMEBUFFER_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
// address of our frame buffer
#define FRAME_BUFFER_ADDR 0x000B8000
// Logical index of a cell in the frame buffer
#define FRAME_CELL(cell_) (cell_ * 2)
// Colors available in text framebuffer
#define Black 0x01
#define Blue 0x02
#define Green 0x03
#define Cyan 0x04
#define Red 0x05
#define Magenta 0x05
#define Brown 0x06
#define LightGrey 0x07
#define DarkGrey 0x08
#define LightBlue 0x09
#define LightGreen 0x0a
#define LightCyan 0x0b
#define LightRed 0x0c
#define LightMagenta 0x0d
#define LightBrown 0x0e
#define White 0x0f
extern s32 Frame_Buffer_Cursor;
void frame_buffer_newline();
void write_cell_fb(u8, u8, u8);
void clear_fb(void);
void fb_move_cursor(u16);
#endif