Advertiser Content
Seen September 10th, 2019
Posted June 25th, 2019
232 posts
8.6 Years
I'm trying to make a routine that gets the IV values of a pokemon whose slot is stored at var 0x8007 and store those values into vars 0x8001-0x8006 and the total of those values into var 0x8000. I'm having a difficult time in allowing the routine to loop. here's my routine:
.text
.align 2
.thumb
.thumb_func
.global decryptor

main:
    push {r0-r5, lr}
    ldr r0, var_8007        @slot number should be in var_8007
    ldrh r0, [r0]
    mov r1, #0x64
    mul r1, r1, r0
    ldr r0, partypoke
    add r5, r1, r0        @slot loaded
    mov r1, #0x27
    ldr r3, var_8001
    mov r4, #0x0

decrypt:
    mov r0, r5
    ldr r2, poke_decrypt
    bl linker
    strh r0, [r3]            @store result into var_8001-8006
    add r4, r4, r0
    add r1, r1, #0x1
    cmp r1, #0x2D
    beq exit
    add r3, r3, #0x2
    b decrypt

exit:
    ldr r1, var_8000        @load var_8000
    strh r4, [r1]
    pop {r0-r5, pc}

linker:
    bx r2

.align 2
var_8000:    .word 0x20370B8
var_8001:    .word 0x20370BA
var_8007:    .word 0x20370C6
partypoke:    .word 0x2024284
poke_decrypt:    .word 0x803FBE8 + 1
When it attempts to loop, the game freezes.
Male
Antarctica
Seen January 29th, 2018
Posted September 26th, 2017
326 posts
5.6 Years
I'm trying to make a routine that gets the IV values of a pokemon whose slot is stored at var 0x8007 and store those values into vars 0x8001-0x8006 and the total of those values into var 0x8000. I'm having a difficult time in allowing the routine to loop. here's my routine:
.text
.align 2
.thumb
.thumb_func
.global decryptor

main:
    push {r0-r5, lr}
    ldr r0, var_8007        @slot number should be in var_8007
    ldrh r0, [r0]
    mov r1, #0x64
    mul r1, r1, r0
    ldr r0, partypoke
    add r5, r1, r0        @slot loaded
    mov r1, #0x27
    ldr r3, var_8001
    mov r4, #0x0

decrypt:
    mov r0, r5
    ldr r2, poke_decrypt
    bl linker
    strh r0, [r3]            @store result into var_8001-8006
    add r4, r4, r0
    add r1, r1, #0x1
    cmp r1, #0x2D
    beq exit
    add r3, r3, #0x2
    b decrypt

exit:
    ldr r1, var_8000        @load var_8000
    strh r4, [r1]
    pop {r0-r5, pc}

linker:
    bx r2

.align 2
var_8000:    .word 0x20370B8
var_8001:    .word 0x20370BA
var_8007:    .word 0x20370C6
partypoke:    .word 0x2024284
poke_decrypt:    .word 0x803FBE8 + 1
When it attempts to loop, the game freezes.
r1 is changed during the pokedecrypt routine, use a higher register to store stuff, like you did for r5. Also the same thing is happening with r3.
Seen September 10th, 2019
Posted June 25th, 2019
232 posts
8.6 Years
r1 is changed during the pokedecrypt routine, use a higher register to store stuff, like you did for r5. Also the same thing is happening with r3.
Thank you very much. Your other post also helps a lot too!

Here's the fixed routine:
.text
.align 2
.thumb
.thumb_func
.global getiv

main:
    push {r4-r7, lr}
    ldr r0, =(0x20370C6)        @slot number should be in var_8007
    ldrh r0, [r0]
    mov r1, #0x64
    mul r1, r1, r0
    ldr r0, =(0x2024284) @partyram
    add r5, r1, r0        @slot loaded
    mov r6, #0x27
    mov r1, r6
    ldr r7, =(0x20370BA) @var8001
    mov r4, #0x0

decrypt:
    mov r0, r5
    ldr r2, =(0x803FBE8|1) @getattr
    bl linker
    strh r0, [r7]            @store result into var_8001
    add r4, r4, r0
    add r6, r6, #0x1
    cmp r6, #0x2D
    beq exit
    mov r1, r6
    add r7, r7, #0x2
    b decrypt

exit:
    ldr r1, =(0x20370B8)        @load var_8000
    strh r4, [r1]
    pop {r4-r7, pc}

linker:
    bx r2

.align 2
Advertiser Content