Black border color for better compatibility

Request patches for Keens 4-6.
Post Reply
furan
Posts: 8
Joined: Sun Dec 16, 2007 9:23 am

Black border color for better compatibility

Post by furan »

Hey folks,
I spent some time today trying to figure out what about Keen Galaxy games is not working with my Matrox card. It's the fastest PCI card I have as far as bus read/write so I like to use it in my DOS development machine, but it didn't work with Keen Galaxy games. I had two issues - one was that the palettes were all messed up in the games (see pictures), and the other was that the scrolling was very glitchy, even with the no jerk/svga compatibility options (in fact they made it worse).

I was able to fix the scroll issues using the patches that restore the original shareware 1.0 scroll code from the wiki. The palettes were interesting and another issue entirely. It turns out my Matrox card doesn't handle the contents of the border color/overscan register correctly - it ends up tinting everything on screen. This attribute register doesn't hold a palette entry, but an actual 6 bit hi/lo RGB color value. The same thing happens with my 3dfx Voodoo 3/4/5 cards. I checked Richard Ferraro's book "Programmer's Guide to the EGA and VGA Cards" and he mentions the following: "Normally this color is 0, which is black. Note: Most EGA/VGA implementations do not operate satisfactorily when a color other than black is selected for the border region."

Well, I changed cksrcmod to just initialize the attribute register with 0 and sure enough, it fixed the palette issues there. Changing the border index color to palette index 0 using the B+F10 cheat also fixes the issue.

I don't know if there is a patch for this yet, since it looks like so many are used to using the last palette entry for the border color, but since the border color is a simple attribute register that has its own hi/lo red/green/blue - I'm not sure it has to share an entry with the palette - I think it would be good to have a patch that simply sets the overscan attribute register (11h) to zero.

Pictures:
ImageImage
ImageImage

I confirmed that this fixes color for later 3dfx cards as well.
User avatar
K1n9_Duk3
Posts: 13
Joined: Tue Jan 19, 2021 9:57 pm

Re: Black border color for better compatibility

Post by K1n9_Duk3 »

You can use this patch to change the border color to black as the game starts:

Code: Select all

%ext ck4
%version 1.4

%patch $39E3 $0000w	# black border color (default value is $0003w for dark cyan)

%end
Just keep in mind that the memory manager will temporarily change the border color while it is sorting memory blocks. Once it's done sorting, it will change it back to the previous color, so that shouldn't be much of an issue.

Edit: You might also want to check out this version of the screen update code - it works perfectly in DOSBox and it might also work fine on your Matrox card. Once you release your mod to the public, most people are going to play it in DOSBox, so using a patch that works for your system but might make things worse in DOSBox is not what I would consider a solution for the problem.
furan
Posts: 8
Joined: Sun Dec 16, 2007 9:23 am

Re: Black border color for better compatibility

Post by furan »

I'm suggesting you modify your code to make the border black to make keen compatible with more cards, nothing more.
User avatar
K1n9_Duk3
Posts: 13
Joined: Tue Jan 19, 2021 9:57 pm

Re: Black border color for better compatibility

Post by K1n9_Duk3 »

I would suggest that you do a bit of additional research on this. I remembered having a similar issue with one of my old laptops, so I went ahead and checked if setting the border color to black really did fix that issue. This is what happened:

Upon starting the game, it looked perfectly fine on the internal display (except for the awful scaling that stretches the graphics to the internal display's native 800x600 pixel resolution). No tinting whatsoever.

Then I hooked up one of the monitors on my desk and switched the laptop to use both displays simultaneously. There was some tinting going on, but it was even worse than the simple red tint in your photos. Some rows were darker on that monitor and the dark rows would move along with the graphics as the screen scrolled. I changed the border color to black and some of the tinting was gone, but not the dark rows. With the "base tinting" of the border color gone, I could still see some red tinting on the screen from time to time, depending on what color the leftmost pixels of each row were supposed to have.

The next step was switching to external display only. This got rid of the 800x600 pixel upsacling and the displayed image looked fine. Setting the border color back to cyan brought back the red tinting, but as long as the border color was black, everything worked fine.

I would like to point out that I use the same monitor and VGA cable to playtest Keen mods on other systems and none of my other systems have any problems. Said laptop is the only system that has this tinting problem.

Since I have two VGA-capable monitors on my desk, I thought I might as well check both of them. And guess what: The other monitor didn't have any issues at all. Even at 800x600 all the colors looked perfectly fine no matter what border color I used.


The fact that the system is capable of displaying the image correctly (internal display and second monitor) proves that this tinting is not entirely the video chipset's fault per se. And the fact that the other systems have no problem displaying colored overscan borders on that first monitor means that it's not entirely the monitor's fault either. The main problem appears to be that having a non-black overscan color makes it harder for some (rare) combinations of video card and monitor to sync up and get the correct color information across. The resolution and refresh rate may also have an impact on the color syncing.

It would be interesting to hear if you could get to the same result by trying different monitors (if you have any other VGA-capable monitors), just to verify my hypothesis.


In any case, I agree that setting the border color to black would be the right thing to do when releasing a new Keen mod. A black overscan border can indeed fix minor problems on certain (rare) monitor/graphics card combinations. Since DOSBox doesn't emulate the overscan border (and overscan doesn't seem to exist in modern digital video signals such as DVI and HDMI), most players wouldn't get to see the color anyway, so it'll make no difference to them. And those who have the right hardware (or emulator) and really need the nostalgic feeling of the overscan borders can still activate it via the border color debug option.
User avatar
Malvineous
Posts: 113
Joined: Sat Mar 13, 2004 12:54 am
Location: Brisbane, Australia
Contact:

Re: Black border color for better compatibility

Post by Malvineous »

That's very interesting. A friend of mine had similar problems back in the day but I don't remember the hardware combination they were using. I remember suggesting changing the border colour as they reported seeing no border at all, and eventually we discovered that was the culprit.

If a different monitor fixes the issue, I wonder whether they are doing some sort of noise/blacklevel compensation and the presence of the border colour in the overscan area is causing issues?

IIRC with CGA and EGA the border colour was entirely in the overscan region, however with VGA a dedicated space was assigned for the border so technically it's no longer in the overscan area and shouldn't cause any issues. It almost looks like some cards could be reverting back to the pre-VGA method of setting the border? I suppose if that were true you should still see the border colour though, rather than seeing no border and tinting as shown.

I don't think digital standards like DVI or HDMI are a guarantee though. Most systems I've used don't show the border at all, but some of them do display the text with space around the edge which (after trying to work out why it wasn't displaying full screen) I realised is where the border shows up. I guess it just depends on how the firmware handles those modes.

It would be interesting to get one of those VGA to HDMI converters to see whether that resolves the tinting problem on affected devices, although I believe the cheap ones only go down to 640x480, whereas these graphic modes are 720x400 so may not work with the lower-end converters.
Post Reply