mirror of
https://github.com/a2-4am/4cade.git
synced 2025-08-15 12:27:32 +00:00
add butterfly effects
This commit is contained in:
@@ -1 +1 @@
|
||||
RIPPLE
|
||||
RIPPLE
|
60
res/notes/transitions/butterfly.py
Executable file
60
res/notes/transitions/butterfly.py
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from math import sqrt, sin, cos, acos, pi
|
||||
import util
|
||||
|
||||
# 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 flipped (so 0,0 ends up on the bottom left) then
|
||||
# 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(theta, k):
|
||||
r = k*(12-sin(theta)+2*sin(3*theta)+2*sin(5*theta)-sin(7*theta)+3*cos(2*theta)-2*cos(4*theta))
|
||||
return r*cos(theta),r*sin(theta)
|
||||
|
||||
coords = []
|
||||
for k_mul in range(3000):
|
||||
for t_mul in range(int(pi*1000+1)):
|
||||
a, b = f(float(t_mul/100), float(k_mul)/100.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))
|
||||
|
||||
unique_coords = util.unique(coords)
|
||||
unique_vals = util.vals_2bit(unique_coords)
|
||||
with open("../../../src/fx/fx.hgr.butterfly.data.a", "w") as f:
|
||||
for aval, bval in unique_vals:
|
||||
f.write(" !byte %s,%s\n" % (aval, bval))
|
||||
|
||||
ripple_vals = util.ripple(unique_vals)
|
||||
with open("../../../src/fx/fx.hgr.butterfly.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.butterfly.in.data.a", "w") as f:
|
||||
for aval, bval in unique_vals:
|
||||
f.write(" !byte %s,%s\n" % (aval, bval))
|
@@ -51,12 +51,7 @@ with open("../../../src/fx/fx.hgr.heart.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])
|
||||
ripple_vals = util.ripple(unique_vals)
|
||||
with open("../../../src/fx/fx.hgr.heart.ripple.data.a", "w") as f:
|
||||
for aval, bval in ripple_vals:
|
||||
f.write(" !byte %s,%s\n" % (aval, bval))
|
||||
|
@@ -45,12 +45,7 @@ with open("../../../src/fx/fx.hgr.iris.in.data.a", "w") as f:
|
||||
f.write(" !byte %s,%s\n" % (aval, bval))
|
||||
|
||||
unique_vals.reverse()
|
||||
ripple_vals = []
|
||||
for i, j, k, l in zip(range(1680), range(1680,3360), range(3360,5040), range(5040,6720)):
|
||||
ripple_vals.append(unique_vals[i])
|
||||
ripple_vals.append(unique_vals[j])
|
||||
ripple_vals.append(unique_vals[k])
|
||||
ripple_vals.append(unique_vals[l])
|
||||
ripple_vals = util.ripple(unique_vals)
|
||||
with open("../../../src/fx/fx.hgr.ripple.data.a", "w") as f:
|
||||
for aval, bval in ripple_vals:
|
||||
f.write(" !byte %s,%s\n" % (aval, bval))
|
||||
|
@@ -50,12 +50,7 @@ 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])
|
||||
ripple_vals = util.ripple(unique_vals)
|
||||
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))
|
||||
|
@@ -32,3 +32,13 @@ def vals_2bit(unique_coords):
|
||||
bval = "%011" + bin(byte+1)[2:].rjust(5, "0") + ";"
|
||||
unique_vals.append((aval, bval))
|
||||
return unique_vals
|
||||
|
||||
def ripple(unique_vals):
|
||||
z = len(unique_vals)
|
||||
ripple_vals = []
|
||||
for i, j, k, l in zip(range(z//4), range(z//4,z//2), range(z//2,z*3//4), range(z*3//4,z)):
|
||||
ripple_vals.append(unique_vals[i])
|
||||
ripple_vals.append(unique_vals[j])
|
||||
ripple_vals.append(unique_vals[k])
|
||||
ripple_vals.append(unique_vals[l])
|
||||
return ripple_vals
|
||||
|
14
src/fx/fx.hgr.butterfly.a
Normal file
14
src/fx/fx.hgr.butterfly.a
Normal file
@@ -0,0 +1,14 @@
|
||||
;license:MIT
|
||||
;(c) 2019 by 4am
|
||||
;
|
||||
!cpu 6502
|
||||
!to "build/FX/BUTTERFLY",plain
|
||||
*=$6000
|
||||
|
||||
!source "src/fx/fx.hgr.precomputed.2bit.a"
|
||||
|
||||
+FX_PRECOMPUTED_2BIT Coordinates
|
||||
|
||||
Coordinates
|
||||
!source "src/fx/fx.hgr.butterfly.data.a"
|
||||
!byte $00
|
7680
src/fx/fx.hgr.butterfly.data.a
Normal file
7680
src/fx/fx.hgr.butterfly.data.a
Normal file
File diff suppressed because it is too large
Load Diff
14
src/fx/fx.hgr.butterfly.in.a
Normal file
14
src/fx/fx.hgr.butterfly.in.a
Normal file
@@ -0,0 +1,14 @@
|
||||
;license:MIT
|
||||
;(c) 2019 by 4am
|
||||
;
|
||||
!cpu 6502
|
||||
!to "build/FX/BUTTERFLY.IN",plain
|
||||
*=$6000
|
||||
|
||||
!source "src/fx/fx.hgr.precomputed.2bit.a"
|
||||
|
||||
+FX_PRECOMPUTED_2BIT Coordinates
|
||||
|
||||
Coordinates
|
||||
!source "src/fx/fx.hgr.butterfly.in.data.a"
|
||||
!byte $00
|
7680
src/fx/fx.hgr.butterfly.in.data.a
Normal file
7680
src/fx/fx.hgr.butterfly.in.data.a
Normal file
File diff suppressed because it is too large
Load Diff
14
src/fx/fx.hgr.butterfly.ripple.a
Normal file
14
src/fx/fx.hgr.butterfly.ripple.a
Normal file
@@ -0,0 +1,14 @@
|
||||
;license:MIT
|
||||
;(c) 2019 by 4am
|
||||
;
|
||||
!cpu 6502
|
||||
!to "build/FX/BUTTERFLYRIPPLE",plain
|
||||
*=$6000
|
||||
|
||||
!source "src/fx/fx.hgr.precomputed.2bit.a"
|
||||
|
||||
+FX_PRECOMPUTED_2BIT Coordinates
|
||||
|
||||
Coordinates
|
||||
!source "src/fx/fx.hgr.butterfly.ripple.data.a"
|
||||
!byte $00
|
7680
src/fx/fx.hgr.butterfly.ripple.data.a
Normal file
7680
src/fx/fx.hgr.butterfly.ripple.data.a
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user