• 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.
325
Posts
10
Years
  • I can't even tell what you are trying to do, but I'll do my best. It looks as though you are loading a ROM offset rather than an address. ROM is prefixed by 08/09, you have prefixed it with 00 (BIOS). In fact this address is invalid and will be ignored by VBA - the bios is only 16kb. Hardware will do weird things.

    Next, you load two half words, add 5, then load the addresses again? Why? I think what you are trying to do is store to those addresses, but you'd need str, strh or strb to do that. If I'm right about these being ROM offsets, then you clearly don't understand the concept of ROM. You can't right to it. Ever. There are a few bytes of ROM address space reserved for GPIO for sensors, and this is the only exception.

    Lastly, you're wasting stack space. Neither R0, R1 or LR need to be pushed.

    I suggest you read some tutorials and look at existing code so you actually understand what you're doing, rather than fumbling around in the dark.
    Ah well, had to start somewhere, even if it was 'get good scrub'.
    Thank you for the information on the ROM offsets. I actually had no idea that it had to be 08. And I think I understand that more now, thanks.
     
    45
    Posts
    14
    Years
    • Seen May 20, 2015
    Guys I need your help.

    I inserted FBI's set party level routine in my rom and it worked perfectly.
    Here's the routine:
    Spoiler:


    However, I would like to create a variation of this.
    I would simply like to be able to set level of pokes individually.

    I am re-learning asm, had it in college, and I do understand most of it, but still inexperienced to do a whole routine on my own.

    The way to solve my prob is simply have 2 inputs
    1 - the index of the poke to set the level
    2 - the level it shall be set to

    And, I can't follow FBI's routine since I don't know where the pointers point to.

    And also, would it be possible to set by experience points?

    Ex. Lv 5 Pikachu with 50 extra exp
    -set to Lv 30 Pikachu (0 extra exp)
    -set back to Lv 5 with the 50 extra exp
    Idea is temporarily set the Poke to a certain level.
     

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    Guys I need your help.

    I inserted FBI's set party level routine in my rom and it worked perfectly.
    Here's the routine:
    Spoiler:


    However, I would like to create a variation of this.
    I would simply like to be able to set level of pokes individually.

    I am re-learning asm, had it in college, and I do understand most of it, but still inexperienced to do a whole routine on my own.

    The way to solve my prob is simply have 2 inputs
    1 - the index of the poke to set the level
    2 - the level it shall be set to

    And, I can't follow FBI's routine since I don't know where the pointers point to.

    And also, would it be possible to set by experience points?

    Ex. Lv 5 Pikachu with 50 extra exp
    -set to Lv 30 Pikachu (0 extra exp)
    -set back to Lv 5 with the 50 extra exp
    Idea is temporarily set the Poke to a certain level.

    Get yourself a copy of IDA and knizz's IDB for FireRed if you want to see what those addresses are. You can set Exp using the same function he uses there actually.

    You just need to remove the loop in that code to do what you want.

    FBI doesn't seem to label his addresses ever so it's understandable that you got stuck

    0x2024029 - Number of pokemon in the party
    0x2024284 - First party pokemon. This is an array of up to 6 entries long. Each entry is 100 (0x64) bytes

    I assume the rest figures out the EXP needed to attain the target level and then recalculates the level based on EXP curves, but I haven't read it.
     
    45
    Posts
    14
    Years
    • Seen May 20, 2015
    I modified FBI's routine to the one below and got it to work. However, I still would like to learn what the computation does, what does linker link to, etc, if anyone can elaborate. It doesn't feel comfortable running a program that works but you don't know how ~_~

    Also, I'd like to have another input for the index of the pokemon to be changed (highlighted in bold)
    What are the possible variables that can be used as input? aside from 0x8000 and what are their addresses?

    Spoiler:
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • I modified FBI's routine to the one below and got it to work. However, I still would like to learn what the computation does, what does linker link to, etc, if anyone can elaborate. It doesn't feel comfortable running a program that works but you don't know how ~_~

    Also, I'd like to have another input for the index of the pokemon to be changed (highlighted in bold)
    What are the possible variables that can be used as input? aside from 0x8000 and what are their addresses?

    Spoiler:


    Commented, and removed stupid pushes/pops. For explanations of what bl linker is, read my ASM tutorial about function calling :)
     

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    Spoiler:


    Commented, and removed stupid pushes/pops. For explanations of what bl linker is, read my ASM tutorial about function calling :)

    Please. Please. Please. Never use MUL unless you really need to. Powers of two can be expressed as LSL, which is both shorter and faster.

    Code:
    @ BAD FBI
    mov r3, #0x4
    mul r1, r1, r3
    
    @ Good
    lsl r1, #2

    I modified FBI's routine to the one below and got it to work. However, I still would like to learn what the computation does, what does linker link to, etc, if anyone can elaborate. It doesn't feel comfortable running a program that works but you don't know how ~_~

    Also, I'd like to have another input for the index of the pokemon to be changed (highlighted in bold)
    What are the possible variables that can be used as input? aside from 0x8000 and what are their addresses?

    Spoiler:

    The variables 0x8000 - 0x800F can be referenced by their memory address as expressed in the literal pool there (0x020270B8 + (0x8000 *2)). This can calculate the correct address for those variables. Other variables are DMA protected and thus it is recommended that you use the engine function to get their values. For simple script input, the 0x8000 series is better.

    Again, look at the IDB - it will explain most of these questions about the locations of stuff.
     
    Last edited:

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • Please. Please. Please. Never use MUL unless you really need to. Powers of two can be expressed as LSL, which is both shorter and faster.

    Code:
    @ BAD FBI
    mov r3, #0x4
    mul r1, r1, r3
    
    @ Good
    lsl r1, #2



    The variables 0x8000 - 0x800F can be referenced by their memory address as expressed in the literal pool there (0x020270B8 + (0x8000 *2)). This can calculate the correct address for those variables. Other variables are DMA protected and thus it is recommended that you use the engine function to get their values. For simple script input, the 0x8000 series is better.

    Again, look at the IDB - it will explain most of these questions about the locations of stuff.

    Don't blame me, this routine was written back in my early days :P
     
    45
    Posts
    14
    Years
    • Seen May 20, 2015
    Thanks FBI. ^^ ^^ ^^ ^^ ^^

    Touched,
    Ya, I've read that too in one of FBI's tutorial, about lsl/lsr being faster when multiplying by powers of two.
    So I can just replace 0x8000 with any 0x8 series variable? Are all of them temporary ones? How about the addresses of 0x4011 onward variables, the safe ones?
    Also I downloaded the IDB in your sig but I don't know how to use it -_- it opens in Visual Studio but displays hex values.

    I want to know the other routines FBI's routine links to because I would like to make a variation of it that sets the exp not the level. And also the I want to know the addresses of tables such as the experience table. If it's in the IDB, how do you use it?

    Again, thanks
     
    Last edited:

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    Thanks FBI. ^^ ^^ ^^ ^^ ^^

    Touched,
    Ya, I've read that too in one of FBI's tutorial, about lsl/lsr being faster when multiplying by powers of two.
    So I can just replace 0x8000 with any 0x8 series variable? Are all of them temporary ones? How about the addresses of 0x4011 onward variables, the safe ones?
    Also I downloaded the IDB in your sig but I don't know how to use it -_- it opens in Visual Studio but displays hex values.

    I want to know the other routines FBI's routine links to because I would like to make a variation of it that sets the exp not the level. And also the I want to know the addresses of tables such as the experience table. If it's in the IDB, how do you use it?

    Again, thanks

    The 0x8000 series are special, and seem to be designed to be accessed easily from code without the need for a function call. The other variables need this function call. It's the same function used by the code for setvar and other variable related script functions.

    As daniilS said, you need to download IDA to open the IDB.
     

    Joexv

    ManMadeOfGouda joexv.github.io
    1,037
    Posts
    11
    Years
  • So I'm having issues regarding a custom evolution routine I made. All it does is first checks the flag 0x4a1 to see if its not set. If it is it quits. Then it checks the Pokemon's capture location for 0xa1 or 161. Then if its anything but that it will quit. Then finally it will do the basic level check of a normal evolution. ATM it freezes the game upon leveling up to the proper level,
    Spoiler:
    Emerald btw
     
    Last edited:
    9
    Posts
    10
    Years
    • Seen Jul 27, 2016
    Hi I need help with my own day night system. Everythings works fine and it works by writing a step number into RAM and after a certain amount of steps a script is executed which clears some flags like beery flags. The problem is that I want the light on the maps change depending on the current step number. So all I have to do is insert a light changing routine in my already working routine.
    There is some information about setting brightness on this page: https://problemkaputt.de/gbatek.htm#lcdiocolorspecialeffects
    Problem again is that I dont know how to use that information. I searched everywhere with google but I cant find a similar problem or someone using that feature.
     

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    So I'm having issues regarding a custom evolution routine I made. All it does is first checks the flag 0x4a1 to see if its not set. If it is it quits. Then it checks the Pokemon's capture location for 0xa1 or 161. Then if its anything but that it will quit. Then finally it will do the basic level check of a normal evolution. ATM it freezes the game upon leveling up to the proper level,
    Spoiler:
    Emerald btw

    Code:
    ldr r0, levelcheckloc
    bx r0
    exit: pop {r0-r7}
    ldr r0, noevo
    bx r0
    linker:
    bx r3

    You branch to levelcheckloc without doing pop {r0-r7} before that, causing stack corruption.

    You should also specify an alignment for the routine and the literal pool, I don't think it defaults to 2. You should also use the .thumb directive.

    Hi I need help with my own day night system. Everythings works fine and it works by writing a step number into RAM and after a certain amount of steps a script is executed which clears some flags like beery flags. The problem is that I want the light on the maps change depending on the current step number. So all I have to do is insert a light changing routine in my already working routine.
    There is some information about setting brightness on this page: https://problemkaputt.de/gbatek.htm#lcdiocolorspecialeffects
    Problem again is that I dont know how to use that information. I searched everywhere with google but I cant find a similar problem or someone using that feature.

    Changing the IO registers is something which is pretty unpredictable within the context of the engine. They get constantly overwritten, so it's better to use the engine functions. Anyway, filtering palettes is probably a better way to go than using the blending features, as the former is more customisable. You should look at existing Day/Night systems if you have no idea how to do this.
     

    Joexv

    ManMadeOfGouda joexv.github.io
    1,037
    Posts
    11
    Years
  • Code:
    ldr r0, levelcheckloc
    bx r0
    exit: pop {r0-r7}
    ldr r0, noevo
    bx r0
    linker:
    bx r3

    You branch to levelcheckloc without doing pop {r0-r7} before that, causing stack corruption.

    You should also specify an alignment for the routine and the literal pool, I don't think it defaults to 2. You should also use the .thumb directive.
    Spoiler:
    Still freezing. I did what you said and I added a few things that other evolution methods seemed to have, but alas to no prevail.
     

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    Spoiler:
    Still freezing. I did what you said and I added a few things that other evolution methods seemed to have, but alas to no prevail.

    Code:
    @Check capture location
    mov r1, #0x37
    ldr r3, decryptpoke

    Two issues with this - first, there is no Pokemon data structure in r0. Second, #0x37 doesn't fetch the capture location - it's the status ailment. 0x23 is the capture location.

    Right before you call the decrypter you call 806E6D0. Then you cmp r0 ... 806E6D0 doesn't have a return value so what are you trying to do?
     

    Joexv

    ManMadeOfGouda joexv.github.io
    1,037
    Posts
    11
    Years
  • Code:
    @Check capture location
    mov r1, #0x37
    ldr r3, decryptpoke

    Two issues with this - first, there is no Pokemon data structure in r0. Second, #0x37 doesn't fetch the capture location - it's the status ailment. 0x23 is the capture location.

    Right before you call the decrypter you call 806E6D0. Then you cmp r0 ... 806E6D0 doesn't have a return value so what are you trying to do?
    Yea I fixed managed to fix everything but that 0x806E6D0 call. I read online that, that was the flagcheck routine for Emerald. Is it incorrect? Cause that would explain that.
     
    9
    Posts
    10
    Years
    • Seen Jul 27, 2016
    Changing the IO registers is something which is pretty unpredictable within the context of the engine. They get constantly overwritten, so it's better to use the engine functions. Anyway, filtering palettes is probably a better way to go than using the blending features, as the former is more customisable. You should look at existing Day/Night systems if you have no idea how to do this.

    Currently im trying to make it similar to the darkness of for example rain. I cant figure out though how the darkness there works and I thought it must work with the IO registers. I guess working with palettes is just like adding new darker pals and use them during night ?
     

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    Currently im trying to make it similar to the darkness of for example rain. I cant figure out though how the darkness there works and I thought it must work with the IO registers. I guess working with palettes is just like adding new darker pals and use them during night ?

    Yeah, I could be wrong, but I think the rain and stuff works similarly to the sepia and greyscale functions - that is they manually blend the palettes. I think the only time those blend functions are used is in fade screens and stuff.
     
    9
    Posts
    10
    Years
    • Seen Jul 27, 2016
    Maybe I can find the corresponding ASM code by debugging the fadescreen script. I'm coming again if I find something useful.
    (Trying to debug the doweather script ended with crashs)
     

    daniilS

    busy trying to do stuff not done yet
    409
    Posts
    10
    Years
    • Seen Jan 29, 2024
    Fade screen used a different method. Look at palette filters or at the cloudy weather, or use special effects. There's a function to modify IO regs, can't look up the address today though.
     
    Status
    Not open for further replies.
    Back
    Top