Add third input to XOR Gate
hellow554 opened this issue ยท 3 comments
Add a third input to the xor gate will make it more compact and more flexible to use.
I changed it in my local sources, but didn't managed to update to graphic in mineraft, because I felt not like doing that.
Here is a git diff for the xor gate file:
diff --git a/src/mrtjp/projectred/integration/SimpleGateLogic.java b/src/mrtjp/projectred/integration/SimpleGateLogic.java
index 3a49a72..a7a81ce 100644
--- a/src/mrtjp/projectred/integration/SimpleGateLogic.java
+++ b/src/mrtjp/projectred/integration/SimpleGateLogic.java
@@ -278,18 +278,22 @@ public abstract class SimpleGateLogic extends RedstoneGateLogic<SimpleGatePart>
@Override
public int inputMask(int shape)
{
- int m = 0;
- m |= 1<<1; // Right
- m |= 1<<3; // Left
- return m;
+ return ~shape<<1&0xE;
+ }
+
+ @Override
+ public int deadSides()
+ {
+ return 3;
}
@Override
public int calcOutput(SimpleGatePart gate, int input)
{
boolean side1 = (input&1<<1) != 0;
- boolean side2 = (input&1<<3) != 0;
- return side1 != side2 ? 1 : 0;
+ boolean side2 = (input&1<<2) != 0;
+ boolean side3 = (input&1<<3) != 0;
+ return side1 ^ side2 ^ side3 ? 1 : 0;
}
}
AND gates by definition only have 2 inputs.... OR gates by definition only have 2 inputs.... I could continue this list as much as I want. A three input AND is only a shortcut for (and (and a b) c), so we can define a three input xor as well: (xor a b c) is the same as (xor (xor a b) c).That's what is supposed to be.
Okay, If you are not pleased with the idea to have thrree inputs, how about to change where the inputs of the xor are?
XOR gates by definition only have 2 inputs. Once you get into 3 inputs, there is no concrete definition for them. Some say its 'only one input on' while others say 'all inputs different'. So for the second, if there are 3 inputs, the output can never be on.