Skip to content

Commit

Permalink
-executing the codehandler once directly before the game boot, this w…
Browse files Browse the repository at this point in the history
…ill make sure that cheats which affect the game boot will work properly

-added a low memory patch for f-zero gx, this will make sure the codehandler wont crash on execution
  • Loading branch information
FIX94 committed Jul 15, 2016
1 parent c8df260 commit 27595ea
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common/include/NintendontVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define __NINTENDONT_VERSION_H__

#define NIN_MAJOR_VERSION 4
#define NIN_MINOR_VERSION 417
#define NIN_MINOR_VERSION 418

#define NIN_VERSION ((NIN_MAJOR_VERSION << 16) | NIN_MINOR_VERSION)

Expand Down
12 changes: 10 additions & 2 deletions kernel/Patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,15 @@ void DoPatches( char *Buffer, u32 Length, u32 DiscOffset )
// skips __start init of debugger mem
write32(0x00003194, 0x48000028);
}
else if( TITLE_ID == 0x47465A && read32(0x5608) == 0x3C804C00 )
{
dbgprintf("Patch:[F-Zero GX Low Mem] applied\r\n");
// dont write "rfi" into 0x1000, 0x1100, 0x1200 and 0x1300
if( (read32(0) & 0xFF) == 0x4A ) // JAP
memset32( (void*)0x5630, 0x60000000, 0x10 );
else // EUR/USA
memset32( (void*)0x5634, 0x60000000, 0x10 );
}
else if(DOLMaxOff == 0x141FE0 && read32(0xF278C) == 0x2F6D616A) //Majoras Mask NTSC-U
{
dbgprintf("Patch:[Majoras Mask NTSC-U] applied\r\n");
Expand Down Expand Up @@ -3074,7 +3083,6 @@ void DoPatches( char *Buffer, u32 Length, u32 DiscOffset )
else
*(vu32*)(P2C(*(vu32*)0x1000)) = 0;
}
sync_after_write((void*)0x1000, 0x800); //not touched otherwise
//if(DebuggerHook) PatchB( codehandler_stub_offset, DebuggerHook );
//if(DebuggerHook2) PatchB( codehandler_stub_offset, DebuggerHook2 );
//if(DebuggerHook3) PatchB( codehandler_stub_offset, DebuggerHook3 );
Expand Down Expand Up @@ -3434,7 +3442,7 @@ void PatchGame()
Command2 |= 0x80000000;
write32( FLUSH_ADDR, Command2 );
dbgprintf("Jumping to 0x%08X\n", GameEntry);
sync_after_write((void*)0x1800, 0x1800); //low patches
sync_after_write((void*)0x1000, 0x2000); //low patches
write32( RESET_STATUS, GameEntry );
sync_after_write((void*)RESET_STATUS, 0x20);
// in case we patched ipl remove status
Expand Down
16 changes: 14 additions & 2 deletions kernel/asm/FakeEntryLoad.S
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ InvalidateRange1:
addi %r4, %r4, 0x20
bdnz InvalidateRange1

li %r4, 0xC0
li %r4, 0x100
mtctr %r4
lis %r4, 0x8000
ori %r4, %r4, 0x1800
ori %r4, %r4, 0x1000

InvalidateRange2:
dcbi %r0, %r4
Expand All @@ -38,4 +38,16 @@ InvalidateRange2:

sync
isync

lis %r3, 0x8000
ori %r3, %r3, 0x10A0
lwz %r0, 0(%r3)
lis %r4, 0x9421
ori %r4, %r4, 0xFF58
cmplw %r4, %r0
bne GameBoot
CodeHandlerBoot:
mtctr %r3
bctr #codehandler jumps to LR
GameBoot:
blr
Binary file modified loader/loader.dol
Binary file not shown.
4 changes: 2 additions & 2 deletions loader/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,8 +1108,8 @@ int main(int argc, char **argv)
*(vu32*)0xD3003420 = 0x5DEA;
while(*(vu32*)0xD3003420 == 0x5DEA) ;
/* Patches */
DCInvalidateRange((void*)0x80001800, 0x1800);
ICInvalidateRange((void*)0x80001800, 0x1800);
DCInvalidateRange((void*)0x80001000, 0x2000);
ICInvalidateRange((void*)0x80001000, 0x2000);
/* IPL */
DCInvalidateRange((void*)0x81300000, 0x300000);
ICInvalidateRange((void*)0x81300000, 0x300000);
Expand Down

0 comments on commit 27595ea

Please sign in to comment.