home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / c / pcw_c.zip / PALDEMO.C < prev    next >
C/C++ Source or Header  |  1991-12-05  |  2KB  |  63 lines

  1. /***************************************************************/
  2. /* File Id.                     Paldemo.C                      */
  3. /* Author.                      Stan Milam.                    */
  4. /* Date Written.                28 Nov 89.                     */
  5. /*                                                             */
  6. /*           (c) Copywrite 1989, 1990 by Stan Milam            */
  7. /*                                                             */
  8. /* Demo of changing the palette color on EGA/VGA.              */
  9. /***************************************************************/
  10.  
  11. #include <stdio.h>
  12. #include <pcwproto.h>
  13.  
  14. void main(void) {
  15.  
  16.    int i,j;
  17.    WNDPTR *wnd, *savewnd;
  18.  
  19.    chk_video_state(&i,&j);
  20.    if (_adaptor < EGA || _monitor != COLOR) {
  21.       puts("\nYou must have an EGA or VGA adapter with color monitor to ");
  22.       puts("run this demo.");
  23.       return;
  24.    }
  25.    savewnd = wpush(1,1,i,j);
  26.    get_ega_palette( DFLT_PALETTE );
  27.    for (i = 0; i < 16; i++) qputs(i+4,CENTER,i,BLACK,"Hello World!");
  28.    keywait(10);
  29.  
  30.    for(i = 32, j = 0; i < 48; i++, j++) set_load_palette(j, i);
  31.    keywait(10); get_ega_palette(22); load_ega_palette();
  32.    bordercolor(BLUE,LIGHTGRAY);
  33.    titlecolor(RED,LIGHTGRAY);
  34.    wnd = wframe(6,20,18,60,BLACK,LIGHTGRAY);
  35.    wtitle(wnd,TOP,MIDDLE," Changing Palette Colors ");
  36.    keywait(10);
  37.    set_palette(BLUE,RED);
  38.    set_palette(RED,BLUE);
  39.    load_ega_palette();
  40.    wputs(wnd,1,CENTER,"Red is now blue and blue is red!");
  41.    keywait(10);
  42.    set_palette(LIGHTGRAY, GREEN); load_ega_palette();
  43.    wputs(wnd,2,CENTER,"Lightgray becomes green!");
  44.    keywait(10);
  45.    get_ega_palette(22); load_ega_palette();
  46.    wputs(wnd,5,CENTER,"**** Back to normal ****");
  47.    keywait(10);
  48.    wnd = wpop(wnd);
  49.    bordercolor(RED,RED);
  50.    wnd = wframe(6, 20, 18, 60, RED, RED);
  51.    wtitle(wnd, TOP, MIDDLE, " Now all 64 colors ");
  52.    wtitle(wnd,BOTTOM,RITE, " Press a key to stop ");
  53.    for (i = 0; i < 64; i++) {
  54.        set_load_palette(RED,i);
  55.        swait(1);
  56.        if (keypressed()) {
  57.           getch();
  58.           break;
  59.        }
  60.    }
  61.    set_load_palette(RED,RED);
  62. }
  63.