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

Finally got around to annotating some of my PM codes

wiiztec

Smash Journeyman
Joined
Dec 19, 2007
Messages
402
Location
Houston, TX
NNID
wiiztec
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
mc:ccmpwi 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
rsc:ccmpwi 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
nr2:ccmpwi 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
co:ccmpwi 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
co:ccmpwi 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:

wiiztec

Smash Journeyman
Joined
Dec 19, 2007
Messages
402
Location
Houston, TX
NNID
wiiztec
Here's PM's stamina mode

-------------------------------------------------------------------------------------------
Stamina Full codes breakdown
-------------------------------------------------------------------------------------------

4A000000 90000000 #sets pointer address to 90000000
3A17F378 00FF0200 #checks if the byte at 9017F378 is not 02 (stamina mode flag)
0477FB78 93DD0034
040E14A4 9421FFE0
046CF1B4 80640004
04816090 8876006D
0483B844 8803006D
049559F0 88740007
04947370 9801008C
04816108 36A3FFFF
04816588 38A50001
04816088 38840001
04816794 38030001
0405542C 80C40010
047CBBB8 98030034
04766828 981E0048 #sets all C2 code hooks and 04 ASM writes back to their original instructions
3817F379 00FF0200 #end previous if and checks if the byte at 9017F378 is 02 (stamina mode flag)

stamina mode corpse cleanup
-------------------------------- 100%
hook:8077FB78
lis r12,0x901C
ori r12,r12,0x4924 #loads stamina dead flags address into r12
lwz r11,0x1C(r31) #(1)
lwz r11,0x28(r11) #(2)
cmplwi r11,0xFFFF
ble end #branches to end if the value in r11 is not an address (prevents crashing from trying to load from a nonexistant address)
lwz r11,0x10(r11) #(3)
cmplwi r11,0xFFFF
ble end #branches to end if the value in r11 is not an address (prevents crashing from trying to load from a nonexistant address)
lbz r11,0x55(r11) #(1 2 3) loads player number ID into r11
lbzx r6,r12,r11 #loads current player stamina dead flag byte
cmpwi r30,0xBE
bne co #branches to continue on if character action is not respawn
stbx r7,r12,r11 #clears current player stamina dead flag
co:ccmpwi r6,0x1D
bne end #checks if current player stamina dead flag was set and branches to end if not
cmpwi r30,0x4D
bne end #branches to end if character is not lying down (allows for corpse juggling)
li r30,0xBD #set current player action to death
end:ccmpwi r25,0x14
bne ssdfc #branches to skip stamina dead flags clear if not beginning or end of match
stw r7,0(r12) #clears stamina dead flags for all players
ssdfc:stw r30,52(r29) #original instruction at hooked address

hp # is max hp after respawn
---------------------------------- 100%
hook:800E14A4
stwu r1,-32(r1) #original instruction at hooked address
lis r0,0x8120
cmplw r21,r0
bgt end #branch to end if r21 > 0x81200000 (r21 should be 0x43300000 when a character is respawning)
cmplw r30,r0
blt end #branch to end if r30 < 0x81200000 (sanity check to prevent loading from an invalid address)
lbz r11,2(r30) #loads player number ID into r11
mulli r11,r11,0x5C #multiplies PNID by offset to next player mem2 player data address
lis r12,0x9018
ori r12,r12,0x0C1C #loads player 1 stamina address into r12
lhzx r4,r12,r11 #loads current player stamina into r4 from player 1 stamina address + offset to current player mem2 player data
end: #the codehandler puts a branch back to the line after the instruction I hooked here

stamina death doesn't subtract stocks
------------------------------------------ 100%
hook:80816108
cmpwi r24,5
bne end #branches to end if normal death
addi r3,r3,1 #adds 1 to stock count
end:subic. r21,r3,1 #original instruction at hooked address

exclude stamina deaths from KO tally
----------------------------------------- 100%
hook:80816588
cmpwi r20,0
beq end #branches to end if stamina death
addi r5,r5,1 #adds 1 to KO tally (original instruction at hooked address)
end: #the codehandler puts a branch back to the line after the instruction I hooked here

exclude stamina deaths from Fall tally
------------------------------------------ 100%
hook:80816088
cmpwi r20,0
beq end #branches to end if stamina death
addi r4,r4,1 #adds 1 to fall tally (original instruction at hooked address)
end: #the codehandler puts a branch back to the line after the instruction I hooked here

exclude stamina deaths from SD tally
----------------------------------------- 100%
hook: 80816794
mr r0,r3 #copies current SD tally in r3 to new SD tally in r0
cmpwi r20,0
beq end #branches to end if stamina death
addi r0,r3,1 #original instruction at hooked address
end: #the codehandler puts a branch back to the line after the instruction I hooked here

stamina dead flag set
------------------------ 100%
hook:800E1588
cmpwi r24,5
bne end #branches to end if normal death
li r0,0x1D #loads stamina dead flag into r0
lis r12,0x901C
ori r12,r12,0x4924 #loads stamina dead flags address into r12
lbz r11,1(r27) #loads player number ID into r11
stbx r0,r12,r11 #stores stamina dead flag to stamina dead flag address + PNID
end:stwu r1,-112(r1) #original instruction at hooked address

stop stamina corpses from flashing red
------------------------------------------- 100%
hook:807CBBB8
cmpwi r7,0
beq end #branches to end if stamina death rather than some other cause of flashing
stb r0,52(r3) #original instruction at hooked address (causes character to flash a color)
end: #the codehandler puts a branch back to the line after the instruction I hooked here

no slowmo stamina deaths unless slow mode is on
----------------------------------------------------- 100%
hook:80766828
lis r12,0x9018
lbz r11,0xFFFFF37E(r12) #loads slow mode on/off flag at 9017F37E into r11
cmpwi r11,1
bne end #branches to end if slow mode is not on
stb r0,72(r30) #original instruction at hooked address (causes slowmo)
end: #the codehandler puts a branch back to the line after the instruction I hooked here

use HP instead of % anywhere
--------------------------------- 100%
hook:806CF1B4
lwz r3,4(r4) #original instruction at hooked address
cmpwi r0,0x12
bne end #branches to end if r4 isn't pointing near the game mode address (r0 is always 12 when it is)
srwi r3,r3,8
slwi r3,r3,8
ori r3,r3,0x28 #loads 0x28 (stamina mode) into the 4th byte of r3
end: #the codehandler puts a branch back to the line after the instruction I hooked here

04816090 38600000 #forces respawns in stamina for offstage KO's before HP is zero
0483B844 38000000 #forces respawns in stamina for offstage KO's after HP is zero
046DF124 48000018
046DF0FC 60000000
049559F0 38600040 #allows multiple stocks in stamina
04947370 60000000 #allows stock icons to appear with the HP HUD
046A5C78 38000000 #enables first page rules menu feaures
046A8570 38000000 #enables second page rules menu feaures
046DEB3C 48000008
046DEDF0 4800000C #stops rules from resetting to infinite time
0468F04C 38000000 #shifts rules bar text to the right (otherwise overlapped by stock/time count)
0468F290 38000000 #enables normal rules bar instead of "brawl till you drop"
04690754 38000000 #enables changing amount of stocks/time with the rules bar
046A0350 3BA00064 #enables setting HP up to 990
0469F3D4 3BC00064 #sets 990 as new highest cursor position on HP selection that can be saved
0469F898 3BC00064 #allows HP selection tiles above 300 to appear
0469FDD4 3BE00064 #sets 990 as new end point for HP selection tiles to not generate beyond
040E5B94 38000000 #forces the normal results screen instead of finishes/misses

stamina option enabler
------------------------ 100%
hook:8005542C
cmpwi r0,0
beq skbzy #branch to set knockback blastzones yes if stage choice setting is choose
cmpwi r0,1
beq skbzn #branch to set knockback blastzones no if stage choice setting is random
cmpwi r0,2
beq nkbzn #branch to normal knockback blastzones no if stage choice setting is turns
cmpwi r0,3
beq nkbzy #branch to normal knockback blastzones yes if stage choice setting is ordered
cmpwi r0,4
beq nkbzn #branch to normal knockback blastzones no if stage choice setting is loser's pick
skbzy:li r12,0x0101 #sets flags for set knockback and blastzones on
b end #unconditional branch to end
skbzn:li r12,0x0102 #sets flags for set knockback and blastzones off
b end #unconditional branch to end
nkbzn:li r12,0x0202 #sets flags for normal knockback and blastzones off
b end #unconditional branch to end
nkbzy:li r12,0x0201 #sets flags for normal knockback and blastzones on
end:sth r12,0x24(r3) #stores knockback & blastzone flags to 9017F384
li r0,0 #sets stage choice to choose

046873B0 38000000 #stops music from turning off on the SSS when stage choice is set to random or ordered
3817F384 00FF0100 #checks for set knockback flag
0485CCF8 8863006D #sets knockback to default stamina set knockback
3817F385 00FF0200 #ends previous if and checks for normal knockback flag
0485CCF8 38600000 #sets knockback to normal knockback
046DF330 889A001F #sets back to default instruction that reads if fixed camera mode is on
3817F366 FF000004 #check if stage choice is set to loser's pick
046DF330 38800001 #turns on fixed camera mode
E0000000 80008000 #full terminator, ends all ifs and sets base and pointer addresses back to 80000000

4A000000 90000000 #sets pointer address to 90000000
3A17F378 00FF0200 #checks if the byte at 9017F378 is not 02 (stamina mode flag)
66000001 00000000 #skips next line if code execution is true
3A17F385 FF000002 #ends previous if and checks if the byte at 9017F385 is not 02 (no blastzones flag)
0472E8A4 D043000C
0472E8A8 D0230010
04960F48 880300B4
04118E24 9421FE60
04710230 9421FF90 #writes back the original instructions of all the C2 code addresses
3817F379 00FF0200 #ends previous if and checks if the byte at 9017F378 is 02 (stamina mode flag)
3817F384 FF000002 #checks if the byte at 9017F385 is 02 (no blastzones flag)

XYWW prep
-------------- 100%
hook:8072E8A4
lis r12,0x80B8
ori r12,r12,0xA428
lwz r12,0(r12)
lwz r11,0x80(r12) #loads address of stage camera limits into r11
lis r12,0x901C
ori r12,r12,0x4900 #loads address of XYWW floats into r12
lfs f21,0(r12) #loads float value of the difference between stage camera limit and wrap point for Y axis (CLWPD Y) into f21
lfs f22,0x20(r12) #loads float value of the difference between stage camera limit and wrap point for Y axis for Norfair (SNB) into f22
lfs f23,4(r12) #loads float value of the difference between stage camera limit and wrap point for X axis (CLWPD X) into f23
lfs f17,0(r11) #loads floot coordinate of stage's left camera limit into f17
lfs f18,4(r11) #loads floot coordinate of stage's right camera limit into f18
lfs f19,8(r11) #loads floot coordinate of stage's top camera limit into f19
lfs f20,0xC(r11) #loads floot coordinate of stage's bottom camera limit into f18
fsubs f17,f17,f23 #subtracts CLWPD X from stage's left camera limit and stores the result in f17
fadds f18,f18,f23 #adds CLWPD X to stage's left camera limit and stores the result in f18
lis r11,0x9018
lbz r11,0xF3B(r11)
cmpwi r11,0xB
beq sin #loads stage ID into r11 and branches to stage is norfair if it's norfair
fadds f19,f19,f21 #adds CLWPD Y to stage's top camera limit and stores the result in f19
fsubs f20,f20,f21 #subtracts CLWPD Y from stage's bottom camera limit and stores the result in f20
b sf #unconditional branch to store floats
sin:fsubs f19,f19,f21 #subtracts CLWPD Y from stage's top camera limit and stores the result in f19
fsubs f20,f20,f22 #subtracts SNB from stage's bottom camera limit and stores the result in f20
sf:stfs f17,0x0C(r12) #stores float coordinate of stage's left wrap point to unused memory in mem2
stfs f18,0x10(r12) #stores float coordinate of stage's right wrap point to unused memory in mem2
stfs f19,0x14(r12) #stores float coordinate of stage's top wrap point to unused memory in mem2
stfs f20,0x18(r12) #stores float coordinate of stage's bottom wrap point to unused memory in mem2

X/Y world wrap
------------------ 90%
hook:8072E8A8
stwu r1,-128(r1)
stmw r2,8(r1) #creates a stack frame so I can freely use all registers
lis r11,0x8000 #loads 0x80000000 into r11
lwz r5,136(r3) #phantom wings stuff
stfs f1,4(r4) #?????
lis r6,0x901C
ori r6,r6,0x4900 #loads address of XYWW floats into r6
lfs f17,4(r4) #loads float coordinate of current player's Y position into f17
lfs f18,0x14(r6) #loads float coordinate of stage's top wrap point into f18
lfs f19,0x18(r6) #loads float coordinate of stage's bottom wrap point into f19
lwz r17,4(r4) #loads float coordinate of current player's Y position into r17
lwz r18,0x14(r6) #loads float coordinate of stage's top wrap point into r18
lwz r19,0x18(r6) #loads float coordinate of stage's bottom wrap point into r19
lfs f20,0(r4) #loads float coordinate of current player's X position into f20
lfs f21,0x0C(r6) #loads float coordinate of stage's left wrap point into f21
lfs f22,0x10(r6) #loads float coordinate of stage's right wrap point into f22
lwz r20,0(r4) #loads float coordinate of current player's X position into r20
lwz r21,0x0C(r6) #loads float coordinate of stage's left wrap point into r21
lwz r22,0x10(r6) #loads float coordinate of stage's right wrap point into r22
subis r29,r19,1
cmplw r17,r29
beq etcd #branches to end temp collision disable if current player has wrapped from stage's top wrap point to stage's bottom wrap point
subis r29,r18,1
cmplw r17,r29
beq etcd #branches to end temp collision disable if current player has wrapped from stage's bottom wrap point to stage's top wrap point
subis r29,r22,1
cmplw r20,r29
beq etcd #branches to end temp collision disable if current player has wrapped from stage's left wrap point to stage's right wrap point
subis r29,r21,1
cmplw r20,r29
bne detcd #branches to don't end temp collision disable if current player has not wrapped from stage's right wrap point to stage's LWP
etcd:addi r30,r6,0x28 #adds 0x28 to XYWW floats address in r6 to store TSCD AD flags address in r30
lbz r24,8(r6) #loads player number ID from stamina flags area into r24
stbx r15,r30,r24 #clears current player's TSCD currently wrapping flag (AD)
detcd:li r7,7
li r8,0
lbz r9,188(r3)
cmpwi r9,7
bne- 0x0C
li r9,5
stb r9,188(r3) #phantom wings stuff (part of the original x world wrap code, I don't know what it does)
cmpwi r30,8
bne end #branches to end if r30 isn't 8 (prevents crash)
lwz r12,0x1C(r31) #(1)
cmplw r12,r11
blt end #sanity check, branches to end if r12 is not a valid address
lwz r12,0x28(r12) #(2)
cmplw r12,r11
blt end #sanity check, branches to end if r12 is not a valid address
lwz r27,0x10(r12)
lbz r24,0x55(r27) #(1 2) loads player number ID into r24
lwz r28,0x10(r27) #loads value that can identify what is wrapping into r28?
cmplwi r28,0xFFFF
bgt end #branches to end if value in r28 is greater than 0xFFFF to prevent items from wrapping
lwz r26,-0xB4(r27) #loads current player damage integer into r26
lis r11,0x9018
ori r11,r11,0x0C1C #loads player 1 stamina address into r11
mulli r25,r24,0x5C #multiplies PNID by mem2 per player data offset and stores result in r25
lhzx r25,r11,r25 #loads current player stamina into r25 from player 1 stamina address + offset to current player mem2 player data
cmpw r26,r25
bge end #branches to end disallowing wrapping if current player's damage taken is >= to current player's max stamina
addi r11,r6,0x24 #loads stamina dead flags address into r11
lbzx r25,r11,r24 #loads current player stamina dead flag byte into r25 from stamina dead flags address + PNID
cmpwi r25,0x1D
beq end #branches to end if current player's stamina dead flag is set (appears to be redundant with above branch)
lwz r12,0x7C(r31)
lhz r11,0x06(r12) #loads current player previous action into r11
lhz r12,0x3A(r12) #loads cureent player action into r12
cmpwi r12,0xBC
beq end #branches to end if current action is drowning (if allowed you would drown forever)
cmpwi r12,0xBE
beq end #branches to end if current action is respawn (if allowed you take wrap damage on respawn)
cmpwi r12,0xC6
beq end #branches to end if current action is eaten by summit fish (if allowed you're trapped in the fish)
cmpwi r12,0xF1
beq end #branches to end if current action is Kirby/MK uthrow (if allowed you take wrap damage and jump up through the stage)
cmpwi r11,0x116
beq end #branches to end if current action is final smash (some final smashes crash when wrapping)
lwz r11,0x64(r31)
lwz r11,-0xC(r11)
lbz r11,0x3F(r11) #loads current player is grabbed/being thrown flag into r11
cmpwi r11,1
beq end #branches to end if current player is grabbed/thrown (prevents ganondorf/kirby/DDDK cheese)
fcmpo cr0,f17,f18
blt bwpc #branches to bottom wrap point check if current player's Y coordinate is less than the stage's top wrap point
li r10,0xAD #sets flag 0xAD in r10 indicating a wrap is in progress
subis r17,r19,1 #sets current player Y coordinate to bottom wrap point -0x10000 (adds about .5-1 in float)
bwpc:fcmpo cr0,f17,f19
bgt lwpc #branches to left wrap point check if current player's Y coordinate is greater than the stage's bottom wrap point
li r10,0xAD #sets flag 0xAD in r10 indicating a wrap is in progress
subis r17,r18,1 #sets current player Y coordinate to top wrap point -0x10000 (subtracts about .5-1 in float)
lwpc:fcmpo cr0,f20,f21
bgt rwpc #branches to right wrap point check if current player's X coordinate is greater than the stage's left wrap point
li r10,0xAD #sets flag 0xAD in r10 indicating a wrap is in progress
subis r20,r22,1 #sets current player X coordinate to right wrap point -0x10000 (subtracts about .5-1 in float)
stb r7,188(r3)
stb r8,117(r5) #phantom wings stuff (part of the original x world wrap code, I don't know what it does)
rwpc:fcmpo cr0,f20,f22
blt adc #branches to AD check if current player's X coordinate is less than the stage's right wrap point
li r10,0xAD #sets flag 0xAD in r10 indicating a wrap is in progress
subis r20,r21,1 #sets current player X coordinate to left wrap point -0x10000 (adds about .5-1 in float)
stb r7,188(r3)
stb r8,117(r5) #phantom wings stuff (part of the original x world wrap code, I don't know what it does)
adc:ccmpwi r10,0xAD
bne end #branches to end if a wrap is not in progress
addi r30,r6,0x30 #Loads WD AD flags address into r30
lwz r12,8(r31)
lwz r11,0x110(r12) #loads alternate character ID into r11
cmpwi r11,0xF
bne fs #branches to flag store if character isn't ice climbers
lhz r11,0xFC(r12) #loads popo or nana ID into r11
cmpwi r11,1
beq nwd #branches to no wrap damage if nana
fs:stbx r10,r30,r24 #stores AD flag to WD AD flags address + PNID
nwd:subi r30,r30,4
stbx r10,r30,r24 #stores AD flag to HI AD flags address + PNID
subi r30,r30,4
stbx r10,r30,r24 #stores AD flag to TSCD AD flags address + PNID
stb r24,8(r6)
end:stw r17,16(r3) #stores current player Y coordinate
stw r20,12(r3) #stores current player X coordinate
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

