• Welcome to Smashboards, the world's largest Super Smash Brothers community! Over 250,000 Smash Bros. fans from around the world have come to discuss these great games in over 19 million posts!

    You are currently viewing our boards as a visitor. Click here to sign up right now and start on your path in the Smash community!

In Progress Grab Port Priority Experimental Fix

UnclePunch

Smash Ace
Joined
Nov 9, 2014
Messages
673
Code:
$Grab Port Priority Experimental Fix 0.1 [UnclePunch]
0406cab0 38000000
C22FA8A0 00000029
9421FFBC BE810008
7C0802A6 90010040
3B200006 3F008045
63183080 80180000
2C000000 41A2005C
83D800B0 83FE002C
807F1A58 2C030000
41820014 8063002C
80631A58 2C030000
41820034 83D800B4
2C1E0000 4182002C
83FE002C 807F1A58
2C030000 4182001C
8063002C 80631A58
2C030000 41820008
48000008 48000019
3B180E90 3B39FFFF
2C190000 4082FF90
4800009C 9421FFBC
BE810008 7C0802A6
90010040 881F2225
5400D7FF 4082002C
809F010C 387F0000
38A0007F 8084004C
38C00040 80840030
3D608008 616B8148
7D6903A6 4E800421
809F1A58 387E0000
38A00000 3D608007
616B8754 7D6903A6
4E800421 819F2190
387E0000 7D8803A6
4E800021 819F2198
7FC4F378 807F1A58
7D8803A6 4E800021
80010040 7C0803A6
BA810008 38210044
4E800020 80010040
7C0803A6 BA810008
38210044 80010024
60000000 00000000

Explanation

Normally grabs are processed per character, in the order of port priority. This code makes the game not act on grab collisions per character. Instead it checks and acts on the grab conditions in a separate function after all collisions have been determined. It is here that the new logic is performed. A player can only grab another player if the player they are grabbing is not in grabbing distance of another player on that frame. Sounds a bit confusing but here are some gifs to better explain.

Case 1: Both players input grab on the same frame and are within grabbing distance of each other.

In this case, the interaction is ignored since both players are grabbing someone (each other) on the same frame.


Case 2: Multiple players input grab on the same frame and some are within grabbing distance of each other.

In this case, Blue Marth is denied a grab since Red Marth is grabbing someone else (Green Marth) on the same frame.



Case 3: Multiple players input grab on the same frame and all are within grabbing distance of each other.

In this case, everyone is denied a grab since everyone is grabbing someone else on the same frame.


Case 4: Both players input grab on the same frame but only one grab box -> hurtbox collision occurs.

In this case, Fox was never in grabbing distance of Marth but Marth was in grabbing distance of Fox, so naturally Marth got the grab.


Case 5: Both players input grab on the same frame but one player is Ice Climbers.

In this case, Popo and Marth collide at same time, so nothing happens. However, when Nana and Marth collide, Marth's grab has ended, so Nana gets the grab.


Code:
#Use with this code to disable the original grab process
#0406cab0 38000000

.macro branchl reg, address
lis \reg, \address @h
ori \reg,\reg,\address @l
mtctr \reg
bctrl
.endm

#backup original registers
stwu    r1,-68(r1)    # make space for 12 registers
stmw    r20,8(r1)    # push r20-r31 onto the stack
mflr r0
stw r0,64(sp)

##############################
## Check For Grab Conflicts ##
##############################

#initLoop
li r25, 6                #there are 6 static player blocks to check
lis r24, 0x8045
ori r24, r24, 0x3080              #r4 = player block BA

#this loops once for each block
playerBlockCheck:
lwz r0, 0(r24)
cmpwi r0, 0                     #an inactive player block will store "0" at offset 0x0
beq+ nextPlayerBlock            #so only check active players

lwz r30,0xB0(r24)                #get dynamic player block
lwz r31,0x2c(r30)                #get data struct
lwz r3, 0x1A58(r31)             #check if player grabbed anyone
cmpwi r3, 0
beq checkForNana                        #if 0, move on to nana check

lwz r3,0x2c(r3)                #get data struct
lwz r3, 0x1A58(r3)              #get player grabbed
cmpwi r3,0
beq processGrabPrefunction                #if the victim hasnt grabbed anyone, process the grab

################
## Nana Check ##
################

checkForNana:
lwz r30,0xB4(r24)                #check sub-entity
cmpwi r30,0x0
beq nextPlayerBlock                #if no nana, continue

lwz r31,0x2c(r30)                #get data struct
lwz r3, 0x1A58(r31)             #check if player grabbed anyone
cmpwi r3, 0
beq nextPlayerBlock             #if 0, move on to next player

lwz r3,0x2c(r3)                #get data struct
lwz r3, 0x1A58(r3)              #get player grabbed
cmpwi r3,0
beq processGrabPrefunction                #if the victim hasnt grabbed anyone, process the grab

b nextPlayerBlock                #if the victim grabbed someone, ignore the interaction

processGrabPrefunction:
bl processGrab


#####################
## nextPlayerBlock ##
#####################

nextPlayerBlock:
addi r24, r24, 0xe90              #blocks are 0xe90 in length
subi r25,r25,0x1
cmpwi r25,0
bne playerBlockCheck
b original                        #if all players have been checked, then nobody got jv5 conditions

#################
## ProcessGrab ##
#################

processGrab:

#backup loop info
stwu    r1,-68(r1)    # make space for 12 registers
stmw    r20,8(r1)    # push r20-r31 onto the stack
mflr r0
stw r0,64(sp)

lbz    r0, 0x2225 (r31)
rlwinm.    r0, r0, 26, 31, 31
bne    enterGrab

playGrabSound:
lwz    r4, 0x010C (r31)
addi    r3, r31, 0
li    r5, 127
lwz    r4, 0x004C (r4)
li    r6, 64
lwz    r4, 0x0030 (r4)
branchl r11,0x80088148

enterGrab:
lwz    r4, 0x1A58 (r31)
addi    r3, r30, 0
li    r5, 0
branchl r11,0x80078754

lwz    r12, 0x2190 (r31)
addi    r3, r30, 0
mtlr    r12
blrl  

lwz    r12, 0x2198 (r31)
mr    r4, r30
lwz    r3, 0x1A58 (r31)
mtlr    r12
blrl

#restore loop info
lwz r0,64(sp)
mtlr r0
lmw    r20,8(r1)    # pop r20-r31 off the stack
addi    r1,r1,68    # release the space

blr

##########
## EXIT ##
##########

original:
#restore original registers
lwz r0,64(sp)
mtlr r0
lmw    r20,8(r1)    # pop r20-r31 off the stack
addi    r1,r1,68    # release the space

lwz    r0, 0x0024 (sp)
 
Last edited:
Top Bottom