From 45ddce738b6ca3e92eaca99e1a5695b9cdecf1da Mon Sep 17 00:00:00 2001 From: Jas Laferriere Date: Thu, 14 Sep 2023 15:06:22 -0400 Subject: [PATCH] improve computeBranchTargetAddress macro --- Common/Common.s | 16 +-- External/Debug Inputs/LogFetchTime.asm | 2 +- Output/Console/GALE01r2.ini | 50 ++++--- Output/Console/g_core.bin | Bin 8040 -> 8008 bytes Output/Console/g_core_porta.bin | Bin 8040 -> 8008 bytes Output/Netplay/GALE01r2.ini | 173 +++++++++++-------------- Output/Netplay/GALJ01r2.ini | 173 +++++++++++-------------- 7 files changed, 188 insertions(+), 226 deletions(-) diff --git a/Common/Common.s b/Common/Common.s index e679ea0f..6fb06a86 100644 --- a/Common/Common.s +++ b/Common/Common.s @@ -322,14 +322,14 @@ lwz \reg, -0x62A0(\reg) load r3, \address lwz r4, 0(r3) # Get branch instruction which contains offset -# Process 3rd byte and extend sign to handle negative branches -rlwinm r5, r4, 16, 0xFF -extsb r5, r5 -rlwinm r5, r5, 16, 0xFFFF0000 - -# Extract last 2 bytes, combine with top half, and then add to base address to get result -rlwinm r4, r4, 0, 0xFFFC # Use 0xFFFC because the last bit is used for link -or r4, r4, r5 +# This extracts the LI portion of the branch instruction and shifts it such +# that the sign bit is all the way left. Then it does a divide instruction to +# shift to the right 6 bits while preserving the sign. After that, add to +# branch instruction location to get result. +# Credit to taukhan for the divw improvement (saves 2 instructions) +rlwinm r5, r4, 6, 0xFFFFFF00 +li r4, 64 +divw r4, r5, r4 add \reg, r3, r4 .endm diff --git a/External/Debug Inputs/LogFetchTime.asm b/External/Debug Inputs/LogFetchTime.asm index 9e736e61..8583bde2 100644 --- a/External/Debug Inputs/LogFetchTime.asm +++ b/External/Debug Inputs/LogFetchTime.asm @@ -15,7 +15,7 @@ lwz r3, 0x0(r3) # 0x80479d64 - Believed to be some loading state cmpwi r3, 0 # Loading state should be zero when game starts bne EXIT -.set CONST_BACKUP_BYTES, 0xB0 # Maybe add this to Common.s +.set CONST_BACKUP_BYTES, 0xE0 # Maybe add this to Common.s .set P1_PAD_OFFSET, CONST_BACKUP_BYTES + 0x2C .set REG_DIB, 31 diff --git a/Output/Console/GALE01r2.ini b/Output/Console/GALE01r2.ini index b458de8b..4dcd582c 100644 --- a/Output/Console/GALE01r2.ini +++ b/Output/Console/GALE01r2.ini @@ -853,20 +853,19 @@ C03F0018 C05F001C 800100E4 382100E0 7C0803A6 C022A8C8 60000000 00000000 -C21A4DEC 00000028 #External/Debug Inputs/LogEngineTime.asm +C21A4DEC 00000027 #External/Debug Inputs/LogEngineTime.asm 3C608048 80639D30 5463443E 2C030202 -40820124 3C608048 +4082011C 3C608048 80639D60 2C030000 -40810114 7C0802A6 +4081010C 7C0802A6 90010004 9421FF20 BE8100B0 3D808034 618C7364 7D8903A6 4E800421 7C7E1B78 3C608016 6063E774 -80830000 5485863E -7CA50774 54A5801E -5484043A 7C842B78 +80830000 5485302E +38800040 7C8523D6 7C632214 83E30008 887F0000 2C030000 41820098 3C80804C @@ -894,25 +893,24 @@ BE8100B0 3D808034 800100E4 382100E0 7C0803A6 800D9368 60000000 00000000 -C2376A88 0000002D #External/Debug Inputs/LogFetchTime.asm +C2376A88 0000002C #External/Debug Inputs/LogFetchTime.asm 3C608048 80639D30 5463443E 2C030202 -40820150 3C608047 +40820148 3C608047 60639D64 80630000 -2C030000 4082013C +2C030000 40820134 7C0802A6 90010004 9421FF20 BE8100B0 3D808034 618C7364 7D8903A6 4E800421 7C7E1B78 3C608016 6063E774 80830000 -5485863E 7CA50774 -54A5801E 5484043A -7C842B78 7C632214 -83E30008 806100DC +5485302E 38800040 +7C8523D6 7C632214 +83E30008 8061010C 54638036 889F0001 7C632378 5463803E -906100DC 807F000A +9061010C 807F000A 889F0001 1C840004 38840016 7C7F212E 887F0001 38630001 @@ -940,21 +938,20 @@ C2376A88 0000002D #External/Debug Inputs/LogFetchTime.asm BA8100B0 800100E4 382100E0 7C0803A6 881F0002 00000000 -C2349A28 00000025 #External/Debug Inputs/LogPollTime.asm +C2349A28 00000024 #External/Debug Inputs/LogPollTime.asm 3C608048 80639D30 5463443E 2C030202 -4082010C 3C608047 +40820104 3C608047 60639D64 80630000 -2C030000 408200F8 +2C030000 408200F0 7C0802A6 90010004 9421FF20 BE8100B0 3D808034 618C7364 7D8903A6 4E800421 7C7E1B78 3C608016 6063E774 80830000 -5485863E 7CA50774 -54A5801E 5484043A -7C842B78 7C632214 +5485302E 38800040 +7C8523D6 7C632214 83E30008 807F006E 38630001 907F006E 3D808034 618CC408 @@ -978,7 +975,7 @@ C2349A28 00000025 #External/Debug Inputs/LogPollTime.asm 800100E4 382100E0 7C0803A6 80B80000 60000000 00000000 -C2375C14 0000002C #External/Debug Inputs/LogScanoutTime.asm +C2375C14 0000002B #External/Debug Inputs/LogScanoutTime.asm 48000034 5464C63E 5463463E 7C032000 4182000C 3860FFFF @@ -987,18 +984,17 @@ C2375C14 0000002C #External/Debug Inputs/LogScanoutTime.asm 7C632396 5463E73E 4E800020 3C608048 80639D30 5463443E -2C030202 40820110 +2C030202 40820108 3C608047 60639D64 80630000 2C030000 -408200FC 7C0802A6 +408200F4 7C0802A6 90010004 9421FF20 BE8100B0 3D808034 618C7364 7D8903A6 4E800421 7C7E1B78 3C608016 6063E774 -80830000 5485863E -7CA50774 54A5801E -5484043A 7C842B78 +80830000 5485302E +38800040 7C8523D6 7C632214 83E30008 887F0000 2C030000 41820080 3C60804A @@ -1006,7 +1002,7 @@ BE8100B0 3D808034 38800000 7C0323AC 7C0004AC 4C00012C 83430000 7F43D378 -4BFFFF2D 2C030000 +4BFFFF35 2C030000 41800050 7C7C1B78 3D808034 618CC408 7D8903A6 4E800421 diff --git a/Output/Console/g_core.bin b/Output/Console/g_core.bin index 1a1e9fea60562aa73ae5839346637f045e54af09..ba15a8a97f6a57515543456eb1c06ff15b533d01 100644 GIT binary patch delta 271 zcmaE1cfxLiyp*cCO+tf5L-JgMkYpD-9cCsbhbBfDs91syGXsM|BO}k`3DQPf26`3^ z3=TD|%GV}$NZr@e!J^RvDCVA!JU68wnSlYUxrxyPq*)80xh7djr1>!eM?)ebPe^iu zS;u?^#+qd13Lx8V0#I!77wN~EDp(9>!8DxV1G>vxWDhfHPv($w7v;dB{0qAB6>`>$ Krjwt@wEzHdU{W^# delta 303 zcmX?M_rh+2yp*bjO+tf5L-JgMkYpD-9cCsbhbBf9s91syGXsM|BcsUV4>CqVZFV(F z*-Ju}Hpqpvuvpc!Xje>bkh-s_i^YHdpqP6?^4ye$WCjMXAx(@nAVZ8W4XH_15@~+S zz|oM%a3>_W!K`CG17l6Has`lWHvuR%`HA#nO;s$G@L*cP@B^1ibz~1S>P-G1>n!eM?)ebPe^iu zS;u?^#+qd13Lx8V0#I!77wN~EDp(9>!8DxV1G>vxWDhfHPv($w7v;dB{0qAB6>`>$ Krjwt@wEzHdU{W^# delta 303 zcmX?M_rh+2yp*bjO+tf5L-JgMkYpD-9cCsbhbBf9s91syGXsM|BcsUV4>CqVZFV(F z*-Ju}Hpqpvuvpc!Xje>bkh-s_i^YHdpqP6?^4ye$WCjMXAx(@nAVZ8W4XH_15@~+S zz|oM%a3>_W!K`CG17l6Has`lWHvuR%`HA#nO;s$G@L*cP@B^1ibz~1S>P-G1>n