First post, by Scali
Over the years, I've heard various stories on the vertical retrace interrupt on EGA/VGA cards, and how this may or may not be supported, is broken, or whatever...
So I want to put this myth to bed and find out what's what.
To begin at the beginning... IBM first implemented a vertical retrace interrupt on the PCjr in 1984. This is implemented on IRQ5. The interrupt is always enabled on the video chip, but is masked on the 8259A PIT by default.
Later that year, IBM introduced EGA. It also has a vertical retrace interrupt, but it works differently. It is implemented on IRQ2, but it is not enabled by default.
EGA has an extended/enhanced version of the 6845 CRTC. The IRQ control is implemented in bits 4 and 5 of register 11h (vertical retrace end) of the 6845, which is on port 3D4h.
Bit 5 is set by default, which disables(!) the IRQ. Set it to 0 to enable the IRQ.
Bit 4 is used to acknowledge the interrupt. When an interrupt occurs, you first write a 0 to bit 4 to clear the interrupt, then you write a 1 again, so a new interrupt can be triggered.
See the IBM EGA manual at page 72 for the description: http://minuszerodegrees.net/oa/OA%20-%20IBM%2 … s%20Adapter.pdf
While I have never found the original VGA manual, I did find the IBM VGA/XGA manual from 1992, which fully documents VGA as well: http://mcamafia.de/pdf/ibm_vgaxga_trm2.pdf
And if you look at page 2-69, it documents this functionality in the exact same way as EGA. So this proves that VGA/XGA are fully backwards compatible with the vertical retrace interrupt of EGA.
However... if you run DOSBox, the IRQ only works if you set machine=ega. Why is that?
Also, if you check OSDev.org, they do not document these bits and the functionality at all: https://wiki.osdev.org/VGA_Hardware#Registers
The same goes for osdever.net: http://www.osdever.net/FreeVGA/vga/crtcreg.htm#11
This seems to be revisionist history...
So, I decided to make a little test-program: https://www.dropbox.com/s/bzobfyhmppin435/vretirq.zip?dl=0
It basically enables the vertical retrace IRQ, and installs a handler that increments a counter every time it is triggered.
The program constantly prints the value of this counter in the top left corner of the screen. So you can easily verify whether it works or not: if it works, it should increment at the refresh rate of the screen (generally 60 or 70 Hz).
The following keys are supported:
ESC - exit the program
1 - switch to 80x25 textmode (mode 03h)
2 - switch to 320x200x16 mode (EGA mode 0Dh)
3 - switch to 320x200x256 mode (VGA mode 13h)
I tested it on my 486 with Diamond SpeedStar PRO VLB, and as expected, the counter counts up in all three modes.
So I would like everyone with an EGA, VGA, SVGA or XGA system to run this program, and report their video card and whether or not the counter counted up.