home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / TOP / USR / SRC / yahtzee.t.Z / yahtzee.t / dis_dice.c < prev    next >
Text File  |  1988-07-28  |  1KB  |  65 lines

  1. /* dis_dice.c
  2.  *    display dice on default screen.
  3.  */
  4. #include <curses.h>
  5. #include "defs.h"
  6. #include "dice.h"
  7.  
  8. #define hold_fix(dice_num, hold_string) \
  9.     { \
  10.     mvwaddstr(screen, diey[dice_num], diex[dice_num] + 4, hold_string); \
  11.     mvwaddstr(screen, diey[dice_num] + 4, diex[dice_num] + 1, \
  12.         hold_string); \
  13.     }
  14.  
  15. extern int BadStandout;
  16. extern int diey[Five_Dice], diex[Five_Dice];
  17. extern WINDOW *screen;
  18.  
  19. int old_dice[Five_Dice];
  20. static int old_hold[Five_Dice] = {-1, -1, -1, -1};
  21.  
  22. dis_dice(dice, hold)
  23.  
  24. int dice[Five_Dice], hold[Five_Dice];
  25.  
  26.     {
  27.     register int i, j, die;
  28.  
  29. /* iterate through each dice value */
  30.     for (i = 0; i < Five_Dice; ++i)
  31.         {
  32.  
  33. /* die is the index for the dices display strings */
  34.         die = dice[i] - 1;
  35.  
  36. /* use standout mode (or "hold") for held dice */
  37.         if (! BadStandout)
  38.             if (! hold[i])
  39.                 wstandend(screen);
  40.             else
  41.                 wstandout(screen);
  42.         else
  43.             if (hold[i])
  44.                 hold_fix(i, "hold")
  45.             else
  46.                 hold_fix(i, "----")
  47.  
  48. /* this test stops redraw of dice already on screen (curses will
  49.  * look after this but not as efficiently */
  50.         if (dice[i] != old_dice[i] || (! BadStandout && old_hold[i]
  51.             != hold[i]))
  52.             {
  53.             for (j = 0; j < dicey; ++j)
  54.                 mvwaddstr(screen, diey[i] + j, diex[i],
  55.                     dices[die][j]);
  56.             old_dice[i] = dice[i];
  57.             old_hold[i] = hold[i];
  58.             }
  59.         }
  60.     if (! BadStandout)
  61.         wstandend(screen);
  62.     wmove(screen, 5, 0);
  63.     wrefresh(screen);
  64.     }
  65.