games-request@tekred.TEK.COM (03/09/88)
Submitted by: Dan Heller <island!argv@sun.com>
Comp.sources.games: Volume 3, Issue 93
Archive-name: qix/Patch1
[This patch adds color capability to qix plus a
few little extras - see the README2 file. -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 shell archive."
# Contents: README2 Patches01
# Wrapped by billr@saab on Tue Mar 8 10:36:52 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f README2 -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"README2\"
else
echo shar: Extracting \"README2\" \(733 characters\)
sed "s/^X//" >README2 <<'END_OF_README2'
XThe latest qix version now supports color.
XThanx to:
XIan Donaldson <uunet.uu.net!munnari!koel.rmit.oz.au!rcodi>
X
XIn addition to Ian's changes:
X
XNew command line option "-s timeout" where timeout is in milliseconds.
XMachines with a graphics processor run significantly faster and the player
Xhasn't a chance. I've noticed that running with a gp, -s 50000 should
Xbe sufficient.
X
XThe program has been speeded up slightly -- it was too easy. The qix is
Xmore aggressive and faster beginning at the second screen.
X
XThe program figures out whether you're running in color and if so, it
Xwill speed up a little for those without gp's so that it runs about
Xthe same speed as a sun3/50.
X
XThe scorefile is created if it doesn't already exist.
X
END_OF_README2
if test 733 -ne `wc -c <README2`; then
echo shar: \"README2\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f Patches01 -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"Patches01\"
else
echo shar: Extracting \"Patches01\" \(42908 characters\)
sed "s/^X//" >Patches01 <<'END_OF_Patches01'
X*** OLD/Makefile Tue Jan 12 15:53:56 1988
X--- Makefile Mon Mar 7 21:55:35 1988
X***************
X*** 6,19 ****
X ICONS= joystick.lf joystick.rt joystick.up joystick.dn joystick.stop \
X spark1.pr spark2.pr spark3.pr spark4.pr marker.cursor qix.icon \
X mouse.rt.icon
X CFLAGS= -O
X LDFLAGS=
X LIBES= -lsuntool -lsunwindow -lpixrect
X
X! qix.x: ${OBJS}
X @echo loading...
X @cc ${LDFLAGS} ${OBJS} ${LIBES} -o qix
X
X # qix with a recursive polygon file rather than iterative.
X # If you use it you have to unlimit the stacksize in csh
X # and check the code to make sure it's called right (it's old).
X--- 6,37 ----
X ICONS= joystick.lf joystick.rt joystick.up joystick.dn joystick.stop \
X spark1.pr spark2.pr spark3.pr spark4.pr marker.cursor qix.icon \
X mouse.rt.icon
X+
X+ # Change these to suit your installation
X+
X+ SCOREFILE=/usr/games/lib/qix.scores
X+ BINDIR=/usr/people/argv/bin
X+
X CFLAGS= -O
X LDFLAGS=
X LIBES= -lsuntool -lsunwindow -lpixrect
X
X! all: qix
X!
X! qix: ${OBJS}
X @echo loading...
X @cc ${LDFLAGS} ${OBJS} ${LIBES} -o qix
X
X+ install: all
X+ install -s -c -m 2711 -o games -g games qix ${BINDIR}
X+ touch ${SCOREFILE}
X+ chmod 660 ${SCOREFILE}
X+ -chgrp games ${SCOREFILE}
X+ -chown games ${SCOREFILE}
X+
X+ score.o:
X+ cc $(CFLAGS) -DSCOREFILE=\"${SCOREFILE}\" -c score.c
X+
X # qix with a recursive polygon file rather than iterative.
X # If you use it you have to unlimit the stacksize in csh
X # and check the code to make sure it's called right (it's old).
X***************
X*** 25,27 ****
X--- 43,86 ----
X btoa > qix.tarmail
X
X shar: ; shar Makefile qix.h ${CFILES} ${ICONS} > qix.shar
X+
X+ clean:
X+ rm -f qix $(OBJS)
X+
X+ lint:
X+ lint -hbx $(CPPFLAGS) $(CFILES) $(LIBES)
X+
X+ depend: $(CFILES)
X+ makedep -i $(CPPFLAGS) $(CFILES)
X+
X+ # DO NOT EDIT BELOW THIS LINE -- or it will disappear when you "make depend"
X+
X+ main.o: ./qix.icon
X+ main.o: main.c
X+
X+ joystick.o: ./joystick.dn
X+ joystick.o: ./joystick.lf
X+ joystick.o: ./joystick.rt
X+ joystick.o: ./joystick.stop
X+ joystick.o: ./joystick.up
X+ joystick.o: ./marker.cursor
X+ joystick.o: ./mouse.rt.icon
X+ joystick.o: joystick.c
X+
X+ sparks.o: ./spark1.pr
X+ sparks.o: ./spark2.pr
X+ sparks.o: ./spark3.pr
X+ sparks.o: ./spark4.pr
X+ sparks.o: sparks.c
X+
X+ regions.o: regions.c
X+
X+ qmove.o: qmove.c
X+
X+ polyfill.o: polyfill.c
X+
X+ polygon_area.o: polygon_area.c
X+
X+ polyfill_rec.o: polyfill_rec.c
X+
X+ score.o: score.c
X*** OLD/joystick.c Tue Jan 12 17:30:52 1988
X--- joystick.c Mon Mar 7 21:40:32 1988
X***************
X*** 108,114 ****
X if (isdigit(ID)) {
X debug = ID - '0';
X msg("Debugging level set to %d", debug);
X! sleep(2);
X remove_msgs();
X return;
X } else
X--- 108,114 ----
X if (isdigit(ID)) {
X debug = ID - '0';
X msg("Debugging level set to %d", debug);
X! Sleep(2);
X remove_msgs();
X return;
X } else
X***************
X*** 164,172 ****
X moving = DOWN;
X when 'k' : case 'K' : case KEY_RIGHT(8) :
X moving = UP;
X! when LOC_MOVE : break; /* let those thru! */
X #ifdef DEBUG
X! case '@' : no_qix_kill = !no_qix_kill; drawing = 0;
X when '#' : clear_sparks();
X when '+' : lives = min(lives+1, MAX_LIVES); update_score(); drawing = 0;
X when '-' : lives = max(lives-1, 1); update_score(); drawing = 0;
X--- 164,178 ----
X moving = DOWN;
X when 'k' : case 'K' : case KEY_RIGHT(8) :
X moving = UP;
X! when LOC_MOVE : ; /* let those thru! (break-- do nothing) */
X! when 3 : /* CTRL(C) */
X! drawing = 0;
X! if (play_mode == REAL_PLAY) {
X! lives = 0;
X! change_life(DIE);
X! }
X #ifdef DEBUG
X! when '@' : no_qix_kill = !no_qix_kill; drawing = 0;
X when '#' : clear_sparks();
X when '+' : lives = min(lives+1, MAX_LIVES); update_score(); drawing = 0;
X when '-' : lives = max(lives-1, 1); update_score(); drawing = 0;
X***************
X*** 198,208 ****
X
X if (!is_alive && lives > 0) {
X /* user has died and is waiting to start again */
X! sleep(2);
X change_life(LIVE);
X stop_timer(); /* change_life restarts it */
X msg("Ready?");
X! sleep(2);
X remove_msgs(0);
X start_timer();
X return;
X--- 204,214 ----
X
X if (!is_alive && lives > 0) {
X /* user has died and is waiting to start again */
X! Sleep(2);
X change_life(LIVE);
X stop_timer(); /* change_life restarts it */
X msg("Ready?");
X! Sleep(2);
X remove_msgs(0);
X start_timer();
X return;
X***************
X*** 281,287 ****
X when SHOW_QIX :
X remove_msgs(0);
X msg("Your Enemies:");
X! sleep(2);
X time_left = 40;
X when SHOW_SPARKS :
X time_left = 90;
X--- 287,293 ----
X when SHOW_QIX :
X remove_msgs(0);
X msg("Your Enemies:");
X! Sleep(2);
X time_left = 40;
X when SHOW_SPARKS :
X time_left = 90;
X***************
X*** 298,304 ****
X change_life(LIVE);
X stop_timer();
X msg("Enclose more than\n75%%\nof the play area for extra bonus.");
X! sleep(2);
X remove_msgs(0);
X level = -2;
X drawing = fast = 1;
X--- 304,310 ----
X change_life(LIVE);
X stop_timer();
X msg("Enclose more than\n75%%\nof the play area for extra bonus.");
X! Sleep(2);
X remove_msgs(0);
X level = -2;
X drawing = fast = 1;
X***************
X*** 308,322 ****
X when SHOW_QIX :
X move_qix();
X if (time_left == 1) {
X! pw_text(draw_win, 200,200,PIX_SRC,big_font, "The qix.");
X! sleep(2);
X }
X when SHOW_SPARKS :
X move_sparks();
X if (time_left == 1) {
X! pw_text(draw_win, 15, 110, PIX_SRC, big_font, "Sparx.");
X! pw_text(draw_win,625, 110, PIX_SRC, big_font, "Sparx.");
X! sleep(2);
X }
X when SHOW_FUSE :
X /* after the pw_text, this moves into spiral death trap */
X--- 314,335 ----
X when SHOW_QIX :
X move_qix();
X if (time_left == 1) {
X! pw_putattributes(draw_win, &text_mask);
X! pw_text(draw_win, 200,200,PIX_SRC|PIX_COLOR(TEXT_COLOR),
X! big_font, "The qix.");
X! Sleep(2);
X }
X when SHOW_SPARKS :
X move_sparks();
X if (time_left == 1) {
X! pw_putattributes(draw_win, &text_mask);
X! pw_text(draw_win, 15, 110,
X! PIX_SRC|PIX_COLOR(TEXT_COLOR),
X! big_font, "Sparx.");
X! pw_text(draw_win,625, 110,
X! PIX_SRC|PIX_COLOR(TEXT_COLOR),
X! big_font, "Sparx.");
X! Sleep(2);
X }
X when SHOW_FUSE :
X /* after the pw_text, this moves into spiral death trap */
X***************
X*** 323,334 ****
X switch (time_left) {
X when 230 :
X drawing = 0;
X pw_text(draw_win,
X convert_x(pen_x - 7), convert_y(pen_y + 7),
X! PIX_SRC, big_font, "The fuse.");
X when 80 :
X pw_text(draw_win, 265, 445,
X! PIX_SRC, big_font, "The Spiral Death Trap.");
X case 200 : case 240 : case 40 : case 20 :
X moving = LEFT, drawing = 1;
X when 110 : case 55 : case 30 : moving = RIGHT;
X--- 336,351 ----
X switch (time_left) {
X when 230 :
X drawing = 0;
X+ pw_putattributes(draw_win, &text_mask);
X pw_text(draw_win,
X convert_x(pen_x - 7), convert_y(pen_y + 7),
X! PIX_SRC|PIX_COLOR(TEXT_COLOR),
X! big_font, "The fuse.");
X when 80 :
X+ pw_putattributes(draw_win, &text_mask);
X pw_text(draw_win, 265, 445,
X! PIX_SRC|PIX_COLOR(TEXT_COLOR),
X! big_font, "The Spiral Death Trap.");
X case 200 : case 240 : case 40 : case 20 :
X moving = LEFT, drawing = 1;
X when 110 : case 55 : case 30 : moving = RIGHT;
X***************
X*** 342,348 ****
X goto movit;
X } else if (region) {
X move_fuse(fuse = NULL);
X! rm_cur_line(PIX_SRC);
X }
X when SHOW_POINTS : {
X char buf[5];
X--- 359,365 ----
X goto movit;
X } else if (region) {
X move_fuse(fuse = NULL);
X! rm_cur_line(PIX_SRC|PIX_COLOR(BORDER_COLOR));
X }
X when SHOW_POINTS : {
X char buf[5];
X***************
X*** 358,371 ****
X when 250 : case 130 : moving = RIGHT;
X when 230 : case 90 : moving = DOWN;
X when 210 : drawing = 0, moving = RIGHT;
X pw_text(draw_win,
X convert_x(pen_x - 12), convert_y(pen_y - 25),
X! PIX_SRC, big_font, sprintf(buf, "%d", score));
X when 49 : /* make sure region is closed */
X msg("Use RIGHT mouse button to STOP movement.");
X pw_text(draw_win,
X convert_x(pen_x - 12), convert_y(pen_y - 25),
X! PIX_SRC, big_font, sprintf(buf, "%d", score));
X when 15 : drawing = 0, moving = RIGHT;
X }
X goto movit; /* avoid moving qix and sparks */
X--- 375,392 ----
X when 250 : case 130 : moving = RIGHT;
X when 230 : case 90 : moving = DOWN;
X when 210 : drawing = 0, moving = RIGHT;
X+ pw_putattributes(draw_win, &text_mask);
X pw_text(draw_win,
X convert_x(pen_x - 12), convert_y(pen_y - 25),
X! PIX_SRC|PIX_COLOR(TEXT_COLOR),
X! big_font, sprintf(buf, "%d", score));
X when 49 : /* make sure region is closed */
X msg("Use RIGHT mouse button to STOP movement.");
X+ pw_putattributes(draw_win, &text_mask);
X pw_text(draw_win,
X convert_x(pen_x - 12), convert_y(pen_y - 25),
X! PIX_SRC|PIX_COLOR(TEXT_COLOR),
X! big_font, sprintf(buf, "%d", score));
X when 15 : drawing = 0, moving = RIGHT;
X }
X goto movit; /* avoid moving qix and sparks */
X***************
X*** 493,500 ****
X board[pen_x][pen_y] |= CL_LN_DN;
X board[x][y] |= CL_LN_UP;
X }
X draw(convert_x(x), convert_y(y),
X! convert_x(pen_x), convert_y(pen_y), PIX_SRC);
X if (!region) {
X saved_edge = old_value;
X add_to_line(pen_x, pen_y);
X--- 514,523 ----
X board[pen_x][pen_y] |= CL_LN_DN;
X board[x][y] |= CL_LN_UP;
X }
X+ pw_putattributes(draw_win, &border_mask);
X draw(convert_x(x), convert_y(y),
X! convert_x(pen_x), convert_y(pen_y),
X! PIX_SRC|PIX_COLOR(BORDER_COLOR));
X if (!region) {
X saved_edge = old_value;
X add_to_line(pen_x, pen_y);
X***************
X*** 518,524 ****
X }
X } else
X level++;
X! sleep(3);
X clear_board(); /* removes msgs also */
X change_life(LIVE);
X stop_timer();
X--- 541,547 ----
X }
X } else
X level++;
X! Sleep(3);
X clear_board(); /* removes msgs also */
X change_life(LIVE);
X stop_timer();
X***************
X*** 526,532 ****
X level++;
X if (level == 0) {
X msg("Split the 2 qix to advance score multiplier.");
X! sleep(2);
X remove_msgs(0);
X }
X start_timer();
X--- 549,555 ----
X level++;
X if (level == 0) {
X msg("Split the 2 qix to advance score multiplier.");
X! Sleep(2);
X remove_msgs(0);
X }
X start_timer();
X***************
X*** 551,561 ****
X moving == UP? &joystick_up :
X moving == DOWN? &joystick_down :
X moving == STOP? &joystick_stop : &ready_icon;
X pw_rop(joystick_win,
X! BOARD_WIDTH_IN_PIXELS/2-32, 2, 64, 64, PIX_SRC, image, 0,0);
X! pw_rop(joystick_win, 100,32, 16,23, PIX_SRC,
X (drawing && fast)? &ms_fast_on : &ms_fast_off, 0, 0);
X! pw_rop(joystick_win, 150,32, 16,23, PIX_SRC,
X (drawing && !fast)? &ms_slow_on : &ms_slow_off, 0, 0);
X }
X
X--- 574,586 ----
X moving == UP? &joystick_up :
X moving == DOWN? &joystick_down :
X moving == STOP? &joystick_stop : &ready_icon;
X+ pw_putattributes(joystick_win, &border_mask);
X pw_rop(joystick_win,
X! BOARD_WIDTH_IN_PIXELS/2-32, 2, 64, 64, PIX_SRC|PIX_COLOR(BORDER_COLOR),
X! image, 0,0);
X! pw_rop(joystick_win, 100,32, 16,23, PIX_SRC|PIX_COLOR(BORDER_COLOR),
X (drawing && fast)? &ms_fast_on : &ms_fast_off, 0, 0);
X! pw_rop(joystick_win, 150,32, 16,23, PIX_SRC|PIX_COLOR(BORDER_COLOR),
X (drawing && !fast)? &ms_slow_on : &ms_slow_off, 0, 0);
X }
X
X*** OLD/main.c Tue Jan 12 17:09:06 1988
X--- main.c Mon Mar 7 21:45:09 1988
X***************
X*** 3,12 ****
X * Appearance ONLY shamelessly stolen from the real video game wonderfully
X * and admirably written by individual(s) unknown at Taito Corp (I think).
X *
X! * Copyright 1987 by Dan Heller (island!argv@sun.com or argv@spam.istc.sri.com)
X *
X * Various polygon filling routines written by
X! * -- Dan "Sky" Shultz (island!sky@sun.com) and
X * -- Don Hatch (splat%ucscb@ucscc.ucsc.edu [fall, 1987])
X * additional help (general debugging, recursive polyfill)
X *
X--- 3,14 ----
X * Appearance ONLY shamelessly stolen from the real video game wonderfully
X * and admirably written by individual(s) unknown at Taito Corp (I think).
X *
X! * Copyright 1987 by Dan Heller
X! * island!argv@sun.com
X! * dheller@dheller@ucbcory.berkeley.edu
X *
X * Various polygon filling routines written by
X! * -- Dan "Sky" Shultz
X * -- Don Hatch (splat%ucscb@ucscc.ucsc.edu [fall, 1987])
X * additional help (general debugging, recursive polyfill)
X *
X***************
X*** 33,38 ****
X--- 35,46 ----
X
X int (*old_repaint_func)();
X
X+ int qix_mask = 0x7;
X+ int text_mask = TEXT_COLOR;
X+ int fast_draw_mask = FAST_DRAW_COLOR;
X+ int slow_draw_mask = SLOW_DRAW_COLOR;
X+ int border_mask = BORDER_COLOR;
X+ int all_mask = 0xff;
X
X redraw(args)
X {
X***************
X*** 51,57 ****
X (void) signal(SIGSEGV, catch);
X (void) signal(SIGXCPU, catch);
X
X- #ifdef DEBUG
X /*
X * specify debug levels "-d level"
X * a level of 2 prints polygon fill info. 4 disables spark-generation
X--- 59,64 ----
X***************
X*** 58,64 ****
X * but doesn't kill current sparks. debug level 1 does prints things...
X */
X while (*++newargv)
X! if (!strcmp(*newargv, "-q"))
X no_qix_kill = 1;
X else if (!strcmp(*newargv, "-d"))
X debug = (*++newargv) ? atoi(*newargv) : 1;
X--- 65,79 ----
X * but doesn't kill current sparks. debug level 1 does prints things...
X */
X while (*++newargv)
X! if (!strcmp(*newargv, "-s"))
X! if (!*++newargv)
X! puts("usage: qix [-s timeout] (in milliseconds)"), exit(1);
X! else {
X! if ((interval = atoi(*newargv)) < 15000 || interval > 60000)
X! puts("delay must be between 15000 and 60000"), exit(1);
X! }
X! #ifdef DEBUG
X! else if (!strcmp(*newargv, "-q"))
X no_qix_kill = 1;
X else if (!strcmp(*newargv, "-d"))
X debug = (*++newargv) ? atoi(*newargv) : 1;
X***************
X*** 79,84 ****
X--- 94,101 ----
X 0);
X
X draw_win = canvas_pixwin(Draw);
X+ if (interval == 0)
X+ interval = (draw_win->pw_pixrect->pr_depth == 8)? 35000 : 50000;
X window_set(Draw,
X CANVAS_FAST_MONO, TRUE,
X WIN_CONSUME_PICK_EVENTS,
X***************
X*** 99,104 ****
X--- 116,165 ----
X 0);
X joystick_win = canvas_pixwin(Joystick);
X
X+ /*
X+ * set color map segment name and load color map
X+ */
X+ {
X+ static char cmsname[CMS_NAMESIZE];
X+ static char r[QIX_CMS_SIZE],g[QIX_CMS_SIZE],b[QIX_CMS_SIZE];
X+
X+ (void) strcpy(cmsname, QIX_CMS_NAME);
X+ pw_setcmsname(draw_win, cmsname);
X+ pw_setcmsname(joystick_win, cmsname);
X+
X+ /* blueish */
X+ r[FAST_DRAW_COLOR] = 40;
X+ g[FAST_DRAW_COLOR] = 170;
X+ b[FAST_DRAW_COLOR] = 213;
X+
X+ /* brownish */
X+ r[SLOW_DRAW_COLOR] = 213;
X+ g[SLOW_DRAW_COLOR] = 170;
X+ b[SLOW_DRAW_COLOR] = 0;
X+
X+ /* dark something */
X+ r[TEXT_COLOR] = 0;
X+ g[TEXT_COLOR] = 80;
X+ b[TEXT_COLOR] = 190;
X+
X+ /* red sparks when not aggressive */
X+ r[SPARKS_COLOR] = 255;
X+ g[SPARKS_COLOR] = 0;
X+ b[SPARKS_COLOR] = 0;
X+
X+ /* blue sparks when aggressive */
X+ r[AGGR_SPARK_COLOR] = 0;
X+ g[AGGR_SPARK_COLOR] = 0;
X+ b[AGGR_SPARK_COLOR] = 255;
X+
X+ cms_rainbowsetup(&r[QIX_COLOR_BASE],
X+ &g[QIX_COLOR_BASE],
X+ &b[QIX_COLOR_BASE]);
X+
X+ pw_putcolormap(draw_win, 0, QIX_CMS_SIZE, r, g, b);
X+ pw_putcolormap(joystick_win, 0, QIX_CMS_SIZE, r, g, b);
X+ }
X+
X window_fit(frame);
X
X if (!(small_font = pf_open("/usr/people/argv/computer.14")) &&
X***************
X*** 120,126 ****
X pw_text(joystick_win, 92, 24, PIX_SRC, small_font, "Fast Slow");
X play_mode = SHOW_SCORES;
X update_score();
X! score_board(TRUE, FALSE);
X time_left = 100; /* timeout before next demo mode switch */
X (void) signal(SIGALRM, move_pen);
X old_repaint_func = (int(*)())window_get(frame, CANVAS_REPAINT_PROC);
X--- 181,187 ----
X pw_text(joystick_win, 92, 24, PIX_SRC, small_font, "Fast Slow");
X play_mode = SHOW_SCORES;
X update_score();
X! (void) score_board(TRUE, FALSE);
X time_left = 100; /* timeout before next demo mode switch */
X (void) signal(SIGALRM, move_pen);
X old_repaint_func = (int(*)())window_get(frame, CANVAS_REPAINT_PROC);
X***************
X*** 141,152 ****
X pen_x = (BOARD_WIDTH-1)/2, pen_y = BOARD_HEIGHT-1;
X remove_msgs(1);
X
X /* give left->right sweeping effect like the real game */
X for (x = 0; x < BOARD_WIDTH_IN_PIXELS; x++)
X draw(x, 0, x, BOARD_HEIGHT_IN_PIXELS-1, PIX_CLR);
X
X box(convert_x(0), convert_y(0),
X! convert_x(BOARD_WIDTH-1), convert_y(BOARD_HEIGHT-1), PIX_SRC);
X
X /* clear the interior of the board */
X for (x = 1; x < BOARD_WIDTH-1; x++)
X--- 202,217 ----
X pen_x = (BOARD_WIDTH-1)/2, pen_y = BOARD_HEIGHT-1;
X remove_msgs(1);
X
X+ pw_putattributes(draw_win, &all_mask);
X+
X /* give left->right sweeping effect like the real game */
X for (x = 0; x < BOARD_WIDTH_IN_PIXELS; x++)
X draw(x, 0, x, BOARD_HEIGHT_IN_PIXELS-1, PIX_CLR);
X
X+ pw_putattributes(draw_win, &border_mask);
X box(convert_x(0), convert_y(0),
X! convert_x(BOARD_WIDTH-1), convert_y(BOARD_HEIGHT-1),
X! PIX_SRC|PIX_COLOR(BORDER_COLOR));
X
X /* clear the interior of the board */
X for (x = 1; x < BOARD_WIDTH-1; x++)
X***************
X*** 194,200 ****
X lives = 1;
X else
X lives = MAX_LIVES;
X! clear_board(); /* resets pen_x, pen_y */
X level = -2, score = 0;
X } else {
X extern int qix1_x0[], qix1_x1[], qix1_y0[], qix1_y1[];
X--- 259,265 ----
X lives = 1;
X else
X lives = MAX_LIVES;
X! clear_board(); /* resets pen_x, pen_y (changes plane mask) */
X level = -2, score = 0;
X } else {
X extern int qix1_x0[], qix1_x1[], qix1_y0[], qix1_y1[];
X***************
X*** 217,248 ****
X drawing = FALSE;
X if (level > 0) {
X msg("All scores now\n%d times\ntheir original value.", level+1);
X! sleep(3);
X remove_msgs(0);
X }
X place_pen(); /* make pen appear */
X }
X
X for (x = 0; x < 2; x++)
X for (n = m; n >= 40 && n <= 300; n -= 5 * live_or_die)
X box(pen_coord_x(pen_x)-n/2, pen_coord_y(pen_y)-n/2,
X! pen_coord_x(pen_x)+n/2, pen_coord_y(pen_y)+n/2, XOR);
X
X if (live_or_die == DIE) {
X is_alive = FALSE;
X if (--lives <= 0) {
X reset_joystick_win(TRUE);
X msg("Game Over.");
X! sleep(2);
X /* if he got on the scoreboard, let him put his initials up */
X if (play_mode == REAL_PLAY)
X! score_board(FALSE, FALSE);
X if (play_mode == SHOW_SPIRAL)
X time_left = 50; /* demo mode comes after spiral death trap */
X else {
X- score_board(TRUE, FALSE);
X play_mode = SHOW_SCORES;
X! time_left = 100; /* show scores after demo mode or real play */
X }
X moving = NO_MOVE;
X } else {
X--- 282,318 ----
X drawing = FALSE;
X if (level > 0) {
X msg("All scores now\n%d times\ntheir original value.", level+1);
X! Sleep(3);
X remove_msgs(0);
X }
X place_pen(); /* make pen appear */
X }
X
X+ pw_putattributes(draw_win, &border_mask);
X for (x = 0; x < 2; x++)
X for (n = m; n >= 40 && n <= 300; n -= 5 * live_or_die)
X box(pen_coord_x(pen_x)-n/2, pen_coord_y(pen_y)-n/2,
X! pen_coord_x(pen_x)+n/2, pen_coord_y(pen_y)+n/2,
X! XOR | PIX_COLOR(BORDER_COLOR));
X
X if (live_or_die == DIE) {
X is_alive = FALSE;
X if (--lives <= 0) {
X+ int do_scores = TRUE;
X reset_joystick_win(TRUE);
X msg("Game Over.");
X! Sleep(2);
X /* if he got on the scoreboard, let him put his initials up */
X if (play_mode == REAL_PLAY)
X! do_scores = (score_board(FALSE, FALSE) == 0);
X if (play_mode == SHOW_SPIRAL)
X time_left = 50; /* demo mode comes after spiral death trap */
X else {
X play_mode = SHOW_SCORES;
X! if (do_scores)
X! (void) score_board(TRUE, FALSE), time_left = 300;
X! else
X! time_left = 100;
X }
X moving = NO_MOVE;
X } else {
X***************
X*** 263,284 ****
X int x;
X
X sprintf(buf, "Score: %6d", score);
X! pw_text(joystick_win, 500, 22, PIX_SRC, big_font, buf);
X! pw_text(joystick_win, 500, 22, PIX_SRC|PIX_DST, big_font, buf);
X
X if (play_mode != REAL_PLAY) {
X! pw_text(draw_win, 105, 12, PIX_SRC, small_font,
X "Click RIGHT mouse button or use <spacebar> to start new game.");
X return;
X }
X
X! pw_text(joystick_win, 500, 45, PIX_SRC, big_font, "Lives: ");
X for (x = 0; x < MAX_LIVES; x++)
X! pw_rop(joystick_win, 575+(x*20), 32, 16,16, (x < lives-1)?
X! PIX_SRC:PIX_CLR, &pen_image, 0, 0);
X sprintf(buf, "Filled: %d%%",(int)((double)area_closed/TOTAL_AREA*100));
X! pw_text(draw_win, 280, 12, PIX_SRC, small_font, buf);
X! pw_text(draw_win, 281, 12, PIX_SRC|PIX_DST, small_font, buf);
X }
X
X Pixrect *save[15]; /* area under text to be redisplayed upon removal of text */
X--- 333,362 ----
X int x;
X
X sprintf(buf, "Score: %6d", score);
X! pw_putattributes(joystick_win, &text_mask);
X! pw_text(joystick_win, 500, 22, PIX_SRC|PIX_COLOR(TEXT_COLOR),
X! big_font, buf);
X! pw_text(joystick_win, 500, 22, PIX_SRC|PIX_DST|PIX_COLOR(TEXT_COLOR),
X! big_font, buf);
X
X if (play_mode != REAL_PLAY) {
X! pw_text(draw_win, 105, 12, PIX_SRC|PIX_COLOR(TEXT_COLOR), small_font,
X "Click RIGHT mouse button or use <spacebar> to start new game.");
X return;
X }
X
X! pw_text(joystick_win, 500, 45, PIX_SRC|PIX_COLOR(TEXT_COLOR),
X! big_font, "Lives: ");
X! pw_putattributes(joystick_win, &border_mask);
X for (x = 0; x < MAX_LIVES; x++)
X! pw_rop(joystick_win, 575+(x*20), 32, 16,16, ((x < lives-1)?
X! PIX_SRC:PIX_CLR)|PIX_COLOR(BORDER_COLOR), &pen_image, 0, 0);
X!
X sprintf(buf, "Filled: %d%%",(int)((double)area_closed/TOTAL_AREA*100));
X! pw_putattributes(draw_win, &text_mask);
X! pw_text(draw_win, 280, 12, PIX_SRC|PIX_COLOR(TEXT_COLOR), small_font, buf);
X! pw_text(draw_win, 281, 12, PIX_SRC|PIX_DST|PIX_COLOR(TEXT_COLOR),
X! small_font, buf);
X }
X
X Pixrect *save[15]; /* area under text to be redisplayed upon removal of text */
X***************
X*** 286,291 ****
X--- 364,370 ----
X static int msgs; /* the number of text lines displayed on the board */
X
X /* print a message somewhere at the top of the playing board for two seconds */
X+ /*VARARGS1*/
X msg(fmt, args)
X char *fmt;
X {
X***************
X*** 298,303 ****
X--- 377,383 ----
X #ifdef DEBUG
X puts(buf);
X #endif DEBUG
X+ pw_putattributes(draw_win, &text_mask);
X do {
X if (p2 = index(p, '\n'))
X *p2 = 0;
X***************
X*** 313,321 ****
X draw_win->pw_prretained, x_pos[msgs], y_pos[msgs]);
X
X pw_text(draw_win, x_pos[msgs], y_pos[msgs]+l_height(big_font)-5,
X! PIX_SRC, big_font, p);
X pw_text(draw_win, x_pos[msgs]+1, y_pos[msgs]+l_height(big_font)-5,
X! PIX_SRC|PIX_DST, big_font, p);
X } while (++msgs < 15 && p2 && *(p = p2+1));
X }
X
X--- 393,401 ----
X draw_win->pw_prretained, x_pos[msgs], y_pos[msgs]);
X
X pw_text(draw_win, x_pos[msgs], y_pos[msgs]+l_height(big_font)-5,
X! PIX_SRC | PIX_COLOR(TEXT_COLOR), big_font, p);
X pw_text(draw_win, x_pos[msgs]+1, y_pos[msgs]+l_height(big_font)-5,
X! PIX_SRC|PIX_DST | PIX_COLOR(TEXT_COLOR), big_font, p);
X } while (++msgs < 15 && p2 && *(p = p2+1));
X }
X
X***************
X*** 322,331 ****
X /* remove all messages from the board and put back the images underneith */
X remove_msgs(clearing)
X {
X while (msgs--) {
X if (!clearing)
X pw_rop(draw_win, x_pos[msgs], y_pos[msgs], x_save[msgs], y_save,
X! PIX_SRC, save[msgs], 0, 0);
X pr_destroy(save[msgs]);
X }
X msgs = 0;
X--- 402,412 ----
X /* remove all messages from the board and put back the images underneith */
X remove_msgs(clearing)
X {
X+ pw_putattributes(draw_win, &text_mask);
X while (msgs--) {
X if (!clearing)
X pw_rop(draw_win, x_pos[msgs], y_pos[msgs], x_save[msgs], y_save,
X! PIX_SRC | PIX_COLOR(TEXT_COLOR), save[msgs], 0, 0);
X pr_destroy(save[msgs]);
X }
X msgs = 0;
X***************
X*** 336,342 ****
X stop_timer();
X if (sig == SIGXCPU) {
X msg("CPU timelimit exceeded. Go home and eat dinner.");
X! sleep(2);
X remove_msgs(0);
X return;
X }
X--- 417,423 ----
X stop_timer();
X if (sig == SIGXCPU) {
X msg("CPU timelimit exceeded. Go home and eat dinner.");
X! Sleep(2);
X remove_msgs(0);
X return;
X }
X***************
X*** 346,349 ****
X--- 427,448 ----
X else
X fprintf(stderr, "Bus Error\n");
X abort();
X+ }
X+
X+ void
X+ flush_events()
X+ {
X+ struct timeval dummy;
X+ Event event;
X+ int readfd = 1 << (int)window_get(Draw, WIN_FD);
X+
X+ timerclear(&dummy);
X+ while (select(readfd+1, &readfd, 0, 0, &dummy) > 0)
X+ window_read_event(Draw, &event);
X+ }
X+
X+ Sleep(n)
X+ {
X+ sleep(n);
X+ flush_events();
X }
X*** OLD/qix.h Wed Dec 23 17:50:58 1987
X--- qix.h Mon Mar 7 21:28:36 1988
X***************
X*** 19,28 ****
X #include <sys/time.h>
X #include <ctype.h>
X
X #define when break;case
X #define otherwise break;default
X #define rrand random
X- #define SCOREFILE "qix.scores"
X
X Frame frame;
X Canvas Draw, Joystick;
X--- 19,48 ----
X #include <sys/time.h>
X #include <ctype.h>
X
X+ #include <sunwindow/cms_rainbow.h>
X+
X+ /* qix uses 0..7 */
X+ #define QIX_COLOR_BASE 0
X+ #define TEXT_COLOR 8
X+ #define SLOW_DRAW_COLOR 16
X+ #define FAST_DRAW_COLOR 32
X+ #define SPARKS_COLOR RED
X+ #define AGGR_SPARK_COLOR BLUE
X+ #define BORDER_COLOR 128
X+
X+ #define QIX_CMS_SIZE 256
X+ #define QIX_CMS_NAME "QIX"
X+
X+ extern int text_mask;
X+ extern int qix_mask;
X+ extern int fast_draw_mask;
X+ extern int slow_draw_mask;
X+ extern int border_mask;
X+ extern int all_mask;
X+
X #define when break;case
X #define otherwise break;default
X #define rrand random
X
X Frame frame;
X Canvas Draw, Joystick;
X***************
X*** 44,51 ****
X
X struct itimerval timeout;
X
X #define start_timer() \
X! timeout.it_value.tv_usec = 50000, setitimer(ITIMER_REAL, &timeout, NULL);
X #define stop_timer() \
X timerclear(&timeout.it_value), setitimer(ITIMER_REAL, &timeout, NULL);
X
X--- 64,72 ----
X
X struct itimerval timeout;
X
X+ long interval; /* 50000 for monochrome or 35000 for color displays */
X #define start_timer() \
X! timeout.it_value.tv_usec = interval, setitimer(ITIMER_REAL, &timeout, NULL);
X #define stop_timer() \
X timerclear(&timeout.it_value), setitimer(ITIMER_REAL, &timeout, NULL);
X
X***************
X*** 105,113 ****
X extern Pixrect pen_image;
X
X /* place_pen() macro XOR's the pen at its current coordinates */
X! #define place_pen() pw_rop(draw_win, \
X! pen_coord_x(pen_x), pen_coord_y(pen_y), \
X! 16, 16, XOR, &pen_image, 0, 0)
X
X #define XOR (PIX_SRC^PIX_DST)
X #define draw(x1,y1,x2,y2,OP) pw_vector(draw_win, x1,y1,x2,y2,(OP),1)
X--- 126,136 ----
X extern Pixrect pen_image;
X
X /* place_pen() macro XOR's the pen at its current coordinates */
X! #define place_pen() \
X! pw_putattributes(draw_win, &qix_mask), \
X! pw_rop(draw_win, \
X! pen_coord_x(pen_x), pen_coord_y(pen_y), \
X! 16, 16, XOR|PIX_COLOR(VIOLET), &pen_image, 0, 0)
X
X #define XOR (PIX_SRC^PIX_DST)
X #define draw(x1,y1,x2,y2,OP) pw_vector(draw_win, x1,y1,x2,y2,(OP),1)
X*** OLD/qmove.c Mon Jan 11 14:53:04 1988
X--- qmove.c Mon Mar 7 21:41:38 1988
X***************
X*** 38,44 ****
X static index = 0, count;
X int i, j;
X
X! if (level < 0 && count++ & 1)
X return 0;
X
X if (qix1_x0[index] <= 0)
X--- 38,44 ----
X static index = 0, count;
X int i, j;
X
X! if (level < -1 && count++ & 1)
X return 0;
X
X if (qix1_x0[index] <= 0)
X***************
X*** 87,97 ****
X i = (index + 1) % NLINES;
X
X /* erase old line */
X draw(convert_x(qix1_x0[i]), convert_y(qix1_y0[i]),
X! convert_x(qix1_x1[i]), convert_y(qix1_y1[i]), PIX_CLR);
X if (level > -1)
X draw(convert_x(qix2_x0[i]), convert_y(qix2_y0[i]),
X! convert_x(qix2_x1[i]), convert_y(qix2_y1[i]), PIX_CLR);
X
X qix1_x0[i] = qix1_x0[index] + qix1_dx0;
X qix1_y0[i] = qix1_y0[index] + qix1_dy0;
X--- 87,102 ----
X i = (index + 1) % NLINES;
X
X /* erase old line */
X+ pw_putattributes(draw_win, &qix_mask);
X draw(convert_x(qix1_x0[i]), convert_y(qix1_y0[i]),
X! convert_x(qix1_x1[i]), convert_y(qix1_y1[i]),
X! PIX_CLR|PIX_COLOR((index % CMS_RAINBOWSIZE) +
X! QIX_COLOR_BASE));
X if (level > -1)
X draw(convert_x(qix2_x0[i]), convert_y(qix2_y0[i]),
X! convert_x(qix2_x1[i]), convert_y(qix2_y1[i]),
X! PIX_CLR|PIX_COLOR((index % CMS_RAINBOWSIZE) +
X! QIX_COLOR_BASE));
X
X qix1_x0[i] = qix1_x0[index] + qix1_dx0;
X qix1_y0[i] = qix1_y0[index] + qix1_dy0;
X***************
X*** 107,116 ****
X index = i;
X
X draw(convert_x(qix1_x0[i]), convert_y(qix1_y0[i]),
X! convert_x(qix1_x1[i]), convert_y(qix1_y1[i]), PIX_SRC);
X if (level > -1)
X draw(convert_x(qix2_x0[i]), convert_y(qix2_y0[i]),
X! convert_x(qix2_x1[i]), convert_y(qix2_y1[i]), PIX_SRC);
X return j;
X }
X
X--- 112,125 ----
X index = i;
X
X draw(convert_x(qix1_x0[i]), convert_y(qix1_y0[i]),
X! convert_x(qix1_x1[i]), convert_y(qix1_y1[i]),
X! PIX_SRC|PIX_COLOR((index % CMS_RAINBOWSIZE) +
X! QIX_COLOR_BASE));
X if (level > -1)
X draw(convert_x(qix2_x0[i]), convert_y(qix2_y0[i]),
X! convert_x(qix2_x1[i]), convert_y(qix2_y1[i]),
X! PIX_SRC|PIX_COLOR((index % CMS_RAINBOWSIZE) +
X! QIX_COLOR_BASE));
X return j;
X }
X
X***************
X*** 125,134 ****
X if (!(rrand() % 10)) {
X register int r;
X /* move at least one space, but not greater than "Speed" */
X! *dx0 = (1 + (r = rrand())%(Speed-1)) * ((r&1) ? -1 : 1);
X! *dy0 = (1 + (r = rrand())%(Speed-1)) * ((r&1) ? -1 : 1);
X! *dx1 = (1 + (r = rrand())%(Speed-1)) * ((r&1) ? -1 : 1);
X! *dy1 = (1 + (r = rrand())%(Speed-1)) * ((r&1) ? -1 : 1);
X /* check that qix is moving towards player */
X if (level > -2 && !(rrand() % (6 - level))) {
X if (pen_x - x0 > 0 && *dx0 < 0)
X--- 134,147 ----
X if (!(rrand() % 10)) {
X register int r;
X /* move at least one space, but not greater than "Speed" */
X! r = rrand();
X! *dx0 = (1 + r%(Speed-1)) * ((r&1) ? -1 : 1);
X! r = rrand();
X! *dy0 = (1 + r%(Speed-1)) * ((r&1) ? -1 : 1);
X! r = rrand();
X! *dx1 = (1 + r%(Speed-1)) * ((r&1) ? -1 : 1);
X! r = rrand();
X! *dy1 = (1 + r%(Speed-1)) * ((r&1) ? -1 : 1);
X /* check that qix is moving towards player */
X if (level > -2 && !(rrand() % (6 - level))) {
X if (pen_x - x0 > 0 && *dx0 < 0)
X***************
X*** 180,186 ****
X if (!(++loop_count % 100)) {
X #ifdef DEBUG
X msg("bad news... loop count hit %d", loop_count);
X! sleep(2);
X remove_msgs(0);
X #endif DEBUG
X break;
X--- 193,199 ----
X if (!(++loop_count % 100)) {
X #ifdef DEBUG
X msg("bad news... loop count hit %d", loop_count);
X! Sleep(2);
X remove_msgs(0);
X #endif DEBUG
X break;
X***************
X*** 235,241 ****
X return 0;
X }
X msg("The qix is trapped in a place it shouldn't have gotten to!");
X! sleep(2);
X remove_msgs(0);
X return -1;
X }
X--- 248,254 ----
X return 0;
X }
X msg("The qix is trapped in a place it shouldn't have gotten to!");
X! Sleep(2);
X remove_msgs(0);
X return -1;
X }
X*** OLD/regions.c Mon Dec 21 22:15:46 1987
X--- regions.c Mon Mar 7 21:41:47 1988
X***************
X*** 62,69 ****
X return -1;
X if (level > -1 && edge != n) {
X msg("You split the two qix!");
X! sleep(2);
X! rm_cur_line(PIX_SRC); /* don't erase it, but free it up */
X moving = STOP;
X return 1;
X }
X--- 62,70 ----
X return -1;
X if (level > -1 && edge != n) {
X msg("You split the two qix!");
X! Sleep(2);
X! /* don't erase it, but free it up */
X! rm_cur_line(PIX_SRC|PIX_COLOR(BORDER_COLOR));
X moving = STOP;
X return 1;
X }
X***************
X*** 108,114 ****
X msg("can't fill region; over 10000 positions");
X pen_x = region->x, pen_y = region->y;
X msg("removing bad line ...(takes a while)");
X! rm_cur_line(XOR); /* causes dotted line effect */
X remove_msgs(0);
X return -1;
X }
X--- 109,116 ----
X msg("can't fill region; over 10000 positions");
X pen_x = region->x, pen_y = region->y;
X msg("removing bad line ...(takes a while)");
X! /* causes dotted line effect */
X! rm_cur_line(XOR|PIX_COLOR(BORDER_COLOR));
X remove_msgs(0);
X return -1;
X }
X***************
X*** 258,265 ****
X #endif
X
X toggle_sparks();
X! pw_polygon_2(draw_win, 0,0,1, npts, new_area, PIX_SRC | PIX_DST,
X! fast? &fast_grey : &slow_grey,0,0);
X toggle_sparks();
X
X free(new_area);
X--- 260,270 ----
X #endif
X
X toggle_sparks();
X! pw_putattributes(draw_win, fast ? &fast_draw_mask: &slow_draw_mask);
X! pw_polygon_2(draw_win, 0,0,1, npts, new_area,
X! PIX_SRC | PIX_DST | PIX_COLOR(fast ? FAST_DRAW_COLOR: SLOW_DRAW_COLOR),
X! draw_win->pw_pixrect->pr_depth == 8? NULL :
X! fast? &fast_grey : &slow_grey, 0, 0);
X toggle_sparks();
X
X free(new_area);
X***************
X*** 278,284 ****
X (moving == RIGHT)? "right" : "left",
X (edge == UP)? "up" : (edge == DOWN)? "down" :
X (edge == RIGHT)? "right" : "left");
X! sleep(2);
X remove_msgs(0);
X }
X #endif DEBUG
X--- 283,289 ----
X (moving == RIGHT)? "right" : "left",
X (edge == UP)? "up" : (edge == DOWN)? "down" :
X (edge == RIGHT)? "right" : "left");
X! Sleep(2);
X remove_msgs(0);
X }
X #endif DEBUG
X***************
X*** 285,290 ****
X--- 290,296 ----
X
X rm_cur_line(op)
X {
X+ pw_putattributes(draw_win, &border_mask);
X if (region)
X board[region->x][region->y] = saved_edge;
X while (cur_coord)
X*** OLD/score.c Wed Dec 23 17:47:03 1987
X--- score.c Mon Mar 7 21:42:04 1988
X***************
X*** 15,20 ****
X--- 15,21 ----
X extern char *sys_errlist[];
X extern char *sprintf();
X
X+ /* returns whether the score file can be accessed */
X score_board(Read, names)
X {
X struct scores *scp, *temp;
X***************
X*** 34,46 ****
X #endif DEBUG
X }
X
X! /* read the top ten file into the array and close the file */
X! if ((fd = open(SCOREFILE, O_RDWR)) == -1 ||
X read(fd, (char *) top_ten, sizeof(top_ten)) == -1) {
X msg("No score file:\n%s", sys_errlist[errno]);
X! sleep(2);
X remove_msgs(0);
X! return;
X }
X
X /* Print the list */
X--- 35,50 ----
X #endif DEBUG
X }
X
X! /* read the top ten file into the array and close the file. If it doesn't
X! * open for read/write, it probably doesn't exit -- create it rw for all.
X! */
X! if ((fd = open(SCOREFILE, O_RDWR)) == -1 &&
X! (Read || (fd = open(SCOREFILE, O_WRONLY, 0666))) ||
X read(fd, (char *) top_ten, sizeof(top_ten)) == -1) {
X msg("No score file:\n%s", sys_errlist[errno]);
X! Sleep(2);
X remove_msgs(0);
X! return -1;
X }
X
X /* Print the list */
X***************
X*** 75,80 ****
X--- 79,85 ----
X }
X }
X (void) close(fd);
X+ return 0;
X }
X
X char *
X***************
X*** 102,114 ****
X msg("MIDDLE button to decrement one character.\n");
X msg("Use RETURN or RIGHT button to enter each letter.");
X msg("Use <backspace> key to go back one position.");
X! pw_text(draw_win, x, y, PIX_SRC, big_font, sprintf(s, "%d", score));
X x += 25 * l_width(big_font);
X (void) strcpy(buf, "AAA");
X
X for (len = 0; len < 3;) {
X! pw_text(draw_win, x - len*l_width(big_font), y, PIX_SRC, big_font, buf);
X! pw_char(draw_win, x, y, PIX_SRC|PIX_DST, big_font, '_');
X
X do window_read_event(Draw, &event);
X while (event.ie_code == LOC_MOVE || event.ie_code == LOC_DRAG ||
X--- 107,122 ----
X msg("MIDDLE button to decrement one character.\n");
X msg("Use RETURN or RIGHT button to enter each letter.");
X msg("Use <backspace> key to go back one position.");
X! pw_text(draw_win, x, y, PIX_SRC|PIX_COLOR(TEXT_COLOR), big_font,
X! sprintf(s, "%d", score));
X x += 25 * l_width(big_font);
X (void) strcpy(buf, "AAA");
X
X for (len = 0; len < 3;) {
X! pw_text(draw_win, x - len*l_width(big_font), y,
X! PIX_SRC|PIX_COLOR(TEXT_COLOR), big_font, buf);
X! pw_char(draw_win, x, y, PIX_SRC|PIX_DST|PIX_COLOR(TEXT_COLOR),
X! big_font, '_');
X
X do window_read_event(Draw, &event);
X while (event.ie_code == LOC_MOVE || event.ie_code == LOC_DRAG ||
X*** OLD/sparks.c Mon Sep 7 18:55:05 1987
X--- sparks.c Mon Mar 7 21:42:25 1988
X***************
X*** 35,43 ****
X * move left-right or up-down the formula given finds which icon to use to
X * to guarantee that it's not the last one used.
X */
X! #define draw_spark(x, y) \
X pw_rop(draw_win, pen_coord_x(x), pen_coord_y(y), 16,16, \
X! XOR, spark_icons[(x + y) & 3], 0,0)
X
X struct spark {
X int x, y, oldx, oldy;
X--- 35,43 ----
X * move left-right or up-down the formula given finds which icon to use to
X * to guarantee that it's not the last one used.
X */
X! #define draw_spark(x, y, color) \
X pw_rop(draw_win, pen_coord_x(x), pen_coord_y(y), 16,16, \
X! XOR| PIX_COLOR(color), spark_icons[(x + y) & 3], 0,0)
X
X struct spark {
X int x, y, oldx, oldy;
X***************
X*** 107,112 ****
X--- 107,113 ----
X register int x, y, sp, move_clockwise, came_from, dir;
X /* new spark x and y coord */
X
X+ pw_putattributes(draw_win, &qix_mask);
X for (sp = 0; sp < MAX_SPARKS; sp++) {
X if (sparks[sp].x < 0)
X break;
X***************
X*** 115,125 ****
X * duced in pairs, the second spark will have the same coords and
X * erase this mark. (clever, huh?)
X */
X! draw_spark(sparks[sp].x, sparks[sp].y);
X x = sparks[sp].x, y = sparks[sp].y;
X /* user bit the big one */
X if (x == pen_x && y == pen_y) {
X! draw_spark(sparks[sp].x, sparks[sp].y); /* redraw the spark */
X change_life(DIE);
X return -1;
X }
X--- 116,128 ----
X * duced in pairs, the second spark will have the same coords and
X * erase this mark. (clever, huh?)
X */
X! draw_spark(sparks[sp].x, sparks[sp].y,
X! aggressive? AGGR_SPARK_COLOR : SPARKS_COLOR);
X x = sparks[sp].x, y = sparks[sp].y;
X /* user bit the big one */
X if (x == pen_x && y == pen_y) {
X! draw_spark(sparks[sp].x, sparks[sp].y,
X! aggressive? AGGR_SPARK_COLOR : SPARKS_COLOR);
X change_life(DIE);
X return -1;
X }
X***************
X*** 157,163 ****
X box(convert_x(x)-10, convert_y(y)-10,
X convert_x(x)+10, convert_y(y)+10, XOR);
X msg("HALT! infinite-loop police! [y] (%d, %d)", x, y);
X! sleep(2);
X remove_msgs(0);
X box(convert_x(x)-10, convert_y(y)-10,
X convert_x(x)+10, convert_y(y)+10, XOR);
X--- 160,166 ----
X box(convert_x(x)-10, convert_y(y)-10,
X convert_x(x)+10, convert_y(y)+10, XOR);
X msg("HALT! infinite-loop police! [y] (%d, %d)", x, y);
X! Sleep(2);
X remove_msgs(0);
X box(convert_x(x)-10, convert_y(y)-10,
X convert_x(x)+10, convert_y(y)+10, XOR);
X***************
X*** 182,188 ****
X
X sparks[sp].oldx = sparks[sp].x, sparks[sp].oldy = sparks[sp].y;
X /* draw the new spark */
X! draw_spark(x, y);
X sparks[sp].x = x, sparks[sp].y = y;
X
X if (x == pen_x && y == pen_y) {
X--- 185,191 ----
X
X sparks[sp].oldx = sparks[sp].x, sparks[sp].oldy = sparks[sp].y;
X /* draw the new spark */
X! draw_spark(x, y, aggressive? AGGR_SPARK_COLOR : SPARKS_COLOR);
X sparks[sp].x = x, sparks[sp].y = y;
X
X if (x == pen_x && y == pen_y) {
X***************
X*** 198,214 ****
X /* give the only warning we can without a sound chip :-) */
X fputc(7, stderr), fflush(stderr);
X msg("Sparx are now aggressive.");
X! sleep(2);
X remove_msgs(0);
X aggressive = 1;
X }
X! if (sp == MAX_SPARKS)
X return 0; /* no sparks left to start, so don't do a countdown */
X }
X! start_spark(BOARD_WIDTH/2, 0, TRUE);
X! start_spark(BOARD_WIDTH/2, 0, FALSE);
X! draw(BORDER, 20, BOARD_WIDTH_IN_PIXELS-BORDER, 20, PIX_SRC);
X! draw(BORDER, 21, BOARD_WIDTH_IN_PIXELS-BORDER, 21, PIX_SRC);
X }
X if (sp < MAX_SPARKS) {
X /* calculate the percentage of the width of the board in pixels */
X--- 201,224 ----
X /* give the only warning we can without a sound chip :-) */
X fputc(7, stderr), fflush(stderr);
X msg("Sparx are now aggressive.");
X! Sleep(2);
X remove_msgs(0);
X+ /* erase red sparks now or blue sparks will leave green */
X+ toggle_sparks();
X aggressive = 1;
X+ /* now draw blue sparks */
X+ toggle_sparks();
X }
X! if (sp == MAX_SPARKS) {
X return 0; /* no sparks left to start, so don't do a countdown */
X+ }
X }
X! start_spark(BOARD_WIDTH/2, 0);
X! start_spark(BOARD_WIDTH/2, 0);
X! draw(BORDER, 20, BOARD_WIDTH_IN_PIXELS-BORDER, 20,
X! PIX_SRC|PIX_COLOR(SPARKS_COLOR));
X! draw(BORDER, 21, BOARD_WIDTH_IN_PIXELS-BORDER, 21,
X! PIX_SRC|PIX_COLOR(SPARKS_COLOR));
X }
X if (sp < MAX_SPARKS) {
X /* calculate the percentage of the width of the board in pixels */
X***************
X*** 236,248 ****
X static x = -1, y;
X int n;
X
X if (x > -1)
X! draw_spark(x, y);
X if (!pos || !*pos) {
X x = -1;
X return 0;
X }
X! draw_spark((*pos)->x, (*pos)->y);
X x = (*pos)->x, y = (*pos)->y;
X
X if ((*pos)->x == pen_x && (*pos)->y == pen_y) {
X--- 246,260 ----
X static x = -1, y;
X int n;
X
X+ /* fuse is always red */
X+ pw_putattributes(draw_win, &qix_mask);
X if (x > -1)
X! draw_spark(x, y, SPARKS_COLOR);
X if (!pos || !*pos) {
X x = -1;
X return 0;
X }
X! draw_spark((*pos)->x, (*pos)->y, SPARKS_COLOR);
X x = (*pos)->x, y = (*pos)->y;
X
X if ((*pos)->x == pen_x && (*pos)->y == pen_y) {
X***************
X*** 263,272 ****
X {
X int n;
X
X /* for each spark, if active, make it go away and reset to -1 */
X for (n = 0; n < MAX_SPARKS; n++)
X if (sparks[n].x > -1) {
X! draw_spark(sparks[n].x, sparks[n].y);
X sparks[n].oldx = sparks[n].x = -1;
X }
X draw(BORDER, 20, BOARD_WIDTH_IN_PIXELS-BORDER, 20, PIX_CLR);
X--- 275,286 ----
X {
X int n;
X
X+ pw_putattributes(draw_win, &qix_mask);
X /* for each spark, if active, make it go away and reset to -1 */
X for (n = 0; n < MAX_SPARKS; n++)
X if (sparks[n].x > -1) {
X! draw_spark(sparks[n].x, sparks[n].y,
X! aggressive? AGGR_SPARK_COLOR : SPARKS_COLOR);
X sparks[n].oldx = sparks[n].x = -1;
X }
X draw(BORDER, 20, BOARD_WIDTH_IN_PIXELS-BORDER, 20, PIX_CLR);
X***************
X*** 282,290 ****
X {
X register int sp;
X
X for (sp = 0; sp < MAX_SPARKS; sp++) {
X if (sparks[sp].x < 0)
X break;
X! draw_spark(sparks[sp].x, sparks[sp].y);
X }
X }
X--- 296,306 ----
X {
X register int sp;
X
X+ pw_putattributes(draw_win, &qix_mask);
X for (sp = 0; sp < MAX_SPARKS; sp++) {
X if (sparks[sp].x < 0)
X break;
X! draw_spark(sparks[sp].x, sparks[sp].y,
X! aggressive? AGGR_SPARK_COLOR : SPARKS_COLOR);
X }
X }
END_OF_Patches01
if test 42908 -ne `wc -c <Patches01`; then
echo shar: \"Patches01\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0