src/mame/drivers/megadriv.c
| r4789 | r4790 | |
| 2242 | 2242 | } |
| 2243 | 2243 | |
| 2244 | 2244 | |
| 2245 | static TIMER_CALLBACK( megadriv_z80_run_state ) |
| 2246 | { |
| 2247 | /* Is the z80 RESET line pulled? */ |
| 2248 | if ( genz80.z80_is_reset ) |
| 2249 | { |
| 2250 | devtag_reset( machine, "genesis_snd_z80" ); |
| 2251 | cputag_suspend( machine, "genesis_snd_z80", SUSPEND_REASON_HALT, 1 ); |
| 2252 | devtag_reset( machine, "ym" ); |
| 2253 | } |
| 2254 | else |
| 2255 | { |
| 2256 | /* Check if z80 has the bus */ |
| 2257 | if ( genz80.z80_has_bus ) |
| 2258 | { |
| 2259 | cputag_resume( machine, "genesis_snd_z80", SUSPEND_REASON_HALT ); |
| 2260 | } |
| 2261 | else |
| 2262 | { |
| 2263 | cputag_suspend( machine, "genesis_snd_z80", SUSPEND_REASON_HALT, 1 ); |
| 2264 | } |
| 2265 | } |
| 2266 | } |
| 2267 | |
| 2268 | |
| 2245 | 2269 | static WRITE16_HANDLER( megadriv_68k_req_z80_bus ) |
| 2246 | 2270 | { |
| 2247 | 2271 | /* Request the Z80 bus, allows 68k to read/write Z80 address space */ |
| r4789 | r4790 | |
| 2251 | 2275 | { |
| 2252 | 2276 | //logerror("%06x: 68000 request z80 Bus (byte MSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask); |
| 2253 | 2277 | genz80.z80_has_bus = 0; |
| 2254 | | cputag_suspend( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT, 1 ); |
| 2255 | 2278 | } |
| 2256 | 2279 | else |
| 2257 | 2280 | { |
| 2258 | 2281 | //logerror("%06x: 68000 return z80 Bus (byte MSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask); |
| 2259 | 2282 | genz80.z80_has_bus = 1; |
| 2260 | | cputag_resume( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT ); |
| 2261 | 2283 | } |
| 2262 | 2284 | } |
| 2263 | 2285 | else if (!ACCESSING_BITS_8_15) // is this valid? |
| r4789 | r4790 | |
| 2266 | 2288 | { |
| 2267 | 2289 | //logerror("%06x: 68000 request z80 Bus (byte LSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask); |
| 2268 | 2290 | genz80.z80_has_bus = 0; |
| 2269 | | cputag_suspend( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT, 1 ); |
| 2270 | 2291 | } |
| 2271 | 2292 | else |
| 2272 | 2293 | { |
| 2273 | 2294 | //logerror("%06x: 68000 return z80 Bus (byte LSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask); |
| 2274 | 2295 | genz80.z80_has_bus = 1; |
| 2275 | | cputag_resume( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT ); |
| 2276 | 2296 | } |
| 2277 | 2297 | } |
| 2278 | 2298 | else // word access |
| r4789 | r4790 | |
| 2281 | 2301 | { |
| 2282 | 2302 | //logerror("%06x: 68000 request z80 Bus (word access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask); |
| 2283 | 2303 | genz80.z80_has_bus = 0; |
| 2284 | | cputag_suspend( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT, 1 ); |
| 2285 | 2304 | } |
| 2286 | 2305 | else |
| 2287 | 2306 | { |
| 2288 | 2307 | //logerror("%06x: 68000 return z80 Bus (byte LSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask); |
| 2289 | 2308 | genz80.z80_has_bus = 1; |
| 2290 | | cputag_resume( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT ); |
| 2291 | 2309 | } |
| 2292 | 2310 | } |
| 2311 | timer_set( space->machine, attotime_zero, NULL, 0, megadriv_z80_run_state ); |
| 2293 | 2312 | } |
| 2294 | 2313 | |
| 2295 | 2314 | static WRITE16_HANDLER ( megadriv_68k_req_z80_reset ) |
| r4789 | r4790 | |
| 2300 | 2319 | { |
| 2301 | 2320 | //logerror("%06x: 68000 clear z80 reset (byte MSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask); |
| 2302 | 2321 | genz80.z80_is_reset = 0; |
| 2303 | | if ( genz80.z80_has_bus ) |
| 2304 | | cputag_resume( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT ); |
| 2305 | 2322 | } |
| 2306 | 2323 | else |
| 2307 | 2324 | { |
| 2308 | 2325 | //logerror("%06x: 68000 start z80 reset (byte MSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask); |
| 2309 | 2326 | genz80.z80_is_reset = 1; |
| 2310 | | device_reset( cputag_get_cpu(space->machine, "genesis_snd_z80") ); |
| 2311 | | cputag_suspend( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT, 1 ); |
| 2312 | | devtag_reset(space->machine, "ym"); |
| 2313 | 2327 | } |
| 2314 | 2328 | } |
| 2315 | 2329 | else if (!ACCESSING_BITS_8_15) // is this valid? |
| r4789 | r4790 | |
| 2318 | 2332 | { |
| 2319 | 2333 | //logerror("%06x: 68000 clear z80 reset (byte LSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask); |
| 2320 | 2334 | genz80.z80_is_reset = 0; |
| 2321 | | if ( genz80.z80_has_bus ) |
| 2322 | | cputag_resume( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT ); |
| 2323 | 2335 | } |
| 2324 | 2336 | else |
| 2325 | 2337 | { |
| 2326 | 2338 | //logerror("%06x: 68000 start z80 reset (byte LSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask); |
| 2327 | 2339 | genz80.z80_is_reset = 1; |
| 2328 | | device_reset( cputag_get_cpu(space->machine, "genesis_snd_z80") ); |
| 2329 | | cputag_suspend( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT, 1 ); |
| 2330 | | devtag_reset(space->machine, "ym"); |
| 2331 | | |
| 2332 | 2340 | } |
| 2333 | 2341 | } |
| 2334 | 2342 | else // word access |
| r4789 | r4790 | |
| 2337 | 2345 | { |
| 2338 | 2346 | //logerror("%06x: 68000 clear z80 reset (word access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask); |
| 2339 | 2347 | genz80.z80_is_reset = 0; |
| 2340 | | if ( genz80.z80_has_bus ) |
| 2341 | | cputag_resume( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT ); |
| 2342 | 2348 | } |
| 2343 | 2349 | else |
| 2344 | 2350 | { |
| 2345 | 2351 | //logerror("%06x: 68000 start z80 reset (byte LSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask); |
| 2346 | 2352 | genz80.z80_is_reset = 1; |
| 2347 | | device_reset( cputag_get_cpu(space->machine, "genesis_snd_z80") ); |
| 2348 | | cputag_suspend( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT, 1 ); |
| 2349 | | devtag_reset(space->machine, "ym"); |
| 2350 | 2353 | } |
| 2351 | 2354 | } |
| 2355 | timer_set( space->machine, attotime_zero, NULL, 0, megadriv_z80_run_state ); |
| 2352 | 2356 | } |
| 2353 | 2357 | |
| 2354 | 2358 | static READ8_HANDLER( z80_read_68k_banked_data ) |
| r4789 | r4790 | |
| 5973 | 5977 | if (cputag_get_cpu(machine, "genesis_snd_z80") != NULL) |
| 5974 | 5978 | { |
| 5975 | 5979 | genz80.z80_is_reset = 1; |
| 5976 | | cputag_set_input_line(machine, "genesis_snd_z80", INPUT_LINE_RESET, ASSERT_LINE); |
| 5977 | 5980 | genz80.z80_has_bus = 1; |
| 5978 | | cputag_set_input_line(machine, "genesis_snd_z80", INPUT_LINE_HALT, CLEAR_LINE); |
| 5979 | 5981 | genz80.z80_bank_addr = 0; |
| 5980 | 5982 | genesis_scanline_counter = -1; |
| 5983 | timer_set( machine, attotime_zero, NULL, 0, megadriv_z80_run_state ); |
| 5981 | 5984 | } |
| 5982 | 5985 | |
| 5983 | 5986 | megadrive_imode = 0; |