Skip to content

Conversation

@Rangi42
Copy link
Member

@Rangi42 Rangi42 commented Dec 30, 2025

This renames "missable objects" aka "hide/show objects" to "toggleable objects" which can be on or off. We want to avoid the word "hidden" because there are also "hidden objects" (named that way due to Itemfinder items and hidden Coins, but also used for Gym statues, Pokémon Center PCs, Pokémon Center bench guys, and other such scripts which weren't implemented as bg_events). (Those would be more appropriately named "hidden events", but that can be a separate PR.)

@Rangi42 Rangi42 requested review from dannye and vulcandth December 30, 2025 03:15
@Rangi42 Rangi42 force-pushed the hide-show branch 2 times, most recently from 879ce5f to 62f37bf Compare December 30, 2025 03:40
@Rangi42
Copy link
Member Author

Rangi42 commented Dec 30, 2025

(I believe that a common mistake with hide/show customization is just adding a new constant and data entry but not in the right place, i.e. at the end of the whole list instead of at the end of its appropriate map. So just chunking everything by map ID should help with that.)

@Rangi42 Rangi42 marked this pull request as ready for review January 1, 2026 04:35
@Rangi42 Rangi42 changed the title Use macros to enforce more hide/show data constraints Use macros to enforce "missable/hide/show object" constraints, and rename them to "toggleable objects" Jan 1, 2026
@Rangi42
Copy link
Member Author

Rangi42 commented Jan 1, 2026

I kept the function names HideObject and ShowObject because they're the same as the Gen 2 script commands hide_object and show_object.

DEF TOGGLEMAP{\1} EQU const_value
ENDM

; ToggleableObjects indexes (see data/maps/toggle_data.asm)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
; ToggleableObjects indexes (see data/maps/toggle_data.asm)
; ToggleableObjectState indexes (see data/maps/toggleable_objects.asm)

ld l, a
push hl
ld de, MissableObjects ; calculate difference between out pointer and the base pointer
ld de, ToggleableObjectState ; calculate difference between out pointer and the base pointer
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ld de, ToggleableObjectState ; calculate difference between out pointer and the base pointer
ld de, ToggleableObjectState ; calculate difference between our pointer and the base pointer

It's not even a great comment, but might as well fix the typo.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. And ToggleableObjectState should be plural ToggleableObjectStates (or arguably ToggleableObjectsState?) anyway.

DEF toggles_ok &= DEF(TOGGLEMAP{toggle_map_id})
IF toggles_ok
assert_table_length TOGGLEMAP{toggle_map_id}
DEF toggles_ok &= TOGGLEMAP{toggle_map_id} * 3 == @ - ToggleableObjectState
Copy link
Member

Choose a reason for hiding this comment

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

Kind of a bummer to repeat the assert_table_length logic and make this macro more complicated/nested, but it appears to be necessary to avoid distracting/unhelpful error messages since assembly does not abort after the first assertion failure, so oh well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. I considered feature-requesting RGBDS to have something like C's errno but for the previous ASSERT result; or else to refactor assert_table_length to store its result in some variable that anything can use; but both seemed excessive for handling this one case.

Yet another alternative would be to allow two-arg assert_table_length fatal, TOGGLEMAP{toggle_map_id} to do ASSERT FATAL, but that would also be unusual: most of our asserting macros don't immediately halt assembly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants