upgraded single-star wipes

This commit is contained in:
4am
2019-10-27 20:28:28 -04:00
parent 8da2d2d057
commit 64db15d856
9 changed files with 23332 additions and 1 deletions

View File

@@ -1 +1 @@
RIPPLE
RIPPLE

View File

@@ -0,0 +1,93 @@
#!/usr/bin/env python3
from math import sqrt, sin, cos, acos, pi
# Graph is plotted across the entire HGR screen, but only coordinates
# - in the left half of the screen, AND
# - on even rows, AND
# - on even columns
# are included. It is assumed that the graph is symmetrical across
# the left and half sides of the screen (along an axis at X=140).
#
# X coordinates are converted to byte+bitmask (but see notes below).
# Y coordinates are incremented by 1 so that 0 can terminate the loop.
#
# 6502 code will be responsible for plotting each of these coordinates
# in a 2x2 block. The bitmask usually includes 2 adjacent pixels;
# the code will also plot the same 2 adjacent pixels in the adjacent row,
# AND mirror both of those plots in the right half of the screen.
#
# Unfortunately, since bytes are 7 bits across, some blocks will cross a
# byte boundary. To simplify the 6502 code, those are simply listed as
# separate coordinate pairs, each with a bitmask that includes 1 pixel
# instead of 2.
max_x = 280
max_y = 192
def f(t, k):
t = float(t)
r = k/cos(0.4*acos(sin(2.5*(t+pi/2))))
return r*cos(t),r*sin(t)
coords = []
for k_mul in range(1000):
for t_mul in range(int(pi*1000+1)):
a, b = f(float(t_mul/100), float(k_mul)/10.0)
x = round(max_x//2+a*1.2)
y = round(max_y//2+b)
if (x % 2 != 0) or (y % 2 != 0):
continue
if x < 0 or x >= max_x//2 or y < 0 or y >= max_y:
continue
coords.append((x,y))
d = {}
unique_coords = []
for c in coords:
if not d.get(c):
unique_coords.append(c)
d[c] = 1
unique_vals = []
even_byte_bitmask = (0, 0, 1, 1, 2, 2, 3)
odd_byte_bitmask = (5, 5, 6, 6, 7, 7, 4)
for x, y in unique_coords:
y = y + 1
aval = "$" + hex(y)[2:].rjust(2, "0").upper()
byte = x//7
if byte % 2 == 0:
# high 3 bits are 0-3, low 5 bits are 0-39
bval = "%" + bin(even_byte_bitmask[x % 7])[2:].rjust(3, "0") + bin(byte)[2:].rjust(5, "0")
unique_vals.append((aval, bval))
if x % 7 == 6:
# this 2x2 block will be split across bytes, so add an extra coordinate pair with the adjacent byte and high 3 bits = 4
bval = "%100" + bin(byte+1)[2:].rjust(5, "0") + ";"
unique_vals.append((aval, bval))
else:
# high 3 bits are 5-7 or 4, low 5 bits are 0-39
bval = "%" + bin(odd_byte_bitmask[x % 7])[2:].rjust(3, "0") + bin(byte)[2:].rjust(5, "0")
unique_vals.append((aval, bval))
if x % 7 == 6:
# this 2x2 block will be split across bytes, so add an extra coordinate pair with the adjacent byte and high 3 bits = 3
bval = "%011" + bin(byte+1)[2:].rjust(5, "0") + ";"
unique_vals.append((aval, bval))
with open("../../../src/fx/fx.hgr.star.data.a", "w") as f:
for aval, bval in unique_vals:
f.write(" !byte %s,%s\n" % (aval, bval))
ripple_vals = []
for i, j, k, l in zip(range(1920), range(1920,3840), range(3840,5760), range(5760,7680)):
ripple_vals.append(unique_vals[i])
ripple_vals.append(unique_vals[j])
ripple_vals.append(unique_vals[k])
ripple_vals.append(unique_vals[l])
with open("../../../src/fx/fx.hgr.star.ripple.data.a", "w") as f:
for aval, bval in ripple_vals:
f.write(" !byte %s,%s\n" % (aval, bval))
unique_vals.reverse()
with open("../../../src/fx/fx.hgr.star.in.data.a", "w") as f:
for aval, bval in unique_vals:
f.write(" !byte %s,%s\n" % (aval, bval))

View File

@@ -0,0 +1,156 @@
;license:MIT
;(c) 2019 by 4am
;
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
copymasks = $0200 ; $100 bytes but sparse, index is 0..4 but in high 3 bits, so $00, $20, $40, $60, $80
mirror_copymasks = $0201
hgrlo = $0300 ; $C0 bytes
hgrlomirror = $BD40 ; $C0 bytes
mirror_cols = $BE00 ; $28 bytes
hgr1hi = $BE40 ; $C0 bytes
hgr1himirror = $BF40 ; $C0 bytes
!source "src/fx/macros.a"
!macro BUILD_MIRROR_COLS .mirror_cols {
; build lookup table to get $27-y for y in $00..$27
ldx #$27
ldy #$00
- tya
sta .mirror_cols,x
iny
dex
bpl -
}
!macro BUILD_SPARSE_BITMASKS_2BIT .copymasks, .mirror_copymasks {
; build sparse lookup tables for bitmasks
lda #%10000011
sta .copymasks
sta .mirror_copymasks+$E0
lda #%10001100
sta .copymasks+$20
sta .mirror_copymasks+$C0
lda #%10110000
sta .copymasks+$40
sta .mirror_copymasks+$A0
lda #%11000000
sta .copymasks+$60
sta .mirror_copymasks+$80
lda #%10000001
sta .copymasks+$80
sta .mirror_copymasks+$60
lda #%10000110
sta .copymasks+$A0
sta .mirror_copymasks+$40
lda #%10011000
sta .copymasks+$C0
sta .mirror_copymasks+$20
lda #%11100000
sta .copymasks+$E0
sta .mirror_copymasks
}
!macro ROW_X_TO_2BIT_BASE_ADDRESSES {
; X = $01..$C0, mapping to row 0..191
lda hgrlo-1,x
sta dest1
sta src1
lda hgr1hi-1,x
sta dest1+1
eor #$60
sta src1+1
lda hgrlo,x
sta dest2
sta src2
lda hgr1hi,x
sta dest2+1
eor #$60
sta src2+1
}
!macro HIGH_3_LOW_5 .input {
and #%11100000 ; second value: high 3 bits = index into tables to find bitmasks
tax
eor (.input),y ; second value: low 5 bits = byte offset within the row (implicitly "and #%00011111")
tay
}
!macro INC_INPUT_AND_LOOP .loop {
inc input
beq +
jmp .loop
+ bit $c000
bmi +
inc input+1
jmp .loop
+ rts
}
!macro DEC_INPUT_AND_LOOP .loop {
lda input
beq +
dec input
dec input
jmp .loop
+ dec input
dec input
dec input+1
bit $c000
bmi +
jmp .loop
+ rts
}
!macro FX_PRECOMPUTED_2BIT .coords {
+BUILD_HGR_LOOKUP_TABLES hgrlo, hgr1hi
+BUILD_MIRROR_COLS mirror_cols
+BUILD_SPARSE_BITMASKS_2BIT copymasks, mirror_copymasks
+LDADDR .coords
+STAY input
jmp InputLoop
Exit2Bit rts
InputLoop
ldy #0
lda (input),y ; first value: HGR row + 1
beq Exit2Bit ; if 0 then we're done
tax
+ROW_X_TO_2BIT_BASE_ADDRESSES
inc input
lda (input),y
+HIGH_3_LOW_5 input
; main 2x2 block in left half
+COPY_BIT src1, dest1, copymasks
+COPY_BIT src2, dest2, copymasks
; corresponding 2x2 block in right half (same row, opposite column)
lda mirror_cols,y
tay
+COPY_BIT src1, dest1, mirror_copymasks
+COPY_BIT src2, dest2, mirror_copymasks
+INC_INPUT_AND_LOOP InputLoop
rts
!if * and 1 {
!byte 0 ;align 2 but avoids the fake allocation bug if it was aligned already
}
}

14
src/fx/fx.hgr.star.a Normal file
View File

@@ -0,0 +1,14 @@
;license:MIT
;(c) 2019 by 4am
;
!cpu 6502
!to "build/FX/STAR",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.2bit.a"
+FX_PRECOMPUTED_2BIT Coordinates
Coordinates
!source "src/fx/fx.hgr.star.data.a"
!byte $00

7680
src/fx/fx.hgr.star.data.a Normal file

File diff suppressed because it is too large Load Diff

14
src/fx/fx.hgr.star.in.a Normal file
View File

@@ -0,0 +1,14 @@
;license:MIT
;(c) 2019 by 4am
;
!cpu 6502
!to "build/FX/STAR.IN",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.2bit.a"
+FX_PRECOMPUTED_2BIT Coordinates
Coordinates
!source "src/fx/fx.hgr.star.in.data.a"
!byte $00

7680
src/fx/fx.hgr.star.in.data.a Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
;license:MIT
;(c) 2019 by 4am
;
!cpu 6502
!to "build/FX/STAR.RIPPLE",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.2bit.a"
+FX_PRECOMPUTED_2BIT Coordinates
Coordinates
!source "src/fx/fx.hgr.star.ripple.data.a"
!byte $00

File diff suppressed because it is too large Load Diff