04960F48 38000000 #disables offscreen magnifying glass
141C4904 40A00000 #writes CLWPD X to 901C4904

temp stage collision disable
----------------------------- 100%
hook:80118E24
lis r11,0x8000 #loads 0x80000000 into r11
cmplw r31,r11
blt ac #branches to allow collision if value in r31 is not an address
lbz r0,0x55(r31) #loads player number ID into r0
lis r12,0x901C
ori r12,r12,0x4928 #loads TSCD AD flags address into r12
lbzx r11,r12,r0 #loads current player's currently wrapping flag (AD) into r11 from TSCD AD flags address + PNID
cmpwi r11,0xAD
bne ac #branches to allow collision if current player's AD flag is not set
lbz r11,-0x20(r12) #loads player number ID from stamina flags area into r11
cmpw r11,r0
bne ac #branches to allow collision if PNID's do not match (prevents accidentally disabling collision for the wrong player)
blr #branches back to address in link register skipping the stage collision function
ac:stwu r1,-416(r1) #original instruction at hooked address

141C4900 41A00000 #writes CLWPD Y to 901C4900
141C4920 42700000 #writes SNB to 901C4920

temp hitbox interpolation disable
----------------------------------- 100%
hook:8076052C
lis r7,0x8000 #loads 0x80000000 into r7
lis r12,0x8138 #loads 0x81380000 into r11
lwz r11,0xC8(r24) #(1)
cmplw r11,r7
blt end
cmplw r11,r12
bgt end #sanity checks, they branch to end if value in r11 is invalid as an address
lwz r11,0x1C(r11) #(2)
cmplw r11,r7
blt end
cmplw r11,r12
bgt end #sanity checks, they branch to end if value in r11 is invalid as an address
lwz r11,0x28(r11) #(3)
cmplw r11,r7
blt end
cmplw r11,r12
bgt end #sanity checks, they branch to end if value in r11 is invalid as an address
lwz r11,0x10(r11) #(4)
cmplw r11,r7
blt end
cmplw r11,r12
bgt end #sanity checks, they branch to end if value in r11 is invalid as an address
lbz r11,0x55(r11) #(1 2 3 4) loads player number ID into r11
lis r12,0x901C
ori r12,r12,0x492C #loads interpolation AD flags address into r12
lbzx r7,r12,r11 #loads current player's currently wrapping flag (AD) into r7 from interpolation AD flags address + PNID
cmpwi r7,0xAD
blt end #branches to end if interpolation AD flag not set
li r27,1 #loads 1 into r27 (if r27 is 1 hitboxes are not interpolated)
addi r7,r7,1 #adds 1 to AD flag
stbx r7,r12,r11 #stores incremented AD flag to interpolation AD flags address + PNID
cmpwi r7,0xB0
blt end #branches to end if interpolation AD flag is not 0xBO yet (used as a timer to disable hitbox interpolation for 3 frames)
stbx r15,r12,r11 #clears current player interpolation AD flag
end:ccmplwi r27,1 #original instruction at hooked address

wrap damage
--------------- 100%
hook:8076802C
lfs f1,148(r26) #original instruction at hooked address
lis r12,0x901C
ori r12,r12,0x4930 #loads wrap damage AD flags address into r12
lis r11,0x8100 #loads 0x81000000 into r11
lwz r3,0x3C(r22) #(1)
cmplw r3,r11
blt end #sanity check to make sure value in r3 is an address in the 81 range branches to end if not
lwz r3,0x1C(r3) #(2)
cmplw r3,r11
blt end #sanity check to make sure value in r3 is an address in the 81 range branches to end if not
lwz r3,0x28(r3) #(3)
cmplw r3,r11
blt end #sanity check to make sure value in r3 is an address in the 81 range branches to end if not
lwz r3,0x10(r3) #(4)
cmplw r3,r11
blt end #sanity check to make sure value in r3 is an address in the 81 range branches to end if not
lbz r3,0x55(r3) #(1 2 3 4) loads player number ID into r3
lbzx r11,r12,r3 #loads current player AD flag byte from wrap damage wrap damage AD flags address + PNID
cmpwi r11,0xAD
bne end #branches to end if current player wrap damage AD flag not set
lfs f1,-0x2C(r12) #loads CLWPD X into r1 as wrap damage amount (5 in float)
stbx r15,r12,r3 #clears current player's wrap damage AD flag
end: #the codehandler puts a branch back to the line after the instruction I hooked here

E0000000 80008000 #full terminator, ends all ifs and sets base and pointer addresses back to 80000000
 
Last edited:

wiiztec

Smash Journeyman
Joined
Dec 19, 2007
Messages
402
Location
Houston, TX
NNID
wiiztec
--------------------------------------------------
0 to death mode (regen) full code breakdown
--------------------------------------------------

regen doesn't give bunny ears
--------------------------------- 100%
hook:806DF180
lbz r8,0x1A(r26) #original instruction at hooked address (loads bunny mode flag (now regen))
cmpwi r8,2
bne end #branch to end if not regen mode
li r8,0 #sets value for no flower or bunny ears
end: #the codehandler puts a branch back to the line after the instruction I hooked here

