aboutsummaryrefslogtreecommitdiff
path: root/devices/vga.c
diff options
context:
space:
mode:
Diffstat (limited to 'devices/vga.c')
-rw-r--r--devices/vga.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/devices/vga.c b/devices/vga.c
index e4831b8..b2a6da4 100644
--- a/devices/vga.c
+++ b/devices/vga.c
@@ -16,7 +16,7 @@ struct __attribute__((packed)) VGAEntry {
uint8_t foreground : 4;
uint8_t background : 4;
};
-_Static_assert(sizeof(struct VGAEntry) == 2, "sizeof VGAEntry");
+/* TODO _Static_assert(sizeof(struct VGAEntry) == 2, "sizeof VGAEntry"); */
const int width = 80;
const int height = 25;
@@ -25,7 +25,7 @@ struct VGAEntry *buffer;
int col = 0;
int row = 0;
-// *** Cursor ***
+/* *** Cursor *** */
void
vga_enable_cursor(unsigned char start, unsigned char end)
{
@@ -55,10 +55,12 @@ vga_update_cursor(void)
outb((pos >> 8) & 0xff, cga_dat_port);
}
-// *** Text Mode Output ***
+/* *** Text Mode Output *** */
void
vga_putc(__attribute__((unused)) const FILE *self, char a)
{
+ int i, x, y;
+
switch (a) {
case '\n':
col = 0;
@@ -82,15 +84,15 @@ vga_putc(__attribute__((unused)) const FILE *self, char a)
}
if (row == height) {
- // scroll up
- for (int y = 1; y < height; ++y)
- for (int x = 0; x < width; ++x) {
+ /* scroll up */
+ for (y = 1; y < height; ++y)
+ for (x = 0; x < width; ++x) {
const int prev = (y - 1) * width + x;
const int curr = y * width + x;
buffer[prev] = buffer[curr];
}
- // blank out last row
- for (int i = (height - 1) * width; i < height * width; ++i) buffer[i].text = ' ';
+ /* blank out last row */
+ for (i = (height - 1) * width; i < height * width; ++i) buffer[i].text = ' ';
--row;
}
}
@@ -98,6 +100,8 @@ vga_putc(__attribute__((unused)) const FILE *self, char a)
int
vga_puts(const FILE *self, const char *string, int len)
{
+ int i;
+
int written = 0;
if (len == -1)
while (*string != '\0') {
@@ -107,7 +111,7 @@ vga_puts(const FILE *self, const char *string, int len)
}
else
- for (int i = 0; i < len; ++i) {
+ for (i = 0; i < len; ++i) {
vga_putc(self, string[i]);
++written;
}
@@ -120,7 +124,7 @@ vga_flush(__attribute__((unused)) const FILE *self)
vga_update_cursor();
}
-// *** Text Mode ***
+/* *** Text Mode *** */
FILE vga_stream;
FILE *
@@ -140,8 +144,10 @@ vga_init(void *addr)
void
vga_clear(enum vga_color foreground, enum vga_color background)
{
- for (int y = 0; y < height; ++y)
- for (int x = 0; x < width; ++x) {
+ int x, y;
+
+ for (y = 0; y < height; ++y)
+ for (x = 0; x < width; ++x) {
const int index = y * width + x;
buffer[index].text = ' ';
buffer[index].foreground = foreground;