fix: solid white background for pause sprites, stop music and play sound on pause
This commit is contained in:
+7
-46
@@ -48,26 +48,6 @@ letters = {
|
|||||||
"01000000",
|
"01000000",
|
||||||
"01111100",
|
"01111100",
|
||||||
"00000000"
|
"00000000"
|
||||||
],
|
|
||||||
'BLANK': [
|
|
||||||
"00000000",
|
|
||||||
"00000000",
|
|
||||||
"00000000",
|
|
||||||
"00000000",
|
|
||||||
"00000000",
|
|
||||||
"00000000",
|
|
||||||
"00000000",
|
|
||||||
"00000000"
|
|
||||||
],
|
|
||||||
'BORDER_H': [
|
|
||||||
"00000000",
|
|
||||||
"01111111",
|
|
||||||
"00000000",
|
|
||||||
"00000000",
|
|
||||||
"00000000",
|
|
||||||
"00000000",
|
|
||||||
"01111111",
|
|
||||||
"00000000"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,12 +56,10 @@ def to_gb(tile):
|
|||||||
for r in tile:
|
for r in tile:
|
||||||
lo = hi = 0
|
lo = hi = 0
|
||||||
for i, c in enumerate(r):
|
for i, c in enumerate(r):
|
||||||
if c == '1':
|
# 3 for text (black), 1 for background (white using OBP1)
|
||||||
hi |= (1 << (7 - i))
|
val = 3 if c == '1' else 1
|
||||||
lo |= (1 << (7 - i)) # 3 = white/black depending on palette. Wait, 3 is black. 0 is white.
|
if val & 1: lo |= (1 << (7 - i))
|
||||||
# Let's make text black on a white dialog!
|
if val & 2: hi |= (1 << (7 - i))
|
||||||
# If background is white (0), text is black (3).
|
|
||||||
# So if '1', lo=1, hi=1.
|
|
||||||
b.append(lo)
|
b.append(lo)
|
||||||
b.append(hi)
|
b.append(hi)
|
||||||
return b
|
return b
|
||||||
@@ -89,31 +67,14 @@ def to_gb(tile):
|
|||||||
with open('src/pause_gfx.c', 'w') as f:
|
with open('src/pause_gfx.c', 'w') as f:
|
||||||
f.write('#include "pause_gfx.h"\n\n')
|
f.write('#include "pause_gfx.h"\n\n')
|
||||||
f.write('const unsigned char PauseTiles[] = {\n')
|
f.write('const unsigned char PauseTiles[] = {\n')
|
||||||
for k in ['P', 'A', 'U', 'S', 'E', 'BLANK', 'BORDER_H']:
|
for k in ['P', 'A', 'U', 'S', 'E']:
|
||||||
b = to_gb(letters[k])
|
b = to_gb(letters[k])
|
||||||
f.write(' ' + ','.join(f'0x{x:02X}' for x in b) + ',\n')
|
f.write(' ' + ','.join(f'0x{x:02X}' for x in b) + ',\n')
|
||||||
f.write('};\n\n')
|
f.write('};\n\n')
|
||||||
|
|
||||||
# Dialog map: 7x3
|
|
||||||
# Borders and blank background
|
|
||||||
# Indices: 22=P, 23=A, 24=U, 25=S, 26=E, 27=BLANK, 28=BORDER_H
|
|
||||||
|
|
||||||
# Row 0: all BORDER_H
|
|
||||||
# Row 1: BLANK, P, A, U, S, E, BLANK
|
|
||||||
# Row 2: all BORDER_H
|
|
||||||
map_data = [
|
|
||||||
28, 28, 28, 28, 28, 28, 28,
|
|
||||||
27, 22, 23, 24, 25, 26, 27,
|
|
||||||
28, 28, 28, 28, 28, 28, 28
|
|
||||||
]
|
|
||||||
f.write('const unsigned char PauseMap[] = {\n ')
|
|
||||||
f.write(','.join(str(x) for x in map_data))
|
|
||||||
f.write('\n};\n')
|
|
||||||
|
|
||||||
with open('src/pause_gfx.h', 'w') as f:
|
with open('src/pause_gfx.h', 'w') as f:
|
||||||
f.write('#ifndef PAUSE_GFX_H\n#define PAUSE_GFX_H\n\n')
|
f.write('#ifndef PAUSE_GFX_H\n#define PAUSE_GFX_H\n\n')
|
||||||
f.write('extern const unsigned char PauseTiles[];\n')
|
f.write('extern const unsigned char PauseTiles[];\n\n')
|
||||||
f.write('extern const unsigned char PauseMap[];\n\n')
|
|
||||||
f.write('#endif\n')
|
f.write('#endif\n')
|
||||||
|
|
||||||
print("Generated pause_gfx files")
|
print("Generated pause_gfx files with solid white backgrounds.")
|
||||||
|
|||||||
+26
-11
@@ -38,6 +38,11 @@ void main(void) {
|
|||||||
DISPLAY_ON;
|
DISPLAY_ON;
|
||||||
BGP_REG = 0b11100100;
|
BGP_REG = 0b11100100;
|
||||||
|
|
||||||
|
// Inizializza le palette
|
||||||
|
BGP_REG = 0b11100100;
|
||||||
|
OBP0_REG = 0b11100100; // Normale (3=Nero, 2=GrigioS, 1=GrigioC, 0=Trasparente)
|
||||||
|
OBP1_REG = 0b11000000; // Pausa (3=Nero, 2=Bianco, 1=Bianco, 0=Trasparente)
|
||||||
|
|
||||||
// Attendi la pressione di START
|
// Attendi la pressione di START
|
||||||
while (1) {
|
while (1) {
|
||||||
if (joypad() & J_START) {
|
if (joypad() & J_START) {
|
||||||
@@ -52,8 +57,7 @@ void main(void) {
|
|||||||
// Spegni il display per caricare i tile del gioco in sicurezza
|
// Spegni il display per caricare i tile del gioco in sicurezza
|
||||||
DISPLAY_OFF;
|
DISPLAY_OFF;
|
||||||
|
|
||||||
// Inizializza il seme casuale. Poiché il giocatore ha aspettato
|
// Inizializza il seme casuale.
|
||||||
// un tempo imprevedibile nel menu, DIV_REG produrrà un labirinto sempre nuovo!
|
|
||||||
initrand(DIV_REG);
|
initrand(DIV_REG);
|
||||||
|
|
||||||
// Invia i dati grafici del gioco alla VRAM
|
// Invia i dati grafici del gioco alla VRAM
|
||||||
@@ -61,12 +65,11 @@ void main(void) {
|
|||||||
|
|
||||||
// Inizializza la grafica della PAUSA come Sprite
|
// Inizializza la grafica della PAUSA come Sprite
|
||||||
set_sprite_data(11, 5, PauseTiles); // 5 tile per la pausa (P,A,U,S,E)
|
set_sprite_data(11, 5, PauseTiles); // 5 tile per la pausa (P,A,U,S,E)
|
||||||
// Nascondi gli sprite del menu pausa all'avvio
|
// Nascondi gli sprite del menu pausa e imposta OBP1
|
||||||
move_sprite(20, 0, 0);
|
for (uint8_t i = 20; i <= 24; i++) {
|
||||||
move_sprite(21, 0, 0);
|
set_sprite_prop(i, S_PALETTE); // Usa OBP1
|
||||||
move_sprite(22, 0, 0);
|
move_sprite(i, 0, 0);
|
||||||
move_sprite(23, 0, 0);
|
}
|
||||||
move_sprite(24, 0, 0);
|
|
||||||
|
|
||||||
// La mappa background in memoria hardware è grande 32x32 tiles.
|
// La mappa background in memoria hardware è grande 32x32 tiles.
|
||||||
// Inizializziamo il "fuori mappa" con siepi solide (mask 15 -> indice 21)
|
// Inizializziamo il "fuori mappa" con siepi solide (mask 15 -> indice 21)
|
||||||
@@ -92,8 +95,7 @@ void main(void) {
|
|||||||
if (x > 0 && maze[y][x-1] == 1) mask |= 1; // Ovest
|
if (x > 0 && maze[y][x-1] == 1) mask |= 1; // Ovest
|
||||||
tile_idx = 6 + mask; // Offset 6 per le siepi
|
tile_idx = 6 + mask; // Offset 6 per le siepi
|
||||||
} else {
|
} else {
|
||||||
// Scegli una variante casuale di pavimento per le stanze e i percorsi
|
// Scegli una variante casuale di pavimento
|
||||||
// 0 è la base pulita, 1-5 sono crepe e detriti (rarità maggiore per la 0)
|
|
||||||
uint8_t r = rand() % 10;
|
uint8_t r = rand() % 10;
|
||||||
if (r < 5) tile_idx = 0;
|
if (r < 5) tile_idx = 0;
|
||||||
else tile_idx = 1 + (r % 5);
|
else tile_idx = 1 + (r % 5);
|
||||||
@@ -148,6 +150,13 @@ void main(void) {
|
|||||||
|
|
||||||
// Controllo per la Pausa
|
// Controllo per la Pausa
|
||||||
if ((keys & J_START) && !(main_prev_keys & J_START)) {
|
if ((keys & J_START) && !(main_prev_keys & J_START)) {
|
||||||
|
// Effetto sonoro pausa
|
||||||
|
NR10_REG = 0x00;
|
||||||
|
NR11_REG = 0x81;
|
||||||
|
NR12_REG = 0x43;
|
||||||
|
NR13_REG = 0x73;
|
||||||
|
NR14_REG = 0x86;
|
||||||
|
|
||||||
// Mostra la scritta PAUSE al centro dello schermo usando gli sprite
|
// Mostra la scritta PAUSE al centro dello schermo usando gli sprite
|
||||||
set_sprite_tile(20, 11);
|
set_sprite_tile(20, 11);
|
||||||
set_sprite_tile(21, 12);
|
set_sprite_tile(21, 12);
|
||||||
@@ -165,9 +174,15 @@ void main(void) {
|
|||||||
while (1) {
|
while (1) {
|
||||||
uint8_t p_keys = joypad();
|
uint8_t p_keys = joypad();
|
||||||
if (p_keys & J_START) {
|
if (p_keys & J_START) {
|
||||||
|
// Effetto sonoro resume
|
||||||
|
NR10_REG = 0x00;
|
||||||
|
NR11_REG = 0x81;
|
||||||
|
NR12_REG = 0x43;
|
||||||
|
NR13_REG = 0x73;
|
||||||
|
NR14_REG = 0x86;
|
||||||
break; // Esci dalla pausa
|
break; // Esci dalla pausa
|
||||||
}
|
}
|
||||||
update_music(); // La musica continua in pausa
|
// update_music(); // MUSICA BLOCCATA (commentato intenzionalmente)
|
||||||
wait_vbl_done();
|
wait_vbl_done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-10
@@ -1,15 +1,10 @@
|
|||||||
#include "pause_gfx.h"
|
#include "pause_gfx.h"
|
||||||
|
|
||||||
const unsigned char PauseTiles[] = {
|
const unsigned char PauseTiles[] = {
|
||||||
0x00,0x00,0x7C,0x7C,0x44,0x44,0x7C,0x7C,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,
|
0xFF,0x00,0xFF,0x7C,0xFF,0x44,0xFF,0x7C,0xFF,0x40,0xFF,0x40,0xFF,0x40,0xFF,0x00,
|
||||||
0x00,0x00,0x38,0x38,0x44,0x44,0x44,0x44,0x7C,0x7C,0x44,0x44,0x44,0x44,0x00,0x00,
|
0xFF,0x00,0xFF,0x38,0xFF,0x44,0xFF,0x44,0xFF,0x7C,0xFF,0x44,0xFF,0x44,0xFF,0x00,
|
||||||
0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x38,0x00,0x00,
|
0xFF,0x00,0xFF,0x44,0xFF,0x44,0xFF,0x44,0xFF,0x44,0xFF,0x44,0xFF,0x38,0xFF,0x00,
|
||||||
0x00,0x00,0x3C,0x3C,0x40,0x40,0x38,0x38,0x04,0x04,0x44,0x44,0x38,0x38,0x00,0x00,
|
0xFF,0x00,0xFF,0x3C,0xFF,0x40,0xFF,0x38,0xFF,0x04,0xFF,0x44,0xFF,0x38,0xFF,0x00,
|
||||||
0x00,0x00,0x7C,0x7C,0x40,0x40,0x78,0x78,0x40,0x40,0x40,0x40,0x7C,0x7C,0x00,0x00,
|
0xFF,0x00,0xFF,0x7C,0xFF,0x40,0xFF,0x78,0xFF,0x40,0xFF,0x40,0xFF,0x7C,0xFF,0x00,
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x7F,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x00,0x00,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned char PauseMap[] = {
|
|
||||||
28,28,28,28,28,28,28,27,22,23,24,25,26,27,28,28,28,28,28,28,28
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -2,6 +2,5 @@
|
|||||||
#define PAUSE_GFX_H
|
#define PAUSE_GFX_H
|
||||||
|
|
||||||
extern const unsigned char PauseTiles[];
|
extern const unsigned char PauseTiles[];
|
||||||
extern const unsigned char PauseMap[];
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user