summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/arm_proxy.h6
-rw-r--r--include/coord.h (renamed from include/position.h)6
-rw-r--r--include/dma.h9
-rw-r--r--include/entity.h93
-rw-r--r--include/functions.h5
-rw-r--r--include/greatFairy.h1
-rw-r--r--include/main.h7
-rw-r--r--include/readKeyInput.h9
-rw-r--r--include/textbox.h31
-rw-r--r--include/trig.h7
-rw-r--r--include/utils.h64
11 files changed, 177 insertions, 61 deletions
diff --git a/include/arm_proxy.h b/include/arm_proxy.h
new file mode 100644
index 00000000..c07a649e
--- /dev/null
+++ b/include/arm_proxy.h
@@ -0,0 +1,6 @@
+#ifndef ARM_PROXY_H
+#define ARM_PROXY_H
+
+extern void PrepNextFrame(void);
+
+#endif
diff --git a/include/position.h b/include/coord.h
index 87d5b128..b91c97b2 100644
--- a/include/position.h
+++ b/include/coord.h
@@ -4,6 +4,9 @@
#include "global.h"
#include "entity.h"
+s16 FixedMul(s16 r0, s16 r1);
+s16 FixedDiv(s16 r0, s16 r1);
+
void CopyPosition(Entity*, Entity*);
void PositionEntityOnTop(Entity*, Entity*);
void PositionRelative(Entity*, Entity*, s32, s32);
@@ -12,4 +15,7 @@ void sub_0806FA90(Entity*, Entity*, s32, s32);
void ResolveEntityOnTop(Entity*, Entity*);
void sub_0806FAD8(Entity*, Entity*);
+const s16 gSineTable[64];
+const s16 gCosineTable[256];
+
#endif
diff --git a/include/dma.h b/include/dma.h
deleted file mode 100644
index 168c870e..00000000
--- a/include/dma.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef DMA_H
-#define DMA_H
-
-void MemFill16(u32 value, void* dest, u32 size);
-void MemFill32(u32 value, void* dest, u32 size);
-void MemClear(void* dest, u32 size);
-void MemCopy(const void* src, void* dest, u32 size);
-
-#endif // DMA_H
diff --git a/include/entity.h b/include/entity.h
index 10867f53..f19e0876 100644
--- a/include/entity.h
+++ b/include/entity.h
@@ -175,12 +175,33 @@ extern LinkedList gUnk_03003DA0;
#define COORD_TO_TILE_OFFSET(entity, xOff, yOff) \
TILE((entity)->x.HALF.HI - (xOff), (entity)->y.HALF.HI - (yOff))
+enum {
+ DirectionNorth = 0x00,
+ DirectionEast = 0x08,
+ DirectionSouth = 0x10,
+ DirectionWest = 0x18,
+};
+
+#define DirectionRound(expr) ((expr) & 0x18)
+#define DirectionRoundUp(expr) DirectionRound((expr) + 4)
+#define DirectionIsHorizontal(expr) ((expr) & 0x08)
+#define DirectionIsVertical(expr) ((expr) & 0x10)
+#define DirectionTurnAround(expr) (DirectionRoundUp(expr) ^ 0x10)
+#define DirectionToAnimationState(expr) (DirectionRoundUp(expr) >> 3)
+#define DirectionFromAnimationState(expr) ((expr) << 3)
+
+#define Direction8Round(expr) ((expr) & 0x1c)
+#define Direction8RoundUp(expr) Direction8Round((expr) + 2)
+#define Direction8TurnAround(expr) (Direction8RoundUp(expr) ^ 0x10)
+#define Direction8ToAnimationState(expr) (Direction8RoundUp(expr) >> 2)
+#define Direction8FromAnimationState(expr) (((expr) << 2)
+
Entity* GetEmptyEntity(void);
-extern Entity* CreateEnemy(u32 subtype, u32 form);
-extern Entity* CreateObject(u32 subtype, u32 form, u32 parameter);
-extern Entity* CreateNPC(u32 subtype, u32 form, u32 parameter);
-extern Entity* CreateObjectWithParent(Entity* parent, u32 subtype, u32 form, u32 parameter);
-extern Entity* CreateFx(Entity* parent, u32 form, u32 parameter);
+extern Entity* CreateEnemy(u32 id, u32 type);
+extern Entity* CreateNPC(u32 id, u32 type, u32 type2);
+extern Entity* CreateObject(u32 id, u32 type, u32 type2);
+extern Entity* CreateObjectWithParent(Entity* parent, u32 id, u32 type, u32 type2);
+extern Entity* CreateFx(Entity* parent, u32 type, u32 type2);
extern void InitializeAnimation(Entity*, u32);
extern void InitAnimationForceUpdate(Entity*, u32);
@@ -194,34 +215,54 @@ extern void SetSpriteSubEntryOffsetData2(Entity*, u32, u32);
extern u32 GetFacingDirection(Entity*, Entity*);
+/**
+ * @brief Delete the entity currently in execution.
+ */
void DeleteThisEntity(void);
+
+/**
+ * @brief Delete an entity.
+ */
void DeleteEntity(Entity*);
+/**
+ * @brief Append entity to linked list.
+ */
void AppendEntityToList(Entity* entity, u32 listIndex);
-void PrependEntityToList(Entity* entity, int listIndex);
-Entity* FindEntityInListBySubtype(u32 type, u32 subtype, u32 listIndex);
-Entity* FindEntityInListByForm(u32 type, u32 subtype, u32 listIndex, u32 form, u32 parameter);
+/**
+ * @brief Prepend entity to linked list.
+ */
+void PrependEntityToList(Entity* entity, u32 listIndex);
-enum {
- DirectionNorth = 0x00,
- DirectionEast = 0x08,
- DirectionSouth = 0x10,
- DirectionWest = 0x18,
-};
+/**
+ * @brief Find an entity for a given kind and ID.
+ * @return Entity* First result or NULL if none found
+ */
+Entity* FindEntityByID(u32 kind, u32 id, u32 listIndex);
-#define DirectionRound(expr) ((expr) & 0x18)
-#define DirectionRoundUp(expr) DirectionRound((expr) + 4)
-#define DirectionIsHorizontal(expr) ((expr) & 0x08)
-#define DirectionIsVertical(expr) ((expr) & 0x10)
-#define DirectionTurnAround(expr) (DirectionRoundUp(expr) ^ 0x10)
-#define DirectionToAnimationState(expr) (DirectionRoundUp(expr) >> 3)
-#define DirectionFromAnimationState(expr) ((expr) << 3)
+/**
+ * @brief Search all lists for an entity of same kind and id.
+ * @return Entity* First result or NULL if none found
+ */
+Entity* DeepFindEntityByID(u32 kind, u32 id);
-#define Direction8Round(expr) ((expr) & 0x1c)
-#define Direction8RoundUp(expr) Direction8Round((expr) + 2)
-#define Direction8TurnAround(expr) (Direction8RoundUp(expr) ^ 0x10)
-#define Direction8ToAnimationState(expr) (Direction8RoundUp(expr) >> 2)
-#define Direction8FromAnimationState(expr) (((expr) << 2)
+/**
+ * @brief Search all lists for entity of same kind and id.
+ * @return bool32 Duplicate was entity found
+ */
+bool32 EntityHasDuplicateID(Entity* ent);
+
+/**
+ * @brief Find an entity of same kind and id in list.
+ * @return Entity* First result or NULL if none found
+ */
+Entity* FindNextDuplicateID(Entity* ent, int listIndex);
+
+/**
+ * @brief Find Entity with full identifiers.
+ * @return Entity* First result or NULL if none found
+ */
+Entity* FindEntity(u32 kind, u32 id, u32 listIndex, u32 type, u32 type2);
#endif
diff --git a/include/functions.h b/include/functions.h
index 4711ec1e..5c62cced 100644
--- a/include/functions.h
+++ b/include/functions.h
@@ -5,7 +5,7 @@
#include "global.h"
#include "entity.h"
#include "manager.h"
-#include "position.h"
+#include "coord.h"
#include "player.h"
#include "room.h"
#include "structures.h"
@@ -13,7 +13,6 @@
// Identified - to be sorted into header files
extern void SoundReq(u32);
extern void ShowNPCDialogue(Entity*, Dialog*);
-extern u32 __modsi3(u32, u32);
extern void DoFade(u32, u32);
extern u32 CheckKinstoneFused(u32);
extern void ForceEquipItem(u32, u8);
@@ -120,7 +119,7 @@ extern u32 sub_08060354(void);
extern void sub_08057E64(void);
extern void sub_0809F814(u32);
extern void sub_080300E8(void);
-extern void sub_0801DA90(u32);
+extern void DispReset(u32);
extern void sub_08058D34(void);
extern void sub_0807AABC(Entity*);
extern void sub_08078A90(u32);
diff --git a/include/greatFairy.h b/include/greatFairy.h
index 6afb06dd..fd325b6c 100644
--- a/include/greatFairy.h
+++ b/include/greatFairy.h
@@ -24,7 +24,6 @@ extern u32 gUnk_0810C2E4;
extern const s16 GreatFairy_RippleOffsets[10];
extern u32 gUnk_02034350;
extern u8 gUnk_0812079C[8];
-extern s16 gSineTable[];
extern s8 gUnk_081207AC[];
#endif
diff --git a/include/main.h b/include/main.h
index 39514ff7..1653a40e 100644
--- a/include/main.h
+++ b/include/main.h
@@ -77,18 +77,13 @@ static_assert(sizeof(UI) == 0x3b4);
extern Main gMain;
extern UI gUnk_02032EC0;
-void InitScreen();
+void InitScreen(u32 screen);
extern void InitSound(void);
-extern void sub_080560B8(void);
extern void sub_08056208(void);
extern void sub_0804FFE4(void);
-extern void MessageInitialize(void);
extern void sub_080ADD30(void);
-extern void InitScreen(u32);
-extern void PrepNextFrame(void);
-extern void ReadKeyInput(void);
extern void DoSoftReset(void);
extern void sub_08056260(void);
extern void VBlankIntrWait();
diff --git a/include/readKeyInput.h b/include/readKeyInput.h
deleted file mode 100644
index 7961c2b6..00000000
--- a/include/readKeyInput.h
+++ /dev/null
@@ -1,9 +0,0 @@
-typedef struct {
- u16 heldKeys;
- u16 newKeys;
- u16 unk4;
- u8 unk6;
- u8 unk7;
-} Input;
-
-extern Input gInput;
diff --git a/include/textbox.h b/include/textbox.h
index 4b0333a5..817d50a0 100644
--- a/include/textbox.h
+++ b/include/textbox.h
@@ -56,9 +56,40 @@ typedef struct {
extern struct_02022780 gUnk_02022780;
static_assert(sizeof(struct_02022780) == 0xa8);
+/**
+ * @brief Initialize the message system.
+ */
+void MessageInitialize(void);
+
+/**
+ * @brief Show a message on screen.
+ *
+ * @param index u32 Message index
+ */
void ShowTextbox(u32 index);
+
+/**
+ * @brief Show a message at screen posiiton.
+ *
+ * @param index u32 Message index
+ * @param x u32 Screen x
+ * @param y u32 Screen y
+ */
void TextboxAtPosition(u32 index, u32 x, u32 y);
+
+/**
+ * @brief Show a message that attempts not to obscure the entity.
+ *
+ * @param index u32 Message index
+ * @param ent Entity* Your important entity
+ */
void TextboxNoOverlap(u32 index, Entity* ent);
+
+/**
+ * @brief Show a message that attempts not to obscure the camera target.
+ *
+ * @param index u32 Message index
+ */
void TextboxNoOverlapFollow(u32 index);
#endif
diff --git a/include/trig.h b/include/trig.h
deleted file mode 100644
index 0e6e44a9..00000000
--- a/include/trig.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef TRIG_H
-#define TRIG_H
-
-extern const s16 gSineTable[];
-extern const s16 gCosineTable[];
-
-#endif
diff --git a/include/utils.h b/include/utils.h
new file mode 100644
index 00000000..040eacee
--- /dev/null
+++ b/include/utils.h
@@ -0,0 +1,64 @@
+typedef struct {
+ u16 heldKeys;
+ u16 newKeys;
+ u16 unk4;
+ u8 unk6;
+ u8 unk7;
+} Input;
+
+extern Input gInput;
+
+/**
+ * Fill memory with 16 bit value.
+ */
+void MemFill16(u32 value, void* dest, u32 size);
+
+/**
+ * Fill memory with 32 bit value.
+ */
+void MemFill32(u32 value, void* dest, u32 size);
+
+/**
+ * Clear memory.
+ */
+void MemClear(void* dest, u32 size);
+
+/**
+ * Copy memory.
+ */
+void MemCopy(const void* src, void* dest, u32 size);
+
+/**
+ * Refresh gInput from hardware registers.
+ */
+void ReadKeyInput(void);
+
+void LoadPalettes(const u8*, int, int);
+void LoadPaletteGroup(u32 group);
+
+/**
+ * Allocate memory on heap.
+ *
+ * The heap size is 0x1000 bytes and should be used sparingly.
+ * It is customary for entities store the returned handle in their 'myHeap' field.
+ *
+ * @param size u32 Size to be allocated
+ * @return void* Pointer to allocated memory
+ */
+void* zMalloc(u32 size);
+
+/**
+ * Free memory from heap.
+ *
+ * The entity system will automatically free the address stored in the 'myHeap' field.
+ *
+ * @param ptr void* Handle to be freed
+ */
+void zFree(void* ptr);
+
+/**
+ * Reset All display hardware registers.
+ *
+ * @param updateHUD bool32 Request refresh of HUD layer (bg 0)
+ */
+void DispReset(bool32 updateHUD);