From aac16e6edc3b6c9193c6405606f27676733c06ed Mon Sep 17 00:00:00 2001 From: Namonay Date: Mon, 17 Jun 2024 15:31:14 +0200 Subject: [PATCH] added basic scroll without buffer --- sources/drivers/vga/vga.zig | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sources/drivers/vga/vga.zig b/sources/drivers/vga/vga.zig index 6e3c720..e143686 100644 --- a/sources/drivers/vga/vga.zig +++ b/sources/drivers/vga/vga.zig @@ -52,6 +52,21 @@ fn putEntry(c: u8, color: u8, x: usize, y: usize) void vga.buffer[y * vga.width + x] = getVal(c, color); } +pub fn scroll() void +{ + for (1..vga.height) |x| + { + for (0..vga.width) |y| + { + vga.buffer[(x - 1) * vga.width + y] = vga.buffer[x * vga.width + y]; + } + } + for (0..vga.width) |y| + { + vga.buffer[vga.height * vga.width + y] = 0; + } +} + pub fn putChar(c: u8) void { if(c == 0) @@ -64,7 +79,7 @@ pub fn putChar(c: u8) void vga.row = 0; vga.column += 1; if(vga.column == vga.height) - vga.column = 0; + scroll(); } }