summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/bigevglf.cpp
blob: bca48fed8afa824afc7b98a07f5548533a739b4c (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
// license:???
// copyright-holders:Jarek Burczynski, Tomasz Slanina
/***************************************************************************

  machine.c

  Functions to emulate general aspects of the machine (RAM, ROM, interrupts,
  I/O ports)

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

#include "emu.h"
#include "includes/bigevglf.h"


READ8_MEMBER(bigevglf_state::bigevglf_68705_port_a_r)
{
	return (m_port_a_out & m_ddr_a) | (m_port_a_in & ~m_ddr_a);
}

WRITE8_MEMBER(bigevglf_state::bigevglf_68705_port_a_w)
{
	m_port_a_out = data;
}

WRITE8_MEMBER(bigevglf_state::bigevglf_68705_ddr_a_w)
{
	m_ddr_a = data;
}

READ8_MEMBER(bigevglf_state::bigevglf_68705_port_b_r)
{
	return (m_port_b_out & m_ddr_b) | (m_port_b_in & ~m_ddr_b);
}

WRITE8_MEMBER(bigevglf_state::bigevglf_68705_port_b_w)
{
	if ((m_ddr_b & 0x02) && (~m_port_b_out & 0x02) && (data & 0x02)) /* positive going transition of the clock */
	{
		m_mcu->set_input_line(0, CLEAR_LINE);
		m_main_sent = 0;

	}
	if ((m_ddr_b & 0x04) && (~m_port_b_out & 0x04) && (data & 0x04) ) /* positive going transition of the clock */
	{
		m_from_mcu = m_port_a_out;
		m_mcu_sent = 0;
	}

	m_port_b_out = data;
}

WRITE8_MEMBER(bigevglf_state::bigevglf_68705_ddr_b_w)
{
	m_ddr_b = data;
}

READ8_MEMBER(bigevglf_state::bigevglf_68705_port_c_r)
{
	m_port_c_in = 0;
	if (m_main_sent)
		m_port_c_in |= 0x01;
	if (m_mcu_sent)
		m_port_c_in |= 0x02;

	return (m_port_c_out & m_ddr_c) | (m_port_c_in & ~m_ddr_c);
}

WRITE8_MEMBER(bigevglf_state::bigevglf_68705_port_c_w)
{
	m_port_c_out = data;
}

WRITE8_MEMBER(bigevglf_state::bigevglf_68705_ddr_c_w)
{
	m_ddr_c = data;
}

WRITE8_MEMBER(bigevglf_state::bigevglf_mcu_w)
{
	m_port_a_in = data;
	m_main_sent = 1;
	m_mcu->set_input_line(0, ASSERT_LINE);
}


READ8_MEMBER(bigevglf_state::bigevglf_mcu_r)
{
	m_mcu_sent = 1;
	return m_from_mcu;
}

READ8_MEMBER(bigevglf_state::bigevglf_mcu_status_r)
{
	int res = 0;

	if (!m_main_sent)
		res |= 0x08;
	if (!m_mcu_sent)
		res |= 0x10;

	return res;
}