public MessageStyle(byte[] romData, int offset) { TileDataOffset = (uint)(offset + BitConverter.ToUInt32(romData, offset)); TileDataSize = BitConverter.ToUInt32(romData, offset + 0x04); Unknown0x08 = BitConverter.ToUInt16(romData, offset + 0x08); Unknown0x0A = BitConverter.ToUInt16(romData, offset + 0x0A); PaletteDataOffset = (uint)(offset + 0x0C + BitConverter.ToUInt32(romData, offset + 0x0C)); PaletteDataSize = BitConverter.ToUInt32(romData, offset + 0x10); TileData = new byte[TileDataSize]; Buffer.BlockCopy(romData, (int)TileDataOffset, TileData, 0, TileData.Length); PaletteData = new byte[PaletteDataSize]; Buffer.BlockCopy(romData, (int)PaletteDataOffset, PaletteData, 0, PaletteData.Length); if (Unknown0x08 == 0x0040 && Unknown0x0A == 0x0020) { StyleImage = GBAGraphics.GetBitmap(TileData, 0, PaletteData, 0, 8, 8); StyleImageFlipped = (StyleImage.Clone() as Bitmap); StyleImageFlipped.RotateFlip(RotateFlipType.RotateNoneFlipX); } }
public RomHandler(string filename) { FileName = filename; using (FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { byte[] romData = new byte[fileStream.Length]; if (romData.Length != fileStream.Read(romData, 0, romData.Length)) { throw new Exception("Data read mismatch"); } string gameId = Encoding.ASCII.GetString(romData, 0xAC, 4); switch (gameId) { case "ARZJ": fontOffset = FollowPointer(romData, 0xBC11C); baseMessageTextOffset = FollowPointer(romData, 0xBC99C); baseMessageIdxOffset = FollowPointer(romData, 0xBC9A0); bankXTextOffset = FollowPointer(romData, 0xF440); bankXIdxOffset = FollowPointer(romData, 0xF438); Language = GameLanguage.Japanese; break; case "AZCE": fontOffset = FollowPointer(romData, 0xBBFF8); baseMessageTextOffset = FollowPointer(romData, 0xBC878); baseMessageIdxOffset = FollowPointer(romData, 0xBC87C); bankXTextOffset = FollowPointer(romData, 0xF44C); bankXIdxOffset = FollowPointer(romData, 0xF444); Language = GameLanguage.English; break; default: throw new Exception(string.Format("Unknown ROM or game version '{0}'", gameId)); } MessageBanks = new MessageBank[((baseMessageTextOffset - baseMessageIdxOffset) / 4) + 1]; MessageBanks[0] = new MessageBank(romData, -1, bankXTextOffset, bankXIdxOffset, Language); for (int i = 1; i < MessageBanks.Length; i++) { MessageBanks[i] = new MessageBank( romData, i, FollowPointer(romData, (uint)(baseMessageTextOffset + ((i - 1) * 4))), FollowPointer(romData, (uint)(baseMessageIdxOffset + ((i - 1) * 4))), Language); } MessageStyles = new MessageStyle[BitConverter.ToUInt32(romData, MessageStyle.BaseOffset) / MessageStyle.SizeOf]; for (int i = 0; i < MessageStyles.Length; i++) { MessageStyles[i] = new MessageStyle(romData, (MessageStyle.BaseOffset + (i * MessageStyle.SizeOf))); } FontImage = GBAGraphics.GetMMZFont(romData, (int)fontOffset, romData, (int)(fontOffset - 0x20), false); FontImageHighlighted = GBAGraphics.GetMMZFont(romData, (int)fontOffset, romData, (int)(fontOffset - 0x20), true); } }