diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Cubot.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Cubot.java index 0048725..c2d871f 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Cubot.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Cubot.java @@ -14,6 +14,9 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit { public static final int ID = 1; private char hologram = 0; + private String hologramString = ""; + private HologramMode hologramMode = HologramMode.CLEARED; + private char lastHologram = 0; /** @@ -86,6 +89,8 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit { json.put("hp", hp); json.put("action", lastAction.ordinal()); json.put("holo", (int) lastHologram); + json.put("holoStr", hologramString); + json.put("holoMode", hologramMode.ordinal()); json.put("energy", energy); if (parent != null) { @@ -149,6 +154,10 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit { return lastAction; } + public Action getCurrentAction() { + return currentAction; + } + public void setHologram(char hologram) { this.hologram = hologram; } @@ -157,6 +166,9 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit { return lastHologram; } + public void setHologramString(String hologramString) { + this.hologramString = hologramString; + } public int getEnergy() { return energy; @@ -206,4 +218,14 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit { public boolean isAt(int x, int y) { return false; } + + public void setHologramMode(HologramMode hologramMode) { + this.hologramMode = hologramMode; + } + + public enum HologramMode { + CLEARED, + HEX, + STRING + } } diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotDrill.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotDrill.java index ea09b09..6faf457 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotDrill.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotDrill.java @@ -42,7 +42,7 @@ public class CubotDrill extends CpuHardware { } else if (a == GATHER_SLOW || a == GATHER_FAST) { if (cubot.spendEnergy(1400)) { - if (cubot.getAction() == Action.IDLE) { + if (cubot.getCurrentAction() == Action.IDLE) { int tile = cubot.getWorld().getTileMap().getTileAt(cubot.getX(), cubot.getY()); if (tile == TileMap.IRON_TILE) { diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotHologram.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotHologram.java index d5172c4..7e07839 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotHologram.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotHologram.java @@ -17,6 +17,12 @@ public class CubotHologram extends CpuHardware { private Cubot cubot; + private static final int CLEAR = 0; + private static final int DISPLAY_HEX = 1; + private static final int DISPLAY_STRING = 2; + + private static final int STR_MAX_LEN = 8; + public CubotHologram(Cubot cubot) { this.cubot = cubot; } @@ -25,7 +31,33 @@ public class CubotHologram extends CpuHardware { public void handleInterrupt(Status status) { char a = getCpu().getRegisterSet().getRegister("A").getValue(); - cubot.setHologram(a); + + if (a == CLEAR) { + cubot.setHologramMode(Cubot.HologramMode.CLEARED); + } else if (a == DISPLAY_HEX) { + char b = getCpu().getRegisterSet().getRegister("B").getValue(); + cubot.setHologram(b); + cubot.setHologramMode(Cubot.HologramMode.HEX); + } else if (a == DISPLAY_STRING) { + char x = getCpu().getRegisterSet().getRegister("X").getValue(); + //Display zero-terminated string starting at X (max 8 chars) + + StringBuilder holoString = new StringBuilder(); + + for (int i = 0; i < STR_MAX_LEN; i++) { + + char nextChar = (char) getCpu().getMemory().get(x + i); + + if (nextChar != 0) { + holoString.append((char) getCpu().getMemory().get(x + i)); + } else { + break; + } + } + + cubot.setHologramString(holoString.toString()); + cubot.setHologramMode(Cubot.HologramMode.STRING); + } } diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLaser.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLaser.java index 22a3a17..341f59b 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLaser.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLaser.java @@ -49,7 +49,7 @@ public class CubotLaser extends CpuHardware { ArrayList objects = cubot.getWorld().getGameObjectsAt(frontTile.x, frontTile.y); - if (cubot.getAction() == Action.IDLE && objects.size() > 0) { + if (cubot.getCurrentAction() == Action.IDLE && objects.size() > 0) { //FIXME: Problem here if more than 1 object if (objects.get(0) instanceof InventoryHolder) { if (((InventoryHolder) objects.get(0)).canTakeItem(b)) { @@ -62,6 +62,8 @@ public class CubotLaser extends CpuHardware { } } } + } else { + System.out.println("\n\n\n\n\n It did it"); } diff --git a/Server/src/main/java/net/simon987/server/assembly/Assembler.java b/Server/src/main/java/net/simon987/server/assembly/Assembler.java index 17abd62..5b151b3 100755 --- a/Server/src/main/java/net/simon987/server/assembly/Assembler.java +++ b/Server/src/main/java/net/simon987/server/assembly/Assembler.java @@ -7,6 +7,7 @@ import net.simon987.server.logging.LogManager; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.HashMap; /** @@ -144,6 +145,9 @@ public class Assembler { //Handle DUP operator if (valueTokens.length == 2 && valueTokens[1].toUpperCase().contains("DUP(")) { out.write(parseDUPOperator16(valueTokens, labels, currentLine)); + } else if (value.startsWith("\"") && value.endsWith("\"")) { + //Handle string + out.write(value.substring(1, value.length() - 1).getBytes(StandardCharsets.UTF_16)); } else if (labels != null && labels.containsKey(value)) { //Handle label out.writeChar(labels.get(value)); diff --git a/Server/src/main/java/net/simon987/server/assembly/AssemblyResult.java b/Server/src/main/java/net/simon987/server/assembly/AssemblyResult.java index bc0a0ce..f1754df 100755 --- a/Server/src/main/java/net/simon987/server/assembly/AssemblyResult.java +++ b/Server/src/main/java/net/simon987/server/assembly/AssemblyResult.java @@ -15,9 +15,8 @@ import java.util.HashMap; */ public class AssemblyResult { - /** - * The origin of the program, default is 0x400 + * The origin of the program, default is 0x200 */ public int origin; /** @@ -34,7 +33,7 @@ public class AssemblyResult { */ private int codeSegmentOffset; /** - * Line of the code segment definition (for editor icons) + * Line of the code segment definition */ private int codeSegmentLine; @@ -44,11 +43,11 @@ public class AssemblyResult { */ public byte[] bytes; /** - * Offset of the data segment, default is 0x4000 + * Offset of the data segment */ private int dataSegmentOffset; /** - * Line of the data segment definition (for editor icons) + * Line of the data segment definition */ private int dataSegmentLine; /** diff --git a/Server/src/main/java/net/simon987/server/assembly/CPU.java b/Server/src/main/java/net/simon987/server/assembly/CPU.java index 0a8efe9..071d459 100755 --- a/Server/src/main/java/net/simon987/server/assembly/CPU.java +++ b/Server/src/main/java/net/simon987/server/assembly/CPU.java @@ -44,7 +44,7 @@ public class CPU implements JSONSerialisable { /** * Offset of the code segment. The code starts to get - * executed at this address each tick. Defaults to 0x4000 + * executed at this address each tick. Defaults to org_offset@config.properties */ private int codeSegmentOffset; diff --git a/Server/src/net/simon987/server/event/TickEvent.java b/Server/src/net/simon987/server/event/TickEvent.java deleted file mode 100644 index c2483b0..0000000 --- a/Server/src/net/simon987/server/event/TickEvent.java +++ /dev/null @@ -1,4 +0,0 @@ -package net.simon987.server.event; - -public class TickEvent { -} diff --git a/Server/src/net/simon987/server/event/WorldUpdateEvent.java b/Server/src/net/simon987/server/event/WorldUpdateEvent.java deleted file mode 100644 index c47fb3b..0000000 --- a/Server/src/net/simon987/server/event/WorldUpdateEvent.java +++ /dev/null @@ -1,4 +0,0 @@ -package net.simon987.server.event; - -public class UpdateEvent { -}