import struct import math import random random.seed(0) LOGO = ''' BBBB BBBB BB B B B B BB BBBB B B B B B BBBB BBBB B BB WWWW WWWW W W WWWW WWWW W W WWWW WWWW '''[1:-1] LOGO = ''' RRRR RRRR RR R BBBB BBBB R R R B B RR RRRR R R BBBB BBBB R R R B B RRRR RRRR R RR BBBB BBBB WWWW WWWW W W W W W WWWW W W W WWWW WWWW '''[1:-1] LOGO = LOGO.split("\n") print(LOGO) width = max(len(row) for row in LOGO) height = len(LOGO) print("width =", width) print("height =", height) with open("xenrom/data/logo.dat", "wb") as data_out, open("xenrom/data/logo.inc", "w") as inc: for y in range(height): row = LOGO[y] for x in range(width): c = row[x] if x < len(row) else ' ' data_out.write(b'\x00' if c == ' ' else b'\x01' if c == 'B' else b'\x02' if c == 'W' else b'\x03') inc.write(f"const LOGO_WIDTH: {hex(width)}\n") inc.write(f"const LOGO_HEIGHT: {hex(height)}\n") with open("xenrom/data/logo_cycle.dat", "wb") as data, open("xenrom/data/logo_cycle.inc", "w") as inc: T = 60 N = T * 4 r = 0 for i in range(N): if i < T or i > 3 * T: f = 0.5 - (1/2 * math.cos((i/T) * math.pi)) elif i < 180: f = 0.75 - (1/4 * math.cos((i/T) * math.pi)) if i == 3 * T - 10: r = 1 if i == 3 * T: r = 2 if i == 3 * T + 10: r = 0 data.write(struct.pack("BB", min(255, int(256 * f)), r)) inc.write(f"const LOGO_LENGTH: {N}")