03-16-2024, 05:36 AM
(This post was last modified: 03-16-2024, 05:36 AM by seanmcnally.)
(03-16-2024, 02:23 AM)Vega Wrote: I don't know if r27 is the "base" pointer for the portion of code for the slot loading. You will need to step by step your code and see if r3 (after the lbz) is always a number from 0 thru B. If not, then try r29. Tutorial for stepping - https://mariokartwii.com/showthread.php?tid=1383
I don't fully understand what a base pointer is, but I do know I tested it for all four human players and it works. I'll come back to this if I run into issues, I appreciate the info
(03-16-2024, 02:23 AM)Vega Wrote: You have the default instruction in your source twice, remove the 2nd one.
You also have "lis r12, 0x8000" twice. Not needed as r12's value remains intact by the time your code reaches the 2nd stb.
Entirely my bad. This is because I initially wrote this as two separate codes (get item used, get player that used item), and then just sort of mashed them together without thinking about it once they both worked . Here's the updated code:
C278894C 00000004
83E3008C 3D808000
9BEC164F 807B0000
80630000 88630010
986C165F 00000000
Source:
Instruction 8078894C
lwz r31, 0x008C (r3) # Default instruction, loads item to r31
# Find out what item was used, store to 8000164F
lis r12, 0x8000 #Set the upper 16 bits of the EVA
stb r31, 0x164F (r12) #Store what item was used to the EVA at address 8000164F
# Load the slot of player that just used an item, store to 8000165F
lwz r3, 0x0 (r27) # Slot loading code start, load mem address from r27 into r3
lwz r3, 0x0 (r3) # Load new word from a memory address based on the word we just loaded
lbz r3, 0x10 (r3) # Load new byte from a memory address based on the word we just loaded
stb r3, 0x165F (r12) #Store who used an item to the EVA at address 8000165F
---
For anyone who wants to use this the way I am, add memory write breakpoints at 8000164F and 8000165F. Choose "Write To Log". Dolphin will write these item code values to 8000164F depending on what was used. It will also write 0-3 based on what human player used the item.
P1 = 0
P2 = 1
P3 = 2
P4 = 3