• Please review our updated Terms and Rules here

CGA mode 4, Horizontal displayed over EGA/VGA

carlos12

Experienced Member
Joined
May 10, 2020
Messages
183
Location
Madrid, Spain
Hi there!

I'm now messing with the CGA registers. My goal is to achieve horizontal hardware scrolling on CGA 4 color mode without flickering. I achieved to reduce the horizontal displayed on the CGA (emulated, I have no real CGA to play with):

Code:
outp (0x3D4,1);
outp (0x3D5,39);

But this has no effect on EGA or VGA. According to the documentation, that register number has another function on the EGA/VGA.

So my question is: is there an EGA register that sets the horizontal displayed? I looked on the documentation and on Wilton's book and I found vertical displayed but had no luck with the horizontal ones. My idea is to use a detection code to tell if we are using a CGA or an EGA/VGA, so setting the adequate ports for reducing the visible width on each adapter, as I want my code work on as many adapters as possible, not only pure CGAs.

Thank you so much!
 
I correct myself: it has effect on the EGA, albeit slightly different to the CGA. My mistake was trying it only on the VGA thinking that it would behave the same on EGA.

On the EGA it cuts the right end but maintains the lines organization (i.e, the image does not distort, just trims). On the CGA the image distorts completely as, I guess, the number of pixels per line is changed.
 
The good news is that you're going to have a lot of fun playing around with video card registers!

The bad news is that 3D4/3D5 are the I/O ports for the CRTC, and each of the CGA EGA and VGA cards uses a different and somewhat-incompatible CRTC register layout.

If you use the video BIOS to set the modes using INT 10h and restrict yourself to simply read/write the video memory only, then yes the VGA is backwards compatible with the EGA which is backwards compatible with the CGA. But the moment you start poking at registers, the three cards are quite different. (Some older EGA cards had hardware emulation of the CGA registers, because many CGA games will bypass the BIOS and poke at the hardware registers.)

Once you start departing from the standard video modes, you'll find emulators do all sorts of odd things, and your desire to get actual hardware will eventually become overwhelming. :)

Good reference material for CGA, available at minuszerodegrees.net:
- IBM PC Technical Reference Manual for the IBM BIOS source listing (for the INT 10h handler and mode setting code)
- IBM PC Options & Adapters manual for the IBM CGA card register descriptions and schematics

For the EGA, there's the official IBM documentation for the card, but it's not very helpful because most of the functionality is contained inside four IBM proprietary chips. But CHIPS reverse engineered the whole thing and produced the first EGA clone chipset, the CS8240 "Enhanced Graphics CHIPset". Get a copy of the datasheet for that, which documents every single I/O pin of all four chips plus every single register -- the EGA is a bit unusual because the registers are spread out amongst all four chips.

And finally we come to VGA, which has been extensively documented. I really like the Cirrus Logic "CL-GD542X Technical Reference Manual", which again goes into great detail about all of the available registers and modes.
 
Back
Top