Merge github.com:pikalaxalt/pokecrystal

This commit is contained in:
PikalaxALT
2016-07-21 07:58:36 -04:00
302 changed files with 10504 additions and 10455 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -13,13 +13,13 @@ Music_Evolution_Ch1: ; f06ed
dutycycle $2 dutycycle $2
notetype $c, $92 notetype $c, $92
octave 3 octave 3
unknownmusic0xe0 $0, 4, A_ slidepitchto 0, 4, A_
note C_, 1 note C_, 1
unknownmusic0xe0 $0, 4, A_ slidepitchto 0, 4, A_
note G_, 1 note G_, 1
unknownmusic0xe0 $0, 4, A_ slidepitchto 0, 4, A_
note C_, 1 note C_, 1
unknownmusic0xe0 $0, 4, A_ slidepitchto 0, 4, A_
note G_, 1 note G_, 1
note __, 4 note __, 4
dutycycle $3 dutycycle $3

View File

@@ -275,9 +275,8 @@ Music_GoldenrodCity_Ch3: ; eb584
vibrato $8, $23 vibrato $8, $23
notetype $c, $25 notetype $c, $25
Music_GoldenrodCity_branch_eb58c: ; eb58c Music_GoldenrodCity_branch_eb58c: ; eb58c
rept 2
callchannel Music_GoldenrodCity_branch_eb5aa callchannel Music_GoldenrodCity_branch_eb5aa
endr callchannel Music_GoldenrodCity_branch_eb5aa
callchannel Music_GoldenrodCity_branch_eb5d2 callchannel Music_GoldenrodCity_branch_eb5d2
note __, 3 note __, 3
octave 3 octave 3

View File

@@ -11,16 +11,16 @@ Music_HealPokemon_Ch1: ; f06a0
tone $0001 tone $0001
notetype $c, $81 notetype $c, $81
note __, 2 note __, 2
unknownmusic0xe0 $0, 4, __ slidepitchto 0, 4, __
note B_, 2 note B_, 2
unknownmusic0xe0 $0, 5, E_ slidepitchto 0, 5, E_
note B_, 2 note B_, 2
unknownmusic0xe0 $0, 4, E_ slidepitchto 0, 4, E_
note E_, 2 note E_, 2
note __, 4 note __, 4
unknownmusic0xe0 $0, 3, __ slidepitchto 0, 3, __
note E_, 4 note E_, 4
unknownmusic0xe0 $0, 4, __ slidepitchto 0, 4, __
note B_, 4 note B_, 4
endchannel endchannel
; f06c4 ; f06c4

View File

@@ -492,9 +492,8 @@ Music_JohtoWildBattle_branch_f5fdb: ; f5fdb
note G_, 2 note G_, 2
loopchannel 7, Music_JohtoWildBattle_branch_f5fdb loopchannel 7, Music_JohtoWildBattle_branch_f5fdb
note F#, 4 note F#, 4
rept 2
callchannel Music_JohtoWildBattle_branch_f6055 callchannel Music_JohtoWildBattle_branch_f6055
endr callchannel Music_JohtoWildBattle_branch_f6055
Music_JohtoWildBattle_branch_f5fe8: ; f5fe8 Music_JohtoWildBattle_branch_f5fe8: ; f5fe8
note D_, 2 note D_, 2
note G_, 2 note G_, 2

View File

@@ -325,25 +325,21 @@ Music_KantoWildBattle_branch_ed1c8: ; ed1c8
note F_, 1 note F_, 1
note F#, 1 note F#, 1
notetype $6, $b7 notetype $6, $b7
rept 2
callchannel Music_KantoWildBattle_branch_ed307 callchannel Music_KantoWildBattle_branch_ed307
endr callchannel Music_KantoWildBattle_branch_ed307
forceoctave $1 forceoctave $1
rept 2
callchannel Music_KantoWildBattle_branch_ed307 callchannel Music_KantoWildBattle_branch_ed307
endr callchannel Music_KantoWildBattle_branch_ed307
forceoctave $0 forceoctave $0
rept 4 rept 4
callchannel Music_KantoWildBattle_branch_ed307 callchannel Music_KantoWildBattle_branch_ed307
endr endr
forceoctave $1 forceoctave $1
rept 2
callchannel Music_KantoWildBattle_branch_ed307 callchannel Music_KantoWildBattle_branch_ed307
endr callchannel Music_KantoWildBattle_branch_ed307
forceoctave $0 forceoctave $0
rept 2
callchannel Music_KantoWildBattle_branch_ed307 callchannel Music_KantoWildBattle_branch_ed307
endr callchannel Music_KantoWildBattle_branch_ed307
note __, 16 note __, 16
octave 3 octave 3
note A#, 16 note A#, 16

View File

