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 >
Wrap
Text File
|
1988-07-28
|
1KB
|
65 lines
/* dis_dice.c
* display dice on default screen.
*/
#include <curses.h>
#include "defs.h"
#include "dice.h"
#define hold_fix(dice_num, hold_string) \
{ \
mvwaddstr(screen, diey[dice_num], diex[dice_num] + 4, hold_string); \
mvwaddstr(screen, diey[dice_num] + 4, diex[dice_num] + 1, \
hold_string); \
}
extern int BadStandout;
extern int diey[Five_Dice], diex[Five_Dice];
extern WINDOW *screen;
int old_dice[Five_Dice];
static int old_hold[Five_Dice] = {-1, -1, -1, -1};
dis_dice(dice, hold)
int dice[Five_Dice], hold[Five_Dice];
{
register int i, j, die;
/* iterate through each dice value */
for (i = 0; i < Five_Dice; ++i)
{
/* die is the index for the dices display strings */
die = dice[i] - 1;
/* use standout mode (or "hold") for held dice */
if (! BadStandout)
if (! hold[i])
wstandend(screen);
else
wstandout(screen);
else
if (hold[i])
hold_fix(i, "hold")
else
hold_fix(i, "----")
/* this test stops redraw of dice already on screen (curses will
* look after this but not as efficiently */
if (dice[i] != old_dice[i] || (! BadStandout && old_hold[i]
!= hold[i]))
{
for (j = 0; j < dicey; ++j)
mvwaddstr(screen, diey[i] + j, diex[i],
dices[die][j]);
old_dice[i] = dice[i];
old_hold[i] = hold[i];
}
}
if (! BadStandout)
wstandend(screen);
wmove(screen, 5, 0);
wrefresh(screen);
}