2018-11-07 23:56:39 +00:00
|
|
|
;license:MIT
|
|
|
|
;(c) 2018 by 4am
|
|
|
|
;
|
|
|
|
; Mega Attract Mode - cycle through slideshows and self-running demos
|
|
|
|
;
|
|
|
|
; Public functions
|
2019-06-22 19:50:24 +00:00
|
|
|
; - MegaAttractMode
|
|
|
|
;;;;;; - RunAttractModule
|
2018-11-07 23:56:39 +00:00
|
|
|
;
|
2018-11-17 14:43:20 +00:00
|
|
|
; 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-11-07 23:56:39 +00:00
|
|
|
|
2018-12-29 18:29:17 +00:00
|
|
|
;------------------------------------------------------------------------------
|
2019-06-22 19:50:24 +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)
|
|
|
|
;------------------------------------------------------------------------------
|
2019-06-22 19:50:24 +00:00
|
|
|
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
|
2018-12-28 20:08:36 +00:00
|
|
|
!word gAttractModeStore
|
2018-12-29 18:29:17 +00:00
|
|
|
!word ldrlo2 ; (ldrlo2) points to last load address, so $8000
|
2018-12-28 20:08:36 +00:00
|
|
|
!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
|
|
|
|
|
2018-11-07 23:56:39 +00:00
|
|
|
jsr okvs_nth ; get filename of next attract-mode module
|
|
|
|
!word gAttractModeStore
|
2018-11-17 14:54:55 +00:00
|
|
|
gAttractIndex
|
|
|
|
!byte 0
|
2018-11-07 23:56:39 +00:00
|
|
|
+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
|
2018-11-07 23:56:39 +00:00
|
|
|
jsr okvs_len
|
|
|
|
!word gAttractModeStore
|
2018-11-17 14:54:55 +00:00
|
|
|
cmp gAttractIndex
|
2018-11-07 23:56:39 +00:00
|
|
|
bne +
|
|
|
|
lda #0
|
2018-11-17 14:54:55 +00:00
|
|
|
sta gAttractIndex
|
2018-11-07 23:56:39 +00:00
|
|
|
+
|
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
|
|
|
|
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
|
|
|
|
|
|
|
|
jsr @RunNextAttractModule
|
|
|
|
lda $C000
|
2019-06-19 02:40:17 +00:00
|
|
|
bmi +
|
2019-06-22 19:50:24 +00:00
|
|
|
jmp MegaAttractMode
|
2019-06-19 02:40:17 +00:00
|
|
|
+
|
2018-11-07 23:56:39 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
@RunNextAttractModule
|
|
|
|
ldy #1
|
|
|
|
lda (PTR),y
|
|
|
|
and #$0F
|
2019-06-22 19:50:24 +00:00
|
|
|
; 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-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
|
|
|
|
|
|
|
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
|
2018-11-07 23:56:39 +00:00
|
|
|
+LOAD_PATH kDemoDirectory
|
|
|
|
ldy gPathname
|
|
|
|
sty ProDOS_prefix
|
2019-01-10 17:42:50 +00:00
|
|
|
- lda gPathname, y
|
2018-11-07 23:56:39 +00:00
|
|
|
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
|
2018-11-07 23:56:39 +00:00
|
|
|
|
2019-06-22 19:50:24 +00:00
|
|
|
@NotDemo ; slideshow module or screenshot
|
|
|
|
; cmp #$06 ; 1-5 are slideshow modules
|
|
|
|
; bcs @Single ; higher values are screenshot modules
|
|
|
|
|
|
|
|
pha ; save module type
|
2018-11-07 23:56:39 +00:00
|
|
|
|
2018-12-30 02:25:16 +00:00
|
|
|
; load slideshow configuration file at $4000
|
2018-11-07 23:56:39 +00:00
|
|
|
+LOAD_FILE kAttractModeSlideshowDirectory, @key
|
|
|
|
|
2018-12-30 02:25:16 +00:00
|
|
|
jsr ParseKeyValueList ; parse slideshow configuration 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-11 18:56:00 +00:00
|
|
|
|
2018-11-07 23:56:39 +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
|
2019-06-22 19:50:24 +00:00
|
|
|
!word 0
|
|
|
|
; !word HGRSingle
|
|
|
|
; !word DHGRSingle
|
|
|
|
; !word SHRSingle
|
2019-01-13 23:55:40 +00:00
|
|
|
|
2018-12-28 20:08:36 +00:00
|
|
|
kAttractModeConfFile
|
2018-12-29 18:29:17 +00:00
|
|
|
!byte @kAttractModeConfFile_e-*-1
|
2018-12-28 20:08:36 +00:00
|
|
|
!text "ATTRACT.CONF"
|
|
|
|
@kAttractModeConfFile_e
|
2018-11-07 23:56:39 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; 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
|
|
|
;------------------------------------------------------------------------------
|
2018-11-07 23:56:39 +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
|
2018-11-07 23:56:39 +00:00
|
|
|
ldx #(@end-@start-1)
|
|
|
|
- lda @start,x
|
2019-01-08 19:10:26 +00:00
|
|
|
sta $106,x
|
2018-11-07 23:56:39 +00:00
|
|
|
dex
|
|
|
|
bpl -
|
2019-01-08 19:10:26 +00:00
|
|
|
jmp $106
|
2018-11-07 23:56:39 +00:00
|
|
|
@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
|