Still not working!

main
Astoria 7 months ago
parent 17ff02dfe1
commit ed54f55acf

@ -1 +1 @@
Subproject commit 3690b0031fd685abecc2f7d21678c61dca69f40f Subproject commit 419245bf18a266be19f8b02a565fb5e7150a39a3

@ -5,6 +5,7 @@ import com.simon816.j65el02.Cpu;
import com.simon816.j65el02.device.Memory; import com.simon816.j65el02.device.Memory;
import com.simon816.j65el02.device.RedBus; import com.simon816.j65el02.device.RedBus;
import com.simon816.j65el02.device.RedBusState; import com.simon816.j65el02.device.RedBusState;
import net.brokenmoon.redcontrol.RedControl;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
@ -15,13 +16,12 @@ public class Emulator {
private RedBus bus; private RedBus bus;
public Cpu cpu; public Cpu cpu;
private Memory ram; private Memory ram;
public boolean isRunning = false;
public Emulator(RedBus bus){ public Emulator(RedBus bus){
this.bus = bus; this.bus = bus;
cpu = new Cpu(); cpu = new Cpu();
cpu.setBus(new Bus(bus)); cpu.setBus(new TempBus(bus));
ram = new Memory(0x0000, 0x2000, new RedBusState()); ram = new Memory(0x0000, 0x2000 - 1, cpu.redBusState);
try { try {
ram.loadFromFile(Paths.get("/home/astoria/code/java/mods/RedControl/src/main/resources/assets/redcontrol/image/redforth.img"), 0x400, 0x100); ram.loadFromFile(Paths.get("/home/astoria/code/java/mods/RedControl/src/main/resources/assets/redcontrol/image/redforth.img"), 0x400, 0x100);
@ -40,6 +40,7 @@ public class Emulator {
} }
public void setBus(RedBus bus) { public void setBus(RedBus bus) {
RedControl.LOGGER.info("Setting Emulator bus");
this.bus = bus; this.bus = bus;
this.cpu.getBus().setRedBus(bus); this.cpu.getBus().setRedBus(bus);
} }
@ -60,7 +61,6 @@ public class Emulator {
} }
public void reset(){ public void reset(){
isRunning = false;
cpu.reset(); cpu.reset();
ram.write(0, 2, cpu.redBusState); ram.write(0, 2, cpu.redBusState);
ram.write(1, 1, cpu.redBusState); ram.write(1, 1, cpu.redBusState);

@ -0,0 +1,27 @@
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;
}
}

@ -0,0 +1,33 @@
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,6 +4,7 @@ import com.simon816.j65el02.device.RedBus;
import net.brokenmoon.redcontrol.RedControl; import net.brokenmoon.redcontrol.RedControl;
import net.brokenmoon.redcontrol.api.Emulator; import net.brokenmoon.redcontrol.api.Emulator;
import net.brokenmoon.redcontrol.api.RCWorldBus; import net.brokenmoon.redcontrol.api.RCWorldBus;
import net.brokenmoon.redcontrol.api.TempRedBus;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -16,7 +17,7 @@ public class CpuEntity extends Peripheral{
public int i = 0; public int i = 0;
public boolean notTicked = true; public boolean notTicked = true;
public Emulator core = new Emulator(new RedBus()); public Emulator core = new Emulator(new TempRedBus());
private Path bootloader; private Path bootloader;

@ -146,6 +146,7 @@ public class MonitorEntity extends Peripheral {
@Override @Override
public void update() { public void update() {
RedControl.LOGGER.info("MONITOR UPDATED");
int maxWidth = Math.min(WIDTH, this.blitWidth + this.blitXOffset); int maxWidth = Math.min(WIDTH, this.blitWidth + this.blitXOffset);
int maxHeight = Math.min(HEIGHT, this.blitHeight + this.blitYOffset); int maxHeight = Math.min(HEIGHT, this.blitHeight + this.blitYOffset);

@ -45,7 +45,7 @@ public class CpuBlock extends NetworkCarrier {
if (!world.isClient) { if (!world.isClient) {
CpuEntity peripheral = (CpuEntity) world.getBlockEntity(pos); CpuEntity peripheral = (CpuEntity) world.getBlockEntity(pos);
player.sendMessage(Text.literal(String.valueOf(peripheral.getBus().hashCode())), false); player.sendMessage(Text.literal(String.valueOf(peripheral.getBus().hashCode())), false);
player.sendMessage(Text.literal(String.valueOf(peripheral.getBus().getRedBus().hashCode())), false); player.sendMessage(Text.literal(String.valueOf(peripheral.core.cpu.getBus().getRedBus().hashCode())), false);
player.sendMessage(Text.literal(String.valueOf(peripheral.i)), false); player.sendMessage(Text.literal(String.valueOf(peripheral.i)), false);
player.sendMessage(Text.literal(String.valueOf(peripheral.core.isWaitingOnInterrupt())), false); player.sendMessage(Text.literal(String.valueOf(peripheral.core.isWaitingOnInterrupt())), false);
} }

@ -2,6 +2,7 @@ package net.brokenmoon.redcontrol.blocks;
import com.simon816.j65el02.device.RedBus; import com.simon816.j65el02.device.RedBus;
import net.brokenmoon.redcontrol.api.RCWorldBus; import net.brokenmoon.redcontrol.api.RCWorldBus;
import net.brokenmoon.redcontrol.api.TempRedBus;
import net.brokenmoon.redcontrol.blockentities.Peripheral; import net.brokenmoon.redcontrol.blockentities.Peripheral;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
@ -54,7 +55,7 @@ public abstract class NetworkCarrier extends BlockWithEntity implements BlockEnt
Block worldBlock = world.getBlockState(pos).getBlock(); Block worldBlock = world.getBlockState(pos).getBlock();
if(world.getBlockEntity(pos) instanceof Peripheral){ if(world.getBlockEntity(pos) instanceof Peripheral){
Peripheral entityBlock = (Peripheral) world.getBlockEntity(pos); Peripheral entityBlock = (Peripheral) world.getBlockEntity(pos);
RCWorldBus bus = new RCWorldBus(new RedBus(), world, pos); RCWorldBus bus = new RCWorldBus(new TempRedBus(), world, pos);
entityBlock.setBus(bus); entityBlock.setBus(bus);
entityBlock.getBus().setValid(true); entityBlock.getBus().setValid(true);
floodBus(entityBlock.getBus(), world, pos); floodBus(entityBlock.getBus(), world, pos);
@ -84,6 +85,11 @@ public abstract class NetworkCarrier extends BlockWithEntity implements BlockEnt
Peripheral peripheral = (Peripheral) world.getBlockEntity(pos); Peripheral peripheral = (Peripheral) world.getBlockEntity(pos);
player.sendMessage(Text.literal(String.valueOf(peripheral.getBus().hashCode())), false); player.sendMessage(Text.literal(String.valueOf(peripheral.getBus().hashCode())), false);
player.sendMessage(Text.literal(String.valueOf(peripheral.getBus().getRedBus().hashCode())), false); player.sendMessage(Text.literal(String.valueOf(peripheral.getBus().getRedBus().hashCode())), false);
for(int i = 0; i < peripheral.getBus().getRedBus().peripherals.length; i++){
if (peripheral.getBus().getRedBus().peripherals[i] != null){
player.sendMessage(Text.literal(String.valueOf(peripheral.getBus().getRedBus().peripherals[i])), false);
}
}
} }
return ActionResult.SUCCESS; return ActionResult.SUCCESS;

Loading…
Cancel
Save