shithub: pokecrystal

Download patch

ref: dbabd8b4a94014749a9c2a6f36ed524947c4403e
parent: 71073a5f3bcbf4f2725e16bdce147c070c8b833e
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Wed Mar 10 16:06:06 EST 2021

Define MAPGROUP_* constants and verify MapGroup_* table sizes

--- a/constants/map_constants.asm
+++ b/constants/map_constants.asm
@@ -1,5 +1,8 @@
 newgroup: MACRO
+;\1: group id
 	const_skip
+MAPGROUP_\1 EQU const_value
+CURRENT_NUM_MAPGROUP_MAPS EQUS "NUM_\1_MAPS"
 __map_value__ = 1
 ENDM
 
@@ -14,6 +17,11 @@
 \1_HEIGHT EQU \3
 ENDM
 
+endgroup: MACRO
+CURRENT_NUM_MAPGROUP_MAPS EQU __map_value__ - 1
+PURGE CURRENT_NUM_MAPGROUP_MAPS
+ENDM
+
 ; map group ids
 ; `newgroup` indexes are for:
 ; - MapGroupPointers (see data/maps/maps.asm)
@@ -27,8 +35,7 @@
 ; - scripts and events (see data/maps/scripts.asm)
 	const_def
 
-	newgroup                                                      ;  1
-
+	newgroup OLIVINE                                              ;  1
 	map_const OLIVINE_POKECENTER_1F,                        5,  4 ;  1
 	map_const OLIVINE_GYM,                                  5,  8 ;  2
 	map_const OLIVINE_TIMS_HOUSE,                           4,  4 ;  3
@@ -43,9 +50,9 @@
 	map_const ROUTE_38,                                    20,  9 ; 12
 	map_const ROUTE_39,                                    10, 18 ; 13
 	map_const OLIVINE_CITY,                                20, 18 ; 14
+	endgroup
 
-	newgroup                                                      ;  2
-
+	newgroup MAHOGANY                                             ;  2
 	map_const MAHOGANY_RED_GYARADOS_SPEECH_HOUSE,           4,  4 ;  1
 	map_const MAHOGANY_GYM,                                 5,  9 ;  2
 	map_const MAHOGANY_POKECENTER_1F,                       5,  4 ;  3
@@ -53,9 +60,9 @@
 	map_const ROUTE_42,                                    30,  9 ;  5
 	map_const ROUTE_44,                                    30,  9 ;  6
 	map_const MAHOGANY_TOWN,                               10,  9 ;  7
+	endgroup
 
-	newgroup                                                      ;  3
-
+	newgroup DUNGEONS                                             ;  3
 	map_const SPROUT_TOWER_1F,                             10,  8 ;  1
 	map_const SPROUT_TOWER_2F,                             10,  8 ;  2
 	map_const SPROUT_TOWER_3F,                             10,  8 ;  3
@@ -147,9 +154,9 @@
 	map_const SAFARI_ZONE_FUCHSIA_GATE_BETA,                5,  4 ; 89
 	map_const SAFARI_ZONE_BETA,                            10, 18 ; 90
 	map_const VICTORY_ROAD,                                10, 36 ; 91
+	endgroup
 
-	newgroup                                                      ;  4
-
+	newgroup ECRUTEAK                                             ;  4
 	map_const ECRUTEAK_TIN_TOWER_ENTRANCE,                 10,  9 ;  1
 	map_const WISE_TRIOS_ROOM,                              4,  4 ;  2
 	map_const ECRUTEAK_POKECENTER_1F,                       5,  4 ;  3
@@ -159,9 +166,9 @@
 	map_const ECRUTEAK_GYM,                                 5,  9 ;  7
 	map_const ECRUTEAK_ITEMFINDER_HOUSE,                    4,  4 ;  8
 	map_const ECRUTEAK_CITY,                               20, 18 ;  9
+	endgroup
 
-	newgroup                                                      ;  5
-
+	newgroup BLACKTHORN                                           ;  5
 	map_const BLACKTHORN_GYM_1F,                            5,  9 ;  1
 	map_const BLACKTHORN_GYM_2F,                            5,  9 ;  2
 	map_const BLACKTHORN_DRAGON_SPEECH_HOUSE,               4,  4 ;  3
@@ -172,9 +179,9 @@
 	map_const ROUTE_45,                                    10, 45 ;  8
 	map_const ROUTE_46,                                    10, 18 ;  9
 	map_const BLACKTHORN_CITY,                             20, 18 ; 10
+	endgroup
 
-	newgroup                                                      ;  6
-
+	newgroup CINNABAR                                             ;  6
 	map_const CINNABAR_POKECENTER_1F,                       5,  4 ;  1
 	map_const CINNABAR_POKECENTER_2F_BETA,                  8,  4 ;  2
 	map_const ROUTE_19_FUCHSIA_GATE,                        5,  4 ;  3
@@ -183,9 +190,9 @@
 	map_const ROUTE_20,                                    30,  9 ;  6
 	map_const ROUTE_21,                                    10, 18 ;  7
 	map_const CINNABAR_ISLAND,                             10,  9 ;  8
+	endgroup
 
-	newgroup                                                      ;  7
-
+	newgroup CERULEAN                                             ;  7
 	map_const CERULEAN_GYM_BADGE_SPEECH_HOUSE,              4,  4 ;  1
 	map_const CERULEAN_POLICE_STATION,                      4,  4 ;  2
 	map_const CERULEAN_TRADE_SPEECH_HOUSE,                  4,  4 ;  3
@@ -203,9 +210,9 @@
 	map_const ROUTE_24,                                    10,  9 ; 15
 	map_const ROUTE_25,                                    30,  9 ; 16
 	map_const CERULEAN_CITY,                               20, 18 ; 17
+	endgroup
 
-	newgroup                                                      ;  8
-
+	newgroup AZALEA                                               ;  8
 	map_const AZALEA_POKECENTER_1F,                         5,  4 ;  1
 	map_const CHARCOAL_KILN,                                4,  4 ;  2
 	map_const AZALEA_MART,                                  6,  4 ;  3
@@ -213,9 +220,9 @@
 	map_const AZALEA_GYM,                                   5,  8 ;  5
 	map_const ROUTE_33,                                    10,  9 ;  6
 	map_const AZALEA_TOWN,                                 20,  9 ;  7
+	endgroup
 
-	newgroup                                                      ;  9
-
+	newgroup LAKE_OF_RAGE                                         ;  9
 	map_const LAKE_OF_RAGE_HIDDEN_POWER_HOUSE,              4,  4 ;  1
 	map_const LAKE_OF_RAGE_MAGIKARP_HOUSE,                  4,  4 ;  2
 	map_const ROUTE_43_MAHOGANY_GATE,                       5,  4 ;  3
@@ -222,9 +229,9 @@
 	map_const ROUTE_43_GATE,                                5,  4 ;  4
 	map_const ROUTE_43,                                    10, 27 ;  5
 	map_const LAKE_OF_RAGE,                                20, 18 ;  6
+	endgroup
 
-	newgroup                                                      ; 10
-
+	newgroup VIOLET                                               ; 10
 	map_const ROUTE_32,                                    10, 45 ;  1
 	map_const ROUTE_35,                                    10, 18 ;  2
 	map_const ROUTE_36,                                    30,  9 ;  3
@@ -242,9 +249,9 @@
 	map_const ROUTE_35_NATIONAL_PARK_GATE,                  4,  4 ; 15
 	map_const ROUTE_36_RUINS_OF_ALPH_GATE,                  5,  4 ; 16
 	map_const ROUTE_36_NATIONAL_PARK_GATE,                  5,  4 ; 17
+	endgroup
 
-	newgroup                                                      ; 11
-
+	newgroup GOLDENROD                                            ; 11
 	map_const ROUTE_34,                                    10, 27 ;  1
 	map_const GOLDENROD_CITY,                              20, 18 ;  2
 	map_const GOLDENROD_GYM,                               10,  9 ;  3
@@ -269,9 +276,9 @@
 	map_const ILEX_FOREST_AZALEA_GATE,                      5,  4 ; 22
 	map_const ROUTE_34_ILEX_FOREST_GATE,                    5,  4 ; 23
 	map_const DAY_CARE,                                     5,  4 ; 24
+	endgroup
 
-	newgroup                                                      ; 12
-
+	newgroup VERMILION                                            ; 12
 	map_const ROUTE_6,                                     10,  9 ;  1
 	map_const ROUTE_11,                                    20,  9 ;  2
 	map_const VERMILION_CITY,                              20, 18 ;  3
@@ -285,9 +292,9 @@
 	map_const VERMILION_GYM,                                5,  9 ; 11
 	map_const ROUTE_6_SAFFRON_GATE,                         5,  4 ; 12
 	map_const ROUTE_6_UNDERGROUND_PATH_ENTRANCE,            4,  4 ; 13
+	endgroup
 
-	newgroup                                                      ; 13
-
+	newgroup PALLET                                               ; 13
 	map_const ROUTE_1,                                     10, 18 ;  1
 	map_const PALLET_TOWN,                                 10,  9 ;  2
 	map_const REDS_HOUSE_1F,                                4,  4 ;  3
@@ -294,9 +301,9 @@
 	map_const REDS_HOUSE_2F,                                4,  4 ;  4
 	map_const BLUES_HOUSE,                                  4,  4 ;  5
 	map_const OAKS_LAB,                                     5,  6 ;  6
+	endgroup
 
-	newgroup                                                      ; 14
-
+	newgroup PEWTER                                               ; 14
 	map_const ROUTE_3,                                     30,  9 ;  1
 	map_const PEWTER_CITY,                                 20, 18 ;  2
 	map_const PEWTER_NIDORAN_SPEECH_HOUSE,                  4,  4 ;  3
@@ -305,9 +312,9 @@
 	map_const PEWTER_POKECENTER_1F,                         5,  4 ;  6
 	map_const PEWTER_POKECENTER_2F_BETA,                    8,  4 ;  7
 	map_const PEWTER_SNOOZE_SPEECH_HOUSE,                   4,  4 ;  8
+	endgroup
 
-	newgroup                                                      ; 15
-
+	newgroup FAST_SHIP                                            ; 15
 	map_const OLIVINE_PORT,                                10, 18 ;  1
 	map_const VERMILION_PORT,                              10, 18 ;  2
 	map_const FAST_SHIP_1F,                                16,  9 ;  3
@@ -320,9 +327,9 @@
 	map_const MOUNT_MOON_SQUARE,                           15,  9 ; 10
 	map_const MOUNT_MOON_GIFT_SHOP,                         4,  4 ; 11
 	map_const TIN_TOWER_ROOF,                              10,  9 ; 12
+	endgroup
 
-	newgroup                                                      ; 16
-
+	newgroup INDIGO                                               ; 16
 	map_const ROUTE_23,                                    10,  9 ;  1
 	map_const INDIGO_PLATEAU_POKECENTER_1F,                 9,  7 ;  2
 	map_const WILLS_ROOM,                                   5,  9 ;  3
@@ -331,9 +338,9 @@
 	map_const KARENS_ROOM,                                  5,  9 ;  6
 	map_const LANCES_ROOM,                                  5, 12 ;  7
 	map_const HALL_OF_FAME,                                 5,  7 ;  8
+	endgroup
 
-	newgroup                                                      ; 17
-
+	newgroup FUCHSIA                                              ; 17
 	map_const ROUTE_13,                                    30,  9 ;  1
 	map_const ROUTE_14,                                    10, 18 ;  2
 	map_const ROUTE_15,                                    20,  9 ;  3
@@ -347,9 +354,9 @@
 	map_const FUCHSIA_POKECENTER_2F_BETA,                   8,  4 ; 11
 	map_const SAFARI_ZONE_WARDENS_HOME,                     5,  4 ; 12
 	map_const ROUTE_15_FUCHSIA_GATE,                        5,  4 ; 13
+	endgroup
 
-	newgroup                                                      ; 18
-
+	newgroup LAVENDER                                             ; 18
 	map_const ROUTE_8,                                     20,  9 ;  1
 	map_const ROUTE_12,                                    10, 27 ;  2
 	map_const ROUTE_10_SOUTH,                              10,  9 ;  3
@@ -364,16 +371,16 @@
 	map_const LAV_RADIO_TOWER_1F,                          10,  4 ; 12
 	map_const ROUTE_8_SAFFRON_GATE,                         5,  4 ; 13
 	map_const ROUTE_12_SUPER_ROD_HOUSE,                     4,  4 ; 14
