new dither transition effects

This commit is contained in:
4am 2022-08-24 22:31:23 -04:00
parent 952d68dc33
commit d356d4be23
67 changed files with 1183 additions and 57 deletions

View File

@ -28,83 +28,104 @@ MANDELBROT.IN
RADIAL
STAGGER.LR
SOFT.UD
DITHER.IRIS
HEART.IN
CRYSTAL
STAR.RIPPLE
BIT2.FIZZLE
DITHER.HEART
MEETINTHEMIDDLE
BOXES48
APPLE.IN
FLOWER.RAD.RIP
DITHER.CORNER4
SOFT.IRIS
W.RIPPLE.BLOOM
DIAGONAL
PINWHEELS
DITHER.SLOWSTAR
STAGGERWHITE.UD
BOXES48.SYNCC
CORNER4.RIP
BOLT
DITHER.SNOWFLAK
RADIAL2
STAR
FLOWER.IN
R.BY.PIXEL
DITHER.BUTTERFL
WAVY.IRIS
BIT.FIZZLE
STAR.IN
BOXES48.PAGEC
DITHER.MAPLE
DIAG.STRIPES
APPLE
MANDELBROT.RIP
SOFT.L
DITHER.SOFTIRIS
HEART.RIPPLE
FLOWER.RAD
SLOW.STAR.IN
IRIS.IN
DITHER.STAR
BUTTERFLYRIPPLE
BOXES48.SPIRALC
W.IRIS.BLOOM.IN
CENTER.BY.PIXEL
DITHER.WAVYIRIS
RADBUBBLES
SNOWFLAKE.IN
FLOWER
APPLE.RIPPLE
DITHER.DISSOLVE
DIAGONAL2
STAR.BLOOM
DIAMOND.STRIPES
BOXES48.SYNC
DITHER.RADIAL
THIN.DISSOLVE
PALETTE.FIZZLE
BUTTERFLY
BUBBLES
DITHER.RADIAL2
FLOWER.RIPPLE
SPLIT.UD.INTRO
WAVY.IRIS.IN
R.BY.2
DITHER.RADIAL4
HALF.FIZZLE
BOXES48.LDIAGON
SNOWFLAKE.RIP
RADIAL3
HEART
BOLT.IN
DITHER.RADIAL5
FLOWER.RAD.IN
DIAGONAL3
MANDELBROT
BOXES48.SPIRAL
DITHER.APPLE
WAVY.RIPPLE
CORNER4.OUT
LATTICE
BAR.DISSOLVE
DITHER.BOLT
R.BY.PALETTE
FOURSPIRAL
SOFT.R
MAPLE.IN
DITHER.FLOWER
BOXES48.SNAKEC
RADIAL4
IRIS
CASCADE
DITHER.FLOWERRD
SNOWFLAKE
VERTICAL.BLINDS
BUTTERFLY.IN
LR.BY.PIXEL
DITHER.MANDEL
CHECKERB.FIZZLE
BOXES48.SIDES
CIRCLE.STRIPES

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.APPLE",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.3bit.a"
+FX_INITONCE_3BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_3BIT_DITHER Coordinates3Bit, EndCoordinates3Bit
CoordinatesFile
!byte 13
!text "FX/APPLE.DATA"

View File

@ -0,0 +1,19 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
; https://thenounproject.com/ArtZ91/collection/pure-lines/?i=550425
; Lightning Bolt by Arthur Shlain from the Noun Project
; CC-BY
!cpu 6502
!to "build/FX.INDEXED/DITHER.BOLT",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.3bit.a"
+FX_INITONCE_3BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_3BIT_DITHER Coordinates3Bit, EndCoordinates3Bit
CoordinatesFile
!byte 12
!text "FX/BOLT.DATA"

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.BUTTERFL",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.2bit.a"
+FX_INITONCE_2BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_2BIT_DITHER Coordinates2Bit, EndCoordinates2Bit
CoordinatesFile
!byte 17
!text "FX/BUTTERFLY.DATA"

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.CORNER4",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.1bit.a"
+FX_INITONCE_1BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_1BIT_DITHER Coordinates1Bit, EndCoordinates1Bit
CoordinatesFile
!byte 15
!text "FX/CORNER4.DATA"

View File

@ -0,0 +1,68 @@
;license:MIT
;(c) 2022 by 4am
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.DISSOLVE",plain
*=$6000
row1 = $fe
row2 = $ff
src = $3c
dst = $26
lda #$00
sta row1
lda #$BF
sta row2
@loop lda row1
jsr HGRCalc
ldy #$27
- tya
and #$03
tax
lda (src),y
eor (dst),y ; merge source and destination bits
@amask and mask1,x ; isolate the bits to replace, zero the rest
eor (dst),y ; unmerge source and destination bits, leaves 'to keep' destination bits intact
sta (dst),y ; write the result
dey
bpl -
lda row2
jsr HGRCalc
ldy #$27
- tya
and #$03
tax
lda (src),y
eor (dst),y
@bmask and mask3,x
eor (dst),y
sta (dst),y
dey
bpl -
lda #$28
jsr WaitForKeyWithTimeout
bmi @exit
inc row1
dec row2
lda row1
cmp #$60
beq @loop
ldx @amask+1
ldy @bmask+1
stx @bmask+1
sty @amask+1
cmp #$C0
bne @loop
@exit rts
mask1 !byte %10110011
mask2 !byte %11100110
mask3 !byte %11001100
mask4 !byte %10011001
!byte %10110011
!byte %11100110
!source "src/wait.a"
!source "src/fx/fx.hgr.common.a"
+HGR_CALC_ROUTINES

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.FLOWER",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.3bit.a"
+FX_INITONCE_3BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_3BIT_DITHER Coordinates3Bit, EndCoordinates3Bit
CoordinatesFile
!byte 14
!text "FX/FLOWER.DATA"

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.FLOWERRD",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.3bit.a"
+FX_INITONCE_3BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_3BIT_DITHER Coordinates3Bit, EndCoordinates3Bit
CoordinatesFile
!byte 18
!text "FX/FLOWER.RAD.DATA"

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.HEART",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.2bit.a"
+FX_INITONCE_2BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_2BIT_DITHER Coordinates2Bit, EndCoordinates2Bit
CoordinatesFile
!byte 13
!text "FX/HEART.DATA"

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.IRIS",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.1bit.a"
+FX_INITONCE_1BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_1BIT_DITHER Coordinates1Bit, EndCoordinates1Bit
CoordinatesFile
!byte 12
!text "FX/IRIS.DATA"

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.MANDEL",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.3bit.a"
+FX_INITONCE_3BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_3BIT_DITHER Coordinates3Bit, EndCoordinates3Bit
CoordinatesFile
!byte 18
!text "FX/MANDELBROT.DATA"

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.MAPLE",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.2bit.a"
+FX_INITONCE_2BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_2BIT_DITHER Coordinates2Bit, EndCoordinates2Bit
CoordinatesFile
!byte 13
!text "FX/MAPLE.DATA"

View File

@ -0,0 +1,117 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.RADIAL",plain
*=$6000
evenrow_ptr = $E4 ; word
oddrow_ptr = $E6 ; word
mirror_src1 = $E8 ; word
mirror_dest1 = $EA ; word
mirror_src2 = $EC ; word
mirror_dest2 = $EE ; word
src1 = $F0 ; word
dest1 = $F2 ; word
src2 = $F4 ; word
dest2 = $F6 ; word
input = $FE ; word
!source "src/fx/fx.hgr.precomputed.1bit.a"
+FX_INITONCE_1BIT CoordinatesFile, Start
lda #$80
sta Coordinates1Bit-2
+BUILD_DITHER_MASKS dither_masks, evenrow_masks, oddrow_masks, no_masks
+BUILD_HGR_LOOKUP_TABLES hgrlo, hgr1hi
+BUILD_HGR_MIRROR_LOOKUP_TABLES hgrlomirror, hgr1himirror
+BUILD_MIRROR_COLS mirror_cols
+BUILD_SPARSE_BITMASKS copymasks, mirror_copymasks
Start
+LDADDR evenrow_masks
+ST16 evenrow_ptr
+LDADDR oddrow_masks
+ST16 oddrow_ptr
jsr FullRadial
bit KBD
bpl +
rts
+ lda #<no_masks
sta <evenrow_ptr
sta <oddrow_ptr
; /!\ execution falls through here
FullRadial
+LDADDR EndCoordinates1Bit-2
+ST16 input
LoopBL ; bottom-left quadrant (opposite row, original column, reverse input order)
ldy #0
lda (input),y
bmi DoneBL
tax
+ROW_X_TO_MIRROR_ADDRESSES
iny
lda (input),y
+HIGH_3_LOW_5 input
+COPY_BIT_DITHER mirror_src1, mirror_dest1, copymasks, oddrow_ptr
+COPY_BIT_DITHER mirror_src2, mirror_dest2, copymasks, evenrow_ptr
+DEC_INPUT_AND_LOOP LoopBL
DoneBL
+LDADDR Coordinates1Bit
+ST16 input
LoopTL ; top-left quadrant
ldy #0
lda (input),y
bmi DoneTL
tax
+ROW_X_TO_BASE_ADDRESSES
inc input
lda (input),y
+HIGH_3_LOW_5 input
+COPY_BIT_DITHER src1, dest1, copymasks, evenrow_ptr
+COPY_BIT_DITHER src2, dest2, copymasks, oddrow_ptr
+INC_INPUT_AND_LOOP LoopTL
DoneTL
+LDADDR EndCoordinates1Bit-2
+ST16 input
LoopTR ; top-right quadrant (same row, opposite column, reverse input order)
ldy #0
lda (input),y
bmi DoneTR
tax
+ROW_X_TO_BASE_ADDRESSES
iny
lda (input),y
+HIGH_3_LOW_5 input
lda mirror_cols,y
tay
+COPY_BIT_DITHER src1, dest1, mirror_copymasks, evenrow_ptr
+COPY_BIT_DITHER src2, dest2, mirror_copymasks, oddrow_ptr
+DEC_INPUT_AND_LOOP LoopTR
DoneTR
+LDADDR Coordinates1Bit
+ST16 input
LoopBR ; bottom-right quadrant (opposite row, opposite column, original input order)
ldy #0
lda (input),y
bmi DoneBR
tax
+ROW_X_TO_MIRROR_ADDRESSES
inc input
lda (input),y
+HIGH_3_LOW_5 input
lda mirror_cols,y
tay
+COPY_BIT_DITHER mirror_src1, mirror_dest1, mirror_copymasks, oddrow_ptr
+COPY_BIT_DITHER mirror_src2, mirror_dest2, mirror_copymasks, evenrow_ptr
+INC_INPUT_AND_LOOP LoopBR
DoneBR
rts
+DITHER_MASK_DATA
CoordinatesFile
!byte 14
!text "FX/RADIAL.DATA"

View File

@ -0,0 +1,91 @@
evenrow_ptr = $E4 ; word
oddrow_ptr = $E6 ; word
mirror_src1 = $E8 ; word
mirror_dest1 = $EA ; word
mirror_src2 = $EC ; word
mirror_dest2 = $EE ; word
src1 = $F0 ; word
dest1 = $F2 ; word
src2 = $F4 ; word
dest2 = $F6 ; word
reverse_input = $FC ; word
input = $FE ; word
+BUILD_DITHER_MASKS dither_masks, evenrow_masks, oddrow_masks, no_masks
+BUILD_MIRROR_COLS mirror_cols
+BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 hgrlo, hgr1hi
+BUILD_HGR_MIRROR_LOOKUP_TABLES hgrlomirror, hgr1himirror
+BUILD_SPARSE_BITMASKS copymasks, mirror_copymasks
+LDADDR evenrow_masks
+ST16 evenrow_ptr
+LDADDR oddrow_masks
+ST16 oddrow_ptr
jsr FullRadial
bit KBD
bmi Exit
lda #<no_masks
sta <evenrow_ptr
sta <oddrow_ptr
; /!\ execution falls through here
FullRadial
+LDADDR Coordinates
+ST16 input
+LDADDR EndCoordinates-2
+ST16 reverse_input
+HIDE_NEXT_BYTE
Exit rts
Loop ldy #0
lda (input),y
bmi Exit
tax
+ROW_X_TO_BASE_ADDRESSES
+ROW_X_TO_MIRROR_ADDRESSES
inc input
lda (input),y
+HIGH_3_LOW_5 input
; top-left quadrant (original row, original column, original input order)
+COPY_BIT_DITHER src1, dest1, copymasks, evenrow_ptr
+COPY_BIT_DITHER src2, dest2, copymasks, oddrow_ptr
; bottom-right quadrant (opposite row, opposite column, original input order)
lda mirror_cols,y
tay
+COPY_BIT_DITHER mirror_src1, mirror_dest1, mirror_copymasks, oddrow_ptr
+COPY_BIT_DITHER mirror_src2, mirror_dest2, mirror_copymasks, evenrow_ptr
ldy #0
lda (reverse_input),y
tax
+ROW_X_TO_BASE_ADDRESSES
+ROW_X_TO_MIRROR_ADDRESSES
iny
lda (reverse_input),y
+HIGH_3_LOW_5 reverse_input
; bottom-left quadrant (opposite row, original column, reverse input order)
+COPY_BIT_DITHER mirror_src1, mirror_dest1, copymasks, oddrow_ptr
+COPY_BIT_DITHER mirror_src2, mirror_dest2, copymasks, evenrow_ptr
; top-right quadrant (same row, opposite column, reverse input order)
lda mirror_cols,y
tay
+COPY_BIT_DITHER src1, dest1, mirror_copymasks, evenrow_ptr
+COPY_BIT_DITHER src2, dest2, mirror_copymasks, oddrow_ptr
inc input
bne +
inc input+1
+ lda reverse_input
php
dec reverse_input
dec reverse_input
plp
bne +
dec reverse_input+1
bit $c000
bmi ++
+ jmp Loop
++ rts
+DITHER_MASK_DATA

