Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registering a hook to change PC to the previous instruction doesn't properly advance 'tick' #332

Open
VariantXYZ opened this issue Jun 22, 2024 · 0 comments
Labels

Comments

@VariantXYZ
Copy link

While trying to see if I could emulate breakpoint behavior in PyBoy using hooks, I found that setting the hook to one instruction ahead and changing PC to the instruction I actually wanted to hook was causing tick to never return.

Specifically, in my disassembly of Medarot 3:

from pyboy import PyBoy
def breakpoint(p):
     p.register_file.PC = p.symbol_lookup("Main.mainGameLoop")[1]

pyboy = PyBoy('medarot3_kabuto.gbc', symbols='medarot3_kabuto.sym')
pyboy.hook_register(0, pyboy.symbol_lookup("Main.mainGameLoop")[1] + 1, breakpoint, pyboy)
pyboy.tick(100)

where Main.mainGameLoop is defined as:

xor a
ld [$c4d9], a
call Function
...

If I instead opt to have my breakpoint at +4 (at the call instead), tick seems to properly return.

This Tick behavior seems to be unintended or undefined, but if it is intended, then I think it would be useful to have it documented.

@Baekalfen Baekalfen added the bug label Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants