mirror of
https://github.com/a2-4am/4cade.git
synced 2024-09-27 12:57:21 +00:00
389 lines
12 KiB
Plaintext
389 lines
12 KiB
Plaintext
;license:MIT
|
|
;(c) 2018 by 4am
|
|
;
|
|
; Mega Attract Mode - cycle through slideshows and self-running demos
|
|
;
|
|
; Public functions
|
|
; - AttractMode
|
|
;
|
|
; Public variables
|
|
; - gAttractIndex ; [byte] numeric index of Mega-Attract Module
|
|
; - gFXIndex ; [byte] numeric index of HGR transition effect
|
|
; - gDFXIndex ; [byte] numeric index of DHGR transition effect
|
|
|
|
AttractMode
|
|
jsr LoadFile ; load attract-mode configuration into $8000
|
|
!word kAttractModeConfFile
|
|
jsr ParseKeyValueList ; parse attract-mode configuration into $6000
|
|
!word gAttractModeStore
|
|
!word ldrlo2 ; (ldrlo2) points to last load address
|
|
!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
|
|
gAttractIndex
|
|
!byte 0
|
|
+STAY @key
|
|
|
|
inc gAttractIndex ; increment module index for next time
|
|
jsr okvs_len
|
|
!word gAttractModeStore
|
|
cmp gAttractIndex
|
|
bne +
|
|
lda #0
|
|
sta gAttractIndex
|
|
+
|
|
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
|
|
|
|
; jsr SaveGlobalPreferences ; write prefs store to disk
|
|
|
|
jsr okvs_get
|
|
!word gAttractModeStore
|
|
@key !word $FDFD
|
|
+STAY PTR
|
|
|
|
jsr @RunNextAttractModule
|
|
lda $C000
|
|
bpl AttractMode
|
|
rts
|
|
|
|
@RunNextAttractModule
|
|
ldy #1
|
|
lda (PTR),y
|
|
and #$0F
|
|
cmp #$03
|
|
bne @Slideshow
|
|
|
|
; 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
|
|
|
|
+LOAD_PATH kDemoDirectory
|
|
ldy gPathname
|
|
iny
|
|
iny
|
|
sty ProDOS_prefix
|
|
- lda gPathname-2, y
|
|
sta ProDOS_prefix, y
|
|
dey
|
|
bne -
|
|
lda #'/'
|
|
sta ProDOS_prefix+1
|
|
lda #'X'
|
|
sta ProDOS_prefix+2
|
|
|
|
+LOAD_FILE_IMM @key
|
|
|
|
jsr SaveScreenHoles ; save screen hole contents in case game changes them
|
|
ldx #(End_Prelaunch-Prelaunch-1)
|
|
- lda Prelaunch,x ; copy pre-launch code to main memory
|
|
sta $100,x
|
|
dex
|
|
bpl -
|
|
ldx #(end_promote-promote-1)
|
|
- lda promote,x ; copy tiny ProDOS to main memory
|
|
sta $bf00,x
|
|
dex
|
|
bpl -
|
|
jmp $106 ; jump to pre-launch code
|
|
|
|
@Slideshow ; HGR or DHGR slideshow
|
|
pha ; save module type (1=HGR, 2=DHGR)
|
|
|
|
+LOAD_FILE kAttractModeSlideshowDirectory, @key
|
|
|
|
jsr ParseKeyValueList ; parse slideshow configuration
|
|
!word gSlideshowStore
|
|
!word ldrlo2 ; (ldrlo2) points to load address
|
|
!byte 0
|
|
|
|
pla ; restore module type
|
|
cmp #$01
|
|
beq @HGRSlideshow
|
|
|
|
@DHGRSlideshow
|
|
bit MachineStatus ; only run DHGR slideshow if we have 128K
|
|
bvc @exit
|
|
jsr LoadDHGRTransition ; load transition effect code at $6000
|
|
jsr BlankDHGR ; switch to DHGR mode with initial blank screen
|
|
jsr okvs_iter ; cycle through all listed DHGR files
|
|
!word gSlideshowStore
|
|
!word DHGRLoad ; address of callback (called on each file)
|
|
jmp BlankHGR ; switch back to HGR mode with initial blank screen
|
|
|
|
@HGRSlideshow
|
|
jsr LoadTransition ; load transition effect code at $6000
|
|
jsr okvs_iter ; cycle through all listed HGR files
|
|
!word gSlideshowStore
|
|
!word HGRLoad ; address of callback (called on each file)
|
|
@exit rts
|
|
kAttractModeConfFile
|
|
!byte @kAttractModeConfFile_e-@kAttractModeConfFile_b
|
|
@kAttractModeConfFile_b
|
|
!text "ATTRACT.CONF"
|
|
@kAttractModeConfFile_e
|
|
|
|
;------------------------------------------------------------------------------
|
|
; internal functions
|
|
|
|
HGRLoad
|
|
; in: A/Y contains address of filename
|
|
|
|
ldx $C000
|
|
bpl +
|
|
rts
|
|
+
|
|
+STAY PTR
|
|
|
|
; load HGR screenshot at $4000
|
|
+LOAD_FILE kHGRScreenshotDirectory, PTR
|
|
|
|
; jsr LoadTransition ; uncomment this line to load a new transition on every picture
|
|
jsr $6000 ; call transition effect code to display picture
|
|
jmp WaitOnScreenshot
|
|
|
|
DHGRLoad
|
|
; in: A/Y contains address of filename
|
|
|
|
ldx $C000
|
|
bpl +
|
|
rts
|
|
+
|
|
; load DHGR screenshot at $4000/main and $4000/aux
|
|
+STAY PTR
|
|
jsr ResetPath
|
|
+LDADDR kDHGRScreenshotDirectory
|
|
jsr AddToPath
|
|
+LDADDR kPathSeparator
|
|
jsr AddToPath
|
|
+LDAY PTR
|
|
jsr AddToPath
|
|
jsr LoadDHRFile
|
|
!word gPathname
|
|
|
|
jsr $6000 ; call transition effect code to display picture
|
|
; note: execution falls through here
|
|
|
|
WaitOnScreenshot
|
|
ldx #$20
|
|
- lda #0
|
|
jsr WaitForKeyWithTimeout
|
|
bmi +
|
|
dex
|
|
bpl -
|
|
+ rts
|
|
|
|
LoadTransition
|
|
jsr LoadFile ; load HGR transition effects list into $8000
|
|
!word kFXConfFile
|
|
jsr ParseKeyValueList ; parse HGR transition effects list into $6000
|
|
!word gFXStore
|
|
!word ldrlo2 ; (ldrlo2) points to last load address
|
|
!byte 0
|
|
|
|
jsr okvs_get ; get next HGR transition effect from prefs
|
|
!word gGlobalPrefsStore
|
|
!word kNextFX
|
|
bcs @nofx
|
|
+STAY @fx
|
|
jsr okvs_get
|
|
!word gFXStore
|
|
@fx !word $FDFD ; SMC
|
|
bcc +
|
|
@nofx ldx #0
|
|
+ stx gFXIndex
|
|
|
|
jsr okvs_nth ; get filename of transition effect code
|
|
!word gFXStore
|
|
gFXIndex
|
|
!byte 0
|
|
+STAY @fxkey
|
|
|
|
inc gFXIndex ; increment transition effect index
|
|
jsr okvs_len
|
|
!word gFXStore
|
|
cmp gFXIndex
|
|
bne +
|
|
lda #0
|
|
sta gFXIndex
|
|
+
|
|
lda gFXIndex
|
|
sta @nexti
|
|
jsr okvs_nth ; get name of next HGR transition
|
|
!word gFXStore
|
|
@nexti !byte $FD ; SMC
|
|
+STAY @nextfx
|
|
|
|
jsr okvs_update ; save name of next HGR transition in prefs store
|
|
!word gGlobalPrefsStore
|
|
!word kNextFX
|
|
@nextfx !word $FDFD ; SMC
|
|
|
|
; jsr SaveGlobalPreferences ; write prefs store to disk
|
|
|
|
; load transition effect code at $6000
|
|
+LOAD_FILE kFXDirectory, @fxkey
|
|
rts
|
|
@fxkey !word $FDFD
|
|
kFXConfFile
|
|
!byte @kFXConfFile_e-@kFXConfFile_b
|
|
@kFXConfFile_b
|
|
!text "FX.CONF"
|
|
@kFXConfFile_e
|
|
|
|
LoadDHGRTransition
|
|
jsr LoadFile ; load DHGR transition effects list into $8000
|
|
!word kDFXConfFile
|
|
jsr ParseKeyValueList ; parse DHGR transition effects list into $6000
|
|
!word gDFXStore
|
|
!word ldrlo2 ; (ldrlo2) points to last load address
|
|
!byte 0
|
|
|
|
jsr okvs_get ; get next DHGR transition effect from prefs
|
|
!word gGlobalPrefsStore
|
|
!word kNextDFX
|
|
bcs @nodfx
|
|
+STAY @dfx
|
|
jsr okvs_get
|
|
!word gDFXStore
|
|
@dfx !word $FDFD ; SMC
|
|
bcc +
|
|
@nodfx ldx #0
|
|
+ stx gDFXIndex
|
|
|
|
jsr okvs_nth ; get filename of DHGR transition effect code
|
|
!word gDFXStore
|
|
gDFXIndex
|
|
!byte 0
|
|
+STAY @dfxkey
|
|
|
|
inc gDFXIndex ; increment transition effect index for next time
|
|
jsr okvs_len
|
|
!word gDFXStore
|
|
cmp gDFXIndex
|
|
bne +
|
|
lda #0
|
|
sta gDFXIndex
|
|
+
|
|
lda gDFXIndex
|
|
sta @nexti
|
|
jsr okvs_nth ; get name of next DHGR transition
|
|
!word gDFXStore
|
|
@nexti !byte $FD ; SMC
|
|
+STAY @nextdfx
|
|
|
|
jsr okvs_update ; save name of next DHGR transition in prefs store
|
|
!word gGlobalPrefsStore
|
|
!word kNextDFX
|
|
@nextdfx !word $FDFD ; SMC
|
|
|
|
; jsr SaveGlobalPreferences ; write prefs store to disk
|
|
|
|
; load transition effect code at $6000
|
|
+LOAD_FILE kFXDirectory, @dfxkey
|
|
rts
|
|
@dfxkey !word $FDFD
|
|
kDFXConfFile
|
|
!byte @kDFXConfFile_e-@kDFXConfFile_b
|
|
@kDFXConfFile_b
|
|
!text "DFX.CONF"
|
|
@kDFXConfFile_e
|
|
|
|
BlankHGR
|
|
jsr Home
|
|
jsr ClearHGR1 ; clear hi-res screen 1
|
|
lda $c057 ; show hi-res screen 1 (now blank)
|
|
lda $c054
|
|
lda $c052
|
|
lda $c050
|
|
rts
|
|
BlankDHGR
|
|
jsr Home
|
|
jsr ClearHGR1 ; clear hi-res screen 1
|
|
sta $C005
|
|
jsr ClearHGR1 ; clear hi-res screen 1 in auxmem
|
|
sta $C004
|
|
sta $c00d
|
|
sta $c057
|
|
sta $c054
|
|
sta $c052
|
|
sta $c050
|
|
sta $c05e
|
|
rts
|
|
ClearHGR1
|
|
ldx #$20 ; clear hi-res screen 1
|
|
stx @a+2
|
|
lda #0
|
|
tay
|
|
@a sta $2000,y
|
|
iny
|
|
bne @a
|
|
inc @a+2
|
|
dex
|
|
bne @a
|
|
rts
|
|
Home
|
|
ldx #(@end-@start-1)
|
|
- lda @start,x
|
|
sta $100,x
|
|
dex
|
|
bpl -
|
|
jmp $100
|
|
@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
|
|
|
|
Prelaunch ; this runs from main memory
|
|
lda $C088 ; entry point used by some self-running demos
|
|
jmp Reenter
|
|
+READ_ROM_NO_WRITE ; entry point to launch game (called above)
|
|
jsr $FE89 ; initialize machine like a cold boot
|
|
jsr $FE93 ; (many games assume a 'clean slate')
|
|
jsr $FE84
|
|
sta $C000
|
|
sta $C002
|
|
sta $C004
|
|
sta $C00C
|
|
sta $C00E
|
|
jsr $FB2F
|
|
jsr $FC58
|
|
ldx #$FF
|
|
txs
|
|
jmp (ldrlo2) ; jump to game
|
|
End_Prelaunch
|