Merge pull request #224 from yenatch/moves

Clean up the battle core and specify type categories
This commit is contained in:
Bryan Bishop
2014-01-27 06:51:01 -08:00
20 changed files with 1167 additions and 1072 deletions

View File

@@ -162,7 +162,7 @@ AIScoring_RedSuperEffective: ; 38635
push de push de
ld a, 1 ld a, 1
ld [hBattleTurn], a ld [hBattleTurn], a
callab Function0x347c8 callab Function347c8
pop de pop de
pop bc pop bc
pop hl pop hl
@@ -412,7 +412,7 @@ AIScoring_LeechHit: ; 387f7
push hl push hl
ld a, 1 ld a, 1
ld [hBattleTurn], a ld [hBattleTurn], a
callab Function0x347c8 callab Function347c8
pop hl pop hl
ld a, [$d265] ld a, [$d265]
@@ -559,7 +559,7 @@ AIScoring_LockOn: ; 3881d
AIScoring_Explosion: ; 388a6 AIScoring_Explosion: ; 388a6
push hl push hl
callba Function0x349f4 callba Function349f4
pop hl pop hl
jr nc, .asm_388b7 jr nc, .asm_388b7
@@ -904,7 +904,7 @@ AIScoring_Bide: ; 38a1e
AIScoring_Whirlwind: ; 38a2a AIScoring_Whirlwind: ; 38a2a
push hl push hl
callab Function0x3484e callab Function3484e
ld a, [$c716] ld a, [$c716]
cp $a cp $a
pop hl pop hl
@@ -1760,7 +1760,7 @@ AIScoring_MeanLook: ; 38dfb
jr nz, .asm_38e26 jr nz, .asm_38e26
push hl push hl
callab Function0x3484e callab Function3484e
ld a, [$c716] ld a, [$c716]
cp $b cp $b
pop hl pop hl
@@ -1874,7 +1874,7 @@ AIScoring_Curse: ; 38e5c
jp nz, AIDiscourageMove jp nz, AIDiscourageMove
push hl push hl
callba Function0x349f4 callba Function349f4
pop hl pop hl
jr nc, .asm_38eb0 jr nc, .asm_38eb0
@@ -2003,7 +2003,7 @@ AIScoring_Foresight: ; 38f1d
AIScoring_PerishSong: ; 38f4a AIScoring_PerishSong: ; 38f4a
push hl push hl
callab Function0x349f4 callab Function349f4
pop hl pop hl
jr c, .asm_38f75 jr c, .asm_38f75
@@ -2012,7 +2012,7 @@ AIScoring_PerishSong: ; 38f4a
jr nz, .asm_38f6f jr nz, .asm_38f6f
push hl push hl
callab Function0x3484e callab Function3484e
ld a, [$c716] ld a, [$c716]
cp 10 ; 1.0 cp 10 ; 1.0
pop hl pop hl
@@ -2242,7 +2242,7 @@ AIScoring_Earthquake: ; 39044
AIScoring_BatonPass: ; 39062 AIScoring_BatonPass: ; 39062
push hl push hl
callab Function0x3484e callab Function3484e
ld a, [$c716] ld a, [$c716]
cp 10 ; 1.0 cp 10 ; 1.0
pop hl pop hl
@@ -2299,7 +2299,7 @@ AIScoring_HiddenPower: ; 3909e
ld hl, $7ced ld hl, $7ced
ld a, $3e ld a, $3e
rst FarCall rst FarCall
callab Function0x347c8 callab Function347c8
pop hl pop hl
ld a, [$d265] ld a, [$d265]
@@ -3223,7 +3223,7 @@ AIScoring_StatusImmunity: ; 39453
push de push de
ld a, 1 ld a, 1
ld [hBattleTurn], a ld [hBattleTurn], a
callab Function0x347c8 callab Function347c8
pop de pop de
pop bc pop bc
pop hl pop hl

View File

