4cade/src/ui.attract.mode.a

216 lines
7.6 KiB
Plaintext
Raw Normal View History

;license:MIT
;(c) 2018-9 by 4am
;
2019-09-21 03:26:32 +00:00
; Attract Mode - cycle through slideshows and self-running demos
;
; Public functions
; - MegaAttractMode
2019-09-21 03:26:32 +00:00
; - MiniAttractMode
2019-06-26 02:44:39 +00:00
; - RunAttractModule
2018-12-29 18:29:17 +00:00
;------------------------------------------------------------------------------
; MegaAttractMode
2019-06-27 02:51:34 +00:00
; main entry point for Mega Attract Mode, which endlessly cycles through
; modules listed in ATTRACT.CONF to display title pages, action screenshots,
; super hi-res box art (on supporting platforms), and self-running game demos
2018-12-29 18:29:17 +00:00
;
; in: gGlobalPrefsStore must be initialized
; out: never returns to caller (may JMP to other major modes)
2018-12-29 18:29:17 +00:00
;------------------------------------------------------------------------------
MegaAttractMode
2019-09-26 03:01:59 +00:00
jsr SwitchToBank1
ldx #$FF
txs
jsr BlankHGR ; switch to HGR page 1 (once cleared)
2019-09-21 03:26:32 +00:00
jsr LoadFile ; load attract-mode configuration file into $8000
!word kRootDirectory
!word kAttractModeConfFile
- !word $8000
jsr ParseKeyValueList ; parse attract-mode configuration into OKVS data structure at $6000
!word gAttractModeStore
!word -
!byte 0
2019-09-16 16:36:10 +00:00
jsr pref_get ; get attract mode module from prefs
!word kNextAttract
2018-11-17 14:54:55 +00:00
!word gAttractModeStore
2019-09-16 16:36:10 +00:00
+STAY @mname ; A/Y = module name
; X = index of module in attract store
+LDADDR gAttractModeStore
jsr okvs_next ; get module after this one
+STAY +
2018-11-17 14:54:55 +00:00
2019-09-16 16:36:10 +00:00
jsr pref_set ; update prefs store and save to disk
2018-11-17 14:54:55 +00:00
!word kNextAttract
2019-09-16 16:36:10 +00:00
+ !word $FDFD ; SMC
2018-11-17 14:54:55 +00:00
jsr okvs_get
!word gAttractModeStore
2019-09-16 16:36:10 +00:00
@mname !word $FDFD ; SMC
+STAY PTR
2019-06-26 02:44:39 +00:00
ldy #1
lda (PTR),y
tax ; X = module type
2019-09-16 16:36:10 +00:00
+LDAY @mname ; A/Y = address of module name
2019-06-26 02:44:39 +00:00
jsr RunAttractModule
2019-06-27 14:55:07 +00:00
lda KBD
2019-10-08 23:25:43 +00:00
bpl MegaAttractMode
2019-06-26 02:44:39 +00:00
cmp #$8D ; Enter plays the game shown on screen.
2019-10-08 23:25:43 +00:00
bne + ; Any other key switches to Search Mode.
2019-09-21 03:26:32 +00:00
jsr PlayGame ; (might return if user hits Ctrl-Reset)
2019-10-08 23:25:43 +00:00
+ jmp SearchMode
2019-06-27 02:51:34 +00:00
;------------------------------------------------------------------------------
; MiniAttractMode
; run attract modules related to one game
;
2019-10-08 18:43:41 +00:00
; in: gGameToLaunch = index in gGamesListStore
2019-06-27 02:51:34 +00:00
; out: all flags and registers clobbered
; assume all of main memory has been clobbered
;------------------------------------------------------------------------------
MiniAttractMode
2019-10-08 18:43:41 +00:00
jsr GetGameToLaunch
+STAY +
2019-06-27 02:51:34 +00:00
2019-09-20 23:27:16 +00:00
jsr BlankHGR
2019-10-08 23:40:38 +00:00
; X = 0
stx @MiniAttractIndex
2019-06-27 02:51:34 +00:00
@loop
2019-09-10 02:58:16 +00:00
jsr LoadFile ; load mini attract mode configuration file into $8000
2019-09-10 02:38:17 +00:00
!word kMiniAttractDirectory
2019-10-08 18:43:41 +00:00
+ !word $FDFD ; SMC
2019-09-10 02:58:16 +00:00
- !word $8000
2019-06-27 02:51:34 +00:00
jsr ParseKeyValueList ; parse configuration into OKVS data structure at $6000
!word gAttractModeStore
2019-09-10 02:58:16 +00:00
!word -
2019-06-27 02:51:34 +00:00
!byte 0
2019-09-20 23:42:26 +00:00
+LDADDR gAttractModeStore
2019-06-27 02:51:34 +00:00
jsr okvs_len
cmp @MiniAttractIndex
2019-10-08 18:56:20 +00:00
beq ATTRTS ; we've run through all modules, so exit to caller
2019-06-27 02:51:34 +00:00
2019-09-20 23:27:16 +00:00
@MiniAttractIndex=*+1
ldx #$FD ; SMC
+LDADDR gAttractModeStore
2019-06-27 02:51:34 +00:00
jsr okvs_nth ; get the next module on the list
2019-09-22 00:03:46 +00:00
+STAY SAVE
jsr okvs_get_current ; get module type
2019-06-27 02:51:34 +00:00
ldy #1
lda (PTR),y
tax ; X = module type
2019-09-22 00:03:46 +00:00
+LDAY SAVE ; A/Y = address of module name
2019-06-27 02:51:34 +00:00
jsr RunAttractModule ; execute the module
inc @MiniAttractIndex
2019-06-27 14:55:07 +00:00
lda KBD
2019-06-27 02:51:34 +00:00
bpl @loop
2019-10-08 18:56:20 +00:00
ATTRTS rts
2019-06-27 02:51:34 +00:00
;------------------------------------------------------------------------------
; RunAttractModule
; run a single attract module of any type and return to caller
;
; in: X = module type as ASCII char (1-6,A-C, see attract.conf)
2019-06-26 02:44:39 +00:00
; A/Y = address of module name
; for demos, this is the filename of an executable in /demo/
; for slideshows, this is the filename of a .conf file in /ss/
; for singles, this is a pathname of the graphic to load
; gGlobalPrefsStore must be initialized (if we load a transition effect
; of any kind, we will update the global prefs with the next one)
; out: all flags and registers clobbered
; assume all of main memory has been clobbered
;------------------------------------------------------------------------------
2019-06-26 02:44:39 +00:00
RunAttractModule
+STAY @key
2019-09-10 02:38:17 +00:00
+STAY @key2
2019-09-24 00:01:42 +00:00
cpx #$30
bne @NotDemo
2018-12-29 18:29:17 +00:00
; Self-running demos are loaded into main memory and executed.
; Each binary has been patched to quit on any key and jump back
; to the |Reenter| entry point.
; All demos are strictly 48K / main memory. No demo uses the
; language card or auxiliary memory.
+LDAY @key
2019-10-08 17:22:29 +00:00
jsr GetGameInfo
2019-10-08 18:56:20 +00:00
bcs ATTRTS ; if game doesn't exist, skip the demo
2019-09-21 03:26:32 +00:00
cpx #$FF
beq +
stx gGameToLaunch
+
2019-10-10 01:02:46 +00:00
jsr ClearScreens ; avoid seeing code load into the HGR page
; (clobbers $106, must do now before loading prelaunch code)
2019-09-10 02:38:17 +00:00
2019-09-15 02:57:52 +00:00
jsr LoadFile ; load standard prelaunch code (|Launch| will call it)
!word kPrelaunchDirectory
!word kStandardPrelaunch
!word $0106
2019-09-10 02:38:17 +00:00
jsr LoadFile ; load self-running demo into its default address (varies)
!word kDemoDirectory
@key !word $FDFD
!word 0
2019-06-26 02:44:39 +00:00
jmp Launch ; will return to caller via |Reenter|
2019-06-26 02:44:39 +00:00
; not a demo, so maybe a slideshow or single screenshot
@NotDemo
2019-09-24 00:01:42 +00:00
txa
cmp #$41 ; numbers are slideshow modules,
bcs @dispatchSingle ; letters are single files
2019-06-30 19:18:51 +00:00
; it's a slideshow, so load and parse slideshow configuration file
pha ; save module type
2019-09-10 02:58:16 +00:00
jsr LoadFile ; load slideshow configuration file into $4000
2019-09-10 02:38:17 +00:00
!word kAttractModeSlideshowDirectory
@key2 !word $FDFD ; SMC
2019-09-10 02:58:16 +00:00
- !word $4000
2019-06-30 19:18:51 +00:00
jsr ParseKeyValueList ; parse into an OKVS data structure at $0800
!word gSlideshowStore
2019-09-10 02:58:16 +00:00
!word -
!byte 0
pla ; restore module type
2019-06-26 02:44:39 +00:00
- and #$0F ; convert ASCII digit to int
2019-01-13 23:55:40 +00:00
tax
2019-09-11 04:26:00 +00:00
lda @slideshowslo-1,x
2019-01-13 23:55:40 +00:00
sta @jmp+1
2019-09-11 04:26:00 +00:00
lda @slideshowshi-1,x
2019-01-13 23:55:40 +00:00
sta @jmp+2
2019-06-26 02:44:39 +00:00
+LDAY @key ; pass in module name
2019-01-13 23:55:40 +00:00
@jmp jmp $FDFD ; SMC
@dispatchSingle
2019-09-11 04:26:00 +00:00
adc #(@singleslo-@slideshowslo)-1
bne - ; always branches
2019-09-10 02:38:17 +00:00
2019-09-11 04:26:00 +00:00
@slideshowslo
!byte <HGRTitleSlideshow
!byte <HGRActionSlideshow
!byte <DHGRTitleSlideshow
!byte <DHGRActionSlideshow
!byte <SHRSlideshow
!byte <GRActionSlideshow
@singleslo
!byte <HGRSingle
!byte <DHGRSingle
!byte <SHRSingle
!byte <GRSingle
@slideshowshi
!byte >HGRTitleSlideshow
!byte >HGRActionSlideshow
!byte >DHGRTitleSlideshow
!byte >DHGRActionSlideshow
!byte >SHRSlideshow
!byte >GRActionSlideshow
@singleshi
!byte >HGRSingle
!byte >DHGRSingle
!byte >SHRSingle
!byte >GRSingle