Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jacob Swehla 2017-12-29 10:06:20 -06:00
commit fcd339c315
9 changed files with 68 additions and 17 deletions

View File

@ -14,6 +14,9 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
public static final int ID = 1; public static final int ID = 1;
private char hologram = 0; private char hologram = 0;
private String hologramString = "";
private HologramMode hologramMode = HologramMode.CLEARED;
private char lastHologram = 0; private char lastHologram = 0;
/** /**
@ -86,6 +89,8 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
json.put("hp", hp); json.put("hp", hp);
json.put("action", lastAction.ordinal()); json.put("action", lastAction.ordinal());
json.put("holo", (int) lastHologram); json.put("holo", (int) lastHologram);
json.put("holoStr", hologramString);
json.put("holoMode", hologramMode.ordinal());
json.put("energy", energy); json.put("energy", energy);
if (parent != null) { if (parent != null) {
@ -149,6 +154,10 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
return lastAction; return lastAction;
} }
public Action getCurrentAction() {
return currentAction;
}
public void setHologram(char hologram) { public void setHologram(char hologram) {
this.hologram = hologram; this.hologram = hologram;
} }
@ -157,6 +166,9 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
return lastHologram; return lastHologram;
} }
public void setHologramString(String hologramString) {
this.hologramString = hologramString;
}
public int getEnergy() { public int getEnergy() {
return energy; return energy;
@ -206,4 +218,14 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
public boolean isAt(int x, int y) { public boolean isAt(int x, int y) {
return false; return false;
} }
public void setHologramMode(HologramMode hologramMode) {
this.hologramMode = hologramMode;
}
public enum HologramMode {
CLEARED,
HEX,
STRING
}
} }

View File

@ -42,7 +42,7 @@ public class CubotDrill extends CpuHardware {
} else if (a == GATHER_SLOW || a == GATHER_FAST) { } else if (a == GATHER_SLOW || a == GATHER_FAST) {
if (cubot.spendEnergy(1400)) { if (cubot.spendEnergy(1400)) {
if (cubot.getAction() == Action.IDLE) { if (cubot.getCurrentAction() == Action.IDLE) {
int tile = cubot.getWorld().getTileMap().getTileAt(cubot.getX(), cubot.getY()); int tile = cubot.getWorld().getTileMap().getTileAt(cubot.getX(), cubot.getY());
if (tile == TileMap.IRON_TILE) { if (tile == TileMap.IRON_TILE) {

View File

@ -17,6 +17,12 @@ public class CubotHologram extends CpuHardware {
private Cubot cubot; 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) { public CubotHologram(Cubot cubot) {
this.cubot = cubot; this.cubot = cubot;
} }
@ -25,7 +31,33 @@ public class CubotHologram extends CpuHardware {
public void handleInterrupt(Status status) { public void handleInterrupt(Status status) {
char a = getCpu().getRegisterSet().getRegister("A").getValue(); 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);
}
} }

View File

@ -49,7 +49,7 @@ public class CubotLaser extends CpuHardware {
ArrayList<GameObject> objects = cubot.getWorld().getGameObjectsAt(frontTile.x, frontTile.y); ArrayList<GameObject> 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 //FIXME: Problem here if more than 1 object
if (objects.get(0) instanceof InventoryHolder) { if (objects.get(0) instanceof InventoryHolder) {
if (((InventoryHolder) objects.get(0)).canTakeItem(b)) { 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");
} }

View File

@ -7,6 +7,7 @@ import net.simon987.server.logging.LogManager;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
/** /**
@ -144,6 +145,9 @@ public class Assembler {
//Handle DUP operator //Handle DUP operator
if (valueTokens.length == 2 && valueTokens[1].toUpperCase().contains("DUP(")) { if (valueTokens.length == 2 && valueTokens[1].toUpperCase().contains("DUP(")) {
out.write(parseDUPOperator16(valueTokens, labels, currentLine)); 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)) { } else if (labels != null && labels.containsKey(value)) {
//Handle label //Handle label
out.writeChar(labels.get(value)); out.writeChar(labels.get(value));

View File

@ -15,9 +15,8 @@ import java.util.HashMap;
*/ */
public class AssemblyResult { public class AssemblyResult {
/** /**
* The origin of the program, default is 0x400 * The origin of the program, default is 0x200
*/ */
public int origin; public int origin;
/** /**
@ -34,7 +33,7 @@ public class AssemblyResult {
*/ */
private int codeSegmentOffset; private int codeSegmentOffset;
/** /**
* Line of the code segment definition (for editor icons) * Line of the code segment definition
*/ */
private int codeSegmentLine; private int codeSegmentLine;
@ -44,11 +43,11 @@ public class AssemblyResult {
*/ */
public byte[] bytes; public byte[] bytes;
/** /**
* Offset of the data segment, default is 0x4000 * Offset of the data segment
*/ */
private int dataSegmentOffset; private int dataSegmentOffset;
/** /**
* Line of the data segment definition (for editor icons) * Line of the data segment definition
*/ */
private int dataSegmentLine; private int dataSegmentLine;
/** /**

View File

@ -44,7 +44,7 @@ public class CPU implements JSONSerialisable {
/** /**
* Offset of the code segment. The code starts to get * 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; private int codeSegmentOffset;

View File

@ -1,4 +0,0 @@
package net.simon987.server.event;
public class TickEvent {
}

View File

@ -1,4 +0,0 @@
package net.simon987.server.event;
public class UpdateEvent {
}