factor out more FX routines

This commit is contained in:
4am 2024-05-27 21:39:51 -04:00
parent 99dcc896d1
commit c7a2c1a921
53 changed files with 174 additions and 174 deletions

View File

@ -159,6 +159,7 @@ gGlobalPrefsStore
+DEFINE_INDIRECT_VECTOR iSetupPrecomputed3Bit, SetupPrecomputed3Bit
+DEFINE_INDIRECT_VECTOR iRippleCoordinates2Bit, RippleCoordinates2Bit
+DEFINE_INDIRECT_VECTOR iReverseCoordinates2Bit, ReverseCoordinates2Bit
+DEFINE_INDIRECT_VECTOR iBuildDHGRSparseBitmasks2Bit, BuildDHGRSparseBitmasks2Bit
+DEFINE_INDIRECT_VECTOR iBuildHGRSparseBitmasks2Bit, BuildHGRSparseBitmasks2Bit
+DEFINE_INDIRECT_VECTOR iBuildDHGRSparseBitmasks1Bit, BuildDHGRSparseBitmasks1Bit
+DEFINE_INDIRECT_VECTOR iBuildHGRSparseBitmasks1Bit, BuildHGRSparseBitmasks1Bit
@ -168,7 +169,9 @@ gGlobalPrefsStore
+DEFINE_INDIRECT_VECTOR iRippleCoordinates1Bit, RippleCoordinates1Bit
+DEFINE_INDIRECT_VECTOR iReverseCoordinates1Bit, ReverseCoordinates1Bit
+DEFINE_INDIRECT_VECTOR iWaitForKeyWithTimeout, WaitForKeyWithTimeout
+DEFINE_INDIRECT_VECTOR iBuildDHGRDitherMasks, BuildDHGRDitherMasks
+DEFINE_INDIRECT_VECTOR iBuildHGRDitherMasks, BuildHGRDitherMasks
+DEFINE_INDIRECT_VECTOR iBuildDHGRMirrorCols, BuildDHGRMirrorCols
+DEFINE_INDIRECT_VECTOR iBuildHGRMirrorCols, BuildHGRMirrorCols
+DEFINE_INDIRECT_VECTOR iBuildHGRMirrorTables, BuildHGRMirrorTables
+DEFINE_INDIRECT_VECTOR iBuildHGRTables, BuildHGRTables

View File

@ -181,8 +181,10 @@ iLoadFXDATA = iLoadXSingle-3
iBuildHGRTables = iLoadFXDATA-3
iBuildHGRMirrorTables = iBuildHGRTables-3
iBuildHGRMirrorCols = iBuildHGRMirrorTables-3
iBuildHGRDitherMasks = iBuildHGRMirrorCols-3
iWaitForKeyWithTimeout = iBuildHGRDitherMasks-3
iBuildDHGRMirrorCols = iBuildHGRMirrorCols-3
iBuildHGRDitherMasks = iBuildDHGRMirrorCols-3
iBuildDHGRDitherMasks = iBuildHGRDitherMasks-3
iWaitForKeyWithTimeout = iBuildDHGRDitherMasks-3
iReverseCoordinates1Bit = iWaitForKeyWithTimeout-3
iRippleCoordinates1Bit = iReverseCoordinates1Bit-3
iRippleCoordinates1Bit2 = iRippleCoordinates1Bit-3
@ -191,7 +193,8 @@ iRippleCoordinates1Bit4 = iRippleCoordinates1Bit3-3
iBuildHGRSparseBitmasks1Bit = iRippleCoordinates1Bit4-3
iBuildDHGRSparseBitmasks1Bit = iBuildHGRSparseBitmasks1Bit-3
iBuildHGRSparseBitmasks2Bit = iBuildDHGRSparseBitmasks1Bit-3
iReverseCoordinates2Bit = iBuildHGRSparseBitmasks2Bit-3
iBuildDHGRSparseBitmasks2Bit = iBuildHGRSparseBitmasks2Bit-3
iReverseCoordinates2Bit = iBuildDHGRSparseBitmasks2Bit-3
iRippleCoordinates2Bit = iReverseCoordinates2Bit-3
iSetupPrecomputed3Bit = iRippleCoordinates2Bit-3
iReverseCoordinates3Bit = iSetupPrecomputed3Bit-3

View File

@ -13,7 +13,9 @@
; - BuildHGRTables
; - BuildHGRMirrorTables
; - BuildHGRMirrorCols
; - BuildDHGRMirrorCols
; - BuildHGRDitherMasks
; - BuildDHGRDitherMasks
; - BuildHGRSparseBitmasks1Bit
; - BuildDHGRSparseBitmasks1Bit
@ -24,6 +26,7 @@
; - RippleCoordinates1Bit4
; - BuildHGRSparseBitmasks2Bit
; - BuildDHGRSparseBitmasks2Bit
; - ReverseCoordinates2Bit
; - RippleCoordinates2Bit
@ -116,6 +119,23 @@ BuildHGRMirrorCols
bpl -
rts
BuildDHGRMirrorCols
; out: mirror_cols populated with lookup table to get $27-y for y in $00..$27
; duplicated in both mainmem and auxmem
; X=0
; Z=1
ldx #$28
ldy #$00
- tya
sta mirror_cols-1, x
sta $C005
sta mirror_cols-1, x
sta $C004
iny
dex
bne -
rts
BuildHGRDitherMasks
ldy #40
- lda #%10110011
@ -138,6 +158,49 @@ BuildHGRDitherMasks
bpl -
rts
BuildDHGRDitherMasks
ldy #40
- lda #%10011110
sta dithermasks, y
lda #%11111000
sta dithermasks+1, y
lda #%11100001
sta dithermasks+2, y
lda #%10000111
sta dithermasks+3, y
dey
dey
dey
dey
bpl -
ldy #43
- lda #$FF
sta no_masks, y
dey
bpl -
sta $C005
ldy #40
- lda #%10001111
sta dithermasks, y
lda #%10111100
sta dithermasks+1, y
lda #%11110000
sta dithermasks+2, y
lda #%11000011
sta dithermasks+3, y
dey
dey
dey
dey
bpl -
ldy #43
- lda #$FF
sta no_masks, y
dey
bpl -
sta $C004
rts
BuildHGRSparseBitmasks1Bit
lda #%10000001
sta copymasks1bit
@ -386,6 +449,53 @@ BuildHGRSparseBitmasks2Bit
sta mirror_copymasks2bit
rts
BuildDHGRSparseBitmasks2Bit
ldx #$00
txa
- sta copymasks2bit, x
sta $C005
sta copymasks2bit, x
sta $C004
inx
bne -
lda #%10011111
sta copymasks2bit+$40
sta mirror_copymasks2bit+$A0
lda #%11100000
sta copymasks2bit+$60
sta mirror_copymasks2bit+$80
lda #%10000111
sta copymasks2bit+$C0
sta mirror_copymasks2bit+$20
lda #%11111000
sta copymasks2bit+$E0
sta mirror_copymasks2bit
sta $C005
lda #%10001111
sta copymasks2bit
sta mirror_copymasks2bit+$E0
lda #%11110000
sta copymasks2bit+$20
sta mirror_copymasks2bit+$C0
lda #%10000011
sta copymasks2bit+$80
sta mirror_copymasks2bit+$60
lda #%11111100
sta copymasks2bit+$A0
sta mirror_copymasks2bit+$40
sta $C004
rts
ReverseCoordinates2Bit
ldy #0 ; <Coordinates2Bit
sty $f0

View File

@ -24,11 +24,11 @@ input = $FE ; word
sta Coordinates1Bit-2
Start
+BUILD_DITHER_MASKS_DHGR dithermasks
jsr iBuildDHGRDitherMasks
jsr iBuildDHGRSparseBitmasks1Bit
jsr iBuildHGRTables
jsr iBuildHGRMirrorTables
+BUILD_MIRROR_COLS_DHGR mirror_cols
jsr iBuildDHGRMirrorCols
+COPY_TO_AUXMEM $60, 4
+LDADDR evenrow_masks

View File

@ -15,11 +15,11 @@ dest2 = $F6 ; word
reverse_input = $FC ; word
input = $FE ; word
+BUILD_DITHER_MASKS_DHGR dithermasks
jsr iBuildDHGRDitherMasks
jsr iBuildDHGRSparseBitmasks1Bit
jsr iBuildHGRTables
jsr iBuildHGRMirrorTables
+BUILD_MIRROR_COLS_DHGR mirror_cols
jsr iBuildDHGRMirrorCols
+COPY_TO_AUXMEM $60, 4
+LDADDR evenrow_masks

