diff --git a/Makefile b/Makefile index cc7ad67..ed414d3 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 $(SRC_DIR)/screens/credits.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 $(SRC_DIR)/screens/intro.c all: $(BUILD_DIR)/hello_iso.gb $(BUILD_DIR)/test_gameover.gb $(BUILD_DIR)/test_finale.gb @@ -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)/screens/credits.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)/screens/intro.c $(SRC_DIR)/title_bg.h diff --git a/src/globals.c b/src/globals.c index 9e13087..6f08a85 100644 --- a/src/globals.c +++ b/src/globals.c @@ -48,3 +48,4 @@ 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; +volatile uint8_t intro_active = 0; diff --git a/src/globals.h b/src/globals.h index 13049a5..6c7fd7b 100644 --- a/src/globals.h +++ b/src/globals.h @@ -86,4 +86,8 @@ extern volatile uint8_t hint_displayed; // credits_active: 1 = mostra la schermata crediti (SELECT nel menu titolo) extern volatile uint8_t credits_active; +// --- Intro Screen --- +// intro_active: 1 = mostra l'introduzione alla storia (dopo START, prima del gioco) +extern volatile uint8_t intro_active; + #endif \ No newline at end of file diff --git a/src/main.c b/src/main.c index ddb6a70..369995c 100644 --- a/src/main.c +++ b/src/main.c @@ -20,24 +20,33 @@ void main(void) { uint8_t keys = joypad(); if (app_state == 0) { - // Schermata crediti attiva: B per tornare al titolo if (credits_active) { + // Credits: B per tornare al titolo 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)) { + } else if (intro_active) { + // Intro: un tasto qualsiasi avvia la partita + if (keys && !prev_keys) { + HIDE_WIN; + BGP_REG = 0xE4; app_state = 1; - level = 1; // Nuova partita dal livello 1 + level = 1; + intro_active = 0; engine_init(); } - // SELECT nel titolo: mostra i crediti + } else { + title_update(keys, prev_keys); + // START: mostra l'introduzione alla storia + if ((keys & J_START) && !(prev_keys & J_START)) { + intro_active = 1; + show_intro(); + } + // SELECT: mostra i crediti if ((keys & J_SELECT) && !(prev_keys & J_SELECT)) { show_credits(); credits_active = 1; @@ -49,4 +58,4 @@ void main(void) { prev_keys = keys; } -} +} \ No newline at end of file diff --git a/src/screens/death.c b/src/screens/death.c index 9199072..cd934c0 100644 --- a/src/screens/death.c +++ b/src/screens/death.c @@ -12,11 +12,9 @@ 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(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"); + ending_puttext(2, 5, "THE DARK CLAIMED"); + ending_puttext(8, 7, "YOU"); + ending_puttext(4, 14, "PRESS START"); + ending_puttext(5, 15, "AND RETRY"); 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 d010990..9d9e597 100644 --- a/src/screens/instructions.c +++ b/src/screens/instructions.c @@ -11,12 +11,13 @@ 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, 3, "FIND THE HATCH"); - ending_puttext(5, 7, "DPAD WALK"); - ending_puttext(2, 9, "A + DPAD JUMP"); + + ending_puttext(3, 2, "FIND THE HATCH"); + ending_puttext(4, 8, "DPAD WALK"); + ending_puttext(2, 9, "A + DPAD JUMP"); ending_puttext(2, 10, "B + DPAD RUN"); - ending_puttext(2, 13, "PRESS B TO CONTINUE"); - ending_puttext(4, 14, "SELECT: HELP"); + ending_puttext(2, 12, "PRESS B"); + ending_puttext(2, 13, "TO CONTINUE"); // 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/intro.c b/src/screens/intro.c new file mode 100644 index 0000000..4be271a --- /dev/null +++ b/src/screens/intro.c @@ -0,0 +1,29 @@ +#include "screens.h" +#include "../globals.h" +#include + +// Schermata di introduzione alla storia (dopo START, prima del gioco). +// Si chiude con un tasto qualsiasi. Usa il Window layer. +void show_intro(void) { + HIDE_SPRITES; + font_init(); + font_t intro_font = font_load(font_ibm); + font_set(intro_font); + BGP_REG = 0x1B; + memset(map_buffer, 0, sizeof(map_buffer)); + ending_puttext(2, 1, "You were walking"); + ending_puttext(1, 2, "alone in the dead"); + ending_puttext(6, 3, "of night."); + ending_puttext(1, 5, "Without warning, an"); + ending_puttext(1, 6, "unnatural darkness"); + ending_puttext(0, 7, "consumed the world."); + ending_puttext(1, 9, "Your only comfort:"); + ending_puttext(3, 10, "a faint torch."); + ending_puttext(0, 12, "The path behind you"); + ending_puttext(6, 13, "is gone."); + ending_puttext(0, 15, "Descend deeper into"); + ending_puttext(6, 16, "the unknown."); + 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/screens.h b/src/screens/screens.h index 20e7f0a..0155bc8 100644 --- a/src/screens/screens.h +++ b/src/screens/screens.h @@ -29,6 +29,9 @@ void show_finale(void); // Schermata dei crediti (SELECT nel menu titolo) void show_credits(void); +// Schermata di introduzione alla storia (dopo START, prima del gioco) +void show_intro(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);