From d422d89cf4e433fd52235704aaf00ec78e6e1c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 16 Aug 2014 01:46:48 +0200 Subject: [PATCH 1/3] Add OpenLoader Loot disk --- .../loot/OpenLoader/OpenLoader.man | 16 +++ .../opencomputers/loot/OpenLoader/init.lua | 125 ++++++++++++++++++ .../assets/opencomputers/loot/OpenOS/.osprop | 1 + .../assets/opencomputers/loot/loot.properties | 1 + 4 files changed, 143 insertions(+) create mode 100644 src/main/resources/assets/opencomputers/loot/OpenLoader/OpenLoader.man create mode 100644 src/main/resources/assets/opencomputers/loot/OpenLoader/init.lua create mode 100644 src/main/resources/assets/opencomputers/loot/OpenOS/.osprop diff --git a/src/main/resources/assets/opencomputers/loot/OpenLoader/OpenLoader.man b/src/main/resources/assets/opencomputers/loot/OpenLoader/OpenLoader.man new file mode 100644 index 000000000..c74ecb87f --- /dev/null +++ b/src/main/resources/assets/opencomputers/loot/OpenLoader/OpenLoader.man @@ -0,0 +1,16 @@ +NAME + OpenLoader - A simple bootloader + +DESCRIPTION + A simple bootloader that gives power to chose wich system to boot. + The bootloader searches for init.lua on filesystems. + One drive can contain more than one system/init. Another inits + may be placed into /boot/kernel directory. Entries are labeled + following these rules: + for /boot/kernel, the label is file name + for /init.lua label is contained in /.osprop file, which is + simple lua script returning table with properties. + +EXAMPLE .osprop file: + return {name = "OpenOS"} + diff --git a/src/main/resources/assets/opencomputers/loot/OpenLoader/init.lua b/src/main/resources/assets/opencomputers/loot/OpenLoader/init.lua new file mode 100644 index 000000000..4922ed85b --- /dev/null +++ b/src/main/resources/assets/opencomputers/loot/OpenLoader/init.lua @@ -0,0 +1,125 @@ +_G._OSVERSION = "OpenLoader 0.1" +local component = component or require('component') +local computer = computer or require('computer') +local unicode = unicode or require('unicode') + + +local gpu = component.list("gpu")() +local w, h + +local screen = component.list('screen')() +for address in component.list('screen') do + if #component.invoke(address, 'getKeyboards') > 0 then + screen = address + end +end + +local cls = function()end +if gpu and screen then + component.invoke(gpu, "bind", screen) + w, h = component.invoke(gpu, "getResolution") + component.invoke(gpu, "setResolution", w, h) + component.invoke(gpu, "setBackground", 0x000000) + component.invoke(gpu, "setForeground", 0xFFFFFF) + component.invoke(gpu, "fill", 1, 1, w, h, " ") + cls = function()component.invoke(gpu,"fill", 1, 1, w, h, " ")end +end +local y = 1 +local function status(msg) + if gpu and screen then + component.invoke(gpu, "set", 1, y, msg) + if y == h then + component.invoke(gpu, "copy", 1, 2, w, h - 1, 0, -1) + component.invoke(gpu, "fill", 1, h, w, 1, " ") + else + y = y + 1 + end + end +end + +local function loadfile(fs, file) + --status("> " .. file) + local handle, reason = component.invoke(fs,"open",file) + if not handle then + error(reason) + end + local buffer = "" + repeat + local data, reason = component.invoke(fs,"read",handle,math.huge) + if not data and reason then + error(reason) + end + buffer = buffer .. (data or "") + until not data + component.invoke(fs,"close",handle) + return load(buffer, "=" .. file) +end + +local function dofile(fs, file) + local program, reason = loadfile(fs, file) + if program then + local result = table.pack(pcall(program)) + if result[1] then + return table.unpack(result, 2, result.n) + else + error(result[2]) + end + else + error(reason) + end +end + +local function boot(kernel) + status("BOOTING") + _G.computer.getBootAddress = function()return kernel.address end + cls() + dofile(kernel.address, kernel.fpx .. kernel.file) +end + +status("OpenLoader") +status("Select what to boot:") + +local osList = {} + +for fs in component.list("filesystem") do + if component.invoke(fs, "isDirectory", "boot/kernel/")then + for _,file in ipairs(component.invoke(fs, "list", "boot/kernel/")) do + osList[#osList+1] = {fpx = "boot/kernel/", file = file, address = fs} + status(tostring(#osList).."."..file.." from "..(fs:sub(1,3))) + end + end + if fs ~= computer.getBootAddress() and component.invoke(fs, "exists", "init.lua") then + local osName = "init.lua" + if component.invoke(fs, "exists", ".osprop") then + pcall(function() + local prop = dofile(fs, ".osprop") + osName = (prop and prop.name) or "init.lua" + end) + end + osList[#osList+1] = {fpx = "", file = "init.lua", address = fs} + status(tostring(#osList).."."..osName.." from "..(fs:sub(1,3))) + end +end +status("Select os: ") +if #osList == 1 then + boot(osList[1]) +end +if #osList == 0 then + error("No OS found") + while true do computer.pullSignal() end +end +while true do + local sig = {computer.pullSignal()} + if sig[1] == "key_down" then + if sig[4] >= 2 and sig[4] <= 11 then + if osList[sig[4]-1] then + boot(osList[sig[4]-1]) + else + status("Not found!") + end + end + end +end +error("System crashed") +while true do computer.pullSignal() end + diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/.osprop b/src/main/resources/assets/opencomputers/loot/OpenOS/.osprop new file mode 100644 index 000000000..b2dc1ceff --- /dev/null +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/.osprop @@ -0,0 +1 @@ +return {name = "OpenOS"} diff --git a/src/main/resources/assets/opencomputers/loot/loot.properties b/src/main/resources/assets/opencomputers/loot/loot.properties index 3ddab9ce5..39c90ea9b 100644 --- a/src/main/resources/assets/opencomputers/loot/loot.properties +++ b/src/main/resources/assets/opencomputers/loot/loot.properties @@ -7,6 +7,7 @@ BetterShell=besh Builder=build:1:dyeCyan OpenIRC=irc:1:dyeRed +OpenLoader=openloader:1:dyeOrange OpenOS=openos:1:dyeGreen MazeGen=maze:1:dyeBrown OPPM=oppm:1:dyeLime From c4d860ceaffa5c53d43dfdd2261e2dc55130b891 Mon Sep 17 00:00:00 2001 From: Dwayne Slater Date: Mon, 18 Aug 2014 08:03:32 -0400 Subject: [PATCH 2/3] space space I wanna go to space QUICK: WHAT'S THE SITUATION? Oh, hey, hi pretty lady. My name's Rick. So, you out having a little adventure? What's your favorite thing about space? Mine is space. The likelihood of you dying violently within the next five minutes is eighty-seven point six one percent. --- src/main/resources/assets/opencomputers/robot.names | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/resources/assets/opencomputers/robot.names b/src/main/resources/assets/opencomputers/robot.names index 8dafa5947..6da6e4738 100644 --- a/src/main/resources/assets/opencomputers/robot.names +++ b/src/main/resources/assets/opencomputers/robot.names @@ -38,6 +38,9 @@ Terminator T-800 Wheatley Rosie Uniblab +Space Core +Fact Core +Adventure Core # Perry Rhodan Robots, definitly not all... Anson Argyris From 65f5806a9368d7b4f26fdd6e7609ea844e081585 Mon Sep 17 00:00:00 2001 From: Dwayne Slater Date: Mon, 18 Aug 2014 16:18:50 -0400 Subject: [PATCH 3/3] sortato. SPAAAAAAAAAAAAAAAAAAAAAAACE. --- src/main/resources/assets/opencomputers/robot.names | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/assets/opencomputers/robot.names b/src/main/resources/assets/opencomputers/robot.names index 6da6e4738..6b4e15122 100644 --- a/src/main/resources/assets/opencomputers/robot.names +++ b/src/main/resources/assets/opencomputers/robot.names @@ -17,12 +17,14 @@ Kilobyte # Names of more or less famous robots, as a bit of filler material. Feel free # to add more via pull requests. Let's hope this won't get us sued... +Adventure Core Atlas Bender C-3PO Clank Claptrap Dog +Fact Core GLaDOS HAL 9000 Heron @@ -33,14 +35,12 @@ Marvin P-Body R2-D2 Skynet +Space Core Terminator T-1000 Terminator T-800 Wheatley Rosie Uniblab -Space Core -Fact Core -Adventure Core # Perry Rhodan Robots, definitly not all... Anson Argyris