#include "defs.h" void define_shapes() { /* begin shape 0 definition, four rotations */ shape[0].table[0][0] = 0; shape[0].table[1][0] = 15; /* #### */ shape[0].table[2][0] = 0; shape[0].table[3][0] = 0; shape[0].pointv[0] = 5; shape[0].table[0][1] = 4; /* # */ shape[0].table[1][1] = 4; /* # */ shape[0].table[2][1] = 4; /* # */ shape[0].table[3][1] = 4; /* # */ shape[0].pointv[1] = 8; shape[0].table[0][2] = 0; shape[0].table[1][2] = 15; /* #### */ shape[0].table[2][2] = 0; shape[0].table[3][2] = 0; shape[0].pointv[2] = 5; shape[0].table[0][3] = 4; /* # */ shape[0].table[1][3] = 4; /* # */ shape[0].table[2][3] = 4; /* # */ shape[0].table[3][3] = 4; /* # */ shape[0].pointv[2] = 8; shape[0].width = 4; shape[0].height = 1; shape[0].offset = 153; shape[0].color = RED; shape[0].cycletop = 2; /* begin shape 1 definition, four rotations */ shape[1].table[0][0] = 12; /* ## */ shape[1].table[1][0] = 12; /* ## */ shape[1].table[2][0] = 0; /* */ shape[1].table[3][0] = 0; /* */ shape[1].pointv[0] = 6; shape[1].table[0][1] = 12; /* ## */ shape[1].table[1][1] = 12; /* ## */ shape[1].table[2][1] = 0; /* */ shape[1].table[3][1] = 0; /* */ shape[1].pointv[1] = 6; shape[1].table[0][2] = 12; /* ## */ shape[1].table[1][2] = 12; /* ## */ shape[1].table[2][2] = 0; /* */ shape[1].table[3][2] = 0; /* */ shape[1].pointv[2] = 6; shape[1].table[0][3] = 12; /* ## */ shape[1].table[1][3] = 12; /* ## */ shape[1].table[2][3] = 0; /* */ shape[1].table[3][3] = 0; /* */ shape[1].pointv[3] = 6; shape[1].width = 2; shape[1].height = 2; shape[1].offset = 0; shape[1].color = ORANGE; shape[1].cycletop = 1; /* begin shape 2 definition, four rotations */ shape[2].table[0][0] = 4; /* # */ shape[2].table[1][0] = 14; /* ### */ shape[2].table[2][0] = 0; /* */ shape[2].table[3][0] = 0; /* */ shape[2].pointv[0] = 5; shape[2].table[0][1] = 4; /* # */ shape[2].table[1][1] = 6; /* ## */ shape[2].table[2][1] = 4; /* # */ shape[2].table[3][1] = 0; /* */ shape[2].pointv[0] = 5; shape[2].table[0][2] = 0; /* */ shape[2].table[1][2] = 14; /* ### */ shape[2].table[2][2] = 4; /* # */ shape[2].table[3][2] = 0; /* */ shape[2].pointv[2] = 6; shape[2].table[0][3] = 4; /* # */ shape[2].table[1][3] = 12; /* ## */ shape[2].table[2][3] = 4; /* # */ shape[2].table[3][3] = 0; /* */ shape[2].pointv[3] = 5; shape[2].width = 3; shape[2].height = 2; shape[2].offset = 24; shape[2].color = YELLOW; shape[2].cycletop = 4; /* begin shape 3 definition, four rotations */ shape[3].table[0][0] = 12; /* ## */ shape[3].table[1][0] = 6; /* ## */ shape[3].table[2][0] = 0; /* */ shape[3].table[3][0] = 0; /* */ shape[3].pointv[0] = 6; shape[3].table[0][1] = 4; /* # */ shape[3].table[1][1] = 12; /* ## */ shape[3].table[2][1] = 8; /* # */ shape[3].table[3][1] = 0; /* */ shape[3].pointv[1] = 7; shape[3].table[0][2] = 12; /* ## */ shape[3].table[1][2] = 6; /* ## */ shape[3].table[2][2] = 0; /* */ shape[3].table[3][2] = 0; /* */ shape[3].pointv[2] = 6; shape[3].table[0][3] = 4; /* # */ shape[3].table[1][3] = 12; /* ## */ shape[3].table[2][3] = 8; /* # */ shape[3].table[3][3] = 0; /* */ shape[3].pointv[3] = 7; shape[3].width = 3; shape[3].height = 2; shape[3].offset = 0; shape[3].color = GREEN; shape[3].cycletop = 2; /* begin shape 4 definition, four rotations */ shape[4].table[0][0] = 6; /* ## */ shape[4].table[1][0] = 12; /* ## */ shape[4].table[2][0] = 0; /* */ shape[4].table[3][0] = 0; /* */ shape[4].pointv[0] = 6; shape[4].table[0][1] = 8; /* # */ shape[4].table[1][1] = 12; /* ## */ shape[4].table[2][1] = 4; /* # */ shape[4].table[3][1] = 0; /* */ shape[4].pointv[1] = 7; shape[4].table[0][2] = 6; /* ## */ shape[4].table[1][2] = 12; /* ## */ shape[4].table[2][2] = 0; /* */ shape[4].table[3][2] = 0; /* */ shape[4].pointv[2] = 6; shape[4].table[0][3] = 8; /* # */ shape[4].table[1][3] = 12; /* ## */ shape[4].table[2][3] = 4; /* # */ shape[4].table[3][3] = 0; /* */ shape[4].pointv[3] = 7; shape[4].width = 3; shape[4].height = 2; shape[4].offset = 0; shape[4].color = BLUE; shape[4].cycletop = 2; /* begin shape 5 definition, four rotations */ shape[5].table[0][0] = 2; /* # */ shape[5].table[1][0] = 14; /* ### */ shape[5].table[2][0] = 0; /* */ shape[5].table[3][0] = 0; /* */ shape[5].pointv[0] = 6; shape[5].table[0][1] = 8; /* # */ shape[5].table[1][1] = 8; /* # */ shape[5].table[2][1] = 12; /* ## */ shape[5].table[3][1] = 0; /* */ shape[5].pointv[1] = 7; shape[5].table[0][2] = 14; /* ### */ shape[5].table[1][2] = 8; /* # */ shape[5].table[2][2] = 0; /* */ shape[5].table[3][2] = 0; /* */ shape[5].pointv[2] = 6; shape[5].table[0][3] = 12; /* ## */ shape[5].table[1][3] = 4; /* # */ shape[5].table[2][3] = 4; /* # */ shape[5].table[3][3] = 0; /* */ shape[5].pointv[3] = 7; shape[5].width = 3; shape[5].height = 2; shape[5].offset = 0; shape[5].color = CYAN; shape[5].cycletop = 4; /* begin shape 6 definition, four rotations */ shape[6].table[0][0] = 14; /* ### */ shape[6].table[1][0] = 2; /* # */ shape[6].table[2][0] = 0; /* */ shape[6].table[3][0] = 0; /* */ shape[6].pointv[0] = 6; shape[6].table[0][1] = 4; /* # */ shape[6].table[1][1] = 4; /* # */ shape[6].table[2][1] = 12; /* ## */ shape[6].table[3][1] = 0; /* */ shape[6].pointv[1] = 7; shape[6].table[0][2] = 8; /* # */ shape[6].table[1][2] = 14; /* ### */ shape[6].table[2][2] = 0; /* */ shape[6].table[3][2] = 0; /* */ shape[6].pointv[2] = 6; shape[6].table[0][3] = 12; /* ## */ shape[6].table[1][3] = 8; /* # */ shape[6].table[2][3] = 8; /* # */ shape[6].table[3][3] = 0; /* */ shape[6].pointv[3] = 7; shape[6].width = 3; shape[6].height = 2; shape[6].offset = 0; shape[6].color = VIOLET; shape[6].cycletop = 4; } store_shape(shape_no, xpos, ypos, rot) int shape_no, xpos, ypos, rot; { int i; for (i = 0; i < 4; i++) { if (shape[shape_no].table[i][rot] & 8) displaygrid[xpos][ypos + i] = 1; if (shape[shape_no].table[i][rot] & 4) displaygrid[xpos + 1][ypos + i] = 1; if (shape[shape_no].table[i][rot] & 2) displaygrid[xpos + 2][ypos + i] = 1; if (shape[shape_no].table[i][rot] & 1) displaygrid[xpos + 3][ypos + i] = 1; } } create_shape() { AdversaryChoosePiece(); display_xpos = (UWIDTH / 2) - 1; display_ypos = -4; chooseplay(); } void compute_shape_constants() { int shape_no; int rot; for (shape_no = 0; shape_no < 7; shape_no += 1) { for (rot = 0; rot < 4; rot += 1) { shape[shape_no].minX[rot] = minX(shape_no, rot); shape[shape_no].maxX[rot] = maxX(shape_no, rot); } } } minX(shape_no, rot) int shape_no, rot; { int y, x; int mask = 0x8; int found; for (x = 0; x < 4; x++) { found = 0; for (y = 0; y < 4; y++) { if (mask & shape[shape_no].table[y][rot]) { found = 1; } } if (found) { break; } mask >>= 1; } return -x; } maxX(shape_no, rot) int shape_no, rot; { int y, x; int mask = 0x1; int found; for (x = 0; x < 4; x++) { found = 0; for (y = 0; y < 4; y++) { if (mask & shape[shape_no].table[y][rot]) { found = 1; } } if (found) { break; } mask <<= 1; } return UWIDTH - 4 + x; }