4cade/src/ui.attract.dhgr.a
2019-09-21 22:25:34 -04:00

156 lines
5.9 KiB
Plaintext

;license:MIT
;(c) 2018-9 by 4am
;
; Double hi-res slideshows
;
; Public functions
; - DHGRTitleSlideshow
; - DHGRActionSlideshow
; - DHGRSingle
;
DHGRTitleSlideshow
bit MachineStatus ; only run DHGR slideshow if we have 128K
bvs +
rts
+ 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 .DHGRTitleCallback ; address of callback (called on each file)
jmp BlankHGR ; switch back to HGR mode with initial blank screen on exit
DHGRActionSlideshow
bit MachineStatus ; only run DHGR slideshow if we have 128K
bvs +
rts
+ 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 .DHGRActionCallback ; address of callback (called on each file)
jmp BlankHGR ; switch back to HGR mode with initial blank screen on exit
DHGRSingle
bit MachineStatus ; only show DHGR screenshots if we have 128K
bvs +
rts
+
+STAY @fname
jsr BlankDHGR ; switch to DHGR mode with initial blank screen
jsr LoadDHRFile ; load DHGR file at $4000/main and $4000/aux
!word kRootDirectory
@fname !word $FDFD ; SMC
+ jsr .LoadDHGRTransition ; load transition effect code at $6000
+LDADDR $6000
jsr ExecuteTransitionAndWait
jmp BlankHGR ; switch back to HGR mode with initial blank screen on exit
;------------------------------------------------------------------------------
; .LoadDHGRTransition [private]
; looks up name of next DHGR transition effect in DFX.CONF and loads that file
; at $6000
; in: gDFXStore has been initialized
; gGlobalPrefsStore has been initialized
; out: all registers and flags clobbered
; $6000..$BFFF/main contains transition effect code
;------------------------------------------------------------------------------
.LoadDHGRTransition
jsr LoadFile ; load DHGR transition effects list into $8000
!word kRootDirectory
!word kDFXConfFile
- !word $8000
jsr ParseKeyValueList ; parse DHGR transition effects list into $6000
!word gDFXStore
!word -
!byte 0
jsr pref_get ; get DHGR transition effect from prefs
!word kNextDFX
!word gDFXStore
+STAY @filename ; A/Y = filename (don't load file yet)
; X = index of the transition in DFX store
+LDADDR gDFXStore
jsr okvs_next ; get transition after this one
+STAY +
jsr pref_set ; update prefs store and save to disk
!word kNextDFX
+ !word $FDFD ; SMC
jsr LoadFile ; now load transition effect code into $6000
!word kFXDirectory
@filename !word $FDFD ; SMC
!word $6000
rts
;------------------------------------------------------------------------------
; .DHGRTitleCallback [private]
; callback called by okvs_iter on gSlideshowStore
; to load and display a single DHGR title screenshot
; in: A/Y contains address of filename (name only, path is always /TITLE.DHGR/)
; X contains 0-based index of the current record in gSlideshowStore
; out: all registers and flags clobbered
; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data)
; $2000..$BFFF clobbered by graphics data and transition code
; $2000..$5FFF/aux clobbered
;------------------------------------------------------------------------------
.DHGRTitleCallback
bit KBD
bpl +
@exit rts
+
+STAY @tfname
jsr GetGameDisplayName
; if game is not found (C will be set here), it means it can't be played on
; this machine due to memory or joystick requirements, so we don't display
; it in slideshows
bcs @exit
stx gGameToLaunch
; load DHGR screenshot at $4000/main and $4000/aux
jsr LoadDHRFile
!word kDHGRTitleDirectory
@tfname !word $FDFD
+LDADDR $6000
jmp ExecuteTransitionAndWait
;------------------------------------------------------------------------------
; .DHGRActionCallback [private]
; callback called by okvs_iter on gSlideshowStore
; to load and display a single DHGR action screenshot
; in: A/Y contains address of filename (name only, path is always /ACTION.DHGR/)
; X contains 0-based index of the current record in gSlideshowStore
; out: all registers and flags clobbered
; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data)
; $2000..$BFFF clobbered by graphics data and transition code
; $2000..$5FFF/aux clobbered
;------------------------------------------------------------------------------
.DHGRActionCallback
bit KBD
bpl +
@actionExit
rts
+
+STAY @afname
jsr GetGameDisplayNameInActionSlideshow
; if game name is not found (C will be set here), it means the game
; can't be played due to memory or joystick requirements, so we hide
; it from slideshows
bcs @actionExit
stx gGameToLaunch
; load DHGR screenshot at $4000/main and $4000/aux
jsr LoadDHRFile
!word kDHGRActionDirectory
@afname !word $FDFD
+LDADDR $6000
jmp ExecuteTransitionAndWait