pull/28/head
E. Almqvist 3 years ago
parent d0050227bc
commit 7c901071a1
  1. 18
      drivers/vga.c
  2. 2
      kernel/kernel.c

@ -5,8 +5,11 @@
// Charpos = 0xb8000 + 2(row*80 + col) // Charpos = 0xb8000 + 2(row*80 + col)
// Memory // Memory
#define VIDEO_MEM (char*)0xb8000 #define VGA_ADDRESS (char*)0xb8000
#define VIDEO_MEM_MAX (char*)0xb8fa0 #define VGA_ADDRESS_MAX (char*)0xb8fa0
#define MAX_ROWS 25
#define MAX_COLS 80
// Global // Global
static unsigned int cursor_row = 0; static unsigned int cursor_row = 0;
@ -16,10 +19,13 @@ static unsigned int cursor_col = 0;
VGA & Memory Functions VGA & Memory Functions
*/ */
char* get_vga_charpos_pointer(unsigned int col, unsigned int row) { char* get_vga_charpos_pointer(unsigned int col, unsigned int row) {
return (char*)(VIDEO_MEM + 2*((row*80) + col)); return (char*)(VGA_ADDRESS + 2*((row*80) + col));
} }
void writechar(char c, unsigned int col, unsigned int row, int attribute_byte) { void writechar(char c, unsigned int col, unsigned int row, int attribute_byte) {
if( !attribute_byte )
attribute_byte = 0x0f;
char* mem = get_vga_charpos_pointer(col, row); char* mem = get_vga_charpos_pointer(col, row);
*mem = c; // Write the character *mem = c; // Write the character
*(mem+1) = attribute_byte; // Write the attribute_byte *(mem+1) = attribute_byte; // Write the attribute_byte
@ -30,9 +36,9 @@ void writechar(char c, unsigned int col, unsigned int row, int attribute_byte) {
Graphics Functions Graphics Functions
*/ */
void clear_screen() { void clear_screen() {
// Make all the characters spaces for( int c = 0; c < MAX_COLS; c++ )
for( char* c = VIDEO_MEM; c <= VIDEO_MEM_MAX; c += 2 ) for( int r = 0; r < MAX_ROWS; r++ )
*c = 0x20; writechar(0x20, c, r, 0x0);
} }
void disable_vga_cursor() { void disable_vga_cursor() {

@ -1,3 +1,5 @@
#define NULL ((void*)0x0)
#include "../drivers/vga.h" #include "../drivers/vga.h"
void main() { void main() {

Loading…
Cancel
Save