Use labels instead of constants for HRAM

Use explicit ldh instruction to access HRAM locations, don't rely on optimizing ld
This commit is contained in:
Rangi
2018-08-25 14:28:22 -04:00
parent 376c64468b
commit eb1e3636bb
243 changed files with 4706 additions and 4661 deletions

View File

@@ -258,7 +258,7 @@ PokeBallEffect:
jp z, .skip_hp_calc
ld a, b
ld [hMultiplicand + 2], a
ldh [hMultiplicand + 2], a
ld hl, wEnemyMonHP
ld b, [hl]
@@ -300,20 +300,20 @@ PokeBallEffect:
push bc
ld a, b
sub c
ld [hMultiplier], a
ldh [hMultiplier], a
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
call Multiply
pop bc
ld a, b
ld [hDivisor], a
ldh [hDivisor], a
ld b, $4
call Divide
ld a, [hQuotient + 2]
ldh a, [hQuotient + 2]
and a
jr nz, .statuscheck
ld a, 1
@@ -389,7 +389,7 @@ PokeBallEffect:
ld a, d
ld [wFXAnimID + 1], a
xor a
ld [hBattleTurn], a
ldh [hBattleTurn], a
ld [wBuffer2], a
ld [wNumHits], a
predef PlayBattleAnim
@@ -1313,11 +1313,11 @@ RareCandyEffect:
ld a, MON_EXP
call GetPartyParamLocation
ld a, [hMultiplicand]
ldh a, [hMultiplicand]
ld [hli], a
ld a, [hMultiplicand + 1]
ldh a, [hMultiplicand + 1]
ld [hli], a
ld a, [hMultiplicand + 2]
ldh a, [hMultiplicand + 2]
ld [hl], a
ld a, MON_MAXHP
@@ -1628,7 +1628,7 @@ BitterBerryEffect:
res SUBSTATUS_CONFUSED, [hl]
xor a
ld [hBattleTurn], a
ldh [hBattleTurn], a
call UseItemText
ld hl, ConfusedNoMoreText
@@ -1770,7 +1770,7 @@ ItemActionText:
ItemActionTextWaitButton:
xor a
ld [hBGMapMode], a
ldh [hBGMapMode], a
hlcoord 0, 0
ld bc, wTileMapEnd - wTileMap
ld a, " "
@@ -1778,7 +1778,7 @@ ItemActionTextWaitButton:
ld a, [wPartyMenuActionText]
call ItemActionText
ld a, $1
ld [hBGMapMode], a
ldh [hBGMapMode], a
ld c, 50
call DelayFrames
jp WaitPressAorB_BlinkCursor
@@ -1956,16 +1956,16 @@ GetOneFifthMaxHP:
ld a, MON_MAXHP
call GetPartyParamLocation
ld a, [hli]
ld [hDividend + 0], a
ldh [hDividend + 0], a
ld a, [hl]
ld [hDividend + 1], a
ldh [hDividend + 1], a
ld a, 5
ld [hDivisor], a
ldh [hDivisor], a
ld b, 2
call Divide
ld a, [hQuotient + 1]
ldh a, [hQuotient + 1]
ld d, a
ld a, [hQuotient + 2]
ldh a, [hQuotient + 2]
ld e, a
pop bc
ret
@@ -2156,7 +2156,7 @@ XItemEffect:
inc hl
ld b, [hl]
xor a
ld [hBattleTurn], a
ldh [hBattleTurn], a
ld [wAttackMissed], a
ld [wEffectFailed], a
farcall RaiseStat
@@ -2624,7 +2624,7 @@ UseBallInTrainerBattle:
ld [wFXAnimID + 1], a
xor a
ld [wBattleAnimParam], a
ld [hBattleTurn], a
ldh [hBattleTurn], a
ld [wNumHits], a
predef PlayBattleAnim
ld hl, BlockedTheBallText
@@ -2788,13 +2788,13 @@ ComputeMaxPP:
push bc
; Divide the base PP by 5.
ld a, [de]
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
ld a, 5
ld [hDivisor], a
ldh [hDivisor], a
ld b, 4
call Divide
; Get the number of PP, which are bits 6 and 7 of the PP value stored in RAM.
@@ -2814,7 +2814,7 @@ ComputeMaxPP:
; Since this would overflow into bit 6, we prevent that from happening
; by decreasing the extra amount of PP each PP Up provides, resulting
; in a maximum of 61.
ld a, [hQuotient + 2]
ldh a, [hQuotient + 2]
cp $8
jr c, .okay
ld a, $7