Shared Item Cheat Detection [Star]
#1
Shared Item Cheat Detection [Star]

This code will detect when a player tries to obtain a Shared Item, but the item they intend to cheat already has it's maximum amount in play. The code will also detect when a player obtains impossible item combinations. It will display the slot of the offending player in the milliseconds of the timer, accompanied by a value denoting the reason.

(NTSC-U)
C26593FC 00000005
907C0008 9421FFF0
BFC10008 3FE08053
3FC080A1 63DE0024
93DF10A0 BBC10008
38210010 00000000
C265EE14 0000000B
88030001 9421FFF0
BFC10008 8BE30003
56CC103A 3D8C8168
2C1F0000 41A20010
2C1F0001 41820014
4800001C 3BC00014
9BCC0193 48000014
3BC00057 9BCC0193
48000008 980C0193
BBC10008 38210010
60000000 00000000
C265EE30 00000059
88100011 9421FFB0
BDC10008 8BF00013
56CC103A 3D8C8168
2C1F0000 41A20010
2C1F0001 41820014
48000258 3BC00014
9BCC0193 48000284
3BC00057 9BCC0193
3FA08053 3F8038A0
8B700012 2C1B0010
41820018 2C1B0011
41820010 2C1B0012
41820008 4800001C
2C000010 41820224
2C000011 4182021C
2C000012 41820214
3B40000C 7F4903A6
3F208168 63390193
3F008168 63180133
8AF90000 2C170006
40A20014 8AD80000
3AD60001 9AD80000
480000D8 2C170007
40A20014 8AD80004
3AD60001 9AD80004
480000C0 2C170008
40A20014 8AD80008
3AD60001 9AD80008
480000A8 2C170009
40A20014 8AD8000C
3AD60001 9AD8000C
48000090 2C17000A
40A20014 8AD80010
3AD60001 9AD80010
48000078 2C17000B
40A20014 8AD80014
3AD60001 9AD80014
48000060 2C17000C
40A20014 8AD80018
3AD60001 9AD80018
48000048 2C17000D
40A20014 8AD8001C
3AD60001 9AD8001C
48000030 2C17000E
40A20014 8AD80020
3AD60001 9AD80020
48000018 2C17000F
40A20010 8AD80024
3AD60001 9AD80024
3B390004 4200FF0C
2C000006 40A20014
8AD80000 2C160003
408000E8 480000FC
2C000007 40A20014
8AD80004 2C160001
408000D0 480000E4
2C000008 40A20014
8AD80008 2C160001
408000B8 480000CC
2C000009 40A20014
8AD8000C 2C160003
408000A0 480000B4
2C00000A 40A20014
8AD80010 2C160002
40800088 4800009C
2C00000B 40A20014
8AD80014 2C160002
40800070 48000084
2C00000C 40A20014
8AD80018 2C160001
40800058 4800006C
2C00000D 40A20014
8AD8001C 2C160001
40800040 48000054
2C00000E 40A20014
8AD80020 2C160001
40800028 4800003C
2C00000F 40A20010
8AD80024 2C160001
40800010 48000024
980C0193 48000034
639C0064 48000008
639C012C 7F9CB214
3B9C0001 939D10A0
3AA00000 3B40000A
7F4903A6 9AB80000
3B180004 4200FFF8
B9C10008 38210050
60000000 00000000

(PAL)
C2661338 00000005
907C0008 9421FFF0
BFC10008 3FE08053
3FC080A1 63DE0024
93DF5BE8 BBC10008
38210010 00000000
C265E18C 0000000B
88030001 9421FFF0
BFC10008 8BE30003
56CC103A 3D8C8168
2C1F0000 41A20010
2C1F0001 41820014
4800001C 3BC00014
9BCC0193 48000014
3BC00057 9BCC0193
48000008 980C0193
BBC10008 38210010
60000000 00000000
C265E1A8 00000059
88100011 9421FFB0
BDC10008 8BF00013
56CC103A 3D8C8168
2C1F0000 41A20010
2C1F0001 41820014
48000258 3BC00014
9BCC0193 48000284
3BC00057 9BCC0193
3FA08053 3F8038A0
8B700012 2C1B0010
41820018 2C1B0011
41820010 2C1B0012
41820008 4800001C
2C000010 41820224
2C000011 4182021C
2C000012 41820214
3B40000C 7F4903A6
3F208168 63390193
3F008168 63180133
8AF90000 2C170006
40A20014 8AD80000
3AD60001 9AD80000
480000D8 2C170007
40A20014 8AD80004
3AD60001 9AD80004
480000C0 2C170008
40A20014 8AD80008
3AD60001 9AD80008
480000A8 2C170009
40A20014 8AD8000C
3AD60001 9AD8000C
48000090 2C17000A
40A20014 8AD80010
3AD60001 9AD80010
48000078 2C17000B
40A20014 8AD80014
3AD60001 9AD80014
48000060 2C17000C
40A20014 8AD80018
3AD60001 9AD80018
48000048 2C17000D
40A20014 8AD8001C
3AD60001 9AD8001C
48000030 2C17000E
40A20014 8AD80020
3AD60001 9AD80020
48000018 2C17000F
40A20010 8AD80024
3AD60001 9AD80024
3B390004 4200FF0C
2C000006 40A20014
8AD80000 2C160003
408000E8 480000FC
2C000007 40A20014
8AD80004 2C160001
408000D0 480000E4
2C000008 40A20014
8AD80008 2C160001
408000B8 480000CC
2C000009 40A20014
8AD8000C 2C160003
408000A0 480000B4
2C00000A 40A20014
8AD80010 2C160002
40800088 4800009C
2C00000B 40A20014
8AD80014 2C160002
40800070 48000084
2C00000C 40A20014
8AD80018 2C160001
40800058 4800006C
2C00000D 40A20014
8AD8001C 2C160001
40800040 48000054
2C00000E 40A20014
8AD80020 2C160001
40800028 4800003C
2C00000F 40A20010
8AD80024 2C160001
40800010 48000024
980C0193 48000034
639C0064 48000008
639C012C 7F9CB214
3B9C0001 939D5BE8
3AA00000 3B40000A
7F4903A6 9AB80000
3B180004 4200FFF8
B9C10008 38210050
60000000 00000000

(NTSC-J)
C26609A4 00000005
907C0008 9421FFF0
BFC10008 3FE08053
3FC080A1 63DE0024
93DF5568 BBC10008
38210010 00000000
C265D7F8 0000000B
88030001 9421FFF0
BFC10008 8BE30003
56CC103A 3D8C8168
2C1F0000 41A20010
2C1F0001 41820014
4800001C 3BC00014
9BCC0193 48000014
3BC00057 9BCC0193
48000008 980C0193
BBC10008 38210010
60000000 00000000
C265D814 00000059
88100011 9421FFB0
BDC10008 8BF00013
56CC103A 3D8C8168
2C1F0000 41A20010
2C1F0001 41820014
48000258 3BC00014
9BCC0193 48000284
3BC00057 9BCC0193
3FA08053 3F8038A0
8B700012 2C1B0010
41820018 2C1B0011
41820010 2C1B0012
41820008 4800001C
2C000010 41820224
2C000011 4182021C
2C000012 41820214
3B40000C 7F4903A6
3F208168 63390193
3F008168 63180133
8AF90000 2C170006
40A20014 8AD80000
3AD60001 9AD80000
480000D8 2C170007
40A20014 8AD80004
3AD60001 9AD80004
480000C0 2C170008
40A20014 8AD80008
3AD60001 9AD80008
480000A8 2C170009
40A20014 8AD8000C
3AD60001 9AD8000C
48000090 2C17000A
40A20014 8AD80010
3AD60001 9AD80010
48000078 2C17000B
40A20014 8AD80014
3AD60001 9AD80014
48000060 2C17000C
40A20014 8AD80018
3AD60001 9AD80018
48000048 2C17000D
40A20014 8AD8001C
3AD60001 9AD8001C
48000030 2C17000E
40A20014 8AD80020
3AD60001 9AD80020
48000018 2C17000F
40A20010 8AD80024
3AD60001 9AD80024
3B390004 4200FF0C
2C000006 40A20014
8AD80000 2C160003
408000E8 480000FC
2C000007 40A20014
8AD80004 2C160001
408000D0 480000E4
2C000008 40A20014
8AD80008 2C160001
408000B8 480000CC
2C000009 40A20014
8AD8000C 2C160003
408000A0 480000B4
2C00000A 40A20014
8AD80010 2C160002
40800088 4800009C
2C00000B 40A20014
8AD80014 2C160002
40800070 48000084
2C00000C 40A20014
8AD80018 2C160001
40800058 4800006C
2C00000D 40A20014
8AD8001C 2C160001
40800040 48000054
2C00000E 40A20014
8AD80020 2C160001
40800028 4800003C
2C00000F 40A20010
8AD80024 2C160001
40800010 48000024
980C0193 48000034
639C0064 48000008
639C012C 7F9CB214
3B9C0001 939D5568
3AA00000 3B40000A
7F4903A6 9AB80000
3B180004 4200FFF8
B9C10008 38210050
60000000 00000000

(NTSC-K)
C264F650 00000005
907C0008 9421FFF0
BFC10008 3FE08052
3FC080A1 63DE0024
93DF3C40 BBC10008
38210010 00000000
C264C4A4 0000000B
88030001 9421FFF0
BFC10008 8BE30003
56CC103A 3D8C8168
2C1F0000 41A20010
2C1F0001 41820014
4800001C 3BC00014
9BCC0193 48000014
3BC00057 9BCC0193
48000008 980C0193
BBC10008 38210010
60000000 00000000
C264C4C0 00000059
88100011 9421FFB0
BDC10008 8BF00013
56CC103A 3D8C8168
2C1F0000 41A20010
2C1F0001 41820014
48000258 3BC00014
9BCC0193 48000284
3BC00057 9BCC0193
3FA08052 3F8038A0
8B700012 2C1B0010
41820018 2C1B0011
41820010 2C1B0012
41820008 4800001C
2C000010 41820224
2C000011 4182021C
2C000012 41820214
3B40000C 7F4903A6
3F208168 63390193
3F008168 63180133
8AF90000 2C170006
40A20014 8AD80000
3AD60001 9AD80000
480000D8 2C170007
40A20014 8AD80004
3AD60001 9AD80004
480000C0 2C170008
40A20014 8AD80008
3AD60001 9AD80008
480000A8 2C170009
40A20014 8AD8000C
3AD60001 9AD8000C
48000090 2C17000A
40A20014 8AD80010
3AD60001 9AD80010
48000078 2C17000B
40A20014 8AD80014
3AD60001 9AD80014
48000060 2C17000C
40A20014 8AD80018
3AD60001 9AD80018
48000048 2C17000D
40A20014 8AD8001C
3AD60001 9AD8001C
48000030 2C17000E
40A20014 8AD80020
3AD60001 9AD80020
48000018 2C17000F
40A20010 8AD80024
3AD60001 9AD80024
3B390004 4200FF0C
2C000006 40A20014
8AD80000 2C160003
408000E8 480000FC
2C000007 40A20014
8AD80004 2C160001
408000D0 480000E4
2C000008 40A20014
8AD80008 2C160001
408000B8 480000CC
2C000009 40A20014
8AD8000C 2C160003
408000A0 480000B4
2C00000A 40A20014
8AD80010 2C160002
40800088 4800009C
2C00000B 40A20014
8AD80014 2C160002
40800070 48000084
2C00000C 40A20014
8AD80018 2C160001
40800058 4800006C
2C00000D 40A20014
8AD8001C 2C160001
40800040 48000054
2C00000E 40A20014
8AD80020 2C160001
40800028 4800003C
2C00000F 40A20010
8AD80024 2C160001
40800010 48000024
980C0193 48000034
639C0064 48000008
639C012C 7F9CB214
3B9C0001 939D3C40
3AA00000 3B40000A
7F4903A6 9AB80000
3B180004 4200FFF8
B9C10008 38210050
60000000 00000000

Code:
#============================================================#
#                          Source                            #
#============================================================#

#============================================================#
#                    Local SELECT Record                     #
#============================================================#
# Original Address Ports:                                    #
# RMCE - 0x806593FC                                          #
# RMCP - 0x80661338                                          #
# RMCJ - 0x806609A4                                          #
# RMCK - 0x8064F650                                          #
#============================================================#

.set region, ''

.if     (region == 'E' || region == 'e') # RMCE
        .set millisecondsDisplayAddress, 0x805310A0
.elseif (region == 'P' || region == 'p') # RMCP
        .set millisecondsDisplayAddress, 0x80535BE8
.elseif (region == 'J' || region == 'j') # RMCJ
        .set millisecondsDisplayAddress, 0x80535568
.elseif (region == 'K' || region == 'k') # RMCK
        .set millisecondsDisplayAddress, 0x80523C40
.else # Invalid Region
        .abort
.endif

# Original instruction
stw r3, 8(r28)

# Function Prologue...
stwu r1, -16(r1)
stmw r30, 8(r1)

lis r31, millisecondsDisplayAddress@ha

# Default Millisecond Display Opcode
lis r30, 0x80A1
ori r30, r30, 0x0024

stw r30, millisecondsDisplayAddress@l(r31)

# Function Epilogue...
lmw r30, 8(r1)
addi r1, r1, 16

#============================================================#
#                Local Player's ITEM Record                  #
#============================================================#
# Original Address Ports:                                    #
# RMCE - 0x8065EE14                                          #
# RMCP - 0x8065E18C                                          #
# RMCJ - 0x8065D7F8                                          #
# RMCK - 0x8064C4A4                                          #
#============================================================#

# Original instruction
lbz r0, 1(r3) # Load the Local Player's Held Item into r0

# Function Prologue...
stwu r1, -16(r1)
stmw r30, 8(r1)

lbz r31, 3(r3) # Load the Local Player's Activation Mode into r31

# Calculate a unique address using the Local Player's Slot
slwi r12, r22, 2
subis r12, r12, 32408

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# Find the Activation Mode of the Local Player.              #
#============================================================#

cmpwi r31, 0
beq+ branch_handshake_stage_0
cmpwi r31, 1
beq- branch_handshake_stage_1
b branch_handshake_stage_2_or_greater

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# Store the Local Player's Held Item to Item Spy.            #
#                                                            #
# To prevent false positives from occuring (Caused by the    #
# Item Value switching before the Activation Mode), store    #
# the No Item value to the Item Spy.                         #
#                                                            #
# Activation Mode:                                           #
# 0 - No Item                                                #
#============================================================#

branch_handshake_stage_0:

li r30, 0x14
stb r30, 0x193(r12)

b branch_finished

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# This code will not detect if the Local Player is using the #
# Shared Item code.                                          #
#                                                            #
# To prevent false positives from occuring (Caused by the    #
# Item Value switching before the Activation Mode), store    #
# garbage to the Item Spy.                                   #
#                                                            #
# Handshake Value:                                           #
# 1 - Item Local Player wants                                #
#============================================================#

branch_handshake_stage_1:

li r30, 0x57
stb r30, 0x193(r12)

b branch_finished

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# Store the Local Player's Held Item to Item Spy.            #
#                                                            #
# Activation Modes >= 2 mean the Item the Local Player will  #
# receive is confirmed.                                      #
#                                                            #
# Activation Mode:                                           #
# 2 - Item Local Player will receive                         #
# 3 - ?                                                      #
# 4 - Ready to fire Triple Items                             #
# 5 - ?                                                      #
# 6 - Ready to fire Item                                     #
# 7 - No Item Available                                      #
#============================================================#

branch_handshake_stage_2_or_greater:

stb r0, 0x193(r12) # Store the Local Player's Held Item to the Item Spy

branch_finished:

# Function Epilogue...
lmw r30, 8(r1)
addi r1, r1, 16

#============================================================#
#                   Players ITEM Record                      #
#============================================================#
# Original Address Ports:                                    #
# RMCE - 0x8065EE30                                          #
# RMCP - 0x8065E1A8                                          #
# RMCJ - 0x8065D814                                          #
# RMCK - 0x8064C4C0                                          #
#============================================================#

