Home
Developer Resources
QNX RTOS v4
QNX RTOS v4 Knowledge Base

QNX RTOS v4 Knowledge Base

Foundry27
Foundry27
QNX RTOS v4 project
Resources

QNX RTOS v4 Knowledge Base

Title Setting text colour attributes from code
Ref. No. QNX.000001700
Category(ies) Development
Issue I am using console write, and I would like to have different colours, cursor control and specifically bright backgrounds.  By default, the video card is set for blinking foreground, not bright background.  This is an attribute bit in the mode control register on the VGA card.
How to get these attributes from code?




Solution Here is a sample application, showing the input and output stuff for toggling the hardware display abilities.

#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/console.h>
#include <conio.h>

#define BRIGHT 0
#define BLINK  1

void set_blink_bit(int mode)
{
    unsigned short val;

    inp(0x3da);        // an IN to 0x3da (VGA) clears the 0x3c0 flip flop

    outp(0x3c0,0x10);  // load the control register with the reg num
    val = inp(0x3c1);  // grab the reg num value for later restore
    outp(0x3c1, 0x20); // give control of the register back (set bit 0x20)

    if(mode == BRIGHT)
        val &= ~0x08;  // bit 3 of the 0x10 register toggles blink/bright
    if(mode == BLINK)
        val |= 0x08;  // bit 3 of the 0x10 register toggles blink/bright

    inp(0x3da);        // an IN to 0x3da (VGA) clears the 0x3c0 flip flop
    outp(0x3c0,0x10);  // load the control register with the reg num
    outp(0x3c0, val);

    outp(0x3C0, 0x20); // give control of the register back (set bit 0x20)

    inp(0x3DA);        // clear the flip flop - leave a happy state.

}