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