initial commit

This commit is contained in:
Redo
2020-05-19 02:22:30 -05:00
commit 1cdffd4e01
203 changed files with 108753 additions and 0 deletions

View File

@ -0,0 +1,34 @@
datablock fxDTSBrickData(LogicGate_TextBrick_Data){
brickFile = $LuaLogic::Path @ "bricks/blb/TextBrick.blb";
category = "Logic Bricks";
subCategory = "Outputs";
uiName = "Text Brick";
iconName = $LuaLogic::Path @ "icons/Text Brick";
hasPrint = 1;
printAspectRatio = "Logic";
orientationFix = 3;
isLogic = true;
isLogicGate = true;
isLogicInput = false;
logicUIName = "Text Brick";
logicUIDesc = "Resets on rise, increments based on pulse length";
logicInit = lualogic_readfile($LuaLogic::Path @ "bricks/outputs/text-init.lua" );
logicUpdate = lualogic_readfile($LuaLogic::Path @ "bricks/outputs/text-update.lua");
numLogicPorts = 1;
logicPortType[0] = 1;
logicPortPos[0] = "0 0 -1";
logicPortDir[0] = 3;
logicPortCauseUpdate[0] = true;
logicPortUIName[0] = "Inc";
};
lualogic_registergatedefinition("LogicGate_TextBrick_Data");
function LogicGate_TextBrick_Data::LuaLogic_Callback(%data, %brick, %printname){
%brick.setPrint(lualogic_getprint(%printname));
}

View File

@ -0,0 +1,35 @@
datablock fxDTSBrickData(LogicGate_TextBrick2_Data){
brickFile = $LuaLogic::Path @ "bricks/blb/TextBrick.blb";
category = "Logic Bricks";
subCategory = "Outputs";
uiName = "Text Brick 2";
iconName = $LuaLogic::Path @ "icons/Text Brick";
hasPrint = 1;
printAspectRatio = "Logic";
orientationFix = 3;
isLogic = true;
isLogicGate = true;
isLogicInput = false;
logicUIName = "Text Brick 2";
logicUIDesc = "Takes 7-bit serial input for ascii character";
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;
logicPortCauseUpdate[0] = true;
logicPortUIName[0] = "In";
};
lualogic_registergatedefinition("LogicGate_TextBrick2_Data");
function LogicGate_TextBrick2_Data::LuaLogic_Callback(%data, %brick, %printname){
%brick.setPrint(lualogic_getprint(%printname));
}

View File

@ -0,0 +1,13 @@
return function(gate)
if gate.ports[1]:isrising() then
gate.tickStarted = gate:gettick()
elseif gate.ports[1]:isfalling() then
local ticksOn = gate:gettick() - gate.tickStarted
local colorid = ((ticksOn-1) % 8)
local colorname = string.reverse(tobitstring(colorid, 3))
gate:cb(colorname)
end
end

124
bricks/outputs/pixel.cs Normal file
View File

