aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/Ic2ExpReactorPlanner/TaloniusDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/Ic2ExpReactorPlanner/TaloniusDecoder.java')
-rw-r--r--src/main/java/Ic2ExpReactorPlanner/TaloniusDecoder.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/Ic2ExpReactorPlanner/TaloniusDecoder.java b/src/main/java/Ic2ExpReactorPlanner/TaloniusDecoder.java
new file mode 100644
index 0000000000..89232eb007
--- /dev/null
+++ b/src/main/java/Ic2ExpReactorPlanner/TaloniusDecoder.java
@@ -0,0 +1,26 @@
+
+package Ic2ExpReactorPlanner;
+
+import java.math.BigInteger;
+
+/**
+ * Pulls values out of codes from Talonius's old reactor planner.
+ * @author Brian McCloud
+ */
+public class TaloniusDecoder {
+ private BigInteger dataStack = null;
+
+ public TaloniusDecoder(final String dataCode) {
+ dataStack = new BigInteger(dataCode, 36);
+ }
+
+ public int readInt(final int bits) {
+ return readBigInteger(bits).intValue();
+ }
+
+ private BigInteger readBigInteger(final int bits) {
+ BigInteger data = dataStack.and(BigInteger.ONE.shiftLeft(bits).subtract(BigInteger.ONE));
+ dataStack = dataStack.shiftRight(bits);
+ return data;
+ }
+}