[alt.sources] Oops, Here is a video poker shar file WITH the .h files

jak@sactoh0.sac.ca.us (Jay A. Konigsberg) (05/03/91)

Well, here is the video poker game again. Same as before, only now
I included the .h files. Minor detail - sorry folks.

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	cleanup.c
#	deal.c
#	display_hand.c
#	display_val.c
#	draw.c
#	id_hand.c
#	main.c
#	payoff_val.c
#	rawmode.c
#	setup_deck.c
#	sort.c
#	hand_value.h
#	vid_curses.h
#	vid_extern.h
#	vid_local.h
#	vid_poker.h
#	Makefile
# This archive created: Thu May  2 17:52:00 1991
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'cleanup.c'
then
	echo shar: "will not over-write existing file 'cleanup.c'"
else
cat << \SHAR_EOF > 'cleanup.c'

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * cleanup - resets port settings to what they were before entering
 * raw mode.
 */

#include	<stdio.h>
#include	<termio.h>
#include	"vid_extern.h"

extern	int	errno;

/* Global for interrupt routine: cleanup() */
extern	struct	  termio  ttyset;	/* terminal settings */
extern	unsigned  short   c_lflag_hold;	/* hold original values for reset */
extern	unsigned  char    VEOF_hold;	/* hold original value for reset */

int	(*cleanup())	/* Signal trap for SIGINT */
{
/* reset terminal charastics */
ttyset.c_lflag = c_lflag_hold;
ttyset.c_cc[4] = VEOF_hold;
if ( ioctl(0, TCSETAW, &ttyset) == -1) {
    fprintf(stderr, "ioctl: error=%d\n", errno);
    (void)exit(2);
}
puts("\nExiting Video Poker\t\t\t\t\t\t");
(void)exit(0);
return(0);
}
SHAR_EOF
fi
if test -f 'deal.c'
then
	echo shar: "will not over-write existing file 'deal.c'"
else
cat << \SHAR_EOF > 'deal.c'
/*LINTLIBRARY*/

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * deal.c - generate the random numbers that will represent cards.
 */

#include	"vid_poker.h"
#include	<sys/types.h>

extern	double	drand48();
extern	void	srand48();
extern	time_t	time();

static	time_t	seed=0;

void	deal(deck, numcards)
int	*deck,			/* 52 card deck				*/
	numcards;		/* number of cards requested		*/
{
int	check,			/* index for preventing dup cards	*/
	count=0;		/* count of cards already delt (0 or 5)	*/

if ( seed == (time_t)0 )
    {
    seed=time(&seed);
    (void)srand48(seed);
    }

if ( deck[0] != 0 )
    numcards += (count=5);	/* we are on the draw	*/

for (; count < numcards; ++count)
    {
    deck[count] = 52 * drand48()+1;
    for ( check=0; check < count; ++check )
	if ( deck[check] == deck[count] )
	    --count;
    }
}
SHAR_EOF
fi
if test -f 'display_hand.c'
then
	echo shar: "will not over-write existing file 'display_hand.c'"
else
cat << \SHAR_EOF > 'display_hand.c'
/*LINTLIBRARY*/

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * display_hand.c - draw the cards onto the screen
 */

#include	"vid_extern.h"
#include	"vid_curses.h"
#include	"vid_poker.h"

void	display_hand(value, suite, count)
int	*value;
char	**suite;
int	count;
{
int	cardinx;

for ( cardinx=0; cardinx < count; ++cardinx)
    {
    if ( ! strcmp(suite[cardinx], "Spades") )
	{
	mvaddstr(10, cardinx * 15, "|-----------|");
	mvaddstr(11, cardinx * 15, "|     __    |");
	mvaddstr(12, cardinx * 15, "|   /\\`'/\\  |");
	mvaddstr(13, cardinx * 15, "|   \\ ~~ /  |");
	mvaddstr(14, cardinx * 15, "|    \\  /   |");
	mvaddstr(15, cardinx * 15, "|     \\/    |");
	mvaddstr(16, cardinx * 15, "|   Spades  |");
	mvaddstr(17, cardinx * 15, "|           |");
	mvaddstr(18, cardinx * 15, "|-----------|");
	}
    else
    if ( ! strcmp(suite[cardinx], "Hearts") )
	{
	mvaddstr(10, cardinx * 15, "|-----------|");
	mvaddstr(11, cardinx * 15, "|           |");
	mvaddstr(12, cardinx * 15, "|    /\\/\\   |");
	mvaddstr(13, cardinx * 15, "|   (    )  |");
	mvaddstr(14, cardinx * 15, "|    \\  /   |");
	mvaddstr(15, cardinx * 15, "|     \\/    |");
	mvaddstr(16, cardinx * 15, "|   Hearts  |");
	mvaddstr(17, cardinx * 15, "|           |");
	mvaddstr(18, cardinx * 15, "|-----------|");
	}
    else
    if ( ! strcmp(suite[cardinx], "Clubs") )
	{
	mvaddstr(10, cardinx * 15, "|-----------|");
	mvaddstr(11, cardinx * 15, "|           |");
	mvaddstr(12, cardinx * 15, "|     ^     |");
	mvaddstr(13, cardinx * 15, "|   _/ \\_   |");
	mvaddstr(14, cardinx * 15, "|  (__ __)  |");
	mvaddstr(15, cardinx * 15, "|    /_\\    |");
	mvaddstr(16, cardinx * 15, "|   Clubs   |");
	mvaddstr(17, cardinx * 15, "|           |");
	mvaddstr(18, cardinx * 15, "|-----------|");
	}
    else
    if ( ! strcmp(suite[cardinx], "Diamonds") )
	{
	mvaddstr(10, cardinx * 15, "|-----------|");
	mvaddstr(11, cardinx * 15, "|           |");
	mvaddstr(12, cardinx * 15, "|     /\\    |");
	mvaddstr(13, cardinx * 15, "|    /  \\   |");
	mvaddstr(14, cardinx * 15, "|    \\  /   |");
	mvaddstr(15, cardinx * 15, "|     \\/    |");
	mvaddstr(16, cardinx * 15, "|  Diamonds |");
	mvaddstr(17, cardinx * 15, "|           |");
	mvaddstr(18, cardinx * 15, "|-----------|");
	}
    switch (value[cardinx])
	{
	case 1:
	    mvaddstr(11, cardinx*15+1, "A");
	    mvaddstr(14, cardinx*15+6, "AA");
	    mvaddstr(17, cardinx*15+10, "A");
	    break;
	case 10:
	    mvaddstr(11, cardinx*15+1, "10");
	    mvaddstr(14, cardinx*15+6, "10");
	    mvaddstr(17, cardinx*15+10, "10");
	    break;
	case 11:
	    mvaddstr(11, cardinx*15+1, "J ");
	    mvaddstr(14, cardinx*15+6, "JJ");
	    mvaddstr(17, cardinx*15+10, "J ");
	    break;
	case 12:
	    mvaddstr(11, cardinx*15+1, "Q ");
	    mvaddstr(14, cardinx*15+6, "QQ");
	    mvaddstr(17, cardinx*15+10, "Q ");
	    break;
	case 13:
	    mvaddstr(11, cardinx*15+1, "K ");
	    mvaddstr(14, cardinx*15+6, "KK");
	    mvaddstr(17, cardinx*15+10, "K ");
	    break;
	default:
	    mvaddch(11, cardinx*15+1, '0' + value[cardinx]);
	    mvaddch(11, cardinx*15+2, ' ');
	    mvaddch(14, cardinx*15+6, '0' + value[cardinx]);
	    mvaddch(14, cardinx*15+7, '0' + value[cardinx]);
	    mvaddch(17, cardinx*15+10, '0' + value[cardinx]);
	    mvaddch(17, cardinx*15+11, ' ');
	    break;
	}
    }
refresh();
}
SHAR_EOF
fi
if test -f 'display_val.c'
then
	echo shar: "will not over-write existing file 'display_val.c'"
