sync latest code with 4cade [decompress launch artwork on idle, build decrunch, reset SHR mode properly]

This commit is contained in:
4am 2025-01-23 21:19:04 -05:00
parent 2f0ce1fb73
commit 24ffbf5a37
21 changed files with 225 additions and 105 deletions

View File

@ -95,7 +95,7 @@ FX.CONF=res/FX.CONF
SFX.CONF=res/SFX.CONF SFX.CONF=res/SFX.CONF
PREFS.CONF.SOURCE=res/PREFS.CONF PREFS.CONF.SOURCE=res/PREFS.CONF
COVER=res/COVER COVER=res/COVER
DECRUNCH=res/DECRUNCH DECRUNCH=build/DECRUNCH
FINDER.DATA=res/Finder.Data FINDER.DATA=res/Finder.Data
FINDER.ROOT=res/Finder.Root FINDER.ROOT=res/Finder.Root
HELP=res/HELP HELP=res/HELP
@ -428,6 +428,9 @@ $(MD):
touch "$(CADIUS.LOG)" touch "$(CADIUS.LOG)"
@touch "$@" @touch "$@"
$(DECRUNCH): $(MD)
$(ACME) -o $(DECRUNCH) src/decrunch/exodecrunch.a
clean: clean:
rm -rf "$(BUILDDIR)"/ || rm -rf "$(BUILDDIR)" rm -rf "$(BUILDDIR)"/ || rm -rf "$(BUILDDIR)"

Binary file not shown.

View File

@ -146,6 +146,9 @@ ResetVector ; 6 bytes, copied to $100
!source "src/hw.vbl.a" !source "src/hw.vbl.a"
!source "src/ui.wait.a" !source "src/ui.wait.a"
gPreloadStatus
!byte %00000000
gMegaAttractModeFilter ; module types to include in mega-attract mode gMegaAttractModeFilter ; module types to include in mega-attract mode
!byte %11111111 !byte %11111111
; |||||||+- bit 0 include self-running demos ; |||||||+- bit 0 include self-running demos

View File

@ -24,6 +24,7 @@
; DCB8..DCBD - backup of stack (during gameplay and self-running demos) ; DCB8..DCBD - backup of stack (during gameplay and self-running demos)
; DCBE..DCC2 - okvs cache (attract state saved across self-running demo) ; DCBE..DCC2 - okvs cache (attract state saved across self-running demo)
; ...unused... ; ...unused...
; DFAE..DFB3 - HideLaunchArtwork function
; DFB4..DFFF - (de)acceleration function ; DFB4..DFFF - (de)acceleration function
; ;
; MAIN MEMORY DURING SEARCH/BROWSE MODE ; MAIN MEMORY DURING SEARCH/BROWSE MODE
@ -138,8 +139,12 @@ WCOUNT = $0C ; word
HTAB = $24 ; byte HTAB = $24 ; byte
VTAB = $25 ; byte VTAB = $25 ; byte
RNDSEED = $4E ; word RNDSEED = $4E ; word
!src "src/decrunch/constants.a"
PrelaunchInit= $EA PrelaunchInit= $EA
HideLaunchArtwork = $1BA HideLaunchArtwork = $1BA
HideLaunchArtworkLC2 = $DFAE
; textrank ; textrank
BestMatchIndex = $E5 ; word BestMatchIndex = $E5 ; word
tmpx = $E7 ; byte tmpx = $E7 ; byte

15
src/decrunch/constants.a Normal file
View File

@ -0,0 +1,15 @@
!ifndef _EXO_CONSTANTS_ {
zp_len_lo = $a0
zp_len_hi = $a1
zp_src_lo = $a2
zp_src_hi = $a3
zp_bits_hi = $a4
zp_bitbuf = $a5
zp_dest_lo = $a6 ; dest addr lo
zp_dest_hi = $a7 ; dest addr hi
exo_save_x = $a8
exo_save_y = $a9
_EXO_CONSTANTS_=*
}

View File

