1 // license:BSD-3-Clause
2 // copyright-holders:Takahiro Nogi, David Haywood
3 #ifndef MAME_AUDIO_GOMOKU_H
4 #define MAME_AUDIO_GOMOKU_H
5 
6 //**************************************************************************
7 //  TYPE DEFINITIONS
8 //**************************************************************************
9 
10 // ======================> gomoku_sound_device
11 
12 class gomoku_sound_device : public device_t,
13 							public device_sound_interface
14 {
15 public:
16 	gomoku_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 48'000);
17 
18 	void sound1_w(offs_t offset, uint8_t data);
19 	void sound2_w(offs_t offset, uint8_t data);
20 
21 protected:
22 	// device-level overrides
23 	virtual void device_start() override;
24 
25 	// sound stream update overrides
26 	virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
27 
28 private:
29 	void make_mixer_table(int voices, int gain);
30 
31 	// 4 voices max
32 	static constexpr unsigned MAX_VOICES = 4;
33 
34 	struct sound_channel
35 	{
sound_channelsound_channel36 		sound_channel() { }
37 
38 		int channel = 0;
39 		int frequency = 0;
40 		int counter = 0;
41 		int volume = 0;
42 		int oneshotplaying = 0;
43 	};
44 
45 
46 	// data about the sound system
47 	sound_channel m_channel_list[MAX_VOICES];
48 
49 	// global sound parameters
50 	required_region_ptr<uint8_t> m_sound_rom;
51 	bool m_sound_enable;
52 	sound_stream *m_stream;
53 
54 	// mixer tables and internal buffers
55 	std::vector<short> m_mixer_buffer;
56 
57 	uint8_t m_soundregs1[0x20];
58 	uint8_t m_soundregs2[0x20];
59 };
60 
61 DECLARE_DEVICE_TYPE(GOMOKU_SOUND, gomoku_sound_device)
62 
63 #endif // MAME_AUDIO_GOMOKU_H
64