QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

OUT writes values to register and port hardware addresses.


OUT registerAddress%, value%



Color Port Palette access using OUT

OUT &H3C7, attribute : Set port to read RGB settings for start attribute

[INP](INP) &H3C9, colorIntensity : Reads RGB color intensity settings in order

OUT &H3C8, attribute : Set port to write RGB settings for start attribute

OUT &H3C9, colorIntensity : Writes RGB color intensity settings in order



Reading the default RGB color settings of color attribute 15.

OUT &H3C7, 15      'set color port attribute 15 for a read
red% = INP(&H3C9)
green% = INP(&H3C9)
blue% = INP(&H3C9)
PRINT red%, green%, blue% 

 63       63       63

Changing the color intensity settings of the SCREEN background COLOR 0 to bright white.

OUT &H3C8, 0  'attribute number. 0 for black screen background
OUT &H3C9, 63 'red
OUT &H3C9, 63 'green
OUT &H3C9, 63 'blue 

Explanation: In SCREEN 0 this is one way to make high intensity background colors. [COLOR](COLOR) ,15 is actually grey (7).

Toggling blinking colors in SCREEN beginning with build 20170816/61

OUT &H3C0, &H10  'disables blinking and enables high intensity backgrounds (colors 16-31)
OUT &H3C0, 2 ^ 3 'reenables blinking and disables high intensity backgrounds  (colors 16-31)

Note: In QB64, the recommended practice is to use the _BLINK {ON OFF} statement.

Restoring colors to a bitmap from the Red, Green and Blue BSAVEd indexed array of color values.

 OUT &H3C8, 0 ' set color port for output at attribute 0
 FOR i = 0 TO 47 ' 48 RGB values is (3 * 16) -1 color attributes from 0 in screen 12
   OUT &H3C9, Image%(i) ' changes to next attribute after 3 RGB loops
 PUT(clm, row), Image(48) PSET 

Explanation: The color RGB intensity settings were imported from a file to the Image array using BLOAD. The color attribute advances to the next one every 3 writes using OUT. The color information was indexed to the start of the array. The image is after the color settings at index 48. Index 48 is the GET (graphics statement) image width and 49 is the height.

See Also