vbe: Fix bug where the vbe tty double buffer did not properly refresh

This commit is contained in:
mintsuki 2020-12-27 19:32:18 +01:00
parent a9ff406d31
commit faae7a002c
8 changed files with 17 additions and 14 deletions

View File

@ -51,7 +51,7 @@ echfs-test: all limine-install test.hdd
rm -f limine.cfg.tmp part_guid
echfs-utils -g -p0 test.hdd import stage2.map boot/stage2.map
echfs-utils -g -p0 test.hdd import test/test.elf boot/test.elf
echfs-utils -g -p0 test.hdd import test/bg.bmp.gz boot/bg.bmp.gz
echfs-utils -g -p0 test.hdd import test/bg.bmp boot/bg.bmp
echfs-utils -g -p0 test.hdd import test/font.bin boot/font.bin
./limine-install limine.bin test.hdd
qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.hdd -debugcon stdio

View File

@ -6,7 +6,7 @@ megs: 512
clock: sync=realtime, time0=local
ata0-master: type=disk, path="test.img", mode=flat
ata0-master: type=disk, path="test.hdd", mode=flat
boot: c

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -166,7 +166,7 @@ void vbe_plot_bg_blent_rect(int x, int y, int width, int height, uint32_t hex) {
}
struct vbe_char {
uint8_t c;
uint32_t c;
uint32_t fg;
uint32_t bg;
};
@ -278,9 +278,7 @@ void vbe_set_text_bg(int bg) {
void vbe_double_buffer_flush(void) {
for (size_t i = 0; i < (size_t)rows * cols; i++) {
struct vbe_char c = grid[i];
if (!memcmp(&c, &front_grid[i], sizeof(struct vbe_char)))
if (!memcmp(&grid[i], &front_grid[i], sizeof(struct vbe_char)))
continue;
front_grid[i] = grid[i];
@ -288,20 +286,25 @@ void vbe_double_buffer_flush(void) {
int x = i % cols;
int y = i / cols;
vbe_plot_char(&c, x * VGA_FONT_WIDTH + frame_width,
vbe_plot_char(&grid[i], x * VGA_FONT_WIDTH + frame_width,
y * VGA_FONT_HEIGHT + frame_height);
}
}
void vbe_double_buffer(bool state) {
double_buffer_enabled = state;
if (state) {
memset(grid, 0, rows * cols * sizeof(struct vbe_char));
memset(front_grid, 0, rows * cols * sizeof(struct vbe_char));
memcpy(front_grid, grid, rows * cols * sizeof(struct vbe_char));
double_buffer_enabled = true;
vbe_clear(true);
vbe_double_buffer_flush();
} else {
bool pcs = cursor_status;
cursor_status = false;
vbe_clear(true);
vbe_double_buffer_flush();
cursor_status = pcs;
draw_cursor();
double_buffer_enabled = false;
}
}

BIN
test/bg.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

View File

@ -10,7 +10,7 @@ STAGE2_MAP=bios://:1/boot/stage2.map
THEME_COLOURS=60000000;aa0000;00aaff;aa5500;0000aa;aa00aa;9076de;aaaaaa
THEME_MARGIN=64
BACKGROUND_PATH=$bios://:1/boot/bg.bmp.gz
BACKGROUND_PATH=bios://:1/boot/bg.bmp
:+Legacy
@ -23,7 +23,7 @@ KERNEL_CMDLINE=Hi! This is an example!
MODULE_PATH=bios://:1/boot/test.elf
MODULE_STRING=yooooo
MODULE_PATH=$bios://:1/boot/bg.bmp.gz
MODULE_PATH=bios://:1/boot/bg.bmp
MODULE_STRING=yooooo
:Stivale2 Test
@ -33,5 +33,5 @@ RESOLUTION=640x480x16
KERNEL_PATH=bios://:1/boot/test.elf
KERNEL_CMDLINE=Woah! Another example!
MODULE_PATH=$bios://:1/boot/bg.bmp.gz
MODULE_PATH=bios://:1/boot/bg.bmp
MODULE_STRING=yooooo