3 ms·
Many moons ago, my CRT monitor's red gun went kaput. It's easy to imagine what that must have looked like. Anything red appeared as, well, black. Everything els
by thangalin 11y ago
Many moons ago, my CRT monitor's red gun went kaput. It's easy to imagine what that must have looked like. Anything red appeared as, well, black. Everything else was a shade of cyan, blue, or green. The solution? A TSR, like in the article.
The TSR I wrote was simple in comparison: it constantly refreshed the palette. A palette entry with a red value greater than zero had its blue and green values increased accordingly. The red component was then zeroed out.
Necessity is a powerful impetus for spurring creativity in frugal college students.
This looks to be an earlier version, as it doesn't increase the blue and green values, but gives an idea of how it worked:
{$M 1024,0,0 } { 1K stack, no heap }
USES Crt, DOS;
CONST
MAX_COUNT = 384;
READ_PAL = $3C7;
WRIT_PAL = $3C8;
RED = 1;
GRN = 2;
BLU = 3;
VAR
OldIntVec : PROCEDURE;
NoRed : ARRAY[ RED..BLU, 0..255 ] OF BYTE;
Count : INTEGER;
Colour : BYTE;
PROCEDURE ReadPalette;
Begin
FOR Colour := 0 TO 255 DO
Begin
Port[ $3C7 ] := Colour;
NoRed[ RED, Colour ] := Port[ $3C9 ];
NoRed[ GRN, Colour ] := Port[ $3C9 ];
NoRed[ BLU, Colour ] := Port[ $3C9 ];
End;
End;
PROCEDURE ChngPalette;
Begin
FOR Colour := 0 TO 255 DO
IF NoRed[ RED, Colour ] <> 0 THEN
NoRed[ RED, Colour ] := 0;
End;
PROCEDURE WritePalette;
Begin
FOR Colour := 0 TO 255 DO
Begin
Port[ $3C8 ] := Colour;
Port[ $3C9 ] := NoRed[ RED, Colour ];
Port[ $3C9 ] := NoRed[ GRN, Colour ];
Port[ $3C9 ] := NoRed[ BLU, Colour ];
End;
End;
{$F+}
PROCEDURE NewTimer; INTERRUPT;
Begin
InLine( $9C ); { PUSHF -- Push flags }
OldIntVec;
IF Count = MAX_COUNT THEN
Begin
Count := 0;
ReadPalette;
ChngPalette;
WritePalette;
End
ELSE
INC( Count );
End;
{$F-}
BEGIN
Count := MAX_COUNT;
GetIntVec( $1C, @OldIntVec );
SetIntVec( $1C, Addr( NewTimer ) );
Keep( 0 );
END.
- threeio 11y agoYour TurboPascal program just gave me flashbacks to a different time. Thanks.
- white-flame 11y agoUsually if one color goes away it's the connector or cable that failed. But in all the VGA cards I had, updating the palette caused a little bit of snow to appear onscreen. Didn't you get the same?
- thangalin 11y agoI don't recall any snow, but my memories of that old monitor from over two decades ago are foggy.
- bananaboy 11y agoThis might have been because your VGA card didn't use dual ported RAM. I don't think all cards used it since it was more expensive. The safest way to ensure you don't get snow across a wide variety of cards is to wait for the vertical retrace period before updating the palette registers. This way you update while the CRT beam is returning to the top of the screen, instead of while it is drawing in some random part of the screen and potentially reading from the palette while you are in the middle of updating it. Also it's possible that the vertical retrace period isn't long enough to update the entire palette (i.e. you're still updating it and vertical retrace has finished, and the video card has already started redrawing the screen). This kind of depends on a number of factors - VLB/ISA/CPU speed/video card speed. You can work around it by updating smaller sections of the palette at a time (e.g. 32 colours at a time).
- phaedrus 11y agoWhen I was a kid my family got a big, ancient second hand TV that had individual "cards" for the R G and B components. One day a diode on the red card blew out. I soldered in a replacement and the replacement diode lasted a couple minutes before also blowing out with a "bang!" Obviously a short somewhere else, but I didn't feel like troubleshooting it. What to do? Well these 3 cards all look pretty similar, I wonder what would happen if I swapped slots? Well, turns out it works! Just whatever color channel the bad card was in would go out. To get a "full" range of colors I swapped the red and green cards so that we'd have red and blue and it would be the green that was out. The result was surprisingly decent; you could tell something was "off" about the colors but not bad. However, after watching TV for a couple hours, when you looked away the real world would appear green!!
- Houshalter 11y agoWhy green though. Green is actually the color human eyes are most sensitive too. Blue is the color we see the worst, and usually given extra compression by image compression algorithms.
- rahimnathwani 11y agoMaybe because it's in the middle of the visible spectrum?
- FullyFunctional 11y agoThat is awesome. I can't believe how simple and straight forward that is. I never know you could write TSRs in Turbo Pascal. Imagine for a second pulling off a similar trick today on, let's say, a Mac. Plain hopeless.