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: 13145 $ 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 InfoBlockBody; 30 struct FileBlockBody; 31 struct GroupItemInfo; 32 33 struct FileHeader : public Util::SoundFileHeader 34 { 35 const InfoBlock* GetInfoBlock() const; 36 const FileBlock* GetFileBlock() const; 37 }; 38 39 struct InfoBlockBody 40 { 41 // TODO: リファレンスがひとつ多いと思う。 42 // GroupItemInfo 自体が固定長なので、 43 // ここに直接 GroupItemInfo テーブルを埋めればいいのでは? 44 45 // データ 46 Util::ReferenceTable referenceTableOfGroupItemInfo; 47 48 // アクセサ GetGroupItemInfoCountGroupFile::InfoBlockBody49 NW_INLINE u32 GetGroupItemInfoCount() const 50 { 51 return referenceTableOfGroupItemInfo.count; 52 } GetGroupItemInfoGroupFile::InfoBlockBody53 const GroupItemInfo* GetGroupItemInfo( u32 index ) const 54 { 55 if ( index >= GetGroupItemInfoCount() ) 56 { 57 return NULL; 58 } 59 return static_cast<const GroupItemInfo*>( ut::AddOffsetToPtr( 60 this, referenceTableOfGroupItemInfo.item[ index ].offset ) ); 61 } 62 #if 0 63 // データ 64 Util::Table<GroupItemInfo> table; 65 66 // アクセサ 67 NW_INLINE u32 GetItemCount() const { return table.count; } 68 const GroupItemInfo* GetItemInfo( u32 index ) const 69 { 70 if ( index > GetItemCount() ) 71 { 72 return NULL; 73 } 74 return &table.item[ index ]; 75 } 76 #endif 77 }; 78 79 struct InfoBlock 80 { 81 ut::BinaryBlockHeader header; 82 InfoBlockBody body; 83 }; 84 85 struct GroupItemInfo 86 { 87 // データ 88 ut::ResU32 fileId; 89 Util::ReferenceWithSize embeddedItemInfo; 90 // 埋め込まれたアイテムの場所やサイズを表現します。 91 // [場所] = [offset の起点] は、FileBlockBody です。 92 93 static const u32 OFFSET_FOR_LINK = 0xffffffff; 94 static const u32 SIZE_FOR_LINK = 0xffffffff; 95 96 // アクセサ GetFileLocationGroupFile::GroupItemInfo97 const void* GetFileLocation( const FileBlockBody* fileBlockBody ) const 98 { 99 // ファイルブロック (ボディ?) のアドレスに、 100 // offset 値を足して返す。 101 if ( embeddedItemInfo.offset == OFFSET_FOR_LINK ) 102 { 103 return NULL; 104 } 105 return ut::AddOffsetToPtr( fileBlockBody, 106 embeddedItemInfo.offset ); 107 } 108 }; 109 110 struct FileBlockBody 111 { 112 // プレースホルダ 113 }; 114 115 struct FileBlock 116 { 117 ut::BinaryBlockHeader header; 118 FileBlockBody body; 119 }; 120 121 }; 122 123 124 } // namespace nw::snd::internal 125 } // namespace nw::snd 126 } // namespace nw 127 128 129 #endif /* NW_SND_GROUP_FILE_H_ */ 130 131