<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.mamedev.org/index.php?action=history&amp;feed=atom&amp;title=Timers_and_timing</id>
	<title>Timers and timing - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.mamedev.org/index.php?action=history&amp;feed=atom&amp;title=Timers_and_timing"/>
	<link rel="alternate" type="text/html" href="https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;action=history"/>
	<updated>2026-04-04T11:51:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=9583&amp;oldid=prev</id>
		<title>Arekkusu: Clarify &quot;immediately&quot; per Vas Crabb&#039;s explanation: https://forums.bannister.org/ubbthreads.php?ubb=showflat&amp;Number=124846#Post124846</title>
		<link rel="alternate" type="text/html" href="https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=9583&amp;oldid=prev"/>
		<updated>2025-09-28T17:41:50Z</updated>

		<summary type="html">&lt;p&gt;Clarify &amp;quot;immediately&amp;quot; per Vas Crabb&amp;#039;s explanation: https://forums.bannister.org/ubbthreads.php?ubb=showflat&amp;amp;Number=124846#Post124846&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:41, 28 September 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l47&quot;&gt;Line 47:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 47:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;attotime_never&amp;#039;&amp;#039;&amp;#039; is a constant for infinity, or as close to it as MAME can get.  If you use it as a timer&amp;#039;s time value the timer will never go off.  This is useful for when you&amp;#039;re emulating a hardware timer and it&amp;#039;s disabled.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;attotime_never&amp;#039;&amp;#039;&amp;#039; is a constant for infinity, or as close to it as MAME can get.  If you use it as a timer&amp;#039;s time value the timer will never go off.  This is useful for when you&amp;#039;re emulating a hardware timer and it&amp;#039;s disabled.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&#039;&#039;&#039;attotime_zero&#039;&#039;&#039; is a constant for zero time.  If you use this as a timer value the callback will occur immediately.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&#039;&#039;&#039;attotime_zero&#039;&#039;&#039; is a constant for zero time.  If you use this as a timer value the callback will occur immediately &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;(subject to [https://wiki.mamedev.org/index.php?title=CPU_Scheduling_in_MAME round-robin scheduling])&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following conversion macros are also available:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following conversion macros are also available:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Arekkusu</name></author>
	</entry>
	<entry>
		<id>https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=4399&amp;oldid=prev</id>
		<title>Stiletto at 03:25, 25 November 2014</title>
		<link rel="alternate" type="text/html" href="https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=4399&amp;oldid=prev"/>
		<updated>2014-11-25T03:25:28Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 05:25, 25 November 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l65&quot;&gt;Line 65:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 65:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;These work similarly to ATTOTIME_IN_SEC but work in terms of milliseconds, microseconds, and nanoseconds.  They are rarely used, obviously.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;These work similarly to ATTOTIME_IN_SEC but work in terms of milliseconds, microseconds, and nanoseconds.  They are rarely used, obviously.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Math operations on attotime values are available; refer to the [&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;https&lt;/del&gt;://github.com/mamedev/mame/blob/master/src/emu/attotime.h attotime.h] file for more information.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Math operations on attotime values are available; refer to the [&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;http&lt;/ins&gt;://github.com/mamedev/mame/blob/master/src/emu/attotime.h attotime.h] file for more information.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Stiletto</name></author>
	</entry>
	<entry>
		<id>https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=4390&amp;oldid=prev</id>
		<title>Stiletto at 03:00, 25 November 2014</title>
		<link rel="alternate" type="text/html" href="https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=4390&amp;oldid=prev"/>
		<updated>2014-11-25T03:00:45Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 05:00, 25 November 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l65&quot;&gt;Line 65:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 65:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;These work similarly to ATTOTIME_IN_SEC but work in terms of milliseconds, microseconds, and nanoseconds.  They are rarely used, obviously.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;These work similarly to ATTOTIME_IN_SEC but work in terms of milliseconds, microseconds, and nanoseconds.  They are rarely used, obviously.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Math operations on attotime values are available; refer to the [&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;http&lt;/del&gt;://mamedev&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.org&lt;/del&gt;/&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;source&lt;/del&gt;/src/emu/attotime.h&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.html &lt;/del&gt;attotime.h] file for more information.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Math operations on attotime values are available; refer to the [&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;https&lt;/ins&gt;:/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;/github.com&lt;/ins&gt;/mamedev/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;mame/blob/master&lt;/ins&gt;/src/emu/attotime.h attotime.h] file for more information.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Stiletto</name></author>
	</entry>
	<entry>
		<id>https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=2035&amp;oldid=prev</id>
		<title>Rbelmont: /* Creating a timer */</title>
		<link rel="alternate" type="text/html" href="https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=2035&amp;oldid=prev"/>
		<updated>2009-08-19T05:55:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Creating a timer&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:55, 19 August 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l18&quot;&gt;Line 18:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  TIMER_CALLBACK( my_timer_callback )&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  TIMER_CALLBACK( my_timer_callback )&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; {&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; }&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;reference_pointer&amp;#039;&amp;#039;&amp;#039; is any value you want that you can fit into a pointer (beware of 32/64 bit issues here!).  It is passed to your callback as a void * named &amp;#039;&amp;#039;&amp;#039;ptr&amp;#039;&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;reference_pointer&amp;#039;&amp;#039;&amp;#039; is any value you want that you can fit into a pointer (beware of 32/64 bit issues here!).  It is passed to your callback as a void * named &amp;#039;&amp;#039;&amp;#039;ptr&amp;#039;&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Rbelmont</name></author>
	</entry>
	<entry>
		<id>https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=2034&amp;oldid=prev</id>
		<title>Rbelmont: /* Creating a timer */</title>
		<link rel="alternate" type="text/html" href="https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=2034&amp;oldid=prev"/>
		<updated>2009-08-19T05:45:16Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Creating a timer&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:45, 19 August 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l13&quot;&gt;Line 13:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  my_timer = timer_alloc(machine, callback, reference_pointer);&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  my_timer = timer_alloc(machine, callback, reference_pointer);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&#039;&#039;&#039;machine&#039;&#039;&#039; is the current machine pointer &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;- you &lt;/del&gt;should be calling timer_alloc in either your MACHINE_INIT(), DRIVER_INIT(), or DEVICE_INIT()/CPU_INIT() functions, all of which have the current machine pointer available.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&#039;&#039;&#039;machine&#039;&#039;&#039; is the current machine pointer&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.  You generally &lt;/ins&gt;should be calling timer_alloc in either your MACHINE_INIT(), DRIVER_INIT(), or DEVICE_INIT()/CPU_INIT() functions, all of which have the current machine pointer available.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;callback&amp;#039;&amp;#039;&amp;#039; is your function that is called when the timer expires.  It&amp;#039;s of this form:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;callback&amp;#039;&amp;#039;&amp;#039; is your function that is called when the timer expires.  It&amp;#039;s of this form:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Rbelmont</name></author>
	</entry>
	<entry>
		<id>https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=2033&amp;oldid=prev</id>
		<title>Rbelmont: /* About those time parameters */</title>
		<link rel="alternate" type="text/html" href="https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=2033&amp;oldid=prev"/>
		<updated>2009-08-19T05:43:53Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;About those time parameters&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:43, 19 August 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l55&quot;&gt;Line 55:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 55:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ATTOTIME_IN_SEC(x)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ATTOTIME_IN_SEC(x)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This creates an attotime for a timer which &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;first &lt;/del&gt;every x seconds.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This creates an attotime for a timer which &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;fires &lt;/ins&gt;every x seconds.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ATTOTIME_IN_MSEC(x)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ATTOTIME_IN_MSEC(x)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Rbelmont</name></author>
	</entry>
	<entry>
		<id>https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=2032&amp;oldid=prev</id>
		<title>Rbelmont: New page: &#039;&#039;&#039;Timers&#039;&#039;&#039; in MAME are objects which can call you back after a very precise amount of emulated time has passed.  You can use them in your drivers and devices to emulate hardware timers o...</title>
		<link rel="alternate" type="text/html" href="https://wiki.mamedev.org/index.php?title=Timers_and_timing&amp;diff=2032&amp;oldid=prev"/>
		<updated>2009-08-19T05:42:43Z</updated>

		<summary type="html">&lt;p&gt;New page: &amp;#039;&amp;#039;&amp;#039;Timers&amp;#039;&amp;#039;&amp;#039; in MAME are objects which can call you back after a very precise amount of emulated time has passed.  You can use them in your drivers and devices to emulate hardware timers o...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Timers&amp;#039;&amp;#039;&amp;#039; in MAME are objects which can call you back after a very precise amount of emulated time has passed.  You can use them in your drivers and devices to emulate hardware timers or do other kinds of periodic tasks.&lt;br /&gt;
&lt;br /&gt;
== The basics ==&lt;br /&gt;
&lt;br /&gt;
=== Creating a timer ===&lt;br /&gt;
&lt;br /&gt;
Each timer is an object which you refer to by an opaque pointer, like many other things in MAME.  For timers, they are of type &amp;quot;emu_timer&amp;quot;, like this:&lt;br /&gt;
&lt;br /&gt;
 emu_timer *my_timer;&lt;br /&gt;
&lt;br /&gt;
To instantiate a timer, you call &amp;#039;&amp;#039;&amp;#039;timer_alloc&amp;#039;&amp;#039;&amp;#039;().&lt;br /&gt;
&lt;br /&gt;
 my_timer = timer_alloc(machine, callback, reference_pointer);&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;machine&amp;#039;&amp;#039;&amp;#039; is the current machine pointer - you should be calling timer_alloc in either your MACHINE_INIT(), DRIVER_INIT(), or DEVICE_INIT()/CPU_INIT() functions, all of which have the current machine pointer available.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;callback&amp;#039;&amp;#039;&amp;#039; is your function that is called when the timer expires.  It&amp;#039;s of this form:&lt;br /&gt;
&lt;br /&gt;
 TIMER_CALLBACK( my_timer_callback )&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;reference_pointer&amp;#039;&amp;#039;&amp;#039; is any value you want that you can fit into a pointer (beware of 32/64 bit issues here!).  It is passed to your callback as a void * named &amp;#039;&amp;#039;&amp;#039;ptr&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Your callback also gets a pointer to the current machine named &amp;#039;&amp;#039;&amp;#039;machine&amp;#039;&amp;#039;&amp;#039; and one more parameter we will discuss a little later.&lt;br /&gt;
&lt;br /&gt;
=== Arming a timer ===&lt;br /&gt;
&lt;br /&gt;
Timers can either be one-shot or periodic.  One-shot timers fire once and then never again.  Periodic timers automatically start over again after they fire and will keep going off until you stop them.  You can change a timer&amp;#039;s &amp;quot;mode&amp;quot; on the fly if you wish - each new arm call makes the timer mode behave as specified.&lt;br /&gt;
&lt;br /&gt;
This is how you arm a timer for one-shot operation:&lt;br /&gt;
&lt;br /&gt;
 timer_adjust_oneshot(my_timer, time_to_fire, reference_integer);&lt;br /&gt;
&lt;br /&gt;
my_timer is the emu_timer object pointer you allocated, time_to_fire is the amount of time from the current point in the emulation when the timer should fire, and reference_integer is a number for your own use which is passed to your callback as an int named &amp;#039;&amp;#039;&amp;#039;param&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Here&amp;#039;s the equivalent for periodic:&lt;br /&gt;
&lt;br /&gt;
 timer_adjust_periodic(my_timer, time_to_delay, reference_integer, time_to_fire);&lt;br /&gt;
&lt;br /&gt;
This is quite similar, but it has two time parameters.  The first (&amp;#039;&amp;#039;&amp;#039;time_to_delay&amp;#039;&amp;#039;&amp;#039;) is an optional amount of time to wait before beginning our periodic operation.  The &amp;#039;&amp;#039;&amp;#039;time_to_fire&amp;#039;&amp;#039;&amp;#039; parameter gives the period of the timer.&lt;br /&gt;
&lt;br /&gt;
=== About those time parameters ===&lt;br /&gt;
&lt;br /&gt;
Time in MAME is in terms of &amp;quot;attotime&amp;quot;, a high-precision 96 bit fixed point representation accurate to 1 attosecond.  Fortunately a variety of helpers are provided in case you don&amp;#039;t speak attoseconds:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;attotime_never&amp;#039;&amp;#039;&amp;#039; is a constant for infinity, or as close to it as MAME can get.  If you use it as a timer&amp;#039;s time value the timer will never go off.  This is useful for when you&amp;#039;re emulating a hardware timer and it&amp;#039;s disabled.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;attotime_zero&amp;#039;&amp;#039;&amp;#039; is a constant for zero time.  If you use this as a timer value the callback will occur immediately.&lt;br /&gt;
&lt;br /&gt;
The following conversion macros are also available:&lt;br /&gt;
&lt;br /&gt;
 ATTOTIME_IN_HZ(x)&lt;br /&gt;
&lt;br /&gt;
This creates an attotime for a timer which fires x number of times per second.&lt;br /&gt;
&lt;br /&gt;
 ATTOTIME_IN_SEC(x)&lt;br /&gt;
&lt;br /&gt;
This creates an attotime for a timer which first every x seconds.&lt;br /&gt;
 &lt;br /&gt;
 ATTOTIME_IN_MSEC(x)&lt;br /&gt;
 ATTOTIME_IN_USEC(x)&lt;br /&gt;
 ATTOTIME_IN_NSEC(x)&lt;br /&gt;
&lt;br /&gt;
These work similarly to ATTOTIME_IN_SEC but work in terms of milliseconds, microseconds, and nanoseconds.  They are rarely used, obviously.&lt;br /&gt;
&lt;br /&gt;
Math operations on attotime values are available; refer to the [http://mamedev.org/source/src/emu/attotime.h.html attotime.h] file for more information.&lt;/div&gt;</summary>
		<author><name>Rbelmont</name></author>
	</entry>
</feed>