4cade/src/ui.attract.shr.a
2019-06-27 10:55:07 -04:00

141 lines
4.1 KiB
Plaintext

;license:MIT
;(c) 2018-9 by 4am
;
; Super hi-res slideshows
;
; Public functions
; - SHRSlideshow
; - SHRSingle
;
!zone {
SHRSlideshow
lda MachineStatus ; only show SHR on IIgs or if we have a VidHD card
and #SUPPORTS_SHR
bne +
rts
+ jsr .LoadSHRTransition
jsr okvs_iter
!word gSlideshowStore
!word SHRArtworkCallback
jmp BlankHGR
SHRSingle
+STAY SAVE
lda MachineStatus ; only show SHR on IIgs or if we have a VidHD card
and #SUPPORTS_SHR
bne +
rts
+
+LDAY SAVE
jsr SetPath
jsr .BlankSHR
jsr LoadFile
jsr .LoadSHRTransition
+LDADDR $A000
jsr ExecuteTransitionAndWait
jmp BlankHGR
;------------------------------------------------------------------------------
; .LoadSHGRTransition [private]
; [TODO] for now there is only 1 SHR transition so this always load the same file
; [TODO] but eventually it should look up name of next SHR transition effect in
; [TODO] SFX.CONF or something and loads that file at $A000
;
; in: gSFXStore has been initialized
; gGlobalPrefsStore has been initialized
; out: all registers and flags clobbered
; $A000..$BFFF/main contains transition effect code
;------------------------------------------------------------------------------
.LoadSHRTransition
+LDADDR kSFXFizzleFile
+STAY @file
+LOAD_FILE kFXDirectory, @file
rts
@file !word $FDFD
kSFXFizzleFile
!byte @kSFXFizzleFile_e-*-1
!text "SHR.FIZZLE"
@kSFXFizzleFile_e
;------------------------------------------------------------------------------
; SHRArtworkCallback
; callback called by okvs_iter on gSlideshowStore
; to load and display a single SHR graphic
; in: A/Y contains address of filename (name only, path is always /SHR/)
; 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
;------------------------------------------------------------------------------
SHRArtworkCallback
+STAY PTR
lda KBD
bpl +
rts
+
stx gCurrentlyVisibleSlideshowIndex
jsr .BlankSHR
; load SHR artwork at $2000/main (not aux)
+LDADDR kSHRArtworkDirectory
jsr SetPath
+LDAY PTR
jsr AddToPath
jsr LoadFile
+LDADDR $A000
jmp ExecuteTransitionAndWait
;------------------------------------------------------------------------------
; .BlankSHR [private]
; clear and show SHR mode without flickering
;
; in: Machine is a IIgs or has a VidHD card that responds appropriately to
; IIgs-specific softswitches for graphics and memory modes.
; NOTE: THIS ROUTINE WILL CRASH ON AN APPLE //C due to writing to $C029,
; so it is imperative that the caller ensures the machine type.
; Thanks to John Brooks for explaining all of this to me.
; out: text page clobbered (but screen holes preserved)
; $2000..$9FFF/aux cleared
;------------------------------------------------------------------------------
.BlankSHR
jsr Home
lda NEWVIDEO ; set GS NEWVIDEO mode to turn on linearize
ora #$40
sta NEWVIDEO
sta WRITEAUXMEM ; writes go to auxmem
lda SHADOW ; enable auxmem-to-bank-E1 shadowing on IIgs
and #$F7
sta SHADOW
lda #$20 ; clear $2000..$9FFF in auxmem
sta @a+2
ldx #$80
lda #0
tay
@a sta $2000,y
iny
bne @a
inc @a+2
dex
bne @a
sta WRITEMAINMEM ; writes go to main memory
lda NEWVIDEO ; set GS NEWVIDEO mode to turn on SHR mode
ora #$81
sta NEWVIDEO
rts
}