• 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.

Help Thread: ASM & Disassembly

Status
Not open for further replies.

Lance32497

LanceKoijer of Pokemon_Addicts
792
Posts
9
Years
  • Hello guys, I want to ask this,
    str stores the value of a certain register into a register
    while add adds a byte in a certain register

    so let's say r0 has 0x020370b8
    ldr r0, =(0x020370B8)
    ldr r1, =(0x0880EE4A)
    ldrb r1, [r1]
    ldrb r0, [r0]
    strb r0, [r1]

    so it means that by doing that, 0x020370B8 has 0x4A

    while
    ldr r0, =(0x020370B8)
    ldrb r0, [r0]
    add r0, r0, #0x5

    so it means that by doing that, r0 is now 0x020370BD

    correct me if I'm wrong
     

    daniilS

    busy trying to do stuff not done yet
    409
    Posts
    10
    Years
    • Seen Jan 29, 2024
    Hello guys, I want to ask this,
    str stores the value of a certain register into a register
    while add adds a byte in a certain register

    so let's say r0 has 0x020370b8
    ldr r0, =(0x020370B8)
    ldr r1, =(0x0880EE4A)
    ldrb r1, [r1]
    ldrb r0, [r0]
    strb r0, [r1]

    so it means that by doing that, 0x020370B8 has 0x4A

    while
    ldr r0, =(0x020370B8)
    ldrb r0, [r0]
    add r0, r0, #0x5

    so it means that by doing that, r0 is now 0x020370BD

    correct me if I'm wrong

    nnnnnope.
    ldrb loads a byte from an address into a certain register. and stop trying to write to the rom, it's not gonna work.
     
    218
    Posts
    10
    Years
    • Seen Nov 12, 2021
    Hello guys, I want to ask this,
    str stores the value of a certain register into a register
    while add adds a byte in a certain register

    so let's say r0 has 0x020370b8
    ldr r0, =(0x020370B8)
    ldr r1, =(0x0880EE4A) Here you load a ROM address, as mentioned above it means "Read Only Memory". You cannot right something in here. Just let you know.
    ldrb r1, [r1] Here you load a byte in r1, so r1 doesn't contain a pointer anymore. Actually pointer are just numbers, but it would look like "000000XX" which point to nothing relevant AFAIK.
    ldrb r0, [r0]
    strb r0, [r1] So here you write a byte at the address "000000XX", which I don't even know if it's possible.

    so it means that by doing that, 0x020370B8 has 0x4A Actually you didn't change what was wrote at 0x020370B8 as I explained.

    while
    ldr r0, =(0x020370B8)
    ldrb r0, [r0] again, you load a byte into r0, so let's suppose at 0x020370B8 there was 0x24 wrote, r0 contain now 0x24.
    add r0, r0, #0x5 By adding 0x5 it hold now 0x29

    so it means that by doing that, r0 is now 0x020370BD And not that

    correct me if I'm wrong

    Responses in bold.

    Ninja-ed, thanks daniilS.
     
    Last edited:

    Lance32497

    LanceKoijer of Pokemon_Addicts
    792
    Posts
    9
    Years
  • Hello guys, I'm trying to build a routine that lets the Var 8000 edit thePokémon data substructures(Bulbapedia term)
    .... I had read the entire site but I can't find the RAM Address of that Pokemon Data substructure
     

    Lance32497

    LanceKoijer of Pokemon_Addicts
    792
    Posts
    9
    Years
  • Hello guys, I'm trying to build a routine that lets the Var 8000 edit thePokémon data substructures(Bulbapedia term)
    .... I had read the entire site but I can't find the RAM Address of that Pokemon Data substructure
     
    218
    Posts
    10
    Years
    • Seen Nov 12, 2021
    Hello guys, I'm trying to build a routine that lets the Var 8000 edit thePokémon data substructures(Bulbapedia term)
    .... I had read the entire site but I can't find the RAM Address of that Pokemon Data substructure

    Use the FBI's routine in the ASM resource thread. For the substructure it's wrote in bulbapedia, something like 0x020244EC for emerald if I remember well
     
    417
    Posts
    9
    Years
    • Seen Nov 20, 2016
    Hello guys, I'm trying to build a routine that lets the Var 8000 edit thePokémon data substructures(Bulbapedia term)
    .... I had read the entire site but I can't find the RAM Address of that Pokemon Data substructure

    Are you just asking how to edit things in it like IVs? Because if that's the case, there's no reason to "build a routine," as a vanilla rom already has it built in. You can just move/load to a few registers then call it. I'm on a phone now so I can't give it to you right now, but I could give it to you the next time I'm on my computer/ you could probably find it with a quick google.

    Also, what do you mean by "that" RAM address? There are six party slots and 30 pokemon in each box.
     
    Last edited:

    GoGoJJTech

    (☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)
    2,475
    Posts
    11
    Years
  • Hello guys, I'm trying to build a routine that lets the Var 8000 edit thePokémon data substructures(Bulbapedia term)
    .... I had read the entire site but I can't find the RAM Address of that Pokemon Data substructure

    Pokémon data tables are not copied to RAM, they're read from the ROM. You can't change them in real time because you can't edit them from the game. (Obviously)

    You may want to have a special case of reading a different piece of data or something. But I'm here to tell you that what you're doing is impossible by normal means.
     

    Lance32497

    LanceKoijer of Pokemon_Addicts
    792
    Posts
    9
    Years
  • The reason why I'm looking for that is for the pokemon current experience, anyway please forgive me if this routine I created is too dumb, I'm trying to create a routine that var 8004 is the slot number, 8005 is the Stat 0 is Current HP, 1 is Total HP, 2 is Attack and so on, then in 8006 is XXYY where XX can be only be 00(Add YY) or 01(Subtract YY) and YY is the value to add or subtract
    But yeah, when I call it in a script, the game freezes
    Spoiler:
     
    Last edited:

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    The reason why I'm looking for that is for the pokemon current experience, anyway please forgive me if this routine I created is too dumb, I'm trying to create a routine that var 8004 is the slot number, 8005 is the Stat 0 is Current HP, 1 is Total HP, 2 is Attack and so on, then in 8006 is XXYY where XX can be only be 00(Add YY) or 01(Subtract YY) and YY is the value to add or subtract
    But yeah, when I call it in a script, the game freezes
    Spoiler:

    So much is wrong with this - the cause for the freeze being the least worrying. You label stuff as loops, yet they don't loop? Anyway, your main problem is you push more than you pop, thus causing stack corruption.

    Please comment what you think you are doing so I can correct it - I can't guess what this is supposed to do without comments.
     

    Lance32497

    LanceKoijer of Pokemon_Addicts
    792
    Posts
    9
    Years
  • So much is wrong with this - the cause for the freeze being the least worrying. You label stuff as loops, yet they don't loop? Anyway, your main problem is you push more than you pop, thus causing stack corruption.

    Please comment what you think you are doing so I can correct it - I can't guess what this is supposed to do without comments.

    am already put the comment
     
    23
    Posts
    9
    Years
    • Seen Sep 2, 2015
    The reason why I'm looking for that is for the pokemon current experience, anyway please forgive me if this routine I created is too dumb, I'm trying to create a routine that var 8004 is the slot number, 8005 is the Stat 0 is Current HP, 1 is Total HP, 2 is Attack and so on, then in 8006 is XXYY where XX can be only be 00(Add YY) or 01(Subtract YY) and YY is the value to add or subtract
    But yeah, when I call it in a script, the game freezes
    Spoiler:


    Spoiler:
     

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    #1: Since r4 won't be used, IMO {r0-r3,lr/pc} is safer. You should check available bytes in SP first
    #2: This step is redundant.
    #3: IIRC, it's 2 byte per stat, so you should multiply r3 by 2 first.
    #4: r1 isn't usable due to #3. Use r0 instead.
    #5: The value in r1 should be loaded first into r3 (ldrh). Then, use sub/add r3, r3, r0 instead, assuming you're using r0 and r3 as I've mentioned.
    #6: At this rate, you should store the value of r3 into r1 (strh instead of strb). Also, put r3 between limit (0 - 999) before storing them.

    #1: If he doesn't use R4 he doesn't need to push/pop any registers...
     

    daniilS

    busy trying to do stuff not done yet
    409
    Posts
    10
    Years
    • Seen Jan 29, 2024
    You're right, assuming that r0 - r3 aren't used every time he calls this routine.

    It's not assuming, it's a standard. And may I ask how on earth you would check available space on the stack?
     
    23
    Posts
    9
    Years
    • Seen Sep 2, 2015
    It's not assuming, it's a standard. And may I ask how on earth you would check available space on the stack?
    Since the only pokemon game I've ever hacked is R/S, I don't have any good example. In other GBA games, there are times where I need to push some registers (r0-r3) to insert a routine. I'm putting those just for insurance.

    To check the availability of the stack, I'm checking all routines before and after this function. A function with SP modifying instruction can limit the space on the stack. If he calls the function inside a SP modifying function, there is a chance that pushing will overwrite important data.
     
    Last edited:
    Status
    Not open for further replies.
    Back
    Top