From be1fe26d8abd56267d2e17c9066c62b2072770f5 Mon Sep 17 00:00:00 2001 From: chschnell Date: Wed, 4 Sep 2024 14:16:14 +0200 Subject: [PATCH 1/2] Add support for VBE_DISPI_INDEX_X_OFFSET Adds support for horizontal offset in Bochs VESA BIOS Extension. Should fix issue #1088. --- src/vga.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/vga.js b/src/vga.js index 8e746f9365..cf30eadeee 100644 --- a/src/vga.js +++ b/src/vga.js @@ -220,7 +220,7 @@ function VGAScreen(cpu, bus, vga_memory_size) * @type {number} */ this.svga_offset = 0; - + this.svga_offset_x = 0; this.svga_offset_y = 0; const pci_revision = 0; // set to 2 for qemu extended registers @@ -2123,14 +2123,23 @@ VGAScreen.prototype.port1CF_write = function(value) dbg_log("SVGA bank offset: " + h(value << 16), LOG_VGA); this.svga_bank_offset = value << 16; break; + case 8: + // x offset + dbg_log("SVGA X offset: " + h(value), LOG_VGA); + if(this.svga_offset_x !== value) + { + this.svga_offset_x = value; + this.svga_offset = this.svga_offset_y * this.svga_width + this.svga_offset_x; + this.complete_redraw(); + } + break; case 9: // y offset - const offset = value * this.svga_width; - dbg_log("SVGA offset: " + h(offset) + " y=" + h(value), LOG_VGA); + dbg_log("SVGA Y offset: " + h(value * this.svga_width) + " y=" + h(value), LOG_VGA); if(this.svga_offset_y !== value) { this.svga_offset_y = value; - this.svga_offset = offset; + this.svga_offset = this.svga_offset_y * this.svga_width + this.svga_offset_x; this.complete_redraw(); } break; @@ -2204,7 +2213,7 @@ VGAScreen.prototype.svga_register_read = function(n) case 8: // x offset - return 0; + return this.svga_offset_x; case 9: return this.svga_offset_y; case 0x0A: From 4411f62d4a1276ba747e2bc8c08d91ca3636f43e Mon Sep 17 00:00:00 2001 From: chschnell Date: Sun, 8 Sep 2024 19:02:23 +0200 Subject: [PATCH 2/2] Reset X- and Y-offsets when enabling SVGA video mode Reset members svga_offset, svga_offset_x and svga_offset_y to 0 when enabling any SVGA video mode. Behaviour copied from Bochs at: https://sourceforge.net/p/bochs/code/HEAD/tree/trunk/bochs/iodev/display/vga.cc#l1068 --- src/vga.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/vga.js b/src/vga.js index cf30eadeee..0f2f1de272 100644 --- a/src/vga.js +++ b/src/vga.js @@ -2163,6 +2163,9 @@ VGAScreen.prototype.port1CF_write = function(value) if(this.svga_enabled && this.dispi_index === 4) { + this.svga_offset = 0; + this.svga_offset_x = 0; + this.svga_offset_y = 0; this.set_size_graphical(this.svga_width, this.svga_height, this.svga_bpp, this.svga_width, this.svga_height); this.bus.send("screen-set-mode", true); this.graphical_mode = true;