shithub: pokered

Download patch

ref: f0d8e69adcb176e82deb588c6b6e1ba8a12f5123
parent: f8291c9cda3d4be6ba29a61280bd33e89f375e35
author: Bryan Bishop <kanzure@gmail.com>
date: Sun Jan 15 12:20:06 EST 2012

replace connection pointers with formulas

hg-commit-id: 92972d3acaea


--- a/common.asm
+++ b/common.asm
@@ -8187,7 +8187,7 @@
     ; connections data
 
 	db ROUTE_2
-    dw $41C8, $C6F0 ; pointers (connected, current) (strip)
+    dw Route2Blocks + (Route2Height - 3) * Route2Width, $C6F0 ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $47, $f6 ; alignments (y, x)
     dw $c929 ; window
@@ -8199,7 +8199,7 @@
     dw $c6f9 ; window
 
 	db ROUTE_22
-    dw $404e, $c79e ; pointers (connected, current) (strip)
+    dw Route22Blocks - 3 + (Route22Width), $c79e ; pointers (connected, current) (strip)
     db $09, $14 ; bigness, width
     db $f8, $27 ; alignments (y, x)
     dw $c716 ; window
@@ -8254,13 +8254,13 @@
     ; connections data
 
 	db ROUTE_2
-    dw $407e, $c912 ; pointers (connected, current) (strip)
+    dw Route2Blocks, $c912 ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $00, $f6 ; alignments (y, x)
     dw $c6f9 ; window
 
 	db ROUTE_3
-    dw $4255, $c7b5 ; pointers (connected, current) (strip)
+    dw Route3Blocks + (Route3Width * 0), $c7b5 ; pointers (connected, current) (strip)
     db $09, $23 ; bigness, width
     db $f8, $00 ; alignments (y, x)
     dw $c712 ; window
@@ -8320,7 +8320,7 @@
     ; connections data
 
 	db ROUTE_24
-    dw $477d, $c6f0 ; pointers (connected, current) (strip)
+    dw Route24Blocks + (Route24Height - 3) * Route24Width, $c6f0 ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $23, $f6 ; alignments (y, x)
     dw $c809 ; window
@@ -8332,13 +8332,13 @@
     dw $c6f9 ; window
 
 	db ROUTE_4
-    dw $4416, $c79e ; pointers (connected, current) (strip)
+    dw Route4Blocks - 3 + (Route4Width), $c79e ; pointers (connected, current) (strip)
     db $09, $2d ; bigness, width
     db $f8, $59 ; alignments (y, x)
     dw $c748 ; window
 
 	db ROUTE_9
-    dw $46fe, $c7b5 ; pointers (connected, current) (strip)
+    dw Route9Blocks + (Route9Width * 0), $c7b5 ; pointers (connected, current) (strip)
     db $09, $1e ; bigness, width
     db $f8, $00 ; alignments (y, x)
     dw $c70d ; window
@@ -8407,13 +8407,13 @@
     ; connections data
 
 	db ROUTE_6
-    dw $410f, $c6f0 ; pointers (connected, current) (strip)
+    dw Route6Blocks + (Route6Height - 3) * Route6Width, $c6f0 ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $23, $f6 ; alignments (y, x)
     dw $c809 ; window
 
 	db ROUTE_11
-    dw $455f, $c7b5 ; pointers (connected, current) (strip)
+    dw Route11Blocks + (Route11Width * 0), $c7b5 ; pointers (connected, current) (strip)
     db $09, $1e ; bigness, width
     db $f8, $00 ; alignments (y, x)
     dw $c70d ; window
@@ -8482,13 +8482,13 @@
     dw $c6f9 ; window
 
 	db ROUTE_18
-    dw $4cb2, $c79e ; pointers (connected, current) (strip)
+    dw Route18Blocks - 3 + (Route18Width), $c79e ; pointers (connected, current) (strip)
     db $09, $19 ; bigness, width
     db $f8, $31 ; alignments (y, x)
     dw $c720 ; window
 
 	db ROUTE_15
-    dw $49cc, $c7b5 ; pointers (connected, current) (strip)
+    dw Route15Blocks + (Route15Width * 0), $c7b5 ; pointers (connected, current) (strip)
     db $09, $1e ; bigness, width
     db $f8, $00 ; alignments (y, x)
     dw $c70d ; window
@@ -10393,13 +10393,13 @@
     ; connections data
 
 	db ROUTE_21
-    dw $5211, $c6eb ; pointers (connected, current) (strip)
+    dw Route21Blocks + (Route21Height - 3) * Route21Width, $c6eb ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $59, $00 ; alignments (y, x)
     dw $c9b9 ; window
 
 	db ROUTE_20
-    dw $417d, $c725 ; pointers (connected, current) (strip)
+    dw Route20Blocks + (Route20Width * 0), $c725 ; pointers (connected, current) (strip)
     db $09, $32 ; bigness, width
     db $00, $00 ; alignments (y, x)
     dw $c721 ; window
@@ -10448,7 +10448,7 @@
     ; connections data
 
 	db VIRIDIAN_CITY
-    dw $451a, $c6e8 ; pointers (connected, current) (strip)
+    dw ViridianCityBlocks + (ViridianCityHeight - 3) * ViridianCityWidth + 2, $c6e8 ; pointers (connected, current) (strip)
     db $10, $14 ; bigness, width
     db $23, $0a ; alignments (y, x)
     dw $c8bd ; window
@@ -20415,7 +20415,7 @@
     ; connections data
 
 	db ROUTE_10
-    dw $44a0, $c6eb ; pointers (connected, current) (strip)
+    dw Route10Blocks + (Route10Height - 3) * Route10Width, $c6eb ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $47, $00 ; alignments (y, x)
     dw $c929 ; window
@@ -20427,7 +20427,7 @@
     dw $c6f9 ; window
 
 	db ROUTE_8
-    dw $41e1, $c718 ; pointers (connected, current) (strip)
+    dw Route8Blocks - 3 + (Route8Width), $c718 ; pointers (connected, current) (strip)
     db $09, $1e ; bigness, width
     db $00, $3b ; alignments (y, x)
     dw $c72a ; window
@@ -22447,13 +22447,13 @@
     ; connections data
 
 	db CELADON_CITY
-    dw $410e, $c6e8 ; pointers (connected, current) (strip)
+    dw CeladonCityBlocks - 3 + (CeladonCityWidth * 2), $c6e8 ; pointers (connected, current) (strip)
     db $0f, $19 ; bigness, width
     db $08, $31 ; alignments (y, x)
     dw $c720 ; window
 
 	db SAFFRON_CITY
-    dw $4aac, $c6f5 ; pointers (connected, current) (strip)
+    dw SaffronCityBlocks + (SaffronCityWidth), $c6f5 ; pointers (connected, current) (strip)
     db $0f, $14 ; bigness, width
     db $08, $00 ; alignments (y, x)
     dw $c703 ; window
@@ -25573,13 +25573,13 @@
     ; connections data
 
 	db ROUTE_23
-    dw $4664, $c6eb ; pointers (connected, current) (strip)
+    dw Route23Blocks + (Route23Height - 3) * Route23Width, $c6eb ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $8f, $00 ; alignments (y, x)
     dw $cb69 ; window
 
 	db VIRIDIAN_CITY
-    dw $4400, $c6ff ; pointers (connected, current) (strip)
+    dw ViridianCityBlocks + (ViridianCityWidth), $c6ff ; pointers (connected, current) (strip)
     db $0f, $14 ; bigness, width
     db $08, $00 ; alignments (y, x)
     dw $c703 ; window
@@ -25616,13 +25616,13 @@
     ; connections data
 
 	db CINNABAR_ISLAND
-    dw $4070, $c790 ; pointers (connected, current) (strip)
+    dw CinnabarIslandBlocks - 3 + (CinnabarIslandWidth), $c790 ; pointers (connected, current) (strip)
     db $09, $0a ; bigness, width
     db $00, $13 ; alignments (y, x)
     dw $c702 ; window
 
 	db ROUTE_19
-    dw $4f87, $c71d ; pointers (connected, current) (strip)
+    dw Route19Blocks + (Route19Width * 15), $c71d ; pointers (connected, current) (strip)
     db $0c, $0a ; bigness, width
     db $24, $00 ; alignments (y, x)
     dw $c6f9 ; window
@@ -25670,7 +25670,7 @@
     ; connections data
 
 	db INDIGO_PLATEAU
-    dw $4986, $c6eb ; pointers (connected, current) (strip)
+    dw IndigoPlateauBlocks + (IndigoPlateauHeight - 3) * IndigoPlateauWidth, $c6eb ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $11, $00 ; alignments (y, x)
     dw $c779 ; window
@@ -25730,7 +25730,7 @@
     dw $c703 ; window
 
 	db ROUTE_25
-    dw $4810, $c725 ; pointers (connected, current) (strip)
+    dw Route25Blocks + (Route25Width * 0), $c725 ; pointers (connected, current) (strip)
     db $09, $1e ; bigness, width
     db $00, $00 ; alignments (y, x)
     dw $c70d ; window
@@ -25768,7 +25768,7 @@
     ; connections data
 
 	db ROUTE_24
-    dw $46ee, $c754 ; pointers (connected, current) (strip)
+    dw Route24Blocks - 3 + (Route24Width), $c754 ; pointers (connected, current) (strip)
     db $0c, $0a ; bigness, width
     db $00, $13 ; alignments (y, x)
     dw $c702 ; window
@@ -25854,7 +25854,7 @@
     ; connections data
 
 	db ROUTE_5
-    dw $4668, $c6f0 ; pointers (connected, current) (strip)
+    dw Route5Blocks + (Route5Height - 3) * Route5Width, $c6f0 ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $23, $f6 ; alignments (y, x)
     dw $c809 ; window
@@ -25866,13 +25866,13 @@
     dw $c6f9 ; window
 
 	db ROUTE_7
-    dw $4058, $c79e ; pointers (connected, current) (strip)
+    dw Route7Blocks - 3 + (Route7Width), $c79e ; pointers (connected, current) (strip)
     db $09, $0a ; bigness, width
     db $f8, $13 ; alignments (y, x)
     dw $c702 ; window
 
 	db ROUTE_8
-    dw $41c6, $c7b5 ; pointers (connected, current) (strip)
+    dw Route8Blocks + (Route8Width * 0), $c7b5 ; pointers (connected, current) (strip)
     db $09, $1e ; bigness, width
     db $f8, $00 ; alignments (y, x)
     dw $c70d ; window
@@ -27627,13 +27627,13 @@
     ; connections data
 
 	db ROUTE_4
-    dw $44fa, $c704 ; pointers (connected, current) (strip)
+    dw Route4Blocks + (Route4Height - 3) * Route4Width, $c704 ; pointers (connected, current) (strip)
     db $0d, $2d ; bigness, width
     db $11, $ce ; alignments (y, x)
     dw $c8b4 ; window
 
 	db PEWTER_CITY
-    dw $460b, $c6e8 ; pointers (connected, current) (strip)
+    dw PewterCityBlocks - 3 + (PewterCityWidth * 2), $c6e8 ; pointers (connected, current) (strip)
     db $0f, $14 ; bigness, width
     db $08, $27 ; alignments (y, x)
     dw $c716 ; window
@@ -27679,7 +27679,7 @@
     dw $c712 ; window
 
 	db CERULEAN_CITY
-    dw $4844, $c718 ; pointers (connected, current) (strip)
+    dw CeruleanCityBlocks + (CeruleanCityWidth), $c718 ; pointers (connected, current) (strip)
     db $0f, $14 ; bigness, width
     db $08, $00 ; alignments (y, x)
     dw $c703 ; window
@@ -27723,7 +27723,7 @@
     ; connections data
 
 	db CERULEAN_CITY
-    dw $495e, $c6e8 ; pointers (connected, current) (strip)
+    dw CeruleanCityBlocks + (CeruleanCityHeight - 3) * CeruleanCityWidth + 2, $c6e8 ; pointers (connected, current) (strip)
     db $10, $14 ; bigness, width
     db $23, $0a ; alignments (y, x)
     dw $c8bd ; window
@@ -27772,13 +27772,13 @@
     ; connections data
 
 	db CERULEAN_CITY
-    dw $4855, $c6e8 ; pointers (connected, current) (strip)
+    dw CeruleanCityBlocks - 3 + (CeruleanCityWidth * 2), $c6e8 ; pointers (connected, current) (strip)
     db $0f, $14 ; bigness, width
     db $08, $27 ; alignments (y, x)
     dw $c716 ; window
 
 	db ROUTE_10
-    dw $4356, $c775 ; pointers (connected, current) (strip)
+    dw Route10Blocks + (Route10Width * 0), $c775 ; pointers (connected, current) (strip)
     db $0c, $0a ; bigness, width
     db $00, $00 ; alignments (y, x)
     dw $c6f9 ; window
@@ -27819,13 +27819,13 @@
     ; connections data
 
 	db ROUTE_12
-    dw $490e, $c6ff ; pointers (connected, current) (strip)
+    dw Route12Blocks + (Route12Height - 3) * Route12Width, $c6ff ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $6b, $d8 ; alignments (y, x)
     dw $ca49 ; window
 
 	db ROUTE_14
-    dw $4a19, $c754 ; pointers (connected, current) (strip)
+    dw Route14Blocks - 3 + (Route14Width), $c754 ; pointers (connected, current) (strip)
     db $0c, $0a ; bigness, width
     db $00, $13 ; alignments (y, x)
     dw $c702 ; window
@@ -27868,13 +27868,13 @@
     ; connections data
 
 	db ROUTE_15
-    dw $49e7, $c838 ; pointers (connected, current) (strip)
+    dw Route15Blocks - 3 + (Route15Width), $c838 ; pointers (connected, current) (strip)
     db $09, $1e ; bigness, width
     db $dc, $3b ; alignments (y, x)
     dw $c72a ; window
 
 	db ROUTE_13
-    dw $488b, $c725 ; pointers (connected, current) (strip)
+    dw Route13Blocks + (Route13Width * 0), $c725 ; pointers (connected, current) (strip)
     db $09, $1e ; bigness, width
     db $00, $00 ; alignments (y, x)
     dw $c70d ; window
@@ -27915,7 +27915,7 @@
     ; connections data
 
 	db ROUTE_16
-    dw $4bfc, $c6eb ; pointers (connected, current) (strip)
+    dw Route16Blocks + (Route16Height - 3) * Route16Width, $c6eb ; pointers (connected, current) (strip)
     db $0d, $14 ; bigness, width
     db $11, $00 ; alignments (y, x)
     dw $c7d3 ; window
@@ -27967,13 +27967,13 @@
     ; connections data
 
 	db FUCHSIA_CITY
-    dw $4db4, $c6e8 ; pointers (connected, current) (strip)
+    dw FuchsiaCityBlocks + (FuchsiaCityHeight - 3) * FuchsiaCityWidth + 2, $c6e8 ; pointers (connected, current) (strip)
     db $10, $14 ; bigness, width
     db $23, $0a ; alignments (y, x)
     dw $c8bd ; window
 
 	db ROUTE_20
-    dw $41ac, $c838 ; pointers (connected, current) (strip)
+    dw Route20Blocks - 3 + (Route20Width), $c838 ; pointers (connected, current) (strip)
     db $09, $32 ; bigness, width
     db $dc, $63 ; alignments (y, x)
     dw $c752 ; window
@@ -28014,7 +28014,7 @@
     ; connections data
 
 	db PALLET_TOWN
-    dw $4339, $c6eb ; pointers (connected, current) (strip)
+    dw PalletTownBlocks + (PalletTownHeight - 3) * PalletTownWidth, $c6eb ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $11, $00 ; alignments (y, x)
     dw $c779 ; window
