shithub: pokecrystal

Download patch

ref: e34e68095df1f91dc5357669c187623d7cba39c6
parent: da2b01a36c6855230ec36c42bd49e7cf2ca2d348
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Mon Dec 25 08:40:10 EST 2017

Resolve #428: Use `HIGH(X)` and `LOW(X)` instead of `X / $100` and `X % $100` or `X >> 8` and `X & $ff`

--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -539,7 +539,7 @@
 	ld a, [Danger]
 	bit DANGER_ON_F, a
 	ret z
-	and $ff - (1 << DANGER_ON_F)
+	and $ff ^ (1 << DANGER_ON_F)
 	ld d, a
 	call _CheckSFX
 	jr c, .asm_e8335
@@ -2297,9 +2297,9 @@
 	add hl, bc
 	ld a, [hl]
 	; multiply NoteLength by delay units
-	ld l, 0; just multiply
+	ld l, 0 ; just multiply
 	call .Multiply
-	ld a, l ; % $100
+	ld a, l ; low
 	; store Tempo in de
 	ld hl, Channel1Tempo - Channel1
 	add hl, bc
@@ -2310,7 +2310,7 @@
 	ld hl, Channel1Field0x16 - Channel1
 	add hl, bc
 	ld l, [hl]
-	; multiply Tempo by last result (NoteLength * delay % $100)
+	; multiply Tempo by last result (NoteLength * LOW(delay))
 	call .Multiply
 	; copy result to de
 	ld e, l
--- a/battle/anim_commands.asm
+++ b/battle/anim_commands.asm
@@ -237,16 +237,16 @@
 ; Appears to be unused.
 	xor a
 	ld [hBGMapMode], a
-	ld a, (VBGMap0 tile $28) % $100
+	ld a, LOW(VBGMap0 tile $28)
 	ld [hBGMapAddress], a
-	ld a, (VBGMap0 tile $28) / $100
+	ld a, HIGH(VBGMap0 tile $28)
 	ld [hBGMapAddress + 1], a
 	call WaitBGMap2
 	ld a, $60
 	ld [hWY], a
-	xor a
+	xor a ; LOW(VBGMap0)
 	ld [hBGMapAddress], a
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [hBGMapAddress + 1], a
 	call BattleAnimDelayFrame
 	ret
@@ -1501,10 +1501,10 @@
 	jr nz, .loop
 	ld a, [wBattleAnimOAMPointerLo]
 	ld l, a
-	ld h, Sprites / $100
+	ld h, HIGH(Sprites)
 .loop2
 	ld a, l
-	cp SpritesEnd % $100
+	cp LOW(SpritesEnd)
 	jr nc, .done
 	xor a
 	ld [hli], a
--- a/battle/bg_effects.asm
+++ b/battle/bg_effects.asm
@@ -1223,7 +1223,7 @@
 	xor $ff
 	inc a
 	ld d, a
-	ld h, LYOverridesBackup / $100
+	ld h, HIGH(LYOverridesBackup)
 	ld a, [hLYOverrideStart]
 	ld l, a
 	ld a, [hLYOverrideEnd]
@@ -1264,7 +1264,7 @@
 	ld e, [hl]
 	ld d, 2
 	call Functionc8f2e
-	ld h, LYOverridesBackup / $100
+	ld h, HIGH(LYOverridesBackup)
 	ld a, [hLYOverrideEnd]
 	ld l, a
 	ld [hl], $0
@@ -1275,7 +1275,7 @@
 .one
 	ld a, [hLYOverrideEnd]
 	ld l, a
-	ld h, LYOverridesBackup / $100
+	ld h, HIGH(LYOverridesBackup)
 	ld e, l
 	ld d, h
 	dec de
@@ -1554,7 +1554,7 @@
 	ld a, [hLYOverrideEnd]
 	sub d
 	ld d, a
-	ld h, LYOverridesBackup / $100
+	ld h, HIGH(LYOverridesBackup)
 	ld a, [hSCY]
 	or a
 	jr nz, .skip1
@@ -1846,7 +1846,7 @@
 	ld [hLYOverrideEnd], a
 	ld a, [hLYOverrideStart]
 	ld l, a
-	ld h, LYOverridesBackup / $100
+	ld h, HIGH(LYOverridesBackup)
 .loop
 	ld a, [hLYOverrideEnd]
 	cp l
@@ -1900,7 +1900,7 @@
 	ld a, [hLYOverrideEnd]
 	sub l
 	srl a
-	ld h, LYOverridesBackup / $100
+	ld h, HIGH(LYOverridesBackup)
 .loop2
 	ld [hl], e
 	inc hl
@@ -2851,7 +2851,7 @@
 	ld l, a
 	inc a
 	ld e, a
-	ld h, LYOverridesBackup / $100
+	ld h, HIGH(LYOverridesBackup)
 	ld d, h
 	ld a, [hLYOverrideEnd]
 	sub l
@@ -2874,7 +2874,7 @@
 
 BGEffect_FillLYOverridesBackup: ; c900b (32:500b)
 	push af
-	ld h, LYOverridesBackup / $100
+	ld h, HIGH(LYOverridesBackup)
 	ld a, [hLYOverrideStart]
 	ld l, a
 	ld a, [hLYOverrideEnd]
@@ -2897,7 +2897,7 @@
 	sub l
 	sub e
 	ld d, a
-	ld h, LYOverridesBackup / $100
+	ld h, HIGH(LYOverridesBackup)
 	ld a, [hLYOverrideStart]
 	ld l, a
 	ld a, $90
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -2573,11 +2573,11 @@
 .CheckMaxedOutMomMoney: ; 3d0b1
 	ld hl, wMomsMoney + 2
 	ld a, [hld]
-	cp MAX_MONEY % $100
+	cp LOW(MAX_MONEY)
 	ld a, [hld]
-	sbc MAX_MONEY / $100 % $100
+	sbc HIGH(MAX_MONEY) ; mid
 	ld a, [hl]
-	sbc MAX_MONEY / $10000 % $100
+	sbc HIGH(MAX_MONEY >> 8)
 	ret
 ; 3d0be
 
@@ -2602,17 +2602,17 @@
 	jr nz, .loop
 	pop hl
 	ld a, [hld]
-	cp MAX_MONEY % $100
+	cp LOW(MAX_MONEY)
 	ld a, [hld]
-	sbc MAX_MONEY / $100 % $100
+	sbc HIGH(MAX_MONEY) ; mid
 	ld a, [hl]
-	sbc MAX_MONEY / $10000 % $100
+	sbc HIGH(MAX_MONEY >> 8)
 	ret c
-	ld [hl], MAX_MONEY / $10000 % $100
+	ld [hl], HIGH(MAX_MONEY >> 8)
 	inc hl
-	ld [hl], MAX_MONEY / $100 % $100
+	ld [hl], HIGH(MAX_MONEY) ; mid
 	inc hl
-	ld [hl], MAX_MONEY % $100
+	ld [hl], LOW(MAX_MONEY)
 	ret
 ; 3d0ea
 
@@ -6384,25 +6384,25 @@
 
 ; We're clear if the length is < 1536
 	ld a, [wMagikarpLength]
-	cp $06 ; $600 = 1536
+	cp HIGH(1536)
 	jr nz, .CheckMagikarpArea
 
-; 5% chance of skipping size checks
+; 5% chance of skipping both size checks
 	call Random
-	cp $0c ; / $100
+	cp 5 percent
 	jr c, .CheckMagikarpArea
 ; Try again if > 1614
 	ld a, [wMagikarpLength + 1]
-	cp $50
+	cp LOW(1614) + 2
 	jr nc, .GenerateDVs
 
 ; 20% chance of skipping this check
 	call Random
-	cp $32 ; / $100
+	cp 20 percent - 1
 	jr c, .CheckMagikarpArea
 ; Try again if > 1598
 	ld a, [wMagikarpLength + 1]
-	cp $40
+	cp LOW(1598) + 2
 	jr nc, .GenerateDVs
 
 .CheckMagikarpArea:
@@ -6423,11 +6423,11 @@
 	jr z, .Happiness
 ; 40% chance of not flooring
 	call Random
-	cp $64 ; / $100
+	cp 40 percent - 2
 	jr c, .Happiness
 ; Floor at length 1024
 	ld a, [wMagikarpLength]
-	cp 1024 >> 8
+	cp HIGH(1024)
 	jr c, .GenerateDVs ; try again
 
 ; Finally done with DVs
@@ -6462,7 +6462,7 @@
 .TreeMon:
 ; If we're headbutting trees, some monsters enter battle asleep
 	call CheckSleepingTreeMon
-	ld a, SLP ; Asleep for 7 turns
+	ld a, TREEMON_SLEEP_TURNS
 	jr c, .UpdateStatus
 ; Otherwise, no status
 	xor a
@@ -7009,14 +7009,14 @@
 
 ; Cap at 999.
 	ld a, [hQuotient + 2]
-	sub MAX_STAT_VALUE % $100
+	sub LOW(MAX_STAT_VALUE)
 	ld a, [hQuotient + 1]
-	sbc MAX_STAT_VALUE / $100
+	sbc HIGH(MAX_STAT_VALUE)
 	jp c, .okay3
 
-	ld a, MAX_STAT_VALUE / $100
+	ld a, HIGH(MAX_STAT_VALUE)
 	ld [hQuotient + 1], a
-	ld a, MAX_STAT_VALUE % $100
+	ld a, LOW(MAX_STAT_VALUE)
 	ld [hQuotient + 2], a
 
 .okay3
@@ -7132,13 +7132,13 @@
 
 ; Cap at 999.
 	ld a, [hld]
-	sub MAX_STAT_VALUE % $100
+	sub LOW(MAX_STAT_VALUE)
 	ld a, [hl]
-	sbc MAX_STAT_VALUE / $100
+	sbc HIGH(MAX_STAT_VALUE)
 	ret c
-	ld a, MAX_STAT_VALUE / $100
+	ld a, HIGH(MAX_STAT_VALUE)
 	ld [hli], a
-	ld a, MAX_STAT_VALUE % $100
+	ld a, LOW(MAX_STAT_VALUE)
 	ld [hld], a
 	ret
 ; 3ed9f
@@ -7217,7 +7217,7 @@
 	ld b, 10 ; number of seeds
 
 ; Generate next number in the sequence for each seed
-; The algorithm takes the form *5 + 1 % 256
+; a[n+1] = (a[n] * 5 + 1) % 256
 .loop
 	; get last #
 	ld a, [hl]
@@ -9135,10 +9135,10 @@
 	dec hl
 	ld a, [hl]
 	inc hl
-	cp MAX_LINK_RECORD / $100
+	cp HIGH(MAX_LINK_RECORD)
 	ret c
 	ld a, [hl]
-	cp MAX_LINK_RECORD % $100
+	cp LOW(MAX_LINK_RECORD)
 	ret
 ; 3fac8
 
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -3576,14 +3576,14 @@
 	jr nz, .Cap
 
 	ld a, [hProduct + 2]
-	cp 998 / $100
+	cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
 	jr c, .dont_cap_2
 
