21
21
***************************************************************************/
23
READ8_HANDLER( flstory_68705_port_a_r )
25
flstory_state *state = space->machine().driver_data<flstory_state>();
27
//logerror("%04x: 68705 port A read %02x\n", cpu_get_pc(&space->device()), state->m_port_a_in);
28
return (state->m_port_a_out & state->m_ddr_a) | (state->m_port_a_in & ~state->m_ddr_a);
31
WRITE8_HANDLER( flstory_68705_port_a_w )
33
flstory_state *state = space->machine().driver_data<flstory_state>();
35
//logerror("%04x: 68705 port A write %02x\n", cpu_get_pc(&space->device()), data);
36
state->m_port_a_out = data;
39
WRITE8_HANDLER( flstory_68705_ddr_a_w )
41
flstory_state *state = space->machine().driver_data<flstory_state>();
42
state->m_ddr_a = data;
23
READ8_MEMBER(flstory_state::flstory_68705_port_a_r)
26
//logerror("%04x: 68705 port A read %02x\n", cpu_get_pc(&space.device()), m_port_a_in);
27
return (m_port_a_out & m_ddr_a) | (m_port_a_in & ~m_ddr_a);
30
WRITE8_MEMBER(flstory_state::flstory_68705_port_a_w)
33
//logerror("%04x: 68705 port A write %02x\n", cpu_get_pc(&space.device()), data);
37
WRITE8_MEMBER(flstory_state::flstory_68705_ddr_a_w)
53
50
* 2 W when 0->1, copies port A to the latch for the main CPU
56
READ8_HANDLER( flstory_68705_port_b_r )
58
flstory_state *state = space->machine().driver_data<flstory_state>();
59
return (state->m_port_b_out & state->m_ddr_b) | (state->m_port_b_in & ~state->m_ddr_b);
62
WRITE8_HANDLER( flstory_68705_port_b_w )
64
flstory_state *state = space->machine().driver_data<flstory_state>();
65
//logerror("%04x: 68705 port B write %02x\n",cpu_get_pc(&space->device()),data);
67
if ((state->m_ddr_b & 0x02) && (~data & 0x02) && (state->m_port_b_out & 0x02))
69
state->m_port_a_in = state->m_from_main;
70
if (state->m_main_sent)
71
device_set_input_line(state->m_mcu, 0, CLEAR_LINE);
72
state->m_main_sent = 0;
73
logerror("read command %02x from main cpu\n", state->m_port_a_in);
75
if ((state->m_ddr_b & 0x04) && (data & 0x04) && (~state->m_port_b_out & 0x04))
77
logerror("send command %02x to main cpu\n", state->m_port_a_out);
78
state->m_from_mcu = state->m_port_a_out;
79
state->m_mcu_sent = 1;
82
state->m_port_b_out = data;
85
WRITE8_HANDLER( flstory_68705_ddr_b_w )
87
flstory_state *state = space->machine().driver_data<flstory_state>();
88
state->m_ddr_b = data;
92
READ8_HANDLER( flstory_68705_port_c_r )
94
flstory_state *state = space->machine().driver_data<flstory_state>();
96
state->m_port_c_in = 0;
97
if (state->m_main_sent)
98
state->m_port_c_in |= 0x01;
100
if (!state->m_mcu_sent)
101
state->m_port_c_in |= 0x02;
103
//logerror("%04x: 68705 port C read %02x\n", cpu_get_pc(&space->device()), port_c_in);
104
return (state->m_port_c_out & state->m_ddr_c) | (state->m_port_c_in & ~state->m_ddr_c);
107
WRITE8_HANDLER( flstory_68705_port_c_w )
109
flstory_state *state = space->machine().driver_data<flstory_state>();
110
logerror("%04x: 68705 port C write %02x\n", cpu_get_pc(&space->device()), data);
111
state->m_port_c_out = data;
114
WRITE8_HANDLER( flstory_68705_ddr_c_w )
116
flstory_state *state = space->machine().driver_data<flstory_state>();
117
state->m_ddr_c = data;
120
WRITE8_HANDLER( flstory_mcu_w )
122
flstory_state *state = space->machine().driver_data<flstory_state>();
124
logerror("%04x: mcu_w %02x\n", cpu_get_pc(&space->device()), data);
125
state->m_from_main = data;
126
state->m_main_sent = 1;
127
device_set_input_line(state->m_mcu, 0, ASSERT_LINE);
130
READ8_HANDLER( flstory_mcu_r )
132
flstory_state *state = space->machine().driver_data<flstory_state>();
134
logerror("%04x: mcu_r %02x\n",cpu_get_pc(&space->device()), state->m_from_mcu);
135
state->m_mcu_sent = 0;
136
return state->m_from_mcu;
139
READ8_HANDLER( flstory_mcu_status_r )
141
flstory_state *state = space->machine().driver_data<flstory_state>();
53
READ8_MEMBER(flstory_state::flstory_68705_port_b_r)
55
return (m_port_b_out & m_ddr_b) | (m_port_b_in & ~m_ddr_b);
58
WRITE8_MEMBER(flstory_state::flstory_68705_port_b_w)
60
//logerror("%04x: 68705 port B write %02x\n",cpu_get_pc(&space.device()),data);
62
if ((m_ddr_b & 0x02) && (~data & 0x02) && (m_port_b_out & 0x02))
64
m_port_a_in = m_from_main;
66
device_set_input_line(m_mcu, 0, CLEAR_LINE);
68
logerror("read command %02x from main cpu\n", m_port_a_in);
70
if ((m_ddr_b & 0x04) && (data & 0x04) && (~m_port_b_out & 0x04))
72
logerror("send command %02x to main cpu\n", m_port_a_out);
73
m_from_mcu = m_port_a_out;
80
WRITE8_MEMBER(flstory_state::flstory_68705_ddr_b_w)
86
READ8_MEMBER(flstory_state::flstory_68705_port_c_r)
96
//logerror("%04x: 68705 port C read %02x\n", cpu_get_pc(&space.device()), port_c_in);
97
return (m_port_c_out & m_ddr_c) | (m_port_c_in & ~m_ddr_c);
100
WRITE8_MEMBER(flstory_state::flstory_68705_port_c_w)
102
logerror("%04x: 68705 port C write %02x\n", cpu_get_pc(&space.device()), data);
106
WRITE8_MEMBER(flstory_state::flstory_68705_ddr_c_w)
111
WRITE8_MEMBER(flstory_state::flstory_mcu_w)
114
logerror("%04x: mcu_w %02x\n", cpu_get_pc(&space.device()), data);
117
device_set_input_line(m_mcu, 0, ASSERT_LINE);
120
READ8_MEMBER(flstory_state::flstory_mcu_r)
123
logerror("%04x: mcu_r %02x\n",cpu_get_pc(&space.device()), m_from_mcu);
128
READ8_MEMBER(flstory_state::flstory_mcu_status_r)
144
132
/* bit 0 = when 1, mcu is ready to receive data from main cpu */
145
133
/* bit 1 = when 1, mcu has sent data to the main cpu */
146
//logerror("%04x: mcu_status_r\n", cpu_get_pc(&space->device()));
147
if (!state->m_main_sent)
134
//logerror("%04x: mcu_status_r\n", cpu_get_pc(&space.device()));
149
if (state->m_mcu_sent)
155
WRITE8_HANDLER( onna34ro_mcu_w )
143
WRITE8_MEMBER(flstory_state::onna34ro_mcu_w)
157
flstory_state *state = space->machine().driver_data<flstory_state>();
158
UINT16 score_adr = state->m_workram[0x29e] * 0x100 + state->m_workram[0x29d];
145
UINT16 score_adr = m_workram[0x29e] * 0x100 + m_workram[0x29d];
163
state->m_from_mcu = 0xff;
166
state->m_from_mcu = 0x6a;
169
156
if(score_adr >= 0xe000 && score_adr < 0xe800)
170
state->m_from_mcu = state->m_workram[score_adr - 0xe000]; /* score l*/
157
m_from_mcu = m_workram[score_adr - 0xe000]; /* score l*/
173
160
if(score_adr >= 0xe000 && score_adr < 0xe800)
174
state->m_from_mcu = state->m_workram[(score_adr + 1) - 0xe000]; /* score m*/
161
m_from_mcu = m_workram[(score_adr + 1) - 0xe000]; /* score m*/
177
164
if(score_adr >= 0xe000 && score_adr < 0xe800)
178
state->m_from_mcu = state->m_workram[(score_adr + 2) - 0xe000] & 0x0f; /* score h*/
165
m_from_mcu = m_workram[(score_adr + 2) - 0xe000] & 0x0f; /* score h*/
181
state->m_from_mcu = 0x80;
185
READ8_HANDLER( onna34ro_mcu_r )
172
READ8_MEMBER(flstory_state::onna34ro_mcu_r)
187
flstory_state *state = space->machine().driver_data<flstory_state>();
188
return state->m_from_mcu;
191
READ8_HANDLER( onna34ro_mcu_status_r )
177
READ8_MEMBER(flstory_state::onna34ro_mcu_status_r)