4cade/src/ui.attract.shr.a

165 lines
5.8 KiB
Plaintext

;license:MIT
;(c) 2018-2021 by 4am & qkumba
;
; Super hi-res slideshows
;
; Public functions
; - SHRSlideshow
; - SHRSingle
;
;------------------------------------------------------------------------------
; SHRSlideshow
; execute a slideshow of super hi-res artwork
;
; safe to call if machine can not display super hi-res graphics (does nothing
; and exits)
;
; in: none
; out: everything clobbered
; graphics mode reset to display hi-res screen, which is blank
;------------------------------------------------------------------------------
SHRSlideshow
lda MachineStatus ; only show SHR on IIgs or if we have a VidHD card
and #SUPPORTS_SHR
beq SHRRTS
jsr LoadSHRTransition
jsr okvs_iter
!word gSlideshowStore
!word SHRArtworkCallback
beq jmpblank ; always taken
;------------------------------------------------------------------------------
; SHRSingle
; display a single super hi-res artwork
;
; safe to call if machine can not display super hi-res graphics (does nothing
; and exits)
;
; in: none
; out: everything clobbered
; graphics mode reset to display hi-res screen, which is blank
;------------------------------------------------------------------------------
SHRSingle
+ST16 IndexedSHRFilename
lda MachineStatus ; only show SHR on IIgs or if we have a VidHD card
and #SUPPORTS_SHR
beq SHRRTS
jsr BlankSHR
jsr LoadIndexedSHRFile
jsr DecompressSHR
jsr LoadSHRTransition
jsr ExecuteTransitionAtA000AndWait
jmpblank
jmp BlankHGR
;------------------------------------------------------------------------------
; LoadSHGRTransition [private]
; load the SHR transition effect code (currently always the same file)
;
; in: none
; out: all registers and flags clobbered
; $A000..$BFFF/main contains transition effect code
;------------------------------------------------------------------------------
LoadSHRTransition
jsr LoadFile
!word kFXDirectory
!word kSFXFizzleFile
!word $A000
SHRRTS rts
;------------------------------------------------------------------------------
; SHRArtworkCallback [private]
; 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 /ARTWORK.SHR/)
; $WINDEX contains 0-based index of the current record in gSlideshowStore (word)
; 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
bit KBD
bmi SHRRTS
+ST16 IndexedSHRFilename
+ST16 gLastMegaAttractGame
jsr FindGame
; 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 SHRRTS
jsr BlankSHR
jsr LoadIndexedSHRFile
jsr DecompressSHR
jmp ExecuteTransitionAtA000AndWait
LoadIndexedSHRFile
; in: caller has populated IndexedSHRFilename
; out: all flags & registers clobbered
jsr LoadIndexedFile ; load index file into $2000
!word kTotalIndexFile
- !word $2000
!word kSHRArtworkIndexRecord
jsr okvs_find
!word -
IndexedSHRFilename
!word $FDFD ; SMC
+ST16 @indexRecordPtr
jsr LoadIndexedFile ; load compressed SHR artwork at $1FF8/main (not aux)
!word kTotalDataFile
!word $1FF8
@indexRecordPtr
!word $FDFD ; SMC
rts
;------------------------------------------------------------------------------
; 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. Twice.
; out: text page clobbered (but screen holes preserved)
; $2000..$9FFF/aux cleared
;------------------------------------------------------------------------------
BlankSHR
jsr Home
lda #%01000001 ; set GS NEWVIDEO mode to turn on linearize
sta NEWVIDEO
sta WRITEAUXMEM ; writes go to auxmem
ldx #$00 ; enable auxmem-to-bank-E1 shadowing on IIgs
stx SHADOW
; VIDHD-SPECIFIC HACK HERE!
; On the II/II+/IIe, all $C03x addresses are aliases for $C030, i.e. the speaker.
; Any single access of the speaker register requires a second access within a short
; time to balance the level if we want to avoid an audible click, which we do here.
; Since we can't read from SHADOW before writing to it (it returns random values on
; 8-bit machines, which VidHD interprets as invalid graphic modes and crashes hard),
; we instead balance the speaker access with a second write to the same speaker-
; aliased softswitch. Do not remove.
stx SHADOW
lsr ; clear $2000..$9FFF in auxmem
ldx #$80
jsr ClearMem
sta WRITEMAINMEM ; writes go to main memory
lda #%11000001 ; set GS NEWVIDEO mode to turn on SHR mode
sta NEWVIDEO
rts