diff options
Diffstat (limited to 'engine/battle')
47 files changed, 583 insertions, 583 deletions
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm index 28dfb1010..b3f40cd34 100644 --- a/engine/battle/ai/items.asm +++ b/engine/battle/ai/items.asm @@ -520,7 +520,7 @@ AIUpdateHUD: call UpdateEnemyMonInParty farcall UpdateEnemyHUD ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld hl, wEnemyItemState dec [hl] scf @@ -671,7 +671,7 @@ AI_Switch: ld hl, wEnemySubStatus4 res SUBSTATUS_RAGE, [hl] xor a - ld [hBattleTurn], a + ldh [hBattleTurn], a callfar PursuitSwitch push af @@ -755,17 +755,17 @@ EnemyUsedDireHit: jp PrintText_UsedItemOn_AND_AIUpdateHUD Function3851e: ; This appears to be unused - 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 + 2] + ldh a, [hQuotient + 2] ld c, a - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] ld b, a ld hl, wEnemyMonHP + 1 ld a, [hld] diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm index 752796892..75efcf920 100644 --- a/engine/battle/ai/scoring.asm +++ b/engine/battle/ai/scoring.asm @@ -165,7 +165,7 @@ AI_Types: push bc push de ld a, 1 - ld [hBattleTurn], a + ldh [hBattleTurn], a callfar BattleCheckTypeMatchup pop de pop bc @@ -410,7 +410,7 @@ AI_Smart_Sleep: AI_Smart_LeechHit: push hl ld a, 1 - ld [hBattleTurn], a + ldh [hBattleTurn], a callfar BattleCheckTypeMatchup pop hl @@ -486,7 +486,7 @@ AI_Smart_LockOn: jr nc, .asm_3884f ld a, $1 - ld [hBattleTurn], a + ldh [hBattleTurn], a push hl push bc @@ -1289,7 +1289,7 @@ AI_Smart_Mimic: call AIGetEnemyMove ld a, $1 - ld [hBattleTurn], a + ldh [hBattleTurn], a callfar BattleCheckTypeMatchup ld a, [wTypeMatchup] @@ -1631,7 +1631,7 @@ AI_Smart_PriorityHit: ; Greatly encourage this move if it will KO the player. ld a, $1 - ld [hBattleTurn], a + ldh [hBattleTurn], a push hl callfar EnemyAttackDamage callfar BattleCommand_DamageCalc @@ -1675,7 +1675,7 @@ AI_Smart_Conversion2: ld [wPlayerMoveStruct + MOVE_TYPE], a xor a - ld [hBattleTurn], a + ldh [hBattleTurn], a callfar BattleCheckTypeMatchup @@ -2285,7 +2285,7 @@ AI_Smart_RapidSpin: AI_Smart_HiddenPower: push hl ld a, 1 - ld [hBattleTurn], a + ldh [hBattleTurn], a ; Calculate Hidden Power's type and base power based on enemy's DVs. callfar HiddenPowerDamage @@ -3013,7 +3013,7 @@ INCLUDE "data/battle/ai/reckless_moves.asm" AIDamageCalc: ld a, 1 - ld [hBattleTurn], a + ldh [hBattleTurn], a ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld de, 1 ld hl, ConstantDamageEffects @@ -3119,7 +3119,7 @@ AI_Status: push bc push de ld a, 1 - ld [hBattleTurn], a + ldh [hBattleTurn], a callfar BattleCheckTypeMatchup pop de pop bc diff --git a/engine/battle/anim_hp_bar.asm b/engine/battle/anim_hp_bar.asm index fd9c783ce..9248ad4f7 100644 --- a/engine/battle/anim_hp_bar.asm +++ b/engine/battle/anim_hp_bar.asm @@ -277,7 +277,7 @@ HPBarAnim_UpdateHPRemaining: ret HPBarAnim_PaletteUpdate: - ld a, [hCGB] + ldh a, [hCGB] and a ret z ld hl, wCurHPAnimPal @@ -288,7 +288,7 @@ HPBarAnim_PaletteUpdate: ret HPBarAnim_BGMapUpdate: - ld a, [hCGB] + ldh a, [hCGB] and a jr nz, .cgb call DelayFrame @@ -316,15 +316,15 @@ HPBarAnim_BGMapUpdate: cp $5 jr z, .skip_delay ld a, $2 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld a, c - ld [hBGMapThird], a + ldh [hBGMapThird], a call DelayFrame .skip_delay ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld a, c - ld [hBGMapThird], a + ldh [hBGMapThird], a call DelayFrame pop af cp $2 @@ -336,14 +336,14 @@ HPBarAnim_BGMapUpdate: .two_frames inc c ld a, $2 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld a, c - ld [hBGMapThird], a + ldh [hBGMapThird], a call DelayFrame ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld a, c - ld [hBGMapThird], a + ldh [hBGMapThird], a call DelayFrame ret @@ -356,7 +356,7 @@ HPBarAnim_BGMapUpdate: .finish call DelayFrame ld a, c - ld [hBGMapThird], a + ldh [hBGMapThird], a call DelayFrame ret diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm index 8747f46a6..e4c99be6c 100644 --- a/engine/battle/battle_transition.asm +++ b/engine/battle/battle_transition.asm @@ -10,11 +10,11 @@ BATTLETRANSITION_SQUARE EQUS "\"8\"" ; $fe DoBattleTransition: call .InitGFX - ld a, [rBGP] + ldh a, [rBGP] ld [wBGP], a - ld a, [rOBP0] + ldh a, [rOBP0] ld [wOBP0], a - ld a, [rOBP1] + ldh a, [rOBP1] ld [wOBP1], a call DelayFrame ld hl, hVBlank @@ -31,10 +31,10 @@ DoBattleTransition: jr .loop .done - ld a, [rSVBK] + ldh a, [rSVBK] push af ld a, BANK(wBGPals1) - ld [rSVBK], a + ldh [rSVBK], a ld hl, wBGPals1 ld bc, 8 palettes @@ -42,22 +42,22 @@ DoBattleTransition: call ByteFill pop af - ld [rSVBK], a + ldh [rSVBK], a ld a, %11111111 ld [wBGP], a call DmgToCgbBGPals call DelayFrame xor a - ld [hLCDCPointer], a - ld [hLYOverrideStart], a - ld [hLYOverrideEnd], a - ld [hSCY], a + ldh [hLCDCPointer], a + ldh [hLYOverrideStart], a + ldh [hLYOverrideEnd], a + ldh [hSCY], a ld a, 1 ; unnecessary bankswitch? - ld [rSVBK], a + ldh [rSVBK], a pop af - ld [hVBlank], a + ldh [hVBlank], a call DelayFrame ret @@ -77,10 +77,10 @@ DoBattleTransition: .resume ld a, SCREEN_HEIGHT_PX - ld [hWY], a + ldh [hWY], a call DelayFrame xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a ld hl, wJumptableIndex xor a ld [hli], a @@ -104,10 +104,10 @@ LoadTrainerBattlePokeballTiles: ld c, 2 call Request2bpp - ld a, [rVBK] + ldh a, [rVBK] push af ld a, $1 - ld [rVBK], a + ldh [rVBK], a ld de, TrainerBattlePokeballTiles ld hl, vTiles3 tile BATTLETRANSITION_SQUARE @@ -116,14 +116,14 @@ LoadTrainerBattlePokeballTiles: call Request2bpp pop af - ld [rVBK], a + ldh [rVBK], a ret ConvertTrainerBattlePokeballTilesTo2bpp: - ld a, [rSVBK] + ldh a, [rSVBK] push af ld a, BANK(wDecompressScratch) - ld [rSVBK], a + ldh [rSVBK], a push hl ld hl, wDecompressScratch ld bc, $28 tiles @@ -142,7 +142,7 @@ ConvertTrainerBattlePokeballTilesTo2bpp: ld c, $28 call Request2bpp pop af - ld [rSVBK], a + ldh [rSVBK], a ret TrainerBattlePokeballTiles: @@ -258,7 +258,7 @@ StartTrainerBattle_SetUpBGMap: call StartTrainerBattle_NextScene xor a ld [wcf64], a - ld [hBGMapMode], a + ldh [hBGMapMode], a ret StartTrainerBattle_Flash: @@ -311,16 +311,16 @@ StartTrainerBattle_Flash: StartTrainerBattle_SetUpForWavyOutro: farcall Function5602 ld a, BANK(wLYOverrides) - ld [rSVBK], a + ldh [rSVBK], a call StartTrainerBattle_NextScene - ld a, rSCX - $ff00 - ld [hLCDCPointer], a + ld a, LOW(rSCX) + ldh [hLCDCPointer], a xor a - ld [hLYOverrideStart], a + ldh [hLYOverrideStart], a ld a, $90 - ld [hLYOverrideEnd], a + ldh [hLYOverrideEnd], a xor a ld [wcf64], a ld [wcf65], a @@ -369,7 +369,7 @@ StartTrainerBattle_SineWave: StartTrainerBattle_SetUpForSpinOutro: farcall Function5602 ld a, BANK(wLYOverrides) - ld [rSVBK], a + ldh [rSVBK], a call StartTrainerBattle_NextScene xor a ld [wcf64], a @@ -377,7 +377,7 @@ StartTrainerBattle_SetUpForSpinOutro: StartTrainerBattle_SpinToBlack: xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a ld a, [wcf64] ld e, a ld d, 0 @@ -391,7 +391,7 @@ endr ld [wcf65], a call .load ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a call DelayFrame call DelayFrame ld hl, wcf64 @@ -400,12 +400,12 @@ endr .end ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a call DelayFrame call DelayFrame call DelayFrame xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a ld a, BATTLETRANSITION_FINISH ld [wJumptableIndex], a ret @@ -511,12 +511,12 @@ ENDM StartTrainerBattle_SetUpForRandomScatterOutro: farcall Function5602 ld a, BANK(wLYOverrides) - ld [rSVBK], a + ldh [rSVBK], a call StartTrainerBattle_NextScene ld a, $10 ld [wcf64], a ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ret StartTrainerBattle_SpeckleToBlack: @@ -536,12 +536,12 @@ StartTrainerBattle_SpeckleToBlack: .done ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a call DelayFrame call DelayFrame call DelayFrame xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a ld a, BATTLETRANSITION_FINISH ld [wJumptableIndex], a ret @@ -583,7 +583,7 @@ StartTrainerBattle_LoadPokeBallGraphics: jp z, .nextscene ; don't need to be here if wild xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a hlcoord 0, 0, wAttrMap ld bc, SCREEN_HEIGHT * SCREEN_WIDTH inc b @@ -640,11 +640,11 @@ StartTrainerBattle_LoadPokeBallGraphics: dec b jr nz, .loop2 - ld a, [hCGB] + ldh a, [hCGB] and a jr nz, .cgb ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a call DelayFrame call DelayFrame jr .nextscene @@ -657,10 +657,10 @@ StartTrainerBattle_LoadPokeBallGraphics: jr nz, .daytime ld hl, .nightpals .daytime - ld a, [rSVBK] + ldh a, [rSVBK] push af ld a, BANK(wBGPals1) - ld [rSVBK], a + ldh [rSVBK], a call .copypals push hl ld de, wBGPals1 palette PAL_BG_TEXT @@ -671,9 +671,9 @@ StartTrainerBattle_LoadPokeBallGraphics: ld bc, 1 palettes call CopyBytes pop af - ld [rSVBK], a + ldh [rSVBK], a ld a, $1 - ld [hCGBPalUpdate], a + ldh [hCGBPalUpdate], a call DelayFrame call BattleStart_CopyTilemapAtOnce @@ -731,10 +731,10 @@ PokeBallTransition: db %00000011, %11000000 WipeLYOverrides: - ld a, [rSVBK] + ldh a, [rSVBK] push af ld a, BANK(wLYOverrides) - ld [rSVBK], a + ldh [rSVBK], a ld hl, wLYOverrides call .wipe @@ -742,7 +742,7 @@ WipeLYOverrides: call .wipe pop af - ld [rSVBK], a + ldh [rSVBK], a ret .wipe @@ -777,7 +777,7 @@ StartTrainerBattle_ZoomToBlack: inc de ld h, a xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a call .Copy call WaitBGMap jr .loop @@ -823,8 +823,8 @@ ENDM Unreferenced_Function8c7c9: ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a call WaitBGMap xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a ret diff --git a/engine/battle/consume_held_item.asm b/engine/battle/consume_held_item.asm index fe63d40a8..c5e3b2041 100644 --- a/engine/battle/consume_held_item.asm +++ b/engine/battle/consume_held_item.asm @@ -2,7 +2,7 @@ ConsumeHeldItem: push hl push de push bc - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld hl, wOTPartyMon1Item ld de, wEnemyMonItem @@ -38,7 +38,7 @@ ConsumeHeldItem: pop af pop hl call GetPartyLocation - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .ourturn ld a, [wBattleMode] diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 2d5e85cef..32de2d307 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -26,7 +26,7 @@ DoBattle: and a jr z, .not_linked - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .player_2 @@ -97,7 +97,7 @@ DoBattle: ld a, [wLinkMode] and a jr z, .not_linked_2 - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr nz, .not_linked_2 xor a @@ -247,7 +247,7 @@ Stubbed_Function3c1bf: ret HandleBetweenTurnEffects: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .CheckEnemyFirst call CheckFaint_PlayerThenEnemy @@ -343,7 +343,7 @@ CheckFaint_EnemyThenPlayer: ret HandleBerserkGene: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .reverse @@ -449,7 +449,7 @@ DetermineMoveOrder: ld a, [wBattlePlayerAction] cp BATTLEPLAYERACTION_SWITCH jr nz, .switch - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .player_2 @@ -506,7 +506,7 @@ DetermineMoveOrder: jp .enemy_first .both_have_quick_claw - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .player_2b call BattleRandom @@ -536,7 +536,7 @@ DetermineMoveOrder: jp .enemy_first .speed_tie - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .player_2c call BattleRandom @@ -633,7 +633,7 @@ ParsePlayerAction: .struggle ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a pop af ret nz @@ -695,7 +695,7 @@ ParsePlayerAction: ret HandleEncore: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .player_1 call .do_player @@ -982,7 +982,7 @@ EndUserDestinyBond: ret HasUserFainted: - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, HasPlayerFainted HasEnemyFainted: @@ -1027,7 +1027,7 @@ ResidualDamage: call Call_PlayBattleAnim_OnlyIfVisible call GetEighthMaxHP ld de, wPlayerToxicCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .check_toxic ld de, wEnemyToxicCount @@ -1074,7 +1074,7 @@ ResidualDamage: call GetEighthMaxHP call SubtractHPFromUser ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a call RestoreHP ld hl, LeechSeedSapsText call StdBattleTextBox @@ -1116,7 +1116,7 @@ ResidualDamage: .not_cursed ld hl, wBattleMonHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .check_fainted ld hl, wEnemyMonHP @@ -1134,7 +1134,7 @@ ResidualDamage: ret HandlePerishSong: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .EnemyFirst call SetPlayerTurn @@ -1149,7 +1149,7 @@ HandlePerishSong: .do_it ld hl, wPlayerPerishCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_count ld hl, wEnemyPerishCount @@ -1170,7 +1170,7 @@ HandlePerishSong: ld a, BATTLE_VARS_SUBSTATUS1 call GetBattleVarAddr res SUBSTATUS_PERISH, [hl] - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .kill_enemy ld hl, wBattleMonHP @@ -1202,7 +1202,7 @@ HandlePerishSong: ret HandleWrap: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .EnemyFirst call SetPlayerTurn @@ -1218,7 +1218,7 @@ HandleWrap: .do_it ld hl, wPlayerWrapCount ld de, wPlayerTrappingMove - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_addrs ld hl, wEnemyWrapCount @@ -1266,13 +1266,13 @@ HandleWrap: jp StdBattleTextBox SwitchTurnCore: - ld a, [hBattleTurn] + ldh a, [hBattleTurn] xor 1 - ld [hBattleTurn], a + ldh [hBattleTurn], a ret HandleLeftovers: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .DoEnemyFirst call SetPlayerTurn @@ -1295,7 +1295,7 @@ HandleLeftovers: ret nz ld hl, wBattleMonHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_hp ld hl, wEnemyMonHP @@ -1321,7 +1321,7 @@ HandleLeftovers: jp StdBattleTextBox HandleMysteryberry: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .DoEnemyFirst call SetPlayerTurn @@ -1347,7 +1347,7 @@ HandleMysteryberry: ld hl, wPartyMon1Moves ld a, [wCurBattleMon] call GetPartyLocation - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .wild ld de, wWildMonPP @@ -1400,7 +1400,7 @@ HandleMysteryberry: ld [wTempByteValue], a ld de, wBattleMonMoves - 1 ld hl, wBattleMonPP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .player_pp ld de, wEnemyMonMoves - 1 @@ -1420,7 +1420,7 @@ HandleMysteryberry: ld a, [wTempByteValue] cp [hl] jr nz, .skip_checks - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, [wPlayerSubStatus5] jr z, .check_transform @@ -1438,7 +1438,7 @@ HandleMysteryberry: xor a ld [hl], a call GetPartymonItem - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .consume_item ld a, [wBattleMode] @@ -1459,7 +1459,7 @@ HandleMysteryberry: jp StdBattleTextBox HandleFutureSight: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .enemy_first call SetPlayerTurn @@ -1474,7 +1474,7 @@ HandleFutureSight: .do_it ld hl, wPlayerFutureSightCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .okay ld hl, wEnemyFutureSightCount @@ -1517,7 +1517,7 @@ HandleFutureSight: jp UpdateEnemyMonInParty HandleDefrost: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .enemy_first call .do_player_turn @@ -1576,7 +1576,7 @@ HandleDefrost: jp StdBattleTextBox HandleSafeguard: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .player1 call .CheckPlayer @@ -1608,12 +1608,12 @@ HandleSafeguard: ld a, $1 .print - ld [hBattleTurn], a + ldh [hBattleTurn], a ld hl, BattleText_SafeguardFaded jp StdBattleTextBox HandleScreens: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .Both call .CheckPlayer @@ -1693,7 +1693,7 @@ HandleWeather: cp WEATHER_SANDSTORM ret nz - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .enemy_first @@ -1715,7 +1715,7 @@ HandleWeather: ret nz ld hl, wBattleMonType1 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wEnemyMonType1 @@ -1790,7 +1790,7 @@ SubtractHPFromUser: SubtractHP: ld hl, wBattleMonHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wEnemyMonHP @@ -1885,7 +1885,7 @@ GetMaxHP: ; output: bc, wBuffer1-2 ld hl, wBattleMonMaxHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wEnemyMonMaxHP @@ -1901,7 +1901,7 @@ GetMaxHP: Unreferenced_GetHalfHP: ld hl, wBattleMonHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wEnemyMonHP @@ -1920,7 +1920,7 @@ Unreferenced_GetHalfHP: CheckUserHasEnoughHP: ld hl, wBattleMonHP + 1 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wEnemyMonHP + 1 @@ -1934,7 +1934,7 @@ CheckUserHasEnoughHP: RestoreHP ld hl, wEnemyMonMaxHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wBattleMonMaxHP @@ -1982,7 +1982,7 @@ UpdateHPBarBattleHuds: UpdateHPBar: hlcoord 10, 9 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, 1 jr z, .ok @@ -2015,7 +2015,7 @@ HandleEnemyMonFaint: call nz, UpdatePlayerHUD ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld c, 60 call DelayFrames @@ -2064,7 +2064,7 @@ HandleEnemyMonFaint: ret DoubleSwitch: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .player_1 call ClearSprites @@ -3059,7 +3059,7 @@ MonFaintedAnimation: db " @" SlideBattlePicOut: - ld [hMapObjectIndexBuffer], a + ldh [hMapObjectIndexBuffer], a ld c, a .loop push bc @@ -3082,7 +3082,7 @@ SlideBattlePicOut: ret .DoFrame: - ld a, [hMapObjectIndexBuffer] + ldh a, [hMapObjectIndexBuffer] ld c, a cp $8 jr nz, .back @@ -3517,7 +3517,7 @@ OfferSwitch: ClearEnemyMonBox: xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a call ExitMenu call ClearSprites hlcoord 1, 0 @@ -3577,7 +3577,7 @@ Function_SetEnemyMonAndSendOutAnimation: .skip_cry call UpdateEnemyHUD ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ret NewEnemyMonStatus: @@ -3715,14 +3715,14 @@ TryToRunAwayFromBattle: inc a ld [wNumFleeAttempts], a ld a, [hli] - ld [hPartyMon1Speed + 0], a + ldh [hPartyMon1Speed + 0], a ld a, [hl] - ld [hPartyMon1Speed + 1], a + ldh [hPartyMon1Speed + 1], a ld a, [de] inc de - ld [hEnemyMonSpeed + 0], a + ldh [hEnemyMonSpeed + 0], a ld a, [de] - ld [hEnemyMonSpeed + 1], a + ldh [hEnemyMonSpeed + 1], a call Call_LoadTempTileMapToTileMap ld de, hPartyMon1Speed ld hl, hEnemyMonSpeed @@ -3731,27 +3731,27 @@ TryToRunAwayFromBattle: jr nc, .can_escape xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, 32 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply - ld a, [hProduct + 2] - ld [hDividend + 0], a - ld a, [hProduct + 3] - ld [hDividend + 1], a - ld a, [hEnemyMonSpeed + 0] + ldh a, [hProduct + 2] + ldh [hDividend + 0], a + ldh a, [hProduct + 3] + ldh [hDividend + 1], a + ldh a, [hEnemyMonSpeed + 0] ld b, a - ld a, [hEnemyMonSpeed + 1] + ldh a, [hEnemyMonSpeed + 1] srl b rr a srl b rr a and a jr z, .can_escape - ld [hDivisor], a + ldh [hDivisor], a ld b, 2 call Divide - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] and a jr nz, .can_escape ld a, [wNumFleeAttempts] @@ -3760,16 +3760,16 @@ TryToRunAwayFromBattle: dec c jr z, .cant_escape_2 ld b, 30 - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] add b - ld [hQuotient + 2], a + ldh [hQuotient + 2], a jr c, .can_escape jr .loop .cant_escape_2 call BattleRandom ld b, a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] cp b jr nc, .can_escape ld a, BATTLEPLAYERACTION_USEITEM @@ -4013,10 +4013,10 @@ SendOutPlayerMon: call ClearBox call WaitBGMap xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a call GetBattleMonBackpic xor a - ld [hGraphicStartTile], a + ldh [hGraphicStartTile], a ld [wBattleMenuCursorBuffer], a ld [wCurMoveNum], a ld [wTypeModifier], a @@ -4056,7 +4056,7 @@ SendOutPlayerMon: .statused call UpdatePlayerHUD ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ret NewBattleMonStatus: @@ -4098,7 +4098,7 @@ SpikesDamage: ld hl, wPlayerScreens ld de, wBattleMonType ld bc, UpdatePlayerHUD - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wEnemyScreens @@ -4147,7 +4147,7 @@ PursuitSwitch: push af ld hl, DoPlayerTurn - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .do_turn ld hl, DoEnemyTurn @@ -4165,7 +4165,7 @@ PursuitSwitch: pop af ld [wCurBattleMon], a - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .check_enemy_fainted @@ -4214,19 +4214,19 @@ PursuitSwitch: ret RecallPlayerMon: - ld a, [hBattleTurn] + ldh a, [hBattleTurn] push af xor a - ld [hBattleTurn], a + ldh [hBattleTurn], a ld [wNumHits], a ld de, ANIM_RETURN_MON call Call_PlayBattleAnim pop af - ld [hBattleTurn], a + ldh [hBattleTurn], a ret HandleHealingItems: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .player_1 call SetPlayerTurn @@ -4255,7 +4255,7 @@ HandleHPHealingItem: ret nz ld de, wEnemyMonHP + 1 ld hl, wEnemyMonMaxHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .go ld de, wBattleMonHP + 1 @@ -4321,7 +4321,7 @@ HandleHPHealingItem: inc de ld a, [wBuffer5] ld [de], a - ld a, [hBattleTurn] + ldh a, [hBattleTurn] ld [wWhichHPBar], a and a hlcoord 2, 2 @@ -4397,7 +4397,7 @@ UseHeldStatusHealingItem: .skip_confuse ld hl, CalcEnemyStats - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_pointer ld hl, CalcPlayerStats @@ -4437,7 +4437,7 @@ UseConfusionHealingItem: call ItemRecoveryAnim ld hl, BattleText_ItemHealedConfusion call StdBattleTextBox - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .do_partymon call GetOTPartymonItem @@ -4458,7 +4458,7 @@ UseConfusionHealingItem: HandleStatBoostingHeldItems: ; The effects handled here are not used in-game. - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .player_1 call .DoPlayer @@ -4477,7 +4477,7 @@ HandleStatBoostingHeldItems: call GetOTPartymonItem ld a, $1 .HandleItem: - ld [hBattleTurn], a + ldh [hBattleTurn], a ld d, h ld e, l push de @@ -4570,7 +4570,7 @@ UpdatePlayerHUD:: DrawPlayerHUD: xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a ; Clear the area hlcoord 9, 7 @@ -4708,7 +4708,7 @@ UpdateEnemyHUD:: DrawEnemyHUD: xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a hlcoord 1, 0 lb bc, 4, 11 @@ -4774,9 +4774,9 @@ DrawEnemyHUD: 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] jr nz, .not_fainted @@ -4787,44 +4787,44 @@ DrawEnemyHUD: .not_fainted xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, HP_BAR_LENGTH_PX - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld hl, wEnemyMonMaxHP ld a, [hli] ld b, a ld a, [hl] - ld [hMultiplier], a + ldh [hMultiplier], a ld a, b and a jr z, .less_than_256_max - ld a, [hMultiplier] + ldh a, [hMultiplier] 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 .less_than_256_max - ld a, [hProduct + 2] - ld [hDividend + 0], a - ld a, [hProduct + 3] - ld [hDividend + 1], a + ldh a, [hProduct + 2] + ldh [hDividend + 0], a + ldh a, [hProduct + 3] + ldh [hDividend + 1], a ld a, 2 ld b, a call Divide - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld e, a ld a, HP_BAR_LENGTH ld d, a @@ -4856,7 +4856,7 @@ ret_3e138: BattleMenu: xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a call LoadTempTileMapToTileMap ld a, [wBattleType] @@ -4889,7 +4889,7 @@ BattleMenu: .next ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld a, [wBattleMenuCursorBuffer] cp $1 jp z, BattleMenu_Fight @@ -5001,7 +5001,7 @@ BattleMenu_Pack: .ball xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a call _LoadBattleFontsHPBar call ClearSprites ld a, [wBattleType] @@ -5203,7 +5203,7 @@ PlayerSwitch: ret .dont_run - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .player_1 call BattleMonEntrance @@ -5332,7 +5332,7 @@ MoveSelectionScreen: ld bc, NUM_MOVES call CopyBytes xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a hlcoord 4, 17 - NUM_MOVES - 1 ld b, 4 @@ -5429,7 +5429,7 @@ MoveSelectionScreen: .interpret_joypad ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a call ScrollingMenuJoypad bit D_UP_F, a jp nz, .pressed_up @@ -5618,7 +5618,7 @@ MoveSelectionScreen: MoveInfoBox: xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a hlcoord 0, 8 ld b, 3 @@ -6513,8 +6513,8 @@ BattleWinSlideInEnemyTrainerFrontpic: cp 7 ret z xor a - ld [hBGMapMode], a - ld [hBGMapThird], a + ldh [hBGMapMode], a + ldh [hBGMapThird], a ld d, $0 push bc push hl @@ -6529,7 +6529,7 @@ BattleWinSlideInEnemyTrainerFrontpic: jr nz, .inner_loop ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld c, 4 call DelayFrames pop hl @@ -6564,12 +6564,12 @@ ApplyStatusEffectOnEnemyStats: xor a ApplyStatusEffectOnStats: - ld [hBattleTurn], a + ldh [hBattleTurn], a call ApplyPrzEffectOnSpeed jp ApplyBrnEffectOnAttack ApplyPrzEffectOnSpeed: - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .enemy ld a, [wBattleMonStatus] @@ -6614,7 +6614,7 @@ ApplyPrzEffectOnSpeed: ret ApplyBrnEffectOnAttack: - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .enemy ld a, [wBattleMonStatus] @@ -6707,38 +6707,38 @@ ApplyStatLevelMultiplier: ld b, 0 add hl, bc xor a - ld [hMultiplicand + 0], a + ldh [hMultiplicand + 0], 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, [hQuotient + 2] + ldh a, [hQuotient + 2] sub LOW(MAX_STAT_VALUE) - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] sbc HIGH(MAX_STAT_VALUE) jp c, .okay3 ld a, HIGH(MAX_STAT_VALUE) - ld [hQuotient + 1], a + ldh [hQuotient + 1], a ld a, LOW(MAX_STAT_VALUE) - ld [hQuotient + 2], a + ldh [hQuotient + 2], a .okay3 - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] ld [hli], a ld b, a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld [hl], a or b jr nz, .okay4 @@ -7054,15 +7054,15 @@ GiveExperiencePoints: dec c jr nz, .loop1 xor a - ld [hMultiplicand + 0], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 0], 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 ; Boost Experience for traded Pokemon @@ -7095,9 +7095,9 @@ GiveExperiencePoints: ld a, [hl] cp LUCKY_EGG call z, BoostExp - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld [wStringBuffer2 + 1], a - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] ld [wStringBuffer2], a ld a, [wCurPartyMon] ld hl, wPartyMonNicknames @@ -7105,9 +7105,9 @@ GiveExperiencePoints: ld hl, Text_MonGainedExpPoint call BattleTextBox ld a, [wStringBuffer2 + 1] - ld [hQuotient + 2], a + ldh [hQuotient + 2], a ld a, [wStringBuffer2] - ld [hQuotient + 1], a + ldh [hQuotient + 1], a pop bc call AnimateExpBar push bc @@ -7116,11 +7116,11 @@ GiveExperiencePoints: ld hl, MON_EXP + 2 add hl, bc ld d, [hl] - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] add d ld [hld], a ld d, [hl] - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] adc d ld [hl], a jr nc, .skip2 @@ -7148,11 +7148,11 @@ GiveExperiencePoints: ld hl, MON_EXP + 2 add hl, bc push bc - ld a, [hQuotient] + ldh a, [hQuotient] ld b, a - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] ld c, a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld d, a ld a, [hld] sub d @@ -7265,7 +7265,7 @@ GiveExperiencePoints: call EmptyBattleTextBox call LoadTileMapToTempTileMap ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a .skip_animation farcall LevelUpHappinessMod @@ -7364,14 +7364,14 @@ GiveExperiencePoints: ld c, wEnemyMonEnd - wEnemyMonBaseStats .count_loop2 xor a - ld [hDividend + 0], a + ldh [hDividend + 0], a ld a, [hl] - ld [hDividend + 1], a + ldh [hDividend + 1], a ld a, [wTempByteValue] - ld [hDivisor], a + ldh [hDivisor], a ld b, 2 call Divide - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld [hli], a dec c jr nz, .count_loop2 @@ -7381,19 +7381,19 @@ BoostExp: ; Multiply experience by 1.5x push bc ; load experience value - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld b, a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld c, a ; halve it srl b rr c ; add it back to the whole exp value add c - ld [hProduct + 3], a - ld a, [hProduct + 2] + ldh [hProduct + 3], a + ldh a, [hProduct + 2] adc b - ld [hProduct + 2], a + ldh [hProduct + 2], a pop bc ret @@ -7428,10 +7428,10 @@ AnimateExpBar: cp MAX_LEVEL jp nc, .finish - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld [wd004], a push af - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld [wd003], a push af xor a @@ -7464,11 +7464,11 @@ AnimateExpBar: .NoOverflow: ld d, MAX_LEVEL callfar CalcExpAtLevel - ld a, [hProduct + 1] + ldh a, [hProduct + 1] ld b, a - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld c, a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld d, a ld hl, wTempMonExp + 2 ld a, [hld] @@ -7539,9 +7539,9 @@ AnimateExpBar: call .LoopBarAnimation call TerminateExpBarSound pop af - ld [hProduct + 2], a + ldh [hProduct + 2], a pop af - ld [hProduct + 3], a + ldh [hProduct + 3], a .finish pop bc @@ -7568,11 +7568,11 @@ AnimateExpBar: call PlaceExpBar pop de ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld c, d call DelayFrames xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a pop bc ld a, c cp b @@ -7584,11 +7584,11 @@ AnimateExpBar: call PlaceExpBar pop de ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld c, d call DelayFrames xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a dec d jr nz, .min_number_of_frames ld d, 1 @@ -7599,7 +7599,7 @@ AnimateExpBar: jr nz, .anim_loop .end_animation ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ret SendOutMonText: @@ -7623,16 +7623,16 @@ SendOutMonText: ; compute enemy helth remaining as a percentage xor a - ld [hMultiplicand + 0], a + ldh [hMultiplicand + 0], a ld hl, wEnemyMonHP ld a, [hli] ld [wEnemyHPAtTimeOfPlayerSwitch], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hl] ld [wEnemyHPAtTimeOfPlayerSwitch + 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] @@ -7643,10 +7643,10 @@ SendOutMonText: rr b ld a, b ld b, 4 - ld [hDivisor], a + ldh [hDivisor], a call Divide - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld hl, JumpText_GoMon cp 70 jr nc, .skip_to_textbox @@ -7706,14 +7706,14 @@ WithdrawMonText: 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] @@ -7724,11 +7724,11 @@ WithdrawMonText: rr b ld a, b ld b, 4 - ld [hDivisor], a + ldh [hDivisor], a call Divide pop bc pop de - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld hl, TextJump_ThatsEnoughComeBack and a ret z @@ -7826,17 +7826,17 @@ CalcExpBar: ; back up the next level exp, and subtract the two levels ld hl, hMultiplicand + 2 ld a, [hl] - ld [hMathBuffer + 2], a + ldh [hMathBuffer + 2], a pop bc sub b ld [hld], a ld a, [hl] - ld [hMathBuffer + 1], a + ldh [hMathBuffer + 1], a pop bc sbc b ld [hld], a ld a, [hl] - ld [hMathBuffer], a + ldh [hMathBuffer], a pop bc sbc b ld [hl], a @@ -7852,25 +7852,25 @@ CalcExpBar: ld a, [de] dec de ld c, a - ld a, [hMathBuffer + 2] + ldh a, [hMathBuffer + 2] sub c ld [hld], a ld a, [de] dec de ld b, a - ld a, [hMathBuffer + 1] + ldh a, [hMathBuffer + 1] sbc b ld [hld], a ld a, [de] ld c, a - ld a, [hMathBuffer] + ldh a, [hMathBuffer] sbc c ld [hld], a xor a ld [hl], a ; multiply by 64 ld a, $40 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply pop af ld c, a @@ -7894,10 +7894,10 @@ CalcExpBar: .done ld a, c - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld b, a ld a, $40 sub b @@ -7959,14 +7959,14 @@ DropPlayerSub: ret GetBattleMonBackpic_DoAnim: - ld a, [hBattleTurn] + ldh a, [hBattleTurn] push af xor a - ld [hBattleTurn], a + ldh [hBattleTurn], a ld a, BANK(BattleAnimCommands) rst FarCall pop af - ld [hBattleTurn], a + ldh [hBattleTurn], a ret GetEnemyMonFrontpic: @@ -7996,13 +7996,13 @@ DropEnemySub: ret GetEnemyMonFrontpic_DoAnim: - ld a, [hBattleTurn] + ldh a, [hBattleTurn] push af call SetEnemyTurn ld a, BANK(BattleAnimCommands) rst FarCall pop af - ld [hBattleTurn], a + ldh [hBattleTurn], a ret StartBattle: @@ -8034,7 +8034,7 @@ BattleIntro: ld [wTempBattleMonSpecies], a ld [wBattleMenuCursorBuffer], a xor a - ld [hMapAnims], a + ldh [hMapAnims], a farcall PlayBattleMusic farcall ShowLinkBattleParticipants farcall FindFirstAliveMonAndStartBattle @@ -8051,7 +8051,7 @@ BattleIntro: ld hl, rLCDC set rLCDC_WINDOW_TILEMAP, [hl] ; select 9C00-9FFF xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a call EmptyBattleTextBox hlcoord 9, 7 lb bc, 5, 11 @@ -8064,7 +8064,7 @@ BattleIntro: cp WILD_BATTLE call z, UpdateEnemyHUD ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ret LoadTrainerOrWildMonPic: @@ -8085,26 +8085,26 @@ InitEnemy: jp InitEnemyWildmon ; wild BackUpBGMap2: - ld a, [rSVBK] + ldh a, [rSVBK] push af ld a, BANK(wDecompressScratch) - ld [rSVBK], a + ldh [rSVBK], a ld hl, wDecompressScratch ld bc, $40 tiles ; vBGMap3 - vBGMap2 ld a, $2 call ByteFill - ld a, [rVBK] + ldh a, [rVBK] push af ld a, $1 - ld [rVBK], a + ldh [rVBK], a ld de, wDecompressScratch hlbgcoord 0, 0 ; vBGMap2 lb bc, BANK(BackUpBGMap2), $40 call Request2bpp pop af - ld [rVBK], a + ldh [rVBK], a pop af - ld [rSVBK], a + ldh [rSVBK], a ret InitEnemyTrainer: @@ -8126,7 +8126,7 @@ InitEnemyTrainer: ld de, vTiles2 callfar GetTrainerPic xor a - ld [hGraphicStartTile], a + ldh [hGraphicStartTile], a dec a ld [wEnemyItemState], a hlcoord 12, 0 @@ -8190,7 +8190,7 @@ InitEnemyWildmon: predef GetAnimatedFrontpic xor a ld [wTrainerClass], a - ld [hGraphicStartTile], a + ldh [hGraphicStartTile], a hlcoord 12, 0 lb bc, 7, 7 predef PlaceGraphic @@ -8906,41 +8906,41 @@ InitBattleDisplay: call _LoadBattleFontsHPBar call .BlankBGMap xor a - ld [hMapAnims], a - ld [hSCY], a + ldh [hMapAnims], a + ldh [hSCY], a ld a, $90 - ld [hWY], a - ld [rWY], a + ldh [hWY], a + ldh [rWY], a call WaitBGMap xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a farcall BattleIntroSlidingPics ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld a, $31 - ld [hGraphicStartTile], a + ldh [hGraphicStartTile], a hlcoord 2, 6 lb bc, 6, 6 predef PlaceGraphic xor a - ld [hWY], a - ld [rWY], a + ldh [hWY], a + ldh [rWY], a call WaitBGMap call HideSprites ld b, SCGB_BATTLE_COLORS call GetSGBLayout call SetPalettes ld a, $90 - ld [hWY], a + ldh [hWY], a xor a - ld [hSCX], a + ldh [hSCX], a ret .BlankBGMap: - ld a, [rSVBK] + ldh a, [rSVBK] push af ld a, BANK(wDecompressScratch) - ld [rSVBK], a + ldh [rSVBK], a ld hl, wDecompressScratch ld bc, wScratchAttrMap - wDecompressScratch @@ -8953,7 +8953,7 @@ InitBattleDisplay: call Request2bpp pop af - ld [rSVBK], a + ldh [rSVBK], a ret .InitBackPic: @@ -8995,21 +8995,21 @@ GetTrainerBackpic: ret CopyBackpic: - ld a, [rSVBK] + ldh a, [rSVBK] push af ld a, BANK(wDecompressScratch) - ld [rSVBK], a + ldh [rSVBK], a ld hl, vTiles0 ld de, vTiles2 tile $31 - ld a, [hROMBank] + ldh a, [hROMBank] ld b, a ld c, $31 call Get2bpp pop af - ld [rSVBK], a + ldh [rSVBK], a call .LoadTrainerBackpicAsOAM ld a, $31 - ld [hGraphicStartTile], a + ldh [hGraphicStartTile], a hlcoord 2, 6 lb bc, 6, 6 predef PlaceGraphic @@ -9018,7 +9018,7 @@ CopyBackpic: .LoadTrainerBackpicAsOAM: ld hl, wVirtualOAMSprite00 xor a - ld [hMapObjectIndexBuffer], a + ldh [hMapObjectIndexBuffer], a ld b, 6 ld e, (SCREEN_WIDTH + 1) * TILE_WIDTH .outer_loop @@ -9029,10 +9029,10 @@ CopyBackpic: inc hl ld [hl], e ; x inc hl - ld a, [hMapObjectIndexBuffer] + ldh a, [hMapObjectIndexBuffer] ld [hli], a ; tile id inc a - ld [hMapObjectIndexBuffer], a + ldh [hMapObjectIndexBuffer], a ld a, PAL_BATTLE_OB_PLAYER ld [hli], a ; attributes ld a, d @@ -9040,9 +9040,9 @@ CopyBackpic: ld d, a dec c jr nz, .inner_loop - ld a, [hMapObjectIndexBuffer] + ldh a, [hMapObjectIndexBuffer] add $3 - ld [hMapObjectIndexBuffer], a + ldh [hMapObjectIndexBuffer], a ld a, e add 1 * TILE_WIDTH ld e, a @@ -9074,7 +9074,7 @@ BattleStartMessage: xor a ld [wNumHits], a ld a, 1 - ld [hBattleTurn], a + ldh [hBattleTurn], a ld a, 1 ld [wBattleAnimParam], a ld de, ANIM_SEND_OUT_MON diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index 91c021a72..8ad52ef3c 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -130,7 +130,7 @@ BattleCommand_CheckTurn: ld a, EFFECTIVE ld [wTypeModifier], a - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jp nz, CheckEnemyTurn @@ -171,7 +171,7 @@ CheckPlayerTurn: ld hl, UpdatePlayerHUD call CallBattleCore ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld hl, wPlayerSubStatus1 res SUBSTATUS_NIGHTMARE, [hl] jr .not_asleep @@ -402,7 +402,7 @@ CheckEnemyTurn: ld hl, UpdateEnemyHUD call CallBattleCore ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld hl, wEnemySubStatus1 res SUBSTATUS_NIGHTMARE, [hl] jr .not_asleep @@ -623,7 +623,7 @@ HitConfusion: ld hl, UpdatePlayerHUD call CallBattleCore ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld c, TRUE call DoPlayerDamage jp BattleCommand_RaiseSub @@ -632,7 +632,7 @@ BattleCommand_CheckObedience: ; checkobedience ; Enemy can't disobey - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ret nz @@ -945,7 +945,7 @@ BattleCommand_UsedMoveText: ret CheckUserIsCharging: - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, [wPlayerCharging] ; player jr z, .end @@ -962,7 +962,7 @@ BattleCommand_DoTurn: ld de, wPlayerSubStatus3 ld bc, wPlayerTurnsTaken - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .proceed @@ -999,7 +999,7 @@ BattleCommand_DoTurn: bit SUBSTATUS_TRANSFORMED, a ret nz - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld hl, wPartyMon1PP @@ -1022,7 +1022,7 @@ BattleCommand_DoTurn: ret c .consume_pp - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, [wCurMoveNum] jr z, .okay @@ -1091,7 +1091,7 @@ BattleCommand_DoTurn: db -1 CheckMimicUsed: - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, [wCurMoveNum] jr z, .player @@ -1133,7 +1133,7 @@ BattleCommand_Critical: and a ret z - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld hl, wEnemyMonItem ld a, [wEnemyMonSpecies] @@ -1232,7 +1232,7 @@ BattleCommand_Stab: ld d, a ld e, [hl] - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .go ; Who Attacks and who Defends @@ -1339,48 +1339,48 @@ BattleCommand_Stab: ld [wAttackMissed], a xor a .NotImmune: - ld [hMultiplier], a + ldh [hMultiplier], a add b ld [wTypeModifier], a xor a - ld [hMultiplicand + 0], a + ldh [hMultiplicand + 0], a ld hl, wCurDamage 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, [hProduct + 1] + ldh a, [hProduct + 1] ld b, a - ld a, [hProduct + 2] + ldh a, [hProduct + 2] or b ld b, a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] or b jr z, .ok ; This is a very convoluted way to get back that we've essentially dealt no damage. ; Take the product and divide it by 10. ld a, 10 - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] ld b, a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] or b jr nz, .ok ld a, 1 - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a .ok - ld a, [hMultiplicand + 1] + ldh a, [hMultiplicand + 1] ld [hli], a - ld a, [hMultiplicand + 2] + ldh a, [hMultiplicand + 2] ld [hl], a pop bc pop hl @@ -1402,7 +1402,7 @@ BattleCommand_Stab: BattleCheckTypeMatchup: ld hl, wEnemyMonType1 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, CheckTypeMatchup ld hl, wBattleMonType1 @@ -1455,21 +1455,21 @@ CheckTypeMatchup: .Yup: xor a - ld [hDividend + 0], a - ld [hMultiplicand + 0], a - ld [hMultiplicand + 1], a + ldh [hDividend + 0], a + ldh [hMultiplicand + 0], a + ldh [hMultiplicand + 1], a ld a, [hli] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [wTypeMatchup] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, 10 - ld [hDivisor], a + ldh [hDivisor], a push bc ld b, 4 call Divide pop bc - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld [wTypeMatchup], a jr .TypesLoop @@ -1523,12 +1523,12 @@ BattleCommand_DamageVariation: .go ; Start with the maximum damage. xor a - ld [hMultiplicand + 0], a + ldh [hMultiplicand + 0], 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 ; Multiply by 85-100%... .loop @@ -1537,20 +1537,20 @@ BattleCommand_DamageVariation: cp 85 percent + 1 jr c, .loop - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; ...divide by 100%... ld a, $ff ; 100% - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide ; ...to get .85-1.00x damage. - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] ld hl, wCurDamage ld [hli], a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld [hl], a ret @@ -1588,7 +1588,7 @@ BattleCommand_CheckHit: ld a, [wPlayerMoveStruct + MOVE_ACC] ld b, a - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .BrightPowder ld a, [wEnemyMoveStruct + MOVE_ACC] @@ -1769,7 +1769,7 @@ BattleCommand_CheckHit: ret .StatModifiers: - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ; load the user's accuracy into b and the opponent's evasion into c. @@ -1805,10 +1805,10 @@ BattleCommand_CheckHit: ld c, a ; store the base move accuracy for math ops xor a - ld [hMultiplicand + 0], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 0], a + ldh [hMultiplicand + 1], a ld a, [hl] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a push hl ld d, 2 ; do this twice, once for the user's accuracy and once for the target's evasion @@ -1824,22 +1824,22 @@ BattleCommand_CheckHit: pop bc ; multiply by the first byte in that row... ld a, [hli] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; ... and divide by the second byte ld a, [hl] - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide ; minimum accuracy is $0001 - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld b, a - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] or b jr nz, .min_accuracy - ld [hQuotient + 1], a + ldh [hQuotient + 1], a ld a, 1 - ld [hQuotient + 2], a + ldh [hQuotient + 2], a .min_accuracy ; do the same thing to the target's evasion @@ -1848,9 +1848,9 @@ BattleCommand_CheckHit: jr nz, .accuracy_loop ; if the result is more than 2 bytes, max out at 100% - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] and a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] jr z, .finish_accuracy ld a, $ff @@ -1871,7 +1871,7 @@ BattleCommand_EffectChance: push hl ld hl, wPlayerMoveStruct + MOVE_CHANCE - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_move_chance ld hl, wEnemyMoveStruct + MOVE_CHANCE @@ -1967,7 +1967,7 @@ BattleCommand_MoveAnimNoSub: and a jp nz, BattleCommand_MoveDelay - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld de, wPlayerRolloutCount ld a, BATTLEANIM_ENEMY_DAMAGE @@ -2039,7 +2039,7 @@ BattleCommand_StatDownAnim: and a jp nz, BattleCommand_MoveDelay - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, BATTLEANIM_ENEMY_STAT_DOWN jr z, BattleCommand_StatUpDownAnim @@ -2060,9 +2060,9 @@ BattleCommand_StatUpDownAnim: BattleCommand_SwitchTurn: ; switchturn - ld a, [hBattleTurn] + ldh a, [hBattleTurn] xor 1 - ld [hBattleTurn], a + ldh [hBattleTurn], a ret BattleCommand_RaiseSub: @@ -2159,7 +2159,7 @@ BattleCommand_ApplyDamage: push bc call .update_damage_taken ld c, FALSE - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .damage_player call DoEnemyDamage @@ -2194,7 +2194,7 @@ BattleCommand_ApplyDamage: ret nz ld de, wPlayerDamageTaken + 1 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .got_damage_taken ld de, wEnemyDamageTaken + 1 @@ -2271,7 +2271,7 @@ endr ld [wKickCounter], a call LoadMoveAnim ld c, TRUE - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jp nz, DoEnemyDamage jp DoPlayerDamage @@ -2331,7 +2331,7 @@ BattleCommand_StartLoop: ; startloop ld hl, wPlayerRolloutCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wEnemyRolloutCount @@ -2371,7 +2371,7 @@ BattleCommand_CheckFaint: ; Ends the move effect if the opponent faints. ld hl, wEnemyMonHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_hp ld hl, wBattleMonHP @@ -2389,7 +2389,7 @@ BattleCommand_CheckFaint: ld hl, TookDownWithItText call StdBattleTextBox - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld hl, wEnemyMonMaxHP + 1 bccoord 2, 2 ; hp bar @@ -2468,7 +2468,7 @@ BattleCommand_BuildOpponentRage: ret z ld de, wEnemyRageCounter - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .player ld de, wPlayerRageCounter @@ -2492,7 +2492,7 @@ BattleCommand_RageDamage: ld a, [wCurDamage + 1] ld l, a ld c, a - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, [wPlayerRageCounter] jr z, .rage_loop @@ -2525,7 +2525,7 @@ EndMoveEffect: DittoMetalPowder: ld a, MON_SPECIES call BattlePartyAttr - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, [hl] jr nz, .Ditto @@ -2561,7 +2561,7 @@ DittoMetalPowder: BattleCommand_DamageStats: ; damagestats - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jp nz, EnemyAttackDamage @@ -2706,7 +2706,7 @@ CheckDamageStatsCritical: push hl push bc - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .enemy ld a, [wPlayerMoveStructType] @@ -2784,7 +2784,7 @@ SpeciesItemBoost: ld a, MON_SPECIES call BattlePartyAttr - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, [hl] jr z, .CompareSpecies @@ -2900,7 +2900,7 @@ BattleCommand_ClearMissDamage: HitSelfInConfusion: call ResetDamage - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld hl, wBattleMonDefense ld de, wPlayerScreens @@ -3049,12 +3049,12 @@ BattleCommand_DamageCalc: ; * 100 + item effect amount ld a, c add 100 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; / 100 ld a, 100 - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide @@ -3065,44 +3065,44 @@ BattleCommand_DamageCalc: ; Update wCurDamage (capped at 997). ld hl, wCurDamage ld b, [hl] - ld a, [hProduct + 3] + ldh a, [hProduct + 3] add b - ld [hProduct + 3], a + ldh [hProduct + 3], a jr nc, .dont_cap_1 - ld a, [hProduct + 2] + ldh a, [hProduct + 2] inc a - ld [hProduct + 2], a + ldh [hProduct + 2], a and a jr z, .Cap .dont_cap_1 - ld a, [hProduct] + ldh a, [hProduct] ld b, a - ld a, [hProduct + 1] + ldh a, [hProduct + 1] or a jr nz, .Cap - ld a, [hProduct + 2] + ldh a, [hProduct + 2] cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1) jr c, .dont_cap_2 cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1) + 1 jr nc, .Cap - ld a, [hProduct + 3] + ldh a, [hProduct + 3] cp LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1) jr nc, .Cap .dont_cap_2 inc hl - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld b, [hl] add b ld [hld], a - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld b, [hl] adc b ld [hl], a @@ -3146,20 +3146,20 @@ BattleCommand_DamageCalc: ret z ; x2 - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] add a - ld [hProduct + 3], a + ldh [hProduct + 3], a - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] rl a - ld [hProduct + 2], a + ldh [hProduct + 2], a ; Cap at $ffff. ret nc ld a, $ff - ld [hProduct + 2], a - ld [hProduct + 3], a + ldh [hProduct + 2], a + ldh [hProduct + 3], a ret @@ -3169,7 +3169,7 @@ BattleCommand_ConstantDamage: ; constantdamage ld hl, wBattleMonLevel - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_turn ld hl, wEnemyMonLevel @@ -3216,7 +3216,7 @@ BattleCommand_ConstantDamage: .super_fang ld hl, wEnemyMonHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_hp ld hl, wBattleMonHP @@ -3245,50 +3245,50 @@ BattleCommand_ConstantDamage: .reversal ld hl, wBattleMonHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .reversal_got_hp ld hl, wEnemyMonHP .reversal_got_hp xor a - ld [hDividend], a - ld [hMultiplicand + 0], a + ldh [hDividend], a + ldh [hMultiplicand + 0], a ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hli] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, $30 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, [hli] ld b, a ld a, [hl] - ld [hDivisor], a + ldh [hDivisor], a ld a, b and a jr z, .skip_to_divide - ld a, [hProduct + 4] + ldh a, [hProduct + 4] 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 [hDividend + 3], a + ldh [hDividend + 3], a ld a, b - ld [hDividend + 2], a + ldh [hDividend + 2], a .skip_to_divide ld b, 4 call Divide - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld b, a ld hl, FlailReversalPower @@ -3300,7 +3300,7 @@ BattleCommand_ConstantDamage: jr .reversal_loop .break_loop - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, [hl] jr nz, .notPlayersTurn @@ -3521,7 +3521,7 @@ DoSubstituteDamage: call StdBattleTextBox ld de, wEnemySubstituteHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_hp ld de, wPlayerSubstituteHP @@ -3662,7 +3662,7 @@ BattleCommand_SleepTarget: .CheckAIRandomFail: ; Enemy turn - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .dont_fail @@ -3758,7 +3758,7 @@ BattleCommand_Poison: and a jr nz, .failed - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .dont_sample_failure @@ -3819,7 +3819,7 @@ BattleCommand_Poison: .check_toxic ld a, BATTLE_VARS_SUBSTATUS5_OPP call GetBattleVarAddr - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld de, wEnemyToxicCount jr z, .ok @@ -3832,7 +3832,7 @@ BattleCommand_Poison: CheckIfTargetIsPoisonType: ld de, wEnemyMonType1 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld de, wBattleMonType1 @@ -3868,20 +3868,20 @@ SapHealth: ld hl, wCurDamage ld a, [hli] srl a - ld [hDividend], a + ldh [hDividend], a ld b, a ld a, [hl] rr a - ld [hDividend + 1], a + ldh [hDividend + 1], a or b jr nz, .at_least_one ld a, 1 - ld [hDividend + 1], a + ldh [hDividend + 1], a .at_least_one ld hl, wBattleMonHP ld de, wBattleMonMaxHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .battlemonhp ld hl, wEnemyMonHP @@ -3906,12 +3906,12 @@ SapHealth: ld [bc], a ; Add hDividend to current HP and copy it to little endian wBuffer5/6 - ld a, [hDividend + 1] + ldh a, [hDividend + 1] ld b, [hl] add b ld [hld], a ld [wBuffer5], a - ld a, [hDividend] + ldh a, [hDividend] ld b, [hl] adc b ld [hli], a @@ -3943,7 +3943,7 @@ SapHealth: inc de .finish - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a hlcoord 10, 9 ld a, $1 @@ -4005,7 +4005,7 @@ Defrost: xor a ld [hl], a - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, [wCurOTMon] ld hl, wOTPartyMon1Status @@ -4067,7 +4067,7 @@ BattleCommand_FreezeTarget: call OpponentCantMove call EndRechargeOpp ld hl, wEnemyJustGotFrozen - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .finish ld hl, wPlayerJustGotFrozen @@ -4193,7 +4193,7 @@ RaiseStat: ld a, b ld [wLoweredStat], a ld hl, wPlayerStatLevels - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_stat_levels ld hl, wEnemyStatLevels @@ -4230,7 +4230,7 @@ RaiseStat: jr nc, .done_calcing_stats ld hl, wBattleMonStats + 1 ld de, wPlayerStats - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_stats_pointer ld hl, wEnemyMonStats + 1 @@ -4254,7 +4254,7 @@ RaiseStat: sbc HIGH(MAX_STAT_VALUE) jp z, .stats_already_max .not_already_max - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .calc_player_stats call CalcEnemyStats @@ -4290,7 +4290,7 @@ MinimizeDropSub: ld bc, wPlayerMinimized ld hl, DropPlayerSub - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .do_player ld bc, wEnemyMinimized @@ -4307,7 +4307,7 @@ MinimizeDropSub: ret nc xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a call CallBattleCore call WaitBGMap jp BattleCommand_MoveDelay @@ -4390,7 +4390,7 @@ BattleCommand_StatDown: jp nz, .Mist ld hl, wEnemyStatLevels - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .GetStatLevel ld hl, wPlayerStatLevels @@ -4416,7 +4416,7 @@ BattleCommand_StatDown: .ComputerMiss: ; Computer opponents have a 25% chance of failing. - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .DidntMiss @@ -4467,7 +4467,7 @@ BattleCommand_StatDown: push hl ld hl, wEnemyMonAttack + 1 ld de, wEnemyStats - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .do_enemy ld hl, wBattleMonAttack + 1 @@ -4613,7 +4613,7 @@ TryLowerStat: ret z .not_min - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .Player @@ -4728,7 +4728,7 @@ LowerStat: ld [wLoweredStat], a ld hl, wPlayerStatLevels - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_target ld hl, wEnemyStatLevels @@ -4759,7 +4759,7 @@ LowerStat: push hl ld hl, wBattleMonStats + 1 ld de, wPlayerStats - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_target_2 ld hl, wEnemyMonStats + 1 @@ -4771,7 +4771,7 @@ LowerStat: jr z, .failed .accuracy_evasion - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .player @@ -4825,25 +4825,25 @@ BattleCommand_Curl: BattleCommand_RaiseSubNoAnim: ld hl, GetBattleMonBackpic - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .PlayerTurn ld hl, GetEnemyMonFrontpic .PlayerTurn: xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a call CallBattleCore jp WaitBGMap BattleCommand_LowerSubNoAnim: ld hl, DropPlayerSub - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .PlayerTurn ld hl, DropEnemySub .PlayerTurn: xor a - ld [hBGMapMode], a + ldh [hBGMapMode], a call CallBattleCore jp WaitBGMap @@ -4901,51 +4901,51 @@ CalcStats: add hl, bc xor a - ld [hMultiplicand + 0], a + ldh [hMultiplicand + 0], 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 inc de 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 - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] ld b, a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] or b jr nz, .check_maxed_out ld a, 1 - ld [hQuotient + 2], a + ldh [hQuotient + 2], a jr .not_maxed_out .check_maxed_out - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] cp LOW(MAX_STAT_VALUE) ld a, b sbc HIGH(MAX_STAT_VALUE) jr c, .not_maxed_out ld a, LOW(MAX_STAT_VALUE) - ld [hQuotient + 2], a + ldh [hQuotient + 2], a ld a, HIGH(MAX_STAT_VALUE) - ld [hQuotient + 1], a + ldh [hQuotient + 1], a .not_maxed_out pop bc - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] ld [bc], a inc bc - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld [bc], a inc bc pop hl @@ -4961,7 +4961,7 @@ BattleCommand_CheckRampage: ; checkrampage ld de, wPlayerRolloutCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .player ld de, wEnemyRolloutCount @@ -5004,7 +5004,7 @@ BattleCommand_Rampage: ret nz ld de, wPlayerRolloutCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld de, wEnemyRolloutCount @@ -5042,7 +5042,7 @@ BattleCommand_ForceSwitch: jp z, .fail cp BATTLETYPE_SUICUNE jp z, .fail - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jp nz, .force_player_switch ld a, [wAttackMissed] @@ -5285,7 +5285,7 @@ BattleCommand_EndLoop: ld de, wPlayerRolloutCount ld bc, wPlayerDamageTaken - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_addrs ld de, wEnemyRolloutCount @@ -5321,7 +5321,7 @@ BattleCommand_EndLoop: jr .done_loop .beat_up - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .check_ot_beat_up ld a, [wPartyCount] @@ -5377,7 +5377,7 @@ BattleCommand_EndLoop: res SUBSTATUS_IN_LOOP, [hl] ld hl, PlayerHitTimesText - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_hit_n_times_text ld hl, EnemyHitTimesText @@ -5463,7 +5463,7 @@ CheckOpponentWentFirst: push bc ld a, [wEnemyGoesFirst] ; 0 if player went first ld b, a - ld a, [hBattleTurn] ; 0 if it's the player's turn + ldh a, [hBattleTurn] ; 0 if it's the player's turn xor b ; 1 if opponent went first pop bc ret @@ -5506,7 +5506,7 @@ BattleCommand_OHKO: ld hl, wEnemyMonLevel ld de, wBattleMonLevel ld bc, wPlayerMoveStruct + MOVE_ACC - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_move_accuracy push hl @@ -5708,7 +5708,7 @@ BattleCommand_TrapTarget: ret nz ld hl, wEnemyWrapCount ld de, wEnemyTrappingMove - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_trap ld hl, wPlayerWrapCount @@ -5764,7 +5764,7 @@ BattleCommand_Recoil: ; recoil ld hl, wBattleMonMaxHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_hp ld hl, wEnemyMonMaxHP @@ -5811,7 +5811,7 @@ BattleCommand_Recoil: ld [hl], a .dont_ko hlcoord 10, 9 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, 1 jr z, .animate_hp_bar @@ -5875,7 +5875,7 @@ BattleCommand_Confuse: jr nz, BattleCommand_Confuse_CheckSnore_Swagger_ConfuseHit BattleCommand_FinishConfusingTarget: ld bc, wEnemyConfuseCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_confuse_count ld bc, wPlayerConfuseCount @@ -5949,7 +5949,7 @@ BattleCommand_Paralyze: jp StdBattleTextBox .no_item_protection - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .dont_sample_failure @@ -5983,7 +5983,7 @@ BattleCommand_Paralyze: call DelayFrames call AnimateCurrentMove ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ld a, BATTLE_VARS_STATUS_OPP call GetBattleVarAddr set PAR, [hl] @@ -6015,7 +6015,7 @@ CheckMoveTypeMatchesTarget: push hl ld hl, wEnemyMonType1 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wBattleMonType1 @@ -6112,7 +6112,7 @@ BattleCommand_ResetStats: ld hl, wEnemyStatLevels call .Fill - ld a, [hBattleTurn] + ldh a, [hBattleTurn] push af call SetPlayerTurn @@ -6121,7 +6121,7 @@ BattleCommand_ResetStats: call CalcEnemyStats pop af - ld [hBattleTurn], a + ldh [hBattleTurn], a call AnimateCurrentMove @@ -6141,7 +6141,7 @@ BattleCommand_Heal: ld de, wBattleMonHP ld hl, wBattleMonMaxHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_hp ld de, wEnemyMonHP @@ -6180,7 +6180,7 @@ BattleCommand_Heal: ld hl, RestedText .no_status_to_heal call StdBattleTextBox - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .calc_enemy_stats call CalcPlayerStats @@ -6223,7 +6223,7 @@ INCLUDE "engine/battle/move_effects/transform.asm" BattleSideCopy: ; Copy bc bytes from hl to de if it's the player's turn. ; Copy bc bytes from de to hl if it's the enemy's turn. - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .copy @@ -6252,7 +6252,7 @@ ClearLastMove: ret ResetActorDisable: - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .player @@ -6272,7 +6272,7 @@ BattleCommand_Screen: ld hl, wPlayerScreens ld bc, wPlayerLightScreenCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_screens_pointer ld hl, wEnemyScreens @@ -6375,7 +6375,7 @@ CheckUserMove: ; Return z if the user has move a. ld b, a ld de, wBattleMonMoves - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld de, wEnemyMonMoves @@ -6397,7 +6397,7 @@ CheckUserMove: ResetTurn: ld hl, wPlayerCharging - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .player ld hl, wEnemyCharging @@ -6452,7 +6452,7 @@ BattleCommand_Defrost: ; Don't update the enemy's party struct in a wild battle. - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .party @@ -6505,7 +6505,7 @@ INCLUDE "engine/battle/move_effects/safeguard.asm" SafeCheckSafeguard: push hl ld hl, wEnemyScreens - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_turn ld hl, wPlayerScreens @@ -6518,7 +6518,7 @@ SafeCheckSafeguard: BattleCommand_CheckSafeguard: ; checksafeguard ld hl, wEnemyScreens - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_turn ld hl, wPlayerScreens @@ -6560,7 +6560,7 @@ BattleCommand_TimeBasedHealContinue: ld hl, wBattleMonMaxHP ld de, wBattleMonHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .start ld hl, wEnemyMonMaxHP @@ -6653,7 +6653,7 @@ BattleCommand_DoubleMinimizeDamage: ; doubleminimizedamage ld hl, wEnemyMinimized - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wPlayerMinimized @@ -6693,7 +6693,7 @@ CheckHiddenOpponent: GetUserItem: ; Return the effect of the user's item in bc, and its id at hl. ld hl, wBattleMonItem - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .go ld hl, wEnemyMonItem @@ -6704,7 +6704,7 @@ GetUserItem: GetOpponentItem: ; Return the effect of the opponent's item in bc, and its id at hl. ld hl, wEnemyMonItem - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .go ld hl, wBattleMonItem @@ -6775,7 +6775,7 @@ PlayDamageAnim: ld [wFXAnimID], a - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, BATTLEANIM_ENEMY_DAMAGE jr z, .player diff --git a/engine/battle/hidden_power.asm b/engine/battle/hidden_power.asm index 537fe4354..9cc5a36e9 100644 --- a/engine/battle/hidden_power.asm +++ b/engine/battle/hidden_power.asm @@ -2,7 +2,7 @@ HiddenPowerDamage: ; Override Hidden Power's type and power based on the user's DVs. ld hl, wBattleMonDVs - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_dvs ld hl, wEnemyMonDVs diff --git a/engine/battle/link_result.asm b/engine/battle/link_result.asm index 0dd339fe4..07426d523 100644 --- a/engine/battle/link_result.asm +++ b/engine/battle/link_result.asm @@ -83,13 +83,13 @@ DetermineLinkBattleResult: jr z, .next dec hl xor a - ld [hDividend + 0], a + ldh [hDividend + 0], a ld a, [hli] - ld [hDividend + 1], a + ldh [hDividend + 1], a ld a, [hli] - ld [hDividend + 2], a + ldh [hDividend + 2], a xor a - ld [hDividend + 3], a + ldh [hDividend + 3], a ld a, [hli] ld b, a ld a, [hld] @@ -97,13 +97,13 @@ DetermineLinkBattleResult: rr a srl b rr a - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] add e ld e, a - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] adc d ld d, a dec hl diff --git a/engine/battle/misc.asm b/engine/battle/misc.asm index 8985385a0..5a7b44cb1 100644 --- a/engine/battle/misc.asm +++ b/engine/battle/misc.asm @@ -1,7 +1,7 @@ _DisappearUser: xor a - ld [hBGMapMode], a - ld a, [hBattleTurn] + ldh [hBGMapMode], a + ldh a, [hBattleTurn] and a jr z, .player call GetEnemyFrontpicCoords @@ -21,8 +21,8 @@ _AppearUserLowerSub: AppearUser: xor a - ld [hBGMapMode], a - ld a, [hBattleTurn] + ldh [hBGMapMode], a + ldh a, [hBattleTurn] and a jr z, .player call GetEnemyFrontpicCoords @@ -32,11 +32,11 @@ AppearUser: call GetPlayerBackpicCoords ld a, $31 .okay - ld [hGraphicStartTile], a + ldh [hGraphicStartTile], a predef PlaceGraphic FinishAppearDisappearUser: ld a, $1 - ld [hBGMapMode], a + ldh [hBGMapMode], a ret GetEnemyFrontpicCoords: @@ -101,32 +101,32 @@ DoWeatherModifiers: .ApplyModifier: xor a - ld [hMultiplicand + 0], a + ldh [hMultiplicand + 0], a ld hl, wCurDamage ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hl] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a inc de ld a, [de] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, 10 - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide - ld a, [hQuotient + 0] + ldh a, [hQuotient + 0] and a ld bc, -1 jr nz, .Update - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] ld b, a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld c, a or b jr nz, .Update @@ -153,7 +153,7 @@ DoBadgeTypeBoosts: and a ret nz - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ret nz diff --git a/engine/battle/move_effects/baton_pass.asm b/engine/battle/move_effects/baton_pass.asm index 7f922b214..46baeb75f 100644 --- a/engine/battle/move_effects/baton_pass.asm +++ b/engine/battle/move_effects/baton_pass.asm @@ -1,7 +1,7 @@ BattleCommand_BatonPass: ; batonpass - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jp nz, .Enemy diff --git a/engine/battle/move_effects/beat_up.asm b/engine/battle/move_effects/beat_up.asm index 673fc46c6..bd0307f40 100644 --- a/engine/battle/move_effects/beat_up.asm +++ b/engine/battle/move_effects/beat_up.asm @@ -2,7 +2,7 @@ BattleCommand_BeatUp: ; beatup call ResetDamage - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jp nz, .enemy_beats_up @@ -210,7 +210,7 @@ GetBeatupMonLocation: push bc ld c, a ld b, 0 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld hl, wPartyMon1Species jr z, .got_species diff --git a/engine/battle/move_effects/bide.asm b/engine/battle/move_effects/bide.asm index 871e0e7a8..cfb3f3ab2 100644 --- a/engine/battle/move_effects/bide.asm +++ b/engine/battle/move_effects/bide.asm @@ -7,7 +7,7 @@ BattleCommand_StoreEnergy: ret z ld hl, wPlayerRolloutCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .check_still_storing_energy ld hl, wEnemyRolloutCount @@ -28,7 +28,7 @@ BattleCommand_StoreEnergy: ld [hl], a ld hl, wPlayerDamageTaken + 1 ld de, wPlayerCharging ; player - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .player ld hl, wEnemyDamageTaken + 1 @@ -74,7 +74,7 @@ BattleCommand_UnleashEnergy: ld de, wPlayerDamageTaken ld bc, wPlayerRolloutCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_damage ld de, wEnemyDamageTaken diff --git a/engine/battle/move_effects/conversion.asm b/engine/battle/move_effects/conversion.asm index f9307056c..4b13f29dd 100644 --- a/engine/battle/move_effects/conversion.asm +++ b/engine/battle/move_effects/conversion.asm @@ -3,7 +3,7 @@ BattleCommand_Conversion: ld hl, wBattleMonMoves ld de, wBattleMonType1 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_moves ld hl, wEnemyMonMoves diff --git a/engine/battle/move_effects/conversion2.asm b/engine/battle/move_effects/conversion2.asm index 14a7e257a..d67725f9c 100644 --- a/engine/battle/move_effects/conversion2.asm +++ b/engine/battle/move_effects/conversion2.asm @@ -5,7 +5,7 @@ BattleCommand_Conversion2: and a jr nz, .failed ld hl, wBattleMonType1 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_type ld hl, wEnemyMonType1 diff --git a/engine/battle/move_effects/curse.asm b/engine/battle/move_effects/curse.asm index 4861e9a37..fb59d9b67 100644 --- a/engine/battle/move_effects/curse.asm +++ b/engine/battle/move_effects/curse.asm @@ -3,7 +3,7 @@ BattleCommand_Curse: ld de, wBattleMonType1 ld bc, wPlayerStatLevels - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .go ld de, wEnemyMonType1 diff --git a/engine/battle/move_effects/disable.asm b/engine/battle/move_effects/disable.asm index 44017e30d..7f5cfaea0 100644 --- a/engine/battle/move_effects/disable.asm +++ b/engine/battle/move_effects/disable.asm @@ -7,7 +7,7 @@ BattleCommand_Disable: ld de, wEnemyDisableCount ld hl, wEnemyMonMoves - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_moves ld de, wPlayerDisableCount @@ -33,7 +33,7 @@ BattleCommand_Disable: cp b jr nz, .loop - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld hl, wEnemyMonPP jr z, .got_pp @@ -55,7 +55,7 @@ BattleCommand_Disable: ld [de], a call AnimateCurrentMove ld hl, wDisabledMove - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .got_disabled_move_pointer inc hl diff --git a/engine/battle/move_effects/encore.asm b/engine/battle/move_effects/encore.asm index f436fd970..3ac107e2b 100644 --- a/engine/battle/move_effects/encore.asm +++ b/engine/battle/move_effects/encore.asm @@ -3,7 +3,7 @@ BattleCommand_Encore: ld hl, wEnemyMonMoves ld de, wEnemyEncoreCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wBattleMonMoves @@ -47,7 +47,7 @@ BattleCommand_Encore: ld [de], a call CheckOpponentWentFirst jr nz, .finish_move - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .force_last_enemy_move diff --git a/engine/battle/move_effects/false_swipe.asm b/engine/battle/move_effects/false_swipe.asm index 0d3f7d47c..e2e0c6f10 100644 --- a/engine/battle/move_effects/false_swipe.asm +++ b/engine/battle/move_effects/false_swipe.asm @@ -4,7 +4,7 @@ BattleCommand_FalseSwipe: ; Makes sure wCurDamage < MonHP ld hl, wEnemyMonHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_hp ld hl, wBattleMonHP diff --git a/engine/battle/move_effects/frustration.asm b/engine/battle/move_effects/frustration.asm index 3d395b510..e9986bdf3 100644 --- a/engine/battle/move_effects/frustration.asm +++ b/engine/battle/move_effects/frustration.asm @@ -3,25 +3,25 @@ BattleCommand_FrustrationPower: push bc ld hl, wBattleMonHappiness - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_happiness ld hl, wEnemyMonHappiness .got_happiness ld a, $ff sub [hl] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a xor a - ld [hMultiplicand + 0], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 0], a + ldh [hMultiplicand + 1], a ld a, 10 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, 25 - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld d, a pop bc ret diff --git a/engine/battle/move_effects/fury_cutter.asm b/engine/battle/move_effects/fury_cutter.asm index 6aa6b7838..a12848499 100644 --- a/engine/battle/move_effects/fury_cutter.asm +++ b/engine/battle/move_effects/fury_cutter.asm @@ -2,7 +2,7 @@ BattleCommand_FuryCutter: ; furycutter ld hl, wPlayerFuryCutterCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .go ld hl, wEnemyFuryCutterCount @@ -42,7 +42,7 @@ ResetFuryCutterCount: push hl ld hl, wPlayerFuryCutterCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .reset ld hl, wEnemyFuryCutterCount diff --git a/engine/battle/move_effects/future_sight.asm b/engine/battle/move_effects/future_sight.asm index c28841b35..0cb0b43ba 100644 --- a/engine/battle/move_effects/future_sight.asm +++ b/engine/battle/move_effects/future_sight.asm @@ -3,7 +3,7 @@ BattleCommand_CheckFutureSight: ld hl, wPlayerFutureSightCount ld de, wPlayerFutureSightDamage - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wEnemyFutureSightCount @@ -41,7 +41,7 @@ BattleCommand_FutureSight: ld [hl], b .AlreadyChargingFutureSight: ld hl, wPlayerFutureSightCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .GotFutureSightCount ld hl, wEnemyFutureSightCount @@ -57,7 +57,7 @@ BattleCommand_FutureSight: call StdBattleTextBox call BattleCommand_RaiseSub ld de, wPlayerFutureSightDamage - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .StoreDamage ld de, wEnemyFutureSightDamage diff --git a/engine/battle/move_effects/heal_bell.asm b/engine/battle/move_effects/heal_bell.asm index 2570a53ba..a9923429e 100644 --- a/engine/battle/move_effects/heal_bell.asm +++ b/engine/battle/move_effects/heal_bell.asm @@ -5,7 +5,7 @@ BattleCommand_HealBell: call GetBattleVarAddr res SUBSTATUS_NIGHTMARE, [hl] ld de, wPartyMon1Status - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_status ld de, wOTPartyMon1Status @@ -28,7 +28,7 @@ BattleCommand_HealBell: ld hl, BellChimedText call StdBattleTextBox - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jp z, CalcPlayerStats jp CalcEnemyStats diff --git a/engine/battle/move_effects/leech_seed.asm b/engine/battle/move_effects/leech_seed.asm index 5602e7f62..7cb14c27c 100644 --- a/engine/battle/move_effects/leech_seed.asm +++ b/engine/battle/move_effects/leech_seed.asm @@ -7,7 +7,7 @@ BattleCommand_LeechSeed: jr nz, .evaded ld de, wEnemyMonType1 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld de, wBattleMonType1 diff --git a/engine/battle/move_effects/mimic.asm b/engine/battle/move_effects/mimic.asm index b1c6608fa..30b531572 100644 --- a/engine/battle/move_effects/mimic.asm +++ b/engine/battle/move_effects/mimic.asm @@ -7,7 +7,7 @@ BattleCommand_Mimic: and a jr nz, .fail ld hl, wBattleMonMoves - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .player_turn ld hl, wEnemyMonMoves diff --git a/engine/battle/move_effects/pay_day.asm b/engine/battle/move_effects/pay_day.asm index ba1dce884..9f59dbb08 100644 --- a/engine/battle/move_effects/pay_day.asm +++ b/engine/battle/move_effects/pay_day.asm @@ -5,7 +5,7 @@ BattleCommand_PayDay: ld hl, wStringBuffer1 ld [hli], a - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, [wBattleMonLevel] jr z, .ok diff --git a/engine/battle/move_effects/present.asm b/engine/battle/move_effects/present.asm index f0949558f..35713927b 100644 --- a/engine/battle/move_effects/present.asm +++ b/engine/battle/move_effects/present.asm @@ -54,7 +54,7 @@ BattleCommand_Present: call AnimateCurrentMove call BattleCommand_SwitchTurn ld hl, AICheckPlayerMaxHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_hp_fn_pointer ld hl, AICheckEnemyMaxHP diff --git a/engine/battle/move_effects/protect.asm b/engine/battle/move_effects/protect.asm index 9025d2f4b..1e540923d 100644 --- a/engine/battle/move_effects/protect.asm +++ b/engine/battle/move_effects/protect.asm @@ -14,7 +14,7 @@ BattleCommand_Protect: ProtectChance: ld de, wPlayerProtectCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .asm_37637 ld de, wEnemyProtectCount diff --git a/engine/battle/move_effects/psych_up.asm b/engine/battle/move_effects/psych_up.asm index 02fdef5d2..c32316ccd 100644 --- a/engine/battle/move_effects/psych_up.asm +++ b/engine/battle/move_effects/psych_up.asm @@ -3,7 +3,7 @@ BattleCommand_PsychUp: ld hl, wEnemyStatLevels ld de, wPlayerStatLevels - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .pointers_correct ; It's the enemy's turn, so swap the pointers. @@ -35,7 +35,7 @@ BattleCommand_PsychUp: inc de dec b jr nz, .loop2 - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .calc_enemy_stats call CalcPlayerStats diff --git a/engine/battle/move_effects/pursuit.asm b/engine/battle/move_effects/pursuit.asm index 18c358144..f8979fb9f 100644 --- a/engine/battle/move_effects/pursuit.asm +++ b/engine/battle/move_effects/pursuit.asm @@ -3,7 +3,7 @@ BattleCommand_Pursuit: ; Double damage if the opponent is switching. ld hl, wEnemyIsSwitching - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wPlayerIsSwitching diff --git a/engine/battle/move_effects/rapid_spin.asm b/engine/battle/move_effects/rapid_spin.asm index 0dc8b7de2..6e40726db 100644 --- a/engine/battle/move_effects/rapid_spin.asm +++ b/engine/battle/move_effects/rapid_spin.asm @@ -12,7 +12,7 @@ BattleCommand_ClearHazards: ld hl, wPlayerScreens ld de, wPlayerWrapCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_screens_wrap ld hl, wEnemyScreens diff --git a/engine/battle/move_effects/return.asm b/engine/battle/move_effects/return.asm index d3071d23a..18a2d10f4 100644 --- a/engine/battle/move_effects/return.asm +++ b/engine/battle/move_effects/return.asm @@ -2,24 +2,24 @@ BattleCommand_HappinessPower: ; happinesspower push bc ld hl, wBattleMonHappiness - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wEnemyMonHappiness .ok xor a - ld [hMultiplicand + 0], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 0], a + ldh [hMultiplicand + 1], a ld a, [hl] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, 10 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, 25 - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld d, a pop bc ret diff --git a/engine/battle/move_effects/rollout.asm b/engine/battle/move_effects/rollout.asm index de4bfcaa6..e2f810e6a 100644 --- a/engine/battle/move_effects/rollout.asm +++ b/engine/battle/move_effects/rollout.asm @@ -4,7 +4,7 @@ BattleCommand_CheckCurl: ; checkcurl ld de, wPlayerRolloutCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld de, wEnemyRolloutCount @@ -31,7 +31,7 @@ BattleCommand_RolloutPower: ret nz ld hl, wPlayerRolloutCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_rollout_count ld hl, wEnemyRolloutCount diff --git a/engine/battle/move_effects/safeguard.asm b/engine/battle/move_effects/safeguard.asm index a926bdccc..cb5a4857e 100644 --- a/engine/battle/move_effects/safeguard.asm +++ b/engine/battle/move_effects/safeguard.asm @@ -3,7 +3,7 @@ BattleCommand_Safeguard: ld hl, wPlayerScreens ld de, wPlayerSafeguardCount - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .ok ld hl, wEnemyScreens diff --git a/engine/battle/move_effects/sketch.asm b/engine/battle/move_effects/sketch.asm index a5b0d1c03..2d9705106 100644 --- a/engine/battle/move_effects/sketch.asm +++ b/engine/battle/move_effects/sketch.asm @@ -27,7 +27,7 @@ BattleCommand_Sketch: ld e, l ; Get the battle move structs. ld hl, wBattleMonMoves - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .get_last_move ld hl, wEnemyMonMoves @@ -74,7 +74,7 @@ BattleCommand_Sketch: ld [hl], a pop bc - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .user_trainer ld a, [wBattleMode] diff --git a/engine/battle/move_effects/sleep_talk.asm b/engine/battle/move_effects/sleep_talk.asm index ae2d252b7..92bff2602 100644 --- a/engine/battle/move_effects/sleep_talk.asm +++ b/engine/battle/move_effects/sleep_talk.asm @@ -5,7 +5,7 @@ BattleCommand_SleepTalk: ld a, [wAttackMissed] and a jr nz, .fail - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld hl, wBattleMonMoves + 1 ld a, [wDisabledMove] @@ -77,7 +77,7 @@ BattleCommand_SleepTalk: ret .check_has_usable_move - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, [wDisabledMove] jr z, .got_move_2 diff --git a/engine/battle/move_effects/spikes.asm b/engine/battle/move_effects/spikes.asm index 1eca7ae53..c22787d6d 100644 --- a/engine/battle/move_effects/spikes.asm +++ b/engine/battle/move_effects/spikes.asm @@ -2,7 +2,7 @@ BattleCommand_Spikes: ; spikes ld hl, wEnemyScreens - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .asm_3768e ld hl, wPlayerScreens diff --git a/engine/battle/move_effects/spite.asm b/engine/battle/move_effects/spite.asm index 71252fe22..031cdb71f 100644 --- a/engine/battle/move_effects/spite.asm +++ b/engine/battle/move_effects/spite.asm @@ -6,7 +6,7 @@ BattleCommand_Spite: jp nz, .failed ld bc, PARTYMON_STRUCT_LENGTH ; ???? ld hl, wEnemyMonMoves - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_moves ld hl, wBattleMonMoves @@ -63,7 +63,7 @@ BattleCommand_Spite: call GetBattleVar bit SUBSTATUS_TRANSFORMED, a jr nz, .transformed - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .not_wildmon ld a, [wBattleMode] diff --git a/engine/battle/move_effects/substitute.asm b/engine/battle/move_effects/substitute.asm index 8f14bc315..bafd4c460 100644 --- a/engine/battle/move_effects/substitute.asm +++ b/engine/battle/move_effects/substitute.asm @@ -4,7 +4,7 @@ BattleCommand_Substitute: call BattleCommand_MoveDelay ld hl, wBattleMonMaxHP ld de, wPlayerSubstituteHP - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .got_hp ld hl, wEnemyMonMaxHP @@ -46,7 +46,7 @@ BattleCommand_Substitute: ld hl, wPlayerWrapCount ld de, wPlayerTrappingMove - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .player ld hl, wEnemyWrapCount diff --git a/engine/battle/move_effects/teleport.asm b/engine/battle/move_effects/teleport.asm index 1c67ef112..55eb6675f 100644 --- a/engine/battle/move_effects/teleport.asm +++ b/engine/battle/move_effects/teleport.asm @@ -16,7 +16,7 @@ BattleCommand_Teleport: bit SUBSTATUS_CANT_RUN, a jr nz, .failed ; Only need to check these next things if it's your turn - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .enemy_turn ; Can't teleport from a trainer battle diff --git a/engine/battle/move_effects/thief.asm b/engine/battle/move_effects/thief.asm index 34a9699fc..47270d6c2 100644 --- a/engine/battle/move_effects/thief.asm +++ b/engine/battle/move_effects/thief.asm @@ -1,7 +1,7 @@ BattleCommand_Thief: ; thief - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .enemy diff --git a/engine/battle/move_effects/transform.asm b/engine/battle/move_effects/transform.asm index ef8071290..ab94da79c 100644 --- a/engine/battle/move_effects/transform.asm +++ b/engine/battle/move_effects/transform.asm @@ -30,7 +30,7 @@ BattleCommand_Transform: call ResetActorDisable ld hl, wBattleMonSpecies ld de, wEnemyMonSpecies - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .got_mon_species ld hl, wEnemyMonSpecies @@ -46,7 +46,7 @@ BattleCommand_Transform: inc de ld bc, NUM_MOVES call CopyBytes - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr z, .mimic_enemy_backup ld a, [de] @@ -112,7 +112,7 @@ BattleCommand_Transform: call BattleSideCopy call _CheckBattleScene jr c, .mimic_anims - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a ld a, [wPlayerMinimized] jr z, .got_byte diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm index 0a537b64e..bf32a1e21 100644 --- a/engine/battle/read_trainer_party.asm +++ b/engine/battle/read_trainer_party.asm @@ -315,9 +315,9 @@ ComputeTrainerReward: ld hl, wBattleReward xor a ld [hli], a - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld [hli], a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld [hl], a ret diff --git a/engine/battle/sliding_intro.asm b/engine/battle/sliding_intro.asm index 6b866c6d8..bda859cb4 100644 --- a/engine/battle/sliding_intro.asm +++ b/engine/battle/sliding_intro.asm @@ -1,22 +1,22 @@ BattleIntroSlidingPics: - ld a, [rSVBK] + ldh a, [rSVBK] push af ld a, BANK(wLYOverrides) - ld [rSVBK], a + ldh [rSVBK], a call .subfunction1 - ld a, rSCX - $ff00 - ld [hLCDCPointer], a + ld a, LOW(rSCX) + ldh [hLCDCPointer], a call .subfunction2 xor a - ld [hLCDCPointer], a + ldh [hLCDCPointer], a pop af - ld [rSVBK], a + ldh [rSVBK], a ret .subfunction1 call .subfunction4 ld a, $90 - ld [hSCX], a + ldh [hSCX], a ld a, %11100100 call DmgToCgbBGPals lb de, %11100100, %11100100 @@ -31,11 +31,11 @@ BattleIntroSlidingPics: .loop1 push af .loop2 - ld a, [rLY] + ldh a, [rLY] cp $60 jr c, .loop2 ld a, d - ld [hSCX], a + ldh [hSCX], a call .subfunction5 inc e inc e diff --git a/engine/battle/start_battle.asm b/engine/battle/start_battle.asm index f5fc4a6b0..12d657e39 100644 --- a/engine/battle/start_battle.asm +++ b/engine/battle/start_battle.asm @@ -14,7 +14,7 @@ ShowLinkBattleParticipants: FindFirstAliveMonAndStartBattle: xor a - ld [hMapAnims], a + ldh [hMapAnims], a call DelayFrame ld b, PARTY_LENGTH ld hl, wPartyMon1HP @@ -36,14 +36,14 @@ FindFirstAliveMonAndStartBattle: predef DoBattleTransition farcall _LoadBattleFontsHPBar ld a, 1 - ld [hBGMapMode], a + ldh [hBGMapMode], a call ClearSprites call ClearTileMap xor a - ld [hBGMapMode], a - ld [hWY], a - ld [rWY], a - ld [hMapAnims], a + ldh [hBGMapMode], a + ldh [hWY], a + ldh [rWY], a + ldh [hMapAnims], a ret PlayBattleMusic: diff --git a/engine/battle/trainer_huds.asm b/engine/battle/trainer_huds.asm index 7a971e21f..2f0e93b6e 100644 --- a/engine/battle/trainer_huds.asm +++ b/engine/battle/trainer_huds.asm @@ -1,6 +1,6 @@ BattleStart_TrainerHuds: ld a, $e4 - ld [rOBP0], a + ldh [rOBP0], a call LoadBallIconGFX call ShowPlayerMonsRemaining ld a, [wBattleMode] @@ -10,7 +10,7 @@ BattleStart_TrainerHuds: EnemySwitch_TrainerHud: ld a, $e4 - ld [rOBP0], a + ldh [rOBP0], a call LoadBallIconGFX jp ShowOTTrainerMonsRemaining @@ -253,5 +253,5 @@ _ShowLinkBattleParticipants: call GetSGBLayout call SetPalettes ld a, $e4 - ld [rOBP0], a + ldh [rOBP0], a ret diff --git a/engine/battle/used_move_text.asm b/engine/battle/used_move_text.asm index 8166094f2..656f2ba1f 100644 --- a/engine/battle/used_move_text.asm +++ b/engine/battle/used_move_text.asm @@ -8,7 +8,7 @@ UsedMoveText: ; this is a stream of text and asm from 105db9 to 105ef6 text_jump _ActorNameText start_asm - ld a, [hBattleTurn] + ldh a, [hBattleTurn] and a jr nz, .start |