mirror of
https://github.com/LNH-team/pico-loader.git
synced 2026-06-02 09:16:49 +02:00
Refactored platform code to use interfaces for patch code with a special feature and improved patch code file names
This commit is contained in:
64
arm9/source/patches/platform/r4idsn/R4iDsnLoaderPlatform.h
Normal file
64
arm9/source/patches/platform/r4idsn/R4iDsnLoaderPlatform.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
#include "../acekard-common/IoRPGLoaderPlatform.h"
|
||||
#include "R4iDsnReadSdPatchCode.h"
|
||||
#include "R4iDsnSdReadSectorPatchCode.h"
|
||||
#include "R4iDsnWriteSdPatchCode.h"
|
||||
|
||||
/// @brief Implementation of LoaderPlatform for the r4idsn.com flashcard.
|
||||
class R4iDsnLoaderPlatform : public IoRpgLoaderPlatform
|
||||
{
|
||||
private:
|
||||
enum
|
||||
{
|
||||
IORPG_CMD_SDIO_BYTE = 0xAB
|
||||
};
|
||||
|
||||
public:
|
||||
R4iDsnLoaderPlatform() : IoRpgLoaderPlatform(IORPG_CMD_SDIO_BYTE) { }
|
||||
|
||||
const IReadSectorsPatchCode* CreateSdReadPatchCode(
|
||||
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
|
||||
{
|
||||
return patchCodeCollection.GetOrAddSharedPatchCode([&]
|
||||
{
|
||||
auto* waitForStatePatchCode = patchCodeCollection.GetOrAddSharedPatchCode([&]
|
||||
{
|
||||
return new IoRpgSdWaitForStatePatchCode(patchHeap);
|
||||
});
|
||||
return new R4iDsnReadSdPatchCode(patchHeap,
|
||||
patchCodeCollection.GetOrAddSharedPatchCode([&]
|
||||
{
|
||||
return new IoRpgSendSdioCommandPatchCode(patchHeap);
|
||||
}),
|
||||
patchCodeCollection.GetOrAddSharedPatchCode([&]
|
||||
{
|
||||
return new R4iDsnSdReadSectorPatchCode(patchHeap, waitForStatePatchCode);
|
||||
}),
|
||||
waitForStatePatchCode);
|
||||
});
|
||||
}
|
||||
|
||||
const IWriteSectorsPatchCode* CreateSdWritePatchCode(
|
||||
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
|
||||
{
|
||||
return patchCodeCollection.GetOrAddSharedPatchCode([&]
|
||||
{
|
||||
return new R4iDsnWriteSdPatchCode(patchHeap,
|
||||
patchCodeCollection.GetOrAddSharedPatchCode([&]
|
||||
{
|
||||
return new IoRpgSendSdioCommandPatchCode(patchHeap);
|
||||
}),
|
||||
patchCodeCollection.GetOrAddSharedPatchCode([&]
|
||||
{
|
||||
return new IoRpgSdWaitForStatePatchCode(patchHeap);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
void PatchSdscShift(void) const override
|
||||
{
|
||||
r4idsn_readSd_sdsc_shift = THUMB_MOVS_REG(THUMB_R4, THUMB_R0);
|
||||
r4idsn_writeSd_sdsc_shift = THUMB_MOVS_REG(THUMB_R7, THUMB_R0);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user