forked from Hyperion/HyperionOS
Update src/disks/1h/boot/HBoot.sys
This commit is contained in:
@@ -1,75 +1,80 @@
|
|||||||
local args={...}
|
local args = {...}
|
||||||
local apis=args[2]
|
local apis = args[2]
|
||||||
local term=args[4]
|
local term = args[4]
|
||||||
local getfile=args[5]
|
local getfile = args[5]
|
||||||
local computer=args[7]
|
local computer = args[7]
|
||||||
local timeout = computer.time()+5000
|
local timeout = computer.time() + 5000
|
||||||
|
|
||||||
term.print("HBoot V1.0.0 //\n")
|
term.print("HBoot V1.0.0 //\n")
|
||||||
local w,h = term.getSize()
|
local w, h = term.getSize()
|
||||||
|
|
||||||
local kernel = load(getfile("/boot/Hyprkrnl.sys").readAllText())
|
local kernel = load(getfile("/boot/Hyprkrnl.sys").readAllText())
|
||||||
local recovery = load(getfile("/boot/util/shell").readAllText())
|
local recovery = load(getfile("/boot/util/shell").readAllText())
|
||||||
|
|
||||||
local dbg = {}
|
local dbg = {}
|
||||||
local entries = {
|
local entries = {
|
||||||
{"HyperionOS",function() kernel(args) end},
|
{"HyperionOS", function() kernel(args) end},
|
||||||
{"HyperionOS (Debug options)",dbg}
|
{"HyperionOS (Debug options)", dbg}
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg = {
|
dbg = {
|
||||||
{"Back",entries},
|
{"Back", entries},
|
||||||
{"Boot HyperionOS in debug mode",function() kernel(args, true) end},
|
{"Boot HyperionOS in debug mode", function() kernel(args, true) end},
|
||||||
{"Boot as shell",function() kernel(args, true, true) end},
|
{"Boot as shell", function() kernel(args, true, true) end},
|
||||||
{"Boot in recovery",function() recovery(args) end}
|
{"Boot in recovery", function() recovery(args) end}
|
||||||
}
|
}
|
||||||
|
|
||||||
local function render(table, select)
|
local function render(tbl, selected)
|
||||||
term.clear()
|
term.clear()
|
||||||
term.print("HBoot V1.0.0 //\n")
|
term.print("HBoot V1.0.0 //\n")
|
||||||
for i,v in pairs(table) do
|
for i, v in ipairs(tbl) do
|
||||||
if select=i then
|
if selected == i then
|
||||||
term.print("- "..v[1])
|
term.print("- " .. v[1] .. "\n")
|
||||||
else
|
else
|
||||||
term.print(" "..v[1])
|
term.print(" " .. v[1] .. "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
render(entries, 1)
|
render(entries, 1)
|
||||||
local exit=false
|
local exit = false
|
||||||
|
|
||||||
while not exit do
|
while not exit do
|
||||||
local ret={computer.getMachineEvent()}
|
local ret = {computer.getMachineEvent()}
|
||||||
if ret[1]=="keyPressed" then
|
if ret[1] == "keyPressed" then
|
||||||
timeout=math.huge
|
timeout = math.huge
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
if timeout<=computer.time() then
|
if timeout <= computer.time() then
|
||||||
exit=true
|
exit = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local cerent=entries
|
local cerent = entries
|
||||||
local cersel=1
|
local cersel = 1
|
||||||
|
|
||||||
if not exit then
|
if not exit then
|
||||||
while true do
|
while true do
|
||||||
local ret={computer.getMachineEvent()}
|
local ret = {computer.getMachineEvent()}
|
||||||
if ret[1]="keyTyped" then
|
if ret[1] == "keyTyped" then
|
||||||
if ret[3]=="\n" then
|
if ret[3] == "\n" then
|
||||||
if type(cerent[cersel][2])=="function" then
|
if type(cerent[cersel][2]) == "function" then
|
||||||
cerent[cersel][2]()
|
cerent[cersel][2]()
|
||||||
elseif type(cerent[cersel][2])=="table" then
|
elseif type(cerent[cersel][2]) == "table" then
|
||||||
cerent=cerent[cersel][2]
|
cerent = cerent[cersel][2]
|
||||||
cersel=1
|
cersel = 1
|
||||||
end
|
end
|
||||||
elseif ret[3]=="\x1b[A" then
|
elseif ret[3] == "\x1b[A" then
|
||||||
if cersel>1 then
|
if cersel > 1 then
|
||||||
cersel=cersel-1
|
cersel = cersel - 1
|
||||||
end
|
end
|
||||||
elseif ret[3]=="\x1b[B" then
|
elseif ret[3] == "\x1b[B" then
|
||||||
if cersel<#cerent then
|
if cersel < #cerent then
|
||||||
cersel=cersel+1
|
cersel = cersel + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
render(cerent, cersel)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user