12
12
bit 1 = microcontroller reset line
13
13
bit 0 = ? (unused?)
15
WRITE8_HANDLER( mexico86_f008_w )
15
WRITE8_MEMBER(mexico86_state::mexico86_f008_w)
17
mexico86_state *state = space->machine().driver_data<mexico86_state>();
19
device_set_input_line(state->m_audiocpu, INPUT_LINE_RESET, (data & 4) ? CLEAR_LINE : ASSERT_LINE);
21
if (state->m_mcu != NULL)
18
device_set_input_line(m_audiocpu, INPUT_LINE_RESET, (data & 4) ? CLEAR_LINE : ASSERT_LINE);
23
22
// mexico 86, knight boy
24
device_set_input_line(state->m_mcu, INPUT_LINE_RESET, (data & 2) ? CLEAR_LINE : ASSERT_LINE);
23
device_set_input_line(m_mcu, INPUT_LINE_RESET, (data & 2) ? CLEAR_LINE : ASSERT_LINE);
28
27
// simulation for KiKi KaiKai
29
state->m_mcu_running = data & 2;
28
m_mcu_running = data & 2;
31
if (!state->m_mcu_running)
32
state->m_mcu_initialised = 0;
31
m_mcu_initialised = 0;
79
78
state->m_protection_ram[0x04] = 0x3c; // coin inputs
81
state->m_protection_ram[0x02] = BITSWAP8(input_port_read(machine, "IN1"), 7,6,5,4,2,3,1,0); // player 1
82
state->m_protection_ram[0x03] = BITSWAP8(input_port_read(machine, "IN2"), 7,6,5,4,2,3,1,0); // player 2
80
state->m_protection_ram[0x02] = BITSWAP8(machine.root_device().ioport("IN1")->read(), 7,6,5,4,2,3,1,0); // player 1
81
state->m_protection_ram[0x03] = BITSWAP8(machine.root_device().ioport("IN2")->read(), 7,6,5,4,2,3,1,0); // player 2
84
83
if (state->m_protection_ram[0x19] == 0xaa) // player 2 active
85
84
state->m_protection_ram[0x1b] = state->m_protection_ram[0x03];
228
READ8_HANDLER( mexico86_68705_port_a_r )
230
mexico86_state *state = space->machine().driver_data<mexico86_state>();
232
//logerror("%04x: 68705 port A read %02x\n", cpu_get_pc(&space->device()), state->m_port_a_in);
233
return (state->m_port_a_out & state->m_ddr_a) | (state->m_port_a_in & ~state->m_ddr_a);
236
WRITE8_HANDLER( mexico86_68705_port_a_w )
238
mexico86_state *state = space->machine().driver_data<mexico86_state>();
240
//logerror("%04x: 68705 port A write %02x\n", cpu_get_pc(&space->device()), data);
241
state->m_port_a_out = data;
244
WRITE8_HANDLER( mexico86_68705_ddr_a_w )
246
mexico86_state *state = space->machine().driver_data<mexico86_state>();
247
state->m_ddr_a = data;
227
READ8_MEMBER(mexico86_state::mexico86_68705_port_a_r)
230
//logerror("%04x: 68705 port A read %02x\n", cpu_get_pc(&space.device()), m_port_a_in);
231
return (m_port_a_out & m_ddr_a) | (m_port_a_in & ~m_ddr_a);
234
WRITE8_MEMBER(mexico86_state::mexico86_68705_port_a_w)
237
//logerror("%04x: 68705 port A write %02x\n", cpu_get_pc(&space.device()), data);
241
WRITE8_MEMBER(mexico86_state::mexico86_68705_ddr_a_w)
268
READ8_HANDLER( mexico86_68705_port_b_r )
264
READ8_MEMBER(mexico86_state::mexico86_68705_port_b_r)
270
mexico86_state *state = space->machine().driver_data<mexico86_state>();
271
return (state->m_port_b_out & state->m_ddr_b) | (state->m_port_b_in & ~state->m_ddr_b);
266
return (m_port_b_out & m_ddr_b) | (m_port_b_in & ~m_ddr_b);
274
WRITE8_HANDLER( mexico86_68705_port_b_w )
269
WRITE8_MEMBER(mexico86_state::mexico86_68705_port_b_w)
276
mexico86_state *state = space->machine().driver_data<mexico86_state>();
277
//logerror("%04x: 68705 port B write %02x\n", cpu_get_pc(&space->device()), data);
279
if (BIT(state->m_ddr_b, 0) && BIT(~data, 0) && BIT(state->m_port_b_out, 0))
281
state->m_port_a_in = state->m_latch;
284
if (BIT(state->m_ddr_b, 1) && BIT(data, 1) && BIT(~state->m_port_b_out, 1)) /* positive edge trigger */
286
state->m_address = state->m_port_a_out;
287
//if (state->m_address >= 0x80) logerror("%04x: 68705 address %02x\n", cpu_get_pc(&space->device()), state->m_port_a_out);
290
if (BIT(state->m_ddr_b, 3) && BIT(~data, 3) && BIT(state->m_port_b_out, 3))
271
//logerror("%04x: 68705 port B write %02x\n", cpu_get_pc(&space.device()), data);
273
if (BIT(m_ddr_b, 0) && BIT(~data, 0) && BIT(m_port_b_out, 0))
275
m_port_a_in = m_latch;
278
if (BIT(m_ddr_b, 1) && BIT(data, 1) && BIT(~m_port_b_out, 1)) /* positive edge trigger */
280
m_address = m_port_a_out;
281
//if (m_address >= 0x80) logerror("%04x: 68705 address %02x\n", cpu_get_pc(&space.device()), m_port_a_out);
284
if (BIT(m_ddr_b, 3) && BIT(~data, 3) && BIT(m_port_b_out, 3))
292
286
if (data & 0x10) /* read */
296
//logerror("%04x: 68705 read %02x from address %04x\n", cpu_get_pc(&space->device()), state->m_protection_ram[state->m_address], state->m_address);
297
state->m_latch = state->m_protection_ram[state->m_address];
290
//logerror("%04x: 68705 read %02x from address %04x\n", cpu_get_pc(&space.device()), m_protection_ram[m_address], m_address);
291
m_latch = m_protection_ram[m_address];
301
//logerror("%04x: 68705 read input port %04x\n", cpu_get_pc(&space->device()), state->m_address);
302
state->m_latch = input_port_read(space->machine(), (state->m_address & 1) ? "IN2" : "IN1");
295
//logerror("%04x: 68705 read input port %04x\n", cpu_get_pc(&space.device()), m_address);
296
m_latch = ioport((m_address & 1) ? "IN2" : "IN1")->read();
307
//logerror("%04x: 68705 write %02x to address %04x\n",cpu_get_pc(&space->device()), port_a_out, state->m_address);
308
state->m_protection_ram[state->m_address] = state->m_port_a_out;
301
//logerror("%04x: 68705 write %02x to address %04x\n",cpu_get_pc(&space.device()), port_a_out, m_address);
302
m_protection_ram[m_address] = m_port_a_out;
312
if (BIT(state->m_ddr_b, 5) && BIT(data, 5) && BIT(~state->m_port_b_out, 5))
314
device_set_input_line_vector(state->m_maincpu, 0, state->m_protection_ram[0]);
315
device_set_input_line(state->m_maincpu, 0, HOLD_LINE); // HOLD_LINE works better in Z80 interrupt mode 1.
316
device_set_input_line(state->m_mcu, 0, CLEAR_LINE);
319
if (BIT(state->m_ddr_b, 6) && BIT(~data, 6) && BIT(state->m_port_b_out, 6))
321
logerror("%04x: 68705 unknown port B bit %02x\n", cpu_get_pc(&space->device()), data);
324
if (BIT(state->m_ddr_b, 7) && BIT(~data, 7) && BIT(state->m_port_b_out, 7))
326
logerror("%04x: 68705 unknown port B bit %02x\n", cpu_get_pc(&space->device()), data);
329
state->m_port_b_out = data;
306
if (BIT(m_ddr_b, 5) && BIT(data, 5) && BIT(~m_port_b_out, 5))
308
device_set_input_line_vector(m_maincpu, 0, m_protection_ram[0]);
309
device_set_input_line(m_maincpu, 0, HOLD_LINE); // HOLD_LINE works better in Z80 interrupt mode 1.
310
device_set_input_line(m_mcu, 0, CLEAR_LINE);
313
if (BIT(m_ddr_b, 6) && BIT(~data, 6) && BIT(m_port_b_out, 6))
315
logerror("%04x: 68705 unknown port B bit %02x\n", cpu_get_pc(&space.device()), data);
318
if (BIT(m_ddr_b, 7) && BIT(~data, 7) && BIT(m_port_b_out, 7))
320
logerror("%04x: 68705 unknown port B bit %02x\n", cpu_get_pc(&space.device()), data);
332
WRITE8_HANDLER( mexico86_68705_ddr_b_w )
326
WRITE8_MEMBER(mexico86_state::mexico86_68705_ddr_b_w)
334
mexico86_state *state = space->machine().driver_data<mexico86_state>();
335
state->m_ddr_b = data;