1
0
mirror of https://github.com/Adorable-Catgirl/Zorya-NEO.git synced 2024-11-27 04:38:06 +11:00

Because someone complained about boot speed.

This commit is contained in:
Jane Roxanne 2020-03-29 11:52:53 -05:00
parent 760bec1eb7
commit 0e7f55624a
4 changed files with 97 additions and 22 deletions

View File

@ -37,25 +37,6 @@ function menu.draw()
local sel = 1 local sel = 1
local function redraw() local function redraw()
local w, h = gpu.getViewport() local w, h = gpu.getViewport()
local cls = function()gpu.fill(1,1,w,h," ")end
gpu.setBackground(bg)
gpu.setForeground(fg)
cls()
--Draw some things
local namestr = _BIOS .. " " .. string.format("%.1f.%d %s", _ZVER, _ZPAT, _ZGIT)
gpu.set((w/2)-(#namestr/2), 1, namestr)
gpu.set(1, 2, border_chars[1])
gpu.set(2, 2, border_chars[2]:rep(w-2))
gpu.set(w, 2, border_chars[3])
for i=1, h-6 do
gpu.set(1, i+2, border_chars[4])
gpu.set(w, i+2, border_chars[4])
end
gpu.set(1, h-3, border_chars[5])
gpu.set(2, h-3, border_chars[2]:rep(w-2))
gpu.set(w, h-3, border_chars[6])
gpu.set(1, h-1, "Use ↑ and ↓ keys to select which entry is highlighted.")
gpu.set(1, h, "Use ENTER to boot the selected entry.")
gpu.setBackground(bg) gpu.setBackground(bg)
gpu.setForeground(fg) gpu.setForeground(fg)
gpu.fill(1, h-2, w, 1, " ") gpu.fill(1, h-2, w, 1, " ")
@ -84,7 +65,30 @@ function menu.draw()
gpu.set(2, i+2, short) gpu.set(2, i+2, short)
end end
end end
redraw() local function full_redraw()
local w, h = gpu.getViewport()
local cls = function()gpu.fill(1,1,w,h," ")end
gpu.setBackground(bg)
gpu.setForeground(fg)
cls()
--Draw some things
local namestr = _BIOS .. " " .. string.format("%.1f.%d %s", _ZVER, _ZPAT, _ZGIT)
gpu.set((w/2)-(#namestr/2), 1, namestr)
gpu.set(1, 2, border_chars[1])
gpu.set(2, 2, border_chars[2]:rep(w-2))
gpu.set(w, 2, border_chars[3])
for i=1, h-6 do
gpu.set(1, i+2, border_chars[4])
gpu.set(w, i+2, border_chars[4])
end
gpu.set(1, h-3, border_chars[5])
gpu.set(2, h-3, border_chars[2]:rep(w-2))
gpu.set(w, h-3, border_chars[6])
gpu.set(1, h-1, "Use ↑ and ↓ keys to select which entry is highlighted.")
gpu.set(1, h, "Use ENTER to boot the selected entry.")
redraw()
end
full_redraw()
sel = 1 sel = 1
while true do while true do
local sig, _, key, code = computer.pullSignal(0.01) local sig, _, key, code = computer.pullSignal(0.01)
@ -110,10 +114,12 @@ function menu.draw()
gpu.setBackground(0) gpu.setBackground(0)
gpu.setForeground(0xFFFFFF) gpu.setForeground(0xFFFFFF)
entries[sel][2]() entries[sel][2]()
full_redraw()
end end
end end
if (((computer.uptime()-stime) >= timeout) and autosel) then if (((computer.uptime()-stime) >= timeout) and autosel) then
entries[sel][2]() entries[sel][2]()
full_redraw()
end end
redraw() redraw()
end end

View File

@ -0,0 +1,67 @@
_ZLOADER = "initramfs"
local readfile=function(f,h)
local b=""
local d,r=f.read(h,math.huge)
if not d and r then error(r)end
b=d
while d do
local d,r=f.read(h,math.huge)
b=b..(d or "")
if(not d)then break end
end
f.close(h)
return b
end
local bfs = {}
local cfg = component.proxy(component.list("eeprom")()).getData()
local baddr = cfg:sub(1, 36)
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 = readfile(bootfs, romfs_file)
--[[local romfs_dev = tsar.read(function(a)
local c = ""
local d
while a > 0 do
d = bootfs.read(romfs_file, a)
a = a - #d
c = c .. d
end
return c
end, function(a)
return bootfs.seek(romfs_file, "cur", a)
end, function()
return bootfs.close(romfs_file)
end)]]
local h = 1
local romfs_dev = tsar.read(function(a)
local d = rfs:sub(h, h+a-1)
h = h+a
return d
end, function(a)
h = h + a
return h
end, function()
rfs = nil
end)
function bfs.getfile(path)
return romfs_dev:fetch(path)
end
function bfs.exists(path)
return romfs_dev:exists(path)
end
function bfs.getcfg()
local h = assert(bootfs.open(".zy2/cfg.lua", "r"))
return readfile(bootfs, h)
end
bfs.addr = baddr

View File

@ -78,7 +78,8 @@ end
local tmp = os.tmpname() local tmp = os.tmpname()
local h = io.popen("luacomp ../utils/selfextract.lua -O"..tmp, "w") local h = io.popen("luacomp ../utils/selfextract.lua -O"..tmp, "w")
h:write(mkstr(lzss_compress(f))) --h:write(mkstr(lzss_compress(f)))
h:write(mkstr(f))
h:close() h:close()
local f = io.open(tmp, "rb") local f = io.open(tmp, "rb")
io.stdout:write(f:read("*a")) io.stdout:write(f:read("*a"))

View File

@ -42,7 +42,8 @@ function lzss_decompress(input)
return table.concat(output) return table.concat(output)
end end
--print("Decompressing CPIO...") --print("Decompressing CPIO...")
local code = lzss_decompress(@[{io.stdin:read("*a")}]) --local code = lzss_decompress(@--[{io.stdin:read("*a")}])
local code = @[{io.stdin:read("*a")}]
local dat = code local dat = code
local tbl = {} local tbl = {}