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

@@ -105,7 +105,7 @@ StubbedTrainerRankings_BugContestScore:
ret
ld a, BANK(sTrainerRankingBugContestScore)
call GetSRAMBank
ld a, [hProduct]
ldh a, [hProduct]
ld hl, sTrainerRankingBugContestScore
cp [hl]
jr z, .isLowByteHigher
@@ -114,15 +114,15 @@ StubbedTrainerRankings_BugContestScore:
.isLowByteHigher
inc hl
ld a, [hMultiplicand]
ldh a, [hMultiplicand]
cp [hl]
jr c, .done
dec hl
.newHighScore
ld a, [hProduct]
ldh a, [hProduct]
ld [hli], a
ld a, [hMultiplicand]
ldh a, [hMultiplicand]
ld [hl], a
.done
@@ -375,7 +375,7 @@ StubbedTrainerRankings_LinkBattles:
StubbedTrainerRankings_Splash:
ret
; Only counts if its the players turn
ld a, [hBattleTurn]
ldh a, [hBattleTurn]
and a
ret nz
ld hl, sTrainerRankingSplash
@@ -410,7 +410,7 @@ StubbedTrainerRankings_ColosseumDraws: ; draw
StubbedTrainerRankings_Selfdestruct:
ret
; Only counts if its the players turn
ld a, [hBattleTurn]
ldh a, [hBattleTurn]
and a
ret nz
ld hl, sTrainerRankingSelfdestruct
@@ -586,9 +586,9 @@ _MobilePrintNum::
; hl: where to print the converted string
push bc
xor a
ld [hPrintNum1], a
ld [hPrintNum2], a
ld [hPrintNum3], a
ldh [hPrintNum1], a
ldh [hPrintNum2], a
ldh [hPrintNum3], a
ld a, b
and $f
cp $1
@@ -599,29 +599,29 @@ _MobilePrintNum::
jr z, .three_bytes
; four bytes
ld a, [de]
ld [hPrintNum1], a
ldh [hPrintNum1], a
inc de
.three_bytes
ld a, [de]
ld [hPrintNum2], a
ldh [hPrintNum2], a
inc de
.two_bytes
ld a, [de]
ld [hPrintNum3], a
ldh [hPrintNum3], a
inc de
.one_byte
ld a, [de]
ld [hPrintNum4], a
ldh [hPrintNum4], a
inc de
push de
xor a
ld [hPrintNum9], a
ldh [hPrintNum9], a
ld a, b
ld [hPrintNum10], a
ldh [hPrintNum10], a
ld a, c
cp 2
jr z, .two_digits
@@ -668,7 +668,7 @@ endr
.two_digits
ld c, 0
ld a, [hPrintNum4]
ldh a, [hPrintNum4]
.mod_ten_loop
cp 10
jr c, .simple_divide_done
@@ -678,9 +678,9 @@ endr
.simple_divide_done
ld b, a
ld a, [hPrintNum9]
ldh a, [hPrintNum9]
or c
ld [hPrintNum9], a
ldh [hPrintNum9], a
jr nz, .create_digit
call .LoadMinusTenIfNegative
jr .done
@@ -714,53 +714,53 @@ endr
ld a, [de]
dec de
ld b, a
ld a, [hPrintNum4]
ldh a, [hPrintNum4]
sub b
ld [hPrintNum8], a
ldh [hPrintNum8], a
ld a, [de]
dec de
ld b, a
ld a, [hPrintNum3]
ldh a, [hPrintNum3]
sbc b
ld [hPrintNum7], a
ldh [hPrintNum7], a
ld a, [de]
dec de
ld b, a
ld a, [hPrintNum2]
ldh a, [hPrintNum2]
sbc b
ld [hPrintNum6], a
ldh [hPrintNum6], a
ld a, [de]
inc de
inc de
inc de
ld b, a
ld a, [hPrintNum1]
ldh a, [hPrintNum1]
sbc b
ld [hPrintNum5], a
ldh [hPrintNum5], a
jr c, .asm_1062eb
ld a, [hPrintNum5]
ld [hPrintNum1], a
ld a, [hPrintNum6]
ld [hPrintNum2], a
ld a, [hPrintNum7]
ld [hPrintNum3], a
ld a, [hPrintNum8]
ld [hPrintNum4], a
ldh a, [hPrintNum5]
ldh [hPrintNum1], a
ldh a, [hPrintNum6]
ldh [hPrintNum2], a
ldh a, [hPrintNum7]
ldh [hPrintNum3], a
ldh a, [hPrintNum8]
ldh [hPrintNum4], a
inc c
jr .asm_1062b4
.asm_1062eb
ld a, [hPrintNum9]
ldh a, [hPrintNum9]
or c
jr z, .LoadMinusTenIfNegative
ld a, -10
add c
ld [hl], a
ld [hPrintNum9], a
ldh [hPrintNum9], a
ret
.LoadMinusTenIfNegative:
ld a, [hPrintNum10]
ldh a, [hPrintNum10]
bit 7, a
ret z
@@ -768,12 +768,12 @@ endr
ret
.Function1062ff:
ld a, [hPrintNum10]
ldh a, [hPrintNum10]
bit 7, a
jr nz, .asm_10630d
bit 6, a
jr z, .asm_10630d
ld a, [hPrintNum9]
ldh a, [hPrintNum9]
and a
ret z
@@ -988,8 +988,8 @@ Function106442:
ld a, $36
call Function3e32
xor a
ld [hMobile], a
ld [hMobileReceive], a
ldh [hMobile], a
ldh [hMobileReceive], a
ld a, [wMobileCommsJumptableIndex]
inc a
ld [wMobileCommsJumptableIndex], a
@@ -1048,10 +1048,10 @@ Function10649b:
ret
Function1064c3:
ld a, [rSVBK]
ldh a, [rSVBK]
push af
ld a, $6
ld [rSVBK], a
ldh [rSVBK], a
push bc
push hl
ld hl, Function3f88
@@ -1060,14 +1060,14 @@ Function1064c3:
pop hl
pop bc
pop af
ld [rSVBK], a
ldh [rSVBK], a
jr asm_1064ed
Function1064d8:
ld a, [rSVBK]
ldh a, [rSVBK]
push af
ld a, $6
ld [rSVBK], a
ldh [rSVBK], a
push bc
push hl
ld hl, Function3f9f
@@ -1076,25 +1076,25 @@ Function1064d8:
pop hl
pop bc
pop af
ld [rSVBK], a
ldh [rSVBK], a
jr asm_1064ed
asm_1064ed
ld de, wDecompressScratch
ld b, $0
ld a, [rSVBK]
ldh a, [rSVBK]
push af
ld a, $6
ld [rSVBK], a
ld a, [rVBK]
ldh [rSVBK], a
ldh a, [rVBK]
push af
ld a, $1
ld [rVBK], a
ldh [rVBK], a
call Get2bpp
pop af
ld [rVBK], a
ldh [rVBK], a
pop af
ld [rSVBK], a
ldh [rSVBK], a
ret
Function10650a: