Debian Codegraph @

src/engine/platform/sound/sn76496.h

raw
1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3
4 // additional modifications by tildearrow, cam900 for furnace
5 #ifndef MAME_SOUND_SN76496_H
6 #define MAME_SOUND_SN76496_H
7
8 #include <stdlib.h>
9 #include <stdint.h>
10
11 typedef unsigned char u8;
12
13 class sn76496_base_device {
14 public:
15 void stereo_w(u8 data);
16 void write(u8 data);
17 void device_start();
18 void sound_stream_update(short* outputs, int outLen);
19 inline int32_t get_channel_output(int ch) {
20 return ((m_output[ch]!=0)?m_volume[ch]:0);
21 }
22 //DECLARE_READ_LINE_MEMBER( ready_r ) { return m_ready_state ? 1 : 0; }
23
24 sn76496_base_device(
25 int feedbackmask,
26 int noise_start,
27 int noisetap1,
28 int noisetap2,
29 bool negate,
30 bool stereo,
31 bool ncr,
32 bool sega);
33
34 sn76496_base_device(
35 int feedbackmask,
36 int noisetap1,
37 int noisetap2,
38 bool negate,
39 bool stereo,
40 bool ncr,
41 bool sega)
42 : sn76496_base_device(
43 feedbackmask,
44 feedbackmask,
45 noisetap1,
46 noisetap2,
47 negate,
48 stereo,
49 ncr,
50 sega)
51 {}
52
53 public: // SORRY....
54 inline bool in_noise_mode();
55
56 bool m_ready_state;
57
58 const int32_t m_feedback_mask; // mask for feedback
59 const int32_t m_noise_start; // noise start value
60 const int32_t m_whitenoise_tap1; // mask for white noise tap 1 (higher one, usually bit 14)
61 const int32_t m_whitenoise_tap2; // mask for white noise tap 2 (lower one, usually bit 13)
62 bool m_negate; // output negate flag
63 const bool m_stereo; // whether we're dealing with stereo or not
64 const bool m_ncr_style_psg; // flag to ignore writes to regs 1,3,5,6,7 with bit 7 low
65 const bool m_sega_style_psg; // flag to make frequency zero acts as if it is one more than max (0x3ff+1) or if it acts like 0; the initial register is pointing to 0x3 instead of 0x0; the volume reg is preloaded with 0xF instead of 0x0
66
67 int32_t m_vol_table[16]; // volume table (for 4-bit to db conversion)
68 int32_t m_register[8]; // registers
69 int32_t m_last_register; // last register written
70 int32_t m_volume[4]; // db volume of voice 0-2 and noise
71 uint32_t m_RNG; // noise generator LFSR
72 int32_t m_stereo_mask; // the stereo output mask
73 int32_t m_period[4]; // Length of 1/2 of waveform
74 int32_t m_count[4]; // Position within the waveform
75 int32_t m_output[4]; // 1-bit output of each channel, pre-volume
76 };
77
78 // SN76496: Whitenoise verified, phase verified, periodic verified (by Michael Zapf)
79 class sn76496_device : public sn76496_base_device
80 {
81 public:
82 sn76496_device();
83 };
84
85 // Y2404 not verified yet. todo: verify; (don't be fooled by the Y, it's a TI chip, not Yamaha)
86 class y2404_device : public sn76496_base_device
87 {
88 public:
89 y2404_device();
90 };
91
92 // SN76489 not verified yet. todo: verify;
93 class sn76489_device : public sn76496_base_device
94 {
95 public:
96 sn76489_device();
97 };
98
99 // SN76489A: whitenoise verified, phase verified, periodic verified (by plgdavid)
100 class sn76489a_device : public sn76496_base_device
101 {
102 public:
103 sn76489a_device();
104 };
105
106 // SN76494 not verified, (according to datasheet: same as sn76489a but without the /8 divider)
107 class sn76494_device : public sn76496_base_device
108 {
109 public:
110 sn76494_device();
111 };
112
113 // SN94624 whitenoise verified, phase verified, period verified; verified by PlgDavid
114 class sn94624_device : public sn76496_base_device
115 {
116 public:
117 sn94624_device();
118 };
119
120 // NCR8496 whitenoise verified, phase verified; verified by ValleyBell & NewRisingSun
121 class ncr8496_device : public sn76496_base_device
122 {
123 public:
124 ncr8496_device();
125 };
126
127 // PSSJ-3 whitenoise verified, phase verified; verified by ValleyBell & NewRisingSun
128 class pssj3_device : public sn76496_base_device
129 {
130 public:
131 pssj3_device();
132 };
133
134 // Verified by Justin Kerk
135 class gamegear_device : public sn76496_base_device
136 {
137 public:
138 gamegear_device();
139 };
140
141 // todo: verify; from smspower wiki, assumed to have same invert as gamegear
142 class segapsg_device : public sn76496_base_device
143 {
144 public:
145 segapsg_device();
146 };
147
148 #endif // MAME_SOUND_SN76496_H