View File

@ -0,0 +1,20 @@
;license:MIT
;(c) 2019-2020 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.RADIAL2",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.1bit.a"
+FX_INITONCE_1BIT CoordinatesFile, Start
+FX_RIPPLE_1BIT aslmod
Start
!source "src/fx/fx.hgr.dither.radial.common.a"
CoordinatesFile
!byte 14
!text "FX/RADIAL.DATA"
Coordinates=Coordinates1Bit
EndCoordinates=EndCoordinates1Bit

View File

@ -0,0 +1,20 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.RADIAL4",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.1bit.a"
+FX_INITONCE_1BIT CoordinatesFile, Start
jsr EndCoordinates1Bit+1
Start
!source "src/fx/fx.hgr.dither.radial.common.a"
CoordinatesFile
!byte 14
!text "FX/RADIAL.DATA"
Coordinates=Coordinates1Bit
EndCoordinates=EndCoordinates1Bit

View File

@ -0,0 +1,20 @@
;license:MIT
;(c) 2019-2020 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.RADIAL5",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.1bit.a"
+FX_INITONCE_1BIT CoordinatesFile, Start
+FX_RIPPLE_1BIT aslmod3
Start
!source "src/fx/fx.hgr.dither.radial.common.a"
CoordinatesFile
!byte 14
!text "FX/RADIAL.DATA"
Coordinates=Coordinates1Bit
EndCoordinates=EndCoordinates1Bit

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.SLOWSTAR",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.1bit.a"
+FX_INITONCE_1BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_1BIT_DITHER Coordinates1Bit, EndCoordinates1Bit
CoordinatesFile
!byte 17
!text "FX/SLOW.STAR.DATA"

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.SNOWFLAK",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.1bit.a"
+FX_INITONCE_1BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_1BIT_DITHER Coordinates1Bit, EndCoordinates1Bit
CoordinatesFile
!byte 17
!text "FX/SNOWFLAKE.DATA"

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.SOFTIRIS",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.2bit.a"
+FX_INITONCE_2BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_2BIT_DITHER Coordinates2Bit, EndCoordinates2Bit
CoordinatesFile
!byte 17
!text "FX/SOFT.IRIS.DATA"

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.STAR",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.2bit.a"
+FX_INITONCE_2BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_2BIT_DITHER Coordinates2Bit, EndCoordinates2Bit
CoordinatesFile
!byte 12
!text "FX/STAR.DATA"

View File

@ -0,0 +1,16 @@
;license:MIT
;(c) 2019-2022 by 4am/qkumba
;
!cpu 6502
!to "build/FX.INDEXED/DITHER.WAVYIRIS",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.2bit.a"
+FX_INITONCE_2BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_2BIT_DITHER Coordinates2Bit, EndCoordinates2Bit
CoordinatesFile
!byte 17
!text "FX/WAVY.IRIS.DATA"

View File

