summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/tiamc1.h
blob: f469e8a40e06fcc779cce5cf19148e01180038c6 (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
// license:BSD-3-Clause
// copyright-holders:Eugene Sandulenko
#ifndef MAME_AUDIO_TIAMC1_H
#define MAME_AUDIO_TIAMC1_H

#pragma once

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

// ======================> tiamc1_sound_device

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

	void tiamc1_timer0_w(offs_t offset, uint8_t data);
	void tiamc1_timer1_w(offs_t offset, uint8_t data);
	void tiamc1_timer1_gate_w(uint8_t data);

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

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

private:
	struct timer8253chan
	{
		timer8253chan() { }

		uint16_t count = 0;
		uint16_t cnval = 0;
		uint8_t bcdMode = 0;
		uint8_t cntMode = 0;
		uint8_t valMode = 0;
		uint8_t gate = 0;
		uint8_t output = 0;
		uint8_t loadCnt = 0;
		uint8_t enable = 0;
	};

	struct timer8253struct
	{
		struct timer8253chan channel[3];
	};


	void timer8253_reset(struct timer8253struct *t);
	void timer8253_tick(struct timer8253struct *t,int chn);
	void timer8253_wr(struct timer8253struct *t, int reg, uint8_t val);
	char timer8253_get_output(struct timer8253struct *t, int chn);
	void timer8253_set_gate(struct timer8253struct *t, int chn, uint8_t gate);

	sound_stream *m_channel;
	int m_timer1_divider;

	timer8253struct m_timer0;
	timer8253struct m_timer1;
};

DECLARE_DEVICE_TYPE(TIAMC1, tiamc1_sound_device)

#endif // MAME_AUDIO_TIAMC1_H