mirror of
https://github.com/sethm/symon.git
synced 2025-08-09 11:25:13 +00:00
Split PIA into PIA/VIA6522
This commit is contained in:
@@ -23,45 +23,19 @@
|
|||||||
|
|
||||||
package com.loomcom.symon.devices;
|
package com.loomcom.symon.devices;
|
||||||
|
|
||||||
import com.loomcom.symon.exceptions.MemoryAccessException;
|
|
||||||
import com.loomcom.symon.exceptions.MemoryRangeException;
|
import com.loomcom.symon.exceptions.MemoryRangeException;
|
||||||
|
|
||||||
public class Pia extends Device {
|
public abstract class Pia extends Device {
|
||||||
public static final int PIA_SIZE = 16;
|
|
||||||
|
|
||||||
private static final int ORB = 0;
|
private final String name;
|
||||||
private static final int ORA = 1;
|
|
||||||
private static final int DDRB = 2;
|
|
||||||
private static final int DDRA = 3;
|
|
||||||
private static final int T1C_L = 4;
|
|
||||||
private static final int T1C_H = 5;
|
|
||||||
private static final int T1L_L = 6;
|
|
||||||
private static final int T1L_H = 7;
|
|
||||||
private static final int T2C_L = 8;
|
|
||||||
private static final int T2C_H = 9;
|
|
||||||
private static final int SR = 10;
|
|
||||||
private static final int ACR = 11;
|
|
||||||
private static final int PCR = 12;
|
|
||||||
private static final int IFR = 13;
|
|
||||||
private static final int IER = 14;
|
|
||||||
private static final int ORA_H = 15;
|
|
||||||
|
|
||||||
public Pia(int address) throws MemoryRangeException {
|
public Pia(int startAddress, int endAddress, String name) throws MemoryRangeException {
|
||||||
super(address, address + PIA_SIZE - 1, "PIA");
|
super(startAddress, endAddress, name);
|
||||||
}
|
this.name = name;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(int address, int data) throws MemoryAccessException {
|
|
||||||
; // No-Op
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read(int address) throws MemoryAccessException {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return null;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
90
src/main/java/com/loomcom/symon/devices/Via6522.java
Normal file
90
src/main/java/com/loomcom/symon/devices/Via6522.java
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package com.loomcom.symon.devices;
|
||||||
|
|
||||||
|
import com.loomcom.symon.exceptions.MemoryAccessException;
|
||||||
|
import com.loomcom.symon.exceptions.MemoryRangeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Very basic implementation of a MOS 6522 VIA.
|
||||||
|
*
|
||||||
|
* TODO: Implement timers as threads.
|
||||||
|
*/
|
||||||
|
public class Via6522 extends Pia {
|
||||||
|
public static final int VIA_SIZE = 16;
|
||||||
|
|
||||||
|
enum Register {
|
||||||
|
ORB, ORA, DDRB, DDRA, T1C_L, T1C_H, T1L_L, T1L_H,
|
||||||
|
T2C_L, T2C_H, SR, ACR, PCR, IFR, IER, ORA_H
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ports A and B
|
||||||
|
private char[] portData = {0, 0};
|
||||||
|
private char[] portDirections = {0, 0};
|
||||||
|
|
||||||
|
public Via6522(int address) throws MemoryRangeException {
|
||||||
|
super(address, address + VIA_SIZE - 1, "MOS 6522 VIA");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(int address, int data) throws MemoryAccessException {
|
||||||
|
Register[] registers = Register.values();
|
||||||
|
|
||||||
|
if (address >= registers.length) {
|
||||||
|
throw new MemoryAccessException("Unknown register: " + address);
|
||||||
|
}
|
||||||
|
|
||||||
|
Register r = registers[address];
|
||||||
|
|
||||||
|
switch (r) {
|
||||||
|
case ORA:
|
||||||
|
case ORB:
|
||||||
|
case DDRA:
|
||||||
|
case DDRB:
|
||||||
|
case T1C_L:
|
||||||
|
case T1C_H:
|
||||||
|
case T1L_L:
|
||||||
|
case T1L_H:
|
||||||
|
case T2C_L:
|
||||||
|
case T2C_H:
|
||||||
|
case SR:
|
||||||
|
case ACR:
|
||||||
|
case PCR:
|
||||||
|
case IFR:
|
||||||
|
case IER:
|
||||||
|
case ORA_H:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int read(int address) throws MemoryAccessException {
|
||||||
|
Register[] registers = Register.values();
|
||||||
|
|
||||||
|
if (address >= registers.length) {
|
||||||
|
throw new MemoryAccessException("Unknown register: " + address);
|
||||||
|
}
|
||||||
|
|
||||||
|
Register r = registers[address];
|
||||||
|
|
||||||
|
switch (r) {
|
||||||
|
case ORA:
|
||||||
|
case ORB:
|
||||||
|
case DDRA:
|
||||||
|
case DDRB:
|
||||||
|
case T1C_L:
|
||||||
|
case T1C_H:
|
||||||
|
case T1L_L:
|
||||||
|
case T1L_H:
|
||||||
|
case T2C_L:
|
||||||
|
case T2C_H:
|
||||||
|
case SR:
|
||||||
|
case ACR:
|
||||||
|
case PCR:
|
||||||
|
case IFR:
|
||||||
|
case IER:
|
||||||
|
case ORA_H:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@@ -26,11 +26,7 @@ package com.loomcom.symon.machines;
|
|||||||
|
|
||||||
import com.loomcom.symon.Bus;
|
import com.loomcom.symon.Bus;
|
||||||
import com.loomcom.symon.Cpu;
|
import com.loomcom.symon.Cpu;
|
||||||
import com.loomcom.symon.devices.Acia;
|
import com.loomcom.symon.devices.*;
|
||||||
import com.loomcom.symon.devices.Acia6551;
|
|
||||||
import com.loomcom.symon.devices.Crtc;
|
|
||||||
import com.loomcom.symon.devices.Memory;
|
|
||||||
import com.loomcom.symon.devices.Pia;
|
|
||||||
import com.loomcom.symon.exceptions.MemoryRangeException;
|
import com.loomcom.symon.exceptions.MemoryRangeException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -78,7 +74,7 @@ public class SymonMachine implements Machine {
|
|||||||
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.ram = new Memory(MEMORY_BASE, MEMORY_BASE + MEMORY_SIZE - 1, false);
|
||||||
this.pia = new Pia(PIA_BASE);
|
this.pia = new Via6522(PIA_BASE);
|
||||||
this.acia = new Acia6551(ACIA_BASE);
|
this.acia = new Acia6551(ACIA_BASE);
|
||||||
this.crtc = new Crtc(CRTC_BASE, ram);
|
this.crtc = new Crtc(CRTC_BASE, ram);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user