local address,serialnumber, driveproxy,rb,readBytes,loadFileTable,findFile = ... Filetable = loadFileTable() function loadfile(file) local fileIndex = findFile(file) assert(fileIndex, "file \""..file.."\" not found") local fileData = Filetable[fileIndex] assert(readBytes(fileData["offset"],9) == "STARTFILE", "magic does not match") local data = readBytes(fileData["offset"]+9, fileData["size"]*driveproxy.getSectorSize()-9) return load(data, "=" .. file, "bt", _G) end local compo = component local compu = computer _G.screen_x = 1 _G.screen_y = 1 -- init gpu screen = compo.list("screen", true)() gpu = screen and compo.list("gpu", true)() if gpu then gpu = compo.proxy(gpu) _G.gpu = gpu if not gpu.getScreen() then gpu.bind(screen) end _G.boot_screen = gpu.getScreen() w, h = gpu.maxResolution() gpu.setResolution(w, h) gpu.setBackground(0x000000) gpu.setForeground(0xFFFFFF) gpu.fill(1, 1, w, h, " ") end function printk(msg,xOffset) if gpu then if xOffset==nil then xOffset=0 end if _G._JOURNAL then _G.journal_add(msg) end gpu.set(1+xOffset, screen_y, msg) if screen_y == h then gpu.copy(1, 2, w, h - 1, 0, -1) gpu.fill(1, h, w, 1, " ") else screen_y = screen_y + 1 end end end function waitsleep(time) local time_start = os.time() while true do if os.time() - time_start >= time then break end end end printk("set hcf") function hcf() local ts = os.time() while 1 do if os.time() - ts >= 0.5 then coroutine.yield() end end end printk("OSloader v2.1") -- start loading printk("Setting important functions") _G.osloader = {} printk("set osloader.bootinvoke") osloader.bootinvoke = function(a, m, ...) local r = table.pack(pcall(compu.invoke,a,m,...)) if not r[1] then return nil, r[2] else return table.unpack(r, 2, r.n) end end _G.BootAddress = address printk(_G.BootAddress) printk("loading boot flags") local flagsfile, reason = loadfile("/flags.lua") flagsfile() printk("loading kernel at /kernel...") local kernelfile, reason = loadfile("/kernel") kernelfile() hcf()