VOGONS


First post, by ockiller

User metadata
Rank Newbie
Rank
Newbie

I don't know if this has already been tried, I can't find much information on the topic of making EGA modes work again on Turing+ (it's completely broken from that generation onwards, only VGA and VESA modes remains functional).

The idea that I wanted to try was that a VGA mode 12h (640x480 planar 16 colors) isn't much different from say mode EGA mode 0Dh (320x200 planar 16 colors), so maybe it's possible to trap mode 0Dh, ask for mode 12h instead and tweak it to a 320x200 version. And it works indeed! In fact, modern Geforces seem to just ignore all CGA/EGA mode requests, they are no-op, but it seems that manual mode settings via the VGA registers still mostly works (tested on an Ada Geforce RTX 4060 Ti).

So here is my proof-of-concept (NASM source included), a small TSR that for now traps mode 0Dh only, and reconstruct it as close as I could with my limited knowledge of the VGA registers from mode 12h. It should be possible make such workarounds for other legacy graphics modes like CGA or EGA's 640x350 modes.

I also included a fix attempt at the wrong color palette of these old modes (the green/yellow/cyan tint that exists at least from the Maxwell generation), and it's the result of many failed attempts for which I still don't fully understand. I reproduce this palette bug with my fake mode 0Dh even on DOSbox so here it's only my fault. As I couldn't get any success remapping the EGA palette to the VGA DAC (I suspect some games to overwrite them after setting the graphics mode), I simply set the corresponding DAC colors. Thing is, which DAC indices to fix depend on the game! So, as it only concerns the bright colors (8-15) I just repeat them over the whole DAC range 8-63, and it seems to do the job for all the games I tested, including the Commander Keen series.

In theory this TSR shouldn't have a visible effect on a graphics card with a perfectly sane VGA BIOS, so it could be used on Maxwell+ too to fix the wrong color palette.

Reply 1 of 7, by ockiller

User metadata
Rank Newbie
Rank
Newbie

I implemented the proper color palette behavior. It's the restriction to the 16 CGA colors in 200 lines EGA modes, and the layout of these colors is not obvious. Now I'm confident I'm doing the same thing as good VGA BIOS implementations.

I also added the other EGA color graphics modes. Mode 0Eh (640x200 16 colors) is often utilized by later VGA games as the EGA fallback (notably some Lucas Arts games), with heavy dithering. And mode 10h (640x350 16 colors).

Text modes other than mode 3 are also ignored on Turing+, so 40 column text modes are also broken. For now I added mode 1 (40x25 color text mode), it works with a 3D Tetris game named Block Out, which uses hi res EGA graphics in game but 40x25 text mode menus. So now this game is also fully working with an RTX. 40 column text mode doesn't behave very well in the command line though, I still haven't figured out why.

I don't handle monochrome modes, nor CGA modes. For these, I might make another TSR (CGAFIX?) as to not increase the TSR size for those that don't need them.

Reply 3 of 7, by wbahnassi

User metadata
Rank Oldbie
Rank
Oldbie

Oooh I gotta try this.. I don't mind if the TSR covers all CGA/EGA even if it goes a little larger.. I have space in upper memory to toss it in.. better than having to load two TSRs.

Shame that this stuff should actually exist in the card's BIOS.. but RTX cards have a lot of BIOS issues beyond just ignoring those legacy modes..

I'm wondering also if there is something that can be done to somehow drive the monitor to 4:3 aspect ratio?

Turbo XT 12MHz, EGA, MFM HDD
Intel 386 DX-33, Speedstar 24X, SB 1.5, 1x CD
Intel 486 DX2-66, CL5428 VLB, SBPro 2, 2x CD
IBM BlueLightning 100MHz, CL5428, SB16, 4x CD
Intel Pentium 90, Matrox Millenium 2, SB16, 4x CD
HP Z400, Xeon 3.46GHz, YMF-744, RTX2060

Reply 4 of 7, by wbahnassi

User metadata
Rank Oldbie
Rank
Oldbie

Gave it a try. Prince of Persia EGA looks great. Keen 4 looks great and scrolls great too, except anywhere there is text. Text comes garbled whether in the main menu or in messages during the game. Not sure why is that...

Turbo XT 12MHz, EGA, MFM HDD
Intel 386 DX-33, Speedstar 24X, SB 1.5, 1x CD
Intel 486 DX2-66, CL5428 VLB, SBPro 2, 2x CD
IBM BlueLightning 100MHz, CL5428, SB16, 4x CD
Intel Pentium 90, Matrox Millenium 2, SB16, 4x CD
HP Z400, Xeon 3.46GHz, YMF-744, RTX2060

Reply 5 of 7, by ockiller

User metadata
Rank Newbie
Rank
Newbie

I've found some limitations of faking graphics modes behind the back of the graphics card. Some other vBIOS functions depends implicitly on the current mode, like switching video page (as there is an address calculation that depends on the resolution, bit depth, ...), as done by Cosmo's Cosmic Adventure, so every two frames we get garbled graphics. It can also explain the problems in 40 columns command line, the vBIOS still thinks it has 80 columns of real estate. It will be a significant amount of work to do all the book-keeping and reimplementing all these functions, provided that's possible. I removed all the broken features for now (so you still can't go past Cosmo's Cosmic Adventure EGA detection) not to bloat the TSR with useless code.

Other than that, I added monochrome text modes and a preliminary CGA modes support. Color palette selection is yet another mechanism, via vBIOS functions that are unsurprisingly non functional, so I'll have to reimplement them too, which shouldn't be too hard this time. So for now you will only have the default bright black, cyan, magenta, white palette. And text isn't working at all in CGA graphics modes, I haven't figured out why yet. That's already enough for some CGA games like Prince of Persia. In Alley Cat, when in the menu, the screen is all black, you have to blindly type 'N' (for no joystick), then 'K' (for Kitten difficulty, this game is already so hard...), then any key, and you can play. Unpon exiting (Ctrl+Y), as the game doesn't revert to text mode, you have to blindly enter 'mode 80' or 'cls' to bring back the prompt on screen.

Speaking of reducing the number of TSRs, I integrated the fix of Falcosoft's MSKVBEF7 into it, because I don't see a situation where you wouldn't want it on a modern system.

wbahnassi wrote on Yesterday, 13:25:

I'm wondering also if there is something that can be done to somehow drive the monitor to 4:3 aspect ratio?

I can't have my monitor to display anything with the 4:3 aspect ratio when connected via DisplayPort. With HDMI I have the option to respect the 4:3 aspect ratio for 4:3 or 5:4 resolutions, but modern graphics card seem to scale everything to the screen preferred resolution. It's possible to modify the EDID of the screen to prefer a 4:3 resolution instead, but a safer option that I haven't tested may be this one.

wbahnassi wrote on Yesterday, 17:10:

Gave it a try. Prince of Persia EGA looks great. Keen 4 looks great and scrolls great too, except anywhere there is text. Text comes garbled whether in the main menu or in messages during the game. Not sure why is that...

This I think comes from the fact that it's not possible to read the VGA latches registers directly, since at least the Geforce 6 series. On one hand it's an undocumented VGA feature, but on the other hand it was so ubiquitous that a lot of software relied on it, Commander Keen 4-6, even Windows 9x default VGA driver (there are a lot of artifacts there). So yeah it's a shame, but quite ancient bug, and sadly we can't fix it with real mode code.

Reply 6 of 7, by LSS10999

User metadata
Rank Oldbie
Rank
Oldbie
ockiller wrote on Yesterday, 21:15:
I've found some limitations of faking graphics modes behind the back of the graphics card. Some other vBIOS functions depends im […]
Show full quote

I've found some limitations of faking graphics modes behind the back of the graphics card. Some other vBIOS functions depends implicitly on the current mode, like switching video page (as there is an address calculation that depends on the resolution, bit depth, ...), as done by Cosmo's Cosmic Adventure, so every two frames we get garbled graphics. It can also explain the problems in 40 columns command line, the vBIOS still thinks it has 80 columns of real estate. It will be a significant amount of work to do all the book-keeping and reimplementing all these functions, provided that's possible. I removed all the broken features for now (so you still can't go past Cosmo's Cosmic Adventure EGA detection) not to bloat the TSR with useless code.

Other than that, I added monochrome text modes and a preliminary CGA modes support. Color palette selection is yet another mechanism, via vBIOS functions that are unsurprisingly non functional, so I'll have to reimplement them too, which shouldn't be too hard this time. So for now you will only have the default bright black, cyan, magenta, white palette. And text isn't working at all in CGA graphics modes, I haven't figured out why yet. That's already enough for some CGA games like Prince of Persia. In Alley Cat, when in the menu, the screen is all black, you have to blindly type 'N' (for no joystick), then 'K' (for Kitten difficulty, this game is already so hard...), then any key, and you can play. Unpon exiting (Ctrl+Y), as the game doesn't revert to text mode, you have to blindly enter 'mode 80' or 'cls' to bring back the prompt on screen.

Speaking of reducing the number of TSRs, I integrated the fix of Falcosoft's MSKVBEF7 into it, because I don't see a situation where you wouldn't want it on a modern system.

wbahnassi wrote on Yesterday, 13:25:

I'm wondering also if there is something that can be done to somehow drive the monitor to 4:3 aspect ratio?

I can't have my monitor to display anything with the 4:3 aspect ratio when connected via DisplayPort. With HDMI I have the option to respect the 4:3 aspect ratio for 4:3 or 5:4 resolutions, but modern graphics card seem to scale everything to the screen preferred resolution. It's possible to modify the EDID of the screen to prefer a 4:3 resolution instead, but a safer option that I haven't tested may be this one.

wbahnassi wrote on Yesterday, 17:10:

Gave it a try. Prince of Persia EGA looks great. Keen 4 looks great and scrolls great too, except anywhere there is text. Text comes garbled whether in the main menu or in messages during the game. Not sure why is that...

This I think comes from the fact that it's not possible to read the VGA latches registers directly, since at least the Geforce 6 series. On one hand it's an undocumented VGA feature, but on the other hand it was so ubiquitous that a lot of software relied on it, Commander Keen 4-6, even Windows 9x default VGA driver (there are a lot of artifacts there). So yeah it's a shame, but quite ancient bug, and sadly we can't fix it with real mode code.

I just tested this on my RTX A4000 (Ampere) and it seems to restore legacy EGA/VGA functionality of this card -- VGA/EGA mode works albeit with some graphical glitches, such as flickers when scrolling, as well as some "transparent" colors being rendered incorrectly leading to some distortions in the background. Should note that these graphical glitches are also present on Kepler where EGA/VGA functionality is not broken.

These games I've tested will work with my card after loading your TSR: Bio Menace (EGA), Titus the Fox (VGA). Previously Bio Menace will only give a (hung) black screen, and Titus the Fox would enter a garbled text mode that can be exited via ESC.

Reply 7 of 7, by ockiller

User metadata
Rank Newbie
Rank
Newbie

Cosmo's Cosmic Adventure now works! It was the only game I know that uses the BIOS to flip pages, all other ones set the start address directly. This function still works for VGA modes, so I just reimplemented this function for EGA mode 0Dh (320x200 16 colors) for now. I don't know any game or demo that does page flipping through the BIOS in 640x350 modes (requiring at least a 256 kB adapter, not that common for EGA, and with VGA you can do page flipping in 640x400), which should be the only case where it's still broken.

I also added basic palette handling for CGA modes (warm/cold, intensity), color 0 is always black for now, I don't handle border color nor the special palette 5 (again, I don't have games that uses this). And most importantly, text in CGA graphics mode is still missing! That's the last big inconvenience, other than that we are in a pretty good state IMHO. 😀

LSS10999 wrote on Today, 16:36:

VGA/EGA mode works albeit with some graphical glitches, such as flickers when scrolling, as well as some "transparent" colors being rendered incorrectly leading to some distortions in the background. Should note that these graphical glitches are also present on Kepler where EGA/VGA functionality is not broken.

Thanks for the feedback, I'll take a look at these games, chances that I can do something about it are low, but who knows, it might be instructive.