Previous 199869 Revisions Next

r23707 Friday 14th June, 2013 at 11:45:23 UTC by Dirk Best
Allow devices with execute interface to have a clock of zero, they are suspended and restarted on clock change. Note that the device still needs to have a clock before MAME actually starts executing timeslices.
[src/emu]diexec.c diexec.h

trunk/src/emu/diexec.c
r23706r23707
638638
639639void device_execute_interface::interface_clock_changed()
640640{
641   // a clock of zero disables the device
642   if (device().clock() == 0)
643   {
644      suspend(SUSPEND_REASON_CLOCK, true);
645      return;
646   }
647
648   // if we were suspended because we had no clock, enable us now
649   if (suspended(SUSPEND_REASON_CLOCK))
650      resume(SUSPEND_REASON_CLOCK);
651
641652   // recompute cps and spc
642653   m_cycles_per_second = clocks_to_cycles(device().clock());
643654   m_attoseconds_per_cycle = HZ_TO_ATTOSECONDS(m_cycles_per_second);
r23706r23707
693704
694705attoseconds_t device_execute_interface::minimum_quantum() const
695706{
696   // if we don't have that information, compute it
707   // if we don't have a clock, return a huge factor
708   if (device().clock() == 0)
709      return ATTOSECONDS_PER_SECOND - 1;
710
711   // if we don't have the quantum time, compute it
697712   attoseconds_t basetick = m_attoseconds_per_cycle;
698713   if (basetick == 0)
699714      basetick = HZ_TO_ATTOSECONDS(clocks_to_cycles(device().clock()));
r23706r23707
727742      return;
728743
729744   // generate the interrupt callback
730   if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE))
745   if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE | SUSPEND_REASON_CLOCK))
731746   {
732747      if (m_vblank_interrupt_legacy != NULL)
733748         (*m_vblank_interrupt_legacy)(&device());
r23706r23707
750765void device_execute_interface::trigger_periodic_interrupt()
751766{
752767   // bail if there is no routine
753   if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE))
768   if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE | SUSPEND_REASON_CLOCK))
754769   {
755770      if (m_timed_interrupt_legacy != NULL)
756771         (*m_timed_interrupt_legacy)(&device());
trunk/src/emu/diexec.h
r23706r23707
5858const UINT32 SUSPEND_REASON_TRIGGER     = 0x0008;   // waiting for a trigger
5959const UINT32 SUSPEND_REASON_DISABLE     = 0x0010;   // disabled (due to disable flag)
6060const UINT32 SUSPEND_REASON_TIMESLICE   = 0x0020;   // waiting for the next timeslice
61const UINT32 SUSPEND_REASON_CLOCK       = 0x0040;   // currently not clocked
6162const UINT32 SUSPEND_ANY_REASON         = ~0;       // all of the above
6263
6364

Previous 199869 Revisions Next


© 1997-2024 The MAME Team