FantasyLand on VGA

In 1984, Joel Gould of IBM Cambridge (that is Cambridge, Massachusetts rather than Cambridge, UK) Scientific Center wrote a demo program named FantasyLand. This demo was meant to show off the capabilities of IBM’s brand new Enhanced Graphics Adapter, or EGA.

The demo was strictly a demo and was never sold. A few years ago, the demo resurfaced and perhaps the best way to experience it is PCjs, because PCjs faithfully emulates an EGA card. That last bit is important.

The FantasyLand EGA demo

I’ve attempted to run the FantasyLand demo on a number of VGA cards and in the end concluded that it cannot run properly. Even though the VGA is in general highly backwards compatible with the EGA, the FantasyLand demo exposes a couple of minor points where that’s not the case.

Font Size

The first problem with the FantasyLand demo is actually something that affects EGA systems as well. The FantasyLand demo assumes that the system is using 200-line text modes with 8×8 pixel character box. That is no doubt an accident of history—FantasyLand was written in 1984, before the 350-line capable EGA monitors became available. To use color with an EGA, the only option was a 200-line CGA monitor at the time when FantasyLand was written.

On EGA systems equipped with an Enhanced (i.e. EGA) monitor, it is necessary to flip the switches on the back of the EGA card to the “compatible” setting.

On VGA systems it’s actually easier: The video BIOS function INT 10h/12h with BL=30h can be called to request text modes with 200 lines. The next mode set will establish a CGA compatible text mode with 8×8 characters.

That is enough to get FantasyLand looking mostly right on a VGA system. But only mostly.

Split Screen

The FantasyLand demo makes heavy use of split screen, a new feature IBM introduced with the EGA. But when run on a VGA… there is no split screen at all. The reason for that is interesting.

On the EGA, the line compare field which controls split screen is a 9-bit value. The low 8 bits (i.e. bits 7:0) are in CRTC register CR18 and bit 8 is stored in bit 4 of CR7, the overflow register. That allows the line compare field to represent values in the 0 to 511 range (a necessity since some EGA modes use 350 scan lines).

On the VGA, IBM extended the line compare field; bit 9 is stored in bit 6 of register CR9, which primarily controls the character cell height. Thus the line compare field on the VGA can represent values in the 0 to 1,023 range. Yet software written for the EGA knows nothing about the additional bit.

When the VGA BIOS sets a text mode, the line compare field is set to 1,023 (the maximum value). That is a problem for EGA software, because it will never clear the high bit it doesn’t know about. Even if software written for the EGA tries to set the line compare field to zero, it will in reality still be 512, and no split screen will be in effect.

It’s possible to work around this issue by modifying the mode parameters. All it takes is creating a copy of the mode parameter table plus the video save pointer table, and modifying the BDA to reference the customized pointer table. The parameter table for mode 3 needs just one bit changed; the new-on-VGA bit 6 of register CR9 has to be zeroed so that EGA software can effectively manipulate the line compare field.

And with that change… FantasyLand still does not look right.

Irreconcilable Differences

As it turns out, FantasyLand exposes a subtle hardware incompatibility between EGA and VGA related to split screens.

The line compare field determines the scan line after which the image will be displayed from the start of video memory. That sounds simple enough… except it’s not in those 200-line CGA compatible modes. The thing is that an EGA card attached to either CGA or EGA monitor actually displays 200 scan lines. But the VGA does not; it instead displays 400 scan lines and sets bit 7 of register CR9 to “double scan”, i.e. display each scan line twice.

When FantasyLand initially sets the line compare field to 199, there will be no split screen on an EGA, since 199 is the last displayed scan line. But on a VGA, the screen will be split right in the middle when it shouldn’t be, because the image is in reality composed of 400 scan lines!

ATI Graphics Vantage in VGA mode

In theory, the double scan bit could have influenced the line compare functionality on the VGA. But all the VGA cards I’ve tried agree that it does not.

Do Not Interrupt

There is yet another problem with many VGA cards. FantasyLand uses vertical retrace interrupts to achieve smooth animation, with the split screen nicely sliding up and down. On many VGA cards, vertical retrace interrupts do not work.

I’m not sure of the exact history there. What I know is that for example my Cirrus Logic CL-GD5442 based ISA card could support vertical retrace interrupts, since the Cirrus Logic chip implements them. But the card does not even have the corresponding pin on the ISA slot populated.

Some ISA VGA cards have a jumper that can be used to enable interrupts. This is often disabled by default.

On PCI based VGA cards, it’s extremely unlikely that interrupts would be routed to IRQ9/IRQ2, even if the card did generate interrupts (enough of them do).

The reality is that many if not most VGA cards do not support interrupts—either not at all or not in a manner compatible with IBM EGA/VGA.

Compatibility Fun

I did find one card in my junk pile that can display FantasyLand very well: An ATI Graphics Vantage, an ISA VGA card with a Mach8 accelerator.

In the default VGA mode, the Graphics Vantage has the same problem as other VGA cards—the screen is split in the middle when it shouldn’t be. But the card can be switched to an EGA emulation mode, and then FantasyLand works properly, with interrupts (and hence smooth animation) and all.

ATI Graphics Vantage in EGA emulation mode

My experience is that EGA emulation modes are rare on VGA cards and only found on older models if at all.

At any rate… FantasyLand is a very interesting piece of software, obscure enough that even though it was written at IBM, it’s too much even for IBM’s own VGA and exposes minor incompatibilities with the EGA.

This entry was posted in IBM, PC hardware, PC history, VGA. Bookmark the permalink.

11 Responses to FantasyLand on VGA

  1. Chris M. says:

    Has there been any attempt to run this demo with a VGA card running in 15khz (NTSC) output mode? Most cards including IBM’s support this.

  2. Joshua says:

    “My experience is that EGA emulation modes are rare on VGA cards and only found on older models if at all.”

    Hi there! I know a few cards. List isn’t complete, though.
    They all have mode utilities tzat cover CGA, EGA, Hercules, VGA and text-modes.
    If memory serves, they got VBE 1.2 TSRs afterwards, even.

    – ET4000, ET3000
    – Paradise VGA/WD90Cxx
    – OAK OTI-037c and up
    – Video Seven Vega
    – Trident 8800, 8900

    Best regards

  3. Michal Necasek says:

    I have no idea. How would one go about that? I don’t think the VGA BIOS supports any true 200-line modes.

  4. Michal Necasek says:

    Yes, exactly… these chips are mostly pretty old (Paradise, Video 7) or painfully slow (Trident, OAK). The Tseng is an exception. But once you look at some halfway modern chip like S3, the backward compatibility isn’t even there. And of course IBM never had it either, which gave software developers a good incentive to not write software that only ran on an actual CGA/EGA/Hercules.

    Looking at ATI for example, their mach32 (1992) still advertised CGA/EGA/Hercules register compatibility, but mach64 (1994) no longer did. That tells me by 1994 ATI considered it irrelevant, even though they already had the technology.

    As far as I can tell, new VGA compatible chips developed circa 1990 (S3, Acumos/Cirrus Logic) didn’t even bother. Some chips, like the Matrox Athena, used a combined approach where they didn’t have truly CGA/Hercules compatible registers but supported software trapping (using NMIs) and emulating register access.

    I guess the point is that even in the early 1990s, running CGA/EGA/Hercules specific software on a VGA-compatible system was far from guaranteed, and CGA/EGA/Hercules emulation was likely quite rare on PCI adapters.

  5. Richard Wells says:

    The VGA boards that succeed in running Fantasy Land started off as EGA+ boards which gained a driver disk to add support for the VGA BIOS of the 640×480 modes that EGA+ already supported. Those cards were promoted to VGA cards after adding VGA BIOS to the ROM and having support for the 256 color mode added. Support for hardware specifics of VGA was spotty but EGA support was quite complete. The Wonder+ had very good support for both EGA and VGA but followed the chip sold as both EGA Wonder and VGA Wonder. The same chip in the Wonder+ handled VGA duties in the Graphics Ultra.

    New chip designs not saddled with an EGA+ predecessor stuck close to replicating the IBM VGA design and eschewed hardware compatibility with older graphics standards. Saved money with a smaller chip without needing multiple oscillators while also gaining improved performance and fewer support calls from accidentally being in the wrong mode. ATI put down the changes for the Mach64 to getting rid of the problems caused by the hardware register layout of the older chip designs.

  6. Chris M. says:

    There are TSRs out there that will reprogram the VGA DAC to output true 200 line 15khz video. The one I have is called AdvanceCAB which was originally designed for MAME machine use in arcade cabinets.

  7. MiaM says:

    As a side track, there are also programs that run under Windows that can reprogram a VGA card to use 15kHz modes.

    Back in the days they were great for displaying PC video on a TV having an RGB input (like almost every European TV made since mid 80’s). To connect a VGA output running at 15kHz to a SCART input you need to combine and possibly change polarity of the sync pulses to one negative-active composite sync.

  8. Michal Necasek says:

    Very interesting. I haven’t yet found detailed technical information but it sounds like some of those utilities should work on a standard VGA. Now I wonder if that was something IBM designed in (but never offered as a feature), or if it works more or less by accident as a side effect of backward compatibility with CGA.

  9. Chris M. says:

    The Sega TeraDrive, which is a PS/2 Model 30 combined with a Sega MegaDrive console apparently supports native 15khz output for the PC side out of the box.

  10. Michal Necasek says:

    Doesn’t PS/2 Model 30 have an MCGA (rather than VGA) onboard?

  11. Richard Wells says:

    The Seaga Teradrive has a 286 which suggests the Model 30-286 was the base which has VGA built in. Though looking at the Teradrive pictures, what I think is the VGA chip has a different part number from the 5 VGA chips I have seen listed for other Model 30-286s or the MCA PS/2s.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.