Auto Run [FR]
Compile this ASM, copy everything past offset 0x5BA30 in the bin file, and paste in at 0x5BA30 in your rom. This checks if a flag is set to allow you to run automatically. The default is the original running shoes flag in Fire Red. This also removes the need for a flag to be set in order for the player to run. If you want a flag, you'll have to hook to a new routine altogether.
Code:
.thumb
.global AutoRun
.org 0x5BA30
CheckAutoRunFlag:
ldr r0, .Flag
bl 0x6E6D0 @Flag Check
lsl r0, #0x18
cmp r0, #0x0
bne CheckRunTile
CheckBButton:
mov r0, #0x2
and r5, r0
cmp r5, #0x0
beq 0x5BA8C @Walk
CheckRunTile:
ldr r2, .NPC_States
ldrb r1, [r6, #0x5]
lsl r0, r1, #0x3
add r0, r1
lsl r0, #0x2
add r0, r2
ldrb r0, [r0, #0x1E]
bl 0xBD488 @Runnable Tile
cmp r0, #0x0
bne 0x5BA8C @Walk
Run:
mov r0, r4
bl 0x5BAAC
cmp r0, #0x0
beq 0x5BA74
mov r0, r4
bl 0x5C194
b 0x5BA7A
.align 2
.Flag: .word 0x82F
.NPC_States: .word 0x2036E38
This next piece of code allows you to toggle auto run through the use of the L or R buttons. Just make sure you disable the help menu (put 1D E0 at 0x13B8C2), and flashbacks (somewhere on PC). The bottom area of the code is where the customizable stuff is. If you don't know much about Ram locations leave the helper byte location alone (it's probably fine for you). Also, this code only allows you to change the toggle every second of playtime (so no spamming).
Note:
-The toggling rarely works when the game is in Turbo Mode.
-This code will only work if you've inserted the above code.
-This code must have the same flag as above to work.
Code:
.thumb
.global AutoRunToggle
@Hook at 0x8056458 with r0
@00 48 00 47 XX+1 XX XX 0x8 at 0x8056458
Main:
lsr r1, #0x10
mov r4, r1
CheckButtonPress:
ldrb r2, .Key
ldr r0, .KeyInput
ldrb r0, [r0, #0x1]
mov r1, #0x3
and r0, r1
cmp r0, r2
bne Return
CheckSecondPass:
ldr r0, .HelperByte
ldrb r0, [r0]
ldr r1, .SaveBlock2
ldr r1, [r1]
ldrb r1, [r1, #0x11]
cmp r0, r1
beq Return
ChangeFlag:
ldrh r2, .Flag
mov r0, r2
ldr r1, .Flag_Decrypt
bl Linker
cmp r0, #0x0
bne ClearFlag
SetFlag:
mov r0, r2
ldr r1, .SetFlag
bl Linker
b UpdateHelper
ClearFlag:
mov r0, r2
ldr r1, .ClearFlag
bl Linker
UpdateHelper:
ldr r1, .SaveBlock2
ldr r1, [r1]
ldrb r1, [r1, #0x11]
ldr r0, .HelperByte
strb r1, [r0]
Return:
ldr r1, =0x8112B3D
bl Linker
ldr r1, =0x8056461
Linker:
bx r1
.align 2
.SaveBlock2: .word 0x300500C
.Flag_Decrypt: .word 0x806E6D1
.SetFlag: .word 0x806E681
.ClearFlag: .word 0x806E6A9
.KeyInput: .word 0x04000130
.HelperByte: .word 0x203D800 @Replace with custom loc
.Key: .word 0x1 @0x0 = L+R, 0x1 = L, 0x2 = R @Choose key
.Flag: .word 0x82F @Change to Custom Flag