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,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<G003ReadSdDmaPatchCode>(
patchHeap, miiCardDmaCopy32Ptr);
}
const SdWritePatchCode* CreateSdWritePatchCode(
const IWriteSectorsPatchCode* CreateSdWritePatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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