mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-19 18:46:43 +00:00
Boolean result of ComPort actions are stored in B register
This commit is contained in:
parent
d832f65535
commit
1e26c63358
@ -13,6 +13,8 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
|||||||
private static final char MAP_INFO = 0x0080;
|
private static final char MAP_INFO = 0x0080;
|
||||||
public static final int ID = 1;
|
public static final int ID = 1;
|
||||||
|
|
||||||
|
public static int TYPE_ID = 2;
|
||||||
|
|
||||||
private int hologram = 0;
|
private int hologram = 0;
|
||||||
private String hologramString = "";
|
private String hologramString = "";
|
||||||
private HologramMode hologramMode = HologramMode.CLEARED;
|
private HologramMode hologramMode = HologramMode.CLEARED;
|
||||||
@ -250,10 +252,13 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(char[] message) {
|
public boolean sendMessage(char[] message) {
|
||||||
|
|
||||||
if (consoleMessagesBuffer.size() < CONSOLE_BUFFER_MAX_SIZE) {
|
if (consoleMessagesBuffer.size() < CONSOLE_BUFFER_MAX_SIZE) {
|
||||||
consoleMessagesBuffer.add(message);
|
consoleMessagesBuffer.add(message);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,13 +82,15 @@ public class CubotComPort extends CpuHardware {
|
|||||||
System.arraycopy(getCpu().getMemory().getWords(), x, message, 0, MESSAGE_LENGTH);
|
System.arraycopy(getCpu().getMemory().getWords(), x, message, 0, MESSAGE_LENGTH);
|
||||||
|
|
||||||
//Send it to the Programmable object
|
//Send it to the Programmable object
|
||||||
((Programmable) objects.get(0)).sendMessage(message);
|
getCpu().getRegisterSet().getRegister("B").setValue(
|
||||||
|
((Programmable) objects.get(0)).sendMessage(message) ? 1 : 0);
|
||||||
System.out.println("Sent message to " + ((Cubot) objects.get(0)).getParent().getUsername());
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCpu().getRegisterSet().getRegister("B").setValue(0); //Failed
|
||||||
|
|
||||||
} else if (a == COMPORT_SELF_OUT) {
|
} else if (a == COMPORT_SELF_OUT) {
|
||||||
|
|
||||||
if (cubot.spendEnergy(1)) {
|
if (cubot.spendEnergy(1)) {
|
||||||
@ -104,9 +106,12 @@ public class CubotComPort extends CpuHardware {
|
|||||||
//Get MESSAGE_LENGTH-word message pointed by X
|
//Get MESSAGE_LENGTH-word message pointed by X
|
||||||
char[] message = new char[MESSAGE_LENGTH];
|
char[] message = new char[MESSAGE_LENGTH];
|
||||||
System.arraycopy(getCpu().getMemory().getWords(), x, message, 0, MESSAGE_LENGTH);
|
System.arraycopy(getCpu().getMemory().getWords(), x, message, 0, MESSAGE_LENGTH);
|
||||||
cubot.sendMessage(message);
|
getCpu().getRegisterSet().getRegister("B").setValue(cubot.sendMessage(message) ? 1 : 0);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCpu().getRegisterSet().getRegister("B").setValue(0); //Failed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,10 +41,13 @@ public class RadioTower extends GameObject implements Programmable, Updatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(char[] message) {
|
public boolean sendMessage(char[] message) {
|
||||||
|
|
||||||
if (message.length < MAX_MESSAGES) {
|
if (message.length < MAX_MESSAGES) {
|
||||||
messages.add(message);
|
messages.add(message);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ public abstract class GameObject implements JSONSerialisable {
|
|||||||
newY = y;
|
newY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Check if out of World bounds / collision
|
//Check if out of World bounds / collision
|
||||||
if (newX < 0) {
|
if (newX < 0) {
|
||||||
//Move object to adjacent World (left)
|
//Move object to adjacent World (left)
|
||||||
|
@ -2,6 +2,6 @@ package net.simon987.server.game;
|
|||||||
|
|
||||||
public interface Programmable {
|
public interface Programmable {
|
||||||
|
|
||||||
void sendMessage(char[] message);
|
boolean sendMessage(char[] message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user