shithub: pokecrystal

Download patch

ref: bc3a21193dd522284818c724fb52b887973c281e
parent: dbe4c7ab67cb88ef4ce725598b2082b13a566776
author: yenatch <yenatch@gmail.com>
date: Tue Jun 17 20:55:44 EDT 2014

Residual damage, battle text labels, pic predefs.

--- a/battle/anim_commands.asm
+++ b/battle/anim_commands.asm
@@ -956,7 +956,7 @@
 	ld hl, BattleMonDVs ; $c632
 	predef GetUnownLetter
 	ld de, $8000
-	predef Function51077
+	predef GetFrontpic
 	jr .done
 
 .player
@@ -965,7 +965,7 @@
 	ld hl, EnemyMonDVs ; $d20c
 	predef GetUnownLetter
 	ld de, $8000
-	predef Function5116c
+	predef GetBackpic
 
 .done
 	pop af
@@ -1192,7 +1192,7 @@
 	ld hl, BattleMonDVs ; $c632
 	predef GetUnownLetter
 	ld de, $9000
-	predef Function51077
+	predef GetFrontpic
 	jr .done
 
 .player
@@ -1199,7 +1199,7 @@
 	ld hl, EnemyMonDVs ; $d20c
 	predef GetUnownLetter
 	ld de, $9310
-	predef Function5116c
+	predef GetBackpic
 
 .done
 	pop af
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -307,7 +307,7 @@
 ; 3c23c
 
 Function3c23c: ; 3c23c
-	call Function3c710
+	call HasPlayerFainted
 	jr nz, .asm_3c24a
 	call Function3d14e
 	ld a, [BattleEnded]
@@ -315,7 +315,7 @@
 	jr nz, .asm_3c25a
 
 .asm_3c24a
-	call Function3c70b
+	call HasEnemyFainted
 	jr nz, .asm_3c258
 	call Function3cd55
 	ld a, [BattleEnded]
@@ -332,7 +332,7 @@
 ; 3c25c
 
 Function3c25c: ; 3c25c
-	call Function3c70b
+	call HasEnemyFainted
 	jr nz, .asm_3c26a
 	call Function3cd55
 	ld a, [BattleEnded]
@@ -340,7 +340,7 @@
 	jr nz, .asm_3c27a
 
 .asm_3c26a
-	call Function3c710
+	call HasPlayerFainted
 	jr nz, .asm_3c278
 	call Function3d14e
 	ld a, [BattleEnded]
@@ -947,14 +947,14 @@
 	ld a, [$d232]
 	and a
 	ret nz
-	call Function3c710
+	call HasPlayerFainted
 	jp z, Function3d14e
-	call Function3c70b
+	call HasEnemyFainted
 	jp z, Function3cd55
 
 .asm_3c62f
 	call SetEnemyTurn
-	call Function3c716
+	call ResidualDamage
 	jp z, Function3cd55
 	call RefreshBattleHuds
 	call Function3c6cf
@@ -963,12 +963,12 @@
 	ld a, [$d232]
 	and a
 	ret nz
-	call Function3c70b
+	call HasEnemyFainted
 	jp z, Function3cd55
-	call Function3c710
+	call HasPlayerFainted
 	jp z, Function3d14e
 	call SetPlayerTurn
-	call Function3c716
+	call ResidualDamage
 	jp z, Function3d14e
 	call RefreshBattleHuds
 	xor a
@@ -989,13 +989,13 @@
 	ret nz
 	call Function3d2e0
 	ret c
-	call Function3c70b
+	call HasEnemyFainted
 	jp z, Function3cd55
-	call Function3c710
+	call HasPlayerFainted
 	jp z, Function3d14e
 	push bc
 	call SetPlayerTurn
-	call Function3c716
+	call ResidualDamage
 	pop bc
 	jp z, Function3d14e
 	push bc
@@ -1011,14 +1011,14 @@
 	ld a, [$d232]
 	and a
 	ret nz
-	call Function3c710
+	call HasPlayerFainted
 	jp z, Function3d14e
-	call Function3c70b
+	call HasEnemyFainted
 	jp z, Function3cd55
 
 .asm_3c6be
 	call SetEnemyTurn
-	call Function3c716
+	call ResidualDamage
 	jp z, Function3cd55
 	call RefreshBattleHuds
 	xor a
@@ -1058,15 +1058,15 @@
 	ret
 ; 3c706
 
-Function3c706: ; 3c706
+HasUserFainted: ; 3c706
 	ld a, [hBattleTurn]
 	and a
-	jr z, Function3c710
-Function3c70b: ; 3c70b
+	jr z, HasPlayerFainted
+HasEnemyFainted: ; 3c70b
 	ld hl, EnemyMonHP
 	jr Function3c713
 
-Function3c710: ; 3c710
+HasPlayerFainted: ; 3c710
 	ld hl, BattleMonHP
 
 Function3c713: ; 3c713
@@ -1075,22 +1075,26 @@
 	ret
 ; 3c716
 
-Function3c716: ; 3c716
-	call Function3c706
+ResidualDamage: ; 3c716
+; Return z if the user fainted before
+; or as a result of residual damage.
+; For Sandstorm damage, see HandleWeather.
+
+	call HasUserFainted
 	ret z
 
 	ld a, BATTLE_VARS_STATUS
 	call GetBattleVar
 	and 1 << PSN | 1 << BRN
-	jr z, .asm_3c768
+	jr z, .did_psn_brn
 
-	ld hl, BattleText_0x807e2
+	ld hl, HurtByPoisonText
 	ld de, ANIM_PSN
 	and 1 << BRN
-	jr z, .asm_3c733
-	ld hl, BattleText_0x807f8
+	jr z, .got_anim
+	ld hl, HurtByBurnText
 	ld de, ANIM_BRN
-.asm_3c733
+.got_anim
 
 	push de
 	call StdBattleTextBox
@@ -1110,26 +1114,25 @@
 	ld a, BATTLE_VARS_SUBSTATUS5
 	call GetBattleVar
 	bit SUBSTATUS_TOXIC, a
-	jr z, .asm_3c765
-
+	jr z, .did_toxic
 	call GetSixteenthMaxHP
 	ld a, [de]
 	inc a
 	ld [de], a
 	ld hl, 0
-.asm_3c75f
+.add
 	add hl, bc
 	dec a
-	jr nz, .asm_3c75f
+	jr nz, .add
 	ld b, h
 	ld c, l
+.did_toxic
 
-.asm_3c765
 	call Function3cc3f
+.did_psn_brn
 
-.asm_3c768
-	call Function3c706
-	jp z, .asm_3c7f7
+	call HasUserFainted
+	jp z, .fainted
 
 	ld a, BATTLE_VARS_SUBSTATUS4
 	call GetBattleVarAddr
@@ -1151,18 +1154,17 @@
 	ld a, $1
 	ld [hBGMapMode], a
 	call Function3ccef
-	ld hl, BattleText_0x8080e
+	ld hl, LeechSeedSapsText
 	call StdBattleTextBox
-
 .asm_3c7a1
-	call Function3c706
-	jr z, .asm_3c7f7
 
+	call HasUserFainted
+	jr z, .fainted
+
 	ld a, BATTLE_VARS_SUBSTATUS1
 	call GetBattleVarAddr
 	bit SUBSTATUS_NIGHTMARE, [hl]
 	jr z, .asm_3c7c5
-
 	xor a
 	ld [$cfca], a
 	ld de, ANIM_IN_NIGHTMARE
@@ -1169,13 +1171,13 @@
 	call Function3ee0f
 	call GetQuarterMaxHP
 	call Function3cc3f
-	ld hl, BattleText_0x80822
+	ld hl, HasANightmareText
 	call StdBattleTextBox
-
 .asm_3c7c5
-	call Function3c706
-	jr z, .asm_3c7f7
 
+	call HasUserFainted
+	jr z, .fainted
+
 	ld a, BATTLE_VARS_SUBSTATUS1
 	call GetBattleVarAddr
 	bit SUBSTATUS_CURSE, [hl]
@@ -1187,7 +1189,7 @@
 	call Function3ee0f
 	call GetQuarterMaxHP
 	call Function3cc3f
