Account for spurious CARDi_ReadCard match in Shaberu! DS Oryouri Navi (Japan) (rev 0 and 1)

This commit is contained in:
Gericom
2026-01-10 11:52:23 +01:00
parent 9f2dff3967
commit cd007d6505
4 changed files with 58 additions and 40 deletions

View File

@@ -39,6 +39,7 @@ void* Arm7Patcher::ApplyPatches(const LoaderPlatform* loaderPlatform) const
(romHeader->IsTwlRom()) ? twlRomHeader->arm7iSize : 0, (romHeader->IsTwlRom()) ? twlRomHeader->arm7iSize : 0,
sdkVersion, sdkVersion,
romHeader->gameCode, romHeader->gameCode,
romHeader->softwareVersion,
loaderPlatform loaderPlatform
}; };
void* patchSpaceStart = nullptr; void* patchSpaceStart = nullptr;

View File

@@ -116,6 +116,7 @@ void Arm9Patcher::ApplyPatches(const LoaderPlatform* loaderPlatform, const ApLis
arm9iSize, arm9iSize,
sdkVersion, sdkVersion,
romHeader->gameCode, romHeader->gameCode,
romHeader->softwareVersion,
loaderPlatform loaderPlatform
}; };
PatchCollection patchCollection; PatchCollection patchCollection;

View File

@@ -11,9 +11,9 @@ class PatchContext
{ {
public: public:
PatchContext(void* data, u32 dataSize, void* twlData, u32 twlDataSize, PatchContext(void* data, u32 dataSize, void* twlData, u32 twlDataSize,
SdkVersion sdkVersion, u32 gameCode, const LoaderPlatform* loaderPlatform) SdkVersion sdkVersion, u32 gameCode, u8 gameRevision, const LoaderPlatform* loaderPlatform)
: _data(data), _dataSize(dataSize), _twlData(twlData), _twlDataSize(twlDataSize) : _data(data), _dataSize(dataSize), _twlData(twlData), _twlDataSize(twlDataSize)
, _sdkVersion(sdkVersion), _gameCode(gameCode), _loaderPlatform(loaderPlatform) { } , _sdkVersion(sdkVersion), _gameCode(gameCode), _gameRevision(gameRevision), _loaderPlatform(loaderPlatform) { }
/// @brief Tries to find the given \p pattern of the given \p byteLength in the ntr region. /// @brief Tries to find the given \p pattern of the given \p byteLength in the ntr region.
/// @param pattern The pattern to find. /// @param pattern The pattern to find.
@@ -43,6 +43,10 @@ public:
/// @return The game code of the rom that is being patched. /// @return The game code of the rom that is being patched.
constexpr u32 GetGameCode() const { return _gameCode; } constexpr u32 GetGameCode() const { return _gameCode; }
/// @brief Returns the game revision of the rom that is being patched.
/// @return The game revision of the rom that is being patched.
constexpr u8 GetGameRevision() const { return _gameRevision; }
/// @brief Returns the loader platform that should be used for the patches. /// @brief Returns the loader platform that should be used for the patches.
/// @return The loader platform that should be used for the patches. /// @return The loader platform that should be used for the patches.
constexpr const LoaderPlatform* GetLoaderPlatform() { return _loaderPlatform; } constexpr const LoaderPlatform* GetLoaderPlatform() { return _loaderPlatform; }
@@ -54,6 +58,7 @@ private:
u32 _twlDataSize; u32 _twlDataSize;
SdkVersion _sdkVersion; SdkVersion _sdkVersion;
u32 _gameCode; u32 _gameCode;
u8 _gameRevision;
PatchHeap _patchHeap; PatchHeap _patchHeap;
PatchCodeCollection _patchCodeCollection; PatchCodeCollection _patchCodeCollection;

View File

@@ -6,6 +6,7 @@
#include "patches/arm9/RomOffsetToSdSectorPatchCode.h" #include "patches/arm9/RomOffsetToSdSectorPatchCode.h"
#include "patches/OffsetToSectorRemapPatchCode.h" #include "patches/OffsetToSectorRemapPatchCode.h"
#include "patches/arm9/FixCp15Asm.h" #include "patches/arm9/FixCp15Asm.h"
#include "gameCode.h"
#include "CardiReadCardPatchAsm.h" #include "CardiReadCardPatchAsm.h"
#include "CardiReadCardPatch.h" #include "CardiReadCardPatch.h"
@@ -29,6 +30,15 @@ void CardiReadCardPatch::TryPattern(PatchContext& patchContext, const u32* patte
} }
bool CardiReadCardPatch::FindPatchTarget(PatchContext& patchContext) bool CardiReadCardPatch::FindPatchTarget(PatchContext& patchContext)
{
if (patchContext.GetGameCode() == GAMECODE("A4VJ"))
{
// Shaberu! DS Oryouri Navi (Japan) has a spurious match
_foundPattern = sCARDiReadCardPatternUnknown;
_thumb = false;
_cardiReadCard = (u32*)(patchContext.GetGameRevision() == 0 ? 0x020DBD5C : 0x020DBD4C);
}
else
{ {
if (patchContext.GetSdkVersion() >= 0x4017530) if (patchContext.GetSdkVersion() >= 0x4017530)
TryPattern(patchContext, sCARDiReadCardPatternSdk4017530, sizeof(sCARDiReadCardPatternSdk4017530)); TryPattern(patchContext, sCARDiReadCardPatternSdk4017530, sizeof(sCARDiReadCardPatternSdk4017530));
@@ -84,6 +94,7 @@ bool CardiReadCardPatch::FindPatchTarget(PatchContext& patchContext)
if (_cardiReadCard) if (_cardiReadCard)
_thumb = true; _thumb = true;
} }
}
if (_cardiReadCard) if (_cardiReadCard)
{ {