-	cp 998 / $100 + 1
+	cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1) + 1
 	jr nc, .Cap
 
 	ld a, [hProduct + 3]
-	cp 998 % $100
+	cp LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
 	jr nc, .Cap
 
 .dont_cap_2
@@ -3601,21 +3601,21 @@
 	jr c, .Cap
 
 	ld a, [hl]
-	cp 998 / $100
+	cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
 	jr c, .dont_cap_3
 
-	cp 998 / $100 + 1
+	cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1) + 1
 	jr nc, .Cap
 
 	inc hl
 	ld a, [hld]
-	cp 998 % $100
+	cp LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
 	jr c, .dont_cap_3
 
 .Cap:
-	ld a, 997 / $100
+	ld a, HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE)
 	ld [hli], a
-	ld a, 997 % $100
+	ld a, LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE)
 	ld [hld], a
 
 
@@ -3623,7 +3623,7 @@
 ; Minimum neutral damage is 2 (bringing the cap to 999).
 	inc hl
 	ld a, [hl]
-	add 2
+	add MIN_NEUTRAL_DAMAGE
 	ld [hld], a
 	jr nc, .dont_floor
 	inc [hl]
@@ -5651,10 +5651,10 @@
 .no_carry
 	pop bc
 	ld a, [hld]
-	sub MAX_STAT_VALUE % $100
+	sub LOW(MAX_STAT_VALUE)
 	jr nz, .not_already_max
 	ld a, [hl]
-	sbc MAX_STAT_VALUE / $100
+	sbc HIGH(MAX_STAT_VALUE)
 	jp z, .stats_already_max
 .not_already_max
 	ld a, [hBattleTurn]
@@ -6417,14 +6417,14 @@
 
 .check_maxed_out
 	ld a, [hQuotient + 2]
-	cp MAX_STAT_VALUE % $100
+	cp LOW(MAX_STAT_VALUE)
 	ld a, b
-	sbc MAX_STAT_VALUE / $100
+	sbc HIGH(MAX_STAT_VALUE)
 	jr c, .not_maxed_out
 
-	ld a, MAX_STAT_VALUE % $100
+	ld a, LOW(MAX_STAT_VALUE)
 	ld [hQuotient + 2], a
-	ld a, MAX_STAT_VALUE / $100
+	ld a, HIGH(MAX_STAT_VALUE)
 	ld [hQuotient + 1], a
 
 .not_maxed_out
@@ -8367,7 +8367,7 @@
 	call GetBattleVarAddr
 	ld a, [hl]
 	and a
-	ld [hl], REST_TURNS + 1
+	ld [hl], REST_SLEEP_TURNS + 1
 	ld hl, WentToSleepText
 	jr z, .no_status_to_heal
 	ld hl, RestedText
--- a/battle/objects/engine.asm
+++ b/battle/objects/engine.asm
@@ -106,7 +106,7 @@
 	ld l, a
 	ld a, [wBattleAnimOAMPointerLo]
 	ld e, a
-	ld d, Sprites / $100
+	ld d, HIGH(Sprites)
 .loop
 	ld a, [wBattleAnimTempYCoord]
 	ld b, a
--- a/constants/battle_constants.asm
+++ b/constants/battle_constants.asm
@@ -10,8 +10,12 @@
 BASE_STAT_LEVEL EQU 7
 MAX_STAT_LEVEL EQU 13
 
-; turns that Rest sleep lasts
-REST_TURNS EQU 2
+; minimum damage before type effectiveness
+MIN_NEUTRAL_DAMAGE EQU 2
+
+; turns that sleep lasts
+REST_SLEEP_TURNS EQU 2
+TREEMON_SLEEP_TURNS EQU 7
 
 ; PlayerStatLevels and EnemyStatLevels indexes
 ; used for GetStatName
--- /dev/null
+++ b/data/maps/environment_colors.asm
@@ -1,0 +1,35 @@
+EnvironmentColorsPointers:
+; entries correspond to environment constants (see constants/map_constants.asm)
+	dw .OutdoorColors ; unused
+	dw .OutdoorColors ; TOWN
+	dw .OutdoorColors ; ROUTE
+	dw .IndoorColors  ; INDOOR
+	dw .DungeonColors ; CAVE
+	dw .Env5Colors    ; ENVIRONMENT_5
+	dw .IndoorColors  ; GATE
+	dw .DungeonColors ; DUNGEON
+
+; Valid indices: $00 - $29
+.OutdoorColors:
+	db $00, $01, $02, $28, $04, $05, $06, $07 ; morn
+	db $08, $09, $0a, $28, $0c, $0d, $0e, $0f ; day
+	db $10, $11, $12, $29, $14, $15, $16, $17 ; nite
+	db $18, $19, $1a, $1b, $1c, $1d, $1e, $1f ; dark
+
+.IndoorColors:
+	db $20, $21, $22, $23, $24, $25, $26, $07 ; morn
+	db $20, $21, $22, $23, $24, $25, $26, $07 ; day
+	db $10, $11, $12, $13, $14, $15, $16, $07 ; nite
+	db $18, $19, $1a, $1b, $1c, $1d, $1e, $07 ; dark
+
+.DungeonColors:
+	db $00, $01, $02, $03, $04, $05, $06, $07 ; morn
+	db $08, $09, $0a, $0b, $0c, $0d, $0e, $0f ; day
+	db $10, $11, $12, $13, $14, $15, $16, $17 ; nite
+	db $18, $19, $1a, $1b, $1c, $1d, $1e, $1f ; dark
+
+.Env5Colors:
+	db $00, $01, $02, $03, $04, $05, $06, $07 ; morn
+	db $08, $09, $0a, $0b, $0c, $0d, $0e, $0f ; day
+	db $10, $11, $12, $13, $14, $15, $16, $17 ; nite
+	db $18, $19, $1a, $1b, $1c, $1d, $1e, $1f ; dark
--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -72,16 +72,16 @@
 	sla l
 	rl h
 
-	ld a, 999 / $100
+	ld a, HIGH(MAX_STAT_VALUE)
 	cp h
 	jr c, .cap
-	ld a, 999 % $100
+	ld a, LOW(MAX_STAT_VALUE)
 	cp l
 	ret nc
 
 .cap
-	ld h, 999 / $100
-	ld l, 999 % $100
+	ld h, HIGH(MAX_STAT_VALUE)
+	ld l, LOW(MAX_STAT_VALUE)
 	ret
 ```
 
@@ -128,16 +128,16 @@
 	scf
 	rr c
 
-	ld a, 999 / $100
+	ld a, HIGH(MAX_STAT_VALUE)
 	cp b
 	jr c, .cap
-	ld a, 999 % $100
+	ld a, LOW(MAX_STAT_VALUE)
 	cp c
 	ret nc
 
 .cap
-	ld b, 999 / $100
-	ld c, 999 % $100
+	ld b, HIGH(MAX_STAT_VALUE)
+	ld c, LOW(MAX_STAT_VALUE)
 	ret
 ```
 
@@ -1398,7 +1398,7 @@
 	push af
 	ld [rSVBK], a
 	xor a
-	ld hl, $d000
+	ld hl, wRAM1Start
 	ld bc, $1000
 	call ByteFill
 	pop af
--- a/engine/breeding.asm
+++ b/engine/breeding.asm
@@ -719,7 +719,7 @@
 	call PlayMusic
 	call EnableLCD
 	hlcoord 7, 4
-	ld b, VBGMap0 / $100
+	ld b, HIGH(VBGMap0)
 	ld c, $31 ; Egg tiles start here
 	ld a, EGG
 	call Hatch_UpdateFrontpicBGMapCenter
@@ -768,7 +768,7 @@
 	call ClearSprites
 	call Hatch_InitShellFragments
 	hlcoord 6, 3
-	ld b, VBGMap0 / $100
+	ld b, HIGH(VBGMap0)
 	ld c, $00 ; Hatchling tiles start here
 	ld a, [wJumptableIndex]
 	call Hatch_UpdateFrontpicBGMapCenter
--- a/engine/card_flip.asm
+++ b/engine/card_flip.asm
@@ -644,10 +644,10 @@
 	ld a, e
 	and $1c ; get level
 	srl a
-	add .Jumptable % $100
+	add LOW(.Jumptable)
 	ld l, a
 	ld a, 0
-	adc .Jumptable / $100
+	adc HIGH(.Jumptable)
 	ld h, a
 	ld a, [hli]
 	ld h, [hl]
@@ -1185,7 +1185,7 @@
 
 .IsCoinCaseFull: ; e0833
 	ld a, [Coins]
-	cp MAX_COINS / $100
+	cp HIGH(MAX_COINS)
 	jr c, .less
 	jr z, .check_low
 	jr .more
@@ -1192,7 +1192,7 @@
 
 .check_low
 	ld a, [Coins + 1]
-	cp MAX_COINS % $100
+	cp LOW(MAX_COINS)
 	jr c, .less
 
 .more
--- a/engine/color.asm
+++ b/engine/color.asm
@@ -523,10 +523,10 @@
 	ld a, $5
 	ld [rSVBK], a
 
-	ld a, (palred 31 + palgreen 31 + palblue 31) % $100
+	ld a, LOW(palred 31 + palgreen 31 + palblue 31)
 	ld [de], a
 	inc de
-	ld a, (palred 31 + palgreen 31 + palblue 31) / $100
+	ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
 	ld [de], a
 	inc de
 
@@ -912,9 +912,9 @@
 	ld [rBGPI], a
 	ld c, 4 * 8
 .bgpals_loop
-	ld a, (palred 31 + palgreen 31 + palblue 31) % $100
+	ld a, LOW(palred 31 + palgreen 31 + palblue 31)
 	ld [rBGPD], a
-	ld a, (palred 31 + palgreen 31 + palblue 31) / $100
+	ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
 	ld [rBGPD], a
 	dec c
 	jr nz, .bgpals_loop
@@ -922,9 +922,9 @@
 	ld [rOBPI], a
 	ld c, 4 * 8
 .obpals_loop
-	ld a, (palred 31 + palgreen 31 + palblue 31) % $100
+	ld a, LOW(palred 31 + palgreen 31 + palblue 31)
 	ld [rOBPD], a
-	ld a, (palred 31 + palgreen 31 + palblue 31) / $100
+	ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
 	ld [rOBPD], a
 	dec c
 	jr nz, .obpals_loop
@@ -943,9 +943,9 @@
 .LoadWhitePals:
 	ld c, 4 * 16
 .loop
-	ld a, (palred 31 + palgreen 31 + palblue 31) % $100
+	ld a, LOW(palred 31 + palgreen 31 + palblue 31)
 	ld [hli], a
-	ld a, (palred 31 + palgreen 31 + palblue 31) / $100
+	ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
 	ld [hli], a
 	dec c
 	jr nz, .loop
@@ -1070,7 +1070,7 @@
 	ld [rBGP], a
 	ld hl, PredefPals
 	ld de, VTiles1
-	ld bc, $1000
+	ld bc, $100 tiles
 	call CopyData
 	call DrawDefaultTiles
 	ld a, $e3
--- a/engine/credits.asm
+++ b/engine/credits.asm
@@ -193,9 +193,9 @@
 	ld [Requested2bppSource], a
 	ld a, h
 	ld [Requested2bppSource + 1], a
-	ld a, VTiles2 % $100
+	ld a, LOW(VTiles2)
 	ld [Requested2bppDest], a
-	ld a, VTiles2 / $100
+	ld a, HIGH(VTiles2)
 	ld [Requested2bppDest + 1], a
 	jr Credits_RequestGFX
 
@@ -374,9 +374,9 @@
 	set 7, [hl]
 	ld a, 32
 	ld [MusicFade], a
-	ld a, MUSIC_POST_CREDITS % $100
+	ld a, LOW(MUSIC_POST_CREDITS)
 	ld [MusicFadeID], a
-	ld a, MUSIC_POST_CREDITS / $100
+	ld a, HIGH(MUSIC_POST_CREDITS)
 	ld [MusicFadeID + 1], a
 	ret
 
@@ -523,10 +523,10 @@
 ; Update the first three colors in both palette buffers.
 	push af
 	push hl
-	add UnknBGPals % $100
+	add LOW(UnknBGPals)
 	ld e, a
 	ld a, 0
-	adc UnknBGPals / $100
+	adc HIGH(UnknBGPals)
 	ld d, a
 	ld bc, 24
 	call CopyBytes
@@ -533,10 +533,10 @@
 
 	pop hl
 	pop af
-	add BGPals % $100
+	add LOW(BGPals)
 	ld e, a
 	ld a, 0
-	adc BGPals / $100
+	adc HIGH(BGPals)
 	ld d, a
 	ld bc, 24
 	call CopyBytes
--- a/engine/crystal_intro.asm
+++ b/engine/crystal_intro.asm
@@ -3,9 +3,9 @@
 	call PlayMusic
 	call ClearBGPalettes
 	call ClearTileMap
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [hBGMapAddress + 1], a
-	xor a
+	xor a ; LOW(VBGMap0)
 	ld [hBGMapAddress], a
 	ld [hJoyDown], a
 	ld [hSCX], a
@@ -1922,9 +1922,9 @@
 	ld [Requested2bppSource], a
 	ld a, [hli]
 	ld [Requested2bppSource + 1], a
-	ld a, (VTiles2 tile $09) % $100
+	ld a, LOW(VTiles2 tile $09)
 	ld [Requested2bppDest], a
-	ld a, (VTiles2 tile $09) / $100
+	ld a, HIGH(VTiles2 tile $09)
 	ld [Requested2bppDest + 1], a
 	ld a, 4
 	ld [Requested2bppSize], a
--- a/engine/debug.asm
+++ b/engine/debug.asm
@@ -1069,7 +1069,7 @@
 	ld hl, VTiles1
 	lb bc, BANK(DebugColorTestGFX), 1
 	call Request2bpp
-	ld a, VBGMap1 / $100
+	ld a, HIGH(VBGMap1)
 	ld [hBGMapAddress + 1], a
 	hlcoord 0, 0
 	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
--- a/engine/events_2.asm
+++ b/engine/events_2.asm
@@ -300,7 +300,7 @@
 	; If we've taken at least 1024 steps, have the bike
 	;  shop owner try to call us.
 	ld a, d
-	cp 1024 >> 8
+	cp HIGH(1024)
 	jr c, .NoCall
 
 	; If a call has already been queued, don't overwrite
--- a/engine/experience.asm
+++ b/engine/experience.asm
@@ -6,7 +6,7 @@
 .next_level
 	inc d
 	ld a, d
-	cp (MAX_LEVEL + 1) % $100
+	cp MAX_LEVEL + 1
 	jr z, .got_level
 	call CalcExpAtLevel
 	push hl
--- a/engine/init_hof_credits.asm
+++ b/engine/init_hof_credits.asm
@@ -46,9 +46,9 @@
 	ld hl, UnknBGPals
 	ld c, 4 tiles
 .load_white_palettes
-	ld a, (palred 31 + palgreen 31 + palblue 31) % $100
+	ld a, LOW(palred 31 + palgreen 31 + palblue 31)
 	ld [hli], a
-	ld a, (palred 31 + palgreen 31 + palblue 31) / $100
+	ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
 	ld [hli], a
 	dec c
 	jr nz, .load_white_palettes
--- a/engine/init_map.asm
+++ b/engine/init_map.asm
@@ -27,7 +27,7 @@
 	ld a, $90
 	ld [hWY], a
 	call OverworldTextModeSwitch
-	ld a, VBGMap1 / $100
+	ld a, HIGH(VBGMap1)
 	call .LoadBGMapAddrIntoHRAM
 	call _OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
 	farcall LoadOW_BGPal7
@@ -38,11 +38,11 @@
 	ld [hBGMapMode], a
 	ld [hWY], a
 	farcall HDMATransfer_FillBGMap0WithBlack ; no need to farcall
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	call .LoadBGMapAddrIntoHRAM
-	xor a
+	xor a ; LOW(VBGMap0)
 	ld [wBGMapAnchor], a
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [wBGMapAnchor + 1], a
 	xor a
 	ld [hSCX], a
@@ -86,13 +86,13 @@
 	ld hl, wDecompressScratch
 	ld bc, wScratchAttrMap - wDecompressScratch
 	call ByteFill
-	ld a, wDecompressScratch / $100
+	ld a, HIGH(wDecompressScratch)
 	ld [rHDMA1], a
-	ld a, wDecompressScratch % $100
+	ld a, LOW(wDecompressScratch)
 	ld [rHDMA2], a
-	ld a, (VBGMap0 % $8000) / $100
+	ld a, HIGH(VBGMap0 % $8000)
 	ld [rHDMA3], a
-	ld a, (VBGMap0 % $8000) % $100
+	ld a, LOW(VBGMap0 % $8000)
 	ld [rHDMA4], a
 	ld a, $3f
 	ld [hDMATransfer], a
--- a/engine/intro_menu.asm
+++ b/engine/intro_menu.asm
@@ -199,13 +199,13 @@
 	ld [Coins], a
 	ld [Coins + 1], a
 
-IF START_MONEY / $10000
-	ld a, START_MONEY / $10000
+IF START_MONEY >= $10000
+	ld a, HIGH(START_MONEY >> 8)
 ENDC
 	ld [Money], a
-	ld a, START_MONEY / $100 % $100
+	ld a, HIGH(START_MONEY) ; mid
 	ld [Money + 1], a
-	ld a, START_MONEY % $100
+	ld a, LOW(START_MONEY)
 	ld [Money + 2], a
 
 	xor a
@@ -212,11 +212,11 @@
 	ld [wWhichMomItem], a
 
 	ld hl, MomItemTriggerBalance
-	ld [hl], MOM_MONEY / $10000
+	ld [hl], HIGH(MOM_MONEY >> 8)
 	inc hl
-	ld [hl], MOM_MONEY / $100 % $100
+	ld [hl], HIGH(MOM_MONEY) ; mid
 	inc hl
-	ld [hl], MOM_MONEY % $100
+	ld [hl], LOW(MOM_MONEY)
 
 	call InitializeNPCNames
 
@@ -372,9 +372,9 @@
 .Check2Pass:
 	ld a, $8
 	ld [MusicFade], a
-	ld a, MUSIC_NONE % $100
+	ld a, LOW(MUSIC_NONE)
 	ld [MusicFadeID], a
-	ld a, MUSIC_NONE / $100
+	ld a, HIGH(MUSIC_NONE)
 	ld [MusicFadeID + 1], a
 	call ClearBGPalettes
 	call Continue_MobileAdapterMenu
@@ -426,9 +426,9 @@
 	ret nz
 	ld a, 5
 	ld [MusicFade], a
-	ld a, MUSIC_MOBILE_ADAPTER_MENU % $100
+	ld a, LOW(MUSIC_MOBILE_ADAPTER_MENU)
 	ld [MusicFadeID], a
-	ld a, MUSIC_MOBILE_ADAPTER_MENU / $100
+	ld a, HIGH(MUSIC_MOBILE_ADAPTER_MENU)
 	ld [MusicFadeID + 1], a
 	ld c, 20
 	call DelayFrames
@@ -437,9 +437,9 @@
 	farcall _SaveData
 	ld a, 8
 	ld [MusicFade], a
-	ld a, MUSIC_NONE % $100
+	ld a, LOW(MUSIC_NONE)
 	ld [MusicFadeID], a
-	ld a, MUSIC_NONE / $100
+	ld a, HIGH(MUSIC_NONE)
 	ld [MusicFadeID + 1], a
 	ld c, 35
 	call DelayFrames
@@ -1405,9 +1405,9 @@
 	call ClearWindowData
 	call ClearBGPalettes
 	call ClearTileMap
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [hBGMapAddress + 1], a
-	xor a
+	xor a ; LOW(VBGMap0)
 	ld [hBGMapAddress], a
 	ld [hJoyDown], a
 	ld [hSCX], a
--- a/engine/item_effects.asm
+++ b/engine/item_effects.asm
@@ -861,7 +861,7 @@
 
 .compare
 	ld c, a
-	cp 1024 >> 8 ; 102.4 kg
+	cp HIGH(1024) ; 102.4 kg
 	jr c, .lightmon
 
 	ld hl, .WeightsTable
@@ -892,10 +892,10 @@
 
 .WeightsTable:
 ; weight factor, boost
-	db 2048 >> 8, 0
-	db 3072 >> 8, 20
-	db 4096 >> 8, 30
-	db 65280 >> 8, 40
+	db HIGH(2048),   0
+	db HIGH(3072),  20
+	db HIGH(4096),  30
+	db HIGH(65280), 40
 
 LureBallMultiplier:
 ; multiply catch rate by 3 if this is a fishing rod battle
--- a/engine/items.asm
+++ b/engine/items.asm
@@ -124,28 +124,28 @@
 
 DoesHLEqualNumItems: ; d27b
 	ld a, l
-	cp NumItems % $100
+	cp LOW(NumItems)
 	ret nz
 	ld a, h
-	cp NumItems / $100
+	cp HIGH(NumItems)
 	ret
 
 GetPocketCapacity: ; d283
 	ld c, MAX_ITEMS
 	ld a, e
-	cp NumItems % $100
+	cp LOW(NumItems)
 	jr nz, .not_bag
 	ld a, d
-	cp NumItems / $100
+	cp HIGH(NumItems)
 	ret z
 
 .not_bag
 	ld c, MAX_PC_ITEMS
 	ld a, e
-	cp PCItems % $100
+	cp LOW(PCItems)
 	jr nz, .not_pc
 	ld a, d
-	cp PCItems / $100
+	cp HIGH(PCItems)
 	ret z
 
 .not_pc
--- a/engine/link.asm
+++ b/engine/link.asm
@@ -162,9 +162,9 @@
 	ld [de], a
 	ld hl, wTimeCapsulePartyMon1Species
 	call Function2868a
-	ld a, OTPartyMonOT % $100
+	ld a, LOW(OTPartyMonOT)
 	ld [wUnusedD102], a
-	ld a, OTPartyMonOT / $100
+	ld a, HIGH(OTPartyMonOT)
 	ld [wUnusedD102 + 1], a
 	ld de, MUSIC_NONE
 	call PlayMusic
@@ -333,10 +333,10 @@
 	push bc
 	ld bc, MAIL_MSG_LENGTH + 1
 	call CopyBytes
-	ld a, (MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1)) % $100
+	ld a, LOW(MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1))
 	add e
 	ld e, a
-	ld a, (MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1)) / $100
+	ld a, HIGH(MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1))
 	adc d
 	ld d, a
 	pop bc
@@ -346,10 +346,10 @@
 	ld b, PARTY_LENGTH
 .copy_author_loop
 	push bc
-	ld a, (MAIL_MSG_LENGTH + 1) % $100
+	ld a, LOW(MAIL_MSG_LENGTH + 1)
 	add e
 	ld e, a
-	ld a, (MAIL_MSG_LENGTH + 1) / $100
+	ld a, HIGH(MAIL_MSG_LENGTH + 1)
 	adc d
 	ld d, a
 	ld bc, MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1)
@@ -403,9 +403,9 @@
 	ld de, OTPartyMons
 	ld bc, OTPartyDataEnd - OTPartyMons
 	call CopyBytes
-	ld a, OTPartyMonOT % $100
+	ld a, LOW(OTPartyMonOT)
 	ld [wUnusedD102], a
-	ld a, OTPartyMonOT / $100
+	ld a, HIGH(OTPartyMonOT)
 	ld [wUnusedD102 + 1], a
 	ld de, MUSIC_NONE
 	call PlayMusic
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -2812,7 +2812,7 @@
 .fill
 	ld a, [VramState]
 	bit 1, a
-	ld b, SpritesEnd % $100
+	ld b, LOW(SpritesEnd)
 	jr z, .ok
 	ld b, 28 * 4
 .ok
@@ -2820,7 +2820,7 @@
 	cp b
 	ret nc
 	ld l, a
-	ld h, Sprites / $100
+	ld h, HIGH(Sprites)
 	ld de, 4
 	ld a, b
 	ld c, SCREEN_HEIGHT_PX + 16
@@ -3032,11 +3032,11 @@
 	ld l, a
 	ld a, [hUsedSpriteIndex]
 	ld c, a
-	ld b, Sprites / $100
+	ld b, HIGH(Sprites)
 	ld a, [hli]
 	ld [hUsedSpriteTile], a
 	add c
-	cp SpritesEnd % $100
+	cp LOW(SpritesEnd)
 	jr nc, .full
 .addsprite
 	ld a, [hFFC0]
--- a/engine/move_mon.asm
+++ b/engine/move_mon.asm
@@ -1570,18 +1570,18 @@
 
 .no_overflow_4
 	ld a, [hQuotient + 1]
-	cp (1000 / $100) + 1
+	cp HIGH(MAX_STAT_VALUE + 1) + 1
 	jr nc, .max_stat
-	cp 1000 / $100
+	cp HIGH(MAX_STAT_VALUE + 1)
 	jr c, .stat_value_okay
 	ld a, [hQuotient + 2]
-	cp 1000 % $100
+	cp LOW(MAX_STAT_VALUE + 1)
 	jr c, .stat_value_okay
 
 .max_stat
-	ld a, MAX_STAT_VALUE / $100
+	ld a, HIGH(MAX_STAT_VALUE)
 	ld [hMultiplicand + 1], a
-	ld a, MAX_STAT_VALUE % $100
+	ld a, LOW(MAX_STAT_VALUE)
 	ld [hMultiplicand + 2], a
 
 .stat_value_okay
@@ -1702,9 +1702,9 @@
 	ld hl, PartyMon1ID
 	ld bc, PARTYMON_STRUCT_LENGTH
 	call AddNTimes
-	ld a, 01001 / $100
+	ld a, HIGH(01001)
 	ld [hli], a
-	ld [hl], 01001 % $100
+	ld [hl], LOW(01001)
 	pop bc
 	farcall SetGiftPartyMonCaughtData
 	jr .skip_nickname
--- a/engine/mystery_gift.asm
+++ b/engine/mystery_gift.asm
@@ -264,7 +264,7 @@
 	ld a, [rLY]
 	cp $90
 	jr c, .ly_loop
-	ld c, rRP % $100
+	ld c, LOW(rRP)
 	ld a, $c0
 	ld [$ff00+c], a
 	ld b, 240 ; This might have been intended as a 4-second timeout buffer.
@@ -274,7 +274,7 @@
 	call MysteryGift_ReadJoypad
 
 	ld b, $2
-	ld c, rRP % $100
+	ld c, LOW(rRP)
 	; Delay frame
 .ly_loop2
 	ld a, [$ff00+c]
@@ -715,7 +715,7 @@
 .loop
 	call MysteryGift_ReadJoypad
 	ld b, $2
-	ld c, rRP % $100
+	ld c, LOW(rRP)
 	ld a, [hMGJoypadReleased]
 	bit B_BUTTON_F, a
 	jr z, .next
@@ -731,7 +731,7 @@
 	jr nz, .loop
 
 Function104dfe: ; 104dfe (41:4dfe)
-	ld c, rRP % $100
+	ld c, LOW(rRP)
 	ld d, $0
 	ld e, d
 	call Function104db7
@@ -771,7 +771,7 @@
 Function104e46: ; 104e46 (41:4e46)
 	ld a, $2
 	ld [hPrintNum9], a
-	ld c, rRP % $100
+	ld c, LOW(rRP)
 	ld d, $0
 	ld e, d
 	ld d, $3d
@@ -812,7 +812,7 @@
 	ld [hPrintNum6], a
 	push hl
 	push bc
-	ld c, rRP % $100
+	ld c, LOW(rRP)
 	ld d, $3d
 	call Function104dd1
 	ld hl, hPrintNum2
@@ -844,7 +844,7 @@
 	ret
 
 Function104ed6: ; 104ed6 (41:4ed6)
-	ld c, rRP % $100
+	ld c, LOW(rRP)
 	ld d, $5
 	call Function104dd1
 	ld d, $5
@@ -981,7 +981,7 @@
 	ret
 
 Function104faf: ; 104faf (41:4faf)
-	ld c, rRP % $100
+	ld c, LOW(rRP)
 	ld d, $0
 	call Function104db7
 	jp z, Function104f42
--- a/engine/namingscreen.asm
+++ b/engine/namingscreen.asm
@@ -235,10 +235,10 @@
 	pop de
 	ld b, SPRITE_ANIM_INDEX_RED_WALK
 	ld a, d
-	cp KrisSpriteGFX / $100
+	cp HIGH(KrisSpriteGFX)
 	jr nz, .not_kris
 	ld a, e
-	cp KrisSpriteGFX % $100
+	cp LOW(KrisSpriteGFX)
 	jr nz, .not_kris
 	ld b, SPRITE_ANIM_INDEX_BLUE_WALK
 .not_kris
--- a/engine/odd_eggs.asm
+++ b/engine/odd_eggs.asm
@@ -15,10 +15,10 @@
 
 	; Break on $ffff.
 	ld a, d
-	cp $ffff / $100
+	cp HIGH($ffff)
 	jr nz, .not_done
 	ld a, e
-	cp $ffff % $100
+	cp LOW($ffff)
 	jr z, .done
 .not_done
 
@@ -60,14 +60,14 @@
 	ld [wMobileMonSpeciesBuffer], a
 
 	; load pointer to (wMobileMonSpeciesBuffer - 1) in wMobileMonSpeciesPointerBuffer
-	ld a, (wMobileMonSpeciesBuffer - 1) % $100
+	ld a, LOW(wMobileMonSpeciesBuffer - 1)
 	ld [wMobileMonSpeciesPointerBuffer], a
-	ld a, (wMobileMonSpeciesBuffer - 1) / $100
+	ld a, HIGH(wMobileMonSpeciesBuffer - 1)
 	ld [wMobileMonSpeciesPointerBuffer + 1], a
 	; load pointer to OddEggSpecies in wMobileMonStructurePointerBuffer
-	ld a, OddEggSpecies % $100
+	ld a, LOW(OddEggSpecies)
 	ld [wMobileMonStructurePointerBuffer], a
-	ld a, OddEggSpecies / $100
+	ld a, HIGH(OddEggSpecies)
 	ld [wMobileMonStructurePointerBuffer + 1], a
 
 	; load Odd Egg Name in wTempOddEggNickname
@@ -77,14 +77,14 @@
 	call CopyBytes
 
 	; load pointer to wTempOddEggNickname in wMobileMonOTNamePointerBuffer
-	ld a, wTempOddEggNickname % $100
+	ld a, LOW(wTempOddEggNickname)
 	ld [wMobileMonOTNamePointerBuffer], a
-	ld a, wTempOddEggNickname / $100
+	ld a, HIGH(wTempOddEggNickname)
 	ld [wMobileMonOTNamePointerBuffer + 1], a
 	; load pointer to wOddEggName in wMobileMonNicknamePointerBuffer
-	ld a, wOddEggName % $100
+	ld a, LOW(wOddEggName)
 	ld [wMobileMonNicknamePointerBuffer], a
-	ld a, wOddEggName / $100
+	ld a, HIGH(wOddEggName)
 	ld [wMobileMonNicknamePointerBuffer + 1], a
 	farcall AddMobileMonToParty
 	ret
--- a/engine/overworld.asm
+++ b/engine/overworld.asm
@@ -663,10 +663,10 @@
 	add hl, hl
 endr
 	ld a, l
-	add VTiles0 % $100
+	add LOW(VTiles0)
 	ld l, a
 	ld a, h
-	adc VTiles0 / $100
+	adc HIGH(VTiles0)
 	ld h, a
 	ret
 ; 14418
--- a/engine/party_menu.asm
+++ b/engine/party_menu.asm
@@ -587,10 +587,10 @@
 
 
 PartyMenuCheckEgg: ; 50389
-	ld a, PartySpecies % $100
+	ld a, LOW(PartySpecies)
 	add b
 	ld e, a
-	ld a, PartySpecies / $100
+	ld a, HIGH(PartySpecies)
 	adc 0
 	ld d, a
 	ld a, [de]
--- a/engine/player_step.asm
+++ b/engine/player_step.asm
@@ -156,7 +156,7 @@
 	ld a, [wBGMapAnchor + 1]
 	inc a
 	and $3
-	or VBGMap0 / $100
+	or HIGH(VBGMap0)
 	ld [wBGMapAnchor + 1], a
 .not_overflowed
 	ld hl, wMetatileStandingY
@@ -187,7 +187,7 @@
 	ld a, [wBGMapAnchor + 1]
 	dec a
 	and $3
-	or VBGMap0 / $100
+	or HIGH(VBGMap0)
 	ld [wBGMapAnchor + 1], a
 .not_underflowed
 	ld hl, wMetatileStandingY
--- a/engine/pokegear.asm
+++ b/engine/pokegear.asm
@@ -35,9 +35,9 @@
 	pop af
 	ld [Options], a
 	call ClearBGPalettes
