aboutsummaryrefslogtreecommitdiffstats
path: root/engine/battle
diff options
context:
space:
mode:
authorRangi42 <remy.oukaour+rangi42@gmail.com>2023-11-21 20:15:30 -0500
committerRangi42 <remy.oukaour+rangi42@gmail.com>2023-11-21 20:15:30 -0500
commitd4e7a39dd89a32c7af13fed31b3178cc769fb797 (patch)
tree364eb45a0bf6c5425c4f89aced9c91b1a379cb63 /engine/battle
parentReplace some `$a` with `EFFECTIVE` (#399) (diff)
downloadpokeyellow-d4e7a39dd89a32c7af13fed31b3178cc769fb797.tar.gz
pokeyellow-d4e7a39dd89a32c7af13fed31b3178cc769fb797.tar.xz
pokeyellow-d4e7a39dd89a32c7af13fed31b3178cc769fb797.zip
Use some more constants in place of raw numbers
Diffstat (limited to 'engine/battle')
-rw-r--r--engine/battle/core.asm32
1 files changed, 16 insertions, 16 deletions
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index ed2c4b7a..b93b6fa7 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -18,7 +18,7 @@ SlidePlayerAndEnemySilhouettesOnScreen:
call LoadFontTilePatterns
call LoadHudAndHpBarAndStatusTilePatterns
ld hl, vBGMap0
- ld bc, $400
+ ld bc, BG_MAP_WIDTH * BG_MAP_HEIGHT
.clearBackgroundLoop
ld a, " "
ld [hli], a
@@ -29,9 +29,9 @@ SlidePlayerAndEnemySilhouettesOnScreen:
; copy the work RAM tile map to VRAM
hlcoord 0, 0
ld de, vBGMap0
- ld b, 18 ; number of rows
+ ld b, SCREEN_HEIGHT
.copyRowLoop
- ld c, 20 ; number of columns
+ ld c, SCREEN_WIDTH
.copyColumnLoop
ld a, [hli]
ld [de], a
@@ -825,7 +825,7 @@ FaintEnemyPokemon:
; the enemy mon base stats are added to stat exp, so they are halved
; the base exp (which determines normal exp) is also halved
ld hl, wEnemyMonBaseStats
- ld b, $7
+ ld b, NUM_STATS + 2
.halveExpDataLoop
srl [hl]
inc hl
@@ -1259,7 +1259,7 @@ SlideTrainerPicOffScreen:
dec c
jr nz, .columnLoop
pop hl
- ld de, 20
+ ld de, SCREEN_WIDTH
add hl, de
dec b
jr nz, .rowLoop
@@ -4183,7 +4183,7 @@ GetDamageVarsForPlayerAttack:
and a ; check for critical hit
jr z, .scaleStats
; in the case of a critical hit, reset the player's attack and the enemy's defense to their base values
- ld c, 3 ; defense stat
+ ld c, STAT_DEFENSE
call GetEnemyMonStat
ldh a, [hProduct + 2]
ld b, a
@@ -4215,7 +4215,7 @@ GetDamageVarsForPlayerAttack:
and a ; check for critical hit
jr z, .scaleStats
; in the case of a critical hit, reset the player's and enemy's specials to their base values
- ld c, 5 ; special stat
+ ld c, STAT_SPECIAL
call GetEnemyMonStat
ldh a, [hProduct + 2]
ld b, a
@@ -4304,7 +4304,7 @@ GetDamageVarsForEnemyAttack:
ld b, a
ld c, [hl]
push bc
- ld c, 2 ; attack stat
+ ld c, STAT_ATTACK
call GetEnemyMonStat
ld hl, hProduct + 2
pop bc
@@ -4336,7 +4336,7 @@ GetDamageVarsForEnemyAttack:
ld b, a
ld c, [hl]
push bc
- ld c, 5 ; special stat
+ ld c, STAT_SPECIAL
call GetEnemyMonStat
ld hl, hProduct + 2
pop bc
@@ -4380,7 +4380,7 @@ GetDamageVarsForEnemyAttack:
ret
; get stat c of enemy mon
-; c: stat to get (HP=1,Attack=2,Defense=3,Speed=4,Special=5)
+; c: stat to get (STAT_* constant)
GetEnemyMonStat:
push de
push bc
@@ -5287,7 +5287,7 @@ AdjustDamageForMoveType:
call Multiply
ld a, 10
ldh [hDivisor], a
- ld b, $04
+ ld b, 4
call Divide
ldh a, [hQuotient + 2]
ld [hli], a
@@ -5315,7 +5315,6 @@ AdjustDamageForMoveType:
; this doesn't take into account the effects that dual types can have
; (e.g. 4x weakness / resistance, weaknesses and resistances canceling)
; the result is stored in [wTypeEffectiveness]
-; ($05 is not very effective, $10 is neutral, $14 is super effective)
; as far is can tell, this is only used once in some AI code to help decide which move to use
AIGetTypeEffectiveness:
ld a, [wEnemyMoveType]
@@ -5324,8 +5323,10 @@ AIGetTypeEffectiveness:
ld b, [hl] ; b = type 1 of player's pokemon
inc hl
ld c, [hl] ; c = type 2 of player's pokemon
- ld a, $10
- ld [wTypeEffectiveness], a ; initialize to neutral effectiveness
+ ; initialize to neutral effectiveness
+ ; bug: this is $10 (MORE_EFFECTIVE + 1) but should be 10 (EFFECTIVE)
+ ld a, MORE_EFFECTIVE + 1
+ ld [wTypeEffectiveness], a
ld hl, TypeEffects
.loop
ld a, [hli]
@@ -6909,7 +6910,6 @@ _InitBattleCommon:
db "@"
_LoadTrainerPic:
-; wd033-wd034 contain pointer to pic
ld a, [wTrainerPicPointer]
ld e, a
ld a, [wTrainerPicPointer + 1]
@@ -7043,7 +7043,7 @@ LoadMonBackPic:
call InterlaceMergeSpriteBuffers ; combine the two buffers to a single 2bpp sprite
ld hl, vSprites
ld de, vBackPic
- ld c, (2*SPRITEBUFFERSIZE)/16 ; count of 16-byte chunks to be copied
+ ld c, (2 * SPRITEBUFFERSIZE) / 16 ; count of 16-byte chunks to be copied
ldh a, [hLoadedROMBank]
ld b, a
jp CopyVideoData