4cade/src/glue.launch.lc2.a
2019-10-09 13:16:29 -04:00

33 lines
1.0 KiB
Plaintext

;license:MIT
;(c) 2018-9 by 4am & qkumba
;
; Functions to launch games and self-running demos
;
; /!\ These live in LC RAM 2 and rely on the ProRWTS code which is also in LC RAM 2. /!\
; Code in LC RAM 1 (which is most program code) should call the functions in glue.launch
; which handle bank switching for you.
LaunchInternal
jsr SaveOrRestoreScreenHoles ; save screen hole contents
ldy #$F1
- lda $100,y
sta STACKBASE - $F0,y ; back up stack
iny
bne -
tsx ; back up stack pointer
stx STACKBASE
sty RestoreStackNextTime + 1
; tell |Reenter| to restore the stack and stack pointer
ldx #(end_promote-promote-1)
- lda promote,x ; copy ProDOS shim to main memory
sta $bf00,x
dex
bpl -
tya
ldy #$18
- sta $bf57,y
dey
bne -
jmp $106 ; jump to pre-launch code