Skip to content

Commit

Permalink
Reworked the debug mode patches of 128MB build, added them all.
Browse files Browse the repository at this point in the history
  • Loading branch information
LuminarLight committed Feb 3, 2024
1 parent 6c2ecb6 commit 9db2b26
Show file tree
Hide file tree
Showing 20 changed files with 544 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/patches/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*3A84D099*
*3A84D099*
*C20596DB*
32 changes: 32 additions & 0 deletions bin/patches/SCED-51700_F41C1B29_Jak2junedemoPAL_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[TOOL]
gametitle=Jak II: Renegade [Demo] - (PAL)(SCED-51700)
author=Luminar
description=Makes the game boot in Debug Mode. You will spawn in the void. Use the Debug Menu to escape.
comment=Enables Developer/Debug Mode - Credit to water111 for discovering / documenting the required ELF edits
comment=Credits to Luminar Light for making this pnach.
comment=You will spawn in the void. Use the Debug Menu to escape.

// NOP Disabling MasterDebug
patch=0,EE,00100400,word,00000000
// NOP Disabling DebugSegment
patch=0,EE,00100408,word,00000000
// NOP SendFromBufferD call in InitListener - This is called only when MasterDebug is on
patch=0,EE,00108930,word,00000000

// 0x4ff0000 for global heap initialization - Set in InitMachine
patch=0,EE,001031dc,word,3c0604ff

// This is about changing the stack pointer
// Shoves a MIPS instruction into near the very top of the entry point
// Ghidra blows up here, but binary ninja can handle it
// Orginally at this position there is `2D E8 40 00` - `daddu $sp, $v0, $zero`
// This changes it to - `lui sp, 0x0800` Which loads the value 0x0800 to the stackpointer register, modifying it.
patch=0,EE,0010017c,word,3c1d0800

// Change DebugBootMessage from `demo` to `play`.
patch=0,EE,00127610,word,79616c70

// The level that the game wants to load on startup with 'play' DebugBootMessage is missing. Getting around this problem with DebugBootLevel is not a correct solution, since it modifies how the game looks for DGO files - making most levels unreachable.
// It is possible to tell the game to load a different DGO instead of the missing one. The patches below will make the game load 'DEMO.DGO' instead of 'PRI.DGO'.
// This is the only level that it wants on startup - the game will work fine now, but you will spawn in the void. Just use the Debug Menu to escape.
patch=1,EE,0087AB78,word,6f6d6564
11 changes: 11 additions & 0 deletions bin/patches/SCES-50361_9C712FF0_JakTPLpal_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[TOOL]
gametitle=Jak and Daxter: The Precursor Legacy - (PAL-M6) - (SCES-50361)
author=Luminar
description=Makes the game boot in Debug Mode.
comment=Enables Developer/Debug Mode - Credit to water111 for discovering / documenting the required ELF edits
comment=Credits to Luminar Light for making the patch for this game build.

// NOP Disabling DebugSegment
patch=0,EE,00100290,word,00000000
// NOP Disabling MasterDebug
patch=0,EE,0010029c,word,00000000
23 changes: 23 additions & 0 deletions bin/patches/SCES-51608_2479F4A9_Jak2pal_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[TOOL]
gametitle=Jak II: Renegade - (PAL-M7)(SCES-51608)
author=Luminar
description=Makes the game boot in Debug Mode.
comment=Enables Developer/Debug Mode - Credit to water111 for discovering / documenting the required ELF edits
comment=Credits to Luminar Light for making the patch for this game build.

// NOP Disabling MasterDebug
patch=0,EE,001003f8,word,00000000
// NOP Disabling DebugSegment
patch=0,EE,00100400,word,00000000
// NOP SendFromBufferD call in InitListener - This is called only when MasterDebug is on
patch=0,EE,00108d88,word,00000000

// 0x4ff0000 for global heap initialization - Set in InitMachine
patch=0,EE,00103364,word,3c0604ff

// This is about changing the stack pointer
// Shoves a MIPS instruction into near the very top of the entry point
// Ghidra blows up here, but binary ninja can handle it
// Orginally at this position there is `2D E8 40 00` - `daddu $sp, $v0, $zero`
// This changes it to - `lui sp, 0x0800` Which loads the value 0x0800 to the stackpointer register, modifying it.
patch=0,EE,0010017c,word,3c1d0800
23 changes: 23 additions & 0 deletions bin/patches/SCES-52460_12804727_Jak3pal_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[TOOL]
gametitle=Jak 3 - (PAL-M7)(SCES-52460)
author=Luminar
description=Makes the game boot in Debug Mode.
comment=Enables Developer/Debug Mode - Credit to water111 for discovering / documenting the required ELF edits in Jak 1/2. ELF edits for Jak 3 figured out by xTVaser.
comment=Credits to Luminar Light for making the patch for this game build.

// NOP Disabling MasterDebug
patch=0,EE,00100404,word,00000000
// NOP Disabling DebugSegment
patch=0,EE,00100408,word,00000000
// NOP SendFromBufferD call in InitListener - This is called only when MasterDebug is on
patch=0,EE,00109998,word,00000000

// 0x4ff0000 for global heap initialization - Set in InitMachine
patch=0,EE,0010372c,word,3c0604ff

// This is about changing the stack pointer
// Shoves a MIPS instruction into near the very top of the entry point
// Ghidra blows up here, but binary ninja can handle it
// Orginally at this position there is `2D E8 40 00` - `daddu $sp, $v0, $zero`
// This changes it to - `lui sp, 0x0800` Which loads the value 0x0800 to the stackpointer register, modifying it.
patch=0,EE,0010017c,word,3c1d0800
68 changes: 68 additions & 0 deletions bin/patches/SCES_53286_DF659E77_JakXpal_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[TOOL]
gametitle=Jak X (PAL)(SCES-53286)
author=Luminar
description=Makes the game boot in Debug Mode.
comment=Enables Developer/Debug Mode - Credit to Luminar for making the patch for this build.
comment=Special thanks to water111 and Vaser for their relevant research done for earlier Jak games. It helped make this possible.

//---// The following patches are on the "ELF side". //---//
// The ELF of Jak X is encrypted/packed/compressed (not sure which). It unpacks itself while booting. So analyzing it is a bit more difficult, but doable if you use a memory dump.
// If you want to patch the "early part" of memory, you should add condition (E-type extended) patches to ensure you only write after the unpacking is done.

// nop the disabling of MasterDebug, this will make MasterDebug stay 1
// Edit: We don't actually need this, and I couldn't find a way to make the game work with MasterDebug on. So this patch is commented out for now, but kept here for reference.
//patch=1,EE,00266884,word,00000000

// nop the disabling of DebugSegment, this will make DebugSegment stay 1
patch=1,EE,0026688c,word,00000000
// nop the disabling of DebugSymbols, this will make DebugSymbols stay 1
patch=1,EE,00266898,word,00000000

// The following patch was copied from Jak 3's patches (found the same thing in Jak X), but since it only matters with MasterDebug, we can comment it out.
// NOP SendFromBufferD call in InitListener - This is called only when MasterDebug is on
//patch=1,EE,00270470,word,00000000

// Extra console logs. Very useful.
// The E-type patch is needed because writing the patch too early causes weird problems, preventing us from booting the game.
patch=1,EE,E00027D2,extended,00282EC1
patch=1,EE,001EDA00,extended,00000001

// nop the weird function call in InitMachine that returns something but we don't use it because I rewrote the init heap function calls.
patch=1,EE,0026a054,word,00000000

// Change malloc param to 0x10, because it is like that in Jak 3 and it works.
patch=1,EE,0026a064,word,24040010

// Rewrite init heap function call for global heap.
patch=1,EE,0026a0d4,word,8e04bb40
patch=1,EE,0026a0d8,word,3c0604d2
patch=1,EE,0026a0dc,word,34c609a0
patch=1,EE,0026a0e0,word,00402825
patch=1,EE,0026a0e4,word,0c096e30
patch=1,EE,0026a0e8,word,00000000

// Rewrite init heap function call for debug heap.
patch=1,EE,0026a10c,word,3c0f0026
patch=1,EE,0026a110,word,3c0602f0
patch=1,EE,0026a114,word,8de4bb44
patch=1,EE,0026a118,word,00000000
patch=1,EE,0026a11c,word,0c096e30
patch=1,EE,0026a120,word,3c050500

// This was copied straight from the Jak 3 patches (I found the same place in Jak X).
// This is about changing the stack pointer
// Shoves a MIPS instruction into near the very top of the entry point
// Ghidra blows up here, but binary ninja can handle it
// Orginally at this position there is `2D E8 40 00` - `daddu $sp, $v0, $zero`
// This changes it to - `lui sp, 0x0800` Which loads the value 0x0800 to the stackpointer register, modifying it.
patch=1,EE,002665d4,word,3c1d0800

//---// The following patches are on the "GOAL side". //---//

// Make 'read-sound-info-tweaks' unable to get stuck in a while loop, by ruining the loop itself.
// This is needed to be able to boot the game in "debug mode". Without this patch, the game will get stuck forever, after printing "reading sound info ..." twice.
patch=1,EE,067a69b4,word,00000000

// Make 'set-blackout-frames' always act as if the parameter was 0. The other branch will never be called.
// This gets rid of the (sometimes infinite) blackout you get when using Game... Continue... to warp to a continue-point.
patch=1,EE,00ad3834,word,00000000
11 changes: 11 additions & 0 deletions bin/patches/SCPS-15021_EDE4FE64_JakTPLntscj_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[TOOL]
gametitle=Jak x Daxter: Kyuusekai no Isan - (NTSC-J) - (SCPS-15021)
author=Luminar
description=Makes the game boot in Debug Mode.
comment=Enables Developer/Debug Mode - Credit to water111 for discovering / documenting the required ELF edits
comment=Credits to Luminar Light for making the patch for this game build.

// NOP Disabling DebugSegment
patch=0,EE,0010028c,word,00000000
// NOP Disabling MasterDebug
patch=0,EE,00100298,word,00000000
28 changes: 28 additions & 0 deletions bin/patches/SCPS-15057_B4976DAF_Jak2ntscj_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[TOOL]
gametitle=Jak II - (NTSC-J)(SCPS-15057)
//author=
description=Makes the game boot in Debug Mode.
comment=Enables Developer/Debug Mode - Credit to water111 for discovering / documenting the required ELF edits

// NOP Disabling MasterDebug
patch=0,EE,001003f8,word,00000000
// NOP Disabling DebugSegment
patch=0,EE,00100400,word,00000000
// NOP SendFromBufferD call in InitListener - This is called only when MasterDebug is on
patch=0,EE,00108cd0,word,00000000

// 0x4ff0000 for global heap initialization - Set in InitMachine
patch=0,EE,001032bc,word,3c0604ff

// This is about changing the stack pointer
// Shoves a MIPS instruction into near the very top of the entry point
// Ghidra blows up here, but binary ninja can handle it
// Orginally at this position there is `2D E8 40 00` - `daddu $sp, $v0, $zero`
// This changes it to - `lui sp, 0x0800` Which loads the value 0x0800 to the stackpointer register, modifying it.
patch=0,EE,0010017c,word,3c1d0800

// Example - Changing the Starting Level, Disabled by Default
// Load halfpipe level by default - "halfpipe" BigEndian - 68 61 6c 66 | 70 69 70 65
// LittleEndian:
//patch=0,EE,00127f10,word,666C6168
//patch=0,EE,00127f14,word,65706970
10 changes: 10 additions & 0 deletions bin/patches/SCUS-97124_1B3976AB_JakTPLntscv1_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[TOOL]
gametitle=Jak and Daxter - The Precursor Legacy - (U) - (SCUS-97124)
//author=
description=Makes the game boot in Debug Mode.
comment=Enables Developer/Debug Mode - Credit to water111 for discovering / documenting the required ELF edits

// NOP Disabling DebugSegment
patch=0,EE,00100290,word,00000000
// NOP Disabling MasterDebug
patch=0,EE,0010029c,word,00000000
10 changes: 10 additions & 0 deletions bin/patches/SCUS-97124_472E7699_JakTPLntscv2_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[TOOL]
gametitle=Jak and Daxter - The Precursor Legacy - (U) - (SCUS-97124)
//author=
description=Makes the game boot in Debug Mode.
comment=Enables Developer/Debug Mode - Credit to water111 for discovering / documenting the required ELF edits

// NOP Disabling DebugSegment
patch=0,EE,00100290,word,00000000
// NOP Disabling MasterDebug
patch=0,EE,0010029c,word,00000000
28 changes: 28 additions & 0 deletions bin/patches/SCUS-97265_9184AAF1_Jak2ntsc_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[TOOL]
gametitle=Jak II - (U)(SCUS-97265)
//author=
description=Makes the game boot in Debug Mode.
comment=Enables Developer/Debug Mode - Credit to water111 for discovering / documenting the required ELF edits

// NOP Disabling MasterDebug
patch=0,EE,001003f8,word,00000000
// NOP Disabling DebugSegment
patch=0,EE,00100400,word,00000000
// NOP SendFromBufferD call in InitListener - This is called only when MasterDebug is on
patch=0,EE,00108cd0,word,00000000

// 0x4ff0000 for global heap initialization - Set in InitMachine
patch=0,EE,001032bc,word,3c0604ff

// This is about changing the stack pointer
// Shoves a MIPS instruction into near the very top of the entry point
// Ghidra blows up here, but binary ninja can handle it
// Orginally at this position there is `2D E8 40 00` - `daddu $sp, $v0, $zero`
// This changes it to - `lui sp, 0x0800` Which loads the value 0x0800 to the stackpointer register, modifying it.
patch=0,EE,0010017c,word,3c1d0800

// Example - Changing the Starting Level, Disabled by Default
// Load halfpipe level by default - "halfpipe" BigEndian - 68 61 6c 66 | 70 69 70 65
// LittleEndian:
//patch=0,EE,00127f10,word,666C6168
//patch=0,EE,00127f14,word,65706970
33 changes: 33 additions & 0 deletions bin/patches/SCUS-97273_A2034C69_Jak2marchdemoNTSC_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[TOOL]
gametitle=Jak II [Demo] - (U)(SCUS-97273)
author=Luminar
description=Makes the game boot in Debug Mode. You will spawn in the void. Use the Debug Menu to escape.
comment=Enables Developer/Debug Mode - Credit to water111 and Vaser for discovering / documenting the required ELF edits for the Jak 2 Demo.
comment=Thanks to Luminar Light for figuring out how to get around the missing level problem.
comment=You will spawn in the void. Use the Debug Menu to escape.

// NOP Disabling MasterDebug
patch=0,EE,001002ec,word,00000000
// NOP Disabling DebugSegment
patch=0,EE,001002f4,word,00000000
// NOP SendFromBufferD call in InitListener - This is called only when MasterDebug is on
patch=0,EE,00108660,word,00000000

// 0x4ff0000 for global heap initialization - Set in InitMachine
patch=0,EE,00102fac,word,3c0604ff

// This is about changing the stack pointer
// Shoves a MIPS instruction into near the very top of the entry point
// Ghidra blows up here, but binary ninja can handle it
// Orginally at this position there is `2D E8 40 00` - `daddu $sp, $v0, $zero`
// This changes it to - `lui sp, 0x0800` Which loads the value 0x0800 to the stackpointer register, modifying it.
patch=0,EE,00100068,word,3c1d0800

// This changes the DebugBootMessage from `demo` to `play`.
patch=0,EE,00126e10,word,79616c70

// The levels that the game wants to load on startup with 'play' DebugBootMessage are missing. Getting around this problem with DebugBootLevel is not a correct solution, since it modifies how the game looks for DGO files - making most levels unreachable.
// It is possible to tell the game to load a different DGO instead of the missing ones. The patches below will make the game load 'DEMO.DGO' instead of 'FEA.DGO' and 'PRI.DGO'.
// These are the only two levels that it wants on startup - the game will work fine now, but you will spawn in the void. Just use the Debug Menu to escape.
patch=1,EE,0077BB18,word,6f6d6564
patch=1,EE,0077C1B8,word,6f6d6564
22 changes: 22 additions & 0 deletions bin/patches/SCUS-97330_644CFD03_Jak3ntsc_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[TOOL]
gametitle=Jak 3 - (U)(SCUS-97330)
//author=
description=Makes the game boot in Debug Mode.
comment=Enables Developer/Debug Mode - Credit to water111 for discovering / documenting the required ELF edits in Jak 1/2. ELF edits for Jak 3 figured out by xTVaser.

// NOP Disabling MasterDebug
patch=0,EE,00100404,word,00000000
// NOP Disabling DebugSegment
patch=0,EE,00100408,word,00000000
// NOP SendFromBufferD call in InitListener - This is called only when MasterDebug is on
patch=0,EE,001098f0,word,00000000

// 0x4ff0000 for global heap initialization - Set in InitMachine
patch=0,EE,00103694,word,3c0604ff

