2 Commits
v2 ... v4
Author SHA1 Message Date
Luxferre 833c57631b added ranks to nes/gb versions 2026-01-27 11:46:59 +02:00
Luxferre 69c3f46640 added exit guard for nes/gb 2026-01-21 10:23:57 +02:00
3 changed files with 65 additions and 18 deletions
+18 -13
View File
@@ -89,8 +89,14 @@ void game_startup() {
}
/* Win screen display */
static char* ranks[] = {"Survivor", "Master", "Epic", "Legend", "God"};
void win_screen(s16 score) {
u8 i, j;
u8 i, j, r;
if(score > 29) r = 4;
else if(score > 24) r = 3;
else if(score > 19) r = 2;
else if(score > 9) r = 1;
else r = 0;
termreset();
cputs( \
" \x1d \x1c \x0e\x0e\x0e \x1c \x1c" NL
@@ -102,9 +108,10 @@ void win_screen(s16 score) {
cputsxy(0, 7, " You made it across");
cputsxy(0, 8, " the dangerous");
cputsxy(0, 9, " dungeon alive!");
gotoxy(0, 11);
cprintf(" Your score: ");
printnum(score);
gotoxy(1, 11);
cprintf("Score: %d", score);
gotoxy(SCREEN_WIDTH-3-strlen(ranks[r]), 11);
cprintf("|%s|", ranks[r]);
chlinexy(0, 12, SCREEN_WIDTH);
cputs(" By: Luxferre, 2026");
cputs(NL NL " Orig: Zach Gage," NL " Kurt Bieg, 2011");
@@ -184,13 +191,9 @@ void render_room_item(u8 i, u8 v) {
rect(topleft_x, topleft_y, cwidth, cheight);
gotoxy(topleft_x + 1, topleft_y + 1);
/* draw text */
if(v < 14) {
cputs("ENMY");
} else if(v < 23) {
cputs("WEAP");
} else {
cputs("POTI");
}
if(v < 14) cputs("ENMY");
else if(v < 23) cputs("WEAP");
else cputs("POTI");
gotoxy(topleft_x + 2, topleft_y + 2);
if(v < 14) printnum(v + 1);
else if(v < 23) printnum(v - 12);
@@ -368,8 +371,10 @@ s16 game() {
}
if(ch == CH_Q) {
hp = 0;
break;
if(confirm("End game?")) {
hp = 0;
break;
} else print_msg("Go on!");
} else if(ch == CH_INVAL) {
print_msg("Invalid input!");
beep_err();
+18
View File
@@ -37,6 +37,7 @@
#define EZJOY_B 6
#define EZJOY_SL 7
#define EZJOY_ST 8
#define EZJOY_COMBO 9
#define EZ_CORNER_UL (char) 20
#define EZ_CORNER_UR (char) 18
@@ -197,6 +198,23 @@ void wait_for_start_rand() {
srand(_ez_entropy);
}
/* wait for Start or a button combination */
u8 wait_for_start_or_combo(u8 combo_mask) {
u8 last_joy = 0, joy, pressed;
/* wait until the previous key is released */
while(joy_read(JOY_1));
/* wait for a new press */
while(1) {
++_ez_entropy;
joy = joy_read(JOY_1);
pressed = joy & ~last_joy;
if(pressed == combo_mask) return EZJOY_COMBO;
if(pressed & JOY_BTN_4_MASK) return EZJOY_ST;
last_joy = joy;
waitvsync();
}
}
/* Generic helper methods */
/* Array shuffle method */
+29 -5
View File
@@ -96,8 +96,18 @@ void game_startup() {
}
/* Win screen display */
static char* ranks[] = {"Survivor", "Master", "Epic", "Legend", "God"};
static u8 sb1[] = { 6, 0x14, 3, 16, 0x75, 0, 0x1E, 7, 0x14, 0x1C, 0x1B, 0x1C, 0x14, 0x1B, 6, 0};
static u8 sb2[] = { 0x13, 7, 0x1A, 0x18, 0x75, 15, 16, 0x16, 1, 0x14, 1, 0x1A, 7, 6, 0x1D, 0x1C, 5, 0 };
static u8 sb3[] = { 0xF9, 0xFA, 0xF8, 0xEF, 0xEB, 0xEE, 0x8A, 0xFE, 0xE2, 0xEF, 0x8A, 0xFD,
0xE5, 0xF8, 0xEE, 0};
void win_screen(s16 score) {
u8 i, j;
u8 i, j, r;
if(score > 29) r = 4;
else if(score > 24) r = 3;
else if(score > 19) r = 2;
else if(score > 9) r = 1;
else r = 0;
clrscr();
ppu_off();
for(j=0;j<12;j+=4)
@@ -111,7 +121,9 @@ void win_screen(s16 score) {
" |::.|:. |::.|::.| |\r\n" \
" `--- ---`---`--- ---'");
cputsxy(0, 12, " Congratulations! You made it\r\n through the dangerous\r\n dungeon alive!\r\n\r\n");
cprintf(" Your score: %d\r\n\r\n", score);
cprintf(" Score: %d", score);
gotoxy(SCREEN_WIDTH - 8 - strlen(ranks[r]), 16);
cprintf("Rank: %s", ranks[r]);
chlinexy(0, 17, SCREEN_WIDTH);
cputs("Created by Luxferre in 2026\r\nReleased into public domain\r\n");
cputs("\r\nOriginal concept by Zach Gage\r\nand Kurt Bieg, 2011");
@@ -120,7 +132,17 @@ void win_screen(s16 score) {
ppu_on();
waitvsync();
beep_win();
wait_for_start();
for(i=0;i<15;++i) sb1[i] ^= 0x55;
for(i=0;i<17;++i) sb2[i] ^= 0x55;
for(i=0;i<15;++i) sb3[i] ^= 0xaa;
do {
r = wait_for_start_or_combo(JOY_BTN_1_MASK | JOY_BTN_2_MASK);
if(r == EZJOY_COMBO) {
cputsxy(8, 1, sb1);
cputsxy(7, 2, sb2);
cputsxy(8, 10, sb3);
}
} while(r != EZJOY_ST);
}
/* UI choices */
@@ -393,8 +415,10 @@ s16 game() {
}
if(ch == CH_Q) {
hp = 0;
break;
if(confirm("End game?")) {
hp = 0;
break;
} else print_msg("Go on!");
} else if(ch == CH_INVAL) {
print_msg("Invalid input!");
beep_err();