-	ld hl, BattleText_0x80836
+	ld hl, HurtByCurseText
 	call StdBattleTextBox
 
 .asm_3c7e9
@@ -1202,7 +1204,7 @@
 	or [hl]
 	ret nz
 
-.asm_3c7f7
+.fainted
 	call RefreshBattleHuds
 	ld c, 20
 	call DelayFrames
@@ -1239,7 +1241,7 @@
 	ld a, [hl]
 	ld [$d265], a
 	push af
-	ld hl, BattleText_0x80864
+	ld hl, PerishCountText
 	call StdBattleTextBox
 	pop af
 	ret nz
@@ -1826,7 +1828,7 @@
 	call GetEighthMaxHP
 	call Function3cc3f
 
-	ld hl, BattleText_0x8084d
+	ld hl, SandstormHitsText
 	jp StdBattleTextBox
 
 .ended
@@ -2034,20 +2036,20 @@
 	ld hl, BattleMonMaxHP
 .ok
 	ld a, [hli]
-	ld [Buffer2], a
+	ld [Buffer1 + 1], a
 	ld a, [hld]
-	ld [Buffer1], a
+	ld [Buffer1 + 0], a
 	dec hl
 	ld a, [hl]
-	ld [$d1ec], a
+	ld [Buffer1 + 2], a
 	add c
 	ld [hld], a
-	ld [$d1ee], a
+	ld [Buffer1 + 4], a
 	ld a, [hl]
-	ld [$d1ed], a
+	ld [Buffer1 + 3], a
 	adc b
 	ld [hli], a
-	ld [$d1ef], a
+	ld [Buffer1 + 5], a
 
 	ld a, [Buffer1]
 	ld c, a
@@ -2060,10 +2062,10 @@
 	jr c, .asm_3cd2d
 	ld a, b
 	ld [hli], a
-	ld [$d1ef], a
+	ld [Buffer1 + 5], a
 	ld a, c
 	ld [hl], a
-	ld [$d1ee], a
+	ld [Buffer1 + 4], a
 .asm_3cd2d
 
 	call SwitchTurnCore
@@ -2076,17 +2078,15 @@
 	jp UpdateBattleHuds
 ; 3cd3c
 
-
 Function3cd3c: ; 3cd3c
 	hlcoord 10, 9
 	ld a, [hBattleTurn]
 	and a
 	ld a, 1
-	jr z, .asm_3cd4a
+	jr z, .ok
 	hlcoord 2, 2
 	xor a
-
-.asm_3cd4a
+.ok
 	push bc
 	ld [$d10a], a
 	predef Functionc6e0
@@ -3128,7 +3128,7 @@
 	and $c0
 	add 2
 	ld [$d0ee], a
-	jr .asm_3d412
+	jr .text
 
 .asm_3d40a
 	ld hl, LostAgainstText
@@ -3135,7 +3135,7 @@
 	call IsMobileBattle
 	jr z, .asm_3d417
 
-.asm_3d412
+.text
 	call StdBattleTextBox
 
 .end
@@ -3293,7 +3293,6 @@
 	call Function3d533
 	jr c, .asm_3d4f1
 	call Function3d599
-
 .asm_3d4f1
 	call Function3d6ca
 	call Function3d74b
@@ -3318,7 +3317,6 @@
 	call Function3d533
 	jr c, .asm_3d522
 	call Function3d599
-
 .asm_3d522
 	call Function3d6ca
 	ld a, 1
@@ -3332,6 +3330,7 @@
 	ld a, [InLinkBattle]
 	and a
 	jr z, .asm_3d541
+
 	ld a, [wBattleAction]
 	sub NUM_MOVES
 	ld b, a
@@ -3383,7 +3382,7 @@
 	ld a, [CurBattleMon]
 	ld c, a
 	ld hl, $c664
-	ld b, $1
+	ld b, SET_FLAG
 	push bc
 	predef FlagPredef
 	pop bc
@@ -3434,13 +3433,13 @@
 	ld a, b
 	call GetPartyLocation
 	pop bc
-	ld e, $5
-.asm_3d5e2
+	ld e, NUM_MOVES + 1
+.loop
 	dec e
-	jr z, .asm_3d617
+	jr z, .done
 	ld a, [hli]
 	and a
-	jr z, .asm_3d617
+	jr z, .done
 	push hl
 	push de
 	push bc
@@ -3457,13 +3456,12 @@
 	pop de
 	pop hl
 	ld a, [$d265]
-	cp $b
-	jr c, .asm_3d5e2
+	cp 10 + 1 ; 1.0 + 0.1
+	jr c, .loop
 	ld hl, Buffer1
 	set 0, [hl]
 	ret
-
-.asm_3d617
+.done
 	ret
 ; 3d618
 
@@ -3590,7 +3588,7 @@
 	inc a
 	ld hl, OTPartyCount
 	ld c, a
-	ld b, $0
+	ld b, 0
 	add hl, bc
 	ld a, [hl]
 	ld [TempEnemyMonSpecies], a
@@ -3606,7 +3604,6 @@
 	predef GetUnownLetter
 	ld a, [UnownLetter]
 	ld [$def4], a
-
 .asm_3d708
 	ld hl, EnemyMonHP
 	ld a, [hli]
@@ -3693,7 +3690,7 @@
 	call Function1c07
 	call ClearSprites
 	hlcoord 1, 0
-	ld bc, $040a
+	lb bc, 4, 10
 	call ClearBox
 	call WaitBGMap
 	jp Function3ee27
@@ -3711,10 +3708,11 @@
 	ld [CurPartySpecies], a
 	ld [CurSpecies], a
 	call GetBaseData
-	ld a, $1
+	ld a, OTPARTYMON
 	ld [MonType], a
 	predef Function5084a
 	call Function3f47c
+
 	xor a
 	ld [$cfca], a
 	ld [$c689], a
@@ -3721,14 +3719,15 @@
 	call SetEnemyTurn
 	ld de, ANIM_SEND_OUT_MON
 	call Function3ee17
+
 	call Function3da79
 	jr nc, .asm_3d800
-	ld a, $1
+	ld a, 1 ; shiny anim
 	ld [$c689], a
 	ld de, ANIM_SEND_OUT_MON
 	call Function3ee17
-
 .asm_3d800
+
 	ld bc, TempMonSpecies
 	callba Function4e53f
 	jr c, .asm_3d82c
@@ -6817,7 +6816,7 @@
 	ld a, [OtherTrainerClass]
 	ld [TrainerClass], a
 	ld de, VTiles2
-	callab Function5120d
+	callab GetTrainerPic
 	hlcoord 19, 0
 	ld c, $0
 .asm_3ebf3
@@ -8308,7 +8307,7 @@
 	ld hl, BattleMonDVs
 	predef GetUnownLetter
 	ld de, $9310
-	predef Function5116c
+	predef GetBackpic
 	pop af
 	ld [CurPartySpecies], a
 	ret
@@ -8331,11 +8330,13 @@
 	bit SUBSTATUS_SUBSTITUTE, a
 	ld hl, BattleAnimCmd_DD
 	jr nz, Function3f4b4
+
 Function3f486: ; 3f486
 	ld a, [$c6fa]
 	and a
 	ld hl, BattleAnimCmd_E2
 	jr nz, Function3f4b4
+
 	ld a, [CurPartySpecies]
 	push af
 	ld a, [EnemyMonSpecies]
@@ -8451,7 +8452,7 @@
 	ld a, $6
 	ld [rSVBK], a
 	ld hl, $d000
-	ld bc, VBlank5
+	ld bc, $400
 	ld a, $2
 	call ByteFill
 	ld a, [rVBK]
@@ -8485,7 +8486,7 @@
 .ok
 
 	ld de, VTiles2
-	callab Function5120d
+	callab GetTrainerPic
 	xor a
 	ld [$ffad], a
 	dec a
@@ -8547,7 +8548,6 @@
 	jr nz, .asm_3f648
 	ld a, [UnownLetter]
 	ld [$def4], a
-
 .asm_3f648
 	ld de, VTiles2
 	predef Function5108b
@@ -9332,7 +9332,7 @@
 	ld a, $6
 	ld [rSVBK], a
 	ld hl, $d000
-	ld bc, VBlank5
+	ld bc, $400
 	ld a, $7f
 	call ByteFill
 	ld de, $d000
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -1536,7 +1536,7 @@
 	ld b, [hl]
 	inc hl
 	ld c, [hl]
-	ld a, $a
+	ld a, 10 ; 1.0
 	ld [$d265], a
 	ld hl, TypeMatchup
 .asm_347e7
--- a/home.asm
+++ b/home.asm
@@ -1699,7 +1699,7 @@
 	jr c, .asm_37ad
 	push hl
 	ld de, VTiles2
-	predef Function51077
+	predef GetFrontpic
 	pop hl
 	xor a
 	ld [$ffad], a
--- a/main.asm
+++ b/main.asm
@@ -4672,7 +4672,7 @@
 
 Function619c: ; 619c
 	ld de, VTiles2
-	callba Function5120d
+	callba GetTrainerPic
 	xor a
 	ld [$ffad], a
 	hlcoord 6, 4
@@ -7814,10 +7814,10 @@
 	add_predef Predef39
 	add_predef Functionfd1d0
 	add_predef PartyMonItemName
-	add_predef Function51077
-	add_predef Function5116c
+	add_predef GetFrontpic
+	add_predef GetBackpic
 	add_predef Function5108b
-	add_predef Function5120d
+	add_predef GetTrainerPic
 	add_predef DecompressPredef ; $40
 	add_predef Function347d3
 	add_predef Functionfb908
@@ -29600,7 +29600,7 @@
 	xor a
 	ld [$c2c6], a
 	ld de, VTiles2
-	predef Function51077
+	predef GetFrontpic
 	call Function16cff
 	hlcoord 1, 6
 	xor a
@@ -30394,7 +30394,7 @@
 	ld hl, BattleMonDVs
 	predef GetUnownLetter
 	pop de
-	predef_jump Function51077
+	predef_jump GetFrontpic
 
 ; known jump sources: 172c2 (5:72c2)
 Function1723c: ; 1723c (5:723c)
@@ -31882,7 +31882,7 @@
 	ld [CurSpecies], a
 	call GetBaseData
 	ld de, VTiles1
-	predef Function51077
+	predef GetFrontpic
 	ld a, [$cf82]
 	inc a
 	ld b, a
@@ -39075,7 +39075,7 @@
 	ld [CurSpecies], a
 	call GetBaseData
 	pop de
-	predef Function51077
+	predef GetFrontpic
 	ret
 ; 294a9
 
@@ -46440,7 +46440,7 @@
 	ld [CurPartySpecies], a
 	call GetBaseData
 	ld de, VTiles2
-	predef Function51077
+	predef GetFrontpic
 	ret
 
 .asm_4145b
@@ -46601,7 +46601,7 @@
 	ld [CurPartySpecies], a ; $d108
 	call GetBaseData
 	ld de, $9000
-	predef Function51077
+	predef GetFrontpic
 	pop af
 	ld [UnownLetter], a ; $d234
 	ret
@@ -46631,7 +46631,7 @@
 	call WaitBGMap
 	call GetBaseData
 	ld de, VTiles2
-	predef Function51077
+	predef GetFrontpic
 	ld a, $4
 	call Function41423
 	ld a, [CurPartySpecies]
@@ -60679,7 +60679,7 @@
 ; 51077
 
 
-Function51077: ; 51077
+GetFrontpic: ; 51077
 	ld a, [CurPartySpecies]
 	ld [CurSpecies], a
 	call IsAPokemon
@@ -60686,7 +60686,7 @@
 	ret c
 	ld a, [rSVBK]
 	push af
-	call Function510a5
+	call _GetFrontpic
 	pop af
 	ld [rSVBK], a
 	ret
@@ -60701,7 +60701,7 @@
 	push af
 	xor a
 	ld [hBGMapMode], a
-	call Function510a5
+	call _GetFrontpic
 	call Function51103
 	pop af
 	ld [rSVBK], a
@@ -60708,7 +60708,7 @@
 	ret
 ; 510a5
 
-Function510a5: ; 510a5
+_GetFrontpic: ; 510a5
 	push de
 	call GetBaseData
 	ld a, [BasePicSize]
