shithub: pokecrystal

Download patch

ref: c087d44c420a25dc95f61690e8d3c82932187d67
parent: 2a263629a40e201b1702e2f4e65f1c61360cc2b2
author: PikalaxALT <[email protected]>
date: Mon Jan 4 03:43:55 EST 2016

more gfx-related labels

--- a/battle/core.asm
+++ b/battle/core.asm
@@ -9167,11 +9167,11 @@
 
 
 Function3fa42: ; 3fa42
-	ld hl, wd276
+	ld hl, OTPlayerID
 	ld de, StringBuffer1
 	ld bc, 2
 	call CopyBytes
-	ld hl, wd26b
+	ld hl, OTPlayerName
 	ld bc, 10
 	call CopyBytes
 	ld hl, s1_b254
--- a/engine/color.asm
+++ b/engine/color.asm
@@ -109,7 +109,7 @@
 ; 8ad1
 
 
-Function8ad1: ; 8ad1
+InitPartyMenuPalettes: ; 8ad1
 	ld hl, PalPacket_9c56 + 1
 	call CopyFourPalettes
 	call InitPartyMenuOBPals
@@ -145,16 +145,17 @@
 ; 8b07
 
 Function8b07: ; 8b07
+; Unreferenced
 	call CheckCGB
 	ret z
-	ld hl, Palette8b2f
+	ld hl, .BGPal
 	ld de, UnknBGPals
 	ld bc, 1 palettes
 	ld a, $5
 	call FarCopyWRAM
 
-	ld hl, Palette8b37
-	ld de, MartPointer
+	ld hl, .OBPal
+	ld de, UnknOBPals
 	ld bc, 1 palettes
 	ld a, $5
 	call FarCopyWRAM
@@ -163,17 +164,14 @@
 	ld a, $1
 	ld [hCGBPalUpdate], a
 	ret
-; 8b2f
 
-Palette8b2f: ; 8b2f
+.BGPal
 	RGB 31, 31, 31
 	RGB 18, 23, 31
 	RGB 15, 20, 31
 	RGB 00, 00, 00
 
-; 8b37
-
-Palette8b37: ; 8b37
+.OBPal
 	RGB 31, 31, 31
 	RGB 31, 31, 12
 	RGB 08, 16, 28
@@ -182,6 +180,7 @@
 ; 8b3f
 
 Function8b3f: ; 8b3f
+; Unreferenced
 	call CheckCGB
 	ret nz
 	ld a, [hSGB]
@@ -193,7 +192,7 @@
 
 Function8b4d: ; 8b4d
 	call CheckCGB
-	jr nz, .asm_8b5c
+	jr nz, .cgb
 	ld a, [hSGB]
 	and a
 	ret z
@@ -200,7 +199,7 @@
 	ld hl, PalPacket_9c26
 	jp Function9809
 
-.asm_8b5c
+.cgb
 	ld de, UnknOBPals
 	ld a, $3b
 	call GetPredefPal
@@ -209,7 +208,7 @@
 
 Function8b67: ; 8b67
 	call CheckCGB
-	jr nz, .asm_8b76
+	jr nz, .cgb
 	ld a, [hSGB]
 	and a
 	ret z
@@ -216,7 +215,7 @@
 	ld hl, PalPacket_9c36
 	jp Function9809
 
-.asm_8b76
+.cgb
 	ld de, UnknOBPals
 	ld a, $3c
 	call GetPredefPal
@@ -934,13 +933,13 @@
 	push af
 	set 7, a
 	ld [wcfbe], a
-	call Function981a
+	call PushSGBPals
 	pop af
 	ld [wcfbe], a
 	ret
 ; 981a
 
-Function981a: ; 981a
+PushSGBPals: ; 981a
 	ld a, [hl]
 	and $7
 	ret z
@@ -1004,7 +1003,7 @@
 	call SGBDelayCycles
 	call Function993f
 	ld hl, PalPacket_9d66
-	call Function981a
+	call PushSGBPals
 
 .asm_988a
 	pop af
@@ -1020,7 +1019,7 @@
 	ld a, $1
 	ld [rVBK], a
 	ld hl, VTiles0
-	ld bc, $2000
+	ld bc, $200 tiles
 	xor a
 	call ByteFill
 	ld a, $0
@@ -1027,43 +1026,42 @@
 	ld [rVBK], a
 	ld a, $80
 	ld [rBGPI], a
-	ld c, $20
-.asm_98ac
-	ld a, $ff
+	ld c, 4 * 8
+.bgpals_loop
+	ld a, $7fff % $100
 	ld [rBGPD], a
-	ld a, $7f
+	ld a, $7fff / $100
 	ld [rBGPD], a
 	dec c
-	jr nz, .asm_98ac
+	jr nz, .bgpals_loop
 	ld a, $80
 	ld [rOBPI], a
-	ld c, $20
-.asm_98bd
-	ld a, $ff
+	ld c, 4 * 8
+.obpals_loop
+	ld a, $7fff % $100
 	ld [rOBPD], a
-	ld a, $7f
+	ld a, $7fff / $100
 	ld [rOBPD], a
 	dec c
-	jr nz, .asm_98bd
+	jr nz, .obpals_loop
 	ld a, [rSVBK]
 	push af
 	ld a, $5
 	ld [rSVBK], a
 	ld hl, UnknBGPals
-	call Function98df
+	call .LoadWhitePals
 	ld hl, BGPals
-	call Function98df
+	call .LoadWhitePals
 	pop af
 	ld [rSVBK], a
 	ret
-; 98df
 
-Function98df: ; 98df
-	ld c, $40
+.LoadWhitePals
+	ld c, 4 * 16
 .loop
-	ld a, $ff
+	ld a, $7fff % $100
 	ld [hli], a
-	ld a, $7f
+	ld a, $7fff / $100
 	ld [hli], a
 	dec c
 	jr nz, .loop
@@ -1071,24 +1069,24 @@
 ; 98eb
 
 Function98eb: ; 98eb
-	ld hl, Unknown_98ff
-	ld c, $9
-.asm_98f0
+	ld hl, .PalPacketPointerTable
+	ld c, 9
+.loop
 	push bc
 	ld a, [hli]
 	push hl
 	ld h, [hl]
 	ld l, a
-	call Function981a
+	call PushSGBPals
 	pop hl
 	inc hl
 	pop bc
 	dec c
-	jr nz, .asm_98f0
+	jr nz, .loop
 	ret
 ; 98ff
 
-Unknown_98ff: ; 98ff
+.PalPacketPointerTable: ; 98ff
 	dw PalPacket_9d56
 	dw PalPacket_9d76
 	dw PalPacket_9d86
@@ -1105,18 +1103,18 @@
 	xor a
 	ld [rJOYP], a
 	ld hl, PalPacket_9d56
-	call Function981a
+	call PushSGBPals
 	call Function992c
 	call SGBDelayCycles
 	call Function993f
 	ld hl, PalPacket_9d66
-	call Function981a
+	call PushSGBPals
 	ei
 	ret
 ; 992c
 
 Function992c: ; 992c
-	call Function9938
+	call .LoadSGBBorderPointers
 	push de
 	call Function9a24
 	pop hl
@@ -1124,7 +1122,7 @@
 	ret
 ; 9938
 
-Function9938: ; 9938
+.LoadSGBBorderPointers: ; 9938
 	ld hl, SGBBorder
 	ld de, SGBBorderMap
 	ret
@@ -1140,7 +1138,7 @@
 
 Function994a: ; 994a
 	ld hl, PalPacket_9d26
-	call Function981a
+	call PushSGBPals
 	call SGBDelayCycles
 	ld a, [rJOYP]
 	and $3
@@ -1186,7 +1184,7 @@
 
 Function99ab: ; 99ab
 	ld hl, PalPacket_9d16
-	call Function981a
+	call PushSGBPals
 	jp SGBDelayCycles
 ; 99b4
 
@@ -1202,7 +1200,7 @@
 	ld a, $e3
 	ld [rLCDC], a
 	ld hl, PalPacket_9d06
-	call Function981a
+	call PushSGBPals
 	xor a
 	ld [rBGP], a
 	ret
