Skip to content

Document box user input handling #533

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

Merged
merged 25 commits into from
Jun 22, 2025
Merged

Conversation

CharlesFolz4
Copy link
Contributor

Initial box user input handling documentation

Document UnkEnum_021DFB94 as BoxMenuItem
Document ov19_021DF964 as box_menu
Document release mon state machine

Copy link
Collaborator

@lhearachel lhearachel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mostly looks good, just some little quibbles for polish and consistency.

BOX_MENU_HEART,
BOX_MENU_STAR,
BOX_MENU_DIAMOND
} BoxMenuItem;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: We don't typedef enum in this project.


#define MAX_MENU_ITEMS 8

typedef struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Tag the struct with the same name as its typedef.

u8 unk_02[2];
BOOL compareButtonAnimationPressed;
PCCompareMon compareMons[2];
} UnkStruct_ov19_021D4EE4;
} UnkStruct_ov19_021D4EE4; // BoxCompareMode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Feel free to name the struct if it feels apt.

@@ -8,7 +8,7 @@
typedef struct {
SaveData *saveData;
enum BoxMode boxMode;
BOOL unk_08;
BOOL RecordBoxUseInJournal;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polish: camelCase


void BoxMenu_FillYesNo(UnkStruct_ov19_021D4DF0 *param0, u32 menuItemIndex)
{
BoxMenu *menu = &(param0->boxMenu);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polish: Unnecessary parens.


BoxMenu_AddMenuItem(menu, BOX_MENU_SUMMARY);

{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polish: Unnecessary scope block.

Comment on lines 173 to 176
static const u16 v0[][4] = {
{ BOX_MENU_FOREST, BOX_MENU_CITY, BOX_MENU_DESERT, BOX_MENU_SAVANNA },
{ BOX_MENU_CRAG, BOX_MENU_VOLCANO, BOX_MENU_SNOW, BOX_MENU_CAVE },
{ BOX_MENU_BEACH, BOX_MENU_SEAFLOOR, BOX_MENU_RIVER, BOX_MENU_SKY },
{ BOX_MENU_POKECENTER, BOX_MENU_MACHINE, BOX_MENU_CHECKS, BOX_MENU_SIMPLE },
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:

Suggested change
static const u16 v0[][4] = {
{ BOX_MENU_FOREST, BOX_MENU_CITY, BOX_MENU_DESERT, BOX_MENU_SAVANNA },
{ BOX_MENU_CRAG, BOX_MENU_VOLCANO, BOX_MENU_SNOW, BOX_MENU_CAVE },
{ BOX_MENU_BEACH, BOX_MENU_SEAFLOOR, BOX_MENU_RIVER, BOX_MENU_SKY },
{ BOX_MENU_POKECENTER, BOX_MENU_MACHINE, BOX_MENU_CHECKS, BOX_MENU_SIMPLE },
};
static const u16 sWallpaperPages[][4] = {
{ BOX_MENU_FOREST, BOX_MENU_CITY, BOX_MENU_DESERT, BOX_MENU_SAVANNA },
{ BOX_MENU_CRAG, BOX_MENU_VOLCANO, BOX_MENU_SNOW, BOX_MENU_CAVE },
{ BOX_MENU_BEACH, BOX_MENU_SEAFLOOR, BOX_MENU_RIVER, BOX_MENU_SKY },
{ BOX_MENU_POKECENTER, BOX_MENU_MACHINE, BOX_MENU_CHECKS, BOX_MENU_SIMPLE },
};

I also see a few raw 4s here that seem to be related to the number of items on a given page, so I think that's worth a shared constant.

@lhearachel lhearachel self-assigned this Jun 1, 2025
Copy link
Collaborator

@lhearachel lhearachel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some additional preliminary feedback.

@@ -0,0 +1,91 @@
#ifndef POKEPLATINUM_STRUCT_OV19_021DF964_H
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polish: Update include guards on documented files.

void ov19_021D6594(UnkStruct_ov19_021D61B0 *param0, u32 param1);
BOOL ov19_021D6600(UnkStruct_ov19_021D61B0 *param0, u32 param1);
BOOL ov19_021D6628(UnkStruct_ov19_021D61B0 *param0);
enum BoxFunctions {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Do all of these relate to graphics?

I also wouldn't mind these just being the function name prefixed with a tight abbreviation like FN.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't confirmed in-depth every one of these functions, but I think it's safe to say that yes, these are probably all going to be box graphics functions.

void (*boxApplicationAction)(struct UnkStruct_ov19_021D5DF8_t *param0, u32 *param1);
u32 cursorLocationHandlerState;
u32 boxApplicationActionState;
enum BoxMenuItem menuItem; // This stops being a BoxMenuItem in ov19_ReleaseMon, where it does something completely different and unrelated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Given the comment here, maybe it's best to use an anonymous union for this field.

union {
    enum BoxMenuItem menuItem;
    int unk_1B8;
};

Then, you can replace the uses in ov19_ReleaseMon, which makes it apparent that the usage is unknown.

u32 unk_04;
} v0[] = {
} functions[] = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:

  1. Pull this static table into module-level scope and prefix the name with s (e.g., sBoxTaskHandlers).
  2. Use array-initializers so that the association with the parent enum is clear at-a-glance.

@CharlesFolz4 CharlesFolz4 force-pushed the BoxUserInput branch 2 times, most recently from c5157d8 to 567d82c Compare June 11, 2025 03:49
@CharlesFolz4 CharlesFolz4 marked this pull request as ready for review June 15, 2025 22:08
@CharlesFolz4
Copy link
Contributor Author

Declaring this ready for review now. I have cut out the non-trivial compare mode user input handling and touch screen user input handling, because properly documenting those would have involved more scope creep than I was prepared to deal with in the current PR.

@CharlesFolz4 CharlesFolz4 changed the title WIP document box user input handling Document box user input handling Jun 15, 2025
Copy link
Collaborator

@lhearachel lhearachel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; one polish-comment below. 😁

@lhearachel lhearachel merged commit 8bbd22e into pret:main Jun 22, 2025
2 checks passed
github-actions bot pushed a commit that referenced this pull request Jun 22, 2025
@CharlesFolz4 CharlesFolz4 deleted the BoxUserInput branch June 22, 2025 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants