diff options
Diffstat (limited to 'engine/battle')
31 files changed, 1853 insertions, 1687 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 8791d538..626eea9e 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -163,14 +163,14 @@ DrawFrameBlock: ; 78000 (1e:4000) PlayAnimation: ; 780f1 (1e:40f1) xor a - ld [$FF8B],a + ld [$FF8B],a ; it looks like nothing reads this ld [W_SUBANIMTRANSFORM],a ld a,[W_ANIMATIONID] ; get animation number dec a ld l,a ld h,0 add hl,hl - ld de,AttackAnimationPointers ; $607d ; animation command stream pointers + ld de,AttackAnimationPointers ; animation command stream pointers add hl,de ld a,[hli] ld h,[hl] @@ -199,7 +199,7 @@ PlayAnimation: ; 780f1 (1e:40f1) ld [wAnimSoundID],a ; store sound push hl push de - call Func_7986f + call GetMoveSound call PlaySound pop de pop hl @@ -223,7 +223,7 @@ PlayAnimation: ; 780f1 (1e:40f1) rla sla c rla - ld [wd09f],a ; tile select + ld [wWhichBattleAnimTileset],a ld a,[hli] ; sound ld [wAnimSoundID],a ; store sound ld a,[hli] ; subanimation ID @@ -243,7 +243,7 @@ PlayAnimation: ; 780f1 (1e:40f1) push hl ld a,[rOBP0] push af - ld a,[wcc79] + ld a,[wAnimPalette] ld [rOBP0],a call LoadAnimationTileset call LoadSubanimation @@ -328,7 +328,7 @@ GetSubanimationTransform2: ; 781ca (1e:41ca) ; loads tile patterns for battle animations LoadAnimationTileset: ; 781d2 (1e:41d2) - ld a,[wd09f] ; tileset select + ld a,[wWhichBattleAnimTileset] add a add a ld hl,AnimationTilesetPointers @@ -336,14 +336,14 @@ LoadAnimationTileset: ; 781d2 (1e:41d2) ld d,0 add hl,de ld a,[hli] - ld [wd07d],a ; number of tiles + ld [wTempTilesetNumTiles],a ; number of tiles ld a,[hli] ld e,a ld a,[hl] ld d,a ; de = address of tileset ld hl,vSprites + $310 ld b, BANK(AnimationTileset1) ; ROM bank - ld a,[wd07d] + ld a,[wTempTilesetNumTiles] ld c,a ; number of tiles jp CopyVideoData ; load tileset @@ -375,7 +375,7 @@ MoveAnimation: ; 78d5e (1e:4d5e) push bc push af call WaitForSoundToFinish - call Func_78e23 + call SetAnimationPalette ld a,[W_ANIMATIONID] and a jr z,.AnimationFinished @@ -404,7 +404,7 @@ MoveAnimation: ; 78d5e (1e:4d5e) call WaitForSoundToFinish xor a ld [W_SUBANIMSUBENTRYADDR],a - ld [wd09b],a + ld [wUnusedD09B],a ld [W_SUBANIMTRANSFORM],a dec a ld [wAnimSoundID],a @@ -464,16 +464,16 @@ AnimationTypePointerTable: ; 78dcf (1e:4dcf) ShakeScreenVertically: ; 78ddb (1e:4ddb) call PlayApplyingAttackSound - ld b, $8 + ld b, 8 jp AnimationShakeScreenVertically ShakeScreenHorizontallyHeavy: ; 78de3 (1e:4de3) call PlayApplyingAttackSound - ld b, $8 + ld b, 8 jp AnimationShakeScreenHorizontallyFast ShakeScreenHorizontallySlow: ; 78deb (1e:4deb) - ld bc, $602 + lb bc, 6, 2 jr AnimationShakeScreenHorizontallySlow BlinkEnemyMonSprite: ; 78df0 (1e:4df0) @@ -482,71 +482,71 @@ BlinkEnemyMonSprite: ; 78df0 (1e:4df0) ShakeScreenHorizontallyLight: ; 78df6 (1e:4df6) call PlayApplyingAttackSound - ld b, $2 + ld b, 2 jp AnimationShakeScreenHorizontallyFast ShakeScreenHorizontallySlow2: ; 78dfe (1e:4dfe) - ld bc, $302 + lb bc, 3, 2 AnimationShakeScreenHorizontallySlow: ; 78e01 (1e:4e01) push bc push bc -.asm_78e03 - ld a, [rWX] ; $ff4b +.loop1 + ld a, [rWX] inc a - ld [rWX], a ; $ff4b - ld c, $2 + ld [rWX], a + ld c, 2 call DelayFrames dec b - jr nz, .asm_78e03 + jr nz, .loop1 pop bc -.asm_78e11 - ld a, [rWX] ; $ff4b +.loop2 + ld a, [rWX] dec a - ld [rWX], a ; $ff4b - ld c, $2 + ld [rWX], a + ld c, 2 call DelayFrames dec b - jr nz, .asm_78e11 + jr nz, .loop2 pop bc dec c jr nz, AnimationShakeScreenHorizontallySlow ret -Func_78e23: ; 78e23 (1e:4e23) +SetAnimationPalette: ; 78e23 (1e:4e23) ld a, [wOnSGB] and a ld a, $e4 - jr z, .asm_78e47 + jr z, .notSGB ld a, $f0 - ld [wcc79], a + ld [wAnimPalette], a ld b, $e4 - ld a, [W_ANIMATIONID] ; W_ANIMATIONID + ld a, [W_ANIMATIONID] cp TRADE_BALL_DROP_ANIM - jr c, .asm_78e3f + jr c, .next cp TRADE_BALL_POOF_ANIM + 1 - jr nc, .asm_78e3f + jr nc, .next ld b, $f0 -.asm_78e3f +.next ld a, b - ld [rOBP0], a ; $ff48 + ld [rOBP0], a ld a, $6c - ld [rOBP1], a ; $ff49 + ld [rOBP1], a ret -.asm_78e47 +.notSGB ld a, $e4 - ld [wcc79], a - ld [rOBP0], a ; $ff48 + ld [wAnimPalette], a + ld [rOBP0], a ld a, $6c - ld [rOBP1], a ; $ff49 + ld [rOBP1], a ret PlaySubanimation: ; 78e53 (1e:4e53) ld a,[wAnimSoundID] cp a,$FF jr z,.skipPlayingSound - call Func_7986f - call PlaySound ; play sound effect + call GetMoveSound + call PlaySound .skipPlayingSound ld hl,wOAMBuffer ; base address of OAM buffer ld a,l @@ -573,7 +573,7 @@ PlaySubanimation: ; 78e53 (1e:4e53) push hl ld e,[hl] ; base coordinate ID ld d,0 - ld hl,FrameBlockBaseCoords ; $7c85 ; base coordinate table + ld hl,FrameBlockBaseCoords ; base coordinate table add hl,de add hl,de ld a,[hli] @@ -659,7 +659,7 @@ AnimationIdSpecialEffects: ; 78ef5 (1e:4ef5) dw AnimationFlashScreen db TAIL_WHIP - dw Func_790d0 + dw TailWhipAnimationUnused db GROWL dw DoGrowlSpecialEffects @@ -695,13 +695,13 @@ AnimationIdSpecialEffects: ; 78ef5 (1e:4ef5) dw DoRockSlideSpecialEffects db TRADE_BALL_DROP_ANIM - dw Func_79041 + dw TradeHidePokemon db TRADE_BALL_SHAKE_ANIM - dw Func_7904c + dw TradeShakePokeball db TRADE_BALL_TILT_ANIM - dw Func_7907c + dw TradeJumpPokeball db TOSS_ANIM dw DoBallTossSpecialEffects @@ -733,8 +733,8 @@ DoBallTossSpecialEffects: ; 78f3e (1e:4f3e) cp a,11 ; is it the beginning of the subanimation? jr nz,.skipPlayingSound ; if it is the beginning of the subanimation, play a sound - ld a,(SFX_08_41 - SFX_Headers_08) / 3 - call PlaySound ; play sound + ld a,SFX_BALL_TOSS + call PlaySound .skipPlayingSound ld a,[W_ISINBATTLE] cp a,02 ; is it a trainer battle? @@ -751,20 +751,20 @@ DoBallTossSpecialEffects: ; 78f3e (1e:4f3e) cp a,1 ret nz .moveGhostMarowakLeft - hlCoord 17, 0 + coord hl, 17, 0 ld de,20 - ld bc,$0707 ; 7 rows and 7 columns + lb bc, 7, 7 .loop push hl push bc - call Func_79862 ; move row of tiles left + call AnimCopyRowRight ; move row of tiles left pop bc pop hl add hl,de dec b jr nz,.loop ld a,%00001000 - ld [$ff10],a ; Channel 1 sweep register + ld [rNR10],a ; Channel 1 sweep register ret .isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame ld a,[W_SUBANIMCOUNTER] @@ -779,8 +779,8 @@ DoBallShakeSpecialEffects: ; 78f96 (1e:4f96) cp a,4 ; is it the beginning of a shake? jr nz,.skipPlayingSound ; if it is the beginning of a shake, play a sound and wait 2/3 of a second - ld a,(SFX_08_3c - SFX_Headers_08) / 3 - call PlaySound ; play sound + ld a,SFX_TINK + call PlaySound ld c,40 call DelayFrames .skipPlayingSound @@ -788,9 +788,9 @@ DoBallShakeSpecialEffects: ; 78f96 (1e:4f96) dec a ret nz ; if it's the end of the ball shaking subanimation, check if more shakes are left and restart the subanimation - ld a,[wWhichTrade] ; number of shakes + ld a,[wNumShakes] ; number of shakes dec a ; decrement number of shakes - ld [wWhichTrade],a + ld [wNumShakes],a ret z ; if there are shakes left, restart the subanimation ld a,[W_SUBANIMSUBENTRYADDR] @@ -812,7 +812,7 @@ DoPoofSpecialEffects: ; 78fce (1e:4fce) ld a,[W_SUBANIMCOUNTER] cp a,5 ret nz - ld a,(SFX_08_42 - SFX_Headers_08) / 3 + ld a,SFX_BALL_POOF jp PlaySound DoRockSlideSpecialEffects: ; 78fd9 (1e:4fd9) @@ -827,9 +827,9 @@ DoRockSlideSpecialEffects: ; 78fd9 (1e:4fd9) ; if the subaninmation counter is between 8 and 11, shake the screen horizontally and vertically .shakeScreen ld b,1 - predef Func_48125 ; shake horizontally + predef PredefShakeScreenHorizontally ; shake horizontally ld b,1 - predef_jump Func_480ff ; shake vertically + predef_jump PredefShakeScreenVertically ; shake vertically FlashScreenEveryEightFrameBlocks: ; 78ff7 (1e:4ff7) ld a,[W_SUBANIMCOUNTER] @@ -850,7 +850,7 @@ DoExplodeSpecialEffects: ; 79009 (1e:5009) cp a,1 ; is it the end of the subanimation? jr nz,FlashScreenEveryFourFrameBlocks ; if it's the end of the subanimation, make the attacking pokemon disappear - hlCoord 1, 5 + coord hl, 1, 5 jp AnimationHideMonPic ; make pokemon disappear ; flashes the screen when subanimation counter is 1 modulo 4 @@ -867,8 +867,8 @@ DoBlizzardSpecialEffects: ; 79016 (1e:5016) ret ; flashes the screen at 3 points in the subanimation -; XXX is this unused? -Func_7902e: ; 7902e (1e:502e) +; unused +FlashScreenUnused: ; 7902e (1e:502e) ld a,[W_SUBANIMCOUNTER] cp a,14 jp z,AnimationFlashScreen @@ -879,17 +879,15 @@ Func_7902e: ; 7902e (1e:502e) ret ; function to make the pokemon disappear at the beginning of the animation -; XXX probably a trade-related animation -Func_79041: ; 79041 (1e:5041) +TradeHidePokemon: ; 79041 (1e:5041) ld a,[W_SUBANIMCOUNTER] cp a,6 ret nz - ld a,$2F - jp Func_7980c ; make pokemon disappear + ld a,2 * SCREEN_WIDTH + 7 + jp ClearMonPicFromTileMap ; make pokemon disappear ; function to make a shaking pokeball jump up at the end of the animation -; XXX probably a trade-related animation -Func_7904c: ; 7904c (1e:504c) +TradeShakePokeball: ; 7904c (1e:504c) ld a,[W_SUBANIMCOUNTER] cp a,1 ret nz @@ -915,16 +913,15 @@ Func_7904c: ; 7904c (1e:504c) jr .loop .done call AnimationCleanOAM - ld a,(SFX_02_44 - SFX_Headers_02) / 3 - jp PlaySound ; play sound + ld a,SFX_TRADE_MACHINE + jp PlaySound BallMoveDistances1: ; 79078 (1e:5078) db -12,-12,-8 db $ff ; terminator ; function to make the pokeball jump up -; XXX probably a trade-related animation -Func_7907c ; 507C +TradeJumpPokeball: ; 507C ld de,BallMoveDistances2 .loop ld hl,wOAMBuffer ; OAM buffer @@ -947,7 +944,7 @@ Func_7907c ; 507C cp a,$ff jr nz,.skipPlayingSound .playSound ; play sound if next move distance is 12 or this is the last one - ld a,(SFX_08_58 - SFX_Headers_08) / 3 + ld a,SFX_BATTLE_18 call PlaySound .skipPlayingSound push bc @@ -977,7 +974,7 @@ DoGrowlSpecialEffects: ; 790bc (1e:50bc) ret ; this is associated with Tail Whip, but Tail Whip doesn't use any subanimations -Func_790d0: ; 790d0 (1e:50d0) +TailWhipAnimationUnused: ; 790d0 (1e:50d0) ld a,1 ld [W_SUBANIMCOUNTER],a ld c,20 @@ -1005,8 +1002,8 @@ SpecialEffectPointers: ; 790da (1e:50da) dw AnimationSlideMonDown db SE_FLASH_MON_PIC ; $F5 dw AnimationFlashMonPic - db SE_SLIDE_MON_OUT ; $F4 - dw AnimationSlideMonOut + db SE_SLIDE_MON_OFF ; $F4 + dw AnimationSlideMonOff db SE_BLINK_MON ; $F3 dw AnimationBlinkMon db SE_MOVE_MON_HORIZONTALLY ; $F2 @@ -1035,8 +1032,8 @@ SpecialEffectPointers: ; 790da (1e:50da) dw AnimationLeavesFalling db SE_PETALS_FALLING ; $E6 dw AnimationPetalsFalling - db SE_SLIDE_MON_HALF_LEFT ; $E5 - dw AnimationSlideMonHalfLeft + db SE_SLIDE_MON_HALF_OFF ; $E5 + dw AnimationSlideMonHalfOff db SE_SHAKE_ENEMY_HUD ; $E4 dw AnimationShakeEnemyHUD db SE_SHAKE_ENEMY_HUD_2 ; unused--same pointer as SE_SHAKE_ENEMY_HUD ($E4) @@ -1055,8 +1052,8 @@ SpecialEffectPointers: ; 790da (1e:50da) dw AnimationShowMonPic db SE_SHOW_ENEMY_MON_PIC ; $DC dw AnimationShowEnemyMonPic - db SE_SLIDE_ENEMY_MON_OUT ; $DB - dw AnimationSlideEnemyMonOut + db SE_SLIDE_ENEMY_MON_OFF ; $DB + dw AnimationSlideEnemyMonOff db SE_SHAKE_BACK_AND_FORTH ; $DA dw AnimationShakeBackAndForth db SE_SUBSTITUTE_MON ; $D9 @@ -1087,7 +1084,7 @@ CallWithTurnFlipped: ; 79155 (1e:5155) ; flashes the screen for an extended period (48 frames) AnimationFlashScreenLong: ; 79165 (1e:5165) ld a,3 ; cycle through the palettes 3 times - ld [wd08a],a + ld [wFlashScreenLongCounter],a ld a,[wOnSGB] ; running on SGB? and a ld hl,FlashScreenLongMonochrome @@ -1103,9 +1100,9 @@ AnimationFlashScreenLong: ; 79165 (1e:5165) call FlashScreenLongDelay jr .innerLoop .endOfPalettes - ld a,[wd08a] + ld a,[wFlashScreenLongCounter] dec a - ld [wd08a],a + ld [wFlashScreenLongCounter],a pop hl jr nz,.loop ret @@ -1145,8 +1142,8 @@ FlashScreenLongSGB: ; 7919b (1e:519b) ; causes a delay of 2 frames for the first cycle ; causes a delay of 1 frame for the second and third cycles FlashScreenLongDelay: ; 791a8 (1e:51a8) - ld a,[wd08a] - cp a,4 ; never true since [wd08a] starts at 3 + ld a,[wFlashScreenLongCounter] + cp a,4 ; never true since [wFlashScreenLongCounter] starts at 3 ld c,4 jr z,.delayFrames cp a,3 @@ -1174,233 +1171,248 @@ AnimationFlashScreen: ; 791be (1e:51be) AnimationDarkScreenPalette: ; 791d6 (1e:51d6) ; Changes the screen's palette to a dark palette. - ld bc, $6f6f - jr Func_791fc + lb bc, $6f, $6f + jr SetAnimationBGPalette AnimationDarkenMonPalette: ; 791db (1e:51db) ; Darkens the mon sprite's palette. - ld bc, $f9f4 - jr Func_791fc + lb bc, $f9, $f4 + jr SetAnimationBGPalette -Func_791e0: ; 791e0 (1e:51e0) - ld bc, $fef8 - jr Func_791fc +AnimationUnusedPalette1: ; 791e0 (1e:51e0) + lb bc, $fe, $f8 + jr SetAnimationBGPalette -Func_791e5: ; 791e5 (1e:51e5) - ld bc, $ffff - jr Func_791fc +AnimationUnusedPalette2: ; 791e5 (1e:51e5) + lb bc, $ff, $ff + jr SetAnimationBGPalette AnimationResetScreenPalette: ; 791ea (1e:51ea) ; Restores the screen's palette to the normal palette. - ld bc, $e4e4 - jr Func_791fc + lb bc, $e4, $e4 + jr SetAnimationBGPalette -Func_791ef: ; 791ef (1e:51ef) - ld bc, $0000 - jr Func_791fc +AnimationUnusedPalette3: ; 791ef (1e:51ef) + lb bc, $00, $00 + jr SetAnimationBGPalette AnimationLightScreenPalette: ; 791f4 (1e:51f4) ; Changes the screen to use a palette with light colors. - ld bc, $9090 - jr Func_791fc + lb bc, $90, $90 + jr SetAnimationBGPalette -Func_791f9: ; 791f9 (1e:51f9) - ld bc, $4040 +AnimationUnusedPalette4: ; 791f9 (1e:51f9) + lb bc, $40, $40 -Func_791fc: ; 791fc (1e:51fc) +SetAnimationBGPalette: ; 791fc (1e:51fc) ld a, [wOnSGB] and a ld a, b - jr z, .asm_79204 + jr z, .next ld a, c -.asm_79204 - ld [rBGP], a ; $ff47 +.next + ld [rBGP], a ret ld b, $5 AnimationShakeScreenVertically: ; 79209 (1e:5209) - predef_jump Func_480ff + predef_jump PredefShakeScreenVertically AnimationShakeScreen: ; 7920e (1e:520e) ; Shakes the screen for a while. Used in Earthquake/Fissure/etc. animations. ld b, $8 AnimationShakeScreenHorizontallyFast: ; 79210 (1e:5210) - predef_jump Func_48125 + predef_jump PredefShakeScreenHorizontally AnimationWaterDropletsEverywhere: ; 79215 (1e:5215) ; Draws water droplets all over the screen and makes them ; scroll. It's hard to describe, but it's the main animation ; in Surf/Mist/Toxic. xor a - ld [wd09f], a + ld [wWhichBattleAnimTileset], a call LoadAnimationTileset - ld d, $20 - ld a, $f0 - ld [W_BASECOORDX], a ; wd081 + ld d, 32 + ld a, -16 + ld [W_BASECOORDX], a ld a, $71 - ld [wd09f], a -.asm_79228 - ld a, $10 - ld [W_BASECOORDY], a ; wd082 - ld a, $0 - ld [wd08a], a - call Func_79246 - ld a, $18 - ld [W_BASECOORDY], a ; wd082 - ld a, $20 - ld [wd08a], a - call Func_79246 + ld [wDropletTile], a +.loop + ld a, 16 + ld [W_BASECOORDY], a + ld a, 0 + ld [wUnusedD08A], a + call _AnimationWaterDroplets + ld a, 24 + ld [W_BASECOORDY], a + ld a, 32 + ld [wUnusedD08A], a + call _AnimationWaterDroplets dec d - jr nz, .asm_79228 + jr nz, .loop ret -Func_79246: ; 79246 (1e:5246) +_AnimationWaterDroplets: ; 79246 (1e:5246) ld hl, wOAMBuffer -.asm_79249 - ld a, [W_BASECOORDY] ; wd082 - ld [hli], a - ld a, [W_BASECOORDX] ; wd081 - add $1b - ld [W_BASECOORDX], a ; wd081 - ld [hli], a - ld a, [wd09f] - ld [hli], a +.loop + ld a, [W_BASECOORDY] + ld [hli], a ; Y + ld a, [W_BASECOORDX] + add 27 + ld [W_BASECOORDX], a + ld [hli], a ; X + ld a, [wDropletTile] + ld [hli], a ; tile xor a - ld [hli], a - ld a, [W_BASECOORDX] ; wd081 - cp $90 - jr c, .asm_79249 - sub $a8 - ld [W_BASECOORDX], a ; wd081 - ld a, [W_BASECOORDY] ; wd082 - add $10 - ld [W_BASECOORDY], a ; wd082 - cp $70 - jr c, .asm_79249 + ld [hli], a ; attribute + ld a, [W_BASECOORDX] + cp 144 + jr c, .loop + sub 168 + ld [W_BASECOORDX], a + ld a, [W_BASECOORDY] + add 16 + ld [W_BASECOORDY], a + cp 112 + jr c, .loop call AnimationCleanOAM jp DelayFrame AnimationSlideMonUp: ; 7927a (1e:527a) ; Slides the mon's sprite upwards. - ld c, $7 + ld c, 7 ld a, [H_WHOSETURN] and a - ld hl, wTileMap + $79 - ld de, wTileMap + $65 + coord hl, 1, 6 + coord de, 1, 5 ld a, $30 - jr z, .asm_79291 - ld hl, wTileMap + $20 - ld de, wTileMap + $c + jr z, .next + coord hl, 12, 1 + coord de, 12, 0 ld a, $ff -.asm_79291 - ld [wd09f], a - jp Func_792bf +.next + ld [wSlideMonUpBottomRowLeftTile], a + jp _AnimationSlideMonUp AnimationSlideMonDown: ; 79297 (1e:5297) ; Slides the mon's sprite down out of the screen. xor a call GetTileIDList -.asm_7929b +.loop call GetMonSpriteTileMapPointerFromRowCount push bc push de - call Func_79aae + call CopyPicTiles call Delay3 call AnimationHideMonPic pop de pop bc dec b - jr nz, .asm_7929b + jr nz, .loop ret -AnimationSlideMonOut: ; 792af (1e:52af) -; Slides the mon's sprite out of the screen horizontally. - ld e, $8 - ld a, $3 - ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM - jp Func_795f8 +AnimationSlideMonOff: ; 792af (1e:52af) +; Slides the mon's sprite off the screen horizontally. + ld e, 8 + ld a, 3 + ld [wSlideMonDelay], a + jp _AnimationSlideMonOff -AnimationSlideEnemyMonOut: ; 792b9 (1e:52b9) -; Slides the enemy mon out of the screen horizontally. - ld hl, AnimationSlideMonOut ; $52af +AnimationSlideEnemyMonOff: ; 792b9 (1e:52b9) +; Slides the enemy mon off the screen horizontally. + ld hl, AnimationSlideMonOff jp CallWithTurnFlipped -Func_792bf: ; 792bf (1e:52bf) +_AnimationSlideMonUp: ; 792bf (1e:52bf) push de push hl push bc - ld b, $6 -.asm_792c4 + +; In each iteration, slide up all rows but the top one (which is overwritten). + ld b, 6 +.slideLoop push bc push de push hl - ld bc, $0007 + ld bc, 7 call CopyData +; Note that de and hl are popped in the same order they are pushed, swapping +; their values. When CopyData is called, hl points to a tile 1 row below +; the one de points to. To maintain this relationship, after swapping, we add 2 +; rows to hl so that it is 1 row below again. pop de pop hl - ld bc, $0028 + ld bc, SCREEN_WIDTH * 2 add hl, bc pop bc dec b - jr nz, .asm_792c4 + jr nz, .slideLoop + +; Fill in the bottom row of the mon pic with the next row's tile IDs. ld a, [H_WHOSETURN] and a - ld hl, wTileMap + $dd - jr z, .asm_792e2 - ld hl, wTileMap + $84 -.asm_792e2 - ld a, [wd09f] + coord hl, 1, 11 + jr z, .next + coord hl, 12, 6 +.next + ld a, [wSlideMonUpBottomRowLeftTile] inc a - ld [wd09f], a - ld c, $7 -.asm_792eb + ld [wSlideMonUpBottomRowLeftTile], a + ld c, 7 +.fillBottomRowLoop ld [hli], a - add $7 + add 7 dec c - jr nz, .asm_792eb - ld c, $2 + jr nz, .fillBottomRowLoop + + ld c, 2 call DelayFrames pop bc pop hl pop de dec c - jr nz, Func_792bf + jr nz, _AnimationSlideMonUp ret -Func_792fd: ; 792fd (1e:52fd) +ShakeEnemyHUD_WritePlayerMonPicOAM: ; 792fd (1e:52fd) +; Writes the OAM entries for a copy of the player mon's pic in OAM. +; The top 5 rows are reproduced in OAM, although only 2 are actually needed. ld a, $10 ld [W_BASECOORDX], a ld a, $30 ld [W_BASECOORDY], a ld hl, wOAMBuffer - ld d, $0 - ld c, $7 -.asm_7930e + ld d, 0 + ld c, 7 +.loop ld a, [W_BASECOORDY] ld e, a - ld b, $5 -.asm_79314 - call Func_79329 + ld b, 5 +.innerLoop + call BattleAnimWriteOAMEntry inc d dec b - jr nz, .asm_79314 + jr nz, .innerLoop dec c ret z inc d inc d ld a, [W_BASECOORDX] - add $8 + add 8 ld [W_BASECOORDX], a - jr .asm_7930e + jr .loop -Func_79329: ; 79329 (1e:5329) +BattleAnimWriteOAMEntry: ; 79329 (1e:5329) +; Y coordinate = e (increased by 8 each call, before the write to OAM) +; X coordinate = [W_BASECOORDX] +; tile = d +; attributes = 0 ld a, e - add $8 + add 8 ld e, a ld [hli], a - ld a, [W_BASECOORDX] ; wd081 + ld a, [W_BASECOORDX] ld [hli], a ld a, d ld [hli], a @@ -1413,16 +1425,17 @@ AdjustOAMBlockXPos: ; 79337 (1e:5337) ld h, d AdjustOAMBlockXPos2: ; 79339 (1e:5339) - ld de, $4 + ld de, 4 .loop - ld a, [wd08a] + ld a, [wCoordAdjustmentAmount] ld b, a ld a, [hl] add b - cp $a8 + cp 168 jr c, .skipPuttingEntryOffScreen +; put off-screen if X >= 168 dec hl - ld a, $a0 + ld a, 160 ld [hli], a .skipPuttingEntryOffScreen ld [hl], a @@ -1436,16 +1449,16 @@ AdjustOAMBlockYPos: ; 79350 (1e:5350) ld h, d AdjustOAMBlockYPos2: ; 79352 (1e:5352) - ld de, $4 + ld de, 4 .loop - ld a, [wd08a] + ld a, [wCoordAdjustmentAmount] ld b, a ld a, [hl] add b - cp $70 + cp 112 jr c, .skipSettingPreviousEntrysAttribute dec hl - ld a, $a0 ; bug, sets previous OAM entry's attribute + ld a, 160 ; bug, sets previous OAM entry's attribute ld [hli], a .skipSettingPreviousEntrysAttribute ld [hl], a @@ -1456,34 +1469,34 @@ AdjustOAMBlockYPos2: ; 79352 (1e:5352) AnimationBlinkEnemyMon: ; 79369 (1e:5369) ; Make the enemy mon's sprite blink on and off for a second or two - ld hl, AnimationBlinkMon ; $536f + ld hl, AnimationBlinkMon jp CallWithTurnFlipped AnimationBlinkMon: ; 7936f (1e:536f) ; Make the mon's sprite blink on and off for a second or two. push af - ld c, $6 -.asm_79372 + ld c, 6 +.loop push bc call AnimationHideMonPic - ld c, $5 + ld c, 5 call DelayFrames call AnimationShowMonPic - ld c, $5 + ld c, 5 call DelayFrames pop bc dec c - jr nz, .asm_79372 + jr nz, .loop pop af ret AnimationFlashMonPic: ; 79389 (1e:5389) ; Flashes the mon's sprite on and off ld a, [wBattleMonSpecies] - ld [wHPBarMaxHP + 1], a + ld [wChangeMonPicPlayerTurnSpecies], a ld a, [wEnemyMonSpecies] - ld [wHPBarMaxHP], a - jp Func_79793 + ld [wChangeMonPicEnemyTurnSpecies], a + jp ChangeMonPic AnimationFlashEnemyMonPic: ; 79398 (1e:5398) ; Flashes the enemy mon's sprite on and off @@ -1494,7 +1507,7 @@ AnimationShowMonPic: ; 7939e (1e:539e) xor a call GetTileIDList call GetMonSpriteTileMapPointerFromRowCount - call Func_79aae + call CopyPicTiles jp Delay3 AnimationShowEnemyMonPic: ; 793ab (1e:53ab) @@ -1508,16 +1521,16 @@ AnimationShakeBackAndForth: ; 793b1 (1e:53b1) ; The mon's sprite disappears after this animation. ld a, [H_WHOSETURN] and a - ld hl, wTileMap + $64 - ld de, wTileMap + $66 - jr z, .asm_793c2 - ld hl, wTileMap + $b - ld de, wTileMap + $d + coord hl, 0, 5 + coord de, 2, 5 + jr z, .next + coord hl, 11, 0 + coord de, 13, 0 -.asm_793c2 +.next xor a ld c, $10 -.asm_793c5 +.loop push af push bc push de @@ -1529,113 +1542,113 @@ AnimationShakeBackAndForth: ; 793b1 (1e:53b1) push hl call GetTileIDList pop hl - call Func_79aae + call CopyPicTiles call Delay3 pop hl - ld bc, $0709 + lb bc, 7, 9 call ClearScreenArea pop af call GetTileIDList pop hl - call Func_79aae + call CopyPicTiles call Delay3 pop hl - ld bc, $0709 + lb bc, 7, 9 call ClearScreenArea pop hl pop de pop bc pop af dec c - jr nz, .asm_793c5 + jr nz, .loop ret AnimationMoveMonHorizontally: ; 793f9 (1e:53f9) ; Shifts the mon's sprite horizontally to a fixed location. Used by lots of ; animations like Tackle/Body Slam. call AnimationHideMonPic - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - hlCoord 2, 5 - jr z, .asm_79407 - hlCoord 11, 0 -.asm_79407 + coord hl, 2, 5 + jr z, .next + coord hl, 11, 0 +.next xor a push hl call GetTileIDList pop hl - call Func_79aae - ld c, $3 + call CopyPicTiles + ld c, 3 jp DelayFrames AnimationResetMonPosition: ; 79415 (1e:5415) ; Resets the mon's sprites to be located at the normal coordinates. - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld a, $66 - jr z, .asm_7941e - ld a, $b -.asm_7941e - call Func_7980c + ld a, 5 * SCREEN_WIDTH + 2 + jr z, .next + ld a, 11 +.next + call ClearMonPicFromTileMap jp AnimationShowMonPic AnimationSpiralBallsInward: ; 79424 (1e:5424) -; Creates an effect that looks like energy balls sprialing into the +; Creates an effect that looks like energy balls spiralling into the ; player mon's sprite. Used in Focus Energy, for example. - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - jr z, .asm_79435 - ld a, $d8 - ld [wd08a], a - ld a, $50 - ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM - jr .asm_7943c -.asm_79435 + jr z, .playerTurn + ld a, -40 + ld [wSpiralBallsBaseY], a + ld a, 80 + ld [wSpiralBallsBaseX], a + jr .next +.playerTurn xor a - ld [wd08a], a - ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM -.asm_7943c - ld d, $7a - ld c, $3 + ld [wSpiralBallsBaseY], a + ld [wSpiralBallsBaseX], a +.next + ld d, $7a ; ball tile + ld c, 3 ; number of balls xor a - call Func_797e8 - ld hl, SpiralBallAnimationCoordinates ; $5476 -.asm_79447 + call InitMultipleObjectsOAM + ld hl, SpiralBallAnimationCoordinates +.loop push hl - ld c, $3 + ld c, 3 ld de, wOAMBuffer -.asm_7944d +.innerLoop ld a, [hl] cp $ff - jr z, .asm_7946f - ld a, [wd08a] + jr z, .done + ld a, [wSpiralBallsBaseY] add [hl] - ld [de], a + ld [de], a ; Y inc de inc hl - ld a, [W_SUBANIMTRANSFORM] ; W_SUBANIMTRANSFORM + ld a, [wSpiralBallsBaseX] add [hl] - ld [de], a + ld [de], a ; X inc hl inc de inc de inc de dec c - jr nz, .asm_7944d - ld c, $5 + jr nz, .innerLoop + ld c, 5 call DelayFrames pop hl inc hl inc hl - jr .asm_79447 -.asm_7946f + jr .loop +.done pop hl call AnimationCleanOAM jp AnimationFlashScreen SpiralBallAnimationCoordinates: ; 79476 (1e:5476) ; y, x pairs -; This is the sequence of screen coordinates that the spiraling +; This is the sequence of screen coordinates that the spiralling ; balls are positioned at. db $38, $28 db $40, $18 @@ -1663,125 +1676,126 @@ SpiralBallAnimationCoordinates: ; 79476 (1e:5476) AnimationSquishMonPic: ; 794a1 (1e:54a1) ; Squishes the mon's sprite horizontally making it ; disappear. Used by Teleport/Sky Attack animations. - ld c, $4 -.asm_794a3 + ld c, 4 +.loop push bc - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - jr z, .asm_794b1 - hlCoord 16, 0 - deCoord 14, 0 - jr .asm_794b7 -.asm_794b1 - hlCoord 5, 5 - deCoord 3, 5 -.asm_794b7 + jr z, .playerTurn + coord hl, 16, 0 + coord de, 14, 0 + jr .next +.playerTurn + coord hl, 5, 5 + coord de, 3, 5 +.next push de - xor a - ld [wd09f], a - call Func_794d4 + xor a ; left + ld [wSquishMonCurrentDirection], a + call _AnimationSquishMonPic pop hl - ld a, $1 - ld [wd09f], a - call Func_794d4 + ld a, 1 ; right + ld [wSquishMonCurrentDirection], a + call _AnimationSquishMonPic pop bc dec c - jr nz, .asm_794a3 + jr nz, .loop call AnimationHideMonPic - ld c, $2 + ld c, 2 jp DelayFrame -Func_794d4: ; 794d4 (1e:54d4) - ld c, $7 -.asm_794d6 +_AnimationSquishMonPic: ; 794d4 (1e:54d4) + ld c, 7 +.loop push bc push hl - ld c, $3 - ld a, [wd09f] - cp $0 - jr nz, .asm_794e7 - call Func_7985b + ld c, 3 + ld a, [wSquishMonCurrentDirection] + cp 0 + jr nz, .right + call AnimCopyRowLeft dec hl - jr .asm_794eb -.asm_794e7 - call Func_79862 + jr .next +.right + call AnimCopyRowRight inc hl -.asm_794eb - ld [hl], $7f +.next + ld [hl], " " pop hl - ld de, $14 + ld de, SCREEN_WIDTH add hl, de pop bc dec c - jr nz, .asm_794d6 + jr nz, .loop jp Delay3 AnimationShootBallsUpward: ; 794f9 (1e:54f9) ; Shoots one pillar of "energy" balls upwards. Used in Teleport/Sky Attack ; animations. - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - jr z, .asm_79503 - ld bc, $80 - jr .asm_79506 -.asm_79503 - ld bc, $3028 -.asm_79506 + jr z, .playerTurn + lb bc, 0, 16 * 8 + jr .next +.playerTurn + lb bc, 6 * 8, 5 * 8 +.next ld a, b - ld [W_BASECOORDY], a ; wd082 + ld [W_BASECOORDY], a ld a, c - ld [W_BASECOORDX], a ; wd081 - ld bc, $501 - call Func_79517 + ld [W_BASECOORDX], a + lb bc, 5, 1 + call _AnimationShootBallsUpward jp AnimationCleanOAM -Func_79517: ; 79517 (1e:5517) +_AnimationShootBallsUpward: ; 79517 (1e:5517) push bc xor a - ld [wd09f], a + ld [wWhichBattleAnimTileset], a call LoadAnimationTileset pop bc - ld d, $7a + ld d, $7a ; ball tile ld hl, wOAMBuffer push bc - ld a, [W_BASECOORDY] ; wd082 + ld a, [W_BASECOORDY] ld e, a -.asm_7952a - call Func_79329 +.initOAMLoop + call BattleAnimWriteOAMEntry dec b - jr nz, .asm_7952a + jr nz, .initOAMLoop call DelayFrame pop bc ld a, b - ld [wd08a], a -.asm_79538 + ld [wNumShootingBalls], a +.loop push bc ld hl, wOAMBuffer -.asm_7953c - ld a, [W_BASECOORDY] ; wd082 - add $8 +.innerLoop + ld a, [W_BASECOORDY] + add 8 ld e, a ld a, [hl] - cp e - jr z, .asm_7954b - add $fc + cp e ; has the ball reached the top? + jr z, .reachedTop + add -4 ; ball hasn't reached the top. move it up 4 pixels ld [hl], a - jr .asm_79554 -.asm_7954b - ld [hl], $0 - ld a, [wd08a] + jr .next +.reachedTop +; remove the ball once it has reached the top + ld [hl], 0 ; put it off-screen + ld a, [wNumShootingBalls] dec a - ld [wd08a], a -.asm_79554 - ld de, $4 - add hl, de + ld [wNumShootingBalls], a +.next + ld de, 4 + add hl, de ; next OAM entry dec b - jr nz, .asm_7953c + jr nz, .innerLoop call DelayFrames pop bc - ld a, [wd08a] + ld a, [wNumShootingBalls] and a - jr nz, .asm_79538 + jr nz, .loop ret AnimationShootManyBallsUpward: ; 79566 (1e:5566) @@ -1794,17 +1808,17 @@ AnimationShootManyBallsUpward: ; 79566 (1e:5566) ld hl, UpwardBallsAnimXCoordinatesEnemyTurn ld a, $28 ; y coordinate for "energy" ball pillar .player - ld [wTrainerSpriteOffset], a + ld [wSavedY], a .loop - ld a, [wTrainerSpriteOffset] + ld a, [wSavedY] ld [W_BASECOORDY], a ld a, [hli] cp $ff jp z, AnimationCleanOAM ld [W_BASECOORDX], a - ld bc, $0401 + lb bc, 4, 1 push hl - call Func_79517 + call _AnimationShootBallsUpward pop hl jr .loop @@ -1831,16 +1845,16 @@ AnimationMinimizeMon: ; 7959f (1e:559f) pop hl ld de, $194 add hl, de - ld de, MinimizedMonSprite ; $55c4 + ld de, MinimizedMonSprite ld c, $5 -.asm_795b4 +.loop ld a, [de] ld [hli], a ld [hli], a inc de dec c - jr nz, .asm_795b4 - call Func_79652 + jr nz, .loop + call CopyTempPicToMonPic call Delay3 jp AnimationShowMonPic @@ -1851,7 +1865,7 @@ AnimationSlideMonDownAndHide: ; 795c9 (1e:55c9) ; Slides the mon's sprite down and disappears. Used in Acid Armor. ld a, $1 ld c, $2 -.asm_795cd +.loop push bc push af call AnimationHideMonPic @@ -1859,94 +1873,108 @@ AnimationSlideMonDownAndHide: ; 795c9 (1e:55c9) push af call GetTileIDList call GetMonSpriteTileMapPointerFromRowCount - call Func_79aae - ld c, $8 + call CopyPicTiles + ld c, 8 call DelayFrames pop af inc a pop bc dec c - jr nz, .asm_795cd + jr nz, .loop call AnimationHideMonPic ld hl, wTempPic ld bc, $0310 xor a call FillMemory - jp Func_79652 + jp CopyTempPicToMonPic -Func_795f8: ; 795f8 (1e:55f8) - ld a, [H_WHOSETURN] ; $fff3 +_AnimationSlideMonOff: ; 795f8 (1e:55f8) +; Slides the mon's sprite off the screen horizontally by e tiles and waits +; [wSlideMonDelay] V-blanks each time the pic is slid by one tile. + ld a, [H_WHOSETURN] and a - jr z, .asm_79602 - hlCoord 12, 0 - jr .asm_79605 -.asm_79602 - hlCoord 0, 5 -.asm_79605 - ld d, $8 -.asm_79607 + jr z, .playerTurn + coord hl, 12, 0 + jr .next +.playerTurn + coord hl, 0, 5 +.next + ld d, 8 ; d's value is unused +.slideLoop ; iterates once for each time the pic slides by one tile push hl - ld b, $7 -.asm_7960a - ld c, $8 -.asm_7960c - ld a, [H_WHOSETURN] ; $fff3 + ld b, 7 +.rowLoop ; iterates once for each row + ld c, 8 +.tileLoop ; iterates once for each tile in the row + ld a, [H_WHOSETURN] and a - jr z, .asm_79616 - call Func_7963c - jr .asm_79619 -.asm_79616 - call Func_79633 -.asm_79619 + jr z, .playerTurn2 + call .EnemyNextTile + jr .next2 +.playerTurn2 + call .PlayerNextTile +.next2 ld [hli], a dec c - jr nz, .asm_7960c + jr nz, .tileLoop push de - ld de, $c + ld de, SCREEN_WIDTH - 8 add hl, de pop de dec b - jr nz, .asm_7960a - ld a, [W_SUBANIMTRANSFORM] ; W_SUBANIMTRANSFORM + jr nz, .rowLoop + ld a, [wSlideMonDelay] ld c, a call DelayFrames pop hl dec d dec e - jr nz, .asm_79607 + jr nz, .slideLoop ret -Func_79633: ; 79633 (1e:5633) +; Since mon pic tile numbers go from top to bottom, left to right in order, +; adding the height of the mon pic in tiles to a tile number gives the tile +; number of the tile one column to the right (and thus subtracting the height +; gives the reverse). If the next tile would be past the edge of the pic, the 2 +; functions below catch it by checking if the tile number is within the valid +; range and if not, replacing it with a blank tile. + +.PlayerNextTile ; 79633 (1e:5633) ld a, [hl] - add $7 + add 7 +; This is a bug. The lower right corner tile of the mon back pic is blanked +; while the mon is sliding off the screen. It should compare with the max tile +; plus one instead. cp $61 ret c - ld a, $7f + ld a, " " ret -Func_7963c: ; 7963c (1e:563c) +.EnemyNextTile ; 7963c (1e:563c) ld a, [hl] - sub $7 + sub 7 +; This has the same problem as above, but it has no visible effect because +; the lower right tile is in the first column to slide off the screen. cp $30 ret c - ld a, $7f + ld a, " " ret -AnimationSlideMonHalfLeft: ; 79645 (1e:5645) -; Slides the mon's sprite halfway out of the screen. It's used in Softboiled. - ld e, $4 - ld a, $4 - ld [W_SUBANIMTRANSFORM], a - call Func_795f8 +AnimationSlideMonHalfOff: ; 79645 (1e:5645) +; Slides the mon's sprite halfway off the screen. It's used in Softboiled. + ld e, 4 + ld a, 4 + ld [wSlideMonDelay], a + call _AnimationSlideMonOff jp Delay3 -Func_79652: ; 79652 (1e:5652) - ld a, [H_WHOSETURN] ; $fff3 +CopyTempPicToMonPic: ; 79652 (1e:5652) + ld a, [H_WHOSETURN] and a - ld hl, vBackPic - jr z, .asm_7965d - ld hl, vFrontPic -.asm_7965d + ld hl, vBackPic ; player turn + jr z, .next + ld hl, vFrontPic ; enemy turn +.next ld de, wTempPic ld bc, 7 * 7 jp CopyVideoData @@ -1954,55 +1982,55 @@ Func_79652: ; 79652 (1e:5652) AnimationWavyScreen: ; 79666 (1e:5666) ; used in Psywave/Psychic etc. ld hl, vBGMap0 - call Func_79e0d + call BattleAnimCopyTileMapToVRAM call Delay3 xor a ld [H_AUTOBGTRANSFERENABLED], a - ld a, $90 + ld a, SCREEN_HEIGHT_PIXELS ld [hWY], a - ld d, $80 - ld e, $8f + ld d, $80 ; terminator + ld e, SCREEN_HEIGHT_PIXELS - 1 ld c, $ff ld hl, WavyScreenLineOffsets -.asm_7967f +.loop push hl -.asm_79680 - call Func_796ae - ld a, [$ff44] - cp e - jr nz, .asm_79680 +.innerLoop + call WavyScreen_SetSCX + ld a, [rLY] + cp e ; is it the last visible line in the frame? + jr nz, .innerLoop ; keep going if not pop hl inc hl ld a, [hl] - cp d - jr nz, .asm_79691 - ld hl, WavyScreenLineOffsets -.asm_79691 + cp d ; have we reached the end? + jr nz, .next + ld hl, WavyScreenLineOffsets ; go back to the beginning if so +.next dec c - jr nz, .asm_7967f + jr nz, .loop xor a ld [hWY], a call SaveScreenTilesToBuffer2 call ClearScreen - ld a, $1 + ld a, 1 ld [H_AUTOBGTRANSFERENABLED], a call Delay3 call LoadScreenTilesFromBuffer2 ld hl, vBGMap1 - call Func_79e0d + call BattleAnimCopyTileMapToVRAM ret -Func_796ae: ; 796ae (1e:56ae) - ld a, [$ff41] - and $3 - jr nz, Func_796ae +WavyScreen_SetSCX: ; 796ae (1e:56ae) + ld a, [rSTAT] + and $3 ; is it H-blank? + jr nz, WavyScreen_SetSCX ; wait until it's H-blank ld a, [hl] - ld [$ff43], a + ld [rSCX], a inc hl ld a, [hl] - cp d + cp d ; have we reached the end? ret nz - ld hl, WavyScreenLineOffsets + ld hl, WavyScreenLineOffsets ; go back to the beginning if so ret WavyScreenLineOffsets: ; 796bf (1e:56bf) @@ -2018,9 +2046,9 @@ AnimationSubstitute: ; 796e0 (1e:56e0) xor a ld bc, $0310 call FillMemory - ld a, [$fff3] + ld a, [H_WHOSETURN] and a - jr z, .asm_79715 ; 0x796ed $26 + jr z, .playerTurn ld hl, SlowbroSprite ; facing down sprite ld de, wTempPic + $120 call CopySlowbroSpriteData @@ -2033,8 +2061,8 @@ AnimationSubstitute: ; 796e0 (1e:56e0) ld hl, SlowbroSprite + $30 ld de, wTempPic + $120 + $10 + $70 call CopySlowbroSpriteData - jr .asm_79739 -.asm_79715 + jr .next +.playerTurn ld hl, SlowbroSprite + $40 ; facing up sprite ld de, wTempPic + $120 + $70 call CopySlowbroSpriteData @@ -2047,8 +2075,8 @@ AnimationSubstitute: ; 796e0 (1e:56e0) ld hl, SlowbroSprite + $70 ld de, wTempPic + $120 + $f0 call CopySlowbroSpriteData -.asm_79739 - call Func_79652 +.next + call CopyTempPicToMonPic jp AnimationShowMonPic CopySlowbroSpriteData: ; 7973f (1e:573f) @@ -2056,23 +2084,24 @@ CopySlowbroSpriteData: ; 7973f (1e:573f) ld a, BANK(SlowbroSprite) jp FarCopyData2 -Func_79747: ; 79747 (1e:5747) - ld a, [H_WHOSETURN] ; $fff3 +HideSubstituteShowMonAnim: ; 79747 (1e:5747) + ld a, [H_WHOSETURN] and a - ld hl, wccf7 - ld a, [W_PLAYERBATTSTATUS2] ; W_PLAYERBATTSTATUS2 - jr z, .asm_79758 - ld hl, wccf3 - ld a, [W_ENEMYBATTSTATUS2] ; W_ENEMYBATTSTATUS2 -.asm_79758 + ld hl, wPlayerMonMinimized + ld a, [W_PLAYERBATTSTATUS2] + jr z, .next1 + ld hl, wEnemyMonMinimized + ld a, [W_ENEMYBATTSTATUS2] +.next1 push hl - bit 4, a - jr nz, .asm_79762 +; if the substitute broke, slide it down, else slide it offscreen horizontally + bit HasSubstituteUp, a + jr nz, .substituteStillUp call AnimationSlideMonDown - jr .asm_79765 -.asm_79762 - call AnimationSlideMonOut -.asm_79765 + jr .next2 +.substituteStillUp + call AnimationSlideMonOff +.next2 pop hl ld a, [hl] and a @@ -2080,48 +2109,48 @@ Func_79747: ; 79747 (1e:5747) call AnimationFlashMonPic jp AnimationShowMonPic -Func_79771: ; 79771 (1e:5771) - call AnimationSlideMonOut +ReshowSubstituteAnim: ; 79771 (1e:5771) + call AnimationSlideMonOff call AnimationSubstitute jp AnimationShowMonPic AnimationBoundUpAndDown: ; 7977a (1e:577a) ; Bounces the mon's sprite up and down several times. It is used ; by Splash's animation. - ld c, $5 -.asm_7977c + ld c, 5 +.loop push bc call AnimationSlideMonDown pop bc dec c - jr nz, .asm_7977c ; 0x79782 $f8 + jr nz, .loop jp AnimationShowMonPic AnimationTransformMon: ; 79787 (1e:5787) ; Redraws this mon's sprite as the back/front sprite of the opposing mon. ; Used in Transform. ld a, [wEnemyMonSpecies] - ld [wHPBarMaxHP + 1], a + ld [wChangeMonPicPlayerTurnSpecies], a ld a, [wBattleMonSpecies] - ld [wHPBarMaxHP], a + ld [wChangeMonPicEnemyTurnSpecies], a -Func_79793: ; 79793 (1e:5793) - ld a, [H_WHOSETURN] ; $fff3 +ChangeMonPic: ; 79793 (1e:5793) + ld a, [H_WHOSETURN] and a - jr z, .asm_797b0 - ld a, [wHPBarMaxHP] + jr z, .playerTurn + ld a, [wChangeMonPicEnemyTurnSpecies] ld [wcf91], a ld [wd0b5], a xor a ld [W_SPRITEFLIPPED], a call GetMonHeader - hlCoord 12, 0 + coord hl, 12, 0 call LoadFrontSpriteByMonIndex - jr .asm_797d3 -.asm_797b0 + jr .done +.playerTurn ld a, [wBattleMonSpecies2] push af - ld a, [wHPBarMaxHP + 1] + ld a, [wChangeMonPicPlayerTurnSpecies] ld [wBattleMonSpecies2], a ld [wd0b5], a call GetMonHeader @@ -2129,59 +2158,63 @@ Func_79793: ; 79793 (1e:5793) xor a call GetTileIDList call GetMonSpriteTileMapPointerFromRowCount - call Func_79aae + call CopyPicTiles pop af ld [wBattleMonSpecies2], a -.asm_797d3 - ld b, $1 - jp GoPAL_SET +.done + ld b, SET_PAL_BATTLE + jp RunPaletteCommand AnimationHideEnemyMonPic: ; 797d8 (1e:57d8) ; Hides the enemy mon's sprite xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld hl, AnimationHideMonPic ; $5801 + ld [H_AUTOBGTRANSFERENABLED], a + ld hl, AnimationHideMonPic call CallWithTurnFlipped ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a jp Delay3 -Func_797e8: ; 797e8 (1e:57e8) +InitMultipleObjectsOAM: ; 797e8 (1e:57e8) +; Writes c OAM entries with tile d. +; Sets their Y coordinates to sequential multiples of 8, starting from 0. +; Sets their X coordinates to 0. +; Loads animation tileset a. push bc push de - ld [wd09f], a + ld [wWhichBattleAnimTileset], a call LoadAnimationTileset pop de pop bc xor a ld e, a - ld [W_BASECOORDX], a ; wd081 + ld [W_BASECOORDX], a ld hl, wOAMBuffer -.asm_797fa - call Func_79329 +.loop + call BattleAnimWriteOAMEntry dec c - jr nz, .asm_797fa + jr nz, .loop ret AnimationHideMonPic: ; 79801 (1e:5801) ; Hides the mon's sprite. - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - jr z, .asm_7980a - ld a, $c - jr Func_7980c -.asm_7980a - ld a, $65 + jr z, .playerTurn + ld a, 12 + jr ClearMonPicFromTileMap +.playerTurn + ld a, 5 * SCREEN_WIDTH + 1 -Func_7980c: ; 7980c (1e:580c) +ClearMonPicFromTileMap: ; 7980c (1e:580c) push hl push de push bc ld e, a - ld d, $0 - ld hl, wTileMap + ld d, 0 + coord hl, 0, 0 add hl, de - ld bc, $707 + lb bc, 7, 7 call ClearScreenArea pop bc pop de @@ -2201,7 +2234,7 @@ GetMonSpriteTileMapPointerFromRowCount: ; 79820 (1e:5820) .enemyTurn ld a, 12 .next - ld hl, wTileMap + coord hl, 0, 0 ld e, a ld d, 0 add hl, de @@ -2245,29 +2278,33 @@ GetTileIDList: ; 79842 (1e:5842) ld b, a ret -Func_7985b: ; 7985b (1e:585b) +AnimCopyRowLeft: ; 7985b (1e:585b) +; copy a row of c tiles 1 tile left ld a, [hld] ld [hli], a inc hl dec c - jr nz, Func_7985b + jr nz, AnimCopyRowLeft ret -Func_79862: ; 79862 (1e:5862) +AnimCopyRowRight: ; 79862 (1e:5862) +; copy a row of c tiles 1 tile right ld a, [hli] ld [hld], a dec hl dec c - jr nz, Func_79862 + jr nz, AnimCopyRowRight ret -Func_79869: ; 79869 (1e:5869) +; get the sound of the move id in b +GetMoveSoundB: ; 79869 (1e:5869) ld a, b - call Func_7986f + call GetMoveSound ld b, a ret -Func_7986f: ; 7986f (1e:586f) +; get the sound of the (move id - 1) in a +GetMoveSound: ; 7986f (1e:586f) ld hl,MoveSoundTable ld e,a ld d,0 @@ -2290,19 +2327,19 @@ Func_7986f: ; 7986f (1e:586f) call GetCryData ld b,a pop hl - ld a,[wc0f1] + ld a,[wFrequencyModifier] add [hl] - ld [wc0f1],a + ld [wFrequencyModifier],a inc hl - ld a,[wc0f2] + ld a,[wTempoModifier] add [hl] - ld [wc0f2],a + ld [wTempoModifier],a jr .done .NotCryMove ld a,[hli] - ld [wc0f1],a + ld [wFrequencyModifier],a ld a,[hli] - ld [wc0f2],a + ld [wTempoModifier],a .done ld a,b ret @@ -2321,196 +2358,200 @@ IsCryMove: ; 798ad (1e:58ad) ret MoveSoundTable: ; 798bc (1e:58bc) - db (SFX_08_4a - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_4c - SFX_Headers_08) / 3,$10,$80 - db (SFX_08_5d - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_4b - SFX_Headers_08) / 3,$01,$80 - db (SFX_08_4d - SFX_Headers_08) / 3,$00,$40 - db (SFX_08_77 - SFX_Headers_08) / 3,$00,$ff - db (SFX_08_4d - SFX_Headers_08) / 3,$10,$60 - db (SFX_08_4d - SFX_Headers_08) / 3,$20,$80 - db (SFX_08_4d - SFX_Headers_08) / 3,$00,$a0 - db (SFX_08_50 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_4f - SFX_Headers_08) / 3,$20,$40 - db (SFX_08_4f - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_4e - SFX_Headers_08) / 3,$00,$a0 - db (SFX_08_51 - SFX_Headers_08) / 3,$10,$c0 - db (SFX_08_51 - SFX_Headers_08) / 3,$00,$a0 - db (SFX_08_52 - SFX_Headers_08) / 3,$00,$c0 - db (SFX_08_52 - SFX_Headers_08) / 3,$10,$a0 - db (SFX_08_53 - SFX_Headers_08) / 3,$00,$e0 - db (SFX_08_51 - SFX_Headers_08) / 3,$20,$c0 - db (SFX_08_54 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_62 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_55 - SFX_Headers_08) / 3,$01,$80 - db (SFX_08_60 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_57 - SFX_Headers_08) / 3,$f0,$40 - db (SFX_08_5a - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_57 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_61 - SFX_Headers_08) / 3,$10,$80 - db (SFX_08_5b - SFX_Headers_08) / 3,$01,$a0 - db (SFX_08_58 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_5e - SFX_Headers_08) / 3,$00,$60 - db (SFX_08_5e - SFX_Headers_08) / 3,$01,$40 - db (SFX_08_5f - SFX_Headers_08) / 3,$00,$a0 - db (SFX_08_5a - SFX_Headers_08) / 3,$10,$a0 - db (SFX_08_60 - SFX_Headers_08) / 3,$00,$c0 - db (SFX_08_54 - SFX_Headers_08) / 3,$10,$60 - db (SFX_08_5a - SFX_Headers_08) / 3,$00,$a0 - db (SFX_08_62 - SFX_Headers_08) / 3,$11,$c0 - db (SFX_08_5a - SFX_Headers_08) / 3,$20,$c0 - db (SFX_08_61 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_5b - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_5b - SFX_Headers_08) / 3,$20,$c0 - db (SFX_08_59 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_71 - SFX_Headers_08) / 3,$ff,$40 - db (SFX_08_5e - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_4b - SFX_Headers_08) / 3,$00,$c0 - db (SFX_08_4b - SFX_Headers_08) / 3,$00,$40 - db (SFX_08_75 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_67 - SFX_Headers_08) / 3,$40,$60 - db (SFX_08_67 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_67 - SFX_Headers_08) / 3,$ff,$40 - db (SFX_08_6a - SFX_Headers_08) / 3,$80,$c0 - db (SFX_08_59 - SFX_Headers_08) / 3,$10,$a0 - db (SFX_08_59 - SFX_Headers_08) / 3,$21,$e0 - db (SFX_08_69 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_64 - SFX_Headers_08) / 3,$20,$60 - db (SFX_08_6a - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_6c - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_68 - SFX_Headers_08) / 3,$40,$80 - db (SFX_08_69 - SFX_Headers_08) / 3,$f0,$e0 - db (SFX_08_6d - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_6a - SFX_Headers_08) / 3,$f0,$60 - db (SFX_08_68 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_76 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_47 - SFX_Headers_08) / 3,$01,$a0 - db (SFX_08_53 - SFX_Headers_08) / 3,$f0,$20 - db (SFX_08_63 - SFX_Headers_08) / 3,$01,$c0 - db (SFX_08_63 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_5a - SFX_Headers_08) / 3,$00,$e0 - db (SFX_08_66 - SFX_Headers_08) / 3,$01,$60 - db (SFX_08_66 - SFX_Headers_08) / 3,$20,$40 - db (SFX_08_64 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_64 - SFX_Headers_08) / 3,$40,$c0 - db (SFX_08_5b - SFX_Headers_08) / 3,$03,$60 - db (SFX_08_65 - SFX_Headers_08) / 3,$11,$e0 - db (SFX_08_52 - SFX_Headers_08) / 3,$20,$e0 - db (SFX_08_6e - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_5c - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_5c - SFX_Headers_08) / 3,$11,$a0 - db (SFX_08_5c - SFX_Headers_08) / 3,$01,$c0 - db (SFX_08_53 - SFX_Headers_08) / 3,$14,$c0 - db (SFX_08_5b - SFX_Headers_08) / 3,$02,$a0 - db (SFX_08_69 - SFX_Headers_08) / 3,$f0,$80 - db (SFX_08_69 - SFX_Headers_08) / 3,$20,$c0 - db (SFX_08_6f - SFX_Headers_08) / 3,$00,$20 - db (SFX_08_6f - SFX_Headers_08) / 3,$20,$80 - db (SFX_08_6e - SFX_Headers_08) / 3,$12,$60 - db (SFX_08_66 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_54 - SFX_Headers_08) / 3,$01,$e0 - db (SFX_08_69 - SFX_Headers_08) / 3,$0f,$e0 - db (SFX_08_69 - SFX_Headers_08) / 3,$11,$20 - db (SFX_08_50 - SFX_Headers_08) / 3,$10,$40 - db (SFX_08_4f - SFX_Headers_08) / 3,$10,$c0 - db (SFX_08_54 - SFX_Headers_08) / 3,$00,$20 - db (SFX_08_70 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_75 - SFX_Headers_08) / 3,$11,$18 - db (SFX_08_49 - SFX_Headers_08) / 3,$20,$c0 - db (SFX_08_48 - SFX_Headers_08) / 3,$20,$c0 - db (SFX_08_65 - SFX_Headers_08) / 3,$00,$10 - db (SFX_08_66 - SFX_Headers_08) / 3,$f0,$20 - db (SFX_08_73 - SFX_Headers_08) / 3,$f0,$c0 - db (SFX_08_51 - SFX_Headers_08) / 3,$f0,$e0 - db (SFX_08_49 - SFX_Headers_08) / 3,$f0,$40 - db (SFX_08_71 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_73 - SFX_Headers_08) / 3,$80,$40 - db (SFX_08_73 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_54 - SFX_Headers_08) / 3,$11,$20 - db (SFX_08_54 - SFX_Headers_08) / 3,$22,$10 - db (SFX_08_5b - SFX_Headers_08) / 3,$f1,$ff - db (SFX_08_53 - SFX_Headers_08) / 3,$f1,$ff - db (SFX_08_54 - SFX_Headers_08) / 3,$33,$30 - db (SFX_08_72 - SFX_Headers_08) / 3,$40,$c0 - db (SFX_08_4e - SFX_Headers_08) / 3,$20,$20 - db (SFX_08_4e - SFX_Headers_08) / 3,$f0,$10 - db (SFX_08_4f - SFX_Headers_08) / 3,$f8,$10 - db (SFX_08_51 - SFX_Headers_08) / 3,$f0,$10 - db (SFX_08_65 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_58 - SFX_Headers_08) / 3,$00,$c0 - db (SFX_08_72 - SFX_Headers_08) / 3,$c0,$ff - db (SFX_08_49 - SFX_Headers_08) / 3,$f2,$20 - db (SFX_08_74 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_74 - SFX_Headers_08) / 3,$00,$40 - db (SFX_08_49 - SFX_Headers_08) / 3,$00,$40 - db (SFX_08_51 - SFX_Headers_08) / 3,$10,$ff - db (SFX_08_6a - SFX_Headers_08) / 3,$20,$20 - db (SFX_08_72 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_69 - SFX_Headers_08) / 3,$1f,$20 - db (SFX_08_65 - SFX_Headers_08) / 3,$2f,$80 - db (SFX_08_4f - SFX_Headers_08) / 3,$1f,$ff - db (SFX_08_6b - SFX_Headers_08) / 3,$1f,$60 - db (SFX_08_66 - SFX_Headers_08) / 3,$1e,$20 - db (SFX_08_66 - SFX_Headers_08) / 3,$1f,$18 - db (SFX_08_54 - SFX_Headers_08) / 3,$0f,$80 - db (SFX_08_49 - SFX_Headers_08) / 3,$f8,$10 - db (SFX_08_48 - SFX_Headers_08) / 3,$18,$20 - db (SFX_08_72 - SFX_Headers_08) / 3,$08,$40 - db (SFX_08_57 - SFX_Headers_08) / 3,$01,$e0 - db (SFX_08_51 - SFX_Headers_08) / 3,$09,$ff - db (SFX_08_75 - SFX_Headers_08) / 3,$42,$01 - db (SFX_08_5c - SFX_Headers_08) / 3,$00,$ff - db (SFX_08_72 - SFX_Headers_08) / 3,$08,$e0 - db (SFX_08_64 - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_49 - SFX_Headers_08) / 3,$88,$10 - db (SFX_08_65 - SFX_Headers_08) / 3,$48,$ff - db (SFX_08_48 - SFX_Headers_08) / 3,$ff,$ff - db (SFX_08_64 - SFX_Headers_08) / 3,$ff,$10 - db (SFX_08_48 - SFX_Headers_08) / 3,$ff,$04 - db (SFX_08_5c - SFX_Headers_08) / 3,$01,$ff - db (SFX_08_53 - SFX_Headers_08) / 3,$f8,$ff - db (SFX_08_4c - SFX_Headers_08) / 3,$f0,$f0 - db (SFX_08_4f - SFX_Headers_08) / 3,$08,$10 - db (SFX_08_4d - SFX_Headers_08) / 3,$f0,$ff - db (SFX_08_5a - SFX_Headers_08) / 3,$f0,$ff - db (SFX_08_74 - SFX_Headers_08) / 3,$10,$ff - db (SFX_08_4e - SFX_Headers_08) / 3,$f0,$20 - db (SFX_08_6b - SFX_Headers_08) / 3,$f0,$60 - db (SFX_08_61 - SFX_Headers_08) / 3,$12,$10 - db (SFX_08_76 - SFX_Headers_08) / 3,$f0,$20 - db (SFX_08_5e - SFX_Headers_08) / 3,$12,$ff - db (SFX_08_71 - SFX_Headers_08) / 3,$80,$04 - db (SFX_08_73 - SFX_Headers_08) / 3,$f0,$10 - db (SFX_08_69 - SFX_Headers_08) / 3,$f8,$ff - db (SFX_08_66 - SFX_Headers_08) / 3,$f0,$ff - db (SFX_08_51 - SFX_Headers_08) / 3,$01,$ff - db (SFX_08_6c - SFX_Headers_08) / 3,$d8,$04 - db (SFX_08_4b - SFX_Headers_08) / 3,$00,$80 - db (SFX_08_4b - SFX_Headers_08) / 3,$00,$80 - -Func_79aae: ; 79aae (1e:5aae) + db SFX_POUND, $00,$80 ; POUND + db SFX_BATTLE_0C, $10,$80 ; KARATE_CHOP + db SFX_DOUBLESLAP, $00,$80 ; DOUBLESLAP + db SFX_BATTLE_0B, $01,$80 ; COMET_PUNCH + db SFX_BATTLE_0D, $00,$40 ; MEGA_PUNCH + db SFX_SILPH_SCOPE, $00,$ff ; PAY_DAY + db SFX_BATTLE_0D, $10,$60 ; FIRE_PUNCH + db SFX_BATTLE_0D, $20,$80 ; ICE_PUNCH + db SFX_BATTLE_0D, $00,$a0 ; THUNDERPUNCH + db SFX_DAMAGE, $00,$80 ; SCRATCH + db SFX_BATTLE_0F, $20,$40 ; VICEGRIP + db SFX_BATTLE_0F, $00,$80 ; GUILLOTINE + db SFX_BATTLE_0E, $00,$a0 ; RAZOR_WIND + db SFX_NOT_VERY_EFFECTIVE,$10,$c0 ; SWORDS_DANCE + db SFX_NOT_VERY_EFFECTIVE,$00,$a0 ; CUT + db SFX_BATTLE_12, $00,$c0 ; GUST + db SFX_BATTLE_12, $10,$a0 ; WING_ATTACK + db SFX_BATTLE_13, $00,$e0 ; WHIRLWIND + db SFX_NOT_VERY_EFFECTIVE,$20,$c0 ; FLY + db SFX_BATTLE_14, $00,$80 ; BIND + db SFX_BATTLE_22, $00,$80 ; SLAM + db SFX_VINE_WHIP, $01,$80 ; VINE_WHIP + db SFX_BATTLE_20, $00,$80 ; STOMP + db SFX_BATTLE_17, $f0,$40 ; DOUBLE_KICK + db SFX_SUPER_EFFECTIVE, $00,$80 ; MEGA_KICK + db SFX_BATTLE_17, $00,$80 ; JUMP_KICK + db SFX_BATTLE_21, $10,$80 ; ROLLING_KICK + db SFX_BATTLE_1B, $01,$a0 ; SAND_ATTACK + db SFX_BATTLE_18, $00,$80 ; HEADBUTT + db SFX_BATTLE_1E, $00,$60 ; HORN_ATTACK + db SFX_BATTLE_1E, $01,$40 ; FURY_ATTACK + db SFX_HORN_DRILL, $00,$a0 ; HORN_DRILL + db SFX_SUPER_EFFECTIVE, $10,$a0 ; TACKLE + db SFX_BATTLE_20, $00,$c0 ; BODY_SLAM + db SFX_BATTLE_14, $10,$60 ; WRAP + db SFX_SUPER_EFFECTIVE, $00,$a0 ; TAKE_DOWN + db SFX_BATTLE_22, $11,$c0 ; THRASH + db SFX_SUPER_EFFECTIVE, $20,$c0 ; DOUBLE_EDGE + db SFX_BATTLE_21, $00,$80 ; TAIL_WHIP + db SFX_BATTLE_1B, $00,$80 ; POISON_STING + db SFX_BATTLE_1B, $20,$c0 ; TWINEEDLE + db SFX_BATTLE_19, $00,$80 ; PIN_MISSILE + db SFX_BATTLE_31, $ff,$40 ; LEER + db SFX_BATTLE_1E, $00,$80 ; BITE + db SFX_BATTLE_0B, $00,$c0 ; GROWL + db SFX_BATTLE_0B, $00,$40 ; ROAR + db SFX_BATTLE_35, $00,$80 ; SING + db SFX_BATTLE_27, $40,$60 ; SUPERSONIC + db SFX_BATTLE_27, $00,$80 ; SONICBOOM + db SFX_BATTLE_27, $ff,$40 ; DISABLE + db SFX_BATTLE_2A, $80,$c0 ; ACID + db SFX_BATTLE_19, $10,$a0 ; EMBER + db SFX_BATTLE_19, $21,$e0 ; FLAMETHROWER + db SFX_BATTLE_29, $00,$80 ; MIST + db SFX_BATTLE_24, $20,$60 ; WATER_GUN + db SFX_BATTLE_2A, $00,$80 ; HYDRO_PUMP + db SFX_BATTLE_2C, $00,$80 ; SURF + db SFX_BATTLE_28, $40,$80 ; ICE_BEAM + db SFX_BATTLE_29, $f0,$e0 ; BLIZZARD + db SFX_PSYBEAM, $00,$80 ; PSYBEAM + db SFX_BATTLE_2A, $f0,$60 ; BUBBLEBEAM + db SFX_BATTLE_28, $00,$80 ; AURORA_BEAM + db SFX_BATTLE_36, $00,$80 ; HYPER_BEAM + db SFX_PECK,$01, $a0 ; PECK + db SFX_BATTLE_13, $f0,$20 ; DRILL_PECK + db SFX_BATTLE_23, $01,$c0 ; SUBMISSION + db SFX_BATTLE_23, $00,$80 ; LOW_KICK + db SFX_SUPER_EFFECTIVE, $00,$e0 ; COUNTER + db SFX_BATTLE_26, $01,$60 ; SEISMIC_TOSS + db SFX_BATTLE_26, $20,$40 ; STRENGTH + db SFX_BATTLE_24, $00,$80 ; ABSORB + db SFX_BATTLE_24, $40,$c0 ; MEGA_DRAIN + db SFX_BATTLE_1B, $03,$60 ; LEECH_SEED + db SFX_BATTLE_25, $11,$e0 ; GROWTH + db SFX_BATTLE_12, $20,$e0 ; RAZOR_LEAF + db SFX_BATTLE_2E, $00,$80 ; SOLARBEAM + db SFX_BATTLE_1C, $00,$80 ; POISONPOWDER + db SFX_BATTLE_1C, $11,$a0 ; STUN_SPORE + db SFX_BATTLE_1C, $01,$c0 ; SLEEP_POWDER + db SFX_BATTLE_13, $14,$c0 ; PETAL_DANCE + db SFX_BATTLE_1B, $02,$a0 ; STRING_SHOT + db SFX_BATTLE_29, $f0,$80 ; DRAGON_RAGE + db SFX_BATTLE_29, $20,$c0 ; FIRE_SPIN + db SFX_BATTLE_2F, $00,$20 ; THUNDERSHOCK + db SFX_BATTLE_2F, $20,$80 ; THUNDERBOLT + db SFX_BATTLE_2E, $12,$60 ; THUNDER_WAVE + db SFX_BATTLE_26, $00,$80 ; THUNDER + db SFX_BATTLE_14, $01,$e0 ; ROCK_THROW + db SFX_BATTLE_29, $0f,$e0 ; EARTHQUAKE + db SFX_BATTLE_29, $11,$20 ; FISSURE + db SFX_DAMAGE, $10,$40 ; DIG + db SFX_BATTLE_0F, $10,$c0 ; TOXIC + db SFX_BATTLE_14, $00,$20 ; CONFUSION + db SFX_PSYCHIC_M, $00,$80 ; PSYCHIC_M + db SFX_BATTLE_35, $11,$18 ; HYPNOSIS + db SFX_BATTLE_09, $20,$c0 ; MEDITATE + db SFX_FAINT_FALL, $20,$c0 ; AGILITY + db SFX_BATTLE_25, $00,$10 ; QUICK_ATTACK + db SFX_BATTLE_26, $f0,$20 ; RAGE + db SFX_BATTLE_33, $f0,$c0 ; TELEPORT + db SFX_NOT_VERY_EFFECTIVE,$f0,$e0 ; NIGHT_SHADE + db SFX_BATTLE_09, $f0,$40 ; MIMIC + db SFX_BATTLE_31, $00,$80 ; SCREECH + db SFX_BATTLE_33, $80,$40 ; DOUBLE_TEAM + db SFX_BATTLE_33, $00,$80 ; RECOVER + db SFX_BATTLE_14, $11,$20 ; HARDEN + db SFX_BATTLE_14, $22,$10 ; MINIMIZE + db SFX_BATTLE_1B, $f1,$ff ; SMOKESCREEN + db SFX_BATTLE_13, $f1,$ff ; CONFUSE_RAY + db SFX_BATTLE_14, $33,$30 ; WITHDRAW + db SFX_BATTLE_32, $40,$c0 ; DEFENSE_CURL + db SFX_BATTLE_0E, $20,$20 ; BARRIER + db SFX_BATTLE_0E, $f0,$10 ; LIGHT_SCREEN + db SFX_BATTLE_0F, $f8,$10 ; HAZE + db SFX_NOT_VERY_EFFECTIVE,$f0,$10 ; REFLECT + db SFX_BATTLE_25, $00,$80 ; FOCUS_ENERGY + db SFX_BATTLE_18, $00,$c0 ; BIDE + db SFX_BATTLE_32, $c0,$ff ; METRONOME + db SFX_BATTLE_09, $f2,$20 ; MIRROR_MOVE + db SFX_BATTLE_34, $00,$80 ; SELFDESTRUCT + db SFX_BATTLE_34, $00,$40 ; EGG_BOMB + db SFX_BATTLE_09, $00,$40 ; LICK + db SFX_NOT_VERY_EFFECTIVE,$10,$ff ; SMOG + db SFX_BATTLE_2A, $20,$20 ; SLUDGE + db SFX_BATTLE_32, $00,$80 ; BONE_CLUB + db SFX_BATTLE_29, $1f,$20 ; FIRE_BLAST + db SFX_BATTLE_25, $2f,$80 ; WATERFALL + db SFX_BATTLE_0F, $1f,$ff ; CLAMP + db SFX_BATTLE_2B, $1f,$60 ; SWIFT + db SFX_BATTLE_26, $1e,$20 ; SKULL_BASH + db SFX_BATTLE_26, $1f,$18 ; SPIKE_CANNON + db SFX_BATTLE_14, $0f,$80 ; CONSTRICT + db SFX_BATTLE_09, $f8,$10 ; AMNESIA + db SFX_FAINT_FALL, $18,$20 ; KINESIS + db SFX_BATTLE_32, $08,$40 ; SOFTBOILED + db SFX_BATTLE_17, $01,$e0 ; HI_JUMP_KICK + db SFX_NOT_VERY_EFFECTIVE,$09,$ff ; GLARE + db SFX_BATTLE_35, $42,$01 ; DREAM_EATER + db SFX_BATTLE_1C, $00,$ff ; POISON_GAS + db SFX_BATTLE_32, $08,$e0 ; BARRAGE + db SFX_BATTLE_24, $00,$80 ; LEECH_LIFE + db SFX_BATTLE_09, $88,$10 ; LOVELY_KISS + db SFX_BATTLE_25, $48,$ff ; SKY_ATTACK + db SFX_FAINT_FALL, $ff,$ff ; TRANSFORM + db SFX_BATTLE_24, $ff,$10 ; BUBBLE + db SFX_FAINT_FALL, $ff,$04 ; DIZZY_PUNCH + db SFX_BATTLE_1C, $01,$ff ; SPORE + db SFX_BATTLE_13, $f8,$ff ; FLASH + db SFX_BATTLE_0C, $f0,$f0 ; PSYWAVE + db SFX_BATTLE_0F, $08,$10 ; SPLASH + db SFX_BATTLE_0D, $f0,$ff ; ACID_ARMOR + db SFX_SUPER_EFFECTIVE, $f0,$ff ; CRABHAMMER + db SFX_BATTLE_34, $10,$ff ; EXPLOSION + db SFX_BATTLE_0E, $f0,$20 ; FURY_SWIPES + db SFX_BATTLE_2B, $f0,$60 ; BONEMERANG + db SFX_BATTLE_21, $12,$10 ; REST + db SFX_BATTLE_36, $f0,$20 ; ROCK_SLIDE + db SFX_BATTLE_1E, $12,$ff ; HYPER_FANG + db SFX_BATTLE_31, $80,$04 ; SHARPEN + db SFX_BATTLE_33, $f0,$10 ; CONVERSION + db SFX_BATTLE_29, $f8,$ff ; TRI_ATTACK + db SFX_BATTLE_26, $f0,$ff ; SUPER_FANG + db SFX_NOT_VERY_EFFECTIVE,$01,$ff ; SLASH + db SFX_BATTLE_2C, $d8,$04 ; SUBSTITUTE + db SFX_BATTLE_0B, $00,$80 ; STRUGGLE + db SFX_BATTLE_0B, $00,$80 + +CopyPicTiles: ; 79aae (1e:5aae) ld a, [H_WHOSETURN] and a ld a, $31 ; base tile ID of player mon sprite - jr z, .asm_79ab6 + jr z, .next ; enemy turn xor a ; base tile ID of enemy mon sprite -.asm_79ab6 +.next ld [hBaseTileID], a - jr asm_79acb + jr CopyTileIDs_NoBGTransfer -Func_79aba: ; 79aba (1e:5aba) +; copy the tiles used when a mon is being sent out of or into a pokeball +CopyDownscaledMonTiles: ; 79aba (1e:5aba) call GetPredefRegisters - ld a, [wcd6c] + ld a, [wDownscaledMonSize] and a - jr nz, .asm_79ac8 - ld de, Unknown_79b02 ; $5b02 - jr asm_79acb -.asm_79ac8 - ld de, Unknown_79b1b ; $5b1b -asm_79acb: ; 79acb (1e:5acb) + jr nz, .smallerSize + ld de, DownscaledMonTiles_5x5 + jr CopyTileIDs_NoBGTransfer +.smallerSize + ld de, DownscaledMonTiles_3x3 +; fall through + +CopyTileIDs_NoBGTransfer: ; 79acb (1e:5acb) xor a ld [H_AUTOBGTRANSFERENABLED], a +; fall through ; b = number of rows ; c = number of columns @@ -2557,14 +2598,14 @@ TileIDListPointerTable: ; 79aea (1e:5aea) dw Unknown_79c50 db $3C -Unknown_79b02: ; 79b02 (1e:5b02) +DownscaledMonTiles_5x5: ; 79b02 (1e:5b02) db $31,$38,$46,$54,$5B db $32,$39,$47,$55,$5C db $34,$3B,$49,$57,$5E db $36,$3D,$4B,$59,$60 db $37,$3E,$4C,$5A,$61 -Unknown_79b1b: ; 79b1b (1e:5b1b) +DownscaledMonTiles_3x3: ; 79b1b (1e:5b1b) db $31,$46,$5B db $34,$49,$5E db $37,$4C,$61 @@ -2635,130 +2676,135 @@ Unknown_79c50: ; 79c50 (1e:5c50) AnimationLeavesFalling: ; 79c74 (1e:5c74) ; Makes leaves float down from the top of the screen. This is used ; in Razor Leaf's animation. - ld a, [$ff48] + ld a, [rOBP0] push af - ld a, [wcc79] - ld [$ff48], a - ld d, $37 - ld a, $3 - ld [W_SUBANIMTRANSFORM], a - call Func_79c97 + ld a, [wAnimPalette] + ld [rOBP0], a + ld d, $37 ; leaf tile + ld a, 3 ; number of leaves + ld [wNumFallingObjects], a + call AnimationFallingObjects pop af - ld [$ff48], a + ld [rOBP0], a ret AnimationPetalsFalling: ; 79c8a (1e:5c8a) ; Makes lots of petals fall down from the top of the screen. It's used in ; the animation for Petal Dance. - ld d, $71 - ld a, $14 - ld [W_SUBANIMTRANSFORM], a - call Func_79c97 + ld d, $71 ; petal tile + ld a, 20 ; number of petals + ld [wNumFallingObjects], a + call AnimationFallingObjects jp ClearSprites -Func_79c97: ; 79c97 (1e:5c97) +AnimationFallingObjects: ; 79c97 (1e:5c97) ld c, a - ld a, $1 - call Func_797e8 - call Func_79d2a - call Func_79d52 + ld a, 1 + call InitMultipleObjectsOAM + call FallingObjects_InitXCoords + call FallingObjects_InitMovementData ld hl, wOAMBuffer - ld [hl], $0 -.asm_79ca8 - ld hl, wTrainerSpriteOffset - ld de, $0000 - ld a, [W_SUBANIMTRANSFORM] + ld [hl], 0 +.loop + ld hl, wFallingObjectsMovementData + ld de, 0 + ld a, [wNumFallingObjects] ld c, a -.asm_79cb2 +.innerLoop push bc push hl push de ld a, [hl] - ld [wd08a], a - call Func_79d16 - call Func_79cdb + ld [wFallingObjectMovementByte], a + call FallingObjects_UpdateMovementByte + call FallingObjects_UpdateOAMEntry pop de - ld hl, $0004 + ld hl, 4 add hl, de ld e, l ld d, h pop hl - ld a, [wd08a] + ld a, [wFallingObjectMovementByte] ld [hli], a pop bc dec c - jr nz, .asm_79cb2 + jr nz, .innerLoop call Delay3 ld hl, wOAMBuffer - ld a, [hl] - cp $68 - jr nz, .asm_79ca8 + ld a, [hl] ; Y + cp 104 ; has the top falling object reached 104 yet? + jr nz, .loop ; keep moving the falling objects down until it does ret -Func_79cdb: ; 79cdb (1e:5cdb) +FallingObjects_UpdateOAMEntry: ; 79cdb (1e:5cdb) +; Increases Y by 2 pixels and adjusts X and X flip based on the falling object's +; movement byte. ld hl, wOAMBuffer add hl, de ld a, [hl] inc a inc a - cp $70 - jr c, .asm_79ce8 - ld a, $a0 -.asm_79ce8 - ld [hli], a - ld a, [wd08a] + cp 112 + jr c, .next + ld a, 160 ; if Y >= 112, put it off-screen +.next + ld [hli], a ; Y + ld a, [wFallingObjectMovementByte] ld b, a - ld de, Unknown_79d0d + ld de, FallingObjects_DeltaXs and $7f add e - jr nc, .asm_79cf6 + jr nc, .noCarry inc d -.asm_79cf6 +.noCarry ld e, a ld a, b and $80 - jr nz, .asm_79d03 + jr nz, .movingLeft +; moving right ld a, [de] add [hl] - ld [hli], a + ld [hli], a ; X inc hl - xor a - jr .asm_79d0b -.asm_79d03 + xor a ; no horizontal flip + jr .next2 +.movingLeft ld a, [de] ld b, a ld a, [hl] sub b - ld [hli], a + ld [hli], a ; X inc hl - ld a, $20 -.asm_79d0b - ld [hl], a + ld a, (1 << OAM_X_FLIP) +.next2 + ld [hl], a ; attribute ret -Unknown_79d0d: ; 79d0d (1e:5d0d) - db $00,$01,$03,$05,$07,$09,$0B,$0D,$0F +FallingObjects_DeltaXs: ; 79d0d (1e:5d0d) + db 0, 1, 3, 5, 7, 9, 11, 13, 15 -Func_79d16: ; 79d16 (1e:5d16) - ld a, [wd08a] +FallingObjects_UpdateMovementByte: ; 79d16 (1e:5d16) + ld a, [wFallingObjectMovementByte] inc a ld b, a and $7f - cp $9 + cp 9 ; have we reached the end of the delta-Xs? ld a, b - jr nz, .asm_79d26 + jr nz, .next +; We've reached the end of the delta-Xs, so wrap to the start and change +; direction from right to left or vice versa. and $80 xor $80 -.asm_79d26 - ld [wd08a], a +.next + ld [wFallingObjectMovementByte], a ret -Func_79d2a: ; 79d2a (1e:5d2a) +FallingObjects_InitXCoords: ; 79d2a (1e:5d2a) ld hl, wOAMBuffer + $01 - ld de, Unknown_79d3e - ld a, [W_SUBANIMTRANSFORM] + ld de, FallingObjects_InitialXCoords + ld a, [wNumFallingObjects] ld c, a -.asm_79d34 +.loop ld a, [de] ld [hli], a inc hl @@ -2766,66 +2812,98 @@ Func_79d2a: ; 79d2a (1e:5d2a) inc hl inc de dec c - jr nz, .asm_79d34 + jr nz, .loop ret -Unknown_79d3e: ; 79d3e (1e:5d3e) +FallingObjects_InitialXCoords: ; 79d3e (1e:5d3e) db $38,$40,$50,$60,$70,$88,$90,$56,$67,$4A,$77,$84,$98,$32,$22,$5C,$6C,$7D,$8E,$99 -Func_79d52: ; 79d52 (1e:5d52) - ld hl, wTrainerSpriteOffset - ld de, Unknown_79d63 - ld a, [W_SUBANIMTRANSFORM] +FallingObjects_InitMovementData: ; 79d52 (1e:5d52) + ld hl, wFallingObjectsMovementData + ld de, FallingObjects_InitialMovementData + ld a, [wNumFallingObjects] ld c, a -.asm_79d5c +.loop ld a, [de] ld [hli], a inc de dec c - jr nz, .asm_79d5c + jr nz, .loop ret -Unknown_79d63: ; 79d63 (1e:5d63) +FallingObjects_InitialMovementData: ; 79d63 (1e:5d63) db $00,$84,$06,$81,$02,$88,$01,$83,$05,$89,$09,$80,$07,$87,$03,$82,$04,$85,$08,$86 AnimationShakeEnemyHUD: ; 79d77 (1e:5d77) +; Shakes the enemy HUD. + +; Make a copy of the back pic's tile patterns in sprite tile pattern VRAM. ld de, vBackPic ld hl, vSprites ld bc, 7 * 7 call CopyVideoData + xor a ld [hSCX], a + +; Copy wTileMap to BG map 0. The regular BG (not the window) is set to use +; map 0 and can be scrolled with SCX, which allows a shaking effect. ld hl, vBGMap0 - call Func_79e0d - ld a, $90 + call BattleAnimCopyTileMapToVRAM + +; Now that the regular BG is showing the same thing the window was, move the +; window off the screen so that we can modify its contents below. + ld a, SCREEN_HEIGHT_PIXELS ld [hWY], a - ld hl, vBGMap0 + $320 - call Func_79e0d - ld a, $38 + +; Copy wTileMap to VRAM such that the row below the enemy HUD (in wTileMap) is +; lined up with row 0 of the window. + ld hl, vBGMap1 - $20 * 7 + call BattleAnimCopyTileMapToVRAM + +; Move the window so that the row below the enemy HUD (in BG map 0) lines up +; with the top row of the window on the screen. This makes it so that the window +; covers everything below the enemy HD with a copy that looks just like what +; was there before. + ld a, 7 * 8 ld [hWY], a - call Func_792fd + +; Write OAM entries so that the copy of the back pic from the top of this +; function shows up on screen. We need this because the back pic's Y coordinates +; range overlaps with that of the enemy HUD and we don't want to shake the top +; of the back pic when we shake the enemy HUD. The OAM copy won't be affected +; by SCX. + call ShakeEnemyHUD_WritePlayerMonPicOAM + ld hl, vBGMap0 - call Func_79e0d + call BattleAnimCopyTileMapToVRAM + +; Remove the back pic from the BG map. call AnimationHideMonPic call Delay3 - ld de, $0208 - call Func_79de9 + +; Use SCX to shake the regular BG. The window and the back pic OAM copy are +; not affected. + lb de, 2, 8 + call ShakeEnemyHUD_ShakeBG + +; Restore the original graphics. call AnimationShowMonPic call ClearSprites - ld a, $90 + ld a, SCREEN_HEIGHT_PIXELS ld [hWY], a ld hl, vBGMap1 - call Func_79e0d + call BattleAnimCopyTileMapToVRAM xor a ld [hWY], a call SaveScreenTilesToBuffer1 ld hl, vBGMap0 - call Func_79e0d + call BattleAnimCopyTileMapToVRAM call ClearScreen call Delay3 call LoadScreenTilesFromBuffer1 ld hl, vBGMap1 - jp Func_79e0d + jp BattleAnimCopyTileMapToVRAM ; b = tile ID list index ; c = base tile ID @@ -2839,29 +2917,29 @@ CopyTileIDsFromList: ; 79dda (1e:5dda) pop hl jp CopyTileIDs -Func_79de9: ; 79de9 (1e:5de9) +ShakeEnemyHUD_ShakeBG: ; 79de9 (1e:5de9) ld a, [hSCX] - ld [wTrainerSpriteOffset], a -.asm_79dee - ld a, [wTrainerSpriteOffset] + ld [wTempSCX], a +.loop + ld a, [wTempSCX] add d ld [hSCX], a - ld c, $2 + ld c, 2 call DelayFrames - ld a, [wTrainerSpriteOffset] + ld a, [wTempSCX] sub d ld [hSCX], a - ld c, $2 + ld c, 2 call DelayFrames dec e - jr nz, .asm_79dee - ld a, [wTrainerSpriteOffset] + jr nz, .loop + ld a, [wTempSCX] ld [hSCX], a ret -Func_79e0d: ; 79e0d (1e:5e0d) +BattleAnimCopyTileMapToVRAM: ; 79e0d (1e:5e0d) ld a, h - ld [$ffbd], a + ld [H_AUTOBGTRANSFERDEST + 1], a ld a, l ld [H_AUTOBGTRANSFERDEST], a jp Delay3 @@ -2870,7 +2948,7 @@ TossBallAnimation: ; 79e16 (1e:5e16) ld a,[W_ISINBATTLE] cp a,2 jr z,.BlockBall ; if in trainer battle, play different animation - ld a,[wd11e] + ld a,[wPokeBallAnimData] ld b,a ; upper nybble: how many animations (from PokeBallAnimations) to play @@ -2883,7 +2961,7 @@ TossBallAnimation: ; 79e16 (1e:5e16) ; store these for later ld a,b and a,$F - ld [wWhichTrade],a + ld [wNumShakes],a ld hl,.PokeBallAnimations ; choose which toss animation to use @@ -2917,8 +2995,8 @@ TossBallAnimation: ; 79e16 (1e:5e16) ld a,TOSS_ANIM ld [W_ANIMATIONID],a call PlayAnimation - ld a,(SFX_08_43 - SFX_Headers_08) / 3 - call PlaySound ; play sound effect + ld a,SFX_FAINT_THUD + call PlaySound ld a,BLOCKBALL_ANIM ld [W_ANIMATIONID],a jp PlayAnimation @@ -2930,21 +3008,21 @@ PlayApplyingAttackSound: ; 79e6a (1e:5e6a) ld a, [wDamageMultipliers] and $7f ret z - cp $a + cp 10 ld a, $20 ld b, $30 - ld c, (SFX_08_50 - SFX_Headers_08) / 3 - jr z, .asm_79e8b + ld c, SFX_DAMAGE + jr z, .playSound ld a, $e0 ld b, $ff - ld c, (SFX_08_5a - SFX_Headers_08) / 3 - jr nc, .asm_79e8b + ld c, SFX_SUPER_EFFECTIVE + jr nc, .playSound ld a, $50 ld b, $1 - ld c, (SFX_08_51 - SFX_Headers_08) / 3 -.asm_79e8b - ld [wc0f1], a + ld c, SFX_NOT_VERY_EFFECTIVE +.playSound + ld [wFrequencyModifier], a ld a, b - ld [wc0f2], a + ld [wTempoModifier], a ld a, c jp PlaySound diff --git a/engine/battle/bank_e_misc.asm b/engine/battle/bank_e_misc.asm index 6ef4065f..dc766f23 100755 --- a/engine/battle/bank_e_misc.asm +++ b/engine/battle/bank_e_misc.asm @@ -24,7 +24,7 @@ FormatMovesString: ; 39b87 (e:5b87) jr .copyNameLoop .doneCopyingName ld a, b - ld [wcd6c], a + ld [wNumMovesMinusOne], a inc b ld a, $4e ; line break ld [de], a @@ -52,49 +52,49 @@ FormatMovesString: ; 39b87 (e:5b87) ret ; XXX this is called in a few places, but it doesn't appear to do anything useful -Func_39bd5: ; 39bd5 (e:5bd5) - ld a, [wd11b] - cp $1 - jr nz, .asm_39be6 +InitList: ; 39bd5 (e:5bd5) + ld a, [wInitListType] + cp INIT_ENEMYOT_LIST + jr nz, .notEnemy ld hl, wEnemyPartyCount ld de, wEnemyMonOT ld a, ENEMYOT_NAME - jr .asm_39c18 -.asm_39be6 - cp $4 - jr nz, .calcAttackStat4 + jr .done +.notEnemy + cp INIT_PLAYEROT_LIST + jr nz, .notPlayer ld hl, wPartyCount ld de, wPartyMonOT ld a, PLAYEROT_NAME - jr .asm_39c18 -.calcAttackStat4 - cp $5 - jr nz, .asm_39c02 - ld hl, wStringBuffer2 + 11 + jr .done +.notPlayer + cp INIT_MON_LIST + jr nz, .notMonster + ld hl, wItemList ld de, MonsterNames ld a, MONSTER_NAME - jr .asm_39c18 -.asm_39c02 - cp $2 - jr nz, .asm_39c10 + jr .done +.notMonster + cp INIT_BAG_ITEM_LIST + jr nz, .notBag ld hl, wNumBagItems ld de, ItemNames ld a, ITEM_NAME - jr .asm_39c18 -.asm_39c10 - ld hl, wStringBuffer2 + 11 + jr .done +.notBag + ld hl, wItemList ld de, ItemNames ld a, ITEM_NAME -.asm_39c18 +.done ld [wNameListType], a ld a, l - ld [wList], a + ld [wListPointer], a ld a, h - ld [wList + 1], a + ld [wListPointer + 1], a ld a, e - ld [wcf8d], a + ld [wUnusedCF8D], a ld a, d - ld [wcf8e], a + ld [wUnusedCF8D + 1], a ld bc, ItemPrices ld a, c ld [wItemPrices], a @@ -102,10 +102,10 @@ Func_39bd5: ; 39bd5 (e:5bd5) ld [wItemPrices + 1], a ret -; get species of mon e in list [wcc49] for LoadMonData +; get species of mon e in list [wMonDataLocation] for LoadMonData GetMonSpecies: ; 39c37 (e:5c37) ld hl, wPartySpecies - ld a, [wcc49] + ld a, [wMonDataLocation] and a jr z, .getSpecies dec a diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm index 4a9ea782..642d457b 100644 --- a/engine/battle/battle_transitions.asm +++ b/engine/battle/battle_transitions.asm @@ -7,10 +7,13 @@ BattleTransition: ; 709d7 (1c:49d7) dec a ld [wUpdateSpritesEnabled], a call DelayFrame + +; Determine which OAM block is being used by the enemy trainer sprite (if there +; is one). ld hl, wSpriteStateData1 + 2 - ld a, [H_DOWNARROWBLINKCNT2] + ld a, [hSpriteIndexOrTextID] ; enemy trainer sprite index (0 if wild battle) ld c, a - ld b, $0 + ld b, 0 ld de, $10 .loop1 ld a, [hl] @@ -21,13 +24,15 @@ BattleTransition: ; 709d7 (1c:49d7) add hl, de dec c jr nz, .loop1 + +; Clear OAM except for the blocks used by the player and enemy trainer sprites. ld hl, wOAMBuffer + $10 - ld c, $9 + ld c, 9 .loop2 ld a, b swap a cp l - jr z, .skip2 + jr z, .skip2 ; skip clearing the block if the enemy trainer is using it push hl push bc ld bc, $10 @@ -40,9 +45,10 @@ BattleTransition: ; 709d7 (1c:49d7) add hl, de dec c jr nz, .loop2 + call Delay3 call LoadBattleTransitionTile - ld bc, $0 + ld bc, 0 ld a, [wLinkState] cp LINK_STATE_BATTLING jr z, .linkBattle @@ -76,7 +82,7 @@ BattleTransitions: ; 70a3c (1c:4a3c) GetBattleTransitionID_WildOrTrainer: ; 70a4c (1c:4a4c) ld a, [W_CUROPPONENT] - cp $c8 + cp 200 jr nc, .trainer res 0, c ret @@ -103,13 +109,13 @@ GetBattleTransitionID_CompareLevels: ; 70a59 (1c:4a59) sub e jr nc, .highLevelEnemy res 1, c - ld a, $1 - ld [wcd47], a + ld a, 1 + ld [wBattleTransitionSpiralDirection], a ret .highLevelEnemy set 1, c xor a - ld [wcd47], a + ld [wBattleTransitionSpiralDirection], a ret ; fails to recognize VICTORY_ROAD_2, VICTORY_ROAD_3, all ROCKET_HIDEOUT maps, @@ -178,11 +184,12 @@ DungeonMaps2: ; 70aac (1c:4aac) LoadBattleTransitionTile: ; 70ab7 (1c:4ab7) ld hl, vChars1 + $7f0 ld de, BattleTransitionTile - ld bc, (BANK(BattleTransitionTile) << 8) + $01 + lb bc, BANK(BattleTransitionTile), (BattleTransitionTileEnd - BattleTransitionTile) / $10 jp CopyVideoData BattleTransitionTile: ; 70ac3 (1c:4ac3) INCBIN "gfx/battle_transition.2bpp" +BattleTransitionTileEnd: BattleTransition_BlackScreen: ; 70ad3 (1c:4ad3) ld a, $ff @@ -198,58 +205,76 @@ BattleTransition_BlackScreen: ; 70ad3 (1c:4ad3) ; called regardless of mon levels, but does an ; outward spiral if enemy is at least 3 levels ; higher than player and does an inward spiral otherwise +<<<<<<< HEAD BattleTransition_Spiral: ; 70ae5 (1c:4ae5) ld a, [wcd47] +======= +BattleTransition_Spiral: ; 70a72 (1c:4a72) + ld a, [wBattleTransitionSpiralDirection] +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a and a jr z, .outwardSpiral call BattleTransition_InwardSpiral jr .done .outwardSpiral - hlCoord 10, 10 + coord hl, 10, 10 ld a, $3 - ld [wd09f], a + ld [wOutwardSpiralCurrentDirection], a ld a, l - ld [wd09b], a + ld [wOutwardSpiralTileMapPointer + 1], a ld a, h - ld [wd09a], a - ld b, $78 -.loop1 - ld c, $3 -.loop2 + ld [wOutwardSpiralTileMapPointer], a + ld b, 120 +.loop + ld c, 3 +.innerLoop push bc call BattleTransition_OutwardSpiral_ pop bc dec c - jr nz, .loop2 + jr nz, .innerLoop call DelayFrame dec b - jr nz, .loop1 + jr nz, .loop .done call BattleTransition_BlackScreen xor a - ld [wd09b], a - ld [wd09a], a + ld [wOutwardSpiralTileMapPointer + 1], a + ld [wOutwardSpiralTileMapPointer], a ret +<<<<<<< HEAD BattleTransition_InwardSpiral: ; 70b1d (1c:4b1d) ld a, $7 ld [wWhichTrade], a ld hl, wTileMap ld c, $11 ld de, $14 +======= +BattleTransition_InwardSpiral: ; 70aaa (1c:4aaa) + ld a, 7 + ld [wInwardSpiralUpdateScreenCounter], a + coord hl, 0, 0 + ld c, SCREEN_HEIGHT - 1 + ld de, SCREEN_WIDTH +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a call BattleTransition_InwardSpiral_ inc c jr .skip .loop - ld de, $14 + ld de, SCREEN_WIDTH call BattleTransition_InwardSpiral_ .skip inc c - ld de, $1 + ld de, 1 call BattleTransition_InwardSpiral_ dec c dec c +<<<<<<< HEAD ld de, -$14 +======= + ld de, -SCREEN_WIDTH +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a call BattleTransition_InwardSpiral_ inc c ld de, -1 @@ -267,85 +292,92 @@ BattleTransition_InwardSpiral_: ; 70b53 (1c:4b53) ld [hl], $ff add hl, de push bc - ld a, [wWhichTrade] + ld a, [wInwardSpiralUpdateScreenCounter] dec a jr nz, .skip call BattleTransition_TransferDelay3 - ld a, $7 + ld a, 7 .skip - ld [wWhichTrade], a + ld [wInwardSpiralUpdateScreenCounter], a pop bc dec c jr nz, .loop pop bc ret +<<<<<<< HEAD BattleTransition_OutwardSpiral_: ; 70b6c (1c:4b6c) ld bc, -$14 ld de, $14 ld a, [wd09b] +======= +BattleTransition_OutwardSpiral_: ; 70af9 (1c:4af9) + ld bc, -SCREEN_WIDTH + ld de, SCREEN_WIDTH + ld a, [wOutwardSpiralTileMapPointer + 1] +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a ld l, a - ld a, [wd09a] + ld a, [wOutwardSpiralTileMapPointer] ld h, a - ld a, [wd09f] + ld a, [wOutwardSpiralCurrentDirection] cp $0 - jr z, .zero + jr z, .up cp $1 - jr z, .one + jr z, .left cp $2 - jr z, .two + jr z, .down cp $3 - jr z, .three -.done1 + jr z, .right +.keepSameDirection ld [hl], $ff -.done2_ +.done ld a, l - ld [wd09b], a + ld [wOutwardSpiralTileMapPointer + 1], a ld a, h - ld [wd09a], a + ld [wOutwardSpiralTileMapPointer], a ret -.zero +.up dec hl ld a, [hl] cp $ff - jr nz, .done2 + jr nz, .changeDirection inc hl add hl, bc - jr .done1 -.one + jr .keepSameDirection +.left add hl, de ld a, [hl] cp $ff - jr nz, .done2 + jr nz, .changeDirection add hl, bc dec hl - jr .done1 -.two + jr .keepSameDirection +.down inc hl ld a, [hl] cp $ff - jr nz, .done2 + jr nz, .changeDirection dec hl add hl, de - jr .done1 -.three + jr .keepSameDirection +.right add hl, bc ld a, [hl] cp $ff - jr nz, .done2 + jr nz, .changeDirection add hl, de inc hl - jr .done1 -.done2 + jr .keepSameDirection +.changeDirection ld [hl], $ff - ld a, [wd09f] + ld a, [wOutwardSpiralCurrentDirection] inc a cp $4 jr nz, .skip xor a .skip - ld [wd09f], a - jr .done2_ + ld [wOutwardSpiralCurrentDirection], a + jr .done FlashScreen: BattleTransition_FlashScreen_: ; 70be8 (1c:4be8s) @@ -355,8 +387,12 @@ BattleTransition_FlashScreen_: ; 70be8 (1c:4be8s) cp $1 jr z, .done ld [rBGP], a +<<<<<<< HEAD call Func_3021 ld c, $2 +======= + ld c, 2 +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a call DelayFrames jr .loop .done @@ -369,61 +405,95 @@ BattleTransition_FlashScreenPalettes: ; 70be8 (1c:4be8) db $01 ; terminator ; used for low level trainer dungeon battles +<<<<<<< HEAD BattleTransition_Shrink: ; 70bf4 (1c:4bf4) ld c, $9 +======= +BattleTransition_Shrink: ; 70b7f (1c:4b7f) + ld c, SCREEN_HEIGHT / 2 +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a .loop push bc xor a ld [H_AUTOBGTRANSFERENABLED], a +<<<<<<< HEAD hlCoord 0, 7 deCoord 0, 8 ld bc, -$28 +======= + coord hl, 0, 7 + coord de, 0, 8 + ld bc, -SCREEN_WIDTH * 2 +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a call BattleTransition_CopyTiles1 - hlCoord 0, 10 - deCoord 0, 9 - ld bc, $28 + coord hl, 0, 10 + coord de, 0, 9 + ld bc, SCREEN_WIDTH * 2 call BattleTransition_CopyTiles1 +<<<<<<< HEAD hlCoord 8, 0 deCoord 9, 0 ld bc, -$2 +======= + coord hl, 8, 0 + coord de, 9, 0 + ld bc, -2 +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a call BattleTransition_CopyTiles2 - hlCoord 11, 0 - deCoord 10, 0 - ld bc, $2 + coord hl, 11, 0 + coord de, 10, 0 + ld bc, 2 call BattleTransition_CopyTiles2 ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - ld c, $6 + ld c, 6 call DelayFrames pop bc dec c jr nz, .loop call BattleTransition_BlackScreen - ld c, $a + ld c, 10 jp DelayFrames ; used for high level trainer dungeon battles +<<<<<<< HEAD BattleTransition_Split: ; 70c40 (1c:4c40) ld c, $9 +======= +BattleTransition_Split: ; 70bca (1c:4bca) + ld c, SCREEN_HEIGHT / 2 +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a xor a ld [H_AUTOBGTRANSFERENABLED], a .loop push bc +<<<<<<< HEAD hlCoord 0, 16 deCoord 0, 17 ld bc, -$28 +======= + coord hl, 0, 16 + coord de, 0, 17 + ld bc, -SCREEN_WIDTH * 2 +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a call BattleTransition_CopyTiles1 - hlCoord 0, 1 - ld de, wTileMap - ld bc, $28 + coord hl, 0, 1 + coord de, 0, 0 + ld bc, SCREEN_WIDTH * 2 call BattleTransition_CopyTiles1 +<<<<<<< HEAD hlCoord 18, 0 deCoord 19, 0 ld bc, -$2 +======= + coord hl, 18, 0 + coord de, 19, 0 + ld bc, -2 +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a call BattleTransition_CopyTiles2 - hlCoord 1, 0 - ld de, wTileMap - ld bc, $2 + coord hl, 1, 0 + coord de, 0, 0 + ld bc, 2 call BattleTransition_CopyTiles2 call BattleTransition_TransferDelay3 call Delay3 @@ -431,26 +501,26 @@ BattleTransition_Split: ; 70c40 (1c:4c40) dec c jr nz, .loop call BattleTransition_BlackScreen - ld c, $a + ld c, 10 jp DelayFrames BattleTransition_CopyTiles1: ; 70c88 (1c:4c88) ld a, c - ld [wWhichTrade], a + ld [wBattleTransitionCopyTilesOffset], a ld a, b - ld [wTrainerEngageDistance], a - ld c, $8 + ld [wBattleTransitionCopyTilesOffset + 1], a + ld c, 8 .loop1 push bc push hl push de - ld bc, $14 + ld bc, SCREEN_WIDTH call CopyData pop hl pop de - ld a, [wWhichTrade] + ld a, [wBattleTransitionCopyTilesOffset] ld c, a - ld a, [wTrainerEngageDistance] + ld a, [wBattleTransitionCopyTilesOffset + 1] ld b, a add hl, bc pop bc @@ -459,7 +529,7 @@ BattleTransition_CopyTiles1: ; 70c88 (1c:4c88) ld l, e ld h, d ld a, $ff - ld c, $14 + ld c, SCREEN_WIDTH .loop2 ld [hli], a dec c @@ -468,26 +538,26 @@ BattleTransition_CopyTiles1: ; 70c88 (1c:4c88) BattleTransition_CopyTiles2: ; 70cb5 (1c:4c3f) ld a, c - ld [wWhichTrade], a + ld [wBattleTransitionCopyTilesOffset], a ld a, b - ld [wTrainerEngageDistance], a - ld c, $9 + ld [wBattleTransitionCopyTilesOffset + 1], a + ld c, SCREEN_HEIGHT / 2 .loop1 push bc push hl push de - ld c, $12 + ld c, SCREEN_HEIGHT .loop2 ld a, [hl] ld [de], a ld a, e - add $14 + add SCREEN_WIDTH jr nc, .noCarry1 inc d .noCarry1 ld e, a ld a, l - add $14 + add SCREEN_WIDTH jr nc, .noCarry2 inc h .noCarry2 @@ -496,9 +566,9 @@ BattleTransition_CopyTiles2: ; 70cb5 (1c:4c3f) jr nz, .loop2 pop hl pop de - ld a, [wWhichTrade] + ld a, [wBattleTransitionCopyTilesOffset] ld c, a - ld a, [wTrainerEngageDistance] + ld a, [wBattleTransitionCopyTilesOffset + 1] ld b, a add hl, bc pop bc @@ -506,8 +576,8 @@ BattleTransition_CopyTiles2: ; 70cb5 (1c:4c3f) jr nz, .loop1 ld l, e ld h, d - ld de, $14 - ld c, $12 + ld de, SCREEN_WIDTH + ld c, SCREEN_HEIGHT .loop3 ld [hl], $ff add hl, de @@ -516,10 +586,17 @@ BattleTransition_CopyTiles2: ; 70cb5 (1c:4c3f) ret ; used for high level wild dungeon battles +<<<<<<< HEAD BattleTransition_VerticalStripes: ; 70cf4 (1c:4cf4) ld c, $12 ld hl, wTileMap deCoord 1, 17 +======= +BattleTransition_VerticalStripes: ; 70c7e (1c:4c7e) + ld c, SCREEN_HEIGHT + coord hl, 0, 0 + coord de, 1, 17 +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a xor a ld [H_AUTOBGTRANSFERENABLED], a .loop @@ -532,20 +609,25 @@ BattleTransition_VerticalStripes: ; 70cf4 (1c:4cf4) call BattleTransition_VerticalStripes_ call BattleTransition_TransferDelay3 pop hl - ld bc, $ffec + ld bc, -SCREEN_WIDTH add hl, bc ld e, l ld d, h pop hl - ld bc, $14 + ld bc, SCREEN_WIDTH add hl, bc pop bc dec c jr nz, .loop jp BattleTransition_BlackScreen +<<<<<<< HEAD BattleTransition_VerticalStripes_: ; 70d20 (1c:4d20) ld c, $a +======= +BattleTransition_VerticalStripes_: ; 70caa (1c:4caa) + ld c, SCREEN_WIDTH / 2 +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a .loop ld [hl], $ff inc hl @@ -555,10 +637,17 @@ BattleTransition_VerticalStripes_: ; 70d20 (1c:4d20) ret ; used for low level wild dungeon battles +<<<<<<< HEAD BattleTransition_HorizontalStripes: ; 70d2a (1c:4d2a) ld c, $14 ld hl, wTileMap deCoord 19, 1 +======= +BattleTransition_HorizontalStripes: ; 70cb4 (1c:4cb4) + ld c, SCREEN_WIDTH + coord hl, 0, 0 + coord de, 19, 1 +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a xor a ld [H_AUTOBGTRANSFERENABLED], a .loop @@ -579,9 +668,15 @@ BattleTransition_HorizontalStripes: ; 70d2a (1c:4d2a) jr nz, .loop jp BattleTransition_BlackScreen +<<<<<<< HEAD BattleTransition_HorizontalStripes_: ; 70d4e (1c:4d4e) ld c, $9 ld de, $28 +======= +BattleTransition_HorizontalStripes_: ; 70cd8 (1c:4cd8) + ld c, SCREEN_HEIGHT / 2 + ld de, SCREEN_WIDTH * 2 +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a .loop ld [hl], $ff add hl, de @@ -594,11 +689,11 @@ BattleTransition_HorizontalStripes_: ; 70d4e (1c:4d4e) ; by animating each half circle one at a time BattleTransition_Circle: ; 70d5a (1c:4d5a) call BattleTransition_FlashScreen - ld bc, $000a + lb bc, 0, SCREEN_WIDTH / 2 ld hl, BattleTransition_HalfCircle1 call BattleTransition_Circle_Sub1 - ld c, $a - ld b, $1 + ld c, SCREEN_WIDTH / 2 + ld b, 1 ld hl, BattleTransition_HalfCircle2 call BattleTransition_Circle_Sub1 jp BattleTransition_BlackScreen @@ -616,7 +711,7 @@ BattleTransition_Circle_Sub1: ; 70d7c (1c:4d7c) ld a, b call BattleTransition_Circle_Sub2 pop hl - ld bc, $0005 + ld bc, 5 add hl, bc call BattleTransition_TransferDelay3 pop bc @@ -624,8 +719,13 @@ BattleTransition_Circle_Sub1: ; 70d7c (1c:4d7c) jr nz, BattleTransition_Circle_Sub1 ret +<<<<<<< HEAD BattleTransition_TransferDelay3: ; 70d8f (1c:4d8f) ld a, $1 +======= +BattleTransition_TransferDelay3: ; 70d19 (1c:4d19) + ld a, 1 +>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a ld [H_AUTOBGTRANSFERENABLED], a call Delay3 xor a @@ -637,7 +737,7 @@ BattleTransition_TransferDelay3: ; 70d8f (1c:4d8f) ; by animating both half circles at the same time BattleTransition_DoubleCircle: ; 70d9a (1c:4d9a) call BattleTransition_FlashScreen - ld c, $a + ld c, SCREEN_WIDTH / 2 ld hl, BattleTransition_HalfCircle1 ld de, BattleTransition_HalfCircle2 .loop @@ -651,7 +751,7 @@ BattleTransition_DoubleCircle: ; 70d9a (1c:4d9a) ld a, $1 call BattleTransition_Circle_Sub2 pop hl - ld bc, $5 + ld bc, 5 add hl, bc ld e, l ld d, h @@ -664,9 +764,9 @@ BattleTransition_DoubleCircle: ; 70d9a (1c:4d9a) jp BattleTransition_BlackScreen BattleTransition_Circle_Sub2: ; 70dc6 (1c:4dc6) - ld [wWhichTrade], a + ld [wBattleTransitionCircleScreenQuadrantY], a ld a, [hli] - ld [wTrainerEngageDistance], a + ld [wBattleTransitionCircleScreenQuadrantX], a ld a, [hli] ld e, a ld a, [hli] @@ -765,7 +865,7 @@ BattleTransition_Circle_Sub3: ; 70e3b (1c:4e3b) inc de .loop1 ld [hl], $ff - ld a, [wTrainerEngageDistance] + ld a, [wBattleTransitionCircleScreenQuadrantX] and a jr z, .skip1 inc hl @@ -776,11 +876,11 @@ BattleTransition_Circle_Sub3: ; 70e3b (1c:4e3b) dec c jr nz, .loop1 pop hl - ld a, [wWhichTrade] + ld a, [wBattleTransitionCircleScreenQuadrantY] and a - ld bc, $14 + ld bc, SCREEN_WIDTH jr z, .skip3 - ld bc, $ffec + ld bc, -SCREEN_WIDTH .skip3 add hl, bc ld a, [de] @@ -791,7 +891,7 @@ BattleTransition_Circle_Sub3: ; 70e3b (1c:4e3b) jr z, BattleTransition_Circle_Sub3 ld c, a .loop2 - ld a, [wTrainerEngageDistance] + ld a, [wBattleTransitionCircleScreenQuadrantX] and a jr z, .skip4 dec hl diff --git a/engine/battle/common_text.asm b/engine/battle/common_text.asm index 5d427e97..e3c7e1fa 100644 --- a/engine/battle/common_text.asm +++ b/engine/battle/common_text.asm @@ -2,7 +2,7 @@ PrintBeginningBattleText: ; f4000 (3d:4000) ld a, [W_ISINBATTLE] ; W_ISINBATTLE dec a jr nz, .trainerBattle - ld a, [W_CURMAP] ; W_CURMAP + ld a, [W_CURMAP] cp POKEMONTOWER_3 jr c, .notPokemonTower cp LAVENDER_HOUSE_1 @@ -23,7 +23,7 @@ PrintBeginningBattleText: ; f4000 (3d:4000) call PlayCry .continue ld hl, WildMonAppearedText - ld a, [W_MOVEMISSED] ; W_MOVEMISSED + ld a, [W_MOVEMISSED] and a jr z, .notFishing ld hl, HookedMonAttackedText @@ -31,7 +31,7 @@ PrintBeginningBattleText: ; f4000 (3d:4000) jr .wildBattle .trainerBattle call .playSFX - ld c, $14 + ld c, 20 call DelayFrames ld hl, TrainerWantsToFightText .wildBattle @@ -77,7 +77,7 @@ PrintBeginningBattleText: ; f4000 (3d:4000) .playSFX xor a - ld [wc0f1], a + ld [wFrequencyModifier], a ld a, $80 ld [wc0f2], a ld a, $e9 ; (SFX_08_77 - SFX_Headers_08) / 3 @@ -120,10 +120,10 @@ PrintSendOutMonMessage: ; f40e0 (3d:40e5) ld [H_MULTIPLICAND], a ld hl, wEnemyMonHP ld a, [hli] - ld [wcce3], a + ld [wLastSwitchInEnemyMonHP], a ld [H_MULTIPLICAND + 1], a ld a, [hl] - ld [wcce4], a + ld [wLastSwitchInEnemyMonHP + 1], a ld [H_MULTIPLICAND + 2], a ld a, 25 ld [H_MULTIPLIER], a @@ -136,7 +136,7 @@ PrintSendOutMonMessage: ; f40e0 (3d:40e5) srl a rr b ld a, b - ld b, $4 + ld b, 4 ld [H_DIVISOR], a ; enemy mon max HP divided by 4 call Divide ld a, [H_QUOTIENT + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP @@ -155,22 +155,22 @@ PrintSendOutMonMessage: ; f40e0 (3d:40e5) GoText: ; f413a (3d:413a) TX_FAR _GoText - db $08 ; asm + TX_ASM jr PrintPlayerMon1Text DoItText: ; f4141 (3d:4141) TX_FAR _DoItText - db $08 ; asm + TX_ASM jr PrintPlayerMon1Text GetmText: ; f4148 (3d:4148) TX_FAR _GetmText - db $08 ; asm + TX_ASM jr PrintPlayerMon1Text EnemysWeakText: ; f414f (3d:414f) TX_FAR _EnemysWeakText - db $08 ; asm + TX_ASM PrintPlayerMon1Text: ; f4154 (3d:4154) ld hl, PlayerMon1Text @@ -186,23 +186,23 @@ RetreatMon: ; f415d (3d:415d) PlayerMon2Text: ; f4163 (3d:4163) TX_FAR _PlayerMon2Text - db $08 ; asm + TX_ASM push de push bc ld hl, wEnemyMonHP + 1 - ld de, wcce4 + ld de, wLastSwitchInEnemyMonHP + 1 ld b, [hl] dec hl ld a, [de] sub b - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a dec de ld b, [hl] ld a, [de] sbc b - ld [$ff97], a - ld a, $19 - ld [H_POWEROFTEN], a + ld [H_MULTIPLICAND + 1], a + ld a, 25 + ld [H_MULTIPLIER], a call Multiply ld hl, wEnemyMonMaxHP ld a, [hli] @@ -212,37 +212,42 @@ PlayerMon2Text: ; f4163 (3d:4163) srl a rr b ld a, b - ld b, $4 - ld [H_POWEROFTEN], a + ld b, 4 + ld [H_DIVISOR], a call Divide pop bc pop de - ld a, [$ff98] - ld hl, EnoughText + ld a, [H_QUOTIENT + 3] ; a = ((LastSwitchInEnemyMonHP - CurrentEnemyMonHP) / 25) / (EnemyMonMaxHP / 4) +; Assuming that the enemy mon hasn't gained HP since the last switch in, +; a approximates the percentage that the enemy mon's total HP has decreased +; since the last switch in. +; If the enemy mon has gained HP, then a is garbage due to wrap-around and +; can fall in any of the ranges below. + ld hl, EnoughText ; HP stayed the same and a ret z - ld hl, ComeBackText - cp $1e + ld hl, ComeBackText ; HP went down 1% - 29% + cp 30 ret c - ld hl, OKExclamationText - cp $46 + ld hl, OKExclamationText ; HP went down 30% - 69% + cp 70 ret c - ld hl, GoodText + ld hl, GoodText ; HP went down 70% or more ret EnoughText: ; f41b1 (3d:41b1) TX_FAR _EnoughText - db $08 ; asm + TX_ASM jr PrintComeBackText OKExclamationText: ; f41b8 (3d:41b8) TX_FAR _OKExclamationText - db $08 ; asm + TX_ASM jr PrintComeBackText GoodText: ; f41bf (3d:41bf) TX_FAR _GoodText - db $08 ; asm + TX_ASM jr PrintComeBackText PrintComeBackText: ; f41c6 (3d:41c6) diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 1b8203b1..8a46c705 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -101,8 +101,8 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) ld a, MESSAGE_BOX ; the usual text box at the bottom of the screen ld [wTextBoxID], a call DisplayTextBoxID - hlCoord 1, 5 - ld bc, $307 + coord hl, 1, 5 + lb bc, 3, 7 call ClearScreenArea call DisableLCD call LoadFontTilePatterns @@ -110,14 +110,14 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) ld hl, vBGMap0 ld bc, $400 .clearBackgroundLoop - ld a, $7f + ld a, " " ld [hli], a dec bc ld a, b or c jr nz, .clearBackgroundLoop ; copy the work RAM tile map to VRAM - ld hl, wTileMap + coord hl, 0, 0 ld de, vBGMap0 ld b, 18 ; number of rows .copyRowLoop @@ -175,21 +175,19 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ld a, $31 - ld [$ffe1], a - hlCoord 1, 5 - predef Func_3f0c6 + ld [hStartTileID], a + coord hl, 1, 5 + predef CopyUncompressedPicToTilemap xor a ld [hWY], a ld [rWY], a inc a ld [H_AUTOBGTRANSFERENABLED], a call Delay3 - ld b, $1 - call GoPAL_SET + ld b, SET_PAL_BATTLE + call RunPaletteCommand call HideSprites - ld hl, PrintBeginningBattleText - ld b, BANK(PrintBeginningBattleText) - jp Bankswitch + jpab PrintBeginningBattleText ; when a battle is starting, silhouettes of the player's pic and the enemy's pic are slid onto the screen ; the lower of the player's pic (his body) is part of the background, but his head is a sprite @@ -225,9 +223,9 @@ StartBattle: ; 3c11e (f:411e) xor a ld [wPartyGainExpFlags], a ld [wPartyFoughtCurrentEnemyFlags], a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a inc a - ld [wd11d], a + ld [wFirstMonsNotOutYet], a ld hl, wEnemyMon1HP ld bc, wEnemyMon2 - wEnemyMon1 - 1 ld d, $3 @@ -260,7 +258,7 @@ StartBattle: ; 3c11e (f:411e) .displaySafariZoneBattleMenu call DisplayBattleMenu ret c ; return if the player ran from battle - ld a, [wcd6a] + ld a, [wActionResultOrTookBattleTurn] and a ; was the item used successfully? jr z, .displaySafariZoneBattleMenu ; if not, display the menu again; XXX does this ever jump? ld a, [W_NUMSAFARIBALLS] @@ -324,13 +322,13 @@ StartBattle: ; 3c11e (f:411e) ld [wcf91], a ld [wBattleMonSpecies2], a call LoadScreenTilesFromBuffer1 - hlCoord 1, 5 + coord hl, 1, 5 ld a, $9 call SlideTrainerPicOffScreen call SaveScreenTilesToBuffer1 ld a, [wWhichPokemon] ld c, a - ld b, $1 + ld b, FLAG_SET push bc ld hl, wPartyGainExpFlags predef FlagActionPredef @@ -355,13 +353,11 @@ EnemyRan: ; 3c202 (f:4202) ld hl, EnemyRanText .printText call PrintText - ld a, (SFX_08_44 - SFX_Headers_08) / 3 + ld a, SFX_RUN call PlaySoundWaitForCurrent xor a ld [H_WHOSETURN], a - ld hl, AnimationSlideEnemyMonOut - ld b, BANK(AnimationSlideEnemyMonOut) - jp Bankswitch + jpab AnimationSlideEnemyMonOff WildRanText: ; 3c229 (f:4229) TX_FAR _WildRanText @@ -383,7 +379,7 @@ MainInBattleLoop: ; 3c233 (f:4233) jp z, HandleEnemyMonFainted ; if enemy mon HP is 0, jump call SaveScreenTilesToBuffer1 xor a - ld [wd11d], a + ld [wFirstMonsNotOutYet], a ld a, [W_PLAYERBATTSTATUS2] and (1 << NeedsToRecharge) | (1 << UsingRage) ; check if the player is using Rage or needs to recharge jr nz, .selectEnemyMove @@ -415,8 +411,8 @@ MainInBattleLoop: ; 3c233 (f:4233) ld [wPlayerSelectedMove], a jr .selectEnemyMove .selectPlayerMove - ld a, [wcd6a] - and a + ld a, [wActionResultOrTookBattleTurn] + and a ; has the player already used the turn (e.g. by using an item, trying to run or switching pokemon) jr nz, .selectEnemyMove ld [wMoveMenuType], a inc a @@ -620,7 +616,7 @@ HandlePoisonBurnLeechSeed: ; 3c3bd (f:43bd) or [hl] ret nz ; test if fainted call DrawHUDsAndHPBars - ld c, $14 + ld c, 20 call DelayFrames xor a ret @@ -721,8 +717,8 @@ HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ; 3c4a3 (f:44a3) ld [wHPBarMaxHP+1], a ld a, [hl] ld [wHPBarMaxHP], a - ld de, $fff2 - add hl, de ; skip back fomr max hp to current hp + ld de, wBattleMonHP - wBattleMonMaxHP + add hl, de ; skip back from max hp to current hp ld a, [hl] ld [wHPBarOldHP], a ; add bc to current HP add c @@ -760,12 +756,12 @@ HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ; 3c4a3 (f:44a3) ret UpdateCurMonHPBar: ; 3c4f6 (f:44f6) - hlCoord 10, 9 ; tile pointer to player HP bar + coord hl, 10, 9 ; tile pointer to player HP bar ld a, [H_WHOSETURN] and a ld a, $1 jr z, .playersTurn - hlCoord 2, 2 ; tile pointer to enemy HP bar + coord hl, 2, 2 ; tile pointer to enemy HP bar xor a .playersTurn push bc @@ -792,7 +788,7 @@ CheckNumAttacksLeft: ; 3c50f (f:450f) HandleEnemyMonFainted: ; 3c525 (f:4525) xor a - ld [wccf0], a + ld [wInHandlePlayerMonFainted], a call FaintEnemyPokemon call AnyPartyAlive ld a, d @@ -816,14 +812,14 @@ HandleEnemyMonFainted: ; 3c525 (f:4525) call ChooseNextMon .skipReplacingBattleMon ld a, $1 - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a call ReplaceFaintedEnemyMon jp z, EnemyRan xor a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a jp MainInBattleLoop -FaintEnemyPokemon ; 0x3c567 +FaintEnemyPokemon: ; 0x3c567 call ReadPlayerMonCurHPAndStatus ld a, [W_ISINBATTLE] dec a @@ -838,8 +834,17 @@ FaintEnemyPokemon ; 0x3c567 .wild ld hl, W_PLAYERBATTSTATUS1 res AttackingMultipleTimes, [hl] - xor a - ld [wPlayerNumHits], a +; Bug. This only zeroes the high byte of the player's accumulated damage, +; setting the accumulated damage to itself mod 256 instead of 0 as was probably +; intended. That alone is problematic, but this mistake has another more severe +; effect. This function's counterpart for when the player mon faints, +; RemoveFaintedPlayerMon, zeroes both the high byte and the low byte. In a link +; battle, the other player's Game Boy will call that function in response to +; the enemy mon (the player mon from the other side's perspective) fainting, +; and the states of the two Game Boys will go out of sync unless the damage +; was congruent to 0 modulo 256. + xor a + ld [wPlayerBideAccumulatedDamage], a ld hl, wEnemyStatsToDouble ; clear enemy statuses ld [hli], a ld [hli], a @@ -848,29 +853,29 @@ FaintEnemyPokemon ; 0x3c567 ld [hl], a ld [W_ENEMYDISABLEDMOVE], a ld [wEnemyDisabledMoveNumber], a - ld [wccf3], a + ld [wEnemyMonMinimized], a ld hl, wPlayerUsedMove ld [hli], a ld [hl], a - hlCoord 12, 5 - deCoord 12, 6 + coord hl, 12, 5 + coord de, 12, 6 call SlideDownFaintedMonPic - ld hl, wTileMap - ld bc, $40b + coord hl, 0, 0 + lb bc, 4, 11 call ClearScreenArea ld a, [W_ISINBATTLE] dec a jr z, .wild_win xor a - ld [wc0f1], a - ld [wc0f2], a - ld a, (SFX_08_48 - SFX_Headers_08) / 3 ; SFX_FALL? + ld [wFrequencyModifier], a + ld [wTempoModifier], a + ld a, SFX_FAINT_FALL call PlaySoundWaitForCurrent .sfxwait - ld a, [wc02a] - cp (SFX_08_48 - SFX_Headers_08) / 3 + ld a, [wChannelSoundIDs + CH4] + cp SFX_FAINT_FALL jr z, .sfxwait - ld a, (SFX_08_43 - SFX_Headers_08) / 3 ; SFX_DROP + ld a, SFX_FAINT_THUD call PlaySound call WaitForSoundToFinish jr .sfxplayed @@ -883,9 +888,9 @@ FaintEnemyPokemon ; 0x3c567 ld a, [hli] or [hl] jr nz, .playermonnotfaint - ld a, [wccf0] - and a - jr nz, .playermonnotfaint + ld a, [wInHandlePlayerMonFainted] + and a ; was this called by HandlePlayerMonFainted? + jr nz, .playermonnotfaint ; if so, don't call RemoveFaintedPlayerMon twice call RemoveFaintedPlayerMon .playermonnotfaint call AnyPartyAlive @@ -938,20 +943,20 @@ FaintEnemyPokemon ; 0x3c567 jr nz, .gainExpFlagsLoop ld a, b ld [wPartyGainExpFlags], a - ld hl, GainExperience - ld b, BANK(GainExperience) - jp Bankswitch + jpab GainExperience EnemyMonFaintedText: ; 0x3c63e TX_FAR _EnemyMonFaintedText db "@" EndLowHealthAlarm: ; 3c643 (f:4643) +; This function is called when the player has the won the battle. It turns off +; the low health alarm and prevents it from reactivating until the next battle. xor a - ld [wLowHealthAlarm], a ;disable low health alarm - ld [wc02a], a + ld [wLowHealthAlarm], a ; turn off low health alarm + ld [wChannelSoundIDs + CH4], a inc a - ld [wccf6], a + ld [wLowHealthAlarmDisabled], a ; prevent it from reactivating ret AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f) @@ -973,7 +978,7 @@ AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f) ; stores whether enemy ran in Z flag ReplaceFaintedEnemyMon: ; 3c664 (f:4664) - ld hl, wcf1e + ld hl, wEnemyHPBarColor ld e, $30 call GetBattleHealthBarColor callab DrawEnemyPokeballs @@ -990,7 +995,7 @@ ReplaceFaintedEnemyMon: ; 3c664 (f:4664) call EnemySendOut xor a ld [W_ENEMYMOVENUM], a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a ld [wAILayer2Encouragement], a inc a ; reset Z flag ret @@ -1020,10 +1025,10 @@ TrainerBattleVictory: ; 3c696 (f:4696) cp LINK_STATE_BATTLING ret z call ScrollTrainerPicAfterBattle - ld c, $28 + ld c, 40 call DelayFrames call PrintEndBattleText -; win money +; win money ld hl, MoneyForWinningText call PrintText ld de, wPlayerMoney + 2 @@ -1042,7 +1047,7 @@ TrainerDefeatedText: ; 3c6e9 (f:46e9) PlayBattleVictoryMusic: ; 3c6ee (f:46ee) push af ld a, $ff - ld [wc0ee], a + ld [wNewSoundID], a call PlaySoundWaitForCurrent ld c, BANK(Music_DefeatedTrainer) pop af @@ -1050,8 +1055,8 @@ PlayBattleVictoryMusic: ; 3c6ee (f:46ee) jp Delay3 HandlePlayerMonFainted: ; 3c700 (f:4700) - ld a, $1 - ld [wccf0], a + ld a, 1 + ld [wInHandlePlayerMonFainted], a call RemoveFaintedPlayerMon call AnyPartyAlive ; test if any more mons are alive ld a, d @@ -1075,11 +1080,11 @@ HandlePlayerMonFainted: ; 3c700 (f:4700) jp nz, MainInBattleLoop ; if the enemy mon has more than 0 HP, go back to battle loop ; the enemy mon has 0 HP ld a, $1 - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a call ReplaceFaintedEnemyMon jp z, EnemyRan ; if enemy ran from battle rather than sending out another mon, jump xor a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a jp MainInBattleLoop ; resets flags, slides mon's pic down, plays cry, and prints fainted message @@ -1087,7 +1092,7 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741) ld a, [wPlayerMonNumber] ld c, a ld hl, wPartyGainExpFlags - ld b, $0 + ld b, FLAG_RESET predef FlagActionPredef ; clear gain exp flag for fainted mon ld hl, W_ENEMYBATTSTATUS1 res 2, [hl] ; reset "attacking multiple times" flag @@ -1098,24 +1103,29 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741) ld [wLowHealthAlarm], a ;disable low health alarm call WaitForSoundToFinish .skipWaitForSound -; bug? if the player mon faints while the enemy mon is using bide, -; the accumulated damage is overwritten. xxx what values can [wLowHealthAlarm] have here? +; a is 0, so this zeroes the enemy's accumulated damage. ld hl, wEnemyBideAccumulatedDamage ld [hli], a ld [hl], a ld [wBattleMonStatus], a call ReadPlayerMonCurHPAndStatus - hlCoord 9, 7 - ld bc, $50b + coord hl, 9, 7 + lb bc, 5, 11 call ClearScreenArea - hlCoord 1, 10 - deCoord 1, 11 + coord hl, 1, 10 + coord de, 1, 11 call SlideDownFaintedMonPic ld a, $1 ld [wBattleResult], a - ld a, [wccf0] - and a - ret z + +; When the player mon and enemy mon faint at the same time and the fact that the +; enemy mon has fainted is detected first (e.g. when the player mon knocks out +; the enemy mon using a move with recoil and faints due to the recoil), don't +; play the player mon's cry or show the "[player mon] fainted!" message. + ld a, [wInHandlePlayerMonFainted] + and a ; was this called by HandleEnemyMonFainted? + ret z ; if so, return + ld a, [wBattleMonSpecies] call PlayCry ld hl, PlayerMonFaintedText @@ -1137,13 +1147,13 @@ DoUseNextMonDialogue: ; 3c79b (f:479b) ld hl, UseNextMonText call PrintText .displayYesNoBox - hlCoord 13, 9 - ld bc, $a0e + coord hl, 13, 9 + lb bc, 10, 14 ld a, TWO_OPTION_MENU ld [wTextBoxID], a call DisplayTextBoxID - ld a, [wd12e] - cp $2 ; did the player choose NO? + ld a, [wMenuExitMethod] + cp CHOSE_SECOND_ITEM ; did the player choose NO? jr z, .tryRunning ; if the player chose NO, try running and a ; reset carry ret @@ -1162,8 +1172,8 @@ UseNextMonText: ; 3c7d3 (f:47d3) ; choose next player mon to send out ; stores whether enemy mon has no HP left in Z flag ChooseNextMon: ; 3c7d8 (f:47d8) - ld a, $2 - ld [wd07d], a + ld a, BATTLE_PARTY_MENU + ld [wPartyMenuTypeOrMessageID], a call DisplayPartyMenu .checkIfMonChosen jr nc, .monChosen @@ -1177,17 +1187,17 @@ ChooseNextMon: ; 3c7d8 (f:47d8) cp LINK_STATE_BATTLING jr nz, .notLinkBattle inc a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a call LinkBattleExchangeData .notLinkBattle xor a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a call ClearSprites ld a, [wWhichPokemon] ld [wPlayerMonNumber], a ld c, a ld hl, wPartyGainExpFlags - ld b, $1 + ld b, FLAG_SET push bc predef FlagActionPredef pop bc @@ -1197,7 +1207,7 @@ ChooseNextMon: ; 3c7d8 (f:47d8) call GBPalWhiteOut call LoadHudTilePatterns call LoadScreenTilesFromBuffer1 - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call GBPalNormal call SendOutMon ld hl, wEnemyMonHP @@ -1212,13 +1222,13 @@ HandlePlayerBlackOut: ; 3c837 (f:4837) cp LINK_STATE_BATTLING jr z, .notSony1Battle ld a, [W_CUROPPONENT] - cp $c8 + SONY1 + cp OPP_SONY1 jr nz, .notSony1Battle - ld hl, wTileMap ; sony 1 battle - ld bc, $815 + coord hl, 0, 0 ; sony 1 battle + lb bc, 8, 21 call ClearScreenArea call ScrollTrainerPicAfterBattle - ld c, $28 + ld c, 40 call DelayFrames ld hl, Sony1WinText call PrintText @@ -1226,8 +1236,8 @@ HandlePlayerBlackOut: ; 3c837 (f:4837) cp OAKS_LAB ret z ; starter battle in oak's lab: don't black out .notSony1Battle - ld b, $0 - call GoPAL_SET + ld b, SET_PAL_BATTLE_BLACK + call RunPaletteCommand ld hl, PlayerBlackedOutText2 ld a, [wLinkState] cp LINK_STATE_BATTLING @@ -1310,7 +1320,7 @@ SevenSpacesText: ; 3c8d7 (f:48d7) ; if a is 8, the slide is to the right, else it is to the left ; bug: when this is called, [H_AUTOBGTRANSFERENABLED] is non-zero, so there is screen tearing SlideTrainerPicOffScreen: ; 3c8df (f:48df) - ld [$FF8B], a + ld [hSlideAmount], a ld c, a .slideStepLoop ; each iteration, the trainer pic is slid one tile left/right push bc @@ -1318,10 +1328,10 @@ SlideTrainerPicOffScreen: ; 3c8df (f:48df) ld b, 7 ; number of rows .rowLoop push hl - ld a, [$FF8B] + ld a, [hSlideAmount] ld c, a .columnLoop - ld a, [$FF8B] + ld a, [hSlideAmount] cp 8 jr z, .slideRight .slideLeft ; slide player sprite off screen @@ -1356,7 +1366,7 @@ EnemySendOut: ; 3c90e (f:490e) ld [hl],a ld a,[wPlayerMonNumber] ld c,a - ld b,1 + ld b,FLAG_SET push bc predef FlagActionPredef ld hl,wPartyFoughtCurrentEnemyFlags @@ -1376,7 +1386,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) ld [hl],a ld [W_ENEMYDISABLEDMOVE],a ld [wEnemyDisabledMoveNumber],a - ld [wccf3],a + ld [wEnemyMonMinimized],a ld hl,wPlayerUsedMove ld [hli],a ld [hl],a @@ -1384,7 +1394,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) ld [wAICount],a ld hl,W_PLAYERBATTSTATUS1 res 5,[hl] - hlCoord 18, 0 + coord hl, 18, 0 ld a,8 call SlideTrainerPicOffScreen call PrintEmptyString @@ -1435,12 +1445,12 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) call LoadEnemyMonData ld hl,wEnemyMonHP ld a,[hli] - ld [wcce3],a + ld [wLastSwitchInEnemyMonHP],a ld a,[hl] - ld [wcce4],a + ld [wLastSwitchInEnemyMonHP + 1],a ld a,1 ld [wCurrentMenuItem],a - ld a,[wd11d] + ld a,[wFirstMonsNotOutYet] dec a jr z,.next4 ld a,[wPartyCount] @@ -1454,16 +1464,16 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) jr nz,.next4 ld hl, TrainerAboutToUseText call PrintText - hlCoord 0, 7 - ld bc,$0801 + coord hl, 0, 7 + lb bc, 8, 1 ld a,TWO_OPTION_MENU ld [wTextBoxID],a call DisplayTextBoxID ld a,[wCurrentMenuItem] and a jr nz,.next4 - ld a,2 - ld [wd07d],a + ld a,BATTLE_PARTY_MENU + ld [wPartyMenuTypeOrMessageID],a call DisplayPartyMenu .next9 ld a,1 @@ -1489,11 +1499,11 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) call LoadScreenTilesFromBuffer1 .next4 call ClearSprites - ld hl,wTileMap - ld bc,$040B + coord hl, 0, 0 + lb bc, 4, 11 call ClearScreenArea - ld b,1 - call GoPAL_SET + ld b, SET_PAL_BATTLE + call RunPaletteCommand call GBPalNormal ld hl,TrainerSentOutText call PrintText @@ -1503,10 +1513,10 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) call GetMonHeader ld de,vFrontPic call LoadMonFrontSprite - ld a,$CF - ld [$FFE1],a - hlCoord 15, 6 - predef Func_3f073 + ld a,-$31 + ld [hStartTileID],a + coord hl, 15, 6 + predef AnimateSendingOutMon ld a,[wEnemyMonSpecies2] call PlayCry call DrawEnemyHUDAndHPBar @@ -1555,7 +1565,7 @@ HasMonFainted: ; 3ca97 (f:4a97) ld a, [hli] or [hl] ret nz - ld a, [wd11d] + ld a, [wFirstMonsNotOutYet] and a jr nz, .done ld hl, NoWillText @@ -1590,14 +1600,14 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9) ld a, [hl] ld [H_MULTIPLICAND + 2], a ld a, [de] - ld [$ff8d], a + ld [hEnemySpeed], a inc de ld a, [de] - ld [$ff8e], a + ld [hEnemySpeed + 1], a call LoadScreenTilesFromBuffer1 ld de, H_MULTIPLICAND + 1 - ld hl, $ff8d - ld c, $2 + ld hl, hEnemySpeed + ld c, 2 call StringCmp jr nc, .canEscape ; jump if player speed greater than enemy speed xor a @@ -1609,9 +1619,9 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9) ld [H_DIVIDEND], a ld a, [H_PRODUCT + 3] ld [H_DIVIDEND + 1], a - ld a, [$ff8d] + ld a, [hEnemySpeed] ld b, a - ld a, [$ff8e] + ld a, [hEnemySpeed + 1] ; divide enemy speed by 4 srl b rr a @@ -1642,19 +1652,19 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9) ld b, a ld a, [H_QUOTIENT + 3] cp b - jr nc, .canEscape ; if the random value was less than or equal to the quotient + jr nc, .canEscape ; if the random value was less than or equal to the quotient ; plus 30 times the number of attempts, the player can escape ; can't escape ld a, $1 - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a ; you lose your turn when you can't escape ld hl, CantEscapeText jr .printCantEscapeOrNoRunningText .trainerBattle ld hl, NoRunningText .printCantEscapeOrNoRunningText call PrintText - ld a, $1 - ld [wd11f], a + ld a, 1 + ld [wForcePlayerToChooseMon], a call SaveScreenTilesToBuffer1 and a ; reset carry ret @@ -1666,7 +1676,7 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9) ; link battle call SaveScreenTilesToBuffer1 xor a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a ld a, $f ld [wPlayerMoveListIndex], a call LinkBattleExchangeData @@ -1678,7 +1688,7 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9) dec a .playSound ld [wBattleResult], a - ld a, (SFX_08_44 - SFX_Headers_08) / 3 + ld a, SFX_RUN call PlaySoundWaitForCurrent ld hl, GotAwayText call PrintText @@ -1702,19 +1712,19 @@ GotAwayText: ; 3cba1 (f:4ba1) ; copies from party data to battle mon data when sending out a new player mon LoadBattleMonFromParty: ; 3cba6 (f:4ba6) ld a, [wWhichPokemon] - ld bc, $2c + ld bc, wPartyMon2 - wPartyMon1 ld hl, wPartyMon1Species call AddNTimes ld de, wBattleMonSpecies - ld bc, $c + ld bc, wBattleMonDVs - wBattleMonSpecies call CopyData - ld bc, $f + ld bc, wPartyMon1DVs - wPartyMon1OTID add hl, bc ld de, wBattleMonDVs - ld bc, $2 + ld bc, NUM_DVS call CopyData ld de, wBattleMonPP - ld bc, $4 + ld bc, NUM_MOVES call CopyData ld de, wBattleMonLevel ld bc, $b @@ -1726,16 +1736,16 @@ LoadBattleMonFromParty: ; 3cba6 (f:4ba6) ld a, [wPlayerMonNumber] call SkipFixedLengthTextEntries ld de, wBattleMonNick - ld bc, $b + ld bc, NAME_LENGTH call CopyData ld hl, wBattleMonLevel ld de, wPlayerMonUnmodifiedLevel ; block of memory used for unmodified stats - ld bc, $b + ld bc, 1 + NUM_STATS * 2 call CopyData call ApplyBurnAndParalysisPenaltiesToPlayer call ApplyBadgeStatBoosts ld a, $7 ; default stat modifier - ld b, $8 + ld b, NUM_STAT_MODS ld hl, wPlayerMonAttackMod .statModLoop ld [hli], a @@ -1746,19 +1756,19 @@ LoadBattleMonFromParty: ; 3cba6 (f:4ba6) ; copies from enemy party data to current enemy mon data when sending out a new enemy mon LoadEnemyMonFromParty: ; 3cc13 (f:4c13) ld a, [wWhichPokemon] - ld bc, $2c + ld bc, wEnemyMon2 - wEnemyMon1 ld hl, wEnemyMons call AddNTimes ld de, wEnemyMonSpecies - ld bc, $c + ld bc, wEnemyMonDVs - wEnemyMonSpecies call CopyData - ld bc, $f + ld bc, wEnemyMon1DVs - wEnemyMon1OTID add hl, bc ld de, wEnemyMonDVs - ld bc, $2 + ld bc, NUM_DVS call CopyData ld de, wEnemyMonPP - ld bc, $4 + ld bc, NUM_MOVES call CopyData ld de, wEnemyMonLevel ld bc, $b @@ -1770,16 +1780,16 @@ LoadEnemyMonFromParty: ; 3cc13 (f:4c13) ld a, [wWhichPokemon] call SkipFixedLengthTextEntries ld de, wEnemyMonNick - ld bc, $b + ld bc, NAME_LENGTH call CopyData ld hl, wEnemyMonLevel ld de, wEnemyMonUnmodifiedLevel ; block of memory used for unmodified stats - ld bc, $b + ld bc, 1 + NUM_STATS * 2 call CopyData call ApplyBurnAndParalysisPenaltiesToEnemy ld hl, W_MONHBASESTATS ld de, wEnemyMonBaseStats - ld b, $5 + ld b, NUM_STATS .copyBaseStatsLoop ld a, [hli] ld [de], a @@ -1787,7 +1797,7 @@ LoadEnemyMonFromParty: ; 3cc13 (f:4c13) dec b jr nz, .copyBaseStatsLoop ld a, $7 ; default stat modifier - ld b, $8 + ld b, NUM_STAT_MODS ld hl, wEnemyMonStatMods .statModLoop ld [hli], a @@ -1808,8 +1818,8 @@ SendOutMon: ; 3cc91 (f:4c91) call DrawPlayerHUDAndHPBar predef LoadMonBackPic xor a - ld [$ffe1], a - ld hl, wcc2d + ld [hStartTileID], a + ld hl, wBattleAndStartSavedMenuItem ld [hli], a ld [hl], a ld [wBoostExpByExpAll], a @@ -1826,50 +1836,50 @@ SendOutMon: ; 3cc91 (f:4c91) ld [hl], a ld [W_PLAYERDISABLEDMOVE], a ld [wPlayerDisabledMoveNumber], a - ld [wccf7], a - ld b, $1 - call GoPAL_SET + ld [wPlayerMonMinimized], a + ld b, SET_PAL_BATTLE + call RunPaletteCommand ld hl, W_ENEMYBATTSTATUS1 res UsingTrappingMove, [hl] ld a, $1 ld [H_WHOSETURN], a ld a, POOF_ANIM call PlayMoveAnimation - hlCoord 4, 11 - predef Func_3f073 + coord hl, 4, 11 + predef AnimateSendingOutMon ld a, [wcf91] call PlayCry call PrintEmptyString jp SaveScreenTilesToBuffer1 -; show 2 stages of the player getting smaller before disappearing +; show 2 stages of the player mon getting smaller before disappearing AnimateRetreatingPlayerMon: ; 3ccfa (f:4cfa) - hlCoord 1, 5 - ld bc, $707 + coord hl, 1, 5 + lb bc, 7, 7 call ClearScreenArea - hlCoord 3, 7 - ld bc, $505 + coord hl, 3, 7 + lb bc, 5, 5 xor a - ld [wcd6c], a - ld [H_DOWNARROWBLINKCNT1], a - predef Func_79aba - ld c, $4 + ld [wDownscaledMonSize], a + ld [hBaseTileID], a + predef CopyDownscaledMonTiles + ld c, 4 call DelayFrames call .clearScreenArea - hlCoord 4, 9 - ld bc, $303 - ld a, $1 - ld [wcd6c], a + coord hl, 4, 9 + lb bc, 3, 3 + ld a, 1 + ld [wDownscaledMonSize], a xor a - ld [H_DOWNARROWBLINKCNT1], a - predef Func_79aba + ld [hBaseTileID], a + predef CopyDownscaledMonTiles call Delay3 call .clearScreenArea ld a, $4c Coorda 5, 11 .clearScreenArea - hlCoord 1, 5 - ld bc, $707 + coord hl, 1, 5 + lb bc, 7, 7 jp ClearScreenArea ; reads player's current mon's HP into wBattleMonHP @@ -1891,14 +1901,14 @@ DrawHUDsAndHPBars: ; 3cd5a (f:4d5a) DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60) xor a ld [H_AUTOBGTRANSFERENABLED], a - hlCoord 9, 7 - ld bc, $50b + coord hl, 9, 7 + lb bc, 5, 11 call ClearScreenArea callab PlacePlayerHUDTiles - hlCoord 18, 9 + coord hl, 18, 9 ld [hl], $73 ld de, wBattleMonNick - hlCoord 10, 7 + coord hl, 10, 7 call CenterMonName call PlaceString ld hl, wBattleMonSpecies @@ -1909,7 +1919,7 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60) ld de, wLoadedMonLevel ld bc, $b call CopyData - hlCoord 14, 8 + coord hl, 14, 8 push hl inc hl ld de, wLoadedMonStatus @@ -1920,21 +1930,21 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60) .asm_3cdae ld a, [wLoadedMonSpecies] ld [wcf91], a - hlCoord 10, 9 + coord hl, 10, 9 predef DrawHP ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - ld hl, wcf1d + ld hl, wPlayerHPBarColor call GetBattleHealthBarColor ld hl, wBattleMonHP ld a, [hli] or [hl] jr z, .asm_3cdd9 - ld a, [wccf6] - and a - ret nz - ld a, [wcf1d] - cp $2 + ld a, [wLowHealthAlarmDisabled] + and a ; has the alarm been disabled because the player has already won? + ret nz ; if so, return + ld a, [wPlayerHPBarColor] + cp HP_BAR_RED jr z, .asm_3cde6 .asm_3cdd9 ld hl, wLowHealthAlarm @@ -1942,7 +1952,7 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60) ld [hl], $0 ret z xor a - ld [wc02a], a + ld [wChannelSoundIDs + CH4], a ret .asm_3cde6 ld hl, wLowHealthAlarm @@ -1952,15 +1962,15 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60) DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec) xor a ld [H_AUTOBGTRANSFERENABLED], a - ld hl, wTileMap - ld bc, $40c + coord hl, 0, 0 + lb bc, 4, 12 call ClearScreenArea callab PlaceEnemyHUDTiles ld de, wEnemyMonNick - hlCoord 1, 0 + coord hl, 1, 0 call CenterMonName call PlaceString - hlCoord 4, 1 + coord hl, 4, 1 push hl inc hl ld de, wEnemyMonStatus @@ -2033,11 +2043,11 @@ DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec) .drawHPBar xor a ld [wHPBarType], a - hlCoord 2, 2 + coord hl, 2, 2 call DrawHPBar ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - ld hl, wcf1e + ld hl, wEnemyHPBarColor GetBattleHealthBarColor: ; 3ce90 (f:4e90) ld b, [hl] @@ -2045,8 +2055,8 @@ GetBattleHealthBarColor: ; 3ce90 (f:4e90) ld a, [hl] cp b ret z - ld b, $1 - jp GoPAL_SET + ld b, SET_PAL_BATTLE + jp RunPaletteCommand ; center's mon's name on the battle screen ; if the name is 1 or 2 letters long, it is printed 2 spaces more to the right than usual @@ -2061,11 +2071,11 @@ CenterMonName: ; 3ce9c (f:4e9c) .loop inc de ld a, [de] - cp $50 + cp "@" jr z, .done inc de ld a, [de] - cp $50 + cp "@" jr z, .done dec hl dec b @@ -2097,7 +2107,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) ; the following happens for the old man tutorial ld hl, wPlayerName ld de, W_GRASSRATE - ld bc, $b + ld bc, NAME_LENGTH call CopyData ; temporarily save the player name in unused space, ; which is supposed to get overwritten when entering a ; map with wild Pokémon. Due to an oversight, the data @@ -2105,17 +2115,17 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) ; Missingno. glitch can show up. ld hl, .oldManName ld de, wPlayerName - ld bc, $b + ld bc, NAME_LENGTH call CopyData ; the following simulates the keystrokes by drawing menus on screen - hlCoord 9, 14 + coord hl, 9, 14 ld [hl], "▶" - ld c, $50 + ld c, 80 call DelayFrames - ld [hl], $7f - hlCoord 9, 16 + ld [hl], " " + coord hl, 9, 16 ld [hl], "▶" - ld c, $32 + ld c, 50 call DelayFrames ld [hl], $ec ld a, $2 ; select the "ITEM" menu @@ -2123,7 +2133,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) .oldManName db "OLD MAN@" .handleBattleMenuInput - ld a, [wcc2d] + ld a, [wBattleAndStartSavedMenuItem] ld [wCurrentMenuItem], a ld [wLastMenuItem], a sub 2 ; check if the cursor is in the left column @@ -2145,9 +2155,9 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) .safariLeftColumn Coorda 13, 14 Coorda 13, 16 - hlCoord 7, 14 + coord hl, 7, 14 ld de, W_NUMSAFARIBALLS - ld bc, $102 + lb bc, 1, 2 call PrintNumber ld b, $1 ; top menu item X .leftColumn_WaitForInput @@ -2178,9 +2188,9 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) .safariRightColumn Coorda 1, 14 ; clear upper cursor position in left column Coorda 1, 16 ; clear lower cursor position in left column - hlCoord 7, 14 + coord hl, 7, 14 ld de, W_NUMSAFARIBALLS - ld bc, $102 + lb bc, 1, 2 call PrintNumber ld b, $d ; top menu item X .rightColumn_WaitForInput @@ -2206,7 +2216,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) ld a, [W_BATTLETYPE] cp $2 ; is it a Safari battle? ld a, [wCurrentMenuItem] - ld [wcc2d], a + ld [wBattleAndStartSavedMenuItem], a jr z, .handleMenuSelection ; not Safari battle ; swap the IDs of the item menu and party menu (this is probably because they swapped the positions @@ -2276,9 +2286,9 @@ BagWasSelected: jr nz, DisplayPlayerBag ; no, it is a normal battle ld hl, OldManItemList ld a, l - ld [wList], a + ld [wListPointer], a ld a, h - ld [wList + 1], a + ld [wListPointer + 1], a jr DisplayBagMenu OldManItemList: @@ -2290,22 +2300,22 @@ DisplayPlayerBag: ; get the pointer to player's bag when in a normal battle ld hl, wNumBagItems ld a, l - ld [wList], a + ld [wListPointer], a ld a, h - ld [wList + 1], a + ld [wListPointer + 1], a DisplayBagMenu: xor a - ld [wcf93], a + ld [wPrintItemPrices], a ld a, ITEMLISTMENU ld [wListMenuID], a - ld a, [wcc2c] + ld a, [wBagSavedMenuItem] ld [wCurrentMenuItem], a call DisplayListMenuID ld a, [wCurrentMenuItem] - ld [wcc2c], a + ld [wBagSavedMenuItem], a ld a, $0 - ld [wcc37], a + ld [wMenuWatchMovingOutOfBounds], a ld [wMenuItemToSwap], a jp c, DisplayBattleMenu ; go back to battle menu if an item was not selected @@ -2316,7 +2326,7 @@ UseBagItem: call GetItemName call CopyStringToCF4B ; copy name xor a - ld [wd152], a + ld [wPseudoItemID], a call UseItem call LoadHudTilePatterns call ClearSprites @@ -2326,7 +2336,7 @@ UseBagItem: cp $2 ; is it a safari battle? jr z, .checkIfMonCaptured - ld a, [wcd6a] + ld a, [wActionResultOrTookBattleTurn] and a ; was the item used successfully? jp z, BagWasSelected ; if not, go back to the bag menu @@ -2340,7 +2350,7 @@ UseBagItem: res UsingTrappingMove, [hl] ; not using multi-turn move any more .checkIfMonCaptured - ld a, [wd11c] + ld a, [wCapturedMonSpecies] and a ; was the enemy mon captured with a ball? jr nz, .returnAfterCapturingMon @@ -2360,7 +2370,7 @@ UseBagItem: .returnAfterCapturingMon call GBPalNormal xor a - ld [wd11c], a + ld [wCapturedMonSpecies], a ld a, $2 ld [wBattleResult], a scf ; set carry @@ -2384,8 +2394,8 @@ PartyMenuOrRockOrRun: jp UseBagItem .partyMenuWasSelected call LoadScreenTilesFromBuffer1 - xor a - ld [wd07d], a + xor a ; NORMAL_PARTY_MENU + ld [wPartyMenuTypeOrMessageID], a ld [wMenuItemToSwap], a call DisplayPartyMenu .checkIfPartyMonWasSelected @@ -2395,16 +2405,16 @@ PartyMenuOrRockOrRun: call GBPalWhiteOut call LoadHudTilePatterns call LoadScreenTilesFromBuffer2 - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call GBPalNormal jp DisplayBattleMenu .partyMonDeselected - hlCoord 11, 11 - ld bc, $81 - ld a, $7f + coord hl, 11, 11 + ld bc, 6 * SCREEN_WIDTH + 9 + ld a, " " call FillMemory - xor a - ld [wd07d], a + xor a ; NORMAL_PARTY_MENU + ld [wPartyMenuTypeOrMessageID], a call GoBackToPartyMenu jr .checkIfPartyMonWasSelected .partyMonWasSelected @@ -2435,8 +2445,8 @@ PartyMenuOrRockOrRun: and a ; was Switch selected? jr z, .switchMon ; if so, jump ; Stats was selected - xor a - ld [wcc49], a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation], a ld hl, wPartyMon1 call ClearSprites ; display the two status screens @@ -2448,7 +2458,7 @@ PartyMenuOrRockOrRun: ld hl, AnimationSubstitute jr nz, .doEnemyMonAnimation ; enemy mon doesn't have substitute - ld a, [wccf3] + ld a, [wEnemyMonMinimized] and a ; has the enemy mon used Minimise? ld hl, AnimationMinimizeMon jr nz, .doEnemyMonAnimation @@ -2479,24 +2489,24 @@ PartyMenuOrRockOrRun: call HasMonFainted jp z, .partyMonDeselected ; can't switch to fainted mon ld a, $1 - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a call GBPalWhiteOut call ClearSprites call LoadHudTilePatterns call LoadScreenTilesFromBuffer1 - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call GBPalNormal ; fall through to SwitchPlayerMon SwitchPlayerMon: ; 3d1ba (f:51ba) callab RetreatMon - ld c, $32 + ld c, 50 call DelayFrames call AnimateRetreatingPlayerMon ld a, [wWhichPokemon] ld [wPlayerMonNumber], a ld c, a - ld b, $1 + ld b, FLAG_SET push bc ld hl, wPartyGainExpFlags predef FlagActionPredef @@ -2522,12 +2532,12 @@ BattleMenu_RunWasSelected: ; 3d1fa (f:51fa) ld hl, wBattleMonSpeed ld de, wEnemyMonSpeed call TryRunningFromBattle - ld a, $0 - ld [wd11f], a + ld a, 0 + ld [wForcePlayerToChooseMon], a ret c - ld a, [wcd6a] + ld a, [wActionResultOrTookBattleTurn] and a - ret nz + ret nz ; return if the player couldn't escape jp DisplayBattleMenu MoveSelectionMenu: ; 3d219 (f:5219) @@ -2561,17 +2571,17 @@ MoveSelectionMenu: ; 3d219 (f:5219) ret z ld hl, wBattleMonMoves call .loadmoves - hlCoord 4, 12 + coord hl, 4, 12 ld b, $4 ld c, $e di call TextBoxBorder - hlCoord 4, 12 + coord hl, 4, 12 ld [hl], $7a - hlCoord 10, 12 + coord hl, 10, 12 ld [hl], $7e ei - hlCoord 6, 13 + coord hl, 6, 13 call .writemoves ld b, $5 ld a, $c @@ -2579,11 +2589,11 @@ MoveSelectionMenu: ; 3d219 (f:5219) .mimicmenu ld hl, wEnemyMonMoves call .loadmoves - hlCoord 0, 7 + coord hl, 0, 7 ld b, $4 ld c, $e call TextBoxBorder - hlCoord 2, 8 + coord hl, 2, 8 call .writemoves ld b, $1 ld a, $7 @@ -2591,22 +2601,22 @@ MoveSelectionMenu: ; 3d219 (f:5219) .relearnmenu ld a, [wWhichPokemon] ld hl, wPartyMon1Moves - ld bc, $2c + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes call .loadmoves - hlCoord 4, 7 + coord hl, 4, 7 ld b, $4 ld c, $e call TextBoxBorder - hlCoord 6, 8 + coord hl, 6, 8 call .writemoves ld b, $5 ld a, $7 .menuset ld hl, wTopMenuItemY - ld [hli], a + ld [hli], a ; wTopMenuItemY ld a, b - ld [hli], a + ld [hli], a ; wTopMenuItemX ld a, [wMoveMenuType] cp $1 jr z, .selectedmoveknown @@ -2615,30 +2625,30 @@ MoveSelectionMenu: ; 3d219 (f:5219) ld a, [wPlayerMoveListIndex] inc a .selectedmoveknown - ld [hli], a + ld [hli], a ; wCurrentMenuItem inc hl ; wTileBehindCursor untouched - ld a, [wcd6c] + ld a, [wNumMovesMinusOne] inc a inc a - ld [hli], a + ld [hli], a ; wMaxMenuItem ld a, [wMoveMenuType] dec a - ld b, $c1 ; can't use B + ld b, D_UP | D_DOWN | A_BUTTON jr z, .matchedkeyspicked dec a - ld b, $c3 + ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON jr z, .matchedkeyspicked ld a, [wLinkState] cp LINK_STATE_BATTLING jr z, .matchedkeyspicked ld a, [W_FLAGS_D733] - bit 0, a - ld b, $c7 + bit BIT_TEST_BATTLE, a + ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON | SELECT jr z, .matchedkeyspicked ld b, $ff .matchedkeyspicked ld a, b - ld [hli], a + ld [hli], a ; wMenuWatchedKeys ld a, [wMoveMenuType] cp $1 jr z, .movelistindex1 @@ -2654,21 +2664,21 @@ SelectMenuItem: ; 3d2fe (f:52fe) jr z, .battleselect dec a jr nz, .select - hlCoord 1, 14 + coord hl, 1, 14 ld de, WhichTechniqueString call PlaceString jr .select .battleselect ld a, [W_FLAGS_D733] - bit 0, a + bit BIT_TEST_BATTLE, a jr nz, .select call PrintMenuItem ld a, [wMenuItemToSwap] and a jr z, .select - hlCoord 5, 13 + coord hl, 5, 13 dec a - ld bc, $14 + ld bc, SCREEN_WIDTH call AddNTimes ld [hl], $ec .select @@ -2759,7 +2769,7 @@ CursorUp: ; 3d3c9 (f:53c9) and a jp nz, SelectMenuItem call EraseMenuCursor - ld a, [wcd6c] + ld a, [wNumMovesMinusOne] inc a ld [wCurrentMenuItem], a jp SelectMenuItem @@ -2767,7 +2777,7 @@ CursorUp: ; 3d3c9 (f:53c9) CursorDown: ; 3d3dd (f:53dd) ld a, [wCurrentMenuItem] ld b, a - ld a, [wcd6c] + ld a, [wNumMovesMinusOne] inc a inc a cp b @@ -2815,7 +2825,7 @@ AnyMoveToSelect: ; 3d3f5 (f:53f5) .asm_3d423 ld hl, NoMovesLeftText call PrintText - ld c, $3c + ld c, 60 call DelayFrames xor a ret @@ -2868,7 +2878,7 @@ SwapMovesInMenu: ; 3d435 (f:5435) push hl call .swapBytes ; swap moves pop hl - ld bc, $15 + ld bc, wPartyMon1PP - wPartyMon1Moves add hl, bc call .swapBytes ; swap move PP xor a @@ -2903,7 +2913,7 @@ SwapMovesInMenu: ; 3d435 (f:5435) PrintMenuItem: ; 3d4b6 (f:54b6) xor a ld [H_AUTOBGTRANSFERENABLED], a - hlCoord 0, 8 + coord hl, 0, 8 ld b, $3 ld c, $9 call TextBoxBorder @@ -2916,7 +2926,7 @@ PrintMenuItem: ; 3d4b6 (f:54b6) ld a, [wCurrentMenuItem] cp b jr nz, .notDisabled - hlCoord 1, 10 + coord hl, 1, 10 ld de, DisabledText call PlaceString jr .moveDisabled @@ -2930,13 +2940,13 @@ PrintMenuItem: ; 3d4b6 (f:54b6) ld c, a ld b, $0 ; which item in the menu is the cursor pointing to? (0-3) add hl, bc ; point to the item (move) in memory - ld a, [hl] - ld [wPlayerSelectedMove], a ; update wPlayerSelectedMove even if the move + ld a, [hl] + ld [wPlayerSelectedMove], a ; update wPlayerSelectedMove even if the move ; isn't actually selected (just pointed to by the cursor) ld a, [wPlayerMonNumber] ld [wWhichPokemon], a - ld a, $4 - ld [wcc49], a + ld a, BATTLE_MON_DATA + ld [wMonDataLocation], a callab GetMaxPP ld hl, wCurrentMenuItem ld c, [hl] @@ -2947,24 +2957,24 @@ PrintMenuItem: ; 3d4b6 (f:54b6) ld a, [hl] and $3f ld [wcd6d], a -; print TYPE/<type> and <curPP>/<maxPP> - hlCoord 1, 9 +; print TYPE/<type> and <curPP>/<maxPP> + coord hl, 1, 9 ld de, TypeText call PlaceString - hlCoord 7, 11 + coord hl, 7, 11 ld [hl], "/" - hlCoord 5, 9 + coord hl, 5, 9 ld [hl], "/" - hlCoord 5, 11 + coord hl, 5, 11 ld de, wcd6d - ld bc, $102 + lb bc, 1, 2 call PrintNumber - hlCoord 8, 11 - ld de, wd11e - ld bc, $102 + coord hl, 8, 11 + ld de, wMaxPP + lb bc, 1, 2 call PrintNumber - call GetCurrentMove - hlCoord 2, 10 + call GetCurrentMove + coord hl, 2, 10 predef PrintMoveType .moveDisabled ld a, $1 @@ -2979,7 +2989,7 @@ TypeText: ; 3d55f (f:555f) SelectEnemyMove: ; 3d564 (f:5564) ld a, [wLinkState] - sub $4 + sub LINK_STATE_BATTLING jr nz, .noLinkBattle ; link battle call SaveScreenTilesToBuffer1 @@ -3037,18 +3047,18 @@ SelectEnemyMove: ; 3d564 (f:5564) push hl call BattleRandom ld b, $1 - cp $3f ; select move 1 in [0,3e] (63/256 chance) + cp $3f ; select move 1, [0,3e] (63/256 chance) jr c, .moveChosen inc hl inc b - cp $7f ; select move 1 in [3f,7e] (64/256 chance) + cp $7f ; select move 2, [3f,7e] (64/256 chance) jr c, .moveChosen inc hl inc b - cp $be ; select move 1 in [7f,bd] (63/256 chance) + cp $be ; select move 3, [7f,bd] (63/256 chance) jr c, .moveChosen inc hl - inc b ; select move 4 in [be,ff] (66/256 chance) + inc b ; select move 4, [be,ff] (66/256 chance) .moveChosen ld a, b dec a @@ -3075,46 +3085,47 @@ LinkBattleExchangeData: ; 3d605 (f:5605) ld [wSerialExchangeNybbleReceiveData], a ld a, [wPlayerMoveListIndex] cp $f ; is the player running from battle? - jr z, .asm_3d630 - ld a, [wcd6a] - and a - jr nz, .asm_3d629 + jr z, .doExchange + ld a, [wActionResultOrTookBattleTurn] + and a ; is the player switching in another mon? + jr nz, .switching +; the player used a move ld a, [wPlayerSelectedMove] cp STRUGGLE ld b, $e - jr z, .asm_3d62f + jr z, .next dec b inc a - jr z, .asm_3d62f + jr z, .next ld a, [wPlayerMoveListIndex] - jr .asm_3d630 -.asm_3d629 + jr .doExchange +.switching ld a, [wWhichPokemon] - add $4 + add 4 ld b, a -.asm_3d62f +.next ld a, b -.asm_3d630 +.doExchange ld [wSerialExchangeNybbleSendData], a callab PrintWaitingText -.asm_3d63b +.syncLoop1 call Serial_ExchangeNybble call DelayFrame ld a, [wSerialExchangeNybbleReceiveData] inc a - jr z, .asm_3d63b - ld b, $a -.asm_3d649 + jr z, .syncLoop1 + ld b, 10 +.syncLoop2 call DelayFrame call Serial_ExchangeNybble dec b - jr nz, .asm_3d649 - ld b, $a -.asm_3d654 + jr nz, .syncLoop2 + ld b, 10 +.syncLoop3 call DelayFrame call Serial_SendZeroByte dec b - jr nz, .asm_3d654 + jr nz, .syncLoop3 ret ExecutePlayerMove: ; 3d65e (f:565e) @@ -3129,8 +3140,8 @@ ExecutePlayerMove: ; 3d65e (f:565e) ld [wMoveDidntMiss], a ld a, $a ld [wDamageMultipliers], a - ld a, [wcd6a] - and a + ld a, [wActionResultOrTookBattleTurn] + and a ; has the player already used the turn (e.g. by using an item, trying to run or switching pokemon) jp nz, ExecutePlayerMoveDone call PrintGhostText jp z, ExecutePlayerMoveDone @@ -3170,13 +3181,13 @@ PlayerCanExecuteMove: ; 3d6b0 (f:56b0) ld hl,ResidualEffects1 ld de,1 call IsInArray - jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests - ; unless executed as part of their exclusive effect functions + jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests + ; unless executed as part of their exclusive effect functions ld a,[W_PLAYERMOVEEFFECT] ld hl,SpecialEffectsCont ld de,1 call IsInArray - call c,JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything + call c,JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything PlayerCalcMoveDamage: ; 3d6dc (f:56dc) ld a,[W_PLAYERMOVEEFFECT] ld hl,SetDamageEffects @@ -3199,7 +3210,7 @@ handleIfPlayerMoveMissed and a jr z,getPlayerAnimationType ld a,[W_PLAYERMOVEEFFECT] - sub a,EXPLODE_EFFECT + sub a,EXPLODE_EFFECT jr z,playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT jr playerCheckIfFlyOrChargeEffect getPlayerAnimationType @@ -3211,9 +3222,9 @@ getPlayerAnimationType playPlayerMoveAnimation push af ld a,[W_PLAYERBATTSTATUS2] - bit 4,a - ld hl,Func_79747 - ld b,BANK(Func_79747) + bit HasSubstituteUp,a + ld hl,HideSubstituteShowMonAnim + ld b,BANK(HideSubstituteShowMonAnim) call nz,Bankswitch pop af ld [wAnimationType],a @@ -3222,13 +3233,13 @@ playPlayerMoveAnimation call HandleExplodingAnimation call DrawPlayerHUDAndHPBar ld a,[W_PLAYERBATTSTATUS2] - bit 4,a - ld hl,Func_79771 - ld b,BANK(Func_79771) + bit HasSubstituteUp,a + ld hl,ReshowSubstituteAnim + ld b,BANK(ReshowSubstituteAnim) call nz,Bankswitch jr MirrorMoveCheck playerCheckIfFlyOrChargeEffect - ld c,$1E + ld c,30 call DelayFrames ld a,[W_PLAYERMOVEEFFECT] cp a,FLY_EFFECT @@ -3294,7 +3305,7 @@ MirrorMoveCheck ld a,[wPlayerNumAttacksLeft] dec a ld [wPlayerNumAttacksLeft],a - jp nz,getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. + jp nz,getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. ; damage calculation and accuracy tests only happen for the first hit res AttackingMultipleTimes,[hl] ; clear attacking multiple times status when all attacks are over ld hl,MultiHitText @@ -3320,7 +3331,7 @@ MultiHitText: ; 3d805 (f:5805) ExecutePlayerMoveDone: ; 3d80a (f:580a) xor a - ld [wcd6a],a + ld [wActionResultOrTookBattleTurn],a ld b,1 ret @@ -3505,8 +3516,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .MonHurtItselfOrFullyParalysed ld hl,W_PLAYERBATTSTATUS1 ld a,[hl] - ; clear bide, thrashing, charging up, and trapping moves such as warp (already cleared for confusion damage) - and $ff ^ ((1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << ChargingUp) | (1 << UsingTrappingMove)) + ; clear bide, thrashing, charging up, and trapping moves such as warp (already cleared for confusion damage) + and $ff ^ ((1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << ChargingUp) | (1 << UsingTrappingMove)) ld [hl],a ld a,[W_PLAYERMOVEEFFECT] cp a,FLY_EFFECT @@ -3584,7 +3595,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld hl,wPlayerNumAttacksLeft dec [hl] ; did Thrashing About counter hit 0? ld hl,PlayerCalcMoveDamage ; skip DecrementPP - jp nz,.returnToHL + jp nz,.returnToHL push hl ld hl,W_PLAYERBATTSTATUS1 res ThrashingAbout,[hl] ; no longer thrashing about @@ -3605,7 +3616,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld a,[wPlayerNumAttacksLeft] dec a ; did multi-turn move end? ld [wPlayerNumAttacksLeft],a - ld hl,getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit), + ld hl,getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit), ; DecrementPP and MoveHitTest jp nz,.returnToHL jp .returnToHL @@ -3702,7 +3713,7 @@ PrintMoveIsDisabledText: ; 3da88 (f:5a88) ld de, W_ENEMYBATTSTATUS1 .removeChargingUp ld a, [de] - res ChargingUp, a ; end the pokemon's + res ChargingUp, a ; end the pokemon's ld [de], a ld a, [hl] ld [wd11e], a @@ -3762,9 +3773,14 @@ PrintMonName1Text: ; 3daf5 (f:5af5) ld hl, MonName1Text jp PrintText +; this function wastes time calling DetermineExclamationPointTextNum +; and choosing between Used1Text and Used2Text, even though +; those text strings are identical and both continue at PrintInsteadText +; this likely had to do with Japanese grammar that got translated, +; but the functionality didn't get removed MonName1Text: ; 3dafb (f:5afb) TX_FAR _MonName1Text - db $08 ; asm + TX_ASM ld a, [H_WHOSETURN] and a ld a, [W_PLAYERMOVENUM] @@ -3775,7 +3791,7 @@ MonName1Text: ; 3dafb (f:5afb) .asm_3db11 ld [hl], a ld [wd11e], a - call Func_3db85 + call DetermineExclamationPointTextNum ld a, [wMonIsDisobedient] and a ld hl, Used2Text @@ -3789,33 +3805,35 @@ MonName1Text: ; 3dafb (f:5afb) Used1Text: ; 3db2d (f:5b2d) TX_FAR _Used1Text - db $08 ; asm + TX_ASM jr PrintInsteadText Used2Text: ; 3db34 (f:5b34) TX_FAR _Used2Text - db $08 ; asm + TX_ASM + ; fall through PrintInsteadText: ; 3db39 (f:5b39) ld a, [wMonIsDisobedient] and a - jr z, PrintCF4BText + jr z, PrintMoveName ld hl, InsteadText ret InsteadText: ; 3db43 (f:5b43) TX_FAR _InsteadText - db $08 ; asm + TX_ASM + ; fall through -PrintCF4BText: ; 3db48 (f:5b48) - ld hl, CF4BText +PrintMoveName: ; 3db48 (f:5b48) + ld hl, _PrintMoveName ret -CF4BText: ; 3db4c (f:5b4c) +_PrintMoveName: ; 3db4c (f:5b4c) TX_FAR _CF4BText - db $08 ; asm + TX_ASM ld hl, ExclamationPointPointerTable - ld a, [wd11e] + ld a, [wd11e] ; exclamation point num add a push bc ld b, $0 @@ -3854,29 +3872,36 @@ ExclamationPoint5Text: ; 3db80 (f:5b80) TX_FAR _ExclamationPoint5Text db "@" -Func_3db85: ; 3db85 (f:5b85) +; this function does nothing useful +; if the move being used is in set [1-4] from ExclamationPointMoveSets, +; use ExclamationPoint[1-4]Text +; otherwise, use ExclamationPoint5Text +; but all five text strings are identical +; this likely had to do with Japanese grammar that got translated, +; but the functionality didn't get removed +DetermineExclamationPointTextNum: ; 3db85 (f:5b85) push bc - ld a, [wd11e] ; move number + ld a, [wd11e] ; move ID ld c, a ld b, $0 - ld hl, UnknownMovesList_3dba3 -.asm_3db8f + ld hl, ExclamationPointMoveSets +.loop ld a, [hli] cp $ff - jr z, .asm_3db9d + jr z, .done cp c - jr z, .asm_3db9d + jr z, .done and a - jr nz, .asm_3db8f + jr nz, .loop inc b - jr .asm_3db8f -.asm_3db9d + jr .loop +.done ld a, b - ld [wd11e], a + ld [wd11e], a ; exclamation point num pop bc ret -UnknownMovesList_3dba3: ; 3dba3 (f:5ba3) +ExclamationPointMoveSets: ; 3dba3 (f:5ba3) db SWORDS_DANCE, GROWTH db $00 db RECOVER, BIDE, SELFDESTRUCT, AMNESIA @@ -3919,7 +3944,7 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) ; if you get here, the mon used jump kick or hi jump kick and missed ld hl, W_DAMAGE ; since the move missed, W_DAMAGE will always contain 0 at this point. - ; Thus, recoil damage will always be equal to 1 + ; Thus, recoil damage will always be equal to 1 ; even if it was intended to be potential damage/8. ld a, [hli] ld b, [hl] @@ -3940,7 +3965,7 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) ld hl, KeptGoingAndCrashedText call PrintText ld b, $4 - predef Func_48125 + predef PredefShakeScreenHorizontally ld a, [H_WHOSETURN] and a jr nz, .enemyTurn @@ -3986,7 +4011,7 @@ PrintCriticalOHKOText: ; 3dc5c (f:5c5c) xor a ld [wCriticalHitOrOHKO], a .done - ld c, $14 + ld c, 20 jp DelayFrames CriticalOHKOTextPointers: ; 3dc7a (f:5c7a) @@ -4673,7 +4698,7 @@ CriticalHitTest: ; 3e023 (f:6023) jr z, .calcCriticalHitProbability ld hl, W_ENEMYMOVEPOWER ld de, W_ENEMYBATTSTATUS2 -.calcCriticalHitProbability ; 0x3e04f +.calcCriticalHitProbability ld a, [hld] ; read base power from RAM and a ret z ; do nothing if zero @@ -4772,7 +4797,7 @@ HandleCounterMove: ; 3e093 (f:6093) ld a,[hli] or [hl] ret z ; If we made it here, Counter still misses if the last move used in battle did no damage to its target. - ; W_DAMAGE is shared by both players, so Counter may strike back damage dealt by the Counter user itself + ; W_DAMAGE is shared by both players, so Counter may strike back damage dealt by the Counter user itself ; if the conditions meet, even though 99% of the times damage will come from the target. ; if it did damage, double it ld a,[hl] @@ -4905,7 +4930,7 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142) ld [wHPBarNewHP+1],a ld a,[hl] ld [wHPBarNewHP],a - hlCoord 2, 2 + coord hl, 2, 2 xor a ld [wHPBarType],a predef UpdateHPBar2 ; animate the HP bar shortening @@ -5023,7 +5048,7 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200) ld [wHPBarMaxHP+1],a ld a,[hl] ld [wHPBarMaxHP],a - hlCoord 10, 9 + coord hl, 10, 9 ld a,$01 ld [wHPBarType],a predef UpdateHPBar2 ; animate the HP bar shortening @@ -5033,9 +5058,9 @@ ApplyAttackToPlayerPokemonDone AttackSubstitute: ; 3e25e (f:625e) ; Unlike the two ApplyAttackToPokemon functions, Attack Substitute is shared by player and enemy. ; Self-confusion damage as well as Hi-Jump Kick and Jump Kick recoil cause a momentary turn swap before being applied. -; If the user has a Substitute up and would take damage because of that, +; If the user has a Substitute up and would take damage because of that, ; damage will be applied to the other player's Substitute. -; Normal recoil such as from Double-Edge isn't affected by this glitch, +; Normal recoil such as from Double-Edge isn't affected by this glitch, ; because this function is never called in that case. ld hl,SubstituteTookDamageText @@ -5060,7 +5085,7 @@ AttackSubstitute: ; 3e25e (f:625e) ld [de],a ret nc .substituteBroke -; If the target's Substitute breaks, W_DAMAGE isn't updated with the amount of HP +; If the target's Substitute breaks, W_DAMAGE isn't updated with the amount of HP ; the Substitute had before being attacked. ld h,b ld l,c @@ -5071,7 +5096,7 @@ AttackSubstitute: ; 3e25e (f:625e) ld a,[H_WHOSETURN] xor a,$01 ld [H_WHOSETURN],a - callab Func_79747 ; animate the substitute breaking + callab HideSubstituteShowMonAnim ; animate the substitute breaking ; flip the turn back to the way it was ld a,[H_WHOSETURN] xor a,$01 @@ -5181,7 +5206,7 @@ ReloadMoveData: ; 3e329 (f:6329) ld [wd11e],a dec a ld hl,Moves - ld bc,$0006 + ld bc,MoveEnd - Moves call AddNTimes ld a,BANK(Moves) call FarCopyData ; copy the move's stats @@ -5266,7 +5291,7 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5) ld d,a ; d = type 1 of defender ld e,[hl] ; e = type 2 of defender ld a,[W_PLAYERMOVETYPE] - ld [wd11e],a + ld [wMoveType],a ld a,[H_WHOSETURN] and a jr z,.next @@ -5280,9 +5305,9 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5) ld d,a ; d = type 1 of defender ld e,[hl] ; e = type 2 of defender ld a,[W_ENEMYMOVETYPE] - ld [wd11e],a + ld [wMoveType],a .next - ld a,[wd11e] ; move type + ld a,[wMoveType] cp b ; does the move type match type 1 of the attacker? jr z,.sameTypeAttackBonus cp c ; does the move type match type 2 of the attacker? @@ -5307,8 +5332,8 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5) ld hl,wDamageMultipliers set 7,[hl] .skipSameTypeAttackBonus - ld a,[wd11e] - ld b,a ; b = move type + ld a,[wMoveType] + ld b,a ld hl,TypeEffects .loop ld a,[hli] ; a = "attacking type" of the current type pair @@ -5371,29 +5396,29 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5) ; function to tell how effective the type of an enemy attack is on the player's current pokemon ; this doesn't take into account the effects that dual types can have ; (e.g. 4x weakness / resistance, weaknesses and resistances canceling) -; the result is stored in [wd11e] +; the result is stored in [wTypeEffectiveness] ; ($05 is not very effective, $10 is neutral, $14 is super effective) ; as far is can tell, this is only used once in some AI code to help decide which move to use AIGetTypeEffectiveness: ; 3e449 (f:6449) ld a,[W_ENEMYMOVETYPE] - ld d,a ; d = type of enemy move + ld d,a ; d = type of enemy move ld hl,wBattleMonType - ld b,[hl] ; b = type 1 of player's pokemon + ld b,[hl] ; b = type 1 of player's pokemon inc hl - ld c,[hl] ; c = type 2 of player's pokemon + ld c,[hl] ; c = type 2 of player's pokemon ld a,$10 - ld [wd11e],a ; initialize [wd11e] to neutral effectiveness + ld [wTypeEffectiveness],a ; initialize to neutral effectiveness ld hl,TypeEffects .loop ld a,[hli] cp a,$ff ret z - cp d ; match the type of the move + cp d ; match the type of the move jr nz,.nextTypePair1 ld a,[hli] - cp b ; match with type 1 of pokemon + cp b ; match with type 1 of pokemon jr z,.done - cp c ; or match with type 2 of pokemon + cp c ; or match with type 2 of pokemon jr z,.done jr .nextTypePair2 .nextTypePair1 @@ -5403,7 +5428,7 @@ AIGetTypeEffectiveness: ; 3e449 (f:6449) jr .loop .done ld a,[hl] - ld [wd11e],a ; store damage multiplier + ld [wTypeEffectiveness],a ; store damage multiplier ret INCLUDE "data/type_effects.asm" @@ -5561,7 +5586,7 @@ CalcHitChance: ; 3e624 (f:6624) ; the second iteration multiplies by the evasion ratio .loop push bc - ld hl, StatModifierRatios ; $76cb ; stat modifier ratios + ld hl, StatModifierRatios ; stat modifier ratios dec b sla b ld c,b @@ -5749,8 +5774,8 @@ playEnemyMoveAnimation: ; 3e7a4 (f:67a4) push af ld a, [W_ENEMYBATTSTATUS2] bit HasSubstituteUp, a ; does mon have a substitute? - ld hl, Func_79747 - ld b, BANK(Func_79747) + ld hl, HideSubstituteShowMonAnim + ld b, BANK(HideSubstituteShowMonAnim) call nz, Bankswitch pop af ld [wAnimationType], a @@ -5760,14 +5785,14 @@ playEnemyMoveAnimation: ; 3e7a4 (f:67a4) call DrawEnemyHUDAndHPBar ld a, [W_ENEMYBATTSTATUS2] bit HasSubstituteUp, a ; does mon have a substitute? - ld hl, Func_79771 - ld b, BANK(Func_79771) + ld hl, ReshowSubstituteAnim + ld b, BANK(ReshowSubstituteAnim) call nz, Bankswitch ; slide the substitute's sprite out jr EnemyCheckIfMirrorMoveEffect EnemyCheckIfFlyOrChargeEffect: ; 3e7d1 (f:67d1) call SwapPlayerAndEnemyLevels - ld c, $1e + ld c, 30 call DelayFrames ld a, [W_ENEMYMOVEEFFECT] cp FLY_EFFECT @@ -6019,7 +6044,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) .monHurtItselfOrFullyParalysed ld hl, W_ENEMYBATTSTATUS1 ld a, [hl] - ; clear bide, thrashing about, charging up, and multi-turn moves such as warp + ; clear bide, thrashing about, charging up, and multi-turn moves such as warp and $ff ^ ((1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << ChargingUp) | (1 << UsingTrappingMove)) ld [hl], a ld a, [W_ENEMYMOVEEFFECT] @@ -6115,7 +6140,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) call PrintText ld hl, wEnemyNumAttacksLeft dec [hl] ; did multi-turn move end? - ld hl, GetEnemyAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit), + ld hl, GetEnemyAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit), ; DecrementPP and MoveHitTest jp nz, .enemyReturnToHL jp .enemyReturnToHL @@ -6149,15 +6174,15 @@ GetCurrentMove: ; 3eabe (f:6abe) .player ld de, W_PLAYERMOVENUM ld a, [W_FLAGS_D733] - bit 0, a - ld a, [wccd9] + bit BIT_TEST_BATTLE, a + ld a, [wTestBattlePlayerSelectedMove] jr nz, .selected ld a, [wPlayerSelectedMove] .selected ld [wd0b5], a dec a ld hl, Moves - ld bc, $6 + ld bc, MoveEnd - Moves call AddNTimes ld a, BANK(Moves) call FarCopyData @@ -6180,7 +6205,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) call GetMonHeader ld a, [W_ENEMYBATTSTATUS3] bit Transformed, a ; is enemy mon transformed? - ld hl, wcceb ; copied DVs from when it used Transform + ld hl, wTransformedEnemyMonOriginalDVs ; original DVs before transforming ld a, [hli] ld b, [hl] jr nz, .storeDVs @@ -6279,15 +6304,15 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) dec de dec de xor a - ld [wHPBarMaxHP], a + ld [wLearningMovesFromDayCare], a predef WriteMonMoves ; get moves based on current level .loadMovePPs ld hl, wEnemyMonMoves - ld de, wEnemyMonSpecial + 1 + ld de, wEnemyMonPP - 1 predef LoadMovePPs ld hl, W_MONHBASESTATS ld de, wEnemyMonBaseStats - ld b, $5 + ld b, NUM_STATS .copyBaseStatsLoop ld a, [hli] ld [de], a @@ -6305,7 +6330,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) call GetMonName ld hl, wcd6d ld de, wEnemyMonNick - ld bc, $b + ld bc, NAME_LENGTH call CopyData ld a, [wEnemyMonSpecies2] ld [wd11e], a @@ -6313,15 +6338,15 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) ld a, [wd11e] dec a ld c, a - ld b, $1 + ld b, FLAG_SET ld hl, wPokedexSeen predef FlagActionPredef ; mark this mon as seen in the pokedex ld hl, wEnemyMonLevel ld de, wEnemyMonUnmodifiedLevel - ld bc, $b + ld bc, 1 + NUM_STATS * 2 call CopyData ld a, $7 ; default stat mod - ld b, $8 ; number of stat mods + ld b, NUM_STAT_MODS ; number of stat mods ld hl, wEnemyMonStatMods .statModLoop ld [hli], a @@ -6392,7 +6417,7 @@ LoadPlayerBackPic: ; 3ec92 (f:6c92) predef ScaleSpriteByTwo ld hl, wOAMBuffer xor a - ld [$FF8B], a ; initial tile number + ld [hOAMTile], a ; initial tile number ld b, $7 ; 7 columns ld e, $a0 ; X for the left-most column .loop ; each loop iteration writes 3 OAM entries in a vertical column @@ -6406,16 +6431,16 @@ LoadPlayerBackPic: ; 3ec92 (f:6c92) add d ; increase Y by height of tile ld d, a inc hl - ld a, [$FF8B] + ld a, [hOAMTile] ld [hli], a ; OAM tile number inc a ; increment tile number - ld [$FF8B], a + ld [hOAMTile], a inc hl dec c jr nz, .innerLoop - ld a, [$FF8B] + ld a, [hOAMTile] add $4 ; increase tile number by 4 - ld [$FF8B], a + ld [hOAMTile], a ld a, $8 ; width of tile add e ; increase X by width of tile ld e, a @@ -6436,21 +6461,17 @@ LoadPlayerBackPic: ; 3ec92 (f:6c92) xor a ld [$0], a ld a, $31 - ld [$ffe1], a - hlCoord 1, 5 - predef_jump Func_3f0c6 + ld [hStartTileID], a + coord hl, 1, 5 + predef_jump CopyUncompressedPicToTilemap ; does nothing since no stats are ever selected (barring glitches) DoubleOrHalveSelectedStats: ; 3ed02 (f:6d02) callab DoubleSelectedStats - ld hl, HalveSelectedStats - ld b, BANK(HalveSelectedStats) - jp Bankswitch + jpab HalveSelectedStats ScrollTrainerPicAfterBattle: ; 3ed12 (f:6d12) - ld hl, _ScrollTrainerPicAfterBattle - ld b, BANK(_ScrollTrainerPicAfterBattle) - jp Bankswitch + jpab _ScrollTrainerPicAfterBattle ApplyBurnAndParalysisPenaltiesToPlayer: ; 3ed1a (f:6d1a) ld a, $1 @@ -6552,7 +6573,7 @@ CalculateModifiedStats: ; 3ed99 (f:6d99) call CalculateModifiedStat inc c ld a, c - cp 4 + cp NUM_STATS - 1 jr nz, .loop ret @@ -6560,12 +6581,12 @@ CalculateModifiedStats: ; 3ed99 (f:6d99) CalculateModifiedStat: ; 3eda5 (f:6da5) push bc push bc - ld a, [wd11e] + ld a, [wCalculateWhoseStats] and a ld a, c ld hl, wBattleMonAttack ld de, wPlayerMonUnmodifiedAttack - ld bc, wPlayerMonAttackMod + ld bc, wPlayerMonStatMods jr z, .next ld hl, wEnemyMonAttack ld de, wEnemyMonUnmodifiedAttack @@ -6698,22 +6719,22 @@ LoadHudTilePatterns: ; 3ee5b (f:6e5b) .lcdDisabled ld hl, BattleHudTiles1 ld de, vChars2 + $6d0 - ld bc, $18 + ld bc, BattleHudTiles1End - BattleHudTiles1 ld a, BANK(BattleHudTiles1) call FarCopyDataDouble ld hl, BattleHudTiles2 ld de, vChars2 + $730 - ld bc, $30 + ld bc, BattleHudTiles3End - BattleHudTiles2 ld a, BANK(BattleHudTiles2) jp FarCopyDataDouble .lcdEnabled ld de, BattleHudTiles1 ld hl, vChars2 + $6d0 - ld bc, (BANK(BattleHudTiles1) << 8) + $03 + lb bc, BANK(BattleHudTiles1), (BattleHudTiles1End - BattleHudTiles1) / $8 call CopyVideoDataDouble ld de, BattleHudTiles2 ld hl, vChars2 + $730 - ld bc, (BANK(BattleHudTiles2) << 8) + $06 + lb bc, BANK(BattleHudTiles2), (BattleHudTiles3End - BattleHudTiles2) / $8 jp CopyVideoDataDouble PrintEmptyString: ; 3ee94 (f:6e94) @@ -6749,8 +6770,8 @@ BattleRandom: push hl push bc push af - -; point to seed 0 so we pick the first number the next time + +; point to seed 0 so we pick the first number the next time xor a ld [wLinkBattleRandomNumberListIndex], a @@ -6759,11 +6780,11 @@ BattleRandom: .loop ld a, [hl] ld c, a -; multiply by 5 +; multiply by 5 add a add a add c -; add 1 +; add 1 inc a ld [hli], a dec b @@ -6778,11 +6799,11 @@ BattleRandom: HandleExplodingAnimation: ; 3eed3 (f:6ed3) ld a, [H_WHOSETURN] and a - ld hl, wEnemyMonType1 ; wcfea + ld hl, wEnemyMonType1 ld de, W_ENEMYBATTSTATUS1 ld a, [W_PLAYERMOVENUM] jr z, .asm_3eeea - ld hl, wBattleMonType1 ; wd019 + ld hl, wBattleMonType1 ld de, W_ENEMYBATTSTATUS1 ld a, [W_ENEMYMOVENUM] .asm_3eeea @@ -6812,10 +6833,10 @@ PlayMoveAnimation: ; 3ef07 (f:6f07) predef_jump MoveAnimation ; unreferenced -Func_3f069: ; 3f069 (f:7069) +ResetCryModifiers: ; 3f069 (f:7069) xor a - ld [wc0f1], a - ld [wc0f2], a + ld [wFrequencyModifier], a + ld [wTempoModifier], a jp PlaySound JumpMoveEffect: ; 3f132 (f:7132) @@ -7063,7 +7084,7 @@ PoisonEffect: ; 3f24f (f:724f) cp POISON_EFFECT ret nz .didntAffect - ld c, $32 + ld c, 50 call DelayFrames jp PrintDidntAffectText @@ -7076,9 +7097,7 @@ BadlyPoisonedText: ; 3f2e4 (f:72e4) db "@" DrainHPEffect: ; 3f2e9 (f:72e9) - ld hl, DrainHPEffect_ - ld b, BANK(DrainHPEffect_) - jp Bankswitch + jpab DrainHPEffect_ ExplodeEffect: ; 3f2f1 (f:72f1) ld hl, wBattleMonHP @@ -7325,17 +7344,17 @@ StatModifierUpEffect: ; 3f428 (f:7428) add hl, bc pop bc xor a - ld [H_MULTIPLICAND], a + ld [H_MULTIPLICAND], a ld a, [de] ld [H_MULTIPLICAND + 1], a inc de ld a, [de] ld [H_MULTIPLICAND + 2], a ld a, [hli] - ld [H_MULTIPLIER], a + ld [H_MULTIPLIER], a call Multiply ld a, [hl] - ld [H_DIVISOR], a + ld [H_DIVISOR], a ld b, $4 call Divide pop hl @@ -7359,27 +7378,29 @@ UpdateStat: ; 3f4c3 (f:74c3) UpdateStatDone: ; 3f4ca (f:74ca) ld b, c inc b - call Func_3f688 + call PrintStatText ld hl, W_PLAYERBATTSTATUS2 ld de, W_PLAYERMOVENUM - ld bc, wccf7 + ld bc, wPlayerMonMinimized ld a, [H_WHOSETURN] and a jr z, .asm_3f4e6 ld hl, W_ENEMYBATTSTATUS2 ld de, W_ENEMYMOVENUM - ld bc, wccf3 + ld bc, wEnemyMonMinimized .asm_3f4e6 ld a, [de] cp MINIMIZE jr nz, .asm_3f4f9 - bit HasSubstituteUp, [hl] ; substitute + ; if a substitute is up, slide off the substitute and show the mon pic before + ; playing the minimize animation + bit HasSubstituteUp, [hl] push af push bc - ld hl, Func_79747 - ld b, BANK(Func_79747) + ld hl, HideSubstituteShowMonAnim + ld b, BANK(HideSubstituteShowMonAnim) push de - call nz, Bankswitch ; play Minimize animation unless there's Substitute involved + call nz, Bankswitch pop de .asm_3f4f9 call PlayCurrentMoveAnimation @@ -7389,8 +7410,8 @@ UpdateStatDone: ; 3f4ca (f:74ca) pop bc ld a, $1 ld [bc], a - ld hl, Func_79771 - ld b, BANK(Func_79771) + ld hl, ReshowSubstituteAnim + ld b, BANK(ReshowSubstituteAnim) pop af call nz, Bankswitch .applyBadgeBoostsAndStatusPenalties @@ -7415,7 +7436,7 @@ PrintNothingHappenedText: ; 3f522 (f:7522) MonsStatsRoseText: ; 3f528 (f:7528) TX_FAR _MonsStatsRoseText - db $08 ; asm + TX_ASM ld hl, GreatlyRoseText ld a, [H_WHOSETURN] and a @@ -7529,7 +7550,7 @@ StatModifierDownEffect: ; 3f54c (f:754c) jr nz, .recalculateStat ld a, [hl] and a - jp z, Func_3f64d + jp z, CantLowerAnymore_Pop .recalculateStat ; recalculate affected stat ; paralysis and burn penalties, as well as badge boosts are ignored @@ -7543,17 +7564,17 @@ StatModifierDownEffect: ; 3f54c (f:754c) add hl, bc pop bc xor a - ld [H_MULTIPLICAND], a + ld [H_MULTIPLICAND], a ld a, [de] ld [H_MULTIPLICAND + 1], a inc de ld a, [de] ld [H_MULTIPLICAND + 2], a ld a, [hli] - ld [H_MULTIPLIER], a + ld [H_MULTIPLIER], a call Multiply ld a, [hl] - ld [H_DIVISOR], a + ld [H_DIVISOR], a ld b, $4 call Divide pop hl @@ -7577,7 +7598,7 @@ UpdateLoweredStatDone: ; 3f62c (f:762c) ld b, c inc b push de - call Func_3f688 + call PrintStatText pop de ld a, [de] cp $44 @@ -7597,7 +7618,7 @@ UpdateLoweredStatDone: ; 3f62c (f:762c) call QuarterSpeedDueToParalysis jp HalveAttackDueToBurn -Func_3f64d: ; 3f64d (f:764d) +CantLowerAnymore_Pop: ; 3f64d (f:764d) pop de pop hl inc [hl] @@ -7617,7 +7638,7 @@ MoveMissed: ; 3f65a (f:765a) MonsStatsFellText: ; 3f661 (f:7661) TX_FAR _MonsStatsFellText - db $08 ; asm + TX_ASM ld hl, FellText ld a, [H_WHOSETURN] and a @@ -7640,9 +7661,9 @@ FellText: ; 3f683 (f:7683) TX_FAR _FellText db "@" -Func_3f688: ; 3f688 (f:7688) +PrintStatText: ; 3f688 (f:7688) ld hl, StatsTextStrings - ld c, $50 + ld c, "@" .asm_3f68d dec b jr z, .asm_3f696 @@ -7749,7 +7770,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) srl b cp b jr nc, .asm_3f76e - ld c, $32 + ld c, 50 call DelayFrames ld a, [W_PLAYERMOVENUM] cp TELEPORT @@ -7764,7 +7785,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) ld a, [W_PLAYERMOVENUM] jr .asm_3f7e4 .asm_3f77e - ld c, $32 + ld c, 50 call DelayFrames ld hl, IsUnaffectedText ld a, [W_PLAYERMOVENUM] @@ -7791,7 +7812,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) srl b cp b jr nc, .asm_3f7c1 - ld c, $32 + ld c, 50 call DelayFrames ld a, [W_ENEMYMOVENUM] cp TELEPORT @@ -7806,7 +7827,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) ld a, [W_ENEMYMOVENUM] jr .asm_3f7e4 .asm_3f7d1 - ld c, $32 + ld c, 50 call DelayFrames ld hl, IsUnaffectedText ld a, [W_ENEMYMOVENUM] @@ -7816,7 +7837,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) .asm_3f7e4 push af call PlayBattleAnimation - ld c, $14 + ld c, 20 call DelayFrames pop af ld hl, RanFromBattleText @@ -7911,9 +7932,7 @@ FlinchSideEffect: ; 3f85b (f:785b) ret OneHitKOEffect: ; 3f884 (f:7884) - ld hl, OneHitKOEffect_ - ld b, BANK(OneHitKOEffect_) - jp Bankswitch + jpab OneHitKOEffect_ ChargeEffect: ; 3f88c (f:788c) ld hl, W_PLAYERBATTSTATUS1 @@ -7945,14 +7964,14 @@ ChargeEffect: ; 3f88c (f:788c) ld a, b call PlayBattleAnimation ld a, [de] - ld [wWhichTrade], a + ld [wChargeMoveNum], a ld hl, ChargeMoveEffectText jp PrintText ChargeMoveEffectText: ; 3f8c8 (f:78c8) TX_FAR _ChargeMoveEffectText - db $08 ; asm - ld a, [wWhichTrade] + TX_ASM + ld a, [wChargeMoveNum] cp RAZOR_WIND ld hl, MadeWhirlwindText jr z, .asm_3f8f8 @@ -8008,8 +8027,8 @@ TrappingEffect: ; 3f917 (f:7917) .trappingEffect bit UsingTrappingMove, [hl] ret nz - call ClearHyperBeam ; since this effect is called before testing whether the move will hit, - ; the target won't need to recharge even if the trapping move missed + call ClearHyperBeam ; since this effect is called before testing whether the move will hit, + ; the target won't need to recharge even if the trapping move missed set UsingTrappingMove, [hl] ; mon is now using a trapping move call BattleRandom ; 3/8 chance for 2 and 3 attacks, and 1/8 chance for 4 and 5 attacks and $3 @@ -8023,19 +8042,13 @@ TrappingEffect: ; 3f917 (f:7917) ret MistEffect: ; 3f941 (f:7941) - ld hl, MistEffect_ - ld b, BANK(MistEffect_) - jp Bankswitch + jpab MistEffect_ FocusEnergyEffect: ; 3f949 (f:7949) - ld hl, FocusEnergyEffect_ - ld b, BANK(FocusEnergyEffect_) - jp Bankswitch + jpab FocusEnergyEffect_ RecoilEffect: ; 3f951 (f:7951) - ld hl, RecoilEffect_ - ld b, BANK(RecoilEffect_) - jp Bankswitch + jpab RecoilEffect_ ConfusionSideEffect: ; 3f959 (f:7959) call BattleRandom @@ -8067,7 +8080,7 @@ ConfusionSideEffectSuccess: ; 3f96f (f:796f) set Confused, [hl] ; mon is now confused push af call BattleRandom - and $3 + and $3 inc a inc a ld [bc], a ; confusion status will last 2-5 turns @@ -8084,19 +8097,15 @@ BecameConfusedText: ; 3f9a1 (f:79a1) ConfusionEffectFailed: ; 3f9a6 (f:79a6) cp CONFUSION_SIDE_EFFECT ret z - ld c, $32 + ld c, 50 call DelayFrames jp ConditionalPrintButItFailed ParalyzeEffect: ; 3f9b1 (f:79b1) - ld hl, ParalyzeEffect_ - ld b, BANK(ParalyzeEffect_) - jp Bankswitch + jpab ParalyzeEffect_ SubstituteEffect: ; 3f9b9 (f:79b9) - ld hl, SubstituteEffect_ - ld b, BANK(SubstituteEffect_) - jp Bankswitch + jpab SubstituteEffect_ HyperBeamEffect: ; 3f9c1 (f:79c1) ld hl, W_PLAYERBATTSTATUS2 @@ -8131,7 +8140,7 @@ RageEffect: ; 3f9df (f:79df) ret MimicEffect: ; 3f9ed (f:79ed) - ld c, $32 + ld c, 50 call DelayFrames call MoveHitTest ld a, [W_MOVEMISSED] @@ -8207,9 +8216,7 @@ MimicLearnedMoveText: ; 3fa77 (f:7a77) db "@" LeechSeedEffect: ; 3fa7c (f:7a7c) - ld hl, LeechSeedEffect_ - ld b, BANK(LeechSeedEffect_) - jp Bankswitch + jpab LeechSeedEffect_ SplashEffect: ; 3fa84 (f:7a84) call PlayCurrentMoveAnimation @@ -8248,12 +8255,12 @@ DisableEffect: ; 3fa8a (f:7a8a) ld a, [H_WHOSETURN] and a ld hl, wBattleMonPP - jr nz, .enemyTurn + jr nz, .enemyTurn ld a, [wLinkState] cp LINK_STATE_BATTLING pop hl ; wEnemyMonMoves jr nz, .playerTurnNotLinkBattle -; .playerTurnLinkBattle +; .playerTurnLinkBattle push hl ld hl, wEnemyMonPP .enemyTurn @@ -8278,7 +8285,7 @@ DisableEffect: ; 3fa8a (f:7a8a) and $7 inc a ; 1-8 turns disabled inc c ; move 1-4 will be disabled - swap c + swap c add c ; map disabled move to high nibble of W_ENEMYDISABLEDMOVE / W_PLAYERDISABLEDMOVE ld [de], a call PlayCurrentMoveAnimation2 @@ -8289,7 +8296,7 @@ DisableEffect: ; 3fa8a (f:7a8a) inc hl ; wEnemyDisabledMoveNumber .printDisableText ld a, [wd11e] ; move number - ld [hl], a + ld [hl], a call GetMoveName ld hl, MoveWasDisabledText jp PrintText @@ -8303,34 +8310,22 @@ MoveWasDisabledText: ; 3fb09 (f:7b09) db "@" PayDayEffect: ; 3fb0e (f:7b0e) - ld hl, PayDayEffect_ - ld b, BANK(PayDayEffect_) - jp Bankswitch + jpab PayDayEffect_ ConversionEffect: ; 3fb16 (f:7b16) - ld hl, ConversionEffect_ - ld b, BANK(ConversionEffect_) - jp Bankswitch + jpab ConversionEffect_ HazeEffect: ; 3fb1e (f:7b1e) - ld hl, HazeEffect_ - ld b, BANK(HazeEffect_) - jp Bankswitch + jpab HazeEffect_ HealEffect: ; 3fb26 (f:7b26) - ld hl, HealEffect_ - ld b, BANK(HealEffect_) - jp Bankswitch + jpab HealEffect_ TransformEffect: ; 3fb2e (f:7b2e) - ld hl, TransformEffect_ - ld b, BANK(TransformEffect_) - jp Bankswitch + jpab TransformEffect_ ReflectLightScreenEffect: ; 3fb36 (f:7b36) - ld hl, ReflectLightScreenEffect_ - ld b, BANK(ReflectLightScreenEffect_) - jp Bankswitch + jpab ReflectLightScreenEffect_ NothingHappenedText: ; 3fb3e (f:7b3e) TX_FAR _NothingHappenedText @@ -8380,12 +8375,12 @@ ParalyzedMayNotAttackText: ; 3fb74 (f:7b74) CheckTargetSubstitute: ; 3fb79 (f:7b79) push hl ld hl, W_ENEMYBATTSTATUS2 - ld a, [H_WHOSETURN] + ld a, [H_WHOSETURN] and a jr z, .next1 ld hl, W_PLAYERBATTSTATUS2 .next1 - bit HasSubstituteUp, [hl] + bit HasSubstituteUp, [hl] pop hl ret diff --git a/engine/battle/decrement_pp.asm b/engine/battle/decrement_pp.asm index 7774070c..c6a9f2b5 100644 --- a/engine/battle/decrement_pp.asm +++ b/engine/battle/decrement_pp.asm @@ -9,15 +9,15 @@ DecrementPP: ; f42db (3d:42db) ; W_PLAYERBATTSTATUS2 status flags later and a, (1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << AttackingMultipleTimes) ret nz ; if any of these statuses are true, don't decrement PP - bit UsingRage, [hl] + bit UsingRage, [hl] ret nz ; don't decrement PP either if Pokemon is using Rage ld hl, wBattleMonPP ; PP of first move (in battle) - -; decrement PP in the battle struct - call .DecrementPP - -; decrement PP in the party struct - ld a, [W_PLAYERBATTSTATUS3] + +; decrement PP in the battle struct + call .DecrementPP + +; decrement PP in the party struct + ld a, [W_PLAYERBATTSTATUS3] bit Transformed, a ret nz ; Return if transformed. Pokemon Red stores the "current pokemon's" PP ; separately from the "Pokemon in your party's" PP. This is @@ -31,7 +31,7 @@ DecrementPP: ; f42db (3d:42db) ld hl, wPartyMon1PP ; PP of first move (in party) ld a, [wPlayerMonNumber] ; which mon in party is active - ld bc, wPartyMon2 - wPartyMon1 + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ; calculate address of the mon to modify .DecrementPP ; f4301 (3d:4301) ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use? diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm index fce3701c..c1387b7b 100644 --- a/engine/battle/draw_hud_pokeball_gfx.asm +++ b/engine/battle/draw_hud_pokeball_gfx.asm @@ -1,46 +1,46 @@ DrawAllPokeballs: ; 3a849 (e:6849) call LoadPartyPokeballGfx call SetupOwnPartyPokeballs - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] dec a ret z ; return if wild pokémon jp SetupEnemyPartyPokeballs -DrawEnemyPokeballs: ; 0x3a857 +DrawEnemyPokeballs: ; 3a857 (e:6857) call LoadPartyPokeballGfx jp SetupEnemyPartyPokeballs LoadPartyPokeballGfx: ; 3a85d (e:685d) - ld de, PokeballTileGraphics ; $697e + ld de, PokeballTileGraphics ld hl, vSprites + $310 - ld bc, (BANK(PokeballTileGraphics) << 8) + $04 + lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10 jp CopyVideoData SetupOwnPartyPokeballs: ; 3a869 (e:6869) call PlacePlayerHUDTiles ld hl, wPartyMon1 - ld de, wPartyCount ; wPartyCount + ld de, wPartyCount call SetupPokeballs ld a, $60 - ld hl, W_BASECOORDX ; wd081 + ld hl, W_BASECOORDX ld [hli], a ld [hl], a - ld a, $8 - ld [wTrainerEngageDistance], a + ld a, 8 + ld [wHUDPokeballGfxOffsetX], a ld hl, wOAMBuffer jp WritePokeballOAMData SetupEnemyPartyPokeballs: ; 3a887 (e:6887) call PlaceEnemyHUDTiles ld hl, wEnemyMons - ld de, wEnemyPartyCount ; wEnemyPartyCount + ld de, wEnemyPartyCount call SetupPokeballs - ld hl, W_BASECOORDX ; wd081 + ld hl, W_BASECOORDX ld a, $48 ld [hli], a ld [hl], $20 - ld a, $f8 - ld [wTrainerEngageDistance], a + ld a, -8 + ld [wHUDPokeballGfxOffsetX], a ld hl, wOAMBuffer + PARTY_LENGTH * 4 jp WritePokeballOAMData @@ -90,39 +90,39 @@ PickPokeball: ; 3a8c2 (e:68c2) .done ld a, b ld [de], a - ld bc, $0028 ; rest of mon struct - add hl, bc + ld bc, wPartyMon2 - wPartyMon1Status + add hl, bc ; next mon struct ret WritePokeballOAMData: ; 3a8e1 (e:68e1) ld de, wBuffer ld c, PARTY_LENGTH .loop - ld a, [W_BASECOORDY] ; wd082 + ld a, [W_BASECOORDY] ld [hli], a - ld a, [W_BASECOORDX] ; wd081 + ld a, [W_BASECOORDX] ld [hli], a ld a, [de] ld [hli], a xor a ld [hli], a - ld a, [W_BASECOORDX] ; wd081 + ld a, [W_BASECOORDX] ld b, a - ld a, [wTrainerEngageDistance] + ld a, [wHUDPokeballGfxOffsetX] add b - ld [W_BASECOORDX], a ; wd081 + ld [W_BASECOORDX], a inc de dec c jr nz, .loop ret PlacePlayerHUDTiles: ; 3a902 (e:6902) - ld hl, PlayerBattleHUDGraphicsTiles ; $6916 - ld de, wTrainerFacingDirection + ld hl, PlayerBattleHUDGraphicsTiles + ld de, wHUDGraphicsTiles ld bc, $3 call CopyData - hlCoord 18, 10 - ld de, rIE ; $ffff + coord hl, 18, 10 + ld de, -1 jr PlaceHUDTiles PlayerBattleHUDGraphicsTiles: ; 3a916 (e:6916) @@ -132,11 +132,11 @@ PlayerBattleHUDGraphicsTiles: ; 3a916 (e:6916) db $6F ; lower-left triangle tile of the HUD PlaceEnemyHUDTiles: ; 3a919 (e:6919) - ld hl, EnemyBattleHUDGraphicsTiles ; $692d - ld de, wTrainerFacingDirection + ld hl, EnemyBattleHUDGraphicsTiles + ld de, wHUDGraphicsTiles ld bc, $3 call CopyData - hlCoord 1, 2 + coord hl, 1, 2 ld de, $1 jr PlaceHUDTiles @@ -148,38 +148,38 @@ EnemyBattleHUDGraphicsTiles: ; 3a92d (e:692d) PlaceHUDTiles: ; 3a930 (e:6930) ld [hl], $73 - ld bc, $14 + ld bc, SCREEN_WIDTH add hl, bc - ld a, [wTrainerScreenY] + ld a, [wHUDGraphicsTiles + 1] ; leftmost tile ld [hl], a - ld a, $8 -.asm_3a93c + ld a, 8 +.loop add hl, de ld [hl], $76 dec a - jr nz, .asm_3a93c + jr nz, .loop add hl, de - ld a, [wTrainerScreenX] + ld a, [wHUDGraphicsTiles + 2] ; rightmost tile ld [hl], a ret SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948) call LoadPartyPokeballGfx - ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) - ld de, wPartyCount ; wPartyCount + ld hl, wPartyMons + ld de, wPartyCount call SetupPokeballs - ld hl, W_BASECOORDX ; wd081 + ld hl, W_BASECOORDX ld a, $50 ld [hli], a ld [hl], $40 - ld a, $8 - ld [wTrainerEngageDistance], a + ld a, 8 + ld [wHUDPokeballGfxOffsetX], a ld hl, wOAMBuffer call WritePokeballOAMData - ld hl, wEnemyMons ; wEnemyMon1Species - ld de, wEnemyPartyCount ; wEnemyPartyCount + ld hl, wEnemyMons + ld de, wEnemyPartyCount call SetupPokeballs - ld hl, W_BASECOORDX ; wd081 + ld hl, W_BASECOORDX ld a, $50 ld [hli], a ld [hl], $68 @@ -189,3 +189,4 @@ SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948) ; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (faited) and pokeball slot (no mon) PokeballTileGraphics:: ; 3a97e (e:697e) INCBIN "gfx/pokeball.2bpp" +PokeballTileGraphicsEnd: diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm index 5d78af5b..f1de313c 100755 --- a/engine/battle/end_of_battle.asm +++ b/engine/battle/end_of_battle.asm @@ -19,9 +19,9 @@ EndOfBattle: ; 137aa (4:77aa) jr z, .placeWinOrLoseString ld de, DrawText .placeWinOrLoseString - hlCoord 6, 8 + coord hl, 6, 8 call PlaceString - ld c, $c8 + ld c, 200 call DelayFrames jr .evolution .notLinkBattle @@ -41,20 +41,20 @@ EndOfBattle: ; 137aa (4:77aa) call PrintText .evolution xor a - ld [wccd4], a + ld [wForceEvolution], a predef EvolutionAfterBattle .resetVariables xor a ld [wLowHealthAlarm], a ;disable low health alarm - ld [wc02a], a + ld [wChannelSoundIDs + CH4], a ld [W_ISINBATTLE], a ld [W_BATTLETYPE], a ld [W_MOVEMISSED], a ld [W_CUROPPONENT], a - ld [wd11f], a + ld [wForcePlayerToChooseMon], a ld [wNumRunAttempts], a ld [wEscapedFromBattle], a - ld hl, wcc2b + ld hl, wPartyAndBillsPCSavedMenuItem ld [hli], a ld [hli], a ld [hli], a diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index 9bd67654..ab3e3c19 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -15,7 +15,7 @@ GainExperience: ; 5524f (15:524f) ld hl, wPartyGainExpFlags ld a, [wWhichPokemon] ld c, a - ld b, $2 + ld b, FLAG_TEST predef FlagActionPredef ld a, c and a ; is mon's gain exp flag set? @@ -26,7 +26,7 @@ GainExperience: ; 5524f (15:524f) ld d, h ld e, l ld hl, wEnemyMonBaseStats - ld c, $5 + ld c, NUM_STATS .gainStatExpLoop ld a, [hli] ld b, a ; enemy mon base stat @@ -66,7 +66,7 @@ GainExperience: ; 5524f (15:524f) ld [H_DIVISOR], a ld b, 4 call Divide - ld hl, -((wPartyMon1HPExp + 1) - wPartyMon1OTID + 4 * 2) + ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1) add hl, de ld b, [hl] ; party mon OTID inc hl @@ -76,11 +76,11 @@ GainExperience: ; 5524f (15:524f) ld b, [hl] ld a, [wPlayerID + 1] cp b - ld a, $0 + ld a, 0 jr z, .next .tradedMon call BoostExp ; traded mon exp boost - ld a, $1 + ld a, 1 .next ld [wGainBoostedExp], a ld a, [W_ISINBATTLE] @@ -92,12 +92,12 @@ GainExperience: ; 5524f (15:524f) ; add the gained exp to the party mon's exp ld b, [hl] ld a, [H_QUOTIENT + 3] - ld [wcf4c], a + ld [wExpAmountGained + 1], a add b ld [hld], a ld b, [hl] ld a, [H_QUOTIENT + 2] - ld [wcf4b], a + ld [wExpAmountGained], a adc b ld [hl], a jr nc, .noCarry @@ -148,8 +148,8 @@ GainExperience: ; 5524f (15:524f) call GetPartyMonName ld hl, GainedText call PrintText - xor a ; party mon data - ld [wcc49], a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation], a call LoadMonData pop hl ld bc, wPartyMon1Level - wPartyMon1Exp @@ -220,7 +220,7 @@ GainExperience: ; 5524f (15:524f) add hl, bc push hl ld de, wBattleMonLevel - ld bc, $b ; size of stats + ld bc, 1 + NUM_STATS * 2 ; size of stats call CopyData pop hl ld a, [W_PLAYERBATTSTATUS3] @@ -228,11 +228,11 @@ GainExperience: ; 5524f (15:524f) jr nz, .recalcStatChanges ; the mon is not transformed, so update the unmodified stats ld de, wPlayerMonUnmodifiedLevel - ld bc, $b + ld bc, 1 + NUM_STATS * 2 call CopyData .recalcStatChanges - xor a - ld [wd11e], a + xor a ; battle mon + ld [wCalculateWhoseStats], a callab CalculateModifiedStats callab ApplyBurnAndParalysisPenaltiesToPlayer callab ApplyBadgeStatBoosts @@ -242,22 +242,22 @@ GainExperience: ; 5524f (15:524f) .printGrewLevelText ld hl, GrewLevelText call PrintText - xor a ; party mon data - ld [wcc49], a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation], a call LoadMonData ld d, $1 callab PrintStatsBox call WaitForTextScrollButtonPress call LoadScreenTilesFromBuffer1 - xor a - ld [wcc49], a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation], a ld a, [wd0b5] ld [wd11e], a predef LearnMoveFromLevelUp - ld hl, wccd3 + ld hl, wCanEvolveFlags ld a, [wWhichPokemon] ld c, a - ld b, $1 + ld b, FLAG_SET predef FlagActionPredef pop hl pop af @@ -281,7 +281,7 @@ GainExperience: ; 5524f (15:524f) ld [hl], a ; clear gain exp flags ld a, [wPlayerMonNumber] ld c, a - ld b, $1 + ld b, FLAG_SET push bc predef FlagActionPredef ; set the gain exp flag for the mon that is currently out ld hl, wPartyFoughtCurrentEnemyFlags @@ -308,7 +308,7 @@ DivideExpDataByNumMonsGainingExp: ; 5546c (15:546c) ret c ; return if only one mon is gaining exp ld [wd11e], a ; store number of mons gaining exp ld hl, wEnemyMonBaseStats - ld c, $7 + ld c, wEnemyMonBaseExp + 1 - wEnemyMonBaseStats .divideLoop xor a ld [H_DIVIDEND], a @@ -341,7 +341,7 @@ BoostExp: ; 5549f (15:549f) GainedText: ; 554b2 (15:54b2) TX_FAR _GainedText - db $08 ; asm + TX_ASM ld a, [wBoostExpByExpAll] ld hl, WithExpAllText and a @@ -355,7 +355,7 @@ GainedText: ; 554b2 (15:54b2) WithExpAllText: ; 554cb (15:54cb) TX_FAR _WithExpAllText - db $08 ; asm + TX_ASM ld hl, ExpPointsText ret diff --git a/engine/battle/ghost_marowak_anim.asm b/engine/battle/ghost_marowak_anim.asm index 5c9e6f1a..719fcf0a 100644 --- a/engine/battle/ghost_marowak_anim.asm +++ b/engine/battle/ghost_marowak_anim.asm @@ -5,18 +5,18 @@ MarowakAnim: ; 7092b (1c:492b) call Func_3061 call CopyMonPicFromBGToSpriteVRAM ; cover the BG ghost pic with a sprite ghost pic that looks the same ; now that the ghost pic is being displayed using sprites, clear the ghost pic from the BG tilemap - hlCoord 12, 0 - ld bc, $707 + coord hl, 12, 0 + lb bc, 7, 7 call ClearScreenArea call Delay3 xor a ld [H_AUTOBGTRANSFERENABLED], a ; disable BG transfer so we don't see the Marowak too soon ; replace ghost pic with Marowak in BG ld a, MAROWAK - ld [wHPBarMaxHP], a + ld [wChangeMonPicEnemyTurnSpecies], a ld a, $1 ld [H_WHOSETURN], a - callab Func_798d4 + callab ChangeMonPic ; alternate between black and light grey 8 times. ; this makes the ghost's body appear to flash ld d, $80 @@ -62,7 +62,7 @@ CopyMonPicFromBGToSpriteVRAM: ; 70994 (1c:4994) ld a, $70 ld [W_BASECOORDX], a ld hl, wOAMBuffer - ld bc, $606 + lb bc, 6, 6 ld d, $8 .oamLoop push bc diff --git a/engine/battle/init_battle_variables.asm b/engine/battle/init_battle_variables.asm index 94d964e8..78f4ad22 100644 --- a/engine/battle/init_battle_variables.asm +++ b/engine/battle/init_battle_variables.asm @@ -1,10 +1,10 @@ InitBattleVariables: ; f6236 (3d:6236) ld a, [hTilesetType] - ld [wd0d4], a + ld [wSavedTilesetType], a xor a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a ld [wBattleResult], a - ld hl, wcc2b + ld hl, wPartyAndBillsPCSavedMenuItem ld [hli], a ld [hli], a ld [hli], a @@ -13,21 +13,21 @@ InitBattleVariables: ; f6236 (3d:6236) ld [wCriticalHitOrOHKO], a ld [wBattleMonSpecies], a ld [wPartyGainExpFlags], a - ld [wPlayerMonNumber], a + ld [wPlayerMonNumber], a ld [wEscapedFromBattle], a ld [wMapPalOffset], a - ld hl, wcf1d - ld [hli], a - ld [hl], a - ld hl, wccd3 + ld hl, wPlayerHPBarColor + ld [hli], a ; wPlayerHPBarColor + ld [hl], a ; wEnemyHPBarColor + ld hl, wCanEvolveFlags ld b, $3c .loop ld [hli], a dec b jr nz, .loop - inc a - ld [wccd9], a - ld a, [W_CURMAP] + inc a ; POUND + ld [wTestBattlePlayerSelectedMove], a + ld a, [W_CURMAP] cp SAFARI_ZONE_EAST jr c, .notSafariBattle cp SAFARI_ZONE_REST_HOUSE_1 @@ -35,6 +35,4 @@ InitBattleVariables: ; f6236 (3d:6236) ld a, $2 ; safari battle ld [W_BATTLETYPE], a .notSafariBattle - ld hl, PlayBattleMusic - ld b, BANK(PlayBattleMusic) - jp Bankswitch + jpab PlayBattleMusic diff --git a/engine/battle/link_battle_versus_text.asm b/engine/battle/link_battle_versus_text.asm index c29e1c85..9849cc9a 100644 --- a/engine/battle/link_battle_versus_text.asm +++ b/engine/battle/link_battle_versus_text.asm @@ -1,17 +1,17 @@ ; display "[player] VS [enemy]" text box with pokeballs representing their parties next to the names DisplayLinkBattleVersusTextBox: ; f41cf (3d:41cf) call LoadTextBoxTilePatterns - hlCoord 3, 4 + coord hl, 3, 4 ld bc, $70c call TextBoxBorder - hlCoord 4, 5 + coord hl, 4, 5 ld de, wPlayerName call PlaceString - hlCoord 4, 10 + coord hl, 4, 10 ld de, wLinkEnemyTrainerName call PlaceString ; place bold "VS" tiles between the names - hlCoord 9, 8 + coord hl, 9, 8 ld a, $69 ld [hli], a ld [hl], $6a diff --git a/engine/battle/moveEffects/conversion_effect.asm b/engine/battle/moveEffects/conversion_effect.asm index 2f05afb3..e4c5b4bd 100644 --- a/engine/battle/moveEffects/conversion_effect.asm +++ b/engine/battle/moveEffects/conversion_effect.asm @@ -13,7 +13,7 @@ ConversionEffect_: ; 139a3 (4:79a3) .conversionEffect bit Invulnerable, a ; is mon immune to typical attacks (dig/fly) jr nz, PrintButItFailedText -; copy target's types to user +; copy target's types to user ld a, [hli] ld [de], a inc de diff --git a/engine/battle/moveEffects/drain_hp_effect.asm b/engine/battle/moveEffects/drain_hp_effect.asm index 517d53d1..1096794f 100644 --- a/engine/battle/moveEffects/drain_hp_effect.asm +++ b/engine/battle/moveEffects/drain_hp_effect.asm @@ -1,5 +1,5 @@ DrainHPEffect_: ; 783f (1:783f) - ld hl, W_DAMAGE + ld hl, W_DAMAGE ld a, [hl] srl a ; divide damage by 2 ld [hli], a @@ -17,8 +17,8 @@ DrainHPEffect_: ; 783f (1:783f) ld a, [H_WHOSETURN] and a jp z, .addDamageToAttackerHP - ld hl, wEnemyMonHP - ld de, wEnemyMonMaxHP + ld hl, wEnemyMonHP + ld de, wEnemyMonMaxHP .addDamageToAttackerHP ld bc, wHPBarOldHP+1 ; copy current HP to wHPBarOldHP @@ -41,7 +41,7 @@ DrainHPEffect_: ; 783f (1:783f) add b ld [hld], a ld [wHPBarNewHP], a - ld a, [W_DAMAGE] + ld a, [W_DAMAGE] ld b, [hl] adc b ld [hli], a @@ -71,10 +71,10 @@ DrainHPEffect_: ; 783f (1:783f) .next ld a, [H_WHOSETURN] and a - hlCoord 10, 9 + coord hl, 10, 9 ld a, $1 jr z, .next2 - hlCoord 2, 2 + coord hl, 2, 2 xor a .next2 ld [wHPBarType], a @@ -87,7 +87,7 @@ DrainHPEffect_: ; 783f (1:783f) and a ld a, [W_PLAYERMOVEEFFECT] jr z, .next3 - ld a, [W_ENEMYMOVEEFFECT] + ld a, [W_ENEMYMOVEEFFECT] .next3 cp DREAM_EATER_EFFECT jr nz, .printText diff --git a/engine/battle/moveEffects/focus_energy_effect.asm b/engine/battle/moveEffects/focus_energy_effect.asm index 0089c8b1..e88d065a 100644 --- a/engine/battle/moveEffects/focus_energy_effect.asm +++ b/engine/battle/moveEffects/focus_energy_effect.asm @@ -12,11 +12,9 @@ FocusEnergyEffect_: ; f628b (3d:628b) ld hl, GettingPumpedText jp PrintText .alreadyUsing - ld c, $32 + ld c, 50 call DelayFrames - ld hl, PrintButItFailedText_ - ld b, BANK(PrintButItFailedText_) - jp Bankswitch + jpab PrintButItFailedText_ GettingPumpedText: ; f62b5 (3d:62b5) db $0a diff --git a/engine/battle/moveEffects/haze_effect.asm b/engine/battle/moveEffects/haze_effect.asm index 14b5f5dd..5c5443c0 100644 --- a/engine/battle/moveEffects/haze_effect.asm +++ b/engine/battle/moveEffects/haze_effect.asm @@ -1,11 +1,11 @@ HazeEffect_: ; 139da (4:79da) ld a, $7 -; store 7 on every stat mod +; store 7 on every stat mod ld hl, wPlayerMonAttackMod call ResetStatMods ld hl, wEnemyMonAttackMod call ResetStatMods -; copy unmodified stats to battle stats +; copy unmodified stats to battle stats ld hl, wPlayerMonUnmodifiedAttack ld de, wBattleMonAttack call ResetStats @@ -25,7 +25,7 @@ HazeEffect_: ; 139da (4:79da) ld [hl], $0 and SLP | (1 << FRZ) jr z, .cureVolatileStatuses -; prevent the Pokemon from executing a move if it was asleep or frozen +; prevent the Pokemon from executing a move if it was asleep or frozen ld a, $ff ld [de], a @@ -51,7 +51,7 @@ CureVolatileStatuses: ; 13a37 (4:7a37) inc hl ; BATTSTATUS2 ld a, [hl] ; clear UsingXAccuracy, ProtectedByMist, GettingPumped, and Seeded statuses - and $ff ^((1 << UsingXAccuracy) | (1 << ProtectedByMist) | (1 << GettingPumped) | (1 << Seeded)) + and $ff ^((1 << UsingXAccuracy) | (1 << ProtectedByMist) | (1 << GettingPumped) | (1 << Seeded)) ld [hli], a ; BATTSTATUS3 ld a, [hl] and %11110000 | (1 << Transformed) ; clear Bad Poison, Reflect and Light Screen statuses @@ -61,7 +61,7 @@ CureVolatileStatuses: ; 13a37 (4:7a37) ResetStatMods: ; 13a43 (4:7a43) ld b, $8 .loop - ld [hli], a + ld [hli], a dec b jr nz, .loop ret diff --git a/engine/battle/moveEffects/heal_effect.asm b/engine/battle/moveEffects/heal_effect.asm index d6d4e183..dbce6ebb 100644 --- a/engine/battle/moveEffects/heal_effect.asm +++ b/engine/battle/moveEffects/heal_effect.asm @@ -76,7 +76,7 @@ HealEffect_: ; f62ba (3d:62ba) ld a, [de] sbc [hl] jr c, .playAnim -; copy max HP to current HP if an overflow ocurred +; copy max HP to current HP if an overflow ocurred ld a, [hli] ld [de], a ld [wHPBarNewHP+1], a @@ -89,10 +89,10 @@ HealEffect_: ; f62ba (3d:62ba) call Bankswitch3DtoF ld a, [H_WHOSETURN] and a - hlCoord 10, 9 + coord hl, 10, 9 ld a, $1 jr z, .updateHPBar - hlCoord 2, 2 + coord hl, 2, 2 xor a .updateHPBar ld [wHPBarType], a diff --git a/engine/battle/moveEffects/leech_seed_effect.asm b/engine/battle/moveEffects/leech_seed_effect.asm index e29fd7c2..1b0afe4b 100644 --- a/engine/battle/moveEffects/leech_seed_effect.asm +++ b/engine/battle/moveEffects/leech_seed_effect.asm @@ -1,20 +1,20 @@ LeechSeedEffect_: ; 2bea9 (a:7ea9) callab MoveHitTest - ld a, [W_MOVEMISSED] + ld a, [W_MOVEMISSED] and a jr nz, .moveMissed - ld hl, W_ENEMYBATTSTATUS2 - ld de, wEnemyMonType1 - ld a, [H_WHOSETURN] + ld hl, W_ENEMYBATTSTATUS2 + ld de, wEnemyMonType1 + ld a, [H_WHOSETURN] and a jr z, .leechSeedEffect - ld hl, W_PLAYERBATTSTATUS2 - ld de, wBattleMonType1 + ld hl, W_PLAYERBATTSTATUS2 + ld de, wBattleMonType1 .leechSeedEffect ; miss if the target is grass-type or already seeded ld a, [de] cp GRASS - jr z, .moveMissed + jr z, .moveMissed inc de ld a, [de] cp GRASS @@ -23,12 +23,12 @@ LeechSeedEffect_: ; 2bea9 (a:7ea9) jr nz, .moveMissed set Seeded, [hl] callab PlayCurrentMoveAnimation - ld hl, WasSeededText ; $7ef2 + ld hl, WasSeededText jp PrintText .moveMissed - ld c, $32 + ld c, 50 call DelayFrames - ld hl, EvadedAttackText ; $7ef7 + ld hl, EvadedAttackText jp PrintText WasSeededText: ; 2bef2 (a:7ef2) diff --git a/engine/battle/moveEffects/mist_effect.asm b/engine/battle/moveEffects/mist_effect.asm index ed06d16c..5d7669f8 100644 --- a/engine/battle/moveEffects/mist_effect.asm +++ b/engine/battle/moveEffects/mist_effect.asm @@ -12,9 +12,7 @@ MistEffect_: ; f64ac (3d:64ac) ld hl, ShroudedInMistText jp PrintText .mistAlreadyInUse - ld hl, PrintButItFailedText_ - ld b, BANK(PrintButItFailedText_) - jp Bankswitch + jpab PrintButItFailedText_ ShroudedInMistText: ; f64d3 (3d:64d3) TX_FAR _ShroudedInMistText diff --git a/engine/battle/moveEffects/one_hit_ko_effect.asm b/engine/battle/moveEffects/one_hit_ko_effect.asm index f859f9c4..c1dde6ff 100644 --- a/engine/battle/moveEffects/one_hit_ko_effect.asm +++ b/engine/battle/moveEffects/one_hit_ko_effect.asm @@ -7,7 +7,7 @@ OneHitKOEffect_: ; f64db (3d:64db) ld [wCriticalHitOrOHKO], a ld hl, wBattleMonSpeed + 1 ld de, wEnemyMonSpeed + 1 - ld a, [H_WHOSETURN] + ld a, [H_WHOSETURN] and a jr z, .compareSpeed ld hl, wEnemyMonSpeed + 1 @@ -24,7 +24,7 @@ OneHitKOEffect_: ; f64db (3d:64db) ld a, [hl] sbc b jr c, .userIsSlower - ld hl, W_DAMAGE + ld hl, W_DAMAGE ld a, $ff ld [hli], a ld [hl], a @@ -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 [W_MOVEMISSED], a ret diff --git a/engine/battle/moveEffects/paralyze_effect.asm b/engine/battle/moveEffects/paralyze_effect.asm index 74a7319d..3e0cf062 100644 --- a/engine/battle/moveEffects/paralyze_effect.asm +++ b/engine/battle/moveEffects/paralyze_effect.asm @@ -4,7 +4,7 @@ ParalyzeEffect_: ; f6562 (3d:6562) ld a, [H_WHOSETURN] and a jp z, .next - ld hl, wBattleMonStatus + ld hl, wBattleMonStatus ld de, W_ENEMYMOVETYPE .next ld a, [hl] @@ -28,7 +28,7 @@ ParalyzeEffect_: ; f6562 (3d:6562) push hl callab MoveHitTest pop hl - ld a, [W_MOVEMISSED] + ld a, [W_MOVEMISSED] and a jr nz, .didntAffect set PAR, [hl] @@ -36,18 +36,12 @@ ParalyzeEffect_: ; f6562 (3d:6562) ld c, 30 call DelayFrames callab PlayCurrentMoveAnimation - ld hl, PrintMayNotAttackText - ld b, BANK(PrintMayNotAttackText) - jp Bankswitch + jpab PrintMayNotAttackText .didntAffect ld c, 50 call DelayFrames - ld hl, PrintDidntAffectText - ld b, BANK(PrintDidntAffectText) - jp Bankswitch + jpab PrintDidntAffectText .doesntAffect ld c, 50 call DelayFrames - ld hl, PrintDoesntAffectText - ld b, BANK(PrintDoesntAffectText) - jp Bankswitch + jpab PrintDoesntAffectText diff --git a/engine/battle/moveEffects/pay_day_effect.asm b/engine/battle/moveEffects/pay_day_effect.asm index 1fab9771..2fa6b53f 100644 --- a/engine/battle/moveEffects/pay_day_effect.asm +++ b/engine/battle/moveEffects/pay_day_effect.asm @@ -9,19 +9,19 @@ PayDayEffect_ ; f6511 (3d:6511) ld a, [wEnemyMonLevel] .payDayEffect ; level * 2 - add a + add a ld [H_DIVIDEND + 3], a xor a ld [H_DIVIDEND], a ld [H_DIVIDEND + 1], a ld [H_DIVIDEND + 2], a -; convert to BCD +; convert to BCD ld a, 100 ld [H_DIVISOR], a ld b, $4 call Divide ld a, [H_QUOTIENT + 3] - ld [hli], a + ld [hli], a ld a, [H_REMAINDER] ld [H_DIVIDEND + 3], a ld a, 10 diff --git a/engine/battle/moveEffects/recoil_effect.asm b/engine/battle/moveEffects/recoil_effect.asm index fe516c03..51232af6 100644 --- a/engine/battle/moveEffects/recoil_effect.asm +++ b/engine/battle/moveEffects/recoil_effect.asm @@ -46,19 +46,19 @@ RecoilEffect_: ; 1392c (4:792c) ld [wHPBarNewHP+1], a jr nc, .getHPBarCoords ; if recoil damage is higher than the Pokemon's HP, set its HP to 0 - xor a + xor a ld [hli], a ld [hl], a ld hl, wHPBarNewHP ld [hli], a ld [hl], a .getHPBarCoords - hlCoord 10, 9 + coord hl, 10, 9 ld a, [H_WHOSETURN] and a ld a, $1 jr z, .updateHPBar - hlCoord 2, 2 + coord hl, 2, 2 xor a .updateHPBar ld [wHPBarType], a diff --git a/engine/battle/moveEffects/reflect_light_screen_effect.asm b/engine/battle/moveEffects/reflect_light_screen_effect.asm index 83a97486..ee053670 100644 --- a/engine/battle/moveEffects/reflect_light_screen_effect.asm +++ b/engine/battle/moveEffects/reflect_light_screen_effect.asm @@ -27,7 +27,7 @@ ReflectLightScreenEffect_: ; f645d (3d:645d) pop hl jp PrintText .moveFailed - ld c, $32 + ld c, 50 call DelayFrames ld hl, PrintButItFailedText_ jp Bankswitch3DtoF diff --git a/engine/battle/moveEffects/substitute_effect.asm b/engine/battle/moveEffects/substitute_effect.asm index 8412e281..c72fffbe 100644 --- a/engine/battle/moveEffects/substitute_effect.asm +++ b/engine/battle/moveEffects/substitute_effect.asm @@ -11,15 +11,15 @@ SubstituteEffect_: ; 17dad (5:7dad) ld de, wEnemySubstituteHP ld bc, W_ENEMYBATTSTATUS2 .notEnemy - ld a, [bc] + ld a, [bc] bit HasSubstituteUp, a ; user already has substitute? - jr nz, .alreadyHasSubstitute + jr nz, .alreadyHasSubstitute ; quarter health to remove from user -; assumes max HP is 1023 or lower +; assumes max HP is 1023 or lower push bc ld a, [hli] ld b, [hl] - srl a + srl a rr b srl a rr b ; max hp / 4 @@ -27,37 +27,35 @@ SubstituteEffect_: ; 17dad (5:7dad) ld de, wBattleMonHP - wBattleMonMaxHP add hl, de ; point hl to current HP low byte pop de - ld a, b + ld a, b ld [de], a ; save copy of HP to subtract in ccd7/ccd8 [how much HP substitute has] ld a, [hld] -; subtract [max hp / 4] to current HP - sub b +; subtract [max hp / 4] to current HP + sub b ld d, a ld a, [hl] - sbc 0 + sbc 0 pop bc jr c, .notEnoughHP ; underflow means user would be left with negative health ; bug: since it only brances on carry, it will possibly leave user with 0 HP .userHasZeroOrMoreHP ldi [hl], a ; save resulting HP after substraction into current HP - ld [hl], d + ld [hl], d ld h, b ld l, c - set HasSubstituteUp, [hl] - ld a, [W_OPTIONS] + set HasSubstituteUp, [hl] + ld a, [W_OPTIONS] bit 7, a ; battle animation is enabled? - ld hl, PlayCurrentMoveAnimation + ld hl, PlayCurrentMoveAnimation ld b, BANK(PlayCurrentMoveAnimation) jr z, .animationEnabled - ld hl, AnimationSubstitute + ld hl, AnimationSubstitute ld b, BANK(AnimationSubstitute) .animationEnabled call Bankswitch ; jump to routine depending on animation setting ld hl, SubstituteText call PrintText - ld hl, DrawHUDsAndHPBars - ld b, BANK(DrawHUDsAndHPBars) - jp Bankswitch + jpab DrawHUDsAndHPBars .alreadyHasSubstitute ld hl, HasSubstituteText jr .printText diff --git a/engine/battle/moveEffects/transform_effect.asm b/engine/battle/moveEffects/transform_effect.asm index 74b70431..fef6f7aa 100644 --- a/engine/battle/moveEffects/transform_effect.asm +++ b/engine/battle/moveEffects/transform_effect.asm @@ -24,10 +24,10 @@ TransformEffect_: ; f637f (3d:637f) ld hl, W_ENEMYBATTSTATUS2 .transformEffect ; animation(s) played are different if target has Substitute up - bit HasSubstituteUp, [hl] + bit HasSubstituteUp, [hl] push af - ld hl, Func_79816 - ld b, BANK(Func_79816) + ld hl, HideSubstituteShowMonAnim + ld b, BANK(HideSubstituteShowMonAnim) call nz, Bankswitch ld a, [W_OPTIONS] add a @@ -38,8 +38,8 @@ TransformEffect_: ; f637f (3d:637f) ld b, BANK(AnimationTransformMon) .gotAnimToPlay call Bankswitch - ld hl, Func_798b2 - ld b, BANK(Func_798b2) + ld hl, ReshowSubstituteAnim + ld b, BANK(ReshowSubstituteAnim) pop af call nz, Bankswitch pop bc @@ -49,13 +49,13 @@ TransformEffect_: ; f637f (3d:637f) pop de pop hl push hl -; transform user into opposing Pokemon +; transform user into opposing Pokemon ; species - ld a, [hl] + ld a, [hl] ld [de], a -; type 1, type 2, catch rate, and moves +; type 1, type 2, catch rate, and moves ld bc, $5 - add hl, bc + add hl, bc inc de inc de inc de @@ -67,12 +67,12 @@ TransformEffect_: ; f637f (3d:637f) ld a, [H_WHOSETURN] and a jr z, .next -; save enemy mon DVs in wcceb/wccec (enemy turn only) +; save enemy mon DVs at wTransformedEnemyMonOriginalDVs ld a, [de] - ld [wcceb], a + ld [wTransformedEnemyMonOriginalDVs], a inc de ld a, [de] - ld [wccec], a + ld [wTransformedEnemyMonOriginalDVs + 1], a dec de .next ; DVs @@ -82,7 +82,7 @@ TransformEffect_: ; f637f (3d:637f) ld a, [hli] ld [de], a inc de -; Attack, Defense, Speed, and Special stats +; Attack, Defense, Speed, and Special stats inc hl inc hl inc hl @@ -91,7 +91,7 @@ TransformEffect_: ; f637f (3d:637f) inc de ld bc, $8 call CopyData - ld bc, wBattleMonMoves - wBattleMonPP + ld bc, wBattleMonMoves - wBattleMonPP add hl, bc ; ld hl, wBattleMonMoves ld b, NUM_MOVES .copyPPLoop diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm index d8da714e..37a45476 100755 --- a/engine/battle/read_trainer_party.asm +++ b/engine/battle/read_trainer_party.asm @@ -55,8 +55,8 @@ ReadTrainer: ; 39c53 (e:5c53) and a ; have we reached the end of the trainer data? jr z,.FinishUp ld [wcf91],a ; write species somewhere (XXX why?) - ld a,1 - ld [wcc49],a + ld a,ENEMY_PARTY_DATA + ld [wMonDataLocation],a push hl call AddPartyMon pop hl @@ -72,8 +72,8 @@ ReadTrainer: ; 39c53 (e:5c53) ld [W_CURENEMYLVL],a ld a,[hli] ld [wcf91],a - ld a,1 - ld [wcc49],a + ld a,ENEMY_PARTY_DATA + ld [wMonDataLocation],a push hl call AddPartyMon pop hl @@ -101,7 +101,7 @@ ReadTrainer: ; 39c53 (e:5c53) ; get trainer class number ld a,[W_CUROPPONENT] - sub $C8 + sub 200 ld b,a ld hl,TeamMoves @@ -143,7 +143,7 @@ ReadTrainer: ; 39c53 (e:5c53) ld [wEnemyMon6Moves + 2],a .FinishUp ; clear wAmountMoneyWon addresses - xor a + xor a ld de,wAmountMoneyWon ld [de],a inc de @@ -154,7 +154,7 @@ ReadTrainer: ; 39c53 (e:5c53) ld b,a .LastLoop ; update wAmountMoneyWon addresses (money to win) based on enemy's level - ld hl,wd047 + ld hl,wTrainerBaseMoney + 1 ld c,2 ; wAmountMoneyWon is a 3-byte number push bc predef AddBCDPredef diff --git a/engine/battle/scale_sprites.asm b/engine/battle/scale_sprites.asm index dae4ad42..ed227984 100644 --- a/engine/battle/scale_sprites.asm +++ b/engine/battle/scale_sprites.asm @@ -41,16 +41,16 @@ ScaleFirstThreeSpriteColumnsByTwo: ; 2fe55 (b:7e55) ScaleLastSpriteColumnByTwo: ; 2fe7d (b:7e7d) ld a, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows - ld [H_SPRITEINTERLACECOUNTER], a ; $ff8b - ld bc, -1 ; $ffff + ld [H_SPRITEINTERLACECOUNTER], a + ld bc, -1 .columnInnerLoop ld a, [de] dec de swap a ; only high nybble contains information call ScalePixelsByTwo - ld a, [H_SPRITEINTERLACECOUNTER] ; $ff8b + ld a, [H_SPRITEINTERLACECOUNTER] dec a - ld [H_SPRITEINTERLACECOUNTER], a ; $ff8b + ld [H_SPRITEINTERLACECOUNTER], a jr nz, .columnInnerLoop dec de ; skip last 4 rows of new column dec de diff --git a/engine/battle/scroll_draw_trainer_pic.asm b/engine/battle/scroll_draw_trainer_pic.asm index c6b69362..e5e66b38 100644 --- a/engine/battle/scroll_draw_trainer_pic.asm +++ b/engine/battle/scroll_draw_trainer_pic.asm @@ -3,10 +3,10 @@ _ScrollTrainerPicAfterBattle: ; f4259 (e:f4259) ; the screen from the right. xor a ld [wEnemyMonSpecies2], a - ld b, $1 - call GoPAL_SET + ld b, SET_PAL_BATTLE + call RunPaletteCommand callab _LoadTrainerPic - hlCoord 19, 0 + coord hl, 19, 0 ld c, $0 .scrollLoop inc c diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm index 19a184f2..afb04216 100644 --- a/engine/battle/trainer_ai.asm +++ b/engine/battle/trainer_ai.asm @@ -2,7 +2,7 @@ ; unused slots are filled with 0, all used slots may be chosen with equal probability AIEnemyTrainerChooseMoves: ; 39719 (e:5719) ld a, $a - ld hl, wHPBarMaxHP ; init temporary move selection array. Only the moves with the lowest numbers are chosen in the end + ld hl, wBuffer ; init temporary move selection array. Only the moves with the lowest numbers are chosen in the end ld [hli], a ; move 1 ld [hli], a ; move 2 ld [hli], a ; move 3 @@ -11,14 +11,14 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719) swap a and $f jr z, .noMoveDisabled - ld hl, wHPBarMaxHP + ld hl, wBuffer dec a ld c, a ld b, $0 add hl, bc ; advance pointer to forbidden move ld [hl], $50 ; forbid (highly discourage) disabled move .noMoveDisabled - ld hl, TrainerClassMoveChoiceModifications ; 589B + ld hl, TrainerClassMoveChoiceModifications ld a, [W_TRAINERCLASS] ld b, a .loopTrainerClasses @@ -40,11 +40,11 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719) and a jr z, .loopFindMinimumEntries push hl - ld hl, AIMoveChoiceModificationFunctionPointers ; $57a3 + ld hl, AIMoveChoiceModificationFunctionPointers dec a add a ld c, a - ld b, $0 + ld b, 0 add hl, bc ; skip to pointer ld a, [hli] ; read pointer into hl ld h, [hl] @@ -53,9 +53,9 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719) push de jp [hl] ; execute modification function .loopFindMinimumEntries ; all entries will be decremented sequentially until one of them is zero - ld hl, wHPBarMaxHP ; temp move selection array + ld hl, wBuffer ; temp move selection array ld de, wEnemyMonMoves ; enemy moves - ld c, $4 + ld c, NUM_MOVES .loopDecrementEntries ld a, [de] inc de @@ -73,15 +73,15 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719) inc [hl] dec hl inc a - cp $5 + cp NUM_MOVES + 1 jr nz, .loopUndoPartialIteration - ld hl, wHPBarMaxHP ; temp move selection array + ld hl, wBuffer ; temp move selection array ld de, wEnemyMonMoves ; enemy moves - ld c, $4 + ld c, NUM_MOVES .filterMinimalEntries ; all minimal entries now have value 1. All other slots will be disabled (move set to 0) ld a, [de] and a - jr nz, .moveExisting ; 0x3978a $1 + jr nz, .moveExisting ld [hl], a .moveExisting ld a, [hl] @@ -97,7 +97,7 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719) inc de dec c jr nz, .filterMinimalEntries - ld hl, wHPBarMaxHP ; use created temporary array as move set + ld hl, wBuffer ; use created temporary array as move set ret .useOriginalMoveSet ld hl, wEnemyMonMoves ; use original move set @@ -145,7 +145,7 @@ AIMoveChoiceModification1: ; 397ab (e:57ab) ld [hl], a jr .nextMove -StatusAilmentMoveEffects ; 57e2 +StatusAilmentMoveEffects: ; 57e2 db $01 ; unused sleep effect db SLEEP_EFFECT db POISON_EFFECT @@ -157,7 +157,7 @@ StatusAilmentMoveEffects ; 57e2 ; that fall in-bewteen AIMoveChoiceModification2: ; 397e7 (e:57e7) ld a, [wAILayer2Encouragement] - cp $1 + cp $1 ret nz ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset) ld de, wEnemyMonMoves ; enemy moves @@ -191,7 +191,7 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7) AIMoveChoiceModification3: ; 39817 (e:5817) ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset) ld de, wEnemyMonMoves ; enemy moves - ld b, $5 + ld b, NUM_MOVES + 1 .nextMove dec b ret z ; processed all 4 moves @@ -208,7 +208,7 @@ AIMoveChoiceModification3: ; 39817 (e:5817) pop de pop bc pop hl - ld a, [wd11e] + ld a, [wTypeEffectiveness] cp $10 jr z, .nextMove jr c, .notEffectiveMove @@ -264,7 +264,7 @@ ReadMove: ; 39884 (e:5884) push bc dec a ld hl,Moves - ld bc,6 + ld bc,MoveEnd - Moves call AddNTimes ld de,W_ENEMYMOVENUM call CopyData @@ -325,8 +325,8 @@ TrainerClassMoveChoiceModifications: ; 3989b (e:589b) db 1,3,0 ; LANCE INCLUDE "engine/battle/trainer_pic_money_pointers.asm" - -INCLUDE "text/trainer_names.asm" + +INCLUDE "text/trainer_names.asm" INCLUDE "engine/battle/bank_e_misc.asm" @@ -337,7 +337,6 @@ INCLUDE "data/trainer_moves.asm" INCLUDE "data/trainer_parties.asm" TrainerAI: ; 3a52e (e:652e) -;XXX called at 34964, 3c342, 3c398 and a ld a,[W_ISINBATTLE] dec a @@ -553,14 +552,14 @@ DecrementAICount: ; 3a695 (e:6695) scf ret -Func_3a69b: ; 3a69b (e:669b) - ld a,(SFX_08_3e - SFX_Headers_08) / 3 +AIPlayRestoringSFX: ; 3a69b (e:669b) + ld a,SFX_HEAL_AILMENT jp PlaySoundWaitForCurrent AIUseFullRestore: ; 3a6a0 (e:66a0) call AICureStatus ld a,FULL_RESTORE - ld [wcf05],a + ld [wAIItem],a ld de,wHPBarOldHP ld hl,wEnemyMonHP + 1 ld a,[hld] @@ -601,7 +600,7 @@ AIUseHyperPotion: ; 3a6d6 (e:66d6) AIRecoverHP: ; 3a6da (e:66da) ; heal b HP and print "trainer used $(a) on pokemon!" - ld [wcf05],a + ld [wAIItem],a ld hl,wEnemyMonHP + 1 ld a,[hl] ld [wHPBarOldHP],a @@ -642,7 +641,7 @@ AIRecoverHP: ; 3a6da (e:66da) AIPrintItemUseAndUpdateHPBar: ; 3a718 (e:6718) call AIPrintItemUse_ - hlCoord 2, 2 + coord hl, 2, 2 xor a ld [wHPBarType],a predef UpdateHPBar2 @@ -666,7 +665,7 @@ AISwitchIfEnoughMons: ; 3a72a (e:672a) inc d .Fainted push bc - ld bc,$2C + ld bc, wEnemyMon2 - wEnemyMon1 add hl,bc pop bc dec c @@ -695,11 +694,13 @@ SwitchEnemyMon: ; 3a74b (e:674b) ld hl, AIBattleWithdrawText call PrintText + ; This wFirstMonsNotOutYet variable is abused to prevent the player from + ; switching in a new mon in response to this switch. ld a,1 - ld [wd11d],a + ld [wFirstMonsNotOutYet],a callab EnemySendOut xor a - ld [wd11d],a + ld [wFirstMonsNotOutYet],a ld a,[wLinkState] cp LINK_STATE_BATTLING @@ -712,7 +713,7 @@ AIBattleWithdrawText: ; 3a781 (e:6781) db "@" AIUseFullHeal: ; 3a786 (e:6786) - call Func_3a69b + call AIPlayRestoringSFX call AICureStatus ld a,FULL_HEAL jp AIPrintItemUse @@ -731,21 +732,21 @@ AICureStatus: ; 3a791 (e:6791) ret AIUseXAccuracy: ; 0x3a7a8 unused - call Func_3a69b + call AIPlayRestoringSFX ld hl,W_ENEMYBATTSTATUS2 set 0,[hl] ld a,X_ACCURACY jp AIPrintItemUse AIUseGuardSpec: ; 3a7b5 (e:67b5) - call Func_3a69b + call AIPlayRestoringSFX ld hl,W_ENEMYBATTSTATUS2 set 1,[hl] ld a,GUARD_SPEC_ jp AIPrintItemUse AIUseDireHit: ; 0x3a7c2 unused - call Func_3a69b + call AIPlayRestoringSFX ld hl,W_ENEMYBATTSTATUS2 set 2,[hl] ld a,DIRE_HIT @@ -798,7 +799,7 @@ AIUseXSpecial: ; 3a804 (e:6804) ; fallthrough AIIncreaseStat: ; 3a808 (e:6808) - ld [wcf05],a + ld [wAIItem],a push bc call AIPrintItemUse_ pop bc @@ -820,13 +821,13 @@ AIIncreaseStat: ; 3a808 (e:6808) jp DecrementAICount AIPrintItemUse: ; 3a82c (e:682c) - ld [wcf05],a + ld [wAIItem],a call AIPrintItemUse_ jp DecrementAICount AIPrintItemUse_: ; 3a835 (e:6835) -; print "x used [wcf05] on z!" - ld a,[wcf05] +; print "x used [wAIItem] on z!" + ld a,[wAIItem] ld [wd11e],a call GetItemName ld hl, AIBattleUseItemText diff --git a/engine/battle/wild_encounters.asm b/engine/battle/wild_encounters.asm index 61b318b9..144234bb 100644 --- a/engine/battle/wild_encounters.asm +++ b/engine/battle/wild_encounters.asm @@ -18,14 +18,14 @@ TryDoWildEncounter: ; 13870 (4:7870) jr z, .CantEncounter ld a, [wRepelRemainingSteps] and a - jr z, .asm_1389e + jr z, .next dec a jr z, .lastRepelStep ld [wRepelRemainingSteps], a -.asm_1389e -; determine if wild pokemon can appear in the half-block we're standing in +.next +; determine if wild pokemon can appear in the half-block we're standing in ; is the bottom right tile (9,9) of the half-block we're standing in a grass/water tile? - hlCoord 9, 9 + coord hl, 9, 9 ld c, [hl] ld a, [W_GRASSTILE] cp c @@ -64,14 +64,14 @@ TryDoWildEncounter: ; 13870 (4:7870) ; determine which wild pokemon (grass or water) can appear in the half-block we're standing in ld c, [hl] ld hl, W_GRASSMONS - aCoord 8, 9 - cp $14 ; is the bottom left tile (8,9) of the half-block we're standing in a water tile? + aCoord 8, 9 + cp $14 ; is the bottom left tile (8,9) of the half-block we're standing in a water tile? jr nz, .gotWildEncounterType ; else, it's treated as a grass tile by default ld hl, W_WATERMONS ; since the bottom right tile of a "left shore" half-block is $14 but the bottom left tile is not, -; "left shore" half-blocks (such as the one in the east coast of Cinnabar) load grass encounters. +; "left shore" half-blocks (such as the one in the east coast of Cinnabar) load grass encounters. .gotWildEncounterType - ld b, $0 + ld b, 0 add hl, bc ld a, [hli] ld [W_CURENEMYLVL], a @@ -89,8 +89,8 @@ TryDoWildEncounter: ; 13870 (4:7870) jr .willEncounter .lastRepelStep ld [wRepelRemainingSteps], a - ld a, $d2 - ld [H_DOWNARROWBLINKCNT2], a + ld a, TEXT_REPEL_WORE_OFF + ld [hSpriteIndexOrTextID], a call EnableAutoTextBoxDrawing call DisplayTextID .CantEncounter2 |