Skip to content

Commit f011ca1

Browse files
committed
Add per-game setting to turn on/off DS Phat colors
1 parent e05e51f commit f011ca1

File tree

19 files changed

+406
-18
lines changed

19 files changed

+406
-18
lines changed

quickmenu/arm9/source/main.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "autoboot.h" // For rebooting into the game
5858

5959
#include "defaultSettings.h"
60+
#include "colorLutBlacklist.h"
6061
#include "twlClockExcludeMap.h"
6162
#include "dmaExcludeMap.h"
6263
#include "asyncReadExcludeMap.h"
@@ -172,6 +173,21 @@ void stop (void) {
172173
}
173174
}
174175

176+
/**
177+
* Disables DS Phat colors for a specific game.
178+
*/
179+
bool setDSPhatColors() {
180+
// TODO: If the list gets large enough, switch to bsearch().
181+
for (unsigned int i = 0; i < sizeof(colorLutBlacklist)/sizeof(colorLutBlacklist[0]); i++) {
182+
if (memcmp(gameTid[ms().secondaryDevice], colorLutBlacklist[i], 3) == 0) {
183+
// Found match
184+
return false;
185+
}
186+
}
187+
188+
return perGameSettings_dsPhatColors == -1 ? DEFAULT_PHAT_COLORS : perGameSettings_dsPhatColors;
189+
}
190+
175191
/**
176192
* Disable TWL clock speed for a specific game.
177193
*/
@@ -2384,6 +2400,7 @@ int dsClassicMenu(void) {
23842400
bootstrapini.SetString("NDS-BOOTSTRAP", "PRV_PATH", sfnPrv);
23852401
bootstrapini.SetString("NDS-BOOTSTRAP", "MANUAL_PATH", getGameManual(filename[ms().secondaryDevice].c_str()));
23862402
bootstrapini.SetString("NDS-BOOTSTRAP", "GUI_LANGUAGE", ms().getGuiLanguageString());
2403+
bootstrapini.SetInt("NDS-BOOTSTRAP", "PHAT_COLORS", setDSPhatColors());
23872404
bootstrapini.SetInt("NDS-BOOTSTRAP", "LANGUAGE", perGameSettings_language == -2 ? ms().gameLanguage : perGameSettings_language);
23882405
bootstrapini.SetInt("NDS-BOOTSTRAP", "REGION", perGameSettings_region < -1 ? ms().gameRegion : perGameSettings_region);
23892406
bootstrapini.SetInt("NDS-BOOTSTRAP", "USE_ROM_REGION", perGameSettings_region < -1 ? ms().useRomRegion : 0);
@@ -2602,6 +2619,7 @@ int dsClassicMenu(void) {
26022619
bootstrapini.SetString("NDS-BOOTSTRAP", "HOMEBREW_ARG", (useWidescreen && (gameTid[ms().secondaryDevice][0] == 'W' || romVersion[ms().secondaryDevice] == 0x57)) ? "wide" : "");
26032620
bootstrapini.SetString("NDS-BOOTSTRAP", "RAM_DRIVE_PATH", (perGameSettings_ramDiskNo >= 0 && !ms().secondaryDevice) ? ramdiskpath : "sd:/null.img");
26042621
bootstrapini.SetString("NDS-BOOTSTRAP", "GUI_LANGUAGE", ms().getGuiLanguageString());
2622+
bootstrapini.SetInt("NDS-BOOTSTRAP", "PHAT_COLORS", setDSPhatColors());
26052623
bootstrapini.SetInt("NDS-BOOTSTRAP", "LANGUAGE", perGameSettings_language == -2 ? ms().gameLanguage : perGameSettings_language);
26062624
bootstrapini.SetInt("NDS-BOOTSTRAP", "REGION", perGameSettings_region < -1 ? ms().gameRegion : perGameSettings_region);
26072625
bootstrapini.SetInt("NDS-BOOTSTRAP", "USE_ROM_REGION", perGameSettings_region < -1 ? ms().useRomRegion : 0);

quickmenu/arm9/source/perGameSettings.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
int perGameSettings_cursorPosition = 0;
2020
bool perGameSettings_directBoot = false; // Homebrew only
2121
int perGameSettings_dsiMode = -1;
22+
int perGameSettings_dsPhatColors = -1;
2223
int perGameSettings_language = -2;
2324
int perGameSettings_region = -2;
2425
int perGameSettings_saveNo = 0;
@@ -43,6 +44,7 @@ void loadPerGameSettings (std::string filename) {
4344
} else {
4445
perGameSettings_dsiMode = pergameini.GetInt("GAMESETTINGS", "DSI_MODE", -1);
4546
}
47+
perGameSettings_dsPhatColors = pergameini.GetInt("GAMESETTINGS", "PHAT_COLORS", -1);
4648
perGameSettings_language = pergameini.GetInt("GAMESETTINGS", "LANGUAGE", -2);
4749
perGameSettings_region = pergameini.GetInt("GAMESETTINGS", "REGION", -2);
4850
if (perGameSettings_region < -2 || (!dsiFeatures() && perGameSettings_region == -1)) perGameSettings_region = -2;

quickmenu/arm9/source/perGameSettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern bool perGameSettingsButtons;
77

88
extern bool perGameSettings_directBoot; // Homebrew only
99
extern int perGameSettings_dsiMode;
10+
extern int perGameSettings_dsPhatColors;
1011
extern int perGameSettings_language;
1112
extern int perGameSettings_region;
1213
extern int perGameSettings_ramDiskNo;

romsel_aktheme/arm9/source/main.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151
#include "autoboot.h" // For rebooting into the game
5252

53+
#include "colorLutBlacklist.h"
5354
#include "twlClockExcludeMap.h"
5455
#include "dmaExcludeMap.h"
5556
#include "asyncReadExcludeMap.h"
@@ -239,6 +240,21 @@ void stop (void) {
239240
}
240241
}
241242

243+
/**
244+
* Disables DS Phat colors for a specific game.
245+
*/
246+
bool setDSPhatColors() {
247+
// TODO: If the list gets large enough, switch to bsearch().
248+
for (unsigned int i = 0; i < sizeof(colorLutBlacklist)/sizeof(colorLutBlacklist[0]); i++) {
249+
if (memcmp(gameTid[cursorPosOnScreen], colorLutBlacklist[i], 3) == 0) {
250+
// Found match
251+
return false;
252+
}
253+
}
254+
255+
return perGameSettings_dsPhatColors == -1 ? DEFAULT_PHAT_COLORS : perGameSettings_dsPhatColors;
256+
}
257+
242258
/**
243259
* Disable TWL clock speed for a specific game.
244260
*/
@@ -1484,6 +1500,7 @@ int akTheme(void) {
14841500
bootstrapini.SetString("NDS-BOOTSTRAP", "PRV_PATH", sfnPrv);
14851501
bootstrapini.SetString("NDS-BOOTSTRAP", "MANUAL_PATH", getGameManual(filename.c_str()));
14861502
bootstrapini.SetString("NDS-BOOTSTRAP", "GUI_LANGUAGE", ms().getGuiLanguageString());
1503+
bootstrapini.SetInt("NDS-BOOTSTRAP", "PHAT_COLORS", setDSPhatColors());
14871504
bootstrapini.SetInt("NDS-BOOTSTRAP", "LANGUAGE", perGameSettings_language == -2 ? ms().getGameLanguage() : perGameSettings_language);
14881505
bootstrapini.SetInt("NDS-BOOTSTRAP", "REGION", perGameSettings_region < -1 ? ms().gameRegion : perGameSettings_region);
14891506
bootstrapini.SetInt("NDS-BOOTSTRAP", "USE_ROM_REGION", perGameSettings_region < -1 ? ms().useRomRegion : 0);
@@ -1698,6 +1715,7 @@ int akTheme(void) {
16981715
bootstrapini.SetString("NDS-BOOTSTRAP", "HOMEBREW_ARG", (useWidescreen && (gameTid[cursorPosOnScreen][0] == 'W' || romVersion[cursorPosOnScreen] == 0x57)) ? "wide" : "");
16991716
bootstrapini.SetString("NDS-BOOTSTRAP", "RAM_DRIVE_PATH", (perGameSettings_ramDiskNo >= 0 && !ms().secondaryDevice) ? ramdiskpath : "sd:/null.img");
17001717
bootstrapini.SetString("NDS-BOOTSTRAP", "GUI_LANGUAGE", ms().getGuiLanguageString());
1718+
bootstrapini.SetInt("NDS-BOOTSTRAP", "PHAT_COLORS", setDSPhatColors());
17011719
bootstrapini.SetInt("NDS-BOOTSTRAP", "LANGUAGE", perGameSettings_language == -2 ? ms().getGameLanguage() : perGameSettings_language);
17021720
bootstrapini.SetInt("NDS-BOOTSTRAP", "REGION", perGameSettings_region < -1 ? ms().gameRegion : perGameSettings_region);
17031721
bootstrapini.SetInt("NDS-BOOTSTRAP", "USE_ROM_REGION", perGameSettings_region < -1 ? ms().useRomRegion : 0);

romsel_aktheme/arm9/source/perGameSettings.cpp

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@
3232
#include "common/systemdetails.h"
3333
#include "common/twlmenusettings.h"
3434

35+
#include "colorLutBlacklist.h"
3536
#include "twlClockExcludeMap.h"
3637
#include "dmaExcludeMap.h"
3738
#include "asyncReadExcludeMap.h"
3839

3940
extern bool useTwlCfg;
4041

42+
extern u16* colorTable;
4143
extern bool lcdSwapped;
4244

4345
std::string SDKnumbertext;
@@ -53,6 +55,7 @@ bool perGameSettingsChanged = false;
5355
int perGameSettings_cursorPosition = 0;
5456
bool perGameSettings_directBoot = false; // Homebrew only
5557
int perGameSettings_dsiMode = -1;
58+
int perGameSettings_dsPhatColors = -1;
5659
int perGameSettings_language = -2;
5760
int perGameSettings_region = -2;
5861
int perGameSettings_saveNo = 0;
@@ -82,10 +85,11 @@ extern bool usernameRenderedDone;
8285
char fileCounter[8];
8386
char gameTIDText[16];
8487

85-
int firstPerGameOpShown = 0;
86-
int perGameOps = -1;
87-
int perGameOp[10] = {-1};
88+
static int firstPerGameOpShown = 0;
89+
static int perGameOps = -1;
90+
static int perGameOp[17] = {-1};
8891

92+
bool blacklisted_colorLut = false;
8993
bool blacklisted_boostCpu = false;
9094
bool blacklisted_cardReadDma = false;
9195
bool blacklisted_asyncCardRead = false;
@@ -99,6 +103,7 @@ void loadPerGameSettings (std::string filename) {
99103
} else {
100104
perGameSettings_dsiMode = pergameini.GetInt("GAMESETTINGS", "DSI_MODE", -1);
101105
}
106+
perGameSettings_dsPhatColors = pergameini.GetInt("GAMESETTINGS", "PHAT_COLORS", -1);
102107
perGameSettings_language = pergameini.GetInt("GAMESETTINGS", "LANGUAGE", -2);
103108
perGameSettings_region = pergameini.GetInt("GAMESETTINGS", "REGION", -2);
104109
if (perGameSettings_region < -2 || (!dsiFeatures() && perGameSettings_region == -1)) perGameSettings_region = -2;
@@ -141,7 +146,10 @@ void savePerGameSettings (std::string filename) {
141146
pergameini.SetInt("GAMESETTINGS", "WIDESCREEN", perGameSettings_wideScreen);
142147
}
143148
} else {
144-
if ((perGameSettings_useBootstrap == -1 ? ms().useBootstrap : perGameSettings_useBootstrap) || (dsiFeatures() && romUnitCode[cursorPosOnScreen] > 0) || isDSiWare[cursorPosOnScreen] || !ms().secondaryDevice) pergameini.SetInt("GAMESETTINGS", "LANGUAGE", perGameSettings_language);
149+
if ((perGameSettings_useBootstrap == -1 ? ms().useBootstrap : perGameSettings_useBootstrap) || (dsiFeatures() && romUnitCode[cursorPosOnScreen] > 0) || isDSiWare[cursorPosOnScreen] || !ms().secondaryDevice) {
150+
if (sys().dsiWramAccess() && !sys().dsiWramMirrored() && !blacklisted_colorLut) pergameini.SetInt("GAMESETTINGS", "PHAT_COLORS", perGameSettings_dsPhatColors);
151+
pergameini.SetInt("GAMESETTINGS", "LANGUAGE", perGameSettings_language);
152+
}
145153
if (!isDSiWare[cursorPosOnScreen] && ((perGameSettings_useBootstrap == -1 ? ms().useBootstrap : perGameSettings_useBootstrap) || (dsiFeatures() && romUnitCode[cursorPosOnScreen] > 0) || !ms().secondaryDevice)) {
146154
pergameini.SetInt("GAMESETTINGS", "REGION", perGameSettings_region);
147155
pergameini.SetInt("GAMESETTINGS", "DSI_MODE", perGameSettings_dsiMode);
@@ -386,6 +394,16 @@ void perGameSettings (std::string filename) {
386394
FILE *f_nds_file = fopen(filenameForInfo.c_str(), "rb");
387395

388396
// Check if blacklisted
397+
blacklisted_colorLut = false;
398+
if (sys().dsiWramAccess() && !sys().dsiWramMirrored()) {
399+
for (unsigned int i = 0; i < sizeof(colorLutBlacklist)/sizeof(colorLutBlacklist[0]); i++) {
400+
if (memcmp(gameTid[cursorPosOnScreen], colorLutBlacklist[i], 3) == 0) {
401+
// Found match
402+
blacklisted_colorLut = true;
403+
}
404+
}
405+
}
406+
389407
blacklisted_boostCpu = false;
390408
blacklisted_cardReadDma = false;
391409
blacklisted_asyncCardRead = false;
@@ -475,7 +493,12 @@ void perGameSettings (std::string filename) {
475493
}
476494

477495
#define sharedWramEnabled (!sys().arm7SCFGLocked() || *(u32*)0x02FFE1A0 != 0x00403000)
478-
u32 romSizeLimit = (ms().consoleModel > 0 ? 0x1BE0000 : 0xBE0000) + ((sys().dsiWramAccess() && !sys().dsiWramMirrored()) ? (sharedWramEnabled ? 0x88000 : 0x80000) : (sharedWramEnabled ? 0x8000 : 0));
496+
u32 dsiWramAmount = (sharedWramEnabled ? 0x88000 : 0x80000);
497+
if (colorTable && sys().dsiWramAccess() && !sys().dsiWramMirrored()) {
498+
dsiWramAmount -= 0x80000;
499+
dsiWramAmount += 0x4AC00;
500+
}
501+
u32 romSizeLimit = (ms().consoleModel > 0 ? 0x1BE0000 : 0xBE0000) + ((sys().dsiWramAccess() && !sys().dsiWramMirrored()) ? dsiWramAmount : (sharedWramEnabled ? 0x8000 : 0));
479502
romSizeLimit -= 0x400000; // Account for DSi mode setting
480503
const u32 romSizeLimitTwl = (ms().consoleModel > 0 ? 0x1000000 : 0);
481504
const bool romLoadableInRam = (romSize <= (romUnitCode[cursorPosOnScreen] > 0 ? romSizeLimitTwl : romSizeLimit));
@@ -498,7 +521,7 @@ void perGameSettings (std::string filename) {
498521

499522
firstPerGameOpShown = 0;
500523
perGameOps = -1;
501-
for (int i = 0; i < 10; i++) {
524+
for (int i = 0; i < 17; i++) {
502525
perGameOp[i] = -1;
503526
}
504527
if (isHomebrew[cursorPosOnScreen]) { // Per-game settings for homebrew
@@ -542,6 +565,10 @@ void perGameSettings (std::string filename) {
542565
}
543566
} else if (showPerGameSettings && isDSiWare[cursorPosOnScreen]) { // Per-game settings for DSiWare
544567
if ((perGameSettings_dsiwareBooter == -1 ? ms().dsiWareBooter : perGameSettings_dsiwareBooter) || sys().arm7SCFGLocked() || ms().consoleModel > 0) {
568+
if (((dsiFeatures() && !bs().b4dsMode) || !ms().secondaryDevice) && sys().dsiWramAccess() && !sys().dsiWramMirrored() && !blacklisted_colorLut) {
569+
perGameOps++;
570+
perGameOp[perGameOps] = 16; // DS Phat Colors
571+
}
545572
perGameOps++;
546573
perGameOp[perGameOps] = 0; // Language
547574
perGameOps++;
@@ -578,6 +605,10 @@ void perGameSettings (std::string filename) {
578605
} else if (showPerGameSettings) { // Per-game settings for retail/commercial games
579606
const bool bootstrapEnabled = ((perGameSettings_useBootstrap == -1 ? ms().useBootstrap : perGameSettings_useBootstrap) || (dsiFeatures() && romUnitCode[cursorPosOnScreen] > 0) || (ms().secondaryDevice && (!ms().kernelUseable || romUnitCode[cursorPosOnScreen] == 3)) || !ms().secondaryDevice);
580607
if (bootstrapEnabled) {
608+
if (((dsiFeatures() && !bs().b4dsMode) || !ms().secondaryDevice) && sys().dsiWramAccess() && !sys().dsiWramMirrored() && !blacklisted_colorLut) {
609+
perGameOps++;
610+
perGameOp[perGameOps] = 16; // DS Phat Colors
611+
}
581612
perGameOps++;
582613
perGameOp[perGameOps] = 0; // Language
583614
}
@@ -890,6 +921,16 @@ void perGameSettings (std::string filename) {
890921
}
891922
}
892923
break;
924+
case 16:
925+
printSmall(false, perGameOpXpos, perGameOpYpos, "DS Phat Colors:", Alignment::left, highlighted);
926+
if (perGameSettings_dsPhatColors == -1) {
927+
printSmall(false, 256-perGameOpXpos, perGameOpYpos, "Default", Alignment::right, highlighted);
928+
} else if (perGameSettings_dsPhatColors == 1) {
929+
printSmall(false, 256-perGameOpXpos, perGameOpYpos, "On", Alignment::right, highlighted);
930+
} else {
931+
printSmall(false, 256-perGameOpXpos, perGameOpYpos, "Off", Alignment::right, highlighted);
932+
}
933+
break;
893934
}
894935
perGameOpYpos += 12;
895936
}
@@ -1008,6 +1049,10 @@ void perGameSettings (std::string filename) {
10081049
perGameSettings_useBootstrap--;
10091050
if (perGameSettings_useBootstrap < -1) perGameSettings_useBootstrap = 1;
10101051
break;
1052+
case 16:
1053+
perGameSettings_dsPhatColors--;
1054+
if (perGameSettings_dsPhatColors < -1) perGameSettings_dsPhatColors = 1;
1055+
break;
10111056
}
10121057
perGameSettingsChanged = true;
10131058
} else if ((pressed & KEY_A) || (held & KEY_RIGHT)) {
@@ -1125,6 +1170,10 @@ void perGameSettings (std::string filename) {
11251170
perGameSettings_useBootstrap++;
11261171
if (perGameSettings_useBootstrap > 1) perGameSettings_useBootstrap = -1;
11271172
break;
1173+
case 16:
1174+
perGameSettings_dsPhatColors++;
1175+
if (perGameSettings_dsPhatColors > 1) perGameSettings_dsPhatColors = -1;
1176+
break;
11281177
}
11291178
perGameSettingsChanged = true;
11301179
}

romsel_aktheme/arm9/source/perGameSettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ extern bool perGameSettingsButtons;
99

1010
extern bool perGameSettings_directBoot; // Homebrew only
1111
extern int perGameSettings_dsiMode;
12+
extern int perGameSettings_dsPhatColors;
1213
extern int perGameSettings_language;
1314
extern int perGameSettings_region;
1415
extern int perGameSettings_ramDiskNo;

romsel_dsimenutheme/arm9/source/language.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ STRING(NEXT_R, "Next Page \\R")
147147

148148
// Per-game settings
149149
STRING(SDK_VER, "SDK ver: %s")
150+
STRING(DS_PHAT_COLORS, "DS Phat Colors")
150151
STRING(LANGUAGE, "Language")
151152
STRING(REGION, "Region")
152153
STRING(RAM_DISK, "RAM disk")

romsel_dsimenutheme/arm9/source/main.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
#include "autoboot.h" // For rebooting into the game
6060

61+
#include "colorLutBlacklist.h"
6162
#include "twlClockExcludeMap.h"
6263
#include "dmaExcludeMap.h"
6364
#include "asyncReadExcludeMap.h"
@@ -170,6 +171,21 @@ int SetDonorSDK() {
170171
}
171172

172173

174+
/**
175+
* Disables DS Phat colors for a specific game.
176+
*/
177+
bool setDSPhatColors() {
178+
// TODO: If the list gets large enough, switch to bsearch().
179+
for (unsigned int i = 0; i < sizeof(colorLutBlacklist)/sizeof(colorLutBlacklist[0]); i++) {
180+
if (memcmp(gameTid[CURPOS], colorLutBlacklist[i], 3) == 0) {
181+
// Found match
182+
return false;
183+
}
184+
}
185+
186+
return perGameSettings_dsPhatColors == -1 ? DEFAULT_PHAT_COLORS : perGameSettings_dsPhatColors;
187+
}
188+
173189
/**
174190
* Disable TWL clock speed for a specific game.
175191
*/
@@ -1468,6 +1484,7 @@ int dsiMenuTheme(void) {
14681484
bootstrapini.SetString("NDS-BOOTSTRAP", "PRV_PATH", sfnPrv);
14691485
bootstrapini.SetString("NDS-BOOTSTRAP", "MANUAL_PATH", getGameManual(filename.c_str()));
14701486
bootstrapini.SetString("NDS-BOOTSTRAP", "GUI_LANGUAGE", ms().getGuiLanguageString());
1487+
bootstrapini.SetInt("NDS-BOOTSTRAP", "PHAT_COLORS", setDSPhatColors());
14711488
bootstrapini.SetInt("NDS-BOOTSTRAP", "LANGUAGE", perGameSettings_language == -2 ? ms().gameLanguage : perGameSettings_language);
14721489
bootstrapini.SetInt("NDS-BOOTSTRAP", "REGION", perGameSettings_region < -1 ? ms().gameRegion : perGameSettings_region);
14731490
bootstrapini.SetInt("NDS-BOOTSTRAP", "USE_ROM_REGION", perGameSettings_region < -1 ? ms().useRomRegion : 0);
@@ -1668,6 +1685,7 @@ int dsiMenuTheme(void) {
16681685
}
16691686
bootstrapini.SetString("NDS-BOOTSTRAP", "RAM_DRIVE_PATH", (perGameSettings_ramDiskNo >= 0 && !ms().secondaryDevice) ? ramdiskpath : "sd:/null.img");
16701687
bootstrapini.SetString("NDS-BOOTSTRAP", "GUI_LANGUAGE", ms().getGuiLanguageString());
1688+
bootstrapini.SetInt("NDS-BOOTSTRAP", "PHAT_COLORS", setDSPhatColors());
16711689
bootstrapini.SetInt("NDS-BOOTSTRAP", "LANGUAGE", perGameSettings_language == -2 ? ms().gameLanguage : perGameSettings_language);
16721690
bootstrapini.SetInt("NDS-BOOTSTRAP", "REGION", perGameSettings_region < -1 ? ms().gameRegion : perGameSettings_region);
16731691
bootstrapini.SetInt("NDS-BOOTSTRAP", "USE_ROM_REGION", perGameSettings_region < -1 ? ms().useRomRegion : 0);

0 commit comments

Comments
 (0)