Functional
parent
d6fc1bfe5c
commit
0ba53d2149
@ -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);
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue