Aggiungi schermata crediti (SELECT nel menu titolo)

SELECT nel menu titolo mostra i crediti: titolo, autore (Matteo B.),
strumenti (GBDK 2020, SDCC SM83, PyBoy). B per tornare al titolo.
Usa il Window layer (come le istruzioni) per non corrompere il BG map.

Ricrea i file src/screens/ rimossi da make clean (death.c,
instructions.c, screens.c) e aggiunge credits.c.
This commit is contained in:
2026-06-26 11:12:29 +02:00
parent 402b713477
commit 7757e414a4
9 changed files with 77 additions and 23 deletions
+3 -3
View File
@@ -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
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

+1
View File
@@ -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;
+4
View File
@@ -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
+19
View File
@@ -1,6 +1,8 @@
#include <gb/gb.h>
#include "engine.h"
#include "globals.h"
#include "screens/screens.h"
#include "title_bg.h"
uint8_t app_state = 0; // 0 = title, 1 = game
@@ -18,12 +20,29 @@ void main(void) {
uint8_t keys = joypad();
if (app_state == 0) {
// 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);
}
+26
View File
@@ -0,0 +1,26 @@
#include "screens.h"
#include "../globals.h"
#include <string.h>
// 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;
}
+6 -4
View File
@@ -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);
}
+4 -5
View File
@@ -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(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
+3
View File
@@ -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);