summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/tvc.h
blob: 4555598bca7b50c57044ec9fa67f976587c0ae56 (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
// license:BSD-3-Clause
// copyright-holders:Sandro Ronco
/*****************************************************************************
 *
 *   includes/tvc.h
 *
 ****************************************************************************/

#ifndef MAME_AUDIO_TVC_H
#define MAME_AUDIO_TVC_H

#pragma once

#define MCFG_TVC_SOUND_SNDINT_CALLBACK(_write) \
	downcast<tvc_sound_device &>(*device).set_sndint_wr_callback(DEVCB_##_write);

//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

// ======================> tvc_sound_device

class tvc_sound_device : public device_t, public device_sound_interface
{
public:
	// construction/destruction
	tvc_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	template <class Object> devcb_base &set_sndint_wr_callback(Object &&cb) { return m_write_sndint.set_callback(std::forward<Object>(cb)); }

	DECLARE_WRITE8_MEMBER(write);
	void reset_divider();

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;
	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
	virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;

private:
	static const device_timer_id TIMER_SNDINT = 0;

	sound_stream *  m_stream;
	int             m_freq;
	int             m_enabled;
	int             m_volume;
	int             m_incr;
	int             m_signal;
	uint8_t           m_ports[3];
	emu_timer *     m_sndint_timer;
	devcb_write_line   m_write_sndint;
};

// device type definition
DECLARE_DEVICE_TYPE(TVC_SOUND, tvc_sound_device)

#endif // MAME_AUDIO_TVC_H