diff --git a/Makefile b/Makefile index e8d56f9..cc7ad67 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ SCRIPTS_DIR = scripts BUILD_DIR = build # C source files -SRCS = $(SRC_DIR)/main.c $(SRC_DIR)/engine.c $(SRC_DIR)/globals.c $(SRC_DIR)/maze.c $(SRC_DIR)/sound.c $(SRC_DIR)/render.c $(SRC_DIR)/player_logic.c $(SRC_DIR)/enemy_logic.c $(SRC_DIR)/tiles.c $(SRC_DIR)/player.c $(SRC_DIR)/enemy.c $(SRC_DIR)/gameover.c $(SRC_DIR)/stamina.c $(SRC_DIR)/level.c $(SRC_DIR)/title_bg.c $(SRC_DIR)/screens/screens.c $(SRC_DIR)/screens/instructions.c $(SRC_DIR)/screens/death.c $(SRC_DIR)/screens/going_deeper.c $(SRC_DIR)/screens/finale.c +SRCS = $(SRC_DIR)/main.c $(SRC_DIR)/engine.c $(SRC_DIR)/globals.c $(SRC_DIR)/maze.c $(SRC_DIR)/sound.c $(SRC_DIR)/render.c $(SRC_DIR)/player_logic.c $(SRC_DIR)/enemy_logic.c $(SRC_DIR)/tiles.c $(SRC_DIR)/player.c $(SRC_DIR)/enemy.c $(SRC_DIR)/gameover.c $(SRC_DIR)/stamina.c $(SRC_DIR)/level.c $(SRC_DIR)/title_bg.c $(SRC_DIR)/screens/screens.c $(SRC_DIR)/screens/instructions.c $(SRC_DIR)/screens/death.c $(SRC_DIR)/screens/going_deeper.c $(SRC_DIR)/screens/finale.c $(SRC_DIR)/screens/credits.c all: $(BUILD_DIR)/hello_iso.gb $(BUILD_DIR)/test_gameover.gb $(BUILD_DIR)/test_finale.gb @@ -28,7 +28,7 @@ generate_c_assets: generate_images $(PNG2ASSET) $(ASSETS_DIR)/next_level.png -c $(SRC_DIR)/next_level.c -map -bpp 2 -noflip -max_palettes 1 $(PNG2ASSET) $(ASSETS_DIR)/stamina.png -c $(SRC_DIR)/stamina.c -bpp 2 -noflip -keep_palette_order $(PNG2ASSET) $(ASSETS_DIR)/level.png -c $(SRC_DIR)/level.c -sw 8 -sh 16 -bpp 2 -noflip -keep_palette_order -keep_duplicate_tiles - $(PNG2ASSET) $(ASSETS_DIR)/title_bg.png -c $(SRC_DIR)/title_bg.c $(SRC_DIR)/screens/screens.c $(SRC_DIR)/screens/instructions.c $(SRC_DIR)/screens/death.c $(SRC_DIR)/screens/going_deeper.c $(SRC_DIR)/screens/finale.c -map -bpp 2 -noflip -keep_palette_order -max_palettes 1 + $(PNG2ASSET) $(ASSETS_DIR)/title_bg.png -c $(SRC_DIR)/title_bg.c -map -bpp 2 -noflip -keep_palette_order -max_palettes 1 # Main ROM target $(BUILD_DIR)/hello_iso.gb: generate_c_assets $(SRCS) @@ -52,4 +52,4 @@ clean: rm -f $(SRC_DIR)/gameover.c $(SRC_DIR)/gameover.h rm -f $(SRC_DIR)/stamina.c $(SRC_DIR)/stamina.h rm -f $(SRC_DIR)/level.c $(SRC_DIR)/level.h - rm -f $(SRC_DIR)/title_bg.c $(SRC_DIR)/screens/screens.c $(SRC_DIR)/screens/instructions.c $(SRC_DIR)/screens/death.c $(SRC_DIR)/screens/going_deeper.c $(SRC_DIR)/screens/finale.c $(SRC_DIR)/title_bg.h + rm -f $(SRC_DIR)/title_bg.c $(SRC_DIR)/screens/screens.c $(SRC_DIR)/screens/instructions.c $(SRC_DIR)/screens/death.c $(SRC_DIR)/screens/going_deeper.c $(SRC_DIR)/screens/finale.c $(SRC_DIR)/screens/credits.c $(SRC_DIR)/title_bg.h diff --git a/assets/bg.png b/assets/bg.png index 3555bcd..c943dc7 100644 Binary files a/assets/bg.png and b/assets/bg.png differ diff --git a/src/globals.c b/src/globals.c index 3b92996..9e13087 100644 --- a/src/globals.c +++ b/src/globals.c @@ -47,3 +47,4 @@ int16_t enemy_target_px[MAX_ENEMIES], enemy_target_py[MAX_ENEMIES]; uint8_t enemy_cooldown[MAX_ENEMIES] = {0}; volatile uint8_t hint_active = 0; volatile uint8_t hint_displayed = 0; +volatile uint8_t credits_active = 0; diff --git a/src/globals.h b/src/globals.h index fd0aae4..13049a5 100644 --- a/src/globals.h +++ b/src/globals.h @@ -82,4 +82,8 @@ extern uint8_t enemy_cooldown[MAX_ENEMIES]; extern volatile uint8_t hint_active; extern volatile uint8_t hint_displayed; +// --- Credits Screen --- +// credits_active: 1 = mostra la schermata crediti (SELECT nel menu titolo) +extern volatile uint8_t credits_active; + #endif \ No newline at end of file diff --git a/src/main.c b/src/main.c index 179cf18..ddb6a70 100644 --- a/src/main.c +++ b/src/main.c @@ -1,33 +1,52 @@ #include #include "engine.h" #include "globals.h" +#include "screens/screens.h" +#include "title_bg.h" uint8_t app_state = 0; // 0 = title, 1 = game void main(void) { title_init(); - + SHOW_BKG; SHOW_SPRITES; DISPLAY_ON; - + uint8_t prev_keys = 0; - + while (1) { wait_vbl_done(); uint8_t keys = joypad(); - + if (app_state == 0) { - title_update(keys, prev_keys); - if ((keys & J_START) && !(prev_keys & J_START)) { - app_state = 1; - level = 1; // Nuova partita dal livello 1 - engine_init(); + // Schermata crediti attiva: B per tornare al titolo + if (credits_active) { + if ((keys & J_B) && !(prev_keys & J_B)) { + HIDE_WIN; + BGP_REG = 0xE4; + // Ripristina i tile del titolo (font li aveva sovrascritti) + set_bkg_data(0, title_bg_TILE_COUNT, title_bg_tiles); + set_bkg_tiles(0, 0, title_bg_WIDTH / 8, title_bg_HEIGHT / 8, title_bg_map); + credits_active = 0; + } + } else { + title_update(keys, prev_keys); + if ((keys & J_START) && !(prev_keys & J_START)) { + app_state = 1; + level = 1; // Nuova partita dal livello 1 + engine_init(); + } + // SELECT nel titolo: mostra i crediti + if ((keys & J_SELECT) && !(prev_keys & J_SELECT)) { + show_credits(); + credits_active = 1; + } } } else { engine_update(keys, prev_keys); } - + prev_keys = keys; } } diff --git a/src/screens/credits.c b/src/screens/credits.c new file mode 100644 index 0000000..8abcf27 --- /dev/null +++ b/src/screens/credits.c @@ -0,0 +1,26 @@ +#include "screens.h" +#include "../globals.h" +#include + +// Schermata dei crediti (SELECT nel menu titolo). Usa il Window layer. +// Il BG map del titolo resta intatto -> tornando al titolo niente garbage. +void show_credits(void) { + HIDE_SPRITES; + font_init(); + font_t cr_font = font_load(font_ibm); + font_set(cr_font); + BGP_REG = 0x1B; // palette invertita (sfondo nero, testo chiaro) + memset(map_buffer, 0, sizeof(map_buffer)); + ending_puttext(3, 1, "A SCREAM FROM"); + ending_puttext(6, 2, "THE DARK"); + ending_puttext(2, 5, "A GAME BY"); + ending_puttext(3, 6, "MATTEO B."); + ending_puttext(2, 9, "GBDK 2020"); + ending_puttext(2, 10, "SDCC SM83"); + ending_puttext(2, 11, "PYBOY TEST"); + ending_puttext(1, 14, "PRESS B TO RETURN"); + // Window layer: tile map separato dal BG + set_win_tiles(0, 0, 32, 32, map_buffer); + move_win(7, 0); + SHOW_WIN; +} \ No newline at end of file diff --git a/src/screens/death.c b/src/screens/death.c index cd934c0..9199072 100644 --- a/src/screens/death.c +++ b/src/screens/death.c @@ -12,9 +12,11 @@ void show_death(void) { font_t dead_font = font_load(font_ibm); font_set(dead_font); memset(map_buffer, 0, sizeof(map_buffer)); - ending_puttext(2, 5, "THE DARK CLAIMED"); - ending_puttext(8, 7, "YOU"); - ending_puttext(4, 14, "PRESS START"); - ending_puttext(5, 15, "AND RETRY"); + ending_puttext(5, 3, "YOU DIED"); + ending_puttext(2, 5, "THE DARK CLAIMS"); + ending_puttext(5, 6, "ANOTHER"); + ending_puttext(2, 9, "JUST ANOTHER SCREAM"); + ending_puttext(3, 10, "FROM THE DARK."); + ending_puttext(5, 14, "GAME OVER"); set_bkg_tiles(0, 0, 32, 32, map_buffer); } \ No newline at end of file diff --git a/src/screens/instructions.c b/src/screens/instructions.c index 9d9e597..d010990 100644 --- a/src/screens/instructions.c +++ b/src/screens/instructions.c @@ -11,13 +11,12 @@ void show_instructions(void) { font_set(hint_font); BGP_REG = 0x1B; // palette invertita (sfondo nero, testo chiaro) memset(map_buffer, 0, sizeof(map_buffer)); - - ending_puttext(3, 2, "FIND THE HATCH"); - ending_puttext(4, 8, "DPAD WALK"); - ending_puttext(2, 9, "A + DPAD JUMP"); + ending_puttext(3, 3, "FIND THE HATCH"); + ending_puttext(5, 7, "DPAD WALK"); + ending_puttext(2, 9, "A + DPAD JUMP"); ending_puttext(2, 10, "B + DPAD RUN"); - ending_puttext(2, 12, "PRESS B"); - ending_puttext(2, 13, "TO CONTINUE"); + ending_puttext(2, 13, "PRESS B TO CONTINUE"); + ending_puttext(4, 14, "SELECT: HELP"); // Window layer: tile map separato (0x9C00) dal BG (0x9800) set_win_tiles(0, 0, 32, 32, map_buffer); move_win(7, 0); // -7 pixel offset: allinea a sinistra diff --git a/src/screens/screens.h b/src/screens/screens.h index a2ab27c..20e7f0a 100644 --- a/src/screens/screens.h +++ b/src/screens/screens.h @@ -26,6 +26,9 @@ void show_going_deeper(void); // Schermata del finale tragico (game_over == 3) void show_finale(void); +// Schermata dei crediti (SELECT nel menu titolo) +void show_credits(void); + // Helper condivisi (definiti in screens.c) void ending_puttext(uint8_t col, uint8_t row, const char *s); void ending_putdigit(uint8_t col, uint8_t row, uint8_t digit);