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

263 lines
8.5 KiB
Plaintext
Raw Normal View History

;license:MIT
;(c) 2018-9 by 4am
;
; Mega Attract Mode - cycle through slideshows and self-running demos
;
; Public functions
; - MegaAttractMode
2019-06-26 02:44:39 +00:00
; - RunAttractModule
; - LoadAndParseAttractModeConf
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-06-27 14:55:07 +00:00
+READ_RAM1_WRITE_RAM1
ldx #$FF
txs
jsr BlankHGR ; switch to HGR page 1 (once cleared)
2019-06-26 02:44:39 +00:00
jsr LoadAndParseAttractModeConf
jsr okvs_get ; get next attract-mode module from prefs
!word gGlobalPrefsStore
!word kNextAttract
bcs @noattract
+STAY @attract
jsr okvs_get
!word gAttractModeStore
@attract !word $FDFD ; SMC
bcc +
@noattract
ldx #0
2019-06-26 02:44:39 +00:00
+ stx @attractIndex
jsr okvs_nth ; get filename of next attract-mode module
!word gAttractModeStore
2019-06-26 02:44:39 +00:00
@attractIndex
2018-11-17 14:54:55 +00:00
!byte 0
+STAY @key
2019-06-26 02:44:39 +00:00
lda @attractIndex
2019-01-08 20:01:45 +00:00
sta gCurrentAttractIndex
2019-06-26 02:44:39 +00:00
inc @attractIndex ; increment module index for next time
jsr okvs_len
!word gAttractModeStore
2019-06-26 02:44:39 +00:00
cmp @attractIndex
bne +
lda #0
2019-06-26 02:44:39 +00:00
sta @attractIndex
+
2019-06-26 02:44:39 +00:00
lda @attractIndex
2018-11-17 14:54:55 +00:00
sta @nexti
jsr okvs_nth ; get name of next attract-mode module
!word gAttractModeStore
@nexti !byte $FD ; SMC
+STAY @nextattract
jsr okvs_update ; save name of next attract-mode module in prefs store
!word gGlobalPrefsStore
!word kNextAttract
@nextattract
!word $FDFD ; SMC
2019-01-04 02:01:55 +00:00
jsr SaveGlobalPreferences ; write prefs store to disk
2018-11-17 14:54:55 +00:00
jsr okvs_get
!word gAttractModeStore
2018-12-29 18:29:17 +00:00
@key !word $FDFD ; SMC
+STAY PTR
2019-06-26 02:44:39 +00:00
ldy #1
lda (PTR),y
tax ; X = module type
+LDAY @key ; A/Y = address of module name
jsr RunAttractModule
2019-06-27 14:55:07 +00:00
lda KBD
bpl @jmpattract
2019-06-26 02:44:39 +00:00
cmp #$8D ; Enter plays the game shown on screen.
bne @jmpsearch ; Any other key switches to Search Mode.
jsr PlayGameFromAttract ; Might return if user hits Ctrl-Reset.
@jmpattract
jmp MegaAttractMode
@jmpsearch
jmp SearchMode
2019-06-27 02:51:34 +00:00
;------------------------------------------------------------------------------
; MiniAttractMode
; run attract modules related to one game
;
2019-06-27 14:55:07 +00:00
; in: X = index in gGamesListStore
2019-06-27 02:51:34 +00:00
; gGlobalPrefsStore must be initialized
; out: all flags and registers clobbered
; assume all of main memory has been clobbered
;------------------------------------------------------------------------------
MiniAttractMode
stx +
jsr BlankHGR
jsr okvs_nth
!word gGamesListStore
+ !byte $FD ; SMC
2019-09-10 02:38:17 +00:00
+STAY @fname
2019-06-27 02:51:34 +00:00
lda #0
sta @MiniAttractIndex
@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
@fname !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
jsr okvs_len
!word gAttractModeStore
cmp @MiniAttractIndex
beq @exit ; we've run through all modules, so exit to caller
lda @MiniAttractIndex
sta +
jsr okvs_nth ; get the next module on the list
!word gAttractModeStore
+ !byte $FD ; SMC
+STAY @key
jsr okvs_get ; get module type
!word gAttractModeStore
@key !word $FDFD ; SMC
+STAY PTR
ldy #1
lda (PTR),y
tax ; X = module type
+LDAY @key ; A/Y = address of module name
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
@exit rts
@MiniAttractIndex
!byte $FD
;------------------------------------------------------------------------------
; 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-06-26 02:44:39 +00:00
txa
cmp #$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
ldx #$60
jsr GetGameDisplayName
bcc + ; if game doesn't exist, skip the demo
rts
+
2019-06-26 02:44:39 +00:00
jsr Home ; avoid seeing code load into the HGR page
2019-09-10 02:38:17 +00:00
ldy kDemoDirectory
2019-06-26 02:44:39 +00:00
sty ProDOS_prefix ; temporarily set 'root' directory to
2019-09-10 02:38:17 +00:00
- lda kDemoDirectory, y ; /demos/ directory so demos can can load
2019-06-26 02:44:39 +00:00
sta ProDOS_prefix, y ; other resources in the same directory
dey
bne -
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
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
asl
tax
lda @slideshows-2,x
sta @jmp+1
lda @slideshows-1,x
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
clc
adc #$06
bne - ; always branches
2019-09-10 02:38:17 +00:00
2019-01-13 23:55:40 +00:00
@slideshows
!word HGRTitleSlideshow
!word HGRActionSlideshow
!word DHGRTitleSlideshow
2019-02-09 01:48:07 +00:00
!word DHGRActionSlideshow
2019-06-26 02:44:39 +00:00
!word SHRSlideshow
!word GRActionSlideshow
@singles
2019-06-26 02:44:39 +00:00
!word HGRSingle
!word DHGRSingle
!word SHRSingle
!word GRSingle
2019-01-13 23:55:40 +00:00
2019-06-26 02:44:39 +00:00
LoadAndParseAttractModeConf
2019-06-30 19:18:51 +00:00
; TODO refactor launch code then make this private
2019-09-10 02:58:16 +00:00
jsr LoadFile ; load attract-mode configuration file into $8000
2019-09-10 02:38:17 +00:00
!word kRootDirectory
!word @AttractModeConfFile
2019-09-10 02:58:16 +00:00
- !word $8000
2019-06-26 02:44:39 +00:00
jsr ParseKeyValueList ; parse attract-mode configuration into OKVS data structure at $6000
!word gAttractModeStore
2019-09-10 02:58:16 +00:00
!word -
2019-06-26 02:44:39 +00:00
!byte 0
rts
2019-06-26 02:44:39 +00:00
@AttractModeConfFile
!byte 12
!text "ATTRACT.CONF"