aboutsummaryrefslogtreecommitdiffstats
path: root/engine/battle
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2023-11-21 20:56:28 -0600
committerdannye <33dannye@gmail.com>2023-11-21 20:56:28 -0600
commit04f7f7f506a1dbb877e4678601261e8157fd0e57 (patch)
treebfe62d3872c5f031ee40df9488910bd58b0e1b15 /engine/battle
parentExtend tools/pcm.c to allow decoding .pcm to .wav (diff)
parentFix some map text constants (diff)
downloadpokeyellow-04f7f7f506a1dbb877e4678601261e8157fd0e57.tar.gz
pokeyellow-04f7f7f506a1dbb877e4678601261e8157fd0e57.tar.xz
pokeyellow-04f7f7f506a1dbb877e4678601261e8157fd0e57.zip
Merge branch 'master' of https://github.com/pret/pokered
Diffstat (limited to 'engine/battle')
-rw-r--r--engine/battle/animations.asm54
-rw-r--r--engine/battle/battle_transitions.asm24
-rw-r--r--engine/battle/core.asm46
-rw-r--r--engine/battle/display_effectiveness.asm2
-rw-r--r--engine/battle/effects.asm4
-rw-r--r--engine/battle/init_battle.asm3
-rw-r--r--engine/battle/scale_sprites.asm21
7 files changed, 71 insertions, 83 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index ffa7e5a8..da758332 100644
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -1016,7 +1016,7 @@ AnimationFlashScreenLong:
push hl
.innerLoop
ld a, [hli]
- cp $01 ; is it the end of the palettes?
+ cp 1
jr z, .endOfPalettes
ldh [rBGP], a
call UpdateGBCPal_BGP
@@ -1032,35 +1032,35 @@ AnimationFlashScreenLong:
; BG palettes
FlashScreenLongMonochrome:
- db %11111001 ; 3, 3, 2, 1
- db %11111110 ; 3, 3, 3, 2
- db %11111111 ; 3, 3, 3, 3
- db %11111110 ; 3, 3, 3, 2
- db %11111001 ; 3, 3, 2, 1
- db %11100100 ; 3, 2, 1, 0
- db %10010000 ; 2, 1, 0, 0
- db %01000000 ; 1, 0, 0, 0
- db %00000000 ; 0, 0, 0, 0
- db %01000000 ; 1, 0, 0, 0
- db %10010000 ; 2, 1, 0, 0
- db %11100100 ; 3, 2, 1, 0
- db $01 ; terminator
+ dc 3, 3, 2, 1
+ dc 3, 3, 3, 2
+ dc 3, 3, 3, 3
+ dc 3, 3, 3, 2
+ dc 3, 3, 2, 1
+ dc 3, 2, 1, 0
+ dc 2, 1, 0, 0
+ dc 1, 0, 0, 0
+ dc 0, 0, 0, 0
+ dc 1, 0, 0, 0
+ dc 2, 1, 0, 0
+ dc 3, 2, 1, 0
+ db 1 ; end
; BG palettes
FlashScreenLongSGB:
- db %11111000 ; 3, 3, 2, 0
- db %11111100 ; 3, 3, 3, 0
- db %11111111 ; 3, 3, 3, 3
- db %11111100 ; 3, 3, 3, 0
- db %11111000 ; 3, 3, 2, 0
- db %11100100 ; 3, 2, 1, 0
- db %10010000 ; 2, 1, 0, 0
- db %01000000 ; 1, 0, 0, 0
- db %00000000 ; 0, 0, 0, 0
- db %01000000 ; 1, 0, 0, 0
- db %10010000 ; 2, 1, 0, 0
- db %11100100 ; 3, 2, 1, 0
- db $01 ; terminator
+ dc 3, 3, 2, 0
+ dc 3, 3, 3, 0
+ dc 3, 3, 3, 3
+ dc 3, 3, 3, 0
+ dc 3, 3, 2, 0
+ dc 3, 2, 1, 0
+ dc 2, 1, 0, 0
+ dc 1, 0, 0, 0
+ dc 0, 0, 0, 0
+ dc 1, 0, 0, 0
+ dc 2, 1, 0, 0
+ dc 3, 2, 1, 0
+ db 1 ; end
; causes a delay of 2 frames for the first cycle
; causes a delay of 1 frame for the second and third cycles
diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm
index b0289d7e..77f2ba89 100644
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -339,18 +339,18 @@ BattleTransition_FlashScreen_:
ret
BattleTransition_FlashScreenPalettes:
- db %11111001
- db %11111110
- db %11111111
- db %11111110
- db %11111001
- db %11100100
- db %10010000
- db %01000000
- db %00000000
- db %01000000
- db %10010000
- db %11100100
+ dc 3, 3, 2, 1
+ dc 3, 3, 3, 2
+ dc 3, 3, 3, 3
+ dc 3, 3, 3, 2
+ dc 3, 3, 2, 1
+ dc 3, 2, 1, 0
+ dc 2, 1, 0, 0
+ dc 1, 0, 0, 0
+ dc 0, 0, 0, 0
+ dc 1, 0, 0, 0
+ dc 2, 1, 0, 0
+ dc 3, 2, 1, 0
db 1 ; end
; used for low level trainer dungeon battles
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 3bc59a4f..b7b10d06 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
@@ -834,7 +834,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
@@ -1298,7 +1298,7 @@ SlideTrainerPicOffScreen:
dec c
jr nz, .columnLoop
pop hl
- ld de, 20
+ ld de, SCREEN_WIDTH
add hl, de
dec b
jr nz, .rowLoop
@@ -3245,7 +3245,7 @@ ExecutePlayerMove:
ld [wMoveMissed], a
ld [wMonIsDisobedient], a
ld [wMoveDidntMiss], a
- ld a, $a
+ ld a, EFFECTIVE
ld [wDamageMultipliers], a
ld a, [wActionResultOrTookBattleTurn]
and a ; has the player already used the turn (e.g. by using an item, trying to run or switching pokemon)
@@ -3323,9 +3323,9 @@ handleIfPlayerMoveMissed:
getPlayerAnimationType:
ld a, [wPlayerMoveEffect]
and a
- ld a, 4 ; move has no effect other than dealing damage
+ ld a, ANIMATIONTYPE_BLINK_ENEMY_MON_SPRITE ; move has no effect other than dealing damage
jr z, playPlayerMoveAnimation
- ld a, 5 ; move has effect
+ ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_LIGHT ; move has effect
playPlayerMoveAnimation:
push af
ld a, [wPlayerBattleStatus2]
@@ -4352,7 +4352,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
@@ -4384,7 +4384,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
@@ -4473,7 +4473,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
@@ -4505,7 +4505,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
@@ -4549,7 +4549,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
@@ -5456,7 +5456,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
@@ -5484,7 +5484,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]
@@ -5493,8 +5492,9 @@ 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
+ ld a, $10 ; bug: should be EFFECTIVE (10)
+ ld [wTypeEffectiveness], a
ld hl, TypeEffects
.loop
ld a, [hli]
@@ -5782,7 +5782,7 @@ ExecuteEnemyMove:
xor a
ld [wMoveMissed], a
ld [wMoveDidntMiss], a
- ld a, $a
+ ld a, EFFECTIVE
ld [wDamageMultipliers], a
call CheckEnemyStatusConditions
jr nz, .enemyHasNoSpecialConditions
@@ -5861,9 +5861,9 @@ handleIfEnemyMoveMissed:
GetEnemyAnimationType:
ld a, [wEnemyMoveEffect]
and a
- ld a, $1
+ ld a, ANIMATIONTYPE_SHAKE_SCREEN_VERTICALLY
jr z, playEnemyMoveAnimation
- ld a, $2
+ ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_HEAVY
jr playEnemyMoveAnimation
handleExplosionMiss:
call SwapPlayerAndEnemyLevels
@@ -6935,9 +6935,11 @@ HandleExplodingAnimation:
ld a, [wMoveMissed]
and a
ret nz
- ld a, 5
+ ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_LIGHT
ld [wAnimationType], a
-
+ assert ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_LIGHT == MEGA_PUNCH
+ ; ld a, MEGA_PUNCH
+; fallthrough
PlayMoveAnimation:
ld [wAnimationID], a
call Delay3
diff --git a/engine/battle/display_effectiveness.asm b/engine/battle/display_effectiveness.asm
index b23695cf..2879f847 100644
--- a/engine/battle/display_effectiveness.asm
+++ b/engine/battle/display_effectiveness.asm
@@ -1,7 +1,7 @@
DisplayEffectiveness:
ld a, [wDamageMultipliers]
and $7F
- cp $0A
+ cp EFFECTIVE
ret z
ld hl, SuperEffectiveText
jr nc, .done
diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm
index c6ec7628..51dc1d37 100644
--- a/engine/battle/effects.asm
+++ b/engine/battle/effects.asm
@@ -1516,9 +1516,9 @@ PlayBattleAnimation2:
ld [wAnimationID], a
ldh a, [hWhoseTurn]
and a
- ld a, $6
+ ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_SLOW_2
jr z, .storeAnimationType
- ld a, $3
+ ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_SLOW
.storeAnimationType
ld [wAnimationType], a
jp PlayBattleAnimationGotID
diff --git a/engine/battle/init_battle.asm b/engine/battle/init_battle.asm
index e4c56d6d..d23df283 100644
--- a/engine/battle/init_battle.asm
+++ b/engine/battle/init_battle.asm
@@ -151,7 +151,6 @@ _InitBattleCommon:
db "@"
_LoadTrainerPic:
-; wd033-wd034 contain pointer to pic
ld a, [wTrainerPicPointer]
ld e, a
ld a, [wTrainerPicPointer + 1]
@@ -183,7 +182,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
diff --git a/engine/battle/scale_sprites.asm b/engine/battle/scale_sprites.asm
index 38ebff21..2e33f536 100644
--- a/engine/battle/scale_sprites.asm
+++ b/engine/battle/scale_sprites.asm
@@ -84,21 +84,8 @@ ScalePixelsByTwo:
add hl, bc ; add offset
ret
-; repeats each input bit twice
+; repeats each input bit twice, e.g. DuplicateBitsTable[%0101] = %00110011
DuplicateBitsTable:
- db %00000000
- db %00000011
- db %00001100
- db %00001111
- db %00110000
- db %00110011
- db %00111100
- db %00111111
- db %11000000
- db %11000011
- db %11001100
- db %11001111
- db %11110000
- db %11110011
- db %11111100
- db %11111111
+FOR n, 16
+ db (n & 1) * 3 + (n & 2) * 6 + (n & 4) * 12 + (n & 8) * 24
+ENDR