Skip to content

Commit 6f5fd83

Browse files
committed
Ask for confirmation for resetting or quitting the game in in-game menu
Closes #1561
1 parent 1528b53 commit 6f5fd83

5 files changed

Lines changed: 65 additions & 11 deletions

File tree

retail/arm9/source/conf_sd.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ void getIgmStrings(configuration* conf, bool b4ds) {
610610
setIgmString(lang.fetch("TITLES", "JUMP_ADDRESS", "Jump to Address").c_str(), igmText->jumpAddress);
611611
setIgmString(lang.fetch("TITLES", "SELECT_BANK", "Select VRAM Bank").c_str(), igmText->selectBank);
612612
setIgmString(lang.fetch("TITLES", "COUNT", "Count:").c_str(), igmText->count);
613+
setIgmString(lang.fetch("TITLES", "A_YES", "A: Yes").c_str(), igmText->aYes);
614+
setIgmString(lang.fetch("TITLES", "B_NO", "B: No").c_str(), igmText->bNo);
615+
616+
setIgmString(lang.fetch("MESSAGES", "RESET_GAME", "Are you sure you want to reset the game?").c_str(), igmText->resetGameMessage);
617+
setIgmString(lang.fetch("MESSAGES", "QUIT_GAME", "Are you sure you want to quit the game?").c_str(), igmText->quitGameMessage);
613618

614619
setIgmString(lang.fetch("MENU", "RETURN_TO_GAME", "Return to Game").c_str(), igmText->menu[0]);
615620
setIgmString(lang.fetch("MENU", "RESET_GAME", "Reset Game").c_str(), igmText->menu[1]);

retail/cardenginei/arm9_igm/source/card_engine_header.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#Text is placed here
2626
igmText:
27-
.space 0xEA0
27+
.space 0xF40
2828
.align 4
2929

3030
sharedAddr:

retail/cardenginei/arm9_igm/source/inGameMenu.c

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void printRight(int x, int y, const unsigned char *str, FontPalette palette, boo
106106
*(dst--) = *(--str) | palette << 12;
107107
}
108108

109-
void printMsg(int y, const unsigned char *str, FontPalette palette, bool main) {
109+
int printMsg(int y, const unsigned char *str, FontPalette palette, bool main) {
110110
u16 *dst = main ? BG_MAP_RAM(15) : BG_MAP_RAM_SUB(15);
111111
while(*str) {
112112
bool endFound = false;
@@ -143,6 +143,7 @@ void printMsg(int y, const unsigned char *str, FontPalette palette, bool main) {
143143
}
144144
if (y == 0x18) break;
145145
}
146+
return y;
146147
}
147148

148149
void printChar(int x, int y, unsigned char c, FontPalette palette, bool main) {
@@ -237,6 +238,40 @@ void clearScreen(bool main) {
237238
toncset16(main ? BG_MAP_RAM(15) : BG_MAP_RAM_SUB(15), 0, 0x300);
238239
}
239240

241+
bool boolQuestion(const unsigned char *str) {
242+
clearScreen(false);
243+
244+
const int y = printMsg(0, str, FONT_WHITE, false) + 1;
245+
if (igmText.rtl) {
246+
printRight(0x20, y, igmText.aYes, FONT_WHITE, false);
247+
printRight(0x20, y+1, igmText.bNo, FONT_WHITE, false);
248+
} else {
249+
print(0, y, igmText.aYes, FONT_WHITE, false);
250+
print(0, y+1, igmText.bNo, FONT_WHITE, false);
251+
}
252+
253+
do {
254+
while (REG_VCOUNT != 191) mySwiDelay(100);
255+
while (REG_VCOUNT == 191) mySwiDelay(100);
256+
} while(KEYS & KEY_A);
257+
258+
waitKeys(KEY_A | KEY_B);
259+
260+
if (KEYS & KEY_A) {
261+
do {
262+
while (REG_VCOUNT != 191) mySwiDelay(100);
263+
while (REG_VCOUNT == 191) mySwiDelay(100);
264+
} while(KEYS & KEY_A);
265+
return true;
266+
} else {
267+
do {
268+
while (REG_VCOUNT != 191) mySwiDelay(100);
269+
while (REG_VCOUNT == 191) mySwiDelay(100);
270+
} while(KEYS & KEY_B);
271+
}
272+
return false;
273+
}
274+
240275
#define VRAM_x(bank) ((u16*)(0x6800000 + (0x0020000 * (bank))))
241276
#define VRAM_x_CR(bank) (((vu8*)0x04000240)[bank])
242277

@@ -949,11 +984,13 @@ u32 inGameMenu(s32 *mainScreen, u32 consoleModel, s32 *exceptionRegisters) {
949984
while (sharedAddr[4] != 0) swiDelay(100);
950985
break;
951986
case MENU_RESET:
952-
extern bool exceptionPrinted;
953-
exceptionPrinted = false;
954-
res = 0x52534554; // TESR
955-
sharedAddr[3] = res;
956-
sharedAddr[4] = 0x54455352; // RSET
987+
if (boolQuestion(igmText.resetGameMessage)) {
988+
extern bool exceptionPrinted;
989+
exceptionPrinted = false;
990+
res = 0x52534554; // TESR
991+
sharedAddr[3] = res;
992+
sharedAddr[4] = 0x54455352; // RSET
993+
}
957994
break;
958995
case MENU_SCREENSHOT:
959996
screenshot();
@@ -983,9 +1020,11 @@ u32 inGameMenu(s32 *mainScreen, u32 consoleModel, s32 *exceptionRegisters) {
9831020
ramViewer();
9841021
break;
9851022
case MENU_QUIT:
986-
res = 0x54495845; // EXIT
987-
sharedAddr[3] = res;
988-
sharedAddr[4] = 0x54495551; // QUIT
1023+
if (boolQuestion(igmText.quitGameMessage)) {
1024+
res = 0x54495845; // EXIT
1025+
sharedAddr[3] = res;
1026+
sharedAddr[4] = 0x54495551; // QUIT
1027+
}
9891028
break;
9901029
default:
9911030
break;

retail/common/include/igm_text.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ struct IgmText {
1414
unsigned char jumpAddress[20];
1515
unsigned char selectBank[20];
1616
unsigned char count[14];
17+
unsigned char aYes[16];
18+
unsigned char bNo[16];
1719
unsigned char menu[8][20];
20+
unsigned char resetGameMessage[64];
21+
unsigned char quitGameMessage[64];
1822
unsigned char optionsLabels[6][20];
1923
unsigned char optionsValues[7][20];
2024
unsigned char optionsDescriptions[6][192];
@@ -29,7 +33,7 @@ struct IgmText {
2933
};
3034

3135
#ifdef __cplusplus
32-
static_assert(sizeof(IgmText) == 0xEA0, "IgmText is too big! Allocate more space in the in-game menu header");
36+
static_assert(sizeof(IgmText) == 0xF40, "IgmText is too big! Allocate more space in the in-game menu header");
3337

3438
enum class IgmFont : u8 {
3539
arabic = 0,

retail/nitrofiles/languages/en/in_game_menu.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ RAM_VIEWER=RAM Viewer
33
JUMP_ADDRESS=Jump to Address
44
SELECT_BANK=Select VRAM Bank
55
COUNT=Count:
6+
A_YES=A: Yes
7+
B_NO=B: No
8+
9+
[MESSAGES]
10+
RESET_GAME=Are you sure you want to reset the game?
11+
QUIT_GAME=Are you sure you want to quit the game?
612

713
[MENU]
814
RETURN_TO_GAME=Return to Game

0 commit comments

Comments
 (0)