Male
Seen September 12th, 2019
Posted October 23rd, 2017
13 posts
3.5 Years
Not sure if I've expressed what I'm trying to do correctly in the title, so here's the scenario -

I'm looking into how running shoes work as I want to modify how the player's overworld frames are loaded. There's a value at 0x2037078 that changes depending on how the player is moving. When the player is stood still or walking it's set to 0x1 and when they're running (specifically when the B button is held and the player is moving) it's set to 0x81. I'm trying to change how this works, so that the player doesn't need to be moving and just needs to hold B to set this value to 0x81 and be "running". The end goal here is to replace the player's running frames with them riding a bicycle and have them appear on the bicycle whenever B is held, rather than when B and a directional button is held.

To get back to the point, I'm trying to find the routine that sets 0x2037078 to 0x81 so I can modify it. I've got VBA-SDL-H open but can't cause it to break when it's equal to 0x81, it just breaks as soon as the emulator starts again (I'm assuming because it's constantly being set to 0x1 when the player isn't running). I'm quite new to ASM and I thought this seemed like a simple beginner project, apologies if I'm missing something obvious here. Thank you!

Touched

Resident ASMAGICIAN

Male
Seen February 1st, 2018
Posted October 19th, 2017
626 posts
6 Years
Not sure if I've expressed what I'm trying to do correctly in the title, so here's the scenario -

I'm looking into how running shoes work as I want to modify how the player's overworld frames are loaded. There's a value at 0x2037078 that changes depending on how the player is moving. When the player is stood still or walking it's set to 0x1 and when they're running (specifically when the B button is held and the player is moving) it's set to 0x81. I'm trying to change how this works, so that the player doesn't need to be moving and just needs to hold B to set this value to 0x81 and be "running". The end goal here is to replace the player's running frames with them riding a bicycle and have them appear on the bicycle whenever B is held, rather than when B and a directional button is held.

To get back to the point, I'm trying to find the routine that sets 0x2037078 to 0x81 so I can modify it. I've got VBA-SDL-H open but can't cause it to break when it's equal to 0x81, it just breaks as soon as the emulator starts again (I'm assuming because it's constantly being set to 0x1 when the player isn't running). I'm quite new to ASM and I thought this seemed like a simple beginner project, apologies if I'm missing something obvious here. Thank you!
That is called a conditional breakpoint and I don't think it is supported by VBA-SDL-H. I'm pretty sure mGBA has support for these, but I'm not sure if you can get the console debugger to do it (it might only be via GDB, which is complex to set up)

That being said I think you're going about this the wrong way. The value you speak of holds a lot more than just the running state - it's actually a bitfield that controls initiating and continuing movement (to check whether to actually move you or just to change the direction you're facing or whatever).

You should instead try modify the routine that controls button presses to enable/disable the bike as you press/release B.

A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.
Male
Seen September 12th, 2019
Posted October 23rd, 2017
13 posts
3.5 Years
That is called a conditional breakpoint and I don't think it is supported by VBA-SDL-H. I'm pretty sure mGBA has support for these, but I'm not sure if you can get the console debugger to do it (it might only be via GDB, which is complex to set up)

That being said I think you're going about this the wrong way. The value you speak of holds a lot more than just the running state - it's actually a bitfield that controls initiating and continuing movement (to check whether to actually move you or just to change the direction you're facing or whatever).

You should instead try modify the routine that controls button presses to enable/disable the bike as you press/release B.
Thanks for your reply, I've been looking into this all morning and I've decided it must be done a different way. How would I go about finding/hacking this routine? I haven't been able to find many leads myself but your way seems to make a lot of sense.

Touched

Resident ASMAGICIAN

Male
Seen February 1st, 2018
Posted October 19th, 2017
626 posts
6 Years
Thanks for your reply, I've been looking into this all morning and I've decided it must be done a different way. How would I go about finding/hacking this routine? I haven't been able to find many leads myself but your way seems to make a lot of sense.
There is a function called "player_step_by_keypad" (0805B4D4 in fire red) which is called every frame by the main overworld callback handler. It eventually calls 080BD100 (walkrun_accelerate2) which checks if B is pressed 080BD14E, and if so, sets some values in the structure at 02037078.

Set a breakpoint at 080BD14E to check that this is the correct location (ensure that this section runs only when the player is holding B while moving).

If this is the correct location, you should modify this so that it does not set these bits, instead calling a custom routine that toggles the players current biking state. I think this is a special or something, but check the ASM code that is called by the bike item (look in an item editor).

A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.
Male
Seen September 12th, 2019
Posted October 23rd, 2017
13 posts
3.5 Years
There is a function called "player_step_by_keypad" (0805B4D4 in fire red) which is called every frame by the main overworld callback handler. It eventually calls 080BD100 (walkrun_accelerate2) which checks if B is pressed 080BD14E, and if so, sets some values in the structure at 02037078.

Set a breakpoint at 080BD14E to check that this is the correct location (ensure that this section runs only when the player is holding B while moving).

If this is the correct location, you should modify this so that it does not set these bits, instead calling a custom routine that toggles the players current biking state. I think this is a special or something, but check the ASM code that is called by the bike item (look in an item editor).
Fantastic, thank you so much! If I can make something that I'm happy with I'll share it in the ASM resource thread.