@@ -29209,7 +29209,7 @@
     ; connections data
 
 	db SAFFRON_CITY
-    dw $4bc6, $c6e8 ; pointers (connected, current) (strip)
+    dw SaffronCityBlocks + (SaffronCityHeight - 3) * SaffronCityWidth + 2, $c6e8 ; pointers (connected, current) (strip)
     db $10, $14 ; bigness, width
     db $23, $0a ; alignments (y, x)
     dw $c8bd ; window
@@ -29262,13 +29262,13 @@
     ; connections data
 
 	db SAFFRON_CITY
-    dw $4abd, $c6e8 ; pointers (connected, current) (strip)
+    dw SaffronCityBlocks - 3 + (SaffronCityWidth * 2), $c6e8 ; pointers (connected, current) (strip)
     db $0f, $14 ; bigness, width
     db $08, $27 ; alignments (y, x)
     dw $c716 ; window
 
 	db LAVENDER_TOWN
-    dw $4085, $c775 ; pointers (connected, current) (strip)
+    dw LavenderTownBlocks + (LavenderTownWidth * 0), $c775 ; pointers (connected, current) (strip)
     db $09, $0a ; bigness, width
     db $00, $00 ; alignments (y, x)
     dw $c6f9 ; window
@@ -29326,7 +29326,7 @@
     dw $c6f9 ; window
 
 	db ROUTE_9
-    dw $4719, $c718 ; pointers (connected, current) (strip)
+    dw Route9Blocks - 3 + (Route9Width), $c718 ; pointers (connected, current) (strip)
     db $09, $1e ; bigness, width
     db $00, $3b ; alignments (y, x)
     dw $c72a ; window
@@ -29376,13 +29376,13 @@
     ; connections data
 
 	db VERMILION_CITY
-    dw $4a64, $c6e8 ; pointers (connected, current) (strip)
+    dw VermilionCityBlocks - 3 + (VermilionCityWidth * 2), $c6e8 ; pointers (connected, current) (strip)
     db $0f, $14 ; bigness, width
     db $08, $27 ; alignments (y, x)
     dw $c716 ; window
 
 	db ROUTE_12
-    dw $4800, $c709 ; pointers (connected, current) (strip)
+    dw Route12Blocks + (Route12Width * 24), $c709 ; pointers (connected, current) (strip)
     db $0f, $0a ; bigness, width
     db $36, $00 ; alignments (y, x)
     dw $c6f9 ; window
@@ -29435,7 +29435,7 @@
     ; connections data
 
 	db LAVENDER_TOWN
-    dw $40c1, $c6eb ; pointers (connected, current) (strip)
+    dw LavenderTownBlocks + (LavenderTownHeight - 3) * LavenderTownWidth, $c6eb ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $11, $00 ; alignments (y, x)
     dw $c779 ; window
@@ -29447,7 +29447,7 @@
     dw $c70d ; window
 
 	db ROUTE_11
-    dw $457a, $c8c8 ; pointers (connected, current) (strip)
+    dw Route11Blocks - 3 + (Route11Width), $c8c8 ; pointers (connected, current) (strip)
     db $09, $1e ; bigness, width
     db $ca, $3b ; alignments (y, x)
     dw $c72a ; window
@@ -29499,13 +29499,13 @@
     ; connections data
 
 	db FUCHSIA_CITY
-    dw $4cab, $c6e8 ; pointers (connected, current) (strip)
+    dw FuchsiaCityBlocks - 3 + (FuchsiaCityWidth * 2), $c6e8 ; pointers (connected, current) (strip)
     db $0f, $14 ; bigness, width
     db $08, $27 ; alignments (y, x)
     dw $c716 ; window
 
 	db ROUTE_14
-    dw $4aa8, $c709 ; pointers (connected, current) (strip)
+    dw Route14Blocks + (Route14Width * 15), $c709 ; pointers (connected, current) (strip)
     db $0c, $0a ; bigness, width
     db $24, $00 ; alignments (y, x)
     dw $c6f9 ; window
@@ -29563,7 +29563,7 @@
     dw $c6f9 ; window
 
 	db CELADON_CITY
