From f26bc88b0b5eb636dd89ce8ca4f9cd7b498247c1 Mon Sep 17 00:00:00 2001 From: Adex-8x Date: Tue, 7 Jan 2025 18:03:40 -0500 Subject: [PATCH] Adjustments + object info --- headers/data/overlay11.h | 6 +- headers/functions/overlay11.h | 36 +++- headers/types/ground_mode/ground_mode.h | 92 +++++++-- symbols/overlay11.yml | 249 +++++++++++++++++++++++- 4 files changed, 352 insertions(+), 31 deletions(-) diff --git a/headers/data/overlay11.h b/headers/data/overlay11.h index 7eaf7e8d..44af7dc2 100644 --- a/headers/data/overlay11.h +++ b/headers/data/overlay11.h @@ -14,10 +14,10 @@ extern struct dungeon_id_16 RECRUITMENT_TABLE_LOCATIONS[22]; extern int16_t RECRUITMENT_TABLE_LEVELS[22]; extern struct monster_id_16 RECRUITMENT_TABLE_SPECIES[22]; extern struct level_tilemap_list_entry LEVEL_TILEMAP_LIST[81]; -extern struct ground_entity_function_pointer_table ACTOR_FUNCTION_POINTER_TABLE; +extern struct ground_entity_function_table ACTOR_FUNCTION_POINTER_TABLE; extern struct animation_data SETANIMATION_TABLE[84]; -extern struct ground_entity_function_pointer_table OBJECT_FUNCTION_POINTER_TABLE; -extern struct ground_entity_function_pointer_table PERFORMER_FUNCTION_POINTER_TABLE; +extern struct ground_entity_function_table OBJECT_FUNCTION_POINTER_TABLE; +extern struct ground_entity_function_table PERFORMER_FUNCTION_POINTER_TABLE; extern struct window_params TEAM_INFO_BOX_DEFAULT_WINDOW_PARAMS; extern struct overlay_load_entry OVERLAY11_OVERLAY_LOAD_TABLE[21]; extern struct main_ground_data GROUND_STATE_PTRS; diff --git a/headers/functions/overlay11.h b/headers/functions/overlay11.h index c2059ffc..f36ed9bd 100644 --- a/headers/functions/overlay11.h +++ b/headers/functions/overlay11.h @@ -48,6 +48,8 @@ void InitPartnerFollowDataAndLiveActorList(void); void DeleteLiveActor(int16_t actor_id); void SetAttributeBitfieldLiveActor(int16_t live_actor_id, uint32_t attribute_bitfield); void ResetAttributeBitfieldLiveActor(int16_t live_actor_id, uint32_t attribute_bitfield); +int GetCollidingActorId(int16_t live_actor_id, uint32_t attribute_bitfield, struct vec2* coord_min, + struct vec2* coord_max); void ChangeActorAnimation(struct live_actor* actor, uint16_t setanimation_param); void SetPositionLiveActor(struct live_actor* actor, struct vec2* pos); int16_t GetIdLiveActor(struct live_actor* actor); @@ -59,8 +61,8 @@ void GetCollisionBoxCenterLiveActor(struct live_actor* actor, struct uvec2* coll void SetPositionLiveActorVeneer(struct live_actor* actor, struct vec2* pos); void GetHeightLiveActor(struct live_actor* actor, int* height, int* second_height); void SetHeightLiveActor(struct live_actor* actor, int height); -void GetDirectionLiveActor(struct live_actor* actor, struct direction_id_8* target); -void SetDirectionLiveActor(struct live_actor* actor, struct direction_id_8 direction); +void GetDirectionLiveActor(struct live_actor* actor, enum direction_id* target); +void SetDirectionLiveActor(struct live_actor* actor, enum direction_id direction); void SetAnimationLiveActor(struct live_actor* actor, uint16_t setanimation_param); void SetEffectLiveActor(struct live_actor* actor, bool flag, int16_t effect_id, int position_marker); @@ -73,8 +75,34 @@ void SetBlinkLiveActor(struct live_actor* actor, uint16_t interval_blink_in, uint16_t interval_blink_out); void SetPositionOffsetLiveActor(struct live_actor* actor, struct vec2* offset); void InitPartnerFollowData(void); -void GetDirectionLiveObject(undefined object, struct direction_id_8* target); -void SetDirectionLiveObject(undefined object, struct direction_id_8 direction); +void SetAttributeBitfieldLiveObject(int16_t live_object_id, uint32_t attribute_bitfield); +void ResetAttributeBitfieldLiveObject(int16_t live_object_id, uint32_t attribute_bitfield); +int GetCollidingObjectId(uint32_t attribute_bitfield, struct vec2* coord_min, + struct vec2* coord_max); +void SetPositionLiveObject(struct live_object* object, struct vec2* pos); +int16_t GetIdLiveObject(struct live_object* object); +void GetCollisionBoxLiveObject(struct live_object* object, struct uvec2* collision_box); +void SetPositionInitialLiveObject(struct live_object* object, struct vec2* offset); +void SetMovementRangeLiveObject(struct live_object* object, struct vec2* limit_min_pos, + struct vec2* limit_max_pos); +void GetCollisionBoxCenterLiveObject(struct live_object* object, + struct uvec2* collision_box_center); +void SetPositionLiveObjectVeneer(struct live_object* object, struct vec2* pos); +void GetHeightLiveObject(struct live_object* object, int* height, int* second_height); +void SetHeightLiveObject(struct live_object* object, int height); +void GetDirectionLiveObject(struct live_object* object, enum direction_id* target); +void SetDirectionLiveObject(struct live_object* object, enum direction_id direction); +void SetAnimationLiveObject(struct live_object* object, uint16_t setanimation_param); +void SetEffectLiveObject(struct live_object* object, bool flag, int16_t effect_id); +int GetAnimationStatusLiveObject(struct live_object* object); +int GetEffectStatusLiveObject(struct live_object* object); +void GetAttributeBitfieldLiveObject(struct live_object* object, uint32_t* attribute_bitfield); +void SetAttributeBitfieldLiveObjectWrapper(struct live_object* object, uint32_t attribute_bitfield); +void ResetAttributeBitfieldLiveObjectWrapper(struct live_object* object, + uint32_t attribute_bitfield); +void SetBlinkLiveObject(struct live_object* object, uint16_t interval_blink_in, + uint16_t interval_blink_out); +void SetPositionOffsetLiveObject(struct live_object* object, struct vec2* offset); int CreateTeamInfoBox(void); void CloseTeamInfoBox(int window_id); bool IsTeamInfoBoxActive(int window_id); diff --git a/headers/types/ground_mode/ground_mode.h b/headers/types/ground_mode/ground_mode.h index 5d449f28..114b7067 100644 --- a/headers/types/ground_mode/ground_mode.h +++ b/headers/types/ground_mode/ground_mode.h @@ -287,17 +287,17 @@ struct animation_data { ASSERT_SIZE(struct animation_data, 2); #pragma pack(pop) -// represent an actor present in the scene in the overworld (both during cutscenes and free-roams) +// Represents an actor currently loaded in a script scene (both during cutscenes and free-roam) struct live_actor { int16_t id; // The ID of this live actor, used to index an actor within the statically-allocated // list. - uint16_t entity_id; // The ID of the actor in the ENTITIES table. Internally named kind. + uint16_t kind; // The ID of the actor in the ENTITIES table. Internally named kind. bool is_enabled; // true when the actor is loaded, false otherwise (should be checked if unsure) undefined field_0x5; uint16_t hanger; uint8_t sector; int8_t field_0x9; - int16_t field_0xa; + int16_t field_0xa; // Related to animation? struct uvec2 collision_box; // The size of the collision box of the actor struct uvec2 size_div2; // The size of the collision box divided by two struct direction_id_8 initial_direction; @@ -360,33 +360,87 @@ struct live_actor { // not sure. seem to be 0 when not moving and 3 when moving most of the time. int32_t movement_related; int16_t second_bitfield; // not sure - int16_t field_0x182; - int16_t field_0x184; + int16_t effect_flag; // not sure + int16_t effect_id; undefined field_0x186; undefined field_0x187; - undefined field_0x188; - undefined field_0x189; - undefined field_0x18a; - undefined field_0x18b; + int effect_position_marker; struct animation animation; }; ASSERT_SIZE(struct live_actor, 592); -// A list of 24 actors, which is the number of statically allocated live actors +// Represents an object currently loaded in a script scene (both during cutscenes and free-roam) +struct live_object { + undefined field_0x0; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int16_t id; // The ID of this live object, used to index an object within the + // statically-allocated list. + uint16_t kind; // The ID of the object in the OBJECTS table. Internally named kind. + bool + is_enabled; // true when the object is loaded, false otherwise (should be checked if unsure) + undefined field_0x9; + uint16_t hanger; + uint8_t sector; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + struct uvec2 collision_box; // The size of the collision box of the object + struct uvec2 size_div2; // The size of the collision box divided by two + struct direction_id_8 initial_direction; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + struct vec2 initial_position; + struct vec2 limit_min_pos; // minimum possible coordinates, for random move in free roam + struct vec2 limit_max_pos; // maximum possible coordinates, for random move in free roam + undefined maybe_command_data[236]; // Seems to be a script-related struct + undefined field_0x128; + undefined field_0x129; + undefined field_0x12a; + undefined field_0x12b; + uint32_t attribute_bitfield; // Changed by various "Attribute" opcodes + struct direction_id_8 direction; + undefined field_0x131; + undefined field_0x132; + undefined field_0x133; + struct vec2 coord_min; // the top-left coordinate of the collision box of the object + struct vec2 coord_max; // the bottom-right coordinate of the collision box of the object + int32_t height; + int32_t second_height; + bool direction_should_change; // Seems to be set to 1 in SetPositionInitialLiveObject if + // initial_direction != direction + undefined field_0x14d; + undefined field_0x14e; + undefined field_0x14f; + int16_t effect_flag; // not sure + int16_t effect_id; + struct animation animation; +}; +ASSERT_SIZE(struct live_object, 536); + +// A list of 24 actors, which is the maximum number of statically allocated live actors struct live_actor_list { struct live_actor actors[24]; }; ASSERT_SIZE(struct live_actor_list, 14208); -// A global structure holding various pointer to important structure for ground mode +// A list of 16 objects, which is the maximum number of statically allocated live objects +struct live_object_list { + struct live_object objects[16]; +}; +ASSERT_SIZE(struct live_object_list, 8576); + +// A global structure holding various pointers to important structures for ground mode struct main_ground_data { undefined* script; // 0x0: pointer to script structure undefined* partner_follow_data; // 0x4: pointer to the data related to the partner following the player - struct live_actor_list* actors; // 0x8: pointer to the actors - undefined* objects; // 0xC: pointer to the objects - undefined* performers; // 0x10: pointer to the performers - undefined* events; // 0x14: pointer to the events + struct live_actor_list* actors; // 0x8: pointer to the actors + struct live_object_list* objects; // 0xC: pointer to the objects + undefined* performers; // 0x10: pointer to the performers + undefined* events; // 0x14: pointer to the events }; ASSERT_SIZE(struct main_ground_data, 24); @@ -431,20 +485,20 @@ struct ground_weather_entry { }; ASSERT_SIZE(struct ground_weather_entry, 4); -struct ground_entity_function_pointer_table { +struct ground_entity_function_table { enum script_routine routine_type; int16_t (*get_id)(void* ground_entity); void (*get_collision_box)(void* ground_entity, struct uvec2* collision_box); void (*get_collision_box_center)(void* ground_entity, struct uvec2* collision_box_center); void (*get_height)(void* ground_entity, int* height, int* second_height); - void (*get_direction)(void* ground_entity, struct direction_id_8* target); + void (*get_direction)(void* ground_entity, enum direction_id* target); void (*get_attribute_bitfield)(void* ground_entity, uint32_t* attribute_bitfield); void (*set_position_initial)(void* ground_entity, struct vec2* offset); void (*set_movement_range)(void* ground_entity, struct vec2* limit_min_pos, struct vec2* limit_max_pos); void (*set_position)(void* ground_entity, struct vec2* pos); void (*set_height)(void* ground_entity, int height); - void (*set_direction)(void* ground_entity, struct direction_id_8 direction); + void (*set_direction)(void* ground_entity, enum direction_id direction); void (*set_animation)(void* ground_entity, uint16_t setanimation_param); void (*set_effect)(void* ground_entity, bool flag, int16_t effect_id, int position_marker); void (*set_attribute_bitfield_wrapper)(void* ground_entity, uint32_t attribute_bitfield); @@ -454,6 +508,6 @@ struct ground_entity_function_pointer_table { int (*get_animation_status)(void* ground_entity); int (*get_effect_status)(void* ground_entity); }; -ASSERT_SIZE(struct ground_entity_function_pointer_table, 80); +ASSERT_SIZE(struct ground_entity_function_table, 80); #endif diff --git a/symbols/overlay11.yml b/symbols/overlay11.yml index e05bd7aa..a8497824 100644 --- a/symbols/overlay11.yml +++ b/symbols/overlay11.yml @@ -498,6 +498,19 @@ overlay11: r0: live actor id r1: attribute bitfield + - name: GetCollidingActorId + address: + EU: 0x22F9B20 + NA: 0x22F9180 + JP: 0x22FA804 + description: |- + Returns the first colliding actor given a series of vector coordinates. + + r0: live actor id (used only to ignore an actor colliding with itself) + r1: attribute bitfield to test actors against + r2: pointer to coord_min + r3: pointer to coord_max + return: The first colliding actor's id, or -1 if no is collision detected - name: ChangeActorAnimation address: EU: 0x22F9D68 @@ -738,28 +751,254 @@ overlay11: Initialize the partner follow data structure, without allocating it (in GROUND_STATE_PTRS) No params. + - name: SetAttributeBitfieldLiveObject + address: + EU: 0x22FCF98 + NA: 0x22FC5F8 + JP: 0x22FDC70 + description: |- + Sets bits of the attribute bitfield of a currently loaded object. + + r0: live object id + r1: attribute bitfield + - name: ResetAttributeBitfieldLiveObject + address: + EU: 0x22FCFD8 + NA: 0x22FC638 + JP: 0x22FDCB0 + description: |- + Clears bits of the attribute bitfield of a currently loaded object. + + r0: live object id + r1: attribute bitfield + - name: GetCollidingObjectId + address: + EU: 0x22FD6B8 + NA: 0x22FCD18 + JP: 0x22FE390 + description: |- + Returns the first colliding object given a series of vector coordinates. + + r0: attribute bitfield to test objects against + r1: pointer to coord_min + r2: pointer to coord_max + return: The first colliding object's id, or -1 if no is collision detected + - name: SetPositionLiveObject + address: + EU: 0x22FD910 + NA: 0x22FCF70 + JP: 0x22FE5E8 + description: |- + Sets the position for a currently loaded object. + + r0: live object + r1: pointer to a position vector + - name: GetIdLiveObject + address: + EU: 0x22FDA00 + NA: 0x22FD060 + JP: 0x22FE6D8 + description: |- + Returns the ID of a currently loaded object. This ID can then be used to index GROUND_STATE_PTRS::objects. + + r0: live object + return: id + - name: GetCollisionBoxLiveObject + address: + EU: 0x22FDA08 + NA: 0x22FD068 + JP: 0x22FE6E0 + description: |- + Gets the collision box of a currently loaded object. + + r0: live object + r1: [output] collision box buffer + - name: SetPositionInitialLiveObject + address: + EU: 0x22FDA1C + NA: 0x22FD07C + JP: 0x22FE6F4 + description: |- + Sets a currently loaded object to return to its initial position. + + r0: live object + r1: pointer to an position vector; if null, object will return to its initial position + - name: SetMovementRangeLiveObject + address: + EU: 0x22FDAD8 + NA: 0x22FD138 + JP: 0x22FE7B0 + description: |- + Sets a currently loaded object's random movement range. + + r0: live object + r1: pointer to limit_min_pos + r2: pointer to limit_max_pos + - name: GetCollisionBoxCenterLiveObject + address: + EU: 0x22FDAFC + NA: 0x22FD15C + JP: 0x22FE7D4 + description: |- + Gets the center of a collision box of a currently loaded object. + + This simply adds the object's minimum coordinates by half the size of the object's collision box. + + r0: live object + r1: [output] collision box center buffer + - name: SetPositionLiveObjectVeneer + address: + EU: 0x22FDB20 + NA: 0x22FD180 + JP: 0x22FE7F8 + description: |- + Likely a linker-generated veneer for SetPositionLiveObject. + + See https://developer.arm.com/documentation/dui0474/k/image-structure-and-generation/linker-generated-veneers/what-is-a-veneer- + + r0: live object + r1: pointer to a position vector + - name: GetHeightLiveObject + address: + EU: 0x22FDB2C + NA: 0x22FD18C + JP: 0x22FE804 + description: |- + Gets the two height values of a currently loaded object. + + r0: live object + r1: [output] pointer to first height value + r2: [output] pointer to second height value, which is curiously not referenced by SetHeightLiveObject + - name: SetHeightLiveObject + address: + EU: 0x22FDB40 + NA: 0x22FD1A0 + JP: 0x22FE818 + description: |- + Sets the height of a currently loaded object. + + r0: live object + r1: height - name: GetDirectionLiveObject address: EU: 0x22FDB48 NA: 0x22FD1A8 JP: 0x22FE820 description: |- - Put the direction of the object in the destination + Gets the direction of a currently loaded object. r0: live object - r1: destination address (1 byte) + r1: [output] pointer to direction - name: SetDirectionLiveObject address: EU: 0x22FDB58 NA: 0x22FD1B8 JP: 0x22FE830 description: |- - Store the direction in the object structure - -1 input is ignored - Unsure if this change the animation + Sets the direction of a currently loaded object. Does nothing if the direction value passed is -1. r0: live object r1: direction + - name: SetAnimationLiveObject + address: + EU: 0x22FDB68 + NA: 0x22FD1C8 + JP: 0x22FE840 + description: |- + Sets the animation of a currently loaded object. + + r0: live object + r1: SetAnimation parameter + - name: SetEffectLiveObject + address: + EU: 0x22FDC28 + NA: 0x22FD288 + JP: 0x22FE900 + description: |- + Sets the effect of a currently loaded object. + + r0: live object + r1: flag (true if effect id is 0?) + r2: effect id + - name: GetAnimationStatusLiveObject + address: + EU: 0x22FDC38 + NA: 0x22FD298 + JP: 0x22FE910 + description: |- + Gets the animation status of a currently loaded object. + + Used to determine if the animation has finished via script opcodes like WaitAnimation and WaitEndAnimation. + + r0: live object + return: status + - name: GetEffectStatusLiveObject + address: + EU: 0x22FDC58 + NA: 0x22FD2B8 + JP: 0x22FE930 + description: |- + Gets the effect status of a currently loaded object. + + Used to determine if an effect has finished via the script opcode WaitEffect. + + r0: live object + return: status + - name: GetAttributeBitfieldLiveObject + address: + EU: 0x22FDC7C + NA: 0x22FD2DC + JP: 0x22FE954 + description: |- + Gets the attribute bitfield of a currently loaded object. + + r0: live object + r1: [output] pointer to attribute bitfield + - name: SetAttributeBitfieldLiveObjectWrapper + address: + EU: 0x22FDC88 + NA: 0x22FD2E8 + JP: 0x22FE960 + description: |- + Sets bits of the attribute bitfield of a currently loaded object. + + Is a wrapper around SetAttributeBitfieldLiveObject, meaning this calls SetAttributeBitfieldLiveObject with a first parameter of live_object::id. + + r0: live object + r1: attribute bitfield + - name: ResetAttributeBitfieldLiveObjectWrapper + address: + EU: 0x22FDC98 + NA: 0x22FD2F8 + JP: 0x22FE970 + description: |- + Clears bits of the attribute bitfield of a currently loaded object. + + Is a wrapper around ResetAttributeBitfieldLiveObject, meaning this calls ResetAttributeBitfieldLiveObject with a first parameter of live_object::id. + + r0: live object + r1: attribute bitfield + - name: SetBlinkLiveObject + address: + EU: 0x22FDCA8 + NA: 0x22FD308 + JP: 0x22FE980 + description: |- + Sets the object to blink in and out of sight at certain intervals. + + r0: live object + r1: frame interval for blinking in + r2: frame interval for blinking out + - name: SetPositionOffsetLiveObject + address: + EU: 0x22FDCB8 + NA: 0x22FD318 + JP: 0x22FE990 + description: |- + Offsets a currently loaded object's position. + + r0: live object + r1: pointer to an position offset vector - name: CreateTeamInfoBox address: EU: 0x22FF834