1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_MmlParser.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: 19566 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_SND_MML_PARSER_H_ 17 #define NW_SND_MML_PARSER_H_ 18 19 #include <nw/snd/snd_SequenceTrack.h> 20 21 namespace nw { 22 namespace snd { 23 namespace internal { 24 namespace driver { 25 26 class MmlSequenceTrack; 27 class SequenceSoundPlayer; 28 29 /* ======================================================================== 30 class definition 31 ======================================================================== */ 32 33 class MmlParser 34 { 35 public: 36 static const int PAN_CENTER = 64; 37 static const int SURROUND_PAN_CENTER = 64; 38 static const int CALL_STACK_DEPTH = 3; 39 static const int TEMPO_MIN = 0; 40 static const int TEMPO_MAX = 1023; 41 42 private: 43 enum SeqArgType 44 { 45 SEQ_ARG_NONE, 46 SEQ_ARG_U8, 47 SEQ_ARG_S16, 48 SEQ_ARG_VMIDI, 49 SEQ_ARG_RANDOM, 50 SEQ_ARG_VARIABLE 51 }; 52 53 public: 54 SequenceTrack::ParseResult Parse( 55 MmlSequenceTrack* track, 56 bool doNoteOn 57 ) const; 58 59 static u32 ParseAllocTrack( const void* baseAddress, u32 seqOffset, u32* allocTrack ); 60 EnablePrintVar(bool enble)61 static void EnablePrintVar( bool enble ) { mPrintVarEnabledFlag = enble; } IsEnabledPrintVar()62 static bool IsEnabledPrintVar() { return mPrintVarEnabledFlag; } 63 64 protected: 65 virtual void CommandProc( 66 MmlSequenceTrack* track, 67 u32 command, 68 s32 commandArg1, 69 s32 commandArg2 70 ) const; 71 72 virtual void NoteOnCommandProc( 73 MmlSequenceTrack* track, 74 int key, 75 int velocity, 76 s32 length, 77 bool tieFlag 78 ) const; 79 80 private: 81 static bool mPrintVarEnabledFlag; 82 ReadByte(const u8 ** ptr)83 u8 ReadByte( const u8** ptr ) const { return *(*ptr)++; } UnreadByte(const u8 ** ptr)84 void UnreadByte( const u8** ptr ) const { --(*ptr); } 85 u16 Read16( const u8** ptr ) const; 86 u32 Read24( const u8** ptr ) const; 87 s32 ReadVar( const u8** ptr ) const; 88 s32 ReadArg( const u8** ptr, SequenceSoundPlayer* player, SequenceTrack* track, SeqArgType argType ) const; 89 vs16* GetVariablePtr( SequenceSoundPlayer* player, SequenceTrack* track, int varNo ) const; 90 }; 91 92 } // namespace nw::snd::internal::driver 93 } // namespace nw::snd::internal 94 } // namespace nw::snd 95 } // namespace nw 96 97 98 #endif /* NW_SND_MML_PARSER_H_ */ 99 100