dirkwhoffmann / virtualc64

VirtualC64 is a cycle-accurate C64 emulator for macOS
https://dirkwhoffmann.github.io/virtualc64
Other
342 stars 33 forks source link

Emulate a BRK instruction when a breakpoint is reached #773

Closed dirkwhoffmann closed 5 months ago

dirkwhoffmann commented 8 months ago

Would it be possible to allow for the dynamic breakpoints set by the emulator to cause the same effects in the processors emulation code as the execution of the BRK opcode? This could be an alternative option to be set in the preferences/inspector to the current "time freeze" of the whole system. This would allow then to break into a native debugger/monitor (e.g. from a cartridge)...

dirkwhoffmann commented 6 months ago

To get started, I've added a new menu item, Edit->BRK, which simulates the execution of a BRK command. To test, I've started Final Cartridge III and entered the monitor via MON:

Bildschirmfoto 2024-01-21 um 15 39 46

Now, selecting BRK from the Edit menu results in the following:

Bildschirmfoto 2024-01-21 um 15 39 51

@cfwdman Is this the expected behavior? If yes, the only remaining task is letting the breakpoint handler do the same as the menu item.

dirkwhoffmann commented 6 months ago

Additional thoughts: The intended behavior (entering the debugger when reaching a breakpoint) can already be achieved like so:

  1. Set a breakpoint The emulator will pause when the breakpoint is reached
  2. Choose Edit->BRK
  3. Hit Run The debugger will be entered at the desired position.

Yes, it's two additional steps (steps 2 and 3), but I prefer not to add yet another configuration option. With every new option, the emulator gets bloated more and more, which I'd like to avoid. I want to keep the emulator as lean as possible.

dirkwhoffmann commented 5 months ago

Fixed in v4.7b1