@@ -2322,7 +2322,7 @@ Sfx_Aeroblast: ; f1334
; f133a ; f133a
Sfx_Aeroblast_Ch5: ; f133a Sfx_Aeroblast_Ch5: ; f133a
unknownmusic0xde $f2 sound_duty 2, 0, 3, 3
soundinput $f5 soundinput $f5
sound C_, 13, $f8, $0580 sound C_, 13, $f8, $0580
soundinput $8 soundinput $8
@@ -4762,7 +4762,7 @@ Sfx_Supersonic_branch_f21ef: ; f21ef
; f21fc ; f21fc
Sfx_Supersonic_Ch6: ; f21fc Sfx_Supersonic_Ch6: ; f21fc
unknownmusic0xde $b3 sound_duty 3, 0, 3, 2
sound __, 16, $2f, $07c8 sound __, 16, $2f, $07c8
Sfx_Supersonic_branch_f2202: ; f2202 Sfx_Supersonic_branch_f2202: ; f2202
sound __, 16, $cf, $07c7 sound __, 16, $cf, $07c7
@@ -4790,7 +4790,7 @@ Sfx_Leer_branch_f221a: ; f221a
Sfx_Leer_Ch6: ; f2229 Sfx_Leer_Ch6: ; f2229
Sfx_Leer_branch_f2229: ; f2229 Sfx_Leer_branch_f2229: ; f2229
unknownmusic0xde $b3 sound_duty 3, 0, 3, 2
sound __, 1, $e1, $07c1 sound __, 1, $e1, $07c1
sound __, 1, $e1, $0701 sound __, 1, $e1, $0701
loopchannel 12, Sfx_Leer_branch_f2229 loopchannel 12, Sfx_Leer_branch_f2229
@@ -4807,7 +4807,7 @@ Sfx_Leer_branch_f2238: ; f2238
Sfx_Ember_Ch5: ; f2243 Sfx_Ember_Ch5: ; f2243
Sfx_Ember_branch_f2243: ; f2243 Sfx_Ember_branch_f2243: ; f2243
unknownmusic0xde $c9 sound_duty 1, 2, 0, 3
sound __, 12, $f3, $0120 sound __, 12, $f3, $0120
sound __, 10, $d3, $0150 sound __, 10, $d3, $0150
loopchannel 5, Sfx_Ember_branch_f2243 loopchannel 5, Sfx_Ember_branch_f2243
@@ -4829,7 +4829,7 @@ Sfx_Ember_branch_f225a: ; f225a
Sfx_Bubblebeam_Ch5: ; f226e Sfx_Bubblebeam_Ch5: ; f226e
Sfx_Bubblebeam_branch_f226e: ; f226e Sfx_Bubblebeam_branch_f226e: ; f226e
unknownmusic0xde $39 sound_duty 1, 2, 3, 0
sound __, 5, $f4, $0600 sound __, 5, $f4, $0600
sound __, 4, $c4, $0500 sound __, 4, $c4, $0500
sound __, 6, $b5, $0600 sound __, 6, $b5, $0600
@@ -4841,7 +4841,7 @@ Sfx_Bubblebeam_branch_f226e: ; f226e
Sfx_Bubblebeam_Ch6: ; f2289 Sfx_Bubblebeam_Ch6: ; f2289
Sfx_Bubblebeam_branch_f2289: ; f2289 Sfx_Bubblebeam_branch_f2289: ; f2289
unknownmusic0xde $8d sound_duty 1, 3, 0, 2
sound __, 6, $e4, $05e0 sound __, 6, $e4, $05e0
sound __, 5, $b4, $04e0 sound __, 5, $b4, $04e0
sound __, 7, $a5, $05e8 sound __, 7, $a5, $05e8
@@ -4862,7 +4862,7 @@ Sfx_Bubblebeam_branch_f22a0: ; f22a0
Sfx_HydroPump_Ch5: ; f22b1 Sfx_HydroPump_Ch5: ; f22b1
Sfx_HydroPump_branch_f22b1: ; f22b1 Sfx_HydroPump_branch_f22b1: ; f22b1
unknownmusic0xde $d2 sound_duty 2, 0, 1, 3
sound __, 4, $81, $0300 sound __, 4, $81, $0300
sound __, 4, $c1, $0400 sound __, 4, $c1, $0400
sound __, 4, $f1, $0500 sound __, 4, $f1, $0500
@@ -4887,7 +4887,7 @@ Sfx_HydroPump_branch_f22d0: ; f22d0
Sfx_Surf_Ch5: ; f22e7 Sfx_Surf_Ch5: ; f22e7
Sfx_Surf_branch_f22e7: ; f22e7 Sfx_Surf_branch_f22e7: ; f22e7
unknownmusic0xde $39 sound_duty 1, 2, 3, 0
sound __, 16, $f4, $0500 sound __, 16, $f4, $0500
sound __, 16, $c4, $0400 sound __, 16, $c4, $0400
sound __, 16, $e2, $05c0 sound __, 16, $e2, $05c0
@@ -4897,7 +4897,7 @@ Sfx_Surf_branch_f22e7: ; f22e7
Sfx_Surf_Ch6: ; f22fa Sfx_Surf_Ch6: ; f22fa
Sfx_Surf_branch_f22fa: ; f22fa Sfx_Surf_branch_f22fa: ; f22fa
unknownmusic0xde $8d sound_duty 1, 3, 0, 2
sound __, 8, $e4, $0430 sound __, 8, $e4, $0430
sound __, 16, $b4, $0330 sound __, 16, $b4, $0330
sound __, 16, $a2, $0438 sound __, 16, $a2, $0438
@@ -4917,7 +4917,7 @@ Sfx_Surf_branch_f230d: ; f230d
Sfx_Psybeam_Ch5: ; f231e Sfx_Psybeam_Ch5: ; f231e
Sfx_Psybeam_branch_f231e: ; f231e Sfx_Psybeam_branch_f231e: ; f231e
unknownmusic0xde $a1 sound_duty 1, 0, 2, 2
sound __, 11, $f1, $0640 sound __, 11, $f1, $0640
sound __, 11, $f3, $0680 sound __, 11, $f3, $0680
sound __, 11, $f2, $0620 sound __, 11, $f2, $0620
@@ -4928,7 +4928,7 @@ Sfx_Psybeam_branch_f231e: ; f231e
Sfx_Psybeam_Ch6: ; f2335 Sfx_Psybeam_Ch6: ; f2335
Sfx_Psybeam_branch_f2335: ; f2335 Sfx_Psybeam_branch_f2335: ; f2335
unknownmusic0xde $b3 sound_duty 3, 0, 3, 2
sound __, 11, $f3, $0571 sound __, 11, $f3, $0571
sound __, 8, $e3, $0531 sound __, 8, $e3, $0531
sound __, 11, $f1, $0551 sound __, 11, $f1, $0551
@@ -4958,7 +4958,7 @@ Sfx_Charge_branch_f2357: ; f2357
Sfx_Charge_Ch6: ; f236e Sfx_Charge_Ch6: ; f236e
Sfx_Charge_branch_f236e: ; f236e Sfx_Charge_branch_f236e: ; f236e
unknownmusic0xde $b3 sound_duty 3, 0, 3, 2
sound __, 3, $e1, $0302 sound __, 3, $e1, $0302
sound __, 4, $e1, $07f2 sound __, 4, $e1, $07f2
sound __, 5, $e1, $0602 sound __, 5, $e1, $0602
@@ -4979,7 +4979,7 @@ Sfx_Charge_branch_f2385: ; f2385
Sfx_Thundershock_Ch5: ; f2396 Sfx_Thundershock_Ch5: ; f2396
Sfx_Thundershock_branch_f2396: ; f2396 Sfx_Thundershock_branch_f2396: ; f2396
unknownmusic0xde $2b sound_duty 3, 2, 2, 0
sound __, 4, $f1, $07f0 sound __, 4, $f1, $07f0
sound __, 5, $f2, $0200 sound __, 5, $f2, $0200
loopchannel 8, Sfx_Thundershock_branch_f2396 loopchannel 8, Sfx_Thundershock_branch_f2396
@@ -4988,7 +4988,7 @@ Sfx_Thundershock_branch_f2396: ; f2396
Sfx_Thundershock_Ch6: ; f23a5 Sfx_Thundershock_Ch6: ; f23a5
Sfx_Thundershock_branch_f23a5: ; f23a5 Sfx_Thundershock_branch_f23a5: ; f23a5
unknownmusic0xde $b3 sound_duty 3, 0, 3, 2
sound __, 5, $e2, $0202 sound __, 5, $e2, $0202
sound __, 5, $e1, $07e2 sound __, 5, $e1, $07e2
loopchannel 9, Sfx_Thundershock_branch_f23a5 loopchannel 9, Sfx_Thundershock_branch_f23a5
@@ -5092,7 +5092,7 @@ Sfx_Sharpen_Ch6: ; f2463
; f247a ; f247a
Sfx_EggBomb_Ch5: ; f247a Sfx_EggBomb_Ch5: ; f247a
unknownmusic0xde $ed sound_duty 1, 3, 2, 3
sound __, 9, $ff, $03f8 sound __, 9, $ff, $03f8
sound __, 16, $ff, $0400 sound __, 16, $ff, $0400
sound __, 16, $f3, $0400 sound __, 16, $f3, $0400
@@ -5100,7 +5100,7 @@ Sfx_EggBomb_Ch5: ; f247a
; f2489 ; f2489
Sfx_EggBomb_Ch6: ; f2489 Sfx_EggBomb_Ch6: ; f2489
unknownmusic0xde $b4 sound_duty 0, 1, 3, 2
sound __, 9, $ef, $03c0 sound __, 9, $ef, $03c0
sound __, 16, $ef, $03c0 sound __, 16, $ef, $03c0
sound __, 16, $e3, $03c0 sound __, 16, $e3, $03c0
@@ -5168,7 +5168,7 @@ Sfx_HyperBeam_branch_f24f8: ; f24f8
; f2509 ; f2509
Sfx_HyperBeam_Ch6: ; f2509 Sfx_HyperBeam_Ch6: ; f2509
unknownmusic0xde $b3 sound_duty 3, 0, 3, 2
sound __, 3, $f1, $0781 sound __, 3, $f1, $0781
sound __, 3, $f1, $0701 sound __, 3, $f1, $0701
sound __, 3, $f1, $0791 sound __, 3, $f1, $0791

