Trigger breakpoint on PRG bank swap
Moderator: Moderators
Trigger breakpoint on PRG bank swap
Is there a way to make breakpoint in FCEUX that gets triggered when the game swaps PRG banks? If it is any of help, I believe the game in question uses MMC3 (iNES 004 iirc).
Avatar is pixel art of Noah Prime from Astral Chain
Re: Trigger breakpoint on PRG bank swap
A write breakpoint on $8000-$9FFF will catch all MMC3 bank switching, but this includes CHR bank switching as well.
- rainwarrior
- Posts: 8732
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Trigger breakpoint on PRG bank swap
The debugger doesn't directly have functionality for tracking internal mapper registers, so with something like MMC3 where the internal register gets selected first you can't really do it with a single breakpoint.
However, an execution breakpoint on $8000-FFFF (or any suitable range) with the condition K==#5 will break whenever PRG bank 5 starts executing, that would break on the instruction after the write for that specific bank, for example. (On Mesen you could step backward from here, on FCEUX you'd probably want to start a trace first, then read backward in the trace log from there.)
Another way to do it is keep track of the internal register writes with a Lua script, and have the Lua script call debugger.hitbreakpoint() when it sees the write you want. (Can also do something similar in Mesen, I believe.)
However, an execution breakpoint on $8000-FFFF (or any suitable range) with the condition K==#5 will break whenever PRG bank 5 starts executing, that would break on the instruction after the write for that specific bank, for example. (On Mesen you could step backward from here, on FCEUX you'd probably want to start a trace first, then read backward in the trace log from there.)
Another way to do it is keep track of the internal register writes with a Lua script, and have the Lua script call debugger.hitbreakpoint() when it sees the write you want. (Can also do something similar in Mesen, I believe.)
Re: Trigger breakpoint on PRG bank swap
This might be the best option. For now I only want to know when the game swaps PRG banks if at all. CHR bank swaps are usually easier to figure out since they appear on PPU Viewer.rainwarrior wrote: Another way to do it is keep track of the internal register writes with a Lua script, and have the Lua script call debugger.hitbreakpoint() when it sees the write you want.
And just to confirm: PRG swapping works as follow:
-first write a value to $8000 that has either 6 or 7 written on the bits 0-2
-write the bank number to $8001
-7 will always swap the bank at $A000-$BFFF
-6 will swap the bank at $8000-$9FFF if the value written to $8000 has the 6th bit cleared. If it's set, the swap is done at $C000-$DFFF
Avatar is pixel art of Noah Prime from Astral Chain