DECLARE SUB setColor (attr AS INTEGER, r AS INTEGER, g AS INTEGER, b AS INTEGER) DECLARE SUB setPalette () CONST DAC.PELMask = &H3C6 ' DAC (Digital/Analog Converter) PEL Mask Register CONST DAC.WRITE = &H3C8 ' DAC Write Port/DAC State Register CONST DAC.DATA = &H3C9 ' DAC Data Port ' Enter Mode 13 (320x200, 256 colors) SCREEN 13 ' Display the whole color palette FOR y% = 0 TO 15 FOR x% = 0 TO 15 LINE (x% * 10, y% * 10)-STEP(9, 9), x% + (y% * 16), BF NEXT x% NEXT y% ' Wait for user input COLOR 15: LOCATE 3, 25: PRINT "Press a key - 1": SLEEP ' Tweak attributes 254 and 255 to teal and orange setColor 254, 0, 29, 63 setColor 255, 63, 34, 0 ' Wait for user input COLOR 15: LOCATE 3, 25: PRINT "Press a key - 2": SLEEP ' Modify the whole palette setPalette ' {attr} is the color attribute index, must be 0 - 255 ' {r}, {g} and {b} are Red, Green and Blue intensity, must be 0 - 63 SUB setColor (attr AS INTEGER, r AS INTEGER, g AS INTEGER, b AS INTEGER) OUT DAC.PELMask, &HFF ' Mask all registers OUT DAC.WRITE, attr ' Select attribute OUT DAC.DATA, r ' Feed red intensity OUT DAC.DATA, g ' Feed green intensity OUT DAC.DATA, b ' Feed blue intensity END SUB ' fill the whole palette with 64 shades of red, green, blue and grey SUB setPalette OUT DAC.PELMask, &HFF ' Mask all registers OUT DAC.WRITE, 0 ' Select first attribute ' Attributes 0 to 63: red shades FOR i% = 0 TO 63 OUT DAC.DATA, i% OUT DAC.DATA, 0 OUT DAC.DATA, 0 NEXT i% ' Attributes 64 to 127: green shades FOR i% = 0 TO 63 OUT DAC.DATA, 0 OUT DAC.DATA, i% OUT DAC.DATA, 0 NEXT i% ' Attributes 128 to 191: blue shades FOR i% = 0 TO 63 OUT DAC.DATA, 0 OUT DAC.DATA, 0 OUT DAC.DATA, i% NEXT i% ' Attributes 192 to 255: grey shades FOR i% = 0 TO 191 OUT DAC.DATA, i% \ 3 NEXT i% END SUB