Libretro: Better auto detection of save types when not found in gbaover
This commit is contained in:
parent
7337341166
commit
c1f281b7ba
|
@ -182,53 +182,65 @@ uint8_t *utilLoad(const char *file, bool (*accept)(const char *), uint8_t *data,
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
void utilGBAFindSave(const uint8_t *data, const int size)
|
void utilGBAFindSave(const int size)
|
||||||
{
|
{
|
||||||
uint32_t *p = (uint32_t *)data;
|
bool rtcFound_ = false;
|
||||||
uint32_t *end = (uint32_t *)(data + size);
|
int detectedSaveType = 0;
|
||||||
int saveType = 0;
|
int flashSize_ = 0x8000;
|
||||||
int flashSize = 0x10000;
|
uint32_t *p = (uint32_t *)&rom[0];
|
||||||
bool rtcFound = false;
|
uint32_t *end = (uint32_t *)(&rom[0] + size);
|
||||||
|
|
||||||
while(p < end) {
|
while (p < end) {
|
||||||
uint32_t d = READ32LE(p);
|
uint32_t d = READ32LE(p);
|
||||||
|
|
||||||
if(d == 0x52504545) {
|
if (d == 0x52504545) {
|
||||||
if(memcmp(p, "EEPROM_", 7) == 0) {
|
if (memcmp(p, "EEPROM_", 7) == 0) {
|
||||||
if(saveType == 0)
|
if (detectedSaveType == 0 || detectedSaveType == 4) {
|
||||||
saveType = 3;
|
detectedSaveType = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (d == 0x4D415253) {
|
} else if (d == 0x4D415253) {
|
||||||
if(memcmp(p, "SRAM_", 5) == 0) {
|
if (memcmp(p, "SRAM_", 5) == 0) {
|
||||||
if(saveType == 0)
|
if (detectedSaveType == 0 || detectedSaveType == 1
|
||||||
saveType = 1;
|
|| detectedSaveType == 4) {
|
||||||
|
detectedSaveType = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (d == 0x53414C46) {
|
} else if (d == 0x53414C46) {
|
||||||
if(memcmp(p, "FLASH1M_", 8) == 0) {
|
if (memcmp(p, "FLASH1M_", 8) == 0) {
|
||||||
if(saveType == 0) {
|
if (detectedSaveType == 0) {
|
||||||
saveType = 2;
|
detectedSaveType = 3;
|
||||||
flashSize = 0x20000;
|
flashSize_ = 0x20000;
|
||||||
}
|
}
|
||||||
} else if(memcmp(p, "FLASH", 5) == 0) {
|
} else if (memcmp(p, "FLASH512_", 9) == 0) {
|
||||||
if(saveType == 0) {
|
if (detectedSaveType == 0) {
|
||||||
saveType = 2;
|
detectedSaveType = 3;
|
||||||
flashSize = 0x10000;
|
flashSize_ = 0x10000;
|
||||||
|
}
|
||||||
|
} else if (memcmp(p, "FLASH", 5) == 0) {
|
||||||
|
if (detectedSaveType == 0) {
|
||||||
|
detectedSaveType = 4;
|
||||||
|
flashSize_ = 0x10000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (d == 0x52494953) {
|
} else if (d == 0x52494953) {
|
||||||
if(memcmp(p, "SIIRTC_V", 8) == 0)
|
if (memcmp(p, "SIIRTC_V", 8) == 0) {
|
||||||
rtcFound = true;
|
rtcFound_ = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
// if no matches found, then set it to NONE
|
// if no matches found, then set it to NONE
|
||||||
if(saveType == 0) {
|
if (detectedSaveType == 0) {
|
||||||
saveType = 5;
|
detectedSaveType = 5;
|
||||||
|
}
|
||||||
|
if (detectedSaveType == 4) {
|
||||||
|
detectedSaveType = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
rtcEnable(rtcFound);
|
cpuSaveType = detectedSaveType;
|
||||||
cpuSaveType = saveType;
|
rtcEnabled = rtcFound_;
|
||||||
flashSetSize(flashSize);
|
flashSize = flashSize_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void utilUpdateSystemColorMaps(bool lcd)
|
void utilUpdateSystemColorMaps(bool lcd)
|
||||||
|
|
|
@ -43,7 +43,6 @@ static retro_environment_t environ_cb;
|
||||||
|
|
||||||
static float sndFiltering = 0.5f;
|
static float sndFiltering = 0.5f;
|
||||||
static bool sndInterpolation = true;
|
static bool sndInterpolation = true;
|
||||||
static bool enableRtc = false;
|
|
||||||
static bool can_dupe = false;
|
static bool can_dupe = false;
|
||||||
int emulating = 0;
|
int emulating = 0;
|
||||||
static int retropad_layout = 0;
|
static int retropad_layout = 0;
|
||||||
|
@ -408,15 +407,32 @@ static const ini_t gbaover[256] = {
|
||||||
{"Zoku Bokura no Taiyou - Taiyou Shounen Django (Japan)", "U32J", 0, 0, 1, 0, 0}
|
{"Zoku Bokura no Taiyou - Taiyou Shounen Django (Japan)", "U32J", 0, 0, 1, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int romSize = 0;
|
||||||
|
|
||||||
static void load_image_preferences(void)
|
static void load_image_preferences(void)
|
||||||
{
|
{
|
||||||
|
const char *savetype[] = {
|
||||||
|
"AUTO",
|
||||||
|
"EEPROM",
|
||||||
|
"SRAM",
|
||||||
|
"FLASH",
|
||||||
|
"SENSOR+EEPROM",
|
||||||
|
"NONE"
|
||||||
|
};
|
||||||
|
|
||||||
char buffer[5];
|
char buffer[5];
|
||||||
|
|
||||||
buffer[0] = rom[0xac];
|
buffer[0] = rom[0xac];
|
||||||
buffer[1] = rom[0xad];
|
buffer[1] = rom[0xad];
|
||||||
buffer[2] = rom[0xae];
|
buffer[2] = rom[0xae];
|
||||||
buffer[3] = rom[0xaf];
|
buffer[3] = rom[0xaf];
|
||||||
buffer[4] = 0;
|
buffer[4] = 0;
|
||||||
|
|
||||||
|
cpuSaveType = 0;
|
||||||
|
flashSize = 0x8000;
|
||||||
|
rtcEnabled = false;
|
||||||
|
mirroringEnable = false;
|
||||||
|
|
||||||
if (log_cb)
|
if (log_cb)
|
||||||
log_cb(RETRO_LOG_INFO, "GameID in ROM is: %s\n", buffer);
|
log_cb(RETRO_LOG_INFO, "GameID in ROM is: %s\n", buffer);
|
||||||
|
|
||||||
|
@ -435,33 +451,30 @@ static void load_image_preferences(void)
|
||||||
if (log_cb)
|
if (log_cb)
|
||||||
log_cb(RETRO_LOG_INFO, "Found ROM in vba-over list.\n");
|
log_cb(RETRO_LOG_INFO, "Found ROM in vba-over list.\n");
|
||||||
|
|
||||||
enableRtc = gbaover[found_no].rtcEnabled;
|
rtcEnabled = gbaover[found_no].rtcEnabled;
|
||||||
|
|
||||||
if (gbaover[found_no].flashSize != 0)
|
if (gbaover[found_no].flashSize != 0)
|
||||||
flashSize = gbaover[found_no].flashSize;
|
flashSize = gbaover[found_no].flashSize;
|
||||||
else
|
|
||||||
flashSize = 65536;
|
|
||||||
|
|
||||||
cpuSaveType = gbaover[found_no].saveType;
|
cpuSaveType = gbaover[found_no].saveType;
|
||||||
|
|
||||||
mirroringEnable = gbaover[found_no].mirroringEnabled;
|
mirroringEnable = gbaover[found_no].mirroringEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!cpuSaveType/* && !found*/) {
|
||||||
|
utilGBAFindSave(romSize);
|
||||||
|
}
|
||||||
|
|
||||||
if (log_cb) {
|
if (log_cb) {
|
||||||
log_cb(RETRO_LOG_INFO, "RTC = %d.\n", enableRtc);
|
log_cb(RETRO_LOG_INFO, "RTC = %d.\n", rtcEnabled);
|
||||||
log_cb(RETRO_LOG_INFO, "flashSize = %d.\n", flashSize);
|
log_cb(RETRO_LOG_INFO, "flashSize = %d.\n", flashSize);
|
||||||
log_cb(RETRO_LOG_INFO, "cpuSaveType = %d.\n", cpuSaveType);
|
log_cb(RETRO_LOG_INFO, "cpuSaveType = %s.\n", savetype[cpuSaveType]);
|
||||||
log_cb(RETRO_LOG_INFO, "mirroringEnable = %d.\n", mirroringEnable);
|
log_cb(RETRO_LOG_INFO, "mirroringEnable = %d.\n", mirroringEnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gba_init(void)
|
static void gba_init(void)
|
||||||
{
|
{
|
||||||
cpuSaveType = 0;
|
|
||||||
flashSize = 0x10000;
|
|
||||||
enableRtc = false;
|
|
||||||
mirroringEnable = false;
|
|
||||||
|
|
||||||
#ifdef FRONTEND_SUPPORTS_RGB565
|
#ifdef FRONTEND_SUPPORTS_RGB565
|
||||||
systemColorDepth = 16;
|
systemColorDepth = 16;
|
||||||
systemRedShift = 11;
|
systemRedShift = 11;
|
||||||
|
@ -483,9 +496,8 @@ static void gba_init(void)
|
||||||
if (flashSize == 0x10000 || flashSize == 0x20000)
|
if (flashSize == 0x10000 || flashSize == 0x20000)
|
||||||
flashSetSize(flashSize);
|
flashSetSize(flashSize);
|
||||||
|
|
||||||
rtcEnabled = enableRtc;
|
rtcEnable(rtcEnabled);
|
||||||
if (enableRtc)
|
rtcEnableRumble(!rtcEnabled);
|
||||||
rtcEnable(enableRtc);
|
|
||||||
|
|
||||||
doMirroring(mirroringEnable);
|
doMirroring(mirroringEnable);
|
||||||
|
|
||||||
|
@ -496,8 +508,6 @@ static void gba_init(void)
|
||||||
|
|
||||||
CPUReset();
|
CPUReset();
|
||||||
|
|
||||||
soundReset();
|
|
||||||
|
|
||||||
uint8_t* state_buf = (uint8_t*)malloc(2000000);
|
uint8_t* state_buf = (uint8_t*)malloc(2000000);
|
||||||
serialize_size = CPUWriteState(state_buf, 2000000);
|
serialize_size = CPUWriteState(state_buf, 2000000);
|
||||||
free(state_buf);
|
free(state_buf);
|
||||||
|
@ -887,7 +897,7 @@ bool retro_load_game(const struct retro_game_info *game)
|
||||||
update_variables();
|
update_variables();
|
||||||
update_input_descriptors();
|
update_input_descriptors();
|
||||||
|
|
||||||
int romSize = CPULoadRomData((const char*)game->data, game->size);
|
romSize = CPULoadRomData((const char*)game->data, game->size);
|
||||||
if (!romSize)
|
if (!romSize)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue