You could compare to immediate values (up to two digits in thumb): Before: Code: ReviveFlowers: ldrh r2,[r0,r1] mov r3, #0x6F cmp r2,r3 ble WaterFlowers mov r3, #0x89 cmp r2,r3 bge WaterFlowers sub r2,#0x6E After: Code: ReviveFlowers: ldrh r2,[r0,r1] cmp r2, #0x6F ble WaterFlowers cmp r2, #0x89 bge WaterFlowers sub r2, #0x6E There's really no need to mov r3 by a byte and then compare. ^_^ Edit: You should load the map with a 32-bit load XD Original: Code: ldrh r0,Map ldrh r1,MapOffset Modified: Code: ldr r0,Map ldrh r1,MapOffset
ReviveFlowers: ldrh r2,[r0,r1] mov r3, #0x6F cmp r2,r3 ble WaterFlowers mov r3, #0x89 cmp r2,r3 bge WaterFlowers sub r2,#0x6E
ReviveFlowers: ldrh r2,[r0,r1] cmp r2, #0x6F ble WaterFlowers cmp r2, #0x89 bge WaterFlowers sub r2, #0x6E
ldrh r0,Map ldrh r1,MapOffset
ldr r0,Map ldrh r1,MapOffset
Last edited by Demonic722; 07-12-2011 at 02:00 PM.
3DS Friend Code: 4699-6293-3106
MisterNobody
Code: mov r3, #0x6F #Wilted Red Tulips start at 6E I'll read the rest later.
mov r3, #0x6F #Wilted Red Tulips start at 6E
Last edited by Maniac; 07-12-2011 at 06:07 PM.
Say what you mean, mean what you say, and let your actions speak for you.
Thanks for your advices. I've fixed the ASM source: Code: @Thumb mode add r2,pc,#1 bx r2 .thumb ldr r0,Map ldrh r1,MapOffset ReviveFlowers: ldrh r2,[r0,r1] cmp r2, #0x6D ble WaterFlowers cmp r2,#0x89 bge WaterFlowers sub r2,#0x6E WaterFlowers: cmp r2, #0x1B bge RemoveWeeds strh r2, [r0,r1] RemoveWeeds: mov r1, #0xFF lsl r1, #8 add r1, #0xF1 cmp r2,#0x1E ble RemoveRafflesia cmp r2,#0x25 bge RemoveRafflesia strh r3, [r0,r1] RemoveRafflesia: cmp r2, #0x1B bne RemoveRafflesia2 strh r3, [r0,r1] RemoveRafflesia2: cmp r2, #0x89 bne End strh r3, [r0,r1] End: sub r1,#2 bpl ReviveFlowers bx lr .arm Map: .long 0x21E6D4C MapOffset: .short 0x1FFE Edit: The AR codes in the first post are fixed (2 lines shorter).
@Thumb mode add r2,pc,#1 bx r2 .thumb ldr r0,Map ldrh r1,MapOffset ReviveFlowers: ldrh r2,[r0,r1] cmp r2, #0x6D ble WaterFlowers cmp r2,#0x89 bge WaterFlowers sub r2,#0x6E WaterFlowers: cmp r2, #0x1B bge RemoveWeeds strh r2, [r0,r1] RemoveWeeds: mov r1, #0xFF lsl r1, #8 add r1, #0xF1 cmp r2,#0x1E ble RemoveRafflesia cmp r2,#0x25 bge RemoveRafflesia strh r3, [r0,r1] RemoveRafflesia: cmp r2, #0x1B bne RemoveRafflesia2 strh r3, [r0,r1] RemoveRafflesia2: cmp r2, #0x89 bne End strh r3, [r0,r1] End: sub r1,#2 bpl ReviveFlowers bx lr .arm Map: .long 0x21E6D4C MapOffset: .short 0x1FFE
Last edited by MisterNobody; 07-13-2011 at 03:05 PM.
It looks like the code posted was compiled with a different source XD. Not only because of the limitation of only 1 "ldrh r0-r5, LabelHere" rule in thumb, but no where in the code 0xFFF1, or 0x1FFE is seen. o.o
I've just changed 2-3 things because it doesn't want to compile with this source. But don't worry, the code seems to work, I've tested it myself. :P
Originally Posted by MisterNobody I've just changed 2-3 things because it doesn't want to compile with this source. But don't worry, the code seems to work, I've tested it myself. :P It doesn't compile because you have two "ldrh r0-r5, LabelHere" things XD :P
Oh that's it ! Thank you I'm going to fix the source again. xD
Forum Rules