Work In Progress: CPU behavior, UI changes

This is something of a "Work in Progress" checkpoint of several features
that are all half baked:

1. Allow loading of 16KB ROM files at address $C000 at run-time, not
   just at startup. See the "Load ROM..." File menu item.

2. Introduces the notion of "CPU Behaviors", so the core 6502 CPU
   implementation can match the behavior of either an early NMOS 6502, late
   NMOS 6502, or CMOS 65C02. Very little of this is actually implemented so
   far.

3. Adds a completely bogus implementation of the 6522 VIA (it
   does absolutely nothing right now).

4. Changes the address of the ACIA in the simulated system to match a
   real hardware implementation I put together.
This commit is contained in:
Seth Morabito committed 2012-11-25 22:49:21 -08:00
1 parent 795ccfde5d
commit 2ebdd254b3
33 files changed
+822 -443

No files matched your search

@@ -2,77 +2,57 @@ package com.loomcom.symon.util;
import com.loomcom.symon.exceptions.*;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
/**
* A very simple and efficient FIFO ring buffer implementation backed
* by an array. It can only hold only integers.
* A FIFO buffer with a bounded maximum size.
*/
public class FifoRingBuffer {
public class FifoRingBuffer<E> implements Iterable<E> {
private int[] fifoBuffer;
private int readPtr = 0;
private int writePtr = 0;
private int size = 0;
private Queue<E> fifoBuffer;
private int maxLength;
public FifoRingBuffer(int size) {
if (size <= 0) {
throw new RuntimeException("Cannot create a FifoRingBuffer with size <= 0.");
public FifoRingBuffer(int maxLength) {
this.fifoBuffer = new LinkedList<E>();
this.maxLength = maxLength;
}
this.size = size;
fifoBuffer = new int[size];
}
public int peek() throws FifoUnderrunException {
if (isEmpty()) {
throw new FifoUnderrunException("Buffer Underrun");
public E pop() throws FifoUnderrunException {
return fifoBuffer.remove();
}
return fifoBuffer[readPtr];
}
public int pop() throws FifoUnderrunException {
if (isEmpty()) {
throw new FifoUnderrunException("Buffer Underrun");
public boolean isEmpty() {
return fifoBuffer.isEmpty();
}
int val = fifoBuffer[readPtr];
incrementReadPointer();
return val;
}
public boolean isEmpty() {
return(readPtr == writePtr);
}
public boolean isFull() {
return((readPtr == 0 && writePtr == (size - 1)) ||
writePtr == (readPtr - 1));
}
public void push(int val) {
fifoBuffer[writePtr] = val;
incrementWritePointer();
}
public void reset() {
readPtr = 0;
writePtr = 0;
}
private void incrementWritePointer() {
if (++writePtr == size) {
writePtr = 0;
public void push(E val) {
if (fifoBuffer.size() == maxLength) {
// Delete the oldest element.
fifoBuffer.remove();
}
fifoBuffer.offer(val);
}
if (writePtr == readPtr) {
incrementReadPointer();
}
}
private void incrementReadPointer() {
if (++readPtr == size) {
readPtr = 0;
public E peek() {
return fifoBuffer.peek();
}
}
public String toString() {
return "[FifoRingBuffer: size=" + size + "]";
}
public void reset() {
fifoBuffer.clear();
}
public int length() {
return fifoBuffer.size();
}
public String toString() {
return "[FifoRingBuffer: size=" + fifoBuffer.size() + "]";
}
public Iterator<E> iterator() {
return fifoBuffer.iterator();
}
}