From 30151a0b9e81d76e7777216d22a1a786f082f9e1 Mon Sep 17 00:00:00 2001 From: Astoria Date: Wed, 10 Apr 2024 19:38:56 -0500 Subject: [PATCH] Get rid of a whole bunch of logspam, make block breaking less janky after world reload? --- .../brokenmoon/redcontrol/api/Emulator.java | 7 ++-- .../brokenmoon/redcontrol/api/TempBus.java | 27 --------------- .../brokenmoon/redcontrol/api/TempRedBus.java | 33 ------------------- .../redcontrol/blockentities/CpuEntity.java | 10 +----- .../redcontrol/blockentities/DriveEntity.java | 1 - .../blockentities/MonitorEntity.java | 2 -- .../redcontrol/blocks/NetworkCarrier.java | 6 ++-- 7 files changed, 6 insertions(+), 80 deletions(-) delete mode 100644 src/main/java/net/brokenmoon/redcontrol/api/TempBus.java delete mode 100644 src/main/java/net/brokenmoon/redcontrol/api/TempRedBus.java diff --git a/src/main/java/net/brokenmoon/redcontrol/api/Emulator.java b/src/main/java/net/brokenmoon/redcontrol/api/Emulator.java index ac481cc..9034f05 100644 --- a/src/main/java/net/brokenmoon/redcontrol/api/Emulator.java +++ b/src/main/java/net/brokenmoon/redcontrol/api/Emulator.java @@ -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()); } diff --git a/src/main/java/net/brokenmoon/redcontrol/api/TempBus.java b/src/main/java/net/brokenmoon/redcontrol/api/TempBus.java deleted file mode 100644 index f267675..0000000 --- a/src/main/java/net/brokenmoon/redcontrol/api/TempBus.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/net/brokenmoon/redcontrol/api/TempRedBus.java b/src/main/java/net/brokenmoon/redcontrol/api/TempRedBus.java deleted file mode 100644 index 5cad760..0000000 --- a/src/main/java/net/brokenmoon/redcontrol/api/TempRedBus.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/net/brokenmoon/redcontrol/blockentities/CpuEntity.java b/src/main/java/net/brokenmoon/redcontrol/blockentities/CpuEntity.java index 9200c8a..6dc8652 100644 --- a/src/main/java/net/brokenmoon/redcontrol/blockentities/CpuEntity.java +++ b/src/main/java/net/brokenmoon/redcontrol/blockentities/CpuEntity.java @@ -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(); diff --git a/src/main/java/net/brokenmoon/redcontrol/blockentities/DriveEntity.java b/src/main/java/net/brokenmoon/redcontrol/blockentities/DriveEntity.java index b5dbff1..a53dd4a 100644 --- a/src/main/java/net/brokenmoon/redcontrol/blockentities/DriveEntity.java +++ b/src/main/java/net/brokenmoon/redcontrol/blockentities/DriveEntity.java @@ -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; diff --git a/src/main/java/net/brokenmoon/redcontrol/blockentities/MonitorEntity.java b/src/main/java/net/brokenmoon/redcontrol/blockentities/MonitorEntity.java index 0c92e1f..1bfac77 100644 --- a/src/main/java/net/brokenmoon/redcontrol/blockentities/MonitorEntity.java +++ b/src/main/java/net/brokenmoon/redcontrol/blockentities/MonitorEntity.java @@ -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); diff --git a/src/main/java/net/brokenmoon/redcontrol/blocks/NetworkCarrier.java b/src/main/java/net/brokenmoon/redcontrol/blocks/NetworkCarrier.java index 8e03ac8..53db078 100644 --- a/src/main/java/net/brokenmoon/redcontrol/blocks/NetworkCarrier.java +++ b/src/main/java/net/brokenmoon/redcontrol/blocks/NetworkCarrier.java @@ -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);