-    dw $40f8, $c6ff ; pointers (connected, current) (strip)
+    dw CeladonCityBlocks + (CeladonCityWidth), $c6ff ; pointers (connected, current) (strip)
     db $0f, $19 ; bigness, width
     db $08, $00 ; alignments (y, x)
     dw $c708 ; window
@@ -29622,13 +29622,13 @@
     ; connections data
 
 	db ROUTE_17
-    dw $4e5a, $c6eb ; pointers (connected, current) (strip)
+    dw Route17Blocks + (Route17Height - 3) * Route17Width, $c6eb ; pointers (connected, current) (strip)
     db $0a, $0a ; bigness, width
     db $8f, $00 ; alignments (y, x)
     dw $cb69 ; window
 
 	db FUCHSIA_CITY
-    dw $4c9a, $c704 ; pointers (connected, current) (strip)
+    dw FuchsiaCityBlocks + (FuchsiaCityWidth), $c704 ; pointers (connected, current) (strip)
     db $0f, $14 ; bigness, width
     db $08, $00 ; alignments (y, x)
     dw $c703 ; window
--- a/extras/connection_helper.py
+++ b/extras/connection_helper.py
@@ -5,11 +5,17 @@
 import extract_maps
 from pretty_map_headers import map_constants, map_name_cleaner, offset_to_pointer
 
-def print_connections(map_id):
+def print_connections(map_id, in_connection_id=None, do_output=False):
     map1        = extract_maps.map_headers[map_id]
     map1_name   = map1["name"]
     connections = map1["connections"]
+    output = ""
     
+    if in_connection_id != None:
+        connections2 = {}
+        connections2[in_connection_id] = connections[in_connection_id]
+        connections = connections2
+    
     for connection_id in connections:
         connection          = connections[connection_id]
         direction           = connection["direction"]
@@ -24,11 +30,11 @@
         map2_height         = int(map2["y"], 16)
         map2_width          = int(map2["x"], 16)
 
-        print map1_name + " (id=" + str(map_id) + ") " + direction + " to " + map2_name
-        print "map2 blocks pointer: " + hex(map2_blocks_pointer)
-        print "map2 height: " + str(map2_height)
-        print "map2 width: " + str(map2_width)
-        print "map1 connection pointer: " + hex(connected_pointer)
+        output +=  map1_name + " (id=" + str(map_id) + ") " + direction + " to " + map2_name + "\n"
+        output +=  "map2 blocks pointer: " + hex(map2_blocks_pointer) + "\n"
+        output +=  "map2 height: " + str(map2_height) + "\n"
+        output +=  "map2 width: " + str(map2_width) + "\n"
+        output +=  "map1 connection pointer: " + hex(connected_pointer) + "\n"
         
         shift = 0
         #not sure about the calculated shift for NORTH or SOUTH
@@ -38,7 +44,7 @@
             if result != 0:
                 shift = result #seems to always be 2?
                 calculated = map2_blocks_pointer + (map2_height - 3) * map2_width + shift
-                print "shift: " + str(shift)
+                output += "shift: " + str(shift) + "\n"
                 formula = map2_cname + "Blocks + (" + map2_cname + "Height - 3) * " + map2_cname + "Width + " + str(shift)
             else:
                 formula = map2_cname + "Blocks + (" + map2_cname + "Height - 3) * " + map2_cname + "Width"
@@ -49,36 +55,41 @@
             if result != 0:
                 shift = result
                 calculated = map2_blocks_pointer + shift
-                print "shift: " + str(shift)
-                formula += " + " + str(shift)
+                output += "shift: " + str(shift) + "\n"
+                formula += "Blocks + " + str(shift)
         elif direction == "WEST":
             calculated = map2_blocks_pointer - 3 + (map2_width)
             result = connected_pointer - calculated
-            formula = map2_cname + " - 3 + (" + map2_cname + "Width)"
+            formula = map2_cname + "Blocks - 3 + (" + map2_cname + "Width)"
             if result != 0:
                 shift = result / map2_width
                 shift += 1
                 calculated = map2_blocks_pointer - 3 + (map2_width * shift)