@@ -1215,7 +1213,7 @@
 	ld de, VTiles1
 	ld bc, 20 tiles
 	call CopyData
-	ld b, $12
+	ld b, 18
 .asm_99ea
 	push bc
 	ld bc, $c
@@ -1237,7 +1235,7 @@
 	ld a, $e3
 	ld [rLCDC], a
 	ld hl, PalPacket_9d46
-	call Function981a
+	call PushSGBPals
 	xor a
 	ld [rBGP], a
 	ret
@@ -1245,15 +1243,15 @@
 
 Function9a24: ; 9a24
 	call DisableLCD
-	ld a, $e4
+	ld a, %11100100
 	ld [rBGP], a
 	ld de, VTiles1
 	ld b, $80
 .asm_9a30
 	push bc
-	ld bc, 2 palettes
+	ld bc, 1 tiles
 	call CopyData
-	ld bc, 2 palettes
+	ld bc, 1 tiles
 	call ClearBytes
 	pop bc
 	dec b
@@ -1262,7 +1260,7 @@
 	ld a, $e3
 	ld [rLCDC], a
 	ld hl, PalPacket_9d36
-	call Function981a
+	call PushSGBPals
 	xor a
 	ld [rBGP], a
 	ret
@@ -1295,7 +1293,7 @@
 DrawDefaultTiles: ; 0x9a64
 ; Draw 240 tiles (2/3 of the screen) from tiles in VRAM
 	hlbgcoord 0, 0 ; BG Map 0
-	ld de, 32 - 20
+	ld de, BG_MAP_WIDTH - SCREEN_WIDTH
 	ld a, $80 ; starting tile
 	ld c, 12 + 1
 .line
--- a/engine/events.asm
+++ b/engine/events.asm
@@ -227,7 +227,7 @@
 ; 967d1
 
 Function967d1: ; 967d1
-	callba Function576a ; engine/map_objects.asm
+	callba HandleNPCStep ; engine/map_objects.asm
 	callba _HandlePlayerStep
 	call _CheckObjectEnteringVisibleRange
 	ret
--- a/engine/link.asm
+++ b/engine/link.asm
@@ -184,7 +184,7 @@
 	call Function29dba
 	ld a, [ScriptVar]
 	and a
-	jp z, Function283b2
+	jp z, LinkTimeout
 	ld a, [hLinkPlayerNumber]
 	cp $2
 	jr nz, .Player1
@@ -397,11 +397,11 @@
 	ld de, OTPartyCount
 	ld bc, 8
 	call CopyBytes
-	ld de, wd276
+	ld de, OTPlayerID
 	ld bc, 2
 	call CopyBytes
-	ld de, OTPartyMon1Species
-	ld bc, $1a4
+	ld de, OTPartyMons
+	ld bc, OTPartyDataEnd - OTPartyMons
 	call CopyBytes
 	ld a, OTPartyMonOT % $100
 	ld [wd102], a
@@ -419,7 +419,7 @@
 	ld a, CAL
 	ld [OtherTrainerClass], a
 	call ClearScreen
-	callba Function4d354
+	callba Link_WaitBGMap
 	ld hl, Options
 	ld a, [hl]
 	push af
@@ -468,9 +468,9 @@
 	jp InitTradeMenuDisplay
 ; 283b2
 
-Function283b2: ; 283b2
+LinkTimeout: ; 283b2
 	ld de, .TooMuchTimeHasElapsed
-	ld b, $a
+	ld b, 10
 .loop
 	call DelayFrame
 	call LinkDataReceived
@@ -1379,7 +1379,7 @@
 	hlcoord 2, 16
 	ld de, .String_Stats_Trade
 	call PlaceString
-	callba Function4d354
+	callba Link_WaitBGMap
 
 .joy_loop
 	ld a, " "
@@ -1485,7 +1485,7 @@
 	ld b, 4
 	ld c, 18
 	call Predef_LinkTextbox
-	callba Function4d354
+	callba Link_WaitBGMap
 	ld hl, .Text_CantTradeLastMon
 	bccoord 1, 14
 	call PlaceWholeStringInBoxAtOnce