@@ -60715,7 +60715,7 @@
 	and $f
 	ld b, a
 	push bc
-	call Function510d7
+	call GetFrontpicPointer
 	ld a, $6
 	ld [rSVBK], a
 	ld a, b
@@ -60722,12 +60722,12 @@
 	ld de, $d800
 	call FarDecompress
 	pop bc
-	ld hl, Unkn1Pals
+	ld hl, $d000
 	ld de, $d800
 	call Function512ab
 	pop hl
 	push hl
-	ld de, Unkn1Pals
+	ld de, $d000
 	ld c, 7 * 7
 	ld a, [hROMBank]
 	ld b, a
@@ -60736,28 +60736,28 @@
 	ret
 ; 510d7
 
-Function510d7: ; 510d7
+GetFrontpicPointer: ; 510d7
 GLOBAL PicPointers, UnownPicPointers
 
 	ld a, [CurPartySpecies]
 	cp UNOWN
-	jr z, .asm_510e5
+	jr z, .unown
 	ld a, [CurPartySpecies]
 	ld d, BANK(PicPointers)
-	jr .asm_510ea
+	jr .ok
 
-.asm_510e5
+.unown
 	ld a, [UnownLetter]
 	ld d, BANK(UnownPicPointers)
 
-.asm_510ea
-	ld hl, Function50000
+.ok
+	ld hl, PicPointers ; UnownPicPointers
 	dec a
-	ld bc, $0006
+	ld bc, 6
 	call AddNTimes
 	ld a, d
 	call GetFarByte
-	call Function511c5
+	call FixPicBank
 	push af
 	inc hl
 	ld a, d
@@ -60770,13 +60770,13 @@
 	ld a, $1
 	ld [rVBK], a
 	push hl
-	ld de, Unkn1Pals
-	ld c, $31
+	ld de, $d000
+	ld c, 7 * 7
 	ld a, [hROMBank]
 	ld b, a
 	call Get2bpp
 	pop hl
-	ld de, $0310
+	ld de, 7 * 7 * $10
 	add hl, de
 	push hl
 	ld a, $1
@@ -60784,24 +60784,24 @@
 	call GetFarWRAMByte
 	pop hl
 	and $f
-	ld de, $d990
+	ld de, $d800 + 5 * 5 * $10
 	ld c, 5 * 5
 	cp 5
 	jr z, .asm_5113b
-	ld de, $da40
+	ld de, $d800 + 6 * 6 * $10
 	ld c, 6 * 6
 	cp 6
 	jr z, .asm_5113b
-	ld de, $db10
+	ld de, $d800 + 7 * 7 * $10
 	ld c, 7 * 7
-
 .asm_5113b
+
 	push hl
 	push bc
 	call Function5114f
 	pop bc
 	pop hl
-	ld de, Unkn1Pals
+	ld de, $d000
 	ld a, [hROMBank]
 	ld b, a
 	call Get2bpp
@@ -60832,10 +60832,11 @@
 	ret
 ; 5116c
 
-Function5116c: ; 5116c
+GetBackpic: ; 5116c
 	ld a, [CurPartySpecies]
 	call IsAPokemon
 	ret c
+
 	ld a, [CurPartySpecies]
 	ld b, a
 	ld a, [UnownLetter]
@@ -60853,31 +60854,30 @@
 	ld a, b
 	ld d, BANK(PicPointers)
 	cp UNOWN
-	jr nz, .asm_51190
+	jr nz, .ok
 	ld a, c
 	ld d, BANK(UnownPicPointers)
-
-.asm_51190
+.ok
 	dec a
-	ld bc, $0006
+	ld bc, 6
 	call AddNTimes
-	ld bc, $0003
+	ld bc, 3
 	add hl, bc
 	ld a, d
 	call GetFarByte
-	call Function511c5
+	call FixPicBank
 	push af
 	inc hl
 	ld a, d
 	call GetFarHalfword
-	ld de, Unkn1Pals
+	ld de, $d000
 	pop af
 	call FarDecompress
-	ld hl, Unkn1Pals
-	ld c, $24
+	ld hl, $d000
+	ld c, 6 * 6
 	call Function5127c
 	pop hl
