Skip to content

Commit

Permalink
Add scene checking before following scene-specific pointers
Browse files Browse the repository at this point in the history
 - Avoids segfaulting on trying to read them
  • Loading branch information
altf4 committed Jun 19, 2020
1 parent d800e31 commit 15aacd6
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 80 deletions.
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.
81 changes: 43 additions & 38 deletions Output/Netplay/GALE01r2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1217,17 +1217,16 @@ A0640002 B07D0031
BA810008 800100B4
382100B0 7C0803A6
881F2219 00000000
C21A4FA4 0000004A #Recording/SendMenuFrame.asm
C21A4FA4 0000004F #Recording/SendMenuFrame.asm
7C0802A6 90010004
9421FF6A BE810008
38610038 3863001F
54630034 3D808000
618C5604 7D8903A6
4E800421 2C030001
41820204 3880003E
98830000 3C808048
80849D30 5484443E
B0830001 3C808111
3D008048 81089D30
5508443E 2C080202
41820240 2C080208
41820238 38610038
3863001F 54630034
3880003E 98830000
B1030001 3C808111
60848DEC 80840000
90830003 3C808111
60848DF0 80840000
Expand Down Expand Up @@ -1263,35 +1262,41 @@ B0830001 3C808111
60840E52 88840000
9883002B 3C80803F
60840E76 88840000
9883002C 3C80804A
60840BC0 80840000
38840005 88840000
9883002D 3C80804A
60840BC4 80840000
38840005 88840000
9883002E 3C80804A
60840BC8 80840000
38840005 88840000
9883002F 3C80804A
60840BCC 80840000
38840005 88840000
98830030 3C8080BD
6084A810 80840000
38840028 80840000
38840038 80840000
90830031 3C8080BD
6084A810 80840000
38840028 80840000
3884003C 80840000
90830035 3C808047
60849D60 80840000
90830039 3880003E
38A00001 3D808000
618C55F0 7D8903A6
4E800421 BA810008
8001009A 38210096
7C0803A6 80790000
60000000 00000000
9883002C 3C800000
60840000 9083002D
2C080002 40820064
3C80804A 60840BC0
80840000 38840005
88840000 9883002D
3C80804A 60840BC4
80840000 38840005
88840000 9883002E
3C80804A 60840BC8
80840000 38840005
88840000 9883002F
3C80804A 60840BCC
80840000 38840005
88840000 98830030
3C800000 60840000
90830031 3C800000
60840000 90830035
2C080102 40820044
3C8080BD 6084A810
80840000 38840028
80840000 38840038
80840000 90830031
3C8080BD 6084A810
80840000 38840028
80840000 3884003C
80840000 90830035
3C808047 60849D60
80840000 90830039
3880003E 38A00001
3D808000 618C55F0
7D8903A6 4E800421
BA810008 8001009A
38210096 7C0803A6
80790000 00000000
C2005604 00000007 #Recording/ShouldRecord.asm
3C608048 80639D30
5463443E 2C030202
Expand Down
81 changes: 43 additions & 38 deletions Output/Netplay/GALJ01r2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1217,17 +1217,16 @@ A0640002 B07D0031
BA810008 800100B4
382100B0 7C0803A6
881F2219 00000000
C21A4FA4 0000004A #Recording/SendMenuFrame.asm
C21A4FA4 0000004F #Recording/SendMenuFrame.asm
7C0802A6 90010004
9421FF6A BE810008
38610038 3863001F
54630034 3D808000
618C5604 7D8903A6
4E800421 2C030001
41820204 3880003E
98830000 3C808048
80849D30 5484443E
B0830001 3C808111
3D008048 81089D30
5508443E 2C080202
41820240 2C080208
41820238 38610038
3863001F 54630034
3880003E 98830000
B1030001 3C808111
60848DEC 80840000
90830003 3C808111
60848DF0 80840000
Expand Down Expand Up @@ -1263,35 +1262,41 @@ B0830001 3C808111
60840E52 88840000
9883002B 3C80803F
60840E76 88840000
9883002C 3C80804A
60840BC0 80840000
38840005 88840000
9883002D 3C80804A
60840BC4 80840000
38840005 88840000
9883002E 3C80804A
60840BC8 80840000
38840005 88840000
9883002F 3C80804A
60840BCC 80840000
38840005 88840000
98830030 3C8080BD
6084A810 80840000
38840028 80840000
38840038 80840000
90830031 3C8080BD
6084A810 80840000
38840028 80840000
3884003C 80840000
90830035 3C808047
60849D60 80840000
90830039 3880003E
38A00001 3D808000
618C55F0 7D8903A6
4E800421 BA810008
8001009A 38210096
7C0803A6 80790000
60000000 00000000
9883002C 3C800000
60840000 9083002D
2C080002 40820064
3C80804A 60840BC0
80840000 38840005
88840000 9883002D
3C80804A 60840BC4
80840000 38840005
88840000 9883002E
3C80804A 60840BC8
80840000 38840005
88840000 9883002F
3C80804A 60840BCC
80840000 38840005
88840000 98830030
3C800000 60840000
90830031 3C800000
60840000 90830035
2C080102 40820044
3C8080BD 6084A810
80840000 38840028
80840000 38840038
80840000 90830031
3C8080BD 6084A810
80840000 38840028
80840000 3884003C
80840000 90830035
3C808047 60849D60
80840000 90830039
3880003E 38A00001
3D808000 618C55F0
7D8903A6 4E800421
BA810008 8001009A
38210096 7C0803A6
80790000 00000000
C2005604 00000007 #Recording/ShouldRecord.asm
3C608048 80639D30
5463443E 2C030202
Expand Down
38 changes: 34 additions & 4 deletions Recording/SendMenuFrame.asm
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
backup STACK_FREE_SPACE

# check if NOT VS Mode
branchl r12,FN_ShouldRecord
cmpwi r3,0x1
getMinorMajor r8
cmpwi r8, 0x0202
beq Injection_Exit
cmpwi r8, 0x0208
beq Injection_Exit

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

# Two bytes for major / minor scene
getMinorMajor r4
sth r4, 0x1(r3)
sth r8, 0x1(r3)

# send player 1 cursor x position
load r4 0x81118DEC
Expand Down Expand Up @@ -132,6 +133,18 @@ stb r4, 0x2C(r3)
# 1 == Coin in hand
# 2 == Coin down
# 3 == Not plugged in

# Reading this value involves needing to follow a dynamic pointer
# This can segfault when not in the right scene
# So just return 0's when not in there and don't follow the pointers

# Load 0's into player coins
load r4 0x00000000
stw r4, 0x2D(r3)

cmpwi r8, 0x0002
bne Not_CSS

# Player 1
load r4 0x804a0bc0
lwz r4, 0(r4)
Expand All @@ -157,6 +170,21 @@ addi r4, r4, 5
lbz r4, 0(r4)
stb r4, 0x30(r3)

Not_CSS:

# Reading this value involves needing to follow a dynamic pointer
# This can segfault when not in the right scene
# So just return 0's when not in there and don't follow the pointers

# Load 0's into cursors
load r4 0x00000000
stw r4, 0x31(r3)
load r4 0x00000000
stw r4, 0x35(r3)

cmpwi r8, 0x0102
bne Not_SSS

# Stage Select Cursor X
# 4-byte float
load r4 0x80bda810
Expand All @@ -177,6 +205,8 @@ addi r4, r4, 0x3C
lwz r4, 0(r4)
stw r4, 0x35(r3)

Not_SSS:

# Frame count
load r4 0x80479D60
lwz r4, 0(r4)
Expand Down

0 comments on commit 15aacd6

Please sign in to comment.