diff options
Diffstat (limited to 'engine/battle')
30 files changed, 717 insertions, 717 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 78301b2e..4e836510 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -163,7 +163,7 @@ DrawFrameBlock: PlayAnimation: xor a - ld [hROMBankTemp], a ; it looks like nothing reads this + ldh [hROMBankTemp], a ; it looks like nothing reads this ld [wSubAnimTransform], a ld a, [wAnimationID] ; get animation number dec a @@ -241,15 +241,15 @@ PlayAnimation: ld l, c ld h, b push hl - ld a, [rOBP0] + ldh a, [rOBP0] push af ld a, [wAnimPalette] - ld [rOBP0], a + ldh [rOBP0], a call LoadAnimationTileset call LoadSubanimation call PlaySubanimation pop af - ld [rOBP0], a + ldh [rOBP0], a .nextAnimationCommand pop hl jr .animationLoop @@ -308,7 +308,7 @@ LoadSubanimation: ; sets the transform to the subanimation type if it's the enemy's turn GetSubanimationTransform1: ld b, a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, b ret nz @@ -319,7 +319,7 @@ GetSubanimationTransform1: ; sets the transform to 2 (i.e. horizontal and vertical flip) if it's the player's turn ; sets the transform to 0 (i.e. no transform) if it's the enemy's turn GetSubanimationTransform2: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, 2 << 5 ret z @@ -341,7 +341,7 @@ LoadAnimationTileset: ld e, a ld a, [hl] ld d, a ; de = address of tileset - ld hl, vSprites + $310 + ld hl, vSprites tile $31 ld b, BANK(AnimationTileset1) ; ROM bank ld a, [wTempTilesetNumTiles] ld c, a ; number of tiles @@ -373,6 +373,7 @@ ENDC IF DEF(_BLUE) INCBIN "gfx/slots/blue_slots_2.2bpp" ENDC +SlotMachineTiles2End: MoveAnimation: push hl @@ -421,11 +422,11 @@ MoveAnimation: ShareMoveAnimations: ; some moves just reuse animations from status conditions - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ret z - ; opponent’s turn + ; opponent's turn ld a, [wAnimationID] @@ -497,18 +498,18 @@ AnimationShakeScreenHorizontallySlow: push bc push bc .loop1 - ld a, [rWX] + ldh a, [rWX] inc a - ld [rWX], a + ldh [rWX], a ld c, 2 call DelayFrames dec b jr nz, .loop1 pop bc .loop2 - ld a, [rWX] + ldh a, [rWX] dec a - ld [rWX], a + ldh [rWX], a ld c, 2 call DelayFrames dec b @@ -534,16 +535,16 @@ SetAnimationPalette: ld b, $f0 .next ld a, b - ld [rOBP0], a + ldh [rOBP0], a ld a, $6c - ld [rOBP1], a + ldh [rOBP1], a ret .notSGB ld a, $e4 ld [wAnimPalette], a - ld [rOBP0], a + ldh [rOBP0], a ld a, $6c - ld [rOBP1], a + ldh [rOBP1], a ret PlaySubanimation: @@ -656,9 +657,9 @@ DoBallTossSpecialEffects: cp 3 ; is it a Master Ball or Ultra Ball? jr nc, .skipFlashingEffect .flashingEffect ; do a flashing effect if it's Master Ball or Ultra Ball - ld a, [rOBP0] + ldh a, [rOBP0] xor %00111100 ; complement colors 1 and 2 - ld [rOBP0], a + ldh [rOBP0], a .skipFlashingEffect ld a, [wSubAnimCounter] cp 11 ; is it the beginning of the subanimation? @@ -682,7 +683,7 @@ DoBallTossSpecialEffects: cp 1 ret nz .moveGhostMarowakLeft - coord hl, 17, 0 + hlcoord 17, 0 ld de, 20 lb bc, 7, 7 .loop @@ -695,7 +696,7 @@ DoBallTossSpecialEffects: dec b jr nz, .loop ld a, %00001000 - ld [rNR10], a ; Channel 1 sweep register + ldh [rNR10], a ; Channel 1 sweep register ret .isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame ld a, [wSubAnimCounter] @@ -781,7 +782,7 @@ DoExplodeSpecialEffects: cp 1 ; is it the end of the subanimation? jr nz, FlashScreenEveryFourFrameBlocks ; if it's the end of the subanimation, make the attacking pokemon disappear - coord hl, 1, 5 + hlcoord 1, 5 jp AnimationHideMonPic ; make pokemon disappear ; flashes the screen when subanimation counter is 1 modulo 4 @@ -882,9 +883,9 @@ TradeJumpPokeball: ld c, 5 call DelayFrames pop bc - ld a, [hSCX] ; background scroll X + ldh a, [hSCX] ; background scroll X sub 8 ; scroll to the left - ld [hSCX], a + ldh [hSCX], a pop de jr .loop @@ -920,16 +921,16 @@ AnimationDelay10: ; calls a function with the turn flipped from player to enemy or vice versa ; input - hl - address of function to call CallWithTurnFlipped: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] push af xor 1 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ld de, .returnAddress push de jp hl .returnAddress pop af - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ret ; flashes the screen for an extended period (48 frames) @@ -947,7 +948,7 @@ AnimationFlashScreenLong: ld a, [hli] cp $01 ; is it the end of the palettes? jr z, .endOfPalettes - ld [rBGP], a + ldh [rBGP], a call FlashScreenLongDelay jr .innerLoop .endOfPalettes @@ -1006,18 +1007,18 @@ FlashScreenLongDelay: jp DelayFrames AnimationFlashScreen: - ld a, [rBGP] + ldh a, [rBGP] push af ; save initial palette ld a, %00011011 ; 0, 1, 2, 3 (inverted colors) - ld [rBGP], a + ldh [rBGP], a ld c, 2 call DelayFrames xor a ; white out background - ld [rBGP], a + ldh [rBGP], a ld c, 2 call DelayFrames pop af - ld [rBGP], a ; restore initial palette + ldh [rBGP], a ; restore initial palette ret AnimationDarkScreenPalette: @@ -1062,7 +1063,7 @@ SetAnimationBGPalette: jr z, .next ld a, c .next - ld [rBGP], a + ldh [rBGP], a ret ld b, $5 @@ -1133,14 +1134,14 @@ _AnimationWaterDroplets: AnimationSlideMonUp: ; Slides the mon's sprite upwards. ld c, 7 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a - coord hl, 1, 6 - coord de, 1, 5 + hlcoord 1, 6 + decoord 1, 5 ld a, $30 jr z, .next - coord hl, 12, 1 - coord de, 12, 0 + hlcoord 12, 1 + decoord 12, 0 ld a, $ff .next ld [wSlideMonUpBottomRowLeftTile], a @@ -1201,11 +1202,11 @@ _AnimationSlideMonUp: jr nz, .slideLoop ; Fill in the bottom row of the mon pic with the next row's tile IDs. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a - coord hl, 1, 11 + hlcoord 1, 11 jr z, .next - coord hl, 12, 6 + hlcoord 12, 6 .next ld a, [wSlideMonUpBottomRowLeftTile] inc a @@ -1370,13 +1371,13 @@ AnimationShowEnemyMonPic: AnimationShakeBackAndForth: ; Shakes the mon's sprite back and forth rapidly. This is used in Double Team. ; The mon's sprite disappears after this animation. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a - coord hl, 0, 5 - coord de, 2, 5 + hlcoord 0, 5 + decoord 2, 5 jr z, .next - coord hl, 11, 0 - coord de, 13, 0 + hlcoord 11, 0 + decoord 13, 0 .next xor a @@ -1418,11 +1419,11 @@ AnimationMoveMonHorizontally: ; Shifts the mon's sprite horizontally to a fixed location. Used by lots of ; animations like Tackle/Body Slam. call AnimationHideMonPic - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a - coord hl, 2, 5 + hlcoord 2, 5 jr z, .next - coord hl, 11, 0 + hlcoord 11, 0 .next xor a push hl @@ -1434,7 +1435,7 @@ AnimationMoveMonHorizontally: AnimationResetMonPosition: ; Resets the mon's sprites to be located at the normal coordinates. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, 5 * SCREEN_WIDTH + 2 jr z, .next @@ -1446,7 +1447,7 @@ AnimationResetMonPosition: AnimationSpiralBallsInward: ; Creates an effect that looks like energy balls spiralling into the ; player mon's sprite. Used in Focus Energy, for example. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn ld a, -40 @@ -1530,15 +1531,15 @@ AnimationSquishMonPic: ld c, 4 .loop push bc - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn - coord hl, 16, 0 - coord de, 14, 0 + hlcoord 16, 0 + decoord 14, 0 jr .next .playerTurn - coord hl, 5, 5 - coord de, 3, 5 + hlcoord 5, 5 + decoord 3, 5 .next push de xor a ; left @@ -1583,7 +1584,7 @@ _AnimationSquishMonPic: AnimationShootBallsUpward: ; Shoots one pillar of "energy" balls upwards. Used in Teleport/Sky Attack ; animations. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn lb bc, 0, 16 * 8 @@ -1651,7 +1652,7 @@ _AnimationShootBallsUpward: AnimationShootManyBallsUpward: ; Shoots several pillars of "energy" balls upward. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, UpwardBallsAnimXCoordinatesPlayerTurn ld a, $50 ; y coordinate for "energy" ball pillar @@ -1743,13 +1744,13 @@ AnimationSlideMonDownAndHide: _AnimationSlideMonOff: ; 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, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn - coord hl, 12, 0 + hlcoord 12, 0 jr .next .playerTurn - coord hl, 0, 5 + hlcoord 0, 5 .next ld d, 8 ; d's value is unused .slideLoop ; iterates once for each time the pic slides by one tile @@ -1758,7 +1759,7 @@ _AnimationSlideMonOff: .rowLoop ; iterates once for each row ld c, 8 .tileLoop ; iterates once for each tile in the row - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn2 call .EnemyNextTile @@ -1821,7 +1822,7 @@ AnimationSlideMonHalfOff: jp Delay3 CopyTempPicToMonPic: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, vBackPic ; player turn jr z, .next @@ -1837,9 +1838,9 @@ AnimationWavyScreen: call BattleAnimCopyTileMapToVRAM call Delay3 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, SCREEN_HEIGHT_PX - ld [hWY], a + ldh [hWY], a ld d, $80 ; terminator ld e, SCREEN_HEIGHT_PX - 1 ld c, $ff @@ -1848,7 +1849,7 @@ AnimationWavyScreen: push hl .innerLoop call WavyScreen_SetSCX - ld a, [rLY] + ldh a, [rLY] cp e ; is it the last visible line in the frame? jr nz, .innerLoop ; keep going if not pop hl @@ -1861,11 +1862,11 @@ AnimationWavyScreen: dec c jr nz, .loop xor a - ld [hWY], a + ldh [hWY], a call SaveScreenTilesToBuffer2 call ClearScreen ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 call LoadScreenTilesFromBuffer2 ld hl, vBGMap1 @@ -1873,11 +1874,11 @@ AnimationWavyScreen: ret WavyScreen_SetSCX: - ld a, [rSTAT] + ldh a, [rSTAT] and $3 ; is it H-blank? jr nz, WavyScreen_SetSCX ; wait until it's H-blank ld a, [hl] - ld [rSCX], a + ldh [rSCX], a inc hl ld a, [hl] cp d ; have we reached the end? @@ -1898,7 +1899,7 @@ AnimationSubstitute: xor a ld bc, $310 call FillMemory - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn ld hl, SlowbroSprite ; facing down sprite @@ -1937,7 +1938,7 @@ CopySlowbroSpriteData: jp FarCopyData2 HideSubstituteShowMonAnim: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wPlayerMonMinimized ld a, [wPlayerBattleStatus2] @@ -1987,7 +1988,7 @@ AnimationTransformMon: ld [wChangeMonPicEnemyTurnSpecies], a ChangeMonPic: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn ld a, [wChangeMonPicEnemyTurnSpecies] @@ -1996,7 +1997,7 @@ ChangeMonPic: xor a ld [wSpriteFlipped], a call GetMonHeader - coord hl, 12, 0 + hlcoord 12, 0 call LoadFrontSpriteByMonIndex jr .done .playerTurn @@ -2020,11 +2021,11 @@ ChangeMonPic: AnimationHideEnemyMonPic: ; Hides the enemy mon's sprite xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld hl, AnimationHideMonPic call CallWithTurnFlipped ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a jp Delay3 InitMultipleObjectsOAM: @@ -2050,7 +2051,7 @@ InitMultipleObjectsOAM: AnimationHideMonPic: ; Hides the mon's sprite. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn ld a, 12 @@ -2064,7 +2065,7 @@ ClearMonPicFromTileMap: push bc ld e, a ld d, 0 - coord hl, 0, 0 + hlcoord 0, 0 add hl, de lb bc, 7, 7 call ClearScreenArea @@ -2078,7 +2079,7 @@ ClearMonPicFromTileMap: ; in order to show only a portion of the mon sprite. GetMonSpriteTileMapPointerFromRowCount: push de - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .enemyTurn ld a, 20 * 5 + 1 @@ -2086,7 +2087,7 @@ GetMonSpriteTileMapPointerFromRowCount: .enemyTurn ld a, 12 .next - coord hl, 0, 0 + hlcoord 0, 0 ld e, a ld d, 0 add hl, de @@ -2166,7 +2167,7 @@ GetMoveSound: ld b, a call IsCryMove jr nc, .NotCryMove - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .next ld a, [wBattleMonSpecies] ; get number of current monster @@ -2211,14 +2212,14 @@ IsCryMove: INCLUDE "data/moves/sfx.asm" CopyPicTiles: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, $31 ; base tile ID of player mon sprite jr z, .next ; enemy turn xor a ; base tile ID of enemy mon sprite .next - ld [hBaseTileID], a + ldh [hBaseTileID], a jr CopyTileIDs_NoBGTransfer ; copy the tiles used when a mon is being sent out of or into a pokeball @@ -2235,7 +2236,7 @@ CopyDownscaledMonTiles: CopyTileIDs_NoBGTransfer: xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ; fall through ; b = number of rows @@ -2245,7 +2246,7 @@ CopyTileIDs: .rowLoop push bc push hl - ld a, [hBaseTileID] + ldh a, [hBaseTileID] ld b, a .columnLoop ld a, [de] @@ -2261,7 +2262,7 @@ CopyTileIDs: dec b jr nz, .rowLoop ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a pop hl ret @@ -2361,16 +2362,16 @@ Unknown_79c50: AnimationLeavesFalling: ; Makes leaves float down from the top of the screen. This is used ; in Razor Leaf's animation. - ld a, [rOBP0] + ldh a, [rOBP0] push af ld a, [wAnimPalette] - ld [rOBP0], a + ldh [rOBP0], a ld d, $37 ; leaf tile ld a, 3 ; number of leaves ld [wNumFallingObjects], a call AnimationFallingObjects pop af - ld [rOBP0], a + ldh [rOBP0], a ret AnimationPetalsFalling: @@ -2529,7 +2530,7 @@ AnimationShakeEnemyHUD: call CopyVideoData xor a - ld [hSCX], a + ldh [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. @@ -2539,7 +2540,7 @@ AnimationShakeEnemyHUD: ; 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_PX - ld [hWY], a + ldh [hWY], a ; Copy wTileMap to VRAM such that the row below the enemy HUD (in wTileMap) is ; lined up with row 0 of the window. @@ -2551,7 +2552,7 @@ AnimationShakeEnemyHUD: ; covers everything below the enemy HD with a copy that looks just like what ; was there before. ld a, 7 * 8 - ld [hWY], a + ldh [hWY], a ; 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 @@ -2576,11 +2577,11 @@ AnimationShakeEnemyHUD: call AnimationShowMonPic call ClearSprites ld a, SCREEN_HEIGHT_PX - ld [hWY], a + ldh [hWY], a ld hl, vBGMap1 call BattleAnimCopyTileMapToVRAM xor a - ld [hWY], a + ldh [hWY], a call SaveScreenTilesToBuffer1 ld hl, vBGMap0 call BattleAnimCopyTileMapToVRAM @@ -2595,7 +2596,7 @@ AnimationShakeEnemyHUD: CopyTileIDsFromList: call GetPredefRegisters ld a, c - ld [hBaseTileID], a + ldh [hBaseTileID], a ld a, b push hl call GetTileIDList @@ -2603,30 +2604,30 @@ CopyTileIDsFromList: jp CopyTileIDs ShakeEnemyHUD_ShakeBG: - ld a, [hSCX] + ldh a, [hSCX] ld [wTempSCX], a .loop ld a, [wTempSCX] add d - ld [hSCX], a + ldh [hSCX], a ld c, 2 call DelayFrames ld a, [wTempSCX] sub d - ld [hSCX], a + ldh [hSCX], a ld c, 2 call DelayFrames dec e jr nz, .loop ld a, [wTempSCX] - ld [hSCX], a + ldh [hSCX], a ret BattleAnimCopyTileMapToVRAM: ld a, h - ld [hAutoBGTransferDest + 1], a + ldh [hAutoBGTransferDest + 1], a ld a, l - ld [hAutoBGTransferDest], a + ldh [hAutoBGTransferDest], a jp Delay3 TossBallAnimation: diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm index 548e85fb..34b3fbdb 100644 --- a/engine/battle/battle_transitions.asm +++ b/engine/battle/battle_transitions.asm @@ -1,9 +1,9 @@ BattleTransition: ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 xor a - ld [hWY], a + ldh [hWY], a dec a ld [wUpdateSpritesEnabled], a call DelayFrame @@ -11,7 +11,7 @@ BattleTransition: ; Determine which OAM block is being used by the enemy trainer sprite (if there ; is one). ld hl, wSpritePlayerStateData1ImageIndex - ld a, [hSpriteIndexOrTextID] ; enemy trainer sprite index (0 if wild battle) + ldh a, [hSpriteIndexOrTextID] ; enemy trainer sprite index (0 if wild battle) ld c, a ld b, 0 ld de, $10 @@ -154,20 +154,18 @@ GetBattleTransitionID_IsDungeonMap: INCLUDE "data/maps/dungeon_maps.asm" LoadBattleTransitionTile: - ld hl, vChars1 + $7f0 + ld hl, vChars1 tile $7f ld de, BattleTransitionTile - lb bc, BANK(BattleTransitionTile), (BattleTransitionTileEnd - BattleTransitionTile) / $10 + lb bc, BANK(BattleTransitionTile), 1 jp CopyVideoData -BattleTransitionTile: - INCBIN "gfx/overworld/battle_transition.2bpp" -BattleTransitionTileEnd: +BattleTransitionTile: INCBIN "gfx/overworld/battle_transition.2bpp" BattleTransition_BlackScreen: ld a, $ff - ld [rBGP], a - ld [rOBP0], a - ld [rOBP1], a + ldh [rBGP], a + ldh [rOBP0], a + ldh [rOBP1], a ret ; for non-dungeon trainer battles @@ -181,7 +179,7 @@ BattleTransition_Spiral: call BattleTransition_InwardSpiral jr .done .outwardSpiral - coord hl, 10, 10 + hlcoord 10, 10 ld a, $3 ld [wOutwardSpiralCurrentDirection], a ld a, l @@ -210,7 +208,7 @@ BattleTransition_Spiral: BattleTransition_InwardSpiral: ld a, 7 ld [wInwardSpiralUpdateScreenCounter], a - coord hl, 0, 0 + hlcoord 0, 0 ld c, SCREEN_HEIGHT - 1 ld de, SCREEN_WIDTH call BattleTransition_InwardSpiral_ @@ -330,7 +328,7 @@ BattleTransition_FlashScreen_: ld a, [hli] cp $1 jr z, .done - ld [rBGP], a + ldh [rBGP], a ld c, 2 call DelayFrames jr .loop @@ -349,25 +347,25 @@ BattleTransition_Shrink: .loop push bc xor a - ld [hAutoBGTransferEnabled], a - coord hl, 0, 7 - coord de, 0, 8 + ldh [hAutoBGTransferEnabled], a + hlcoord 0, 7 + decoord 0, 8 ld bc, -SCREEN_WIDTH * 2 call BattleTransition_CopyTiles1 - coord hl, 0, 10 - coord de, 0, 9 + hlcoord 0, 10 + decoord 0, 9 ld bc, SCREEN_WIDTH * 2 call BattleTransition_CopyTiles1 - coord hl, 8, 0 - coord de, 9, 0 + hlcoord 8, 0 + decoord 9, 0 ld bc, -2 call BattleTransition_CopyTiles2 - coord hl, 11, 0 - coord de, 10, 0 + hlcoord 11, 0 + decoord 10, 0 ld bc, 2 call BattleTransition_CopyTiles2 ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld c, 6 call DelayFrames pop bc @@ -381,23 +379,23 @@ BattleTransition_Shrink: BattleTransition_Split: ld c, SCREEN_HEIGHT / 2 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a .loop push bc - coord hl, 0, 16 - coord de, 0, 17 + hlcoord 0, 16 + decoord 0, 17 ld bc, -SCREEN_WIDTH * 2 call BattleTransition_CopyTiles1 - coord hl, 0, 1 - coord de, 0, 0 + hlcoord 0, 1 + decoord 0, 0 ld bc, SCREEN_WIDTH * 2 call BattleTransition_CopyTiles1 - coord hl, 18, 0 - coord de, 19, 0 + hlcoord 18, 0 + decoord 19, 0 ld bc, -2 call BattleTransition_CopyTiles2 - coord hl, 1, 0 - coord de, 0, 0 + hlcoord 1, 0 + decoord 0, 0 ld bc, 2 call BattleTransition_CopyTiles2 call BattleTransition_TransferDelay3 @@ -493,10 +491,10 @@ BattleTransition_CopyTiles2: ; used for high level wild dungeon battles BattleTransition_VerticalStripes: ld c, SCREEN_HEIGHT - coord hl, 0, 0 - coord de, 1, 17 + hlcoord 0, 0 + decoord 1, 17 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a .loop push bc push hl @@ -532,10 +530,10 @@ BattleTransition_VerticalStripes_: ; used for low level wild dungeon battles BattleTransition_HorizontalStripes: ld c, SCREEN_WIDTH - coord hl, 0, 0 - coord de, 19, 1 + hlcoord 0, 0 + decoord 19, 1 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a .loop push bc push hl @@ -582,7 +580,7 @@ BattleTransition_FlashScreen: ld b, $3 call BattleTransition_FlashScreen_ xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret BattleTransition_Circle_Sub1: @@ -601,10 +599,10 @@ BattleTransition_Circle_Sub1: BattleTransition_TransferDelay3: ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret ; used for low level wild non-dungeon battles @@ -654,84 +652,84 @@ BattleTransition_Circle_Sub2: BattleTransition_HalfCircle1: db $01 dw BattleTransition_CircleData1 - dwCoord 18, 6 + dwcoord 18, 6 db $01 dw BattleTransition_CircleData2 - dwCoord 19, 3 + dwcoord 19, 3 db $01 dw BattleTransition_CircleData3 - dwCoord 18, 0 + dwcoord 18, 0 db $01 dw BattleTransition_CircleData4 - dwCoord 14, 0 + dwcoord 14, 0 db $01 dw BattleTransition_CircleData5 - dwCoord 10, 0 + dwcoord 10, 0 db $00 dw BattleTransition_CircleData5 - dwCoord 9, 0 + dwcoord 9, 0 db $00 dw BattleTransition_CircleData4 - dwCoord 5, 0 + dwcoord 5, 0 db $00 dw BattleTransition_CircleData3 - dwCoord 1, 0 + dwcoord 1, 0 db $00 dw BattleTransition_CircleData2 - dwCoord 0, 3 + dwcoord 0, 3 db $00 dw BattleTransition_CircleData1 - dwCoord 1, 6 + dwcoord 1, 6 BattleTransition_HalfCircle2: db $00 dw BattleTransition_CircleData1 - dwCoord 1, 11 + dwcoord 1, 11 db $00 dw BattleTransition_CircleData2 - dwCoord 0, 14 + dwcoord 0, 14 db $00 dw BattleTransition_CircleData3 - dwCoord 1, 17 + dwcoord 1, 17 db $00 dw BattleTransition_CircleData4 - dwCoord 5, 17 + dwcoord 5, 17 db $00 dw BattleTransition_CircleData5 - dwCoord 9, 17 + dwcoord 9, 17 db $01 dw BattleTransition_CircleData5 - dwCoord 10, 17 + dwcoord 10, 17 db $01 dw BattleTransition_CircleData4 - dwCoord 14, 17 + dwcoord 14, 17 db $01 dw BattleTransition_CircleData3 - dwCoord 18, 17 + dwcoord 18, 17 db $01 dw BattleTransition_CircleData2 - dwCoord 19, 14 + dwcoord 19, 14 db $01 dw BattleTransition_CircleData1 - dwCoord 18, 11 + dwcoord 18, 11 BattleTransition_Circle_Sub3: push hl diff --git a/engine/battle/common_text.asm b/engine/battle/common_text.asm index 1cb455f3..9f6f90b6 100644 --- a/engine/battle/common_text.asm +++ b/engine/battle/common_text.asm @@ -24,7 +24,7 @@ PrintBeginningBattleText: ld hl, TrainerWantsToFightText .wildBattle push hl - callab DrawAllPokeballs + callfar DrawAllPokeballs pop hl call PrintText jr .done @@ -38,7 +38,7 @@ PrintBeginningBattleText: ld a, b and a jr z, .noSilphScope - callab LoadEnemyMonData + callfar LoadEnemyMonData jr .notPokemonTower .noSilphScope ld hl, EnemyAppearedText @@ -54,8 +54,8 @@ PrintBeginningBattleText: call PrintText ld hl, UnveiledGhostText call PrintText - callab LoadEnemyMonData - callab MarowakAnim + callfar LoadEnemyMonData + callfar MarowakAnim ld hl, WildMonAppearedText call PrintText @@ -101,16 +101,16 @@ PrintSendOutMonMessage: ld hl, GoText jr z, .printText xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld hl, wEnemyMonHP ld a, [hli] ld [wLastSwitchInEnemyMonHP], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hl] ld [wLastSwitchInEnemyMonHP + 1], a - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, 25 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld hl, wEnemyMonMaxHP ld a, [hli] @@ -121,9 +121,9 @@ PrintSendOutMonMessage: rr b ld a, b ld b, 4 - ld [hDivisor], a ; enemy mon max HP divided by 4 + ldh [hDivisor], a ; enemy mon max HP divided by 4 call Divide - ld a, [hQuotient + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP + ldh a, [hQuotient + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP ld hl, GoText ; 70% or greater cp 70 jr nc, .printText @@ -179,14 +179,14 @@ PlayerMon2Text: dec hl ld a, [de] sub b - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a dec de ld b, [hl] ld a, [de] sbc b - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, 25 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld hl, wEnemyMonMaxHP ld a, [hli] @@ -197,11 +197,11 @@ PlayerMon2Text: rr b ld a, b ld b, 4 - ld [hDivisor], a + ldh [hDivisor], a call Divide pop bc pop de - ld a, [hQuotient + 3] ; a = ((LastSwitchInEnemyMonHP - CurrentEnemyMonHP) / 25) / (EnemyMonMaxHP / 4) + ldh a, [hQuotient + 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. diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 935764aa..5cf8a45d 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -11,7 +11,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ld a, MESSAGE_BOX ; the usual text box at the bottom of the screen ld [wTextBoxID], a call DisplayTextBoxID - coord hl, 1, 5 + hlcoord 1, 5 lb bc, 3, 7 call ClearScreenArea call DisableLCD @@ -27,7 +27,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: or c jr nz, .clearBackgroundLoop ; copy the work RAM tile map to VRAM - coord hl, 0, 0 + hlcoord 0, 0 ld de, vBGMap0 ld b, 18 ; number of rows .copyRowLoop @@ -48,25 +48,25 @@ SlidePlayerAndEnemySilhouettesOnScreen: jr nz, .copyRowLoop call EnableLCD ld a, $90 - ld [hWY], a - ld [rWY], a + ldh [hWY], a + ldh [rWY], a xor a - ld [hTilesetType], a - ld [hSCY], a + ldh [hTilesetType], a + ldh [hSCY], a dec a ld [wUpdateSpritesEnabled], a call Delay3 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld b, $70 ld c, $90 ld a, c - ld [hSCX], a + ldh [hSCX], a call DelayFrame ld a, %11100100 ; inverted palette for silhouette effect - ld [rBGP], a - ld [rOBP0], a - ld [rOBP1], a + ldh [rBGP], a + ldh [rOBP0], a + ldh [rOBP1], a .slideSilhouettesLoop ; slide silhouettes of the player's pic and the enemy's pic onto the screen ld h, b ld l, $40 @@ -78,26 +78,26 @@ SlidePlayerAndEnemySilhouettesOnScreen: call SetScrollXForSlidingPlayerBodyLeft ; end background scrolling on line $60 call SlidePlayerHeadLeft ld a, c - ld [hSCX], a + ldh [hSCX], a dec c dec c jr nz, .slideSilhouettesLoop ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, $31 - ld [hStartTileID], a - coord hl, 1, 5 + ldh [hStartTileID], a + hlcoord 1, 5 predef CopyUncompressedPicToTilemap xor a - ld [hWY], a - ld [rWY], a + ldh [hWY], a + ldh [rWY], a inc a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 ld b, SET_PAL_BATTLE call RunPaletteCommand call HideSprites - jpab PrintBeginningBattleText + jpfar 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 @@ -118,13 +118,13 @@ SlidePlayerHeadLeft: ret SetScrollXForSlidingPlayerBodyLeft: - ld a, [rLY] + ldh a, [rLY] cp l jr nz, SetScrollXForSlidingPlayerBodyLeft ld a, h - ld [rSCX], a + ldh [rSCX], a .loop - ld a, [rLY] + ldh a, [rLY] cp h jr z, .loop ret @@ -178,7 +178,7 @@ StartBattle: ld hl, .outOfSafariBallsText jp PrintText .notOutOfSafariBalls - callab PrintSafariZoneBattleText + callfar PrintSafariZoneBattleText ld a, [wEnemyMonSpeed + 1] add a ld b, a ; init b (which is later compared with random value) to (enemy speed % 256) * 2 @@ -232,7 +232,7 @@ StartBattle: ld [wcf91], a ld [wBattleMonSpecies2], a call LoadScreenTilesFromBuffer1 - coord hl, 1, 5 + hlcoord 1, 5 ld a, $9 call SlideTrainerPicOffScreen call SaveScreenTilesToBuffer1 @@ -266,8 +266,8 @@ EnemyRan: ld a, SFX_RUN call PlaySoundWaitForCurrent xor a - ld [hWhoseTurn], a - jpab AnimationSlideEnemyMonOff + ldh [hWhoseTurn], a + jpfar AnimationSlideEnemyMonOff WildRanText: text_far _WildRanText @@ -365,7 +365,7 @@ MainInBattleLoop: jr nz, .specialMoveNotUsed ld [wPlayerSelectedMove], a .specialMoveNotUsed - callab SwitchEnemyMon + callfar SwitchEnemyMon .noLinkBattle ld a, [wPlayerSelectedMove] cp QUICK_ATTACK @@ -398,7 +398,7 @@ MainInBattleLoop: jr nc, .playerMovesFirst ; if player is faster jr .enemyMovesFirst ; if enemy is faster .speedEqual ; 50/50 chance for both players - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .invertOutcome call BattleRandom @@ -412,8 +412,8 @@ MainInBattleLoop: jr .playerMovesFirst .enemyMovesFirst ld a, $1 - ld [hWhoseTurn], a - callab TrainerAI + ldh [hWhoseTurn], a + callfar TrainerAI jr c, .AIActionUsedEnemyFirst call ExecuteEnemyMove ld a, [wEscapedFromBattle] @@ -450,8 +450,8 @@ MainInBattleLoop: jp z, HandlePlayerMonFainted call DrawHUDsAndHPBars ld a, $1 - ld [hWhoseTurn], a - callab TrainerAI + ldh [hWhoseTurn], a + callfar TrainerAI jr c, .AIActionUsedPlayerFirst call ExecuteEnemyMove ld a, [wEscapedFromBattle] @@ -470,7 +470,7 @@ MainInBattleLoop: HandlePoisonBurnLeechSeed: ld hl, wBattleMonHP ld de, wBattleMonStatus - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playersTurn ld hl, wEnemyMonHP @@ -495,7 +495,7 @@ HandlePoisonBurnLeechSeed: call HandlePoisonBurnLeechSeed_DecreaseOwnHP .notBurnedOrPoisoned ld de, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playersTurn2 ld de, wEnemyBattleStatus2 @@ -504,16 +504,16 @@ HandlePoisonBurnLeechSeed: add a jr nc, .notLeechSeeded push hl - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] push af xor $1 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a xor a ld [wAnimationType], a ld a, ABSORB call PlayMoveAnimation ; play leech seed animation (from opposing mon) pop af - ld [hWhoseTurn], a + ldh [hWhoseTurn], a pop hl call HandlePoisonBurnLeechSeed_DecreaseOwnHP call HandlePoisonBurnLeechSeed_IncreaseEnemyHP @@ -571,7 +571,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: .nonZeroDamage ld hl, wPlayerBattleStatus3 ld de, wPlayerToxicCounter - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playersTurn ld hl, wEnemyBattleStatus3 @@ -618,7 +618,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: HandlePoisonBurnLeechSeed_IncreaseEnemyHP: push hl ld hl, wEnemyMonMaxHP - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playersTurn ld hl, wBattleMonMaxHP @@ -655,23 +655,23 @@ HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ld [hl], a ld [wHPBarNewHP], a .noOverfullHeal - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor $1 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a call UpdateCurMonHPBar - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor $1 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a pop hl ret UpdateCurMonHPBar: - coord hl, 10, 9 ; tile pointer to player HP bar - ld a, [hWhoseTurn] + hlcoord 10, 9 ; tile pointer to player HP bar + ldh a, [hWhoseTurn] and a ld a, $1 jr z, .playersTurn - coord hl, 2, 2 ; tile pointer to enemy HP bar + hlcoord 2, 2 ; tile pointer to enemy HP bar xor a .playersTurn push bc @@ -767,10 +767,10 @@ FaintEnemyPokemon: ld hl, wPlayerUsedMove ld [hli], a ld [hl], a - coord hl, 12, 5 - coord de, 12, 6 + hlcoord 12, 5 + decoord 12, 6 call SlideDownFaintedMonPic - coord hl, 0, 0 + hlcoord 0, 0 lb bc, 4, 11 call ClearScreenArea ld a, [wIsInBattle] @@ -837,7 +837,7 @@ FaintEnemyPokemon: .giveExpToMonsThatFought xor a ld [wBoostExpByExpAll], a - callab GainExperience + callfar GainExperience pop af ret z ; return if no exp all @@ -855,7 +855,7 @@ FaintEnemyPokemon: jr nz, .gainExpFlagsLoop ld a, b ld [wPartyGainExpFlags], a - jpab GainExperience + jpfar GainExperience EnemyMonFaintedText: text_far _EnemyMonFaintedText @@ -893,7 +893,7 @@ ReplaceFaintedEnemyMon: ld hl, wEnemyHPBarColor ld e, $30 call GetBattleHealthBarColor - callab DrawEnemyPokeballs + callfar DrawEnemyPokeballs ld a, [wLinkState] cp LINK_STATE_BATTLING jr nz, .notLinkBattle @@ -1021,11 +1021,11 @@ RemoveFaintedPlayerMon: ld [hl], a ld [wBattleMonStatus], a call ReadPlayerMonCurHPAndStatus - coord hl, 9, 7 + hlcoord 9, 7 lb bc, 5, 11 call ClearScreenArea - coord hl, 1, 10 - coord de, 1, 11 + hlcoord 1, 10 + decoord 1, 11 call SlideDownFaintedMonPic ld a, $1 ld [wBattleResult], a @@ -1059,7 +1059,7 @@ DoUseNextMonDialogue: ld hl, UseNextMonText call PrintText .displayYesNoBox - coord hl, 13, 9 + hlcoord 13, 9 lb bc, 10, 14 ld a, TWO_OPTION_MENU ld [wTextBoxID], a @@ -1136,7 +1136,7 @@ HandlePlayerBlackOut: ld a, [wCurOpponent] cp OPP_SONY1 jr nz, .notSony1Battle - coord hl, 0, 0 ; sony 1 battle + hlcoord 0, 0 ; sony 1 battle lb bc, 8, 21 call ClearScreenArea call ScrollTrainerPicAfterBattle @@ -1232,7 +1232,7 @@ SevenSpacesText: ; if a is 8, the slide is to the right, else it is to the left ; bug: when this is called, [hAutoBGTransferEnabled] is non-zero, so there is screen tearing SlideTrainerPicOffScreen: - ld [hSlideAmount], a + ldh [hSlideAmount], a ld c, a .slideStepLoop ; each iteration, the trainer pic is slid one tile left/right push bc @@ -1240,10 +1240,10 @@ SlideTrainerPicOffScreen: ld b, 7 ; number of rows .rowLoop push hl - ld a, [hSlideAmount] + ldh a, [hSlideAmount] ld c, a .columnLoop - ld a, [hSlideAmount] + ldh a, [hSlideAmount] cp 8 jr z, .slideRight .slideLeft ; slide player sprite off screen @@ -1306,7 +1306,7 @@ EnemySendOutFirstMon: ld [wAICount], a ld hl, wPlayerBattleStatus1 res 5, [hl] - coord hl, 18, 0 + hlcoord 18, 0 ld a, 8 call SlideTrainerPicOffScreen call PrintEmptyString @@ -1376,7 +1376,7 @@ EnemySendOutFirstMon: jr nz, .next4 ld hl, TrainerAboutToUseText call PrintText - coord hl, 0, 7 + hlcoord 0, 7 lb bc, 8, 1 ld a, TWO_OPTION_MENU ld [wTextBoxID], a @@ -1411,7 +1411,7 @@ EnemySendOutFirstMon: call LoadScreenTilesFromBuffer1 .next4 call ClearSprites - coord hl, 0, 0 + hlcoord 0, 0 lb bc, 4, 11 call ClearScreenArea ld b, SET_PAL_BATTLE @@ -1426,8 +1426,8 @@ EnemySendOutFirstMon: ld de, vFrontPic call LoadMonFrontSprite ld a, -$31 - ld [hStartTileID], a - coord hl, 15, 6 + ldh [hStartTileID], a + hlcoord 15, 6 predef AnimateSendingOutMon ld a, [wEnemyMonSpecies2] call PlayCry @@ -1508,14 +1508,14 @@ TryRunningFromBattle: inc a ld [wNumRunAttempts], a ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hl] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [de] - ld [hEnemySpeed], a + ldh [hEnemySpeed], a inc de ld a, [de] - ld [hEnemySpeed + 1], a + ldh [hEnemySpeed + 1], a call LoadScreenTilesFromBuffer1 ld de, hMultiplicand + 1 ld hl, hEnemySpeed @@ -1523,17 +1523,17 @@ TryRunningFromBattle: call StringCmp jr nc, .canEscape ; jump if player speed greater than enemy speed xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, 32 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; multiply player speed by 32 - ld a, [hProduct + 2] - ld [hDividend], a - ld a, [hProduct + 3] - ld [hDividend + 1], a - ld a, [hEnemySpeed] + ldh a, [hProduct + 2] + ldh [hDividend], a + ldh a, [hProduct + 3] + ldh [hDividend + 1], a + ldh a, [hEnemySpeed] ld b, a - ld a, [hEnemySpeed + 1] + ldh a, [hEnemySpeed + 1] ; divide enemy speed by 4 srl b rr a @@ -1541,10 +1541,10 @@ TryRunningFromBattle: rr a and a jr z, .canEscape ; jump if enemy speed divided by 4, mod 256 is 0 - ld [hDivisor], a ; ((enemy speed / 4) % 256) + ldh [hDivisor], a ; ((enemy speed / 4) % 256) ld b, $2 call Divide ; divide (player speed * 32) by ((enemy speed / 4) % 256) - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] and a ; is the quotient greater than 256? jr nz, .canEscape ; if so, the player can escape ld a, [wNumRunAttempts] @@ -1554,15 +1554,15 @@ TryRunningFromBattle: dec c jr z, .compareWithRandomValue ld b, 30 - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] add b - ld [hQuotient + 3], a + ldh [hQuotient + 3], a jr c, .canEscape jr .loop .compareWithRandomValue call BattleRandom ld b, a - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] cp b 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 @@ -1720,7 +1720,7 @@ LoadEnemyMonFromParty: ret SendOutMon: - callab PrintSendOutMonMessage + callfar PrintSendOutMonMessage ld hl, wEnemyMonHP ld a, [hli] or [hl] ; is enemy mon HP zero? @@ -1730,7 +1730,7 @@ SendOutMon: call DrawPlayerHUDAndHPBar predef LoadMonBackPic xor a - ld [hStartTileID], a + ldh [hStartTileID], a ld hl, wBattleAndStartSavedMenuItem ld [hli], a ld [hl], a @@ -1754,10 +1754,10 @@ SendOutMon: ld hl, wEnemyBattleStatus1 res USING_TRAPPING_MOVE, [hl] ld a, $1 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ld a, POOF_ANIM call PlayMoveAnimation - coord hl, 4, 11 + hlcoord 4, 11 predef AnimateSendingOutMon ld a, [wcf91] call PlayCry @@ -1766,31 +1766,31 @@ SendOutMon: ; show 2 stages of the player mon getting smaller before disappearing AnimateRetreatingPlayerMon: - coord hl, 1, 5 + hlcoord 1, 5 lb bc, 7, 7 call ClearScreenArea - coord hl, 3, 7 + hlcoord 3, 7 lb bc, 5, 5 xor a ld [wDownscaledMonSize], a - ld [hBaseTileID], a + ldh [hBaseTileID], a predef CopyDownscaledMonTiles ld c, 4 call DelayFrames call .clearScreenArea - coord hl, 4, 9 + hlcoord 4, 9 lb bc, 3, 3 ld a, 1 ld [wDownscaledMonSize], a xor a - ld [hBaseTileID], a + ldh [hBaseTileID], a predef CopyDownscaledMonTiles call Delay3 call .clearScreenArea ld a, $4c - Coorda 5, 11 + ldcoord_a 5, 11 .clearScreenArea - coord hl, 1, 5 + hlcoord 1, 5 lb bc, 7, 7 jp ClearScreenArea @@ -1812,15 +1812,15 @@ DrawHUDsAndHPBars: DrawPlayerHUDAndHPBar: xor a - ld [hAutoBGTransferEnabled], a - coord hl, 9, 7 + ldh [hAutoBGTransferEnabled], a + hlcoord 9, 7 lb bc, 5, 11 call ClearScreenArea - callab PlacePlayerHUDTiles - coord hl, 18, 9 + callfar PlacePlayerHUDTiles + hlcoord 18, 9 ld [hl], $73 ld de, wBattleMonNick - coord hl, 10, 7 + hlcoord 10, 7 call CenterMonName call PlaceString ld hl, wBattleMonSpecies @@ -1831,7 +1831,7 @@ DrawPlayerHUDAndHPBar: ld de, wLoadedMonLevel ld bc, wBattleMonPP - wBattleMonLevel call CopyData - coord hl, 14, 8 + hlcoord 14, 8 push hl inc hl ld de, wLoadedMonStatus @@ -1842,10 +1842,10 @@ DrawPlayerHUDAndHPBar: .doNotPrintLevel ld a, [wLoadedMonSpecies] ld [wcf91], a - coord hl, 10, 9 + hlcoord 10, 9 predef DrawHP ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld hl, wPlayerHPBarColor call GetBattleHealthBarColor ld hl, wBattleMonHP @@ -1873,16 +1873,16 @@ DrawPlayerHUDAndHPBar: DrawEnemyHUDAndHPBar: xor a - ld [hAutoBGTransferEnabled], a - coord hl, 0, 0 + ldh [hAutoBGTransferEnabled], a + hlcoord 0, 0 lb bc, 4, 12 call ClearScreenArea - callab PlaceEnemyHUDTiles + callfar PlaceEnemyHUDTiles ld de, wEnemyMonNick - coord hl, 1, 0 + hlcoord 1, 0 call CenterMonName call PlaceString - coord hl, 4, 1 + hlcoord 4, 1 push hl inc hl ld de, wEnemyMonStatus @@ -1895,9 +1895,9 @@ DrawEnemyHUDAndHPBar: .skipPrintLevel ld hl, wEnemyMonHP ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hld] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a or [hl] ; is current HP zero? jr nz, .hpNonzero ; current HP is 0 @@ -1908,45 +1908,45 @@ DrawEnemyHUDAndHPBar: jp .drawHPBar .hpNonzero xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, 48 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; multiply current HP by 48 ld hl, wEnemyMonMaxHP ld a, [hli] ld b, a ld a, [hl] - ld [hDivisor], a + ldh [hDivisor], a ld a, b and a ; is max HP > 255? jr z, .doDivide ; if max HP > 255, scale both (current HP * 48) and max HP by dividing by 4 so that max HP fits in one byte ; (it needs to be one byte so it can be used as the divisor for the Divide function) - ld a, [hDivisor] + ldh a, [hDivisor] srl b rr a srl b rr a - ld [hDivisor], a - ld a, [hProduct + 2] + ldh [hDivisor], a + ldh a, [hProduct + 2] ld b, a srl b - ld a, [hProduct + 3] + ldh a, [hProduct + 3] rr a srl b rr a - ld [hProduct + 3], a + ldh [hProduct + 3], a ld a, b - ld [hProduct + 2], a + ldh [hProduct + 2], a .doDivide - ld a, [hProduct + 2] - ld [hDividend], a - ld a, [hProduct + 3] - ld [hDividend + 1], a + ldh a, [hProduct + 2] + ldh [hDividend], a + ldh a, [hProduct + 3] + ldh [hDividend + 1], a ld a, $2 ld b, a call Divide ; divide (current HP * 48) by max HP - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ; set variables for DrawHPBar ld e, a ld a, $6 @@ -1955,10 +1955,10 @@ DrawEnemyHUDAndHPBar: .drawHPBar xor a ld [wHPBarType], a - coord hl, 2, 2 + hlcoord 2, 2 call DrawHPBar ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld hl, wEnemyHPBarColor GetBattleHealthBarColor: @@ -2030,12 +2030,12 @@ DisplayBattleMenu:: ld bc, NAME_LENGTH call CopyData ; the following simulates the keystrokes by drawing menus on screen - coord hl, 9, 14 + hlcoord 9, 14 ld [hl], "▶" ld c, 80 call DelayFrames ld [hl], " " - coord hl, 9, 16 + hlcoord 9, 16 ld [hl], "▶" ld c, 50 call DelayFrames @@ -2060,14 +2060,14 @@ DisplayBattleMenu:: ld a, " " jr z, .safariLeftColumn ; put cursor in left column for normal battle menu (i.e. when it's not a Safari battle) - Coorda 15, 14 ; clear upper cursor position in right column - Coorda 15, 16 ; clear lower cursor position in right column + ldcoord_a 15, 14 ; clear upper cursor position in right column + ldcoord_a 15, 16 ; clear lower cursor position in right column ld b, $9 ; top menu item X jr .leftColumn_WaitForInput .safariLeftColumn - Coorda 13, 14 - Coorda 13, 16 - coord hl, 7, 14 + ldcoord_a 13, 14 + ldcoord_a 13, 16 + hlcoord 7, 14 ld de, wNumSafariBalls lb bc, 1, 2 call PrintNumber @@ -2093,14 +2093,14 @@ DisplayBattleMenu:: ld a, " " jr z, .safariRightColumn ; put cursor in right column for normal battle menu (i.e. when it's not a Safari battle) - Coorda 9, 14 ; clear upper cursor position in left column - Coorda 9, 16 ; clear lower cursor position in left column + ldcoord_a 9, 14 ; clear upper cursor position in left column + ldcoord_a 9, 16 ; clear lower cursor position in left column ld b, $f ; top menu item X jr .rightColumn_WaitForInput .safariRightColumn - Coorda 1, 14 ; clear upper cursor position in left column - Coorda 1, 16 ; clear lower cursor position in left column - coord hl, 7, 14 + ldcoord_a 1, 14 ; clear upper cursor position in left column + ldcoord_a 1, 16 ; clear lower cursor position in left column + hlcoord 7, 14 ld de, wNumSafariBalls lb bc, 1, 2 call PrintNumber @@ -2321,7 +2321,7 @@ PartyMenuOrRockOrRun: call GBPalNormal jp DisplayBattleMenu .partyMonDeselected - coord hl, 11, 11 + hlcoord 11, 11 ld bc, 6 * SCREEN_WIDTH + 9 ld a, " " call FillMemory @@ -2411,7 +2411,7 @@ PartyMenuOrRockOrRun: ; fall through to SwitchPlayerMon SwitchPlayerMon: - callab RetreatMon + callfar RetreatMon ld c, 50 call DelayFrames call AnimateRetreatingPlayerMon @@ -2464,18 +2464,18 @@ MoveSelectionMenu: ld de, wMoves ld bc, NUM_MOVES call CopyData - callab FormatMovesString + callfar FormatMovesString ret .writemoves ld de, wMovesString - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] set 2, a - ld [hFlagsFFF6], a + ldh [hFlagsFFF6], a call PlaceString - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] res 2, a - ld [hFlagsFFF6], a + ldh [hFlagsFFF6], a ret .regularmenu @@ -2483,18 +2483,18 @@ MoveSelectionMenu: ret z ld hl, wBattleMonMoves call .loadmoves - coord hl, 4, 12 + hlcoord 4, 12 ld b, 4 ld c, 14 di ; out of pure coincidence, it is possible for vblank to occur between the di and ei ; so it is necessary to put the di ei block to not cause tearing call TextBoxBorder - coord hl, 4, 12 + hlcoord 4, 12 ld [hl], $7a - coord hl, 10, 12 + hlcoord 10, 12 ld [hl], $7e ei - coord hl, 6, 13 + hlcoord 6, 13 call .writemoves ld b, $5 ld a, $c @@ -2502,11 +2502,11 @@ MoveSelectionMenu: .mimicmenu ld hl, wEnemyMonMoves call .loadmoves - coord hl, 0, 7 + hlcoord 0, 7 ld b, 4 ld c, 14 call TextBoxBorder - coord hl, 2, 8 + hlcoord 2, 8 call .writemoves ld b, $1 ld a, $7 @@ -2517,11 +2517,11 @@ MoveSelectionMenu: ld bc, wPartyMon2 - wPartyMon1 call AddNTimes call .loadmoves - coord hl, 4, 7 + hlcoord 4, 7 ld b, 4 ld c, 14 call TextBoxBorder - coord hl, 6, 8 + hlcoord 6, 8 call .writemoves ld b, $5 ld a, $7 @@ -2577,7 +2577,7 @@ SelectMenuItem: jr z, .battleselect dec a jr nz, .select - coord hl, 1, 14 + hlcoord 1, 14 ld de, WhichTechniqueString call PlaceString jr .select @@ -2589,7 +2589,7 @@ SelectMenuItem: ld a, [wMenuItemToSwap] and a jr z, .select - coord hl, 5, 13 + hlcoord 5, 13 dec a ld bc, SCREEN_WIDTH call AddNTimes @@ -2825,8 +2825,8 @@ SwapMovesInMenu: PrintMenuItem: xor a - ld [hAutoBGTransferEnabled], a - coord hl, 0, 8 + ldh [hAutoBGTransferEnabled], a + hlcoord 0, 8 ld b, 3 ld c, 9 call TextBoxBorder @@ -2839,7 +2839,7 @@ PrintMenuItem: ld a, [wCurrentMenuItem] cp b jr nz, .notDisabled - coord hl, 1, 10 + hlcoord 1, 10 ld de, DisabledText call PlaceString jr .moveDisabled @@ -2847,7 +2847,7 @@ PrintMenuItem: ld hl, wCurrentMenuItem dec [hl] xor a - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ld hl, wBattleMonMoves ld a, [wCurrentMenuItem] ld c, a @@ -2860,7 +2860,7 @@ PrintMenuItem: ld [wWhichPokemon], a ld a, BATTLE_MON_DATA ld [wMonDataLocation], a - callab GetMaxPP + callfar GetMaxPP ld hl, wCurrentMenuItem ld c, [hl] inc [hl] @@ -2871,27 +2871,27 @@ PrintMenuItem: and $3f ld [wcd6d], a ; print TYPE/<type> and <curPP>/<maxPP> - coord hl, 1, 9 + hlcoord 1, 9 ld de, TypeText call PlaceString - coord hl, 7, 11 + hlcoord 7, 11 ld [hl], "/" - coord hl, 5, 9 + hlcoord 5, 9 ld [hl], "/" - coord hl, 5, 11 + hlcoord 5, 11 ld de, wcd6d lb bc, 1, 2 call PrintNumber - coord hl, 8, 11 + hlcoord 8, 11 ld de, wMaxPP lb bc, 1, 2 call PrintNumber call GetCurrentMove - coord hl, 2, 10 + hlcoord 2, 10 predef PrintMoveType .moveDisabled ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a jp Delay3 DisabledText: @@ -2955,7 +2955,7 @@ SelectEnemyMove: ld a, [wIsInBattle] dec a jr z, .chooseRandomMove ; wild encounter - callab AIEnemyTrainerChooseMoves + callfar AIEnemyTrainerChooseMoves .chooseRandomMove push hl call BattleRandom @@ -3020,7 +3020,7 @@ LinkBattleExchangeData: ld a, b .doExchange ld [wSerialExchangeNybbleSendData], a - callab PrintWaitingText + callfar PrintWaitingText .syncLoop1 call Serial_ExchangeNybble call DelayFrame @@ -3043,7 +3043,7 @@ LinkBattleExchangeData: ExecutePlayerMove: xor a - ld [hWhoseTurn], a ; set player's turn + ldh [hWhoseTurn], a ; set player's turn ld a, [wPlayerSelectedMove] inc a jp z, ExecutePlayerMoveDone ; for selected move = FF, skip most of player's turn @@ -3196,7 +3196,7 @@ MirrorMoveCheck: .moveDidNotMiss call ApplyAttackToEnemyPokemon call PrintCriticalOHKOText - callab DisplayEffectiveness + callfar DisplayEffectiveness ld a, 1 ld [wMoveDidntMiss], a .notDone @@ -3252,17 +3252,17 @@ PrintGhostText: ; print the ghost battle messages call IsGhostBattle ret nz - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .Ghost - ld a, [wBattleMonStatus] ; player’s turn + ld a, [wBattleMonStatus] ; player's turn and SLP | (1 << FRZ) ret nz ld hl, ScaredText call PrintText xor a ret -.Ghost ; ghost’s turn +.Ghost ; ghost's turn ld hl, GetOutText call PrintText xor a @@ -3619,7 +3619,7 @@ CantMoveText: PrintMoveIsDisabledText: ld hl, wPlayerSelectedMove ld de, wPlayerBattleStatus1 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .removeChargingUp inc hl @@ -3675,11 +3675,11 @@ HandleSelfConfusionDamage: xor a ld [wAnimationType], a inc a - ld [hWhoseTurn], a + ldh [hWhoseTurn], a call PlayMoveAnimation call DrawPlayerHUDAndHPBar xor a - ld [hWhoseTurn], a + ldh [hWhoseTurn], a jp ApplyDamageToPlayerPokemon PrintMonName1Text: @@ -3694,7 +3694,7 @@ PrintMonName1Text: MonName1Text: text_far _MonName1Text text_asm - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveNum] ld hl, wPlayerUsedMove @@ -3818,7 +3818,7 @@ INCLUDE "data/moves/grammar.asm" PrintMoveFailureText: ld de, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playersTurn ld de, wEnemyMoveEffect @@ -3866,7 +3866,7 @@ PrintMoveFailureText: call PrintText ld b, $4 predef PredefShakeScreenHorizontally - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .enemyTurn jp ApplyDamageToPlayerPokemon @@ -4160,9 +4160,9 @@ GetDamageVarsForPlayerAttack: ; in the case of a critical hit, reset the player's attack and the enemy's defense to their base values ld c, 3 ; defense stat call GetEnemyMonStat - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld b, a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld c, a push bc ld hl, wPartyMon1Attack @@ -4182,8 +4182,8 @@ GetDamageVarsForPlayerAttack: ; if the enemy has used Light Screen, double the enemy's special sla c rl b -; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if -; a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen +; reflect and light screen boosts do not cap the stat at MAX_STAT_VALUE, so weird things will happen during stats scaling +; if a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen .specialAttackCritCheck ld hl, wBattleMonSpecial ld a, [wCriticalHitOrOHKO] @@ -4192,9 +4192,9 @@ GetDamageVarsForPlayerAttack: ; in the case of a critical hit, reset the player's and enemy's specials to their base values ld c, 5 ; special stat call GetEnemyMonStat - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld b, a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld c, a push bc ld hl, wPartyMon1Special @@ -4295,8 +4295,8 @@ GetDamageVarsForEnemyAttack: ; if the player has used Light Screen, double the player's special sla c rl b -; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if -; a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen +; reflect and light screen boosts do not cap the stat at MAX_STAT_VALUE, so weird things will happen during stats scaling +; if a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen .specialAttackCritCheck ld hl, wEnemyMonSpecial ld a, [wCriticalHitOrOHKO] @@ -4371,9 +4371,9 @@ GetEnemyMonStat: ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hl] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a pop bc pop de ret @@ -4404,7 +4404,7 @@ CalculateDamage: ; d: base power ; e: level - ld a, [hWhoseTurn] ; whose turn? + ldh a, [hWhoseTurn] ; whose turn? and a ld a, [wPlayerMoveEffect] jr z, .effect @@ -4489,65 +4489,65 @@ CalculateDamage: ; Capped at MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE: 999 - 2 = 997. ld hl, wDamage ld b, [hl] - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] add b - ld [hQuotient + 3], a + ldh [hQuotient + 3], a jr nc, .dont_cap_1 - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] inc a - ld [hQuotient + 2], a + ldh [hQuotient + 2], a and a jr z, .cap .dont_cap_1 - ld a, [hQuotient] + ldh a, [hQuotient] ld b, a - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] or a jr nz, .cap - ld a, [hQuotient + 2] - cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 + ldh a, [hQuotient + 2] + cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) jr c, .dont_cap_2 - cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 + 1 + cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + 1 jr nc, .cap - ld a, [hQuotient + 3] - cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) % $100 + ldh a, [hQuotient + 3] + cp LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) jr nc, .cap .dont_cap_2 inc hl - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld b, [hl] add b ld [hld], a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld b, [hl] adc b ld [hl], a jr c, .cap ld a, [hl] - cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 + cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) jr c, .dont_cap_3 - cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 + 1 + cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + 1 jr nc, .cap inc hl ld a, [hld] - cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) % $100 + cp LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) jr c, .dont_cap_3 .cap - ld a, (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) / $100 + ld a, HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) ld [hli], a - ld a, (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) % $100 + ld a, LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) ld [hld], a .dont_cap_3 @@ -4579,7 +4579,7 @@ INCLUDE "data/battle/unused_critical_hit_moves.asm" CriticalHitTest: xor a ld [wCriticalHitOrOHKO], a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wEnemyMonSpecies] jr nz, .handleEnemy @@ -4590,7 +4590,7 @@ CriticalHitTest: ld a, [wMonHBaseSpeed] ld b, a srl b ; (effective (base speed/2)) - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wPlayerMovePower ld de, wPlayerBattleStatus2 @@ -4652,7 +4652,7 @@ HandleCounterMove: ; the outcome may be affected by the player's actions in the move selection menu prior to switching the Pokemon. ; This might also lead to desync glitches in link battles. - ld a, [hWhoseTurn] ; whose turn + ldh a, [hWhoseTurn] ; whose turn and a ; player's turn ld hl, wEnemySelectedMove @@ -4822,7 +4822,7 @@ ApplyDamageToEnemyPokemon: ld [wHPBarNewHP+1], a ld a, [hl] ld [wHPBarNewHP], a - coord hl, 2, 2 + hlcoord 2, 2 xor a ld [wHPBarType], a predef UpdateHPBar2 ; animate the HP bar shortening @@ -4940,7 +4940,7 @@ ApplyDamageToPlayerPokemon: ld [wHPBarMaxHP+1], a ld a, [hl] ld [wHPBarMaxHP], a - coord hl, 10, 9 + hlcoord 10, 9 ld a, $01 ld [wHPBarType], a predef UpdateHPBar2 ; animate the HP bar shortening @@ -4960,7 +4960,7 @@ AttackSubstitute: ; values for player turn ld de, wEnemySubstituteHP ld bc, wEnemyBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .applyDamageToSubstitute ; values for enemy turn @@ -4985,14 +4985,14 @@ AttackSubstitute: ld hl, SubstituteBrokeText call PrintText ; flip whose turn it is for the next function call - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor $01 - ld [hWhoseTurn], a - callab HideSubstituteShowMonAnim ; animate the substitute breaking + ldh [hWhoseTurn], a + callfar HideSubstituteShowMonAnim ; animate the substitute breaking ; flip the turn back to the way it was - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor $01 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ld hl, wPlayerMoveEffect ; value for player's turn and a jr z, .nullifyEffect @@ -5016,7 +5016,7 @@ HandleBuildingRage: ld hl, wEnemyBattleStatus2 ld de, wEnemyMonStatMods ld bc, wEnemyMoveNum - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .next ; values for the enemy turn @@ -5029,9 +5029,9 @@ HandleBuildingRage: ld a, [de] cp $0d ; maximum stat modifier value ret z ; return if attack modifier is already maxed - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor $01 ; flip turn for the stat modifier raising function - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ; temporarily change the target pokemon's move to $00 and the effect to the one ; that causes the attack modifier to go up one stage ld h, b @@ -5048,9 +5048,9 @@ HandleBuildingRage: ldd [hl], a ; null move effect ld a, RAGE ld [hl], a ; restore the target pokemon's move number to Rage - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor $01 ; flip turn back to the way it was - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ret BuildingRageText: @@ -5066,7 +5066,7 @@ MirrorMoveCopyMove: ; wPlayerUsedMove is also set to 0 whenever the player is fast asleep or frozen solid. ; wEnemyUsedMove is also set to 0 whenever the enemy is fast asleep or frozen solid. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ; values for player turn ld a, [wEnemyUsedMove] @@ -5119,7 +5119,7 @@ MetronomePickMove: ; values for player turn ld de, wPlayerMoveNum ld hl, wPlayerSelectedMove - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .pickMoveLoop ; values for enemy turn @@ -5141,7 +5141,7 @@ MetronomePickMove: ; it's used to prevent moves that run another move within the same turn ; (like Mirror Move and Metronome) from losing 2 PP IncrementMovePP: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ; values for player turn ld hl, wBattleMonPP @@ -5160,7 +5160,7 @@ IncrementMovePP: ld h, d ld l, e add hl, bc - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMonNumber] ; value for player turn jr z, .updatePP @@ -5184,7 +5184,7 @@ AdjustDamageForMoveType: ld e, [hl] ; e = type 2 of defender ld a, [wPlayerMoveType] ld [wMoveType], a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .next ; values for enemy turn @@ -5248,25 +5248,25 @@ AdjustDamageForMoveType: and $80 ld b, a ld a, [hl] ; a = damage multiplier - ld [hMultiplier], a + ldh [hMultiplier], a add b ld [wDamageMultipliers], a xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld hl, wDamage ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hld] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a call Multiply ld a, 10 - ld [hDivisor], a + ldh [hDivisor], a ld b, $04 call Divide - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld [hli], a ld b, a - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld [hl], a or b ; is damage 0? jr nz, .skipTypeImmunity @@ -5331,7 +5331,7 @@ MoveHitTest: ld hl, wEnemyBattleStatus1 ld de, wPlayerMoveEffect ld bc, wEnemyMonStatus - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .dreamEaterCheck ; enemy's turn @@ -5360,7 +5360,7 @@ MoveHitTest: .checkForDigOrFlyStatus bit INVULNERABLE, [hl] jp nz, .moveMissed - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .enemyTurn .playerTurn @@ -5414,7 +5414,7 @@ MoveHitTest: call CalcHitChance ; scale the move accuracy according to attacker's accuracy and target's evasion ld a, [wPlayerMoveAccuracy] ld b, a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .doAccuracyCheck ld a, [wEnemyMoveAccuracy] @@ -5433,7 +5433,7 @@ MoveHitTest: ld [hl], a inc a ld [wMoveMissed], a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn2 .enemyTurn2 @@ -5448,7 +5448,7 @@ MoveHitTest: ; values for player turn CalcHitChance: ld hl, wPlayerMoveAccuracy - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMonAccuracyMod] ld b, a @@ -5468,10 +5468,10 @@ CalcHitChance: ; decreases the hit chance instead of increasing the hit chance) ; zero the high bytes of the multiplicand xor a - ld [hMultiplicand], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand], a + ldh [hMultiplicand + 1], a ld a, [hl] - ld [hMultiplicand + 2], a ; set multiplicand to move accuracy + ldh [hMultiplicand + 2], a ; set multiplicand to move accuracy push hl ld d, $02 ; loop has two iterations ; loop to do the calculations, the first iteration multiplies by the accuracy ratio and @@ -5486,29 +5486,29 @@ CalcHitChance: add hl, bc ; hl = address of stat modifier ratio pop bc ld a, [hli] - ld [hMultiplier], a ; set multiplier to the numerator of the ratio + ldh [hMultiplier], a ; set multiplier to the numerator of the ratio call Multiply ld a, [hl] - ld [hDivisor], a ; set divisor to the the denominator of the ratio + ldh [hDivisor], a ; set divisor to the the denominator of the ratio ; (the dividend is the product of the previous multiplication) ld b, $04 ; number of bytes in the dividend call Divide - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld b, a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] or b jp nz, .nextCalculation ; make sure the result is always at least one - ld [hQuotient + 2], a + ldh [hQuotient + 2], a ld a, $01 - ld [hQuotient + 3], a + ldh [hQuotient + 3], a .nextCalculation ld b, c dec d jr nz, .loop - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] and a ; is the calculated hit chance over 0xFF? - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] jr z, .storeAccuracy ; if calculated hit chance over 0xFF ld a, $ff ; set the hit chance to 0xFF @@ -5528,29 +5528,29 @@ RandomizeDamage: ret c ; return if damage is equal to 0 or 1 .DamageGreaterThanOne xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a dec hl ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hl] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ; loop until a random number greater than or equal to 217 is generated .loop call BattleRandom rrca cp 217 jr c, .loop - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; multiply damage by the random number, which is in the range [217, 255] ld a, 255 - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide ; divide the result by 255 ; store the modified damage - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld hl, wDamage ld [hli], a - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld [hl], a ret @@ -5726,7 +5726,7 @@ EnemyCheckIfMirrorMoveEffect: .moveDidNotMiss call ApplyAttackToPlayerPokemon call PrintCriticalOHKOText - callab DisplayEffectiveness + callfar DisplayEffectiveness ld a, 1 ld [wMoveDidntMiss], a .handleExplosionMiss @@ -5906,11 +5906,11 @@ CheckEnemyStatusConditions: ld [hl], a xor a ld [wAnimationType], a - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ld a, POUND call PlayMoveAnimation ld a, $1 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a call ApplyDamageToEnemyPokemon jr .monHurtItselfOrFullyParalysed .checkIfTriedToUseDisabledMove @@ -6057,7 +6057,7 @@ CheckEnemyStatusConditions: ret GetCurrentMove: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jp z, .player ld de, wEnemyMoveNum @@ -6254,25 +6254,25 @@ DoBattleTransitionAndInitBattleVariables: ; link battle xor a ld [wMenuJoypadPollCount], a - callab DisplayLinkBattleVersusTextBox + callfar DisplayLinkBattleVersusTextBox ld a, $1 ld [wUpdateSpritesEnabled], a call ClearScreen .next call DelayFrame predef BattleTransition - callab LoadHudAndHpBarAndStatusTilePatterns + callfar LoadHudAndHpBarAndStatusTilePatterns ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, $ff ld [wUpdateSpritesEnabled], a call ClearSprites call ClearScreen xor a - ld [hAutoBGTransferEnabled], a - ld [hWY], a - ld [rWY], a - ld [hTilesetType], a + ldh [hAutoBGTransferEnabled], a + ldh [hWY], a + ldh [rWY], a + ldh [hTilesetType], a ld hl, wPlayerStatsToDouble ld [hli], a ld [hli], a @@ -6309,7 +6309,7 @@ LoadPlayerBackPic: predef ScaleSpriteByTwo ld hl, wOAMBuffer xor a - ld [hOAMTile], a ; initial tile number + ldh [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 @@ -6323,16 +6323,16 @@ LoadPlayerBackPic: add d ; increase Y by height of tile ld d, a inc hl - ld a, [hOAMTile] + ldh a, [hOAMTile] ld [hli], a ; OAM tile number inc a ; increment tile number - ld [hOAMTile], a + ldh [hOAMTile], a inc hl dec c jr nz, .innerLoop - ld a, [hOAMTile] + ldh a, [hOAMTile] add $4 ; increase tile number by 4 - ld [hOAMTile], a + ldh [hOAMTile], a ld a, $8 ; width of tile add e ; increase X by width of tile ld e, a @@ -6346,24 +6346,24 @@ LoadPlayerBackPic: ld [MBC1SRamBank], a ld hl, vSprites ld de, sSpriteBuffer1 - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld b, a ld c, 7 * 7 call CopyVideoData xor a ld [MBC1SRamEnable], a ld a, $31 - ld [hStartTileID], a - coord hl, 1, 5 + ldh [hStartTileID], a + hlcoord 1, 5 predef_jump CopyUncompressedPicToTilemap ; does nothing since no stats are ever selected (barring glitches) DoubleOrHalveSelectedStats: - callab DoubleSelectedStats - jpab HalveSelectedStats + callfar DoubleSelectedStats + jpfar HalveSelectedStats ScrollTrainerPicAfterBattle: - jpab _ScrollTrainerPicAfterBattle + jpfar _ScrollTrainerPicAfterBattle ApplyBurnAndParalysisPenaltiesToPlayer: ld a, $1 @@ -6373,12 +6373,12 @@ ApplyBurnAndParalysisPenaltiesToEnemy: xor a ApplyBurnAndParalysisPenalties: - ld [hWhoseTurn], a + ldh [hWhoseTurn], a call QuarterSpeedDueToParalysis jp HalveAttackDueToBurn QuarterSpeedDueToParalysis: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn .enemyTurn ; quarter the player's speed @@ -6421,7 +6421,7 @@ QuarterSpeedDueToParalysis: ret HalveAttackDueToBurn: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn .enemyTurn ; halve the player's attack @@ -6511,35 +6511,35 @@ CalculateModifiedStat: ld b, 0 add hl, bc xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, [de] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a inc de ld a, [de] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [hli] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, [hl] - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide pop hl - ld a, [hDividend + 3] - sub 999 % $100 - ld a, [hDividend + 2] - sbc 999 / $100 + ldh a, [hDividend + 3] + sub LOW(MAX_STAT_VALUE) + ldh a, [hDividend + 2] + sbc HIGH(MAX_STAT_VALUE) jp c, .storeNewStatValue -; cap the stat at 999 - ld a, 999 / $100 - ld [hDividend + 2], a - ld a, 999 % $100 - ld [hDividend + 3], a +; cap the stat at MAX_STAT_VALUE (999) + ld a, HIGH(MAX_STAT_VALUE) + ldh [hDividend + 2], a + ld a, LOW(MAX_STAT_VALUE) + ldh [hDividend + 3], a .storeNewStatValue - ld a, [hDividend + 2] + ldh a, [hDividend + 2] ld [hli], a ld b, a - ld a, [hDividend + 3] + ldh a, [hDividend + 3] ld [hl], a or b jr nz, .done @@ -6573,7 +6573,7 @@ ApplyBadgeStatBoosts: ret ; multiply stat at hl by 1.125 -; cap stat at 999 +; cap stat at MAX_STAT_VALUE .applyBoostToStat ld a, [hli] ld d, a @@ -6591,13 +6591,13 @@ ApplyBadgeStatBoosts: adc d ld [hli], a ld a, [hld] - sub 999 % $100 + sub LOW(MAX_STAT_VALUE) ld a, [hl] - sbc 999 / $100 + sbc HIGH(MAX_STAT_VALUE) ret c - ld a, 999 / $100 + ld a, HIGH(MAX_STAT_VALUE) ld [hli], a - ld a, 999 % $100 + ld a, LOW(MAX_STAT_VALUE) ld [hld], a ret @@ -6605,27 +6605,27 @@ LoadHudAndHpBarAndStatusTilePatterns: call LoadHpBarAndStatusTilePatterns LoadHudTilePatterns: - ld a, [rLCDC] + ldh a, [rLCDC] add a ; is LCD disabled? jr c, .lcdEnabled .lcdDisabled ld hl, BattleHudTiles1 - ld de, vChars2 + $6d0 + ld de, vChars2 tile $6d ld bc, BattleHudTiles1End - BattleHudTiles1 ld a, BANK(BattleHudTiles1) call FarCopyDataDouble ld hl, BattleHudTiles2 - ld de, vChars2 + $730 + ld de, vChars2 tile $73 ld bc, BattleHudTiles3End - BattleHudTiles2 ld a, BANK(BattleHudTiles2) jp FarCopyDataDouble .lcdEnabled ld de, BattleHudTiles1 - ld hl, vChars2 + $6d0 + ld hl, vChars2 tile $6d lb bc, BANK(BattleHudTiles1), (BattleHudTiles1End - BattleHudTiles1) / $8 call CopyVideoDataDouble ld de, BattleHudTiles2 - ld hl, vChars2 + $730 + ld hl, vChars2 tile $73 lb bc, BANK(BattleHudTiles2), (BattleHudTiles3End - BattleHudTiles2) / $8 jp CopyVideoDataDouble @@ -6690,7 +6690,7 @@ BattleRandom: HandleExplodingAnimation: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wEnemyMonType1 ld de, wEnemyBattleStatus1 @@ -6740,14 +6740,14 @@ DetermineWildOpponent: ld a, [wd732] bit 1, a jr z, .asm_3ef2f - ld a, [hJoyHeld] + ldh a, [hJoyHeld] bit 1, a ; B button pressed? ret nz .asm_3ef2f ld a, [wNumberOfNoRandomBattleStepsLeft] and a ret nz - callab TryDoWildEncounter + callfar TryDoWildEncounter ret nz InitBattleCommon: ld a, [wMapPalOffset] @@ -6756,21 +6756,21 @@ InitBattleCommon: ld a, [hl] push af res 1, [hl] - callab InitBattleVariables + callfar InitBattleVariables ld a, [wEnemyMonSpecies2] sub OPP_ID_OFFSET jp c, InitWildBattle ld [wTrainerClass], a call GetTrainerInformation - callab ReadTrainer + callfar ReadTrainer call DoBattleTransitionAndInitBattleVariables call _LoadTrainerPic xor a ld [wEnemyMonSpecies2], a - ld [hStartTileID], a + ldh [hStartTileID], a dec a ld [wAICount], a - coord hl, 12, 0 + hlcoord 12, 0 predef CopyUncompressedPicToTilemap ld a, $ff ld [wEnemyMonPartyPos], a @@ -6823,8 +6823,8 @@ InitWildBattle: .spriteLoaded xor a ld [wTrainerClass], a - ld [hStartTileID], a - coord hl, 12, 0 + ldh [hStartTileID], a + hlcoord 12, 0 predef CopyUncompressedPicToTilemap ; common code that executes after init battle code specific to trainer or wild battles @@ -6833,23 +6833,23 @@ _InitBattleCommon: call RunPaletteCommand call SlidePlayerAndEnemySilhouettesOnScreen xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld hl, .emptyString call PrintText call SaveScreenTilesToBuffer1 call ClearScreen ld a, $98 - ld [hAutoBGTransferDest + 1], a + ldh [hAutoBGTransferDest + 1], a ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 ld a, $9c - ld [hAutoBGTransferDest + 1], a + ldh [hAutoBGTransferDest + 1], a call LoadScreenTilesFromBuffer1 - coord hl, 9, 7 + hlcoord 9, 7 lb bc, 5, 10 call ClearScreenArea - coord hl, 1, 0 + hlcoord 1, 0 lb bc, 4, 10 call ClearScreenArea call ClearSprites @@ -6857,13 +6857,13 @@ _InitBattleCommon: dec a ; is it a wild battle? call z, DrawEnemyHUDAndHPBar ; draw enemy HUD and HP bar if it's a wild battle call StartBattle - callab EndOfBattle + callfar EndOfBattle pop af ld [wLetterPrintingDelayFlags], a pop af ld [wMapPalOffset], a ld a, [wSavedTilesetType] - ld [hTilesetType], a + ldh [hTilesetType], a scf ret .emptyString @@ -6900,8 +6900,8 @@ AnimateSendingOutMon: ld h, a ld a, [wPredefRegisters + 1] ld l, a - ld a, [hStartTileID] - ld [hBaseTileID], a + ldh a, [hStartTileID] + ldh [hBaseTileID], a ld b, $4c ld a, [wIsInBattle] and a @@ -6931,7 +6931,7 @@ AnimateSendingOutMon: ld bc, -(SCREEN_WIDTH * 6 + 3) .next add hl, bc - ld a, [hBaseTileID] + ldh a, [hBaseTileID] add $31 jr CopyUncompressedPicToHL @@ -6940,7 +6940,7 @@ CopyUncompressedPicToTilemap: ld h, a ld a, [wPredefRegisters + 1] ld l, a - ld a, [hStartTileID] + ldh a, [hStartTileID] CopyUncompressedPicToHL:: lb bc, 7, 7 ld de, SCREEN_WIDTH @@ -6993,7 +6993,7 @@ LoadMonBackPic: ; been loaded with GetMonHeader. ld a, [wBattleMonSpecies2] ld [wcf91], a - coord hl, 1, 5 + hlcoord 1, 5 ld b, 7 ld c, 8 call ClearScreenArea @@ -7005,6 +7005,6 @@ LoadMonBackPic: ld hl, vSprites ld de, vBackPic ld c, (2*SPRITEBUFFERSIZE)/16 ; count of 16-byte chunks to be copied - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld b, a jp CopyVideoData diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm index c0a91949..097a0fcc 100644 --- a/engine/battle/draw_hud_pokeball_gfx.asm +++ b/engine/battle/draw_hud_pokeball_gfx.asm @@ -12,7 +12,7 @@ DrawEnemyPokeballs: LoadPartyPokeballGfx: ld de, PokeballTileGraphics - ld hl, vSprites + $310 + ld hl, vSprites tile $31 lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10 jp CopyVideoData @@ -121,7 +121,7 @@ PlacePlayerHUDTiles: ld de, wHUDGraphicsTiles ld bc, $3 call CopyData - coord hl, 18, 10 + hlcoord 18, 10 ld de, -1 jr PlaceHUDTiles @@ -136,7 +136,7 @@ PlaceEnemyHUDTiles: ld de, wHUDGraphicsTiles ld bc, $3 call CopyData - coord hl, 1, 2 + hlcoord 1, 2 ld de, $1 jr PlaceHUDTiles diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm index 22fadb42..441d6c1c 100644 --- a/engine/battle/effects.asm +++ b/engine/battle/effects.asm @@ -4,7 +4,7 @@ JumpMoveEffect: ret _JumpMoveEffect: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] jr z, .next1 @@ -26,7 +26,7 @@ INCLUDE "data/moves/effects_pointers.asm" SleepEffect: ld de, wEnemyMonStatus ld bc, wEnemyBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jp z, .sleepEffect ld de, wBattleMonStatus @@ -78,7 +78,7 @@ AlreadyAsleepText: PoisonEffect: ld hl, wEnemyMonStatus ld de, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .poisonEffect ld hl, wBattleMonStatus @@ -121,7 +121,7 @@ PoisonEffect: set 3, [hl] ; mon is now poisoned push de dec de - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld b, ANIM_C7 ld hl, wPlayerBattleStatus3 @@ -170,12 +170,12 @@ BadlyPoisonedText: text_end DrainHPEffect: - jpab DrainHPEffect_ + jpfar DrainHPEffect_ ExplodeEffect: ld hl, wBattleMonHP ld de, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .faintUser ld hl, wEnemyMonHP @@ -196,7 +196,7 @@ FreezeBurnParalyzeEffect: ld [wAnimationType], a call CheckTargetSubstitute ; test bit 4 of d063/d068 flags [target has substitute flag] ret nz ; return if they have a substitute, can't effect them - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jp nz, opponentAttacker ld a, [wEnemyMonStatus] @@ -308,7 +308,7 @@ CheckDefrost: ; any fire-type move that has a chance inflict burn (all but Fire Spin) will defrost a frozen target and 1 << FRZ ; are they frozen? ret z ; return if so - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .opponent ;player [attacker] @@ -346,7 +346,7 @@ FireDefrostedText: StatModifierUpEffect: ld hl, wPlayerMonStatMods ld de, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .statModifierUpEffect ld hl, wEnemyMonStatMods @@ -382,7 +382,7 @@ StatModifierUpEffect: push hl ld hl, wBattleMonAttack + 1 ld de, wPlayerMonUnmodifiedAttack - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .pointToStats ld hl, wEnemyMonAttack + 1 @@ -399,11 +399,12 @@ StatModifierUpEffect: inc d ; de = unmodified (original) stat .checkIf999 pop bc + ; check if stat is already 999 ld a, [hld] - sub 999 % $100 ; check if stat is already 999 + sub LOW(MAX_STAT_VALUE) jr nz, .recalculateStat ld a, [hl] - sbc 999 / $100 + sbc HIGH(MAX_STAT_VALUE) jp z, RestoreOriginalStatModifier .recalculateStat ; recalculate affected stat ; paralysis and burn penalties, as well as badge boosts are ignored @@ -417,35 +418,35 @@ StatModifierUpEffect: add hl, bc pop bc xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, [de] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a inc de ld a, [de] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [hli] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, [hl] - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide pop hl -; cap at 999 - ld a, [hProduct + 3] - sub 999 % $100 - ld a, [hProduct + 2] - sbc 999 / $100 +; cap at MAX_STAT_VALUE (999) + ldh a, [hProduct + 3] + sub LOW(MAX_STAT_VALUE) + ldh a, [hProduct + 2] + sbc HIGH(MAX_STAT_VALUE) jp c, UpdateStat - ld a, 999 / $100 - ld [hMultiplicand + 1], a - ld a, 999 % $100 - ld [hMultiplicand + 2], a + ld a, HIGH(MAX_STAT_VALUE) + ldh [hMultiplicand + 1], a + ld a, LOW(MAX_STAT_VALUE) + ldh [hMultiplicand + 2], a UpdateStat: - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld [hli], a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld [hl], a pop hl UpdateStatDone: @@ -455,7 +456,7 @@ UpdateStatDone: ld hl, wPlayerBattleStatus2 ld de, wPlayerMoveNum ld bc, wPlayerMonMinimized - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .asm_3f4e6 ld hl, wEnemyBattleStatus2 @@ -488,7 +489,7 @@ UpdateStatDone: pop af call nz, Bankswitch .applyBadgeBoostsAndStatusPenalties - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a call z, ApplyBadgeStatBoosts ; whenever the player uses a stat-up move, badge boosts get reapplied again to every stat, ; even to those not affected by the stat-up move (will be boosted further) @@ -511,7 +512,7 @@ MonsStatsRoseText: text_far _MonsStatsRoseText text_asm ld hl, GreatlyRoseText - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] jr z, .playerTurn @@ -534,7 +535,7 @@ StatModifierDownEffect: ld hl, wEnemyMonStatMods ld de, wPlayerMoveEffect ld bc, wEnemyBattleStatus1 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .statModifierDownEffect ld hl, wPlayerMonStatMods @@ -601,7 +602,7 @@ StatModifierDownEffect: push de ld hl, wEnemyMonAttack + 1 ld de, wEnemyMonUnmodifiedAttack - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .pointToStat ld hl, wBattleMonAttack + 1 @@ -637,33 +638,33 @@ StatModifierDownEffect: add hl, bc pop bc xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, [de] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a inc de ld a, [de] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [hli] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, [hl] - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide pop hl - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld b, a - ld a, [hProduct + 2] + ldh a, [hProduct + 2] or b jp nz, UpdateLoweredStat - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, $1 - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a UpdateLoweredStat: - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld [hli], a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld [hl], a pop de pop hl @@ -678,7 +679,7 @@ UpdateLoweredStatDone: jr nc, .ApplyBadgeBoostsAndStatusPenalties call PlayCurrentMoveAnimation2 .ApplyBadgeBoostsAndStatusPenalties - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat, ; even to those not affected by the stat-up move (will be boosted further) @@ -713,7 +714,7 @@ MonsStatsFellText: text_far _MonsStatsFellText text_asm ld hl, FellText - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] jr z, .playerTurn @@ -759,7 +760,7 @@ BideEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerBideAccumulatedDamage ld bc, wPlayerNumAttacksLeft - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .bideEffect ld hl, wEnemyBattleStatus1 @@ -778,14 +779,14 @@ BideEffect: inc a inc a ld [bc], a ; set Bide counter to 2 or 3 at random - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] add XSTATITEM_ANIM jp PlayBattleAnimation2 ThrashPetalDanceEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerNumAttacksLeft - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .thrashPetalDanceEffect ld hl, wEnemyBattleStatus1 @@ -797,12 +798,12 @@ ThrashPetalDanceEffect: inc a inc a ld [de], a ; set thrash/petal dance counter to 2 or 3 at random - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] add ANIM_B0 jp PlayBattleAnimation2 SwitchAndTeleportEffect: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .handleEnemy ld a, [wIsInBattle] @@ -920,7 +921,7 @@ TwoToFiveAttacksEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerNumAttacksLeft ld bc, wPlayerNumHits - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .twoToFiveAttacksEffect ld hl, wEnemyBattleStatus1 @@ -931,7 +932,7 @@ TwoToFiveAttacksEffect: ret nz set ATTACKING_MULTIPLE_TIMES, [hl] ; mon is now attacking multiple times ld hl, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .setNumberOfHits ld hl, wEnemyMoveEffect @@ -967,7 +968,7 @@ FlinchSideEffect: ret nz ld hl, wEnemyBattleStatus1 ld de, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .flinchSideEffect ld hl, wPlayerBattleStatus1 @@ -987,12 +988,12 @@ FlinchSideEffect: ret OneHitKOEffect: - jpab OneHitKOEffect_ + jpfar OneHitKOEffect_ ChargeEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld b, XSTATITEM_ANIM jr z, .chargeEffect @@ -1074,7 +1075,7 @@ DugAHoleText: TrappingEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerNumAttacksLeft - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .trappingEffect ld hl, wEnemyBattleStatus1 @@ -1097,13 +1098,13 @@ TrappingEffect: ret MistEffect: - jpab MistEffect_ + jpfar MistEffect_ FocusEnergyEffect: - jpab FocusEnergyEffect_ + jpfar FocusEnergyEffect_ RecoilEffect: - jpab RecoilEffect_ + jpfar RecoilEffect_ ConfusionSideEffect: call BattleRandom @@ -1120,7 +1121,7 @@ ConfusionEffect: jr nz, ConfusionEffectFailed ConfusionSideEffectSuccess: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wEnemyBattleStatus1 ld bc, wEnemyConfusedCounter @@ -1157,14 +1158,14 @@ ConfusionEffectFailed: jp ConditionalPrintButItFailed ParalyzeEffect: - jpab ParalyzeEffect_ + jpfar ParalyzeEffect_ SubstituteEffect: - jpab SubstituteEffect_ + jpfar SubstituteEffect_ HyperBeamEffect: ld hl, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .hyperBeamEffect ld hl, wEnemyBattleStatus2 @@ -1175,7 +1176,7 @@ HyperBeamEffect: ClearHyperBeam: push hl ld hl, wEnemyBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn ld hl, wPlayerBattleStatus2 @@ -1186,7 +1187,7 @@ ClearHyperBeam: RageEffect: ld hl, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .player ld hl, wEnemyBattleStatus2 @@ -1201,7 +1202,7 @@ MimicEffect: ld a, [wMoveMissed] and a jr nz, .mimicMissed - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wBattleMonMoves ld a, [wPlayerBattleStatus1] @@ -1226,7 +1227,7 @@ MimicEffect: and a jr z, .getRandomMove ld d, a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wBattleMonMoves ld a, [wPlayerMoveListIndex] @@ -1271,7 +1272,7 @@ MimicLearnedMoveText: text_end LeechSeedEffect: - jpab LeechSeedEffect_ + jpfar LeechSeedEffect_ SplashEffect: call PlayCurrentMoveAnimation @@ -1284,7 +1285,7 @@ DisableEffect: jr nz, .moveMissed ld de, wEnemyDisabledMove ld hl, wEnemyMonMoves - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .disableEffect ld de, wPlayerDisabledMove @@ -1307,7 +1308,7 @@ DisableEffect: jr z, .pickMoveToDisable ; loop until a non-00 move slot is found ld [wd11e], a ; store move number push hl - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wBattleMonPP jr nz, .enemyTurn @@ -1345,7 +1346,7 @@ DisableEffect: ld [de], a call PlayCurrentMoveAnimation2 ld hl, wPlayerDisabledMoveNumber - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .printDisableText inc hl ; wEnemyDisabledMoveNumber @@ -1365,22 +1366,22 @@ MoveWasDisabledText: text_end PayDayEffect: - jpab PayDayEffect_ + jpfar PayDayEffect_ ConversionEffect: - jpab ConversionEffect_ + jpfar ConversionEffect_ HazeEffect: - jpab HazeEffect_ + jpfar HazeEffect_ HealEffect: - jpab HealEffect_ + jpfar HealEffect_ TransformEffect: - jpab TransformEffect_ + jpfar TransformEffect_ ReflectLightScreenEffect: - jpab ReflectLightScreenEffect_ + jpfar ReflectLightScreenEffect_ NothingHappenedText: text_far _NothingHappenedText @@ -1430,7 +1431,7 @@ ParalyzedMayNotAttackText: CheckTargetSubstitute: push hl ld hl, wEnemyBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .next1 ld hl, wPlayerBattleStatus2 @@ -1442,7 +1443,7 @@ CheckTargetSubstitute: PlayCurrentMoveAnimation2: ; animation at MOVENUM will be played unless MOVENUM is 0 ; plays wAnimationType 3 or 6 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveNum] jr z, .notEnemyTurn @@ -1454,7 +1455,7 @@ PlayCurrentMoveAnimation2: PlayBattleAnimation2: ; play animation ID at a and animation type 6 or 3 ld [wAnimationID], a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, $6 jr z, .storeAnimationType @@ -1468,7 +1469,7 @@ PlayCurrentMoveAnimation: ; resets wAnimationType xor a ld [wAnimationType], a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveNum] jr z, .notEnemyTurn diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm index f490c34d..bd4a1901 100755 --- a/engine/battle/end_of_battle.asm +++ b/engine/battle/end_of_battle.asm @@ -10,7 +10,7 @@ EndOfBattle: ld a, [wEnemyMonStatus] ld [hl], a call ClearScreen - callab DisplayLinkBattleVersusTextBox + callfar DisplayLinkBattleVersusTextBox ld a, [wBattleResult] cp $1 ld de, YouWinText @@ -19,7 +19,7 @@ EndOfBattle: jr z, .placeWinOrLoseString ld de, DrawText .placeWinOrLoseString - coord hl, 6, 8 + hlcoord 6, 8 call PlaceString ld c, 200 call DelayFrames diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index 6bc0a019..0eab6e08 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -55,15 +55,15 @@ GainExperience: jr .gainStatExpLoop .statExpDone xor a - ld [hMultiplicand], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand], a + ldh [hMultiplicand + 1], a ld a, [wEnemyMonBaseExp] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [wEnemyMonLevel] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, 7 - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1) @@ -91,12 +91,12 @@ GainExperience: inc hl ; add the gained exp to the party mon's exp ld b, [hl] - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld [wExpAmountGained + 1], a add b ld [hld], a ld b, [hl] - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld [wExpAmountGained], a adc b ld [hl], a @@ -117,13 +117,13 @@ GainExperience: ld [wd0b5], a call GetMonHeader ld d, MAX_LEVEL - callab CalcExperience ; get max exp + callfar CalcExperience ; get max exp ; compare max exp with current exp - ld a, [hExperience] + ldh a, [hExperience] ld b, a - ld a, [hExperience + 1] + ldh a, [hExperience + 1] ld c, a - ld a, [hExperience + 2] + ldh a, [hExperience + 2] ld d, a pop hl ld a, [hld] @@ -155,7 +155,7 @@ GainExperience: ld bc, wPartyMon1Level - wPartyMon1Exp add hl, bc push hl - callba CalcLevelFromExperience + farcall CalcLevelFromExperience pop hl ld a, [hl] ; current level cp d @@ -233,11 +233,11 @@ GainExperience: .recalcStatChanges xor a ; battle mon ld [wCalculateWhoseStats], a - callab CalculateModifiedStats - callab ApplyBurnAndParalysisPenaltiesToPlayer - callab ApplyBadgeStatBoosts - callab DrawPlayerHUDAndHPBar - callab PrintEmptyString + callfar CalculateModifiedStats + callfar ApplyBurnAndParalysisPenaltiesToPlayer + callfar ApplyBadgeStatBoosts + callfar DrawPlayerHUDAndHPBar + callfar PrintEmptyString call SaveScreenTilesToBuffer1 .printGrewLevelText ld hl, GrewLevelText @@ -246,7 +246,7 @@ GainExperience: ld [wMonDataLocation], a call LoadMonData ld d, $1 - callab PrintStatsBox + callfar PrintStatsBox call WaitForTextScrollButtonPress call LoadScreenTilesFromBuffer1 xor a ; PLAYER_PARTY_DATA @@ -311,14 +311,14 @@ DivideExpDataByNumMonsGainingExp: ld c, wEnemyMonBaseExp + 1 - wEnemyMonBaseStats .divideLoop xor a - ld [hDividend], a + ldh [hDividend], a ld a, [hl] - ld [hDividend + 1], a + ldh [hDividend + 1], a ld a, [wd11e] - ld [hDivisor], a + ldh [hDivisor], a ld b, $2 call Divide ; divide value by number of mons gaining exp - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld [hli], a dec c jr nz, .divideLoop @@ -326,17 +326,17 @@ DivideExpDataByNumMonsGainingExp: ; multiplies exp by 1.5 BoostExp: - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld b, a - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld c, a srl b rr c add c - ld [hQuotient + 3], a - ld a, [hQuotient + 2] + ldh [hQuotient + 3], a + ldh a, [hQuotient + 2] adc b - ld [hQuotient + 2], a + ldh [hQuotient + 2], a ret GainedText: diff --git a/engine/battle/ghost_marowak_anim.asm b/engine/battle/ghost_marowak_anim.asm index 28f536ca..7405c40b 100644 --- a/engine/battle/ghost_marowak_anim.asm +++ b/engine/battle/ghost_marowak_anim.asm @@ -1,21 +1,21 @@ MarowakAnim: ; animate the ghost being unveiled as a Marowak ld a, $e4 - ld [rOBP1], a + ldh [rOBP1], a 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 - coord hl, 12, 0 + hlcoord 12, 0 lb bc, 7, 7 call ClearScreenArea call Delay3 xor a - ld [hAutoBGTransferEnabled], a ; disable BG transfer so we don't see the Marowak too soon + ldh [hAutoBGTransferEnabled], a ; disable BG transfer so we don't see the Marowak too soon ; replace ghost pic with Marowak in BG ld a, MAROWAK ld [wChangeMonPicEnemyTurnSpecies], a ld a, $1 - ld [hWhoseTurn], a - callab ChangeMonPic + ldh [hWhoseTurn], a + callfar ChangeMonPic ; alternate between black and light grey 8 times. ; this makes the ghost's body appear to flash ld d, $80 @@ -23,10 +23,10 @@ MarowakAnim: .fadeOutGhostLoop ld c, 10 call DelayFrames - ld a, [rOBP1] + ldh a, [rOBP1] sla a sla a - ld [rOBP1], a + ldh [rOBP1], a jr nz, .fadeOutGhostLoop call ClearSprites call CopyMonPicFromBGToSpriteVRAM ; copy Marowak pic from BG to sprite VRAM @@ -34,17 +34,17 @@ MarowakAnim: .fadeInMarowakLoop ld c, 10 call DelayFrames - ld a, [rOBP1] + ldh a, [rOBP1] srl b rra srl b rra - ld [rOBP1], a + ldh [rOBP1], a ld a, b and a jr nz, .fadeInMarowakLoop ld a, $1 - ld [hAutoBGTransferEnabled], a ; enable BG transfer so the BG Marowak pic will be visible after the sprite one is cleared + ldh [hAutoBGTransferEnabled], a ; enable BG transfer so the BG Marowak pic will be visible after the sprite one is cleared call Delay3 jp ClearSprites diff --git a/engine/battle/init_battle_variables.asm b/engine/battle/init_battle_variables.asm index 7bc912d2..0d403b55 100644 --- a/engine/battle/init_battle_variables.asm +++ b/engine/battle/init_battle_variables.asm @@ -1,5 +1,5 @@ InitBattleVariables: - ld a, [hTilesetType] + ldh a, [hTilesetType] ld [wSavedTilesetType], a xor a ld [wActionResultOrTookBattleTurn], a @@ -35,4 +35,4 @@ InitBattleVariables: ld a, BATTLE_TYPE_SAFARI ld [wBattleType], a .notSafariBattle - jpab PlayBattleMusic + jpfar PlayBattleMusic diff --git a/engine/battle/link_battle_versus_text.asm b/engine/battle/link_battle_versus_text.asm index 76559117..29c11356 100644 --- a/engine/battle/link_battle_versus_text.asm +++ b/engine/battle/link_battle_versus_text.asm @@ -1,23 +1,23 @@ ; display "[player] VS [enemy]" text box with pokeballs representing their parties next to the names DisplayLinkBattleVersusTextBox: call LoadTextBoxTilePatterns - coord hl, 3, 4 + hlcoord 3, 4 ld b, 7 ld c, 12 call TextBoxBorder - coord hl, 4, 5 + hlcoord 4, 5 ld de, wPlayerName call PlaceString - coord hl, 4, 10 + hlcoord 4, 10 ld de, wLinkEnemyTrainerName call PlaceString ; place bold "VS" tiles between the names - coord hl, 9, 8 + hlcoord 9, 8 ld a, $69 ld [hli], a ld [hl], $6a xor a ld [wUpdateSpritesEnabled], a - callab SetupPlayerAndEnemyPokeballs + callfar SetupPlayerAndEnemyPokeballs ld c, 150 jp DelayFrames diff --git a/engine/battle/move_effects/conversion.asm b/engine/battle/move_effects/conversion.asm index 662f65e0..1f64ec5b 100644 --- a/engine/battle/move_effects/conversion.asm +++ b/engine/battle/move_effects/conversion.asm @@ -1,7 +1,7 @@ ConversionEffect_: ld hl, wEnemyMonType1 ld de, wBattleMonType1 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wEnemyBattleStatus1] jr z, .conversionEffect diff --git a/engine/battle/move_effects/drain_hp.asm b/engine/battle/move_effects/drain_hp.asm index 452ccf0c..04a585cc 100644 --- a/engine/battle/move_effects/drain_hp.asm +++ b/engine/battle/move_effects/drain_hp.asm @@ -14,7 +14,7 @@ DrainHPEffect_: .getAttackerHP ld hl, wBattleMonHP ld de, wBattleMonMaxHP - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jp z, .addDamageToAttackerHP ld hl, wEnemyMonHP @@ -69,21 +69,21 @@ DrainHPEffect_: ld [wHPBarNewHP+1], a inc de .next - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a - coord hl, 10, 9 + hlcoord 10, 9 ld a, $1 jr z, .next2 - coord hl, 2, 2 + hlcoord 2, 2 xor a .next2 ld [wHPBarType], a predef UpdateHPBar2 predef DrawPlayerHUDAndHPBar predef DrawEnemyHUDAndHPBar - callab ReadPlayerMonCurHPAndStatus + callfar ReadPlayerMonCurHPAndStatus ld hl, SuckedHealthText - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] jr z, .next3 diff --git a/engine/battle/move_effects/focus_energy.asm b/engine/battle/move_effects/focus_energy.asm index 7a426d2c..1fafe920 100644 --- a/engine/battle/move_effects/focus_energy.asm +++ b/engine/battle/move_effects/focus_energy.asm @@ -1,6 +1,6 @@ FocusEnergyEffect_: ld hl, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .notEnemy ld hl, wEnemyBattleStatus2 @@ -8,13 +8,13 @@ FocusEnergyEffect_: bit GETTING_PUMPED, [hl] ; is mon already using focus energy? jr nz, .alreadyUsing set GETTING_PUMPED, [hl] ; mon is now using focus energy - callab PlayCurrentMoveAnimation + callfar PlayCurrentMoveAnimation ld hl, GettingPumpedText jp PrintText .alreadyUsing ld c, 50 call DelayFrames - jpab PrintButItFailedText_ + jpfar PrintButItFailedText_ GettingPumpedText: text_pause diff --git a/engine/battle/move_effects/haze.asm b/engine/battle/move_effects/haze.asm index 521ff662..915eeed8 100644 --- a/engine/battle/move_effects/haze.asm +++ b/engine/battle/move_effects/haze.asm @@ -15,7 +15,7 @@ HazeEffect_: ; cure non-volatile status, but only for the target ld hl, wEnemyMonStatus ld de, wEnemySelectedMove - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .cureStatuses ld hl, wBattleMonStatus diff --git a/engine/battle/move_effects/heal.asm b/engine/battle/move_effects/heal.asm index 8cc9da93..e9fb62a7 100644 --- a/engine/battle/move_effects/heal.asm +++ b/engine/battle/move_effects/heal.asm @@ -1,5 +1,5 @@ HealEffect_: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld de, wBattleMonHP ld hl, wBattleMonMaxHP @@ -27,7 +27,7 @@ HealEffect_: ld c, 50 call DelayFrames ld hl, wBattleMonStatus - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .restEffect ld hl, wEnemyMonStatus @@ -87,12 +87,12 @@ HealEffect_: .playAnim ld hl, PlayCurrentMoveAnimation call BankswitchEtoF - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a - coord hl, 10, 9 + hlcoord 10, 9 ld a, $1 jr z, .updateHPBar - coord hl, 2, 2 + hlcoord 2, 2 xor a .updateHPBar ld [wHPBarType], a diff --git a/engine/battle/move_effects/leech_seed.asm b/engine/battle/move_effects/leech_seed.asm index 74360233..61bd982a 100644 --- a/engine/battle/move_effects/leech_seed.asm +++ b/engine/battle/move_effects/leech_seed.asm @@ -1,11 +1,11 @@ LeechSeedEffect_: - callab MoveHitTest + callfar MoveHitTest ld a, [wMoveMissed] and a jr nz, .moveMissed ld hl, wEnemyBattleStatus2 ld de, wEnemyMonType1 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .leechSeedEffect ld hl, wPlayerBattleStatus2 @@ -22,7 +22,7 @@ LeechSeedEffect_: bit SEEDED, [hl] jr nz, .moveMissed set SEEDED, [hl] - callab PlayCurrentMoveAnimation + callfar PlayCurrentMoveAnimation ld hl, WasSeededText jp PrintText .moveMissed diff --git a/engine/battle/move_effects/mist.asm b/engine/battle/move_effects/mist.asm index 67ee4921..163d386f 100644 --- a/engine/battle/move_effects/mist.asm +++ b/engine/battle/move_effects/mist.asm @@ -1,6 +1,6 @@ MistEffect_: ld hl, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .mistEffect ld hl, wEnemyBattleStatus2 @@ -8,11 +8,11 @@ MistEffect_: bit PROTECTED_BY_MIST, [hl] ; is mon protected by mist? jr nz, .mistAlreadyInUse set PROTECTED_BY_MIST, [hl] ; mon is now protected by mist - callab PlayCurrentMoveAnimation + callfar PlayCurrentMoveAnimation ld hl, ShroudedInMistText jp PrintText .mistAlreadyInUse - jpab PrintButItFailedText_ + jpfar PrintButItFailedText_ ShroudedInMistText: text_far _ShroudedInMistText diff --git a/engine/battle/move_effects/one_hit_ko.asm b/engine/battle/move_effects/one_hit_ko.asm index 347a4c7b..7e5db0f7 100644 --- a/engine/battle/move_effects/one_hit_ko.asm +++ b/engine/battle/move_effects/one_hit_ko.asm @@ -7,7 +7,7 @@ OneHitKOEffect_: ld [wCriticalHitOrOHKO], a ld hl, wBattleMonSpeed + 1 ld de, wEnemyMonSpeed + 1 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .compareSpeed ld hl, wEnemyMonSpeed + 1 diff --git a/engine/battle/move_effects/paralyze.asm b/engine/battle/move_effects/paralyze.asm index b01aa5cf..dbaa0fb8 100644 --- a/engine/battle/move_effects/paralyze.asm +++ b/engine/battle/move_effects/paralyze.asm @@ -1,7 +1,7 @@ ParalyzeEffect_: ld hl, wEnemyMonStatus ld de, wPlayerMoveType - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jp z, .next ld hl, wBattleMonStatus @@ -26,22 +26,22 @@ ParalyzeEffect_: jr z, .doesntAffect .hitTest push hl - callab MoveHitTest + callfar MoveHitTest pop hl ld a, [wMoveMissed] and a jr nz, .didntAffect set PAR, [hl] - callab QuarterSpeedDueToParalysis + callfar QuarterSpeedDueToParalysis ld c, 30 call DelayFrames - callab PlayCurrentMoveAnimation - jpab PrintMayNotAttackText + callfar PlayCurrentMoveAnimation + jpfar PrintMayNotAttackText .didntAffect ld c, 50 call DelayFrames - jpab PrintDidntAffectText + jpfar PrintDidntAffectText .doesntAffect ld c, 50 call DelayFrames - jpab PrintDoesntAffectText + jpfar PrintDoesntAffectText diff --git a/engine/battle/move_effects/pay_day.asm b/engine/battle/move_effects/pay_day.asm index 11140ec2..fa373038 100644 --- a/engine/battle/move_effects/pay_day.asm +++ b/engine/battle/move_effects/pay_day.asm @@ -2,7 +2,7 @@ PayDayEffect_: xor a ld hl, wcd6d ld [hli], a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wBattleMonLevel] jr z, .payDayEffect @@ -10,28 +10,28 @@ PayDayEffect_: .payDayEffect ; level * 2 add a - ld [hDividend + 3], a + ldh [hDividend + 3], a xor a - ld [hDividend], a - ld [hDividend + 1], a - ld [hDividend + 2], a + ldh [hDividend], a + ldh [hDividend + 1], a + ldh [hDividend + 2], a ; convert to BCD ld a, 100 - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld [hli], a - ld a, [hRemainder] - ld [hDividend + 3], a + ldh a, [hRemainder] + ldh [hDividend + 3], a ld a, 10 - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] swap a ld b, a - ld a, [hRemainder] + ldh a, [hRemainder] add b ld [hl], a ld de, wTotalPayDayMoney + 2 diff --git a/engine/battle/move_effects/recoil.asm b/engine/battle/move_effects/recoil.asm index 63aff429..85110d50 100644 --- a/engine/battle/move_effects/recoil.asm +++ b/engine/battle/move_effects/recoil.asm @@ -1,5 +1,5 @@ RecoilEffect_: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveNum] ld hl, wBattleMonMaxHP @@ -53,12 +53,12 @@ RecoilEffect_: ld [hli], a ld [hl], a .getHPBarCoords - coord hl, 10, 9 - ld a, [hWhoseTurn] + hlcoord 10, 9 + ldh a, [hWhoseTurn] and a ld a, $1 jr z, .updateHPBar - coord hl, 2, 2 + hlcoord 2, 2 xor a .updateHPBar ld [wHPBarType], a diff --git a/engine/battle/move_effects/reflect_light_screen.asm b/engine/battle/move_effects/reflect_light_screen.asm index 07338c9a..7bdc7be7 100644 --- a/engine/battle/move_effects/reflect_light_screen.asm +++ b/engine/battle/move_effects/reflect_light_screen.asm @@ -1,7 +1,7 @@ ReflectLightScreenEffect_: ld hl, wPlayerBattleStatus3 ld de, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .reflectLightScreenEffect ld hl, wEnemyBattleStatus3 diff --git a/engine/battle/move_effects/substitute.asm b/engine/battle/move_effects/substitute.asm index 95c43462..860b76b6 100644 --- a/engine/battle/move_effects/substitute.asm +++ b/engine/battle/move_effects/substitute.asm @@ -4,7 +4,7 @@ SubstituteEffect_: ld hl, wBattleMonMaxHP ld de, wPlayerSubstituteHP ld bc, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .notEnemy ld hl, wEnemyMonMaxHP @@ -55,7 +55,7 @@ SubstituteEffect_: call Bankswitch ; jump to routine depending on animation setting ld hl, SubstituteText call PrintText - jpab DrawHUDsAndHPBars + jpfar DrawHUDsAndHPBars .alreadyHasSubstitute ld hl, HasSubstituteText jr .printText diff --git a/engine/battle/move_effects/transform.asm b/engine/battle/move_effects/transform.asm index da26d031..46cea51c 100644 --- a/engine/battle/move_effects/transform.asm +++ b/engine/battle/move_effects/transform.asm @@ -3,7 +3,7 @@ TransformEffect_: ld de, wEnemyMonSpecies ld bc, wEnemyBattleStatus3 ld a, [wEnemyBattleStatus1] - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .hitTest ld hl, wEnemyMonSpecies @@ -18,7 +18,7 @@ TransformEffect_: push de push bc ld hl, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .transformEffect ld hl, wEnemyBattleStatus2 @@ -64,7 +64,7 @@ TransformEffect_: inc bc inc bc call CopyData - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .next ; save enemy mon DVs at wTransformedEnemyMonOriginalDVs @@ -128,7 +128,7 @@ TransformEffect_: jp PrintText .copyBasedOnTurn - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .gotStatsOrModsToCopy push hl diff --git a/engine/battle/scale_sprites.asm b/engine/battle/scale_sprites.asm index 11967ba1..69979412 100644 --- a/engine/battle/scale_sprites.asm +++ b/engine/battle/scale_sprites.asm @@ -41,16 +41,16 @@ ScaleFirstThreeSpriteColumnsByTwo: ScaleLastSpriteColumnByTwo: ld a, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows - ld [hSpriteInterlaceCounter], a + ldh [hSpriteInterlaceCounter], a ld bc, -1 .columnInnerLoop ld a, [de] dec de swap a ; only high nybble contains information call ScalePixelsByTwo - ld a, [hSpriteInterlaceCounter] + ldh a, [hSpriteInterlaceCounter] dec a - ld [hSpriteInterlaceCounter], a + ldh [hSpriteInterlaceCounter], 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 98893dcf..e19d681a 100644 --- a/engine/battle/scroll_draw_trainer_pic.asm +++ b/engine/battle/scroll_draw_trainer_pic.asm @@ -5,8 +5,8 @@ _ScrollTrainerPicAfterBattle: ld [wEnemyMonSpecies2], a ld b, SET_PAL_BATTLE call RunPaletteCommand - callab _LoadTrainerPic - coord hl, 19, 0 + callfar _LoadTrainerPic + hlcoord 19, 0 ld c, $0 .scrollLoop inc c diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm index 8373ef4f..87bec842 100644 --- a/engine/battle/trainer_ai.asm +++ b/engine/battle/trainer_ai.asm @@ -204,7 +204,7 @@ AIMoveChoiceModification3: push hl push bc push de - callab AIGetTypeEffectiveness + callfar AIGetTypeEffectiveness pop de pop bc pop hl @@ -542,7 +542,7 @@ AIRecoverHP: AIPrintItemUseAndUpdateHPBar: call AIPrintItemUse_ - coord hl, 2, 2 + hlcoord 2, 2 xor a ld [wHPBarType], a predef UpdateHPBar2 @@ -599,7 +599,7 @@ SwitchEnemyMon: ; switching in a new mon in response to this switch. ld a, 1 ld [wFirstMonsNotOutYet], a - callab EnemySendOut + callfar EnemySendOut xor a ld [wFirstMonsNotOutYet], a @@ -655,17 +655,17 @@ AIUseDireHit: ; unused AICheckIfHPBelowFraction: ; return carry if enemy trainer's current HP is below 1 / a of the maximum - ld [hDivisor], a + ldh [hDivisor], a ld hl, wEnemyMonMaxHP ld a, [hli] - ld [hDividend], a + ldh [hDividend], a ld a, [hl] - ld [hDividend + 1], a + ldh [hDividend + 1], a ld b, 2 call Divide - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld c, a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld b, a ld hl, wEnemyMonHP + 1 ld a, [hld] @@ -713,7 +713,7 @@ AIIncreaseStat: ld a, ANIM_AF ld [hli], a ld [hl], b - callab StatModifierUpEffect + callfar StatModifierUpEffect pop hl pop af ld [hli], a diff --git a/engine/battle/unused_stats_functions.asm b/engine/battle/unused_stats_functions.asm index fb3422c7..5174adf5 100644 --- a/engine/battle/unused_stats_functions.asm +++ b/engine/battle/unused_stats_functions.asm @@ -1,6 +1,6 @@ ; does nothing since no stats are ever selected (barring glitches) DoubleSelectedStats: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerStatsToDouble] ld hl, wBattleMonAttack + 1 @@ -30,7 +30,7 @@ DoubleSelectedStats: ; does nothing since no stats are ever selected (barring glitches) HalveSelectedStats: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerStatsToHalve] ld hl, wBattleMonAttack diff --git a/engine/battle/wild_encounters.asm b/engine/battle/wild_encounters.asm index 9d6fcb8d..e24f9632 100644 --- a/engine/battle/wild_encounters.asm +++ b/engine/battle/wild_encounters.asm @@ -7,14 +7,14 @@ TryDoWildEncounter: ld a, [wd736] and a ret nz - callab IsPlayerStandingOnDoorTileOrWarpTile + callfar IsPlayerStandingOnDoorTileOrWarpTile jr nc, .notStandingOnDoorOrWarpTile .CantEncounter ld a, $1 and a ret .notStandingOnDoorOrWarpTile - callab IsPlayerJustOutsideMap + callfar IsPlayerJustOutsideMap jr z, .CantEncounter ld a, [wRepelRemainingSteps] and a @@ -25,7 +25,7 @@ TryDoWildEncounter: .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? - coord hl, 9, 9 + hlcoord 9, 9 ld c, [hl] ld a, [wGrassTile] cp c @@ -48,10 +48,10 @@ TryDoWildEncounter: .CanEncounter ; compare encounter chance with a random number to determine if there will be an encounter ld b, a - ld a, [hRandomAdd] + ldh a, [hRandomAdd] cp b jr nc, .CantEncounter2 - ld a, [hRandomSub] + ldh a, [hRandomSub] ld b, a ld hl, WildMonEncounterSlotChances .determineEncounterSlot @@ -64,7 +64,7 @@ TryDoWildEncounter: ; determine which wild pokemon (grass or water) can appear in the half-block we're standing in ld c, [hl] ld hl, wGrassMons - aCoord 8, 9 + lda_coord 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, wWaterMons @@ -90,7 +90,7 @@ TryDoWildEncounter: .lastRepelStep ld [wRepelRemainingSteps], a ld a, TEXT_REPEL_WORE_OFF - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call EnableAutoTextBoxDrawing call DisplayTextID .CantEncounter2 |