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