View File

@ -8,7 +8,7 @@
jsr iBuildDHGRSparseBitmasks1Bit
jsr iBuildHGRTables
jsr iBuildHGRMirrorTables
+BUILD_MIRROR_COLS_DHGR mirror_cols
jsr iBuildDHGRMirrorCols
+COPY_TO_0 start, end
jmp InputLoop
start
@ -96,11 +96,11 @@ end
}
!macro FX_PRECOMPUTED_1BIT_DHGR_DITHER .coords, .endcoords {
+BUILD_DITHER_MASKS_DHGR dithermasks
jsr iBuildDHGRDitherMasks
jsr iBuildDHGRSparseBitmasks1Bit
jsr iBuildHGRTables
jsr iBuildHGRMirrorTables
+BUILD_MIRROR_COLS_DHGR mirror_cols
jsr iBuildDHGRMirrorCols
; phase 1 - in reverse, with additional masking
+COPY_TO_0 start, end

View File

@ -3,58 +3,10 @@
;
!source "src/fx/fx.hgr.precomputed.2bit.a"
!macro BUILD_SPARSE_BITMASKS_2BIT_DHGR .copymasks2bit, .mirror_copymasks2bit {
; build sparse lookup tables for bitmasks
ldx #$00
txa
- sta .copymasks2bit, x
sta $C005
sta .copymasks2bit, x
sta $C004
inx
bne -
lda #%10011111
sta .copymasks2bit+$40
sta .mirror_copymasks2bit+$A0
lda #%11100000
sta .copymasks2bit+$60
sta .mirror_copymasks2bit+$80
lda #%10000111
sta .copymasks2bit+$C0
sta .mirror_copymasks2bit+$20
lda #%11111000
sta .copymasks2bit+$E0
sta .mirror_copymasks2bit
sta $C005
lda #%10001111
sta .copymasks2bit
sta .mirror_copymasks2bit+$E0
lda #%11110000
sta .copymasks2bit+$20
sta .mirror_copymasks2bit+$C0
lda #%10000011
sta .copymasks2bit+$80
sta .mirror_copymasks2bit+$60
lda #%11111100
sta .copymasks2bit+$A0
sta .mirror_copymasks2bit+$40
sta $C004
}
!macro FX_PRECOMPUTED_2BIT_DHGR .coords {
+BUILD_SPARSE_BITMASKS_2BIT_DHGR copymasks2bit, mirror_copymasks2bit
jsr iBuildDHGRSparseBitmasks2Bit
jsr iBuildHGRTables
+BUILD_MIRROR_COLS_DHGR mirror_cols
jsr iBuildDHGRMirrorCols
+COPY_TO_0 start, end
jmp InputLoop
@ -126,10 +78,10 @@ end
}
!macro FX_PRECOMPUTED_2BIT_DHGR_DITHER .coords, .endcoords {
+BUILD_DITHER_MASKS_DHGR dithermasks
+BUILD_SPARSE_BITMASKS_2BIT_DHGR copymasks2bit, mirror_copymasks2bit
jsr iBuildDHGRDitherMasks
jsr iBuildDHGRSparseBitmasks2Bit
jsr iBuildHGRTables
+BUILD_MIRROR_COLS_DHGR mirror_cols
jsr iBuildDHGRMirrorCols
; phase 1 - in reverse, with additional masking (dithering)
jsr copytozp

View File

@ -25,7 +25,7 @@ Start
jsr iBuildDHGRSparseBitmasks1Bit
jsr iBuildHGRTables
jsr iBuildHGRMirrorTables
+BUILD_MIRROR_COLS_DHGR mirror_cols
jsr iBuildDHGRMirrorCols
+COPY_TO_AUXMEM $60, 4
+LDADDR EndCoordinates1Bit-2
+ST16 input

View File

@ -16,7 +16,7 @@ input = $FE ; word
jsr iBuildDHGRSparseBitmasks1Bit
jsr iBuildHGRTables
jsr iBuildHGRMirrorTables
+BUILD_MIRROR_COLS_DHGR mirror_cols
jsr iBuildDHGRMirrorCols
+COPY_TO_AUXMEM $60, 4
+LDADDR Coordinates

View File

@ -24,7 +24,7 @@ Start
jsr iBuildDHGRSparseBitmasks1Bit
jsr iBuildHGRTables
jsr iBuildHGRMirrorTables
+BUILD_MIRROR_COLS_DHGR mirror_cols
jsr iBuildDHGRMirrorCols
+COPY_TO_AUXMEM $60, 4
+LDADDR Coordinates1Bit

View File

@ -8,7 +8,6 @@
!source "src/fx/macros.dhgr.a"
!source "src/fx/macros.shr.a"
!source "src/fx/macros.copybit.a"
!source "src/fx/macros.dither.a"
!source "src/fx/macros.misc.a"
_FX_MACROS_=*

View File

@ -22,21 +22,5 @@
sta $C004
}
!macro BUILD_MIRROR_COLS_DHGR .mirror_cols {
; build lookup table to get $27-y for y in $00..$27
; duplicate in both mainmem and auxmem
ldx #$28
ldy #$00
- tya
sta .mirror_cols-1, x
sta $C005
sta .mirror_cols-1, x
sta $C004
iny
dex
bne -
; X=0
}
_FX_MACROS_DHGR_=*
}

