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

241 lines
8.1 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
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)
2021-10-06 20:22:54 +00:00
jsr LoadFile ; load pre-parsed attract mode configuration data into $6000
2019-09-21 03:26:32 +00:00
!word kRootDirectory
2021-10-13 02:55:41 +00:00
!word kAttractModeIndexFile
2021-10-12 23:37:45 +00:00
- !word $6000
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
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.
2021-11-03 01:49:41 +00:00
+LD16 gLastMegaAttractGame
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
;------------------------------------------------------------------------------
MiniAttractMode
2019-10-08 18:43:41 +00:00
jsr GetGameToLaunch
2020-03-24 20:30:14 +00:00
+ST16 +
2021-10-29 01:36:07 +00:00
jsr LoadFile
2021-10-12 23:37:45 +00:00
!word kRootDirectory
2021-10-13 02:55:41 +00:00
!word kMiniAttractIndexFile
2021-10-12 23:37:45 +00:00
- !word $6000
jsr okvs_find
2019-09-10 02:58:16 +00:00
!word -
2021-10-12 23:37:45 +00:00
+ !word $FDFD ; SMC
jsr okvs_next_field
2021-10-29 19:59:35 +00:00
jsr SwitchToBank2
sty OKVS_CACHE
2021-10-29 01:36:07 +00:00
ldy #4
- 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
2021-10-29 01:36:07 +00:00
jsr BlankHGR
; X = 0
stx @MiniAttractIndex+1
stx @MiniAttractIndex+3
@loop
2021-10-29 19:14:48 +00:00
jsr SwitchToBank2
2021-10-29 18:39:43 +00:00
jsr resetRoot
2021-10-13 22:04:56 +00:00
jsr LoadIndexedFile
2021-11-09 18:05:33 +00:00
!word kTotalDataFile
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
+ST16 @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.
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
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)
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
2021-10-12 23:37:45 +00:00
; it's a slideshow, so load slideshow configuration file
pha ; save module type
2019-09-10 02:58:16 +00:00
jsr LoadFile ; load slideshow configuration file into $4000
2021-10-13 02:55:41 +00:00
!word kAttractModeSlideshowIndexFile
2021-10-12 23:37:45 +00:00
!word kRootDirectory
2019-09-10 02:58:16 +00:00
- !word $4000
2021-10-12 23:37:45 +00:00
jsr okvs_find
2019-09-10 02:58:16 +00:00
!word -
2021-10-12 23:37:45 +00:00
@key2 !word $FDFD ; SMC
2021-10-13 22:04:56 +00:00
+ST16 +
jsr LoadIndexedFile
2021-11-09 18:05:33 +00:00
!word kTotalDataFile
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
@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
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