1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     OriginalSoundHeapApp.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:$
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NW_SND_DEMO_SIMPLE_APP_H_
17 #define NW_SND_DEMO_SIMPLE_APP_H_
18 
19 #include "demolib.h"
20 #include <nw/snd.h>
21 
22 /*  頭とおしりから取得できるサウンドヒープ。
23     実用的にするには、残りサイズを取得できるようにしたり、
24     小分けに Alloc/Free できるようにする必要がある。
25     (現在は Alloc と Free (全削除) しかできない) */
26 class OriginalSoundHeap : public nw::snd::SoundMemoryAllocatable
27 {
28 public:
29     virtual void* Alloc( size_t size );
30     void Free();
31 
32     OriginalSoundHeap();
33     bool Create( void* startAddress, size_t size );
34     void* Destroy();
35 
SetAllocDirection(bool isDirectionHead)36     void SetAllocDirection( bool isDirectionHead )
37     {
38         m_IsDirectionHead = isDirectionHead;
39     }
40 
41 private:
42     static const int ALIGNMENT_SIZE = 32;
43     nw::ut::FrameHeap* m_pFrameHeap;
44     void* m_pBufferHead;
45     size_t m_BufferSize;
46     bool m_IsDirectionHead;
47 };
48 
49 
50 class OriginalSoundHeapApp : public nw::snd::demolib::AppBase
51 {
52 protected:
53     virtual void OnInitialize();
54     virtual void OnFinalize();
55     virtual void OnDrawUpLCD( nw::font::TextWriter& );
56     virtual void OnDrawDownLCD( nw::font::TextWriter& );
57     virtual void OnUpdatePad( nw::demo::Pad& );
58     virtual void OnUpdate();
59 
60 private:
61     void InitializeSoundSystem();
62 
63     nw::snd::RomSoundArchive    m_Archive;
64     nw::snd::SoundArchivePlayer m_ArchivePlayer;
65     nw::snd::SoundDataManager   m_DataManager;
66     OriginalSoundHeap           m_Heap;
67     nw::snd::SoundHandle        m_Handle;
68 
69     void* m_pMemoryForSoundSystem;
70     void* m_pMemoryForInfoBlock;
71     void* m_pMemoryForStringBlock;
72     void* m_pMemoryForSoundDataManager;
73     void* m_pMemoryForSoundArchivePlayer;
74     void* m_pMemoryForSoundHeap;
75     void* m_pMemoryForStreamBuffer;
76 };
77 
78 #endif /* NW_SND_DEMO_SIMPLE_APP_H_ */
79 
80