Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- screen I/O --
- sys.dofile(0, "font.lua")
- local screen = {}
- -- color palette taken from VICE with no CRT emuation filter
- local palette = {
- [0] = 0x000000,
- [1] = 0xffffff,
- [2] = 0xb5685e,
- [3] = 0xa9f3ff,
- [4] = 0xcd6fd4,
- [5] = 0x89e581,
- [6] = 0x6953f5,
- [7] = 0xffff7b,
- [8] = 0xc69232,
- [9] = 0x8d7900,
- [10]= 0xf5ab96,
- [11]= 0x818181,
- [12]= 0xb6b6b6,
- [13]= 0xcdffc6,
- [14]= 0xb19eff,
- [15]= 0xe0e0e0
- }
- local function computeXY(index)
- index = index + 1
- local y = math.floor(index / 40)
- local x = index % 40
- return x*4, y*2 -- displayed font is 4x2 chars or 8x8 pixels
- end
- local function drawchar(index, code, color)
- local colsw
- if code > 127 then
- colsw = true
- code = code - 127
- end
- local draw = sys.font[code+1]
- local x, y = computeXY(index)
- local fg, bg = palette[color], palette[sys.ram.get(53281)]
- if colsw then
- fg, bg = bg, fg
- end
- sys.gpu.setForeground(fg)
- sys.gpu.setBackground(bg)
- -- component.proxy(component.list("sandbox")()).log(x, y, fg, bg, color, code, draw)
- sys.gpu.set(x-1, y, unicode.sub(draw, 1,4))
- sys.gpu.set(x-1, y, unicode.sub(draw, 5))
- end
- -- TODO: this is probably sloooooooow
- function screen.refresh()
- for i=1024, 2023, 1 do
- drawchar(i - 1024, sys.ram.get(i), sys.ram.get(55296 + i - 1024))
- end
- end
- for i=55296, 56295, 1 do
- sys.ram.set(i, 14)
- end
- sys.ram.set(53281, 6)
- screen.refresh()
- sys.screen = screen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement