2018-11-07 23:56:39 +00:00
|
|
|
;license:MIT
|
2021-10-12 23:37:45 +00:00
|
|
|
;(c) 2018-2021 by 4am & qkumba
|
2018-11-07 23:56:39 +00:00
|
|
|
;
|
2019-09-21 03:26:32 +00:00
|
|
|
; Attract Mode - cycle through slideshows and self-running demos
|
2018-11-07 23:56:39 +00:00
|
|
|
;
|
|
|
|
; Public functions
|
2019-06-22 19:50:24 +00:00
|
|
|
; - MegaAttractMode
|
2019-09-21 03:26:32 +00:00
|
|
|
; - MiniAttractMode
|
2019-06-26 02:44:39 +00:00
|
|
|
; - RunAttractModule
|
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-09-26 03:01:59 +00:00
|
|
|
jsr SwitchToBank1
|
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
|
|
|
|
2021-11-13 01:46:05 +00:00
|
|
|
jsr LoadIndexedFile ; load pre-parsed attract mode configuration data into $6000
|
|
|
|
!word kTotalIndexFile
|
2021-10-12 23:37:45 +00:00
|
|
|
- !word $6000
|
2021-11-13 01:46:05 +00:00
|
|
|
!word kAttractModeIndexRecord
|
2018-12-28 20:08:36 +00:00
|
|
|
|
2019-09-16 16:36:10 +00:00
|
|
|
jsr pref_get ; get attract mode module from prefs
|
2018-12-28 20:08:36 +00:00
|
|
|
!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
|
2018-11-07 23:56:39 +00:00
|
|
|
|
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
|
2021-11-12 03:20:06 +00:00
|
|
|
; 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
|
2020-03-24 20:30:14 +00:00
|
|
|
+ST16 +
|
2021-11-13 01:46:05 +00:00
|
|
|
jsr LoadIndexedFile
|
|
|
|
!word kTotalIndexFile
|
2021-11-10 04:51:09 +00:00
|
|
|
- !word $0800
|
2021-11-13 01:46:05 +00:00
|
|
|
!word kMiniAttractIndexRecord
|
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
|
|
|
+ !word $FDFD ; SMC
|
2021-11-09 17:41:15 +00:00
|
|
|
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-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
|
2021-11-09 17:41:15 +00:00
|
|
|
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
|
|
|
|
2019-06-22 19:50:24 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; RunAttractModule
|
|
|
|
; run a single attract module of any type and return to caller
|
|
|
|
;
|
2019-07-15 15:42:05 +00:00
|
|
|
; 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)
|
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
|
2020-03-24 20:30:14 +00:00
|
|
|
+ST16 @key
|
|
|
|
+ST16 @key2
|
2019-09-24 00:01:42 +00:00
|
|
|
cpx #$30
|
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.
|
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.
|
2018-11-11 13:42:53 +00:00
|
|
|
|
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|
|
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
|
2019-09-24 00:01:42 +00:00
|
|
|
txa
|
2019-07-15 15:42:05 +00:00
|
|
|
cmp #$41 ; numbers are slideshow modules,
|
|
|
|
bcs @dispatchSingle ; letters are single files
|
2019-06-22 19:50:24 +00:00
|
|
|
|
2021-10-12 23:37:45 +00:00
|
|
|
; it's a slideshow, so load slideshow configuration file
|
2019-06-22 19:50:24 +00:00
|
|
|
pha ; save module type
|
2021-11-13 01:46:05 +00:00
|
|
|
jsr LoadIndexedFile ; load slideshow configuration file into $4000
|
|
|
|
!word kTotalIndexFile
|
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 -
|
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
|
2018-11-07 23:56:39 +00:00
|
|
|
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
|
|
|
|
2019-07-15 15:42:05 +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-07-15 15:42:05 +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
|
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
|