mirror of
https://github.com/20kdc/OC-KittenOS.git
synced 2024-11-16 23:48:05 +11:00
d8c4378ec1
Also, store an old installer copy for reference
609 lines
62 KiB
Lua
609 lines
62 KiB
Lua
-- KOSNEO inst.
|
||
-- This is released into the public domain.
|
||
-- No warranty is provided, implied or otherwise.
|
||
|
||
-- PADPADPADPADPADPADPADPAD
|
||
|
||
local C, O, G, D = component, computer
|
||
local sAddr = C.list("screen", true)()
|
||
if sAddr then
|
||
G = C.list("gpu", true)()
|
||
if G then
|
||
G = C.proxy(G)
|
||
G.bind(sAddr)
|
||
G.setForeground(0xFFFFFF)
|
||
G.setBackground(0x000000)
|
||
G.setResolution(50, 5)
|
||
G.setDepth(1)
|
||
G.fill(1, 1, 50, 5, " ")
|
||
G.setBackground(0xFFFFFF)
|
||
G.setForeground(0x000000)
|
||
G.fill(1, 2, 50, 1, " ")
|
||
G.set(2, 2, "KittenOS NEO Installer")
|
||
end
|
||
end
|
||
|
||
D = C.proxy(O.getBootAddress())
|
||
|
||
local file = nil
|
||
local fileName = "Starting..."
|
||
local fileSizeRm = 0
|
||
local ws = 0
|
||
|
||
local convoct
|
||
convoct = function (oct)
|
||
local v = oct:byte(#oct) - 0x30
|
||
if #oct > 1 then
|
||
return (convoct(oct:sub(1, #oct - 1)) * 8) + v
|
||
end
|
||
return v
|
||
end
|
||
local function sectorCore(sector)
|
||
if ws > 0 then
|
||
ws = ws - 1
|
||
return
|
||
end
|
||
if file then
|
||
local takeaway = math.min(512, fileSizeRm)
|
||
D.write(file, sector:sub(1, takeaway))
|
||
fileSizeRm = fileSizeRm - takeaway
|
||
if fileSizeRm == 0 then
|
||
D.close(file)
|
||
file = nil
|
||
end
|
||
else
|
||
local name = sector:sub(1, 100):gsub("\x00", "")
|
||
local sz = convoct(sector:sub(125, 135))
|
||
if name:sub(1, 5) ~= "code/" then
|
||
ws = math.ceil(sz / 512)
|
||
else
|
||
if name:sub(#name, #name) == "/" then
|
||
ws = math.ceil(sz / 512)
|
||
D.makeDirectory(name:sub(6))
|
||
else
|
||
fileName = name:sub(6)
|
||
file = D.open(fileName, "wb")
|
||
fileSizeRm = sz
|
||
if file then
|
||
if fileSizeRm == 0 then
|
||
D.close(file)
|
||
file = nil
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
local dieCB = function () end
|
||
|
||
local sectorNum = 0
|
||
local sectorCount = 0
|
||
|
||
local function sector(n)
|
||
sectorCore(n)
|
||
sectorNum = sectorNum + 1
|
||
if G then
|
||
local a = sectorNum / sectorCount
|
||
G.fill(1, 2, 50, 1, " ")
|
||
G.set(2, 2, "KittenOS NEO Installer : " .. fileName)
|
||
G.setForeground(0xFFFFFF)
|
||
G.setBackground(0x000000)
|
||
G.fill(2, 4, 48, 1, " ")
|
||
G.setBackground(0xFFFFFF)
|
||
G.setForeground(0x000000)
|
||
G.fill(2, 4, math.ceil(48 * a), 1, " ")
|
||
end
|
||
if sectorNum % 8 == 0 then
|
||
O.pullSignal(0.05)
|
||
end
|
||
if sectorNum == sectorCount then
|
||
dieCB()
|
||
O.shutdown(true)
|
||
end
|
||
end
|
||
|
||
sectorCount = 260
|
||
D.remove("init-symsear.lua")
|
||
D.rename("init.lua", "init-symsear.lua")
|
||
local instHandle = D.open("init-symsear.lua", "rb")
|
||
dieCB = function ()
|
||
D.close(instHandle)
|
||
D.remove("init-symsear.lua")
|
||
end
|
||
local syms = {" ","s","e","t","a","i","\24","(","r",".","\
|
||
","p","\"","o","c","m",", ","\1","l","n",")","d","u","\17","\9","x","-","\7","\6","\8","\4","\13","\2","\3","\5","g","\14","\21","\11"," then\
|
||
","1","w"," ","\12","\18","\22","f","F","y",",","\20","re","b","k"," = ","\23","return "," local ","\16","v"," if ","\
|
||
","\15","\19","\
|
||
"," ","[","en","/","0","]","path","nction (","\
|
||
","se","h"," =","or","S","T","le","\
|
||
local ",")\
|
||
","= fu","on"," == ","ne",")\
|
||
","functio","\
|
||
end\
|
||
","D","{"," t","n ","oc","lo"," end\
|
||
","\0\0\0\0\0\0\0\0\0","un"," i","W","\0\0\0\0\0\0","fu","et"," end\
|
||
","then ","nd","ni","A","ing"," tab","loca","etting",")\
|
||
","ct","C","P","}","\
|
||
end\
|
||
",")\
|
||
","onit","= ","end\
|
||
","\0","I","Y"," do\
|
||
","return\
|
||
","le.inser"," = func","= \"","al"," r"," e","in","he","nc"," e","j","donkonit","tion ()",") do\
|
||
"," the","\
|
||
",")\
|
||
","ur","#","+","N","cursor",".inse",", v ","nction (w"," neo.req"," for "," then\
|
||
","\0\0\0\0\0\0\0","nd\
|
||
","()\
|
||
","neo.","ath","table","l ","do","2","3",":","H"," = nil\
|
||
","nd\
|
||
e","hen\
|
||
","\7local ","indowCore",")\
|
||
end\
|
||
","d\") end\
|
||
"," = false","if ","pairs(","dow","string\"","ti","O","uestAcces","nd\
|
||
if ","icode."," if","v in ","pkg, pid","000","750\0000001","end\
|
||
e","750\0000000"," else\
|
||
","window","end","00",".neo.sys.","neoux.tc","= {}\
|
||
","(window, ","5","=","E","R",") end\
|
||
"," cursor","request","ode/app"," return e","\" the","equire("," "," then",".neo.pub.","hile true"," end"," en","\0\0","B","M"," ret","for ","in ipai"," true\
|
||
","close","code.sub","error(\"","return t","oroutine"," end\
|
||
if","end\
|
||
en","tion ","\", funct",":sub(","vailable"," end\
|
||
"," l"," == \"","prima"," if type(","ryWindow","window.s"," end\
|
||
","L","X","~","on ("," in ipair"," for _, v"," for k","\0\0\0\0\0cod","lose()\
|
||
"," = funct","rror(\"Exp","nsurePath","s.primary","primary","buildingS","unic"," "," re","surfaces","disallowe","ackground","neoux.","ccess","selectUnk"," end\
|
||
"," = uni","\
|
||
end\
|
||
"," f","7","Z","z","for k","rue\
|
||
end\
|
||
","ode.len("," end\
|
||
","lse\
|
||
",") end","end\
|
||
"," fu",":sub(1, ","sub(1, 4)"," ","neo","the","if not "," th","tion","unknownA","end\
|
||
","[1] == \"","= unico","Acces","\
|
||
end\
|
||
\
|
||
l","n\
|
||
","\") end\
|
||
","de.len("," end","\" then\
|
||
","0\0000001","urface","nd\
|
||
","()\
|
||
","(surfaces"," if ","\0\0\0\0\0\0\0\0","unc","urn","\
|
||
"," end\
|
||
"," neoux","ction","\
|
||
end\
|
||
","\
|
||
","neoux","\24\0\0\0\0\0\0\0\0","\
|
||
end"," end\
|
||
end\
|
||
","\
|
||
end\
|
||
"," if "," err","s[1] == \"","unicode."," window"," if ","ocal fun","= false","\0\0\0\0\0\0\0000","\0\0\0\0\0\0\00000","code","_, v in i","()\
|
||
","d\
|
||
","f ev == \""," return",", bg, fg"," end"," neoux.","\0\0\0","w.close(","\
|
||
if ev"," i"," if not ","if kc == ",")\
|
||
end\
|
||
","indow","onkonit","00175","table.",", bg, fg)"," l"," end\
|
||
",") == \"","d\
|
||
"," return ","rn","ca","q"," tabl"," error(\"","end\
|
||
re"," in ","hen err","nd\
|
||
en","nd\
|
||
","\
|
||
end","turn ","x.neo.","ion ("," table","false","string","e.len(","d\
|
||
"," re","1, unicod","cursorX ","local ","end\
|
||
end\
|
||
","cal","\" then e","nd\
|
||
if k","ion","00644\00000"," end\
|
||
","\
|
||
end"," window."," e","if not","== \"",", func"," neo.",", functi","\
|
||
end\
|
||
end"," r","end\
|
||
","ion (w)\
|
||
","\
|
||
end"," = false\
|
||
"," ret","tu"," end\
|
||
","f ","unction","= nil\
|
||
","th","n\
|
||
","6","U","_","requir","eturn\
|
||
"," funct","eturn tr","\
|
||
\
|
||
local"," table.","eques","rn ",")\
|
||
r",".insert(","ode.",")\
|
||
end","== ","\0\0\0\0\0\0\0c","n\
|
||
","\0\0\0\0\0","()\
|
||
"," = nil","able.","n\
|
||
"," = n","return","000644\0000","Access","able","etu","d\
|
||
","\
|
||
if ","end\
|
||
end","nction (p","ub(1, 4) "," return "," return","lse\
|
||
","abl","= uni","for k, ","\0\0\0\0\0\0\0\0c","cursorY","ble","bg, fg)\
|
||
","\
|
||
e","ind","ret","tring\"","000000"," neo","pairs","then\
|
||
",")\
|
||
","le.inse","loc","\
|
||
end","n error","\
|
||
end\
|
||
\
|
||
","if s[1] =","lse\
|
||
","turn","ursor","function","neou","\0\0\0\0\0\0c","function ","\0000001","end\
|
||
e","eo.","Access(\""," re"," lo","\
|
||
e",")\
|
||
end","urn ","\
|
||
re"," end\
|
||
e"," = f","\0\0\0\0","cal ","\0000000644\0","in ip","\
|
||
en"," return",")\
|
||
i","ction ","\
|
||
end\
|
||
","ode","equire(\"","r(\"Expect","ctio"," cursorY","if","%","4","<","G","\
|
||
local f","\
|
||
ret"," for ","d\
|
||
if"," erro","true\
|
||
end","ed\") end","hen ","nd\
|
||
en","al ","on ","] then\
|
||
","string\")","for _, ","unicode.l","[1] == ","true\
|
||
","uestAc","nd\
|
||
end\
|
||
"," for k, "," if ev ","then\
|
||
","\
|
||
en",")\
|
||
en","do\
|
||
","e.ins",".primary"," true","coroutine","return\
|
||
","airs(",") end\
|
||
","nd\
|
||
end\
|
||
\
|
||
","\
|
||
return","window, ","end\
|
||
e","end\
|
||
end","750\0000","eturn t",", functio"," e","d\") end","en\
|
||
","ocal","icode.len","e\
|
||
","n\
|
||
","w.close()"," uni","sub(","n ipairs("," for ","end\
|
||
","ion ()","end\
|
||
en","quest","cursorY ","eturn","unicode.s","x.neo.pub"," = neo","hen\
|
||
","then\
|
||
","string\") ","in ipa"," retur","indowCor"," re","750\00000"," do\
|
||
",")\
|
||
if "," then ret","\") end"," en","n\
|
||
","ipairs"," then err","d\
|
||
en","= f"," local",".neo.","\24\0\0\0\0\0\0\0","func","()\
|
||
",")\
|
||
en","curs","\
|
||
loca","ode/apps","nd\
|
||
if "," i"," = neo.r","kg, pid, ","\
|
||
i","win","code.sub(","require","wind"," else\
|
||
","close()"," end\
|
||
e","\
|
||
\
|
||
local "," then re","\
|
||
e",".request","wnAvailab","tion (","\
|
||
local ","error(","\0000001750\0","n\
|
||
","d\
|
||
"," ","uestA","reques","end\
|
||
end\
|
||
\
|
||
","ion ()\
|
||
"," curso","then\
|
||
","0001750","surfac",".close("," function","= neo.","if type("," loc","d\
|
||
e","oroutine."," do\
|
||
"," else\
|
||
","tion ()\
|
||
",", v in ","window.","neo.re","0000","\000000","\
|
||
end\
|
||
","ipairs("," ret","\"x.neo.pu","error","\
|
||
i","\
|
||
end","()\
|
||
","= nil\
|
||
","nsert(","n erro","rror(\"","nil\
|
||
","cursorX ="," do\
|
||
"," for","turn f","en\
|
||
"," table.","\
|
||
","\") end\
|
||
","\") end\
|
||
",".close()\
|
||
","\
|
||
re","d\
|
||
e","\
|
||
end\
|
||
","ownAvaila","000644\00000"," false\
|
||
","\
|
||
re","false\
|
||
","ion ()\
|
||
",")\
|
||
e","urn end\
|
||
",")\
|
||
if","x.neo.sys","indow, ","then\
|
||
",")\
|
||
if t","cti","ion ","ion (w","\" then"," = nil\
|
||
","then","e\" then\
|
||
"," if","on (w)\
|
||
",") do\
|
||
"," en","tAccess(\"","surePath"," end\
|
||
end","\
|
||
end\
|
||
","e.inse"," table.i"," local","oca","n (","0 then\
|
||
",") end\
|
||
"," loc","se\
|
||
","do\
|
||
","nd\
|
||
end\
|
||
"," then e","0000644\0","ion ()\
|
||
","ocal ","end\
|
||
if ","e\
|
||
"," then\
|
||
"," local","icode.le","\" then "," ==","] == \"","eoux","ndow","\0\0\0\0\0c","nownAvail"," functi","0\000000000","eoux.tc","hen error"," = neo.","table.ins"," window","(window","d\
|
||
if ","\
|
||
if ","\
|
||
local","end\
|
||
e","nd\
|
||
end","insert("," local ","k, v i","surface","eturn ","\
|
||
loc","sub(1, ","end\
|
||
if ","io","!","$","&","'","*","8","9",";",">","?","@","J","K","Q","V","\\","^","|","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>","<EFBFBD>",}
|
||
local bytBuf = ""
|
||
local bitBuf = ""
|
||
local function getByte()
|
||
if bytBuf == "" then
|
||
bytBuf = D.read(instHandle, 64)
|
||
end
|
||
local r = bytBuf:byte()
|
||
bytBuf = bytBuf:sub(2)
|
||
return r
|
||
end
|
||
while true do
|
||
if getByte() == 0 then break end
|
||
end
|
||
local function pb(c, p) if c % (p * 2) ~= c % p then bitBuf = bitBuf .. "1" else bitBuf = bitBuf .. "0" end end
|
||
local stn = 0
|
||
local function getBit()
|
||
if bitBuf == "" then
|
||
local c = getByte()
|
||
c = (c - stn) % 256 stn = stn + 3
|
||
pb(c, 1)
|
||
pb(c, 2)
|
||
pb(c, 4)
|
||
pb(c, 8)
|
||
pb(c, 16)
|
||
pb(c, 32)
|
||
pb(c, 64)
|
||
pb(c, 128)
|
||
end
|
||
local bit = bitBuf:sub(1, 1) == "1"
|
||
bitBuf = bitBuf:sub(2)
|
||
return bit
|
||
end
|
||
local buf = ""
|
||
local mode = false
|
||
local bc2 = 10
|
||
while true do
|
||
local bc = getBit()
|
||
local v = 0
|
||
if bc then bc = bc2 v = 64 else bc = 6 end
|
||
for bit = 0, bc - 1 do
|
||
if getBit() then v = v + (2 ^ bit) end
|
||
end
|
||
buf = buf .. syms[v]
|
||
if mode then
|
||
while #buf >= 512 do
|
||
sector(buf:sub(1, 512))
|
||
buf = buf:sub(513)
|
||
end
|
||
else
|
||
if #buf == 27939 then
|
||
stn = 0
|
||
bc2 = 11
|
||
bitBuf = ""
|
||
syms = {}
|
||
while #buf > 0 do
|
||
local len = buf:byte()
|
||
if len > 127 then error("symlen") end
|
||
buf = buf:sub(2)
|
||
local ch = buf:sub(1, len)
|
||
buf = buf:sub(len + 1)
|
||
table.insert(syms, ch)
|
||
end
|
||
mode = true
|
||
end
|
||
end
|
||
end
|
||
--[[ |