~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/mame/machine/taitosj.c

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Emmanuel Kasper, Félix Arreola Rodríguez, Jordi Mallach
  • Date: 2011-05-11 21:06:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110511210650-jizvh8a6x117y9hr
Tags: 0.142-1
[ Emmanuel Kasper ]
* New upstream release
* Set NOWERROR=1 to allow compiling with gcc-4.6
* Remove fix_powerpc_build.patch, as upstream has taken it in this release
* Add gnome-video-arcade front end as a suggested package

[ Félix Arreola Rodríguez ]
* Add kfreebsd-build.patch to quilt series, to fix build on kfreebsd

[ Jordi Mallach ]
* Remove unneeded and bogus addition of --with-quilt to the dh invocation.
* Add Cesare Falco (long time Ubuntu maintainer) to Uploaders, and wrap
  them into multiple lines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
17
17
 
18
18
 
19
 
static UINT8 fromz80,toz80;
20
 
static UINT8 zaccept,zready,busreq;
21
 
static UINT8 portA_in,portA_out;
22
 
 
23
 
static UINT8 spacecr_prot_value;
24
 
static UINT8 protection_value;
25
 
static UINT32 address;
26
 
 
27
19
MACHINE_START( taitosj )
28
20
{
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);
31
 
 
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);
37
 
 
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);
 
24
 
 
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));
 
30
 
 
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));
43
36
}
44
37
 
45
38
MACHINE_RESET( taitosj )
46
39
{
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);
51
45
 
52
46
 
53
 
        zaccept = 1;
54
 
        zready = 0;
55
 
        busreq = 0;
56
 
        if (machine->device("mcu") != NULL)
 
47
        state->m_zaccept = 1;
 
48
        state->m_zready = 0;
 
49
        state->m_busreq = 0;
 
50
        if (machine.device("mcu") != NULL)
57
51
                cputag_set_input_line(machine, "mcu", 0, CLEAR_LINE);
58
52
 
59
 
        spacecr_prot_value = 0;
 
53
        state->m_spacecr_prot_value = 0;
60
54
}
61
55
 
62
56
 
63
57
WRITE8_HANDLER( taitosj_bankswitch_w )
64
58
{
65
 
        coin_lockout_global_w(space->machine, ~data & 1);
 
59
        coin_lockout_global_w(space->machine(), ~data & 1);
66
60
 
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);
69
63
}
70
64
 
71
65
 
85
79
***************************************************************************/
86
80
READ8_HANDLER( taitosj_fake_data_r )
87
81
{
88
 
        LOG(("%04x: protection read\n",cpu_get_pc(space->cpu)));
 
82
        LOG(("%04x: protection read\n",cpu_get_pc(&space->device())));
89
83
        return 0;
90
84
}
91
85
 
92
86
WRITE8_HANDLER( taitosj_fake_data_w )
93
87
{
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));
95
89
}
96
90
 
97
91
READ8_HANDLER( taitosj_fake_status_r )
98
92
{
99
 
        LOG(("%04x: protection status read\n",cpu_get_pc(space->cpu)));
 
93
        LOG(("%04x: protection status read\n",cpu_get_pc(&space->device())));
100
94
        return 0xff;
101
95
}
102
96
 
104
98
/* timer callback : */
105
99
READ8_HANDLER( taitosj_mcu_data_r )
106
100
{
107
 
        LOG(("%04x: protection read %02x\n",cpu_get_pc(space->cpu),toz80));
108
 
        zaccept = 1;
109
 
        return 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;
110
105
}
111
106
 
112
107
/* timer callback : */
113
108
static TIMER_CALLBACK( taitosj_mcu_real_data_w )
114
109
{
115
 
        zready = 1;
 
110
        taitosj_state *state = machine.driver_data<taitosj_state>();
 
111
        state->m_zready = 1;
116
112
        cputag_set_input_line(machine, "mcu", 0, ASSERT_LINE);
117
 
        fromz80 = param;
 
113
        state->m_fromz80 = param;
118
114
}
119
115
 
120
116
WRITE8_HANDLER( taitosj_mcu_data_w )
121
117
{
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));
126
122
}
127
123
 
128
124
READ8_HANDLER( taitosj_mcu_status_r )
129
125
{
 
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));
132
129
 
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));
136
133
}
137
134
 