@@ -1507,7 +1507,7 @@
 	ld b, 4
 	ld c, 18
 	call Predef_LinkTextbox
-	callba Function4d354
+	callba Link_WaitBGMap
 	ld hl, .Text_Abnormal
 	bccoord 1, 14
 	call PlaceWholeStringInBoxAtOnce
@@ -1663,7 +1663,7 @@
 	ld b, $4
 	ld c, $12
 	call Predef_LinkTextbox
-	callba Function4d354
+	callba Link_WaitBGMap
 	ld a, [wd002]
 	ld hl, PartySpecies
 	ld c, a
@@ -1713,7 +1713,7 @@
 	ld a, 1
 	ld [wMenuCursorY], a
 	ld [wMenuCursorX], a
-	callba Function4d354
+	callba Link_WaitBGMap
 	call ScrollingMenuJoypad
 	push af
 	call Call_ExitMenu
@@ -1935,7 +1935,7 @@
 	call ClearScreen
 	call LoadTradeScreenBorder
 	call Function28eff
-	callba Function4d354
+	callba Link_WaitBGMap
 	ld b, $1
 	pop af
 	ld c, a
@@ -1982,7 +1982,7 @@
 	hlcoord 1, 14
 	ld de, String28ebd
 	call PlaceString
-	callba Function4d354
+	callba Link_WaitBGMap
 	ld c, 50
 	call DelayFrames
 	ld a, [wLinkMode]
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -2470,9 +2470,9 @@
 	ret
 ; 576a
 
-Function576a:: ; 576a
+HandleNPCStep:: ; 576a
 	call .ResetStepVector
-	call Function5781
+	call .DoStepsForAllObjects
 	ret
 
 .ResetStepVector
@@ -2483,9 +2483,8 @@
 	ld a, -1
 	ld [wPlayerStepDirection], a
 	ret
-; 5781
 
-Function5781: ; 5781
+.DoStepsForAllObjects
 	ld bc, ObjectStructs
 	xor a
 .loop
@@ -2505,21 +2504,21 @@
 	ret
 ; 579d
 
-Function579d: ; 579d
-	ld a, $3e
+RefreshPlayerSprite: ; 579d
+	ld a, movement_step_sleep_1
 	ld [wPlayerNextMovement], a
 	ld [wPlayerMovement], a
 	xor a
 	ld [wd04e], a
 	ld [PlayerObjectStepFrame], a
-	call Function57bc
+	call .TryResetPlayerAction
 	callba CheckWarpFacingDown
 	call c, SpawnInFacingDown
-	call SpawnInCustomFacing
+	call .SpawnInCustomFacing
 	ret
 ; 57bc
 
-Function57bc: ; 57bc
+.TryResetPlayerAction: ; 57bc
 	ld hl, wPlayerSpriteSetupFlags
 	bit 7, [hl]
 	jr nz, .ok
@@ -2531,7 +2530,7 @@
 	ret
 ; 57ca
 
-SpawnInCustomFacing: ; 57ca
+.SpawnInCustomFacing: ; 57ca
 	ld hl, wPlayerSpriteSetupFlags
 	bit 5, [hl]
 	ret z
--- a/engine/money.asm
+++ b/engine/money.asm
@@ -1,11 +1,11 @@
 GiveMoney:: ; 15fd7
-	ld a, $3
+	ld a, 3
 	call AddMoney
 	ld bc, MaxMoney
-	ld a, $3
+	ld a, 3
 	call CompareMoney
-	jr z, .asm_15ff5
-	jr c, .asm_15ff5
+	jr z, .not_maxed_out
+	jr c, .not_maxed_out
 	ld hl, MaxMoney
 	ld a, [hli]
 	ld [de], a
@@ -18,7 +18,7 @@
 	scf
 	ret
 
-.asm_15ff5
+.not_maxed_out
 	and a
 	ret
 ; 15ff7
@@ -31,7 +31,8 @@
 TakeMoney:: ; 15ffa
 	ld a, 3
 	call SubtractMoney
-	jr nc, .asm_16009
+	jr nc, .okay
+	; leave with 0 money
 	xor a
 	ld [de], a
 	inc de
@@ -41,20 +42,23 @@
 	scf
 	ret
 
-.asm_16009
+.okay
 	and a
 	ret
 ; 1600b
 
 CompareMoney:: ; 1600b
-	ld a, $3
+	ld a, 3
 CompareFunds: ; 1600d
+; a: number of bytes
+; bc: start addr of amount (big-endian)
+; de: start addr of account (big-endian)
 	push hl
 	push de
 	push bc
 	ld h, b
 	ld l, c
-	ld c, $0
+	ld c, 0
 	ld b, a
 .loop1
 	dec a
@@ -82,10 +86,9 @@
 	jr .skip_carry
 
 .set_carry
-	ld a, $1
+	ld a, TRUE
 	and a
 	scf
-
 .skip_carry
 	pop bc
 	pop de
@@ -96,6 +99,9 @@
 SubtractMoney: ; 16035
 	ld a, 3
 SubtractFunds: ; 16037
+; a: number of bytes
+; bc: start addr of amount (big-endian)
+; de: start addr of account (big-endian)
 	push hl
 	push de
 	push bc
@@ -127,11 +133,15 @@
 ; 16053
 
 AddMoney: ; 16053
-	ld a, $3
+	ld a, 3
 AddFunds: ; 16055
+; a: number of bytes
+; bc: start addr of amount (big-endian)
+; de: start addr of account (big-endian)
 	push hl
 	push de
 	push bc
+
 	ld h, b
 	ld l, c
 	ld b, a
@@ -152,6 +162,7 @@
 	dec hl
 	dec b
 	jr nz, .loop2
+
 	pop bc
 	pop de
 	pop hl
@@ -189,7 +200,8 @@
 	ld a, 2
 	ld de, Coins
 	call SubtractFunds
-	jr nc, .asm_1609f
+	jr nc, .okay
+	; leave with 0 coins
 	xor a
 	ld [de], a
 	inc de
@@ -197,13 +209,13 @@
 	scf
 	ret
 
-.asm_1609f
+.okay
 	and a
 	ret
 ; 160a1
 
 CheckCoins:: ; 160a1
-	ld a, $2
+	ld a, 2
 	ld de, Coins
 	jp CompareFunds
 ; 160a9
--- a/engine/move_mon.asm
+++ b/engine/move_mon.asm
@@ -1428,7 +1428,7 @@
 	sla c
 	ld a, d
 	and a
-	jr z, .SkipSqrt
+	jr z, .no_stat_exp
 	add hl, bc
 	push de
 	ld a, [hld]
@@ -1437,7 +1437,7 @@
 	callba GetSquareRoot
 	pop de
 
-.SkipSqrt
+.no_stat_exp
 	srl c
 	pop hl
 	push bc
--- a/engine/party_menu.asm
+++ b/engine/party_menu.asm
@@ -3,7 +3,7 @@
 	xor a
 	ld [PartyMenuActionText], a
 	call ClearBGPalettes
-	call Function5003f
+	call InitPartyMenuLayout
 	call WaitBGMap
 	call SetPalettes
 	call DelayFrame
@@ -18,7 +18,7 @@
 	ld [PartyMenuActionText], a
 	call DisableSpriteUpdates
 	call ClearBGPalettes
-	call Function5003f
+	call InitPartyMenuLayout
 	call WaitBGMap
 	ld b, SCGB_0A
 	call GetSGBLayout
@@ -29,7 +29,7 @@
 	ret
 ; 5003f
 
-Function5003f: ; 5003f
+InitPartyMenuLayout: ; 5003f
 	call LoadPartyMenuGFX
 	call InitPartyMenuWithCancel
 	call InitPartyMenuGFX
@@ -40,7 +40,7 @@
 
 LoadPartyMenuGFX: ; 5004f
 	call LoadFontsBattleExtra
-	callab Function8ad1 ; engine/color.asm
+	callab InitPartyMenuPalettes ; engine/color.asm
 	callab ClearSpriteAnims2
 	ret
 ; 5005f
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -3049,10 +3049,7 @@
 	ret
 ; 97b2e
 