else
cat << \SHAR_EOF > 'display_val.c'
/*LINTLIBRARY*/

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * display_val.c - places the value of the hand above the displayed cards.
 * Also, this routine will return the number of coins the hand is worth.
 *
 * Ok, ok, the name isn't the greatest. But hey, its the best I could come
 * up with.
 */

#include	"hand_value.h"
#include	"vid_curses.h"
#include	"vid_poker.h"

int	display_val(hand_value)
int	hand_value;
{
int	value;			/* payoff value of this hand	*/

switch ( hand_value )
    {
    case PAIR:
	mvaddstr(9, 29, "   ONE PAIR    ");
	value=0;
	break;
    case JACKSOR:
	mvaddstr(9, 29, "JACKS OR BETTER");
	value=1;
	break;
    case TWOPAIR:
	mvaddstr(9, 29, "   TWO PAIR    ");
	value=2;
	break;
    case TRIPS:
	mvaddstr(9, 29, "THREE OF A KIND");
	value=3;
	break;
    case STRAIGHT:
	mvaddstr(9, 29, "   STRAIGHT    ");
	value=4;
	break;
    case FLUSH:
	mvaddstr(9, 29, "    FLUSH      ");
	value=5;
	break;
    case FULLHOUSE:
	mvaddstr(9, 29, "  FULL HOUSE   ");
	value=8;
	break;
    case FOUR:
	mvaddstr(9, 29, " FOUR OF A KIND");
	value=25;
	break;
    case STRAIGHTFLUSH:
	mvaddstr(9, 29, " STRAIGHT FLUSH");
	value=50;
	break;
    case ROYALFLUSH:
	mvaddstr(9, 29, "   ROYAL FLUSH ");
	value=250;
	break;
    default:
	mvaddstr(9, 29, "  NO PAIR      ");
	value=0;
    }
refresh();
return(value);
}
SHAR_EOF
fi
if test -f 'draw.c'
then
	echo shar: "will not over-write existing file 'draw.c'"
else
cat << \SHAR_EOF > 'draw.c'
/*LINTLIBRARY*/

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * draw.c - Select which card to hold (You've got to know when to hold-um, ..
 */

#include	"vid_local.h"
#include	"vid_curses.h"
#include	"vid_poker.h"

extern	int	bet;
extern	int	credits;

void	draw(deck, value, suite)
int	*deck,
	*value;
char	**suite;
{
int	count,		/* count of cards to be drawn	*/
	index,		/* loop index			*/
	win,		/* amount won on hand		*/
	key = -1,	/* keys pressed during draw	*/
	draw_card=5,	/* The first draw card		*/
	hold[5];	/* mark the cards help		*/

for (index=0; index < 5; ++index)
    hold[index] = 0;

mvaddstr(19, 0, "\t\t\t\t\t\t\t\t\t\t");
mvaddstr(21, 0, "Keys 1-5 will hold/cancel cards, space/return to draw:");
refresh();
while ( key != ' ' && key != '\r' )
    {
    if( (key=mvgetch(21,56)) >= '0' && key <= '5' )
	{
	addstr("\010 ");
	move(19, 4+(15 * ((key - '0')-1)));
	if ( hold[(key - '0') - 1] )
	    {
	    addstr("    ");
	    hold[(key - '0' -1) ] = 0;
	    }
	else
	    {
	    addstr("HOLD");
	    hold[ (key - '0' -1) ] = 1;
	    }
	}
    else
    if ( key != '\r' && key != ' ' )
	{
	putchar('\007');
	fflush(stdout);
	}
    refresh();
    }

/* cards selected, now draw */
count=0;
for(index=0; index < 5; ++index)
    if ( hold[index] )
	++count;
count = 5 - count;

deal(deck, count);
setup_deck(deck, value, suite, count);

/* Replace the discarded cards */
for( index=0; index < 5 && count; ++index )
    {
    if ( hold[index] == 0 )		/* card NOT held */
	{
	value[index] = value[draw_card];
	suite[index] = suite[draw_card++];
	--count;
	}
    }
display_hand(value, suite, 5);
sort(value, suite, 5);
win = bet * display_val(id_hand(value, suite));
credits += win;
mvprintw(22, 65, "Credits %-6d     ", credits);
mvprintw(23, 65, "Winner  %-6d     ", win);
refresh();
}
SHAR_EOF
fi
if test -f 'id_hand.c'
then
	echo shar: "will not over-write existing file 'id_hand.c'"
else
cat << \SHAR_EOF > 'id_hand.c'
/*LINTLIBRARY*/

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * id_hand.c - Determins what value the hand is. I suppose it could be
 * optimized further, but hey - how fast can you play this puppy?
 */

#include	"vid_poker.h"
#include	"vid_extern.h"
#include	"hand_value.h"

int	id_hand(value, suite)
int	*value;
char	**suite;
{
int	flush		= FALSE,
	straight	= FALSE,
	pair		= FALSE,
	jacksor 	= FALSE,
	twopair		= FALSE,
	trips		= FALSE,
	fullhouse	= FALSE,
	four		= FALSE,
	straightflush	= FALSE,
	royalflush	= FALSE;

int	card;		/* loop variable used while checking hand	*/
char	*check;		/* pointer in suite - flush checking		*/

do
    {		/* one pass only. a break may exit before its done	*/
    /* check the first five cards only */

    /* Flush ? */
    flush=TRUE;
    check = suite[0];
    for ( card=1; card < 5; ++card )
	{
	if ( strcmp((char *)suite[card], check) )
	    {
	    flush=FALSE;
	    break;
	    }
	}

    /* Straight */
    straight=FALSE;
    straightflush=FALSE;
    royalflush=FALSE;
    if ( value[0] == value[1]-1 && value[0] == value[2]-2
	&& value[0] == value[3]-3 && value[0] == value[4]-4 )
	straight=TRUE;;

    /* Ace high straight/ royal flush */
    if ( value[0] == 1 && value[1] == 10 && value[2] == 11
	&& value[3] == 12 && value[4] == 13 )
	{
	if ( flush )
	    {
	    straight=FALSE;
	    flush=FALSE;
	    royalflush=TRUE;
	    break;		/* do */
	    }
	else
	    {
	    straight=TRUE;;
	    }
	}

    /* Straight flush */
    if ( straight && flush )
	{
	straight=FALSE;
	flush=FALSE;
	straightflush=TRUE;
	/* return; */
	}

    if ( straight || flush || straightflush )
	break;		/* do */

    /* Pair */
    pair=FALSE;
    for ( card=0; card < 4; ++card )
	{
	if (value[card]==value[card+1])
	    {
	    pair=TRUE;
	    break;
	    }
	}

    /* Jacks or better */
    jacksor=FALSE;
    if ( pair && (value[card] == 1 || value[card] >= 11) )
	{
	pair=FALSE;
	jacksor=TRUE;
	}

    /* Trips */
    trips=FALSE;
    if ( (pair || jacksor) && card < 3 && value[card] == value[card+2] )
	{
	pair=FALSE;
	jacksor=FALSE;
	trips=TRUE;
	}

    /* Four of a kind */
    four=FALSE;
    if ( trips && card < 2 && value[card] == value[card+3] )
	{
	trips=FALSE;
	four=TRUE;
	break;	/* do */
	}

    /* two pair */
    twopair=FALSE;
    if ( pair || jacksor )
	for (card += 2; card < 4; ++card )
	    if (value[card]==value[card+1])
		{
		pair=FALSE;
		jacksor=FALSE;
		twopair=TRUE;
		break;
		}

    /* full house */
    fullhouse=FALSE;
    if ( twopair && card == 2 && value[3] == value[4] )
	{
	twopair=FALSE;
	fullhouse=TRUE;
	break;	/* do */
	}

    if ( trips && card == 0 && value[3] == value[4] )
	{
	trips=FALSE;
	fullhouse=TRUE;
	break;	/* do */
	}
    }
while ( FALSE );

/* return the value of the hand */
if ( flush )
    return(FLUSH);
if ( straight )
    return(STRAIGHT);
if ( straightflush )
    return(STRAIGHTFLUSH);
if ( royalflush )
    return(ROYALFLUSH);
if ( pair )
    return(PAIR);
if ( jacksor )
    return(JACKSOR);
if ( twopair )
    return(TWOPAIR);
if ( trips )
    return(TRIPS);
if ( four )
    return(FOUR);
if ( fullhouse )
    return(FULLHOUSE);
else
    return(0);
}
SHAR_EOF
fi
if test -f 'main.c'
then
	echo shar: "will not over-write existing file 'main.c'"
else
cat << \SHAR_EOF > 'main.c'
/*LINTLIBRARY*/

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * main for "video_poker" - just like the ones in Nevada.
 * Jay Konigsberg
 * jak@sactoh0 - pacbel!sactoh0!jak
 */

#include	"vid_local.h"
#include	<signal.h>
#include	"vid_curses.h"
#include	"vid_poker.h"

int		bet,
		credits;

void	main()
{
int	deck[10],	/* The random numbers as they were generated	*/
	value[10],	/* The card values - A, 2 ... 12=Q, 13=K	*/
	loop;		/* loop while bet is selected			*/
char	*suite[10];	/* Corasponding suites (Spades, Hearts, ...	*/
int	cardinx;	/* Just a loop variable				*/

credits=0;
rawmode();		/* set up char-at-a-time processing		*/
signal(SIGINT, cleanup);/* trap inturrepts (also in rawmode)		*/

initscr();
payoff_val(0);		/* Put the payoff values on the screen */

for (;;)
    {
    for (cardinx=0; cardinx<10; ++cardinx)
	{
	deck[cardinx] = 0;
	value[cardinx] = 0;
	suite[cardinx] = (char *)0;
	}
    bet = 0;
    loop = TRUE;
    while (loop)
	{
	mvaddstr(21,0,"B/b=bet one credit, M/m=bet max credits, Q/q=quit?\t\t");
	move(21,51);
	refresh();
	switch (getch())
	    {
	    case '\n':
	    case '\r':
		loop=FALSE;
		break;
	    case 'q':
	    case 'Q':
	    case 'n':
	    case 'N':
		loop=FALSE;
		cleanup();
		break;
	    case 'M':
	    case 'm':
	    case ' ':
		loop=FALSE;
		credits -= (5 - bet);
		bet = 5;
		move(21,65);
		printw("Bet     %-6d", bet);
		payoff_val(bet); /* Put the payoff values on the screen */
		break;
	    case 'b':
	    case 'B':
		++bet;
		if ( bet == 5 )
		    loop=FALSE;
		else
		    loop=TRUE;
		payoff_val(bet); /* Put the payoff values on the screen */
		move(21,65);
		printw("Bet     %-6d", bet);
		--credits;
		break;
	    }
	mvprintw(22, 65, "Credits %-5d    ", credits);
	refresh();;
	if (bet == 0)
	    loop=TRUE;
	}
    deal(deck, 5);
    setup_deck(deck, value, suite, 5);
    sort(value, suite, 5);
    display_hand(value, suite, 5);
    (void)display_val(id_hand(value, suite));
    draw(deck, value, suite);
    }
/*NOTREACHED*/
}
SHAR_EOF
fi
if test -f 'payoff_val.c'
then
	echo shar: "will not over-write existing file 'payoff_val.c'"
else
cat << \SHAR_EOF > 'payoff_val.c'
/*LINTLIBRARY*/

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * payoff_val.c - dumb routine to show the payoffs
 */

#include	"vid_curses.h"
#include	"vid_poker.h"

void	payoff_val(bet)
int bet;
{
if ( bet == 0 )
    {
    mvaddstr(1, 23, "VIDEO POKER - Standard Nevada odds");
    mvaddstr(3, 10, "Jacks or better    1");
    mvaddstr(4, 10, "Two Pair           2");
    mvaddstr(5, 10, "Three of a kind    3");
    mvaddstr(6, 10, "Straight           4");
    mvaddstr(7, 10, "Flush              5");
    mvaddstr(3, 45, "Full House         8");
    mvaddstr(4, 45, "Four of a kind    25");
    mvaddstr(5, 45, "Straight flush    50");
    mvaddstr(6, 45, "Royal flush      250");
    }
else
    {
    mvprintw(3, 27, "%4d", bet);
    mvprintw(4, 27, "%4d", bet * 2);
    mvprintw(5, 27, "%4d", bet * 3);
    mvprintw(6, 27, "%4d", bet * 4);
    mvprintw(7, 27, "%4d", bet * 5);
    mvprintw(3, 62, "%4d", bet * 8);
    mvprintw(4, 62, "%4d", bet * 25);
    mvprintw(5, 62, "%4d", bet * 50);
    mvprintw(6, 62, "%4d", bet * 250);
    }
}
SHAR_EOF
fi
if test -f 'rawmode.c'
then
	echo shar: "will not over-write existing file 'rawmode.c'"
else
cat << \SHAR_EOF > 'rawmode.c'

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * rawmode.c - enter character at a time processing. I ripped this off
 * from one of my other programs because the one in curses didn't work
 * the way _I_ wanted :-)
 */

