Skip to content

Commit

Permalink
Fixed refactoring oopsie in Save.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Gericom committed Dec 9, 2023
1 parent e920bb8 commit 3aa32d7
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions code/core/arm9/source/Save/Save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ static DWORD sClusterTable[64];
// temporarily
extern FIL gFile;

#ifdef GBAR3_HICODE_CACHE_MAPPING

static u32* searchHiCode(const u32* signature, u32 romStart, u32 romEnd)
{
// todo: this doesn't work if the function lies on a cache block boundary
for (u32 i = romStart; i < romEnd; i += SDC_BLOCK_SIZE)
{
const void* block = sdc_getRomBlock(i);
u32* function = (u32*)mem_fastSearch16((const u32*)block, SDC_BLOCK_SIZE, signature);
if (function)
{
return (u32*)sdc_loadRomBlockForPatching(i + (u32)function - (u32)block);
}
}

return nullptr;
}

#endif

bool sav_tryPatchFunction(const u32* signature, u32 saveSwiNumber, void* patchFunction)
{
u32* function = (u32*)mem_fastSearch16((const u32*)ROM_LINEAR_DS_ADDRESS, ROM_LINEAR_SIZE, signature);
Expand All @@ -45,26 +65,6 @@ bool sav_tryPatchFunction(const u32* signature, u32 saveSwiNumber, void* patchFu
return true;
}

#ifdef GBAR3_HICODE_CACHE_MAPPING

static u32* searchHiCode(const u32* signature, u32 romStart, u32 romEnd)
{
// todo: this doesn't work if the function lies on a cache block boundary
for (u32 i = romStart; i < romEnd; i += SDC_BLOCK_SIZE)
{
const void* block = sdc_getRomBlock(i);
u32* function = (u32*)mem_fastSearch16((const u32*)block, SDC_BLOCK_SIZE, signature);
if (function)
{
return (u32*)sdc_loadRomBlockForPatching(i + (u32)function - (u32)block);
}
}

return nullptr;
}

#endif

static void loadSaveClusterMap(void)
{
sClusterTable[0] = sizeof(sClusterTable) / sizeof(DWORD);
Expand Down

0 comments on commit 3aa32d7

Please sign in to comment.