diff --git a/src/bitmap.c b/src/bitmap.h similarity index 100% rename from src/bitmap.c rename to src/bitmap.h diff --git a/src/draw.c b/src/draw.c index 451fc93..286a40f 100644 --- a/src/draw.c +++ b/src/draw.c @@ -9,7 +9,7 @@ uint16_t bitmap_draw( unsigned int width, unsigned int height, unsigned int bytes_per_pixel, - unsigned char *pixel_data){ + const unsigned char *pixel_data){ if(bytes_per_pixel != BYTES_PER_PIXEL){ return -1; diff --git a/src/draw.h b/src/draw.h index e09c130..12d13af 100644 --- a/src/draw.h +++ b/src/draw.h @@ -12,6 +12,6 @@ * @return -1 if error 0 else * */ -uint16_t bitmap_draw( unsigned int width, unsigned int height, unsigned int bytes_per_pixel, unsigned char *pixel_data); +uint16_t bitmap_draw(unsigned int width, unsigned int height, unsigned int bytes_per_pixel, const unsigned char *pixel_data); #endif /* DRAW_H */ diff --git a/src/game.c b/src/game.c index 8c26384..749965e 100644 --- a/src/game.c +++ b/src/game.c @@ -5,6 +5,9 @@ #include "game.h" #include "io.h" +#include "draw.h" +#include "bitmap.h" //generated by gimp + void game_init(game_t* game, uint16_t ticks_per_sec) { @@ -16,7 +19,7 @@ void game_init(game_t* game, uint16_t ticks_per_sec) { LCD_Clear(GUI_COLOR_BLACK); // struct init - game->state=prestart; + game->state=init; game->ticks_per_pixel = SPEED_SLOW; game->ticks_leftover = 0; game->ticks_per_sec = ticks_per_sec; @@ -241,6 +244,24 @@ void game_get_color(uint16_t confbits, uint16_t* player1_color, uint16_t* player } } + +bool game_step_init(game_t* game) { + + //Draw welcome bitmap + bitmap_draw(gimp_image.width,gimp_image.height,gimp_image.bytes_per_pixel,gimp_image.pixel_data); + + //Wait on player to press the start button + while(!io_button_has_edge(BTN_START)); + + //Change game state + game->state=prestart; + + LCD_Clear(GUI_COLOR_BLACK); // Clear the background + + return true; +} + + static const char* texts [] = { "Config Instructions:", "* Change the player colors using the switches S7-S0", @@ -467,7 +488,9 @@ bool game_step_ended(game_t* game) { bool game_step(game_t* game, uint64_t delta_time) { // Calculate the next game step switch(game->state) { - case prestart: // If the game is in prestart state + case init: + return game_step_init(game); + case prestart: return game_step_prestart(game); case running: return game_step_running(game,delta_time); diff --git a/src/game.h b/src/game.h index d408265..3154b2b 100644 --- a/src/game.h +++ b/src/game.h @@ -57,6 +57,7 @@ typedef struct game_s{ player_t player[PLAYER_COUNT]; enum{ // Current state of the game + init, prestart, running, ended