• 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!

All-Star Versus 1.1 random selection customization guide

wiiztec

Smash Journeyman
Joined
Dec 19, 2007
Messages
402
Location
Houston, TX
NNID
wiiztec
ASV 1.1 match part
---------------------
stwu r1,-80(r1)
stmw r14,8(r1) #Creates a stack frame so I can use all the registers without worrying about ****ing **** up
lis r12,0x9018
lbz r12,0xFFFFF37F(r12) #loads fixed camera/ASV flag into r12
cmpwi r12,2 #checks if ASV is on
bne end #branches to end if it isn't
lis r14,0x8058
ori r14,r14,0x8003 #Loads the address of the beginning of my ASV memory bank +3 bytes into r14
lis r15,0x9018
ori r15,r15,0x0FB8 #Loads the address of player 1's mem2 character ID into r15 (changes character immeidately if poked with a diffferent ID)
lis r29,0x8058
ori r29,r29,0x8300
lwz r22,-0x0C(r29) #Loads the address of player 1's mem1 character ID into r22 (reloads current character when poked with a different ID)
cmpwi r25,0x14 #r25 is 0x14 before a match starts and after it ends
bne mc #Branch to main code if r25 is not 0x14, it's usually only 0x14 before the start or after the end of a match
cmplwi r26,0xBEEF #on the rare occasion r25 is 0x14 in the middle of a match r26 will not have an address in it
blt mc #branches to main code if r26's value indicates it's the middle of a match despite r25 being 0x14
loop:stw r7,0x99(r14) #Clears next char offset, death counter, & stock head offset (r7 is always 0 when this instruction executes)
stw r7,0x68(r29) #Clears counter for CSS portrait data
addi r14,r14,0xA0 #adds offset to next player ASV data
addi r29,r29,0x70 #adds offset to next player CSP data
addi r9,r9,1
cmpwi r9,4
bne loop #increments loop counter and allows escape once instructions have been run through for all players
mc:addi r16,r14,0x98
lhz r26,-7(r14)
lbzx r17,r16,r26
cmpwi cr1,r17,0x9B #checks if 9B(share stock flag) is in r17
cmpwi r30,0xBE
bne ac #checks if current player action is respawn & branches to action checks if it isn't
stbx r7,r16,r26
beq cr1,icc #branch to ice climbers check if share stock
ac:cmpwi r30,0x10B
bne end #if current action is not unloaded branch to end
cmpwi r23,0xBD
bne end #if previous action is not death branch to end
icc:lwz r12,8(r31)
lwz r11,0x110(r12) #loads alternate character ID into r11
cmpwi r11,0xF
bne co #Checks if Ice climbers, branch to continue on if not
lhz r11,0xFC(r12)
cmpwi r11,1
beq end #Checks if it was nana who died, branches to end to prevent swapping to next char if so
co:lwz r12,0x1C(r31)
lwz r12,0x28(r12)
lwz r12,0x10(r12)
lbz r12,0x55(r12) #Loads player number ID into r12
mulli r16,r12,0xA0 #multiplies the PNID by the per player ASV data offset and stores the result in r16
mulli r17,r12,0x5C #multiplies the PNID by the per player character ID offset in mem2 and stores the result in r17
mulli r23,r12,0x80 #multiplies the PNID by the per player character ID offset in mem1 and stores the result in r23
add r16,r16,r14 #adds the current player ASV data offset to the address of the beginning of the ASV data bank and stores the result in r16
sub r22,r22,r23 #subtracts the -offset to the current player from the address of player 1's character ID in mem1 and stores the result in r22
lbz r20,0x99(r16) #loads offset to next character from current players ASV data +0x99 into r20
rc:lbzx r19,r16,r20 #loads character ID into r19
cmplwi r19,0xCC #checks if the character ID to be loaded is CC which is an indicator signifying the end of the picked characters
blt lc #branches to load character if it's less than CC (all legitimite character ID's are less than CC)
li r20,-3 #sets next character offset to -3 to loop back to the first picked character after CC is encountered
b rc #loops back to reload character ID
lc:lwzx r19,r16,r20 #loads character ID, costume ID, portrait ID, & next character ID into r19
srwi r18,r19,24 #shifts only character ID from r19 to r18
cmpwi r18,0x3D
bne nr2 #checks if character ID is 3D which I designated to signify random and branches to not random 2 if it's not
mflr r24
bl rndm #preserves previous contents of link register in r24 and branch & links to random ASV subroutine
mtlr r24 #moves r24's contents back to link register
nr2:srwi r19,r19,8 #shifts next character ID out of r19
lis r11,0x8128
ori r11,r11,0xAE64 #Loads player 1 stock count address into r11
li r6,0x52
slwi r6,r6,12 #Loads player offset for stock count address into r6
mullw r6,r6,r12 #Multiplies player offset for stock count address by PNID and stores result in r4
lwzx r6,r11,r6
beq cr1,ssc
cmpwi r6,1
beq end #Loads player stock count and branches to end if it's 1 preventing unlimited respawns in FFA's
ssc:li r23,0x12 #Loads character ID of sona into r23, sona is a character not selectable from the CSS so it will always for a reload
stb r23,0(r22) #stores sona character ID to mem1 char ID address (force reload is necessary for stock heads to swap properly)
dc:stbx r18,r15,r17 #stores char ID to mem2 char ID address
addi r15,r15,5 #moves address in r15 up by 5 bytes
sthx r19,r15,r17 #stores costume and portrait ID's
addi r20,r20,3
stb r20,0x99(r16) #increments next character offset by 3 and stores to current player ASV data +0x99
lbz r21,0x9A(r16)
addi r21,r21,1
stb r21,0x9A(r16) #loads player death count increments it by 1 and stores to current player ASV data +0x9A
end:lmw r14,8(r1) #reloads previous register values back from the stack
addi r1,r1,80 #sets stack pointer back to where it was before now that the space is free again
lwz r3,44(r29) #original instruction at code hook
b sr #unconditional branch to skip random
rndm:stwu r1,-100(r1)
stmw r9,8(r1) #creates stack frame for random ASV subroutine
lis r27,0x8003
ori r27,r27,0xFC7C #loads address of brawl RNG function into r27
mflr r8 #preserves current link register in r8
mtctr r27 #moves brawl RNG function address into ctr
li r3,0x34 #sets paramater for value range to randomly select from to 0x00-0x33
bctrl #branch to ctr and link (branches to brawl RNG function)
mtlr r8 #copies the contents of r8 back into the link register
lmw r9,8(r1) #reloads previous register values back from the stack
addi r1,r1,100 #sets stack pointer back to where it was before now that the space is free again
mr r18,r3 #copies the contents of r3 (the random value the RNG function gave me is in r3) to r18
cmpwi r18,0x17
bne nrw #if ID is not wario branch to not random wario
lis r19,0x06 #sets wario's costume to warioland wario
nrw:cmpwi r18,0x11
beq rndm #if ID is sopo rechoose random ID
cmpwi r18,0x12
beq rndm #if ID is sona rechoose random ID
cmpwi r18,0x1D
beq rndm #if ID is pokemon trainer's charizard rechoose random ID
cmpwi r18,0x1F
beq rndm #if ID is pokemon trainer's squirtle rechoose random ID
cmpwi r18,0x21
beq rndm #if ID is pokemon trainer's ivysaur rechoose random ID
cmpwi r18,0x2C
blt blr #if ID is less than 0x2C ID is good so branch to blr
cmpwi r18,0x31
ble rndm #if ID is giga bowser, warioman, or alloys rechoose random ID