@ -1,5 +1,5 @@
;license:MIT
;(c) 2019 by 4am
;(c) 2019-2022 by 4am
;
copymasks = $0200 ; $100 bytes but sparse, index is 0..6 but in high 3 bits, so $00, $20, $40, $60, $80, $A0, $C0
mirror_copymasks = $0201
@ -8,6 +8,10 @@ hgrlomirror = $BD40 ; $C0 bytes
mirror_cols = $BE00 ; $28 bytes
hgr1hi = $BE40 ; $C0 bytes
hgr1himirror = $BF40 ; $C0 bytes
; the next 3 addresses should all be on the same page
evenrow_masks = $8500 ; $28 bytes (for dithering)
oddrow_masks = $8528 ; $28 bytes (for dithering)
no_masks = $8550 ; $28 bytes (for dithering)
Coordinates1Bit= $8600 ; $3481 bytes ($3480 on disk + 1 byte EOF marker)
EndCoordinates1Bit=Coordinates1Bit+$3480
@ -101,7 +105,7 @@ EndCoordinates1Bit=Coordinates1Bit+$3480
inc <input
beq +
jmp .loop
+ bit $c000
+ bit KBD
bmi +
inc <input+1
jmp .loop
@ -116,7 +120,7 @@ EndCoordinates1Bit=Coordinates1Bit+$3480
plp
bne +
dec input+1
bit $c000
bit KBD
bpl .loop
bmi ++
+ jmp .loop
@ -331,7 +335,142 @@ mirror_dest2=*+1
+INC_INPUT_AND_LOOP InputLoop
}
end
!if * and 1 {
!byte 0 ;align 2 but avoids the fake allocation bug if it was aligned already
}
!macro FX_PRECOMPUTED_1BIT_DITHER .coords, .endcoords {
+BUILD_DITHER_MASKS dither_masks, evenrow_masks, oddrow_masks, no_masks
+BUILD_HGR_LOOKUP_TABLES hgrlo, hgr1hi
+BUILD_HGR_MIRROR_LOOKUP_TABLES hgrlomirror, hgr1himirror
+BUILD_MIRROR_COLS mirror_cols
+BUILD_SPARSE_BITMASKS copymasks, mirror_copymasks
; phase 1 - in reverse, with additional masking
+COPY_TO_0 start, end
; set up starting coordinate for reading coordinates in reverse order
+LDADDR .endcoords-2
sta <input
sty <input+1
; set up EOF marker to stop reading coordinates in reverse order
lda #$80
sta .coords-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 -
jsr InputLoop
bit KBD
bmi start
; phase 2 - in order, without additional masking
+COPY_TO_0 start, end
; redirect additional masking pointers to an array that contains #$FFs (so no masking)
lda #<no_masks
sta <evenrow_ptr
sta <oddrow_ptr
jmp InputLoop
start
!pseudopc 0 {
Exit1Bit rts
evenrow_ptr
!word evenrow_masks
oddrow_ptr
!word oddrow_masks
InputLoop
ldy #0
input=*+1
ldx .coords ; first value: HGR row (only 0..95 will be in input array)
bmi Exit1Bit ; if > 127 then we're done
+ROW_X_TO_BASE_ADDRESSES
+ROW_X_TO_MIRROR_ADDRESSES
iny
lda (<input), y
+HIGH_3_LOW_5 input
; main 1x2 block in top-left quadrant
src1=*+1
lda $FDFD, y
eor (<dest1), y
and copymasks, x
and (<evenrow_ptr), y
eor (<dest1), y
dest1=*+1
sta $FDFD, y
src2=*+1
lda $FDFD, y
eor (<dest2), y
and copymasks, x
and (<oddrow_ptr), y
eor (<dest2), y
dest2=*+1
sta $FDFD, y
; corresponding 1x2 block in top-right quadrant (same row, opposite column)
lda mirror_cols, y
tay
+COPY_BIT_DITHER src1, dest1, mirror_copymasks, evenrow_ptr
+COPY_BIT_DITHER src2, dest2, mirror_copymasks, oddrow_ptr
; corresponding 1x2 block in bottom-right quadrant (opposite row, opposite column)
mirror_src1=*+1
lda $FDFD, y
eor (<mirror_dest1), y
and mirror_copymasks, x
and (<oddrow_ptr), y
eor (<mirror_dest1), y
mirror_dest1=*+1
sta $FDFD, y
mirror_src2=*+1
lda $FDFD, y
eor (<mirror_dest2), y
and mirror_copymasks, x
and (<evenrow_ptr), y
eor (<mirror_dest2), y
mirror_dest2=*+1
sta $FDFD, y
; corresponding 1x2 block in bottom-left quadrant (opposite row, original column)
lda mirror_cols, y
tay
+COPY_BIT_DITHER mirror_src1, mirror_dest1, copymasks, oddrow_ptr
+COPY_BIT_DITHER mirror_src2, mirror_dest2, copymasks, evenrow_ptr
next
inc <input
inc <input
bne +
bit KBD
bmi ++
inc <input+1
+ jmp InputLoop
++ rts
}
end
next2_start
!pseudopc next {
lda <input
php
dec <input
dec <input
plp
bne +
dec <input+1
bit KBD
bmi ++
+ jmp InputLoop
++ rts
}
next2_end
+DITHER_MASK_DATA
}

View File