-
-CloseTextScript: ; 97b2e
-	closetext
-; 97b2f
+	ld c, c ; XXX
 
 Script_closetext: ; 97b2f
 ; script command 0x49
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -9,7 +9,7 @@
 
 _SlotMachine:
 	ld hl, Options
-	set 4, [hl]
+	set NO_TEXT_SCROLL, [hl]
 	call .InitGFX
 	call DelayFrame
 .loop
@@ -22,7 +22,7 @@
 	call ClearBGPalettes
 	callba MobileFn_105fd0
 	ld hl, Options
-	res 4, [hl]
+	res NO_TEXT_SCROLL, [hl]
 	ld hl, rLCDC ; $ff40
 	res 2, [hl]
 	ret
--- a/engine/spawn_points.asm
+++ b/engine/spawn_points.asm
@@ -1,8 +1,6 @@
 
 SpawnPoints: ; 0x152ab
 
-	const_def
-
 spawn: MACRO
 ; map, y, x
 	map \1
--- a/engine/warp_connection.asm
+++ b/engine/warp_connection.asm
@@ -319,7 +319,7 @@
 	call ClearSprites
 	callba ReturnFromMapSetupScript
 	call GetMovementPermissions
-	callba Function579d
+	callba RefreshPlayerSprite
 	callba CheckReplaceKrisSprite
 	ld hl, wPlayerSpriteSetupFlags
 	bit 6, [hl]
--- a/engine/wildmons.asm
+++ b/engine/wildmons.asm
@@ -494,6 +494,7 @@
 ; 2a288
 
 LookUpWildmonsForMapDE: ; 2a288
+.loop
 	push hl
 	ld a, [hl]
 	inc a
@@ -509,7 +510,7 @@
 .next
 	pop hl
 	add hl, bc
-	jr LookUpWildmonsForMapDE
+	jr .loop
 
 .nope
 	pop hl
@@ -896,7 +897,7 @@
 	ld a, c
 	ld [wNamedObjectIndexBuffer], a
 	call GetPokemonName
-	ld hl, UnknownText_0x2a51a
+	ld hl, .SawRareMonText
 	call PrintText
 	xor a
 	ld [ScriptVar], a
@@ -906,9 +907,8 @@
 	ld a, $1
 	ld [ScriptVar], a
 	ret
-; 2a51a
 
-UnknownText_0x2a51a: ; 0x2a51a
+.SawRareMonText
 	; I just saw some rare @  in @ . I'll call you if I see another rare #MON, OK?
 	text_jump UnknownText_0x1bd34b
 	db "@"
--- a/macros/event.asm
+++ b/macros/event.asm
@@ -94,7 +94,6 @@
 	dba \1
 	endm
 
-
 	enum special_command
 special: macro
 	db special_command
@@ -105,7 +104,6 @@
 \1Special::
 	dba \1
 ENDM
-
 
 	enum ptcallasm_command
 ptcallasm: macro
--- a/main.asm
+++ b/main.asm
@@ -6749,13 +6749,20 @@
 	ld a, [PartyCount]
 	ld b, a
 	ld de, PARTYMON_STRUCT_LENGTH
+; Check to see if any of your Pokemon already has Pokerus.
+; If so, sample its spread through your party.
+; This means that you cannot get Pokerus de novo while
+; a party member has an active infection.
 .loopMons
 	ld a, [hl]
 	and $f
-	jr nz, .monHasActivePokerus
+	jr nz, .TrySpreadPokerus
 	add hl, de
 	dec b
 	jr nz, .loopMons
+
+; If we haven't been to Goldenrod City at least once,
+; prevent the contraction of Pokerus.
 	ld hl, StatusFlags2
 	bit 6, [hl]
 	ret z
@@ -6778,7 +6785,7 @@
 	ld a, [hl]
 	and $f0
 	ret nz                 ; if it already has pokerus, do nothing
-.randomPokerusLoop
+.randomPokerusLoop         ; Simultaneously sample the strain and duration
 	call Random
 	and a
 	jr z, .randomPokerusLoop
