summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/lsasquad.cpp
blob: b11ed937c400265e10f86e2baf1ced81d81b81ec (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:Nicola Salmoria

#include "emu.h"
#include "cpu/z80/z80.h"
#include "includes/lsasquad.h"

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

 main <-> sound CPU communication

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

void lsasquad_state::sh_nmi_disable_w(uint8_t data)
{
	m_soundnmi->in_w<1>(0);
}

void lsasquad_state::sh_nmi_enable_w(uint8_t data)
{
	m_soundnmi->in_w<1>(1);
}

uint8_t lsasquad_state::lsasquad_sound_status_r()
{
	// bit 0: message pending for sound cpu
	// bit 1: message pending for main cpu
	return (m_soundlatch->pending_r() ? 1 : 0) | (m_soundlatch2->pending_r() ? 2 : 0);
}


uint8_t lsasquad_state::daikaiju_sound_status_r()
{
	// bit 0: message pending for sound cpu
	// bit 1: message pending for main cpu
	return (m_soundlatch->pending_r() ? 2 : 1);
}

uint8_t lsasquad_state::lsasquad_mcu_status_r()
{
	int res = m_bmcu_port->read();

	// bit 0 = when 1, mcu is ready to receive data from main cpu
	// bit 1 = when 0, mcu has sent data to the main cpu
	//logerror("%04x: mcu_status_r\n", m_maincpu->pc());
	if (m_bmcu)
	{
		if (CLEAR_LINE == m_bmcu->host_semaphore_r())
			res |= 0x01;
		if (CLEAR_LINE == m_bmcu->mcu_semaphore_r())
			res |= 0x02;
	}

	return res;
}

uint8_t lsasquad_state::daikaiju_mcu_status_r()
{
	int res = m_bmcu_port->read();

	// bit 0 = when 1, mcu is ready to receive data from main cpu
	// bit 1 = when 0, mcu has sent data to the main cpu
	//logerror("%04x: mcu_status_r\n", m_maincpu->pc());
	if (m_bmcu)
	{
		if (CLEAR_LINE == m_bmcu->host_semaphore_r())
			res |= 0x01;
		if (CLEAR_LINE == m_bmcu->mcu_semaphore_r())
			res |= 0x02;
	}

	res |= ((m_soundlatch->pending_r() & 0x02) ^ 2) << 3; //inverted flag
	return res;
}