/*---------------------------------------------------------------------------* Project: NintendoWare File: snd_AnimSoundFileReader.cpp Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo and/or its licensed developers and are protected by national and international copyright laws. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. The content herein is highly confidential and should be handled accordingly. $Revision: $ *---------------------------------------------------------------------------*/ #include "precompiled.h" #include #include namespace nw { namespace snd { namespace internal { namespace { const u32 SIGNATURE_FILE = NW_UT_MAKE_SIGWORD( 'C', 'A', 'S', 'D' ); const u32 SIGNATURE_DATA_BLOCK = NW_UT_MAKE_SIGWORD( 'D', 'A', 'T', 'A' ); const u32 SUPPORTED_FILE_VERSION = 0x01000000; // サポートする最低バージョン const u32 CURRENT_FILE_VERSION = 0x01000000; // サポートする最新バージョン bool IsValidFileHeader( const void* bcasdFile ) { const ut::BinaryFileHeader& header = *reinterpret_cast( bcasdFile ); // シグニチャ確認 NW_ASSERTMSG( header.signature == SIGNATURE_FILE, "invalid file signature." ); if ( header.signature != SIGNATURE_FILE ) { return false; } // バージョン確認 NW_ASSERTMSG( header.version >= SUPPORTED_FILE_VERSION, "bcasd file is not supported version.\n" "please reconvert file using new version tools.\n" "(SUPPORTED_FILE_VERSION:0x%08x >= your version:0x%08x)\n", SUPPORTED_FILE_VERSION, header.version ); if ( header.version < SUPPORTED_FILE_VERSION ) { return false; } NW_ASSERTMSG( header.version <= CURRENT_FILE_VERSION, "bcasd file is not supported version.\n" "please reconvert file using new version tools.\n" "(CURRENT_FILE_VERSION:0x%08x <= your version:0x%08x)\n", CURRENT_FILE_VERSION, header.version ); if ( header.version > CURRENT_FILE_VERSION ) { return false; } return true; } } // anonymous namespace AnimSoundFileReader::AnimSoundFileReader() : m_pAnimEventTable( NULL ), m_FrameSize( 0 ) {} bool AnimSoundFileReader::Initialize( const void* bcasdFile ) { if ( ! IsValidFileHeader( bcasdFile ) ) { return false; } const AnimSoundFile::FileHeader* header = reinterpret_cast( bcasdFile ); const AnimSoundFile::DataBlockBody* body = &header->GetDataBlock()->body; NW_NULL_ASSERT( body ); if ( ! body ) { return false; } const AnimSoundFile::AnimEventTable* table = body->GetAnimEventTable(); NW_NULL_ASSERT( table ); if ( ! table ) { return false; } m_pAnimEventTable = table; m_FrameSize = body->frameSize; return true; } void AnimSoundFileReader::Finalize() { m_pAnimEventTable = NULL; m_FrameSize = 0; } } // namespace nw::snd::internal } // namespace nw::snd } // namespace nw