shithub: pokecrystal

Download patch

ref: a10ee4e9f1ee3d671b67e2e68531b1f851661000
parent: bfaad924e7f0ebad59da85830211b9b0c8d2afa8
author: yenatch <[email protected]>
date: Mon Dec 30 18:32:37 EST 2013

comment move priority functions

--- a/battle/core.asm
+++ b/battle/core.asm
@@ -475,7 +475,7 @@
 	ld a, [$d0ec]
 	and a
 	jp nz, .asm_3c3f1
-	call Function3c5b4
+	call CompareMovePriority
 	jr z, .asm_3c36d
 	jp c, .asm_3c3f1
 	jp Function3c3f3
@@ -848,7 +848,10 @@
 ; 3c5b4
 
 
-Function3c5b4: ; 3c5b4
+CompareMovePriority: ; 3c5b4
+; Compare the priority of the player and enemy's moves.
+; Return carry if the player goes first, or z if they match.
+
 	ld a, [CurPlayerMove]
 	call GetMovePriority
 	ld b, a
@@ -861,28 +864,34 @@
 ; 3c5c5
 
 GetMovePriority: ; 3c5c5
+; Return the priority (0-3) of move a.
+
 	ld b, a
+
+	; Vital throw goes last.
 	cp VITAL_THROW
 	ld a, 0
 	ret z
-	call Function3c5ec
-	ld hl, .data_3c5df
+
+	call GetMoveEffect
+	ld hl, MoveEffectPriorities
 .loop
 	ld a, [hli]
 	cp b
-	jr z, .asm_3c5dd
+	jr z, .done
 	inc hl
-	cp $ff
+	cp -1
 	jr nz, .loop
+
 	ld a, 1
 	ret
 
-.asm_3c5dd
+.done
 	ld a, [hl]
 	ret
 ; 3c5df
 
-.data_3c5df
+MoveEffectPriorities: ; 3c5df
 	db EFFECT_PROTECT,      3
 	db EFFECT_ENDURE,       3
 	db EFFECT_PRIORITY_HIT, 2
@@ -889,11 +898,11 @@
 	db EFFECT_WHIRLWIND,    0
 	db EFFECT_COUNTER,      0
 	db EFFECT_MIRROR_COAT,  0
-	db $ff
+	db -1
 ; 3c5ec
 
 
-Function3c5ec: ; 3c5ec
+GetMoveEffect: ; 3c5ec
 	ld a, b
 	dec a
 	ld hl, Moves + MOVE_EFFECT
@@ -905,6 +914,7 @@
 	ret
 ; 3c5fe
 
+
 Function3c5fe: ; 3c5fe
 	call Function309d
 	call Function3c543
@@ -4282,7 +4292,7 @@
 	ld a, $10
 	call GetBattleVar
 	ld b, a
-	call Function3c5ec
+	call GetMoveEffect
 	ld a, b
 	cp $80
 	jr nz, .asm_3dce4
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -4469,7 +4469,7 @@
 	ret z
 	ld b, a
 
-	callab Function3c5ec
+	callab GetMoveEffect
 
 	ld a, b
 	cp $59
@@ -5095,7 +5095,7 @@
 	push bc
 
 	ld b, a
-	callab Function3c5ec
+	callab GetMoveEffect
 	ld a, b
 
 	pop bc
@@ -10181,7 +10181,7 @@
 	and a
 	ret z
 	ld b, a
-	callab Function3c5ec
+	callab GetMoveEffect
 	ld a, b
 	cp $90
 	ret z