ref: c9e1f4003a54d71ed97e6d7d32487c616be893c0
parent: 97ec62235b22bebe63c08c659bbdfdf052bb8afe
author: mkf <mkf@cloud9p.org>
date: Wed Dec 6 20:29:25 EST 2023
vga: scroll(int lines) → scroll(void) i'm not sure why, but vga_scroll(1) was acting oddly. it's a int literal, isn't it?
--- a/include/vga.h
+++ b/include/vga.h
@@ -34,7 +34,7 @@
void vga_clear(char c);
void vga_init(void);
void vga_writeto(char c, uint8 color, int x, int y);
-void vga_scroll(int lines);
+void vga_scroll(void);
void vga_nl(void);
void vga_putc(char c);
void vga_puts(char *s);
--- a/pc/vga.c
+++ b/pc/vga.c
@@ -34,7 +34,7 @@
{
vga_row = 0;
vga_col = 0;
- vga_color = vga_gencolor(WHITE, BLACK);
+ vga_color = vga_gencolor(WHITE, BLUE);
vga_buf = (uint16*)VGA_MEM;
vga_clear(' ');
}
@@ -47,21 +47,21 @@
}
void
-vga_scroll(int lines)
+vga_scroll()
{
- int index;
+ uint16 c;
+ char *s;
+
+ s = malloc(10);
+ c = vga_char(' ', vga_color);
- index = 0;
- while(index < VGA_WIDTH * (VGA_HEIGHT - lines))
- {
- vga_buf[index] = vga_buf[index + VGA_WIDTH * lines];
- index++;
- }
+ for(int i = 0 ; i < VGA_WIDTH * VGA_HEIGHT ; i++)
+ vga_buf[i] = vga_buf[i + VGA_WIDTH];
+
/* clear last line */
- while(index < VGA_WIDTH * VGA_HEIGHT)
+ for(int i = VGA_WIDTH * (VGA_HEIGHT - 1) ; i < VGA_WIDTH * VGA_HEIGHT ; i++)
{
- vga_buf[index] = vga_char(' ', vga_color);
- index++;
+ vga_buf[i] = c;
}
}
@@ -69,8 +69,8 @@
vga_nl(void)
{
vga_col = 0; /* cr */
- if(vga_row == VGA_HEIGHT-1)
- vga_scroll(1);
+ if(vga_row == VGA_HEIGHT - 1)
+ vga_scroll();
else
vga_row++;
}