@ -1,5 +1,5 @@
;license:MIT
;(c) 2019-2020 by 4am
;(c) 2019-2022 by 4am
;
copymasks = $0200 ; $100 bytes but sparse, index is 0..4 but in high 3 bits, so $00, $20, $40, $60, $80
mirror_copymasks = $0201
@ -8,7 +8,12 @@ hgrlomirror = $BD40 ; $C0 bytes
mirror_cols = $BE00 ; $28 bytes
hgr1hi = $BE40 ; $C0 bytes
hgr1himirror = $BF40 ; $C0 bytes
; the next 3 addresses should all be on the same page
evenrow_masks = $8000 ; $28 bytes (used for dithering)
oddrow_masks = $8028 ; $28 bytes (used for dithering)
no_masks = $8050 ; $28 bytes (used for dithering)
Coordinates2Bit= $8100 ; $3C01 bytes ($3C00 on disk + 1 byte as EOF)
EndCoordinates2Bit = Coordinates2Bit + $3C00
!source "src/fx/macros.a"
@ -92,7 +97,7 @@ InitOnce
+LOAD_FILE_AT .CoordinatesFile, Coordinates2Bit
+READ_RAM1_WRITE_RAM1
lda #$00
sta Coordinates2Bit + $3C00
sta EndCoordinates2Bit
}
!macro FX_REVERSE_2BIT {
@ -100,9 +105,9 @@ InitOnce
sty $f0
lda #>Coordinates2Bit
sta $f1
lda #<(Coordinates2Bit + $3C00 - 2)
lda #<(EndCoordinates2Bit - 2)
sta $f2
lda #>(Coordinates2Bit + $3C00 - 2)
lda #>(EndCoordinates2Bit - 2)
sta $f3
ldx #$1E ; #$3C/2
@ -305,13 +310,134 @@ dest2=*+1
inc <input
bne InputLoop
bit $c000
bit KBD
bmi Exit2Bit
inc <input+1
bne InputLoop ; always branches
}
end
!if * and 1 {
!byte 0 ;align 2 but avoids the fake allocation bug if it was aligned already
}
!macro FX_PRECOMPUTED_2BIT_DITHER .coords, .endcoords {
+BUILD_DITHER_MASKS dither_masks, evenrow_masks, oddrow_masks, no_masks
+BUILD_HGR_LOOKUP_TABLES hgrlo, hgr1hi
+BUILD_MIRROR_COLS mirror_cols
+BUILD_SPARSE_BITMASKS_2BIT copymasks, mirror_copymasks
; phase 1 - in reverse, with additional masking (dithering)
jsr copytozp
; set up starting coordinate for reading coordinates in reverse order
+LDADDR .endcoords-2
sta <input
sty <input+1
; set up EOF marker to stop reading coordinates in reverse order
lda #$00
sta .coords-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 -
jsr InputLoop
bit KBD
bmi start
; phase 2 - in order, without additional masking
jsr copytozp
; redirect additional masking pointers to an array that contains #$FFs (so no dithering)
lda #<no_masks
sta <evenrow_ptr
sta <oddrow_ptr
jmp InputLoop
copytozp
+COPY_TO_0 start, end
start
!pseudopc 0 {
Exit2Bit rts
evenrow_ptr
!word evenrow_masks
oddrow_ptr
!word oddrow_masks
InputLoop
ldy #0
input=*+1
ldx .coords ; first value: HGR row + 1
beq Exit2Bit ; if 0 then we're done
+ROW_X_TO_2BIT_BASE_ADDRESSES
iny
lda (<input), y
+HIGH_3_LOW_5 input
; main 2x2 block in left half
src1=*+1
lda $FDFD, y
eor (<dest1), y
and copymasks, x
and (<evenrow_ptr), y
eor (<dest1), y
dest1=*+1
sta $FDFD, y
src2=*+1
lda $FDFD, y
eor (<dest2), y
and copymasks, x
and (<oddrow_ptr), y
eor (<dest2), y
dest2=*+1
sta $FDFD, y
; corresponding 2x2 block in right half (same row, opposite column)
lda mirror_cols, y
tay
lda (src1), y
eor (dest1), y
and mirror_copymasks, x
and (<evenrow_ptr), y
eor (dest1), y
sta (dest1), y
lda (src2), y
eor (dest2), y
and mirror_copymasks, x
and (<oddrow_ptr), y
eor (dest2), y
sta (dest2), y
next
inc <input
inc <input
bne InputLoop
bit KBD
bmi Exit2Bit
inc <input+1
bne InputLoop ; always branches
}
end
next2_start
!pseudopc next {
lda <input
php
dec <input
dec <input
plp
bne InputLoop
dec <input+1
bit KBD
bpl InputLoop
rts
}
next2_end
+DITHER_MASK_DATA
}

View File

