ref: a48827d1fd9dc95d033554b8d7da9f70b00fc892
parent: ca563e03c774c1da22039ead4b64ef3322249f97
author: mkf <mkf@cloud9p.org>
date: Sun Nov 19 22:16:49 EST 2023
cons: add scroll
--- a/include/cons.h
+++ b/include/cons.h
@@ -8,6 +8,7 @@
void (*puts)(char *s);
void (*putc)(char c);
char (*getc)(void);
+ void (*scroll)(int lines);
}consdev_t;
void consinit(consdev_t);
@@ -15,3 +16,4 @@
void conswrite(consdev_t cons, char* s);
void consputc(consdev_t, char c);
char consread(consdev_t cons);
+void consscroll(consdev_t, int lines);
--- a/include/pccons.h
+++ b/include/pccons.h
@@ -11,5 +11,5 @@
.puts = vga_puts,
.putc = vga_putc,
.getc = ps2_getc,
-
+ .scroll = vga_scroll,
};
--- a/include/vga.h
+++ b/include/vga.h
@@ -36,7 +36,7 @@
void vga_clear(char c);
void vga_init(void);
void vga_writeto(char c, uint8 color, int x, int y);
-void vga_scroll(void);
+void vga_scroll(int lines);
void vga_nl(void);
void vga_putc(char c);
void vga_puts(char *s);
--- a/pc/vga.c
+++ b/pc/vga.c
@@ -1,6 +1,7 @@
#include <u.h>
#include <libc.h>
#include <vga.h>
+#include <mem.h>
static inline uint8
vga_gencolor(int fg, int bg)
@@ -35,7 +36,7 @@
vga_row = 0;
vga_col = 0;
vga_color = vga_gencolor(WHITE, BLACK);
- vga_buf = (uint16*) VGA_MEM;
+ vga_buf = (uint16*)VGA_MEM;
vga_clear(' ');
}
@@ -47,13 +48,13 @@
}
void
-vga_scroll(void)
+vga_scroll(int lines)
{
int index;
index = 0;
- while(index < VGA_WIDTH * (VGA_HEIGHT-1))
+ while(index < VGA_WIDTH * (VGA_HEIGHT - lines))
{
- vga_buf[index] = vga_buf[index + VGA_WIDTH];
+ vga_buf[index] = vga_buf[index + VGA_WIDTH * lines];
index++;
}
/* clear last line */
@@ -70,8 +71,7 @@
vga_col = 0; /* cr */
if(vga_row == VGA_HEIGHT-1)
{
- //vga_row = 0; /* lf */
- vga_scroll();
+ vga_scroll(1);
}
else
vga_row++;