Specify the ldh instruction, don't turn ld into ldh

This commit is contained in:
Rangi 2020-07-06 19:03:05 -04:00
parent c480632d54
commit 772fcc7588
219 changed files with 2556 additions and 2556 deletions

View file

@ -15,7 +15,7 @@ _AddPartyMon::
ret nc ; return if the party is already full
ld [de], a
ld a, [de]
ld [hNewPartyLength], a
ldh [hNewPartyLength], a
add e
ld e, a
jr nc, .noCarry
@ -32,7 +32,7 @@ _AddPartyMon::
jr z, .next2
ld hl, wEnemyMonOT
.next2
ld a, [hNewPartyLength]
ldh a, [hNewPartyLength]
dec a
call SkipFixedLengthTextEntries
ld d, h
@ -44,7 +44,7 @@ _AddPartyMon::
and a
jr nz, .skipNaming
ld hl, wPartyMonNicks
ld a, [hNewPartyLength]
ldh a, [hNewPartyLength]
dec a
call SkipFixedLengthTextEntries
ld a, NAME_MON_SCREEN
@ -57,7 +57,7 @@ _AddPartyMon::
jr z, .next3
ld hl, wEnemyMons
.next3
ld a, [hNewPartyLength]
ldh a, [hNewPartyLength]
dec a
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
@ -129,10 +129,10 @@ _AddPartyMon::
xor a
ld b, a
call CalcStat ; calc HP stat (set cur Hp to max HP)
ld a, [hMultiplicand+1]
ldh a, [hMultiplicand+1]
ld [de], a
inc de
ld a, [hMultiplicand+2]
ldh a, [hMultiplicand+2]
ld [de], a
inc de
xor a
@ -204,13 +204,13 @@ _AddPartyMon::
callab CalcExperience
pop de
inc de
ld a, [hExperience] ; write experience
ldh a, [hExperience] ; write experience
ld [de], a
inc de
ld a, [hExperience + 1]
ldh a, [hExperience + 1]
ld [de], a
inc de
ld a, [hExperience + 2]
ldh a, [hExperience + 2]
ld [de], a
xor a
ld b, NUM_STATS * 2

View file

@ -1,6 +1,6 @@
DisplayPCMainMenu::
xor a
ld [hAutoBGTransferEnabled], a
ldh [hAutoBGTransferEnabled], a
call SaveScreenTilesToBuffer2
ld a, [wNumHoFTeams]
and a
@ -82,7 +82,7 @@ DisplayPCMainMenu::
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
ld a, 1
ld [hAutoBGTransferEnabled], a
ldh [hAutoBGTransferEnabled], a
ret
SomeonesPCText: db "SOMEONE's PC@"
@ -168,7 +168,7 @@ BillsPCMenu:
ld de, BoxNoPCText
call PlaceString
ld a, 1
ld [hAutoBGTransferEnabled], a
ldh [hAutoBGTransferEnabled], a
call Delay3
call HandleMenuInput
bit 1, a
@ -501,7 +501,7 @@ MonWasReleasedText:
text_end
CableClubLeftGameboy::
ld a, [hSerialConnectionStatus]
ldh a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK
ret z
ld a, [wSpritePlayerStateData1FacingDirection]
@ -518,7 +518,7 @@ CableClubLeftGameboy::
tx_pre_jump JustAMomentText
CableClubRightGameboy::
ld a, [hSerialConnectionStatus]
ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK
ret z
ld a, [wSpritePlayerStateData1FacingDirection]

View file

@ -11,7 +11,7 @@ TryEvolvingMon:
; this is only called after battle
; it is supposed to do level up evolutions, though there is a bug that allows item evolutions to occur
EvolutionAfterBattle:
ld a, [hTilesetType]
ldh a, [hTilesetType]
push af
xor a
ld [wEvolutionOccurred], a
@ -120,12 +120,12 @@ Evolution_PartyMonLoop: ; loop over party mons
ld c, 50
call DelayFrames
xor a
ld [hAutoBGTransferEnabled], a
ldh [hAutoBGTransferEnabled], a
coord hl, 0, 0
lb bc, 12, 20
call ClearScreenArea
ld a, $1
ld [hAutoBGTransferEnabled], a
ldh [hAutoBGTransferEnabled], a
ld a, $ff
ld [wUpdateSpritesEnabled], a
call ClearSprites
@ -245,7 +245,7 @@ Evolution_PartyMonLoop: ; loop over party mons
pop bc
pop hl
pop af
ld [hTilesetType], a
ldh [hTilesetType], a
ld a, [wLinkState]
cp LINK_STATE_TRADING
ret z

View file

@ -10,15 +10,15 @@ CalcLevelFromExperience::
push hl
ld hl, wLoadedMonExp + 2 ; current exp
; compare exp needed for level d with current exp
ld a, [hExperience + 2]
ldh a, [hExperience + 2]
ld c, a
ld a, [hld]
sub c
ld a, [hExperience + 1]
ldh a, [hExperience + 1]
ld c, a
ld a, [hld]
sbc c
ld a, [hExperience]
ldh a, [hExperience]
ld c, a
ld a, [hl]
sbc c
@ -38,56 +38,56 @@ CalcExperience::
add hl, bc
call CalcDSquared
ld a, d
ld [hMultiplier], a
ldh [hMultiplier], a
call Multiply
ld a, [hl]
and $f0
swap a
ld [hMultiplier], a
ldh [hMultiplier], a
call Multiply
ld a, [hli]
and $f
ld [hDivisor], a
ldh [hDivisor], a
ld b, $4
call Divide
ld a, [hQuotient + 1]
ldh a, [hQuotient + 1]
push af
ld a, [hQuotient + 2]
ldh a, [hQuotient + 2]
push af
ld a, [hQuotient + 3]
ldh a, [hQuotient + 3]
push af
call CalcDSquared
ld a, [hl]
and $7f
ld [hMultiplier], a
ldh [hMultiplier], a
call Multiply
ld a, [hProduct + 1]
ldh a, [hProduct + 1]
push af
ld a, [hProduct + 2]
ldh a, [hProduct + 2]
push af
ld a, [hProduct + 3]
ldh a, [hProduct + 3]
push af
ld a, [hli]
push af
xor a
ld [hMultiplicand], a
ld [hMultiplicand + 1], a
ldh [hMultiplicand], a
ldh [hMultiplicand + 1], a
ld a, d
ld [hMultiplicand + 2], a
ldh [hMultiplicand + 2], a
ld a, [hli]
ld [hMultiplier], a
ldh [hMultiplier], a
call Multiply
ld b, [hl]
ld a, [hProduct + 3]
ldh a, [hProduct + 3]
sub b
ld [hProduct + 3], a
ldh [hProduct + 3], a
ld b, $0
ld a, [hProduct + 2]
ldh a, [hProduct + 2]
sbc b
ld [hProduct + 2], a
ld a, [hProduct + 1]
ldh [hProduct + 2], a
ldh a, [hProduct + 1]
sbc b
ld [hProduct + 1], a
ldh [hProduct + 1], a
; The difference of the linear term and the constant term consists of 3 bytes
; starting at hProduct + 1. Below, hExperience (an alias of that address) will
; be used instead for the further work of adding or subtracting the squared
@ -96,54 +96,54 @@ CalcExperience::
and $80
jr nz, .subtractSquaredTerm ; check sign
pop bc
ld a, [hExperience + 2]
ldh a, [hExperience + 2]
add b
ld [hExperience + 2], a
ldh [hExperience + 2], a
pop bc
ld a, [hExperience + 1]
ldh a, [hExperience + 1]
adc b
ld [hExperience + 1], a
ldh [hExperience + 1], a
pop bc
ld a, [hExperience]
ldh a, [hExperience]
adc b
ld [hExperience], a
ldh [hExperience], a
jr .addCubedTerm
.subtractSquaredTerm
pop bc
ld a, [hExperience + 2]
ldh a, [hExperience + 2]
sub b
ld [hExperience + 2], a
ldh [hExperience + 2], a
pop bc
ld a, [hExperience + 1]
ldh a, [hExperience + 1]
sbc b
ld [hExperience + 1], a
ldh [hExperience + 1], a
pop bc
ld a, [hExperience]
ldh a, [hExperience]
sbc b
ld [hExperience], a
ldh [hExperience], a
.addCubedTerm
pop bc
ld a, [hExperience + 2]
ldh a, [hExperience + 2]
add b
ld [hExperience + 2], a
ldh [hExperience + 2], a
pop bc
ld a, [hExperience + 1]
ldh a, [hExperience + 1]
adc b
ld [hExperience + 1], a
ldh [hExperience + 1], a
pop bc
ld a, [hExperience]
ldh a, [hExperience]
adc b
ld [hExperience], a
ldh [hExperience], a
ret
; calculates d*d
CalcDSquared:
xor a
ld [hMultiplicand], a
ld [hMultiplicand + 1], a
ldh [hMultiplicand], a
ldh [hMultiplicand + 1], a
ld a, d
ld [hMultiplicand + 2], a
ld [hMultiplier], a
ldh [hMultiplicand + 2], a
ldh [hMultiplier], a
jp Multiply
INCLUDE "data/growth_rates.asm"

