Previous 15994 Revisions Next

r4790 Friday 22nd May, 2009 at 13:18:50 UTC by Wilbert Pol
Improved timing of communication between the main and sound cpus in the megadriv driver.
[src/mame/drivers]megadriv.c

src/mame/drivers/megadriv.c
r4789r4790
22422242}
22432243
22442244
2245static 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
22452269static WRITE16_HANDLER( megadriv_68k_req_z80_bus )
22462270{
22472271   /* Request the Z80 bus, allows 68k to read/write Z80 address space */
r4789r4790
22512275      {
22522276         //logerror("%06x: 68000 request z80 Bus (byte MSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask);
22532277         genz80.z80_has_bus = 0;
2254         cputag_suspend( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT, 1 );
22552278      }
22562279      else
22572280      {
22582281         //logerror("%06x: 68000 return z80 Bus (byte MSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask);
22592282         genz80.z80_has_bus = 1;
2260         cputag_resume( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT );
22612283      }
22622284   }
22632285   else if (!ACCESSING_BITS_8_15) // is this valid?
r4789r4790
22662288      {
22672289         //logerror("%06x: 68000 request z80 Bus (byte LSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask);
22682290         genz80.z80_has_bus = 0;
2269         cputag_suspend( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT, 1 );
22702291      }
22712292      else
22722293      {
22732294         //logerror("%06x: 68000 return z80 Bus (byte LSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask);
22742295         genz80.z80_has_bus = 1;
2275         cputag_resume( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT );
22762296      }
22772297   }
22782298   else // word access
r4789r4790
22812301      {
22822302         //logerror("%06x: 68000 request z80 Bus (word access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask);
22832303         genz80.z80_has_bus = 0;
2284         cputag_suspend( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT, 1 );
22852304      }
22862305      else
22872306      {
22882307         //logerror("%06x: 68000 return z80 Bus (byte LSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask);
22892308         genz80.z80_has_bus = 1;
2290         cputag_resume( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT );
22912309      }
22922310   }
2311   timer_set( space->machine, attotime_zero, NULL, 0, megadriv_z80_run_state );
22932312}
22942313
22952314static WRITE16_HANDLER ( megadriv_68k_req_z80_reset )
r4789r4790
23002319      {
23012320         //logerror("%06x: 68000 clear z80 reset (byte MSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask);
23022321         genz80.z80_is_reset = 0;
2303         if ( genz80.z80_has_bus )
2304            cputag_resume( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT );
23052322      }
23062323      else
23072324      {
23082325         //logerror("%06x: 68000 start z80 reset (byte MSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask);
23092326         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");
23132327      }
23142328   }
23152329   else if (!ACCESSING_BITS_8_15) // is this valid?
r4789r4790
23182332      {
23192333         //logerror("%06x: 68000 clear z80 reset (byte LSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask);
23202334         genz80.z80_is_reset = 0;
2321         if ( genz80.z80_has_bus )
2322            cputag_resume( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT );
23232335      }
23242336      else
23252337      {
23262338         //logerror("%06x: 68000 start z80 reset (byte LSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask);
23272339         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
23322340      }
23332341   }
23342342   else // word access
r4789r4790
23372345      {
23382346         //logerror("%06x: 68000 clear z80 reset (word access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask);
23392347         genz80.z80_is_reset = 0;
2340         if ( genz80.z80_has_bus )
2341            cputag_resume( space->machine, "genesis_snd_z80", SUSPEND_REASON_HALT );
23422348      }
23432349      else
23442350      {
23452351         //logerror("%06x: 68000 start z80 reset (byte LSB access) %04x %04x\n", cpu_get_pc(space->cpu),data,mem_mask);
23462352         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");
23502353      }
23512354   }
2355   timer_set( space->machine, attotime_zero, NULL, 0, megadriv_z80_run_state );
23522356}
23532357
23542358static READ8_HANDLER( z80_read_68k_banked_data )
r4789r4790
59735977   if (cputag_get_cpu(machine, "genesis_snd_z80") != NULL)
59745978   {
59755979      genz80.z80_is_reset = 1;
5976      cputag_set_input_line(machine, "genesis_snd_z80", INPUT_LINE_RESET, ASSERT_LINE);
59775980      genz80.z80_has_bus = 1;
5978      cputag_set_input_line(machine, "genesis_snd_z80", INPUT_LINE_HALT, CLEAR_LINE);
59795981      genz80.z80_bank_addr = 0;
59805982      genesis_scanline_counter = -1;
5983      timer_set( machine, attotime_zero, NULL, 0, megadriv_z80_run_state );
59815984   }
59825985
59835986   megadrive_imode = 0;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team