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

208 lines
6.8 KiB
Plaintext
Raw Normal View History

;license:MIT
;(c) 2018 by 4am
;
; Mega Attract Mode - cycle through slideshows and self-running demos
;
; Public functions
; - MegaAttractMode
;;;;;; - RunAttractModule
;
; Public variables
2019-01-08 20:01:45 +00:00
; - gAttractIndex ; [byte] numeric index in gAttractModeStore of next Mega-Attract Module
; - gFXIndex ; [byte] numeric index in gFXStore of next HGR transition effect
; - gDFXIndex ; [byte] numeric index in gDFXStore of next DHGR transition effect
2018-12-29 18:29:17 +00:00
;------------------------------------------------------------------------------
; MegaAttractMode
2018-12-29 18:29:17 +00:00
; main entry point for Mega Attract Mode, which cycles through modules listed
; in ATTRACT.CONF to provide pretty visual effects and snippets of self-running
; self-terminating game demos
;
; in: gGlobalPrefsStore must be initialized
; out: exits to caller (note that some attract mode modules never return but
; instead call |Reenter|, in which case this routine technically never
; returns)
; if this routine returns, everything is clobbered (zero page, main
; memory, unused portions of the stack page, all registers, all flags)
;------------------------------------------------------------------------------
MegaAttractMode
2019-06-19 02:40:17 +00:00
+LDADDR kAttractModeConfFile
jsr SetPath
2018-12-29 18:29:17 +00:00
jsr LoadFile ; load attract-mode configuration file at $8000
2019-06-19 02:40:17 +00:00
2018-12-29 18:29:17 +00:00
jsr ParseKeyValueList ; parse attract-mode configuration into OKVS data structure at $6000
!word gAttractModeStore
2018-12-29 18:29:17 +00:00
!word ldrlo2 ; (ldrlo2) points to last load address, so $8000
!byte 0
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
+ stx gAttractIndex
jsr okvs_nth ; get filename of next attract-mode module
!word gAttractModeStore
2018-11-17 14:54:55 +00:00
gAttractIndex
!byte 0
+STAY @key
2019-01-08 20:01:45 +00:00
lda gAttractIndex
sta gCurrentAttractIndex
2018-11-17 14:54:55 +00:00
inc gAttractIndex ; increment module index for next time
jsr okvs_len
!word gAttractModeStore
2018-11-17 14:54:55 +00:00
cmp gAttractIndex
bne +
lda #0
2018-11-17 14:54:55 +00:00
sta gAttractIndex
+
2018-11-17 14:54:55 +00:00
lda gAttractIndex
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
jsr @RunNextAttractModule
lda $C000
2019-06-19 02:40:17 +00:00
bmi +
jmp MegaAttractMode
2019-06-19 02:40:17 +00:00
+
rts
@RunNextAttractModule
ldy #1
lda (PTR),y
and #$0F
; jsr RunAttractModule
;------------------------------------------------------------------------------
; RunAttractModule
; run a single attract module of any type and return to caller
;
; in: A = module type (#$01..#$09, see attract.conf)
; gGlobalPrefsStore must be initialized
; out: all flags and registers clobbered
; assume all of main memory has been clobbered
;------------------------------------------------------------------------------
;RunAttractModule
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.
jsr Home ; clear text screen and switch to it during loading
2018-12-29 18:29:17 +00:00
; to avoid seeing executable code load into the HGR page
+LOAD_PATH kDemoDirectory
ldy gPathname
sty ProDOS_prefix
2019-01-10 17:42:50 +00:00
- lda gPathname, y
sta ProDOS_prefix, y
dey
bne -
+LOAD_FILE_IMM @key
2018-11-26 19:43:39 +00:00
jsr SaveScreenHoles ; save screen hole contents in case game changes them
2019-01-10 17:42:50 +00:00
jmp copy_prelaunch
@NotDemo ; slideshow module or screenshot
; cmp #$06 ; 1-5 are slideshow modules
; bcs @Single ; higher values are screenshot modules
pha ; save module type
2018-12-30 02:25:16 +00:00
; load slideshow configuration file at $4000
+LOAD_FILE kAttractModeSlideshowDirectory, @key
2018-12-30 02:25:16 +00:00
jsr ParseKeyValueList ; parse slideshow configuration into an OKVS data structure at $0800
!word gSlideshowStore
2018-12-30 02:25:16 +00:00
!word ldrlo2 ; (ldrlo2) points to address of last loaded file, so $4000
!byte 0
2018-11-11 18:56:00 +00:00
pla ; restore module type
2019-01-13 23:55:40 +00:00
asl
tax
lda @slideshows-2,x
sta @jmp+1
lda @slideshows-1,x
sta @jmp+2
@jmp jmp $FDFD ; SMC
@slideshows
!word HGRTitleSlideshow
!word HGRActionSlideshow
!word DHGRTitleSlideshow
2019-02-09 01:48:07 +00:00
!word DHGRActionSlideshow
2019-01-13 23:55:40 +00:00
!word SHRArtworkSlideshow
!word 0
; !word HGRSingle
; !word DHGRSingle
; !word SHRSingle
2019-01-13 23:55:40 +00:00
kAttractModeConfFile
2018-12-29 18:29:17 +00:00
!byte @kAttractModeConfFile_e-*-1
!text "ATTRACT.CONF"
@kAttractModeConfFile_e
;------------------------------------------------------------------------------
; internal functions
2018-12-29 18:29:17 +00:00
;------------------------------------------------------------------------------
; Home
; clear and display text screen
;
; in: none
2019-01-08 19:10:26 +00:00
; out: $0106..$011F clobbered
2018-12-29 18:29:17 +00:00
;------------------------------------------------------------------------------
Home
2019-01-18 03:09:36 +00:00
lda MachineStatus
and #SUPPORTS_SHR
beq @noSHR
lda $C035
ora #$08
sta $C035 ; turn off auxmem-to-bank-E1 shadowing
lda $C029
and #$7F
sta $C029 ; get out of SHR mode
@noSHR
ldx #(@end-@start-1)
- lda @start,x
2019-01-08 19:10:26 +00:00
sta $106,x
dex
bpl -
2019-01-08 19:10:26 +00:00
jmp $106
@start
; this will be run from main memory
+READ_ROM_NO_WRITE
sta $C00C ; get out of DHGR mode
sta $C05F ; get out of DHGR mode
jsr $FB2F ; TEXT
jsr $FC58 ; HOME
+READ_RAM1_WRITE_RAM1
rts
@end