diff --git a/badapple-tape.py b/badapple-tape.py new file mode 100644 index 0000000..94958f1 --- /dev/null +++ b/badapple-tape.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# x-run: python3 % badapple.bin ~/videos/badapple/frame*.png + +from sys import argv +from PIL import Image + +w, h = 82, 40 + +bits = [[1,2],[4,8],[16,0]] + +with open(argv[1], "wb") as fp: + fp.write(bytes([w, h])) + for i, f in enumerate(argv[2:]): + with Image.open(f) as im: + img = im.resize((w * 2, h * 3)).convert("1") + for y in range(h): + line = bytearray() + for x in range(w): + val = 0 + for oy, l in enumerate(bits): + for ox, bi in enumerate(l): + if img.getpixel((x * 2 + ox, y * 3 + oy)): + val |= bi + if img.getpixel((x * 2 + 1, y * 3 + 2)): + val ^= 0x9f + line.append(val) + fp.write(line) + print(f"wrote {i + 1} / {len(argv) - 2}") diff --git a/badapple.bin b/badapple.bin new file mode 100644 index 0000000..09910c8 Binary files /dev/null and b/badapple.bin differ diff --git a/videotape.lua b/videotape.lua new file mode 100644 index 0000000..6283a01 --- /dev/null +++ b/videotape.lua @@ -0,0 +1,23 @@ +local tape = peripheral.find("tape_drive") +local mon = peripheral.find("monitor") + +tape.seek(0) +mon.setTextScale(1) + +local w, h = string.byte(tape.read(2), 1, 2) + +repeat + for y = 1, h do + mon.setCursorPos(1, y) + local buf = string.byte(tape.read(w), 1, -1) + local s, f, b = "", "", "" + for x = 1, w do + s = s .. string.char(bit32.band(0x7F, buf[x])) + local inv = bit32.band(0x80, buf[x]) + f = f .. (inv and "f" or "0") + b = b .. (inv and "0" or "f") + end + mon.blit(s, f, b) + end + os.sleep(0.01) +until tape.isEnd()