4cade/src/glue.launch.lc2.a

68 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

;license:MIT
;(c) 2018-2021 by 4am & qkumba
;
2019-10-09 17:16:29 +00:00
; 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.
2019-10-09 17:04:39 +00:00
LaunchInternal
tsx ; back up stack pointer
2019-11-27 21:51:43 +00:00
stx STACKPTR + 1
inx
- pla
sta STACKBASE - $100 + gStackSize,x
; back up stack
inx
bne -
stx RestoreStackNextTime + 1
2019-10-09 17:04:39 +00:00
; tell |Reenter| to restore the stack and stack pointer
ldx #(PrelaunchInitInternal_e-PrelaunchInitInternal+1)
- lda PrelaunchInitInternal-1, x
sta PrelaunchInit-1, x
dex
bne -
;X=0
txa
2019-10-09 17:04:39 +00:00
ldy #$18
- sta $bf57,y
dey
bne -
ldx #RNDSEED-1 ; wipe lower part of zero page
txa
- sta $00,x
dex
bpl -
lda #$65 ; Initialize 'random' seed. These are
sta RNDSEED ; arbitrary values. Some games like Pooyan
lda #$02 ; require these to be non-zero. Ask me
sta RNDSEED+1 ; how long that one took to debug.
2024-05-26 00:51:48 +00:00
sta STOREOFF
sta READMAINMEM
sta WRITEMAINMEM
sta CLR80VID
sta PRIMARYCHARSET
bit CLEARKBD
jmp PrelaunchInit
2024-05-26 00:51:48 +00:00
PrelaunchInitInternal
!pseudopc PrelaunchInit {
+READ_ROM_NO_WRITE
jsr ROM_IN0 ; Initialize machine like a cold boot.
jsr ROM_PR0 ; Many games assume a 'clean slate' and
jsr ROM_NORMAL ; rely on zero page values set by these
2024-05-26 00:51:48 +00:00
jsr ROM_TEXT ; ROM routines, e.g. Wavy Navy prints text
jsr ROM_HOME ; via $FDED and expects it to work.
sei
bvc $106 ; unconditional jump to game-specific pre-launch code
!if * != $100 {
!serious "adjust PrelaunchInit to ",PrelaunchInit+$100-*
}
}
PrelaunchInitInternal_e