Skip to content
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

RFC: game.h Header Refactor #1406

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions include/animset.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef ANIMSET_H
#define ANIMSET_H

#define ANIMSET_OVL_FLAG 0x8000
#define ANIMSET_DRA(x) (x)
#define ANIMSET_OVL(x) ((x) | ANIMSET_OVL_FLAG)

#endif // ANIMSET_H
23 changes: 23 additions & 0 deletions include/castle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef CASTLE_H
#define CASTLE_H

#include <common.h>
#include <types.h>

#define CASTLE_MAP_PTR 0x801E0000

// Holds flags that checks if certain switches are enabled to allow to have
// shortcuts around the castle. One typical example is the wood column that
// prevents the player to enter in the warp room. When g_CastleFlags[0x32] the
// column will disappear.
extern u8 g_CastleFlags[0x300]; // starts at 0x8003BDEC
extern u8 D_8003BEEC[]; // g_CastleFlags[x + 0x100]
extern u8 D_8003BF9C[]; // not sure if it is part of D_8003BEEC?

extern u8 g_CastleMap[0x800];

#ifdef VERSION_PC
extern u8 g_BmpCastleMap[0x20000];
#endif

#endif // CASTLE_H
13 changes: 13 additions & 0 deletions include/clut.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef CLUT_H
#define CLUT_H

#include "types.h"

extern u16 g_ClutIds[]; // array of palette VRAM offsets
extern u16 g_Clut[0x3000];
extern u16 D_8006EBCC[0x1000]; // part of g_Clut
extern u16 D_8006EBE0; // part of g_Clut
extern s16 D_800705CC[]; // part of g_Clut
extern u32 D_80070BCC; // part of g_Clut

#endif // CLUT_H
43 changes: 43 additions & 0 deletions include/collider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef COLLIDER_H
#define COLLIDER_H

#include "types.h"

typedef enum {
EFFECT_SOLID = 1 << 0,
EFFECT_UNK_0002 = 1 << 1,
EFFECT_QUICKSAND = 1 << 2,
EFFECT_WATER = 1 << 3,
EFFECT_MIST_ONLY = 1 << 4,
EFFECT_UNK_0020 = 1 << 5,
// Used when you jump from below to a platform. You can drop below.
EFFECT_SOLID_FROM_ABOVE = 1 << 6,
// Doesn't collide when falling on it but you cannot go back up.
EFFECT_SOLID_FROM_BELOW = 1 << 7,
EFFECT_UNK_0100 = 1 << 8,
EFFECT_UNK_0200 = 1 << 9,
EFFECT_UNK_0400 = 1 << 10,
EFFECT_UNK_0800 = 1 << 11,
EFFECT_UNK_1000 = 1 << 12,
EFFECT_UNK_2000 = 1 << 13,
EFFECT_UNK_4000 = 1 << 14,
EFFECT_UNK_8000 = 1 << 15,

// Aggregate helpers below:
EFFECT_NOTHROUGH = EFFECT_SOLID | EFFECT_QUICKSAND,
EFFECT_NOTHROUGH_PLUS = EFFECT_SOLID | EFFECT_UNK_0002 | EFFECT_QUICKSAND
} ColliderEffectFlags;

typedef struct Collider {
/* 0x00 */ u32 effects;
/* 0x04 */ s32 unk4;
/* 0x08 */ s32 unk8;
/* 0x0C */ s32 unkC;
/* 0x10 */ s32 unk10;
/* 0x14 */ s32 unk14;
/* 0x18 */ s32 unk18;
/* 0x1C */ s32 unk1C;
/* 0x20 */ s32 unk20;
} Collider; /* size=0x24 */

#endif // COLLIDER_H
2 changes: 2 additions & 0 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ int sprintf(char* dst, const char* fmt, ...);
#define SP(x) (0x1F800000 + (x))
#endif

#define SPAD(x) ((s32*)SP(x * sizeof(s32)))

#endif
8 changes: 8 additions & 0 deletions include/cutscene.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef CUTSCENE_H
#define CUTSCENE_H

// used to indicate that a cutscene is in progress? (including familiar
// introductions)
extern s32 D_8003C704;

#endif // CUTSCENE_H
21 changes: 21 additions & 0 deletions include/demo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef DEMO_H
#define DEMO_H

#ifndef DEMO_KEY_PTR
#define DEMO_KEY_PTR 0x801E8000
#endif

#define DEMO_KEY_LEN 3
#define DEMO_MAX_LEN 0x2000

typedef enum {
Demo_None,
Demo_PlaybackInit,
Demo_Recording,
Demo_End,
Demo_Playback,
} DemoMode;

extern DemoMode g_DemoMode;

#endif // DEMO_H
6 changes: 6 additions & 0 deletions include/disk.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef DISK_H
#define DISK_H

#include "types.h"

