jiangzhengwenjzw

now working on pokefirered

Male
Seen 9 Hours Ago
Posted December 19th, 2019
177 posts
8.1 Years
Yep you are right! Except you still need to push r4-7 if you use them, I know they are assumed to have random value returning from a branch or something.

Yeah anything you make I will add :)
Thank you very much if you can test and add them ;)
For the latter sentence, r u speaking of the last function? Then r4 needn't be protected as the decrypter function pushes and pops r4 so it won't change XD
And please ignore the last function as it is very bugged and it couldn't be done if the pokemon is not the first one in the party. (I tried to change r8 to fix it as you can see in the label "adjust", but failed.)

Then I've just written a routine to evolve at specific level (the second parameter in the evolution table) when it detects a certain event has happened by checking flag 0x200.
Not tested.
Spoiler:
.thumb
mov r0, #0x1
lsl r0, r0, #0x9 @you can change the flag ID here and I use 0x200
push {r1-r7}
ldr r1, decrypter
bl decrypt
pop {r1-r7}
cmp r0, #0x1
bne abort
ldr r0, evolve
bx r0

abort:
ldr r0, evolve
add r0, #0xfa
bx r0

decrypt:
bx r1

.align 2
decrypter: .word 0x0806e6d1
evolve: .word 0x8043017


In addition, the routine checking if the Pokemon is shiny to go to level evolution. (Also not tested and I'm a bit not sure if the pokemon data pointer is in r8)
Spoiler:
.thumb
mov r0, r8
push {r1-r2}
ldrh r1, [r0]
ldrh r2, [r0, #0x2]
eor r1, r2
ldrh r2, [r0, #0x4]
ldrh r0, [r0, #0x6]
eor r0, r2
eor r0, r1
pop {r1-r2}
cmp r0, #0x7
bls evolution
ldr r0, evolve
add r0, #0xfa
bx r0

evolution:
ldr r0, evolve
bx r0

.align 2
evolve: .word 0x8043017


And here I will post the simplified routines in the thread, all not tested. (The routines I write before several days will also be included)
Now the simplified routines are all finished because i only simplified some of them.
Spoiler:

evolve in the specific map:
.thumb

add r0, r6, r7
lsl r0, r0, #0x3
add r0, r2, r0
add r1, r0, r3
ldrh r0, [r1, #0x2]
push {r1}
ldr r1, mapbank
ldrh r1, [r1]
cmp r1, r0
bne exit
pop {r1}
ldr r0, evolve
bx r0

exit:
pop {r1}
ldr r0, evolve
add r0, r0, #0x4
bx r0

.align 2
evolve: .word 0x0804310D
mapbank: .word 0x02031DBC
Day friendship:
.thumb
ldr r0, time
ldrb r0, [r0]
cmp r0, #0x15
bge abort
cmp r0, #0x6
blt abort
ldr r1, evolve
bx r1

abort:
ldr r0, noevo
bx r0

.align 2
time: .word 0x3005542
evolve: .word 0x8043001
noevo: .word 0x8043111
night friendship:
.thumb
ldr r0, time
ldrb r0, [r0]
cmp r0, #0x15
bge evolution
cmp r0, #0x6
blt evolution
ldr r0, noevo
bx r0

evolution:
ldr r1, evolve
bx r1

.align 2
time: .word 0x3005542
evolve: .word 0x8043001
noevo: .word 0x8043111
Raining in the Overworld (Goodra)
.thumb
ldr r0, currentweather
ldrb r0, [r0, #0x0]
cmp r0, #0x3
beq rain
cmp r0, #0x5
beq rain
cmp r0, #0xd
beq rain
ldr r0, levelcheckloc
add r0, #0xfa
bx r0

rain:
ldr r0, levelcheckloc
bx r0

.align 2
levelcheckloc: .word 0x08043017
currentweather: .word 0x02036E12
Night Time Level Up
.thumb
ldr r0, time
ldrb r0, [r0]
cmp r0, #0x15
bge level
cmp r0, #0x6
blt level
ldr r0, levelcheckloc
add r0, #0xfa
bx r0

level:
ldr r0, levelcheckloc
bx r0


.align 2
levelcheckloc: .word 0x08043017
time: .word 0x03005542
Day Time Level Induced Tyruant(I keep its original time)
.thumb
ldr r0, time
ldrb r0, [r0]
cmp r0, #0x15
bge exit
cmp r0, #0x6
bls exit
ldr r0, levelcheckloc
bx r0

exit:
ldr r0, levelcheckloc
add r0, #0xfa
bx r0

.align 2
levelcheckloc: .word 0x08043017
time: .word 0x03005542
Specific Map Name evolution(I don't quite know what it means, but anyway I've simplified it)
.thumb
add r0, r6, r7
lsl r0, r0, #0x3
add r0, r2, r0
add r1, r0, r3
ldrh r0, [r1, #0x2]
push {r1}
ldr r1, map
ldrb r1, [r1]
cmp r0, r1
bne exit
pop {r1}
ldr r0, evolve
bx r0

exit:
pop {r1}
ldr r0, evolve
add r0, r0, #0x4
bx r0

.align 2
map: .word 0x2036e10
evolve: .word 0x804310d
I won't simplify the other routines because I'm very lazy and busy. I think they are great and do not need modification.
If you've found any glitches, please post a reply to this post and testing them is very appreciated.


I am not sure if my way of writing evolution routines is correct as it looks different from the original ones in the thread.