From 2e3b58e6207997315cd69bf50968494b3b2b982b Mon Sep 17 00:00:00 2001 From: luckytyphlosion Date: Sat, 28 Nov 2015 17:55:14 -0500 Subject: BankA misc functions predefsA.asm (replaces predefs12.asm), and LeechSeedEffect_ --- constants/predef_constants.asm | 2 +- engine/battle/common_text.asm | 2 +- engine/battle/core.asm | 40 +++++++------- engine/battle/end_of_battle.asm | 2 +- engine/battle/moveEffects/leech_seed_effect.asm | 8 +-- engine/battle/moveEffects/one_hit_ko_effect.asm | 2 +- engine/battle/moveEffects/paralyze_effect.asm | 2 +- engine/items/items.asm | 2 +- engine/predefs.asm | 2 +- engine/predefs12.asm | 71 ------------------------ engine/predefsA.asm | 73 +++++++++++++++++++++++++ main.asm | 2 +- wram.asm | 2 +- yellow/main.asm | 6 +- 14 files changed, 109 insertions(+), 107 deletions(-) delete mode 100755 engine/predefs12.asm create mode 100644 engine/predefsA.asm diff --git a/constants/predef_constants.asm b/constants/predef_constants.asm index 0adba76a..c8b4a9cd 100644 --- a/constants/predef_constants.asm +++ b/constants/predef_constants.asm @@ -31,7 +31,7 @@ const_value = 0 predef_const GetQuantityOfItemInBag predef_const CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; for these two, the bank number is actually 0 predef_const GiveItem - predef_const ChangeBGPalColor0_4Frames + predef_const InvertBGPalColor0_4Frames predef_const FindPathToPlayer predef_const Func_480ff predef_const CalcPositionOfPlayerRelativeToNPC diff --git a/engine/battle/common_text.asm b/engine/battle/common_text.asm index 0cbf70f0..687fbf99 100644 --- a/engine/battle/common_text.asm +++ b/engine/battle/common_text.asm @@ -23,7 +23,7 @@ PrintBeginningBattleText: ; f4000 (3d:4000) call PlayCry .continue ld hl, WildMonAppearedText - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] and a jr z, .notFishing ld hl, HookedMonAttackedText diff --git a/engine/battle/core.asm b/engine/battle/core.asm index f54e7000..5663b8b4 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -3135,7 +3135,7 @@ ExecutePlayerMove: ; 3d65e (f:565e) inc a jp z, ExecutePlayerMoveDone ; for selected move = FF, skip most of player's turn xor a - ld [W_MOVEMISSED], a + ld [wMoveMissed], a ld [wMonIsDisobedient], a ld [wMoveDidntMiss], a ld a, $a @@ -3206,7 +3206,7 @@ PlayerCalcMoveDamage: ; 3d6dc (f:56dc) .moveHitTest call MoveHitTest handleIfPlayerMoveMissed - ld a,[W_MOVEMISSED] + ld a,[wMoveMissed] and a jr z,getPlayerAnimationType ld a,[W_PLAYERMOVEEFFECT] @@ -3272,7 +3272,7 @@ MirrorMoveCheck ld de,1 call IsInArray jp c,JumpMoveEffect ; done here after executing effects of ResidualEffects2 - ld a,[W_MOVEMISSED] + ld a,[wMoveMissed] and a jr z,.moveDidNotMiss call PrintMoveFailureText @@ -3575,7 +3575,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) or b jr nz,.next ld a,1 - ld [W_MOVEMISSED],a + ld [wMoveMissed],a .next xor a ld [hli],a @@ -4661,7 +4661,7 @@ CalculateDamage: ; 3df65 (f:5f65) JumpToOHKOMoveEffect: ; 3e016 (f:6016) call JumpMoveEffect - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] dec a ret @@ -4775,7 +4775,7 @@ HandleCounterMove: ; 3e093 (f:6093) cp a,COUNTER ret nz ; return if not using Counter ld a,$01 - ld [W_MOVEMISSED],a ; initialize the move missed variable to true (it is set to false below if the move hits) + ld [wMoveMissed],a ; initialize the move missed variable to true (it is set to false below if the move hits) ld a,[hl] cp a,COUNTER ret z ; miss if the opponent's last selected move is Counter. @@ -4813,7 +4813,7 @@ HandleCounterMove: ; 3e093 (f:6093) ld [hl],a .noCarry xor a - ld [W_MOVEMISSED],a + ld [wMoveMissed],a call MoveHitTest ; do the normal move hit test in addition to Counter's special rules xor a ret @@ -5382,7 +5382,7 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5) ; if damage is 0, make the move miss ; this only occurs if a move that would do 2 or 3 damage is 0.25x effective against the target inc a - ld [W_MOVEMISSED],a + ld [wMoveMissed],a .skipTypeImmunity pop bc pop hl @@ -5540,7 +5540,7 @@ MoveHitTest: ; 3e56b (f:656b) ld [hli],a ld [hl],a inc a - ld [W_MOVEMISSED],a + ld [wMoveMissed],a ld a,[H_WHOSETURN] and a jr z,.playerTurn2 @@ -5682,7 +5682,7 @@ ExecuteEnemyMove: ; 3e6bc (f:66bc) ld hl, wAILayer2Encouragement inc [hl] xor a - ld [W_MOVEMISSED], a + ld [wMoveMissed], a ld [wMoveDidntMiss], a ld a, $a ld [wDamageMultipliers], a @@ -5750,7 +5750,7 @@ EnemyCalcMoveDamage: ; 3e750 (f:6750) EnemyMoveHitTest: ; 3e77f (f:677f) call MoveHitTest handleIfEnemyMoveMissed: ; 3e782 (f:6782) - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] and a jr z, .asm_3e791 ld a, [W_ENEMYMOVEEFFECT] @@ -5823,7 +5823,7 @@ EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef) ld de, $1 call IsInArray jp c, JumpMoveEffect - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] and a jr z, .asm_3e82b call PrintMoveFailureText @@ -6101,7 +6101,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) or b jr nz, .next ld a, $1 - ld [W_MOVEMISSED], a + ld [wMoveMissed], a .next xor a ld [hli], a @@ -6821,7 +6821,7 @@ HandleExplodingAnimation: ; 3eed3 (f:6ed3) ld a, [hl] cp GHOST ret z - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] and a ret nz ld a, 5 @@ -6979,7 +6979,7 @@ SleepEffect: ; 3f1fc (f:71fc) push de call MoveHitTest ; apply accuracy tests pop de - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] and a jr nz, .didntAffect .setSleepCounter @@ -7035,7 +7035,7 @@ PoisonEffect: ; 3f24f (f:724f) call MoveHitTest ; apply accuracy tests pop de pop hl - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] and a jr nz, .didntAffect jr .inflictPoison @@ -7493,7 +7493,7 @@ StatModifierDownEffect: ; 3f54c (f:754c) pop bc pop de pop hl - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] and a jp nz, MoveMissed ld a, [bc] @@ -8060,7 +8060,7 @@ ConfusionEffect: ; 3f961 (f:7961) call CheckTargetSubstitute jr nz, ConfusionEffectFailed call MoveHitTest - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] and a jr nz, ConfusionEffectFailed @@ -8143,7 +8143,7 @@ MimicEffect: ; 3f9ed (f:79ed) ld c, 50 call DelayFrames call MoveHitTest - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] and a jr nz, .asm_3fa74 ld a, [H_WHOSETURN] @@ -8224,7 +8224,7 @@ SplashEffect: ; 3fa84 (f:7a84) DisableEffect: ; 3fa8a (f:7a8a) call MoveHitTest - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] and a jr nz, .moveMissed ld de, W_ENEMYDISABLEDMOVE diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm index 5782b274..5760889b 100755 --- a/engine/battle/end_of_battle.asm +++ b/engine/battle/end_of_battle.asm @@ -53,7 +53,7 @@ EndOfBattle: ; 13765 (4:7765) ld [wChannelSoundIDs + CH4], a ld [wIsInBattle], a ld [W_BATTLETYPE], a - ld [W_MOVEMISSED], a + ld [wMoveMissed], a ld [wCurOpponent], a ld [wForcePlayerToChooseMon], a ld [wNumRunAttempts], a diff --git a/engine/battle/moveEffects/leech_seed_effect.asm b/engine/battle/moveEffects/leech_seed_effect.asm index 769e9ed9..ef649ff6 100644 --- a/engine/battle/moveEffects/leech_seed_effect.asm +++ b/engine/battle/moveEffects/leech_seed_effect.asm @@ -1,6 +1,6 @@ -LeechSeedEffect_: ; 2bea9 (a:7ea9) +LeechSeedEffect_: ; 2bdba (a:7dba) callab MoveHitTest - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] and a jr nz, .moveMissed ld hl, wEnemyBattleStatus2 @@ -31,10 +31,10 @@ LeechSeedEffect_: ; 2bea9 (a:7ea9) ld hl, EvadedAttackText jp PrintText -WasSeededText: ; 2bef2 (a:7ef2) +WasSeededText: ; 2be03 (a:7e03) TX_FAR _WasSeededText db "@" -EvadedAttackText: ; 2bef7 (a:7ef7) +EvadedAttackText: ; 2be08 (a:7e08) TX_FAR _EvadedAttackText db "@" diff --git a/engine/battle/moveEffects/one_hit_ko_effect.asm b/engine/battle/moveEffects/one_hit_ko_effect.asm index 12f70b90..28973356 100644 --- a/engine/battle/moveEffects/one_hit_ko_effect.asm +++ b/engine/battle/moveEffects/one_hit_ko_effect.asm @@ -34,5 +34,5 @@ OneHitKOEffect_: ; f64db (3d:64db) .userIsSlower ; keep damage at 0 and set move missed flag if target's current speed is higher instead ld a, $1 - ld [W_MOVEMISSED], a + ld [wMoveMissed], a ret diff --git a/engine/battle/moveEffects/paralyze_effect.asm b/engine/battle/moveEffects/paralyze_effect.asm index 3e0cf062..9b364425 100644 --- a/engine/battle/moveEffects/paralyze_effect.asm +++ b/engine/battle/moveEffects/paralyze_effect.asm @@ -28,7 +28,7 @@ ParalyzeEffect_: ; f6562 (3d:6562) push hl callab MoveHitTest pop hl - ld a, [W_MOVEMISSED] + ld a, [wMoveMissed] and a jr nz, .didntAffect set PAR, [hl] diff --git a/engine/items/items.asm b/engine/items/items.asm index c2aff579..831f6afc 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -1972,7 +1972,7 @@ RodResponse: ; e15b (3:615b) jr nz, DoNotGenerateFishingEncounter ; if yes, store level and species data ld a, 1 - ld [W_MOVEMISSED], a + ld [wMoveMissed], a ld a, b ; level ld [wCurEnemyLVL], a ld a, c ; species diff --git a/engine/predefs.asm b/engine/predefs.asm index b385b217..02c696d6 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -84,7 +84,7 @@ PredefPointers:: ; f681d (3d:681d) ;add_predef IsItemInBag_ ;dbw $03,CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; for these two, the bank number is actually 0 ;dbw $03,GiveItem - ;add_predef ChangeBGPalColor0_4Frames + ;add_predef InvertBGPalColor0_4Frames ;add_predef FindPathToPlayer ;add_predef Func_480ff ;add_predef CalcPositionOfPlayerRelativeToNPC diff --git a/engine/predefs12.asm b/engine/predefs12.asm deleted file mode 100755 index 269a681e..00000000 --- a/engine/predefs12.asm +++ /dev/null @@ -1,71 +0,0 @@ -; b = new colour for BG colour 0 (usually white) for 4 frames -ChangeBGPalColor0_4Frames: ; 480eb (12:40eb) - call GetPredefRegisters - ld a, [rBGP] - or b - ld [rBGP], a - ld c, 4 - call DelayFrames - ld a, [rBGP] - and %11111100 - ld [rBGP], a - ret - -PredefShakeScreenVertically: ; 480ff (12:40ff) -; Moves the window down and then back in a sequence of progressively smaller -; numbers of pixels, starting at b. - call GetPredefRegisters - ld a, 1 - ld [wDisableVBlankWYUpdate], a - xor a -.loop - ld [$ff96], a - call .MutateWY - call .MutateWY - dec b - ld a, b - jr nz, .loop - xor a - ld [wDisableVBlankWYUpdate], a - ret - -.MutateWY ; 48119 (12:4119) - ld a, [$ff96] - xor b - ld [$ff96], a - ld [rWY], a - ld c, 3 - jp DelayFrames - -PredefShakeScreenHorizontally: ; 48125 (12:4125) -; Moves the window right and then back in a sequence of progressively smaller -; numbers of pixels, starting at b. - call GetPredefRegisters - xor a -.loop - ld [$ff97], a - call .MutateWX - ld c, 1 - call DelayFrames - call .MutateWX - dec b - ld a, b - jr nz, .loop - -; restore normal WX - ld a, 7 - ld [rWX], a - ret - -.MutateWX ; 4813f (12:413f) - ld a, [$ff97] - xor b - ld [$ff97], a - bit 7, a - jr z, .skipZeroing - xor a ; zero a if it's negative -.skipZeroing - add 7 - ld [rWX], a - ld c, 4 - jp DelayFrames diff --git a/engine/predefsA.asm b/engine/predefsA.asm new file mode 100644 index 00000000..5761fdb4 --- /dev/null +++ b/engine/predefsA.asm @@ -0,0 +1,73 @@ +; inverts the BGP for 4 (6 on CGB due to lag) frames +InvertBGPalColor0_4Frames: ; 2bd4c (a:7d4c) + call GetPredefRegisters ; leftover of red/blue, has no use here + ld a, [rBGP] + xor $ff + ld [rBGP], a + call UpdateGBCPal_BGP + ld c, 4 + call DelayFrames + ld a, [rBGP] + xor $ff + ld [rBGP], a + call UpdateGBCPal_BGP + ret + +PredefShakeScreenVertically: ; 2bd67 (a:7d67) +; Moves the window down and then back in a sequence of progressively smaller +; numbers of pixels, starting at b. + call GetPredefRegisters + ld a, 1 + ld [wDisableVBlankWYUpdate], a + xor a +.loop + ld [$ff96], a + call .MutateWY + call .MutateWY + dec b + ld a, b + jr nz, .loop + xor a + ld [wDisableVBlankWYUpdate], a + ret + +.MutateWY ; 2bd81 (a:7d81) + ld a, [$ff96] + xor b + ld [$ff96], a + ld [rWY], a + ld c, 3 + jp DelayFrames + +PredefShakeScreenHorizontally: ; 2bd8d (a:7d8d) +; Moves the window right and then back in a sequence of progressively smaller +; numbers of pixels, starting at b. + call GetPredefRegisters + xor a +.loop + ld [$ff97], a + call .MutateWX + ld c, 1 + call DelayFrames + call .MutateWX + dec b + ld a, b + jr nz, .loop + +; restore normal WX + ld a, 7 + ld [rWX], a + ret + +.MutateWX ; 2bda7 (a:4da7) + ld a, [$ff97] + xor b + ld [$ff97], a + bit 7, a + jr z, .skipZeroing + xor a ; zero a if it's negative +.skipZeroing + add 7 + ld [rWX], a + ld c, 4 + jp DelayFrames diff --git a/main.asm b/main.asm index 2ecf5f63..741e9857 100755 --- a/main.asm +++ b/main.asm @@ -2575,7 +2575,7 @@ ApplyOutOfBattlePoisonDamage: ; c3de (3:43de) and a ; are any party members poisoned? jr z, .skipPoisonEffectAndSound ld b, $2 - predef ChangeBGPalColor0_4Frames ; change BG white to dark grey for 4 frames + predef InvertBGPalColor0_4Frames ; change BG white to dark grey for 4 frames ld a, SFX_POISONED call PlaySound .skipPoisonEffectAndSound diff --git a/wram.asm b/wram.asm index 8ed01add..74ca6a5d 100755 --- a/wram.asm +++ b/wram.asm @@ -1635,7 +1635,7 @@ wCriticalHitOrOHKO:: ; d05e ; $ff = failed OHKO ds 1 -W_MOVEMISSED:: ; d05f +wMoveMissed:: ; d05f ds 1 wPlayerStatsToDouble:: ; d060 diff --git a/yellow/main.asm b/yellow/main.asm index 99acf4a5..b7a9cfba 100755 --- a/yellow/main.asm +++ b/yellow/main.asm @@ -1796,7 +1796,7 @@ ApplyOutOfBattlePoisonDamage: ; c3de (3:43de) and a ; are any party members poisoned? jr z, .skipPoisonEffectAndSound ld b, $2 - predef ChangeBGPalColor0_4Frames ; change BG white to dark grey for 4 frames + predef InvertBGPalColor0_4Frames ; change BG white to dark grey for 4 frames ld a, SFX_POISONED call PlaySound .skipPoisonEffectAndSound @@ -3790,8 +3790,8 @@ JynxPicBack: INCBIN "pic/monback/jynxb.pic" MoltresPicFront: INCBIN "pic/ymon/moltres.pic" MoltresPicBack: INCBIN "pic/monback/moltresb.pic" - dr $2bd4c,$2c000 - +INCLUDE "engine/predefsA.asm" +INCLUDE "engine/battle/moveEffects/leech_seed_effect.asm" SECTION "Pics 3", ROMX, BANK[PICS_3] -- cgit v1.2.3