View File

@@ -196,9 +196,9 @@ AI_TryItem: ; 38105
jr z, .has_item jr z, .has_item
dec de dec de
rept 3
inc hl inc hl
endr inc hl
inc hl
jr .loop jr .loop
.has_item .has_item
@@ -216,9 +216,8 @@ endr
pop de pop de
pop hl pop hl
rept 2
inc hl inc hl
endr inc hl
jr c, .loop jr c, .loop
.used_item .used_item
@@ -572,20 +571,20 @@ EnemyUsedFullHeal: ; 383a3 (e:43a3)
EnemyUsedMaxPotion: ; 383ae (e:43ae) EnemyUsedMaxPotion: ; 383ae (e:43ae)
ld a, MAX_POTION ld a, MAX_POTION
ld [wd1f1], a ld [CurEnemyItem], a
jr FullRestoreContinue jr FullRestoreContinue
EnemyUsedFullRestore: ; 383b5 (e:43b5) EnemyUsedFullRestore: ; 383b5 (e:43b5)
call AI_HealStatus call AI_HealStatus
ld a, FULL_RESTORE ld a, FULL_RESTORE
ld [wd1f1], a ld [CurEnemyItem], a
ld hl, EnemySubStatus3 ld hl, EnemySubStatus3
res SUBSTATUS_CONFUSED, [hl] res SUBSTATUS_CONFUSED, [hl]
xor a xor a
ld [EnemyConfuseCount], a ld [EnemyConfuseCount], a
FullRestoreContinue: ; 383c6 FullRestoreContinue: ; 383c6
ld de, wd1ec ld de, wCurHPAnimOldHP
ld hl, EnemyMonHP + 1 ld hl, EnemyMonHP + 1
ld a, [hld] ld a, [hld]
ld [de], a ld [de], a
@@ -597,11 +596,11 @@ FullRestoreContinue: ; 383c6
ld a, [hld] ld a, [hld]
ld [de], a ld [de], a
inc de inc de
ld [Buffer1], a ld [wCurHPAnimMaxHP], a
ld [EnemyMonHP + 1], a ld [EnemyMonHP + 1], a
ld a, [hl] ld a, [hl]
ld [de], a ld [de], a
ld [Buffer2], a ld [wCurHPAnimMaxHP + 1], a
ld [EnemyMonHP], a ld [EnemyMonHP], a
jr EnemyPotionFinish jr EnemyPotionFinish
; 383e8 (e:43e8) ; 383e8 (e:43e8)
@@ -621,20 +620,20 @@ EnemyUsedHyperPotion: ; 383f4 (e:43f4)
ld b, 200 ld b, 200
EnemyPotionContinue: ; 383f8 EnemyPotionContinue: ; 383f8
ld [wd1f1], a ld [CurEnemyItem], a
ld hl, EnemyMonHP + 1 ld hl, EnemyMonHP + 1
ld a, [hl] ld a, [hl]
ld [wd1ec], a ld [wCurHPAnimOldHP], a
add b add b
ld [hld], a ld [hld], a
ld [wd1ee], a ld [wCurHPAnimNewHP], a
ld a, [hl] ld a, [hl]
ld [wd1ec + 1], a ld [wCurHPAnimOldHP + 1], a
ld [wd1ee + 1], a ld [wCurHPAnimNewHP + 1], a
jr nc, .ok jr nc, .ok
inc a inc a
ld [hl], a ld [hl], a
ld [wd1ee + 1], a ld [wCurHPAnimNewHP + 1], a
.ok .ok
inc hl inc hl
ld a, [hld] ld a, [hld]
@@ -642,22 +641,22 @@ EnemyPotionContinue: ; 383f8
ld de, EnemyMonMaxHP + 1 ld de, EnemyMonMaxHP + 1
ld a, [de] ld a, [de]
dec de dec de
ld [Buffer1], a ld [wCurHPAnimMaxHP], a
sub b sub b
ld a, [hli] ld a, [hli]
ld b, a ld b, a
ld a, [de] ld a, [de]
ld [Buffer2], a ld [wCurHPAnimMaxHP + 1], a
sbc b sbc b
jr nc, EnemyPotionFinish jr nc, EnemyPotionFinish
inc de inc de
ld a, [de] ld a, [de]
dec de dec de
ld [hld], a ld [hld], a
ld [wd1ee], a ld [wCurHPAnimNewHP], a
ld a, [de] ld a, [de]
ld [hl], a ld [hl], a
ld [wd1ef], a ld [wCurHPAnimNewHP + 1], a
EnemyPotionFinish: ; 38436 EnemyPotionFinish: ; 38436
call PrintText_UsedItemOn call PrintText_UsedItemOn
@@ -844,7 +843,7 @@ EnemyUsedXSpecial: ; 38553
; a = ITEM_CONSTANT ; a = ITEM_CONSTANT
; b = BATTLE_CONSTANT (ATTACK, DEFENSE, SPEED, SP_ATTACK, SP_DEFENSE, ACCURACY, EVASION) ; b = BATTLE_CONSTANT (ATTACK, DEFENSE, SPEED, SP_ATTACK, SP_DEFENSE, ACCURACY, EVASION)
EnemyUsedXItem: EnemyUsedXItem:
ld [wd1f1], a ld [CurEnemyItem], a
push bc push bc
call PrintText_UsedItemOn call PrintText_UsedItemOn
pop bc pop bc
@@ -856,13 +855,13 @@ EnemyUsedXItem:
; Parameter ; Parameter
; a = ITEM_CONSTANT ; a = ITEM_CONSTANT
PrintText_UsedItemOn_AND_AIUpdateHUD: ; 38568 PrintText_UsedItemOn_AND_AIUpdateHUD: ; 38568
ld [wd1f1], a ld [CurEnemyItem], a
call PrintText_UsedItemOn call PrintText_UsedItemOn
jp AIUpdateHUD jp AIUpdateHUD
; 38571 ; 38571
PrintText_UsedItemOn: ; 38571 PrintText_UsedItemOn: ; 38571
ld a, [wd1f1] ld a, [CurEnemyItem]
ld [wd265], a ld [wd265], a
call GetItemName call GetItemName
ld hl, StringBuffer1 ld hl, StringBuffer1