@ -2,7 +2,6 @@
; the Exomizer homepage. ; the Exomizer homepage.
; It contains modifications made by qkumba to work with ACME assembler. ; It contains modifications made by qkumba to work with ACME assembler.
!cpu 6502 !cpu 6502
!to "DECRUNCH",plain
*=$200 *=$200
; ;
@ -66,17 +65,7 @@ EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE = 1
; ------------------------------------------------------------------- ; -------------------------------------------------------------------
; zero page addresses used ; zero page addresses used
; ------------------------------------------------------------------- ; -------------------------------------------------------------------
zp_len_lo = $a7 !src "src/decrunch/constants.a"
zp_len_hi = $a8
zp_src_lo = $ae
zp_src_hi = zp_src_lo + 1
zp_bits_hi = $fc
zp_bitbuf = $fd
zp_dest_lo = zp_bitbuf + 1 ; dest addr lo
zp_dest_hi = zp_bitbuf + 2 ; dest addr hi
!IFDEF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE { !IFDEF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE {
encoded_entries = 68 encoded_entries = 68
@ -207,6 +196,11 @@ literal_start1:
tya tya
bne no_hi_decr bne no_hi_decr
dec zp_dest_hi dec zp_dest_hi
bit $c000
bpl no_hi_decr
exit_on_keypress:
!warn "exit_on_keypress=",*
nop
no_hi_decr: no_hi_decr:
dey dey
jsr get_crunched_byte jsr get_crunched_byte

View File

@ -663,6 +663,65 @@ ReverseCoordinates3Bit
bcc -- ; always branches bcc -- ; always branches
++ rts ++ rts
RippleCoordinates3Bit
ldx #$1B
- lda @ripplezp, x
sta $e0, x
dex
bpl -
--- ldx #$0c
-- ldy $ee, x
lda $ef, x
jsr @aslmod
sty $ee, x
sta $ef, x
sty $ec
clc
adc #>Coordinates3Bit
sta $ed
ldy #0
!byte $24
- sec
lda ($ec), y
pha
lda $de, x
sta ($ec), y
pla
sta $de, x
inx
iny
bcc -
dex
dex
dex
dex
bne --
dec $ee
bne ---
dec $ef
bpl ---
bmi @exit ; always branches
@aslmod jsr +
+ cmp #$28
bcc +
iny
+ pha
tya
asl
tay
pla
rol
cmp #$50
bcc @exit
sbc #$50
@exit rts
@ripplezp
!byte $1F,$F3,$20,$F3,$20,$14,$20,$D3
!byte $1E,$F3,$1F,$54,$00,$00,$AA,$06
!byte $02,$00,$04,$00,$06,$00,$0C,$00
!byte $16,$00,$1A,$00
!zone { !zone {
RippleCoordinates1Bit4 RippleCoordinates1Bit4
lda #<aslmod4 lda #<aslmod4
@ -761,62 +820,3 @@ aslmod cmp #$1A
sbc #$34 sbc #$34
exit rts exit rts
} }
RippleCoordinates3Bit
ldx #$1B
- lda @ripplezp, x
sta $e0, x
dex
bpl -
--- ldx #$0c
-- ldy $ee, x
lda $ef, x
jsr @aslmod
sty $ee, x
sta $ef, x
sty $ec
clc
adc #>Coordinates3Bit
sta $ed
ldy #0
!byte $24
- sec
lda ($ec), y
pha
lda $de, x
sta ($ec), y
pla
sta $de, x
inx
iny
bcc -
dex
dex
dex
dex
bne --
dec $ee
bne ---
dec $ef
bpl ---
bmi @exit ; always branches
@aslmod jsr +
+ cmp #$28
bcc +
iny
+ pha
tya
asl
tay
pla
rol
cmp #$50
bcc @exit
sbc #$50
@exit rts
@ripplezp
!byte $1F,$F3,$20,$F3,$20,$14,$20,$D3
!byte $1E,$F3,$1F,$54,$00,$00,$AA,$06
!byte $02,$00,$04,$00,$06,$00,$0C,$00
!byte $16,$00,$1A,$00

View File

@ -9,7 +9,10 @@
; - DecompressSHR ; - DecompressSHR
; ;
DECRUNCH = $0314 ; decrunch entry point ; these are maintained by hand and must remain in sync with
; labels in exodecrunch.a, which is assembled separately
DECRUNCH_EXIT_ON_KEYPRESS = $025c ; set to 'RTS' to exit decrunch on keypress
DECRUNCH = $031a ; decrunch entry point
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; DecompressSHR ; DecompressSHR
@ -65,14 +68,19 @@ DecompressInternal
lda #<(@params - 1) lda #<(@params - 1)
pha pha
bvs + bvs +
jmp LoadIndexedFile ; load decompression code to $200 jmp LoadIndexedFile ; load decompression code to $200/main
+ jmp LoadAuxIndexedFile ; load decompression code to $200/aux + jmp LoadAuxIndexedFile ; load decompression code to $200/aux
@params !word $200 @params !word $200
!word kDecrunchRecord !word kDecrunchRecord
ldx auxreq ldx auxreq
sta READMAINMEM,x ; X = 0 or 1, so this will be READMAINMEM or READAUXMEM sta READMAINMEM,x ; X = 0 or 1, so this will be READMAINMEM or READAUXMEM
sta WRITEMAINMEM,x ; X = 0 or 1, so this will be WRITEMAINMEM or WRITEAUXMEM sta WRITEMAINMEM,x ; X = 0 or 1, so this will be WRITEMAINMEM or WRITEAUXMEM
jsr DECRUNCH ; loaded from separate file beq +
lda #$60
sta DECRUNCH_EXIT_ON_KEYPRESS
+ jsr DECRUNCH
- stx exo_save_x
sty exo_save_y
sta READMAINMEM sta READMAINMEM
sta WRITEMAINMEM sta WRITEMAINMEM
jsr SwitchToBank2 jsr SwitchToBank2
@ -80,6 +88,18 @@ DecompressInternal
sta auxreq sta auxreq
jmp DisableAcceleratorAndSwitchToBank1 jmp DisableAcceleratorAndSwitchToBank1
ResumeAuxDecompress
jsr SwitchToBank2
jsr EnableAccelerator
sta READAUXMEM
sta WRITEAUXMEM
lda #$EA
sta DECRUNCH_EXIT_ON_KEYPRESS
ldx exo_save_x
ldy exo_save_y
jsr DECRUNCH_EXIT_ON_KEYPRESS+1
jmp -
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; DecompressDHGR ; DecompressDHGR
; ;
@ -93,8 +113,10 @@ DecompressInternal
; $0200..$03CB clobbered by decompressor ; $0200..$03CB clobbered by decompressor
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
DecompressDHGR DecompressDHGR
jsr DecompressHGR lda #$3F
sta WRITEMAINMEM bit SHRRTS
jsr DecompressInternal
sta READAUXMEM
lda #$60 lda #$60
sta PageFrom+2 sta PageFrom+2
lda #$40 lda #$40

View File

@ -142,18 +142,20 @@ PlayGameInAY
beq @noLaunchArtwork beq @noLaunchArtwork
lda (PTR), y ; A = game info bitfield lda (PTR), y ; A = game info bitfield
and #HAS_LAUNCH_ARTWORK and #HAS_LAUNCH_ARTWORK
bne @showLaunchArtwork ; Z=0 if game has artwork to display during launch bne @loadLaunchArtwork ; Z=0 if game has artwork to display during launch
@noLaunchArtwork @noLaunchArtwork
jsr ClearScreens ; avoid seeing code load into the HGR page jsr ClearScreens ; avoid seeing code load into the HGR page
; (clobbers $106, must do now before loading prelaunch code) ; (clobbers $106, must do now before loading prelaunch code)
; don't have to do this if we're displaying launch artwork ; don't have to do this if we're displaying launch artwork
; since SHR video mode will be active instead of HGR ; since SHR video mode will be active instead of HGR
beq @postArtwork ; always branches because Z=1 coming out of ClearScreens beq @postArtwork ; always branches because Z=1 coming out of ClearScreens
@showLaunchArtwork @loadLaunchArtwork
lda gPreloadStatus
bmi @showLaunchArtwork128K
jsr Home jsr Home
lda MachineStatus lda MachineStatus
and #HAS_128K and #HAS_128K
bne @showLaunchArtwork128K bne @loadLaunchArtwork128K
jsr LoadIndexedSHRFile ; requires IndexedSHRFilename (set earlier) jsr LoadIndexedSHRFile ; requires IndexedSHRFilename (set earlier)
jsr DecompressSHR jsr DecompressSHR
jsr PreSHRMode jsr PreSHRMode
@ -161,10 +163,19 @@ PlayGameInAY
jsr SHRMode jsr SHRMode
jsr ReloadSearchIndexOnly jsr ReloadSearchIndexOnly
jmp @postArtwork jmp @postArtwork
@showLaunchArtwork128K @loadLaunchArtwork128K
jsr LoadAuxIndexedSHRFile lda gPreloadStatus
bne @resumeBackgroundDecompression
+ jsr LoadAuxIndexedSHRFile
jsr PreSHRMode jsr PreSHRMode
jsr DecompressAuxSHR jsr DecompressAuxSHR
jmp @showLaunchArtwork128K
@resumeBackgroundDecompression
jsr PreSHRMode
jsr ResumeAuxDecompress
lda #%11111111
sta gPreloadStatus
@showLaunchArtwork128K
jsr SHRMode jsr SHRMode
@postArtwork @postArtwork
jsr LoadIndexedFile ; load prelaunch index file jsr LoadIndexedFile ; load prelaunch index file

View File

@ -19,14 +19,15 @@ LaunchInternal
stx RestoreStackNextTime + 1 stx RestoreStackNextTime + 1
; tell |Reenter| to restore the stack and stack pointer ; tell |Reenter| to restore the stack and stack pointer
ldx #(PrelaunchInitInternal_e-PrelaunchInitInternal+1) ldx #(PrelaunchInitInternal_e-PrelaunchInitInternal)
- lda PrelaunchInitInternal-1, x - lda PrelaunchInitInternal-1, x
sta PrelaunchInit-1, x sta PrelaunchInit-1, x
dex dex
bne - bne -
ldx #(HideLaunchArtworkInternal_e-HideLaunchArtworkInternal+1) ldx #(HideLaunchArtworkInternal_e-HideLaunchArtworkInternal)
- lda HideLaunchArtworkInternal-1, x - lda HideLaunchArtworkInternal-1, x
sta HideLaunchArtwork-1, x sta HideLaunchArtwork-1, x
sta HideLaunchArtworkLC2-1, x
dex dex
bne - bne -
;X=0 ;X=0
@ -55,10 +56,16 @@ LaunchInternal
bit CLEARKBD bit CLEARKBD
lda MachineStatus lda MachineStatus
and #SUPPORTS_SHR and #SUPPORTS_SHR
bne + bne @turnOffSHRShadow
lda #$60 lda #$60
sta HideLaunchArtwork sta HideLaunchArtwork
+ jmp iPrelaunchInit sta HideLaunchArtworkLC2
bne @jmp ; always branches
@turnOffSHRShadow
lda #%00101000 ; matches powerup value
sta SHADOW
sta SHADOW
@jmp jmp iPrelaunchInit
PrelaunchInitInternal PrelaunchInitInternal
!pseudopc PrelaunchInit { !pseudopc PrelaunchInit {

View File

@ -1,8 +1,8 @@
; ;
; Index record for res/DECRUNCH ; Index record for build/DECRUNCH
; ;
; This file is automatically generated ; This file is automatically generated
; ;
!byte 0 !byte 0
!be24 2972422 !be24 2972422
!le16 303 !le16 309

View File

@ -4,5 +4,5 @@
; This file is automatically generated ; This file is automatically generated
; ;
!byte 0 !byte 0
!be24 2972725 !be24 2972731
!le16 2370 !le16 2370

View File

@ -387,9 +387,6 @@ okvs_iter_values
bne @loop bne @loop
@exit rts @exit rts
;------------------------------------------------------------------------------
; internal functions
okvs_next_field okvs_next_field
; out: Y = 0 ; out: Y = 0
+ST16 PTR +ST16 PTR
@ -409,6 +406,9 @@ incptr
inc PTR+1 inc PTR+1
+ rts + rts
;------------------------------------------------------------------------------
; internal functions
GetStoreAddressFromAY GetStoreAddressFromAY
+ST16 PTR +ST16 PTR
jmp derefptr jmp derefptr

View File

@ -183,6 +183,8 @@ DHGRTitleCallback
+LD16 WINDEX ; save game index in case user hits RETURN +LD16 WINDEX ; save game index in case user hits RETURN
+ST16 gGameToLaunch ; while it's visible (we'll launch it) +ST16 gGameToLaunch ; while it's visible (we'll launch it)
lda #0
sta gPreloadStatus
jsr LoadIndexedFile ; load index file into $4000 jsr LoadIndexedFile ; load index file into $4000
- !word $4000 - !word $4000

View File

@ -178,6 +178,8 @@ HGRTitleCallback
+LD16 WINDEX ; save game index in case user hits RETURN +LD16 WINDEX ; save game index in case user hits RETURN
+ST16 gGameToLaunch ; while it's visible (we'll launch it) +ST16 gGameToLaunch ; while it's visible (we'll launch it)
lda #0
sta gPreloadStatus
jsr LoadIndexedFile ; load index file into $4000 jsr LoadIndexedFile ; load index file into $4000
- !word $4000 - !word $4000

