Skip to content

Commit

Permalink
Refactored Amiga::computeFrame()
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Dec 29, 2024
1 parent 869af7d commit e722936
Showing 1 changed file with 35 additions and 39 deletions.
74 changes: 35 additions & 39 deletions Emulator/Components/Amiga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,103 +835,99 @@ Amiga::computeFrame()
// Check if special action needs to be taken
if (flags) {

enum Action { cont, pause, leave } action = cont;

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

action = leave;
}

// Did we reach a soft breakpoint?
if (flags & RL::SOFTSTOP_REACHED) {
clearFlag(RL::SOFTSTOP_REACHED);

msgQueue.put(MSG_STEP);
throw StateChangeException(STATE_PAUSED);
break;
action = pause;
}

// Shall we stop at the end of the current line?
if (flags & RL::EOL_REACHED) {
clearFlag(RL::EOL_REACHED);

msgQueue.put(MSG_EOL_REACHED);
throw StateChangeException(STATE_PAUSED);
break;
action = pause;
}

// Shall we stop at the end of the current frame?
if (flags & RL::EOF_REACHED) {
clearFlag(RL::EOF_REACHED);

msgQueue.put(MSG_EOF_REACHED);
throw StateChangeException(STATE_PAUSED);
break;
action = pause;
}

// Did we reach a breakpoint?
if (flags & RL::BREAKPOINT_REACHED) {
clearFlag(RL::BREAKPOINT_REACHED);

auto addr = cpu.debugger.breakpoints.hit->addr;
msgQueue.put(MSG_BREAKPOINT_REACHED, CpuMsg { addr, 0 });
throw StateChangeException(STATE_PAUSED);
break;
action = pause;
}

// Did we reach a watchpoint?
if (flags & RL::WATCHPOINT_REACHED) {
clearFlag(RL::WATCHPOINT_REACHED);

auto addr = cpu.debugger.watchpoints.hit->addr;
msgQueue.put(MSG_WATCHPOINT_REACHED, CpuMsg { addr, 0 });
throw StateChangeException(STATE_PAUSED);
break;
action = pause;
}

// Did we reach a catchpoint?
if (flags & RL::CATCHPOINT_REACHED) {
clearFlag(RL::CATCHPOINT_REACHED);

auto vector = u8(cpu.debugger.catchpoints.hit->addr);
msgQueue.put(MSG_CATCHPOINT_REACHED, CpuMsg { cpu.getPC0(), vector });
throw StateChangeException(STATE_PAUSED);
break;
action = pause;
}

// Did we reach a software trap?
if (flags & RL::SWTRAP_REACHED) {
clearFlag(RL::SWTRAP_REACHED);

msgQueue.put(MSG_SWTRAP_REACHED, CpuMsg { cpu.getPC0(), 0 });
throw StateChangeException(STATE_PAUSED);
break;
action = pause;
}

// Did we reach a beam trap?
if (flags & RL::BEAMTRAP_REACHED) {
clearFlag(RL::BEAMTRAP_REACHED);

msgQueue.put(MSG_BEAMTRAP_REACHED, CpuMsg { 0, 0 });
throw StateChangeException(STATE_PAUSED);
break;
action = pause;
}

// Did we reach a Copper breakpoint?
if (flags & RL::COPPERBP_REACHED) {
clearFlag(RL::COPPERBP_REACHED);

auto addr = u8(agnus.copper.debugger.breakpoints.hit()->addr);
msgQueue.put(MSG_COPPERBP_REACHED, CpuMsg { addr, 0 });
throw StateChangeException(STATE_PAUSED);
break;
action = pause;
}

// Did we reach a Copper watchpoint?
if (flags & RL::COPPERWP_REACHED) {
clearFlag(RL::COPPERWP_REACHED);

auto addr = u8(agnus.copper.debugger.watchpoints.hit()->addr);
msgQueue.put(MSG_COPPERWP_REACHED, CpuMsg { addr, 0 });
throw StateChangeException(STATE_PAUSED);
break;
action = pause;
}

// Are we requested to terminate the run loop?
// Are we requested to pause the emulator?
if (flags & RL::STOP) {
clearFlag(RL::STOP);
throw StateChangeException(STATE_PAUSED);
break;
}

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

flags = 0;

if (action == pause) { throw StateChangeException(STATE_PAUSED); }
if (action == leave) { break; }
}
}
}
Expand Down

0 comments on commit e722936

Please sign in to comment.