From 231f14a783031204a394ddee110de5ed248de489 Mon Sep 17 00:00:00 2001 From: Gericom Date: Fri, 2 Jan 2026 15:18:45 +0100 Subject: [PATCH] Refactored platform code to use interfaces for patch code with a special feature and improved patch code file names --- arm9/source/main.cpp | 4 +- arm9/source/patches/ISectorRemapPatchCode.h | 10 +++++ ...apAsm.h => OffsetToSectorRemapPatchCode.h} | 8 ++-- ...apAsm.s => OffsetToSectorRemapPatchCode.s} | 0 ...rAsm.h => SaveOffsetToSdSectorPatchCode.h} | 7 ++-- ...rAsm.s => SaveOffsetToSdSectorPatchCode.s} | 0 arm9/source/patches/SectorRemapPatchCode.h | 11 ------ .../{ReadSaveAsm.h => ReadSavePatchCode.h} | 12 +++--- .../{ReadSaveAsm.s => ReadSavePatchCode.s} | 0 ...{VerifySaveAsm.h => VerifySavePatchCode.h} | 12 +++--- ...{VerifySaveAsm.s => VerifySavePatchCode.s} | 0 .../{WriteSaveAsm.h => WriteSavePatchCode.h} | 16 ++++---- .../{WriteSaveAsm.s => WriteSavePatchCode.s} | 0 .../arm7/sdk2to4/CardiTaskThreadPatch.cpp | 8 ++-- .../arm7/sdk5/CardiDoTaskFromArm9Patch.cpp | 8 ++-- .../arm7/sdk5/Sdk5DsiSdCardRedirectPatchAsm.h | 14 +++---- ...Asm.s => Sdk5DsiSdCardRedirectPatchCode.s} | 0 .../patches/arm9/CardiReadRomIdCorePatch.cpp | 2 +- ...tchAsm.h => CardiReadRomIdCorePatchCode.h} | 0 ...tchAsm.s => CardiReadRomIdCorePatchCode.s} | 0 .../NandSave/FaceTrainingNandSavePatch.cpp | 6 +-- .../NandSave/JamWithTheBandNandSavePatch.cpp | 6 +-- .../NandSave/NintendoDSGuideNandSavePatch.cpp | 6 +-- ...dNandSaveAsm.h => ReadNandSavePatchCode.h} | 14 +++---- ...dNandSaveAsm.s => ReadNandSavePatchCode.s} | 0 .../NandSave/WarioWareDiyNandSavePatch.cpp | 6 +-- ...NandSaveAsm.h => WriteNandSavePatchCode.h} | 14 +++---- ...NandSaveAsm.s => WriteNandSavePatchCode.s} | 0 .../patches/arm9/OSResetSystemPatch.cpp | 6 +-- ...temPatchAsm.h => OSResetSystemPatchCode.h} | 6 +-- ...temPatchAsm.s => OSResetSystemPatchCode.s} | 0 .../arm9/PokemonDownloaderArm9Patch.cpp | 2 +- ...Asm.h => PokemonDownloaderArm9PatchCode.h} | 8 ++-- ...Asm.s => PokemonDownloaderArm9PatchCode.s} | 0 ...orAsm.h => RomOffsetToSdSectorPatchCode.h} | 7 ++-- ...orAsm.s => RomOffsetToSdSectorPatchCode.s} | 0 .../arm9/sdk2to4/CardiReadCardPatch.cpp | 8 ++-- ...aPatchAsm.h => CardiSetCardDmaPatchCode.h} | 15 ++++---- ...aPatchAsm.s => CardiSetCardDmaPatchCode.s} | 0 .../arm9/sdk2to4/CardiTryReadCardDmaPatch.cpp | 3 +- .../arm9/sdk5/CardiReadRomWithCpuPatch.cpp | 8 ++-- ...PatchCode.h => IReadSectorsDmaPatchCode.h} | 16 ++++---- .../patches/platform/IReadSectorsPatchCode.h | 17 +++++++++ .../patches/platform/IWriteSectorsPatchCode.h | 17 +++++++++ arm9/source/patches/platform/LoaderPlatform.h | 23 ++++++------ .../platform/LoaderPlatformFactory.cpp | 20 +++++----- .../source/patches/platform/SdReadPatchCode.h | 19 ---------- .../patches/platform/SdWritePatchCode.h | 19 ---------- .../platform/ace3ds/Ace3DSLoaderPlatform.h | 13 +++---- .../ace3ds/Ace3DSReadSdDmaPatchCode.h | 31 ++++++++++++++++ ...dSdDmaAsm.s => Ace3DSReadSdDmaPatchCode.s} | 0 .../platform/ace3ds/Ace3DSReadSdPatchCode.h | 20 ++++++++++ ...3dsReadSdAsm.s => Ace3DSReadSdPatchCode.s} | 0 .../platform/ace3ds/Ace3DSWriteSdPatchCode.h | 20 ++++++++++ ...sWriteSdAsm.s => Ace3DSWriteSdPatchCode.s} | 0 .../patches/platform/ace3ds/ace3dsReadSdAsm.h | 19 ---------- .../platform/ace3ds/ace3dsReadSdDmaAsm.h | 30 --------------- .../platform/ace3ds/ace3dsWriteSdAsm.h | 19 ---------- ...{ioRPGDefinitions.h => IoRpgDefinitions.h} | 3 +- ...erPlatform.cpp => IoRpgLoaderPlatform.cpp} | 12 +++--- ...LoaderPlatform.h => IoRpgLoaderPlatform.h} | 11 +++--- ...teAsm.h => IoRpgSdWaitForStatePatchCode.h} | 5 ++- ...teAsm.s => IoRpgSdWaitForStatePatchCode.s} | 0 ...dAsm.h => IoRpgSendSdioCommandPatchCode.h} | 5 ++- ...dAsm.s => IoRpgSendSdioCommandPatchCode.s} | 0 ...K2LoaderPlatform.h => Ak2LoaderPlatform.h} | 31 ++++++++-------- .../patches/platform/ak2/Ak2ReadSdPatchCode.h | 37 +++++++++++++++++++ .../{ak2ReadSdAsm.s => Ak2ReadSdPatchCode.s} | 0 ...SectorAsm.h => Ak2SdReadSectorPatchCode.h} | 8 ++-- ...SectorAsm.s => Ak2SdReadSectorPatchCode.s} | 0 .../platform/ak2/Ak2WriteSdPatchCode.h | 33 +++++++++++++++++ ...{ak2WriteSdAsm.s => Ak2WriteSdPatchCode.s} | 0 .../patches/platform/ak2/ak2ReadSdAsm.h | 36 ------------------ .../patches/platform/ak2/ak2WriteSdAsm.h | 32 ---------------- ...LoaderPlatform.h => AkRpgLoaderPlatform.h} | 29 +++++++-------- .../platform/akrpg/AkRpgReadSdPatchCode.h | 37 +++++++++++++++++++ ...krpgReadSdAsm.s => AkRpgReadSdPatchCode.s} | 0 ...ctorAsm.h => AkRpgSdReadSectorPatchCode.h} | 8 ++-- ...ctorAsm.s => AkRpgSdReadSectorPatchCode.s} | 0 .../platform/akrpg/AkRpgWriteSdPatchCode.h | 33 +++++++++++++++++ ...pgWriteSdAsm.s => AkRpgWriteSdPatchCode.s} | 0 .../patches/platform/akrpg/akrpgReadSdAsm.h | 36 ------------------ .../patches/platform/akrpg/akrpgWriteSdAsm.h | 32 ---------------- .../platform/datel/DatelLoaderPlatform.h | 15 ++++---- ...eadSectorsAsm.h => DatelReadSdPatchCode.h} | 14 ++++--- ...eadSectorsAsm.s => DatelReadSdPatchCode.s} | 0 ...sAsm.h => DatelSendSdioCommandPatchCode.h} | 7 ++-- ...sAsm.s => DatelSendSdioCommandPatchCode.s} | 0 ...teSectorsAsm.h => DatelWriteSdPatchCode.h} | 13 ++++--- ...teSectorsAsm.s => DatelWriteSdPatchCode.s} | 0 .../platform/dspico/DSPicoLoaderPlatform.h | 13 +++---- ...Asm.h => DSPicoReadSdSectorDmaPatchCode.h} | 19 +++++----- ...Asm.s => DSPicoReadSdSectorDmaPatchCode.s} | 0 ...rsAsm.h => DSPicoReadSdSectorsPatchCode.h} | 11 +++--- ...rsAsm.s => DSPicoReadSdSectorsPatchCode.s} | 0 .../dspico/DSPicoWriteSdSectorsPatchCode.h | 20 ++++++++++ ...sAsm.s => DSPicoWriteSdSectorsPatchCode.s} | 0 .../platform/dspico/dspicoWriteSectorsAsm.h | 19 ---------- .../{dsttDefinitions.h => DsttDefinitions.h} | 0 ...derPlatform.cpp => DsttLoaderPlatform.cpp} | 4 +- ...TLoaderPlatform.h => DsttLoaderPlatform.h} | 19 +++++----- ...{dsttReadSdAsm.h => DsttReadSdPatchCode.h} | 19 +++++----- ...{dsttReadSdAsm.s => DsttReadSdPatchCode.s} | 0 ...sttWriteSdAsm.h => DsttWriteSdPatchCode.h} | 19 +++++----- ...sttWriteSdAsm.s => DsttWriteSdPatchCode.s} | 0 ...ZPLoaderPlatform.h => EzpLoaderPlatform.h} | 19 +++++----- ...adSdDataAsm.h => EzpReadSdDataPatchCode.h} | 4 +- ...adSdDataAsm.s => EzpReadSdDataPatchCode.s} | 0 .../platform/ezp/EzpReadSectorsPatchCode.h | 27 ++++++++++++++ ...SectorsAsm.s => EzpReadSectorsPatchCode.s} | 0 .../platform/ezp/EzpWriteSectorsPatchCode.h | 20 ++++++++++ ...ectorsAsm.s => EzpWriteSectorsPatchCode.s} | 0 .../patches/platform/ezp/ezpReadSectorsAsm.h | 26 ------------- .../patches/platform/ezp/ezpWriteSectorsAsm.h | 19 ---------- .../platform/g003/G003LoaderPlatform.h | 13 +++---- .../platform/g003/G003ReadSdDmaPatchCode.h | 31 ++++++++++++++++ ...eadSdDmaAsm.s => G003ReadSdDmaPatchCode.s} | 0 .../platform/g003/G003ReadSdPatchCode.h | 20 ++++++++++ ...{g003ReadSdAsm.s => G003ReadSdPatchCode.s} | 0 .../platform/g003/G003WriteSdPatchCode.h | 20 ++++++++++ ...003WriteSdAsm.s => G003WriteSdPatchCode.s} | 0 .../patches/platform/g003/g003ReadSdAsm.h | 19 ---------- .../patches/platform/g003/g003ReadSdDmaAsm.h | 30 --------------- .../patches/platform/g003/g003WriteSdAsm.h | 19 ---------- .../platform/isnitro/IsNitroLoaderPlatform.h | 9 ++--- .../platform/isnitro/IsNitroSdReadAsm.h | 24 ------------ .../platform/isnitro/IsNitroSdReadPatchCode.h | 25 +++++++++++++ ...roSdReadAsm.s => IsNitroSdReadPatchCode.s} | 0 .../platform/isnitro/IsNitroSdWriteAsm.h | 24 ------------ .../isnitro/IsNitroSdWritePatchCode.h | 25 +++++++++++++ ...SdWriteAsm.s => IsNitroSdWritePatchCode.s} | 2 +- .../platform/m3ds/M3DSLoaderPlatform.h | 9 ++--- ...torsAsm.h => M3DSReadSdSectorsPatchCode.h} | 13 ++++--- ...torsAsm.s => M3DSReadSdSectorsPatchCode.s} | 0 ...orsAsm.h => M3DSWriteSdSectorsPatchCode.h} | 11 +++--- ...orsAsm.s => M3DSWriteSdSectorsPatchCode.s} | 0 .../platform/melonds/MelonDSLoaderPlatform.h | 9 ++--- .../platform/melonds/MelonDSReadSdPatchCode.h | 20 ++++++++++ ...dsReadSdAsm.s => MelonDSReadSdPatchCode.s} | 0 .../melonds/MelonDSWriteSdPatchCode.h | 20 ++++++++++ ...WriteSdAsm.s => MelonDSWriteSdPatchCode.s} | 0 .../platform/melonds/melondsReadSdAsm.h | 19 ---------- .../platform/melonds/melondsWriteSdAsm.h | 19 ---------- .../patches/platform/r4/R4LoaderPlatform.cpp | 1 + .../patches/platform/r4/R4LoaderPlatform.h | 14 +++---- .../patches/platform/r4/R4ReadRomPatchCode.h | 21 +++++++++++ .../{r4ReadRomAsm.s => R4ReadRomPatchCode.s} | 0 .../patches/platform/r4/R4ReadSdPatchCode.h | 20 ++++++++++ .../r4/{r4ReadSdAsm.s => R4ReadSdPatchCode.s} | 0 .../patches/platform/r4/R4WriteSdPatchCode.h | 20 ++++++++++ .../{r4WriteSdAsm.s => R4WriteSdPatchCode.s} | 0 .../source/patches/platform/r4/r4ReadRomAsm.h | 20 ---------- arm9/source/patches/platform/r4/r4ReadSdAsm.h | 19 ---------- .../source/patches/platform/r4/r4WriteSdAsm.h | 19 ---------- ...oaderPlatform.h => R4iDsnLoaderPlatform.h} | 28 +++++++------- .../platform/r4idsn/R4iDsnReadSdPatchCode.h | 37 +++++++++++++++++++ ...dsnReadSdAsm.s => R4iDsnReadSdPatchCode.s} | 0 ...torAsm.h => R4iDsnSdReadSectorPatchCode.h} | 8 ++-- ...torAsm.s => R4iDsnSdReadSectorPatchCode.s} | 0 .../platform/r4idsn/R4iDsnWriteSdPatchCode.h | 33 +++++++++++++++++ ...nWriteSdAsm.s => R4iDsnWriteSdPatchCode.s} | 0 .../patches/platform/r4idsn/r4idsnReadSdAsm.h | 36 ------------------ .../platform/r4idsn/r4idsnWriteSdAsm.h | 32 ---------------- .../stargate/StargateLoaderPlatform.h | 13 +++---- .../stargate/StargateReadSdDmaPatchCode.h | 31 ++++++++++++++++ ...dDmaAsm.s => StargateReadSdDmaPatchCode.s} | 0 .../stargate/StargateReadSdPatchCode.h | 20 ++++++++++ ...eReadSdAsm.s => StargateReadSdPatchCode.s} | 0 .../stargate/StargateWriteSdPatchCode.h | 20 ++++++++++ ...riteSdAsm.s => StargateWriteSdPatchCode.s} | 0 .../platform/stargate/stargateReadSdAsm.h | 19 ---------- .../platform/stargate/stargateReadSdDmaAsm.h | 30 --------------- .../platform/stargate/stargateWriteSdAsm.h | 19 ---------- .../platform/supercard/SuperCardCommon.h | 1 - .../supercard/SuperCardLoaderPlatform.cpp | 2 +- .../supercard/SuperCardLoaderPlatform.h | 37 +++++++++---------- ...SDCommands.cpp => SuperCardSdCommands.cpp} | 2 +- ...CardSDCommands.h => SuperCardSdCommands.h} | 0 .../supercard/sclite/SuperCardLiteImpl.h | 21 ++++++----- .../platform/supercard/scsd/SuperCardSDImpl.h | 21 ++++++----- 180 files changed, 1073 insertions(+), 1057 deletions(-) create mode 100644 arm9/source/patches/ISectorRemapPatchCode.h rename arm9/source/patches/{OffsetToSectorRemapAsm.h => OffsetToSectorRemapPatchCode.h} (58%) rename arm9/source/patches/{OffsetToSectorRemapAsm.s => OffsetToSectorRemapPatchCode.s} (100%) rename arm9/source/patches/{SaveOffsetToSdSectorAsm.h => SaveOffsetToSdSectorPatchCode.h} (67%) rename arm9/source/patches/{SaveOffsetToSdSectorAsm.s => SaveOffsetToSdSectorPatchCode.s} (100%) delete mode 100644 arm9/source/patches/SectorRemapPatchCode.h rename arm9/source/patches/arm7/{ReadSaveAsm.h => ReadSavePatchCode.h} (64%) rename arm9/source/patches/arm7/{ReadSaveAsm.s => ReadSavePatchCode.s} (100%) rename arm9/source/patches/arm7/{VerifySaveAsm.h => VerifySavePatchCode.h} (64%) rename arm9/source/patches/arm7/{VerifySaveAsm.s => VerifySavePatchCode.s} (100%) rename arm9/source/patches/arm7/{WriteSaveAsm.h => WriteSavePatchCode.h} (56%) rename arm9/source/patches/arm7/{WriteSaveAsm.s => WriteSavePatchCode.s} (100%) rename arm9/source/patches/arm7/sdk5/{Sdk5DsiSdCardRedirectPatchAsm.s => Sdk5DsiSdCardRedirectPatchCode.s} (100%) rename arm9/source/patches/arm9/{CardiReadRomIdCorePatchAsm.h => CardiReadRomIdCorePatchCode.h} (100%) rename arm9/source/patches/arm9/{CardiReadRomIdCorePatchAsm.s => CardiReadRomIdCorePatchCode.s} (100%) rename arm9/source/patches/arm9/NandSave/{ReadNandSaveAsm.h => ReadNandSavePatchCode.h} (63%) rename arm9/source/patches/arm9/NandSave/{ReadNandSaveAsm.s => ReadNandSavePatchCode.s} (100%) rename arm9/source/patches/arm9/NandSave/{WriteNandSaveAsm.h => WriteNandSavePatchCode.h} (63%) rename arm9/source/patches/arm9/NandSave/{WriteNandSaveAsm.s => WriteNandSavePatchCode.s} (100%) rename arm9/source/patches/arm9/{OSResetSystemPatchAsm.h => OSResetSystemPatchCode.h} (89%) rename arm9/source/patches/arm9/{OSResetSystemPatchAsm.s => OSResetSystemPatchCode.s} (100%) rename arm9/source/patches/arm9/{PokemonDownloaderArm9PatchAsm.h => PokemonDownloaderArm9PatchCode.h} (75%) rename arm9/source/patches/arm9/{PokemonDownloaderArm9PatchAsm.s => PokemonDownloaderArm9PatchCode.s} (100%) rename arm9/source/patches/arm9/{RomOffsetToSdSectorAsm.h => RomOffsetToSdSectorPatchCode.h} (67%) rename arm9/source/patches/arm9/{RomOffsetToSdSectorAsm.s => RomOffsetToSdSectorPatchCode.s} (100%) rename arm9/source/patches/arm9/sdk2to4/{CardiSetCardDmaPatchAsm.h => CardiSetCardDmaPatchCode.h} (69%) rename arm9/source/patches/arm9/sdk2to4/{CardiSetCardDmaPatchAsm.s => CardiSetCardDmaPatchCode.s} (100%) rename arm9/source/patches/platform/{SdReadDmaPatchCode.h => IReadSectorsDmaPatchCode.h} (56%) create mode 100644 arm9/source/patches/platform/IReadSectorsPatchCode.h create mode 100644 arm9/source/patches/platform/IWriteSectorsPatchCode.h delete mode 100644 arm9/source/patches/platform/SdReadPatchCode.h delete mode 100644 arm9/source/patches/platform/SdWritePatchCode.h create mode 100644 arm9/source/patches/platform/ace3ds/Ace3DSReadSdDmaPatchCode.h rename arm9/source/patches/platform/ace3ds/{ace3dsReadSdDmaAsm.s => Ace3DSReadSdDmaPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/ace3ds/Ace3DSReadSdPatchCode.h rename arm9/source/patches/platform/ace3ds/{ace3dsReadSdAsm.s => Ace3DSReadSdPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/ace3ds/Ace3DSWriteSdPatchCode.h rename arm9/source/patches/platform/ace3ds/{ace3dsWriteSdAsm.s => Ace3DSWriteSdPatchCode.s} (100%) delete mode 100644 arm9/source/patches/platform/ace3ds/ace3dsReadSdAsm.h delete mode 100644 arm9/source/patches/platform/ace3ds/ace3dsReadSdDmaAsm.h delete mode 100644 arm9/source/patches/platform/ace3ds/ace3dsWriteSdAsm.h rename arm9/source/patches/platform/acekard-common/{ioRPGDefinitions.h => IoRpgDefinitions.h} (95%) rename arm9/source/patches/platform/acekard-common/{IoRPGLoaderPlatform.cpp => IoRpgLoaderPlatform.cpp} (92%) rename arm9/source/patches/platform/acekard-common/{IoRPGLoaderPlatform.h => IoRpgLoaderPlatform.h} (90%) rename arm9/source/patches/platform/acekard-common/{iorpgSdWaitForStateAsm.h => IoRpgSdWaitForStatePatchCode.h} (74%) rename arm9/source/patches/platform/acekard-common/{iorpgSdWaitForStateAsm.s => IoRpgSdWaitForStatePatchCode.s} (100%) rename arm9/source/patches/platform/acekard-common/{iorpgSendSdioCommandAsm.h => IoRpgSendSdioCommandPatchCode.h} (75%) rename arm9/source/patches/platform/acekard-common/{iorpgSendSdioCommandAsm.s => IoRpgSendSdioCommandPatchCode.s} (100%) rename arm9/source/patches/platform/ak2/{AK2LoaderPlatform.h => Ak2LoaderPlatform.h} (62%) create mode 100644 arm9/source/patches/platform/ak2/Ak2ReadSdPatchCode.h rename arm9/source/patches/platform/ak2/{ak2ReadSdAsm.s => Ak2ReadSdPatchCode.s} (100%) rename arm9/source/patches/platform/ak2/{ak2SdReadSectorAsm.h => Ak2SdReadSectorPatchCode.h} (72%) rename arm9/source/patches/platform/ak2/{ak2SdReadSectorAsm.s => Ak2SdReadSectorPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/ak2/Ak2WriteSdPatchCode.h rename arm9/source/patches/platform/ak2/{ak2WriteSdAsm.s => Ak2WriteSdPatchCode.s} (100%) delete mode 100644 arm9/source/patches/platform/ak2/ak2ReadSdAsm.h delete mode 100644 arm9/source/patches/platform/ak2/ak2WriteSdAsm.h rename arm9/source/patches/platform/akrpg/{AKRPGLoaderPlatform.h => AkRpgLoaderPlatform.h} (64%) create mode 100644 arm9/source/patches/platform/akrpg/AkRpgReadSdPatchCode.h rename arm9/source/patches/platform/akrpg/{akrpgReadSdAsm.s => AkRpgReadSdPatchCode.s} (100%) rename arm9/source/patches/platform/akrpg/{akrpgSdReadSectorAsm.h => AkRpgSdReadSectorPatchCode.h} (72%) rename arm9/source/patches/platform/akrpg/{akrpgSdReadSectorAsm.s => AkRpgSdReadSectorPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/akrpg/AkRpgWriteSdPatchCode.h rename arm9/source/patches/platform/akrpg/{akrpgWriteSdAsm.s => AkRpgWriteSdPatchCode.s} (100%) delete mode 100644 arm9/source/patches/platform/akrpg/akrpgReadSdAsm.h delete mode 100644 arm9/source/patches/platform/akrpg/akrpgWriteSdAsm.h rename arm9/source/patches/platform/datel/{DatelReadSectorsAsm.h => DatelReadSdPatchCode.h} (66%) rename arm9/source/patches/platform/datel/{DatelReadSectorsAsm.s => DatelReadSdPatchCode.s} (100%) rename arm9/source/patches/platform/datel/{DatelSpiCommandsAsm.h => DatelSendSdioCommandPatchCode.h} (90%) rename arm9/source/patches/platform/datel/{DatelSpiCommandsAsm.s => DatelSendSdioCommandPatchCode.s} (100%) rename arm9/source/patches/platform/datel/{DatelWriteSectorsAsm.h => DatelWriteSdPatchCode.h} (66%) rename arm9/source/patches/platform/datel/{DatelWriteSectorsAsm.s => DatelWriteSdPatchCode.s} (100%) rename arm9/source/patches/platform/dspico/{dspicoReadSdSectorDmaAsm.h => DSPicoReadSdSectorDmaPatchCode.h} (65%) rename arm9/source/patches/platform/dspico/{dspicoReadSdSectorDmaAsm.s => DSPicoReadSdSectorDmaPatchCode.s} (100%) rename arm9/source/patches/platform/dspico/{dspicoReadSectorsAsm.h => DSPicoReadSdSectorsPatchCode.h} (71%) rename arm9/source/patches/platform/dspico/{dspicoReadSectorsAsm.s => DSPicoReadSdSectorsPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/dspico/DSPicoWriteSdSectorsPatchCode.h rename arm9/source/patches/platform/dspico/{dspicoWriteSectorsAsm.s => DSPicoWriteSdSectorsPatchCode.s} (100%) delete mode 100644 arm9/source/patches/platform/dspico/dspicoWriteSectorsAsm.h rename arm9/source/patches/platform/dstt/{dsttDefinitions.h => DsttDefinitions.h} (100%) rename arm9/source/patches/platform/dstt/{DSTTLoaderPlatform.cpp => DsttLoaderPlatform.cpp} (98%) rename arm9/source/patches/platform/dstt/{DSTTLoaderPlatform.h => DsttLoaderPlatform.h} (64%) rename arm9/source/patches/platform/dstt/{dsttReadSdAsm.h => DsttReadSdPatchCode.h} (56%) rename arm9/source/patches/platform/dstt/{dsttReadSdAsm.s => DsttReadSdPatchCode.s} (100%) rename arm9/source/patches/platform/dstt/{dsttWriteSdAsm.h => DsttWriteSdPatchCode.h} (54%) rename arm9/source/patches/platform/dstt/{dsttWriteSdAsm.s => DsttWriteSdPatchCode.s} (100%) rename arm9/source/patches/platform/ezp/{EZPLoaderPlatform.h => EzpLoaderPlatform.h} (60%) rename arm9/source/patches/platform/ezp/{ezpReadSdDataAsm.h => EzpReadSdDataPatchCode.h} (80%) rename arm9/source/patches/platform/ezp/{ezpReadSdDataAsm.s => EzpReadSdDataPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/ezp/EzpReadSectorsPatchCode.h rename arm9/source/patches/platform/ezp/{ezpReadSectorsAsm.s => EzpReadSectorsPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/ezp/EzpWriteSectorsPatchCode.h rename arm9/source/patches/platform/ezp/{ezpWriteSectorsAsm.s => EzpWriteSectorsPatchCode.s} (100%) delete mode 100644 arm9/source/patches/platform/ezp/ezpReadSectorsAsm.h delete mode 100644 arm9/source/patches/platform/ezp/ezpWriteSectorsAsm.h create mode 100644 arm9/source/patches/platform/g003/G003ReadSdDmaPatchCode.h rename arm9/source/patches/platform/g003/{g003ReadSdDmaAsm.s => G003ReadSdDmaPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/g003/G003ReadSdPatchCode.h rename arm9/source/patches/platform/g003/{g003ReadSdAsm.s => G003ReadSdPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/g003/G003WriteSdPatchCode.h rename arm9/source/patches/platform/g003/{g003WriteSdAsm.s => G003WriteSdPatchCode.s} (100%) delete mode 100644 arm9/source/patches/platform/g003/g003ReadSdAsm.h delete mode 100644 arm9/source/patches/platform/g003/g003ReadSdDmaAsm.h delete mode 100644 arm9/source/patches/platform/g003/g003WriteSdAsm.h delete mode 100644 arm9/source/patches/platform/isnitro/IsNitroSdReadAsm.h create mode 100644 arm9/source/patches/platform/isnitro/IsNitroSdReadPatchCode.h rename arm9/source/patches/platform/isnitro/{IsNitroSdReadAsm.s => IsNitroSdReadPatchCode.s} (100%) delete mode 100644 arm9/source/patches/platform/isnitro/IsNitroSdWriteAsm.h create mode 100644 arm9/source/patches/platform/isnitro/IsNitroSdWritePatchCode.h rename arm9/source/patches/platform/isnitro/{IsNitroSdWriteAsm.s => IsNitroSdWritePatchCode.s} (99%) rename arm9/source/patches/platform/m3ds/{m3dsReadSectorsAsm.h => M3DSReadSdSectorsPatchCode.h} (61%) rename arm9/source/patches/platform/m3ds/{m3dsReadSectorsAsm.s => M3DSReadSdSectorsPatchCode.s} (100%) rename arm9/source/patches/platform/m3ds/{m3dsWriteSectorsAsm.h => M3DSWriteSdSectorsPatchCode.h} (69%) rename arm9/source/patches/platform/m3ds/{m3dsWriteSectorsAsm.s => M3DSWriteSdSectorsPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/melonds/MelonDSReadSdPatchCode.h rename arm9/source/patches/platform/melonds/{melondsReadSdAsm.s => MelonDSReadSdPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/melonds/MelonDSWriteSdPatchCode.h rename arm9/source/patches/platform/melonds/{melondsWriteSdAsm.s => MelonDSWriteSdPatchCode.s} (100%) delete mode 100644 arm9/source/patches/platform/melonds/melondsReadSdAsm.h delete mode 100644 arm9/source/patches/platform/melonds/melondsWriteSdAsm.h create mode 100644 arm9/source/patches/platform/r4/R4ReadRomPatchCode.h rename arm9/source/patches/platform/r4/{r4ReadRomAsm.s => R4ReadRomPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/r4/R4ReadSdPatchCode.h rename arm9/source/patches/platform/r4/{r4ReadSdAsm.s => R4ReadSdPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/r4/R4WriteSdPatchCode.h rename arm9/source/patches/platform/r4/{r4WriteSdAsm.s => R4WriteSdPatchCode.s} (100%) delete mode 100644 arm9/source/patches/platform/r4/r4ReadRomAsm.h delete mode 100644 arm9/source/patches/platform/r4/r4ReadSdAsm.h delete mode 100644 arm9/source/patches/platform/r4/r4WriteSdAsm.h rename arm9/source/patches/platform/r4idsn/{R4iDSNLoaderPlatform.h => R4iDsnLoaderPlatform.h} (65%) create mode 100644 arm9/source/patches/platform/r4idsn/R4iDsnReadSdPatchCode.h rename arm9/source/patches/platform/r4idsn/{r4idsnReadSdAsm.s => R4iDsnReadSdPatchCode.s} (100%) rename arm9/source/patches/platform/r4idsn/{r4idsnSdReadSectorAsm.h => R4iDsnSdReadSectorPatchCode.h} (72%) rename arm9/source/patches/platform/r4idsn/{r4idsnSdReadSectorAsm.s => R4iDsnSdReadSectorPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/r4idsn/R4iDsnWriteSdPatchCode.h rename arm9/source/patches/platform/r4idsn/{r4idsnWriteSdAsm.s => R4iDsnWriteSdPatchCode.s} (100%) delete mode 100644 arm9/source/patches/platform/r4idsn/r4idsnReadSdAsm.h delete mode 100644 arm9/source/patches/platform/r4idsn/r4idsnWriteSdAsm.h create mode 100644 arm9/source/patches/platform/stargate/StargateReadSdDmaPatchCode.h rename arm9/source/patches/platform/stargate/{stargateReadSdDmaAsm.s => StargateReadSdDmaPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/stargate/StargateReadSdPatchCode.h rename arm9/source/patches/platform/stargate/{stargateReadSdAsm.s => StargateReadSdPatchCode.s} (100%) create mode 100644 arm9/source/patches/platform/stargate/StargateWriteSdPatchCode.h rename arm9/source/patches/platform/stargate/{stargateWriteSdAsm.s => StargateWriteSdPatchCode.s} (100%) delete mode 100644 arm9/source/patches/platform/stargate/stargateReadSdAsm.h delete mode 100644 arm9/source/patches/platform/stargate/stargateReadSdDmaAsm.h delete mode 100644 arm9/source/patches/platform/stargate/stargateWriteSdAsm.h rename arm9/source/patches/platform/supercard/{SuperCardSDCommands.cpp => SuperCardSdCommands.cpp} (99%) rename arm9/source/patches/platform/supercard/{SuperCardSDCommands.h => SuperCardSdCommands.h} (100%) diff --git a/arm9/source/main.cpp b/arm9/source/main.cpp index 788ab09..422d4ed 100644 --- a/arm9/source/main.cpp +++ b/arm9/source/main.cpp @@ -192,8 +192,8 @@ static void handleGetSdFunctionsCommand() { auto sdReadPatchCode = sLoaderPlatform->CreateSdReadPatchCode(patchCodeCollection, patchHeap); auto sdWritePatchCode = sLoaderPlatform->CreateSdWritePatchCode(patchCodeCollection, patchHeap); - *(vu32*)0x037F8000 = (u32)sdReadPatchCode->GetSdReadFunction(); - *(vu32*)0x037F8004 = (u32)sdWritePatchCode->GetSdWriteFunction(); + *(vu32*)0x037F8000 = (u32)sdReadPatchCode->GetReadSectorsFunction(); + *(vu32*)0x037F8004 = (u32)sdWritePatchCode->GetWriteSectorFunction(); patchCodeCollection.CopyAllToTarget(); } dc_flushAll(); diff --git a/arm9/source/patches/ISectorRemapPatchCode.h b/arm9/source/patches/ISectorRemapPatchCode.h new file mode 100644 index 0000000..ad8bd16 --- /dev/null +++ b/arm9/source/patches/ISectorRemapPatchCode.h @@ -0,0 +1,10 @@ +#pragma once + +class ISectorRemapPatchCode +{ +protected: + ISectorRemapPatchCode() { } + +public: + virtual const void* GetRemapFunction() const = 0; +}; diff --git a/arm9/source/patches/OffsetToSectorRemapAsm.h b/arm9/source/patches/OffsetToSectorRemapPatchCode.h similarity index 58% rename from arm9/source/patches/OffsetToSectorRemapAsm.h rename to arm9/source/patches/OffsetToSectorRemapPatchCode.h index 5fee154..529edbc 100644 --- a/arm9/source/patches/OffsetToSectorRemapAsm.h +++ b/arm9/source/patches/OffsetToSectorRemapPatchCode.h @@ -1,17 +1,17 @@ #pragma once #include "sections.h" -#include "SectorRemapPatchCode.h" +#include "PatchCode.h" +#include "ISectorRemapPatchCode.h" DEFINE_SECTION_SYMBOLS(offsettosectorremap); extern "C" u32 offset_to_sector_remap(u32 romOffset); -class OffsetToSectorRemapPatchCode : public SectorRemapPatchCode +class OffsetToSectorRemapPatchCode : public PatchCode, public ISectorRemapPatchCode { public: explicit OffsetToSectorRemapPatchCode(PatchHeap& patchHeap) - : SectorRemapPatchCode(SECTION_START(offsettosectorremap), SECTION_SIZE(offsettosectorremap), patchHeap) - { } + : PatchCode(SECTION_START(offsettosectorremap), SECTION_SIZE(offsettosectorremap), patchHeap) { } const void* GetRemapFunction() const override { diff --git a/arm9/source/patches/OffsetToSectorRemapAsm.s b/arm9/source/patches/OffsetToSectorRemapPatchCode.s similarity index 100% rename from arm9/source/patches/OffsetToSectorRemapAsm.s rename to arm9/source/patches/OffsetToSectorRemapPatchCode.s diff --git a/arm9/source/patches/SaveOffsetToSdSectorAsm.h b/arm9/source/patches/SaveOffsetToSdSectorPatchCode.h similarity index 67% rename from arm9/source/patches/SaveOffsetToSdSectorAsm.h rename to arm9/source/patches/SaveOffsetToSdSectorPatchCode.h index de22ee1..3f00f5f 100644 --- a/arm9/source/patches/SaveOffsetToSdSectorAsm.h +++ b/arm9/source/patches/SaveOffsetToSdSectorPatchCode.h @@ -1,6 +1,7 @@ #pragma once #include "sections.h" -#include "SectorRemapPatchCode.h" +#include "PatchCode.h" +#include "ISectorRemapPatchCode.h" #include "fileInfo.h" DEFINE_SECTION_SYMBOLS(saveoffsettosdsector); @@ -9,11 +10,11 @@ extern "C" u32 save_offset_to_sd_sector_asm(u32 saveOffset); extern u32 saveoffsettosdsector_fatDataPtr; -class SaveOffsetToSdSectorPatchCode : public SectorRemapPatchCode +class SaveOffsetToSdSectorPatchCode : public PatchCode, public ISectorRemapPatchCode { public: SaveOffsetToSdSectorPatchCode(PatchHeap& patchHeap, const save_file_info_t* fatDataPtr) - : SectorRemapPatchCode(SECTION_START(saveoffsettosdsector), SECTION_SIZE(saveoffsettosdsector), patchHeap) + : PatchCode(SECTION_START(saveoffsettosdsector), SECTION_SIZE(saveoffsettosdsector), patchHeap) { saveoffsettosdsector_fatDataPtr = (u32)fatDataPtr; } diff --git a/arm9/source/patches/SaveOffsetToSdSectorAsm.s b/arm9/source/patches/SaveOffsetToSdSectorPatchCode.s similarity index 100% rename from arm9/source/patches/SaveOffsetToSdSectorAsm.s rename to arm9/source/patches/SaveOffsetToSdSectorPatchCode.s diff --git a/arm9/source/patches/SectorRemapPatchCode.h b/arm9/source/patches/SectorRemapPatchCode.h deleted file mode 100644 index 17dc1a1..0000000 --- a/arm9/source/patches/SectorRemapPatchCode.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "PatchCode.h" - -class SectorRemapPatchCode : public PatchCode -{ -public: - SectorRemapPatchCode(const void* code, u32 size, PatchHeap& patchHeap) - : PatchCode(code, size, patchHeap) { } - - virtual const void* GetRemapFunction() const = 0; -}; diff --git a/arm9/source/patches/arm7/ReadSaveAsm.h b/arm9/source/patches/arm7/ReadSavePatchCode.h similarity index 64% rename from arm9/source/patches/arm7/ReadSaveAsm.h rename to arm9/source/patches/arm7/ReadSavePatchCode.h index c1e4ce6..b2a3f5f 100644 --- a/arm9/source/patches/arm7/ReadSaveAsm.h +++ b/arm9/source/patches/arm7/ReadSavePatchCode.h @@ -1,8 +1,8 @@ #pragma once #include "sections.h" -#include "../PatchCode.h" -#include "../SectorRemapPatchCode.h" -#include "../platform/SdReadPatchCode.h" +#include "patches/PatchCode.h" +#include "patches/ISectorRemapPatchCode.h" +#include "patches/platform/IReadSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(readsave); @@ -15,12 +15,12 @@ extern u32 readsave_sdread_asm_address; class ReadSavePatchCode : public PatchCode { public: - ReadSavePatchCode(PatchHeap& patchHeap, const SectorRemapPatchCode* sectorRemapPatchCode, - const SdReadPatchCode* sdReadPatchCode, void* tmpBuffer) + ReadSavePatchCode(PatchHeap& patchHeap, const ISectorRemapPatchCode* sectorRemapPatchCode, + const IReadSectorsPatchCode* readSectorsPatchCode, void* tmpBuffer) : PatchCode(SECTION_START(readsave), SECTION_SIZE(readsave), patchHeap) { readsave_save_offset_to_sd_sector_asm_address = (u32)sectorRemapPatchCode->GetRemapFunction(); - readsave_sdread_asm_address = (u32)sdReadPatchCode->GetSdReadFunction(); + readsave_sdread_asm_address = (u32)readSectorsPatchCode->GetReadSectorsFunction(); readsave_tmpBufferPtr = (u32)tmpBuffer; } diff --git a/arm9/source/patches/arm7/ReadSaveAsm.s b/arm9/source/patches/arm7/ReadSavePatchCode.s similarity index 100% rename from arm9/source/patches/arm7/ReadSaveAsm.s rename to arm9/source/patches/arm7/ReadSavePatchCode.s diff --git a/arm9/source/patches/arm7/VerifySaveAsm.h b/arm9/source/patches/arm7/VerifySavePatchCode.h similarity index 64% rename from arm9/source/patches/arm7/VerifySaveAsm.h rename to arm9/source/patches/arm7/VerifySavePatchCode.h index 9d1e06f..f2dca36 100644 --- a/arm9/source/patches/arm7/VerifySaveAsm.h +++ b/arm9/source/patches/arm7/VerifySavePatchCode.h @@ -1,8 +1,8 @@ #pragma once #include "sections.h" -#include "../PatchCode.h" -#include "../SectorRemapPatchCode.h" -#include "../platform/SdReadPatchCode.h" +#include "patches/PatchCode.h" +#include "patches/ISectorRemapPatchCode.h" +#include "patches/platform/IReadSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(verifysave); @@ -15,12 +15,12 @@ extern u32 verifysave_sdread_asm_address; class VerifySavePatchCode : public PatchCode { public: - VerifySavePatchCode(PatchHeap& patchHeap, const SectorRemapPatchCode* sectorRemapPatchCode, - const SdReadPatchCode* sdReadPatchCode, void* tmpBuffer) + VerifySavePatchCode(PatchHeap& patchHeap, const ISectorRemapPatchCode* sectorRemapPatchCode, + const IReadSectorsPatchCode* readSectorsPatchCode, void* tmpBuffer) : PatchCode(SECTION_START(verifysave), SECTION_SIZE(verifysave), patchHeap) { verifysave_save_offset_to_sd_sector_asm_address = (u32)sectorRemapPatchCode->GetRemapFunction(); - verifysave_sdread_asm_address = (u32)sdReadPatchCode->GetSdReadFunction(); + verifysave_sdread_asm_address = (u32)readSectorsPatchCode->GetReadSectorsFunction(); verifysave_tmpBufferPtr = (u32)tmpBuffer; } diff --git a/arm9/source/patches/arm7/VerifySaveAsm.s b/arm9/source/patches/arm7/VerifySavePatchCode.s similarity index 100% rename from arm9/source/patches/arm7/VerifySaveAsm.s rename to arm9/source/patches/arm7/VerifySavePatchCode.s diff --git a/arm9/source/patches/arm7/WriteSaveAsm.h b/arm9/source/patches/arm7/WriteSavePatchCode.h similarity index 56% rename from arm9/source/patches/arm7/WriteSaveAsm.h rename to arm9/source/patches/arm7/WriteSavePatchCode.h index a32ddcb..e00a006 100644 --- a/arm9/source/patches/arm7/WriteSaveAsm.h +++ b/arm9/source/patches/arm7/WriteSavePatchCode.h @@ -1,9 +1,9 @@ #pragma once #include "sections.h" -#include "../PatchCode.h" -#include "../SectorRemapPatchCode.h" -#include "../platform/SdReadPatchCode.h" -#include "../platform/SdWritePatchCode.h" +#include "patches/PatchCode.h" +#include "patches/ISectorRemapPatchCode.h" +#include "patches/platform/IReadSectorsPatchCode.h" +#include "patches/platform/IWriteSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(writesave); @@ -17,13 +17,13 @@ extern u32 writesave_sdwrite_asm_address; class WriteSavePatchCode : public PatchCode { public: - WriteSavePatchCode(PatchHeap& patchHeap, const SectorRemapPatchCode* sectorRemapPatchCode, - const SdReadPatchCode* sdReadPatchCode, const SdWritePatchCode* sdWritePatchCode, void* tmpBuffer) + WriteSavePatchCode(PatchHeap& patchHeap, const ISectorRemapPatchCode* sectorRemapPatchCode, + const IReadSectorsPatchCode* readSectorsPatchCode, const IWriteSectorsPatchCode* writeSectorsPatchCode, void* tmpBuffer) : PatchCode(SECTION_START(writesave), SECTION_SIZE(writesave), patchHeap) { writesave_save_offset_to_sd_sector_asm_address = (u32)sectorRemapPatchCode->GetRemapFunction(); - writesave_sdread_asm_address = (u32)sdReadPatchCode->GetSdReadFunction(); - writesave_sdwrite_asm_address = (u32)sdWritePatchCode->GetSdWriteFunction(); + writesave_sdread_asm_address = (u32)readSectorsPatchCode->GetReadSectorsFunction(); + writesave_sdwrite_asm_address = (u32)writeSectorsPatchCode->GetWriteSectorFunction(); writesave_tmpBufferPtr = (u32)tmpBuffer; } diff --git a/arm9/source/patches/arm7/WriteSaveAsm.s b/arm9/source/patches/arm7/WriteSavePatchCode.s similarity index 100% rename from arm9/source/patches/arm7/WriteSaveAsm.s rename to arm9/source/patches/arm7/WriteSavePatchCode.s diff --git a/arm9/source/patches/arm7/sdk2to4/CardiTaskThreadPatch.cpp b/arm9/source/patches/arm7/sdk2to4/CardiTaskThreadPatch.cpp index b5bdac3..9fc0c65 100644 --- a/arm9/source/patches/arm7/sdk2to4/CardiTaskThreadPatch.cpp +++ b/arm9/source/patches/arm7/sdk2to4/CardiTaskThreadPatch.cpp @@ -3,12 +3,12 @@ #include #include "fileInfo.h" #include "patches/PatchContext.h" -#include "patches/arm7/ReadSaveAsm.h" -#include "patches/arm7/WriteSaveAsm.h" -#include "patches/arm7/VerifySaveAsm.h" +#include "patches/arm7/ReadSavePatchCode.h" +#include "patches/arm7/WriteSavePatchCode.h" +#include "patches/arm7/VerifySavePatchCode.h" #include "patches/FunctionSignature.h" #include "patches/platform/LoaderPlatform.h" -#include "patches/SaveOffsetToSdSectorAsm.h" +#include "patches/SaveOffsetToSdSectorPatchCode.h" #include "patches/arm7/CardiTaskThreadPatchAsm.h" #include "thumbInstructions.h" #include "CardiTaskThreadPatch.h" diff --git a/arm9/source/patches/arm7/sdk5/CardiDoTaskFromArm9Patch.cpp b/arm9/source/patches/arm7/sdk5/CardiDoTaskFromArm9Patch.cpp index 105f1d0..5a0d0f9 100644 --- a/arm9/source/patches/arm7/sdk5/CardiDoTaskFromArm9Patch.cpp +++ b/arm9/source/patches/arm7/sdk5/CardiDoTaskFromArm9Patch.cpp @@ -2,10 +2,10 @@ #include "patches/PatchContext.h" #include "thumbInstructions.h" #include "fileInfo.h" -#include "patches/arm7/ReadSaveAsm.h" -#include "patches/arm7/WriteSaveAsm.h" -#include "patches/arm7/VerifySaveAsm.h" -#include "patches/SaveOffsetToSdSectorAsm.h" +#include "patches/arm7/ReadSavePatchCode.h" +#include "patches/arm7/WriteSavePatchCode.h" +#include "patches/arm7/VerifySavePatchCode.h" +#include "patches/SaveOffsetToSdSectorPatchCode.h" #include "patches/platform/LoaderPlatform.h" #include "patches/arm7/CardiTaskThreadPatchAsm.h" #include "CardiDoTaskFromArm9Patch.h" diff --git a/arm9/source/patches/arm7/sdk5/Sdk5DsiSdCardRedirectPatchAsm.h b/arm9/source/patches/arm7/sdk5/Sdk5DsiSdCardRedirectPatchAsm.h index dceab18..aeef615 100644 --- a/arm9/source/patches/arm7/sdk5/Sdk5DsiSdCardRedirectPatchAsm.h +++ b/arm9/source/patches/arm7/sdk5/Sdk5DsiSdCardRedirectPatchAsm.h @@ -1,8 +1,8 @@ #pragma once -#include "patches/PatchCode.h" #include "sections.h" -#include "patches/platform/SdReadPatchCode.h" -#include "patches/platform/SdWritePatchCode.h" +#include "patches/PatchCode.h" +#include "patches/platform/IReadSectorsPatchCode.h" +#include "patches/platform/IWriteSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(patch_dsisdredirect); @@ -16,12 +16,12 @@ extern u32 __patch_dsisdredirect_control_get_drive_struct_address; class Sdk5DsiSdCardRedirectPatchCode : public PatchCode { public: - Sdk5DsiSdCardRedirectPatchCode(PatchHeap& patchHeap, const SdReadPatchCode* sdReadPatchCode, - const SdWritePatchCode* sdWritePatchCode, u32 getDriveStructAddress) + Sdk5DsiSdCardRedirectPatchCode(PatchHeap& patchHeap, const IReadSectorsPatchCode* readSectorsPatchCode, + const IWriteSectorsPatchCode* writeSectorsPatchCode, u32 getDriveStructAddress) : PatchCode(SECTION_START(patch_dsisdredirect), SECTION_SIZE(patch_dsisdredirect), patchHeap) { - __patch_dsisdredirect_io_readsd_asm_address = (u32)sdReadPatchCode->GetSdReadFunction(); - __patch_dsisdredirect_io_writesd_asm_address = (u32)sdWritePatchCode->GetSdWriteFunction(); + __patch_dsisdredirect_io_readsd_asm_address = (u32)readSectorsPatchCode->GetReadSectorsFunction(); + __patch_dsisdredirect_io_writesd_asm_address = (u32)writeSectorsPatchCode->GetWriteSectorFunction(); __patch_dsisdredirect_control_get_drive_struct_address = getDriveStructAddress; } diff --git a/arm9/source/patches/arm7/sdk5/Sdk5DsiSdCardRedirectPatchAsm.s b/arm9/source/patches/arm7/sdk5/Sdk5DsiSdCardRedirectPatchCode.s similarity index 100% rename from arm9/source/patches/arm7/sdk5/Sdk5DsiSdCardRedirectPatchAsm.s rename to arm9/source/patches/arm7/sdk5/Sdk5DsiSdCardRedirectPatchCode.s diff --git a/arm9/source/patches/arm9/CardiReadRomIdCorePatch.cpp b/arm9/source/patches/arm9/CardiReadRomIdCorePatch.cpp index 61c4c94..ac1a836 100644 --- a/arm9/source/patches/arm9/CardiReadRomIdCorePatch.cpp +++ b/arm9/source/patches/arm9/CardiReadRomIdCorePatch.cpp @@ -2,7 +2,7 @@ #include "thumbInstructions.h" #include "../PatchContext.h" #include "../FunctionSignature.h" -#include "CardiReadRomIdCorePatchAsm.h" +#include "CardiReadRomIdCorePatchCode.h" #include "CardiReadRomIdCorePatch.h" static constexpr auto sSignaturesArm = std::to_array diff --git a/arm9/source/patches/arm9/CardiReadRomIdCorePatchAsm.h b/arm9/source/patches/arm9/CardiReadRomIdCorePatchCode.h similarity index 100% rename from arm9/source/patches/arm9/CardiReadRomIdCorePatchAsm.h rename to arm9/source/patches/arm9/CardiReadRomIdCorePatchCode.h diff --git a/arm9/source/patches/arm9/CardiReadRomIdCorePatchAsm.s b/arm9/source/patches/arm9/CardiReadRomIdCorePatchCode.s similarity index 100% rename from arm9/source/patches/arm9/CardiReadRomIdCorePatchAsm.s rename to arm9/source/patches/arm9/CardiReadRomIdCorePatchCode.s diff --git a/arm9/source/patches/arm9/NandSave/FaceTrainingNandSavePatch.cpp b/arm9/source/patches/arm9/NandSave/FaceTrainingNandSavePatch.cpp index 7ac99f1..e597449 100644 --- a/arm9/source/patches/arm9/NandSave/FaceTrainingNandSavePatch.cpp +++ b/arm9/source/patches/arm9/NandSave/FaceTrainingNandSavePatch.cpp @@ -1,9 +1,9 @@ #include "common.h" #include "gameCode.h" #include "patches/platform/LoaderPlatform.h" -#include "patches/SaveOffsetToSdSectorAsm.h" -#include "ReadNandSaveAsm.h" -#include "WriteNandSaveAsm.h" +#include "patches/SaveOffsetToSdSectorPatchCode.h" +#include "ReadNandSavePatchCode.h" +#include "WriteNandSavePatchCode.h" #include "FaceTrainingNandSavePatch.h" // This code was based on nds-bootstrap: diff --git a/arm9/source/patches/arm9/NandSave/JamWithTheBandNandSavePatch.cpp b/arm9/source/patches/arm9/NandSave/JamWithTheBandNandSavePatch.cpp index 61eb75d..ede4ab5 100644 --- a/arm9/source/patches/arm9/NandSave/JamWithTheBandNandSavePatch.cpp +++ b/arm9/source/patches/arm9/NandSave/JamWithTheBandNandSavePatch.cpp @@ -1,9 +1,9 @@ #include "common.h" #include "gameCode.h" #include "patches/platform/LoaderPlatform.h" -#include "patches/SaveOffsetToSdSectorAsm.h" -#include "ReadNandSaveAsm.h" -#include "WriteNandSaveAsm.h" +#include "patches/SaveOffsetToSdSectorPatchCode.h" +#include "ReadNandSavePatchCode.h" +#include "WriteNandSavePatchCode.h" #include "JamWithTheBandNandSavePatch.h" // This code was based on nds-bootstrap: diff --git a/arm9/source/patches/arm9/NandSave/NintendoDSGuideNandSavePatch.cpp b/arm9/source/patches/arm9/NandSave/NintendoDSGuideNandSavePatch.cpp index 1a3e377..4d694a2 100644 --- a/arm9/source/patches/arm9/NandSave/NintendoDSGuideNandSavePatch.cpp +++ b/arm9/source/patches/arm9/NandSave/NintendoDSGuideNandSavePatch.cpp @@ -1,9 +1,9 @@ #include "common.h" #include "gameCode.h" #include "patches/platform/LoaderPlatform.h" -#include "patches/SaveOffsetToSdSectorAsm.h" -#include "ReadNandSaveAsm.h" -#include "WriteNandSaveAsm.h" +#include "patches/SaveOffsetToSdSectorPatchCode.h" +#include "ReadNandSavePatchCode.h" +#include "WriteNandSavePatchCode.h" #include "NintendoDSGuideNandSavePatch.h" // This code was based on nds-bootstrap: diff --git a/arm9/source/patches/arm9/NandSave/ReadNandSaveAsm.h b/arm9/source/patches/arm9/NandSave/ReadNandSavePatchCode.h similarity index 63% rename from arm9/source/patches/arm9/NandSave/ReadNandSaveAsm.h rename to arm9/source/patches/arm9/NandSave/ReadNandSavePatchCode.h index 213a22a..3d18e42 100644 --- a/arm9/source/patches/arm9/NandSave/ReadNandSaveAsm.h +++ b/arm9/source/patches/arm9/NandSave/ReadNandSavePatchCode.h @@ -1,8 +1,8 @@ #pragma once -#include "patches/PatchCode.h" #include "sections.h" -#include "patches/SaveOffsetToSdSectorAsm.h" -#include "patches/platform/SdReadPatchCode.h" +#include "patches/PatchCode.h" +#include "patches/ISectorRemapPatchCode.h" +#include "patches/platform/IReadSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(patch_readnandsave); @@ -14,12 +14,12 @@ extern u32 patch_readNandSave_sdread_asm_address; class ReadNandSavePatchCode : public PatchCode { public: - ReadNandSavePatchCode(PatchHeap& patchHeap, const SaveOffsetToSdSectorPatchCode* saveOffsetToSdSectorPatchCode, - const SdReadPatchCode* sdReadPatchCode) + ReadNandSavePatchCode(PatchHeap& patchHeap, const ISectorRemapPatchCode* sectorRemapPatchCode, + const IReadSectorsPatchCode* readSectorsPatchCode) : PatchCode(SECTION_START(patch_readnandsave), SECTION_SIZE(patch_readnandsave), patchHeap) { - patch_readNandSave_save_offset_to_sd_sector_asm_address = (u32)saveOffsetToSdSectorPatchCode->GetRemapFunction(); - patch_readNandSave_sdread_asm_address = (u32)sdReadPatchCode->GetSdReadFunction(); + patch_readNandSave_save_offset_to_sd_sector_asm_address = (u32)sectorRemapPatchCode->GetRemapFunction(); + patch_readNandSave_sdread_asm_address = (u32)readSectorsPatchCode->GetReadSectorsFunction(); } const void* GetReadNandSaveFunction() const diff --git a/arm9/source/patches/arm9/NandSave/ReadNandSaveAsm.s b/arm9/source/patches/arm9/NandSave/ReadNandSavePatchCode.s similarity index 100% rename from arm9/source/patches/arm9/NandSave/ReadNandSaveAsm.s rename to arm9/source/patches/arm9/NandSave/ReadNandSavePatchCode.s diff --git a/arm9/source/patches/arm9/NandSave/WarioWareDiyNandSavePatch.cpp b/arm9/source/patches/arm9/NandSave/WarioWareDiyNandSavePatch.cpp index 121d1f7..33fdd62 100644 --- a/arm9/source/patches/arm9/NandSave/WarioWareDiyNandSavePatch.cpp +++ b/arm9/source/patches/arm9/NandSave/WarioWareDiyNandSavePatch.cpp @@ -1,9 +1,9 @@ #include "common.h" #include "gameCode.h" #include "patches/platform/LoaderPlatform.h" -#include "patches/SaveOffsetToSdSectorAsm.h" -#include "ReadNandSaveAsm.h" -#include "WriteNandSaveAsm.h" +#include "patches/SaveOffsetToSdSectorPatchCode.h" +#include "ReadNandSavePatchCode.h" +#include "WriteNandSavePatchCode.h" #include "WarioWareDiyNandSavePatch.h" // This code was based on nds-bootstrap: diff --git a/arm9/source/patches/arm9/NandSave/WriteNandSaveAsm.h b/arm9/source/patches/arm9/NandSave/WriteNandSavePatchCode.h similarity index 63% rename from arm9/source/patches/arm9/NandSave/WriteNandSaveAsm.h rename to arm9/source/patches/arm9/NandSave/WriteNandSavePatchCode.h index 21e1116..6551af3 100644 --- a/arm9/source/patches/arm9/NandSave/WriteNandSaveAsm.h +++ b/arm9/source/patches/arm9/NandSave/WriteNandSavePatchCode.h @@ -1,8 +1,8 @@ #pragma once -#include "patches/PatchCode.h" #include "sections.h" -#include "patches/SaveOffsetToSdSectorAsm.h" -#include "patches/platform/SdWritePatchCode.h" +#include "patches/PatchCode.h" +#include "patches/ISectorRemapPatchCode.h" +#include "patches/platform/IWriteSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(patch_writenandsave); @@ -14,12 +14,12 @@ extern u32 patch_writeNandSave_sdwrite_asm_address; class WriteNandSavePatchCode : public PatchCode { public: - WriteNandSavePatchCode(PatchHeap& patchHeap, const SaveOffsetToSdSectorPatchCode* saveOffsetToSdSectorPatchCode, - const SdWritePatchCode* sdWritePatchCode) + WriteNandSavePatchCode(PatchHeap& patchHeap, const ISectorRemapPatchCode* sectorRemapPatchCode, + const IWriteSectorsPatchCode* writeSectorsPatchCode) : PatchCode(SECTION_START(patch_writenandsave), SECTION_SIZE(patch_writenandsave), patchHeap) { - patch_writeNandSave_save_offset_to_sd_sector_asm_address = (u32)saveOffsetToSdSectorPatchCode->GetRemapFunction(); - patch_writeNandSave_sdwrite_asm_address = (u32)sdWritePatchCode->GetSdWriteFunction(); + patch_writeNandSave_save_offset_to_sd_sector_asm_address = (u32)sectorRemapPatchCode->GetRemapFunction(); + patch_writeNandSave_sdwrite_asm_address = (u32)writeSectorsPatchCode->GetWriteSectorFunction(); } const void* GetWriteNandSaveFunction() const diff --git a/arm9/source/patches/arm9/NandSave/WriteNandSaveAsm.s b/arm9/source/patches/arm9/NandSave/WriteNandSavePatchCode.s similarity index 100% rename from arm9/source/patches/arm9/NandSave/WriteNandSaveAsm.s rename to arm9/source/patches/arm9/NandSave/WriteNandSavePatchCode.s diff --git a/arm9/source/patches/arm9/OSResetSystemPatch.cpp b/arm9/source/patches/arm9/OSResetSystemPatch.cpp index c67f603..3c6a371 100644 --- a/arm9/source/patches/arm9/OSResetSystemPatch.cpp +++ b/arm9/source/patches/arm9/OSResetSystemPatch.cpp @@ -1,8 +1,8 @@ #include "common.h" -#include "../PatchContext.h" +#include "patches/PatchContext.h" #include "thumbInstructions.h" -#include "../platform/LoaderPlatform.h" -#include "OSResetSystemPatchAsm.h" +#include "patches/platform/LoaderPlatform.h" +#include "OSResetSystemPatchCode.h" #include "OSResetSystemPatch.h" static const u32 sOSResetSystemPatternSdk2Old[] = { 0xE59F101Cu, 0xE3A00010u, 0xE5815000u, 0xEB000005u }; diff --git a/arm9/source/patches/arm9/OSResetSystemPatchAsm.h b/arm9/source/patches/arm9/OSResetSystemPatchCode.h similarity index 89% rename from arm9/source/patches/arm9/OSResetSystemPatchAsm.h rename to arm9/source/patches/arm9/OSResetSystemPatchCode.h index 02c028a..a46db77 100644 --- a/arm9/source/patches/arm9/OSResetSystemPatchAsm.h +++ b/arm9/source/patches/arm9/OSResetSystemPatchCode.h @@ -2,7 +2,7 @@ #include "../PatchCode.h" #include "sections.h" #include "LoaderInfo.h" -#include "../platform/SdReadPatchCode.h" +#include "patches/platform/IReadSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(patch_osresetsystem); DEFINE_SECTION_SYMBOLS(patch_osresetsystem_boot); @@ -34,11 +34,11 @@ class OSResetSystemPatchCode : public PatchCode { public: OSResetSystemPatchCode(PatchHeap& patchHeap, const loader_info_t* loaderInfo, - const SdReadPatchCode* sdReadPatchCode, const OSResetSystemPart2PatchCode* part2PatchCode) + const IReadSectorsPatchCode* sdReadPatchCode, const OSResetSystemPart2PatchCode* part2PatchCode) : PatchCode(SECTION_START(patch_osresetsystem), SECTION_SIZE(patch_osresetsystem), patchHeap) { patch_osresetsystem_loader_info_address = loaderInfo; - patch_osresetsystem_readSdSectors_address = (u32)sdReadPatchCode->GetSdReadFunction(); + patch_osresetsystem_readSdSectors_address = (u32)sdReadPatchCode->GetReadSectorsFunction(); patch_osresetsystem_bootPicoLoader_address = (u32)part2PatchCode->GetOSResetSystemPart2Function(); } diff --git a/arm9/source/patches/arm9/OSResetSystemPatchAsm.s b/arm9/source/patches/arm9/OSResetSystemPatchCode.s similarity index 100% rename from arm9/source/patches/arm9/OSResetSystemPatchAsm.s rename to arm9/source/patches/arm9/OSResetSystemPatchCode.s diff --git a/arm9/source/patches/arm9/PokemonDownloaderArm9Patch.cpp b/arm9/source/patches/arm9/PokemonDownloaderArm9Patch.cpp index 22666ea..da88e62 100644 --- a/arm9/source/patches/arm9/PokemonDownloaderArm9Patch.cpp +++ b/arm9/source/patches/arm9/PokemonDownloaderArm9Patch.cpp @@ -1,7 +1,7 @@ #include "common.h" #include "../PatchContext.h" #include "../platform/LoaderPlatform.h" -#include "PokemonDownloaderArm9PatchAsm.h" +#include "PokemonDownloaderArm9PatchCode.h" #include "PokemonDownloaderArm9Patch.h" static const u32 sBootFunctionPattern[] = { 0xE92D4010u, 0xE59F003Cu, 0xE5904000u, 0xE3540000u }; diff --git a/arm9/source/patches/arm9/PokemonDownloaderArm9PatchAsm.h b/arm9/source/patches/arm9/PokemonDownloaderArm9PatchCode.h similarity index 75% rename from arm9/source/patches/arm9/PokemonDownloaderArm9PatchAsm.h rename to arm9/source/patches/arm9/PokemonDownloaderArm9PatchCode.h index 4e9dc00..d529b46 100644 --- a/arm9/source/patches/arm9/PokemonDownloaderArm9PatchAsm.h +++ b/arm9/source/patches/arm9/PokemonDownloaderArm9PatchCode.h @@ -1,8 +1,8 @@ #pragma once -#include "../PatchCode.h" +#include "patches/PatchCode.h" #include "sections.h" #include "LoaderInfo.h" -#include "../platform/SdReadPatchCode.h" +#include "patches/platform/IReadSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(patch_pokemondownloader9); @@ -15,11 +15,11 @@ class PokemonDownloaderArm9PatchCode : public PatchCode { public: PokemonDownloaderArm9PatchCode(PatchHeap& patchHeap, const loader_info_t* loaderInfo, - const SdReadPatchCode* sdReadPatchCode) + const IReadSectorsPatchCode* readSectorsPatchCode) : PatchCode(SECTION_START(patch_pokemondownloader9), SECTION_SIZE(patch_pokemondownloader9), patchHeap) { patch_pokemondownloader9_loader_info_address = loaderInfo; - patch_pokemondownloader9_readSdSectors_address = (u32)sdReadPatchCode->GetSdReadFunction(); + patch_pokemondownloader9_readSdSectors_address = (u32)readSectorsPatchCode->GetReadSectorsFunction(); } const void* GetBoot9Function() const diff --git a/arm9/source/patches/arm9/PokemonDownloaderArm9PatchAsm.s b/arm9/source/patches/arm9/PokemonDownloaderArm9PatchCode.s similarity index 100% rename from arm9/source/patches/arm9/PokemonDownloaderArm9PatchAsm.s rename to arm9/source/patches/arm9/PokemonDownloaderArm9PatchCode.s diff --git a/arm9/source/patches/arm9/RomOffsetToSdSectorAsm.h b/arm9/source/patches/arm9/RomOffsetToSdSectorPatchCode.h similarity index 67% rename from arm9/source/patches/arm9/RomOffsetToSdSectorAsm.h rename to arm9/source/patches/arm9/RomOffsetToSdSectorPatchCode.h index 4149980..ba3d7f0 100644 --- a/arm9/source/patches/arm9/RomOffsetToSdSectorAsm.h +++ b/arm9/source/patches/arm9/RomOffsetToSdSectorPatchCode.h @@ -1,6 +1,7 @@ #pragma once #include "sections.h" -#include "../SectorRemapPatchCode.h" +#include "../PatchCode.h" +#include "../ISectorRemapPatchCode.h" #include "fileInfo.h" DEFINE_SECTION_SYMBOLS(romoffsettosdsector); @@ -9,11 +10,11 @@ extern "C" u32 rom_offset_to_sd_sector_asm(u32 romOffset); extern u32 romoffsettosdsector_fatDataPtr; -class RomOffsetToSdSectorPatchCode : public SectorRemapPatchCode +class RomOffsetToSdSectorPatchCode : public PatchCode, public ISectorRemapPatchCode { public: RomOffsetToSdSectorPatchCode(PatchHeap& patchHeap, const rom_file_info_t* fatDataPtr) - : SectorRemapPatchCode(SECTION_START(romoffsettosdsector), SECTION_SIZE(romoffsettosdsector), patchHeap) + : PatchCode(SECTION_START(romoffsettosdsector), SECTION_SIZE(romoffsettosdsector), patchHeap) { romoffsettosdsector_fatDataPtr = (u32)fatDataPtr; } diff --git a/arm9/source/patches/arm9/RomOffsetToSdSectorAsm.s b/arm9/source/patches/arm9/RomOffsetToSdSectorPatchCode.s similarity index 100% rename from arm9/source/patches/arm9/RomOffsetToSdSectorAsm.s rename to arm9/source/patches/arm9/RomOffsetToSdSectorPatchCode.s diff --git a/arm9/source/patches/arm9/sdk2to4/CardiReadCardPatch.cpp b/arm9/source/patches/arm9/sdk2to4/CardiReadCardPatch.cpp index 8a7817a..1fb22b7 100644 --- a/arm9/source/patches/arm9/sdk2to4/CardiReadCardPatch.cpp +++ b/arm9/source/patches/arm9/sdk2to4/CardiReadCardPatch.cpp @@ -3,8 +3,8 @@ #include "fileInfo.h" #include "thumbInstructions.h" #include "patches/platform/LoaderPlatform.h" -#include "patches/arm9/RomOffsetToSdSectorAsm.h" -#include "patches/OffsetToSectorRemapAsm.h" +#include "patches/arm9/RomOffsetToSdSectorPatchCode.h" +#include "patches/OffsetToSectorRemapPatchCode.h" #include "patches/arm9/FixCp15Asm.h" #include "CardiReadCardPatchAsm.h" #include "CardiReadCardPatch.h" @@ -119,7 +119,7 @@ void CardiReadCardPatch::ApplyPatch(PatchContext& patchContext) return new OffsetToSectorRemapPatchCode(patchContext.GetPatchHeap()); }); __patch_cardireadcard_rom_offset_to_sd_sector_asm_address = (u32)offsetToSectorRemapPatchCode->GetRemapFunction(); - __patch_cardireadcard_sdread_asm_address = (u32)romReadPatchCode->GetSdReadFunction(); + __patch_cardireadcard_sdread_asm_address = (u32)romReadPatchCode->GetReadSectorsFunction(); } else { @@ -131,7 +131,7 @@ void CardiReadCardPatch::ApplyPatch(PatchContext& patchContext) (const rom_file_info_t*)((u32)SHARED_ROM_FILE_INFO - 0x02F00000 + 0x02700000)); }); __patch_cardireadcard_rom_offset_to_sd_sector_asm_address = (u32)romOffsetToSdSectorPatchCode->GetRemapFunction(); - __patch_cardireadcard_sdread_asm_address = (u32)sdReadPatchCode->GetSdReadFunction(); + __patch_cardireadcard_sdread_asm_address = (u32)sdReadPatchCode->GetReadSectorsFunction(); } u32 patch4Size = SECTION_SIZE(fixcp15); void* patch4Address = patchContext.GetPatchHeap().Alloc(patch4Size); diff --git a/arm9/source/patches/arm9/sdk2to4/CardiSetCardDmaPatchAsm.h b/arm9/source/patches/arm9/sdk2to4/CardiSetCardDmaPatchCode.h similarity index 69% rename from arm9/source/patches/arm9/sdk2to4/CardiSetCardDmaPatchAsm.h rename to arm9/source/patches/arm9/sdk2to4/CardiSetCardDmaPatchCode.h index f2bf09b..f636a01 100644 --- a/arm9/source/patches/arm9/sdk2to4/CardiSetCardDmaPatchAsm.h +++ b/arm9/source/patches/arm9/sdk2to4/CardiSetCardDmaPatchCode.h @@ -1,8 +1,8 @@ #pragma once #include "patches/PatchCode.h" #include "sections.h" -#include "patches/arm9/RomOffsetToSdSectorAsm.h" -#include "patches/platform/SdReadDmaPatchCode.h" +#include "patches/ISectorRemapPatchCode.h" +#include "patches/platform/IReadSectorsDmaPatchCode.h" DEFINE_SECTION_SYMBOLS(patch_cardisetcarddma); @@ -18,15 +18,16 @@ extern u32 patch_cardionreadcard_sdreaddma_finish_asm_address; class CardiSetCardDmaPatchCode : public PatchCode { public: - CardiSetCardDmaPatchCode(PatchHeap& patchHeap, const RomOffsetToSdSectorPatchCode* romOffsetToSdSectorPatchCode, - const SdReadDmaPatchCode* sdReadDmaPatchCode, const void* cardiCommonPointer, const void* osDisableIrqMaskPointer) + CardiSetCardDmaPatchCode(PatchHeap& patchHeap, const ISectorRemapPatchCode* sectorRemapPatchCode, + const IReadSectorsDmaPatchCode* readSectorsDmaPatchCode, const void* cardiCommonPointer, + const void* osDisableIrqMaskPointer) : PatchCode(SECTION_START(patch_cardisetcarddma), SECTION_SIZE(patch_cardisetcarddma), patchHeap) { patch_cardisetcarddma_cardi_common = (u32)cardiCommonPointer; - patch_cardisetcarddma_rom_offset_to_sd_sector_asm_address = (u32)romOffsetToSdSectorPatchCode->GetRemapFunction(); - patch_cardisetcarddma_sdreaddma_asm_address = (u32)sdReadDmaPatchCode->GetSdReadDmaFunction(); + patch_cardisetcarddma_rom_offset_to_sd_sector_asm_address = (u32)sectorRemapPatchCode->GetRemapFunction(); + patch_cardisetcarddma_sdreaddma_asm_address = (u32)readSectorsDmaPatchCode->GetSdReadDmaFunction(); patch_cardionreadcard_osdisableirqmask_address = (u32)osDisableIrqMaskPointer; - patch_cardionreadcard_sdreaddma_finish_asm_address = (u32)sdReadDmaPatchCode->GetSdReadDmaFinishFunction(); + patch_cardionreadcard_sdreaddma_finish_asm_address = (u32)readSectorsDmaPatchCode->GetSdReadDmaFinishFunction(); } const void* GetCardiSetCardDmaFunction() const diff --git a/arm9/source/patches/arm9/sdk2to4/CardiSetCardDmaPatchAsm.s b/arm9/source/patches/arm9/sdk2to4/CardiSetCardDmaPatchCode.s similarity index 100% rename from arm9/source/patches/arm9/sdk2to4/CardiSetCardDmaPatchAsm.s rename to arm9/source/patches/arm9/sdk2to4/CardiSetCardDmaPatchCode.s diff --git a/arm9/source/patches/arm9/sdk2to4/CardiTryReadCardDmaPatch.cpp b/arm9/source/patches/arm9/sdk2to4/CardiTryReadCardDmaPatch.cpp index eaaed82..b7a4a60 100644 --- a/arm9/source/patches/arm9/sdk2to4/CardiTryReadCardDmaPatch.cpp +++ b/arm9/source/patches/arm9/sdk2to4/CardiTryReadCardDmaPatch.cpp @@ -1,8 +1,9 @@ #include "common.h" #include "patches/PatchContext.h" #include "thumbInstructions.h" -#include "CardiSetCardDmaPatchAsm.h" +#include "CardiSetCardDmaPatchCode.h" #include "patches/platform/LoaderPlatform.h" +#include "patches/arm9/RomOffsetToSdSectorPatchCode.h" #include "CardiTryReadCardDmaPatch.h" static const u32 sCARDiTryReadCardDmaPatternPingPals[] = { 0xE92D47F0u, 0xE1A0A000u, 0xE59F9120u, 0xE3A08000u }; diff --git a/arm9/source/patches/arm9/sdk5/CardiReadRomWithCpuPatch.cpp b/arm9/source/patches/arm9/sdk5/CardiReadRomWithCpuPatch.cpp index 2db0ea9..08b3254 100644 --- a/arm9/source/patches/arm9/sdk5/CardiReadRomWithCpuPatch.cpp +++ b/arm9/source/patches/arm9/sdk5/CardiReadRomWithCpuPatch.cpp @@ -3,8 +3,8 @@ #include "fileInfo.h" #include "thumbInstructions.h" #include "patches/platform/LoaderPlatform.h" -#include "patches/arm9/RomOffsetToSdSectorAsm.h" -#include "patches/OffsetToSectorRemapAsm.h" +#include "patches/arm9/RomOffsetToSdSectorPatchCode.h" +#include "patches/OffsetToSectorRemapPatchCode.h" #include "CardiReadRomWithCpuPatchAsm.h" #include "patches/arm9/FixCp15Asm.h" #include "CardiReadRomWithCpuPatch.h" @@ -88,7 +88,7 @@ void CardiReadRomWithCpuPatch::ApplyPatch(PatchContext& patchContext) return new OffsetToSectorRemapPatchCode(patchContext.GetPatchHeap()); }); __patch_cardireadromwithcpu_rom_offset_to_sd_sector_asm_address = (u32)offsetToSectorRemapPatchCode->GetRemapFunction(); - __patch_cardireadromwithcpu_sdread_asm_address = (u32)romReadPatchCode->GetSdReadFunction(); + __patch_cardireadromwithcpu_sdread_asm_address = (u32)romReadPatchCode->GetReadSectorsFunction(); } else { @@ -99,7 +99,7 @@ void CardiReadRomWithCpuPatch::ApplyPatch(PatchContext& patchContext) return new RomOffsetToSdSectorPatchCode(patchContext.GetPatchHeap(), SHARED_ROM_FILE_INFO); }); __patch_cardireadromwithcpu_rom_offset_to_sd_sector_asm_address = (u32)romOffsetToSdSectorPatchCode->GetRemapFunction(); - __patch_cardireadromwithcpu_sdread_asm_address = (u32)sdReadPatchCode->GetSdReadFunction(); + __patch_cardireadromwithcpu_sdread_asm_address = (u32)sdReadPatchCode->GetReadSectorsFunction(); } u32 patch1Size = SECTION_SIZE(patch_cardireadromwithcpu); diff --git a/arm9/source/patches/platform/SdReadDmaPatchCode.h b/arm9/source/patches/platform/IReadSectorsDmaPatchCode.h similarity index 56% rename from arm9/source/patches/platform/SdReadDmaPatchCode.h rename to arm9/source/patches/platform/IReadSectorsDmaPatchCode.h index aad4431..2d63108 100644 --- a/arm9/source/patches/platform/SdReadDmaPatchCode.h +++ b/arm9/source/patches/platform/IReadSectorsDmaPatchCode.h @@ -1,28 +1,26 @@ #pragma once -#include "../PatchCode.h" -/// @brief Abstract base class for patch code implementing dma SD reads -class SdReadDmaPatchCode : public PatchCode +/// @brief Abstract base class for patch code implementing dma sector reads +class IReadSectorsDmaPatchCode { protected: - SdReadDmaPatchCode(const void* code, u32 size, PatchHeap& patchHeap) - : PatchCode(code, size, patchHeap) { } + IReadSectorsDmaPatchCode() { } public: /// @brief Pointer to a function for reading a single SD sector using the given dmaChannel. /// In first sector of batch read, previousSrcSector will be 0. /// On further reads previousSrcSector will contains the previous srcSector /// which can be used to continue a sequential read. - typedef void (*SdReadDmaFunc)(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst); + typedef void (*ReadSectorsDmaFunc)(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst); /// @brief Pointer to a function for finishing a batch of dma reads. - typedef void (*SdReadDmaFinishFunc)(void); + typedef void (*ReadSectorsDmaFinishFunc)(void); /// @brief Gets a pointer to the dma SD read function in the patch code. /// @return The pointer to the dma SD read function. - virtual const SdReadDmaFunc GetSdReadDmaFunction() const = 0; + virtual const ReadSectorsDmaFunc GetSdReadDmaFunction() const = 0; /// @brief Gets a pointer to the dma SD read finish function in the patch code. /// @return The pointer to the dma SD read finish function. - virtual const SdReadDmaFinishFunc GetSdReadDmaFinishFunction() const = 0; + virtual const ReadSectorsDmaFinishFunc GetSdReadDmaFinishFunction() const = 0; }; diff --git a/arm9/source/patches/platform/IReadSectorsPatchCode.h b/arm9/source/patches/platform/IReadSectorsPatchCode.h new file mode 100644 index 0000000..fa94f6b --- /dev/null +++ b/arm9/source/patches/platform/IReadSectorsPatchCode.h @@ -0,0 +1,17 @@ +#pragma once + +/// @brief Abstract base class for patch code implementing sector reads +class IReadSectorsPatchCode +{ +protected: + IReadSectorsPatchCode() { } + +public: + /// @brief Pointer to a function for reading sectorCount sectors + /// from srcSector to the given dst buffer. + typedef void (*ReadSectorsFunc)(u32 srcSector, void* dst, u32 sectorCount); + + /// @brief Gets a pointer to the sector read function in the patch code. + /// @return The pointer to the sector read function. + virtual const ReadSectorsFunc GetReadSectorsFunction() const = 0; +}; diff --git a/arm9/source/patches/platform/IWriteSectorsPatchCode.h b/arm9/source/patches/platform/IWriteSectorsPatchCode.h new file mode 100644 index 0000000..a795014 --- /dev/null +++ b/arm9/source/patches/platform/IWriteSectorsPatchCode.h @@ -0,0 +1,17 @@ +#pragma once + +/// @brief Abstract base class for patch code implementing sector writes +class IWriteSectorsPatchCode +{ +protected: + IWriteSectorsPatchCode() { } + +public: + /// @brief Pointer to a function for writing sectorCount sectors + /// from the given src buffer to dstSector. + typedef void (*WriteSectorsFunc)(u32 dstSector, const void* src, u32 sectorCount); + + /// @brief Gets a pointer to the sector write function in the patch code. + /// @return The pointer to the sector write function. + virtual const WriteSectorsFunc GetWriteSectorFunction() const = 0; +}; diff --git a/arm9/source/patches/platform/LoaderPlatform.h b/arm9/source/patches/platform/LoaderPlatform.h index cf0e2ef..a0aaf9e 100644 --- a/arm9/source/patches/platform/LoaderPlatform.h +++ b/arm9/source/patches/platform/LoaderPlatform.h @@ -1,8 +1,7 @@ #pragma once -#include -#include "SdReadPatchCode.h" -#include "SdReadDmaPatchCode.h" -#include "SdWritePatchCode.h" +#include "IReadSectorsPatchCode.h" +#include "IReadSectorsDmaPatchCode.h" +#include "IWriteSectorsPatchCode.h" #include "../PatchHeap.h" #include "../PatchCodeCollection.h" #include "LoaderPlatformType.h" @@ -14,29 +13,29 @@ public: /// @brief Creates the SD read patch code for the platform. /// @param patchCodeCollection The patch code collection. /// @param patchHeap The patch heap. - /// @return A unique pointer to the created SD read patch code. - virtual const SdReadPatchCode* CreateSdReadPatchCode( + /// @return A pointer to the created SD read patch code. + virtual const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const = 0; /// @brief Creates the SD read dma patch code for the platform. /// @param patchCodeCollection The patch code collection. /// @param patchHeap The patch heap. - /// @return A unique pointer to the created SD read dma patch code. - virtual const SdReadDmaPatchCode* CreateSdReadDmaPatchCode( + /// @return A pointer to the created SD read dma patch code. + virtual const IReadSectorsDmaPatchCode* CreateSdReadDmaPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) const { return nullptr; } /// @brief Creates the SD write patch code for the platform. /// @param patchCodeCollection The patch code collection. /// @param patchHeap The patch heap. - /// @return A unique pointer to the created SD write patch code. - virtual const SdWritePatchCode* CreateSdWritePatchCode( + /// @return A pointer to the created SD write patch code. + virtual const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const = 0; /// @brief Creates the rom read patch code for the platform. /// @param patchCodeCollection The patch code collection. /// @param patchHeap The patch heap. - /// @return A unique pointer to the created rom read patch code. - virtual const SdReadPatchCode* CreateRomReadPatchCode( + /// @return A pointer to the created rom read patch code. + virtual const IReadSectorsPatchCode* CreateRomReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const { return nullptr; } /// @brief Returns the type of this loader platform. diff --git a/arm9/source/patches/platform/LoaderPlatformFactory.cpp b/arm9/source/patches/platform/LoaderPlatformFactory.cpp index a1297a5..e09a548 100644 --- a/arm9/source/patches/platform/LoaderPlatformFactory.cpp +++ b/arm9/source/patches/platform/LoaderPlatformFactory.cpp @@ -7,12 +7,12 @@ #include "patches/platform/ace3ds/Ace3DSLoaderPlatform.h" #include "patches/platform/g003/G003LoaderPlatform.h" #include "patches/platform/melonds/MelonDSLoaderPlatform.h" -#include "patches/platform/dstt/DSTTLoaderPlatform.h" -#include "patches/platform/ak2/AK2LoaderPlatform.h" -#include "patches/platform/akrpg/AKRPGLoaderPlatform.h" -#include "patches/platform/r4idsn/R4iDSNLoaderPlatform.h" +#include "patches/platform/dstt/DsttLoaderPlatform.h" +#include "patches/platform/ak2/Ak2LoaderPlatform.h" +#include "patches/platform/akrpg/AkRpgLoaderPlatform.h" +#include "patches/platform/r4idsn/R4iDsnLoaderPlatform.h" #include "patches/platform/supercard/SuperCardLoaderPlatform.h" -#include "patches/platform/ezp/EZPLoaderPlatform.h" +#include "patches/platform/ezp/EzpLoaderPlatform.h" #include "patches/platform/datel/DatelLoaderPlatform.h" #include "patches/platform/stargate/StargateLoaderPlatform.h" #include "LoaderPlatformFactory.h" @@ -34,17 +34,17 @@ LoaderPlatform* LoaderPlatformFactory::CreateLoaderPlatform() const #elif defined(PICO_LOADER_TARGET_MELONDS) return new MelonDSLoaderPlatform(); #elif defined(PICO_LOADER_TARGET_DSTT) - return new DSTTLoaderPlatform(); + return new DsttLoaderPlatform(); #elif defined(PICO_LOADER_TARGET_AK2) - return new AK2LoaderPlatform(); + return new Ak2LoaderPlatform(); #elif defined(PICO_LOADER_TARGET_AKRPG) - return new AKRPGLoaderPlatform(); + return new AkRpgLoaderPlatform(); #elif defined(PICO_LOADER_TARGET_R4iDSN) - return new R4iDSNLoaderPlatform(); + return new R4iDsnLoaderPlatform(); #elif defined(PICO_LOADER_TARGET_SUPERCARD) return new SuperCardLoaderPlatform(); #elif defined(PICO_LOADER_TARGET_EZP) - return new EZPLoaderPlatform(); + return new EzpLoaderPlatform(); #elif defined(PICO_LOADER_TARGET_DATEL) return new DatelLoaderPlatform(); #elif defined(PICO_LOADER_TARGET_STARGATE) diff --git a/arm9/source/patches/platform/SdReadPatchCode.h b/arm9/source/patches/platform/SdReadPatchCode.h deleted file mode 100644 index cbedc81..0000000 --- a/arm9/source/patches/platform/SdReadPatchCode.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "../PatchCode.h" - -/// @brief Abstract base class for patch code implementing SD reads -class SdReadPatchCode : public PatchCode -{ -protected: - SdReadPatchCode(const void* code, u32 size, PatchHeap& patchHeap) - : PatchCode(code, size, patchHeap) { } - -public: - /// @brief Pointer to a function for reading sectorCount SD sectors - /// from srcSector to the given dst buffer. - typedef void (*SdReadFunc)(u32 srcSector, void* dst, u32 sectorCount); - - /// @brief Gets a pointer to the SD read function in the patch code. - /// @return The pointer to the SD read function. - virtual const SdReadFunc GetSdReadFunction() const = 0; -}; diff --git a/arm9/source/patches/platform/SdWritePatchCode.h b/arm9/source/patches/platform/SdWritePatchCode.h deleted file mode 100644 index 0213b15..0000000 --- a/arm9/source/patches/platform/SdWritePatchCode.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "../PatchCode.h" - -/// @brief Abstract base class for patch code implementing SD writes -class SdWritePatchCode : public PatchCode -{ -protected: - SdWritePatchCode(const void* code, u32 size, PatchHeap& patchHeap) - : PatchCode(code, size, patchHeap) { } - -public: - /// @brief Pointer to a function for writing sectorCount SD sectors - /// from the given src buffer to dstSector. - typedef void (*SdWriteFunc)(u32 dstSector, const void* src, u32 sectorCount); - - /// @brief Gets a pointer to the SD write function in the patch code. - /// @return The pointer to the SD write function. - virtual const SdWriteFunc GetSdWriteFunction() const = 0; -}; diff --git a/arm9/source/patches/platform/ace3ds/Ace3DSLoaderPlatform.h b/arm9/source/patches/platform/ace3ds/Ace3DSLoaderPlatform.h index fe3772f..3e0fc79 100644 --- a/arm9/source/patches/platform/ace3ds/Ace3DSLoaderPlatform.h +++ b/arm9/source/patches/platform/ace3ds/Ace3DSLoaderPlatform.h @@ -1,15 +1,14 @@ #pragma once -#include "common.h" #include "../LoaderPlatform.h" -#include "ace3dsReadSdAsm.h" -#include "ace3dsReadSdDmaAsm.h" -#include "ace3dsWriteSdAsm.h" +#include "Ace3DSReadSdPatchCode.h" +#include "Ace3DSReadSdDmaPatchCode.h" +#include "Ace3DSWriteSdPatchCode.h" /// @brief Implementation of LoaderPlatform for the Ace3DS+ flashcard class Ace3DSLoaderPlatform : public LoaderPlatform { public: - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -18,14 +17,14 @@ public: }); } - const SdReadDmaPatchCode* CreateSdReadDmaPatchCode(PatchCodeCollection& patchCodeCollection, + const IReadSectorsDmaPatchCode* CreateSdReadDmaPatchCode(PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) const override { return patchCodeCollection.AddUniquePatchCode( patchHeap, miiCardDmaCopy32Ptr); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] diff --git a/arm9/source/patches/platform/ace3ds/Ace3DSReadSdDmaPatchCode.h b/arm9/source/patches/platform/ace3ds/Ace3DSReadSdDmaPatchCode.h new file mode 100644 index 0000000..58fd9b8 --- /dev/null +++ b/arm9/source/patches/platform/ace3ds/Ace3DSReadSdDmaPatchCode.h @@ -0,0 +1,31 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsDmaPatchCode.h" + +DEFINE_SECTION_SYMBOLS(ace3ds_readsddma); + +extern "C" void ace3ds_readSdDma(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst); +extern "C" void ace3ds_finishReadSdDma(void); + +extern u32 ace3ds_readSdDma_miiCardDmaCopy32Ptr; + +class Ace3DSReadSdDmaPatchCode : public PatchCode, public IReadSectorsDmaPatchCode +{ +public: + Ace3DSReadSdDmaPatchCode(PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) + : PatchCode(SECTION_START(ace3ds_readsddma), SECTION_SIZE(ace3ds_readsddma), patchHeap) + { + ace3ds_readSdDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr; + } + + const ReadSectorsDmaFunc GetSdReadDmaFunction() const override + { + return (const ReadSectorsDmaFunc)GetAddressAtTarget((void*)ace3ds_readSdDma); + } + + const ReadSectorsDmaFinishFunc GetSdReadDmaFinishFunction() const override + { + return (const ReadSectorsDmaFinishFunc)GetAddressAtTarget((void*)ace3ds_finishReadSdDma); + } +}; diff --git a/arm9/source/patches/platform/ace3ds/ace3dsReadSdDmaAsm.s b/arm9/source/patches/platform/ace3ds/Ace3DSReadSdDmaPatchCode.s similarity index 100% rename from arm9/source/patches/platform/ace3ds/ace3dsReadSdDmaAsm.s rename to arm9/source/patches/platform/ace3ds/Ace3DSReadSdDmaPatchCode.s diff --git a/arm9/source/patches/platform/ace3ds/Ace3DSReadSdPatchCode.h b/arm9/source/patches/platform/ace3ds/Ace3DSReadSdPatchCode.h new file mode 100644 index 0000000..0327972 --- /dev/null +++ b/arm9/source/patches/platform/ace3ds/Ace3DSReadSdPatchCode.h @@ -0,0 +1,20 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(ace3ds_readsd); + +extern "C" void ace3ds_readSd(u32 srcSector, void* dst, u32 sectorCount); + +class Ace3DSReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode +{ +public: + explicit Ace3DSReadSdPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(ace3ds_readsd), SECTION_SIZE(ace3ds_readsd), patchHeap) { } + + const ReadSectorsFunc GetReadSectorsFunction() const override + { + return (const ReadSectorsFunc)GetAddressAtTarget((void*)ace3ds_readSd); + } +}; diff --git a/arm9/source/patches/platform/ace3ds/ace3dsReadSdAsm.s b/arm9/source/patches/platform/ace3ds/Ace3DSReadSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/ace3ds/ace3dsReadSdAsm.s rename to arm9/source/patches/platform/ace3ds/Ace3DSReadSdPatchCode.s diff --git a/arm9/source/patches/platform/ace3ds/Ace3DSWriteSdPatchCode.h b/arm9/source/patches/platform/ace3ds/Ace3DSWriteSdPatchCode.h new file mode 100644 index 0000000..3e7a865 --- /dev/null +++ b/arm9/source/patches/platform/ace3ds/Ace3DSWriteSdPatchCode.h @@ -0,0 +1,20 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(ace3ds_writesd); + +extern "C" void ace3ds_writeSd(u32 dstSector, const void* src, u32 sectorCount); + +class Ace3DSWriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode +{ +public: + explicit Ace3DSWriteSdPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(ace3ds_writesd), SECTION_SIZE(ace3ds_writesd), patchHeap) { } + + const WriteSectorsFunc GetWriteSectorFunction() const override + { + return (const WriteSectorsFunc)GetAddressAtTarget((void*)ace3ds_writeSd); + } +}; diff --git a/arm9/source/patches/platform/ace3ds/ace3dsWriteSdAsm.s b/arm9/source/patches/platform/ace3ds/Ace3DSWriteSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/ace3ds/ace3dsWriteSdAsm.s rename to arm9/source/patches/platform/ace3ds/Ace3DSWriteSdPatchCode.s diff --git a/arm9/source/patches/platform/ace3ds/ace3dsReadSdAsm.h b/arm9/source/patches/platform/ace3ds/ace3dsReadSdAsm.h deleted file mode 100644 index e1c958a..0000000 --- a/arm9/source/patches/platform/ace3ds/ace3dsReadSdAsm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdReadPatchCode.h" - -DEFINE_SECTION_SYMBOLS(ace3ds_readsd); - -extern "C" void ace3ds_readSd(u32 srcSector, void* dst, u32 sectorCount); - -class Ace3DSReadSdPatchCode : public SdReadPatchCode -{ -public: - explicit Ace3DSReadSdPatchCode(PatchHeap& patchHeap) - : SdReadPatchCode(SECTION_START(ace3ds_readsd), SECTION_SIZE(ace3ds_readsd), patchHeap) { } - - const SdReadFunc GetSdReadFunction() const override - { - return (const SdReadFunc)GetAddressAtTarget((void*)ace3ds_readSd); - } -}; diff --git a/arm9/source/patches/platform/ace3ds/ace3dsReadSdDmaAsm.h b/arm9/source/patches/platform/ace3ds/ace3dsReadSdDmaAsm.h deleted file mode 100644 index 6b69cc2..0000000 --- a/arm9/source/patches/platform/ace3ds/ace3dsReadSdDmaAsm.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdReadDmaPatchCode.h" - -DEFINE_SECTION_SYMBOLS(ace3ds_readsddma); - -extern "C" void ace3ds_readSdDma(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst); -extern "C" void ace3ds_finishReadSdDma(void); - -extern u32 ace3ds_readSdDma_miiCardDmaCopy32Ptr; - -class Ace3DSReadSdDmaPatchCode : public SdReadDmaPatchCode -{ -public: - explicit Ace3DSReadSdDmaPatchCode(PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) - : SdReadDmaPatchCode(SECTION_START(ace3ds_readsddma), SECTION_SIZE(ace3ds_readsddma), patchHeap) - { - ace3ds_readSdDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr; - } - - const SdReadDmaFunc GetSdReadDmaFunction() const override - { - return (const SdReadDmaFunc)GetAddressAtTarget((void*)ace3ds_readSdDma); - } - - const SdReadDmaFinishFunc GetSdReadDmaFinishFunction() const override - { - return (const SdReadDmaFinishFunc)GetAddressAtTarget((void*)ace3ds_finishReadSdDma); - } -}; diff --git a/arm9/source/patches/platform/ace3ds/ace3dsWriteSdAsm.h b/arm9/source/patches/platform/ace3ds/ace3dsWriteSdAsm.h deleted file mode 100644 index 8c134ca..0000000 --- a/arm9/source/patches/platform/ace3ds/ace3dsWriteSdAsm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdWritePatchCode.h" - -DEFINE_SECTION_SYMBOLS(ace3ds_writesd); - -extern "C" void ace3ds_writeSd(u32 dstSector, const void* src, u32 sectorCount); - -class Ace3DSWriteSdPatchCode : public SdWritePatchCode -{ -public: - explicit Ace3DSWriteSdPatchCode(PatchHeap& patchHeap) - : SdWritePatchCode(SECTION_START(ace3ds_writesd), SECTION_SIZE(ace3ds_writesd), patchHeap) { } - - const SdWriteFunc GetSdWriteFunction() const override - { - return (const SdWriteFunc)GetAddressAtTarget((void*)ace3ds_writeSd); - } -}; diff --git a/arm9/source/patches/platform/acekard-common/ioRPGDefinitions.h b/arm9/source/patches/platform/acekard-common/IoRpgDefinitions.h similarity index 95% rename from arm9/source/patches/platform/acekard-common/ioRPGDefinitions.h rename to arm9/source/patches/platform/acekard-common/IoRpgDefinitions.h index 61ca54e..ed8955a 100644 --- a/arm9/source/patches/platform/acekard-common/ioRPGDefinitions.h +++ b/arm9/source/patches/platform/acekard-common/IoRpgDefinitions.h @@ -1,5 +1,4 @@ #pragma once -#include "common.h" #include /// All RPG-based SDIO drivers use this as base, and add latency/size as needed @@ -11,7 +10,7 @@ #define IORPG_CMD_SET_SD_MODE_SDHC (0xC101000000000000ull) /// @brief SDIO parameter types. Used with IORPG_CMD_SDIO command. -enum ioRPGSdioParamTypes +enum IoRpgSdioParamTypes { IORPG_SDIO_NORESPONSE = 0ull, IORPG_SDIO_READ_RESPONSE = 1ull, diff --git a/arm9/source/patches/platform/acekard-common/IoRPGLoaderPlatform.cpp b/arm9/source/patches/platform/acekard-common/IoRpgLoaderPlatform.cpp similarity index 92% rename from arm9/source/patches/platform/acekard-common/IoRPGLoaderPlatform.cpp rename to arm9/source/patches/platform/acekard-common/IoRpgLoaderPlatform.cpp index 125a73d..97f22d8 100644 --- a/arm9/source/patches/platform/acekard-common/IoRPGLoaderPlatform.cpp +++ b/arm9/source/patches/platform/acekard-common/IoRpgLoaderPlatform.cpp @@ -1,11 +1,11 @@ #include "common.h" #include -#include "ioRPGDefinitions.h" +#include "IoRpgDefinitions.h" #include "../SdioDefinitions.h" #include "waitByLoop.h" -#include "IoRPGLoaderPlatform.h" +#include "IoRpgLoaderPlatform.h" -bool IoRPGLoaderPlatform::InitializeSdCard() +bool IoRpgLoaderPlatform::InitializeSdCard() { bool isSdhc = false; bool isSdVersion2 = false; @@ -70,7 +70,7 @@ bool IoRPGLoaderPlatform::InitializeSdCard() return isSuccess; } -void IoRPGLoaderPlatform::SdSendSdioCommand(u64 command, u8* buffer, u32 length) const +void IoRpgLoaderPlatform::SdSendSdioCommand(u64 command, u8* buffer, u32 length) const { u32 flags; if (length == 0) @@ -140,7 +140,7 @@ void IoRPGLoaderPlatform::SdSendSdioCommand(u64 command, u8* buffer, u32 length) card_romWaitBusy(); } -u32 IoRPGLoaderPlatform::SdSendR1Command(u8 cmd, u32 argument) const +u32 IoRpgLoaderPlatform::SdSendR1Command(u8 cmd, u32 argument) const { u64 buffer = 0; SdSendSdioCommand(IoRpgCmdSdio(cmd, IORPG_SDIO_READ_RESPONSE, argument), (u8*)&buffer, SD_R1_RESPONSE_LENGTH_BITS); @@ -148,7 +148,7 @@ u32 IoRPGLoaderPlatform::SdSendR1Command(u8 cmd, u32 argument) const return (u32)(buffer >> 9); } -void IoRPGLoaderPlatform::SdSendR2Command(u8 cmd, u32 argument) const +void IoRpgLoaderPlatform::SdSendR2Command(u8 cmd, u32 argument) const { ALIGN(4) u8 ret[136 >> 3] = {}; SdSendSdioCommand(IoRpgCmdSdio(cmd, IORPG_SDIO_READ_RESPONSE, argument), ret, SD_R2_RESPONSE_LENGTH_BITS); diff --git a/arm9/source/patches/platform/acekard-common/IoRPGLoaderPlatform.h b/arm9/source/patches/platform/acekard-common/IoRpgLoaderPlatform.h similarity index 90% rename from arm9/source/patches/platform/acekard-common/IoRPGLoaderPlatform.h rename to arm9/source/patches/platform/acekard-common/IoRpgLoaderPlatform.h index 3ff5c7f..e822292 100644 --- a/arm9/source/patches/platform/acekard-common/IoRPGLoaderPlatform.h +++ b/arm9/source/patches/platform/acekard-common/IoRpgLoaderPlatform.h @@ -1,14 +1,13 @@ #pragma once -#include "common.h" #include "../LoaderPlatform.h" -#include "iorpgSendSdioCommandAsm.h" -#include "iorpgSdWaitForStateAsm.h" +#include "IoRpgSendSdioCommandPatchCode.h" +#include "IoRpgSdWaitForStatePatchCode.h" /// @brief Implementation of LoaderPlatform for flashcarts based on the Acekard RPG family -class IoRPGLoaderPlatform : public LoaderPlatform +class IoRpgLoaderPlatform : public LoaderPlatform { public: - explicit IoRPGLoaderPlatform(u8 ioRpgCmdSdioByte) + explicit IoRpgLoaderPlatform(u8 ioRpgCmdSdioByte) : _ioRpgCmdSdioByte(ioRpgCmdSdioByte) { } LoaderPlatformType GetPlatformType() const override { return LoaderPlatformType::Slot1; } @@ -42,7 +41,7 @@ private: /// @brief Builds a card command containing the SDIO command, SDIO parameter and the parameter type /// @param SDIO command - /// @param Parameter type seen in ioRPGSdioParamTypes + /// @param Parameter type seen in IoRpgSdioParamTypes /// @param Parameter to SDIO command. /// @return A u64 to be written to REG_MCCMD0 u64 IoRpgCmdSdio(u8 sdio, u8 paramType, u32 parameter) const diff --git a/arm9/source/patches/platform/acekard-common/iorpgSdWaitForStateAsm.h b/arm9/source/patches/platform/acekard-common/IoRpgSdWaitForStatePatchCode.h similarity index 74% rename from arm9/source/patches/platform/acekard-common/iorpgSdWaitForStateAsm.h rename to arm9/source/patches/platform/acekard-common/IoRpgSdWaitForStatePatchCode.h index cc5ee11..59283dd 100644 --- a/arm9/source/patches/platform/acekard-common/iorpgSdWaitForStateAsm.h +++ b/arm9/source/patches/platform/acekard-common/IoRpgSdWaitForStatePatchCode.h @@ -1,15 +1,16 @@ #pragma once #include "sections.h" #include "thumbInstructions.h" +#include "patches/PatchCode.h" DEFINE_SECTION_SYMBOLS(iorpg_sdwaitforstate); extern "C" void iorpg_sdWaitForState(u32 status_shift, u8 state); -class ioRPGSDWaitForStatePatchCode : public PatchCode +class IoRpgSdWaitForStatePatchCode : public PatchCode { public: - explicit ioRPGSDWaitForStatePatchCode(PatchHeap& patchHeap) + explicit IoRpgSdWaitForStatePatchCode(PatchHeap& patchHeap) : PatchCode(SECTION_START(iorpg_sdwaitforstate), SECTION_SIZE(iorpg_sdwaitforstate), patchHeap) { } const void* GetSDWaitForStateFunction() const diff --git a/arm9/source/patches/platform/acekard-common/iorpgSdWaitForStateAsm.s b/arm9/source/patches/platform/acekard-common/IoRpgSdWaitForStatePatchCode.s similarity index 100% rename from arm9/source/patches/platform/acekard-common/iorpgSdWaitForStateAsm.s rename to arm9/source/patches/platform/acekard-common/IoRpgSdWaitForStatePatchCode.s diff --git a/arm9/source/patches/platform/acekard-common/iorpgSendSdioCommandAsm.h b/arm9/source/patches/platform/acekard-common/IoRpgSendSdioCommandPatchCode.h similarity index 75% rename from arm9/source/patches/platform/acekard-common/iorpgSendSdioCommandAsm.h rename to arm9/source/patches/platform/acekard-common/IoRpgSendSdioCommandPatchCode.h index bca82e0..490c11c 100644 --- a/arm9/source/patches/platform/acekard-common/iorpgSendSdioCommandAsm.h +++ b/arm9/source/patches/platform/acekard-common/IoRpgSendSdioCommandPatchCode.h @@ -1,15 +1,16 @@ #pragma once #include "sections.h" #include "thumbInstructions.h" +#include "patches/PatchCode.h" DEFINE_SECTION_SYMBOLS(iorpg_sendsdiocommand); extern "C" void iorpg_sendSdioCommand(u8 sdio, u8 param_type, u32 param, u32 read_len); -class ioRPGSendSDIOCommandPatchCode : public PatchCode +class IoRpgSendSdioCommandPatchCode : public PatchCode { public: - explicit ioRPGSendSDIOCommandPatchCode(PatchHeap& patchHeap) + explicit IoRpgSendSdioCommandPatchCode(PatchHeap& patchHeap) : PatchCode(SECTION_START(iorpg_sendsdiocommand), SECTION_SIZE(iorpg_sendsdiocommand), patchHeap) { } const void* GetSendSdioCommandFunction() const diff --git a/arm9/source/patches/platform/acekard-common/iorpgSendSdioCommandAsm.s b/arm9/source/patches/platform/acekard-common/IoRpgSendSdioCommandPatchCode.s similarity index 100% rename from arm9/source/patches/platform/acekard-common/iorpgSendSdioCommandAsm.s rename to arm9/source/patches/platform/acekard-common/IoRpgSendSdioCommandPatchCode.s diff --git a/arm9/source/patches/platform/ak2/AK2LoaderPlatform.h b/arm9/source/patches/platform/ak2/Ak2LoaderPlatform.h similarity index 62% rename from arm9/source/patches/platform/ak2/AK2LoaderPlatform.h rename to arm9/source/patches/platform/ak2/Ak2LoaderPlatform.h index e305e24..9a35f7f 100644 --- a/arm9/source/patches/platform/ak2/AK2LoaderPlatform.h +++ b/arm9/source/patches/platform/ak2/Ak2LoaderPlatform.h @@ -1,12 +1,11 @@ #pragma once -#include "common.h" -#include "../acekard-common/IoRPGLoaderPlatform.h" -#include "ak2ReadSdAsm.h" -#include "ak2SdReadSectorAsm.h" -#include "ak2WriteSdAsm.h" +#include "../acekard-common/IoRpgLoaderPlatform.h" +#include "Ak2ReadSdPatchCode.h" +#include "Ak2SdReadSectorPatchCode.h" +#include "Ak2WriteSdPatchCode.h" /// @brief Implementation of LoaderPlatform for the Acekard 2 flashcard -class AK2LoaderPlatform : public IoRPGLoaderPlatform +class Ak2LoaderPlatform : public IoRpgLoaderPlatform { private: enum @@ -15,43 +14,43 @@ private: }; public: - AK2LoaderPlatform() : IoRPGLoaderPlatform(IORPG_CMD_SDIO_BYTE) { } + Ak2LoaderPlatform() : IoRpgLoaderPlatform(IORPG_CMD_SDIO_BYTE) { } - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] { auto* waitForStatePatchCode = patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new ioRPGSDWaitForStatePatchCode(patchHeap); + return new IoRpgSdWaitForStatePatchCode(patchHeap); }); - return new AK2ReadSdPatchCode(patchHeap, + return new Ak2ReadSdPatchCode(patchHeap, patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new ioRPGSendSDIOCommandPatchCode(patchHeap); + return new IoRpgSendSdioCommandPatchCode(patchHeap); }), patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new AK2SDReadSectorPatchCode(patchHeap, waitForStatePatchCode); + return new Ak2SdReadSectorPatchCode(patchHeap, waitForStatePatchCode); }), waitForStatePatchCode); }); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new AK2WriteSdPatchCode(patchHeap, + return new Ak2WriteSdPatchCode(patchHeap, patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new ioRPGSendSDIOCommandPatchCode(patchHeap); + return new IoRpgSendSdioCommandPatchCode(patchHeap); }), patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new ioRPGSDWaitForStatePatchCode(patchHeap); + return new IoRpgSdWaitForStatePatchCode(patchHeap); })); }); } diff --git a/arm9/source/patches/platform/ak2/Ak2ReadSdPatchCode.h b/arm9/source/patches/platform/ak2/Ak2ReadSdPatchCode.h new file mode 100644 index 0000000..94f6d75 --- /dev/null +++ b/arm9/source/patches/platform/ak2/Ak2ReadSdPatchCode.h @@ -0,0 +1,37 @@ +#pragma once +#include "sections.h" +#include "thumbInstructions.h" +#include "Ak2SdReadSectorPatchCode.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" +#include "../acekard-common/IoRpgSendSdioCommandPatchCode.h" +#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h" + +DEFINE_SECTION_SYMBOLS(ak2_readsd); + +extern "C" void ak2_readSd(u32 srcSector, void* dst, u32 sectorCount); + +extern u32 ak2_readSd_sendSdioCommand_address; +extern u32 ak2_readSd_sdReadSector_address; +extern u32 ak2_readSd_sdWaitForState_address; +extern u16 ak2_readSd_sdsc_shift; + +class Ak2ReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode +{ +public: + Ak2ReadSdPatchCode(PatchHeap& patchHeap, + const IoRpgSendSdioCommandPatchCode* iorpgSendSdioCommandPatchCode, + const Ak2SdReadSectorPatchCode* ak2SdReadSectorPatchCode, + const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) + : PatchCode(SECTION_START(ak2_readsd), SECTION_SIZE(ak2_readsd), patchHeap) + { + ak2_readSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction(); + ak2_readSd_sdReadSector_address = (u32)ak2SdReadSectorPatchCode->GetSDReadSectorFunction(); + ak2_readSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); + } + + const ReadSectorsFunc GetReadSectorsFunction() const override + { + return (const ReadSectorsFunc)GetAddressAtTarget((void*)ak2_readSd); + } +}; diff --git a/arm9/source/patches/platform/ak2/ak2ReadSdAsm.s b/arm9/source/patches/platform/ak2/Ak2ReadSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/ak2/ak2ReadSdAsm.s rename to arm9/source/patches/platform/ak2/Ak2ReadSdPatchCode.s diff --git a/arm9/source/patches/platform/ak2/ak2SdReadSectorAsm.h b/arm9/source/patches/platform/ak2/Ak2SdReadSectorPatchCode.h similarity index 72% rename from arm9/source/patches/platform/ak2/ak2SdReadSectorAsm.h rename to arm9/source/patches/platform/ak2/Ak2SdReadSectorPatchCode.h index c7507ba..1158e97 100644 --- a/arm9/source/patches/platform/ak2/ak2SdReadSectorAsm.h +++ b/arm9/source/patches/platform/ak2/Ak2SdReadSectorPatchCode.h @@ -1,7 +1,7 @@ #pragma once #include "sections.h" #include "thumbInstructions.h" -#include "../acekard-common/iorpgSdWaitForStateAsm.h" +#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h" DEFINE_SECTION_SYMBOLS(ak2_sdreadsector); @@ -9,11 +9,11 @@ extern "C" void ak2_sdReadSector(u32 srcSector, void* dst, u32 sectorCount); extern u32 ak2_sdReadSector_sdWaitForState_address; -class AK2SDReadSectorPatchCode : public PatchCode +class Ak2SdReadSectorPatchCode : public PatchCode { public: - explicit AK2SDReadSectorPatchCode(PatchHeap& patchHeap, - const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) + explicit Ak2SdReadSectorPatchCode(PatchHeap& patchHeap, + const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) : PatchCode(SECTION_START(ak2_sdreadsector), SECTION_SIZE(ak2_sdreadsector), patchHeap) { ak2_sdReadSector_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); diff --git a/arm9/source/patches/platform/ak2/ak2SdReadSectorAsm.s b/arm9/source/patches/platform/ak2/Ak2SdReadSectorPatchCode.s similarity index 100% rename from arm9/source/patches/platform/ak2/ak2SdReadSectorAsm.s rename to arm9/source/patches/platform/ak2/Ak2SdReadSectorPatchCode.s diff --git a/arm9/source/patches/platform/ak2/Ak2WriteSdPatchCode.h b/arm9/source/patches/platform/ak2/Ak2WriteSdPatchCode.h new file mode 100644 index 0000000..99f4a53 --- /dev/null +++ b/arm9/source/patches/platform/ak2/Ak2WriteSdPatchCode.h @@ -0,0 +1,33 @@ +#pragma once +#include "sections.h" +#include "thumbInstructions.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" +#include "../acekard-common/IoRpgSendSdioCommandPatchCode.h" +#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h" + +DEFINE_SECTION_SYMBOLS(ak2_writesd); + +extern "C" void ak2_writeSd(u32 srcSector, void* dst, u32 sectorCount); + +extern u32 ak2_writeSd_sendSdioCommand_address; +extern u32 ak2_writeSd_sdWaitForState_address; +extern u16 ak2_writeSd_sdsc_shift; + +class Ak2WriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode +{ +public: + Ak2WriteSdPatchCode(PatchHeap& patchHeap, + const IoRpgSendSdioCommandPatchCode* iorpgSendSdioCommandPatchCode, + const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) + : PatchCode(SECTION_START(ak2_writesd), SECTION_SIZE(ak2_writesd), patchHeap) + { + ak2_writeSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction(); + ak2_writeSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); + } + + const WriteSectorsFunc GetWriteSectorFunction() const override + { + return (const WriteSectorsFunc)GetAddressAtTarget((void*)ak2_writeSd); + } +}; diff --git a/arm9/source/patches/platform/ak2/ak2WriteSdAsm.s b/arm9/source/patches/platform/ak2/Ak2WriteSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/ak2/ak2WriteSdAsm.s rename to arm9/source/patches/platform/ak2/Ak2WriteSdPatchCode.s diff --git a/arm9/source/patches/platform/ak2/ak2ReadSdAsm.h b/arm9/source/patches/platform/ak2/ak2ReadSdAsm.h deleted file mode 100644 index 4a9f5dc..0000000 --- a/arm9/source/patches/platform/ak2/ak2ReadSdAsm.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "sections.h" -#include "thumbInstructions.h" -#include "ak2SdReadSectorAsm.h" -#include "../SdReadPatchCode.h" -#include "../acekard-common/iorpgSendSdioCommandAsm.h" -#include "../acekard-common/iorpgSdWaitForStateAsm.h" - -DEFINE_SECTION_SYMBOLS(ak2_readsd); - -extern "C" void ak2_readSd(u32 srcSector, void* dst, u32 sectorCount); - -extern u32 ak2_readSd_sendSdioCommand_address; -extern u32 ak2_readSd_sdReadSector_address; -extern u32 ak2_readSd_sdWaitForState_address; -extern u16 ak2_readSd_sdsc_shift; - -class AK2ReadSdPatchCode : public SdReadPatchCode -{ -public: - explicit AK2ReadSdPatchCode(PatchHeap& patchHeap, - const ioRPGSendSDIOCommandPatchCode* iorpgSendSdioCommandPatchCode, - const AK2SDReadSectorPatchCode* ak2SdReadSectorPatchCode, - const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) - : SdReadPatchCode(SECTION_START(ak2_readsd), SECTION_SIZE(ak2_readsd), patchHeap) - { - ak2_readSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction(); - ak2_readSd_sdReadSector_address = (u32)ak2SdReadSectorPatchCode->GetSDReadSectorFunction(); - ak2_readSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); - } - - const SdReadFunc GetSdReadFunction() const override - { - return (const SdReadFunc)GetAddressAtTarget((void*)ak2_readSd); - } -}; diff --git a/arm9/source/patches/platform/ak2/ak2WriteSdAsm.h b/arm9/source/patches/platform/ak2/ak2WriteSdAsm.h deleted file mode 100644 index 7ac0888..0000000 --- a/arm9/source/patches/platform/ak2/ak2WriteSdAsm.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "sections.h" -#include "thumbInstructions.h" -#include "../SdWritePatchCode.h" -#include "../acekard-common/iorpgSendSdioCommandAsm.h" -#include "../acekard-common/iorpgSdWaitForStateAsm.h" - -DEFINE_SECTION_SYMBOLS(ak2_writesd); - -extern "C" void ak2_writeSd(u32 srcSector, void* dst, u32 sectorCount); - -extern u32 ak2_writeSd_sendSdioCommand_address; -extern u32 ak2_writeSd_sdWaitForState_address; -extern u16 ak2_writeSd_sdsc_shift; - -class AK2WriteSdPatchCode : public SdWritePatchCode -{ -public: - explicit AK2WriteSdPatchCode(PatchHeap& patchHeap, - const ioRPGSendSDIOCommandPatchCode* iorpgSendSdioCommandPatchCode, - const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) - : SdWritePatchCode(SECTION_START(ak2_writesd), SECTION_SIZE(ak2_writesd), patchHeap) - { - ak2_writeSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction(); - ak2_writeSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); - } - - const SdWriteFunc GetSdWriteFunction() const override - { - return (const SdWriteFunc)GetAddressAtTarget((void*)ak2_writeSd); - } -}; diff --git a/arm9/source/patches/platform/akrpg/AKRPGLoaderPlatform.h b/arm9/source/patches/platform/akrpg/AkRpgLoaderPlatform.h similarity index 64% rename from arm9/source/patches/platform/akrpg/AKRPGLoaderPlatform.h rename to arm9/source/patches/platform/akrpg/AkRpgLoaderPlatform.h index b7d6446..cc61c55 100644 --- a/arm9/source/patches/platform/akrpg/AKRPGLoaderPlatform.h +++ b/arm9/source/patches/platform/akrpg/AkRpgLoaderPlatform.h @@ -1,12 +1,11 @@ #pragma once -#include "common.h" #include "../acekard-common/IoRPGLoaderPlatform.h" -#include "akrpgReadSdAsm.h" -#include "akrpgSdReadSectorAsm.h" -#include "akrpgWriteSdAsm.h" +#include "AkRpgReadSdPatchCode.h" +#include "AkRpgSdReadSectorPatchCode.h" +#include "AkRpgWriteSdPatchCode.h" /// @brief Implementation of LoaderPlatform for the Acekard RPG SD card. -class AKRPGLoaderPlatform : public IoRPGLoaderPlatform +class AkRpgLoaderPlatform : public IoRpgLoaderPlatform { private: enum @@ -15,43 +14,43 @@ private: }; public: - AKRPGLoaderPlatform() : IoRPGLoaderPlatform(IORPG_CMD_SDIO_BYTE) { } + AkRpgLoaderPlatform() : IoRpgLoaderPlatform(IORPG_CMD_SDIO_BYTE) { } - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] { auto* waitForStatePatchCode = patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new ioRPGSDWaitForStatePatchCode(patchHeap); + return new IoRpgSdWaitForStatePatchCode(patchHeap); }); - return new AKRPGReadSdPatchCode(patchHeap, + return new AkRpgReadSdPatchCode(patchHeap, patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new ioRPGSendSDIOCommandPatchCode(patchHeap); + return new IoRpgSendSdioCommandPatchCode(patchHeap); }), patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new AKRPGSDReadSectorPatchCode(patchHeap, waitForStatePatchCode); + return new AkRpgSdReadSectorPatchCode(patchHeap, waitForStatePatchCode); }), waitForStatePatchCode); }); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new AKRPGWriteSdPatchCode(patchHeap, + return new AkRpgWriteSdPatchCode(patchHeap, patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new ioRPGSendSDIOCommandPatchCode(patchHeap); + return new IoRpgSendSdioCommandPatchCode(patchHeap); }), patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new ioRPGSDWaitForStatePatchCode(patchHeap); + return new IoRpgSdWaitForStatePatchCode(patchHeap); })); }); } diff --git a/arm9/source/patches/platform/akrpg/AkRpgReadSdPatchCode.h b/arm9/source/patches/platform/akrpg/AkRpgReadSdPatchCode.h new file mode 100644 index 0000000..266be8e --- /dev/null +++ b/arm9/source/patches/platform/akrpg/AkRpgReadSdPatchCode.h @@ -0,0 +1,37 @@ +#pragma once +#include "sections.h" +#include "thumbInstructions.h" +#include "AkRpgSdReadSectorPatchCode.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" +#include "../acekard-common/IoRpgSendSdioCommandPatchCode.h" +#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h" + +DEFINE_SECTION_SYMBOLS(akrpg_readsd); + +extern "C" void akrpg_readSd(u32 srcSector, void* dst, u32 sectorCount); + +extern u32 akrpg_readSd_sendSdioCommand_address; +extern u32 akrpg_readSd_sdReadSector_address; +extern u32 akrpg_readSd_sdWaitForState_address; +extern u16 akrpg_readSd_sdsc_shift; + +class AkRpgReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode +{ +public: + AkRpgReadSdPatchCode(PatchHeap& patchHeap, + const IoRpgSendSdioCommandPatchCode* iorpgSendSdioCommandPatchCode, + const AkRpgSdReadSectorPatchCode* akrpgSdReadSectorPatchCode, + const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) + : PatchCode(SECTION_START(akrpg_readsd), SECTION_SIZE(akrpg_readsd), patchHeap) + { + akrpg_readSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction(); + akrpg_readSd_sdReadSector_address = (u32)akrpgSdReadSectorPatchCode->GetSDReadSectorFunction(); + akrpg_readSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); + } + + const ReadSectorsFunc GetReadSectorsFunction() const override + { + return (const ReadSectorsFunc)GetAddressAtTarget((void*)akrpg_readSd); + } +}; diff --git a/arm9/source/patches/platform/akrpg/akrpgReadSdAsm.s b/arm9/source/patches/platform/akrpg/AkRpgReadSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/akrpg/akrpgReadSdAsm.s rename to arm9/source/patches/platform/akrpg/AkRpgReadSdPatchCode.s diff --git a/arm9/source/patches/platform/akrpg/akrpgSdReadSectorAsm.h b/arm9/source/patches/platform/akrpg/AkRpgSdReadSectorPatchCode.h similarity index 72% rename from arm9/source/patches/platform/akrpg/akrpgSdReadSectorAsm.h rename to arm9/source/patches/platform/akrpg/AkRpgSdReadSectorPatchCode.h index 7ab9e03..aa76fb1 100644 --- a/arm9/source/patches/platform/akrpg/akrpgSdReadSectorAsm.h +++ b/arm9/source/patches/platform/akrpg/AkRpgSdReadSectorPatchCode.h @@ -1,7 +1,7 @@ #pragma once #include "sections.h" #include "thumbInstructions.h" -#include "../acekard-common/iorpgSdWaitForStateAsm.h" +#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h" DEFINE_SECTION_SYMBOLS(akrpg_sdreadsector); @@ -9,11 +9,11 @@ extern "C" void akrpg_sdReadSector(u32 srcSector, void* dst, u32 sectorCount); extern u32 akrpg_sdReadSector_sdWaitForState_address; -class AKRPGSDReadSectorPatchCode : public PatchCode +class AkRpgSdReadSectorPatchCode : public PatchCode { public: - explicit AKRPGSDReadSectorPatchCode(PatchHeap& patchHeap, - const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) + explicit AkRpgSdReadSectorPatchCode(PatchHeap& patchHeap, + const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) : PatchCode(SECTION_START(akrpg_sdreadsector), SECTION_SIZE(akrpg_sdreadsector), patchHeap) { akrpg_sdReadSector_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); diff --git a/arm9/source/patches/platform/akrpg/akrpgSdReadSectorAsm.s b/arm9/source/patches/platform/akrpg/AkRpgSdReadSectorPatchCode.s similarity index 100% rename from arm9/source/patches/platform/akrpg/akrpgSdReadSectorAsm.s rename to arm9/source/patches/platform/akrpg/AkRpgSdReadSectorPatchCode.s diff --git a/arm9/source/patches/platform/akrpg/AkRpgWriteSdPatchCode.h b/arm9/source/patches/platform/akrpg/AkRpgWriteSdPatchCode.h new file mode 100644 index 0000000..13c4ef9 --- /dev/null +++ b/arm9/source/patches/platform/akrpg/AkRpgWriteSdPatchCode.h @@ -0,0 +1,33 @@ +#pragma once +#include "sections.h" +#include "thumbInstructions.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" +#include "../acekard-common/IoRpgSendSdioCommandPatchCode.h" +#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h" + +DEFINE_SECTION_SYMBOLS(akrpg_writesd); + +extern "C" void akrpg_writeSd(u32 srcSector, void* dst, u32 sectorCount); + +extern u32 akrpg_writeSd_sendSdioCommand_address; +extern u32 akrpg_writeSd_sdWaitForState_address; +extern u16 akrpg_writeSd_sdsc_shift; + +class AkRpgWriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode +{ +public: + AkRpgWriteSdPatchCode(PatchHeap& patchHeap, + const IoRpgSendSdioCommandPatchCode* iorpgSendSdioCommandPatchCode, + const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) + : PatchCode(SECTION_START(akrpg_writesd), SECTION_SIZE(akrpg_writesd), patchHeap) + { + akrpg_writeSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction(); + akrpg_writeSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); + } + + const WriteSectorsFunc GetWriteSectorFunction() const override + { + return (const WriteSectorsFunc)GetAddressAtTarget((void*)akrpg_writeSd); + } +}; diff --git a/arm9/source/patches/platform/akrpg/akrpgWriteSdAsm.s b/arm9/source/patches/platform/akrpg/AkRpgWriteSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/akrpg/akrpgWriteSdAsm.s rename to arm9/source/patches/platform/akrpg/AkRpgWriteSdPatchCode.s diff --git a/arm9/source/patches/platform/akrpg/akrpgReadSdAsm.h b/arm9/source/patches/platform/akrpg/akrpgReadSdAsm.h deleted file mode 100644 index 68ba3b7..0000000 --- a/arm9/source/patches/platform/akrpg/akrpgReadSdAsm.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "sections.h" -#include "thumbInstructions.h" -#include "akrpgSdReadSectorAsm.h" -#include "../SdReadPatchCode.h" -#include "../acekard-common/iorpgSendSdioCommandAsm.h" -#include "../acekard-common/iorpgSdWaitForStateAsm.h" - -DEFINE_SECTION_SYMBOLS(akrpg_readsd); - -extern "C" void akrpg_readSd(u32 srcSector, void* dst, u32 sectorCount); - -extern u32 akrpg_readSd_sendSdioCommand_address; -extern u32 akrpg_readSd_sdReadSector_address; -extern u32 akrpg_readSd_sdWaitForState_address; -extern u16 akrpg_readSd_sdsc_shift; - -class AKRPGReadSdPatchCode : public SdReadPatchCode -{ -public: - explicit AKRPGReadSdPatchCode(PatchHeap& patchHeap, - const ioRPGSendSDIOCommandPatchCode* iorpgSendSdioCommandPatchCode, - const AKRPGSDReadSectorPatchCode* akrpgSdReadSectorPatchCode, - const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) - : SdReadPatchCode(SECTION_START(akrpg_readsd), SECTION_SIZE(akrpg_readsd), patchHeap) - { - akrpg_readSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction(); - akrpg_readSd_sdReadSector_address = (u32)akrpgSdReadSectorPatchCode->GetSDReadSectorFunction(); - akrpg_readSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); - } - - const SdReadFunc GetSdReadFunction() const override - { - return (const SdReadFunc)GetAddressAtTarget((void*)akrpg_readSd); - } -}; diff --git a/arm9/source/patches/platform/akrpg/akrpgWriteSdAsm.h b/arm9/source/patches/platform/akrpg/akrpgWriteSdAsm.h deleted file mode 100644 index 4e8ca54..0000000 --- a/arm9/source/patches/platform/akrpg/akrpgWriteSdAsm.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "sections.h" -#include "thumbInstructions.h" -#include "../SdWritePatchCode.h" -#include "../acekard-common/iorpgSendSdioCommandAsm.h" -#include "../acekard-common/iorpgSdWaitForStateAsm.h" - -DEFINE_SECTION_SYMBOLS(akrpg_writesd); - -extern "C" void akrpg_writeSd(u32 srcSector, void* dst, u32 sectorCount); - -extern u32 akrpg_writeSd_sendSdioCommand_address; -extern u32 akrpg_writeSd_sdWaitForState_address; -extern u16 akrpg_writeSd_sdsc_shift; - -class AKRPGWriteSdPatchCode : public SdWritePatchCode -{ -public: - explicit AKRPGWriteSdPatchCode(PatchHeap& patchHeap, - const ioRPGSendSDIOCommandPatchCode* iorpgSendSdioCommandPatchCode, - const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) - : SdWritePatchCode(SECTION_START(akrpg_writesd), SECTION_SIZE(akrpg_writesd), patchHeap) - { - akrpg_writeSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction(); - akrpg_writeSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); - } - - const SdWriteFunc GetSdWriteFunction() const override - { - return (const SdWriteFunc)GetAddressAtTarget((void*)akrpg_writeSd); - } -}; diff --git a/arm9/source/patches/platform/datel/DatelLoaderPlatform.h b/arm9/source/patches/platform/datel/DatelLoaderPlatform.h index 0c6bed1..b98577a 100644 --- a/arm9/source/patches/platform/datel/DatelLoaderPlatform.h +++ b/arm9/source/patches/platform/datel/DatelLoaderPlatform.h @@ -1,15 +1,14 @@ #pragma once -#include "common.h" #include "../LoaderPlatform.h" -#include "DatelSpiCommandsAsm.h" -#include "DatelReadSectorsAsm.h" -#include "DatelWriteSectorsAsm.h" +#include "DatelSendSdioCommandPatchCode.h" +#include "DatelReadSdPatchCode.h" +#include "DatelWriteSdPatchCode.h" /// @brief Implementation of LoaderPlatform for the DATEL line of flashcarts class DatelLoaderPlatform : public LoaderPlatform { public: - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { auto spi = patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -18,7 +17,7 @@ public: }); auto sendSdio = patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new DatelSendSDIOCommandPatchCode(patchHeap, spi); + return new DatelSendSdioCommandPatchCode(patchHeap, spi); }); return patchCodeCollection.GetOrAddSharedPatchCode([&] { @@ -26,7 +25,7 @@ public: }); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { auto spi = patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -35,7 +34,7 @@ public: }); auto sendSdio = patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new DatelSendSDIOCommandPatchCode(patchHeap, spi); + return new DatelSendSdioCommandPatchCode(patchHeap, spi); }); return patchCodeCollection.GetOrAddSharedPatchCode([&] { diff --git a/arm9/source/patches/platform/datel/DatelReadSectorsAsm.h b/arm9/source/patches/platform/datel/DatelReadSdPatchCode.h similarity index 66% rename from arm9/source/patches/platform/datel/DatelReadSectorsAsm.h rename to arm9/source/patches/platform/datel/DatelReadSdPatchCode.h index 46b2ffd..1ce5bae 100644 --- a/arm9/source/patches/platform/datel/DatelReadSectorsAsm.h +++ b/arm9/source/patches/platform/datel/DatelReadSdPatchCode.h @@ -1,6 +1,8 @@ #pragma once #include "sections.h" -#include "../SdReadPatchCode.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" + DEFINE_SECTION_SYMBOLS(datel_read); extern u16 datel_readSectorSdhcLabel; @@ -12,13 +14,13 @@ extern u32 datel_SDReadMultipleSector_ReadSpiShort; extern "C" void datel_SDReadMultipleSector(u32 srcSector, void* dst, u32 sectorCount); -class DatelReadSdPatchCode : public SdReadPatchCode +class DatelReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode { public: DatelReadSdPatchCode(PatchHeap& patchHeap, const DatelReadSpiBytePatchCode* datelReadSpiBytePatchCode, - const DatelSendSDIOCommandPatchCode* datelSendSDIOCommandPatchCode) - : SdReadPatchCode(SECTION_START(datel_read), SECTION_SIZE(datel_read), patchHeap) + const DatelSendSdioCommandPatchCode* datelSendSDIOCommandPatchCode) + : PatchCode(SECTION_START(datel_read), SECTION_SIZE(datel_read), patchHeap) { datel_SDReadMultipleSector_SpiSendSDIOCommandR0 = (u32)datelSendSDIOCommandPatchCode->GetSpiSendSDIOCommandR0Function(); @@ -26,8 +28,8 @@ public: datel_SDReadMultipleSector_ReadSpiShort = (u32)datelReadSpiBytePatchCode->GetReadSpiShortFunction(); } - const SdReadFunc GetSdReadFunction() const override + const ReadSectorsFunc GetReadSectorsFunction() const override { - return (const SdReadFunc)GetAddressAtTarget((void*)datel_SDReadMultipleSector); + return (const ReadSectorsFunc)GetAddressAtTarget((void*)datel_SDReadMultipleSector); } }; diff --git a/arm9/source/patches/platform/datel/DatelReadSectorsAsm.s b/arm9/source/patches/platform/datel/DatelReadSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/datel/DatelReadSectorsAsm.s rename to arm9/source/patches/platform/datel/DatelReadSdPatchCode.s diff --git a/arm9/source/patches/platform/datel/DatelSpiCommandsAsm.h b/arm9/source/patches/platform/datel/DatelSendSdioCommandPatchCode.h similarity index 90% rename from arm9/source/patches/platform/datel/DatelSpiCommandsAsm.h rename to arm9/source/patches/platform/datel/DatelSendSdioCommandPatchCode.h index 1a38615..86a4f32 100644 --- a/arm9/source/patches/platform/datel/DatelSpiCommandsAsm.h +++ b/arm9/source/patches/platform/datel/DatelSendSdioCommandPatchCode.h @@ -1,6 +1,6 @@ #pragma once #include "sections.h" -#include "../SdReadDmaPatchCode.h" +#include "patches/PatchCode.h" DEFINE_SECTION_SYMBOLS(datel_read_spi); DEFINE_SECTION_SYMBOLS(datel_spi_send); @@ -49,11 +49,10 @@ public: } }; -class DatelSendSDIOCommandPatchCode : public PatchCode +class DatelSendSdioCommandPatchCode : public PatchCode { public: - DatelSendSDIOCommandPatchCode(PatchHeap& patchHeap, - const DatelReadSpiBytePatchCode* datelReadSpiBytePatchCode) + DatelSendSdioCommandPatchCode(PatchHeap& patchHeap, const DatelReadSpiBytePatchCode* datelReadSpiBytePatchCode) : PatchCode(SECTION_START(datel_spi_send), SECTION_SIZE(datel_spi_send), patchHeap) { datel_spiSendSDIOCommandR0_ReadWriteSpiByte = (u32)datelReadSpiBytePatchCode->GetReadWriteSpiByteFunction(); diff --git a/arm9/source/patches/platform/datel/DatelSpiCommandsAsm.s b/arm9/source/patches/platform/datel/DatelSendSdioCommandPatchCode.s similarity index 100% rename from arm9/source/patches/platform/datel/DatelSpiCommandsAsm.s rename to arm9/source/patches/platform/datel/DatelSendSdioCommandPatchCode.s diff --git a/arm9/source/patches/platform/datel/DatelWriteSectorsAsm.h b/arm9/source/patches/platform/datel/DatelWriteSdPatchCode.h similarity index 66% rename from arm9/source/patches/platform/datel/DatelWriteSectorsAsm.h rename to arm9/source/patches/platform/datel/DatelWriteSdPatchCode.h index b884f3e..246b732 100644 --- a/arm9/source/patches/platform/datel/DatelWriteSectorsAsm.h +++ b/arm9/source/patches/platform/datel/DatelWriteSdPatchCode.h @@ -1,6 +1,7 @@ #pragma once #include "sections.h" -#include "../SdWritePatchCode.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(datel_write); @@ -13,13 +14,13 @@ extern u32 datel_SDWriteMultipleSector_ReadSpiByte; extern "C" void datel_SDWriteMultipleSector(u32 srcSector, void* dst, u32 sectorCount); -class DatelWriteSdPatchCode : public SdWritePatchCode +class DatelWriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode { public: DatelWriteSdPatchCode(PatchHeap& patchHeap, const DatelReadSpiBytePatchCode* datelReadSpiBytePatchCode, - const DatelSendSDIOCommandPatchCode* datelSendSDIOCommandPatchCode) - : SdWritePatchCode(SECTION_START(datel_write), SECTION_SIZE(datel_write), patchHeap) + const DatelSendSdioCommandPatchCode* datelSendSDIOCommandPatchCode) + : PatchCode(SECTION_START(datel_write), SECTION_SIZE(datel_write), patchHeap) { datel_SDWriteMultipleSector_SpiSendSDIOCommand = (u32)datelSendSDIOCommandPatchCode->GetSpiSendSDIOCommandFunction(); @@ -27,8 +28,8 @@ public: datel_SDWriteMultipleSector_ReadSpiByte = (u32)datelReadSpiBytePatchCode->GetReadSpiByteFunction(); } - const SdWriteFunc GetSdWriteFunction() const override + const WriteSectorsFunc GetWriteSectorFunction() const override { - return (const SdWriteFunc)GetAddressAtTarget((void*)datel_SDWriteMultipleSector); + return (const WriteSectorsFunc)GetAddressAtTarget((void*)datel_SDWriteMultipleSector); } }; diff --git a/arm9/source/patches/platform/datel/DatelWriteSectorsAsm.s b/arm9/source/patches/platform/datel/DatelWriteSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/datel/DatelWriteSectorsAsm.s rename to arm9/source/patches/platform/datel/DatelWriteSdPatchCode.s diff --git a/arm9/source/patches/platform/dspico/DSPicoLoaderPlatform.h b/arm9/source/patches/platform/dspico/DSPicoLoaderPlatform.h index 1ccf414..cb10901 100644 --- a/arm9/source/patches/platform/dspico/DSPicoLoaderPlatform.h +++ b/arm9/source/patches/platform/dspico/DSPicoLoaderPlatform.h @@ -1,15 +1,14 @@ #pragma once -#include "common.h" #include "../LoaderPlatform.h" -#include "dspicoReadSectorsAsm.h" -#include "dspicoReadSdSectorDmaAsm.h" -#include "dspicoWriteSectorsAsm.h" +#include "DSPicoReadSdSectorsPatchCode.h" +#include "DSPicoReadSdSectorDmaPatchCode.h" +#include "DSPicoWriteSdSectorsPatchCode.h" /// @brief Implementation of LoaderPlatform for the DS pico flashcard class DSPicoLoaderPlatform : public LoaderPlatform { public: - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -22,7 +21,7 @@ public: }); } - const SdReadDmaPatchCode* CreateSdReadDmaPatchCode(PatchCodeCollection& patchCodeCollection, + const IReadSectorsDmaPatchCode* CreateSdReadDmaPatchCode(PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) const override { auto pollSdDataReadyPatchCode = patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -34,7 +33,7 @@ public: patchHeap, pollSdDataReadyPatchCode, miiCardDmaCopy32Ptr); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] diff --git a/arm9/source/patches/platform/dspico/dspicoReadSdSectorDmaAsm.h b/arm9/source/patches/platform/dspico/DSPicoReadSdSectorDmaPatchCode.h similarity index 65% rename from arm9/source/patches/platform/dspico/dspicoReadSdSectorDmaAsm.h rename to arm9/source/patches/platform/dspico/DSPicoReadSdSectorDmaPatchCode.h index 4caea0a..1377c90 100644 --- a/arm9/source/patches/platform/dspico/dspicoReadSdSectorDmaAsm.h +++ b/arm9/source/patches/platform/dspico/DSPicoReadSdSectorDmaPatchCode.h @@ -1,6 +1,7 @@ #pragma once #include "sections.h" -#include "../SdReadDmaPatchCode.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsDmaPatchCode.h" DEFINE_SECTION_SYMBOLS(dspico_readsdsectordma); DEFINE_SECTION_SYMBOLS(dspico_readsdsectordma_pollSdDataReady); @@ -23,34 +24,34 @@ public: return GetAddressAtTarget((void*)dspico_readSdSectorDma_pollSdDataReady); } - const SdReadDmaPatchCode::SdReadDmaFinishFunc GetSdReadDmaFinishFunction() const + const IReadSectorsDmaPatchCode::ReadSectorsDmaFinishFunc GetSdReadDmaFinishFunction() const { - return (const SdReadDmaPatchCode::SdReadDmaFinishFunc)GetAddressAtTarget((void*)dspico_finishReadSdSectorDma); + return (const IReadSectorsDmaPatchCode::ReadSectorsDmaFinishFunc)GetAddressAtTarget((void*)dspico_finishReadSdSectorDma); } }; -class DSPicoReadSdSectorDmaPatchCode : public SdReadDmaPatchCode +class DSPicoReadSdSectorDmaPatchCode : public PatchCode, public IReadSectorsDmaPatchCode { public: DSPicoReadSdSectorDmaPatchCode(PatchHeap& patchHeap, const DSPicoReadSdSectorDmaPollSdDataReadyPatchCode* pollSdDataReadyPatchCode, const void* miiCardDmaCopy32Ptr) - : SdReadDmaPatchCode(SECTION_START(dspico_readsdsectordma), SECTION_SIZE(dspico_readsdsectordma), patchHeap) + : PatchCode(SECTION_START(dspico_readsdsectordma), SECTION_SIZE(dspico_readsdsectordma), patchHeap) , _sdReadDmaFinishFunc(pollSdDataReadyPatchCode->GetSdReadDmaFinishFunction()) { dspico_readSdSectorDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr; dspico_readSdSectorDma_pollSdDataReadyPtr = (u32)pollSdDataReadyPatchCode->GetPollSdDataReadyFunction(); } - const SdReadDmaFunc GetSdReadDmaFunction() const override + const ReadSectorsDmaFunc GetSdReadDmaFunction() const override { - return (const SdReadDmaFunc)GetAddressAtTarget((void*)dspico_readSdSectorDma); + return (const ReadSectorsDmaFunc)GetAddressAtTarget((void*)dspico_readSdSectorDma); } - const SdReadDmaFinishFunc GetSdReadDmaFinishFunction() const override + const ReadSectorsDmaFinishFunc GetSdReadDmaFinishFunction() const override { return _sdReadDmaFinishFunc; } private: - const SdReadDmaFinishFunc _sdReadDmaFinishFunc; + const ReadSectorsDmaFinishFunc _sdReadDmaFinishFunc; }; diff --git a/arm9/source/patches/platform/dspico/dspicoReadSdSectorDmaAsm.s b/arm9/source/patches/platform/dspico/DSPicoReadSdSectorDmaPatchCode.s similarity index 100% rename from arm9/source/patches/platform/dspico/dspicoReadSdSectorDmaAsm.s rename to arm9/source/patches/platform/dspico/DSPicoReadSdSectorDmaPatchCode.s diff --git a/arm9/source/patches/platform/dspico/dspicoReadSectorsAsm.h b/arm9/source/patches/platform/dspico/DSPicoReadSdSectorsPatchCode.h similarity index 71% rename from arm9/source/patches/platform/dspico/dspicoReadSectorsAsm.h rename to arm9/source/patches/platform/dspico/DSPicoReadSdSectorsPatchCode.h index 7bc5a67..d5263a9 100644 --- a/arm9/source/patches/platform/dspico/dspicoReadSectorsAsm.h +++ b/arm9/source/patches/platform/dspico/DSPicoReadSdSectorsPatchCode.h @@ -1,6 +1,7 @@ #pragma once #include "sections.h" -#include "../SdReadPatchCode.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(dspico_readsdsectors); DEFINE_SECTION_SYMBOLS(dspico_readsdsectors_readdirect); @@ -22,17 +23,17 @@ public: } }; -class DSPicoReadSdSectorsPatchCode : public SdReadPatchCode +class DSPicoReadSdSectorsPatchCode : public PatchCode, public IReadSectorsPatchCode { public: DSPicoReadSdSectorsPatchCode(PatchHeap& patchHeap, const DSPicoReadSdSectorsDirectPatchCode* readSdSectorsDirectPatchCode) - : SdReadPatchCode(SECTION_START(dspico_readsdsectors), SECTION_SIZE(dspico_readsdsectors), patchHeap) + : PatchCode(SECTION_START(dspico_readsdsectors), SECTION_SIZE(dspico_readsdsectors), patchHeap) { dspico_readsdsectors_readDirectAddress = (u32)readSdSectorsDirectPatchCode->GetReadSdSectorsDirectFunction(); } - const SdReadFunc GetSdReadFunction() const override + const ReadSectorsFunc GetReadSectorsFunction() const override { - return (const SdReadFunc)GetAddressAtTarget((void*)dspico_readSdSectors); + return (const ReadSectorsFunc)GetAddressAtTarget((void*)dspico_readSdSectors); } }; diff --git a/arm9/source/patches/platform/dspico/dspicoReadSectorsAsm.s b/arm9/source/patches/platform/dspico/DSPicoReadSdSectorsPatchCode.s similarity index 100% rename from arm9/source/patches/platform/dspico/dspicoReadSectorsAsm.s rename to arm9/source/patches/platform/dspico/DSPicoReadSdSectorsPatchCode.s diff --git a/arm9/source/patches/platform/dspico/DSPicoWriteSdSectorsPatchCode.h b/arm9/source/patches/platform/dspico/DSPicoWriteSdSectorsPatchCode.h new file mode 100644 index 0000000..d0201f6 --- /dev/null +++ b/arm9/source/patches/platform/dspico/DSPicoWriteSdSectorsPatchCode.h @@ -0,0 +1,20 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(dspico_writesdsectors); + +extern "C" void dspico_writeSdSectors(u32 dstSector, const void* src, u32 sectorCount); + +class DSPicoWriteSdSectorsPatchCode : public PatchCode, public IWriteSectorsPatchCode +{ +public: + explicit DSPicoWriteSdSectorsPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(dspico_writesdsectors), SECTION_SIZE(dspico_writesdsectors), patchHeap) { } + + const WriteSectorsFunc GetWriteSectorFunction() const override + { + return (const WriteSectorsFunc)GetAddressAtTarget((void*)dspico_writeSdSectors); + } +}; diff --git a/arm9/source/patches/platform/dspico/dspicoWriteSectorsAsm.s b/arm9/source/patches/platform/dspico/DSPicoWriteSdSectorsPatchCode.s similarity index 100% rename from arm9/source/patches/platform/dspico/dspicoWriteSectorsAsm.s rename to arm9/source/patches/platform/dspico/DSPicoWriteSdSectorsPatchCode.s diff --git a/arm9/source/patches/platform/dspico/dspicoWriteSectorsAsm.h b/arm9/source/patches/platform/dspico/dspicoWriteSectorsAsm.h deleted file mode 100644 index c20270c..0000000 --- a/arm9/source/patches/platform/dspico/dspicoWriteSectorsAsm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdWritePatchCode.h" - -DEFINE_SECTION_SYMBOLS(dspico_writesdsectors); - -extern "C" void dspico_writeSdSectors(u32 dstSector, const void* src, u32 sectorCount); - -class DSPicoWriteSdSectorsPatchCode : public SdWritePatchCode -{ -public: - explicit DSPicoWriteSdSectorsPatchCode(PatchHeap& patchHeap) - : SdWritePatchCode(SECTION_START(dspico_writesdsectors), SECTION_SIZE(dspico_writesdsectors), patchHeap) { } - - const SdWriteFunc GetSdWriteFunction() const override - { - return (const SdWriteFunc)GetAddressAtTarget((void*)dspico_writeSdSectors); - } -}; diff --git a/arm9/source/patches/platform/dstt/dsttDefinitions.h b/arm9/source/patches/platform/dstt/DsttDefinitions.h similarity index 100% rename from arm9/source/patches/platform/dstt/dsttDefinitions.h rename to arm9/source/patches/platform/dstt/DsttDefinitions.h diff --git a/arm9/source/patches/platform/dstt/DSTTLoaderPlatform.cpp b/arm9/source/patches/platform/dstt/DsttLoaderPlatform.cpp similarity index 98% rename from arm9/source/patches/platform/dstt/DSTTLoaderPlatform.cpp rename to arm9/source/patches/platform/dstt/DsttLoaderPlatform.cpp index 02e6969..4427498 100644 --- a/arm9/source/patches/platform/dstt/DSTTLoaderPlatform.cpp +++ b/arm9/source/patches/platform/dstt/DsttLoaderPlatform.cpp @@ -1,6 +1,6 @@ #include "common.h" #include -#include "dsttDefinitions.h" +#include "DsttDefinitions.h" #include "../SdioDefinitions.h" #include "waitByLoop.h" #include "DSTTLoaderPlatform.h" @@ -92,7 +92,7 @@ static void sdHostSetRegister(u8 bits) waitByLoop(0x600); } -bool DSTTLoaderPlatform::InitializeSdCard(void) +bool DsttLoaderPlatform::InitializeSdCard(void) { bool isSdVersion2 = false; bool isSdhc = false; diff --git a/arm9/source/patches/platform/dstt/DSTTLoaderPlatform.h b/arm9/source/patches/platform/dstt/DsttLoaderPlatform.h similarity index 64% rename from arm9/source/patches/platform/dstt/DSTTLoaderPlatform.h rename to arm9/source/patches/platform/dstt/DsttLoaderPlatform.h index da6eafb..3d0f7e3 100644 --- a/arm9/source/patches/platform/dstt/DSTTLoaderPlatform.h +++ b/arm9/source/patches/platform/dstt/DsttLoaderPlatform.h @@ -1,35 +1,34 @@ #pragma once -#include "common.h" #include "../LoaderPlatform.h" -#include "dsttReadSdAsm.h" -#include "dsttWriteSdAsm.h" +#include "DsttReadSdPatchCode.h" +#include "DsttWriteSdPatchCode.h" /// @brief Implementation of LoaderPlatform for the DSTT flashcard -class DSTTLoaderPlatform : public LoaderPlatform +class DsttLoaderPlatform : public LoaderPlatform { public: - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new DSTTReadSdPatchCode(patchHeap, + return new DsttReadSdPatchCode(patchHeap, patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new DSTTReadSdStopTransmissionPatchCode(patchHeap); + return new DsttReadSdStopTransmissionPatchCode(patchHeap); })); }); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new DSTTWriteSdPatchCode(patchHeap, + return new DsttWriteSdPatchCode(patchHeap, patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new DSTTWriteSdContinuePatchCode(patchHeap); + return new DsttWriteSdContinuePatchCode(patchHeap); })); }); } diff --git a/arm9/source/patches/platform/dstt/dsttReadSdAsm.h b/arm9/source/patches/platform/dstt/DsttReadSdPatchCode.h similarity index 56% rename from arm9/source/patches/platform/dstt/dsttReadSdAsm.h rename to arm9/source/patches/platform/dstt/DsttReadSdPatchCode.h index 5266067..498c55c 100644 --- a/arm9/source/patches/platform/dstt/dsttReadSdAsm.h +++ b/arm9/source/patches/platform/dstt/DsttReadSdPatchCode.h @@ -1,7 +1,8 @@ #pragma once #include "sections.h" #include "thumbInstructions.h" -#include "../SdReadPatchCode.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(dstt_readsd); DEFINE_SECTION_SYMBOLS(dstt_readsd_stopTransmission); @@ -12,10 +13,10 @@ extern "C" void dstt_stopTransmission(); extern u32 dstt_stopTransmission_address; extern u16 dstt_readSd_sdsc_shift; -class DSTTReadSdStopTransmissionPatchCode : public PatchCode +class DsttReadSdStopTransmissionPatchCode : public PatchCode { public: - explicit DSTTReadSdStopTransmissionPatchCode(PatchHeap& patchHeap) + explicit DsttReadSdStopTransmissionPatchCode(PatchHeap& patchHeap) : PatchCode(SECTION_START(dstt_readsd_stopTransmission), SECTION_SIZE(dstt_readsd_stopTransmission), patchHeap) { } const void* GetStopTransmissionFunction() const @@ -24,18 +25,18 @@ public: } }; -class DSTTReadSdPatchCode : public SdReadPatchCode +class DsttReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode { public: - explicit DSTTReadSdPatchCode(PatchHeap& patchHeap, - const DSTTReadSdStopTransmissionPatchCode* dsttReadSdStopTransmissionPatchCode) - : SdReadPatchCode(SECTION_START(dstt_readsd), SECTION_SIZE(dstt_readsd), patchHeap) + explicit DsttReadSdPatchCode(PatchHeap& patchHeap, + const DsttReadSdStopTransmissionPatchCode* dsttReadSdStopTransmissionPatchCode) + : PatchCode(SECTION_START(dstt_readsd), SECTION_SIZE(dstt_readsd), patchHeap) { dstt_stopTransmission_address = (u32)dsttReadSdStopTransmissionPatchCode->GetStopTransmissionFunction(); } - const SdReadFunc GetSdReadFunction() const override + const ReadSectorsFunc GetReadSectorsFunction() const override { - return (const SdReadFunc)GetAddressAtTarget((void*)dstt_readSd); + return (const ReadSectorsFunc)GetAddressAtTarget((void*)dstt_readSd); } }; diff --git a/arm9/source/patches/platform/dstt/dsttReadSdAsm.s b/arm9/source/patches/platform/dstt/DsttReadSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/dstt/dsttReadSdAsm.s rename to arm9/source/patches/platform/dstt/DsttReadSdPatchCode.s diff --git a/arm9/source/patches/platform/dstt/dsttWriteSdAsm.h b/arm9/source/patches/platform/dstt/DsttWriteSdPatchCode.h similarity index 54% rename from arm9/source/patches/platform/dstt/dsttWriteSdAsm.h rename to arm9/source/patches/platform/dstt/DsttWriteSdPatchCode.h index 6f193cf..38b48aa 100644 --- a/arm9/source/patches/platform/dstt/dsttWriteSdAsm.h +++ b/arm9/source/patches/platform/dstt/DsttWriteSdPatchCode.h @@ -1,6 +1,7 @@ #pragma once #include "sections.h" -#include "../SdWritePatchCode.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(dstt_writesd); DEFINE_SECTION_SYMBOLS(dstt_writesd_continue); @@ -11,10 +12,10 @@ extern "C" void dstt_writeSdContinue(); extern u32 dstt_writeSdContinue_address; extern u16 dstt_writeSd_sdsc_shift; -class DSTTWriteSdContinuePatchCode : public PatchCode +class DsttWriteSdContinuePatchCode : public PatchCode { public: - explicit DSTTWriteSdContinuePatchCode(PatchHeap& patchHeap) + explicit DsttWriteSdContinuePatchCode(PatchHeap& patchHeap) : PatchCode(SECTION_START(dstt_writesd_continue), SECTION_SIZE(dstt_writesd_continue), patchHeap) { } const void* GetWriteSdContinueFunction() const @@ -23,18 +24,18 @@ public: } }; -class DSTTWriteSdPatchCode : public SdWritePatchCode +class DsttWriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode { public: - explicit DSTTWriteSdPatchCode(PatchHeap& patchHeap, - const DSTTWriteSdContinuePatchCode* dsttWriteSdContinuePatchCode) - : SdWritePatchCode(SECTION_START(dstt_writesd), SECTION_SIZE(dstt_writesd), patchHeap) + DsttWriteSdPatchCode(PatchHeap& patchHeap, + const DsttWriteSdContinuePatchCode* dsttWriteSdContinuePatchCode) + : PatchCode(SECTION_START(dstt_writesd), SECTION_SIZE(dstt_writesd), patchHeap) { dstt_writeSdContinue_address = (u32)dsttWriteSdContinuePatchCode->GetWriteSdContinueFunction(); } - const SdWriteFunc GetSdWriteFunction() const override + const WriteSectorsFunc GetWriteSectorFunction() const override { - return (const SdWriteFunc)GetAddressAtTarget((void*)dstt_writeSd); + return (const WriteSectorsFunc)GetAddressAtTarget((void*)dstt_writeSd); } }; diff --git a/arm9/source/patches/platform/dstt/dsttWriteSdAsm.s b/arm9/source/patches/platform/dstt/DsttWriteSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/dstt/dsttWriteSdAsm.s rename to arm9/source/patches/platform/dstt/DsttWriteSdPatchCode.s diff --git a/arm9/source/patches/platform/ezp/EZPLoaderPlatform.h b/arm9/source/patches/platform/ezp/EzpLoaderPlatform.h similarity index 60% rename from arm9/source/patches/platform/ezp/EZPLoaderPlatform.h rename to arm9/source/patches/platform/ezp/EzpLoaderPlatform.h index dfbc3ed..14ab7ce 100644 --- a/arm9/source/patches/platform/ezp/EZPLoaderPlatform.h +++ b/arm9/source/patches/platform/ezp/EzpLoaderPlatform.h @@ -1,33 +1,32 @@ #pragma once -#include "common.h" #include "../LoaderPlatform.h" -#include "ezpReadSectorsAsm.h" -#include "ezpReadSdDataAsm.h" -#include "ezpWriteSectorsAsm.h" +#include "EzpReadSectorsPatchCode.h" +#include "EzpReadSdDataPatchCode.h" +#include "EzpWriteSectorsPatchCode.h" /// @brief Implementation of LoaderPlatform for the EZ-Flash Parallel flashcard -class EZPLoaderPlatform : public LoaderPlatform +class EzpLoaderPlatform : public LoaderPlatform { public: - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new EZPReadSectorsPatchCode(patchHeap, + return new EzpReadSectorsPatchCode(patchHeap, patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new EZPReadSDDataPatchCode(patchHeap); + return new EzpReadSdDataPatchCode(patchHeap); })); }); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new EZPWriteSectorsPatchCode(patchHeap); + return new EzpWriteSectorsPatchCode(patchHeap); }); } diff --git a/arm9/source/patches/platform/ezp/ezpReadSdDataAsm.h b/arm9/source/patches/platform/ezp/EzpReadSdDataPatchCode.h similarity index 80% rename from arm9/source/patches/platform/ezp/ezpReadSdDataAsm.h rename to arm9/source/patches/platform/ezp/EzpReadSdDataPatchCode.h index e1d53dd..3b032b4 100644 --- a/arm9/source/patches/platform/ezp/ezpReadSdDataAsm.h +++ b/arm9/source/patches/platform/ezp/EzpReadSdDataPatchCode.h @@ -6,10 +6,10 @@ DEFINE_SECTION_SYMBOLS(ezp_readsddata); extern "C" void ezp_readSdData(u32 srcSector, void* dst, u32 sectorCount, u32 sectorCountThisRead); -class EZPReadSDDataPatchCode : public PatchCode +class EzpReadSdDataPatchCode : public PatchCode { public: - explicit EZPReadSDDataPatchCode(PatchHeap& patchHeap) + explicit EzpReadSdDataPatchCode(PatchHeap& patchHeap) : PatchCode(SECTION_START(ezp_readsddata), SECTION_SIZE(ezp_readsddata), patchHeap) { } const void* GetReadSDDataFunction() const diff --git a/arm9/source/patches/platform/ezp/ezpReadSdDataAsm.s b/arm9/source/patches/platform/ezp/EzpReadSdDataPatchCode.s similarity index 100% rename from arm9/source/patches/platform/ezp/ezpReadSdDataAsm.s rename to arm9/source/patches/platform/ezp/EzpReadSdDataPatchCode.s diff --git a/arm9/source/patches/platform/ezp/EzpReadSectorsPatchCode.h b/arm9/source/patches/platform/ezp/EzpReadSectorsPatchCode.h new file mode 100644 index 0000000..61661de --- /dev/null +++ b/arm9/source/patches/platform/ezp/EzpReadSectorsPatchCode.h @@ -0,0 +1,27 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" +#include "EzpReadSdDataPatchCode.h" + +DEFINE_SECTION_SYMBOLS(ezp_readsectors); + +extern "C" void ezp_readSectors(u32 srcSector, void* dst, u32 sectorCount); + +extern "C" u32 ezp_readSectors_readSdData_address; + +class EzpReadSectorsPatchCode : public PatchCode, public IReadSectorsPatchCode +{ +public: + explicit EzpReadSectorsPatchCode(PatchHeap& patchHeap, + const EzpReadSdDataPatchCode* ezpReadSdDataPatchCode) + : PatchCode(SECTION_START(ezp_readsectors), SECTION_SIZE(ezp_readsectors), patchHeap) + { + ezp_readSectors_readSdData_address = (u32)ezpReadSdDataPatchCode->GetReadSDDataFunction(); + } + + const ReadSectorsFunc GetReadSectorsFunction() const override + { + return (const ReadSectorsFunc)GetAddressAtTarget((void*)ezp_readSectors); + } +}; diff --git a/arm9/source/patches/platform/ezp/ezpReadSectorsAsm.s b/arm9/source/patches/platform/ezp/EzpReadSectorsPatchCode.s similarity index 100% rename from arm9/source/patches/platform/ezp/ezpReadSectorsAsm.s rename to arm9/source/patches/platform/ezp/EzpReadSectorsPatchCode.s diff --git a/arm9/source/patches/platform/ezp/EzpWriteSectorsPatchCode.h b/arm9/source/patches/platform/ezp/EzpWriteSectorsPatchCode.h new file mode 100644 index 0000000..2627b9a --- /dev/null +++ b/arm9/source/patches/platform/ezp/EzpWriteSectorsPatchCode.h @@ -0,0 +1,20 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(ezp_writesectors); + +extern "C" void ezp_writeSectors(u32 dstSector, const void* src, u32 sectorCount); + +class EzpWriteSectorsPatchCode : public PatchCode, public IWriteSectorsPatchCode +{ +public: + explicit EzpWriteSectorsPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(ezp_writesectors), SECTION_SIZE(ezp_writesectors), patchHeap) { } + + const WriteSectorsFunc GetWriteSectorFunction() const override + { + return (const WriteSectorsFunc)GetAddressAtTarget((void*)ezp_writeSectors); + } +}; diff --git a/arm9/source/patches/platform/ezp/ezpWriteSectorsAsm.s b/arm9/source/patches/platform/ezp/EzpWriteSectorsPatchCode.s similarity index 100% rename from arm9/source/patches/platform/ezp/ezpWriteSectorsAsm.s rename to arm9/source/patches/platform/ezp/EzpWriteSectorsPatchCode.s diff --git a/arm9/source/patches/platform/ezp/ezpReadSectorsAsm.h b/arm9/source/patches/platform/ezp/ezpReadSectorsAsm.h deleted file mode 100644 index 9d3b639..0000000 --- a/arm9/source/patches/platform/ezp/ezpReadSectorsAsm.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdReadPatchCode.h" -#include "ezpReadSdDataAsm.h" - -DEFINE_SECTION_SYMBOLS(ezp_readsectors); - -extern "C" void ezp_readSectors(u32 srcSector, void* dst, u32 sectorCount); - -extern "C" u32 ezp_readSectors_readSdData_address; - -class EZPReadSectorsPatchCode : public SdReadPatchCode -{ -public: - explicit EZPReadSectorsPatchCode(PatchHeap& patchHeap, - const EZPReadSDDataPatchCode* ezpReadSdDataPatchCode) - : SdReadPatchCode(SECTION_START(ezp_readsectors), SECTION_SIZE(ezp_readsectors), patchHeap) - { - ezp_readSectors_readSdData_address = (u32)ezpReadSdDataPatchCode->GetReadSDDataFunction(); - } - - const SdReadFunc GetSdReadFunction() const override - { - return (const SdReadFunc)GetAddressAtTarget((void*)ezp_readSectors); - } -}; diff --git a/arm9/source/patches/platform/ezp/ezpWriteSectorsAsm.h b/arm9/source/patches/platform/ezp/ezpWriteSectorsAsm.h deleted file mode 100644 index 31358fc..0000000 --- a/arm9/source/patches/platform/ezp/ezpWriteSectorsAsm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdWritePatchCode.h" - -DEFINE_SECTION_SYMBOLS(ezp_writesectors); - -extern "C" void ezp_writeSectors(u32 dstSector, const void* src, u32 sectorCount); - -class EZPWriteSectorsPatchCode : public SdWritePatchCode -{ -public: - explicit EZPWriteSectorsPatchCode(PatchHeap& patchHeap) - : SdWritePatchCode(SECTION_START(ezp_writesectors), SECTION_SIZE(ezp_writesectors), patchHeap) { } - - const SdWriteFunc GetSdWriteFunction() const override - { - return (const SdWriteFunc)GetAddressAtTarget((void*)ezp_writeSectors); - } -}; diff --git a/arm9/source/patches/platform/g003/G003LoaderPlatform.h b/arm9/source/patches/platform/g003/G003LoaderPlatform.h index 484cde8..b165965 100644 --- a/arm9/source/patches/platform/g003/G003LoaderPlatform.h +++ b/arm9/source/patches/platform/g003/G003LoaderPlatform.h @@ -1,15 +1,14 @@ #pragma once -#include "common.h" #include "../LoaderPlatform.h" -#include "g003ReadSdAsm.h" -#include "g003ReadSdDmaAsm.h" -#include "g003WriteSdAsm.h" +#include "G003ReadSdPatchCode.h" +#include "G003ReadSdDmaPatchCode.h" +#include "G003WriteSdPatchCode.h" /// @brief Implementation of LoaderPlatform for the GMP-Z003 flashcard class G003LoaderPlatform : public LoaderPlatform { public: - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -18,14 +17,14 @@ public: }); } - const SdReadDmaPatchCode* CreateSdReadDmaPatchCode(PatchCodeCollection& patchCodeCollection, + const IReadSectorsDmaPatchCode* CreateSdReadDmaPatchCode(PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) const override { return patchCodeCollection.AddUniquePatchCode( patchHeap, miiCardDmaCopy32Ptr); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] diff --git a/arm9/source/patches/platform/g003/G003ReadSdDmaPatchCode.h b/arm9/source/patches/platform/g003/G003ReadSdDmaPatchCode.h new file mode 100644 index 0000000..0928afa --- /dev/null +++ b/arm9/source/patches/platform/g003/G003ReadSdDmaPatchCode.h @@ -0,0 +1,31 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsDmaPatchCode.h" + +DEFINE_SECTION_SYMBOLS(g003_readsddma); + +extern "C" void g003_readSdDma(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst); +extern "C" void g003_finishReadSdDma(void); + +extern u32 g003_readSdDma_miiCardDmaCopy32Ptr; + +class G003ReadSdDmaPatchCode : public PatchCode, public IReadSectorsDmaPatchCode +{ +public: + G003ReadSdDmaPatchCode(PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) + : PatchCode(SECTION_START(g003_readsddma), SECTION_SIZE(g003_readsddma), patchHeap) + { + g003_readSdDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr; + } + + const ReadSectorsDmaFunc GetSdReadDmaFunction() const override + { + return (const ReadSectorsDmaFunc)GetAddressAtTarget((void*)g003_readSdDma); + } + + const ReadSectorsDmaFinishFunc GetSdReadDmaFinishFunction() const override + { + return (const ReadSectorsDmaFinishFunc)GetAddressAtTarget((void*)g003_finishReadSdDma); + } +}; diff --git a/arm9/source/patches/platform/g003/g003ReadSdDmaAsm.s b/arm9/source/patches/platform/g003/G003ReadSdDmaPatchCode.s similarity index 100% rename from arm9/source/patches/platform/g003/g003ReadSdDmaAsm.s rename to arm9/source/patches/platform/g003/G003ReadSdDmaPatchCode.s diff --git a/arm9/source/patches/platform/g003/G003ReadSdPatchCode.h b/arm9/source/patches/platform/g003/G003ReadSdPatchCode.h new file mode 100644 index 0000000..9fb28b1 --- /dev/null +++ b/arm9/source/patches/platform/g003/G003ReadSdPatchCode.h @@ -0,0 +1,20 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(g003_readsd); + +extern "C" void g003_readSd(u32 srcSector, void* dst, u32 sectorCount); + +class G003ReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode +{ +public: + explicit G003ReadSdPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(g003_readsd), SECTION_SIZE(g003_readsd), patchHeap) { } + + const ReadSectorsFunc GetReadSectorsFunction() const override + { + return (const ReadSectorsFunc)GetAddressAtTarget((void*)g003_readSd); + } +}; diff --git a/arm9/source/patches/platform/g003/g003ReadSdAsm.s b/arm9/source/patches/platform/g003/G003ReadSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/g003/g003ReadSdAsm.s rename to arm9/source/patches/platform/g003/G003ReadSdPatchCode.s diff --git a/arm9/source/patches/platform/g003/G003WriteSdPatchCode.h b/arm9/source/patches/platform/g003/G003WriteSdPatchCode.h new file mode 100644 index 0000000..66d9bc0 --- /dev/null +++ b/arm9/source/patches/platform/g003/G003WriteSdPatchCode.h @@ -0,0 +1,20 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(g003_writesd); + +extern "C" void g003_writeSd(u32 dstSector, const void* src, u32 sectorCount); + +class G003WriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode +{ +public: + explicit G003WriteSdPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(g003_writesd), SECTION_SIZE(g003_writesd), patchHeap) { } + + const WriteSectorsFunc GetWriteSectorFunction() const override + { + return (const WriteSectorsFunc)GetAddressAtTarget((void*)g003_writeSd); + } +}; diff --git a/arm9/source/patches/platform/g003/g003WriteSdAsm.s b/arm9/source/patches/platform/g003/G003WriteSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/g003/g003WriteSdAsm.s rename to arm9/source/patches/platform/g003/G003WriteSdPatchCode.s diff --git a/arm9/source/patches/platform/g003/g003ReadSdAsm.h b/arm9/source/patches/platform/g003/g003ReadSdAsm.h deleted file mode 100644 index 4bc9843..0000000 --- a/arm9/source/patches/platform/g003/g003ReadSdAsm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdReadPatchCode.h" - -DEFINE_SECTION_SYMBOLS(g003_readsd); - -extern "C" void g003_readSd(u32 srcSector, void* dst, u32 sectorCount); - -class G003ReadSdPatchCode : public SdReadPatchCode -{ -public: - explicit G003ReadSdPatchCode(PatchHeap& patchHeap) - : SdReadPatchCode(SECTION_START(g003_readsd), SECTION_SIZE(g003_readsd), patchHeap) { } - - const SdReadFunc GetSdReadFunction() const override - { - return (const SdReadFunc)GetAddressAtTarget((void*)g003_readSd); - } -}; diff --git a/arm9/source/patches/platform/g003/g003ReadSdDmaAsm.h b/arm9/source/patches/platform/g003/g003ReadSdDmaAsm.h deleted file mode 100644 index dcd3194..0000000 --- a/arm9/source/patches/platform/g003/g003ReadSdDmaAsm.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdReadDmaPatchCode.h" - -DEFINE_SECTION_SYMBOLS(g003_readsddma); - -extern "C" void g003_readSdDma(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst); -extern "C" void g003_finishReadSdDma(void); - -extern u32 g003_readSdDma_miiCardDmaCopy32Ptr; - -class G003ReadSdDmaPatchCode : public SdReadDmaPatchCode -{ -public: - explicit G003ReadSdDmaPatchCode(PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) - : SdReadDmaPatchCode(SECTION_START(g003_readsddma), SECTION_SIZE(g003_readsddma), patchHeap) - { - g003_readSdDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr; - } - - const SdReadDmaFunc GetSdReadDmaFunction() const override - { - return (const SdReadDmaFunc)GetAddressAtTarget((void*)g003_readSdDma); - } - - const SdReadDmaFinishFunc GetSdReadDmaFinishFunction() const override - { - return (const SdReadDmaFinishFunc)GetAddressAtTarget((void*)g003_finishReadSdDma); - } -}; diff --git a/arm9/source/patches/platform/g003/g003WriteSdAsm.h b/arm9/source/patches/platform/g003/g003WriteSdAsm.h deleted file mode 100644 index b4618b3..0000000 --- a/arm9/source/patches/platform/g003/g003WriteSdAsm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdWritePatchCode.h" - -DEFINE_SECTION_SYMBOLS(g003_writesd); - -extern "C" void g003_writeSd(u32 dstSector, const void* src, u32 sectorCount); - -class G003WriteSdPatchCode : public SdWritePatchCode -{ -public: - explicit G003WriteSdPatchCode(PatchHeap& patchHeap) - : SdWritePatchCode(SECTION_START(g003_writesd), SECTION_SIZE(g003_writesd), patchHeap) { } - - const SdWriteFunc GetSdWriteFunction() const override - { - return (const SdWriteFunc)GetAddressAtTarget((void*)g003_writeSd); - } -}; diff --git a/arm9/source/patches/platform/isnitro/IsNitroLoaderPlatform.h b/arm9/source/patches/platform/isnitro/IsNitroLoaderPlatform.h index 818f580..05e7943 100644 --- a/arm9/source/patches/platform/isnitro/IsNitroLoaderPlatform.h +++ b/arm9/source/patches/platform/isnitro/IsNitroLoaderPlatform.h @@ -1,15 +1,14 @@ #pragma once -#include "common.h" #include "../LoaderPlatform.h" -#include "IsNitroSdReadAsm.h" -#include "IsNitroSdWriteAsm.h" +#include "IsNitroSdReadPatchCode.h" +#include "IsNitroSdWritePatchCode.h" #include "sharedMemory.h" /// @brief Implementation of LoaderPlatform for the IS-NITRO-EMULATOR with agb semihosting class IsNitroLoaderPlatform : public LoaderPlatform { public: - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -18,7 +17,7 @@ public: }); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] diff --git a/arm9/source/patches/platform/isnitro/IsNitroSdReadAsm.h b/arm9/source/patches/platform/isnitro/IsNitroSdReadAsm.h deleted file mode 100644 index af161f9..0000000 --- a/arm9/source/patches/platform/isnitro/IsNitroSdReadAsm.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdReadPatchCode.h" - -DEFINE_SECTION_SYMBOLS(sdread); - -extern "C" void sdread_asm(u32 srcSector, void* dst, u32 sectorCount); - -extern u32 sdread_asm_agbRamPtr; - -class IsNitroSdReadPatchCode : public SdReadPatchCode -{ -public: - IsNitroSdReadPatchCode(PatchHeap& patchHeap, u32 agbRamPtr) - : SdReadPatchCode(SECTION_START(sdread), SECTION_SIZE(sdread), patchHeap) - { - sdread_asm_agbRamPtr = agbRamPtr; - } - - const SdReadFunc GetSdReadFunction() const override - { - return (const SdReadFunc)GetAddressAtTarget((void*)sdread_asm); - } -}; diff --git a/arm9/source/patches/platform/isnitro/IsNitroSdReadPatchCode.h b/arm9/source/patches/platform/isnitro/IsNitroSdReadPatchCode.h new file mode 100644 index 0000000..d13c770 --- /dev/null +++ b/arm9/source/patches/platform/isnitro/IsNitroSdReadPatchCode.h @@ -0,0 +1,25 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(sdread); + +extern "C" void sdread_asm(u32 srcSector, void* dst, u32 sectorCount); + +extern u32 sdread_asm_agbRamPtr; + +class IsNitroSdReadPatchCode : public PatchCode, public IReadSectorsPatchCode +{ +public: + IsNitroSdReadPatchCode(PatchHeap& patchHeap, u32 agbRamPtr) + : PatchCode(SECTION_START(sdread), SECTION_SIZE(sdread), patchHeap) + { + sdread_asm_agbRamPtr = agbRamPtr; + } + + const ReadSectorsFunc GetReadSectorsFunction() const override + { + return (const ReadSectorsFunc)GetAddressAtTarget((void*)sdread_asm); + } +}; diff --git a/arm9/source/patches/platform/isnitro/IsNitroSdReadAsm.s b/arm9/source/patches/platform/isnitro/IsNitroSdReadPatchCode.s similarity index 100% rename from arm9/source/patches/platform/isnitro/IsNitroSdReadAsm.s rename to arm9/source/patches/platform/isnitro/IsNitroSdReadPatchCode.s diff --git a/arm9/source/patches/platform/isnitro/IsNitroSdWriteAsm.h b/arm9/source/patches/platform/isnitro/IsNitroSdWriteAsm.h deleted file mode 100644 index ab1d0a5..0000000 --- a/arm9/source/patches/platform/isnitro/IsNitroSdWriteAsm.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdWritePatchCode.h" - -DEFINE_SECTION_SYMBOLS(sdwrite); - -extern "C" void sdwrite_asm(u32 dstSector, const void* src, u32 sectorCount); - -extern u32 sdwrite_asm_agbRamPtr; - -class IsNitroSdWritePatchCode : public SdWritePatchCode -{ -public: - IsNitroSdWritePatchCode(PatchHeap& patchHeap, u32 agbRamPtr) - : SdWritePatchCode(SECTION_START(sdwrite), SECTION_SIZE(sdwrite), patchHeap) - { - sdwrite_asm_agbRamPtr = agbRamPtr; - } - - const SdWriteFunc GetSdWriteFunction() const override - { - return (const SdWriteFunc)GetAddressAtTarget((void*)sdwrite_asm); - } -}; diff --git a/arm9/source/patches/platform/isnitro/IsNitroSdWritePatchCode.h b/arm9/source/patches/platform/isnitro/IsNitroSdWritePatchCode.h new file mode 100644 index 0000000..375baad --- /dev/null +++ b/arm9/source/patches/platform/isnitro/IsNitroSdWritePatchCode.h @@ -0,0 +1,25 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(sdwrite); + +extern "C" void sdwrite_asm(u32 dstSector, const void* src, u32 sectorCount); + +extern u32 sdwrite_asm_agbRamPtr; + +class IsNitroSdWritePatchCode : public PatchCode, public IWriteSectorsPatchCode +{ +public: + IsNitroSdWritePatchCode(PatchHeap& patchHeap, u32 agbRamPtr) + : PatchCode(SECTION_START(sdwrite), SECTION_SIZE(sdwrite), patchHeap) + { + sdwrite_asm_agbRamPtr = agbRamPtr; + } + + const WriteSectorsFunc GetWriteSectorFunction() const override + { + return (const WriteSectorsFunc)GetAddressAtTarget((void*)sdwrite_asm); + } +}; diff --git a/arm9/source/patches/platform/isnitro/IsNitroSdWriteAsm.s b/arm9/source/patches/platform/isnitro/IsNitroSdWritePatchCode.s similarity index 99% rename from arm9/source/patches/platform/isnitro/IsNitroSdWriteAsm.s rename to arm9/source/patches/platform/isnitro/IsNitroSdWritePatchCode.s index 7668609..676ad02 100644 --- a/arm9/source/patches/platform/isnitro/IsNitroSdWriteAsm.s +++ b/arm9/source/patches/platform/isnitro/IsNitroSdWritePatchCode.s @@ -37,7 +37,7 @@ sdwrite_asm: subs r0, #1 bne 4b mov r5, lr - + // GBA slot irq bit: 1 << 13 movs r4, #1 lsls r3, r4, #13 diff --git a/arm9/source/patches/platform/m3ds/M3DSLoaderPlatform.h b/arm9/source/patches/platform/m3ds/M3DSLoaderPlatform.h index 08eddf4..06a65b4 100644 --- a/arm9/source/patches/platform/m3ds/M3DSLoaderPlatform.h +++ b/arm9/source/patches/platform/m3ds/M3DSLoaderPlatform.h @@ -1,14 +1,13 @@ #pragma once -#include "common.h" #include "../LoaderPlatform.h" -#include "m3dsReadSectorsAsm.h" -#include "m3dsWriteSectorsAsm.h" +#include "M3DSReadSdSectorsPatchCode.h" +#include "M3DSWriteSdSectorsPatchCode.h" /// @brief Implementation of LoaderPlatform for the M3 DS Real flashcard class M3DSLoaderPlatform : public LoaderPlatform { public: - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -21,7 +20,7 @@ public: }); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] diff --git a/arm9/source/patches/platform/m3ds/m3dsReadSectorsAsm.h b/arm9/source/patches/platform/m3ds/M3DSReadSdSectorsPatchCode.h similarity index 61% rename from arm9/source/patches/platform/m3ds/m3dsReadSectorsAsm.h rename to arm9/source/patches/platform/m3ds/M3DSReadSdSectorsPatchCode.h index ec6bfa9..091c896 100644 --- a/arm9/source/patches/platform/m3ds/m3dsReadSectorsAsm.h +++ b/arm9/source/patches/platform/m3ds/M3DSReadSdSectorsPatchCode.h @@ -1,6 +1,7 @@ #pragma once #include "sections.h" -#include "../SdReadPatchCode.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(m3ds_readsdsectors); DEFINE_SECTION_SYMBOLS(m3ds_readsdsectors_receiveSector); @@ -22,17 +23,17 @@ public: } }; -class M3DSReadSdSectorsPatchCode : public SdReadPatchCode +class M3DSReadSdSectorsPatchCode : public PatchCode, public IReadSectorsPatchCode { public: - explicit M3DSReadSdSectorsPatchCode(PatchHeap& patchHeap, const M3DSReceiveSectorPatchCode* m3dsReceiveSectorPatchCode) - : SdReadPatchCode(SECTION_START(m3ds_readsdsectors), SECTION_SIZE(m3ds_readsdsectors), patchHeap) + M3DSReadSdSectorsPatchCode(PatchHeap& patchHeap, const M3DSReceiveSectorPatchCode* m3dsReceiveSectorPatchCode) + : PatchCode(SECTION_START(m3ds_readsdsectors), SECTION_SIZE(m3ds_readsdsectors), patchHeap) { m3ds_receiveSector_address = (u32)m3dsReceiveSectorPatchCode->GetReceiveSectorFunction(); } - const SdReadFunc GetSdReadFunction() const override + const ReadSectorsFunc GetReadSectorsFunction() const override { - return (const SdReadFunc)GetAddressAtTarget((void*)m3ds_readSdSectors); + return (const ReadSectorsFunc)GetAddressAtTarget((void*)m3ds_readSdSectors); } }; diff --git a/arm9/source/patches/platform/m3ds/m3dsReadSectorsAsm.s b/arm9/source/patches/platform/m3ds/M3DSReadSdSectorsPatchCode.s similarity index 100% rename from arm9/source/patches/platform/m3ds/m3dsReadSectorsAsm.s rename to arm9/source/patches/platform/m3ds/M3DSReadSdSectorsPatchCode.s diff --git a/arm9/source/patches/platform/m3ds/m3dsWriteSectorsAsm.h b/arm9/source/patches/platform/m3ds/M3DSWriteSdSectorsPatchCode.h similarity index 69% rename from arm9/source/patches/platform/m3ds/m3dsWriteSectorsAsm.h rename to arm9/source/patches/platform/m3ds/M3DSWriteSdSectorsPatchCode.h index fe6c39a..7da1398 100644 --- a/arm9/source/patches/platform/m3ds/m3dsWriteSectorsAsm.h +++ b/arm9/source/patches/platform/m3ds/M3DSWriteSdSectorsPatchCode.h @@ -1,6 +1,7 @@ #pragma once #include "sections.h" -#include "../SdWritePatchCode.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(m3ds_writesdsectors); DEFINE_SECTION_SYMBOLS(m3ds_writesdsectors_sendSector); @@ -22,17 +23,17 @@ public: } }; -class M3DSWriteSdSectorsPatchCode : public SdWritePatchCode +class M3DSWriteSdSectorsPatchCode : public PatchCode, public IWriteSectorsPatchCode { public: M3DSWriteSdSectorsPatchCode(PatchHeap& patchHeap, const M3DSSendSectorPatchCode* m3dsSendSectorPatchCode) - : SdWritePatchCode(SECTION_START(m3ds_writesdsectors), SECTION_SIZE(m3ds_writesdsectors), patchHeap) + : PatchCode(SECTION_START(m3ds_writesdsectors), SECTION_SIZE(m3ds_writesdsectors), patchHeap) { m3ds_sendSector_address = (u32)m3dsSendSectorPatchCode->GetSendSectorFunction(); } - const SdWriteFunc GetSdWriteFunction() const override + const WriteSectorsFunc GetWriteSectorFunction() const override { - return (const SdWriteFunc)GetAddressAtTarget((void*)m3ds_writeSdSectors); + return (const WriteSectorsFunc)GetAddressAtTarget((void*)m3ds_writeSdSectors); } }; diff --git a/arm9/source/patches/platform/m3ds/m3dsWriteSectorsAsm.s b/arm9/source/patches/platform/m3ds/M3DSWriteSdSectorsPatchCode.s similarity index 100% rename from arm9/source/patches/platform/m3ds/m3dsWriteSectorsAsm.s rename to arm9/source/patches/platform/m3ds/M3DSWriteSdSectorsPatchCode.s diff --git a/arm9/source/patches/platform/melonds/MelonDSLoaderPlatform.h b/arm9/source/patches/platform/melonds/MelonDSLoaderPlatform.h index bbc4ac6..42059cc 100644 --- a/arm9/source/patches/platform/melonds/MelonDSLoaderPlatform.h +++ b/arm9/source/patches/platform/melonds/MelonDSLoaderPlatform.h @@ -1,14 +1,13 @@ #pragma once -#include "common.h" #include "../LoaderPlatform.h" -#include "melondsReadSdAsm.h" -#include "melondsWriteSdAsm.h" +#include "MelonDSReadSdPatchCode.h" +#include "MelonDSWriteSdPatchCode.h" /// @brief Implementation of LoaderPlatform for MelonDS class MelonDSLoaderPlatform : public LoaderPlatform { public: - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -17,7 +16,7 @@ public: }); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] diff --git a/arm9/source/patches/platform/melonds/MelonDSReadSdPatchCode.h b/arm9/source/patches/platform/melonds/MelonDSReadSdPatchCode.h new file mode 100644 index 0000000..3815992 --- /dev/null +++ b/arm9/source/patches/platform/melonds/MelonDSReadSdPatchCode.h @@ -0,0 +1,20 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(melonds_readsd); + +extern "C" void melonds_readSd(u32 srcSector, void* dst, u32 sectorCount); + +class MelonDSReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode +{ +public: + explicit MelonDSReadSdPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(melonds_readsd), SECTION_SIZE(melonds_readsd), patchHeap) { } + + const ReadSectorsFunc GetReadSectorsFunction() const override + { + return (const ReadSectorsFunc)GetAddressAtTarget((void*)melonds_readSd); + } +}; diff --git a/arm9/source/patches/platform/melonds/melondsReadSdAsm.s b/arm9/source/patches/platform/melonds/MelonDSReadSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/melonds/melondsReadSdAsm.s rename to arm9/source/patches/platform/melonds/MelonDSReadSdPatchCode.s diff --git a/arm9/source/patches/platform/melonds/MelonDSWriteSdPatchCode.h b/arm9/source/patches/platform/melonds/MelonDSWriteSdPatchCode.h new file mode 100644 index 0000000..ff50556 --- /dev/null +++ b/arm9/source/patches/platform/melonds/MelonDSWriteSdPatchCode.h @@ -0,0 +1,20 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(melonds_writesd); + +extern "C" void melonds_writeSd(u32 dstSector, const void* src, u32 sectorCount); + +class MelonDSWriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode +{ +public: + explicit MelonDSWriteSdPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(melonds_writesd), SECTION_SIZE(melonds_writesd), patchHeap) { } + + const WriteSectorsFunc GetWriteSectorFunction() const override + { + return (const WriteSectorsFunc)GetAddressAtTarget((void*)melonds_writeSd); + } +}; diff --git a/arm9/source/patches/platform/melonds/melondsWriteSdAsm.s b/arm9/source/patches/platform/melonds/MelonDSWriteSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/melonds/melondsWriteSdAsm.s rename to arm9/source/patches/platform/melonds/MelonDSWriteSdPatchCode.s diff --git a/arm9/source/patches/platform/melonds/melondsReadSdAsm.h b/arm9/source/patches/platform/melonds/melondsReadSdAsm.h deleted file mode 100644 index 4d4de02..0000000 --- a/arm9/source/patches/platform/melonds/melondsReadSdAsm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdReadPatchCode.h" - -DEFINE_SECTION_SYMBOLS(melonds_readsd); - -extern "C" void melonds_readSd(u32 srcSector, void* dst, u32 sectorCount); - -class MelonDSReadSdPatchCode : public SdReadPatchCode -{ -public: - explicit MelonDSReadSdPatchCode(PatchHeap& patchHeap) - : SdReadPatchCode(SECTION_START(melonds_readsd), SECTION_SIZE(melonds_readsd), patchHeap) { } - - const SdReadFunc GetSdReadFunction() const override - { - return (const SdReadFunc)GetAddressAtTarget((void*)melonds_readSd); - } -}; diff --git a/arm9/source/patches/platform/melonds/melondsWriteSdAsm.h b/arm9/source/patches/platform/melonds/melondsWriteSdAsm.h deleted file mode 100644 index c06ecd5..0000000 --- a/arm9/source/patches/platform/melonds/melondsWriteSdAsm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdWritePatchCode.h" - -DEFINE_SECTION_SYMBOLS(melonds_writesd); - -extern "C" void melonds_writeSd(u32 dstSector, const void* src, u32 sectorCount); - -class MelonDSWriteSdPatchCode : public SdWritePatchCode -{ -public: - explicit MelonDSWriteSdPatchCode(PatchHeap& patchHeap) - : SdWritePatchCode(SECTION_START(melonds_writesd), SECTION_SIZE(melonds_writesd), patchHeap) { } - - const SdWriteFunc GetSdWriteFunction() const override - { - return (const SdWriteFunc)GetAddressAtTarget((void*)melonds_writeSd); - } -}; diff --git a/arm9/source/patches/platform/r4/R4LoaderPlatform.cpp b/arm9/source/patches/platform/r4/R4LoaderPlatform.cpp index 26feeaa..0be197b 100644 --- a/arm9/source/patches/platform/r4/R4LoaderPlatform.cpp +++ b/arm9/source/patches/platform/r4/R4LoaderPlatform.cpp @@ -1,4 +1,5 @@ #include "common.h" +#include #include "R4LoaderPlatform.h" #define R4_CMD_CARD_INFO 0xB000000000000000ull diff --git a/arm9/source/patches/platform/r4/R4LoaderPlatform.h b/arm9/source/patches/platform/r4/R4LoaderPlatform.h index 106a90e..d14d21c 100644 --- a/arm9/source/patches/platform/r4/R4LoaderPlatform.h +++ b/arm9/source/patches/platform/r4/R4LoaderPlatform.h @@ -1,16 +1,14 @@ #pragma once -#include "common.h" -#include #include "../LoaderPlatform.h" -#include "r4ReadRomAsm.h" -#include "r4ReadSdAsm.h" -#include "r4WriteSdAsm.h" +#include "R4ReadRomPatchCode.h" +#include "R4ReadSdPatchCode.h" +#include "R4WriteSdPatchCode.h" /// @brief Implementation of LoaderPlatform for the original R4 flashcard class R4LoaderPlatform : public LoaderPlatform { public: - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -19,7 +17,7 @@ public: }); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -28,7 +26,7 @@ public: }); } - const SdReadPatchCode* CreateRomReadPatchCode( + const IReadSectorsPatchCode* CreateRomReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] diff --git a/arm9/source/patches/platform/r4/R4ReadRomPatchCode.h b/arm9/source/patches/platform/r4/R4ReadRomPatchCode.h new file mode 100644 index 0000000..5e31f41 --- /dev/null +++ b/arm9/source/patches/platform/r4/R4ReadRomPatchCode.h @@ -0,0 +1,21 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(r4_readrom); + +extern "C" void r4_readRom(u32 srcSector, void* dst); + +class R4ReadRomPatchCode : public PatchCode, public IReadSectorsPatchCode +{ +public: + explicit R4ReadRomPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(r4_readrom), SECTION_SIZE(r4_readrom), patchHeap) + { } + + const ReadSectorsFunc GetReadSectorsFunction() const override + { + return (const ReadSectorsFunc)GetAddressAtTarget((void*)r4_readRom); + } +}; diff --git a/arm9/source/patches/platform/r4/r4ReadRomAsm.s b/arm9/source/patches/platform/r4/R4ReadRomPatchCode.s similarity index 100% rename from arm9/source/patches/platform/r4/r4ReadRomAsm.s rename to arm9/source/patches/platform/r4/R4ReadRomPatchCode.s diff --git a/arm9/source/patches/platform/r4/R4ReadSdPatchCode.h b/arm9/source/patches/platform/r4/R4ReadSdPatchCode.h new file mode 100644 index 0000000..9db9695 --- /dev/null +++ b/arm9/source/patches/platform/r4/R4ReadSdPatchCode.h @@ -0,0 +1,20 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(r4_readsd); + +extern "C" void r4_readSd(u32 srcSector, void* dst, u32 sectorCount); + +class R4ReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode +{ +public: + explicit R4ReadSdPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(r4_readsd), SECTION_SIZE(r4_readsd), patchHeap) { } + + const ReadSectorsFunc GetReadSectorsFunction() const override + { + return (const ReadSectorsFunc)GetAddressAtTarget((void*)r4_readSd); + } +}; diff --git a/arm9/source/patches/platform/r4/r4ReadSdAsm.s b/arm9/source/patches/platform/r4/R4ReadSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/r4/r4ReadSdAsm.s rename to arm9/source/patches/platform/r4/R4ReadSdPatchCode.s diff --git a/arm9/source/patches/platform/r4/R4WriteSdPatchCode.h b/arm9/source/patches/platform/r4/R4WriteSdPatchCode.h new file mode 100644 index 0000000..46177ee --- /dev/null +++ b/arm9/source/patches/platform/r4/R4WriteSdPatchCode.h @@ -0,0 +1,20 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(r4_writesd); + +extern "C" void r4_writeSd(u32 dstSector, const void* src, u32 sectorCount); + +class R4WriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode +{ +public: + explicit R4WriteSdPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(r4_writesd), SECTION_SIZE(r4_writesd), patchHeap) { } + + const WriteSectorsFunc GetWriteSectorFunction() const override + { + return (const WriteSectorsFunc)GetAddressAtTarget((void*)r4_writeSd); + } +}; diff --git a/arm9/source/patches/platform/r4/r4WriteSdAsm.s b/arm9/source/patches/platform/r4/R4WriteSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/r4/r4WriteSdAsm.s rename to arm9/source/patches/platform/r4/R4WriteSdPatchCode.s diff --git a/arm9/source/patches/platform/r4/r4ReadRomAsm.h b/arm9/source/patches/platform/r4/r4ReadRomAsm.h deleted file mode 100644 index fc87d78..0000000 --- a/arm9/source/patches/platform/r4/r4ReadRomAsm.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdReadPatchCode.h" - -DEFINE_SECTION_SYMBOLS(r4_readrom); - -extern "C" void r4_readRom(u32 srcSector, void* dst); - -class R4ReadRomPatchCode : public SdReadPatchCode -{ -public: - explicit R4ReadRomPatchCode(PatchHeap& patchHeap) - : SdReadPatchCode(SECTION_START(r4_readrom), SECTION_SIZE(r4_readrom), patchHeap) - { } - - const SdReadFunc GetSdReadFunction() const override - { - return (const SdReadFunc)GetAddressAtTarget((void*)r4_readRom); - } -}; diff --git a/arm9/source/patches/platform/r4/r4ReadSdAsm.h b/arm9/source/patches/platform/r4/r4ReadSdAsm.h deleted file mode 100644 index e25d1bf..0000000 --- a/arm9/source/patches/platform/r4/r4ReadSdAsm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdReadPatchCode.h" - -DEFINE_SECTION_SYMBOLS(r4_readsd); - -extern "C" void r4_readSd(u32 srcSector, void* dst, u32 sectorCount); - -class R4ReadSdPatchCode : public SdReadPatchCode -{ -public: - explicit R4ReadSdPatchCode(PatchHeap& patchHeap) - : SdReadPatchCode(SECTION_START(r4_readsd), SECTION_SIZE(r4_readsd), patchHeap) { } - - const SdReadFunc GetSdReadFunction() const override - { - return (const SdReadFunc)GetAddressAtTarget((void*)r4_readSd); - } -}; diff --git a/arm9/source/patches/platform/r4/r4WriteSdAsm.h b/arm9/source/patches/platform/r4/r4WriteSdAsm.h deleted file mode 100644 index 871a05a..0000000 --- a/arm9/source/patches/platform/r4/r4WriteSdAsm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdWritePatchCode.h" - -DEFINE_SECTION_SYMBOLS(r4_writesd); - -extern "C" void r4_writeSd(u32 dstSector, const void* src, u32 sectorCount); - -class R4WriteSdPatchCode : public SdWritePatchCode -{ -public: - explicit R4WriteSdPatchCode(PatchHeap& patchHeap) - : SdWritePatchCode(SECTION_START(r4_writesd), SECTION_SIZE(r4_writesd), patchHeap) { } - - const SdWriteFunc GetSdWriteFunction() const override - { - return (const SdWriteFunc)GetAddressAtTarget((void*)r4_writeSd); - } -}; diff --git a/arm9/source/patches/platform/r4idsn/R4iDSNLoaderPlatform.h b/arm9/source/patches/platform/r4idsn/R4iDsnLoaderPlatform.h similarity index 65% rename from arm9/source/patches/platform/r4idsn/R4iDSNLoaderPlatform.h rename to arm9/source/patches/platform/r4idsn/R4iDsnLoaderPlatform.h index b1d7efb..f23b821 100644 --- a/arm9/source/patches/platform/r4idsn/R4iDSNLoaderPlatform.h +++ b/arm9/source/patches/platform/r4idsn/R4iDsnLoaderPlatform.h @@ -1,12 +1,12 @@ #pragma once #include "common.h" #include "../acekard-common/IoRPGLoaderPlatform.h" -#include "r4idsnReadSdAsm.h" -#include "r4idsnSdReadSectorAsm.h" -#include "r4idsnWriteSdAsm.h" +#include "R4iDsnReadSdPatchCode.h" +#include "R4iDsnSdReadSectorPatchCode.h" +#include "R4iDsnWriteSdPatchCode.h" /// @brief Implementation of LoaderPlatform for the r4idsn.com flashcard. -class R4iDSNLoaderPlatform : public IoRPGLoaderPlatform +class R4iDsnLoaderPlatform : public IoRpgLoaderPlatform { private: enum @@ -15,43 +15,43 @@ private: }; public: - R4iDSNLoaderPlatform() : IoRPGLoaderPlatform(IORPG_CMD_SDIO_BYTE) { } + R4iDsnLoaderPlatform() : IoRpgLoaderPlatform(IORPG_CMD_SDIO_BYTE) { } - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] { auto* waitForStatePatchCode = patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new ioRPGSDWaitForStatePatchCode(patchHeap); + return new IoRpgSdWaitForStatePatchCode(patchHeap); }); - return new R4iDSNReadSdPatchCode(patchHeap, + return new R4iDsnReadSdPatchCode(patchHeap, patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new ioRPGSendSDIOCommandPatchCode(patchHeap); + return new IoRpgSendSdioCommandPatchCode(patchHeap); }), patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new R4iDSNSDReadSectorPatchCode(patchHeap, waitForStatePatchCode); + return new R4iDsnSdReadSectorPatchCode(patchHeap, waitForStatePatchCode); }), waitForStatePatchCode); }); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new R4iDSNWriteSdPatchCode(patchHeap, + return new R4iDsnWriteSdPatchCode(patchHeap, patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new ioRPGSendSDIOCommandPatchCode(patchHeap); + return new IoRpgSendSdioCommandPatchCode(patchHeap); }), patchCodeCollection.GetOrAddSharedPatchCode([&] { - return new ioRPGSDWaitForStatePatchCode(patchHeap); + return new IoRpgSdWaitForStatePatchCode(patchHeap); })); }); } diff --git a/arm9/source/patches/platform/r4idsn/R4iDsnReadSdPatchCode.h b/arm9/source/patches/platform/r4idsn/R4iDsnReadSdPatchCode.h new file mode 100644 index 0000000..5c82922 --- /dev/null +++ b/arm9/source/patches/platform/r4idsn/R4iDsnReadSdPatchCode.h @@ -0,0 +1,37 @@ +#pragma once +#include "sections.h" +#include "thumbInstructions.h" +#include "patches/PatchCode.h" +#include "R4iDsnSdReadSectorPatchCode.h" +#include "../IReadSectorsPatchCode.h" +#include "../acekard-common/IoRpgSendSdioCommandPatchCode.h" +#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h" + +DEFINE_SECTION_SYMBOLS(r4idsn_readsd); + +extern "C" void r4idsn_readSd(u32 srcSector, void* dst, u32 sectorCount); + +extern u32 r4idsn_readSd_sendSdioCommand_address; +extern u32 r4idsn_readSd_sdReadSector_address; +extern u32 r4idsn_readSd_sdWaitForState_address; +extern u16 r4idsn_readSd_sdsc_shift; + +class R4iDsnReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode +{ +public: + R4iDsnReadSdPatchCode(PatchHeap& patchHeap, + const IoRpgSendSdioCommandPatchCode* iorpgSendSdioCommandPatchCode, + const R4iDsnSdReadSectorPatchCode* r4idsnSdReadSectorPatchCode, + const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) + : PatchCode(SECTION_START(r4idsn_readsd), SECTION_SIZE(r4idsn_readsd), patchHeap) + { + r4idsn_readSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction(); + r4idsn_readSd_sdReadSector_address = (u32)r4idsnSdReadSectorPatchCode->GetSDReadSectorFunction(); + r4idsn_readSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); + } + + const ReadSectorsFunc GetReadSectorsFunction() const override + { + return (const ReadSectorsFunc)GetAddressAtTarget((void*)r4idsn_readSd); + } +}; diff --git a/arm9/source/patches/platform/r4idsn/r4idsnReadSdAsm.s b/arm9/source/patches/platform/r4idsn/R4iDsnReadSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/r4idsn/r4idsnReadSdAsm.s rename to arm9/source/patches/platform/r4idsn/R4iDsnReadSdPatchCode.s diff --git a/arm9/source/patches/platform/r4idsn/r4idsnSdReadSectorAsm.h b/arm9/source/patches/platform/r4idsn/R4iDsnSdReadSectorPatchCode.h similarity index 72% rename from arm9/source/patches/platform/r4idsn/r4idsnSdReadSectorAsm.h rename to arm9/source/patches/platform/r4idsn/R4iDsnSdReadSectorPatchCode.h index c5c3966..205d87d 100644 --- a/arm9/source/patches/platform/r4idsn/r4idsnSdReadSectorAsm.h +++ b/arm9/source/patches/platform/r4idsn/R4iDsnSdReadSectorPatchCode.h @@ -1,7 +1,7 @@ #pragma once #include "sections.h" #include "thumbInstructions.h" -#include "../acekard-common/iorpgSdWaitForStateAsm.h" +#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h" DEFINE_SECTION_SYMBOLS(r4idsn_sdreadsector); @@ -9,11 +9,11 @@ extern "C" void r4idsn_sdReadSector(u32 srcSector, void* dst, u32 sectorCount); extern u32 r4idsn_sdReadSector_sdWaitForState_address; -class R4iDSNSDReadSectorPatchCode : public PatchCode +class R4iDsnSdReadSectorPatchCode : public PatchCode { public: - explicit R4iDSNSDReadSectorPatchCode(PatchHeap& patchHeap, - const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) + explicit R4iDsnSdReadSectorPatchCode(PatchHeap& patchHeap, + const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) : PatchCode(SECTION_START(r4idsn_sdreadsector), SECTION_SIZE(r4idsn_sdreadsector), patchHeap) { r4idsn_sdReadSector_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); diff --git a/arm9/source/patches/platform/r4idsn/r4idsnSdReadSectorAsm.s b/arm9/source/patches/platform/r4idsn/R4iDsnSdReadSectorPatchCode.s similarity index 100% rename from arm9/source/patches/platform/r4idsn/r4idsnSdReadSectorAsm.s rename to arm9/source/patches/platform/r4idsn/R4iDsnSdReadSectorPatchCode.s diff --git a/arm9/source/patches/platform/r4idsn/R4iDsnWriteSdPatchCode.h b/arm9/source/patches/platform/r4idsn/R4iDsnWriteSdPatchCode.h new file mode 100644 index 0000000..d6fc71d --- /dev/null +++ b/arm9/source/patches/platform/r4idsn/R4iDsnWriteSdPatchCode.h @@ -0,0 +1,33 @@ +#pragma once +#include "sections.h" +#include "thumbInstructions.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" +#include "../acekard-common/IoRpgSendSdioCommandPatchCode.h" +#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h" + +DEFINE_SECTION_SYMBOLS(r4idsn_writesd); + +extern "C" void r4idsn_writeSd(u32 srcSector, void* dst, u32 sectorCount); + +extern u32 r4idsn_writeSd_sendSdioCommand_address; +extern u32 r4idsn_writeSd_sdWaitForState_address; +extern u16 r4idsn_writeSd_sdsc_shift; + +class R4iDsnWriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode +{ +public: + explicit R4iDsnWriteSdPatchCode(PatchHeap& patchHeap, + const IoRpgSendSdioCommandPatchCode* iorpgSendSdioCommandPatchCode, + const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) + : PatchCode(SECTION_START(r4idsn_writesd), SECTION_SIZE(r4idsn_writesd), patchHeap) + { + r4idsn_writeSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction(); + r4idsn_writeSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); + } + + const WriteSectorsFunc GetWriteSectorFunction() const override + { + return (const WriteSectorsFunc)GetAddressAtTarget((void*)r4idsn_writeSd); + } +}; diff --git a/arm9/source/patches/platform/r4idsn/r4idsnWriteSdAsm.s b/arm9/source/patches/platform/r4idsn/R4iDsnWriteSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/r4idsn/r4idsnWriteSdAsm.s rename to arm9/source/patches/platform/r4idsn/R4iDsnWriteSdPatchCode.s diff --git a/arm9/source/patches/platform/r4idsn/r4idsnReadSdAsm.h b/arm9/source/patches/platform/r4idsn/r4idsnReadSdAsm.h deleted file mode 100644 index 540f9d1..0000000 --- a/arm9/source/patches/platform/r4idsn/r4idsnReadSdAsm.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "sections.h" -#include "thumbInstructions.h" -#include "r4idsnSdReadSectorAsm.h" -#include "../SdReadPatchCode.h" -#include "../acekard-common/iorpgSendSdioCommandAsm.h" -#include "../acekard-common/iorpgSdWaitForStateAsm.h" - -DEFINE_SECTION_SYMBOLS(r4idsn_readsd); - -extern "C" void r4idsn_readSd(u32 srcSector, void* dst, u32 sectorCount); - -extern u32 r4idsn_readSd_sendSdioCommand_address; -extern u32 r4idsn_readSd_sdReadSector_address; -extern u32 r4idsn_readSd_sdWaitForState_address; -extern u16 r4idsn_readSd_sdsc_shift; - -class R4iDSNReadSdPatchCode : public SdReadPatchCode -{ -public: - explicit R4iDSNReadSdPatchCode(PatchHeap& patchHeap, - const ioRPGSendSDIOCommandPatchCode* iorpgSendSdioCommandPatchCode, - const R4iDSNSDReadSectorPatchCode* r4idsnSdReadSectorPatchCode, - const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) - : SdReadPatchCode(SECTION_START(r4idsn_readsd), SECTION_SIZE(r4idsn_readsd), patchHeap) - { - r4idsn_readSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction(); - r4idsn_readSd_sdReadSector_address = (u32)r4idsnSdReadSectorPatchCode->GetSDReadSectorFunction(); - r4idsn_readSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); - } - - const SdReadFunc GetSdReadFunction() const override - { - return (const SdReadFunc)GetAddressAtTarget((void*)r4idsn_readSd); - } -}; diff --git a/arm9/source/patches/platform/r4idsn/r4idsnWriteSdAsm.h b/arm9/source/patches/platform/r4idsn/r4idsnWriteSdAsm.h deleted file mode 100644 index 9e508e5..0000000 --- a/arm9/source/patches/platform/r4idsn/r4idsnWriteSdAsm.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "sections.h" -#include "thumbInstructions.h" -#include "../SdWritePatchCode.h" -#include "../acekard-common/iorpgSendSdioCommandAsm.h" -#include "../acekard-common/iorpgSdWaitForStateAsm.h" - -DEFINE_SECTION_SYMBOLS(r4idsn_writesd); - -extern "C" void r4idsn_writeSd(u32 srcSector, void* dst, u32 sectorCount); - -extern u32 r4idsn_writeSd_sendSdioCommand_address; -extern u32 r4idsn_writeSd_sdWaitForState_address; -extern u16 r4idsn_writeSd_sdsc_shift; - -class R4iDSNWriteSdPatchCode : public SdWritePatchCode -{ -public: - explicit R4iDSNWriteSdPatchCode(PatchHeap& patchHeap, - const ioRPGSendSDIOCommandPatchCode* iorpgSendSdioCommandPatchCode, - const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode) - : SdWritePatchCode(SECTION_START(r4idsn_writesd), SECTION_SIZE(r4idsn_writesd), patchHeap) - { - r4idsn_writeSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction(); - r4idsn_writeSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction(); - } - - const SdWriteFunc GetSdWriteFunction() const override - { - return (const SdWriteFunc)GetAddressAtTarget((void*)r4idsn_writeSd); - } -}; diff --git a/arm9/source/patches/platform/stargate/StargateLoaderPlatform.h b/arm9/source/patches/platform/stargate/StargateLoaderPlatform.h index 008528c..ec56218 100644 --- a/arm9/source/patches/platform/stargate/StargateLoaderPlatform.h +++ b/arm9/source/patches/platform/stargate/StargateLoaderPlatform.h @@ -1,15 +1,14 @@ #pragma once -#include "common.h" #include "../LoaderPlatform.h" -#include "stargateReadSdAsm.h" -#include "stargateReadSdDmaAsm.h" -#include "stargateWriteSdAsm.h" +#include "StargateReadSdPatchCode.h" +#include "StargateReadSdDmaPatchCode.h" +#include "StargateWriteSdPatchCode.h" /// @brief Implementation of LoaderPlatform for the Stargate 3DS flashcard class StargateLoaderPlatform : public LoaderPlatform { public: - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -18,14 +17,14 @@ public: }); } - const SdReadDmaPatchCode* CreateSdReadDmaPatchCode(PatchCodeCollection& patchCodeCollection, + const IReadSectorsDmaPatchCode* CreateSdReadDmaPatchCode(PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) const override { return patchCodeCollection.AddUniquePatchCode( patchHeap, miiCardDmaCopy32Ptr); } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { return patchCodeCollection.GetOrAddSharedPatchCode([&] diff --git a/arm9/source/patches/platform/stargate/StargateReadSdDmaPatchCode.h b/arm9/source/patches/platform/stargate/StargateReadSdDmaPatchCode.h new file mode 100644 index 0000000..46f9d6e --- /dev/null +++ b/arm9/source/patches/platform/stargate/StargateReadSdDmaPatchCode.h @@ -0,0 +1,31 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsDmaPatchCode.h" + +DEFINE_SECTION_SYMBOLS(stargate_readsddma); + +extern "C" void stargate_readSdDma(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst); +extern "C" void stargate_finishReadSdDma(void); + +extern u32 stargate_readSdDma_miiCardDmaCopy32Ptr; + +class StargateReadSdDmaPatchCode : public PatchCode, public IReadSectorsDmaPatchCode +{ +public: + StargateReadSdDmaPatchCode(PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) + : PatchCode(SECTION_START(stargate_readsddma), SECTION_SIZE(stargate_readsddma), patchHeap) + { + stargate_readSdDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr; + } + + const ReadSectorsDmaFunc GetSdReadDmaFunction() const override + { + return (const ReadSectorsDmaFunc)GetAddressAtTarget((void*)stargate_readSdDma); + } + + const ReadSectorsDmaFinishFunc GetSdReadDmaFinishFunction() const override + { + return (const ReadSectorsDmaFinishFunc)GetAddressAtTarget((void*)stargate_finishReadSdDma); + } +}; diff --git a/arm9/source/patches/platform/stargate/stargateReadSdDmaAsm.s b/arm9/source/patches/platform/stargate/StargateReadSdDmaPatchCode.s similarity index 100% rename from arm9/source/patches/platform/stargate/stargateReadSdDmaAsm.s rename to arm9/source/patches/platform/stargate/StargateReadSdDmaPatchCode.s diff --git a/arm9/source/patches/platform/stargate/StargateReadSdPatchCode.h b/arm9/source/patches/platform/stargate/StargateReadSdPatchCode.h new file mode 100644 index 0000000..59b8f45 --- /dev/null +++ b/arm9/source/patches/platform/stargate/StargateReadSdPatchCode.h @@ -0,0 +1,20 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IReadSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(stargate_readsd); + +extern "C" void stargate_readSd(u32 srcSector, void* dst, u32 sectorCount); + +class StargateReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode +{ +public: + explicit StargateReadSdPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(stargate_readsd), SECTION_SIZE(stargate_readsd), patchHeap) { } + + const ReadSectorsFunc GetReadSectorsFunction() const override + { + return (const ReadSectorsFunc)GetAddressAtTarget((void*)stargate_readSd); + } +}; diff --git a/arm9/source/patches/platform/stargate/stargateReadSdAsm.s b/arm9/source/patches/platform/stargate/StargateReadSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/stargate/stargateReadSdAsm.s rename to arm9/source/patches/platform/stargate/StargateReadSdPatchCode.s diff --git a/arm9/source/patches/platform/stargate/StargateWriteSdPatchCode.h b/arm9/source/patches/platform/stargate/StargateWriteSdPatchCode.h new file mode 100644 index 0000000..f8caf6f --- /dev/null +++ b/arm9/source/patches/platform/stargate/StargateWriteSdPatchCode.h @@ -0,0 +1,20 @@ +#pragma once +#include "sections.h" +#include "patches/PatchCode.h" +#include "../IWriteSectorsPatchCode.h" + +DEFINE_SECTION_SYMBOLS(stargate_writesd); + +extern "C" void stargate_writeSd(u32 dstSector, const void* src, u32 sectorCount); + +class StargateWriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode +{ +public: + explicit StargateWriteSdPatchCode(PatchHeap& patchHeap) + : PatchCode(SECTION_START(stargate_writesd), SECTION_SIZE(stargate_writesd), patchHeap) { } + + const WriteSectorsFunc GetWriteSectorFunction() const override + { + return (const WriteSectorsFunc)GetAddressAtTarget((void*)stargate_writeSd); + } +}; diff --git a/arm9/source/patches/platform/stargate/stargateWriteSdAsm.s b/arm9/source/patches/platform/stargate/StargateWriteSdPatchCode.s similarity index 100% rename from arm9/source/patches/platform/stargate/stargateWriteSdAsm.s rename to arm9/source/patches/platform/stargate/StargateWriteSdPatchCode.s diff --git a/arm9/source/patches/platform/stargate/stargateReadSdAsm.h b/arm9/source/patches/platform/stargate/stargateReadSdAsm.h deleted file mode 100644 index 01a597f..0000000 --- a/arm9/source/patches/platform/stargate/stargateReadSdAsm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdReadPatchCode.h" - -DEFINE_SECTION_SYMBOLS(stargate_readsd); - -extern "C" void stargate_readSd(u32 srcSector, void* dst, u32 sectorCount); - -class StargateReadSdPatchCode : public SdReadPatchCode -{ -public: - explicit StargateReadSdPatchCode(PatchHeap& patchHeap) - : SdReadPatchCode(SECTION_START(stargate_readsd), SECTION_SIZE(stargate_readsd), patchHeap) { } - - const SdReadFunc GetSdReadFunction() const override - { - return (const SdReadFunc)GetAddressAtTarget((void*)stargate_readSd); - } -}; diff --git a/arm9/source/patches/platform/stargate/stargateReadSdDmaAsm.h b/arm9/source/patches/platform/stargate/stargateReadSdDmaAsm.h deleted file mode 100644 index c09dfec..0000000 --- a/arm9/source/patches/platform/stargate/stargateReadSdDmaAsm.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdReadDmaPatchCode.h" - -DEFINE_SECTION_SYMBOLS(stargate_readsddma); - -extern "C" void stargate_readSdDma(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst); -extern "C" void stargate_finishReadSdDma(void); - -extern u32 stargate_readSdDma_miiCardDmaCopy32Ptr; - -class StargateReadSdDmaPatchCode : public SdReadDmaPatchCode -{ -public: - StargateReadSdDmaPatchCode(PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) - : SdReadDmaPatchCode(SECTION_START(stargate_readsddma), SECTION_SIZE(stargate_readsddma), patchHeap) - { - stargate_readSdDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr; - } - - const SdReadDmaFunc GetSdReadDmaFunction() const override - { - return (const SdReadDmaFunc)GetAddressAtTarget((void*)stargate_readSdDma); - } - - const SdReadDmaFinishFunc GetSdReadDmaFinishFunction() const override - { - return (const SdReadDmaFinishFunc)GetAddressAtTarget((void*)stargate_finishReadSdDma); - } -}; diff --git a/arm9/source/patches/platform/stargate/stargateWriteSdAsm.h b/arm9/source/patches/platform/stargate/stargateWriteSdAsm.h deleted file mode 100644 index 70560e9..0000000 --- a/arm9/source/patches/platform/stargate/stargateWriteSdAsm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "sections.h" -#include "../SdWritePatchCode.h" - -DEFINE_SECTION_SYMBOLS(stargate_writesd); - -extern "C" void stargate_writeSd(u32 dstSector, const void* src, u32 sectorCount); - -class StargateWriteSdPatchCode : public SdWritePatchCode -{ -public: - explicit StargateWriteSdPatchCode(PatchHeap& patchHeap) - : SdWritePatchCode(SECTION_START(stargate_writesd), SECTION_SIZE(stargate_writesd), patchHeap) { } - - const SdWriteFunc GetSdWriteFunction() const override - { - return (const SdWriteFunc)GetAddressAtTarget((void*)stargate_writeSd); - } -}; diff --git a/arm9/source/patches/platform/supercard/SuperCardCommon.h b/arm9/source/patches/platform/supercard/SuperCardCommon.h index 931992e..8931f39 100644 --- a/arm9/source/patches/platform/supercard/SuperCardCommon.h +++ b/arm9/source/patches/platform/supercard/SuperCardCommon.h @@ -1,7 +1,6 @@ #pragma once #include "sections.h" #include "thumbInstructions.h" -#include "../SdReadPatchCode.h" DEFINE_SECTION_SYMBOLS(scsd_change_mode); DEFINE_SECTION_SYMBOLS(scsd_common); diff --git a/arm9/source/patches/platform/supercard/SuperCardLoaderPlatform.cpp b/arm9/source/patches/platform/supercard/SuperCardLoaderPlatform.cpp index bf352cc..6fb4235 100644 --- a/arm9/source/patches/platform/supercard/SuperCardLoaderPlatform.cpp +++ b/arm9/source/patches/platform/supercard/SuperCardLoaderPlatform.cpp @@ -4,7 +4,7 @@ #include "thumbInstructions.h" #include "SuperCardDefinitions.h" #include "SuperCardLoaderPlatform.h" -#include "SuperCardSDCommands.h" +#include "SuperCardSdCommands.h" enum SupercardType { diff --git a/arm9/source/patches/platform/supercard/SuperCardLoaderPlatform.h b/arm9/source/patches/platform/supercard/SuperCardLoaderPlatform.h index 037a0e0..7624174 100644 --- a/arm9/source/patches/platform/supercard/SuperCardLoaderPlatform.h +++ b/arm9/source/patches/platform/supercard/SuperCardLoaderPlatform.h @@ -1,5 +1,4 @@ #pragma once -#include "common.h" #include "../LoaderPlatform.h" #include "SuperCardCommon.h" #include "sclite/SuperCardLiteImpl.h" @@ -9,17 +8,17 @@ class SuperCardLoaderPlatform : public LoaderPlatform { public: - const SdReadPatchCode* CreateSdReadPatchCode( + const IReadSectorsPatchCode* CreateSdReadPatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { - auto common = patchCodeCollection.GetOrAddSharedPatchCode([&] - { - return new SuperCardCommonPatchCode(patchHeap); - }); - auto changeMode = patchCodeCollection.GetOrAddSharedPatchCode([&] - { - return new SuperCardChangeModePatchCode(patchHeap); - }); + auto common = patchCodeCollection.GetOrAddSharedPatchCode([&] + { + return new SuperCardCommonPatchCode(patchHeap); + }); + auto changeMode = patchCodeCollection.GetOrAddSharedPatchCode([&] + { + return new SuperCardChangeModePatchCode(patchHeap); + }); if (isScLite) { return patchCodeCollection.GetOrAddSharedPatchCode([&] @@ -54,17 +53,17 @@ public: } } - const SdWritePatchCode* CreateSdWritePatchCode( + const IWriteSectorsPatchCode* CreateSdWritePatchCode( PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override { - auto common = patchCodeCollection.GetOrAddSharedPatchCode([&] - { - return new SuperCardCommonPatchCode(patchHeap); - }); - auto changeMode = patchCodeCollection.GetOrAddSharedPatchCode([&] - { - return new SuperCardChangeModePatchCode(patchHeap); - }); + auto common = patchCodeCollection.GetOrAddSharedPatchCode([&] + { + return new SuperCardCommonPatchCode(patchHeap); + }); + auto changeMode = patchCodeCollection.GetOrAddSharedPatchCode([&] + { + return new SuperCardChangeModePatchCode(patchHeap); + }); if (isScLite) { return patchCodeCollection.GetOrAddSharedPatchCode([&] diff --git a/arm9/source/patches/platform/supercard/SuperCardSDCommands.cpp b/arm9/source/patches/platform/supercard/SuperCardSdCommands.cpp similarity index 99% rename from arm9/source/patches/platform/supercard/SuperCardSDCommands.cpp rename to arm9/source/patches/platform/supercard/SuperCardSdCommands.cpp index 6ece392..fdf21dc 100644 --- a/arm9/source/patches/platform/supercard/SuperCardSDCommands.cpp +++ b/arm9/source/patches/platform/supercard/SuperCardSdCommands.cpp @@ -1,6 +1,6 @@ #include "common.h" #include "../SdioDefinitions.h" -#include "SuperCardSDCommands.h" +#include "SuperCardSdCommands.h" #include "SuperCardDefinitions.h" #define BUSY_WAIT_TIMEOUT 500000 diff --git a/arm9/source/patches/platform/supercard/SuperCardSDCommands.h b/arm9/source/patches/platform/supercard/SuperCardSdCommands.h similarity index 100% rename from arm9/source/patches/platform/supercard/SuperCardSDCommands.h rename to arm9/source/patches/platform/supercard/SuperCardSdCommands.h diff --git a/arm9/source/patches/platform/supercard/sclite/SuperCardLiteImpl.h b/arm9/source/patches/platform/supercard/sclite/SuperCardLiteImpl.h index b9ad434..1948278 100644 --- a/arm9/source/patches/platform/supercard/sclite/SuperCardLiteImpl.h +++ b/arm9/source/patches/platform/supercard/sclite/SuperCardLiteImpl.h @@ -1,8 +1,9 @@ #pragma once #include "sections.h" #include "../SuperCardCommon.h" -#include "../../SdReadPatchCode.h" -#include "../../SdWritePatchCode.h" +#include "patches/PatchCode.h" +#include "../../IReadSectorsPatchCode.h" +#include "../../IWriteSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(sclite_sd_command_drop); DEFINE_SECTION_SYMBOLS(sclite_write_sector); @@ -68,7 +69,7 @@ public: } }; -class SuperCardReadSectorLitePatchCode : public SdReadPatchCode +class SuperCardReadSectorLitePatchCode : public PatchCode, public IReadSectorsPatchCode { public: SuperCardReadSectorLitePatchCode(PatchHeap& patchHeap, @@ -76,7 +77,7 @@ public: const SuperCardChangeModePatchCode* superCardChangeModePatchCode, const SuperCardSDCommandAndDropLitePatchCode* superCardSdCommandAndDropLitePatchCode, const SuperCardReadDataLitePatchCode* superCardReadDataLitePatchCode) - : SdReadPatchCode(SECTION_START(sclite_read_sector), SECTION_SIZE(sclite_read_sector), patchHeap) + : PatchCode(SECTION_START(sclite_read_sector), SECTION_SIZE(sclite_read_sector), patchHeap) { INTERWORK_LABEL(sccmn_changeMode, readInterwork) = (u32)superCardChangeModePatchCode->GetScChangeModeFunction(); INTERWORK_LABEL(sclite_sdCommandAndDropResponse6, readInterwork) @@ -85,13 +86,13 @@ public: INTERWORK_LABEL(sccmn_sdSendClock10, readInterwork) = (u32)superCardCommonPatchCode->GetSdSendClock10Function(); } - const SdReadFunc GetSdReadFunction() const override + const ReadSectorsFunc GetReadSectorsFunction() const override { - return (const SdReadFunc)GetAddressAtTarget((void*)sclite_readSector); + return (const ReadSectorsFunc)GetAddressAtTarget((void*)sclite_readSector); } }; -class SuperCardWriteSectorLitePatchCode : public SdWritePatchCode +class SuperCardWriteSectorLitePatchCode : public PatchCode, public IWriteSectorsPatchCode { public: SuperCardWriteSectorLitePatchCode(PatchHeap& patchHeap, @@ -99,7 +100,7 @@ public: const SuperCardChangeModePatchCode* superCardChangeModePatchCode, const SuperCardSDCommandAndDropLitePatchCode* superCardSdCommandAndDropLitePatchCode, const SuperCardWriteDataLitePatchCode* superCardWriteDataLitePatchCode) - : SdWritePatchCode(SECTION_START(sclite_write_sector), SECTION_SIZE(sclite_write_sector), patchHeap) + : PatchCode(SECTION_START(sclite_write_sector), SECTION_SIZE(sclite_write_sector), patchHeap) { INTERWORK_LABEL(sclite_writeData, writeInterwork) = (u32)superCardWriteDataLitePatchCode->GetWriteDataLiteFunction(); INTERWORK_LABEL(sccmn_sdio4BitCrc16, writeInterwork) = (u32)superCardCommonPatchCode->GetCrc16ChecksumFunction(); @@ -109,9 +110,9 @@ public: = (u32)superCardSdCommandAndDropLitePatchCode->GetSdCommandAndDropResponse6Function(); } - const SdWriteFunc GetSdWriteFunction() const override + const WriteSectorsFunc GetWriteSectorFunction() const override { - return (const SdWriteFunc)GetAddressAtTarget((void*)sclite_writeSector); + return (const WriteSectorsFunc)GetAddressAtTarget((void*)sclite_writeSector); } }; diff --git a/arm9/source/patches/platform/supercard/scsd/SuperCardSDImpl.h b/arm9/source/patches/platform/supercard/scsd/SuperCardSDImpl.h index 04a4007..3593abf 100644 --- a/arm9/source/patches/platform/supercard/scsd/SuperCardSDImpl.h +++ b/arm9/source/patches/platform/supercard/scsd/SuperCardSDImpl.h @@ -1,8 +1,9 @@ #pragma once #include "sections.h" #include "../SuperCardCommon.h" -#include "../../SdReadPatchCode.h" -#include "../../SdWritePatchCode.h" +#include "patches/PatchCode.h" +#include "../../IReadSectorsPatchCode.h" +#include "../../IWriteSectorsPatchCode.h" DEFINE_SECTION_SYMBOLS(scsd_sd_command_drop); DEFINE_SECTION_SYMBOLS(scsd_write_sector); @@ -68,7 +69,7 @@ public: } }; -class SuperCardWriteSectorPatchCode : public SdWritePatchCode +class SuperCardWriteSectorPatchCode : public PatchCode, public IWriteSectorsPatchCode { public: SuperCardWriteSectorPatchCode(PatchHeap& patchHeap, @@ -76,7 +77,7 @@ public: const SuperCardChangeModePatchCode* superCardChangeModePatchCode, const SuperCardSdCommandAndDropPatchCode* superCardSdCommandAndDropPatchCode, const SuperCardWriteDataPatchCode* superCardWriteDataPatchCode) - : SdWritePatchCode(SECTION_START(scsd_write_sector), SECTION_SIZE(scsd_write_sector), patchHeap) + : PatchCode(SECTION_START(scsd_write_sector), SECTION_SIZE(scsd_write_sector), patchHeap) { INTERWORK_LABEL(scsd_writeData, writeInterwork) = (u32)superCardWriteDataPatchCode->GetWriteDataFunction(); INTERWORK_LABEL(sccmn_sdio4BitCrc16, writeInterwork) = (u32)superCardCommonPatchCode->GetCrc16ChecksumFunction(); @@ -86,13 +87,13 @@ public: = (u32)superCardSdCommandAndDropPatchCode->GetSdCommandAndDropResponse6Function(); } - const SdWriteFunc GetSdWriteFunction() const override + const WriteSectorsFunc GetWriteSectorFunction() const override { - return (const SdWriteFunc)GetAddressAtTarget((void*)scsd_writeSector); + return (const WriteSectorsFunc)GetAddressAtTarget((void*)scsd_writeSector); } }; -class SuperCardReadSectorPatchCode : public SdReadPatchCode +class SuperCardReadSectorPatchCode : public PatchCode, public IReadSectorsPatchCode { public: SuperCardReadSectorPatchCode(PatchHeap& patchHeap, @@ -100,7 +101,7 @@ public: const SuperCardChangeModePatchCode* superCardChangeModePatchCode, const SuperCardSdCommandAndDropPatchCode* superCardSdCommandAndDropPatchCode, const SuperCardReadDataPatchCode* superCardReadDataPatchCode) - : SdReadPatchCode(SECTION_START(scsd_read_sector), SECTION_SIZE(scsd_read_sector), patchHeap) + : PatchCode(SECTION_START(scsd_read_sector), SECTION_SIZE(scsd_read_sector), patchHeap) { INTERWORK_LABEL(sccmn_changeMode, readInterwork) = (u32)superCardChangeModePatchCode->GetScChangeModeFunction(); INTERWORK_LABEL(scsd_sdCommandAndDropResponse6, readInterwork) @@ -109,9 +110,9 @@ public: INTERWORK_LABEL(sccmn_sdSendClock10, readInterwork) = (u32)superCardCommonPatchCode->GetSdSendClock10Function(); } - const SdReadFunc GetSdReadFunction() const override + const ReadSectorsFunc GetReadSectorsFunction() const override { - return (const SdReadFunc)GetAddressAtTarget((void*)scsd_readSector); + return (const ReadSectorsFunc)GetAddressAtTarget((void*)scsd_readSector); } };