2012-05-07 06:56:00 +00:00
|
|
|
/**
|
|
|
|
* \addtogroup tetris
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file variant_bastet.h
|
|
|
|
* @brief Public interface of the "Bastard Tetris" module.
|
2012-07-10 01:59:06 +00:00
|
|
|
* @details Based on the game "Bastet" (version 0.41) by Federico Poloni. His
|
2012-05-07 06:56:00 +00:00
|
|
|
* code isn't used as the Borg's Tetris framework is too different from
|
|
|
|
* that of "Petris" (on which Bastet is based), but the algorithms of
|
|
|
|
* this implementation are closely modeled after his ideas.
|
|
|
|
* @author Christian Kroll
|
2012-07-10 01:59:06 +00:00
|
|
|
* @see Federico Poloni's homepage: http://fph.altervista.org/prog/bastet.html
|
2012-05-07 06:56:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-08-28 15:13:35 +00:00
|
|
|
#ifndef VARIANT_BASTET_H_
|
|
|
|
#define VARIANT_BASTET_H_
|
2010-04-01 03:11:59 +00:00
|
|
|
|
2010-08-24 23:00:40 +00:00
|
|
|
#include <stdint.h>
|
2010-08-22 03:07:46 +00:00
|
|
|
#include "bearing.h"
|
2010-08-28 15:13:35 +00:00
|
|
|
#include "piece.h"
|
|
|
|
#include "highscore.h"
|
|
|
|
#include "bucket.h"
|
2010-04-01 03:11:59 +00:00
|
|
|
#include "input.h"
|
2010-08-28 15:13:35 +00:00
|
|
|
#include "variants.h"
|
2010-04-01 03:11:59 +00:00
|
|
|
|
2012-05-07 06:56:00 +00:00
|
|
|
|
2010-04-01 03:11:59 +00:00
|
|
|
/***************
|
|
|
|
* entry point *
|
|
|
|
***************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* runs the Bastet game
|
|
|
|
*/
|
|
|
|
void tetris_bastet(void);
|
|
|
|
|
|
|
|
|
|
|
|
/*********
|
|
|
|
* types *
|
|
|
|
*********/
|
|
|
|
|
2012-05-07 06:56:00 +00:00
|
|
|
typedef struct tetris_bastet_scorepair_s
|
2010-04-01 03:11:59 +00:00
|
|
|
{
|
|
|
|
tetris_piece_shape_t shape;
|
|
|
|
int16_t nScore;
|
|
|
|
}
|
|
|
|
tetris_bastet_scorepair_t;
|
|
|
|
|
|
|
|
|
2012-05-07 06:56:00 +00:00
|
|
|
typedef struct tetris_bastet_variant_s
|
2010-04-01 03:11:59 +00:00
|
|
|
{
|
2013-02-02 15:48:44 +00:00
|
|
|
uint16_t nScore; /**< score of the player */
|
|
|
|
uint16_t nHighscore; /**< high score */
|
|
|
|
uint16_t nHighscoreName; /**< champion's initials */
|
|
|
|
uint8_t nLevel; /**< current level */
|
|
|
|
uint16_t nLines; /**< number of completed lines */
|
|
|
|
tetris_piece_t *pPreviewPiece; /**< the piece for the preview */
|
|
|
|
tetris_bucket_t *pBucket; /**< bucket to be examined */
|
|
|
|
int16_t *pColScore; /**< score impact of each column*/
|
|
|
|
int8_t *pStartingRow; /**< starting point for
|
|
|
|
collision detection */
|
|
|
|
int8_t *pColHeights; /**< predicted column heights */
|
|
|
|
tetris_bastet_scorepair_t nPieceScore[7]; /**< score for every piece */
|
2010-04-01 03:11:59 +00:00
|
|
|
}
|
|
|
|
tetris_bastet_variant_t;
|
|
|
|
|
2010-08-24 23:00:40 +00:00
|
|
|
tetris_variant_t const tetrisBastetVariant;
|
2010-04-01 03:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
/****************************
|
|
|
|
* construction/destruction *
|
|
|
|
****************************/
|
|
|
|
|
|
|
|
/**
|
2010-08-22 03:07:46 +00:00
|
|
|
* constructs a bastet instance for a given bucket
|
|
|
|
* @param pBucket the bucket to be observed
|
2010-04-01 03:11:59 +00:00
|
|
|
* @return pointer to a newly created bastet instance
|
|
|
|
*/
|
2010-08-22 03:07:46 +00:00
|
|
|
void* tetris_bastet_construct(tetris_bucket_t *pBucket);
|
2010-04-01 03:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* destructs the given bastet instance
|
|
|
|
* @param pVariantData the bastet instance to be destroyed
|
|
|
|
*/
|
|
|
|
void tetris_bastet_destruct(void *pVariantData);
|
|
|
|
|
|
|
|
|
|
|
|
/****************************
|
|
|
|
* bastet related functions *
|
|
|
|
****************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* chooses a new worst possible piece
|
|
|
|
* @param pVariantData the variant instance of interest
|
|
|
|
* @return a tetris piece
|
|
|
|
*/
|
|
|
|
tetris_piece_t* tetris_bastet_choosePiece(void *pBastet);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* chooses a new (best possible) piece for the preview
|
|
|
|
* @param pVariantData the variant instance of interest
|
|
|
|
* @return a tetris piece
|
|
|
|
*/
|
|
|
|
tetris_piece_t* tetris_bastet_choosePreviewPiece(void *pBastet);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* add points which result from single step dropping
|
|
|
|
* @param pVariantData the variant data object we want to modify
|
|
|
|
*/
|
2011-02-06 22:56:26 +00:00
|
|
|
void tetris_bastet_singleDrop(void *pVariantData);
|
2010-04-01 03:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* add points which result from a complete drop
|
|
|
|
* @param pVariantData the variant data object we want to modify
|
|
|
|
* @param nLines the number of rows involved
|
|
|
|
*/
|
|
|
|
void tetris_bastet_completeDrop(void *pVariantData,
|
|
|
|
uint8_t nLines);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* add points which result from removed rows
|
|
|
|
* @param pVariantData the variant data object we want to modify
|
|
|
|
* @param nRowMask bit mask of removed lines
|
|
|
|
*/
|
|
|
|
void tetris_bastet_removedLines(void *pVariantData,
|
|
|
|
uint8_t nRowMask);
|
|
|
|
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* get/set functions *
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the current score
|
|
|
|
* @param pVariantData variant data object we want information from
|
|
|
|
* @return score
|
|
|
|
*/
|
|
|
|
uint16_t tetris_bastet_getScore(void *pVariantData);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the current highscore
|
|
|
|
* @param pVariantData variant data object we want information from
|
|
|
|
* @return highscore
|
|
|
|
*/
|
|
|
|
uint16_t tetris_bastet_getHighscore(void *pVariantData);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set highscore
|
|
|
|
* @param pVariantData variant data object we want to modify
|
|
|
|
* @param nHighscore highscore
|
|
|
|
*/
|
|
|
|
void tetris_bastet_setHighscore(void *pVariantData,
|
|
|
|
uint16_t nHighscore);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the current highscore name
|
|
|
|
* @param pVariantData variant data object we want information from
|
|
|
|
* @return champion's name packed as uint16_t
|
|
|
|
*/
|
|
|
|
uint16_t tetris_bastet_getHighscoreName(void *pVariantData);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set highscore name
|
|
|
|
* @param pVariantData the variant data object we want to modify
|
|
|
|
* @param nHighscoreName champion's name packed as uint16_t
|
|
|
|
*/
|
|
|
|
void tetris_bastet_setHighscoreName(void *pVariantData,
|
|
|
|
uint16_t nHighscoreName);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the current level
|
|
|
|
* @param pVariantData variant data object we want information from
|
|
|
|
* @return the level as uint8_t
|
|
|
|
*/
|
|
|
|
uint8_t tetris_bastet_getLevel(void *pVariantData);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the number of completed lines
|
|
|
|
* @param pVariantData the variant data object we want information from
|
|
|
|
* @return number of completed lines
|
|
|
|
*/
|
|
|
|
uint16_t tetris_bastet_getLines(void *pVariantData);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns piece which was set via tetris_std_setPreviewPiece
|
|
|
|
* @param pVariantData the variant data object we want information from
|
|
|
|
* @return the piece intended to be the next one
|
|
|
|
*/
|
|
|
|
tetris_piece_t* tetris_bastet_getPreviewPiece(void *pVariantData);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* retrieves the variant's highscore index
|
|
|
|
* @param pVariantData the variant data object we want information from
|
|
|
|
*/
|
|
|
|
tetris_highscore_index_t tetris_bastet_getHighscoreIndex(void *pVariantData);
|
|
|
|
|
|
|
|
|
2010-08-22 03:07:46 +00:00
|
|
|
/**
|
2011-03-07 00:32:38 +00:00
|
|
|
* inform the Bastet instance about the player's last input
|
|
|
|
* @param pVariantData the Bastet object we want to modify
|
|
|
|
* @param inCmd the last issued command
|
|
|
|
* @param bMoveOk 1 if the last move was possible, otherwise 0
|
2010-08-22 03:07:46 +00:00
|
|
|
*/
|
2010-04-01 03:11:59 +00:00
|
|
|
void tetris_bastet_setLastInput(void *pVariantData,
|
2011-03-07 00:32:38 +00:00
|
|
|
tetris_input_command_t inCmd,
|
|
|
|
uint8_t bMoveOk);
|
2010-04-01 03:11:59 +00:00
|
|
|
|
|
|
|
|
2010-08-22 03:07:46 +00:00
|
|
|
/**
|
|
|
|
* returns the bearing which is requested by the Bastet instance (always 0)
|
|
|
|
* @param pVariantData the variant data object we want information from
|
|
|
|
* @return always TETRIS_BEARING_0 as we don't change the bearing in Bastet
|
|
|
|
*/
|
|
|
|
tetris_bearing_t tetris_bastet_getBearing(void *pVariantData);
|
2010-04-01 03:11:59 +00:00
|
|
|
|
2010-08-28 15:13:35 +00:00
|
|
|
#endif /*VARIANT_BASTET_H_*/
|
2012-05-07 06:56:00 +00:00
|
|
|
|
|
|
|
/*@}*/
|