Skip to content

Commit 58a6f6e

Browse files
committed
Prevent saving/loading settings if vanilla code is doing memory card stuff
This check is done via cardIsExec. Also adjusted the text that is displayed when saving/loading settings.
1 parent 1b54a46 commit 58a6f6e

File tree

8 files changed

+69
-9
lines changed

8 files changed

+69
-9
lines changed

ttyd-tools/rel/include/global.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ enum SETTINGS_OPTIONS
255255

256256
enum SETTINGS_RETURN_CODES
257257
{
258+
MEMCARD_IN_USE = -200,
258259
LOAD_FAILED = 1,
259260
LOAD_FAILED_NO_FILE,
260261
LOAD_SUCCESSFUL,
@@ -803,7 +804,7 @@ struct DisplayActionCommandsTiming
803804

804805
struct MemoryCardStruct
805806
{
806-
uint8_t ReturnCode;
807+
int32_t ReturnCode;
807808
const char *SettingsFileName;
808809
const char *SettingsDescription;
809810
const char *RelFileName;

ttyd-tools/rel/include/ttyd.eu.lst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@
10501050
// 800B33D8:cardCopy2Main
10511051
// 800B3564:cardMain
10521052
// 800B3BDC:cardGetCode
1053-
// 800B3BE8:cardIsExec
1053+
800B3BE8:cardIsExec
10541054
// 800B3CB4:cardInit
10551055
// 800B3F28:cardBufReset
10561056
// 800B4118:cardGetFilePtr

ttyd-tools/rel/include/ttyd.jp.lst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@
10471047
// 800B0640:cardCopy2Main
10481048
// 800B07AC:cardMain
10491049
// 800B0E24:cardGetCode
1050-
// 800B0E30:cardIsExec
1050+
800B0E30:cardIsExec
10511051
// 800B0EFC:cardInit
10521052
// 800B1304:cardBufReset
10531053
// 800B1688:cardGetFilePtr

ttyd-tools/rel/include/ttyd.us.lst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@
10481048
// 800B2388:cardCopy2Main
10491049
// 800B2508:cardMain
10501050
// 800B2B80:cardGetCode
1051-
// 800B2B8C:cardIsExec
1051+
800B2B8C:cardIsExec
10521052
// 800B2C58:cardInit
10531053
// 800B3060:cardBufReset
10541054
// 800B33E4:cardGetFilePtr

ttyd-tools/rel/include/ttyd/cardmgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ extern "C" {
6969
// cardCopy2Main
7070
// cardMain
7171
// cardGetCode
72-
// cardIsExec
72+
bool cardIsExec();
7373
// cardInit
7474
// cardBufReset
7575
// cardGetFilePtr

ttyd-tools/rel/source/draw.cpp

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5487,37 +5487,73 @@ void drawSettingsCurrentWork()
54875487
{
54885488
const char *String;
54895489
int32_t WindowWidth;
5490+
int32_t TextPosX = -50;
54905491

54915492
switch (MenuSettings.ReturnCode)
54925493
{
54935494
case LOAD_FAILED:
54945495
{
54955496
String = "Load Failed";
54965497
WindowWidth = 129;
5498+
5499+
#ifdef TTYD_JP
5500+
WindowWidth -= 7;
5501+
TextPosX += 4;
5502+
#endif
54975503
break;
54985504
}
54995505
case LOAD_FAILED_NO_FILE:
55005506
{
5501-
String = "Settings file not found";
5502-
WindowWidth = 218;
5507+
String = "Settings File Not Found";
5508+
WindowWidth = 226;
5509+
TextPosX -= 48;
5510+
5511+
#ifdef TTYD_JP
5512+
WindowWidth -= 8;
5513+
TextPosX += 3;
5514+
#endif
55035515
break;
55045516
}
55055517
case LOAD_SUCCESSFUL:
55065518
{
55075519
String = "Load Successful";
55085520
WindowWidth = 162;
5521+
TextPosX -= 16;
55095522
break;
55105523
}
55115524
case SAVE_FAILED:
55125525
{
55135526
String = "Save Failed";
55145527
WindowWidth = 129;
5528+
5529+
#ifdef TTYD_JP
5530+
WindowWidth -= 7;
5531+
TextPosX += 4;
5532+
#endif
55155533
break;
55165534
}
55175535
case SAVE_SUCCESSFUL:
55185536
{
55195537
String = "Save Successful";
5520-
WindowWidth = 162;
5538+
WindowWidth = 160;
5539+
TextPosX -= 15;
5540+
5541+
#ifdef TTYD_JP
5542+
WindowWidth += 4;
5543+
TextPosX -= 2;
5544+
#endif
5545+
break;
5546+
}
5547+
case MEMCARD_IN_USE:
5548+
{
5549+
String = "Memory Card Currently In Use";
5550+
WindowWidth = 275;
5551+
TextPosX -= 73;
5552+
5553+
#ifdef TTYD_JP
5554+
WindowWidth -= 3;
5555+
TextPosX += 2;
5556+
#endif
55215557
break;
55225558
}
55235559
default:
@@ -5530,7 +5566,6 @@ void drawSettingsCurrentWork()
55305566
uint32_t TextColor = 0xFFFFFFFF;
55315567
uint32_t WindowColor = 0x151515F4;
55325568
uint8_t Alpha = 0xFF;
5533-
int32_t TextPosX = -80;
55345569
int32_t TextPosY = 0;
55355570
int32_t WindowCurve = 10;
55365571
float Scale = 0.6;

ttyd-tools/rel/source/memcard.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ int32_t createSettingsFile(gc::card::CARDFileInfo *settingsFileInfo)
201201

202202
int32_t saveSettings()
203203
{
204+
// Make sure the vanilla code isn't currently doing memory card stuff
205+
if (ttyd::cardmgr::cardIsExec())
206+
{
207+
return MEMCARD_IN_USE;
208+
}
209+
204210
// Make sure a memory card is inserted into slot A
205211
int32_t ReturnCode = checkForMemoryCard();
206212
if (ReturnCode != CARD_RESULT_READY)
@@ -369,6 +375,12 @@ int32_t saveSettings()
369375

370376
int32_t loadSettings()
371377
{
378+
// Make sure the vanilla code isn't currently doing memory card stuff
379+
if (ttyd::cardmgr::cardIsExec())
380+
{
381+
return MEMCARD_IN_USE;
382+
}
383+
372384
// Make sure a memory card is inserted into slot A
373385
int32_t ReturnCode = checkForMemoryCard();
374386
if (ReturnCode != CARD_RESULT_READY)

ttyd-tools/rel/source/menu.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,12 @@ void menuCheckButton()
16791679
MenuVar.Timer = secondsToFrames(3);
16801680
break;
16811681
}
1682+
case MEMCARD_IN_USE:
1683+
{
1684+
MenuSettings.ReturnCode = MEMCARD_IN_USE;
1685+
MenuVar.Timer = secondsToFrames(3);
1686+
break;
1687+
}
16821688
default:
16831689
{
16841690
MenuSettings.ReturnCode = LOAD_FAILED;
@@ -1699,6 +1705,12 @@ void menuCheckButton()
16991705
MenuVar.Timer = secondsToFrames(3);
17001706
break;
17011707
}
1708+
case MEMCARD_IN_USE:
1709+
{
1710+
MenuSettings.ReturnCode = MEMCARD_IN_USE;
1711+
MenuVar.Timer = secondsToFrames(3);
1712+
break;
1713+
}
17021714
default:
17031715
{
17041716
MenuSettings.ReturnCode = SAVE_FAILED;

0 commit comments

Comments
 (0)