Debian Codegraph @

src/engine/platform/sound/nes_nsfplay/nes_mmc5.h

raw
1 #ifndef _NES_MMC5_H_
2 #define _NES_MMC5_H_
3
4 namespace xgm
5 {
6 class NES_MMC5
7 {
8 public:
9 enum
10 { OPT_NONLINEAR_MIXER=0, OPT_PHASE_REFRESH, OPT_END };
11
12 protected:
13 int option[OPT_END];
14 int mask;
15 int sm[2][3]; // stereo panning
16 unsigned char ram[0x6000 - 0x5c00];
17 unsigned char reg[8];
18 unsigned char mreg[2];
19 unsigned char pcm; // PCM channel
20 bool pcm_mode; // PCM channel
21
22 unsigned int scounter[2]; // frequency divider
23 unsigned int sphase[2]; // phase counter
24
25 unsigned int duty[2];
26 unsigned int volume[2];
27 unsigned int freq[2];
28 int out[3];
29 bool enable[2];
30
31 bool envelope_disable[2]; // エンベロープ有効フラグ
32 bool envelope_loop[2]; // エンベロープループ
33 bool envelope_write[2];
34 int envelope_div_period[2];
35 int envelope_div[2];
36 int envelope_counter[2];
37
38 int length_counter[2];
39
40 int frame_sequence_count;
41
42 double clock, rate;
43 int calc_sqr (int i, unsigned int clocks);
44 int square_table[32];
45 int pcm_table[256];
46 public:
47 NES_MMC5 ();
48 ~NES_MMC5 ();
49
50 void FrameSequence ();
51 void TickFrameSequence (unsigned int clocks);
52
53 void Reset ();
54 void Tick (unsigned int clocks);
55 unsigned int Render (int b[2]);
56 bool Write (unsigned int adr, unsigned int val, unsigned int id=0);
57 bool Read (unsigned int adr, unsigned int & val, unsigned int id=0);
58 void SetOption (int id, int b);
59 void SetClock (double);
60 void SetRate (double);
61 void SetMask (int m){ mask = m; }
62 void SetStereoMix (int trk, short mixl, short mixr);
63 };
64
65 }
66
67 #endif