4cade/src/4cade.a

120 lines
4.0 KiB
Plaintext
Raw Normal View History

2018-12-29 18:38:18 +00:00
;license:MIT
;(c) 2018-9 by 4am
2018-12-29 18:38:18 +00:00
;
2018-08-23 20:02:48 +00:00
!cpu 6502
!to "build/LAUNCHER.SYSTEM",plain
*=$2000
2019-06-19 04:49:12 +00:00
!ifndef RELBASE {
RELBASE=$2000
}
!source "src/constants.a" ; no code in these
2018-08-26 19:33:32 +00:00
!source "src/macros.a"
2018-11-10 13:36:36 +00:00
; first-run initialization, relocates code to language card and jumps
; to |Reenter|
!source "src/4cade.init.a"
2018-10-23 19:44:06 +00:00
FirstMover
2019-06-19 04:49:12 +00:00
!pseudopc RELBASE {
;------------------------------------------------------------------------------
; Reenter
; This is the primary entry point for returning to the launcher from anywhere.
; - Self-running demos call this when the user presses a key or when the demo
; cycles ends naturally.
; - It is set as the reset vector, so the user can play a game then press
; Ctrl-Reset to return to the launcher and choose another.
; - It also functions as a reset vector while the launcher is running.
; - It is also called on program startup, after the first-run initialization.
;
; When execution reaches this point, we may have previously backed up the stack
; and stack pointer, in which case it is now our job to restore it and return
; to the caller. This allows magic like 'JSR PlayGame' then continuing once the
; JSR returns.
;
; If there is no stack to restore, this exits via SearchMode.
;
; in: none
; out: see above
;------------------------------------------------------------------------------
Reenter
cld
cli
+READ_RAM2_WRITE_RAM2
jsr CloseHandles ; close any open handles to restore ProRWTS
jsr SaveOrRestoreScreenHoles ; restore original screen hole contents
RestoreStackNextTime
clc ; SMC
bcc SearchMode ; not an unconditional branch because code
; might change the 'clc' just before it
; If we fall through to here, it's because we backed up the stack and
; stack pointer and wanted this routine to restore it and return to
; caller.
lda #$18 ; reset to 'clc' opcode so we don't try to
sta RestoreStackNextTime ; restore the same stack twice
2019-09-10 17:50:36 +00:00
ldx #$F1
- lda $DF00,x ; restore stack
2019-01-08 19:10:26 +00:00
sta $100,x
inx
bne -
2019-09-10 17:50:36 +00:00
ldx $DFF0 ; restore stack pointer
txs
+READ_RAM1_WRITE_RAM1
rts ; and return to caller
2018-10-27 22:47:27 +00:00
; these routines will only be called after relocating to language card
2018-12-28 20:11:38 +00:00
!source "src/ui.search.mode.a"
2019-07-03 22:31:50 +00:00
!source "src/ui.browse.mode.a"
2019-07-10 17:37:59 +00:00
!source "src/ui.credits.a"
!source "src/ui.attract.mode.a"
2019-01-15 00:06:58 +00:00
!source "src/ui.attract.hgr.a"
!source "src/ui.attract.dhgr.a"
!source "src/ui.attract.shr.a"
!source "src/ui.attract.gr.a"
!source "src/ui.cheats.a"
2018-09-13 13:53:04 +00:00
!source "src/prodos.path.a"
2019-01-15 00:06:58 +00:00
!source "src/glue.launch.a"
!source "src/glue.prorwts2.a"
!source "src/okvs.a"
!source "src/wait.a"
2019-06-18 18:56:05 +00:00
!source "src/textrank.a"
2018-10-23 19:44:06 +00:00
!source "src/parse.common.a"
!source "src/parse.prefs.a"
2019-09-10 18:21:23 +00:00
!source "src/glue.font.a"
2019-09-10 04:19:07 +00:00
; add new files above here so ui.common stays last
2019-06-26 02:44:39 +00:00
!source "src/ui.common.a"
2019-06-30 19:10:09 +00:00
gAttractModeStore
gFXStore
gDFXStore
!word $6000
gSlideshowStore
!word $0800
2018-11-10 15:08:14 +00:00
gGlobalPrefsStore
!word $D100
gGamesListStore
!word $FDFD ; SMC
2019-06-21 16:43:43 +00:00
!word Reenter ; NMI vector ($FFFA-B)
!word Reenter ; reset vector ($FFFC-D)
!word Reenter ; IRQ vector ($FFFE-F)
2018-08-29 19:27:30 +00:00
}
LastMover
2019-09-10 01:40:59 +00:00
!pseudopc $D600 {
!source "src/ui.font.data.a"
2019-09-10 18:21:23 +00:00
!source "src/ui.font.a"
2019-09-06 22:12:17 +00:00
!source "src/prodos.impl.a"
2019-09-10 21:33:43 +00:00
LCRAM2_END = *
2019-09-10 18:01:55 +00:00
!if * > $DFEF {
2019-09-10 01:40:59 +00:00
!error "code is too large: ends at ", *
}
2019-09-09 21:28:13 +00:00
}
2019-09-06 22:12:17 +00:00
EvenLasterMover
2019-06-19 04:49:12 +00:00
!if RELBASE = $2000 {
!ifdef PASS2 {
} else { ;PASS2
!set PASS2=1
2019-09-10 21:33:43 +00:00
!warn "LCRAM2 ends at ", LCRAM2_END
2019-06-21 16:43:43 +00:00
!warn "RELBASE = ", $10000 - (LastMover - FirstMover)
2019-06-19 04:49:12 +00:00
}
}