map_attributes: MACRO
;\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
\1_MapAttributes::
	db \3
	db CURRENT_MAP_HEIGHT, CURRENT_MAP_WIDTH
	db BANK(\1_Blocks)
	dw \1_Blocks
	db BANK(\1_MapScripts) ; BANK(\1_MapEvents)
	dw \1_MapScripts
	dw \1_MapEvents
	db \4
ENDM

; Connections go in order: north, south, west, east
connection: MACRO
;\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
; Calculate tile offsets for source (current) and target maps
_src = 0
_tgt = (\4) + 3
if _tgt < 0
_src = -_tgt
_tgt = 0
endc
if "\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 "\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 "\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 "\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 + _blk
        dw wOverworldMapBlocks + _map
        db _len - _src
        db \3_WIDTH
        db _y, _x
        dw wOverworldMapBlocks + _win
endc
ENDM


; dakos
	map_attributes SkidrawCamp, SKIDRAW_CAMP, $03, EAST
		connection east, Route1, ROUTE_1, 4

	map_attributes SkidrawChiefHouse, SKIDRAW_CHIEF_HOUSE, $00, 0
	map_attributes HikersHouse, HIKERS_HOUSE, $00, 0
	map_attributes MickeysHouse, MICKEYS_HOUSE, $00, 0
	map_attributes MickeysCave, MICKEYS_CAVE, $00, 0

	map_attributes Route1, ROUTE_1, $05, SOUTH | WEST | EAST
		connection south, Route3, ROUTE_3, 0
		connection west, SkidrawCamp, SKIDRAW_CAMP, -4
		connection east, Route2, ROUTE_2, 10

	map_attributes Route2, ROUTE_2, $05, WEST
		connection west, Route1, ROUTE_1, -10

	map_attributes Route3, ROUTE_3, $05, NORTH | SOUTH
		connection north, Route1, ROUTE_1, 0, 0, 9
		connection south, DawnTownCamp, DAWN_TOWN_CAMP, -1

	map_attributes BlackPondGate, BLACK_POND_GATE, $00, 0
	map_attributes BlackPondCreek, BLACK_POND_CREEK, $05, EAST
		connection east, Route6, ROUTE_6, 1
	map_attributes BlackPondNursery, BLACK_POND_NURSERY, $00, 0
	map_attributes BlackPondShop, BLACK_POND_SHOP, $00, 0
	map_attributes BlackPondContainer, BLACK_POND_CONTAINER, $00, 0
	map_attributes BlackPondFisherHouse, BLACK_POND_FISHER_HOUSE, $00, 0

	map_attributes Route6, ROUTE_6, $71, NORTH | WEST
		connection north, SparkleRanch, SPARKLE_RANCH, 11
		connection west, BlackPondCreek, BLACK_POND_CREEK, -1

	map_attributes SparkleRanch, SPARKLE_RANCH, $71, SOUTH
		connection south, Route6, ROUTE_6, -11

	map_attributes SparkleRanchHouse, SPARKLE_RANCH_HOUSE, $00, 0
	map_attributes MountainTunnel, MOUNTAIN_TUNNEL, $09, 0
	map_attributes MountainPasture, MOUNTAIN_PASTURE, $19, 0

	map_attributes MountainGate1, MOUNTAIN_GATE1, $09, 0
	map_attributes MountainGate2, MOUNTAIN_GATE2, $09, 0
	map_attributes MountainGate3, MOUNTAIN_GATE2, $09, 0
	map_attributes MountainCave0F, MOUNTAIN_CAVE_0F, $09, 0
	map_attributes MountainCave1F, MOUNTAIN_CAVE_1F, $09, 0
	map_attributes MountainCave2F, MOUNTAIN_CAVE_2F, $09, 0

	map_attributes DawnTownForest, DAWN_TOWN_FOREST, $05, 0

	map_attributes DawnTownCamp, DAWN_TOWN_CAMP, $05, NORTH | EAST
		connection north, Route3, ROUTE_3, 1
		connection east, DawnTown, DAWN_TOWN, 3

	map_attributes DawnTownCampShop, DAWN_TOWN_CAMP_SHOP, $00, 0

	map_attributes DawnTown, DAWN_TOWN, $05, WEST | EAST
		connection west, DawnTownCamp, DAWN_TOWN_CAMP, -3
		connection east, DawnTownGraveyard, DAWN_TOWN_GRAVEYARD, 0

	map_attributes DawnTownGraveyard, DAWN_TOWN_GRAVEYARD, $05, WEST
		connection west, DawnTown, DAWN_TOWN, 0

	map_attributes DawnTownLumberjackHouse, DAWN_TOWN_LUMBERJACK_HOUSE, $00, 0
	map_attributes DawnTownGroundkeeperHouse, DAWN_TOWN_GROUNDKEEPER_HOUSE, $00, 0
	map_attributes DawnTownShop, DAWN_TOWN_SHOP, $00, 0
	map_attributes DawnTownChiefHouse, DAWN_TOWN_CHIEF_HOUSE, $00, 0
	map_attributes DawnTownPokecenter, DAWN_TOWN_POKECENTER, $00, 0
	map_attributes DawnTownGym, DAWN_TOWN_GYM, $00, 0
	map_attributes DawnTownGymB1F, DAWN_TOWN_GYM_B1F, $00, 0
	map_attributes DawnTownCaveGate, DAWN_TOWN_CAVE_GATE, $09, 0
	map_attributes DawnTownCave0F, DAWN_TOWN_CAVE_0F, $09, 0
	map_attributes DawnTownCave1F, DAWN_TOWN_CAVE_1F, $09, 0
	map_attributes DawnTownCaveRoom, DAWN_TOWN_CAVE_ROOM, $00, 0
	map_attributes DawnTownGate, DAWN_TOWN_GATE, $00, 0

	map_attributes Route4, ROUTE_4, $05, SOUTH | WEST
		connection south, Route5, ROUTE_5, 8
		connection west, DawnTown, DAWN_TOWN, -9

	map_attributes Route5, ROUTE_5, $05, NORTH
		connection north, Route4, ROUTE_4, -8

; vaast
	map_attributes CampingCampfire, CAMPING_CAMPFIRE, $00, 0
	map_attributes CampingPeebush, CAMPING_PEEBUSH, $00, 0
