diff --git a/include/entity.h b/include/entity.h index 6f1b5e72..e40b281f 100644 --- a/include/entity.h +++ b/include/entity.h @@ -175,6 +175,7 @@ extern LinkedList gUnk_03003DA0; #define COORD_TO_TILE_OFFSET(entity, xOff, yOff) \ TILE((entity)->x.HALF.HI - (xOff), (entity)->y.HALF.HI - (yOff)) +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); @@ -193,8 +194,11 @@ extern void SetSpriteSubEntryOffsetData2(Entity*, u32, u32); extern u32 GetFacingDirection(Entity*, Entity*); -extern void DeleteThisEntity(void); -extern void DeleteEntity(Entity*); +void DeleteThisEntity(void); +void DeleteEntity(Entity*); + +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); diff --git a/include/fileScreen.h b/include/fileScreen.h index b5782093..8f11aaef 100644 --- a/include/fileScreen.h +++ b/include/fileScreen.h @@ -2,12 +2,6 @@ #define FILESELECT_H #include "global.h" -#include "functions.h" -#include "main.h" -#include "player.h" -#include "readKeyInput.h" -#include "screen.h" -#include "menu.h" #include "save.h" typedef struct { diff --git a/include/functions.h b/include/functions.h index 34e79e08..08e8c90e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -11,20 +11,16 @@ #include "room.h" // Identified - to be sorted into header files -extern u32 Random(void); extern void SoundReq(u32); extern void ShowNPCDialogue(Entity*, Dialog*); -extern u32 UpdateFuseInteraction(); extern u32 __modsi3(u32, u32); extern void DoFade(u32, u32); extern u32 CheckKinstoneFused(u32); extern void ForceEquipItem(u32, u8); extern void LoadRoomEntityList(); -extern void EnemyFunctionHandler(Entity*, void (*const funcs[])(Entity*)); extern u32 GetAnimationState(Entity*); extern void SetChildOffset(Entity*, s32, s32, s32); extern Entity* CreatePlayerItem(u32, u32, u32, u32); -extern Entity* GetEmptyEntity(void); extern u32 GetTileTypeByPos(s32 x, s32 y, u32 layer); extern u32 GetTileType(u32 pos, u32 layer); extern void EraseAllEntities(void); @@ -43,7 +39,6 @@ extern void LoadResourceAsync(const void*, u32, u32); extern void LoadPaletteGroup(u32); extern void TryLoadPrologueHyruleTown(void); extern Manager* GetEmptyManager(void); -extern void AppendEntityToList(void*, u32); extern void LoadGfxGroup(u32); extern void EnqueueSFX(u32); extern void ResetPlayer(void); diff --git a/include/gba/macro.h b/include/gba/macro.h index 53f03071..f142d5c0 100644 --- a/include/gba/macro.h +++ b/include/gba/macro.h @@ -1,9 +1,9 @@ #ifndef GUARD_GBA_MACRO_H #define GUARD_GBA_MACRO_H -#define CPU_FILL(value, dest, size, bit) \ - { \ - vu##bit tmp = (vu##bit)(value); \ +#define CPU_FILL(value, dest, size, bit) \ + { \ + vu##bit tmp = (vu##bit)(value); \ CpuSet((void*)&tmp, dest, CPU_SET_##bit##BIT | CPU_SET_SRC_FIXED | ((size) / ((bit) / 8) & 0x1FFFFF)); \ } @@ -42,7 +42,7 @@ vu##bit tmp = (vu##bit)(value); \ DmaSet(dmaNum, &tmp, dest, \ (DMA_ENABLE | DMA_START_NOW | DMA_##bit##BIT | DMA_SRC_FIXED | DMA_DEST_INC) << 16 | \ - ((size) / ((bit) / 8))); \ + ((size) / ((bit) / 8))); \ } #define DmaFill16(dmaNum, value, dest, size) DMA_FILL(dmaNum, value, dest, size, 16) @@ -112,7 +112,7 @@ #define DmaFillLarge(dmaNum, value, dest, size, block, bit) \ { \ - void* _dest = (void*)(dest); \ + void* _dest = (void*)(dest); \ u32 _size = size; \ while (1) { \ DmaFill##bit(dmaNum, value, _dest, (block)); \ @@ -149,7 +149,7 @@ #define DmaFillDefvars(dmaNum, value, dest, size, bit) \ { \ - void* _dest = (void*)(dest); \ + void* _dest = (void*)(dest); \ u32 _size = size; \ DmaFill##bit(dmaNum, value, _dest, _size); \ } @@ -180,7 +180,7 @@ \ imeTemp = REG_IME; \ REG_IME = 0; \ - REG_IE |= (flags); \ + REG_IE |= (flags); \ REG_IME = imeTemp; \ } diff --git a/include/global.h b/include/global.h index f45ee218..74e38a45 100644 --- a/include/global.h +++ b/include/global.h @@ -31,9 +31,9 @@ #define SWAP(a, b, temp) \ { \ - (temp) = a; \ - (a) = b; \ - (b) = temp; \ + (temp) = a; \ + (a) = b; \ + (b) = temp; \ } // useful math macros diff --git a/include/structures.h b/include/structures.h index a7e4902f..66c2a6b6 100644 --- a/include/structures.h +++ b/include/structures.h @@ -39,7 +39,7 @@ typedef struct { u8 field_0x4[0x4]; bool8 transitioningOut; u8 transitionType; // transition when changing areas - u16 field_0xa; // seems to be a tile type + u16 field_0xa; // seems to be a tile type u8 areaID; u8 roomID; u8 playerState; diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index fff1cb50..142b4010 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -1,5 +1,6 @@ #include "global.h" #include "entity.h" +#include "random.h" #include "functions.h" extern u32 sub_080002D4(s32, s32, u32); diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index 61e54b6a..a55b0f7f 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -1,6 +1,8 @@ #include "entity.h" -#include "functions.h" +#include "enemy.h" #include "player.h" +#include "random.h" +#include "functions.h" extern u32 PlayerInRange(Entity*, u32, u32); diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index bf4b4372..e5716276 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -1,4 +1,5 @@ #include "enemy.h" +#include "random.h" #include "functions.h" extern void CreateDustSmall(Entity*); diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index 58e1ed51..caaf98b0 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -1,7 +1,8 @@ #include "global.h" #include "entity.h" -#include "functions.h" #include "player.h" +#include "random.h" +#include "functions.h" extern void sub_08078954(Entity*); extern void sub_08078930(Entity*); diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index 49ba9ea1..30e95a2b 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -1,9 +1,11 @@ #include "enemy.h" #include "entity.h" #include "flags.h" -#include "functions.h" #include "textbox.h" #include "save.h" +#include "random.h" +#include "npc.h" +#include "functions.h" extern void sub_0801D040(Entity*, u32); extern Entity* sub_08049DF4(u32); @@ -326,7 +328,7 @@ void sub_08028E40(Entity* this) { } void sub_08028E84(Entity* this) { - if (UpdateFuseInteraction()) { + if (UpdateFuseInteraction(this)) { this->action = 4; this->actionDelay = 1; } diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c index 99a9160a..625fab9b 100644 --- a/src/enemy/chuchu.c +++ b/src/enemy/chuchu.c @@ -1,5 +1,6 @@ #include "enemy.h" #include "entity.h" +#include "random.h" #include "functions.h" extern s32 sub_080012DC(Entity*); diff --git a/src/enemy/cuccoChickAggr.c b/src/enemy/cuccoChickAggr.c index de87165a..0b894e09 100644 --- a/src/enemy/cuccoChickAggr.c +++ b/src/enemy/cuccoChickAggr.c @@ -1,5 +1,6 @@ #include "enemy.h" #include "entity.h" +#include "random.h" #include "functions.h" extern Entity* sub_08049DF4(u32); diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c index 49acb71d..82f1d53a 100644 --- a/src/enemy/darkNut.c +++ b/src/enemy/darkNut.c @@ -1,4 +1,6 @@ #include "entity.h" +#include "enemy.h" +#include "random.h" #include "functions.h" typedef struct { diff --git a/src/enemy/fallingBoulder.c b/src/enemy/fallingBoulder.c index 4b469258..570c3715 100644 --- a/src/enemy/fallingBoulder.c +++ b/src/enemy/fallingBoulder.c @@ -1,4 +1,5 @@ #include "enemy.h" +#include "random.h" #include "functions.h" void sub_0802C4B0(Entity*); diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c index 3a4e4148..c77281a7 100644 --- a/src/enemy/fireballGuy.c +++ b/src/enemy/fireballGuy.c @@ -1,5 +1,7 @@ #include "global.h" #include "entity.h" +#include "enemy.h" +#include "random.h" #include "functions.h" typedef struct { diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c index a1a9833d..02b7f327 100644 --- a/src/enemy/gibdo.c +++ b/src/enemy/gibdo.c @@ -1,8 +1,9 @@ #include "global.h" #include "entity.h" #include "sprite.h" -#include "functions.h" #include "enemy.h" +#include "random.h" +#include "functions.h" // Gibudo void sub_08037794(); void sub_08037B10(); diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c index c7d26607..86939a3c 100644 --- a/src/enemy/gyorgMale.c +++ b/src/enemy/gyorgMale.c @@ -4,8 +4,9 @@ #include "room.h" #include "trig.h" #include "structures.h" -#include "functions.h" #include "fileScreen.h" +#include "random.h" +#include "functions.h" void (*const gUnk_080D1AFC[8])(Entity*); void (*const gUnk_080D1B1C[7])(Entity*); diff --git a/src/enemy/hangingSeed.c b/src/enemy/hangingSeed.c index fc09db31..fe6fe0fc 100644 --- a/src/enemy/hangingSeed.c +++ b/src/enemy/hangingSeed.c @@ -1,4 +1,5 @@ #include "entity.h" +#include "enemy.h" #include "functions.h" extern void (*const gHangingSeedFunctions[])(Entity*); diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 64a97b39..c36db42b 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -1,4 +1,5 @@ #include "enemy.h" +#include "random.h" #include "functions.h" extern void sub_08008796(Entity*, u32, u32, u32); diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c index a011fcb7..0da3cb57 100644 --- a/src/enemy/keaton.c +++ b/src/enemy/keaton.c @@ -1,5 +1,7 @@ #include "global.h" #include "entity.h" +#include "enemy.h" +#include "random.h" #include "functions.h" extern Entity* gUnk_020000B0; diff --git a/src/enemy/keese.c b/src/enemy/keese.c index 2c5dc02b..0f3a090f 100644 --- a/src/enemy/keese.c +++ b/src/enemy/keese.c @@ -2,6 +2,7 @@ #include "entity.h" #include "enemy.h" #include "player.h" +#include "random.h" #include "functions.h" extern void sub_08001328(Entity*); diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c index 00e220cc..ccf93784 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -1,5 +1,6 @@ #include "global.h" #include "entity.h" +#include "enemy.h" #include "functions.h" #include "trig.h" #include "random.h" @@ -33,7 +34,6 @@ typedef struct { s8 y; } PACKED OffsetCoords; - // Variables extern void (*const gUnk_080D0110[])(Entity*); extern void (*const gUnk_080D0128[])(Entity*); diff --git a/src/enemy/leever.c b/src/enemy/leever.c index 7e2f0774..4e6fb823 100644 --- a/src/enemy/leever.c +++ b/src/enemy/leever.c @@ -1,6 +1,7 @@ #include "global.h" #include "entity.h" #include "enemy.h" +#include "random.h" #include "functions.h" extern u32 sub_080002D4(s32, s32, u32); diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index b5596a55..fb16c1ee 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -1,8 +1,9 @@ #include "enemy.h" #include "entity.h" -#include "functions.h" #include "textbox.h" #include "save.h" +#include "random.h" +#include "functions.h" extern bool32 sub_080544B4(u32); diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c index cea511b4..bca381f6 100644 --- a/src/enemy/madderpillar.c +++ b/src/enemy/madderpillar.c @@ -1,5 +1,6 @@ #include "enemy.h" #include "entity.h" +#include "random.h" #include "functions.h" extern u8 gEntCount; diff --git a/src/enemy/miniFireballGuy.c b/src/enemy/miniFireballGuy.c index c0114ff1..50a10eec 100644 --- a/src/enemy/miniFireballGuy.c +++ b/src/enemy/miniFireballGuy.c @@ -1,5 +1,7 @@ #include "global.h" #include "entity.h" +#include "enemy.h" +#include "random.h" #include "functions.h" extern void sub_08045678(Entity*); diff --git a/src/enemy/miniSlime.c b/src/enemy/miniSlime.c index 993d7666..ad880319 100644 --- a/src/enemy/miniSlime.c +++ b/src/enemy/miniSlime.c @@ -1,6 +1,8 @@ #include "global.h" #include "entity.h" +#include "enemy.h" #include "room.h" +#include "random.h" #include "functions.h" void sub_08045374(Entity*); diff --git a/src/enemy/moldorm.c b/src/enemy/moldorm.c index 186bee30..8061aff7 100644 --- a/src/enemy/moldorm.c +++ b/src/enemy/moldorm.c @@ -1,5 +1,6 @@ #include "enemy.h" #include "entity.h" +#include "random.h" #include "functions.h" void sub_08022EAC(Entity*); diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index 3bf68715..62c75be4 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -1,5 +1,6 @@ #include "enemy.h" #include "entity.h" +#include "random.h" #include "functions.h" extern void sub_0800449C(Entity*, u32); diff --git a/src/enemy/octorok.c b/src/enemy/octorok.c index 199742bc..ec102485 100644 --- a/src/enemy/octorok.c +++ b/src/enemy/octorok.c @@ -1,5 +1,7 @@ #include "global.h" #include "entity.h" +#include "enemy.h" +#include "random.h" #include "functions.h" extern Entity* sub_08049DF4(u32); diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index 165bf1eb..b2d27d02 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -1,4 +1,6 @@ #include "entity.h" +#include "enemy.h" +#include "random.h" #include "functions.h" extern void (*const gPeahatFunctions[])(Entity*); diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index a22dd53b..8d8e39fa 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -1,5 +1,6 @@ #include "enemy.h" #include "entity.h" +#include "random.h" #include "functions.h" extern u32 sub_080002E0(u16, u32); diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c index 80c98278..8daec1d7 100644 --- a/src/enemy/puffstool.c +++ b/src/enemy/puffstool.c @@ -1,5 +1,6 @@ #include "enemy.h" #include "entity.h" +#include "random.h" #include "functions.h" extern u32 sub_080002E0(u32, u32); diff --git a/src/enemy/rockChuchu.c b/src/enemy/rockChuchu.c index 01a0c9c7..91d2a66c 100644 --- a/src/enemy/rockChuchu.c +++ b/src/enemy/rockChuchu.c @@ -1,5 +1,6 @@ #include "enemy.h" #include "entity.h" +#include "random.h" #include "functions.h" extern void sub_0804A4E4(Entity*, Entity*); diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index 7ef108b4..474f3849 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -1,4 +1,6 @@ #include "entity.h" +#include "enemy.h" +#include "random.h" #include "functions.h" extern void (*const gRollobiteFunctions[])(Entity*); diff --git a/src/enemy/rope.c b/src/enemy/rope.c index e76f8ec1..44a955b1 100644 --- a/src/enemy/rope.c +++ b/src/enemy/rope.c @@ -1,8 +1,9 @@ #include "global.h" #include "entity.h" #include "sprite.h" -#include "functions.h" #include "enemy.h" +#include "random.h" +#include "functions.h" extern void (*const gRope[6])(Entity*); extern void (*const gUnk_080CE460[4])(Entity*); diff --git a/src/enemy/slime.c b/src/enemy/slime.c index 6ef1e9fa..2235bcf9 100644 --- a/src/enemy/slime.c +++ b/src/enemy/slime.c @@ -1,6 +1,8 @@ #include "global.h" #include "entity.h" +#include "enemy.h" #include "room.h" +#include "random.h" #include "functions.h" typedef struct { diff --git a/src/enemy/sluggula.c b/src/enemy/sluggula.c index 86b90864..436baf3c 100644 --- a/src/enemy/sluggula.c +++ b/src/enemy/sluggula.c @@ -1,5 +1,6 @@ #include "enemy.h" #include "entity.h" +#include "random.h" #include "functions.h" extern s32 sub_080012DC(Entity*); diff --git a/src/enemy/smallPesto.c b/src/enemy/smallPesto.c index d39712ef..8eb16b63 100644 --- a/src/enemy/smallPesto.c +++ b/src/enemy/smallPesto.c @@ -1,6 +1,7 @@ #include "global.h" #include "entity.h" #include "position.h" +#include "random.h" #include "functions.h" extern u32 GetNextFunction(Entity*); diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c index c206edd2..d15068a6 100644 --- a/src/enemy/spearMoblin.c +++ b/src/enemy/spearMoblin.c @@ -1,5 +1,6 @@ #include "enemy.h" #include "entity.h" +#include "random.h" #include "functions.h" extern bool32 sub_0806FC80(Entity*, Entity*, u32); diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c index e1c32ce0..57d11579 100644 --- a/src/enemy/spikedBeetle.c +++ b/src/enemy/spikedBeetle.c @@ -1,5 +1,6 @@ #include "enemy.h" #include "entity.h" +#include "random.h" #include "functions.h" extern u32 sub_0804A024(Entity*, u32, u32); diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c index 873962c9..7a2f50fa 100644 --- a/src/enemy/spinyChuchu.c +++ b/src/enemy/spinyChuchu.c @@ -1,5 +1,6 @@ #include "enemy.h" #include "entity.h" +#include "random.h" #include "functions.h" extern void sub_08001318(Entity*); diff --git a/src/enemy/tektite.c b/src/enemy/tektite.c index a738d82a..f8af6e9d 100644 --- a/src/enemy/tektite.c +++ b/src/enemy/tektite.c @@ -1,6 +1,7 @@ #include "global.h" #include "entity.h" #include "enemy.h" +#include "random.h" #include "functions.h" extern void (*const gUnk_080CDED0[])(Entity*); diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c index 3bf14e34..d3f5f0b5 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -1,8 +1,9 @@ #include "global.h" #include "entity.h" #include "enemy.h" -#include "functions.h" #include "flags.h" +#include "random.h" +#include "functions.h" extern void sub_08038168(Entity*); diff --git a/src/enemy/wallMaster.c b/src/enemy/wallMaster.c index 1ba24a96..394e8620 100644 --- a/src/enemy/wallMaster.c +++ b/src/enemy/wallMaster.c @@ -1,7 +1,8 @@ #include "enemy.h" #include "entity.h" -#include "functions.h" #include "area.h" +#include "random.h" +#include "functions.h" extern void sub_08001328(Entity*); extern Entity* sub_08049DF4(u32); diff --git a/src/enemy/wallMaster2.c b/src/enemy/wallMaster2.c index ffe1d1e9..7023c024 100644 --- a/src/enemy/wallMaster2.c +++ b/src/enemy/wallMaster2.c @@ -1,6 +1,7 @@ #include "enemy.h" -#include "functions.h" #include "area.h" +#include "random.h" +#include "functions.h" extern void sub_08001328(Entity*); extern void DoExitTransition(u32*); diff --git a/src/enemy/waterDrop.c b/src/enemy/waterDrop.c index 87b80940..017eb2b9 100644 --- a/src/enemy/waterDrop.c +++ b/src/enemy/waterDrop.c @@ -1,7 +1,8 @@ #include "enemy.h" #include "entity.h" -#include "functions.h" #include "screen.h" +#include "random.h" +#include "functions.h" void sub_0802A39C(Entity*); void sub_0802A334(Entity*); diff --git a/src/enemy/wisp.c b/src/enemy/wisp.c index 10463258..195838af 100644 --- a/src/enemy/wisp.c +++ b/src/enemy/wisp.c @@ -3,8 +3,9 @@ #include "enemy.h" #include "structures.h" #include "player.h" -#include "functions.h" #include "save.h" +#include "random.h" +#include "functions.h" extern void (*const gUnk_080CEB74[])(Entity*); extern void (*const gUnk_080CEB8C[])(Entity*); diff --git a/src/entity.c b/src/entity.c index 47acc2dc..cef327b6 100644 --- a/src/entity.c +++ b/src/entity.c @@ -1,5 +1,6 @@ #include "global.h" #include "entity.h" +#include "dma.h" typedef struct OtherEntity { struct OtherEntity* prev; @@ -22,8 +23,7 @@ Entity* sub_0805E744(void) { return NULL; } -extern Entity* GetEmptyEntity(); -OtherEntity* GetEmptyManager(); +OtherEntity* GetEmptyManager(void); typedef void* (*Getter)(void); @@ -47,7 +47,7 @@ typedef struct { extern struct_03003DD0 gUnk_03003DD0; extern u32 _call_via_r0(u32*); extern u32 _EntUpdate; -extern void DeleteEntityAny(Entity*); +void DeleteEntityAny(Entity*); void DeleteThisEntity(void) { DeleteEntityAny(gUnk_03003DD0.field_0x8); @@ -80,7 +80,7 @@ extern void UnloadCutsceneData(); extern void UnloadHitbox(); extern void sub_0801DA0C(); extern void sub_0804AA1C(); -extern void UnlinkEntity(); // Unlink +void UnlinkEntity(); void DeleteEntity(Entity* ent) { if (ent->next) { @@ -159,7 +159,6 @@ OtherEntity* GetEmptyManager(void) { return NULL; } -extern void MemClear(void*, u32); extern u8 gManagerCount; void DeleteManager(OtherEntity* ent) { @@ -183,8 +182,7 @@ void sub_0805E92C(u32 param_1) { } extern Entity gUnk_020369F0; -extern void MemCopy(const void* src, void* dest, size_t size); // dma copy -extern void sub_0805E98C(void); +void sub_0805E98C(void); void sub_0805E958(void) { MemCopy(&gEntityLists, &gUnk_020369F0, 0x48); @@ -236,32 +234,32 @@ void sub_0805E9F4(void) { extern void sub_0805E374(Entity*); -void AppendEntityToList(Entity* ent, int listIndex) { +void AppendEntityToList(Entity* entity, u32 listIndex) { LinkedList* list; list = &gEntityLists[listIndex]; - ent->next = (Entity*)list; - ent->prev = list->last; - list->last->next = ent; - list->last = ent; - if (ent->kind != 9) { - ent->spritePriority.b0 = 4; + entity->next = (Entity*)list; + entity->prev = list->last; + list->last->next = entity; + list->last = entity; + if (entity->kind != 9) { + entity->spritePriority.b0 = 4; gEntCount++; } else { gManagerCount++; } - sub_0805E374(ent); + sub_0805E374(entity); } -void PrependEntityToList(Entity* ent, int listIndex) { +void PrependEntityToList(Entity* entity, int listIndex) { LinkedList* list; - UnlinkEntity(ent); + UnlinkEntity(entity); list = &gEntityLists[listIndex]; - ent->prev = (Entity*)list; - ent->next = list->first; - list->first->prev = ent; - list->first = ent; + entity->prev = (Entity*)list; + entity->next = list->first; + list->first->prev = entity; + list->first = entity; } void UnlinkEntity(Entity* ent) { diff --git a/src/fileScreen.c b/src/fileScreen.c index 1862bdb6..78ed7e91 100644 --- a/src/fileScreen.c +++ b/src/fileScreen.c @@ -1,5 +1,11 @@ #include "fileScreen.h" +#include "main.h" +#include "player.h" +#include "readKeyInput.h" +#include "screen.h" +#include "menu.h" #include "dma.h" +#include "random.h" // copy, erase, start #define NUM_FILE_OPERATIONS 3 diff --git a/src/game.c b/src/game.c index bf44ea66..4ae96174 100644 --- a/src/game.c +++ b/src/game.c @@ -2,7 +2,6 @@ #include "screen.h" #include "structures.h" #include "dma.h" -#include "functions.h" #include "screen.h" #include "entity.h" #include "player.h" @@ -10,7 +9,9 @@ #include "main.h" #include "flags.h" #include "save.h" +#include "readKeyInput.h" #include "fileScreen.h" +#include "functions.h" extern u8 gArea; extern u32 gUnk_03000B80; diff --git a/src/manager/manager1A.c b/src/manager/manager1A.c index fc08d6cc..d9912a7e 100644 --- a/src/manager/manager1A.c +++ b/src/manager/manager1A.c @@ -223,5 +223,5 @@ void sub_0805B390(u32 unk1) { tmp->type = 0x9; tmp->subtype = 0x1A; tmp->unk_0a = unk1; - AppendEntityToList(tmp, 6); + AppendEntityToList((Entity*)tmp, 6); } diff --git a/src/manager/manager28.c b/src/manager/manager28.c index f60541e2..f6790624 100644 --- a/src/manager/manager28.c +++ b/src/manager/manager28.c @@ -46,7 +46,7 @@ void Manager28_Init(Manager28* this) { /* tmp3->enemies[tmp4] = this->enemies[tmp4]; */ /* } */ tmp3->d = this->d; - AppendEntityToList(tmp3, 6); + AppendEntityToList((Entity*)tmp3, 6); } } DeleteManager(&this->manager); diff --git a/src/manager/manager3.c b/src/manager/manager3.c index 5234f149..d4053961 100644 --- a/src/manager/manager3.c +++ b/src/manager/manager3.c @@ -4,6 +4,7 @@ #include "area.h" #include "room.h" #include "player.h" +#include "random.h" #include "functions.h" typedef struct { diff --git a/src/manager/managerB.c b/src/manager/managerB.c index cfa48775..6ea279dc 100644 --- a/src/manager/managerB.c +++ b/src/manager/managerB.c @@ -130,7 +130,7 @@ ManagerBHelper* CreateHelper(Manager* this) { extra->manager.parent = this; this->unk_0e++; MemClear(&extra->enemies, 0x20); - AppendEntityToList(extra, 8); + AppendEntityToList((Entity*)extra, 8); } return extra; } diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 25b5b50d..f7251ac0 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -2,8 +2,9 @@ #include "entity.h" #include "player.h" #include "structures.h" -#include "functions.h" #include "script.h" +#include "random.h" +#include "functions.h" extern void (*gUnk_081140D4[])(Entity*); diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index 913f30cc..4e2e47fb 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -1,12 +1,13 @@ #include "global.h" #include "entity.h" -#include "functions.h" #include "flags.h" #include "player.h" #include "room.h" #include "textbox.h" #include "save.h" #include "script.h" +#include "npc.h" +#include "functions.h" extern void (*gUnk_081115C0[])(Entity*); extern void (*gUnk_081115D0[])(Entity*); @@ -132,7 +133,7 @@ void FUN_08068b2c(Entity* this) { } void sub_08068B70(Entity* this) { - if (UpdateFuseInteraction()) { + if (UpdateFuseInteraction(this)) { this->action = 1; } } diff --git a/src/npc/carpenter.c b/src/npc/carpenter.c index 53e719f8..83ac3bfc 100644 --- a/src/npc/carpenter.c +++ b/src/npc/carpenter.c @@ -2,6 +2,7 @@ #include "entity.h" #include "sprite.h" #include "player.h" +#include "npc.h" #include "functions.h" extern SpriteLoadData gUnk_08110CA8[]; diff --git a/src/npc/cow.c b/src/npc/cow.c index 18e18927..f942b424 100644 --- a/src/npc/cow.c +++ b/src/npc/cow.c @@ -1,6 +1,8 @@ #include "global.h" #include "entity.h" #include "player.h" +#include "random.h" +#include "npc.h" #include "functions.h" extern void (*gUnk_08111914[])(Entity*); diff --git a/src/npc/epona.c b/src/npc/epona.c index a79ccd48..a3e8536f 100644 --- a/src/npc/epona.c +++ b/src/npc/epona.c @@ -2,6 +2,7 @@ #include "entity.h" #include "textbox.h" #include "player.h" +#include "npc.h" #include "functions.h" void sub_08065A64(Entity* this); @@ -43,7 +44,7 @@ void sub_08065A10(Entity* this) { } void sub_08065A34(Entity* this) { - if (UpdateFuseInteraction() != 0) { + if (UpdateFuseInteraction(this) != 0) { this->action = 1; InitAnimationForceUpdate(this, this->animationState / 2); } diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index a44f413b..73044b47 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -4,10 +4,11 @@ #include "flags.h" #include "textbox.h" #include "player.h" -#include "structures.h" -#include "functions.h" #include "save.h" #include "script.h" +#include "random.h" +#include "structures.h" +#include "functions.h" extern void sub_080600F0(Entity*); extern s32 sub_0806EDD8(Entity*, u32, u32); diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index 9fd402c5..b4a44355 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -89,7 +89,7 @@ void sub_08069684(void) { if (mgr != NULL) { mgr->type = 9; mgr->subtype = 0x31; - AppendEntityToList(mgr, 8); + AppendEntityToList((Entity*)mgr, 8); } } } diff --git a/src/npc/malon.c b/src/npc/malon.c index 47052160..0799e8b3 100644 --- a/src/npc/malon.c +++ b/src/npc/malon.c @@ -1,7 +1,8 @@ #include "global.h" -#include "functions.h" #include "entity.h" #include "script.h" +#include "npc.h" +#include "functions.h" extern void (*gUnk_0810FF5C[])(Entity* this); extern void (*gUnk_0810FF64[])(Entity* this); diff --git a/src/npc/melari.c b/src/npc/melari.c index 9758c20d..8e9077e3 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -2,8 +2,9 @@ #include "entity.h" #include "npc.h" #include "textbox.h" -#include "functions.h" #include "script.h" +#include "random.h" +#include "functions.h" extern void sub_08068780(Entity*); extern s32 sub_0806EDD8(Entity*, u32, u32); diff --git a/src/npc/smith.c b/src/npc/smith.c index ac3a9d4c..c7e4b1e8 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -1,9 +1,11 @@ #include "global.h" #include "entity.h" #include "textbox.h" -#include "functions.h" #include "save.h" #include "script.h" +#include "random.h" +#include "npc.h" +#include "functions.h" extern void sub_08078850(u32, u32, u32, u32*); diff --git a/src/npc/talon.c b/src/npc/talon.c index 24380fc9..d7d6f857 100644 --- a/src/npc/talon.c +++ b/src/npc/talon.c @@ -1,9 +1,11 @@ #include "global.h" #include "entity.h" #include "textbox.h" -#include "functions.h" #include "player.h" #include "script.h" +#include "npc.h" +#include "random.h" +#include "functions.h" extern void (*gUnk_0810FEC4[])(Entity* this); extern void (*gUnk_0810FEBC[])(Entity* this); @@ -83,7 +85,7 @@ void sub_08065648(Entity* this) { } void sub_08065680(Entity* this) { - if (UpdateFuseInteraction() != 0) { + if (UpdateFuseInteraction(this) != 0) { this->action = this->field_0x68.HALF.HI; InitAnimationForceUpdate(this, this->field_0x6a.HALF.LO); } diff --git a/src/npc/teachers.c b/src/npc/teachers.c index 87fb3180..bf7e6983 100644 --- a/src/npc/teachers.c +++ b/src/npc/teachers.c @@ -1,9 +1,10 @@ #include "global.h" #include "entity.h" #include "player.h" -#include "functions.h" #include "save.h" #include "script.h" +#include "npc.h" +#include "functions.h" extern SpriteLoadData gUnk_08113910[]; diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index 7f87dd41..fcea0ff4 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -4,10 +4,11 @@ #include "player.h" #include "textbox.h" #include "flags.h" -#include "structures.h" -#include "functions.h" #include "save.h" #include "script.h" +#include "random.h" +#include "structures.h" +#include "functions.h" typedef struct { u8 frame1; diff --git a/src/npc/zelda.c b/src/npc/zelda.c index 62672012..4704b5bb 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -5,7 +5,6 @@ #include "flags.h" #include "script.h" -extern void PrependEntityToList(Entity*, u32); extern Entity* FindEntityBySubtype(u32, u32); void sub_08068680(Entity*, Entity*); void sub_08068694(Entity*, Entity*); diff --git a/src/object/backgroundCloud.c b/src/object/backgroundCloud.c index ceebf3d7..1ee11b67 100644 --- a/src/object/backgroundCloud.c +++ b/src/object/backgroundCloud.c @@ -1,5 +1,6 @@ #include "global.h" #include "entity.h" +#include "random.h" #include "functions.h" extern void (*const gUnk_08121EA4[])(Entity*); diff --git a/src/object/bird.c b/src/object/bird.c index 2b6f194b..9d21f708 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -1,8 +1,9 @@ #include "global.h" #include "entity.h" #include "flags.h" -#include "functions.h" #include "save.h" +#include "random.h" +#include "functions.h" extern void (*const gUnk_08123EC0[])(Entity*); extern void (*const gUnk_08123EEC[])(Entity*); diff --git a/src/object/cloud.c b/src/object/cloud.c index de6aa165..674c1d73 100644 --- a/src/object/cloud.c +++ b/src/object/cloud.c @@ -3,6 +3,7 @@ #include "room.h" #include "player.h" #include "flags.h" +#include "random.h" #include "functions.h" #include "structures.h" diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c index a35ea276..4424032d 100644 --- a/src/object/fileScreenObjects.c +++ b/src/object/fileScreenObjects.c @@ -1,13 +1,14 @@ #include "global.h" #include "entity.h" #include "flags.h" -#include "functions.h" #include "main.h" #include "menu.h" #include "npc.h" #include "position.h" -#include "structures.h" #include "fileScreen.h" +#include "readKeyInput.h" +#include "structures.h" +#include "functions.h" extern int sub_0807A094(int); extern u32 sub_080041EC(int, int); diff --git a/src/object/greatFairy.c b/src/object/greatFairy.c index 85d7474b..886fdf43 100644 --- a/src/object/greatFairy.c +++ b/src/object/greatFairy.c @@ -2,10 +2,11 @@ #include "entity.h" #include "room.h" #include "screen.h" -#include "structures.h" #include "greatFairy.h" #include "flags.h" #include "save.h" +#include "random.h" +#include "structures.h" #include "functions.h" enum { diff --git a/src/object/lilypadSmall.c b/src/object/lilypadSmall.c index a96c49ad..ce0d8c08 100644 --- a/src/object/lilypadSmall.c +++ b/src/object/lilypadSmall.c @@ -1,7 +1,8 @@ #include "global.h" #include "entity.h" -#include "functions.h" #include "player.h" +#include "random.h" +#include "functions.h" extern void sub_080A2CC0(Entity*, Entity**, u16*); diff --git a/src/object/mask.c b/src/object/mask.c index ffe931b1..b6d06206 100644 --- a/src/object/mask.c +++ b/src/object/mask.c @@ -7,7 +7,6 @@ #include "flags.h" #include "functions.h" - extern void (*MaskActionFuncs[])(Entity*); extern void sub_08000148(u16, u16, u32); diff --git a/src/object/object1A.c b/src/object/object1A.c index 26ece918..7b8fbcb2 100644 --- a/src/object/object1A.c +++ b/src/object/object1A.c @@ -1,5 +1,6 @@ #include "global.h" #include "entity.h" +#include "random.h" #include "functions.h" extern void sub_08086A6C(); diff --git a/src/object/objectA2.c b/src/object/objectA2.c index 01fd9fa6..89a2041c 100644 --- a/src/object/objectA2.c +++ b/src/object/objectA2.c @@ -1,6 +1,7 @@ #include "global.h" #include "object.h" #include "menu.h" +#include "random.h" #include "structures.h" #include "functions.h" diff --git a/src/object/smoke.c b/src/object/smoke.c index 679894a8..4c2739dd 100644 --- a/src/object/smoke.c +++ b/src/object/smoke.c @@ -1,5 +1,6 @@ #include "global.h" #include "entity.h" +#include "random.h" #include "functions.h" extern void (*const gUnk_08121060[])(Entity*); diff --git a/src/object/windTribeFlag.c b/src/object/windTribeFlag.c index 9c769808..14f64fba 100644 --- a/src/object/windTribeFlag.c +++ b/src/object/windTribeFlag.c @@ -1,5 +1,6 @@ #include "global.h" #include "entity.h" +#include "random.h" #include "functions.h" void WindTribeFlag(Entity* this) { diff --git a/src/room.c b/src/room.c index 0af93d77..f79da48d 100644 --- a/src/room.c +++ b/src/room.c @@ -2,7 +2,6 @@ #include "entity.h" #include "area.h" #include "room.h" -#include "functions.h" #include "flags.h" #include "npc.h" #include "player.h" @@ -10,6 +9,8 @@ #include "main.h" #include "structures.h" #include "save.h" +#include "random.h" +#include "functions.h" void sub_0804B3C4(void* arg0) { sub_0804B29C(arg0); diff --git a/src/script.c b/src/script.c index a686b371..3033d528 100644 --- a/src/script.c +++ b/src/script.c @@ -6,8 +6,9 @@ #include "structures.h" #include "textbox.h" #include "dma.h" -#include "functions.h" #include "save.h" +#include "random.h" +#include "functions.h" void sub_0807DAF0(Entity*, ScriptExecutionContext*, u16*); void sub_0807DB88(ScriptExecutionContext*, u16*); diff --git a/src/sub_0804AFF4.c b/src/sub_0804AFF4.c index bdd0cf50..b2555120 100644 --- a/src/sub_0804AFF4.c +++ b/src/sub_0804AFF4.c @@ -5,14 +5,14 @@ extern u32* GetCurrentRoomProperty(u8); extern void sub_0804B16C(); void sub_0804AFF4(void) { - void(*func)(); + void (*func)(); sub_080186EC(); - func = (void(*)())GetCurrentRoomProperty(5); + func = (void (*)())GetCurrentRoomProperty(5); if (func) { func(); } - func = (void(*)())GetCurrentRoomProperty(7); + func = (void (*)())GetCurrentRoomProperty(7); if (func) { func(); }