private bool LoadFile( Stream stream, uint textPointerLocationDiff ) { string magic = stream.ReadAscii( 8 ); uint alwaysSame = stream.ReadUInt32().SwapEndian(); uint filesize = stream.ReadUInt32().SwapEndian(); uint lengthSection1 = stream.ReadUInt32().SwapEndian(); stream.Position = 0x50; int textPointerDiffDiff = (int)stream.ReadUInt32().SwapEndian(); stream.Position = 0x20; uint textStart = stream.ReadUInt32().SwapEndian(); int textPointerDiff = (int)stream.ReadUInt32().SwapEndian() - textPointerDiffDiff; EntryList = new List<ScenarioFileEntry>(); // i wonder what the actual logic behind this is... uint textPointersLocation = ( lengthSection1 + 0x80 ).Align( 0x10 ) + textPointerLocationDiff; // + 0x1888; // + 0x1B4C // diff of 2C4 // Actually this isn't constant, dammit. if ( textStart != textPointersLocation ) { stream.Position = textPointersLocation; while ( true ) { long loc = stream.Position; stream.DiscardBytes( 8 ); uint[] ptrs = new uint[4]; ptrs[0] = stream.ReadUInt32().SwapEndian(); ptrs[1] = stream.ReadUInt32().SwapEndian(); ptrs[2] = stream.ReadUInt32().SwapEndian(); ptrs[3] = stream.ReadUInt32().SwapEndian(); if ( stream.Position > textStart ) { break; } if ( ptrs.Any( x => x == 0 ) ) { break; } if ( ptrs.Any( x => x + textPointerDiff < textStart ) ) { break; } if ( ptrs.Any( x => x + textPointerDiff >= filesize ) ) { break; } var s = new ScenarioFileEntry(); s.Pointer = (uint)loc; stream.Position = ptrs[0] + textPointerDiff; s.JpName = stream.ReadShiftJisNullterm(); stream.Position = ptrs[1] + textPointerDiff; s.JpText = stream.ReadShiftJisNullterm(); stream.Position = ptrs[2] + textPointerDiff; s.EnName = stream.ReadShiftJisNullterm(); stream.Position = ptrs[3] + textPointerDiff; s.EnText = stream.ReadShiftJisNullterm(); EntryList.Add( s ); stream.Position = loc + 0x18; } } return true; }
private bool LoadFile( Stream stream ) { string magic = stream.ReadAscii( 8 ); uint entrySize = stream.ReadUInt32().SwapEndian(); uint synopsisCount = stream.ReadUInt32().SwapEndian(); uint unknown = stream.ReadUInt32().SwapEndian(); stream.DiscardBytes( 0xC ); SynopsisList = new List<SynopsisEntry>( (int)synopsisCount ); for ( uint i = 0; i < synopsisCount; ++i ) { SynopsisEntry l = new SynopsisEntry( stream ); SynopsisList.Add( l ); } return true; }
public g1tTexture( Stream stream, Util.Endianness endian ) { Mipmaps = (byte)stream.ReadByte(); byte format = (byte)stream.ReadByte(); byte dimensions = (byte)stream.ReadByte(); byte unknown4 = (byte)stream.ReadByte(); byte unknown5 = (byte)stream.ReadByte(); byte unknown6 = (byte)stream.ReadByte(); byte unknown7 = (byte)stream.ReadByte(); byte unknown8 = (byte)stream.ReadByte(); if ( endian == Util.Endianness.LittleEndian ) { Mipmaps = Mipmaps.SwapEndian4Bits(); dimensions = dimensions.SwapEndian4Bits(); unknown4 = unknown4.SwapEndian4Bits(); unknown5 = unknown5.SwapEndian4Bits(); unknown6 = unknown6.SwapEndian4Bits(); unknown7 = unknown7.SwapEndian4Bits(); unknown8 = unknown8.SwapEndian4Bits(); } if ( unknown8 == 0x01 ) { stream.DiscardBytes( 0x0C ); } switch ( format ) { case 0x00: Format = Textures.TextureFormat.ABGR; BitPerPixel = 32; break; case 0x01: Format = Textures.TextureFormat.RGBA; BitPerPixel = 32; break; case 0x06: Format = Textures.TextureFormat.DXT1; BitPerPixel = 4; break; case 0x08: Format = Textures.TextureFormat.DXT5; BitPerPixel = 8; break; default: throw new Exception( String.Format( "g1t: Unknown Format ({0:X2})", format ) ); } Width = (uint)( 1 << ( dimensions >> 4 ) ); Height = (uint)( 1 << ( dimensions & 0x0F ) ); uint highestMipmapSize = ( Width * Height * BitPerPixel ) / 8; long textureSize = highestMipmapSize; for ( int i = 0; i < Mipmaps - 1; ++i ) { textureSize += highestMipmapSize / ( 4 << ( i * 2 ) ); } Data = new byte[textureSize]; stream.Read( Data, 0, Data.Length ); }
private bool LoadFile( Stream stream ) { string magic = stream.ReadAscii( 8 ); uint filesize = stream.ReadUInt32().SwapEndian(); uint modelDefStart = stream.ReadUInt32().SwapEndian(); uint modelDefCount = stream.ReadUInt32().SwapEndian(); uint refStringStart = stream.ReadUInt32().SwapEndian(); uint customStart = stream.ReadUInt32().SwapEndian(); uint customCount = stream.ReadUInt32().SwapEndian(); uint otherStart = stream.ReadUInt32().SwapEndian(); uint otherCount = stream.ReadUInt32().SwapEndian(); uint u20BsectionStart = stream.ReadUInt32().SwapEndian(); uint u20BsectionCount = stream.ReadUInt32().SwapEndian(); uint u80sectionStart = stream.ReadUInt32().SwapEndian(); uint u80sectionCount = stream.ReadUInt32().SwapEndian(); stream.DiscardBytes( 8 ); ModelDefList = new List<CharacterModelDefinition>( (int)modelDefCount ); stream.Position = modelDefStart; for ( uint i = 0; i < modelDefCount; ++i ) { ModelDefList.Add( new CharacterModelDefinition( stream, refStringStart ) ); } ModelCustomList = new List<CustomModelAddition>( (int)customCount ); stream.Position = customStart; for ( uint i = 0; i < customCount; ++i ) { ModelCustomList.Add( new CustomModelAddition( stream, refStringStart ) ); } ModelOtherList = new List<OtherModelAddition>( (int)otherCount ); stream.Position = otherStart; for ( uint i = 0; i < otherCount; ++i ) { ModelOtherList.Add( new OtherModelAddition( stream, refStringStart ) ); } U20BList = new List<Unknown0x20byteAreaB>( (int)u20BsectionCount ); stream.Position = u20BsectionStart; for ( uint i = 0; i < u20BsectionCount; ++i ) { U20BList.Add( new Unknown0x20byteAreaB( stream, refStringStart ) ); } U80List = new List<Unknown0x80byteArea>( (int)u80sectionCount ); stream.Position = u80sectionStart; for ( uint i = 0; i < u80sectionCount; ++i ) { U80List.Add( new Unknown0x80byteArea( stream, refStringStart ) ); } foreach ( var model in ModelDefList ) { model.Custom = new CustomModelAddition[model.CustomCount]; for ( int i = 0; i < model.Custom.Length; ++i ) { model.Custom[i] = ModelCustomList[(int)model.CustomIndex + i]; } model.Other = new OtherModelAddition[model.OtherCount]; for ( int i = 0; i < model.Other.Length; ++i ) { model.Other[i] = ModelOtherList[(int)model.OtherIndex + i]; } model.Unknown0x20Area = new Unknown0x20byteAreaB[model.Unknown0x20AreaCount]; for ( int i = 0; i < model.Unknown0x20Area.Length; ++i ) { model.Unknown0x20Area[i] = U20BList[(int)model.Unknown0x20AreaIndex + i]; } model.Unknown0x80Area = new Unknown0x80byteArea[model.Unknown0x80AreaCount]; for ( int i = 0; i < model.Unknown0x80Area.Length; ++i ) { model.Unknown0x80Area[i] = U80List[(int)model.Unknown0x80AreaIndex + i]; } } return true; }