implement proper tape support, also speed up loading from tapes.
This commit is contained in:
parent
2e959ebbbf
commit
a144937e24
@ -1,10 +1,11 @@
|
||||
return (function()
|
||||
local component = component
|
||||
function computer.getBootAddress()
|
||||
return component.invoke(component.list("eeprom")(),"getData")
|
||||
end
|
||||
function computer.setBootAddress(a)
|
||||
return component.invoke(component.list("eeprom")(),"setData",a)
|
||||
end
|
||||
return (function()
|
||||
local rv
|
||||
local function getProxy(addr)
|
||||
if type(addr) == "string" then
|
||||
@ -13,14 +14,22 @@ local function getProxy(addr)
|
||||
return addr
|
||||
end
|
||||
local function aop(td,n,mn,...)
|
||||
local rv
|
||||
if td.getPosition then
|
||||
local rts = td.getPosition()
|
||||
if rts ~= n then
|
||||
td.seek(n - rts)
|
||||
end
|
||||
rv = {td[mn](...)}
|
||||
else
|
||||
local rts = td.seek(-math.huge)
|
||||
td.seek(n)
|
||||
local rv = {td[mn](...)}
|
||||
rv = {td[mn](...)}
|
||||
td.seek(-math.huge)
|
||||
td.seek(rts)
|
||||
end
|
||||
return table.unpack(rv)
|
||||
end
|
||||
|
||||
local eformat = "c20c4>I4>I4"
|
||||
function parsePartitions(s)
|
||||
local rt = {}
|
||||
@ -33,7 +42,6 @@ function parsePartitions(s)
|
||||
end
|
||||
return rt
|
||||
end
|
||||
|
||||
function getPartitions(drive)
|
||||
local rv
|
||||
if drive.type == "tape_drive" then
|
||||
@ -45,7 +53,6 @@ function getPartitions(drive)
|
||||
end
|
||||
return rv[1][2] == "mtpt" and rv
|
||||
end
|
||||
|
||||
local function offsetSector(part,sector)
|
||||
if sector < 1 or sector > part[4] then error("invalid offset, not in a usable sector") end
|
||||
return (part[3] - 1) + sector
|
||||
@ -54,16 +61,16 @@ local function readSector(drive,part,sector)
|
||||
return drive.readSector(offsetSector(part,sector)):gsub("\0+$","")
|
||||
end
|
||||
local function readPart(drive,part)
|
||||
if drive.type == "tape_drive" then
|
||||
return aop(drive, (part[3]-1)*512, "read", part[4] * 512)
|
||||
end
|
||||
local rv = ""
|
||||
for i = 1, part[4] do
|
||||
if drive.type == "tape_drive" then
|
||||
rv=rv .. aop(drive, ((part[3]-2) + i)*512, "read", 512):gsub("\0+$","")
|
||||
else
|
||||
rv=rv .. readSector(drive,part,i)
|
||||
end
|
||||
end
|
||||
return rv
|
||||
end
|
||||
|
||||
local pB = computer.getBootAddress()
|
||||
local candidates={pB,[pB] = true}
|
||||
if not component.type(pB) then candidates[1] = nil end
|
||||
@ -71,11 +78,10 @@ for a,t in component.list() do
|
||||
candidates[#candidates+1] = not candidates[a] and (t == "drive" or t == "filesystem" or t == "tape_drive") and a or nil
|
||||
candidates[a] = true
|
||||
end
|
||||
|
||||
local function wL()
|
||||
return false
|
||||
end
|
||||
local cL = wL
|
||||
local cL=wL
|
||||
local ga, sa = component.list("gpu")(), component.list("screen")()
|
||||
if ga and sa then
|
||||
local g, cl = component.proxy(ga), 1
|
||||
@ -110,7 +116,6 @@ if ga and sa then
|
||||
end
|
||||
until computer.uptime() >= to
|
||||
end
|
||||
|
||||
for i,a in ipairs(candidates) do
|
||||
computer.beep(("."):rep(i))
|
||||
wL("Attempting to load from "..a)
|
||||
|
Loading…
Reference in New Issue
Block a user