@ -1,5 +1,5 @@
;license:MIT
;(c) 2019-2020 by 4am
;(c) 2019-2022 by 4am
;
copymasks = $0200 ; $100 bytes but sparse, index is 0..7 but in high 3 bits, so $00, $20, $40...
@ -12,10 +12,18 @@ hgrlo3c = $BD00 ; $80 bytes
hgrhi3a = $BD80 ; $80 bytes
hgrhi3b = $BE00 ; $80 bytes
hgrhi3c = $BE80 ; $80 bytes
dither1_lo = $6900 ; $80 bytes
dither2_lo = $6980 ; $80 bytes
dither3_lo = $6A00 ; $80 bytes
; the next 3 addresses should all be on the same page
evenrow_masks = $6A80 ; $28 bytes (for dithering)
oddrow_masks = $6AA8 ; $28 bytes (for dithering)
no_masks = $6AD0 ; $28 bytes (for dithering)
Coordinates3Bit= $6B00 ; pixel data is $5001 bytes ($5000 on disk + 1 byte as EOF marker)
; and for optimization we only support loading external files page-aligned
; and $BC00+ is used by the 3bit macros for data tables
; so we load at $6B00 and waste $FF bytes at $BB01+ but it's okay
EndCoordinates3Bit = Coordinates3Bit + $5000
!source "src/fx/macros.a"
@ -279,13 +287,159 @@ dest3=*+1
inc <input
bne InputLoop
bit $c000
bit KBD
bmi Exit3Bit
inc <input+1
bne InputLoop ; always branches
}
end
!if * and 1 {
!byte 0 ;align 2 but avoids the fake allocation bug if it was aligned already
}
!macro FX_PRECOMPUTED_3BIT_DITHER .coords, .endcoords {
+BUILD_DITHER_MASKS dither_masks, evenrow_masks, oddrow_masks, no_masks
+BUILD_3BIT_HGR_LOOKUP_TABLES
+BUILD_EXTRA_COLS
+BUILD_SPARSE_BITMASKS_3BIT
; phase 1 - in reverse, with additional masking
+COPY_TO_0 start, end
; set up starting coordinate for reading coordinates in reverse order
+LDADDR .endcoords-2
sta <input
sty <input+1
; set up EOF marker to stop reading coordinates in reverse order
lda #$80
sta .coords-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 #<evenrow_masks
sta dither1_lo, x
sta dither2_lo-1, x
sta dither3_lo, x
lda #<oddrow_masks
sta dither1_lo-1, x
sta dither2_lo, x
sta dither3_lo-1, x
dex
dex
bpl -
jsr InputLoop
bit KBD
bmi start
; phase 2 - in order, without additional masking
+COPY_TO_0 start, end
; set up pointers to dither mask pointers so all rows do no dithering
ldx #$7F
- lda #<no_masks
sta dither1_lo, x
sta dither2_lo, x
sta dither3_lo, x
dex
bpl -
jmp InputLoop
start
!pseudopc 0 {
Exit3Bit rts
dither1_ptr
!word evenrow_masks
dither2_ptr
!word oddrow_masks
dither3_ptr
!word evenrow_masks
InputLoop
ldy #0
input=*+1
lda .coords
bmi Exit3Bit ; if high bit is 1 then we're done
cmp #$40
php
tax
lda dither1_lo, x
sta dither1_ptr
lda dither2_lo, x
sta dither2_ptr
lda dither3_lo, x
sta dither3_ptr
+ROW_X_TO_3BIT_BASE_ADDRESSES
iny
lda (<input), y
and #%11100000
tax
eor (<input), y
plp
bcc +
tay
lda extra_cols, y
+ tay
; 2x3 block
src1=*+1
lda $FDFD, y
eor (<dest1), y
and copymasks, x
and (dither1_ptr), y
eor (<dest1), y
dest1=*+1
sta $FDFD, y
src2=*+1
lda $FDFD, y
eor (<dest2), y
and copymasks, x
and (dither2_ptr), y
eor (<dest2), y
dest2=*+1
sta $FDFD, y
src3=*+1
lda $FDFD, y
eor (<dest3), y
and copymasks, x
and (dither3_ptr), y
eor (<dest3), y
dest3=*+1
sta $FDFD, y
next
inc <input
inc <input
bne +
bit KBD
bmi ++
inc <input+1
+ jmp InputLoop
++ rts
}
end
next2_start
!pseudopc next {
lda <input
php
dec <input
dec <input
plp
bne +
dec <input+1
bit KBD
bmi ++
+ jmp InputLoop
++ rts
}
next2_end
+DITHER_MASK_DATA
}

View File

