mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-18 02:06:43 +00:00
Merge branch 'master' into More-Maven-fixes
This commit is contained in:
commit
fde79ed97e
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class CubotLaser extends CpuHardware {
|
||||
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
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
/**
|
||||
|
@ -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;
|
||||
|
||||
|
@ -1,4 +0,0 @@
|
||||
package net.simon987.server.event;
|
||||
|
||||
public class TickEvent {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package net.simon987.server.event;
|
||||
|
||||
public class UpdateEvent {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user