Refactored platform code to use interfaces for patch code with a special feature and improved patch code file names

This commit is contained in:
Gericom
2026-01-02 15:18:45 +01:00
parent d6080984d1
commit 231f14a783
180 changed files with 1073 additions and 1057 deletions

View File

@@ -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([&]

View File

@@ -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);
}
};

View File

@@ -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);
}
};

View File

@@ -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);
}
};

View File

@@ -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);
}
};