-                print "shift: " + str(shift)
-                formula = map2_cname + " - 3 + (" + map2_cname + "Width * " + str(shift) + ")"
+                output += "shift: " + str(shift) + "\n"
+                formula = map2_cname + "Blocks - 3 + (" + map2_cname + "Width * " + str(shift) + ")"
         elif direction == "EAST":
             calculated = map2_blocks_pointer + (map2_width)
             result = connected_pointer - calculated
-            print ".. result is: " + str(result)
-            formula = map2_cname + " + (" + map2_cname + "Width)"
+            output += ".. result is: " + str(result) + "\n"
+            formula = map2_cname + "Blocks + (" + map2_cname + "Width)"
             if result != 0:
                 shift = result / map2_width
                 shift += 1
                 calculated = map2_blocks_pointer + (map2_width * shift)
-                print "shift: " + str(shift)
-                formula = map2_cname + " + (" + map2_cname + "Width * " + str(shift) + ")"
+                output += "shift: " + str(shift) + "\n"
+                formula = map2_cname + "Blocks" + " + (" + map2_cname + "Width * " + str(shift) + ")"
         
-        print "formula: " + formula
+        output += "formula: " + formula + "\n"
 
         result = connected_pointer - calculated
-        print "result: " + str(result) 
+        output += "result: " + str(result) + "\n"
 
-        print "\n",
+        output += "\n\n"
+    
+    if in_connection_id != None:
+        return formula
+    if do_output == True:
+        return output
 
 if __name__ == "__main__":
     extract_maps.load_rom()
@@ -91,4 +102,4 @@
     
     for map_id in extract_maps.map_headers.keys():
         if map_id not in extract_maps.bad_maps:
-            print_connections(map_id)
+            print print_connections(map_id, do_output=True)
--- a/extras/replace_dimensions.py
+++ b/extras/replace_dimensions.py
@@ -4,7 +4,8 @@
 #replace dimensions with constants
 import sys #for non-newline-terminated output :/
 from add_map_labels_to_map_headers import find_with_start_of_line
-from pretty_map_headers import map_name_cleaner, spacing
+from pretty_map_headers import map_name_cleaner, spacing, offset_to_pointer, map_constants
+from connection_helper import print_connections
 
 asm = None
 asm_lines = None
@@ -23,7 +24,7 @@
         id += 1
     return False #not found
 
-def replace_dimensions():
+def replace_values():
     global asm_lines
     for map_id in extract_maps.map_headers.keys():
         if map_id in extract_maps.bad_maps: continue #skip
@@ -34,9 +35,28 @@
         line_number = find_line_starting_with(label_name)
         if line_number == False: continue #skip, not found
 
+        #replace dimensions if necessary
         if "dimensions" in asm_lines[line_number + 2] and "$" in asm_lines[line_number + 2] and not "\t" in asm_lines[line_number+2]:
             asm_lines[line_number + 2] = spacing + "db " + clean_name + "Height, " + clean_name + "Width ; dimensions (y, x)"
 
+        #skip the rest of this if there are no connections
+        if len(map1["connections"]) == 0: continue
+        if not "; connections data" in asm_lines[line_number + 6]: continue
+
+        connection_offset = line_number + 8
+
+        for connection_id in map1["connections"]:
+            if "dw $" in asm_lines[connection_offset + 1]:
+                formula = print_connections(map_id, in_connection_id=connection_id)
+
+                temp_line = asm_lines[connection_offset + 1]
+                temp_line = spacing + "dw " + formula + temp_line[12:]
+
+                asm_lines[connection_offset + 1] = temp_line
+
+            connection_offset += 6
+            
+
 if __name__ == "__main__":
     import extract_maps
     extract_maps.load_rom()
@@ -44,6 +64,6 @@
     extract_maps.read_all_map_headers()
 
     load_asm()
-    replace_dimensions()
+    replace_values()
     sys.stdout.write("\n".join(asm_lines))