#include	<stdio.h>
#include	<termio.h>
#include	<signal.h>
#include	"vid_extern.h"
#include	"vid_local.h"

extern	int	errno;

/* Global for interrupt routine: cleanup() */
struct	  termio  ttyset;	/* terminal settings */
unsigned  short   c_lflag_hold;	/* hold original values for reset */
unsigned  char    VEOF_hold;	/* hold original value for reset */

/*
 *enter raw mode
 */
void	rawmode()
{
if ( ioctl(0, TCGETA, &ttyset) == -1 )
    {
    fprintf(stderr, "ioctl: error=%d\n", errno);
    (void)exit(2);
    }
c_lflag_hold=ttyset.c_lflag;
VEOF_hold = ttyset.c_cc[4];

ttyset.c_cc[4] = (unsigned char)1;
ttyset.c_lflag &= ~(ICANON | ECHO);

if ( ioctl(0, TCSETAW, &ttyset) == -1 )
    {
    fprintf(stderr, "ioctl: error=%d\n",errno);
    }
signal(SIGINT, cleanup);
}
SHAR_EOF
fi
if test -f 'setup_deck.c'
then
	echo shar: "will not over-write existing file 'setup_deck.c'"
else
cat << \SHAR_EOF > 'setup_deck.c'

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * setup_deck.c - converts the random numbers into 1-13 + suite. Yes, I know
 * I don't really need to use a char string for the suite. But it worked well
 * in the first version and I didn't ever get around to changing it. If it
 * bugs you - fix it and enjoy.
 */