+	endgroup
 
-	newgroup                                                      ; 19
-
+	newgroup SILVER                                               ; 19
 	map_const ROUTE_28,                                    20,  9 ;  1
 	map_const SILVER_CAVE_OUTSIDE,                         20, 18 ;  2
 	map_const SILVER_CAVE_POKECENTER_1F,                    5,  4 ;  3
 	map_const ROUTE_28_STEEL_WING_HOUSE,                    4,  4 ;  4
+	endgroup
 
-	newgroup                                                      ; 20
-
+	newgroup CABLE_CLUB                                           ; 20
 	map_const POKECENTER_2F,                                8,  4 ;  1
 	map_const TRADE_CENTER,                                 5,  4 ;  2
 	map_const COLOSSEUM,                                    5,  4 ;  3
@@ -380,9 +387,9 @@
 	map_const TIME_CAPSULE,                                 5,  4 ;  4
 	map_const MOBILE_TRADE_ROOM,                            5,  4 ;  5
 	map_const MOBILE_BATTLE_ROOM,                           5,  4 ;  6
+	endgroup
 
-	newgroup                                                      ; 21
-
+	newgroup CELADON                                              ; 21
 	map_const ROUTE_7,                                     10,  9 ;  1
 	map_const ROUTE_16,                                    10,  9 ;  2
 	map_const ROUTE_17,                                    10, 45 ;  3
@@ -409,9 +416,9 @@
 	map_const ROUTE_16_GATE,                                5,  4 ; 24
 	map_const ROUTE_7_SAFFRON_GATE,                         5,  4 ; 25
 	map_const ROUTE_17_ROUTE_18_GATE,                       5,  4 ; 26
+	endgroup
 
-	newgroup                                                      ; 22
-
+	newgroup CIANWOOD                                             ; 22
 	map_const ROUTE_40,                                    10, 18 ;  1
 	map_const ROUTE_41,                                    25, 27 ;  2
 	map_const CIANWOOD_CITY,                               15, 27 ;  3
@@ -428,9 +435,9 @@
 	map_const BATTLE_TOWER_HALLWAY,                        11,  2 ; 14
 	map_const ROUTE_40_BATTLE_TOWER_GATE,                   5,  4 ; 15
 	map_const BATTLE_TOWER_OUTSIDE,                        10, 14 ; 16
+	endgroup
 
-	newgroup                                                      ; 23
-
+	newgroup VIRIDIAN                                             ; 23
 	map_const ROUTE_2,                                     10, 27 ;  1
 	map_const ROUTE_22,                                    20,  9 ;  2
 	map_const VIRIDIAN_CITY,                               20, 18 ;  3
@@ -444,9 +451,9 @@
 	map_const ROUTE_2_NUGGET_HOUSE,                         4,  4 ; 11
 	map_const ROUTE_2_GATE,                                 5,  4 ; 12
 	map_const VICTORY_ROAD_GATE,                           10,  9 ; 13
+	endgroup
 
-	newgroup                                                      ; 24
-
+	newgroup NEW_BARK                                             ; 24
 	map_const ROUTE_26,                                    10, 54 ;  1
 	map_const ROUTE_27,                                    40,  9 ;  2
 	map_const ROUTE_29,                                    30,  9 ;  3
@@ -460,9 +467,9 @@
 	map_const DAY_OF_WEEK_SIBLINGS_HOUSE,                   4,  4 ; 11
 	map_const ROUTE_27_SANDSTORM_HOUSE,                     4,  4 ; 12
 	map_const ROUTE_29_ROUTE_46_GATE,                       5,  4 ; 13
+	endgroup
 
-	newgroup                                                      ; 25
-
+	newgroup SAFFRON                                              ; 25
 	map_const ROUTE_5,                                     10,  9 ;  1
 	map_const SAFFRON_CITY,                                20, 18 ;  2
 	map_const FIGHTING_DOJO,                                5,  6 ;  3
@@ -478,9 +485,9 @@
 	map_const ROUTE_5_UNDERGROUND_PATH_ENTRANCE,            4,  4 ; 13
 	map_const ROUTE_5_SAFFRON_GATE,                         5,  4 ; 14
 	map_const ROUTE_5_CLEANSE_TAG_HOUSE,                    4,  4 ; 15
+	endgroup
 
-	newgroup                                                      ; 26
-
+	newgroup CHERRYGROVE                                          ; 26
 	map_const ROUTE_30,                                    10, 27 ;  1
 	map_const ROUTE_31,                                    20,  9 ;  2
 	map_const CHERRYGROVE_CITY,                            20,  9 ;  3
@@ -492,5 +499,6 @@
 	map_const ROUTE_30_BERRY_HOUSE,                         4,  4 ;  9
 	map_const MR_POKEMONS_HOUSE,                            4,  4 ; 10
 	map_const ROUTE_31_VIOLET_GATE,                         5,  4 ; 11
+	endgroup
 
 NUM_MAP_GROUPS EQU const_value ; 26
--- a/constants/map_data_constants.asm
+++ b/constants/map_data_constants.asm
@@ -1,19 +1,21 @@
-GROUP_N_A  EQU -1
-MAP_N_A    EQU -1
-GROUP_NONE EQU 0
-MAP_NONE   EQU 0
+MAPGROUP_N_A  EQU -1
+GROUP_N_A     EQU -1
+MAP_N_A       EQU -1
+MAPGROUP_NONE EQU 0
+GROUP_NONE    EQU 0
+MAP_NONE      EQU 0
 
 ; map struct members (see data/maps/maps.asm)
-	const_def
-	const MAP_MAPATTRIBUTES_BANK ; 0
-	const MAP_TILESET            ; 1
-	const MAP_ENVIRONMENT        ; 2
-	const MAP_MAPATTRIBUTES      ; 3
-	const MAP_MAPATTRIBUTES_HI   ; 4
-	const MAP_LOCATION           ; 5
-	const MAP_MUSIC              ; 6
-	const MAP_PALETTE            ; 7
-	const MAP_FISHGROUP          ; 8
+rsreset
+MAP_MAPATTRIBUTES_BANK rb ; 0
+MAP_TILESET            rb ; 1
+MAP_ENVIRONMENT        rb ; 2
+MAP_MAPATTRIBUTES      rw ; 3
+MAP_LOCATION           rb ; 5
+MAP_MUSIC              rb ; 6
+MAP_PALETTE            rb ; 7
+MAP_FISHGROUP          rb ; 8
+MAP_LENGTH EQU _RS
 
 ; map environments (wEnvironment)
 	const_def 1
