2018-11-07 23:56:39 +00:00
|
|
|
;license:MIT
|
2019-06-24 02:32:18 +00:00
|
|
|
;(c) 2018-9 by 4am
|
2018-11-07 23:56:39 +00:00
|
|
|
;
|
|
|
|
; Mega Attract Mode - cycle through slideshows and self-running demos
|
|
|
|
;
|
|
|
|
; Public functions
|
2019-06-22 19:50:24 +00:00
|
|
|
; - MegaAttractMode
|
2019-06-26 02:44:39 +00:00
|
|
|
; - RunAttractModule
|
|
|
|
; - LoadAndParseAttractModeConf
|
2018-11-07 23:56:39 +00:00
|
|
|
|
2018-12-29 18:29:17 +00:00
|
|
|
;------------------------------------------------------------------------------
|
2019-06-22 19:50:24 +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
|
2019-06-24 02:32:18 +00:00
|
|
|
; out: never returns to caller (may JMP to other major modes)
|
2018-12-29 18:29:17 +00:00
|
|
|
;------------------------------------------------------------------------------
|
2019-06-22 19:50:24 +00:00
|
|
|
MegaAttractMode
|
2019-06-27 14:55:07 +00:00
|
|
|
+READ_RAM1_WRITE_RAM1
|
2019-06-24 02:32:18 +00:00
|
|
|
ldx #$FF
|
|
|
|
txs
|
|
|
|
|
|
|
|
jsr BlankHGR ; switch to HGR page 1 (once cleared)
|
2019-06-23 18:24:09 +00:00
|
|
|
|
2019-06-26 02:44:39 +00:00
|
|
|
jsr LoadAndParseAttractModeConf
|
2018-12-28 20:08:36 +00:00
|
|
|
|
|
|
|
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
|
2018-12-28 20:08:36 +00:00
|
|
|
|
2018-11-07 23:56:39 +00:00
|
|
|
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
|
2018-11-07 23:56:39 +00:00
|
|
|
+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
|
2018-11-07 23:56:39 +00:00
|
|
|
jsr okvs_len
|
|
|
|
!word gAttractModeStore
|
2019-06-26 02:44:39 +00:00
|
|
|
cmp @attractIndex
|
2018-11-07 23:56:39 +00:00
|
|
|
bne +
|
|
|
|
lda #0
|
2019-06-26 02:44:39 +00:00
|
|
|
sta @attractIndex
|
2018-11-07 23:56:39 +00:00
|
|
|
+
|
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
|
|
|
|
2018-11-07 23:56:39 +00:00
|
|
|
jsr okvs_get
|
|
|
|
!word gAttractModeStore
|
2018-12-29 18:29:17 +00:00
|
|
|
@key !word $FDFD ; SMC
|
2018-11-07 23:56:39 +00:00
|
|
|
+STAY PTR
|
|
|
|
|
2019-06-26 02:44:39 +00:00
|
|
|
ldy #1
|
|
|
|
lda (PTR),y
|
|
|
|
and #$0F ; convert ASCII digit to integer
|
|
|
|
tax ; X = module type
|
|
|
|
+LDAY @key ; A/Y = address of module name
|
|
|
|
jsr RunAttractModule
|
2019-06-27 14:55:07 +00:00
|
|
|
lda KBD
|
2019-06-23 18:24:09 +00:00
|
|
|
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.
|
2019-06-23 18:24:09 +00:00
|
|
|
@jmpattract
|
2019-06-22 19:50:24 +00:00
|
|
|
jmp MegaAttractMode
|
2019-06-23 18:24:09 +00:00
|
|
|
@jmpsearch
|
|
|
|
jmp SearchMode
|
2018-11-07 23:56:39 +00:00
|
|
|
|
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
|
|
|
|
+STAY @MiniAttractGame
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta @MiniAttractIndex
|
|
|
|
|
|
|
|
@loop
|
|
|
|
; load mini attract mode configuration file at $8000
|
|
|
|
+LOAD_FILE kMiniAttractDirectory, @MiniAttractGame
|
|
|
|
|
|
|
|
jsr ParseKeyValueList ; parse configuration into OKVS data structure at $6000
|
|
|
|
!word gAttractModeStore
|
|
|
|
!word ldrlo2 ; (ldrlo2) points to last load address, so $8000
|
|
|
|
!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
|
|
|
|
and #$0F ; convert ASCII digit to integer
|
|
|
|
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
|
|
|
|
@MiniAttractGame
|
|
|
|
!word $FDFD
|
|
|
|
|
2019-06-22 19:50:24 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; RunAttractModule
|
|
|
|
; run a single attract module of any type and return to caller
|
|
|
|
;
|
2019-06-26 02:44:39 +00:00
|
|
|
; in: X = module type (1-9, see attract.conf)
|
|
|
|
; 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)
|
2019-06-22 19:50:24 +00:00
|
|
|
; 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
|
|
|
|
txa
|
2019-06-22 19:50:24 +00:00
|
|
|
bne @NotDemo
|
2018-11-07 23:56:39 +00:00
|
|
|
|
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.
|
2018-11-11 13:42:53 +00:00
|
|
|
|
2019-07-08 19:03:25 +00:00
|
|
|
+LDAY @key
|
|
|
|
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
|
2018-11-07 23:56:39 +00:00
|
|
|
+LOAD_PATH kDemoDirectory
|
|
|
|
ldy gPathname
|
2019-06-26 02:44:39 +00:00
|
|
|
sty ProDOS_prefix ; temporarily set 'root' directory to
|
|
|
|
- lda gPathname, y ; /demos/ directory so demos can can load
|
|
|
|
sta ProDOS_prefix, y ; other resources in the same directory
|
2018-11-07 23:56:39 +00:00
|
|
|
dey
|
|
|
|
bne -
|
2019-06-26 02:44:39 +00:00
|
|
|
+LOAD_FILE_IMM @key ; load self-running demo (address varies)
|
|
|
|
jsr SaveOrRestoreScreenHoles ; save screen hole contents
|
|
|
|
jmp Launch ; will return to caller via |Reenter|
|
2018-11-07 23:56:39 +00:00
|
|
|
|
2019-06-26 02:44:39 +00:00
|
|
|
; not a demo, so maybe a slideshow or single screenshot
|
|
|
|
@NotDemo
|
|
|
|
cmp #$06 ; 1-5 are slideshow modules
|
|
|
|
bcs @startDispatch
|
2019-06-22 19:50:24 +00:00
|
|
|
|
2019-06-30 19:18:51 +00:00
|
|
|
; it's a slideshow, so load and parse slideshow configuration file
|
2019-06-22 19:50:24 +00:00
|
|
|
pha ; save module type
|
2019-06-30 19:18:51 +00:00
|
|
|
+LOAD_FILE kAttractModeSlideshowDirectory, @key ; load slideshow configuration file at $4000
|
|
|
|
jsr ParseKeyValueList ; parse into an OKVS data structure at $0800
|
2018-11-07 23:56:39 +00:00
|
|
|
!word gSlideshowStore
|
2018-12-30 02:25:16 +00:00
|
|
|
!word ldrlo2 ; (ldrlo2) points to address of last loaded file, so $4000
|
2018-11-11 13:42:53 +00:00
|
|
|
!byte 0
|
2018-11-07 23:56:39 +00:00
|
|
|
pla ; restore module type
|
2019-06-26 02:44:39 +00:00
|
|
|
|
|
|
|
@startDispatch
|
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
|
2019-06-26 02:44:39 +00:00
|
|
|
@key !word $FDFD ; SMC
|
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
|
2019-06-22 19:50:24 +00:00
|
|
|
!word 0
|
2019-06-26 02:44:39 +00:00
|
|
|
!word HGRSingle
|
|
|
|
!word DHGRSingle
|
|
|
|
!word SHRSingle
|
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-06-26 02:44:39 +00:00
|
|
|
+LDADDR @AttractModeConfFile
|
|
|
|
jsr SetPath
|
|
|
|
jsr LoadFile ; load attract-mode configuration file at $8000
|
2018-11-07 23:56:39 +00:00
|
|
|
|
2019-06-26 02:44:39 +00:00
|
|
|
jsr ParseKeyValueList ; parse attract-mode configuration into OKVS data structure at $6000
|
|
|
|
!word gAttractModeStore
|
|
|
|
!word ldrlo2 ; (ldrlo2) points to last load address, so $8000
|
|
|
|
!byte 0
|
2018-11-07 23:56:39 +00:00
|
|
|
rts
|
2019-06-26 02:44:39 +00:00
|
|
|
@AttractModeConfFile
|
|
|
|
!byte 12
|
|
|
|
!text "ATTRACT.CONF"
|