Debian Codegraph @

src/engine/platform/sound/vsu.h

raw
1 /******************************************************************************/
2 /* Mednafen Virtual Boy Emulation Module */
3 /******************************************************************************/
4 /* vsu.h:
5 ** Copyright (C) 2010-2016 Mednafen Team
6 **
7 ** This program is free software; you can redistribute it and/or
8 ** modify it under the terms of the GNU General Public License
9 ** as published by the Free Software Foundation; either version 2
10 ** of the License, or (at your option) any later version.
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; if not, write to the Free Software Foundation, Inc.,
19 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22 #ifndef __VB_VSU_H
23 #define __VB_VSU_H
24
25 #include "blip_buf.h"
26 #include "../../dispatch.h"
27
28 class VSU
29 {
30 public:
31
32 int last_output[6][2];
33 blip_buffer_t* bb[2];
34 DivDispatchOscBuffer* oscBuf[6];
35
36 VSU();
37 ~VSU();
38
39 void SetSoundRate(double rate);
40
41 void Power(void);
42
43 void Write(int timestamp, unsigned int A, unsigned char V);
44
45 int EndFrame(int timestamp);
46
47 unsigned char PeekWave(const unsigned int which, unsigned int Address);
48 void PokeWave(const unsigned int which, unsigned int Address, unsigned char value);
49
50 unsigned char PeekModWave(unsigned int Address);
51 void PokeModWave(unsigned int Address, unsigned char value);
52
53 private:
54
55 void CalcCurrentOutput(int ch, int &left, int &right);
56
57 void Update(int timestamp);
58
59 unsigned char IntlControl[6];
60 unsigned char LeftLevel[6];
61 unsigned char RightLevel[6];
62 unsigned short Frequency[6];
63 unsigned short EnvControl[6]; // Channel 5/6 extra functionality tacked on too.
64
65 unsigned char RAMAddress[6];
66
67 unsigned char SweepControl;
68
69 unsigned char WaveData[5][0x20];
70
71 unsigned char ModData[0x20];
72
73 //
74 //
75 //
76 int EffFreq[6];
77 int EnvelopeValue[6];
78 int EnvelopeReload[6];
79
80 int WavePos[6];
81 int ModWavePos;
82
83 int LatcherClockDivider[6];
84
85 int FreqCounter[6];
86 int IntervalCounter[6];
87 int EnvelopeCounter[6];
88 int SweepModCounter;
89
90 int EffectsClockDivider[6];
91 int IntervalClockDivider[6];
92 int EnvelopeClockDivider[6];
93 int SweepModClockDivider;
94
95 public:
96 int EnvelopeModMask[6];
97 int ModState;
98 int ModLock;
99
100 private:
101 int NoiseLatcherClockDivider;
102 unsigned int NoiseLatcher;
103
104 unsigned int lfsr;
105
106 int last_ts;
107 };
108
109 #endif