mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp.git
synced 2024-12-27 12:19:06 +00:00
134 lines
3.4 KiB
C
134 lines
3.4 KiB
C
#include "patches.h"
|
|
#include "input.h"
|
|
|
|
u32 sPlayerItemButtons[] = {
|
|
BTN_B,
|
|
BTN_CLEFT,
|
|
BTN_CDOWN,
|
|
BTN_CRIGHT,
|
|
};
|
|
|
|
u32 prev_item_buttons = 0;
|
|
u32 cur_item_buttons = 0;
|
|
u32 pressed_item_buttons = 0;
|
|
u32 released_item_buttons = 0;
|
|
|
|
typedef enum {
|
|
EQUIP_SLOT_EX_DEKU = -2,
|
|
EQUIP_SLOT_EX_GORON = -3,
|
|
EQUIP_SLOT_EX_ZORA = -4,
|
|
EQUIP_SLOT_EX_OCARINA = -5
|
|
} EquipSlotEx;
|
|
|
|
void GameState_GetInput(GameState* gameState) {
|
|
PadMgr_GetInput(gameState->input, true);
|
|
|
|
|
|
prev_item_buttons = cur_item_buttons;
|
|
recomp_get_item_inputs(&cur_item_buttons);
|
|
u32 button_diff = prev_item_buttons ^ cur_item_buttons;
|
|
pressed_item_buttons = cur_item_buttons & button_diff;
|
|
released_item_buttons = prev_item_buttons & button_diff;
|
|
}
|
|
|
|
struct SlotMap {
|
|
u32 button;
|
|
EquipSlotEx slot;
|
|
};
|
|
|
|
struct SlotMap exSlotMapping[] = {
|
|
{BTN_DLEFT, EQUIP_SLOT_EX_GORON},
|
|
{BTN_DRIGHT, EQUIP_SLOT_EX_ZORA},
|
|
{BTN_DUP, EQUIP_SLOT_EX_DEKU},
|
|
{BTN_DDOWN, EQUIP_SLOT_EX_OCARINA},
|
|
};
|
|
|
|
// D-Pad items
|
|
// TODO restore this once UI is made
|
|
// Return currently-pressed button, in order of priority D-Pad, B, CLEFT, CDOWN, CRIGHT.
|
|
/*
|
|
EquipSlot func_8082FDC4(void) {
|
|
EquipSlot i;
|
|
|
|
for (int mapping_index = 0; mapping_index < ARRAY_COUNT(exSlotMapping); mapping_index++) {
|
|
if (pressed_item_buttons & exSlotMapping[mapping_index].button) {
|
|
return (EquipSlot)exSlotMapping[mapping_index].slot;
|
|
}
|
|
}
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sPlayerItemButtons); i++) {
|
|
if (CHECK_BTN_ALL(pressed_item_buttons, sPlayerItemButtons[i])) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
return i;
|
|
}
|
|
|
|
ItemId Player_GetItemOnButton(PlayState* play, Player* player, EquipSlot slot) {
|
|
if (slot >= EQUIP_SLOT_A) {
|
|
return ITEM_NONE;
|
|
}
|
|
|
|
if (slot <= EQUIP_SLOT_EX_DEKU) {
|
|
ItemId dpad_item = ITEM_NONE;
|
|
switch ((EquipSlotEx)slot) {
|
|
case EQUIP_SLOT_EX_DEKU:
|
|
dpad_item = ITEM_MASK_DEKU;
|
|
break;
|
|
case EQUIP_SLOT_EX_GORON:
|
|
dpad_item = ITEM_MASK_GORON;
|
|
break;
|
|
case EQUIP_SLOT_EX_ZORA:
|
|
dpad_item = ITEM_MASK_ZORA;
|
|
break;
|
|
case EQUIP_SLOT_EX_OCARINA:
|
|
dpad_item = ITEM_OCARINA_OF_TIME;
|
|
break;
|
|
}
|
|
|
|
if ((dpad_item != ITEM_NONE) && (INV_CONTENT(dpad_item) == dpad_item)) {
|
|
recomp_printf("Used dpad item %d\n", dpad_item);
|
|
return dpad_item;
|
|
}
|
|
else {
|
|
return ITEM_NONE;
|
|
}
|
|
}
|
|
|
|
if (slot == EQUIP_SLOT_B) {
|
|
ItemId item = Inventory_GetBtnBItem(play);
|
|
|
|
if (item >= ITEM_FD) {
|
|
return item;
|
|
}
|
|
|
|
if ((player->currentMask == PLAYER_MASK_BLAST) && (play->interfaceCtx.bButtonDoAction == DO_ACTION_EXPLODE)) {
|
|
return ITEM_F0;
|
|
}
|
|
|
|
if ((player->currentMask == PLAYER_MASK_BREMEN) && (play->interfaceCtx.bButtonDoAction == DO_ACTION_MARCH)) {
|
|
return ITEM_F1;
|
|
}
|
|
|
|
if ((player->currentMask == PLAYER_MASK_KAMARO) && (play->interfaceCtx.bButtonDoAction == DO_ACTION_DANCE)) {
|
|
return ITEM_F2;
|
|
}
|
|
|
|
return item;
|
|
}
|
|
|
|
if (slot == EQUIP_SLOT_C_LEFT) {
|
|
return C_BTN_ITEM(EQUIP_SLOT_C_LEFT);
|
|
}
|
|
|
|
if (slot == EQUIP_SLOT_C_DOWN) {
|
|
return C_BTN_ITEM(EQUIP_SLOT_C_DOWN);
|
|
}
|
|
|
|
// EQUIP_SLOT_C_RIGHT
|
|
|
|
return C_BTN_ITEM(EQUIP_SLOT_C_RIGHT);
|
|
}
|
|
*/
|