From 965d7bed5f0672c86f80dbe69fad60db8975a080 Mon Sep 17 00:00:00 2001 From: 4am Date: Wed, 29 May 2024 14:41:36 -0400 Subject: [PATCH] factor out more FX routines --- src/4cade.a | 1 + src/constants.a | 97 ++++++++--------- src/fx.lib.a | 146 ++++++++++++++++++++++++++ src/fx/fx.hgr.dither.apple.a | 2 +- src/fx/fx.hgr.dither.bolt.a | 2 +- src/fx/fx.hgr.dither.flower.a | 2 +- src/fx/fx.hgr.dither.flower.radial.a | 2 +- src/fx/fx.hgr.dither.mandelbrot.a | 2 +- src/fx/fx.hgr.precomputed.3bit.a | 149 --------------------------- src/index/artwork.idx.a | 2 +- src/index/attract.idx.a | 2 +- src/index/cache00.idx.a | 2 +- src/index/cache01.idx.a | 2 +- src/index/cache10.idx.a | 2 +- src/index/cache11.idx.a | 2 +- src/index/coverfade.idx.a | 2 +- src/index/credits.idx.a | 2 +- src/index/decrunch.idx.a | 2 +- src/index/demo.idx.a | 2 +- src/index/dfx.idx.a | 2 +- src/index/dgr.fizzle.idx.a | 2 +- src/index/dgr.idx.a | 2 +- src/index/dhgr.idx.a | 2 +- src/index/dtitle.idx.a | 2 +- src/index/fx.idx.a | 2 +- src/index/fxdata.idx.a | 2 +- src/index/gamehelp.idx.a | 2 +- src/index/gr.fizzle.idx.a | 2 +- src/index/gr.idx.a | 2 +- src/index/helptext.idx.a | 2 +- src/index/hgr0.idx.a | 2 +- src/index/hgr1.idx.a | 2 +- src/index/hgr2.idx.a | 2 +- src/index/hgr3.idx.a | 2 +- src/index/hgr4.idx.a | 2 +- src/index/hgr5.idx.a | 2 +- src/index/hgr6.idx.a | 2 +- src/index/joystick.idx.a | 2 +- src/index/miniattract0.idx.a | 2 +- src/index/miniattract1.idx.a | 2 +- src/index/prelaunch.idx.a | 2 +- src/index/search00.idx.a | 2 +- src/index/search01.idx.a | 2 +- src/index/search10.idx.a | 2 +- src/index/search11.idx.a | 2 +- src/index/sfx.idx.a | 2 +- src/index/slideshow.idx.a | 2 +- src/index/title.idx.a | 2 +- src/index/xsingle.idx.a | 2 +- 49 files changed, 241 insertions(+), 242 deletions(-) diff --git a/src/4cade.a b/src/4cade.a index cae42b482..0e277a908 100644 --- a/src/4cade.a +++ b/src/4cade.a @@ -159,6 +159,7 @@ gGlobalPrefsStore ; be set to $55 as part of the 64K memory test, ; which is apparently one of the acceptable values) + +DEFINE_INDIRECT_VECTOR iHGRDitherPrecomputed3Bit, HGRDitherPrecomputed3Bit +DEFINE_INDIRECT_VECTOR iHGRPrecomputed3Bit, HGRPrecomputed3Bit +DEFINE_INDIRECT_VECTOR iRippleCoordinates3Bit, RippleCoordinates3Bit +DEFINE_INDIRECT_VECTOR iReverseCoordinates3Bit, ReverseCoordinates3Bit diff --git a/src/constants.a b/src/constants.a index 93a6cbd9b..3ad404954 100644 --- a/src/constants.a +++ b/src/constants.a @@ -116,7 +116,7 @@ ROM_NORMAL = $FE84 ; NORMAL text (instead of INVERSE or FLASH) ROM_IN0 = $FE89 ; SETKBD ROM_PR0 = $FE93 ; SETVID -; zero page during init ONLY +; zero page addresses during init ONLY zpMachineStatus= $F0 ; bit 7 = 1 if machine has joystick ; bit 6 = 1 if machine has 128K ; bit 5 = 1 if machine has a VidHD card @@ -124,7 +124,7 @@ zpMachineStatus= $F0 ; bit 7 = 1 if machine has joystick ; only used during init, then copied to MachineStatus in LC RAM zpCharMask = $F1 ; only used during init, then clobbered -; zero page +; zero page addresses PARAM = $00 ; word (used by PARAMS_ON_STACK macro, so basically everywhere) PTR = $02 ; word SRC = $04 ; word @@ -135,6 +135,7 @@ WCOUNT = $0C ; word HTAB = $24 ; byte VTAB = $25 ; byte RNDSEED = $4E ; word +PrelaunchInit= $EB ; textrank BestMatchIndex = $E5 ; word tmpx = $E7 ; byte @@ -153,9 +154,7 @@ firstletter= $FA ; byte MatchCount = $FB ; byte BestMatchScore = $FC ; byte -; main memory -gStackSize = 6 ; seems like only six are needed -gPathname = $BFD0 ; used by SetPath/AddToPath +; main memory addresses gKeyLen = $1F00 ; used by ParseKeyValueList gKey = $1F01 ; "" gValLen = $1F80 ; "" @@ -164,12 +163,48 @@ UILine1 = $1FB0 ; used by DrawUI UILine2 = $1FD8 ; "" UI_ToPlay = $1FF7 ; "" ProBootEntry = $2025 ; used by ProBoot - - gSearchIndex = $6000 gSearchCache = $A000 +gPathname = $BFD0 ; used by SetPath/AddToPath -; LC RAM 1 & 2 +; main memory addresses used by graphic effects +hgrlo = $0201 ; $C0 bytes +mirror_cols = $02C1 ; $28 bytes +hgrhi = $0301 ; $C0 bytes +hgr1hi = hgrhi + +Coordinates1Bit= $8600 ; $3481 bytes ($3480 on disk + 1 byte EOF marker added at runtime) +EndCoordinates1Bit = Coordinates1Bit + $3480 + +Coordinates2Bit= $8100 ; $3C01 bytes ($3C00 on disk + 1 byte EOF marker added at runtime) +EndCoordinates2Bit = Coordinates2Bit + $3C00 + +Coordinates3Bit= $6D00 ; $5001 bytes ($5000 on disk + 1 byte EOF marker added at runtime) +EndCoordinates3Bit = Coordinates3Bit + $5000 + +hgrlomirror = $BB01 ; $C0 bytes +hgr1himirror = $BC01 ; $C0 bytes +dithermasks = $BDA8 ; $58 bytes, must not cross page boundary +evenrow_masks = dithermasks +oddrow_masks = dithermasks+2 +no_masks = dithermasks+44 +copymasks1bit = $BE00 ; $100 bytes but sparse, index is 0..6 but in high 3 bits, so $00,$20,$40,$60,$80,$A0,$C0 +copymasks2bit = copymasks1bit ; $100 bytes but sparse, index is 0..4 but in high 3 bits, so $00,$20,$40,$60,$80 +copymasks3bit = copymasks1bit ; $100 bytes but sparse, index is 0..7 but in high 3 bits, so $00,$20,$40,$60,$80,$A0,$C0,$E0 +mirror_copymasks1bit = copymasks1bit+1 +mirror_copymasks2bit = copymasks2bit+1 +hgrlo3a = $6A00 ; $80 bytes +hgrlo3b = $6A80 ; $80 bytes +hgrlo3c = $6B00 ; $80 bytes +hgrhi3a = $6B80 ; $80 bytes +dither1_lo = $6880 ; $80 bytes +dither2_lo = $6900 ; $80 bytes +dither3_lo = $6980 ; $80 bytes +hgrhi3b = $6C00 ; $80 bytes +hgrhi3c = $BD01 ; $80 bytes +extra_cols = $BEF8 ; $08 bytes + +; LC RAM 1 & 2 addresses ; these are defined here because they are also called by other targets ; that are assembled separately, e.g. prelaunchers, demo launchers, and graphic effects UnwaitForVBL = $FFEE @@ -208,6 +243,7 @@ iSetupPrecomputed3Bit = iDHGRDitherPrecomputed2Bit-3 iReverseCoordinates3Bit = iSetupPrecomputed3Bit-3 iRippleCoordinates3Bit = iReverseCoordinates3Bit-3 iHGRPrecomputed3Bit = iRippleCoordinates3Bit-3 +iHGRDitherPrecomputed3Bit = iHGRPrecomputed3Bit-3 MockingboardStuff = $FFF8 ; bit 7 = 1 if SC-01 speech chip present (Speech I) ; bit 6 = 1 if SSI-263 speech chip present (Mockingboard "B"-"D") @@ -217,10 +253,14 @@ MockingboardStuff = $FFF8 ; bit 7 = 1 if SC-01 speech chip present (Speech I) ; bits 0-3: slot number MachineStatus = $FFF9 -; LC RAM 2 +; LC RAM 2 addresses DisableAccelerator = $DFB4 EnableAccelerator = DisableAccelerator+3 +; application constants +gStackSize = 6 ; seems like only six are needed +PRELAUNCH_STANDARD_SIZE = 61 ; LoadStandardPrelaunch, eventually to be determined at build-time + ; AND masks for MockingboardStuff MOCKINGBOARD_SLOT = %00001111 HAS_STEREO = %00100000 @@ -251,8 +291,6 @@ ATTRACT_SHR = %00100000 ATTRACT_GR = %01000000 ATTRACT_DGR = %10000000 -PRELAUNCH_STANDARD_SIZE = 61 ; LoadStandardPrelaunch, eventually to be determined at build-time - ; shared symbols for prelaunch and effects to call ProRWTS2 functions iCurBlockLo = $D601 ; constant iCurBlockHi = $D603 ; constant @@ -268,42 +306,5 @@ ldrhi2 = $65 ; constant ; Columns and Dangerous Dave also call (de)accelerator functions directly -PrelaunchInit = $EB - -; addresses used by graphic effects -hgrlo = $0201 ; $C0 bytes -mirror_cols = $02C1 ; $28 bytes -hgrhi = $0301 ; $C0 bytes -hgr1hi = hgrhi - -Coordinates1Bit= $8600 ; $3481 bytes ($3480 on disk + 1 byte EOF marker added at runtime) -EndCoordinates1Bit = Coordinates1Bit + $3480 - -Coordinates2Bit= $8100 ; $3C01 bytes ($3C00 on disk + 1 byte EOF marker added at runtime) -EndCoordinates2Bit = Coordinates2Bit + $3C00 - -Coordinates3Bit= $6D00 ; $5001 bytes ($5000 on disk + 1 byte EOF marker added at runtime) -EndCoordinates3Bit = Coordinates3Bit + $5000 - -hgrlomirror = $BB01 ; $C0 bytes -hgr1himirror = $BC01 ; $C0 bytes -dithermasks = $BDA8 ; $58 bytes, must not cross page boundary -evenrow_masks = dithermasks -oddrow_masks = dithermasks+2 -no_masks = dithermasks+44 -copymasks1bit = $BE00 ; $100 bytes but sparse, index is 0..6 but in high 3 bits, so $00,$20,$40,$60,$80,$A0,$C0 -copymasks2bit = copymasks1bit ; $100 bytes but sparse, index is 0..4 but in high 3 bits, so $00,$20,$40,$60,$80 -copymasks3bit = copymasks1bit ; $100 bytes but sparse, index is 0..7 but in high 3 bits, so $00,$20,$40,$60,$80,$A0,$C0,$E0 -mirror_copymasks1bit = copymasks1bit+1 -mirror_copymasks2bit = copymasks2bit+1 -hgrlo3a = $6A00 ; $80 bytes -hgrlo3b = $6A80 ; $80 bytes -hgrlo3c = $6B00 ; $80 bytes -hgrhi3a = $6B80 ; $80 bytes -hgrhi3b = $6C00 ; $80 bytes -hgrhi3c = $BD01 ; $80 bytes -extra_cols = $BEF8 ; $08 bytes - - _CONSTANTS_=* } diff --git a/src/fx.lib.a b/src/fx.lib.a index 8cb5c918f..0e468c069 100644 --- a/src/fx.lib.a +++ b/src/fx.lib.a @@ -42,6 +42,7 @@ ; - ReverseCoordinates3Bit ; - RippleCoordinates3Bit ; - HGRPrecomputed3Bit +; - HGRDitherPrecomputed3Bit !source "src/fx/macros.hgr.a" !source "src/fx/macros.dhgr.a" @@ -1739,3 +1740,148 @@ HGRPrecomputed3Bit } .end } + +!zone { +HGRDitherPrecomputed3Bit + jsr BuildHGRDitherMasks + jsr SetupPrecomputed3Bit + + ; phase 1 - in reverse, with additional masking + +COPY_TO_0 .start, .end + + ; set up starting coordinate for reading coordinates in reverse order + +LDADDR EndCoordinates3Bit-2 + sta <.input + sty <.input+1 + + ; set up EOF marker to stop reading coordinates in reverse order + lda #$80 + sta Coordinates3Bit-2 + + ; set up logic to advance to next coordinates in reverse order + ldx #(.next2_end-.next2_start-1) +- lda .next2_start, x + sta <.next, x + dex + bpl - + + ; set up pointers to dither mask pointers so even rows do even-row dithering and odd rows do odd-row dithering + ldx #$7F +- lda #