Use HIGH() and LOW()

This commit is contained in:
Rangi 2020-07-07 11:10:29 -04:00
parent bbc257476f
commit 45ed05decf
22 changed files with 89 additions and 87 deletions

View file

@ -82,9 +82,9 @@ rLCDC_DEFAULT EQU %11100011
ld a, CONNECTION_NOT_ESTABLISHED
ldh [hSerialConnectionStatus], a
ld h, vBGMap0 / $100
ld h, HIGH(vBGMap0)
call ClearBgMap
ld h, vBGMap1 / $100
ld h, HIGH(vBGMap1)
call ClearBgMap
ld a, rLCDC_DEFAULT

View file

@ -197,17 +197,17 @@ CalcStat::
ldh [hMultiplicand+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + 10
.noCarry4
ldh a, [hMultiplicand+1] ; check for overflow (>999)
cp 999 / $100 + 1
cp HIGH(MAX_STAT_VALUE) + 1
jr nc, .overflow
cp 999 / $100
cp HIGH(MAX_STAT_VALUE)
jr c, .noOverflow
ldh a, [hMultiplicand+2]
cp 999 % $100 + 1
cp LOW(MAX_STAT_VALUE) + 1
jr c, .noOverflow
.overflow
ld a, 999 / $100 ; overflow: cap at 999
ld a, HIGH(MAX_STAT_VALUE) ; overflow: cap at 999
ldh [hMultiplicand+1], a
ld a, 999 % $100
ld a, LOW(MAX_STAT_VALUE)
ldh [hMultiplicand+2], a
.noOverflow
pop bc

View file

@ -20,8 +20,8 @@ UncompressSpriteData::
; initializes necessary data to load a sprite and runs UncompressSpriteDataLoop
_UncompressSpriteData::
ld hl, sSpriteBuffer1
ld c, (2*SPRITEBUFFERSIZE) % $100
ld b, (2*SPRITEBUFFERSIZE) / $100
ld c, LOW(2 * SPRITEBUFFERSIZE)
ld b, HIGH(2 * SPRITEBUFFERSIZE)
xor a
call FillMemory ; clear sprite buffer 1 and 2
ld a, $1