// This is about changing the stack pointer
// Shoves a MIPS instruction into near the very top of the entry point
// Ghidra blows up here, but binary ninja can handle it
// Orginally at this position there is `2D E8 40 00` - `daddu $sp, $v0, $zero`
// This changes it to - `lui sp, 0x0800` Which loads the value 0x0800 to the stackpointer register, modifying it.
patch=0,EE,0010017c,word,3c1d0800
68 changes: 68 additions & 0 deletions bin/patches/SCUS-97429_3091E6FB_JakXntscv1_DebugMode.pnach
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[TOOL]
gametitle=Jak X: Combat Racing (NTSC)(SCES-53286)
author=Luminar
description=Makes the game boot in Debug Mode.
comment=Enables Developer/Debug Mode - Credit to Luminar for making the patch for this build.
comment=Special thanks to water111 and Vaser for their relevant research done for earlier Jak games. It helped make this possible.

//---// The following patches are on the "ELF side". //---//
// The ELF of Jak X is encrypted/packed/compressed (not sure which). It unpacks itself while booting. So analyzing it is a bit more difficult, but doable if you use a memory dump.
// If you want to patch the "early part" of memory, you should add condition (E-type extended) patches to ensure you only write after the unpacking is done.

// nop the disabling of MasterDebug, this will make MasterDebug stay 1
// Edit: We don't actually need this, and I couldn't find a way to make the game work with MasterDebug on. So this patch is commented out for now, but kept here for reference.
//patch=1,EE,00266884,word,00000000

// nop the disabling of DebugSegment, this will make DebugSegment stay 1
patch=1,EE,0026688c,word,00000000
// nop the disabling of DebugSymbols, this will make DebugSymbols stay 1
patch=1,EE,00266898,word,00000000

// The following patch was copied from Jak 3's patches (found the same thing in Jak X), but since it only matters with MasterDebug, we can comment it out.
// NOP SendFromBufferD call in InitListener - This is called only when MasterDebug is on
//patch=1,EE,002703e0,word,00000000

// Extra console logs. Very useful.
// The E-type patch is recommended because writing the patch too early can cause weird problems in other builds, so it is safe to have it in this one as well (though not essential).
patch=1,EE,E00027D1,extended,00282DC1
patch=1,EE,001EDA00,extended,00000001

// nop the weird function call in InitMachine that returns something but we don't use it because I rewrote the init heap function calls.
patch=1,EE,00269fd0,word,00000000

// Change malloc param to 0x10, because it is like that in Jak 3 and it works.
patch=1,EE,00269fe0,word,24040010

// Rewrite init heap function call for global heap.
patch=1,EE,0026a050,word,8e04bb40
patch=1,EE,0026a054,word,3c0604d2
patch=1,EE,0026a058,word,34c60aa0
patch=1,EE,0026a05c,word,00402825
patch=1,EE,0026a060,word,0c096e30
patch=1,EE,0026a064,word,00000000

// Rewrite init heap function call for debug heap.
patch=1,EE,0026a088,word,3c0f0026
patch=1,EE,0026a08c,word,3c0602f0
patch=1,EE,0026a090,word,8de4bb44
patch=1,EE,0026a094,word,00000000
patch=1,EE,0026a098,word,0c096e30
patch=1,EE,0026a09c,word,3c050500

// This was copied straight from the Jak 3 patches (I found the same place in Jak X).
// This is about changing the stack pointer
// Shoves a MIPS instruction into near the very top of the entry point
// Ghidra blows up here, but binary ninja can handle it
// Orginally at this position there is `2D E8 40 00` - `daddu $sp, $v0, $zero`
// This changes it to - `lui sp, 0x0800` Which loads the value 0x0800 to the stackpointer register, modifying it.
patch=1,EE,002665d4,word,3c1d0800

//---// The following patches are on the "GOAL side". //---//

// Make 'read-sound-info-tweaks' unable to get stuck in a while loop, by ruining the loop itself.
// This is needed to be able to boot the game in "debug mode". Without this patch, the game will get stuck forever, after printing "reading sound info ..." twice.
patch=1,EE,067a67a4,word,00000000

// Make 'set-blackout-frames' always act as if the parameter was 0. The other branch will never be called.
// This gets rid of the (sometimes infinite) blackout you get when using Game... Continue... to warp to a continue-point.
patch=1,EE,00ad36b4,word,00000000
Loading

0 comments on commit 9db2b26

Please sign in to comment.