• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[ASM & Hex] Making VBA-SDL-H break on write at a certain value?

  • 13
    Posts
    7
    Years
    • Seen Sep 12, 2019
    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!
     
    Last edited:

    Touched

    Resident ASMAGICIAN
  • 625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    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.
     
  • 13
    Posts
    7
    Years
    • Seen Sep 12, 2019
    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
  • 625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    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).
     
  • 13
    Posts
    7
    Years
    • Seen Sep 12, 2019
    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.
     
    Back
    Top