home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / clock.zip / CLKPNT.C < prev    next >
Text File  |  1987-01-03  |  4KB  |  136 lines

  1. /***************************************************** CLKPNT.C
  2.  * NAME:    CLKPNT
  3.  *
  4.  * FUNCTION:    Paints hands onto display
  5.  *
  6.  * EXAMPLE:    CLKPNT();
  7.  *
  8.  * INPUTS:    determined from global definitions
  9.  *
  10.  * OUTPUT:    to screen.
  11.  *
  12.  **************************************************************
  13.  * 11/22/86 -RBM- original implementation
  14.  **************************************************************/
  15. #define XTRNALGLOBALS 1        /* globals externally defined    */
  16. #include "E:CLKGBL.H"        /* setup global storage */
  17.  
  18. /**************************************************************
  19.  * BEGIN ROUTINE
  20.  **************************************************************/
  21.  
  22. CLKPNT()
  23. {
  24. static int lacthr;        /* last active hour hand        */
  25. static int lactmn;        /* last active minute hand        */
  26. int    i;            /* temporary counter            */
  27. struct    ACTIMAGE *imgptr;    /* pointer to hand image structure    */
  28. char    digtim[8];        /* digital time start column        */
  29. int    dtrow,dtcol;        /* digital time write row, column    */
  30. #define SCP 512         /* set cursor position video command    */
  31.  
  32. /* --- draw second blanking image -------*/
  33. imgptr=&acbsc[0];            /* sec. hand blanking    */
  34. drawit (imgptr,bkcol);
  35.  
  36. /* --- draw hour blanking image -------*/
  37. if (lacthr != acthr)
  38.     {lacthr = acthr;
  39.      imgptr=&acbhr[0];        /* hour hand blanking    */
  40.      drawit (imgptr,bkcol);
  41.     };
  42.  
  43. /* --- draw minute blanking image -------*/
  44. if (lactmn != actmn)
  45.     {lactmn = actmn;
  46.      imgptr=&acbmn[0];            /* min. hand blanking    */
  47.      drawit (imgptr,bkcol);
  48.     };
  49.  
  50. /* --- draw hour hand image -------*/
  51. imgptr=&acdhr[0];             /* hr hand image    */
  52. drawit (imgptr,mncol);
  53.  
  54. /* --- draw minute hand image -------*/
  55. imgptr=&acdmn[0];            /* min hand image    */
  56. drawit (imgptr,mncol);
  57.  
  58. /* --- draw second hand image -------*/
  59. imgptr=&acdsc[0];            /* sec hand image    */
  60. drawit (imgptr,sccol);
  61.  
  62. /*--- draw digital time -----------------*/
  63. if (digclock != 0)
  64.     {
  65.     dtrow = digrow;                /* row to write at       */
  66.     dtcol = digcol;                /* column to start writing */
  67.  
  68.     sreg.ax = SCP;                /* "set cursor position"   */
  69.     sreg.bx = 0;                /* page #           */
  70.     sreg.cx = 0;                /* unused           */
  71.     sreg.dx = dtrow*256 + dtcol;        /* row, col           */
  72.     csysint(VIDEO, &sreg, &rreg);
  73.  
  74.     digtim[0] = '0' + (char)(lt24hr/10);    /* compute hrs tens digits */
  75.     if (digtim[0]=='0') digtim[0]=' ';        /* blank out hrs leading 0 */
  76.     digtim[1] = '0' + (char)(lt24hr%10);    /* compute hrs units digits*/
  77.     digtim[2] = ':';
  78.     digtim[3] = '0' + (char)(lastmn/10);    /* compute min tens digits */
  79.     digtim[4] = '0' + (char)(lastmn%10);    /* compute min units digits*/
  80.     digtim[5] = ':';
  81.     digtim[6] = '0' + (char)(lastsc/10);    /* compute sec tens digits */
  82.     digtim[7] = '0' + (char)(lastsc%10);    /* compute sec units digits*/
  83.  
  84.     for (i=0; i<=7; i++)
  85.     {sreg.ax = 2304 + digtim[i];        /* char write command       */
  86.      sreg.bx = digclr;            /* set color           */
  87.      sreg.cx = 1;                /* write 1 char           */
  88.      sreg.dx = 0;                /* unused           */
  89.      csysint(VIDEO, &sreg, &rreg);
  90.  
  91.      dtcol++;                /* move cursor over       */
  92.      sreg.ax = SCP;
  93.      sreg.bx = sreg.cx = 0;
  94.      sreg.dx = dtrow*256 + dtcol;
  95.      csysint(VIDEO, &sreg, &rreg);
  96.     };
  97.     };
  98. }                /***** end of routine ******/
  99.  
  100. /*--- subroutine to actually do the drawing ----------------------------*/
  101. #define abs(x) ((x)<0?-(x):(x))    /* define absolute value function    */
  102.  
  103.  
  104. drawit (ptr,color)
  105.  
  106. struct ACTIMAGE *ptr;        /* pointer to hand image structure    */
  107. int    color;            /* color of dot to draw            */
  108.  
  109. {
  110. int    overdown;        /* over or down flag (+=over, -=down)    */
  111. int    width;            /* width of dots to draw (-tive is down)*/
  112. int    i;            /* temporary counter            */
  113.  
  114. for ( ; ptr->row != 0; ptr++)
  115.     {sreg.ax = 12*256 + color;        /* color of dot         */
  116.      sreg.cx = ptr->col;            /* point to column        */
  117.      sreg.dx = ptr->row;            /* row to draw on         */
  118.  
  119.     overdown = ptr->wth;        /* get over or down flag    */
  120.     width = abs(overdown);        /* get width of dots to draw    */
  121.     for (i=0; i<width; i++)     /* step thru "wth" columns    */
  122.         {if (overdown >= 0)
  123.         { /*--- stepping "over" ---*/
  124.          sreg.cx = ptr->col + i;    /* point to column        */
  125.          csysint(VIDEO, &sreg, &rreg);    /* draw dot        */
  126.         }
  127.          else
  128.         { /*--- stepping "down" ---*/
  129.          sreg.dx = ptr->row + i;    /* point to row            */
  130.          csysint(VIDEO, &sreg, &rreg);    /* draw dot        */
  131.         };
  132.  
  133.         };
  134.     };
  135. } /*--- end subroutine -------------------------------------------------*/
  136.