--- a/constants/script_constants.asm
+++ b/constants/script_constants.asm
@@ -60,7 +60,7 @@
 	const VAR_MAPGROUP         ; 0c
 	const VAR_MAPNUMBER        ; 0d
 	const VAR_UNOWNCOUNT       ; 0e
-	const VAR_ROOFPALETTE      ; 0f
+	const VAR_ENVIRONMENT      ; 0f
 	const VAR_BOXSPACE         ; 10
 	const VAR_CONTESTMINUTES   ; 11
 	const VAR_XCOORD           ; 12
--- a/data/maps/maps.asm
+++ b/data/maps/maps.asm
@@ -46,6 +46,7 @@
 	assert_table_length NUM_MAP_GROUPS
 
 MapGroup_Olivine:
+	table_width MAP_LENGTH, MapGroup_Olivine
 	map OlivinePokecenter1F, TILESET_POKECENTER, INDOOR, LANDMARK_OLIVINE_CITY, MUSIC_POKEMON_CENTER, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map OlivineGym, TILESET_CHAMPIONS_ROOM, INDOOR, LANDMARK_OLIVINE_CITY, MUSIC_GYM, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map OlivineTimsHouse, TILESET_HOUSE, INDOOR, LANDMARK_OLIVINE_CITY, MUSIC_VIOLET_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -60,8 +61,10 @@
 	map Route38, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_38, MUSIC_ROUTE_37, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map Route39, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_39, MUSIC_ROUTE_37, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map OlivineCity, TILESET_JOHTO, TOWN, LANDMARK_OLIVINE_CITY, MUSIC_VIOLET_CITY, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
+	assert_table_length NUM_OLIVINE_MAPS
 
 MapGroup_Mahogany:
+	table_width MAP_LENGTH, MapGroup_Mahogany
 	map MahoganyRedGyaradosSpeechHouse, TILESET_HOUSE, INDOOR, LANDMARK_MAHOGANY_TOWN, MUSIC_CHERRYGROVE_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map MahoganyGym, TILESET_ELITE_FOUR_ROOM, INDOOR, LANDMARK_MAHOGANY_TOWN, MUSIC_GYM, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map MahoganyPokecenter1F, TILESET_POKECENTER, INDOOR, LANDMARK_MAHOGANY_TOWN, MUSIC_POKEMON_CENTER, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -69,8 +72,10 @@
 	map Route42, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_42, MUSIC_LAKE_OF_RAGE, FALSE, PALETTE_AUTO, FISHGROUP_LAKE
 	map Route44, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_44, MUSIC_LAKE_OF_RAGE, FALSE, PALETTE_AUTO, FISHGROUP_POND
 	map MahoganyTown, TILESET_JOHTO, TOWN, LANDMARK_MAHOGANY_TOWN, MUSIC_CHERRYGROVE_CITY, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
+	assert_table_length NUM_MAHOGANY_MAPS
 
 MapGroup_Dungeons:
+	table_width MAP_LENGTH, MapGroup_Dungeons
 	map SproutTower1F, TILESET_TOWER, DUNGEON, LANDMARK_SPROUT_TOWER, MUSIC_SPROUT_TOWER, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map SproutTower2F, TILESET_TOWER, DUNGEON, LANDMARK_SPROUT_TOWER, MUSIC_SPROUT_TOWER, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map SproutTower3F, TILESET_TOWER, DUNGEON, LANDMARK_SPROUT_TOWER, MUSIC_SPROUT_TOWER, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -162,8 +167,10 @@
 	map SafariZoneFuchsiaGateBeta, TILESET_GATE, INDOOR, LANDMARK_FUCHSIA_CITY, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map SafariZoneBeta, TILESET_PARK, CAVE, LANDMARK_FUCHSIA_CITY, MUSIC_EVOLUTION, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map VictoryRoad, TILESET_CAVE, CAVE, LANDMARK_VICTORY_ROAD, MUSIC_VICTORY_ROAD, TRUE, PALETTE_NITE, FISHGROUP_SHORE
+	assert_table_length NUM_DUNGEONS_MAPS
 
 MapGroup_Ecruteak:
+	table_width MAP_LENGTH, MapGroup_Ecruteak
 	map EcruteakTinTowerEntrance, TILESET_TOWER, INDOOR, LANDMARK_ECRUTEAK_CITY, MUSIC_ECRUTEAK_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map WiseTriosRoom, TILESET_TRADITIONAL_HOUSE, INDOOR, LANDMARK_ECRUTEAK_CITY, MUSIC_ECRUTEAK_CITY, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map EcruteakPokecenter1F, TILESET_POKECENTER, INDOOR, LANDMARK_ECRUTEAK_CITY, MUSIC_POKEMON_CENTER, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -173,8 +180,10 @@
 	map EcruteakGym, TILESET_TOWER, INDOOR, LANDMARK_ECRUTEAK_CITY, MUSIC_GYM, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map EcruteakItemfinderHouse, TILESET_TRADITIONAL_HOUSE, INDOOR, LANDMARK_ECRUTEAK_CITY, MUSIC_ECRUTEAK_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map EcruteakCity, TILESET_JOHTO, TOWN, LANDMARK_ECRUTEAK_CITY, MUSIC_ECRUTEAK_CITY, FALSE, PALETTE_AUTO, FISHGROUP_POND
+	assert_table_length NUM_ECRUTEAK_MAPS
 
 MapGroup_Blackthorn:
+	table_width MAP_LENGTH, MapGroup_Blackthorn
 	map BlackthornGym1F, TILESET_ELITE_FOUR_ROOM, INDOOR, LANDMARK_BLACKTHORN_CITY, MUSIC_GYM, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map BlackthornGym2F, TILESET_ELITE_FOUR_ROOM, INDOOR, LANDMARK_BLACKTHORN_CITY, MUSIC_GYM, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map BlackthornDragonSpeechHouse, TILESET_HOUSE, INDOOR, LANDMARK_BLACKTHORN_CITY, MUSIC_AZALEA_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -185,8 +194,10 @@
 	map Route45, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_45, MUSIC_ROUTE_36, FALSE, PALETTE_AUTO, FISHGROUP_DRATINI_2
 	map Route46, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_46, MUSIC_ROUTE_36, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map BlackthornCity, TILESET_JOHTO, TOWN, LANDMARK_BLACKTHORN_CITY, MUSIC_AZALEA_TOWN, FALSE, PALETTE_AUTO, FISHGROUP_POND
+	assert_table_length NUM_BLACKTHORN_MAPS
 
 MapGroup_Cinnabar:
+	table_width MAP_LENGTH, MapGroup_Cinnabar
 	map CinnabarPokecenter1F, TILESET_POKECENTER, INDOOR, LANDMARK_CINNABAR_ISLAND, MUSIC_POKEMON_CENTER, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map CinnabarPokecenter2FBeta, TILESET_POKECENTER, INDOOR, LANDMARK_CINNABAR_ISLAND, MUSIC_POKEMON_CENTER, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route19FuchsiaGate, TILESET_GATE, GATE, LANDMARK_ROUTE_19, MUSIC_ROUTE_3, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -195,8 +206,10 @@
 	map Route20, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_20, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_OCEAN
 	map Route21, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_21, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_OCEAN
 	map CinnabarIsland, TILESET_KANTO, TOWN, LANDMARK_CINNABAR_ISLAND, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_AUTO, FISHGROUP_OCEAN
+	assert_table_length NUM_CINNABAR_MAPS
 
 MapGroup_Cerulean:
+	table_width MAP_LENGTH, MapGroup_Cerulean
 	map CeruleanGymBadgeSpeechHouse, TILESET_HOUSE, INDOOR, LANDMARK_CERULEAN_CITY, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map CeruleanPoliceStation, TILESET_HOUSE, INDOOR, LANDMARK_CERULEAN_CITY, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map CeruleanTradeSpeechHouse, TILESET_HOUSE, INDOOR, LANDMARK_CERULEAN_CITY, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -214,8 +227,10 @@
 	map Route24, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_24, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_LAKE
 	map Route25, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_25, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_LAKE
 	map CeruleanCity, TILESET_KANTO, TOWN, LANDMARK_CERULEAN_CITY, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_AUTO, FISHGROUP_NONE
+	assert_table_length NUM_CERULEAN_MAPS
 
 MapGroup_Azalea:
+	table_width MAP_LENGTH, MapGroup_Azalea
 	map AzaleaPokecenter1F, TILESET_POKECENTER, INDOOR, LANDMARK_AZALEA_TOWN, MUSIC_POKEMON_CENTER, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map CharcoalKiln, TILESET_HOUSE, INDOOR, LANDMARK_AZALEA_TOWN, MUSIC_AZALEA_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map AzaleaMart, TILESET_MART, INDOOR, LANDMARK_AZALEA_TOWN, MUSIC_AZALEA_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -223,8 +238,10 @@
 	map AzaleaGym, TILESET_ELITE_FOUR_ROOM, INDOOR, LANDMARK_AZALEA_TOWN, MUSIC_GYM, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route33, TILESET_JOHTO_MODERN, ROUTE, LANDMARK_ROUTE_33, MUSIC_ROUTE_30, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map AzaleaTown, TILESET_JOHTO_MODERN, TOWN, LANDMARK_AZALEA_TOWN, MUSIC_AZALEA_TOWN, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
+	assert_table_length NUM_AZALEA_MAPS
 
 MapGroup_LakeOfRage:
+	table_width MAP_LENGTH, MapGroup_LakeOfRage
 	map LakeOfRageHiddenPowerHouse, TILESET_HOUSE, INDOOR, LANDMARK_LAKE_OF_RAGE, MUSIC_LAKE_OF_RAGE, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map LakeOfRageMagikarpHouse, TILESET_HOUSE, INDOOR, LANDMARK_LAKE_OF_RAGE, MUSIC_LAKE_OF_RAGE, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route43MahoganyGate, TILESET_GATE, GATE, LANDMARK_ROUTE_43, MUSIC_LAKE_OF_RAGE, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -231,8 +248,10 @@
 	map Route43Gate, TILESET_GATE, GATE, LANDMARK_ROUTE_43, MUSIC_LAKE_OF_RAGE, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route43, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_43, MUSIC_LAKE_OF_RAGE, FALSE, PALETTE_AUTO, FISHGROUP_POND
 	map LakeOfRage, TILESET_JOHTO, TOWN, LANDMARK_LAKE_OF_RAGE, MUSIC_LAKE_OF_RAGE, FALSE, PALETTE_AUTO, FISHGROUP_GYARADOS
+	assert_table_length NUM_LAKE_OF_RAGE_MAPS
 
 MapGroup_Violet:
+	table_width MAP_LENGTH, MapGroup_Violet
 	map Route32, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_32, MUSIC_ROUTE_30, FALSE, PALETTE_AUTO, FISHGROUP_QWILFISH
 	map Route35, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_35, MUSIC_ROUTE_36, FALSE, PALETTE_AUTO, FISHGROUP_POND
 	map Route36, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_36, MUSIC_ROUTE_36, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
@@ -250,8 +269,10 @@
 	map Route35NationalParkGate, TILESET_GATE, INDOOR, LANDMARK_ROUTE_35, MUSIC_GOLDENROD_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route36RuinsOfAlphGate, TILESET_GATE, GATE, LANDMARK_ROUTE_36, MUSIC_ROUTE_36, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route36NationalParkGate, TILESET_GATE, INDOOR, LANDMARK_ROUTE_36, MUSIC_GOLDENROD_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_VIOLET_MAPS
 
 MapGroup_Goldenrod:
+	table_width MAP_LENGTH, MapGroup_Goldenrod
 	map Route34, TILESET_JOHTO_MODERN, ROUTE, LANDMARK_ROUTE_34, MUSIC_ROUTE_36, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map GoldenrodCity, TILESET_JOHTO_MODERN, TOWN, LANDMARK_GOLDENROD_CITY, MUSIC_GOLDENROD_CITY, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map GoldenrodGym, TILESET_ELITE_FOUR_ROOM, INDOOR, LANDMARK_GOLDENROD_CITY, MUSIC_GYM, TRUE, PALETTE_DAY, FISHGROUP_SHORE
@@ -276,8 +297,10 @@
 	map IlexForestAzaleaGate, TILESET_GATE, GATE, LANDMARK_ROUTE_34, MUSIC_ROUTE_36, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route34IlexForestGate, TILESET_GATE, GATE, LANDMARK_ROUTE_34, MUSIC_ROUTE_36, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map DayCare, TILESET_HOUSE, INDOOR, LANDMARK_ROUTE_34, MUSIC_AZALEA_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_GOLDENROD_MAPS
 
 MapGroup_Vermilion:
+	table_width MAP_LENGTH, MapGroup_Vermilion
 	map Route6, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_6, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_POND
 	map Route11, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_11, MUSIC_ROUTE_12, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map VermilionCity, TILESET_KANTO, TOWN, LANDMARK_VERMILION_CITY, MUSIC_VERMILION_CITY, FALSE, PALETTE_AUTO, FISHGROUP_OCEAN
@@ -291,8 +314,10 @@
 	map VermilionGym, TILESET_GAME_CORNER, INDOOR, LANDMARK_VERMILION_CITY, MUSIC_GYM, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route6SaffronGate, TILESET_GATE, GATE, LANDMARK_ROUTE_6, MUSIC_ROUTE_3, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route6UndergroundPathEntrance, TILESET_GATE, GATE, LANDMARK_ROUTE_6, MUSIC_ROUTE_3, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_VERMILION_MAPS
 
 MapGroup_Pallet:
+	table_width MAP_LENGTH, MapGroup_Pallet
 	map Route1, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_1, MUSIC_ROUTE_1, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map PalletTown, TILESET_KANTO, TOWN, LANDMARK_PALLET_TOWN, MUSIC_PALLET_TOWN, FALSE, PALETTE_AUTO, FISHGROUP_OCEAN
 	map RedsHouse1F, TILESET_PLAYERS_HOUSE, INDOOR, LANDMARK_PALLET_TOWN, MUSIC_PALLET_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -299,8 +324,10 @@
 	map RedsHouse2F, TILESET_PLAYERS_HOUSE, INDOOR, LANDMARK_PALLET_TOWN, MUSIC_PALLET_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map BluesHouse, TILESET_HOUSE, INDOOR, LANDMARK_PALLET_TOWN, MUSIC_PALLET_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map OaksLab, TILESET_LAB, INDOOR, LANDMARK_PALLET_TOWN, MUSIC_POKEMON_TALK, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_PALLET_MAPS
 
 MapGroup_Pewter:
+	table_width MAP_LENGTH, MapGroup_Pewter
 	map Route3, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_3, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map PewterCity, TILESET_KANTO, TOWN, LANDMARK_PEWTER_CITY, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map PewterNidoranSpeechHouse, TILESET_HOUSE, INDOOR, LANDMARK_PEWTER_CITY, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -309,8 +336,10 @@
 	map PewterPokecenter1F, TILESET_POKECENTER, INDOOR, LANDMARK_PEWTER_CITY, MUSIC_POKEMON_CENTER, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map PewterPokecenter2FBeta, TILESET_POKECENTER, INDOOR, LANDMARK_PEWTER_CITY, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map PewterSnoozeSpeechHouse, TILESET_HOUSE, INDOOR, LANDMARK_PEWTER_CITY, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_PEWTER_MAPS
 
 MapGroup_FastShip:
+	table_width MAP_LENGTH, MapGroup_FastShip
 	map OlivinePort, TILESET_PORT, ROUTE, LANDMARK_OLIVINE_CITY, MUSIC_VIOLET_CITY, FALSE, PALETTE_AUTO, FISHGROUP_OCEAN
 	map VermilionPort, TILESET_PORT, ROUTE, LANDMARK_VERMILION_CITY, MUSIC_VERMILION_CITY, FALSE, PALETTE_AUTO, FISHGROUP_OCEAN
 	map FastShip1F, TILESET_LIGHTHOUSE, INDOOR, LANDMARK_FAST_SHIP, MUSIC_SS_AQUA, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -323,8 +352,10 @@
 	map MountMoonSquare, TILESET_KANTO, ROUTE, LANDMARK_MT_MOON, MUSIC_MT_MOON_SQUARE, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map MountMoonGiftShop, TILESET_TRADITIONAL_HOUSE, INDOOR, LANDMARK_MT_MOON, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map TinTowerRoof, TILESET_TOWER, ROUTE, LANDMARK_TIN_TOWER, MUSIC_TIN_TOWER, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
+	assert_table_length NUM_FAST_SHIP_MAPS
 
 MapGroup_Indigo:
+	table_width MAP_LENGTH, MapGroup_Indigo
 	map Route23, TILESET_KANTO, TOWN, LANDMARK_ROUTE_23, MUSIC_INDIGO_PLATEAU, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map IndigoPlateauPokecenter1F, TILESET_POKECENTER, INDOOR, LANDMARK_INDIGO_PLATEAU, MUSIC_INDIGO_PLATEAU, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map WillsRoom, TILESET_ELITE_FOUR_ROOM, INDOOR, LANDMARK_INDIGO_PLATEAU, MUSIC_INDIGO_PLATEAU, TRUE, PALETTE_DAY, FISHGROUP_SHORE
@@ -333,8 +364,10 @@
 	map KarensRoom, TILESET_ELITE_FOUR_ROOM, INDOOR, LANDMARK_INDIGO_PLATEAU, MUSIC_INDIGO_PLATEAU, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map LancesRoom, TILESET_CHAMPIONS_ROOM, INDOOR, LANDMARK_INDIGO_PLATEAU, MUSIC_INDIGO_PLATEAU, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map HallOfFame, TILESET_ICE_PATH, INDOOR, LANDMARK_INDIGO_PLATEAU, MUSIC_NEW_BARK_TOWN, TRUE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_INDIGO_MAPS
 
 MapGroup_Fuchsia:
+	table_width MAP_LENGTH, MapGroup_Fuchsia
 	map Route13, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_13, MUSIC_ROUTE_12, FALSE, PALETTE_AUTO, FISHGROUP_QWILFISH_NO_SWARM
 	map Route14, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_14, MUSIC_ROUTE_12, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map Route15, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_15, MUSIC_ROUTE_12, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
@@ -348,8 +381,10 @@
 	map FuchsiaPokecenter2FBeta, TILESET_POKECENTER, INDOOR, LANDMARK_FUCHSIA_CITY, MUSIC_CELADON_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map SafariZoneWardensHome, TILESET_HOUSE, INDOOR, LANDMARK_FUCHSIA_CITY, MUSIC_CELADON_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route15FuchsiaGate, TILESET_GATE, GATE, LANDMARK_ROUTE_15, MUSIC_ROUTE_12, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_FUCHSIA_MAPS
 
 MapGroup_Lavender:
+	table_width MAP_LENGTH, MapGroup_Lavender
 	map Route8, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_8, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map Route12, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_12, MUSIC_ROUTE_12, FALSE, PALETTE_AUTO, FISHGROUP_QWILFISH_NO_SWARM
 	map Route10South, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_10, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_LAKE
@@ -364,14 +399,18 @@
 	map LavRadioTower1F, TILESET_RADIO_TOWER, INDOOR, LANDMARK_LAV_RADIO_TOWER, MUSIC_LAVENDER_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route8SaffronGate, TILESET_GATE, GATE, LANDMARK_ROUTE_8, MUSIC_ROUTE_3, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route12SuperRodHouse, TILESET_HOUSE, INDOOR, LANDMARK_ROUTE_12, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_LAVENDER_MAPS
 
 MapGroup_Silver:
+	table_width MAP_LENGTH, MapGroup_Silver
 	map Route28, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_28, MUSIC_INDIGO_PLATEAU, FALSE, PALETTE_AUTO, FISHGROUP_POND
 	map SilverCaveOutside, TILESET_KANTO, TOWN, LANDMARK_SILVER_CAVE, MUSIC_INDIGO_PLATEAU, FALSE, PALETTE_AUTO, FISHGROUP_POND
 	map SilverCavePokecenter1F, TILESET_POKECENTER, INDOOR, LANDMARK_SILVER_CAVE, MUSIC_POKEMON_CENTER, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route28SteelWingHouse, TILESET_HOUSE, INDOOR, LANDMARK_ROUTE_28, MUSIC_AZALEA_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_SILVER_MAPS
 
 MapGroup_CableClub:
+	table_width MAP_LENGTH, MapGroup_CableClub
 	map Pokecenter2F, TILESET_POKECENTER, INDOOR, LANDMARK_SPECIAL, MUSIC_POKEMON_CENTER, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map TradeCenter, TILESET_GATE, INDOOR, LANDMARK_SPECIAL, MUSIC_CHERRYGROVE_CITY, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map Colosseum, TILESET_GATE, INDOOR, LANDMARK_SPECIAL, MUSIC_CHERRYGROVE_CITY, TRUE, PALETTE_DAY, FISHGROUP_SHORE
@@ -378,8 +417,10 @@
 	map TimeCapsule, TILESET_GATE, INDOOR, LANDMARK_SPECIAL, MUSIC_CHERRYGROVE_CITY, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map MobileTradeRoom, TILESET_MANSION, INDOOR, LANDMARK_SPECIAL, MUSIC_CHERRYGROVE_CITY, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map MobileBattleRoom, TILESET_MANSION, INDOOR, LANDMARK_SPECIAL, MUSIC_CHERRYGROVE_CITY, TRUE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_CABLE_CLUB_MAPS
 
 MapGroup_Celadon:
+	table_width MAP_LENGTH, MapGroup_Celadon
 	map Route7, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_7, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map Route16, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_16, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map Route17, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_17, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_NONE
@@ -406,8 +447,10 @@
 	map Route16Gate, TILESET_GATE, GATE, LANDMARK_ROUTE_16, MUSIC_ROUTE_3, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route7SaffronGate, TILESET_GATE, GATE, LANDMARK_ROUTE_7, MUSIC_ROUTE_3, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route17Route18Gate, TILESET_GATE, GATE, LANDMARK_ROUTE_17, MUSIC_ROUTE_3, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_CELADON_MAPS
 
 MapGroup_Cianwood:
+	table_width MAP_LENGTH, MapGroup_Cianwood
 	map Route40, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_40, MUSIC_ROUTE_36, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map Route41, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_41, MUSIC_ROUTE_36, FALSE, PALETTE_AUTO, FISHGROUP_OCEAN
 	map CianwoodCity, TILESET_JOHTO, TOWN, LANDMARK_CIANWOOD_CITY, MUSIC_ECRUTEAK_CITY, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
@@ -424,8 +467,10 @@
 	map BattleTowerHallway, TILESET_BATTLE_TOWER_INSIDE, INDOOR, LANDMARK_BATTLE_TOWER, MUSIC_BATTLE_TOWER_THEME, TRUE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route40BattleTowerGate, TILESET_GATE, GATE, LANDMARK_BATTLE_TOWER, MUSIC_ROUTE_36, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map BattleTowerOutside, TILESET_BATTLE_TOWER_OUTSIDE, ROUTE, LANDMARK_BATTLE_TOWER, MUSIC_BATTLE_TOWER_THEME, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
+	assert_table_length NUM_CIANWOOD_MAPS
 
 MapGroup_Viridian:
+	table_width MAP_LENGTH, MapGroup_Viridian
 	map Route2, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_2, MUSIC_ROUTE_2, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map Route22, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_22, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_POND
 	map ViridianCity, TILESET_KANTO, TOWN, LANDMARK_VIRIDIAN_CITY, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_AUTO, FISHGROUP_POND
@@ -439,8 +484,10 @@
 	map Route2NuggetHouse, TILESET_HOUSE, INDOOR, LANDMARK_ROUTE_2, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route2Gate, TILESET_GATE, GATE, LANDMARK_ROUTE_2, MUSIC_ROUTE_2, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map VictoryRoadGate, TILESET_GATE, GATE, LANDMARK_ROUTE_26, MUSIC_INDIGO_PLATEAU, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_VIRIDIAN_MAPS
 
 MapGroup_NewBark:
+	table_width MAP_LENGTH, MapGroup_NewBark
 	map Route26, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_26, MUSIC_ROUTE_26, FALSE, PALETTE_AUTO, FISHGROUP_OCEAN
 	map Route27, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_27, MUSIC_ROUTE_26, FALSE, PALETTE_AUTO, FISHGROUP_OCEAN
 	map Route29, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_29, MUSIC_ROUTE_29, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
