diff --git a/.buildactions/00_setup.lua b/.buildactions/00_setup.lua
new file mode 100644
index 0000000..02c52ea
--- /dev/null
+++ b/.buildactions/00_setup.lua
@@ -0,0 +1,5 @@
+os.execute("mkdir -p pkg")
+os.execute("rm -rf pkg/*")
+
+os.execute("mkdir -p release")
+os.execute("rm -rf release/*")
diff --git a/.buildactions/01_velx.lua b/.buildactions/01_velx.lua
new file mode 100644
index 0000000..048a396
--- /dev/null
+++ b/.buildactions/01_velx.lua
@@ -0,0 +1,215 @@
+-- VELX builder
+
+--[[----------------------------------------------------------------------------
+ LZSS - encoder / decoder
+ This is free and unencumbered software released into the public domain.
+ Anyone is free to copy, modify, publish, use, compile, sell, or
+ distribute this software, either in source code form or as a compiled
+ binary, for any purpose, commercial or non-commercial, and by any
+ means.
+ In jurisdictions that recognize copyright laws, the author or authors
+ of this software dedicate any and all copyright interest in the
+ software to the public domain. We make this dedication for the benefit
+ of the public at large and to the detriment of our heirs and
+ successors. We intend this dedication to be an overt act of
+ relinquishment in perpetuity of all present and future rights to this
+ software under copyright law.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ For more information, please refer to
+--]]----------------------------------------------------------------------------
+--------------------------------------------------------------------------------
+local M = {}
+local string, table = string, table
+
+--------------------------------------------------------------------------------
+local POS_BITS = 12
+local LEN_BITS = 16 - POS_BITS
+local POS_SIZE = 1 << POS_BITS
+local LEN_SIZE = 1 << LEN_BITS
+local LEN_MIN = 3
+
+--------------------------------------------------------------------------------
+function M.compress(input)
+ local offset, output = 1, {}
+ local window = ''
+
+ local function search()
+ for i = LEN_SIZE + LEN_MIN - 1, LEN_MIN, -1 do
+ local str = string.sub(input, offset, offset + i - 1)
+ local pos = string.find(window, str, 1, true)
+ if pos then
+ return pos, str
+ end
+ end
+ end
+
+ while offset <= #input do
+ local flags, buffer = 0, {}
+
+ for i = 0, 7 do
+ if offset <= #input then
+ local pos, str = search()
+ if pos and #str >= LEN_MIN then
+ local tmp = ((pos - 1) << LEN_BITS) | (#str - LEN_MIN)
+ buffer[#buffer + 1] = string.pack('>I2', tmp)
+ else
+ flags = flags | (1 << i)
+ str = string.sub(input, offset, offset)
+ buffer[#buffer + 1] = str
+ end
+ window = string.sub(window .. str, -POS_SIZE)
+ offset = offset + #str
+ else
+ break
+ end
+ end
+
+ if #buffer > 0 then
+ output[#output + 1] = string.char(flags)
+ output[#output + 1] = table.concat(buffer)
+ end
+ end
+
+ return table.concat(output)
+end
+
+--------------------------------------------------------------------------------
+function M.decompress(input)
+ local offset, output = 1, {}
+ local window = ''
+
+ while offset <= #input do
+ local flags = string.byte(input, offset)
+ offset = offset + 1
+
+ for i = 1, 8 do
+ local str = nil
+ if (flags & 1) ~= 0 then
+ if offset <= #input then
+ str = string.sub(input, offset, offset)
+ offset = offset + 1
+ end
+ else
+ if offset + 1 <= #input then
+ local tmp = string.unpack('>I2', input, offset)
+ offset = offset + 2
+ local pos = (tmp >> LEN_BITS) + 1
+ local len = (tmp & (LEN_SIZE - 1)) + LEN_MIN
+ str = string.sub(window, pos, pos + len - 1)
+ end
+ end
+ flags = flags >> 1
+ if str then
+ output[#output + 1] = str
+ window = string.sub(window .. str, -POS_SIZE)
+ end
+ end
+ end
+
+ return table.concat(output)
+end
+
+
+local function struct(tbl)
+ local pat = tbl.endian or "="
+ local args = {}
+ for i=1, #tbl do
+ local a, b = pairs(tbl[i])
+ local k, v = a(b)
+ args[i] = k
+ pat = pat .. v
+ end
+ return setmetatable({}, {__call=function(_, arg)
+ --checkArg(1, arg, "string", "table")
+ if (type(arg) == "string") then
+ local sval = {string.unpack(pat, arg)}
+ local rtn = {}
+ for i=1, #args do
+ rtn[args[i]] = sval[i]
+ end
+ return rtn, sval[#sval]
+ elseif (type(arg) == "table") then
+ local sval = {}
+ for i=1, #args do
+ sval[i] = arg[args[i]]
+ end
+ return string.pack(pat, unpack(sval))
+ end
+ end, __len=function()
+ return string.packsize(pat)
+ end})
+end
+
+
+local velx_spec = struct {
+ endian = "<",
+ {magic="c5"},
+ {fver="B"},
+ {compression="B"},
+ {lver="B"},
+ {os="B"},
+ {arctype="c4"},
+ {psize="I3"},
+ {lsize="I3"},
+ {ssize="I3"},
+ {rsize="I4"}
+}
+
+local function velx_multistep(path, arcpath, args, steps)
+ local shell_args = ""
+ for k, v in pairs(args) do
+ if (k == "PWD") then
+ shell_args = "cd "..v.."; " .. shell_args
+ else
+ shell_args = shell_args .. k .. "=\"".. v .."\" "
+ end
+ end
+ steps.precomp()
+ local h = io.popen(shell_args.."luacomp "..path, "r")
+ local prog = h:read("*a")
+ h:close()
+ prog = steps.postcomp(prog)
+ steps.prearc()
+ local arc = ""
+ if arcpath then
+ h = io.popen("cd "..arcpath.."; find $".."(ls) -depth | tsar -o", "r")
+ arc = h:read("*a")
+ h:close()
+ steps.postarc()
+ end
+ if (not args.noz) then
+ steps.prez()
+ prog = M.compress(prog)
+ steps.postz()
+ end
+ local header = velx_spec({
+ magic = "\27VelX",
+ compression = (args.noz and 0) or 1,
+ lver = 0x53,
+ fver = 1,
+ os = 0xDA, --da, comrade
+ psize = #prog,
+ lsize=0,
+ ssize=0,
+ rsize=#arc,
+ arctype=(arcpath and "tsar") or ""
+ })
+ return header .. prog .. arc
+end
+
+local function velx(path, arcpath, args)
+ return velx_multistep(path, arcpath, args, {
+ precomp = function()end,
+ postcomp = function(prog) return prog end,
+ prearc = function()end,
+ postarc = function()end,
+ prez = function()end,
+ postz = function()end,
+ })
+end
\ No newline at end of file
diff --git a/.buildactions/10_bios.lua b/.buildactions/10_bios.lua
new file mode 100644
index 0000000..11c99d6
--- /dev/null
+++ b/.buildactions/10_bios.lua
@@ -0,0 +1,48 @@
+local function make_platform(plat)
+ os.execute("mkdir -p pkg/bios")
+ print("Making "..plat..".bios")
+ os.execute("luacomp src/loader.lua -O pkg/bios/"..plat..".bios")
+ --os.execute("ZY_PLATFORM="..plat.." luacomp src/loader.lua -O pkg/bios/"..plat..".bios")
+ print("ZY_PLATFORM="..plat.."luacomp src/loader.lua -O pkg/bios/"..plat..".bios")
+ print("[[ $".."(stat --printf=%s pkg/bios/"..plat..".bios) > 4096 ]]")
+ if (os.execute("[[ $".."(stat --printf=%s pkg/bios/"..plat..".bios) > 4096 ]]")) then
+ io.stderr:write("WARNING: "..plat.." bios is over 4KiB!\n")
+ end
+end
+
+local function mkplat(plat)
+ local h = io.popen("luacomp src/loader.lua")
+ local loader = h:read("*a")
+ h:close()
+ local h = io.popen("ZY_PLATFORM="..plat.." luacomp src/zy-neo/zinit.lua -mluamin | lua5.3 utils/makezbios.lua")
+ local dat = h:read("*a")
+ h:close()
+ os.execute("mkdir -p pkg/bios")
+ local h = io.open("pkg/bios/"..plat..".bios", "wb")
+ h:write(string.format(loader, dat))
+ h:close()
+ if (os.execute("[[ $".."(stat --printf=%s pkg/bios/"..plat..".bios) > 4096 ]]")) then
+ io.stderr:write("WARNING: "..plat.." bios is over 4KiB!\n")
+ end
+end
+
+function actions.managed_bios()
+ mkplat("managed")
+end
+
+function actions.initramfs_bios()
+ mkplat("initramfs")
+end
+
+function actions.prom_bios()
+ mkplat("prom")
+end
+
+function actions.osdi_bios()
+ mkplat("osdi")
+end
+
+actions[#actions+1] = "managed_bios"
+actions[#actions+1] = "initramfs_bios"
+actions[#actions+1] = "prom_bios"
+actions[#actions+1] = "osdi_bios"
\ No newline at end of file
diff --git a/.buildactions/11_modules.lua b/.buildactions/11_modules.lua
new file mode 100644
index 0000000..894c501
--- /dev/null
+++ b/.buildactions/11_modules.lua
@@ -0,0 +1,31 @@
+function make_module(mod)
+ os.execute("mkdir -p pkg/mods")
+ print("MOD", mod)
+ local arc = false
+ if (os.execute("[[ -d mods/"..mod.."/arc ]]")) then
+ arc = "mods/"..mod.."/arc"
+ end
+ local h = io.open("pkg/mods/"..mod..".velx", "w")
+ h:write(velx("init.lua", arc, {
+ PWD = os.getenv("PWD").."/mods/"..mod
+ }))
+ h:close()
+end
+
+local mods = {}
+
+local h = io.popen("ls mods", "r")
+for line in h:lines() do
+ actions["mod_"..line] = function()
+ make_module(line)
+ end
+ mods[#mods+1] = "mod_"..line
+end
+
+function actions.allmods()
+ for i=1, #mods do
+ actions[mods[i]]()
+ end
+end
+
+actions[#actions+1] = "allmods"
\ No newline at end of file
diff --git a/.buildactions/12_libraries.lua b/.buildactions/12_libraries.lua
new file mode 100644
index 0000000..714f2c3
--- /dev/null
+++ b/.buildactions/12_libraries.lua
@@ -0,0 +1,27 @@
+function make_library(mod)
+ os.execute("mkdir -p pkg/lib")
+ print("LIB", mod)
+ local h = io.open("pkg/lib/"..mod..".velx", "w")
+ h:write(velx("init.lua", false, {
+ PWD = os.getenv("PWD").."/lib/"..mod
+ }))
+ h:close()
+end
+
+local libs = {}
+
+local h = io.popen("ls lib", "r")
+for line in h:lines() do
+ actions["lib_"..line] = function()
+ make_library(line)
+ end
+ libs[#libs+1] = "lib_"..line
+end
+
+function actions.alllibs()
+ for i=1, #libs do
+ actions[libs[i]]()
+ end
+end
+
+actions[#actions+1] = "alllibs"
\ No newline at end of file
diff --git a/.buildactions/20_pkg.lua b/.buildactions/20_pkg.lua
new file mode 100644
index 0000000..e9f64bb
--- /dev/null
+++ b/.buildactions/20_pkg.lua
@@ -0,0 +1,5 @@
+function actions.makepkg()
+ os.execute("cd pkg; find bios lib mods -depth | lua ../utils/make_tsar.lua > ../release/zorya-neo-update.tsar")
+end
+
+actions[#actions+1] = "makepkg"
\ No newline at end of file
diff --git a/.buildactions/30_selfextract.lua b/.buildactions/30_selfextract.lua
new file mode 100644
index 0000000..5dbd657
--- /dev/null
+++ b/.buildactions/30_selfextract.lua
@@ -0,0 +1,4 @@
+function makeselfextract(indir, outfile)
+ local cwd = os.getenv("PWD")
+ os.execute("cd "..indir.."; find * -depth | lua "..cwd.."/utils/make_tsar.lua | lua "..cwd.."/utils/mkselfextract.lua > "..cwd.."/"..outfile)
+end
\ No newline at end of file
diff --git a/.buildactions/31_installer.lua b/.buildactions/31_installer.lua
new file mode 100644
index 0000000..a15c3a0
--- /dev/null
+++ b/.buildactions/31_installer.lua
@@ -0,0 +1,7 @@
+function actions.installer()
+ os.execute("cp utils/ser.lua pkg/init.lua")
+ os.execute("cp -r installer_dat pkg")
+ makeselfextract("pkg", "release/zorya-neo-installer.lua")
+end
+
+actions[#actions+1] = "installer"
\ No newline at end of file
diff --git a/.buildactions/32_utils.lua b/.buildactions/32_utils.lua
new file mode 100644
index 0000000..f203ade
--- /dev/null
+++ b/.buildactions/32_utils.lua
@@ -0,0 +1,5 @@
+function actions.utils()
+ makeselfextract("util", "release/zorya-neo-utils-installer.lua")
+end
+
+actions[#actions+1] = "utils"
\ No newline at end of file
diff --git a/.buildactions/ff_clean.lua b/.buildactions/ff_clean.lua
new file mode 100644
index 0000000..6cf7ace
--- /dev/null
+++ b/.buildactions/ff_clean.lua
@@ -0,0 +1,5 @@
+function actions.clean()
+ print("Cleaning up...")
+ --os.execute("rm -rf .docs")
+ --os.execute("rm -rf .ktmp")
+end
\ No newline at end of file
diff --git a/build.lua b/build.lua
new file mode 100644
index 0000000..a4f0656
--- /dev/null
+++ b/build.lua
@@ -0,0 +1,36 @@
+local actions = {}
+
+@[[local h = io.popen("ls .buildactions", "r")
+for line in h:lines() do]]
+--#include @[{".buildactions/"..line}]
+@[[end]]
+
+--[[function actions.debug()
+ actions.kernel(true)
+ actions.crescent()
+ actions.velxboot()
+ actions.clean()
+end]]
+
+function actions.all()
+ for i=1, #actions do
+ actions[actions[i]]()
+ end
+end
+
+function actions.list()
+ for k, v in pairs(actions) do
+ if type(k) == "string" then
+ io.stdout:write(k, " ")
+ end
+ end
+ print("")
+end
+
+if not arg[1] then
+ arg[1] = "all"
+end
+
+actions[arg[1]]()
+
+print("Build complete.")
\ No newline at end of file
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..222171f
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+luacomp build.lua 2>/dev/null | lua - $@
\ No newline at end of file
diff --git a/installer_dat/bios_list.lua b/installer_dat/bios_list.lua
index 041481f..56fbf03 100644
--- a/installer_dat/bios_list.lua
+++ b/installer_dat/bios_list.lua
@@ -1,7 +1,8 @@
{
{type="managed", path="bios/managed.bios"},
{type="initramfs", path="bios/initramfs.bios"},
- --{type="osdi", path="bios/osdi.bios"},
+ {type="osdi", path="bios/osdi.bios"},
+ {type="prom", path="bios/prom.bios"}
--{type="romfs", path="bios/romfs.bios"},
--{type="proxfs", path="bios/proxfs.bios"}
}
\ No newline at end of file
diff --git a/installer_dat/lang/en_US.lua b/installer_dat/lang/en_US.lua
index 5ecac07..e69de29 100644
--- a/installer_dat/lang/en_US.lua
+++ b/installer_dat/lang/en_US.lua
@@ -1,28 +0,0 @@
-{
- ["bios_managed_name"] = "Standard Zorya BIOS",
- ["bios_managed_desc"] = "Zorya BIOS boots off of a managed drive.",
- ["bios_osdi_name"] = "OSDI Zorya BIOS",
- ["bios_osdi_desc"] = "Zorya BIOS boots off of an OSDI BOOTCODE partition.",
- ["bios_romfs_name"] = "ROMFS Zorya BIOS",
- ["bios_romfs_desc"] = "Zorya BIOS boots off of a ROMFS formatted EEPROM card.",
- ["bios_proxfs_name"] = "ProximaFS Zorya BIOS",
- ["bios_proxfs_desc"] = "placeholder",
- ["mod_util_zlan_name"] = "Zorya LAN",
- ["mod_util_zlan_desc"] = "Provides the ability to use the Zorya LAN Boot (zlan) protocol.",
- ["mod_loader_openos_name"] = "OpenOS",
- ["mod_loader_openos_desc"] = "Provides a utility to allow for BIOS threads to work while using OpenOS.",
- ["mod_loader_tsuki_name"] = "Tsuki",
- ["mod_loader_tsuki_desc"] = "Allows for easier loading of the Tsuki kernel.",
- ["mod_util_cpio_name"] = "cpio",
- ["mod_util_cpio_desc"] = "Allows the reading of CPIO archives",
- ["mod_util_frequest_name"] = "frequest",
- ["mod_util_frequest_desc"] = "Allows fetching of files over frequest.",
- ["mod_net_minitel_name"] = "Minitel",
- ["mod_net_minitel_desc"] = "Allows use of Minitel in Zorya.",
- ["cat_bios"] = "BIOS",
- ["cat_util"] = "Utilities",
- ["cat_loader"] = "Loaders",
- ["cat_rtmod"] = "Runtime modifiers",
- ["cat_net"] = "Networking",
- ["cat_vdev"] = "Virtual Devices"
-}
\ No newline at end of file
diff --git a/installer_dat/package_list.lua b/installer_dat/package_list.lua
index 919bd9e..7396419 100644
--- a/installer_dat/package_list.lua
+++ b/installer_dat/package_list.lua
@@ -1,25 +1,25 @@
{
- {name="zlan", cat="util", path="lib/util_zlan.zy2l"},
- {name="cpio", cat="util", path="lib/util_cpio.zy2l"},
- {name="urf", cat="util", path="lib/util_urf.zy2l"},
- {name="vcomponent", cat="util", path="lib/util_vcomponent.zy2l"},
- {name="oefiv2", cat="util", path="mods/util_oefiv2.zy2m"},
- {name="oefiv1", cat="util", path="mods/util_oefiv1.zy2m"},
- {name="openos", cat="loader", path="mods/loader_openos.zy2m"},
- {name="fuchas", cat="loader", path="mods/loader_fuchas.zy2m"},
- {name="vbios", cat="vdev", path="mods/vdev_vbios.zy2m"},
- {name="biosdev", cat="vdev", path="mods/vdev_biosdev.zy2m"},
- {name="searchpaths", cat="util", path="mods/util_searchpaths.zy2m"},
- {name="vfs", cat="core", path="mods/vfs.zy2m"},
+ {name="zlan", cat="util", path="lib/util_zlan.velx"},
+ {name="cpio", cat="util", path="lib/util_cpio.velx"},
+ {name="urf", cat="util", path="lib/util_urf.velx"},
+ {name="vcomponent", cat="util", path="lib/util_vcomponent.velx"},
+ {name="oefiv2", cat="util", path="mods/util_oefiv2.velx"},
+ {name="oefiv1", cat="util", path="mods/util_oefiv1.velx"},
+ {name="openos", cat="loader", path="mods/loader_openos.velx"},
+ {name="fuchas", cat="loader", path="mods/loader_fuchas.velx"},
+ {name="vbios", cat="vdev", path="mods/vdev_vbios.velx"},
+ {name="biosdev", cat="vdev", path="mods/vdev_biosdev.velx"},
+ {name="searchpaths", cat="util", path="mods/util_searchpaths.velx"},
+ {name="vfs", cat="core", path="mods/vfs.velx"},
--{name="tsuki", cat="loader", path="mods/loader_tsuki.zy2m"},
--{name="romfs", cat="util", path="mods/util_romfs.zy2m"},
- {name="cpio", cat="util", path="lib/util_cpio.zy2l"},
+ {name="cpio", cat="util", path="lib/util_cpio.velx"},
--{name="frequest", cat="util", path="mods/util_frequest.zy2m"},
--{name="loadfile", cat="loader", path="mods/loader_loadfile.zy2m"},
- {name="minitel", cat="net", path="lib/net_minitel.zy2l"},
+ {name="minitel", cat="net", path="lib/net_minitel.velx"},
--{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="classic", cat="menu", path="mods/menu_classic.velx"},
+ {name="luaconsole", cat="util", path="mods/util_luaconsole.velx"},
--{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/lib/fs_arcfs/init.lua b/lib/fs_arcfs/init.lua
index 6a222ed..adab888 100644
--- a/lib/fs_arcfs/init.lua
+++ b/lib/fs_arcfs/init.lua
@@ -41,7 +41,7 @@ function arcfs.make(arc)
end
function proxy.size(path)
-
+
end
function proxy.read(hand, count)
diff --git a/lib/net_minitel/microtel/microtel-3.lua b/lib/net_minitel/microtel/microtel-3.lua
index ef783e0..1913c11 100644
--- a/lib/net_minitel/microtel/microtel-3.lua
+++ b/lib/net_minitel/microtel/microtel-3.lua
@@ -49,9 +49,10 @@ local function checkCache(packetID)
end
--local realComputerPullSignal = computer.pullSignal
+local ps = computer.pullSignal
thd.add("minitel_handler", function()
while true do
- local eventTab = {computer.pullSignal(0)}
+ local eventTab = {ps(0)}
for k,v in pairs(net.hook) do
pcall(v,table.unpack(eventTab))
end
diff --git a/mods/loader_openos/init.lua b/mods/loader_openos/init.lua
index 9599ebe..185e515 100644
--- a/mods/loader_openos/init.lua
+++ b/mods/loader_openos/init.lua
@@ -1,8 +1,20 @@
local zy = krequire("zorya")
--zy.loadmod("vdev_biosdev")
local utils = krequire("utils")
+local thd = krequire("thd")
--local vdev = krequire("zorya").loadmod("util_vdev")
local vdev = krequire("util_vcomponent")
+local function proxytable(t)
+ return setmetatable({}, {__index=function(self, i)
+ if (type(t[i]) == "table") then
+ self[i] = proxytable(t[i])
+ return rawget(self, i)
+ else
+ return t[i]
+ end
+ end})
+end
+local openos_count = 0
return function(addr)
local fs = component.proxy(addr)
--vdev.overwrite(_G)
@@ -16,10 +28,21 @@ return function(addr)
env.krequire = nil]]
--vdev.install(env)
--log(env, env.computer, env.computer.getBootAddress, env.computer.getBootAddress())
- function computer.getBootAddress()
- return addr
+-- local env = proxytable(_G)
+ thd.add("openos$"..openos_count, function()
+ local env = utils.make_env()
+ function env.computer.getBootAddress()
+ return addr
+ end
+ function env.computer.setBootAddress()end
+ local old_dl = utils.debug_log
+ load(utils.readfile(fs.address, fs.open("init.lua")), "=init.lua", "t", env)()
+ computer.pushSignal("openos_dead")
+ end)
+ while true do
+ if computer.pullSignal() == "openos_dead" then
+ utils.debug_log("Got signal.")
+ break
+ end
end
- function computer.setBootAddress()end
- local old_dl = utils.debug_log
- load(utils.readfile(fs.address, fs.open("init.lua")), "=init.lua", "t", env)()
end
\ No newline at end of file
diff --git a/mods/util_luaconsole/arc/bin/boot.lua b/mods/util_luaconsole/arc/bin/boot.lua
new file mode 100644
index 0000000..05b02e4
--- /dev/null
+++ b/mods/util_luaconsole/arc/bin/boot.lua
@@ -0,0 +1,5 @@
+local arg = ...
+if (arg == "") then
+ arg = "init.lua"
+end
+load_exec(arg)()
\ No newline at end of file
diff --git a/mods/util_luaconsole/arc/bin/download-recovery-env.lua b/mods/util_luaconsole/arc/bin/download-recovery-env.lua
new file mode 100644
index 0000000..cfee2fb
--- /dev/null
+++ b/mods/util_luaconsole/arc/bin/download-recovery-env.lua
@@ -0,0 +1,105 @@
+local inet = component.list("internet")()
+if not inet then
+ tty.setcolor(0x4)
+ print("internet card not found.")
+ return 1
+end
+
+inet = component.proxy(inet)
+
+print("connecting...")
+local hand, res = inet.request("https://git.shadowkat.net/sam/OC-PsychOS2/raw/branch/master/psychos.tsar")
+if not hand then
+ tty.setcolor(0x4)
+ print(res)
+ return 1
+end
+local fs = component.proxy(computer.tmpAddress())
+_DRIVE = computer.tmpAddress()
+
+local magic = 0x5f7d
+local magic_rev = 0x7d5f
+local header_fmt = "I2I2I2I2I2I6I6"
+local en = string.unpack("=I2", string.char(0x7d, 0x5f)) == magic -- true = LE, false = BE
+local function get_end(e)
+ return (e and "<") or ">"
+end
+local function read_header(dat)
+ local e = get_end(en)
+ local m = string.unpack(e.."I2", dat)
+ if m ~= magic and m ~= magic_rev then return nil, string.format("bad magic (%.4x)", m) end
+ if m ~= magic then
+ e = get_end(not en)
+ end
+ local ent = {}
+ ent.magic, ent.namesize, ent.mode, ent.uid, ent.gid, ent.filesize, ent.mtime = string.unpack(e..header_fmt, dat)
+ return ent
+end
+
+local spin = {"|", "/", "-", "\\"}
+
+local spinv = 0
+
+local function getspin()
+ local c = spin[spinv + 1]
+ spinv = (spinv + 1) & 3
+ return c
+end
+
+tty.write("downloading psychos.tsar... "..getspin())
+local x, y = tty.getcursor()
+tty.setcursor(x-1, y)
+local buf = ""
+local lc = ""
+
+while true do
+ tty.setcursor(x-1, y)
+ tty.write(getspin())
+ lc, res = hand.read()
+ if not lc and res then
+ tty.setcolor(0x4)
+ print(res)
+ return 1
+ end
+ buf = buf .. (lc or "")
+ if not lc then
+ break
+ elseif (lc == "") then
+ computer.pullSignal(0)
+ end
+end
+hand.close()
+
+print("")
+print(#buf)
+print("unpacking... "..getspin())
+x, y = tty.getcursor()
+tty.setcursor(x-1, y)
+local pos = 1
+local function read(a)
+ local dat = buf:sub(pos, pos+a-1)
+ pos = pos + a
+ return dat
+end
+local function seek(a)
+ pos = pos + a
+ return pos
+end
+while true do
+ tty.setcursor(x-1, y)
+ tty.write(getspin())
+ local header = read_header(read(string.packsize(header_fmt)))
+ local fn = read(header.namesize)
+ seek(header.namesize & 1)
+ if (fn == "TRAILER!!!") then break end
+ if (header.mode & 32768 > 0) then
+ local path = fn:match("^(.+)/.+%..+$")
+ if path then fs.makeDirectory(path) end
+ local h = fs.open(fn, "w")
+ fs.write(h, read(header.filesize))
+ fs.close(h)
+ seek(header.filesize & 1)
+ end
+end
+tty.setcolor(0x6)
+print("run $boot to start the recovery enviroment")
\ No newline at end of file
diff --git a/mods/util_luaconsole/arc/bin/help.lua b/mods/util_luaconsole/arc/bin/help.lua
new file mode 100644
index 0000000..fda2481
--- /dev/null
+++ b/mods/util_luaconsole/arc/bin/help.lua
@@ -0,0 +1,11 @@
+print("$boot [file] - Loads a Lua or a BIOS or Zorya VELX file. Defaults to init.lua.")
+print("$download-recovery-env - Downloads a tsar with PsychOS on it and boots into it.")
+print("$help - Prints this")
+print("$kill [thread name] - Kills a thread")
+print("$ls - Lists files if a root is set, lists filesystems otherwise.")
+print("$lsfs - Lists filesystems.")
+print("$lsthd - Lists threads.")
+print("$reboot - Reboots the computer.")
+print("$root [uuid part] - Sets the root (_DRIVE variable). Will autocomplete.")
+print("$shutdown - Shuts down the computer.")
+print("$start [file] - Starts a Lua file or Zorya VELX in the background.")
\ No newline at end of file
diff --git a/mods/util_luaconsole/arc/bin/kill.lua b/mods/util_luaconsole/arc/bin/kill.lua
new file mode 100644
index 0000000..18b3416
--- /dev/null
+++ b/mods/util_luaconsole/arc/bin/kill.lua
@@ -0,0 +1,9 @@
+local thd = krequire("thd")
+local threads = thd.get_threads()
+local n = ...
+for i=1, #threads do
+ if (threads[i][1] == n) then
+ thd.kill(i)
+ print("killed "..n)
+ end
+end
\ No newline at end of file
diff --git a/mods/util_luaconsole/arc/bin/ls.lua b/mods/util_luaconsole/arc/bin/ls.lua
new file mode 100644
index 0000000..7780a0a
--- /dev/null
+++ b/mods/util_luaconsole/arc/bin/ls.lua
@@ -0,0 +1,11 @@
+local arg = ...
+if not _DRIVE then
+ for d in component.list("filesystem") do
+ print(d)
+ end
+else
+ local t = component.invoke(_DRIVE, "list", arg)
+ for i=1, #t do
+ print(t[i])
+ end
+end
\ No newline at end of file
diff --git a/mods/util_luaconsole/arc/bin/lsfs.lua b/mods/util_luaconsole/arc/bin/lsfs.lua
new file mode 100644
index 0000000..62c7e2d
--- /dev/null
+++ b/mods/util_luaconsole/arc/bin/lsfs.lua
@@ -0,0 +1,3 @@
+for d in component.list("filesystem") do
+ print(d)
+end
\ No newline at end of file
diff --git a/mods/util_luaconsole/arc/bin/lsthd.lua b/mods/util_luaconsole/arc/bin/lsthd.lua
new file mode 100644
index 0000000..8eb8acb
--- /dev/null
+++ b/mods/util_luaconsole/arc/bin/lsthd.lua
@@ -0,0 +1,4 @@
+local threads = krequire("thd").get_threads()
+for i=1, #threads do
+ print(threads[i][1])
+end
\ No newline at end of file
diff --git a/mods/util_luaconsole/arc/bin/reboot.lua b/mods/util_luaconsole/arc/bin/reboot.lua
new file mode 100644
index 0000000..1d60ba4
--- /dev/null
+++ b/mods/util_luaconsole/arc/bin/reboot.lua
@@ -0,0 +1 @@
+computer.shutdown(true)
\ No newline at end of file
diff --git a/mods/util_luaconsole/arc/bin/root.lua b/mods/util_luaconsole/arc/bin/root.lua
new file mode 100644
index 0000000..14682b3
--- /dev/null
+++ b/mods/util_luaconsole/arc/bin/root.lua
@@ -0,0 +1,6 @@
+local fs = ...
+for f in component.list("filesystem") do
+ if (f:sub(1, #fs) == fs) then
+ _DRIVE = f
+ end
+end
\ No newline at end of file
diff --git a/mods/util_luaconsole/arc/bin/shutdown.lua b/mods/util_luaconsole/arc/bin/shutdown.lua
new file mode 100644
index 0000000..969b7c3
--- /dev/null
+++ b/mods/util_luaconsole/arc/bin/shutdown.lua
@@ -0,0 +1 @@
+computer.shutdown()
\ No newline at end of file
diff --git a/mods/util_luaconsole/arc/bin/start.lua b/mods/util_luaconsole/arc/bin/start.lua
new file mode 100644
index 0000000..27179c1
--- /dev/null
+++ b/mods/util_luaconsole/arc/bin/start.lua
@@ -0,0 +1,7 @@
+local thd = krequire("thd")
+local utils = krequire("utils")
+local arg = ...
+local name = arg:match("/(.+%..+)^") or arg
+thd.add(name, function()
+ load_exec(arg)()
+end)
\ No newline at end of file
diff --git a/mods/util_luaconsole/arc/info.txt b/mods/util_luaconsole/arc/info.txt
new file mode 100644
index 0000000..e69de29
diff --git a/mods/util_luaconsole/init.lua b/mods/util_luaconsole/init.lua
index 13f6ea6..7bba6ed 100644
--- a/mods/util_luaconsole/init.lua
+++ b/mods/util_luaconsole/init.lua
@@ -1,4 +1,14 @@
+local utils = krequire("utils")
--#include "tty.lua"
+--#include "velx.lua"
+--#include "load.lua"
+
+function _runcmd(cmd)
+ local rcmd = cmd:sub(1, (cmd:find(" ") or (#cmd+1))-1)
+ local script = _ARCHIVE:fetch("bin/"..rcmd..".lua")
+ load(script, "=bin/"..rcmd..".lua", "t", _G)(cmd:sub(#rcmd+1):gsub("^%s+", ""))
+end
+
return function(autorun)
local keys = {
lcontrol = 0x1D,
@@ -37,7 +47,10 @@ return function(autorun)
print = nil
end
if (autorun) then
- load(autorun)()
+ local c = load(autorun)
+ if c then
+ pcall(c)
+ end
end
tty.print("")
tty.setcolor(2)
@@ -70,6 +83,8 @@ return function(autorun)
elseif (sig[4] == keys.enter) then
if (buffer:sub(1,1) == "=") then
buffer = "return "..buffer:sub(2)
+ elseif (buffer:sub(1,1) == "$") then
+ buffer = "return _runcmd(\""..buffer:sub(2).."\")"
end
local s, e = load(buffer)
local x, y = tty.getcursor()
@@ -92,7 +107,7 @@ return function(autorun)
end)
end
tty.setcolor(2)
- tty.write("boot> ")
+ tty.write(((_DRIVE and _DRIVE:sub(1, 4)) or "boot").."> ")
tty.setcolor(0xF0)
tty.write(" ")
tty.setcolor(0xF)
diff --git a/mods/util_luaconsole/load.lua b/mods/util_luaconsole/load.lua
new file mode 100644
index 0000000..7ae9b27
--- /dev/null
+++ b/mods/util_luaconsole/load.lua
@@ -0,0 +1,40 @@
+function load_exec(path)
+ if not _DRIVE then
+ tty.setcolor(0x4)
+ print("need to set root")
+ end
+ local env = utils.make_env()
+ function env.computer.getBootAddress()
+ return _DRIVE
+ end
+ function env.computer.setBootAddress()end
+ local ext = path:match("%.(.+)$")
+ if (ext == "lua") then
+ return load(krequire("utils").readfile(_DRIVE, component.invoke(_DRIVE, "open", path)), "="..path, "t", env)
+ elseif (ext == "velx") then
+ local fs = component.proxy(_DRIVE)
+ local h = fs.open(path)
+ local v, e = load_velx(function(a)
+ local c = ""
+ local d
+ while a > 0 do
+ d = fs.read(h, a)
+ a = a - #d
+ c = c .. d
+ end
+ return c
+ end, function(a)
+ return fs.seek(h, "cur", a)
+ end, function()
+ fs.close(h)
+ end, path)
+ if not v then
+ tty.setcolor(0x4)
+ print(e)
+ end
+ return v
+ else
+ tty.setcolor(0x4)
+ print("invalid executable format "..ext)
+ end
+end
\ No newline at end of file
diff --git a/mods/util_luaconsole/tty.lua b/mods/util_luaconsole/tty.lua
index 9517180..b2eb8a7 100644
--- a/mods/util_luaconsole/tty.lua
+++ b/mods/util_luaconsole/tty.lua
@@ -2,6 +2,9 @@
tty = {}
do
local gpu = component.proxy(component.list("gpu")())
+ if not gpu.getScreen() then
+ gpu.bind(component.list("screen")())
+ end
local gfg = -1
local gbg = -1
diff --git a/mods/util_luaconsole/velx.lua b/mods/util_luaconsole/velx.lua
new file mode 100644
index 0000000..b9a3c94
--- /dev/null
+++ b/mods/util_luaconsole/velx.lua
@@ -0,0 +1,30 @@
+function load_velx(read, seek, close, name)
+ -- Load a VELX format library.
+ local magic, fver, compression, lver, osid, arctype, psize, lsize, ssize, rsize = string.unpack(velx_header, read(string.packsize(velx_header)))
+ if (magic ~= "\27VelX") then
+ return nil, "bad magic ("..magic..")"
+ end
+ if (osid & 0x7F ~= 0x5A or osid & 0x7F ~= 0x7F) then
+ return nil, string.format("wrong os (%x)", osid & 0x7F)
+ end
+ if (compression > 1) then
+ return nil, "bad compression"
+ end
+ if ((arctype ~= "\0\0\0\0" and (arctype ~= "tsar" and osid & 0x7F == 0x5A))) then
+ return nil, "bad arctype ("..arctype..")"
+ end
+ if (fver ~= 1) then
+ return nil, "wrong version"
+ end
+ local prog = read(psize)
+ if (compression == 1) then
+ prog = lzss_decompress(prog)
+ end
+ seek(lsize+ssize)
+ local env = {}
+ if (arctype == "tsar") then
+ env._ARCHIVE = tsar.read(read, seek, close)
+ end
+ setmetatable(env, {__index=_G, __newindex=function(_, i, v) _G[i] = v end})
+ return load(prog, "="..(name or "(loaded velx)"), "t", env)
+end
\ No newline at end of file
diff --git a/mods/util_oefiv1/init.lua b/mods/util_oefiv1/init.lua
index 1a91f11..f2ead6e 100644
--- a/mods/util_oefiv1/init.lua
+++ b/mods/util_oefiv1/init.lua
@@ -8,8 +8,7 @@ local oefi = {}
local function load_oefi(drive, path, uuid)
local oefi_env = {}
- local env = {}
- utils.deepcopy(_G, env)
+ local env = utils.make_env()
env.krequire = nil
env._BIOS = nil
env._ZVER = nil
diff --git a/mods/util_oefiv2/init.lua b/mods/util_oefiv2/init.lua
index d11f323..307c735 100644
--- a/mods/util_oefiv2/init.lua
+++ b/mods/util_oefiv2/init.lua
@@ -21,8 +21,7 @@ local function load_oefi_env(file, envx)
arc = cpio.read(envx.fs, file)
end
local oefi_env = {}
- local env = {}
- utils.deepcopy(_G, env)
+ local env = utils.make_env()
env.krequire = nil
env._BIOS = nil
env._ZVER = nil
@@ -116,8 +115,7 @@ end
function ext.ZyNeo_GetOEFIEnv(drive, arc)
local oefi_env = {}
- local env = {}
- utils.deepcopy(_G, env)
+ local env = utils.make_env()
env.krequire = nil
env._BIOS = nil
env._ZVER = nil
diff --git a/mods/vdev_vbios/machine.lua b/mods/vdev_vbios/machine.lua
index 2865c4e..5fc6073 100644
--- a/mods/vdev_vbios/machine.lua
+++ b/mods/vdev_vbios/machine.lua
@@ -3,10 +3,8 @@
local computer = computer
xpcall(function()
utils.debug_log("Copying env...")
- local env = utils.deepcopy(_G)
+ local env = utils.make_env()
utils.debug_log("Coppied env.")
- env._G = env
- env._ENV = env
env.krequire = nil
env._BIOS = nil
env._ZVSTR = nil
diff --git a/src/loader.lua b/src/loader.lua
index 202d779..36b735b 100644
--- a/src/loader.lua
+++ b/src/loader.lua
@@ -1,2 +1,2 @@
--#include "src/lzss.lua"
-return assert(load(lzss_decompress($[[luacomp src/zy-neo/zinit.lua -mluamin 2>/dev/null | lua5.3 utils/makezbios.lua ]]), "=bios.lua"))(lzss_decompress)
\ No newline at end of file
+return assert(load(lzss_decompress(%s), "=bios.lua"))(lzss_decompress)
\ No newline at end of file
diff --git a/src/zy-neo/builtins/init_initramfs/init.lua b/src/zy-neo/builtins/init_initramfs/init.lua
index f80fdc4..7159fb1 100644
--- a/src/zy-neo/builtins/init_initramfs/init.lua
+++ b/src/zy-neo/builtins/init_initramfs/init.lua
@@ -1,5 +1,5 @@
_ZLOADER = "initramfs"
-local readfile=function(f,h)
+--[[local readfile=function(f,h)
local b=""
local d,r=f.read(h,math.huge)
if not d and r then error(r)end
@@ -11,19 +11,19 @@ local readfile=function(f,h)
end
f.close(h)
return b
-end
+end]]
local bfs = {}
-local cfg = component.proxy(component.list("eeprom")()).getData()
+local cfg = cproxy(clist("eeprom")()).getData()
local baddr = cfg:sub(1, 36)
-local bootfs = component.proxy(baddr)
+local bootfs = cproxy(baddr)
assert(bootfs.exists(".zy2/image.tsar"), "No boot image!")
local romfs_file = assert(bootfs.open(".zy2/image.tsar", "rb"))
-local rfs = readfile(bootfs, romfs_file)
+local rfs = utils.readfile(bootfs, romfs_file)
--[[local romfs_dev = tsar.read(function(a)
local c = ""
@@ -59,9 +59,13 @@ function bfs.exists(path)
return romfs_dev:exists(path)
end
+function bfs.getstream(path)
+ return romfs_dev:stream(path)
+end
+
function bfs.getcfg()
local h = assert(bootfs.open(".zy2/cfg.lua", "r"))
- return readfile(bootfs, h)
+ return utils.readfile(bootfs, h)
end
bfs.addr = baddr
\ No newline at end of file
diff --git a/src/zy-neo/builtins/init_managed/init.lua b/src/zy-neo/builtins/init_managed/init.lua
index 2fef1fd..fb16636 100644
--- a/src/zy-neo/builtins/init_managed/init.lua
+++ b/src/zy-neo/builtins/init_managed/init.lua
@@ -1,5 +1,5 @@
_ZLOADER = "managed"
-local readfile=function(f,h)
+--[[local readfile=function(f,h)
local b=""
local d,r=f.read(h,math.huge)
if not d and r then error(r)end
@@ -11,14 +11,14 @@ local readfile=function(f,h)
end
f.close(h)
return b
-end
+end]]
local bfs = {}
-local cfg = component.proxy(component.list("eeprom")()).getData()
+local cfg = cproxy(clist("eeprom")()).getData()
local baddr = cfg:sub(1, 36)
-local bootfs = component.proxy(baddr)
+local bootfs = cproxy(baddr)
assert(bootfs.exists(".zy2/image.tsar"), "No boot image!")
@@ -47,9 +47,13 @@ function bfs.exists(path)
return romfs_dev:exists(path)
end
+function bfs.getstream(path)
+ return romfs_dev:stream(path)
+end
+
function bfs.getcfg()
local h = assert(bootfs.open(".zy2/cfg.lua", "r"))
- return readfile(bootfs, h)
+ return utils.readfile(bootfs, h)
end
bfs.addr = baddr
\ No newline at end of file
diff --git a/src/zy-neo/builtins/init_osdi/init.lua b/src/zy-neo/builtins/init_osdi/init.lua
index 64c1dd2..fb29920 100644
--- a/src/zy-neo/builtins/init_osdi/init.lua
+++ b/src/zy-neo/builtins/init_osdi/init.lua
@@ -1,38 +1,47 @@
-local osdi = {}
+local bfs = {}
-local function int(str)
- local t=0
- for i=1, #str do
- t = t | (str:byte(i) << ((i-1)*8))
- end
- return t
-end
+local cfg = cproxy(clist("eeprom")()).getData()
-local function get_part_info(meta, part)
- local info = meta:sub((part*32)+1, ((part+1)*32))
- local start = int(info:sub(1, 4))
- local size = int(info:sub(5, 8))
- local ptype = info:sub(9, 16)
- local flags = int(info:sub(17, 19))
- local label = info:sub(20):gsub("\0", "")
- return {start = start,
- size = size,
- ptype = ptype,
- flags = flags,
- label = label
- }
-end
+local baddr, part = cfg:sub(1, 36)
+local bootfs = cproxy(baddr)
-local function pad(str, len)
- return str .. string.rep(" ", len-#str)
-end
-
-function osdi.get_table(volume)
- local t = {}
- local meta = component.invoke(volume, "readSector", 1)
- for i=2, 16 do
- t[i-1] = get_part_info(meta, i)
+--find active partition
+local bs, p, t, ss = bootfs.readSector(1), "I4I4c8I3c13", {}
+for i=1, 15 do
+ t = {p:unpack(bs:sub((i*32)+1, (i+1)*32))}
+ if (t[4] & 0x200 and t[4] & 0x40) then
+ ss = t[1]
end
end
-return osdi
\ No newline at end of file
+local h = 1
+local romfs_dev = tsar.read(function(a)
+ local sz, c, st, p, d = math.ceil(a/512), "", (h//512), (h & 511)+1
+ for i=1, sz do
+ c = c .. bootfs.readSector(ss+i+st)
+ end
+ d = c:sub(p, p+a-1)
+ h = h+a
+ return d
+end, function(a)
+ h = h + a
+ return h
+end, function()
+
+end)
+
+function bfs.getfile(path)
+ return romfs_dev:fetch(path)
+end
+
+function bfs.exists(path)
+ return romfs_dev:exists(path)
+end
+
+function bfs.getstream(path)
+ return romfs_dev:stream(path)
+end
+
+function bfs.getcfg()
+ return romfs_dev:fetch(".zy2/cfg.lua")
+end
\ No newline at end of file
diff --git a/src/zy-neo/builtins/init_prom/init.lua b/src/zy-neo/builtins/init_prom/init.lua
new file mode 100644
index 0000000..263ba96
--- /dev/null
+++ b/src/zy-neo/builtins/init_prom/init.lua
@@ -0,0 +1,38 @@
+local bfs = {}
+
+local cfg = cproxy(clist("eeprom")()).getData()
+
+local baddr = cfg:sub(1, 36)
+local bootfs = cproxy(baddr)
+
+local h = 1
+local romfs_dev = tsar.read(function(a)
+ local sz, c, st, p, d = math.ceil(a/512), "", (h//512)+1, (h & 511)+1
+ for i=1, sz do
+ c = c .. bootfs.blockRead(i+st)
+ end
+ d = c:sub(p, p+a-1)
+ h = h+a
+ return d
+end, function(a)
+ h = h + a
+ return h
+end, function()
+
+end)
+
+function bfs.getfile(path)
+ return romfs_dev:fetch(path)
+end
+
+function bfs.exists(path)
+ return romfs_dev:exists(path)
+end
+
+function bfs.getstream(path)
+ return romfs_dev:stream(path)
+end
+
+function bfs.getcfg()
+ return romfs_dev:fetch(".zy2/cfg.lua")
+end
\ No newline at end of file
diff --git a/src/zy-neo/builtins/init_romfs/init.lua b/src/zy-neo/builtins/init_romfs/init.lua
deleted file mode 100644
index 57990bc..0000000
--- a/src/zy-neo/builtins/init_romfs/init.lua
+++ /dev/null
@@ -1,12 +0,0 @@
---#error "Not implemented."
-local rfs = {}
-
-local bfs = {}
-
-function bfs.getfile(path)
-
-end
-
-function bfs.exists(path)
-
-end
\ No newline at end of file
diff --git a/src/zy-neo/builtins/util_tsar.lua b/src/zy-neo/builtins/util_tsar.lua
index 9c3f0df..62a61ec 100644
--- a/src/zy-neo/builtins/util_tsar.lua
+++ b/src/zy-neo/builtins/util_tsar.lua
@@ -1,14 +1,14 @@
local magic = 0x5f7d
local magic_rev = 0x7d5f
local header_fmt = "I2I2I2I2I2I6I6"
-local en = string.unpack("=I2", string.char(0x7d, 0x5f)) == magic -- true = LE, false = BE
+local en = true
local function get_end(e)
return (e and "<") or ">"
end
local function read_header(dat)
local e = get_end(en)
local m = string.unpack(e.."I2", dat)
- if m ~= magic and m ~= magic_rev then return nil, "bad magic" end
+ if m ~= magic and m ~= magic_rev then return nil, string.format("bad magic (%.4x)", m) end
if m ~= magic then
e = get_end(not en)
end
@@ -49,20 +49,51 @@ function arc:list(path)
return ent
end
+function arc:stream(path)
+ for i=1, #self.tbl do
+ if (self.tbl[i].name == path and self.tbl[i].mode & 32768 > 0) then
+ local pos = 1
+ local function read(amt)
+ self.seek(self.tbl[i].pos-self.seek(0)+pos-1)
+ pos = pos + amt
+ return self.read(amt)
+ end
+ local function seek(amt)
+ pos = pos + amt
+ return pos
+ end
+ local function close()end
+ return read, seek, close
+ end
+ end
+ return nil, "file not found"
+end
+
function arc:close()
self.close()
end
+function arc:meta(path)
+ for i=1, #self.tbl do
+ if (self.tbl[i].name == path and self.tbl[i].mode & 32768 > 0) then
+ return self.tbl[i]
+ end
+ end
+ return nil, "file not found"
+end
+
+
return {
read = function(read, seek, close)
local tbl = {}
local lname = ""
while lname ~= "TRAILER!!!" do
local dat = read(22)
- local et = read_header(dat)
+ local et = assert(read_header(dat))
et.name = read(et.namesize)
et.pos = seek(et.namesize & 1)
- seek(et.filesize + (et.filesize & 1))
+ local t = (et.filesize & 1)
+ seek(et.filesize + t)
lname = et.name
if lname ~= "TRAILER!!!" then
tbl[#tbl+1] = et
diff --git a/src/zy-neo/utils.lua b/src/zy-neo/utils.lua
index a3c0e69..4e5cf3e 100644
--- a/src/zy-neo/utils.lua
+++ b/src/zy-neo/utils.lua
@@ -1,35 +1,36 @@
local utils = {}
-
function utils.debug_log(...)
- local sb = component.list("sandbox")() or component.list("ocemu")()
- if (sb) then component.invoke(sb, "log", ...) end
+ local sb = clist("sandbox")() or clist("ocemu")()
+ if (sb) then cinvoke(sb, "log", ...) end
end
-function utils.baddr(address)
+--[[function utils.baddr(address)
local address = address:gsub("-", "", true)
local b = ""
for i=1, #address, 2 do
b = b .. string.char(tonumber(address:sub(i, i+1), 16))
end
return b
-end
+end]]
function utils.readfile(f,h)
local b=""
- local d,r=component.invoke(f,"read",h,math.huge)
+ local d,r=cinvoke(f,"read",h,math.huge)
if not d and r then error(r)end
b=d
while d do
- local d,r=component.invoke(f,"read",h,math.huge)
+ local d,r=cinvoke(f,"read",h,math.huge)
b=b..(d or "")
if(not d)then break end
end
- component.invoke(f,"close",h)
+ cinvoke(f,"close",h)
return b
end
utils.load_lua = load_lua
+utils.lzss_decompress = lzss_decompress
+
-- Hell yeah, deepcopy time.
function utils.deepcopy(src, dest)
dest = dest or {}
@@ -58,4 +59,61 @@ function utils.deepcopy(src, dest)
return dest
end
+local velx_header = " 1) then
+ return nil, "bad compression"
+ end
+ if ((arctype ~= "\0\0\0\0" and arctype ~= "tsar")) then
+ return nil, "bad arctype ("..arctype..")"
+ end
+ if (fver ~= 1) then
+ return nil, "wrong version"
+ end
+ local prog = read(psize)
+ if (compression == 1) then
+ prog = lzss_decompress(prog)
+ end
+ seek(lsize+ssize)
+ local env = {}
+ if (arctype == "tsar") then
+ env._ARCHIVE = tsar.read(read, seek, close)
+ end
+ setmetatable(env, {__index=_G, __newindex=function(_, i, v) _G[i] = v end})
+ return load(prog, "="..(name or "(loaded velx)"), "t", env)
+end
+
+local _RENV = _G
+
+function utils.make_env()
+ local env = utils.deepcopy(_RENV)
+ env._G = env
+ env.load = function(scr, name, mode, e)
+ return load(scr, name, mode, e or env)
+ end
+ return env
+end
+
+function utils.console_panic(er)
+ local con = krequire("zorya").loadmod("util_luaconsole")
+ if (con) then
+ local gpu = cproxy(clist("gpu")())
+ if not gpu.getScreen() or gpu.getScreen() == "" then
+ gpu.bind(clist("screen")())
+ end
+ con(string.format("tty.setcolor(0x4) print([[%s]])", er))
+ return true
+ end
+end
+
+_RENV = utils.make_env()
+
builtins.utils = function() return utils end
\ No newline at end of file
diff --git a/src/zy-neo/zinit.lua b/src/zy-neo/zinit.lua
index 03b1766..02216c5 100644
--- a/src/zy-neo/zinit.lua
+++ b/src/zy-neo/zinit.lua
@@ -1,24 +1,18 @@
local lzss_decompress = ...
--Zorya NEO itself.
_BIOS = "Zorya NEO"
-_ZVSTR = "2.0-rc4"
+_ZVSTR = "2.0-rc5"
_ZVER = 2.0
_ZPAT = 0
_ZGIT = "$[[git rev-parse --short HEAD]]"
--#include "ksrc/kinit.lua"
local thd = krequire("thd")
-local util = krequire("util")
local sys = krequire("sys")
local component = component
local computer = computer
-local booted = false
-local zcfg = {}
-function log(...)
- local c = component.list("ocemu")() or component.list("sandbox")()
- if c then
- component.proxy(c).log(...)
- end
-end
+local cinvoke = component.invoke
+local clist = component.list
+local cproxy = component.proxy
local th_i = 0
local function th_a(func)
thd.add("zyneo$"..th_i, func)
@@ -26,19 +20,19 @@ local function th_a(func)
end
local function load_lua(src, ...)
- log(#src)
if (src:sub(1, 4) == "\27ZLS") then
src = lzss_decompress(src:sub(5))
end
return load(src, ...)
end
+local tsar = load([[
+$[[cat src/zy-neo/builtins/util_tsar.lua | luamin -c]]
+]])()
+
local builtins = {}
--#include "src/zy-neo/utils.lua"
-
-local tsar = load([[
---#include "src/zy-neo/builtins/util_tsar.lua"
-]])()
+local log = utils.debug_log
sys.add_lib("zorya", (function()
@@ -56,8 +50,6 @@ sys.add_lib("zorya", (function()
local loaded_mods = {}
- loaded_mods.util_tsar = tsar
-
function zy.loadmod(mod)
if (loaded_mods[mod]) then return loaded_mods[mod] end
for i=1, #mod_search do
@@ -67,10 +59,6 @@ sys.add_lib("zorya", (function()
end
end
- function zy.loader_run(func, env)
- func(env)
- end
-
function zy.add_mod_search(func)
mod_search[#mod_search+1] = func
log(#mod_search)
@@ -94,11 +82,11 @@ th_a(function()
xpcall(function()
local zy = krequire("zorya")
zy.add_mod_search(function(mod)
- if (bfs.exists(".zy2/mods/"..mod..".zy2m")) then
- utils.debug_log(mod, ".zy2m")
- return load_lua(bfs.getfile(".zy2/mods/"..mod..".zy2m"), "=.zy2/mods/"..mod..".zy2m")()
- elseif (bfs.exists(".zy2/mods/"..mod.."/init.zy2m")) then
- return assert(load_lua(bfs.getfile(".zy2/mods/"..mod.."/init.zy2m"), "=.zy2/mods/"..mod.."/init.zy2m"))()
+ if (bfs.exists(".zy2/mods/"..mod..".velx")) then
+ --utils.debug_log(mod, ".zy2m")
+ --return load_lua(bfs.getfile(".zy2/mods/"..mod..".zy2m"), "=.zy2/mods/"..mod..".zy2m")()
+ local r,s,c = bfs.getstream(".zy2/mods/"..mod..".velx")
+ return assert(utils.load_velx(r,s,c,".zy2/mods/"..mod..".velx"))()
end
end)
sys.add_search(function(mod)
@@ -107,28 +95,31 @@ th_a(function()
end
end)
sys.add_search(function(mod)
- if (bfs.exists(".zy2/lib/"..mod..".zy2l")) then
- return load_lua(bfs.getfile(".zy2/lib/"..mod..".zy2l"), "=.zy2/lib/"..mod..".zy2l")
- elseif (bfs.exists(".zy2/lib/"..mod.."/init..zy2l")) then
- return load_lua(bfs.getfile(".zy2/lib/"..mod.."/init.zy2l"), "=.zy2/lib/"..mod.."/init.zy2l")
+ if (bfs.exists(".zy2/lib/"..mod..".velx")) then
+ local r,s,c = bfs.getstream(".zy2/lib/"..mod..".velx")
+ return utils.load_velx(r,s,c,".zy2/lib/"..mod..".velx")
+ --return load_lua(bfs.getfile(".zy2/lib/"..mod..".velx"), "=.zy2/lib/"..mod..".zy2l")
end
end)
local zycfg = bfs.getcfg()
-- Config loaded, now we can do our shit.
- local env = {
- zorya = zy,
- loadmod = zy.loadmod,
- loadfile = bfs.getfile,
- _BOOTADDR = bfs.addr
- }
- for k, v in pairs(_G) do
- env[k] = v
+ local env = utils.make_env()
+ env.zorya = zy
+ env.loadmod = zy.loadmod
+ env.loadfile = bfs.getfile
+ env._BOOTADDR = bfs.addr
+
+ local c, e = load(zycfg, "=zycfg", "t", env)
+ if c then
+ return c()
+ else
+ utils.console_panic(e)
end
- env._G = env
- env._ENV = env
- return assert(load(zycfg, "=zycfg", "t", env))()
end, function(e)
er = e..": "..debug.traceback()
+ if(not utils.console_panic(er)) then
+ er = er .. "\n(Lua console failed to start)"
+ end
end)
if er then error(er) end
end)
diff --git a/utils/installer/blt.lua b/utils/installer/blt.lua
new file mode 100644
index 0000000..5433ffd
--- /dev/null
+++ b/utils/installer/blt.lua
@@ -0,0 +1,247 @@
+-- BLT, made for Lua 5.3
+
+local blt = {}
+
+local types
+
+local function serialize(val)
+ local t = type(val)
+ if (t == "number") then
+ t = math.type(val)
+ end
+ local b, str = types["s"..t](val)
+ b = (b << 3) | types[t]
+ return string.char(b) .. str
+end
+
+local function deserialize(str, t)
+ local tb = str:byte(1)
+ local type_ = tb & 7
+ local b = tb >> 3
+ local v, l = types[type_](b, str:sub(2))
+ return v, l+1
+end
+
+local function fromdouble(f)
+ return 0, string.pack(" 0xFFFFFFFFFFFFFF) then return _fromlongint(i) end
+ for j=0, 7 do
+ len = len + 1
+ cmp2 = cmp2 | (0xFF << j)
+ --print("fromint", i+((cmp2//2)), cmp2)
+ --if (i+((cmp2//2)) <= cmp2) then
+ if (math.abs(i) <= cmp2//2) then
+ break
+ end
+ end
+ if (i < 0) then
+ i = i + (cmp2//2)
+ end
+ --i = i + (cmp2//2)
+ local tmp = ""
+ for j=0, len-1 do
+ tmp = tmp .. string.char((i & (0xFF << (j*8))) >> (j*8))
+ end
+ --local tmp = string.pack(" 0) then
+ if (nindex == nmax) then
+ local ib, dat = fromarray(t)
+ tmp = tmp .. string.char(0) .. string.char(types.table_array | (ib << 3)) .. dat
+ else
+ for k, v in pairs(t) do
+ if (type(k) == "number" and math.type(k) == "integer") then
+ local ks = serialize(k)
+ local vs = serialize(v)
+ tmp = tmp .. ks .. vs
+ end
+ end
+ end
+ end
+ return 0, tmp .. string.char(0,0) --nil,nil terminated
+end
+
+local function totbl(b, str)
+ local t = {}
+ local k = ""
+ local v = ""
+ local pos = 1
+ --print("topen")
+ while true do
+ --print("k", str:byte(pos), str:byte(pos) & 7)
+ local k, l = deserialize(str:sub(pos))
+ pos = pos + l
+ --print("v", str:byte(pos), str:byte(pos) & 7)
+ if (str:byte(pos) & 7 == 6) then
+ --print("ailen", str:byte(pos) & (7 ~ 0xFF))
+ local r, l = deserialize(str:sub(pos))
+ pos = pos + l
+ for i=1, #r do
+ t[i] = r[i]
+ end
+ else
+ local v, l = deserialize(str:sub(pos))
+ pos = pos + l
+ if (not v and not k) then
+ --print("tclose")
+ break
+ end
+ --print("decode", k, v)
+ t[k] = v
+ end
+ end
+ return t, pos-1 --how
+end
+
+-- Type LUT
+types = {
+ ["nil"] = 0,
+ float = 1,
+ number = 1,
+ integer = 2,
+ string = 3,
+ boolean = 4,
+ table = 5,
+ table_array = 6, --Meta-value
+ [0] = function(b, str) return nil, 0 end,
+ [1] = todouble,
+ [2] = toint,
+ [3] = tostr,
+ [4] = tobool,
+ [5] = totbl,
+ [6] = toarray,
+ snil = function()return 0, ""end,
+ sfloat = fromdouble,
+ sinteger = fromint,
+ sstring = fromstr,
+ sboolean = frombool,
+ stable = fromtbl,
+ stable_array = fromarray
+}
+
+function blt.serialize(...)
+ local args = {...}
+ local tmp = string.char(#args)
+ for i=1, #args do
+ local str = serialize(args[i])
+ tmp = tmp .. str
+ end
+ return tmp
+end
+
+local unpack = unpack or table.unpack
+
+function blt.deserialize(str)
+ local args = {}
+ local pos = 2
+ local amt = str:byte(1)
+ local l
+ for i=1, amt do
+ local v, l = deserialize(str:sub(pos))
+ args[i] = v
+ pos = pos + l
+ end
+ return unpack(args)
+end
+
+return blt
\ No newline at end of file
diff --git a/utils/installer/bootstrap.lua b/utils/installer/bootstrap.lua
new file mode 100644
index 0000000..3b6f0fd
--- /dev/null
+++ b/utils/installer/bootstrap.lua
@@ -0,0 +1,37 @@
+local args = {...}
+local tbl = args[1]
+local dat = args[2]
+table.remove(args, 1)
+table.remove(args, 1)
+
+local function getfile(path)
+ for i=1, #tbl do
+ if (tbl[i].name == path) then
+ return dat:sub(tbl[i].pos, tbl[i].pos+tbl[i].filesize-1)
+ end
+ end
+end
+
+if debug.debug then
+ for i=1, #tbl do
+ print(tbl[i].name, tbl[i].filesize)
+ end
+ print("Zorya NEO Installer")
+ print("This was made for OpenComputers, and, as such, is not compatible with your system.")
+ os.exit(0)
+end
+
+function lzss_decompress(a)local b,c,d,e,j,i,h,g=1,'',''while b<=#a do
+e=c.byte(a,b)b=b+1
+for k=0,7 do h=c.sub
+g=h(a,b,b)if e>>k&1<1 and b<#a then
+i=c.unpack('>I2',a,b)j=1+(i>>4)g=h(d,j,j+(i&15)+2)b=b+1
+end
+b=b+1
+c=c..g
+d=h(d..g,-4^6)end
+end
+return c end
+
+local component = component or require("component")
+local computer = computer or require("computer")
\ No newline at end of file
diff --git a/utils/installer/graphics.lua b/utils/installer/graphics.lua
new file mode 100644
index 0000000..8e2b675
--- /dev/null
+++ b/utils/installer/graphics.lua
@@ -0,0 +1,30 @@
+local characters = {
+ "╔", "╗", "═", "║", "╚", "╝"
+}
+
+local proxy, list = component.proxy, component.list
+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
+
+function gfx.drawtitle()
+
+end
\ No newline at end of file
diff --git a/utils/installer/init.lua b/utils/installer/init.lua
new file mode 100644
index 0000000..8323325
--- /dev/null
+++ b/utils/installer/init.lua
@@ -0,0 +1,7 @@
+--#include "utils/installer/bootstrap.lua"
+--#include "utils/installer/blt.lua"
+--#include "utils/installer/strings.lua"
+--#include "utils/installer/graphics.lua"
+--#include "utils/installer/menu.lua"
+
+local menus = {}
\ No newline at end of file
diff --git a/utils/installer/menu.lua b/utils/installer/menu.lua
new file mode 100644
index 0000000..e3dfcd7
--- /dev/null
+++ b/utils/installer/menu.lua
@@ -0,0 +1,128 @@
+local menu = {}
+
+local _menu = {}
+
+function menu.create(title)
+ return setmetatable({}, {__index=_menu})
+end
+
+function _menu:destroy()
+
+end
+
+function _menu:add(obj)
+
+end
+
+function _menu:calcsize()
+ local w, h = 0,0
+ for i=1, #self do
+ local ew, eh = self[i]:size()
+ if (ew > w) then
+ w = ew
+ end
+ h = h + eh
+ end
+ self.w = w
+ self.h = h
+ return w, h
+end
+
+function _menu:draw()
+ local w, h = self.w+2, self.h+2
+ for i=1, #self do
+
+ end
+end
+
+function _menu:drawblit()
+ local w, h = self.w+2, self.h+2
+ for i=1, #self do
+
+ end
+end
+
+local _text = {}
+
+function _text:size()
+ return self.w, self.h
+end
+
+function _text:draw(gpu, x, y, width)
+ for i=1, #self.txt do
+ local rx = x+math.floor((width/2)-(#self.txt/2))
+ gpu.set(rx, y+i-1, self.txt[i])
+ end
+end
+
+local _select = {entry = true}
+
+function _select:select(func)
+ self.select = func
+end
+
+function _select:size()
+ return self.w, self.h
+end
+
+function _select:keyupdate(key)
+
+end
+
+local _buttons = {entry = true}
+
+function _buttons:select(func)
+ self.select = func
+end
+
+function _buttons:size()
+ return self.w, self.h
+end
+
+function _buttons:keyupdate(key)
+
+end
+
+local _checkboxes = {entry = true}
+
+function _checkboxes:size()
+
+end
+
+function _checkboxes:keyupdate(key)
+
+end
+
+local _textbox = {entry = true}
+
+function _textbox:keyupdate(key)
+
+end
+
+function _textbox:size()
+
+end
+
+function _textbox:select(func)
+
+end
+
+function _textbox:get()
+ return self.buffer
+end
+
+function menu.textbox(w)
+
+end
+
+function menu.select(options)
+
+end
+
+function menu.buttons(buttons)
+
+end
+
+function menu.checkbox(options)
+
+end
\ No newline at end of file
diff --git a/utils/installer/menus/bios.lua b/utils/installer/menus/bios.lua
new file mode 100644
index 0000000..246212e
--- /dev/null
+++ b/utils/installer/menus/bios.lua
@@ -0,0 +1,16 @@
+function menu.bios()
+ local biossel = menu.create()
+ biossel:add(menu.text(lang.getstring("menu_bios_select")))
+ local bios = menu.select {
+ {text = lang.getstring("bios_type_managed"), value = "managed"},
+ {text = lang.getstring("bios_type_initramfs"), value = "initramfs"},
+ {text = lang.getstring("bios_type_prom"), value = "prom"},
+ {text = lang.getstring("bios_type_osdi"), value = "osdi"},
+ }
+ bios:select(function(v)
+ biossel:destroy()
+ menu["bios_"..v]()
+ end)
+ biossel:add(bios)
+ biossel:draw()
+end
\ No newline at end of file
diff --git a/utils/installer/menus/format.lua b/utils/installer/menus/format.lua
new file mode 100644
index 0000000..e69de29
diff --git a/utils/installer/menus/initramfs.lua b/utils/installer/menus/initramfs.lua
new file mode 100644
index 0000000..e69de29
diff --git a/utils/installer/menus/langselect.lua b/utils/installer/menus/langselect.lua
new file mode 100644
index 0000000..a52d3b0
--- /dev/null
+++ b/utils/installer/menus/langselect.lua
@@ -0,0 +1,14 @@
+function menu.langsetup()
+ local langselect = menu.create()
+ menu:add(menu.text("Language"))
+ local langs = menu.select {
+ {text = "English (US)", value = "en_US"}
+ }
+ langs:select(function(v)
+ langselect:destroy()
+ lang.load(v)
+ menu.bios()
+ end)
+ menu:add(langs)
+ menu:draw()
+end
\ No newline at end of file
diff --git a/utils/installer/menus/managed.lua b/utils/installer/menus/managed.lua
new file mode 100644
index 0000000..e69de29
diff --git a/utils/installer/menus/osdi.lua b/utils/installer/menus/osdi.lua
new file mode 100644
index 0000000..7ab5473
--- /dev/null
+++ b/utils/installer/menus/osdi.lua
@@ -0,0 +1,20 @@
+function menu.bios_osdi()
+ -- Find OSDI formatted disks.
+ local osdi = menu.create()
+ local drives = {}
+ local dselv = {}
+ for d in list("drive") do
+ local drive = proxy(d)
+ local t = drive.readSector(1)
+ local fmt = (t:sub(1, 4) == "OSDI")
+ drives[#drives+1] = {dev=drive, addr=d, format=fmt}
+ dselv[#dselv+1] = {text=string.format("%s (%s)", d:sub(1,6), lang.getstring((fmt and "osdi_formatted") or "osdi_unformatted")), value=drives[#drives]}
+ end
+ local disksel = menu.select(dselv)
+ disksel:select(function(v)
+ if not v.format then
+
+ end)
+ osdi:add(disksel)
+ osdi:destroy()
+end
diff --git a/utils/installer/menus/prom.lua b/utils/installer/menus/prom.lua
new file mode 100644
index 0000000..e69de29
diff --git a/utils/installer/strings.lua b/utils/installer/strings.lua
new file mode 100644
index 0000000..e955e6c
--- /dev/null
+++ b/utils/installer/strings.lua
@@ -0,0 +1,11 @@
+local lang = {}
+do
+ local _LANGINFO = {}
+ function lang.load(locale)
+ _LANGINFO = blt.deserialize(lzss_decompress(getfile("lang/"..locale..".blt.z")))
+ end
+
+ function lang.getstring(str)
+ return _LANGINFO[str]
+ end
+end
\ No newline at end of file
diff --git a/utils/installer/tsarbuild.lua b/utils/installer/tsarbuild.lua
new file mode 100644
index 0000000..256817f
--- /dev/null
+++ b/utils/installer/tsarbuild.lua
@@ -0,0 +1,49 @@
+local tsar = {}
+
+do
+ local file = ""
+ local modes = {
+ ["fifo"] = 1,
+ ["char device"] = 2,
+ ["directory"] = 4,
+ ["block device"] = 6,
+ ["file"] = 8,
+ ["link"] = 0xA,
+ ["socket"] = 0xC
+ }
+ local function tsar.getperm(ftype, perm)
+ local md = 0
+ for i=1, 9 do
+ if (perm:sub(i,i) ~= "-") then
+ md = md | (1 << (i-1))
+ end
+ end
+ return md | (modes[ftype] << 12)
+ end
+
+ function tsar.new_node(ni)
+ local ent = {
+ name = ni.name,
+ namesize = #ni.name,
+ magic = 0x5f7d,
+ mode = ni.mode or tsar.getperm("directory", "r-xr-xr-x"),
+ uid = ni.uid or 0,
+ gid = ni.gid or 0,
+ filesize = (ni.data and #ni.data) or 0,
+ mtime = os.time()
+ }
+ file = file .. string.pack("=I2I2I2I2I2I6I6", ent.magic, ent.namesize, ent.mode, ent.uid, ent.gid, ent.filesize, ent.mtime)
+ file = file .. ni.path
+ if ent.namesize & 1 > 0 then
+ file = file .. "\0"
+ end
+ file = file .. (ni.data or "")
+ if ent.namesize & 1 > 0 then
+ file = file .. "\0"
+ end
+ end
+
+ function tsar.get()
+ return file
+ end
+end
\ No newline at end of file
diff --git a/utils/installer/velxbootstrap.lua b/utils/installer/velxbootstrap.lua
new file mode 100644
index 0000000..58170f8
--- /dev/null
+++ b/utils/installer/velxbootstrap.lua
@@ -0,0 +1,29 @@
+local args = {...}
+
+local function getfile(path)
+ return _ARCHIVE:fetch(path)
+end
+
+if debug.debug then
+ for i=1, #tbl do
+ print(tbl[i].name, tbl[i].filesize)
+ end
+ print("Zorya NEO Installer")
+ print("This was made for OpenComputers, and, as such, is not compatible with your system.")
+ os.exit(0)
+end
+
+function lzss_decompress(a)local b,c,d,e,j,i,h,g=1,'',''while b<=#a do
+e=c.byte(a,b)b=b+1
+for k=0,7 do h=c.sub
+g=h(a,b,b)if e>>k&1<1 and b<#a then
+i=c.unpack('>I2',a,b)j=1+(i>>4)g=h(d,j,j+(i&15)+2)b=b+1
+end
+b=b+1
+c=c..g
+d=h(d..g,-4^6)end
+end
+return c end
+
+local component = component or require("component")
+local computer = computer or require("computer")
\ No newline at end of file