add rom brick
This commit is contained in:
parent
7bd5fe696d
commit
de586ff608
@ -23,6 +23,7 @@ exec("./outputs/Pixel3.cs");
|
|||||||
exec("./outputs/TextBrick2.cs");
|
exec("./outputs/TextBrick2.cs");
|
||||||
|
|
||||||
exec("./special/EventGate.cs");
|
exec("./special/EventGate.cs");
|
||||||
|
exec("./special/rom.cs");
|
||||||
|
|
||||||
exec("./big/cpu1.cs");
|
exec("./big/cpu1.cs");
|
||||||
exec("./big/ram8x12.cs");
|
exec("./big/ram8x12.cs");
|
||||||
|
@ -271,3 +271,4 @@ exec("./newcode/Demux 5 Bit.cs");
|
|||||||
exec("./newcode/Demux 5 Bit Vertical.cs");
|
exec("./newcode/Demux 5 Bit Vertical.cs");
|
||||||
exec("./newcode/Demux 6 Bit.cs");
|
exec("./newcode/Demux 6 Bit.cs");
|
||||||
exec("./newcode/Demux 6 Bit Vertical.cs");
|
exec("./newcode/Demux 6 Bit Vertical.cs");
|
||||||
|
exec("./newcode/ROM 16x16.cs");
|
||||||
|
1220
bricks/gen/newbricks/ROM 16x16.blb
Normal file
1220
bricks/gen/newbricks/ROM 16x16.blb
Normal file
File diff suppressed because it is too large
Load Diff
118
bricks/gen/newcode/ROM 16x16.cs
Normal file
118
bricks/gen/newcode/ROM 16x16.cs
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
|
||||||
|
datablock fxDtsBrickData(LogicGate_Rom16x16_Data){
|
||||||
|
brickFile = $LuaLogic::Path @ "bricks/gen/newbricks/ROM 16x16.blb";
|
||||||
|
iconName = $LuaLogic::Path @ "bricks/gen/newicons/ROM 16x16";
|
||||||
|
|
||||||
|
category = "Logic Bricks";
|
||||||
|
subCategory = "Special I/O";
|
||||||
|
uiName = "ROM 16x16";
|
||||||
|
logicUIName = "ROM 16x16";
|
||||||
|
logicUIDesc = "";
|
||||||
|
|
||||||
|
hasPrint = 1;
|
||||||
|
printAspectRatio = "Logic";
|
||||||
|
|
||||||
|
logicBrickSize = "16 16 1";
|
||||||
|
orientationFix = 3;
|
||||||
|
|
||||||
|
isLogic = true;
|
||||||
|
isLogicGate = true;
|
||||||
|
isLogicInput = false;
|
||||||
|
|
||||||
|
logicInit =
|
||||||
|
"return function(gate) " @
|
||||||
|
" gate.romdata = {} " @
|
||||||
|
" for i = 0, 255 do " @
|
||||||
|
" gate.romdata[i] = false " @
|
||||||
|
" end " @
|
||||||
|
"end"
|
||||||
|
;
|
||||||
|
logicInput =
|
||||||
|
"return function(gate, args) " @
|
||||||
|
" local data = args[1] " @
|
||||||
|
" for i = 1, #data do " @
|
||||||
|
" local c = data:sub(i, i) " @
|
||||||
|
" gate.romdata[i-1] = (c==\"1\") " @
|
||||||
|
" end " @
|
||||||
|
" Gate.queue(gate, 0) " @
|
||||||
|
"end"
|
||||||
|
;
|
||||||
|
logicUpdate =
|
||||||
|
"return function(gate) " @
|
||||||
|
" local addr = (Gate.getportstate(gate, 1) and 1 or 0) " @
|
||||||
|
" + (Gate.getportstate(gate, 2) and 2 or 0) " @
|
||||||
|
" + (Gate.getportstate(gate, 3) and 4 or 0) " @
|
||||||
|
" + (Gate.getportstate(gate, 4) and 8 or 0) " @
|
||||||
|
" + (Gate.getportstate(gate, 5) and 16 or 0) " @
|
||||||
|
" + (Gate.getportstate(gate, 6) and 32 or 0) " @
|
||||||
|
" + (Gate.getportstate(gate, 7) and 64 or 0) " @
|
||||||
|
" + (Gate.getportstate(gate, 8) and 128 or 0) " @
|
||||||
|
" Gate.setportstate(gate, 9, gate.romdata[addr]) " @
|
||||||
|
"end"
|
||||||
|
;
|
||||||
|
logicGlobal = "";
|
||||||
|
|
||||||
|
numLogicPorts = 9;
|
||||||
|
|
||||||
|
isLogicRom = true;
|
||||||
|
logicRomY = 16;
|
||||||
|
logicRomX = 16;
|
||||||
|
|
||||||
|
logicPortType[0] = 1;
|
||||||
|
logicPortPos[0] = "15 -15 0";
|
||||||
|
logicPortDir[0] = 3;
|
||||||
|
logicPortUIName[0] = "Addr0";
|
||||||
|
logicPortCauseUpdate[0] = true;
|
||||||
|
|
||||||
|
logicPortType[1] = 1;
|
||||||
|
logicPortPos[1] = "13 -15 0";
|
||||||
|
logicPortDir[1] = 3;
|
||||||
|
logicPortUIName[1] = "Addr1";
|
||||||
|
logicPortCauseUpdate[1] = true;
|
||||||
|
|
||||||
|
logicPortType[2] = 1;
|
||||||
|
logicPortPos[2] = "11 -15 0";
|
||||||
|
logicPortDir[2] = 3;
|
||||||
|
logicPortUIName[2] = "Addr2";
|
||||||
|
logicPortCauseUpdate[2] = true;
|
||||||
|
|
||||||
|
logicPortType[3] = 1;
|
||||||
|
logicPortPos[3] = "9 -15 0";
|
||||||
|
logicPortDir[3] = 3;
|
||||||
|
logicPortUIName[3] = "Addr3";
|
||||||
|
logicPortCauseUpdate[3] = true;
|
||||||
|
|
||||||
|
logicPortType[4] = 1;
|
||||||
|
logicPortPos[4] = "7 -15 0";
|
||||||
|
logicPortDir[4] = 3;
|
||||||
|
logicPortUIName[4] = "Addr4";
|
||||||
|
logicPortCauseUpdate[4] = true;
|
||||||
|
|
||||||
|
logicPortType[5] = 1;
|
||||||
|
logicPortPos[5] = "5 -15 0";
|
||||||
|
logicPortDir[5] = 3;
|
||||||
|
logicPortUIName[5] = "Addr5";
|
||||||
|
logicPortCauseUpdate[5] = true;
|
||||||
|
|
||||||
|
logicPortType[6] = 1;
|
||||||
|
logicPortPos[6] = "3 -15 0";
|
||||||
|
logicPortDir[6] = 3;
|
||||||
|
logicPortUIName[6] = "Addr6";
|
||||||
|
logicPortCauseUpdate[6] = true;
|
||||||
|
|
||||||
|
logicPortType[7] = 1;
|
||||||
|
logicPortPos[7] = "1 -15 0";
|
||||||
|
logicPortDir[7] = 3;
|
||||||
|
logicPortUIName[7] = "Addr7";
|
||||||
|
logicPortCauseUpdate[7] = true;
|
||||||
|
|
||||||
|
logicPortType[8] = 0;
|
||||||
|
logicPortPos[8] = "15 15 0";
|
||||||
|
logicPortDir[8] = 1;
|
||||||
|
logicPortUIName[8] = "Out";
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
function LogicGate_Rom16x16_Data::Logic_onAdd(%data, %brick) {
|
||||||
|
lualogic_rom_updatedata(%brick);
|
||||||
|
}
|
BIN
bricks/gen/newicons/ROM 16x16.png
Normal file
BIN
bricks/gen/newicons/ROM 16x16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 735 B |
@ -2,7 +2,7 @@
|
|||||||
datablock fxDTSBrickData(LogicGate_Keyboard_Data){
|
datablock fxDTSBrickData(LogicGate_Keyboard_Data){
|
||||||
brickFile = $LuaLogic::Path @ "bricks/blb/keyboardgate.blb";
|
brickFile = $LuaLogic::Path @ "bricks/blb/keyboardgate.blb";
|
||||||
category = "Logic Bricks";
|
category = "Logic Bricks";
|
||||||
subCategory = "Inputs";
|
subCategory = "Special I/O";
|
||||||
uiName = "Input Keyboard";
|
uiName = "Input Keyboard";
|
||||||
iconName = $LuaLogic::Path @ "icons/Input Keyboard";
|
iconName = $LuaLogic::Path @ "icons/Input Keyboard";
|
||||||
orientationFix = 3;
|
orientationFix = 3;
|
||||||
|
150
bricks/special/rom.cs
Normal file
150
bricks/special/rom.cs
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
|
||||||
|
function rom_reload() {
|
||||||
|
exec($Con::File);
|
||||||
|
exec($LuaLogic::Path @ "bricks/gen/newcode/ROM 16x16.cs");
|
||||||
|
}
|
||||||
|
|
||||||
|
package lualogic_rom_update {
|
||||||
|
function fxDtsBrick::onPlant(%brick) {
|
||||||
|
parent::onPlant(%brick);
|
||||||
|
lualogic_rom_createbrick(%brick);
|
||||||
|
}
|
||||||
|
function fxDtsBrick::onLoadPlant(%brick) {
|
||||||
|
parent::onLoadPlant(%brick);
|
||||||
|
lualogic_rom_createbrick(%brick);
|
||||||
|
}
|
||||||
|
function fxDTSBrick::onDeath(%brick) {
|
||||||
|
parent::onDeath(%brick);
|
||||||
|
if(%brick.lualogic_rom_affects) {
|
||||||
|
lualogic_rom_deletebrick(%brick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function fxDTSBrick::onRemove(%brick) {
|
||||||
|
parent::onRemove(%brick);
|
||||||
|
if(%brick.lualogic_rom_affects) {
|
||||||
|
lualogic_rom_deletebrick(%brick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function fxDtsBrick::setRaycasting(%brick, %val) {
|
||||||
|
parent::setRaycasting(%brick, %val);
|
||||||
|
if(%brick.lualogic_rom_affects) {
|
||||||
|
lualogic_rom_updatercbrick(%brick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
schedule(0, 0, activatePackage, lualogic_rom_update);
|
||||||
|
|
||||||
|
// lualogic_rom_affects: whether this brick is on top of a rom brick
|
||||||
|
// lualogic_rom_is: whether this brick is a rom brick
|
||||||
|
|
||||||
|
function lualogic_rom_createbrick(%brick) {
|
||||||
|
%brick.lualogic_rom_delete = 0;
|
||||||
|
|
||||||
|
//if rom: set is, set affects on any up bricks, compute data
|
||||||
|
if(%brick.getdatablock().isLogicRom) {
|
||||||
|
%brick.lualogic_rom_is = 1;
|
||||||
|
|
||||||
|
%nub = 0;
|
||||||
|
for(%i=0; %i<%nub; %i++) {
|
||||||
|
%upbrick = %brick.getUpBrick(%i);
|
||||||
|
%upbrick.lualogic_rom_affects = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
lualogic_rom_updatedata(%brick);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update any rom down bricks; if there are any, set affects
|
||||||
|
%ndb = %brick.getNumDownBricks();
|
||||||
|
for(%i=0; %i<%ndb; %i++) {
|
||||||
|
%downbrick = %brick.getDownBrick(%i);
|
||||||
|
if(%downbrick.lualogic_rom_is) {
|
||||||
|
%brick.lualogic_rom_affects = 1;
|
||||||
|
lualogic_rom_updatedata(%downbrick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function lualogic_rom_deletebrick(%brick) {
|
||||||
|
// update any rom down bricks
|
||||||
|
%brick.lualogic_rom_delete = 1;
|
||||||
|
%ndb = %brick.getNumDownBricks();
|
||||||
|
for(%i=0; %i<%ndb; %i++) {
|
||||||
|
%downbrick = %brick.getDownBrick(%i);
|
||||||
|
if(%downbrick.lualogic_rom_is) {
|
||||||
|
lualogic_rom_updatedata(%downbrick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function lualogic_rom_updatercbrick(%brick) {
|
||||||
|
// update any rom down bricks
|
||||||
|
%ndb = %brick.getNumDownBricks();
|
||||||
|
for(%i=0; %i<%ndb; %i++) {
|
||||||
|
%downbrick = %brick.getDownBrick(%i);
|
||||||
|
if(%downbrick.lualogic_rom_is) {
|
||||||
|
lualogic_rom_updatedata(%downbrick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function lualogic_rom_rotate(%pos, %rot) {
|
||||||
|
%x = getWord(%pos, 0);
|
||||||
|
%y = getWord(%pos, 1);
|
||||||
|
%z = getWord(%pos, 2);
|
||||||
|
|
||||||
|
%rot = %rot % 4;
|
||||||
|
if (%rot==0) {
|
||||||
|
return %x SPC %y SPC %z;
|
||||||
|
} else if(%rot==1) {
|
||||||
|
return %y SPC -%x SPC %z;
|
||||||
|
} else if(%rot==2) {
|
||||||
|
return -%x SPC -%y SPC %z;
|
||||||
|
} else if(%rot==3) {
|
||||||
|
return -%y SPC %x SPC %z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function lualogic_rom_updatedata(%brick) {
|
||||||
|
if(!%brick.lualogic_rom_updatedata_scheduled) {
|
||||||
|
schedule(1, 0, lualogic_rom_updatedata_final, %brick);
|
||||||
|
%brick.lualogic_rom_updatedata_scheduled = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function lualogic_rom_updatedata_final(%brick) {
|
||||||
|
if(!isObject(%brick) || %brick.lualogic_rom_delete) return;
|
||||||
|
|
||||||
|
%brick.lualogic_rom_updatedata_scheduled = 0;
|
||||||
|
|
||||||
|
%data = %brick.getDatablock();
|
||||||
|
|
||||||
|
%rx = %data.logicRomX;
|
||||||
|
%ry = %data.logicRomY;
|
||||||
|
|
||||||
|
%brickpos = %brick.getPosition();
|
||||||
|
%rot = (%brick.angleId + 1)%4;
|
||||||
|
|
||||||
|
%data_str = "";
|
||||||
|
|
||||||
|
for(%x=0; %x<%rx; %x++) {
|
||||||
|
%line_str = "";
|
||||||
|
for(%y=0; %y<%ry; %y++) {
|
||||||
|
%pos = (%x*0.5 - %rx/4 + 0.25) SPC (%y*0.5 - %ry/4 + 0.25) SPC 0;
|
||||||
|
%pos = lualogic_rom_rotate(%pos, %rot);
|
||||||
|
%pos = vectorAdd(%brickpos, %pos);
|
||||||
|
%ray = containerRaycast(
|
||||||
|
%pos,
|
||||||
|
vectorAdd(%pos, "0 0 0.2"),
|
||||||
|
$TypeMasks::FxBrickObjectType,
|
||||||
|
%brick
|
||||||
|
);
|
||||||
|
%hit = getWord(%ray, 0);
|
||||||
|
if(isObject(%hit) && !%hit.lualogic_rom_delete && %hit.isRaycasting()) {
|
||||||
|
%line_str = %line_str @ "1";
|
||||||
|
} else {
|
||||||
|
%line_str = %line_str @ "0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%data_str = %data_str @ %line_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
lualogic_sendinput(%brick, 1, %data_str);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user