.set region, ''

.if     (region == 'E' || region == 'e') # RMCE
        .set millisecondsDisplayAddress, 0x805310A0
.elseif (region == 'P' || region == 'p') # RMCP
        .set millisecondsDisplayAddress, 0x80535BE8
.elseif (region == 'J' || region == 'j') # RMCJ
        .set millisecondsDisplayAddress, 0x80535568
.elseif (region == 'K' || region == 'k') # RMCK
        .set millisecondsDisplayAddress, 0x80523C40
.else # Invalid Region
        .abort
.endif

# Original instruction
lbz r0, 17(r16) # Load the Player's Held Item into r0

# Function Prologue...
stwu r1, -80(r1)
stmw r14, 8(r1)

lbz r31, 19(r16) # Load the Player's Activation Mode into r31

# Calculate a unique address using the Player's Slot
slwi r12, r22, 2
subis r12, r12, 32408

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# Find the Activation Mode of the Player.                    #
#============================================================#

cmpwi r31, 0
beq+ branch_handshake_stage_0
cmpwi r31, 1
beq- branch_handshake_stage_1
b branch_handshake_stage_2_or_greater

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# Store the Player's Held Item to Item Spy.                  #
#                                                            #
# To prevent false positives from occuring (Caused by the    #
# Item Value switching before the Activation Mode), store    #
# the No Item value to the Item Spy.                         #
#                                                            #
# Activation Mode:                                           #
# 0 - No Item                                                #
#============================================================#

branch_handshake_stage_0:

li r30, 0x14
stb r30, 0x193(r12)

b branch_finished

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# Detect Players trying to obtain impossible Shared Items    #
# using a variety of methods.                                #
#                                                            #
# To prevent false positives from occuring (Caused by the    #
# Item Value switching before the Activation Mode), store    #
# garbage to the Item Spy.                                   #
#                                                            #
# Handshake Value:                                           #
# 1 - Item Player wants                                      #
#============================================================#

branch_handshake_stage_1:

li r30, 0x57
stb r30, 0x193(r12)

lis r29, millisecondsDisplayAddress@ha
lis r28, 0x38A0 # Milliseconds Display Value
lbz r27, 18(r16) # Load the Player's Trailed Item into r27

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# Check the if the current Player has impossible             #
# Items trailing them, according to their current Item.      #
#                                                            #
# It is impossible for a Player to obtain another set of     #
# Triple Items if they are currently trailing a set.         #
#============================================================#

cmpwi r27, 0x10 # Compare the Player's Trailed Item to 0x10 (Triple Green Shells)
beq- branch_impossible_trailed_items_check
cmpwi r27, 0x11 # Compare the Player's Trailed Item to 0x11 (Triple Red Shells)
beq- branch_impossible_trailed_items_check
cmpwi r27, 0x12 # Compare the Player's Trailed Item to 0x12 (Triple Bananas)
beq- branch_impossible_trailed_items_check

b branch_skip_impossible_trailed_items_check

branch_impossible_trailed_items_check:

cmpwi r0, 0x10 # Compare the Player's Held Item to 0x10 (Triple Green Shells)
beq- branch_impossible_triple_item_combination_detected
cmpwi r0, 0x11 # Compare the Player's Held Item to 0x11 (Triple Red Shells)
beq- branch_impossible_triple_item_combination_detected
cmpwi r0, 0x12 # Compare the Player's Held Item) to 0x12 (Triple Bananas)
beq- branch_impossible_triple_item_combination_detected

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# Store the amount of each Item currently in play,           #
# not including the Player's pending Item.                   #
#============================================================#

branch_skip_impossible_trailed_items_check:

li r26, 12
mtctr r26

# Address to all Player's Items
lis r25, 0x8168
ori r25, r25, 0x0193

# Address to the Number of Items in Play
lis r24, 0x8168
ori r24, r24, 0x0133

branch_item_amount_loop:

lbz r23, 0(r25) # Load the nth Player's Item into r23