@ -0,0 +1,124 @@
datablock fxDTSBrickData(LogicGate_Pixel_Data)
{
brickFile = $LuaLogic::Path @ "bricks/blb/pixels/pixel.blb";
category = "Logic Bricks";
subCategory = "Outputs";
uiName = "Pixel";
iconName = $LuaLogic::Path @ "icons/Pixel";
hasPrint = 1;
printAspectRatio = "Logic";
orientationFix = 3;
isLogic = true;
isLogicGate = true;
isLogicInput = false;
logicUIName = "Pixel";
logicUIDesc = "";
logicUpdate = "return function(gate) gate:cb(bool_to_int[gate.ports[1].state] .. bool_to_int[gate.ports[2].state] .. bool_to_int[gate.ports[3].state]) end";
numLogicPorts = 3;
logicPortType[0] = 1;
logicPortPos[0] = "-1 0 -4";
logicPortDir[0] = 3;
logicPortCauseUpdate[0] = true;
logicPortUIName[0] = "R";
logicPortType[1] = 1;
logicPortPos[1] = "-1 0 0";
logicPortDir[1] = 3;
logicPortCauseUpdate[1] = true;
logicPortUIName[1] = "G";
logicPortType[2] = 1;
logicPortPos[2] = "-1 0 4";
logicPortDir[2] = 3;
logicPortCauseUpdate[2] = true;
logicPortUIName[2] = "B";
};
lualogic_registergatedefinition("LogicGate_Pixel_Data");
function LogicGate_Pixel_Data::LuaLogic_Callback(%this, %brick, %color){
if(lualogic_isprint("COLOR" @ %color))
%brick.setPrint(lualogic_getprint("COLOR" @ %color));
}
datablock fxDTSBrickData(LogicGate_HorizontalPixel_Data : LogicGate_Pixel_Data)
{
brickFile = $LuaLogic::Path @ "bricks/blb/pixels/HPixel.blb";
category = "Logic Bricks";
subCategory = "Outputs";
uiName = "Horizontal Pixel";
iconName = $LuaLogic::Path @ "icons/Horizontal Pixel";
hasPrint = 1;
printAspectRatio = "Logic";
orientationFix = 3;
isLogic = true;
isLogicGate = true;
isLogicInput = false;
logicUIName = "Horizontal Pixel";
logicUIDesc = "";
numLogicPorts = 3;
logicPortType[0] = 1;
logicPortPos[0] = "-1 1 0";
logicPortDir[0] = 5;
logicPortCauseUpdate[0] = true;
logicPortUIName[0] = "R";
logicPortType[1] = 1;
logicPortPos[1] = "-1 -1 0";
logicPortDir[1] = 5;
logicPortCauseUpdate[1] = true;
logicPortUIName[1] = "G";
logicPortType[2] = 1;
logicPortPos[2] = "1 -1 0";
logicPortDir[2] = 5;
logicPortCauseUpdate[2] = true;
logicPortUIName[2] = "B";
};
lualogic_registergatedefinition("LogicGate_HorizontalPixel_Data");
function LogicGate_HorizontalPixel_Data::LuaLogic_Callback(%this, %obj, %data){
LogicGate_Pixel_Data::LuaLogic_Callback(%this, %obj, %data);
}
datablock fxDTSBrickData(LogicGate_SmallPixel_Data){
brickFile = $LuaLogic::Path @ "bricks/blb/TextBrick.blb";
category = "Logic Bricks";
subCategory = "Outputs";
uiName = "Small Pixel";
iconName = $LuaLogic::Path @ "icons/Text Brick";
hasPrint = 1;
printAspectRatio = "Logic";
orientationFix = 3;
isLogic = true;
isLogicGate = true;
isLogicInput = false;
logicUIName = "Small pixel";
logicUIDesc = "Resets on rise, increments based on pulse length";
logicInit = "return function(gate) gate.tickStarted = 0 end";
logicUpdate = lualogic_readfile($LuaLogic::Path @ "bricks/outputs/pixel-update.lua");
numLogicPorts = 1;
logicPortType[0] = 1;
logicPortPos[0] = "0 0 -1";
logicPortDir[0] = 3;
logicPortCauseUpdate[0] = true;
logicPortUIName[0] = "Inc";
};
lualogic_registergatedefinition("LogicGate_SmallPixel_Data");
function LogicGate_SmallPixel_Data::LuaLogic_Callback(%data, %brick, %color){
LogicGate_Pixel_Data::LuaLogic_Callback(%data, %brick, %color);
}

View File