View File

@ -94,12 +94,15 @@ LoadAuxIndexedSHRFile
LoadIndexedSHRFile LoadIndexedSHRFile
clv clv
php php
jsr LoadIndexedFile ; load index file into $2000 jsr GetOffscreenAddress
- !word $2000 sta IndexedSHRAddr+1
jsr LoadIndexedFile ; load index file into offscreen HGR page
IndexedSHRAddr
!word $FD00 ; SMC high byte
!word kSHRArtworkIndexRecord !word kSHRArtworkIndexRecord
jsr okvs_find jsr okvs_find
!word - !word IndexedSHRAddr
IndexedSHRFilename IndexedSHRFilename
!word $FDFD ; SMC !word $FDFD ; SMC
+ST16 @indexRecordPtr +ST16 @indexRecordPtr
@ -252,3 +255,44 @@ PreSHRMode
; aliased softswitch. Do not remove. ; aliased softswitch. Do not remove.
sta SHADOW sta SHADOW
rts rts
LoadLaunchArtworkInBackground
lda KBD
bmi @exit ; keypress pending -> done
lda MachineStatus
and #SUPPORTS_SHR
beq @exit ; no SHR -> done
lda MachineStatus
and #HAS_128K
beq @exit ; no 128K -> done (want to do this all in auxmem)
lda gPreloadStatus
bmi @exit ; already preloaded -> done
jsr GetGameToLaunch
bcs @exit ; no game -> done (this should never happen but okay)
+ST16 IndexedSHRFilename
jsr okvs_next_field
;Y=0
jsr okvs_next_field_PTR_is_already_set
;Y=0
iny ; Y = 1
lda (PTR), y ; A = game info bitfield
and #HAS_LAUNCH_ARTWORK
beq @exit ; currently selected game has no launch artwork -> done
lda (PTR), y
and #HAS_DHGR_TITLE
bne @exit ; game has dhgr title -> done (title is using part of auxmem, load would cause visible artifacts)
jsr LoadAuxIndexedSHRFile
lda KBD
bmi @exit
lda #%00000001
sta gPreloadStatus
jsr PreSHRMode
jsr DecompressAuxSHR
lda KBD
bmi @turnOffLinearizeAndExit
lda #%11111111
sta gPreloadStatus
@turnOffLinearizeAndExit
lda #%00000001
sta NEWVIDEO
@exit rts