blr:blr #branches to the address in the link register which should be the mtlr r24 above
sr: #the codehandler puts a branch back to the line after the instruction I hooked here
#8077FB7C

Take this whole thing and copy & paste it into asmwiird take the address after the # above and paste it into the address bar, stretch the window so that none of the comments wrap over to the next line,

The bold and underlined line is the range of values that the random function is going to spit out as character ID's(slot config ID's for PMEX) you should set it to 1 above the highest character ID you want included in the random selection.

The bold lines are the branches for exclusions if there are any invalid(unused) or unwanted ID's in your range you will have to exclude them by adding to or otherwise changing these lines. There are 6 instructions for basic conditional branches they are beq (branch if equal) bne (branch if not equal) blt (branch if less than) bgt (branch if greater than) ble (branch if less or equal) & bge (branch if greater or equal). If an ID is invalid you'll want to branch to rndm to have the random function choose a new ID and if it's good you can branch to blr

Once you have edited the above to your liking you'll have to adjust the number of bytes the bl in the code below according to how many lines you added or removed because it must point to the line labeled rndm: in the code above. Usually 0x04 per line the exception being if after assembling with asmwiird if the code changed from having a 60000000 at the end to not having one or vice versa you must account for that by adding or subtracting an additional 0x04

ASV 1.1 start matches with first picked characters
------------------------------------------------------
stwu r1,-128(r1)
stmw r2,8(r1) #create stack frame
lis r12,0x9018
lbz r12,0xFFFFF37F(r12) #loads fixed camera/ASV flag into r12
cmpwi r12,2 #checks if ASV is on
stb r0,158(r23) #original instruction at hooked address
bne end #branches to end if it isn't
lis r14,0x8058
ori r14,r14,0x8003 #loads ASV data bank address into r14
lis r15,0x9018
ori r15,r15,0x0FB8 #loads the address of player 1's mem2 character ID into r15
loop:lwz r19,-3(r14) #loads character ID, costume ID, portrait ID, & next character ID into r19
srwi r18,r19,24
cmpwi r18,0x3D
bne nr1 #branches to not random 1 if char ID isn't 3D (my invented ID for random)
mflr r27 #preserves contents of link register in r27
bl -0xC4 #branch & links to random in the match part C2 code above
mtlr r27 #restores link register contents from r27
nr1:srwi r19,r19,8 #shifts next character ID out of r19
nrw:stb r18,0(r15) #stores first picked char to mem2 char ID address
sth r19,5(r15) #stores first picked char costume & portrait ID's to mem2 char ID address +5
addi r14,r14,0xA0 #adds offset to next player ASV data
addi r15,r15,0x5C #adds offset to next player mem2 char ID address
addi r22,r22,1
cmpwi r22,6
bne loop #increments loop counter and allows escape once instructions have been run through for all players (?why 6 not 4?)
end:lmw r2,8(r1) #reloads previous register values back from the stack
addi r1,r1,128 #sets stack pointer back to where it was before now that the space is free again
#806DEFD4
 
Last edited:
Top Bottom