public bool Init(byte[] buffer, AbbreviationTable abbreviationTable) { int len = GetByte(buffer, Header); int index = Header + 1; // load object name if (len > 0) { Text t = new Text(); for (int i = 0; i < len; i++) { t.AddCharacters(GetWord(buffer, index)); index += 2; } Name = t.GetValue(abbreviationTable); } int x = GetByte(buffer, index); // load object properties while (x != 0) { List <int> list = new List <int>(); int id = x & 0x1f; int numberOfBytes = (x >> 5) + 1; ObjectProperties.Add(id, new ObjectProperty() { //TODO Verify Address Address = index + 1, Index = id }); for (int i = 0; i < numberOfBytes; i++) { list.Add(GetByte(buffer, ++index)); } ObjectProperties[id].List = list; x = GetByte(buffer, ++index); } LoadAttributes(); return(true); }
public bool Init(byte[] buffer, AbbreviationTable abbreviationTable) { // read default attributes for (int i = 0; i < 31; i++) { _defaultProperties[i + 1] = GetWord(buffer, _start + (i * 2)); } bool done = false; int j = 0; int n = 1; // loop through all objects while (!done && j < MaxObjects) { int attr = _start + (PropertyDefaultCount * 2) + (j * ObjectLength); if (_objects.Count > 1 && (attr == _objects[1].Header)) { done = true; } else { byte[] attributes = new byte[4]; for (int k = 0; k < 4; k++) { attributes[k] = GetByte(buffer, attr + k); } int parent = GetByte(buffer, attr + 4); int sibling = GetByte(buffer, attr + 5); int child = GetByte(buffer, attr + 6); int header = GetWord(buffer, attr + 7); var obj = new GameObject(n++, attributes, parent, sibling, child, header); if (obj.Init(buffer, abbreviationTable)) { _objects.Add(obj); } j++; } } return(true); }
public bool Init() { InitFunctionTable(); Stack = new Stack <Frame>(); var initialPc = GetWord(Buffer, Header.InitialPc); // create abbreviation table _abbreviationTable = new AbbreviationTable(); if (!_abbreviationTable.Init(Buffer, GetWord(Buffer, Header.AbbrTable))) { Logger.Error("Failed to load abbreviation table"); return(false); } // create dictionary _dictionary = new Dictionary(GetWord(Buffer, Header.Dictionary)); if (!_dictionary.Init(Buffer)) { Logger.Error("Failed to load dictionary"); return(false); } // create object table _objectTable = new ObjectTable(GetWord(Buffer, Header.ObjectTable)); if (!_objectTable.Init(Buffer, _abbreviationTable)) { Logger.Error("Failed to load object table"); return(false); } Logger.Debug($"Starting execution at {initialPc}"); // Create initial frame and push it on stack Stack.Push(new Frame(initialPc)); // TODO create window _window = new Window(); return(true); }
public string GetValue(AbbreviationTable abbreviationTable = null) { var alphabet = Character.Alphabet0; var tableOffset = 0; var start = 0; var str = ""; var abbreviation = false; if (Characters[0].Value == 5 && Characters[1].Value == 6 && Characters.Count >= 5) { var x = ((Characters[2].Value & 0x1f) << 5) + (Characters[3].Value & 0x1f); str += ((char)x); start = 4; } for (var i = start; i < Characters.Count; i++) { if (abbreviation && alphabet == Character.Alphabet2 && abbreviationTable != null) { var n = tableOffset + Characters[i].Value; var abbr = abbreviationTable.GetAbbreviation(n); str += abbr; tableOffset = 0; alphabet = Character.Alphabet0; abbreviation = false; } else { switch (Characters[i].Value) { case 0: str += " "; alphabet = Character.Alphabet0; break; case 1: tableOffset = 0; alphabet = Character.Alphabet2; abbreviation = true; break; case 2: tableOffset = 32; alphabet = Character.Alphabet2; abbreviation = true; break; case 3: tableOffset = 64; alphabet = Character.Alphabet2; abbreviation = true; break; case 4: alphabet = Character.Alphabet1; break; case 5: alphabet = Character.Alphabet2; break; default: str += Characters[i].DecodeCharacter(alphabet); alphabet = Character.Alphabet0; break; } } } return(str); }