View File

@@ -19,9 +19,9 @@ AIChooseMove: ; 440ce
; The default score is 20. Unusable moves are given a score of 80. ; The default score is 20. Unusable moves are given a score of 80.
ld a, 20 ld a, 20
ld hl, Buffer1 ld hl, Buffer1
rept 3
ld [hli], a ld [hli], a
endr ld [hli], a
ld [hli], a
ld [hl], a ld [hl], a
; Don't pick disabled moves. ; Don't pick disabled moves.
@@ -107,9 +107,8 @@ endr
ld hl, AIScoringPointers ld hl, AIScoringPointers
dec c dec c
ld b, 0 ld b, 0
rept 2
add hl, bc add hl, bc
endr add hl, bc
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a

File diff suppressed because it is too large Load Diff

View File

@@ -136,9 +136,11 @@ CheckPlayerMoveTypeMatchups: ; 3484e
jr c, .loop2 jr c, .loop2
; neutral ; neutral
rept 5
inc c inc c
endr inc c
inc c
inc c
inc c
cp 10 cp 10
jr z, .loop2 jr z, .loop2
@@ -161,11 +163,6 @@ endr
.doubledown .doubledown
call .DecreaseScore call .DecreaseScore
; fallthrough
; 34931
.DecreaseScore: ; 34931 .DecreaseScore: ; 34931
ld a, [wEnemyAISwitchScore] ld a, [wEnemyAISwitchScore]
dec a dec a
@@ -173,7 +170,6 @@ endr
ret ret
; 34939 ; 34939
.IncreaseScore: ; 34939 .IncreaseScore: ; 34939
ld a, [wEnemyAISwitchScore] ld a, [wEnemyAISwitchScore]
inc a inc a
@@ -198,16 +194,16 @@ CheckAbleToSwitch: ; 34941
; Perish count is 1 ; Perish count is 1
call FindAliveEnemyMons call FindAliveEnemyMons
call FindEnemyMonsWithEnoughHP call FindEnemyMonsWithAtLeastQuarterMaxHP
call FindEnemyMonsThatResistPlayer call FindEnemyMonsThatResistPlayer
call Function34a85 call FindAliveEnemyMonsWithASuperEffectiveMove
ld a, e ld a, e
cp 2 cp 2
jr nz, .not_2 jr nz, .not_2
ld a, [wEnemyAISwitchScore] ld a, [wEnemyAISwitchScore]
add $30 add $30 ; maximum chance
ld [wEnemySwitchMonParam], a ld [wEnemySwitchMonParam], a
ret ret
@@ -223,12 +219,11 @@ CheckAbleToSwitch: ; 34941
jr nc, .loop1 jr nc, .loop1
ld a, b ld a, b
add $30 add $30 ; maximum chance
ld [wEnemySwitchMonParam], a ld [wEnemySwitchMonParam], a
ret ret
.no_perish .no_perish
call CheckPlayerMoveTypeMatchups call CheckPlayerMoveTypeMatchups
ld a, [wEnemyAISwitchScore] ld a, [wEnemyAISwitchScore]
cp 11 cp 11
@@ -238,13 +233,13 @@ CheckAbleToSwitch: ; 34941
and a and a
jr z, .no_last_counter_move jr z, .no_last_counter_move
call Function34a2a call FindEnemyMonsImmuneToLastCounterMove
ld a, [wEnemyAISwitchScore] ld a, [wEnemyAISwitchScore]
and a and a
jr z, .no_last_counter_move jr z, .no_last_counter_move
ld c, a ld c, a
call Function34aa7 call FindEnemyMonsWithASuperEffectiveMove
ld a, [wEnemyAISwitchScore] ld a, [wEnemyAISwitchScore]
cp $ff cp $ff
ret z ret z
@@ -285,9 +280,9 @@ CheckAbleToSwitch: ; 34941
ret nc ret nc
call FindAliveEnemyMons call FindAliveEnemyMons
call FindEnemyMonsWithEnoughHP call FindEnemyMonsWithAtLeastQuarterMaxHP
call FindEnemyMonsThatResistPlayer call FindEnemyMonsThatResistPlayer
call Function34a85 call FindAliveEnemyMonsWithASuperEffectiveMove
ld a, e ld a, e
cp $2 cp $2
@@ -352,7 +347,7 @@ FindAliveEnemyMons: ; 349f4
; 34a2a ; 34a2a
Function34a2a: ; 34a2a FindEnemyMonsImmuneToLastCounterMove: ; 34a2a
ld hl, OTPartyMon1 ld hl, OTPartyMon1
ld a, [OTPartyCount] ld a, [OTPartyCount]
ld b, a ld b, a
@@ -361,44 +356,50 @@ Function34a2a: ; 34a2a
xor a xor a
ld [wEnemyAISwitchScore], a ld [wEnemyAISwitchScore], a
.asm_34a39 .loop
ld a, [CurOTMon] ld a, [CurOTMon]
cp d cp d
push hl push hl
jr z, .asm_34a77 jr z, .next
push hl push hl
push bc push bc
; If the Pokemon has at least 1 HP...
ld bc, MON_HP ld bc, MON_HP
add hl, bc add hl, bc
pop bc pop bc
ld a, [hli] ld a, [hli]
or [hl] or [hl]
pop hl pop hl
jr z, .asm_34a77 jr z, .next
ld a, [hl] ld a, [hl]
ld [CurSpecies], a ld [CurSpecies], a
call GetBaseData call GetBaseData
; the enemy's last move is damaging...
ld a, [LastEnemyCounterMove] ld a, [LastEnemyCounterMove]
dec a dec a
ld hl, Moves + MOVE_POWER ld hl, Moves + MOVE_POWER
call GetMoveAttr call GetMoveAttr
and a and a
jr z, .asm_34a77 jr z, .next
; and the Pokemon is immune to it...
inc hl inc hl
call GetMoveByte call GetMoveByte
ld hl, BaseType ld hl, BaseType
call CheckTypeMatchup call CheckTypeMatchup
ld a, [wTypeMatchup] ld a, [wTypeMatchup]
and a and a
jr nz, .asm_34a77 jr nz, .next
; ... encourage that Pokemon.
ld a, [wEnemyAISwitchScore] ld a, [wEnemyAISwitchScore]
or c or c
ld [wEnemyAISwitchScore], a ld [wEnemyAISwitchScore], a
.asm_34a77 .next
pop hl pop hl
dec b dec b
ret z ret z
@@ -410,11 +411,11 @@ Function34a2a: ; 34a2a
inc d inc d
srl c srl c
jr .asm_34a39 jr .loop
; 34a85 ; 34a85
Function34a85: ; 34a85 FindAliveEnemyMonsWithASuperEffectiveMove: ; 34a85
push bc push bc
ld a, [OTPartyCount] ld a, [OTPartyCount]
ld e, a ld e, a
@@ -444,13 +445,9 @@ Function34a85: ; 34a85
and c and c
ld c, a ld c, a
FindEnemyMonsWithASuperEffectiveMove: ; 34aa7
; fallthrough ld a, -1
; 34aa7
Function34aa7: ; 34aa7
ld a, $ff
ld [wEnemyAISwitchScore], a ld [wEnemyAISwitchScore], a
ld hl, OTPartyMon1Moves ld hl, OTPartyMon1Moves
ld b, 1 << (PARTY_LENGTH - 1) ld b, 1 << (PARTY_LENGTH - 1)
@@ -463,32 +460,40 @@ Function34aa7: ; 34aa7
push hl push hl
push bc push bc
; for move on mon:
ld b, NUM_MOVES ld b, NUM_MOVES
ld c, 0 ld c, 0
.loop3 .loop3
; if move is None: break
ld a, [hli] ld a, [hli]
and a and a
push hl push hl
jr z, .break3 jr z, .break3
; if move has no power: continue
dec a dec a
ld hl, Moves + MOVE_POWER ld hl, Moves + MOVE_POWER
call GetMoveAttr call GetMoveAttr
and a and a
jr z, .nope jr z, .nope
; check type matchups
inc hl inc hl
call GetMoveByte call GetMoveByte
ld hl, BattleMonType1 ld hl, BattleMonType1
call CheckTypeMatchup call CheckTypeMatchup
; if immune or not very effective: continue
ld a, [wTypeMatchup] ld a, [wTypeMatchup]
cp 10 cp 10
jr c, .nope jr c, .nope
; if neutral: load 1 and continue
ld e, 1 ld e, 1
cp 10 + 1 cp 10 + 1
jr c, .nope jr c, .nope
; if super-effective: load 2 and break
ld e, 2 ld e, 2
jr .break3 jr .break3
@@ -505,18 +510,19 @@ Function34aa7: ; 34aa7
ld a, e ld a, e
pop bc pop bc
pop hl pop hl
cp $2 cp 2
jr z, .done2 jr z, .done2 ; at least one move is super-effective
cp 1
cp $1 jr nz, .next ; no move does more than half damage
jr nz, .next
; encourage this pokemon
ld a, d ld a, d
or b or b
ld d, a ld d, a
jr .next jr .next ; such a long jump
.next .next
; next pokemon?
push bc push bc
ld bc, PARTYMON_STRUCT_LENGTH ld bc, PARTYMON_STRUCT_LENGTH
add hl, bc add hl, bc
@@ -524,12 +530,14 @@ Function34aa7: ; 34aa7
srl b srl b
jr nc, .loop jr nc, .loop
; if no pokemon has a super-effective move: return
ld a, d ld a, d
ld b, a ld b, a
and a and a
ret z ret z
.done2 .done2
; convert the bit flag to an int and return
push bc push bc
sla b sla b
sla b sla b
@@ -608,7 +616,7 @@ FindEnemyMonsThatResistPlayer: ; 34b20
; 34b77 ; 34b77
FindEnemyMonsWithEnoughHP: ; 34b77 FindEnemyMonsWithAtLeastQuarterMaxHP: ; 34b77
push bc push bc
ld de, OTPartySpecies ld de, OTPartySpecies
ld b, 1 << (PARTY_LENGTH - 1) ld b, 1 << (PARTY_LENGTH - 1)
@@ -626,17 +634,15 @@ FindEnemyMonsWithEnoughHP: ; 34b77
ld b, [hl] ld b, [hl]
inc hl inc hl
ld c, [hl] ld c, [hl]
rept 2
inc hl inc hl
endr inc hl
; hl = MaxHP + 1 ; hl = MaxHP + 1
; b = (4 * b) % $100 + (c & 3) ; bc = [CurHP] * 4
; c = c / 4
srl c srl c
rl b rl b
srl c srl c
rl b rl b
; a = (MaxHP / $100) - b - (1 if c > (MaxHP % $100) else 0) ; if bc >= [hl], encourage
ld a, [hld] ld a, [hld]
cp c cp c
ld a, [hl] ld a, [hl]

