mirror of
https://github.com/LNH-team/pico-loader.git
synced 2026-06-02 09:16:49 +02:00
Fix folder name to proper case
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
#include "common.h"
|
||||||
|
#include "../../../PatchContext.h"
|
||||||
|
#include "PokemonIrApPatchAsm.h"
|
||||||
|
#include "PokemonIrApPatch.h"
|
||||||
|
|
||||||
|
const void* PokemonIrApPatch::InsertPatch(PatchContext& patchContext)
|
||||||
|
{
|
||||||
|
ConfigurePatch();
|
||||||
|
return patchContext.GetPatchCodeCollection().AddUniquePatchCode<PokemonIrApPatchCode>
|
||||||
|
(
|
||||||
|
patchContext.GetPatchHeap(),
|
||||||
|
next ? next->InsertPatch(patchContext) : nullptr
|
||||||
|
)->GetPatchFunction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PokemonIrApPatch::ConfigurePatch() const {
|
||||||
|
switch (_version)
|
||||||
|
{
|
||||||
|
// All of these offsets are luckily region-independent
|
||||||
|
case PokemonIrVersion::Hgss:
|
||||||
|
{
|
||||||
|
pokemonirappatch_overlayId = 1;
|
||||||
|
pokemonirappatch_offset = 0xD2C + 0x12;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PokemonIrVersion::Bw1:
|
||||||
|
{
|
||||||
|
pokemonirappatch_overlayId = 231;
|
||||||
|
pokemonirappatch_offset = 0x1B8 + 0x12;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PokemonIrVersion::Bw2:
|
||||||
|
{
|
||||||
|
pokemonirappatch_overlayId = 338;
|
||||||
|
pokemonirappatch_offset = 0x1B8 + 0x12;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
LOG_WARNING("Unsupported Pokemon IR version\n");
|
||||||
|
pokemonirappatch_overlayId = 0xFFFFFFFF;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../OverlayPatch.h"
|
||||||
|
#include "PokemonIrVersion.h"
|
||||||
|
|
||||||
|
/// @brief Arm9 overlay patch to disable the IR-sensor anti-piracy in Pokemon HeartGold, SoulSilver, Black, White, Black 2, and White 2.
|
||||||
|
class PokemonIrApPatch : public OverlayPatch
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PokemonIrApPatch(PokemonIrVersion version) : _version(version) { }
|
||||||
|
const void* InsertPatch(PatchContext& patchContext) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
PokemonIrVersion _version;
|
||||||
|
|
||||||
|
void ConfigurePatch() const;
|
||||||
|
};
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "sections.h"
|
||||||
|
#include "../../../PatchCode.h"
|
||||||
|
|
||||||
|
DEFINE_SECTION_SYMBOLS(pokemonirappatch);
|
||||||
|
|
||||||
|
extern "C" void pokemonirappatch_entry();
|
||||||
|
|
||||||
|
extern u32 pokemonirappatch_overlayId;
|
||||||
|
extern u32 pokemonirappatch_offset;
|
||||||
|
extern u32 pokemonirappatch_nextAddress;
|
||||||
|
|
||||||
|
class PokemonIrApPatchCode : public PatchCode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PokemonIrApPatchCode(PatchHeap& patchHeap, const void* nextPatch)
|
||||||
|
: PatchCode(SECTION_START(pokemonirappatch), SECTION_SIZE(pokemonirappatch), patchHeap)
|
||||||
|
{
|
||||||
|
pokemonirappatch_nextAddress = (u32)nextPatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void* GetPatchFunction() const
|
||||||
|
{
|
||||||
|
return GetAddressAtTarget((void*)pokemonirappatch_entry);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
.cpu arm946e-s
|
||||||
|
.syntax unified
|
||||||
|
.section "pokemonirappatch", "ax"
|
||||||
|
.thumb
|
||||||
|
|
||||||
|
.global pokemonirappatch_entry
|
||||||
|
.type pokemonirappatch_entry, %function
|
||||||
|
pokemonirappatch_entry:
|
||||||
|
push {r5,lr}
|
||||||
|
|
||||||
|
ldmia r5!, {r1, r2} // overlay id, ram address
|
||||||
|
ldr r0, pokemonirappatch_overlayId
|
||||||
|
cmp r0, r1
|
||||||
|
bne continue_to_next
|
||||||
|
|
||||||
|
ldr r1, pokemonirappatch_offset
|
||||||
|
movs r0, #1 // force return value of function to 1 instead of 0
|
||||||
|
strb r0, [r2, r1]
|
||||||
|
|
||||||
|
continue_to_next:
|
||||||
|
ldr r0, pokemonirappatch_nextAddress
|
||||||
|
pop {r5,pc}
|
||||||
|
|
||||||
|
.balign 4
|
||||||
|
|
||||||
|
.global pokemonirappatch_overlayId
|
||||||
|
pokemonirappatch_overlayId:
|
||||||
|
.word 0
|
||||||
|
|
||||||
|
.global pokemonirappatch_offset
|
||||||
|
pokemonirappatch_offset:
|
||||||
|
.word 0
|
||||||
|
|
||||||
|
.global pokemonirappatch_nextAddress
|
||||||
|
pokemonirappatch_nextAddress:
|
||||||
|
.word 0
|
||||||
|
|
||||||
|
.pool
|
||||||
|
|
||||||
|
.end
|
||||||
Reference in New Issue
Block a user