1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_WaveArchiveFile.cpp 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 #include "precompiled.h" 17 #include <nw/snd/snd_WaveArchiveFile.h> 18 19 #include <nw/snd/snd_ElementType.h> 20 21 namespace nw { 22 namespace snd { 23 namespace internal { 24 25 26 // 27 // WaveArchiveFile::FileHeader 28 // 29 const WaveArchiveFile::InfoBlock* GetInfoBlock() const30WaveArchiveFile::FileHeader::GetInfoBlock() const 31 { 32 return reinterpret_cast<const InfoBlock*>( 33 ut::AddOffsetToPtr( this, GetInfoBlockOffset() ) ); 34 } 35 const WaveArchiveFile::FileBlock* GetFileBlock() const36WaveArchiveFile::FileHeader::GetFileBlock() const 37 { 38 return reinterpret_cast<const FileBlock*>( 39 ut::AddOffsetToPtr( this, GetFileBlockOffset() ) ); 40 } 41 GetInfoBlockSize() const42u32 WaveArchiveFile::FileHeader::GetInfoBlockSize() const 43 { 44 return GetReferenceBy( ElementType_WaveArchiveFile_InfoBlock )->size; 45 } GetFileBlockSize() const46u32 WaveArchiveFile::FileHeader::GetFileBlockSize() const 47 { 48 return GetReferenceBy( ElementType_WaveArchiveFile_FileBlock )->size; 49 } GetInfoBlockOffset() const50u32 WaveArchiveFile::FileHeader::GetInfoBlockOffset() const 51 { 52 return GetReferenceBy( ElementType_WaveArchiveFile_InfoBlock )->offset; 53 } GetFileBlockOffset() const54u32 WaveArchiveFile::FileHeader::GetFileBlockOffset() const 55 { 56 return GetReferenceBy( ElementType_WaveArchiveFile_FileBlock )->offset; 57 } 58 const Util::ReferenceWithSize* GetReferenceBy(u16 typeId) const59WaveArchiveFile::FileHeader::GetReferenceBy( u16 typeId ) const 60 { 61 for ( int i = 0; i < BLOCK_SIZE; i++ ) 62 { 63 if ( toBlocks[ i ].typeId == typeId ) 64 { 65 return &toBlocks[ i ]; 66 } 67 } 68 return NULL; 69 } 70 71 72 73 } // namespace nw::snd::internal 74 } // namespace nw::snd 75 } // namespace nw 76