diff options
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/kernel.c | 8 | ||||
-rw-r--r-- | src/vga.c | 1 | ||||
-rw-r--r-- | src/vga.h | 18 |
4 files changed, 24 insertions, 5 deletions
diff --git a/src/Makefile b/src/Makefile index 041a029..94fb3f1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,5 @@ CC := gcc -CFLAGS := -std=c99 -m32 -ffreestanding +CFLAGS := -std=c99 -m32 -ffreestanding -Os -g -Wall -Werror LD := ld all: image.bin diff --git a/src/kernel.c b/src/kernel.c index 100fc6d..ecd9aca 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -12,9 +12,9 @@ void entry( ) *(VIDEO_MEMORY+10) = '_'; uint8_t bar[4] = "\\|/-"; - char backup = *VIDEO_MEMORY; int pos = 10; - for( int i = 0; i < 200000; i++ ) { + volatile int i = 0; + for( i = 0; i < 20000; i++ ) { if( i % 1000 == 0 ) { *(VIDEO_MEMORY+pos) = '.'; *(VIDEO_MEMORY+pos+1) = 0x07; @@ -22,7 +22,7 @@ void entry( ) } *(VIDEO_MEMORY+pos) = bar[i%4]; *(VIDEO_MEMORY+pos+1) = 0x07; - for( int j = 0; j < 10000; j++ ); + for( int j = 0; j < 10000; j++ ) { + } } - *VIDEO_MEMORY = backup; } diff --git a/src/vga.c b/src/vga.c new file mode 100644 index 0000000..26208a0 --- /dev/null +++ b/src/vga.c @@ -0,0 +1 @@ +#include "vga.h" diff --git a/src/vga.h b/src/vga.h new file mode 100644 index 0000000..49fe8f2 --- /dev/null +++ b/src/vga.h @@ -0,0 +1,18 @@ +#ifndef VGA_H +#define VGA_H + +#include <inttypes.h> + +enum { + VGA_DEFAULT_RES_X = 80, + VGA_DEFAULT_RES_Y = 25 +}; + +typedef struct vga_t { + int res_x; // resolution, default 80 + int res_y; // resolution, default 25 + int cursor_x; // current cursor position X + int cursor_y; // current cursor position Y +} vga_t; + +#endif /* VGA_H */ |