From 958e4457914c5e5646dc145ee18f1bc616a9520f Mon Sep 17 00:00:00 2001 From: Jonathan Campbell Date: Fri, 1 Sep 2023 22:38:54 -0700 Subject: [PATCH] VGA DS START command to force start address --- CHANGELOG | 2 ++ include/vga.h | 6 ++++++ src/debug/debug.cpp | 25 ++++++++++++++++++++++++- src/hardware/vga_draw.cpp | 15 +++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 57e3c538392..62bbfba018a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ Next version: - Add "VRD" debugger command to force redraw of the VGA screen. + - Add VGA debug set commands to force a video start address and another + to clear all debug settings. 2023.09.01 - Disable by default message confirmation after snapshot and AVI video diff --git a/include/vga.h b/include/vga.h index 4de8296be2c..f8982913b62 100644 --- a/include/vga.h +++ b/include/vga.h @@ -649,6 +649,11 @@ typedef struct VGA_Complexity_t { } } VGA_Complexity; +typedef struct VGA_Override_t { + bool enable = false; + uint32_t start = ~uint32_t(0u); +} VGA_Override; + typedef struct VGA_Type_t { VGAModes mode = {}; /* The mode the vga system is in */ VGAModes lastmode = {}; @@ -672,6 +677,7 @@ typedef struct VGA_Type_t { VGA_Memory mem; VGA_LFB lfb = {}; VGA_Complexity complexity = {}; + VGA_Override overopts = {}; } VGA_Type; diff --git a/src/debug/debug.cpp b/src/debug/debug.cpp index b005514f415..34edb043c80 100644 --- a/src/debug/debug.cpp +++ b/src/debug/debug.cpp @@ -304,6 +304,9 @@ static FPU_rec oldfpu; void VGA_DebugRedraw(void); +void VGA_DebugOverrideStart(uint32_t ofs); +void VGA_ResetDebugOverrides(void); + bool IsDebuggerActive(void) { return debugging; } @@ -2811,7 +2814,27 @@ bool ParseCommand(char* str) { return false; } - if (command == "FONTDUMP") { // Dump font RAM to file + if (command == "DS") { + std::string cmd2; + while (*found == ' ') found++; + stream >> cmd2; + while (*found != 0 && *found != ' ') found++; + while (*found == ' ') found++; + + if (cmd2 == "START") { + VGA_DebugOverrideStart(strtoul(found,NULL,16/*hexadecimal*/)); + VGA_DebugRedraw(); + } + else if (cmd2 == "X") { + VGA_ResetDebugOverrides(); + VGA_DebugRedraw(); + } + else { + DEBUG_ShowMsg("Unknown VGA debug command"); + return false; + } + } + else if (command == "FONTDUMP") { // Dump font RAM to file /* Rule: If the file extension is .BIN, write the entire contents of bitplane 2 where the font resides (64KB). * If the file extension is .BMP, write only the visible font characters in a neat 8x8 (256) matrix. * If you run this when EGA/VGA graphics are active, you will get "jibberish" based on the graphics on diff --git a/src/hardware/vga_draw.cpp b/src/hardware/vga_draw.cpp index 42ccc996449..2eddc3b3a42 100644 --- a/src/hardware/vga_draw.cpp +++ b/src/hardware/vga_draw.cpp @@ -3691,6 +3691,10 @@ static void VGA_DisplayStartLatch(Bitu /*val*/) { vga.config.real_start=vga.config.display_start & vga.mem.memmask; vga.draw.bytes_skip = vga.config.bytes_skip; + if (vga.overopts.enable) { + if (vga.overopts.start != ~uint32_t(0u)) vga.config.real_start = vga.overopts.start & vga.mem.memmask; + } + /* TODO: When does 640x480 2-color mode latch foreground/background colors from the DAC? */ if (machine == MCH_MCGA && (vga.other.mcga_mode_control & 2)) {//640x480 2-color mode MCGA VGA_DAC_UpdateColorPalette(); @@ -6202,6 +6206,7 @@ bool IsDebuggerActive(void); void VGA_DebugRedraw(void) { if (IsDebuggerActive()) { RENDER_EndUpdate(true); + vga.draw.lines_done = vga.draw.lines_total; PIC_RemoveEvents(VGA_Other_VertInterrupt); PIC_RemoveEvents(VGA_VerticalTimer); PIC_RemoveEvents(VGA_PanningLatch); @@ -6212,6 +6217,16 @@ void VGA_DebugRedraw(void) { } } +void VGA_DebugOverrideStart(uint32_t ofs) { + vga.overopts.start = ofs; + vga.overopts.enable = true; +} + +void VGA_ResetDebugOverrides(void) { + vga.overopts.start = ~uint32_t(0ul); + vga.overopts.enable = false; +} + void VGA_CheckScanLength(void) { switch (vga.mode) { case M_EGA: