---
name: "timer_simulate_retrace"
section: "3alleg"
platform: "linux"
package: "liballegro-doc"
version: "2:4.1.15-5"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/timer_simulate_retrace"
---

# timer\_simulate\_retrace(3alleg)

## NAME

timer\_simulate\_retrace

## SYNOPSIS

**#include \<allegro.h\>**

**void timer\_simulate\_retrace(int enable);**

## DESCRIPTION

The DOS timer handler can be used to simulate vertical retrace  interrupts. A retrace interrupt can be extremely useful for implementing  smooth animation, but unfortunately the VGA hardware doesn´t support it.  The EGA did, and some SVGA chipsets do, but not enough, and not in a  sufficiently standardised way, for it to be useful. Allegro works around  this by programming the timer to generate an interrupt when it thinks a  retrace is next likely to occur, and polling the VGA inside the interrupt  handler to make sure it stays in sync with the monitor refresh. This  works quite well in some situations, but there are a lot of caveats:

You can´t use the retrace simulator in SVGA modes. It will work with some chipsets, but not others, and it conflicts with most VESA  implementations. Retrace simulation is only reliable in VGA mode 13h  and mode-X.

Retrace simulation doesn´t work under win95, because win95 returns garbage when I try to read the elapsed time from the PIT. If anyone  knows how I can make this work, please tell me!

Retrace simulation involves a lot of waiting around in the timer handler with interrupts disabled. This will significantly slow down  your entire system, and may also cause static when playing samples on  SB 1.0 cards (because they don´t support auto-initialised DMA: SB 2.0  and above will be fine).

Bearing all those problems in mind, I´d strongly advise against relying on the retrace simulator. If you are coding in mode-X, and don´t care  about your program working under win95, it is great, but it would be a  good idea to give the user an option to disable it.

Retrace simulation must be enabled before you use the triple buffering  functions in a mode-X resolution. It can also be useful for simple  retrace detection, because the polling vsync() function can occasionally  miss retraces if a soundcard or timer interrupt occurs at exactly the  same time as the retrace. When retrace interrupt simulation is enabled,  vsync() will check the retrace\_count variable rather than polling the  VGA, so it won´t miss retraces even if they are masked by other  interrupts.

## SEE ALSO

[**install\_timer**(3alleg)](/install_timer/3alleg.md), [**retrace\_count**(3alleg)](/retrace_count/3alleg.md), [**retrace\_proc**(3alleg)](/retrace_proc/3alleg.md), [**request\_scroll**(3alleg)](/request_scroll/3alleg.md), [**vsync**(3alleg)](/vsync/3alleg.md), [**timer\_can\_simulate\_retrace**(3alleg)](/timer_can_simulate_retrace/3alleg.md), [**timer\_is\_using\_retrace**(3alleg)](/timer_is_using_retrace/3alleg.md), [**enable\_triple\_buffer**(3alleg)](/enable_triple_buffer/3alleg.md), [**ex3buf**(3alleg)](/ex3buf/3alleg.md)
