Changed byte array in Memory to char array (+60% performance improvement)

This commit is contained in:
simon
2017-11-18 22:23:32 -05:00
parent d004386b7b
commit 12db25e726
10 changed files with 102 additions and 55 deletions

View File

@@ -187,6 +187,13 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
@Override
public Memory getFloppyData() {
return ((CubotFloppyDrive) getParent().getCpu().getHardware(CubotFloppyDrive.DEFAULT_ADDRESS)).getFloppy().getMemory();
CubotFloppyDrive drive = ((CubotFloppyDrive) getParent().getCpu().getHardware(CubotFloppyDrive.DEFAULT_ADDRESS));
if (drive.getFloppy() != null) {
return drive.getFloppy().getMemory();
} else {
return null;
}
}
}

View File

@@ -23,6 +23,8 @@ public class CubotFloppyDrive extends CpuHardware {
public CubotFloppyDrive(Cubot cubot) {
this.cubot = cubot;
floppyDisk = new FloppyDisk();
}
@Override
@@ -94,8 +96,6 @@ public class CubotFloppyDrive extends CpuHardware {
if (hwJSON.containsKey("floppy")) {
drive.floppyDisk = FloppyDisk.deserialise((JSONObject) hwJSON.get("floppy"));
} else {
drive.floppyDisk = new FloppyDisk();
}
return drive;

View File

@@ -25,7 +25,7 @@ public class FloppyDisk implements JSONSerialisable {
public FloppyDisk() {
this.memory = new Memory(1024 * 1440);
this.memory = new Memory(512 * 1440);
}
/**
@@ -39,7 +39,7 @@ public class FloppyDisk implements JSONSerialisable {
public boolean readSector(int sector, Memory cpuMemory, int ramAddress) {
if (sector <= 1440) {
cpuMemory.write(ramAddress, memory.getBytes(), sector * 1024, 1024);
cpuMemory.write(ramAddress, memory.getWords(), sector * 512, 512);
//Calculate seek time
int deltaTrack = (sector / 80) - rwHeadTrack;
@@ -66,7 +66,7 @@ public class FloppyDisk implements JSONSerialisable {
public boolean writeSector(int sector, Memory cpuMemory, int ramAddress) {
if (sector <= 1440) {
memory.write(sector * 512, cpuMemory.getBytes(), ramAddress * 2, 1024);
memory.write(sector * 512, cpuMemory.getWords(), ramAddress, 512);
//Calculate seek time
int deltaTrack = (sector / 80) - rwHeadTrack;