Comparisons! Memory!

main
Astoria 2 years ago
parent 968073604f
commit b025231c6c

@ -32,6 +32,15 @@ public class GuiProgrammer extends GuiScrollable {
this.controlList.add(new GuiButtonExtended(i++, this.width, "Subtraction"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Multiplication"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Division"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Memory"));
i = 0;
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, "=="));
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, "!="));
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, ">"));
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, ">="));
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, "<"));
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, "<="));
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, "<=>"));
}
public GuiProgrammer(EntityPlayer player, AbstractWireTileEntity wireEntity) {
@ -70,6 +79,9 @@ public class GuiProgrammer extends GuiScrollable {
case "Increment/Decrement":
((ChipTileEntity) wireEntity).setMode("incdec");
break;
case "Memory":
((ChipTileEntity) wireEntity).setMode("mem");
break;
case "TRUE":
case "FALSE":
case "NOT":
@ -79,6 +91,13 @@ public class GuiProgrammer extends GuiScrollable {
case "NAND":
case "NOR":
case "XNOR":
case "==":
case "!=":
case ">":
case ">=":
case "<":
case "<=":
case "<=>":
((ChipTileEntity) wireEntity).setMode(guibutton.displayString);
break;
}

@ -24,6 +24,10 @@ public class ChipTileEntity extends AbstractWireTileEntity {
doIncrementDecrement();
updateIO();
break;
case "mem":
doMemory();
updateIO();
break;
case "dup":
doDup();
updateIO();
@ -80,9 +84,65 @@ public class ChipTileEntity extends AbstractWireTileEntity {
outputs[0].floatvalue = 0.0f;
updateIO();
break;
case "==":
doEquals();
updateIO();
break;
case "!=":
doNotEquals();
updateIO();
break;
case ">":
doGreater();
updateIO();
break;
case ">=":
doGreaterEq();
updateIO();
break;
case "<":
doLess();
updateIO();
break;
case "<=":
doLessEq();
updateIO();
break;
case "<=>":
doSpaceShip();
updateIO();
break;
}
}
private void doSpaceShip() {
outputs[0].floatvalue = Float.compare(inputs[0].floatvalue, inputs[1].floatvalue);
}
private void doLessEq() {
outputs[0].floatvalue = inputs[0].floatvalue <= inputs[1].floatvalue ? 1.0f : 0.0f;
}
private void doLess() {
outputs[0].floatvalue = inputs[0].floatvalue < inputs[1].floatvalue ? 1.0f : 0.0f;
}
private void doGreaterEq() {
outputs[0].floatvalue = inputs[0].floatvalue >= inputs[1].floatvalue ? 1.0f : 0.0f;
}
private void doGreater() {
outputs[0].floatvalue = inputs[0].floatvalue > inputs[1].floatvalue ? 1.0f : 0.0f;
}
private void doNotEquals() {
outputs[0].floatvalue = inputs[0].floatvalue != inputs[1].floatvalue ? 1.0f : 0.0f;
}
private void doEquals() {
outputs[0].floatvalue = inputs[0].floatvalue == inputs[1].floatvalue ? 1.0f : 0.0f;
}
private void doXNOR() {
outputs[0].floatvalue = inputs[0].floatvalue != 0 ^ inputs[1].floatvalue != 0 ? 0.0f : 1.0f;
}
@ -181,6 +241,19 @@ public class ChipTileEntity extends AbstractWireTileEntity {
}
}
private void doMemory() {
if (inputs[2].floatvalue > 0) {
this.outputs[0].floatvalue = 0;
return;
}
if (this.inputs[1].floatvalue > 0 && shouldIncrement) {
this.outputs[0].floatvalue = this.inputs[0].floatvalue;
shouldIncrement = false;
} else if (this.inputs[1].floatvalue == 0.0 && !shouldIncrement) {
shouldIncrement = true;
}
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
@ -207,6 +280,7 @@ public class ChipTileEntity extends AbstractWireTileEntity {
break;
case "inc":
case "dec":
case "mem":
this.inputs = new WiringButton[3];
this.outputs = new WiringButton[1];
this.outputs[0] = new WiringButton(214, 240, "Output", 0);
@ -246,6 +320,13 @@ public class ChipTileEntity extends AbstractWireTileEntity {
case "sub":
case "mult":
case "div":
case "==":
case "!=":
case ">":
case ">=":
case "<":
case "<=":
case "<=>":
this.inputs = new WiringButton[2];
this.outputs = new WiringButton[1];
this.outputs[0] = new WiringButton(214, 230, "Output", 0);

Loading…
Cancel
Save