Decompile/port event_object_movement

This commit is contained in:
ultima-soul
2020-03-12 12:46:40 -07:00
parent 65690ca7dc
commit 339c2914af
46 changed files with 8790 additions and 23331 deletions
+7
View File
@@ -1,6 +1,13 @@
#ifndef GUARD_CONSTANTS_EVENT_OBJECTS_H
#define GUARD_CONSTANTS_EVENT_OBJECTS_H
#define NUM_OBJ_EVENT_GFX 239
// These are dynamic object gfx ids.
// They correspond with the values of the VAR_OBJ_GFX_ID_X vars.
// More info about them in include/constants/vars.h
#define OBJ_EVENT_GFX_VARS (NUM_OBJ_EVENT_GFX + 1)
#define OBJ_EVENT_ID_PLAYER 0xFF
#define OBJ_EVENT_ID_CAMERA 0x7F
+2 -2
View File
@@ -1,7 +1,7 @@
#ifndef GUARD_CONSTANTS_FIELD_EFFECTS_H
#define GUARD_CONSTANTS_FIELD_EFFECTS_H
#define FLDEFF_EXCLAMATION_MARK_ICON_1 0
#define FLDEFF_EXCLAMATION_MARK_ICON 0
#define FLDEFF_USE_CUT_ON_GRASS 1
#define FLDEFF_USE_CUT_ON_TREE 2
#define FLDEFF_SHADOW 3
@@ -34,7 +34,7 @@
#define FLDEFF_NPCFLY_OUT 30
#define FLDEFF_USE_FLY 31
#define FLDEFF_FLY_IN 32
#define FLDEFF_EXCLAMATION_MARK_ICON_2 33
#define FLDEFF_QUESTION_MARK_ICON 33
#define FLDEFF_FEET_IN_FLOWING_WATER 34
#define FLDEFF_BIKE_TIRE_TRACKS 35
#define FLDEFF_SAND_DISGUISE 36
+1
View File
@@ -31,6 +31,7 @@
#define BAG_POKEBALLS_COUNT 13
#define BAG_TMHM_COUNT 58
#define BAG_BERRIES_COUNT 43
#define OBJECT_EVENT_TEMPLATES_COUNT 64
#define QUEST_LOG_SCENE_COUNT 4
+13
View File
@@ -11,5 +11,18 @@ u32 sub_806916C(u8 a0);
void sub_80691A4(u8 a0, u8 a1);
void sub_8069094(u8 a0, u8 a1);
bool32 sub_8069294(u8 a0);
void sub_8068BBC(struct Sprite *, u8);
void sub_8068C58(struct Sprite *, u8);
void sub_8068C08(struct Sprite *, u8);
bool8 sub_8068C68(struct Sprite *sprite);
bool8 sub_8068C18(struct Sprite *sprite);
void sub_8068CA4(struct Sprite *, u8);
bool8 obj_npc_ministep(struct Sprite *sprite);
bool8 sub_8068CB4(struct Sprite *sprite);
void SetAndStartSpriteAnim(struct Sprite *, u8, u8);
bool8 SpriteAnimEnded(struct Sprite *);
void SetMovementDelay(struct Sprite *, s16);
bool8 WaitForMovementDelay(struct Sprite *);
void UpdateObjectEventSpriteSubpriorityAndVisibility(struct Sprite *);
#endif // GUARD_EVENT_OBJECT_80688E4_H
-2
View File
@@ -17,14 +17,12 @@ void sub_8097AC8(struct Sprite *);
void UnfreezeObjectEvent(struct ObjectEvent *);
void oamt_npc_ministep_reset(struct Sprite *, u8, u8);
u8 sub_8097F78(struct ObjectEvent *);
bool8 obj_npc_ministep(struct Sprite *sprite);
bool8 sub_80976EC(struct Sprite *sprite);
void sub_80976DC(struct Sprite *, u8);
void sub_809783C(struct Sprite *, u8, u8, u8);
void DoShadowFieldEffect(struct ObjectEvent *);
u8 sub_809785C(struct Sprite *);
u8 sub_80978E4(struct Sprite *);
void obj_anim_image_set_and_seek(struct Sprite *, u8, u8);
bool8 sub_80979BC(struct Sprite *);
void sub_8097750(struct Sprite *);
bool8 sub_8097758(struct Sprite *);
+55 -29
View File
@@ -22,6 +22,18 @@ enum SpinnerRunnerFollowPatterns {
RUNFOLLOW_SOUTH_EAST_WEST
};
struct UnkStruct_083A3698
{
const union AnimCmd *const *anims;
u8 animPos[4];
};
struct PairedPalettes
{
u16 tag;
const u16 *data;
};
// Exported RAM declarations
// Exported ROM declarations
@@ -30,74 +42,88 @@ void sub_808D438(void);
u8 GetObjectEventIdByLocalIdAndMap(u8, u8, u8);
bool8 TryGetObjectEventIdByLocalIdAndMap(u8, u8, u8, u8 *);
u8 GetObjectEventIdByXY(s16, s16);
void ObjectEventSetDirection(struct ObjectEvent *, u8);
void SetObjectEventDirection(struct ObjectEvent *, u8);
u8 sub_808D4F4(void);
void RemoveObjectEventByLocalIdAndMap(u8, u8, u8);
void npc_load_two_palettes__no_record(u16, u8);
void npc_load_two_palettes__and_record(u16, u8);
void sub_805F7C4(u8, u8, u8, s16, s16);
void pal_patch_for_npc(u16, u8);
void LoadPlayerObjectReflectionPalette(u16, u8);
void LoadSpecialObjectReflectionPalette(u16, u8);
void TryMoveObjectEventToMapCoords(u8, u8, u8, s16, s16);
void PatchObjectPalette(u16, u8);
void sub_808E16C(s16, s16);
void sub_808F28C(u8 localId, u8 mapNum, u8 mapGroup, u8 decorCat);
void sub_8092FF0(s16, s16, s16 *, s16 *);
u8 ObjectEventDirectionToImageAnimId(u8);
void sub_80930E0(s16 *, s16 *, s16, s16);
void ObjectEventClearAnim(struct ObjectEvent *);
void ObjectEventClearAnimIfSpecialAnimActive(struct ObjectEvent *);
void sub_8063AD4(s16, s16, s16 *, s16 *);
u8 GetFaceDirectionAnimNum(u8);
void sub_8063BC4(s16 *, s16 *, s16, s16);
void ObjectEventClearHeldMovement(struct ObjectEvent *);
void ObjectEventClearHeldMovementIfActive(struct ObjectEvent *);
void SpawnObjectEventsInView(s16, s16);
u8 sprite_new(u8, u8, s16, s16, u8, u8);
u8 AddPseudoObjectEvent(u16, SpriteCallback, s16, s16, u8);
u8 TrySpawnObjectEvent(u8 localId, u8 mapNum, u8 mapGroup);
u8 SpawnSpecialObjectEventParameterized(u8, u8, u8, s16, s16, u8);
u8 SpawnSpecialObjectEvent(struct ObjectEventTemplate *);
void sub_8093038(s16, s16, s16 *, s16 *);
void SetSpritePosToMapCoords(s16, s16, s16 *, s16 *);
void CameraObjectReset1(void);
void CameraObjectReset2(void);
void ObjectEventSetGraphicsId(struct ObjectEvent *, u8);
void ObjectEventTurn(struct ObjectEvent *, u8);
void ObjectEventTurnByLocalIdAndMap(u8, u8, u8, u8);
void ObjectEventForceSetSpecialAnim(struct ObjectEvent *, u8);
u8 sub_8064270(u8 a0);
void ObjectEventForceSetHeldMovement(struct ObjectEvent *, u8);
const struct ObjectEventGraphicsInfo *GetObjectEventGraphicsInfo(u8);
void npc_by_local_id_and_map_set_field_1_bit_x20(u8, u8, u8, u8);
void gpu_pal_allocator_reset__manage_upper_four(void);
void FreeAndReserveObjectSpritePalettes(void);
void sub_808E82C(u8, u8, u8, s16, s16);
void sub_805F400(u8, u8, u8);
void sub_805F3A8(u8, u8, u8, u8);
void sub_808E75C(s16, s16);
void ObjectEventGetLocalIdAndMap(struct ObjectEvent *, u8 *, u8 *, u8 *);
void npc_coords_shift(struct ObjectEvent *, s16, s16);
void ObjectEventGetLocalIdAndMap(struct ObjectEvent *objectEvent, void *localId, void *mapNum, void *mapGroup);
void ShiftObjectEventCoords(struct ObjectEvent *, s16, s16);
void sub_808EB08(struct ObjectEvent *, s16, s16);
void sub_805FE94(u8, u8, u8);
void ObjectEventStep(struct ObjectEvent *, struct Sprite *, bool8(struct ObjectEvent *, struct Sprite *));
void TryOverrideObjectEventTemplateCoords(u8, u8, u8);
void UpdateObjectEventCurrentMovement(struct ObjectEvent *, struct Sprite *, bool8(struct ObjectEvent *, struct Sprite *));
u8 ObjectEventFaceOppositeDirection(struct ObjectEvent *, u8);
u8 GetOppositeDirection(u8);
u8 GetStepInPlaceDelay4AnimId(u32);
u8 GetWalkInPlaceFastMovementAction(u32);
u8 GetStepInPlaceDelay8AnimId(u32);
u8 GetStepInPlaceDelay16AnimId(u32);
u8 GetWalkInPlaceNormalMovementAction(u32);
u8 GetWalkInPlaceSlowMovementAction(u32);
u8 GetStepInPlaceDelay32AnimId(u32);
u8 npc_block_way(struct ObjectEvent *, s16, s16, u32);
u8 GetCollisionAtCoords(struct ObjectEvent *, s16, s16, u32);
void MoveCoords(u8, s16 *, s16 *);
bool8 ObjectEventIsSpecialAnimActive(struct ObjectEvent *);
bool8 ObjectEventIsHeldMovementActive(struct ObjectEvent *);
u8 ObjectEventClearHeldMovementIfFinished(struct ObjectEvent *);
u8 GetObjectEventIdByXYZ(u16 x, u16 y, u8 z);
void sub_8063E28(struct ObjectEvent *, struct Sprite *);
bool8 ObjectEventSetHeldMovement(struct ObjectEvent *, u8);
void npc_coords_shift_still(struct ObjectEvent *);
void sub_805FE7C(struct ObjectEvent *, u8);
void ShiftStillObjectEventCoords(struct ObjectEvent *);
void OverrideMovementTypeForObjectEvent(const struct ObjectEvent *, u8);
void SetTrainerMovementType(struct ObjectEvent *, u8);
u8 sub_80634F0(u8 direction);
u8 sub_8063500(u8 a0);
u8 GetFishingNoCatchDirectionAnimNum(u8 direction);
u8 GetFishingBiteDirectionAnimNum(u8 a0);
void ObjectEventSetGraphicsId(struct ObjectEvent *objectEvent, u8 a1);
u8 sub_805EB44(u8, u8, s16, s16);
void npc_paltag_set_load(u8 mode);
void InitObjectEventPalettes(u8 mode);
bool8 ObjectEventIsMovementOverridden(struct ObjectEvent *objectEvent);
u8 ObjectEventCheckHeldMovementStatus(struct ObjectEvent *objectEvent);
u8 sub_8063F84(u8 direction);
u8 GetWalkNormalMovementAction(u32);
u8 GetWalkFastMovementAction(u32);
u8 GetWalkFastestMovementAction(u32);
u8 sub_8063F2C(u32 direction);
u8 GetTrainerFacingDirectionMovementType(u8 direction);
void CameraObjectSetFollowedObjectId(u8 spriteId);
u8 GetFaceDirectionMovementAction(u32);
void CameraObjectSetFollowedObjectId(u8 objectId);
void UnfreezeObjectEvents(void);
void sub_8069058(u8, u8);
void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8);
u8 GetSlideMovementAction(u32);
u8 GetJumpInPlaceMovementAction(u32);
u8 GetJumpMovementAction(u32);
u8 GetJump2MovementAction(u32);
bool8 sub_8068BCC(struct Sprite *sprite);
void sub_8068D1C(struct Sprite *, u8, u8, u8);
u8 sub_8068D3C(struct Sprite *);
u8 sub_8068DC4(struct Sprite *);
// Exported data declarations
+3 -4
View File
@@ -15,12 +15,11 @@ struct CameraObject
s32 y;
};
extern struct CameraObject gUnknown_03005DD0;
// Exported RAM declarations
extern u16 gUnknown_03005DEC;
extern u16 gUnknown_03005DE8;
extern struct CameraObject gFieldCamera;
extern u16 gTotalCameraPixelOffsetX;
extern u16 gTotalCameraPixelOffsetY;
// Exported ROM declarations
+1
View File
@@ -8,5 +8,6 @@ extern u32 gUnknown_3005078;
void RestartWildEncounterImmunitySteps(void);
void ClearPoisonStepCounter(void);
void SetCableClubWarp(void);
void sub_806DE28(struct ObjectEvent *);
#endif //GUARD_FIELD_CONTROL_AVATAR_H
+3 -2
View File
@@ -12,9 +12,10 @@
// Exported RAM declarations
// Exported ROM declarations
u8 sub_8154228(void);
bool8 sub_8155DA0(struct ObjectEvent *);
u8 CreateWarpArrowSprite(void);
void sub_80DC44C(u8, u8);
void StartAshFieldEffect(s16, s16, u16, s16);
void sub_80DCBB8(struct ObjectEvent *);
bool8 sub_80DCBE0(struct ObjectEvent *);
#endif //GUARD_FIELD_EFFECT_HELPERS_H
+2 -2
View File
@@ -9,8 +9,8 @@ u8 GetPlayerAvatarGenderByGraphicsId(u8);
bool8 TestPlayerAvatarFlags(u8);
void PlayerGetDestCoords(s16 *, s16 *);
u8 GetPlayerFacingDirection(void);
u8 player_get_direction_upper_nybble(void);
u8 player_get_x22(void);
u8 GetPlayerMovementDirection(void);
u8 PlayerGetCopyableMovement(void);
void sub_808D074(u8);
void sub_805C270(void);
+1 -1
View File
@@ -11,7 +11,7 @@
#define NUM_PALS_TOTAL 13
#define VIRTUAL_MAP_SIZE 0x2800
extern struct BackupMapLayout VMap;
extern struct BackupMapLayout gBackupMapLayout;
extern const struct MapLayout Route1_Layout;
u32 MapGridGetMetatileIdAt(int, int);
+65 -44
View File
@@ -169,61 +169,61 @@ struct MapHeader
struct ObjectEvent
{
/*0x00*/ u32 active:1;
u32 mapobj_bit_1:1;
u32 mapobj_bit_2:1;
u32 mapobj_bit_3:1;
u32 mapobj_bit_4:1;
u32 mapobj_bit_5:1;
u32 mapobj_bit_6:1;
u32 mapobj_bit_7:1;
/*0x01*/ u32 mapobj_bit_8:1;
u32 mapobj_bit_9:1;
u32 mapobj_bit_10:1;
u32 mapobj_bit_11:1;
u32 mapobj_bit_12:1;
u32 mapobj_bit_13:1;
u32 mapobj_bit_14:1;
u32 mapobj_bit_15:1;
/*0x02*/ u32 mapobj_bit_16:1;
u32 mapobj_bit_17:1;
u32 mapobj_bit_18:1;
u32 mapobj_bit_19:1;
u32 mapobj_bit_20:1;
u32 mapobj_bit_21:1;
u32 mapobj_bit_22:1;
u32 mapobj_bit_23:1;
/*0x03*/ u32 mapobj_bit_24:1;
u32 mapobj_bit_25:1;
u32 mapobj_bit_26:1;
u32 mapobj_bit_27:1;
u32 singleMovementActive:1;
u32 triggerGroundEffectsOnMove:1;
u32 triggerGroundEffectsOnStop:1;
u32 disableCoveringGroundEffects:1;
u32 landingJump:1;
u32 heldMovementActive:1;
u32 heldMovementFinished:1;
/*0x01*/ u32 frozen:1;
u32 facingDirectionLocked:1;
u32 disableAnim:1;
u32 enableAnim:1;
u32 inanimate:1;
u32 invisible:1;
u32 offScreen:1;
u32 trackedByCamera:1;
/*0x02*/ u32 isPlayer:1;
u32 hasReflection:1;
u32 inShortGrass:1;
u32 inShallowFlowingWater:1;
u32 inSandPile:1;
u32 inHotSprings:1;
u32 hasShadow:1;
u32 spriteAnimPausedBackup:1;
/*0x03*/ u32 spriteAffineAnimPausedBackup:1;
u32 disableJumpLandingGroundEffect:1;
u32 fixedPriority:1;
u32 hideReflection:1;
u32 mapobj_bit_28:1;
u32 mapobj_bit_29:1;
u32 mapobj_bit_30:1;
u32 mapobj_bit_31:1;
/*0x04*/ u8 spriteId;
/*0x05*/ u8 graphicsId;
/*0x06*/ u8 animPattern;
/*0x06*/ u8 movementType;
/*0x07*/ u8 trainerType;
/*0x08*/ u8 localId;
/*0x09*/ u8 mapNum;
/*0x0A*/ u8 mapGroup;
/*0x0B*/ u8 mapobj_unk_0B_0:4;
u8 elevation:4;
/*0x0C*/ struct Coords16 coords1;
/*0x10*/ struct Coords16 coords2;
/*0x14*/ struct Coords16 coords3;
/*0x18*/ u8 facingDirection:4; //current direction?
/*0x18*/ u8 placeholder18:4;
/*0x0B*/ u8 currentElevation:4;
u8 previousElevation:4;
/*0x0C*/ struct Coords16 initialCoords;
/*0x10*/ struct Coords16 currentCoords;
/*0x14*/ struct Coords16 previousCoords;
/*0x18*/ u8 facingDirection:4; // current direction?
/*0x18*/ u8 movementDirection:4;
/*0x19*/ union ObjectEventRange range;
/*0x1A*/ u8 mapobj_unk_1A;
/*0x1B*/ u8 mapobj_unk_1B;
/*0x1C*/ u8 mapobj_unk_1C;
/*0x1A*/ u8 fieldEffectSpriteId;
/*0x1B*/ u8 warpArrowSpriteId;
/*0x1C*/ u8 movementActionId;
/*0x1D*/ u8 trainerRange_berryTreeId;
/*0x1E*/ u8 mapobj_unk_1E;
/*0x1F*/ u8 mapobj_unk_1F;
/*0x20*/ u8 mapobj_unk_20;
/*0x21*/ u8 mapobj_unk_21;
/*0x22*/ u8 animId;
/*0x1E*/ u8 currentMetatileBehavior;
/*0x1F*/ u8 previousMetatileBehavior;
/*0x20*/ u8 previousMovementDirection;
/*0x21*/ u8 directionSequenceIndex;
/*0x22*/ u8 playerCopyableMovement;
/*size = 0x24*/
};
@@ -269,7 +269,28 @@ enum
enum
{
COLLISION_LEDGE_JUMP = 6
COLLISION_NONE,
COLLISION_OUTSIDE_RANGE,
COLLISION_IMPASSABLE,
COLLISION_ELEVATION_MISMATCH,
COLLISION_OBJECT_EVENT,
COLLISION_STOP_SURFING,
COLLISION_LEDGE_JUMP,
COLLISION_PUSHED_BOULDER,
COLLISION_ROTATING_GATE,
COLLISION_WHEELIE_HOP,
COLLISION_ISOLATED_VERTICAL_RAIL,
COLLISION_ISOLATED_HORIZONTAL_RAIL,
COLLISION_VERTICAL_RAIL,
COLLISION_HORIZONTAL_RAIL,
};
// player tile transition states
enum
{
T_NOT_MOVING,
T_TILE_TRANSITION,
T_TILE_CENTER, // player is on a frame in which they are centered on a tile during which the player either stops or keeps their momentum and keeps going, changing direction if necessary.
};
struct PlayerAvatar /* 0x202E858 */
+1 -1
View File
@@ -8,7 +8,7 @@ bool8 MetatileBehavior_IsJumpEast(u8 metatileBehavior);
bool8 MetatileBehavior_IsJumpWest(u8 metatileBehavior);
bool8 MetatileBehavior_IsJumpNorth(u8 metatileBehavior);
bool8 MetatileBehavior_IsJumpSouth(u8 metatileBehavior);
bool8 MetatileBehavior_IsTallGrass(u8 metatileBehavior);
bool8 MetatileBehavior_IsPokeGrass(u8 metatileBehavior);
bool8 MetatileBehavior_IsMB21OrSand(u8 metatileBehavior);
bool8 MetatileBehavior_IsSandOrDeepSand(u8 metatileBehavior);
bool8 MetatileBehavior_ReturnFalse(u8 metatileBehavior);
+3 -2
View File
@@ -37,7 +37,7 @@ struct LinkPlayerObjectEvent
{
u8 active;
u8 linkPlayerId;
u8 mapObjId;
u8 objEventId;
u8 mode;
};
@@ -95,7 +95,7 @@ void Overworld_ChangeMusicTo(u16);
bool32 IsUpdateLinkStateCBActive(void);
void strange_npc_table_clear(void);
void ClearLinkPlayerObjectEvents(void);
const struct MapHeader *Overworld_GetMapHeaderByGroupAndId(u16, u16);
void ObjectEventMoveDestCoords(struct ObjectEvent *, u32, s16 *, s16 *);
void sub_8086230(void);
@@ -141,6 +141,7 @@ void sub_8055864(u8 mapGroup, u8 mapNum);
void CB2_Overworld(void);
void CB2_OverworldBasic(void);
void CB2_NewGame(void);
bool8 IsMapTypeOutdoors(u8 mapType);
bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType);
void Overworld_ResetStateAfterTeleport(void);
+2
View File
@@ -49,5 +49,7 @@ void *QuestLogGetFlagOrVarPtr(bool8 isFlag, u16 idx);
void QuestLogSetFlagOrVar(bool8 isFlag, u16 idx, u16 value);
void sub_8110840(void *oldSave);
void sub_8112F18(u8 windowId);
void sub_811246C(struct Sprite *sprite);
void sub_81124EC(u8 a0, u8 a1, u8 a2, u8 a3);
#endif //GUARD_QUEST_LOG_H
+2
View File
@@ -316,5 +316,7 @@ u8 SpriteTileAllocBitmapOp(u16 bit, u8 op);
void ClearSpriteCopyRequests(void);
void ResetAffineAnimData(void);
void sub_8007FFC(struct Sprite* sprite, s16 a2, s16 a3);
void sub_80075C0(struct Sprite *sprite);
s16 AllocSpriteTiles(u16 tileCount);
#endif //GUARD_SPRITE_H
+1 -2
View File
@@ -3,8 +3,7 @@
#include "global.h"
void sub_80B4578(struct ObjectEvent *);
u8 sub_80B47BC(void);
void sub_8155D78(struct ObjectEvent *);
void sub_80824EC(struct ObjectEvent *var);
#endif //GUARD_TRAINER_SEE_H