Added memory location option for LiDAR GET_PATH. Fixes #140

This commit is contained in:
Simon 2018-11-27 13:52:00 -05:00
parent 04c837d692
commit b361583252
3 changed files with 6 additions and 12 deletions

View File

@ -5,7 +5,6 @@ import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.ControllableUnit; import net.simon987.server.game.objects.ControllableUnit;
import net.simon987.server.game.pathfinding.Node; import net.simon987.server.game.pathfinding.Node;
import net.simon987.server.game.pathfinding.Pathfinder; import net.simon987.server.game.pathfinding.Pathfinder;
import net.simon987.server.logging.LogManager;
import org.bson.Document; import org.bson.Document;
import java.util.ArrayList; import java.util.ArrayList;
@ -25,8 +24,6 @@ public class CubotLidar extends CubotHardwareModule {
private static final int LIDAR_GET_WORLD_POS = 4; private static final int LIDAR_GET_WORLD_POS = 4;
private static final int LIDAR_GET_WORLD_SIZE = 5; private static final int LIDAR_GET_WORLD_SIZE = 5;
private static final int MEMORY_PATH_START = 0x0000;
public CubotLidar(Cubot cubot) { public CubotLidar(Cubot cubot) {
super(cubot); super(cubot);
} }
@ -52,6 +49,7 @@ public class CubotLidar extends CubotHardwareModule {
break; break;
case LIDAR_GET_PATH: case LIDAR_GET_PATH:
if (cubot.spendEnergy(50)) { if (cubot.spendEnergy(50)) {
int c = getCpu().getRegisterSet().getRegister("C").getValue();
int b = getCpu().getRegisterSet().getRegister("B").getValue(); int b = getCpu().getRegisterSet().getRegister("B").getValue();
int destX = getCpu().getRegisterSet().getRegister("X").getValue(); int destX = getCpu().getRegisterSet().getRegister("X").getValue();
int destY = getCpu().getRegisterSet().getRegister("Y").getValue(); int destY = getCpu().getRegisterSet().getRegister("Y").getValue();
@ -63,7 +61,7 @@ public class CubotLidar extends CubotHardwareModule {
//Write to memory //Write to memory
Memory mem = getCpu().getMemory(); Memory mem = getCpu().getMemory();
int counter = MEMORY_PATH_START; int counter = c;
if (nodes != null) { if (nodes != null) {
@ -71,7 +69,6 @@ public class CubotLidar extends CubotHardwareModule {
for (Node n : nodes) { for (Node n : nodes) {
//Store the path as a sequence of directions //Store the path as a sequence of directions
if (lastNode == null) { if (lastNode == null) {
lastNode = n; lastNode = n;
continue; continue;
@ -100,8 +97,6 @@ public class CubotLidar extends CubotHardwareModule {
//Indicate invalid path 0xFFFF //Indicate invalid path 0xFFFF
mem.set(counter, 0xFFFF); mem.set(counter, 0xFFFF);
} }
LogManager.LOGGER.fine("DEBUG: path to" + destX + "," + destY);
} }
break; break;
@ -118,7 +113,6 @@ public class CubotLidar extends CubotHardwareModule {
} }
} }
} }
break; break;
case LIDAR_GET_WORLD_SIZE: case LIDAR_GET_WORLD_SIZE:

View File

@ -540,9 +540,10 @@ public class Assembler {
} }
//Check operands and encode instruction //Check operands and encode instruction
final int beginIndex = line.indexOf(mnemonic) + mnemonic.length();
if (line.contains(",")) { if (line.contains(",")) {
//2 operands //2 operands
String strO1 = line.substring(line.indexOf(mnemonic) + mnemonic.length(), line.indexOf(',')); String strO1 = line.substring(beginIndex, line.indexOf(','));
String strO2 = line.substring(line.indexOf(',')); String strO2 = line.substring(line.indexOf(','));
Operand o1, o2; Operand o1, o2;
@ -562,7 +563,7 @@ public class Assembler {
} else if (tokens.length > 1) { } else if (tokens.length > 1) {
//1 operand //1 operand
String strO1 = line.substring(line.indexOf(mnemonic) + mnemonic.length()); String strO1 = line.substring(beginIndex);
Operand o1; Operand o1;
if (assumeLabels) { if (assumeLabels) {
@ -583,6 +584,5 @@ public class Assembler {
} }
return out.toByteArray(); return out.toByteArray();
} }
} }

View File

@ -9,7 +9,7 @@ keyStore_password=
#Server #Server
mar_address=ws://localhost:4567/socket mar_address=ws://localhost:4567/socket
server_name=MAR dev server_name=MAR dev
# ALLOW | TEMPORARY | BLOCK # ALLOW | BLOCK
guest_policy=ALLOW guest_policy=ALLOW
#Database #Database