Skip to content

Commit 6410e47

Browse files
SouzookaF0bes
authored andcommitted
SLUS-20672: Add patch to see more precise completion percent in save screen
1 parent cf1ad80 commit 6410e47

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

patches/SLUS-20672_48FE0C71.pnach

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,54 @@ patch=1,EE,203670C4,word,3F5EEEEF // y fov - HD remaster
1616
patch=1,EE,002142cc,word,3c013f40
1717

1818

19+
[More Precise Completion Percentage]
20+
author=Souzooka
21+
description=Shows a more precise completion percentage in the save menu. Older saves have to be resaved with this patch on to see completion percentage.
22+
23+
// NOTE: Only saves saved with this patch active will show a correct percentage.
24+
// Saves saved without this patch will likely just display as "0.0%",
25+
// but saves saved with this patch may show arbitrary completion values when
26+
// this patch is disabled.
27+
28+
// Change code which calculates the completion percentage for save files
29+
// This is originally done by taking min(100, (total event flags - not set event flags) / 5)
30+
// e.g. min(100, (525 - 489) / 5) = 7%
31+
// and then saved as a byte on [s2+0xC].
32+
// The offsets 0xD..0xF are unused, so we can promote this directly to float.
33+
// New formula = fminf(100.0f, (525 - 489) / 5.0f) = 7.2%
34+
patch=0,EE,2024172C,extended,3C0140A0 // lui at,0x40A0
35+
patch=0,EE,20241730,extended,44810000 // mtc1 at,f00
36+
patch=0,EE,20241734,extended,44900800 // mtc1 s0,f01
37+
patch=0,EE,20241738,extended,46800860 // cvt.s.w f01,f01
38+
patch=0,EE,2024173C,extended,46000843 // div.s f01,f01,f00
39+
patch=0,EE,20241740,extended,3C0142C8 // lui at,0x42C8
40+
patch=0,EE,20241744,extended,44810000 // mtc1 at,f00
41+
patch=0,EE,20241748,extended,00000000 // nop
42+
patch=0,EE,2024174C,extended,00000000 // nop
43+
patch=0,EE,20241750,extended,46010029 // min.s f00,f00,f01
44+
patch=0,EE,20241754,extended,E640000C // swc1 f00,0xC(s2)
45+
46+
// Now here's the code which sets up the completion percentage string in the save file screen
47+
patch=0,EE,20242C20,extended,C6CC000C // lwc1 f12,0xC(s6)
48+
// Overwrite call to sprintf to unused Sony function (scePadGetSlotMax)
49+
// so that we have some space to promote the float to double (as needed for sprintf)
50+
patch=0,EE,20242C2C,extended,0C0C8864 // jal z_un_00322190
51+
// modified callsite
52+
patch=0,EE,20322190,extended,27BDFFD0 // addiu sp,sp,-0x30
53+
patch=0,EE,20322194,extended,7FBF0020 // sq ra,0x20(sp)
54+
patch=0,EE,20322198,extended,7FB00010 // sq s0,0x10(sp)
55+
patch=0,EE,2032219C,extended,7FB10000 // sq s1,0x0(sp)
56+
patch=0,EE,203221A0,extended,00808021 // addu s0,a0,zero
57+
patch=0,EE,203221A4,extended,0C0CE872 // jal z_un_0033a1c8 ; jal fptodp
58+
patch=0,EE,203221A8,extended,00A08821 // addu s1,a1,zero
59+
patch=0,EE,203221AC,extended,02002021 // addu a0,s0,zero
60+
patch=0,EE,203221B0,extended,02202821 // addu a1,s1,zero
61+
patch=0,EE,203221B4,extended,0040302D // daddu a2,v0,zero
62+
patch=0,EE,203221B8,extended,7BBF0020 // lq ra,0x20(sp)
63+
patch=0,EE,203221BC,extended,7BB00010 // lq s0,0x10(sp)
64+
patch=0,EE,203221C0,extended,7BB10000 // lq s1,0x0(sp)
65+
patch=0,EE,203221C4,extended,080CFFC2 // j z_un_0033ff08 ; j sprintf
66+
patch=0,EE,203221C8,extended,27BD0030 // addiu sp,sp,0x30
67+
// And edit the format string used for sprintf for displaying percentage in save menu
68+
patch=0,EE,20484C10,extended,66312E25 // "%.1f"
69+
patch=0,EE,20484C14,extended,00002525 // "%%"<0><0>

0 commit comments

Comments
 (0)