From 217c997788a799a4541061239176b85fe07fb680 Mon Sep 17 00:00:00 2001 From: Luc Lagarde Date: Wed, 28 Mar 2018 23:34:23 -0500 Subject: [PATCH 1/2] Add action to get world size from LiDAR --- .../src/main/java/net/simon987/cubotplugin/CubotLidar.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLidar.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLidar.java index 36be823..953e5b3 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLidar.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLidar.java @@ -29,6 +29,7 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable { private static final int LIDAR_GET_PATH = 2; private static final int LIDAR_GET_MAP = 3; private static final int LIDAR_GET_WORLD_POS = 4; + private static final int LIDAR_GET_WORLD_SIZE = 5; private static final int MEMORY_MAP_START = 0x0100; private static final int MEMORY_PATH_START = 0x0000; @@ -122,6 +123,12 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable { } break; + + case LIDAR_GET_WORLD_SIZE: + getCpu().getRegisterSet().getRegister("X").setValue(cubot.getWorld().getWorldSize()); + getCpu().getRegisterSet().getRegister("Y").setValue(cubot.getWorld().getWorldSize()); + break; + case LIDAR_GET_WORLD_POS: getCpu().getRegisterSet().getRegister("X").setValue(cubot.getWorld().getX()); getCpu().getRegisterSet().getRegister("Y").setValue(cubot.getWorld().getY()); From e62a51ee2e9f73561cdf351f51f14da37bffd6d3 Mon Sep 17 00:00:00 2001 From: Luc Lagarde Date: Wed, 28 Mar 2018 23:37:05 -0500 Subject: [PATCH 2/2] Modify LIDAR_GET_MAP to write to a given memory address --- .../src/main/java/net/simon987/cubotplugin/CubotLidar.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLidar.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLidar.java index 953e5b3..8ffea91 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLidar.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLidar.java @@ -114,7 +114,8 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable { if (cubot.spendEnergy(10)) { char[][] mapInfo = cubot.getWorld().getMapInfo(); - int i = MEMORY_MAP_START; + //Write map data to the location specified by register X + int i = getCpu().getRegisterSet().getRegister("X").getValue(); for (int y = 0; y < cubot.getWorld().getWorldSize(); y++) { for (int x = 0; x < cubot.getWorld().getWorldSize(); x++) { getCpu().getMemory().set(i++, mapInfo[x][y]);