Skip to content

Commit

Permalink
drivers: add up/down scrolling thru VGA screens
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Nov 13, 2020
1 parent 4a593b2 commit 2ff3af1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define MAX_ROWS VGA_ROWS
#define MAX_COLS (2 * VGA_COLS)

static unsigned scroll_screen = 0;

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

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

void vga_scroll_down(void) {
if (scroll_screen < (VGA_SCREENS - 1))
write_vga_buffer(++scroll_screen);
}

void vga_scroll_up(void) {
if (scroll_screen > 0)
write_vga_buffer(--scroll_screen);
}

void vga_write(const char *buf, size_t len, vga_color_t color) {
static int screen = 0, row = 0, col = 0;

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

scroll_screen = screen;
write_vga_buffer(screen);
}
3 changes: 3 additions & 0 deletions include/drivers/vga.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@ typedef enum vga_color vga_color_t;
#define VGA_COLS 80
#define VGA_SCREENS 10

extern void vga_scroll_up(void);
extern void vga_scroll_down(void);

extern void vga_write(const char *buf, size_t len, vga_color_t color);
#endif /* KTF_DRV_VGA_H */

0 comments on commit 2ff3af1

Please sign in to comment.