This sort of turned into a log, so instead of wasting a fresh forum post...
Scroll down?
Original Text:
Hey guys, I've been having a little bit of bother getting any useful code running on my XplorerFX cart as a custom .ROM.
I've studied the Multirom source pretty thoroughly and quite successfully patched various ROMs and EXEs together with bits of multirom, myAR and the romrunner ROM by hand in the hex editor - so I've got a fairly good idea of the layout at least, and that the code is at least attempting to run.
To some extent the code is working fine - for example Silpheed's InitGPU routines from the GreenTro get at least as far as visibly altering the screen size, and I've gotten a simple test program to navigate some jumps and gracefully return control to Caetla after preserving the ra register.
However, a few things just won't play ball:
The WaitGPU function from GreenTro (called from InitGPU, while it's setting things up) hangs.
-Compiled with Spasm as .EXE - Works perfectl.y
-Compiled with ASMPSX as .EXE - Hangs at the first WaitGPU call (visible change)
-Compiled with Spasm as .BIN (spasm -b whatever.s,whatever.rom) hangs (visible change)
-Compiled with ASMPSX as .BIN (asmpsx /p whatever.s,whatever.rom) hangs (visible change)
Or using a simple program running HitMOD (asm), with a 0x20000 cycle For-Loop simulating the v sync (so it's the only other code running):
-Spasm .EXE works perfectly
-ASMPSX .EXE works perfectly
-Spasm .BIN hangs immediately with a blank screen
-ASMPSX .BIN hangs immediately with a blank screen
Is there a specific reason certain calls just won't work when ran from the cart?
Here's my code if it helps any:
Code: Select all
;Attempt at getting Hitmod (with Greentro BGM) running on Xplorer FX cart.
;Hitmod init, poll and includes borrowed from Greentro.
opt c+
org $1F000000
dw entryPoint2
db "Licensed by Sony Computer Entertainment Inc."
org $1F000080
dw entryPoint1
db "Licensed by Sony Computer Entertainment Inc."
org $1F000100
;Compiles correctly to 0x80
entryPoint1:
j initStuff
nop;
;Compiles correctly to 0x00 with header
entryPoint2:
j initStuff
nop;
initStuff:
;Store RA on the stack.
addiu sp, sp, $FFF4
sw ra, $0(sp)
sw t1, $4(sp)
sw t2, $8(sp)
la a0, module
jal HM_Init ; init the mod player
nop
mainLoop:
jal HM_Poll ; call mod player
nop
li t1,$00020000
innerLoop:
bltz t1,innerLoopEnd;
nop
subiu t1,t1,$1
j innerLoop
nop
innerLoopEnd:
j mainLoop
nop
exitCode:
;Return RA to its former glory, and allow to bask once again in the sweet sunlight.
lw ra, $0(sp)
lw t1, $4(sp)
lw t2, $8(sp)
addiu sp, sp, $C
nop
jr ra
nop
;;---------------- Includes n Stuff.
nop
module incbin thesong.hit
nop
include hitmod.inc
cnop 0,1024
end
WaitGPU / InitGPU snippet:
Code: Select all
; WaitGPU - waits until GPU ready to receive commands
WaitGPU
lw t1, GP1(k1)
li t0, $10000000
and t1, t1, t0
beqz t1, WaitGPU
nop
jr ra
nop
;;And a bit further down:
; InitGPU - basic GPU init routine
; in: a0 - display mode
InitGPU:
move t3,ra
sw zero, GP1(k1) ; reset
li t2, $03000001
sw t2, GP1(k1) ; disable display
li t2, $06c40240 ; horizontal start/end
sw t2, GP1(k1)
nop
li t2, $07049025 ; vertical start/end
sw t2, GP1(k1)
nop
li t2, $e1000685 ; draw mode, texture page = (8bit,320,0)
jal WaitGPU ;Causes the Hang
nop
sw t2, GP0(k1)
nop
jal WaitGPU
nop
As you can see it's pretty basic, but the ORG statements are set up.
(Padded them out manually with nops in spasm 'cause it only supports a single org)
I was initially pretty convinced that it was something to do with T3 failing to store RA properly, but even pushing it onto the stack, or other random registers just in case didn't make much difference. The final BIN is quite small too as you'd imagine so it's not spanning a huge amount of memory.
I've only really been learning this over about 2 days, so I'm probably missing something very obvious here - so any help would be pretty awesome - even if it's just a link to an old obscure document.
Cheers
