diff options
author | Rangi <remy.oukaour+rangi@gmail.com> | 2020-09-22 11:40:17 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi@gmail.com> | 2020-09-22 11:40:17 -0400 |
commit | 34cbb1a9d43856e9f114f7a79e596cb56aa7e1ed (patch) | |
tree | 3a1ba707a9bdaedc65e7fcbeed3092b30fe29fc9 /macros | |
parent | 9b03aac9fe359af82e132418942ba9317e8eae75 (diff) |
Port the improved connection macro from pokegold/pokecrystal
Diffstat (limited to 'macros')
-rw-r--r-- | macros/maps.asm | 106 |
1 files changed, 69 insertions, 37 deletions
diff --git a/macros/maps.asm b/macros/maps.asm index 8ecc24f..135b8a3 100644 --- a/macros/maps.asm +++ b/macros/maps.asm @@ -23,45 +23,77 @@ connection: MACRO ;\1: direction ;\2: map name ;\3: map id -;\4: final y offset for east/west, x offset for north/south -;\5: map data y offset for east/west, x offset for north/south -;\6: strip length -if "\1" == "north" - map_id \3 - dw \2_Blocks + \3_WIDTH * (\3_HEIGHT - 3) + \5 - dw wOverworldMapBlocks + \4 + 3 - db \6 - db \3_WIDTH - db \3_HEIGHT * 2 - 1 - db (\4 - \5) * -2 - dw wOverworldMapBlocks + \3_HEIGHT * (\3_WIDTH + 6) + 1 -elif "\1" == "south" - map_id \3 - dw \2_Blocks + \5 - dw wOverworldMapBlocks + (CURRENT_MAP_HEIGHT + 3) * (CURRENT_MAP_WIDTH + 6) + \4 + 3 - db \6 - db \3_WIDTH - db 0 - db (\4 - \5) * -2 - dw wOverworldMapBlocks + \3_WIDTH + 7 -elif "\1" == "west" - map_id \3 - dw \2_Blocks + (\3_WIDTH * \5) + \3_WIDTH - 3 - dw wOverworldMapBlocks + (CURRENT_MAP_WIDTH + 6) * (\4 + 3) - db \6 - db \3_WIDTH - db (\4 - \5) * -2 - db \3_WIDTH * 2 - 1 - dw wOverworldMapBlocks + \3_WIDTH * 2 + 6 -elif "\1" == "east" +;\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 + +; Calculate tile offsets for source (current) and target maps +_src = 0 +_tgt = (\4) + 3 +if _tgt < 0 +_src = -_tgt +_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 + +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", "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", "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 - dw \2_Blocks + (\3_WIDTH * \5) - dw wOverworldMapBlocks + (CURRENT_MAP_WIDTH + 6) * (\4 + 3 + 1) - 3 - db \6 + dw \2_Blocks + _blk + dw wOverworldMapBlocks + _map + db _len - _src db \3_WIDTH - db (\4 - \5) * -2 - db 0 - dw wOverworldMapBlocks + \3_WIDTH + 7 + db _y, _x + dw wOverworldMapBlocks + _win endc ENDM |