#include	"vid_poker.h"
#include	"vid_extern.h"

void	setup_deck(deck, value, suite, count)
int	*deck,
	*value;
char	**suite;
int	count;
{
int	cardinx=0;

if ( deck[5] == 0 )
    {
    cardinx=0;
    }
else
    {
    cardinx=5;
    count += 5;
    }

for(; cardinx < count; ++cardinx)
    {
    /* Set the suite and card value */
    if ( deck[cardinx] > 39 )
	{
	suite[cardinx]="Spades";
	value[cardinx] = deck[cardinx] - 39;
	}
    else
    if ( deck[cardinx] > 26 )
	{
	suite[cardinx]="Diamonds";
	value[cardinx] = deck[cardinx] - 26;
	}
    else
    if ( deck[cardinx] > 13 )
	{
	suite[cardinx]="Hearts";
	value[cardinx] = deck[cardinx] - 13;
	}
    else
	{
	suite[cardinx]="Clubs";
	value[cardinx] = deck[cardinx];
	}
    }
}
SHAR_EOF
fi
if test -f 'sort.c'
then
	echo shar: "will not over-write existing file 'sort.c'"
else
cat << \SHAR_EOF > 'sort.c'

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * sort.c - sorts the hand into acending order. This is required for the
 * id_hand routine.
 *
 * Hmm, considering that this is a bubble sort, I really wonder how
 * approporiate that Copyright up there is? Oh well, I guess I'll leave
 * it there. Say, does this mean I own the bubble sort and everyone out
 * there gets to pay me royalties :-)
 */

