diff --git a/Makefile b/Makefile index debd070..168e106 100644 --- a/Makefile +++ b/Makefile @@ -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)" diff --git a/res/DECRUNCH b/res/DECRUNCH deleted file mode 100644 index 30a6859..0000000 Binary files a/res/DECRUNCH and /dev/null differ diff --git a/src/4cade.a b/src/4cade.a index 0a02264..2c545fc 100644 --- a/src/4cade.a +++ b/src/4cade.a @@ -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 diff --git a/src/constants.a b/src/constants.a index 6de4051..f4a8137 100644 --- a/src/constants.a +++ b/src/constants.a @@ -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 diff --git a/src/decrunch/constants.a b/src/decrunch/constants.a new file mode 100644 index 0000000..91711a7 --- /dev/null +++ b/src/decrunch/constants.a @@ -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_=* +} diff --git a/src/decrunch/exodecrunch.a b/src/decrunch/exodecrunch.a index 346f0a4..afe8a73 100644 --- a/src/decrunch/exodecrunch.a +++ b/src/decrunch/exodecrunch.a @@ -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 diff --git a/src/fx.lib.a b/src/fx.lib.a index 41f51a4..5e3ec56 100644 --- a/src/fx.lib.a +++ b/src/fx.lib.a @@ -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 #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 diff --git a/src/glue.decompress.a b/src/glue.decompress.a index 6d59e04..355eaf5 100644 --- a/src/glue.decompress.a +++ b/src/glue.decompress.a @@ -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 diff --git a/src/glue.launch.a b/src/glue.launch.a index feeb260..fefde91 100644 --- a/src/glue.launch.a +++ b/src/glue.launch.a @@ -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 diff --git a/src/glue.launch.lc2.a b/src/glue.launch.lc2.a index be89dd3..f2f8af4 100644 --- a/src/glue.launch.lc2.a +++ b/src/glue.launch.lc2.a @@ -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 { diff --git a/src/index/decrunch.idx.a b/src/index/decrunch.idx.a index 94325ff..768fc52 100644 --- a/src/index/decrunch.idx.a +++ b/src/index/decrunch.idx.a @@ -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 diff --git a/src/index/joystick.idx.a b/src/index/joystick.idx.a index cefc2e4..b9b69f6 100644 --- a/src/index/joystick.idx.a +++ b/src/index/joystick.idx.a @@ -4,5 +4,5 @@ ; This file is automatically generated ; !byte 0 - !be24 2972725 + !be24 2972731 !le16 2370 diff --git a/src/okvs.a b/src/okvs.a index fa446aa..8b9aac0 100644 --- a/src/okvs.a +++ b/src/okvs.a @@ -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 diff --git a/src/ui.attract.dhgr.a b/src/ui.attract.dhgr.a index 3e034a1..f778bc7 100644 --- a/src/ui.attract.dhgr.a +++ b/src/ui.attract.dhgr.a @@ -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 diff --git a/src/ui.attract.hgr.a b/src/ui.attract.hgr.a index 44fc529..ea88353 100644 --- a/src/ui.attract.hgr.a +++ b/src/ui.attract.hgr.a @@ -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 diff --git a/src/ui.attract.shr.a b/src/ui.attract.shr.a index aaa3c32..92d5f5c 100644 --- a/src/ui.attract.shr.a +++ b/src/ui.attract.shr.a @@ -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 diff --git a/src/ui.browse.mode.a b/src/ui.browse.mode.a index 4f6e815..af9fd77 100644 --- a/src/ui.browse.mode.a +++ b/src/ui.browse.mode.a @@ -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 diff --git a/src/ui.common.a b/src/ui.common.a index 58f8d3e..8653567 100755 --- a/src/ui.common.a +++ b/src/ui.common.a @@ -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 diff --git a/src/ui.credits.a b/src/ui.credits.a index 7d84ce1..8cb5a54 100644 --- a/src/ui.credits.a +++ b/src/ui.credits.a @@ -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 diff --git a/src/ui.search.mode.a b/src/ui.search.mode.a index 4a0dbe5..fac7fd8 100644 --- a/src/ui.search.mode.a +++ b/src/ui.search.mode.a @@ -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 diff --git a/src/ui.wait.a b/src/ui.wait.a index 2d00328..4c59a35 100644 --- a/src/ui.wait.a +++ b/src/ui.wait.a @@ -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