View file

@ -126,13 +126,13 @@ TryingToLearn:
call TextBoxBorder
coord hl, 6, 8
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
ld hl, wTopMenuItemY
ld a, 8
ld [hli], a ; wTopMenuItemY

View file

@ -40,7 +40,7 @@ DrawHP_:
push hl
call DrawHPBar
pop hl
ld a, [hFlagsFFF6]
ldh a, [hFlagsFFF6]
bit 0, a
jr z, .printFractionBelowBar
ld bc, $9 ; right of bar
@ -80,7 +80,7 @@ StatusScreen:
ld hl, wd72c
set 1, [hl]
ld a, $33
ld [rNR50], a ; Reduce the volume
ldh [rNR50], a ; Reduce the volume
call GBPalWhiteOutWithDelay3
call ClearScreen
call UpdateSprites
@ -101,10 +101,10 @@ StatusScreen:
ld hl, vChars2 + $720
lb bc, BANK(PTile), (PTileEnd - PTile) / $8
call CopyVideoDataDouble ; P (for PP), inline
ld a, [hTilesetType]
ldh a, [hTilesetType]
push af
xor a
ld [hTilesetType], a
ldh [hTilesetType], a
coord hl, 19, 1
lb bc, 6, 10
call DrawLineBox ; Draws the box around name, HP and status
@ -174,7 +174,7 @@ StatusScreen:
call PlayCry ; play Pokémon cry
call WaitForTextScrollButtonPress ; wait for button
pop af
ld [hTilesetType], a
ldh [hTilesetType], a
ret
.GetStringPointer
@ -298,11 +298,11 @@ StatsText:
next "SPECIAL@"
StatusScreen2:
ld a, [hTilesetType]
ldh a, [hTilesetType]
push af
xor a
ld [hTilesetType], a
ld [hAutoBGTransferEnabled], a
ldh [hTilesetType], a
ldh [hAutoBGTransferEnabled], a
ld bc, NUM_MOVES + 1
ld hl, wMoves
call FillMemory
@ -427,15 +427,15 @@ StatusScreen2:
coord hl, 9, 1
call PlaceString
ld a, $1
ld [hAutoBGTransferEnabled], a
ldh [hAutoBGTransferEnabled], a
call Delay3
call WaitForTextScrollButtonPress ; wait for button
pop af
ld [hTilesetType], a
ldh [hTilesetType], a
ld hl, wd72c
res 1, [hl]
ld a, $77
ld [rNR50], a
ldh [rNR50], a
call GBPalWhiteOut
jp ClearScreen
@ -447,13 +447,13 @@ CalcExpToLevelUp:
ld d, a
callab CalcExperience
ld hl, wLoadedMonExp + 2
ld a, [hExperience + 2]
ldh a, [hExperience + 2]
sub [hl]
ld [hld], a
ld a, [hExperience + 1]
ldh a, [hExperience + 1]
sbc [hl]
ld [hld], a
ld a, [hExperience]
ldh a, [hExperience]
sbc [hl]
ld [hld], a
ret