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
3940extern bool useTwlCfg;
4041
42+ extern u16 * colorTable;
4143extern bool lcdSwapped;
4244
4345std::string SDKnumbertext;
@@ -53,6 +55,7 @@ bool perGameSettingsChanged = false;
5355int perGameSettings_cursorPosition = 0 ;
5456bool perGameSettings_directBoot = false ; // Homebrew only
5557int perGameSettings_dsiMode = -1 ;
58+ int perGameSettings_dsPhatColors = -1 ;
5659int perGameSettings_language = -2 ;
5760int perGameSettings_region = -2 ;
5861int perGameSettings_saveNo = 0 ;
@@ -82,10 +85,11 @@ extern bool usernameRenderedDone;
8285char fileCounter[8 ];
8386char 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 ;
8993bool blacklisted_boostCpu = false ;
9094bool blacklisted_cardReadDma = false ;
9195bool 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 }
0 commit comments