cmpwi r23, 0x6 # Compare the Player's Item to 0x6 (Bob-omb)
bne+ branch_item_not_bob_omb
lbz r22, 0(r24) # Load the Number of Bob-ombs in play into r22
addi r22, r22, 1 # Add 1 to the number of Bob-ombs in play
stb r22, 0(r24) # Store the updated Number of Bob-ombs in play
b branch_item_found # Branch to check the next player since we found the item this player is holding

branch_item_not_bob_omb:

cmpwi r23, 0x7
bne+ branch_item_not_blue_shell
lbz r22, 4(r24)
addi r22, r22, 1
stb r22, 4(r24)
b branch_item_found

branch_item_not_blue_shell:

cmpwi r23, 0x8
bne+ branch_item_not_lightning
lbz r22, 8(r24)
addi r22, r22, 1
stb r22, 8(r24)
b branch_item_found

branch_item_not_lightning:

cmpwi r23, 0x9
bne+ branch_item_not_star
lbz r22, 12(r24)
addi r22, r22, 1
stb r22, 12(r24)
b branch_item_found

branch_item_not_star:

cmpwi r23, 0xA
bne+ branch_item_not_golden_mushroom
lbz r22, 16(r24)
addi r22, r22, 1
stb r22, 16(r24)
b branch_item_found

branch_item_not_golden_mushroom:

cmpwi r23, 0xB
bne+ branch_item_not_mega_mushroom
lbz r22, 20(r24)
addi r22, r22, 1
stb r22, 20(r24)
b branch_item_found

branch_item_not_mega_mushroom:

cmpwi r23, 0xC
bne+ branch_item_not_blooper
lbz r22, 24(r24)
addi r22, r22, 1
stb r22, 24(r24)
b branch_item_found

branch_item_not_blooper:

cmpwi r23, 0xD
bne+ branch_item_not_pow_block
lbz r22, 28(r24)
addi r22, r22, 1
stb r22, 28(r24)
b branch_item_found

branch_item_not_pow_block:

cmpwi r23, 0xE
bne+ branch_item_not_thunder_cloud
lbz r22, 32(r24)
addi r22, r22, 1
stb r22, 32(r24)
b branch_item_found

branch_item_not_thunder_cloud:

cmpwi r23, 0xF
bne+ branch_item_not_bullet_bill
lbz r22, 36(r24)
addi r22, r22, 1
stb r22, 36(r24)

branch_item_not_bullet_bill:

branch_item_found:

addi r25, r25, 4 # Get the next Player's Item
bdnz+ branch_item_amount_loop # Check the next Item

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# Now that we have the amount of each Item in play,          #
# we can compare them to their hardcoded limits.             #
#                                                            #
# If the amount in play is equal (or greater) to the max,    #
# the current Player must be trying to cheat one. This is    #
# because they are trying obtain one when the game would     #
# not normally allow it due to hardcoded limits.             #
#                                                            #
# This is possible because during Activation Mode 1, the     #
# Player will report the Item they would like to receive as  #
# their Held Item.                                           #
#============================================================#

cmpwi r0, 0x6 # Compare the Player's Held Item to 0x6 (Bob-omb)
bne+ branch_not_checking_bob_omb_limit
lbz r22, 0(r24) # Load the Number of Bob-ombs in play into r22
cmpwi r22, 3 # Compare the Number of Bob-ombs in play to 0x3 (Maximum Number of Bob-ombs that can be in play at once)
bge- branch_impossible_shared_item_detected
b branch_impossible_shared_item_not_detected

branch_not_checking_bob_omb_limit:

cmpwi r0, 0x7
bne+ branch_not_checking_blue_shell_limit
lbz r22, 4(r24)
cmpwi r22, 1
bge- branch_impossible_shared_item_detected
b branch_impossible_shared_item_not_detected

branch_not_checking_blue_shell_limit:

cmpwi r0, 0x8
bne+ branch_not_checking_lightning_limit
lbz r22, 8(r24)
cmpwi r22, 1
bge- branch_impossible_shared_item_detected
b branch_impossible_shared_item_not_detected

branch_not_checking_lightning_limit:

cmpwi r0, 0x9
bne+ branch_not_checking_star_limit
lbz r22, 12(r24)
cmpwi r22, 3
bge- branch_impossible_shared_item_detected
b branch_impossible_shared_item_not_detected

branch_not_checking_star_limit:

cmpwi r0, 0xA
bne+ branch_not_checking_golden_mushroom_limit
lbz r22, 16(r24)
cmpwi r22, 2
bge- branch_impossible_shared_item_detected
b branch_impossible_shared_item_not_detected

branch_not_checking_golden_mushroom_limit:

cmpwi r0, 0xB
bne+ branch_not_checking_mega_mushroom_limit
lbz r22, 20(r24)
cmpwi r22, 2
bge- branch_impossible_shared_item_detected
b branch_impossible_shared_item_not_detected

branch_not_checking_mega_mushroom_limit:

cmpwi r0, 0xC
bne+ branch_not_checking_blooper_limit
lbz r22, 24(r24)
cmpwi r22, 1
bge- branch_impossible_shared_item_detected
b branch_impossible_shared_item_not_detected

branch_not_checking_blooper_limit:

cmpwi r0, 0xD
bne+ branch_not_checking_pow_block_limit
lbz r22, 28(r24)
cmpwi r22, 1
bge- branch_impossible_shared_item_detected
b branch_impossible_shared_item_not_detected

branch_not_checking_pow_block_limit:

cmpwi r0, 0xE
bne+ branch_not_checking_thunder_cloud_limit
lbz r22, 32(r24)
cmpwi r22, 1
bge- branch_impossible_shared_item_detected
b branch_impossible_shared_item_not_detected

branch_not_checking_thunder_cloud_limit:

cmpwi r0, 0xF
bne+ branch_not_checking_bullet_bill_limit
lbz r22, 36(r24)
cmpwi r22, 1
bge- branch_impossible_shared_item_detected

branch_not_checking_bullet_bill_limit:

b branch_impossible_shared_item_not_detected

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# Store the Player's Held Item to Item Spy.                  #
#                                                            #
# Activation Modes >= 2 mean the Item the Player will        #
# receive is confirmed.                                      #
#                                                            #
# Activation Mode:                                           #
# 2 - Item Player will receive                               #
# 3 - ?                                                      #
# 4 - Ready to fire Triple Items                             #
# 5 - ?                                                      #
# 6 - Ready to fire Item                                     #
# 7 - No Item Available                                      #
#============================================================#

branch_handshake_stage_2_or_greater:

stb r0, 0x193(r12) # Store the Player's Held Item to the Item Spy

b branch_finished

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# The first digit of the milliseconds will denote the        #
# detection reason. The last two digits will denote the      #
# Player's Slot (01-12).                                     #
#                                                            #
# Possible Detection Reasons:                                #
# 1SS - Impossible Shared Item Detected                      #
# 3SS - Impossible Triple Item Combination Detected          #
#============================================================#

branch_impossible_shared_item_detected:

ori r28, r28, 100

b branch_modify_timer

branch_impossible_triple_item_combination_detected:

ori r28, r28, 300

branch_modify_timer:

add r28, r28, r22 # Add the Player's Slot to the value in Milliseconds Display Value
addi r28, r28, 1 # Have the milliseconds display 1-12 rather than 0-11 for the Player's Slot
stw r28, millisecondsDisplayAddress@l(r29)

#============================================================#
#                         Purpose                            #
#------------------------------------------------------------#
# Clear the amount of Items in play.                         #
#============================================================#

branch_impossible_shared_item_not_detected:

li r21, 0

li r26, 10
mtctr r26

branch_clear_item_amount_loop:

stb r21, 0(r24)
addi r24, r24, 4

bdnz+ branch_clear_item_amount_loop

branch_finished:

# Function Epilogue...
lmw r14, 8(r1)
addi r1, r1, 80

Notes:
- If a detection occurs, the milliseconds will return to normal when the next race begins.
- This code relies on a specific value in the ITEM Packet. Due to the nature of how network traffic is sent, it is recommended to have all P2P connections set up (NATNEG complete).

Code Creator: Star
Code Credits: Bully@WiiPlaza (USB Gecko Spy Items, Millisecond Display Modifier)
Reply
#2
Nice work!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)