You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's an example. engine/events/mom_phone.asm defines DEF NUM_MOM_ITEMS_1 EQUS "((MomItems_1.End - MomItems_1) / 8)" and DEF NUM_MOM_ITEMS_2 EQUS "((MomItems_2.End - MomItems_2) / 8)". NUM_MOM_ITEMS_1 is only used once, in ld a, NUM_MOM_ITEMS_1. NUM_MOM_ITEMS_2 is used in two cp NUM_MOM_ITEMS_2. Neither of those EQUS definitions should exist -- just do ld a, (MomItems_1.End - MomItems_1) / 8 and cp (MomItems_2.End - MomItems_2) / 8.
This goes for EQUS more generally. The way the auto-expand is a misfeature of the assembly language, and we should avoid it when alternatives are possible. For example, DEF text EQUS "db TX_START," should really be MACRO textdb TX_START, \#ENDM -- although it's two lines longer, it's more flexible (you could add checks inside for mistakes like text after line) and more future-proof (rgbasm eventually wants to remove EQUS expansion).
(The big exception is things like DEF tiles EQUS "* LEN_2BPP_TILE" so you can do ld bc, (7 * 7) tiles. Eventually rgbasm will have user-defined functions and we can replace it with DEF tiles(n) := n * LEN_2BPP_TILE to do ld bc, tiles(7 * 7)... but until then, the EQUS is okay.)
The text was updated successfully, but these errors were encountered:
Here's an example. engine/events/mom_phone.asm defines
DEF NUM_MOM_ITEMS_1 EQUS "((MomItems_1.End - MomItems_1) / 8)"
andDEF NUM_MOM_ITEMS_2 EQUS "((MomItems_2.End - MomItems_2) / 8)"
.NUM_MOM_ITEMS_1
is only used once, inld a, NUM_MOM_ITEMS_1
.NUM_MOM_ITEMS_2
is used in twocp NUM_MOM_ITEMS_2
. Neither of thoseEQUS
definitions should exist -- just dold a, (MomItems_1.End - MomItems_1) / 8
andcp (MomItems_2.End - MomItems_2) / 8
.This goes for
EQUS
more generally. The way the auto-expand is a misfeature of the assembly language, and we should avoid it when alternatives are possible. For example,DEF text EQUS "db TX_START,"
should really beMACRO text
db TX_START, \#
ENDM
-- although it's two lines longer, it's more flexible (you could add checks inside for mistakes liketext
afterline
) and more future-proof (rgbasm eventually wants to removeEQUS
expansion).(The big exception is things like
DEF tiles EQUS "* LEN_2BPP_TILE"
so you can dold bc, (7 * 7) tiles
. Eventually rgbasm will have user-defined functions and we can replace it withDEF tiles(n) := n * LEN_2BPP_TILE
to dold bc, tiles(7 * 7)
... but until then, theEQUS
is okay.)The text was updated successfully, but these errors were encountered: