Changeset ebe70f1 in mainline for uspace/app/tetris/tetris.h


Ignore:
Timestamp:
2009-06-09T11:10:31Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f3afd24
Parents:
080ad7f
Message:

slightly cleanup the horrible mess of tetris
introduce colors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tetris/tetris.h

    r080ad7f rebe70f1  
    3737
    3838/** @addtogroup tetris
    39  * @{ 
     39 * @{
    4040 */
    4141/** @file
     
    5656 */
    5757
    58         /* the board */
    59 #define B_COLS  12
    60 #define B_ROWS  23
    61 #define B_SIZE  (B_ROWS * B_COLS)
     58/* The board */
     59#define B_COLS  12
     60#define B_ROWS  23
     61#define B_SIZE  (B_ROWS * B_COLS)
    6262
    63 typedef unsigned char cell;
    64 extern cell     board[B_SIZE];  /* 1 => occupied, 0 => empty */
     63typedef uint32_t cell;
    6564
    66         /* the displayed area (rows) */
    67 #define D_FIRST 1
    68 #define D_LAST  22
     65extern cell board[B_SIZE];  /* 1 => occupied, 0 => empty */
    6966
    70         /* the active area (rows) */
    71 #define A_FIRST 1
    72 #define A_LAST  21
     67/* The displayed area (rows) */
     68#define D_FIRST  1
     69#define D_LAST   22
     70
     71/* The active area (rows) */
     72#define A_FIRST  1
     73#define A_LAST   21
    7374
    7475/*
    7576 * Minimum display size.
    7677 */
    77 #define MINROWS 23
    78 #define MINCOLS 40
     78#define MINROWS  23
     79#define MINCOLS  40
    7980
    80 extern int      Rows, Cols;     /* current screen size */
     81/* Current screen size */
     82extern int Rows;
     83extern int Cols;
    8184
    8285/*
     
    8487 * As with board coordinates, display coordiates are zero origin.
    8588 */
    86 #define RTOD(x) ((x) - 1)
    87 #define CTOD(x) ((x) * 2 + (((Cols - 2 * B_COLS) >> 1) - 1))
     89#define RTOD(x)  ((x) - 1)
     90#define CTOD(x)  ((x) * 2 + (((Cols - 2 * B_COLS) >> 1) - 1))
    8891
    8992/*
     
    9194 * are 7 basic shapes, each consisting of four `blots':
    9295 *
    93  *      X.X       X.X           X.X
    94  *        X.X   X.X     X.X.X   X.X     X.X.X   X.X.X   X.X.X.X
    95  *                        X             X           X
     96 *      X.X       X.X           X.X
     97 *        X.X   X.X     X.X.X   X.X     X.X.X   X.X.X   X.X.X.X
     98 *                        X             X           X
    9699 *
    97  *        0       1       2       3       4       5       6
     100 *          0     1       2       3       4       5       6
    98101 *
    99102 * Except for 3 and 6, the center of each shape is one of the blots.
    100  * This blot is designated (0,0).  The other three blots can then be
     103 * This blot is designated (0, 0).  The other three blots can then be
    101104 * described as offsets from the center.  Shape 3 is the same under
    102105 * rotation, so its center is effectively irrelevant; it has been chosen
    103106 * so that it `sticks out' upward and leftward.  Except for shape 6,
    104  * all the blots are contained in a box going from (-1,-1) to (+1,+1);
     107 * all the blots are contained in a box going from (-1, -1) to (+1, +1);
    105108 * shape 6's center `wobbles' as it rotates, so that while it `sticks out'
    106109 * rightward, its rotation---a vertical line---`sticks out' downward.
    107  * The containment box has to include the offset (2,0), making the overall
    108  * containment box range from offset (-1,-1) to (+2,+1).  (This is why
     110 * The containment box has to include the offset (2, 0), making the overall
     111 * containment box range from offset (-1, -1) to (+2, +1).  (This is why
    109112 * there is only one row above, but two rows below, the display area.)
    110113 *
     
    117120 * these rows move down to make more room.  A new random shape is again
    118121 * introduced at the top of the board, and the whole process repeats.
    119  * The game ends when the new shape will not fit at (1,5).
     122 * The game ends when the new shape will not fit at (1, 5).
    120123 *
    121124 * While the shapes are falling, the user can rotate them counterclockwise
     
    129132 */
    130133struct shape {
    131         int     rot;    /* index of rotated version of this shape */
    132         int     rotc;   /* -- " -- in classic version  */
    133         int     off[3]; /* offsets to other blots if center is at (0,0) */
     134        int rot;     /* index of rotated version of this shape */
     135        int rotc;    /* -- " -- in classic version  */
     136        int off[3];  /* offsets to other blots if center is at (0,0) */
     137        uint32_t color;
    134138};
    135139
     
    149153 * but by then the game is utterly impossible.
    150154 */
    151 extern long     fallrate;       /* less than 1 million; smaller => faster */
    152 #define faster() (fallrate -= fallrate / 3000)
     155extern long fallrate;  /* less than 1 million; smaller => faster */
     156
     157#define faster()  (fallrate -= fallrate / 3000)
    153158
    154159/*
     
    156161 * and affects scoring.
    157162 */
    158 #define MINLEVEL        1
    159 #define MAXLEVEL        9
     163#define MINLEVEL  1
     164#define MAXLEVEL  9
    160165
    161166/*
     
    171176 * If previewing has been turned on, the score is multiplied by PRE_PENALTY.
    172177 */
    173 #define PRE_PENALTY 0.75
     178#define PRE_PENALTY  0.75
    174179
    175 extern int      score;          /* the obvious thing */
    176 //extern gid_t  gid, egid;
     180extern int score;  /* The obvious thing */
    177181
    178 extern char     key_msg[100];
    179 extern int      showpreview;
    180 extern int      classic;
     182extern char key_msg[100];
     183extern int showpreview;
     184extern int classic;
    181185
    182 int     fits_in(const struct shape *, int);
    183 void    place(const struct shape *, int, int);
    184 void    stop(char *);
     186extern int fits_in(const struct shape *, int);
     187extern void place(const struct shape *, int, int);
     188extern void stop(char *);
    185189
    186190/** @}
    187191 */
    188 
Note: See TracChangeset for help on using the changeset viewer.