home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / c / colortbl.zip / COLORTBL.C next >
Text File  |  1988-01-30  |  4KB  |  109 lines

  1. /************************************************************************
  2.  *    COLOR VALUES TABLE DISPLAY PROGRAM FOR USE WITH DESQVIEW        *
  3.  *                                    *
  4.  *    Copyright 1987, Phillip A. Kaufman. All rights, except those    *
  5.  *    specifically granted herein are reserved by the author. The right    *
  6.  *    to copy and distribute this material is granted without fee for    *
  7.  *    any and all non-commercial use. This material specifically may    *
  8.  *    not be distributed or sold for a fee nor incorporated in whole or    *
  9.  *    in part into any other product that is distributed or sold for a    *
  10.  *    fee without specific permission of the author. To obtain special    *
  11.  *    permission or to report any difficulties with this material    *
  12.  *    contact:                                *
  13.  *                      Phillip A. Kaufman                *
  14.  *                      19987 Moran Lane                *
  15.  *                      Saratoga, CA 95070                *
  16.  *                                    *
  17.  *    THIS MATERIAL IS DISTRIBUTED "as is" WITHOUT ANY EXPRESSED OR    *
  18.  *    IMPLIED WARRANTY OR LIABILITY FOR DIRECT, INDIRECT OR        *
  19.  *    CONSEQUENTIAL DAMAGES.                        *
  20.  ************************************************************************
  21.  *                                    *
  22.  *    Use:  ESC to exit                        *
  23.  *                                    *
  24.  *    Installation: Must be installed in Desqview environment.    *
  25.  *        Requires a DV memory size of only 4k. Must set the    *
  26.  *        window size to 18 high and 23 wide.            *
  27.  *                                    *
  28.  *    Files:                                *
  29.  *        asciitbl.c    this source file ( for MSC 4.0;     *
  30.  *                  compile with small model and link     *
  31.  *                  with stack of 150 bytes - IT IS    *
  32.  *                  REALLY IMPORTANT to either use linker *
  33.  *                  directive to set stack or to use    *
  34.  *                  EXEMOD. Microsoft's default stack size*
  35.  *                  is 2k and program will crash DV if    *
  36.  *                  loaded into a 4k segment.)        *
  37.  *        asciitbl.exe    compiled version of above - fits in 4k    *
  38.  *                  with room to spare!            *
  39.  *        at-pif.dvp    dv 2.0 pif file                *
  40.  *        at-scrip.dvs    dv 2.0 startup script for colors    *
  41.  ************************************************************************/
  42.  
  43. #include    <dos.h>
  44. char hex[] = "0123456789ABCDEF";
  45.  
  46. union REGS rg;            /* cpu regs        */
  47. struct SREGS segregs;
  48. union {
  49.     unsigned long l;    /* long form of address    */
  50.     int far *p;        /* pointer form of address */
  51. } addr;
  52.  
  53. _setargv()        /* dummy since we use no command line args */
  54. {
  55. }
  56. _setenvp()        /* dummy since we don't use environment variables */
  57. {
  58. }
  59. _nullcheck()        /* disable null pointer checking */
  60. {
  61. }
  62.  
  63. main()
  64. {
  65.     register int i, j, attr;
  66.  
  67.         /* Check for Desqview and use its buffer */
  68.         rg.x.ax = 0x2B01;           /* do date set as DV check */
  69.         rg.x.cx = 0x4445;               /* "DESQ"an illegal date */
  70.         rg.x.dx = 0x5351;
  71.         int86(0x21,&rg,&rg);
  72.         if (rg.h.al != 0xFF){        /* we are in desqview    */
  73.                 rg.h.ah = 0xFE;        /* dv get buff addr    */
  74.         int86(0x10,&rg,&rg);
  75.         segread(&segregs);
  76.                 addr.l=((unsigned long)segregs.es<<16)+(unsigned long)rg.x.di;
  77.         }
  78.     else {
  79.         cputs ("\x07Program requires DESQview!\n");
  80.         exit(1);
  81.     }
  82.     
  83.     for (i=0; i <= 0x7; i++){
  84.         for (j=0; j <=0xF; j++){
  85.             attr = (i << 4 | j ) << 8;
  86.             *addr.p = ' ' | attr;
  87.             addr.p++;
  88.             *addr.p = hex[i] | attr;
  89.             addr.p++;
  90.             *addr.p = hex[j] | attr;
  91.             addr.p++;
  92.         }
  93.         *addr.p = ' ' | attr;
  94.         addr.p++;
  95.     }
  96.  
  97.     /* put the cursor outside the window */
  98.     rg.h.ah = 0x2;
  99.     rg.h.bh = 0;
  100.     rg.x.dx = 0x154f;  /* row 24 col 79*/
  101.     int86(0x10,&rg,&rg);
  102.     
  103.     while (1) {      /* loop, wait for ESC to exit */
  104.         rg.h.ah = 0x07;        /* kbd input, wait, no echo */
  105.         int86(0x21,&rg,&rg);
  106.             if (rg.h.al == 0x1B) exit (0);    /* ESC */
  107.     }
  108. }
  109.