FreeRTOS Tetris
Macros | Functions
game.c File Reference

File containing the Game's Tasks. More...

#include "game.h"
#include "input.h"
#include "stateMachine.h"
#include "logic.h"
#include "gui.h"
#include "opponent.h"
Include dependency graph for game.c:

Macros

#define HIGHSCORES_SIZE   3
 
Delays
#define POS_UPDATE_DELAY   500
 Initial value for the delay for updating a Tetromino's position.
 
#define DELAY_AT_BOTTOM   300
 Initial value for the delay when a Tetromino hits the bottom.
 

Functions

static void buttonInput (bool *buttonPressed)
 Check for button input, give semaphores and write the pressed buttons in a queue. More...
 
static void changeTimerPeriod (TimerHandle_t timer, uint8_t level, int delay)
 Change a timer's period depending on the current level & start the timer. More...
 
static void mainMenuTask ()
 Task that handles the Main Menu. More...
 
static void posUpdateTimerCallback (TimerHandle_t PosUpdateTimer)
 Callback function for the Timer that updates the position. More...
 
static void delayAtBottomTimerCallback (TimerHandle_t DelayAtGroundTimer)
 Callback function for the Timer that starts a delay if a Tetromino hits the bottom. More...
 
static void gameTask ()
 Task that handles the Tetris gameplay. More...
 
static void pauseTask ()
 Task that handles the pause & game-over screen. More...
 
static void scoreTask ()
 Low priority task, running in the background, that handles the score.
 
int iGameInit ()
 Initialize the game. More...
 

Variables

Task Handles
TaskHandle_t MainMenuTask = NULL
 Task for the Main Menu Task
 
TaskHandle_t GameTask = NULL
 Task for the Game Task
 
TaskHandle_t PauseTask = NULL
 Task for the Pause Task
 
TaskHandle_t ScoreTask = NULL
 Task for the Score Task
 
Timer Handles
TimerHandle_t PosUpdateTimer = NULL
 Timer for updating a Tetromino's position
 
TimerHandle_t DelayAtGroundTimer = NULL
 Timer for the delay, when a Tetromino hits the bottom
 
Semaphore Handles
SemaphoreHandle_t ScreenLock = NULL
 Semaphore for locking the screen
 
SemaphoreHandle_t DrawSignal = NULL
 Signal for drawing
 
SemaphoreHandle_t YSignal = NULL
 Signal for updating a Tetromino's y-position
 
SemaphoreHandle_t XSignal = NULL
 Signal for updating a Tetromino's x-position
 
SemaphoreHandle_t FallSignal = NULL
 Signal if the down-key is held
 
SemaphoreHandle_t RotationSignal = NULL
 Signal for rotating a Tetromino
 
SemaphoreHandle_t InitNextSignal = NULL
 Signal for initializing the next Tetromino
 
SemaphoreHandle_t ResetGameSignal = NULL
 Signal for resetting the game
 
SemaphoreHandle_t ResetUDPSignal = NULL
 Signal for resetting the UDP socket
 
SemaphoreHandle_t NoConnectionSignal = NULL
 Signal if the binary is not connected
 
Queue Handles
QueueHandle_t LeftRightQueue = NULL
 Queue for left & right input
 
QueueHandle_t ConnectionQueue = NULL
 Queue for the connection status
 
QueueHandle_t GameModeQueue = NULL
 Queue for the game mode
 
QueueHandle_t PlayerModeQueue = NULL
 Queue for the player mode
 
QueueHandle_t RotationModeQueue = NULL
 Queue for the rotation mode
 
QueueHandle_t ScoreQueue = NULL
 Queue for the current score
 
QueueHandle_t HighScoresQueue = NULL
 Queue for the highscores
 
QueueHandle_t LevelQueue = NULL
 Queue for the current level
 
QueueHandle_t GameOverQueue = NULL
 Queue for the game-over status
 

Detailed Description

File containing the Game's Tasks.

Authors
Philipp Karg (phili.nosp@m.pp.k.nosp@m.arg@t.nosp@m.um.d.nosp@m.e)
Date
04.02.2021