Skip to content

Commit c50fdfd

Browse files
committed
Fixed a bug that can cause the SDL port to be stuck on the greyscale palette
1 parent 2015782 commit c50fdfd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

SDL/gui.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,8 +1439,10 @@ static void cycle_palette(unsigned index)
14391439
}
14401440
}
14411441
else if (configuration.dmg_palette == 4) {
1442+
bool found = false;
14421443
for (unsigned i = 0; i < n_custom_palettes; i++) {
14431444
if (strcmp(custom_palettes[i], configuration.dmg_palette_name) == 0) {
1445+
found = true;
14441446
if (i == n_custom_palettes - 1) {
14451447
configuration.dmg_palette = 0;
14461448
}
@@ -1450,6 +1452,9 @@ static void cycle_palette(unsigned index)
14501452
break;
14511453
}
14521454
}
1455+
if (!found) {
1456+
configuration.dmg_palette = 0;
1457+
}
14531458
}
14541459
else {
14551460
configuration.dmg_palette++;
@@ -1471,7 +1476,9 @@ static void cycle_palette_backwards(unsigned index)
14711476
}
14721477
else if (configuration.dmg_palette == 4) {
14731478
for (unsigned i = 0; i < n_custom_palettes; i++) {
1479+
bool found = false;
14741480
if (strcmp(custom_palettes[i], configuration.dmg_palette_name) == 0) {
1481+
found = true;
14751482
if (i == 0) {
14761483
configuration.dmg_palette = 3;
14771484
}
@@ -1480,6 +1487,9 @@ static void cycle_palette_backwards(unsigned index)
14801487
}
14811488
break;
14821489
}
1490+
if (!found) {
1491+
configuration.dmg_palette = 3;
1492+
}
14831493
}
14841494
}
14851495
else {

0 commit comments

Comments
 (0)