public GeneralizedPointerTableEntry(IROM rom, IMemoryManager manager, FE6RawFormat rawFormat) { this.rom = rom; this.manager = manager; this.fromFE6Format = true; MainPortraitOffset = GetPtr(rawFormat.MainPortraitPointer); MiniPortraitOffset = GetPtr(rawFormat.MiniPortraitPointer); PaletteOffset = GetPtr(rawFormat.PalettePointer); MouthOffset = 0; GenericOffset = 0; MouthPosition = new Point(rawFormat.MouthXPosition, rawFormat.MouthYPosition); EyePosition = Point.Empty; EyeControl = EyeControl.Open; }
private void LoadDataFromROM(IMemoryManager memoryManager, IROM rom) { int portraitPtrOffset; int defaultIndexAmount; bool FE6Format; switch (game = GameEnumHelpers.GetGame(rom.GameCode)) { case GameEnum.FE6Trans: case GameEnum.FE6: portraitPtrOffset = 0x007FD8; defaultIndexAmount = 0xE6; FE6Format = true; break; case GameEnum.FE7U: portraitPtrOffset = 0x006B30; defaultIndexAmount = 0xE4; FE6Format = false; break; case GameEnum.FE8U: portraitPtrOffset = 0x005524; defaultIndexAmount = 0xAC; FE6Format = false; break; //Unknown case GameEnum.FE7J: case GameEnum.FE8J: case GameEnum.FE7E: case GameEnum.FE8E: default: throw new Exception("Game not supported."); } portraitDataPointerPointer = memoryManager.Reserve(portraitPtrOffset, 4); int tableRawPtr = BitConverter.ToInt32(rom.ReadData(portraitDataPointerPointer), 0); int indexSize = Marshal.SizeOf(FE6Format ? typeof(FE6RawFormat) : typeof(FE78RawFormat)); portraitDataPointer = memoryManager.Reserve( Pointer.GetOffset(tableRawPtr + indexSize), defaultIndexAmount * indexSize); byte[] portraitData = rom.ReadData(portraitDataPointer); portraitEntries.Clear(); unsafe { if (FE6Format) { FE6RawFormat[] rawData = new FE6RawFormat[defaultIndexAmount]; fixed (FE6RawFormat* ptr = rawData) { IntPtr ptr2 = (IntPtr)ptr; Marshal.Copy(portraitData, 0, ptr2, portraitData.Length); } for (int i = 0; i < rawData.Length; i++) { portraitEntries.Add(new GeneralizedPointerTableEntry( rom, memoryManager, rawData[i])); } } else { FE78RawFormat[] rawData = new FE78RawFormat[defaultIndexAmount]; fixed (FE78RawFormat* ptr = rawData) { IntPtr ptr2 = (IntPtr)ptr; Marshal.Copy(portraitData, 0, ptr2, portraitData.Length); } for (int i = 0; i < rawData.Length; i++) { portraitEntries.Add(new GeneralizedPointerTableEntry( rom, memoryManager, rawData[i])); } } } CurrentIndex = 0; form.MaxIndex = portraitEntries.Count - 1; }
private void LoadDataFromROM(IMemoryManager memoryManager, IROM rom, bool useFE6Format, int indexCount) { byte[] portraitData = rom.ReadData(portraitDataPointer); unsafe { if (useFE6Format) { FE6RawFormat[] rawData = new FE6RawFormat[indexCount]; fixed (FE6RawFormat* ptr = rawData) { IntPtr ptr2 = (IntPtr)ptr; Marshal.Copy(portraitData, 0, ptr2, portraitData.Length); } for (int i = 0; i < rawData.Length; i++) { entries.Add(new GeneralizedPointerTableEntry( rom, memoryManager, rawData[i])); } } else { FE78RawFormat[] rawData = new FE78RawFormat[indexCount]; fixed (FE78RawFormat* ptr = rawData) { IntPtr ptr2 = (IntPtr)ptr; Marshal.Copy(portraitData, 0, ptr2, portraitData.Length); } for (int i = 0; i < rawData.Length; i++) { entries.Add(new GeneralizedPointerTableEntry( rom, memoryManager, rawData[i])); } } } }