Skip to content

Commit

Permalink
CRITICAL: Added RL::SYNC_THREAD flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jan 23, 2024
1 parent bfcf746 commit 15ecc3d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
24 changes: 9 additions & 15 deletions Emulator/Components/C64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,11 @@ C64::execute()
cpu.reg.pc0 = cpu.reg.pc - 1;
}

// Are we requested to synchronize the thread?
if (flags & RL::SYNC_THREAD) {
clearFlag(RL::SYNC_THREAD);
}

assert(flags == 0);
}
}
Expand Down Expand Up @@ -1369,16 +1374,10 @@ C64::stepOver()

void
C64::executeOneFrame()
{
do { executeOneLine(); } while (scanline != 0 && flags == 0);
}

void
C64::executeOneLine()
{
isize lastCycle = vic.getCyclesPerLine();

while (1) {
do {

Cycle cycle = ++cpu.clock;

Expand Down Expand Up @@ -1418,22 +1417,17 @@ C64::executeOneLine()
if (rasterCycle++ == lastCycle) {

endScanline();
return;
if (scanline == 0) setFlag(RL::SYNC_THREAD);
}

// Exit the loop if an action flag is set
if (flags != 0) {

return;
}
}
} while (!flags);
}

void
C64::executeOneCycle()
{
setFlag(RL::STOP);
executeOneLine();
executeOneFrame();
clearFlag(RL::STOP);
}

Expand Down
7 changes: 1 addition & 6 deletions Emulator/Components/C64.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,7 @@ class C64 : public Thread {
* the C64 is emulated until the curent frame has been completed.
*/
void executeOneFrame();

/* Emulates the C64 until the end of the current scanline. This function
* is called inside executeOneFrame().
*/
void executeOneLine();


// Executes a single clock cycle
void executeOneCycle();

Expand Down
23 changes: 12 additions & 11 deletions Emulator/Components/C64Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,17 +366,18 @@ typedef u32 RunLoopFlags;

namespace RL
{
constexpr u32 STOP = 0b00000000001;
constexpr u32 INSPECT = 0b00000000010;
constexpr u32 WARP_ON = 0b00000000100;
constexpr u32 WARP_OFF = 0b00000001000;
constexpr u32 BREAKPOINT = 0b00000010000;
constexpr u32 WATCHPOINT = 0b00000100000;
constexpr u32 AUTO_SNAPSHOT = 0b00001000000;
constexpr u32 USER_SNAPSHOT = 0b00010000000;
constexpr u32 CPU_JAM = 0b00100000000;
constexpr u32 EXTERNAL_NMI = 0b01000000000;
constexpr u32 EXTERNAL_BRK = 0b10000000000;
constexpr u32 STOP = (1 << 0);
constexpr u32 INSPECT = (1 << 1);
constexpr u32 WARP_ON = (1 << 2);
constexpr u32 WARP_OFF = (1 << 3);
constexpr u32 BREAKPOINT = (1 << 4);
constexpr u32 WATCHPOINT = (1 << 5);
constexpr u32 AUTO_SNAPSHOT = (1 << 6);
constexpr u32 USER_SNAPSHOT = (1 << 7);
constexpr u32 CPU_JAM = (1 << 8);
constexpr u32 EXTERNAL_NMI = (1 << 9);
constexpr u32 EXTERNAL_BRK = (1 << 10);
constexpr u32 SYNC_THREAD = (1 << 11);
};

#endif

0 comments on commit 15ecc3d

Please sign in to comment.