Category : C Source Code
Archive   : SMPDEMO2.ZIP
Filename : VGACOLOR.C
* for C Compilers.
*
* FILE: VGACOLOR.C contains code for the vga color mixing demonstration.
*
* Power Programming Tools for Advanced Interface Design.
* written by: Jim Everingham May 25, 1990
* last Modification: January 23, 1991
*/
#include
#include
#include
#include
#include "smp.h" /* Screen Manager window and menu header file */
#include "smpkey.h" /* Screen Manager keyboard support */
#include "smpdata.h" /* Screen Manager data entry support */
#include "smpmouse.h" /* Screen Manager mouse support */
#include "smpdemo.h" /* text screens and function prototypes */
void makeColors ( void )
{
int i, x, lastX, keyStroke, j, temp;
SMP_HANDLE infoWindow; /* SMP window handle variables */
SMP_HANDLE mainWindow;
SMP_HANDLE colorBarWindow;
mainWindow = backWindow ( ); /* set the window background */
w_def ( infoWindow = w_nexthandle ( ),/* define a window */
3,2, /* upper left hand corner at 3, 2 */
41,12, /* bottom right hand corner at 41,12 */
attr(BLACK,LIGHTGREY), /* inner window color of BLACK on */
/* LIGHTGREY */
attr(BLACK,LIGHTGREY), /* frame color of BLACK on LIGHTGREY */
TRANSHADE(1), /* frame type one single line border */
/* transparent shadow */
EXPAND ); /* opening effect - expands rapidly */
/* put up a window title */
w_title (infoWindow, " Press Keys [Esc] = Exit ",
TOPCENTER, 12, attr(BLACK,LIGHTGREY) );
w_def ( slideWindow = w_nexthandle ( ), /* define a window */
3,12, /* upper left hand corner at 3, 12 */
41,22, /* bottom right hand corner at 41, 22 */
attr(BLACK,LIGHTGREY), /* inner window color of BLACK on L.GREY */
attr(BLACK,LIGHTGREY), /* frame color of BLACK on L.GREY */
TRANSHADE(1), /* frame type one single line border */
/* transparent shadow */
INSTANT ); /* opening effect - expands rapidly */
/* put up a window title */
w_title (slideWindow, " VGA Pallete ",
TOPCENTER, 9, attr(BLACK,LIGHTGREY) );
w_def ( colorWindow = w_nexthandle ( ),/* define a window */
4,16, /* upper left hand corner at 4, 16 */
39,20, /* bottom right hand corner at 39, 20 */
LIGHTGREY, /* inner window color of LIGHTGREY */
LIGHTGREY, /* frame color of LIGHT GREY */
3, /* frame type three single line top */
/* double line side, no shadow */
INSTANT); /* open the window at once */
/* assign event handling routine to windows */
mm_setevent ( colorWindow, sliderHandler );
mm_setevent ( slideWindow, sliderHandler );
/* put up a window title */
w_title (colorWindow,
" BLACK ", TOPCENTER, 3, WHITE);
w_def ( colorBarWindow = w_nexthandle ( ),/* define a window */
45,2, /* upper left hand corner at 4, 16 */
76,22, /* bottom right hand corner at 39, 20 */
attr(BLACK,LIGHTGREY), /* inner window color of LIGHTGREY */
attr(BLACK,LIGHTGREY), /* frame color of LIGHT GREY */
TRANSHADE(1), /* frame type one single line top */
/* transparent shadow */
EXPLODE); /* opening effect - expands rapidly */
/* put up a window title */
w_title (colorBarWindow,
" Color Bar ", TOPCENTER, 12, attr(BLACK,LIGHTGREY) );
mm_coff ( );
/* open a window and cyle through the color list */
w_open ( colorBarWindow );
for ( i = BLACK; i <= WHITE; i++ ) {
w_color ( colorBarWindow, i );
for ( j = 0; j < w_width ( colorBarWindow ); j++ ) {
w_pos ( colorBarWindow, j, i+1 );
w_putc ( colorBarWindow, 219 );
}
}
/* open a information window and put up VGA display message */
w_open ( infoWindow );
w_pos ( infoWindow, 0, 1 );
/* put up user instructions */
for (i = 0; strlen( vgaMsg1[ i ] ); i++ )
w_centerlf ( infoWindow, vgaMsg1[ i ] );
w_open ( slideWindow );
w_open ( colorWindow );
w_home ( slideWindow );
w_puts ( slideWindow, " " );
mm_restrict ( slideWindow ); /* restrict mouse movement */
/* build the slide window */
for ( i = 0; i <= WHITE; i++ ) {
w_color ( slideWindow, i );
w_puts ( slideWindow, "\333\333" );
}
w_pos ( slideWindow, 0, 2 );
w_color ( slideWindow, attr(BLACK,LIGHTGREY) );
w_puts ( slideWindow, " 0% 100%\r" );
w_color ( slideWindow, attr(BLACK,LIGHTGREY) );
w_center ( slideWindow, "INTENSITY SCALE" );
keyStroke = lastX = x = 0;
w_hline ( slideWindow, 2, SINGLE );
/* build the color bars */
w_overlap ( OFF );
currentColor = BLACK;
do {
mm_coff ( );
temp = currentColor;
x = currentColor << 1;
for ( i=0 ; i<3 ; i++ ) {
w_color ( colorWindow,
i == 0 ? LIGHTGREEN : i == 1 ? LIGHTBLUE : LIGHTRED );
w_pos( colorWindow, 0, i );
w_puts( colorWindow,
i == 0 ? "G " : i == 1 ? "B " : "R ");
currentColor = x >> 1;
if ( currentColor > 8 ) currentColor |= 0x38;
currentColor = (vga_get(currentColor,i)-1)>>1;
for ( j = 0 ; j < currentColor ; j++ )
w_putc ( colorWindow, '\337' );
w_ereol( colorWindow );
}
w_pos ( slideWindow, lastX + 2, 1 );
lastX = x;
w_color ( slideWindow, attr( BLACK,LIGHTGREY ) );
w_puts( slideWindow, "\304\304" );
w_pos ( slideWindow, x+2, 1 );
w_color ( slideWindow, attr( BLACK,LIGHTGREY )+BLINK );
w_puts ( slideWindow,"\030\030" );
currentColor = temp;
if ( currentColor > 8 ) currentColor |= 0x38;
w_title ( colorWindow, colorName[currentColor & 7], TOPCENTER, 3, WHITE );
w_cframe ( colorWindow, 3, LIGHTGREY );
/* look for a key press to increase or decrease the corresponding color */
/* intensity loop until the ESCAPE key is pressed */
mm_con ( );
switch ( ( keyStroke=k_read( ) ) ) {
case K_LEFT:
currentColor &= 0xf;
currentColor--;
if ( currentColor < 0 )
currentColor = 15;
break;
case K_RIGHT:
currentColor &= 0xf;
currentColor++;
if ( currentColor > 15 )
currentColor = 0;
break;
case 'R':
if ( vga_get ( currentColor, _RED ) < 60 )
vga_set ( currentColor, _RED, vga_get ( currentColor, _RED ) + 2 );
break;
case 'r':
if ( vga_get ( currentColor, _RED ) > 1 )
vga_set ( currentColor, _RED, vga_get ( currentColor, _RED ) - 2 );
break;
case 'B':
if ( vga_get ( currentColor, _BLUE ) < 60 )
vga_set ( currentColor, _BLUE, vga_get ( currentColor, _BLUE ) + 2 );
break;
case 'b':
if ( vga_get ( currentColor, _BLUE ) > 1 )
vga_set ( currentColor, _BLUE, vga_get ( currentColor, _BLUE ) - 2 );
break;
case 'G':
if ( vga_get ( currentColor, _GREEN ) < 60 )
vga_set ( currentColor, _GREEN, vga_get ( currentColor, _GREEN ) + 2 );
break;
case 'g':
if ( vga_get ( currentColor, _GREEN ) > 1 )
vga_set ( currentColor, _GREEN, vga_get ( currentColor, _GREEN ) - 2 );
break;
case 'd':
case 'D':
vga_set ( currentColor, _RED, vga_default ( currentColor,_RED ) );
vga_set ( currentColor, _BLUE, vga_default ( currentColor,_BLUE ) );
vga_set ( currentColor, _GREEN, vga_default ( currentColor,_GREEN ) );
break;
}
currentColor &= 0xf;
} while ( keyStroke != K_ESC );
mm_coff ( );
w_overlap ( ON );
/* disintegrate the windows and release the window allocation */
w_disint ( slideWindow );
w_disint ( colorWindow );
w_disint ( infoWindow );
w_disint ( mainWindow );
w_disint ( colorBarWindow );
w_undef ( slideWindow );
w_undef ( colorWindow );
w_undef ( infoWindow );
w_undef ( mainWindow );
w_undef ( colorBarWindow );
mm_con ( ); /* enable mouse cursor */
mm_restrict ( 0 ); /* reset mouse movement to full screen */
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/