summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/sound/k056800.c
blob: 60443468b6dd18eacf6edc6ff2c1aa7f2159a341 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/***********************************************************************

    Konami K056800 (MIRAC)
    Sound interface and audio control

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

#include "emu.h"
#include "sound/k056800.h"



const device_type K056800 = &device_creator<k056800_device>;



//-------------------------------------------------
//  k056800_device - constructor
//-------------------------------------------------

k056800_device::k056800_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
				: device_t(mconfig, K056800, "Konami 056800 MIRAC", tag, owner, clock, "k056800", __FILE__),
	m_int_handler(*this)
{
}


//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void k056800_device::device_start()
{
	m_int_handler.resolve_safe();

	save_item(NAME(m_int_pending));
	save_item(NAME(m_host_to_snd_regs));
	save_item(NAME(m_snd_to_host_regs));
}


//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void k056800_device::device_reset()
{
	m_int_pending = false;
	memset(m_host_to_snd_regs, 0, sizeof(m_host_to_snd_regs));
	memset(m_snd_to_host_regs, 0, sizeof(m_snd_to_host_regs));
}


/*****************************************************************************
    DEVICE HANDLERS
*****************************************************************************/

READ8_MEMBER( k056800_device::host_r )
{
	UINT32 r = offset & 7;
	UINT8 data = 0;

	switch (r)
	{
		case 0:
		case 1:
			data = m_snd_to_host_regs[r];
			break;

		case 2:
			// .... ...x - Front volume busy
			// .... ..x. - Rear volume busy
			break;
	}

	return data;
}


WRITE8_MEMBER( k056800_device::host_w )
{
	UINT32 r = offset & 7;

	switch (r)
	{
		case 0:
		case 1:
		case 2:
		case 3:
			m_host_to_snd_regs[r] = data;
			break;

		case 4:
			// xxxx xxxx - Front volume (CAh increments, 35h decrements)
			break;

		case 5:
			// xxxx xxxx - Rear volume (as above)
			break;

		case 6:
			// .... ...x - Mute front
			// .... ..x. - Mute rear
			break;

		case 7:
			// Sound interrupt
			m_int_pending = true;

			if (m_int_enabled)
				m_int_handler(ASSERT_LINE);

			break;
	}
}


READ8_MEMBER( k056800_device::sound_r )
{
	UINT32 r = offset & 7;
	UINT8 data = 0;

	switch (r)
	{
		case 0:
		case 1:
		case 2:
		case 3:
			data = m_host_to_snd_regs[r];
			break;
	}

	return data;
}


WRITE8_MEMBER( k056800_device::sound_w )
{
	UINT32 r = offset & 7;

	switch (r)
	{
		case 0:
		case 1:
			m_snd_to_host_regs[r] = data;
			break;

		case 2:
		case 3:
			// TODO: Unknown
			break;

		case 4:
			// Sound CPU interrupt control
			m_int_enabled = (data & 1) != 0;

			if (m_int_enabled)
			{
				// Enable interrupt
				if (m_int_pending)
					m_int_handler(ASSERT_LINE);
			}
			else
			{
				// Disable/acknowledge interrupt
				m_int_pending = false;
				m_int_handler(CLEAR_LINE);
			}
			break;

		case 5:
			// TODO: Unknown
			break;
	}
}