/* * colours.c * * Display all combinations of background and foreground colours, excluding * the blinking ones. There are 8 background and 16 foreground colours, * making a total of 128. Eight of these are "invisible" (the foreground is * the same as the background), leaving 120 colour combinations. Some of these * are hard to see (particularly numbers 35 and 50), so there are fewer than * 118 "usable" colour combinations. * * Jason Hood, 25 August, 1997. * Public Domain. * * 980822: use a parameter to do the blinking colours (or bright background). * * 031014, v1.00: * test for redirection. */ #include #include #ifdef __DJGPP__ #include #else #include #endif void help( void ) { puts( "Colours by Jason Hood .\n" "Version 1.00 (14 October, 2003). Public Domain.\n" "http://misc.adoxa.cjb.net/\n" "\n" "Display the text-mode colours with their decimal value.\n" "Use any parameter to display the blinking/bright background colours." ); } int main( int argc, char* argv[] ) { int x, y, a, b; if (!isatty( 1 ) || (argc > 1 && argv[1][0] == '/' && argv[1][1] == '?')) { help(); return 0; } b = (argc > 1) << 7; cputs( "\r\n" ); for (y = 0; y < 16; ++y) // Foreground colours down the screen { for (x = 0; x < 8; ++x) // Background colours across the screen { a = (x << 4) | y | b; // Create the attribute byte textattr( a ); cprintf( " %03d ", a ); // Use the colour number as a test normvideo(); cputs( " " ); } cputs( "\r\n" ); } return 0; }