rgbds
rgbds copied to clipboard
[Feature request] Enums
Macro Assembler AS has enums, similar to the ones implemented by pret's const
macros. They define a series of numeric constants with a configurable starting value and increment value.
; rgbasm
foo equ 1
bar equ 3
baz equ 5
; AS
enumconf 2
enum foo = 1
enum bar
enum baz
; pret
const_def 1, 2
const foo
const bar
const baz
Why not _RS
?
rsreset
foo rb
bar rb
baz rb
RS
is meant for defining relative offset constants, e.g. for structs. Apart from the name "rb
" being less appropriate for defining general-purpose constants, it's also that RS
has features irrelevant to enums, and vice-versa.
If you're defining a series of enum constants using rb
, then the feature allows you to use rb 2
, rw
, rs 12
, which don't make sense in that context. Plus, RS
constants have no ability to change the increment value, which can be useful for enums. Compare:
enumconf 1, 2
enum foo
enum bar
enum baz
with:
rsset 1
foo rb 2
bar rb 2
baz rb 2
Or:
enumconf $FF, -1
enum ENTER_MAP_MUSIC
enum RESTART_MAP_MUSIC
enum SPECIAL_MUSIC
with:
rsset $FF - 3 + 1
SPECIAL_MUSIC rb
RESTART_MAP_MUSIC rb
ENTER_MAP_MUSIC rb
pret has its const
macros for this purpose, which do not use rsset
internally; we're planning to use rsset
for its stated purpose of defining struct offsets (currently we have no consistent approach for those), but not for constants in general. Aevilia-GB also has enum
macros. LADX so far defines all its constants as explicit EQU
values even when they're in a series, but it's still in progress, maybe they'll simplify it.
Aevilia uses macros because I mimicked pokered, but my more recent (not yet published) works use _RS
.
Fair enough, but I would be surprised to see something like:
rsset 1
BULBASAUR rb
IVYSAUR rb
VENUSAUR rb
...