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

204 lines
7.2 KiB
Plaintext
Raw Permalink Normal View History

2019-01-15 00:06:58 +00:00
;license:MIT
2021-10-12 23:37:45 +00:00
;(c) 2018-2021 by 4am & qkumba
2019-01-15 00:06:58 +00:00
;
; Super hi-res slideshows
;
; Public functions
; - AllSHRSlideshow
2019-06-26 02:44:39 +00:00
; - SHRSlideshow
; - SHRSingle
2019-01-15 00:06:58 +00:00
;
;------------------------------------------------------------------------------
; AllSHRSlideshow
; execute mega-attract mode of all super hi-res artwork (and nothing else)
;
; safe to call if machine can not display super hi-res graphics (clears carry
; and exits)
;
; in: none
; out: C=0 if machine can not display SHR
; otherwise all registers and flags clobbered
;------------------------------------------------------------------------------
AllSHRSlideshow
clc
lda MachineStatus ; only show SHR on IIgs or if we have a VidHD card
and #SUPPORTS_SHR
beq SHRRTS
lda #ATTRACT_SHR
sta gMegaAttractModeFilter
jmp MegaAttractMode
2019-10-14 02:22:47 +00:00
;------------------------------------------------------------------------------
; 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
;------------------------------------------------------------------------------
2019-06-26 02:44:39 +00:00
SHRSlideshow
lda MachineStatus ; only show SHR on IIgs or if we have a VidHD card
2019-01-15 00:06:58 +00:00
and #SUPPORTS_SHR
2021-10-08 06:28:11 +00:00
beq SHRRTS
jsr LoadSHRTransition
2019-01-15 00:06:58 +00:00
jsr okvs_iter
!word gSlideshowStore
2019-10-08 03:47:36 +00:00
!word SHRArtworkCallback
2021-10-13 22:58:26 +00:00
beq jmpblank ; always taken
2019-01-15 00:06:58 +00:00
2019-10-14 02:22:47 +00:00
;------------------------------------------------------------------------------
2021-10-19 23:39:57 +00:00
; SHRSingle
2019-10-14 02:22:47 +00:00
; 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
;------------------------------------------------------------------------------
2019-06-26 02:44:39 +00:00
SHRSingle
jsr SetPath
+LDADDR gPathname
2021-10-24 05:36:09 +00:00
+ST16 IndexedSHRFilename
lda MachineStatus ; only show SHR on IIgs or if we have a VidHD card
2019-06-27 02:51:34 +00:00
and #SUPPORTS_SHR
2019-10-08 18:57:40 +00:00
beq SHRRTS
2019-10-08 03:47:36 +00:00
jsr BlankSHR
2021-10-24 05:36:09 +00:00
jsr LoadIndexedSHRFile
2020-03-12 00:41:16 +00:00
jsr DecompressSHR
2019-10-08 03:47:36 +00:00
jsr LoadSHRTransition
2019-10-10 02:21:46 +00:00
jsr ExecuteTransitionAtA000AndWait
2021-10-13 22:58:26 +00:00
jmpblank
2019-06-27 02:51:34 +00:00
jmp BlankHGR
2019-06-26 02:44:39 +00:00
2019-01-15 00:06:58 +00:00
;------------------------------------------------------------------------------
; LoadSHRTransition [private]
; looks up name of next SHR transition effect in SFX.CONF and loads that file
; at $A000
2019-01-15 00:06:58 +00:00
;
; in: none
2019-01-15 00:06:58 +00:00
; out: all registers and flags clobbered
; $A000..$BFFF/main contains transition effect code
;------------------------------------------------------------------------------
2019-10-08 03:47:36 +00:00
LoadSHRTransition
jsr LoadIndexedFile ; load SHR transition effects list into $A000
- !word $A000
!word kSFXIndexRecord
jsr pref_get ; get SHR transition effect from prefs
!word kNextSFX
!word -
+ST16 @indexRecordPtr ; A/Y = filename (don't load file yet)
; $WINDEX = index of the transition in SFX store
+LDADDR -
jsr okvs_next ; get transition after this one
+ST16 +
jsr pref_set ; update prefs store and save to disk
!word kNextSFX
+ !word $FDFD ; SMC
jsr LoadIndexedFile
!word $A000 ; load actual transition effect code into $A000
@indexRecordPtr
!word $FDFD ; SMC
2021-10-08 06:28:11 +00:00
SHRRTS rts
2019-01-15 00:06:58 +00:00
;------------------------------------------------------------------------------
2019-10-14 02:22:47 +00:00
; SHRArtworkCallback [private]
2019-01-15 00:06:58 +00:00
; 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/)
2020-03-24 20:30:14 +00:00
; $WINDEX contains 0-based index of the current record in gSlideshowStore (word)
2019-01-15 00:06:58 +00:00
; 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
;------------------------------------------------------------------------------
2019-10-08 03:47:36 +00:00
SHRArtworkCallback
2019-09-10 02:38:17 +00:00
bit KBD
2019-10-08 18:57:40 +00:00
bmi SHRRTS
2021-10-24 05:36:09 +00:00
+ST16 IndexedSHRFilename
2021-11-03 01:49:41 +00:00
+ST16 gLastMegaAttractGame
2019-09-21 03:26:32 +00:00
jsr FindGame
2019-09-21 03:26:32 +00:00
; 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
2019-10-08 18:57:40 +00:00
bcs SHRRTS
2020-03-24 20:30:14 +00:00
2019-10-08 03:47:36 +00:00
jsr BlankSHR
2021-10-24 05:36:09 +00:00
jsr LoadIndexedSHRFile
jsr DecompressSHR
jmp ExecuteTransitionAtA000AndWait
2019-01-15 00:06:58 +00:00
2021-10-24 05:36:09 +00:00
LoadIndexedSHRFile
; in: caller has populated IndexedSHRFilename
; out: all flags & registers clobbered
2021-11-13 01:46:05 +00:00
jsr LoadIndexedFile ; load index file into $2000
2021-10-19 23:39:57 +00:00
- !word $2000
2021-11-13 01:46:05 +00:00
!word kSHRArtworkIndexRecord
2021-10-19 23:39:57 +00:00
jsr okvs_find
!word -
2021-10-24 05:36:09 +00:00
IndexedSHRFilename
!word $FDFD ; SMC
2021-10-19 23:39:57 +00:00
+ST16 @indexRecordPtr
jsr LoadIndexedFile ; load compressed SHR artwork at $1FF8/main (not aux)
2020-03-12 00:41:16 +00:00
!word $1FF8
2021-10-19 23:39:57 +00:00
@indexRecordPtr
!word $FDFD ; SMC
2021-10-24 05:36:09 +00:00
rts
2019-01-15 00:06:58 +00:00
;------------------------------------------------------------------------------
2019-10-14 02:22:47 +00:00
; BlankSHR [private]
2019-01-15 00:06:58 +00:00
; clear and show SHR mode without flickering
;
2019-06-27 14:55:07 +00:00
; 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.
2019-06-30 17:59:06 +00:00
; Thanks to John Brooks for explaining all of this to me. Twice.
; out: text page clobbered
2019-01-15 00:06:58 +00:00
; $2000..$9FFF/aux cleared
;------------------------------------------------------------------------------
2019-10-08 03:47:36 +00:00
BlankSHR
2019-01-15 00:06:58 +00:00
jsr Home
lda #%01000001 ; set GS NEWVIDEO mode to turn on linearize
2019-06-27 14:55:07 +00:00
sta NEWVIDEO
2019-01-15 00:06:58 +00:00
2019-06-27 14:55:07 +00:00
sta WRITEAUXMEM ; writes go to auxmem
2019-01-15 00:06:58 +00:00
ldx #$00 ; enable auxmem-to-bank-E1 shadowing on IIgs
stx SHADOW
; VIDHD-SPECIFIC HACK HERE!
2020-11-10 00:44:53 +00:00
; 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.
2020-11-10 00:44:53 +00:00
; 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
2019-01-15 00:06:58 +00:00
ldx #$80
2019-10-10 01:02:46 +00:00
jsr ClearMem
2019-01-15 00:06:58 +00:00
2019-06-27 14:55:07 +00:00
sta WRITEMAINMEM ; writes go to main memory
2019-01-15 00:06:58 +00:00
lda #%11000001 ; set GS NEWVIDEO mode to turn on SHR mode
2019-06-27 14:55:07 +00:00
sta NEWVIDEO
2019-01-15 00:06:58 +00:00
rts