1
0
mirror of https://github.com/Adorable-Catgirl/Zorya-NEO.git synced 2024-11-27 12:48:07 +11:00

one strange debugging session later, 2.0.0-rc1 should be ready.

This commit is contained in:
Jane Roxanne 2020-03-09 22:30:41 -05:00
parent a3f93518cc
commit f5c8ccd5a2
6 changed files with 94 additions and 8 deletions

View File

@ -10,6 +10,7 @@
{name="minitel", cat="net", path="lib/net_minitel.zy2l"}, {name="minitel", cat="net", path="lib/net_minitel.zy2l"},
--{name="vdev", cat="util", path="mods/util_vdev.zy2m"}, --{name="vdev", cat="util", path="mods/util_vdev.zy2m"},
{name="menu", cat="menu", path="mods/menu_classic.zy2m"}, {name="menu", cat="menu", path="mods/menu_classic.zy2m"},
{name="thd", cat="core", path="lib/thd.zy2l"}
--{name="vdevrt", cat="rtmod", path="mods/rtmod_vdevrt.zy2m"}, --{name="vdevrt", cat="rtmod", path="mods/rtmod_vdevrt.zy2m"},
--{name="tsukinet", cat="net", path="mods/net_tsukinet"}, --{name="tsukinet", cat="net", path="mods/net_tsukinet"},
--{name="biosemu", cat="loader", path="mods/loader_biosemu.zy2m", warning="warn_mod_biosemu"}, --{name="biosemu", cat="loader", path="mods/loader_biosemu.zy2m", warning="warn_mod_biosemu"},

92
lib/core_thd/init.lua Normal file
View File

@ -0,0 +1,92 @@
local thd = {}
local threads = {}
local idx = 1
local computer = computer
local unpack = unpack or table.unpack
local coroutine = coroutine
local c_create = coroutine.create
local c_yield = coroutine.yield
local c_resume = coroutine.resume
local c_status = coroutine.status
function thd.add(name, func)
local t = assert(c_create(func))
--component.proxy(component.list("sandbox")()).debug_log(name, t, func)
threads[#threads+1] = {name, t, {}, 0, ".+"}
threads[t] = threads[#threads]
end
local sigs = {}
local ps = computer.pullSignal
function thd.autosleep()
local msleep = math.huge
for i=1, #threads do
if (threads[i][4] and threads[i][4] < msleep) then
msleep = threads[i][4]
end
end
local rsleep = msleep-computer.uptime()
if (rsleep < 0 or #sigs > 0) then
rsleep = 0
end
local sig = {ps(rsleep)}
if (#sigs > 0) then
if (#sig > 0) then
sigs[#sigs+1] = sig
end
sig = sigs[1]
table.remove(sigs, 1)
end
return sig
end
local last_sig = {}
function thd.run()
last_sig = thd.autosleep()
for i=1, #threads do
if (threads[i][4] <= computer.uptime() or #last_sig > 0) then
if (c_status(threads[i][2]) ~= "running") then
local er, dl = c_resume(threads[i][2], unpack(last_sig))
if (not er) then error(threads[i][1]..": "..dl) end
if (dl == "k") then
threads[i][6] = true
end
dl = computer.uptime() + (dl or math.huge)
threads[i][4] = dl
sigs[#sigs+1] = {ps(0)}
end
end
end
local t = {}
for i=1, #threads do
local v = threads[i]
if (c_status(v[2]) ~= "dead" and not v[6]) then
t[#t+1] = v
t[v[2]] = v
end
end
threads = t
return #threads > 0
end
function thd.kill(i)
threads[i][6] = true
end
function thd.sched_end()
return #threads == idx
end
function thd.get_threads()
return threads
end
function computer.pullSignal(t)
return c_yield(t)
end
return thd

View File

@ -1,2 +1,2 @@
--#include "src/lzss.lua" --#include "src/lzss.lua"
return assert(load(lzss_decompress($[[luacomp src/zy-neo/zinit.lua 2>/dev/null | sed "s/\]\]/]\ ]/g" | lua5.3 utils/makezbios.lua ]]), "=bios.lua"))(lzss_decompress) return assert(load(lzss_decompress($[[luacomp src/zy-neo/zinit.lua -mluamin 2>/dev/null | sed "s/\]\]/]\ ]/g" | lua5.3 utils/makezbios.lua ]]), "=bios.lua"))(lzss_decompress)

View File

@ -8,7 +8,6 @@ end
function romfs.read(read, seek, close) function romfs.read(read, seek, close)
local sig = read(7) local sig = read(7)
utils.debug_log("SIGNATURE", sig, #sig)
assert(sig, "Read error!") assert(sig, "Read error!")
if sig ~= "romfs\1\0" then error(string.format("Invalid romfs (%.14x != %.14x)", string.unpack("i7", sig), string.unpack("i7", "romfs\1\0"))) end if sig ~= "romfs\1\0" then error(string.format("Invalid romfs (%.14x != %.14x)", string.unpack("i7", sig), string.unpack("i7", "romfs\1\0"))) end
local tbl = {} local tbl = {}
@ -19,21 +18,17 @@ function romfs.read(read, seek, close)
local fsize = readint(read, 2) local fsize = readint(read, 2)
local exec = read(1) local exec = read(1)
tbl[#tbl+1] = {name = name, size = fsize, exec = exec == "x", pos = seek(0)} tbl[#tbl+1] = {name = name, size = fsize, exec = exec == "x", pos = seek(0)}
utils.debug_log(name, fsize, exec)
seek(fsize) seek(fsize)
lname = name lname = name
end end
tbl[#tbl] = nil tbl[#tbl] = nil
utils.debug_log("ROMFS loaded!")
return setmetatable({tbl=tbl, read=read,seek=seek, close=close}, {__index=arc}) return setmetatable({tbl=tbl, read=read,seek=seek, close=close}, {__index=arc})
end end
function arc:fetch(path) function arc:fetch(path)
for i=1, #self.tbl do for i=1, #self.tbl do
if self.tbl[i].name == path then if self.tbl[i].name == path then
utils.debug_log("DEBUG", self.tbl[i].pos, self.tbl[i].size)
self.seek(self.tbl[i].pos-self.seek(0)) self.seek(self.tbl[i].pos-self.seek(0))
utils.debug_log("DEBUG2", self.seek(0))
return self.read(self.tbl[i].size) return self.read(self.tbl[i].size)
end end
end end

View File

@ -57,5 +57,4 @@ function utils.deepcopy(src, dest)
end end
return dest return dest
end end
utils.debug_log("Zorya NEO Started!")
builtins.utils = function() return utils end builtins.utils = function() return utils end

View File

@ -27,7 +27,6 @@ local function load_lua(src, ...)
if (src:sub(1, 4) == "\27ZLS") then if (src:sub(1, 4) == "\27ZLS") then
src = lzss_decompress(src:sub(5)) src = lzss_decompress(src:sub(5))
end end
log("DECOMPRESS", src)
return load(src, ...) return load(src, ...)
end end