private void ReadAcs95(ref BinaryReader reader) { int numPointers = reader.ReadInt32(); for (int i = 0; i < numPointers; i++) { int number = reader.ReadInt32(); int pointer = reader.ReadInt32(); int argc = reader.ReadInt32(); int id = number % 1000; int typeNum = number / 1000; ScriptType type = (ScriptType)typeNum; Console.WriteLine("Script " + id + " is of type " + type); long pos = InputStream.Position; AcsScript script = new AcsScript(number, type, argc, pointer); InputStream.Seek(pointer, SeekOrigin.Begin); int len = 0; while (reader.ReadInt32() != (int)OpcodeEnum.Terminate) { len++; } InputStream.Seek(pointer, SeekOrigin.Begin); script.Code = AcsInstruction.ReadCode(this, ref reader, len); InputStream.Seek(pos, SeekOrigin.Begin); Scripts[number] = script; } int stringCount = reader.ReadInt32(); for (int i = 0; i < stringCount; i++) { int pointer = reader.ReadInt32(); long pos = InputStream.Position; InputStream.Seek(pointer, SeekOrigin.Begin); StringTable.Add(ReadString()); InputStream.Seek(pos, SeekOrigin.Begin); } }
private void ReadCode(ref BinaryReader reader) { foreach (var script in Scripts) { int num = script.Key; AcsScript s = script.Value; s.CodeSize = FindClosestPointer(s.Pointer) - s.Pointer; InputStream.Seek(s.Pointer, SeekOrigin.Begin); s.Code = AcsInstruction.ReadCode(this, ref reader, s.CodeSize); } foreach (var func in FunctionList) { func.CodeSize = FindClosestPointer(func.Pointer) - func.Pointer; InputStream.Seek(func.Pointer, SeekOrigin.Begin); func.Code = AcsInstruction.ReadCode(this, ref reader, func.CodeSize); } }