diff --git a/build.lua b/build.lua index 475040e..0647514 100644 --- a/build.lua +++ b/build.lua @@ -144,6 +144,7 @@ local function struct(tbl) end}) end + local velx_spec = struct { endian = "<", {magic="c5"}, @@ -151,6 +152,7 @@ local velx_spec = struct { {compression="B"}, {lver="B"}, {os="B"}, + {arctype="c4"}, {psize="I3"}, {lsize="I3"}, {ssize="I3"}, @@ -160,9 +162,9 @@ local velx_spec = struct { -- This builds Tsuki into a VELX executable. print("Compiling kernel...") local h = io.popen("luacomp ksrc/init.lua", "r") -os.execute("luacomp ksrc/init.lua -O debug.lua") local krnl = h:read("*a") h:close() +os.execute("luacomp ksrc/init.lua -O debug.lua 2>/dev/null") print("Generating docs and stripping comments...") os.execute("mkdir .docs") h = io.popen("lua utils/gendocs.lua .docs 2>.ktmp", "w") @@ -187,7 +189,8 @@ local header = velx_spec({ psize = #data, lsize=0, ssize=0, - rsize=#arc + rsize=#arc, + arctype="tsar" }) h:write(header) h:write(data) diff --git a/docs/foxfs.md b/docs/foxfs.md new file mode 100644 index 0000000..e69de29 diff --git a/extras/crescent/init.lua b/extras/crescent/init.lua new file mode 100644 index 0000000..5ab9dd9 --- /dev/null +++ b/extras/crescent/init.lua @@ -0,0 +1,48 @@ +local version = "1.0" + +local gpu = component.list("gpu")() +local w, h +local screen = component.list('screen')() +for address in component.list('screen') do + if #component.invoke(address, 'getKeyboards') > 0 then + screen = address + end +end +local cls = function()end +if gpu and screen then + component.invoke(gpu, "bind", screen) + w, h = component.invoke(gpu, "getResolution") + component.invoke(gpu, "setResolution", w, h) + component.invoke(gpu, "setBackground", 0x000000) + component.invoke(gpu, "setForeground", 0xFFFFFF) + component.invoke(gpu, "fill", 1, 1, w, h, " ") + cls = function()component.invoke(gpu,"fill", 1, 1, w, h, " ")end +end +local y = 1 +local function status(msg) + if gpu and screen then + component.invoke(gpu, "set", 1, y, msg) + if y == h then + component.invoke(gpu, "copy", 1, 2, w, h - 1, 0, -1) + component.invoke(gpu, "fill", 1, h, w, 1, " ") + else + y = y + 1 + end + end +end + +local loadspin = 1 +local spins = { + "-", "\\", "|", "/" +} + +local function lsc() + loadspin = (loadspin % 4) + 1 + return spins[loadspin] +end + +--#include "crescent/velx.lua" +--#include "crescent/tsar.lua" +--#include "crescent/loader.lua" + +status("crescent loader v"..version) \ No newline at end of file diff --git a/extras/crescent/loader.lua b/extras/crescent/loader.lua new file mode 100644 index 0000000..e881848 --- /dev/null +++ b/extras/crescent/loader.lua @@ -0,0 +1,6 @@ +function boot_kernel(...) + local knl, env = load_velx(computer.getBootAddress(), "kernel.velx") + local iramfs = load_tsar(computer.getBootAddress(), "initramfs.tsar") + env._ARCHIVE = iramfs + knl(...) +end \ No newline at end of file diff --git a/extras/crescent/tsar.lua b/extras/crescent/tsar.lua new file mode 100644 index 0000000..e69de29 diff --git a/extras/crescent/velx.lua b/extras/crescent/velx.lua new file mode 100644 index 0000000..98149da --- /dev/null +++ b/extras/crescent/velx.lua @@ -0,0 +1,39 @@ +local 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 function load_velx(addr, path) + status("loading kernel... "..lsc()) + local fs = component.proxy(addr) + local h = fs.open(path) + local magic, fver, comp, lver, osid, psize = string.unpack(">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 function boot_velx(addr, path) - + local fs = component.proxy(addr) + local h = fs.open(path) + local magic, fver, comp, lver, osid, psize = string.unpack(" 0) and "Library") or "Executable", os[header.os & 0x7F] or "Unknown", -lver),"\n") -local h = io.popen("tsar -t", "w") +lver, +header.arctype:gsub("\0", "")),"\n") +local h = io.popen(commands[header.arctype:gsub("\0", "")], "w") h:write(archive) h:close() if (header.compression == 1) then