From 9c0ed5651b40d644a9ec9c961baf4cdd66402eb9 Mon Sep 17 00:00:00 2001 From: Technus Date: Wed, 24 Jul 2019 13:10:31 +0200 Subject: persistence? --- AVRcore | 2 +- .../tileEntity/MicroControllerTileEntity.java | 63 ++++++++++++++++------ 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/AVRcore b/AVRcore index abd28835fb..4c0bd1b374 160000 --- a/AVRcore +++ b/AVRcore @@ -1 +1 @@ -Subproject commit abd28835fb49e03e6d08d4f2056ff671693fe671 +Subproject commit 4c0bd1b3744bc0c328990266f1f910c438c7abd9 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