Debian Codegraph @

src/engine/platform/sound/saa1099.h

raw
1 // license:BSD-3-Clause
2 // copyright-holders:Juergen Buchmueller, Manuel Abadia
3 /**********************************************
4 Philips SAA1099 Sound driver
5 **********************************************/
6
7 #ifndef MAME_SOUND_SAA1099_H
8 #define MAME_SOUND_SAA1099_H
9
10 #include "../../dispatch.h"
11
12 //**************************************************************************
13 // TYPE DEFINITIONS
14 //**************************************************************************
15
16 // ======================> saa1099_device
17
18 class saa1099_device
19 {
20 public:
21 saa1099_device();
22
23 void control_w(unsigned char data);
24 void data_w(unsigned char data);
25
26 void write(int offset, unsigned char data);
27
28 // device-level overrides
29 void device_start();
30 void device_clock_changed();
31
32 // sound stream update overrides
33 void sound_stream_update(short** outputs, int len, DivDispatchOscBuffer** oscBuf=NULL);
34
35 private:
36 struct saa1099_channel
37 {
38 saa1099_channel() : amplitude{ 0, 0 }, envelope{ 0, 0 } { }
39
40 unsigned char frequency = 0; // frequency (0x00..0xff)
41 bool freq_enable = false; // frequency enable
42 bool noise_enable = false; // noise enable
43 unsigned char octave = 0; // octave (0x00..0x07)
44 unsigned short amplitude[2]; // amplitude
45 unsigned char envelope[2]; // envelope (0x00..0x0f or 0x10 == off)
46
47 /* vars to simulate the square wave */
48 inline unsigned int freq() const { return (511 - frequency) << (8 - octave); } // clock / ((511 - frequency) * 2^(8 - octave))
49 int counter = 0;
50 unsigned char level = 0;
51 };
52
53 struct saa1099_noise
54 {
55 saa1099_noise() { }
56
57 /* vars to simulate the noise generator output */
58 int counter = 0;
59 int freq = 0;
60 unsigned int level = 0xffffffffU; // noise polynomial shifter
61 };
62
63 void envelope_w(int ch);
64
65 unsigned char m_noise_params[2]; // noise generators parameters
66 bool m_env_enable[2]; // envelope generators enable
67 bool m_env_reverse_right[2]; // envelope reversed for right channel
68 unsigned char m_env_mode[2]; // envelope generators mode
69 bool m_env_bits[2]; // true = 3 bits resolution
70 bool m_env_clock[2]; // envelope clock mode (true external)
71 unsigned char m_env_step[2]; // current envelope step
72 bool m_all_ch_enable; // all channels enable
73 bool m_sync_state; // sync all channels
74 unsigned char m_selected_reg; // selected register
75 saa1099_channel m_channels[6]; // channels
76 saa1099_noise m_noise[2]; // noise generators
77 };
78
79 #endif // MAME_SOUND_SAA1099_H