@@ -6789,7 +6796,7 @@
 	and $7
 	inc a
 .load_pkrs
-	ld b, a
+	ld b, a ; this should come before the label
 	swap b
 	and $3
 	inc a
@@ -6797,19 +6804,22 @@
 	ld [hl], a
 	ret
 
-.monHasActivePokerus
+.TrySpreadPokerus
 	call Random
 	cp 1 + 33 percent
 	ret nc              ; 1/3 chance
+
 	ld a, [PartyCount]
 	cp 1
 	ret z               ; only one mon, nothing to do
+
 	ld c, [hl]
 	ld a, b
-	cp $2
+	cp 2
 	jr c, .checkPreviousMonsLoop    ; no more mons after this one, go backwards
+
 	call Random
-	cp $80
+	cp 1 + 50 percent
 	jr c, .checkPreviousMonsLoop    ; 1/2 chance, go backwards
 .checkFollowingMonsLoop
 	add hl, de
@@ -6821,7 +6831,7 @@
 	ret z               ; if mon has cured pokerus, stop searching
 	dec b               ; go on to next mon
 	ld a, b
-	cp $1
+	cp 1
 	jr nz, .checkFollowingMonsLoop ; no more mons left
 	ret
 
@@ -8188,7 +8198,7 @@
 	call ClearBGPalettes
 	call MaxVolume
 	callba LoadTradeScreenBorder
-	callba Function4d354
+	callba Link_WaitBGMap
 	callba InitTradeSpeciesList
 	callba Function28eff
 	call WaitBGMap2
@@ -8195,7 +8205,7 @@
 	ret
 ; 4d354
 
-Function4d354: ; 4d354
+Link_WaitBGMap: ; 4d354
 	call WaitBGMap
 	call WaitBGMap2
 	ret
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -1570,7 +1570,7 @@
 	inc de
 	dec c
 	jr nz, .loop_col
-	ld bc, 12
+	ld bc, BG_MAP_WIDTH - SCREEN_WIDTH
 	add hl, bc
 	pop bc
 	dec b
@@ -1609,7 +1609,7 @@
 	ld a, [hJoyDown]
 	and SELECT + A_BUTTON
 	cp SELECT + A_BUTTON
-	jr nz, .asm_100a07
+	jr nz, .select_a
 	ld hl, wcd2a
 	set 4, [hl]
 	ld a, $f8
@@ -1617,7 +1617,7 @@
 	scf
 	ret
 
-.asm_100a07
+.select_a
 	xor a
 	ret
 ; 100a09
@@ -1630,13 +1630,13 @@
 	cp LINK_MOBILE
 	jr nz, .not_mobile
 
-	call Function100a87
+	call .MobileBattle_SendReceiveAction
 	call Function100da5
 	callba FinishBattleAnim
 	jr .done
 
 .not_mobile
-	call Function100a53
+	call .LinkBattle_SendReceiveAction
 
 .done
 	ret
@@ -1669,7 +1669,7 @@
 	ret
 ; 100a53
 
-Function100a53: ; 100a53
+.LinkBattle_SendReceiveAction: ; 100a53
 	ld a, [wd431]
 	ld [wPlayerLinkAction], a
 	ld a, $ff
@@ -1700,7 +1700,7 @@
 	ret
 ; 100a87
 
-Function100a87: ; 100a87
+.MobileBattle_SendReceiveAction: ; 100a87
 	call Function100acf
 	call Function100641
 	ld a, 0
@@ -2100,7 +2100,7 @@
 ; 100d67
 
 Function100d67: ; 100d67
-	ld hl, MenuDataHeader_100d88
+	ld hl, .MenuDataHeader
 	call CopyMenuDataHeader
 	xor a
 	ld [hBGMapMode], a
@@ -2115,19 +2115,19 @@
 	ret
 ; 100d88
 
-MenuDataHeader_100d88: ; 100d88
+.MenuDataHeader: ; 100d88
 	db 0 ; flags
 	db 11, 11 ; start coords
 	db 17, 19 ; end coords
-	dw MenuData2_100d90
+	dw .MenuData2
 	db 1 ; default option
 