0 to death mode main part
----------------------------- 98%
hook:80769694
stfs f1,0(r4) #original instruction at hooked address (stores damage)
stwu r1,-128(r1)
stmw r2,8(r1) #creates stack frame so I can freely use all registers
lis r12,0x9018
lbz r12,0x0F3B(r12) #loads stage ID into r12
cmpwi r12,0x28
beq end #branches to end if stage is results screen
cmpwi r27,3
beq end #branches to end if r27 is 3 (???????)
lis r12,0x8058
ori r12,r12,0x82FC #loads frames till damage reset timers address into r12
lis r14,0x8171
ori r14,r14,0xD278 #loads player 1's damage display address into r14
lis r15,0x9018
ori r15,r15,0x0C1C #loads player 1's set stamina address into r15
lis r19,0x901C
ori r19,r19,0x4930 #loads wrap damage AD flags address into r19
lbz r8,-0x18A2(r15) #loads regen mode flag into r8
cmpwi r8,2
bne end #branches to end if not regen mode
lis r8,0x8180 #loads 0x81800000 into r8
lwz r11,0x3C(r22) #loads player/character main index into r11
lwz r24,0x08(r11)
lwz r23,0x110(r24) #loads alternate character ID into r23
cmpwi r23,0x0F
bne nic #branches to not ice climbers if character is not ice climbers
lhz r24,0xFC(r24) #loads popo or nana ID into r24
cmpwi r24,0
bgt end #branches to end if it's nana
nic:lwz r18,0x7C(r11)
lbz r17,0x7F(r18) #loads hitbox has connected flag into r17
lhz r18,0x3A(r18) #loads current action into r18
lwz r11,0x1C(r11) #(1)
cmplw r11,r8
bgt end #branches to end if value in r11 is greater than 0x81800000
lwz r11,0x28(r11) #(2)
cmplwi r11,0xFFFF
blt end #sanity check, branches to end if value in r11 is invalid as an address
lwz r11,0x10(r11) #(3)
cmplwi r11,0xFFFF
blt end #sanity check, branches to end if value in r11 is invalid as an address
lwz r24,0x10(r11) #????? (value goes up by random amount before and after every match)
cmpwi r24,0
blt end #branches to end if r24 is less than 0 (sanity check??)
lbz r24,0x55(r11) #(1 2 3) loads player number ID into r24
lbzx r10,r19,r24 #loads current player's wrap damage AD flag into r10
cmpwi r10,0xAD
beq rt #branches to reset timer if AD flag is active (so you can't camp offstage to reset HP in stamina w/o blastzones)
cmpwi r18,0x74
beq rt #branches to reset timer if action is ledge grab (prevents planking)
lwz r10,4(r4) #loads current player's damage to be added into r10
cmpwi r10,0
beq it #branches to increment timer if damage to be added is 0
rt:stbx r0,r12,r24 #resets current player's frames until damage reset timer
b end #unconditional branch to end
it:lbzx r10,r12,r24 #loads current player's frames until damage reset timer
cmpwi r10,0
bgt ac #branches to already counting if frame timer is greater than 0
cmpwi r18,0x00B
bgt end #branches to end if action is anything greater than first jump
ac:mulli r21,r24,0x5C #multiplies PNID by mem2 per player data offset and stores result in r21
lbz r20,-0x18B7(r15) #loads frame control option byte into r20
cmpwi cr2,r20,2 #checks if frame control is on
cmpwi r10,90 #checks if current players frame timer has reached the default 90 frames
bne cr2,uds #branches to use default setting if frame control is not on
addi r20,r15,2
lhzx r20,r20,r21 #loads current player's frame control timer setting into r20
cmpw r10,r20
uds:blt add #branches to add (increments timer) if current player's frame timer is lower than the set amount
cmpwi r17,1
beq rd #branches to reset damage if current player has landed an attack
cmpwi r18,0x00B
ble rd #branches to reset damage if action is <= first jump
cmpwi r18,0x01A
blt end #branches to end if action is less than enter shield
cmpwi r18,0x020
bgt end #branches to end if action is greater than roll back
rd:li r11,0x271E #loads 0x271E into r11
slwi r11,r11,4 #shifts value in r11 left 1 byte so it becomes 0x271E0
lbz r10,-0x18BA(r15) #loads match type byte into r10
cmpwi r10,1
beq ntoc #branches to not time or coin if it's stock
addi r11,r11,0xA80 #adds 0xA80 to r11 (offset between players' damage display addresses)
ntoc:mullw r11,r11,r24 #multiplies OBPDDA by PNID and stores result in r11
sub r14,r14,r11 #subtracts offset to current player damage display address from P1's DDA (it's a negative offset)
stw r0,0(r14) #clear's current player damage display
li r16,1 #loads 1 into r16
stw r16,4(r14) #sets current player's previous displayed damage to 1 (otherwise it would countdown)
lbz r11,-0x18A4(r15) #loads 300%/stamina mode flag into r11
cmpwi r11,1
blt nso3 #branches to not stamina or 300% if flags not set
li r16,300
stw r16,0(r14) #sets current player damage display to 300
li r16,301
stw r16,4(r14) #sets current player previous damage display to 301
lis r17,0x4396
stw r17,0(r4) #sets current player actual damage to 300
beq nsm #branches to not stamina mode if it's 300% mode
lhzx r16,r15,r21 #loads current player stamina setting into r16 from P1's stamina address + offset to current player mem2 player data
stw r16,0(r14) #stores current player stamina setting to current player damage display (now HP)
subi r16,r16,1
stw r16,4(r14) #subtracts 1 from current player stamina setting and stores to current player previous damage display
nso3:stw r0,0(r4) #sets current player actual damage to 0
nsm:li r10,-1 #sets r10 to -1 so the next line resets frame timer to 0
add:addi r10,r10,1 #increments current player frame timer by 1
stbx r10,r12,r24 #stores current player frame timer to frames till damage reset timers address + PNID
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

046A0348 3BA00019
0469F3CC 3BC00019
0469F890 3BC00019
0469FDCC 3BE00019 #sets 240 as limit for frame control list menu tiles

0TDM frame control in stamina
---------------------------------- 99%
hook:806844E4
li r0,1 #sets list menu type to stamina
cmpwi r8,0
bne end #branches to end if r8 is not 0 (sanity check??)
lis r12,0x9017
ori r12,r12,0xF365 #loads rules settings address into r12
lbz r12,0(r12) #loads frame control byte into r12
cmpwi r12,2
bne end #branches to end if frame control is off
li r0,0 #sets list menu type to handicap/stock control/frame control
end: #the codehandler puts a branch back to the line after the instruction I hooked here

create list menu pointers & set stock/frame control off by default when in stamina
------------------------------------------------------------------------------------------- 100%
hook:80693A6C
stw r5,464(r30) #original instruction at hooked address
lis r12,0x8058
ori r12,r12,0x82E0 #loads player 1's list menu pointer address
mulli r11,r25,4 #multiplies PNID (already in r25) by 4 and stores result in r11
cmplwi cr3,r11,0x0C
bgt cr3,end #branch to end if if offset is to player beyond P4
stwx r30,r12,r11 #store current player's list menu pointer to P1 list menu pointer address + offset to current player
lis r12,0x9018
lbz r11,0xFFFFF378(12) #loads stamina mode flag from 9017F378
cmpwi cr3,r11,2
bne cr3,end #branches to end if it's not stamina mode
stb r8,0xFFFFF365(12) #turns frame control off
end: #the codehandler puts a branch back to the line after the instruction I hooked here

store stamina values when frame control is turned on
---------------------------------------------------------- 100%
hook:806A8388
stb r0,5(r30) #original instruction at hooked address
lis r5,0x8100 #loads 0x81000000 into r5
lis r7,0x8180 #loads 0x81800000 into r7
li r10,0 #sets r10 to 0
lis r12,0x9018
ori r12,r12,0x0C1C #loads player 1 stamina address into r12
loop:lis r11,0x8058
ori r11,r11,0x82E0 #loads player 1 list pointer address into r11
lwzx r11,r11,r10 #loads players list pointer into r11
cmplw r11,r5
blt end
cmplw r11,r7
bgt end #branches to end if value in r11 is not a valid 81 range mem1 address (81000000-81800000)
lwz r11,0x1D0(r11) #loads players stamina list menu setting
mulli r11,r11,10 #multiplies it by 10 so it's the actual stamina value
cmpwi r11,0
bne nz #if stamina is not 1 (0 is value for list menu tile for 1 stamina)
li r11,1 #set stamina to 1
nz:sth r11,0(r12) #store stamina to actual stamina value address
addi r12,r12,0x5C #increment r12 to point to next player's stamina address
addi r10,r10,0x04 #increment r10 to be offset to next player's list menu pointer
cmpwi r10,0x10
bne loop #branches back to loop until code has been run through for all 4 players
end: #the codehandler puts a branch back to the line after the instruction I hooked here

set stock/frame control to off at results screen
----------------------------------------------------- 99%
hook:80769698
lis r12,0x9018 #loads 0x90180000 into r12
lbz r11,0xF3B(r12) #loads stage ID into r11
cmpwi r11,0x28
bne end #branches to end if stage isn't results screen
lis r11,0x8059 #loads 0x80590000 into r11
stw r0,0xFFFF82F8(r11) #???????
lbz r11,0xFFFFF378(12) #loads stamina mode flag into r11
cmpwi r11,2
bne end #branches to end if it's not stamina mode
stb r0,0xFFFFF365(12) #turns frame control off
end:blr #original instruction at hooked address

04693AA4 60000000 #???????
 
Last edited:

wiiztec

Smash Journeyman
Joined
Dec 19, 2007
Messages
402
Location
Houston, TX
NNID
wiiztec
------------------------------------------------------------------------
special modes rules menu change cosmetics full code breakdown
------------------------------------------------------------------------

4A000000 90000000 #sets pointer address to 90000000

special modes rules menu change cosmetics text part
r5=length of string including ÿ
r30=length of string including filler (from ÿ to Ä)
r4 offset measured from first letter of replaced description to just before first letter of replacee description
------------------------------------------------------------ 100%
hook: 80004350
lis r12,0x9017
ori r12,r12,0xF377 #loads address of byte before stamina mode flag into r12
cmpwi r27,1
bne end #this hook runs every time the game displays text
cmpwi r0,0xFF
bne end #these first 3 register checks and conditional branches
cmpwi r11,0x18
bne end #narrow it down to the rules menu and a few other things
cmplwi r28,6
bgt fcc #branches to frame control check when selection is moved within the top 3 options on the rules menu
cmplwi r28,2
blt end #branches to end if selection is not moved within the bottom 4 options on the rules menu
lbz r10,1(r12) #loads stamina mode flag into r10
cmpwi r10,2
bne fcc #branches to frame control check if it's not stamina mode
cmpwi r5,0x25
beq skwb #branches to set knockback with blastzones if r5 has the string length of the choose discription
cmpwi r5,0x18
beq sknb #branches to set knockback no blastzones if r5 has the string length of the random discription
cmpwi r5,0x30
beq nknb #branches to no knockback no blastzones if r5 has the string length of the turns discription
cmpwi r5,0x1C
beq nkwb #branches to no knockback with blastzones if r5 has the string length of the ordered discription
cmpwi r5,0x32
bne fcc #branches to frame control check if r5 doesn't have the string length of the loser's pick discription
addi r4,r4,0x109F #adds offset from loser's pick to DBZ lite (Type 5) to text pointer in r4
li r30,0x35
li r5,0x33 #sets string sizes (with & w/o filler) for DBZ lite option description
b end #unconditional branch to end
skwb:addi r4,r4,0x10A0 #adds offset from choose to normal (Type 1) to text pointer in r4
li r30,0x26
li r5,0x1F #sets string sizes (with & w/o filler) for normal option description
b end #unconditional branch to end
sknb:addi r4,r4,0x109A #adds offset from random to mahvel (Type 2) to text pointer in r4
li r30,0x29
li r5,0x22 #sets string sizes (with & w/o filler) for mahvel option description
b end #unconditional branch to end
nknb:addi r4,r4,0x10A4 #adds offset from turns to DBZ (Type 3) to text pointer in r4
li r30,0x2C
li r5,0x25 #sets string sizes (with & w/o filler) for DBZ option description
b end #unconditional branch to end
nkwb:addi r4,r4,0x1099 #adds offset from ordered to Smash with HP (Type 4) to text pointer in r4
li r30,0x29
li r5,0x22 #sets string sizes (with & w/o filler) for Smash with HP option description
fcc:lbz r10,3(r12) #loads regen mode flag into r10
cmpwi r10,2
bne end #branches to end if it's not regen mode
cmpwi r28,4
beq end #branches to end if the selection is in the bottom half of the rules menu
cmpwi r5,0x2C
beq fcn #branches to frame control no if r5 has the string length of the stock control off discription
cmpwi r5,0x2F
bne end #branches to end if r5 doesn't have the string length of the stock control on discription
fcy:addi r4,r4,0x1271 #adds offset from stock control on to frame control on to text pointer in r4
li r30,0x4C
li r5,0x45 #sets string sizes (with & w/o filler) for frame control on option description
b end #unconditional branch to end
fcn:addi r4,r4,0x126F #adds offset from stock control off to frame control off to text pointer in r4
li r30,0x35
li r5,0x2E #sets string sizes (with & w/o filler) for frame control off option description
end:lbzu r0,1(r4) #original instruction at hooked address

offset measured with HXD from C in Choose to before S in Set
current offset between first stage choice option and first stamina option: 0x1095

SMRMCC:frame control has no 3rd option
---------------------------------------------- 100%
hook:806A792C
cmplwi r4,2 #original instruction at hooked address
lis r12,0x9017
ori r12,r12,0xF37A #loads address of regen mode flag into r12
lbz r12,0(r12) #loads regen mode flag into r12
cmpwi cr1,r12,2
bne cr1,end #branches to end if it's not regen mode
cmplwi r4,1 #checks if option is 1 (0 is off 1 is on) (if 1 the branch at 806A7930 will disallow moving on to the third option)
end: #the codehandler puts a branch back to the line after the instruction I hooked here

