[comp.sources.games] v06i072: mex - yet another version of Tetris for the Sun, Part01/02

games@tekred.CNA.TEK.COM (05/17/89)

Submitted-by: Glenn Kreisel <glenn@midget.towson.edu>
Posting-number: Volume 6, Issue 72
Archive-name: mex/Part01

	[I played this on a Sun 3/60, OS 3.5 and it seems to work well.
	 I especially like the cute pictures on the blocks.  -br]

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 2)."
# Contents:  README MANIFEST mex.c mex_look.c mex_scores.c
#   still_block.icon
# Wrapped by billr@saab on Wed May 17 08:33:13 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1872 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X/**************************************************************************
X	Mex was copyrighted by Glenn Kreisel on April 1989.
X
X   This program may be redistributed without fee as long as this copyright
X   notice is intact.
X
X==> PLEASE send comments and bug reports to one of the following addresses:
X
X	   ARPA-Internet: glenn@midget.towson.edu			
X	   BITNET: S72QKRE@TOWSONVX.BITNET
X
X
X**************************************************************************/
X
X		Mex is an arcade style game that enhances your spatial
X		awareness.  In short, the object is to not let the rows
X		build up at the bottom of the screen.  Very simular to a
X		popular arcade style game called Tetris.  Information during
X		game execution will explain which control keys are used.
X
X
X
X
X
XHow to install Mex
X
X1)  Unpack all of the archive files into the same directory.
X    This should be the directory of final residence for the executable.
X
X2)  While in csh, type: **
X
X       printenv
X
X    and be sure that the environment variable PWD appears and is set to
X    the current directory; otherwise, you must modify the Makefile, defining
X    PWD explicitly as the full path to the directory in which you have
X    unpacked the files.
X
X3)  Type the following command:
X
X       % make
X	or
X	   % make install
X
X5)  To clean up, you may remove all but the following files:
X
X       mex
X       info.file
X       mex.hiscores
X
X6)  To play Mex simply type:
X
X       % mex 
X
XNOTES:
X    You can just press the "info" button on the right
X    control panel to display the info.  You are welcome to
X    redefine the blocks used in the game.  They are standard
X    cursor (16x16) icons created with the icon editor.
X
X-------------
X** I have modified the Makefile to use an explicit path, as this
Xwill generally be installed in a common lib dir, rather than the
Xdirectory it is unpacked in. <billr@saab.CNA.TEK.COM>
END_OF_FILE
if test 1872 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(747 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	
X Makefile                   2	
X README                     1	
X block1.icon                2	
X block2.icon                2	
X block3.icon                2	
X block4.icon                2	
X block5.icon                2	
X block6.icon                2	
X block7.icon                2	
X hiscore.icon               2	
X info.file                  2	
X mex.c                      1	
X mex.h                      2	
X mex.hiscores.uu            2	
X mex.icon                   2	
X mex_look.c                 1	
X mex_scores.c               1	
X objects.h                  2	
X screens.h                  2	
X still_block.icon           1	
END_OF_FILE
if test 747 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'mex.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mex.c'\"
else
echo shar: Extracting \"'mex.c'\" \(17519 characters\)
sed "s/^X//" >'mex.c' <<'END_OF_FILE'
X/*   ALL code in this program may be used for personal use */
X/*   and this program may be distributed as long as this copyright */
X/*   heading is attached to each source code file.  Distribution must  */
X/*   be done FREE of charge................ */
X/*                                           Glenn Kreisel */
X/*				             glenn@midget.towson.edu */		
X/*					     S72QKRE@TOWSONVX.BITNET */
X#include "mex.h" 
Xextern Panel_item rows_left_string;
Xextern ring_bell();
Xextern Panel_item level_num;
Xextern Panel_item score_string,rows_string;
Xextern Panel_item level_string;
Xextern Panel right_panel;
Xextern Panel_item restart_button,start_button;
Xextern void do_mex_look();
Xextern void read_in_scores();
Xextern void write_out_scores();
Xextern void insert_score();
Xextern void freeze_proc();
Xextern char   **define_2d();
X
Xextern Frame           frame;
Xextern Panel_item      show_next;
XPixfont        *bold, *cour;
Xextern Canvas          game_canvas;
X
X
Xstatic short    box[] = {
X#include "block1.icon"
X};
Xmpr_static(block, block_icon_width, block_icon_height, 1, box);
X
Xstatic short    box1[] = {
X#include "block2.icon"
X};
Xmpr_static(block2, block_icon_width, block_icon_height, 1, box1);
X
Xstatic short    box2[] = {
X#include "block3.icon"
X};
Xmpr_static(block3, block_icon_width, block_icon_height, 1, box2);
X
Xstatic short    box3[] = {
X#include "block4.icon"
X};
Xmpr_static(block4, block_icon_width, block_icon_height, 1, box3);
X
Xstatic short    box4[] = {
X#include "block5.icon"
X};
Xmpr_static(block5, block_icon_width, block_icon_height, 1, box4);
X
Xstatic short    box5[] = {
X#include "block6.icon"
X};
Xmpr_static(block6, block_icon_width, block_icon_height, 1, box5);
X
Xstatic short    box6[] = {
X#include "block7.icon"
X};
Xmpr_static(block7, block_icon_width, block_icon_height, 1, box6);
X
Xstruct object_struct {
X	struct object_struct *next_pointer;
X	Pixrect        *block_type;
X	char            x[4];
X	char            y[4];
X};
X
X#include "objects.h"
X
Xstruct object_struct *objects[7] = {&ltred_piece, &ltgreen_piece,
X	&yellow_piece, &blue_piece,
X	&white_piece, &red_piece, &green_piece
X};
Xstruct object_struct *current_object;
X
Xint key=0;
X
Xchar  black[char_width * char_width];
X
Xstruct xy {
X	int	x;
X	int	y;
X	};
X
Xstruct xy still_blocks[22];
Xint	num_stationary;
X
Xstatic short    still_box[] = {
X#include "still_block.icon"
X};
Xmpr_static(still_block_type, block_icon_width, block_icon_height, 1, still_box);
X
X
X#include "screens.h"
X
Xchar    **screen;
XPixwin  *pw;
XPixwin	*right_panel_pw;
Xint            frozen=0, top_of = 0, key_up = 0, fast = 0,score=0,level=0,sound_on=0;
Xint		c,rows_needed=0,num_rows=0,rows=0,restart=0,drop_score,DELAY,sun3_delay;
Xint		speed,speed_add=0,something_on_screen=0;
XPixrect        *black_pr;
X
X
X/* /userb/shirley/icons/tetrix 64x64 */
X
Xmain(argc,argv)
Xint	argc;
Xchar **argv;
X{
X	int             i, j;
X	Event           event;
X	char            num_str[5];
X	Rect            start;
X
X	DELAY=5;
X	sun3_delay=0;
X	if(system("sparc")!=0) {sun3_delay=3; DELAY=1;}
X
X	srand((int)time(0));
X
X	if (!(bold = pf_open("/usr/lib/fonts/fixedwidthfonts/gallant.r.19")))
X		bold = pf_default();
X
X	if (!(cour = pf_open("/usr/lib/fonts/fixedwidthfonts/cour.r.24")))
X		cour = pf_default();
X
X	for (i = 0; i < char_height * char_width; i++)
X		black[i] = 255;
X
X	black_pr = mem_point(char_width, char_height, 1, black);
X
X
X	screen = define_2d(width + 2, height+1);
X	do_mex_look(&argc,argv);
X	for(i=1;i<argc;i++)
X	{
X	if(strcmp(argv[i],"-SUN3")==0 || strcmp(argv[i],"-sun3")==0) {sun3_delay=3; DELAY=1;}
X	if(strcmp(argv[i],"-so")==0) sound_on=1;
X	}
X	right_panel_pw=(Pixwin *)window_get(right_panel,WIN_PIXWIN);
X	window_set(frame,WIN_SHOW,TRUE,0);
X
X	(void) notify_dispatch();
X	restart=GAME_OVER;
X	do
X	{
X	while(restart!=GAME_OVER && restart!=EXIT_GAME) 
X	{
X		restart=Do_game();
X		if(restart==GAME_OVER)
X		insert_score(score,rows);
X
X		panel_set(start_button,PANEL_SHOW_ITEM,TRUE,0);
X		panel_set(restart_button,PANEL_SHOW_ITEM,FALSE,0);
X
X	}
X	restart=GAME_OVER;
X	(void) notify_dispatch();
X	usleep(200);
X	} while(restart!=EXIT_GAME);
X
X	free(*screen);
X	free(screen);
X	exit(0);
X}
X
Xchar          **
Xdefine_2d(wid, hei)
X	int             wid, hei;
X{
X	char           *a;
X	int             i;
X	char          **aa;
X
X	a = (char *) calloc(wid * hei, sizeof(char));
X	aa = (char **) calloc(hei, sizeof(char *));
X	for (i = 0; i < hei; i++) {
X		aa[i] = a;
X		a += wid;
X	}
X
X	return (aa);
X}
X
X
Xclear_screen()
X{
X	Rect r;
X	int             x, y;
X	for (y = 0; y < height; y++)
X		for (x = 0; x < width+2; x++)
X			screen[y][x] = 0;
X	for (x = 0; x < width + 2; x++)
X		{
X		screen[height][x] = 1;
X		screen[0][x]=1;
X		}
X
X	for (x = 0; x < height; x++) {
X		screen[x][width + 1] = 1;
X		screen[x][0] = 1;
X	}
X
X	do_split_screen();
X	something_on_screen=0;
X	top_of=255;
X	if(level==10) {level=0; speed_add++;}
X	x=level;
X	rows_needed=10;
X	speed=13;
X
X	pw_batch_on(pw);
X	if(x==1 && speed_add>0)
X		{
X			do_GMK();
X			speed=9;
X			rows_needed=17;
X		}
X	if(x==2 && speed_add>0)
X		{
X			do_CLW();
X			speed=10;
X			rows_needed=16;
X		}
X
X	if(x==3)
X		{
X			if(speed_add==0){
X			num_stationary=do_columns();
X			display_stationary_stuff();
X			}
X			else do_SMILE();
X			rows_needed=13;
X			speed=11;
X		}
X
X	if(x==4)
X		{
X			num_stationary=pick_random_station_pos(4);
X			display_stationary_stuff();
X			rows_needed=15;
X			speed=12;
X		}
X	if(x==5)
X		{
X			num_stationary=pick_random_station_pos(5);
X			display_stationary_stuff();
X			speed=10;
X			rows_needed=12;
X		}
X	if(x==6)
X		{
X			do_triangle();
X			rows_needed=11;
X			speed=10;
X		}
X	if(x==7)
X		{
X			do_screen10();
X			rows_needed=13;
X			speed=10;
X		}
X
X	if(x==8)
X		{
X			do_side_triangles();
X	speed=8;
X
X		}
X	if(x==9)
X		{
X			do_hex();
X		}
X
X	if(speed>speed_add) speed=(speed-(speed_add*2))+sun3_delay;
X	bump_level(0);
X	pw_batch_off(pw);
X}
X
Xdo_split_screen()
X{
Xregister i,x;
XRect r;
X	pw_get_region_rect(pw,&r);
X
Xif(something_on_screen)
X	{
X	x=r.r_width >> 1;
X	for(i=0;i<x;i++)
X	{
X		pw_batch_on(pw);
X		pw_copy(pw,0,0,x-i-1,r.r_height,PIX_SRC,pw,1,0);
X		pw_copy(pw,x+i+1,0,r.r_width-(x+i)-1,r.r_height,PIX_SRC,pw,x+i,0);
X		pw_batch_off(pw);
X	}
X     }
X
X	pw_batch_on(pw);
X	pw_writebackground(pw,0,0,r.r_width,r.r_height,PIX_SRC);
X	pw_vector(pw, 14, 0, 14, height * char_height, PIX_SRC, 3);
X	pw_vector(pw, (width + 1) * char_width, 0, (width + 1) * char_width, height * char_height, PIX_SRC, 3);
X
X	pw_replrop(pw, char_width, (height-1) * char_height,
X		   (width) * char_width, char_height,
X		   PIX_SRC , black_pr, 0, 0);
X	pw_batch_off(pw);
X/* Clear Show Next space in right panel */
X	pw_writebackground(right_panel_pw,20,25,
X		char_width*object_width,char_height*object_height,PIX_SRC);
X}
X
Xinit_screen()
X{
Xint	x;
X
X
X	score=num_rows=level=rows=0;
X	speed_add=0;  /* change this one now man */
X	level=(int)panel_get_value(level_num);
X	clear_screen();
X
X	bump_rows(0);
X	bump_score(0);
X	bump_level(0);
X	bump_rows_left();
X
X	restart=RUNNING;
X
X
X}
X
X
X
Xcheck_rot(x, y)
X	int             x, y;
X{
X	int             ob_x;
X
X	for (ob_x = 0; ob_x < object_width; ob_x++)
X		if (screen[1+y + current_object->next_pointer->y[ob_x]]
X		    [x + current_object->next_pointer->x[ob_x]] == 1)
X			return (0);
X	return (1);
X}
X
X
Xcheck_left(x, y)
X	int             x, y;
X{
X	int             ob_x;
X
X	for (ob_x = 0; ob_x < object_width; ob_x++)
X		if (screen[1+y + current_object->y[ob_x]][x + current_object->x[ob_x] - 1] == 1)
X			return (0);
X	return (1);
X}
X
Xcheck_right(x, y)
X	int             x, y;
X{
X	int             ob_x;
X
X	for (ob_x = 0; ob_x < object_width; ob_x++)
X		if (screen[1+y + current_object->y[ob_x]][x + current_object->x[ob_x] + 1] == 1)
X			return (0);
X	return (1);
X}
X
Xvoid my_directions(win,my_event)
XWindow win;
XEvent *my_event;
X{
Xint id=event_id(my_event);
X
X
X		if ((id==MS_LEFT || id=='j') &&
X		event_is_down(my_event)) {
X			key = 1;
X		} else if ((id==MS_RIGHT || id=='l') &&
X		event_is_down(my_event)) {
X			key = 2;
X		} else if ((id==MS_MIDDLE || id=='k') &&
X		event_is_down(my_event)) {
X			key = 3;
X		}  else if (id==' ' &&
X		event_is_down(my_event)) {
X			key = 4;
X		}
X}
X
Xint 
Xcheck_keys(x, y)
X	int             x, y;
X{
X int key_up;
X
X	for(key_up=0;key_up<(speed)*DELAY;key_up++) (void)notify_dispatch();
X
X	if (key == 1) {
X		key=0;
X		key_up = 1;
X		if (check_left(x, y))
X			x--;
X	} else if (key == 2) {
X		key=0;
X		key_up = 1;
X		if (check_right(x, y))
X			x++;
X	} else if (key == 3) {
X		key=0;
X		key_up = 1;
X		if (check_rot(x, y))
X			current_object = current_object->next_pointer;
X	} else if(key==4) {
X		key=0;
X		fast=1;
X		drop_score=height-y;
X		key_up=1;
X	}
X	while(frozen)
X		{
X		notify_dispatch();
X		usleep(200);
X		}
X
X	return (x);
X}
X
X
XDo_game()
X{
X	register x,y,ob_y,ob_x;
X	unsigned int    time_up, q, hit, value;
X	struct object_struct *already_got;
X	struct pr_subregion bound;
X
X	panel_set(start_button,PANEL_SHOW_ITEM,FALSE,0);
X	panel_set(restart_button,PANEL_SHOW_ITEM,TRUE,0);
X	pw = canvas_pixwin(game_canvas);
X
X	init_screen();
X	srand(rand());
X	already_got = objects[rand() % 7];
X	while (1) {
X		fast = hit = 0;
X		drop_score=1;
X
X		current_object = already_got;
X		already_got = objects[rand() % 7];
X		y = 0-current_object->y[0];
X		x = width >> 1;
X		value = (int) panel_get(show_next, PANEL_TOGGLE_VALUE, 0);
X		if (value)
X			for (ob_x = 0; ob_x < object_width; ob_x++)
X				pw_write(right_panel_pw,
X					 20+( already_got->x[ob_x]*char_width) ,
X				   25 +(already_got->y[ob_x]*char_height),
X					 block_icon_width, block_icon_height,
X					 PIX_SRC | PIX_DST,
X					 already_got->block_type, 0, 0);
X
X		if (!check_left(x+1, y))
X			break;
X
X		for (ob_x = 0; ob_x < object_width; ob_x++)
X			pw_write(pw,
X				 (x + current_object->x[ob_x]) * char_width,
X				 (y + current_object->y[ob_x]) * char_height,
X				 block_icon_width, block_icon_height,
X				 PIX_SRC | PIX_DST,
X				 current_object->block_type, 0, 0);
X
X
X		while (!hit) {
X			time_up = 0;
X			while (time_up < MOVES_PER_ROW && !hit) {
X				time_up++;
X				if ((time_up == MOVES_PER_ROW) && (hit = yadd(x, y)))
X					break;
X				pw_batch_on(pw);
X				/* blink_stationary_stuff(); */
X				for (ob_x = 0; ob_x < object_width; ob_x++)
X				    pw_write(pw,
X					(x + current_object->x[ob_x]) * char_width, 
X					(y + current_object->y[ob_x]) * char_height,
X					block_icon_width, block_icon_height,
X					PIX_SRC ^ PIX_DST,
X					current_object->block_type, 0, 0);
X
X					if(restart==NEW_GAME)
X						return(NEW_GAME);
X					if(restart==EXIT_GAME)
X						return(EXIT_GAME);
X
X				if ((!fast) && time_up == MOVES_PER_ROW) {
X					y++;
X				}
X				if (fast) 
X					y++;
X				 else
X					x = check_keys(x, y);
X				if(fast)
X					time_up=MOVES_PER_ROW-1;
X				for (ob_x = 0; ob_x < object_width; ob_x++) {
X					pw_write(pw, (x + current_object->x[ob_x]) * char_width, (y + current_object->y[ob_x]) * char_height,
X					block_icon_width, block_icon_height,
X						 PIX_SRC | PIX_DST, current_object->block_type, 0, 0);
X				}
X
X				pw_batch_off(pw);
X
X			}
X
X		}
X
X		if (top_of > y+current_object->y[0])
X			top_of = y+current_object->y[0];
X		bump_score(drop_score*5);
X		fill_in_pos(x, y);
X
X		if(level>6 || speed_add>0) do_maybe_on_top();
X		if(speed_add>0 || level>8) do_row_maybe(level);
X		ring_bell(50000,1);
X		if (value)
X			for (ob_x = 0; ob_x < object_width; ob_x++)
X				pw_write(right_panel_pw,
X					 20+( already_got->x[ob_x]*char_width) ,
X				   25 +(already_got->y[ob_x]*char_height),
X					 block_icon_width, block_icon_height,
X					 PIX_NOT(PIX_SRC) & PIX_DST, already_got->block_type, 0, 0);
X
X	}
X	pf_textbound(&bound,9,cour,"Game Over");
X
X		pw_writebackground(pw, 50+bound.pos.x, (height >> 1) * char_height+bound.pos.y, bound.size.x, bound.size.y,PIX_SRC);
X	pw_text(pw, 50, (height >> 1) * char_height, PIX_SRC, cour, "Game Over");
X	return(GAME_OVER);
X}
X
X
Xyadd(x, y)
X	int             x, y;
X{
X	int             ob_x;
X	for (ob_x = 0; ob_x < object_width; ob_x++)
X		if ((screen[2 + y + current_object->y[ob_x]][x + current_object->x[ob_x]]) == 1)
X			return (1);
X	return (0);
X}
X
X
Xfill_in_pos(x, y)
X	int             x, y;
X{
X	int             ob_x, i1, i;
X	something_on_screen=1;
X	for (ob_x = 0; ob_x < object_width; ob_x++) {
X		screen[1+y + current_object->y[ob_x]][x + current_object->x[ob_x]] = 1;
X	}
X	check_rows(y);
X}
X
Xbump_rows_left()
X{
Xchar dummy[8];
Xsprintf(dummy,"%d",rows_needed);
Xpanel_set_value(rows_left_string,dummy);
X}
Xbump_score(x)
Xint x;
X{
Xchar dummy[8];
Xscore+=x;
Xsprintf(dummy,"%d",score);
Xpanel_set_value(score_string,dummy);
X}
X
Xbump_rows(x)
Xint x;
X{
Xchar dummy[8];
Xrows+=x;
Xsprintf(dummy,"%d",rows);
Xpanel_set_value(rows_string,dummy);
X}
X
Xbump_level(x)
Xint x;
X{
Xchar dummy[8];
Xif(level!=MAX_LEVEL)
Xlevel+=x;
Xsprintf(dummy,"%d",(speed_add*10)+level+1);
Xpanel_set_value(level_string,dummy);
X}
X
Xmove_block_down(where)
X	int             where;
X{
X
X	unsigned int    i, i1;
X	char           *temp;
X
X
X	for (i = 0; i < 14; i++) {
X		pw_replrop(pw, char_width, where * char_height,
X			   (width) * char_width, char_height,
X			   PIX_SRC ^ PIX_DST, black_pr, 0, 0);
X		ring_bell(15000,1);
X		for (i1 = 0; i1 < 15000; i1++);
X	}
X	bump_rows(1);
X	bump_score(100);
X	pw_batch_on(pw);
X	for (i = where; i >= top_of; i--) {
X		pw_copy(pw, char_width, i * char_height, (width) * char_width, char_height, PIX_SRC, pw, char_width, (i - 1) * char_height);
X	}
X	pw_batch_off(pw);
X
X	temp = screen[where+1];
X	for (i = where+1; i > top_of+1; i--)
X		screen[i] = screen[i - 1];
X
X	screen[i] = temp;
X
X	for (i1 = 0; i1 < width + 2; i1++)
X		screen[i][i1] = 0;
X	screen[i][0] = 1;
X	screen[i][width + 1] = 1;
X	top_of++;
X	if((--rows_needed)==0)
X	{
X		bump_rows_left();
X		num_rows=0;
X		bump_level(1);
X		bump_score(top_of*5);
X		for (i = 0; i < top_of; i++) {
X		pw_replrop(pw, char_width, i * char_height,
X			   (width) * char_width, char_height,
X			   PIX_SRC ^ PIX_DST, black_pr, 0, 0);
X		for (i1 = 0; i1 < 10000; i1++);
X		}
X
X		pw_text(pw, 1*char_width, (height >> 1) * char_height,
X			PIX_SRC^PIX_DST, cour, "Low Level Bonus");
X		sleep(2);	
X		pw_text(pw, 1*char_width, (height >> 1) * char_height,
X			PIX_SRC^PIX_DST, cour, "Low Level Bonus");
X		for (i = top_of; i>0; i--) {
X		pw_replrop(pw, char_width, (i-1) * char_height,
X			   (width) * char_width, char_height,
X			   PIX_NOT(PIX_SRC) & PIX_DST, black_pr, 0, 0);
X		for (i1 = 0; i1 < 10000; i1++);
X		}
X		clear_screen();
X	}
X	bump_rows_left();
X
X
X}
X
X
Xcheck_rows(y)
X	int             y;
X{
X	int             got_one,i, x, ob_x, where;
X	where = 999;
X	got_one=0;
X	for (ob_x = 0; ob_x < object_width && top_of!=255; ob_x++) {
X		if (where != current_object->y[ob_x] + y) {
X			where = current_object->y[ob_x] + y;
X			for (x = 0; (x < width + 2) && (screen[where+1][x] == 1); x++);
X			if (x == width + 2)
X				{
X				move_block_down(where);
X				got_one++;
X				}
X		}
X	}
X	if(got_one>1) { 
X			bump_score(got_one*20);
X			}
X
X}
X
Xdisplay_stationary_stuff()
X{
Xint i;
Xsomething_on_screen=1;
Xfor(i=0;i<num_stationary;i++)
X	{
X	pw_write(pw, (still_blocks[i].x) * char_width,
X			(still_blocks[i].y) * char_height,
X			block_icon_width, block_icon_height,
X			PIX_SRC,&still_block_type, 0, 0);
X	if(top_of>still_blocks[i].y) top_of=still_blocks[i].y;
X	screen[still_blocks[i].y+1][still_blocks[i].x]=1;
X	}
X}
X
X
Xpick_random_station_pos(x)
Xint	x;
X{
Xint i,i1,per_row;
Xi1=0;
X
Xfor(i=0;i<x;i++)
X{
X	for(per_row=0;per_row<3;per_row++)
X	{
X	still_blocks[i1].x=2+((rand()>>8) % width-1);
X	still_blocks[i1++].y=(height-2)-i;
X	}
X}
Xreturn(i1);
X}
X
Xint do_columns()
X{
Xint i,i1;
Xi1=0;
X for(i=height-2;i>height-8;i--)
X	{
X		still_blocks[i1].x=1;
X		still_blocks[i1++].y=i;
X		still_blocks[i1].x=width;
X		still_blocks[i1++].y=i;
X
X	}
Xreturn(i1);
X}
X
Xdo_triangle()
X{
Xdo_read_in(screen9);
X}
X
Xdo_random_insert()
X{
Xint insert_row;
Xchar *temp;
Xint i,i1;
X
Xif (top_of<10 || top_of>height-3) return;
X	insert_row=((rand()>> 8) % ((height-1)-top_of))+top_of;
X	pw_batch_on(pw);
X	temp = screen[top_of];
X	for (i =top_of ; i <= insert_row; i++) {
X		pw_copy(pw, char_width, (i-1) * char_height, (width) * char_width, char_height, PIX_SRC, pw, char_width, (i) * char_height);
X		screen[i] = screen[i + 1];
X	}
X	screen[i] = temp;
X		pw_writebackground(pw, char_width, (i-1) * char_height, (width) * char_width, char_height,PIX_SRC) ;
X	pw_batch_off(pw);
X
X	
X	for (i1 = 0; i1 < width + 2; i1++)
X		screen[i][i1] = 0;
X	screen[i][0] = 1;
X	screen[i][width+1]=1;
X	for(i=0;i<6;i++)
X	{
X	still_blocks[0].x=1+(rand() % (width-1));
X	still_blocks[0].y=insert_row;
X	num_stationary=1;
X	(void)display_stationary_stuff();
X	}
X	for (i = 0; i < 14; i++) {
X		pw_replrop(pw, char_width, insert_row * char_height,
X			   (width) * char_width, char_height,
X			   PIX_SRC ^ PIX_DST, black_pr, 0, 0);
X		ring_bell(15000,1);
X		for (i1 = 0; i1 < 15000; i1++);
X	}
X	top_of--;
X}
Xdo_row_maybe(x)
Xint x;
X{
Xif(((rand()>> 8)%50)<(speed_add+1)*2) do_random_insert();
X}
X
Xdo_maybe_on_top()
X{
Xif(((rand()>> 8)%25)<(speed_add+1)*3) do_add_on_top();
X}
X
Xdo_add_on_top()
X{
Xint x,i,i1,column;
Xcolumn=1+((rand()>>8)%(width-1));
Xi=1;
Xwhile(screen[(++i)][column]==0);
Xstill_blocks[0].x=column;
Xstill_blocks[0].y=i-2;
Xnum_stationary=1;
X(void)display_stationary_stuff();
X	for (x = 0; x < 14; x++) {
X		pw_replrop(pw, column*char_width, (i-2) * char_height,
X			   char_width, char_height,
X			   PIX_SRC ^ PIX_DST, black_pr, 0, 0);
X		ring_bell(15000,1);
X		for (i1 = 0; i1 < 23000; i1++);
X	}
Xfor (x = 0; (x < width + 2) && (screen[i-1][x] == 1); x++);
X   if(x==width+2) move_block_down(i-2);
X}
X
Xdo_side_triangles()
X{
Xdo_read_in(screen4);
X}
X
Xdo_hex()
X{
Xdo_read_in(screen5);
X}
X
Xdo_screen10()
X{
Xdo_read_in(screen10);
X}
Xdo_GMK()
X{
Xdo_read_in(screen6);
X}
X
Xdo_CLW()
X{
Xdo_read_in(screen7);
X}
X
Xdo_SMILE()
X{
Xdo_read_in(screen8);
X}
X
Xdo_read_in(x)
Xchar	x[][width];
X{
Xint i,y;
Xy=0;i=0;
X
Xwhile(x[y][0]!='e')
X{
X	for(i=0;i<width;i++)
X	{
X	if(x[y][i]=='x') {
X	still_blocks[0].x=i+1;
X	still_blocks[0].y=y+(height-6);
X	num_stationary=1;
X	display_stationary_stuff();
X	}
X	}
X	y++;
X
X}
X
X}
X
X
X
END_OF_FILE
if test 17519 -ne `wc -c <'mex.c'`; then
    echo shar: \"'mex.c'\" unpacked with wrong size!
fi
# end of 'mex.c'
fi
if test -f 'mex_look.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mex_look.c'\"
else
echo shar: Extracting \"'mex_look.c'\" \(14168 characters\)
sed "s/^X//" >'mex_look.c' <<'END_OF_FILE'
X/*   ALL code in this program may be used for personal use */
X/*   and this program may be distributed as long as this copyright */
X/*   heading is attached to each source code file.  Distribution must  */
X/*   be done FREE of charge................ */
X/*                                           Glenn Kreisel */
X/*				             glenn@midget.towson.edu */		
X/*					     S72QKRE@TOWSONVX.BITNET */				
X#include "mex.h"
X#include <suntool/textsw.h>
X
Xstatic short mex_image[]={
X#include "mex.icon"
X};
XDEFINE_ICON_FROM_IMAGE(mex_icon,mex_image);
X
Xstatic short hiscore_image[]={
X#include "hiscore.icon"
X};
Xmpr_static(hiscore_icon,64,64,1,hiscore_image);
X
Xextern int sound_on;
Xextern read_in_scores();
Xextern int restart;
Xextern int frozen;
Xextern struct each_player hiscore_list[KEEP_SCORES];
Xextern Pixfont *bold;
Xextern void my_directions();
XCanvas game_canvas;
XFrame frame,hiscore_popup,show_scores_frame,info_frame;
XPanel right_panel,bottom_panel,hiscore_panel,show_scores;
XPanel_item hiscores_item[KEEP_SCORES];
X
XTextsw info_message;
X
X
XPanel_item resume_button,freeze_button,score_string,level_string,name_field,
X			level_num,show_next,restart_button,start_button,
X			hiscore_button,take_away_button,rows_string,rows_left_string;
X
Xint still_type;
X
Xvoid hi_scores_proc(item,event)
XPanel_item item;
XEvent *event;
X{
Xif(!(int)window_get(show_scores_frame,WIN_SHOW))
X{
Xread_in_scores();
Xupdate_hiscore_window();
Xpanel_set(hiscore_button,PANEL_SHOW_ITEM,FALSE,0);
Xpanel_set(take_away_button,PANEL_SHOW_ITEM,TRUE,0);
X
X}
Xelse 
X{
Xwindow_set(show_scores_frame,WIN_SHOW,FALSE,0);
Xpanel_set(take_away_button,PANEL_SHOW_ITEM,FALSE,0);
Xpanel_set(hiscore_button,PANEL_SHOW_ITEM,TRUE,0);
X}
X
X
X}
X
Xhiscore_done_proc(frame)
XFrame frame;
X{
Xwindow_set(show_scores_frame,WIN_SHOW,FALSE,0);
Xpanel_set(take_away_button,PANEL_SHOW_ITEM,FALSE,0);
Xpanel_set(hiscore_button,PANEL_SHOW_ITEM,TRUE,0);
X}
X
X     
Xring_bell(on,off)
Xunsigned int on,off;
X{
X   int bell;
X   int bell_on = KBD_CMD_BELL;
X   int bell_off = KBD_CMD_NOBELL;
X
X   if(!sound_on) return;
X     
X   bell = open("/dev/kbd",1);
X   ioctl(bell, KIOCCMD, &bell_on);
X   usleep(on);
X   ioctl(bell, KIOCCMD, &bell_off);
X   usleep(off);
X   close(bell);
X     
X} 
X
Xupdate_hiscore_window()
X{
Xchar wholething[140];
Xint i;
X
Xi=0;
Xwhile(hiscore_list[i].score!=-1 && i<KEEP_SCORES)
X	{
X	sprintf(wholething,"%2d) %-30s%8d %4d %26s",i+1,hiscore_list[i].name,hiscore_list[i].score,hiscore_list[i].rows,hiscore_list[i].date);
X	panel_set(hiscores_item[i],PANEL_LABEL_STRING,wholething,0);
X	i++;
X	}
Xwhile(i<KEEP_SCORES)
X	panel_set(hiscores_item[i++],PANEL_LABEL_STRING,"",0);
Xwindow_fit(show_scores);
Xwindow_fit(show_scores_frame);
Xwindow_set(show_scores_frame,WIN_SHOW,TRUE,0);
X}
X
Xchar * get_user_name()
X{
X	char *s;
X	struct passwd *p;
X	if (s = (char *)getlogin())
X	return (s);
X	p = (struct passwd *)getpwuid(getuid());
X	return (p->pw_name);
X}
X
Xchar *
Xget_player_name()
X{
Xchar *s;
Xpanel_set(name_field,PANEL_VALUE,"",0);
Xwindow_set(hiscore_popup,WIN_SHOW,TRUE,
X		0);
Xwindow_set(hiscore_panel,WIN_GRAB_ALL_INPUT,TRUE,0);
X
Xwindow_bell(hiscore_popup);
Xstill_type=1;
Xwhile(still_type)
Xnotify_dispatch();
X
X
Xwindow_set(hiscore_panel,WIN_GRAB_ALL_INPUT,FALSE,0);
Xwindow_set(hiscore_popup,WIN_SHOW,FALSE,0);
Xs=(char *)panel_get_value(name_field);
Xif(s[0]=='\0') return(get_user_name());
Xreturn(s);
X}
X
X
Xvoid freeze_proc(item,event)
XPanel_item item;
XEvent *event;
X{
Xif(restart!=GAME_OVER){
Xpanel_set(freeze_button,PANEL_SHOW_ITEM,FALSE,0);
Xpanel_set(resume_button,PANEL_SHOW_ITEM,TRUE,0);
Xfrozen=1;
X}
X
X}
X
Xvoid static resume_proc(item,event)
XPanel_item item;
XEvent *event;
X{
Xif(restart!=GAME_OVER){
Xpanel_set(resume_button,PANEL_SHOW_ITEM,FALSE,0);
Xpanel_set(freeze_button,PANEL_SHOW_ITEM,TRUE,0);
Xfrozen=0;
X}
X
X}
X
Xvoid static restart_proc(item,event)
XPanel_item item;
XEvent *event;
X{
Xrestart=NEW_GAME;
Xresume_proc(item,event);
X}
X
Xint do_confirmer()
X{
Xreturn(1);
X}
X
Xstatic Notify_value destroy_game(frame,status)
XFrame frame;
XDestroy_status status;
X{
X	if(status==DESTROY_CHECKING) {
X		if(do_confirmer())
X		{
X			restart=EXIT_GAME;
X			(void)notify_veto_destroy(frame);
X			return(NOTIFY_DONE);
X		}
X	}
X	return(notify_next_destroy_func(frame,status));
X}
X
X
Xvoid static exit_proc(item,event)
XPanel_item item;
XEvent *event;
X{
Xrestart=EXIT_GAME;
Xresume_proc(item,event);
X}
X
Xvoid static info_done_proc(frame)
XFrame frame;
X{
Xwindow_set(info_frame,WIN_SHOW,FALSE,0); 
Xwindow_set(info_message,WIN_SHOW,FALSE,0); 
X}
X
X
Xvoid static info_proc(item,event)
XPanel_item item;
XEvent *event;
X{
Xwindow_set(info_frame,WIN_SHOW,(char)window_get(info_frame,WIN_SHOW)^TRUE,0); 
Xwindow_set(info_message,WIN_SHOW,(char)window_get(info_message,WIN_SHOW)^TRUE,0); 
X}
X
X
X
Xstatic Panel_setting quit_text_input(item,event)
XPanel_item item;
XEvent *event;
X{
Xstill_type=0;
Xreturn(panel_text_notify(item,event));
X}
X
X
Xvoid static get_hiscore_info(item,event)
XPanel_item item;
XEvent *event;
X{
Xprintf("%d WAS the name selected\n ",(int)panel_get(item,PANEL_CLIENT_DATA));
X}
X
X
XNotify_value my_frame_interposer(frame,event,arg,type)
XFrame frame;
XEvent *event;
XNotify_arg arg;
XNotify_event_type type;
X{
Xint closed_initial,closed_current;
XNotify_value value;
X
Xclosed_initial=(int)window_get(frame,FRAME_CLOSED);
X
Xvalue=notify_next_event_func(frame,event,arg,type);
Xclosed_current=(int)window_get(frame,FRAME_CLOSED);
X
X
X
Xif(event_id(event)==WIN_RESIZE)	
X		{
X	if(closed_current) { 
X		if((int)window_get(show_scores_frame,WIN_SHOW))
X		hi_scores_proc();
X		freeze_proc();
X		} 
X		}
X
Xif(closed_initial!=closed_current){
X	if(closed_current)
X		resume_proc();
X	}
X
Xreturn(value);
X}
X
Xleave_pause(win,event)
XWindow win;
XEvent *event;
X{
X if(event_id(event)==LOC_WINEXIT || event_id(event)==LOC_RGNEXIT)
X	freeze_proc((Panel_item)0,event);
X}
X
X
X
X
Xdo_mex_look(argc,argv)
Xint *argc;
Xchar **argv;
X
X{
Xint i;
X	frame = window_create(0, FRAME,
X				FRAME_ARGC_PTR_ARGV,argc,argv,
X			      FRAME_LABEL, "->> MEX <<- Ver 1.6 by Glenn Kreisel  (c) 1989",
X				FRAME_SHOW_LABEL,TRUE,
X			      FRAME_EMBOLDEN_LABEL, TRUE,
X			      FRAME_SUBWINDOWS_ADJUSTABLE,FALSE,
X			      WIN_X,400,WIN_Y,270,
X			      FRAME_ICON,&mex_icon,
X			      0);
X	(void)notify_interpose_event_func(frame,my_frame_interposer,NOTIFY_SAFE);
X	(void)notify_interpose_destroy_func(frame,destroy_game);
X
X/* Do game canvas now */
X	game_canvas=window_create(frame,CANVAS,
X				WIN_WIDTH,(width+2)*char_width, 
X				WIN_HEIGHT,height*char_height,
X                		WIN_CONSUME_PICK_EVENTS,WIN_NO_EVENTS,
X				WIN_MOUSE_BUTTONS,
X                                LOC_DRAG,
X                                LOC_MOVE,
X				WIN_IN_TRANSIT_EVENTS,
X                                0,
X         		       WIN_CONSUME_KBD_EVENTS,WIN_ASCII_EVENTS,
X			       KEY_LEFT(7),KEY_LEFT(5),
X                                0,
X				WIN_EVENT_PROC,my_directions,
X				CANVAS_FAST_MONO,TRUE,
X				0);
X
X
X	i=(int)window_get(game_canvas,WIN_DEVICE_NUMBER);
X
X	right_panel = window_create(frame, PANEL,
X			      WIN_FONT, bold,
X		      	WIN_RIGHT_OF,game_canvas,
X			      PANEL_LAYOUT,PANEL_VERTICAL,
X			      WIN_CONSUME_KBD_EVENTS,WIN_NO_EVENTS,0,
X			      WIN_CONSUME_PICK_EVENTS,
X			      WIN_MOUSE_BUTTONS,0,
X			      WIN_INPUT_DESIGNEE,i,
X			      0);
X
X	bottom_panel= window_create(frame,PANEL,
X				PANEL_FONT,bold,
X			WIN_BELOW,game_canvas,
X				PANEL_LAYOUT,PANEL_HORIZONTAL,
X				WIN_FIT_HEIGHT,TRUE, 
X				WIN_CONSUME_KBD_EVENTS,WIN_NO_EVENTS,0,
X			      WIN_CONSUME_PICK_EVENTS,
X			      WIN_MOUSE_BUTTONS,0,
X				 WIN_WIDTH,WIN_EXTEND_TO_EDGE, 
X				 WIN_INPUT_DESIGNEE,i,
X				0);
X
X
X
X/* Do right panel now */
X	show_next = panel_create_item(right_panel,
X				      PANEL_TOGGLE,
X				      PANEL_LABEL_STRING, "Show Next",
X				      PANEL_LAYOUT, PANEL_HORIZONTAL,
X				      PANEL_CHOICE_STRINGS, "", 0,
X				      0);
X
X	score_string=panel_create_item(right_panel,
X					PANEL_TEXT,
X					PANEL_LAYOUT,PANEL_VERTICAL,
X					PANEL_LABEL_STRING,"Score:",
X					PANEL_VALUE,"0",
X					PANEL_VALUE_DISPLAY_LENGTH,8,
X					PANEL_VALUE_FONT,bold,
X					PANEL_ITEM_X,10,
X					PANEL_ITEM_Y,80+panel_get(show_next,PANEL_ITEM_Y,0),
X					0);
X
X	level_string=panel_create_item(right_panel,
X					PANEL_TEXT,
X					PANEL_LABEL_STRING,"Level:",
X					PANEL_VALUE,"0",
X					PANEL_VALUE_DISPLAY_LENGTH,8,
X					PANEL_LAYOUT,PANEL_VERTICAL,
X					PANEL_VALUE_FONT,bold,
X					PANEL_ITEM_X,10,
X					PANEL_ITEM_Y,60+panel_get(score_string,PANEL_ITEM_Y,0),
X					0);
X
X	rows_string=panel_create_item(right_panel,
X					PANEL_TEXT,
X					PANEL_LABEL_STRING,"Rows Completed",
X					PANEL_VALUE,"0",
X					PANEL_VALUE_DISPLAY_LENGTH,8,
X					PANEL_LAYOUT,PANEL_VERTICAL,
X					PANEL_VALUE_FONT,bold,
X					PANEL_ITEM_X,10,
X					PANEL_ITEM_Y,60+panel_get(level_string,PANEL_ITEM_Y,0),
X					0);
X
X	rows_left_string=panel_create_item(right_panel,
X					PANEL_TEXT,
X					PANEL_LABEL_STRING,"Rows In Level:",
X					PANEL_VALUE,"0",
X					PANEL_VALUE_DISPLAY_LENGTH,8,
X					PANEL_LAYOUT,PANEL_VERTICAL,
X					PANEL_VALUE_FONT,bold,
X					PANEL_ITEM_X,10,
X					PANEL_ITEM_Y,60+panel_get(rows_string,PANEL_ITEM_Y,0),
X					0);
X	resume_button=panel_create_item(right_panel,
X					PANEL_BUTTON,
X					PANEL_LABEL_IMAGE,
X					panel_button_image(right_panel,"Resume",6,0),
X					PANEL_SHOW_ITEM,FALSE,
X					PANEL_NOTIFY_PROC,resume_proc,
X					PANEL_ITEM_X,14,
X					PANEL_ITEM_Y,60+panel_get(rows_left_string,PANEL_ITEM_Y,0),
X					0);
X
X	freeze_button=panel_create_item(right_panel,
X				PANEL_BUTTON,
X				PANEL_LABEL_IMAGE,
X				panel_button_image(right_panel,"Freeze",6,0),
X				PANEL_NOTIFY_PROC,freeze_proc,
X			PANEL_ITEM_X,(int)panel_get(resume_button,PANEL_ITEM_X),
X				PANEL_ITEM_Y,(int)panel_get(resume_button,PANEL_ITEM_Y),
X				0);
X
X	panel_create_item(right_panel,
X					PANEL_BUTTON,
X					PANEL_LABEL_IMAGE,
X				panel_button_image(right_panel,"Info..",6,0),
X					PANEL_NOTIFY_PROC,info_proc,
X					PANEL_ITEM_X,14,
X					PANEL_ITEM_Y,30+panel_get(freeze_button,PANEL_ITEM_Y,0),
X					0);
Xwindow_fit(right_panel); 
Xwindow_set(right_panel,WIN_HEIGHT,WIN_EXTEND_TO_EDGE,0);
Xwindow_set(right_panel,WIN_WIDTH,WIN_EXTEND_TO_EDGE,0);
X/* End of right panel */
X
X/* Start of bottom panel */
X
X				
X				
Xpanel_create_item(bottom_panel, PANEL_BUTTON,
X		PANEL_LABEL_IMAGE,
X		panel_button_image(bottom_panel, "Exit", 5, 0),
X		PANEL_NOTIFY_PROC, exit_proc,
X		0);
X
Xstart_button=panel_create_item(bottom_panel,
X			  PANEL_BUTTON,
X		PANEL_LABEL_IMAGE, panel_button_image(bottom_panel, "Start", 5, 0),
X			  PANEL_NOTIFY_PROC, restart_proc,
X			  0);
Xrestart_button=panel_create_item(bottom_panel,
X			  PANEL_BUTTON,
X		PANEL_LABEL_IMAGE, panel_button_image(bottom_panel, "Restart", 7, 0),
X			PANEL_SHOW_ITEM,FALSE,
X			  PANEL_NOTIFY_PROC, restart_proc,
X			  0);
X
Xhiscore_button=panel_create_item(bottom_panel,
X			  PANEL_BUTTON,
X		PANEL_LABEL_IMAGE, &hiscore_icon,
X		  PANEL_NOTIFY_PROC, hi_scores_proc,
X			  0);
X
Xtake_away_button=panel_create_item(bottom_panel,
X			  PANEL_BUTTON,
X		PANEL_LABEL_IMAGE, panel_button_image(bottom_panel, "Hide Scores", 13, 0),
X		  PANEL_NOTIFY_PROC, hi_scores_proc,
X			PANEL_ITEM_X,(int)panel_get(hiscore_button,PANEL_ITEM_X),
X			PANEL_ITEM_Y,(int)panel_get(hiscore_button,PANEL_ITEM_Y),
X			PANEL_SHOW_ITEM,FALSE,
X			  0);
X	level_num=panel_create_item(bottom_panel,
X			PANEL_CYCLE,
X			PANEL_LABEL_STRING,"Level",
X			PANEL_CHOICE_STRINGS,"Novice","Intermediate",
X			"Expert","Extra Special","Super Special",0,
X			PANEL_ITEM_X,0,
X			PANEL_ITEM_Y,30+panel_get(restart_button,PANEL_ITEM_Y,0),
X			0);
Xwindow_fit(bottom_panel);
Xwindow_fit(frame);
X/* enter hi_score popup */
X
Xhiscore_popup=window_create(frame,FRAME,
X		FRAME_LABEL,"You've made it onto the HIGH SCORE LIST",
X				FRAME_SHOW_LABEL,TRUE,
X				WIN_X,29,WIN_Y,-210,
X				0);
Xhiscore_panel=window_create(hiscore_popup,PANEL,
X				PANEL_LAYOUT,PANEL_VERTICAL,
X         		       WIN_CONSUME_KBD_EVENTS,WIN_ASCII_EVENTS,
X			       KEY_LEFT(7),KEY_LEFT(5),
X                                0,
X				0);
X name_field=panel_create_item(hiscore_panel,
X			PANEL_TEXT,
X			PANEL_LABEL_STRING,"Please Enter Your Name:(pretty please)",
X			PANEL_VALUE,"",
X			PANEL_VALUE_DISPLAY_LENGTH,40,
X			PANEL_VALUE_STORED_LENGTH,60,
X			PANEL_NOTIFY_LEVEL,PANEL_SPECIFIED,
X			PANEL_NOTIFY_STRING,"\15",
X			PANEL_NOTIFY_PROC,quit_text_input,
X			0);
X
Xwindow_fit(hiscore_panel);
Xwindow_fit(hiscore_popup);
X
X
X/* frame for printing hiscores */
Xshow_scores_frame=window_create(frame,FRAME,
X				FRAME_LABEL,"********** Mex's wonderful HIGH SCORES ***********",
X				FRAME_SHOW_LABEL,TRUE,
X				WIN_X,-100,WIN_Y,-250,
X				FRAME_DONE_PROC,hiscore_done_proc,
X				0);
Xshow_scores=window_create(show_scores_frame,PANEL,
X				PANEL_LAYOUT,PANEL_VERTICAL,
X				0);
Xpanel_create_item(show_scores,PANEL_MESSAGE,
X				PANEL_LABEL_STRING,
X"                Name                 Score  #Rows           Date",
X				PANEL_FONT,bold,
X				PANEL_ITEM_X,0,
X				PANEL_ITEM_Y,0,
X				PANEL_SHOW_ITEM,TRUE,
X				0);
Xfor(i=0;i<KEEP_SCORES;i++)
X{
Xhiscores_item[i]=panel_create_item(show_scores,PANEL_MESSAGE,
X				PANEL_LABEL_STRING,"",
X				PANEL_FONT,bold,
X				PANEL_ITEM_X,0,
X				PANEL_ITEM_Y,(i+1)*20,
X				PANEL_NOTIFY_PROC,get_hiscore_info,
X				PANEL_CLIENT_DATA,(int)i,
X				PANEL_SHOW_ITEM,TRUE,
X				0);
X}
X
X 
X	info_frame=window_create(frame,FRAME,
X				FRAME_LABEL,"------ Drinking and driving don't Mex ------",
X				FRAME_SHOW_LABEL,TRUE,
X				WIN_X,9,WIN_Y,-250,
X                WIN_HEIGHT,             320,
X                WIN_WIDTH,              520,
X				FRAME_DONE_PROC,info_done_proc,
X				0);
X
X    info_message=window_create(info_frame, TEXTSW,
X                WIN_ERROR_MSG,          "I cannot find the 'info.file'" ,
X                WIN_X,                  0,
X                WIN_Y,                  0,
X                WIN_HEIGHT,             300,
X                WIN_WIDTH,              500,
X                TEXTSW_FONT,           bold,
X                TEXTSW_IGNORE_LIMIT,    TEXTSW_INFINITY,
X                TEXTSW_AUTO_INDENT,     TRUE,
X                TEXTSW_BROWSING,        TRUE,
X                TEXTSW_DISABLE_LOAD,    TRUE,
X                TEXTSW_DISABLE_CD,      TRUE,
X                TEXTSW_FILE,            INFO_FILE,
X		WIN_SHOW,FALSE,
X                0);
X
X
X     
X     
X
X	window_set(bottom_panel,WIN_MOUSE_XY,460,550,0);
X/*
X	window_set(bottom_panel,WIN_MOUSE_XY,20+panel_get(start_button,PANEL_ITEM_X,0),
X			5+panel_get(start_button,PANEL_ITEM_Y,0),0);
X			*/
X
X}
X
END_OF_FILE
if test 14168 -ne `wc -c <'mex_look.c'`; then
    echo shar: \"'mex_look.c'\" unpacked with wrong size!
fi
# end of 'mex_look.c'
fi
if test -f 'mex_scores.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mex_scores.c'\"
else
echo shar: Extracting \"'mex_scores.c'\" \(2564 characters\)
sed "s/^X//" >'mex_scores.c' <<'END_OF_FILE'
X/*   ALL code in this program may be used for personal use */
X/*   and this program may be distributed as long as this copyright */
X/*   heading is attached to each source code file.  Distribution must  */
X/*   be done FREE of charge................ */
X/*                                           Glenn Kreisel */
X/*				             glenn@midget.towson.edu */		
X#include "mex.h"
X#include <unistd.h>
Xextern char *get_player_name();
Xextern update_hiscore_window();
Xextern Frame show_scores_frame; 
Xstruct each_player  hiscore_list[KEEP_SCORES];
XFILE *hi_file;
X
X
Xread_in_scores()
X{
X
Xif((hi_file=fopen(HISCORE_FILE,"r+"))==NULL)
X	clear_hiscores();
Xelse read_in();
X
X}
X
Xwrite_out_scores()
X{
X
Xif((hi_file=fopen(HISCORE_FILE,"w"))==NULL)
X	printf("Error writing hiscore file!!!!!\n");
Xelse write_out();
X}
X
X
X
Xclear_hiscores()
X{
Xint i=0;
Xfor(i=0;i<KEEP_SCORES;i++)
Xhiscore_list[i].score=(-1);
Xwrite_out_scores();
Xchmod(HISCORE_FILE,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
X
X}
X
X
Xwrite_out()
X{
X
Xint i=0;
X
X/*lockf(fileno(hi_file),F_LOCK,0); */
X
Xwhile(hiscore_list[i].score!=-1 && i<KEEP_SCORES)
X{
X	fprintf(hi_file,"\02");
X	fprintf(hi_file,"%s\02%d %d%s",hiscore_list[i].name,hiscore_list[i].score,			hiscore_list[i].rows,
X			hiscore_list[i].date);
X			i++;
X}
Xfprintf(hi_file,"\01\n\n");
Xfclose(hi_file);
Xclose(fileno(hi_file));
X
X}
X
X
X
Xread_in()
X{
Xchar c;
Xint x,i=0,i1;
X/* lockf(fileno(hi_file),F_LOCK,0); */
X	c=fgetc(hi_file);
Xdo
X{
X	if(c=='\01'|| feof(hi_file)) break;
X	hiscore_list[i].name[0]='\0';
X	for(i1=0;(c=fgetc(hi_file))!='\02' && (!feof(hi_file));i1++)
X	{
X
X	hiscore_list[i].name[i1]=c;
X	}
X	hiscore_list[i].name[i1]='\0';
X
X	fscanf(hi_file,"%d %d",&hiscore_list[i].score,&hiscore_list[i].rows);
X
X	hiscore_list[i].date[0]='\0';
X	for(i1=0;(c=fgetc(hi_file))!='\02' && (c!='\01') && (!feof(hi_file));i1++)
X	{
X	hiscore_list[i].date[i1]=c;
X	}
X	i++;
X
X} while((!feof(hi_file)) && (i<KEEP_SCORES));
X
Xif(i<KEEP_SCORES)
Xhiscore_list[i].score=(-1);
Xfclose(hi_file);
Xclose(fileno(hi_file));
X
X}
X
X
Xinsert_score(score,rows)
Xint score,rows;
X{
Xchar *name;
Xint i=0,x;
Xlong t;
Xread_in_scores();
Xif(score!=0)
X{
Xwhile(hiscore_list[i].score>score && i++<KEEP_SCORES);
Xif(i<KEEP_SCORES)
X	{
X		name=get_player_name();
X		for(x=KEEP_SCORES-1;x!=i;x--)
X		{
X			hiscore_list[x]=hiscore_list[x-1];
X		}
X
X		hiscore_list[i].rows=rows;
X		strcpy(hiscore_list[i].name,name,strlen(name));
X		hiscore_list[i].score=score;
X		t=time(0);
X		strcpy(hiscore_list[i].date,ctime(&t),strlen(ctime(&t)));
X		if((int)window_get(show_scores_frame,WIN_SHOW))
X		update_hiscore_window();
X		write_out_scores();
X	}
X}
X
X}
X
END_OF_FILE
if test 2564 -ne `wc -c <'mex_scores.c'`; then
    echo shar: \"'mex_scores.c'\" unpacked with wrong size!
fi
# end of 'mex_scores.c'
fi
if test -f 'still_block.icon' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'still_block.icon'\"
else
echo shar: Extracting \"'still_block.icon'\" \(193 characters\)
sed "s/^X//" >'still_block.icon' <<'END_OF_FILE'
X/* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
X */
X	0x3778,0x5DDE,0xBBBB,0xEEEE,0x7777,0xDDDD,0xBBBB,0xEEEE,
X	0x7777,0xDDDD,0xBBBB,0xEEEE,0x7777,0xDDDD,0x7BBA,0x2EEC
END_OF_FILE
if test 193 -ne `wc -c <'still_block.icon'`; then
    echo shar: \"'still_block.icon'\" unpacked with wrong size!
fi
# end of 'still_block.icon'
fi
echo shar: End of archive 1 \(of 2\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0