Programmer's Guide to the EGA and VGA Cards

Programmer's Guide to the EGA and VGA Cards

comments:

nerd5code posted on r/osdev1w

If you're coming up through the real-mode/PCBIOS path, your options are VESA (INT 10h, AH=4Fh, AL=subfunction but IIRC 02 sets video mode), traditional video services (INT 10h; AH=0 sets mode), and direct programming of the EGA/VGA legacy hardware. Of course, you could implement your own custom driver or rejigger-kludge an existing one, but that takes more effort and know-how. For the first two, Ralf Brown's Interrupt List (raw files etc.); this includes a list of ports also for the third, but imo a book is better (e.g., this is a good 'un). Or for the third, grab VGATweak.zip—I have a copy here. It includes sample code (DOS C), sample register dumps, and an interactive register-tweaking tool (for DOS/Win). However, once you get outside the stuff that (a.) readily fits into VGA memory, and (b.) has a standard resolution in terms of pels-to-pixels ratio, you real quickly find that all monitors don't sync the same, and some perfectly legal modes will send a venerable CRT into a seizure of relay-clicking and flyback transformer whine—ofc flat panels tend to DPMS blankly at you instead, which is less exciting for the youthfsths. So 400×300, sure, probably yes. 480×360: very likely. 480×600, much less likely, and for anything over 320×200 you're either going to be in a planar mode (which takes Tricks) or stuck dithering away in ≤16 colors (with each change of foreground application causing a repaletting that looks … just atrocious), or both. I'm pretty sure 800×600 is only achievable qua VGA mode by using SuperVGA memory size with nonstandard timings and limiting yourself to 16 colors (planar), so I'd assume 480×600 is kinda in the same bucket. So what I'd do is capture a dump of some text modes— 20×6.25 for 4× text zoom-and-pan, 40×12.5 for 2×, 80×25 so you can reboot or go on real-mode sabbaticals cleanly, plus 80×43 and 80×50 configs for actual use, —and graphics modes— 320×200×256 (INT 10h, AH=0, AL=13h), 320×240×256, 400×300×256, and 480×360×256. These are most likely to work and look good (aim for x:y ratio ≈ 4:3, or, if you want to stretch to fit 16:9ish, something rather wider), and you can use a kernel command-line parameter to pick the mode to boot with, which your video driver uses for init. 320×200×256 is unsatisfying on some fronts, but it's dead easy to use, so I'd start there. If you don't want none of that, set Mode 13h on your way in.

Programmer's Guide to the EGA and VGA Cards | eaves-shop