Path: utzoo!attcan!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!lth.se!newsuser From: e87ac@efd.lth.se (Anders Carlsson) Newsgroups: comp.windows.x Subject: Bugfix for xtetris Message-ID: <1990May2.082839.18570@lth.se> Date: 2 May 90 08:28:39 GMT Sender: newsuser@lth.se (LTH network news server) Reply-To: e87ac@efd.lth.se (Anders Carlsson) Organization: Lund Institute of Technology, Sweden Lines: 208 I don't know if anyone has already sent out fixes for xtetris, anyway: The xtetris program in the R4/contrib distribution didn't work right because of some bugs in the source code. The bugs generated the following symptoms: * The game ended immediately after it started, with only the first block appearing on the screen. * After fixing the above, I discoverd that the "Vertical Bar" was impossible to move away from the left side of the game area, when moved there. * One of the dogleg figures was missing (dogleg left & dogleg right were identical). * when filling more than two rows at one time, e.g with a wertical bar, the game stopped. Oh, there are more bugs, but after fixing the few mentioned ones, the game is possible to play, enjoy. /Anders. ---------------------------------------------------------------------------- Festina lente; The Anders Carlsson snail: K{mmn{rsv{gen 8:171 world will wait email: e87ac@efd.lth.se S-222 45 Lund for you. tel int: +46 46 188797 Sweden ---------------------------------------------------------------------------- --------------------- Cut Here ------------------ *** Tetris.c.orig Wed May 2 09:54:51 1990 --- Tetris.c Wed May 2 10:17:04 1990 *************** *** 55,62 **** 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, /* 11 horiz T upside */ 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, /* 12 vertical dogleg left */ 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, /* 13 horiz dogleg left */ ! 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, /* 14 vertical dogleg right */ ! 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, /* 15 horiz dogleg right */ 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, /* 16 long bar (vert) */ 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, /* 17 long bar (horiz) */ 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, /* 18 dummy */ --- 55,62 ---- 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, /* 11 horiz T upside */ 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, /* 12 vertical dogleg left */ 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, /* 13 horiz dogleg left */ ! 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, /* 14 vertical dogleg right */ ! 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, /* 15 horiz dogleg right */ 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, /* 16 long bar (vert) */ 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, /* 17 long bar (horiz) */ 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, /* 18 dummy */ *************** *** 76,84 **** offset(tetris.level), XtRImmediate, (caddr_t) 3}, {XtNcellSizeInPixels, XtCCellSizeInPixels, XtRInt, sizeof(int), offset(tetris.cell_size_in_pixels), XtRImmediate, (caddr_t)DEFAULT_CELL_SIZE }, ! {XtNpixmapWidthInCells, XtCPixmapWidthInCells, XtRDimension, sizeof(Dimension), offset(tetris.pixmap_width_in_cells), XtRImmediate, (caddr_t)DEFAULT_PIXMAP_WIDTH }, ! {XtNpixmapHeightInCells, XtCPixmapHeightInCells, XtRDimension, sizeof(Dimension), offset(tetris.pixmap_height_in_cells), XtRImmediate, (caddr_t)DEFAULT_PIXMAP_HEIGHT }, {XtNdelay, XtCDelay, XtRInt, sizeof(int), offset(tetris.delay), XtRImmediate, (caddr_t) DEFAULT_DELAY}, --- 76,84 ---- offset(tetris.level), XtRImmediate, (caddr_t) 3}, {XtNcellSizeInPixels, XtCCellSizeInPixels, XtRInt, sizeof(int), offset(tetris.cell_size_in_pixels), XtRImmediate, (caddr_t)DEFAULT_CELL_SIZE }, ! {XtNpixmapWidthInCells, XtCPixmapWidthInCells, XtRInt, sizeof(int), offset(tetris.pixmap_width_in_cells), XtRImmediate, (caddr_t)DEFAULT_PIXMAP_WIDTH }, ! {XtNpixmapHeightInCells, XtCPixmapHeightInCells, XtRInt, sizeof(int), offset(tetris.pixmap_height_in_cells), XtRImmediate, (caddr_t)DEFAULT_PIXMAP_HEIGHT }, {XtNdelay, XtCDelay, XtRInt, sizeof(int), offset(tetris.delay), XtRImmediate, (caddr_t) DEFAULT_DELAY}, *************** *** 533,539 **** String *direction; { int i; ! int x, y, xoff; if (*direction[0] == 'l') { xoff = -1; --- 533,539 ---- String *direction; { int i; ! int xoff; if (*direction[0] == 'l') { xoff = -1; *************** *** 621,632 **** return(False); } } ! else if (w->tetris.cell[w->tetris.cur_x + (i % BLOCK_WIDTH)][w->tetris.cur_y + (i % BLOCK_LENGTH) + 1]) { return(False); } } } } static void --- 621,633 ---- return(False); } } ! else /* even, vertical */ if (w->tetris.cell[w->tetris.cur_x + (i % BLOCK_WIDTH)][w->tetris.cur_y + (i % BLOCK_LENGTH) + 1]) { return(False); } } } + return(True); } static void *************** *** 682,699 **** if (crunched_row[0]) { /* some crunching to do */ /* now move down the array to reflect crunched rows */ for (j = 0; j < i; j++) { /* do up to 4 crunched rows */ ! for (y = crunched_row[j]; y >= 0; y--) { for (x = 0;x < w->tetris.pixmap_width_in_cells; x++) { w->tetris.cell[x][y] = w->tetris.cell[x][y - 1]; } } } - for (x = 0;x < w->tetris.pixmap_width_in_cells; x++) { - w->tetris.cell[x][0] = 0; - w->tetris.cell[x][1] = 0; - } } - /* clear first two rows. For some reason they're full of garbarge */ } Score(w) --- 683,695 ---- if (crunched_row[0]) { /* some crunching to do */ /* now move down the array to reflect crunched rows */ for (j = 0; j < i; j++) { /* do up to 4 crunched rows */ ! for (y = crunched_row[j]; y > 0; y--) { for (x = 0;x < w->tetris.pixmap_width_in_cells; x++) { w->tetris.cell[x][y] = w->tetris.cell[x][y - 1]; } } } } } Score(w) *************** *** 723,729 **** w->tetris.cell[w->tetris.cur_x + xoffset][w->tetris.cur_y + yoffset] = True; } } ! if (w->tetris.cur_y < 3) { /* block ends up near top */ XtCallCallbacks(w, XtNgameover, w->tetris.score); XtRemoveTimeOut(timer); w->tetris.running = False; /* stop play */ --- 719,725 ---- w->tetris.cell[w->tetris.cur_x + xoffset][w->tetris.cur_y + yoffset] = True; } } ! if (w->tetris.cur_y < 1) { /* block ends up near top */ XtCallCallbacks(w, XtNgameover, w->tetris.score); XtRemoveTimeOut(timer); w->tetris.running = False; /* stop play */ *** TetrisP.h.old Sun Mar 25 16:12:48 1990 --- TetrisP.h Tue Apr 10 19:48:35 1990 *************** *** 41,48 **** Pixel foreground; XtCallbackList callback; /* application installed callback function(s) */ XtCallbackList gameover; ! Dimension pixmap_width_in_cells; ! Dimension pixmap_height_in_cells; int cell_size_in_pixels; int delay; int level; --- 41,48 ---- Pixel foreground; XtCallbackList callback; /* application installed callback function(s) */ XtCallbackList gameover; ! int pixmap_width_in_cells; ! int pixmap_height_in_cells; int cell_size_in_pixels; int delay; int level; *** xtetris.c.old Sun Mar 25 16:12:48 1990 --- xtetris.c Tue Apr 10 19:49:06 1990 *************** *** 47,53 **** #include "Tetris.h" ! Dimension pixmap_width_in_cells, pixmap_height_in_cells; Widget topLevel, tetris, form, score_label, pause, pshell, highscoretop; Widget initialShell, initialDialog, gameoverShell, gameoverDialog; --- 47,53 ---- #include "Tetris.h" ! int pixmap_width_in_cells, pixmap_height_in_cells; Widget topLevel, tetris, form, score_label, pause, pshell, highscoretop; Widget initialShell, initialDialog, gameoverShell, gameoverDialog;