VOGONS


The myth of the vertical retrace interrupt on EGA/VGA

Topic actions

Reply 60 of 81, by Scali

User metadata
Rank l33t
Rank
l33t
SirNickity wrote:

Results are mixed enough that you can't count on it being supported, so it wouldn't make much sense to write software that relies on it.

That is the takeaway.
Until I wrote these experimental tools and had people run them on a wide variety of hardware, I had no idea of how broad the support was for this feature.
Now we know that it is indeed not something you can generally count on. I mean, if it was say one in 20 video cards that wouldn't support it, especially if those would be the cheap brands like Trident or Realtek, I could justify using it.
But it seems that even many popular and high-end cards don't support it (or the chips do, but it's not connected on the PCB).

The only thing that's still missing is the results of a real IBM PS/2.
I mean, with 8088 MPH, our justification was that at least all our code worked perfectly on any true blue IBM (5150, 5155 and 5160).
If this feature works relibably on a PS/2, then at least I could create some kind of '8088 MPH' for the PS/2, and use this as one of its defining features.

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/

Reply 61 of 81, by Error 0x7CF

User metadata
Rank Member
Rank
Member

I could run it on my IBM PS/1 Model 2011 sometime Friday if you'd like. I'm pretty sure it's VGA and not MCGA.

What I can tell you right now is it doesn't generate interrupts on my Thinkpad 755CS.

Old precedes antique.

Reply 62 of 81, by Error 0x7CF

User metadata
Rank Member
Rank
Member

Zero IRQs out of my PS/1. Then again, it was a value machine so it may not be connected for similar reasoning as IBM's ISA card.

Old precedes antique.

Reply 63 of 81, by Scali

User metadata
Rank l33t
Rank
l33t
Error 0x7CF wrote:

Zero IRQs out of my PS/1. Then again, it was a value machine so it may not be connected for similar reasoning as IBM's ISA card.

Thanks for testing, and yes, perhaps you're right.
I suppose the most interesting test would be a true PS/2, ideally the first model to ever introduce VGA (a model 30, 50, 60 or 80 apparently).

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/

Reply 64 of 81, by SirNickity

User metadata
Rank Oldbie
Rank
Oldbie

I just won an auction for a Model 30 286. I'll give it a try when I can. Will probably have to wait a couple weeks for shipping, cleaning, and PSU recapping.

Reply 66 of 81, by elianda

User metadata
Rank l33t
Rank
l33t

The only thing that's still missing is the results of a real IBM PS/2.

Done

I have tested it on my IBM Model 80 8580 and it shows:
IRQs: 0

Retronn.de - Vintage Hardware Gallery, Drivers, Guides, Videos. Now with file search
Youtube Channel
FTP Server - Driver Archive and more
DVI2PCIe alignment and 2D image quality measurement tool

Reply 67 of 81, by Scali

User metadata
Rank l33t
Rank
l33t
elianda wrote:

Done

I have tested it on my IBM Model 80 8580 and it shows:
IRQs: 0

Okay, now it REALLY gets interesting!
Did IBM deliberately disconnect the IRQ line? Or is there some kind of jumper or BIOS configuration option or such to enable it?

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/

Reply 68 of 81, by SirNickity

User metadata
Rank Oldbie
Rank
Oldbie

Just got my Model 30 286 and finished the PSU recap. Hard drive is failing (shocking...), but the floppy drive works fine. I'll give this a try as well.

Reply 69 of 81, by canthearu

User metadata
Rank Oldbie
Rank
Oldbie

I have one of these cards.

https://computer-retro.de/Bilder/Grafikkarten … Taiwan-1991.jpg

IRQ2 is not actually connected to the trident chip, but the pin on the ISA connector is routed to the top, along with the IRQ pin from the trident. The traces end at 2 separated via's next to the top middle jumper. So IRQ2 must have been thought of during the design of this board, but decided fairly late on they weren't going to connect it and just broke the trace into 2 parts.

Putting a tiny jumper between the 2 vias reconnects IRQ2 to the trident chip and suddenly IRQs work again.

Reply 70 of 81, by SirNickity

User metadata
Rank Oldbie
Rank
Oldbie

So I tried this on my PS/2 Model 30 286, with onboard VGA. By default, no interrupts. But, I couldn't remember if there were any CLI switches, so I ran it as vretirq /? and, while it didn't show a help screen, it did start counting interrupts and the white bar scrolled up screen about at a rate of about one roll from bottom to top per second. Re-running without the switch went back to 0 interrupts. The switch brought it back. Not sure what to make of that, but hope it helps.

Reply 71 of 81, by mills26

User metadata
Rank Newbie
Rank
Newbie

I'm interested in this to use it in a demo, is there any source code?. I tried to add the interrupt using online docs, but it did not work 🙁.

Thanks.

Reply 72 of 81, by AlexZ

User metadata
Rank Oldbie
Rank
Oldbie

It sounds to me like with the advent of VGA vertical retrace interrupt ceased to be a useful feature and assigning IRQ for VGA card was considered unnecessary when most of the time it would be unused. There was no need to have it enabled by default and as support for it was inconsistent it ended up not being used.

Pentium III 900E,ECS P6BXT-A+,384MB,GeForce FX 5600, Voodoo 2,Yamaha SM718
Athlon 64 3400+,Gigabyte GA-K8NE,2GB,GeForce GTX 275,Audigy 2 ZS
Phenom II X4 955,Gigabyte GA-MA770-UD3,8GB,GeForce GTX 780
Vishera FX-8370,Asus 990FX,32GB,GeForce GTX 980 Ti

Reply 73 of 81, by xorlof

User metadata
Rank Newbie
Rank
Newbie

Necroing this thread, but if you're still interested in some PS/2 testing, I have an MCGA Model 25 and a VGA Model 25 that I could dig out and test on. I'd expect the VGA to have a similar result to the Model 30 VGA mentioned above, but I guess it couldn't hurt to get confirmation on the behavior...again, if you're still interested. I did try your utility with the most recent dosbox-x release in its default config and the counter remains at 0.

Reply 74 of 81, by keenmaster486

User metadata
Rank l33t
Rank
l33t

Sorry for the necro but I'm doing some work on this in the game engine I'm writing right now.

Is the vertical retrace interrupt not intended as a vblank detection method? I implemented it as such, but testing in DOSBox with machine=ega shows that although the interrupt is firing at 60Hz as it should, updating the display start offset and pel pan registers in the interrupt is causing significant stuttering, as though I were updating them during active display time.

Is there something I'm missing, or is DOSBox's implementation just wrong?

I have real hardware I can test this with but I have to drag it out of storage. Asking here in case someone already knows.

World's foremost 486 enjoyer.

Reply 75 of 81, by keenmaster486

User metadata
Rank l33t
Rank
l33t

Weirdly, in DOSBox, the palette changes in Scali's test program don't seem to take effect properly. The whole screen is white, despite the counter seeming to increment at the correct rate.

In MartyPC it works for a while and then stops (although you can see in the debug window that the interrupts are in fact still firing and at the correct rate), and in text mode it fires intermittently.

The code I wrote installs a test handler and checks whether it's firing. If so, it then installs the real handler, which updates display start and pel pan. It tries this on IRQ2 first and then on IRQ9. In DOSBox it installs at IRQ2 and acts as though it's firing at random times, not during vblank. In MartyPC it fails entirely - does not fire at all. Weird.

World's foremost 486 enjoyer.

Reply 76 of 81, by jal

User metadata
Rank Oldbie
Rank
Oldbie

Well, there's a MartyPC thread on this board, you could post your results there. In my experience the MartyPC author is quick to respond.

Reply 77 of 81, by clb

User metadata
Rank Oldbie
Rank
Oldbie
keenmaster486 wrote on 2026-02-25, 07:36:

Is the vertical retrace interrupt not intended as a vblank detection method? I implemented it as such, but testing in DOSBox with machine=ega shows that although the interrupt is firing at 60Hz as it should, updating the display start offset and pel pan registers in the interrupt is causing significant stuttering, as though I were updating them during active display time.

The vertical retrace interrupt is a vsync detection method, not a vblank detection method. It should work out for that quite well - on EGA/VGA cards that support it.

There is a vertical front porch (VFP) area that precedes the vertical sync area. This vertical front porch is a couple of scanlines long, and only after that the vsync line is activated.

The vsync interrupt will fire at the start of the first vsync refresh scanline.

It is wholly expected that if you update Display Start (DS) and Horizontal Offset (HS) registers as response to receiving the vsync interrupt, then on original IBM *VGA* adapter, you will get significant stuttering.

This is because IBM screwed up big time (or, it was an unfortunate limitation of the time). The VGA card latches (i.e. captures == records == reads) the value stored to the DS and HS registers at different times.

-> The Display Start (DS) register is latched at start of vsync. So, when the vsync interrupt fires, you are already too late to update the DS register for the next frame. At this time, the card has already read what DS start value it will use for the next frame.

-> However, the HS register is latched at end of vsync. So, if you set the DS+HS registers while in vsync, then effectively only the HS register change will take effect for the next frame, and the DS register update will take effect only for the frame after the next frame. (when the next vsync will start)

This was a massive hardware screw-up/design oversight from IBM, and is exactly the reason why hardware scrolling is so difficult to implement on DOS. If it weren't for this fact, then hardware scrolling on DOS VGA would have been absolutely superior compared to NES and C64 for example. (neither of which can set arbitrary display start with flexible display scanline stride, like IBM EGA and VGA can) But because of splitting the framebuffer starting address into two separate registers: DS+HS, and screwing their latching behavior design to occur at different times, it became very difficult to do smooth hardware scrolling on the PC.

This was exaggerated by the fact that there was no official VGA hardware standard, or hardware conformance test suites, so many clone manufacturers would accidentally implement different latching semantics for DS and HS (hence the table at Re: Solved(?): Why does Commander Keen 4-6 hardware scrolling glitch on ATI (Mach) PCI video cards being investigated)

If IBM had implemented the latching semantics to occur synchronously, so that DS and HS would be read at the exact same time, then none of this would have ever been a problem, and it would have been dead easy to implement smooth hardware scrolling updates - even without any vsync synchronization at all practically. This would have been the case for example if they had also made the DS register to latch at the *end* of vsync, and not at the start.

--------

Now, all that info is based on my research on the original IBM *VGA* adapter. I believe that IBM EGA adapter behaved identically with respect to all of the above info, i.e. DS register was latched at start of vsync, and HS register was latched at end of vsync. But I have not actually tested that.

The reason I believe that EGA has identical behavior to VGA, is that VGA largely grew as a superset of EGA, and both were implemented with a bunch of discrete IC chips. So coordinating synchronization between the chips that affect the DS and HS at scanout was very much the same. If you want to be 101% sure, it may be worth re-testing. (would be quite the unexpected surprise if this hardware design bug was a regression that occurred only when going from EGA to VGA)

Reply 78 of 81, by jal

User metadata
Rank Oldbie
Rank
Oldbie

Not sure if that really is a big problem, as you could wait for the end of vsync, then update. You could set a timer interrupt to occur just before end, wait for end, reset timer. VGAs didn't have a vsync interrupt anyway, aiui, so not latching at the same time is no biggy.

Reply 79 of 81, by clb

User metadata
Rank Oldbie
Rank
Oldbie
jal wrote on 2026-02-28, 19:20:

Not sure if that really is a big problem, as you could wait for the end of vsync, then update. You could set a timer interrupt to occur just before end, wait for end, reset timer. VGAs didn't have a vsync interrupt anyway, aiui, so not latching at the same time is no biggy.

If your game was double-buffered (i.e. draw to offscreen framebuffer before presenting), then updating DS and HS after the end of vsync would require enough memory to implement triple-buffering, no? And it would cause +one frame extra latency?

(also if you do update after end of vsync, the scrolling will break on ATI, Matrox and Paradise, since their HS latching semantics are to update HS every scanline)