wiiztec
Smash Journeyman
Here's All-Star Versus, all sad faces are supposed to be colons <___<
comments apply to all lines between the line they're on and the last line with a comment
-------------------------------------------------------------------------------------------
ASV Full codes breakdown
-------------------------------------------------------------------------------------------
4A000000 90000000 #sets pointer address to 90000000
3A17F37E FF000002 #checks if the byte at 9017F37F is not 02 (angled camera mode flag)
0858809C 00000000
200300A0 00000000 #clears all player's ASV counter data
08588368 00000000
2003006C 00000000 #clears all player's CSP counter data
0477FB7C 807D002C
046DEFD4 9817009E
046DEF94 887800B8
046DEF98 98770098
046DEFCC 9877009D
0469680C 9B9E0444
046965F8 83E301BC
0469A2FC 809F01B8
04699A9C 809B01B8
0481C528 8803000A
046DEFD4 9817009E #sets all nops and all C2 codes hooked backed to their original instructions
3817F37F FF000002 #ends previous if and checks if the byte at 9017F37F is 02 (angled camera mode flag)
create force reload pointer
------------------------------ 100%
hook:80946354
lbz r12,0x53(r30) #loads player number ID into r12
mulli r12,r12,0x80 #multiplies PNID by player mem1 character ID address offset
addi r11,r30,0x5A
add r11,r11,r12 #adds current player mem1 char ID address offset to the address in r30 +0x5A and stores result in r11
lis r12,0x8059
stw r11,0xFFFF82F4(r12) #stores pointer to player 1 mem1 character ID address to 805882F4
lbz r3,0x5A(r30) #original instruction at hooked address
-------------------------
80588000 empty space
match part
-------------------------- 99%
hook:8077FB7C
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 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)
stb r7,0x68(r29) #Clears counter for CSS portrait data
addi r14,r14,0xA0 #adds offset to next player ASV data
addi r29,r29,0x6C #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
mccmpwi 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
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
lis r26,0x901C
ori r26,r26,0x4928
stbx r7,r26,r12 #Clears TSCD AD flag???
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)
cmpwi r20,-3
beq end #sanity check to prevent an infinite loop if the first char id in the ASV data bank is 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 r6
lwzx r6,r11,r6
cmpwi r6,1
beq end #Loads player stock count and branches to end if it's 1 preventing the results screen from showing the next character
lbz r23,0(r22)
cmpw r23,r18 #Loads the mem1 char ID(current character) into r23 and compares it to the character ID in r18(character to be swapped to)
bne dc #if not equal branch to do code (really struggling to come up with branch names at this point)
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-0x34
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,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
start matches with first picked characters
----------------------------------------------- 99%
hook:806DEFD4
stwu r1,-128(r1)
stmw r2,8(r1) #create stack frame
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:lbz r18,-3(r14) #loads first picked char ID from player ASV data
cmpwi r18,0xCC
beq drc #branches to don't replace character if char ID is CC (sanity check for if you unpick all chars with the CSP's)
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 -0xA8 #branch & links to random in the match part C2 code above
mtlr r27 #restores link register contents from r27
nr1:lhz r19,-2(r14) #loads first picked char costume & portrait ID's from player ASV data
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
b co #unconditioal branch to continue on
drc:lbz r3,184(r24) #loads CSS character selection (original instruction at 806DEF94)
stb r3,152(r23) #stores char ID to be loaded at start of match (original instruction at 806DEF98)
li r6,0 #sets r6 to 0
sth r6,157(r23) #stores r6 as player costume & portrait ID (original instruction at 806DEFCC)
co: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
046DEF94 60000000 #loaded CSS character selection
046DEF98 60000000 #stored character ID to be loaded at start of match
046DEFCC 60000000 #stored costume ID to be loaded at start of match
CSS: main part
0x1B0:alt:0x3E4
------------------- 100%
hook:8069680C
cmpwi r9,1
beq end #branches to end if code is executed on results screen instead of CSS
lis r12,0x8058
ori r12,r12,0x8000 #loads ASV data bank address into r12
lwz r11,0x1B0(r30) #Loads player number ID into r11
mulli r11,r11,0xA0
add r12,r12,r11 #multiplies offset to next player ASV data by PNID and adds it to ASV data bank address in r12
lbz r11,0x9C(r12) #loads offset to next char data slot from current players ASV data +0x99 into r11
lbzx r8,r12,r11 #loads byte to store next char pick to
cmplwi cr2,r8,0xFF #checks if 0xFF (ASV data limit signifier) (checks with cr2 to delay branch through other compares)
slwi r8,r28,8 #shifts selected char ID from r28 to 3rd byte of r8
or r8,r8,r29 #loads selected costume ID from r29 to 4th byte of r8
slwi r8,r8,8 #shifts contents of r8 left 1 byte
or r8,r8,r31 #loads selected portrait ID from r31 to 4th byte of r8
slwi r8,r8,8 #shifts contents of r8 left 1 byte
cmpwi r10,0x1BB #checks if r10 is 0x1BB (it's always 1BB when you choose random)
bne nr1 #branch to not random 1 if r10 is not 0x1BB
lis r8,0x3D00 #loads 0x3D000000 into r8
nr1:ori r8,r8,0xCC #loads 0xCC into the 4th byte of r8
cmplwi r25,3
bgt rsc #branches to reselect character if r25 > 3 (r25 is always > 3 when you click a csp)
cmpwi r10,0xFF
ble end #branches to end if costumes are being changed with x or y
beq cr2,end #branches to end if r8 was 0xFF back when the comparison was made
stwx r8,r12,r11 #stores char ID costume ID & portrait ID to current player ASV data address + offset to next char data slot
addi r11,r11,3
stb r11,0x9C(r12) #increments offset to next char data slot and stores to current player ASV data address +0x9C
b end #uncondtional branch to end
rsccmpwi r10,0x1BB
bne nr2 #checks if random again and branches to not random 2 if it isn't
stw r8,0(r12) #stores random ID (3D) when you add a CPU and it automatically defaults to selecting random
nr2cmpwi r11,0 #checks if offset to next char data slot already points to beginning of current player ASV data
beq end #branches to end to prevent offset from updating to point to before beginning of current player ASV data
subi r11,r11,3 #subtracts 3 from offset to next char data slot
stbx r8,r12,r11 #writes over your last picked char ID with 0xCC (this is important if you intend to unpick rather than repick your last char)
stb r11,0x9C(r12) #stores updated offset to next char data slot to current player ASV data address +0x9C
end:stb r28,1092(r30) #original instruction at hooked address
CSS: collect CSP data
------------------------ 100%
hook:806965F8
lwz r31,444(r3) #original instruction at hook address
cmpwi cr1,r10,0xFF
blt cr1,end #branches to end if costumes are being changed with x or y
lis r12,0x8058
ori r12,r12,0x8300 #loads address of CSP databank into r12
lwz r11,0x1B0(r30) #Loads player number ID into r11
mulli r11,r11,0x6C
add r12,r12,r11 #multiplies offset to next player CSP data by PNID and adds it to CSP data bank address in r12
lbz r11,0x68(r12) #loads offset to next CSP data slot from current players CSP data +0x68 into r11
slwi r8,r28,8 #shifts CSP character ID from r28 to 3rd byte of r8
or r8,r8,r31 #loads CSP costume ID from r31 to 4th byte of r8
sthx r8,12,r11 #stores CSP character ID & CSP costume ID to current player CSP data address + offset to next CSP data slot
addi r11,r11,2
stb r11,0x68(r12) #increments offset to next CSP data slot and stores to current player CSP data address +0x68
end: #the codehandler puts a branch back to the line after the instruction I hooked here
CSS: retrive CSP data
------------------------ 100%
hook:8069A2FC
lwz r4,440(r31) #original instruction at hook address
cmpwi r10,0x30
bne end #branches to end if CSP not clicked
lis r12,0x8058
ori r12,r12,0x8300 #loads address of CSP databank into r12
lwz r11,0x1B0(r31) #Loads player number ID into r11
mulli r11,r11,0x6C
add r12,r12,r11 #multiplies offset to next player CSP data by PNID and adds it to CSP data bank address in r12
lbz r11,0x68(r12) #loads offset to next CSP data slot from current players CSP data +0x68 into r11
cmpwi r11,2
bgt co #branches to continue on if not unpicking first picked char or all char selections already unpicked
li r11,0 #sets next CSP data slot offset to 0
li r26,0 #locks CSP to default costume
b dat #unconditional branch to don't add two
cocmpwi r11,0x66
bge end #sanity check to prevent CSP data slot offset being loaded as a CSP char or costume ID, branches to end if fail
subi r11,r11,3 #subtracts 3 from CSP data slot offset to point to previous picked char CSP costume ID
lbzx r26,r12,r11 #loads previous picked char CSP costume ID to be displayed into r26
subi r11,r11,1 #subtracts 1 from CSP data slot offset to point to previous picked char CSP char ID
lbzx r4,r12,r11 #loads previous picked char CSP char ID to be displayed into r4
addi r11,r11,2 #increments the CSP data slot offset to allow saving of CSP data for next picked character
dat:stb r11,0x68(r12) #stores updated CSP data slot offset to current players CSP data +0x68
end: #the codehandler puts a branch back to the line after the instruction I hooked here
CSS: retrive CSP data (teams)
--------------------------------- 100%
hook:80699A9C
lwz r4,440(r27) #original instruction at hook address
cmpwi r10,0x30
bne end #branches to end if CSP not clicked
lis r12,0x8058
ori r12,r12,0x8300 #loads address of CSP databank into r12
lwz r11,0x1B0(r30) #Loads player number ID into r11
mulli r11,r11,0x6C
add r12,r12,r11 #multiplies offset to next player CSP data by PNID and adds it to CSP data bank address in r12
lbz r11,0x68(r12) #loads offset to next CSP data slot from current players CSP data +0x68 into r11
cmpwi r11,2
bgt co #branches to continue on if not unpicking first picked char or all char selections already unpicked
li r11,0 #sets next CSP data slot offset to 0
b dat #unconditional branch to don't add two
cocmpwi r11,0x66
bge end #sanity check to prevent CSP data slot offset being loaded as a CSP char or costume ID, branches to end if fail
subi r11,r11,4 #subtracts 4 from CSP data slot offset to point to previous picked char CSP char ID
lbzx r4,r12,r11 #loads previous picked char CSP char ID to be displayed into r4
subi r29,r29,1 #prevents changing teams when you unpick characters by clicking CSP's
cmpwi r29,0
bge ir #if next team color isn't red branch over next instruction
li r29,2 #loads 2 into r29 to stay green team
ir:addi r11,r11,2 #increments the CSP data slot offset to allow saving of CSP data for next picked character
dat:stb r11,0x68(r12) #stores updated CSP data slot offset to current players CSP data +0x68
end: #the codehandler puts a branch back to the line after the instruction I hooked here
stock part
------------------------------- 99%
hook:8081C528
cmpwi r8,0x3FED #I modified stock control to set this flag in r8
bne feed #if stock control exists in the codeset r3 will already contain a needed address, if not it needs to be loaded from the address in r3
mr r8,r3 #copies stock count pointer to r8
b mc #unconditional branch to main code
feed:lwz r8,0(r3) #loads stock count pointer into r8
mc:slwi r12,r1,16
srwi r12,r12,16
cmplwi r12,0x4DE0
bne end #branches to end if last 2 bytes of r1 aren't 0x4DE0 (it's always 0x4DE0 when chars are swapped during a match)
cmpwi r25,3
bgt end #branches to end if r25 is > 3 (sanity check??)
lbz r11,2(r31) #loads player number ID into r11
lis r12,0x8058
ori r12,r12,0x8000 #loads address of ASV data bank into r12
mulli r11,r11,0xA0
add r12,r12,r11 #multiplies offset to next player ASV data by PNID & adds result to ASV data bank address in r12
lbz r11,0x9D(r12) #loads death count from current player ASV data + 0x9D
sub r4,r4,r11
stw r4,52(r8) #subtracts death count from number of stocks to start next char off with and stores to stock count address
end:lbz r0,10(r3) #original instruction at hooked address
0481BC7C 48000010 #branches over the instructions that wipe KO/Fall/SD/etc records between matches
0481BCB4 60000000 #???????
scores don't reset during character swaps
----------------------------------------------- 75%
hook:8081BC74
lis r12,0x805B
ori r12,r12,0x4B40
cmpw r11,r12
bne end #branches to end if r11 is not 0x805B4B40 which it never is during the middle of a match
stw r7,64(r3) #clears Fall count
stw r7,72(r3)
stw r7,76(r3) #clears KO count
stw r7,80(r3)
stw r7,84(r3)
sth r7,104(r3) #original instructions to reset scores, allowed to run before the beginning of a match
end:
disable angled camera
------------------------ 100%
hook:806D1CA0
cmpwi r0,8 #checks if fixed camera mode instead of angled
beq end #branches to end to allow fixed camera
li r0,0 #disables angled camera
end:subi r3,r3,23688 #original instruction at hooked address
0495506C 60000000 #stops stock matches from ending when characters are swapped
04957DEC 60000000 #?????
04947958 60000000 #stops HUD from unloading when characters are swapped
08588099 000000FF
000300A0 00000000 #sets char selection limit identifiers (FF)
E0000000 80008000 #full terminator, ends all ifs and sets base and pointer addresses back to 80000000
4A000000 90000000 #sets pointer address to 90000000
3A17F37E FF000002 #checks if the byte at 9017F37F is not 02 (angled camera mode flag)
0481EDDC 8803000C
0494FFE4 881F0040 #sets C2 codes hooked backed to their original instructions
3817F37F FF000002 #ends previous if and checks if the byte at 9017F37F is 02 (angled camera mode flag)
load characters as unloaded
------------------------------- 100%
hook:8081EDDC
lbz r0,0xC(r3) #original instruction at hooked address (loads ID for type of character spawn to do)
cmpwi r0,2
bne end #branch to end if spawn type not swap (character just pops in on stage floor)
li r0,0 #set spawn type to unloaded (necessary to prevent character from swap spawing for 1-2 frames before next hook kicks in)
end: #the codehandler puts a branch back to the line after the instruction I hooked here
run normal respawn routine when characters are swapped
---------------------------------------------------------------
hook:8094FFE4
lwz r10,0x50(r31)
lwz r9,0x44(r10)
lis r8,0x0300
ori r8,r8,0x0100
cmpw r9,r8
bne end
lbz r7,0x57(r10)
cmpwi r7,2
bne end
li r7,1
stb r7,0x40(r31) #can't really explain this in detail since Magus made it
end:lbz r0,64(r31) #original instruction at hooked address
E0000000 80008000 #full terminator, ends all ifs and sets base and pointer addresses back to 80000000
comments apply to all lines between the line they're on and the last line with a comment
-------------------------------------------------------------------------------------------
ASV Full codes breakdown
-------------------------------------------------------------------------------------------
4A000000 90000000 #sets pointer address to 90000000
3A17F37E FF000002 #checks if the byte at 9017F37F is not 02 (angled camera mode flag)
0858809C 00000000
200300A0 00000000 #clears all player's ASV counter data
08588368 00000000
2003006C 00000000 #clears all player's CSP counter data
0477FB7C 807D002C
046DEFD4 9817009E
046DEF94 887800B8
046DEF98 98770098
046DEFCC 9877009D
0469680C 9B9E0444
046965F8 83E301BC
0469A2FC 809F01B8
04699A9C 809B01B8
0481C528 8803000A
046DEFD4 9817009E #sets all nops and all C2 codes hooked backed to their original instructions
3817F37F FF000002 #ends previous if and checks if the byte at 9017F37F is 02 (angled camera mode flag)
create force reload pointer
------------------------------ 100%
hook:80946354
lbz r12,0x53(r30) #loads player number ID into r12
mulli r12,r12,0x80 #multiplies PNID by player mem1 character ID address offset
addi r11,r30,0x5A
add r11,r11,r12 #adds current player mem1 char ID address offset to the address in r30 +0x5A and stores result in r11
lis r12,0x8059
stw r11,0xFFFF82F4(r12) #stores pointer to player 1 mem1 character ID address to 805882F4
lbz r3,0x5A(r30) #original instruction at hooked address
-------------------------
80588000 empty space
match part
-------------------------- 99%
hook:8077FB7C
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 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)
stb r7,0x68(r29) #Clears counter for CSS portrait data
addi r14,r14,0xA0 #adds offset to next player ASV data
addi r29,r29,0x6C #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
mccmpwi 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
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
lis r26,0x901C
ori r26,r26,0x4928
stbx r7,r26,r12 #Clears TSCD AD flag???
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)
cmpwi r20,-3
beq end #sanity check to prevent an infinite loop if the first char id in the ASV data bank is 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 r6
lwzx r6,r11,r6
cmpwi r6,1
beq end #Loads player stock count and branches to end if it's 1 preventing the results screen from showing the next character
lbz r23,0(r22)
cmpw r23,r18 #Loads the mem1 char ID(current character) into r23 and compares it to the character ID in r18(character to be swapped to)
bne dc #if not equal branch to do code (really struggling to come up with branch names at this point)
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-0x34
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,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
start matches with first picked characters
----------------------------------------------- 99%
hook:806DEFD4
stwu r1,-128(r1)
stmw r2,8(r1) #create stack frame
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:lbz r18,-3(r14) #loads first picked char ID from player ASV data
cmpwi r18,0xCC
beq drc #branches to don't replace character if char ID is CC (sanity check for if you unpick all chars with the CSP's)
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 -0xA8 #branch & links to random in the match part C2 code above
mtlr r27 #restores link register contents from r27
nr1:lhz r19,-2(r14) #loads first picked char costume & portrait ID's from player ASV data
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
b co #unconditioal branch to continue on
drc:lbz r3,184(r24) #loads CSS character selection (original instruction at 806DEF94)
stb r3,152(r23) #stores char ID to be loaded at start of match (original instruction at 806DEF98)
li r6,0 #sets r6 to 0
sth r6,157(r23) #stores r6 as player costume & portrait ID (original instruction at 806DEFCC)
co: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
046DEF94 60000000 #loaded CSS character selection
046DEF98 60000000 #stored character ID to be loaded at start of match
046DEFCC 60000000 #stored costume ID to be loaded at start of match
CSS: main part
0x1B0:alt:0x3E4
------------------- 100%
hook:8069680C
cmpwi r9,1
beq end #branches to end if code is executed on results screen instead of CSS
lis r12,0x8058
ori r12,r12,0x8000 #loads ASV data bank address into r12
lwz r11,0x1B0(r30) #Loads player number ID into r11
mulli r11,r11,0xA0
add r12,r12,r11 #multiplies offset to next player ASV data by PNID and adds it to ASV data bank address in r12
lbz r11,0x9C(r12) #loads offset to next char data slot from current players ASV data +0x99 into r11
lbzx r8,r12,r11 #loads byte to store next char pick to
cmplwi cr2,r8,0xFF #checks if 0xFF (ASV data limit signifier) (checks with cr2 to delay branch through other compares)
slwi r8,r28,8 #shifts selected char ID from r28 to 3rd byte of r8
or r8,r8,r29 #loads selected costume ID from r29 to 4th byte of r8
slwi r8,r8,8 #shifts contents of r8 left 1 byte
or r8,r8,r31 #loads selected portrait ID from r31 to 4th byte of r8
slwi r8,r8,8 #shifts contents of r8 left 1 byte
cmpwi r10,0x1BB #checks if r10 is 0x1BB (it's always 1BB when you choose random)
bne nr1 #branch to not random 1 if r10 is not 0x1BB
lis r8,0x3D00 #loads 0x3D000000 into r8
nr1:ori r8,r8,0xCC #loads 0xCC into the 4th byte of r8
cmplwi r25,3
bgt rsc #branches to reselect character if r25 > 3 (r25 is always > 3 when you click a csp)
cmpwi r10,0xFF
ble end #branches to end if costumes are being changed with x or y
beq cr2,end #branches to end if r8 was 0xFF back when the comparison was made
stwx r8,r12,r11 #stores char ID costume ID & portrait ID to current player ASV data address + offset to next char data slot
addi r11,r11,3
stb r11,0x9C(r12) #increments offset to next char data slot and stores to current player ASV data address +0x9C
b end #uncondtional branch to end
rsccmpwi r10,0x1BB
bne nr2 #checks if random again and branches to not random 2 if it isn't
stw r8,0(r12) #stores random ID (3D) when you add a CPU and it automatically defaults to selecting random
nr2cmpwi r11,0 #checks if offset to next char data slot already points to beginning of current player ASV data
beq end #branches to end to prevent offset from updating to point to before beginning of current player ASV data
subi r11,r11,3 #subtracts 3 from offset to next char data slot
stbx r8,r12,r11 #writes over your last picked char ID with 0xCC (this is important if you intend to unpick rather than repick your last char)
stb r11,0x9C(r12) #stores updated offset to next char data slot to current player ASV data address +0x9C
end:stb r28,1092(r30) #original instruction at hooked address
CSS: collect CSP data
------------------------ 100%
hook:806965F8
lwz r31,444(r3) #original instruction at hook address
cmpwi cr1,r10,0xFF
blt cr1,end #branches to end if costumes are being changed with x or y
lis r12,0x8058
ori r12,r12,0x8300 #loads address of CSP databank into r12
lwz r11,0x1B0(r30) #Loads player number ID into r11
mulli r11,r11,0x6C
add r12,r12,r11 #multiplies offset to next player CSP data by PNID and adds it to CSP data bank address in r12
lbz r11,0x68(r12) #loads offset to next CSP data slot from current players CSP data +0x68 into r11
slwi r8,r28,8 #shifts CSP character ID from r28 to 3rd byte of r8
or r8,r8,r31 #loads CSP costume ID from r31 to 4th byte of r8
sthx r8,12,r11 #stores CSP character ID & CSP costume ID to current player CSP data address + offset to next CSP data slot
addi r11,r11,2
stb r11,0x68(r12) #increments offset to next CSP data slot and stores to current player CSP data address +0x68
end: #the codehandler puts a branch back to the line after the instruction I hooked here
CSS: retrive CSP data
------------------------ 100%
hook:8069A2FC
lwz r4,440(r31) #original instruction at hook address
cmpwi r10,0x30
bne end #branches to end if CSP not clicked
lis r12,0x8058
ori r12,r12,0x8300 #loads address of CSP databank into r12
lwz r11,0x1B0(r31) #Loads player number ID into r11
mulli r11,r11,0x6C
add r12,r12,r11 #multiplies offset to next player CSP data by PNID and adds it to CSP data bank address in r12
lbz r11,0x68(r12) #loads offset to next CSP data slot from current players CSP data +0x68 into r11
cmpwi r11,2
bgt co #branches to continue on if not unpicking first picked char or all char selections already unpicked
li r11,0 #sets next CSP data slot offset to 0
li r26,0 #locks CSP to default costume
b dat #unconditional branch to don't add two
cocmpwi r11,0x66
bge end #sanity check to prevent CSP data slot offset being loaded as a CSP char or costume ID, branches to end if fail
subi r11,r11,3 #subtracts 3 from CSP data slot offset to point to previous picked char CSP costume ID
lbzx r26,r12,r11 #loads previous picked char CSP costume ID to be displayed into r26
subi r11,r11,1 #subtracts 1 from CSP data slot offset to point to previous picked char CSP char ID
lbzx r4,r12,r11 #loads previous picked char CSP char ID to be displayed into r4
addi r11,r11,2 #increments the CSP data slot offset to allow saving of CSP data for next picked character
dat:stb r11,0x68(r12) #stores updated CSP data slot offset to current players CSP data +0x68
end: #the codehandler puts a branch back to the line after the instruction I hooked here
CSS: retrive CSP data (teams)
--------------------------------- 100%
hook:80699A9C
lwz r4,440(r27) #original instruction at hook address
cmpwi r10,0x30
bne end #branches to end if CSP not clicked
lis r12,0x8058
ori r12,r12,0x8300 #loads address of CSP databank into r12
lwz r11,0x1B0(r30) #Loads player number ID into r11
mulli r11,r11,0x6C
add r12,r12,r11 #multiplies offset to next player CSP data by PNID and adds it to CSP data bank address in r12
lbz r11,0x68(r12) #loads offset to next CSP data slot from current players CSP data +0x68 into r11
cmpwi r11,2
bgt co #branches to continue on if not unpicking first picked char or all char selections already unpicked
li r11,0 #sets next CSP data slot offset to 0
b dat #unconditional branch to don't add two
cocmpwi r11,0x66
bge end #sanity check to prevent CSP data slot offset being loaded as a CSP char or costume ID, branches to end if fail
subi r11,r11,4 #subtracts 4 from CSP data slot offset to point to previous picked char CSP char ID
lbzx r4,r12,r11 #loads previous picked char CSP char ID to be displayed into r4
subi r29,r29,1 #prevents changing teams when you unpick characters by clicking CSP's
cmpwi r29,0
bge ir #if next team color isn't red branch over next instruction
li r29,2 #loads 2 into r29 to stay green team
ir:addi r11,r11,2 #increments the CSP data slot offset to allow saving of CSP data for next picked character
dat:stb r11,0x68(r12) #stores updated CSP data slot offset to current players CSP data +0x68
end: #the codehandler puts a branch back to the line after the instruction I hooked here
stock part
------------------------------- 99%
hook:8081C528
cmpwi r8,0x3FED #I modified stock control to set this flag in r8
bne feed #if stock control exists in the codeset r3 will already contain a needed address, if not it needs to be loaded from the address in r3
mr r8,r3 #copies stock count pointer to r8
b mc #unconditional branch to main code
feed:lwz r8,0(r3) #loads stock count pointer into r8
mc:slwi r12,r1,16
srwi r12,r12,16
cmplwi r12,0x4DE0
bne end #branches to end if last 2 bytes of r1 aren't 0x4DE0 (it's always 0x4DE0 when chars are swapped during a match)
cmpwi r25,3
bgt end #branches to end if r25 is > 3 (sanity check??)
lbz r11,2(r31) #loads player number ID into r11
lis r12,0x8058
ori r12,r12,0x8000 #loads address of ASV data bank into r12
mulli r11,r11,0xA0
add r12,r12,r11 #multiplies offset to next player ASV data by PNID & adds result to ASV data bank address in r12
lbz r11,0x9D(r12) #loads death count from current player ASV data + 0x9D
sub r4,r4,r11
stw r4,52(r8) #subtracts death count from number of stocks to start next char off with and stores to stock count address
end:lbz r0,10(r3) #original instruction at hooked address
0481BC7C 48000010 #branches over the instructions that wipe KO/Fall/SD/etc records between matches
0481BCB4 60000000 #???????
scores don't reset during character swaps
----------------------------------------------- 75%
hook:8081BC74
lis r12,0x805B
ori r12,r12,0x4B40
cmpw r11,r12
bne end #branches to end if r11 is not 0x805B4B40 which it never is during the middle of a match
stw r7,64(r3) #clears Fall count
stw r7,72(r3)
stw r7,76(r3) #clears KO count
stw r7,80(r3)
stw r7,84(r3)
sth r7,104(r3) #original instructions to reset scores, allowed to run before the beginning of a match
end:
disable angled camera
------------------------ 100%
hook:806D1CA0
cmpwi r0,8 #checks if fixed camera mode instead of angled
beq end #branches to end to allow fixed camera
li r0,0 #disables angled camera
end:subi r3,r3,23688 #original instruction at hooked address
0495506C 60000000 #stops stock matches from ending when characters are swapped
04957DEC 60000000 #?????
04947958 60000000 #stops HUD from unloading when characters are swapped
08588099 000000FF
000300A0 00000000 #sets char selection limit identifiers (FF)
E0000000 80008000 #full terminator, ends all ifs and sets base and pointer addresses back to 80000000
4A000000 90000000 #sets pointer address to 90000000
3A17F37E FF000002 #checks if the byte at 9017F37F is not 02 (angled camera mode flag)
0481EDDC 8803000C
0494FFE4 881F0040 #sets C2 codes hooked backed to their original instructions
3817F37F FF000002 #ends previous if and checks if the byte at 9017F37F is 02 (angled camera mode flag)
load characters as unloaded
------------------------------- 100%
hook:8081EDDC
lbz r0,0xC(r3) #original instruction at hooked address (loads ID for type of character spawn to do)
cmpwi r0,2
bne end #branch to end if spawn type not swap (character just pops in on stage floor)
li r0,0 #set spawn type to unloaded (necessary to prevent character from swap spawing for 1-2 frames before next hook kicks in)
end: #the codehandler puts a branch back to the line after the instruction I hooked here
run normal respawn routine when characters are swapped
---------------------------------------------------------------
hook:8094FFE4
lwz r10,0x50(r31)
lwz r9,0x44(r10)
lis r8,0x0300
ori r8,r8,0x0100
cmpw r9,r8
bne end
lbz r7,0x57(r10)
cmpwi r7,2
bne end
li r7,1
stb r7,0x40(r31) #can't really explain this in detail since Magus made it
end:lbz r0,64(r31) #original instruction at hooked address
E0000000 80008000 #full terminator, ends all ifs and sets base and pointer addresses back to 80000000
Last edited: