Skip to content

Commit 15aacd6

Browse files
committed
Add scene checking before following scene-specific pointers
- Avoids segfaulting on trying to read them
1 parent d800e31 commit 15aacd6

File tree

5 files changed

+120
-80
lines changed

5 files changed

+120
-80
lines changed

Output/Console/g_core.bin

40 Bytes
Binary file not shown.

Output/Console/g_core_porta.bin

40 Bytes
Binary file not shown.

Output/Netplay/GALE01r2.ini

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,17 +1217,16 @@ A0640002 B07D0031
12171217
BA810008 800100B4
12181218
382100B0 7C0803A6
12191219
881F2219 00000000
1220-
C21A4FA4 0000004A #Recording/SendMenuFrame.asm
1220+
C21A4FA4 0000004F #Recording/SendMenuFrame.asm
12211221
7C0802A6 90010004
12221222
9421FF6A BE810008
1223-
38610038 3863001F
1224-
54630034 3D808000
1225-
618C5604 7D8903A6
1226-
4E800421 2C030001
1227-
41820204 3880003E
1228-
98830000 3C808048
1229-
80849D30 5484443E
1230-
B0830001 3C808111
1223+
3D008048 81089D30
1224+
5508443E 2C080202
1225+
41820240 2C080208
1226+
41820238 38610038
1227+
3863001F 54630034
1228+
3880003E 98830000
1229+
B1030001 3C808111
12311230
60848DEC 80840000
12321231
90830003 3C808111
12331232
60848DF0 80840000
@@ -1263,35 +1262,41 @@ B0830001 3C808111
12631262
60840E52 88840000
12641263
9883002B 3C80803F
12651264
60840E76 88840000
1266-
9883002C 3C80804A
1267-
60840BC0 80840000
1268-
38840005 88840000
1269-
9883002D 3C80804A
1270-
60840BC4 80840000
1271-
38840005 88840000
1272-
9883002E 3C80804A
1273-
60840BC8 80840000
1274-
38840005 88840000
1275-
9883002F 3C80804A
1276-
60840BCC 80840000
1277-
38840005 88840000
1278-
98830030 3C8080BD
1279-
6084A810 80840000
1280-
38840028 80840000
1281-
38840038 80840000
1282-
90830031 3C8080BD
1283-
6084A810 80840000
1284-
38840028 80840000
1285-
3884003C 80840000
1286-
90830035 3C808047
1287-
60849D60 80840000
1288-
90830039 3880003E
1289-
38A00001 3D808000
1290-
618C55F0 7D8903A6
1291-
4E800421 BA810008
1292-
8001009A 38210096
1293-
7C0803A6 80790000
1294-
60000000 00000000
1265+
9883002C 3C800000
1266+
60840000 9083002D
1267+
2C080002 40820064
1268+
3C80804A 60840BC0
1269+
80840000 38840005
1270+
88840000 9883002D
1271+
3C80804A 60840BC4
1272+
80840000 38840005
1273+
88840000 9883002E
1274+
3C80804A 60840BC8
1275+
80840000 38840005
1276+
88840000 9883002F
1277+
3C80804A 60840BCC
1278+
80840000 38840005
1279+
88840000 98830030
1280+
3C800000 60840000
1281+
90830031 3C800000
1282+
60840000 90830035
1283+
2C080102 40820044
1284+
3C8080BD 6084A810
1285+
80840000 38840028
1286+
80840000 38840038
1287+
80840000 90830031
1288+
3C8080BD 6084A810
1289+
80840000 38840028
1290+
80840000 3884003C
1291+
80840000 90830035
1292+
3C808047 60849D60
1293+
80840000 90830039
1294+
3880003E 38A00001
1295+
3D808000 618C55F0
1296+
7D8903A6 4E800421
1297+
BA810008 8001009A
1298+
38210096 7C0803A6
1299+
80790000 00000000
12951300
C2005604 00000007 #Recording/ShouldRecord.asm
12961301
3C608048 80639D30
12971302
5463443E 2C030202

Output/Netplay/GALJ01r2.ini

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,17 +1217,16 @@ A0640002 B07D0031
12171217
BA810008 800100B4
12181218
382100B0 7C0803A6
12191219
881F2219 00000000
1220-
C21A4FA4 0000004A #Recording/SendMenuFrame.asm
1220+
C21A4FA4 0000004F #Recording/SendMenuFrame.asm
12211221
7C0802A6 90010004
12221222
9421FF6A BE810008
1223-
38610038 3863001F
1224-
54630034 3D808000
1225-
618C5604 7D8903A6
1226-
4E800421 2C030001
1227-
41820204 3880003E
1228-
98830000 3C808048
1229-
80849D30 5484443E
1230-
B0830001 3C808111
1223+
3D008048 81089D30
1224+
5508443E 2C080202
1225+
41820240 2C080208
1226+
41820238 38610038
1227+
3863001F 54630034
1228+
3880003E 98830000
1229+
B1030001 3C808111
12311230
60848DEC 80840000
12321231
90830003 3C808111
12331232
60848DF0 80840000
@@ -1263,35 +1262,41 @@ B0830001 3C808111
12631262
60840E52 88840000
12641263
9883002B 3C80803F
12651264
60840E76 88840000
1266-
9883002C 3C80804A
1267-
60840BC0 80840000
1268-
38840005 88840000
1269-
9883002D 3C80804A
1270-
60840BC4 80840000
1271-
38840005 88840000
1272-
9883002E 3C80804A
1273-
60840BC8 80840000
1274-
38840005 88840000
1275-
9883002F 3C80804A
1276-
60840BCC 80840000
1277-
38840005 88840000
1278-
98830030 3C8080BD
1279-
6084A810 80840000
1280-
38840028 80840000
1281-
38840038 80840000
1282-
90830031 3C8080BD
1283-
6084A810 80840000
1284-
38840028 80840000
1285-
3884003C 80840000
1286-
90830035 3C808047
1287-
60849D60 80840000
1288-
90830039 3880003E
1289-
38A00001 3D808000
1290-
618C55F0 7D8903A6
1291-
4E800421 BA810008
1292-
8001009A 38210096
1293-
7C0803A6 80790000
1294-
60000000 00000000
1265+
9883002C 3C800000
1266+
60840000 9083002D
1267+
2C080002 40820064
1268+
3C80804A 60840BC0
1269+
80840000 38840005
1270+
88840000 9883002D
1271+
3C80804A 60840BC4
1272+
80840000 38840005
1273+
88840000 9883002E
1274+
3C80804A 60840BC8
1275+
80840000 38840005
1276+
88840000 9883002F
1277+
3C80804A 60840BCC
1278+
80840000 38840005
1279+
88840000 98830030
1280+
3C800000 60840000
1281+
90830031 3C800000
1282+
60840000 90830035
1283+
2C080102 40820044
1284+
3C8080BD 6084A810
1285+
80840000 38840028
1286+
80840000 38840038
1287+
80840000 90830031
1288+
3C8080BD 6084A810
1289+
80840000 38840028
1290+
80840000 3884003C
1291+
80840000 90830035
1292+
3C808047 60849D60
1293+
80840000 90830039
1294+
3880003E 38A00001
1295+
3D808000 618C55F0
1296+
7D8903A6 4E800421
1297+
BA810008 8001009A
1298+
38210096 7C0803A6
1299+
80790000 00000000
12951300
C2005604 00000007 #Recording/ShouldRecord.asm
12961301
3C608048 80639D30
12971302
5463443E 2C030202

Recording/SendMenuFrame.asm

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
backup STACK_FREE_SPACE
2222

2323
# check if NOT VS Mode
24-
branchl r12,FN_ShouldRecord
25-
cmpwi r3,0x1
24+
getMinorMajor r8
25+
cmpwi r8, 0x0202
26+
beq Injection_Exit
27+
cmpwi r8, 0x0208
2628
beq Injection_Exit
2729

2830
addi r3, sp, STACK_OFST_EXI_BUF # This is the start address for the free space
@@ -32,8 +34,7 @@ li r4, CMD_MENU_FRAME # Command byte
3234
stb r4, 0x0(r3)
3335

3436
# Two bytes for major / minor scene
35-
getMinorMajor r4
36-
sth r4, 0x1(r3)
37+
sth r8, 0x1(r3)
3738

3839
# send player 1 cursor x position
3940
load r4 0x81118DEC
@@ -132,6 +133,18 @@ stb r4, 0x2C(r3)
132133
# 1 == Coin in hand
133134
# 2 == Coin down
134135
# 3 == Not plugged in
136+
137+
# Reading this value involves needing to follow a dynamic pointer
138+
# This can segfault when not in the right scene
139+
# So just return 0's when not in there and don't follow the pointers
140+
141+
# Load 0's into player coins
142+
load r4 0x00000000
143+
stw r4, 0x2D(r3)
144+
145+
cmpwi r8, 0x0002
146+
bne Not_CSS
147+
135148
# Player 1
136149
load r4 0x804a0bc0
137150
lwz r4, 0(r4)
@@ -157,6 +170,21 @@ addi r4, r4, 5
157170
lbz r4, 0(r4)
158171
stb r4, 0x30(r3)
159172

173+
Not_CSS:
174+
175+
# Reading this value involves needing to follow a dynamic pointer
176+
# This can segfault when not in the right scene
177+
# So just return 0's when not in there and don't follow the pointers
178+
179+
# Load 0's into cursors
180+
load r4 0x00000000
181+
stw r4, 0x31(r3)
182+
load r4 0x00000000
183+
stw r4, 0x35(r3)
184+
185+
cmpwi r8, 0x0102
186+
bne Not_SSS
187+
160188
# Stage Select Cursor X
161189
# 4-byte float
162190
load r4 0x80bda810
@@ -177,6 +205,8 @@ addi r4, r4, 0x3C
177205
lwz r4, 0(r4)
178206
stw r4, 0x35(r3)
179207

208+
Not_SSS:
209+
180210
# Frame count
181211
load r4 0x80479D60
182212
lwz r4, 0(r4)

0 commit comments

Comments
 (0)