View File

@@ -108,7 +108,7 @@ RunBattleAnimScript: ; cc163
call RunBattleAnimCommand call RunBattleAnimCommand
call _ExecuteBGEffects call _ExecuteBGEffects
call BattleAnim_UpdateOAM_All call BattleAnim_UpdateOAM_All
call Function3b0c call PushLYOverrides
call BattleAnimRequestPals call BattleAnimRequestPals
; Speed up Rollout's animation. ; Speed up Rollout's animation.
@@ -265,9 +265,9 @@ BattleAnim_ClearCGB_OAMFlags: ; cc23d
ld a, [hl] ld a, [hl]
and $f0 and $f0
ld [hli], a ld [hli], a
rept 3
inc hl inc hl
endr inc hl
inc hl
dec c dec c
jr nz, .loop jr nz, .loop
ret ret
@@ -382,7 +382,7 @@ BattleAnimCommands:: ; cc2a4 (33:42a4)
dw BattleAnimCmd_EB ; dummy dw BattleAnimCmd_EB ; dummy
dw BattleAnimCmd_EC ; dummy dw BattleAnimCmd_EC ; dummy
dw BattleAnimCmd_ED ; dummy dw BattleAnimCmd_ED ; dummy
dw BattleAnimCmd_JumpAnd dw BattleAnimCmd_IfParamAnd
dw BattleAnimCmd_JumpUntil dw BattleAnimCmd_JumpUntil
dw BattleAnimCmd_BGEffect dw BattleAnimCmd_BGEffect
dw BattleAnimCmd_BGP dw BattleAnimCmd_BGP
@@ -392,10 +392,10 @@ BattleAnimCommands:: ; cc2a4 (33:42a4)
dw BattleAnimCmd_F5 dw BattleAnimCmd_F5
dw BattleAnimCmd_F6 dw BattleAnimCmd_F6
dw BattleAnimCmd_F7 dw BattleAnimCmd_F7
dw BattleAnimCmd_JumpIf dw BattleAnimCmd_IfParamEqual
dw BattleAnimCmd_SetVar dw BattleAnimCmd_SetVar
dw BattleAnimCmd_IncVar dw BattleAnimCmd_IncVar
dw BattleAnimCmd_JumpVar dw BattleAnimCmd_IfVarEqual
dw BattleAnimCmd_Jump dw BattleAnimCmd_Jump
dw BattleAnimCmd_Loop dw BattleAnimCmd_Loop
dw BattleAnimCmd_Call dw BattleAnimCmd_Call
@@ -535,7 +535,7 @@ BattleAnimCmd_IncVar: ; cc3ad (33:43ad)
inc [hl] inc [hl]
ret ret
BattleAnimCmd_JumpVar: ; cc3b2 (33:43b2) BattleAnimCmd_IfVarEqual: ; cc3b2 (33:43b2)
call GetBattleAnimByte call GetBattleAnimByte
ld hl, BattleAnimVar ld hl, BattleAnimVar
cp [hl] cp [hl]
@@ -563,7 +563,7 @@ BattleAnimCmd_JumpVar: ; cc3b2 (33:43b2)
ld [hl], d ld [hl], d
ret ret
BattleAnimCmd_JumpIf: ; cc3d6 (33:43d6) BattleAnimCmd_IfParamEqual: ; cc3d6 (33:43d6)
call GetBattleAnimByte call GetBattleAnimByte
ld hl, wBattleAnimParam ld hl, wBattleAnimParam
cp [hl] cp [hl]
@@ -591,7 +591,7 @@ BattleAnimCmd_JumpIf: ; cc3d6 (33:43d6)
ld [hl], d ld [hl], d
ret ret
BattleAnimCmd_JumpAnd: ; cc3fa (33:43fa) BattleAnimCmd_IfParamAnd: ; cc3fa (33:43fa)
call GetBattleAnimByte call GetBattleAnimByte
ld e, a ld e, a
ld a, [wBattleAnimParam] ld a, [wBattleAnimParam]
@@ -608,6 +608,7 @@ BattleAnimCmd_JumpAnd: ; cc3fa (33:43fa)
dec hl dec hl
ld [hl], e ld [hl], e
ret ret
.jump .jump
call GetBattleAnimByte call GetBattleAnimByte
ld e, a ld e, a

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1541,11 +1541,6 @@ BattleCheckTypeMatchup: ; 347c8
and a and a
jr z, CheckTypeMatchup jr z, CheckTypeMatchup
ld hl, BattleMonType1 ld hl, BattleMonType1
; fallthrough
; 347d3
CheckTypeMatchup: ; 347d3 CheckTypeMatchup: ; 347d3
push hl push hl
push de push de
@@ -2837,11 +2832,11 @@ PlayerAttackDamage: ; 352e2
call GetDamageStatsCritical call GetDamageStatsCritical
jr c, .thickclub jr c, .thickclub
ld hl, EnemyStats + 2 ld hl, EnemyDefense
ld a, [hli] ld a, [hli]
ld b, a ld b, a
ld c, [hl] ld c, [hl]
ld hl, PlayerStats ld hl, PlayerAttack
jr .thickclub jr .thickclub
.special .special
@@ -2861,11 +2856,11 @@ PlayerAttackDamage: ; 352e2
call GetDamageStatsCritical call GetDamageStatsCritical
jr c, .lightball jr c, .lightball
ld hl, EnemyStats + SP_DEFENSE * 2 ld hl, EnemySpDef
ld a, [hli] ld a, [hli]
ld b, a ld b, a
ld c, [hl] ld c, [hl]
ld hl, PlayerStats + SP_ATTACK * 2 ld hl, PlayerSpAtk
.lightball .lightball
; Note: Returns player special attack at hl in hl. ; Note: Returns player special attack at hl in hl.
@@ -3103,11 +3098,11 @@ EnemyAttackDamage: ; 353f6
call GetDamageStatsCritical call GetDamageStatsCritical
jr c, .thickclub jr c, .thickclub
ld hl, PlayerStats + 2 ld hl, PlayerDefense
ld a, [hli] ld a, [hli]
ld b, a ld b, a
ld c, [hl] ld c, [hl]
ld hl, EnemyStats ld hl, EnemyAttack
jr .thickclub jr .thickclub
.Special: .Special:
@@ -3126,11 +3121,11 @@ EnemyAttackDamage: ; 353f6
ld hl, EnemyMonSpclAtk ld hl, EnemyMonSpclAtk
call GetDamageStatsCritical call GetDamageStatsCritical
jr c, .lightball jr c, .lightball
ld hl, PlayerStats + 8 ld hl, PlayerSpDef
ld a, [hli] ld a, [hli]
ld b, a ld b, a
ld c, [hl] ld c, [hl]
ld hl, EnemyStats + 6 ld hl, EnemySpAtk
.lightball .lightball
call LightBallBoost call LightBallBoost
@@ -3407,9 +3402,9 @@ HitSelfInConfusion: ; 355dd
sla c sla c
rl b rl b
.mimic_screen .mimic_screen
rept 3
dec hl dec hl
endr dec hl
dec hl
ld a, [hli] ld a, [hli]
ld l, [hl] ld l, [hl]
ld h, a ld h, a
@@ -3953,9 +3948,9 @@ BattleCommand_Encore: ; 35864
set SUBSTATUS_ENCORED, [hl] set SUBSTATUS_ENCORED, [hl]
call BattleRandom call BattleRandom
and $3 and $3
rept 3
inc a inc a
endr inc a
inc a
ld [de], a ld [de], a
call CheckOpponentWentFirst call CheckOpponentWentFirst
jr nz, .finish_move jr nz, .finish_move
@@ -4094,12 +4089,12 @@ BattleCommand_PainSplit: ; 35926
ld a, [CurDamage + 1] ld a, [CurDamage + 1]
rr a rr a
ld [CurDamage + 1], a ld [CurDamage + 1], a
rept 3
inc hl inc hl
endr inc hl
rept 3 inc hl
inc de
inc de
inc de inc de
endr
.EnemyShareHP: ; 359ac .EnemyShareHP: ; 359ac
ld c, [hl] ld c, [hl]
@@ -7447,9 +7442,9 @@ BattleCommand_TrapTarget: ; 36c2d
ret nz ret nz
call BattleRandom call BattleRandom
and 3 and 3
rept 3
inc a inc a
endr inc a
inc a
ld [hl], a ld [hl], a
ld a, BATTLE_VARS_MOVE_ANIM ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar call GetBattleVar

