2019-10-09 17:15:33 +00:00
|
|
|
;license:MIT
|
2021-10-29 18:32:14 +00:00
|
|
|
;(c) 2018-2021 by 4am & qkumba
|
2019-10-09 17:15:33 +00:00
|
|
|
;
|
2019-10-09 17:16:29 +00:00
|
|
|
; Functions to launch games and self-running demos
|
2019-10-09 17:15:33 +00:00
|
|
|
;
|
|
|
|
; /!\ 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
|
2021-10-29 18:32:14 +00:00
|
|
|
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
|
|
|
|
|
2024-05-25 23:18:49 +00:00
|
|
|
ldx #(PrelaunchInitInternal_e-PrelaunchInitInternal+1)
|
|
|
|
- lda PrelaunchInitInternal-1, x
|
|
|
|
sta PrelaunchInit-1, x
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
;X=0
|
2021-10-29 18:32:14 +00:00
|
|
|
txa
|
2019-10-09 17:04:39 +00:00
|
|
|
ldy #$18
|
|
|
|
- sta $bf57,y
|
|
|
|
dey
|
|
|
|
bne -
|
2024-05-25 23:18:49 +00:00
|
|
|
|
|
|
|
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
|
2024-06-10 16:30:14 +00:00
|
|
|
jmp iPrelaunchInit
|
2024-05-25 23:18:49 +00:00
|
|
|
|
2024-05-26 00:51:48 +00:00
|
|
|
PrelaunchInitInternal
|
|
|
|
!pseudopc PrelaunchInit {
|
|
|
|
+READ_ROM_NO_WRITE
|
2024-05-25 23:18:49 +00:00
|
|
|
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.
|
2024-06-10 16:30:14 +00:00
|
|
|
AnimationPrelaunchInit
|
2024-05-25 23:18:49 +00:00
|
|
|
sei
|
2024-06-10 16:30:14 +00:00
|
|
|
jmp $106
|
2024-05-25 23:18:49 +00:00
|
|
|
!if * != $100 {
|
|
|
|
!serious "adjust PrelaunchInit to ",PrelaunchInit+$100-*
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PrelaunchInitInternal_e
|