-	ld de, Unkn1Pals
+	ld de, $d000
 	ld a, [hROMBank]
 	ld b, a
 	call Get2bpp
@@ -60887,10 +60887,11 @@
 ; 511c5
 
 
-Function511c5: ; 511c5
+FixPicBank: ; 511c5
+; This is a thing for some reason.
 	push hl
 	push bc
-	sub $12
+	sub PICS_1 - $36
 	ld c, a
 	ld b, 0
 	ld hl, Unknown_511d4
@@ -60902,10 +60903,53 @@
 ; 511d4
 
 Unknown_511d4: ; 511d4
-INCBIN "baserom.gbc",$511d4,$5120d - $511d4
+	db PICS_1
+	db PICS_2
+	db PICS_3
+	db PICS_4
+	db PICS_5
+	db PICS_6
+	db PICS_7
+	db PICS_8
+	db PICS_9
+	db PICS_10
+	db PICS_11
+	db PICS_12
+	db PICS_13
+	db PICS_14
+	db PICS_15
+	db PICS_16
+	db PICS_17
+	db PICS_18
+	db PICS_19
+	db PICS_19 + 1
+	db PICS_19 + 2
+	db PICS_19 + 3
+	db PICS_19 + 4
+	db PICS_19 + 5
 
+Function511ec: ; 511ec
+	ld a, c
+	push de
+	ld hl, PicPointers
+	dec a
+	ld bc, 6
+	call AddNTimes
+	ld a, BANK(PicPointers)
+	call GetFarByte
+	call FixPicBank
+	push af
+	inc hl
+	ld a, BANK(PicPointers)
+	call GetFarHalfword
+	pop af
+	pop de
+	call FarDecompress
+	ret
+; 0x5120d
 
-Function5120d: ; 5120d
+
+GetTrainerPic: ; 5120d
 	ld a, [TrainerClass]
 	and a
 	ret z
@@ -60914,10 +60958,10 @@
 	call WaitBGMap
 	xor a
 	ld [hBGMapMode], a
-	ld hl, Function50000
+	ld hl, TrainerPicPointers
 	ld a, [TrainerClass]
 	dec a
-	ld bc, $0003
+	ld bc, 3
 	call AddNTimes
 	ld a, [rSVBK]
 	push af
@@ -60924,12 +60968,12 @@
 	ld a, $6
 	ld [rSVBK], a
 	push de
-	ld a, $4a
+	ld a, BANK(TrainerPicPointers)
 	call GetFarByte
-	call Function511c5
+	call FixPicBank
 	push af
 	inc hl
-	ld a, $4a
+	ld a, BANK(TrainerPicPointers)
 	call GetFarHalfword
 	pop af
 	ld de, $d000
@@ -60936,7 +60980,7 @@
 	call FarDecompress
 	pop hl
 	ld de, $d000
-	ld c, $31
+	ld c, 7 * 7
 	ld a, [hROMBank]
 	ld b, a
 	call Get2bpp
@@ -60983,13 +61027,13 @@
 	and a
 	jr z, .asm_512a8
 	ld a, c
-	cp $31
-	ld de, $0310
+	cp 7 * 7
+	ld de, 7 * 7 * $10
 	jr z, .asm_51296
-	cp $24
-	ld de, $0240
+	cp 6 * 6
+	ld de, 6 * 6 * $10
 	jr z, .asm_51296
-	ld de, $0190
+	ld de, 5 * 5 * $10
 
 .asm_51296
 	ld a, [hl]
@@ -61015,25 +61059,26 @@
 
 Function512ab: ; 512ab
 	ld a, b
-	cp $6
-	jr z, .asm_512bd
-	cp $5
-	jr z, .asm_512d2
-.asm_512b4
+	cp 6
+	jr z, .six
+	cp 5
+	jr z, .five
+
+.seven
 	ld c, $70
 	call Function512f2
 	dec b
-	jr nz, .asm_512b4
+	jr nz, .seven
 	ret
 
-.asm_512bd
+.six
 	ld c, $70
 	xor a
-	call Function512ed
+	call .Fill
 .asm_512c3
 	ld c, $10
 	xor a
