shithub: pokecrystal

Download patch

ref: 20d6c1d876cde19061c458761c7283163e316d8a
parent: 10a1e6c860f3ab1ec3ebfd74fdd5979613f5d04b
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Sun Dec 24 08:08:38 EST 2017

Rename "map permissions" to "map environment" (fix #396)

--- a/constants/map_constants.asm
+++ b/constants/map_constants.asm
@@ -3,17 +3,30 @@
 GROUP_NONE EQU 0
 MAP_NONE   EQU 0
 
-; map permissions (wPermission)
+; map header fields (see maps/map_headers.asm)
+	const_def
+	const MAPHEADER_MAPHEADER2_BANK ; 0
+	const MAPHEADER_TILESET         ; 1
+	const MAPHEADER_ENVIRONMENT     ; 2
+	const MAPHEADER_MAPHEADER2      ; 3
+	const MAPHEADER_MAPHEADER2_HI   ; 4
+	const MAPHEADER_LOCATION        ; 5
+	const MAPHEADER_MUSIC           ; 6
+	const MAPHEADER_PALETTE         ; 7
+	const MAPHEADER_FISHGROUP       ; 8
+NUM_MAPHEADER_ATTRIBUTES EQU const_value
+
+; map environments (wEnvironment)
 const_value SET 1
 	const TOWN
 	const ROUTE
 	const INDOOR
 	const CAVE
-	const PERM_5
+	const ENVIRONMENT_5
 	const GATE
 	const DUNGEON
 
-; map palettes (wPermission)
+; map palettes (wEnvironment)
 	const_def
 	const PALETTE_AUTO
 	const PALETTE_DAY
--- a/constants/trainer_constants.asm
+++ b/constants/trainer_constants.asm
@@ -680,13 +680,13 @@
 
 ; TrainerClassAttributes fields (see data/trainers/trainer_attributes.asm)
 	const_def
-	const TRNATTR_ITEM1
-	const TRNATTR_ITEM2
-	const TRNATTR_BASEMONEY
-	const TRNATTR_AI_MOVE_WEIGHTS
-	const TRNATTR_AI2
-	const TRNATTR_AI_ITEM_SWITCH
-	const TRNATTR_AI4
+	const TRNATTR_ITEM1           ; 0
+	const TRNATTR_ITEM2           ; 1
+	const TRNATTR_BASEMONEY       ; 2
+	const TRNATTR_AI_MOVE_WEIGHTS ; 3
+	const TRNATTR_AI2             ; 4
+	const TRNATTR_AI_ITEM_SWITCH  ; 5
+	const TRNATTR_AI4             ; 6
 NUM_TRAINER_ATTRIBUTES EQU const_value
 
 ; TRNATTR_AI_MOVE_WEIGHTS bit flags (wEnemyTrainerAIFlags)
--- a/data/maps/outdoor_sprites.asm
+++ b/data/maps/outdoor_sprites.asm
@@ -1,5 +1,5 @@
 ; Valid sprite IDs for each map group.
-; Maps with permission ROUTE or TOWN can only use these sprites.
+; Maps with environment ROUTE or TOWN can only use these sprites.
 
 OutdoorSprites: ; 144b8
 	dw OlivineGroupSprites
--- a/engine/battle_transition.asm
+++ b/engine/battle_transition.asm
@@ -208,10 +208,10 @@
 	jr nc, .okay
 	set 0, e
 .okay
-	ld a, [wPermission]
+	ld a, [wEnvironment]
 	cp CAVE
 	jr z, .okay2
-	cp PERM_5
+	cp ENVIRONMENT_5
 	jr z, .okay2
 	cp DUNGEON
 	jr z, .okay2
--- a/engine/color.asm
+++ b/engine/color.asm
@@ -1310,7 +1310,7 @@
 	jr c, .got_pals
 
 	; Which palette group is based on whether we're outside or inside
-	ld a, [wPermission]
+	ld a, [wEnvironment]
 	and 7
 	ld e, a
 	ld d, 0
@@ -1377,7 +1377,7 @@
 	ld a, BANK(UnknOBPals)
 	call FarCopyWRAM
 
-	ld a, [wPermission]
+	ld a, [wEnvironment]
 	cp TOWN
 	jr z, .outside
 	cp ROUTE
@@ -1411,7 +1411,7 @@
 	dw .OutdoorColors ; ROUTE
 	dw .IndoorColors  ; INDOOR
 	dw .DungeonColors ; CAVE
-	dw .Perm5Colors   ; PERM_5
+	dw .Perm5Colors   ; ENVIRONMENT_5
 	dw .IndoorColors  ; GATE
 	dw .DungeonColors ; DUNGEON
 
--- a/engine/events_2.asm
+++ b/engine/events_2.asm
@@ -152,7 +152,7 @@
 	ld hl, StatusFlags
 	bit 5, [hl]
 	jr nz, .no
-	ld a, [wPermission]
+	ld a, [wEnvironment]
 	cp CAVE
 	jr z, .ice_check
 	cp DUNGEON
--- a/engine/events_3.asm
+++ b/engine/events_3.asm
@@ -18,7 +18,7 @@
 	call .CheckNationalParkGate
 	jr z, .nationalparkgate
 
-	call GetMapPermission
+	call GetMapEnvironment
 	cp GATE
 	jr nz, .not_gate
 
--- a/engine/map_setup.asm
+++ b/engine/map_setup.asm
@@ -362,10 +362,10 @@
 	jr z, .surfing
 	cp PLAYER_SURF_PIKA
 	jr z, .surfing
-	call GetMapPermission
+	call GetMapEnvironment
 	cp INDOOR
 	jr z, .checkbiking
-	cp PERM_5
+	cp ENVIRONMENT_5
 	jr z, .checkbiking
 	cp DUNGEON
 	jr z, .checkbiking
--- a/engine/overworld.asm
+++ b/engine/overworld.asm
@@ -112,7 +112,7 @@
 
 
 AddMapSprites: ; 141c9
-	call GetMapPermission
+	call GetMapEnvironment
 	call CheckOutdoorMap
 	jr z, .outdoor
 	call AddIndoorSprites
@@ -179,7 +179,7 @@
 
 	ld c, EMOTE_SHADOW
 	farcall LoadEmote
-	call GetMapPermission
+	call GetMapEnvironment
 	call CheckOutdoorMap
 	ld c, EMOTE_GRASS_RUSTLE
 	jr z, .outdoor
--- a/engine/phone/phone.asm
+++ b/engine/phone/phone.asm
@@ -308,7 +308,7 @@
 	ret
 
 SpecialCallOnlyWhenOutside: ; 90188
-	ld a, [wPermission]
+	ld a, [wEnvironment]
 	cp TOWN
 	jr z, .outside
 	cp ROUTE
--- a/engine/sgb_layouts.asm
+++ b/engine/sgb_layouts.asm
@@ -562,7 +562,7 @@
 	ret
 
 .morn_day
-	ld a, [wPermission]
+	ld a, [wEnvironment]
 	cp ROUTE
 	jr z, .route
 	cp CAVE
@@ -569,7 +569,7 @@
 	jr z, .cave
 	cp DUNGEON
 	jr z, .cave
-	cp PERM_5
+	cp ENVIRONMENT_5
 	jr z, .perm5
 	cp GATE
 	jr z, .gate
--- a/engine/variables.asm
+++ b/engine/variables.asm
@@ -53,7 +53,7 @@
 	dwb MapGroup,                       RETVAR_STRBUF2
 	dwb MapNumber,                      RETVAR_STRBUF2
 	dwb .UnownCaught,                   RETVAR_EXECUTE
-	dwb wPermission,                    RETVAR_STRBUF2
+	dwb wEnvironment,                    RETVAR_STRBUF2
 	dwb .BoxFreeSpace,                  RETVAR_EXECUTE
 	dwb wBugContestMinsRemaining,       RETVAR_STRBUF2
 	dwb XCoord,                         RETVAR_STRBUF2
--- a/engine/warp_connection.asm
+++ b/engine/warp_connection.asm
@@ -164,7 +164,7 @@
 	ret
 
 .SaveDigWarp: ; 1046df (41:46df)
-	call GetMapPermission
+	call GetMapEnvironment
 	call CheckOutdoorMap
 	ret nz
 	ld a, [wNextMapGroup]
@@ -171,7 +171,7 @@
 	ld b, a
 	ld a, [wNextMapNumber]
 	ld c, a
-	call GetAnyMapPermission
+	call GetAnyMapEnvironment
 	call CheckIndoorMap
 	ret nz
 	ld a, [wPrevMapGroup]
@@ -192,7 +192,7 @@
 	ret
 
 .SetSpawn: ; 104718 (41:4718)
-	call GetMapPermission
+	call GetMapEnvironment
 	call CheckOutdoorMap
 	ret nz
 	ld a, [wNextMapGroup]
@@ -199,7 +199,7 @@
 	ld b, a
 	ld a, [wNextMapNumber]
 	ld c, a
-	call GetAnyMapPermission
+	call GetAnyMapEnvironment
 	call CheckIndoorMap
 	ret nz
 	ld a, [wNextMapGroup]
--- a/event/magnet_train.asm
+++ b/event/magnet_train.asm
@@ -434,13 +434,13 @@
 	ld [rSVBK], a
 	ld a, [TimeOfDayPal]
 	push af
-	ld a, [wPermission]
+	ld a, [wEnvironment]
 	push af
 	ld a, [TimeOfDay]
 	and $3
 	ld [TimeOfDayPal], a
 	ld a, $1
-	ld [wPermission], a
+	ld [wEnvironment], a
 	ld b, SCGB_MAPPALS
 	call GetSGBLayout
 	call UpdateTimePals
@@ -451,7 +451,7 @@
 	ld a, [rOBP1]
 	ld [wOBP1], a
 	pop af
-	ld [wPermission], a
+	ld [wEnvironment], a
 	pop af
 	ld [TimeOfDayPal], a
 	pop af
--- a/event/overworld.asm
+++ b/event/overworld.asm
@@ -571,7 +571,7 @@
 	ld de, ENGINE_STORMBADGE
 	call CheckBadge
 	jr c, .nostormbadge
-	call GetMapPermission
+	call GetMapEnvironment
 	call CheckOutdoorMap
 	jr z, .outdoors
 	jr .indoors
@@ -783,7 +783,7 @@
 	dw .FailDig
 
 .CheckCanDig: ; cbb8
-	call GetMapPermission
+	call GetMapEnvironment
 	cp CAVE
 	jr z, .incave
 	cp DUNGEON
@@ -905,7 +905,7 @@
 	dw .FailTeleport
 
 .TryTeleport: ; cc78
-	call GetMapPermission
+	call GetMapEnvironment
 	call CheckOutdoorMap
 	jr z, .CheckIfSpawnPoint
 	jr .nope
@@ -1714,7 +1714,7 @@
 	ret
 
 .CheckEnvironment: ; d121
-	call GetMapPermission
+	call GetMapEnvironment
 	call CheckOutdoorMap
 	jr z, .ok
 	cp CAVE
--- a/home/flag.asm
+++ b/home/flag.asm
@@ -14,7 +14,7 @@
 ; 2e5d
 
 ResetFlashIfOutOfCave:: ; 2e5d
-	ld a, [wPermission]
+	ld a, [wEnvironment]
 	cp $2
 	jr z, .asm_2e69
 	cp $1
--- a/home/map.asm
+++ b/home/map.asm
@@ -389,7 +389,7 @@
 	ret z
 	cp GATE
 	ret z
-	cp PERM_5
+	cp ENVIRONMENT_5
 	ret
 ; 2309
 
@@ -2154,7 +2154,7 @@
 GetAnyMapBank:: ; 2c31
 	push hl
 	push de
-	ld de, 0
+	ld de, MAPHEADER_MAPHEADER2_BANK
 	call GetAnyMapHeaderMember
 	ld a, c
 	pop de
@@ -2163,7 +2163,7 @@
 ; 2c3d
 
 PartiallyCopyMapHeader:: ; 2c3d
-; Copy second map header bank, tileset, permission, and second map header address
+; Copy second map header bank, tileset, environment, and second map header address
 ; from the current map's map header.
 	ld a, [hROMBank]
 	push af
@@ -2198,7 +2198,7 @@
 	push bc
 
 	push bc
-	ld de, 3 ; second map header pointer
+	ld de, MAPHEADER_MAPHEADER2
 	call GetAnyMapHeaderMember
 	ld l, c
 	ld h, b
@@ -2205,11 +2205,11 @@
 	pop bc
 
 	push hl
-	ld de, 0 ; second map header bank
+	ld de, MAPHEADER_MAPHEADER2_BANK
 	call GetAnyMapHeaderMember
 	pop hl
 
-	ld de, 3 ; blockdata bank
+	ld de, MAPHEADER_MAPHEADER2 ; blockdata bank
 	add hl, de
 	ld a, c
 	call GetFarByte
@@ -2225,7 +2225,7 @@
 ; returns the current map's secondary map header pointer in hl.
 	push bc
 	push de
-	ld de, 3 ; secondary map header pointer (offset within header)
+	ld de, MAPHEADER_MAPHEADER2
 	call GetMapHeaderMember
 	ld l, c
 	ld h, b
@@ -2234,11 +2234,11 @@
 	ret
 ; 2c8a
 
-GetMapPermission:: ; 2c8a
+GetMapEnvironment:: ; 2c8a
 	push hl
 	push de
 	push bc
-	ld de, 2 ; permission
+	ld de, MAPHEADER_ENVIRONMENT
 	call GetMapHeaderMember
 	ld a, c
 	pop bc
@@ -2250,11 +2250,11 @@
 	ret ; XXX
 ; 2c99
 
-GetAnyMapPermission:: ; 2c99
+GetAnyMapEnvironment:: ; 2c99
 	push hl
 	push de
 	push bc
-	ld de, 2 ; permission
+	ld de, MAPHEADER_ENVIRONMENT
 	call GetAnyMapHeaderMember
 	ld a, c
 	pop bc
@@ -2264,7 +2264,7 @@
 ; 2ca7
 
 GetAnyMapTileset:: ; 2ca7
-	ld de, 1 ; tileset
+	ld de, MAPHEADER_TILESET
 	call GetAnyMapHeaderMember
 	ld a, c
 	ret
@@ -2276,7 +2276,7 @@
 	push de
 	push bc
 
-	ld de, 5 ; landmark
+	ld de, MAPHEADER_LOCATION
 	call GetAnyMapHeaderMember
 	ld a, c
 
@@ -2289,7 +2289,7 @@
 GetMapHeaderMusic:: ; 2cbd
 	push hl
 	push bc
-	ld de, 6 ; music
+	ld de, MAPHEADER_MUSIC
 	call GetMapHeaderMember
 	ld a, c
 	cp MUSIC_MAHOGANY_MART
@@ -2348,7 +2348,7 @@
 	push hl
 	push bc
 
-	ld de, 7 ; phone service and time of day
+	ld de, MAPHEADER_PALETTE
 	call GetMapHeaderMember
 	ld a, c
 
@@ -2362,7 +2362,7 @@
 	push hl
 	push bc
 
-	ld de, 8 ; fishing group
+	ld de, MAPHEADER_FISHGROUP
 	call GetMapHeaderMember
 	ld a, c
 
--- a/maps/map_headers.asm
+++ b/maps/map_headers.asm
@@ -1,7 +1,7 @@
 map_header: macro
 ;\1: map label
 ;\2: tileset: a TILESET_* constant
-;\3: permission: TOWN, ROUTE, INDOOR, CAVE, PERM_5, GATE, or DUNGEON
+;\3: environment: TOWN, ROUTE, INDOOR, CAVE, ENVIRONMENT_5, GATE, or DUNGEON
 ;\4: location: from constants/landmark_constants.asm
 ;\5: music: a MUSIC_* constant
 ;\6: phone service flag: 1 to prevent phone calls
--- a/tilesets/special_palettes.asm
+++ b/tilesets/special_palettes.asm
@@ -25,7 +25,7 @@
 	ret
 
 .ice_path
-	ld a, [wPermission] ; permission
+	ld a, [wEnvironment]
 	and $7
 	cp INDOOR ; Hall of Fame
 	jr z, .do_nothing
--- a/wram.asm
+++ b/wram.asm
@@ -1935,7 +1935,7 @@
 
 wSecondMapHeaderBank:: db ; d198
 wTileset:: db ; d199
-wPermission:: db ; d19a
+wEnvironment:: db ; d19a
 wSecondMapHeaderAddr:: dw ; d19b
 
 ; width/height are in blocks (2x2 walkable tiles, 4x4 graphics tiles)