@ -0,0 +1,72 @@
;license:MIT
;(c) 2022 by 4am
;
!cpu 6502
!to "build/FX.INDEXED/THIN.DISSOLVE",plain
*=$6000
row1 = $fe
row2 = $ff
src = $3c
dst = $26
lda #$00
sta row1
lda #$BF
sta row2
@loop lda row1
jsr HGRCalc
ldy #$27
- tya
and #$03
tax
lda (src),y
eor (dst),y ; merge source and destination bits
and mask1,x ; isolate the bits to replace, zero the rest
eor (dst),y ; unmerge source and destination bits, leaves 'to keep' destination bits intact
sta (dst),y ; write the result
dey
bpl -
lda row2
jsr HGRCalc
ldy #$27
- tya
and #$03
tax
lda (src),y
eor (dst),y
and mask3,x
eor (dst),y
sta (dst),y
dey
bpl -
lda #$30
jsr WaitForKeyWithTimeout
bmi @exit
!if 0 {
ldx mask1
ldy mask3
stx mask3
sty mask1
ldx mask2
ldy mask4
stx mask4
sty mask2
}
inc row1
dec row2
lda row1
cmp #$C0
bne @loop
@exit rts
!source "src/wait.a"
!source "src/fx/fx.hgr.common.a"
+HGR_CALC_ROUTINES
mask1 !byte %10110011
mask2 !byte %11100110
mask3 !byte %11001100
mask4 !byte %10011001
!byte %10110011
!byte %11100110

View File

@ -62,6 +62,22 @@
bne -
}
!macro BUILD_DITHER_MASKS .dither_masks, .evenrow_masks, .oddrow_masks, .no_masks {
ldy #$28
-- ldx #$03
- dey
lda .dither_masks, x
sta .evenrow_masks, y
lda .dither_masks+2, x
sta .oddrow_masks, y
lda #$FF
sta .no_masks, y
dex
bpl -
tya
bne --
}
!macro HGR_CALC {
; in: A = HGR row (0x00..0xBF)
; out: A/X clobbered
@ -126,6 +142,25 @@
sta (.dest1),y ; write the result
}
!macro COPY_BIT_DITHER .src1, .dest1, .copymasks, .dithermaskptr {
lda (.src1),y
eor (.dest1),y ; merge source and destination bits
and .copymasks,x ; isolate the bits to replace, zero the rest
and (.dithermaskptr),y
eor (.dest1),y ; unmerge source and destination bits, leaves 'to keep' destination bits intact
sta (.dest1),y ; write the result
}
!macro DITHER_MASK_DATA {
dither_masks
!byte %10110011
!byte %11100110
!byte %11001100
!byte %10011001
!byte %10110011
!byte %11100110
}
!macro COPY_BIT_ZP .src1, .dest1, .zpcopymask {
lda (.src1),y
eor (.dest1),y ; merge source and destination bits

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1444524
!be24 1455855
!le16 496

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1434095
!be24 1444997
!le16 917

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1427723
!be24 1438625
!le16 214

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1428988
!be24 1439890
!le16 458

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1430525
!be24 1441427
!le16 399

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1432610
!be24 1443512
!le16 688

View File

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

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1445774
!be24 1457105
!le16 256

View File

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

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1437158
!be24 1448489
!le16 1242

View File

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

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1444512
!be24 1455843
!le16 12

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1443721
!be24 1455052
!le16 739

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1442057
!be24 1453388
!le16 216

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1435012
!le16 2146
!be24 1445914
!le16 2575

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1438758
!be24 1450089
!le16 797

View File

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

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1444460
!be24 1455791
!le16 52

View File

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

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1442273
!be24 1453604
!le16 335

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1442608
!be24 1453939
!le16 69

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1442677
!be24 1454008
!le16 81

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1442758
!be24 1454089
!le16 62

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1442820
!be24 1454151
!le16 623

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1443443
!be24 1454774
!le16 274

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1443717
!be24 1455048
!le16 4

View File

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

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1440617
!be24 1451948
!le16 381

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1440998
!be24 1452329
!le16 420

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1433298
!be24 1444200
!le16 797

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 422443
!be24 422955
!le16 8184

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 438819
!be24 439331
!le16 8184

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 430627
!be24 431139
!le16 8192

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1427156
!be24 1438058
!le16 567

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1427937
!be24 1438839
!le16 1051

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1429446
!be24 1440348
!le16 1079

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1430924
!be24 1441826
!le16 1686

View File

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

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1439555
!be24 1450886
!le16 1062

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 1441418
!be24 1452749
!le16 639