#20864 - BeeWarloc - Tue May 18, 2004 9:15 pm
Hi... I wrote a new fastloader for a linker application I'm coding (xupload)..
But it won't load all roms, some will run, and some will not. I think it has something to do with the state the gameboy is in when I jump back to the ROM..
Anyone know what's appropriate to do before jumping to 0x02000000?
(yeah I know it probably should have been coded in asm, but with a stripped crt0.s and only -lgcc it compiles to ca 700 bytes including header, which is tolerable)
But it won't load all roms, some will run, and some will not. I think it has something to do with the state the gameboy is in when I jump back to the ROM..
Anyone know what's appropriate to do before jumping to 0x02000000?
Code: |
/* a very simple fastloader created for xupload */ /* to compile this file crt0.s needs to have interrupts disabled */ #include <mygba.h> extern void __FarProcedure (void (*ptr)(), ...); // Reference to routine in crt0.S void fastloader() MEM_FUNC_IN_IWRAM; #define RCNT_PTR ((u16 *)0x04000134) #define SIOCNT_PTR ((u16 *)0x4000128) #define SIODATA32L_PTR ((u16 *)0x4000120) #define SIODATA32H_PTR ((u16 *)0x4000122) #define SIODATA32_PTR ((u32 *)0x04000120) MULTIBOOT /********************************************************************************* * Program entry point ********************************************************************************/ void fastloader() { u32 counter = 0, size; u32 *ewram = (u32 *)0x02000000; *RCNT_PTR = 0x0; *SIOCNT_PTR = 0x02 | 0x80 | 0x1000; *SIODATA32_PTR = 0xABADBABE; while(1) { if(!(*SIOCNT_PTR & 0x80)) { *SIOCNT_PTR |= 0x80; if(*SIODATA32_PTR == 0xB0B0DEAD) break; *SIODATA32_PTR = 0xABADBABE; *SIOCNT_PTR |= 0x02 | 0x80; } } *SIODATA32_PTR = 0x12652395; *SIOCNT_PTR |= 0x02 | 0x80; while(1) { if(!(*SIOCNT_PTR & 0x80)) { *SIOCNT_PTR |= 0x80; break; } } size = *SIODATA32_PTR / sizeof(u32); *SIODATA32_PTR = size; *SIOCNT_PTR |= 0x02 | 0x80; while(1) { if(!(*SIOCNT_PTR & 0x80)) { *SIOCNT_PTR |= 0x80; //? ewram[counter] = *SIODATA32_PTR; *SIODATA32_PTR = counter; counter++; if(counter >= size) break; *SIOCNT_PTR |= 0x02 | 0x80; } } __FarProcedure((void *)0x02000000); } int main(void) { fastloader(); return 0; } |
(yeah I know it probably should have been coded in asm, but with a stripped crt0.s and only -lgcc it compiles to ca 700 bytes including header, which is tolerable)