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
PREFS.CONF.SOURCE=res/PREFS.CONF
COVER=res/COVER
DECRUNCH=res/DECRUNCH
DECRUNCH=build/DECRUNCH
FINDER.DATA=res/Finder.Data
FINDER.ROOT=res/Finder.Root
HELP=res/HELP
@ -428,6 +428,9 @@ $(MD):
touch "$(CADIUS.LOG)"
@touch "$@"
$(DECRUNCH): $(MD)
$(ACME) -o $(DECRUNCH) src/decrunch/exodecrunch.a
clean:
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/ui.wait.a"
gPreloadStatus
!byte %00000000
gMegaAttractModeFilter ; module types to include in mega-attract mode
!byte %11111111
; |||||||+- bit 0 include self-running demos

View File

@ -24,6 +24,7 @@
; DCB8..DCBD - backup of stack (during gameplay and self-running demos)
; DCBE..DCC2 - okvs cache (attract state saved across self-running demo)
; ...unused...
; DFAE..DFB3 - HideLaunchArtwork function
; DFB4..DFFF - (de)acceleration function
;
; MAIN MEMORY DURING SEARCH/BROWSE MODE
@ -138,8 +139,12 @@ WCOUNT = $0C ; word
HTAB = $24 ; byte
VTAB = $25 ; byte
RNDSEED = $4E ; word
!src "src/decrunch/constants.a"
PrelaunchInit= $EA
HideLaunchArtwork = $1BA
HideLaunchArtworkLC2 = $DFAE
; textrank
BestMatchIndex = $E5 ; word
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.
; It contains modifications made by qkumba to work with ACME assembler.
!cpu 6502
!to "DECRUNCH",plain
*=$200
;
@ -66,17 +65,7 @@ EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE = 1
; -------------------------------------------------------------------
; zero page addresses used
; -------------------------------------------------------------------
zp_len_lo = $a7
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
!src "src/decrunch/constants.a"
!IFDEF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE {
encoded_entries = 68
@ -207,6 +196,11 @@ literal_start1:
tya
bne no_hi_decr
dec zp_dest_hi
bit $c000
bpl no_hi_decr
exit_on_keypress:
!warn "exit_on_keypress=",*
nop
no_hi_decr:
dey
jsr get_crunched_byte

View File

@ -663,6 +663,65 @@ ReverseCoordinates3Bit
bcc -- ; always branches
++ 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 {
RippleCoordinates1Bit4
lda #<aslmod4
@ -761,62 +820,3 @@ aslmod cmp #$1A
sbc #$34
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
;
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
@ -65,14 +68,19 @@ DecompressInternal
lda #<(@params - 1)
pha
bvs +
jmp LoadIndexedFile ; load decompression code to $200
jmp LoadIndexedFile ; load decompression code to $200/main
+ jmp LoadAuxIndexedFile ; load decompression code to $200/aux
@params !word $200
!word kDecrunchRecord
ldx auxreq
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
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 WRITEMAINMEM
jsr SwitchToBank2
@ -80,6 +88,18 @@ DecompressInternal
sta auxreq
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
;
@ -93,8 +113,10 @@ DecompressInternal
; $0200..$03CB clobbered by decompressor
;------------------------------------------------------------------------------
DecompressDHGR
jsr DecompressHGR
sta WRITEMAINMEM
lda #$3F
bit SHRRTS
jsr DecompressInternal
sta READAUXMEM
lda #$60
sta PageFrom+2
lda #$40

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -94,12 +94,15 @@ LoadAuxIndexedSHRFile
LoadIndexedSHRFile
clv
php
jsr LoadIndexedFile ; load index file into $2000
- !word $2000
jsr GetOffscreenAddress
sta IndexedSHRAddr+1
jsr LoadIndexedFile ; load index file into offscreen HGR page
IndexedSHRAddr
!word $FD00 ; SMC high byte
!word kSHRArtworkIndexRecord
jsr okvs_find
!word -
!word IndexedSHRAddr
IndexedSHRFilename
!word $FDFD ; SMC
+ST16 @indexRecordPtr
@ -252,3 +255,44 @@ PreSHRMode
; aliased softswitch. Do not remove.
sta SHADOW
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
notLastGame
+STX16 gGameToLaunch
lda #0
sta gPreloadStatus
jmp OnBrowseChanged
OnBrowseRandom
@ -104,6 +106,8 @@ GameCount
!word 0
stx gGameToLaunch
sta gGameToLaunch+1
lda #0
sta gPreloadStatus
jmp OnBrowseChanged
ReloadIndexAndLaunch

View File

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

View File

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

View File

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

View File

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