1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_WaveArchiveFileReader.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: 28239 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_SND_WAVE_ARCHIVE_FILE_READER_H_ 17 #define NW_SND_WAVE_ARCHIVE_FILE_READER_H_ 18 19 #include <nw/snd/snd_WaveArchiveFile.h> 20 21 namespace nw { 22 namespace snd { 23 namespace internal { 24 25 class WaveArchiveFileReader 26 { 27 public: 28 static const u32 SIGNATURE_FILE = NW_UT_MAKE_SIGWORD( 'C', 'W', 'A', 'R' ); 29 static const u32 SIGNATURE_WARC_TABLE; 30 31 WaveArchiveFileReader( const void* pWaveArchiveFile, bool isIndividual = false ); 32 33 // 初期化 34 void InitializeFileTable(); IsAvailable()35 bool IsAvailable() const { return m_pHeader != NULL; } 36 37 u32 GetWaveFileCount() const; 38 u32 GetWaveFileSize( u32 waveIndex ) const; 39 u32 GetWaveFileOffsetFromFileHead( u32 waveIndex ) const; 40 41 // 一括ロードの場合 42 const void* GetWaveFile( u32 waveIndex ) const; 43 44 // 個別ロード時に利用 45 const void* SetWaveFile( u32 waveIndex, const void* pWaveFile ); IsLoaded(u32 waveIndex)46 bool IsLoaded( u32 waveIndex ) const 47 { 48 // if ( GetWaveFileForIndividual( waveIndex ) != NULL ) 49 if ( GetWaveFile( waveIndex ) != NULL ) 50 { 51 return true; 52 } 53 return false; 54 } 55 56 bool HasIndividualLoadTable() const; 57 58 private: 59 // 個別ロードされる波形のロード管理テーブル 60 struct IndividualLoadTable 61 { 62 const void* waveFile[1]; // 実際には、 InfoBlockBody.table.count だけ要素が並ぶ 63 }; 64 65 // アクセサ GetWaveFileForWhole(u32 waveIndex)66 const void* GetWaveFileForWhole( u32 waveIndex ) const 67 { 68 u32 offset = m_pInfoBlockBody->GetOffsetFromFileBlockBody( waveIndex ); 69 return ut::AddOffsetToPtr( &m_pHeader->GetFileBlock()->body, offset ); 70 } GetWaveFileForIndividual(u32 waveIndex)71 const void* GetWaveFileForIndividual( u32 waveIndex ) const 72 { 73 return m_pLoadTable->waveFile[ waveIndex ]; 74 } 75 76 77 // データ 78 const WaveArchiveFile::FileHeader* m_pHeader; 79 const WaveArchiveFile::InfoBlockBody* m_pInfoBlockBody; 80 IndividualLoadTable* m_pLoadTable; 81 }; 82 83 } // namespace nw::snd::internal 84 } // namespace nw::snd 85 } // namespace nw 86 87 88 #endif /* NW_SND_WAVE_ARCHIVE_FILE_READER_H_ */ 89 90