-	xor a
+	xor a ; LOW(VBGMap0)
 	ld [hBGMapAddress], a
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [hBGMapAddress + 1], a
 	ld a, $90
 	ld [hWY], a
@@ -243,9 +243,9 @@
 	ld a, [wcf65]
 	and a
 	jr nz, .kanto_0
-	xor a
+	xor a ; LOW(VBGMap0)
 	ld [hBGMapAddress], a
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [hBGMapAddress + 1], a
 	call .UpdateBGMap
 	ld a, $90
@@ -252,9 +252,9 @@
 	jr .finish
 
 .kanto_0
-	xor a
+	xor a ; LOW(VBGMap1)
 	ld [hBGMapAddress], a
-	ld a, VBGMap1 / $100
+	ld a, HIGH(VBGMap1)
 	ld [hBGMapAddress + 1], a
 	call .UpdateBGMap
 	xor a
@@ -2161,9 +2161,9 @@
 	call ClearBGPalettes
 	ld a, $90
 	ld [hWY], a
-	xor a
+	xor a ; LOW(VBGMap0)
 	ld [hBGMapAddress], a
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [hBGMapAddress + 1], a
 	ld a, [wTownMapPlayerIconLandmark]
 	ld e, a
@@ -3003,9 +3003,9 @@
 	call ClearBGPalettes
 	ld a, $90
 	ld [hWY], a
-	xor a
+	xor a ; LOW(VBGMap0)
 	ld [hBGMapAddress], a
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [hBGMapAddress + 1], a
 	ld a, [wTownMapPlayerIconLandmark]
 	ld e, a
--- a/engine/printer_serial.asm
+++ b/engine/printer_serial.asm
@@ -109,9 +109,9 @@
 	call Printer_CopyPacket
 	; prepare to send 40 tiles
 	call Printer_Convert2RowsTo2bpp
-	ld a, (40 tiles) % $100
+	ld a, LOW(40 tiles)
 	ld [wPrinterSendByteCounter], a
-	ld a, (40 tiles) / $100
+	ld a, HIGH(40 tiles)
 	ld [wPrinterSendByteCounter + 1], a
 	; compute the checksum
 	call Printer_ComputeChecksum
@@ -142,9 +142,9 @@
 	call Printer_CopyPacket
 	; prepare to send 1 tile
 	call Printer_StageHeaderForSend
-	ld a, 4 % $100
+	ld a, LOW(4)
 	ld [wPrinterSendByteCounter], a
-	ld a, 4 / $100
+	ld a, HIGH(4)
 	ld [wPrinterSendByteCounter + 1], a
 	; compute the checksum
 	call Printer_ComputeChecksum
--- a/engine/printnum.asm
+++ b/engine/printnum.asm
@@ -80,51 +80,51 @@
 	jr z, .six
 
 .seven
-	ld a, 1000000 / $10000 % $100
+	ld a, HIGH(1000000 >> 8)
 	ld [hPrintNum5], a
-	ld a, 1000000 / $100 % $100
+	ld a, HIGH(1000000) ; mid
 	ld [hPrintNum6], a
-	ld a, 1000000 % $100
+	ld a, LOW(1000000)
 	ld [hPrintNum7], a
 	call .PrintDigit
 	call .AdvancePointer
 
 .six
-	ld a, 100000 / $10000 % $100
+	ld a, HIGH(100000 >> 8)
 	ld [hPrintNum5], a
-	ld a, 100000 / $100 % $100
+	ld a, HIGH(100000) ; mid
 	ld [hPrintNum6], a
-	ld a, 100000 % $100
+	ld a, LOW(100000)
 	ld [hPrintNum7], a
 	call .PrintDigit
 	call .AdvancePointer
 
 .five
-	xor a
+	xor a ; HIGH(10000 >> 8)
 	ld [hPrintNum5], a
-	ld a, 10000 / $100
+	ld a, HIGH(10000) ; mid
 	ld [hPrintNum6], a
-	ld a, 10000 % $100
+	ld a, LOW(10000)
 	ld [hPrintNum7], a
 	call .PrintDigit
 	call .AdvancePointer
 
 .four
-	xor a
+	xor a ; HIGH(1000 >> 8)
 	ld [hPrintNum5], a
-	ld a, 1000 / $100
+	ld a, HIGH(1000) ; mid
 	ld [hPrintNum6], a
-	ld a, 1000 % $100
+	ld a, LOW(1000)
 	ld [hPrintNum7], a
 	call .PrintDigit
 	call .AdvancePointer
 
 .three
-	xor a
+	xor a ; HIGH(100 >> 8)
 	ld [hPrintNum5], a
-	xor a
+	xor a ; HIGH(100) ; mid
 	ld [hPrintNum6], a
-	ld a, 100
+	ld a, LOW(100)
 	ld [hPrintNum7], a
 	call .PrintDigit
 	call .AdvancePointer
--- a/engine/routines/loadpushoam.asm
+++ b/engine/routines/loadpushoam.asm
@@ -11,7 +11,7 @@
 	ret
 
 .PushOAM: ; 403f
-	ld a, Sprites / $100
+	ld a, HIGH(Sprites)
 	ld [rDMA], a
 	ld a, (SpritesEnd - Sprites) / 4 ; 40
 .pushoam_loop
--- a/engine/routines/phonering_copytilemapatonce.asm
+++ b/engine/routines/phonering_copytilemapatonce.asm
@@ -50,7 +50,7 @@
 	ld a, SCREEN_HEIGHT
 	ld [hTilesPerCycle], a
 	ld b, 1 << 1 ; not in v/hblank
-	ld c, rSTAT % $100
+	ld c, LOW(rSTAT)
 
 .loop
 rept SCREEN_WIDTH / 2
--- a/engine/routines/savemenu_copytilemapatonce.asm
+++ b/engine/routines/savemenu_copytilemapatonce.asm
@@ -47,7 +47,7 @@
 	ld a, SCREEN_HEIGHT
 	ld [hTilesPerCycle], a
 	ld b, 1 << 1
-	ld c, rSTAT % $100
+	ld c, LOW(rSTAT)
 
 .loop
 rept SCREEN_WIDTH / 2
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -471,10 +471,10 @@
 
 Slot_CheckCoinCaseFull: ; 92a04 (24:6a04)
 	ld a, d
-	cp MAX_COINS / $100
+	cp HIGH(MAX_COINS)
 	jr c, .not_full
 	ld a, e
-	cp MAX_COINS % $100
+	cp LOW(MAX_COINS)
 	jr c, .not_full
 	scf
 	ret
@@ -771,10 +771,10 @@
 	push hl
 	srl a
 	srl a
-	add .Unknown_92bce % $100
+	add LOW(.Unknown_92bce)
 	ld l, a
 	ld a, 0
-	adc .Unknown_92bce / $100
+	adc HIGH(.Unknown_92bce)
 	ld h, a
 	ld a, [hl]
 	pop hl
--- a/engine/specials.asm
+++ b/engine/specials.asm
@@ -617,9 +617,9 @@
 
 
 Special_FadeOutMusic: ; c48f
-	ld a, MUSIC_NONE % $100
+	ld a, LOW(MUSIC_NONE)
 	ld [MusicFadeID], a
-	ld a, MUSIC_NONE / $100
+	ld a, HIGH(MUSIC_NONE)
 	ld [MusicFadeID + 1], a
 	ld a, $2
 	ld [MusicFade], a
--- a/engine/sprites.asm
+++ b/engine/sprites.asm
@@ -23,7 +23,7 @@
 	push bc
 	push af
 
-	ld a, Sprites % $100
+	ld a, LOW(Sprites)
 	ld [wCurrSpriteOAMAddr], a
 	call DoNextFrameForAllSprites
 
@@ -60,11 +60,11 @@
 
 	ld a, [wCurrSpriteOAMAddr]
 	ld l, a
-	ld h, Sprites / $100
+	ld h, HIGH(Sprites)
 
 .loop2 ; Clear (Sprites + [wCurrSpriteOAMAddr] --> SpritesEnd)
 	ld a, l
-	cp SpritesEnd % $100
+	cp LOW(SpritesEnd)
 	jr nc, .done
 	xor a
 	ld [hli], a
@@ -100,11 +100,11 @@
 
 	ld a, [wCurrSpriteOAMAddr]
 	ld l, a
-	ld h, (Sprites + $40) / $100
+	ld h, HIGH(Sprites + 16 * 4)
 
 .loop2 ; Clear (Sprites + [wCurrSpriteOAMAddr] --> Sprites + $40)
 	ld a, l
-	cp (Sprites + 16 * 4) % $100
+	cp LOW(Sprites + 16 * 4)
 	jr nc, .done
 	xor a
 	ld [hli], a
@@ -253,7 +253,7 @@
 	push bc
 	ld a, [wCurrSpriteOAMAddr]
 	ld e, a
-	ld d, Sprites / $100
+	ld d, HIGH(Sprites)
 	ld a, [hli]
 	ld c, a ; number of objects
 .loop
@@ -302,7 +302,7 @@
 	inc de
 	ld a, e
 	ld [wCurrSpriteOAMAddr], a
-	cp SpritesEnd % $100
+	cp LOW(SpritesEnd)
 	jr nc, .reached_the_end
 	dec c
 	jr nz, .loop
--- a/engine/start_battle.asm
+++ b/engine/start_battle.asm
@@ -191,7 +191,7 @@
 	call ClearWindowData
 
 	ld hl, hBGMapAddress
-	xor a
+	xor a ; LOW(VBGMap0)
 	ld [hli], a
-	ld [hl], VBGMap0 / $100
+	ld [hl], HIGH(VBGMap0)
 	ret
--- a/engine/timeset.asm
+++ b/engine/timeset.asm
@@ -9,9 +9,9 @@
 	ld [wSpriteUpdatesEnabled], a
 	ld a, $10
 	ld [MusicFade], a
-	ld a, MUSIC_NONE % $100
+	ld a, LOW(MUSIC_NONE)
 	ld [MusicFadeID], a
-	ld a, MUSIC_NONE / $100
+	ld a, HIGH(MUSIC_NONE)
 	ld [MusicFadeID + 1], a
 	ld c, 8
 	call DelayFrames
--- a/engine/trade_animation.asm
+++ b/engine/trade_animation.asm
@@ -627,7 +627,7 @@
 	push af
 	call ClearBGPalettes
 	call WaitTop
-	ld a, VBGMap1 / $100
+	ld a, HIGH(VBGMap1)
 	ld [hBGMapAddress + 1], a
 	call ClearTileMap
 	hlcoord 0, 0
@@ -657,7 +657,7 @@
 	call ByteFill
 	call WaitBGMap
 	call WaitTop
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [hBGMapAddress + 1], a
 	call ClearTileMap
 	ret
@@ -776,7 +776,7 @@
 
 TradeAnim_ScrollOutRight: ; 293ea
 	call WaitTop
-	ld a, VBGMap1 / $100
+	ld a, HIGH(VBGMap1)
 	ld [hBGMapAddress + 1], a
 	call WaitBGMap
 	ld a, $7
@@ -785,7 +785,7 @@
 	ld [hWY], a
 	call DelayFrame
 	call WaitTop
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [hBGMapAddress + 1], a
 	call ClearTileMap
 	call TradeAnim_IncrementJumptableIndex
@@ -802,7 +802,7 @@
 	ret
 
 .done
-	ld a, VBGMap1 / $100
+	ld a, HIGH(VBGMap1)
 	ld [hBGMapAddress + 1], a
 	call WaitBGMap
 	ld a, $7
@@ -809,7 +809,7 @@
 	ld [hWX], a
 	ld a, $90
 	ld [hWY], a
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [hBGMapAddress + 1], a
 	call TradeAnim_AdvanceScriptPointer
 	ret
@@ -1009,7 +1009,7 @@
 TrademonStats_MonTemplate: ; 29573
 	call WaitTop
 	call TradeAnim_BlankTileMap
-	ld a, VBGMap1 / $100
+	ld a, HIGH(VBGMap1)
 	ld [hBGMapAddress + 1], a
 	hlcoord 3, 0
 	ld b, $6
@@ -1032,7 +1032,7 @@
 TrademonStats_Egg: ; 295a1
 	call WaitTop
 	call TradeAnim_BlankTileMap
-	ld a, VBGMap1 / $100
+	ld a, HIGH(VBGMap1)
 	ld [hBGMapAddress + 1], a
 	hlcoord 3, 0
 	ld b, 6
@@ -1055,7 +1055,7 @@
 TrademonStats_WaitBGMap: ; 295d8
 	call WaitBGMap
 	call WaitTop
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [hBGMapAddress + 1], a
 	ret
 
--- a/engine/warp_connection.asm
+++ b/engine/warp_connection.asm
@@ -233,9 +233,9 @@
 	ret
 
 .ClearBGMap: ; 104770 (41:4770)
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [wBGMapAnchor + 1], a
-	xor a
+	xor a ; LOW(VBGMap0)
 	ld [wBGMapAnchor], a
 	ld [hSCY], a
 	ld [hSCX], a
--- a/event/halloffame.asm
+++ b/event/halloffame.asm
@@ -36,9 +36,9 @@
 ; 0x86455
 
 RedCredits:: ; 86455
-	ld a, MUSIC_NONE % $100
+	ld a, LOW(MUSIC_NONE)
 	ld [MusicFadeID], a
-	ld a, MUSIC_NONE / $100
+	ld a, HIGH(MUSIC_NONE)
 	ld [MusicFadeID + 1], a
 	ld a, 10
 	ld [MusicFade], a
@@ -59,9 +59,9 @@
 ; 8648e
 
 HallOfFame_FadeOutMusic: ; 8648e
-	ld a, MUSIC_NONE % $100
+	ld a, LOW(MUSIC_NONE)
 	ld [MusicFadeID], a
-	ld a, MUSIC_NONE / $100
+	ld a, HIGH(MUSIC_NONE)
 	ld [MusicFadeID + 1], a
 	ld a, 10
 	ld [MusicFade], a
--- a/event/happiness_egg.asm
+++ b/event/happiness_egg.asm
@@ -159,9 +159,9 @@
 	dec hl
 	inc [hl]
 	ld a, [hl]
-	cp 5242880 / $10000
+	cp HIGH($500000 >> 8)
 	jr c, .day_care_lady
-	ld a, 5242880 / $10000
+	ld a, HIGH($500000 >> 8)
 	ld [hl], a
 
 .day_care_lady
@@ -181,9 +181,9 @@
 	dec hl
 	inc [hl]
 	ld a, [hl]
-	cp 5242880 / $10000
+	cp HIGH($500000 >> 8)
 	jr c, .check_egg
-	ld a, 5242880 / $10000
+	ld a, HIGH($500000 >> 8)
 	ld [hl], a
 
 .check_egg
--- a/event/magikarp.asm
+++ b/event/magikarp.asm
@@ -127,7 +127,7 @@
 
 ; if bc < 10:    [wMagikarpLength] = c + 190
 ; if bc ≥ $ff00: [wMagikarpLength] = c + 1370
-; else:          [wMagikarpLength] = z × 100 + (bc − x) / y
+; else:          [wMagikarpLength] = z * 100 + (bc - x) / y
 
 ; X, Y, and Z depend on the value of b as follows:
 
--- a/event/mom_phone.asm
+++ b/event/mom_phone.asm
@@ -83,11 +83,11 @@
 
 .check_have_2300
 	ld hl, hMoneyTemp
-	ld [hl], MOM_MONEY / $10000
+	ld [hl], HIGH(MOM_MONEY >> 8)
 	inc hl
-	ld [hl], MOM_MONEY / $100 % $100
+	ld [hl], HIGH(MOM_MONEY) ; mid
 	inc hl
-	ld [hl], MOM_MONEY % $100
+	ld [hl], LOW(MOM_MONEY)
 .loop
 	ld de, MomItemTriggerBalance
 	ld bc, wMomsMoney
--- a/event/poisonstep_pals.asm
+++ b/event/poisonstep_pals.asm
@@ -32,9 +32,9 @@
 	ld c, $20
 .loop
 ; RGB 28, 21, 31
-	ld a, (palred 28 + palgreen 21 + palblue 31) % $100
+	ld a, LOW(palred 28 + palgreen 21 + palblue 31)
 	ld [hli], a
-	ld a, (palred 28 + palgreen 21 + palblue 31) / $100
+	ld a, HIGH(palred 28 + palgreen 21 + palblue 31)
 	ld [hli], a
 	dec c
 	jr nz, .loop
--- a/event/special.asm
+++ b/event/special.asm
@@ -85,10 +85,10 @@
 
 ; OT ID
 	ld a, [hli]
-	cp 00518 / $100
+	cp HIGH(00518)
 	jr nz, .DontReturn
 	ld a, [hl]
-	cp 00518 % $100
+	cp LOW(00518)
 	jr nz, .DontReturn
 
 ; OT
--- a/event/unown.asm
+++ b/event/unown.asm
@@ -59,10 +59,10 @@
 
 	call GetSecondaryMapHeaderPointer
 	ld a, h
-	cp RuinsOfAlphAerodactylChamber_SecondMapHeader / $100
+	cp HIGH(RuinsOfAlphAerodactylChamber_SecondMapHeader)
 	jr nz, .nope
 	ld a, l
-	cp RuinsOfAlphAerodactylChamber_SecondMapHeader % $100
+	cp LOW(RuinsOfAlphAerodactylChamber_SecondMapHeader)
 	jr nz, .nope
 
 	ld de, EVENT_WALL_OPENED_IN_AERODACTYL_CHAMBER
@@ -87,10 +87,10 @@
 
 	call GetSecondaryMapHeaderPointer
 	ld a, h
-	cp RuinsOfAlphKabutoChamber_SecondMapHeader / $100
+	cp HIGH(RuinsOfAlphKabutoChamber_SecondMapHeader)
 	jr nz, .done
 	ld a, l
-	cp RuinsOfAlphKabutoChamber_SecondMapHeader % $100
+	cp LOW(RuinsOfAlphKabutoChamber_SecondMapHeader)
 	jr nz, .done
 
 	ld de, EVENT_WALL_OPENED_IN_KABUTO_CHAMBER
--- a/home.asm
+++ b/home.asm
@@ -606,7 +606,7 @@
 	ld a, SCREEN_HEIGHT
 	ld [hTilesPerCycle], a
 	ld b, 1 << 1 ; not in v/hblank
-	ld c, rSTAT % $100
+	ld c, LOW(rSTAT)
 
 .loop
 rept SCREEN_WIDTH / 2
@@ -1350,14 +1350,14 @@
 	and a
 	ret z
 
-	ld a, LYOverridesBackup % $100
+	ld a, LOW(LYOverridesBackup)
 	ld [Requested2bppSource], a
-	ld a, LYOverridesBackup / $100
+	ld a, HIGH(LYOverridesBackup)
 	ld [Requested2bppSource + 1], a
 
-	ld a, LYOverrides % $100
+	ld a, LOW(LYOverrides)
 	ld [Requested2bppDest], a
-	ld a, LYOverrides / $100
+	ld a, HIGH(LYOverrides)
 	ld [Requested2bppDest + 1], a
 
 	ld a, (LYOverridesEnd - LYOverrides) / 16
--- a/home/copy.asm
+++ b/home/copy.asm
@@ -72,16 +72,16 @@
 	call DelayFrame
 ; add $100 to hl and de
 	ld a, l
-	add $100 % $100
+	add LOW($100)
 	ld l, a
 	ld a, h
-	adc $100 / $100
+	adc HIGH($100)
 	ld h, a
 	ld a, e
-	add $100 % $100
+	add LOW($100)
 	ld e, a
 	ld a, d
-	adc $100 / $100
+	adc HIGH($100)
 	ld d, a
 	jr .loop
 
--- a/home/game_time.asm
+++ b/home/game_time.asm
@@ -106,11 +106,11 @@
 
 ; Cap the timer after 1000 hours.
 	ld a, h
-	cp 1000 / $100
+	cp HIGH(1000)
 	jr c, .ok
 
 	ld a, l
-	cp 1000 % $100
+	cp LOW(1000)
 	jr c, .ok
 
 	ld hl, GameTimeCap
--- a/home/init.asm
+++ b/home/init.asm
@@ -141,9 +141,9 @@
 
 	farcall InitCGBPals
 
-	ld a, VBGMap1 / $100
+	ld a, HIGH(VBGMap1)
 	ld [hBGMapAddress + 1], a
-	xor a ; VBGMap1 % $100
+	xor a ; LOW(VBGMap1)
 	ld [hBGMapAddress], a
 
 	farcall StartClock
@@ -201,7 +201,7 @@
 	push af
 	ld [rSVBK], a
 	xor a
-	ld hl, $d000
+	ld hl, wRAM1Start
 	ld bc, $1000
 	call ByteFill
 	pop af
--- a/home/lcd.asm
+++ b/home/lcd.asm
@@ -23,7 +23,7 @@
 	push bc
 	ld a, [rLY]
 	ld c, a
-	ld b, LYOverrides >> 8
+	ld b, HIGH(LYOverrides)
 	ld a, [bc]
 	ld b, a
 	ld a, [hLCDCPointer]
--- a/home/map.asm
+++ b/home/map.asm
@@ -1241,10 +1241,10 @@
 	ld h, a
 	ld bc, $0200
 	add hl, bc
-; cap d at VBGMap1 / $100
+; cap d at HIGH(VBGMap0)
 	ld a, h
 	and %00000011
-	or VBGMap0 / $100
+	or HIGH(VBGMap0)
 	ld e, l
 	ld d, a
 	call UpdateBGMapRow
@@ -1369,10 +1369,10 @@
 	ld e, a
 	jr nc, .skip
 	inc d
-; cap d at VBGMap1 / $100
+; cap d at HIGH(VBGMap0)
 	ld a, d
 	and $3
-	or VBGMap0 / $100
+	or HIGH(VBGMap0)
 	ld d, a
 
 .skip
--- a/home/movement.asm
+++ b/home/movement.asm
@@ -4,9 +4,9 @@
 	ld [wMovementBufferCount], a
 	ld a, $0 ; useless
 	ld [wUnusedMovementBufferBank], a
-	ld a, MovementBuffer % $100
+	ld a, LOW(MovementBuffer)
 	ld [wUnusedMovementBufferPointer], a
-	ld a, MovementBuffer / $100
+	ld a, HIGH(MovementBuffer)
 	ld [wUnusedMovementBufferPointer + 1], a
 	ret
 ; 1b35
--- a/home/palettes.asm
+++ b/home/palettes.asm
@@ -24,18 +24,18 @@
 
 	ld a, [rSVBK]
 	push af
-	ld a, 5 ; BANK(BGPals)
+	ld a, BANK(BGPals)
 	ld [rSVBK], a
 
-	ld hl, BGPals ; 5:d080
+	ld hl, BGPals
 
 ; copy 8 pals to bgpd
 	ld a, %10000000 ; auto increment, index 0
 	ld [rBGPI], a
-	ld c, rBGPD % $100
-	ld b, 4 ; NUM_PALS / 2
+	ld c, LOW(rBGPD)
+	ld b, 8 / 2
 .bgp
-rept 2 palettes
+rept (1 palettes) * 2
 	ld a, [hli]
 	ld [$ff00+c], a
 endr
@@ -43,15 +43,15 @@
 	dec b
 	jr nz, .bgp
 
-; hl is now 5:d0c0 OBPals
+; hl is now OBPals
 
 ; copy 8 pals to obpd
 	ld a, %10000000 ; auto increment, index 0
 	ld [rOBPI], a
-	ld c, rOBPD % $100
-	ld b, 4 ; NUM_PALS / 2
+	ld c, LOW(rOBPD)
+	ld b, 8 / 2
 .obp
-rept 2 palettes
+rept (1 palettes) * 2
 	ld a, [hli]
 	ld [$ff00+c], a
 endr
@@ -90,7 +90,7 @@
 	ld a, [rSVBK]
 	push af
 
-	ld a, 5 ; gfx
+	ld a, BANK(BGPals)
 	ld [rSVBK], a
 
 ; copy & reorder bg pal buffer
@@ -138,7 +138,7 @@
 	ld a, [rSVBK]
 	push af
 
-	ld a, 5
+	ld a, BANK(OBPals)
 	ld [rSVBK], a
 
 ; copy & reorder obj pal buffer
@@ -178,11 +178,11 @@
 
 	ld a, [rSVBK]
 	push af
-	ld a, 5 ; gfx
+	ld a, BANK(OBPals)
 	ld [rSVBK], a
 
-	ld hl, OBPals
-	ld de, UnknOBPals
+	ld hl, OBPals palette 0
+	ld de, UnknOBPals palette 0
 	ld a, [rOBP0]
 	ld b, a
 	ld c, 1
@@ -216,11 +216,11 @@
 
 	ld a, [rSVBK]
 	push af
-	ld a, 5 ; gfx
+	ld a, BANK(OBPals)
 	ld [rSVBK], a
 
-	ld hl, OBPals + 1 palettes
-	ld de, UnknOBPals + 1 palettes
+	ld hl, OBPals palette 1
+	ld de, UnknOBPals palette 1
 	ld a, [rOBP1]
 	ld b, a
 	ld c, 1
@@ -325,10 +325,10 @@
 	ret z
 	ld a, [rSVBK]
 	push af
-	ld a, 5 ; BANK(BGPals)
+	ld a, BANK(BGPals)
 	ld [rSVBK], a
 	ld hl, BGPals
-	ld bc, $40 + $10
+	ld bc, (8 palettes) + (2 palettes)
 	xor a
 	call ByteFill
 	pop af
--- a/home/video.asm
+++ b/home/video.asm
@@ -143,9 +143,9 @@
 	ld h, a
 	push hl
 
-	xor a
+	xor a ; LOW(VBGMap1)
 	ld [hBGMapAddress], a
-	ld a, VBGMap1 >> 8
+	ld a, HIGH(VBGMap1)
 	ld [hBGMapAddress + 1], a
 
 	ld a, [hBGMapMode]
--- a/lib/mobile/main.asm
+++ b/lib/mobile/main.asm
@@ -108,10 +108,10 @@
 	ld a, [$c988]
 	ld l, a
 	push hl
-	ld a, Function110236 % $100
+	ld a, LOW(Function110236)
 	cp l
 	jr nz, .okay
-	ld a, Function110236 / $100
+	ld a, HIGH(Function110236)
 	cp h
 .okay
 	call nz, Function1100b4
@@ -615,7 +615,7 @@
 ; 110393
 
 Function110393: ; 110393
-	ld c, rIE % $100
+	ld c, LOW(rIE)
 	ld a, [$ff00+c]
 	or $c
 	ld [$ff00+c], a
@@ -1969,11 +1969,11 @@
 	push de
 	ld b, 0
 .check_under_10k
-	ld a, 10000 / $100
+	ld a, HIGH(10000)
 	cp h
 	jr c, .subtract_10k
 	jr nz, .done_10k
-	ld a, 10000 % $100
+	ld a, LOW(10000)
 	cp l
 	jr z, .subtract_10k
 	jr nc, .done_10k
@@ -1993,11 +1993,11 @@
 	inc de
 	ld b, 0
 .check_under_1k
-	ld a, 1000 / $100
+	ld a, HIGH(1000)
 	cp h
 	jr c, .subtract_1k
 	jr nz, .done_1k
-	ld a, 1000 % $100
+	ld a, LOW(1000)
 	cp l
 	jr z, .subtract_1k
 	jr nc, .done_1k
@@ -2017,10 +2017,10 @@
 	inc de
 	ld b, 0
 .check_under_100
-	ld a, 100 / $100
+	ld a, HIGH(100)
 	cp h
 	jr nz, .subtract_100
-	ld a, 100 % $100
+	ld a, LOW(100)
 	cp l
 	jr z, .subtract_100
 	jr nc, .check_under_10
@@ -8521,14 +8521,14 @@
 
 .asm_113734
 	ld hl, $cc0c
-	ld a, Unknown_113b8e % $100
+	ld a, LOW(Unknown_113b8e)
 	ld [hli], a
-	ld a, Unknown_113b8e / $100
+	ld a, HIGH(Unknown_113b8e)
 	ld [hl], a
 	ld hl, $cc0e
-	ld a, Unknown_113a70 % $100
+	ld a, LOW(Unknown_113a70)
 	ld [hli], a
-	ld a, Unknown_113a70 / $100
+	ld a, HIGH(Unknown_113a70)
 	ld [hl], a
 	ld hl, $cbe7
 	ld de, $cc18
@@ -8610,7 +8610,7 @@
 	ld [$cc0d], a
 	ld a, l
 	ld [$cc0c], a
-	cp $8e ; XXX (Unknown_113b8e + $100) % $100 ???
+	cp $8e ; XXX ; LOW(Unknown_113b8e + $100) ???
 	jp nz, .asm_113751
 	ld de, $cc18
 	ld hl, $cbe7
--- a/macros.asm
+++ b/macros.asm
@@ -19,7 +19,6 @@
 INCLUDE "macros/scripts/trade_anim.asm"
 INCLUDE "macros/scripts/gfx_anim.asm"
 
-
 percent EQUS "* $ff / 100"
 
 tiles EQUS "* LEN_2BPP_TILE"
--- a/macros/data.asm
+++ b/macros/data.asm
@@ -95,7 +95,7 @@
 ; conditional segment is there because not every instance of
 ; this macro is directly OAM
 if _NARG >= 7 ; y tile, y pxl, x tile, x pxl, vtile offset, flags, palette
-	db (\1 * 8) % $100 + \2, (\3 * 8) % $100 + \4, \5, (\6 << 3) + (\7 & 7)
+	db (\1 * 8) % $100 + \2, (\3 * 8) % $100 + \4, \5, (\6 << 3) + (\7 & PALETTE_MASK)
 else
 	db (\1 * 8) % $100 + \2, (\3 * 8) % $100 + \4, \5, \6
 endc
--- a/mobile/battle_tower_5c.asm
+++ b/mobile/battle_tower_5c.asm
@@ -116,13 +116,13 @@
 	ld a, c
 	ld [de], a
 	inc de
-	ld a, PartyMons % $100
+	ld a, LOW(PartyMons)
 	ld [wcd49], a
-	ld a, PartyMons / $100
+	ld a, HIGH(PartyMons)
 	ld [wcd4a], a
-	ld a, PartyMonNicknames % $100
+	ld a, LOW(PartyMonNicknames)
 	ld [wcd4b], a
-	ld a, PartyMonNicknames / $100
+	ld a, HIGH(PartyMonNicknames)
 	ld [wcd4c], a
 	ld a, 3
 .CopyLoop:
@@ -355,9 +355,9 @@
 	ld hl, wBT_OTTempTrainerClass
 	ld a, [hli]
 	ld [OtherTrainerClass], a
-	ld a, OTPartyMonNicknames % $100
+	ld a, LOW(OTPartyMonNicknames)
 	ld [BGMapBuffer], a
-	ld a, OTPartyMonNicknames / $100
+	ld a, HIGH(OTPartyMonNicknames)
 	ld [BGMapBuffer + 1], a
 
 	; Copy Pkmn into Memory from the address in hl
--- a/mobile/fixed_words.asm
+++ b/mobile/fixed_words.asm
@@ -3015,26 +3015,26 @@
 	ld a, [rSVBK]
 	push af
 	ld hl, $c648
-	ld a, w5_d800 % $100
+	ld a, LOW(w5_d800)
 	ld [wcd2d], a
 	ld [hli], a
-	ld a, w5_d800 / $100
+	ld a, HIGH(w5_d800)
 	ld [wcd2e], a
 	ld [hl], a
 
-	ld a, SortedPokemon % $100
+	ld a, LOW(SortedPokemon)
 	ld [wcd2f], a
-	ld a, SortedPokemon / $100
+	ld a, HIGH(SortedPokemon)
 	ld [wcd30], a
 
-	ld a, $c6a8 % $100
+	ld a, LOW($c6a8)
 	ld [wcd31], a
-	ld a, $c6a8 / $100
+	ld a, HIGH($c6a8)
 	ld [wcd32], a
 
-	ld a, $c64a % $100
+	ld a, LOW($c64a)
 	ld [wcd33], a
-	ld a, $c64a / $100
+	ld a, HIGH($c64a)
 	ld [wcd34], a
 
 	ld hl, EZChat_SortedWords
--- a/mobile/mobile_12.asm
+++ b/mobile/mobile_12.asm
@@ -39,9 +39,9 @@
 .asm_4808a
 	ld a, $5
 	ld [MusicFade], a
-	ld a, MUSIC_MOBILE_ADAPTER_MENU % $100
+	ld a, LOW(MUSIC_MOBILE_ADAPTER_MENU)
 	ld [MusicFadeID], a
-	ld a, MUSIC_MOBILE_ADAPTER_MENU / $100
+	ld a, HIGH(MUSIC_MOBILE_ADAPTER_MENU)
 	ld [MusicFadeID + 1], a
 	ld c, 20
 	call DelayFrames
--- a/mobile/mobile_40.asm
+++ b/mobile/mobile_40.asm
@@ -2736,9 +2736,9 @@
 
 .ContinueCopy:
 	; Copy, via wc608...
-	ld a, wc608 % $100
+	ld a, LOW(wc608)
 	ld [StringBuffer2], a
-	ld a, wc608 / $100
+	ld a, HIGH(wc608)
 	ld [StringBuffer2 + 1], a
 	; ... bc bytes...
 	ld a, c
@@ -7237,9 +7237,9 @@
 	add a
 	add a
 
-	add Unknown_10327a % $100
+	add LOW(Unknown_10327a)
 	ld l, a
-	ld a, Unknown_10327a / $100
+	ld a, HIGH(Unknown_10327a)
 	adc 0
 	ld h, a
 
--- a/mobile/mobile_42.asm
+++ b/mobile/mobile_42.asm
@@ -1297,7 +1297,7 @@
 MobileTradeAnim_DisplayEggData
 	call WaitTop
 	call MobileTradeAnim_ClearTilemap
-	ld a, VBGMap1 / $100
+	ld a, HIGH(VBGMap1)
 	ld [hBGMapAddress + 1], a
 	hlcoord 5, 0
 	ld b, 6
@@ -1320,7 +1320,7 @@
 Function108a33: ; 108a33
 	call WaitTop
 	call MobileTradeAnim_ClearTilemap
-	ld a, VBGMap1 / $100
+	ld a, HIGH(VBGMap1)
 	ld [hBGMapAddress + 1], a
 	hlcoord 5, 0
 	ld b, 6
@@ -1340,7 +1340,7 @@
 MobileTradeAnim_LoadMonTemplate: ; 108a5b
 	call WaitTop
 	call MobileTradeAnim_ClearTilemap
-	ld a, VBGMap1 / $100
+	ld a, HIGH(VBGMap1)
 	ld [hBGMapAddress + 1], a
 	hlcoord 4, 0
 	ld b,  6
@@ -1363,7 +1363,7 @@
 MobileTradeAnim_MonDisplay_UpdateBGMap: ; 108a87
 	call WaitBGMap
 	call WaitTop
-	ld a, VBGMap0 / $100
+	ld a, HIGH(VBGMap0)
 	ld [hBGMapAddress + 1], a
 	ret
 ; 108a92
--- a/mobile/mobile_45.asm
+++ b/mobile/mobile_45.asm
@@ -1,4 +1,3 @@
-
 SECTION "bank45", ROMX
 
 	charmap " ", $20 ; revert to ascii
@@ -7613,9 +7612,9 @@
 	ld c, 8
 .loop
 	push hl
-	ld a, $7fff % $100
+	ld a, LOW(palred 31 + palgreen 31 + palblue 31)
 	ld [hli], a
-	ld a, $7fff / $100
+	ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
 	ld [hl], a
 	pop hl
 	add hl, de
--- a/mobile/mobile_46.asm
+++ b/mobile/mobile_46.asm
@@ -1901,17 +1901,17 @@
 	and a
 	jr z, .asm_118fba
 	ld hl, $c346
-	ld a, $c608 % $100
+	ld a, LOW($c608)
 	ld [hli], a
-	ld a, $c608 / $100
+	ld a, HIGH($c608)
 	ld [hli], a
 	ld a, [wcd4b]
 	ld [hli], a
 	ld a, [wcd4c]
 	ld [hli], a
-	ld a, $c708 % $100
+	ld a, LOW($c708)
 	ld [hli], a
-	ld a, $c708 / $100
+	ld a, HIGH($c708)
 	ld [hli], a
 	ld a, $60
 	ld [hli], a
@@ -2530,17 +2530,17 @@
 	ld [wcd3c], a
 	call BattleTowerRoomMenu2
 	ld hl, $c346
-	ld a, wd000 % $100
+	ld a, LOW(wd000)
 	ld [hli], a
-	ld a, wd000 / $100
+	ld a, HIGH(wd000)
 	ld [hli], a
 	ld a, [wcd3b]
 	ld [hli], a
 	xor a
 	ld [hli], a
-	ld a, $c708 % $100
+	ld a, LOW($c708)
 	ld [hli], a
-	ld a, $c708 / $100
+	ld a, HIGH($c708)
 	ld [hli], a
 	ld a, $60
 	ld [hli], a
@@ -3358,17 +3358,17 @@
 	ld hl, $c608 + 2
 	call Function119940
 	ld hl, w3_d800
-	ld a, $c608 % $100
+	ld a, LOW($c608)
 	ld [hli], a
-	ld a, $c608 / $100
+	ld a, HIGH($c608)
 	ld [hli], a
 	ld a, $f6
 	ld [hli], a
 	xor a
 	ld [hli], a
-	ld a, $c708 % $100
+	ld a, LOW($c708)
 	ld [hli], a
-	ld a, $c708 / $100
+	ld a, HIGH($c708)
 	ld [hli], a
 	ld a, [wcd51]
 	ld [hli], a
@@ -3794,10 +3794,10 @@
 	cp $d
 	jr nz, .asm_119b93
 	ld a, l
-	cp (w3_d869) % $100
+	cp LOW(w3_d869)
 	jr nz, .asm_119be3
 	ld a, h
-	cp (w3_d869) / $100
+	cp HIGH(w3_d869)
 	jr nz, .asm_119be3
 	ld a, $5
 	call GetSRAMBank
@@ -5497,9 +5497,9 @@
 .asm_11a94f
 	xor a
 	ld [$c31f], a
-	ld a, $c320 % $100
+	ld a, LOW($c320)
 	ld [$c31b], a
-	ld a, $c320 / $100
+	ld a, HIGH($c320)
 	ld [$c31c], a
 	hlcoord 1, 14
 	ld a, l
@@ -7456,29 +7456,29 @@
 	ld a, [wcd31]
 	ld [$c709], a
 
-	ld a, $c708 % $100
+	ld a, LOW($c708) ; Species
 	ld [wMobileMonSpeciesPointerBuffer], a
-	ld a, $c708 / $100
+	ld a, HIGH($c708)
 	ld [wMobileMonSpeciesPointerBuffer + 1], a
 
-	ld a, $c60d % $100 ; Partymon Struct
+	ld a, LOW($c60d) ; Partymon Struct
 	ld [wMobileMonStructurePointerBuffer], a
-	ld a, $c60d / $100
+	ld a, HIGH($c60d)
 	ld [wMobileMonStructurePointerBuffer + 1], a
 
-	ld a, $c63d % $100 ; OT
+	ld a, LOW($c63d) ; OT
 	ld [wMobileMonOTNamePointerBuffer], a
-	ld a, $c63d / $100
+	ld a, HIGH($c63d)
 	ld [wMobileMonOTNamePointerBuffer + 1], a
 
-	ld a, $c642 % $100 ; Nickname
+	ld a, LOW($c642) ; Nickname
 	ld [wMobileMonNicknamePointerBuffer], a
-	ld a, $c642 / $100
+	ld a, HIGH($c642)
 	ld [wMobileMonNicknamePointerBuffer + 1], a
 
-	ld a, $c647 % $100 ; ???
+	ld a, LOW($c647) ; Mail
 	ld [wMobileMonMailPointerBuffer], a
-	ld a, $c647 / $100
+	ld a, HIGH($c647)
 	ld [wMobileMonMailPointerBuffer + 1], a
 
 	ld a, $46
@@ -7762,29 +7762,29 @@
 	call CopyBytes
 	call CloseSRAM
 
-	ld a, $c608 % $100
+	ld a, LOW($c608)
 	ld [wMobileMonSpeciesPointerBuffer], a
-	ld a, $c608 / $100
+	ld a, HIGH($c608)
 	ld [wMobileMonSpeciesPointerBuffer + 1], a
 
-	ld a, $c611 % $100
+	ld a, LOW($c611)
 	ld [wMobileMonStructurePointerBuffer], a
-	ld a, $c611 / $100
+	ld a, HIGH($c611)
 	ld [wMobileMonStructurePointerBuffer + 1], a
 
-	ld a, $c641 % $100
+	ld a, LOW($c641)
 	ld [wMobileMonOTNamePointerBuffer], a
-	ld a, $c641 / $100
+	ld a, HIGH($c641)
 	ld [wMobileMonOTNamePointerBuffer + 1], a
 
-	ld a, $c646 % $100
+	ld a, LOW($c646)
 	ld [wMobileMonNicknamePointerBuffer], a
-	ld a, $c646 / $100
+	ld a, HIGH($c646)
 	ld [wMobileMonNicknamePointerBuffer + 1], a
 
-	ld a, $c64b % $100
+	ld a, LOW($c64b)
 	ld [wMobileMonMailPointerBuffer], a
-	ld a, $c64b / $100
+	ld a, HIGH($c64b)
 	ld [wMobileMonMailPointerBuffer + 1], a
 	call AddMobileMonToParty
 	farcall SaveAfterLinkTrade
--- a/tilesets/animations.asm
+++ b/tilesets/animations.asm
@@ -475,10 +475,10 @@
 	add a
 	add a
 
-	add WaterTileFrames % $100
+	add LOW(WaterTileFrames)
 	ld l, a
 	ld a, 0
-	adc WaterTileFrames / $100
+	adc HIGH(WaterTileFrames)
 	ld h, a
 
 ; Stack now points to the start of the tile for this frame.
@@ -513,10 +513,10 @@
 	add a
 	add a
 	add a
-	add ForestTreeLeftFrames % $100
+	add LOW(ForestTreeLeftFrames)
 	ld l, a
 	ld a, 0
-	adc ForestTreeLeftFrames / $100
+	adc HIGH(ForestTreeLeftFrames)
 	ld h, a
 
 .asm_fc47d
@@ -555,10 +555,10 @@
 	add a
 	add a
 	add a
-	add ForestTreeLeftFrames % $100
+	add LOW(ForestTreeLeftFrames)
 	ld l, a
 	ld a, 0
-	adc ForestTreeLeftFrames / $100
+	adc HIGH(ForestTreeLeftFrames)
 	ld h, a
 	push bc
 	ld bc, ForestTreeRightFrames - ForestTreeLeftFrames
@@ -591,10 +591,10 @@
 	add a
 	add a
 	add a
-	add ForestTreeLeftFrames % $100
+	add LOW(ForestTreeLeftFrames)
 	ld l, a
 	ld a, 0
-	adc ForestTreeLeftFrames / $100
+	adc HIGH(ForestTreeLeftFrames)
 	ld h, a
 
 .asm_fc515
@@ -623,10 +623,10 @@
 	add a
 	add a
 	add a
-	add ForestTreeLeftFrames % $100
+	add LOW(ForestTreeLeftFrames)
 	ld l, a
 	ld a, 0
-	adc ForestTreeLeftFrames / $100
+	adc HIGH(ForestTreeLeftFrames)
 	ld h, a
 	push bc
 	ld bc, ForestTreeRightFrames - ForestTreeLeftFrames