public ZMemory(byte[] data, Action restart) { _restart = restart; Header = new ZHeader(data.AsSpan(0, 31)); if (Header.Version > 5) { throw new NotSupportedException("ZMachine > V5 not currently supported"); } // Version specific offsets Offsets = VersionedOffsets.For(Header.Version); Manager = new MemoryManager(data); // ZMachine tables Abbreviations = new ZAbbreviations(Header, Manager); Dictionary = new ZDictionary(Header, Manager, Abbreviations); ObjectTree = new ZObjectTree(Header, Manager, Abbreviations); Globals = new ZGlobals(Header, Manager); // Custom Stack with some abstractions for better testing. Stack = new ZStack(); // Simple managers to abstract variable and argument usage VariableManager = new VariableManager(Stack, Globals); OperandManager = new OperandManager(Manager, Stack, VariableManager); }
private void InitMocks(MockBehavior mockBehavior) { _userIoMock = new Mock <IUserIo>(mockBehavior); _memoryMock = new Mock <IZMemory>(mockBehavior); _objectsMock = new Mock <IZObjectTree>(mockBehavior); _variablesMock = new Mock <IVariableManager>(mockBehavior); _memoryManager = new Mock <IMemoryManager>(mockBehavior); _memoryManager .Setup(m => m.AsSpan(It.IsAny <short>())) .Returns(new byte[] { }); _memoryMock .SetupGet(m => m.VariableManager) .Returns(_variablesMock.Object); _memoryMock .SetupGet(m => m.Manager) .Returns(_memoryManager.Object); _memoryMock .SetupGet(m => m.ObjectTree) .Returns(_objectsMock.Object); _zStack = new ZStack(); _memoryMock .SetupGet(m => m.Stack) .Returns(_zStack); }
public void Initialize(ushort aStartPC) { ZRandom.Seed(0); Stack = new ZStack(this); StartPC = aStartPC; PC = StartPC; //SetByte(HeaderOffset.CONFIG, ZMachine.Story.Header.config); //SetWord(HeaderOffset.FLAGS, ZMachine.Story.Header.flags); //if (ZMachine.Story.Header.Version >= FileVersion.V4) //{ // SetByte(HeaderOffset.INTERPRETER_NUMBER, ZMachine.Story.Header.interpreter_number); // SetByte(HeaderOffset.INTERPRETER_VERSION, ZMachine.Story.Header.interpreter_version); // SetByte(HeaderOffset.SCREEN_ROWS, ZMachine.Story.Header.screen_rows); // SetByte(HeaderOffset.SCREEN_COLS, ZMachine.Story.Header.screen_cols); //} //ushort screenCols = ZMachine.Story.Header.screen_cols; //ushort screenRows = ZMachine.Story.Header.screen_rows; //if (ZMachine.Story.Header.Version >= FileVersion.V5) //{ // SetWord(HeaderOffset.SCREEN_WIDTH, screenCols); // SetWord(HeaderOffset.SCREEN_HEIGHT, screenRows); // SetByte(HeaderOffset.FONT_HEIGHT, 1); // SetByte(HeaderOffset.FONT_WIDTH, 1); // SetByte(HeaderOffset.DEFAULT_BACKGROUND, ZMachine.Story.Header.default_background); // SetByte(HeaderOffset.DEFAULT_FOREGROUND, ZMachine.Story.Header.default_foreground); //} //if ((ZMachine.Story.Header.Version >= FileVersion.V3) && (ZMachine.Story.Header.user_name[0] != 0)) //{ // for (int i = 0; i < 8; i++) // { // SetByte((HeaderOffset.USER_NAME + i), ZMachine.Story.Header.user_name[i]); // } //} //SetByte(HeaderOffset.STANDARD_HIGH, ZMachine.Story.Header.standard_high); //SetByte(HeaderOffset.STANDARD_LOW, ZMachine.Story.Header.standard_low); }
void changeBoundingBox() { BoundingBox = BoundsHelper.BuildBounds(touches.Values); if (touchesChanged && touches.Count > 0) { yPos = ZStack.Add(gameObject); } if (touchesChanged && touches.Count > 1) { scaler.StartMove( getWorldPoint(touches.Values.First().position), getCentrePoint()); } else if (touchesChanged && touches.Count == 1) { scaler.StartMove(getCentrePoint().SetY(yPos)); } else if (touchesChanged && touches.Count == 0) { scaler.EndMove(); ZStack.Remove(gameObject); } if (scaler.IsMoving) { if (touches.Count > 1) { scaler.UpdateMove(getWorldPoint(touches.Values.First().position), getCentrePoint()); } else if (touches.Count == 1) { scaler.UpdateMove(getCentrePoint()); } } }
public ZStack() { Instance = this; }