| 1 |
2 |
idiolatrie |
/******************************************************************************
|
| 2 |
|
|
* Tennmino Version 0.1 *
|
| 3 |
|
|
******************************************************************************
|
| 4 |
|
|
* Copyright (C)2011 Mathias Hörtnagl <mathias.hoertnagl@gmail.com> *
|
| 5 |
|
|
* *
|
| 6 |
|
|
* This program is free software: you can redistribute it and/or modify *
|
| 7 |
|
|
* it under the terms of the GNU General Public License as published by *
|
| 8 |
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
| 9 |
|
|
* (at your option) any later version. *
|
| 10 |
|
|
* *
|
| 11 |
|
|
* This program is distributed in the hope that it will be useful, *
|
| 12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
| 13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
| 14 |
|
|
* GNU General Public License for more details. *
|
| 15 |
|
|
* *
|
| 16 |
|
|
* You should have received a copy of the GNU General Public License *
|
| 17 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
| 18 |
|
|
******************************************************************************/
|
| 19 |
|
|
#include "stdio.h"
|
| 20 |
|
|
|
| 21 |
|
|
#ifndef _TILES_H
|
| 22 |
|
|
#define _TILES_H
|
| 23 |
|
|
|
| 24 |
|
|
// #define TILE_I 0x00
|
| 25 |
|
|
// #define TILE_J 0x01
|
| 26 |
|
|
// #define TILE_L 0x02
|
| 27 |
|
|
// #define TILE_O 0x03
|
| 28 |
|
|
// #define TILE_T 0x04
|
| 29 |
|
|
// #define TILE_S 0x05
|
| 30 |
|
|
// #define TILE_Z 0x06
|
| 31 |
|
|
|
| 32 |
|
|
#define CHR_FULL 0xdb
|
| 33 |
|
|
#define CHR_EMPTY 0xff
|
| 34 |
|
|
|
| 35 |
|
|
#define MOVE_CONTINUE 0 // Tile can move down.
|
| 36 |
|
|
#define MOVE_BLOCKED 1 // Tile is stuck.
|
| 37 |
|
|
|
| 38 |
|
|
#define GAME_CONTINUE 2 // Continue execution of game.
|
| 39 |
|
|
#define GAME_NEW_TILE 3 // Current tile can not move down. Get a new one.
|
| 40 |
|
|
#define GAME_OVER 4 // Current tile can not move. Game over.
|
| 41 |
|
|
|
| 42 |
|
|
|
| 43 |
|
|
typedef struct _Tile {
|
| 44 |
|
|
uchar type;
|
| 45 |
|
|
ushort tile;
|
| 46 |
|
|
uchar ridx;
|
| 47 |
|
|
cursor pos;
|
| 48 |
|
|
} Tile;
|
| 49 |
|
|
|
| 50 |
|
|
|
| 51 |
|
|
/******************************************************************************
|
| 52 |
|
|
* Tile Placement *
|
| 53 |
|
|
******************************************************************************/
|
| 54 |
|
|
/* Initialize a tile at te top of the board. */
|
| 55 |
|
|
extern void initTile(uchar type);
|
| 56 |
|
|
|
| 57 |
|
|
/* Draw the current tile. */
|
| 58 |
|
|
#define drawTile() printTile(CHR_FULL);
|
| 59 |
|
|
|
| 60 |
|
|
/* Erase the curent tile from the display. */
|
| 61 |
|
|
#define eraseTile() printTile(CHR_EMPTY);
|
| 62 |
|
|
|
| 63 |
|
|
|
| 64 |
|
|
/******************************************************************************
|
| 65 |
|
|
* Tile Movement *
|
| 66 |
|
|
******************************************************************************/
|
| 67 |
|
|
/* Rotate the tile if its new rotation does not interfere with already present
|
| 68 |
|
|
tiles or the game board. */
|
| 69 |
|
|
extern void rotate();
|
| 70 |
|
|
|
| 71 |
|
|
/* Move current tile left. */
|
| 72 |
|
|
#define moveLeft() move(-2, 0)
|
| 73 |
|
|
|
| 74 |
|
|
/* Move current tile right. */
|
| 75 |
|
|
#define moveRight() move(+2, 0)
|
| 76 |
|
|
|
| 77 |
|
|
/* Move current tile down. */
|
| 78 |
|
|
#define moveDown() move(0, +1)
|
| 79 |
|
|
|
| 80 |
|
|
|
| 81 |
|
|
/******************************************************************************
|
| 82 |
|
|
* Game State *
|
| 83 |
|
|
******************************************************************************/
|
| 84 |
|
|
/* Return the current game state. Can be either
|
| 85 |
|
|
GAME_CONTINUE if the game can continue without further processing.
|
| 86 |
|
|
GAME_NEW_TILE if the current tile is stuck and a new tile needs to be
|
| 87 |
|
|
initialized.
|
| 88 |
|
|
GAME_OVER if the current tile can not move down from the beginning.
|
| 89 |
|
|
*/
|
| 90 |
|
|
extern uchar getGameState();
|
| 91 |
|
|
|
| 92 |
|
|
|
| 93 |
|
|
/******************************************************************************
|
| 94 |
|
|
* Deletion of Lines *
|
| 95 |
|
|
******************************************************************************/
|
| 96 |
|
|
/* Deletes up to four complete rows and scrolls down acordingly. Returns the
|
| 97 |
|
|
number of deleted rows. For x deleted lines return
|
| 98 |
|
|
|
| 99 |
|
|
1 ... 128 points
|
| 100 |
|
|
2 ... 256 points
|
| 101 |
|
|
3 ... 512 points
|
| 102 |
|
|
4 ... 1024 points
|
| 103 |
|
|
*/
|
| 104 |
|
|
extern uint deleteCompletedRows(uchar x, uchar w);
|
| 105 |
|
|
|
| 106 |
|
|
#endif
|