-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "interact button" enums: C, BC, BCA #1228
base: main
Are you sure you want to change the base?
Add "interact button" enums: C, BC, BCA #1228
Conversation
I'm not opposed to this idea and I have considered it myself many times in the past, but I still don't know if it would be an improvement overall considering the amount of iteration/computation being done with these indices. That plus the A button only being in One thing I'll say is that if we were to have this enum, names like |
Yeah so because there's no way to have a single "save button" enum, I'm now thinking there could be one enum per array basically So maybe: gSaveContext.equips.buttonItems[SAVE_EQUIPS_BUTTON_ITEM_(B / C_LEFT / C_DOWN / C_RIGHT)]
gSaveContext.equips.cButtonSlots[SAVE_EQUIPS_C_BUTTON_SLOT_(LEFT / DOWN / RIGHT)]
gSaveContext.buttonStatus[SAVE_BUTTON_STATUS_(B / C_LEFT / C_DOWN / C_RIGHT / A)] ? |
a49bc09
to
1fbd18c
Compare
SaveButtonIndex
enum
I was inspired |
Can't say that it makes much sense to me to have |
well, where a All three enums overlap, The purpose of this change is documentation and making the code easier to read, may as well not introduce confusion by conflating two enums that share values The PR as it stands isn't my first and only attempt at documenting the button array indices, I've tried several things before settling on this solution, so I'm past the improve-by-tinkering phase and would need concrete suggestions to improve it |
Still seems unnecessary and bloaty to split the one enumeration into two just to avoid using |
Using And yeah it's definitely more bloaty to use names like |
cool, that's nice to hear I would need a recap of what we're arguing about then |
I think he wants only one enum instead of two because those two enums overlap. |
To me, the purpose of an enum is to define an ordering to some set of things, and not necessarily to index an array, and so splitting the larger set into a smaller set just to support indexing different sized arrays just doesn't feel clean. In this case it just happens to feel reasonable to do because there isn't a whole lot of code dependent on the enums, the full set doesn't have a NONE value to cause oobs access, and the duplication isn't adding tremendous amounts of code. In any case, I await to see your split of |
which splits? I can only think of the dungeons one and yeah enums overlap. that's just how OoT was coded. For example I think we have like 10 enums that are contained in the ItemID enum (including like player item action, exchange item, item slots, sword/tunic/boots (and their player counterparts), upgrades, quest items) So at this point I have given up on having everything properly shifting on its own. Unfortunately, I think you just have to learn the codebase and know what to change if you wanted to edit this stuff, as imo favouring that in decomp would be too big of a hit to readability
yeah it isn't, cf where again it's just how oot is coded |
include/z64save.h
Outdated
typedef enum { | ||
/* 0 */ IBTN_BC_B, | ||
/* 1 */ IBTN_BC_C_LEFT, | ||
/* 2 */ IBTN_BC_C_DOWN, | ||
/* 3 */ IBTN_BC_C_RIGHT, | ||
/* 4 */ IBTN_BC_MAX | ||
} InteractButtonBC; | ||
|
||
#define IBTN_BC_C_FIRST IBTN_BC_C_LEFT | ||
#define IBTN_BC_C_LAST IBTN_BC_C_RIGHT | ||
|
||
typedef enum { | ||
/* 0 */ IBTN_C_C_LEFT, | ||
/* 1 */ IBTN_C_C_DOWN, | ||
/* 2 */ IBTN_C_C_RIGHT, | ||
/* 3 */ IBTN_C_MAX | ||
} InteractButtonC; | ||
|
||
#define IBTN_C_TO_BC(btnsC) ((btnsC) + 1) | ||
#define IBTN_BC_TO_C(btnsBC) ((btnsBC) - 1) | ||
|
||
typedef enum { | ||
/* 0 */ IBTN_BCA_B, | ||
/* 1 */ IBTN_BCA_C_LEFT, | ||
/* 2 */ IBTN_BCA_C_DOWN, | ||
/* 3 */ IBTN_BCA_C_RIGHT, | ||
/* 4 */ IBTN_BCA_A, | ||
/* 5 */ IBTN_BCA_MAX | ||
} InteractButtonBCA; | ||
|
||
#define IBTN_C_TO_BCA(btnsC) ((btnsC) + 1) | ||
#define IBTN_BC_TO_BCA(btnsBC) (btnsBC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's too many abbreviations compact in a small place that throws me off for this. I'd have no issues fully spelling out INTERACT_BTN
. What about:
typedef enum {
/* 0 */ INTERACT_BC_BTN_B,
/* 1 */ INTERACT_BC_BTN_C_LEFT,
/* 2 */ INTERACT_BC_BTN_C_DOWN,
/* 3 */ INTERACT_BC_BTN_C_RIGHT,
/* 4 */ INTERACT_BC_BTN_MAX
} InteractBCButton;
#define INTERACT_BC_BTN_C_FIRST INTERACT_BC_BTN_C_LEFT
#define INTERACT_BC_BTN_C_LAST INTERACT_BC_BTN_C_RIGHT
typedef enum {
/* 0 */ INTERACT_C_BTN_C_LEFT,
/* 1 */ INTERACT_C_BTN_C_DOWN,
/* 2 */ INTERACT_C_BTN_C_RIGHT,
/* 3 */ INTERACT_C_BTN_MAX
} InteractCButton;
#define INTERACT_C_BTN_TO_BC_BTN(btnsC) ((btnsC) + 1)
#define INTERACT_BC_BTN_TO_C_BTN(btnsBC) ((btnsBC) - 1)
typedef enum {
/* 0 */ INTERACT_BCA_BTN_B,
/* 1 */ INTERACT_BCA_BTN_C_LEFT,
/* 2 */ INTERACT_BCA_BTN_C_DOWN,
/* 3 */ INTERACT_BCA_BTN_C_RIGHT,
/* 4 */ INTERACT_BCA_BTN_A,
/* 5 */ INTERACT_BCA_BTN_MAX
} InteractBCAButton;
#define INTERACT_C_BTN_TO_BCA_BTN(btnsC) ((btnsC) + 1)
#define INTERACT_BC_BTN_TO_BCA_BTN(btnsBC) (btnsBC)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this yeah, and I think it works with "interact"
the thing with "interact" is "there are other buttons you use to 'interact'", but this way e.g. INTERACT_C_BTN_
could read as "the interact C button(s)"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead with this at least for now
link to short discussion on discord about this PR |
todo: look at macroify every access to the "interact btn"-indexed arrays and use a single enum |
Add three "interact button" enums:
and macros for converting between them (ft. bottle adventure)
see
z64save.h
(to get confirmation of the order of c buttons left/down/right, look at
pauseCtx->equipTargetCBtn
, orD_80854388
)