joeylib2/tools/iigsStart/iigsStartQuit.s
2026-09-28 21:35:48 -05:00

60 lines
1.7 KiB
ArmAsm

; GS/OS inline-call stubs for iigsStart.
;
; The same inline form and the same self-patch as the llvm816 runtime's
; gsosDispatch (runtime/src/iigsGsos.s): the caller passes the parameter
; block's address in A:X (A = offset, X = bank), and the stub writes it
; into its own inline pBlock operand before the call. The stores target
; the stub's own bank (phk/plb), not the caller's DBR. The blocks used to
; sit at fixed addresses in the $E1:9DC8-$9DFD scratch window, which is 54
; bytes: a program name of 8 characters or more ran the QuitGS pathname
; over the SetPrefix string, prefix 0 was never set, and the program could
; not open "ntpplayer" or its DATA folder.
; iigsStartSetPrefix(parm) -- SetPrefixGS ($2009).
;
; GS/OS does NOT point prefix 0 at the program named in a QuitGS launch: it
; was measured still pointing at the BOOT volume, so the launched example's
; own relative fopen()s missed. That is not cosmetic -- JoeyLib loads the
; NTP replayer as bare "ntpplayer", and when that read fails jlpAudioInit
; bails before ntpArm(), leaving the sound vector at its ROM default and
; the application completely silent.
.section .text.iigsStartSetPrefix,"ax"
.globl iigsStartSetPrefix
iigsStartSetPrefix:
phb
phk
plb
sta spPblock
sep #0x20
txa
sta spPblock+2
rep #0x20
plb
jsl 0xE100A8
.word 0x2009
spPblock:
.long 0
rtl
; iigsStartQuit(parm) -- QuitGS ($2029).
;
; Unlike jlpShutdown's pCount=0 "quit to my parent", this is called with
; pCount=2 and a pathname, which tells GS/OS to LAUNCH that program in our
; place. On success it never returns.
.section .text.iigsStartQuit,"ax"
.globl iigsStartQuit
iigsStartQuit:
phb
phk
plb
sta qtPblock
sep #0x20
txa
sta qtPblock+2
rep #0x20
plb
jsl 0xE100A8
.word 0x2029
qtPblock:
.long 0
rtl