diff options
author | xCrystal <rgr.crystal@gmail.com> | 2015-04-01 16:51:04 +0200 |
---|---|---|
committer | xCrystal <rgr.crystal@gmail.com> | 2015-04-01 17:05:50 +0200 |
commit | 2fe782b11a039b52fd236da28fb2f1ae10cae7db (patch) | |
tree | 580cc7bf8b0ebd617fd0ba0440618d38c355aa83 | |
parent | 77d0e5ff84cc61ae625da19f184094241eddd4dc (diff) |
Rename battle files and split move effects Part 4
e.asm, e_2. asm, and 14.asm
-rw-r--r-- | engine/battle/draw_hud_pokeball_gfx.asm | 191 | ||||
-rwxr-xr-x | engine/battle/e_2.asm | 301 | ||||
-rw-r--r-- | engine/battle/init_battle_variables.asm | 40 | ||||
-rw-r--r-- | engine/battle/moveEffects/heal_effect.asm | 116 | ||||
-rw-r--r--[-rwxr-xr-x] | engine/battle/moveEffects/paralyze_effect.asm (renamed from engine/battle/14.asm) | 41 | ||||
-rw-r--r-- | engine/battle/moveEffects/reflect_light_screen_effect.asm | 45 | ||||
-rw-r--r-- | engine/battle/moveEffects/transform_effect.asm | 138 | ||||
-rw-r--r-- | engine/battle/scroll_draw_trainer_pic.asm | 50 | ||||
-rw-r--r--[-rwxr-xr-x] | engine/battle/trainer_party_ai_misc.asm (renamed from engine/battle/e.asm) | 306 | ||||
-rw-r--r-- | engine/battle/unused_stats_functions.asm | 62 | ||||
-rwxr-xr-x | main.asm | 12 |
11 files changed, 651 insertions, 651 deletions
diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm new file mode 100644 index 00000000..fce3701c --- /dev/null +++ b/engine/battle/draw_hud_pokeball_gfx.asm @@ -0,0 +1,191 @@ +DrawAllPokeballs: ; 3a849 (e:6849) + call LoadPartyPokeballGfx + call SetupOwnPartyPokeballs + ld a, [W_ISINBATTLE] ; W_ISINBATTLE + dec a + ret z ; return if wild pokémon + jp SetupEnemyPartyPokeballs + +DrawEnemyPokeballs: ; 0x3a857 + call LoadPartyPokeballGfx + jp SetupEnemyPartyPokeballs + +LoadPartyPokeballGfx: ; 3a85d (e:685d) + ld de, PokeballTileGraphics ; $697e + ld hl, vSprites + $310 + ld bc, (BANK(PokeballTileGraphics) << 8) + $04 + jp CopyVideoData + +SetupOwnPartyPokeballs: ; 3a869 (e:6869) + call PlacePlayerHUDTiles + ld hl, wPartyMon1 + ld de, wPartyCount ; wPartyCount + call SetupPokeballs + ld a, $60 + ld hl, W_BASECOORDX ; wd081 + ld [hli], a + ld [hl], a + ld a, $8 + ld [wTrainerEngageDistance], a + ld hl, wOAMBuffer + jp WritePokeballOAMData + +SetupEnemyPartyPokeballs: ; 3a887 (e:6887) + call PlaceEnemyHUDTiles + ld hl, wEnemyMons + ld de, wEnemyPartyCount ; wEnemyPartyCount + call SetupPokeballs + ld hl, W_BASECOORDX ; wd081 + ld a, $48 + ld [hli], a + ld [hl], $20 + ld a, $f8 + ld [wTrainerEngageDistance], a + ld hl, wOAMBuffer + PARTY_LENGTH * 4 + jp WritePokeballOAMData + +SetupPokeballs: ; 0x3a8a6 + ld a, [de] + push af + ld de, wBuffer + ld c, PARTY_LENGTH + ld a, $34 ; empty pokeball +.emptyloop + ld [de], a + inc de + dec c + jr nz, .emptyloop + pop af + ld de, wBuffer +.monloop + push af + call PickPokeball + inc de + pop af + dec a + jr nz, .monloop + ret + +PickPokeball: ; 3a8c2 (e:68c2) + inc hl + ld a, [hli] + and a + jr nz, .alive + ld a, [hl] + and a + ld b, $33 ; crossed ball (fainted) + jr z, .done_fainted +.alive + inc hl + inc hl + ld a, [hl] ; status + and a + ld b, $32 ; black ball (status) + jr nz, .done + dec b ; regular ball + jr .done +.done_fainted + inc hl + inc hl +.done + ld a, b + ld [de], a + ld bc, $0028 ; rest of mon struct + add hl, bc + ret + +WritePokeballOAMData: ; 3a8e1 (e:68e1) + ld de, wBuffer + ld c, PARTY_LENGTH +.loop + ld a, [W_BASECOORDY] ; wd082 + ld [hli], a + ld a, [W_BASECOORDX] ; wd081 + ld [hli], a + ld a, [de] + ld [hli], a + xor a + ld [hli], a + ld a, [W_BASECOORDX] ; wd081 + ld b, a + ld a, [wTrainerEngageDistance] + add b + ld [W_BASECOORDX], a ; wd081 + inc de + dec c + jr nz, .loop + ret + +PlacePlayerHUDTiles: ; 3a902 (e:6902) + ld hl, PlayerBattleHUDGraphicsTiles ; $6916 + ld de, wTrainerFacingDirection + ld bc, $3 + call CopyData + hlCoord 18, 10 + ld de, rIE ; $ffff + jr PlaceHUDTiles + +PlayerBattleHUDGraphicsTiles: ; 3a916 (e:6916) +; The tile numbers for specific parts of the battle display for the player's pokemon + db $73 ; unused ($73 is hardcoded into the routine that uses these bytes) + db $77 ; lower-right corner tile of the HUD + db $6F ; lower-left triangle tile of the HUD + +PlaceEnemyHUDTiles: ; 3a919 (e:6919) + ld hl, EnemyBattleHUDGraphicsTiles ; $692d + ld de, wTrainerFacingDirection + ld bc, $3 + call CopyData + hlCoord 1, 2 + ld de, $1 + jr PlaceHUDTiles + +EnemyBattleHUDGraphicsTiles: ; 3a92d (e:692d) +; The tile numbers for specific parts of the battle display for the enemy + db $73 ; unused ($73 is hardcoded in the routine that uses these bytes) + db $74 ; lower-left corner tile of the HUD + db $78 ; lower-right triangle tile of the HUD + +PlaceHUDTiles: ; 3a930 (e:6930) + ld [hl], $73 + ld bc, $14 + add hl, bc + ld a, [wTrainerScreenY] + ld [hl], a + ld a, $8 +.asm_3a93c + add hl, de + ld [hl], $76 + dec a + jr nz, .asm_3a93c + add hl, de + ld a, [wTrainerScreenX] + ld [hl], a + ret + +SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948) + call LoadPartyPokeballGfx + ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) + ld de, wPartyCount ; wPartyCount + call SetupPokeballs + ld hl, W_BASECOORDX ; wd081 + ld a, $50 + ld [hli], a + ld [hl], $40 + ld a, $8 + ld [wTrainerEngageDistance], a + ld hl, wOAMBuffer + call WritePokeballOAMData + ld hl, wEnemyMons ; wEnemyMon1Species + ld de, wEnemyPartyCount ; wEnemyPartyCount + call SetupPokeballs + ld hl, W_BASECOORDX ; wd081 + ld a, $50 + ld [hli], a + ld [hl], $68 + ld hl, wOAMBuffer + $18 + jp WritePokeballOAMData + +; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (faited) and pokeball slot (no mon) +PokeballTileGraphics:: ; 3a97e (e:697e) + INCBIN "gfx/pokeball.2bpp" diff --git a/engine/battle/e_2.asm b/engine/battle/e_2.asm deleted file mode 100755 index 9400282d..00000000 --- a/engine/battle/e_2.asm +++ /dev/null @@ -1,301 +0,0 @@ -HealEffect_: ; 3b9ec (e:79ec) - ld a, [H_WHOSETURN] - and a - ld de, wBattleMonHP - ld hl, wBattleMonMaxHP - ld a, [W_PLAYERMOVENUM] - jr z, .asm_3ba03 - ld de, wEnemyMonHP - ld hl, wEnemyMonMaxHP - ld a, [W_ENEMYMOVENUM] -.asm_3ba03 - ld b, a - ld a, [de] - cp [hl] - inc de - inc hl - ld a, [de] - sbc [hl] - jp z, .failed - ld a, b - cp REST - jr nz, .asm_3ba37 - push hl - push de - push af - ld c, 50 - call DelayFrames - ld hl, wBattleMonStatus - ld a, [H_WHOSETURN] - and a - jr z, .asm_3ba25 - ld hl, wEnemyMonStatus -.asm_3ba25 - ld a, [hl] - and a - ld [hl], 2 ; Number of turns from Rest - ld hl, StartedSleepingEffect - jr z, .asm_3ba31 - ld hl, FellAsleepBecameHealthyText -.asm_3ba31 - call PrintText - pop af - pop de - pop hl -.asm_3ba37 - ld a, [hld] - ld [wHPBarMaxHP], a - ld c, a - ld a, [hl] - ld [wHPBarMaxHP+1], a - ld b, a - jr z, .asm_3ba47 - srl b - rr c -.asm_3ba47 - ld a, [de] - ld [wHPBarOldHP], a - add c - ld [de], a - ld [wHPBarNewHP], a - dec de - ld a, [de] - ld [wHPBarOldHP+1], a - adc b - ld [de], a - ld [wHPBarNewHP+1], a - inc hl - inc de - ld a, [de] - dec de - sub [hl] - dec hl - ld a, [de] - sbc [hl] - jr c, .asm_3ba6f - ld a, [hli] - ld [de], a - ld [wHPBarNewHP+1], a - inc de - ld a, [hl] - ld [de], a - ld [wHPBarNewHP], a -.asm_3ba6f - ld hl, PlayCurrentMoveAnimation - call BankswitchEtoF - ld a, [H_WHOSETURN] - and a - hlCoord 10, 9 - ld a, $1 - jr z, .asm_3ba83 - hlCoord 2, 2 - xor a -.asm_3ba83 - ld [wHPBarType], a - predef UpdateHPBar2 - ld hl, DrawHUDsAndHPBars - call BankswitchEtoF - ld hl, RegainedHealthText - jp PrintText -.failed - ld c, 50 - call DelayFrames - ld hl, PrintButItFailedText_ - jp BankswitchEtoF - -StartedSleepingEffect: ; 3baa2 (e:7aa2) - TX_FAR _StartedSleepingEffect - db "@" - -FellAsleepBecameHealthyText: ; 3baa7 (e:7aa7) - TX_FAR _FellAsleepBecameHealthyText - db "@" - -RegainedHealthText: ; 3baac (e:7aac) - TX_FAR _RegainedHealthText - db "@" - -TransformEffect_: ; 3bab1 (e:7ab1) - ld hl, wBattleMonSpecies - ld de, wEnemyMonSpecies - ld bc, W_ENEMYBATTSTATUS3 - ld a, [W_ENEMYBATTSTATUS1] - ld a, [H_WHOSETURN] - and a - jr nz, .asm_3bad1 - ld hl, wEnemyMonSpecies - ld de, wBattleMonSpecies - ld bc, W_PLAYERBATTSTATUS3 - ld [wPlayerMoveListIndex], a - ld a, [W_PLAYERBATTSTATUS1] -.asm_3bad1 - bit Invulnerable, a ; is mon invulnerable to typical attacks? (fly/dig) - jp nz, .failed - push hl - push de - push bc - ld hl, W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] - and a - jr z, .asm_3bae4 - ld hl, W_ENEMYBATTSTATUS2 -.asm_3bae4 - bit HasSubstituteUp, [hl] - push af - ld hl, Func_79747 - ld b, BANK(Func_79747) - call nz, Bankswitch - ld a, [W_OPTIONS] - add a - ld hl, PlayCurrentMoveAnimation - ld b, BANK(PlayCurrentMoveAnimation) - jr nc, .asm_3baff - ld hl, AnimationTransformMon - ld b, BANK(AnimationTransformMon) -.asm_3baff - call Bankswitch - ld hl, Func_79771 - ld b, BANK(Func_79771) - pop af - call nz, Bankswitch - pop bc - ld a, [bc] - set Transformed, a - ld [bc], a - pop de - pop hl - push hl - ld a, [hl] - ld [de], a - ld bc, $5 - add hl, bc - inc de - inc de - inc de - inc de - inc de - inc bc - inc bc - call CopyData - ld a, [H_WHOSETURN] - and a - jr z, .asm_3bb32 - ld a, [de] - ld [wcceb], a - inc de - ld a, [de] - ld [wccec], a - dec de -.asm_3bb32 - ld a, [hli] - ld [de], a - inc de - ld a, [hli] - ld [de], a - inc de - inc hl - inc hl - inc hl - inc de - inc de - inc de - ld bc, $8 - call CopyData - ld bc, $ffef - add hl, bc - ld b, $4 -.asm_3bb4a - ld a, [hli] - and a - jr z, .asm_3bb57 - ld a, $5 - ld [de], a - inc de - dec b - jr nz, .asm_3bb4a - jr .asm_3bb5d -.asm_3bb57 - xor a - ld [de], a - inc de - dec b - jr nz, .asm_3bb57 -.asm_3bb5d - pop hl - ld a, [hl] - ld [wd11e], a - call GetMonName - ld hl, wEnemyMonUnmodifiedAttack - ld de, wPlayerMonUnmodifiedAttack - call .copyBasedOnTurn - ld hl, wEnemyMonStatMods - ld de, wPlayerMonStatMods - call .copyBasedOnTurn - ld hl, TransformedText - jp PrintText - -.copyBasedOnTurn - ld a, [H_WHOSETURN] - and a - jr z, .asm_3bb86 - push hl - ld h, d - ld l, e - pop de -.asm_3bb86 - ld bc, $8 - jp CopyData - -.failed - ld hl, PrintButItFailedText_ - jp BankswitchEtoF - -TransformedText: ; 3bb92 (e:7b92) - TX_FAR _TransformedText - db "@" - -ReflectLightScreenEffect_: ; 3bb97 (e:7b97) - ld hl, W_PLAYERBATTSTATUS3 - ld de, W_PLAYERMOVEEFFECT - ld a, [H_WHOSETURN] - and a - jr z, .asm_3bba8 - ld hl, W_ENEMYBATTSTATUS3 - ld de, W_ENEMYMOVEEFFECT -.asm_3bba8 - ld a, [de] - cp LIGHT_SCREEN_EFFECT - jr nz, .reflect - bit HasLightScreenUp, [hl] ; is mon already protected by light screen? - jr nz, .moveFailed - set HasLightScreenUp, [hl] ; mon is now protected by light screen - ld hl, LightScreenProtectedText - jr .asm_3bbc1 -.reflect - bit HasReflectUp, [hl] ; is mon already protected by reflect? - jr nz, .moveFailed - set HasReflectUp, [hl] ; mon is now protected by reflect - ld hl, ReflectGainedArmorText -.asm_3bbc1 - push hl - ld hl, PlayCurrentMoveAnimation - call BankswitchEtoF - pop hl - jp PrintText -.moveFailed - ld c, $32 - call DelayFrames - ld hl, PrintButItFailedText_ - jp BankswitchEtoF - -LightScreenProtectedText: ; 3bbd7 (e:7bd7) - TX_FAR _LightScreenProtectedText - db "@" - -ReflectGainedArmorText: ; 3bbdc (e:7bdc) - TX_FAR _ReflectGainedArmorText - db "@" - -BankswitchEtoF: ; 3bbe1 (e:7be1) - ld b, BANK(BattleCore) - jp Bankswitch diff --git a/engine/battle/init_battle_variables.asm b/engine/battle/init_battle_variables.asm new file mode 100644 index 00000000..457cc4e1 --- /dev/null +++ b/engine/battle/init_battle_variables.asm @@ -0,0 +1,40 @@ +InitBattleVariables: ; 525af (14:65af) + ld a, [hTilesetType] + ld [wd0d4], a + xor a + ld [wcd6a], a + ld [wBattleResult], a + ld hl, wcc2b + ld [hli], a + ld [hli], a + ld [hli], a + ld [hl], a + ld [wListScrollOffset], a + ld [wCriticalHitOrOHKO], a + ld [wBattleMonSpecies], a + ld [wPartyGainExpFlags], a + ld [wPlayerMonNumber], a + ld [wEscapedFromBattle], a + ld [wMapPalOffset], a + ld hl, wcf1d + ld [hli], a + ld [hl], a + ld hl, wccd3 + ld b, $3c +.loop + ld [hli], a + dec b + jr nz, .loop + inc a + ld [wccd9], a + ld a, [W_CURMAP] + cp SAFARI_ZONE_EAST + jr c, .notSafariBattle + cp SAFARI_ZONE_REST_HOUSE_1 + jr nc, .notSafariBattle + ld a, $2 ; safari battle + ld [W_BATTLETYPE], a +.notSafariBattle + ld hl, PlayBattleMusic + ld b, BANK(PlayBattleMusic) + jp Bankswitch diff --git a/engine/battle/moveEffects/heal_effect.asm b/engine/battle/moveEffects/heal_effect.asm new file mode 100644 index 00000000..22d482e7 --- /dev/null +++ b/engine/battle/moveEffects/heal_effect.asm @@ -0,0 +1,116 @@ +HealEffect_: ; 3b9ec (e:79ec) + ld a, [H_WHOSETURN] + and a + ld de, wBattleMonHP + ld hl, wBattleMonMaxHP + ld a, [W_PLAYERMOVENUM] + jr z, .asm_3ba03 + ld de, wEnemyMonHP + ld hl, wEnemyMonMaxHP + ld a, [W_ENEMYMOVENUM] +.asm_3ba03 + ld b, a + ld a, [de] + cp [hl] + inc de + inc hl + ld a, [de] + sbc [hl] + jp z, .failed + ld a, b + cp REST + jr nz, .asm_3ba37 + push hl + push de + push af + ld c, 50 + call DelayFrames + ld hl, wBattleMonStatus + ld a, [H_WHOSETURN] + and a + jr z, .asm_3ba25 + ld hl, wEnemyMonStatus +.asm_3ba25 + ld a, [hl] + and a + ld [hl], 2 ; Number of turns from Rest + ld hl, StartedSleepingEffect + jr z, .asm_3ba31 + ld hl, FellAsleepBecameHealthyText +.asm_3ba31 + call PrintText + pop af + pop de + pop hl +.asm_3ba37 + ld a, [hld] + ld [wHPBarMaxHP], a + ld c, a + ld a, [hl] + ld [wHPBarMaxHP+1], a + ld b, a + jr z, .asm_3ba47 + srl b + rr c +.asm_3ba47 + ld a, [de] + ld [wHPBarOldHP], a + add c + ld [de], a + ld [wHPBarNewHP], a + dec de + ld a, [de] + ld [wHPBarOldHP+1], a + adc b + ld [de], a + ld [wHPBarNewHP+1], a + inc hl + inc de + ld a, [de] + dec de + sub [hl] + dec hl + ld a, [de] + sbc [hl] + jr c, .asm_3ba6f + ld a, [hli] + ld [de], a + ld [wHPBarNewHP+1], a + inc de + ld a, [hl] + ld [de], a + ld [wHPBarNewHP], a +.asm_3ba6f + ld hl, PlayCurrentMoveAnimation + call BankswitchEtoF + ld a, [H_WHOSETURN] + and a + hlCoord 10, 9 + ld a, $1 + jr z, .asm_3ba83 + hlCoord 2, 2 + xor a +.asm_3ba83 + ld [wHPBarType], a + predef UpdateHPBar2 + ld hl, DrawHUDsAndHPBars + call BankswitchEtoF + ld hl, RegainedHealthText + jp PrintText +.failed + ld c, 50 + call DelayFrames + ld hl, PrintButItFailedText_ + jp BankswitchEtoF + +StartedSleepingEffect: ; 3baa2 (e:7aa2) + TX_FAR _StartedSleepingEffect + db "@" + +FellAsleepBecameHealthyText: ; 3baa7 (e:7aa7) + TX_FAR _FellAsleepBecameHealthyText + db "@" + +RegainedHealthText: ; 3baac (e:7aac) + TX_FAR _RegainedHealthText + db "@" diff --git a/engine/battle/14.asm b/engine/battle/moveEffects/paralyze_effect.asm index 1b2d7462..69acbb01 100755..100644 --- a/engine/battle/14.asm +++ b/engine/battle/moveEffects/paralyze_effect.asm @@ -1,44 +1,3 @@ -InitBattleVariables: ; 525af (14:65af) - ld a, [hTilesetType] - ld [wd0d4], a - xor a - ld [wcd6a], a - ld [wBattleResult], a - ld hl, wcc2b - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a - ld [wListScrollOffset], a - ld [wCriticalHitOrOHKO], a - ld [wBattleMonSpecies], a - ld [wPartyGainExpFlags], a - ld [wPlayerMonNumber], a - ld [wEscapedFromBattle], a - ld [wMapPalOffset], a - ld hl, wcf1d - ld [hli], a - ld [hl], a - ld hl, wccd3 - ld b, $3c -.loop - ld [hli], a - dec b - jr nz, .loop - inc a - ld [wccd9], a - ld a, [W_CURMAP] - cp SAFARI_ZONE_EAST - jr c, .notSafariBattle - cp SAFARI_ZONE_REST_HOUSE_1 - jr nc, .notSafariBattle - ld a, $2 ; safari battle - ld [W_BATTLETYPE], a -.notSafariBattle - ld hl, PlayBattleMusic - ld b, BANK(PlayBattleMusic) - jp Bankswitch - ParalyzeEffect_: ; 52601 (14:6601) ld hl, wEnemyMonStatus ld de, W_PLAYERMOVETYPE diff --git a/engine/battle/moveEffects/reflect_light_screen_effect.asm b/engine/battle/moveEffects/reflect_light_screen_effect.asm new file mode 100644 index 00000000..39a2c154 --- /dev/null +++ b/engine/battle/moveEffects/reflect_light_screen_effect.asm @@ -0,0 +1,45 @@ +ReflectLightScreenEffect_: ; 3bb97 (e:7b97) + ld hl, W_PLAYERBATTSTATUS3 + ld de, W_PLAYERMOVEEFFECT + ld a, [H_WHOSETURN] + and a + jr z, .asm_3bba8 + ld hl, W_ENEMYBATTSTATUS3 + ld de, W_ENEMYMOVEEFFECT +.asm_3bba8 + ld a, [de] + cp LIGHT_SCREEN_EFFECT + jr nz, .reflect + bit HasLightScreenUp, [hl] ; is mon already protected by light screen? + jr nz, .moveFailed + set HasLightScreenUp, [hl] ; mon is now protected by light screen + ld hl, LightScreenProtectedText + jr .asm_3bbc1 +.reflect + bit HasReflectUp, [hl] ; is mon already protected by reflect? + jr nz, .moveFailed + set HasReflectUp, [hl] ; mon is now protected by reflect + ld hl, ReflectGainedArmorText +.asm_3bbc1 + push hl + ld hl, PlayCurrentMoveAnimation + call BankswitchEtoF + pop hl + jp PrintText +.moveFailed + ld c, $32 + call DelayFrames + ld hl, PrintButItFailedText_ + jp BankswitchEtoF + +LightScreenProtectedText: ; 3bbd7 (e:7bd7) + TX_FAR _LightScreenProtectedText + db "@" + +ReflectGainedArmorText: ; 3bbdc (e:7bdc) + TX_FAR _ReflectGainedArmorText + db "@" + +BankswitchEtoF: ; 3bbe1 (e:7be1) + ld b, BANK(BattleCore) + jp Bankswitch diff --git a/engine/battle/moveEffects/transform_effect.asm b/engine/battle/moveEffects/transform_effect.asm new file mode 100644 index 00000000..6e25712a --- /dev/null +++ b/engine/battle/moveEffects/transform_effect.asm @@ -0,0 +1,138 @@ +TransformEffect_: ; 3bab1 (e:7ab1) + ld hl, wBattleMonSpecies + ld de, wEnemyMonSpecies + ld bc, W_ENEMYBATTSTATUS3 + ld a, [W_ENEMYBATTSTATUS1] + ld a, [H_WHOSETURN] + and a + jr nz, .asm_3bad1 + ld hl, wEnemyMonSpecies + ld de, wBattleMonSpecies + ld bc, W_PLAYERBATTSTATUS3 + ld [wPlayerMoveListIndex], a + ld a, [W_PLAYERBATTSTATUS1] +.asm_3bad1 + bit Invulnerable, a ; is mon invulnerable to typical attacks? (fly/dig) + jp nz, .failed + push hl + push de + push bc + ld hl, W_PLAYERBATTSTATUS2 + ld a, [H_WHOSETURN] + and a + jr z, .asm_3bae4 + ld hl, W_ENEMYBATTSTATUS2 +.asm_3bae4 + bit HasSubstituteUp, [hl] + push af + ld hl, Func_79747 + ld b, BANK(Func_79747) + call nz, Bankswitch + ld a, [W_OPTIONS] + add a + ld hl, PlayCurrentMoveAnimation + ld b, BANK(PlayCurrentMoveAnimation) + jr nc, .asm_3baff + ld hl, AnimationTransformMon + ld b, BANK(AnimationTransformMon) +.asm_3baff + call Bankswitch + ld hl, Func_79771 + ld b, BANK(Func_79771) + pop af + call nz, Bankswitch + pop bc + ld a, [bc] + set Transformed, a + ld [bc], a + pop de + pop hl + push hl + ld a, [hl] + ld [de], a + ld bc, $5 + add hl, bc + inc de + inc de + inc de + inc de + inc de + inc bc + inc bc + call CopyData + ld a, [H_WHOSETURN] + and a + jr z, .asm_3bb32 + ld a, [de] + ld [wcceb], a + inc de + ld a, [de] + ld [wccec], a + dec de +.asm_3bb32 + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + inc de + inc hl + inc hl + inc hl + inc de + inc de + inc de + ld bc, $8 + call CopyData + ld bc, $ffef + add hl, bc + ld b, $4 +.asm_3bb4a + ld a, [hli] + and a + jr z, .asm_3bb57 + ld a, $5 + ld [de], a + inc de + dec b + jr nz, .asm_3bb4a + jr .asm_3bb5d +.asm_3bb57 + xor a + ld [de], a + inc de + dec b + jr nz, .asm_3bb57 +.asm_3bb5d + pop hl + ld a, [hl] + ld [wd11e], a + call GetMonName + ld hl, wEnemyMonUnmodifiedAttack + ld de, wPlayerMonUnmodifiedAttack + call .copyBasedOnTurn + ld hl, wEnemyMonStatMods + ld de, wPlayerMonStatMods + call .copyBasedOnTurn + ld hl, TransformedText + jp PrintText + +.copyBasedOnTurn + ld a, [H_WHOSETURN] + and a + jr z, .asm_3bb86 + push hl + ld h, d + ld l, e + pop de +.asm_3bb86 + ld bc, $8 + jp CopyData + +.failed + ld hl, PrintButItFailedText_ + jp BankswitchEtoF + +TransformedText: ; 3bb92 (e:7b92) + TX_FAR _TransformedText + db "@" diff --git a/engine/battle/scroll_draw_trainer_pic.asm b/engine/battle/scroll_draw_trainer_pic.asm new file mode 100644 index 00000000..18df86e0 --- /dev/null +++ b/engine/battle/scroll_draw_trainer_pic.asm @@ -0,0 +1,50 @@ +_ScrollTrainerPicAfterBattle: ; 396d3 (e:56d3) +; Load the enemy trainer's pic and scrolls it into +; the screen from the right. + xor a + ld [wEnemyMonSpecies2], a + ld b, $1 + call GoPAL_SET + callab _LoadTrainerPic + hlCoord 19, 0 + ld c, $0 +.scrollLoop + inc c + ld a, c + cp 7 + ret z + ld d, $0 + push bc + push hl +.drawTrainerPicLoop + call DrawTrainerPicColumn + inc hl + ld a, 7 + add d + ld d, a + dec c + jr nz, .drawTrainerPicLoop + ld c, 4 + call DelayFrames + pop hl + pop bc + dec hl + jr .scrollLoop + +; write one 7-tile column of the trainer pic to the tilemap +DrawTrainerPicColumn: ; 39707 (e:5707) + push hl + push de + push bc + ld e, 7 +.loop + ld [hl], d + ld bc, SCREEN_WIDTH + add hl, bc + inc d + dec e + jr nz, .loop + pop bc + pop de + pop hl + ret diff --git a/engine/battle/e.asm b/engine/battle/trainer_party_ai_misc.asm index 1144abe8..8cbb9329 100755..100644 --- a/engine/battle/e.asm +++ b/engine/battle/trainer_party_ai_misc.asm @@ -1,117 +1,3 @@ -; does nothing since no stats are ever selected (barring glitches) -DoubleSelectedStats: ; 39680 (e:5680) - ld a, [H_WHOSETURN] - and a - ld a, [wPlayerStatsToDouble] - ld hl, wBattleMonAttack + 1 - jr z, .notEnemyTurn - ld a, [wEnemyStatsToDouble] - ld hl, wEnemyMonAttack + 1 -.notEnemyTurn - ld c, 4 - ld b, a -.loop - srl b - call c, .doubleStat - inc hl - inc hl - dec c - ret z - jr .loop - -.doubleStat - ld a, [hl] - add a - ld [hld], a - ld a, [hl] - rl a - ld [hli], a - ret - -; does nothing since no stats are ever selected (barring glitches) -HalveSelectedStats: ; 396a7 (e:56a7) - ld a, [H_WHOSETURN] - and a - ld a, [wPlayerStatsToHalve] - ld hl, wBattleMonAttack - jr z, .notEnemyTurn - ld a, [wEnemyStatsToHalve] - ld hl, wEnemyMonAttack -.notEnemyTurn - ld c, 4 - ld b, a -.loop - srl b - call c, .halveStat - inc hl - inc hl - dec c - ret z - jr .loop - -.halveStat - ld a, [hl] - srl a - ld [hli], a - rr [hl] - or [hl] - jr nz, .nonzeroStat - ld [hl], 1 -.nonzeroStat - dec hl - ret - -_ScrollTrainerPicAfterBattle: ; 396d3 (e:56d3) -; Load the enemy trainer's pic and scrolls it into -; the screen from the right. - xor a - ld [wEnemyMonSpecies2], a - ld b, $1 - call GoPAL_SET - callab _LoadTrainerPic - hlCoord 19, 0 - ld c, $0 -.scrollLoop - inc c - ld a, c - cp 7 - ret z - ld d, $0 - push bc - push hl -.drawTrainerPicLoop - call DrawTrainerPicColumn - inc hl - ld a, 7 - add d - ld d, a - dec c - jr nz, .drawTrainerPicLoop - ld c, 4 - call DelayFrames - pop hl - pop bc - dec hl - jr .scrollLoop - -; write one 7-tile column of the trainer pic to the tilemap -DrawTrainerPicColumn: ; 39707 (e:5707) - push hl - push de - push bc - ld e, 7 -.loop - ld [hl], d - ld bc, SCREEN_WIDTH - add hl, bc - inc d - dec e - jr nz, .loop - pop bc - pop de - pop hl - ret - ; creates a set of moves that may be used and returns its address in hl ; unused slots are filled with 0, all used slots may be chosen with equal probability AIEnemyTrainerChooseMoves: ; 39719 (e:5719) @@ -1375,195 +1261,3 @@ AIPrintItemUse_: ; 3a835 (e:6835) AIBattleUseItemText: ; 3a844 (e:6844) TX_FAR _AIBattleUseItemText db "@" - -DrawAllPokeballs: ; 3a849 (e:6849) - call LoadPartyPokeballGfx - call SetupOwnPartyPokeballs - ld a, [W_ISINBATTLE] ; W_ISINBATTLE - dec a - ret z ; return if wild pokémon - jp SetupEnemyPartyPokeballs - -DrawEnemyPokeballs: ; 0x3a857 - call LoadPartyPokeballGfx - jp SetupEnemyPartyPokeballs - -LoadPartyPokeballGfx: ; 3a85d (e:685d) - ld de, PokeballTileGraphics ; $697e - ld hl, vSprites + $310 - ld bc, (BANK(PokeballTileGraphics) << 8) + $04 - jp CopyVideoData - -SetupOwnPartyPokeballs: ; 3a869 (e:6869) - call PlacePlayerHUDTiles - ld hl, wPartyMon1 - ld de, wPartyCount ; wPartyCount - call SetupPokeballs - ld a, $60 - ld hl, W_BASECOORDX ; wd081 - ld [hli], a - ld [hl], a - ld a, $8 - ld [wTrainerEngageDistance], a - ld hl, wOAMBuffer - jp WritePokeballOAMData - -SetupEnemyPartyPokeballs: ; 3a887 (e:6887) - call PlaceEnemyHUDTiles - ld hl, wEnemyMons - ld de, wEnemyPartyCount ; wEnemyPartyCount - call SetupPokeballs - ld hl, W_BASECOORDX ; wd081 - ld a, $48 - ld [hli], a - ld [hl], $20 - ld a, $f8 - ld [wTrainerEngageDistance], a - ld hl, wOAMBuffer + PARTY_LENGTH * 4 - jp WritePokeballOAMData - -SetupPokeballs: ; 0x3a8a6 - ld a, [de] - push af - ld de, wBuffer - ld c, PARTY_LENGTH - ld a, $34 ; empty pokeball -.emptyloop - ld [de], a - inc de - dec c - jr nz, .emptyloop - pop af - ld de, wBuffer -.monloop - push af - call PickPokeball - inc de - pop af - dec a - jr nz, .monloop - ret - -PickPokeball: ; 3a8c2 (e:68c2) - inc hl - ld a, [hli] - and a - jr nz, .alive - ld a, [hl] - and a - ld b, $33 ; crossed ball (fainted) - jr z, .done_fainted -.alive - inc hl - inc hl - ld a, [hl] ; status - and a - ld b, $32 ; black ball (status) - jr nz, .done - dec b ; regular ball - jr .done -.done_fainted - inc hl - inc hl -.done - ld a, b - ld [de], a - ld bc, $0028 ; rest of mon struct - add hl, bc - ret - -WritePokeballOAMData: ; 3a8e1 (e:68e1) - ld de, wBuffer - ld c, PARTY_LENGTH -.loop - ld a, [W_BASECOORDY] ; wd082 - ld [hli], a - ld a, [W_BASECOORDX] ; wd081 - ld [hli], a - ld a, [de] - ld [hli], a - xor a - ld [hli], a - ld a, [W_BASECOORDX] ; wd081 - ld b, a - ld a, [wTrainerEngageDistance] - add b - ld [W_BASECOORDX], a ; wd081 - inc de - dec c - jr nz, .loop - ret - -PlacePlayerHUDTiles: ; 3a902 (e:6902) - ld hl, PlayerBattleHUDGraphicsTiles ; $6916 - ld de, wTrainerFacingDirection - ld bc, $3 - call CopyData - hlCoord 18, 10 - ld de, rIE ; $ffff - jr PlaceHUDTiles - -PlayerBattleHUDGraphicsTiles: ; 3a916 (e:6916) -; The tile numbers for specific parts of the battle display for the player's pokemon - db $73 ; unused ($73 is hardcoded into the routine that uses these bytes) - db $77 ; lower-right corner tile of the HUD - db $6F ; lower-left triangle tile of the HUD - -PlaceEnemyHUDTiles: ; 3a919 (e:6919) - ld hl, EnemyBattleHUDGraphicsTiles ; $692d - ld de, wTrainerFacingDirection - ld bc, $3 - call CopyData - hlCoord 1, 2 - ld de, $1 - jr PlaceHUDTiles - -EnemyBattleHUDGraphicsTiles: ; 3a92d (e:692d) -; The tile numbers for specific parts of the battle display for the enemy - db $73 ; unused ($73 is hardcoded in the routine that uses these bytes) - db $74 ; lower-left corner tile of the HUD - db $78 ; lower-right triangle tile of the HUD - -PlaceHUDTiles: ; 3a930 (e:6930) - ld [hl], $73 - ld bc, $14 - add hl, bc - ld a, [wTrainerScreenY] - ld [hl], a - ld a, $8 -.asm_3a93c - add hl, de - ld [hl], $76 - dec a - jr nz, .asm_3a93c - add hl, de - ld a, [wTrainerScreenX] - ld [hl], a - ret - -SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948) - call LoadPartyPokeballGfx - ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) - ld de, wPartyCount ; wPartyCount - call SetupPokeballs - ld hl, W_BASECOORDX ; wd081 - ld a, $50 - ld [hli], a - ld [hl], $40 - ld a, $8 - ld [wTrainerEngageDistance], a - ld hl, wOAMBuffer - call WritePokeballOAMData - ld hl, wEnemyMons ; wEnemyMon1Species - ld de, wEnemyPartyCount ; wEnemyPartyCount - call SetupPokeballs - ld hl, W_BASECOORDX ; wd081 - ld a, $50 - ld [hli], a - ld [hl], $68 - ld hl, wOAMBuffer + $18 - jp WritePokeballOAMData - -; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (faited) and pokeball slot (no mon) -PokeballTileGraphics:: ; 3a97e (e:697e) - INCBIN "gfx/pokeball.2bpp" diff --git a/engine/battle/unused_stats_functions.asm b/engine/battle/unused_stats_functions.asm new file mode 100644 index 00000000..23ddbc20 --- /dev/null +++ b/engine/battle/unused_stats_functions.asm @@ -0,0 +1,62 @@ +; does nothing since no stats are ever selected (barring glitches) +DoubleSelectedStats: ; 39680 (e:5680) + ld a, [H_WHOSETURN] + and a + ld a, [wPlayerStatsToDouble] + ld hl, wBattleMonAttack + 1 + jr z, .notEnemyTurn + ld a, [wEnemyStatsToDouble] + ld hl, wEnemyMonAttack + 1 +.notEnemyTurn + ld c, 4 + ld b, a +.loop + srl b + call c, .doubleStat + inc hl + inc hl + dec c + ret z + jr .loop + +.doubleStat + ld a, [hl] + add a + ld [hld], a + ld a, [hl] + rl a + ld [hli], a + ret + +; does nothing since no stats are ever selected (barring glitches) +HalveSelectedStats: ; 396a7 (e:56a7) + ld a, [H_WHOSETURN] + and a + ld a, [wPlayerStatsToHalve] + ld hl, wBattleMonAttack + jr z, .notEnemyTurn + ld a, [wEnemyStatsToHalve] + ld hl, wEnemyMonAttack +.notEnemyTurn + ld c, 4 + ld b, a +.loop + srl b + call c, .halveStat + inc hl + inc hl + dec c + ret z + jr .loop + +.halveStat + ld a, [hl] + srl a + ld [hli], a + rr [hl] + or [hl] + jr nz, .nonzeroStat + ld [hl], 1 +.nonzeroStat + dec hl + ret @@ -5463,7 +5463,10 @@ SECTION "bankE",ROMX,BANK[$E] INCLUDE "data/moves.asm" BaseStats: INCLUDE "data/base_stats.asm" INCLUDE "data/cries.asm" -INCLUDE "engine/battle/e.asm" +INCLUDE "engine/battle/unused_stats_functions.asm" +INCLUDE "engine/battle/scroll_draw_trainer_pic.asm" +INCLUDE "engine/battle/trainer_party_ai_misc.asm" +INCLUDE "engine/battle/draw_hud_pokeball_gfx.asm" TradingAnimationGraphics: INCBIN "gfx/game_boy.norepeat.2bpp" @@ -5474,7 +5477,9 @@ TradingAnimationGraphics2: INCBIN "gfx/trade2.2bpp" INCLUDE "engine/evos_moves.asm" -INCLUDE "engine/battle/e_2.asm" +INCLUDE "engine/battle/moveEffects/heal_effect.asm" +INCLUDE "engine/battle/moveEffects/transform_effect.asm" +INCLUDE "engine/battle/moveEffects/reflect_light_screen_effect.asm" SECTION "bankF",ROMX,BANK[$F] @@ -5947,7 +5952,8 @@ INCLUDE "scripts/mansion4.asm" INCLUDE "data/mapObjects/mansion4.asm" Mansion4Blocks: INCBIN "maps/mansion4.blk" -INCLUDE "engine/battle/14.asm" +INCLUDE "engine/battle/init_battle_variables.asm" +INCLUDE "engine/battle/moveEffects/paralyze_effect.asm" INCLUDE "engine/overworld/card_key.asm" |