Fix high/low ram watermark tracking
Fixes negative sized memset calls and some wrap around bugs. Fixes at least a couple of games.
This commit is contained in:
parent
1feab54699
commit
d649fe96cb
|
@ -54,10 +54,10 @@ u8 *ram_translation_ptr = ram_translation_cache;
|
||||||
#endif
|
#endif
|
||||||
/* Note, see stub files for more cache definitions */
|
/* Note, see stub files for more cache definitions */
|
||||||
|
|
||||||
u32 iwram_code_min = 0xFFFFFFFF;
|
u32 iwram_code_min = ~0U;
|
||||||
u32 iwram_code_max = 0xFFFFFFFF;
|
u32 iwram_code_max = 0U;
|
||||||
u32 ewram_code_min = 0xFFFFFFFF;
|
u32 ewram_code_min = ~0U;
|
||||||
u32 ewram_code_max = 0xFFFFFFFF;
|
u32 ewram_code_max = 0U;
|
||||||
|
|
||||||
|
|
||||||
u32 *rom_branch_hash[ROM_BRANCH_HASH_SIZE];
|
u32 *rom_branch_hash[ROM_BRANCH_HASH_SIZE];
|
||||||
|
@ -3035,17 +3035,9 @@ s32 translate_block_arm(u32 pc, translation_region_type
|
||||||
{
|
{
|
||||||
case TRANSLATION_REGION_RAM:
|
case TRANSLATION_REGION_RAM:
|
||||||
if (pc >= 0x3000000)
|
if (pc >= 0x3000000)
|
||||||
{
|
iwram_code_min = MIN(pc & 0x7FFF, iwram_code_min);
|
||||||
if((pc < iwram_code_min) || (iwram_code_min == 0xFFFFFFFF))
|
else if (pc >= 0x2000000)
|
||||||
iwram_code_min = pc;
|
ewram_code_min = MIN(pc & 0x3FFFF, ewram_code_min);
|
||||||
}
|
|
||||||
else
|
|
||||||
|
|
||||||
if(pc >= 0x2000000)
|
|
||||||
{
|
|
||||||
if((pc < ewram_code_min) || (ewram_code_min == 0xFFFFFFFF))
|
|
||||||
ewram_code_min = pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
translation_ptr = ram_translation_ptr;
|
translation_ptr = ram_translation_ptr;
|
||||||
translation_cache_limit =
|
translation_cache_limit =
|
||||||
|
@ -3182,17 +3174,9 @@ s32 translate_block_arm(u32 pc, translation_region_type
|
||||||
{
|
{
|
||||||
case TRANSLATION_REGION_RAM:
|
case TRANSLATION_REGION_RAM:
|
||||||
if (pc >= 0x3000000)
|
if (pc >= 0x3000000)
|
||||||
{
|
iwram_code_max = MAX(pc & 0x7FFF, iwram_code_max);
|
||||||
if((pc > iwram_code_max) || (iwram_code_max == 0xFFFFFFFF))
|
else if (pc >= 0x2000000)
|
||||||
iwram_code_max = pc;
|
ewram_code_max = MAX(pc & 0x3FFFF, ewram_code_max);
|
||||||
}
|
|
||||||
else
|
|
||||||
|
|
||||||
if(pc >= 0x2000000)
|
|
||||||
{
|
|
||||||
if((pc > ewram_code_max) || (ewram_code_max == 0xFFFFFFFF))
|
|
||||||
ewram_code_max = pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
ram_translation_ptr = translation_ptr;
|
ram_translation_ptr = translation_ptr;
|
||||||
break;
|
break;
|
||||||
|
@ -3248,17 +3232,9 @@ s32 translate_block_thumb(u32 pc, translation_region_type
|
||||||
{
|
{
|
||||||
case TRANSLATION_REGION_RAM:
|
case TRANSLATION_REGION_RAM:
|
||||||
if (pc >= 0x3000000)
|
if (pc >= 0x3000000)
|
||||||
{
|
iwram_code_min = MIN(pc & 0x7FFF, iwram_code_min);
|
||||||
if((pc < iwram_code_min) || (iwram_code_min == 0xFFFFFFFF))
|
else if (pc >= 0x2000000)
|
||||||
iwram_code_min = pc;
|
ewram_code_min = MIN(pc & 0x3FFFF, ewram_code_min);
|
||||||
}
|
|
||||||
else
|
|
||||||
|
|
||||||
if(pc >= 0x2000000)
|
|
||||||
{
|
|
||||||
if((pc < ewram_code_min) || (ewram_code_min == 0xFFFFFFFF))
|
|
||||||
ewram_code_min = pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
translation_ptr = ram_translation_ptr;
|
translation_ptr = ram_translation_ptr;
|
||||||
translation_cache_limit =
|
translation_cache_limit =
|
||||||
|
@ -3387,17 +3363,9 @@ s32 translate_block_thumb(u32 pc, translation_region_type
|
||||||
{
|
{
|
||||||
case TRANSLATION_REGION_RAM:
|
case TRANSLATION_REGION_RAM:
|
||||||
if (pc >= 0x3000000)
|
if (pc >= 0x3000000)
|
||||||
{
|
iwram_code_max = MAX(pc & 0x7FFF, iwram_code_max);
|
||||||
if((pc > iwram_code_max) || (iwram_code_max == 0xFFFFFFFF))
|
else if (pc >= 0x2000000)
|
||||||
iwram_code_max = pc;
|
ewram_code_max = MAX(pc & 0x3FFFF, ewram_code_max);
|
||||||
}
|
|
||||||
else
|
|
||||||
|
|
||||||
if(pc >= 0x2000000)
|
|
||||||
{
|
|
||||||
if((pc > ewram_code_max) || (ewram_code_max == 0xFFFFFFFF))
|
|
||||||
ewram_code_max = pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
ram_translation_ptr = translation_ptr;
|
ram_translation_ptr = translation_ptr;
|
||||||
break;
|
break;
|
||||||
|
@ -3432,24 +3400,16 @@ void flush_translation_cache_ram(void)
|
||||||
|
|
||||||
// Proceed to clean the SMC area if needed
|
// Proceed to clean the SMC area if needed
|
||||||
// (also try to memset as little as possible for performance)
|
// (also try to memset as little as possible for performance)
|
||||||
if(iwram_code_min != 0xFFFFFFFF)
|
if(iwram_code_max)
|
||||||
{
|
memset(&iwram[iwram_code_min], 0, iwram_code_max - iwram_code_min);
|
||||||
iwram_code_min &= 0x7FFF;
|
|
||||||
iwram_code_max &= 0x7FFF;
|
|
||||||
memset(iwram + iwram_code_min, 0, iwram_code_max - iwram_code_min);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ewram_code_min != 0xFFFFFFFF)
|
if(ewram_code_max)
|
||||||
{
|
|
||||||
ewram_code_min &= 0x3FFFF;
|
|
||||||
ewram_code_max &= 0x3FFFF;
|
|
||||||
memset(&ewram[0x40000 + ewram_code_min], 0, ewram_code_max - ewram_code_min);
|
memset(&ewram[0x40000 + ewram_code_min], 0, ewram_code_max - ewram_code_min);
|
||||||
}
|
|
||||||
|
|
||||||
iwram_code_min = 0xFFFFFFFF;
|
iwram_code_min = ~0U;
|
||||||
iwram_code_max = 0xFFFFFFFF;
|
iwram_code_max = 0U;
|
||||||
ewram_code_min = 0xFFFFFFFF;
|
ewram_code_min = ~0U;
|
||||||
ewram_code_max = 0xFFFFFFFF;
|
ewram_code_max = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
void flush_translation_cache_rom(void)
|
void flush_translation_cache_rom(void)
|
||||||
|
@ -3465,9 +3425,9 @@ void init_caches(void)
|
||||||
/* Ensure we wipe everything including the SMC mirrors */
|
/* Ensure we wipe everything including the SMC mirrors */
|
||||||
flush_translation_cache_rom();
|
flush_translation_cache_rom();
|
||||||
ewram_code_min = 0;
|
ewram_code_min = 0;
|
||||||
ewram_code_max = 0x3FFFF;
|
ewram_code_max = 0x40000;
|
||||||
iwram_code_min = 0;
|
iwram_code_min = 0;
|
||||||
iwram_code_max = 0x7FFF;
|
iwram_code_max = 0x8000;
|
||||||
flush_translation_cache_ram();
|
flush_translation_cache_ram();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue