badapple-cc/badapple.lua

41 lines
730 B
Lua
Raw Normal View History

2022-12-03 14:12:39 -07:00
local monitor = peripheral.find("monitor")
monitor.setTextScale(0.5)
videoFile = fs.open("video.bin", "rb")
videoData = videoFile.readAll()
monitor.clear()
function drawFrame (frame)
local byteIndex = frame * 24 * 3
for y = 1, 24 do
monitor.setCursorPos(5, y + 2)
for x = 1, 3 do
byteIndex = byteIndex + 1
drawByte(videoData:byte(byteIndex))
end
end
end
function drawByte (byte)
local divisor = 0x80
for i = 1, 8 do
local bit = ((byte / divisor) % 2) >= 1
if bit then
monitor.setBackgroundColor(colors.white)
else
monitor.setBackgroundColor(colors.black)
end
monitor.write(" ")
divisor = divisor / 2
end
end
for index = 1, 2516 do
drawFrame(index)
os.sleep(0.1)
-- os.sleep(0.5)
end