-MenuData2_100d90: ; 100d90
+.MenuData2: ; 100d90
 	db $c0 ; flags
 	db 3
-	db "いれかえる@"
-	db "つよさをみる@"
-	db "キャンセル@"
+	db "いれかえる@"  ; TRADE
+	db "つよさをみる@" ; STATS
+	db "キャンセル@"  ; CANCEL
 ; 100da5
 
 Function100da5: ; 100da5
--- a/trainers/read_party.asm
+++ b/trainers/read_party.asm
@@ -333,7 +333,7 @@
 Battle_GetTrainerName:: ; 39939
 	ld a, [InBattleTowerBattle]
 	bit 0, a
-	ld hl, wd26b
+	ld hl, OTPlayerName
 	jp nz, CopyTrainerName
 
 	ld a, [OtherTrainerID]
--- a/wram.asm
+++ b/wram.asm
@@ -2072,7 +2072,7 @@
 wItemQuantityChangeBuffer:: ds 1
 wItemQuantityBuffer:: ds 1
 
-TempMon::
+TempMon:: ; d10e
 	party_struct TempMon
 
 wSpriteFlags:: ds 1
@@ -2398,11 +2398,11 @@
 	ds 2
 
 	ds 2
-wMornEncounterRate::  ds 1
-wDayEncounterRate::   ds 1
-wNiteEncounterRate::  ds 1
-wWaterEncounterRate:: ds 1
-wListMoves_MoveIndicesBuffer:: ds 4
+wMornEncounterRate::  ds 1 ; d25a
+wDayEncounterRate::   ds 1 ; d25b
+wNiteEncounterRate::  ds 1 ; d25c
+wWaterEncounterRate:: ds 1 ; d25d
+wListMoves_MoveIndicesBuffer:: ds NUM_MOVES
 wPutativeTMHMMove:: ds 1
 wd263:: ds 1
 wd264:: ds 1
@@ -2428,7 +2428,6 @@
 wd26d:: ds 1
 	ds 3
 wd271:: ds 5
-wd276:: ds 10
 	ds wd26b - @
 
 
@@ -2466,7 +2465,7 @@
 
 OTPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH ; d3a8
 OTPartyMonNicknames:: ds PKMN_NAME_LENGTH * PARTY_LENGTH ; d3ea
-
+OTPartyDataEnd::
 	ds 4
 
 wd430::
@@ -2523,6 +2522,9 @@
 
 wBattleScriptFlags:: ds 2
 wPlayerSpriteSetupFlags:: ds 1
+; bit 7: if set, cancel PlayerAction
+; bit 5: if set, set facing according to bits 0-1
+; bits 0-1: direction facing
 wMapReentryScriptQueueFlag:: ds 1 ; MemScriptFlag
 wMapReentryScriptBank:: ds 1 ; MemScriptBank
 wMapReentryScriptAddress:: ds 2 ; MemScriptAddr
@@ -2946,6 +2948,7 @@
 	ds 1
 
 BikeFlags:: ; dbf5
+; bit 0: using strength
 ; bit 1: always on bike
 ; bit 2: downhill
 	ds 1
@@ -3287,7 +3290,8 @@
 	ds -$22
 
 wBTChoiceOfLvlGroup::
-w3_d800:: ds $69
+w3_d800:: ; ds BG_MAP_WIDTH * SCREEN_HEIGHT ($240)
+	ds $69
 w3_d869:: ds $17
 w3_d880:: ds 1
 w3_d881:: ds 1
@@ -3300,10 +3304,12 @@
 w3_d8a0:: ds 1
 w3_d8a1:: ds 1
 w3_d8a2:: ds 1
-w3_d8a3:: ds 1
-	ds $35c
-w3_dc00:: ds $168
-w3_dd68:: ds $284
+w3_d8a3:: ds $19d
+w3_da40:: ds $1c0
+
+w3_dc00:: ds SCREEN_WIDTH * SCREEN_HEIGHT
+w3_dd68:: ds SCREEN_WIDTH * SCREEN_HEIGHT
+	ds $11c
 w3_dfec:: ds $10
 w3_dffc:: ds 4