Skip to content

Commit

Permalink
improve computeBranchTargetAddress macro
Browse files Browse the repository at this point in the history
  • Loading branch information
JLaferri committed Sep 14, 2023
1 parent b698534 commit 45ddce7
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 226 deletions.
16 changes: 8 additions & 8 deletions Common/Common.s
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion External/Debug Inputs/LogFetchTime.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 23 additions & 27 deletions Output/Console/GALE01r2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -987,26 +984,25 @@ 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
60638B10 80630000
38800000 7C0323AC
7C0004AC 4C00012C
83430000 7F43D378
4BFFFF2D 2C030000
4BFFFF35 2C030000
41800050 7C7C1B78
3D808034 618CC408
7D8903A6 4E800421
Expand Down
Binary file modified Output/Console/g_core.bin
Binary file not shown.
Binary file modified Output/Console/g_core_porta.bin
Binary file not shown.
Loading

0 comments on commit 45ddce7

Please sign in to comment.