Some performance work, remove debug message
This commit is contained in:
parent
e3f753f4df
commit
75f386b03a
2
Makefile
2
Makefile
@ -36,7 +36,7 @@ $(BUILD)lupi: $(OBJECTS)
|
|||||||
$(CC) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBS)
|
$(CC) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBS)
|
||||||
|
|
||||||
$(BUILD)%.c.o: $(SOURCE)%.c $(BUILD)
|
$(BUILD)%.c.o: $(SOURCE)%.c $(BUILD)
|
||||||
$(CC) -c $(CFLAGS) -I src/c -I src/c/lib/lua $< -o $@
|
$(CC) -c $(CFLAGS) -I /usr/include -I src/c -I src/c/lib/lua $< -o $@
|
||||||
|
|
||||||
#Resources
|
#Resources
|
||||||
luaresources: cleanresourcues
|
luaresources: cleanresourcues
|
||||||
|
@ -114,7 +114,6 @@ end
|
|||||||
-----
|
-----
|
||||||
|
|
||||||
function api.pushSignal(s, ...)
|
function api.pushSignal(s, ...)
|
||||||
io.stderr:write("pushSignal "..s.."\n")
|
|
||||||
signalQueue[#signalQueue + 1] = {computer.signalTransformers[s](s, ...)}
|
signalQueue[#signalQueue + 1] = {computer.signalTransformers[s](s, ...)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ io.write = function(...)
|
|||||||
io.flush()
|
io.flush()
|
||||||
native.sleep(20000)
|
native.sleep(20000)
|
||||||
end]]--
|
end]]--
|
||||||
|
local write = io.write
|
||||||
|
local flush = io.flush
|
||||||
|
|
||||||
local background = "0"
|
local background = "0"
|
||||||
local foreground = "0"
|
local foreground = "0"
|
||||||
@ -53,8 +55,8 @@ function textgpu.start()
|
|||||||
end
|
end
|
||||||
local old = background
|
local old = background
|
||||||
background = tostring(math.floor(modules.color.nearest(color, mapping)))
|
background = tostring(math.floor(modules.color.nearest(color, mapping)))
|
||||||
io.write("\x1b[4" .. background .. "m")
|
write("\x1b[4" .. background .. "m")
|
||||||
io.flush()
|
flush()
|
||||||
return mapping[old]
|
return mapping[old]
|
||||||
end
|
end
|
||||||
function gpu.setForeground(color, isPaletteIndex)
|
function gpu.setForeground(color, isPaletteIndex)
|
||||||
@ -65,8 +67,8 @@ function textgpu.start()
|
|||||||
end
|
end
|
||||||
local old = foreground
|
local old = foreground
|
||||||
foreground = tostring(math.floor(modules.color.nearest(color, mapping)))
|
foreground = tostring(math.floor(modules.color.nearest(color, mapping)))
|
||||||
io.write("\x1b[3" .. foreground .. "m")
|
write("\x1b[3" .. foreground .. "m")
|
||||||
io.flush()
|
flush()
|
||||||
return mapping[old]
|
return mapping[old]
|
||||||
end
|
end
|
||||||
function gpu.getBackground()
|
function gpu.getBackground()
|
||||||
@ -126,14 +128,14 @@ function textgpu.start()
|
|||||||
tbuffer[y] = insertString(tbuffer[y], value, x)
|
tbuffer[y] = insertString(tbuffer[y], value, x)
|
||||||
bbuffer[y] = insertString(bbuffer[y], background:rep(utf8.len(value)), x)
|
bbuffer[y] = insertString(bbuffer[y], background:rep(utf8.len(value)), x)
|
||||||
fbuffer[y] = insertString(fbuffer[y], foreground:rep(utf8.len(value)), x)
|
fbuffer[y] = insertString(fbuffer[y], foreground:rep(utf8.len(value)), x)
|
||||||
io.write("\x1b[" .. y .. ";" .. x .. "H" .. value)
|
write("\x1b[" .. y .. ";" .. x .. "H" .. value)
|
||||||
else
|
else
|
||||||
io.write("\x1b[" .. y .. ";" .. x .. "H")
|
write("\x1b[" .. y .. ";" .. x .. "H")
|
||||||
value:gsub(".", function(c)
|
value:gsub(".", function(c)
|
||||||
io.write(c .. "\x1b[D\x1b[B")
|
write(c .. "\x1b[D\x1b[B")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
io.flush()
|
flush()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
function gpu.copy(x, y, w, h, tx, ty) --TODO: Check(check X multiple times)
|
function gpu.copy(x, y, w, h, tx, ty) --TODO: Check(check X multiple times)
|
||||||
@ -156,22 +158,22 @@ function textgpu.start()
|
|||||||
|
|
||||||
for i=1, h do
|
for i=1, h do
|
||||||
local line, linex
|
local line, linex
|
||||||
local write = false
|
local lwrite = false
|
||||||
for j=1, w do
|
for j=1, w do
|
||||||
if btbuf[i]:sub(j,j) ~= bg then
|
if btbuf[i]:sub(j,j) ~= bg then
|
||||||
write = true
|
lwrite = true
|
||||||
end
|
end
|
||||||
if ftbuf[i]:sub(j,j) ~= fg then
|
if ftbuf[i]:sub(j,j) ~= fg then
|
||||||
write = true
|
lwrite = true
|
||||||
end
|
end
|
||||||
if not line then linex = j end
|
if not line then linex = j end
|
||||||
line = (line or "")
|
line = (line or "")
|
||||||
if write then
|
if lwrite then
|
||||||
local wx = (tx + linex)|0
|
local wx = (tx + linex)|0
|
||||||
local wy = (ty + y + i - 1)|0
|
local wy = (ty + y + i - 1)|0
|
||||||
io.write("\x1b[4" .. bg .. "m")
|
write("\x1b[4" .. bg .. "m")
|
||||||
io.write("\x1b[3" .. fg .. "m")
|
write("\x1b[3" .. fg .. "m")
|
||||||
io.write("\x1b[" .. wy .. ";" .. wx .. "H" .. line)
|
write("\x1b[" .. wy .. ";" .. wx .. "H" .. line)
|
||||||
tbuffer[wy] = insertString(tbuffer[wy], line, wx)
|
tbuffer[wy] = insertString(tbuffer[wy], line, wx)
|
||||||
bbuffer[wy] = insertString(bbuffer[wy], bg:rep(utf8.len(line)), wx)
|
bbuffer[wy] = insertString(bbuffer[wy], bg:rep(utf8.len(line)), wx)
|
||||||
fbuffer[wy] = insertString(fbuffer[wy], fg:rep(utf8.len(line)), wx)
|
fbuffer[wy] = insertString(fbuffer[wy], fg:rep(utf8.len(line)), wx)
|
||||||
@ -179,7 +181,7 @@ function textgpu.start()
|
|||||||
fg = ftbuf[i]:sub(j,j)
|
fg = ftbuf[i]:sub(j,j)
|
||||||
line = nil
|
line = nil
|
||||||
linex = nil
|
linex = nil
|
||||||
write = false
|
lwrite = false
|
||||||
end
|
end
|
||||||
if not line then linex = j end
|
if not line then linex = j end
|
||||||
line = (line or "") .. ttbuf[i]:sub(j,j)
|
line = (line or "") .. ttbuf[i]:sub(j,j)
|
||||||
@ -187,20 +189,20 @@ function textgpu.start()
|
|||||||
if line then
|
if line then
|
||||||
local wx = (tx + linex)|0
|
local wx = (tx + linex)|0
|
||||||
local wy = (ty + y + i - 1)|0
|
local wy = (ty + y + i - 1)|0
|
||||||
io.write("\x1b[4" .. bg .. "m")
|
write("\x1b[4" .. bg .. "m")
|
||||||
io.write("\x1b[3" .. fg .. "m")
|
write("\x1b[3" .. fg .. "m")
|
||||||
io.write("\x1b[" .. wy .. ";" .. wx .. "H" .. line)
|
write("\x1b[" .. wy .. ";" .. wx .. "H" .. line)
|
||||||
tbuffer[wy] = insertString(tbuffer[wy], line, wx)
|
tbuffer[wy] = insertString(tbuffer[wy], line, wx)
|
||||||
bbuffer[wy] = insertString(bbuffer[wy], bg:rep(utf8.len(line)), wx)
|
bbuffer[wy] = insertString(bbuffer[wy], bg:rep(utf8.len(line)), wx)
|
||||||
fbuffer[wy] = insertString(fbuffer[wy], fg:rep(utf8.len(line)), wx)
|
fbuffer[wy] = insertString(fbuffer[wy], fg:rep(utf8.len(line)), wx)
|
||||||
line = nil
|
line = nil
|
||||||
linex = nil
|
linex = nil
|
||||||
write = false
|
lwrite = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
io.write("\x1b[4" .. background .. "m")
|
write("\x1b[4" .. background .. "m")
|
||||||
io.write("\x1b[3" .. foreground .. "m")
|
write("\x1b[3" .. foreground .. "m")
|
||||||
io.flush()
|
flush()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
function gpu.fill(x, y, w, h, ch)
|
function gpu.fill(x, y, w, h, ch)
|
||||||
@ -216,7 +218,7 @@ function textgpu.start()
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
io.write("\x1b[?25l") --Disable cursor
|
write("\x1b[?25l") --Disable cursor
|
||||||
local w, h = gpu.getResolution()
|
local w, h = gpu.getResolution()
|
||||||
prepareBuffers(w, h)
|
prepareBuffers(w, h)
|
||||||
gpu.setForeground(0xFFFFFF)
|
gpu.setForeground(0xFFFFFF)
|
||||||
@ -227,7 +229,7 @@ function textgpu.start()
|
|||||||
modules.component.api.register("TODO:SetThisUuid", "keyboard", {})
|
modules.component.api.register("TODO:SetThisUuid", "keyboard", {})
|
||||||
|
|
||||||
deadhooks[#deadhooks + 1] = function()
|
deadhooks[#deadhooks + 1] = function()
|
||||||
io.write("\x1b[?25h") --Enable cursor on quit
|
write("\x1b[?25h") --Enable cursor on quit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user