summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2013-08-09 17:42:04 -0400
committeryenatch <yenatch@gmail.com>2013-08-09 17:50:34 -0400
commit14160a180f8a898d2c282155e32a3c907083cba0 (patch)
tree05d8623ba46daf59f310688c84dbd70e939ce2e0
parent94e9a3f7649b95eff276d8a42b820b74bad5c199 (diff)
hidden power type/power calculation
-rw-r--r--battle/effect_commands.asm6
-rw-r--r--battle/hidden_power.asm108
-rw-r--r--main.asm6
3 files changed, 114 insertions, 6 deletions
diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm
index f52dfa483..afe822a16 100644
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -10623,11 +10623,7 @@ BattleCommand6d: ; 37be8
ld a, [AttackMissed]
and a
ret nz
-
- ld a, $3e
- ld hl, $7ced
- rst FarCall
-
+ callba GetHiddenPower
ret
; 37bf4
diff --git a/battle/hidden_power.asm b/battle/hidden_power.asm
new file mode 100644
index 000000000..995acea2d
--- /dev/null
+++ b/battle/hidden_power.asm
@@ -0,0 +1,108 @@
+GetHiddenPower: ; fbced
+; Override Hidden Power's type and power based on the actor's DVs.
+
+ ld hl, BattleMonDVs
+ ld a, [hBattleTurn]
+ and a
+ jr z, .GotDVs
+ ld hl, EnemyMonDVs
+.GotDVs
+
+
+; Power:
+
+; Take the top bit from...
+
+; Atk
+ ld a, [hl]
+ swap a
+ and 8
+ ld b, a
+; Def
+ ld a, [hli]
+ and 8
+ srl a
+ or b
+ ld b, a
+; Spd
+ ld a, [hl]
+ swap a
+ and 8
+ srl a
+ srl a
+ or b
+ ld b, a
+; Spc
+ ld a, [hl]
+ and 8
+ srl a
+ srl a
+ srl a
+ or b
+ ld b, a
+
+; * 5
+ add a
+ add a
+ add b
+ ld b, a
+
+; + (Spc & 3)
+ ld a, [hld]
+ and 3
+ add b
+
+; / 2
+ srl a
+
+; + 30
+ add 30
+; + 1
+ inc a
+ ld d, a
+
+
+; Type:
+
+; Def & 3
+ ld a, [hl]
+ and 3
+ ld b, a
+
+; + (Atk & 3) << 2
+ ld a, [hl]
+ and 3 << 4
+ swap a
+ add a
+ add a
+ or b
+
+; Skip Normal
+ inc a
+
+; Skip type 6 (unused)
+ cp 6
+ jr c, .GotType
+ inc a
+
+; Skip unused types between Steel and Fire
+ cp STEEL + 1
+ jr c, .GotType
+ add FIRE - (STEEL + 1)
+
+
+.GotType
+ push af
+ ld a, BATTLE_VARS_MOVE_TYPE
+ call GetBattleVarPair
+ pop af
+ ld [hl], a
+
+ ld a, d
+ push af
+ callba BattleCommand06
+ pop af
+ ld d, a
+ ret
+; fbd54
+
diff --git a/main.asm b/main.asm
index 786b9f19b..9ce03109a 100644
--- a/main.asm
+++ b/main.asm
@@ -66168,7 +66168,11 @@ INCBIN "baserom.gbc", $fba2e, $fbbfc - $fba2e
INCLUDE "battle/magikarp_length.asm"
-INCBIN "baserom.gbc", $fbccf, $fbda4 - $fbccf
+INCBIN "baserom.gbc", $fbccf, $fbced - $fbccf
+
+INCLUDE "battle/hidden_power.asm"
+
+INCBIN "baserom.gbc", $fbd54, $fbda4 - $fbd54
DoWeatherModifiers: ; fbda4