PCE.ino: Get rid of menuOptionspceCart global variable

Also, move a few inline string constants into PROGMEM.
Uses 64 bytes of program space.
Frees 206 bytes of global ram space.
This commit is contained in:
Vincent Pelletier 2022-10-29 01:08:42 +00:00
parent 59665bb848
commit cb26782e22

View File

@ -58,15 +58,13 @@ static const char pceMenuItem3[] PROGMEM = "Turbochip";
static const char *const menuOptionspce[] PROGMEM = { pceMenuItem1, pceMenuItem2, pceMenuItem3, string_reset2 };
// PCE card menu items
static char menuOptionspceCart[7][20] = {
"Read ROM",
"", // Read RAM Bank %d
"", //Write RAM Bank %d
"Reset",
"Inc Bank Number",
"Dec Bank Number",
"" // ROM size now %dK / Force ROM size
};
static const char menuOptionspceCart_0[] PROGMEM = "Read ROM";
static const char menuOptionspceCart_1_fmt[] PROGMEM = "Read RAM Bank %d";
static const char menuOptionspceCart_2_fmt[] PROGMEM = "Write RAM Bank %d";
static const char menuOptionspceCart_4[] PROGMEM = "Inc Bank Number";
static const char menuOptionspceCart_5[] PROGMEM = "Dec Bank Number";
static const char menuOptionspceCart_6_fmt[] PROGMEM = "ROM size now %dK";
static const char menuOptionspceCart_6[] PROGMEM = "Force ROM size";
// Turbochip menu items
static const char pceTCMenuItem1[] PROGMEM = "Read ROM";
@ -791,14 +789,18 @@ void pceMenu() {
unsigned char mainMenu;
if (pce_internal_mode == HUCARD || pce_internal_mode == HUCARD_NOSWAP) {
sprintf(menuOptionspceCart[1], "Read RAM Bank %d", tennokoe_bank_index + 1);
sprintf(menuOptionspceCart[2], "Write RAM Bank %d", tennokoe_bank_index + 1);
strcpy_P(menuOptions[0], menuOptionspceCart_0);
sprintf_P(menuOptions[1], menuOptionspceCart_1_fmt, tennokoe_bank_index + 1);
sprintf_P(menuOptions[2], menuOptionspceCart_2_fmt, tennokoe_bank_index + 1);
strcpy_P(menuOptions[3], string_reset2);
strcpy_P(menuOptions[4], menuOptionspceCart_4);
strcpy_P(menuOptions[5], menuOptionspceCart_5);
if (pce_force_rom_size > 0) {
sprintf(menuOptionspceCart[6], "ROM size now %dK", pce_force_rom_size);
sprintf_P(menuOptions[6], menuOptionspceCart_6_fmt, pce_force_rom_size);
} else {
sprintf(menuOptionspceCart[6], "Force ROM size");
strcpy_P(menuOptions[6], menuOptionspceCart_6);
}
mainMenu = question_box(F("PCE HuCARD menu"), menuOptionspceCart, 7, 0);
mainMenu = question_box(F("PCE HuCARD menu"), menuOptions, 7, 0);
// wait for user choice to come back from the question box menu
switch (mainMenu) {