diff --git a/Plugin Cubot/src/net/simon987/cubotplugin/CubotLidar.java b/Plugin Cubot/src/net/simon987/cubotplugin/CubotLidar.java index 23c88c5..340c970 100644 --- a/Plugin Cubot/src/net/simon987/cubotplugin/CubotLidar.java +++ b/Plugin Cubot/src/net/simon987/cubotplugin/CubotLidar.java @@ -64,7 +64,7 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable { //Write to memory byte[] mem = getCpu().getMemory().getBytes(); - int counter = 0; //todo get memory address from config/constant + int counter = MEMORY_PATH_START; if (nodes != null) { diff --git a/Plugin Misc HW/plugin.properties b/Plugin Misc HW/plugin.properties new file mode 100644 index 0000000..38fc991 --- /dev/null +++ b/Plugin Misc HW/plugin.properties @@ -0,0 +1,3 @@ +classpath=net.simon987.mischwplugin.MiscHWPlugin +name=Misc HW Plugin +version=1.0 \ No newline at end of file diff --git a/Plugin Misc HW/src/net/simon987/mischwplugin/MiscHWPlugin.java b/Plugin Misc HW/src/net/simon987/mischwplugin/MiscHWPlugin.java new file mode 100644 index 0000000..cc98376 --- /dev/null +++ b/Plugin Misc HW/src/net/simon987/mischwplugin/MiscHWPlugin.java @@ -0,0 +1,31 @@ +package net.simon987.mischwplugin; + +import net.simon987.mischwplugin.event.CpuInitialisationListener; +import net.simon987.server.assembly.CpuHardware; +import net.simon987.server.io.CpuHardwareDeserializer; +import net.simon987.server.logging.LogManager; +import net.simon987.server.plugin.ServerPlugin; +import org.json.simple.JSONObject; + +public class MiscHWPlugin extends ServerPlugin implements CpuHardwareDeserializer { + + + @Override + public void init() { + listeners.add(new CpuInitialisationListener()); + + LogManager.LOGGER.info("Initialised Misc Hardware Plugin"); + } + + @Override + public CpuHardware deserializeHardware(JSONObject hwJson) { + int hwid = (int) (long) hwJson.get("hwid"); + + switch (hwid) { + case RandomNumberGenerator.HWID: + return RandomNumberGenerator.deserialize(hwJson); + } + + return null; + } +} diff --git a/Plugin Misc HW/src/net/simon987/mischwplugin/RandomNumberGenerator.java b/Plugin Misc HW/src/net/simon987/mischwplugin/RandomNumberGenerator.java new file mode 100644 index 0000000..9efd360 --- /dev/null +++ b/Plugin Misc HW/src/net/simon987/mischwplugin/RandomNumberGenerator.java @@ -0,0 +1,44 @@ +package net.simon987.mischwplugin; + +import net.simon987.server.assembly.CpuHardware; +import net.simon987.server.assembly.Status; +import org.json.simple.JSONObject; + +import java.util.Random; + +public class RandomNumberGenerator extends CpuHardware { + + public static final char HWID = 0x0007; + + public static final char DEFAULT_ADDRESS = 0x0007; + + private Random random; + + public RandomNumberGenerator() { + random = new Random(); + } + + @Override + public void handleInterrupt(Status status) { + + getCpu().getRegisterSet().getRegister("B").setValue(random.nextInt(0xFFFF)); + + } + + @Override + public char getId() { + return HWID; + } + + @Override + public JSONObject serialise() { + JSONObject json = new JSONObject(); + json.put("hwid", (int) HWID); + + return json; + } + + public static RandomNumberGenerator deserialize(JSONObject hwJSON) { + return new RandomNumberGenerator(); + } +} diff --git a/Plugin Misc HW/src/net/simon987/mischwplugin/event/CpuInitialisationListener.java b/Plugin Misc HW/src/net/simon987/mischwplugin/event/CpuInitialisationListener.java new file mode 100644 index 0000000..86bc1ee --- /dev/null +++ b/Plugin Misc HW/src/net/simon987/mischwplugin/event/CpuInitialisationListener.java @@ -0,0 +1,23 @@ +package net.simon987.mischwplugin.event; + +import net.simon987.mischwplugin.RandomNumberGenerator; +import net.simon987.server.assembly.CPU; +import net.simon987.server.event.CpuInitialisationEvent; +import net.simon987.server.event.GameEvent; +import net.simon987.server.event.GameEventListener; + +public class CpuInitialisationListener implements GameEventListener { + + @Override + public Class getListenedEventType() { + return CpuInitialisationEvent.class; + } + + @Override + public void handle(GameEvent event) { + + CPU cpu = (CPU) event.getSource(); + + cpu.attachHardware(new RandomNumberGenerator(), RandomNumberGenerator.DEFAULT_ADDRESS); + } +} \ No newline at end of file diff --git a/Server/src/net/simon987/server/Main.java b/Server/src/net/simon987/server/Main.java index e90c352..d877a68 100644 --- a/Server/src/net/simon987/server/Main.java +++ b/Server/src/net/simon987/server/Main.java @@ -20,10 +20,15 @@ public class Main { * - Instruction set * - */ + //TODO: Random number generator + //TODO: Clock hardware + //TODO: Floppy drive hardware (and item?) + //TODO: LEA instruction + //TODO: NOT instruction + //TODO: Battery Hardware //--------------------------------- - //TODO: Random number generator //TODO: favicon //TODO: Email verification //TODO: Real account page @@ -35,9 +40,6 @@ public class Main { * - INT/INTO instruction * - IRET instruction */ - //TODO: Clock hardware - //TODO: Floppy drive hardware (and item?) - //TODO: LEA instruction //TODO: XCHG instruction //TODO: SAL/SAR instruction //TODO: ROL/ROR/RCL/RCR instruction @@ -56,7 +58,6 @@ public class Main { //TODO: Multiple Biomass style (and yield, rarity) //TODO: Clean sprites //TODO: Auto-resize - //TODO: Battery Hardware LogManager.initialize(); diff --git a/config.properties b/config.properties index e33a517..fe03606 100644 --- a/config.properties +++ b/config.properties @@ -7,9 +7,9 @@ mysql_url=jdbc:mysql://localhost:3306/mar?useSSL=false save_interval=10 # Web server port webSocket_port=8887 -webSocket_host=localhost +webSocket_host=0.0.0.0 -use_secure_webSocket=1 +use_secure_webSocket=0 cert_path=certificates # ---------------------------------------------- diff --git a/plugins/Cubot.jar b/plugins/Cubot.jar index 1b08453..b9c2743 100644 Binary files a/plugins/Cubot.jar and b/plugins/Cubot.jar differ diff --git a/plugins/Plant.jar b/plugins/Plant.jar index e616e70..197eb9e 100644 Binary files a/plugins/Plant.jar and b/plugins/Plant.jar differ