View File

@@ -45,9 +45,8 @@ HiddenPowerDamage: ; fbced
; Multiply by 5 ; Multiply by 5
ld b, a ld b, a
rept 2
add a add a
endr add a
add b add b
; Add Special & 3 ; Add Special & 3
@@ -75,9 +74,8 @@ endr
ld a, [hl] ld a, [hl]
and 3 << 4 and 3 << 4
swap a swap a
rept 2
add a add a
endr add a
or b or b
; Skip Normal ; Skip Normal

162
battle/link_result.asm Executable file
View File

@@ -0,0 +1,162 @@
DetermineLinkBattleResult: ; 2b930
callba UpdateEnemyMonInParty
ld hl, PartyMon1HP
call .CountMonsRemaining
push bc
ld hl, OTPartyMon1HP
call .CountMonsRemaining
ld a, c
pop bc
cp c
jr z, .even_number_of_mons_remaining
jr c, .defeat
jr .victory
.even_number_of_mons_remaining
call .BothSides_CheckNumberMonsAtFullHealth
jr z, .drawn
ld a, e
cp $1
jr z, .victory
cp $2
jr z, .defeat
ld hl, PartyMon1HP
call .CalcPercentHPRemaining
push de
ld hl, OTPartyMon1HP
call .CalcPercentHPRemaining
pop hl
ld a, d
cp h
jr c, .victory
jr z, .compare_lo
jr .defeat
.compare_lo
ld a, e
cp l
jr z, .drawn
jr nc, .defeat
.victory
ld a, [wBattleResult]
and $f0
ld [wBattleResult], a
ret
.defeat
ld a, [wBattleResult]
and $f0
add $1
ld [wBattleResult], a
ret
.drawn
ld a, [wBattleResult]
and $f0
add $2
ld [wBattleResult], a
ret
.CountMonsRemaining: ; 2b995
ld c, 0
ld b, 3
ld de, PARTYMON_STRUCT_LENGTH - 1
.loop
ld a, [hli]
or [hl]
jr nz, .not_fainted
inc c
.not_fainted
add hl, de
dec b
jr nz, .loop
ret
.CalcPercentHPRemaining: ; 2b9a6
ld de, 0
ld c, $3
.loop2
ld a, [hli]
or [hl]
jr z, .next
dec hl
xor a
ld [hDividend + 0], a
ld a, [hli]
ld [hDividend + 1], a
ld a, [hli]
ld [hDividend + 2], a
xor a
ld [hDividend + 3], a
ld a, [hli]
ld b, a
ld a, [hld]
srl b
rr a
srl b
rr a
ld [hDivisor], a
ld b, $4
call Divide
ld a, [hQuotient + 2]
add e
ld e, a
ld a, [hQuotient + 1]
adc d
ld d, a
dec hl
.next
push de
ld de, $2f
add hl, de
pop de
dec c
jr nz, .loop2
ret
.BothSides_CheckNumberMonsAtFullHealth: ; 2b9e1
ld hl, PartyMon1HP
call .CheckFaintedOrFullHealth
jr nz, .finish ; we have a pokemon that's neither fainted nor at full health
ld hl, OTPartyMon1HP
call .CheckFaintedOrFullHealth
ld e, $1
ret
.finish
ld hl, OTPartyMon1HP
call .CheckFaintedOrFullHealth
ld e, $0
ret nz ; we both have pokemon that are neither fainted nor at full health
ld e, $2
ld a, $1
and a
ret
.CheckFaintedOrFullHealth: ; 2ba01
ld d, 3
.loop3
ld a, [hli]
ld b, a
ld a, [hli]
ld c, a
or b
jr z, .fainted_or_full_health
ld a, [hli]
cp b
ret nz
ld a, [hld]
cp c
ret nz
.fainted_or_full_health
push de
ld de, PARTYMON_STRUCT_LENGTH - 2
add hl, de
pop de
dec d
jr nz, .loop3
ret

View File

@@ -141,9 +141,8 @@ CalcMagikarpLength: ; fbbfc
; hl = de * 10 ; hl = de * 10
ld h, d ld h, d
ld l, e ld l, e
rept 2
add hl, hl add hl, hl
endr add hl, hl
add hl, de add hl, de
add hl, hl add hl, hl

Some files were not shown because too many files have changed in this diff Show More