Skip to content

Instantly share code, notes, and snippets.

Created September 1, 2018 18:26
Show Gist options
  • Save kajott/4698dbe0fd9a5868d95c8259da463d66 to your computer and use it in GitHub Desktop.
Save kajott/4698dbe0fd9a5868d95c8259da463d66 to your computer and use it in GitHub Desktop.
test program to find out whether EGA 200-line mode palette manipulation might be feasible after all
10 SCREEN 0: REM This program makes only sense to be run on EGA cards, not VGA!
20 SCREEN 9: H% = 105: GOSUB 1000: LOCATE 9
30 PRINT "Notice the nice rainbow colors above? That's what you can get by reprogramming"
40 PRINT "the EGA palette. Unfortunately, this only works in 350-line mode."
50 PRINT "Press any key to see what it looks like in 200-line mode."
70 SCREEN 8: H% = 60: GOSUB 1000: LOCATE 9
80 PRINT "Well, that's not nearly as nice as it was in 350-line mode. Turns out, the EGA"
90 PRINT "monitor emulates a CGA monitor in 200-line mode and thus restricts the palette"
100 PRINT "to the 16 CGA colors. Reprogramming the EGA palette can shuffle the CGA colors"
110 PRINT "around, but not create new ones. Bummer."
130 PRINT "But let's try something. The EGA monitor detects the 200-/350-line modes by"
140 PRINT "looking at the sync polarity. What happens if we set the sync polarity of 350-"
150 PRINT "line mode, but keep the timing of 200-line mode? Press a key and we'll see!"
160 PRINT "IMPORTANT: If the image doesn't stabilize after a second or there are strange"
170 PRINT " noises coming from the monitor, TURN IT OFF to prevent damage."
190 PRINT : OUT &H3C2, &H83
200 PRINT "So, did it work? Do we still have a stable image? And if so, do the color bars"
210 PRINT "at the top of the screen now look like a proper rainbow?"
220 PRINT "Please report to <> or @KeyJ_trbl on Twitter!"
230 PRINT "Thank you!"
250 SCREEN 0, 0, 0
999 END
1000 FOR I% = 0 TO 15: LINE (I% * 40, 0)-(I% * 40 + 39, H%), I%, BF: NEXT I%
1010 I% = INP(&H3DA): RESTORE 1040: COLOR 10
1020 FOR I% = 0 TO 15: OUT &H3C0, I%: READ V%: OUT &H3C0, V%: NEXT I%
1030 OUT &H3C0, 32: RETURN
1040 DATA 0,32,4,36,52,38,54,22,18,19,27,11,25,9,41,13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment