shithub: pokecrystal

Download patch

ref: 4b35fa05829eb5257186699d8a8e44362905468c
parent: 03f0815679bdd27241d7c212d2667ec30764b820
author: PikalaxALT <PikalaxALT@gmail.com>
date: Tue Nov 10 18:23:28 EST 2015

Added w3 and w5 labels for misc/mobile_40.asm

--- a/battle/core.asm
+++ b/battle/core.asm
@@ -3,7 +3,7 @@
 ; Core components of the battle engine.
 
 
-Function3c000: ; 3c000
+SendOutFirstMons: ; 3c000
 	xor a
 	ld [wBattleParticipantsNotFainted], a
 	ld [wc6fc], a
@@ -2506,7 +2506,7 @@
 
 .mobile
 	call Function3ebd8
-	ld c, $28
+	ld c, 40
 	call DelayFrames
 	ld c, $4
 	callba Function4ea0a
@@ -2514,12 +2514,12 @@
 
 .battle_tower
 	call Function3ebd8
-	ld c, $28
+	ld c, 40
 	call DelayFrames
 	call EmptyBattleTextBox
 	ld c, $3
 	callba BattleTowerText
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	ld hl, wPayDayMoney
 	ld a, [hli]
 	or [hl]
@@ -3135,7 +3135,7 @@
 	call EmptyBattleTextBox
 	ld c, 2
 	callba BattleTowerText
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	call ClearTileMap
 	call WhiteBGMap
 	ret
@@ -7713,7 +7713,7 @@
 	predef PrintTempMonStats
 	ld c, $1e
 	call DelayFrames
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	call Call_LoadTempTileMapToTileMap
 	xor a ; PARTYMON
 	ld [MonType], a
@@ -8474,8 +8474,8 @@
 	ld a, [TimeOfDayPal]
 	push af
 	call BattleIntro
-	call Function3c000
-	call Function3f69e
+	call SendOutFirstMons
+	call ExitBattle
 	pop af
 	ld [TimeOfDayPal], a
 	scf
@@ -8483,8 +8483,9 @@
 ; 3f4d9
 
 
-Function3f4d9: ; 3f4d9
-	call Function3c000
+_SendOutFirstMons: ; 3f4d9
+; unreferenced
+	call SendOutFirstMons
 	ret
 ; 3f4dd
 
@@ -8716,9 +8717,9 @@
 ; 3f69e
 
 
-Function3f69e: ; 3f69e
+ExitBattle: ; 3f69e
 	call Function3f6a5
-	call Function3f6d0
+	call CleanUpBattleRAM
 	ret
 ; 3f6a5
 
@@ -8726,7 +8727,7 @@
 	ld a, [wLinkMode]
 	and a
 	jr z, .not_linked
-	call Function3f759
+	call ShowLinkBattleParticipantsAfterEnd
 	ld c, 150
 	call DelayFrames
 	call Function3f77c
@@ -8736,7 +8737,7 @@
 	ld a, [wBattleResult]
 	and $f
 	ret nz
-	call Function3f71d
+	call CheckPayDay
 	xor a
 	ld [wd1e9], a
 	predef Function421e6
@@ -8744,7 +8745,7 @@
 	ret
 ; 3f6d0
 
-Function3f6d0: ; 3f6d0
+CleanUpBattleRAM: ; 3f6d0
 	call Function3f998
 	xor a
 	ld [Danger], a
@@ -8777,7 +8778,7 @@
 	ret
 ; 3f71d
 
-Function3f71d: ; 3f71d
+CheckPayDay: ; 3f71d
 	ld hl, wPayDayMoney
 	ld a, [hli]
 	or [hl]
@@ -8786,7 +8787,7 @@
 	ret z
 	ld a, [wc73d]
 	and a
-	jr z, .asm_3f73d
+	jr z, .okay
 	ld hl, wPayDayMoney + 2
 	sla [hl]
 	dec hl
@@ -8793,7 +8794,7 @@
 	rl [hl]
 	dec hl
 	rl [hl]
-	jr nc, .asm_3f73d
+	jr nc, .okay
 	ld a, $ff
 rept 2
 	ld [hli], a
@@ -8800,7 +8801,7 @@
 endr
 	ld [hl], a
 
-.asm_3f73d
+.okay
 	ld hl, wPayDayMoney + 2
 	ld de, Money + 2
 	call Function3d0be
@@ -8814,7 +8815,7 @@
 	ret
 ; 3f759
 
-Function3f759: ; 3f759
+ShowLinkBattleParticipantsAfterEnd: ; 3f759
 	callba MobileFn_1060df
 	callba BackupMobileEventIndex
 	ld a, [CurOTMon]
@@ -8829,14 +8830,16 @@
 
 Function3f77c: ; 3f77c
 	callba CheckMobileBattleError
-	jp c, Function3f80f
-	call Function3f830
+	jp c, .Mobile_InvalidBattle
+	call IsMobileBattle2
 	jr nz, .proceed
+
 	ld hl, wcd2a
 	bit 4, [hl]
 	jr z, .proceed
-	callba Function2b930
 
+	callba DetermineLinkBattleResult
+
 .proceed
 	ld a, [wBattleResult]
 	and $f
@@ -8843,17 +8846,17 @@
 	cp $1
 	jr c, .victory
 	jr z, .loss
-	callba MobileFn_106107
+	callba MobileFn_SaveBattleResult_Draw
 	ld de, .Draw
 	jr .store_result
 
 .victory
-	callba MobileFn_1060fb
+	callba MobileFn_SaveBattleResult_Win
 	ld de, .Win
 	jr .store_result
 
 .loss
-	callba MobileFn_106101
+	callba MobileFn_SaveBattleResult_Lose
 	ld de, .Lose
 	jr .store_result
 
@@ -8872,13 +8875,13 @@
 
 	call CloseSRAM
 
-	call Function3f830
-	jr z, .asm_3f7ee
-	call Functiona80
+	call IsMobileBattle2
+	jr z, .mobile
+	call WaitPressAorB_BlinkCursor
 	call ClearTileMap
 	ret
 
-.asm_3f7ee
+.mobile
 	ld c, 200
 	call DelayFrames
 	call ClearTileMap
@@ -8894,11 +8897,11 @@
 ; 3f80f
 
 
-Function3f80f: ; 3f80f
+.Mobile_InvalidBattle: ; 3f80f
 	hlcoord 6, 8
 	ld de, .Invalid
 	call PlaceString
-	ld c, $c8
+	ld c, 200
 	call DelayFrames
 	call ClearTileMap
 	ret
@@ -8909,7 +8912,7 @@
 ; 3f830
 
 
-Function3f830: ; 3f830
+IsMobileBattle2: ; 3f830
 	ld a, [wLinkMode]
 	cp LINK_MOBILE
 	ret
@@ -8919,7 +8922,9 @@
 Function3f836: ; 3f836
 	ld a, BANK(sLinkBattleStats)
 	call GetSRAMBank
+
 	call Function3f85f
+
 	call CloseSRAM
 	hlcoord 0, 0, AttrMap
 	xor a
@@ -8931,7 +8936,7 @@
 	call SetPalettes
 	ld c, $8
 	call DelayFrames
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	ret
 ; 3f85f
 
@@ -9634,7 +9639,7 @@
 	pop hl
 	call StdBattleTextBox
 
-	call Function3f830
+	call IsMobileBattle2
 	ret nz
 
 	ld c, $2
--- a/engine/breeding/egg.asm
+++ b/engine/breeding/egg.asm
@@ -894,7 +894,7 @@
 	jp PrintText
 
 Function1745f: ; 1745f
-	jp Functiona80
+	jp WaitPressAorB_BlinkCursor
 ; 17462
 
 UnknownText_0x17462: ; 0x17462
--- a/engine/clock_reset.asm
+++ b/engine/clock_reset.asm
@@ -99,7 +99,7 @@
 	call .PrintTime
 	ld hl, .Text_ClockReset
 	call PrintText
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	xor a
 	ret
 
--- a/engine/diploma.asm
+++ b/engine/diploma.asm
@@ -1,7 +1,7 @@
 
 Function1dd702: ; 1dd702
 	call Function1dd709
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	ret
 ; 1dd709
 
--- a/home.asm
+++ b/home.asm
@@ -1623,7 +1623,7 @@
 	call GetMapScriptHeaderBank
 	call FarPrintText
 	call WaitBGMap
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	ret
 ; 3741
 
--- a/home/copy2.asm
+++ b/home/copy2.asm
@@ -98,7 +98,9 @@
 	push af
 	ld a, [hBuffer]
 	ld [rSVBK], a
+
 	call CopyBytes
+
 	pop af
 	ld [rSVBK], a
 	ret
--- a/home/joypad.asm
+++ b/home/joypad.asm
@@ -355,7 +355,7 @@
 	ret
 ; a80
 
-Functiona80:: ; a80
+WaitPressAorB_BlinkCursor:: ; a80
 	ld a, [hMapObjectIndexBuffer]
 	push af
 	ld a, [hObjectStructIndexBuffer]
@@ -368,7 +368,7 @@
 .loop
 	push hl
 	hlcoord 18, 17
-	call Functionb06
+	call BlinkCursor
 	pop hl
 
 	call JoyTextDelay
@@ -383,7 +383,7 @@
 	ret
 ; aa5
 
-Functionaa5:: ; aa5
+SimpleWaitPressAorB:: ; aa5
 .loop
 	call JoyTextDelay
 	ld a, [hJoyLast]
@@ -451,7 +451,7 @@
 	ret
 ; b06
 
-Functionb06:: ; b06
+BlinkCursor:: ; b06
 	push bc
 	ld a, [hl]
 	ld b, a
@@ -458,7 +458,7 @@
 	ld a, "▼"
 	cp b
 	pop bc
-	jr nz, .asm_b27
+	jr nz, .place_arrow
 	ld a, [hMapObjectIndexBuffer]
 	dec a
 	ld [hMapObjectIndexBuffer], a
@@ -475,7 +475,7 @@
 	ld [hObjectStructIndexBuffer], a
 	ret
 
-.asm_b27
+.place_arrow
 	ld a, [hMapObjectIndexBuffer]
 	and a
 	ret z
@@ -488,9 +488,9 @@
 	dec a
 	ld [hObjectStructIndexBuffer], a
 	ret nz
-	ld a, $6
+	ld a, 6
 	ld [hObjectStructIndexBuffer], a
-	ld a, $ee
+	ld a, "▼"
 	ld [hl], a
 	ret
 ; b40
--- a/items/item_effects.asm
+++ b/items/item_effects.asm
@@ -1438,7 +1438,7 @@
 	ld bc, $0004
 	predef PrintTempMonStats
 
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 
 	xor a ; PARTYMON
 	ld [MonType], a
@@ -1921,7 +1921,7 @@
 	ld [hBGMapMode], a
 	ld c, $32
 	call DelayFrames
-	jp Functiona80
+	jp WaitPressAorB_BlinkCursor
 
 Functionf299: ; f299 (3:7299)
 	call WontHaveAnyEffectMessage
@@ -2943,7 +2943,7 @@
 	ld hl, UsedItemText
 	call PrintText
 	call Play_SFX_FULL_HEAL
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	; fallthrough
 ; f795
 
--- a/main.asm
+++ b/main.asm
@@ -5486,7 +5486,7 @@
 	jr nz, .failescaperope
 	ld hl, UnknownText_0xcc26
 	call MenuTextBox
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	call WriteBackup
 
 .failescaperope
@@ -25054,53 +25054,53 @@
 INCLUDE "data/wild/swarm_water.asm"
 
 
-Function2b930: ; 2b930
+DetermineLinkBattleResult: ; 2b930
 	callba UpdateEnemyMonInParty
 	ld hl, PartyMon1HP
-	call Function2b995
+	call .CountMonsRemaining
 	push bc
 	ld hl, OTPartyMon1HP
-	call Function2b995
+	call .CountMonsRemaining
 	ld a, c
 	pop bc
 	cp c
-	jr z, .asm_2b94c
-	jr c, .asm_2b97f
-	jr .asm_2b976
+	jr z, .even_number_of_mons_remaining
+	jr c, .defeat
+	jr .victory
 
-.asm_2b94c
-	call Function2b9e1
-	jr z, .asm_2b98a
+.even_number_of_mons_remaining
+	call .BothSides_CheckNumberMonsAtFullHealth
+	jr z, .drawn
 	ld a, e
 	cp $1
-	jr z, .asm_2b976
+	jr z, .victory
 	cp $2
-	jr z, .asm_2b97f
+	jr z, .defeat
 	ld hl, PartyMon1HP
-	call Function2b9a6
+	call .CalcPercentHPRemaining
 	push de
 	ld hl, OTPartyMon1HP
-	call Function2b9a6
+	call .CalcPercentHPRemaining
 	pop hl
 	ld a, d
 	cp h
-	jr c, .asm_2b976
-	jr z, .asm_2b970
-	jr .asm_2b97f
+	jr c, .victory
+	jr z, .compare_lo
+	jr .defeat
 
-.asm_2b970
+.compare_lo
 	ld a, e
 	cp l
-	jr z, .asm_2b98a
-	jr nc, .asm_2b97f
+	jr z, .drawn
+	jr nc, .defeat
 
-.asm_2b976
+.victory
 	ld a, [wBattleResult]
 	and $f0
 	ld [wBattleResult], a
 	ret
 
-.asm_2b97f
+.defeat
 	ld a, [wBattleResult]
 	and $f0
 	add $1
@@ -25107,7 +25107,7 @@
 	ld [wBattleResult], a
 	ret
 
-.asm_2b98a
+.drawn
 	ld a, [wBattleResult]
 	and $f0
 	add $2
@@ -25115,30 +25115,30 @@
 	ret
 ; 2b995
 
-Function2b995: ; 2b995
-	ld c, $0
-	ld b, $3
-	ld de, $2f
-.asm_2b99c
+.CountMonsRemaining: ; 2b995
+	ld c, 0
+	ld b, 3
+	ld de, PARTYMON_STRUCT_LENGTH - 1
+.loop
 	ld a, [hli]
 	or [hl]
-	jr nz, .asm_2b9a1
+	jr nz, .not_fainted
 	inc c
 
-.asm_2b9a1
+.not_fainted
 	add hl, de
 	dec b
-	jr nz, .asm_2b99c
+	jr nz, .loop
 	ret
 ; 2b9a6
 
-Function2b9a6: ; 2b9a6
+.CalcPercentHPRemaining: ; 2b9a6
 	ld de, 0
 	ld c, $3
-.asm_2b9ab
+.loop2
 	ld a, [hli]
 	or [hl]
-	jr z, .asm_2b9d7
+	jr z, .next
 	dec hl
 	xor a
 	ld [hDividend + 0], a
@@ -25166,30 +25166,30 @@
 	ld d, a
 	dec hl
 
-.asm_2b9d7
+.next
 	push de
 	ld de, $2f
 	add hl, de
 	pop de
 	dec c
-	jr nz, .asm_2b9ab
+	jr nz, .loop2
 	ret
 ; 2b9e1
 
-Function2b9e1: ; 2b9e1
+.BothSides_CheckNumberMonsAtFullHealth: ; 2b9e1
 	ld hl, PartyMon1HP
-	call Function2ba01
-	jr nz, .asm_2b9f2
+	call .CheckFaintedOrFullHealth
+	jr nz, .finish ; we have a pokemon that's neither fainted nor at full health
 	ld hl, OTPartyMon1HP
-	call Function2ba01
+	call .CheckFaintedOrFullHealth
 	ld e, $1
 	ret
 
-.asm_2b9f2
+.finish
 	ld hl, OTPartyMon1HP
-	call Function2ba01
+	call .CheckFaintedOrFullHealth
 	ld e, $0
-	ret nz
+	ret nz ; we both have pokemon that are neither fainted nor at full health
 	ld e, $2
 	ld a, $1
 	and a
@@ -25196,15 +25196,15 @@
 	ret
 ; 2ba01
 
-Function2ba01: ; 2ba01
-	ld d, $3
-.asm_2ba03
+.CheckFaintedOrFullHealth: ; 2ba01
+	ld d, 3
+.loop3
 	ld a, [hli]
 	ld b, a
 	ld a, [hli]
 	ld c, a
 	or b
-	jr z, .asm_2ba10
+	jr z, .fainted_or_full_health
 	ld a, [hli]
 	cp b
 	ret nz
@@ -25212,13 +25212,13 @@
 	cp c
 	ret nz
 
-.asm_2ba10
+.fainted_or_full_health
 	push de
-	ld de, $2e
+	ld de, PARTYMON_STRUCT_LENGTH - 2
 	add hl, de
 	pop de
 	dec d
-	jr nz, .asm_2ba03
+	jr nz, .loop3
 	ret
 ; 2ba1a
 
@@ -32049,7 +32049,7 @@
 
 Function49811: ; 49811
 	ld hl, Palette_49826
-	ld de, wd010
+	ld de, Unkn1Pals + $10
 	ld bc, $30
 	ld a, $5
 	call FarCopyWRAM
@@ -37922,22 +37922,26 @@
 	pop af
 	dec a
 	ld bc, $c
-	ld hl, wdc1a
+	ld hl, w5_dc1a
 	call AddNTimes
 	ld de, wcd53
 	ld bc, $c
-	ld a, $5
+	ld a, $5 ; BANK(w5_dc1a)
 	call FarCopyWRAM
+
 	ld a, [rSVBK]
 	push af
 	ld a, $1
 	ld [rSVBK], a
+
 	ld bc, wcd53
 	decoord 1, 14
 	callba Function11c0c6
+
 	pop af
 	ld [rSVBK], a
-	ld c, $b4
+
+	ld c, 180
 	call DelayFrames
 	ret
 ; 4ea44
@@ -50747,7 +50751,7 @@
 	call Function658
 	ld hl, OakText_ResponseToSetTime
 	call PrintText
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	pop af
 	ld [hInMenu], a
 	ret
@@ -54592,7 +54596,7 @@
 
 Function929d9: ; 929d9 (24:69d9)
 	call Function9304c
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	call Function930e9
 	jr c, .asm_929ea
 	ld a, $0
@@ -58976,7 +58980,7 @@
 
 .TabulateTheResult: ; e0314
 	call Functione0637
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	call .Increment
 	ret
 ; e031e
@@ -60725,7 +60729,7 @@
 	ld de, SFX_1ST_PLACE
 	call PlaySFX
 	call WaitSFX
-	call Functionaa5
+	call SimpleWaitPressAorB
 	ld a, $1
 	ld [wd0ec], a
 
@@ -61493,7 +61497,7 @@
 	jr .asm_e1fd5
 
 .asm_e1ff9
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	ld hl, wJumptableIndex
 	inc [hl]
 
@@ -68214,11 +68218,11 @@
 	xor a
 	ld [wPokedexStatus], a
 	callba Function41a7f
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	ld a, $1
 	ld [wPokedexStatus], a
 	callba Function4424d
-	call Functiona80
+	call WaitPressAorB_BlinkCursor
 	pop af
 	ld [wPokedexStatus], a
 	call MaxVolume
@@ -72680,1103 +72684,7 @@
 	ret
 ; 105ef6
 
-
-
-SECTION "bank41_2", ROMX, BANK[$41]
-
-Mobile_HallOfFame2:: mobile ; 0x105ef6
-	ld a, $5
-	call GetSRAMBank
-	ld hl, GameTimeHours
-	ld de, $a001
-	ld bc, 4
-	call CopyBytes
-	ld hl, $a010
-	ld de, $a005
-	ld bc, 4
-	call CopyBytes
-	ld hl, $a039
-	ld de, $a009
-	ld bc, 4
-	call CopyBytes
-	ld hl, $a01b
-	ld de, $a00d
-	ld bc, 3
-	call CopyBytes
-	call Function106162
-	call CloseSRAM
-	ret
-; 105f33
-
-MagikarpLength_Mobile: mobile ; 105f33
-	ld a, $5
-	call GetSRAMBank
-	ld de, Buffer1
-	ld hl, $a07b
-	ld a, [de]
-	cp [hl]
-	jr z, .asm_105f47
-	jr nc, .asm_105f4f
-	jr .asm_105f55
-
-.asm_105f47
-	inc hl
-	inc de
-	ld a, [de]
-	cp [hl]
-	dec hl
-	dec de
-	jr c, .asm_105f55
-
-.asm_105f4f
-	ld a, [de]
-	inc de
-	ld [hli], a
-	ld a, [de]
-	dec de
-	ld [hl], a
-
-.asm_105f55
-	ld hl, $a07d
-	ld a, [hli]
-	or [hl]
-	dec hl
-	jr z, .asm_105f6d
-	ld a, [de]
-	cp [hl]
-	jr z, .asm_105f65
-	jr c, .asm_105f6d
-	jr .asm_105f72
-
-.asm_105f65
-	inc hl
-	inc de
-	ld a, [de]
-	cp [hl]
-	jr nc, .asm_105f72
-	dec hl
-	dec de
-
-.asm_105f6d
-	ld a, [de]
-	inc de
-	ld [hli], a
-	ld a, [de]
-	ld [hl], a
-
-.asm_105f72
-	call Function106162
-	call CloseSRAM
-	ret
-; 105f79
-
-MobileFn_105f79: mobile ; 105f79
-	ld a, $5
-	call GetSRAMBank
-	ld a, [hProduct]
-	ld hl, $a07f
-	cp [hl]
-	jr z, .asm_105f8b
-	jr nc, .asm_105f92
-	jr .asm_105f98
-
-.asm_105f8b
-	inc hl
-	ld a, [hMultiplicand]
-	cp [hl]
-	jr c, .asm_105f98
-	dec hl
-
-.asm_105f92
-	ld a, [hProduct]
-	ld [hli], a
-	ld a, [hMultiplicand]
-	ld [hl], a
-
-.asm_105f98
-	call Function106162
-	call CloseSRAM
-	ret
-; 105f9f
-
-MobileFn_105f9f: mobile ; 105f9f
-	ld a, $5
-	call GetSRAMBank
-	ld hl, $a070
-	inc [hl]
-	jr nz, .asm_105fae
-	dec hl
-	inc [hl]
-	inc hl
-
-.asm_105fae
-	dec hl
-	ld a, [$a071]
-	cp [hl]
-	jr z, .asm_105fb9
-	jr c, .asm_105fc1
-	jr .asm_105fc9
-
-.asm_105fb9
-	inc hl
-	ld a, [$a072]
-	cp [hl]
-	jr nc, .asm_105fc9
-	dec hl
-
-.asm_105fc1
-	ld a, [hli]
-	ld [$a071], a
-	ld a, [hl]
-	ld [$a072], a
-
-.asm_105fc9
-	call Function106162
-	call CloseSRAM
-	ret
-; 105fd0
-
-MobileFn_105fd0: mobile ; 105fd0
-	ld a, $5
-	call GetSRAMBank
-	ld hl, $a06f
-	xor a
-	ld [hli], a
-	ld [hl], a
-	call Function106162
-	call CloseSRAM
-	ret
-; 105fe3
-
-MobileFn_105fe3: mobile ; 105fe3
-	ld a, $5
-	call GetSRAMBank
-	ld hl, $a076
-	ld a, e
-	add [hl]
-	ld [hld], a
-	ld a, d
-	adc [hl]
-	ld [hld], a
-	jr nc, .asm_106001
-	inc [hl]
-	jr nz, .asm_106001
-	dec hl
-	inc [hl]
-	jr nz, .asm_106001
-	ld a, $ff
-rept 3
-	ld [hli], a
-endr
-	ld [hl], a
-
-.asm_106001
-	call Function106162
-	call CloseSRAM
-	ret
-; 106008
-
-MobileFn_106008: mobile ; 106008
-	ld a, $5
-	call GetSRAMBank
-	ld hl, $a07a
-	ld a, [bc]
-	dec bc
-	add [hl]
-	ld [hld], a
-	ld a, [bc]
-	dec bc
-	adc [hl]
-	ld [hld], a
-	ld a, [bc]
-	adc [hl]
-	ld [hld], a
-	jr nc, .asm_106027
-	inc [hl]
-	jr nz, .asm_106027
-	ld a, $ff
-rept 3
-	ld [hli], a
-endr
-	ld [hl], a
-
-.asm_106027
-	call Function106162
-	call CloseSRAM
-	ret
-; 10602e
-
-MobileFn_10602e: mobile ; 10602e (41:602e)
-	ld hl, $a010
-	jp Function106117
-
-MobileFn_106035: mobile ; 106035
-	ld a, $5
-	call GetSRAMBank
-	ld a, [$aa8d]
-	and a
-	call CloseSRAM
-	ret nz
-	ld hl, $a014
-	jp Function106123
-
-MobileFn_106049: mobile ; 106049
-	ld hl, $a018
-	jp Function10611d
-
-MobileFn_106050: mobile ; 106050
-	ld a, [BattleType]
-	cp BATTLETYPE_TUTORIAL
-	ret z
-	ld hl, $a01b
-	jp Function10611d
-
-MobileFn_10605d: mobile ; 10605d
-	ld a, [BattleType]
-	cp BATTLETYPE_TUTORIAL
-	ret z
-	ld hl, $a01e
-	jp Function10611d
-
-MobileFn_10606a: mobile ; 10606a
-	ld hl, $a021
-	jp Function10611d
-
-MobileFn_106071: mobile ; 106071
-	ld hl, $a024
-	jp Function10611d
-
-Mobile_HallOfFame:: mobile ; 0x106078
-	ld hl, $a027
-	jp Function10611d
-
-MobileFn_10607f: mobile ; 10607f (41:607f)
-	ld hl, $a02a
-	jp Function10611d
-
-MobileFn_106086: mobile ; 106086
-	ld hl, $a02d
-	jp Function10611d
-
-MobileFn_10608d: mobile ; 10608d (41:608d)
-	ld hl, $a030
-	jp Function10611d
-
-MobileFn_106094: mobile ; 106094
-	ld hl, $a033
-	jp Function10611d
-
-MobileFn_10609b: mobile ; 10609b
-	ld hl, $a036
-	jp Function10611d
-
-Mobile_HealParty: mobile ; 1060a2
-	ld hl, $a039
-	jp Function10611d
-
-MobileFn_1060a9: mobile ; 1060a9 (41:60a9)
-	ld hl, $a03c
-	jr Function10611d
-
-MobileFn_1060af: mobile ; 1060af
-	ld hl, $a03f
-	jr Function10611d
-
-MobileFn_1060b5: mobile ; 1060b5
-	ld hl, $a042
-	jr Function10611d
-
-MobileFn_1060bb: mobile ; 1060bb
-	ld hl, $a045
-	jr Function10611d
-
-MobileFn_1060c1: mobile ; 1060c1
-	ld hl, $a048
-	jr Function10611d
-
-MobileFn_1060c7: mobile ; 1060c7
-	ld hl, $a04b
-	jr Function10611d
-
-MobileFn_1060cd: mobile ; 1060cd
-	ld hl, $a04e
-	jr Function106123
-
-MobileFn_1060d3: mobile ; 1060d3
-	ld hl, $a051
-	jr Function10611d
-
-MobileFn_1060d9: mobile ; 1060df
-	ld hl, $a054
-	jr Function10611d
-
-MobileFn_1060df: mobile ; 1060df
-	ld hl, $a057
-	jr Function10611d
-
-MobileFn_1060e5: mobile ; 1060e5
-	ld a, [hBattleTurn]
-	and a
-	ret nz
-	ld hl, $a05a
-	jr Function10611d
-
-MobileFn_1060ef: mobile ; 1060ef
-	ld hl, $a05d
-	jr Function10611d
-
-MobileFn_1060f5: mobile ; 1060f5
-	ld hl, $a060
-	jr Function10611d
-
-MobileFn_1060fb: mobile ; 1060fb
-	ld hl, $a063
-	jr Function10611d
-
-MobileFn_106101: mobile ; 106101
-	ld hl, $a066
-	jr Function10611d
-; 106107
-
-MobileFn_106107: mobile ; 106107
-	ld hl, $a069
-	jr Function10611d
-; 10610d
-
-MobileFn_10610d: mobile ; 10610d
-	ld a, [hBattleTurn]
-	and a
-	ret nz
-	ld hl, $a06c
-	jr Function10611d
-; 106117
-
-Function106117: ; 106117
-	push bc
-	ld bc, 3
-	jr Function10612d
-; 10611d
-
-Function10611d: ; 10611d
-	push bc
-	ld bc, 2
-	jr Function10612d
-; 106123
-
-Function106123: ; 106123
-	push bc
-	ld bc, 1
-	jr Function10612d
-; 106129
-
-Function106129: ; 106129
-	push bc
-	ld bc, 0
-
-Function10612d: ; 10612d
-	ld a, $5
-	call GetSRAMBank
-	push hl
-	push de
-	ld e, c
-	inc e
-.asm_106136
-	ld a, [hli]
-	inc a
-	jr nz, .asm_10613d
-	dec e
-	jr nz, .asm_106136
-
-.asm_10613d
-	pop de
-	pop hl
-	jr z, .asm_10614d
-	add hl, bc
-.asm_106142
-	inc [hl]
-	jr nz, .asm_10614d
-	ld a, c
-	and a
-	jr z, .asm_10614d
-	dec hl
-	dec c
-	jr .asm_106142
-
-.asm_10614d
-	call Function106162
-	call CloseSRAM
-	pop bc
-	ret
-; 106155
-
-MobileFn_106155: mobile ; 106155
-	ld a, $5
-	call GetSRAMBank
-	call Function106162
-	call CloseSRAM
-	ret
-; 106162
-
-Function106162: ; 106162
-	push de
-	call Function10616e
-	ld hl, $a081 ; s5_a081
-	ld [hl], d
-	inc hl
-	ld [hl], e
-	pop de
-	ret
-; 10616e
-
-Function10616e: ; 10616e
-	push bc
-	ld hl, $a001 ; s5_a001
-	ld bc, $80
-	xor a
-	ld de, 0
-.asm_106179
-	ld a, e
-	add [hl]
-	ld e, a
-	jr nc, .asm_10617f
-	inc d
-
-.asm_10617f
-	inc hl
-	dec bc
-	ld a, b
-	or c
-	jr nz, .asm_106179
-	pop bc
-	ret
-; 106187
-
-
-BackupMobileEventIndex: ; 106187
-	ld a, BANK(sMobileEventIndex)
-	call GetSRAMBank
-	ld a, [sMobileEventIndex]
-	push af
-	ld a, BANK(sMobileEventIndexBackup)
-	call GetSRAMBank
-	pop af
-	ld [sMobileEventIndexBackup], a
-	call CloseSRAM
-	ret
-; 10619d
-
-
-RestoreMobileEventIndex: ; 10619d (41:619d)
-	ld a, BANK(sMobileEventIndexBackup)
-	call GetSRAMBank
-	ld a, [sMobileEventIndexBackup]
-	push af
-	ld a, BANK(sMobileEventIndex)
-	call GetSRAMBank
-	pop af
-	ld [sMobileEventIndex], a
-	call CloseSRAM
-	ret
-; 1061b3 (41:61b3)
-
-Function1061b3: ; 1061b3
-	call Function10616e
-	ld hl, $a081 ; s5_a081
-	ld a, d
-	cp [hl]
-	ret nz
-	inc hl
-	ld a, e
-	cp [hl]
-	ret
-; 1061c0
-
-DeleteMobileEventIndex: ; 1061c0 (41:61c0)
-	ld a, BANK(sMobileEventIndex)
-	call GetSRAMBank
-	xor a
-	ld [sMobileEventIndex], a
-	call CloseSRAM
-	ret
-; 1061cd (41:61cd)
-
-Function1061cd: ; unreferenced
-	ld hl, $a001
-	ld bc, $82
-	xor a
-	call ByteFill
-	ld hl, $a07d
-	ld a, $3
-	ld [hli], a
-	ld [hl], $e8
-	call Function106162
-	ld hl, $a001
-	ld de, $a084
-	ld bc, $82
-	call CopyBytes
-	ret
-; 1061ef
-
-
-_MobilePrintNum:: ; 1061ef
-; Supports signed 31-bit integers (up to 10 digits)
-; b: Bits 0-4 = # bytes
-;    Bit 7 = set if negative
-; c: Number of digits
-; de: highest byte of number to convert
-; hl: where to print the converted string
-	push bc
-	xor a
-	ld [hPrintNum1], a
-	ld [hPrintNum2], a
-	ld [hPrintNum3], a
-	ld a, b
-	and $f
-	cp $1
-	jr z, .one_byte
-	cp $2
-	jr z, .two_bytes
-	cp $3
-	jr z, .three_bytes
-; four bytes
-	ld a, [de]
-	ld [hPrintNum1], a
-	inc de
-
-.three_bytes
-	ld a, [de]
-	ld [hPrintNum2], a
-	inc de
-
-.two_bytes
-	ld a, [de]
-	ld [hPrintNum3], a
-	inc de
-
-.one_byte
-	ld a, [de]
-	ld [hPrintNum4], a
-	inc de
-
-	push de
-	xor a
-	ld [hPrintNum9], a
-	ld a, b
-	ld [hPrintNum10], a
-	ld a, c
-	cp 2
-	jr z, .two_digits
-	ld de, ._2
-	cp 3
-	jr z, .three_to_nine_digits
-	ld de, ._3
-	cp 4
-	jr z, .three_to_nine_digits
-	ld de, ._4
-	cp 5
-	jr z, .three_to_nine_digits
-	ld de, ._5
-	cp 6
-	jr z, .three_to_nine_digits
-	ld de, ._6
-	cp 7
-	jr z, .three_to_nine_digits
-	ld de, ._7
-	cp 8
-	jr z, .three_to_nine_digits
-	ld de, ._8
-	cp 9
-	jr z, .three_to_nine_digits
-	ld de, ._9
-
-.three_to_nine_digits
-rept 3
-	inc de
-endr
-rept 2
-	dec a
-endr
-
-.digit_loop
-	push af
-	call .Function1062b2
-	call .Function1062ff
-rept 4
-	inc de
-endr
-	pop af
-	dec a
-	jr nz, .digit_loop
-
-.two_digits
-	ld c, 0
-	ld a, [hPrintNum4]
-.mod_ten_loop
-	cp 10
-	jr c, .simple_divide_done
-	sub 10
-	inc c
-	jr .mod_ten_loop
-
-.simple_divide_done
-	ld b, a
-	ld a, [hPrintNum9]
-	or c
-	ld [hPrintNum9], a
-	jr nz, .create_digit
-	call .LoadMinusTenIfNegative
-	jr .done
-
-.create_digit
-	ld a, "0"
-	add c
-	ld [hl], a
-
-.done
-	call .Function1062ff
-	ld a, "0"
-	add b
-	ld [hli], a
-	pop de
-	pop bc
-	ret
-; 106292
-
-._9	dd 1000000000
-._8	dd 100000000
-._7	dd 10000000
-._6	dd 1000000
-._5	dd 100000
-._4	dd 10000
-._3	dd 1000
-._2	dd 100
-; 1062b2
-
-.Function1062b2: ; 1062b2
-	ld c, $0
-.asm_1062b4
-	ld a, [de]
-	dec de
-	ld b, a
-	ld a, [hPrintNum4]
-	sub b
-	ld [hPrintNum8], a
-	ld a, [de]
-	dec de
-	ld b, a
-	ld a, [hPrintNum3]
-	sbc b
-	ld [hPrintNum7], a
-	ld a, [de]
-	dec de
-	ld b, a
-	ld a, [hPrintNum2]
-	sbc b
-	ld [hPrintNum6], a
-	ld a, [de]
-rept 3
-	inc de
-endr
-	ld b, a
-	ld a, [hPrintNum1]
-	sbc b
-	ld [hPrintNum5], a
-	jr c, .asm_1062eb
-	ld a, [hPrintNum5]
-	ld [hPrintNum1], a
-	ld a, [hPrintNum6]
-	ld [hPrintNum2], a
-	ld a, [hPrintNum7]
-	ld [hPrintNum3], a
-	ld a, [hPrintNum8]
-	ld [hPrintNum4], a
-	inc c
-	jr .asm_1062b4
-
-.asm_1062eb
-	ld a, [hPrintNum9]
-	or c
-	jr z, .LoadMinusTenIfNegative
-	ld a, -10
-	add c
-	ld [hl], a
-	ld [hPrintNum9], a
-	ret
-
-.LoadMinusTenIfNegative:
-	ld a, [hPrintNum10]
-	bit 7, a
-	ret z
-
-	ld [hl], -10
-	ret
-; 1062ff
-
-.Function1062ff: ; 1062ff
-	ld a, [hPrintNum10]
-	bit 7, a
-	jr nz, .asm_10630d
-	bit 6, a
-	jr z, .asm_10630d
-	ld a, [hPrintNum9]
-	and a
-	ret z
-
-.asm_10630d
-	inc hl
-	ret
-; 10630f
-
-Function10630f: ; 10630f
-	xor a
-	ld [ScriptVar], a
-	ret
-; 106314
-
-MobileFn_106314: mobile ; 106314
-	ld a, $4
-	call GetSRAMBank
-	ld a, c
-	cpl
-	ld [$b000], a
-	call CloseSRAM
-	ld a, $7
-	call GetSRAMBank
-	ld a, c
-	ld [$a800], a
-	call CloseSRAM
-	ret
-; 10632f
-
-Function10632f: ; 10632f
-	or a
-	mobile
-
-	ld a, $4
-	call GetSRAMBank
-	ld a, [$b000]
-	cpl
-	ld b, a
-	call CloseSRAM
-	ld a, $7
-	call GetSRAMBank
-	ld a, [$a800]
-	ld c, a
-	call CloseSRAM
-	ld a, c
-	cp b
-	jr nz, .asm_106359
-	and a
-	jr z, .asm_106359
-	and $8f
-	cp c
-	jr nz, .asm_106359
-	ld c, a
-	scf
-	ret
-
-.asm_106359
-	xor a
-	ld c, a
-	ret
-; 10635c
-
-Function10635c: ; 10635c
-	ld a, [wcd25]
-	bit 7, a
-	ret nz
-	ld a, [wcd25]
-	ld hl, Jumptable_10636a
-	rst JumpTable
-	ret
-; 10636a
-
-Jumptable_10636a: ; 10636a
-	dw Function10637c
-	dw Function106392
-	dw Function1063cc
-	dw Function1063d8
-	dw Function1063e5
-	dw Function1063f3
-	dw Function106403
-	dw Function106442
-	dw Function106453
-; 10637c
-
-Function10637c: ; 10637c
-	ld de, wcd30
-	ld hl, $41
-	ld bc, $41
-	ld a, $40
-	call Function3e32
-	ld a, [wcd25]
-	inc a
-	ld [wcd25], a
-	ret
-; 106392
-
-Function106392: ; 106392
-	xor a
-	ld [wcf64], a
-	ld a, [wc821]
-	bit 1, a
-	jr nz, .asm_1063a2
-	bit 0, a
-	jr z, .asm_1063bf
-	ret
-
-.asm_1063a2
-	call Function10632f
-	ld a, c
-	and a
-	jr nz, .asm_1063b4
-	ld a, $b
-	ld [wcf64], a
-	ld a, $7
-	ld [wcd25], a
-	ret
-
-.asm_1063b4
-	ld a, $7
-	ld [wcf64], a
-	ld a, $7
-	ld [wcd25], a
-	ret
-
-.asm_1063bf
-	ld a, $1
-	ld [wcf64], a
-	ld a, [wcd25]
-	inc a
-	ld [wcd25], a
-	ret
-; 1063cc
-
-Function1063cc: ; 1063cc
-	ld a, $78
-	ld [wcd42], a
-	ld a, [wcd25]
-	inc a
-	ld [wcd25], a
-
-Function1063d8: ; 1063d8
-	ld hl, wcd42
-	dec [hl]
-	ret nz
-	ld a, [wcd25]
-	inc a
-	ld [wcd25], a
-	ret
-; 1063e5
-
-Function1063e5: ; 1063e5
-	ld a, [wcf64]
-	cp $3
-	ret nz
-	ld a, [wcd25]
-	inc a
-	ld [wcd25], a
-	ret
-; 1063f3
-
-Function1063f3: ; 1063f3
-	ld de, wcd31
-	ld a, $32
-	call Function3e32
-	ld a, [wcd25]
-	inc a
-	ld [wcd25], a
-	ret
-; 106403
-
-Function106403: ; 106403
-	ld a, [wc821]
-	bit 1, a
-	jr nz, .asm_106426
-	bit 0, a
-	jr z, .asm_10640f
-	ret
-
-.asm_10640f
-	ld a, [wcd31]
-	and $80
-	ld c, a
-	ld a, [wcd30]
-	or c
-	inc a
-	ld c, a
-	call MobileFn_106314
-	ld a, [wcd25]
-	inc a
-	ld [wcd25], a
-	ret
-
-.asm_106426
-	call Function10632f
-	ld a, c
-	and a
-	jr z, .asm_106435
-	ld a, [wcd25]
-	inc a
-	ld [wcd25], a
-	ret
-
-.asm_106435
-	ld c, $0
-	call MobileFn_106314
-	ld a, [wcd25]
-	inc a
-	ld [wcd25], a
-	ret
-; 106442
-
-Function106442: ; 106442
-	ld a, $36
-	call Function3e32
-	xor a
-	ld [hMobile], a
-	ld [$ffc9], a
-	ld a, [wcd25]
-	inc a
-	ld [wcd25], a
-
-Function106453: ; 106453
-	ld a, [wcd25]
-	set 7, a
-	ld [wcd25], a
-	nop
-	ld a, $4
-	ld [wcf64], a
-	ret
-; 106462
-
-Function106462: ; 106462
-	ret
-; 106463
-
-Function106463: ; 106463
-	ret
-; 106464
-
-Function106464:: ; 106464
-	ld de, MobilePhoneTilesGFX
-	ld hl, VTiles2 tile $60
-	lb bc, BANK(MobilePhoneTilesGFX), 1
-	call Get2bpp
-	ld de, GFX_f9424
-	ld hl, VTiles2 tile $61
-	lb bc, BANK(GFX_f9424), 1
-	call Get2bpp
-	ld de, GFX_106514
-	ld hl, VTiles2 tile $62
-	ld c, 9
-	ld b, BANK(GFX_106514)
-	call Get2bpp
-	ld de, $40b0
-	ld hl, VTiles2 tile $6b
-	ld b, $f ; XXX no graphics at 0f:40b0
-	call Get2bpp
-	callba LoadFrame
-	ret
-; 10649b
-
-Function10649b: ; 10649b
-	ld a, [TextBoxFrame]
-	and $7
-	ld bc, $30
-	ld hl, Frames
-	call AddNTimes
-	ld d, h
-	ld e, l
-	ld hl, VTiles2 tile $79
-	ld c, 6
-	ld b, BANK(Frames)
-	call Function1064c3
-	ld hl, VTiles2 tile $7f
-	ld de, TextBoxSpaceGFX
-	ld c, 1
-	ld b, BANK(TextBoxSpaceGFX)
-	call Function1064c3
-	ret
-; 1064c3
-
-Function1064c3: ; 1064c3
-	ld a, [rSVBK]
-	push af
-	ld a, $6
-	ld [rSVBK], a
-	push bc
-	push hl
-	ld hl, Function3f88
-	ld a, b
-	rst FarCall
-	pop hl
-	pop bc
-	pop af
-	ld [rSVBK], a
-	jr asm_1064ed
-
-Function1064d8: ; 1064d8
-	ld a, [rSVBK]
-	push af
-	ld a, $6
-	ld [rSVBK], a
-	push bc
-	push hl
-	ld hl, Function3f9f
-	ld a, b
-	rst FarCall
-	pop hl
-	pop bc
-	pop af
-	ld [rSVBK], a
-	jr asm_1064ed
-
-asm_1064ed
-	ld de, w6_d000
-	ld b, $0
-	ld a, [rSVBK]
-	push af
-	ld a, $6
-	ld [rSVBK], a
-	ld a, [rVBK]
-	push af
-	ld a, $1
-	ld [rVBK], a
-	call Get2bpp
-	pop af
-	ld [rVBK], a
-	pop af
-	ld [rSVBK], a
-	ret
-; 10650a
-
-Function10650a: ; 10650a
-	ld de, MobilePhoneTilesGFX + $20
-	lb bc, BANK(MobilePhoneTilesGFX), $11
-	call Get2bpp
-	ret
-; 106514
-
-GFX_106514:
-INCBIN "gfx/unknown/106514.2bpp"
-
-
-Function106594:: ; 106594
-	ld de, GFX_1065ad
-	ld hl, VTiles1
-	lb bc, BANK(GFX_1065ad), $80
-	call Get2bpp
-	ld de, GFX_1065ad + $800
-	ld hl, VTiles2 tile $7f
-	lb bc, BANK(GFX_1065ad), 1
-	call Get2bpp
-	ret
-; 1065ad
-
-GFX_1065ad:
-INCBIN "gfx/unknown/1065ad.2bpp"
-
+INCLUDE "misc/mobile_41.asm"
 
 INCLUDE "misc/mobile_42.asm"
 
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -6,6 +6,7 @@
 	push af
 	ld a, $1
 	ld [rSVBK], a