@@ -454,8 +501,10 @@
 	map DayOfWeekSiblingsHouse, TILESET_HOUSE, INDOOR, LANDMARK_ROUTE_26, MUSIC_AZALEA_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route27SandstormHouse, TILESET_HOUSE, INDOOR, LANDMARK_ROUTE_27, MUSIC_AZALEA_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route29Route46Gate, TILESET_GATE, GATE, LANDMARK_ROUTE_29, MUSIC_ROUTE_29, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_NEW_BARK_MAPS
 
 MapGroup_Saffron:
+	table_width MAP_LENGTH, MapGroup_Saffron
 	map Route5, TILESET_KANTO, ROUTE, LANDMARK_ROUTE_5, MUSIC_ROUTE_3, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map SaffronCity, TILESET_KANTO, TOWN, LANDMARK_SAFFRON_CITY, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
 	map FightingDojo, TILESET_TRAIN_STATION, INDOOR, LANDMARK_SAFFRON_CITY, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
@@ -471,8 +520,10 @@
 	map Route5UndergroundPathEntrance, TILESET_GATE, GATE, LANDMARK_ROUTE_5, MUSIC_ROUTE_3, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route5SaffronGate, TILESET_GATE, GATE, LANDMARK_ROUTE_5, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route5CleanseTagHouse, TILESET_HOUSE, INDOOR, LANDMARK_ROUTE_5, MUSIC_VIRIDIAN_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_SAFFRON_MAPS
 
 MapGroup_Cherrygrove:
+	table_width MAP_LENGTH, MapGroup_Cherrygrove
 	map Route30, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_30, MUSIC_ROUTE_30, FALSE, PALETTE_AUTO, FISHGROUP_POND
 	map Route31, TILESET_JOHTO, ROUTE, LANDMARK_ROUTE_31, MUSIC_ROUTE_30, FALSE, PALETTE_AUTO, FISHGROUP_POND
 	map CherrygroveCity, TILESET_JOHTO, TOWN, LANDMARK_CHERRYGROVE_CITY, MUSIC_CHERRYGROVE_CITY, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
@@ -484,3 +535,4 @@
 	map Route30BerryHouse, TILESET_HOUSE, INDOOR, LANDMARK_ROUTE_30, MUSIC_CHERRYGROVE_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map MrPokemonsHouse, TILESET_FACILITY, INDOOR, LANDMARK_ROUTE_30, MUSIC_CHERRYGROVE_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE
 	map Route31VioletGate, TILESET_GATE, GATE, LANDMARK_ROUTE_31, MUSIC_ROUTE_30, FALSE, PALETTE_DAY, FISHGROUP_SHORE
+	assert_table_length NUM_CHERRYGROVE_MAPS
--- a/data/maps/outdoor_sprites.asm
+++ b/data/maps/outdoor_sprites.asm
@@ -2,7 +2,7 @@
 ; Maps with environment ROUTE or TOWN can only use these sprites.
 
 OutdoorSprites:
-; entries correspond to map groups
+; entries correspond to MAPGROUP_* constants
 	table_width 2, OutdoorSprites
 	dw OlivineGroupSprites
 	dw MahoganyGroupSprites
--- a/data/maps/roofs.asm
+++ b/data/maps/roofs.asm
@@ -8,7 +8,7 @@
 NUM_ROOFS EQU const_value
 
 MapGroupRoofs:
-; entries correspond to map groups
+; entries correspond to MAPGROUP_* constants
 ; values are indexes for Roofs (see below)
 	table_width 1, MapGroupRoofs
 	db -1             ;  0
--- a/engine/overworld/warp_connection.asm
+++ b/engine/overworld/warp_connection.asm
@@ -176,14 +176,14 @@
 ; Dig and Escape Rope should not take you to them.
 	ld a, [wPrevMapGroup]
 	cp GROUP_MOUNT_MOON_SQUARE
+	jr nz, .not_mt_moon_square_or_tin_tower_roof
 	assert GROUP_MOUNT_MOON_SQUARE == GROUP_TIN_TOWER_ROOF
-	jr nz, .not_mt_moon_or_tin_tower
 	ld a, [wPrevMapNumber]
 	cp MAP_MOUNT_MOON_SQUARE
 	ret z
 	cp MAP_TIN_TOWER_ROOF
 	ret z
-.not_mt_moon_or_tin_tower
+.not_mt_moon_square_or_tin_tower_roof
 
 	ld a, [wPrevWarp]
 	ld [wDigWarpNumber], a
--- a/engine/phone/scripts/mom.asm
+++ b/engine/phone/scripts/mom.asm
@@ -15,9 +15,9 @@
 	farwritetext MomPhoneGreetingText
 	promptbutton
 	getcurlandmarkname STRING_BUFFER_3
-	readvar VAR_ROOFPALETTE
-	ifequal 1, MomPhonePalette1
-	ifequal 2, MomPhonePalette2
+	readvar VAR_ENVIRONMENT
+	ifequal TOWN, MomPhoneInTown
+	ifequal ROUTE, MomPhoneOnRoute
 	sjump MomPhoneOther
 
 MomPhoneLandmark:
@@ -25,7 +25,7 @@
 	promptbutton
 	sjump MomSavingMoney
 
-MomPhonePalette1:
+MomPhoneInTown:
 	readvar VAR_MAPGROUP
 	ifequal GROUP_NEW_BARK_TOWN, .newbark
 	ifequal GROUP_CHERRYGROVE_CITY, .cherrygrove
@@ -56,7 +56,7 @@
 	getlandmarkname STRING_BUFFER_4, LANDMARK_RADIO_TOWER
 	sjump MomPhoneLandmark
 
-MomPhonePalette2:
+MomPhoneOnRoute:
 	farwritetext MomOtherAreaText
 	promptbutton
 	sjump MomSavingMoney
--- a/gfx/tileset_palette_maps.asm
+++ b/gfx/tileset_palette_maps.asm
@@ -109,7 +109,7 @@
 INCLUDE "gfx/tilesets/battle_tower_outside_palette_map.asm"
 
 MapGroupPalettes: ; unreferenced
-; entries correspond to GROUP_* constants
+; entries correspond to MAPGROUP_* constants
 rept NUM_MAP_GROUPS
 	db PAL_BG_ROOF
 endr