@ -0,0 +1,83 @@
textbrick_idxToPrint = textbrick_idxToPrint or {
[0x00] = "space",
[0x01] = "A",
[0x02] = "B",
[0x03] = "C",
[0x04] = "D",
[0x05] = "E",
[0x06] = "F",
[0x07] = "G",
[0x08] = "H",
[0x09] = "I",
[0x0A] = "J",
[0x0B] = "K",
[0x0C] = "L",
[0x0D] = "M",
[0x0E] = "N",
[0x0F] = "O",
[0x10] = "P",
[0x11] = "Q",
[0x12] = "R",
[0x13] = "S",
[0x14] = "T",
[0x15] = "U",
[0x16] = "V",
[0x17] = "W",
[0x18] = "X",
[0x19] = "Y",
[0x1A] = "Z",
[0x1B] = "0",
[0x1C] = "1",
[0x1D] = "2",
[0x1E] = "3",
[0x1F] = "4",
[0x20] = "5",
[0x21] = "6",
[0x22] = "7",
[0x23] = "8",
[0x24] = "9",
[0x25] = "bang",
[0x26] = "at",
[0x27] = "pound",
[0x28] = "dollar",
[0x29] = "percent",
[0x2A] = "caret",
[0x2B] = "and",
[0x2C] = "asterisk",
[0x2D] = "minus",
[0x2E] = "equals",
[0x2F] = "plus",
[0x30] = "apostrophe",
[0x31] = "less_than",
[0x32] = "greater_than",
[0x33] = "period",
[0x34] = "qmark",
[0x35] = "apostrophe2",
[0x36] = "colon",
[0x37] = "comma",
[0x38] = "curlybracketright",
[0x39] = "curlybracketleft",
[0x3A] = "currencysign",
[0x3B] = "euro",
[0x3C] = "onehalf",
[0x3D] = "poundsymbol",
[0x3E] = "roundbracketright",
[0x3F] = "roundbracketleft",
[0x40] = "slashleft",
[0x41] = "slashright",
[0x42] = "squarebracketright",
[0x43] = "squarebracketleft",
[0x44] = "tilde",
[0x45] = "umlaut",
[0x46] = "underscore",
[0x47] = "verticalbar",
}
return function(gate)
gate.tickStarted = 0
end

View File

