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

295 lines
10 KiB
Plaintext
Raw Normal View History

;license:MIT
2021-10-12 23:37:45 +00:00
;(c) 2018-2021 by 4am & qkumba
;
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
kAttractModeFilters
!byte ATTRACT_DEMO
!byte ATTRACT_HGR_TITLE
!byte ATTRACT_HGR_ACTION
!byte ATTRACT_DHGR_TITLE
!byte ATTRACT_DHGR_ACTION
!byte ATTRACT_SHR
!byte ATTRACT_GR
!byte ATTRACT_DGR
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)
jsr LoadIndexedFile ; load pre-parsed attract mode configuration data into $6000
2021-10-12 23:37:45 +00:00
- !word $6000
2021-11-13 01:46:05 +00:00
!word kAttractModeIndexRecord
@next
2019-09-16 16:36:10 +00:00
jsr pref_get ; get attract mode module from prefs
!word kNextAttract
2021-10-12 23:37:45 +00:00
!word -
2020-03-24 20:30:14 +00:00
+ST16 @mname ; A/Y = module name
; $WINDEX = index of module in attract store
2021-10-12 23:37:45 +00:00
+LDADDR -
2019-09-16 16:36:10 +00:00
jsr okvs_next ; get module after this one
2020-03-24 20:30:14 +00:00
+ST16 +
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
2021-10-12 23:37:45 +00:00
jsr okvs_get ; sets PTR
!word -
2019-09-16 16:36:10 +00:00
@mname !word $FDFD ; SMC
2019-06-26 02:44:39 +00:00
ldy #1
lda (PTR),y
tax ; X = module type as ASCII digit
and #$0F ; do we want to display this module type
tay
lda gMegaAttractModeFilter
and kAttractModeFilters, y
beq @next
2020-03-24 20:30:14 +00:00
+LD16 @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.
jsr ReloadSearchIndexOnly
2021-11-03 01:49:41 +00:00
+LD16 gLastMegaAttractGame
+ST16 @game
jsr okvs_find
!word SearchIndexHandle
@game !word $FDFD ; SMC
2021-11-03 01:49:41 +00:00
jsr PlayGameInAY ; (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
;
2021-10-28 05:28:20 +00:00
; in: gGameToLaunch = index in gSearchStore (word)
; gSearchStore populated
2019-06-27 02:51:34 +00:00
; out: all flags and registers clobbered
; assume all of main memory has been clobbered (including gSearchStore)
2019-06-27 02:51:34 +00:00
;------------------------------------------------------------------------------
MiniAttractMode
2019-10-08 18:43:41 +00:00
jsr GetGameToLaunch
+ST16 @GameToLaunch
2022-05-04 16:41:40 +00:00
; We want to load the mini attract index into $800 so we can get the
; index record for this game, but we now have so many games that the
; entire index is larger than $1800 bytes and loading it all at once
; would visibly overwrite bytes in HGR page 1. So the index is now
; split into 2 halves based on the first letter of the game's
; directory name, and we figure out which half we want and load it.
+ST16 PTR
ldy #1
lda (PTR), y
sec
sbc #$41 ; A in [0..25]
lsr ; A in [0..15]
lsr ; A in [0..7]
lsr ; A in [0..3]
lsr ; A in [0..1]
tax
lda kMiniAttractIndexLo, x
sta @MiniAttractIndexRecord
lda kMiniAttractIndexHi, x
sta @MiniAttractIndexRecord+1
2021-11-13 01:46:05 +00:00
jsr LoadIndexedFile
- !word $0800
@MiniAttractIndexRecord
!word $FDFD ; SMC
2022-05-04 16:41:40 +00:00
; Find the index record for this game and copy it into LC RAM so we
; can reuse it without reloading the mini attract index over and over
; during attract mode.
2021-10-12 23:37:45 +00:00
jsr okvs_find
2019-09-10 02:58:16 +00:00
!word -
@GameToLaunch
!word $FDFD ; SMC
jsr okvs_next_field
2021-10-29 19:59:35 +00:00
jsr SwitchToBank2
sty OKVS_CACHE
2022-05-04 16:41:40 +00:00
ldy #4 ; length of index record (-1)
2021-10-29 01:36:07 +00:00
- lda (PTR), y
2021-10-29 19:59:35 +00:00
sta OKVS_CACHE + 1, y
2021-10-29 01:36:07 +00:00
dey
bpl -
2021-10-13 22:04:56 +00:00
2022-05-04 16:41:40 +00:00
; Now, finally, start the mini attract mode
2021-10-29 01:36:07 +00:00
jsr BlankHGR
; X = 0
stx @MiniAttractIndex+1
stx @MiniAttractIndex+3
@loop
2021-10-13 22:04:56 +00:00
jsr LoadIndexedFile
2021-10-12 23:37:45 +00:00
- !word $6000
2021-10-29 19:59:35 +00:00
!word OKVS_CACHE
2021-10-13 22:04:56 +00:00
2021-10-12 23:37:45 +00:00
+LDADDR -
2019-06-27 02:51:34 +00:00
jsr okvs_len
2020-03-24 20:30:14 +00:00
lda WCOUNT
2021-10-12 23:37:45 +00:00
cmp @MiniAttractIndex+1
2020-03-24 20:30:14 +00:00
bne +
lda WCOUNT+1
2021-10-12 23:37:45 +00:00
cmp @MiniAttractIndex+3
2019-10-08 18:56:20 +00:00
beq ATTRTS ; we've run through all modules, so exit to caller
2020-03-24 20:30:14 +00:00
+
2021-10-12 23:37:45 +00:00
@MiniAttractIndex
2021-10-14 05:43:50 +00:00
+LDADDR 0 ; SMC
2020-03-24 20:30:14 +00:00
+ST16 WINDEX
2021-10-12 23:37:45 +00:00
+LDADDR -
2019-06-27 02:51:34 +00:00
jsr okvs_nth ; get the next module on the list
2020-03-24 20:30:14 +00:00
+ST16 SAVE
jsr okvs_next_field ; get module type
2021-10-13 22:58:26 +00:00
; Y = 0
iny
2019-06-27 02:51:34 +00:00
lda (PTR),y
tax ; X = module type
2020-03-24 20:30:14 +00:00
+LD16 SAVE ; A/Y = address of module name
2019-06-27 02:51:34 +00:00
jsr RunAttractModule ; execute the module
2021-10-12 23:37:45 +00:00
inc @MiniAttractIndex+1
2020-03-24 20:30:14 +00:00
bne +
2021-10-12 23:37:45 +00:00
inc @MiniAttractIndex+3
2020-03-24 20:30:14 +00:00
+
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
2020-03-24 20:30:14 +00:00
+ST16 @key
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.
2021-11-03 01:49:41 +00:00
; Each demo has been patched to check joystick and memory requirements,
; so a demo won't run if the actual game wouldn't be playable.
; Demos are also patched to jump back to the |Reenter| entry point
; on any key, or at the natural end of the demo cycle.
2018-12-29 18:29:17 +00:00
; All demos are strictly 48K / main memory. No demo uses the
; language card or auxiliary memory.
2021-11-03 01:49:41 +00:00
+ST16 PTR
ldy #0
lda (PTR), y
tay
- lda (PTR), y
sta DemoFilename, y
dey
bpl -
+LDADDR DemoFilename
+ST16 gLastMegaAttractGame ; save game filename in LC in case user hits Return to launch
2022-10-01 00:04:02 +00:00
+ST16 xfile
2021-11-03 01:49:41 +00:00
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)
2021-10-13 22:58:45 +00:00
jsr LoadStandardPrelaunch ; load standard prelaunch code (|Launch| will call it)
2022-10-01 00:04:02 +00:00
jsr LoadIndexedFile ; load demo index file
- !word gSearchCache
!word kDemoIndexRecord
jsr LoadXFile ; load self-running demo into its default address (varies)
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
2021-10-12 23:37:45 +00:00
; it's a slideshow, so load slideshow configuration file
pha ; save module type
2021-11-13 01:46:05 +00:00
jsr LoadIndexedFile ; load slideshow configuration file into $4000
2019-09-10 02:58:16 +00:00
- !word $4000
2021-11-13 01:46:05 +00:00
!word kAttractModeSlideshowIndexRecord
2021-10-12 23:37:45 +00:00
jsr okvs_find
2019-09-10 02:58:16 +00:00
!word -
2022-10-01 00:04:02 +00:00
@key !word $FDFD ; SMC
2021-10-13 22:04:56 +00:00
+ST16 +
jsr LoadIndexedFile
2021-10-12 23:37:45 +00:00
!word $800
2021-10-13 22:04:56 +00:00
+ !word $FDFD ; SMC
pla ; restore module type
2021-10-13 22:58:26 +00:00
+HIDE_NEXT_2_BYTES
@dispatchSingle
adc #(@singleslo-@slideshowslo)-1
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
2020-03-24 20:30:14 +00:00
+LD16 @key ; pass in module name
2019-01-13 23:55:40 +00:00
@jmp jmp $FDFD ; SMC
2019-09-11 04:26:00 +00:00
@slideshowslo
!byte <HGRTitleSlideshow
!byte <HGRActionSlideshow
!byte <DHGRTitleSlideshow
!byte <DHGRActionSlideshow
!byte <SHRSlideshow
!byte <GRActionSlideshow
!byte <DGRActionSlideshow
2019-09-11 04:26:00 +00:00
@singleslo
!byte <HGRSingle
!byte <DHGRSingle
!byte <SHRSingle
!byte <GRSingle
!byte <DGRSingle
2019-09-11 04:26:00 +00:00
@slideshowshi
!byte >HGRTitleSlideshow
!byte >HGRActionSlideshow
!byte >DHGRTitleSlideshow
!byte >DHGRActionSlideshow
!byte >SHRSlideshow
!byte >GRActionSlideshow
!byte >DGRActionSlideshow
2019-09-11 04:26:00 +00:00
@singleshi
!byte >HGRSingle
!byte >DHGRSingle
!byte >SHRSingle
!byte >GRSingle
!byte >DGRSingle
2021-11-03 01:49:41 +00:00
DemoFilename
!byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15