Get rid of a whole bunch of logspam, make block breaking less janky after world reload?

main
Astoria 7 months ago
parent 5a868589f0
commit 30151a0b9e

@ -1,5 +1,6 @@
package net.brokenmoon.redcontrol.api;
import com.simon816.j65el02.Bus;
import com.simon816.j65el02.Cpu;
import com.simon816.j65el02.CpuState;
import com.simon816.j65el02.device.Memory;
@ -20,7 +21,7 @@ public class Emulator {
public Emulator(RedBus bus){
this.bus = bus;
cpu = new Cpu();
cpu.setBus(new TempBus(bus));
cpu.setBus(new Bus(bus));
ram = new Memory(0x0000, 0x2000 - 1, ((CpuAccessor)cpu).getRedBusState());
try {
ram.loadFromFile(Paths.get("/home/astoria/code/java/mods/RedControl/src/main/resources/assets/redcontrol/image/rpcboot.bin"),0x400, 0x100);
@ -32,8 +33,6 @@ public class Emulator {
cpu.reset();
ram.write(0, 2, ((CpuAccessor)cpu).getRedBusState());
ram.write(1, 1, ((CpuAccessor)cpu).getRedBusState());
System.out.println("Emulator made");
System.out.println("Current PC position: " + this.cpu.getCpuState().pc);
}
public RedBus getBus() {
@ -41,7 +40,6 @@ public class Emulator {
}
public void setBus(RedBus bus) {
RedControl.LOGGER.info("Setting Emulator bus");
this.bus = bus;
((BusAccessor)this.cpu.getBus()).setRedBus(bus);
}
@ -57,7 +55,6 @@ public class Emulator {
public void step() {
if(!isWaitingOnInterrupt()) {
CpuState state = ((CpuAccessor)this.cpu).getState();
System.out.println(state.toTraceEvent());
this.cpu.step();
this.cpu.getBus().update(((CpuAccessor)cpu).getRedBusState());
}

@ -1,27 +0,0 @@
package net.brokenmoon.redcontrol.api;
import com.simon816.j65el02.Bus;
import com.simon816.j65el02.device.Device;
import com.simon816.j65el02.device.RedBus;
import com.simon816.j65el02.device.RedBusState;
import net.brokenmoon.redcontrol.RedControl;
public class TempBus extends Bus {
public TempBus(RedBus redBus) {
super(redBus);
}
@Override
public void write(int address, int data, RedBusState state) {
Device device = findDevice(address,state);
//RedControl.LOGGER.info("Writing to bus with device " + device + "at address " + (address - device.startAddress(state)) + " with data " + data + " with target " + state.activeDeviceId + " and redbus offset of " + state.offset);
device.write(address - device.startAddress(state) % 0x2000, data, state);
}
@Override
public int read(int address, boolean cpuAccess, RedBusState state) {
Device device = findDevice(address,state);
//RedControl.LOGGER.info("Reading from bus with device " + device + "at address " + (address - device.startAddress(state)) + " with target " + state.activeDeviceId + " and redbus offset of " + state.offset);
return device.read(address - device.startAddress(state) % 0x2000, cpuAccess, state) & 0xff;
}
}

@ -1,33 +0,0 @@
package net.brokenmoon.redcontrol.api;
import com.simon816.j65el02.device.RedBus;
import com.simon816.j65el02.device.RedBusState;
import net.brokenmoon.redcontrol.RedControl;
public class TempRedBus extends RedBus {
@Override
public void write(int address, int data, RedBusState state) {
RedControl.LOGGER.info("Writing at " + address);
if (!state.enabled) {
return;
}
Peripheral peripheral = this.peripherals[state.activeDeviceId];
if (peripheral != null) {
peripheral.write(address, data & 0xff);
}
}
@Override
public int read(int address, boolean cpuAccess, RedBusState state) {
RedControl.LOGGER.info("Reading at " + address);
if (!state.enabled) {
return 0;
}
Peripheral peripheral = this.peripherals[state.activeDeviceId];
if (peripheral != null) {
return peripheral.read(address);
}
return 0;
}
}

@ -4,20 +4,15 @@ 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.brokenmoon.redcontrol.api.TempRedBus;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
public class CpuEntity extends Peripheral{
public int i = 0;
public boolean notTicked = true;
public Emulator core = new Emulator(new TempRedBus());
public Emulator core = new Emulator(new RedBus());
private int defaultMonitorId = 1;
private int defaultDriveId = 2;
@ -27,13 +22,10 @@ public class CpuEntity extends Peripheral{
public static void tick(World world, BlockPos pos, BlockState state, CpuEntity be) {
if(be.notTicked) {
System.out.println("Ticking pre reset, PC at " + be.core.cpu.getCpuState().pc);
be.reset();
System.out.println("Ticking post reset, PC at " + be.core.cpu.getCpuState().pc);
be.notTicked = false;
}
for(int i = 0; i < 500; i++)
System.out.println("Stepping, PC at " + be.core.cpu.getCpuState().pc);
be.step();
if(be.core.isWaitingOnInterrupt()){
be.core.setWaitingOnInterrupt();

@ -60,7 +60,6 @@ public class DriveEntity extends Peripheral{
@Override
public int read(int address) {
RedControl.LOGGER.info("Drive Reading");
switch (address) {
case 0x80: // Sector number (lo)
return this.sector & 0xff;

@ -47,7 +47,6 @@ public class MonitorEntity extends Peripheral {
@Override
public void write(int address, int data) {
RedControl.LOGGER.info("Monitor Writing");
switch (address) {
case 0x00:
this.accessRow = data;
@ -146,7 +145,6 @@ public class MonitorEntity extends Peripheral {
@Override
public void update() {
RedControl.LOGGER.info("MONITOR UPDATED");
int maxWidth = Math.min(WIDTH, this.blitWidth + this.blitXOffset);
int maxHeight = Math.min(HEIGHT, this.blitHeight + this.blitYOffset);

@ -2,7 +2,6 @@ package net.brokenmoon.redcontrol.blocks;
import com.simon816.j65el02.device.RedBus;
import net.brokenmoon.redcontrol.api.RCWorldBus;
import net.brokenmoon.redcontrol.api.TempRedBus;
import net.brokenmoon.redcontrol.blockentities.Peripheral;
import net.brokenmoon.redcontrol.mixin.RedBusAccessor;
import net.minecraft.block.*;
@ -38,7 +37,8 @@ public abstract class NetworkCarrier extends BlockWithEntity implements BlockEnt
@Override
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
if(state.hasBlockEntity() && world.getBlockEntity(pos) instanceof Peripheral){
((Peripheral) world.getBlockEntity(pos)).getBus().setValid(false);
if(((Peripheral) world.getBlockEntity(pos)).getBus() != null)
((Peripheral) world.getBlockEntity(pos)).getBus().setValid(false);
}
if (state.hasBlockEntity() && !state.isOf(newState.getBlock())) {
world.removeBlockEntity(pos);
@ -56,7 +56,7 @@ public abstract class NetworkCarrier extends BlockWithEntity implements BlockEnt
Block worldBlock = world.getBlockState(pos).getBlock();
if(world.getBlockEntity(pos) instanceof Peripheral){
Peripheral entityBlock = (Peripheral) world.getBlockEntity(pos);
RCWorldBus bus = new RCWorldBus(new TempRedBus(), world, pos);
RCWorldBus bus = new RCWorldBus(new RedBus(), world, pos);
entityBlock.setBus(bus);
entityBlock.getBus().setValid(true);
floodBus(entityBlock.getBus(), world, pos);

Loading…
Cancel
Save