-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
itemEntity struct and 2 functions #267
Comments
Thank you @DenSinH ! Please feel free to let us know if you make any further discoveries / want to get more involved with decomp in the future |
I didn't include the 2 structs in my PR since it seems you weren't too sure on them and they weren't used in these 2 functions. Let us know if you can flesh them out and get some functions which interact with them. |
@ethteck apparently the real N64 might theoretically be able to reach the 0 (hanging) state but the probabiliy is very low due to the 10% chance of the animation being reset before that. So it seems that this theory is correct. @Kelebek1 the thing is that the structs look different depending on the state, and all fields correspond to fields in the I would like to maybe help with the decomp some time, but I'll have to find some time to set it all up, since I gathered the goal is a byte-level accurate decompilation. |
Yep! IMO it's not especially difficult to set up if you have a Unix shell (Linux, macOS, WSL 2) already - there's no fancy stuff like manually setting up a N64 whole toolchain. |
While helping my friend out with his emulator, I found some info on the itemEntity struct and 2 functions. We used a dump of the RAM in his emulator to see what was going on.
The field currently named
unk_34
seems to hold only 4 byte sized values. There is a function calledupdate_item_entities
, that should update item entities. In the ROM this is located at900c85ec
. This function is copied to RAM location80131eec
. In a for loop, this function checks if the itemID of some itemEntity structs is equal to0x157
, which from https://tcrf.net/Notes:Paper_Mario I gathered were coins. If they are coins, there is a 10% chance some values get updated in the struct, which I believe are values related to a (sparkling) animation sequence. The more interesting function call is that toFUN_90130acc
, which is nothing, but after being copied to RAM this is a call to80130acc
corresponding to a function at900c71cc
. The decompilation for this function should be something likeThe
frames_left
field is the field at offset0x3c
in theitemEntity
struct. Essentially, every animation sequence step (I am just guessing it is an animation sequence, it might be some other sequence) lasts for a certain amount of frames.The
next_step
function in ROM is a call to90130a04
, which again points to nothing, but in RAM this is a call to80130a04
, corresponding to900c7104
in the ROM. This function essentially does one step in the animation and returns whether a next step should be taken. It should look something like this:essentially, the
current_state_ptr
(field offset 0x40) points to a struct, which varies on what state it is. In all cases it starts with an int showing what state it actually is. In the case of 0 it is just an int, and thedo_animation
function will hang. In case of 1, it looks likecase 2 resets the animation. The struct is also just an int then. case 3 switches to a new animation, and the struct looks like
case 4 simply advances the state. The struct does hold an extra 32 bit piece of information, but this is not really used here it seems. case 5 or 6 do nothing, but will not hang the
do_animation
function. case 7 is the most interesting one, it holds a struct that looks likeOf course, the integers showing the state are likely some enum. The struct sizes can be checked by the amount that
item_entity->current_state_ptr
is advanced (in strides of 4 bytes). An example of such a sequence can be found in ROM at9009df70
, copied to RAM at80104ac0
. This is a sequence that starts at state 4, then state 7 a few times and then state 0 (which presumably the N64 never reaches, have not figured this out yet). Looking at the values for the pointers of field 0x4c and 0x50, 4c seems to point at 0x20 bytes of data, and 0x50 at some multiple of 0x20.Because of this, I also think that the
itemEntity
struct will look something likeThe text was updated successfully, but these errors were encountered: