summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/awacs.h
blob: 656cc7a814efe2806867bbacb471260b28c05ff7 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
// license:BSD-3-Clause
// copyright-holders:R. Belmont
/***************************************************************************

    awacs.h

    AWACS/Singer style 16-bit audio I/O for '040 and PowerPC Macs

***************************************************************************/

#ifndef MAME_SOUND_AWACS_H
#define MAME_SOUND_AWACS_H

#pragma once

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

// ======================> awacs_device

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

	auto irq_out_cb() { return m_irq_out_cb.bind(); }
	auto irq_in_cb() { return m_irq_in_cb.bind(); }

	auto dma_output() { return m_output_cb.bind(); }
	auto dma_input() { return m_input_cb.bind(); }

	auto port_input() { return m_input_port_cb.bind(); }
	auto port_output() { return m_output_port_cb.bind(); }

	uint8_t read(offs_t offset);
	void write(offs_t offset, uint8_t data);

protected:
	enum {
		ACTIVE_OUT = 0x01,
		ACTIVE_IN = 0x02
	};

	static const u8 divider[4];

	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;

	virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;

	devcb_write_line m_irq_out_cb, m_irq_in_cb;
	devcb_read32 m_output_cb;
	devcb_write32 m_input_cb;
	devcb_read8 m_input_port_cb;
	devcb_write8 m_output_port_cb;

	sound_stream *m_stream;

	attotime m_last_sample;
	u8 m_ctrl0, m_ctrl1, m_codec0, m_codec1, m_codec2, m_out_irq, m_in_irq, m_active;
	u16 m_ext_address, m_ext_data, m_buffer_size, m_phase;
	bool m_extend, m_ext_command, m_input_buffer, m_output_buffer;

	void update_irq();
};


// device type definition
DECLARE_DEVICE_TYPE(AWACS, awacs_device)

#endif // MAME_SOUND_AWACS_H