Adapt macro based on suggestions

This commit is contained in:
mid-kid 2018-11-11 00:32:05 +01:00
parent 375963349a
commit 814a720e9d

View File

@ -21,73 +21,77 @@ connection: MACRO
;\1: direction ;\1: direction
;\2: map name ;\2: map name
;\3: map id ;\3: map id
;\4: x offset for east/west, y offset for north/south, of the target map ;\4: offset of the target map relative to the current map
; relative to the current map. ; (x offset for east/west, y offset for north/south)
; Figure out target and source offsets ; LEGACY: Support for old connection macro
; Target meaning the offset where the tiles will be placed if _NARG == 6
; Source meaning the offset where the tiles are fetched from connection \1, \2, \3, (\4) - (\5)
_s = 0
_t = (\4) + 3
if _t < 0
_s = -_t
_t = 0
endc
; Figure out whether we're using the width or the height as maximum size
_st = 0
_ss = 0
if ("\1" == "north") || ("\1" == "south")
_st = \3_WIDTH
_ss = CURRENT_MAP_WIDTH
elif ("\1" == "west") || ("\1" == "east")
_st = \3_HEIGHT
_ss = CURRENT_MAP_HEIGHT
endc
; Figure out the length of the strip to connect
if ((\4) + _st) > (_ss + 3)
_l = _ss + 3 - (\4) - _s
else else
_l = _st - _s
; Calculate tile offsets for source (current) and target maps
_src = 0
_tgt = (\4) + 3
if _tgt < 0
_src = -_tgt
_tgt = 0
endc endc
if "\1" == "north" if "\1" == "north"
map_id \3 _blk = \3_WIDTH * (\3_HEIGHT + -3) + _src
dw \2_Blocks + \3_WIDTH * (\3_HEIGHT + -3) + _s _map = _tgt
dw wOverworldMapBlocks + _t _win = (\3_WIDTH + 6) * \3_HEIGHT + 1
db _l _y = \3_HEIGHT * 2 - 1
db \3_WIDTH _x = (\4) * -2
db \3_HEIGHT * 2 - 1 _len = CURRENT_MAP_WIDTH + 3 - (\4)
db (\4) * -2 if _len > \3_WIDTH
dw wOverworldMapBlocks + (\3_WIDTH + 6) * \3_HEIGHT + 1 _len = \3_WIDTH
endc
elif "\1" == "south" elif "\1" == "south"
map_id \3 _blk = _src
dw \2_Blocks + _s _map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt
dw wOverworldMapBlocks + (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _t _win = \3_WIDTH + 7
db _l _y = 0
db \3_WIDTH _x = (\4) * -2
db 0 _len = CURRENT_MAP_WIDTH + 3 - (\4)
db (\4) * -2 if _len > \3_WIDTH
dw wOverworldMapBlocks + \3_WIDTH + 7 _len = \3_WIDTH
endc
elif "\1" == "west" elif "\1" == "west"
map_id \3 _blk = (\3_WIDTH * _src) + \3_WIDTH + -3
dw \2_Blocks + (\3_WIDTH * _s) + \3_WIDTH + -3 _map = (CURRENT_MAP_WIDTH + 6) * _tgt
dw wOverworldMapBlocks + (CURRENT_MAP_WIDTH + 6) * _t _win = (\3_WIDTH + 6) * 2 + -6
db _l _y = (\4) * -2
db \3_WIDTH _x = \3_WIDTH * 2 - 1
db (\4) * -2 _len = CURRENT_MAP_HEIGHT + 3 - (\4)
db \3_WIDTH * 2 - 1 if _len > \3_HEIGHT
dw wOverworldMapBlocks + (\3_WIDTH + 6) * 2 + -6 _len = \3_HEIGHT
endc
elif "\1" == "east" elif "\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
else
fail "Invalid direction for 'connection'."
endc
map_id \3 map_id \3
dw \2_Blocks + (\3_WIDTH * _s) dw \2_Blocks + _blk
dw wOverworldMapBlocks + (CURRENT_MAP_WIDTH + 6) * _t + CURRENT_MAP_WIDTH + 3 dw wOverworldMapBlocks + _map
db _l db _len - _src
db \3_WIDTH db \3_WIDTH
db (\4) * -2 db _y, _x
db 0 dw wOverworldMapBlocks + _win
dw wOverworldMapBlocks + \3_WIDTH + 7
endc endc
ENDM ENDM