Item Cycler [Bully, Ro]
#1
Item Cycler [Bully, Ro]

This code will allow cycling through items. You can cycle to the left (decrement) or to the right (increment). The items are infinite but you can make a deactivator to disable the code at will. It is coded from Bully's Always Have Item code.
Useful for debugging purposes. Only NTSC-U has been tested.

Updated as of March 6th of 2024: Added "Item Use Flash Fix for Item Hack" (https://mariokartwii.com/showthread.php?tid=2111) which makes item flash on the roulette if using an item, something that originally doesn't happen. if you don't like this flash, you can remove it (it's at the bottom of the code, look the post for the code to know what part to remove). Reposted code in correct section.

NTSC-U
C27E4B88 00000013
48000009 00000000
7CC802A6 3CE08034
89460000 A187XXXX
718BYYYY 41820040
8BE60001 2C1F0000
40820034 718BLLLL
41820014 2C0A0000
394AFFFF 40820020
39400013 718BRRRR
41820014 2C0A0012
394A0001 40810008
39400000 3BE00001
40820008 3BE00000
9BE60001 99460000
9144008C 38C00001
2C0A0005 4182000C
2C0A0010 41800008
38C00003 90C40090
60000000 00000000
C278894C 00000002
3BE00001 9BFD0238
83E3008C 00000000
047E4E00 60000000

PAL
C27EEE98 00000013
48000009 00000000
7CC802A6 3CE08034
89460000 A187XXXX
718BYYYY 41820040
8BE60001 2C1F0000
40820034 718BLLLL
41820014 2C0A0000
394AFFFF 40820020
39400013 718BRRRR
41820014 2C0A0012
394A0001 40810008
39400000 3BE00001
40820008 3BE00000
9BE60001 99460000
9144008C 38C00001
2C0A0005 4182000C
2C0A0010 41800008
38C00003 90C40090
60000000 00000000
C2791958 00000002
3BE00001 9BFD0238
83E3008C 00000000
047EF110 60000000
 
NTSC-J
C27EE504 00000013
48000009 00000000
7CC802A6 3CE08034
89460000 A187XXXX
718BYYYY 41820040
8BE60001 2C1F0000
40820034 718BLLLL
41820014 2C0A0000
394AFFFF 40820020
39400013 718BRRRR
41820014 2C0A0012
394A0001 40810008
39400000 3BE00001
40820008 3BE00000
9BE60001 99460000
9144008C 38C00001
2C0A0005 4182000C
2C0A0010 41800008
38C00003 90C40090
60000000 00000000
C2790FC4 00000002
3BE00001 9BFD0238
83E3008C 00000000
047EE77C 60000000

NTSC-K
C27DD258 00000013
48000009 00000000
7CC802A6 3CE08035
89460000 A187XXXX
718BYYYY 41820040
8BE60001 2C1F0000
40820034 718BLLLL
41820014 2C0A0000
394AFFFF 40820020
39400013 718BRRRR
41820014 2C0A0012
394A0001 40810008
39400000 3BE00001
40820008 3BE00000
9BE60001 99460000
9144008C 38C00001
2C0A0005 4182000C
2C0A0010 41800008
38C00003 90C40090
60000000 00000000
C277FD18 00000002
3BE00001 9BFD0238
83E3008C 00000000
047DD4D0 60000000

XXXX: Controller Address
YYYY: Both buttons values that will cycle items left and right, masked together (LLLL + RRRR = YYYY). E.g (Wiimote): D-Pad Left (0001) cycles item to the left < and D-Pad Right (0002) cycles item to the right >, therefore YYYY will be 0003 (0001 + 0002 = 0003)
LLLL: Button value that will cycle items to the left < (decrement) 
RRRR: Button value that will cycle items to the right > (increment)

Code:
Source:
bl start # bl trick so values of the code are stored to address below
.value 0 #this place will hold the stored item ID value and the pressed state value. Done this way to avoid loading and storing from EVA
start:
mflr r6 # r6 will hold the address where values of the code will be stored
lis r7, 0x803Q # Q is 5 for NTSC-K, 4 for all other regions
lbz r10, 0 (r6) # Load item value
lhz r12, 0xXXXX (r7) # Load halfword from controller address
andi. r11, r12, 0xYYYY # Change YYYY to both buttons that will cycle items left and right, masked together (LLLL + RRRR = YYYY). E.g (Wiimote): D-Pad Left (0001) cycles item to the left < and D-Pad Right (0002) cycles item to the right >, therefore YYYY will be 0003 (0001 + 0002 = 0003)
beq skip #Not pressed, skip all the code
lbz r31, 1 (r6) # Button pressed, now let's check the pressed state
cmpwi r31, 0 # Is button state not pressed
bne skip # If state is not not pressed (0), skip the code that cycles item
# Code here will only execute for a frame
andi. r11, r12, 0xLLLL # Change LLLL to button value that will cycle items to thee left < (decrement)
beq add
cmpwi r10, 0 # Check if item is Green Shell
subi r10, r10, 1 # Subtract item value (to cycle to the left)
bne skip # If item is not Green Shell, continue code as normal
li r10, 0x13 # Set item to Triple Bananas (last item of the list) if trying to subtract item ID if it's Green Shell - ID is off because of logic but it works as intended
add:
andi. r11, r12, 0xRRRR # Change RRRR to button value that will cycle items to the right > (increment)
beq skip # Button is not pressed, skip cycling to the right
cmpwi r10, 0x12 # Check if item is Triple Banana
addi r10, r10, 1 # Increment item value (to cycle to the left)
ble skip # If item ID is less than invalid ID (0x13, ID is off because of logic but it works as intended), skip resetting item back to Green Shell
reset:
li r10, 0 # Reset item to Green Shell
skip:
li r31, 1 # # Button is set to pressed by default, but depending if button to cycle item is pressed or if in pressed state (1), this might be replaced with not pressed (0) after the branch below
bne skip2 # If button to cycle item is pressed, skip setting not pressed (0) and if button state is pressed (1), skip setting not pressed (0)
li r31, 0 # If button to cycle item is not pressed, set state to not pressed (0)
skip2:
stb r31, 1 (r6) # Store button press state
stb r10, 0(r6) # Store item ID
stw r10, 0x8C (r4) # Store item ID to item pointer
li r6, 1 # Set item amount to one
cmpwi r10, 5 # Check if item is Triple Mushroom
beq triple # Jump to set amount to three
cmpwi r10, 0x10 # If item ID is less than Triple Green Shell (0x10 and above are all Triple Items)
blt storeamt # Skip setting amount to three
triple:
li r6, 3 # Set amount to three
storeamt:
stw r6, 0x90 (r4) #Store amount to item pointer

Base code (Always Have Item [Bully]): https://mariokartwii.com/showthread.php?tid=50

Code credits: Bully (Original Always Have Item code), Ro (Making an item cycler from Bully's code)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)