ref: 0d4c2776d927e5d3162d9a4430fc82f35bf50be5
parent: c76a3c6ecd36d650a1715c0f5520c2336bd27f9c
author: JimB16 <f1@jimb.de>
date: Sun Sep 6 19:38:01 EDT 2015
changed varlabels for multiply- and divide-func, renamed battletext-labels
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -63,7 +63,7 @@
xor a
ld [CurPartyMon], a
.asm_3c06b
- call Function3d887
+ call CheckIfPartyHasPkmnToBattleWith
jr nz, .asm_3c076
ld hl, CurPartyMon
inc [hl]
@@ -71,7 +71,7 @@
.asm_3c076
ld a, [CurBattleMon]
- ld [wc71a], a
+ ld [LastPlayerMon], a
ld a, [CurPartyMon]
ld [CurBattleMon], a
inc a
@@ -89,7 +89,7 @@
call Function3d57a
call Function3da0d
call ResetPlayerStatLevels
- call Function3f26d
+ call SendOutPkmnText
call NewBattleMonStatus
call BreakAttraction
call Function3db5f
@@ -121,7 +121,7 @@
-Function3c0e5: ; 3c0e5
+WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5
call Function30b4
ld a, [wd0ee]
and $c0
@@ -131,6 +131,7 @@
and a
ld hl, BattleText_WildFled
jr z, .asm_3c115
+
ld a, [wd0ee]
and $c0
ld [wd0ee], a
@@ -137,9 +138,11 @@
ld hl, BattleText_EnemyFled
call Function3d2e0
jr nc, .asm_3c115
+
ld hl, wcd2a
bit 4, [hl]
jr nz, .asm_3c118
+
ld hl, BattleText_LinkErrorBattleCanceled
.asm_3c115
@@ -297,9 +300,9 @@
.asm_3c21e
call Function3c8eb
call Function3c93c
- call Function3ca8f
- call Function3cafb
- call Function3cb36
+ call HanleDefrost
+ call HandleSafeguard
+ call HandleScreens
call Function3de97
call Function3dcf9
call UpdateBattleMonInParty
@@ -447,7 +450,7 @@
ret
.asm_3c30f
- call Function3c0e5
+ call WildFled_EnemyFled_LinkBattleCanceled
scf
ret
; 3c314
@@ -936,7 +939,7 @@
Function3c5fe: ; 3c5fe
call Function309d
call Function3c543
- jp c, Function3c0e5
+ jp c, WildFled_EnemyFled_LinkBattleCanceled
call SetEnemyTurn
ld a, $1
ld [wc70f], a
@@ -1005,7 +1008,7 @@
jr c, .asm_3c6be
call Function309d
call Function3c543
- jp c, Function3c0e5
+ jp c, WildFled_EnemyFled_LinkBattleCanceled
call Function3c6de
call Function3d2e0
ret c
@@ -1529,7 +1532,7 @@
call SwitchTurnCore
call Function3ddc8
call SwitchTurnCore
- ld hl, BattleText_0x80899
+ ld hl, BattleText_UserRecoveredPPUsing
jp StdBattleTextBox
; 3ca26
@@ -1591,7 +1594,7 @@
jp UpdateEnemyMonInParty
; 3ca8f
-Function3ca8f: ; 3ca8f
+HanleDefrost: ; 3ca8f
ld a, [$ffcb]
cp $1
jr z, .asm_3ca9a
@@ -1649,7 +1652,7 @@
jp StdBattleTextBox
; 3cafb
-Function3cafb: ; 3cafb
+HandleSafeguard: ; 3cafb
ld a, [$ffcb]
cp $1
jr z, .asm_3cb06
@@ -1683,12 +1686,11 @@
.asm_3cb2e
ld [hBattleTurn], a
- ld hl, BattleText_0x808d2
+ ld hl, BattleText_SafeguardFaded
jp StdBattleTextBox
-; 3cb36
-Function3cb36: ; 3cb36
+HandleScreens: ; 3cb36
ld a, [$ffcb]
cp 1
jr z, .Both
@@ -1740,7 +1742,7 @@
res SCREENS_LIGHT_SCREEN, [hl]
push hl
push de
- ld hl, BattleText_0x808e7
+ ld hl, BattleText_PkmnnLightScreenFell
call StdBattleTextBox
pop de
pop hl
@@ -1851,13 +1853,13 @@
; 3cc2d
.WeatherMessages
- dw BattleText_0x8091f
- dw BattleText_0x80938
- dw BattleText_0x80951
+ dw BattleText_RainContinuesToFall
+ dw BattleText_TheSunlightIsStrong
+ dw BattleText_TheSandstormRages
.WeatherEndedMessages
- dw BattleText_0x80967
- dw BattleText_0x8097a
- dw BattleText_0x8098f
+ dw BattleText_TheRainStopped
+ dw BattleText_TheSunlightFaded
+ dw BattleText_TheSandstormSubsided
; 3cc39
Function3cc39: ; 3cc39
@@ -2144,12 +2146,12 @@
.asm_3cda4
call Function3d227
call Function3d2e0
- jp c, Function3c0e5
+ jp c, WildFled_EnemyFled_LinkBattleCanceled
ld a, $1
ld [wd0ec], a
call Function3cf4a
- jp z, Function3c0e5
+ jp z, WildFled_EnemyFled_LinkBattleCanceled
jr Function3cdca
.asm_3cdba
@@ -2156,7 +2158,7 @@
ld a, $1
ld [wd0ec], a
call Function3cf4a
- jp z, Function3c0e5
+ jp z, WildFled_EnemyFled_LinkBattleCanceled
xor a
ld [wd0ec], a
ret
@@ -2357,7 +2359,7 @@
hlcoord 9, 7
lb bc, 5, 11
call ClearBox
- ld hl, BattleText_0x80a75
+ ld hl, BattleText_PkmnFainted
jp StdBattleTextBox
; 3cf14
@@ -2371,7 +2373,7 @@
hlcoord 1, 0
lb bc, 4, 10
call ClearBox
- ld hl, BattleText_0x809a8
+ ld hl, BattleText_EnemyPkmnFainted
jp StdBattleTextBox
; 3cf35
@@ -2455,7 +2457,7 @@
ld a, b
call z, Function3d0ea
callab Battle_GetTrainerName
- ld hl, BattleText_0x809da
+ ld hl, BattleText_EnemyWasDefeated
call StdBattleTextBox
call IsMobileBattle
jr z, .asm_3cff5
@@ -2462,9 +2464,11 @@
ld a, [InLinkBattle]
and a
ret nz
+
ld a, [InBattleTowerBattle]
bit 0, a
jr nz, .asm_3d006
+
call Function3ebd8
ld c, $28
call DelayFrames
@@ -2785,7 +2789,7 @@
.asm_3d190
call Function3d227
call Function3d2e0
- jp c, Function3c0e5
+ jp c, WildFled_EnemyFled_LinkBattleCanceled
ld a, c
and a
ret nz
@@ -2792,7 +2796,7 @@
ld a, $1
ld [wd0ec], a
call Function3cf4a
- jp z, Function3c0e5
+ jp z, WildFled_EnemyFled_LinkBattleCanceled
jp Function3cdca
; 3d1aa
@@ -2841,7 +2845,7 @@
and a
dec a
ret nz
- ld hl, BattleText_0x80a83
+ ld hl, BattleText_UseNextMon
call StdBattleTextBox
.asm_3d20a
lb bc, 1, 7
@@ -2898,7 +2902,7 @@
.asm_3d26c
call ClearSprites
ld a, [CurBattleMon]
- ld [wc71a], a
+ ld [LastPlayerMon], a
ld a, [CurPartyMon]
ld [CurBattleMon], a
call Function3d581
@@ -2910,7 +2914,7 @@
call WriteBackup
call ClearSGB
call Function32f9
- call Function3f26d
+ call SendOutPkmnText
call NewBattleMonStatus
call BreakAttraction
call Function3db5f
@@ -2926,13 +2930,13 @@
Function3d2b3: ; 3d2b3
ld a, [CurBattleMon]
- ld [wc71a], a
+ ld [LastPlayerMon], a
ld a, [CurPartyMon]
ld [CurBattleMon], a
call Function3d581
call Function3da0d
call ResetPlayerStatLevels
- call Function3f26d
+ call SendOutPkmnText
call NewBattleMonStatus
call BreakAttraction
call Function3db5f
@@ -2946,10 +2950,13 @@
Function3d2e0: ; 3d2e0
ld a, [InLinkBattle]
cp $4
- jr nz, .asm_3d2ef
+ jr nz, .asm_3d2ef ; It's not a mobile battle
+
ld a, [wcd2b]
and a
jr z, .asm_3d2ef
+
+; We have a mobile battle and something else happened
scf
ret
@@ -3001,7 +3008,7 @@
call Function3d313
call Function3d329
ret c
- call Function3d887
+ call CheckIfPartyHasPkmnToBattleWith
jr z, .loop
xor a
ret
@@ -3649,7 +3656,7 @@
ld a, [CurPartyMon]
push af
callab Battle_GetTrainerName
- ld hl, BattleText_0x80aca
+ ld hl, BattleText_EnemyIsAboutToUseWillPlayerChangePkmn
call StdBattleTextBox
lb bc, 1, 7
call PlaceYesNoBox
@@ -3660,7 +3667,7 @@
call PickSwitchMonInBattle
jr c, .asm_3d791
ld a, [CurBattleMon]
- ld [wc71a], a
+ ld [LastPlayerMon], a
ld a, [CurPartyMon]
ld [CurBattleMon], a
call ClearPalettes
@@ -3807,7 +3814,7 @@
; 3d887
-Function3d887: ; 3d887
+CheckIfPartyHasPkmnToBattleWith: ; 3d887
ld a, [CurPartyMon]
ld hl, PartyMon1HP
call GetPartyLocation
@@ -3814,6 +3821,7 @@
ld a, [hli]
or [hl]
ret nz
+
ld a, [wd264]
and a
jr nz, .asm_3d8b1
@@ -3824,10 +3832,11 @@
add hl, bc
ld a, [hl]
cp EGG
- ld hl, BattleText_0x80b26
+ ld hl, BattleText_AnEGGCantBattle
jr z, .asm_3d8ae
- ld hl, BattleText_0x80b0b
+ ld hl, BattleText_TheresNoWillToBattle
+
.asm_3d8ae
call StdBattleTextBox
@@ -3891,29 +3900,30 @@
inc a
ld [wd267], a
ld a, [hli]
- ld [$ffb5], a
+ ld [hStringCmpString2 + 0], a
ld a, [hl]
- ld [$ffb6], a
+ ld [hStringCmpString2 + 1], a
ld a, [de]
inc de
- ld [$ffb1], a
+ ld [hStringCmpString1 + 0], a
ld a, [de]
- ld [$ffb2], a
+ ld [hStringCmpString1 + 1], a
call Function30b4
- ld de, $ffb5
- ld hl, $ffb1
+ ld de, hStringCmpString2
+ ld hl, hStringCmpString1
ld c, $2
call StringCmp
jr nc, .asm_3d9a2
+
xor a
ld [hMultiplicand], a
ld a, $20
ld [hMultiplier], a
call Multiply
- ld a, [$ffb5]
- ld [hProduct], a
- ld a, [$ffb6]
- ld [hMultiplicand], a
+ ld a, [hProduct + 2]
+ ld [hDividend + 0], a
+ ld a, [hProduct + 3]
+ ld [hDividend + 1], a
ld a, [$ffb1]
ld b, a
ld a, [$ffb2]
@@ -3923,10 +3933,10 @@
rr a
and a
jr z, .asm_3d9a2
- ld [hMultiplier], a
+ ld [hDivisor], a
ld b, $2
call Divide
- ld a, [$ffb5]
+ ld a, [hQuotient + 1]
and a
jr nz, .asm_3d9a2
ld a, [wd267]
@@ -3935,7 +3945,7 @@
dec c
jr z, .asm_3d97a
ld b, $1e
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
add b
ld [$ffb6], a
jr c, .asm_3d9a2
@@ -3949,15 +3959,15 @@
jr nc, .asm_3d9a2
ld a, $1
ld [wd0ec], a
- ld hl, BattleText_0x80b3b
+ ld hl, BattleText_CantEscape2
jr .asm_3d995
.asm_3d98d
- ld hl, BattleText_0x80ba0
+ ld hl, BattleText_CantEscape
jr .asm_3d995
.asm_3d992
- ld hl, BattleText_0x80b49
+ ld hl, BattleText_TheresNoEscapeFromTrainerBattle
.asm_3d995
call StdBattleTextBox
@@ -4002,7 +4012,7 @@
call WaitPlaySFX
pop de
call WaitSFX
- ld hl, BattleText_0x80b77
+ ld hl, BattleText_GotAwaySafely
call StdBattleTextBox
call WaitSFX
call Function309d
@@ -4173,7 +4183,7 @@
Function3db32: ; 3db32
call ClearSprites
ld a, [CurBattleMon]
- ld [wc71a], a
+ ld [LastPlayerMon], a
ld a, [CurPartyMon]
ld [CurBattleMon], a
call Function3d581
@@ -4342,7 +4352,7 @@
and a
jr z, .asm_3dc7e
ld hl, DoEnemyTurn
- ld a, [wc71a]
+ ld a, [LastPlayerMon]
ld [CurBattleMon], a
.asm_3dc7e
ld a, BANK(DoPlayerTurn)
@@ -4360,7 +4370,7 @@
and a
jr z, .asm_3dcc0
- ld a, [wc71a]
+ ld a, [LastPlayerMon]
call UpdateBattleMon
ld hl, BattleMonHP
ld a, [hli]
@@ -4377,7 +4387,7 @@
ld b, $0
predef FlagPredef
call Function3d43b
- ld hl, BattleText_0x80a75
+ ld hl, BattleText_PkmnFainted
jr .asm_3dcdf
.asm_3dcc0
@@ -4393,7 +4403,7 @@
call PlaySFX
call WaitSFX
call Function3d432
- ld hl, BattleText_0x809a8
+ ld hl, BattleText_EnemyPkmnFainted
.asm_3dcdf
call StdBattleTextBox
@@ -5004,17 +5014,18 @@
ld hl, EnemyMonHP
ld a, [hli]
- ld [$ffb5], a
+ ld [hMultiplicand + 1], a
ld a, [hld]
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
or [hl]
jr nz, .asm_3e0d1
+
ld c, a
ld e, a
ld d, HP_BAR_LENGTH
jp .asm_3e11a
-.asm_3e0d1
+.asm_3e0d1
xor a
ld [hMultiplicand], a
ld a, HP_BAR_LENGTH_PX
@@ -5033,11 +5044,11 @@
rr a
srl b
rr a
- ld [hMultiplier], a
- ld a, [$ffb5]
+ ld [hDivisor], a
+ ld a, [hProduct + 2]
ld b, a
srl b
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
rr a
srl b
rr a
@@ -5047,13 +5058,13 @@
.asm_3e105
ld a, [$ffb5]
- ld [hProduct], a
+ ld [hDividend + 0], a
ld a, [$ffb6]
- ld [hMultiplicand], a
+ ld [hDividend + 1], a
ld a, $2
ld b, a
call Divide
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
ld e, a
ld a, HP_BAR_LENGTH
ld d, a
@@ -5389,10 +5400,10 @@
jp Function3e299
.asm_3e381
- call Function3d887
+ call CheckIfPartyHasPkmnToBattleWith
jp z, Function3e299
ld a, [CurBattleMon]
- ld [wc71a], a
+ ld [LastPlayerMon], a
ld a, $2
ld [wd0ec], a
call ClearPalettes
@@ -5438,7 +5449,7 @@
jp c, .asm_3e3ca
cp $f
jr nz, .asm_3e3e9
- call Function3c0e5
+ call WildFled_EnemyFled_LinkBattleCanceled
ret
.asm_3e3e9
@@ -5487,7 +5498,7 @@
call Function3d581
call Function3da0d
call ResetPlayerStatLevels
- call Function3f26d
+ call SendOutPkmnText
call NewBattleMonStatus
call BreakAttraction
call Function3db5f
@@ -7029,25 +7040,25 @@
ld b, 0
add hl, bc
xor a
- ld [hMultiplicand], a
+ ld [hMultiplicand + 0], a
ld a, [de]
- ld [$ffb5], a
+ ld [hMultiplicand + 1], a
inc de
ld a, [de]
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
ld a, [hli]
ld [hMultiplier], a
call Multiply
ld a, [hl]
- ld [hMultiplier], a
+ ld [hDivisor], a
ld b, $4
call Divide
pop hl
; Cap at 999.
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
sub 999 % $100
- ld a, [$ffb5]
+ ld a, [hQuotient + 1]
sbc 999 / $100
jp c, .asm_3ed1e
@@ -7411,15 +7422,15 @@
dec c
jr nz, .asm_3ee7c
xor a
- ld [hMultiplicand], a
- ld [$ffb5], a
+ ld [hMultiplicand + 0], a
+ ld [hMultiplicand + 1], a
ld a, [EnemyMonBaseExp]
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
ld a, [EnemyMonLevel]
ld [hMultiplier], a
call Multiply
ld a, $7
- ld [hMultiplier], a
+ ld [hDivisor], a
ld b, $4
call Divide
pop bc
@@ -7961,36 +7972,37 @@
ld a, $1
ld [hBGMapMode], a
ret
-; 3f26d
-Function3f26d: ; 3f26d
-; SendOutMonText?
-
+SendOutPkmnText: ; 3f26d
ld a, [InLinkBattle]
and a
jr z, .asm_3f27c
- ld hl, UnknownText_0x3f2d1
- ld a, [wd264]
+
+ ld hl, JumpText_GoPkmn ; If we're in a LinkBattle print just "Go <PlayerMon>"
+
+ ld a, [wd264] ; besides this variable is set. which stands for ???
and a
jr nz, .asm_3f2ce
.asm_3f27c
+; Depending on the HP of the enemy Pkmn, the game prints a different text
ld hl, EnemyMonHP
ld a, [hli]
or [hl]
- ld hl, UnknownText_0x3f2d1
+ ld hl, JumpText_GoPkmn
jr z, .asm_3f2ce
+
xor a
- ld [hMultiplicand], a
+ ld [hMultiplicand + 0], a
ld hl, EnemyMonHP
ld a, [hli]
ld [wc6ea], a
- ld [$ffb5], a
+ ld [hMultiplicand + 1], a
ld a, [hl]
ld [wc6eb], a
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
ld a, $19
ld [hMultiplier], a
call Multiply
@@ -8003,19 +8015,19 @@
rr b
ld a, b
ld b, $4
- ld [hMultiplier], a
+ ld [hDivisor], a
call Divide
- ld a, [$ffb6]
- ld hl, UnknownText_0x3f2d1
+ ld a, [hQuotient + 2]
+ ld hl, JumpText_GoPkmn
cp $46
jr nc, .asm_3f2ce
- ld hl, UnknownText_0x3f2d8
+ ld hl, JumpText_DoItPkmn
cp $28
jr nc, .asm_3f2ce
- ld hl, UnknownText_0x3f2df
+ ld hl, JumpText_GoForItPkmn
cp $a
jr nc, .asm_3f2ce
- ld hl, UnknownText_0x3f2e6
+ ld hl, JumpText_YourFoesWeakGetmPkmn
.asm_3f2ce
jp BattleTextBox
@@ -8022,36 +8034,36 @@
; 3f2d1
-UnknownText_0x3f2d1: ; 3f2d1
- text_jump UnknownText_0x1c02df
+JumpText_GoPkmn: ; 3f2d1
+ text_jump Text_GoPkmn
start_asm
- jr Function3f2eb
+ jr Function_TextJump_BattleMonNick01
; 3f2d6
-UnknownText_0x3f2d8: ; 3f2d8
- text_jump UnknownText_0x1c02e6
+JumpText_DoItPkmn: ; 3f2d8
+ text_jump Text_DoItPkmn
start_asm
- jr Function3f2eb
+ jr Function_TextJump_BattleMonNick01
; 3f2dd
-UnknownText_0x3f2df: ; 3f2df
- text_jump UnknownText_0x1c02f0
+JumpText_GoForItPkmn: ; 3f2df
+ text_jump Text_GoForItPkmn
start_asm
- jr Function3f2eb
+ jr Function_TextJump_BattleMonNick01
; 3f2e4
-UnknownText_0x3f2e6: ; 3f2e6
- text_jump UnknownText_0x1c02fe
+JumpText_YourFoesWeakGetmPkmn: ; 3f2e6
+ text_jump Text_YourFoesWeakGetmPkmn
start_asm
; 3f2eb
-Function3f2eb: ; 3f2eb
- ld hl, UnknownText_0x3f2ef
+Function_TextJump_BattleMonNick01: ; 3f2eb
+ ld hl, TextJump_BattleMonNick01
ret
; 3f2ef
-UnknownText_0x3f2ef: ; 3f2ef
- text_jump UnknownText_0x1c0317
+TextJump_BattleMonNick01: ; 3f2ef
+ text_jump Text_BattleMonNick01
db "@"
; 3f2f4
@@ -8075,12 +8087,12 @@
dec hl
ld a, [de]
sub b
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
dec de
ld b, [hl]
ld a, [de]
sbc b
- ld [$ffb5], a
+ ld [hMultiplicand + 1], a
ld a, $19
ld [hMultiplier], a
call Multiply
@@ -8093,11 +8105,11 @@
rr b
ld a, b
ld b, $4
- ld [hMultiplier], a
+ ld [hDivisor], a
call Divide
pop bc
pop de
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
ld hl, UnknownText_0x3f348
and a
ret z
@@ -8260,10 +8272,10 @@
.asm_3f40c
ld a, c
- ld [hMultiplier], a
+ ld [hDivisor], a
ld b, $4
call Divide
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
ld b, a
ld a, $40
sub b
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -1458,37 +1458,37 @@
ld [AttackMissed], a
xor a
.asm_34775
- ld [$ffb7], a
+ ld [hMultiplier], a
add b
ld [TypeModifier], a
xor a
- ld [$ffb4], a
+ ld [hMultiplicand + 0], a
ld hl, CurDamage
ld a, [hli]
- ld [$ffb5], a
+ ld [hMultiplicand + 1], a
ld a, [hld]
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
call Multiply
- ld a, [$ffb4]
+ ld a, [hProduct + 1]
ld b, a
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
or b
ld b, a
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
or b
jr z, .asm_347ab
ld a, $a
- ld [$ffb7], a
+ ld [hDivisor], a
ld b, $4
call Divide
- ld a, [$ffb5]
+ ld a, [hQuotient + 1]
ld b, a
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
or b
jr nz, .asm_347ab
@@ -1572,11 +1572,11 @@
jr .asm_347e7
.asm_3480b
xor a
- ld [$ffb3], a
- ld [$ffb4], a
- ld [$ffb5], a
+ ld [hDividend + 0], a
+ ld [hMultiplicand + 0], a
+ ld [hMultiplicand + 1], a
ld a, [hli]
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
ld a, [wd265]
ld [hMultiplier], a
call Multiply
@@ -1586,7 +1586,7 @@
ld b, 4
call Divide
pop bc
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
ld [wd265], a
jr .asm_347e7
@@ -2305,12 +2305,12 @@
.go
; Start with the maximum damage.
xor a
- ld [$ffb4], a
+ ld [hMultiplicand + 0], a
dec hl
ld a, [hli]
- ld [$ffb5], a
+ ld [hMultiplicand + 1], a
ld a, [hl]
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
; Multiply by 85-100%...
.loop
@@ -2319,20 +2319,20 @@
cp $d9 ; 85%
jr c, .loop
- ld [$ffb7], a
+ ld [hMultiplier], a
call Multiply
; ...divide by 100%...
ld a, $ff ; 100%
- ld [$ffb7], a
+ ld [hDivisor], a
ld b, $4
call Divide
; ...to get .85-1.00x damage.
- ld a, [$ffb5]
+ ld a, [hQuotient + 1]
ld hl, CurDamage
ld [hli], a
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
ld [hl], a
ret
; 34d32
@@ -2594,10 +2594,10 @@
sub c
ld c, a
xor a
- ld [$ffb4], a
- ld [$ffb5], a
+ ld [hMultiplicand + 0], a
+ ld [hMultiplicand + 1], a
ld a, [hl]
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
push hl
ld d, $2
@@ -2611,15 +2611,15 @@
add hl, bc
pop bc
ld a, [hli]
- ld [$ffb7], a
+ ld [hMultiplier], a
call Multiply
ld a, [hl]
- ld [$ffb7], a
+ ld [hDivisor], a
ld b, $4
call Divide
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
ld b, a
- ld a, [$ffb5]
+ ld a, [hQuotient + 1]
or b
jr nz, .asm_34ea2
ld [$ffb5], a
@@ -4344,18 +4344,18 @@
.asm_3579d
xor a
ld [$ffb3], a
- ld [$ffb4], a
+ ld [hMultiplicand + 0], a
ld a, [hli]
- ld [$ffb5], a
+ ld [hMultiplicand + 1], a
ld a, [hli]
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
ld a, $30
- ld [$ffb7], a
+ ld [hMultiplier], a
call Multiply
ld a, [hli]
ld b, a
ld a, [hl]
- ld [$ffb7], a
+ ld [hDivisor], a
ld a, b
and a
jr z, .asm_357d6
@@ -4365,22 +4365,22 @@
rr a
srl b
rr a
- ld [$ffb7], a
- ld a, [$ffb5]
+ ld [hDivisor], a
+ ld a, [hProduct + 2]
ld b, a
srl b
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
rr a
srl b
rr a
- ld [$ffb6], a
+ ld [hDividend + 3], a
ld a, b
- ld [$ffb5], a
+ ld [hDividend + 2], a
.asm_357d6
ld b, $4
call Divide
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
ld b, a
ld hl, .FlailPower
@@ -6874,7 +6874,7 @@
endr
xor a
- ld [hMultiplicand], a
+ ld [hMultiplicand + 0], a
ld a, [de]
ld [hMultiplicand + 1], a
inc de
@@ -9470,7 +9470,7 @@
ld hl, EnemyMonHappiness
.ok
xor a
- ld [hMultiplicand], a
+ ld [hMultiplicand + 0], a
ld [hMultiplicand + 1], a
ld a, [hl]
ld [hMultiplicand + 2], a
@@ -9595,18 +9595,18 @@
.asm_3791a
ld a, $ff
sub [hl]
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
xor a
- ld [$ffb4], a
- ld [$ffb5], a
+ ld [hMultiplicand + 0], a
+ ld [hMultiplicand + 1], a
ld a, 10
- ld [$ffb7], a
+ ld [hMultiplier], a
call Multiply
ld a, 25
- ld [$ffb7], a
+ ld [hDivisor], a
ld b, 4
call Divide
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
ld d, a
pop bc
ret
--- a/hram.asm
+++ b/hram.asm
@@ -31,13 +31,16 @@
hPastLeadingZeroes EQU $ffb3
-hDividend EQU $ffb3
-hDivisor EQU $ffb7
-hQuotient EQU $ffb4
+hStringCmpString1 EQU $ffb1
+hStringCmpString2 EQU $ffb5
-hMultiplicand EQU $ffb4
-hMultiplier EQU $ffb7
-hProduct EQU $ffb3
+hDividend EQU $ffb3 ; length in b register, before 'call Divide' (max 4 bytes)
+hDivisor EQU $ffb7 ; 1 byte long
+hQuotient EQU $ffb4 ; result (3 bytes long)
+
+hMultiplicand EQU $ffb4 ; 3 bytes long
+hMultiplier EQU $ffb7 ; 1 byte long
+hProduct EQU $ffb3 ; result (4 bytes long)
hMathBuffer EQU $ffb8
--- a/items/item_effects.asm
+++ b/items/item_effects.asm
@@ -273,7 +273,7 @@
jp z, .asm_e98e
ld a, b
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
ld hl, EnemyMonHP
ld b, [hl]
@@ -318,9 +318,9 @@
sub c
ld [hMultiplier], a
xor a
- ld [hProduct], a
- ld [hMultiplicand], a
- ld [$ffb5], a
+ ld [hDividend + 0], a
+ ld [hMultiplicand + 0], a
+ ld [hMultiplicand + 1], a
call Multiply
pop bc
@@ -329,7 +329,7 @@
ld b, $4
call Divide
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
and a
jr nz, .statuscheck
ld a, 1
--- a/main.asm
+++ b/main.asm
@@ -4464,11 +4464,11 @@
jr z, .zero
push hl
xor a
- ld [hMultiplicand], a
+ ld [hMultiplicand + 0], a
ld a, b
- ld [$ffb5], a
+ ld [hMultiplicand + 1], a
ld a, c
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
ld a, $30
ld [hMultiplier], a
call Multiply
@@ -4479,23 +4479,23 @@
rr e
srl d
rr e
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
ld b, a
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
srl b
rr a
srl b
rr a
- ld [$ffb6], a
+ ld [hDividend + 3], a
ld a, b
- ld [$ffb5], a
+ ld [hDividend + 2], a
.divide
ld a, e
- ld [hMultiplier], a
+ ld [hDivisor], a
ld b, $4
call Divide
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
ld e, a
pop hl
and a
@@ -9390,22 +9390,22 @@
inc d
.asm_e20f
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
ld a, d
- ld [$ffb5], a
+ ld [hMultiplicand + 1], a
xor a
- ld [hMultiplicand], a
+ ld [hMultiplicand + 0], a
ld a, [CurPartyLevel]
ld [hMultiplier], a
call Multiply
- ld a, [hMultiplicand]
- ld [hProduct], a
- ld a, [$ffb5]
- ld [hMultiplicand], a
- ld a, [$ffb6]
- ld [$ffb5], a
+ ld a, [hProduct + 1]
+ ld [hDividend + 0], a
+ ld a, [hProduct + 2]
+ ld [hDividend + 1], a
+ ld a, [hProduct + 3]
+ ld [hDividend + 2], a
ld a, $64
- ld [hMultiplier], a
+ ld [hDivisor], a
ld a, $3
ld b, a
call Divide
@@ -9415,11 +9415,11 @@
jr nz, .asm_e24e
ld a, [CurPartyLevel]
ld b, a
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
add b
ld [$ffb6], a
jr nc, .asm_e24c
- ld a, [$ffb5]
+ ld a, [hQuotient + 1]
inc a
ld [$ffb5], a
@@ -25877,11 +25877,11 @@
Function250a9: ; 250a9
xor a
- ld [hMultiplicand], a
+ ld [hMultiplicand + 0], a
ld a, [Buffer1]
- ld [$ffb5], a
+ ld [hMultiplicand + 1], a
ld a, [Buffer2]
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
ld a, [wd10c]
ld [hMultiplier], a
push hl
@@ -35885,7 +35885,7 @@
; 3991b
Function3991b: ; 3991b (e:591b)
- ld hl, $ffb3
+ ld hl, hMultiplicand - 1
xor a
rept 3
ld [hli], a
@@ -35898,9 +35898,9 @@
ld hl, wc686
xor a
ld [hli], a
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
ld [hli], a
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
ld [hl], a
ret
@@ -39638,8 +39638,8 @@
add c
ld [hld], a
xor a
- ld [hQuotient], a ; $ff00+$b4 (aliases: hMultiplicand)
- ld [$ffb5], a
+ ld [hMultiplicand + 0], a
+ ld [hMultiplicand + 1], a
ld a, [hl]
srl a
srl a
@@ -39651,13 +39651,13 @@
ld a, [hli]
and $f
add b
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
ld a, 100
- ld [hDivisor], a ; $ff00+$b7 (aliases: hMultiplier)
+ ld [hMultiplier], a
call Multiply
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
ld b, a
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
ld c, a
ld e, [hl]
add e
@@ -39672,10 +39672,10 @@
Function48d94: ; 48d94 (12:4d94)
xor a
- ld [$ffb3], a
+ ld [hDividend + 0], a
ld [hQuotient], a ; $ff00+$b4 (aliases: hMultiplicand)
ld a, [hli]
- ld [$ffb3], a
+ ld [hDividend + 0], a
ld a, [hl]
ld [hQuotient], a ; $ff00+$b4 (aliases: hMultiplicand)
ld a, 100
@@ -39691,7 +39691,7 @@
sla b
or b
ld [hld], a
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
ld c, 10
call SimpleDivide
sla b
@@ -49389,11 +49389,11 @@
ld b, $4
call Divide
- ld a, [hMultiplicand]
+ ld a, [hMultiplicand + 0]
push af
- ld a, [$ffb5]
+ ld a, [hMultiplicand + 1]
push af
- ld a, [$ffb6]
+ ld a, [hMultiplicand + 2]
push af
call Function50eed
@@ -49402,33 +49402,33 @@
ld [hMultiplier], a
call Multiply
- ld a, [hMultiplicand]
+ ld a, [hProduct + 1]
push af
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
push af
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
push af
ld a, [hli]
push af
xor a
- ld [hMultiplicand], a
- ld [$ffb5], a
+ ld [hMultiplicand + 0], a
+ ld [hMultiplicand + 1], a
ld a, d
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
ld a, [hli]
ld [hMultiplier], a
call Multiply
ld b, [hl]
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
sub b
ld [$ffb6], a
ld b, $0
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
sbc b
ld [$ffb5], a
- ld a, [hMultiplicand]
+ ld a, [hProduct + 1]
sbc b
ld [hMultiplicand], a
@@ -49482,10 +49482,10 @@
Function50eed: ; 50eed
xor a
- ld [hMultiplicand], a
- ld [$ffb5], a
+ ld [hMultiplicand + 0], a
+ ld [hMultiplicand + 1], a
ld a, d
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
ld [hMultiplier], a
jp Multiply
; 50efa
@@ -87396,12 +87396,12 @@
.ApplyModifier
xor a
- ld [hMultiplicand], a
+ ld [hMultiplicand + 0], a
ld hl, CurDamage
ld a, [hli]
- ld [$ffb5], a
+ ld [hMultiplicand + 1], a
ld a, [hl]
- ld [$ffb6], a
+ ld [hMultiplicand + 2], a
inc de
ld a, [de]
@@ -87410,18 +87410,18 @@
call Multiply
ld a, 10
- ld [hMultiplier], a
+ ld [hDivisor], a
ld b, $4
call Divide
- ld a, [hMultiplicand]
+ ld a, [hQuotient + 0]
and a
ld bc, $ffff
jr nz, .Update
- ld a, [$ffb5]
+ ld a, [hQuotient + 1]
ld b, a
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
ld c, a
or b
jr nz, .Update
--- a/text/battle.asm
+++ b/text/battle.asm
@@ -113,7 +113,7 @@
prompt
; 0x80899
-BattleText_0x80899: ; 0x80899
+BattleText_UserRecoveredPPUsing: ; 0x80899
text "<USER>"
line "recovered PP using"
cont "@"
@@ -129,13 +129,13 @@
prompt
; 0x808d2
-BattleText_0x808d2: ; 0x808d2
+BattleText_SafeguardFaded: ; 0x808d2
text "<USER>'s"
line "SAFEGUARD faded!"
prompt
; 0x808e7
-BattleText_0x808e7: ; 0x808e7
+BattleText_PkmnnLightScreenFell: ; 0x808e7
text_from_ram StringBuffer1
text " #MON's"
line "LIGHT SCREEN fell!"
@@ -149,42 +149,42 @@
prompt
; 0x8091f
-BattleText_0x8091f: ; 0x8091f
+BattleText_RainContinuesToFall: ; 0x8091f
text "Rain continues to"
line "fall."
prompt
; 0x80938
-BattleText_0x80938: ; 0x80938
+BattleText_TheSunlightIsStrong: ; 0x80938
text "The sunlight is"
line "strong."
prompt
; 0x80951
-BattleText_0x80951: ; 0x80951
+BattleText_TheSandstormRages: ; 0x80951
text "The SANDSTORM"
line "rages."
prompt
; 0x80967
-BattleText_0x80967: ; 0x80967
+BattleText_TheRainStopped: ; 0x80967
text "The rain stopped."
prompt
; 0x8097a
-BattleText_0x8097a: ; 0x8097a
+BattleText_TheSunlightFaded: ; 0x8097a
text "The sunlight"
line "faded."
prompt
; 0x8098f
-BattleText_0x8098f: ; 0x8098f
+BattleText_TheSandstormSubsided: ; 0x8098f
text "The SANDSTORM"
line "subsided."
prompt
; 0x809a8
-BattleText_0x809a8: ; 0x809a8
+BattleText_EnemyPkmnFainted: ; 0x809a8
text "Enemy @"
text_from_ram EnemyMonNick
text ""
@@ -199,7 +199,7 @@
line "for winning!"
prompt
-BattleText_0x809da: ; 0x809da
+BattleText_EnemyWasDefeated: ; 0x809da
text "<ENEMY>"
line "was defeated!"
prompt
@@ -234,7 +234,7 @@
prompt
; 0x80a75
-BattleText_0x80a75: ; 0x80a75
+BattleText_PkmnFainted: ; 0x80a75
text_from_ram BattleMonNick
text ""
line "fainted!"
@@ -241,7 +241,7 @@
prompt
; 0x80a83
-BattleText_0x80a83: ; 0x80a83
+BattleText_UseNextMon: ; 0x80a83
text "Use next #MON?"
done
; 0x80a93
@@ -259,7 +259,7 @@
prompt
; 0x80aca
-BattleText_0x80aca: ; 0x80aca
+BattleText_EnemyIsAboutToUseWillPlayerChangePkmn: ; 0x80aca
text "<ENEMY>"
line "is about to use"
cont "@"
@@ -280,34 +280,32 @@
done
; 0x80b0b
-BattleText_0x80b0b: ; 0x80b0b
+BattleText_TheresNoWillToBattle: ; 0x80b0b
text "There's no will to"
line "battle!"
prompt
; 0x80b26
-BattleText_0x80b26: ; 0x80b26
+BattleText_AnEGGCantBattle: ; 0x80b26
text "An EGG can't"
line "battle!"
prompt
; 0x80b3b
-BattleText_0x80b3b: ; 0x80b3b
+BattleText_CantEscape2: ; 0x80b3b
text "Can't escape!"
prompt
; 0x80b49
-BattleText_0x80b49: ; 0x80b49
+BattleText_TheresNoEscapeFromTrainerBattle: ; 0x80b49
text "No! There's no"
line "running from a"
cont "trainer battle!"
prompt
-; 0x80b77
-BattleText_0x80b77: ; 0x80b77
+BattleText_GotAwaySafely: ; 0x80b77
text "Got away safely!"
prompt
-; 0x80b89
BattleText_0x80b89: ; 0x80b89
text "<USER>"
@@ -318,7 +316,7 @@
prompt
; 0x80ba0
-BattleText_0x80ba0: ; 0x80ba0
+BattleText_CantEscape: ; 0x80ba0
text "Can't escape!"
prompt
; 0x80bae
--- a/text/common_3.asm
+++ b/text/common_3.asm
@@ -129,29 +129,29 @@
prompt
; 1c02df
-UnknownText_0x1c02df: ; 1c02df
+Text_GoPkmn: ; 1c02df
text "Go! @"
db "@"
; 1c02e6
-UnknownText_0x1c02e6: ; 1c02e6
+Text_DoItPkmn: ; 1c02e6
text "Do it! @"
db "@"
; 1c02f0
-UnknownText_0x1c02f0: ; 1c02f0
+Text_GoForItPkmn: ; 1c02f0
text "Go for it,"
line "@"
db "@"
; 1c02fe
-UnknownText_0x1c02fe: ; 1c02fe
+Text_YourFoesWeakGetmPkmn: ; 1c02fe
text "Your foe's weak!"
line "Get'm, @"
db "@"
; 1c0317
-UnknownText_0x1c0317: ; 1c0317
+Text_BattleMonNick01: ; 1c0317
text_from_ram BattleMonNick
text "!"
done
--- a/wram.asm
+++ b/wram.asm
@@ -809,6 +809,7 @@
wc717:: ds 1
wc718:: ds 1
wc719:: ds 1
+LastPlayerMon:: ; c71a
wc71a:: ds 1
LastPlayerMove:: ; c71b
ds 1