Skip to content

Commit

Permalink
Work on setHSTRT (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Dec 30, 2023
1 parent f3558eb commit b59650f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
48 changes: 46 additions & 2 deletions Emulator/Components/Denise/Denise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Emulator/Components/Denise/DeniseRegs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
BreakpointExtensionID = "Xcode.Breakpoint.RuntimeIssueBreakpoint">
<BreakpointContent
uuid = "1C34E446-9F03-4ADF-999F-3C4F93560618"
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
breakpointStackSelectionBehavior = "1"
Expand Down Expand Up @@ -108,7 +108,7 @@
BreakpointExtensionID = "Xcode.Breakpoint.RuntimeIssueBreakpoint">
<BreakpointContent
uuid = "E2606246-83A4-48C5-BC45-5FA47C77CC7E"
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
breakpointStackSelectionBehavior = "1"
Expand Down Expand Up @@ -179,7 +179,7 @@
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "9F889B32-39C8-498F-AFC3-14E8073A26C8"
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Emulator/Components/CPU/Moira/Moira.cpp"
Expand Down

0 comments on commit b59650f

Please sign in to comment.