16
16
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
19
static UINT8 fromz80,toz80;
20
static UINT8 zaccept,zready,busreq;
21
static UINT8 portA_in,portA_out;
23
static UINT8 spacecr_prot_value;
24
static UINT8 protection_value;
25
static UINT32 address;
27
19
MACHINE_START( taitosj )
29
memory_configure_bank(machine, "bank1", 0, 1, machine->region("maincpu")->base() + 0x6000, 0);
30
memory_configure_bank(machine, "bank1", 1, 1, machine->region("maincpu")->base() + 0x10000, 0);
32
state_save_register_global(machine, fromz80);
33
state_save_register_global(machine, toz80);
34
state_save_register_global(machine, zaccept);
35
state_save_register_global(machine, zready);
36
state_save_register_global(machine, busreq);
38
state_save_register_global(machine, portA_in);
39
state_save_register_global(machine, portA_out);
40
state_save_register_global(machine, address);
41
state_save_register_global(machine, spacecr_prot_value);
42
state_save_register_global(machine, protection_value);
21
taitosj_state *state = machine.driver_data<taitosj_state>();
22
memory_configure_bank(machine, "bank1", 0, 1, machine.region("maincpu")->base() + 0x6000, 0);
23
memory_configure_bank(machine, "bank1", 1, 1, machine.region("maincpu")->base() + 0x10000, 0);
25
state->save_item(NAME(state->m_fromz80));
26
state->save_item(NAME(state->m_toz80));
27
state->save_item(NAME(state->m_zaccept));
28
state->save_item(NAME(state->m_zready));
29
state->save_item(NAME(state->m_busreq));
31
state->save_item(NAME(state->m_portA_in));
32
state->save_item(NAME(state->m_portA_out));
33
state->save_item(NAME(state->m_address));
34
state->save_item(NAME(state->m_spacecr_prot_value));
35
state->save_item(NAME(state->m_protection_value));
45
38
MACHINE_RESET( taitosj )
47
address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
40
taitosj_state *state = machine.driver_data<taitosj_state>();
41
address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
48
42
/* set the default ROM bank (many games only have one bank and */
49
43
/* never write to the bank selector register) */
50
44
taitosj_bankswitch_w(space, 0, 0);
56
if (machine->device("mcu") != NULL)
50
if (machine.device("mcu") != NULL)
57
51
cputag_set_input_line(machine, "mcu", 0, CLEAR_LINE);
59
spacecr_prot_value = 0;
53
state->m_spacecr_prot_value = 0;
63
57
WRITE8_HANDLER( taitosj_bankswitch_w )
65
coin_lockout_global_w(space->machine, ~data & 1);
59
coin_lockout_global_w(space->machine(), ~data & 1);
67
if(data & 0x80) memory_set_bank(space->machine, "bank1", 1);
68
else memory_set_bank(space->machine, "bank1", 0);
61
if(data & 0x80) memory_set_bank(space->machine(), "bank1", 1);
62
else memory_set_bank(space->machine(), "bank1", 0);
85
79
***************************************************************************/
86
80
READ8_HANDLER( taitosj_fake_data_r )
88
LOG(("%04x: protection read\n",cpu_get_pc(space->cpu)));
82
LOG(("%04x: protection read\n",cpu_get_pc(&space->device())));
92
86
WRITE8_HANDLER( taitosj_fake_data_w )
94
LOG(("%04x: protection write %02x\n",cpu_get_pc(space->cpu),data));
88
LOG(("%04x: protection write %02x\n",cpu_get_pc(&space->device()),data));
97
91
READ8_HANDLER( taitosj_fake_status_r )
99
LOG(("%04x: protection status read\n",cpu_get_pc(space->cpu)));
93
LOG(("%04x: protection status read\n",cpu_get_pc(&space->device())));
104
98
/* timer callback : */
105
99
READ8_HANDLER( taitosj_mcu_data_r )
107
LOG(("%04x: protection read %02x\n",cpu_get_pc(space->cpu),toz80));
101
taitosj_state *state = space->machine().driver_data<taitosj_state>();
102
LOG(("%04x: protection read %02x\n",cpu_get_pc(&space->device()),state->m_toz80));
103
state->m_zaccept = 1;
104
return state->m_toz80;
112
107
/* timer callback : */
113
108
static TIMER_CALLBACK( taitosj_mcu_real_data_w )
110
taitosj_state *state = machine.driver_data<taitosj_state>();
116
112
cputag_set_input_line(machine, "mcu", 0, ASSERT_LINE);
113
state->m_fromz80 = param;
120
116
WRITE8_HANDLER( taitosj_mcu_data_w )
122
LOG(("%04x: protection write %02x\n",cpu_get_pc(space->cpu),data));
123
timer_call_after_resynch(space->machine, NULL, data,taitosj_mcu_real_data_w);
118
LOG(("%04x: protection write %02x\n",cpu_get_pc(&space->device()),data));
119
space->machine().scheduler().synchronize(FUNC(taitosj_mcu_real_data_w), data);
124
120
/* temporarily boost the interleave to sync things up */
125
cpuexec_boost_interleave(space->machine, attotime_zero, ATTOTIME_IN_USEC(10));
121
space->machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(10));
128
124
READ8_HANDLER( taitosj_mcu_status_r )
126
taitosj_state *state = space->machine().driver_data<taitosj_state>();
130
127
/* temporarily boost the interleave to sync things up */
131
cpuexec_boost_interleave(space->machine, attotime_zero, ATTOTIME_IN_USEC(10));
128
space->machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(10));
133
130
/* bit 0 = the 68705 has read data from the Z80 */
134
131
/* bit 1 = the 68705 has written data for the Z80 */
135
return ~((zready << 0) | (zaccept << 1));
132
return ~((state->m_zready << 0) | (state->m_zaccept << 1));
138
135
READ8_HANDLER( taitosj_68705_portA_r )
140
LOG(("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),portA_in));
137
taitosj_state *state = space->machine().driver_data<taitosj_state>();
138
LOG(("%04x: 68705 port A read %02x\n",cpu_get_pc(&space->device()),state->m_portA_in));
139
return state->m_portA_in;
144
142
WRITE8_HANDLER( taitosj_68705_portA_w )
146
LOG(("%04x: 68705 port A write %02x\n",cpu_get_pc(space->cpu),data));
144
taitosj_state *state = space->machine().driver_data<taitosj_state>();
145
LOG(("%04x: 68705 port A write %02x\n",cpu_get_pc(&space->device()),data));
146
state->m_portA_out = data;
177
176
/* timer callback : 68705 is going to read data from the Z80 */
178
177
static TIMER_CALLBACK( taitosj_mcu_data_real_r )
179
taitosj_state *state = machine.driver_data<taitosj_state>();
183
183
/* timer callback : 68705 is writing data for the Z80 */
184
184
static TIMER_CALLBACK( taitosj_mcu_status_real_w )
186
taitosj_state *state = machine.driver_data<taitosj_state>();
187
state->m_toz80 = param;
188
state->m_zaccept = 0;
190
191
WRITE8_HANDLER( taitosj_68705_portB_w )
192
LOG(("%04x: 68705 port B write %02x\n", cpu_get_pc(space->cpu), data));
193
taitosj_state *state = space->machine().driver_data<taitosj_state>();
194
LOG(("%04x: 68705 port B write %02x\n", cpu_get_pc(&space->device()), data));
194
196
if (~data & 0x01)
196
LOG(("%04x: 68705 68INTRQ **NOT SUPPORTED**!\n", cpu_get_pc(space->cpu)));
198
LOG(("%04x: 68705 68INTRQ **NOT SUPPORTED**!\n", cpu_get_pc(&space->device())));
198
200
if (~data & 0x02)
200
202
/* 68705 is going to read data from the Z80 */
201
timer_call_after_resynch(space->machine, NULL, 0, taitosj_mcu_data_real_r);
202
cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE);
204
LOG(("%04x: 68705 <- Z80 %02x\n", cpu_get_pc(space->cpu), portA_in));
203
space->machine().scheduler().synchronize(FUNC(taitosj_mcu_data_real_r));
204
cputag_set_input_line(space->machine(), "mcu", 0, CLEAR_LINE);
205
state->m_portA_in = state->m_fromz80;
206
LOG(("%04x: 68705 <- Z80 %02x\n", cpu_get_pc(&space->device()), state->m_portA_in));
206
208
if (~data & 0x08)
210
212
if (~data & 0x04)
212
LOG(("%04x: 68705 -> Z80 %02x\n", cpu_get_pc(space->cpu), portA_out));
214
LOG(("%04x: 68705 -> Z80 %02x\n", cpu_get_pc(&space->device()), state->m_portA_out));
214
216
/* 68705 is writing data for the Z80 */
215
timer_call_after_resynch(space->machine, NULL, portA_out, taitosj_mcu_status_real_w);
217
space->machine().scheduler().synchronize(FUNC(taitosj_mcu_status_real_w), state->m_portA_out);
217
219
if (~data & 0x10)
219
address_space *cpu0space = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
220
LOG(("%04x: 68705 write %02x to address %04x\n",cpu_get_pc(space->cpu), portA_out, address));
221
address_space *cpu0space = space->machine().device("maincpu")->memory().space(AS_PROGRAM);
222
LOG(("%04x: 68705 write %02x to address %04x\n",cpu_get_pc(&space->device()), state->m_portA_out, state->m_address));
222
cpu0space->write_byte(address, portA_out);
224
cpu0space->write_byte(state->m_address, state->m_portA_out);
224
226
/* increase low 8 bits of latched address for burst writes */
225
address = (address & 0xff00) | ((address + 1) & 0xff);
227
state->m_address = (state->m_address & 0xff00) | ((state->m_address + 1) & 0xff);
227
229
if (~data & 0x20)
229
address_space *cpu0space = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
230
portA_in = cpu0space->read_byte(address);
231
LOG(("%04x: 68705 read %02x from address %04x\n", cpu_get_pc(space->cpu), portA_in, address));
231
address_space *cpu0space = space->machine().device("maincpu")->memory().space(AS_PROGRAM);
232
state->m_portA_in = cpu0space->read_byte(state->m_address);
233
LOG(("%04x: 68705 read %02x from address %04x\n", cpu_get_pc(&space->device()), state->m_portA_in, state->m_address));
233
235
if (~data & 0x40)
235
LOG(("%04x: 68705 address low %02x\n", cpu_get_pc(space->cpu), portA_out));
236
address = (address & 0xff00) | portA_out;
237
LOG(("%04x: 68705 address low %02x\n", cpu_get_pc(&space->device()), state->m_portA_out));
238
state->m_address = (state->m_address & 0xff00) | state->m_portA_out;
238
240
if (~data & 0x80)
240
LOG(("%04x: 68705 address high %02x\n", cpu_get_pc(space->cpu), portA_out));
241
address = (address & 0x00ff) | (portA_out << 8);
242
LOG(("%04x: 68705 address high %02x\n", cpu_get_pc(&space->device()), state->m_portA_out));
243
state->m_address = (state->m_address & 0x00ff) | (state->m_portA_out << 8);
282
286
WRITE8_HANDLER( alpine_protection_w )
288
taitosj_state *state = space->machine().driver_data<taitosj_state>();
287
protection_value = 0x18;
292
state->m_protection_value = 0x18;
292
protection_value = 0x00; /* not used as far as I can tell */
297
state->m_protection_value = 0x00; /* not used as far as I can tell */
295
protection_value = 0x08;
300
state->m_protection_value = 0x08;
298
protection_value = 0x18;
303
state->m_protection_value = 0x18;
301
protection_value = data; /* not used as far as I can tell */
306
state->m_protection_value = data; /* not used as far as I can tell */
306
311
WRITE8_HANDLER( alpinea_bankswitch_w )
313
taitosj_state *state = space->machine().driver_data<taitosj_state>();
308
314
taitosj_bankswitch_w(space, offset, data);
309
protection_value = data >> 2;
315
state->m_protection_value = data >> 2;
312
318
READ8_HANDLER( alpine_port_2_r )
314
return input_port_read(space->machine, "IN2") | protection_value;
320
taitosj_state *state = space->machine().driver_data<taitosj_state>();
321
return input_port_read(space->machine(), "IN2") | state->m_protection_value;