Post subject: [Lua] How to detect a write to a mapper register
SusiKette
He/Him
Joined: 6/11/2017
Posts: 6
Location: Finland
I want to create a script that hits a breakpoint when a certain value is written to a mapper register. I don't think the official documentation mentioned anything about mapper registers, at least not in the function list. Basically it would be something like this:
if((written_value AND 7) == 6 || (written_value AND 7) == 7) then
  debugger.hitbreakpoint();
  written_value = 0;
end;
The value written to the $8000 would be saved to "written_value". even if this wouldn't work as is, it should give a good idea on what I'm trying to do. If it is possible to actually create a breakpoint condition in the debugger that does the same thing, it'll do just as well.
Site Admin, Skilled player (1255)
Joined: 4/17/2010
Posts: 11495
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
What is a mapper register?
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
SusiKette
He/Him
Joined: 6/11/2017
Posts: 6
Location: Finland
Not sure if you are trolling or something, but take a look at this link: https://wiki.nesdev.com/w/index.php/MMC3#Registers It is for the MMC3 memory mapper and it clearly has registers. The NES has some too. Such as $2000, $2001 and $2002
Site Admin, Skilled player (1255)
Joined: 4/17/2010
Posts: 11495
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Currently fceux can only set breakpoints on things mapped to memory. I just tried $8000 with Alien 3, and write breakpoint worked just fine. If you're sure some mapper register exists in memory, but its breakpoints don't work, we can fix that I think. And to grab the value that's being written, just fetch Accumulator's value the usual way (memory.getregister("a")).
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.