+
 	call Function100022
 	call Function1000ba
 	call Function100675
@@ -12,9 +13,11 @@
 	call Function100057
 	call Function10016f
 	call Function100276
+
 	push bc
 	call Function100301
 	pop bc
+
 	pop af
 	ld [rSVBK], a
 	ret
@@ -313,11 +316,14 @@
 	callba Function106464
 	call HideSprites
 	call DelayFrame
+
 	ld a, [rSVBK]
 	push af
 	ld a, $1
 	ld [rSVBK], a
+
 	callba Function17f555
+
 	pop af
 	ld [rSVBK], a
 	ret
@@ -400,7 +406,7 @@
 	ld hl, wcd2a
 	bit 0, [hl]
 	ret z
-	callba Function3f6d0
+	callba CleanUpBattleRAM
 	callba LoadPokemonData
 	ret
 ; 1002dc
@@ -537,7 +543,7 @@
 
 Function10039c: ; 10039c
 	ld hl, wcc60
-	ld de, wd000
+	ld de, w3_d000
 	ld bc, $0054
 	ld a, $3
 	call FarCopyWRAM
@@ -545,7 +551,7 @@
 ; 1003ab
 
 Function1003ab: ; 1003ab
-	ld hl, wd000
+	ld hl, w3_d000
 	ld de, wcc60
 	ld bc, $0054
 	ld a, $3
@@ -555,7 +561,7 @@
 
 Function1003ba: ; 1003ba
 	ld hl, wccb4
-	ld de, $d080
+	ld de, w3_d080
 	ld bc, $0054
 	ld a, $3
 	call FarCopyWRAM
@@ -563,7 +569,7 @@
 ; 1003c9
 
 Function1003c9: ; 1003c9
-	ld hl, $d080
+	ld hl, w3_d080
 	ld de, wccb4
 	ld bc, $0054
 	ld a, $3
@@ -1501,7 +1507,7 @@
 	ld de, SFX_4_NOTE_DITTY
 	call PlaySFX
 	callba Function104061
-	ld c, $78
+	ld c, 120
 	call DelayFrames
 	ret
 ; 10095a
@@ -1515,10 +1521,10 @@
 
 Function100970: ; 100970
 	hlcoord 0, 0
-	ld de, wdc00
+	ld de, w3_dc00
 	call Function1009a5
 	hlcoord 0, 0, AttrMap
-	ld de, $dd68
+	ld de, w3_dd68
 	call Function1009a5
 	call Function1009d2
 	call Function1009ae
@@ -1526,12 +1532,12 @@
 ; 100989
 
 Function100989: ; 100989
-	ld hl, wdc00
+	ld hl, w3_dc00
 	decoord 0, 0
 	call Function1009a5
 	call Function1009ae
 	callba Function104061
-	ld hl, $dd68
+	ld hl, w3_dd68
 	decoord 0, 0, AttrMap
 	call Function1009a5
 	ret
@@ -1549,23 +1555,25 @@
 	push af
 	ld a, $3
 	ld [rSVBK], a
-	ld hl, $d800
+
+	ld hl, w3_d800
 	decoord 0, 0, AttrMap
-	ld c, $14
-	ld b, $12
-.asm_1009bf
+	ld c, SCREEN_WIDTH
+	ld b, SCREEN_HEIGHT
+.loop_row
 	push bc
-.asm_1009c0
+.loop_col
 	ld a, [hli]
 	ld [de], a
 	inc de
 	dec c
-	jr nz, .asm_1009c0
-	ld bc, $000c
+	jr nz, .loop_col
+	ld bc, 12
 	add hl, bc
 	pop bc
 	dec b
-	jr nz, .asm_1009bf
+	jr nz, .loop_row
+
 	pop af
 	ld [rSVBK], a
 	ret
@@ -1576,16 +1584,20 @@
 	push af
 	ld a, $3
 	ld [rSVBK], a
+
 	ld a, [rVBK]
 	push af
 	ld a, $1
 	ld [rVBK], a
-	ld hl, $d800
+
+	ld hl, w3_d800
 	ld de, VBGMap0
 	lb bc, $3, $24
 	call Get2bpp
+
 	pop af
 	ld [rVBK], a
+
 	pop af
 	ld [rSVBK], a
 	ret
@@ -1613,7 +1625,7 @@
 	ld [wd431], a
 	callba Function4000
 	ld a, [wLinkMode]
-	cp $4
+	cp LINK_MOBILE
 	jr nz, .asm_100a2a
 
 	call Function100a87
@@ -2538,7 +2550,7 @@
 	call Function10107d
 	ld a, [OTPartyCount]
 rept 2
-	ld hl, $c608
+	ld hl, wc608
 endr
 	ld bc, $01b3
 	call Function1010de
@@ -2548,7 +2560,7 @@
 	ld [hl], d
 	ld a, $7
 	call GetSRAMBank
-	ld hl, $c608
+	ld hl, wc608
 	ld de, $a001
 	ld bc, $01b5
 	call CopyBytes
@@ -2558,28 +2570,28 @@
 
 Function10107d: ; 10107d
 	xor a
-	ld hl, $c608
+	ld hl, wc608
 	ld bc, $01b5
 	call ByteFill
 	ld hl, wd26b
-	ld de, $c608
+	ld de, wc608
 	ld bc, $000b
 	call CopyBytes
 	ld hl, wd271
 	ld a, [hli]
-	ld [$c608 + 11], a
+	ld [wc608 + 11], a
 	ld a, [hl]
-	ld [$c608 + 12], a
+	ld [wc608 + 12], a
 	ld hl, OTPartyMonNicknames
-	ld de, $c608 + 13
+	ld de, wc608 + 13
 	ld bc, $000b
 	call Function1010cd
 	ld hl, OTPartyMonOT
-	ld de, $c656 + 1
+	ld de, wc656 + 1
 	ld bc, $000b
 	call Function1010cd
 	ld hl, OTPartyMon1Species
-	ld de, $c68a + 15
+	ld de, wc68a + 15
 	ld bc, $0030
 	call Function1010cd
 	ld a, $50
@@ -2707,9 +2719,9 @@
 	ld bc, $000b
 
 asm_101184:
-	ld a, $c608 % $100
+	ld a, wc608 % $100
 	ld [StringBuffer2], a
-	ld a, $c608 / $100
+	ld a, wc608 / $100
 	ld [StringBuffer2 + 1], a
 	ld a, c
 	ld [StringBuffer2 + 2], a
@@ -2751,7 +2763,7 @@
 	call Function1011df
 	ld d, h
 	ld e, l
-	ld hl, $c608
+	ld hl, wc608
 	call CopyBytes
 	ret
 ; 1011df
@@ -3368,11 +3380,11 @@
 ; 10159d
 
 Function10159d: ; 10159d
-	ld de, $c608
+	ld de, wc608
 	callba Function100edf
-	ld de, $c608
+	ld de, wc608
 	ld a, $5
-	ld hl, $d800
+	ld hl, w5_d800
 	call Function10174c
 	ld a, $0
 	ld [wcd26], a
@@ -3383,11 +3395,11 @@
 ; 1015be
 
 Function1015be: ; 1015be
-	ld de, $c608
+	ld de, wc608
 	callba Function100eed
-	ld de, $c608
+	ld de, wc608
 	ld a, $5
-	ld hl, $d800
+	ld hl, w5_d800
 	call Function10174c
 	ld a, $0
 	ld [wcd26], a
@@ -3398,11 +3410,11 @@
 ; 1015df
 
 Function1015df: ; 1015df
-	ld de, $c608
+	ld de, wc608
 	callba Function100ef4
-	ld de, $c608
+	ld de, wc608
 	ld a, $5
-	ld hl, $d800
+	ld hl, w5_d800
 	call Function10174c
 	ld a, $0
 	ld [wcd26], a
@@ -3413,12 +3425,12 @@
 ; 101600
 
 Function101600: ; 101600
-	ld hl, $d800
-	ld de, $c608
+	ld hl, w5_d800
+	ld de, wc608
 	ld bc, $01e0
 	ld a, $5
 	call FarCopyWRAM
-	ld de, $c608
+	ld de, wc608
 	callba Function100ee6
 	ld a, [wcd25]
 	inc a
@@ -3443,7 +3455,7 @@
 ; 101635
 
 Function101635: ; 101635
-	ld de, $c608
+	ld de, wc608
 	ld bc, $01e0
 	call FarCopyWRAM
 	ret
@@ -3450,7 +3462,7 @@
 ; 10163f
 
 Function10163f: ; 10163f
-	ld hl, $c608
+	ld hl, wc608
 	ld bc, $01e0
 	call FarCopyWRAM
 	ret
@@ -3458,10 +3470,10 @@
 
 Function101649: ; 101649
 	ld a, $5
-	ld hl, $d800
+	ld hl, w5_d800
 	call Function101635
 	ld a, $5
-	ld de, wda00
+	ld de, w5_da00
 	call Function10163f
 	ret
 ; 10165a
@@ -3468,7 +3480,7 @@
 
 Function10165a: ; 10165a
 	ld a, $5
-	ld hl, wda00
+	ld hl, w5_da00
 	call Function101635
 	ret
 ; 101663
@@ -3475,10 +3487,10 @@
 
 Function101663: ; 101663
 	ld a, $5
-	ld hl, $d800
+	ld hl, w5_d800
 	call Function101635
 	ld a, $5
-	ld de, wdc00
+	ld de, w5_dc00
 	call Function10163f
 	ret
 ; 101674
@@ -3485,7 +3497,7 @@
 
 Function101674: ; 101674 ; unreferenced
 	ld a, $5
-	ld hl, wdc00
+	ld hl, w5_dc00
 	call Function101635
 	ret
 ; 10167d
@@ -4008,16 +4020,19 @@
 	push af
 	ld a, $5
 	ld [rSVBK], a
-	ld bc, wdc0d
-	ld de, wdc11
+
+	ld bc, w5_dc0d
+	ld de, w5_dc11
 	callba Function4e929
+
 	pop af
 	ld [rSVBK], a
+
 	ld a, c
 	ld [OtherTrainerClass], a
 	ld hl, wd26b
-	ld de, $c656
-	ld bc, $000b
+	ld de, wc656
+	ld bc, NAME_LENGTH
 	call CopyBytes
 	ld a, [wcd2f]
 	and a
@@ -4040,8 +4055,8 @@
 	ld a, $1
 	ld [wc2d7], a
 	callba BattleIntro
-	callba Function3c000
-	callba Function3f759
+	callba SendOutFirstMons
+	callba ShowLinkBattleParticipantsAfterEnd
 	xor a
 	ld [wc2d7], a
 	ld a, $ff
@@ -4057,7 +4072,7 @@
 	callba Function3f77c
 	xor a
 	ld [wc2d7], a
-	callba Function3f6d0
+	callba CleanUpBattleRAM
 	callba LoadPokemonData
 	call Function1013c0
 	ld a, [wcd25]
@@ -4940,10 +4955,10 @@
 	bit 2, [hl]
 	jr nz, .asm_102110
 	call Function10218d
-	ld hl, $c608
+	ld hl, wc608
 	bit 4, [hl]
 	jr z, .asm_102110
-	ld hl, $c608
+	ld hl, wc608
 	bit 2, [hl]
 	jr nz, .asm_102110
 	call Function102112
@@ -4963,7 +4978,7 @@
 	ld c, $28
 .asm_10211c
 	push hl
-	ld de, $c60f
+	ld de, wc60f
 	ld b, $1f
 .asm_102122
 	ld a, [de]
@@ -5022,7 +5037,7 @@
 ; 102180
 
 Function102180: ; 102180
-	ld hl, $c608 + 1
+	ld hl, wc608 + 1
 	ld de, StringBuffer2
 	ld bc, $000b
 	call CopyBytes
@@ -5031,11 +5046,11 @@
 
 Function10218d: ; 10218d
 	ld hl, wdc00
-	ld de, $c608
+	ld de, wc608
 	ld bc, $0026
 	ld a, $5
 	call FarCopyWRAM
-	ld de, $c608 + 1
+	ld de, wc608 + 1
 	ret
 ; 10219f
 
@@ -5042,7 +5057,7 @@
 Function10219f: ; 10219f
 	call FadeToMenu
 	call Function10218d
-	ld de, $c608 + 1
+	ld de, wc608 + 1
 	callba Function8ac4e
 	call JoyWaitAorB
 	call PlayClickSFX
@@ -5053,7 +5068,7 @@
 Function1021b8: ; 1021b8
 	call FadeToMenu
 	call Function10218d
-	ld de, $c60f
+	ld de, wc60f
 	callba Function8ac70
 	ld a, c
 	ld [StringBuffer1], a
@@ -6336,7 +6351,7 @@
 	ld a, [wcd30]
 	ld [wc74e], a
 	ld hl, PlayerName
-	ld de, $c6e7
+	ld de, wc6e7
 	ld bc, $000b
 	call CopyBytes
 	ld a, [wcd4c]
@@ -6346,12 +6361,12 @@
 	ld hl, PartySpecies
 	add hl, bc
 	ld a, [hl]
-	ld [$c6d0], a
+	ld [wc6d0], a
 	ld a, [wcd4c]
 	dec a
 	ld hl, PartyMonOT
 	call SkipNames
-	ld de, $c6f2
+	ld de, wc6f2
 	ld bc, $000b
 	call CopyBytes
 	ld a, [wcd4c]
@@ -6359,7 +6374,7 @@
 	ld hl, PartyMon1ID
 	call GetPartyLocation
 	ld a, [hli]
-	ld [$c6ff], a
+	ld [wc6ff], a
 	ld a, [hl]
 	ld [wc700], a
 	ld a, [wcd4c]
@@ -6367,9 +6382,9 @@
 	ld hl, PartyMon1DVs
 	call GetPartyLocation
 	ld a, [hli]
-	ld [$c6fd], a
+	ld [wc6fd], a
 	ld a, [hl]
-	ld [$c6fe], a
+	ld [wc6fe], a
 	ld a, [wcd4c]
 	dec a
 	ld hl, PartyMon1Species
@@ -6606,11 +6621,11 @@
 	ld a, $0
 	call GetSRAMBank
 	ld hl, $a600
-	ld de, $c608
+	ld de, wc608
 	ld bc, $002f
 	call Function102c71
 	call CloseSRAM
-	ld hl, $c608
+	ld hl, wc608
 	ld de, wda00
 	ld bc, $01e0
 	ld a, $5
@@ -6644,12 +6659,12 @@
 	ld [wcf64], a
 	ld a, $0
 	ld hl, $a600
-	ld de, $c608
+	ld de, wc608
 	ld bc, $011a
 	call Function102d3e
 	call Function102cee
 	ld a, $0
-	ld hl, $c608
+	ld hl, wc608
 	ld de, $a600
 	ld bc, $011a
 	call Function102d3e
@@ -6659,12 +6674,12 @@
 	ld [wcf64], a
 	ld a, $5
 	ld hl, wda00
-	ld de, $c608
+	ld de, wc608
 	ld bc, $011a
 	call FarCopyWRAM
 	call Function102cee
 	ld a, $5
-	ld hl, $c608
+	ld hl, wc608
 	ld de, wda00
 	ld bc, $011a
 	call FarCopyWRAM
@@ -6712,7 +6727,7 @@
 ; 102d34
 
 Function102d34: ; 102d34
-	ld hl, $c608
+	ld hl, wc608
 	ld bc, $002f
 	call AddNTimes
 	ret