@ -0,0 +1,13 @@
return function(gate)
if gate.ports[1]:isrising() then
gate.tickStarted = gate:gettick()
elseif gate.ports[1]:isfalling() then
local ticksOn = gate:gettick() - gate.tickStarted
local printid = ((ticksOn-1) % #textbrick_idxToPrint)
local printname = textbrick_idxToPrint[printid]
gate:cb(printname)
end
end

View File

@ -0,0 +1,146 @@
textbrick2_bitsNeeded = 7
textbrick2_idxToPrint = {
[0x00] = "space",
[0x01] = "space",
[0x02] = "space",
[0x03] = "space",
[0x04] = "space",
[0x05] = "space",
[0x06] = "space",
[0x07] = "space",
[0x08] = "space",
[0x09] = "space",
[0x0A] = "space",
[0x0B] = "space",
[0x0C] = "space",
[0x0D] = "space",
[0x0E] = "space",
[0x0F] = "space",
[0x10] = "space",
[0x11] = "space",
[0x12] = "space",
[0x13] = "space",
[0x14] = "space",
[0x15] = "space",
[0x16] = "space",
[0x17] = "space",
[0x18] = "space",
[0x19] = "space",
[0x1A] = "space",
[0x1B] = "space",
[0x1C] = "space",
[0x1D] = "space",
[0x1E] = "space",
[0x1F] = "space",
[0x20] = "space",
[0x21] = "bang",
[0x22] = "apostrophe2",
[0x23] = "pound",
[0x24] = "dollar",
[0x25] = "percent",
[0x26] = "and",
[0x27] = "apostrophe",
[0x28] = "roundbracketright",
[0x29] = "roundbracketleft",
[0x2A] = "asterisk",
[0x2B] = "plus",
[0x2C] = "comma",
[0x2D] = "minus",
[0x2E] = "period",
[0x2F] = "slashright",
[0x30] = "0",
[0x31] = "1",
[0x32] = "2",
[0x33] = "3",
[0x34] = "4",
[0x35] = "5",
[0x36] = "6",
[0x37] = "7",
[0x38] = "8",
[0x39] = "9",
[0x3A] = "colon",
[0x3B] = "semicolon",
[0x3C] = "less_than",
[0x3D] = "equals",
[0x3E] = "greater_than",
[0x3F] = "qmark",
[0x40] = "at",
[0x41] = "A",
[0x42] = "B",
[0x43] = "C",
[0x44] = "D",
[0x45] = "E",
[0x46] = "F",
[0x47] = "G",
[0x48] = "H",
[0x49] = "I",
[0x4A] = "J",
[0x4B] = "K",
[0x4C] = "L",
[0x4D] = "M",
[0x4E] = "N",
[0x4F] = "O",
[0x50] = "P",
[0x51] = "Q",
[0x52] = "R",
[0x53] = "S",
[0x54] = "T",
[0x55] = "U",
[0x56] = "V",
[0x57] = "W",
[0x58] = "X",
[0x59] = "Y",
[0x5A] = "Z",
[0x5B] = "squarebracketright",
[0x5C] = "slashleft",
[0x5D] = "squarebracketleft",
[0x5E] = "caret",
[0x5F] = "underscore",
[0x60] = "backtick",
[0x61] = "Alcase",
[0x62] = "Blcase",
[0x63] = "Clcase",
[0x64] = "Dlcase",
[0x65] = "Elcase",
[0x66] = "Flcase",
[0x67] = "Glcase",
[0x68] = "Hlcase",
[0x69] = "Ilcase",
[0x6A] = "Jlcase",
[0x6B] = "Klcase",
[0x6C] = "Llcase",
[0x6D] = "Mlcase",
[0x6E] = "Nlcase",
[0x6F] = "Olcase",
[0x70] = "Plcase",
[0x71] = "Qlcase",
[0x72] = "Rlcase",
[0x73] = "Slcase",
[0x74] = "Tlcase",
[0x75] = "Ulcase",
[0x76] = "Vlcase",
[0x77] = "Wlcase",
[0x78] = "Xlcase",
[0x79] = "Ylcase",
[0x7A] = "Zlcase",
[0x7B] = "curlybracketleft",
[0x7C] = "verticalbar",
[0x7D] = "curlybracketright",
[0x7E] = "tilde",
[0x7F] = "space",
[0x80] = "poundsymbol",
[0x81] = "currencysign",
[0x82] = "euro",
[0x83] = "onehalf",
[0x84] = "umlaut",
}

View File

@ -0,0 +1,7 @@
return function(gate)
gate.lastTickChanged = 0
gate.listenState = "wait"
gate.bitsReceived = 0
gate.valReceived = 0
end

View File

@ -0,0 +1,57 @@
local function getBit(gate, val)
--print("get bit", val)
if gate.listenState=="wait" then
if val==1 then
gate.listenState = "getbits"
gate.bitsReceived = 0
--print("", "state = listen")
end
elseif gate.listenState=="getbits" then
gate.valReceived = gate.valReceived + math.pow(2, textbrick2_bitsNeeded-1-gate.bitsReceived)*val
gate.bitsReceived = gate.bitsReceived+1
--print("", "append", gate.bitsReceived-1, val)
if gate.bitsReceived==textbrick2_bitsNeeded then
gate.listenState = "terminate"
end
elseif gate.listenState=="terminate" then
if val==1 then
--print("", "terminate")
local printid = gate.valReceived
local printname = textbrick2_idxToPrint[printid]
gate:cb(printname)
--print("", "set print", string.format("%02x", printid), printname)
end
gate.listenState = "wait"
gate.bitsReceived = 0
gate.valReceived = 0
end
end
local function changeTo(gate, val)
local tick = gate:gettick()
local ticks = tick-gate.lastTickChanged
local bits = math.min(ticks, 10)
for i = 1, bits do
getBit(gate, val)
end
gate.lastTickChanged = tick
end
return function(gate)
if gate.ports[1]:isrising() then
changeTo(gate, 0)
elseif gate.ports[1]:isfalling() then
changeTo(gate, 1)
end
end