diff --git a/desmume/src/cheatSystem.cpp b/desmume/src/cheatSystem.cpp index a0358f5d8..4e5725c66 100644 --- a/desmume/src/cheatSystem.cpp +++ b/desmume/src/cheatSystem.cpp @@ -557,6 +557,11 @@ BOOL CHEATS::save() for (int t = 0; t < list[i].num; t++) { char buf2[10] = { 0 }; + if (list[i].type == 0) + { + list[i].code[t][0] &= 0x0FFFFFFF; + list[i].code[t][0] |= (list[i].size << 28); + } sprintf(buf2, "%08X", list[i].code[t][0]); strcat(buf, buf2); sprintf(buf2, "%08X", list[i].code[t][1]); @@ -656,6 +661,11 @@ BOOL CHEATS::load() strncpy(tmp_buf, (char*)(tmp_code + (i*16)), 8); sscanf_s(tmp_buf, "%x", &tmp_cht.code[i][0]); + + if (tmp_cht.type == 0) + { + tmp_cht.size = std::min(3, ((tmp_cht.code[i][0] & 0xF0000000) >> 28)); + } strncpy(tmp_buf, (char*)(tmp_code + (i*16) + 8), 8); sscanf_s(tmp_buf, "%x", &tmp_cht.code[i][1]); diff --git a/tools/cheatsConverter/src/convert.cpp b/tools/cheatsConverter/src/convert.cpp index 508db0c38..063e90d70 100644 --- a/tools/cheatsConverter/src/convert.cpp +++ b/tools/cheatsConverter/src/convert.cpp @@ -87,6 +87,11 @@ bool save(char *filename) for (int t = 0; t < list[i].num; t++) { char buf2[10] = { 0 }; + if (list[i].type == 0) + { + list[i].hi[t] &= 0x0FFFFFFF; + list[i].hi[t] |= (list[i].size << 28); + } sprintf(buf2, "%08X", list[i].hi[t]); strcat(buf, buf2); sprintf(buf2, "%08X", list[i].lo[t]);