@@ -1430,7 +1430,7 @@ Functioncc8d3: ; cc8d3
ld e, [hl] ld e, [hl]
inc hl inc hl
ld d, [hl] ld d, [hl]
ld hl, $506f ld hl, BattleAnimations
add hl, de add hl, de
add hl, de add hl, de
call Function3ae1 call Function3ae1

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -41,9 +41,9 @@ BattleCommand54: ; 37588
ld a, $1 ld a, $1
ld [$c689], a ld [$c689], a
call Function0x37e01 call AnimateCurrentMove
ld a, $2 ld a, $2
call Function0x36532 call Function36532
call SwitchTurn call SwitchTurn
call BattleCommand8d call BattleCommand8d
call ResetMiss call ResetMiss
@@ -71,17 +71,17 @@ BattleCommand54: ; 37588
jr nz, .failed jr nz, .failed
set 1, [hl] set 1, [hl]
call Function0x37e01 call AnimateCurrentMove
ld hl, GetHalfMaxHP ld hl, GetHalfMaxHP
call CallBankF call CallBattleCore
ld hl, Function3cc3f ld hl, Function3cc3f
call CallBankF call CallBattleCore
call UpdateUserInParty call UpdateUserInParty
ld hl, PutACurseText ld hl, PutACurseText
jp StdBattleTextBox jp StdBattleTextBox
.failed .failed
call Function0x37e77 call AnimateFailedMove
jp PrintButItFailed jp PrintButItFailed
@@ -91,7 +91,7 @@ BattleCommand54: ; 37588
ld b, $8 ; ABILITY ld b, $8 ; ABILITY
call GetStatName call GetStatName
call Function0x37e77 call AnimateFailedMove
ld hl, WontRiseAnymoreText ld hl, WontRiseAnymoreText
jp StdBattleTextBox jp StdBattleTextBox
; 37618 ; 37618

View File

@@ -10,7 +10,7 @@ BattleCommand5a: ; 3766f
call _GetBattleVar call _GetBattleVar
set SUBSTATUS_ENDURE, [hl] set SUBSTATUS_ENDURE, [hl]
call Function0x37e01 call AnimateCurrentMove
ld hl, BracedItselfText ld hl, BracedItselfText
jp StdBattleTextBox jp StdBattleTextBox

View File

@@ -14,11 +14,11 @@ BattleCommand57: ; 376a0
jr nz, .failed jr nz, .failed
set SUBSTATUS_IDENTIFIED, [hl] set SUBSTATUS_IDENTIFIED, [hl]
call Function0x37e01 call AnimateCurrentMove
ld hl, IdentifiedText ld hl, IdentifiedText
jp StdBattleTextBox jp StdBattleTextBox
.failed .failed
jp Function0x37354 jp Function37354
; 376c2 ; 376c2

View File

@@ -1,8 +1,8 @@
BattleCommand34: ; 37418 BattleCommand34: ; 37418
; metronome ; metronome
call Function0x372d8 call Function372d8
call Function0x34548 call Function34548
jr nz, .asm_3742b jr nz, .asm_3742b
ld a, [$c689] ld a, [$c689]
@@ -12,7 +12,7 @@ BattleCommand34: ; 37418
ld [$c689], a ld [$c689], a
.asm_3742b .asm_3742b
call Function0x37e36 call Function37e36
.GetMove .GetMove
call BattleRandom call BattleRandom

View File

@@ -1,7 +1,7 @@
BattleCommand1b: ; 373c9 BattleCommand1b: ; 373c9
; mirrormove ; mirrormove
call Function0x372d8 call Function372d8
ld a, BATTLE_VARS_MOVE ld a, BATTLE_VARS_MOVE
call _GetBattleVar call _GetBattleVar
@@ -15,7 +15,7 @@ BattleCommand1b: ; 373c9
jr nz, .use jr nz, .use
.failed .failed
call Function0x37e77 call AnimateFailedMove
ld hl, MirrorMoveFailedText ld hl, MirrorMoveFailedText
call StdBattleTextBox call StdBattleTextBox
@@ -37,7 +37,7 @@ BattleCommand1b: ; 373c9
call GetMoveData call GetMoveData
call GetMoveName call GetMoveName
call CopyName1 call CopyName1
call Function0x34548 call Function34548
jr nz, .done jr nz, .done
ld a, [$c689] ld a, [$c689]

View File

@@ -28,12 +28,12 @@ BattleCommand52: ; 37536
; Otherwise give the opponent a nightmare. ; Otherwise give the opponent a nightmare.
set SUBSTATUS_NIGHTMARE, [hl] set SUBSTATUS_NIGHTMARE, [hl]
call Function0x37e01 call AnimateCurrentMove
ld hl, StartedNightmareText ld hl, StartedNightmareText
jp StdBattleTextBox jp StdBattleTextBox
.failed .failed
call Function0x37e77 call AnimateFailedMove
jp PrintButItFailed jp PrintButItFailed
; 37563 ; 37563

View File

@@ -30,12 +30,12 @@ BattleCommand58: ; 376c2
ld [EnemyPerishCount], a ld [EnemyPerishCount], a
.done .done
call Function0x37e01 call AnimateCurrentMove
ld hl, StartPerishText ld hl, StartPerishText
jp StdBattleTextBox jp StdBattleTextBox
.failed .failed
call Function0x37e77 call AnimateFailedMove
jp PrintButItFailed jp PrintButItFailed
; 376f8 ; 376f8

View File

@@ -7,7 +7,7 @@ BattleCommand55: ; 37618
call _GetBattleVar call _GetBattleVar
set SUBSTATUS_PROTECT, [hl] set SUBSTATUS_PROTECT, [hl]
call Function0x37e01 call AnimateCurrentMove
ld hl, ProtectedItselfText ld hl, ProtectedItselfText
jp StdBattleTextBox jp StdBattleTextBox
@@ -23,7 +23,7 @@ ProtectChance: ; 3762c
ld de, EnemyProtectCount ld de, EnemyProtectCount
.asm_37637 .asm_37637
call Function0x36abf call Function36abf
jr nz, .failed jr nz, .failed
; Can't have a substitute. ; Can't have a substitute.
@@ -73,7 +73,7 @@ ProtectChance: ; 3762c
.failed .failed
xor a xor a
ld [de], a ld [de], a
call Function0x37e77 call AnimateFailedMove
call PrintButItFailed call PrintButItFailed
scf scf
ret ret

View File

@@ -9,12 +9,12 @@ BattleCommand59: ; 376f8
ld [Weather], a ld [Weather], a
ld a, 5 ld a, 5
ld [WeatherCount], a ld [WeatherCount], a
call Function0x37e01 call AnimateCurrentMove
ld hl, SandstormBrewedText ld hl, SandstormBrewedText
jp StdBattleTextBox jp StdBattleTextBox
.failed .failed
call Function0x37e77 call AnimateFailedMove
jp PrintButItFailed jp PrintButItFailed
; 37718 ; 37718

View File

@@ -17,12 +17,12 @@ BattleCommand56: ; 37683
set SCREENS_SPIKES, [hl] set SCREENS_SPIKES, [hl]
call Function0x37e01 call AnimateCurrentMove
ld hl, SpikesText ld hl, SpikesText
jp StdBattleTextBox jp StdBattleTextBox
.failed .failed
jp Function0x37354 jp Function37354
; 376a0 ; 376a0

View File

@@ -1,75 +1,76 @@
GetHiddenPower: ; fbced HiddenPowerDamage: ; fbced
; Override Hidden Power's type and power based on the actor's DVs. ; Override Hidden Power's type and power based on the user's DVs.
ld hl, BattleMonDVs ld hl, BattleMonDVs
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .GotDVs jr z, .got_dvs
ld hl, EnemyMonDVs ld hl, EnemyMonDVs
.GotDVs .got_dvs
; Power: ; Power:
; Take the top bit from... ; Take the top bit from each stat
; Atk ; Attack
ld a, [hl] ld a, [hl]
swap a swap a
and 8 and 8
; Defense
ld b, a ld b, a
; Def
ld a, [hli] ld a, [hli]
and 8 and 8
srl a srl a
or b or b
; Speed
ld b, a ld b, a
; Spd
ld a, [hl] ld a, [hl]
swap a swap a
and 8 and 8
srl a srl a
srl a srl a
or b or b
; Special
ld b, a ld b, a
; Spc
ld a, [hl] ld a, [hl]
and 8 and 8
srl a srl a
srl a srl a
srl a srl a
or b or b
ld b, a
; * 5 ; Multiply by 5
ld b, a
add a add a
add a add a
add b add b
ld b, a
; + (Spc & 3) ; Add Special & 3
ld b, a
ld a, [hld] ld a, [hld]
and 3 and 3
add b add b
; / 2 ; Divide by 2 and add 30 + 1
srl a srl a
; + 30
add 30 add 30
; + 1
inc a inc a
ld d, a ld d, a
; Type: ; Type:
; Def & 3 ; Def & 3
ld a, [hl] ld a, [hl]
and 3 and 3
ld b, a ld b, a
; + (Atk & 3) << 2 ; + (Atk & 3) << 2
ld a, [hl] ld a, [hl]
and 3 << 4 and 3 << 4
swap a swap a
@@ -80,27 +81,30 @@ GetHiddenPower: ; fbced
; Skip Normal ; Skip Normal
inc a inc a
; Skip type 6 (unused) ; Skip Bird
cp 6 cp BIRD
jr c, .GotType jr c, .done
inc a inc a
; Skip unused types between Steel and Fire ; Skip unused types
cp STEEL + 1 cp UNUSED_TYPES
jr c, .GotType jr c, .done
add FIRE - (STEEL + 1) add SPECIAL - UNUSED_TYPES
.done
.GotType ; Overwrite the current move type.
push af push af
ld a, BATTLE_VARS_MOVE_TYPE ld a, BATTLE_VARS_MOVE_TYPE
call _GetBattleVar call _GetBattleVar
pop af pop af
ld [hl], a ld [hl], a
; Get the rest of the damage formula variables
; based on the new type, but keep base power.
ld a, d ld a, d
push af push af
callba BattleCommand06 callba BattleCommand06 ; damagestats
pop af pop af
ld d, a ld d, a
ret ret

View File

@@ -12,6 +12,7 @@ INCLUDE "hram.asm"
INCLUDE "constants/wram_constants.asm" INCLUDE "constants/wram_constants.asm"
INCLUDE "constants/pokemon_constants.asm" INCLUDE "constants/pokemon_constants.asm"
INCLUDE "constants/type_constants.asm"
INCLUDE "constants/move_constants.asm" INCLUDE "constants/move_constants.asm"
INCLUDE "constants/battle_constants.asm" INCLUDE "constants/battle_constants.asm"
INCLUDE "constants/map_constants.asm" INCLUDE "constants/map_constants.asm"
@@ -31,25 +32,6 @@ INCLUDE "constants/gfx_constants.asm"
NONE EQU 0 NONE EQU 0
; types
NORMAL EQU $00
FIGHTING EQU $01
FLYING EQU $02
POISON EQU $03
GROUND EQU $04
ROCK EQU $05
BUG EQU $07
GHOST EQU $08
STEEL EQU $09
CURSE_T EQU $13
FIRE EQU $14
WATER EQU $15
GRASS EQU $16
ELECTRIC EQU $17
PSYCHIC EQU $18
ICE EQU $19
DRAGON EQU $1A
DARK EQU $1B
; egg group constants ; egg group constants
MONSTER EQU $01 MONSTER EQU $01

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,39 @@
const_def
PHYSICAL EQU const_value
const NORMAL
const FIGHTING
const FLYING
const POISON
const GROUND
const ROCK
const BIRD
const BUG
const GHOST
const STEEL
UNUSED_TYPES EQU const_value
const TYPE_10
const TYPE_11
const TYPE_12
const TYPE_13
const TYPE_14
const TYPE_15
const TYPE_16
const TYPE_17
const TYPE_18
const CURSE_T
SPECIAL EQU const_value
const FIRE
const WATER
const GRASS
const ELECTRIC
const PSYCHIC
const ICE
const DRAGON
const DARK

View File

@@ -1542,7 +1542,7 @@ Functionf030: ; f030 (3:7030)
res 7, [hl] res 7, [hl]
.asm_f04f .asm_f04f
push bc push bc
callba Function0x365d7 callba Function365d7
pop bc pop bc
ret ret
@@ -2343,7 +2343,7 @@ XSpecial: ; f4c5
ld [hBattleTurn], a ld [hBattleTurn], a
ld [AttackMissed], a ld [AttackMissed], a
ld [$c70d], a ld [$c70d], a
callba Function0x361ef callba Function361ef
call WaitSFX call WaitSFX
callba BattleCommand8c callba BattleCommand8c

View File