#include	"vid_poker.h"

void	sort(value, suite, count)
int	*value;
char	**suite;
int	count;
{
int	cardinx1,
	cardinx2,
	temp1;
char	*temp2;

for ( cardinx1=0; cardinx1<count; ++cardinx1)
    for (cardinx2=cardinx1+1; cardinx2<count; ++cardinx2)
	if ( value[cardinx1] > value[cardinx2] )
	    {
	    temp1=value[cardinx2];
	    value[cardinx2] = value[cardinx1];
	    value[cardinx1] = temp1;

	    temp2=suite[cardinx2];
	    suite[cardinx2] = suite[cardinx1];
	    suite[cardinx1] = temp2;
	    }
}
SHAR_EOF
fi
if test -f 'hand_value.h'
then
	echo shar: "will not over-write existing file 'hand_value.h'"
else
cat << \SHAR_EOF > 'hand_value.h'

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * hand_value.h - just some tokens to make life simpler.
 */

#define	NOPAIR		0000
#define	PAIR		0001
#define	JACKSOR		0002
#define	TWOPAIR		0004
#define	TRIPS		0010
#define	STRAIGHT	0020
#define	FLUSH		0040
#define	FULLHOUSE	0100
#define	FOUR		0200
#define	STRAIGHTFLUSH	0400
#define	ROYALFLUSH	1000
SHAR_EOF
fi
if test -f 'vid_curses.h'
then
	echo shar: "will not over-write existing file 'vid_curses.h'"
else
cat << \SHAR_EOF > 'vid_curses.h'

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * vid_curses.h - I just like to reduce the number of complier/lint
 * complaints.
 */

#include	<curses.h>

extern	WINDOW	*initscr();

extern	int	endwin();
extern	int	wmove();
extern	int	waddstr();
extern	int	waddch();
extern	int	wrefresh();
extern	int	printw();
extern	int	mvprintw();
extern	int	waddstr();
extern	int	wgetch();
extern	int	wclrtoeol();
extern	int	wmove();
extern	int	waddstr();
extern	int	waddch();
extern	int	wrefresh();
SHAR_EOF
fi
if test -f 'vid_extern.h'
then
	echo shar: "will not over-write existing file 'vid_extern.h'"
else
cat << \SHAR_EOF > 'vid_extern.h'

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * vid_extern.h - external function declarations for vider_poker
 */

extern	int	printf();
extern	int	fprintf();
extern	int	puts();
extern	int	fputs();
extern	int	strlen();
extern	int	atoi();
extern	int	ioctl();
extern	int	strcmp();
extern	char	*strchr();
extern	int	exit();
SHAR_EOF
fi
if test -f 'vid_local.h'
then
	echo shar: "will not over-write existing file 'vid_local.h'"
else
cat << \SHAR_EOF > 'vid_local.h'

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * vid_local.h - Local function declarations
 */

void	main(),			/* Main driver			*/
	deal(),			/* deal cards - uses drand48	*/
	setup_deck(),		/* determin cards and suites	*/
	sort(),			/* sorts A-low to K-high	*/
	display_hand(),		/* puts the hand on the screen	*/
	payoff_val(),		/* display the value of hands	*/
	rawmode(),		/* set for char processing	*/
	draw();			/* Select which cards to keep	*/

