mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-14 15:19:04 +00:00
Changed byte array in Memory to char array (+60% performance improvement)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user