From b4dd0c8956f1c81836e4f3020efe2f85b3d91902 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 20 Jun 2023 23:08:22 +0100 Subject: Add menu screen (WIP) --- src/data.h | 1 + src/game.c | 4 ++++ src/main.c | 8 +++----- src/menu.c | 35 +++++++++++++++++++++++++++++++++++ src/menu.h | 6 ++++++ 5 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 src/menu.c create mode 100644 src/menu.h (limited to 'src') diff --git a/src/data.h b/src/data.h index 8d4b2e3..78a1f60 100644 --- a/src/data.h +++ b/src/data.h @@ -6,6 +6,7 @@ extern const uint8_t binary_palette_start[]; extern const uint8_t binary_sprites_start[]; extern const uint8_t binary_tiles_start[]; extern const uint8_t binary_font_start[]; +extern const uint8_t binary_title_start[]; extern const uint8_t binary_stage_start[]; diff --git a/src/game.c b/src/game.c index b80090a..cdb0c07 100644 --- a/src/game.c +++ b/src/game.c @@ -105,6 +105,10 @@ void run_game() wait_vsync(); blit_update(); } + + /* wait for ESC to be release */ + while (keys[KEY_ESC]) + wait_vsync(); } void add_score(uint8_t v) diff --git a/src/main.c b/src/main.c index 0711cf9..6207b35 100644 --- a/src/main.c +++ b/src/main.c @@ -8,6 +8,7 @@ #include "keyb.h" #include "vga.h" #include "data.h" +#include "menu.h" #include "game.h" /* disable paging because our int handlers are written in C */ @@ -41,11 +42,8 @@ int main(int argc, char *argv[]) return 1; } - blit_erase(0); - wait_vsync(); - blit_update(); - - run_game(); + while (run_menu()) + run_game(); set_mode(3); close_framebuffer(); diff --git a/src/menu.c b/src/menu.c new file mode 100644 index 0000000..02cda24 --- /dev/null +++ b/src/menu.c @@ -0,0 +1,35 @@ +#include + +#include "keyb.h" +#include "vga.h" +#include "text.h" +#include "data.h" + +uint8_t run_menu() +{ + blit_erase(0); + + put_text(124, 10, "HI 000000"); + + Rect dst = { 80, 45, 160, 38 }; + blit(binary_title_start, &dst); + + put_text(84, 110, "PRESS SPACE TO PLAY"); + + put_text(64, 140, "CODE, GRAPHICS AND MUSIC"); + put_text(96, 150, "JUAN J. MARTINEZ"); + + put_text(96, 180, "_2023 USEBOX.NET"); + + wait_vsync(); + blit_update(); + + while (1) + { + if (keys[KEY_ESC]) + return 0; + + if (keys[KEY_SPACE]) + return 1; + } +} diff --git a/src/menu.h b/src/menu.h new file mode 100644 index 0000000..b367b99 --- /dev/null +++ b/src/menu.h @@ -0,0 +1,6 @@ +#ifdef _MENU_H +#define _MENU_H + +uint8_t run_menu(); + +#endif /* _MENU_H */ -- cgit v1.2.3