summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/sound/c6280.h
blob: 0ce240ff26e73e845308b8185743b7beec26e497 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// license:???
// copyright-holders:???
#pragma once

#ifndef __C6280_H__
#define __C6280_H__

#include "cpu/h6280/h6280.h"

class c6280_device : public device_t,
						public device_sound_interface
{
public:
	c6280_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);

	static void set_devicecpu_tag(device_t &device, const char *tag) { downcast<c6280_device &>(device).m_cpudevice.set_tag(tag); }

	// read/write
	DECLARE_READ8_MEMBER( c6280_r );
	DECLARE_WRITE8_MEMBER( c6280_w );

protected:
	// device-level overrides
	virtual void device_start();

	// sound stream update overrides
	virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);

private:
	struct channel {
		UINT16 m_frequency;
		UINT8 m_control;
		UINT8 m_balance;
		UINT8 m_waveform[32];
		UINT8 m_index;
		INT16 m_dda;
		UINT8 m_noise_control;
		UINT32 m_noise_counter;
		UINT32 m_counter;
	};

	// internal state
	sound_stream *m_stream;
	required_device<h6280_device> m_cpudevice;
	UINT8 m_select;
	UINT8 m_balance;
	UINT8 m_lfo_frequency;
	UINT8 m_lfo_control;
	channel m_channel[8];
	INT16 m_volume_table[32];
	UINT32 m_noise_freq_tab[32];
	UINT32 m_wave_freq_tab[4096];
};

extern const device_type C6280;

#define MCFG_C6280_CPU(_tag) \
	c6280_device::set_devicecpu_tag(*device, "^" _tag);


#endif /* __C6280_H__ */