138
135
READ8_HANDLER( taitosj_68705_portA_r )
139
136
{
140
 
        LOG(("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),portA_in));
141
 
        return 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;
142
140
}
143
141
 
144
142
WRITE8_HANDLER( taitosj_68705_portA_w )
145
143
{
146
 
        LOG(("%04x: 68705 port A write %02x\n",cpu_get_pc(space->cpu),data));
147
 
        portA_out = 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;
148
147
}
149
148
 
150
149
 
177
176
/* timer callback : 68705 is going to read data from the Z80 */
178
177
static TIMER_CALLBACK( taitosj_mcu_data_real_r )
179
178
{
180
 
        zready = 0;
 
179
        taitosj_state *state = machine.driver_data<taitosj_state>();
 
180
        state->m_zready = 0;
181
181
}
182
182
 
183
183
/* timer callback : 68705 is writing data for the Z80 */
184
184
static TIMER_CALLBACK( taitosj_mcu_status_real_w )
185
185
{
186
 
        toz80 = param;
187
 
        zaccept = 0;
 
186
        taitosj_state *state = machine.driver_data<taitosj_state>();
 
187
        state->m_toz80 = param;
 
188
        state->m_zaccept = 0;
188
189
}
189
190
 
190
191
WRITE8_HANDLER( taitosj_68705_portB_w )
191
192
{
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));
193
195
 
194
196
        if (~data & 0x01)
195
197
        {
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())));
197
199
        }
198
200
        if (~data & 0x02)
199
201
        {
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);
203
 
                portA_in = fromz80;
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));
205
207
        }
206
208
        if (~data & 0x08)
207
 
                busreq = 1;
 
209
                state->m_busreq = 1;
208
210
        else
209
 
                busreq = 0;
 
211
                state->m_busreq = 0;
210
212
        if (~data & 0x04)
211
213
        {
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));
213
215
 
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);
216
218
        }
217
219
        if (~data & 0x10)
218
220
        {
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));
221
223
 
222
 
                cpu0space->write_byte(address, portA_out);
 
224
                cpu0space->write_byte(state->m_address, state->m_portA_out);
223
225
 
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);
226
228
        }
227
229
        if (~data & 0x20)
228
230
        {
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));
232
234
        }
233
235
        if (~data & 0x40)
234
236
        {
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;
237
239
        }
238
240
        if (~data & 0x80)
239
241
        {
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);
242
244
        }
243
245
}
244
246
 
254
256
 
255
257
READ8_HANDLER( taitosj_68705_portC_r )
256
258
{
 
259
        taitosj_state *state = space->machine().driver_data<taitosj_state>();
257
260
        int res;
258
261
 
259
 
        res = (zready << 0) | (zaccept << 1) | ((busreq^1) << 2);
260
 
        LOG(("%04x: 68705 port C read %02x\n",cpu_get_pc(space->cpu),res));
 
262
        res = (state->m_zready << 0) | (state->m_zaccept << 1) | ((state->m_busreq^1) << 2);
 
263
        LOG(("%04x: 68705 port C read %02x\n",cpu_get_pc(&space->device()),res));
261
264
        return res;
262
265
}
263
266
 
266
269
 
267
270
READ8_HANDLER( spacecr_prot_r )
268
271
{
269
 
        int pc = cpu_get_pc(space->cpu);
 
272
        taitosj_state *state = space->machine().driver_data<taitosj_state>();
 
273
        int pc = cpu_get_pc(&space->device());
270
274
 
271
275
        if( pc != 0x368A && pc != 0x36A6 )
272
276
                logerror("Read protection from an unknown location: %04X\n",pc);
273
277
 
274
 
        spacecr_prot_value ^= 0xff;
 
278
        state->m_spacecr_prot_value ^= 0xff;
275
279
 
276
 
        return spacecr_prot_value;
 
280
        return state->m_spacecr_prot_value;
277
281
}
278
282
 
279
283
 
281
285
 
282
286
WRITE8_HANDLER( alpine_protection_w )
283
287
{
 
288
        taitosj_state *state = space->machine().driver_data<taitosj_state>();
284
289
        switch (data)
285
290
        {
286
291
        case 0x05:
287
 
                protection_value = 0x18;
 
292
                state->m_protection_value = 0x18;
288
293
                break;
289
294
        case 0x07:
290
295
        case 0x0c:
291
296
        case 0x0f:
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 */
293
298
                break;
294
299
        case 0x16:
295
 
                protection_value = 0x08;
 
300
                state->m_protection_value = 0x08;
296
301
                break;
297
302
        case 0x1d:
298
 
                protection_value = 0x18;
 
303
                state->m_protection_value = 0x18;
299
304
                break;
300
305
        default:
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 */
302
307
                break;
303
308
        }
304
309
}
305
310
 
306
311
WRITE8_HANDLER( alpinea_bankswitch_w )
307
312
{
 
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;
310
316
}
311
317
 
312
318
READ8_HANDLER( alpine_port_2_r )
313
319
{
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;
315
322
}