View File

@ -93,6 +93,8 @@ OnBrowseNext
ldy #0 ldy #0
notLastGame notLastGame
+STX16 gGameToLaunch +STX16 gGameToLaunch
lda #0
sta gPreloadStatus
jmp OnBrowseChanged jmp OnBrowseChanged
OnBrowseRandom OnBrowseRandom
@ -104,6 +106,8 @@ GameCount
!word 0 !word 0
stx gGameToLaunch stx gGameToLaunch
sta gGameToLaunch+1 sta gGameToLaunch+1
lda #0
sta gPreloadStatus
jmp OnBrowseChanged jmp OnBrowseChanged
ReloadIndexAndLaunch ReloadIndexAndLaunch

View File

@ -109,9 +109,8 @@ DHGRMode
; in: A = key ; in: A = key
; out: A &= 0x7F ; out: A &= 0x7F
; Y preserved ; Y preserved
; X clobbered ; Z = 1 and C = 0 and X = 0 if this is a search key
; Z = 1 and C = 0 if this is a search key ; Z = 0 and X = #kInputError if this is not a search key
; Z = 0 if this is not a search key
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
IsSearchKey IsSearchKey
and #$7F ; strip high bit for search characters and #$7F ; strip high bit for search characters

View File

@ -100,7 +100,7 @@ Credits
;end inline ;end inline
jsr ShowOtherPage ; show credits jsr ShowOtherPage ; show credits
jsr WaitForKeyFor30Seconds; wait jsr WaitForKeyFor30Seconds; wait
bit CLEARKBD ; don't care about key bit CLEARKBD
cmp #$81 ; Ctrl-A = about cmp #$81 ; Ctrl-A = about
beq Credits beq Credits
cmp #$90 ; Ctrl-P = launch joystick calibration program cmp #$90 ; Ctrl-P = launch joystick calibration program

