Commit d5f32759 by Jessica Hawkwell

slight refactoring, adding new capabilities

1 parent 8aa59d72
Pipeline #204 failed
in 12 seconds
...@@ -17,7 +17,8 @@ import me.felinewith.kcpu.hardware.Kmcp; ...@@ -17,7 +17,8 @@ import me.felinewith.kcpu.hardware.Kmcp;
import me.felinewith.kcpu.memory.BootRom; import me.felinewith.kcpu.memory.BootRom;
import me.felinewith.kcpu.memory.Buffer; import me.felinewith.kcpu.memory.Buffer;
import me.felinewith.kcpu.util.BaseDevice; import me.felinewith.kcpu.util.BaseDevice;
import me.felinewith.kcpu.util.HardwareTask; import me.felinewith.kcpu.util.HardwareExec;
import me.felinewith.kcpu.util.HardwareMemIrq;
/** /**
* *
...@@ -72,7 +73,7 @@ public class KBoard extends BaseDevice implements IMemory { ...@@ -72,7 +73,7 @@ public class KBoard extends BaseDevice implements IMemory {
attachMemory(0, 0xff00, new Buffer()); attachMemory(0, 0xff00, new Buffer());
attachMemory(1, 0x1000, new BootRom()); attachMemory(1, 0x1000, new BootRom());
tt = new HardwareTask(devices[0]); tt = new HardwareExec(devices[0]);
t = new Timer("CPU Cycler"); t = new Timer("CPU Cycler");
t.schedule(tt, 0, 1); t.schedule(tt, 0, 1);
} }
...@@ -84,11 +85,12 @@ public class KBoard extends BaseDevice implements IMemory { ...@@ -84,11 +85,12 @@ public class KBoard extends BaseDevice implements IMemory {
else if ( dev <= 0x0f ) { else if ( dev <= 0x0f ) {
short devOff = deviceMaps[rdev].getOffset(); short devOff = deviceMaps[rdev].getOffset();
short devAddr = (short)(addr - devOff); short devAddr = (short)(addr - devOff);
devices[rdev].memIrq(devAddr); tpe.execute(new HardwareMemIrq(devices[rdev], devAddr));
} }
else if ( 0x10 <= dev && dev <= 0x1f ) { else if ( 0x10 <= dev && dev <= 0x1f ) {
short devOff = memDevMaps[rdev].getOffset(); short devOff = memDevMaps[rdev].getOffset();
short devAddr = (short)(addr - devOff); short devAddr = (short)(addr - devOff);
tpe.execute(new HardwareMemIrq(memDevs[rdev], devAddr));
memDevs[rdev].memIrq(devAddr); memDevs[rdev].memIrq(devAddr);
} }
...@@ -96,7 +98,7 @@ public class KBoard extends BaseDevice implements IMemory { ...@@ -96,7 +98,7 @@ public class KBoard extends BaseDevice implements IMemory {
@Override public void sendIrq(byte irq) { @Override public void sendIrq(byte irq) {
if ( irq >= 16 ) { return; } if ( irq >= 16 ) { return; }
if ( devices[irq] != null ) { devices[irq].exec(); } if ( devices[irq] != null ) { tpe.execute(new HardwareExec(devices[irq])); }
} }
@Override public short length() { return (short)memory.length; }; @Override public short length() { return (short)memory.length; };
...@@ -133,9 +135,9 @@ public class KBoard extends BaseDevice implements IMemory { ...@@ -133,9 +135,9 @@ public class KBoard extends BaseDevice implements IMemory {
memory[addr] = data; memory[addr] = data;
} }
private void attachDevice(int port, int offset, IDevice device) { public void attachDevice(int port, int offset, IDevice device) {
attachDevice(port, (short)offset, device); } attachDevice(port, (short)offset, device); }
private void attachDevice(int port, short offset, IDevice device) { public void attachDevice(int port, short offset, IDevice device) {
if ( devices[port] != null ) { return; } if ( devices[port] != null ) { return; }
else if ( deviceMaps[port] != null ) { return; } else if ( deviceMaps[port] != null ) { return; }
...@@ -145,9 +147,9 @@ public class KBoard extends BaseDevice implements IMemory { ...@@ -145,9 +147,9 @@ public class KBoard extends BaseDevice implements IMemory {
device.init(this); device.init(this);
} }
private void attachMemory(int port, int offset, IMemory device) { public void attachMemory(int port, int offset, IMemory device) {
attachMemory(port, (short)offset, device); } attachMemory(port, (short)offset, device); }
private void attachMemory(int port, short offset, IMemory device) { public void attachMemory(int port, short offset, IMemory device) {
if ( memDevs[port] != null ) { return; } if ( memDevs[port] != null ) { return; }
else if ( memDevMaps[port] != null ) { return; } else if ( memDevMaps[port] != null ) { return; }
...@@ -155,7 +157,7 @@ public class KBoard extends BaseDevice implements IMemory { ...@@ -155,7 +157,7 @@ public class KBoard extends BaseDevice implements IMemory {
memDevMaps[port] = new KMemoryRange(offset, device.length()); memDevMaps[port] = new KMemoryRange(offset, device.length());
} }
private short checkDevice(short addr) { public short checkDevice(short addr) {
short a; short a;
KMemoryRange io; KMemoryRange io;
......
...@@ -109,6 +109,12 @@ public class Kcpu extends TimerTask implements IDevice { ...@@ -109,6 +109,12 @@ public class Kcpu extends TimerTask implements IDevice {
short rd = (short)(0x03 & d); short rd = (short)(0x03 & d);
switch (od) { switch (od) {
// ask what device is using which address
case ASK : registers[0] = board.checkDevice((short)0);
case ASK: registers[0] = board.checkDevice((short)0);
case ASK: registers[0] = board.checkDevice((short)0);
case ASK: registers[0] = board.checkDevice((short)0);
// interrupt to port // interrupt to port
case IRQD : board.sendIrq((byte)registers[0]); return; case IRQD : board.sendIrq((byte)registers[0]); return;
case IRQD_A: board.sendIrq((byte)MemHelper.readShort(a, board)); return; case IRQD_A: board.sendIrq((byte)MemHelper.readShort(a, board)); return;
......
...@@ -10,7 +10,7 @@ import me.felinewith.kcpu.util.BaseMemory; ...@@ -10,7 +10,7 @@ import me.felinewith.kcpu.util.BaseMemory;
public class BootRom extends BaseMemory { public class BootRom extends BaseMemory {
public BootRom() { public BootRom() {
memory = new byte[0x0fff]; memory = new byte[0x1000];
Arrays.fill(memory, (byte)0x75); Arrays.fill(memory, (byte)0x75);
} }
......
...@@ -24,6 +24,26 @@ public enum OpDirector { ...@@ -24,6 +24,26 @@ public enum OpDirector {
MOVAA(0x0017, Memory.class), MOVAA(0x0017, Memory.class),
// cpu stuffies // cpu stuffies
ASK_AA(0x1000, null),
ASK_AD(0x1001, null),
ASK_AN(0x1002, null),
ASK_AR(0x1003, null),
ASK_DA(0x1004, null),
ASK_DD(0x1005, null),
ASK_DN(0x1006, null),
ASK_DR(0x1007, null),
ASK_NA(0x1010, null),
ASK_ND(0x1011, null),
ASK_NN(0x1012, null),
ASK_NR(0x1013, null),
ASK_RA(0x1014, null),
ASK_RD(0x1015, null),
ASK_RN(0x1016, null),
ASK_RR(0x1017, null),
IRQM (0x8f00, null), IRQM (0x8f00, null),
IRQM_R(0x8f01, null), IRQM_R(0x8f01, null),
IRQM_D(0x8f02, null), IRQM_D(0x8f02, null),
......
...@@ -7,15 +7,12 @@ import me.felinewith.kcpu.IDevice; ...@@ -7,15 +7,12 @@ import me.felinewith.kcpu.IDevice;
* *
* @author jlhawkwell * @author jlhawkwell
*/ */
public class HardwareTask extends TimerTask { public class HardwareExec extends TimerTask {
IDevice id; IDevice id;
public HardwareTask(IDevice device) { public HardwareExec(IDevice device) {
id = device; id = device;
} }
@Override public void run() { @Override public void run() { id.exec(); }
id.exec();
}
} }
package me.felinewith.kcpu.util;
import java.util.TimerTask;
import me.felinewith.kcpu.IMemory;
/**
*
* @author jlhawkwell
*/
public class HardwareMemIrq extends TimerTask {
IMemory id;
short a;
public HardwareMemIrq(IMemory device, short addr) {
id = device;
a = addr;
}
@Override public void run() { id.memIrq(a); }
}
package me.felinewith.kcpu.util;
import java.util.TimerTask;
import me.felinewith.kcpu.IDevice;
/**
*
* @author jlhawkwell
*/
public class HardwareSendIrq extends TimerTask {
IDevice id;
byte i;
public HardwareSendIrq(IDevice device, byte irq) {
id = device;
i = irq;
}
@Override public void run() { id.sendIrq(i); }
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!