Skip to content

Commit 228d2fc

Browse files
committed
miniOS NT 0.6.4.3 - Fixed term, Fixed exit command, Improved bootloader.
1 parent c492a66 commit 228d2fc

File tree

5 files changed

+21
-56
lines changed

5 files changed

+21
-56
lines changed

miniOS/command.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- command.lua, a very basic command interpreter for miniOS
22
--are we in miniOS?
3-
if not miniOS then error("This program requires miniOS!") return end
3+
if not miniOS then error("This program requires miniOS!", 0) end
44

55
local shell = {}
66

@@ -282,7 +282,7 @@ while true do
282282
end
283283
end
284284
if shell.runline(line) == "exit" then
285-
miniOS.cmdBat[#miniOS.cmdBat] = nil
285+
if miniOS.cmdBat then miniOS.cmdBat[#miniOS.cmdBat] = nil end
286286
return true
287287
end
288288
end

miniOS/init.lua

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,15 @@
1-
function bootcode()
2-
-- Low level dofile implementation to read the rest of the OS.
3-
local bootfs = {}
4-
function bootfs.invoke(method, ...)
5-
return component.invoke(computer.getBootAddress(), method, ...)
6-
end
7-
function bootfs.open(file) return bootfs.invoke("open", file) end
8-
function bootfs.read(handle) return bootfs.invoke("read", handle, math.huge) end
9-
function bootfs.close(handle) return bootfs.invoke("close", handle) end
10-
function bootfs.inits(file) return ipairs(bootfs.invoke("list", "boot")) end
11-
function bootfs.isDirectory(path) return bootfs.invoke("isDirectory", path) end
12-
-- Custom low-level loadfile/dofile implementation reading from our bootfs.
13-
local function loadfile(file, mode, env)
14-
local handle, reason = bootfs.open(file)
15-
if not handle then
16-
error(reason)
17-
end
18-
local buffer = ""
19-
repeat
20-
local data, reason = bootfs.read(handle)
21-
if not data and reason then
22-
error(reason)
23-
end
24-
buffer = buffer .. (data or "")
25-
until not data
26-
bootfs.close(handle)
27-
if mode == nil then mode = "bt" end
28-
if env == nil then env = _G end
29-
return load(buffer, "=" .. file)
30-
end
31-
_G.loadfile = loadfile
1+
local function loadfile(name)
2+
local handle, reason = component.invoke(computer.getBootAddress(), "open", name)
3+
if not handle then error(reason) end
4+
local buffer = ""
5+
repeat
6+
local data, reason = component.invoke(computer.getBootAddress(), "read", handle, math.huge)
7+
if not data and reason then error(reason) end
8+
buffer = buffer .. (data or "")
9+
until not data
10+
component.invoke(computer.getBootAddress(), "close", handle)
11+
-- Tail call!
12+
return load(buffer, "=" .. name, 'bt', _G)
3213
end
33-
bootcode()
34-
local function dofile(file)
35-
local program, reason = loadfile(file)
36-
if program then
37-
bootcode = nil
38-
loadfile = nil
39-
dofile = nil
40-
local result = table.pack(pcall(program))
41-
if result[1] then
42-
return table.unpack(result, 2, result.n)
43-
else
44-
error(result[2], 3)
45-
end
46-
else
47-
error(reason, 3)
48-
end
49-
end
50-
dofile("miniOS.lua")
14+
-- Tail call!
15+
return loadfile("miniOS.lua")()

miniOS/miniOS.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
_G._OSNAME = "miniOS classic"
2-
_G._OSVER = "0.6.4"
2+
_G._OSVER = "0.6.4.3"
33
_G._OSVERSION = _OSNAME .. " " .. _OSVER
44
_G._OSCREDIT = "miniOS classic by Skye, based off of OpenOS code from OpenComputers.\nminiOS code is under BSD 2-clause licence, OpenOS code is under the MIT licence."
55

@@ -672,15 +672,15 @@ function terminal_code()
672672
term.gpu = function() return component.gpu end
673673
term.getViewport = function()
674674
local w, h = component.gpu.getResolution()
675-
return w, h, 0, 0, 1, cursorY
675+
return w, h, 0, 0, cursorX, cursorY
676676
end
677677
term.getGlobalArea = function(ignored)
678678
local w,h,dx,dy,rx,ry = term.getViewport(window)
679679
return dx+1,dy+1,w,h
680680
end
681681
term.pull = event.pull
682682
term.keyboard = function() return component.keyboard.address end
683-
term.screen = function() return term.gpu().getScreen().address end
683+
term.screen = function() return term.gpu().getScreen() end
684684

685685
local function toggleBlink()
686686
if term.isAvailable() then

miniOS/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
miniOS classic
2-
0.6.4
2+
0.6.4.3
33
Alpha

miniOSNT

Submodule miniOSNT updated from 79f9369 to dc1625b

0 commit comments

Comments
 (0)