Core: Unbreak ValidSize limits.

Broken in bdd2029.
This commit is contained in:
Unknown W. Brackets 2021-03-28 19:42:29 -07:00
parent 233b0a87c1
commit bab9581901
2 changed files with 7 additions and 4 deletions

View File

@ -313,13 +313,13 @@ inline bool IsValidAddress(const u32 address) {
inline u32 ValidSize(const u32 address, const u32 requested_size) {
u32 max_size;
if ((address & 0x3E000000) == 0x08000000) {
max_size = 0x08000000 + g_MemorySize - (address & 0x3E000000);
max_size = 0x08000000 + g_MemorySize - (address & 0x3FFFFFFF);
} else if ((address & 0x3F800000) == 0x04000000) {
max_size = 0x04800000 - (address & 0x3F800000);
max_size = 0x04800000 - (address & 0x3FFFFFFF);
} else if ((address & 0xBFFF0000) == 0x00010000) {
max_size = 0x00014000 - (address & 0xBFFF0000);
max_size = 0x00014000 - (address & 0xBFFFFFFF);
} else if ((address & 0x3F000000) >= 0x08000000 && (address & 0x3F000000) < 0x08000000 + g_MemorySize) {
max_size = 0x08000000 + g_MemorySize - (address & 0x3F000000);
max_size = 0x08000000 + g_MemorySize - (address & 0x3FFFFFFF);
} else {
max_size = 0;
}

View File

@ -567,6 +567,8 @@ static bool TestMemMap() {
EXPECT_EQ_HEX(Memory::ValidSize(base, 0x40000001), range.size);
EXPECT_EQ_HEX(Memory::ValidSize(base, 0x20000001), range.size);
EXPECT_EQ_HEX(Memory::ValidSize(base, 0x10000001), range.size);
EXPECT_EQ_HEX(Memory::ValidSize(base + range.size - 0x10, 0x20000001), 0x10);
}
}
@ -607,6 +609,7 @@ TestItem availableTests[] = {
TEST_ITEM(ParseLBN),
TEST_ITEM(QuickTexHash),
TEST_ITEM(CLZ),
TEST_ITEM(MemMap),
TEST_ITEM(ShaderGenerators),
};