From 9c0ed5651b40d644a9ec9c961baf4cdd66402eb9 Mon Sep 17 00:00:00 2001 From: Technus Date: Wed, 24 Jul 2019 13:10:31 +0200 Subject: persistence? --- .../tileEntity/MicroControllerTileEntity.java | 63 ++++++++++++++++------ 1 file changed, 46 insertions(+), 17 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/github/technus/tectech/thing/tileEntity/MicroControllerTileEntity.java b/src/main/java/com/github/technus/tectech/thing/tileEntity/MicroControllerTileEntity.java index d4cb8afb0f..394f1272dc 100644 --- a/src/main/java/com/github/technus/tectech/thing/tileEntity/MicroControllerTileEntity.java +++ b/src/main/java/com/github/technus/tectech/thing/tileEntity/MicroControllerTileEntity.java @@ -1,42 +1,63 @@ package com.github.technus.tectech.thing.tileEntity; import com.github.technus.avrClone.AvrCore; +import com.github.technus.avrClone.instructions.ExecutionEvent; import com.github.technus.avrClone.instructions.InstructionRegistry; +import com.github.technus.avrClone.memory.EepromMemory; +import com.github.technus.avrClone.memory.RemovableMemory; import com.github.technus.avrClone.memory.program.ProgramMemory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; public class MicroControllerTileEntity extends TileEntity { - public final AvrCore core; + private final AvrCore core; + private int[] tempData; public MicroControllerTileEntity(){ - core=new AvrCore(InstructionRegistry.INSTRUCTION_REGISTRY_OP,false); + core=new AvrCore(); + core.setUsingImmersiveOperands(false); + core.setInstructionRegistry(InstructionRegistry.INSTRUCTION_REGISTRY_OP); + core.setDataMemory(1< eeprom=core.getEepromMemory(); + if(eeprom!=null){ + tag.setInteger("eepromSize",eeprom.getDefinition().getSize()); + } + if(core.dataMemory!=null){ + tag.setIntArray("dataMemory",core.dataMemory); } } @@ -48,8 +69,16 @@ public class MicroControllerTileEntity extends TileEntity { @Override public void updateEntity() { super.updateEntity(); - if(core.checkValid()){ - + if (tempData != null) { + //todo discovery of components + core.dataMemory = tempData; + tempData = null; + } + for (int i = 0, cycles = Math.min(1 << getBlockMetadata(), 512); i < cycles; i++) { + ExecutionEvent executionEvent = core.cpuCycle(); + if (executionEvent != null) { + break; + } } } } -- cgit