int	id_hand(),		/* identifys value of the cards	*/
	display_val();		/* Displays what the hand is	*/

extern	int	cleanup();	/* Cleanup curses and raw mode	*/
SHAR_EOF
fi
if test -f 'vid_poker.h'
then
	echo shar: "will not over-write existing file 'vid_poker.h'"
else
cat << \SHAR_EOF > 'vid_poker.h'

/*
 * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
 *
 * Permission to use, copy, modify, and distribute this  software  and  its
 * documentation is hereby  granted,  provided  that  the  above  copyright
 * notice appear in all copies  and that  both  the  copyright  notice  and
 * this permission notice appear in supporting documentation. This software
 * is provided "as is" without express or implied  warranty.  However,  the
 * author retains all Copyright priviliges and rights  to  renumeration  if
 * this software is sold.
 *
 * Also, and very important. This game is for recrecation ONLY and is NOT
 * to be used for gambling in any way. 
 */

/*
 * vid_poker.h - Hmm, this is a rather meek .h file. I used to have more
 * in it -- really it did.
 */

#include	<stdio.h>

#ifndef TRUE
#define		TRUE	1
#define		FALSE	0
#endif
SHAR_EOF
fi
if test -f 'Makefile'
then
	echo shar: "will not over-write existing file 'Makefile'"
else
cat << \SHAR_EOF > 'Makefile'
#
# Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
#
# Permission to use, copy, modify, and distribute this  software  and  its
# documentation is hereby  granted,  provided  that  the  above  copyright
# notice appear in all copies  and that  both  the  copyright  notice  and
# this permission notice appear in supporting documentation. This software
# is provided "as is" without express or implied  warranty.  However,  the
# author retains all Copyright priviliges and rights  to  renumeration  if
# this software is sold.
#
# Also, and very important. This game is for recrecation ONLY and is NOT
# to be used for gambling in any way. 
#

# 
# Makefile for video_poker
#

# Select complier and options
#CC=gcc
#CFLAGS=-O -traditional -Wall

CC=cc
# Xenix - note, these work on xenix 2.2.3 & 2.3.1, but not on 2.3.2 - bizzare
#CFLAGS=-g -M2m
#CFLAGS=-O -M2m
# SysV
CFLAGS=-O

# Select libraries
# Xenix
#LIBS=-ltcap -ltermlib
# SysV
LIBS=-lcurses

# Object files
OBJS=sort.o display_hand.o display_val.o rawmode.o cleanup.o payoff_val.o \
deal.o id_hand.o draw.o setup_deck.o main.o 

# Exectuable
EXEC=video

$(EXEC): $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $(EXEC)

main.o:		main.c vid_local.h vid_curses.h vid_poker.h
deal.o:		deal.c vid_poker.h
id_hand.o:	id_hand.c vid_poker.h vid_extern.h hand_value.h
draw.o:		draw.c vid_poker.h vid_curses.h vid_local.h
setup_deck.o:	setup_deck.c vid_extern.h vid_poker.h
cleanup.o:	cleanup.c vid_extern.h
display_hand.o:	display_hand.c vid_poker.h vid_extern.h vid_curses.h
display_val.o:	display_val.c hand_value.h vid_curses.h vid_poker.h
payoff_val.o:	payoff_val.c vid_poker.h vid_curses.h
rawmode.o:	rawmode.c vid_extern.h vid_local.h
sort:		sort.c vid_poker.h


clean:
	rm -f $(OBJS) core make.out lint.out vidpoker.tar*
lint:
	lint [a-z][a-z]*.c 2>&1 | tee lint.out
tar:
	tar cvf vidpoker.tar *.[ch] Makefile
pack: tar
	pack vidpoker.tar
compress: tar
	compress vidpoker.tar
SHAR_EOF
fi
exit 0
#	End of shell archive
-- 
-------------------------------------------------------------
Jay @ SAC-UNIX, Sacramento, Ca.   UUCP=...pacbell!sactoh0!jak
If something is worth doing, it's worth doing correctly.