typedef enum {
CdStep_None,
CdStep_LoadInit,
Expand Down Expand Up @@ -73,4 +75,8 @@ typedef enum {
CdCallback_Vh, // func_80107EF0
} CdCallbacks;

extern s32 g_UseDisk;
extern u32 g_CdStep; // CdStep
extern s32 g_IsUsingCd;

#endif // DISK_H
20 changes: 20 additions & 0 deletions include/drawmode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef DRAWMODE_H
#define DRAWMODE_H

#define DRAW_DEFAULT 0x00
#define DRAW_TRANSP 0x01 // make it semi transparent
#define DRAW_UNK02 0x02 // unknown
#define DRAW_COLORS 0x04 // use color blending
#define DRAW_HIDE 0x08 // do not render the primitive
#define DRAW_TPAGE 0x10 // use custom tpage
#define DRAW_TPAGE2 0x20 // use custom tpage
#define DRAW_UNK_40 0x40
#define DRAW_MENU 0x80 // render only if D_800973EC is set
#define DRAW_UNK_100 0x100 // unknown
#define DRAW_UNK_200 0x200 // unknown
#define DRAW_UNK_400 0x400 // unknown
#define DRAW_UNK_800 0x800 // unknown
#define DRAW_UNK_1000 0x1000 // unknown
#define DRAW_ABSPOS 0x2000 // use absolute coordinates with DRAW_MENU

#endif // DRAWMODE_H
144 changes: 142 additions & 2 deletions include/entity.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/**
* Custom Entity Subtypes
*/
#ifndef ENTITY_H
#define ENTITY_H

#include "common.h"
#include "types.h"
#include "primitive.h"

struct Entity;
typedef void (*PfnEntityUpdate)(struct Entity*);

typedef union {
Expand Down Expand Up @@ -34,7 +38,10 @@ typedef union {
} U8;
} Multi16;

struct Entity;
typedef struct {
u16 duration;
u16 unk2;
} AnimationFrame;

typedef struct ET_Generic {
/* 0x7C */ Multi16 unk7C; // posX
Expand Down Expand Up @@ -1330,3 +1337,136 @@ typedef union { // offset=0x7C
ET_80129864 et_80129864;
ET_801B28E4 et_801B28E4;
} Ext;

typedef struct Entity {
/* 0x00 */ f32 posX;
/* 0x04 */ f32 posY;
/* 0x08 */ s32 velocityX;
/* 0x0C */ s32 velocityY;
#if defined(STAGE) || defined(WEAPON)
/* 0x10 */ s16 hitboxOffX;
#else // hack to match in DRA and RIC
/* 0x10 */ u16 hitboxOffX;
#endif
/* 0x12 */ s16 hitboxOffY;
/* 0x14 */ u16 facingLeft;
/* 0x16 */ u16 palette;
/* 0x18 */ u8 drawMode;
/* 0x19 */ u8 drawFlags;
/* 0x1A */ s16 rotX;
/* 0x1C */ s16 rotY;
/* 0x1E */ s16 rotZ;
/* 0x20 */ s16 rotPivotX;
/* 0x22 */ s16 rotPivotY;
/* 0x24 */ u16 zPriority;
/* 0x26 */ u16 entityId;
/* 0x28 */ PfnEntityUpdate pfnUpdate;
/* 0x2C */ u16 step;
/* 0x2E */ u16 step_s;
/* 0x30 */ u16 params;
/* 0x32 */ u16 entityRoomIndex;
/* 0x34 */ s32 flags;
/* 0x38 */ s16 unk38;
/* 0x3A */ u16 enemyId;
/* 0x3C */ u16 hitboxState; // hitbox state
/* 0x3E */ s16 hitPoints;
/* 0x40 */ s16 attack;
/* 0x42 */ s16 attackElement;
/* 0x44 */ u16 unk44;
/* 0x46 */ u8 hitboxWidth;
/* 0x47 */ u8 hitboxHeight;
/* 0x48 */ u8 hitFlags; // 1 = took hit
/* 0x49 */ u8 nFramesInvincibility;
/* 0x4A */ s16 unk4A;
/* 0x4C */ AnimationFrame* unk4C;
/* 0x50 */ u16 animFrameIdx;
/* 0x52 */ s16 animFrameDuration;
/* 0x54 */ s16 animSet;
/* 0x56 */ s16 animCurFrame;
/* 0x58 */ s16 stunFrames;
/* 0x5A */ u16 unk5A;
/* 0x5C */ struct Entity* unk5C;
/* 0x60 */ struct Entity* unk60;
/* 0x64 */ s32 primIndex;
/* 0x68 */ u16 unk68;
/* 0x6A */ u16 hitEffect;
/* 0x6C */ u8 unk6C;
/* 0x6D */ u8 unk6D[11];
/* 0x78 */ s32 unk78;
/* 0x7C */ Ext ext;
} Entity; // size = 0xBC

#define TOTAL_ENTITY_COUNT 256
extern Entity g_Entities[TOTAL_ENTITY_COUNT];
extern Entity* g_CurrentEntity;
extern s32 g_entityDestroyed[18];

typedef enum {
PLAYER_CHARACTER,
UNK_ENTITY_1,
UNK_ENTITY_2,
UNK_ENTITY_3,
UNK_ENTITY_4,
UNK_ENTITY_5,
UNK_ENTITY_6,
UNK_ENTITY_7,
UNK_ENTITY_8,
E_WEAPON = 0x10,
UNK_ENTITY_11 = 0x11, // related to wolf
UNK_ENTITY_12 = 0x12, // related to wolf?
UNK_ENTITY_13 = 0x13,
UNK_ENTITY_20 = 0x20,
UNK_ENTITY_51 = 0x51, // SubWeapons container falling liquid
UNK_ENTITY_100 = 0x100
} EntityTypes;

// Flags for entity->drawFlags
#define FLAG_DRAW_DEFAULT 0x00
#define FLAG_DRAW_ROTX 0x01
#define FLAG_DRAW_ROTY 0x02
#define FLAG_DRAW_ROTZ 0x04
#define FLAG_DRAW_UNK8 0x08
#define FLAG_DRAW_UNK10 0x10
#define FLAG_DRAW_UNK20 0x20
#define FLAG_DRAW_UNK40 0x40
#define FLAG_DRAW_UNK80 0x80
#define FLAG_DRAW_UNK100 0x100

// Flags for entity->flags
#define FLAG_UNK_4 0x4
#define FLAG_UNK_10 0x10
// Signals that the entity should run its death routine
#define FLAG_DEAD 0x100
#define FLAG_UNK_200 0x200
#define FLAG_UNK_400 0x400
#define FLAG_UNK_800 0x800
#define FLAG_UNK_1000 0x1000
#define FLAG_UNK_2000 0x2000
#define FLAG_UNK_4000 0x4000
#define FLAG_UNK_8000 0x8000
#define FLAG_UNK_10000 0x10000
#define FLAG_UNK_20000 0x20000 // func_8011A9D8 will destroy if not set
#define FLAG_UNK_40000 0x40000
#define FLAG_UNK_80000 0x80000
#define FLAG_UNK_100000 0x100000
#define FLAG_UNK_400000 0x400000
#define FLAG_UNK_800000 0x800000
#define FLAG_UNK_00200000 0x00200000

// When an entity used AllocPrimitives and their primIndex set.
// At their destruction they need to free the prims with FreePrimitives.
#define FLAG_HAS_PRIMS 0x00800000

#define FLAG_UNK_01000000 0x01000000
#define FLAG_UNK_02000000 0x02000000
#define FLAG_UNK_04000000 0x04000000
#define FLAG_UNK_08000000 0x08000000
#define FLAG_UNK_10000000 0x10000000
#define FLAG_UNK_20000000 0x20000000
#define FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA 0x40000000
#define FLAG_DESTROY_IF_OUT_OF_CAMERA 0x80000000

#define STAGE_ENTITY_START 64
#define MaxEntityCount 32

#endif // ENTITY_H
39 changes: 39 additions & 0 deletions include/familiar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef FAMILIAR_H
#define FAMILIAR_H

typedef enum { STAT_STR, STAT_CON, STAT_INT, STAT_LCK } Stats;
typedef struct {
s32 level;
s32 exp;
s32 unk8;
} FamiliarStats;

// Need two familiar enums. One has a zero entry, one does not.
// This one is used in places that need to access the familiar
// stats array...
typedef enum {
FAM_STATS_BAT,
FAM_STATS_GHOST,
FAM_STATS_FAERIE,
FAM_STATS_DEMON,
FAM_STATS_SWORD,
FAM_STATS_YOUSEI, // JP only
FAM_STATS_NOSE_DEMON, // JP only
NUM_FAMILIARS
} FamiliarStatsIds;

// ...and this one is used to designate the active familiar, where
// 0 means no familiar is active, and the rest are off-by-one from
// the previous enum set. Hacky, but works.
typedef enum {
FAM_ACTIVE_NONE,
FAM_ACTIVE_BAT = FAM_STATS_BAT + 1,
FAM_ACTIVE_GHOST = FAM_STATS_GHOST + 1,
FAM_ACTIVE_FAERIE = FAM_STATS_FAERIE + 1,
FAM_ACTIVE_DEMON = FAM_STATS_DEMON + 1,
FAM_ACTIVE_SWORD = FAM_STATS_SWORD + 1,
FAM_ACTIVE_YOUSEI = FAM_STATS_YOUSEI + 1,
FAM_ACTIVE_NOSE_DEMON = FAM_STATS_NOSE_DEMON + 1,
} FamiliarActiveIds;

#endif // FAMILILAR_H
Loading