1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_WaveArchiveFile.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: 22284 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_SND_WAVE_ARCHIVE_FILE_H_ 17 #define NW_SND_WAVE_ARCHIVE_FILE_H_ 18 19 #include <nw/ut/ut_BinaryFileFormat.h> 20 #include <nw/snd/snd_Util.h> 21 22 namespace nw { 23 namespace snd { 24 namespace internal { 25 26 // 27 // MEMO: WaveArchiveFile (.bxwar = 波形アーカイブファイル) 28 // * ヘッダ、INFO ブロックは最初に読む 29 // * FILE ブロックをまるごと読むこともある 30 // * FILE ブロックのうち、必要な波形ファイルのみ読むことも鳴る 31 // 32 33 struct WaveArchiveFile 34 { 35 // 36 // ヘッダー 37 // 38 struct InfoBlock; 39 struct FileBlock; 40 41 static const int BLOCK_SIZE = 2; 42 43 // メモ : WaveArchiveFile::FileHeader はヘッダだけ個別にロードするので、 44 // Util::SoundFileHeader を継承できない。 45 struct FileHeader : public ut::BinaryFileHeader 46 { 47 // データ 48 Util::ReferenceWithSize toBlocks[ BLOCK_SIZE ]; 49 50 // アクセサ (一括ロードの場合に有効) 51 const InfoBlock* GetInfoBlock() const; 52 const FileBlock* GetFileBlock() const; 53 54 // アクセサ (個別ロードのときに利用される) 55 u32 GetInfoBlockSize() const; 56 u32 GetFileBlockSize() const; 57 u32 GetInfoBlockOffset() const; 58 u32 GetFileBlockOffset() const; 59 60 private: 61 const Util::ReferenceWithSize* GetReferenceBy( u16 typeId ) const; 62 }; 63 64 // 65 // INFO ブロック 66 // 67 struct InfoBlockBody 68 { 69 // データ 70 Util::Table<Util::ReferenceWithSize> table; 71 72 // アクセサ GetWaveFileCountWaveArchiveFile::InfoBlockBody73 inline u32 GetWaveFileCount() const { return table.count; } GetSizeWaveArchiveFile::InfoBlockBody74 u32 GetSize( u32 index ) const 75 { 76 NW_ASSERT( index < GetWaveFileCount() ); 77 return table.item[ index ].size; 78 } GetOffsetFromFileBlockBodyWaveArchiveFile::InfoBlockBody79 u32 GetOffsetFromFileBlockBody( u32 index ) const 80 { 81 NW_ASSERT( index < GetWaveFileCount() ); 82 return table.item[ index ].offset; 83 } 84 85 static const u32 INVALID_OFFSET = 0xffffffff; 86 87 }; 88 struct InfoBlock 89 { 90 ut::BinaryBlockHeader header; 91 InfoBlockBody body; 92 }; 93 94 // 95 // FILE ブロック 96 // 97 struct FileBlockBody 98 { 99 }; 100 struct FileBlock 101 { 102 ut::BinaryBlockHeader header; 103 FileBlockBody body; 104 }; 105 }; 106 107 } // namespace nw::snd::internal 108 } // namespace nw::snd 109 } // namespace nw 110 111 112 #endif /* NW_SND_WAVE_ARCHIVE_FILE_H_ */ 113 114