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
+8
View File
@@ -339,6 +339,14 @@ void DrawEnhancementsMenu() {
ImGui::EndMenu();
}
if (UIWidgets::BeginMenu("Dpad")) {
UIWidgets::CVarCheckbox("Dpad Equips", "gEnhancements.Dpad.DpadEquips", {
.tooltip = "Allows you to equip items to your d-pad"
});
ImGui::EndMenu();
}
if (UIWidgets::BeginMenu("Fixes")) {
UIWidgets::CVarCheckbox("Fix Ammo Count Color", "gFixes.FixAmmoCountEnvColor", {
.tooltip = "Fixes a missing gDPSetEnvColor, which causes the ammo count to be the wrong color prior to obtaining magic or other conditions."
+13 -3
View File
@@ -19,6 +19,7 @@ HudEditorElement hudEditorElements[HUD_EDITOR_ELEMENT_MAX] = {
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_RUPEE_COUNTER, "Rupees", "Rupees", 26, 206, 200, 255, 100, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_KEY_COUNTER, "Keys", "Keys", 26, 190, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER, "Skulltulas", "Skulltulas", 26, 190, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_D_PAD, "D-Pad", "DPad", 271, 55, 255, 255, 255, 255),
};
extern "C" bool HudEditor_ShouldOverrideDraw() {
@@ -61,6 +62,14 @@ const char* presetNames[] = {
"Widescreen",
};
namespace HudEditor {
enum Presets {
VANILLA,
HIDDEN,
WIDESCREEN,
};
};
void HudEditorWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(480,600), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Hud Editor", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
@@ -68,7 +77,7 @@ void HudEditorWindow::DrawElement() {
return;
}
static int preset = 0;
static HudEditor::Presets preset = HudEditor::Presets::VANILLA;
if (UIWidgets::Combobox("Preset", &preset, presetNames)) {
for (int i = HUD_EDITOR_ELEMENT_B; i < HUD_EDITOR_ELEMENT_MAX; i++) {
CVarClear(hudEditorElements[i].xCvar);
@@ -79,13 +88,13 @@ void HudEditorWindow::DrawElement() {
}
switch (preset) {
case 1: {
case HudEditor::Presets::HIDDEN: {
for (int i = HUD_EDITOR_ELEMENT_B; i < HUD_EDITOR_ELEMENT_MAX; i++) {
CVarSetInteger(hudEditorElements[i].modeCvar, HUD_EDITOR_ELEMENT_MODE_HIDDEN);
}
break;
}
case 2: {
case HudEditor::Presets::WIDESCREEN: {
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_B].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_LEFT].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_DOWN].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
@@ -98,6 +107,7 @@ void HudEditorWindow::DrawElement() {
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_RUPEE_COUNTER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_KEY_COUNTER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_D_PAD].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
break;
}
}
+1
View File
@@ -35,6 +35,7 @@ typedef enum {
HUD_EDITOR_ELEMENT_RUPEE_COUNTER,
HUD_EDITOR_ELEMENT_KEY_COUNTER,
HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER,
HUD_EDITOR_ELEMENT_D_PAD,
HUD_EDITOR_ELEMENT_MAX,
} HudEditorElementID;
+26
View File
@@ -6,6 +6,30 @@
using json = nlohmann::json;
void to_json(json& j, const DpadSaveInfo& dpadEquips) {
j = json{
{ "dpadItems", dpadEquips.dpadItems },
{ "dpadSlots", dpadEquips.dpadSlots },
};
}
void from_json(const json& j, DpadSaveInfo& dpadEquips) {
for (int i = 0; i < ARRAY_COUNT(dpadEquips.dpadItems); i++) {
j.at("dpadItems").at(i).get_to(dpadEquips.dpadItems[i]);
j.at("dpadSlots").at(i).get_to(dpadEquips.dpadSlots[i]);
}
}
void to_json(json& j, const ShipSaveInfo& shipSaveInfo) {
j = json {
{ "dpadEquips", shipSaveInfo.dpadEquips },
};
}
void from_json(const json& j, ShipSaveInfo& shipSaveInfo) {
j.at("dpadEquips").get_to(shipSaveInfo.dpadEquips);
}
void to_json(json& j, const ItemEquips& itemEquips) {
j = json{
{ "buttonItems", itemEquips.buttonItems },
@@ -252,6 +276,7 @@ void to_json(json& j, const Save& save) {
{ "hasTatl", save.hasTatl },
{ "isOwlSave", save.isOwlSave },
{ "saveInfo", save.saveInfo },
{ "shipSaveInfo", save.shipSaveInfo },
};
}
@@ -273,6 +298,7 @@ void from_json(const json& j, Save& save) {
j.at("hasTatl").get_to(save.hasTatl);
j.at("isOwlSave").get_to(save.isOwlSave);
j.at("saveInfo").get_to(save.saveInfo);
j.at("shipSaveInfo").get_to(save.shipSaveInfo);
}
void to_json(json& j, const SaveContext& saveContext) {
+20 -17
View File
@@ -387,23 +387,26 @@ void DrawEquipItemMenu(InventorySlot slot) {
gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][EQUIP_SLOT_C_RIGHT] = slot;
Interface_LoadItemIconImpl(gPlayState, EQUIP_SLOT_C_RIGHT);
}
// Todo: DPAD equips support
// if (ImGui::MenuItem("D-Up")) {
// gSaveContext.save.saveInfo.equips.buttonItems[CUR_FORM][4] = currentItemId;
// gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][3] = slot;
// }
// if (ImGui::MenuItem("D-Down")) {
// gSaveContext.save.saveInfo.equips.buttonItems[CUR_FORM][5] = currentItemId;
// gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][4] = slot;
// }
// if (ImGui::MenuItem("D-Left")) {
// gSaveContext.save.saveInfo.equips.buttonItems[CUR_FORM][6] = currentItemId;
// gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][5] = slot;
// }
// if (ImGui::MenuItem("D-Right")) {
// gSaveContext.save.saveInfo.equips.buttonItems[CUR_FORM][7] = currentItemId;
// gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][6] = slot;
// }
if (ImGui::MenuItem("D-Up")) {
gSaveContext.save.shipSaveInfo.dpadEquips.dpadItems[CUR_FORM][EQUIP_SLOT_D_RIGHT] = currentItemId;
gSaveContext.save.shipSaveInfo.dpadEquips.dpadSlots[CUR_FORM][EQUIP_SLOT_D_RIGHT] = slot;
Interface_Dpad_LoadItemIconImpl(gPlayState, EQUIP_SLOT_D_RIGHT);
}
if (ImGui::MenuItem("D-Down")) {
gSaveContext.save.shipSaveInfo.dpadEquips.dpadItems[CUR_FORM][EQUIP_SLOT_D_LEFT] = currentItemId;
gSaveContext.save.shipSaveInfo.dpadEquips.dpadSlots[CUR_FORM][EQUIP_SLOT_D_LEFT] = slot;
Interface_Dpad_LoadItemIconImpl(gPlayState, EQUIP_SLOT_D_LEFT);
}
if (ImGui::MenuItem("D-Left")) {
gSaveContext.save.shipSaveInfo.dpadEquips.dpadItems[CUR_FORM][EQUIP_SLOT_D_DOWN] = currentItemId;
gSaveContext.save.shipSaveInfo.dpadEquips.dpadSlots[CUR_FORM][EQUIP_SLOT_D_DOWN] = slot;
Interface_Dpad_LoadItemIconImpl(gPlayState, EQUIP_SLOT_D_DOWN);
}
if (ImGui::MenuItem("D-Right")) {
gSaveContext.save.shipSaveInfo.dpadEquips.dpadItems[CUR_FORM][EQUIP_SLOT_D_UP] = currentItemId;
gSaveContext.save.shipSaveInfo.dpadEquips.dpadSlots[CUR_FORM][EQUIP_SLOT_D_UP] = slot;
Interface_Dpad_LoadItemIconImpl(gPlayState, EQUIP_SLOT_D_UP);
}
ImGui::EndMenu();
}
}
+14
View File
@@ -0,0 +1,14 @@
#include "2s2h/SaveManager/SaveManager.h"
#include "z64.h"
void SaveManager_Migration_2(nlohmann::json& j) {
nlohmann::json dpadEquips;
for (int i = 0; i < EQUIP_SLOT_D_MAX; i++) {
for (int j = 0; j < EQUIP_SLOT_D_MAX; j++) {
dpadEquips["dpadItems"][i][j] = ITEM_NONE;
dpadEquips["dpadSlots"][i][j] = SLOT_NONE;
}
}
j["save"]["shipSaveInfo"]["dpadEquips"] = dpadEquips;
}
+5 -3
View File
@@ -42,19 +42,21 @@ const std::filesystem::path savesFolderPath(Ship::Context::GetPathRelativeToAppD
// - Increment CURRENT_SAVE_VERSION
// - Create the migration file in the Migrations folder with the name `{CURRENT_SAVE_VERSION}.cpp`
// - Add the migration function definition below and add it to the `migrations` map with the key being the previous version
const uint32_t CURRENT_SAVE_VERSION = 1;
const uint32_t CURRENT_SAVE_VERSION = 2;
void SaveManager_Migration_1(nlohmann::json& j);
void SaveManager_Migration_2(nlohmann::json& j);
std::map<uint32_t, std::function<void(nlohmann::json&)>> migrations = {
const std::unordered_map<uint32_t, std::function<void(nlohmann::json&)>> migrations = {
{ 0, SaveManager_Migration_1 },
{ 1, SaveManager_Migration_2 },
};
void SaveManager_MigrateSave(nlohmann::json& j) {
int version = j.value("version", 0);
while (version != CURRENT_SAVE_VERSION) {
if (migrations.contains(version)) {
auto migration = migrations[version];
auto migration = migrations.at(version);
migration(j);
}
version = j["version"] = version + 1;
+3
View File
@@ -55,3 +55,6 @@ static const ALIGN_ASSET(2) char gThreeDayClockHour23Tex[] = dgThreeDayClockHour
#define dgThreeDayClockHour24Tex "__OTR__textures/parameter_static/gThreeDayClockHour24Tex"
static const ALIGN_ASSET(2) char gThreeDayClockHour24Tex[] = dgThreeDayClockHour24Tex;
#define dgEmptyTexture "__OTR__textures/virtual/gEmptyTexture"
static const ALIGN_ASSET(2) char gEmptyTexture[] = dgEmptyTexture;
+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)
+18
View File
@@ -4477,6 +4477,9 @@ s32 Camera_KeepOn3(Camera* camera) {
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) ||
// #region 2S2H [Dpad]
CHECK_BTN_DPAD(CONTROLLER1(&camera->play->state)->press.button) ||
// #endregion
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R)) {
@@ -5536,6 +5539,9 @@ s32 Camera_Unique0(Camera* camera) {
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) ||
// #region 2S2H [Dpad]
CHECK_BTN_DPAD(CONTROLLER1(&camera->play->state)->press.button) ||
// #endregion
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R) ||
@@ -5560,6 +5566,9 @@ s32 Camera_Unique0(Camera* camera) {
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) ||
// #region 2S2H [Dpad]
CHECK_BTN_DPAD(CONTROLLER1(&camera->play->state)->press.button) ||
// #endregion
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R) ||
@@ -6047,6 +6056,9 @@ s32 Camera_Demo2(Camera* camera) {
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) ||
// #region 2S2H [Dpad]
CHECK_BTN_DPAD(CONTROLLER1(&camera->play->state)->press.button) ||
// #endregion
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R)) &&
@@ -6783,6 +6795,9 @@ s32 Camera_Special8(Camera* camera) {
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) ||
// #region 2S2H [Dpad]
CHECK_BTN_DPAD(CONTROLLER1(&camera->play->state)->press.button) ||
// #endregion
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R) ||
@@ -6950,6 +6965,9 @@ s32 Camera_Special9(Camera* camera) {
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) ||
// #region 2S2H [Dpad]
CHECK_BTN_DPAD(CONTROLLER1(&camera->play->state)->press.button) ||
// #endregion
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) ||
CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R) ||
+6
View File
@@ -61,6 +61,12 @@ void GameOver_Update(PlayState* play) {
gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_ENABLED;
gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_ENABLED;
gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED;
// #region 2S2H
gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_RIGHT] = BTN_ENABLED;
gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_LEFT] = BTN_ENABLED;
gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_DOWN] = BTN_ENABLED;
gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_UP] = BTN_ENABLED;
// #endregion
gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED;
gSaveContext.hudVisibilityForceButtonAlphasByStatus = false;
gSaveContext.nextHudVisibility = HUD_VISIBILITY_IDLE;
+8 -4
View File
@@ -14,9 +14,7 @@
#include "assets/interface/message_texture_static/message_texture_static.h"
#include <string.h>
// #region 2S2H [Port] Asset tables we can pull from instead of from ROM
#define dgEmptyTexture "__OTR__textures/virtual/gEmptyTexture"
static const ALIGN_ASSET(2) char gEmptyTexture[] = dgEmptyTexture;
#include "2s2h_assets.h"
const char* gBombersNotebookPhotos[] = {
gBombersNotebookPhotoAnjuTex,
@@ -2883,7 +2881,13 @@ void Message_Decode(PlayState* play) {
decodedBufPos--;
} else if (curChar == 0x22E) {
digits[0] = digits[1] = digits[2] = 0;
digits[3] = gItemPrices[GET_CUR_FORM_BTN_ITEM(player->heldItemButton)];
// #region 2S2H [Dpad]
if (IS_HELD_DPAD(player->heldItemButton)) {
digits[3] = gItemPrices[DPAD_GET_CUR_FORM_BTN_ITEM(HELD_ITEM_TO_DPAD(player->heldItemButton))];
} else {
digits[3] = gItemPrices[GET_CUR_FORM_BTN_ITEM(player->heldItemButton)];
}
// #endregion
while (digits[3] >= 1000) {
digits[0]++;
+7 -1
View File
@@ -1564,7 +1564,13 @@ void Message_DecodeNES(PlayState* play) {
decodedBufPos--;
} else if (curChar == 0xDE) {
digits[0] = digits[1] = digits[2] = 0;
digits[3] = gItemPrices[GET_CUR_FORM_BTN_ITEM(player->heldItemButton)];
// #region 2S2H [Dpad]
if (IS_HELD_DPAD(player->heldItemButton)) {
digits[3] = gItemPrices[DPAD_GET_CUR_FORM_BTN_ITEM(HELD_ITEM_TO_DPAD(player->heldItemButton))];
} else {
digits[3] = gItemPrices[GET_CUR_FORM_BTN_ITEM(player->heldItemButton)];
}
// #endregion
while (digits[3] >= 1000) {
digits[0]++;
+1055 -8
View File
File diff suppressed because it is too large Load Diff
+49 -1
View File
@@ -574,6 +574,16 @@ s32 func_801235DC(PlayState* play, f32 arg1, s16 arg2) {
return false;
}
// #region 2S2H [Dpad]
ItemId Player_Dpad_GetItemOnButton(PlayState* play, Player* player, DpadEquipSlot slot) {
if (slot >= EQUIP_SLOT_D_MAX) {
return ITEM_NONE;
}
return DPAD_BTN_ITEM(slot);
}
// #endregion
ItemId Player_GetItemOnButton(PlayState* play, Player* player, EquipSlot slot) {
if (slot >= EQUIP_SLOT_A) {
return ITEM_NONE;
@@ -614,6 +624,15 @@ ItemId Player_GetItemOnButton(PlayState* play, Player* player, EquipSlot slot) {
return C_BTN_ITEM(EQUIP_SLOT_C_RIGHT);
}
// #region 2S2H [Dpad]
u16 sDItemButtons[] = {
BTN_DRIGHT,
BTN_DLEFT,
BTN_DDOWN,
BTN_DUP,
};
// #endregion
u16 sCItemButtons[] = {
BTN_CLEFT,
BTN_CDOWN,
@@ -657,6 +676,29 @@ PlayerItemAction func_80123810(PlayState* play) {
}
}
}
// #region 2S2H [Dpad]
if (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0)) {
for (i = 0; i < ARRAY_COUNT(sDItemButtons); i++) {
if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, sDItemButtons[i])) {
itemId = Player_Dpad_GetItemOnButton(play, player, i);
play->interfaceCtx.unk_222 = 0;
play->interfaceCtx.unk_224 = 0;
Interface_SetHudVisibility(play->msgCtx.hudVisibility);
if ((itemId >= ITEM_FD) || ((itemAction = play->unk_18794(play, player, itemId)) <= PLAYER_IA_MINUS1)) {
Audio_PlaySfx(NA_SE_SY_ERROR);
return PLAYER_IA_MINUS1;
} else {
s32 pad;
player->heldItemButton = DPAD_TO_HELD_ITEM(i);
return itemAction;
}
}
}
}
// #endregion
return PLAYER_IA_NONE;
}
@@ -1316,7 +1358,13 @@ void Player_SetEquipmentData(PlayState* play, Player* player) {
}
void Player_UpdateBottleHeld(PlayState* play, Player* player, ItemId itemId, PlayerItemAction itemAction) {
Inventory_UpdateBottleItem(play, itemId, player->heldItemButton);
// #region 2S2H [Dpad]
if (IS_HELD_DPAD(player->heldItemButton)) {
Inventory_Dpad_UpdateBottleItem(play, itemId, HELD_ITEM_TO_DPAD(player->heldItemButton));
} else {
Inventory_UpdateBottleItem(play, itemId, player->heldItemButton);
}
// #endregion
if (itemId != ITEM_BOTTLE) {
player->heldItemId = itemId;
+39
View File
@@ -555,6 +555,14 @@ void Sram_SaveEndOfCycle(PlayState* play) {
Interface_LoadItemIconImpl(play, j);
}
}
// #region 2S2H [Dpad]
for (s32 k = EQUIP_SLOT_D_RIGHT; k <= EQUIP_SLOT_D_UP; k++) {
if (DPAD_GET_CUR_FORM_BTN_ITEM(k) == gSaveContext.save.saveInfo.inventory.items[i]) {
DPAD_SET_CUR_FORM_BTN_ITEM(k, ITEM_BOTTLE);
Interface_Dpad_LoadItemIconImpl(play, k);
}
}
// #endregion
gSaveContext.save.saveInfo.inventory.items[i] = ITEM_BOTTLE;
}
}
@@ -623,6 +631,14 @@ void Sram_SaveEndOfCycle(PlayState* play) {
Interface_LoadItemIconImpl(play, j);
}
}
// #region 2S2H [Dpad]
for (s32 k = EQUIP_SLOT_D_RIGHT; k <= EQUIP_SLOT_D_UP; k++) {
if ((DPAD_GET_CUR_FORM_BTN_ITEM(k) >= ITEM_MOONS_TEAR) && (DPAD_GET_CUR_FORM_BTN_ITEM(k) <= ITEM_PENDANT_OF_MEMORIES)) {
DPAD_SET_CUR_FORM_BTN_ITEM(k, ITEM_NONE);
Interface_Dpad_LoadItemIconImpl(play, k);
}
}
// #endregion
gSaveContext.save.saveInfo.skullTokenCount &= ~0xFFFF0000;
gSaveContext.save.saveInfo.skullTokenCount &= ~0x0000FFFF;
@@ -813,6 +829,23 @@ ItemEquips sSaveDefaultItemEquips = {
0x11,
};
// #region 2S2H
DpadSaveInfo sSaveDefaultDpadItemEquips = {
{
{ ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE },
{ ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE },
{ ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE },
{ ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE },
},
{
{ SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE },
{ SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE },
{ SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE },
{ SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE },
},
};
// #endregion
Inventory sSaveDefaultInventory = {
// items
{
@@ -937,6 +970,9 @@ void Sram_InitNewSave(void) {
memcpy(&gSaveContext.save.saveInfo.playerData, &sSaveDefaultPlayerData, sizeof(SavePlayerData));
memcpy(&gSaveContext.save.saveInfo.equips, &sSaveDefaultItemEquips, sizeof(ItemEquips));
// #region 2S2H [Dpad]
memcpy(&gSaveContext.save.shipSaveInfo.dpadEquips, &sSaveDefaultDpadItemEquips, sizeof(DpadSaveInfo));
// #endregion
memcpy(&gSaveContext.save.saveInfo.inventory, &sSaveDefaultInventory, sizeof(Inventory));
memcpy(&gSaveContext.save.saveInfo.checksum, &sSaveDefaultChecksum,
sizeof(gSaveContext.save.saveInfo.checksum));
@@ -1142,6 +1178,9 @@ void Sram_InitDebugSave(void) {
memcpy(&gSaveContext.save.saveInfo.playerData, &sSaveDebugPlayerData, sizeof(SavePlayerData));
memcpy(&gSaveContext.save.saveInfo.equips, &sSaveDebugItemEquips, sizeof(ItemEquips));
// #region 2S2H [Dpad]
memcpy(&gSaveContext.save.shipSaveInfo.dpadEquips, &sSaveDefaultDpadItemEquips, sizeof(DpadSaveInfo));
// #endregion
memcpy(&gSaveContext.save.saveInfo.inventory, &sSaveDebugInventory, sizeof(Inventory));
memcpy(&gSaveContext.save.saveInfo.checksum, &sSaveDebugChecksum, sizeof(gSaveContext.save.saveInfo.checksum));
@@ -266,7 +266,7 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) {
Audio_PlaySfx_AtPos(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_REFLECT);
}
} else if (CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button,
BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) {
BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN | BTN_DPAD_EQUIP)) {
s32 pad;
this->timer = 1;
@@ -1715,7 +1715,7 @@ void Boss02_HandleGiantsMaskCutscene(Boss02* this, PlayState* play) {
case GIANTS_MASK_CS_STATE_MASK_ON:
if ((this->giantsMaskCsTimer < 80) && sCanSkipMaskOnCs &&
CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button,
BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) {
BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT | BTN_DPAD_EQUIP)) {
this->giantsMaskCsState++;
this->giantsMaskCsFlashState = GIANTS_MASK_CS_FLASH_STATE_STARTED;
this->giantsMaskCsTimer = 0;
@@ -1769,7 +1769,7 @@ void Boss02_HandleGiantsMaskCutscene(Boss02* this, PlayState* play) {
case GIANTS_MASK_CS_STATE_MASK_OFF:
if ((this->giantsMaskCsTimer < 30) && sCanSkipMaskOffCs &&
CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button,
BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) {
BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT | BTN_DPAD_EQUIP)) {
this->giantsMaskCsState++;
this->giantsMaskCsFlashState = GIANTS_MASK_CS_FLASH_STATE_STARTED;
this->giantsMaskCsTimer = 0;

Some files were not shown because too many files have changed in this diff Show More