summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-07-07 11:10:29 -0400
committerRangi <remy.oukaour+rangi42@gmail.com>2020-07-07 11:10:29 -0400
commit45ed05decf330faab4503fe8fecadc54698c9724 (patch)
treeadd3eeda2d09334209abe4e55341b674e64dd117
parentbbc257476f9aac8d04d75a8036d412caa8f7d515 (diff)
Use HIGH() and LOW()
-rw-r--r--constants/audio_constants.asm8
-rw-r--r--constants/battle_constants.asm2
-rwxr-xr-xengine/battle/core.asm44
-rw-r--r--engine/battle/effects.asm15
-rwxr-xr-xengine/gfx/mon_icons.asm2
-rw-r--r--engine/gfx/oam_dma.asm4
-rw-r--r--engine/gfx/sprite_oam.asm8
-rw-r--r--engine/items/inventory.asm4
-rwxr-xr-xengine/link/cable_club.asm4
-rw-r--r--engine/movie/oak_speech/init_player_data.asm4
-rwxr-xr-xengine/movie/title.asm12
-rwxr-xr-xengine/movie/trade.asm4
-rwxr-xr-xengine/overworld/elevator.asm2
-rw-r--r--engine/overworld/movement.asm22
-rw-r--r--engine/overworld/sprite_collisions.asm4
-rwxr-xr-xengine/slots/slot_machine.asm10
-rw-r--r--home.asm2
-rw-r--r--home/init.asm4
-rw-r--r--home/move_mon.asm10
-rw-r--r--home/uncompress.asm4
-rwxr-xr-xmacros/scripts/audio.asm3
-rwxr-xr-xscripts/SafariZoneGate.asm4
22 files changed, 89 insertions, 87 deletions
diff --git a/constants/audio_constants.asm b/constants/audio_constants.asm
index 38719f92..3a1a8f5b 100644
--- a/constants/audio_constants.asm
+++ b/constants/audio_constants.asm
@@ -25,10 +25,10 @@
const Ch8 ; 7
; HW sound channel register base addresses
-HW_CH1_BASE EQU (rNR10 % $100)
-HW_CH2_BASE EQU ((rNR21 % $100) - 1)
-HW_CH3_BASE EQU (rNR30 % $100)
-HW_CH4_BASE EQU ((rNR41 % $100) - 1)
+HW_CH1_BASE EQU LOW(rNR10)
+HW_CH2_BASE EQU LOW(rNR21) - 1
+HW_CH3_BASE EQU LOW(rNR30)
+HW_CH4_BASE EQU LOW(rNR41) - 1
; HW sound channel enable bit masks
HW_CH1_ENABLE_MASK EQU %00010001
diff --git a/constants/battle_constants.asm b/constants/battle_constants.asm
index ba5d6c68..bdd03e8a 100644
--- a/constants/battle_constants.asm
+++ b/constants/battle_constants.asm
@@ -35,6 +35,8 @@ BRN EQU 4
FRZ EQU 5
PAR EQU 6
+MAX_STAT_VALUE EQU 999
+
; volatile statuses 1
STORING_ENERGY EQU 0 ; Bide
THRASHING_ABOUT EQU 1 ; e.g. Thrash
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 4d999d2a..9a66265c 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -4182,8 +4182,8 @@ GetDamageVarsForPlayerAttack:
; if the enemy has used Light Screen, double the enemy's special
sla c
rl b
-; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if
-; a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen
+; reflect and light screen boosts do not cap the stat at MAX_STAT_VALUE, so weird things will happen during stats scaling
+; if a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen
.specialAttackCritCheck
ld hl, wBattleMonSpecial
ld a, [wCriticalHitOrOHKO]
@@ -4295,8 +4295,8 @@ GetDamageVarsForEnemyAttack:
; if the player has used Light Screen, double the player's special
sla c
rl b
-; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if
-; a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen
+; reflect and light screen boosts do not cap the stat at MAX_STAT_VALUE, so weird things will happen during stats scaling
+; if a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen
.specialAttackCritCheck
ld hl, wEnemyMonSpecial
ld a, [wCriticalHitOrOHKO]
@@ -4508,14 +4508,14 @@ CalculateDamage:
jr nz, .cap
ldh a, [hQuotient + 2]
- cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100
+ cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1)
jr c, .dont_cap_2
- cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 + 1
+ cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + 1
jr nc, .cap
ldh a, [hQuotient + 3]
- cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) % $100
+ cp LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1)
jr nc, .cap
.dont_cap_2
@@ -4533,21 +4533,21 @@ CalculateDamage:
jr c, .cap
ld a, [hl]
- cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100
+ cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1)
jr c, .dont_cap_3
- cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 + 1
+ cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + 1
jr nc, .cap
inc hl
ld a, [hld]
- cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) % $100
+ cp LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1)
jr c, .dont_cap_3
.cap
- ld a, (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) / $100
+ ld a, HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE)
ld [hli], a
- ld a, (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) % $100
+ ld a, LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE)
ld [hld], a
.dont_cap_3
@@ -6526,14 +6526,14 @@ CalculateModifiedStat:
call Divide
pop hl
ldh a, [hDividend + 3]
- sub 999 % $100
+ sub LOW(MAX_STAT_VALUE)
ldh a, [hDividend + 2]
- sbc 999 / $100
+ sbc HIGH(MAX_STAT_VALUE)
jp c, .storeNewStatValue
-; cap the stat at 999
- ld a, 999 / $100
+; cap the stat at MAX_STAT_VALUE (999)
+ ld a, HIGH(MAX_STAT_VALUE)
ldh [hDividend + 2], a
- ld a, 999 % $100
+ ld a, LOW(MAX_STAT_VALUE)
ldh [hDividend + 3], a
.storeNewStatValue
ldh a, [hDividend + 2]
@@ -6573,7 +6573,7 @@ ApplyBadgeStatBoosts:
ret
; multiply stat at hl by 1.125
-; cap stat at 999
+; cap stat at MAX_STAT_VALUE
.applyBoostToStat
ld a, [hli]
ld d, a
@@ -6591,13 +6591,13 @@ ApplyBadgeStatBoosts:
adc d
ld [hli], a
ld a, [hld]
- sub 999 % $100
+ sub LOW(MAX_STAT_VALUE)
ld a, [hl]
- sbc 999 / $100
+ sbc HIGH(MAX_STAT_VALUE)
ret c
- ld a, 999 / $100
+ ld a, HIGH(MAX_STAT_VALUE)
ld [hli], a
- ld a, 999 % $100
+ ld a, LOW(MAX_STAT_VALUE)
ld [hld], a
ret
diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm
index fe050937..441d6c1c 100644
--- a/engine/battle/effects.asm
+++ b/engine/battle/effects.asm
@@ -399,11 +399,12 @@ StatModifierUpEffect:
inc d ; de = unmodified (original) stat
.checkIf999
pop bc
+ ; check if stat is already 999
ld a, [hld]
- sub 999 % $100 ; check if stat is already 999
+ sub LOW(MAX_STAT_VALUE)
jr nz, .recalculateStat
ld a, [hl]
- sbc 999 / $100
+ sbc HIGH(MAX_STAT_VALUE)
jp z, RestoreOriginalStatModifier
.recalculateStat ; recalculate affected stat
; paralysis and burn penalties, as well as badge boosts are ignored
@@ -431,15 +432,15 @@ StatModifierUpEffect:
ld b, $4
call Divide
pop hl
-; cap at 999
+; cap at MAX_STAT_VALUE (999)
ldh a, [hProduct + 3]
- sub 999 % $100
+ sub LOW(MAX_STAT_VALUE)
ldh a, [hProduct + 2]
- sbc 999 / $100
+ sbc HIGH(MAX_STAT_VALUE)
jp c, UpdateStat
- ld a, 999 / $100
+ ld a, HIGH(MAX_STAT_VALUE)
ldh [hMultiplicand + 1], a
- ld a, 999 % $100
+ ld a, LOW(MAX_STAT_VALUE)
ldh [hMultiplicand + 2], a
UpdateStat:
diff --git a/engine/gfx/mon_icons.asm b/engine/gfx/mon_icons.asm
index 19008c05..253fca35 100755
--- a/engine/gfx/mon_icons.asm
+++ b/engine/gfx/mon_icons.asm
@@ -236,7 +236,7 @@ WriteMonPartySpriteOAM:
; make a copy at wMonPartySpritesSavedOAM.
push af
ld c, $10
- ld h, wOAMBuffer / $100
+ ld h, HIGH(wOAMBuffer)
ldh a, [hPartyMonIndex]
swap a
ld l, a
diff --git a/engine/gfx/oam_dma.asm b/engine/gfx/oam_dma.asm
index d8d8839a..84bb4b5c 100644
--- a/engine/gfx/oam_dma.asm
+++ b/engine/gfx/oam_dma.asm
@@ -1,7 +1,7 @@
WriteDMACodeToHRAM::
; Since no other memory is available during OAM DMA,
; DMARoutine is copied to HRAM and executed there.
- ld c, hDMARoutine % $100
+ ld c, LOW(hDMARoutine)
ld b, DMARoutineEnd - DMARoutine
ld hl, DMARoutine
.copy
@@ -14,7 +14,7 @@ WriteDMACodeToHRAM::
DMARoutine:
; initiate DMA
- ld a, wOAMBuffer / $100
+ ld a, HIGH(wOAMBuffer)
ldh [rDMA], a
; wait for DMA to finish
diff --git a/engine/gfx/sprite_oam.asm b/engine/gfx/sprite_oam.asm
index 1a96286d..7e9bf739 100644
--- a/engine/gfx/sprite_oam.asm
+++ b/engine/gfx/sprite_oam.asm
@@ -18,7 +18,7 @@ PrepareOAMData::
.spriteLoop
ldh [hSpriteOffset2], a
- ld d, wSpriteStateData1 / $100
+ ld d, HIGH(wSpriteStateData1)
ldh a, [hSpriteOffset2]
ld e, a
ld a, [de] ; c1x0
@@ -79,7 +79,7 @@ PrepareOAMData::
ldh a, [hOAMBufferOffset]
ld e, a
- ld d, wOAMBuffer / $100
+ ld d, HIGH(wOAMBuffer)
.tileLoop
ldh a, [hSpriteScreenY] ; temp for sprite Y position
@@ -141,13 +141,13 @@ PrepareOAMData::
.nextSprite
ldh a, [hSpriteOffset2]
add $10
- cp $100 % $100
+ cp LOW($100)
jp nz, .spriteLoop
; Clear unused OAM.
ldh a, [hOAMBufferOffset]
ld l, a
- ld h, wOAMBuffer / $100
+ ld h, HIGH(wOAMBuffer)
ld de, $4
ld b, $a0
ld a, [wd736]
diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm
index 7ce61cb9..bf433175 100644
--- a/engine/items/inventory.asm
+++ b/engine/items/inventory.asm
@@ -12,10 +12,10 @@ AddItemToInventory_::
push hl
push hl
ld d, PC_ITEM_CAPACITY ; how many items the PC can hold
- ld a, wNumBagItems & $FF
+ ld a, LOW(wNumBagItems)
cp l
jr nz, .checkIfInventoryFull
- ld a, wNumBagItems >> 8
+ ld a, HIGH(wNumBagItems)
cp h
jr nz, .checkIfInventoryFull
; if the destination is the bag
diff --git a/engine/link/cable_club.asm b/engine/link/cable_club.asm
index 03e1c50a..dd93ebba 100755
--- a/engine/link/cable_club.asm
+++ b/engine/link/cable_club.asm
@@ -255,9 +255,9 @@ CableClub_DoBattleOrTradeAgain:
ld hl, wEnemyMons + (SERIAL_PREAMBLE_BYTE - 1)
dec c
jr nz, .unpatchEnemyMonsLoop
- ld a, wEnemyMonOT % $100
+ ld a, LOW(wEnemyMonOT)
ld [wUnusedCF8D], a
- ld a, wEnemyMonOT / $100
+ ld a, HIGH(wEnemyMonOT)
ld [wUnusedCF8D + 1], a
xor a
ld [wTradeCenterPointerTableIndex], a
diff --git a/engine/movie/oak_speech/init_player_data.asm b/engine/movie/oak_speech/init_player_data.asm
index bd181bbd..53ca24f3 100644
--- a/engine/movie/oak_speech/init_player_data.asm
+++ b/engine/movie/oak_speech/init_player_data.asm
@@ -23,9 +23,9 @@ InitPlayerData2:
START_MONEY EQU $3000
ld hl, wPlayerMoney + 1
- ld a, START_MONEY / $100
+ ld a, HIGH(START_MONEY)
ld [hld], a
- xor a
+ xor a ; LOW(START_MONEY)
ld [hli], a
inc hl
ld [hl], a
diff --git a/engine/movie/title.asm b/engine/movie/title.asm
index efdf2f07..00e639ae 100755
--- a/engine/movie/title.asm
+++ b/engine/movie/title.asm
@@ -126,13 +126,13 @@ ENDC
ld [wTitleMonSpecies], a
call LoadTitleMonSprite
- ld a, (vBGMap0 + $300) / $100
+ ld a, HIGH(vBGMap0 + $300)
call TitleScreenCopyTileMapToVRAM
call SaveScreenTilesToBuffer1
ld a, $40
ldh [hWY], a
call LoadScreenTilesFromBuffer2
- ld a, vBGMap0 / $100
+ ld a, HIGH(vBGMap0)
call TitleScreenCopyTileMapToVRAM
ld b, SET_PAL_TITLE_SCREEN
call RunPaletteCommand
@@ -205,7 +205,7 @@ ENDC
and a
jr nz, .scrollTitleScreenGameVersionLoop
- ld a, vBGMap1 / $100
+ ld a, HIGH(vBGMap1)
call TitleScreenCopyTileMapToVRAM
call LoadScreenTilesFromBuffer2
call PrintGameVersionOnTitleScreen
@@ -241,9 +241,9 @@ ENDC
inc a
ldh [hAutoBGTransferEnabled], a
call ClearScreen
- ld a, vBGMap0 / $100
+ ld a, HIGH(vBGMap0)
call TitleScreenCopyTileMapToVRAM
- ld a, vBGMap1 / $100
+ ld a, HIGH(vBGMap1)
call TitleScreenCopyTileMapToVRAM
call Delay3
call LoadGBPal
@@ -258,7 +258,7 @@ ENDC
farjp DoClearSaveDialogue
TitleScreenPickNewMon:
- ld a, vBGMap0 / $100
+ ld a, HIGH(vBGMap0)
call TitleScreenCopyTileMapToVRAM
.loop
diff --git a/engine/movie/trade.asm b/engine/movie/trade.asm
index 518742aa..6aac7e23 100755
--- a/engine/movie/trade.asm
+++ b/engine/movie/trade.asm
@@ -237,7 +237,7 @@ Trade_ShowPlayerMon:
ld c, 10
call TextBoxBorder
call Trade_PrintPlayerMonInfoText
- ld b, vBGMap0 / $100
+ ld b, HIGH(vBGMap0)
call CopyScreenTileBufferToVRAM
call ClearScreen
ld a, [wTradedPlayerMonSpecies]
@@ -266,7 +266,7 @@ Trade_ShowPlayerMon:
Trade_DrawOpenEndOfLinkCable:
call Trade_ClearTileMap
- ld b, vBGMap0 / $100
+ ld b, HIGH(vBGMap0)
call CopyScreenTileBufferToVRAM
ld b, SET_PAL_GENERIC
call RunPaletteCommand
diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm
index 7a6aca85..fa404602 100755
--- a/engine/overworld/elevator.asm
+++ b/engine/overworld/elevator.asm
@@ -56,7 +56,7 @@ ShakeElevatorRedrawRow:
add hl, de
ld a, h
and $3
- or vBGMap0 / $100
+ or HIGH(vBGMap0)
ld d, a
ld a, l
pop hl
diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm
index ac7e1b46..a20b3174 100644
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -23,7 +23,7 @@ UpdatePlayerSprite:
ret
.lowerLeftTileIsMapTile
call DetectCollisionBetweenSprites
- ld h, wSpriteStateData1 / $100
+ ld h, HIGH(wSpriteStateData1)
ld a, [wWalkCounter]
and a
jr nz, .moving
@@ -395,7 +395,7 @@ UpdateSpriteMovementDelay:
ld l, a
ld [hl], $1 ; c1x1 = 1 (mark as ready to move)
notYetMoving:
- ld h, wSpriteStateData1 / $100
+ ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1AnimFrameCounter - wSpritePlayerStateData1
ld l, a
@@ -450,7 +450,7 @@ InitializeSpriteStatus:
; calculates the sprite's screen position form its map position and the player position
InitializeSpriteScreenPosition:
- ld h, wSpriteStateData2 / $100
+ ld h, HIGH(wSpriteStateData2)
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MapY - wSpritePlayerStateData2
ld l, a
@@ -478,7 +478,7 @@ CheckSpriteAvailability:
ldh a, [hIsHiddenMissableObject]
and a
jp nz, .spriteInvisible
- ld h, wSpriteStateData2 / $100
+ ld h, HIGH(wSpriteStateData2)
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2
ld l, a
@@ -526,7 +526,7 @@ CheckSpriteAvailability:
cp d
jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile)
.spriteInvisible
- ld h, wSpriteStateData1 / $100
+ ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1
ld l, a
@@ -580,7 +580,7 @@ UpdateSpriteImage:
; e: X movement delta (-1, 0 or 1)
; set carry on failure, clears carry on success
CanWalkOntoTile:
- ld h, wSpriteStateData2 / $100
+ ld h, HIGH(wSpriteStateData2)
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2
ld l, a
@@ -608,7 +608,7 @@ CanWalkOntoTile:
ld a, [hl] ; $c2x6 (movement byte 1)
inc a
jr z, .impassable ; if $ff, no movement allowed (however, changing direction is)
- ld h, wSpriteStateData1 / $100
+ ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld l, a
@@ -627,14 +627,14 @@ CanWalkOntoTile:
call DetectCollisionBetweenSprites
pop bc
pop de
- ld h, wSpriteStateData1 / $100
+ ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset]
add $c
ld l, a
ld a, [hl] ; c1xc (directions in which sprite collision would occur)
and b ; check against chosen direction (1,2,4 or 8)
jr nz, .impassable ; collision between sprites, don't go there
- ld h, wSpriteStateData2 / $100
+ ld h, HIGH(wSpriteStateData2)
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2YDisplacement - wSpritePlayerStateData2
ld l, a
@@ -665,7 +665,7 @@ CanWalkOntoTile:
and a ; clear carry (marking success)
ret
.impassable
- ld h, wSpriteStateData1 / $100
+ ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset]
inc a
ld l, a
@@ -691,7 +691,7 @@ CanWalkOntoTile:
; this is always the lower left tile of the 2x2 tile blocks all sprites are snapped to
; hl: output pointer
GetTileSpriteStandsOn:
- ld h, wSpriteStateData1 / $100
+ ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld l, a
diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm
index e6c415ab..6f8e3c2c 100644
--- a/engine/overworld/sprite_collisions.asm
+++ b/engine/overworld/sprite_collisions.asm
@@ -53,9 +53,9 @@ UpdateNonPlayerSprite:
DetectCollisionBetweenSprites:
nop
- ld h, wSpriteStateData1 / $100
+ ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset]
- add wSpriteStateData1 % $100
+ add LOW(wSpriteStateData1)
ld l, a
ld a, [hl] ; a = [$c1i0] (picture) (0 if slot is unused)
diff --git a/engine/slots/slot_machine.asm b/engine/slots/slot_machine.asm
index b6eda6d1..64c14997 100755
--- a/engine/slots/slot_machine.asm
+++ b/engine/slots/slot_machine.asm
@@ -294,7 +294,7 @@ SlotMachine_StopWheel1Early:
; Stop early if the middle symbol is not a cherry.
inc hl
ld a, [hl]
- cp SLOTSCHERRY >> 8
+ cp HIGH(SLOTSCHERRY)
jr nz, .stopWheel
ret
; It looks like this was intended to make the wheel stop when a 7 symbol was
@@ -303,7 +303,7 @@ SlotMachine_StopWheel1Early:
ld c, $3
.loop
ld a, [hli]
- cp SLOTS7 >> 8
+ cp HIGH(SLOTS7)
jr c, .stopWheel ; condition never true
dec c
jr nz, .loop
@@ -330,7 +330,7 @@ SlotMachine_StopWheel2Early:
.sevenAndBarMode
call SlotMachine_FindWheel1Wheel2Matches
ld a, [de]
- cp (SLOTSBAR >> 8) + 1
+ cp HIGH(SLOTSBAR) + 1
ret nc
.stopWheel
xor a
@@ -427,7 +427,7 @@ SlotMachine_CheckForMatches:
jr nz, .acceptMatch
; if 7/bar matches aren't enabled and the match was a 7/bar symbol, roll wheel
ld a, [hl]
- cp (SLOTSBAR >> 8) + 1
+ cp HIGH(SLOTSBAR) + 1
jr c, .rollWheel3DownByOneSymbol
.acceptMatch
ld a, [hl]
@@ -702,7 +702,7 @@ SlotMachine_PayCoinsToPlayer:
.skip1
ld [wAnimCounter], a
ld a, [wSlotMachineWinningSymbol]
- cp (SLOTSBAR >> 8) + 1
+ cp HIGH(SLOTSBAR) + 1
ld c, 8
jr nc, .skip2
srl c ; c = 4 (make the the coins transfer faster if the symbol was 7 or bar)
diff --git a/home.asm b/home.asm
index 62594b43..3e465cdf 100644
--- a/home.asm
+++ b/home.asm
@@ -1242,7 +1242,7 @@ StringCmp::
; c = X coordinate of upper left corner of sprite
; de = base address of 4 tile number and attribute pairs
WriteOAMBlock::
- ld h, wOAMBuffer / $100
+ ld h, HIGH(wOAMBuffer)
swap a ; multiply by 16
ld l, a
call .writeOneEntry ; upper left
diff --git a/home/init.asm b/home/init.asm
index f18216ff..e3f5fdd4 100644
--- a/home/init.asm
+++ b/home/init.asm
@@ -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
diff --git a/home/move_mon.asm b/home/move_mon.asm
index 9fe7b067..cf7213b1 100644
--- a/home/move_mon.asm
+++ b/home/move_mon.asm
@@ -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
diff --git a/home/uncompress.asm b/home/uncompress.asm
index 69d94cb0..9d08aa60 100644
--- a/home/uncompress.asm
+++ b/home/uncompress.asm
@@ -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
diff --git a/macros/scripts/audio.asm b/macros/scripts/audio.asm
index 8a250c63..4f4d084c 100755
--- a/macros/scripts/audio.asm
+++ b/macros/scripts/audio.asm
@@ -141,8 +141,7 @@ ENDM
; stored in big endian
tempo: MACRO
db $ED
- db \1 / $100
- db \1 % $100
+ db HIGH(\1), LOW(\1)
ENDM
; arguments: left output enable mask, right output enable mask
diff --git a/scripts/SafariZoneGate.asm b/scripts/SafariZoneGate.asm
index eb49ba8d..a15a5630 100755
--- a/scripts/SafariZoneGate.asm
+++ b/scripts/SafariZoneGate.asm
@@ -182,9 +182,9 @@ SafariZoneGate_TextPointers:
call PrintText
ld a, 30
ld [wNumSafariBalls], a
- ld a, 502 / $100
+ ld a, HIGH(502)
ld [wSafariSteps], a
- ld a, 502 % $100
+ ld a, LOW(502)
ld [wSafariSteps + 1], a
ld a, D_UP
ld c, 3