From b59650f997008d1368beec159e61ec03f53e0023 Mon Sep 17 00:00:00 2001 From: Dirk Hoffmann Date: Sat, 30 Dec 2023 12:14:44 +0100 Subject: [PATCH] Work on setHSTRT (#799) --- Emulator/Components/Denise/Denise.cpp | 48 ++++++++++++++++++- Emulator/Components/Denise/DeniseRegs.cpp | 2 +- .../xcdebugger/Breakpoints_v2.xcbkptlist | 6 +-- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/Emulator/Components/Denise/Denise.cpp b/Emulator/Components/Denise/Denise.cpp index b99fc58c4..13986569f 100644 --- a/Emulator/Components/Denise/Denise.cpp +++ b/Emulator/Components/Denise/Denise.cpp @@ -1005,7 +1005,7 @@ Denise::updateBorderColor() void Denise::drawBorder() { - /* The following cases need to be distinguished: + /* The following cases must be distinguished: * * (1) No border 1 -------------------- * flop && !off 0 @@ -1027,6 +1027,36 @@ Denise::drawBorder() bool on = hflopOnPrev != INT16_MAX; bool off = hflopOffPrev != INT16_MAX; + isize hblank = 4 * HBLANK_MIN; + + // EXPERIMENTAL + + if (on && off && hflopOnPrev > hflopOffPrev) { + + if (!flop) { + + trace(true, "ECS feature (!flop): %ld %ld\n", hflopOnPrev, hflopOffPrev); + // Draw left border + auto end = std::min(2 * hflopOnPrev - hblank, isize(HPIXELS + 1)); + for (isize i = 0; i < end; i++) { + bBuffer[i] = iBuffer[i] = mBuffer[i] = borderColor; + } + + } else { + + trace(true, "ECS feature (flop): %ld %ld\n", hflopOnPrev, hflopOffPrev); + + // Draw border in the middle + auto start = std::max(2 * hflopOffPrev - hblank, isize(0)); + auto end = std::min(2 * hflopOnPrev - hblank, isize(HPIXELS + 1)); + for (isize i = start; i < end; i++) { + bBuffer[i] = iBuffer[i] = mBuffer[i] = 0; + } + } + return; + } + + if (!flop && !on) { // Draw blank line (2) @@ -1260,7 +1290,21 @@ Denise::eolHandler() hflopOffPrev = hflopOff; // Update the horizontal DIW flipflop - hflop = (hflopOff != INT16_MAX) ? false : (hflopOn != INT16_MAX) ? true : hflop; + // + // hflopOn | hflopOff | hFlop + // ---------------------------------------- + // in range | in range | hflopOn > hflopOff + // in range | inf | true + // inf | in range | false + // inf | inf | hflop + // + // hflop = (hflopOff != INT16_MAX) ? false : (hflopOn != INT16_MAX) ? true : hflop; + if (hflopOn != INT16_MAX) { + hflop = (hflopOff != INT16_MAX) ? (hflopOn > hflopOff) : true; + } else { + hflop = (hflopOff != INT16_MAX) ? hflop : false; + } + hflopOn = denise.hstrt; hflopOff = denise.hstop; } diff --git a/Emulator/Components/Denise/DeniseRegs.cpp b/Emulator/Components/Denise/DeniseRegs.cpp index bd020f239..4e73cfd51 100644 --- a/Emulator/Components/Denise/DeniseRegs.cpp +++ b/Emulator/Components/Denise/DeniseRegs.cpp @@ -58,7 +58,7 @@ void Denise::setHSTRT(isize val) { // Invalidate the coordinate if it is out of range - if (val < 2 || val > 0x1C7) { + if ((val < 2 || val > 0x1C7) && agnus.pos.v > 8) { trace(DIW_DEBUG, "setHSTRT: %ld is out of range\n", val); val = INT16_MAX; diff --git a/vAmiga.xcodeproj/xcuserdata/hoff.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/vAmiga.xcodeproj/xcuserdata/hoff.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index ba11fc498..95333c575 100644 --- a/vAmiga.xcodeproj/xcuserdata/hoff.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/vAmiga.xcodeproj/xcuserdata/hoff.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -80,7 +80,7 @@ BreakpointExtensionID = "Xcode.Breakpoint.RuntimeIssueBreakpoint">