From dab5cab602cec099f64abe47138179bdf5a76b38 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 28 Dec 2017 19:29:48 -0500 Subject: [PATCH 1/6] Updated incorrect documentation --- .../net/simon987/server/assembly/AssemblyResult.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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; /** From 2fb7d2f73e3756dfd7fc302f96ac2e6edc2ff72e Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 28 Dec 2017 20:33:57 -0500 Subject: [PATCH 2/6] Fixes #54 --- .../src/main/java/net/simon987/cubotplugin/Cubot.java | 4 ++++ .../src/main/java/net/simon987/cubotplugin/CubotDrill.java | 2 +- .../src/main/java/net/simon987/cubotplugin/CubotLaser.java | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) 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..4fbb1fe 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Cubot.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Cubot.java @@ -149,6 +149,10 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit { return lastAction; } + public Action getCurrentAction() { + return currentAction; + } + public void setHologram(char hologram) { this.hologram = hologram; } 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/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"); } From 729debb1a3b25b79defc37739a669defd3cc7b70 Mon Sep 17 00:00:00 2001 From: Simon Fortier Date: Thu, 28 Dec 2017 20:41:02 -0500 Subject: [PATCH 3/6] Fixes #56 --- Server/src/main/java/net/simon987/server/assembly/CPU.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 0fee35baec45706a5e44bd63e882b4dbd8668573 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 28 Dec 2017 22:35:49 -0500 Subject: [PATCH 4/6] Fixes #53 --- .../java/net/simon987/cubotplugin/Cubot.java | 18 ++++++++++ .../simon987/cubotplugin/CubotHologram.java | 34 ++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) 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 4fbb1fe..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) { @@ -161,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; @@ -210,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/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); + } } From d9732557fc1b936415dd0980b1130cb6b82bea4c Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 28 Dec 2017 23:08:05 -0500 Subject: [PATCH 5/6] Removed unused files --- Server/src/net/simon987/server/event/TickEvent.java | 4 ---- Server/src/net/simon987/server/event/WorldUpdateEvent.java | 4 ---- 2 files changed, 8 deletions(-) delete mode 100644 Server/src/net/simon987/server/event/TickEvent.java delete mode 100644 Server/src/net/simon987/server/event/WorldUpdateEvent.java 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 { -} From 45ec7191b4cc5d7528d786fdfd4e04b8e20a6c55 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 29 Dec 2017 08:28:04 -0500 Subject: [PATCH 6/6] Added string literals support for the assembler --- .../src/main/java/net/simon987/server/assembly/Assembler.java | 4 ++++ 1 file changed, 4 insertions(+) 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));