-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
The behavior of emu_timer::enable is to unschedule the timer if called with false, and to re-schedule the timer if called with true, albeit with the originally-set expiration time. This means, for example, if the following sequence occurs:
adjust(attotime::from_seconds(1));enable(false);- 5 seconds elapse
enable(true);
The timer will fire instantly, rather than 1 second after the timer is re-enabled.
The following drivers and devices all make calls to emu_timer::enable with a value of either true or 1, and are grouped based on observed behavior:
Unnecessary calls to enable(true) due to an immediately preceding (or following) call to adjust or reset, or due to the timer never being disabled in the first place:
src/devices/bus/ata/atahle.cppsrc/devices/bus/ss50/mp4.cppsrc/devices/bus/ti99/joyport/handset.cppsrc/devices/bus/ti99/joyport/mecmouse.cppsrc/devices/machine/corvushd.cppsrc/mame/bitcorp/gamate.cppsrc/mame/ensoniq/esqpanel.cppsrc/mame/skeleton/gameking.cppsrc/mame/svision/svision.cppsrc/mame/ti/ti85_m.cppsrc/mame/usp/patinho_feio.cppsrc/mame/shared/xbox_nv2a.cppsrc/mame/shared/xbox_pci.cppsrc/mame/shared/xbox_usb.cpp
Devices or drivers which have a periodic timer that can be temporarily suspended, which may result in the timer spuriously firing on re-enable, regardless of periodicity, if a full timer period has elapsed since it was disabled:
src/devices/bus/vip/vp550.cppsrc/devices/imagedev/microdrv.cppsrc/devices/machine/icm7170.cppsrc/devices/machine/mccs1850.cppsrc/devices/machine/rtc4543.cppsrc/devices/machine/upd4992.cppsrc/mame/act/victor9k_fdc.cppsrc/mame/pdp1/pdp1.cpp
Devices or drivers which appear to erroneously assume that a timer, when re-enabled, will have the same remaining duration as when it was disabled:
src/devices/machine/6840ptm.cppsrc/devices/machine/mc68901.cppsrc/devices/machine/upd1990a.cppsrc/mame/aviion/aviion88k.cppsrc/mame/konami/gticlub.cppsrc/mame/konami/hornet.cppsrc/mame/konami/nwk-tr.cppsrc/mame/nintendo/pokemini.cpp
src/devices/machine/am9513.cpp is a special case as the current behavior is correct, but the code itself could be changed for clarity. The case where m_freq_timer_selected[f] is non-zero is meaningless as the timer will have been adjusted (and therefore enabled) immediately prior, and there is no point in adjusting the timer if m_freq_timer_selected[f] is zero as it is never enabled outside of the relevant function.
I'll remove the unnecessary enable calls from the first group myself, and will be trying to fix up the latter two groups of devices and drivers as well. However, I'd feel more comfortable if the relevant owners of the latter two groups would take point, so tagging in @curt-coder, @angelosa, @happppp, @rb6502, @wilbertpol, and @villedevs if any of you want to take a stab at it yourselves. For the drivers and devices in the final group (incorrect assumption of timer suspension), the solution I've implemented for 6840ptm.cpp in my local tree is:
- When disabling a timer, take note of
remaining(), stash it in a member variable, then calladjust(attotime::never)on the timer. - When calling
adjuston the timer with some non-never value, clear the stashed value toattotime::never - When re-enabling a timer, use the stashed value (if the timer is not already running and enabled).