Skip to content

Conversation

@BenHetherington
Copy link

This makes the ‘Control Stick: Select’, ‘B: Cancel’, and ‘A: Confirm’ descriptions appear while in the game selection menu, while still keeping just ‘B: Cancel’ when on the ‘Press Start’ screen.

To do this, this patches the function that updates the button descriptions, replacing two jump table entries, allowing our own code to be run (and determine which descriptions to display) while within the gameplay menu.

Note that I've only been able to test on PAL 1.0, so please do test on other versions before merging! Cc: @trevor403

This makes the ‘Control Stick: Select’, ‘B: Cancel’, and ‘A: Confirm’ descriptions appear while in the game selection menu, while still keeping just ‘B: Cancel’ when on the ‘Press Start’ screen.

To do this, this patches the function that updates the button descriptions, replacing two jump table entries, allowing our own code to be run (and determine which descriptions to display) while within the gameplay menu.
Compared to just using `asm()` in the .c file, this seems a bit more readable to me, and allows the assembly code to use the `r3` alias in `asm.h`.
update_element_alpha(&all_element_alphas->text.three_columns.centre_finish, true);

// Show 'B: Cancel' on both the loader and start screens
update_element_alpha(&all_element_alphas->text.three_columns.centre_cancel, false);
Copy link
Author

Choose a reason for hiding this comment

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

Oh, one difference from the original is that even 'B: Cancel' was conditional on something there, but I wasn't able to work out what that something was. I haven't replicated that condition here, but it could be worth double-checking if we should.

Copy link
Author

Choose a reason for hiding this comment

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

I think I later found that this hid itself if the 'an error has occurred' message is displayed. I don't think I'll lose much sleep if we just don't replicate that 😛

Rather than patching jump tables to point to unrelated addresses, and then having to jump back to the original code, this just replaces the code at the original jump target instead.
Based on the element alpha code for the disc/FlippyDrive selection UI, this:
- Wraps `update_button_alphas()` - for now just calling the original function
- Moves element alpha structs and functions to its own file
- Updates the `element_alpha_state_t`, to name more members
- Updates `update_element_alpha` to take a `element_alpha_update_state_t` enum, rather than the `bool` that was there before (as this function also supports a ‘dimmed’ state)
This replaces the patches-within-a-jump-table with straightforward C calls in the `patch_update_button_alphas()`. Either we run the original code, or we call our custom update functions.
The standard `update_button_alphas` has some additional code on PAL systems to update the button alphas for the different languages.

This reimplements this behaviour when using custom button description updates.
@BenHetherington
Copy link
Author

While looking at re-adding disc drive support (and UI for switching between the disc/FlippyDrive), I ended up touching a fair bit of related code. So, I've updated this review to include those updates.

Additionally, I've simplified how this works by wrapping the entire function, rather than patching specific parts of jump tables in the original assembly 🙂

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.

1 participant