Debian Codegraph @

android/app/jni/extern/vgsound_emu-modified/vgsound_emu/src/template/template.hpp

raw
1 /*
2 License: Zlib
3 see https://gitlab.com/cam900/vgsound_emu/-/blob/main/LICENSE for more details
4
5 Copyright holder(s): (Author name)
6 Template for sound emulation core, also guideline
7 */
8
9 #ifndef _VGSOUND_EMU_SRC_TEMPLATE_HPP // _VGSOUND_EMU_ABSOLUTE_PATH_OF_THIS_FILE
10 #define _VGSOUND_EMU_SRC_TEMPLATE_HPP
11
12 #pragma once
13
14 #include "../core/core.hpp"
15 #include "../core/util/mem_intf.hpp"
16
17 using namespace vgsound_emu;
18
19 class template_core : public vgsound_emu_core
20 {
21 friend class vgsound_emu_mem_intf; // common memory interface if exists
22
23 private: // protected: if shares between inheritances
24 // place classes and local constants here if exists
25
26 // template voice classes
27 class voice_t : public vgsound_emu_core
28 {
29 public:
30 // constructor
31 voice_t(template_core &host)
32 : vgsound_emu_core("your_voice_tag_here")
33 , m_host(host)
34 , m_something(0)
35 {
36 }
37
38 // internal state
39 void reset();
40 void tick();
41
42 // accessors, getters, setters
43
44 // setters
45 void set_something(s32 something) { m_something = something; }
46
47 // getters
48 s32 something() { return m_something; }
49
50 private:
51 // registers
52 template_core &m_host;
53 s32 m_something = 0; // register
54 };
55
56 public:
57 // place constructor and destructor, getter and setter for local variables,
58 // off-chip interfaces, update routine here only if can't be local
59
60 // constructor
61 template_core(vgsound_emu_mem_intf &intf)
62 : vgsound_emu_core("your_core_tag_here")
63 // initialize all variables in constructor, because constructor is also executable
64 // anywhere, and it works as initializer.
65 , m_voice{*this}
66 , m_intf(intf)
67 {
68 m_array.fill(0);
69 m_vector.resize(1,0);
70 }
71
72 // accessors, getters, setters
73
74 // internal state
75 void reset();
76 void tick();
77
78 protected:
79 // place local variables and functions here if shares between inheritances
80
81 private:
82 // place local variables and functions here
83
84 std::array<voice_t, 1 /*number of voices*/> m_voice; // voice classes
85 vgsound_emu_mem_intf &m_intf; // common memory interface
86 std::array<u8 /*type*/, 8 /*size of array*/> m_array; // std::array for static size array
87 std::vector<u8 /*type*/> m_vector; // std::vector for variable size array
88 };
89
90 #endif