refactoring transition scripts

This commit is contained in:
4am
2019-10-29 10:11:35 -04:00
parent d343d09ba7
commit c80dd4a328
21 changed files with 38020 additions and 40008 deletions
+1
View File
@@ -1,3 +1,4 @@
.DS_Store
__pycache__
/build/
/bin/V2Make.scpt
File diff suppressed because it is too large Load Diff
@@ -1,6 +1,7 @@
#!/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
@@ -10,7 +11,8 @@ from math import sqrt, sin, cos, acos, pi
# 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.
# 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;
@@ -42,36 +44,8 @@ for k_mul in range(2000):
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 = 191 - y
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))
unique_coords = util.unique(coords)
unique_vals = util.vals_2bit(unique_coords)
with open("../../../src/fx/fx.hgr.heart.data.a", "w") as f:
for aval, bval in unique_vals:
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/env python3
import math
def f(x,r=36.3):
try:
return math.sqrt(r*r*(1.0-(x*x/(r*r*0.6))))
except:
return -1
coords = [(255,255)]
for i in range(300, 0, -1):
a = float(i)/10.0
any = False
b = f(a)
for x in range(20, 0, -1):
y = round(float(x)*b/a)
if y < 1 or y > 24:
continue
for m in range(1, y+1):
if (x-1,m-1) not in coords:
coords.append((x-1,m-1))
any = True
if any:
coords.append((255,255))
q1 = coords.copy()
q2 = [(-x-1,y) for x,y in coords]
q2.reverse()
q3 = [(-x-1,-y-1) for x,y in coords]
q4 = [(x,-y-1) for x,y in coords]
q4.reverse()
coords = q4 + q1 + q2 + q3
with open("../../src/fx/fx.hgr.radial.data.a", "w") as f:
for x, y in coords:
if x not in range(-40,40):
f.write(" !byte 255,255\n")
else:
f.write(" !byte %s,%s\n" % ((23-y,19-x)))
coords = []
for cs in list(zip(q1,q3)) + list(zip(q2,q4)):
for c in cs:
coords.append(c)
with open("../../src/fx/fx.hgr.radial2.data.a", "w") as f:
for x, y in coords:
if x not in range(-40,40):
f.write(" !byte 255,255\n")
else:
f.write(" !byte %s,%s\n" % ((23-y,19-x)))
coords = []
for cs in zip(q1,q2,q3,q4):
for c in cs:
coords.append(c)
with open("../../src/fx/fx.hgr.radial3.data.a", "w") as f:
for x, y in coords:
if x not in range(-40,40):
f.write(" !byte 255,255\n")
else:
f.write(" !byte %s,%s\n" % ((23-y,19-x)))
q1.reverse()
q3.reverse()
coords = []
for cs in zip(q1,q2,q3,q4):
for c in cs:
coords.append(c)
with open("../../src/fx/fx.hgr.radial4.data.a", "w") as f:
for x, y in coords:
if x not in range(-40,40):
f.write(" !byte 255,255\n")
else:
f.write(" !byte %s,%s\n" % ((23-y,19-x)))
q1.reverse()
q2.reverse()
q3.reverse()
q4.reverse()
coords = []
for cs in zip(q1,q2,q3,q4):
for c in cs:
coords.append(c)
with open("../../src/fx/fx.hgr.radial5.data.a", "w") as f:
for x, y in coords:
if x not in range(-40,40):
f.write(" !byte 255,255\n")
else:
f.write(" !byte %s,%s\n" % ((23-y,19-x)))
+27 -72
View File
@@ -2,88 +2,43 @@
import math
radius_x = 280//2
radius_y = 192//2
def f(x,r=36.3):
try:
return math.sqrt(r*r*(1.0-(x*x/(r*r*0.6))))
except:
return -1
coords = [(255,255)]
for i in range(300, 0, -1):
a = float(i)/10.0
any = False
coords = []
for i in range(30000, 0, -1):
a = float(i)/1000.0
b = f(a)
for x in range(20, 0, -1):
for x in range(140, 0, -1):
y = round(float(x)*b/a)
if y < 1 or y > 24:
if x < 1 or x > radius_x or y < 1 or y > radius_y:
continue
for m in range(1, y+1):
if (x-1,m-1) not in coords:
coords.append((x-1,m-1))
any = True
if any:
coords.append((255,255))
if m % 2 != 0:
continue
coords.append((radius_x - x,radius_y - m))
q1 = coords.copy()
q2 = [(-x-1,y) for x,y in coords]
q2.reverse()
q3 = [(-x-1,-y-1) for x,y in coords]
q4 = [(x,-y-1) for x,y in coords]
q4.reverse()
coords = q4 + q1 + q2 + q3
with open("../../src/fx/fx.hgr.radial.data.a", "w") as f:
for x, y in coords:
if x not in range(-40,40):
f.write(" !byte 255,255\n")
else:
f.write(" !byte %s,%s\n" % ((23-y,19-x)))
d = {}
unique_coords = []
for c in coords:
if not d.get(c):
unique_coords.append(c)
d[c] = 1
coords = []
for cs in list(zip(q1,q3)) + list(zip(q2,q4)):
for c in cs:
coords.append(c)
with open("../../src/fx/fx.hgr.radial2.data.a", "w") as f:
for x, y in coords:
if x not in range(-40,40):
f.write(" !byte 255,255\n")
else:
f.write(" !byte %s,%s\n" % ((23-y,19-x)))
unique_vals = []
for x, y in unique_coords:
aval = "$" + hex(y)[2:].rjust(2, "0").upper()
bval = "%" + \
bin(x%7)[2:].rjust(3, "0") + \
bin(x//7)[2:].rjust(5, "0")
unique_vals.append((aval, bval))
coords = []
for cs in zip(q1,q2,q3,q4):
for c in cs:
coords.append(c)
with open("../../src/fx/fx.hgr.radial3.data.a", "w") as f:
for x, y in coords:
if x not in range(-40,40):
f.write(" !byte 255,255\n")
else:
f.write(" !byte %s,%s\n" % ((23-y,19-x)))
q1.reverse()
q3.reverse()
coords = []
for cs in zip(q1,q2,q3,q4):
for c in cs:
coords.append(c)
with open("../../src/fx/fx.hgr.radial4.data.a", "w") as f:
for x, y in coords:
if x not in range(-40,40):
f.write(" !byte 255,255\n")
else:
f.write(" !byte %s,%s\n" % ((23-y,19-x)))
q1.reverse()
q2.reverse()
q3.reverse()
q4.reverse()
coords = []
for cs in zip(q1,q2,q3,q4):
for c in cs:
coords.append(c)
with open("../../src/fx/fx.hgr.radial5.data.a", "w") as f:
for x, y in coords:
if x not in range(-40,40):
f.write(" !byte 255,255\n")
else:
f.write(" !byte %s,%s\n" % ((23-y,19-x)))
with open("../../../src/fx/fx.hgr.radial.data.a", "w") as f:
for aval, bval in unique_vals:
f.write(" !byte %s,%s\n" % (aval, bval))
-44
View File
@@ -1,44 +0,0 @@
#!/usr/bin/env python3
import math
radius_x = 280//2
radius_y = 192//2
def f(x,r=36.3):
try:
return math.sqrt(r*r*(1.0-(x*x/(r*r*0.6))))
except:
return -1
coords = []
for i in range(30000, 0, -1):
a = float(i)/1000.0
b = f(a)
for x in range(140, 0, -1):
y = round(float(x)*b/a)
if x < 1 or x > radius_x or y < 1 or y > radius_y:
continue
for m in range(1, y+1):
if m % 2 != 0:
continue
coords.append((radius_x - x,radius_y - m))
d = {}
unique_coords = []
for c in coords:
if not d.get(c):
unique_coords.append(c)
d[c] = 1
unique_vals = []
for x, y in unique_coords:
aval = "$" + hex(y)[2:].rjust(2, "0").upper()
bval = "%" + \
bin(x%7)[2:].rjust(3, "0") + \
bin(x//7)[2:].rjust(5, "0")
unique_vals.append((aval, bval))
with open("../../../src/fx/fx.hgr.radial.data.a", "w") as f:
for aval, bval in unique_vals:
f.write(" !byte %s,%s\n" % (aval, bval))
-92
View File
@@ -1,92 +0,0 @@
#!/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):
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))
+5 -31
View File
@@ -1,6 +1,7 @@
#!/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
@@ -10,7 +11,8 @@ from math import sqrt, sin, cos, acos, pi
# 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.
# 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;
@@ -42,36 +44,8 @@ for k_mul in range(1000):
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))
unique_coords = util.unique(coords)
unique_vals = util.vals_2bit(unique_coords)
with open("../../../src/fx/fx.hgr.soft.iris.data.a", "w") as f:
for aval, bval in unique_vals:
+52 -12
View File
@@ -1,26 +1,66 @@
#!/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(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(500):
any = False
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(20+a*.6)
y = round(24+b)
if x < 0 or x > 39 or y < 0 or y > 47 or (x,y) in coords:
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))
any = True
if any:
coords.append((255,255))
with open("../../src/fx/fx.hgr.star.data.a", "w") as f:
for x, y in coords:
f.write(" !byte %s,%s\n" % (y,x))
unique_coords = util.unique(coords)
unique_vals = util.vals_2bit(unique_coords)
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))
+34
View File
@@ -0,0 +1,34 @@
def unique(coords):
d = {}
unique_coords = []
for c in coords:
if not d.get(c):
unique_coords.append(c)
d[c] = 1
return unique_coords
even_byte_bitmask = (0, 0, 1, 1, 2, 2, 3)
odd_byte_bitmask = (5, 5, 6, 6, 7, 7, 4)
def vals_2bit(unique_coords):
unique_vals = []
for x, y in unique_coords:
y = 191 - y
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))
return unique_vals
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+7551 -7551
View File
File diff suppressed because it is too large Load Diff
+7551 -7551
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff