Debian Codegraph @

android/app/jni/extern/vgsound_emu-modified/vgsound_emu/src/k005289/k005289.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): cam900
6 Konami K005289 emulation core
7 */
8
9 #ifndef _VGSOUND_EMU_SRC_K005289_HPP
10 #define _VGSOUND_EMU_SRC_K005289_HPP
11
12 #pragma once
13
14 #include "../core/core.hpp"
15 using namespace vgsound_emu;
16
17 class k005289_core : public vgsound_emu_core
18 {
19 private:
20 // k005289 timer classes
21 class timer_t : public vgsound_emu_core
22 {
23 public:
24 timer_t()
25 : vgsound_emu_core("k005289_timer")
26 , m_addr(0)
27 , m_pitch(0)
28 , m_freq(0)
29 , m_counter(0)
30 {
31 }
32
33 // internal state
34 void reset();
35 void tick(const unsigned int cycles=1);
36
37 // accessors
38 // Replace current frequency to lastest loaded pitch
39 inline void update() { m_freq = m_pitch; }
40
41 // setters
42 // Load pitch data (address pin)
43 inline void load(u16 pitch) { m_pitch = pitch; }
44
45 // getters
46 inline u8 addr() { return m_addr; }
47
48 public:
49 // registers
50 u8 m_addr = 0; // external address pin
51 u16 m_pitch = 0; // pitch
52 u16 m_freq = 0; // current frequency
53 s16 m_counter = 0; // frequency counter
54 };
55
56 public:
57 // constructor
58 k005289_core()
59 : vgsound_emu_core("k005289")
60 , m_timer{timer_t()}
61 {
62 }
63
64 // internal state
65 void reset();
66 void tick(const unsigned int cycles);
67
68 // accessors
69 // TG1/2 pin
70 inline void update(int voice) { m_timer[voice & 1].update(); }
71
72 // setters
73 // LD1/2 pin, A0...11 pin
74 inline void load(int voice, u16 addr) { m_timer[voice & 1].load(addr); }
75
76 // getters
77 // 1QA...E/2QA...E pin
78 inline u8 addr(int voice) { return m_timer[voice & 1].addr(); }
79
80 public:
81 std::array<timer_t, 2> m_timer;
82 };
83
84 #endif