I'll add another more generic script here, which I called "new-code-finder". I could identify the "should the camera now scroll" section with it.
The idea is simple: The game does certain kinds of logic checks like "should we now start with the jump sequence?". As long as you don't jump at all, this code won't be executed, but all sort of other code (draw enemies, move camera, die, show gameover screen, menu selection) will.
This script will therefore work the following way:
- start it, and do everything you can think of EXCEPT that thing where you want to find the executed code for.
- press F11
- now do the right action (for example jump)
- the script pauses the emulator now
- open the debugger, and try to understand what happens now....
Alternatively, it allows you to create a textfile which lists how often code at specific memory addresses got executed by pressing "numpad/". For example, if you know (or guess) that a specific code region should have been executed exactly 17 times, you would look into the textfile and see which codes have been executed at least 17 times.
Limitations: Most NES games use mappers, and the script has no way to know which part of the ROM is currently visible to the NES, making the "count" part quite unreliable.
Here it is (consider it a WIP)