You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.2 KiB
Java

package net.brokenmoon;
import com.simon816.j65el02.device.FileDiskDriver;
import com.simon816.j65el02.device.RPDrive;
import com.simon816.j65el02.device.RPMonitor;
import com.simon816.j65el02.device.RedBus;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
public class Main {
static Path rpcboot;
static Path disk;
static {
try {
rpcboot = Paths.get(Main.class.getResource("/rpcboot.bin").toURI());
disk = Paths.get(Main.class.getResource("/basic.img").toURI());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
static long interruptTimer = 50L;
//Adjust as needed to match original clock speed
static long frequency = 2L;
static BasicMonitorDriver monitorDriver;
static Timer timer1 = new Timer();
static Timer timer2 = new Timer();
public static void main(String[] args) {
RedBus redBus = new RedBus();
Emulator core = new Emulator(redBus);
TimerTask interruptTask = new TimerTask(){
public void run(){
if(core.cpu.isWaitingForInterrupt())
core.cpu.state.irqDisableFlag = true;
}
};
TimerTask cpuTask = new TimerTask(){
public void run(){
for(int i = 0; i < 50; i++) {
core.step();
}
}
};
try {
FileDiskDriver tetrisDrive = new FileDiskDriver(disk, "tetrisDrive", "TETRIS", false);
monitorDriver = new BasicMonitorDriver();
RPDrive diskDrive = new RPDrive(tetrisDrive);
RPMonitor monitor = new RPMonitor(monitorDriver);
redBus.setPeripheral(2, diskDrive);
redBus.setPeripheral(1, monitor);
System.out.println("Started emu thread");
System.out.println("Started display thread");
timer1.schedule(interruptTask, new Date(), interruptTimer);
timer2.schedule(cpuTask, new Date(), frequency);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}