-	call Function512ed
+	call .Fill
 	ld c, $60
 	call Function512f2
 	dec b
@@ -61040,14 +61085,14 @@
 	jr nz, .asm_512c3
 	ret
 
-.asm_512d2
+.five
 	ld c, $70
 	xor a
-	call Function512ed
+	call .Fill
 .asm_512d8
 	ld c, $20
 	xor a
-	call Function512ed
+	call .Fill
 	ld c, $50
 	call Function512f2
 	dec b
@@ -61054,15 +61099,13 @@
 	jr nz, .asm_512d8
 	ld c, $70
 	xor a
-	call Function512ed
+	call .Fill
 	ret
-; 512ed
 
-Function512ed: ; 512ed
-.asm_512ed
+.Fill
 	ld [hli], a
 	dec c
-	jr nz, .asm_512ed
+	jr nz, .Fill
 	ret
 ; 512f2
 
@@ -61085,22 +61128,10 @@
 	inc de
 	ld b, a
 	xor a
+	rept 8
 	rr b
 	rla
-	rr b
-	rla
-	rr b
-	rla
-	rr b
-	rla
-	rr b
-	rla
-	rr b
-	rla
-	rr b
-	rla
-	rr b
-	rla
+	endr
 	ld [hli], a
 	dec c
 	jr nz, .asm_51300
@@ -62761,7 +62792,7 @@
 	hlcoord 12, 3
 	call Function378b
 	ld de, $9310
-	predef Function5116c
+	predef GetBackpic
 	ld a, $31
 	ld [$ffad], a
 	hlcoord 2, 4
@@ -62792,7 +62823,7 @@
 	hlcoord 4, 1
 	call PlaceString
 	ld de, VTiles2
-	callab Function5120d
+	callab GetTrainerPic
 	xor a
 	ld [TempEnemyMonSpecies], a
 	ld [$ffad], a
@@ -65666,7 +65697,7 @@
 	ld a, $7f
 	call ByteFill
 	ld de, $9310
-	predef Function5116c
+	predef GetBackpic
 	ld a, $31
 	ld [$ffad], a
 	hlcoord 6, 6
@@ -67975,7 +68006,7 @@
 	xor a
 	ld [CurPartySpecies], a
 	ld de, $9370
-	callba Function5120d
+	callba GetTrainerPic
 	pop bc
 	ret
 ; 897d5
@@ -94834,7 +94865,7 @@
 	predef GetUnownLetter
 	call GetBaseData
 	ld de, $9000
-	predef Function51077
+	predef GetFrontpic
 	xor a
 	ld [$cb32], a
 	ld a, [CurPartySpecies]
--- a/text/battle.asm
+++ b/text/battle.asm
@@ -60,43 +60,43 @@
 	prompt
 ; 0x807e2
 
-BattleText_0x807e2: ; 0x807e2
+HurtByPoisonText: ; 0x807e2
 	text $5a
 	line "is hurt by poison!"
 	prompt
 ; 0x807f8
 
-BattleText_0x807f8: ; 0x807f8
+HurtByBurnText: ; 0x807f8
 	text $5a, "'s"
 	line "hurt by its burn!"
 	prompt
 ; 0x8080e
 
-BattleText_0x8080e: ; 0x8080e
+LeechSeedSapsText: ; 0x8080e
 	text "LEECH SEED saps"
 	line $5a, "!"
 	prompt
 ; 0x80822
 
-BattleText_0x80822: ; 0x80822
+HasANightmareText: ; 0x80822
 	text $5a
 	line "has a NIGHTMARE!"
 	prompt
 ; 0x80836
 
-BattleText_0x80836: ; 0x80836
+HurtByCurseText: ; 0x80836
 	text $5a, "'s"
 	line "hurt by the CURSE!"
 	prompt
 ; 0x8084d
 
-BattleText_0x8084d: ; 0x8084d
+SandstormHitsText: ; 0x8084d
 	text "The SANDSTORM hits"
 	line $5a, "!"
 	prompt
 ; 0x80864
 
-BattleText_0x80864: ; 0x80864
+PerishCountText: ; 0x80864
 	text $5a, "'s"
 	line "PERISH count is @"
 	deciram $d265, $11
--