From 389f7ea47dfe04a6723e9563f70724e8f80ac03a Mon Sep 17 00:00:00 2001 From: Aaron B Date: Sun, 22 Sep 2024 11:57:01 -0400 Subject: [PATCH 1/5] typo --- MexTK/include/mex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MexTK/include/mex.h b/MexTK/include/mex.h index 1a91b79e..a06e5ebc 100644 --- a/MexTK/include/mex.h +++ b/MexTK/include/mex.h @@ -255,7 +255,7 @@ typedef struct MexData { char *dat_name; char *symbol_name; - void *particle_data_runtime; // this pointer is shifed back by (effect_idx_start * 4)! + void *particle_data_runtime; // this pointer is shifted back by (effect_idx_start * 4)! } *files; } *effect; void *item; From addb285fbf4947c2afba4e5f90d9eab84b262ba7 Mon Sep 17 00:00:00 2001 From: Aaron B Date: Sun, 22 Sep 2024 17:24:39 -0400 Subject: [PATCH 2/5] Added ItemLogic struct and static vars --- MexTK/include/item.h | 45 +++++++++++++++++++++++------------------ MexTK/include/structs.h | 1 + 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/MexTK/include/item.h b/MexTK/include/item.h index 8ca735e6..2fbfd9e1 100644 --- a/MexTK/include/item.h +++ b/MexTK/include/item.h @@ -405,6 +405,25 @@ struct ItemState void *collCallback; }; +struct ItemLogic +{ + ItemState *item_states; // 0x0 + void (*OnCreate)(GOBJ *item); // 0x4 + void (*OnDestroy)(GOBJ *item); // 0x8 + void (*OnPickup)(GOBJ *item); // 0xC + void (*OnDrop)(GOBJ *item); // 0x10 + void (*OnThrow)(GOBJ *item); // 0x14 + int (*OnGiveDamage)(GOBJ *item); // 0x18, returns isDestroy + int (*OnTakeDamage)(GOBJ *item); // 0x1c, returns isDestroy + void (*OnEnterAir)(GOBJ *item); // 0x20 + void (*OnReflect)(GOBJ *item); // 0x24 + void (*OnClank)(GOBJ *item); // 0x28 + void (*OnAbsorb)(GOBJ *item); // 0x2c + int (*OnShieldBounce)(GOBJ *item); // 0x30, returns isDestroy + int (*OnShieldHit)(GOBJ *item); // 0x34, returns isDestroy + void (*OnUnkEvent)(GOBJ *item); // 0x38 +}; + struct SpawnItem { GOBJ *parent_gobj; // 0x0 @@ -549,24 +568,7 @@ struct ItemData int xac; // 0xac int xb0; // 0xb0 int xb4; // 0xb4 - struct // - { // - ItemState *item_states; // 0x0 - void (*OnCreate)(GOBJ *item); // 0x4 - void (*OnDestroy)(GOBJ *item); // 0x8 - void (*OnPickup)(GOBJ *item); // 0xC - void (*OnDrop)(GOBJ *item); // 0x10 - void (*OnThrow)(GOBJ *item); // 0x14 - int (*OnGiveDamage)(GOBJ *item); // 0x18, returns isDestroy - int (*OnTakeDamage)(GOBJ *item); // 0x1c, returns isDestroy - void (*OnEnterAir)(GOBJ *item); // 0x20 - void (*OnReflect)(GOBJ *item); // 0x24 - void (*x28)(GOBJ *item); // 0x28 - void (*x2c)(GOBJ *item); // 0x2c - int (*OnShieldBounce)(GOBJ *item); // 0x30, returns isDestroy - int (*OnShieldHit)(GOBJ *item); // 0x34, returns isDestroy - void (*x38)(GOBJ *item); // 0x38 - } *it_func; // 0xb8, persistent item callbacks + ItemLogic *item_logic; // 0xb8, persistent item callbacks ItemState *item_states; // 0xbc int air_state; // 0xc0 itData *itData; // 0xc4 @@ -981,8 +983,11 @@ struct ItemData /*** static reference ***/ -static itPublicData **stc_itPublicData = (R13 + -0x4978); -static ItemDesc **stc_itdesc_enemies = (R13 + -0x4968); +static itPublicData **stc_itPublicData = (R13 + -0x4978); // 0x804d6d28 +static ItemDesc **stc_itdesc_enemies = (R13 + -0x4968); // 0x804d6d38 +static ItemLogic *stc_itemlogic_common_items = (R13 + -0xea1dc); // 0x803f14c4 +static ItemLogic *stc_itemlogic_character_items = (R13 + -0xe85a0); // 0x803f3100 +static ItemLogic *stc_itemlogic_pokemon_items = (R13 + -0xe92d4); // 0x803f23cc /*** Functions ***/ void Item_IndexStageItem(ItemDesc *item_desc, int index); diff --git a/MexTK/include/structs.h b/MexTK/include/structs.h index b8e04372..defb3378 100644 --- a/MexTK/include/structs.h +++ b/MexTK/include/structs.h @@ -152,6 +152,7 @@ typedef struct itPublicData itPublicData; typedef struct ItemStateDesc ItemStateDesc; typedef struct ItemData ItemData; typedef struct ItemState ItemState; +typedef struct ItemLogic ItemLogic; typedef struct SpawnItem SpawnItem; typedef struct itData itData; typedef struct itCommonAttr itCommonAttr; From 2162268307a15407c0c564d35b5beba909400012 Mon Sep 17 00:00:00 2001 From: Aaron B Date: Fri, 6 Jun 2025 17:14:54 -0400 Subject: [PATCH 3/5] comments --- MexTK/include/fighter.h | 14 +++++++------- MexTK/include/item.h | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/MexTK/include/fighter.h b/MexTK/include/fighter.h index 2a83fd33..c359fdad 100644 --- a/MexTK/include/fighter.h +++ b/MexTK/include/fighter.h @@ -134,7 +134,7 @@ enum FtPri FTPRI_ENVCOLL, FTPRI_IK, FTPRI_ACCESSORY, - FTPRI_GFX, + FTPRI_GFX, // appears to also control accessory4 callbacks and the subsequent accessory animation FTPRI_10, FTPRI_11, FTPRI_GRABCOLL, @@ -2279,8 +2279,8 @@ struct FighterData float hitlag_mult; // 0x196c int x1970; // 0x1970 GOBJ *item_held; // 0x1974 - GOBJ *x1978; // 0x1978 - int x197c; // 0x197c + GOBJ *x1978; // 0x1978, second held item (new picked up items stored here if 'item_held' already has a value) + GOBJ *x197c; // 0x197c GOBJ *item_head; // 0x1980 GOBJ *item_held_spec; // 0x1984, special held item struct hurt // 0x1988 @@ -2416,7 +2416,7 @@ struct FighterData u16 x2098; // 0x2098 u16 is_hide_player_indicator; // 0x209a int x209c; // 0x209c - JOBJ *accessory; // 0x20a0 + JOBJ *accessory; // 0x20a0, reset on state changes unless persist flag is set int x20a4; // 0x20a4 void *shadow; // 0x20a8, ASSERTS @ 8037f7b8, describes multiple struct members int x20ac; // 0x20ac @@ -2478,10 +2478,10 @@ struct FighterData void (*Phys)(GOBJ *fighter); // 0x21a4 void (*Coll)(GOBJ *fighter); // 0x21a8 void (*Cam)(GOBJ *fighter); // 0x21ac - void (*Accessory1)(GOBJ *fighter); // 0x21b0 + void (*Accessory1)(GOBJ *fighter); // 0x21b0, reset after state change void (*Accessory_Persist)(GOBJ *fighter); // 0x21b4, persists across states while the fighter is alive, death clears this ptr, so re-init on Respawn cb. phys position is copied to tonp and fighter jobj matrices are updated after this cb runs void (*Accessory_Freeze)(GOBJ *fighter); // 0x21b8, only runs during hitlag - void (*Accessory4)(GOBJ *fighter); // 0x21bc + void (*Accessory4)(GOBJ *fighter); // 0x21bc, reset after state change void (*OnGiveDamage)(GOBJ *fighter); // 0x21c0 void (*OnShieldHit)(GOBJ *fighter); // 0x21c4 void (*OnReflectHit)(GOBJ *fighter); // 0x21c8 @@ -2599,7 +2599,7 @@ struct FighterData unsigned char x221f_3 : 1; // 0x20 - 0x221f, hides player indicator unsigned char sleep : 1; // 0x10 - 0x221f unsigned char ms : 1; // 0x08 - 0x221f, ms = master/slave. is 1 when the player is a slave - unsigned char x221f_6 : 1; + unsigned char x221f_6 : 1; // 0x04 - 0x221f, is in hitlag? unsigned char x221f_7 : 1; unsigned char x221f_8 : 1; char can_input_multijump; // 0x2220 diff --git a/MexTK/include/item.h b/MexTK/include/item.h index 2fbfd9e1..72035df3 100644 --- a/MexTK/include/item.h +++ b/MexTK/include/item.h @@ -572,7 +572,7 @@ struct ItemData ItemState *item_states; // 0xbc int air_state; // 0xc0 itData *itData; // 0xc4 - JOBJ *joint; // 0xc8 + JOBJ *joint; // 0xc8, is this a JOBJDesc instead?? itCommonAttr *common_attr; // 0xcc int xd0; // 0xd0 ItDynamicBoneset dynamics_boneset[24]; // 0xd4 @@ -714,7 +714,7 @@ struct ItemData void (*anim)(GOBJ *item); // 0xd14 void (*phys)(GOBJ *item); // 0xd18 void (*coll)(GOBJ *item); // 0xd1c - void (*accessory)(GOBJ *item); // 0xd20 + void (*accessory)(GOBJ *item); // 0xd20, reset upon item state change (only runs if is_hitlag == 0?) void (*on_detect)(GOBJ *item); // 0xd24 void (*on_enter_hitlag)(GOBJ *item); // 0xd28, runs after applying hitlag in damage apply proc 8026a62c void (*on_exit_hitlag)(GOBJ *item); // 0xd2c, runs after exiting hitlag in hitlag update proc 8026a200 @@ -726,7 +726,7 @@ struct ItemData int xd40; // 0xd40 float lifetime; // 0xd44 int xd48; // 0xd48 - int xd4c; // 0xd4c + int xd4c; // 0xd4c, used as ammo counter for lgun int land_num; // 0xd50 int throw_num; // 0xd54 int xd58; // 0xd58 From 71099436040131c7d70d8e08fcc9adbb1d765a56 Mon Sep 17 00:00:00 2001 From: Aaron B Date: Fri, 6 Jun 2025 17:36:43 -0400 Subject: [PATCH 4/5] typo --- MexTK/include/mxdt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MexTK/include/mxdt.h b/MexTK/include/mxdt.h index 378b1878..7a848020 100644 --- a/MexTK/include/mxdt.h +++ b/MexTK/include/mxdt.h @@ -321,7 +321,7 @@ typedef struct MexData { char *dat_name; char *symbol_name; - void *particle_data_runtime; // this pointer is shifed back by (effect_idx_start * 4)! + void *particle_data_runtime; // this pointer is shifted back by (effect_idx_start * 4)! } *files; } *effect; void *item; From f3d48d208326f8a76a8ead9671333fc71ac51891 Mon Sep 17 00:00:00 2001 From: Aaron B Date: Sat, 21 Jun 2025 19:20:27 -0400 Subject: [PATCH 5/5] Helpful references --- MexTK/include/fighter.h | 6 +++--- MexTK/include/item.h | 45 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/MexTK/include/fighter.h b/MexTK/include/fighter.h index 93a32c10..7179e93f 100644 --- a/MexTK/include/fighter.h +++ b/MexTK/include/fighter.h @@ -122,7 +122,7 @@ enum CPUType CPTP_ITEM, }; -// fighter callback priorities +// fighter callback priorities (see 8000FD48) enum FtPri { FTPRI_HITLAG, @@ -133,8 +133,8 @@ enum FtPri FTPRI_5, // nothing FTPRI_ENVCOLL, FTPRI_IK, - FTPRI_ACCESSORY, - FTPRI_GFX, // appears to also control accessory4 callbacks and the subsequent accessory animation + FTPRI_ACCESSORY, // controls the first 3 accessory callbacks + FTPRI_GFX, // also controls accessory4 callback and the subsequent accessory jobj animation FTPRI_10, FTPRI_11, FTPRI_GRABCOLL, diff --git a/MexTK/include/item.h b/MexTK/include/item.h index d180b3c0..870f346e 100644 --- a/MexTK/include/item.h +++ b/MexTK/include/item.h @@ -177,6 +177,34 @@ enum ItemID ITEM_BIRDOEGG = 236, }; +// item callback priorities (see 8026862C) +enum ItPri +{ + ITPRI_HITLAG, + ITPRI_ANIM, + ITPRI_2, + ITPRI_3, + ITPRI_PHYS, + ITPRI_COLL, + ITPRI_6, + ITPRI_7, + ITPRI_8, + ITPRI_ACCESSORY, + ITPRI_10, + ITPRI_PLAYERCOLL, + ITPRI_GRABCOLL, + ITPRI_HITCOLL, + ITPRI_DMGAPPLY, + ITPRI_15, + ITPRI_DYNAMICS, + ITPRI_17, + ITPRI_18, + ITPRI_19, + ITPRI_20, + ITPRI_21, + ITPRI_22, +}; + // ItemStateChange Flags #define ITEMSTATE_UPDATEANIM 0x2 #define ITEMSTATE_GRAB 0x4 @@ -578,7 +606,7 @@ struct ItemData ItDynamicBoneset dynamics_boneset[24]; // 0xd4 int dynamics_num; // 0x374 CollData coll_data; // 0x378 -> 0x518 - GOBJ *fighter_gobj; // 0x518 + GOBJ *fighter_gobj; // 0x518, should be owner_gobj (as it can be an item or other type of GOBJ too) int x51c; // 0x51c CmSubject *camera_subject; // 0x520 int x524; // 0x524 @@ -987,11 +1015,20 @@ struct ItemData /*** static reference ***/ -static itPublicData **stc_itPublicData = (R13 + -0x4978); // 0x804d6d28 -static ItemDesc **stc_itdesc_enemies = (R13 + -0x4968); // 0x804d6d38 static ItemLogic *stc_itemlogic_common_items = (R13 + -0xea1dc); // 0x803f14c4 -static ItemLogic *stc_itemlogic_character_items = (R13 + -0xe85a0); // 0x803f3100 static ItemLogic *stc_itemlogic_pokemon_items = (R13 + -0xe92d4); // 0x803f23cc +static ItemLogic *stc_itemlogic_character_items = (R13 + -0xe85a0); // 0x803f3100 +static ItemLogic *stc_itemlogic_stage_items = (R13 + -0xe6980); // 0x803f4d20 + +static itData **stc_itdata_stage_items = (R13 + -0x3a740); // 0x804a0f60 + +static itPublicData **stc_itPublicData = (R13 + -0x4978); // 0x804d6d28 +static ItemDesc **stc_itdesc_enemies = (R13 + -0x4968); // 0x804d6d38 + +static itData **stc_itdata_common_items = (R13 + -0x497c); // 0x804d6d24 +static itCommonData **stc_itCommonData = (R13 + -0x4978); // 0x804d6d28, loaded in from ItCo.dat/usd +static itData **stc_itdata_pokemon_items = (R13 + -0x4970); // 0x804d6d30 +static itData **stc_itdata_character_items = (R13 + -0x4968); // 0x804d6d38 /*** Functions ***/ void Item_IndexStageItem(ItemDesc *item_desc, int index);