SMRMCC:no right arrow when frame control is on
------------------------------------------------------- 97%
hook:80206130
cmpwi cr2,r3,0xFF
bne cr2,end #branches to end if r3 is not 0xFF
cmpwi cr2,r5,0x224
bne cr2,end #branches to end if r5 is not 0x224
cmpwi cr2,r11,0x35
bne cr2,end #branches to end if r11 is not 0x35 (ID of frame control on's right arrow??)
lis r12,0x9017
ori r12,r12,0xF37A #loads address of regen mode flag into r12
lbz r12,0(r12) #loads regen mode flag into r12
cmpwi cr2,r12,2
bne cr2,end #branches to end if regen mode is not on
li r3,0xF0 #sets value for right arrow to not appear
end:stb r3,0(r4) #original instruction at hooked address

3817F378 00FF0200 #checks if stamina mode is on
21775670 30330000 #checks if 81775670 contains the 2nd 03 of MenMainRule03Sel03
01775671 00000034 #changes it to 04
0177529F 00000039 #changes the 06 of MenMainRule00font06 to 09
E2000002 00000000 #ends the 2 previous ifs
3817F37A 00FF0200 #checks if regen mode is on
21775264 742E3034 #checks if 81775264 contains the 04 of MenMainRule00font04
03775266 00003130 #changes it to 10
4A000000 93000000 #sets pointer address to 93000000
30351CC4 6170345F #checks if 93351CC4 contains the ap4_ in MenSelchrChandicap4_TopN__0
10351CC5 00000074 #changes the p to a t
E0000000 80008000 #full terminator, ends all ifs and sets base and pointer addresses back to 80000000
42000000 90000000 #sets base address to 90000000
4A000000 93000000 #sets pointer address to 93000000
2817F37A 00FF0200 #checks if regen mode is on
30328108 64696361 #checks if 93328108 contains the dica of MenSelchrCardHandicap
1032810C 00000074 #changes the p in MenSelchrCardHandicap to a t
E0000000 80008000 #full terminator, ends all ifs and sets base and pointer addresses back to 80000000

selectively replaced files
----------------------------
MenMainRule03Sel03
MenMainRule00font.06
MenMainRule00font.04
MenSelchrCardHandicap
MenSelchrChandicap4_TopN__0

I'll probably post more including some codes on the PMDT requested codes list that didn't make it in for some reason, I actually forgot I made them until I looked at my codes list on my Gecko.NET recently
 
Last edited:

wiiztec

Smash Journeyman
Joined
Dec 19, 2007
Messages
402
Location
Houston, TX
NNID
wiiztec
This code is run through 5 times for each player before the beginning of a match and 5 times each death in ASV

---------------------------------------
ds22 stock heads modified for ASV
---------------------------------------
hook:800E2168
lwz r12,0xE8(r1) # Load Character ID

#--ASV part 1--------------------------------------------------------------------------------------------------------------------------------
lis r11,0x9018
lbz r11,0xFFFFF37F(r11) #loads ASV mode flag into r11
cmpwi r11,2
bne sasv1 #branches to skip ASV 1 if not ASV
li r9,0xA5 #sets ASV on flag
lis r10,0x8058
ori r10,r10,0x8000 #loads ASV data bank address into r10
lbz r11,0x02(r31) #loads player number ID into r11
mulli r11,r11,0xA0 #multiplies player ASV data offset by PND and stores result in r11
add r10,r10,r11 #adds offset to current player ASV data to the ASV data bank address and stores result in r10
lbz r11,0x9E(r10) #loads current player offset to next stockhead ID
lwz r5,0x20(r31) #loads current player current stock count
cmpwi r5,6
bgt fsof #branches to for stocks over five if stock count is >6 (stock count is still 6 at this point if you just lost your 6th stock)
cmpwi r5,0
bne loop #branches to loop if stock count is not 0 (stock count is 0 before the beginning of a match)
lis r5,0x8128
ori r5,r5,0xAE64 #loads P1 stock count address into r5 (this address is updated before the other one)
lwz r5,0(r5) #loads stock count into r5 (the stock count address r31 points to doesn't update before the match starts)
cmpwi r5,6
ble loop #branches to loop if stock count is 6 or less (should be 5)
fsof:lbzx r12,r10,r11 #loads character ID from current player ASV data + offset to next ASV stock head
cmpwi r12,0xCC
bne ncp #branches to next character picked if character ID is not indicator of end of picked characters
li r11,3 #sets offset to next stock head to 3
b loop #unconditional branch to loop
ncp:addi r11,r11,3 #adds 3 to offset to next ASV stock head to load next char ID instead of current char ID if stocks >5
loop:lbzx r12,r10,r11 #loads character ID from current player ASV data + offset to next ASV stock head
cmpwi r12,0xCC
bne sasv1 #branches to skip ASV 1 if char ID is not indicator of end of picked characters
cmpwi r11,0
beq sasv1 #branches to skip ASV 1 if offset to next stock head is 0 (to avoid infinite loop if you unpick all chars with CSP clicks)
li r11,0 #sets offset to next ASV stock head to 0 to loop back to first char ID if characters < stocks
b loop #unconditional branch back to loop
#------------------------------------------------------------------------------------------------------------------------------------------------

sasv1:lis r29,0x8045
li r6,61
addi r29,r29,22232 # Load Cosmetic Slots base address
li r7,0
mtctr r6 # Set Count Register (CTR) to total amount of Cosmetic Slots

CHARACTER_ID_LOADER:
lbz r6,0x02(r29) # Load Character ID
cmpw r12,r6
beq- COSMETIC_ID_LOADER # Branch if equal
lbz r6,0x03(r29) # Load Second Character ID
cmpw r12,r6
beq- COSMETIC_ID_LOADER # Branch if equal
addi r29,r29,16
addi r7,r7,1 #
bdnz+ CHARACTER_ID_LOADER # Loop if CTR is not zero

COSMETIC_ID_LOADER:
cmpwi r7,61
bne- 0x0C # Skip if valid index
lis r29,0x8045
addi r29,r29,22232 # Load Cosmetic Slots base address
lbz r12,0(r29) # Load Cosmetic ID

WARIOMAN_COSMETIC_CHECK:
cmpwi r12,0x42
bne+ PORTRAIT_ID_LOADER # Branch if not WarioMan's Cosmetic ID
li r12,0x25 # Load Wario's Cosmetic ID

PORTRAIT_ID_LOADER:
lbz r6,0xED(r1) # Load Portrait ID

