1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-23 10:38:05 +11:00

improved the minifier significantly, added miniprompt, and fixed some bugs in microtel

This commit is contained in:
Izaya 2018-05-19 13:36:32 +10:00
parent e9df741396
commit 73694b480f
10 changed files with 96 additions and 15 deletions

View File

@ -1,20 +1,20 @@
{ {
{"eventTab","Z"}, {"eventTab","Z"},
{"modems","M"}, {"modems","M"},
{"qPacket","qP"}, {"qPacket","A"},
{"packetID","pID"}, {"packetID","B"},
{"packetType","pT"}, {"packetType","E"},
{"to","T"}, {"to","T"},
{"vport","vP"}, {"vport","F"},
{"data","D"}, {"data","D"},
{"rawSendPacket","rS"}, {"rawSendPacket","G"},
{"sendPacket","sP"}, {"sendPacket","I"},
{"genPacketID","gP"}, {"genPacketID","J"},
{"packetCache","pC"}, {"packetCache","L"},
{"checkCache","cC"}, {"checkCache","N"},
{"routeCache","rC"}, {"routeCache","O"},
{"realComputerPullSignal","rCPE"}, {"realComputerPullSignal","X"},
{"packetQueue","pQ"}, {"packetQueue","P"},
{"computer","C"}, {"computer","C"},
{"C.uptime","U"}, {"C.uptime","U"},
{"table.unpack","Y"}, {"table.unpack","Y"},

View File

@ -0,0 +1,24 @@
{
{"eventTab","Z"},
{"modems","M"},
{"qPacket","qP"},
{"packetID","pID"},
{"packetType","pT"},
{"to","T"},
{"vport","vP"},
{"data","D"},
{"rawSendPacket","rS"},
{"sendPacket","sP"},
{"genPacketID","gP"},
{"packetCache","pC"},
{"checkCache","cC"},
{"routeCache","rC"},
{"realComputerPullSignal","rCPE"},
{"packetQueue","pQ"},
{"computer","C"},
{"C.uptime","U"},
{"table.unpack","Y"},
{"COMPUTER","computer"},
{"UPTIME","C.uptime"},
{"UNPACK","table.unpack"},
}

View File

@ -1,7 +1,7 @@
function net.socket(address, port, sclose) function net.socket(address, port, sclose)
local conn, rb = {}, "" local conn, rb = {}, ""
conn.state, conn.buffer, conn.port, conn.address = "o", "", tonumber(port), address conn.state, conn.buffer, conn.port, conn.address = "o", "", tonumber(port), address
function conn.r(self,length) function conn.r(self,l)
rb=self.buffer:sub(1,l) rb=self.buffer:sub(1,l)
self.buffer=self.buffer:sub(l+1) self.buffer=self.buffer:sub(l+1)
return rb return rb

View File

@ -5,6 +5,9 @@
{"port","P"}, {"port","P"},
{"conn.state","conn.s"}, {"conn.state","conn.s"},
{"conn.buffer","conn.b"}, {"conn.buffer","conn.b"},
{"self.buffer","self.b"},
{"self.state","self.s"},
{"self","s"},
{"conn","C"}, {"conn","C"},
{"etype","E"}, {"etype","E"},
{"from","F"}, {"from","F"},

View File

@ -1,7 +1,7 @@
net.timeout = 60 net.timeout = 60
function net.open(address,vport) function net.open(address,vport)
local st,from,port,data=computer.uptime() local st,from,port,data=computer.uptime()
net.send(address,port,"openstream") net.send(address,vport,"openstream")
repeat repeat
_, from, port, data = computer.pullSignal(0.5) _, from, port, data = computer.pullSignal(0.5)
if computer.uptime() > st+net.timeout then return false end if computer.uptime() > st+net.timeout then return false end
@ -10,5 +10,5 @@ function net.open(address,vport)
repeat repeat
_, from, port, data = computer.pullSignal(0.5) _, from, port, data = computer.pullSignal(0.5)
until from == address and port == vport until from == address and port == vport
return socket(address,vport,data) return net.socket(address,vport,data)
end end

View File

@ -31,6 +31,9 @@ local replacements={
{" %* ","*"}, {" %* ","*"},
{" \n","\n"}, {" \n","\n"},
{" %.%. ",".."}, {" %.%. ",".."},
{"([%)%}])%s(%a)","%1%2"},
{"(%d)%s([G-Zg-z])","%1%2"},
{"([\"'])%s(%a)","%1%2"},
{"%-%-.-\n",""}, {"%-%-.-\n",""},
} }

35
Embedded/miniprompt.lua Normal file
View File

@ -0,0 +1,35 @@
local ga,sa = component.list("gpu")(),component.list("screen")()
GPU = component.proxy(ga)
GPU.bind(sa)
write = vt100emu(GPU)
function print(...)
for k,v in pairs({...}) do
write(tostring(v).."\n")
end
end
function read()
local sBuffer = ""
repeat
local tSignal = {computer.pullSignal()}
if tSignal[1] == "key_down" then
if tSignal[3] > 31 and tSignal[3] < 127 then
write(string.char(tSignal[3]))
sBuffer = sBuffer .. string.char(tSignal[3])
elseif tSignal[3] == 8 and tSignal[4] == 14 and S:len() > 0 then
write("\8 \8")
sBuffer = sBuffer:sub(1,-2)
end
end
until tSignal[1] == "key_down" and tSignal[3] == 13 and tSignal[4] == 28
write("\n")
return sBuffer
end
--API
while true do
write(_VERSION.."> ")
tResult = {pcall(load(read()))}
for k,v in pairs(tResult) do
print(v)
end
end

View File

@ -0,0 +1,12 @@
{
{"write","W"},
{"print","P"},
{"read","R"},
{"tSignal","T"},
{"sBuffer","S"},
{"tResult","V"},
{"GPU","B"},
{"ga","N"},
{"sa","M"},
{"%-%-API","read,write,print=R,W,P"},
}

View File

@ -0,0 +1,3 @@
{
{"component","GC"},
}

View File

@ -16,4 +16,5 @@
{"my","H"}, {"my","H"},
{"sx","T"}, {"sx","T"},
{"sy","U"}, {"sy","U"},
{"mode","M"},
} }