Merge branch 'master' into crtc
Conflicts: src/main/java/com/loomcom/symon/Simulator.java src/main/java/com/loomcom/symon/devices/Device.java src/main/java/com/loomcom/symon/devices/Memory.java
This commit is contained in:
commit
070e9db813
10 files changed
+51
-66
No files matched your search
@@ -75,7 +75,7 @@ public class Acia extends Device {
|
||||
private boolean txEmpty = true;
|
||||
|
||||
public Acia(int address) throws MemoryRangeException {
|
||||
super(address, ACIA_SIZE, "ACIA");
|
||||
super(address, address + ACIA_SIZE - 1, "ACIA");
|
||||
this.baseAddress = address;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class Crtc extends Device {
|
||||
private Memory memory;
|
||||
|
||||
public Crtc(int deviceAddress, Memory memory) throws MemoryRangeException, IOException {
|
||||
super(deviceAddress, 2, "CRTC");
|
||||
super(deviceAddress, deviceAddress + 2, "CRTC");
|
||||
this.memory = memory;
|
||||
|
||||
// Defaults
|
||||
|
||||
@@ -37,6 +37,11 @@ import java.util.Set;
|
||||
|
||||
public abstract class Device implements Comparable<Device> {
|
||||
|
||||
/**
|
||||
* Size of the device in memory
|
||||
*/
|
||||
int size;
|
||||
|
||||
/**
|
||||
* The memory range for this device.
|
||||
*/
|
||||
@@ -57,15 +62,16 @@ public abstract class Device implements Comparable<Device> {
|
||||
*/
|
||||
private Set<DeviceChangeListener> deviceChangeListeners;
|
||||
|
||||
public Device(int address, int size, String name)
|
||||
public Device(int startAddress, int endAddress, String name)
|
||||
throws MemoryRangeException {
|
||||
this.memoryRange = new MemoryRange(address, address + size - 1);
|
||||
this.memoryRange = new MemoryRange(startAddress, endAddress);
|
||||
this.size = endAddress - startAddress + 1;
|
||||
this.name = name;
|
||||
this.deviceChangeListeners = new HashSet<DeviceChangeListener>();
|
||||
}
|
||||
|
||||
public Device(int address, int size) throws MemoryRangeException {
|
||||
this(address, size, null);
|
||||
public Device(int startAddress, int endAddress) throws MemoryRangeException {
|
||||
this(startAddress, endAddress, null);
|
||||
}
|
||||
|
||||
/* Methods required to be implemented by inheriting classes. */
|
||||
@@ -103,6 +109,10 @@ public abstract class Device implements Comparable<Device> {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void registerListener(DeviceChangeListener listener) {
|
||||
deviceChangeListeners.add(listener);
|
||||
}
|
||||
|
||||
@@ -38,26 +38,26 @@ public class Memory extends Device {
|
||||
/* Initialize all locations to 0x00 (BRK) */
|
||||
private static final int DEFAULT_FILL = 0x00;
|
||||
|
||||
public Memory(int address, int size, boolean readOnly)
|
||||
public Memory(int startAddress, int endAddress, boolean readOnly)
|
||||
throws MemoryRangeException {
|
||||
super(address, size, (readOnly ? "RO Memory" : "RW Memory"));
|
||||
super(startAddress, endAddress, (readOnly ? "RO Memory" : "RW Memory"));
|
||||
this.readOnly = readOnly;
|
||||
this.mem = new int[size];
|
||||
this.mem = new int[this.size];
|
||||
this.fill(DEFAULT_FILL);
|
||||
}
|
||||
|
||||
public Memory(int address, int size) throws MemoryRangeException {
|
||||
this(address, size, false);
|
||||
public Memory(int startAddress, int endAddress) throws MemoryRangeException {
|
||||
this(startAddress, endAddress, false);
|
||||
}
|
||||
|
||||
public static Memory makeROM(int address, int size, File f) throws MemoryRangeException, IOException {
|
||||
Memory memory = new Memory(address, size, true);
|
||||
public static Memory makeROM(int startAddress, int endAddress, File f) throws MemoryRangeException, IOException {
|
||||
Memory memory = new Memory(startAddress, endAddress, true);
|
||||
memory.loadFromFile(f);
|
||||
return memory;
|
||||
}
|
||||
|
||||
public static Memory makeRAM(int address, int size) throws MemoryRangeException {
|
||||
Memory memory = new Memory(address, size, false);
|
||||
public static Memory makeRAM(int startAddress, int endAddress) throws MemoryRangeException {
|
||||
Memory memory = new Memory(startAddress, endAddress, false);
|
||||
return memory;
|
||||
}
|
||||
|
||||
@@ -112,4 +112,4 @@ public class Memory extends Device {
|
||||
public int[] getDmaAccess() {
|
||||
return mem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class Via extends Device {
|
||||
private static final int ORA_H = 15;
|
||||
|
||||
public Via(int address) throws MemoryRangeException {
|
||||
super(address, VIA_SIZE, "VIA");
|
||||
super(address, address + VIA_SIZE - 1, "VIA");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user