Quote:
Originally Posted by FBI agent
It should work. I've tested the routine myself on a clean ROM and simply just pasted the code over here with some minor edits to make it insertable for others. Also it calls the random number generating routine to determine the chance. Did you insert that as well?
If you want to send me your ROM, I can point out what exactly is going downhill for you. Most of the time with these kind of problems it's a simple mistake somewhere or a missing routine.
I know for a fact this routine system works because I've also used it in other places like chain fishing (which I've also tested).
|
Finally, I found the problem !
It's in the code of the shiny encounter chance :
Code:
.text
.align 2
.thumb
.thumb_func
main:
push {r0-r3}
normal:
mov r0, #0x2
lsl r0, r0, #0x0 @1/2 chance normally
calcChance:
ldr r1, =(0x20370B8) @ var 8000
strh r0, [r1] @ var 8000 = r0
ldr r2, .random
bl linker @ random between 0 et r0
cmp r0, #0xFF
bne end
@ if equal to 0xFF, the Pokemon is shiny
ldr r1, =(0x20370BC)
strb r0, [r1]
ldr r1, =(0x20370B8)
mov r0, #0x0
strh r0, [r1]
end:
pop {r0-r3}
sub SP, SP, #0x20
mov r7, r0
ldr r4, [SP, #0x40]
ldr r4, [SP, #0x48]
mov r5, #0xE
ldr r6, =(0x803DAD8 +1)
bx r6
linker:
bx r2
.align 2
.random:
.word 0x8C00001
In fact, if I set r0 to 2 (for example), the random value will be 0 or 1. Generally speaking, if I set r0 to a value under 0xFF, r0 will never be equal to 0xFF, so the Pokemon won't be shiny.
I wrote
cmp r0, #0x0 instead of. And also, because we must set 8002 to 0xFF to make a Pokemon shiny, I added the line
mov r0, #0xFF.
Here is my new code :
Code:
.text
.align 2
.thumb
.thumb_func
main:
push {r0-r3}
normal:
mov r0, #0x2
lsl r0, r0, #0x0 @1/2 chance normally
calcChance:
ldr r1, =(0x20370B8)
strh r0, [r1]
ldr r2, .random
bl linker
cmp r0, #0x0
bne end
mov r0, #0xFF
ldr r1, =(0x20370BC)
strb r0, [r1]
ldr r1, =(0x20370B8)
mov r0, #0x0
strh r0, [r1]
end:
pop {r0-r3}
sub SP, SP, #0x20
mov r7, r0
ldr r4, [SP, #0x40]
ldr r4, [SP, #0x48]
mov r5, #0xE
ldr r6, =(0x803DAD8 +1)
bx r6
linker:
bx r2
.align 2
.random:
.word 0x8C00001
It works perfectly. Thank you for your work fbi, you're great ! {XD}