home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff262.lzh / Lotto / led.c < prev    next >
C/C++ Source or Header  |  1989-10-31  |  3KB  |  144 lines

  1. /*************************************/
  2. /*                                   */
  3. /* AUoH Progressive Door Prize Lotto */
  4. /*                                   */
  5. /*         DISPLAY routines          */
  6. /*                                   */
  7. /*  Michael D. Groshart - 16 Aug 89  */
  8. /*                                   */
  9. /*************************************/
  10.  
  11. #include <intuition/intuition.h>
  12. #include <functions.h>
  13.  
  14. extern struct Window   *win;
  15. extern struct RastPort *rp;
  16. extern struct ViewPort *vp;
  17.  
  18. #define XOFFSET  96
  19.  
  20. static long colreg = 2, rand();
  21.  
  22. static long led[7][6][2] =
  23. {
  24.     32,  82,  26,  76,  26,  28, 32,  22,  39,  29,  39,  75,
  25.     34,  20,  40,  14,  88,  14, 94,  20,  87,  27,  41,  27,
  26.     96,  22, 102,  28, 102,  76, 96,  82,  89,  75,  89,  29,
  27.     94,  84,  87,  91,  41,  91, 34,  84,  41,  77,  87,  77,
  28.     32,  86,  39,  93,  39, 139, 32, 146,  26, 140,  26,  92,
  29.     34, 148,  41, 141,  87, 141, 94, 148,  88, 154,  40, 154,
  30.     96, 146,  89, 139,  89,  93, 96,  86, 102,  92, 102, 140
  31. };
  32.  
  33. static long fill[7][2] =
  34. {
  35.     32, 81, 35, 20, 96, 23, 93, 84, 32, 87, 35, 148, 96, 145
  36. };
  37.  
  38. static int digit[10][7] =
  39. {
  40.     1, 1, 1, 0, 1, 1, 1,    /* 0 */
  41.     0, 0, 1, 0, 0, 0, 1,    /* 1 */
  42.     0, 1, 1, 1, 1, 1, 0,    /* 2 */
  43.     0, 1, 1, 1, 0, 1, 1,    /* 3 */
  44.     1, 0, 1, 1, 0, 0, 1,    /* 4 */
  45.     1, 1, 0, 1, 0, 1, 1,    /* 5 */
  46.     1, 1, 0, 1, 1, 1, 1,    /* 6 */
  47.     0, 1, 1, 0, 0, 0, 1,    /* 7 */
  48.     1, 1, 1, 1, 1, 1, 1,    /* 8 */
  49.     1, 1, 1, 1, 0, 1, 1    /* 9 */
  50. };
  51.  
  52. init_digits()
  53. {
  54.     register long color = 2;
  55.     register int a,b,c;
  56.  
  57.     for (a = 0; a < 3; a++)
  58.     {
  59.         for (b = 0; b < 7; b++)
  60.         {
  61.             SetAPen(rp,color++);
  62.             Move(rp,led[b][5][0],led[b][5][1]);
  63.             for (c = 0; c < 6; c++)
  64.             {
  65.                 Draw(rp,led[b][c][0],led[b][c][1]);
  66.                 led[b][c][0] += XOFFSET;
  67.             }
  68.             Flood(rp,1L,fill[b][0],fill[b][1]);
  69.             fill[b][0] += XOFFSET;
  70.         }
  71.     }
  72.     SetAPen(rp,25L);    /* draw bottom text box */
  73.     Move(rp,  6L,172L);
  74.     Draw(rp,313L,172L);
  75.     Draw(rp,313L,183L);
  76.     Draw(rp,  6L,183L);
  77.     Draw(rp,  6L,172L);
  78. }
  79.  
  80. erase()
  81. {
  82.     SetAPen(rp,0L);
  83.     RectFill(rp,7L,173L,312L,182L);
  84. }
  85.  
  86. flash()
  87. {
  88.     SetRGB4(vp,colreg,rand(16L),rand(16L),rand(16L));
  89.     if (++colreg == 23) colreg = 2;
  90. }
  91.  
  92. char message[80];
  93.  
  94. scroll(text)
  95. register char *text;
  96. {
  97.     register struct IntuiMessage *im;
  98.     register char *ptr = message;
  99.     register int n;
  100.  
  101.     strcpy(message,text);
  102.     strcat(message,"    ");
  103.  
  104.     SetAPen(rp,1L);
  105.     while (!(im = (struct IntuiMessage *) GetMsg(win->UserPort)))
  106.     {
  107.         for (n = 0; n < 4; n++)
  108.         {
  109.             WaitTOF();
  110.             ScrollRaster(rp,2L,0L,8L,174L,311L,181L);
  111.         }
  112.         Move(rp, 304L, 180L);
  113.         Text(rp, ptr, 1L);
  114.         if (*++ptr == '\0') ptr = message;
  115.     }
  116.     ReplyMsg(im);
  117. }
  118.  
  119. display(num)
  120. int num;
  121. {
  122.     register int i;
  123.  
  124.     for (i = 16; i >= 2; i -= 7)
  125.     {
  126.         set_led(i,num % 10);
  127.         num /= 10;
  128.     }
  129. }
  130.  
  131. static set_led(pos,val)
  132. int pos,val;
  133. {
  134.     register long n;
  135.  
  136.     for (n = 0; n < 7; n++)
  137.     {
  138.         if (digit[val][n])
  139.             SetRGB4(vp,pos + n,15L,15L,0L);
  140.         else
  141.             SetRGB4(vp,pos + n,0L,0L,0L);
  142.     }
  143. }
  144.