DPad Items (#228)

* Initial Dpad

* remove old hud stuff

* and comment

* s..

* add dpad equip macro back in

* fix inputs

* fix equipping (hopefully all)

* finish some todos

* add 2s2h asset header

* check dpad macro

* remove 2s2h_assets

* re-add empty texture

* use correct struct for default dpad equips

* dpad save stuff

* fix item offering, use correct equip offset values

* finally figure out unk_154 and fix mask equipping

* avoid ugly code

* add necessary condition

* correct save names for dpad items/slots

* remove todos and sort out suggestions and rename cvar

* func standardise renaming

* Add dpad to hud presets

* dpad save migration
This commit is contained in:
inspectredc
2024-05-22 09:05:04 -05:00
committed by Garrett Cox
parent 1d5d9be069
commit ad478cfc59
28 changed files with 2962 additions and 60 deletions
+3
View File
@@ -792,6 +792,9 @@ s32 func_80123448(PlayState* play);
s32 Player_IsGoronOrDeku(Player* player);
s32 func_801234D4(PlayState* play);
s32 func_80123590(PlayState* play, Actor* actor);
// #region 2S2H [Dpad]
ItemId Player_Dpad_GetItemOnButton(PlayState* play, Player* player, DpadEquipSlot slot);
// #endregion
ItemId Player_GetItemOnButton(PlayState* play, Player* player, EquipSlot slot);
PlayerItemAction func_80123810(PlayState* play);
PlayerModelGroup Player_ActionToModelGroup(Player* player, PlayerItemAction itemAction);
+32
View File
@@ -14,6 +14,17 @@ typedef enum {
/* 5 */ EQUIP_SLOT_MAX
} EquipSlot;
// #region 2S2H
typedef enum {
/* -1 */ EQUIP_SLOT_D_NONE = -1,
/* 0 */ EQUIP_SLOT_D_RIGHT,
/* 1 */ EQUIP_SLOT_D_LEFT,
/* 2 */ EQUIP_SLOT_D_DOWN,
/* 3 */ EQUIP_SLOT_D_UP,
/* 4 */ EQUIP_SLOT_D_MAX
} DpadEquipSlot;
// #endregion
typedef enum {
/* 0 */ A_BTN_STATE_0,
/* 1 */ A_BTN_STATE_1,
@@ -141,6 +152,19 @@ typedef struct {
char* subTex;
} ActionLabel;
// #region 2S2H
typedef struct {
s16 dRightAlpha;
s16 dLeftAlpha;
s16 dDownAlpha;
s16 dUpAlpha;
} DpadInterface;
typedef struct {
DpadInterface dpad;
} ShipInterfaceContext;
// #endregion
typedef struct {
/* 0x000 */ View view;
/* 0x168 */ Vtx* actionVtx;
@@ -238,6 +262,7 @@ typedef struct {
/* 0x33C */ u8* storySegment;
/* 0x340 */ uintptr_t storyAddr;
/* 0x344 */ size_t storySize;
/* 2S2H */ ShipInterfaceContext shipInterface;
} InterfaceContext; // size = 0x348
Gfx* Gfx_DrawTexRectRGBA16(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy);
@@ -253,6 +278,10 @@ void Interface_SetHudVisibility(u16 hudVisibility);
void Interface_UpdateButtonsPart2(struct PlayState* play);
void Interface_SetSceneRestrictions(struct PlayState* play);
void Interface_InitMinigame(struct PlayState* play);
// #region 2S2H [Dpad]
void Interface_Dpad_LoadItemIconImpl(struct PlayState* play, u8 btn);
void Interface_Dpad_LoadItemIcon(struct PlayState* play, u8 btn);
// #endregion
void Interface_LoadItemIconImpl(struct PlayState* play, u8 btn);
void Interface_LoadItemIcon(struct PlayState* play, u8 btn);
void Interface_UpdateButtonsAlt(struct PlayState* play, u16 flag);
@@ -264,6 +293,9 @@ s32 Inventory_ReplaceItem(struct PlayState* play, u8 oldItem, u8 newItem);
void Inventory_UpdateDeitySwordEquip(struct PlayState* play) ;
s32 Inventory_HasEmptyBottle(void);
s32 Inventory_HasItemInBottle(u8 item);
// #region 2S2H [Dpad]
void Inventory_Dpad_UpdateBottleItem(struct PlayState* play, u8 item, u8 btn);
// #endregion
void Inventory_UpdateBottleItem(struct PlayState* play, u8 item, u8 btn);
s32 Inventory_ConsumeFairy(struct PlayState* play);
void Inventory_UpdateItem(struct PlayState* play, s16 slot, s16 item);
+64
View File
@@ -319,6 +319,19 @@ typedef struct SaveInfo {
/* 0xFE6 */ u16 checksum; // "check_sum"
} SaveInfo; // size = 0xFE8
// #region 2S2H
typedef struct DpadSaveInfo {
u8 dpadItems[4][4];
u8 dpadSlots[4][4];
} DpadSaveInfo;
// These are values added by 2S2H that we need to be persisted to the save file
// See `ShipSaveContext` for values on the SaveContext that aren't persisted.
typedef struct ShipSaveInfo {
DpadSaveInfo dpadEquips;
} ShipSaveInfo;
// #endregion
typedef struct Save {
/* 0x00 */ s32 entrance; // "scene_no"
/* 0x04 */ u8 equippedMask; // "player_mask"
@@ -337,8 +350,21 @@ typedef struct Save {
/* 0x22 */ u8 hasTatl; // "bell_flag"
/* 0x23 */ u8 isOwlSave;
/* 0x24 */ SaveInfo saveInfo;
/* 2S2H */ ShipSaveInfo shipSaveInfo;
} Save; // size = 0x100C
// #region 2S2H
typedef struct DpadSaveContext {
u8 status[4];
} DpadSaveContext;
// These are values added by 2S2H that aren't persisted to the save file
// See `ShipSaveInfo` for values on the SaveContext that are persisted.
typedef struct ShipSaveContext {
DpadSaveContext dpad;
} ShipSaveContext;
// #endregion
typedef struct SaveContext {
/* 0x0000 */ Save save;
/* 0x100C */ u8 eventInf[8]; // "event_inf"
@@ -422,6 +448,7 @@ typedef struct SaveContext {
/* 0x3F68 */ CycleSceneFlags cycleSceneFlags[120]; // Scene flags that are temporarily stored over the duration of a single 3-day cycle
/* 0x48C8 */ u16 dungeonIndex; // "scene_id_mix"
/* 0x48CA */ u8 masksGivenOnMoon[27]; // bit-packed, masks given away on the Moon. "mask_mask_bit"
/* 2S2H */ ShipSaveContext shipSaveContext;
} SaveContext; // size = 0x48C8
typedef enum ButtonStatus {
@@ -530,6 +557,43 @@ typedef enum {
} \
(void)0
// #region 2S2H [DPad]
#define DPAD_TO_HELD_ITEM(btn) (btn + EQUIP_SLOT_MAX)
#define HELD_ITEM_TO_DPAD(heldBtn) (heldBtn - EQUIP_SLOT_MAX)
#define IS_HELD_DPAD(heldBtn) ((heldBtn >= DPAD_TO_HELD_ITEM(EQUIP_SLOT_D_RIGHT)) && (heldBtn <= DPAD_TO_HELD_ITEM(EQUIP_SLOT_D_UP)))
#define BTN_DPAD_EQUIP (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0) ? (BTN_DRIGHT | BTN_DLEFT | BTN_DDOWN | BTN_DUP) : 0)
#define CHECK_BTN_DPAD(input) (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0) && \
(CHECK_BTN_ALL(input, BTN_DRIGHT) || \
CHECK_BTN_ALL(input, BTN_DLEFT) || \
CHECK_BTN_ALL(input, BTN_DDOWN) || \
CHECK_BTN_ALL(input, BTN_DUP)))
#define DPAD_BUTTON(btn) (btn) // Translates between equip slot enum and button, in case we change how enum works
#define DPAD_BUTTON_ITEM_EQUIP(form, btn) (gSaveContext.save.shipSaveInfo.dpadEquips.dpadItems[form][DPAD_BUTTON(btn)])
#define DPAD_CUR_FORM_EQUIP(btn) BUTTON_ITEM_EQUIP(CUR_FORM, DPAD_BUTTON(btn)) // Unused
#define DPAD_SLOT_EQUIP(form, btn) (gSaveContext.save.shipSaveInfo.dpadEquips.dpadSlots[form][DPAD_BUTTON(btn)])
#define DPAD_GET_CUR_FORM_BTN_ITEM(btn) (DPAD_BUTTON_ITEM_EQUIP(0, DPAD_BUTTON(btn)))
#define DPAD_GET_CUR_FORM_BTN_SLOT(btn) (DPAD_SLOT_EQUIP(0, DPAD_BUTTON(btn)))
#define DPAD_BTN_ITEM(btn) \
((gSaveContext.shipSaveContext.dpad.status[(DPAD_BUTTON(btn))] != BTN_DISABLED) \
? DPAD_BUTTON_ITEM_EQUIP(0, (DPAD_BUTTON(btn))) \
: ((gSaveContext.hudVisibility == HUD_VISIBILITY_A_B_C) ? DPAD_BUTTON_ITEM_EQUIP(0, (DPAD_BUTTON(btn))) : ITEM_NONE))
#define DPAD_SET_CUR_FORM_BTN_ITEM(btn, item) \
DPAD_BUTTON_ITEM_EQUIP(0, (DPAD_BUTTON(btn))) = (item); \
(void)0
#define DPAD_SET_CUR_FORM_BTN_SLOT(btn, item) \
DPAD_SLOT_EQUIP(0, (DPAD_BUTTON(btn))) = (item); \
(void)0
// #endregion
#define STOLEN_ITEM_NONE (0)
#define STOLEN_ITEM_1 ((gSaveContext.save.saveInfo.stolenItems & 0xFF000000) >> 0x18)