Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@

#include "z64.h"

Actor* Item_DropCollectible(PlayState* play, Vec3f* spawnPos, u32 params);
Actor* Item_DropCollectible2(PlayState* play, Vec3f* spawnPos, s32 params);
void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnPos, s16 params);
s32 func_800A8150(s32 index);
s32 func_800A817C(s32 index);
bool Item_CanDropBigFairy(PlayState* play, s32 index, s32 collectibleFlag);

// Ideally these two prototypes would be in z64actor.h, but they use PlayerItemAction which would require including z64player.h there.
s32 Actor_OfferTalkExchange(Actor* actor, struct PlayState* play, f32 xzRange, f32 yRange, PlayerItemAction exchangeItemAction);
s32 Actor_OfferTalkExchangeEquiCylinder(Actor* actor, struct PlayState* play, f32 radius, PlayerItemAction exchangeItemAction);
Expand Down
82 changes: 3 additions & 79 deletions include/z64actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ typedef struct {
#define BGCHECKFLAG_GROUND_STRICT (1 << 7) // Similar to BGCHECKFLAG_GROUND but with no velocity check and is cleared every frame
#define BGCHECKFLAG_CRUSHED (1 << 8) // Crushed between a floor and ceiling (triggers a void for player)
#define BGCHECKFLAG_PLAYER_WALL_INTERACT (1 << 9) // Only set/used by player, related to interacting with walls
#define BGCHECKFLAG_PLAYER_400 (1 << 10) //
#define BGCHECKFLAG_PLAYER_800 (1 << 11) //
#define BGCHECKFLAG_PLAYER_1000 (1 << 12) //
#define BGCHECKFLAG_PLAYER_400 (1 << 10) //
#define BGCHECKFLAG_PLAYER_800 (1 << 11) //
#define BGCHECKFLAG_PLAYER_1000 (1 << 12) //

// Flags for Actor_UpdateBgCheckInfo
#define UPDBGCHECKINFO_FLAG_1 (1 << 0) // check wall
Expand Down Expand Up @@ -179,82 +179,6 @@ typedef struct DynaPolyActor {
/* 0x158 */ u8 interactFlags;
} DynaPolyActor; // size = 0x15C

typedef enum Item00Type {
/* 0x00 */ ITEM00_RUPEE_GREEN,
/* 0x01 */ ITEM00_RUPEE_BLUE,
/* 0x02 */ ITEM00_RUPEE_RED,
/* 0x03 */ ITEM00_RECOVERY_HEART,
/* 0x04 */ ITEM00_BOMBS_A,
/* 0x05 */ ITEM00_ARROWS_10,
/* 0x06 */ ITEM00_HEART_PIECE,
/* 0x07 */ ITEM00_HEART_CONTAINER,
/* 0x08 */ ITEM00_ARROWS_30,
/* 0x09 */ ITEM00_ARROWS_40,
/* 0x0A */ ITEM00_ARROWS_50,
/* 0x0B */ ITEM00_BOMBS_B,
/* 0x0C */ ITEM00_DEKU_NUTS_1,
/* 0x0D */ ITEM00_DEKU_STICK,
/* 0x0E */ ITEM00_MAGIC_JAR_BIG,
/* 0x0F */ ITEM00_MAGIC_JAR_SMALL,
/* 0x10 */ ITEM00_MASK,
/* 0x11 */ ITEM00_SMALL_KEY,
/* 0x12 */ ITEM00_FLEXIBLE,
/* 0x13 */ ITEM00_RUPEE_HUGE,
/* 0x14 */ ITEM00_RUPEE_PURPLE,
/* 0x15 */ ITEM00_3_HEARTS,
/* 0x16 */ ITEM00_SHIELD_HERO,
/* 0x17 */ ITEM00_DEKU_NUTS_10,
/* 0x18 */ ITEM00_NOTHING,
/* 0x19 */ ITEM00_BOMBS_0,
/* 0x1A */ ITEM00_BIG_FAIRY,
/* 0x1B */ ITEM00_MAP,
/* 0x1C */ ITEM00_COMPASS,
/* 0x1D */ ITEM00_MUSHROOM_CLOUD,

/* 0xFF */ ITEM00_NO_DROP = -1
} Item00Type;

struct EnItem00;

typedef void (*EnItem00ActionFunc)(struct EnItem00*, struct PlayState*);

#define ENITEM00_GET_8000(thisx) ((thisx)->params & 0x8000)
#define ENITEM00_GET_7F00(thisx) (((thisx)->params & 0x7F00) >> 8)

typedef struct EnItem00 {
/* 0x000 */ Actor actor;
/* 0x144 */ EnItem00ActionFunc actionFunc;
/* 0x148 */ s16 collectibleFlag;
/* 0x14A */ s16 getItemId;
/* 0x14C */ s16 unk14C;
/* 0x14E */ s16 unk14E;
/* 0x150 */ s16 unk150;
/* 0x152 */ s16 unk152;
/* 0x154 */ f32 unk154;
/* 0x158 */ ColliderCylinder collider;
/* 0x1A4 */ s8 unk1A4;
} EnItem00; // size = 0x1A8

struct EnAObj;

typedef void (*EnAObjActionFunc)(struct EnAObj*, struct PlayState*);

typedef struct EnAObj {
/* 0x000 */ Actor actor;
/* 0x144 */ EnAObjActionFunc actionFunc;
/* 0x148 */ ColliderCylinder collision;
} EnAObj; // size = 0x194

typedef enum {
/* 0 */ AOBJ_SIGNPOST_OBLONG,
/* 1 */ AOBJ_SIGNPOST_ARROW
} AObjType;

#define AOBJ_GET_TEXTID(thisx) ((((thisx)->params >> 8) & 0xFF) | 0x300)
#define AOBJ_GET_TYPE(thisx) (((thisx)->params & 0xFF) - 9)

#define AOBJ_PARAMS(textId, type) ((((textId - 0x300) & 0xFF) << 8) | (type + 9))

typedef enum {
/* 0x00 */ ACTORCAT_SWITCH,
/* 0x01 */ ACTORCAT_BG,
Expand Down
14 changes: 8 additions & 6 deletions include/z64horse.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
#define Z64_HORSE_H

#include "ultra64.h"
#include "z64.h"

struct ActorContext;
struct Player;
struct PlayState;

s32 Horse_GetJumpingFencePathIndex(PlayState* play);
s32 Horse_CopyPointFromPathList(PlayState* play, s32 pathIndex, s32 pointIndex, Vec3s* dst, s16* arg4);
s32 Horse_GetJumpingFencePathIndex(struct PlayState* play);
s32 Horse_CopyPointFromPathList(struct PlayState* play, s32 pathIndex, s32 pointIndex, Vec3s* dst, s16* arg4);
s32 Horse_IsValidSpawn(s16 sceneId);
void Horse_ResetHorseData(PlayState* play);
void Horse_Spawn(PlayState* play, Player* player);
void Horse_ResetHorseData(struct PlayState* play);
void Horse_Spawn(struct PlayState* play, struct Player* player);
void Horse_RotateToPoint(Actor* actor, Vec3f* pos, s16 turnYaw);
s32 Horse_IsActive(PlayState* play, ActorContext* actorCtx);
s32 Horse_IsActive(struct PlayState* play, struct ActorContext* actorCtx);


extern s32 gHorseIsMounted;
Expand Down
2 changes: 1 addition & 1 deletion include/z64scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ typedef enum {
#define SCENE_CMD_MINIMAP_INFO SCENE_CMD_MAP_DATA
#define SCENE_CMD_MINIMAP_COMPASS_ICON_INFO SCENE_CMD_MAP_DATA_CHESTS

void Scene_ResetTransitionActorList(GameState* gameState, TransitionActorList* transitionActors);
void Scene_ResetTransitionActorList(struct GameState* gameState, TransitionActorList* transitionActors);
void Scene_SetExitFade(struct PlayState* play);
s32 Scene_ExecuteCommands(struct PlayState* play, SceneCmd* sceneCmd);
u16 Entrance_Create(s32 scene, s32 spawn, s32 layer);
Expand Down
26 changes: 26 additions & 0 deletions include/z_en_a_obj.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef Z_EN_A_OBJ_H
#define Z_EN_A_OBJ_H

#include "z64actor.h"

typedef enum {
/* 0 */ AOBJ_SIGNPOST_OBLONG,
/* 1 */ AOBJ_SIGNPOST_ARROW
} AObjType;

struct EnAObj;

typedef void (*EnAObjActionFunc)(struct EnAObj*, struct PlayState*);

typedef struct EnAObj {
/* 0x000 */ Actor actor;
/* 0x144 */ EnAObjActionFunc actionFunc;
/* 0x148 */ ColliderCylinder collision;
} EnAObj; // size = 0x194

#define AOBJ_GET_TEXTID(thisx) ((((thisx)->params >> 8) & 0xFF) | 0x300)
#define AOBJ_GET_TYPE(thisx) (((thisx)->params & 0xFF) - 9)

#define AOBJ_PARAMS(textId, type) ((((textId - 0x300) & 0xFF) << 8) | (type + 9))

#endif
34 changes: 18 additions & 16 deletions include/z_en_hy_code.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#ifndef Z64ENHY_CODE_H
#define Z64ENHY_CODE_H

#include "global.h"
#include "overlays/actors/ovl_En_Door/z_en_door.h"
#include "z64actor.h"

struct EnDoor;
struct EnHy;
struct Path;
struct PlayState;

//! @note: any actor that uses the EnHy system should
//! @note: any actor that uses the EnHy system should
//! have a skeleton that aligns with the enum below.
typedef enum EnHyLimb {
/* 0x00 */ ENHY_LIMB_NONE,
Expand Down Expand Up @@ -55,7 +57,7 @@ typedef enum {
/* 21 */ ENHY_ANIM_MAX
} EnHyAnimation;

typedef void (*EnHyActionFunc)(struct EnHy*, PlayState*);
typedef void (*EnHyActionFunc)(struct EnHy*, struct PlayState*);

typedef enum EnHyBodyPart {
/* 0 */ ENHY_BODYPART_0,
Expand Down Expand Up @@ -89,7 +91,7 @@ typedef struct EnHy {
/* 0x1E0 */ u16 textId;
/* 0x1E2 */ u8 waitingOnInit;
/* 0x1E3 */ u8 msgFading;
/* 0x1E4 */ Path* path;
/* 0x1E4 */ struct Path* path;
/* 0x1E8 */ s16 curPoint;
/* 0x1EC */ Vec3f leftFootPos;
/* 0x1F8 */ Vec3f rightFootPos;
Expand All @@ -116,19 +118,19 @@ extern s8 gEnHyParentShadowBodyParts[];
extern u8 gEnHyShadowSizes[];

s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex);
EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play);
void EnHy_ChangeObjectAndAnim(EnHy* enHy, PlayState* play, s16 animIndex);
s32 EnHy_UpdateSkelAnime(EnHy* enHy, PlayState* play);
struct EnDoor* EnHy_FindNearestDoor(Actor* actor, struct PlayState* play);
void EnHy_ChangeObjectAndAnim(EnHy* enHy, struct PlayState* play, s16 animIndex);
s32 EnHy_UpdateSkelAnime(EnHy* enHy, struct PlayState* play);
void EnHy_Blink(EnHy* enHy, s32 eyeTexMaxIndex);
s32 EnHy_Init(EnHy* enHy, PlayState* play, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex);
void func_800F0BB4(EnHy* enHy, PlayState* play, EnDoor* door, s16 arg3, s16 arg4);
s32 func_800F0CE4(EnHy* enHy, PlayState* play, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5);
s32 func_800F0DD4(EnHy* enHy, PlayState* play, s16 arg2, s16 arg3);
s32 EnHy_SetPointFowards(EnHy* enHy, PlayState* play, f32 gravity, s16 animIndex);
s32 EnHy_SetPointBackwards(EnHy* enHy, PlayState* play, s16 animIndex);
s32 EnHy_Init(EnHy* enHy, struct PlayState* play, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex);
void func_800F0BB4(EnHy* enHy, struct PlayState* play, struct EnDoor* door, s16 arg3, s16 arg4);
s32 func_800F0CE4(EnHy* enHy, struct PlayState* play, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5);
s32 func_800F0DD4(EnHy* enHy, struct PlayState* play, s16 arg2, s16 arg3);
s32 EnHy_SetPointFowards(EnHy* enHy, struct PlayState* play, f32 gravity, s16 animIndex);
s32 EnHy_SetPointBackwards(EnHy* enHy, struct PlayState* play, s16 animIndex);
s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget);
s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget);
void EnHy_UpdateCollider(EnHy* enHy, PlayState* play);
s32 EnHy_PlayWalkingSound(EnHy* enHy, PlayState* play, f32 distAboveThreshold);
void EnHy_UpdateCollider(EnHy* enHy, struct PlayState* play);
s32 EnHy_PlayWalkingSound(EnHy* enHy, struct PlayState* play, f32 distAboveThreshold);

#endif // Z_EN_HY_CODE_H
71 changes: 71 additions & 0 deletions include/z_en_item00.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#ifndef Z_EN_ITEM00_H
#define Z_EN_ITEM00_H

#include "ultra64.h"
#include "z64actor.h"

typedef enum Item00Type {
/* 0x00 */ ITEM00_RUPEE_GREEN,
/* 0x01 */ ITEM00_RUPEE_BLUE,
/* 0x02 */ ITEM00_RUPEE_RED,
/* 0x03 */ ITEM00_RECOVERY_HEART,
/* 0x04 */ ITEM00_BOMBS_A,
/* 0x05 */ ITEM00_ARROWS_10,
/* 0x06 */ ITEM00_HEART_PIECE,
/* 0x07 */ ITEM00_HEART_CONTAINER,
/* 0x08 */ ITEM00_ARROWS_30,
/* 0x09 */ ITEM00_ARROWS_40,
/* 0x0A */ ITEM00_ARROWS_50,
/* 0x0B */ ITEM00_BOMBS_B,
/* 0x0C */ ITEM00_DEKU_NUTS_1,
/* 0x0D */ ITEM00_DEKU_STICK,
/* 0x0E */ ITEM00_MAGIC_JAR_BIG,
/* 0x0F */ ITEM00_MAGIC_JAR_SMALL,
/* 0x10 */ ITEM00_MASK,
/* 0x11 */ ITEM00_SMALL_KEY,
/* 0x12 */ ITEM00_FLEXIBLE,
/* 0x13 */ ITEM00_RUPEE_HUGE,
/* 0x14 */ ITEM00_RUPEE_PURPLE,
/* 0x15 */ ITEM00_3_HEARTS,
/* 0x16 */ ITEM00_SHIELD_HERO,
/* 0x17 */ ITEM00_DEKU_NUTS_10,
/* 0x18 */ ITEM00_NOTHING,
/* 0x19 */ ITEM00_BOMBS_0,
/* 0x1A */ ITEM00_BIG_FAIRY,
/* 0x1B */ ITEM00_MAP,
/* 0x1C */ ITEM00_COMPASS,
/* 0x1D */ ITEM00_MUSHROOM_CLOUD,

/* 0xFF */ ITEM00_NO_DROP = -1
} Item00Type;

struct EnItem00;
struct PlayState;

typedef void (*EnItem00ActionFunc)(struct EnItem00*, struct PlayState*);

#define ENITEM00_GET_8000(thisx) ((thisx)->params & 0x8000)
#define ENITEM00_GET_7F00(thisx) (((thisx)->params & 0x7F00) >> 8)

typedef struct EnItem00 {
/* 0x000 */ Actor actor;
/* 0x144 */ EnItem00ActionFunc actionFunc;
/* 0x148 */ s16 collectibleFlag;
/* 0x14A */ s16 getItemId;
/* 0x14C */ s16 unk14C;
/* 0x14E */ s16 unk14E;
/* 0x150 */ s16 unk150;
/* 0x152 */ s16 unk152;
/* 0x154 */ f32 unk154;
/* 0x158 */ ColliderCylinder collider;
/* 0x1A4 */ s8 unk1A4;
} EnItem00; // size = 0x1A8

Actor* Item_DropCollectible(struct PlayState* play, Vec3f* spawnPos, u32 params);
Actor* Item_DropCollectible2(struct PlayState* play, Vec3f* spawnPos, s32 params);
void Item_DropCollectibleRandom(struct PlayState* play, Actor* fromActor, Vec3f* spawnPos, s16 params);
s32 func_800A8150(s32 index);
s32 func_800A817C(s32 index);
bool Item_CanDropBigFairy(struct PlayState* play, s32 index, s32 collectibleFlag);

#endif
8 changes: 8 additions & 0 deletions src/code/z_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ static s16 sBssPad;
u8 gDisablePlayerCsActionStartPos;
s16 gDungeonBossWarpSceneId;

#include "macros.h"
#include "regs.h"
#include "seqcmd.h"
#include "sequence.h"
#include "sfx.h"
#include "z64lib.h"
#include "z64ocarina.h"
#include "z64play.h"
#include "z64quake.h"
#include "z64rumble.h"
#include "z64shrink_window.h"
Expand Down
5 changes: 5 additions & 0 deletions src/code/z_en_a_keep.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#include "z_en_a_obj.h"
#include "gfx.h"
#include "ichain.h"
#include "z64play.h"

#include "global.h"
#include "assets/objects/gameplay_keep/gameplay_keep.h"

Expand Down
7 changes: 7 additions & 0 deletions src/code/z_en_hy_code.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

#include "z_en_hy_code.h"
#include "overlays/actors/ovl_En_Door/z_en_door.h"

#include "segmented_address.h"
#include "sfx.h"
#include "macros.h"
#include "z64play.h"
#include "z64subs.h"

#include "assets/objects/object_aob/object_aob.h"
#include "assets/objects/object_bba/object_bba.h"
#include "assets/objects/object_bji/object_bji.h"
Expand Down
21 changes: 17 additions & 4 deletions src/code/z_en_item00.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
#include "global.h"
#include "attributes.h"
#include "z_en_item00.h"
#include "overlays/actors/ovl_En_Elf/z_en_elf.h"
#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h"

#include "libc64/qrand.h"
Comment on lines +1 to +5

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move those overlays includes to the bottom instead?

Overall the include order and grouping we have been following is more or less the following:

Current file header

[Libraries] (ultralib.h, libc, libc64.h, libu64.h, attributes.h, etc)

["Game engine" headers] (gfx.h, gamealloc.h, sys*.h, z64*.h, etc)

[Other overlays]

[Objects]

Could you adjust your PR to follow this order?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk the more I do this the more convinced I am at just sorting everything by folder, alphabetical order. Why is attributes.h a "libraries" header? Are there more "libraries" headers hiding in the include folder?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that's not how we have been sorting includes, and neither is how we intend to do it, so please change them. For example z64.h is more or less sorted this way.

attributes.h is kinda a "libraries" header because it doesn't really fit any other category

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please sort them as we have been. Personally I like them sorted like this as it allows me to more easily find headers by knowing what category they are in (especially the current file header as first since that will generally be the first header I would like to see when looking at a new file).

I will say I'm not sure I agree attributes.h would be a library include. I get where that is coming from, but since it is just in the base include folder I would just say its a "game engine" header.

#include "attributes.h"
#include "gfx.h"
#include "gfx_setupdl.h"
#include "ichain.h"
#include "macros.h"
#include "rand.h"
#include "sfx.h"
#include "sys_matrix.h"
#include "z64effect.h"
#include "z64lib.h"
#include "z64play.h"

#include "global.h"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels kinda dumb adding all those individual headers and then add global.h too.
Why not just leave alone those files that import gameplay_keep.h up until we have the new assets system?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i explain why it's not dumb in another comment.

As for the question, it's mainly just that I started to take the same approach to removing global.h as I did with OoT, and realizing a bit late that gameplay_keep.h has more specialized dependencies than in OoT. I can try to avoid it in future PRs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the work is already done, I would kind of say just leave it for now. It does make sense for future PRs though to wait.

#include "assets/objects/gameplay_keep/gameplay_keep.h"
#include "assets/objects/object_gi_hearts/object_gi_hearts.h"
#include "overlays/actors/ovl_En_Elf/z_en_elf.h"
#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h"

#define FLAGS 0x00000000

Expand Down
7 changes: 7 additions & 0 deletions src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

#include "z_bg_danpei_movebg.h"

#include "gfx.h"
#include "ichain.h"
#include "macros.h"
#include "segmented_address.h"
#include "sfx.h"
#include "z64play.h"

#include "assets/objects/object_d_lift/object_d_lift.h"

#define FLAGS (ACTOR_FLAG_UPDATE_CULLING_DISABLED)
Expand Down
Loading