add terminal prints

This commit is contained in:
Redo
2022-11-09 23:48:24 -06:00
parent 794d046db8
commit d5fb2b33b7
5 changed files with 499 additions and 174 deletions

View File

@ -8,20 +8,20 @@ datablock fxDTSBrickData(LogicGate_TextBrick2_Data){
hasPrint = 1;
printAspectRatio = "Logic";
orientationFix = 3;
isLogic = true;
isLogicGate = true;
isLogicInput = false;
logicUIName = "Text Brick";
logicUIDesc = "Takes 7-bit serial input for ascii character, format 1xxxxxxx10, MSB first";
logicUIDesc = "Takes 9-bit serial input of format 1cxxxxxxxx10. If c==0, x = 8-bit ascii code. If c==1, lower 6 bits of x = color ID, top bit = invert character. MSB first.";
logicInit = lualogic_readfile($LuaLogic::Path @ "bricks/outputs/text2-init.lua" );
logicUpdate = lualogic_readfile($LuaLogic::Path @ "bricks/outputs/text2-update.lua");
logicGlobal = lualogic_readfile($LuaLogic::Path @ "bricks/outputs/text2-global.lua");
numLogicPorts = 1;
logicPortType[0] = 1;
logicPortPos[0] = "0 0 -1";
logicPortDir[0] = 3;
@ -30,8 +30,12 @@ datablock fxDTSBrickData(LogicGate_TextBrick2_Data){
};
lualogic_registergatedefinition("LogicGate_TextBrick2_Data");
function LogicGate_TextBrick2_Data::LuaLogic_Callback(%data, %brick, %printname){
%brick.setPrint(lualogic_getprint(%printname));
function LogicGate_TextBrick2_Data::LuaLogic_Callback(%data, %brick, %arg) {
%colorId = getWord(%arg, 0);
if(%colorId != -1) %brick.setColor(%colorId);
%domain = getWord(%arg, 1);
%print = getWord(%arg, 2);
if(%domain !$= "_" && %print !$= "") %brick.setPrint(lualogic_getprint(%print, %domain));
}
@ -43,7 +47,7 @@ datablock fxDtsBrickData(LogicGate_TextBrick2Top2_Data : LogicGate_TextBrick2_Da
logicPortPos[0] = "0 0 0";
};
lualogic_registergatedefinition("LogicGate_TextBrick2Top2_Data");
function LogicGate_TextBrick2Top2_Data::LuaLogic_Callback(%data, %brick, %printname){
function LogicGate_TextBrick2Top2_Data::LuaLogic_Callback(%data, %brick, %printname) {
LogicGate_TextBrick2_Data::LuaLogic_Callback(%data, %brick, %printname);
}
@ -53,6 +57,6 @@ datablock fxDtsBrickData(LogicGate_TextBrick2Bottom2_Data : LogicGate_TextBrick2
logicPortPos[0] = "0 0 0";
};
lualogic_registergatedefinition("LogicGate_TextBrick2Bottom2_Data");
function LogicGate_TextBrick2Bottom2_Data::LuaLogic_Callback(%data, %brick, %printname){
function LogicGate_TextBrick2Bottom2_Data::LuaLogic_Callback(%data, %brick, %printname) {
LogicGate_TextBrick2_Data::LuaLogic_Callback(%data, %brick, %printname);
}

View File

@ -1,5 +1,5 @@
textbrick2_bitsNeeded = 7
textbrick2_bitsNeeded = 9
textbrick2_idxToPrint = {
[0x00] = "space",
@ -138,9 +138,139 @@ textbrick2_idxToPrint = {
[0x7E] = "tilde",
[0x7F] = "space",
[0x80] = "poundsymbol",
[0x81] = "currencysign",
[0x82] = "euro",
[0x83] = "onehalf",
[0x84] = "umlaut",
[0x80] = "space",
[0x81] = "space",
[0x82] = "space",
[0x83] = "space",
[0x84] = "space",
[0x85] = "space",
[0x86] = "space",
[0x87] = "space",
[0x88] = "space",
[0x89] = "space",
[0x8A] = "space",
[0x8B] = "space",
[0x8C] = "space",
[0x8D] = "space",
[0x8E] = "space",
[0x8F] = "space",
[0x90] = "space",
[0x91] = "space",
[0x92] = "space",
[0x93] = "space",
[0x94] = "space",
[0x95] = "space",
[0x96] = "space",
[0x97] = "space",
[0x98] = "space",
[0x99] = "space",
[0x9A] = "space",
[0x9B] = "space",
[0x9C] = "space",
[0x9D] = "space",
[0x9E] = "space",
[0x9F] = "space",
[0xA0] = "jp-yen",
[0xA1] = "jp-period",
[0xA2] = "jp-left-bracket",
[0xA3] = "jp-right-bracket",
[0xA4] = "jp-comma",
[0xA5] = "jp-dot",
[0xA6] = "jp-wo",
[0xA7] = "jp-small-a",
[0xA8] = "jp-small-i",
[0xA9] = "jp-small-u",
[0xAA] = "jp-small-e",
[0xAB] = "jp-small-o",
[0xAC] = "jp-small-ya",
[0xAD] = "jp-small-yu",
[0xAE] = "jp-small-yo",
[0xAF] = "jp-small-tsu",
[0xB0] = "jp-dash",
[0xB1] = "jp-a",
[0xB2] = "jp-i",
[0xB3] = "jp-u",
[0xB4] = "jp-e",
[0xB5] = "jp-o",
[0xB6] = "jp-ka",
[0xB7] = "jp-ki",
[0xB8] = "jp-ku",
[0xB9] = "jp-ke",
[0xBA] = "jp-ko",
[0xBB] = "jp-sa",
[0xBC] = "jp-shi",
[0xBD] = "jp-su",
[0xBE] = "jp-se",
[0xBF] = "jp-so",
[0xC0] = "jp-ta",
[0xC1] = "jp-chi",
[0xC2] = "jp-tsu",
[0xC3] = "jp-te",
[0xC4] = "jp-to",
[0xC5] = "jp-na",
[0xC6] = "jp-ni",
[0xC7] = "jp-nu",
[0xC8] = "jp-ne",
[0xC9] = "jp-no",
[0xCA] = "jp-ha",
[0xCB] = "jp-hi",
[0xCC] = "jp-fu",
[0xCD] = "jp-he",
[0xCE] = "jp-ho",
[0xCF] = "jp-ma",
[0xD0] = "jp-mi",
[0xD1] = "jp-mu",
[0xD2] = "jp-me",
[0xD3] = "jp-mo",
[0xD4] = "jp-ya",
[0xD5] = "jp-yu",
[0xD6] = "jp-yo",
[0xD7] = "jp-ra",
[0xD8] = "jp-ri",
[0xD9] = "jp-ru",
[0xDA] = "jp-re",
[0xDB] = "jp-ro",
[0xDC] = "jp-wa",
[0xDD] = "jp-n",
[0xDE] = "jp-dakuten",
[0xDF] = "jp-handakuten",
[0xE0] = "space",
[0xE1] = "space",
[0xE2] = "space",
[0xE3] = "space",
[0xE4] = "space",
[0xE5] = "space",
[0xE6] = "space",
[0xE7] = "space",
[0xE8] = "space",
[0xE9] = "space",
[0xEA] = "space",
[0xEB] = "space",
[0xEC] = "space",
[0xED] = "space",
[0xEE] = "space",
[0xEF] = "space",
[0xF0] = "space",
[0xF1] = "space",
[0xF2] = "space",
[0xF3] = "space",
[0xF4] = "space",
[0xF5] = "space",
[0xF6] = "space",
[0xF7] = "space",
[0xF8] = "space",
[0xF9] = "space",
[0xFA] = "space",
[0xFB] = "space",
[0xFC] = "space",
[0xFD] = "space",
[0xFE] = "space",
[0xFF] = "space",
}

View File

@ -2,33 +2,33 @@
local function getBit(gate, val)
local gatedata = Gate.getdata(gate)
--print("get bit", val)
if gatedata.listenState=="wait" then
if val==1 then
gatedata.listenState = "getbits"
gatedata.bitsReceived = 0
--print("", "state = listen")
end
elseif gatedata.listenState=="getbits" then
gatedata.valReceived = gatedata.valReceived + math.pow(2, textbrick2_bitsNeeded-1-gatedata.bitsReceived)*val
gatedata.bitsReceived = gatedata.bitsReceived+1
--print("", "append", gatedata.bitsReceived-1, val)
if gatedata.bitsReceived==textbrick2_bitsNeeded then
gatedata.listenState = "terminate"
end
elseif gatedata.listenState=="terminate" then
if val==1 then
--print("", "terminate")
local printid = gatedata.valReceived
local printname = textbrick2_idxToPrint[printid]
Gate.cb(gate, printname)
--print("", "set print", string.format("%02x", printid), printname)
local v = gatedata.valReceived
local iscolor = math.floor(v/512)==1 -- first bit
if iscolor then
local printdomain = (math.floor(v/128)%2)==1 and "terminal" or "terminalInv" -- 8th lowest bit
local colorid = v % 64 -- last 6 bits
gatedata.printdomain = printdomain
gatedata.colorid = colorid
else
local printid = v % 256 -- last 8 bits
local printname = textbrick2_idxToPrint[printid] or "space"
gatedata.printname = printname
end
Gate.cb(gate, (gatedata.colorid or -1).." "..(gatedata.printdomain or "terminal").." "..(gatedata.printname or "_"))
end
gatedata.listenState = "wait"