send bus to emulator

main
Astoria 7 months ago
parent 9ad756e11b
commit 17ff02dfe1

@ -41,6 +41,7 @@ public class Emulator {
public void setBus(RedBus bus) {
this.bus = bus;
this.cpu.getBus().setRedBus(bus);
}
public boolean isWaitingOnInterrupt(){
@ -52,7 +53,7 @@ public class Emulator {
}
public void step() {
if(!isWaitingOnInterrupt() && isRunning) {
if(!isWaitingOnInterrupt()) {
this.cpu.step();
this.cpu.getBus().update(cpu.redBusState);
}

@ -3,6 +3,7 @@ package net.brokenmoon.redcontrol.blockentities;
import com.simon816.j65el02.device.RedBus;
import net.brokenmoon.redcontrol.RedControl;
import net.brokenmoon.redcontrol.api.Emulator;
import net.brokenmoon.redcontrol.api.RCWorldBus;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -15,7 +16,7 @@ public class CpuEntity extends Peripheral{
public int i = 0;
public boolean notTicked = true;
public Emulator core;
public Emulator core = new Emulator(new RedBus());
private Path bootloader;
@ -31,10 +32,6 @@ public class CpuEntity extends Peripheral{
public static void tick(World world, BlockPos pos, BlockState state, CpuEntity be) {
if(be.notTicked) {
if (be.core == null){
RedControl.LOGGER.info("Making CpuEntity");
be.core = new Emulator(new RedBus());
}
be.reset();
be.notTicked = false;
}
@ -86,4 +83,12 @@ public class CpuEntity extends Peripheral{
public void update() {
}
@Override
public void setBus(RCWorldBus bus){
this.bus = bus.getRedBus();
this.core.setBus(this.bus);
this.bus.setPeripheral(id, this);
this.worldBus = bus;
}
}

Loading…
Cancel
Save