From d4b07eebc1124b412ceeec256f1478b860602329 Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 17 May 2020 00:23:43 -0400 Subject: [PATCH] Fixed performance issue. --- installer_dat/bios_list.lua | 1 + installer_dat/package_list.lua | 1 + ksrc/libs/thd.lua | 2 +- lib/fs_arcfs/init.lua | 44 +++++++++++++++++++++ mods/net_minitel/init.lua | 12 ++++++ mods/net_minitel/minitel-3.lua | 0 mods/net_minitel/minitel-4.lua | 0 mods/net_minitel/minitel-5.lua | 29 ++++++++++++++ mods/util_luaconsole/init.lua | 2 +- mods/util_luaconsole/tty.lua | 4 +- utils/ser.lua | 70 +++++++++++++++++++++++++--------- 11 files changed, 143 insertions(+), 22 deletions(-) create mode 100644 mods/net_minitel/init.lua create mode 100644 mods/net_minitel/minitel-3.lua create mode 100644 mods/net_minitel/minitel-4.lua create mode 100644 mods/net_minitel/minitel-5.lua diff --git a/installer_dat/bios_list.lua b/installer_dat/bios_list.lua index 882f03d..041481f 100644 --- a/installer_dat/bios_list.lua +++ b/installer_dat/bios_list.lua @@ -1,5 +1,6 @@ { {type="managed", path="bios/managed.bios"}, + {type="initramfs", path="bios/initramfs.bios"}, --{type="osdi", path="bios/osdi.bios"}, --{type="romfs", path="bios/romfs.bios"}, --{type="proxfs", path="bios/proxfs.bios"} diff --git a/installer_dat/package_list.lua b/installer_dat/package_list.lua index 3750765..919bd9e 100644 --- a/installer_dat/package_list.lua +++ b/installer_dat/package_list.lua @@ -19,6 +19,7 @@ {name="minitel", cat="net", path="lib/net_minitel.zy2l"}, --{name="vdev", cat="util", path="mods/util_vdev.zy2m"}, {name="classic", cat="menu", path="mods/menu_classic.zy2m"}, + {name="luaconsole", cat="util", path="mods/util_luaconsole.zy2m"}, --{name="vdevrt", cat="rtmod", path="mods/rtmod_vdevrt.zy2m"}, --{name="tsukinet", cat="net", path="mods/net_tsukinet"}, --{name="biosemu", cat="loader", path="mods/loader_biosemu.zy2m", warning="warn_mod_biosemu"}, diff --git a/ksrc/libs/thd.lua b/ksrc/libs/thd.lua index 34c8468..2016312 100644 --- a/ksrc/libs/thd.lua +++ b/ksrc/libs/thd.lua @@ -59,7 +59,7 @@ function thd.run() dl = computer.uptime() + (dl or math.huge) threads[i][4] = dl threads[i].delta = computer.uptime() - dt - sigs[#sigs+1] = {ps(0)} + --sigs[#sigs+1] = {ps(0)} end end end diff --git a/lib/fs_arcfs/init.lua b/lib/fs_arcfs/init.lua index 1dada5e..6a222ed 100644 --- a/lib/fs_arcfs/init.lua +++ b/lib/fs_arcfs/init.lua @@ -3,9 +3,53 @@ local arcfs = {} function arcfs.make(arc) local proxy = {} local function ni()return nil, "not implemented"end + local hands = {} proxy.remove = ni proxy.makeDirectory = ni function proxy.exists(path) + return arc:exists(path) + end + function proxy.spaceUsed() + return 0 + end + function proxy.open(path, mode) + if mode ~= "r" and mode ~= "rb" then + return nil, "read-only filesystem" + end + end + function proxy.isReadOnly() + return true + end + proxy.write = ni + function proxy.spaceTotal() + return 0 + end + function proxy.isDirectory(dir) + if arc.isdir then return arc:isdir(dir) end + return #arc:list(dir) > 0 + end + function proxy.list(path) + return arc:list(path) + end + function proxy.lastModified(path) + return 0 + end + function proxy.getLabel() + return "ARCFS_VOLUME" + end + function proxy.close(hand) + + end + function proxy.size(path) end + function proxy.read(hand, count) + + end + function proxy.seek(hand, whence, amt) + + end + function proxy.setLabel() + return "ARCFS_VOLUME" + end end \ No newline at end of file diff --git a/mods/net_minitel/init.lua b/mods/net_minitel/init.lua new file mode 100644 index 0000000..cba611f --- /dev/null +++ b/mods/net_minitel/init.lua @@ -0,0 +1,12 @@ +local net = {} + +net.port = 4096 +net.modems = {} + +local sockets = {} +local sock = {} + +--#include "minitel-3.lua" +--#include "minitel-4.lua" +--#include "minitel-5.lua" + diff --git a/mods/net_minitel/minitel-3.lua b/mods/net_minitel/minitel-3.lua new file mode 100644 index 0000000..e69de29 diff --git a/mods/net_minitel/minitel-4.lua b/mods/net_minitel/minitel-4.lua new file mode 100644 index 0000000..e69de29 diff --git a/mods/net_minitel/minitel-5.lua b/mods/net_minitel/minitel-5.lua new file mode 100644 index 0000000..ce289b7 --- /dev/null +++ b/mods/net_minitel/minitel-5.lua @@ -0,0 +1,29 @@ +local c_sock = {} +local h_sock = {} + +function c_sock:read(a) + local dat = self.data:sub(1, a-1) + self.data = self.data:sub(a) + return dat +end + +function c_sock:recieve(a) + +end + +function c_sock:write(d) + +end + +function c_sock:send(d) + +end + +function c_sock:close() + +end + +function c_sock:timeout(t) + if t then self.to = t endsi + return self.to +end \ No newline at end of file diff --git a/mods/util_luaconsole/init.lua b/mods/util_luaconsole/init.lua index 53748dc..13f6ea6 100644 --- a/mods/util_luaconsole/init.lua +++ b/mods/util_luaconsole/init.lua @@ -88,7 +88,7 @@ return function(autorun) tty.print(s()) end, function(e) tty.setcolor(0x4) - tty.print(debug.traceback(e):gsub("\t", " "):gsub("\r", "")) + tty.print(debug.traceback(e):gsub("\t", " "):gsub("\r", "\n")) end) end tty.setcolor(2) diff --git a/mods/util_luaconsole/tty.lua b/mods/util_luaconsole/tty.lua index 9ff023b..c1e61e2 100644 --- a/mods/util_luaconsole/tty.lua +++ b/mods/util_luaconsole/tty.lua @@ -157,8 +157,8 @@ do for i=1, #args do args[i] = tostring(args[i]) end - local str = table.concat(args, " ").."\n" - for m in str:gmatch("(.*)\n") do + local str = table.concat(args, " ").."\n" -- ugly hack + for m in str:gmatch("(.-)\n") do tty.write(m) local x, y = tty.getcursor() if (x ~= 1) then diff --git a/utils/ser.lua b/utils/ser.lua index bd28abf..30ddf2e 100644 --- a/utils/ser.lua +++ b/utils/ser.lua @@ -57,25 +57,36 @@ local gpu = proxy(list("gpu")()) if (not gpu.getScreen()) then gpu.bind(list("screen")()) end +local usepal +if (gpu.getDepth() > 1) then + usepal = true + gpu.setPaletteColor(0, 0x000000) + gpu.setPaletteColor(1, 0xFFFFFF) + gpu.setPaletteColor(2, 0x4444FF) + gpu.setPaletteColor(3, 0xFF7F44) + gpu.setPaletteColor(4, 0x00007F) + gpu.setPaletteColor(5, 0x7F00FF) + gpu.setPaletteColor(6, 0x595959) +end +local function gc(c) + if usepal then + return c, true + end + return (c == 1) and 1 or 0 +end --Load palette -gpu.setPaletteColor(0, 0x000000) -gpu.setPaletteColor(1, 0xFFFFFF) -gpu.setPaletteColor(2, 0x4444FF) -gpu.setPaletteColor(3, 0xFF7F44) -gpu.setPaletteColor(4, 0x00007F) -gpu.setPaletteColor(5, 0x7F00FF) -gpu.setPaletteColor(6, 0x595959) -gpu.setBackground(0, true) +gpu.setBackground(gc(0)) local w, h = gpu.getViewport() gpu.fill(1, 2, w, h-1, " ") -gpu.setBackground(5, true) +gpu.setBackground(gc(5)) gpu.fill(1, 1, w, 1, " ") local title = "Zorya NEO Installer v2.0" local spos = (w/2)-(#title/2) -gpu.setForeground(1, true) +gpu.setForeground(gc(1)) gpu.set(spos, 1, title) -gpu.setForeground(1, true) -gpu.setBackground(5, true) +--[[ +gpu.setForeground(gc(1)) +gpu.setBackground(gc(5)) gpu.fill(6,6,w-12,h-12, " ") gpu.set(6,6,characters[1]) gpu.set(w-6,6,characters[2]) @@ -84,17 +95,39 @@ gpu.set(w-6,h-6,characters[6]) gpu.fill(7,6,w-13,1,characters[3]) gpu.fill(7,h-6,w-13,1,characters[3]) gpu.fill(6,7,1,h-13,characters[4]) -gpu.fill(w-6,7,1,h-13,characters[4]) -function setStatus(stat) - gpu.setBackground(5, true) - gpu.setForeground(1, true) +gpu.fill(w-6,7,1,h-13,characters[4])]] + +function drawBox(x, y, w, h) + gpu.setForeground(gc(1)) + gpu.setBackground(gc(5)) + gpu.fill(x,y,x+w,y+h, " ") + gpu.fill(x,y,w,1,characters[3]) + gpu.fill(x,y+h,w,1,characters[3]) + gpu.fill(x,y,1,h,characters[4]) + gpu.fill(x+w,y,1,h,characters[4]) + gpu.set(x,y,characters[1]) + gpu.set(x+w,y,characters[2]) + gpu.set(x,y+h,characters[5]) + gpu.set(x+w,y+h,characters[6]) +end + +function drawCenteredBox(x, y) + local marginx, marginy = (w-x)//2, (h-y)//2 + drawBox(marginx, marginy, x, y) +end + +function setStatus(stat, l1, l2) + l1 = l1 or "" + l2 = l2 or "" + gpu.setBackground(gc(5)) + gpu.setForeground(gc(1)) gpu.fill(7,(h/2)-3, w-13, 1, " ") gpu.set((w/2)-(#stat/2), (h/2)-3, stat) end function setBar(pos) - gpu.setBackground(6, true) + gpu.setBackground(gc(6)) gpu.fill(8, (h/2)+1, w-16, 1, " ") - gpu.setBackground(2, true) + gpu.setBackground(gc((usepal and 2) or 1)) gpu.fill(8, (h/2)+1, ((w-16)/100)*pos, 1, " ") computer.pullSignal(0) end @@ -103,6 +136,7 @@ function mkdir(fs, path) fs.makeDirectory(path) end +drawCenteredBox(w-8, h-8) setStatus("Setting up directories...") setBar(100)