-
Notifications
You must be signed in to change notification settings - Fork 817
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
Use RS commands to define struct offset constants #739
Comments
A more drastic proposal would be to replace other For instance, this:
could become this:
Since
This would make constant series definitions more similar to our groups of non-sequential I don't personally think it's worth breaking the long convention of |
Since we sometimes define a |
Big +1 on using rsset for structures but I think it hinders readability vs Can we talk for a hot second about how dumb the |
Yeah, they are redundant. And if |
Related: if
would be more natural as this:
|
I'll be happy to see structures defined using As for |
While we're planning to refactor the
This would be useful for constant sequences with large gaps. It avoids needing a bunch of unused placeholder values, but also ties the whole series together under a single For example, the Also, in constants/event_constants.asm, there are four runs of unused constants: |
|
How about |
Another |
Also, the |
|
Was checking this out through email updates and I personally like Shucks. Looks like you guys already decided. I’ll just leave this here I guess. |
The |
Something else to consider for refactoring structs: using local labels for their members. So |
This seems disruptive for little benefit... while dot notation might be familiar for a class of users, this is something that is very quickly learned, and changing it will break compatibility with every repository using the current format. |
This was discussed in pret#739
This was discussed in pret#739
This was discussed in pret#739
We're currently not using this feature of rgbds. It's similar to our current
const
andenum
macros, with the counter_RS
instead ofconst_value
or__enum__
.rsreset
sets_RS = 0
rsset N
sets_RS = N
FOO rb N
setsFOO = _RS
and does_RS += N
FOO rw N
setsFOO = _RS
and does_RS += N * 2
Their intended use is for defining struct offsets. We have no consistent pattern for those:
const_def
: the most common; e.g.ITEMATTR_*
in constants/item_data_constants.asmEQU
s: easier to have non-sequential values; e.g.NPCTRADE_*
in constants/npc_trade_constants.asmBASE_*
in constants/pokemon_data_constants.asm@ISSOtm also points out that using the rs commands is faster to build than using
const
orenum
macros.I think that at least the
const_def
andEQU
s patterns could be replaced by usage of_RS
, and possibly the label offsets as well.The above examples rewritten:
I don't think the base data case is actually an improvement; there's exactly one base data struct in WRAM, so defining constants based on its labels is convenient and avoids repetition. For the other two cases, I think the rs commands have advantages. Their definitions parallel the data definitions in macros like
item_attribute
andnpctrade
, and it indicates that this particular set of constants is meant as offsets to a struct.The text was updated successfully, but these errors were encountered: