Use rgbds 0.5.0 features:

- FOR loops
- {interpolation}
- REDEF EQUS
- \# for all macro args
This commit is contained in:
Rangi 2021-04-17 19:06:56 -04:00
parent 4b64b146e4
commit dd690920c9
15 changed files with 90 additions and 163 deletions

View file

@ -184,8 +184,8 @@ ENDM
SetEvents: MACRO
SetEvent \1
REPT _NARG - 1
SetEventReuseHL \2
SHIFT
SetEventReuseHL \2
SHIFT
ENDR
ENDM
@ -236,8 +236,8 @@ ENDM
ResetEvents: MACRO
ResetEvent \1
REPT _NARG - 1
ResetEventReuseHL \2
SHIFT
ResetEventReuseHL \2
SHIFT
ENDR
ENDM

View file

@ -1,10 +1,7 @@
def_objects: MACRO
IF DEF(_NUM_OBJECTS)
PURGE _NUM_OBJECTS
ENDC
_NUM_OBJECTS EQUS "_NUM_OBJECTS_\@"
db _NUM_OBJECTS
_NUM_OBJECTS = 0
REDEF _NUM_OBJECTS EQUS "_NUM_OBJECTS_\@"
db {_NUM_OBJECTS}
{_NUM_OBJECTS} = 0
ENDM
;\1 sprite id
@ -32,16 +29,13 @@ object: MACRO
ELSE
db \6
ENDC
_NUM_OBJECTS = _NUM_OBJECTS + 1
{_NUM_OBJECTS} = {_NUM_OBJECTS} + 1
ENDM
def_warps: MACRO
IF DEF(_NUM_WARPS)
PURGE _NUM_WARPS
ENDC
_NUM_WARPS EQUS "_NUM_WARPS_\@"
db _NUM_WARPS
_NUM_WARPS = 0
REDEF _NUM_WARPS EQUS "_NUM_WARPS_\@"
db {_NUM_WARPS}
{_NUM_WARPS} = 0
ENDM
;\1 x position
@ -50,19 +44,15 @@ ENDM
;\4 destination map (-1 = wLastMap)
warp: MACRO
db \2, \1, \3, \4
_TMP EQUS "\n_WARP_{d:{_NUM_WARPS}}_X = \1\n_WARP_{d:{_NUM_WARPS}}_Y = \2"
_TMP
PURGE _TMP
_NUM_WARPS = _NUM_WARPS + 1
_WARP_{d:{_NUM_WARPS}}_X = \1
_WARP_{d:{_NUM_WARPS}}_Y = \2
{_NUM_WARPS} = {_NUM_WARPS} + 1
ENDM
def_signs: MACRO
IF DEF(_NUM_SIGNS)
PURGE _NUM_SIGNS
ENDC
_NUM_SIGNS EQUS "_NUM_SIGNS_\@"
db _NUM_SIGNS
_NUM_SIGNS = 0
REDEF _NUM_SIGNS EQUS "_NUM_SIGNS_\@"
db {_NUM_SIGNS}
{_NUM_SIGNS} = 0
ENDM
;\1 x position
@ -70,17 +60,13 @@ ENDM
;\3 sign id
sign: MACRO
db \2, \1, \3
_NUM_SIGNS = _NUM_SIGNS + 1
{_NUM_SIGNS} = {_NUM_SIGNS} + 1
ENDM
;\1 source map
def_warps_to: MACRO
N = 0
REPT _NUM_WARPS
_TMP EQUS "warp_to _WARP_{d:N}_X, _WARP_{d:N}_Y, \1_WIDTH"
_TMP
PURGE _TMP
N = N + 1
FOR n, _NUM_WARPS
warp_to _WARP_{d:n}_X, _WARP_{d:n}_Y, \1_WIDTH
ENDR
ENDM
@ -146,10 +132,8 @@ ENDM
; Comes after map_header and connection macros
end_map_header: MACRO
dw CURRENT_MAP_OBJECT
PURGE CURRENT_MAP_WIDTH
PURGE CURRENT_MAP_HEIGHT
PURGE CURRENT_MAP_OBJECT
dw {CURRENT_MAP_OBJECT}
PURGE CURRENT_MAP_WIDTH, CURRENT_MAP_HEIGHT, CURRENT_MAP_OBJECT
ENDM
; Connections go in order: north, south, west, east

View file

@ -169,10 +169,9 @@ ENDM
script_mart: MACRO
db TX_SCRIPT_MART
db _NARG ; number of items
REPT _NARG
db \1 ; item id
SHIFT
ENDR
IF _NARG
db \# ; all item ids
ENDC
db -1 ; end
ENDM