You've already forked pico-loader
mirror of
https://github.com/LNH-team/pico-loader.git
synced 2026-01-09 16:28:35 -08:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd08fd19a1 | ||
|
|
ef50e60ff9 | ||
|
|
a424b25263 | ||
|
|
f1e5f0cddc | ||
|
|
26cec4c421 | ||
|
|
e0e33032b9 | ||
|
|
9be5424f23 | ||
|
|
3e4725c99c | ||
|
|
dcc71ca151 | ||
|
|
2d4f9cb29f | ||
|
|
231f14a783 | ||
|
|
d6080984d1 | ||
|
|
6fb34c75f8 | ||
|
|
992e2d1053 | ||
|
|
842dd8e63a | ||
|
|
92a6c6ecdc |
1
.github/workflows/nightly.yml
vendored
1
.github/workflows/nightly.yml
vendored
@@ -2,7 +2,6 @@ name: Build Pico Loader
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["develop"]
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
pull_request:
|
||||
|
||||
@@ -45,7 +45,7 @@ Note that there are still SDK versions and variants for which Pico Loader does n
|
||||
We recommend using WSL (Windows Subsystem for Linux), or MSYS2 to compile this repository.
|
||||
The steps provided will assume you already have one of those environments set up.
|
||||
|
||||
1. Install [BlocksDS](https://blocksds.skylyrac.net/docs/setup/options/)
|
||||
1. Install [BlocksDS](https://blocksds.skylyrac.net/docs/setup/)
|
||||
2. Install [.NET 9.0](https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu-install?tabs=dotnet9&pivots=os-linux-ubuntu-2404) for your system (note: this link points to the instructions for Ubuntu, but links for most OS'es are available on the same page)
|
||||
|
||||
## Compiling
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#include "picoAgbAdapter.h"
|
||||
#include "Environment.h"
|
||||
|
||||
#define NOCASH_ID 0x67246F6E
|
||||
#define NOCASH_ID_MELONDS 0x6F6C656D
|
||||
|
||||
u32 Environment::_flags;
|
||||
|
||||
static bool detectIsNitroEmulator()
|
||||
@@ -15,10 +18,10 @@ static bool detectIsNitroEmulator()
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool detectNocashPrintSuppport()
|
||||
static bool detectNocashPrintSupport()
|
||||
{
|
||||
u32 nocashIdentifier = *(vu32*)0x04FFFA00;
|
||||
return nocashIdentifier == 0x67246F6E; //no$g
|
||||
return nocashIdentifier == NOCASH_ID || nocashIdentifier == NOCASH_ID_MELONDS;
|
||||
}
|
||||
|
||||
static bool detectPicoAgbAdapter()
|
||||
@@ -55,7 +58,7 @@ void Environment::Initialize(bool dsiMode)
|
||||
}
|
||||
if (!(_flags & ENVIRONMENT_FLAGS_IS_NITRO_EMULATOR))
|
||||
{
|
||||
if (detectNocashPrintSuppport())
|
||||
if (detectNocashPrintSupport())
|
||||
_flags |= ENVIRONMENT_FLAGS_NOCASH_PRINT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,6 +220,7 @@ void NdsLoader::Load(BootMode bootMode)
|
||||
if (bootMode == BootMode::Normal)
|
||||
{
|
||||
bootType = _romHeader.IsDsiWare() ? BOOT_TYPE_NAND : BOOT_TYPE_CARD;
|
||||
HandleIQueRegionFreePatching();
|
||||
}
|
||||
else if (bootMode == BootMode::Multiboot)
|
||||
{
|
||||
@@ -296,6 +297,9 @@ void NdsLoader::Load(BootMode bootMode)
|
||||
{
|
||||
SetupDsiDeviceList();
|
||||
|
||||
// Set twl wram locking (REG_MBK9) settings from rom header
|
||||
REG_MBK9 = _romHeader.mbk9Setting[0] | (_romHeader.mbk9Setting[1] << 8) | (_romHeader.mbk9Setting[2] << 16);
|
||||
|
||||
u32 scfgExt7 = 0x93FBFB00 | (_romHeader.arm7ScfgExt7 & 0x40407);
|
||||
REG_SCFG_EXT = scfgExt7;
|
||||
REG_SCFG_CLK = 0x187;
|
||||
@@ -1013,6 +1017,15 @@ bool NdsLoader::TryDecryptSecureArea()
|
||||
return true;
|
||||
}
|
||||
|
||||
void NdsLoader::HandleIQueRegionFreePatching()
|
||||
{
|
||||
if ((_romHeader.flags & 0x80) == 0x80)
|
||||
{
|
||||
_romHeader.flags &= ~0x80;
|
||||
_romHeader.headerCrc = swi_getCrc16(0xFFFF, (void*)&_romHeader, 0x15E);
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleRegion NdsLoader::GetRomRegion(u32 gameCode)
|
||||
{
|
||||
u8 gameRegionCode = (gameCode >> 24) & 0xFF;
|
||||
|
||||
@@ -73,6 +73,7 @@ private:
|
||||
void InsertArgv();
|
||||
bool TrySetupDsiWareSave();
|
||||
bool TryDecryptSecureArea();
|
||||
void HandleIQueRegionFreePatching();
|
||||
ConsoleRegion GetRomRegion(u32 gameCode);
|
||||
UserLanguage GetLanguageByRomRegion(ConsoleRegion romRegion);
|
||||
u32 GetSupportedLanguagesByRegion(ConsoleRegion region);
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "patches/arm9/OverlayPatches/DSProtectPatches/DSProtectOverlayPatch.h"
|
||||
#include "patches/arm9/OverlayPatches/DSProtectPatches/DSProtectPuyoPuyo7Patch.h"
|
||||
#include "patches/arm9/OverlayPatches/PokemonIr/PokemonIrApPatch.h"
|
||||
#include "patches/arm9/OverlayPatches/KirbySuperStarUltra/KirbySuperStarUltraPatch.h"
|
||||
#include "patches/arm9/OverlayPatches/RabbidsGoHome/RabbidsGoHomePatch.h"
|
||||
#include "patches/arm9/OverlayPatches/GoldenSunDarkDawn/GoldenSunDarkDawnOverlayHookPatch.h"
|
||||
#include "SecureSysCallsUnusedSpaceLocator.h"
|
||||
#include "fastSearch.h"
|
||||
@@ -404,6 +406,22 @@ void Arm9Patcher::AddGameSpecificPatches(
|
||||
patchCollection.AddPatch(new NintendoDSGuideNandSavePatch());
|
||||
break;
|
||||
}
|
||||
// Rabbids Go Home
|
||||
case GAMECODE("VRGE"):
|
||||
case GAMECODE("VRGV"):
|
||||
{
|
||||
overlayHookPatch->AddOverlayPatch(new RabbidsGoHomePatch());
|
||||
break;
|
||||
}
|
||||
// Kirby Super Star Ultra
|
||||
case GAMECODE("YKWE"):
|
||||
case GAMECODE("YKWJ"):
|
||||
case GAMECODE("YKWK"):
|
||||
case GAMECODE("YKWP"):
|
||||
{
|
||||
overlayHookPatch->AddOverlayPatch(new KirbySuperStarUltraPatch());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
13
arm9/source/patches/ISectorRemapPatchCode.h
Normal file
13
arm9/source/patches/ISectorRemapPatchCode.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
/// @brief Interface for sector remapping patch code.
|
||||
class ISectorRemapPatchCode
|
||||
{
|
||||
protected:
|
||||
ISectorRemapPatchCode() { }
|
||||
|
||||
public:
|
||||
/// @brief Gets a pointer to the sector remap function in the patch code.
|
||||
/// @return The pointer to the sector remap function.
|
||||
virtual const void* GetRemapFunction() const = 0;
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
@@ -20,15 +20,6 @@ public:
|
||||
while (1);
|
||||
}
|
||||
|
||||
/// @brief Converts a pointer inside the original code block
|
||||
/// to a pointer at the target location in the patch heap.
|
||||
/// @param ptr The pointer to convert.
|
||||
/// @return The converted pointer.
|
||||
const void* GetAddressAtTarget(const void* ptr) const
|
||||
{
|
||||
return (const void*)((u32)ptr - (u32)_code + (u32)_targetAddress);
|
||||
}
|
||||
|
||||
/// @brief Copies the patch code to the target address.
|
||||
void CopyToTarget() const
|
||||
{
|
||||
@@ -44,4 +35,13 @@ protected:
|
||||
|
||||
/// @brief The target address for the code block in the patch heap.
|
||||
void* const _targetAddress;
|
||||
|
||||
/// @brief Converts a pointer inside the original code block
|
||||
/// to a pointer at the target location in the patch heap.
|
||||
/// @param ptr The pointer to convert.
|
||||
/// @return The converted pointer.
|
||||
const void* GetAddressAtTarget(const void* ptr) const
|
||||
{
|
||||
return (const void*)((u32)ptr - (u32)_code + (u32)_targetAddress);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user