Skip to content

Commit 5b88346

Browse files
committed
Work around an MSVCRT limitation, fixes cheat import on SDL Windows, fixes #716
1 parent 20e5e18 commit 5b88346

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Core/cheats.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,15 @@ const GB_cheat_t *GB_import_cheat(GB_gameboy_t *gb, const char *cheat, const cha
155155
uint8_t dummy;
156156
/* GameShark */
157157
if (strlen(cheat) == 8) {
158+
#ifdef _WIN32
159+
// The hh modifier is not supported on old MSVCRT, it's completely ignored
160+
uint32_t bank = 0;
161+
uint32_t value = 0;
162+
#pragma GCC diagnostic ignored "-Wformat"
163+
#else
158164
uint8_t bank;
159165
uint8_t value;
166+
#endif
160167
uint16_t address;
161168
if (sscanf(cheat, "%02hhx%02hhx%04hx%c", &bank, &value, &address, &dummy) == 3) {
162169
address = __builtin_bswap16(address);
@@ -178,8 +185,13 @@ const GB_cheat_t *GB_import_cheat(GB_gameboy_t *gb, const char *cheat, const cha
178185
stripped_cheat[7] = stripped_cheat[8];
179186
stripped_cheat[8] = 0;
180187

188+
#ifdef _WIN32
189+
uint32_t old_value = 0;
190+
uint32_t value = 0;
191+
#else
181192
uint8_t old_value;
182193
uint8_t value;
194+
#endif
183195
uint16_t address;
184196
if (strlen(stripped_cheat) != 8 && strlen(stripped_cheat) != 6) {
185197
return NULL;

0 commit comments

Comments
 (0)