I want to just make a simple ASM where i put the index of a pokemon in the party into 0x8001 then i get the species of that pokemon written into 0x800D (or LASTRESULT), this is what i have:
.text
.align 2
.thumb
.thumb_func
main:
push {r0-r4, lr} @I'm using 4 registers, I think this should be enough
ldr r0, .SLOT @Load the index of the pokemon
ldrh r0, [r0] @change it into half-bite i think
mov r1, #0x64
mul r0, r0, r1 @change the index into a number we can handle
ldr r1, =(0x2024284) @load the pokemon data
add r0, r0, r1 @take the pokemon data at index in the party list
.... @need help here
ldr r4, .VAR @take 0x800D
str r0, [r3] @write the species to give that number back
pop {r0-r4,pc}
.align 2
.VAR:
.word 0x20270B6 + (0x800D *2) @change to any 2 byte free space in RAM
.SLOT:
.word 0x20270B6 + (0x8001 *2) @slot of Pokemon we want to check
From what I gathered until now I know that a pokemons Data structure has a Data part at offset 0x32 and that the species of the pokemon is at offset 0x0 of that Data. So in order to get that species I would need to just navigate to that offset. This code is probably not good, I tried my best by looking at other code in the ASM thread but I'm still a beginner. If someone has any idea how I can get the code to work pls respond and thank you in advance.
.text
.align 2
.thumb
.thumb_func
main:
push {r0-r4, lr} @I'm using 4 registers, I think this should be enough
ldr r0, .SLOT @Load the index of the pokemon
ldrh r0, [r0] @change it into half-bite i think
mov r1, #0x64
mul r0, r0, r1 @change the index into a number we can handle
ldr r1, =(0x2024284) @load the pokemon data
add r0, r0, r1 @take the pokemon data at index in the party list
.... @need help here
ldr r4, .VAR @take 0x800D
str r0, [r3] @write the species to give that number back
pop {r0-r4,pc}
.align 2
.VAR:
.word 0x20270B6 + (0x800D *2) @change to any 2 byte free space in RAM
.SLOT:
.word 0x20270B6 + (0x8001 *2) @slot of Pokemon we want to check
From what I gathered until now I know that a pokemons Data structure has a Data part at offset 0x32 and that the species of the pokemon is at offset 0x0 of that Data. So in order to get that species I would need to just navigate to that offset. This code is probably not good, I tried my best by looking at other code in the ASM thread but I'm still a beginner. If someone has any idea how I can get the code to work pls respond and thank you in advance.