squeezed another 550 bytes
This commit is contained in:
parent
aa29c51bd8
commit
047abb575c
|
@ -110,7 +110,7 @@ void off()
|
||||||
|
|
||||||
#ifdef ANIMATION_SPIRALE
|
#ifdef ANIMATION_SPIRALE
|
||||||
|
|
||||||
static void walk(cursor* cur, unsigned char steps, unsigned int delay){
|
static void walk(cursor_t* cur, unsigned char steps, unsigned int delay){
|
||||||
unsigned char x;
|
unsigned char x;
|
||||||
for(x=steps;x--;){
|
for(x=steps;x--;){
|
||||||
set_cursor(cur, next_pixel(cur->pos, cur->dir));
|
set_cursor(cur, next_pixel(cur->pos, cur->dir));
|
||||||
|
@ -121,7 +121,7 @@ static void walk(cursor* cur, unsigned char steps, unsigned int delay){
|
||||||
void spirale(unsigned int delay){
|
void spirale(unsigned int delay){
|
||||||
clear_screen(0);
|
clear_screen(0);
|
||||||
|
|
||||||
cursor cur;
|
cursor_t cur;
|
||||||
cur.dir = right;
|
cur.dir = right;
|
||||||
cur.mode = set;
|
cur.mode = set;
|
||||||
set_cursor (&cur, (pixel){NUM_COLS-1,0});
|
set_cursor (&cur, (pixel){NUM_COLS-1,0});
|
||||||
|
|
|
@ -37,7 +37,7 @@ ifeq ($(OSTYPE),cygwin)
|
||||||
LDFLAGS_SIM = -Wl -mno-cygwin -T simulator/i386pe.x
|
LDFLAGS_SIM = -Wl -mno-cygwin -T simulator/i386pe.x
|
||||||
LIBS_SIM = -lglut32 -lglu32 -lopengl32
|
LIBS_SIM = -lglut32 -lglu32 -lopengl32
|
||||||
else
|
else
|
||||||
CFLAGS_SIM = -g -Wall -pedantic -std=c99 -O0
|
CFLAGS_SIM = -g -Wall -pedantic -std=c99 -O0 -DNDEBUG
|
||||||
ifeq ($(MACHINE),x86_64)
|
ifeq ($(MACHINE),x86_64)
|
||||||
LDFLAGS_SIM = -Wl -T simulator/elf_x86_64.x
|
LDFLAGS_SIM = -Wl -T simulator/elf_x86_64.x
|
||||||
else
|
else
|
||||||
|
|
|
@ -39,7 +39,7 @@ void borg_breakout_game()
|
||||||
|
|
||||||
void borg_breakout(uint8_t demomode)
|
void borg_breakout(uint8_t demomode)
|
||||||
{
|
{
|
||||||
char my_playfield[NUM_COLS][NUM_ROWS];
|
game_field_t my_playfield[NUM_COLS][NUM_ROWS];
|
||||||
playfield = &my_playfield;
|
playfield = &my_playfield;
|
||||||
|
|
||||||
uint16_t cycles = DEMO_CYCLES;
|
uint16_t cycles = DEMO_CYCLES;
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
static uint16_t maxscore;
|
static uint16_t maxscore;
|
||||||
|
|
||||||
/* real level definition */
|
/* real level definition */
|
||||||
enum game_field_t level_field (uint8_t in_x, uint8_t in_y, uint8_t in_lvl);
|
game_field_t level_field (uint8_t in_x, uint8_t in_y, uint8_t in_lvl);
|
||||||
enum game_field_t level_field (uint8_t in_x, uint8_t in_y, uint8_t in_lvl)
|
game_field_t level_field (uint8_t in_x, uint8_t in_y, uint8_t in_lvl)
|
||||||
{
|
{
|
||||||
switch (in_lvl)
|
switch (in_lvl)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ enum game_field_t level_field (uint8_t in_x, uint8_t in_y, uint8_t in_lvl)
|
||||||
void level_init (uint8_t in_levelnum)
|
void level_init (uint8_t in_levelnum)
|
||||||
{
|
{
|
||||||
uint8_t x,y;
|
uint8_t x,y;
|
||||||
enum game_field_t tmp;
|
game_field_t tmp;
|
||||||
maxscore = 0;
|
maxscore = 0;
|
||||||
|
|
||||||
for (x=0;x<NUM_COLS;x++)
|
for (x=0;x<NUM_COLS;x++)
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "playfield.h"
|
#include "playfield.h"
|
||||||
char (*playfield)[NUM_COLS][NUM_ROWS];
|
game_field_t (*playfield)[NUM_COLS][NUM_ROWS];
|
||||||
|
|
||||||
void playfield_set (uint8_t in_x, uint8_t in_y, enum game_field_t in_field)
|
void playfield_set (uint8_t in_x, uint8_t in_y, game_field_t in_field)
|
||||||
{
|
{
|
||||||
if (in_x >= NUM_ROWS || in_y >= NUM_COLS)
|
if (in_x >= NUM_ROWS || in_y >= NUM_COLS)
|
||||||
{
|
{
|
||||||
|
@ -80,7 +80,7 @@ uint8_t check_bounce (int8_t in_x, int8_t in_y)
|
||||||
|
|
||||||
/* this is the actual draw function for a single field
|
/* this is the actual draw function for a single field
|
||||||
*/
|
*/
|
||||||
static inline void draw_single_field (uint8_t in_x, uint8_t in_y, enum game_field_t in_f)
|
static inline void draw_single_field (uint8_t in_x, uint8_t in_y, game_field_t in_f)
|
||||||
{
|
{
|
||||||
pixel tmp;
|
pixel tmp;
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#define BOUNCE_REBOUND 0x10
|
#define BOUNCE_REBOUND 0x10
|
||||||
|
|
||||||
/* entries for the playing field */
|
/* entries for the playing field */
|
||||||
enum game_field_t
|
enum game_field
|
||||||
{
|
{
|
||||||
sp = 0, /* space */
|
sp = 0, /* space */
|
||||||
b1 = 1, b2 = 2, b3 = 3, /* bricks */
|
b1 = 1, b2 = 2, b3 = 3, /* bricks */
|
||||||
|
@ -36,8 +36,14 @@ enum game_field_t
|
||||||
bl, /* ball */
|
bl, /* ball */
|
||||||
rb /* rebound */
|
rb /* rebound */
|
||||||
};
|
};
|
||||||
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t game_field_t;
|
||||||
|
#else
|
||||||
|
typedef enum game_field game_field_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
extern char (*playfield)[NUM_COLS][NUM_ROWS];
|
|
||||||
|
extern game_field_t (*playfield)[NUM_COLS][NUM_ROWS];
|
||||||
|
|
||||||
/* @description draw the current field
|
/* @description draw the current field
|
||||||
*/
|
*/
|
||||||
|
@ -45,7 +51,7 @@ void playfield_draw();
|
||||||
|
|
||||||
/* @description set a field with given property.
|
/* @description set a field with given property.
|
||||||
*/
|
*/
|
||||||
void playfield_set (uint8_t in_x, uint8_t in_y, enum game_field_t in_field);
|
void playfield_set (uint8_t in_x, uint8_t in_y, game_field_t in_field);
|
||||||
|
|
||||||
/* @description Checks if there is an object in the way. If so, it returns 1
|
/* @description Checks if there is an object in the way. If so, it returns 1
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,15 +43,19 @@ game_descriptor_t snake_game_descriptor __attribute__((section(".game_descriptor
|
||||||
/**
|
/**
|
||||||
* Directions of the snake.
|
* Directions of the snake.
|
||||||
*/
|
*/
|
||||||
typedef enum snake_dir
|
enum snake_dir
|
||||||
{
|
{
|
||||||
SNAKE_DIR_UP, //!< SNAKE_DIR_UP Snake is heading up.
|
SNAKE_DIR_UP, //!< SNAKE_DIR_UP Snake is heading up.
|
||||||
SNAKE_DIR_RIGHT,//!< SNAKE_DIR_RIGHT Snake is heading right.
|
SNAKE_DIR_RIGHT,//!< SNAKE_DIR_RIGHT Snake is heading right.
|
||||||
SNAKE_DIR_DOWN, //!< SNAKE_DIR_DOWN Snake is heading down.
|
SNAKE_DIR_DOWN, //!< SNAKE_DIR_DOWN Snake is heading down.
|
||||||
SNAKE_DIR_LEFT, //!< SNAKE_DIR_LEFT Snake is heading left.
|
SNAKE_DIR_LEFT, //!< SNAKE_DIR_LEFT Snake is heading left.
|
||||||
SNAKE_DIR_NONE //!< SNAKE_DIR_NONE Helper value for a "resting" joystick.
|
SNAKE_DIR_NONE //!< SNAKE_DIR_NONE Helper value for a "resting" joystick.
|
||||||
} snake_dir_t;
|
};
|
||||||
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t snake_dir_t;
|
||||||
|
#else
|
||||||
|
typedef enum snake_dir snake_dir_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This structure represents the snake character itself. It keeps track of the
|
* This structure represents the snake character itself. It keeps track of the
|
||||||
|
@ -59,10 +63,10 @@ typedef enum snake_dir
|
||||||
*/
|
*/
|
||||||
typedef struct snake_protagonist
|
typedef struct snake_protagonist
|
||||||
{
|
{
|
||||||
pixel aSegments[SNAKE_MAX_LENGTH]; /** All segments of the snake. */
|
pixel aSegments[SNAKE_MAX_LENGTH]; /**< All segments of the snake. */
|
||||||
uint8_t nHeadIndex; /** Index of the head segment. */
|
uint8_t nHeadIndex; /**< Index of the head segment. */
|
||||||
uint8_t nTailIndex; /** Index of the tail segment. */
|
uint8_t nTailIndex; /**< Index of the tail segment. */
|
||||||
snake_dir_t dir; /** Direction of the snake. */
|
snake_dir_t dir; /**< Direction of the snake. */
|
||||||
} snake_protagonist_t;
|
} snake_protagonist_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,8 +75,8 @@ typedef struct snake_protagonist
|
||||||
*/
|
*/
|
||||||
typedef struct snake_apples
|
typedef struct snake_apples
|
||||||
{
|
{
|
||||||
pixel aApples[SNAKE_MAX_APPLES]; /** All apple positions */
|
pixel aApples[SNAKE_MAX_APPLES]; /**< All apple positions */
|
||||||
uint8_t nAppleCount; /** Counter of currently existing apples */
|
uint8_t nAppleCount; /**< Counter of currently existing apples*/
|
||||||
} snake_apples_t;
|
} snake_apples_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
#ifndef BEARING_H_
|
#ifndef BEARING_H_
|
||||||
#define BEARING_H_
|
#define BEARING_H_
|
||||||
|
|
||||||
typedef enum tetris_bearing_t
|
enum tetris_bearing
|
||||||
{
|
{
|
||||||
TETRIS_BEARING_0,
|
TETRIS_BEARING_0,
|
||||||
TETRIS_BEARING_90,
|
TETRIS_BEARING_90,
|
||||||
TETRIS_BEARING_180,
|
TETRIS_BEARING_180,
|
||||||
TETRIS_BEARING_270
|
TETRIS_BEARING_270
|
||||||
}
|
};
|
||||||
tetris_bearing_t;
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t tetris_bearing_t;
|
||||||
|
#else
|
||||||
|
typedef enum tetris_bearing tetris_bearing_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* BEARING_H_ */
|
#endif /* BEARING_H_ */
|
||||||
|
|
|
@ -18,28 +18,36 @@
|
||||||
*********/
|
*********/
|
||||||
|
|
||||||
// directions to which a piece can be moved
|
// directions to which a piece can be moved
|
||||||
typedef enum tetris_bucket_direction_t
|
enum tetris_bucket_direction
|
||||||
{
|
{
|
||||||
TETRIS_BUD_LEFT,
|
TETRIS_BUD_LEFT,
|
||||||
TETRIS_BUD_RIGHT
|
TETRIS_BUD_RIGHT
|
||||||
}
|
};
|
||||||
tetris_bucket_direction_t;
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t tetris_bucket_direction_t;
|
||||||
|
#else
|
||||||
|
typedef enum tetris_bucket_direction tetris_bucket_direction_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// status of the bucket
|
// status of the bucket
|
||||||
typedef enum tetris_bucket_status_t
|
enum tetris_bucket_status
|
||||||
{
|
{
|
||||||
TETRIS_BUS_READY, /** ready to get next piece */
|
TETRIS_BUS_READY, /** ready to get next piece */
|
||||||
TETRIS_BUS_HOVERING, /** piece is still hovering */
|
TETRIS_BUS_HOVERING, /** piece is still hovering */
|
||||||
TETRIS_BUS_GLIDING, /** piece is gliding on the dump */
|
TETRIS_BUS_GLIDING, /** piece is gliding on the dump */
|
||||||
TETRIS_BUS_DOCKED, /** piece has been docked */
|
TETRIS_BUS_DOCKED, /** piece has been docked */
|
||||||
TETRIS_BUS_GAMEOVER /** bucket is filled up */
|
TETRIS_BUS_GAMEOVER /** bucket is filled up */
|
||||||
}
|
};
|
||||||
tetris_bucket_status_t;
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t tetris_bucket_status_t;
|
||||||
|
#else
|
||||||
|
typedef enum tetris_bucket_status tetris_bucket_status_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// tetris_bucket_t
|
// tetris_bucket_t
|
||||||
typedef struct tetris_bucket_t
|
typedef struct tetris_bucket
|
||||||
{
|
{
|
||||||
int8_t nWidth; /** width of bucket */
|
int8_t nWidth; /** width of bucket */
|
||||||
int8_t nHeight; /** height of bucket */
|
int8_t nHeight; /** height of bucket */
|
||||||
|
@ -56,7 +64,7 @@ tetris_bucket_t;
|
||||||
|
|
||||||
|
|
||||||
// iterator for predicted dump rows
|
// iterator for predicted dump rows
|
||||||
typedef struct tetris_bucket_iterator_t
|
typedef struct tetris_bucket_iterator
|
||||||
{
|
{
|
||||||
tetris_bucket_t *pBucket; /** bucket to be examined */
|
tetris_bucket_t *pBucket; /** bucket to be examined */
|
||||||
uint16_t nPieceMap; /** piece bitmap */
|
uint16_t nPieceMap; /** piece bitmap */
|
||||||
|
|
|
@ -6,15 +6,19 @@
|
||||||
/**
|
/**
|
||||||
* indexes for different tetris variants
|
* indexes for different tetris variants
|
||||||
*/
|
*/
|
||||||
typedef enum tetris_highscore_index_t
|
enum tetris_highscore_index
|
||||||
{
|
{
|
||||||
TETRIS_HISCORE_TETRIS, /**< high score index for the standard variant */
|
TETRIS_HISCORE_TETRIS, /**< high score index for the standard variant */
|
||||||
TETRIS_HISCORE_BASTET, /**< high score index for the bastet variant */
|
TETRIS_HISCORE_BASTET, /**< high score index for the bastet variant */
|
||||||
TETRIS_HISCORE_FP, /**< high score index for the first person variant */
|
TETRIS_HISCORE_FP, /**< high score index for the first person variant */
|
||||||
TETRIS_HISCORE_PAD, /**< don't use (padding for an even array boundary)*/
|
TETRIS_HISCORE_PAD, /**< don't use (padding for an even array boundary)*/
|
||||||
TETRIS_HISCORE_END /**< boundary for the high score array */
|
TETRIS_HISCORE_END /**< boundary for the high score array */
|
||||||
} tetris_highscore_index_t;
|
};
|
||||||
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t tetris_highscore_index_t;
|
||||||
|
#else
|
||||||
|
typedef enum tetris_highscore_index tetris_highscore_index_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lets the user enter his initials (three characters)
|
* lets the user enter his initials (three characters)
|
||||||
|
|
|
@ -143,7 +143,7 @@ static void tetris_input_chatterProtect(tetris_input_t *pIn,
|
||||||
tetris_input_command_t tetris_input_mapCommand(tetris_bearing_t nBearing,
|
tetris_input_command_t tetris_input_mapCommand(tetris_bearing_t nBearing,
|
||||||
tetris_input_command_t nCmd)
|
tetris_input_command_t nCmd)
|
||||||
{
|
{
|
||||||
static uint8_t const nMapping[] PROGMEM =
|
static tetris_input_command_t const nMapping[] PROGMEM =
|
||||||
{
|
{
|
||||||
TETRIS_INCMD_DOWN, TETRIS_INCMD_ROT_CW, TETRIS_INCMD_RIGHT,
|
TETRIS_INCMD_DOWN, TETRIS_INCMD_ROT_CW, TETRIS_INCMD_RIGHT,
|
||||||
TETRIS_INCMD_LEFT,
|
TETRIS_INCMD_LEFT,
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
/**
|
/**
|
||||||
* allowed input values
|
* allowed input values
|
||||||
*/
|
*/
|
||||||
typedef enum tetris_input_command_t
|
enum tetris_input_command
|
||||||
{
|
{
|
||||||
TETRIS_INCMD_LEFT, /**< move piece left */
|
TETRIS_INCMD_LEFT, /**< move piece left */
|
||||||
TETRIS_INCMD_RIGHT, /**< move piece right */
|
TETRIS_INCMD_RIGHT, /**< move piece right */
|
||||||
|
@ -42,26 +42,34 @@ typedef enum tetris_input_command_t
|
||||||
TETRIS_INCMD_GRAVITY, /**< piece gets pulled by gravity */
|
TETRIS_INCMD_GRAVITY, /**< piece gets pulled by gravity */
|
||||||
TETRIS_INCMD_PAUSE, /**< pause the game */
|
TETRIS_INCMD_PAUSE, /**< pause the game */
|
||||||
TETRIS_INCMD_NONE /**< idle (must alway be the last one) */
|
TETRIS_INCMD_NONE /**< idle (must alway be the last one) */
|
||||||
}
|
};
|
||||||
tetris_input_command_t;
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t tetris_input_command_t;
|
||||||
|
#else
|
||||||
|
typedef enum tetris_input_command tetris_input_command_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* values which influence the gravity time limit for a piece
|
* values which influence the gravity time limit for a piece
|
||||||
*/
|
*/
|
||||||
typedef enum tetris_input_pace_t
|
enum tetris_input_pace
|
||||||
{
|
{
|
||||||
TETRIS_INPACE_HOVERING, /**< normal falling pace */
|
TETRIS_INPACE_HOVERING, /**< normal falling pace */
|
||||||
TETRIS_INPACE_GLIDING /**< guarantees a minimum docking time to avoid
|
TETRIS_INPACE_GLIDING /**< guarantees a minimum docking time to avoid
|
||||||
accidentally docked pieces in higher levels */
|
accidentally docked pieces in higher levels */
|
||||||
}
|
};
|
||||||
tetris_input_pace_t;
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t tetris_input_pace_t;
|
||||||
|
#else
|
||||||
|
typedef enum tetris_input_pace tetris_input_pace_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* data structure for the input module
|
* data structure for the input module
|
||||||
*/
|
*/
|
||||||
typedef struct tetris_input_t
|
typedef struct tetris_input
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* current level (determines falling speed)
|
* current level (determines falling speed)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*********/
|
*********/
|
||||||
|
|
||||||
/** shape attributes for a piece */
|
/** shape attributes for a piece */
|
||||||
typedef enum tetris_piece_shape_t
|
enum tetris_piece_shape
|
||||||
{
|
{
|
||||||
TETRIS_PC_LINE, /**< the I shaped brick */
|
TETRIS_PC_LINE, /**< the I shaped brick */
|
||||||
TETRIS_PC_T, /**< the T shaped brick */
|
TETRIS_PC_T, /**< the T shaped brick */
|
||||||
|
@ -23,35 +23,46 @@ typedef enum tetris_piece_shape_t
|
||||||
TETRIS_PC_LBACK, /**< the reverse L shaped brick */
|
TETRIS_PC_LBACK, /**< the reverse L shaped brick */
|
||||||
TETRIS_PC_S, /**< the S shaped brick */
|
TETRIS_PC_S, /**< the S shaped brick */
|
||||||
TETRIS_PC_Z /**< the Z shaped brick */
|
TETRIS_PC_Z /**< the Z shaped brick */
|
||||||
}
|
};
|
||||||
tetris_piece_shape_t;
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t tetris_piece_shape_t;
|
||||||
|
#else
|
||||||
|
typedef enum tetris_piece_shape tetris_piece_shape_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/** possible angles for a brick */
|
/** possible angles for a brick */
|
||||||
typedef enum tetris_piece_angle_t
|
enum tetris_piece_angle
|
||||||
{
|
{
|
||||||
TETRIS_PC_ANGLE_0, /**< standard angle */
|
TETRIS_PC_ANGLE_0, /**< standard angle */
|
||||||
TETRIS_PC_ANGLE_90, /**< rotated by 90 degrees */
|
TETRIS_PC_ANGLE_90, /**< rotated by 90 degrees */
|
||||||
TETRIS_PC_ANGLE_180, /**< rotated by 180 degrees */
|
TETRIS_PC_ANGLE_180, /**< rotated by 180 degrees */
|
||||||
TETRIS_PC_ANGLE_270 /**< rotated by 270 degrees */
|
TETRIS_PC_ANGLE_270 /**< rotated by 270 degrees */
|
||||||
}
|
};
|
||||||
tetris_piece_angle_t;
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t tetris_piece_angle_t;
|
||||||
|
#else
|
||||||
|
typedef enum tetris_piece_angle tetris_piece_angle_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/** rotation attributes */
|
/** rotation attributes */
|
||||||
typedef enum tetris_piece_rotation_t
|
enum tetris_piece_rotation
|
||||||
{
|
{
|
||||||
TETRIS_PC_ROT_CW, /**< clockwise rotation */
|
TETRIS_PC_ROT_CW, /**< clockwise rotation */
|
||||||
TETRIS_PC_ROT_CCW /**< counter clockwise rotation */
|
TETRIS_PC_ROT_CCW /**< counter clockwise rotation */
|
||||||
}
|
};
|
||||||
tetris_piece_rotation_t;
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t tetris_piece_rotation_t;
|
||||||
|
#else
|
||||||
|
typedef enum tetris_piece_rotation tetris_piece_rotation_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* describes the attributes of a piece
|
* describes the attributes of a piece
|
||||||
* @see tetris_piece_shape_t
|
* @see tetris_piece_shape_t
|
||||||
* @see tetris_piece_angle_t
|
* @see tetris_piece_angle_t
|
||||||
*/
|
*/
|
||||||
typedef struct tetris_piece_t
|
typedef struct tetris_piece
|
||||||
{
|
{
|
||||||
tetris_piece_shape_t shape; /**< specifies the shape of the piece */
|
tetris_piece_shape_t shape; /**< specifies the shape of the piece */
|
||||||
tetris_piece_angle_t angle; /**< specifies one of 4 angels */
|
tetris_piece_angle_t angle; /**< specifies one of 4 angels */
|
||||||
|
|
|
@ -23,7 +23,7 @@ void tetris_bastet(void);
|
||||||
* types *
|
* types *
|
||||||
*********/
|
*********/
|
||||||
|
|
||||||
typedef struct tetris_bastet_scorepair_t
|
typedef struct tetris_bastet_scorepair
|
||||||
{
|
{
|
||||||
tetris_piece_shape_t shape;
|
tetris_piece_shape_t shape;
|
||||||
int16_t nScore;
|
int16_t nScore;
|
||||||
|
@ -31,7 +31,7 @@ typedef struct tetris_bastet_scorepair_t
|
||||||
tetris_bastet_scorepair_t;
|
tetris_bastet_scorepair_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct tetris_bastet_variant_t
|
typedef struct tetris_bastet_variant
|
||||||
{
|
{
|
||||||
uint16_t nScore; /** score of the player */
|
uint16_t nScore; /** score of the player */
|
||||||
uint16_t nHighscore; /** highscore */
|
uint16_t nHighscore; /** highscore */
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "bucket.h"
|
#include "bucket.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
typedef struct tetris_variant_t
|
typedef struct tetris_variant
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* constructs a variant data object
|
* constructs a variant data object
|
||||||
|
|
|
@ -18,16 +18,20 @@
|
||||||
*********/
|
*********/
|
||||||
|
|
||||||
/** presentation modes */
|
/** presentation modes */
|
||||||
typedef enum tetris_view_mode_t
|
enum tetris_view_mode
|
||||||
{
|
{
|
||||||
TETRIS_VIMO_PAUSED,
|
TETRIS_VIMO_PAUSED,
|
||||||
TETRIS_VIMO_RUNNING
|
TETRIS_VIMO_RUNNING
|
||||||
}
|
};
|
||||||
tetris_view_mode_t;
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t tetris_view_mode_t;
|
||||||
|
#else
|
||||||
|
typedef enum tetris_view_mode tetris_view_mode_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/** data structure that drives the view module */
|
/** data structure that drives the view module */
|
||||||
typedef struct tetris_view_t
|
typedef struct tetris_view
|
||||||
{
|
{
|
||||||
tetris_variant_t const *pVariantMethods; /** variant function pointers */
|
tetris_variant_t const *pVariantMethods; /** variant function pointers */
|
||||||
void *pVariant; /** associated variant object */
|
void *pVariant; /** associated variant object */
|
||||||
|
|
11
menu/menu.c
11
menu/menu.c
|
@ -36,13 +36,18 @@ extern game_descriptor_t _game_descriptors_end__[];
|
||||||
#define MENU_PREVITEM(item) ((item + MENU_ITEM_MAX - 1) % MENU_ITEM_MAX)
|
#define MENU_PREVITEM(item) ((item + MENU_ITEM_MAX - 1) % MENU_ITEM_MAX)
|
||||||
|
|
||||||
|
|
||||||
typedef enum menu_direction_t
|
enum menu_direction
|
||||||
{
|
{
|
||||||
MENU_DIRECTION_LEFT,
|
MENU_DIRECTION_LEFT,
|
||||||
MENU_DIRECTION_RIGHT,
|
MENU_DIRECTION_RIGHT,
|
||||||
MENU_DIRECTION_STILL
|
MENU_DIRECTION_STILL
|
||||||
}
|
};
|
||||||
menu_direction_t;
|
#ifdef NDEBUG
|
||||||
|
typedef uint8_t menu_direction_t;
|
||||||
|
#else
|
||||||
|
typedef enum menu_direction menu_direction_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void menu_setpixel(uint8_t x, uint8_t y, uint8_t isSet)
|
static void menu_setpixel(uint8_t x, uint8_t y, uint8_t isSet)
|
||||||
|
|
41
pixel.h
41
pixel.h
|
@ -12,12 +12,35 @@ typedef struct {
|
||||||
} pixel;
|
} pixel;
|
||||||
|
|
||||||
|
|
||||||
typedef enum {up, right, down, left} direction;
|
enum direction{
|
||||||
typedef struct {
|
up,
|
||||||
|
right,
|
||||||
|
down,
|
||||||
|
left
|
||||||
|
};
|
||||||
|
#ifdef NDEBUG
|
||||||
|
typedef unsigned char direction_t;
|
||||||
|
#else
|
||||||
|
typedef enum direction direction_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
enum pixelmode{
|
||||||
|
clear,
|
||||||
|
set
|
||||||
|
};
|
||||||
|
#ifdef NDEBUG
|
||||||
|
typedef unsigned char pixelmode_t;
|
||||||
|
#else
|
||||||
|
typedef enum pixelmode pixelmode_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct cursor{
|
||||||
pixel pos;
|
pixel pos;
|
||||||
direction dir;
|
direction_t dir;
|
||||||
enum{clear=0, set=1} mode;
|
pixelmode_t mode;
|
||||||
} cursor;
|
} cursor_t;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pixel routines
|
* Pixel routines
|
||||||
|
@ -25,18 +48,18 @@ typedef struct {
|
||||||
|
|
||||||
unsigned char get_pixel(pixel p);
|
unsigned char get_pixel(pixel p);
|
||||||
|
|
||||||
static inline pixel next_pixel(pixel pix, direction dir){
|
inline static pixel next_pixel(pixel pix, direction_t dir){
|
||||||
static char const nDelta[] = {0, -1, 0, 1, 0};
|
static char const nDelta[] = {0, -1, 0, 1, 0};
|
||||||
return (pixel){pix.x + nDelta[dir], pix.y + nDelta[dir + 1]};
|
return (pixel){pix.x + nDelta[dir], pix.y + nDelta[dir + 1]};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline unsigned char get_next_pixel(pixel p, direction dir){
|
inline static unsigned char get_next_pixel(pixel p, direction_t dir){
|
||||||
return get_pixel(next_pixel(p, dir));
|
return get_pixel(next_pixel(p, dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline direction direction_r(direction dir){
|
inline static direction_t direction_r(direction_t dir){
|
||||||
return (dir + 1) % 4;
|
return (dir + 1) % 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +74,7 @@ void setpixel(pixel p, unsigned char value);
|
||||||
void shift_pixmap_l();
|
void shift_pixmap_l();
|
||||||
|
|
||||||
|
|
||||||
static inline void set_cursor(cursor* cur, pixel p){
|
static inline void set_cursor(cursor_t* cur, pixel p){
|
||||||
cur->pos = p;
|
cur->pos = p;
|
||||||
setpixel(p, cur->mode ? 3 : 0);
|
setpixel(p, cur->mode ? 3 : 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,13 @@ enum waitfor_e{
|
||||||
wait_col_l,
|
wait_col_l,
|
||||||
wait_col_r
|
wait_col_r
|
||||||
};
|
};
|
||||||
|
#ifdef NDEBUG
|
||||||
|
typedef unsigned char waitfor_e_t;
|
||||||
|
#else
|
||||||
|
typedef enum waitfor_e waitfor_e_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define DIRECTION_RIGHT 0x01
|
#define DIRECTION_RIGHT 0x01
|
||||||
#define DIRECTION_DOWN 0x02
|
#define DIRECTION_DOWN 0x02
|
||||||
|
|
||||||
|
@ -91,7 +98,7 @@ typedef struct blob_t_struct{
|
||||||
struct blob_t_struct * next, * last;
|
struct blob_t_struct * next, * last;
|
||||||
char *str;
|
char *str;
|
||||||
char *commands;
|
char *commands;
|
||||||
enum waitfor_e waitfor;
|
waitfor_e_t waitfor;
|
||||||
int sizex;
|
int sizex;
|
||||||
char sizey;
|
char sizey;
|
||||||
int posx;
|
int posx;
|
||||||
|
|
Loading…
Reference in New Issue