Changeset ebe70f1 in mainline for uspace/app/tetris/shapes.c
- Timestamp:
- 2009-06-09T11:10:31Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f3afd24
- Parents:
- 080ad7f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tetris/shapes.c
r080ad7f rebe70f1 37 37 38 38 /** @addtogroup tetris 39 * @{ 39 * @{ 40 40 */ 41 41 /** @file … … 51 51 #include "tetris.h" 52 52 53 #define TL -B_COLS-1/* top left */54 #define TC -B_COLS/* top center */55 #define TR -B_COLS+1/* top right */56 #define ML -1/* middle left */57 #define MR 1/* middle right */58 #define BL B_COLS-1/* bottom left */59 #define BC B_COLS/* bottom center */60 #define BR B_COLS+1/* bottom right */53 #define TL (-B_COLS - 1) /* top left */ 54 #define TC (-B_COLS) /* top center */ 55 #define TR (-B_COLS + 1) /* top right */ 56 #define ML -1 /* middle left */ 57 #define MR 1 /* middle right */ 58 #define BL (B_COLS - 1) /* bottom left */ 59 #define BC B_COLS /* bottom center */ 60 #define BR (B_COLS + 1) /* bottom right */ 61 61 62 62 const struct shape shapes[] = { 63 /* 0*/ { 7, 7, { TL, TC, MR }},64 /* 1*/ { 8, 8, { TC, TR, ML }},65 /* 2*/ { 9, 11, { ML, MR, BC }},66 /* 3*/ { 3, 3, { TL, TC, ML }},67 /* 4*/ { 12, 14, { ML, BL, MR }},68 /* 5*/ { 15, 17, { ML, BR, MR }},69 /* 6*/ { 18, 18, { ML, MR, 2 } },/* sticks out */70 /* 7*/ { 0, 0, { TC, ML, BL }},71 /* 8*/ { 1, 1, { TC, MR, BR }},72 /* 9*/ { 10, 2, { TC, MR, BC }},73 /* 10*/ { 11, 9, { TC, ML, MR }},74 /* 11*/ { 2, 10, { TC, ML, BC }},75 /* 12*/ { 13, 4, { TC, BC, BR }},76 /* 13*/ { 14, 12, { TR, ML, MR }},77 /* 14*/ { 4, 13, { TL, TC, BC }},78 /* 15*/ { 16, 5, { TR, TC, BC }},79 /* 16*/ { 17, 15, { TL, MR, ML }},80 /* 17*/ { 5, 16, { TC, BC, BL }},81 /* 18*/ { 6, 6, { TC, BC, 2*B_COLS } }/* sticks out */63 /* 0 */ { 7, 7, { TL, TC, MR }, 0xff042d}, 64 /* 1 */ { 8, 8, { TC, TR, ML }, 0xff9304}, 65 /* 2 */ { 9, 11, { ML, MR, BC }, 0xbeff04}, 66 /* 3 */ { 3, 3, { TL, TC, ML }, 0x63ff04}, 67 /* 4 */ { 12, 14, { ML, BL, MR }, 0xce04ff}, 68 /* 5 */ { 15, 17, { ML, BR, MR }, 0xff04cf}, 69 /* 6 */ { 18, 18, { ML, MR, 2 }, 0x7604ff}, /* sticks out */ 70 /* 7 */ { 0, 0, { TC, ML, BL }, 0xff042d}, 71 /* 8 */ { 1, 1, { TC, MR, BR }, 0xff9304}, 72 /* 9 */ { 10, 2, { TC, MR, BC }, 0xbeff04}, 73 /* 10 */ { 11, 9, { TC, ML, MR }, 0xbeff04}, 74 /* 11 */ { 2, 10, { TC, ML, BC }, 0xbeff04}, 75 /* 12 */ { 13, 4, { TC, BC, BR }, 0xce04ff}, 76 /* 13 */ { 14, 12, { TR, ML, MR }, 0xce04ff}, 77 /* 14 */ { 4, 13, { TL, TC, BC }, 0xce04ff}, 78 /* 15 */ { 16, 5, { TR, TC, BC }, 0xff04cf}, 79 /* 16 */ { 17, 15, { TL, MR, ML }, 0xff04cf}, 80 /* 17 */ { 5, 16, { TC, BC, BL }, 0xff04cf}, 81 /* 18 */ { 6, 6, { TC, BC, 2 * B_COLS }, 0x7604ff} /* sticks out */ 82 82 }; 83 83 … … 86 86 * taking the current board into account. 87 87 */ 88 int 89 fits_in(const struct shape *shape, int pos) 88 int fits_in(const struct shape *shape, int pos) 90 89 { 91 90 int *o = shape->off; 92 93 if ( board[pos] || board[pos + *o++] || board[pos + *o++]||94 board[pos + *o])91 92 if ((board[pos]) || (board[pos + *o++]) || (board[pos + *o++]) || 93 (board[pos + *o])) 95 94 return 0; 95 96 96 return 1; 97 97 } … … 101 101 * if `onoff' is 1, and off if `onoff' is 0. 102 102 */ 103 void 104 place(const struct shape *shape, int pos, int onoff) 103 void place(const struct shape *shape, int pos, int onoff) 105 104 { 106 105 int *o = shape->off; 107 108 board[pos] = onoff ;109 board[pos + *o++] = onoff ;110 board[pos + *o++] = onoff ;111 board[pos + *o] = onoff ;106 107 board[pos] = onoff ? shape->color : 0x000000; 108 board[pos + *o++] = onoff ? shape->color : 0x000000; 109 board[pos + *o++] = onoff ? shape->color : 0x000000; 110 board[pos + *o] = onoff ? shape->color : 0x000000; 112 111 } 113 112 114 113 /** @} 115 114 */ 116
Note:
See TracChangeset
for help on using the changeset viewer.