#--ASV Part 2------------------------------------------------------------------------------------------------------------------------------
cmpwi r9,0xA5
bne sasv2 #branches to skip ASV 2 if ASV flag not set
lwzx r6,r10,r11 #loads char, costume, portrait, & next char ID's from current player ASV data + offset to next stock head
slwi r6,r6,16 #shifts char & costume ID off the left of r6
srwi r6,r6,24 #shifts next char ID off the right of r6
addi r11,r11,3 #increment offset to next ASV stock head by 3
stb r11,0x9E(r10) #store new offset to current player ASV data address + 0x9E
cmpwi r27,4 #if last stockhead
bne sasv2 #skips to skip ASV 2 if it's not the last stock head
lbz r9,0x9C(r10) #loads current player offset to next ASV stock character ID
addi r9,r9,3 #adds 3 to offset because ASV assumes beginning of ASV data as 80588003 while this assumes 80588000
stb r9,0x9E(r10) #stores offset to next ASV stock char ID +3 as offset to next ASV stock head
#---------------------------------------------------------------------------------------------------------------------------------------------

sasv2:mulli r12,r12,10
add r12,r12,r6
addi r7,r12,1 # Multiply Cosmetic ID by 10, add Portrait ID, add 1 [A*10+B+1=C]

FIRST_STOCK:
cmpwi r27,0
bne- 0x0C # Branch if not first stock
mr r8,r4 # Move Colour
mr r28,r31 # (Original instruction located at 0x800E215C)

INFO.PAC_CHECK:
lis r12,0x80C2
lhz r12,0x4314(r12) # Load Info.pac header
li r29,0x5F65
cmpw r12,r29
beq- MELEE_STOCK_COLOUR # Branch if Info_en.pac

BRAWL_STOCK_COLOUR:
xoris r30,r8,0x8000 # Set PlayerTeam Colour ID as Frame ID
b 0x08 # Skip to exit

MELEE_STOCK_COLOUR:
xoris r30,r7,0x8000 # Set Stock Colour ID as Frame ID

EXIT:
lwz r29, 0x008C (r28)

I remember being up all night when I did this so that was probably a contributing factor in my oversight in only loading player 1's stock count before the beginning of a match which is of course not adequate for all scenarios (stock control with 1 player <=5 stocks and another >=6 stocks, changing stock count from <=5 to >=6 or vice versa before a match not including player 1) also I'm pretty sure I could have saved a line by rearranging the code to exclude that unconditional branch
 
Last edited:

wiiztec

Smash Journeyman
Joined
Dec 19, 2007
Messages
402
Location
Houston, TX
NNID
wiiztec
need to hold b for b reversal asm
-------------------------------------
hook:807ACA0C
lwz r3,28(r3) #original instruction at hooked address
cmpwi r5,0x37
bne end #branches to end if current player is not pressing any buttons
lis r12,0x1200
cmpw r25,r12
bne end #branches to end if current player is not performing a special
lis r12,0x805B
ori r12,r12,0xC068 #loads controller independant button read addresses address into r12
p1:lhz r11,0x00(r12) #loads player 1's button values into r11
rlwinm. r11,r11,0,30,30
bne p2 #branches to player 2 if B isn't not being pressed
srwi r11,r28,16 #copies player/character main index from r28 to r11 and shifts the last 2 bytes off the right
cmplwi r11,0x8124
blt end #branches to end if main index is lower than the low end of the range of player 1 main indexes
cmplwi r11,0x8128
ble do #branches to do if main index is less or equal to the high end of the range of player 1 main indexes
p2:lhz r11,0x04(r12) #loads player 2's button values into r11
rlwinm. r11,r11,0,30,30
bne p3 #branches to player 3 if B isn't not being pressed
srwi r11,r28,16 #copies player/character main index from r28 to r11 and shifts the last 2 bytes off the right
cmplwi r11,0x8129
blt end #branches to end if main index is lower than the low end of the range of player 2 main indexes
cmplwi r11,0x812D
ble do #branches to do if main index is less or equal to the high end of the range of player 2 main indexes
p3:lhz r11,0x08(r12) #loads player 3's button values into r11
rlwinm. r11,r11,0,30,30
bne p4 #branches to player 4 if B isn't not being pressed
srwi r11,r28,16 #copies player/character main index from r28 to r11 and shifts the last 2 bytes off the right
cmplwi r11,0x812E
blt end #branches to end if main index is lower than the low end of the range of player 3 main indexes
cmplwi r11,0x8132
ble do #branches to do if main index is less or equal to the high end of the range of player 3 main indexes
p4:lhz r11,0x0C(r12) #loads player 4's button values into r11
rlwinm. r11,r11,0,30,30
bne end #branches to end if B isn't not being pressed
srwi r11,r28,16 #copies player/character main index from r28 to r11 and shifts the last 2 bytes off the right
cmplwi r11,0x8133
blt end #branches to end if main index is lower than the low end of the range of player 4 main indexes
cmplwi r11,0x8137
bgt end #branches to end if main index is greater than the high end of the range of player 4 main indexes
do:li r4,0 #sets r4 to 0 which disables b reverses
end: #the codehandler puts a branch back to the line after the instruction I hooked here

This was never actually put into PM, I don't know why as It was on their list of requested codes. The thing with comparing the ranges of the main index per player is what I used to do to differentiate players before I learned about player number ID from Magus's main index pointer tree notes
 

wiiztec

Smash Journeyman
Joined
Dec 19, 2007
Messages
402
Location
Houston, TX
NNID
wiiztec
Tether ledge hop option
-------------------------
hook:8077F780
cmpwi r3,0
beq end #branches to end if no button input
cmpwi r28,0x075
bne end #branches to end if action is not ledge hang
lwz r12,-4(r30) #loads previous action into r12
cmpwi r12,0x081
bne end #branches to end if previous action is not tether grabbing stage
lwz r11,-0x16C(r4) #loads current button inputs into r11
rlwinm r11,r11,0,28,28 #masks out everything but shield input if present
cmpwi r11,8
bne end #branches to end if shield input not present
li r28,0x00E #loads action ID for regular fall into r28
stw r28,0x34(r30) #stores r28 to secondary current action address (this make it so you can't act out of it)
li r28,0x7A #loads action ID for ledge jump end into r28
end:stw r28,0x38(r30) #original instruction at hooked address, stores r28 to primary current action address

This code allows the option of doing an uninterruptible ledge hop directly out of tether reel in if you are holding shield or if the grab button is pressed (because grab is just a macro of shield and attack inputs) the hook is used by another PM code, I'm not sure if it was at the time but in any case that's probably not why it was ultimately excluded because I could have changed the hook. Perhaps a PSA solution was preferred IDK
 

wiiztec

Smash Journeyman
Joined
Dec 19, 2007
Messages
402
Location
Houston, TX
NNID
wiiztec
no item stale
-------------
hook:808E0160
cmplwi r4,0x4B
ble end #branch to end if not item hit
lis r3,0x80FC
ori r3,r3,0x0984 #loads address containing 3F800000 (1 in float) into r3
end:lfs f0,4(r3) #original instruction at hooked address

Another requested code that never actually made it in PM
 
Top Bottom