Bad apple??
This commit is contained in:
parent
635886f683
commit
570e721e3e
|
@ -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}")
|
Binary file not shown.
|
@ -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()
|
Loading…
Reference in New Issue