--- /dev/null
+++ b/misc/mobile_41.asm
@@ -1,0 +1,1094 @@
+SECTION "bank41_2", ROMX, BANK[$41]
+
+Mobile_HallOfFame2:: mobile ; 0x105ef6
+	ld a, $5
+	call GetSRAMBank
+	ld hl, GameTimeHours
+	ld de, $a001
+	ld bc, 4
+	call CopyBytes
+	ld hl, $a010
+	ld de, $a005
+	ld bc, 4
+	call CopyBytes
+	ld hl, $a039
+	ld de, $a009
+	ld bc, 4
+	call CopyBytes
+	ld hl, $a01b
+	ld de, $a00d
+	ld bc, 3
+	call CopyBytes
+	call Function106162
+	call CloseSRAM
+	ret
+; 105f33
+
+MagikarpLength_Mobile: mobile ; 105f33
+	ld a, $5
+	call GetSRAMBank
+	ld de, Buffer1
+	ld hl, $a07b
+	ld a, [de]
+	cp [hl]
+	jr z, .asm_105f47
+	jr nc, .asm_105f4f
+	jr .asm_105f55
+
+.asm_105f47
+	inc hl
+	inc de
+	ld a, [de]
+	cp [hl]
+	dec hl
+	dec de
+	jr c, .asm_105f55
+
+.asm_105f4f
+	ld a, [de]
+	inc de
+	ld [hli], a
+	ld a, [de]
+	dec de
+	ld [hl], a
+
+.asm_105f55
+	ld hl, $a07d
+	ld a, [hli]
+	or [hl]
+	dec hl
+	jr z, .asm_105f6d
+	ld a, [de]
+	cp [hl]
+	jr z, .asm_105f65
+	jr c, .asm_105f6d
+	jr .asm_105f72
+
+.asm_105f65
+	inc hl
+	inc de
+	ld a, [de]
+	cp [hl]
+	jr nc, .asm_105f72
+	dec hl
+	dec de
+
+.asm_105f6d
+	ld a, [de]
+	inc de
+	ld [hli], a
+	ld a, [de]
+	ld [hl], a
+
+.asm_105f72
+	call Function106162
+	call CloseSRAM
+	ret
+; 105f79
+
+MobileFn_105f79: mobile ; 105f79
+	ld a, $5
+	call GetSRAMBank
+	ld a, [hProduct]
+	ld hl, $a07f
+	cp [hl]
+	jr z, .asm_105f8b
+	jr nc, .asm_105f92
+	jr .asm_105f98
+
+.asm_105f8b
+	inc hl
+	ld a, [hMultiplicand]
+	cp [hl]
+	jr c, .asm_105f98
+	dec hl
+
+.asm_105f92
+	ld a, [hProduct]
+	ld [hli], a
+	ld a, [hMultiplicand]
+	ld [hl], a
+
+.asm_105f98
+	call Function106162
+	call CloseSRAM
+	ret
+; 105f9f
+
+MobileFn_105f9f: mobile ; 105f9f
+	ld a, $5
+	call GetSRAMBank
+	ld hl, $a070
+	inc [hl]
+	jr nz, .asm_105fae
+	dec hl
+	inc [hl]
+	inc hl
+
+.asm_105fae
+	dec hl
+	ld a, [$a071]
+	cp [hl]
+	jr z, .asm_105fb9
+	jr c, .asm_105fc1
+	jr .asm_105fc9
+
+.asm_105fb9
+	inc hl
+	ld a, [$a072]
+	cp [hl]
+	jr nc, .asm_105fc9
+	dec hl
+
+.asm_105fc1
+	ld a, [hli]
+	ld [$a071], a
+	ld a, [hl]
+	ld [$a072], a
+
+.asm_105fc9
+	call Function106162
+	call CloseSRAM
+	ret
+; 105fd0
+
+MobileFn_105fd0: mobile ; 105fd0
+	ld a, $5
+	call GetSRAMBank
+	ld hl, $a06f
+	xor a
+	ld [hli], a
+	ld [hl], a
+	call Function106162
+	call CloseSRAM
+	ret
+; 105fe3
+
+MobileFn_105fe3: mobile ; 105fe3
+	ld a, $5
+	call GetSRAMBank
+	ld hl, $a076
+	ld a, e
+	add [hl]
+	ld [hld], a
+	ld a, d
+	adc [hl]
+	ld [hld], a
+	jr nc, .asm_106001
+	inc [hl]
+	jr nz, .asm_106001
+	dec hl
+	inc [hl]
+	jr nz, .asm_106001
+	ld a, $ff
+rept 3
+	ld [hli], a
+endr
+	ld [hl], a
+
+.asm_106001
+	call Function106162
+	call CloseSRAM
+	ret
+; 106008
+
+MobileFn_106008: mobile ; 106008
+	ld a, $5
+	call GetSRAMBank
+	ld hl, $a07a
+	ld a, [bc]
+	dec bc
+	add [hl]
+	ld [hld], a
+	ld a, [bc]
+	dec bc
+	adc [hl]
+	ld [hld], a
+	ld a, [bc]
+	adc [hl]
+	ld [hld], a
+	jr nc, .asm_106027
+	inc [hl]
+	jr nz, .asm_106027
+	ld a, $ff
+rept 3
+	ld [hli], a
+endr
+	ld [hl], a
+
+.asm_106027
+	call Function106162
+	call CloseSRAM
+	ret
+; 10602e
+
+MobileFn_10602e: mobile ; 10602e (41:602e)
+	ld hl, $a010
+	jp MobileFn_106117
+
+MobileFn_106035: mobile ; 106035
+	ld a, $5
+	call GetSRAMBank
+	ld a, [$aa8d]
+	and a
+	call CloseSRAM
+	ret nz
+	ld hl, $a014
+	jp Function106123
+
+MobileFn_106049: mobile ; 106049
+	ld hl, $a018
+	jp Function10611d
+
+MobileFn_106050: mobile ; 106050
+	ld a, [BattleType]
+	cp BATTLETYPE_TUTORIAL
+	ret z
+	ld hl, $a01b
+	jp Function10611d
+
+MobileFn_10605d: mobile ; 10605d
+	ld a, [BattleType]
+	cp BATTLETYPE_TUTORIAL
+	ret z
+	ld hl, $a01e
+	jp Function10611d
+
+MobileFn_10606a: mobile ; 10606a
+	ld hl, $a021
+	jp Function10611d
+
+MobileFn_106071: mobile ; 106071
+	ld hl, $a024
+	jp Function10611d
+
+Mobile_HallOfFame:: mobile ; 0x106078
+	ld hl, $a027
+	jp Function10611d
+
+MobileFn_10607f: mobile ; 10607f (41:607f)
+	ld hl, $a02a
+	jp Function10611d
+
+MobileFn_106086: mobile ; 106086
+	ld hl, $a02d
+	jp Function10611d
+
+MobileFn_10608d: mobile ; 10608d (41:608d)
+	ld hl, $a030
+	jp Function10611d
+
+MobileFn_106094: mobile ; 106094
+	ld hl, $a033
+	jp Function10611d
+
+MobileFn_10609b: mobile ; 10609b
+	ld hl, $a036
+	jp Function10611d
+
+Mobile_HealParty: mobile ; 1060a2
+	ld hl, $a039
+	jp Function10611d
+
+MobileFn_1060a9: mobile ; 1060a9 (41:60a9)
+	ld hl, $a03c
+	jr Function10611d
+
+MobileFn_1060af: mobile ; 1060af
+	ld hl, $a03f
+	jr Function10611d
+
+MobileFn_1060b5: mobile ; 1060b5
+	ld hl, $a042
+	jr Function10611d
+
+MobileFn_1060bb: mobile ; 1060bb
+	ld hl, $a045
+	jr Function10611d
+
+MobileFn_1060c1: mobile ; 1060c1
+	ld hl, $a048
+	jr Function10611d
+
+MobileFn_1060c7: mobile ; 1060c7
+	ld hl, $a04b
+	jr Function10611d
+
+MobileFn_1060cd: mobile ; 1060cd
+	ld hl, $a04e
+	jr Function106123
+
+MobileFn_1060d3: mobile ; 1060d3
+	ld hl, $a051
+	jr Function10611d
+
+MobileFn_1060d9: mobile ; 1060df
+	ld hl, $a054
+	jr Function10611d
+
+MobileFn_1060df: mobile ; 1060df
+	ld hl, $a057
+	jr Function10611d
+
+MobileFn_1060e5: mobile ; 1060e5
+	ld a, [hBattleTurn]
+	and a
+	ret nz
+	ld hl, $a05a
+	jr Function10611d
+
+MobileFn_1060ef: mobile ; 1060ef
+	ld hl, $a05d
+	jr Function10611d
+
+MobileFn_1060f5: mobile ; 1060f5
+	ld hl, $a060
+	jr Function10611d
+
+MobileFn_SaveBattleResult_Win: mobile ; win
+	ld hl, $a063
+	jr Function10611d
+
+MobileFn_SaveBattleResult_Lose: mobile ; lose
+	ld hl, $a066
+	jr Function10611d
+; 106107
+
+MobileFn_SaveBattleResult_Draw: mobile ; draw
+	ld hl, $a069
+	jr Function10611d
+; 10610d
+
+MobileFn_10610d: mobile ; 10610d
+	ld a, [hBattleTurn]
+	and a
+	ret nz
+	ld hl, $a06c
+	jr Function10611d
+; 106117
+
+MobileFn_106117: ; 106117
+	push bc
+	ld bc, 3
+	jr Function10612d
+; 10611d
+
+Function10611d: ; 10611d
+	push bc
+	ld bc, 2
+	jr Function10612d
+; 106123
+
+Function106123: ; 106123
+	push bc
+	ld bc, 1
+	jr Function10612d
+; 106129
+
+Function106129: ; 106129
+	push bc
+	ld bc, 0
+
+Function10612d: ; 10612d
+	ld a, $5
+	call GetSRAMBank
+	push hl
+	push de
+	ld e, c
+	inc e
+.asm_106136
+	ld a, [hli]
+	inc a
+	jr nz, .asm_10613d
+	dec e
+	jr nz, .asm_106136
+
+.asm_10613d
+	pop de
+	pop hl
+	jr z, .asm_10614d
+	add hl, bc
+.asm_106142
+	inc [hl]
+	jr nz, .asm_10614d
+	ld a, c
+	and a
+	jr z, .asm_10614d
+	dec hl
+	dec c
+	jr .asm_106142
+
+.asm_10614d
+	call Function106162
+	call CloseSRAM
+	pop bc
+	ret
+; 106155
+
+MobileFn_106155: mobile ; 106155
+	ld a, $5
+	call GetSRAMBank
+	call Function106162
+	call CloseSRAM
+	ret
+; 106162
+
+Function106162: ; 106162
+	push de
+	call Function10616e
+	ld hl, $a081 ; s5_a081
+	ld [hl], d
+	inc hl
+	ld [hl], e
+	pop de
+	ret
+; 10616e
+
+Function10616e: ; 10616e
+	push bc
+	ld hl, $a001 ; s5_a001
+	ld bc, $80
+	xor a
+	ld de, 0
+.asm_106179
+	ld a, e
+	add [hl]
+	ld e, a
+	jr nc, .asm_10617f
+	inc d
+
+.asm_10617f
+	inc hl
+	dec bc
+	ld a, b
+	or c
+	jr nz, .asm_106179
+	pop bc
+	ret
+; 106187
+
+
+BackupMobileEventIndex: ; 106187
+	ld a, BANK(sMobileEventIndex)
+	call GetSRAMBank
+	ld a, [sMobileEventIndex]
+	push af
+	ld a, BANK(sMobileEventIndexBackup)
+	call GetSRAMBank
+	pop af
+	ld [sMobileEventIndexBackup], a
+	call CloseSRAM
+	ret
+; 10619d
+
+
+RestoreMobileEventIndex: ; 10619d (41:619d)
+	ld a, BANK(sMobileEventIndexBackup)
+	call GetSRAMBank
+	ld a, [sMobileEventIndexBackup]
+	push af
+	ld a, BANK(sMobileEventIndex)
+	call GetSRAMBank
+	pop af
+	ld [sMobileEventIndex], a
+	call CloseSRAM
+	ret
+; 1061b3 (41:61b3)
+
+Function1061b3: ; 1061b3
+	call Function10616e
+	ld hl, $a081 ; s5_a081
+	ld a, d
+	cp [hl]
+	ret nz
+	inc hl
+	ld a, e
+	cp [hl]
+	ret
+; 1061c0
+
+DeleteMobileEventIndex: ; 1061c0 (41:61c0)
+	ld a, BANK(sMobileEventIndex)
+	call GetSRAMBank
+	xor a
+	ld [sMobileEventIndex], a
+	call CloseSRAM
+	ret
+; 1061cd (41:61cd)
+
+Function1061cd: ; unreferenced
+	ld hl, $a001
+	ld bc, $82
+	xor a
+	call ByteFill
+	ld hl, $a07d
+	ld a, $3
+	ld [hli], a
+	ld [hl], $e8
+	call Function106162
+	ld hl, $a001
+	ld de, $a084
+	ld bc, $82
+	call CopyBytes
+	ret
+; 1061ef
+
+
+_MobilePrintNum:: ; 1061ef
+; Supports signed 31-bit integers (up to 10 digits)
+; b: Bits 0-4 = # bytes
+;    Bit 7 = set if negative
+; c: Number of digits
+; de: highest byte of number to convert
+; hl: where to print the converted string
+	push bc
+	xor a
+	ld [hPrintNum1], a
+	ld [hPrintNum2], a
+	ld [hPrintNum3], a
+	ld a, b
+	and $f
+	cp $1
+	jr z, .one_byte
+	cp $2
+	jr z, .two_bytes
+	cp $3
+	jr z, .three_bytes
+; four bytes
+	ld a, [de]
+	ld [hPrintNum1], a
+	inc de
+
+.three_bytes
+	ld a, [de]
+	ld [hPrintNum2], a
+	inc de
+
+.two_bytes
+	ld a, [de]
+	ld [hPrintNum3], a
+	inc de
+
+.one_byte
+	ld a, [de]
+	ld [hPrintNum4], a
+	inc de
+
+	push de
+	xor a
+	ld [hPrintNum9], a
+	ld a, b
+	ld [hPrintNum10], a
+	ld a, c
+	cp 2
+	jr z, .two_digits
+	ld de, ._2
+	cp 3
+	jr z, .three_to_nine_digits
+	ld de, ._3
+	cp 4
+	jr z, .three_to_nine_digits
+	ld de, ._4
+	cp 5
+	jr z, .three_to_nine_digits
+	ld de, ._5
+	cp 6
+	jr z, .three_to_nine_digits
+	ld de, ._6
+	cp 7
+	jr z, .three_to_nine_digits
+	ld de, ._7
+	cp 8
+	jr z, .three_to_nine_digits
+	ld de, ._8
+	cp 9
+	jr z, .three_to_nine_digits
+	ld de, ._9
+
+.three_to_nine_digits
+rept 3
+	inc de
+endr
+rept 2
+	dec a
+endr
+
+.digit_loop
+	push af
+	call .Function1062b2
+	call .Function1062ff
+rept 4
+	inc de
+endr
+	pop af
+	dec a
+	jr nz, .digit_loop
+
+.two_digits
+	ld c, 0
+	ld a, [hPrintNum4]
+.mod_ten_loop
+	cp 10
+	jr c, .simple_divide_done
+	sub 10
+	inc c
+	jr .mod_ten_loop
+
+.simple_divide_done
+	ld b, a
+	ld a, [hPrintNum9]
+	or c
+	ld [hPrintNum9], a
+	jr nz, .create_digit
+	call .LoadMinusTenIfNegative
+	jr .done
+
+.create_digit
+	ld a, "0"
+	add c
+	ld [hl], a
+
+.done
+	call .Function1062ff
+	ld a, "0"
+	add b
+	ld [hli], a
+	pop de
+	pop bc
+	ret
+; 106292
+
+._9	dd 1000000000
+._8	dd 100000000
+._7	dd 10000000
+._6	dd 1000000
+._5	dd 100000
+._4	dd 10000
+._3	dd 1000
+._2	dd 100
+; 1062b2
+
+.Function1062b2: ; 1062b2
+	ld c, $0
+.asm_1062b4
+	ld a, [de]
+	dec de
+	ld b, a
+	ld a, [hPrintNum4]
+	sub b
+	ld [hPrintNum8], a
+	ld a, [de]
+	dec de
+	ld b, a
+	ld a, [hPrintNum3]
+	sbc b
+	ld [hPrintNum7], a
+	ld a, [de]
+	dec de
+	ld b, a
+	ld a, [hPrintNum2]
+	sbc b
+	ld [hPrintNum6], a
+	ld a, [de]
+rept 3
+	inc de
+endr
+	ld b, a
+	ld a, [hPrintNum1]
+	sbc b
+	ld [hPrintNum5], a
+	jr c, .asm_1062eb
+	ld a, [hPrintNum5]
+	ld [hPrintNum1], a
+	ld a, [hPrintNum6]
+	ld [hPrintNum2], a
+	ld a, [hPrintNum7]
+	ld [hPrintNum3], a
+	ld a, [hPrintNum8]
+	ld [hPrintNum4], a
+	inc c
+	jr .asm_1062b4
+
+.asm_1062eb
+	ld a, [hPrintNum9]
+	or c
+	jr z, .LoadMinusTenIfNegative
+	ld a, -10
+	add c
+	ld [hl], a
+	ld [hPrintNum9], a
+	ret
+
+.LoadMinusTenIfNegative:
+	ld a, [hPrintNum10]
+	bit 7, a
+	ret z
+
+	ld [hl], -10
+	ret
+; 1062ff
+
+.Function1062ff: ; 1062ff
+	ld a, [hPrintNum10]
+	bit 7, a
+	jr nz, .asm_10630d
+	bit 6, a
+	jr z, .asm_10630d
+	ld a, [hPrintNum9]
+	and a
+	ret z
+
+.asm_10630d
+	inc hl
+	ret
+; 10630f
+
+Function10630f: ; 10630f
+	xor a
+	ld [ScriptVar], a
+	ret
+; 106314
+
+MobileFn_106314: mobile ; 106314
+	ld a, $4
+	call GetSRAMBank
+	ld a, c
+	cpl
+	ld [$b000], a
+	call CloseSRAM
+	ld a, $7
+	call GetSRAMBank
+	ld a, c
+	ld [$a800], a
+	call CloseSRAM
+	ret
+; 10632f
+
+Function10632f: ; 10632f
+	or a
+	mobile
+
+	ld a, $4
+	call GetSRAMBank
+	ld a, [$b000]
+	cpl
+	ld b, a
+	call CloseSRAM
+	ld a, $7
+	call GetSRAMBank
+	ld a, [$a800]
+	ld c, a
+	call CloseSRAM
+	ld a, c
+	cp b
+	jr nz, .asm_106359
+	and a
+	jr z, .asm_106359
+	and $8f
+	cp c
+	jr nz, .asm_106359
+	ld c, a
+	scf
+	ret
+
+.asm_106359
+	xor a
+	ld c, a
+	ret
+; 10635c
+
+Function10635c: ; 10635c
+	ld a, [wcd25]
+	bit 7, a
+	ret nz
+	ld a, [wcd25]
+	ld hl, Jumptable_10636a
+	rst JumpTable
+	ret
+; 10636a
+
+Jumptable_10636a: ; 10636a
+	dw Function10637c
+	dw Function106392
+	dw Function1063cc
+	dw Function1063d8
+	dw Function1063e5
+	dw Function1063f3
+	dw Function106403
+	dw Function106442
+	dw Function106453
+; 10637c
+
+Function10637c: ; 10637c
+	ld de, wcd30
+	ld hl, $41
+	ld bc, $41
+	ld a, $40
+	call Function3e32
+	ld a, [wcd25]
+	inc a
+	ld [wcd25], a
+	ret
+; 106392
+
+Function106392: ; 106392
+	xor a
+	ld [wcf64], a
+	ld a, [wc821]
+	bit 1, a
+	jr nz, .asm_1063a2
+	bit 0, a
+	jr z, .asm_1063bf
+	ret
+
+.asm_1063a2
+	call Function10632f
+	ld a, c
+	and a
+	jr nz, .asm_1063b4
+	ld a, $b
+	ld [wcf64], a
+	ld a, $7
+	ld [wcd25], a
+	ret
+
+.asm_1063b4
+	ld a, $7
+	ld [wcf64], a
+	ld a, $7
+	ld [wcd25], a
+	ret
+
+.asm_1063bf
+	ld a, $1
+	ld [wcf64], a
+	ld a, [wcd25]
+	inc a
+	ld [wcd25], a
+	ret
+; 1063cc
+
+Function1063cc: ; 1063cc
+	ld a, $78
+	ld [wcd42], a
+	ld a, [wcd25]
+	inc a
+	ld [wcd25], a
+
+Function1063d8: ; 1063d8
+	ld hl, wcd42
+	dec [hl]
+	ret nz
+	ld a, [wcd25]
+	inc a
+	ld [wcd25], a
+	ret
+; 1063e5
+
+Function1063e5: ; 1063e5
+	ld a, [wcf64]
+	cp $3
+	ret nz
+	ld a, [wcd25]
+	inc a
+	ld [wcd25], a
+	ret
+; 1063f3
+
+Function1063f3: ; 1063f3
+	ld de, wcd31
+	ld a, $32
+	call Function3e32
+	ld a, [wcd25]
+	inc a
+	ld [wcd25], a
+	ret
+; 106403
+
+Function106403: ; 106403
+	ld a, [wc821]
+	bit 1, a
+	jr nz, .asm_106426
+	bit 0, a
+	jr z, .asm_10640f
+	ret
+
+.asm_10640f
+	ld a, [wcd31]
+	and $80
+	ld c, a
+	ld a, [wcd30]
+	or c
+	inc a
+	ld c, a
+	call MobileFn_106314
+	ld a, [wcd25]
+	inc a
+	ld [wcd25], a
+	ret
+
+.asm_106426
+	call Function10632f
+	ld a, c
+	and a
+	jr z, .asm_106435
+	ld a, [wcd25]
+	inc a
+	ld [wcd25], a
+	ret
+
+.asm_106435
+	ld c, $0
+	call MobileFn_106314
+	ld a, [wcd25]
+	inc a
+	ld [wcd25], a
+	ret
+; 106442
+
+Function106442: ; 106442
+	ld a, $36
+	call Function3e32
+	xor a
+	ld [hMobile], a
+	ld [$ffc9], a
+	ld a, [wcd25]
+	inc a
+	ld [wcd25], a
+
+Function106453: ; 106453
+	ld a, [wcd25]
+	set 7, a
+	ld [wcd25], a
+	nop
+	ld a, $4
+	ld [wcf64], a
+	ret
+; 106462
+
+Function106462: ; 106462
+	ret
+; 106463
+
+Function106463: ; 106463
+	ret
+; 106464
+
+Function106464:: ; 106464
+	ld de, MobilePhoneTilesGFX
+	ld hl, VTiles2 tile $60
+	lb bc, BANK(MobilePhoneTilesGFX), 1
+	call Get2bpp
+	ld de, GFX_f9424
+	ld hl, VTiles2 tile $61
+	lb bc, BANK(GFX_f9424), 1
+	call Get2bpp
+	ld de, GFX_106514
+	ld hl, VTiles2 tile $62
+	ld c, 9
+	ld b, BANK(GFX_106514)
+	call Get2bpp
+	ld de, $40b0
+	ld hl, VTiles2 tile $6b
+	ld b, $f ; XXX no graphics at 0f:40b0
+	call Get2bpp
+	callba LoadFrame
+	ret
+; 10649b
+
+Function10649b: ; 10649b
+	ld a, [TextBoxFrame]
+	and $7
+	ld bc, $30
+	ld hl, Frames
+	call AddNTimes
+	ld d, h
+	ld e, l
+	ld hl, VTiles2 tile $79
+	ld c, 6
+	ld b, BANK(Frames)
+	call Function1064c3
+	ld hl, VTiles2 tile $7f
+	ld de, TextBoxSpaceGFX
+	ld c, 1
+	ld b, BANK(TextBoxSpaceGFX)
+	call Function1064c3
+	ret
+; 1064c3
+
+Function1064c3: ; 1064c3
+	ld a, [rSVBK]
+	push af
+	ld a, $6
+	ld [rSVBK], a
+	push bc
+	push hl
+	ld hl, Function3f88
+	ld a, b
+	rst FarCall
+	pop hl
+	pop bc
+	pop af
+	ld [rSVBK], a
+	jr asm_1064ed
+
+Function1064d8: ; 1064d8
+	ld a, [rSVBK]
+	push af
+	ld a, $6
+	ld [rSVBK], a
+	push bc
+	push hl
+	ld hl, Function3f9f
+	ld a, b
+	rst FarCall
+	pop hl
+	pop bc
+	pop af
+	ld [rSVBK], a
+	jr asm_1064ed
+
+asm_1064ed
+	ld de, w6_d000
+	ld b, $0
+	ld a, [rSVBK]
+	push af
+	ld a, $6
+	ld [rSVBK], a
+	ld a, [rVBK]
+	push af
+	ld a, $1
+	ld [rVBK], a
+	call Get2bpp
+	pop af
+	ld [rVBK], a
+	pop af
+	ld [rSVBK], a
+	ret
+; 10650a
+
+Function10650a: ; 10650a
+	ld de, MobilePhoneTilesGFX + $20
+	lb bc, BANK(MobilePhoneTilesGFX), $11
+	call Get2bpp
+	ret
+; 106514
+
+GFX_106514:
+INCBIN "gfx/unknown/106514.2bpp"
+
+
+Function106594:: ; 106594
+	ld de, GFX_1065ad
+	ld hl, VTiles1
+	lb bc, BANK(GFX_1065ad), $80
+	call Get2bpp
+	ld de, GFX_1065ad + $800
+	ld hl, VTiles2 tile $7f
+	lb bc, BANK(GFX_1065ad), 1
+	call Get2bpp
+	ret
+; 1065ad
+
+GFX_1065ad:
+INCBIN "gfx/unknown/1065ad.2bpp"
--- a/wram.asm
+++ b/wram.asm
@@ -757,6 +757,7 @@
 
 wc6fc:: ds 1
 wc6fd:: ds 1
+wc6fe::
 wPlayerMinimized:: ds 1 ; c6fe
 wc6ff::
 PlayerScreens:: ; c6ff
@@ -2741,7 +2742,9 @@
 SECTION "WRAM 3", WRAMX, BANK [3]
 
 w3_d000:: ; d000
-	ds $90
+	ds $80
+w3_d080::
+	ds $10
 w3_d090::
 	ds $70
 
@@ -2753,7 +2756,9 @@
 	ds $600
 
 wBTChoiceOfLvlGroup::
-w3_d800:: ds 1
+w3_d800:: ds $400
+w3_dc00:: ds $168
+w3_dd68::
 
 
 SECTION "GBC Video", WRAMX, BANK [5]
@@ -2819,7 +2824,18 @@
 w5_d422:: ds $32
 wBattleAnimEnd::
 	ds $e
+; d462
 
+SECTION "WRAM 5 MOBILE", WRAMX [$d800], BANK [5]
+w5_d800:: ds $200
+w5_da00:: ds $200
+w5_dc00:: ds $d
+w5_dc0d:: ds 4
+w5_dc11:: ds 9
+w5_dc1a:: ds $c
+w5_dc26:: ds $c
+w5_dc32:: ds $c
+w5_dc3e:: ds $c
 
 SECTION "WRAM 6", WRAMX, BANK [6]