Functional

main
Astoria 7 months ago
parent d6fc1bfe5c
commit 0ba53d2149

@ -1,6 +1,5 @@
package net.brokenmoon;
import com.simon816.j65el02.Machine;
import com.simon816.j65el02.device.MonitorDriver;
import com.simon816.j65el02.device.RPMonitor;
@ -23,13 +22,11 @@ public class BasicMonitorDriver implements MonitorDriver, KeyListener {
BufferedImage display;
JLabel[] lines = new JLabel[HEIGHT];
Machine emu;
byte[][] windowDataOld = new byte[HEIGHT][WIDTH];
int xoffset = 30;
int yoffset = 26;
public BasicMonitorDriver() {
this.emu = emu;
try{
display = ImageIO.read(Objects.requireNonNull(getClass().getResourceAsStream("/display.png")));
} catch(IOException e){

@ -0,0 +1,59 @@
package net.brokenmoon;
import com.simon816.j65el02.Bus;
import com.simon816.j65el02.Cpu;
import com.simon816.j65el02.device.Memory;
import com.simon816.j65el02.device.RedBus;
import com.simon816.j65el02.device.RedBusState;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Paths;
public class Emulator {
private RedBus bus;
public Cpu cpu;
private Memory ram;
public Emulator(RedBus bus) {
this.bus = bus;
cpu = new Cpu();
cpu.setBus(new Bus(bus));
ram = new Memory(0x0000, 0x4000, new RedBusState());
try {
ram.loadFromFile(Paths.get(Main.class.getResource("/rpcboot.bin").toURI()), 0x400, 0x100);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
cpu.getBus().addDevice(ram, cpu.redBusState);
cpu.reset();
ram.write(0, 2, cpu.redBusState);
ram.write(1, 1, cpu.redBusState);
System.out.println("Emulator made");
}
public RedBus getBus() {
return bus;
}
public void setBus(RedBus bus) {
this.bus = bus;
}
public boolean isWaitingOnInterrupt(){
return cpu.isWaitingForInterrupt();
}
public void setWaitingOnInterrupt(){
cpu.assertIrq();
}
public void step() {
this.cpu.step();
this.cpu.getBus().update(cpu.redBusState);
}
}

@ -1,6 +1,5 @@
package net.brokenmoon;
import com.simon816.j65el02.Machine;
import com.simon816.j65el02.device.FileDiskDriver;
import com.simon816.j65el02.device.RPDrive;
import com.simon816.j65el02.device.RPMonitor;
@ -21,7 +20,7 @@ public class Main {
static {
try {
rpcboot = Paths.get(Main.class.getResource("/rpcboot.bin").toURI());
disk = Paths.get(Main.class.getResource("/slideshow.img").toURI());
disk = Paths.get(Main.class.getResource("/basic.img").toURI());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
@ -42,14 +41,15 @@ public class Main {
TimerTask interruptTask = new TimerTask(){
public void run(){
if(core.cpu.isWaitingForInterrupt())
core.setWaitingOnInterrupt();
core.cpu.state.irqDisableFlag = true;
}
};
TimerTask cpuTask = new TimerTask(){
public void run(){
for(int i = 0; i < 50; i++)
for(int i = 0; i < 50; i++) {
core.step();
}
}
};

Binary file not shown.
Loading…
Cancel
Save