mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-26 16:59:35 -04:00
ee149581aa
* feat: implement memory card IOP * feat: IOP trace * feat: move IOP logic to ps2xIOP refactor: small refactor on audio api on runtime
56 lines
2.4 KiB
C++
56 lines
2.4 KiB
C++
#ifndef PS2_GAME_OVERRIDES_H
|
|
#define PS2_GAME_OVERRIDES_H
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
class PS2Runtime;
|
|
|
|
namespace ps2_game_overrides
|
|
{
|
|
using ApplyFn = void (*)(PS2Runtime &runtime);
|
|
|
|
struct Descriptor
|
|
{
|
|
const char *name = "";
|
|
const char *elfName = "";
|
|
uint32_t entry = 0;
|
|
uint32_t crc32 = 0;
|
|
ApplyFn apply = nullptr;
|
|
};
|
|
|
|
class AutoRegister
|
|
{
|
|
public:
|
|
explicit AutoRegister(const Descriptor &descriptor);
|
|
};
|
|
|
|
void registerDescriptor(const Descriptor &descriptor);
|
|
void applyMatching(PS2Runtime &runtime, const std::string &elfPath, uint32_t entry, uint32_t crc32, bool crc32Valid);
|
|
|
|
// Runtime helper for game-specific modules:
|
|
// bind an address to an existing syscall/stub handler by name.
|
|
bool bindAddressHandler(PS2Runtime &runtime, uint32_t address, std::string_view handlerName);
|
|
}
|
|
|
|
#define PS2_GAME_OVERRIDE_JOIN2(a, b) a##b
|
|
#define PS2_GAME_OVERRIDE_JOIN(a, b) PS2_GAME_OVERRIDE_JOIN2(a, b)
|
|
|
|
#define PS2_REGISTER_GAME_OVERRIDE(NAME_LITERAL, ELF_NAME_LITERAL, ENTRY_U32, CRC32_U32, APPLY_FN) \
|
|
namespace \
|
|
{ \
|
|
static const ps2_game_overrides::Descriptor PS2_GAME_OVERRIDE_JOIN(kPs2OverrideDesc_, __LINE__) \
|
|
{ \
|
|
NAME_LITERAL, \
|
|
ELF_NAME_LITERAL, \
|
|
static_cast<uint32_t>(ENTRY_U32), \
|
|
static_cast<uint32_t>(CRC32_U32), \
|
|
APPLY_FN \
|
|
}; \
|
|
static const ps2_game_overrides::AutoRegister PS2_GAME_OVERRIDE_JOIN(kPs2OverrideReg_, __LINE__)\
|
|
(PS2_GAME_OVERRIDE_JOIN(kPs2OverrideDesc_, __LINE__)); \
|
|
}
|
|
|
|
#endif // PS2_GAME_OVERRIDES_H
|