4cade/src/ui.attract.hgr.a
2019-09-20 23:26:32 -04:00

194 lines
6.2 KiB
Plaintext

;license:MIT
;(c) 2018-9 by 4am
;
; HGR title and action slideshows
;
; Public functions
; - HGRTitleSlideshow
; - HGRActionSlideshow
; - HGRSingle
;
!zone {
HGRTitleSlideshow
jsr .LoadHGRTransition ; load transition effect code at $6000
jsr okvs_iter ; cycle through all listed HGR files
!word gSlideshowStore
!word .HGRTitleCallback ; address of callback (called on each file)
rts ; exit with last picture still visible
HGRActionSlideshow
jsr .LoadHGRTransition ; load transition effect code at $6000
jsr okvs_iter ; cycle through all listed HGR files
!word gSlideshowStore
!word .HGRActionCallback ; address of callback (called on each file)
rts ; exit with last picture still visible
HGRSingle
+STAY @fname
jsr LoadFile ; load HGR screenshot at $4000
!word kRootDirectory
@fname !word $FDFD ; SMC
!word $4000
jsr .LoadHGRTransition ; load transition effect code at $6000
+LDADDR $6000
jmp ExecuteTransitionAndWait
;------------------------------------------------------------------------------
; .HGRTitleCallback [private]
; callback called by okvs_iter on gSlideshowStore
; to load and display a single HGR title screenshot
; in: A/Y contains address of filename (name only, path is always /TITLE.HGR/)
; 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
;------------------------------------------------------------------------------
.HGRTitleCallback
bit KBD
bpl +
@exit rts
+
+STAY @tfname
; find this game in gGamesListStore
ldx #$60
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
jsr LoadFile ; load HGR screenshot at $4000
!word kHGRTitleDirectory
@tfname !word $FDFD ; SMC
!word $4000
+LDADDR $6000
jmp ExecuteTransitionAndWait
;------------------------------------------------------------------------------
; .HGRActionCallback [private]
; callback called by okvs_iter on gSlideshowStore
; to load and display a single HGR action screenshot
; in: A/Y contains address of filename (name only, path is always /ACTION.HGR/)
; X contains 0-based index of the current record in gSlideshowStore
; gGamesListStore must be initialized
; out: all registers and flags clobbered
; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data)
; $2000..$BFFF clobbered by graphics data and transition code
;------------------------------------------------------------------------------
.HGRActionCallback
bit KBD
bpl +
@actionExit
rts
+
+STAY @afname
; find this game in gGamesListStore or gSlideshowStore
ldx #$EA
jsr GetGameDisplayName
; 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
; found the game
+STAY SAVE
stx gGameToLaunch
jsr LoadFile ; load HGR screenshot at $4000
!word kHGRActionDirectory
@afname !word $FDFD ; SMC
!word $4000
; display game name in the bottom-left corner
ldx #0
stx HTAB
ldx #22
stx VTAB
ldy #0
lda (SAVE),y
tax
+LDADDR @topline
sec
jsr DrawBuffer
ldx #3
+LDADDR @toprightcorner
sec
jsr DrawBuffer
inc VTAB
ldx #0
stx HTAB
inx
+LDADDR @rightline
sec
jsr DrawBuffer
+LDAY SAVE
jsr SetPath
+LDADDR gPathname
sec
jsr DrawString
ldx #2
+LDADDR @rightline
sec
jsr DrawBuffer
+LDADDR $6000
jmp ExecuteTransitionAndWait
@topline
!byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
!byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
@toprightcorner
!byte 0,0,7
@rightline
!text " "
!byte 3
;------------------------------------------------------------------------------
; .LoadHGRTransition [private]
; looks up name of next HGR transition effect in FX.CONF and loads that file
; at $6000
; in: gGlobalPrefsStore has been initialized
; out: all registers and flags clobbered
; $6000..$BFFF contains transition effect code
;------------------------------------------------------------------------------
.LoadHGRTransition
jsr LoadFile ; load HGR transition effects list into $8000
!word kRootDirectory
!word kFXConfFile
- !word $8000
jsr ParseKeyValueList ; parse HGR transition effects list into $6000
!word gFXStore
!word -
!byte 0
jsr pref_get ; get HGR transition effect from prefs
!word kNextFX
!word gFXStore
+STAY @filename ; A/Y = filename (don't load file yet)
; X = index of the transition in FX store
+LDADDR gFXStore
jsr okvs_next ; get transition after this one
+STAY +
jsr pref_set ; update prefs store and save to disk
!word kNextFX
+ !word $FDFD ; SMC
jsr LoadFile ; now load transition effect code into $6000
!word kFXDirectory
@filename !word $FDFD ; SMC
!word $6000
rts
kFXConfFile
!byte 7
!text "FX.CONF"
}