Home | History | Annotate | Line # | Download | only in mille
print.c revision 1.12
      1  1.12    perry /*	$NetBSD: print.c,v 1.12 2007/12/15 19:44:42 perry Exp $	*/
      2   1.4      cgd 
      3   1.1      cgd /*
      4   1.3      jtc  * Copyright (c) 1982, 1993
      5   1.3      jtc  *	The Regents of the University of California.  All rights reserved.
      6   1.1      cgd  *
      7   1.1      cgd  * Redistribution and use in source and binary forms, with or without
      8   1.1      cgd  * modification, are permitted provided that the following conditions
      9   1.1      cgd  * are met:
     10   1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     11   1.1      cgd  *    notice, this list of conditions and the following disclaimer.
     12   1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     14   1.1      cgd  *    documentation and/or other materials provided with the distribution.
     15  1.11      agc  * 3. Neither the name of the University nor the names of its contributors
     16   1.1      cgd  *    may be used to endorse or promote products derived from this software
     17   1.1      cgd  *    without specific prior written permission.
     18   1.1      cgd  *
     19   1.1      cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     20   1.1      cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21   1.1      cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22   1.1      cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     23   1.1      cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24   1.1      cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25   1.1      cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26   1.1      cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27   1.1      cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28   1.1      cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29   1.1      cgd  * SUCH DAMAGE.
     30   1.1      cgd  */
     31   1.1      cgd 
     32   1.6    lukem #include <sys/cdefs.h>
     33   1.1      cgd #ifndef lint
     34   1.4      cgd #if 0
     35   1.4      cgd static char sccsid[] = "@(#)print.c	8.1 (Berkeley) 5/31/93";
     36   1.4      cgd #else
     37  1.12    perry __RCSID("$NetBSD: print.c,v 1.12 2007/12/15 19:44:42 perry Exp $");
     38   1.4      cgd #endif
     39   1.1      cgd #endif /* not lint */
     40   1.1      cgd 
     41   1.1      cgd # include	"mille.h"
     42   1.1      cgd 
     43   1.1      cgd /*
     44   1.1      cgd  * @(#)print.c	1.1 (Berkeley) 4/1/82
     45   1.1      cgd  */
     46   1.1      cgd 
     47   1.1      cgd # define	COMP_STRT	20
     48   1.1      cgd # define	CARD_STRT	2
     49   1.1      cgd 
     50   1.6    lukem void
     51   1.6    lukem prboard()
     52   1.6    lukem {
     53   1.6    lukem 	PLAY	*pp;
     54   1.6    lukem 	int	i, j, k, temp;
     55   1.1      cgd 
     56   1.1      cgd 	for (k = 0; k < 2; k++) {
     57   1.1      cgd 		pp = &Player[k];
     58   1.1      cgd 		temp = k * COMP_STRT + CARD_STRT;
     59   1.1      cgd 		for (i = 0; i < NUM_SAFE; i++)
     60   1.1      cgd 			if (pp->safety[i] == S_PLAYED && !pp->sh_safety[i]) {
     61   1.1      cgd 				mvaddstr(i, temp, C_name[i + S_CONV]);
     62   1.1      cgd 				if (pp->coups[i])
     63   1.1      cgd 					mvaddch(i, temp - CARD_STRT, '*');
     64   1.1      cgd 				pp->sh_safety[i] = TRUE;
     65   1.1      cgd 			}
     66   1.1      cgd 		show_card(14, temp, pp->battle, &pp->sh_battle);
     67   1.1      cgd 		show_card(16, temp, pp->speed, &pp->sh_speed);
     68   1.1      cgd 		for (i = C_25; i <= C_200; i++) {
     69   1.7      jsm 			const char	*name;
     70   1.6    lukem 			int	end;
     71   1.1      cgd 
     72   1.1      cgd 			if (pp->nummiles[i] == pp->sh_nummiles[i])
     73   1.1      cgd 				continue;
     74   1.1      cgd 
     75   1.1      cgd 			name = C_name[i];
     76   1.1      cgd 			temp = k * 40;
     77   1.1      cgd 			end = pp->nummiles[i];
     78   1.1      cgd 			for (j = pp->sh_nummiles[i]; j < end; j++)
     79   1.1      cgd 				mvwaddstr(Miles, i + 1, (j << 2) + temp, name);
     80   1.1      cgd 			pp->sh_nummiles[i] = end;
     81   1.1      cgd 		}
     82   1.1      cgd 	}
     83   1.1      cgd 	prscore(TRUE);
     84   1.1      cgd 	temp = CARD_STRT;
     85   1.1      cgd 	pp = &Player[PLAYER];
     86   1.1      cgd 	for (i = 0; i < HAND_SZ; i++)
     87   1.1      cgd 		show_card(i + 6, temp, pp->hand[i], &pp->sh_hand[i]);
     88  1.10  thorpej 	mvprintw(6, COMP_STRT + CARD_STRT, "%2ld", (long)(Topcard - Deck));
     89   1.1      cgd 	show_card(8, COMP_STRT + CARD_STRT, Discard, &Sh_discard);
     90   1.1      cgd 	if (End == 1000) {
     91   1.1      cgd 		move(EXT_Y, EXT_X);
     92   1.1      cgd 		standout();
     93   1.1      cgd 		addstr("Extension");
     94   1.1      cgd 		standend();
     95   1.1      cgd 	}
     96   1.1      cgd 	wrefresh(Board);
     97   1.1      cgd 	wrefresh(Miles);
     98   1.1      cgd 	wrefresh(Score);
     99   1.1      cgd }
    100   1.1      cgd 
    101   1.1      cgd /*
    102   1.1      cgd  * show_card:
    103   1.1      cgd  *	Show the given card if it is different from the last one shown
    104   1.1      cgd  */
    105   1.6    lukem void
    106   1.1      cgd show_card(y, x, c, lc)
    107   1.6    lukem 	int	y, x;
    108   1.6    lukem 	CARD	c, *lc;
    109   1.1      cgd {
    110   1.1      cgd 	if (c == *lc)
    111   1.1      cgd 		return;
    112   1.1      cgd 
    113   1.1      cgd 	mvprintw(y, x, C_fmt, C_name[c]);
    114   1.1      cgd 	*lc = c;
    115   1.1      cgd }
    116   1.1      cgd 
    117   1.1      cgd static char	Score_fmt[] = "%4d";
    118   1.1      cgd 
    119   1.6    lukem void
    120   1.1      cgd prscore(for_real)
    121   1.8      jsm #ifdef EXTRAP
    122   1.8      jsm 	bool	for_real;
    123   1.8      jsm #else
    124  1.12    perry 	bool	for_real __unused;
    125   1.8      jsm #endif
    126   1.5      jtc {
    127   1.6    lukem 	PLAY	*pp;
    128   1.6    lukem 	int	x;
    129   1.1      cgd 
    130   1.1      cgd 	stdscr = Score;
    131   1.1      cgd 	for (pp = Player; pp < &Player[2]; pp++) {
    132   1.1      cgd 		x = (pp - Player) * 6 + 21;
    133   1.1      cgd 		show_score(1, x, pp->mileage, &pp->sh_mileage);
    134   1.1      cgd 		if (pp->safescore != pp->sh_safescore) {
    135   1.1      cgd 			mvprintw(2, x, Score_fmt, pp->safescore);
    136   1.1      cgd 			if (pp->safescore == 400)
    137   1.1      cgd 				mvaddstr(3, x + 1, "300");
    138   1.1      cgd 			else
    139   1.1      cgd 				mvaddstr(3, x + 1, "  0");
    140   1.1      cgd 			mvprintw(4, x, Score_fmt, pp->coupscore);
    141   1.1      cgd 			pp->sh_safescore = pp->safescore;
    142   1.1      cgd 		}
    143   1.1      cgd 		if (Window == W_FULL || Finished) {
    144   1.1      cgd #ifdef EXTRAP
    145   1.1      cgd 			if (for_real)
    146   1.1      cgd 				finalscore(pp);
    147   1.1      cgd 			else
    148   1.1      cgd 				extrapolate(pp);
    149   1.1      cgd #else
    150   1.1      cgd 			finalscore(pp);
    151   1.1      cgd #endif
    152   1.1      cgd 			show_score(11, x, pp->hand_tot, &pp->sh_hand_tot);
    153   1.1      cgd 			show_score(13, x, pp->total, &pp->sh_total);
    154   1.1      cgd 			show_score(14, x, pp->games, &pp->sh_games);
    155   1.1      cgd 		}
    156   1.1      cgd 		else {
    157   1.1      cgd 			show_score(6, x, pp->hand_tot, &pp->sh_hand_tot);
    158   1.1      cgd 			show_score(8, x, pp->total, &pp->sh_total);
    159   1.1      cgd 			show_score(9, x, pp->games, &pp->sh_games);
    160   1.1      cgd 		}
    161   1.1      cgd 	}
    162   1.1      cgd 	stdscr = Board;
    163   1.1      cgd }
    164   1.1      cgd 
    165   1.1      cgd /*
    166   1.1      cgd  * show_score:
    167   1.1      cgd  *	Show a score value if it is different from the last time we
    168   1.1      cgd  *	showed it.
    169   1.1      cgd  */
    170   1.6    lukem void
    171   1.1      cgd show_score(y, x, s, ls)
    172   1.6    lukem 	int	y, x;
    173   1.6    lukem 	int	s, *ls;
    174   1.1      cgd {
    175   1.1      cgd 	if (s == *ls)
    176   1.1      cgd 		return;
    177   1.1      cgd 
    178   1.1      cgd 	mvprintw(y, x, Score_fmt, s);
    179   1.1      cgd 	*ls = s;
    180   1.1      cgd }
    181