Skip to content

Commit 2ff3af1

Browse files
committed
drivers: add up/down scrolling thru VGA screens
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
1 parent 4a593b2 commit 2ff3af1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

drivers/vga.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define MAX_ROWS VGA_ROWS
3131
#define MAX_COLS (2 * VGA_COLS)
3232

33+
static unsigned scroll_screen = 0;
3334

3435
static uint8_t vga_buffer[VGA_SCREENS][MAX_ROWS][MAX_COLS];
3536

@@ -39,6 +40,16 @@ static inline void write_vga_buffer(int cur_screen) {
3940
memcpy(vga_memory, vga_buffer[cur_screen], sizeof(vga_buffer[cur_screen]));
4041
}
4142

43+
void vga_scroll_down(void) {
44+
if (scroll_screen < (VGA_SCREENS - 1))
45+
write_vga_buffer(++scroll_screen);
46+
}
47+
48+
void vga_scroll_up(void) {
49+
if (scroll_screen > 0)
50+
write_vga_buffer(--scroll_screen);
51+
}
52+
4253
void vga_write(const char *buf, size_t len, vga_color_t color) {
4354
static int screen = 0, row = 0, col = 0;
4455

@@ -65,5 +76,6 @@ void vga_write(const char *buf, size_t len, vga_color_t color) {
6576
vga_buffer[screen][row][col++] = color;
6677
}
6778

79+
scroll_screen = screen;
6880
write_vga_buffer(screen);
6981
}

include/drivers/vga.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,8 @@ typedef enum vga_color vga_color_t;
5555
#define VGA_COLS 80
5656
#define VGA_SCREENS 10
5757

58+
extern void vga_scroll_up(void);
59+
extern void vga_scroll_down(void);
60+
5861
extern void vga_write(const char *buf, size_t len, vga_color_t color);
5962
#endif /* KTF_DRV_VGA_H */

0 commit comments

Comments
 (0)