From 46506530fc489732833e26d321b8879e9b13e6b4 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Sun, 9 Mar 2025 12:01:00 +0000 Subject: [PATCH] cleanup structures.h --- include/beanstalkSubtask.h | 15 + include/color.h | 2 +- include/entity.h | 10 + include/fade.h | 3 + include/gfx.h | 8 + include/itemDefinitions.h | 20 ++ include/main.h | 12 + include/message.h | 8 + include/pauseMenu.h | 16 ++ include/player.h | 31 ++ include/scroll.h | 6 + include/structures.h | 268 +----------------- include/ui.h | 98 +++++++ include/vram.h | 28 ++ src/affine.c | 1 - src/backgroundAnimations.c | 2 +- src/beanstalkSubtask.c | 2 +- src/code_0805EC04.c | 2 +- src/collision.c | 1 - src/color.c | 17 +- src/common.c | 5 +- src/cutscene.c | 1 - src/debug.c | 1 - src/demo.c | 1 - src/enemy/chuchuBoss.c | 2 +- src/enemy/gleerok.c | 2 +- src/enemy/mazaalMacro.c | 1 - src/enemy/octorokBoss.c | 2 +- src/enemy/waterDrop.c | 2 +- src/enterPortalSubtask.c | 4 +- src/entity.c | 1 - src/fade.c | 10 +- src/fileselect.c | 2 +- src/game.c | 2 +- src/gameUtils.c | 4 +- src/interrupts.c | 1 - src/item/itemOcarina.c | 2 +- src/item/itemTryPickupObject.c | 2 +- src/itemDefinitions.c | 2 +- src/itemUtils.c | 2 +- src/main.c | 1 - src/manager/diggingCaveEntranceManager.c | 1 - src/manager/enterRoomTextboxManager.c | 2 +- src/manager/holeManager.c | 2 +- .../horizontalMinishPathBackgroundManager.c | 2 +- src/manager/lightRayManager.c | 1 - src/manager/minishRaftersBackgroundManager.c | 2 +- src/manager/minishVillageTileSetManager.c | 3 +- src/manager/rollingBarrelManager.c | 2 +- src/manager/secretManager.c | 1 - src/manager/templeOfDropletsManager.c | 3 +- src/manager/vaati3InsideArmManager.c | 1 - src/manager/weatherChangeManager.c | 1 - src/menu/figurineMenu.c | 2 +- src/menu/kinstoneMenu.c | 1 - src/menu/pauseMenu.c | 3 +- src/menu/pauseMenuScreen6.c | 1 - src/message.c | 2 +- src/npc/beedle.c | 1 - src/npc/drLeft.c | 1 - src/npc/ghostBrothers.c | 2 +- src/npc/mayorHagen.c | 1 - src/npc/npc23.c | 2 +- src/npc/npc4E.c | 1 - src/npc/postman.c | 1 - src/npc/rem.c | 1 - src/npc/smallTownMinish.c | 1 - src/npc/smith.c | 1 - src/npc/stockwell.c | 1 - src/npc/townMinish.c | 1 - src/object/bird.c | 2 +- src/object/cameraTarget.c | 1 - src/object/chestSpawner.c | 2 +- src/object/cloud.c | 2 +- src/object/crenelBeanSprout.c | 2 +- src/object/fileScreenObjects.c | 2 +- src/object/itemForSale.c | 2 +- src/object/linkAnimation.c | 2 +- src/object/macroMushroomStalk.c | 2 +- src/object/macroPlayer.c | 2 +- src/object/minishPortalCloseup.c | 1 - src/object/minishPortalStone.c | 2 +- src/object/windcrest.c | 1 - src/objectUtils.c | 2 +- src/physics.c | 20 +- src/player.c | 3 +- src/playerItem/playerItemPacciCane.c | 2 +- src/playerUtils.c | 16 +- src/script.c | 2 +- src/scroll.c | 1 - src/staffroll.c | 18 +- src/subtask.c | 2 +- src/subtask/subtaskAuxCutscene.c | 1 - src/subtask/subtaskFastTravel.c | 2 +- src/subtask/subtaskLocalMapHint.c | 2 +- src/text.c | 1 - src/title.c | 1 - src/ui.c | 4 +- src/vram.c | 2 +- 99 files changed, 363 insertions(+), 383 deletions(-) create mode 100644 include/gfx.h create mode 100644 include/itemDefinitions.h diff --git a/include/beanstalkSubtask.h b/include/beanstalkSubtask.h index e89df836..3a91465e 100644 --- a/include/beanstalkSubtask.h +++ b/include/beanstalkSubtask.h @@ -45,4 +45,19 @@ typedef struct { */ extern void SetMultipleTiles(const TileData* tileData, u32 basePosition, u32 layer); +typedef struct { + u8 unk_0; + u8 unk_1; + u8 unk_2[2]; + u16 unk_4; + u8 filler[12]; + struct Entity_* unk_14; + u8 unk_18; + u8 unk_19; + u8 unk_1a; + u8 unk_1b; +} struct_02018EB0; + +extern struct_02018EB0 gUnk_02018EB0; + #endif // BEANSTALKSUBTASK_H diff --git a/include/color.h b/include/color.h index eaebb6a6..06c6662c 100644 --- a/include/color.h +++ b/include/color.h @@ -23,7 +23,7 @@ typedef struct { u16 unk_02; union SplitWord unk_04; union SplitWord unk_08; - u32 unk_0C; + void* unk_0C; } struct_gUnk_020000C0_1; typedef struct { diff --git a/include/entity.h b/include/entity.h index de76f3b7..a332089e 100644 --- a/include/entity.h +++ b/include/entity.h @@ -537,6 +537,16 @@ typedef struct { } CarriedEntity; extern CarriedEntity gCarriedEntity; +typedef struct { + u8 event_priority; /**< system requested priority @see Priority */ + u8 ent_priority; /**< entity requested priority @see Priority */ + u8 queued_priority; /**< @see Priority */ + u8 queued_priority_reset; /**< @see Priority */ + Entity* requester; + u16 priority_timer; +} PriorityHandler; +extern PriorityHandler gPriorityHandler; + /** * Current number of entities. * @see Entity diff --git a/include/fade.h b/include/fade.h index c9b30e10..e623df25 100644 --- a/include/fade.h +++ b/include/fade.h @@ -100,4 +100,7 @@ void FadeVBlank(void); */ void ResetFadeMask(void); +extern u32 gUsedPalettes; +#define USE_PALETTE(i) do { gUsedPalettes |= 1 << (i); } while(0) + #endif // FADE_H diff --git a/include/gfx.h b/include/gfx.h new file mode 100644 index 00000000..b0ecd2a4 --- /dev/null +++ b/include/gfx.h @@ -0,0 +1,8 @@ +#ifndef GFX_H +#define GFX_H + +#include "global.h" + +extern const u8 gGlobalGfxAndPalettes[]; + +#endif //GFX_H diff --git a/include/itemDefinitions.h b/include/itemDefinitions.h new file mode 100644 index 00000000..f48fa18a --- /dev/null +++ b/include/itemDefinitions.h @@ -0,0 +1,20 @@ +#ifndef ITEMDEFINITIONS_H +#define ITEMDEFINITIONS_H + +#include "global.h" + +typedef struct { + /*0x00*/ bool8 isOnlyActiveFirstFrame; /**< Is the behavior for this item only created on the first frame */ + /*0x01*/ u8 priority; + /*0x02*/ u8 createFunc; + /*0x03*/ u8 playerItemId; /**< Id for the corresponsing PlayerItem. */ + /*0x04*/ u16 frameIndex; + /*0x06*/ u8 animPriority; + /*0x07*/ bool8 isChangingAttackStatus; + /*0x08*/ bool8 isUseableAsMinish; + /*0x09*/ u8 pad[3]; +} ItemDefinition; + +static_assert(sizeof(ItemDefinition) == 0xc); + +#endif //ITEMDEFINITIONS_H diff --git a/include/main.h b/include/main.h index 859f90ce..8a38f36f 100644 --- a/include/main.h +++ b/include/main.h @@ -101,6 +101,18 @@ static_assert(sizeof(UI) == 0x3b4); extern Main gMain; /**< Main instance. */ extern UI gUI; /**< UI instance. */ +typedef struct { + s32 signature; + u8 field_0x4; + u8 listenForKeyPresses; + u8 field_0x6; + u8 field_0x7; + u8 pad[24]; +} struct_02000010; +static_assert(sizeof(struct_02000010) == 0x20); + +extern struct_02000010 gUnk_02000010; + /** * Program entry point. */ diff --git a/include/message.h b/include/message.h index ddbc473e..dbb5ac55 100644 --- a/include/message.h +++ b/include/message.h @@ -127,6 +127,14 @@ typedef struct { extern TextRender gTextRender; static_assert(sizeof(TextRender) == 0xa8); +typedef struct { + u8 unk_00; + u8 unk_01; + u8 unk_02[0xE]; +} struct_02000040; + +extern struct_02000040 gUnk_02000040; + /** * @brief Initialize the message system. */ diff --git a/include/pauseMenu.h b/include/pauseMenu.h index 1197b2f3..aba00a4a 100644 --- a/include/pauseMenu.h +++ b/include/pauseMenu.h @@ -40,4 +40,20 @@ typedef enum { PauseMenuScreen_19, } PauseMenuScreen; +typedef struct { + u8 disabled; + u8 screen; + u8 unk2[0xf]; // cursor positions on the different screens + u8 unk11; + u8 unk12; + u8 unk13; + s8 screen2; + u8 unk15; + s8 unk16; + u8 unk17; +} PauseMenuOptions; + +extern PauseMenuOptions gPauseMenuOptions; +static_assert(sizeof(PauseMenuOptions) == 0x18); + #endif // PAUSEMENU_H diff --git a/include/player.h b/include/player.h index 956c98f7..ac8bcddf 100644 --- a/include/player.h +++ b/include/player.h @@ -676,6 +676,37 @@ typedef enum { INTERACTION_NULL = 0xFF, } InteractionType; +typedef struct { + s8 x; + s8 y; + s8 width; + s8 height; +} Rect; + +typedef struct { + /*0x00*/ u8 ignoreLayer; /* if bit 0 set, skip layer check for collision */ + /*0x01*/ u8 type; + /*0x02*/ u8 interactDirections; /* lower 4 bits determine Link's allowed facing directions to interact, 0 to allow + (0000WSEN) */ + /*0x03*/ u8 kinstoneId; + /*0x04*/ const Rect* customHitbox; /* optional custom rectangle */ + /*0x08*/ Entity* entity; +} InteractableObject; + +typedef struct { + /*0x00*/ u8 isUpdated; + /*0x01*/ u8 unused; + /*0x02*/ u8 kinstoneId; + /*0x03*/ u8 currentIndex; /* index of currentObject in candidate list, or 0xFF */ + /*0x04*/ InteractableObject* currentObject; + /*0x08*/ InteractableObject + candidates[0x20]; /* contains the loaded NPCs, key doors, windcrests and other objects */ +} PossibleInteraction; + +static_assert(sizeof(PossibleInteraction) == 0x188); + +extern PossibleInteraction gPossibleInteraction; + typedef enum { R_ACTION_NONE, R_ACTION_CANCEL, diff --git a/include/scroll.h b/include/scroll.h index a100093c..486814f2 100644 --- a/include/scroll.h +++ b/include/scroll.h @@ -4,6 +4,12 @@ #include "global.h" #include "transitions.h" +typedef struct { + u16 unk_00; + u8 unk_02[0xE]; +} struct_02034480; +extern struct_02034480 gUnk_02034480; + extern bool32 DoApplicableTransition(u32, u32, u32, u32); extern void DoExitTransitionWithType(const Transition* screenTransition, u32 transitionType); diff --git a/include/structures.h b/include/structures.h index 68dd1f10..811bae31 100644 --- a/include/structures.h +++ b/include/structures.h @@ -2,223 +2,6 @@ #define STRUCTURES_H #include "global.h" -#include "entity.h" - -typedef struct { - u8 unk_00; - u8 unk_01; - u8 unk_02[0xE]; -} struct_02000040; - -extern struct_02000040 gUnk_02000040; - -typedef struct { - s32 signature; - u8 field_0x4; - u8 listenForKeyPresses; - u8 field_0x6; - u8 field_0x7; - u8 pad[24]; -} struct_02000010; -static_assert(sizeof(struct_02000010) == 0x20); - -extern struct_02000010 gUnk_02000010; - -typedef struct { - u8 unk0; - u8 unk1; - u16 unk2; -} struct_020354C0; -extern struct_020354C0 gUnk_020354C0[0x20]; - -#define MAX_UI_ELEMENTS 24 - -typedef enum { - UI_ELEMENT_BUTTON_A, - UI_ELEMENT_BUTTON_B, - UI_ELEMENT_BUTTON_R, - UI_ELEMENT_ITEM_A, - UI_ELEMENT_ITEM_B, - UI_ELEMENT_TEXT_R, - UI_ELEMENT_HEART, - UI_ELEMENT_EZLONAGSTART, - UI_ELEMENT_EZLONAGACTIVE, - UI_ELEMENT_TEXT_A, - UI_ELEMENT_TEXT_B -} UIElementType; - -/** - * @brief Floating UI element - */ -typedef struct { - u8 used : 1; - u8 unk_0_1 : 1; - u8 unk_0_2 : 2; // Load data into VRAM? 0: do not load, 1: ready to load 2: loaded - u8 unk_0_4 : 4; - u8 type; /**< @see UIElementType */ - u8 type2; // Subtype - u8 buttonElementId; /**< Id of the button UI element this text is attached to */ - u8 action; - u8 unk_5; - u8 unk_6; - u8 unk_7; - u8 unk_8; - u8 unk_9[3]; - u16 x; - u16 y; - u8 frameIndex; - u8 duration; - u8 spriteSettings; - u8 frameSettings; - Frame* framePtr; - u8 unk_18; - u8 numTiles; - u16 unk_1a; // TODO oam id? VRAM target (element->unk_1a * 0x20 + 0x6010000) - u32* firstTile; -} UIElement; - -typedef enum { - HUD_HIDE_NONE, - HUD_HIDE_1 = 0x1, // A - HUD_HIDE_2 = 0x2, // B - HUD_HIDE_4 = 0x4, // R - HUD_HIDE_8 = 0x8, - HUD_HIDE_HEARTS = 0x10, - HUD_HIDE_CHARGE_BAR = 0x20, - HUD_HIDE_RUPEES = 0x40, - HUD_HIDE_KEYS = 0x80, - - HUD_HIDE_ALL = 0xff -} HUDHideFlags; - -typedef struct { - u8 unk_0; - u8 hideFlags; - u8 unk_2; - u8 health; - u8 maxHealth; - u8 unk_5; - u8 unk_6; - u8 unk_7; - u8 unk_8; - u8 unk_9; - u8 unk_a; - u8 unk_b; - u8 unk_c; - u8 unk_d; - u16 rupees; - u8 unk_10; // TODO drawing keys dirty flag or something? - u8 unk_11; - u8 dungeonKeys; - s8 unk_13; - s8 unk_14; - u8 unk_15; - u16 buttonX[3]; /**< X coordinates for the button UI elements */ - u16 buttonY[3]; /**< Y coordinates for the button UI elements */ - u8 filler22[0x2]; - u8 ezloNagFuncIndex; - u8 filler25[7]; - u8 rActionInteractObject; // used as R button UI frame index - u8 rActionInteractTile; - u8 rActionGrabbing; - u8 rActionPlayerState; // if not 0, overrides other R actions - u8 buttonText[3]; - u8 unk_33; - UIElement elements[MAX_UI_ELEMENTS]; -} HUD; -extern HUD gHUD; - -typedef struct { - u16 unk_00; - u8 unk_02[0xE]; -} struct_02034480; -extern struct_02034480 gUnk_02034480; - -extern u16 gBG0Buffer[0x400]; -extern u16 gBG1Buffer[0x400]; -extern u16 gBG2Buffer[0x400]; -extern u16 gBG3Buffer[0x800]; - - -typedef struct { - u8 event_priority; // system requested priority - u8 ent_priority; // entity requested priority - u8 queued_priority; - u8 queued_priority_reset; - Entity* requester; - u16 priority_timer; -} PriorityHandler; -extern PriorityHandler gPriorityHandler; - -typedef struct { - u8 disabled; - u8 screen; - u8 unk2[0xf]; // cursor positions on the different screens - u8 unk11; - u8 unk12; - u8 unk13; - s8 screen2; - u8 unk15; - s8 unk16; - u8 unk17; -} PauseMenuOptions; - -extern PauseMenuOptions gPauseMenuOptions; -static_assert(sizeof(PauseMenuOptions) == 0x18); - -typedef struct { - u8 unk0; - u8 unk1; - u16 unk2; - u8 unk4; - u8 unk5; - u8 unk6; - u8 unk7; -} OAMObj; - -typedef struct { - u8 field_0x0; - u8 field_0x1; - u8 spritesOffset; - u8 updated; - u16 _4; - u16 _6; - u8 _0[0x18]; - struct OamData oam[0x80]; - OAMObj unk[0xA0]; /* todo: affine */ -} OAMControls; -extern OAMControls gOAMControls; - -typedef struct { - s8 x; - s8 y; - s8 width; - s8 height; -} Rect; - -typedef struct { - /*0x00*/ u8 ignoreLayer; /* if bit 0 set, skip layer check for collision */ - /*0x01*/ u8 type; - /*0x02*/ u8 interactDirections; /* lower 4 bits determine Link's allowed facing directions to interact, 0 to allow - (0000WSEN) */ - /*0x03*/ u8 kinstoneId; - /*0x04*/ const Rect* customHitbox; /* optional custom rectangle */ - /*0x08*/ Entity* entity; -} InteractableObject; - -typedef struct { - /*0x00*/ u8 isUpdated; - /*0x01*/ u8 unused; - /*0x02*/ u8 kinstoneId; - /*0x03*/ u8 currentIndex; /* index of currentObject in candidate list, or 0xFF */ - /*0x04*/ InteractableObject* currentObject; - /*0x08*/ InteractableObject - candidates[0x20]; /* contains the loaded NPCs, key doors, windcrests and other objects */ -} PossibleInteraction; - -static_assert(sizeof(PossibleInteraction) == 0x188); - -extern PossibleInteraction gPossibleInteraction; typedef struct { u8 numTiles; @@ -233,60 +16,11 @@ typedef struct { u32 pad; } SpritePtr; -extern SpritePtr gSpritePtrs[]; - -typedef struct { - u8 unk_0; - u8 unk_1; - u8 unk_2[2]; - u16 unk_4; - u8 filler[12]; - Entity* unk_14; - u8 unk_18; - u8 unk_19; - u8 unk_1a; - u8 unk_1b; -} struct_02018EB0; - -extern struct_02018EB0 gUnk_02018EB0; - -typedef struct { - /*0x00*/ bool8 isOnlyActiveFirstFrame; /**< Is the behavior for this item only created on the first frame */ - /*0x01*/ u8 priority; - /*0x02*/ u8 createFunc; - /*0x03*/ u8 playerItemId; /**< Id for the corresponsing PlayerItem. */ - /*0x04*/ u16 frameIndex; - /*0x06*/ u8 animPriority; - /*0x07*/ bool8 isChangingAttackStatus; - /*0x08*/ bool8 isUseableAsMinish; - /*0x09*/ u8 pad[3]; -} ItemDefinition; - -static_assert(sizeof(ItemDefinition) == 0xc); +extern const SpritePtr gSpritePtrs[]; typedef struct { u8 frame; u8 frameIndex; } PACKED FrameStruct; -typedef struct { - /*0x0*/ u8 menuType; - /*0x1*/ u16 font; - /*0x3*/ u8 unk_3; // TODO padding? - /*0x4*/ u16 transitionTimer; - /*0x6*/ u16 gfxEntry; - /*0x8*/ u16 bg2XOffset; - /*0xa*/ u16 sm_unk_14; -} PACKED StaffrollEntry; - -static_assert(sizeof(StaffrollEntry) == 0xc); - -typedef struct { - u8 paletteGroup; - u8 gfxGroup; -} PACKED StaffrollGfxEntry; - -extern const u8 gGlobalGfxAndPalettes[]; -extern u32 gUsedPalettes; - #endif // STRUCTURES_H diff --git a/include/ui.h b/include/ui.h index 669c29d1..77c27f4a 100644 --- a/include/ui.h +++ b/include/ui.h @@ -2,6 +2,104 @@ #define UI_H #include "global.h" +#include "sprite.h" + +#define MAX_UI_ELEMENTS 24 + +typedef enum { + UI_ELEMENT_BUTTON_A, + UI_ELEMENT_BUTTON_B, + UI_ELEMENT_BUTTON_R, + UI_ELEMENT_ITEM_A, + UI_ELEMENT_ITEM_B, + UI_ELEMENT_TEXT_R, + UI_ELEMENT_HEART, + UI_ELEMENT_EZLONAGSTART, + UI_ELEMENT_EZLONAGACTIVE, + UI_ELEMENT_TEXT_A, + UI_ELEMENT_TEXT_B +} UIElementType; + +/** + * @brief Floating UI element + */ +typedef struct { + u8 used : 1; + u8 unk_0_1 : 1; + u8 unk_0_2 : 2; // Load data into VRAM? 0: do not load, 1: ready to load 2: loaded + u8 unk_0_4 : 4; + u8 type; /**< @see UIElementType */ + u8 type2; // Subtype + u8 buttonElementId; /**< Id of the button UI element this text is attached to */ + u8 action; + u8 unk_5; + u8 unk_6; + u8 unk_7; + u8 unk_8; + u8 unk_9[3]; + u16 x; + u16 y; + u8 frameIndex; + u8 duration; + u8 spriteSettings; + u8 frameSettings; + Frame* framePtr; + u8 unk_18; + u8 numTiles; + u16 unk_1a; // TODO oam id? VRAM target (element->unk_1a * 0x20 + 0x6010000) + u32* firstTile; +} UIElement; + +typedef enum { + HUD_HIDE_NONE, + HUD_HIDE_1 = 0x1, // A + HUD_HIDE_2 = 0x2, // B + HUD_HIDE_4 = 0x4, // R + HUD_HIDE_8 = 0x8, + HUD_HIDE_HEARTS = 0x10, + HUD_HIDE_CHARGE_BAR = 0x20, + HUD_HIDE_RUPEES = 0x40, + HUD_HIDE_KEYS = 0x80, + + HUD_HIDE_ALL = 0xff +} HUDHideFlags; + +typedef struct { + u8 unk_0; + u8 hideFlags; + u8 unk_2; + u8 health; + u8 maxHealth; + u8 unk_5; + u8 unk_6; + u8 unk_7; + u8 unk_8; + u8 unk_9; + u8 unk_a; + u8 unk_b; + u8 unk_c; + u8 unk_d; + u16 rupees; + u8 unk_10; // TODO drawing keys dirty flag or something? + u8 unk_11; + u8 dungeonKeys; + s8 unk_13; + s8 unk_14; + u8 unk_15; + u16 buttonX[3]; /**< X coordinates for the button UI elements */ + u16 buttonY[3]; /**< Y coordinates for the button UI elements */ + u8 filler22[0x2]; + u8 ezloNagFuncIndex; + u8 filler25[7]; + u8 rActionInteractObject; // used as R button UI frame index + u8 rActionInteractTile; + u8 rActionGrabbing; + u8 rActionPlayerState; // if not 0, overrides other R actions + u8 buttonText[3]; + u8 unk_33; + UIElement elements[MAX_UI_ELEMENTS]; +} HUD; +extern HUD gHUD; extern void DrawUIElements(void); extern void UpdateUIElements(void); diff --git a/include/vram.h b/include/vram.h index a3fde71c..eae470e5 100644 --- a/include/vram.h +++ b/include/vram.h @@ -50,4 +50,32 @@ extern bool32 LoadSwapGFX(Entity*, u32, u32); extern void UnloadGFXSlots(Entity*); extern void sub_080ADD70(void); +extern u16 gBG0Buffer[0x400]; +extern u16 gBG1Buffer[0x400]; +extern u16 gBG2Buffer[0x400]; +extern u16 gBG3Buffer[0x800]; + +typedef struct { + u8 unk0; + u8 unk1; + u16 unk2; + u8 unk4; + u8 unk5; + u8 unk6; + u8 unk7; +} OAMObj; + +typedef struct { + u8 field_0x0; + u8 field_0x1; + u8 spritesOffset; + u8 updated; + u16 _4; + u16 _6; + u8 _0[0x18]; + struct OamData oam[0x80]; + OAMObj unk[0xA0]; /* todo: affine */ +} OAMControls; +extern OAMControls gOAMControls; + #endif //VRAM_H diff --git a/src/affine.c b/src/affine.c index a7b71857..e552b715 100644 --- a/src/affine.c +++ b/src/affine.c @@ -1,6 +1,5 @@ #include "affine.h" #include "global.h" -#include "structures.h" #include "main.h" #include "room.h" #include "screen.h" diff --git a/src/backgroundAnimations.c b/src/backgroundAnimations.c index 827f42c3..b055bbbf 100644 --- a/src/backgroundAnimations.c +++ b/src/backgroundAnimations.c @@ -8,7 +8,7 @@ #include "asm.h" #include "assets/gfx_offsets.h" #include "common.h" -#include "structures.h" +#include "gfx.h" #include "room.h" void LoadBgAnimationGfx(const BgAnimationGfx*); diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c index 0131c684..3188b2e8 100644 --- a/src/beanstalkSubtask.c +++ b/src/beanstalkSubtask.c @@ -17,10 +17,10 @@ #include "player.h" #include "screen.h" #include "scroll.h" -#include "structures.h" #include "tiles.h" #include "affine.h" #include "subtask.h" +#include "ui.h" extern void sub_0807C898(void); extern void sub_0805BB74(s32); diff --git a/src/code_0805EC04.c b/src/code_0805EC04.c index 09b0c6dd..2adb5251 100644 --- a/src/code_0805EC04.c +++ b/src/code_0805EC04.c @@ -2,7 +2,7 @@ #include "entity.h" #include "player.h" #include "room.h" -#include "structures.h" +#include "vram.h" const u8 gUnk_08109202[] = { 255, 8, 24, 255, 0, 4, 28, 255, 16, 12, 20, 255, 255, 255, 255, 255, 0, 0, diff --git a/src/collision.c b/src/collision.c index 7220bf5f..42f7c358 100644 --- a/src/collision.c +++ b/src/collision.c @@ -3,7 +3,6 @@ #include "common.h" #include "enemy.h" #include "entity.h" -#include "structures.h" #include "global.h" #include "item.h" #include "object.h" diff --git a/src/color.c b/src/color.c index 76f4c4db..cf179c19 100644 --- a/src/color.c +++ b/src/color.c @@ -3,15 +3,12 @@ #include "common.h" #include "color.h" #include "room.h" -#include "global.h" -#include "fileselect.h" #include "main.h" -#include "physics.h" -#include "structures.h" +#include "gfx.h" extern Palette gUnk_02001A3C; -void LoadObjPaletteAtIndex(u32 a1, u32 a2); +void LoadObjPaletteAtIndex(u32 a1, u32 paletteIndex); void CleanUpObjPalettes(); u32 FindFreeObjPalette(u32); void SetEntityObjPalette(Entity*, s32); @@ -238,21 +235,21 @@ void ChangeObjPalette(Entity* entity, u32 objPaletteId) { LoadObjPalette(entity, objPaletteId); } -void LoadObjPaletteAtIndex(u32 objPaletteId, u32 a2) { +void LoadObjPaletteAtIndex(u32 objPaletteId, u32 paletteIndex) { u16* buffer; - gUsedPalettes |= 1 << (a2 + 16); + USE_PALETTE(paletteIndex + 16); if (objPaletteId > 5) { if (objPaletteId == 0x15) { buffer = gPaletteBuffer; - MemFill16(buffer[0x3C], buffer + (a2 + 16) * 16, 0x20); + MemFill16(buffer[0x3C], buffer + (paletteIndex + 16) * 16, 0x20); } else if (objPaletteId < 0x15) { - LoadPalettes((u8*)(gPaletteBuffer + (objPaletteId - 6) * 16), a2 + 16, 1); + LoadPalettes((u8*)(gPaletteBuffer + (objPaletteId - 6) * 16), paletteIndex + 16, 1); } else { u32 offset = gUnk_08133368[(objPaletteId - 0x16)].WORD_U; u32 numPalettes = (offset >> 0x18) & 0xf; offset &= 0xffffff; - LoadPalettes(gGlobalGfxAndPalettes + offset, a2 + 16, numPalettes); + LoadPalettes(&gGlobalGfxAndPalettes[offset], paletteIndex + 16, numPalettes); } } } diff --git a/src/common.c b/src/common.c index 69e4d3df..73020e20 100644 --- a/src/common.c +++ b/src/common.c @@ -16,7 +16,6 @@ #include "screen.h" #include "sound.h" #include "subtask.h" -#include "structures.h" extern u8 gUnk_03003DE0; extern u8 gzHeap[0x1000]; @@ -244,7 +243,7 @@ void LoadPalettes(const u8* src, s32 destPaletteNum, s32 numPalettes) { u32 size = numPalettes * 32; u32 usedPalettesMask = 1 << destPaletteNum; while (--numPalettes > 0) { - usedPalettesMask |= (usedPalettesMask << 1); + usedPalettesMask |= usedPalettesMask << 1; } gUsedPalettes |= usedPalettesMask; dest = &gPaletteBuffer[destPaletteNum * 16]; @@ -253,7 +252,7 @@ void LoadPalettes(const u8* src, s32 destPaletteNum, s32 numPalettes) { void SetColor(u32 colorIndex, u32 color) { gPaletteBuffer[colorIndex] = color; - gUsedPalettes |= 1 << (colorIndex / 16); + USE_PALETTE(colorIndex / 16); } void SetFillColor(u32 color, u32 disable_layers) { diff --git a/src/cutscene.c b/src/cutscene.c index 241c9235..dbdabec5 100644 --- a/src/cutscene.c +++ b/src/cutscene.c @@ -8,7 +8,6 @@ #include "enemy.h" #include "fade.h" #include "fileselect.h" -#include "structures.h" #include "game.h" #include "main.h" #include "menu.h" diff --git a/src/debug.c b/src/debug.c index c8a92ace..9ca357ad 100644 --- a/src/debug.c +++ b/src/debug.c @@ -13,7 +13,6 @@ #include "screen.h" #include "sound.h" #include "save.h" -#include "structures.h" void sub_0805FA04(void); void sub_0805FA98(void); diff --git a/src/demo.c b/src/demo.c index a8934300..b510a6fb 100644 --- a/src/demo.c +++ b/src/demo.c @@ -16,7 +16,6 @@ #include "menu.h" #include "sound.h" #include "affine.h" -#include "structures.h" void sub_080A30AC(void); void sub_080A2E40(void); diff --git a/src/enemy/chuchuBoss.c b/src/enemy/chuchuBoss.c index 8511e2b7..81bfd0c3 100644 --- a/src/enemy/chuchuBoss.c +++ b/src/enemy/chuchuBoss.c @@ -14,7 +14,7 @@ #include "physics.h" #include "player.h" #include "tiles.h" -#include "structures.h" +#include "pauseMenu.h" #ifndef EU #include "vram.h" #endif diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c index 40e0eddf..124d5d65 100644 --- a/src/enemy/gleerok.c +++ b/src/enemy/gleerok.c @@ -16,7 +16,7 @@ #include "physics.h" #include "player.h" #include "screen.h" -#include "structures.h" +#include "pauseMenu.h" typedef struct { union SplitHWord unk0; diff --git a/src/enemy/mazaalMacro.c b/src/enemy/mazaalMacro.c index e3e4e50d..5d2dd7a4 100644 --- a/src/enemy/mazaalMacro.c +++ b/src/enemy/mazaalMacro.c @@ -7,7 +7,6 @@ #include "enemy.h" #include "screenTransitions.h" #include "script.h" -#include "structures.h" #include "tiles.h" #include "player.h" #include "physics.h" diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index f2a85cd8..0ef5f55c 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -6,7 +6,7 @@ */ #include "enemy/octorokBoss.h" #include "collision.h" -#include "structures.h" +#include "pauseMenu.h" #include "game.h" #include "object.h" #include "asm.h" diff --git a/src/enemy/waterDrop.c b/src/enemy/waterDrop.c index d6ba88e8..7d7c7e78 100644 --- a/src/enemy/waterDrop.c +++ b/src/enemy/waterDrop.c @@ -12,7 +12,7 @@ #include "physics.h" #include "player.h" #include "screen.h" -#include "structures.h" +#include "vram.h" void sub_0802A39C(Entity*); void sub_0802A334(Entity*); diff --git a/src/enterPortalSubtask.c b/src/enterPortalSubtask.c index ddc00cbe..ee748dca 100644 --- a/src/enterPortalSubtask.c +++ b/src/enterPortalSubtask.c @@ -9,7 +9,7 @@ #include "area.h" #include "common.h" #include "entity.h" -#include "structures.h" +#include "beanstalkSubtask.h" #include "game.h" #include "main.h" #include "object.h" @@ -188,7 +188,7 @@ void Subtask_PortalCutscene_0(void) { LoadPaletteGroup(ptr->paletteGroup); LoadGfxGroup(ptr->gfxGroup); MemCopy(gPaletteBuffer + 3 * 16, gPaletteBuffer + 21 * 16, 16 * 2); - gUsedPalettes |= 1 << 21; + USE_PALETTE(21); EraseAllEntities(); LoadRoomEntityList(gUnk_080D4110[portalId]); ClearEventPriority(); diff --git a/src/entity.c b/src/entity.c index 34ce01ae..9e1603d4 100644 --- a/src/entity.c +++ b/src/entity.c @@ -6,7 +6,6 @@ #include "npc.h" #include "vram.h" #include "script.h" -#include "structures.h" #include "room.h" #include "player.h" #include "physics.h" diff --git a/src/fade.c b/src/fade.c index a9cd0a4d..8f14b277 100644 --- a/src/fade.c +++ b/src/fade.c @@ -1,6 +1,6 @@ #include "global.h" #include "save.h" -#include "structures.h" +#include "vram.h" #include "screen.h" #include "common.h" @@ -8,7 +8,13 @@ static u32 sub_080501C0(FadeControl* ctl); static u32 sub_08050230(FadeControl* ctl); static u32 sub_080502A4(FadeControl* ctl); -extern u32 gUsedPalettes; +typedef struct { + u8 unk0; + u8 unk1; + u16 unk2; +} struct_020354C0; +extern struct_020354C0 gUnk_020354C0[0x20]; + extern u16 gPaletteBuffer[]; extern u16 gUnk_080FC3C4[]; diff --git a/src/fileselect.c b/src/fileselect.c index 2f873ee1..34c13d3a 100644 --- a/src/fileselect.c +++ b/src/fileselect.c @@ -24,7 +24,7 @@ #include "subtask.h" #include "ui.h" #include "affine.h" -#include "structures.h" +#include "gfx.h" // copy, erase, start #define NUM_FILE_OPERATIONS 3 diff --git a/src/game.c b/src/game.c index e582ec17..da2c4427 100644 --- a/src/game.c +++ b/src/game.c @@ -12,7 +12,6 @@ #include "common.h" #include "entity.h" #include "fileselect.h" -#include "structures.h" #include "main.h" #include "manager/diggingCaveEntranceManager.h" #include "message.h" @@ -23,6 +22,7 @@ #include "sound.h" #include "ui.h" #include "beanstalkSubtask.h" +#include "pauseMenu.h" // Game task diff --git a/src/gameUtils.c b/src/gameUtils.c index 19d39204..92a9db0b 100644 --- a/src/gameUtils.c +++ b/src/gameUtils.c @@ -23,7 +23,7 @@ #include "ui.h" #include "subtask.h" #include "beanstalkSubtask.h" -#include "structures.h" +#include "pauseMenu.h" u32 StairsAreValid(void); void ClearFlagArray(const u16*); @@ -828,7 +828,7 @@ void sub_080533CC(void) { *p2++ = *p1++; *p2++ = *p1++; *p2++ = *p1++; - gUsedPalettes |= 1 << 3; + USE_PALETTE(3); } void UpdateTimerCallbacks(void) { diff --git a/src/interrupts.c b/src/interrupts.c index 9d824006..14b97384 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -10,7 +10,6 @@ #include "save.h" #include "screen.h" #include "sound.h" -#include "structures.h" #include "ui.h" #include "asm.h" diff --git a/src/item/itemOcarina.c b/src/item/itemOcarina.c index 4cd8a621..8cae9252 100644 --- a/src/item/itemOcarina.c +++ b/src/item/itemOcarina.c @@ -1,4 +1,4 @@ -#include "structures.h" +#include "pauseMenu.h" #include "item.h" #include "sound.h" diff --git a/src/item/itemTryPickupObject.c b/src/item/itemTryPickupObject.c index 1648b6a0..5503a670 100644 --- a/src/item/itemTryPickupObject.c +++ b/src/item/itemTryPickupObject.c @@ -2,7 +2,7 @@ #include "item.h" #include "playeritem.h" #include "sound.h" -#include "structures.h" +#include "ui.h" #include "room.h" u32 sub_08077F64(ItemBehavior* arg0, u32 index); diff --git a/src/itemDefinitions.c b/src/itemDefinitions.c index 0550f3e9..c50e71f9 100644 --- a/src/itemDefinitions.c +++ b/src/itemDefinitions.c @@ -1,6 +1,6 @@ +#include "itemDefinitions.h" #include "item.h" #include "playeritem.h" -#include "structures.h" const ItemDefinition gItemDefinitions[] = { [ITEM_NONE] = { TRUE, 1, CREATE_ITEM_0, PLAYER_ITEM_NONE, 0, 0, FALSE, FALSE }, diff --git a/src/itemUtils.c b/src/itemUtils.c index 1ed84adc..a57ad013 100644 --- a/src/itemUtils.c +++ b/src/itemUtils.c @@ -16,7 +16,7 @@ #include "player.h" #include "enemy.h" #include "message.h" -#include "structures.h" +#include "ui.h" const Wallet gWalletSizes[] = { { 100, 0xf060 }, diff --git a/src/main.c b/src/main.c index a57a3ec7..5260574a 100644 --- a/src/main.c +++ b/src/main.c @@ -12,7 +12,6 @@ #include "save.h" #include "screen.h" #include "sound.h" -#include "structures.h" extern u32 gRand; diff --git a/src/manager/diggingCaveEntranceManager.c b/src/manager/diggingCaveEntranceManager.c index d7b37a73..18e7a74c 100644 --- a/src/manager/diggingCaveEntranceManager.c +++ b/src/manager/diggingCaveEntranceManager.c @@ -12,7 +12,6 @@ #include "scroll.h" #include "tiles.h" #ifndef EU -#include "structures.h" #endif void DiggingCaveEntranceManager_Main(DiggingCaveEntranceManager*); diff --git a/src/manager/enterRoomTextboxManager.c b/src/manager/enterRoomTextboxManager.c index f456714c..e9c7d5a4 100644 --- a/src/manager/enterRoomTextboxManager.c +++ b/src/manager/enterRoomTextboxManager.c @@ -11,7 +11,7 @@ #include "game.h" #include "message.h" #include "screen.h" -#include "structures.h" +#include "vram.h" const u16 gUnk_08108DE8[] = { 0, 0x70b, 0x70c, 0x70d, 0x70e, 0x70f, 0x710, 0x711, 0x712, 0x713, 0x714, 0x715, 0x716, 0x717, 0x718, 0x719, 0x71a, 0x71b, 0x71c, 0x71d, 0x71e, 0x71f, diff --git a/src/manager/holeManager.c b/src/manager/holeManager.c index ced8e4b9..cc3a3191 100644 --- a/src/manager/holeManager.c +++ b/src/manager/holeManager.c @@ -15,7 +15,7 @@ #include "game.h" #include "manager/lightManager.h" #include "assets/gfx_offsets.h" -#include "structures.h" +#include "gfx.h" typedef enum { HOLE_TRANSITION_ABSOLUTE, diff --git a/src/manager/horizontalMinishPathBackgroundManager.c b/src/manager/horizontalMinishPathBackgroundManager.c index 7af97dde..6c0a96fd 100644 --- a/src/manager/horizontalMinishPathBackgroundManager.c +++ b/src/manager/horizontalMinishPathBackgroundManager.c @@ -8,7 +8,7 @@ #include "common.h" #include "screen.h" #include "game.h" -#include "structures.h" +#include "vram.h" #include "room.h" void sub_08057F20(HorizontalMinishPathBackgroundManager*); diff --git a/src/manager/lightRayManager.c b/src/manager/lightRayManager.c index 93e21ddd..1a75f63b 100644 --- a/src/manager/lightRayManager.c +++ b/src/manager/lightRayManager.c @@ -12,7 +12,6 @@ #include "main.h" #include "screen.h" #include "game.h" -#include "structures.h" #include "player.h" #include "physics.h" diff --git a/src/manager/minishRaftersBackgroundManager.c b/src/manager/minishRaftersBackgroundManager.c index 183000af..da5680e3 100644 --- a/src/manager/minishRaftersBackgroundManager.c +++ b/src/manager/minishRaftersBackgroundManager.c @@ -8,7 +8,7 @@ #include "common.h" #include "room.h" #include "game.h" -#include "structures.h" +#include "vram.h" void MinishRaftersBackgroundManager_OnEnterRoom(MinishRaftersBackgroundManager*); void sub_08058210(MinishRaftersBackgroundManager*); diff --git a/src/manager/minishVillageTileSetManager.c b/src/manager/minishVillageTileSetManager.c index 81c93ae8..7799ba83 100644 --- a/src/manager/minishVillageTileSetManager.c +++ b/src/manager/minishVillageTileSetManager.c @@ -10,7 +10,8 @@ #include "main.h" #include "game.h" #include "assets/gfx_offsets.h" -#include "structures.h" +#include "pauseMenu.h" +#include "gfx.h" void MinishVillageTileSetManager_OnEnterRoom(void*); bool32 MinishVillageTileSetManager_UpdateRoomGfxGroup(MinishVillageTileSetManager*); diff --git a/src/manager/rollingBarrelManager.c b/src/manager/rollingBarrelManager.c index f8209f6e..cf42b5e7 100644 --- a/src/manager/rollingBarrelManager.c +++ b/src/manager/rollingBarrelManager.c @@ -261,7 +261,7 @@ void RollingBarrelManager_OnEnterRoom(void) { u32 tmp2; LoadPaletteGroup(0x28); MemCopy(gPaletteBuffer + 3 * 16, gPaletteBuffer + 21 * 16, 16 * 2); - gUsedPalettes |= 1 << 21; + USE_PALETTE(21); LoadGfxGroup(0x16); tmp = gScreen.lcd.displayControl; tmp2 = 0; diff --git a/src/manager/secretManager.c b/src/manager/secretManager.c index f0ec19e2..69739493 100644 --- a/src/manager/secretManager.c +++ b/src/manager/secretManager.c @@ -10,7 +10,6 @@ #include "entity.h" #include "flags.h" #include "sound.h" -#include "structures.h" void SecretManager_Type0_Action2(SecretManager*); void SecretManager_Type0(SecretManager*); diff --git a/src/manager/templeOfDropletsManager.c b/src/manager/templeOfDropletsManager.c index 1c9987a5..94b247d0 100644 --- a/src/manager/templeOfDropletsManager.c +++ b/src/manager/templeOfDropletsManager.c @@ -14,7 +14,8 @@ #include "screen.h" #include "sound.h" #include "game.h" -#include "structures.h" +#include "vram.h" +#include "pauseMenu.h" static const u16 gUnk_081085B8[] = { 0x1008, 0x1007, 0x1006, 0x1005, 0x1006, 0x1007, 0x1008, 0x1009, 0x1008, 0x1007, 0x1006, 0x1005, 0x1006, 0x1007, 0x1008, 0x1009 }; diff --git a/src/manager/vaati3InsideArmManager.c b/src/manager/vaati3InsideArmManager.c index 43402c28..2f89d2ce 100644 --- a/src/manager/vaati3InsideArmManager.c +++ b/src/manager/vaati3InsideArmManager.c @@ -7,7 +7,6 @@ #include "manager/vaati3InsideArmManager.h" #include "screenTransitions.h" #include "sound.h" -#include "structures.h" void sub_0805DBF0(Vaati3InsideArmManager*); void Vaati3InsideArmManager_Init(Vaati3InsideArmManager*); diff --git a/src/manager/weatherChangeManager.c b/src/manager/weatherChangeManager.c index d5da1664..53156fef 100644 --- a/src/manager/weatherChangeManager.c +++ b/src/manager/weatherChangeManager.c @@ -15,7 +15,6 @@ #include "game.h" #include "manager/staticBackgroundManager.h" #include "player.h" -#include "structures.h" void WeatherChangeManager_OnEnterRoom(WeatherChangeManager*); void sub_08059608(WeatherChangeManager*); diff --git a/src/menu/figurineMenu.c b/src/menu/figurineMenu.c index cc3e84f8..a15668bb 100644 --- a/src/menu/figurineMenu.c +++ b/src/menu/figurineMenu.c @@ -8,7 +8,6 @@ #include "common.h" #include "flags.h" -#include "structures.h" #include "game.h" #include "main.h" #include "menu.h" @@ -23,6 +22,7 @@ #include "subtask.h" #include "ui.h" #include "affine.h" +#include "pauseMenu.h" void sub_080A4DA8(u32); void sub_080A4B44(void); diff --git a/src/menu/kinstoneMenu.c b/src/menu/kinstoneMenu.c index 3f53829b..a50b5460 100644 --- a/src/menu/kinstoneMenu.c +++ b/src/menu/kinstoneMenu.c @@ -8,7 +8,6 @@ #include "common.h" #include "enemy.h" #include "flags.h" -#include "structures.h" #include "kinstone.h" #include "main.h" #include "menu.h" diff --git a/src/menu/pauseMenu.c b/src/menu/pauseMenu.c index e3585520..e6b0a5ec 100644 --- a/src/menu/pauseMenu.c +++ b/src/menu/pauseMenu.c @@ -17,7 +17,6 @@ #include "save.h" #include "screen.h" #include "sound.h" -#include "structures.h" #include "subtask.h" #include "ui.h" #include "affine.h" @@ -1074,7 +1073,7 @@ void PauseMenu_Screen_5(void) { paletteColor = *gUnk_02017830; MemCopy(gUnk_02017830 + 1, gUnk_02017830, 7 * 2); gUnk_02017830[7] = paletteColor; - gUsedPalettes |= 1 << 12; + USE_PALETTE(12); } } diff --git a/src/menu/pauseMenuScreen6.c b/src/menu/pauseMenuScreen6.c index 8883a1e3..cf74fc22 100644 --- a/src/menu/pauseMenuScreen6.c +++ b/src/menu/pauseMenuScreen6.c @@ -13,7 +13,6 @@ #include "save.h" #include "screen.h" #include "affine.h" -#include "structures.h" typedef struct { u8 unk0; diff --git a/src/message.c b/src/message.c index f7435451..64e26581 100644 --- a/src/message.c +++ b/src/message.c @@ -6,7 +6,7 @@ #include "message.h" #include "save.h" #include "ui.h" -#include "structures.h" +#include "vram.h" #define MESSAGE_ADVANCE_KEYS (A_BUTTON | B_BUTTON | DPAD_ANY | R_BUTTON) #define MESSAGE_PRESS_ANY_ADVANCE_KEYS ((gInput.newKeys & MESSAGE_ADVANCE_KEYS) != 0) diff --git a/src/npc/beedle.c b/src/npc/beedle.c index 97bdd677..84afb434 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -11,7 +11,6 @@ #include "npc.h" #include "room.h" #include "script.h" -#include "structures.h" typedef struct { Rect customHitbox; diff --git a/src/npc/drLeft.c b/src/npc/drLeft.c index 0186c83c..5c22035d 100644 --- a/src/npc/drLeft.c +++ b/src/npc/drLeft.c @@ -12,7 +12,6 @@ #include "save.h" #include "script.h" #include "asm.h" -#include "structures.h" void sub_0806BFD8(Entity* this); diff --git a/src/npc/ghostBrothers.c b/src/npc/ghostBrothers.c index 29f8dc09..b1dd30a6 100644 --- a/src/npc/ghostBrothers.c +++ b/src/npc/ghostBrothers.c @@ -10,7 +10,7 @@ #include "save.h" #include "script.h" #include "screen.h" -#include "structures.h" +#include "beanstalkSubtask.h" #include "physics.h" typedef struct { diff --git a/src/npc/mayorHagen.c b/src/npc/mayorHagen.c index 89e42266..d39943f4 100644 --- a/src/npc/mayorHagen.c +++ b/src/npc/mayorHagen.c @@ -13,7 +13,6 @@ #include "save.h" #include "script.h" #include "physics.h" -#include "structures.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/npc/npc23.c b/src/npc/npc23.c index cd3e67b0..2ff8885a 100644 --- a/src/npc/npc23.c +++ b/src/npc/npc23.c @@ -8,7 +8,7 @@ #include "message.h" #include "npc.h" #include "player.h" -#include "structures.h" +#include "pauseMenu.h" #include "room.h" #include "physics.h" diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c index 3fd3da2e..25a831cc 100644 --- a/src/npc/npc4E.c +++ b/src/npc/npc4E.c @@ -6,7 +6,6 @@ */ #include "entity.h" #include "flags.h" -#include "structures.h" #include "game.h" #include "hitbox.h" #include "item.h" diff --git a/src/npc/postman.c b/src/npc/postman.c index 4a8bbb43..98678a3a 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -13,7 +13,6 @@ #include "asm.h" #include "message.h" #include "physics.h" -#include "structures.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/npc/rem.c b/src/npc/rem.c index 4298eccd..739efcbd 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -12,7 +12,6 @@ #include "message.h" #include "script.h" #include "asm.h" -#include "structures.h" #include "room.h" typedef struct { diff --git a/src/npc/smallTownMinish.c b/src/npc/smallTownMinish.c index 485b4db9..2acf353e 100644 --- a/src/npc/smallTownMinish.c +++ b/src/npc/smallTownMinish.c @@ -11,7 +11,6 @@ #include "player.h" #include "save.h" #include "script.h" -#include "structures.h" void SmallTownMinish(Entity* this) { static const Hitbox gUnk_081142FC = { -2, 1, { 0, 0, 0, 0 }, 6, 6 }; diff --git a/src/npc/smith.c b/src/npc/smith.c index f002c7fa..f1b6f2f7 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -13,7 +13,6 @@ #include "message.h" #include "script.h" #include "asm.h" -#include "structures.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/npc/stockwell.c b/src/npc/stockwell.c index 786e39e7..253f53e2 100644 --- a/src/npc/stockwell.c +++ b/src/npc/stockwell.c @@ -18,7 +18,6 @@ #include "save.h" #include "subtask.h" #ifndef EU -#include "structures.h" #endif #ifndef EU diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index b97dee5f..40f49234 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -14,7 +14,6 @@ #include "message.h" #include "save.h" #include "script.h" -#include "structures.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/object/bird.c b/src/object/bird.c index e7cd5218..083f9322 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -19,7 +19,7 @@ #include "object/cutsceneOrchestrator.h" #include "save.h" #include "subtask.h" -#include "structures.h" +#include "pauseMenu.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/object/cameraTarget.c b/src/object/cameraTarget.c index 7364ce96..f025fea8 100644 --- a/src/object/cameraTarget.c +++ b/src/object/cameraTarget.c @@ -10,7 +10,6 @@ #include "kinstone.h" #include "message.h" #include "vram.h" -#include "structures.h" // typedef struct { // Entity base; diff --git a/src/object/chestSpawner.c b/src/object/chestSpawner.c index 582ecbac..b739489c 100644 --- a/src/object/chestSpawner.c +++ b/src/object/chestSpawner.c @@ -15,7 +15,7 @@ #include "screen.h" #include "tiles.h" #include "manager/lightManager.h" -#include "structures.h" +#include "pauseMenu.h" #include "beanstalkSubtask.h" typedef struct { diff --git a/src/object/cloud.c b/src/object/cloud.c index 7521bdb4..7a51601d 100644 --- a/src/object/cloud.c +++ b/src/object/cloud.c @@ -11,7 +11,7 @@ #include "room.h" #include "physics.h" #include "player.h" -#include "structures.h" +#include "pauseMenu.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index e8f5a060..d1d71e55 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -14,7 +14,7 @@ #include "physics.h" #include "player.h" #include "tiles.h" -#include "structures.h" +#include "ui.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c index aa82c7c1..ab8a1c1f 100644 --- a/src/object/fileScreenObjects.c +++ b/src/object/fileScreenObjects.c @@ -13,7 +13,7 @@ #include "flags.h" #include "physics.h" #include "player.h" -#include "structures.h" +#include "gfx.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/object/itemForSale.c b/src/object/itemForSale.c index 228dda8d..61d111f2 100644 --- a/src/object/itemForSale.c +++ b/src/object/itemForSale.c @@ -10,7 +10,7 @@ #include "message.h" #include "scroll.h" #include "asm.h" -#include "structures.h" +#include "ui.h" #include "room.h" #include "player.h" diff --git a/src/object/linkAnimation.c b/src/object/linkAnimation.c index 75054314..ec523d61 100644 --- a/src/object/linkAnimation.c +++ b/src/object/linkAnimation.c @@ -11,7 +11,7 @@ #include "player.h" #include "object/linkAnimation.h" #include "item.h" -#include "structures.h" +#include "pauseMenu.h" typedef enum { ITEMGET_INIT, diff --git a/src/object/macroMushroomStalk.c b/src/object/macroMushroomStalk.c index 185d1de1..a8c544fb 100644 --- a/src/object/macroMushroomStalk.c +++ b/src/object/macroMushroomStalk.c @@ -9,7 +9,7 @@ #include "object.h" #include "room.h" #include "sound.h" -#include "structures.h" +#include "beanstalkSubtask.h" void MacroMushroomStalk_Init(Entity*); void MacroMushroomStalk_Action1(Entity*); diff --git a/src/object/macroPlayer.c b/src/object/macroPlayer.c index 76dbc3c7..80218ced 100644 --- a/src/object/macroPlayer.c +++ b/src/object/macroPlayer.c @@ -11,7 +11,7 @@ #include "asm.h" #include "physics.h" #include "player.h" -#include "structures.h" +#include "beanstalkSubtask.h" typedef struct { Entity base; diff --git a/src/object/minishPortalCloseup.c b/src/object/minishPortalCloseup.c index ec7232f9..2b224c83 100644 --- a/src/object/minishPortalCloseup.c +++ b/src/object/minishPortalCloseup.c @@ -10,7 +10,6 @@ #include "common.h" #include "room.h" #include "screen.h" -#include "structures.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/object/minishPortalStone.c b/src/object/minishPortalStone.c index ba1699d5..b8e7a960 100644 --- a/src/object/minishPortalStone.c +++ b/src/object/minishPortalStone.c @@ -14,7 +14,7 @@ #include "beanstalkSubtask.h" #include "manager/lightManager.h" #include "effects.h" -#include "structures.h" +#include "pauseMenu.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/object/windcrest.c b/src/object/windcrest.c index 5ac537c0..f6dbba59 100644 --- a/src/object/windcrest.c +++ b/src/object/windcrest.c @@ -6,7 +6,6 @@ */ #include "effects.h" #include "entity.h" -#include "structures.h" #include "save.h" #include "script.h" #include "sound.h" diff --git a/src/objectUtils.c b/src/objectUtils.c index 54883afd..3e589d2e 100644 --- a/src/objectUtils.c +++ b/src/objectUtils.c @@ -5,7 +5,7 @@ #include "asm.h" #include "effects.h" #include "player.h" -#include "structures.h" +#include "pauseMenu.h" #include "definitions.h" #include "vram.h" #include "object/linkAnimation.h" diff --git a/src/physics.c b/src/physics.c index d5b1a0a3..28213602 100644 --- a/src/physics.c +++ b/src/physics.c @@ -557,7 +557,7 @@ void sub_0806FEBC(Entity* ent, u32 param_2, Entity* param_3) { *((u32*)ptr) = 0; ptr->unk_04.WORD = 0; ptr->unk_08.WORD = 0; - ptr->unk_0C = (u32)param_3; + ptr->unk_0C = param_3; ptr->unk_00.unk0 = 1; ptr->unk_00.unk1 = 1; } @@ -647,9 +647,9 @@ void sub_0807000C(Entity* this) { } static bool32 sub_0807007C(struct_gUnk_020000C0* this, u32 param_2) { - u8* ptr2; - u8* ptr3; - u32* spritePtr; + SpriteFrame* frames; + SpriteFrame* frame; + const SpritePtr* spritePtr; struct_gUnk_020000C0_1* ptr1 = &this->unk_00[param_2]; if ((ptr1->unk_00.unk3) == 0) return 0; @@ -658,14 +658,14 @@ static bool32 sub_0807007C(struct_gUnk_020000C0* this, u32 param_2) { if (ptr1->unk_01 == 0xff) return 0; - spritePtr = &((u32*)gSpritePtrs)[ptr1->unk_02 * 4]; - ptr2 = (u8*)(spritePtr[1]); - if (ptr2 == 0) + spritePtr = &gSpritePtrs[ptr1->unk_02]; + frames = spritePtr->frames; + if (frames == 0) return 0; - ptr3 = &ptr2[ptr1->unk_01 * 4]; - ptr1->unk_08.BYTES.byte1 = *ptr3; - ptr1->unk_0C = spritePtr[2] + ((*(u16*)&ptr3[2]) << 5); + frame = &frames[ptr1->unk_01]; + ptr1->unk_08.BYTES.byte1 = frame->numTiles; + ptr1->unk_0C = spritePtr->ptr + (frame->firstTileIndex << 5); return 1; } diff --git a/src/player.c b/src/player.c index 6a7ef891..c8b5d6c7 100644 --- a/src/player.c +++ b/src/player.c @@ -29,7 +29,8 @@ #include "scroll.h" #include "sound.h" #include "tiles.h" -#include "structures.h" +#include "ui.h" +#include "pauseMenu.h" #define kGravityRate Q_8_8(32) #define kWalkSpeedSlopeSubtractor Q_8_8(0.3125) diff --git a/src/playerItem/playerItemPacciCane.c b/src/playerItem/playerItemPacciCane.c index c4937aef..82cb79f9 100644 --- a/src/playerItem/playerItemPacciCane.c +++ b/src/playerItem/playerItemPacciCane.c @@ -8,7 +8,7 @@ #include "entity.h" #include "save.h" #include "sound.h" -#include "structures.h" +#include "pauseMenu.h" #include "vram.h" #include "asm.h" diff --git a/src/playerUtils.c b/src/playerUtils.c index 32236958..c93f1fb9 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -26,6 +26,8 @@ #include "tileMap.h" #include "tiles.h" #include "backgroundAnimations.h" +#include "itemDefinitions.h" +#include "ui.h" static void sub_08077E54(ItemBehavior* this); @@ -3817,18 +3819,18 @@ void LoadRoomTileSet(void) { MemFill16(0xffff, gMapTop.tileTypes, 0x1000); gMapTop.tileTypes[0] = 0; - if ((void*)gRoomControls.tileSet != (gArea.pCurrentRoomInfo)->tileSet) { - gRoomControls.tileSet = (u32)(gArea.pCurrentRoomInfo)->tileSet; - LoadMapData((gArea.pCurrentRoomInfo)->tileSet); + if ((void*)gRoomControls.tileSet != gArea.pCurrentRoomInfo->tileSet) { + gRoomControls.tileSet = (u32)gArea.pCurrentRoomInfo->tileSet; + LoadMapData(gArea.pCurrentRoomInfo->tileSet); } - LoadMapData((gArea.pCurrentRoomInfo)->tiles); + LoadMapData(gArea.pCurrentRoomInfo->tiles); paletteBuffer = gPaletteBuffer; MemCopy(&paletteBuffer[0x30], &paletteBuffer[0x150], 0x20); - gUsedPalettes |= 0x200000; + USE_PALETTE(21); - if ((gArea.pCurrentRoomInfo)->bg_anim != NULL) { - LoadBgAnimations((gArea.pCurrentRoomInfo)->bg_anim); + if (gArea.pCurrentRoomInfo->bg_anim != NULL) { + LoadBgAnimations(gArea.pCurrentRoomInfo->bg_anim); } tileTypes = gMapBottom.tileTypes; diff --git a/src/script.c b/src/script.c index fee3403d..084665ee 100644 --- a/src/script.c +++ b/src/script.c @@ -19,7 +19,7 @@ #include "ui.h" #include "save.h" #include "subtask.h" -#include "structures.h" +#include "pauseMenu.h" void InitScriptExecutionContext(ScriptExecutionContext* context, Script* script); void sub_0807DE80(Entity*); diff --git a/src/scroll.c b/src/scroll.c index b3cd7953..0137e344 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -16,7 +16,6 @@ #include "physics.h" #include "player.h" #include "screen.h" -#include "structures.h" #include "tileMap.h" #include "tiles.h" diff --git a/src/staffroll.c b/src/staffroll.c index 007049fb..169c52ac 100644 --- a/src/staffroll.c +++ b/src/staffroll.c @@ -15,7 +15,6 @@ #include "screen.h" #include "subtask.h" #include "sound.h" -#include "structures.h" typedef struct { /*0x00*/ Menu base; @@ -32,6 +31,23 @@ typedef struct { } StaffrollMenu; #define gStaffrollMenu (*(StaffrollMenu*)&gMenu) +typedef struct { + /*0x0*/ u8 menuType; + /*0x1*/ u16 font; + /*0x3*/ u8 unk_3; // TODO padding? + /*0x4*/ u16 transitionTimer; + /*0x6*/ u16 gfxEntry; + /*0x8*/ u16 bg2XOffset; + /*0xa*/ u16 sm_unk_14; +} PACKED StaffrollEntry; + +static_assert(sizeof(StaffrollEntry) == 0xc); + +typedef struct { + u8 paletteGroup; + u8 gfxGroup; +} PACKED StaffrollGfxEntry; + const Font gUnk_08127280 = { &gBG1Buffer[0x21], BG_TILE_ADDR(0x188), gTextGfxBuffer, 0, 61472, 240, 0, 0, 0, 0, 0, 5, 0, 1, 0 }; diff --git a/src/subtask.c b/src/subtask.c index 5fc61704..974002fe 100644 --- a/src/subtask.c +++ b/src/subtask.c @@ -10,7 +10,7 @@ #include "ui.h" #include "windcrest.h" #include "affine.h" -#include "structures.h" +#include "beanstalkSubtask.h" extern Screen gUnk_03001020; extern u8 gPaletteBufferBackup[]; diff --git a/src/subtask/subtaskAuxCutscene.c b/src/subtask/subtaskAuxCutscene.c index f1c30af4..ac585965 100644 --- a/src/subtask/subtaskAuxCutscene.c +++ b/src/subtask/subtaskAuxCutscene.c @@ -6,7 +6,6 @@ #include "area.h" #include "asm.h" #include "common.h" -#include "structures.h" #include "game.h" #include "main.h" #include "menu.h" diff --git a/src/subtask/subtaskFastTravel.c b/src/subtask/subtaskFastTravel.c index 1b297789..f2f24059 100644 --- a/src/subtask/subtaskFastTravel.c +++ b/src/subtask/subtaskFastTravel.c @@ -12,7 +12,7 @@ #include "save.h" #include "affine.h" #include "asm.h" -#include "structures.h" +#include "pauseMenu.h" extern void (*const Subtask_FastTravel_Functions[])(void); void sub_080A6E70(void); diff --git a/src/subtask/subtaskLocalMapHint.c b/src/subtask/subtaskLocalMapHint.c index cd33365d..7de81d4d 100644 --- a/src/subtask/subtaskLocalMapHint.c +++ b/src/subtask/subtaskLocalMapHint.c @@ -12,7 +12,7 @@ #include "sound.h" #include "common.h" #include "affine.h" -#include "structures.h" +#include "vram.h" void Subtask_LocalMapHint() { extern void (*const gUnk_08128F1C[])(void); diff --git a/src/text.c b/src/text.c index d15ce166..7b4305f8 100644 --- a/src/text.c +++ b/src/text.c @@ -1,6 +1,5 @@ #include "global.h" #include "common.h" -#include "structures.h" #include "asm.h" #include "enemy.h" #include "message.h" diff --git a/src/title.c b/src/title.c index c9ca4543..a9df5b66 100644 --- a/src/title.c +++ b/src/title.c @@ -14,7 +14,6 @@ #include "room.h" #include "player.h" #include "message.h" -#include "structures.h" #include "save.h" #include "game.h" #include "affine.h" diff --git a/src/ui.c b/src/ui.c index f7bd74c8..b12cfc9a 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1,3 +1,4 @@ +#include "ui.h" #include "area.h" #include "common.h" #include "game.h" @@ -9,6 +10,7 @@ #include "screen.h" #include "sound.h" #include "affine.h" +#include "vram.h" #include "structures.h" extern void sub_0805ECEC(u32, u32, u32, u32); @@ -609,7 +611,7 @@ void sub_0801CAFC(UIElement* element, u32 frameIndex) { void sub_0801CB20(UIElement* element, UIElementDefinition* definition) { if (definition->unk_e == 0) { - SpritePtr* ptr = &gSpritePtrs[definition->spriteIndex]; + const SpritePtr* ptr = &gSpritePtrs[definition->spriteIndex]; SpriteFrame* frame = &ptr->frames[element->frameIndex]; u32* firstTile = (u32*)(ptr->ptr + frame->firstTileIndex * 0x20); u8 numTiles = frame->numTiles; diff --git a/src/vram.c b/src/vram.c index 02a186ac..be4820cf 100644 --- a/src/vram.c +++ b/src/vram.c @@ -1,7 +1,7 @@ #include "common.h" #include "fileselect.h" #include "vram.h" -#include "structures.h" +#include "gfx.h" extern u32 gFixedTypeGfxData[];