@@ -5271,10 +5271,10 @@ Function6520: ; 6520
push hl push hl
push de push de
dec a dec a
ld hl, $5b00 ld hl, Moves + MOVE_PP
ld bc, $0007 ld bc, Move2 - Move1
call AddNTimes call AddNTimes
ld a, $10 ld a, BANK(Moves)
call GetFarByte call GetFarByte
pop de pop de
pop hl pop hl
@@ -7793,7 +7793,7 @@ PredefPointers: ; 856b
dwb Function5108b, BANK(Function5108b) dwb Function5108b, BANK(Function5108b)
dwb Function5120d, BANK(Function5120d) dwb Function5120d, BANK(Function5120d)
dwb DecompressPredef, BANK(DecompressPredef) ; $40 dwb DecompressPredef, BANK(DecompressPredef) ; $40
dwb Function0x347d3, BANK(Function0x347d3) dwb Function347d3, BANK(Function347d3)
dwb Functionfb908, BANK(Functionfb908) dwb Functionfb908, BANK(Functionfb908)
dwb Functionfb877, BANK(Functionfb877) dwb Functionfb877, BANK(Functionfb877)
dwb Functiond0000, BANK(Functiond0000) dwb Functiond0000, BANK(Functiond0000)
@@ -11050,7 +11050,7 @@ _CheckTossableItem: ; d427
ld a, 4 ld a, 4
call GetItemAttr call GetItemAttr
bit 7, a bit 7, a
jr nz, Function0xd47f jr nz, Functiond47f
and a and a
ret ret
; d432 ; d432
@@ -11060,7 +11060,7 @@ CheckSelectableItem: ; d432
ld a, 4 ld a, 4
call GetItemAttr call GetItemAttr
bit 6, a bit 6, a
jr nz, Function0xd47f jr nz, Functiond47f
and a and a
ret ret
; d43d ; d43d
@@ -11120,7 +11120,7 @@ GetItemAttr: ; d460
ret ret
; d47f ; d47f
Function0xd47f: ; d47f Functiond47f: ; d47f
ld a, 1 ld a, 1
ld [$d142], a ld [$d142], a
scf scf
@@ -35591,7 +35591,7 @@ INCBIN "baserom.gbc",$2c4d7,$2c4e3 - $2c4d7
cp $3 cp $3
jr z, .asm_2c541 jr z, .asm_2c541
jr Function2c545 jr Function2c545
callba Function0x377f5 callba Function377f5
jr c, .asm_2c541 jr c, .asm_2c541
ld a, [PlayerSubStatus1] ; $c668 ld a, [PlayerSubStatus1] ; $c668
bit 7, a bit 7, a
@@ -36789,7 +36789,7 @@ ClearBattleRAM: ; 2ef18
xor a xor a
call ByteFill call ByteFill
callab Function3d867 callab ResetEnemyStatLevels
call Function1fbf call Function1fbf
@@ -36913,7 +36913,7 @@ Function38041: ; 38041
; 38045 ; 38045
Function38045: ; 38045 Function38045: ; 38045
callab Function0x34941 callab Function34941
ld a, [$c717] ld a, [$c717]
and $f0 and $f0
jp z, Function38041 jp z, Function38041
@@ -36946,7 +36946,7 @@ Function38045: ; 38045
; 38083 ; 38083
Function38083: ; 38083 Function38083: ; 38083
callab Function0x34941 callab Function34941
ld a, [$c717] ld a, [$c717]
and $f0 and $f0
jp z, Function38041 jp z, Function38041
@@ -36979,7 +36979,7 @@ Function38083: ; 38083
; 380c1 ; 380c1
Function380c1: ; 380c1 Function380c1: ; 380c1
callab Function0x34941 callab Function34941
ld a, [$c717] ld a, [$c717]
and $f0 and $f0
jp z, Function38041 jp z, Function38041
@@ -37438,8 +37438,8 @@ Function3846c: ; 3846c
.asm_384a3 .asm_384a3
ld a, $1 ld a, $1
ld [$d264], a ld [$d264], a
callab Function3d834 callab NewEnemyMonStatus
callab Function3d867 callab ResetEnemyStatLevels
ld hl, PlayerSubStatus1 ld hl, PlayerSubStatus1
res 7, [hl] res 7, [hl]
callba Function3d4e1 callba Function3d4e1
@@ -37555,7 +37555,7 @@ Function38557
push bc push bc
call Function38571 call Function38571
pop bc pop bc
callba Function0x361ef callba Function361ef
jp Function38387 jp Function38387
; 38568 ; 38568
@@ -37807,10 +37807,10 @@ Function39806: ; 39806
push hl push hl
push bc push bc
dec a dec a
ld hl, $5b00 ld hl, Moves + MOVE_PP
ld bc, $0007 ld bc, Move2 - Move1
call AddNTimes call AddNTimes
ld a, $10 ld a, BANK(Moves)
call GetFarByte call GetFarByte
pop bc pop bc
pop hl pop hl
@@ -83077,11 +83077,11 @@ Function100bc2: ; 100bc2
ret ret
.asm_100c63 .asm_100c63
ld hl, $4c5b ld hl, BattleText_0x80c5b
jr .asm_100c6b jr .asm_100c6b
.asm_100c68 .asm_100c68
ld hl, $4c39 ld hl, BattleText_0x80c39
.asm_100c6b .asm_100c6b
call StdBattleTextBox call StdBattleTextBox
@@ -86704,7 +86704,7 @@ UsedMoveText: ; 105db9
; check actor ???? ; check actor ????
push hl push hl
callba Function0x34548 callba Function34548
pop hl pop hl
jr nz, .grammar jr nz, .grammar