1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_GroupFile.h 4 5 Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain proprietary 8 information of Nintendo and/or its licensed developers and are protected by 9 national and international copyright laws. They may not be disclosed to third 10 parties or copied or duplicated in any form, in whole or in part, without the 11 prior written consent of Nintendo. 12 13 The content herein is highly confidential and should be handled accordingly. 14 15 $Revision: 31311 $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef NW_SND_GROUP_FILE_H_ 19 #define NW_SND_GROUP_FILE_H_ 20 21 #include <nw/snd/snd_Util.h> 22 23 namespace nw { 24 namespace snd { 25 namespace internal { 26 27 struct GroupFile 28 { 29 struct InfoBlock; 30 struct FileBlock; 31 struct InfoExBlock; 32 struct InfoBlockBody; 33 struct FileBlockBody; 34 struct InfoExBlockBody; 35 struct GroupItemInfo; 36 struct GroupItemInfoEx; 37 38 struct FileHeader : public Util::SoundFileHeader 39 { 40 const InfoBlock* GetInfoBlock() const; // ファイル ID をキーとしたテーブルを含む 41 const FileBlock* GetFileBlock() const; 42 const InfoExBlock* GetInfoExBlock() const; // アイテム ID をキーとしたテーブルを含む 43 }; 44 45 struct InfoBlockBody 46 { 47 // TODO: リファレンスがひとつ多いと思う。 48 // GroupItemInfo 自体が固定長なので、 49 // ここに直接 GroupItemInfo テーブルを埋めればいいのでは? 50 51 // データ 52 Util::ReferenceTable referenceTableOfGroupItemInfo; 53 54 // アクセサ GetGroupItemInfoCountGroupFile::InfoBlockBody55 NW_INLINE u32 GetGroupItemInfoCount() const 56 { 57 return referenceTableOfGroupItemInfo.count; 58 } GetGroupItemInfoGroupFile::InfoBlockBody59 const GroupItemInfo* GetGroupItemInfo( u32 index ) const 60 { 61 if ( index >= GetGroupItemInfoCount() ) 62 { 63 return NULL; 64 } 65 return static_cast<const GroupItemInfo*>( ut::AddOffsetToPtr( 66 this, referenceTableOfGroupItemInfo.item[ index ].offset ) ); 67 } 68 #if 0 69 // データ 70 Util::Table<GroupItemInfo> table; 71 72 // アクセサ 73 NW_INLINE u32 GetItemCount() const { return table.count; } 74 const GroupItemInfo* GetItemInfo( u32 index ) const 75 { 76 if ( index > GetItemCount() ) 77 { 78 return NULL; 79 } 80 return &table.item[ index ]; 81 } 82 #endif 83 }; 84 85 struct InfoBlock 86 { 87 ut::BinaryBlockHeader header; 88 InfoBlockBody body; 89 }; 90 91 struct GroupItemInfo 92 { 93 // データ 94 ut::ResU32 fileId; 95 Util::ReferenceWithSize embeddedItemInfo; 96 // 埋め込まれたアイテムの場所やサイズを表現します。 97 // [場所] = [offset の起点] は、FileBlockBody です。 98 99 static const u32 OFFSET_FOR_LINK = 0xffffffff; 100 static const u32 SIZE_FOR_LINK = 0xffffffff; 101 102 // アクセサ GetFileLocationGroupFile::GroupItemInfo103 const void* GetFileLocation( const FileBlockBody* fileBlockBody ) const 104 { 105 // ファイルブロック (ボディ?) のアドレスに、 106 // offset 値を足して返す。 107 if ( embeddedItemInfo.offset == OFFSET_FOR_LINK ) 108 { 109 return NULL; 110 } 111 return ut::AddOffsetToPtr( fileBlockBody, 112 embeddedItemInfo.offset ); 113 } 114 }; 115 116 struct FileBlockBody 117 { 118 // プレースホルダ 119 }; 120 121 struct FileBlock 122 { 123 ut::BinaryBlockHeader header; 124 FileBlockBody body; 125 }; 126 127 128 struct InfoExBlockBody 129 { 130 // データ 131 Util::ReferenceTable referenceTableOfGroupItemInfoEx; 132 133 // アクセサ GetGroupItemInfoExCountGroupFile::InfoExBlockBody134 NW_INLINE u32 GetGroupItemInfoExCount() const 135 { 136 return referenceTableOfGroupItemInfoEx.count; 137 } GetGroupItemInfoExGroupFile::InfoExBlockBody138 const GroupItemInfoEx* GetGroupItemInfoEx( u32 index ) const 139 { 140 if ( index >= GetGroupItemInfoExCount() ) 141 { 142 return NULL; 143 } 144 return static_cast<const GroupItemInfoEx*>( ut::AddOffsetToPtr( 145 this, referenceTableOfGroupItemInfoEx.item[ index ].offset ) ); 146 } 147 }; 148 149 struct InfoExBlock 150 { 151 ut::BinaryBlockHeader header; 152 InfoExBlockBody body; 153 }; 154 155 struct GroupItemInfoEx 156 { 157 // データ 158 ut::ResU32 itemId; 159 ut::ResU32 loadFlag; // SoundArchiveLoader::LoadFlag の論理和が入る 160 }; 161 }; 162 163 164 } // namespace nw::snd::internal 165 } // namespace nw::snd 166 } // namespace nw 167 168 169 #endif /* NW_SND_GROUP_FILE_H_ */ 170 171