Re: Gen III: Access Pokémon beyond the sixth slot sub-glitches.
Posted by: Stackout
Date: 2016-10-09 14:16:59
You can just run the fasmwarm.exe, type in some asm, hit compile from the run menu, and it'll save out the compiled code in raw .bin. Perfect for writing PIC payloads.
And by the way, I screwed up in the previous post(s), using opcodes that won't work on GBA's ARM CPU. (I hate coding arm shellcode sometimes, especially when you're used to coding PIC for some later version of the instruction set)
Here's a better version, that doesn't use such opcodes – it's smaller too, at 62 bytes (16 items)!
In fact, we shouldn't need to have to grab the DMA base address, as the payloads will actually only run at a specific DMA base address, right?
Best to do that anyway though, just in case.
[tt]
; fasmarm syntax
processor cpu32_v4t ; ARMv4t (GBA cpu)
thumb ; we don't want an ARM-mode payload
; code starts below
; all addresses / offsets are for US FireRed.
push {r0-r1, lr} ; save r0, r1, lr to stack
; is this our first time? if so, run the payload
lsrs r1,24
cmp r1,8
beq run_payload
; we're being called a second time, just remove the task
ldr r1, [move_anim_task_del]
bl _call_via_r1
pop {r0-r1, pc}
move_anim_task_del: dw 0x8072761
run_payload:
ldr r0,[saveblock1_base]
ldr r1,[pc_offset]
ldr r0,[r0]
adds r0,r0,r1
ldr r1,[bytecode_base]
movs r2,#0xff ; copy 0x1fe bytes
svc #0xb ; CpuSet
ldr r0,[bytecode_base]
ldr r1,[script_run]
bl _call_via_r1
pop {r0-r1, pc}
saveblock1_base: dw 0x03005008 ; it's 0x3005D8C in US Emerald. find this address for other versions yourself.
pc_offset: dw 0x298 ; points to PC item #1. for US Emerald this offset is 0x24C. again, find the correct offset for other versions yourself, and add whatever constant you want for starting on PC item #x where x > 1.
bytecode_base: dw 0x200D084 ; you might want to increase this value if something gets screwed by this; however anything from 0x200D084-0x201C000 should be OK.
script_run: dw 0x8069AE5
_call_via_r1:
bx r1
[/tt]