1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     snd_WaveArchiveFile.cpp
4 
5   Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain proprietary
8   information of Nintendo and/or its licensed developers and are protected by
9   national and international copyright laws. They may not be disclosed to third
10   parties or copied or duplicated in any form, in whole or in part, without the
11   prior written consent of Nintendo.
12 
13   The content herein is highly confidential and should be handled accordingly.
14 
15   $Revision: 31311 $
16  *---------------------------------------------------------------------------*/
17 
18 #include "precompiled.h"
19 #include <nw/snd/snd_WaveArchiveFile.h>
20 
21 #include <nw/snd/snd_ElementType.h>
22 
23 namespace nw {
24 namespace snd {
25 namespace internal {
26 
27 
28 //
29 // WaveArchiveFile::FileHeader
30 //
31 const WaveArchiveFile::InfoBlock*
GetInfoBlock() const32 WaveArchiveFile::FileHeader::GetInfoBlock() const
33 {
34     return reinterpret_cast<const InfoBlock*>(
35             ut::AddOffsetToPtr( this, GetInfoBlockOffset() ) );
36 }
37 const WaveArchiveFile::FileBlock*
GetFileBlock() const38 WaveArchiveFile::FileHeader::GetFileBlock() const
39 {
40     return reinterpret_cast<const FileBlock*>(
41             ut::AddOffsetToPtr( this, GetFileBlockOffset() ) );
42 }
43 
GetInfoBlockSize() const44 u32 WaveArchiveFile::FileHeader::GetInfoBlockSize() const
45 {
46     return GetReferenceBy( ElementType_WaveArchiveFile_InfoBlock )->size;
47 }
GetFileBlockSize() const48 u32 WaveArchiveFile::FileHeader::GetFileBlockSize() const
49 {
50     return GetReferenceBy( ElementType_WaveArchiveFile_FileBlock )->size;
51 }
GetInfoBlockOffset() const52 u32 WaveArchiveFile::FileHeader::GetInfoBlockOffset() const
53 {
54     return GetReferenceBy( ElementType_WaveArchiveFile_InfoBlock )->offset;
55 }
GetFileBlockOffset() const56 u32 WaveArchiveFile::FileHeader::GetFileBlockOffset() const
57 {
58     return GetReferenceBy( ElementType_WaveArchiveFile_FileBlock )->offset;
59 }
60 const Util::ReferenceWithSize*
GetReferenceBy(u16 typeId) const61 WaveArchiveFile::FileHeader::GetReferenceBy( u16 typeId ) const
62 {
63     for ( int i = 0; i < BLOCK_SIZE; i++ )
64     {
65         if ( toBlocks[ i ].typeId == typeId )
66         {
67             return &toBlocks[ i ];
68         }
69     }
70     return NULL;
71 }
72 
73 
74 
75 } // namespace nw::snd::internal
76 } // namespace nw::snd
77 } // namespace nw
78