summaryrefslogtreecommitdiff
path: root/engine/battle
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle')
-rwxr-xr-xengine/battle/ai/move.asm4
-rw-r--r--engine/battle/battle_transition.asm4
-rw-r--r--engine/battle/core.asm21
-rw-r--r--engine/battle/effect_commands.asm43
4 files changed, 37 insertions, 35 deletions
diff --git a/engine/battle/ai/move.asm b/engine/battle/ai/move.asm
index 11586c0da..72ed6983b 100755
--- a/engine/battle/ai/move.asm
+++ b/engine/battle/ai/move.asm
@@ -56,7 +56,7 @@ AIChooseMove: ; 440ce
inc hl
ld a, [de]
inc de
- and $3f
+ and PP_MASK
jr nz, .CheckMovePP
ld [hl], 80
jr .CheckMovePP
@@ -186,7 +186,7 @@ AIChooseMove: ; 440ce
.ChooseMove:
ld hl, Buffer1
call Random
- and 3
+ maskbits NUM_MOVES +- 1
ld c, a
ld b, 0
add hl, bc
diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm
index 383674652..4c05112ac 100644
--- a/engine/battle/battle_transition.asm
+++ b/engine/battle/battle_transition.asm
@@ -640,8 +640,8 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc)
.cgb
ld hl, .daypals
ld a, [TimeOfDayPal]
- and $3
- cp 3
+ maskbits NUM_DAYTIMES +- 1
+ cp DARKNESS_F
jr nz, .daytime
ld hl, .nightpals
.daytime
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 5b5b3562e..35d2098bc 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -730,7 +730,7 @@ HandleEncore: ; 3c4df
ld b, 0
add hl, bc
ld a, [hl]
- and $3f
+ and PP_MASK
ret nz
.end_player_encore
@@ -754,7 +754,7 @@ HandleEncore: ; 3c4df
ld b, 0
add hl, bc
ld a, [hl]
- and $3f
+ and PP_MASK
ret nz
.end_enemy_encore
@@ -1401,7 +1401,7 @@ HandleMysteryberry: ; 3c93c
and a
jr z, .quit
ld a, [de]
- and $3f
+ and PP_MASK
jr z, .restore
inc hl
inc de
@@ -5650,7 +5650,7 @@ MoveSelectionScreen: ; 3e4bc
ld b, 0
add hl, bc
ld a, [hl]
- and $3f
+ and PP_MASK
jr z, .no_pp_left
ld a, [PlayerDisableCount]
swap a
@@ -5849,7 +5849,7 @@ MoveInfoBox: ; 3e6c8
ld hl, BattleMonPP
add hl, bc
ld a, [hl]
- and $3f
+ and PP_MASK
ld [StringBuffer1], a
call .PrintPP
@@ -5912,7 +5912,7 @@ CheckPlayerHasUsableMoves: ; 3e786
or [hl]
inc hl
or [hl]
- and $3f
+ and PP_MASK
ret nz
jr .force_struggle
@@ -5934,8 +5934,7 @@ CheckPlayerHasUsableMoves: ; 3e786
.done
; Bug: this will result in a move with PP Up confusing the game.
- ; Replace with "and $3f" to fix.
- and a
+ and a ; should be "and PP_MASK"
ret nz
.force_struggle
@@ -6014,7 +6013,7 @@ ParseEnemyAction: ; 3e7c1
cp [hl]
jr z, .disabled
ld a, [de]
- and $3f
+ and PP_MASK
jr nz, .enough_pp
.disabled
@@ -6032,7 +6031,7 @@ ParseEnemyAction: ; 3e7c1
.loop2
ld hl, EnemyMonMoves
call BattleRandom
- and 3 ; TODO factor in NUM_MOVES
+ maskbits NUM_MOVES +- 1
ld c, a
ld b, 0
add hl, bc
@@ -6049,7 +6048,7 @@ ParseEnemyAction: ; 3e7c1
add hl, bc
ld b, a
ld a, [hl]
- and $3f
+ and PP_MASK
jr z, .loop2
ld a, c
ld [CurEnemyMoveNum], a
diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm
index f9a8ba63e..68184ce30 100644
--- a/engine/battle/effect_commands.asm
+++ b/engine/battle/effect_commands.asm
@@ -846,19 +846,20 @@ BattleCommand_CheckObedience: ; 343db
.DoNothing:
+ ; 4 random choices
call BattleRandom
- and 3
+ and %11
ld hl, LoafingAroundText
- and a
+ and a ; 0
jr z, .Print
ld hl, WontObeyText
- dec a
+ dec a ; 1
jr z, .Print
ld hl, TurnedAwayText
- dec a
+ dec a ; 2
jr z, .Print
ld hl, IgnoredOrdersText
@@ -888,7 +889,7 @@ BattleCommand_CheckObedience: ; 343db
.GetTotalPP:
ld a, [hli]
- and $3f ; exclude pp up
+ and PP_MASK
add b
ld b, a
@@ -911,7 +912,7 @@ BattleCommand_CheckObedience: ; 343db
; Can't use another move if only one move has PP.
ld a, [hl]
- and $3f
+ and PP_MASK
cp b
jr z, .DoNothing
@@ -931,7 +932,7 @@ BattleCommand_CheckObedience: ; 343db
.RandomMove:
call BattleRandom
- and 3 ; TODO NUM_MOVES
+ maskbits NUM_MOVES +- 1
cp b
jr nc, .RandomMove
@@ -947,7 +948,7 @@ BattleCommand_CheckObedience: ; 343db
ld d, 0
add hl, de
ld a, [hl]
- and $3f
+ and PP_MASK
jr z, .RandomMove
@@ -1118,7 +1119,7 @@ BattleCommand_DoTurn: ; 34555
ld b, 0
add hl, bc
ld a, [hl]
- and $3f
+ and PP_MASK
jr z, .out_of_pp
dec [hl]
ld b, 0
@@ -3906,7 +3907,7 @@ BattleCommand_Encore: ; 35864
ld bc, BattleMonPP - BattleMonMoves - 1
add hl, bc
ld a, [hl]
- and $3f
+ and PP_MASK
jp z, .failed
ld a, [AttackMissed]
and a
@@ -4386,7 +4387,7 @@ BattleCommand_SleepTalk: ; 35b33
.sample_move
push hl
call BattleRandom
- and 3 ; TODO factor in NUM_MOVES
+ maskbits NUM_MOVES +- 1
ld c, a
ld b, 0
add hl, bc
@@ -4550,17 +4551,18 @@ BattleCommand_Spite: ; 35c0f
add hl, bc
pop bc
ld a, [hl]
- and $3f
+ and PP_MASK
jr z, .failed
push bc
call GetMoveName
+ ; lose 2-5 PP
call BattleRandom
- and 3
+ and %11
inc a
inc a
ld b, a
ld a, [hl]
- and $3f
+ and PP_MASK
cp b
jr nc, .deplete_pp
ld b, a
@@ -6208,13 +6210,12 @@ BattleCommand_TriStatusChance: ; 3658f
call BattleCommand_EffectChance
-; 1/3 chance of each status
.loop
+ ; 1/3 chance of each status
call BattleRandom
swap a
- and 3
+ and %11
jr z, .loop
-; jump
dec a
ld hl, .ptrs
rst JumpTable
@@ -7392,7 +7393,8 @@ BattleCommand_TrapTarget: ; 36c2d
bit SUBSTATUS_SUBSTITUTE, a
ret nz
call BattleRandom
- and 3
+ ; trapped for 2-5 turns
+ and %11
inc a
inc a
inc a
@@ -7590,8 +7592,9 @@ BattleCommand_FinishConfusingTarget: ; 36d70
.got_confuse_count
set SUBSTATUS_CONFUSED, [hl]
+ ; confused for 2-5 turns
call BattleRandom
- and 3
+ and %11
inc a
inc a
ld [bc], a
@@ -8201,7 +8204,7 @@ BattleCommand_Conversion: ; 3707f
.done
.loop3
call BattleRandom
- and 3 ; TODO factor in NUM_MOVES
+ maskbits NUM_MOVES +- 1
ld c, a
ld b, 0
ld hl, StringBuffer1