RGBDS syntax updates (#905)

New MACRO and DEF syntax
This commit is contained in:
vulcandth
2022-06-06 16:25:42 -05:00
committed by GitHub
parent a4d346cc8c
commit 3648afda16
179 changed files with 2546 additions and 2545 deletions

View File

@@ -1,10 +1,10 @@
map_attributes: MACRO
MACRO map_attributes
;\1: map name
;\2: map id
;\3: border block
;\4: connections: combo of NORTH, SOUTH, WEST, and/or EAST, or 0 for none
CURRENT_MAP_WIDTH = \2_WIDTH
CURRENT_MAP_HEIGHT = \2_HEIGHT
DEF CURRENT_MAP_WIDTH = \2_WIDTH
DEF CURRENT_MAP_HEIGHT = \2_HEIGHT
\1_MapAttributes::
db \3
db CURRENT_MAP_HEIGHT, CURRENT_MAP_WIDTH
@@ -17,73 +17,73 @@ CURRENT_MAP_HEIGHT = \2_HEIGHT
ENDM
; Connections go in order: north, south, west, east
connection: MACRO
MACRO connection
;\1: direction
;\2: map name
;\3: map id
;\4: offset of the target map relative to the current map
; (x offset for east/west, y offset for north/south)
; LEGACY: Support for old connection macro
if _NARG == 6
connection \1, \2, \3, (\4) - (\5)
else
; LEGACY: Support for old connection macro
if _NARG == 6
connection \1, \2, \3, (\4) - (\5)
else
; Calculate tile offsets for source (current) and target maps
_src = 0
_tgt = (\4) + 3
if _tgt < 0
_src = -_tgt
_tgt = 0
endc
; Calculate tile offsets for source (current) and target maps
DEF _src = 0
DEF _tgt = (\4) + 3
if _tgt < 0
DEF _src = -_tgt
DEF _tgt = 0
endc
if !STRCMP("\1", "north")
_blk = \3_WIDTH * (\3_HEIGHT - 3) + _src
_map = _tgt
_win = (\3_WIDTH + 6) * \3_HEIGHT + 1
_y = \3_HEIGHT * 2 - 1
_x = (\4) * -2
_len = CURRENT_MAP_WIDTH + 3 - (\4)
if _len > \3_WIDTH
_len = \3_WIDTH
endc
if !STRCMP("\1", "north")
DEF _blk = \3_WIDTH * (\3_HEIGHT - 3) + _src
DEF _map = _tgt
DEF _win = (\3_WIDTH + 6) * \3_HEIGHT + 1
DEF _y = \3_HEIGHT * 2 - 1
DEF _x = (\4) * -2
DEF _len = CURRENT_MAP_WIDTH + 3 - (\4)
if _len > \3_WIDTH
DEF _len = \3_WIDTH
endc
elif !STRCMP("\1", "south")
_blk = _src
_map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt
_win = \3_WIDTH + 7
_y = 0
_x = (\4) * -2
_len = CURRENT_MAP_WIDTH + 3 - (\4)
if _len > \3_WIDTH
_len = \3_WIDTH
endc
elif !STRCMP("\1", "south")
DEF _blk = _src
DEF _map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt
DEF _win = \3_WIDTH + 7
DEF _y = 0
DEF _x = (\4) * -2
DEF _len = CURRENT_MAP_WIDTH + 3 - (\4)
if _len > \3_WIDTH
DEF _len = \3_WIDTH
endc
elif !STRCMP("\1", "west")
_blk = (\3_WIDTH * _src) + \3_WIDTH - 3
_map = (CURRENT_MAP_WIDTH + 6) * _tgt
_win = (\3_WIDTH + 6) * 2 - 6
_y = (\4) * -2
_x = \3_WIDTH * 2 - 1
_len = CURRENT_MAP_HEIGHT + 3 - (\4)
if _len > \3_HEIGHT
_len = \3_HEIGHT
endc
elif !STRCMP("\1", "west")
DEF _blk = (\3_WIDTH * _src) + \3_WIDTH - 3
DEF _map = (CURRENT_MAP_WIDTH + 6) * _tgt
DEF _win = (\3_WIDTH + 6) * 2 - 6
DEF _y = (\4) * -2
DEF _x = \3_WIDTH * 2 - 1
DEF _len = CURRENT_MAP_HEIGHT + 3 - (\4)
if _len > \3_HEIGHT
DEF _len = \3_HEIGHT
endc
elif !STRCMP("\1", "east")
_blk = (\3_WIDTH * _src)
_map = (CURRENT_MAP_WIDTH + 6) * _tgt + CURRENT_MAP_WIDTH + 3
_win = \3_WIDTH + 7
_y = (\4) * -2
_x = 0
_len = CURRENT_MAP_HEIGHT + 3 - (\4)
if _len > \3_HEIGHT
_len = \3_HEIGHT
endc
elif !STRCMP("\1", "east")
DEF _blk = (\3_WIDTH * _src)
DEF _map = (CURRENT_MAP_WIDTH + 6) * _tgt + CURRENT_MAP_WIDTH + 3
DEF _win = \3_WIDTH + 7
DEF _y = (\4) * -2
DEF _x = 0
DEF _len = CURRENT_MAP_HEIGHT + 3 - (\4)
if _len > \3_HEIGHT
DEF _len = \3_HEIGHT
endc
else
fail "Invalid direction for 'connection'."
endc
else
fail "Invalid direction for 'connection'."
endc
map_id \3
dw \2_Blocks + _blk
@@ -92,7 +92,8 @@ endc
db \3_WIDTH
db _y, _x
dw wOverworldMapBlocks + _win
endc
endc
ENDM

View File

@@ -1,4 +1,4 @@
landmark: MACRO
MACRO landmark
; x, y, name
db \1 + 8, \2 + 16
dw \3

View File

@@ -1,4 +1,4 @@
map: MACRO
MACRO map
;\1: map name: for the MapAttributes pointer (see data/maps/attributes.asm)
;\2: tileset: a TILESET_* constant
;\3: environment: TOWN, ROUTE, INDOOR, CAVE, ENVIRONMENT_5, GATE, or DUNGEON

View File

@@ -5,7 +5,7 @@
const ROOF_AZALEA ; 2
const ROOF_OLIVINE ; 3
const ROOF_GOLDENROD ; 4
NUM_ROOFS EQU const_value
DEF NUM_ROOFS EQU const_value
MapGroupRoofs:
; entries correspond to MAPGROUP_* constants

View File

@@ -1,4 +1,4 @@
scene_var: MACRO
MACRO scene_var
; map, variable
map_id \1
dw \2

View File

@@ -1,4 +1,4 @@
add_mapsetup: MACRO
MACRO add_mapsetup
\1_MapSetupCmd:
dba \1
ENDM

View File

@@ -16,7 +16,7 @@ MapSetupScripts:
assert_table_length NUM_MAPSETUP_SCRIPTS
; valid commands are listed in MapSetupCommands (see data/maps/setup_script_pointers.asm)
mapsetup: MACRO
MACRO mapsetup
db (\1_MapSetupCmd - MapSetupCommands) / 3
ENDM

View File

@@ -1,4 +1,4 @@
spawn: MACRO
MACRO spawn
; map, x, y
map_id \1
db \2, \3