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

Compare commits

..

No commits in common. "39ff04c2b69fc7c5b4759bf8b91374fa7b8bbb4e" and "d09c52f6c285229d53beb308f600b3f092540a42" have entirely different histories.

61 changed files with 176 additions and 1519 deletions

View File

@ -1,5 +0,0 @@
os.execute("mkdir -p pkg")
os.execute("rm -rf pkg/*")
os.execute("mkdir -p release")
os.execute("rm -rf release/*")

View File

@ -1,215 +0,0 @@
-- 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 <http://unlicense.org/>
--]]----------------------------------------------------------------------------
--------------------------------------------------------------------------------
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

View File

@ -1,48 +0,0 @@
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"

View File

@ -1,31 +0,0 @@
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"

View File

@ -1,27 +0,0 @@
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"

View File

@ -1,5 +0,0 @@
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"

View File

@ -1,4 +0,0 @@
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

View File

@ -1,7 +0,0 @@
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"

View File

@ -1,5 +0,0 @@
function actions.utils()
makeselfextract("util", "release/zorya-neo-utils-installer.lua")
end
actions[#actions+1] = "utils"

View File

@ -1,5 +0,0 @@
function actions.clean()
print("Cleaning up...")
--os.execute("rm -rf .docs")
--os.execute("rm -rf .ktmp")
end

View File

@ -1,36 +0,0 @@
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.")

View File

@ -1,2 +0,0 @@
#!/usr/bin/env sh
luacomp build.lua 2>/dev/null | lua - $@

View File

@ -1,8 +1,7 @@
{
{type="managed", path="bios/managed.bios"},
{type="initramfs", path="bios/initramfs.bios"},
{type="osdi", path="bios/osdi.bios"},
{type="prom", path="bios/prom.bios"}
--{type="osdi", path="bios/osdi.bios"},
--{type="romfs", path="bios/romfs.bios"},
--{type="proxfs", path="bios/proxfs.bios"}
}

View File

@ -0,0 +1,28 @@
{
["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"
}

View File

@ -1,25 +1,27 @@
{
{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="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="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.velx"},
{name="cpio", cat="util", path="lib/util_cpio.zy2l"},
--{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.velx"},
{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.velx"},
{name="luaconsole", cat="util", path="mods/util_luaconsole.velx"},
{name="classic", cat="menu", path="mods/menu_classic.zy2m"},
{name="luaconsole", cat="util", path="mods/util_luaconsole.zy2m"},
{name="blkdev", cat="util", path="mods/util_blkdev.zy2m"},
{name="fat", cat="fs", path="mods/fs_fat.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"},

View File

@ -49,10 +49,9 @@ local function checkCache(packetID)
end
--local realComputerPullSignal = computer.pullSignal
local ps = computer.pullSignal
thd.add("minitel_handler", function()
while true do
local eventTab = {ps(0)}
local eventTab = {computer.pullSignal(0)}
for k,v in pairs(net.hook) do
pcall(v,table.unpack(eventTab))
end

View File

@ -1,20 +1,8 @@
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)
@ -28,21 +16,10 @@ return function(addr)
env.krequire = nil]]
--vdev.install(env)
--log(env, env.computer, env.computer.getBootAddress, env.computer.getBootAddress())
-- local env = proxytable(_G)
thd.add("openos$"..openos_count, function()
local env = utils.make_env()
function env.computer.getBootAddress()
function computer.getBootAddress()
return addr
end
function env.computer.setBootAddress()end
function 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
end

View File

@ -1,5 +0,0 @@
local arg = ...
if (arg == "") then
arg = "init.lua"
end
load_exec(arg)()

View File

@ -1,105 +0,0 @@
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")

View File

@ -1,11 +0,0 @@
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.")

View File

@ -1,9 +0,0 @@
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

View File

@ -1,11 +0,0 @@
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

View File

@ -1,3 +0,0 @@
for d in component.list("filesystem") do
print(d)
end

View File

@ -1,4 +0,0 @@
local threads = krequire("thd").get_threads()
for i=1, #threads do
print(threads[i][1])
end

View File

@ -1 +0,0 @@
computer.shutdown(true)

View File

@ -1,6 +0,0 @@
local fs = ...
for f in component.list("filesystem") do
if (f:sub(1, #fs) == fs) then
_DRIVE = f
end
end

View File

@ -1 +0,0 @@
computer.shutdown()

View File

@ -1,7 +0,0 @@
local thd = krequire("thd")
local utils = krequire("utils")
local arg = ...
local name = arg:match("/(.+%..+)^") or arg
thd.add(name, function()
load_exec(arg)()
end)

View File

@ -1,14 +1,4 @@
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,
@ -47,10 +37,7 @@ return function(autorun)
print = nil
end
if (autorun) then
local c = load(autorun)
if c then
pcall(c)
end
load(autorun)()
end
tty.print("")
tty.setcolor(2)
@ -83,8 +70,6 @@ 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()
@ -107,7 +92,7 @@ return function(autorun)
end)
end
tty.setcolor(2)
tty.write(((_DRIVE and _DRIVE:sub(1, 4)) or "boot").."> ")
tty.write("boot> ")
tty.setcolor(0xF0)
tty.write(" ")
tty.setcolor(0xF)

View File

@ -1,40 +0,0 @@
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

View File

@ -2,9 +2,6 @@
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
@ -21,9 +18,9 @@ do
if (depth == 4) then --pregen color
for i=0, 15 do
local hi = i >> 3
local r = (i >> 2) & 1
local b = (i >> 2) & 1
local g = (i >> 1) & 1
local b = i & 1
local r = i & 1
local fr = (r * 0x7F) | (hi << 7)
local fg = (g * 0x7F) | (hi << 7)
local fb = (b * 0x7F) | (hi << 7)
@ -32,7 +29,6 @@ do
end
function colors(i)
if (i < 0) then i = 0 elseif (i > 15) then i = 15 end
if (depth == 1) then
return ((i > 0) and 0xFFFFFF) or 0
elseif (depth == 4) then

View File

@ -1,30 +0,0 @@
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

View File

@ -8,7 +8,8 @@ local oefi = {}
local function load_oefi(drive, path, uuid)
local oefi_env = {}
local env = utils.make_env()
local env = {}
utils.deepcopy(_G, env)
env.krequire = nil
env._BIOS = nil
env._ZVER = nil

View File

@ -21,7 +21,8 @@ local function load_oefi_env(file, envx)
arc = cpio.read(envx.fs, file)
end
local oefi_env = {}
local env = utils.make_env()
local env = {}
utils.deepcopy(_G, env)
env.krequire = nil
env._BIOS = nil
env._ZVER = nil
@ -115,7 +116,8 @@ end
function ext.ZyNeo_GetOEFIEnv(drive, arc)
local oefi_env = {}
local env = utils.make_env()
local env = {}
utils.deepcopy(_G, env)
env.krequire = nil
env._BIOS = nil
env._ZVER = nil

View File

@ -3,8 +3,10 @@
local computer = computer
xpcall(function()
utils.debug_log("Copying env...")
local env = utils.make_env()
local env = utils.deepcopy(_G)
utils.debug_log("Coppied env.")
env._G = env
env._ENV = env
env.krequire = nil
env._BIOS = nil
env._ZVSTR = nil

View File

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

View File

@ -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 @@ _ZLOADER = "initramfs"
end
f.close(h)
return b
end]]
end
local bfs = {}
local cfg = cproxy(clist("eeprom")()).getData()
local cfg = component.proxy(component.list("eeprom")()).getData()
local baddr = cfg:sub(1, 36)
local bootfs = cproxy(baddr)
local bootfs = component.proxy(baddr)
assert(bootfs.exists(".zy2/image.tsar"), "No boot image!")
local romfs_file = assert(bootfs.open(".zy2/image.tsar", "rb"))
local rfs = utils.readfile(bootfs, romfs_file)
local rfs = readfile(bootfs, romfs_file)
--[[local romfs_dev = tsar.read(function(a)
local c = ""
@ -59,13 +59,9 @@ 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 utils.readfile(bootfs, h)
return readfile(bootfs, h)
end
bfs.addr = baddr

View File

@ -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 @@ _ZLOADER = "managed"
end
f.close(h)
return b
end]]
end
local bfs = {}
local cfg = cproxy(clist("eeprom")()).getData()
local cfg = component.proxy(component.list("eeprom")()).getData()
local baddr = cfg:sub(1, 36)
local bootfs = cproxy(baddr)
local bootfs = component.proxy(baddr)
assert(bootfs.exists(".zy2/image.tsar"), "No boot image!")
@ -47,13 +47,9 @@ 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 utils.readfile(bootfs, h)
return readfile(bootfs, h)
end
bfs.addr = baddr

View File

@ -1,47 +1,38 @@
local bfs = {}
local osdi = {}
local cfg = cproxy(clist("eeprom")()).getData()
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 baddr, part = cfg:sub(1, 36)
local bootfs = cproxy(baddr)
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
--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]
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)
end
end
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
return osdi

View File

@ -1,38 +0,0 @@
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

View File

@ -0,0 +1,12 @@
--#error "Not implemented."
local rfs = {}
local bfs = {}
function bfs.getfile(path)
end
function bfs.exists(path)
end

View File

@ -1,14 +1,14 @@
local magic = 0x5f7d
local magic_rev = 0x7d5f
local header_fmt = "I2I2I2I2I2I6I6"
local en = true
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 and m ~= magic_rev then return nil, "bad magic" end
if m ~= magic then
e = get_end(not en)
end
@ -49,51 +49,20 @@ 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 = assert(read_header(dat))
local et = read_header(dat)
et.name = read(et.namesize)
et.pos = seek(et.namesize & 1)
local t = (et.filesize & 1)
seek(et.filesize + t)
seek(et.filesize + (et.filesize & 1))
lname = et.name
if lname ~= "TRAILER!!!" then
tbl[#tbl+1] = et

View File

@ -1,36 +1,35 @@
local utils = {}
function utils.debug_log(...)
local sb = clist("sandbox")() or clist("ocemu")()
if (sb) then cinvoke(sb, "log", ...) end
local sb = component.list("sandbox")() or component.list("ocemu")()
if (sb) then component.invoke(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=cinvoke(f,"read",h,math.huge)
local d,r=component.invoke(f,"read",h,math.huge)
if not d and r then error(r)end
b=d
while d do
local d,r=cinvoke(f,"read",h,math.huge)
local d,r=component.invoke(f,"read",h,math.huge)
b=b..(d or "")
if(not d)then break end
end
cinvoke(f,"close",h)
component.invoke(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 {}
@ -59,61 +58,4 @@ function utils.deepcopy(src, dest)
return dest
end
local velx_header = "<c5BBBBc4I3I3I3I4"
function utils.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) then
return nil, string.format("wrong os (%x ~= 0x5A)", osid & 0x7F)
end
if (compression > 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

View File

@ -1,18 +1,24 @@
local lzss_decompress = ...
--Zorya NEO itself.
_BIOS = "Zorya NEO"
_ZVSTR = "2.0-rc5"
_ZVSTR = "2.0-rc4"
_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 cinvoke = component.invoke
local clist = component.list
local cproxy = component.proxy
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 th_i = 0
local function th_a(func)
thd.add("zyneo$"..th_i, func)
@ -20,19 +26,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 log = utils.debug_log
local tsar = load([[
--#include "src/zy-neo/builtins/util_tsar.lua"
]])()
sys.add_lib("zorya", (function()
@ -50,6 +56,8 @@ 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
@ -59,6 +67,10 @@ 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)
@ -82,11 +94,11 @@ th_a(function()
xpcall(function()
local zy = krequire("zorya")
zy.add_mod_search(function(mod)
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"))()
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"))()
end
end)
sys.add_search(function(mod)
@ -95,31 +107,28 @@ th_a(function()
end
end)
sys.add_search(function(mod)
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")
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")
end
end)
local zycfg = bfs.getcfg()
-- Config loaded, now we can do our shit.
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)
local env = {
zorya = zy,
loadmod = zy.loadmod,
loadfile = bfs.getfile,
_BOOTADDR = bfs.addr
}
for k, v in pairs(_G) do
env[k] = v
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)

View File

@ -1,247 +0,0 @@
-- 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("<d", f)
end
local function todouble(b, str)
return string.unpack("<d", str:sub(1, 8)), 8
end
local function _fromlongint(i)
--print("longint")
return 8, string.pack("<l", i)
end
local function fromint(i)
--Time to rabidly optimize this.
local len = 0
local cmp2 = 0
if (i > 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("<i["..len.."]", i)
return len, tmp
end
local function _tolongint(str)
--print("longint2")
return string.unpack("<l", str:sub(1, 8)), 8
end
local function toint(b, str)
if (b == 8) then return _tolongint(str) end
--return string.unpack("<i["..b.."]", str:sub(1, b)), b
local tmp = 0
for i=0, b-1 do
tmp = tmp | (str:byte(i+1) << (i*8))
end
local sign = (tmp & (0x80 << ((b-1)*8)))
sign = sign << (63 - (b*8))
local int = tmp & ((0x80 << ((b-1)*8)) ~ 0xFFFFFFFFFFFFFF)
return int | sign, b
end
local function frombool(b)
return b and 1 or 0, ""
end
local function tobool(b, str)
return b ~= 0, 0
end
local function fromstr(s)
local len, val = fromint(#s)
return len, val .. s
end
local function tostr(b, str)
local strl, l = toint(b, str)
local rtn = str:sub(1+l, l+strl)
return rtn, strl+l
end
local function fromarray(a)
local b, tmp = fromint(#a)
for i=1, #a do
tmp = tmp .. serialize(a[i])
end
--print("alen_s", #tmp)
return b, tmp
end
local function toarray(b, str, arr)
local arrl, l = toint(b, str)
--print("clen", l)
--print("arr len", arrl)
local arr = {}
local i = 0
for i=1, arrl do
--print("adec", i)
local v, z = deserialize(str:sub(1+l))
--print("arr", i, v)
l = l+z
--print("clen", l, z)
arr[i] = v
end
--print("alen", l)
return arr, l
end
local function fromtbl(t)
local tmp = ""
--See if the numerical keys are a list, and, if so, write a list
local nindex = 0
local nmax = 0
for k, v in pairs(t) do
if (type(k) == "number") then
if (math.type(k) == "integer") then
nindex = nindex + 1
if (nmax < k) then
nmax = k
end
end
else
local ks = serialize(k)
local vs = serialize(v)
tmp = tmp .. ks .. vs
end
end
if (nmax > 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

View File

@ -1,37 +0,0 @@
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")

View File

@ -1,30 +0,0 @@
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

View File

@ -1,7 +0,0 @@
--#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 = {}

View File

@ -1,128 +0,0 @@
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

View File

@ -1,16 +0,0 @@
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

View File

@ -1,14 +0,0 @@
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

View File

@ -1,20 +0,0 @@
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

View File

@ -1,11 +0,0 @@
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

View File

@ -1,49 +0,0 @@
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

View File

@ -1,29 +0,0 @@
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")