View File

@ -118,9 +118,11 @@ SearchMode
stx gGameToLaunch ; $FFFF = no game selected stx gGameToLaunch ; $FFFF = no game selected
stx gGameToLaunch+1 stx gGameToLaunch+1
stx gMegaAttractModeFilter ; $FF = all module types stx gMegaAttractModeFilter ; $FF = all module types
inx
stx gPreloadStatus
stx OffscreenPage ; don't show text page 2 by accident
jsr ReloadSearchIndex jsr ReloadSearchIndex
jsr Home ; clear screen (switches to text mode) jsr Home ; clear screen (switches to text mode)
stx OffscreenPage ; don't show text page 2 by accident
jsr OnInputChanged ; draw UI offscreen jsr OnInputChanged ; draw UI offscreen
jsr HGRMode ; show HGR screen jsr HGRMode ; show HGR screen
jsr ResyncPage jsr ResyncPage
@ -198,6 +200,8 @@ OnInputChanged
dex dex
stx gGameToLaunch ; $FFFF = no game selected stx gGameToLaunch ; $FFFF = no game selected
stx gGameToLaunch+1 stx gGameToLaunch+1
inx
stx gPreloadStatus
jsr LoadTitleOffscreen jsr LoadTitleOffscreen
jmp DrawUIWithoutDots jmp DrawUIWithoutDots
@ -264,6 +268,7 @@ SoftBell
+ST16 gGameToLaunch +ST16 gGameToLaunch
jsr LoadGameTitleOffscreen jsr LoadGameTitleOffscreen
lda #0 lda #0
sta gPreloadStatus
@noload @noload
sta gDrawingOnscreen ; will minimize flicker in case we're sta gDrawingOnscreen ; will minimize flicker in case we're
jsr DrawUI ; drawing directly onscreen jsr DrawUI ; drawing directly onscreen

View File

@ -51,11 +51,15 @@ WAITRTS rts
; otherwise exits via MegaAttractMode and everything is clobbered ; otherwise exits via MegaAttractMode and everything is clobbered
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
WaitForKeyFor30Seconds WaitForKeyFor30Seconds
lda #$16 ; initialize timeout counters lda #$00 ; initialize timeout counters
sta Timeout sta Timeout
sta Timeout+1 sta Timeout+1
lda #$15
sta Timeout+2 sta Timeout+2
@loop bne WFKF30SLoop ; always branches
OnIdle
jsr LoadLaunchArtworkInBackground
WFKF30SLoop
lda KBD lda KBD
bmi WAITRTS bmi WAITRTS
@ -64,11 +68,11 @@ WaitForKeyFor30Seconds
inc RNDSEED ; seed) inc RNDSEED ; seed)
+ +
dec Timeout dec Timeout
bne @loop bne WFKF30SLoop
dec Timeout+1 dec Timeout+1
bne @loop bne WFKF30SLoop
dec Timeout+2 dec Timeout+2
bne @loop bne OnIdle
; /!\ execution falls through here to CoverFade ; /!\ execution falls through here to CoverFade
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; CoverFade ; CoverFade