-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Use macros to enforce "missable/hide/show object" constraints, and rename them to "toggleable objects" #557
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
base: master
Are you sure you want to change the base?
Conversation
879ce5f to
62f37bf
Compare
|
(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.) |
|
I kept the function names |
| DEF TOGGLEMAP{\1} EQU const_value | ||
| ENDM | ||
|
|
||
| ; ToggleableObjects indexes (see data/maps/toggle_data.asm) |
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.
| ; 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 |
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.
| 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.
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.
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 |
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.
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.
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.
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.
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.)