.align 2
.thumb
/****** NEW GEN EXP SHARE + EGG EXP FIX *******
************** FRED VERSION ********************
The following changes in the rom are needed:
- Go to 0x08021C3A and overwrite with "02 21".
- Go to 0x08021D70 and write "01 20".
- Go to 0x08021CC6 and write the following:
"C0 46 00 4A 10 47 [XX+1 XX XX 08] 04 BC"
where [XX+1 XX XX 08] is the reverse pointer +1
to the offset of this routine.
************************************************
Is important to note that you HAVE TO choose the flag you
wanna use to toggle on/off the routine.
In the same way, you also have to choose a temp variable
for this routine to store a control value. (it will actually count
the current pokemon slot its checking)
************************************************
************************************************
************************************************
Credits to BluRose & Lunos *********************
& Samu (lmao almost forgot myself) ******************
************************************************
************************************************/
no_crash:
ldr r0, [r5]
mov r1, r0
add r1, #0x53
ldrb r0, [r1]
flag_check:
push {r0-r2}
ldr r0, flag_number
ldr r2, flag_routine
push {r1-r3}
bl linker
pop {r1-r3}
cmp r0, #0x1
@if flag is set (0x1) routine is "on", otherwise is "off"
bne routine_off
pop {r0-r2}
main:
push {r3-r6}
ldr r6, slot_var @Loads the slot in r3
ldrb r3, [r6]
ldr r4, is_egg_party
mov r5, #0x64
mul r5, r5, r3
ldrb r4, [r4, r5] @Loads in r4 the pointer to the team_slot "egg_byte"
cmp r4, #0x6
@if byte value is 0x6 -> pokemon is an egg
beq pokemonIsEgg
mov r2, #0x1 @otherwise set r0 to 0x1 (will gain exp)
b update_slot
pokemonIsEgg:
mov r2, #0x0 @sets r2 to 0x0 (will not gain exp)
update_slot: @updates and reset slot value.
add r3, #0x1
cmp r3, #0x6
bne end
mov r3, #0x0
end:
strh r3, [r6]
pop {r3-r6}
return:
push {r2}
ldr r2, return_dir
bx r2
routine_off: @"original instructions"
pop {r0-r2}
mov r2, #0x1
and r2, r0
b return
linker:
bx r2
.align 2
flag_number:
.word 0x00000291
@Choose the flag number
flag_routine:
.word 0x0806E6D0 +1 @Routine that returns flag value to r0
slot_var: @choose a temp variable
.word 0x020270B8 + (0x800291 * 2)
is_egg_party:
.word 0x02024284 + 0x13 @"eggByte" of first pokemon slot
return_dir:
.word 0x08021CD0 + 1 @routine return direction