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
+50
-65
No files matched your search
@@ -3,11 +3,11 @@ SYMON - A 6502 System Simulator
|
|||||||
|
|
||||||
**NOTE: THIS SOFTWARE IS UNDER ACTIVE DEVELOPMENT. Feedback is welcome!**
|
**NOTE: THIS SOFTWARE IS UNDER ACTIVE DEVELOPMENT. Feedback is welcome!**
|
||||||
|
|
||||||
**Version:** 0.8.5
|
**Version:** 0.9.0
|
||||||
|
|
||||||
**Last Updated:** 30 March, 2013
|
**Last Updated:** 29 December, 2013
|
||||||
|
|
||||||
Copyright (c) 2008-2013 Seth J. Morabito <web@loomcom.com>
|
Copyright (c) 2013 Seth J. Morabito <web@loomcom.com>
|
||||||
|
|
||||||
See the file COPYING for license.
|
See the file COPYING for license.
|
||||||
|
|
||||||
@@ -139,6 +139,8 @@ running.
|
|||||||
|
|
||||||
## 5.0 Revision History
|
## 5.0 Revision History
|
||||||
|
|
||||||
|
- **0.9.0:** 29 December, 2013 - First pass at a 6545 CRTC simulation.
|
||||||
|
|
||||||
- **0.8.5:** 30 March, 2013 - ASCII display for memory window.
|
- **0.8.5:** 30 March, 2013 - ASCII display for memory window.
|
||||||
Allows user to select a step count from a drop-down box.
|
Allows user to select a step count from a drop-down box.
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<groupId>com.loomcom.symon</groupId>
|
<groupId>com.loomcom.symon</groupId>
|
||||||
<artifactId>symon</artifactId>
|
<artifactId>symon</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>0.8.5</version>
|
<version>0.9.0</version>
|
||||||
<name>symon</name>
|
<name>symon</name>
|
||||||
<url>http://www.loomcom.com/symon</url>
|
<url>http://www.loomcom.com/symon</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -114,40 +114,14 @@ public class Bus {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop over devices and ensure they are contiguous.
|
// Loop over devices and add their size
|
||||||
MemoryRange prev = null;
|
int filledMemory = 0;
|
||||||
int i = 0;
|
|
||||||
int length = devices.size();
|
|
||||||
for (Device d : devices) {
|
for (Device d : devices) {
|
||||||
MemoryRange cur = d.getMemoryRange();
|
filledMemory += d.getSize();
|
||||||
if (i == 0) {
|
|
||||||
// If the first entry doesn't start at 'startAddress', return false.
|
|
||||||
if (cur.startAddress() != startAddress) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prev != null && i < length - 1) {
|
|
||||||
// Otherwise, compare previous map's end against this map's
|
|
||||||
// endAddress. They must be adjacent!
|
|
||||||
if (cur.startAddress() - 1 != prev.endAddress()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == length - 1) {
|
|
||||||
// If the last entry doesn't end at endAddress, return false;
|
|
||||||
if (cur.endAddress() != endAddress) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
prev = cur;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must be complete.
|
// Returns if the total size of the devices fill the bus' memory space
|
||||||
return true;
|
return filledMemory == endAddress - startAddress + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read(int address) throws MemoryAccessException {
|
public int read(int address) throws MemoryAccessException {
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public class Simulator {
|
|||||||
private static final int MEMORY_SIZE = 0x8000;
|
private static final int MEMORY_SIZE = 0x8000;
|
||||||
|
|
||||||
// VIA at $8000-$800F
|
// VIA at $8000-$800F
|
||||||
|
|
||||||
private static final int VIA_BASE = 0x8000;
|
private static final int VIA_BASE = 0x8000;
|
||||||
|
|
||||||
// ACIA at $8800-$8803
|
// ACIA at $8800-$8803
|
||||||
@@ -152,10 +153,9 @@ public class Simulator {
|
|||||||
private static final String[] STEPS = {"1", "5", "10", "20", "50", "100"};
|
private static final String[] STEPS = {"1", "5", "10", "20", "50", "100"};
|
||||||
|
|
||||||
public Simulator() throws MemoryRangeException, IOException {
|
public Simulator() throws MemoryRangeException, IOException {
|
||||||
this.ram = new Memory(MEMORY_BASE, MEMORY_SIZE, false);
|
|
||||||
|
|
||||||
this.bus = new Bus(BUS_BOTTOM, BUS_TOP);
|
this.bus = new Bus(BUS_BOTTOM, BUS_TOP);
|
||||||
this.cpu = new Cpu();
|
this.cpu = new Cpu();
|
||||||
|
this.ram = new Memory(MEMORY_BASE, MEMORY_BASE + MEMORY_SIZE - 1, false);
|
||||||
this.via = new Via(VIA_BASE);
|
this.via = new Via(VIA_BASE);
|
||||||
this.acia = new Acia(ACIA_BASE);
|
this.acia = new Acia(ACIA_BASE);
|
||||||
this.crtc = new Crtc(CRTC_BASE, ram);
|
this.crtc = new Crtc(CRTC_BASE, ram);
|
||||||
@@ -171,11 +171,11 @@ public class Simulator {
|
|||||||
File romImage = new File("rom.bin");
|
File romImage = new File("rom.bin");
|
||||||
if (romImage.canRead()) {
|
if (romImage.canRead()) {
|
||||||
logger.info("Loading ROM image from file " + romImage);
|
logger.info("Loading ROM image from file " + romImage);
|
||||||
this.rom = Memory.makeROM(ROM_BASE, ROM_SIZE, romImage);
|
this.rom = Memory.makeROM(ROM_BASE, ROM_BASE + ROM_SIZE - 1, romImage);
|
||||||
} else {
|
} else {
|
||||||
logger.info("Default ROM file " + romImage +
|
logger.info("Default ROM file " + romImage +
|
||||||
" not found, loading empty R/W memory image.");
|
" not found, loading empty R/W memory image.");
|
||||||
this.rom = Memory.makeRAM(ROM_BASE, ROM_SIZE);
|
this.rom = Memory.makeRAM(ROM_BASE, ROM_BASE + ROM_SIZE - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bus.addDevice(rom);
|
bus.addDevice(rom);
|
||||||
@@ -585,7 +585,7 @@ public class Simulator {
|
|||||||
bus.removeDevice(rom);
|
bus.removeDevice(rom);
|
||||||
}
|
}
|
||||||
// Load the new ROM image
|
// Load the new ROM image
|
||||||
rom = Memory.makeROM(ROM_BASE, ROM_SIZE, romFile);
|
rom = Memory.makeROM(ROM_BASE, ROM_BASE + ROM_SIZE - 1, romFile);
|
||||||
bus.addDevice(rom);
|
bus.addDevice(rom);
|
||||||
|
|
||||||
// Now, reset
|
// Now, reset
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class Acia extends Device {
|
|||||||
private boolean txEmpty = true;
|
private boolean txEmpty = true;
|
||||||
|
|
||||||
public Acia(int address) throws MemoryRangeException {
|
public Acia(int address) throws MemoryRangeException {
|
||||||
super(address, ACIA_SIZE, "ACIA");
|
super(address, address + ACIA_SIZE - 1, "ACIA");
|
||||||
this.baseAddress = address;
|
this.baseAddress = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class Crtc extends Device {
|
|||||||
private Memory memory;
|
private Memory memory;
|
||||||
|
|
||||||
public Crtc(int deviceAddress, Memory memory) throws MemoryRangeException, IOException {
|
public Crtc(int deviceAddress, Memory memory) throws MemoryRangeException, IOException {
|
||||||
super(deviceAddress, 2, "CRTC");
|
super(deviceAddress, deviceAddress + 2, "CRTC");
|
||||||
this.memory = memory;
|
this.memory = memory;
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ import java.util.Set;
|
|||||||
|
|
||||||
public abstract class Device implements Comparable<Device> {
|
public abstract class Device implements Comparable<Device> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Size of the device in memory
|
||||||
|
*/
|
||||||
|
int size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The memory range for this device.
|
* The memory range for this device.
|
||||||
*/
|
*/
|
||||||
@@ -57,15 +62,16 @@ public abstract class Device implements Comparable<Device> {
|
|||||||
*/
|
*/
|
||||||
private Set<DeviceChangeListener> deviceChangeListeners;
|
private Set<DeviceChangeListener> deviceChangeListeners;
|
||||||
|
|
||||||
public Device(int address, int size, String name)
|
public Device(int startAddress, int endAddress, String name)
|
||||||
throws MemoryRangeException {
|
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.name = name;
|
||||||
this.deviceChangeListeners = new HashSet<DeviceChangeListener>();
|
this.deviceChangeListeners = new HashSet<DeviceChangeListener>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Device(int address, int size) throws MemoryRangeException {
|
public Device(int startAddress, int endAddress) throws MemoryRangeException {
|
||||||
this(address, size, null);
|
this(startAddress, endAddress, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Methods required to be implemented by inheriting classes. */
|
/* Methods required to be implemented by inheriting classes. */
|
||||||
@@ -103,6 +109,10 @@ public abstract class Device implements Comparable<Device> {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
public void registerListener(DeviceChangeListener listener) {
|
public void registerListener(DeviceChangeListener listener) {
|
||||||
deviceChangeListeners.add(listener);
|
deviceChangeListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,26 +38,26 @@ public class Memory extends Device {
|
|||||||
/* Initialize all locations to 0x00 (BRK) */
|
/* Initialize all locations to 0x00 (BRK) */
|
||||||
private static final int DEFAULT_FILL = 0x00;
|
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 {
|
throws MemoryRangeException {
|
||||||
super(address, size, (readOnly ? "RO Memory" : "RW Memory"));
|
super(startAddress, endAddress, (readOnly ? "RO Memory" : "RW Memory"));
|
||||||
this.readOnly = readOnly;
|
this.readOnly = readOnly;
|
||||||
this.mem = new int[size];
|
this.mem = new int[this.size];
|
||||||
this.fill(DEFAULT_FILL);
|
this.fill(DEFAULT_FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Memory(int address, int size) throws MemoryRangeException {
|
public Memory(int startAddress, int endAddress) throws MemoryRangeException {
|
||||||
this(address, size, false);
|
this(startAddress, endAddress, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Memory makeROM(int address, int size, File f) throws MemoryRangeException, IOException {
|
public static Memory makeROM(int startAddress, int endAddress, File f) throws MemoryRangeException, IOException {
|
||||||
Memory memory = new Memory(address, size, true);
|
Memory memory = new Memory(startAddress, endAddress, true);
|
||||||
memory.loadFromFile(f);
|
memory.loadFromFile(f);
|
||||||
return memory;
|
return memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Memory makeRAM(int address, int size) throws MemoryRangeException {
|
public static Memory makeRAM(int startAddress, int endAddress) throws MemoryRangeException {
|
||||||
Memory memory = new Memory(address, size, false);
|
Memory memory = new Memory(startAddress, endAddress, false);
|
||||||
return memory;
|
return memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class Via extends Device {
|
|||||||
private static final int ORA_H = 15;
|
private static final int ORA_H = 15;
|
||||||
|
|
||||||
public Via(int address) throws MemoryRangeException {
|
public Via(int address) throws MemoryRangeException {
|
||||||
super(address, VIA_SIZE, "VIA");
|
super(address, address + VIA_SIZE - 1, "VIA");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ public class BusTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testAddDevice() throws MemoryRangeException {
|
public void testAddDevice() throws MemoryRangeException {
|
||||||
Device memory = new Memory(0x0000, 0x0100, true);
|
Device memory = new Memory(0x0000, 0x00ff, true);
|
||||||
Device rom = new Memory(0x0100, 0x0200, false);
|
Device rom = new Memory(0x0100, 0x02ff, false);
|
||||||
|
|
||||||
Bus b = new Bus(0x0000, 0xffff);
|
Bus b = new Bus(0x0000, 0xffff);
|
||||||
|
|
||||||
@@ -85,8 +85,7 @@ public class BusTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testIsCompleteWithOneDevice() throws MemoryRangeException {
|
public void testIsCompleteWithOneDevice() throws MemoryRangeException {
|
||||||
Device memory = new Memory(0x0000, 0x10000, true);
|
Device memory = new Memory(0x0000, 0xffff, true);
|
||||||
|
|
||||||
Bus b = new Bus(0x0000, 0xffff);
|
Bus b = new Bus(0x0000, 0xffff);
|
||||||
assertFalse("Address space was unexpectedly complete!", b.isComplete());
|
assertFalse("Address space was unexpectedly complete!", b.isComplete());
|
||||||
b.addDevice(memory);
|
b.addDevice(memory);
|
||||||
@@ -94,8 +93,8 @@ public class BusTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testIsCompleteWithTwoDevices() throws MemoryRangeException {
|
public void testIsCompleteWithTwoDevices() throws MemoryRangeException {
|
||||||
Device memory = new Memory(0x0000, 0x8000, true);
|
Device memory = new Memory(0x0000, 0x7fff, true);
|
||||||
Device rom = new Memory(0x8000, 0x8000, false);
|
Device rom = new Memory(0x8000, 0xffff, false);
|
||||||
|
|
||||||
Bus b = new Bus(0x0000, 0xffff);
|
Bus b = new Bus(0x0000, 0xffff);
|
||||||
assertFalse("Address space was unexpectedly complete!", b.isComplete());
|
assertFalse("Address space was unexpectedly complete!", b.isComplete());
|
||||||
@@ -106,9 +105,9 @@ public class BusTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testIsCompleteWithThreeDevices() throws MemoryRangeException {
|
public void testIsCompleteWithThreeDevices() throws MemoryRangeException {
|
||||||
Device memory = new Memory(0x0000, 0x8000, true);
|
Device memory = new Memory(0x0000, 0x7fff, true);
|
||||||
Device rom1 = new Memory(0x8000, 0x4000, false);
|
Device rom1 = new Memory(0x8000, 0xBfff, false);
|
||||||
Device rom2 = new Memory(0xC000, 0x4000, false);
|
Device rom2 = new Memory(0xC000, 0xffff, false);
|
||||||
|
|
||||||
Bus b = new Bus(0x0000, 0xffff);
|
Bus b = new Bus(0x0000, 0xffff);
|
||||||
assertFalse("Address space was unexpectedly complete!", b.isComplete());
|
assertFalse("Address space was unexpectedly complete!", b.isComplete());
|
||||||
|
|||||||
Reference in new issue
Block a user