View File

@ -1,51 +0,0 @@
;license:MIT
;(c) 2019-2022 by 4am
;
!ifndef _FX_MACROS_DITHER_ {
!macro BUILD_DITHER_MASKS_DHGR .dithermasks {
ldy #40
- lda #%10011110
sta .dithermasks, y
lda #%11111000
sta .dithermasks+1, y
lda #%11100001
sta .dithermasks+2, y
lda #%10000111
sta .dithermasks+3, y
dey
dey
dey
dey
bpl -
ldy #43
- lda #$FF
sta .dithermasks+44, y
dey
bpl -
sta $C005
ldy #40
- lda #%10001111
sta .dithermasks, y
lda #%10111100
sta .dithermasks+1, y
lda #%11110000
sta .dithermasks+2, y
lda #%11000011
sta .dithermasks+3, y
dey
dey
dey
dey
bpl -
ldy #43
- lda #$FF
sta .dithermasks+44, y
dey
bpl -
sta $C004
}
_FX_MACROS_DITHER_=*
}

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15915234
!be24 15910273
!le16 5130

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15859914
!be24 15854953
!le16 5732

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15791681
!be24 15786720
!le16 4194

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15806395
!be24 15801434
!le16 4652

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15825110
!be24 15820149
!le16 5621

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15846151
!be24 15841190
!le16 6199

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15920364
!be24 15915403
!le16 410

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15921118
!be24 15916157
!le16 449

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15921567
!be24 15916606
!le16 303

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 12687899
!be24 12682938
!le16 1652

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15868286
!be24 15863325
!le16 1640

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15920850
!be24 15915889
!le16 67

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15915175
!be24 15910214
!le16 59

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15913595
!be24 15908634
!le16 1426

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15898361
!be24 15893400
!le16 557

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15865646
!be24 15860685
!le16 2640

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15870284
!be24 15865323
!le16 451

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15870735
!be24 15865774
!le16 7564

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15920774
!be24 15915813
!le16 76

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15915021
!be24 15910060
!le16 154

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15920917
!be24 15915956
!le16 201

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15898918
!be24 15893957
!le16 4334

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15903252
!be24 15898291
!le16 1733

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15904985
!be24 15900024
!le16 1181

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15906166
!be24 15901205
!le16 3394

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15909560
!be24 15904599
!le16 3429

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15912989
!be24 15908028
!le16 479

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15913468
!be24 15908507
!le16 127

View File

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

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15883704
!be24 15878743
!le16 5083

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15888787
!be24 15883826
!le16 2485

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15852350
!be24 15847389
!le16 7564

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15782098
!be24 15777137
!le16 9583

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15795875
!be24 15790914
!le16 10520

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15811047
!be24 15806086
!le16 14063

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15830731
!be24 15825770
!le16 15420

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15869926
!be24 15864965
!le16 358

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15878299
!be24 15873338
!le16 5405

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15891272
!be24 15886311
!le16 7089

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15777750
!be24 15772789
!le16 4348