mirror of
https://github.com/Adorable-Catgirl/Zorya-NEO.git
synced 2024-12-23 09:28:07 +11:00
Because someone complained about boot speed.
This commit is contained in:
parent
760bec1eb7
commit
0e7f55624a
@ -37,25 +37,6 @@ function menu.draw()
|
||||
local sel = 1
|
||||
local function 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.")
|
||||
gpu.setBackground(bg)
|
||||
gpu.setForeground(fg)
|
||||
gpu.fill(1, h-2, w, 1, " ")
|
||||
@ -84,7 +65,30 @@ function menu.draw()
|
||||
gpu.set(2, i+2, short)
|
||||
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
|
||||
while true do
|
||||
local sig, _, key, code = computer.pullSignal(0.01)
|
||||
@ -110,10 +114,12 @@ function menu.draw()
|
||||
gpu.setBackground(0)
|
||||
gpu.setForeground(0xFFFFFF)
|
||||
entries[sel][2]()
|
||||
full_redraw()
|
||||
end
|
||||
end
|
||||
if (((computer.uptime()-stime) >= timeout) and autosel) then
|
||||
entries[sel][2]()
|
||||
full_redraw()
|
||||
end
|
||||
redraw()
|
||||
end
|
||||
|
67
src/zy-neo/builtins/init_initramfs/init.lua
Normal file
67
src/zy-neo/builtins/init_initramfs/init.lua
Normal 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
|
@ -78,7 +78,8 @@ end
|
||||
|
||||
local tmp = os.tmpname()
|
||||
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()
|
||||
local f = io.open(tmp, "rb")
|
||||
io.stdout:write(f:read("*a"))
|
||||
|
@ -42,7 +42,8 @@ function lzss_decompress(input)
|
||||
return table.concat(output)
|
||||
end
|
||||
--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 tbl = {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user