Revert "Implement persistent buffer in a more efficient way - HuCROM is"

This reverts commit 889921c3ab.
This commit is contained in:
twinaphex 2021-06-07 15:12:48 +02:00
parent 889921c3ab
commit 9f4435dd4b

View File

@ -32,9 +32,6 @@
std::string retro_base_directory;
static bool libretro_supports_persistent_buffer = false;
static bool libretro_supports_bitmasks = false;
#define MEDNAFEN_CORE_NAME_MODULE "pce_fast"
#define MEDNAFEN_CORE_NAME "Beetle PCE Fast"
#define MEDNAFEN_CORE_VERSION "v0.9.38.7"
@ -904,8 +901,7 @@ bool PCE_InitCD(void)
static int LoadCommon(void);
static void LoadCommonPre(void);
static int HuCLoad(bool persistent_data,
const uint8 *data, uint32 len, uint32 crc32)
static int HuCLoad(const uint8 *data, uint32 len, uint32 crc32)
{
int x;
uint32 crc = 0;
@ -925,16 +921,11 @@ static int HuCLoad(bool persistent_data,
IsPopulous = 0;
PCE_IsCD = 0;
if (persistent_data)
HuCROM = (uint8 *)data;
else
{
if(!(HuCROM = (uint8 *)malloc(m_len)))
return(0);
if(!(HuCROM = (uint8 *)malloc(m_len)))
return(0);
memset(HuCROM, 0xFF, m_len);
memcpy(HuCROM, data, (m_len < len) ? m_len : len);
}
memset(HuCROM, 0xFF, m_len);
memcpy(HuCROM, data, (m_len < len) ? m_len : len);
memset(ROMSpace, 0xFF, 0x88 * 8192 + 8192);
@ -1004,7 +995,7 @@ static int HuCLoad(bool persistent_data,
return(1);
}
static int Load(bool persistent_data, const uint8_t *data, size_t size)
static int Load(const uint8_t *data, size_t size)
{
int x;
uint32 headerlen = 0;
@ -1026,7 +1017,7 @@ static int Load(bool persistent_data, const uint8_t *data, size_t size)
uint32 crc = encoding_crc32(0, data + headerlen, size - headerlen);
HuCLoad(persistent_data, data + headerlen, size - headerlen, crc);
HuCLoad(data + headerlen, size - headerlen, crc);
if(crc == 0xfae0fc60)
OrderOfGriffonFix = true;
@ -1144,10 +1135,7 @@ static void Cleanup(void)
PCECD_Close();
if(HuCROM)
{
if (!libretro_supports_persistent_buffer)
free(HuCROM);
}
free(HuCROM);
HuCROM = NULL;
}
@ -1550,9 +1538,7 @@ static bool MDFNI_LoadCD(const char *path, const char *ext)
return true;
}
static bool MDFNI_LoadGame(
bool persistent_data,
const char *path, const char *ext,
static bool MDFNI_LoadGame(const char *path, const char *ext,
const uint8_t *data, size_t size)
{
MDFNFILE *GameFile = NULL;
@ -1593,7 +1579,7 @@ static bool MDFNI_LoadGame(
content_size = GET_FSIZE_PTR(GameFile);
}
if(Load(persistent_data, content_data, content_size) <= 0)
if(Load(content_data, content_size) <= 0)
goto error;
MDFN_LoadGameCheats(NULL);
@ -1623,6 +1609,8 @@ static retro_input_poll_t input_poll_cb;
static retro_input_state_t input_state_cb;
static double last_sound_rate = 0.0;
static bool libretro_supports_bitmasks = false;
static MDFN_Surface *surf = NULL;
static bool failed_init = false;
@ -2060,7 +2048,6 @@ bool retro_load_game(const struct retro_game_info *info)
/* Attempt to fetch extended game info */
if (environ_cb(RETRO_ENVIRONMENT_GET_GAME_INFO_EXT, &info_ext))
{
libretro_supports_persistent_buffer = true;
content_data = (const uint8_t *)info_ext->data;
content_size = info_ext->size;
@ -2078,8 +2065,6 @@ bool retro_load_game(const struct retro_game_info *info)
{
const char *ext = NULL;
libretro_supports_persistent_buffer = false;
if (!info || !info->path)
return false;
@ -2098,9 +2083,8 @@ bool retro_load_game(const struct retro_game_info *info)
check_variables(true);
if (!MDFNI_LoadGame(libretro_supports_persistent_buffer,
content_path, content_ext,
content_data, content_size))
if (!MDFNI_LoadGame(content_path, content_ext,
content_data, content_size))
return false;
surf = (MDFN_Surface*)calloc(1, sizeof(*surf));
@ -2198,7 +2182,6 @@ void retro_unload_game(void)
for(i = 0; i < CDInterfaces.size(); i++)
delete CDInterfaces[i];
CDInterfaces.clear();
libretro_supports_persistent_buffer = false;
}
static void update_input(void)