From 6cff332e57b5cc723d9243c2d4667be7c7ca0273 Mon Sep 17 00:00:00 2001 From: theo3 Date: Mon, 20 Dec 2021 02:02:33 -0800 Subject: [PATCH] header overhaul --- asm/code_0801967C.s | 2 +- asm/code_0801D79C.s | 6 +- asm/code_08077B98.s | 4 +- asm/code_080A5574.s | 12 +-- asm/fileScreen.s | 2 +- asm/non_matching/sub_08077F24.inc | 7 -- data/data_080FC8A4.s | 9 -- include/arm_proxy.h | 6 -- include/asm.h | 25 ++++++ include/audio.h | 44 ++++----- include/coord.h | 4 + include/cutscene.h | 16 ---- include/enemy.h | 16 +++- include/entity.h | 13 +-- include/fade.h | 18 ++++ include/fileScreen.h | 1 - include/functions.h | 72 --------------- include/game.h | 8 -- include/greatFairy.h | 29 ------ include/interrupts.h | 6 ++ include/main.h | 1 - include/manager.h | 11 +++ include/npc.h | 47 +++++++++- include/object.h | 17 ++++ include/overworld.h | 63 +++++++++++++ include/random.h | 10 --- include/room.h | 3 + include/screen.h | 1 + include/utils.h | 6 +- linker.ld | 2 - src/audio.c | 21 +++-- src/code_08077B98.c | 120 ++++++++++++++++++++++++- src/code_08077DF4.c | 120 ------------------------- src/code_0808091C.c | 1 + src/collision.c | 2 +- src/coord.c | 1 + src/debugScreen.c | 1 + src/enemy/acroBandits.c | 3 - src/enemy/beetle.c | 3 - src/enemy/bladeTrap.c | 1 + src/enemy/bobomb.c | 3 +- src/enemy/bombPeahat.c | 2 +- src/enemy/businessScrub.c | 3 +- src/enemy/chuchu.c | 3 +- src/enemy/cuccoChickAggr.c | 2 - src/enemy/darkNut.c | 2 - src/enemy/doorMimic.c | 1 + src/enemy/fallingBoulder.c | 2 - src/enemy/fireballGuy.c | 4 - src/enemy/gibdo.c | 3 - src/enemy/gyorgMale.c | 3 - src/enemy/helmasaur.c | 1 - src/enemy/keaton.c | 4 - src/enemy/keese.c | 4 - src/enemy/lakitu.c | 5 -- src/enemy/lakituCloud.c | 1 + src/enemy/leever.c | 4 - src/enemy/likeLike.c | 2 - src/enemy/madderpillar.c | 3 - src/enemy/mazaalBracelet.c | 4 - src/enemy/mazaalHead.c | 7 +- src/enemy/mazaalMacro.c | 4 - src/enemy/miniFireballGuy.c | 3 - src/enemy/miniSlime.c | 3 - src/enemy/moldorm.c | 2 - src/enemy/moldworm.c | 3 - src/enemy/octorok.c | 3 - src/enemy/octorokBoss.c | 7 +- src/enemy/peahat.c | 2 - src/enemy/pesto.c | 4 +- src/enemy/puffstool.c | 3 - src/enemy/rockChuchu.c | 3 - src/enemy/rollobite.c | 2 - src/enemy/rope.c | 4 - src/enemy/rupeeLike.c | 2 + src/enemy/sensorBladeTrap.c | 1 + src/enemy/slime.c | 5 -- src/enemy/sluggula.c | 2 - src/enemy/smallPesto.c | 4 - src/enemy/spearMoblin.c | 3 - src/enemy/spikedBeetle.c | 2 - src/enemy/spinyChuchu.c | 3 - src/enemy/tektite.c | 3 - src/enemy/tektiteGolden.c | 4 - src/enemy/vaatiArm.c | 6 -- src/enemy/vaatiBall.c | 1 + src/enemy/vaatiEyesMacro.c | 3 - src/enemy/vaatiProjectile.c | 2 - src/enemy/vaatiRebornEnemy.c | 6 -- src/enemy/vaatiTransfigured.c | 5 -- src/enemy/vaatiWrath.c | 8 +- src/enemy/vaatiWrathEye.c | 4 +- src/enemy/wallMaster.c | 2 - src/enemy/wallMaster2.c | 1 - src/enemy/waterDrop.c | 2 - src/enemy/wisp.c | 5 -- src/enemyUtils.c | 2 +- src/entity.c | 15 ++-- src/fade.c | 19 ++-- src/fileScreen.c | 1 - src/item/itemPegasusBoots.c | 2 +- src/main.c | 10 ++- src/manager/manager15.c | 1 - src/manager/manager16.c | 2 +- src/manager/manager1C.c | 2 +- src/manager/manager23.c | 1 + src/manager/manager24.c | 2 +- src/manager/manager28.c | 1 + src/manager/manager3.c | 2 +- src/manager/manager31.c | 2 +- src/manager/manager32.c | 4 +- src/manager/manager37.c | 1 + src/manager/manager39.c | 2 +- src/npc.c | 3 +- src/npc/anju.c | 1 - src/npc/beedle.c | 3 +- src/npc/bigGoron.c | 11 +-- src/npc/bladeBrothers.c | 5 +- src/npc/brocco.c | 1 - src/npc/carlov.c | 2 +- src/npc/carpenter.c | 1 - src/npc/castleMaid.c | 3 +- src/npc/castorWildsStatue.c | 2 + src/npc/cat.c | 1 - src/npc/clothesRack.c | 5 +- src/npc/cow.c | 1 - src/npc/cucco.c | 5 +- src/npc/cuccoChick.c | 4 - src/npc/dog.c | 5 -- src/npc/drLeft.c | 7 +- src/npc/ezlo.c | 6 +- src/npc/farmers.c | 3 +- src/npc/forestMinish.c | 9 -- src/npc/gorman.c | 6 +- src/npc/goron.c | 1 + src/npc/goronMerchant.c | 1 + src/npc/guard.c | 3 +- src/npc/kid.c | 3 - src/npc/mailbox.c | 1 + src/npc/melari.c | 8 -- src/npc/milkCart.c | 1 + src/npc/mountainMinish.c | 1 + src/npc/npc23.c | 1 + src/npc/npc26.c | 1 + src/npc/npc4E.c | 1 + src/npc/npc4F.c | 4 +- src/npc/npc5.c | 9 +- src/npc/npc58.c | 1 + src/npc/npc9.c | 3 +- src/npc/pita.c | 6 +- src/npc/postman.c | 3 +- src/npc/rem.c | 8 +- src/npc/simon.c | 1 + src/npc/sittingPerson.c | 5 -- src/npc/smallTownMinish.c | 2 +- src/npc/smith.c | 8 -- src/npc/stamp.c | 1 + src/npc/stockwell.c | 1 + src/npc/sturgeon.c | 1 - src/npc/syrup.c | 4 - src/npc/talon.c | 6 -- src/npc/townMinish.c | 1 - src/npc/townsperson.c | 9 -- src/npc/wheaton.c | 9 +- src/npc/windTribespeople.c | 1 + src/npc/zelda.c | 1 + src/npcUtils.c | 22 ++--- src/object/archway.c | 2 +- src/object/backgroundCloud.c | 4 +- src/object/bakerOven.c | 3 - src/object/bell.c | 3 +- src/object/bird.c | 6 -- src/object/book.c | 6 +- src/object/button.c | 7 +- src/object/cloud.c | 7 -- src/object/fileScreenObjects.c | 6 +- src/object/fireplace.c | 7 +- src/object/floatingBlock.c | 3 +- src/object/frozenFlower.c | 3 +- src/object/giantLeaf.c | 5 +- src/object/greatFairy.c | 35 +++++--- src/object/houseDoorExterior.c | 1 + src/object/jarPortal.c | 7 +- src/object/lightableSwitch.c | 1 + src/object/lilypadSmall.c | 9 +- src/object/lockedDoor.c | 2 +- src/object/mask.c | 8 +- src/object/minecart.c | 5 +- src/object/minishSizedArchway.c | 2 +- src/object/minishSizedEntrance.c | 6 +- src/object/object1A.c | 3 - src/object/object2A.c | 1 + src/object/object49.c | 5 -- src/object/object86.c | 6 +- src/object/objectA.c | 1 + src/object/objectA2.c | 4 - src/object/octorokBossObject.c | 6 +- src/object/palaceArchway.c | 5 +- src/object/pot.c | 1 + src/object/railtrack.c | 1 + src/object/smoke.c | 4 - src/object/thoughtBubble.c | 1 - src/object/treeThorns.c | 1 - src/object/warpPoint.c | 5 +- src/object/windTribeFlag.c | 4 +- src/objectUtils.c | 2 +- src/overworld.c | 83 +++++++++++------ src/player.c | 7 +- src/playerItem/playerItem10.c | 2 +- src/playerItem/playerItem12.c | 1 + src/playerItem/playerItem3.c | 1 + src/playerItem/playerItemBow.c | 1 + src/projectile/dirtBallProjectile.c | 1 + src/projectile/gleerokProjectile.c | 2 +- src/projectile/guardLineOfSight.c | 2 +- src/projectile/gyorgTail.c | 2 +- src/projectile/mandiblesProjectile.c | 4 +- src/projectile/octorokBossProjectile.c | 2 +- src/projectile/v1DarkMagicProjectile.c | 2 +- src/projectile/v1FireProjectile.c | 2 +- src/projectile/v2Projectile.c | 2 +- src/projectile/winder.c | 2 +- src/projectileUtils.c | 2 +- src/room.c | 1 + src/roomInit.c | 6 +- src/save.c | 1 + src/script.c | 30 +++---- src/sub_08055E08.c | 1 + src/sub_0807B820.c | 5 +- src/sub_0807C998.c | 41 --------- src/sub_0807CA18.c | 40 +++++++++ src/sub_08127D30.c | 7 -- src/utils.c | 2 +- 233 files changed, 692 insertions(+), 943 deletions(-) delete mode 100644 include/arm_proxy.h create mode 100644 include/asm.h delete mode 100644 include/cutscene.h create mode 100644 include/fade.h delete mode 100644 include/game.h delete mode 100644 include/greatFairy.h create mode 100644 include/interrupts.h create mode 100644 include/overworld.h delete mode 100644 include/random.h delete mode 100644 src/code_08077DF4.c delete mode 100644 src/sub_0807C998.c delete mode 100644 src/sub_08127D30.c diff --git a/asm/code_0801967C.s b/asm/code_0801967C.s index d4982be5..69ea4740 100644 --- a/asm/code_0801967C.s +++ b/asm/code_0801967C.s @@ -939,7 +939,7 @@ _08019D76: _08019D8C: .4byte gPlayerState _08019D90: .4byte gUnk_0200AF00 _08019D94: - bl sub_08052734 + bl HasDungeonMap cmp r0, #0 bne _08019D9E b _0801A2A4 diff --git a/asm/code_0801D79C.s b/asm/code_0801D79C.s index 8a693cff..d3ffd9a8 100644 --- a/asm/code_0801D79C.s +++ b/asm/code_0801D79C.s @@ -466,7 +466,7 @@ _0801DC04: adds r0, r6, #0 bl sub_0801DF10 mov r8, r0 - bl sub_0805279C + bl HasDungeonBigKey movs r1, #8 adds r1, r1, r6 mov sb, r1 @@ -548,7 +548,7 @@ _0801DCA6: cmp r0, #0 bne _0801DC26 _0801DCAE: - bl sub_0805279C + bl HasDungeonBigKey cmp r0, #0 beq _0801DD16 ldrb r1, [r6, #2] @@ -731,7 +731,7 @@ _0801DDE4: _0801DE14: .4byte gUnk_02032EC0 _0801DE18: .4byte 0x0000FFFF _0801DE1C: - bl sub_080527CC + bl HasDungeonSmallKey cmp r0, #0 beq _0801DE28 movs r0, #2 diff --git a/asm/code_08077B98.s b/asm/code_08077B98.s index 972fafe0..6d889d80 100644 --- a/asm/code_08077B98.s +++ b/asm/code_08077B98.s @@ -741,13 +741,13 @@ _080785B0: ands r0, r1 cmp r0, #0 bne _080785F0 - bl sub_08052734 + bl HasDungeonMap cmp r0, #0 beq _080785C4 movs r0, #1 _080785C4: adds r7, r0, #0 - bl sub_08052764 + bl HasDungeonCompass cmp r0, #0 beq _080785D2 movs r0, #2 diff --git a/asm/code_080A5574.s b/asm/code_080A5574.s index ccc08052..cd023366 100644 --- a/asm/code_080A5574.s +++ b/asm/code_080A5574.s @@ -1344,7 +1344,7 @@ _080A558C: movs r0, #0x87 lsls r0, r0, #7 strh r0, [r5, #8] - bl sub_080527CC + bl HasDungeonSmallKey cmp r0, #0 beq _080A55BE movs r0, #0x18 @@ -1359,7 +1359,7 @@ _080A558C: adds r1, r4, #0 bl sub_080ADA14 _080A55BE: - bl sub_08052764 + bl HasDungeonCompass cmp r0, #0 beq _080A55DE movs r0, #0x2e @@ -1374,7 +1374,7 @@ _080A55BE: adds r1, r4, #0 bl sub_080ADA14 _080A55DE: - bl sub_0805279C + bl HasDungeonBigKey cmp r0, #0 beq _080A563CEU movs r0, #0x45 @@ -1600,7 +1600,7 @@ _080A5D9A: movs r0, #0x87 lsls r0, r0, #7 strh r0, [r5, #8] - bl sub_080527CC + bl HasDungeonSmallKey cmp r0, #0 beq _080A5DCC movs r0, #0x18 @@ -1616,7 +1616,7 @@ _080A5D9A: adds r1, r4, #0 bl sub_080ADA14 _080A5DCC: - bl sub_08052764 + bl HasDungeonCompass cmp r0, #0 beq _080A5DEE movs r0, #0x2e @@ -1632,7 +1632,7 @@ _080A5DCC: adds r1, r4, #0 bl sub_080ADA14 _080A5DEE: - bl sub_0805279C + bl HasDungeonBigKey cmp r0, #0 beq _080A5E48 movs r0, #0x45 diff --git a/asm/fileScreen.s b/asm/fileScreen.s index 94944122..c7b8a3ed 100755 --- a/asm/fileScreen.s +++ b/asm/fileScreen.s @@ -974,7 +974,7 @@ HandleGameOverScreen: @ 0x08052094 cmp r0, #0 beq _080520B8 bl FlushSprites - bl sub_080523D4 + bl DrawGameOverText bl sub_080AD918 _080520B8: pop {r4, pc} diff --git a/asm/non_matching/sub_08077F24.inc b/asm/non_matching/sub_08077F24.inc index e9a5d381..051ccf7a 100644 --- a/asm/non_matching/sub_08077F24.inc +++ b/asm/non_matching/sub_08077F24.inc @@ -1,11 +1,4 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" - .syntax unified - - .text - push {lr} ldr r2, _08077F34 @ =gStats ldrb r3, [r0, #1] diff --git a/data/data_080FC8A4.s b/data/data_080FC8A4.s index db597a8d..ce05a4c6 100644 --- a/data/data_080FC8A4.s +++ b/data/data_080FC8A4.s @@ -93,12 +93,3 @@ gUnk_080FCA70:: @ 080FCA70 .4byte sub_080521A0 .4byte sub_080522F4 .4byte nullsub_107 - -gUnk_080FCA84:: @ 080FCA84 - .incbin "data_080FC8A4/gUnk_080FCA84.bin" - -gUnk_080FCA8C:: @ 080FCA8C - .incbin "data_080FC8A4/gUnk_080FCA8C.bin" - -gUnk_080FCAA4:: @ 080FCAA4 - .incbin "data_080FC8A4/gUnk_080FCAA4.bin" diff --git a/include/arm_proxy.h b/include/arm_proxy.h deleted file mode 100644 index 9364ebf0..00000000 --- a/include/arm_proxy.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef ARM_PROXY_H -#define ARM_PROXY_H - -extern void WaitForNextFrame(void); - -#endif diff --git a/include/asm.h b/include/asm.h new file mode 100644 index 00000000..cd151320 --- /dev/null +++ b/include/asm.h @@ -0,0 +1,25 @@ +#ifndef ASM_H +#define ASM_H + +#include "global.h" + +struct Entity_; + +extern u32 Random(void); +extern void sub_08000152(u32); +extern void SetTile(u32 index, u32 position, u32 layer); +extern void sub_08001242(struct Entity_*); +extern void sub_08001290(struct Entity_*, u32); +extern void sub_08001324(struct Entity_*); +extern u32 sub_08002632(struct Entity_*); +extern u32 sub_08003FC4(struct Entity_*, u32); +extern u32 sub_080043E8(struct Entity_*); +extern void sub_08004484(struct Entity_*, struct Entity_*); +extern u32 sub_080045D4(s16, s16, u32, u32); +extern u32 sub_080045DA(s32, s32); +extern void sub_08004596(struct Entity_*, u32); +extern u32 sub_080045B4(struct Entity_*, u32, u32); +extern u32 EntityInRectRadius(struct Entity_*, struct Entity_*, u32, u32); +extern void UpdateAnimationVariableFrames(struct Entity_*, u32); + +#endif // ASM_H diff --git a/include/audio.h b/include/audio.h index 2add23dd..e5e4c0e4 100644 --- a/include/audio.h +++ b/include/audio.h @@ -5,6 +5,29 @@ #define NUM_BGM 99 +void SoundReq(u32 sound); +extern void EnqueueSFX(u32); + +void InitSound(void); +void InitSoundPlayingInfo(void); +void AudioMain(void); + +typedef struct SoundPlayingInfo { + u16 unk_00; + bool8 stopBgm; + // u8 unk_03; + u16 unk_04; + s16 volumeMasterUnk; + s16 volumeMaster; + s16 volumeMasterTarget; + s16 volumeBgmUnk; + s16 volumeBgm; + s16 volumeBgmTarget; + s16 volumeSfx; + u16 currentBgm; +} SoundPlayingInfo; +extern SoundPlayingInfo gSoundPlayingInfo; + typedef enum { SFX_NONE, // BGM @@ -574,25 +597,4 @@ typedef enum { SONG_BGM_0 = 0x80110000, } Sound; -typedef struct SoundPlayingInfo { - u16 unk_00; - bool8 stopBgm; - // u8 unk_03; - u16 unk_04; - s16 volumeMasterUnk; - s16 volumeMaster; - s16 volumeMasterTarget; - s16 volumeBgmUnk; - s16 volumeBgm; - s16 volumeBgmTarget; - s16 volumeSfx; - u16 currentBgm; -} SoundPlayingInfo; - -extern SoundPlayingInfo gSoundPlayingInfo; - -void InitSound(void); -void SoundReq(Sound sound); -void AudioMain(void); - #endif // AUDIO_H diff --git a/include/coord.h b/include/coord.h index 52dcf210..4b6556e6 100644 --- a/include/coord.h +++ b/include/coord.h @@ -15,6 +15,10 @@ void sub_0806FA90(Entity*, Entity*, s32, s32); void ResolveEntityOnTop(Entity*, Entity*); void ResolveEntityBelow(Entity*, Entity*); +u32 sub_0806F5A4(u32 idx); +u32 sub_0806F3E4(Entity*); +void sub_0806F69C(Entity*); + extern const s16 gSineTable[64]; extern const s16 gCosineTable[256]; diff --git a/include/cutscene.h b/include/cutscene.h deleted file mode 100644 index 72d44fef..00000000 --- a/include/cutscene.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef CUTSCENE_H -#define CUTSCENE_H - -#include "global.h" - -typedef struct { - u32* cutsceneData; - u8 textIndex; - u8 filler[11]; - u16 pauseTime; - u8 filler2[2]; - s32 targetX; - s32 targetY; -} CutsceneBehavior; - -#endif diff --git a/include/enemy.h b/include/enemy.h index 6b187642..8595b8f3 100644 --- a/include/enemy.h +++ b/include/enemy.h @@ -2,8 +2,21 @@ #define ENEMY_H #include "global.h" +#include "asm.h" + +#include "audio.h" +#include "effects.h" +#include "flags.h" +#include "utils.h" + #include "entity.h" +extern u32 GetNextFunction(Entity*); +extern void EnemyFunctionHandler(Entity*, void (*const func[])(Entity*)); +extern void sub_08001324(Entity*); + +extern Entity* sub_0804A9FC(Entity*, u32); + typedef enum { /*0x00*/ OCTOROK, /*0x01*/ CHUCHU, @@ -213,7 +226,4 @@ extern void Enemy64(Entity*); extern void TreeItem(Entity*); extern void Enemy66(Entity*); -extern u32 GetNextFunction(Entity*); -extern void EnemyFunctionHandler(Entity*, void (*const func[])(Entity*)); -extern void sub_08001324(Entity*); #endif diff --git a/include/entity.h b/include/entity.h index 83c3a6c5..43c3b721 100644 --- a/include/entity.h +++ b/include/entity.h @@ -41,9 +41,9 @@ typedef struct { u8 unknown2[3]; } Hitbox3D; -typedef struct Entity { - /*0x00*/ struct Entity* prev; - /*0x04*/ struct Entity* next; +typedef struct Entity_ { + /*0x00*/ struct Entity_* prev; + /*0x04*/ struct Entity_* next; /*0x08*/ u8 kind; /*0x09*/ u8 id; /*0x0a*/ u8 type; @@ -118,9 +118,9 @@ typedef struct Entity { /*0x45*/ u8 health; /*0x46*/ u16 field_0x46; /*0x48*/ Hitbox* hitbox; - /*0x4c*/ struct Entity* field_0x4c; - /*0x50*/ struct Entity* parent; - /*0x54*/ struct Entity* child; + /*0x4c*/ struct Entity_* field_0x4c; + /*0x50*/ struct Entity_* parent; + /*0x54*/ struct Entity_* child; /*0x58*/ u8 animIndex; /*0x59*/ u8 frameDuration; /*0x5a*/ u8 frame; @@ -275,6 +275,7 @@ Entity* FindNextDuplicateID(Entity* ent, int listIndex); */ Entity* FindEntity(u32 kind, u32 id, u32 listIndex, u32 type, u32 type2); +void DeleteManager(void*); void DeleteEntityAny(Entity* ent); void UpdateEntities(void); diff --git a/include/fade.h b/include/fade.h new file mode 100644 index 00000000..7e71a435 --- /dev/null +++ b/include/fade.h @@ -0,0 +1,18 @@ +#ifndef FADE_H +#define FADE_H + +#include "global.h" + +void SetBrightness(u32 arg0); +void DoFade(u32 type, u32 speed); + +void sub_08050008(void); +void sub_08050038(u32); +void sub_080500F4(u32 arg0); +void sub_08050110(u32 param_1, u32 param_2, u32 fadeType, u32 fadeSpeed); + +void InitFade(void); +void FadeMain(void); +void FadeVBlank(void); + +#endif // FADE_H diff --git a/include/fileScreen.h b/include/fileScreen.h index 8cf2304b..04cfa4ba 100644 --- a/include/fileScreen.h +++ b/include/fileScreen.h @@ -59,7 +59,6 @@ extern void sub_0805F46C(u32, void*); extern void RecoverUI(u32 bottomPt, u32 topPt); extern void sub_08080668(void); extern void sub_0805194C(u32); -extern void LoadPalettes(const u8*, int, int); extern struct_02036540* sub_0805F2C8(void); extern void sub_0805F7DC(u32, struct_02036540*); extern void sub_0805F300(struct_02036540*); diff --git a/include/functions.h b/include/functions.h index 293f7e20..cc90e57f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -12,21 +12,16 @@ #include "script.h" // Identified - to be sorted into header files -extern void ShowNPCDialogue(Entity*, Dialog*); -extern void DoFade(u32, u32); extern u32 CheckKinstoneFused(u32); extern void ForceEquipItem(u32, u32); extern void LoadRoomEntityList(EntityData* listPtr); -extern u32 GetAnimationState(Entity*); extern void SetChildOffset(Entity*, s32, s32, s32); extern Entity* CreatePlayerItem(u32, u32, u32, u32); extern u32 GetTileTypeByPos(s32 x, s32 y, u32 layer); extern u32 GetTileType(u32 pos, u32 layer); extern void SetTile(u32, u32, u32); extern void SetDirtTile(u32); -extern void LoadRoomTileEntities(); // tba extern Entity* CreateDeathFx(Entity*, u32, u32); -extern void UpdateAnimationVariableFrames(Entity*, u32); extern u8* GetSpriteSubEntryOffsetDataPointer(u32, u32); extern bool32 LoadFixedGFX(Entity*, u32); extern void CreateItemEntity(u32, u32, u32); @@ -35,20 +30,14 @@ extern void MenuFadeIn(u32, u32); extern void LoadResourceAsync(const void*, u32, u32); extern void LoadPaletteGroup(u32); extern void TryLoadPrologueHyruleTown(void); -extern Manager* GetEmptyManager(void); extern void LoadGfxGroup(u32); -extern void EnqueueSFX(u32); extern void ResetPlayer(void); extern u32 IsItemEquipped(u32); -extern void DeleteManager(Manager*); extern bool32 CheckPlayerInRegion(u32 centerX, u32 centerY, u32 radiusX, u32 radiusY); extern Entity* CreateProjectileWithParent(Entity*, u8, u8); -extern u32 GetBottleContaining(u32); extern u32 GetTileTypeByEntity(Entity*); extern u32 GetSaleItemConfirmMessageID(u32); extern void FlushSprites(void); -extern void DispReset(u32); -extern void InitSoundPlayingInfo(void); extern Entity* CreateProjectile(u32); extern void RegisterPlayerHitbox(); extern s32 GetItemPrice(); @@ -58,41 +47,22 @@ extern void PutItemOnSlot(u32 itemID); extern Entity* CreateSpeechBubbleQuestionMark(Entity*, s32, s32); extern Entity* CreateSpeechBubbleExclamationMark(Entity*, s32, s32); extern Entity* CreateSpeechBubbleSleep(Entity*, s32, s32); -extern u32 CheckPlayerProximity(u32, u32, u32, u32); -extern void ChangeLightLevel(s32); // Unidentified -extern u32 sub_0806ED78(Entity*); -extern u32 sub_0805ACC0(Entity*); -extern u32 sub_0801E99C(Entity*); -extern Entity* sub_080873AC(Entity*, u32, u32); -extern void sub_08078778(Entity*); -extern void sub_080787A8(Entity*, u32); -extern void sub_0806F118(Entity*); extern void sub_080791D0(); extern void sub_0805EC9C(); extern void sub_0805EC60(Entity*); -extern u32 sub_080045D4(s16, s16, u32, u32); -extern void sub_0806F69C(Entity*); extern void sub_0806D0B0(Entity*); extern void sub_0806D02C(Entity*); -extern u32 sub_0806F5A4(u32); -extern void sub_08078784(Entity*, u32); -extern s32 sub_0806ED9C(Entity*, u32, u32); -extern void sub_0807000C(Entity*); -extern void sub_08068BEC(Entity*, u32); -extern s32 sub_0806F078(Entity*, s32); extern void ChangeObjPalette(Entity*, u32); extern void sub_0806FD3C(Entity*); extern void sub_0805ED14(u32*); extern void sub_080A7C18(u32, u32, u32); extern void sub_0804AA30(Entity*, void (*const funcs[])(Entity*)); -extern Entity* sub_0804A9FC(Entity*, u32); extern void sub_0804A720(Entity*); extern u32 sub_080AEFE0(Entity*); extern u32 sub_08049FA0(Entity*); extern u32 sub_08049FDC(Entity*, u32); -extern u32 EntityInRectRadius(Entity*, Entity*, u32, u32); extern u32 sub_08049EE4(Entity*); extern void sub_08077E54(ItemBehavior*); extern void sub_080042BA(Entity*, u32); @@ -111,8 +81,6 @@ extern void sub_080575C8(u32); extern void sub_08057688(void); extern void sub_080580B0(u32); extern void sub_080751E8(u32, u32, void*); -extern void sub_08052CA4(u32, u32, u32, u32); -extern void sub_08052878(void); extern void sub_0808091C(ScreenTransitionData*, u32); extern void sub_0805BC4C(void); extern void sub_0807BB68(u32*, u32, u32); @@ -120,7 +88,6 @@ extern void sub_08054570(void); extern void sub_08059278(void); extern void sub_0804C128(u32); extern void sub_08058324(u32); -extern void sub_0804C2F0(void); extern void sub_0801AFE4(void); extern u32 sub_08060354(void); extern void sub_08057E64(void); @@ -128,7 +95,6 @@ extern void sub_0809F814(u32); extern void sub_080300E8(void); extern void sub_08058D34(void); extern void sub_0807AABC(Entity*); -extern void UpdateGlobalProgress(void); extern void sub_0805B4D0(u32); extern void sub_0804D0B4(void); extern void sub_080534AC(); @@ -137,7 +103,6 @@ extern void sub_0804D9B0(); extern void sub_0807BB98(u32, u32, u32, u32); extern void sub_0801D000(u32); extern void sub_08018C58(u32); -extern void sub_0804E150(void); extern void sub_080AF284(void); extern void sub_080A71C4(u32, u32, u32, u32); extern void sub_08054564(); @@ -150,7 +115,6 @@ extern s32 sub_0801CFA8(u32); extern void sub_080ADA14(u32, u32); // trampoline to sub_080B27F4 extern void sub_0801E1B8(u32, u32); extern void sub_0801E1EC(s32, s32, s32); -extern void sub_08050008(void); extern void sub_080A3B74(void); extern void sub_080A4054(void); extern void sub_0801C1D4(void); @@ -161,25 +125,16 @@ extern void sub_080A4528(void); extern void sub_080A4398(void); extern void sub_0801E738(u32); extern void sub_080A7114(u32); -extern void sub_08001324(Entity*); -extern void sub_08001242(Entity*); -extern u32 sub_08003FC4(Entity*, u32); -extern u32 sub_080043E8(Entity*); -extern void sub_08001290(Entity*, u32); -extern void sub_08004596(Entity*, u32); -extern u32 sub_080045B4(Entity*, u32, u32); extern u32 sub_0807953C(void); extern void sub_080AE068(Entity*); extern u32 sub_0800445C(Entity*); extern void sub_0807A108(void); extern u32 sub_0801766C(Entity*); extern void sub_08004168(Entity*); -extern u32 sub_08052638(u32); extern void sub_08056208(void); extern void sub_08050384(); extern u32 sub_0806F520(); extern void sub_0806F4E8(Entity*); -extern u32 sub_0806F3E4(Entity*); extern void sub_0804A7D4(Entity*); extern void sub_08033744(Entity*); extern void sub_0800417E(Entity*, u32); @@ -197,10 +152,8 @@ extern void sub_08079938(); extern void sub_0807ACCC(Entity*); extern void sub_080A2BE4(Entity*, u32); extern u32 sub_08097ADC(Entity*); -extern void sub_08097B24(Entity*); extern u32 sub_08079F8C(void); extern void sub_080787CC(Entity*); -extern void sub_080526F8(s32); extern u32 sub_080044EC(Entity*, u32); extern u32 sub_080002B8(Entity*); extern u32 sub_08049F84(Entity*, u32); @@ -215,7 +168,6 @@ extern void sub_08080CB4(Entity*); extern u32 sub_0800442E(Entity*); extern void sub_08081404(Entity*, u32); extern void sub_0807B7D8(u32, u32, u32); -extern void RegisterTransitionManager(void*, void (*)(), void (*)()); extern void sub_0800451C(Entity*); extern u32 sub_080002F0(u32, u32, u32); extern u32 sub_080040D8(Entity*, u8*, s32, s32); @@ -227,7 +179,6 @@ extern void sub_080026C4(u8*, u8*, u8*, u32); extern void sub_080026F2(u8*, void*, u8*, u32); extern u32 sub_0805F7A0(u32); extern u32* sub_0805F25C(u32); -extern u32 sub_080045DA(s32, s32); u32 sub_0806FCB8(Entity*, u32, u32, u32); extern void sub_080A1D70(Entity*, u32); extern void sub_0806F62C(Entity*, u32, u32); @@ -235,13 +186,6 @@ extern void sub_080A1ED0(u32, u32, u32); extern u32 sub_0806F5B0(u32); extern void sub_0801DFB4(Entity*, u32, u32, u32); extern void sub_0801E00C(); -extern void sub_08050038(u32); -extern void sub_080500F4(u32); -extern void sub_08050110(u32, u32, u32, u32); -extern u32 sub_08052734(); // has Dungeon Map? -extern u32 sub_08052764(); // has Dungeon Compass? -extern u32 sub_0805279C(); // has Dungeon Big Key? -extern u32 sub_080527CC(); // num Dungeon small keys? extern void sub_08078790(Entity*, u32); extern void sub_080788E0(Entity*); extern void sub_08078AA8(u32, u32); @@ -259,17 +203,7 @@ extern u32 sub_08079FC4(u32); extern void sub_0800455E(Entity*); extern u32* sub_08008790(Entity*, u32); extern void sub_0804ACF8(); -extern void sub_08073904(Entity*); -extern u32 CheckHeaderValid(void); -extern void sub_08004484(Entity*, Entity*); extern void sub_0805F8E4(u32 r0, WStruct* r1); -extern u32 sub_08002632(Entity*); -extern void sub_0807879C(Entity*); -extern void sub_080787C0(Entity*); -extern void sub_080787B4(Entity*); -extern void sub_0808C650(Entity*, u32); -extern u32 sub_0808C67C(void); -extern void sub_0808C688(void); extern Entity* sub_08077C94(ItemBehavior*, u32); extern Entity* sub_08077C0C(ItemBehavior*, u32); @@ -287,12 +221,6 @@ extern void sub_080042D0(Entity*, u32, u16); extern u32 sub_080002A8(u32, u32, u32); extern void sub_080806BC(u32, u32, u32, u32); -extern void sub_080186C0(u32); -extern void sub_0801855C(void); - -extern u32 sub_0807CAEC(u32); -extern void sub_0807CAC8(u32); extern void LoadObjPalette(Entity*, u32); -void sub_0804B3C4(void*); #endif diff --git a/include/game.h b/include/game.h deleted file mode 100644 index fb9d486b..00000000 --- a/include/game.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef GAME_H -#define GAME_H - -#include "gba/types.h" - -u32 CheckIsDungeon(void); - -#endif // GAME_H diff --git a/include/greatFairy.h b/include/greatFairy.h deleted file mode 100644 index 461b83f9..00000000 --- a/include/greatFairy.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef GREATFAIRY_H -#define GREATFAIRY_H - -#include "entity.h" -#include "screen.h" - -void GreatFairy_InitializeAnimation(Entity*); -Entity* GreatFairy_CreateForm(Entity*, u32, u32); -void sub_080873D0(); -extern void (*const GreatFairy_Main[])(Entity*); -extern void (*const GreatFairy_Behaviors[])(Entity*); -extern void (*const GreatFairy_WingsBehaviors[])(Entity*); -extern void (*const GreatFairy_WakeBehaviors[])(Entity*); -extern void (*const GreatFairy_MiniBehaviors[])(Entity*); -extern void (*const GreatFairy_MiniAffineBehaviors[])(Entity*); -extern void (*const GreatFairy_DropletBehaviors[])(Entity*); -extern void (*const GreatFairy_RippleBehaviors[])(Entity*); -extern void (*const GreatFairy_BigRippleBehaviors[])(Entity*); -extern void (*const GreatFairy_EnergyBehaviors[])(Entity*); -extern void (*const GreatFairy_Form1Behaviors[])(Entity*); -extern void (*const GreatFairy_Form2Behaviors[])(Entity*); -extern void (*const gUnk_081207A4[])(Entity*); - -extern u32 gUnk_0810C2E4; -extern const s16 GreatFairy_RippleOffsets[10]; -extern u8 gUnk_0812079C[8]; -extern s8 gUnk_081207AC[]; - -#endif diff --git a/include/interrupts.h b/include/interrupts.h new file mode 100644 index 00000000..b1952acd --- /dev/null +++ b/include/interrupts.h @@ -0,0 +1,6 @@ +#ifndef INTERRUPTS_H +#define INTERRUPTS_H + +extern void WaitForNextFrame(void); + +#endif // INTERRUPTS_H diff --git a/include/main.h b/include/main.h index c9675bfe..d5ffda2e 100644 --- a/include/main.h +++ b/include/main.h @@ -92,7 +92,6 @@ void InitScreen(u32 screen); void InitDMA(void); extern void sub_08056208(void); -extern void InitFade(void); extern void ResetPalettes(void); extern void DoSoftReset(void); diff --git a/include/manager.h b/include/manager.h index 013678b2..e18c51e8 100644 --- a/include/manager.h +++ b/include/manager.h @@ -230,4 +230,15 @@ extern void Manager39_Main(); extern void (*const gManagerFunctions[58])(); +Manager* GetEmptyManager(void); + +/** + * @brief Set manager responsible for handling room changes + */ +extern void RegisterTransitionManager(void* mgr, void (*onEnter)(), void (*onExit)()); + +extern u32 sub_0805ACC0(Entity*); +extern void sub_0801855C(void); +extern void sub_080186C0(u32); + #endif diff --git a/include/npc.h b/include/npc.h index bf49ef0a..d67652de 100644 --- a/include/npc.h +++ b/include/npc.h @@ -1,9 +1,50 @@ +#ifndef NPC_H +#define NPC_H + #include "global.h" +#include "asm.h" +#include "utils.h" + +#include "audio.h" +#include "effects.h" +#include "room.h" +#include "flags.h" +#include "coord.h" +#include "textbox.h" +#include "script.h" +#include "save.h" + #include "entity.h" #include "player.h" -#ifndef NPC_H -#define NPC_H +#include "structures.h" + +void sub_0806EC20(Entity* ent); +void sub_0806EC38(void); +u32 sub_0806ED78(Entity* ent); +s32 sub_0806ED9C(Entity*, u32, u32); +u32 GetAnimationState(Entity* ent); +s32 sub_0806EDD8(Entity* ent, u32 x, u32 y); +void sub_0806EE04(Entity* ent, void* a2, u32 a3); +u32 sub_0806EE20(Entity* ent); +s32 sub_0806F078(Entity* ent, s32 a2); +void sub_0806F118(Entity* ent); +void sub_0806F188(Entity* ent); +void ShowNPCDialogue(Entity* ent, Dialog* dia); + +Entity* CreateNPC(u32 subtype, u32 form, u32 parameter); +u32 UpdateFuseInteraction(Entity*); + +void NPCInit(Entity* ent); +void sub_0806F0A4(void); + +// TODO move? +void sub_08078784(Entity* ent, u32 arg1); +u32 sub_0806F5A4(u32); +u32 sub_0801E99C(Entity*); +void sub_08078778(Entity*); +void sub_0807000C(Entity*); +void sub_080787A8(Entity*, u32); enum NPC { /*0x00*/ NPC_NONE_0, @@ -297,8 +338,6 @@ extern void Phonograph(Entity*); extern void NPC58(Entity*); extern void NPC58_Head(Entity*); -extern u32 UpdateFuseInteraction(Entity*); - extern void (*const gNPCFunctions[128][3])(Entity*); #endif diff --git a/include/object.h b/include/object.h index 1a219e09..20515a6e 100644 --- a/include/object.h +++ b/include/object.h @@ -2,7 +2,24 @@ #define OBJECT_H #include "global.h" +#include "asm.h" +#include "utils.h" + +#include "audio.h" +#include "flags.h" +#include "effects.h" +#include "room.h" +#include "coord.h" + #include "entity.h" +#include "player.h" + +extern void sub_0807879C(Entity*); +extern void sub_080787C0(Entity*); +extern void sub_080787B4(Entity*); +extern void sub_0808C650(Entity*, u32); +extern u32 sub_0808C67C(void); +extern void sub_0808C688(void); typedef enum { GROUND_ITEM, diff --git a/include/overworld.h b/include/overworld.h new file mode 100644 index 00000000..2ffa87d9 --- /dev/null +++ b/include/overworld.h @@ -0,0 +1,63 @@ +#ifndef OVERWORLD_H +#define OVERWORLD_H + +#include "global.h" +#include "area.h" + +void ChangeLightLevel(s32); +void SetPopupState(u32 type, u32 choice_idx); + +bool32 CheckIsOverworld(void); +bool32 sub_08052638(u32 r0); +#ifndef EU +u32 sub_08052654(void); +#endif +u32 CheckIsDungeon(void); +u32 CheckIsInteriorWithEnemies(void); +u32 CheckIsInteriorNoEnemies(void); +u32 CheckHasMap(void); + +s32 ModHealth(s32 deltaHealth); +void ModRupees(s32 rupeeDelta); + +void sub_080526F8(s32 a1); +u32 sub_08052724(void); +u32 HasDungeonMap(void); +u32 HasDungeonCompass(void); +u32 HasDungeonBigKey(void); +u32 HasDungeonSmallKey(void); + +void sub_080527FC(u32 a1, u32 a2); +#ifndef EU +void sub_08052878(void); +#endif + +void RoomExitCallback(void); +void InitParachuteRoom(void); +u32 sub_08052B24(void); +void DisplayEzloMessage(void); + +void sub_08052CA4(u32 area, u32 room, u32 x, u32 y); +void sub_08052CD0(u32 area, u32 room, u32 x, u32 y); + +void sub_08052CFC(void); + +/** + * @brief Get bank offset for area + */ +u32 GetFlagBankOffset(u32 idx); + +RoomResInfo* GetCurrentRoomInfo(void); +void sub_08052EA0(void); +void sub_08052FD8(u32 room, u32 area); +void UpdateGlobalProgress(void); +void sub_08053250(void); +void sub_08053320(void); +void sub_080533CC(void); +void sub_08053494(void); +void sub_080534AC(void); +void sub_08053500(void); + +u32 GetBottleContaining(u32); + +#endif // OVERWORLD_H diff --git a/include/random.h b/include/random.h deleted file mode 100644 index d2c7f3d7..00000000 --- a/include/random.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef RANDOM_H -#define RANDOM_H - -#include "gba/types.h" - -extern u32 Random(void); - -extern u32 gRand; - -#endif diff --git a/include/room.h b/include/room.h index fb706547..efaed68b 100644 --- a/include/room.h +++ b/include/room.h @@ -175,5 +175,8 @@ extern void SetTileType(u32, u32, u32); extern void sub_08080964(u32 time, u32 magnitude); // shake screen extern void* GetCurrentRoomProperty(u32); +extern void LoadRoomTileEntities(); + +void sub_0804B3C4(void*); #endif diff --git a/include/screen.h b/include/screen.h index aaca4ef6..18962f80 100644 --- a/include/screen.h +++ b/include/screen.h @@ -2,6 +2,7 @@ #define BG_H #include "global.h" +#include "fade.h" typedef struct { u16 displayControl; diff --git a/include/utils.h b/include/utils.h index 19c57f14..8cb3e8d1 100644 --- a/include/utils.h +++ b/include/utils.h @@ -38,7 +38,7 @@ void MemCopy(const void* src, void* dest, u32 size); */ void ReadKeyInput(void); -void LoadPalettes(const u8*, int, int); +void LoadPalettes(const u8*, s32, s32); void LoadPaletteGroup(u32 group); void SetColor(u32 colorIndex, u32 color); void SetFillColor(u32 color, u32 arg1); @@ -70,4 +70,6 @@ void zFree(void* ptr); */ void DispReset(bool32 updateHUD); -#endif \ No newline at end of file +u32 CheckPlayerProximity(u32, u32, u32, u32); + +#endif diff --git a/linker.ld b/linker.ld index 896a56fb..852b72cf 100644 --- a/linker.ld +++ b/linker.ld @@ -677,13 +677,11 @@ SECTIONS { asm/code_08077698.o(.text); asm/respawnPlayer.o(.text); src/code_08077B98.o(.text); - src/code_08077DF4.o(.text); asm/code_08077B98.o(.text); src/code_08078778.o(.text); asm/code_08078778.o(.text); src/sub_0807B820.o(.text); asm/code_0807B9B8.o(.text); - src/sub_0807C998.o(.text); src/sub_0807CA18.o(.text); asm/getInventoryValue.o(.text); asm/code_0807CAA0.o(.text); diff --git a/src/audio.c b/src/audio.c index 1da1714a..16e22303 100644 --- a/src/audio.c +++ b/src/audio.c @@ -7,12 +7,11 @@ #define IS_BGM(song) (song) - 1 <= NUM_BGM - 1 #define IS_SFX(song) (song) - 1 > NUM_BGM - 1 -void InitSoundPlayingInfo(void); -s32 fade(s32 target, s32 current); -void doPlaySound(u32 sound); -void PlayFadeIn(u32 sound); -void PlayFadeOut(u32 sound); -void InitVolume(void); +static s32 fade(s32 target, s32 current); +static void doPlaySound(u32 sound); +static void PlayFadeIn(u32 sound); +static void PlayFadeOut(u32 sound); +static void InitVolume(void); void InitSound(void) { InitSoundPlayingInfo(); @@ -182,7 +181,7 @@ void AudioMain(void) { } } -s32 fade(s32 target, s32 current) { +static s32 fade(s32 target, s32 current) { if (target - current >= 1) { current += 4; if (target > current) @@ -196,7 +195,7 @@ s32 fade(s32 target, s32 current) { } } -void doPlaySound(u32 sound) { +static void doPlaySound(u32 sound) { u32 volume; MusicPlayerInfo* musicPlayerInfo; @@ -214,17 +213,17 @@ void doPlaySound(u32 sound) { m4aMPlayVolumeControl(musicPlayerInfo, 0xffff, volume); } -void PlayFadeIn(u32 sound) { +static void PlayFadeIn(u32 sound) { gSoundPlayingInfo.volumeMasterTarget = 0x100; doPlaySound(sound); } -void PlayFadeOut(u32 sound) { +static void PlayFadeOut(u32 sound) { gSoundPlayingInfo.volumeMasterTarget = 0; doPlaySound(sound); } -void InitVolume() { +static void InitVolume() { gSoundPlayingInfo.volumeMasterUnk = 0x100; gSoundPlayingInfo.volumeMaster = 0x100; gSoundPlayingInfo.volumeMasterTarget = 0x100; diff --git a/src/code_08077B98.c b/src/code_08077B98.c index ca36a700..eb3dcd88 100644 --- a/src/code_08077B98.c +++ b/src/code_08077B98.c @@ -1,7 +1,5 @@ -#include "global.h" -#include "entity.h" -#include "player.h" #include "functions.h" +#include "object.h" typedef struct { u8 unk[12]; @@ -122,4 +120,118 @@ Entity* sub_08077CF8(u32 subtype, u32 form, u32 parameter, u32 unk) { return ent; } -ASM_FUNC("asm/non_matching/sub_08077D38.inc", void sub_08077D38(ItemBehavior* beh, u32 arg1)) +ASM_FUNC("asm/non_matching/sub_08077D38.inc", void sub_08077D38(ItemBehavior* beh, u32 arg1)); + +typedef struct { + u8 b0 : 4; + u8 b1 : 4; +} PACKED Unk_bitfield; + +typedef struct { + u8 unk[16]; +} Unk_struct; + +void sub_08077DF4(ItemBehavior* beh, u32 arg1) { + Entity* ent = (Entity*)beh; // @nocheckin + *(u16*)&ent->flags = arg1; + if ((arg1 & 0xff) > 0xb8) { + arg1 += ent->type >> 1; + } + gPlayerEntity.spriteIndex = (short)(arg1 >> 8); + InitAnimationForceUpdate(&gPlayerEntity, (u8)arg1); + sub_08077E54(beh); +} + +void UpdateItemAnim(ItemBehavior* beh) { + UpdateAnimationSingleFrame(&gPlayerEntity); + sub_08077E54(beh); +} + +void sub_08077E3C(ItemBehavior* ent, u32 idx) { + sub_080042BA(&gPlayerEntity, idx); + sub_08077E54(ent); +} + +void sub_08077E54(ItemBehavior* beh) { + Entity* ent = (Entity*)beh; // @nocheckin + ent->action = gPlayerEntity.animIndex; + *(u8*)&ent->spriteIndex = gPlayerEntity.frameIndex; + ent->subAction = gPlayerEntity.frameDuration; + ent->actionDelay = gPlayerEntity.frame; +} + +void sub_08077E78(ItemBehavior* arg0, u32 bits) { + u32 not ; + + if (bits == 0) { + if (gPlayerState.field_0x2c != NULL) { + ((Unk_bitfield*)gPlayerState.field_0x2c)[0x11].b0 = 6; + gPlayerState.field_0x2c = (u8*)bits; + } else { + gPlayerState.field_0x2c = (u8*)bits; + } + } + + not = (8 >> bits); + gPlayerState.field_0x3[1] &= ~((u8)((8 >> bits) << 4) | not ); + not = ~not ; + gPlayerState.field_0xa &= not ; + gPlayerState.keepFacing &= not ; + MemClear(arg0, 0x1c); +} + +u32 sub_08077EC8(ItemBehavior* beh) { + Unk_struct* arg0 = (Unk_struct*)beh; // @nocheckin + + if ((gPlayerState.field_0x1a[1] & 8) != 0) { + sub_08077DF4(beh, 0x170); + arg0->unk[7] = 0x28; + arg0->unk[4] = 7; + arg0->unk[15] = 6; + return 1; + } else { + return 0; + } +} + +bool32 sub_08077EFC(ItemBehavior* arg0) { + return sub_08077F24(arg0, (u16)gPlayerState.field_0x90.HALF.LO); +} + +bool32 sub_08077F10(ItemBehavior* arg0) { + return sub_08077F24(arg0, (u16)gPlayerState.field_0x90.HALF.HI); +} + +ASM_FUNC("asm/non_matching/sub_08077F24.inc", bool32 sub_08077F24(ItemBehavior* beh, u32 arg1)) + +void sub_08077F50(ItemBehavior* beh, u32 arg1) { + sub_08079184(); + sub_08077E78(beh, arg1); +} + +u32 sub_08077F64(ItemBehavior* arg0, u32 unk) { + u32 temp; + if (gPlayerState.heldObject == 0) { + sub_08077F50(arg0, unk); + temp = 0; + } else { + temp = 1; + } + return temp; +} + +void sub_08077F84(void) { + Entity* obj; + + if (((gPlayerEntity.collisionLayer & 2) == 0) && + GetTileTypeByPos(gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI - 0xc, 2) - 0x343U < 4) { + sub_0807AA80(&gPlayerEntity); + gPlayerState.jumpStatus |= 8; + obj = CreateObject(OBJECT_44, 0, 0); + if (obj != NULL) { + obj->x = gPlayerEntity.x; + obj->y.HALF.HI = gPlayerEntity.y.HALF.HI - 0xc; + gPlayerEntity.y.HALF.HI -= 0xc; + } + } +} diff --git a/src/code_08077DF4.c b/src/code_08077DF4.c deleted file mode 100644 index 89246080..00000000 --- a/src/code_08077DF4.c +++ /dev/null @@ -1,120 +0,0 @@ -#include "global.h" -#include "entity.h" -#include "player.h" -#include "utils.h" -#include "object.h" -#include "functions.h" - -typedef struct { - u8 b0 : 4; - u8 b1 : 4; -} PACKED Unk_bitfield; - -typedef struct { - u8 unk[16]; -} Unk_struct; - -void sub_08077DF4(ItemBehavior* beh, u32 arg1) { - Entity* ent = (Entity*)beh; // @nocheckin - *(u16*)&ent->flags = arg1; - if ((arg1 & 0xff) > 0xb8) { - arg1 += ent->type >> 1; - } - gPlayerEntity.spriteIndex = (short)(arg1 >> 8); - InitAnimationForceUpdate(&gPlayerEntity, (u8)arg1); - sub_08077E54(beh); -} - -void UpdateItemAnim(ItemBehavior* beh) { - UpdateAnimationSingleFrame(&gPlayerEntity); - sub_08077E54(beh); -} - -void sub_08077E3C(ItemBehavior* ent, u32 idx) { - sub_080042BA(&gPlayerEntity, idx); - sub_08077E54(ent); -} - -void sub_08077E54(ItemBehavior* beh) { - Entity* ent = (Entity*)beh; // @nocheckin - ent->action = gPlayerEntity.animIndex; - *(u8*)&ent->spriteIndex = gPlayerEntity.frameIndex; - ent->subAction = gPlayerEntity.frameDuration; - ent->actionDelay = gPlayerEntity.frame; -} - -void sub_08077E78(ItemBehavior* arg0, u32 bits) { - u32 not ; - - if (bits == 0) { - if (gPlayerState.field_0x2c != NULL) { - ((Unk_bitfield*)gPlayerState.field_0x2c)[0x11].b0 = 6; - gPlayerState.field_0x2c = (u8*)bits; - } else { - gPlayerState.field_0x2c = (u8*)bits; - } - } - - not = (8 >> bits); - gPlayerState.field_0x3[1] &= ~((u8)((8 >> bits) << 4) | not ); - not = ~not ; - gPlayerState.field_0xa &= not ; - gPlayerState.keepFacing &= not ; - MemClear(arg0, 0x1c); -} - -u32 sub_08077EC8(ItemBehavior* beh) { - Unk_struct* arg0 = (Unk_struct*)beh; // @nocheckin - - if ((gPlayerState.field_0x1a[1] & 8) != 0) { - sub_08077DF4(beh, 0x170); - arg0->unk[7] = 0x28; - arg0->unk[4] = 7; - arg0->unk[15] = 6; - return 1; - } else { - return 0; - } -} - -bool32 sub_08077EFC(ItemBehavior* arg0) { - return sub_08077F24(arg0, (u16)gPlayerState.field_0x90.HALF.LO); -} - -bool32 sub_08077F10(ItemBehavior* arg0) { - return sub_08077F24(arg0, (u16)gPlayerState.field_0x90.HALF.HI); -} - -ASM_FUNC("asm/non_matching/sub_08077F24.inc", bool32 sub_08077F24(ItemBehavior* beh, u32 arg1)) - -void sub_08077F50(ItemBehavior* beh, u32 arg1) { - sub_08079184(); - sub_08077E78(beh, arg1); -} - -u32 sub_08077F64(ItemBehavior* arg0, u32 unk) { - u32 temp; - if (gPlayerState.heldObject == 0) { - sub_08077F50(arg0, unk); - temp = 0; - } else { - temp = 1; - } - return temp; -} - -void sub_08077F84(void) { - Entity* obj; - - if (((gPlayerEntity.collisionLayer & 2) == 0) && - GetTileTypeByPos(gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI - 0xc, 2) - 0x343U < 4) { - sub_0807AA80(&gPlayerEntity); - gPlayerState.jumpStatus |= 8; - obj = CreateObject(OBJECT_44, 0, 0); - if (obj != NULL) { - obj->x = gPlayerEntity.x; - obj->y.HALF.HI = gPlayerEntity.y.HALF.HI - 0xc; - gPlayerEntity.y.HALF.HI -= 0xc; - } - } -} diff --git a/src/code_0808091C.c b/src/code_0808091C.c index 4e9d7561..ab3ceb11 100644 --- a/src/code_0808091C.c +++ b/src/code_0808091C.c @@ -2,6 +2,7 @@ #include "entity.h" #include "structures.h" #include "functions.h" +#include "overworld.h" #include "room.h" extern void sub_08080BC4(void); diff --git a/src/collision.c b/src/collision.c index 9d3380e4..cadaf421 100644 --- a/src/collision.c +++ b/src/collision.c @@ -1,8 +1,8 @@ #include "global.h" +#include "asm.h" #include "entity.h" #include "player.h" #include "save.h" -#include "random.h" #include "utils.h" #include "functions.h" #include "enemy.h" diff --git a/src/coord.c b/src/coord.c index 3fe17296..7bad978a 100644 --- a/src/coord.c +++ b/src/coord.c @@ -1,3 +1,4 @@ +#include "asm.h" #include "area.h" #include "player.h" #include "global.h" diff --git a/src/debugScreen.c b/src/debugScreen.c index dcd22601..c3ddf710 100644 --- a/src/debugScreen.c +++ b/src/debugScreen.c @@ -1,4 +1,5 @@ #include "global.h" +#include "audio.h" #include "utils.h" #include "functions.h" #include "main.h" diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index c4784ee0..e43a8f39 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -1,7 +1,4 @@ -#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/beetle.c b/src/enemy/beetle.c index b2b3e5ed..997f4faf 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -1,7 +1,4 @@ -#include "entity.h" #include "enemy.h" -#include "player.h" -#include "random.h" #include "functions.h" extern u32 PlayerInRange(Entity*, u32, u32); diff --git a/src/enemy/bladeTrap.c b/src/enemy/bladeTrap.c index 66729fce..70fd869c 100644 --- a/src/enemy/bladeTrap.c +++ b/src/enemy/bladeTrap.c @@ -1,4 +1,5 @@ #include "global.h" +#include "audio.h" #include "entity.h" #include "room.h" #include "functions.h" diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index b9976950..9a68209d 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -1,5 +1,6 @@ +#include "asm.h" +#include "audio.h" #include "enemy.h" -#include "random.h" #include "createObject.h" #include "object.h" #include "functions.h" diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index 187670e9..71e0540d 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -1,8 +1,8 @@ +#include "asm.h" #include "global.h" #include "entity.h" #include "enemy.h" #include "player.h" -#include "random.h" #include "object.h" #include "functions.h" diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index 6e75d855..e53d46e5 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -1,9 +1,10 @@ +#include "asm.h" #include "enemy.h" +#include "audio.h" #include "entity.h" #include "flags.h" #include "textbox.h" #include "save.h" -#include "random.h" #include "npc.h" #include "functions.h" #include "effects.h" diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c index c6c83615..f14b400c 100644 --- a/src/enemy/chuchu.c +++ b/src/enemy/chuchu.c @@ -1,7 +1,8 @@ +#include "asm.h" #include "enemy.h" #include "entity.h" -#include "random.h" #include "functions.h" +#include "audio.h" extern s32 sub_080012DC(Entity*); extern void sub_08001318(Entity*); diff --git a/src/enemy/cuccoChickAggr.c b/src/enemy/cuccoChickAggr.c index d3295203..abb416f2 100644 --- a/src/enemy/cuccoChickAggr.c +++ b/src/enemy/cuccoChickAggr.c @@ -1,6 +1,4 @@ #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 e9061ad0..ed6d602b 100644 --- a/src/enemy/darkNut.c +++ b/src/enemy/darkNut.c @@ -1,6 +1,4 @@ -#include "entity.h" #include "enemy.h" -#include "random.h" #include "functions.h" typedef struct { diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c index 713ace16..ab1531fb 100644 --- a/src/enemy/doorMimic.c +++ b/src/enemy/doorMimic.c @@ -1,3 +1,4 @@ +#include "audio.h" #include "enemy.h" #include "entity.h" #include "functions.h" diff --git a/src/enemy/fallingBoulder.c b/src/enemy/fallingBoulder.c index 6084d868..7e4ddde1 100644 --- a/src/enemy/fallingBoulder.c +++ b/src/enemy/fallingBoulder.c @@ -1,7 +1,5 @@ #include "enemy.h" -#include "random.h" #include "functions.h" -#include "effects.h" void sub_0802C4B0(Entity*); void sub_0802C62C(Entity*); diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c index c6e0123e..afcc4ac7 100644 --- a/src/enemy/fireballGuy.c +++ b/src/enemy/fireballGuy.c @@ -1,9 +1,5 @@ -#include "global.h" -#include "entity.h" #include "enemy.h" -#include "random.h" #include "functions.h" -#include "effects.h" typedef struct { s8 h, v; diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c index 59e03862..912f0f61 100644 --- a/src/enemy/gibdo.c +++ b/src/enemy/gibdo.c @@ -1,8 +1,5 @@ #include "global.h" -#include "entity.h" -#include "sprite.h" #include "enemy.h" -#include "random.h" #include "object.h" #include "functions.h" // Gibudo diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c index 855a66dc..40497928 100644 --- a/src/enemy/gyorgMale.c +++ b/src/enemy/gyorgMale.c @@ -1,10 +1,7 @@ #include "global.h" #include "enemy.h" #include "player.h" -#include "room.h" -#include "coord.h" #include "fileScreen.h" -#include "random.h" #include "functions.h" #include "effects.h" diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 0bb1c1c4..594c8800 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -1,5 +1,4 @@ #include "enemy.h" -#include "random.h" #include "object.h" #include "functions.h" diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c index b5bbef3f..6c551e9c 100644 --- a/src/enemy/keaton.c +++ b/src/enemy/keaton.c @@ -1,9 +1,5 @@ -#include "global.h" -#include "entity.h" #include "enemy.h" -#include "random.h" #include "functions.h" -#include "effects.h" extern Entity* gUnk_020000B0; diff --git a/src/enemy/keese.c b/src/enemy/keese.c index 92d3ff86..1b3c4e11 100644 --- a/src/enemy/keese.c +++ b/src/enemy/keese.c @@ -1,8 +1,4 @@ -#include "global.h" -#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 8e4ae08e..85d80ee3 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -1,11 +1,6 @@ #include "global.h" -#include "entity.h" #include "enemy.h" #include "functions.h" -#include "coord.h" -#include "random.h" -#include "player.h" -#include "effects.h" extern void (*const LakituActionFuncs[])(Entity*); diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c index f847b0bd..f391c5ee 100644 --- a/src/enemy/lakituCloud.c +++ b/src/enemy/lakituCloud.c @@ -1,4 +1,5 @@ #include "global.h" +#include "asm.h" #include "entity.h" #include "player.h" #include "functions.h" diff --git a/src/enemy/leever.c b/src/enemy/leever.c index d5b8e3de..e7624432 100644 --- a/src/enemy/leever.c +++ b/src/enemy/leever.c @@ -1,9 +1,5 @@ -#include "global.h" -#include "entity.h" #include "enemy.h" -#include "random.h" #include "functions.h" -#include "coord.h" extern u32 sub_080002D4(s32, s32, u32); extern u32 sub_080002BC(s32, s32, u32); diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index 42e8d88f..3bba9493 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -1,8 +1,6 @@ #include "enemy.h" -#include "entity.h" #include "textbox.h" #include "save.h" -#include "random.h" #include "createObject.h" #include "functions.h" diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c index 45ac8b27..11742547 100644 --- a/src/enemy/madderpillar.c +++ b/src/enemy/madderpillar.c @@ -1,8 +1,5 @@ #include "enemy.h" -#include "entity.h" -#include "random.h" #include "functions.h" -#include "effects.h" extern u8 gEntCount; extern Hitbox gUnk_080FD298; diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index eb32b41b..d0db11ed 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -1,10 +1,6 @@ -#include "global.h" #include "enemy.h" -#include "audio.h" -#include "random.h" #include "object.h" #include "functions.h" -#include "effects.h" void sub_0803B538(Entity*); u32 sub_0803B4E4(Entity*); diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c index b282e776..a96e4f84 100644 --- a/src/enemy/mazaalHead.c +++ b/src/enemy/mazaalHead.c @@ -1,12 +1,7 @@ -#include "global.h" -#include "entity.h" #include "enemy.h" -#include "screen.h" -#include "audio.h" -#include "random.h" #include "object.h" #include "functions.h" -#include "effects.h" +#include "screen.h" extern void UnloadOBJPalette(Entity*); diff --git a/src/enemy/mazaalMacro.c b/src/enemy/mazaalMacro.c index 89eed0d1..ed28d6c8 100644 --- a/src/enemy/mazaalMacro.c +++ b/src/enemy/mazaalMacro.c @@ -1,11 +1,7 @@ -#include "global.h" -#include "entity.h" #include "enemy.h" -#include "random.h" #include "script.h" #include "structures.h" #include "functions.h" -#include "effects.h" extern void sub_0807B600(u32); diff --git a/src/enemy/miniFireballGuy.c b/src/enemy/miniFireballGuy.c index 7f538b1b..cca05ed4 100644 --- a/src/enemy/miniFireballGuy.c +++ b/src/enemy/miniFireballGuy.c @@ -1,7 +1,4 @@ -#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 521b52a8..488cb419 100644 --- a/src/enemy/miniSlime.c +++ b/src/enemy/miniSlime.c @@ -1,7 +1,4 @@ -#include "global.h" -#include "entity.h" #include "enemy.h" -#include "random.h" #include "functions.h" void sub_08045374(Entity*); diff --git a/src/enemy/moldorm.c b/src/enemy/moldorm.c index 25ae0111..767254f9 100644 --- a/src/enemy/moldorm.c +++ b/src/enemy/moldorm.c @@ -1,6 +1,4 @@ #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 7b700322..9ffd49fa 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -1,8 +1,5 @@ #include "enemy.h" -#include "entity.h" -#include "random.h" #include "functions.h" -#include "effects.h" extern void sub_0800449C(Entity*, u32); extern bool32 sub_08023A38(u32); diff --git a/src/enemy/octorok.c b/src/enemy/octorok.c index 9ca40e32..4c142bdc 100644 --- a/src/enemy/octorok.c +++ b/src/enemy/octorok.c @@ -1,7 +1,4 @@ -#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/octorokBoss.c b/src/enemy/octorokBoss.c index 7544b241..23dca6d4 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -1,14 +1,9 @@ -#include "global.h" -#include "audio.h" #include "enemy.h" #include "functions.h" #include "object.h" #include "projectile.h" -#include "random.h" -#include "room.h" #include "structures.h" -#include "structures.h" -#include "utils.h" +#include "overworld.h" extern void sub_08078AC0(u32, u32, u32); extern u32 GetRandomByWeight(const u8*); diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index de45a52a..5d8ba2d5 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -1,6 +1,4 @@ -#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 472d982d..8694f4af 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -1,8 +1,6 @@ #include "enemy.h" -#include "entity.h" -#include "random.h" #include "createObject.h" -#include "game.h" +#include "overworld.h" #include "functions.h" #include "save.h" diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c index 207934a9..6240bcd2 100644 --- a/src/enemy/puffstool.c +++ b/src/enemy/puffstool.c @@ -1,9 +1,6 @@ #include "enemy.h" -#include "entity.h" -#include "random.h" #include "object.h" #include "functions.h" -#include "effects.h" extern u32 sub_080002E0(u32, u32); extern u32 sub_080002C8(u16, u8); diff --git a/src/enemy/rockChuchu.c b/src/enemy/rockChuchu.c index 95e0a9c1..dd3987cd 100644 --- a/src/enemy/rockChuchu.c +++ b/src/enemy/rockChuchu.c @@ -1,8 +1,5 @@ #include "enemy.h" -#include "entity.h" -#include "random.h" #include "functions.h" -#include "effects.h" extern void sub_0804A4E4(Entity*, Entity*); diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index 9815510f..5fb77dab 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -1,6 +1,4 @@ -#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 2c61fb03..d001888d 100644 --- a/src/enemy/rope.c +++ b/src/enemy/rope.c @@ -1,8 +1,4 @@ -#include "global.h" -#include "entity.h" #include "enemy.h" -#include "random.h" -#include "audio.h" #include "functions.h" extern void (*const gRope[6])(Entity*); diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index 05334d65..62853353 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -1,4 +1,6 @@ #include "global.h" +#include "asm.h" +#include "audio.h" #include "entity.h" #include "enemy.h" #include "npc.h" diff --git a/src/enemy/sensorBladeTrap.c b/src/enemy/sensorBladeTrap.c index 0aae18f1..40ad4f03 100644 --- a/src/enemy/sensorBladeTrap.c +++ b/src/enemy/sensorBladeTrap.c @@ -1,4 +1,5 @@ #include "enemy.h" +#include "audio.h" #include "functions.h" extern u32 sub_0804A024(Entity*, u32, u32); diff --git a/src/enemy/slime.c b/src/enemy/slime.c index ab7666f8..86069f50 100644 --- a/src/enemy/slime.c +++ b/src/enemy/slime.c @@ -1,10 +1,5 @@ -#include "global.h" -#include "entity.h" #include "enemy.h" -#include "room.h" -#include "random.h" #include "functions.h" -#include "effects.h" typedef struct { s8 h, v; diff --git a/src/enemy/sluggula.c b/src/enemy/sluggula.c index d6361507..5d307fc4 100644 --- a/src/enemy/sluggula.c +++ b/src/enemy/sluggula.c @@ -1,6 +1,4 @@ #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 3be1f047..b8fdc5db 100644 --- a/src/enemy/smallPesto.c +++ b/src/enemy/smallPesto.c @@ -1,8 +1,4 @@ -#include "global.h" -#include "entity.h" #include "enemy.h" -#include "coord.h" -#include "random.h" #include "functions.h" extern void sub_080317F8(Entity*); diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c index fa90d4f8..6e35d52a 100644 --- a/src/enemy/spearMoblin.c +++ b/src/enemy/spearMoblin.c @@ -1,8 +1,5 @@ #include "enemy.h" -#include "entity.h" -#include "random.h" #include "functions.h" -#include "effects.h" extern bool32 sub_0806FC80(Entity*, Entity*, u32); extern Entity* sub_08049DF4(u32); diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c index 89d9e031..903908c4 100644 --- a/src/enemy/spikedBeetle.c +++ b/src/enemy/spikedBeetle.c @@ -1,6 +1,4 @@ #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 887a433d..69664d39 100644 --- a/src/enemy/spinyChuchu.c +++ b/src/enemy/spinyChuchu.c @@ -1,7 +1,4 @@ #include "enemy.h" -#include "entity.h" -#include "random.h" -#include "audio.h" #include "functions.h" extern void sub_08001318(Entity*); diff --git a/src/enemy/tektite.c b/src/enemy/tektite.c index a4f78704..ac123367 100644 --- a/src/enemy/tektite.c +++ b/src/enemy/tektite.c @@ -1,7 +1,4 @@ -#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 12287902..ba3b5d58 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -1,8 +1,4 @@ -#include "global.h" -#include "entity.h" #include "enemy.h" -#include "flags.h" -#include "random.h" #include "functions.h" extern void sub_08038168(Entity*); diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c index 139b1fe0..8a5dd737 100644 --- a/src/enemy/vaatiArm.c +++ b/src/enemy/vaatiArm.c @@ -1,12 +1,6 @@ -#include "global.h" #include "enemy.h" -#include "entity.h" -#include "audio.h" #include "object.h" -#include "random.h" -#include "utils.h" #include "functions.h" -#include "effects.h" extern void DoExitTransition(ScreenTransitionData*); diff --git a/src/enemy/vaatiBall.c b/src/enemy/vaatiBall.c index 778af1a7..f6a4356f 100644 --- a/src/enemy/vaatiBall.c +++ b/src/enemy/vaatiBall.c @@ -1,4 +1,5 @@ #include "entity.h" +#include "enemy.h" #include "player.h" #include "screen.h" #include "createObject.h" diff --git a/src/enemy/vaatiEyesMacro.c b/src/enemy/vaatiEyesMacro.c index 5bc955dc..be77a617 100644 --- a/src/enemy/vaatiEyesMacro.c +++ b/src/enemy/vaatiEyesMacro.c @@ -1,7 +1,4 @@ -#include "global.h" #include "enemy.h" -#include "audio.h" -#include "random.h" #include "functions.h" extern u32 sub_080002E0(u32, u32); diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c index c8c85e44..2efae6f5 100644 --- a/src/enemy/vaatiProjectile.c +++ b/src/enemy/vaatiProjectile.c @@ -1,6 +1,4 @@ -#include "global.h" #include "enemy.h" -#include "random.h" #include "functions.h" extern bool32 PlayerInRange(Entity*, u32, u32); diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index d1a2e4c8..c8f97752 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -1,12 +1,6 @@ -#include "global.h" #include "enemy.h" -#include "coord.h" -#include "flags.h" -#include "random.h" -#include "audio.h" #include "area.h" #include "functions.h" -#include "effects.h" extern void sub_080AEFB4(Entity*); extern u8 gEntCount; diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index c00649a5..232d95a5 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -1,11 +1,6 @@ -#include "entity.h" #include "enemy.h" #include "object.h" -#include "random.h" -#include "flags.h" -#include "audio.h" #include "functions.h" -#include "effects.h" void sub_080409B0(Entity*); void sub_080408EC(Entity*); diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index 21d38958..a8843ae8 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -1,16 +1,10 @@ -#include "entity.h" #include "enemy.h" -#include "audio.h" -#include "room.h" -#include "random.h" #include "object.h" #include "textbox.h" -#include "flags.h" -#include "utils.h" #include "structures.h" #include "functions.h" #include "save.h" -#include "effects.h" +#include "screen.h" extern u8 gEntCount; diff --git a/src/enemy/vaatiWrathEye.c b/src/enemy/vaatiWrathEye.c index d476ca6c..d8590edc 100644 --- a/src/enemy/vaatiWrathEye.c +++ b/src/enemy/vaatiWrathEye.c @@ -1,8 +1,6 @@ -#include "entity.h" -#include "audio.h" +#include "enemy.h" #include "structures.h" #include "functions.h" -#include "effects.h" void sub_080485D8(Entity*); void sub_080485FC(Entity*); diff --git a/src/enemy/wallMaster.c b/src/enemy/wallMaster.c index a0d612f7..e548e329 100644 --- a/src/enemy/wallMaster.c +++ b/src/enemy/wallMaster.c @@ -1,7 +1,5 @@ #include "enemy.h" -#include "entity.h" #include "area.h" -#include "random.h" #include "functions.h" extern void sub_08001328(Entity*); diff --git a/src/enemy/wallMaster2.c b/src/enemy/wallMaster2.c index 03d35e80..73deb8da 100644 --- a/src/enemy/wallMaster2.c +++ b/src/enemy/wallMaster2.c @@ -1,6 +1,5 @@ #include "enemy.h" #include "area.h" -#include "random.h" #include "functions.h" extern void sub_08001328(Entity*); diff --git a/src/enemy/waterDrop.c b/src/enemy/waterDrop.c index 96ff44c2..32390db3 100644 --- a/src/enemy/waterDrop.c +++ b/src/enemy/waterDrop.c @@ -1,7 +1,5 @@ #include "enemy.h" -#include "entity.h" #include "screen.h" -#include "random.h" #include "object.h" #include "structures.h" #include "functions.h" diff --git a/src/enemy/wisp.c b/src/enemy/wisp.c index beb1ec43..b2c00736 100644 --- a/src/enemy/wisp.c +++ b/src/enemy/wisp.c @@ -1,12 +1,7 @@ -#include "global.h" -#include "entity.h" #include "enemy.h" -#include "player.h" #include "save.h" -#include "random.h" #include "createObject.h" #include "functions.h" -#include "effects.h" extern void (*const gUnk_080CEB74[])(Entity*); extern void (*const gUnk_080CEB8C[])(Entity*); diff --git a/src/enemyUtils.c b/src/enemyUtils.c index 111ed63f..6d8acd97 100644 --- a/src/enemyUtils.c +++ b/src/enemyUtils.c @@ -17,7 +17,7 @@ const EnemyDefinition* GetEnemyDefinition(Entity* entity) { } bool32 EnemyInit(Entity* this) { - if ((this->flags & 1) == 0) { + if ((this->flags & ENT_DID_INIT) == 0) { const EnemyDefinition* definition = GetEnemyDefinition(this); if (LoadEnemySprite(this, definition) == FALSE) { return FALSE; diff --git a/src/entity.c b/src/entity.c index c0d5b62d..85979ca8 100644 --- a/src/entity.c +++ b/src/entity.c @@ -6,6 +6,7 @@ #include "room.h" #include "script.h" #include "textbox.h" +#include "npc.h" extern u8 gUnk_081091F8[]; extern u8 gUnk_081091EE[]; @@ -13,7 +14,6 @@ extern u8 gUpdateVisibleTiles; extern Manager gUnk_02033290; void sub_0805ED30(void); void ClearHitboxList(void); -void sub_0806F0A4(void); void sub_0805EE88(void); void ClearAllDeletedEntities(void); void DeleteAllEntities(void); @@ -277,7 +277,7 @@ void DeleteThisEntity(void) { f(); } -void DeleteManager(Manager*); +void DeleteManager(void*); typedef void (*Deleter)(void*); @@ -378,13 +378,14 @@ Manager* GetEmptyManager(void) { extern u8 gManagerCount; -void DeleteManager(Manager* ent) { - if (!ent->next) +void DeleteManager(void* ent) { + Manager* manager = (Manager*)ent; + if (!manager->next) return; - ReleaseTransitionManager(ent); - UnlinkEntity(ent); - MemClear(ent, sizeof(Temp)); + ReleaseTransitionManager(manager); + UnlinkEntity(manager); + MemClear(manager, sizeof(Temp)); gManagerCount--; } diff --git a/src/fade.c b/src/fade.c index defbe187..2d107df7 100644 --- a/src/fade.c +++ b/src/fade.c @@ -2,6 +2,7 @@ #include "functions.h" #include "screen.h" #include "utils.h" +#include "fade.h" typedef struct { u8 field_0x0; @@ -48,18 +49,18 @@ void FadeVBlank(void) { } } -void InitFade() { +void InitFade(void) { MemClear(&gFadeControl, sizeof(gFadeControl)); MemClear(&gUnk_020354C0, sizeof(gUnk_020354C0)); gFadeControl.mask = 0xffffffff; } -void sub_08050008() { +void sub_08050008(void) { MemClear(&gUnk_020354C0, sizeof(gUnk_020354C0)); gFadeControl.mask = 0xFFFFFFFF; } -void sub_08050024() { +static void sub_08050024(void) { sub_0801E104(); DoFade(5, 256); } @@ -72,9 +73,9 @@ void sub_08050038(u32 arg0) { } } -void DoFade(u32 fadeType, u32 fadeSpeed) { - gFadeControl.fadeSpeed = fadeSpeed; - gFadeControl.fadeType = fadeType; +void DoFade(u32 type, u32 speed) { + gFadeControl.fadeSpeed = speed; + gFadeControl.fadeType = type; gFadeControl.active = 1; gFadeControl.fadeDuration = 0x100; gFadeControl.field_0xe = 0; @@ -83,16 +84,16 @@ void DoFade(u32 fadeType, u32 fadeSpeed) { } else { gFadeControl.field_0x2 = 0; } - if (fadeType & 8) { + if (type & 8) { gUnk_03000000.spritesOffset = 1; gScreen.bg1.control |= BGCNT_MOSAIC; gScreen.bg2.control |= BGCNT_MOSAIC; gScreen.bg3.control |= BGCNT_MOSAIC; } - if (fadeType & 0x10) { + if (type & 0x10) { sub_0801E1B8(gFadeControl.field_0x16, gFadeControl.field_0x18); sub_0801E1EC(gFadeControl.field_0x12, gFadeControl.field_0x14, gFadeControl.field_0x10); - if ((fadeType & 1) == 0) { + if ((type & 1) == 0) { gFadeControl.fadeType &= ~4; sub_08050008(); gUsedPalettes = 0xffffffff; diff --git a/src/fileScreen.c b/src/fileScreen.c index 8820f24f..50f0a4bb 100644 --- a/src/fileScreen.c +++ b/src/fileScreen.c @@ -4,7 +4,6 @@ #include "utils.h" #include "screen.h" #include "menu.h" -#include "random.h" #include "textbox.h" #include "object.h" #include "functions.h" diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index e66f8240..e2d9a268 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -1,6 +1,6 @@ +#include "asm.h" #include "item.h" #include "audio.h" -#include "random.h" #include "functions.h" #include "effects.h" diff --git a/src/main.c b/src/main.c index 6a883794..7cd2f92b 100644 --- a/src/main.c +++ b/src/main.c @@ -1,14 +1,15 @@ #include "audio.h" -#include "global.h" +#include "asm.h" #include "functions.h" #include "structures.h" #include "main.h" #include "screen.h" -#include "random.h" #include "utils.h" #include "save.h" #include "textbox.h" -#include "arm_proxy.h" +#include "interrupts.h" + +extern u32 gRand; extern void HandleIntroScreen(void); extern void HandleChooseFileScreen(void); @@ -20,6 +21,7 @@ extern void HandleDebugTextScreen(void); static void InitOverlays(void); static bool32 SoftResetKeysPressed(void); +static u32 CheckHeaderValid(void); void (*const sScreenHandlers[])(void) = { [SCREEN_INTRO] = HandleIntroScreen, @@ -211,7 +213,7 @@ NONMATCH("asm/non_matching/sub_080560B8.inc", static void sub_080560B8(void)) { } END_NONMATCH -u32 CheckHeaderValid(void) { +static u32 CheckHeaderValid(void) { if ((gSaveHeader->signature != SIGNATURE) || (gSaveHeader->saveFileId >= NUM_SAVE_SLOTS) || (gSaveHeader->messageSpeed >= MAX_MSG_SPEED) || (gSaveHeader->brightnessPref >= MAX_BRIGHTNESS) #ifdef EU diff --git a/src/manager/manager15.c b/src/manager/manager15.c index 867a9429..15f336c4 100644 --- a/src/manager/manager15.c +++ b/src/manager/manager15.c @@ -452,7 +452,6 @@ void sub_0805A9CC(Manager15* this) { extern struct { u8 unk_00[0x20]; } gUnk_085A97A0[]; extern u16 gUnk_081085B8[]; -extern void LoadPalettes(const u8*, u32, u32); void sub_0805AA58(Manager15* this) { if (--this->manager.unk_0e == 0) { diff --git a/src/manager/manager16.c b/src/manager/manager16.c index 23292b39..03450bad 100644 --- a/src/manager/manager16.c +++ b/src/manager/manager16.c @@ -3,4 +3,4 @@ ASM_FUNC("asm/non_matching/manager16/Manager16_Main.inc", void Manager16_Main()) -ASM_FUNC("asm/non_matching/manager16/sub_0805ACC0.inc", void sub_0805ACC0()) +ASM_FUNC("asm/non_matching/manager16/sub_0805ACC0.inc", u32 sub_0805ACC0(Entity* ent)) diff --git a/src/manager/manager1C.c b/src/manager/manager1C.c index cadaec86..4ff51e27 100644 --- a/src/manager/manager1C.c +++ b/src/manager/manager1C.c @@ -1,5 +1,5 @@ #include "manager.h" -#include "random.h" +#include "asm.h" #include "room.h" #include "enemy.h" diff --git a/src/manager/manager23.c b/src/manager/manager23.c index 43f0c688..494018a4 100644 --- a/src/manager/manager23.c +++ b/src/manager/manager23.c @@ -4,6 +4,7 @@ #include "functions.h" #include "flags.h" #include "object.h" +#include "overworld.h" extern void (*const gUnk_08108CCC[])(Manager*); diff --git a/src/manager/manager24.c b/src/manager/manager24.c index 141e1a01..7b3f2d19 100644 --- a/src/manager/manager24.c +++ b/src/manager/manager24.c @@ -2,7 +2,7 @@ #include "functions.h" #include "flags.h" #include "audio.h" -#include "game.h" +#include "overworld.h" #include "object.h" #include "area.h" diff --git a/src/manager/manager28.c b/src/manager/manager28.c index 94ad456a..4d4155c7 100644 --- a/src/manager/manager28.c +++ b/src/manager/manager28.c @@ -1,4 +1,5 @@ #include "global.h" +#include "asm.h" #include "manager.h" #include "entity.h" #include "room.h" diff --git a/src/manager/manager3.c b/src/manager/manager3.c index b71d8a51..e485f8b0 100644 --- a/src/manager/manager3.c +++ b/src/manager/manager3.c @@ -1,10 +1,10 @@ #include "global.h" +#include "asm.h" #include "manager.h" #include "flags.h" #include "area.h" #include "room.h" #include "player.h" -#include "random.h" #include "audio.h" #include "object.h" #include "functions.h" diff --git a/src/manager/manager31.c b/src/manager/manager31.c index bb7ebdde..1cc7beff 100644 --- a/src/manager/manager31.c +++ b/src/manager/manager31.c @@ -1,7 +1,7 @@ #include "manager.h" #include "flags.h" -#include "random.h" +#include "asm.h" #include "object.h" #include "room.h" diff --git a/src/manager/manager32.c b/src/manager/manager32.c index 606f07ea..9cb61068 100644 --- a/src/manager/manager32.c +++ b/src/manager/manager32.c @@ -5,7 +5,7 @@ #include "functions.h" #include "area.h" #include "utils.h" -#include "gba/types.h" +#include "overworld.h" typedef struct { Manager manager; @@ -18,8 +18,6 @@ extern void (*const gUnk_08108D7C[])(Manager32*); void sub_0805D9D8(Manager32*); void sub_0805DA08(u32, u32, u32); -extern void RoomExitCallback(); - extern u8 gUnk_08108D74[]; extern struct BgAffineDstData gUnk_02017AA0[]; diff --git a/src/manager/manager37.c b/src/manager/manager37.c index 937e5b4b..0258dee6 100644 --- a/src/manager/manager37.c +++ b/src/manager/manager37.c @@ -8,6 +8,7 @@ #include "object.h" #include "area.h" #include "enemy.h" +#include "screen.h" extern ScreenTransitionData gUnk_0813AC34; diff --git a/src/manager/manager39.c b/src/manager/manager39.c index 65355f84..96787a29 100644 --- a/src/manager/manager39.c +++ b/src/manager/manager39.c @@ -4,7 +4,7 @@ #include "area.h" #include "textbox.h" #include "utils.h" -#include "game.h" +#include "overworld.h" #include "functions.h" typedef struct { diff --git a/src/npc.c b/src/npc.c index ba3c0ada..4f48e34f 100644 --- a/src/npc.c +++ b/src/npc.c @@ -137,7 +137,7 @@ void (*const gNPCFunctions[][3])(Entity* ent) = { //clang-format on const u8 npc_unk[] = { 0x04, 0x05, 0x06, 0x06 }; -extern u8 gUnk_020342F8; +extern u32 gUnk_020342F8; typedef struct { u16 unk0; u16 unk1; @@ -147,7 +147,6 @@ typedef struct { extern NPCStruct gUnk_02031EC0[100]; void InitNPC(Entity*); -u32 ReadBit(void*, u32); // regalloc NONMATCH("asm/non_matching/arm_proxy/NPCUpdate.inc", void NPCUpdate(Entity* this)) { diff --git a/src/npc/anju.c b/src/npc/anju.c index b7262d24..29a80185 100644 --- a/src/npc/anju.c +++ b/src/npc/anju.c @@ -3,7 +3,6 @@ #include "player.h" #include "npc.h" #include "script.h" -#include "functions.h" void Anju(Entity* this) { switch (this->action) { diff --git a/src/npc/beedle.c b/src/npc/beedle.c index ada9a485..1e303b7a 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -1,10 +1,11 @@ #include "global.h" #include "entity.h" -#include "functions.h" #include "textbox.h" #include "player.h" #include "room.h" #include "script.h" +#include "npc.h" +#include "overworld.h" typedef struct { u32 unk_00; diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index e76a26e2..63c25922 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -1,16 +1,7 @@ -#include "global.h" -#include "entity.h" -#include "player.h" +#include "npc.h" #include "structures.h" -#include "script.h" -#include "random.h" -#include "audio.h" #include "functions.h" -#include "script.h" -#include "save.h" #include "screen.h" -#include "utils.h" -#include "textbox.h" extern void (*gUnk_081140D4[])(Entity*); diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index 10080ffe..66d0a733 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -33,8 +33,9 @@ extern u16 gUnk_0811172A[]; extern u32 gUnk_0300402B; extern EntityData gUnk_080F3494; -void BladeBrothers(Entity* this) { +static void sub_08068BEC(Entity* this, u32 unused); +void BladeBrothers(Entity* this) { if ((this->flags & 2) != 0) { gUnk_081115D0[this->action](this); } else { @@ -163,7 +164,7 @@ void sub_08068BD0(Entity* this) { ForceEquipItem(*(u8*)(&this->field_0x68.HALF.HI + 1), 1); } -void sub_08068BEC(Entity* this, u32 unused) { +static void sub_08068BEC(Entity* this, u32 unused) { Entity* target; target = CreateFx(this, FX_WHITE_SPLASH, 0); diff --git a/src/npc/brocco.c b/src/npc/brocco.c index ee03fa3a..0ec333bb 100644 --- a/src/npc/brocco.c +++ b/src/npc/brocco.c @@ -1,5 +1,4 @@ #include "entity.h" -#include "functions.h" #include "textbox.h" #include "save.h" #include "npc.h" diff --git a/src/npc/carlov.c b/src/npc/carlov.c index f095fe1e..dd25013a 100644 --- a/src/npc/carlov.c +++ b/src/npc/carlov.c @@ -1,9 +1,9 @@ #include "global.h" +#include "audio.h" #include "entity.h" #include "room.h" #include "npc.h" #include "script.h" -#include "functions.h" void Carlov(Entity* this) { if (this->action == 0) { diff --git a/src/npc/carpenter.c b/src/npc/carpenter.c index 8663b241..97efd2c1 100644 --- a/src/npc/carpenter.c +++ b/src/npc/carpenter.c @@ -3,7 +3,6 @@ #include "sprite.h" #include "player.h" #include "npc.h" -#include "functions.h" #include "script.h" #include "flags.h" #include "textbox.h" diff --git a/src/npc/castleMaid.c b/src/npc/castleMaid.c index af001b63..bc6eb925 100644 --- a/src/npc/castleMaid.c +++ b/src/npc/castleMaid.c @@ -1,9 +1,10 @@ #include "entity.h" #include "script.h" #include "save.h" -#include "functions.h" #include "flags.h" #include "textbox.h" +#include "npc.h" +#include "manager.h" extern Dialog gUnk_0810F894[]; diff --git a/src/npc/castorWildsStatue.c b/src/npc/castorWildsStatue.c index 489b584a..884a4289 100644 --- a/src/npc/castorWildsStatue.c +++ b/src/npc/castorWildsStatue.c @@ -1,8 +1,10 @@ +#include "audio.h" #include "entity.h" #include "script.h" #include "functions.h" #include "flags.h" #include "effects.h" +#include "npc.h" extern Hitbox gUnk_08110E94; diff --git a/src/npc/cat.c b/src/npc/cat.c index 3fec5ab9..b670b5ab 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -3,7 +3,6 @@ #include "functions.h" #include "save.h" #include "player.h" -#include "random.h" #include "textbox.h" #include "npc.h" #include "audio.h" diff --git a/src/npc/clothesRack.c b/src/npc/clothesRack.c index 63d6cc0c..f616eccc 100644 --- a/src/npc/clothesRack.c +++ b/src/npc/clothesRack.c @@ -1,7 +1,4 @@ -#include "global.h" -#include "entity.h" -#include "functions.h" -#include "flags.h" +#include "npc.h" extern void (*gUnk_0811423C[])(Entity*); diff --git a/src/npc/cow.c b/src/npc/cow.c index fa57d88c..295e387a 100644 --- a/src/npc/cow.c +++ b/src/npc/cow.c @@ -2,7 +2,6 @@ #include "audio.h" #include "entity.h" #include "player.h" -#include "random.h" #include "npc.h" #include "functions.h" diff --git a/src/npc/cucco.c b/src/npc/cucco.c index b935dc7b..27f3fc5a 100644 --- a/src/npc/cucco.c +++ b/src/npc/cucco.c @@ -1,8 +1,5 @@ -#include "entity.h" -#include "functions.h" #include "npc.h" -#include "audio.h" -#include "random.h" +#include "functions.h" extern void (*const gUnk_081145B4[])(Entity*); diff --git a/src/npc/cuccoChick.c b/src/npc/cuccoChick.c index bfadc897..11aab009 100644 --- a/src/npc/cuccoChick.c +++ b/src/npc/cuccoChick.c @@ -1,9 +1,5 @@ -#include "entity.h" -#include "textbox.h" #include "npc.h" #include "functions.h" -#include "random.h" -#include "audio.h" extern void (*const gUnk_081145D4[])(Entity*); diff --git a/src/npc/dog.c b/src/npc/dog.c index e749ea7e..97fadf4b 100644 --- a/src/npc/dog.c +++ b/src/npc/dog.c @@ -1,12 +1,7 @@ #include "entity.h" #include "functions.h" -#include "script.h" -#include "flags.h" -#include "random.h" #include "npc.h" -#include "audio.h" #include "save.h" -#include "textbox.h" extern void (*gUnk_08111D88[])(Entity*); void sub_08069FE8(Entity*); diff --git a/src/npc/drLeft.c b/src/npc/drLeft.c index 9a81aceb..bccfb259 100644 --- a/src/npc/drLeft.c +++ b/src/npc/drLeft.c @@ -1,10 +1,5 @@ -#include "entity.h" -#include "script.h" -#include "random.h" +#include "npc.h" #include "functions.h" -#include "save.h" -#include "textbox.h" -#include "flags.h" extern void sub_08078850(Entity*, u32, u8, u32*); extern u32 gUnk_081133B4; diff --git a/src/npc/ezlo.c b/src/npc/ezlo.c index 4f1dcd62..6a3a96da 100644 --- a/src/npc/ezlo.c +++ b/src/npc/ezlo.c @@ -1,9 +1,5 @@ -#include "global.h" -#include "entity.h" +#include "npc.h" #include "script.h" -#include "audio.h" -#include "functions.h" -#include "effects.h" const u8 gUnk_08114134[]; const u8 gUnk_08114144[]; diff --git a/src/npc/farmers.c b/src/npc/farmers.c index d31a7a3a..d3c9d94c 100644 --- a/src/npc/farmers.c +++ b/src/npc/farmers.c @@ -1,11 +1,10 @@ #include "entity.h" #include "script.h" #include "functions.h" +#include "npc.h" extern Dialog gUnk_08113158[]; -extern void sub_0806F188(Entity*); - extern SpriteLoadData gUnk_08113140[]; void sub_0806BC58(Entity* this); diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index a8e04f9c..912549bf 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -1,18 +1,9 @@ -#include "global.h" -#include "entity.h" #include "npc.h" -#include "flags.h" -#include "textbox.h" -#include "player.h" -#include "save.h" -#include "script.h" -#include "random.h" #include "createObject.h" #include "structures.h" #include "functions.h" extern void sub_080600F0(Entity*); -extern s32 sub_0806EDD8(Entity*, u32, u32); extern void sub_08060158(Entity*); extern void ModBombs(s32); diff --git a/src/npc/gorman.c b/src/npc/gorman.c index c118eeb5..7dfaf6ca 100644 --- a/src/npc/gorman.c +++ b/src/npc/gorman.c @@ -1,9 +1,5 @@ -#include "entity.h" -#include "script.h" #include "functions.h" -#include "random.h" -#include "flags.h" -#include "textbox.h" +#include "npc.h" extern void (*const gUnk_08111C48[])(Entity*); diff --git a/src/npc/goron.c b/src/npc/goron.c index c7e70d29..d48cda07 100644 --- a/src/npc/goron.c +++ b/src/npc/goron.c @@ -4,6 +4,7 @@ #include "textbox.h" #include "script.h" #include "effects.h" +#include "npc.h" extern void (*gUnk_08111A80[])(Entity*); extern void (*gUnk_08111A8C[])(Entity*); diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index 9c1b107c..f4640890 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -7,6 +7,7 @@ #include "flags.h" #include "script.h" #include "save.h" +#include "npc.h" static u32 GoronMerchant_GetSalePrice(Entity*); diff --git a/src/npc/guard.c b/src/npc/guard.c index aa2d95bd..67c4fa2e 100644 --- a/src/npc/guard.c +++ b/src/npc/guard.c @@ -7,6 +7,7 @@ #include "script.h" #include "structures.h" #include "functions.h" +#include "npc.h" typedef struct { u32 unk; @@ -19,9 +20,7 @@ typedef struct { } struct_08064050; extern void sub_08063D24(Entity*); -extern void sub_0806EE20(Entity*); extern void sub_08064428(Entity*); -extern void sub_0806EE04(Entity*, void*, u32); void sub_08063DC8(Entity*); void sub_08063F20(Entity*); diff --git a/src/npc/kid.c b/src/npc/kid.c index 03ebf3b8..41bebb98 100644 --- a/src/npc/kid.c +++ b/src/npc/kid.c @@ -1,10 +1,7 @@ -#include "entity.h" #include "functions.h" #include "textbox.h" #include "npc.h" #include "script.h" -#include "utils.h" -#include "random.h" #include "save.h" extern void (*const gUnk_0810BE0C[])(Entity*); diff --git a/src/npc/mailbox.c b/src/npc/mailbox.c index 8c7dc813..a4afd083 100644 --- a/src/npc/mailbox.c +++ b/src/npc/mailbox.c @@ -3,6 +3,7 @@ #include "textbox.h" #include "functions.h" #include "effects.h" +#include "npc.h" extern void sub_08063280(); diff --git a/src/npc/melari.c b/src/npc/melari.c index 146ae078..757bc43e 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -1,15 +1,7 @@ -#include "global.h" -#include "entity.h" #include "npc.h" -#include "textbox.h" -#include "script.h" -#include "random.h" -#include "audio.h" #include "functions.h" -#include "effects.h" extern void sub_08068780(Entity*); -extern s32 sub_0806EDD8(Entity*, u32, u32); extern void (*const gUnk_08111530[])(Entity*); diff --git a/src/npc/milkCart.c b/src/npc/milkCart.c index 8ce2eb74..7b32235f 100644 --- a/src/npc/milkCart.c +++ b/src/npc/milkCart.c @@ -1,6 +1,7 @@ #include "global.h" #include "entity.h" #include "functions.h" +#include "npc.h" extern void (*gMilkCartBehaviors[2])(Entity*); diff --git a/src/npc/mountainMinish.c b/src/npc/mountainMinish.c index 14c4d6a1..b7c0f08a 100644 --- a/src/npc/mountainMinish.c +++ b/src/npc/mountainMinish.c @@ -3,6 +3,7 @@ #include "functions.h" #include "textbox.h" #include "flags.h" +#include "npc.h" extern SpriteLoadData gUnk_08111358; diff --git a/src/npc/npc23.c b/src/npc/npc23.c index e90d084c..003c5bd9 100644 --- a/src/npc/npc23.c +++ b/src/npc/npc23.c @@ -5,6 +5,7 @@ #include "functions.h" #include "structures.h" #include "textbox.h" +#include "npc.h" extern void (*const gUnk_081104C8[])(Entity*); diff --git a/src/npc/npc26.c b/src/npc/npc26.c index ca0b17a4..81ce55b7 100644 --- a/src/npc/npc26.c +++ b/src/npc/npc26.c @@ -2,6 +2,7 @@ #include "entity.h" #include "functions.h" #include "script.h" +#include "npc.h" static void (*const gUnk_081106D4[])(Entity*); static void (*const gUnk_081106E0[])(Entity*); diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c index f4a87161..84d18da1 100644 --- a/src/npc/npc4E.c +++ b/src/npc/npc4E.c @@ -7,6 +7,7 @@ #include "save.h" #include "flags.h" #include "object.h" +#include "npc.h" extern Hitbox gHitbox_2; typedef struct { diff --git a/src/npc/npc4F.c b/src/npc/npc4F.c index 07e05132..0ab80863 100644 --- a/src/npc/npc4F.c +++ b/src/npc/npc4F.c @@ -1,6 +1,4 @@ -#include "global.h" -#include "entity.h" -#include "random.h" +#include "npc.h" void NPC4F(Entity* this) { if (this->action == 0) { diff --git a/src/npc/npc5.c b/src/npc/npc5.c index f6b04a24..a86189ef 100644 --- a/src/npc/npc5.c +++ b/src/npc/npc5.c @@ -1,12 +1,6 @@ -#include "global.h" -#include "entity.h" -#include "player.h" -#include "room.h" -#include "coord.h" -#include "random.h" -#include "utils.h" #include "functions.h" #include "textbox.h" +#include "npc.h" extern void (*const gUnk_0810AC1C[])(Entity*); @@ -86,6 +80,7 @@ void sub_08061AFC(Entity*); extern u16* gUnk_0810B660[8]; +// UNUSED zelda follower, probably because it was too resource heavy void NPC5(Entity* this) { gUnk_0810AC1C[this->type](this); } diff --git a/src/npc/npc58.c b/src/npc/npc58.c index b21de320..5cebcb57 100644 --- a/src/npc/npc58.c +++ b/src/npc/npc58.c @@ -1,5 +1,6 @@ #include "entity.h" #include "functions.h" +#include "npc.h" extern void sub_0806FFBC(Entity*, u32, u32, u32); diff --git a/src/npc/npc9.c b/src/npc/npc9.c index 97b32871..0c514fd3 100644 --- a/src/npc/npc9.c +++ b/src/npc/npc9.c @@ -2,6 +2,7 @@ #include "entity.h" #include "textbox.h" #include "functions.h" +#include "npc.h" extern void (*const gUnk_0810C290[])(Entity*); @@ -30,7 +31,7 @@ void sub_08062B14(Entity* this) { void sub_08062B48(Entity* this) { GetNextFrame(this); if (this->frame & 0x80) { - MessageFromTarget(0xa01); + MessageFromTarget(0xa01); // invalid this->action++; } } diff --git a/src/npc/pita.c b/src/npc/pita.c index 3bb6080f..97abf77d 100644 --- a/src/npc/pita.c +++ b/src/npc/pita.c @@ -1,9 +1,5 @@ -#include "entity.h" #include "functions.h" -#include "script.h" -#include "flags.h" -#include "random.h" -#include "textbox.h" +#include "npc.h" extern Hitbox gUnk_0810C428; diff --git a/src/npc/postman.c b/src/npc/postman.c index 0ea13635..3014e4b8 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -1,4 +1,5 @@ #include "global.h" +#include "audio.h" #include "entity.h" #include "functions.h" #include "npc.h" @@ -12,9 +13,7 @@ #include "effects.h" extern void sub_08060528(Entity*); -extern void sub_0806EE04(Entity*, void*, u32); extern void sub_080604DC(Entity*); -extern void sub_0806EE20(Entity*); extern void sub_080606D8(Entity*); extern void sub_080606C0(Entity*); diff --git a/src/npc/rem.c b/src/npc/rem.c index 94356c93..d3ab32d0 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -1,11 +1,5 @@ -#include "global.h" -#include "entity.h" -#include "script.h" -#include "audio.h" #include "functions.h" -#include "random.h" -#include "flags.h" -#include "textbox.h" +#include "npc.h" extern void sub_0806A8C8(Entity*); diff --git a/src/npc/simon.c b/src/npc/simon.c index 09f4b40c..3fffc8cc 100644 --- a/src/npc/simon.c +++ b/src/npc/simon.c @@ -6,6 +6,7 @@ #include "script.h" #include "object.h" #include "functions.h" +#include "screen.h" typedef struct { u8 filler[4]; diff --git a/src/npc/sittingPerson.c b/src/npc/sittingPerson.c index 8a9a7e0d..c8c8e084 100644 --- a/src/npc/sittingPerson.c +++ b/src/npc/sittingPerson.c @@ -1,9 +1,4 @@ -#include "entity.h" -#include "script.h" #include "npc.h" -#include "functions.h" -#include "save.h" -#include "random.h" extern void (*gUnk_0810CBD8[])(Entity*); diff --git a/src/npc/smallTownMinish.c b/src/npc/smallTownMinish.c index f34ecd7d..d4e7d1ea 100644 --- a/src/npc/smallTownMinish.c +++ b/src/npc/smallTownMinish.c @@ -3,7 +3,7 @@ #include "player.h" #include "script.h" #include "save.h" -#include "functions.h" +#include "npc.h" extern Hitbox gUnk_081142FC; extern void sub_08078850(Entity*, u32, u32, u32*); diff --git a/src/npc/smith.c b/src/npc/smith.c index 3f187b73..307bd0bd 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -1,13 +1,5 @@ -#include "global.h" -#include "entity.h" -#include "textbox.h" -#include "save.h" -#include "script.h" -#include "random.h" #include "npc.h" -#include "audio.h" #include "functions.h" -#include "effects.h" extern void sub_08078850(Entity*, u32, u32, u32*); diff --git a/src/npc/stamp.c b/src/npc/stamp.c index 7c71744e..2b5888a8 100644 --- a/src/npc/stamp.c +++ b/src/npc/stamp.c @@ -4,6 +4,7 @@ #include "functions.h" #include "script.h" #include "effects.h" +#include "npc.h" extern void sub_08062CA4(); diff --git a/src/npc/stockwell.c b/src/npc/stockwell.c index f7ebc594..454b8b2a 100644 --- a/src/npc/stockwell.c +++ b/src/npc/stockwell.c @@ -3,6 +3,7 @@ #include "room.h" #include "textbox.h" #include "functions.h" +#include "npc.h" extern void (*const gUnk_0810FDC8[])(Entity*); diff --git a/src/npc/sturgeon.c b/src/npc/sturgeon.c index 749e0732..c5c28329 100644 --- a/src/npc/sturgeon.c +++ b/src/npc/sturgeon.c @@ -10,7 +10,6 @@ extern u16 gUnk_0810FA54[]; extern SpriteLoadData gUnk_0810FA38; -extern void sub_0806EE04(Entity*, void*, u32); extern u32 gUnk_0810FA5A; void sub_08064CC0(Entity* this); diff --git a/src/npc/syrup.c b/src/npc/syrup.c index 3554d95a..45e44c11 100644 --- a/src/npc/syrup.c +++ b/src/npc/syrup.c @@ -1,10 +1,6 @@ -#include "global.h" -#include "entity.h" #include "npc.h" -#include "script.h" #include "functions.h" #include "object.h" -#include "random.h" extern void (*gUnk_081121D4[])(Entity*); diff --git a/src/npc/talon.c b/src/npc/talon.c index 4629119e..1ed653fd 100644 --- a/src/npc/talon.c +++ b/src/npc/talon.c @@ -1,10 +1,4 @@ -#include "global.h" -#include "entity.h" -#include "textbox.h" -#include "player.h" -#include "script.h" #include "npc.h" -#include "random.h" #include "functions.h" extern void (*gUnk_0810FEC4[])(Entity* this); diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index cde7c526..dc8e0531 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -12,7 +12,6 @@ extern void sub_0806ACC4(Entity*); extern void sub_0806AEA8(); extern void sub_0806AEE4(Entity*); extern void sub_0806AFE8(Entity*, ScriptExecutionContext*); -extern s32 sub_0806EDD8(Entity*, u32, u32); extern void sub_08078850(Entity*, u32, u32, u32*); extern u8 gUnk_081125F4[12]; diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index 2a9033a5..3b674b37 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -1,15 +1,6 @@ -#include "global.h" -#include "entity.h" #include "npc.h" -#include "player.h" -#include "textbox.h" -#include "flags.h" -#include "save.h" -#include "script.h" -#include "random.h" #include "structures.h" #include "functions.h" -#include "effects.h" typedef struct { u8 frame1; diff --git a/src/npc/wheaton.c b/src/npc/wheaton.c index 7eafda20..ba154f41 100644 --- a/src/npc/wheaton.c +++ b/src/npc/wheaton.c @@ -1,7 +1,5 @@ -#include "global.h" -#include "entity.h" +#include "npc.h" #include "script.h" -#include "functions.h" extern Hitbox gUnk_0810C3C0; @@ -10,15 +8,10 @@ void Wheaton(Entity* this) { this->action++; SetDefaultPriority(this, PRIO_MESSAGE); - ResolveEntityOnTop(this, this); - this->hitbox = &gUnk_0810C3C0; - this->spriteOffsetY = 0xfe; - sub_0807DD64(this); } - sub_0807DD94(this, 0); } diff --git a/src/npc/windTribespeople.c b/src/npc/windTribespeople.c index 80da0d08..f5e3d57d 100644 --- a/src/npc/windTribespeople.c +++ b/src/npc/windTribespeople.c @@ -1,4 +1,5 @@ #include "global.h" +#include "audio.h" #include "entity.h" #include "npc.h" #include "textbox.h" diff --git a/src/npc/zelda.c b/src/npc/zelda.c index 834679fa..781c2c80 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -5,6 +5,7 @@ #include "room.h" #include "flags.h" #include "script.h" +#include "npc.h" extern Entity* DeepFindEntityByID(u32, u32); void sub_08068680(Entity*, Entity*); diff --git a/src/npcUtils.c b/src/npcUtils.c index 7511beff..f1c8f1b8 100644 --- a/src/npcUtils.c +++ b/src/npcUtils.c @@ -1,13 +1,14 @@ #include "global.h" +#include "asm.h" #include "entity.h" #include "functions.h" #include "definitions.h" #include "save.h" +#include "npc.h" extern const NPCDefinition gNPCDefinitions[]; extern Hitbox* gNPCHitboxes[]; -const NPCDefinition* GetNPCDefinition(Entity*); extern u32 (*gUnk_08114EFC[])(); extern u32 (*gUnk_08114F0C[])(Entity*, u8*); @@ -20,13 +21,14 @@ extern NPCData* gUnk_08001A7C[]; u32 sub_0800445C(Entity*); void sub_08077B20(void); -void sub_0806EF14(Entity*); void sub_0806F69C(Entity*); -void sub_0806EF4C(Entity*, u16*); u32 sub_080041DC(Entity*, u32, u32); -u32 sub_0806EF74(Entity*, u32); u32 sub_0806EF88(Entity*); +static void sub_0806EF14(Entity*); +static void sub_0806EF4C(Entity*, u16*); +static u32 sub_0806EF74(Entity*, u32); + void sub_0806EC20(Entity* ent) { Entity* e = CreateNPC(0x58, 0, 0); if (e != NULL) { @@ -40,7 +42,7 @@ void sub_0806EC38(void) { DeleteEntity(e); } -const NPCDefinition* GetNPCDefinition(Entity* this) { +static const NPCDefinition* GetNPCDefinition(Entity* this) { const NPCDefinition* definition = &gNPCDefinitions[this->id]; if (definition->bitfield.type == 2) { definition = &definition->data.definition[this->type]; @@ -52,7 +54,7 @@ void NPCInit(Entity* this) { u32 tmp; u32 tmp2; - if ((this->flags & 1) == 0) { + if ((this->flags & ENT_DID_INIT) == 0) { const NPCDefinition* definition = GetNPCDefinition(this); if (definition->bitfield.type == 0) { // No sprite for this NPC @@ -184,7 +186,7 @@ u32 sub_0806EEF4(Entity* ent) { return 0; } -void sub_0806EF14(Entity* ent) { +static void sub_0806EF14(Entity* ent) { u16 xy[2]; sub_0806EF4C(ent, xy); ent->direction = sub_080045B4(ent, xy[0], xy[1]); @@ -192,13 +194,13 @@ void sub_0806EF14(Entity* ent) { ent->knockbackDirection = sub_0806F5A4(ent->direction); } -void sub_0806EF4C(Entity* ent, u16* xy) { +static void sub_0806EF4C(Entity* ent, u16* xy) { u16* src = &((u16*)ent->child)[ent->hitType]; xy[0] = gRoomControls.roomOriginX + src[1]; xy[1] = gRoomControls.roomOriginY + src[2]; } -u32 sub_0806EF74(Entity* ent, u32 a2) { +static u32 sub_0806EF74(Entity* ent, u32 a2) { ent->hitType += a2; return sub_0806EF88(ent); } @@ -284,7 +286,7 @@ void sub_0806F118(Entity* ent) { gPlayerState.controlMode = 3; } -u32 UpdateFuseInteraction(void) { +u32 UpdateFuseInteraction(Entity* ent) { u32 ret; sub_0801E00C(); ret = -1; diff --git a/src/object/archway.c b/src/object/archway.c index 823fa485..d0ed7559 100644 --- a/src/object/archway.c +++ b/src/object/archway.c @@ -1,6 +1,6 @@ #include "global.h" #include "entity.h" -#include "game.h" +#include "overworld.h" void Archway(Entity* this) { if (this->action == 0) { diff --git a/src/object/backgroundCloud.c b/src/object/backgroundCloud.c index 2ab9051a..edd764d2 100644 --- a/src/object/backgroundCloud.c +++ b/src/object/backgroundCloud.c @@ -1,6 +1,4 @@ -#include "global.h" -#include "entity.h" -#include "random.h" +#include "object.h" #include "functions.h" extern void (*const gUnk_08121EA4[])(Entity*); diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c index b1c3a1db..ffe11cd9 100644 --- a/src/object/bakerOven.c +++ b/src/object/bakerOven.c @@ -1,7 +1,4 @@ -#include "global.h" -#include "entity.h" #include "object.h" -#include "functions.h" extern void sub_0800449C(Entity*, u32); extern u32 sub_0806FC80(Entity*, Entity*, s32); diff --git a/src/object/bell.c b/src/object/bell.c index a3e7ce3c..135584c3 100644 --- a/src/object/bell.c +++ b/src/object/bell.c @@ -1,5 +1,4 @@ -#include "global.h" -#include "entity.h" +#include "object.h" extern void (*gUnk_08123384[])(Entity*); diff --git a/src/object/bird.c b/src/object/bird.c index 3045fecb..b7774df4 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -1,12 +1,6 @@ -#include "global.h" -#include "audio.h" -#include "entity.h" -#include "flags.h" #include "save.h" -#include "random.h" #include "object.h" #include "functions.h" -#include "effects.h" extern void (*const gUnk_08123EC0[])(Entity*); extern void (*const gUnk_08123EEC[])(Entity*); diff --git a/src/object/book.c b/src/object/book.c index 3430e4ef..9a99b928 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -1,11 +1,7 @@ -#include "entity.h" +#include "object.h" #include "functions.h" -#include "player.h" #include "script.h" -#include "flags.h" -#include "room.h" #include "textbox.h" -#include "effects.h" extern void (*const BookActionFuncs[])(Entity*); extern s8 const gUnk_08123D94[]; diff --git a/src/object/button.c b/src/object/button.c index 4c026baf..76b48da8 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -1,10 +1,5 @@ -#include "global.h" -#include "entity.h" -#include "flags.h" -#include "room.h" -#include "audio.h" +#include "object.h" #include "functions.h" -#include "effects.h" extern void (*const gUnk_0811EE38[])(Entity*); diff --git a/src/object/cloud.c b/src/object/cloud.c index d8915514..22494391 100644 --- a/src/object/cloud.c +++ b/src/object/cloud.c @@ -1,10 +1,3 @@ -#include "global.h" -#include "audio.h" -#include "entity.h" -#include "room.h" -#include "player.h" -#include "flags.h" -#include "random.h" #include "object.h" #include "structures.h" #include "functions.h" diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c index 549e2600..345e8a2b 100644 --- a/src/object/fileScreenObjects.c +++ b/src/object/fileScreenObjects.c @@ -1,12 +1,8 @@ -#include "global.h" -#include "entity.h" -#include "flags.h" +#include "object.h" #include "main.h" #include "menu.h" #include "npc.h" -#include "coord.h" #include "fileScreen.h" -#include "utils.h" #include "structures.h" #include "functions.h" diff --git a/src/object/fireplace.c b/src/object/fireplace.c index fe2dc0d6..1fda4e9f 100644 --- a/src/object/fireplace.c +++ b/src/object/fireplace.c @@ -1,9 +1,6 @@ -#include "entity.h" -#include "functions.h" -#include "player.h" +#include "object.h" #include "script.h" -#include "flags.h" -#include "room.h" +#include "functions.h" extern void (*gUnk_08123D98[])(Entity*); diff --git a/src/object/floatingBlock.c b/src/object/floatingBlock.c index 7e1ad599..c7024c9b 100644 --- a/src/object/floatingBlock.c +++ b/src/object/floatingBlock.c @@ -1,5 +1,4 @@ -#include "global.h" -#include "entity.h" +#include "object.h" void FloatingBlock(Entity* this) { if (this->action == 0) { diff --git a/src/object/frozenFlower.c b/src/object/frozenFlower.c index 92118c4e..e576218b 100644 --- a/src/object/frozenFlower.c +++ b/src/object/frozenFlower.c @@ -1,5 +1,4 @@ -#include "global.h" -#include "entity.h" +#include "object.h" extern void (*const gUnk_0812119C[])(Entity*); diff --git a/src/object/giantLeaf.c b/src/object/giantLeaf.c index a61b267a..a5d25b30 100644 --- a/src/object/giantLeaf.c +++ b/src/object/giantLeaf.c @@ -1,7 +1,4 @@ -#include "global.h" -#include "entity.h" -#include "room.h" -#include "functions.h" +#include "object.h" void sub_0808D618(Entity* ent); diff --git a/src/object/greatFairy.c b/src/object/greatFairy.c index e5575a47..db393026 100644 --- a/src/object/greatFairy.c +++ b/src/object/greatFairy.c @@ -1,16 +1,31 @@ -#include "global.h" -#include "audio.h" -#include "entity.h" -#include "room.h" -#include "screen.h" -#include "greatFairy.h" -#include "flags.h" -#include "save.h" -#include "random.h" -#include "script.h" #include "object.h" +#include "save.h" +#include "script.h" #include "structures.h" #include "functions.h" +#include "screen.h" + +void GreatFairy_InitializeAnimation(Entity*); +Entity* GreatFairy_CreateForm(Entity*, u32, u32); +void sub_080873D0(); +extern void (*const GreatFairy_Main[])(Entity*); +extern void (*const GreatFairy_Behaviors[])(Entity*); +extern void (*const GreatFairy_WingsBehaviors[])(Entity*); +extern void (*const GreatFairy_WakeBehaviors[])(Entity*); +extern void (*const GreatFairy_MiniBehaviors[])(Entity*); +extern void (*const GreatFairy_MiniAffineBehaviors[])(Entity*); +extern void (*const GreatFairy_DropletBehaviors[])(Entity*); +extern void (*const GreatFairy_RippleBehaviors[])(Entity*); +extern void (*const GreatFairy_BigRippleBehaviors[])(Entity*); +extern void (*const GreatFairy_EnergyBehaviors[])(Entity*); +extern void (*const GreatFairy_Form1Behaviors[])(Entity*); +extern void (*const GreatFairy_Form2Behaviors[])(Entity*); +extern void (*const gUnk_081207A4[])(Entity*); + +extern u32 gUnk_0810C2E4; +extern const s16 GreatFairy_RippleOffsets[10]; +extern u8 gUnk_0812079C[8]; +extern s8 gUnk_081207AC[]; enum { BEHAVIORS, diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index b9747788..79b8425c 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -6,6 +6,7 @@ #include "audio.h" #include "object.h" #include "functions.h" +#include "npc.h" typedef struct { /*0x00*/ u16 unk0; diff --git a/src/object/jarPortal.c b/src/object/jarPortal.c index b5eddce6..d84c12b6 100644 --- a/src/object/jarPortal.c +++ b/src/object/jarPortal.c @@ -1,9 +1,6 @@ -#include "global.h" -#include "entity.h" -#include "flags.h" -#include "functions.h" +#include "object.h" #include "area.h" -#include "audio.h" +#include "functions.h" extern void (*gUnk_08121488[])(Entity*); diff --git a/src/object/lightableSwitch.c b/src/object/lightableSwitch.c index 3bcb95a1..54716b5e 100644 --- a/src/object/lightableSwitch.c +++ b/src/object/lightableSwitch.c @@ -1,4 +1,5 @@ #include "global.h" +#include "audio.h" #include "entity.h" #include "room.h" #include "flags.h" diff --git a/src/object/lilypadSmall.c b/src/object/lilypadSmall.c index ae74c9c8..31c5c3a8 100644 --- a/src/object/lilypadSmall.c +++ b/src/object/lilypadSmall.c @@ -1,13 +1,12 @@ -#include "global.h" -#include "entity.h" -#include "player.h" -#include "random.h" +#include "object.h" #include "functions.h" extern void sub_080A2CC0(Entity*, Entity**, u16*); extern u16 gUnk_08123318[]; +static void sub_08097B24(Entity* this); + void LilypadSmall(Entity* this) { u32 rand; u16* psVar4; @@ -48,7 +47,7 @@ u32 sub_08097ADC(Entity* this) { } } -void sub_08097B24(Entity* this) { +static void sub_08097B24(Entity* this) { u32 temp; u32 temp2; u16* temp3; diff --git a/src/object/lockedDoor.c b/src/object/lockedDoor.c index f81f63b7..fccc8b5f 100644 --- a/src/object/lockedDoor.c +++ b/src/object/lockedDoor.c @@ -1,10 +1,10 @@ #include "global.h" #include "entity.h" #include "flags.h" -#include "game.h" #include "audio.h" #include "functions.h" #include "effects.h" +#include "overworld.h" void sub_08083338(Entity*); void sub_080834B4(Entity*); diff --git a/src/object/mask.c b/src/object/mask.c index 837614bd..854cd5c2 100644 --- a/src/object/mask.c +++ b/src/object/mask.c @@ -1,12 +1,6 @@ -#include "global.h" -#include "entity.h" -#include "room.h" -#include "random.h" +#include "object.h" #include "structures.h" -#include "player.h" -#include "flags.h" #include "functions.h" -#include "effects.h" extern void (*MaskActionFuncs[])(Entity*); diff --git a/src/object/minecart.c b/src/object/minecart.c index fe333927..8f5e9360 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -1,8 +1,5 @@ -#include "global.h" -#include "audio.h" -#include "entity.h" +#include "object.h" #include "functions.h" -#include "room.h" extern u32 sub_08091DDC(Entity*); extern u32 sub_080002B4(Entity*, u32, u32); diff --git a/src/object/minishSizedArchway.c b/src/object/minishSizedArchway.c index 240fdf95..ad001c83 100644 --- a/src/object/minishSizedArchway.c +++ b/src/object/minishSizedArchway.c @@ -1,6 +1,6 @@ #include "global.h" #include "entity.h" -#include "game.h" +#include "overworld.h" void MinishSizedArchway(Entity* this) { if (this->action == 0) { diff --git a/src/object/minishSizedEntrance.c b/src/object/minishSizedEntrance.c index 9338bca5..a92a887c 100644 --- a/src/object/minishSizedEntrance.c +++ b/src/object/minishSizedEntrance.c @@ -1,7 +1,5 @@ -#include "global.h" -#include "entity.h" -#include "game.h" -#include "player.h" +#include "object.h" +#include "overworld.h" #include "functions.h" extern void (*const gUnk_08122254[])(Entity*); diff --git a/src/object/object1A.c b/src/object/object1A.c index 7f76d0f7..bdc3fe49 100644 --- a/src/object/object1A.c +++ b/src/object/object1A.c @@ -1,6 +1,3 @@ -#include "global.h" -#include "entity.h" -#include "random.h" #include "object.h" #include "functions.h" diff --git a/src/object/object2A.c b/src/object/object2A.c index edc742c0..9e36b439 100644 --- a/src/object/object2A.c +++ b/src/object/object2A.c @@ -1,4 +1,5 @@ #include "global.h" +#include "audio.h" #include "entity.h" #include "functions.h" #include "flags.h" diff --git a/src/object/object49.c b/src/object/object49.c index 5a02a82c..125c6440 100644 --- a/src/object/object49.c +++ b/src/object/object49.c @@ -1,8 +1,3 @@ -#include "global.h" -#include "audio.h" -#include "entity.h" -#include "coord.h" -#include "random.h" #include "object.h" #include "structures.h" #include "functions.h" diff --git a/src/object/object86.c b/src/object/object86.c index 147e623c..b5c9e60b 100644 --- a/src/object/object86.c +++ b/src/object/object86.c @@ -1,8 +1,4 @@ -#include "global.h" -#include "entity.h" -#include "coord.h" -#include "player.h" -#include "flags.h" +#include "object.h" #include "functions.h" void sub_08099ECC(Entity*); diff --git a/src/object/objectA.c b/src/object/objectA.c index 9335bdc5..c7d885e7 100644 --- a/src/object/objectA.c +++ b/src/object/objectA.c @@ -4,6 +4,7 @@ #include "flags.h" #include "createObject.h" #include "functions.h" +#include "overworld.h" extern Hitbox gHitbox_2; diff --git a/src/object/objectA2.c b/src/object/objectA2.c index 8d751592..c3ad215b 100644 --- a/src/object/objectA2.c +++ b/src/object/objectA2.c @@ -1,11 +1,7 @@ -#include "global.h" #include "object.h" #include "menu.h" -#include "random.h" -#include "audio.h" #include "structures.h" #include "functions.h" -#include "effects.h" void sub_0809F318(Entity*); void sub_0809F374(Entity*); diff --git a/src/object/octorokBossObject.c b/src/object/octorokBossObject.c index b1df61ee..6e69a7db 100644 --- a/src/object/octorokBossObject.c +++ b/src/object/octorokBossObject.c @@ -1,10 +1,6 @@ -#include "global.h" -#include "entity.h" -#include "coord.h" -#include "audio.h" #include "functions.h" -#include "random.h" #include "object.h" +#include "overworld.h" extern void sub_0807B9B8(s32, s32, s32); diff --git a/src/object/palaceArchway.c b/src/object/palaceArchway.c index cec05cbe..13e6d3bb 100644 --- a/src/object/palaceArchway.c +++ b/src/object/palaceArchway.c @@ -1,7 +1,4 @@ -#include "global.h" -#include "entity.h" -#include "room.h" -#include "functions.h" +#include "object.h" extern void (*const gUnk_081246EC[])(Entity*); diff --git a/src/object/pot.c b/src/object/pot.c index 110c1eb8..dd645021 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -1,4 +1,5 @@ #include "global.h" +#include "audio.h" #include "entity.h" #include "flags.h" #include "player.h" diff --git a/src/object/railtrack.c b/src/object/railtrack.c index 00fbb4ec..223a5603 100644 --- a/src/object/railtrack.c +++ b/src/object/railtrack.c @@ -1,4 +1,5 @@ #include "global.h" +#include "audio.h" #include "entity.h" #include "room.h" #include "flags.h" diff --git a/src/object/smoke.c b/src/object/smoke.c index 17ec7ad0..d603ea1c 100644 --- a/src/object/smoke.c +++ b/src/object/smoke.c @@ -1,8 +1,4 @@ -#include "global.h" -#include "entity.h" -#include "random.h" #include "object.h" -#include "functions.h" extern void (*const gUnk_08121060[])(Entity*); extern void (*const gUnk_08121070[])(Entity*); diff --git a/src/object/thoughtBubble.c b/src/object/thoughtBubble.c index 1789195b..e90cfbd7 100644 --- a/src/object/thoughtBubble.c +++ b/src/object/thoughtBubble.c @@ -1,7 +1,6 @@ #include "global.h" #include "entity.h" #include "audio.h" -#include "functions.h" extern void (*const ThoughtBubble_Behaviors[])(Entity*); diff --git a/src/object/treeThorns.c b/src/object/treeThorns.c index 5a52b9a5..8cd2a06f 100644 --- a/src/object/treeThorns.c +++ b/src/object/treeThorns.c @@ -3,7 +3,6 @@ #include "coord.h" #include "room.h" #include "object.h" -#include "functions.h" extern Hitbox gHitbox_1; diff --git a/src/object/warpPoint.c b/src/object/warpPoint.c index 58b2722b..b238e897 100644 --- a/src/object/warpPoint.c +++ b/src/object/warpPoint.c @@ -2,12 +2,15 @@ #include "object.h" #include "player.h" #include "flags.h" -#include "game.h" +#include "overworld.h" #include "audio.h" #include "functions.h" extern Hitbox gHitbox_1; +extern void sub_0807CAC8(u32); +extern u32 sub_0807CAEC(u32); + void WarpPoint(Entity*); void sub_0808B474(Entity*); void sub_0808B530(Entity*); diff --git a/src/object/windTribeFlag.c b/src/object/windTribeFlag.c index 1fcfea7d..b8943a58 100644 --- a/src/object/windTribeFlag.c +++ b/src/object/windTribeFlag.c @@ -1,6 +1,4 @@ -#include "global.h" -#include "entity.h" -#include "random.h" +#include "object.h" void WindTribeFlag(Entity* this) { if (this->action == 0) { diff --git a/src/objectUtils.c b/src/objectUtils.c index 01fe8c6c..b250b0e6 100644 --- a/src/objectUtils.c +++ b/src/objectUtils.c @@ -24,7 +24,7 @@ u32 LoadObjectSprite(Entity* this, s32 type, const ObjectDefinition* definition) u16 tmp1; u8 tmp2; - if ((this->flags & 1) != 0) { + if ((this->flags & ENT_DID_INIT) != 0) { // Sprite already loaded return 1; } diff --git a/src/overworld.c b/src/overworld.c index 417988e0..f33a2584 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -14,6 +14,7 @@ #include "structures.h" #include "area.h" #include "textbox.h" +#include "overworld.h" extern u32 gUnk_03003FC0; @@ -43,8 +44,6 @@ void sub_0801AE44(u32); void sub_0801862C(void); void sub_08078160(u32); void SetPlayerEventPriority(void); -void InitAllRoomResInfo(void); -void InitRoomResInfo(RoomResInfo* info, RoomHeader* hdr, u32 area, u32 room); RoomResInfo* GetCurrentRoomInfo(void); void sub_08049D30(void); void InitScriptData(void); @@ -55,8 +54,6 @@ void sub_08052FF4(u32 area, u32 room); void sub_0807C860(void); void sub_0807C740(void); void sub_080197AC(void); -void sub_080532E4(void); -void sub_08053460(void); void sub_08053390(void); static u32 StairsAreValid(); @@ -64,6 +61,10 @@ static void ClearFlagArray(const u16*); static void DummyHandler(u32* a1); static void sub_08053434(u32* a1); static void sub_080534E4(u32* a1); +static void InitAllRoomResInfo(void); +static void InitRoomResInfo(RoomResInfo* info, RoomHeader* hdr, u32 area, u32 room); +static void sub_080532E4(void); +static void sub_08053460(void); typedef struct { u16* dest; @@ -90,9 +91,6 @@ typedef struct { u16 _a; } PopupOption; -extern Font gUnk_080FCA8C; -extern PopupOption gUnk_080FCAA4[4]; - extern void CreateDialogBox(); void sub_0805212C(void) { @@ -113,7 +111,7 @@ void sub_0805212C(void) { SetPopupState(0, 0); gScreen.lcd.displayControl |= DISPCNT_BG1_ON | DISPCNT_BG2_ON; gFadeControl.mask = 0x0000ffff; - DoFade(4, 0x10); + DoFade(4, 16); #endif } } @@ -261,7 +259,11 @@ void sub_080522F4(void) { void nullsub_107(void) { } -void sub_080523D4(void) { +void DrawGameOverText(void) { + static const u8 sOffsets[] = { + 48, 68, 88, 108, 137, 156, 174, 192, + }; + u32 i; gOamCmd._4 = 0; @@ -269,7 +271,7 @@ void sub_080523D4(void) { gOamCmd._8 = 0x8600; gOamCmd.y = gMenu.focusCoords[0]; for (i = 0; i < 8; ++i) { - gOamCmd.x = gUnk_080FCA84[i]; + gOamCmd.x = sOffsets[i]; #ifdef EU sub_080ADA14(0x1fc, i); #else @@ -279,8 +281,31 @@ void sub_080523D4(void) { } void SetPopupState(u32 type, u32 choice_idx) { + static const Font sDefaultFont = { + .dest = gBG1Buffer, + .gfx_dest = (u16*)0x06006000, + .buffer_loc = gTextGfxBuffer, + ._c = 0, + .gfx_src = 0xD300, + .width = 0xE0, + .right_align = 0, + .sm_border = 0, + .unused = 0, + .draw_border = 0, + .border_type = 0, + .fill_type = 6, + ._15 = 4, + ._16 = 1, + .stylized = 0, + }; + static const PopupOption sPopupOptions[] = { + { { 11, 11, 11, 10, 11, 10, 10, 0 }, 8, 0, 16 }, + { { 10, 11, 11, 9, 11, 9, 9, 0 }, 8, 0, 17 }, + { { 15, 15, 15, 15, 15, 15, 15, 0 }, 5, 1, 13 }, + }; + Font font; - PopupOption* opt; + const PopupOption* opt; u32 fakematch; MemClear(gBG1Buffer, sizeof gBG1Buffer); @@ -290,9 +315,9 @@ void SetPopupState(u32 type, u32 choice_idx) { gUnk_020227E8[3]._0.WORD = 0xf; *(&gUnk_020227E8[choice_idx]._0.BYTES.byte0 + 1) = fakematch = 1; - MemCopy(&gUnk_080FCA8C, &font, sizeof font); - opt = &gUnk_080FCAA4[type]; - font.dest = gUnk_080FCA8C.dest + (opt->dest_off[gSaveHeader->gameLanguage] + opt->_8 * 32); + MemCopy(&sDefaultFont, &font, sizeof font); + opt = &sPopupOptions[type]; + font.dest = sDefaultFont.dest + (opt->dest_off[gSaveHeader->gameLanguage] + opt->_8 * 32); font.right_align = opt->right_align; sub_0805F46C(opt->_a, &font); gScreen.bg1.updated = fakematch; @@ -437,7 +462,7 @@ void ModRupees(s32 rupeeDelta) { s->rupees = newRupeeCount; } -void sub_080526F8(int a1) { +void sub_080526F8(s32 a1) { if (sub_08052724()) { u8* p = &gSave.unk45C[gArea.dungeon_idx]; if (*p + a1 < 0) @@ -451,7 +476,7 @@ u32 sub_08052724(void) { return (gArea.areaMetadata >> 1) & 1; } -u32 sub_08052734(u32 x, u32 y) { +u32 HasDungeonMap(void) { u32 tmp; if (sub_08052724()) @@ -459,7 +484,7 @@ u32 sub_08052734(u32 x, u32 y) { return tmp ? 1 : 0; } -u32 sub_08052764(u32 x, u32 y) { +u32 HasDungeonCompass(void) { u32 tmp; if (sub_08052724()) @@ -467,13 +492,13 @@ u32 sub_08052764(u32 x, u32 y) { return tmp ? 1 : 0; } -u32 sub_0805279C(u32 x, u32 y) { +u32 HasDungeonBigKey(void) { if (!sub_08052724()) return 0; return (gSave.unk46C[gArea.dungeon_idx] >> 1) & 1; } -u32 sub_080527CC(u32 x, u32 y) { +u32 HasDungeonSmallKey(void) { u32 tmp; if (!sub_08052724()) @@ -482,7 +507,7 @@ u32 sub_080527CC(u32 x, u32 y) { } void sub_080527FC(u32 a1, u32 a2) { - sub_08053320(a1, a2); + sub_08053320(); #ifndef EU CleanUpGFXSlots(); #endif @@ -506,7 +531,7 @@ void sub_08052878(void) { SoundReq(SONG_STOP_ALL); } -void sub_0805289C(void) { +static void sub_0805289C(void) { gArea.pMusicIndex = gArea.musicIndex; } #endif @@ -724,7 +749,7 @@ void sub_08052CD0(u32 area, u32 room, u32 x, u32 y) { gScreenTransition.player_status.field_0x1e = hdr->map_y + y; } -void sub_08052CFC() { +void sub_08052CFC(void) { AreaHeader* a_hdr = NULL; MemClear(&gArea, sizeof gArea); @@ -753,7 +778,7 @@ void RegisterTransitionManager(void* mgr, void (*onEnter)(), void (*onExit)()) { } } -void InitAllRoomResInfo(void) { +static void InitAllRoomResInfo(void) { RoomHeader* r_hdr = gAreaRoomHeaders[gRoomControls.areaID]; RoomResInfo* info = gArea.roomResInfos; u32 i; @@ -765,7 +790,7 @@ void InitAllRoomResInfo(void) { gArea.pCurrentRoomInfo = GetCurrentRoomInfo(); } -void InitRoomResInfo(RoomResInfo* info, RoomHeader* r_hdr, u32 area, u32 room) { +static void InitRoomResInfo(RoomResInfo* info, RoomHeader* r_hdr, u32 area, u32 room) { info->map_x = r_hdr->map_x; info->map_y = r_hdr->map_y; info->pixel_width = r_hdr->pixel_width; @@ -800,7 +825,7 @@ void sub_08052EA0(void) { UpdateGlobalProgress(); } -u32 sub_08052EF4(s32 idx) { +static u32 sub_08052EF4(s32 idx) { AreaHeader* a_hdr = NULL; u32 i = idx < 0 ? gRoomControls.areaID : idx; a_hdr = &gAreaMetadata[i]; @@ -885,7 +910,7 @@ void ChangeLightLevel(s32 lightLevel) { gRoomVars.lightLevel = lightLevel; } -void sub_080530B0(void) { +static void sub_080530B0(void) { static const u16 sMinecartData[] = { 0x189, 0x0, 0x102, 0x4, 0x1af, 0x0, 0x204, 0x0, 0x1cf, 0x0, 0x10, 0x4, 0x0, 0x0, 0x0, 0x0 }; @@ -912,7 +937,7 @@ void UpdateGlobalProgress(void) { gSave.global_progress = pcnt; } -u32 sub_08053144(void) { +static u32 sub_08053144(void) { u32 ret; if (CheckGlobalFlag(ENDING)) @@ -992,7 +1017,7 @@ void sub_0805329C(void) { } } -void sub_080532E4(void) { +static void sub_080532E4(void) { s32 x, y; RoomHeader* r_hdr = gAreaRoomHeaders[AREA_FORTRESS_OF_WINDS] + 33; @@ -1065,7 +1090,7 @@ static void sub_08053434(u32* a1) { } } -void sub_08053460(void) { +static void sub_08053460(void) { static const u16 sClearFlags[] = { FLAG_BANK_10, LV6_GUFUU1_GISHIKI, FLAG_BANK_10, LV6_GUFUU1_DEMO, FLAG_BANK_10, LV6_ZELDA_DISCURSE, FLAG_BANK_10, LV6_00_ESCAPE, FLAG_BANK_10, LV6_GUFUU2_DEAD, FLAG_BANK_G, ENDING, diff --git a/src/player.c b/src/player.c index 3f2c89e5..b0bedf4d 100644 --- a/src/player.c +++ b/src/player.c @@ -1,4 +1,5 @@ #include "global.h" +#include "asm.h" #include "audio.h" #include "entity.h" #include "player.h" @@ -6,13 +7,13 @@ #include "utils.h" #include "area.h" #include "save.h" -#include "game.h" #include "object.h" #include "functions.h" #include "object.h" #include "effects.h" -#include "random.h" #include "hitbox.h" +#include "overworld.h" +#include "screen.h" typedef void(EntityAction)(Entity*); @@ -181,7 +182,6 @@ extern void sub_080797EC(); extern void sub_08079E08(); extern void sub_08078F60(); extern void sub_08077698(); -extern void DisplayEzloMessage(); extern void sub_08079258(); extern void sub_0807A298(); extern u32 sub_08079B24(); @@ -206,6 +206,7 @@ extern u32 sub_0806F730(); extern u32 sub_08007DD6(); extern u32 GetSurfaceCalcType(); extern void sub_08074808(); +extern void sub_08073904(Entity*); extern ScreenTransitionData gUnk_0813AB58; diff --git a/src/playerItem/playerItem10.c b/src/playerItem/playerItem10.c index d733570d..02ff1fb6 100644 --- a/src/playerItem/playerItem10.c +++ b/src/playerItem/playerItem10.c @@ -1,7 +1,7 @@ #include "entity.h" #include "player.h" #include "functions.h" -#include "random.h" +#include "asm.h" extern void (*const gUnk_0812AA80[])(Entity*); diff --git a/src/playerItem/playerItem12.c b/src/playerItem/playerItem12.c index 1c14e0ed..3f750765 100644 --- a/src/playerItem/playerItem12.c +++ b/src/playerItem/playerItem12.c @@ -1,3 +1,4 @@ +#include "asm.h" #include "entity.h" #include "functions.h" #include "audio.h" diff --git a/src/playerItem/playerItem3.c b/src/playerItem/playerItem3.c index 790062c0..83fdea5a 100644 --- a/src/playerItem/playerItem3.c +++ b/src/playerItem/playerItem3.c @@ -1,4 +1,5 @@ #include "entity.h" +#include "audio.h" #include "functions.h" extern void (*const gUnk_080B77FC[])(Entity*); diff --git a/src/playerItem/playerItemBow.c b/src/playerItem/playerItemBow.c index 6c2b8206..f9739d9b 100644 --- a/src/playerItem/playerItemBow.c +++ b/src/playerItem/playerItemBow.c @@ -1,4 +1,5 @@ #include "global.h" +#include "asm.h" #include "entity.h" #include "functions.h" #include "effects.h" diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c index 4a805082..791dd040 100644 --- a/src/projectile/dirtBallProjectile.c +++ b/src/projectile/dirtBallProjectile.c @@ -1,3 +1,4 @@ +#include "audio.h" #include "entity.h" #include "enemy.h" #include "player.h" diff --git a/src/projectile/gleerokProjectile.c b/src/projectile/gleerokProjectile.c index 3c59c8f2..f4d71406 100644 --- a/src/projectile/gleerokProjectile.c +++ b/src/projectile/gleerokProjectile.c @@ -3,7 +3,7 @@ #include "enemy.h" #include "player.h" #include "functions.h" -#include "random.h" +#include "asm.h" #include "audio.h" #include "effects.h" diff --git a/src/projectile/guardLineOfSight.c b/src/projectile/guardLineOfSight.c index cf0510e4..a4a87308 100644 --- a/src/projectile/guardLineOfSight.c +++ b/src/projectile/guardLineOfSight.c @@ -1,5 +1,5 @@ #include "entity.h" -#include "random.h" +#include "asm.h" #include "coord.h" #include "functions.h" diff --git a/src/projectile/gyorgTail.c b/src/projectile/gyorgTail.c index 684ace6b..556087f7 100644 --- a/src/projectile/gyorgTail.c +++ b/src/projectile/gyorgTail.c @@ -1,5 +1,5 @@ #include "entity.h" -#include "random.h" +#include "asm.h" #include "coord.h" #include "audio.h" #include "functions.h" diff --git a/src/projectile/mandiblesProjectile.c b/src/projectile/mandiblesProjectile.c index c50657f9..79fcb38b 100644 --- a/src/projectile/mandiblesProjectile.c +++ b/src/projectile/mandiblesProjectile.c @@ -3,8 +3,8 @@ #include "coord.h" #include "functions.h" #include "audio.h" -#include "random.h" -#include "game.h" +#include "asm.h" +#include "overworld.h" extern Entity* sub_08049DF4(u32); extern u32 sub_08049F1C(Entity*, Entity*, u32); diff --git a/src/projectile/octorokBossProjectile.c b/src/projectile/octorokBossProjectile.c index 58b6dbfc..70315175 100644 --- a/src/projectile/octorokBossProjectile.c +++ b/src/projectile/octorokBossProjectile.c @@ -1,6 +1,6 @@ #include "entity.h" #include "enemy.h" -#include "random.h" +#include "asm.h" #include "functions.h" #include "audio.h" #include "effects.h" diff --git a/src/projectile/v1DarkMagicProjectile.c b/src/projectile/v1DarkMagicProjectile.c index 529d46e7..76097b4d 100644 --- a/src/projectile/v1DarkMagicProjectile.c +++ b/src/projectile/v1DarkMagicProjectile.c @@ -4,7 +4,7 @@ #include "player.h" #include "audio.h" #include "functions.h" -#include "random.h" +#include "asm.h" extern void sub_0800449C(Entity*, u32); diff --git a/src/projectile/v1FireProjectile.c b/src/projectile/v1FireProjectile.c index 3379c344..4384766d 100644 --- a/src/projectile/v1FireProjectile.c +++ b/src/projectile/v1FireProjectile.c @@ -3,7 +3,7 @@ #include "player.h" #include "functions.h" #include "audio.h" -#include "random.h" +#include "asm.h" extern void sub_0806F5BC(Entity*, u32, u32); extern u32 sub_080041DC(Entity*, u32, u32); diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c index c7be6769..e0213f6f 100644 --- a/src/projectile/v2Projectile.c +++ b/src/projectile/v2Projectile.c @@ -2,7 +2,7 @@ #include "entity.h" #include "enemy.h" #include "functions.h" -#include "random.h" +#include "asm.h" #include "audio.h" #include "effects.h" diff --git a/src/projectile/winder.c b/src/projectile/winder.c index 640038e2..0075763c 100644 --- a/src/projectile/winder.c +++ b/src/projectile/winder.c @@ -1,5 +1,5 @@ #include "entity.h" -#include "random.h" +#include "asm.h" #include "functions.h" #include "utils.h" diff --git a/src/projectileUtils.c b/src/projectileUtils.c index 5c82f3cf..7e4ee3ef 100644 --- a/src/projectileUtils.c +++ b/src/projectileUtils.c @@ -16,7 +16,7 @@ const ProjectileDefinition* GetProjectileDefinition(Entity* this) { } bool32 ProjectileInit(Entity* this) { - if ((this->flags & 1) == 0) { + if ((this->flags & ENT_DID_INIT) == 0) { const ProjectileDefinition* definition = GetProjectileDefinition(this); if (LoadProjectileSprite(this, definition) == FALSE) { return FALSE; diff --git a/src/room.c b/src/room.c index ae2bb9f0..f685c833 100644 --- a/src/room.c +++ b/src/room.c @@ -5,6 +5,7 @@ #include "functions.h" #include "utils.h" #include "object.h" +#include "overworld.h" extern void sub_0804B058(EntityData* dat); extern void sub_0801AC98(); diff --git a/src/roomInit.c b/src/roomInit.c index 223d7c99..e553a20f 100644 --- a/src/roomInit.c +++ b/src/roomInit.c @@ -1,7 +1,7 @@ #include "global.h" #include "main.h" -#include "random.h" +#include "utils.h" #include "functions.h" #include "structures.h" @@ -13,14 +13,18 @@ #include "item.h" #include "save.h" #include "script.h" +#include "screen.h" #include "area.h" #include "room.h" +#include "overworld.h" #include "entity.h" #include "npc.h" #include "player.h" +static void sub_0804E150(void); + u32 sub_unk3_ArmosInteriors_RuinsEntranceNorth(u32 arg0) { return 1; } diff --git a/src/save.c b/src/save.c index 177ad460..a5b8caea 100644 --- a/src/save.c +++ b/src/save.c @@ -4,6 +4,7 @@ #include "menu.h" #include "main.h" #include "functions.h" +#include "overworld.h" typedef struct SaveFileStatus { u16 checksum1; diff --git a/src/script.c b/src/script.c index 1ca4785a..6d7203eb 100644 --- a/src/script.c +++ b/src/script.c @@ -1,18 +1,14 @@ -#include "global.h" -#include "audio.h" -#include "flags.h" -#include "entity.h" -#include "area.h" #include "script.h" -#include "structures.h" -#include "textbox.h" -#include "utils.h" -#include "save.h" -#include "random.h" -#include "audio.h" -#include "functions.h" #include "main.h" -#include "effects.h" +#include "screen.h" +#include "area.h" +#include "overworld.h" + +#include "object.h" +#include "npc.h" + +#include "functions.h" +#include "structures.h" void InitScriptForEntity(Entity*, ScriptExecutionContext*, u16*); void InitScriptExecutionContext(ScriptExecutionContext* context, u16* script); @@ -733,16 +729,16 @@ void ScriptCommand_CheckInventory1(Entity* entity, ScriptExecutionContext* conte u32 tmp2 = GetNextScriptCommandHalfwordAfterCommandMetadata(context->scriptInstructionPointer); switch (tmp2) { case 0x53: - tmp = sub_08052734(); + tmp = HasDungeonMap(); break; case 0x52: - tmp = sub_08052764(); + tmp = HasDungeonCompass(); break; case 0x51: - tmp = sub_0805279C(); + tmp = HasDungeonBigKey(); break; case 0x50: - tmp = sub_080527CC(); + tmp = HasDungeonSmallKey(); break; default: tmp = GetInventoryValue(tmp2); diff --git a/src/sub_08055E08.c b/src/sub_08055E08.c index e564244f..2c0532eb 100644 --- a/src/sub_08055E08.c +++ b/src/sub_08055E08.c @@ -2,6 +2,7 @@ #include "menu.h" #include "room.h" #include "functions.h" +#include "screen.h" extern void (*const gUnk_080FF420[])(); extern void sub_0804B0B0(u32, u32); diff --git a/src/sub_0807B820.c b/src/sub_0807B820.c index 14da7b18..7d2441c3 100644 --- a/src/sub_0807B820.c +++ b/src/sub_0807B820.c @@ -1,7 +1,6 @@ -#include "global.h" -#include "functions.h" +#include "asm.h" +#include "room.h" -extern void sub_08000152(u32); extern void sub_0807B778(u32, u32); void sub_0807B7D8(u32 param_1, u32 param_2, u32 param_3) { diff --git a/src/sub_0807C998.c b/src/sub_0807C998.c deleted file mode 100644 index 361c0142..00000000 --- a/src/sub_0807C998.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "global.h" - -extern void sub_0807C960(); -extern void LoadPalettes(const u8*, s32, s32); - -extern u16 gMetatilesBottom[]; -extern u16 gMetatilesTop[]; -extern u8 gMapData; - -extern const u8 gUnk_020176E0[]; - -void sub_0807C960(void* dest, u32 offset) { - void* src; - - if (offset != -1) { - src = &gMapData + (offset & 0x7fffffff); - if ((u32)dest >> 0x18 == 6) { - LZ77UnCompVram(src, (void*)dest); - } else { - LZ77UnCompWram(src, (void*)dest); - } - } -} - -void sub_0807C998(u32* a1) { - sub_0807C960(gMetatilesBottom, a1[0]); - sub_0807C960(gMetatilesBottom - 0x1000, a1[1]); - sub_0807C960(gMetatilesTop, a1[2]); - sub_0807C960(gMetatilesTop - 0x1000, a1[3]); -} - -void sub_0807C9D8(u32* a1) { - u32* v1; // r5@1 - - v1 = a1; - sub_0807C960((u8*)0x6004000, *a1); - sub_0807C960((u8*)0x6000000, v1[1]); - sub_0807C960((u8*)0x6008000, v1[2]); - sub_0807C960((u8*)gUnk_020176E0, v1[3]); - LoadPalettes(gUnk_020176E0, 2, 13); -} diff --git a/src/sub_0807CA18.c b/src/sub_0807CA18.c index 3e99e52b..d74a54c3 100644 --- a/src/sub_0807CA18.c +++ b/src/sub_0807CA18.c @@ -3,6 +3,46 @@ #include "save.h" #include "utils.h" +extern void sub_0807C960(); +extern void LoadPalettes(const u8*, s32, s32); + +extern u16 gMetatilesBottom[]; +extern u16 gMetatilesTop[]; +extern u8 gMapData; + +extern const u8 gUnk_020176E0[]; + +void sub_0807C960(void* dest, u32 offset) { + void* src; + + if (offset != -1) { + src = &gMapData + (offset & 0x7fffffff); + if ((u32)dest >> 0x18 == 6) { + LZ77UnCompVram(src, (void*)dest); + } else { + LZ77UnCompWram(src, (void*)dest); + } + } +} + +void sub_0807C998(u32* a1) { + sub_0807C960(gMetatilesBottom, a1[0]); + sub_0807C960(gMetatilesBottom - 0x1000, a1[1]); + sub_0807C960(gMetatilesTop, a1[2]); + sub_0807C960(gMetatilesTop - 0x1000, a1[3]); +} + +void sub_0807C9D8(u32* a1) { + u32* v1; // r5@1 + + v1 = a1; + sub_0807C960((u8*)0x6004000, *a1); + sub_0807C960((u8*)0x6000000, v1[1]); + sub_0807C960((u8*)0x6008000, v1[2]); + sub_0807C960((u8*)gUnk_020176E0, v1[3]); + LoadPalettes(gUnk_020176E0, 2, 13); +} + u8 sub_0807CA18() { if (gSave.unk_00 != 0x00 || gSave.unk_01 != 1) { gSave.unk_00 = 0; diff --git a/src/sub_08127D30.c b/src/sub_08127D30.c deleted file mode 100644 index 13b6839b..00000000 --- a/src/sub_08127D30.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "global.h" - -extern u8 gAreaMetadata[69]; - -u32 sub_08052654(u32 r0) { - return gAreaMetadata[r0 * 4] == 129; -} diff --git a/src/utils.c b/src/utils.c index feb31265..f8ae7c2d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -113,7 +113,7 @@ void LoadPaletteGroup(u32 group) { } } -void LoadPalettes(const u8* src, int destPaletteNum, int numPalettes) { +void LoadPalettes(const u8* src, s32 destPaletteNum, s32 numPalettes) { u16* dest; u32 size = numPalettes * 32; u32 usedPalettesMask = 1 << destPaletteNum;