summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2017-12-25 19:01:36 -0500
committerGitHub <noreply@github.com>2017-12-25 19:01:36 -0500
commit73db02d3cdaf81a214ec6faa5462195618a80a48 (patch)
treeb4d1a5187fda9da6186c52c03e836a5ff8f4dd90
parentec8c9688ce970b9c3b63a5b287a99542f0bc9984 (diff)
parent29b41068cb0644956494dd2b7b75331a336b8d26 (diff)
Merge pull request #433 from roukaour/master
More code cleanup
-rw-r--r--audio/engine.asm8
-rw-r--r--battle/ai/scoring.asm78
-rw-r--r--battle/anim_commands.asm12
-rw-r--r--battle/bg_effects.asm18
-rw-r--r--battle/core.asm58
-rw-r--r--battle/effect_commands.asm32
-rwxr-xr-xbattle/objects/engine.asm2
-rw-r--r--constants/battle_constants.asm8
-rw-r--r--constants/misc_constants.asm2
-rw-r--r--data/maps/environment_colors.asm35
-rw-r--r--data/maps/mapgroup_roofs.asm11
-rw-r--r--data/palettes/battle_objects.pal (renamed from data/palettes/979c.pal)11
-rw-r--r--data/palettes/blk_packets.asm40
-rw-r--r--data/palettes/exp_bar.pal3
-rw-r--r--data/palettes/hp_bar.pal9
-rw-r--r--data/palettes/overworld/bg_text.pal4
-rw-r--r--data/palettes/overworld/map_objects.pal (renamed from data/palettes/map_objects.pal)8
-rw-r--r--data/palettes/overworld/roofs.pal (renamed from data/palettes/roofs.pal)0
-rw-r--r--data/palettes/overworld/tileset_bg.pal61
-rw-r--r--data/palettes/pal_packets.asm113
-rw-r--r--data/palettes/predef.pal157
-rw-r--r--data/palettes/tileset_bg.pal227
-rw-r--r--data/palettes/unknown/49757.pal (renamed from data/palettes/49757.pal)0
-rw-r--r--data/palettes/unknown/4985a.asm15
-rw-r--r--data/palettes/unknown/b6f1.pal (renamed from data/palettes/b6f1.pal)0
-rw-r--r--data/palettes/unknown/b719.pal (renamed from data/palettes/b719.pal)0
-rw-r--r--data/palettes/unknown/b789.pal (renamed from data/palettes/b789.pal)0
-rw-r--r--data/sgb_border_map.asm2
-rw-r--r--data/unown_words.asm18
-rw-r--r--docs/assembly_programming.md8
-rw-r--r--docs/bugs_and_glitches.md18
-rw-r--r--docs/move_anim_commands.md21
-rw-r--r--docs/music_commands.md134
-rwxr-xr-xengine/breeding.asm4
-rwxr-xr-xengine/card_flip.asm8
-rw-r--r--engine/cgb_layouts.asm6
-rw-r--r--engine/color.asm197
-rw-r--r--engine/credits.asm16
-rwxr-xr-xengine/crystal_colors.asm34
-rwxr-xr-xengine/crystal_intro.asm8
-rwxr-xr-xengine/debug.asm2
-rw-r--r--engine/events_2.asm2
-rw-r--r--engine/experience.asm2
-rw-r--r--engine/init_hof_credits.asm4
-rw-r--r--engine/init_map.asm16
-rwxr-xr-xengine/intro_menu.asm30
-rw-r--r--engine/item_effects.asm10
-rwxr-xr-xengine/items.asm12
-rwxr-xr-xengine/link.asm16
-rw-r--r--engine/map_objects.asm8
-rwxr-xr-xengine/move_mon.asm14
-rwxr-xr-xengine/mystery_gift.asm16
-rwxr-xr-xengine/namingscreen.asm4
-rw-r--r--engine/odd_eggs.asm20
-rwxr-xr-xengine/overworld.asm4
-rw-r--r--engine/party_menu.asm4
-rwxr-xr-xengine/player_step.asm4
-rwxr-xr-xengine/pokegear.asm20
-rwxr-xr-xengine/printer_serial.asm8
-rwxr-xr-xengine/printnum.asm30
-rw-r--r--engine/routines/loadpushoam.asm2
-rw-r--r--engine/routines/phonering_copytilemapatonce.asm2
-rw-r--r--engine/routines/savemenu_copytilemapatonce.asm2
-rwxr-xr-xengine/slot_machine.asm8
-rw-r--r--engine/specials.asm4
-rwxr-xr-xengine/sprites.asm14
-rw-r--r--engine/start_battle.asm4
-rwxr-xr-xengine/timeset.asm4
-rwxr-xr-xengine/trade_animation.asm18
-rwxr-xr-xengine/warp_connection.asm4
-rwxr-xr-xevent/halloffame.asm8
-rwxr-xr-xevent/happiness_egg.asm10
-rw-r--r--event/magikarp.asm2
-rwxr-xr-xevent/mom_phone.asm6
-rw-r--r--event/poisonstep_pals.asm4
-rwxr-xr-xevent/special.asm4
-rw-r--r--event/unown.asm8
-rw-r--r--home.asm10
-rw-r--r--home/copy.asm8
-rw-r--r--home/game_time.asm4
-rw-r--r--home/init.asm6
-rw-r--r--home/lcd.asm2
-rw-r--r--home/map.asm8
-rw-r--r--home/movement.asm4
-rw-r--r--home/palettes.asm38
-rw-r--r--home/video.asm4
-rw-r--r--lib/mobile/main.asm28
-rw-r--r--macros.asm1
-rw-r--r--macros/data.asm2
-rw-r--r--main.asm7
-rwxr-xr-xmobile/battle_tower_5c.asm12
-rwxr-xr-xmobile/fixed_words.asm16
-rwxr-xr-xmobile/mobile_12.asm4
-rw-r--r--mobile/mobile_40.asm8
-rw-r--r--mobile/mobile_42.asm8
-rw-r--r--mobile/mobile_45.asm5
-rwxr-xr-xmobile/mobile_46.asm72
-rw-r--r--tilesets/animations.asm21
-rw-r--r--tilesets/data.asm5
-rw-r--r--tilesets/palettes/battle_tower.pal (renamed from tilesets/battle_tower.pal)0
-rw-r--r--tilesets/palettes/house_1.pal (renamed from tilesets/house_1.pal)0
-rw-r--r--tilesets/palettes/ice_path.pal (renamed from tilesets/ice_path.pal)0
-rw-r--r--tilesets/palettes/pokecom_center.pal (renamed from tilesets/pokecom_center.pal)0
-rw-r--r--tilesets/palettes/radio_tower.pal (renamed from tilesets/radio_tower.pal)0
-rw-r--r--tilesets/roofs.asm9
-rw-r--r--tilesets/special_palettes.asm10
106 files changed, 998 insertions, 1010 deletions
diff --git a/audio/engine.asm b/audio/engine.asm
index cd68bc96d..96295b415 100644
--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -539,7 +539,7 @@ PlayDanger: ; e8307
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 @@ SetNoteDuration: ; e8a8d
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 @@ SetNoteDuration: ; e8a8d
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
diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm
index 6391e3b29..44194d6f7 100644
--- a/battle/ai/scoring.asm
+++ b/battle/ai/scoring.asm
@@ -141,7 +141,7 @@ AI_Setup: ; 385e0
.discourage
call Random
- cp 30
+ cp 12 percent
jr c, .checkmove
inc [hl]
inc [hl]
@@ -453,7 +453,7 @@ AI_Smart_LeechHit: ; 387f7
.asm_38815
call Random
- cp 100
+ cp 39 percent + 1
ret c
inc [hl]
@@ -594,7 +594,7 @@ AI_Smart_Selfdestruct: ; 388a6
; If enemy's HP is between 25% and 50%,
; over 90% chance to greatly discourage this move.
call Random
- cp 20
+ cp 9 percent - 2
ret c
.asm_388c6
@@ -610,7 +610,7 @@ AI_Smart_DreamEater: ; 388ca
; The AI_Basic layer will make sure that
; Dream Eater is only used against sleeping targets.
call Random
- cp 25
+ cp 10 percent
ret c
dec [hl]
dec [hl]
@@ -637,7 +637,7 @@ AI_Smart_EvasionUp: ; 388d4
; ...70% chance to greatly encourage this move if player is not badly poisoned.
call Random
- cp $b2
+ cp 70 percent
jr nc, .asm_38911
.asm_388ef
@@ -653,7 +653,7 @@ AI_Smart_EvasionUp: ; 388d4
; If enemy's HP is above 25% but not full, 4% chance to greatly encourage this move.
call Random
- cp $a
+ cp 4 percent
jr c, .asm_388ef
; If enemy's HP is between 25% and 50%,...
@@ -710,11 +710,11 @@ AI_Smart_EvasionUp: ; 388d4
ret
; Player is badly poisoned.
-; 80% chance to greatly encourage this move.
+; 70% chance to greatly encourage this move.
; This would counter any previous discouragement.
.asm_38938
call Random
- cp $50
+ cp 31 percent + 1
ret c
dec [hl]
dec [hl]
@@ -791,7 +791,7 @@ AI_Smart_MirrorMove: ; 3895b
ret nc
call Random
- cp $19
+ cp 10 percent
ret c
dec [hl]
@@ -816,7 +816,7 @@ AI_Smart_AccuracyDown: ; 38985
; ...70% chance to greatly encourage this move if player is not badly poisoned.
call Random
- cp $b2
+ cp 70 percent
jr nc, .asm_389bf
.asm_3899d
@@ -832,7 +832,7 @@ AI_Smart_AccuracyDown: ; 38985
; If player's HP is above 25% but not full, 4% chance to greatly encourage this move.
call Random
- cp $a
+ cp 4 percent
jr c, .asm_3899d
; If player's HP is between 25% and 50%,...
@@ -884,11 +884,11 @@ AI_Smart_AccuracyDown: ; 38985
ret
; Player is badly poisoned.
-; 80% chance to greatly encourage this move.
+; 70% chance to greatly encourage this move.
; This would counter any previous discouragement.
.asm_389e6
call Random
- cp $50
+ cp 31 percent + 1
ret c
dec [hl]
dec [hl]
@@ -934,7 +934,7 @@ AI_Smart_ResetStats: ; 389f5
.asm_38a12
pop hl
call Random
- cp $28
+ cp 16 percent
ret c
dec [hl]
ret
@@ -955,7 +955,7 @@ AI_Smart_Bide: ; 38a1e
call AICheckEnemyMaxHP
ret c
call Random
- cp $19
+ cp 10 percent
ret c
inc [hl]
ret
@@ -997,7 +997,7 @@ AI_Smart_Moonlight: ; 38a3a
.asm_38a45
call Random
- cp $19
+ cp 10 percent
ret c
dec [hl]
dec [hl]
@@ -1023,7 +1023,7 @@ AI_Smart_Reflect: ; 38a54
call AICheckEnemyMaxHP
ret c
call Random
- cp $14
+ cp 8 percent
ret c
inc [hl]
ret
@@ -1126,7 +1126,7 @@ AI_Smart_Unused2B: ; 38a9c
.asm_38acd
call Random
- cp $c8
+ cp 79 percent - 1
ret c
.asm_38ad3
@@ -1148,7 +1148,7 @@ AI_Smart_Confuse: ; 38adb
call AICheckPlayerHalfHP
ret c
call Random
- cp $19
+ cp 10 percent
jr c, .asm_38ae7
inc [hl]
@@ -1272,7 +1272,7 @@ AI_Smart_SpeedDownHit: ; 38b40
call AICompareSpeed
ret c
call Random
- cp 30
+ cp 12 percent
ret c
dec [hl]
dec [hl]
@@ -1304,7 +1304,7 @@ AI_Smart_HyperBeam: ; 38b63
.asm_38b72
; If enemy's HP is above 50%, discourage this move at random
call Random
- cp 40
+ cp 16 percent
ret c
inc [hl]
call AI_50_50
@@ -1457,7 +1457,7 @@ AI_Smart_Counter: ; 38bf1
.asm_38c30
call Random
- cp $64
+ cp 39 percent + 1
jr c, .asm_38c38
dec [hl]
@@ -1510,7 +1510,7 @@ AI_Smart_Encore: ; 38c3b
.asm_38c78
call Random
- cp $46
+ cp 28 percent - 1
ret c
dec [hl]
dec [hl]
@@ -1657,7 +1657,7 @@ AI_Smart_Spite: ; 38cd5
jr nc, .asm_38d0b
call Random
- cp $64
+ cp 39 percent + 1
ret nc
.asm_38d0b
@@ -1666,7 +1666,7 @@ AI_Smart_Spite: ; 38cd5
.asm_38d0d
call Random
- cp $64
+ cp 39 percent + 1
ret c
dec [hl]
dec [hl]
@@ -1827,7 +1827,7 @@ AI_Smart_Conversion2: ; 38d98
.asm_38dc9
call Random
- cp 25
+ cp 10 percent
ret c
inc [hl]
ret
@@ -1848,7 +1848,7 @@ AI_Smart_Disable: ; 38dd1
jr nc, .asm_38dee
call Random
- cp 100
+ cp 39 percent + 1
ret c
dec [hl]
ret
@@ -1860,7 +1860,7 @@ AI_Smart_Disable: ; 38dd1
.asm_38df3
call Random
- cp 20
+ cp 8 percent
ret c
inc [hl]
ret
@@ -2096,7 +2096,7 @@ AI_Smart_Protect: ; 38ed2
.asm_38f14
call Random
- cp 20
+ cp 8 percent
ret c
inc [hl]
inc [hl]
@@ -2120,14 +2120,14 @@ AI_Smart_Foresight: ; 38f1d
jr z, .asm_38f41
call Random
- cp 20
+ cp 8 percent
ret c
inc [hl]
ret
.asm_38f41
call Random
- cp 100
+ cp 39 percent + 1
ret c
dec [hl]
dec [hl]
@@ -2317,7 +2317,7 @@ AI_Smart_Rollout: ; 38fef
; Otherwise, 80% chance to greatly encourage this move.
call Random
- cp 200
+ cp 79 percent - 1
ret nc
dec [hl]
dec [hl]
@@ -2347,7 +2347,7 @@ AI_Smart_Attract: ; 39026
.first_turn
call Random
- cp 200
+ cp 79 percent - 1
ret nc
dec [hl]
ret
@@ -2850,7 +2850,7 @@ AI_Smart_Solarbeam: ; 3920b
ret nz
call Random
- cp 25 ; 1/10
+ cp 10 percent
ret c
inc [hl]
@@ -2875,7 +2875,7 @@ AI_Smart_Thunder: ; 39225
ret nz
call Random
- cp 25 ; 1/10
+ cp 10 percent
ret c
inc [hl]
@@ -3387,7 +3387,7 @@ AI_Cautious: ; 39418
jr nc, .asm_39425
call Random
- cp 230
+ cp 90 percent + 1
ret nc
inc [hl]
@@ -3513,7 +3513,7 @@ AI_Risky: ; 394a9
; Else, 80% chance to exclude them.
call Random
- cp 200 ; 1/5
+ cp 79 percent - 1
jr c, .nextmove
.checkko
@@ -3586,13 +3586,13 @@ AIGetEnemyMove: ; 39508
AI_80_20: ; 39521
call Random
- cp 50 ; 1/5
+ cp 20 percent - 1
ret
; 39527
AI_50_50: ; 39527
call Random
- cp $80 ; 1/2
+ cp 50 percent + 1
ret
; 3952d
diff --git a/battle/anim_commands.asm b/battle/anim_commands.asm
index 510f44d2b..78786f516 100644
--- a/battle/anim_commands.asm
+++ b/battle/anim_commands.asm
@@ -237,16 +237,16 @@ Functioncc220: ; cc220
; 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 @@ BattleAnim_UpdateOAM_All: ; cc96e
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
diff --git a/battle/bg_effects.asm b/battle/bg_effects.asm
index cfd342df7..7799c2cf7 100644
--- a/battle/bg_effects.asm
+++ b/battle/bg_effects.asm
@@ -1223,7 +1223,7 @@ BattleBGEffect_DoubleTeam: ; c8689 (32:4689)
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 @@ BattleBGEffect_AcidArmor: ; c8709 (32:4709)
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 @@ BattleBGEffect_AcidArmor: ; c8709 (32:4709)
.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 @@ Functionc88a5: ; c88a5 (32:48a5)
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 @@ BattleBGEffect_2a: ; c8a3a (32:4a3a)
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 @@ BattleBGEffect_2a: ; c8a3a (32:4a3a)
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 @@ BattleBGEffect_WavyScreenFX: ; c8fef (32:4fef)
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 @@ BattleBGEffect_WavyScreenFX: ; c8fef (32:4fef)
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 @@ BGEffect_DisplaceLYOverridesBackup: ; c901b (32:501b)
sub l
sub e
ld d, a
- ld h, LYOverridesBackup / $100
+ ld h, HIGH(LYOverridesBackup)
ld a, [hLYOverrideStart]
ld l, a
ld a, $90
diff --git a/battle/core.asm b/battle/core.asm
index 9cae539c3..3a6d7ac9e 100644
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -2573,11 +2573,11 @@ WinTrainerBattle: ; 3cfa4
.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 @@ AddBattleMoneyToAccount: ; 3d0be
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 @@ LoadEnemyMon: ; 3e8eb
; 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 @@ LoadEnemyMon: ; 3e8eb
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 @@ LoadEnemyMon: ; 3e8eb
.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 @@ ApplyStatLevelMultiplier: ; 3ecb7
; 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 @@ BoostStat: ; 3ed7c
; 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 @@ _BattleRandom:: ; 3edd8
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 @@ AddLastMobileBattleToLinkRecord: ; 3fa42
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
diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm
index 86b8cc080..f2c6b5d77 100644
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -3576,14 +3576,14 @@ BattleCommand_DamageCalc: ; 35612
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 @@ BattleCommand_DamageCalc: ; 35612
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 @@ BattleCommand_DamageCalc: ; 35612
; 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 @@ CheckIfStatCanBeRaised: ; 361ef
.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 @@ CalcStats: ; 3661d
.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 @@ BattleCommand_Heal: ; 3713e
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
diff --git a/battle/objects/engine.asm b/battle/objects/engine.asm
index 6a4f86902..ae3bdde28 100755
--- a/battle/objects/engine.asm
+++ b/battle/objects/engine.asm
@@ -106,7 +106,7 @@ BattleAnimOAMUpdate: ; cca09
ld l, a
ld a, [wBattleAnimOAMPointerLo]
ld e, a
- ld d, Sprites / $100
+ ld d, HIGH(Sprites)
.loop
ld a, [wBattleAnimTempYCoord]
ld b, a
diff --git a/constants/battle_constants.asm b/constants/battle_constants.asm
index f86cd0873..e9d393fcc 100644
--- a/constants/battle_constants.asm
+++ b/constants/battle_constants.asm
@@ -10,8 +10,12 @@ NUM_MOVES EQU 4
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
diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm
index 64c625933..88ae90c89 100644
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -120,3 +120,5 @@ const_value = 1
const HAPPINESS_REVIVALHERB ; 11
const HAPPINESS_MASSAGE ; 12
const HAPPINESS_GAINLEVELATHOME ; 13
+
+MAX_DAY_CARE_EXP EQU $500000
diff --git a/data/maps/environment_colors.asm b/data/maps/environment_colors.asm
new file mode 100644
index 000000000..92d788fe1
--- /dev/null
+++ b/data/maps/environment_colors.asm
@@ -0,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
diff --git a/data/maps/mapgroup_roofs.asm b/data/maps/mapgroup_roofs.asm
index 0cad8a0e3..8c79e6f82 100644
--- a/data/maps/mapgroup_roofs.asm
+++ b/data/maps/mapgroup_roofs.asm
@@ -1,6 +1,5 @@
-; valid roofs: 0, 1, 2, 3, 4, or -1 for none
-
MapGroupRoofs: ; 1c021i
+; entries correspond to Roofs (see below)
db -1 ; group 0 (unused)
db 3 ; group 1 (Olivine)
db 2 ; group 2 (Mahogany)
@@ -29,3 +28,11 @@ MapGroupRoofs: ; 1c021i
db -1 ; group 25
db 0 ; group 26 (Cherrygrove)
; 1c03c
+
+Roofs: ; 1c03c
+INCBIN "gfx/tilesets/roofs/0.2bpp"
+INCBIN "gfx/tilesets/roofs/1.2bpp"
+INCBIN "gfx/tilesets/roofs/2.2bpp"
+INCBIN "gfx/tilesets/roofs/3.2bpp"
+INCBIN "gfx/tilesets/roofs/4.2bpp"
+; 1c30c
diff --git a/data/palettes/979c.pal b/data/palettes/battle_objects.pal
index 3940a030a..d2ebb6cef 100644
--- a/data/palettes/979c.pal
+++ b/data/palettes/battle_objects.pal
@@ -1,28 +1,29 @@
+; gray
RGB 31, 31, 31
RGB 25, 25, 25
RGB 13, 13, 13
RGB 00, 00, 00
-
+; yellow
RGB 31, 31, 31
RGB 31, 31, 07
RGB 31, 16, 01
RGB 00, 00, 00
-
+; red
RGB 31, 31, 31
RGB 31, 19, 24
RGB 30, 10, 06
RGB 00, 00, 00
-
+; green
RGB 31, 31, 31
RGB 12, 25, 01
RGB 05, 14, 00
RGB 00, 00, 00
-
+; blue
RGB 31, 31, 31
RGB 08, 12, 31
RGB 01, 04, 31
RGB 00, 00, 00
-
+; brown
RGB 31, 31, 31
RGB 24, 18, 07
RGB 20, 15, 03
diff --git a/data/palettes/blk_packets.asm b/data/palettes/blk_packets.asm
new file mode 100644
index 000000000..38f68ad1d
--- /dev/null
+++ b/data/palettes/blk_packets.asm
@@ -0,0 +1,40 @@
+BlkPacket_9a86:
+ db $21, $01, $03, $00, $00, $00, $13, $11, $00, $00, $00, $00, $00, $00, $00, $00
+
+BlkPacket_9a96:
+ db $21, $01, $07, $05, $00, $0a, $13, $0d, $00, $00, $00, $00, $00, $00, $00, $00
+
+BlkPacket_9aa6:
+ db $22, $05, $07, $0a, $00, $0c, $13, $11, $03, $05, $01, $00, $0a, $03, $03, $00
+ db $0a, $08, $13, $0a, $03, $0a, $00, $04, $08, $0b, $03, $0f, $0b, $00, $13, $07
+
+BlkPacket_9ac6:
+ db $21, $01, $07, $05, $00, $01, $07, $07, $00, $00, $00, $00, $00, $00, $00, $00
+
+BlkPacket_9ad6:
+ db $21, $01, $07, $05, $0b, $01, $13, $02, $00, $00, $00, $00, $00, $00, $00, $00
+
+BlkPacket_9ae6:
+ db $21, $01, $07, $05, $01, $01, $08, $08, $00, $00, $00, $00, $00, $00, $00, $00
+
+BlkPacket_9af6:
+ db $21, $01, $07, $05, $07, $05, $0d, $0b, $00, $00, $00, $00, $00, $00, $00, $00
+
+BlkPacket_9b06:
+ db $22, $05, $03, $05, $00, $00, $13, $0b, $03, $0a, $00, $04, $13, $09, $02, $0f
+ db $00, $06, $13, $07, $03, $00, $04, $04, $0f, $09, $03, $00, $00, $0c, $13, $11
+
+BlkPacket_9b26:
+ db $23, $07, $07, $10, $00, $00, $02, $0c, $02, $00, $0c, $00, $12, $01, $02, $00
+ db $0c, $02, $12, $03, $02, $00, $0c, $04, $12, $05, $02, $00, $0c, $06, $12, $07
+ db $02, $00, $0c, $08, $12, $09, $02, $00, $0c, $0a, $12, $0b, $00, $00, $00, $00
+
+BlkPacket_9b56:
+ db $22, $03, $07, $20, $00, $00, $13, $04, $03, $0f, $00, $06, $13, $11, $03, $05
+ db $0f, $01, $12, $04, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+BlkPacket_9b76:
+ db $21, $01, $07, $10, $00, $00, $13, $05, $00, $00, $00, $00, $00, $00, $00, $00
+
+BlkPacket_9b86:
+ db $21, $02, $07, $0a, $00, $04, $13, $0d, $03, $05, $00, $06, $13, $0b, $00, $00
diff --git a/data/palettes/exp_bar.pal b/data/palettes/exp_bar.pal
new file mode 100644
index 000000000..831bbda95
--- /dev/null
+++ b/data/palettes/exp_bar.pal
@@ -0,0 +1,3 @@
+; blue
+ RGB 30, 26, 15
+ RGB 04, 17, 31
diff --git a/data/palettes/hp_bar.pal b/data/palettes/hp_bar.pal
new file mode 100644
index 000000000..909be8efd
--- /dev/null
+++ b/data/palettes/hp_bar.pal
@@ -0,0 +1,9 @@
+; green
+ RGB 30, 26, 15
+ RGB 00, 23, 00
+; yellow
+ RGB 30, 26, 15
+ RGB 31, 21, 00
+; red
+ RGB 30, 26, 15
+ RGB 31, 00, 00
diff --git a/data/palettes/overworld/bg_text.pal b/data/palettes/overworld/bg_text.pal
new file mode 100644
index 000000000..39a4a194c
--- /dev/null
+++ b/data/palettes/overworld/bg_text.pal
@@ -0,0 +1,4 @@
+ RGB 31, 31, 31
+ RGB 08, 19, 28
+ RGB 05, 05, 16
+ RGB 00, 00, 00
diff --git a/data/palettes/map_objects.pal b/data/palettes/overworld/map_objects.pal
index a6e20d7f0..b0f33479a 100644
--- a/data/palettes/map_objects.pal
+++ b/data/palettes/overworld/map_objects.pal
@@ -1,4 +1,4 @@
- ; morn
+; morn
RGB 28,31,16, 31,19,10, 31,07,01, 00,00,00 ; red
RGB 28,31,16, 31,19,10, 10,09,31, 00,00,00 ; blue
RGB 28,31,16, 31,19,10, 07,23,03, 00,00,00 ; green
@@ -8,7 +8,7 @@
RGB 22,31,10, 12,25,01, 05,14,00, 07,07,07 ; tree
RGB 28,31,16, 24,18,07, 20,15,03, 07,07,07 ; rock
- ; day
+; day
RGB 27,31,27, 31,19,10, 31,07,01, 00,00,00 ; red
RGB 27,31,27, 31,19,10, 10,09,31, 00,00,00 ; blue
RGB 27,31,27, 31,19,10, 07,23,03, 00,00,00 ; green
@@ -18,7 +18,7 @@
RGB 22,31,10, 12,25,01, 05,14,00, 07,07,07 ; tree
RGB 27,31,27, 24,18,07, 20,15,03, 07,07,07 ; rock
- ; nite
+; nite
RGB 15,14,24, 31,19,10, 31,07,01, 00,00,00 ; red
RGB 15,14,24, 31,19,10, 10,09,31, 00,00,00 ; blue
RGB 15,14,24, 31,19,10, 07,23,03, 00,00,00 ; green
@@ -28,7 +28,7 @@
RGB 15,14,24, 08,13,19, 00,11,13, 00,00,00 ; tree
RGB 15,14,24, 12,09,15, 08,04,05, 00,00,00 ; rock
- ; dark
+; dark
RGB 01,01,02, 31,19,10, 31,07,01, 00,00,00 ; red
RGB 01,01,02, 31,19,10, 10,09,31, 00,00,00 ; blue
RGB 01,01,02, 31,19,10, 07,23,03, 00,00,00 ; green
diff --git a/data/palettes/roofs.pal b/data/palettes/overworld/roofs.pal
index ba65fc7d2..ba65fc7d2 100644
--- a/data/palettes/roofs.pal
+++ b/data/palettes/overworld/roofs.pal
diff --git a/data/palettes/overworld/tileset_bg.pal b/data/palettes/overworld/tileset_bg.pal
new file mode 100644
index 000000000..e56746536
--- /dev/null
+++ b/data/palettes/overworld/tileset_bg.pal
@@ -0,0 +1,61 @@
+; morn
+ RGB 28,31,16, 21,21,21, 13,13,13, 07,07,07 ; gray
+ RGB 28,31,16, 31,19,24, 30,10,06, 07,07,07 ; red
+ RGB 22,31,10, 12,25,01, 05,14,00, 07,07,07 ; green
+ RGB 31,31,31, 08,12,31, 01,04,31, 07,07,07 ; water
+ RGB 28,31,16, 31,31,07, 31,16,01, 07,07,07 ; yellow
+ RGB 28,31,16, 24,18,07, 20,15,03, 07,07,07 ; brown
+ RGB 28,31,16, 15,31,31, 05,17,31, 07,07,07 ; roof
+ RGB 31,31,16, 31,31,16, 14,09,00, 00,00,00 ; text
+
+; day
+ RGB 27,31,27, 21,21,21, 13,13,13, 07,07,07 ; gray
+ RGB 27,31,27, 31,19,24, 30,10,06, 07,07,07 ; red
+ RGB 22,31,10, 12,25,01, 05,14,00, 07,07,07 ; green
+ RGB 31,31,31, 08,12,31, 01,04,31, 07,07,07 ; water
+ RGB 27,31,27, 31,31,07, 31,16,01, 07,07,07 ; yellow
+ RGB 27,31,27, 24,18,07, 20,15,03, 07,07,07 ; brown
+ RGB 27,31,27, 15,31,31, 05,17,31, 07,07,07 ; roof
+ RGB 31,31,16, 31,31,16, 14,09,00, 00,00,00 ; text
+
+; nite
+ RGB 15,14,24, 11,11,19, 07,07,12, 00,00,00 ; gray
+ RGB 15,14,24, 14,07,17, 13,00,08, 00,00,00 ; red
+ RGB 15,14,24, 08,13,19, 00,11,13, 00,00,00 ; green
+ RGB 15,14,24, 05,05,17, 03,03,10, 00,00,00 ; water
+ RGB 30,30,11, 16,14,18, 16,14,10, 00,00,00 ; yellow
+ RGB 15,14,24, 12,09,15, 08,04,05, 00,00,00 ; brown
+ RGB 15,14,24, 13,12,23, 11,09,20, 00,00,00 ; roof
+ RGB 31,31,16, 31,31,16, 14,09,00, 00,00,00 ; text
+
+; dark
+ RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; gray
+ RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; red
+ RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; green
+ RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; water
+ RGB 30,30,11, 00,00,00, 00,00,00, 00,00,00 ; yellow
+ RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; brown
+ RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; roof
+ RGB 31,31,16, 31,31,16, 14,09,00, 00,00,00 ; text
+
+; indoor
+ RGB 30,28,26, 19,19,19, 13,13,13, 07,07,07 ; gray
+ RGB 30,28,26, 31,19,24, 30,10,06, 07,07,07 ; red
+ RGB 18,24,09, 15,20,01, 09,13,00, 07,07,07 ; green
+ RGB 30,28,26, 15,16,31, 09,09,31, 07,07,07 ; water
+ RGB 30,28,26, 31,31,07, 31,16,01, 07,07,07 ; yellow
+ RGB 26,24,17, 21,17,07, 16,13,03, 07,07,07 ; brown
+ RGB 30,28,26, 17,19,31, 14,16,31, 07,07,07 ; roof
+ RGB 31,31,16, 31,31,16, 14,09,00, 00,00,00 ; text
+
+; overworld water
+; morn/day
+ RGB 23, 23, 31
+ RGB 18, 19, 31
+ RGB 13, 12, 31
+ RGB 07, 07, 07
+; nite
+ RGB 15, 13, 27
+ RGB 10, 09, 20
+ RGB 04, 03, 18
+ RGB 00, 00, 00 \ No newline at end of file
diff --git a/data/palettes/pal_packets.asm b/data/palettes/pal_packets.asm
new file mode 100644
index 000000000..57cd9e492
--- /dev/null
+++ b/data/palettes/pal_packets.asm
@@ -0,0 +1,113 @@
+PalPacket_9b96:
+ db $51, $48, $00, $49, $00, $4a, $00, $4b, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9ba6:
+ db $51, $2b, $00, $24, $00, $20, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9bb6:
+ db $51, $41, $00, $42, $00, $43, $00, $44, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9bc6:
+ db $51, $4c, $00, $4c, $00, $4c, $00, $4c, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9bd6:
+ db $51, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9be6:
+ db $51, $36, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9bf6:
+ db $51, $37, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9c06:
+ db $51, $38, $00, $39, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9c16:
+ db $51, $3a, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9c26:
+ db $51, $3b, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9c36:
+ db $51, $3c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9c46:
+ db $51, $39, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9c56:
+ db $51, $2e, $00, $2f, $00, $30, $00, $31, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9c66:
+ db $51, $1a, $00, $1a, $00, $1a, $00, $1a, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9c76:
+ db $51, $32, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9c86:
+ db $51, $3c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9c96:
+ db $51, $3d, $00, $3e, $00, $3f, $00, $40, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9ca6:
+ db $51, $33, $00, $34, $00, $1b, $00, $1f, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9cb6:
+ db $51, $1b, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9cc6:
+ db $51, $1c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9cd6:
+ db $51, $35, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9ce6:
+ db $01, $ff, $7f, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9cf6:
+ db $09, $ff, $7f, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9d06:
+ db $59, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9d16:
+ db $89, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9d26:
+ db $89, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9d36:
+ db $99, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9d46:
+ db $a1, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9d56:
+ db $b9, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9d66:
+ db $b9, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9d76:
+ db $79, $5d, $08, $00, $0b, $8c, $d0, $f4, $60, $00, $00, $00, $00, $00, $00, $00
+
+PalPacket_9d86:
+ db $79, $52, $08, $00, $0b, $a9, $e7, $9f, $01, $c0, $7e, $e8, $e8, $e8, $e8, $e0
+
+PalPacket_9d96:
+ db $79, $47, $08, $00, $0b, $c4, $d0, $16, $a5, $cb, $c9, $05, $d0, $10, $a2, $28
+
+PalPacket_9da6:
+ db $79, $3c, $08, $00, $0b, $f0, $12, $a5, $c9, $c9, $c8, $d0, $1c, $a5, $ca, $c9
+
+PalPacket_9db6:
+ db $79, $31, $08, $00, $0b, $0c, $a5, $ca, $c9, $7e, $d0, $06, $a5, $cb, $c9, $7e
+
+PalPacket_9dc6:
+ db $79, $26, $08, $00, $0b, $39, $cd, $48, $0c, $d0, $34, $a5, $c9, $c9, $80, $d0
+
+PalPacket_9dd6:
+ db $79, $1b, $08, $00, $0b, $ea, $ea, $ea, $ea, $ea, $a9, $01, $cd, $4f, $0c, $d0
+
+PalPacket_9de6:
+ db $79, $10, $08, $00, $0b, $4c, $20, $08, $ea, $ea, $ea, $ea, $ea, $60, $ea, $ea
diff --git a/data/palettes/predef.pal b/data/palettes/predef.pal
index 6975f17a2..15d9000fb 100644
--- a/data/palettes/predef.pal
+++ b/data/palettes/predef.pal
@@ -1,393 +1,394 @@
+; $00
RGB 31, 31, 31
RGB 22, 25, 19
RGB 16, 21, 30
RGB 00, 00, 00
-
+; $01
RGB 31, 31, 31
RGB 27, 28, 31
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $02
RGB 31, 31, 31
RGB 24, 28, 19
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $03
RGB 31, 31, 31
RGB 24, 24, 24
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $04
RGB 31, 31, 31
RGB 21, 23, 31
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $05
RGB 31, 31, 31
RGB 24, 21, 27
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $06
RGB 31, 31, 31
RGB 31, 24, 16
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $07
RGB 31, 31, 31
RGB 25, 30, 26
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $08
RGB 31, 31, 31
RGB 31, 25, 31
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $09
RGB 31, 31, 31
RGB 31, 20, 19
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $0a
RGB 31, 31, 31
RGB 31, 26, 19
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $0b
RGB 31, 31, 31
RGB 27, 28, 27
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $0c
RGB 31, 31, 31
RGB 24, 30, 23
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $0d
RGB 31, 31, 31
RGB 29, 24, 29
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $0e
RGB 31, 31, 31
RGB 26, 23, 29
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $0f
RGB 31, 31, 31
RGB 25, 23, 20
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $10
RGB 31, 31, 31
RGB 29, 26, 18
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $11
RGB 31, 31, 31
RGB 31, 21, 18
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $12
RGB 31, 31, 31
RGB 26, 25, 31
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $13
RGB 31, 31, 31
RGB 22, 21, 31
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $14
RGB 31, 31, 31
RGB 22, 25, 21
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $15
RGB 31, 31, 31
RGB 21, 21, 22
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $16
RGB 31, 31, 31
RGB 31, 20, 20
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $17
RGB 31, 31, 31
RGB 26, 26, 26
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $18
RGB 31, 31, 31
RGB 21, 14, 09
RGB 15, 20, 20
RGB 00, 00, 00
-
+; $19
RGB 31, 31, 31
RGB 12, 28, 22
RGB 15, 20, 20
RGB 00, 00, 00
-
+; $1a
RGB 31, 31, 31
RGB 07, 07, 07
RGB 02, 03, 03
RGB 00, 00, 00
-
+; $1b
RGB 31, 31, 31
RGB 30, 22, 17
RGB 16, 14, 19
RGB 00, 00, 00
-
+; $1c
RGB 31, 31, 31
RGB 18, 20, 27
RGB 11, 15, 23
RGB 00, 00, 00
-
+; $1d
RGB 31, 31, 31
RGB 31, 20, 10
RGB 26, 10, 06
RGB 00, 00, 00
-
+; $1e
RGB 31, 31, 31
RGB 21, 25, 29
RGB 14, 19, 25
RGB 00, 00, 00
-
+; $1f
RGB 31, 31, 31
RGB 27, 22, 24
RGB 21, 15, 23
RGB 00, 00, 00
-
+; $20
RGB 31, 31, 31
RGB 28, 20, 15
RGB 21, 14, 09
RGB 00, 00, 00
-
+; $21
RGB 31, 31, 31
RGB 20, 26, 16
RGB 09, 20, 11
RGB 00, 00, 00
-
+; $22
RGB 31, 31, 31
RGB 30, 22, 24
RGB 28, 15, 21
RGB 00, 00, 00
-
+; $23
RGB 31, 31, 31
RGB 31, 28, 14
RGB 26, 20, 00
RGB 00, 00, 00
-
+; $24
RGB 31, 31, 31
RGB 26, 21, 22
RGB 15, 15, 18
RGB 00, 00, 00
-
+; $25
RGB 31, 31, 31
RGB 23, 19, 13
RGB 14, 12, 17
RGB 00, 00, 00
-
+; $26
RGB 31, 31, 31
RGB 16, 18, 21
RGB 10, 12, 18
RGB 00, 00, 00
-
+; $27
RGB 31, 31, 31
RGB 22, 15, 16
RGB 17, 02, 05
RGB 00, 00, 00
-
+; $28
RGB 31, 31, 31
RGB 15, 20, 20
RGB 05, 16, 16
RGB 00, 00, 00
-
+; $29
RGB 31, 31, 31
RGB 23, 15, 19
RGB 14, 04, 12
RGB 00, 00, 00
-
+; $2a
RGB 31, 31, 31
RGB 20, 17, 18
RGB 18, 13, 11
RGB 00, 00, 00
-
+; $2b
RGB 31, 31, 31
RGB 23, 21, 16
RGB 12, 12, 10
RGB 00, 00, 00
-
+; $2c
RGB 31, 31, 31
RGB 21, 25, 29
RGB 30, 22, 24
RGB 00, 00, 00
-
+; $2d
RGB 31, 31, 31
RGB 26, 23, 16
RGB 29, 14, 09
RGB 00, 00, 00
-
+; $2e
RGB 31, 31, 31
RGB 18, 18, 18
RGB 10, 10, 10
RGB 00, 00, 00
-
+; $2f
RGB 31, 31, 31
RGB 30, 26, 15
RGB 00, 23, 00
RGB 00, 00, 00
-
+; $30
RGB 31, 31, 31
RGB 30, 26, 15
RGB 31, 23, 00
RGB 00, 00, 00
-
+; $31
RGB 31, 31, 31
RGB 30, 26, 15
RGB 31, 00, 00
RGB 00, 00, 00
-
+; $32
RGB 31, 31, 31
RGB 29, 26, 19
RGB 27, 20, 14
RGB 00, 00, 00
-
+; $33
RGB 31, 31, 31
RGB 24, 20, 10
RGB 21, 00, 04
RGB 00, 00, 00
-
+; $34
RGB 31, 31, 31
RGB 31, 20, 10
RGB 21, 00, 04
RGB 00, 00, 00
-
+; $35
RGB 31, 31, 31
RGB 30, 26, 16
RGB 16, 12, 09
RGB 00, 00, 00
-
+; $36
RGB 31, 31, 31
RGB 15, 28, 26
RGB 12, 22, 26
RGB 03, 16, 14
-
+; $37
RGB 31, 31, 31
RGB 15, 28, 26
RGB 23, 24, 24
RGB 00, 00, 00
-
+; $38
RGB 31, 31, 24
RGB 07, 27, 19
RGB 26, 20, 10
RGB 19, 12, 08
-
+; $39
RGB 31, 31, 31
RGB 31, 28, 14
RGB 31, 13, 31
RGB 00, 00, 00
-
+; $3a
RGB 31, 31, 31
RGB 16, 18, 21
RGB 10, 12, 18
RGB 00, 00, 00
-
+; $3b
RGB 31, 31, 31
RGB 23, 21, 16
RGB 12, 12, 10
RGB 00, 00, 00
-
+; $3c
RGB 31, 31, 31
RGB 31, 14, 00
RGB 07, 11, 15
RGB 00, 00, 00
-
+; $3d
RGB 31, 31, 31
RGB 26, 21, 22
RGB 26, 10, 06
RGB 00, 00, 00
-
+; $3e
RGB 31, 31, 31
RGB 30, 27, 04
RGB 24, 20, 11
RGB 00, 00, 00
-
+; $3f
RGB 31, 31, 31
RGB 31, 13, 25
RGB 24, 20, 11
RGB 00, 00, 00
-
+; $40
RGB 31, 31, 31
RGB 16, 19, 29
RGB 24, 20, 11
RGB 00, 00, 00
-
+; $41
RGB 31, 31, 31
RGB 30, 22, 24
RGB 18, 18, 18
RGB 16, 10, 07
-
+; $42
RGB 31, 31, 31
RGB 21, 25, 29
RGB 18, 18, 18
RGB 16, 10, 07
-
+; $43
RGB 31, 31, 31
RGB 20, 26, 16
RGB 18, 18, 18
RGB 16, 10, 07
-
+; $44
RGB 31, 31, 31
RGB 31, 28, 14
RGB 18, 18, 18
RGB 16, 10, 07
-
+; $45
RGB 31, 31, 31
RGB 18, 18, 18
RGB 26, 10, 06
RGB 00, 00, 00
-
+; $46
RGB 31, 31, 31
RGB 30, 22, 24
RGB 28, 15, 21
RGB 00, 00, 00
-
+; $47
RGB 31, 31, 31
RGB 26, 20, 00
RGB 16, 19, 29
RGB 00, 00, 00
-
+; $48
RGB 31, 31, 31
RGB 16, 02, 30
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $49
RGB 31, 31, 31
RGB 16, 13, 04
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $4a
RGB 31, 31, 31
RGB 28, 04, 02
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $4b
RGB 31, 31, 31
RGB 18, 23, 31
RGB 15, 20, 31
RGB 00, 00, 00
-
+; $4c
RGB 31, 31, 31
RGB 24, 20, 11
RGB 18, 13, 11
RGB 00, 00, 00
-
+; $4d
RGB 31, 31, 31
RGB 31, 31, 31
RGB 25, 30, 00
RGB 25, 30, 00
-
+; $4e
RGB 00, 00, 00
RGB 08, 11, 11
RGB 21, 21, 21
diff --git a/data/palettes/tileset_bg.pal b/data/palettes/tileset_bg.pal
deleted file mode 100644
index 3cd14d142..000000000
--- a/data/palettes/tileset_bg.pal
+++ /dev/null
@@ -1,227 +0,0 @@
-; morn
-
-; gray
- RGB 28, 31, 16
- RGB 21, 21, 21
- RGB 13, 13, 13
- RGB 07, 07, 07
-; red
- RGB 28, 31, 16
- RGB 31, 19, 24
- RGB 30, 10, 06
- RGB 07, 07, 07
-; green
- RGB 22, 31, 10
- RGB 12, 25, 01
- RGB 05, 14, 00
- RGB 07, 07, 07
-; water
- RGB 31, 31, 31
- RGB 08, 12, 31
- RGB 01, 04, 31
- RGB 07, 07, 07
-; yellow
- RGB 28, 31, 16
- RGB 31, 31, 07
- RGB 31, 16, 01
- RGB 07, 07, 07
-; brown
- RGB 28, 31, 16
- RGB 24, 18, 07
- RGB 20, 15, 03
- RGB 07, 07, 07
-; roof
- RGB 28, 31, 16
- RGB 15, 31, 31
- RGB 05, 17, 31
- RGB 07, 07, 07
-; text
- RGB 31, 31, 16
- RGB 31, 31, 16
- RGB 14, 09, 00
- RGB 00, 00, 00
-
-; day
-
-; gray
- RGB 27, 31, 27
- RGB 21, 21, 21
- RGB 13, 13, 13
- RGB 07, 07, 07
-; red
- RGB 27, 31, 27
- RGB 31, 19, 24
- RGB 30, 10, 06
- RGB 07, 07, 07
-; green
- RGB 22, 31, 10
- RGB 12, 25, 01
- RGB 05, 14, 00
- RGB 07, 07, 07
-; water
- RGB 31, 31, 31
- RGB 08, 12, 31
- RGB 01, 04, 31
- RGB 07, 07, 07
-; yellow
- RGB 27, 31, 27
- RGB 31, 31, 07
- RGB 31, 16, 01
- RGB 07, 07, 07
-; brown
- RGB 27, 31, 27
- RGB 24, 18, 07
- RGB 20, 15, 03
- RGB 07, 07, 07
-; roof
- RGB 27, 31, 27
- RGB 15, 31, 31
- RGB 05, 17, 31
- RGB 07, 07, 07
-; text
- RGB 31, 31, 16
- RGB 31, 31, 16
- RGB 14, 09, 00
- RGB 00, 00, 00
-
-; nite
-
-; gray
- RGB 15, 14, 24
- RGB 11, 11, 19
- RGB 07, 07, 12
- RGB 00, 00, 00
-; red
- RGB 15, 14, 24
- RGB 14, 07, 17
- RGB 13, 00, 08
- RGB 00, 00, 00
-; green
- RGB 15, 14, 24
- RGB 08, 13, 19
- RGB 00, 11, 13
- RGB 00, 00, 00
-; water
- RGB 15, 14, 24
- RGB 05, 05, 17
- RGB 03, 03, 10
- RGB 00, 00, 00
-; yellow
- RGB 30, 30, 11
- RGB 16, 14, 18
- RGB 16, 14, 10
- RGB 00, 00, 00
-; brown
- RGB 15, 14, 24
- RGB 12, 09, 15
- RGB 08, 04, 05
- RGB 00, 00, 00
-; roof
- RGB 15, 14, 24
- RGB 13, 12, 23
- RGB 11, 09, 20
- RGB 00, 00, 00
-; text
- RGB 31, 31, 16
- RGB 31, 31, 16
- RGB 14, 09, 00
- RGB 00, 00, 00
-
-; dark
-
-; gray
- RGB 01, 01, 02
- RGB 00, 00, 00
- RGB 00, 00, 00
- RGB 00, 00, 00
-; red
- RGB 01, 01, 02
- RGB 00, 00, 00
- RGB 00, 00, 00
- RGB 00, 00, 00
-; green
- RGB 01, 01, 02
- RGB 00, 00, 00
- RGB 00, 00, 00
- RGB 00, 00, 00
-; water
- RGB 01, 01, 02
- RGB 00, 00, 00
- RGB 00, 00, 00
- RGB 00, 00, 00
-; yellow
- RGB 30, 30, 11
- RGB 00, 00, 00
- RGB 00, 00, 00
- RGB 00, 00, 00
-; brown
- RGB 01, 01, 02
- RGB 00, 00, 00
- RGB 00, 00, 00
- RGB 00, 00, 00
-; roof
- RGB 01, 01, 02
- RGB 00, 00, 00
- RGB 00, 00, 00
- RGB 00, 00, 00
-; text
- RGB 31, 31, 16
- RGB 31, 31, 16
- RGB 14, 09, 00
- RGB 00, 00, 00
-
-; indoor
-
-; gray
- RGB 30, 28, 26
- RGB 19, 19, 19
- RGB 13, 13, 13
- RGB 07, 07, 07
-; red
- RGB 30, 28, 26
- RGB 31, 19, 24
- RGB 30, 10, 06
- RGB 07, 07, 07
-; green
- RGB 18, 24, 09
- RGB 15, 20, 01
- RGB 09, 13, 00
- RGB 07, 07, 07
-; water
- RGB 30, 28, 26
- RGB 15, 16, 31
- RGB 09, 09, 31
- RGB 07, 07, 07
-; yellow
- RGB 30, 28, 26
- RGB 31, 31, 07
- RGB 31, 16, 01
- RGB 07, 07, 07
-; brown
- RGB 26, 24, 17
- RGB 21, 17, 07
- RGB 16, 13, 03
- RGB 07, 07, 07
-; roof
- RGB 30, 28, 26
- RGB 17, 19, 31
- RGB 14, 16, 31
- RGB 07, 07, 07
-; text
- RGB 31, 31, 16
- RGB 31, 31, 16
- RGB 14, 09, 00
- RGB 00, 00, 00
-
-; overworld water
-
-; morn/day
- RGB 23, 23, 31
- RGB 18, 19, 31
- RGB 13, 12, 31
- RGB 07, 07, 07
-; nite
- RGB 15, 13, 27
- RGB 10, 09, 20
- RGB 04, 03, 18
- RGB 00, 00, 00
diff --git a/data/palettes/49757.pal b/data/palettes/unknown/49757.pal
index 93e884046..93e884046 100644
--- a/data/palettes/49757.pal
+++ b/data/palettes/unknown/49757.pal
diff --git a/data/palettes/unknown/4985a.asm b/data/palettes/unknown/4985a.asm
new file mode 100644
index 000000000..35f272227
--- /dev/null
+++ b/data/palettes/unknown/4985a.asm
@@ -0,0 +1,15 @@
+ db $ab, $03, $57, $24, $ac, $0e, $13, $32
+
+ db $be, $30, $5b, $4c, $47, $60, $ed, $f2
+
+ db $ab, $03, $55, $26, $aa, $0a, $13, $3a
+
+ db $be, $28, $33, $24, $6e, $71, $df, $b0
+
+ db $a8, $00, $e5, $e0, $9a, $fc, $f4, $2c
+
+ db $fe, $4c, $a3, $5e, $c6, $3a, $ab, $4d
+
+ db $a8, $00, $b5, $b0, $de, $e8, $fc, $1c
+
+ db $ba, $66, $f7, $0e, $ba, $5e, $43, $bd
diff --git a/data/palettes/b6f1.pal b/data/palettes/unknown/b6f1.pal
index 1dd56f50f..1dd56f50f 100644
--- a/data/palettes/b6f1.pal
+++ b/data/palettes/unknown/b6f1.pal
diff --git a/data/palettes/b719.pal b/data/palettes/unknown/b719.pal
index 09dd9a364..09dd9a364 100644
--- a/data/palettes/b719.pal
+++ b/data/palettes/unknown/b719.pal
diff --git a/data/palettes/b789.pal b/data/palettes/unknown/b789.pal
index cce760662..cce760662 100644
--- a/data/palettes/b789.pal
+++ b/data/palettes/unknown/b789.pal
diff --git a/data/sgb_border_map.asm b/data/sgb_border_map.asm
index d9efb8ead..18e6c7740 100644
--- a/data/sgb_border_map.asm
+++ b/data/sgb_border_map.asm
@@ -1,4 +1,4 @@
-
+SGBBorderMap:
db $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $14, $14, $15, $14, $16, $14, $17, $14, $17, $54, $16, $54, $15, $54, $14, $54, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14
db $01, $14, $02, $14, $03, $14, $03, $54, $02, $54, $01, $54, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $24, $14, $25, $14, $26, $14, $07, $14, $07, $54, $26, $54, $25, $54, $24, $54, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $54, $01, $14, $02, $14, $03, $14, $03, $54, $02, $54, $01, $54
db $11, $14, $12, $14, $13, $14, $13, $54, $12, $54, $11, $54, $10, $54, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $24, $14, $34, $14, $35, $14, $35, $54, $34, $54, $33, $54, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $07, $14, $10, $14, $11, $14, $12, $14, $13, $14, $13, $54, $12, $54, $11, $54
diff --git a/data/unown_words.asm b/data/unown_words.asm
index a36dea6d1..e70f72356 100644
--- a/data/unown_words.asm
+++ b/data/unown_words.asm
@@ -38,15 +38,15 @@ UnownWords: ; fba5a
dw UnownWord26
; fba90
-UnownWord1: unownword "ANGRY"
-UnownWord2: unownword "BEAR"
-UnownWord3: unownword "CHASE"
-UnownWord4: unownword "DIRECT"
-UnownWord5: unownword "ENGAGE"
-UnownWord6: unownword "FIND"
-UnownWord7: unownword "GIVE"
-UnownWord8: unownword "HELP"
-UnownWord9: unownword "INCREASE"
+UnownWord1: unownword "ANGRY"
+UnownWord2: unownword "BEAR"
+UnownWord3: unownword "CHASE"
+UnownWord4: unownword "DIRECT"
+UnownWord5: unownword "ENGAGE"
+UnownWord6: unownword "FIND"
+UnownWord7: unownword "GIVE"
+UnownWord8: unownword "HELP"
+UnownWord9: unownword "INCREASE"
UnownWord10: unownword "JOIN"
UnownWord11: unownword "KEEP"
UnownWord12: unownword "LAUGH"
diff --git a/docs/assembly_programming.md b/docs/assembly_programming.md
index 3d913d125..1f6073b38 100644
--- a/docs/assembly_programming.md
+++ b/docs/assembly_programming.md
@@ -1,13 +1,19 @@
# Assembly Programming
- [**RGBDS documentation**][rgbds-doc]: Includes information on the RGBDS tools and the assembly language syntax.
+ - [**GBZ80 instructions**][gbz80-instructions]: List of CPU instructions and their effects.
+ - [**RGBASM features**][rgbasm-features]: How to use the assembler features: constants, labels, sections, macros, etc.
+ - [**RGBLINK features**][rgblink-features]: How to use the linker, including the [pokecrystal.link](/pokecrystal.link) linkerscript.
- [**Pan Docs**][pan-docs]: Everything You Always Wanted To Know About GAMEBOY (but were afraid to ask).
-- [**GameBoy Programming Manual][gb-manual]: The official GameBoy programming and hardware manual by Nintendo.
+- [**GameBoy Programming Manual**][gb-manual]: The official GameBoy programming and hardware manual by Nintendo.
- [**GameBoy Opcode Summary**][gb-opcodes]: Describes the opcodes of GameBoy assembly language.
- [**GameBoy Memory Map**][gb-memory-map]: Describes the GameBoy Color address space.
- [**awesome-gbdev**][awesome-gbdev]: A curated list of Game Boy development resources such as tools, docs, emulators, related projects and open-source ROMs.
[rgbds-doc]: https://rednex.github.io/
+[rgbasm-features]: https://rednex.github.io/rgbds/rgbasm.5.html
+[rgblink-features]: https://rednex.github.io/rgbds/rgblink.5.html
+[gbz80-instructions]: https://rednex.github.io/rgbds/gbz80.7.html
[pan-docs]: http://bgb.bircd.org/pandocs.htm
[gb-manual]: https://ia801906.us.archive.org/19/items/GameBoyProgManVer1.1/GameBoyProgManVer1.1.pdf
[gb-opcodes]: http://www.devrs.com/gb/files/opcodes.html
diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md
index b38ec12ee..bf170881a 100644
--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -72,16 +72,16 @@ This is a bug with `SpeciesItemBoost` in [battle/effect_commands.asm](/battle/ef
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 @@ This is a bug with `DittoMetalPowder` in [battle/effect_commands.asm](/battle/ef
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 @@ ClearWRAM:: ; 25a
push af
ld [rSVBK], a
xor a
- ld hl, $d000
+ ld hl, wRAM1Start
ld bc, $1000
call ByteFill
pop af
diff --git a/docs/move_anim_commands.md b/docs/move_anim_commands.md
index 9772550c3..1b9bd5b8f 100644
--- a/docs/move_anim_commands.md
+++ b/docs/move_anim_commands.md
@@ -5,7 +5,26 @@ Defined in [macros/scripts/move_anim.asm](/macros/scripts/move_anim.asm) and [ba
## `$00`−`$EF`: `anim_wait` *length*
-## `$D0`: `anim_obj` *object*, *x*, *y*, *param*
+## `$D0`: `anim_obj` *object*, *x1*, *x2*, *y1*, *y2*, *param*
+
+The *x1*/*x2* and *y1*/*y2* pairs specify the position on screen of the animation object.
+*x1*/*y1* specify a tile position, and *x2*/*y2* specify a pixel offset from that tile.
+
+Values for *x2*/*y2* are in the 0-7 range, since 8 pixels make a tile.
+
+Values for *x1* are between -16 to 31. In practice *x1* starts between 0 to 15, then between -16 to -10. Negative values are relative to the opponent, while positive values are relative to the player. Useful values are between 14 to -10 (for the opponent) and between 0 to 13 (for the player).
+
+Some sample values are:
+
+- 0: player left border
+- 6: player center
+- -15: enemy center
+- -10: enemy right border
+
+Values for *y1* are also between -16 to 31; the useful range is between 2 to 14.
+Values between 2 to 8 will be in the opponent's area (2 being the top border and 8 being the
+bottom border), and values between 8 to 14 will be in the player's area (again, 8 being the top border and 14 being the bottom border).
+The center of the body is often 2 to 4 tiles away from the border (i.e., 5-6 for the opponent or 10-11 for the player).
## `$D1`: `anim_1gfx` *gfx*
diff --git a/docs/music_commands.md b/docs/music_commands.md
index ce8368d9a..43d607ff9 100644
--- a/docs/music_commands.md
+++ b/docs/music_commands.md
@@ -2,99 +2,131 @@
Defined in [macros/scripts/audio.asm](/macros/scripts/audio.asm) and [audio/engine.asm:MusicCommands](/audio/engine.asm).
+See also: [Sound Engine Commands](https://github.com/pret/pokecrystal/wiki/Sound-Engine-Commands)
+
## `musicheader` *n*, *index*, *address*
## `cry_header` *n*, *index*, *address*
## `note` *pitch*, *length*
- (Used on all channels)
- The high nibble is the note to play, 0 is rest, 1 is C_ 2 is C# ...etc... $C is B_
- The low nibble is the length of the note. 1 gets added to this, so 0 still has a length.
+
+(Used on all channels)
+
+The high nibble is the note to play. 0 is rest, 1 is `C_`, 2 is `C#`, etc; `$C` is `B_`.
+The low nibble is the length of the note. 1 gets added to this, so 0 still has a length.
## `sound` *pitch*, *octave*, *intensity*, *frequency*
## `noise` *pitch*, *duration*, *intensity*, *frequency*
## `$D0`−`$D7`: `octave` *n*
- (Used in channels 1-3)
- Sets the octave for the notes played on the channel.
- $D7 is the lowest octave, where as $D0 is the highest.
+
+(Used in channels 1-3)
+
+Sets the octave for the notes played on the channel.
+`$D7` is the lowest octave, whereas `$D0` is the highest.
## `$D8`: `notetype` *length*[, *intensity*]
- (Used in channels 1-4)(When using in channel 4, the intensity byte is not needed)
- Sets the length multiplier of notes on the channel, and the envelope for channels 1-3 (see "intensity")
- The first byte only reads the lower 4-bits, and multiplies it to the note length. A larger number means slower playback/longer notes. $C is commonly used for a normal timeframe.
- The second byte is identical to the first byte in the intensity command.
+
+(Used in channels 1-4) (When using in channel 4, the *intensity* byte is not needed)
+
+Sets the length multiplier of notes on the channel, and the envelope for channels 1-3 (see `intensity`).
+The first byte only reads the lower 4 bits, and multiplies it by the note length. A larger number means slower playback/longer notes. `$C` is commonly used for a normal timeframe.
+
+The second byte is identical to the first byte in the `intensity` command.
## `$D9`: `pitchoffset` *octave*, *key*
- (Used in channels 1-3)
- Transposes all notes played on the channel by a value.
- The high nibble determins how many octaves to subtract, while the low nibble is how many note values to add.
- Ex: Setting a value of $13 would make a C_4 play as a D#3
+
+(Used in channels 1-3)
+
+Transposes all notes played on the channel by a value.
+The high nibble determins how many octaves to subtract, while the low nibble is how many note values to add.
+Ex: Setting a value of `$13` would make a `C_`4 play as a `D#`3.
## `$DA`: `tempo` *tempo*
- Sets the tempo for all playing channels. This should only be called on channel 1.
- The formula to convert from this tempo to BPM is: BPM = 19200 / Tempo
- This formula also works backwards to convert BPM to tempo: Tempo = 19200 / BPM
- Only set or change this value when all playing channels are triggering a note or rest at the same time, otherwise desyncs may happen.
+
+(Used in channel 1)
+
+Sets the tempo for all playing channels. This should only be called on channel 1.
+
+The formula to convert from this tempo to BPM is: BPM = 19200 / Tempo
+This formula also works backwards to convert BPM to tempo: Tempo = 19200 / BPM
+
+Only set or change this value when all playing channels are triggering a note or rest at the same time, otherwise desyncs may happen.
## `$DB`: `dutycycle` *duty_cycle*
- (Used on channels 1&2)
- Sets the square duty (sound) for the current channel. To change the sound for channel 3, use intensity. Only accepted values are 0-3.
- 0=12.5% waveform _______-
- 1=25% waveform ______--
- 2=50% waveform ____----
- 3=75% waveform __------ (Sounds the same as 25%)
+
+(Used on channels 1&2)
+
+Sets the square duty (sound) for the current channel. To change the sound for channel 3, use intensity. The only accepted values are 0-3.
+
+- 0 = 12.5% waveform: `_______¯`
+- 1 = 25% waveform: `______¯¯`
+- 2 = 50% waveform: `____¯¯¯¯`
+- 3 = 75% waveform: `__¯¯¯¯¯¯` (sounds the same as 25%)
## `$DC`: `intensity` *intensity*
- (Used on channels 1-3)(Used to set instrument on channel 3)
- For channels 1&2:
- This sets the volume and fade of the notes. The high nibble is the starting volume, 0 is mute, $F is max. Bit 3 determines the fade direction (0=Fade to silence, 1=Fade to max volume). The last 3 bits is how fast the fade happens. 0 is no fade, 1 is fastest fade, 7 is slowest fade.
- For channel 3:
- The high nibble sets the volume of channel 3. Only 4 values are accepted (0=Mute, 1=100% volume, 2=50% volume, 3=25% volume). The low nibble sets the instrument/waveform for channel 3 to play. Crystal natively has 10 instruments, values 0-9.
+
+(Used on channels 1-3) (Used to set instrument on channel 3)
+
+For channels 1&2:
+This sets the volume and fade of the notes. The high nibble is the starting volume, 0 is mute, $F is max. Bit 3 determines the fade direction (0=Fade to silence, 1=Fade to max volume). The last 3 bits is how fast the fade happens. 0 is no fade, 1 is fastest fade, 7 is slowest fade.
+
+For channel 3:
+The high nibble sets the volume of channel 3. Only 4 values are accepted (0=Mute, 1=100% volume, 2=50% volume, 3=25% volume). The low nibble sets the instrument/waveform for channel 3 to play. Crystal natively has 10 instruments, values 0-9.
## `$DD`: `soundinput` *input*
## `$DE`: `sound_duty` *a*, *b*, *c*, *d*
- (Used on channels 1&2)
- This cycles the channel through 4 duty definitions, one per frame.
- Each pair of bits defines a duty, same as the dutycycle command.
- This is mostly only used in cries, sfx, and Jigglypuff's song in RBY.
+
+(Used on channels 1&2)
+
+This cycles the channel through 4 duty definitions, one per frame.
+Each pair of bits defines a duty, same as the `dutycycle` command.
+This is mostly only used in cries, SFX, and Jigglypuff's song in RBY.
## `$DF`: `togglesfx`
## `$E0`: `slidepitchto` *duration*, *octave*, *pitch*
- (Used on channel 1)
- This bends the pitch of the note played next, and only that note.
- The first byte tells how many frames to play the destination note for, before the length of the note is up.
- The high nibble of the second byte is the octave of the destination note.
- The low nibble of the second byte is the destination note. If rest is used as the destination note, then the whole destination pitch becomes $0000 (the lowest pitch).
+
+(Used on channel 1)
+
+This bends the pitch of the note played next, and only that note.
+The first byte tells how many frames to play the destination note for, before the length of the note is up.
+The high nibble of the second byte is the octave of the destination note.
+The low nibble of the second byte is the destination note. If rest is used as the destination note, then the whole destination pitch becomes `$0000` (the lowest pitch).
## `$E1`: `vibrato` *delay*, *extent*
- (Used on channels 1-3)
- Modifies pitch after the timer runs out, making notes sound less "flat"
- First byte will set the delay, decrementing by one each frame. When it tries subtracting from 0, it starts decrementing from the speed timer.
- Second byte, high nibble is the speed timer. It will decrement by one each frame, when it tries decrementing from 0, it mods the frequencey by half of pitch depth, and resets itself to it's initial value.
- Second byte, low nibble is the pitch depth. Half of this value will alternate between adding to the pitch, and subtracting from the pitch each time speed timer resets. When this is an odd number, the value added to the pitch will be greater than the value subtracted from the pitch.
- EX. normal pitch of 405, if pitch depth=3, it will alternate between 407 and 404. Speed timer does NOT reset when a new note is played. only when the song stops or changes. (also, because a timer counts 0, a timer of 5 will take 6 frames to change)
+
+(Used on channels 1-3)
+
+Modifies pitch after the timer runs out, making notes sound less "flat".
+First byte will set the delay, decrementing by one each frame. When it tries subtracting from 0, it starts decrementing from the speed timer.
+Second byte, high nibble is the speed timer. It will decrement by one each frame, when it tries decrementing from 0, it mods the frequencey by half of pitch depth, and resets itself to it's initial value.
+Second byte, low nibble is the pitch depth. Half of this value will alternate between adding to the pitch, and subtracting from the pitch each time speed timer resets. When this is an odd number, the value added to the pitch will be greater than the value subtracted from the pitch.
+Ex: normal pitch of 405, if pitch depth = 3, it will alternate between 407 and 404. Speed timer does NOT reset when a new note is played. only when the song stops or changes. (Also, because a timer counts 0, a timer of 5 will take 6 frames to change.)
## `$E2`: `unknownmusic0xe2` *unknown*
## `$E3`: `togglenoise` *id*
- (Used on channel 4)
- Sets the "drum kit" to be used. This needs to be called before channel 4 can make any noise.
- Calling it more than once in a song will mute the channel. (Keep it out of loops!)
+
+(Used on channel 4)
+
+Sets the "drum kit" to be used. This needs to be called before channel 4 can make any noise.
+Calling it more than once in a song will mute the channel. (Keep it out of loops!)
## `$E4`: `panning` *tracks*
## `$E5`: `volume` *volume*
## `$E6`: `tone` *tone*
- (Used on channel 1-3)
- This modifies the pitch of the notes (fine tuning).
- It makes notes sound better if multiple channels play the same note simultaniously.
- A lot of GSC songs set the main melody channel with a value of 1, and the secondary channel (not bass) as 2.
+
+(Used on channel 1-3)
+
+This modifies the pitch of the notes (fine tuning).
+It makes notes sound better if multiple channels play the same note simultaneously.
+A lot of GSC songs set the main melody channel with a value of 1, and the secondary channel (not bass) as 2.
## `$E7`: `unknownmusic0xe7` *unknown*
diff --git a/engine/breeding.asm b/engine/breeding.asm
index 967694612..8977ae175 100755
--- a/engine/breeding.asm
+++ b/engine/breeding.asm
@@ -719,7 +719,7 @@ EggHatch_AnimationSequence: ; 1728f (5:728f)
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 @@ EggHatch_AnimationSequence: ; 1728f (5:728f)
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
diff --git a/engine/card_flip.asm b/engine/card_flip.asm
index c0c4639ad..ef48283de 100755
--- a/engine/card_flip.asm
+++ b/engine/card_flip.asm
@@ -644,10 +644,10 @@ CardFlip_BlankDiscardedCardSlot: ; e0534
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,14 +1185,14 @@ CardFlip_CheckWinCondition: ; e0637
.IsCoinCaseFull: ; e0833
ld a, [Coins]
- cp MAX_COINS / $100
+ cp HIGH(MAX_COINS)
jr c, .less
jr z, .check_low
jr .more
.check_low
ld a, [Coins + 1]
- cp MAX_COINS % $100
+ cp LOW(MAX_COINS)
jr c, .less
.more
diff --git a/engine/cgb_layouts.asm b/engine/cgb_layouts.asm
index 05834d35f..93e2c4434 100644
--- a/engine/cgb_layouts.asm
+++ b/engine/cgb_layouts.asm
@@ -145,7 +145,7 @@ _CGB_FinishBattleScreenLayout: ; 8e23
ld bc, 6 * SCREEN_WIDTH
ld a, PAL_BATTLE_BG_TEXT
call ByteFill
- ld hl, Palettes_979c
+ ld hl, BattleObjectPals
ld de, UnknOBPals palette PAL_BATTLE_OB_GRAY
ld bc, 6 palettes
ld a, BANK(UnknOBPals)
@@ -621,8 +621,8 @@ _CGB_Evolution: ; 91e4
ld a, [PlayerHPPal]
call GetPlayerOrMonPalettePointer
call LoadPalette_White_Col1_Col2_Black
- ld hl, Palettes_979c
- ld de, UnknOBPals palette 2
+ ld hl, BattleObjectPals
+ ld de, UnknOBPals palette PAL_BATTLE_OB_GRAY
ld bc, 6 palettes
ld a, BANK(UnknOBPals)
call FarCopyWRAM
diff --git a/engine/color.asm b/engine/color.asm
index afa8fe2e7..23f953ebe 100644
--- a/engine/color.asm
+++ b/engine/color.asm
@@ -43,6 +43,7 @@ CheckShininess:
and a
ret
+; unreferenced
CheckContestMon:
; Check a mon's DVs at hl in the bug catching contest.
; Return carry if its DVs are good enough to place in the contest.
@@ -108,7 +109,8 @@ InitPartyMenuPalettes:
call WipeAttrMap
ret
-SGB_ApplyPartyMenuHPPals: ; 8ade SGB layout $fc
+; SGB layout for SCGB_PARTY_MENU_HP_PALS
+SGB_ApplyPartyMenuHPPals: ; 8ade
ld hl, wHPPals
ld a, [wSGBPals]
ld e, a
@@ -343,11 +345,11 @@ ApplyHPBarPals:
ret
.Enemy:
- ld de, BGPals + 2 palettes + 2
+ ld de, BGPals palette PAL_BATTLE_BG_ENEMY_HP + 2
jr .okay
.Player:
- ld de, BGPals + 3 palettes + 2
+ ld de, BGPals palette PAL_BATTLE_BG_PLAYER_HP + 2
.okay
ld l, c
@@ -395,11 +397,11 @@ LoadStatsScreenPals:
ld a, $5
ld [rSVBK], a
ld a, [hli]
- ld [UnknBGPals], a
- ld [UnknBGPals + 8 * 2], a
+ ld [UnknBGPals palette 0], a
+ ld [UnknBGPals palette 2], a
ld a, [hl]
- ld [UnknBGPals + 1], a
- ld [UnknBGPals + 8 * 2 + 1], a
+ ld [UnknBGPals palette 0 + 1], a
+ ld [UnknBGPals palette 2 + 1], a
pop af
ld [rSVBK], a
call ApplyPals
@@ -457,7 +459,7 @@ Function95f0:
; XXX
ld hl, .Palette
ld de, UnknBGPals
- ld bc, 8
+ ld bc, 1 palettes
ld a, $5
call FarCopyWRAM
call ApplyPals
@@ -521,10 +523,10 @@ LoadPalette_White_Col1_Col2_Black:
ld a, $5
ld [rSVBK], a
- ld a, $7fff % $100
+ ld a, LOW(palred 31 + palgreen 31 + palblue 31)
ld [de], a
inc de
- ld a, $7fff / $100
+ ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
ld [de], a
inc de
@@ -574,7 +576,7 @@ ResetBGPals:
ld [rSVBK], a
ld hl, UnknBGPals
- ld c, 8
+ ld c, 1 palettes
.loop
ld a, $ff
ld [hli], a
@@ -655,7 +657,8 @@ ApplyAttrMap:
ld [rVBK], a
ret
-CGB_ApplyPartyMenuHPPals: ; 96f3 CGB layout $fc
+; CGB layout for SCGB_PARTY_MENU_HP_PALS
+CGB_ApplyPartyMenuHPPals: ; 96f3
ld hl, wHPPals
ld a, [wSGBPals]
ld e, a
@@ -746,7 +749,7 @@ GetMonPalettePointer_:
Function9779: mobile
call CheckCGB
ret z
- ld hl, Palettes_979c
+ ld hl, BattleObjectPals
ld a, $90
ld [rOBPI], a
ld c, 6 palettes
@@ -755,15 +758,15 @@ Function9779: mobile
ld [rOBPD], a
dec c
jr nz, .loop
- ld hl, Palettes_979c
+ ld hl, BattleObjectPals
ld de, UnknOBPals palette 2
ld bc, 2 palettes
ld a, $5
call FarCopyWRAM
ret
-Palettes_979c:
-INCLUDE "data/palettes/979c.pal"
+BattleObjectPals:
+INCLUDE "data/palettes/battle_objects.pal"
Function97cc:
; XXX
@@ -909,9 +912,9 @@ InitCGBPals::
ld [rBGPI], a
ld c, 4 * 8
.bgpals_loop
- ld a, $7fff % $100
+ ld a, LOW(palred 31 + palgreen 31 + palblue 31)
ld [rBGPD], a
- ld a, $7fff / $100
+ ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
ld [rBGPD], a
dec c
jr nz, .bgpals_loop
@@ -919,9 +922,9 @@ InitCGBPals::
ld [rOBPI], a
ld c, 4 * 8
.obpals_loop
- ld a, $7fff % $100
+ ld a, LOW(palred 31 + palgreen 31 + palblue 31)
ld [rOBPD], a
- ld a, $7fff / $100
+ ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
ld [rOBPD], a
dec c
jr nz, .obpals_loop
@@ -940,9 +943,9 @@ InitCGBPals::
.LoadWhitePals:
ld c, 4 * 16
.loop
- 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 [hli], a
dec c
jr nz, .loop
@@ -1006,7 +1009,7 @@ PushSGBBorder:
SGB_ClearVRAM:
ld hl, VTiles0
- ld bc, $2000
+ ld bc, VRAM_End - VTiles0
xor a
call ByteFill
ret
@@ -1067,7 +1070,7 @@ SGBBorder_PushBGPals:
ld [rBGP], a
ld hl, PredefPals
ld de, VTiles1
- ld bc, $1000
+ ld bc, $100 tiles
call CopyData
call DrawDefaultTiles
ld a, $e3
@@ -1194,90 +1197,13 @@ SGBDelayCycles:
jr nz, .wait
ret
-BlkPacket_9a86:
- db $21, $01, $03, $00, $00, $00, $13, $11, $00, $00, $00, $00, $00, $00, $00, $00
-
-BlkPacket_9a96:
- db $21, $01, $07, $05, $00, $0a, $13, $0d, $00, $00, $00, $00, $00, $00, $00, $00
-
-BlkPacket_9aa6:
- db $22, $05, $07, $0a, $00, $0c, $13, $11, $03, $05, $01, $00, $0a, $03, $03, $00
- db $0a, $08, $13, $0a, $03, $0a, $00, $04, $08, $0b, $03, $0f, $0b, $00, $13, $07
-
-BlkPacket_9ac6:
- db $21, $01, $07, $05, $00, $01, $07, $07, $00, $00, $00, $00, $00, $00, $00, $00
-
-BlkPacket_9ad6:
- db $21, $01, $07, $05, $0b, $01, $13, $02, $00, $00, $00, $00, $00, $00, $00, $00
-
-BlkPacket_9ae6:
- db $21, $01, $07, $05, $01, $01, $08, $08, $00, $00, $00, $00, $00, $00, $00, $00
-
-BlkPacket_9af6:
- db $21, $01, $07, $05, $07, $05, $0d, $0b, $00, $00, $00, $00, $00, $00, $00, $00
-
-BlkPacket_9b06:
- db $22, $05, $03, $05, $00, $00, $13, $0b, $03, $0a, $00, $04, $13, $09, $02, $0f
- db $00, $06, $13, $07, $03, $00, $04, $04, $0f, $09, $03, $00, $00, $0c, $13, $11
-
-BlkPacket_9b26:
- db $23, $07, $07, $10, $00, $00, $02, $0c, $02, $00, $0c, $00, $12, $01, $02, $00
- db $0c, $02, $12, $03, $02, $00, $0c, $04, $12, $05, $02, $00, $0c, $06, $12, $07
- db $02, $00, $0c, $08, $12, $09, $02, $00, $0c, $0a, $12, $0b, $00, $00, $00, $00
-
-BlkPacket_9b56:
- db $22, $03, $07, $20, $00, $00, $13, $04, $03, $0f, $00, $06, $13, $11, $03, $05
- db $0f, $01, $12, $04, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-
-BlkPacket_9b76:
- db $21, $01, $07, $10, $00, $00, $13, $05, $00, $00, $00, $00, $00, $00, $00, $00
-
-BlkPacket_9b86:
- db $21, $02, $07, $0a, $00, $04, $13, $0d, $03, $05, $00, $06, $13, $0b, $00, $00
-
-PalPacket_9b96: db $51, $48, $00, $49, $00, $4a, $00, $4b, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9ba6: db $51, $2b, $00, $24, $00, $20, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9bb6: db $51, $41, $00, $42, $00, $43, $00, $44, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9bc6: db $51, $4c, $00, $4c, $00, $4c, $00, $4c, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9bd6: db $51, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9be6: db $51, $36, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9bf6: db $51, $37, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9c06: db $51, $38, $00, $39, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9c16: db $51, $3a, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9c26: db $51, $3b, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9c36: db $51, $3c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9c46: db $51, $39, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9c56: db $51, $2e, $00, $2f, $00, $30, $00, $31, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9c66: db $51, $1a, $00, $1a, $00, $1a, $00, $1a, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9c76: db $51, $32, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9c86: db $51, $3c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9c96: db $51, $3d, $00, $3e, $00, $3f, $00, $40, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9ca6: db $51, $33, $00, $34, $00, $1b, $00, $1f, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9cb6: db $51, $1b, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9cc6: db $51, $1c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9cd6: db $51, $35, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9ce6: db $01, $ff, $7f, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9cf6: db $09, $ff, $7f, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9d06: db $59, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9d16: db $89, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9d26: db $89, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9d36: db $99, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9d46: db $a1, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9d56: db $b9, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9d66: db $b9, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9d76: db $79, $5d, $08, $00, $0b, $8c, $d0, $f4, $60, $00, $00, $00, $00, $00, $00, $00
-PalPacket_9d86: db $79, $52, $08, $00, $0b, $a9, $e7, $9f, $01, $c0, $7e, $e8, $e8, $e8, $e8, $e0
-PalPacket_9d96: db $79, $47, $08, $00, $0b, $c4, $d0, $16, $a5, $cb, $c9, $05, $d0, $10, $a2, $28
-PalPacket_9da6: db $79, $3c, $08, $00, $0b, $f0, $12, $a5, $c9, $c9, $c8, $d0, $1c, $a5, $ca, $c9
-PalPacket_9db6: db $79, $31, $08, $00, $0b, $0c, $a5, $ca, $c9, $7e, $d0, $06, $a5, $cb, $c9, $7e
-PalPacket_9dc6: db $79, $26, $08, $00, $0b, $39, $cd, $48, $0c, $d0, $34, $a5, $c9, $c9, $80, $d0
-PalPacket_9dd6: db $79, $1b, $08, $00, $0b, $ea, $ea, $ea, $ea, $ea, $a9, $01, $cd, $4f, $0c, $d0
-PalPacket_9de6: db $79, $10, $08, $00, $0b, $4c, $20, $08, $ea, $ea, $ea, $ea, $ea, $60, $ea, $ea
+INCLUDE "data/palettes/blk_packets.asm"
+
+INCLUDE "data/palettes/pal_packets.asm"
PredefPals:
INCLUDE "data/palettes/predef.pal"
-SGBBorderMap:
INCLUDE "data/sgb_border_map.asm"
SGBBorderPalettes:
@@ -1287,20 +1213,10 @@ SGBBorder:
INCBIN "gfx/sgb/sgb_border.2bpp"
HPBarPals:
-; green
- RGB 30, 26, 15
- RGB 00, 23, 00
-; yellow
- RGB 30, 26, 15
- RGB 31, 21, 00
-; red
- RGB 30, 26, 15
- RGB 31, 00, 00
+INCLUDE "data/palettes/hp_bar.pal"
ExpBarPalette:
-; blue
- RGB 30, 26, 15
- RGB 04, 17, 31
+INCLUDE "data/palettes/exp_bar.pal"
INCLUDE "gfx/pics/palette_pointers.asm"
INCLUDE "gfx/trainer_palettes.asm"
@@ -1314,7 +1230,7 @@ LoadMapPals:
and 7
ld e, a
ld d, 0
- ld hl, .TilesetColorsPointers
+ ld hl, EnvironmentColorsPointers
add hl, de
add hl, de
ld a, [hli]
@@ -1405,40 +1321,7 @@ endr
call FarCopyWRAM
ret
-.TilesetColorsPointers:
- dw .OutdoorColors ; unused
- dw .OutdoorColors ; TOWN
- dw .OutdoorColors ; ROUTE
- dw .IndoorColors ; INDOOR
- dw .DungeonColors ; CAVE
- dw .Perm5Colors ; 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
-
-.Perm5Colors:
- 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
+INCLUDE "data/maps/environment_colors.asm"
Palette_b309: ; b309 mobile
RGB 31, 31, 31
@@ -1453,13 +1336,13 @@ Palette_b311: ; b311 not mobile
RGB 00, 00, 00
TilesetBGPalette:
-INCLUDE "data/palettes/tileset_bg.pal"
+INCLUDE "data/palettes/overworld/tileset_bg.pal"
MapObjectPals::
-INCLUDE "data/palettes/map_objects.pal"
+INCLUDE "data/palettes/overworld/map_objects.pal"
RoofPals:
-INCLUDE "data/palettes/roofs.pal"
+INCLUDE "data/palettes/overworld/roofs.pal"
DiplomaPalettes:
INCLUDE "data/palettes/diploma.pal"
@@ -1468,10 +1351,10 @@ PartyMenuOBPals:
INCLUDE "data/palettes/party_menu.pal"
Palettes_b6f1:
-INCLUDE "data/palettes/b6f1.pal"
+INCLUDE "data/palettes/unknown/b6f1.pal"
Palettes_b719:
-INCLUDE "data/palettes/b719.pal"
+INCLUDE "data/palettes/unknown/b719.pal"
MalePokegearPals:
INCLUDE "data/palettes/pokegear.pal"
@@ -1480,7 +1363,7 @@ FemalePokegearPals:
INCLUDE "data/palettes/pokegear_f.pal"
Palettes_b789:
-INCLUDE "data/palettes/b789.pal"
+INCLUDE "data/palettes/unknown/b789.pal"
SlotMachinePals:
INCLUDE "data/palettes/slot_machine.pal"
diff --git a/engine/credits.asm b/engine/credits.asm
index 0fe7685a6..70729ed3b 100644
--- a/engine/credits.asm
+++ b/engine/credits.asm
@@ -193,9 +193,9 @@ Credits_UpdateGFXRequestPath: ; 109964 (42:5964)
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 @@ ParseCredits: ; 1099aa
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,20 +523,20 @@ GetCreditsPalette: ; 109b2c
; 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
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
diff --git a/engine/crystal_colors.asm b/engine/crystal_colors.asm
index 43841a201..8410caa0e 100755
--- a/engine/crystal_colors.asm
+++ b/engine/crystal_colors.asm
@@ -126,10 +126,7 @@ LoadOW_BGPal7:: ; 49409
; 49418
Palette_TextBG7: ; 49418
- RGB 31, 31, 31
- RGB 08, 19, 28
- RGB 05, 05, 16
- RGB 00, 00, 00
+INCLUDE "data/palettes/overworld/bg_text.pal"
; 49420
Function49420:: ; 49420 (12:5420)
@@ -144,7 +141,7 @@ Function49420:: ; 49420 (12:5420)
MG_Mobile_Layout01: ; 4942f
call MG_Mobile_Layout_LoadPals
ld de, UnknBGPals palette PAL_BG_TEXT
- ld hl, Palette_49478
+ ld hl, .Palette_49478
ld bc, 1 palettes
ld a, BANK(UnknBGPals)
call FarCopyWRAM
@@ -174,7 +171,7 @@ MG_Mobile_Layout01: ; 4942f
ret
; 49478
-Palette_49478: ; 49478
+.Palette_49478: ; 49478
RGB 31, 31, 31
RGB 26, 31, 00
RGB 20, 16, 03
@@ -210,7 +207,7 @@ Function49496: ; 49496
INCLUDE "tilesets/special_palettes.asm"
MG_Mobile_Layout02: ; 49706
- ld hl, Palette_49732
+ ld hl, .Palette_49732
ld de, UnknBGPals
ld bc, 1 palettes
ld a, BANK(UnknBGPals)
@@ -218,7 +215,7 @@ MG_Mobile_Layout02: ; 49706
farcall ApplyPals
call MG_Mobile_Layout_WipeAttrMap
farcall ApplyAttrMap
- ld hl, Palette_4973a
+ ld hl, .Palette_4973a
ld de, UnknOBPals
ld bc, 1 palettes
ld a, BANK(UnknOBPals)
@@ -226,14 +223,14 @@ MG_Mobile_Layout02: ; 49706
ret
; 49732
-Palette_49732: ; 49732
+.Palette_49732: ; 49732
RGB 31, 31, 31
RGB 23, 16, 07
RGB 23, 07, 07
RGB 03, 07, 20
; 4973a
-Palette_4973a: ; 4973a
+.Palette_4973a: ; 4973a
RGB 00, 00, 00
RGB 07, 05, 31
RGB 14, 18, 31
@@ -241,17 +238,17 @@ Palette_4973a: ; 4973a
; 49742
Function49742: ; 49742
- ld hl, Palette_49757
+ ld hl, .Palette_49757
ld de, UnknBGPals
- ld bc, $40
+ ld bc, 8 palettes
ld a, $5
call FarCopyWRAM
farcall ApplyPals
ret
; 49757
-Palette_49757: ; 49757
-INCLUDE "data/palettes/49757.pal"
+.Palette_49757: ; 49757
+INCLUDE "data/palettes/unknown/49757.pal"
; 49797
_InitMG_Mobile_LinkTradePalMap: ; 49797
@@ -326,11 +323,4 @@ InitMG_Mobile_LinkTradePalMap: ; 49856
; 4985a
Unknown_4985a: ; unreferenced
- db $ab, $03, $57, $24, $ac, $0e, $13, $32
- db $be, $30, $5b, $4c, $47, $60, $ed, $f2
- db $ab, $03, $55, $26, $aa, $0a, $13, $3a
- db $be, $28, $33, $24, $6e, $71, $df, $b0
- db $a8, $00, $e5, $e0, $9a, $fc, $f4, $2c
- db $fe, $4c, $a3, $5e, $c6, $3a, $ab, $4d
- db $a8, $00, $b5, $b0, $de, $e8, $fc, $1c
- db $ba, $66, $f7, $0e, $ba, $5e, $43, $bd
+INCLUDE "data/palettes/unknown/4985a.asm"
diff --git a/engine/crystal_intro.asm b/engine/crystal_intro.asm
index 52b07331e..4f79dc6be 100755
--- a/engine/crystal_intro.asm
+++ b/engine/crystal_intro.asm
@@ -3,9 +3,9 @@ Copyright_GFPresents: ; e4579
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 @@ Intro_RustleGrass: ; e546d (39:546d)
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
diff --git a/engine/debug.asm b/engine/debug.asm
index 588de7a64..0ca639aaa 100755
--- a/engine/debug.asm
+++ b/engine/debug.asm
@@ -1069,7 +1069,7 @@ TilesetColorTest:
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
diff --git a/engine/events_2.asm b/engine/events_2.asm
index 12476bd31..cab6b8bd0 100644
--- a/engine/events_2.asm
+++ b/engine/events_2.asm
@@ -300,7 +300,7 @@ DoBikeStep:: ; 97db3
; 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
diff --git a/engine/experience.asm b/engine/experience.asm
index c33aaf02a..b1e1fb831 100644
--- a/engine/experience.asm
+++ b/engine/experience.asm
@@ -6,7 +6,7 @@ CalcLevel: ; 50e1b
.next_level
inc d
ld a, d
- cp (MAX_LEVEL + 1) % $100
+ cp LOW(MAX_LEVEL + 1)
jr z, .got_level
call CalcExpAtLevel
push hl
diff --git a/engine/init_hof_credits.asm b/engine/init_hof_credits.asm
index 0f55a10ab..81def1af3 100644
--- a/engine/init_hof_credits.asm
+++ b/engine/init_hof_credits.asm
@@ -46,9 +46,9 @@ InitDisplayForRedCredits: ; 4e8c2
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
diff --git a/engine/init_map.asm b/engine/init_map.asm
index d73a5acf5..b7c405b5f 100644
--- a/engine/init_map.asm
+++ b/engine/init_map.asm
@@ -27,7 +27,7 @@ ReanchorBGMap_NoOAMUpdate:: ; 6454
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 @@ ReanchorBGMap_NoOAMUpdate:: ; 6454
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 @@ HDMATransfer_FillBGMap0WithBlack: ; 64db
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
diff --git a/engine/intro_menu.asm b/engine/intro_menu.asm
index c73535459..ec53549f8 100755
--- a/engine/intro_menu.asm
+++ b/engine/intro_menu.asm
@@ -199,24 +199,24 @@ _ResetWRAM: ; 5bae
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
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 @@ Continue: ; 5d65
.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 @@ Continue_MobileAdapterMenu: ; 5df0
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 @@ Continue_MobileAdapterMenu: ; 5df0
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 @@ GameInit:: ; 642e
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
diff --git a/engine/item_effects.asm b/engine/item_effects.asm
index 4db1f3b7d..90dfdc7e0 100644
--- a/engine/item_effects.asm
+++ b/engine/item_effects.asm
@@ -861,7 +861,7 @@ HeavyBallMultiplier:
.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 @@ HeavyBallMultiplier:
.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
diff --git a/engine/items.asm b/engine/items.asm
index b0bffb6d6..dcaf10356 100755
--- a/engine/items.asm
+++ b/engine/items.asm
@@ -124,28 +124,28 @@ _CheckItem:: ; d244
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
diff --git a/engine/link.asm b/engine/link.asm
index a2aec3a10..bb3e98b3e 100755
--- a/engine/link.asm
+++ b/engine/link.asm
@@ -162,9 +162,9 @@ TimeCapsule: ; 2805d
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 @@ Gen2ToGen2LinkComms: ; 28177
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 @@ Gen2ToGen2LinkComms: ; 28177
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 @@ Gen2ToGen2LinkComms: ; 28177
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
diff --git a/engine/map_objects.asm b/engine/map_objects.asm
index c37e6d2cf..bfeefa467 100644
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -2812,7 +2812,7 @@ _UpdateSprites:: ; 5920
.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 @@ _UpdateSprites:: ; 5920
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 @@ PRIORITY_HIGH EQU $30
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]
diff --git a/engine/move_mon.asm b/engine/move_mon.asm
index 4ee283e3e..90728e84c 100755
--- a/engine/move_mon.asm
+++ b/engine/move_mon.asm
@@ -1570,18 +1570,18 @@ CalcPkmnStatC: ; e17b
.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 @@ GivePoke:: ; e277
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
diff --git a/engine/mystery_gift.asm b/engine/mystery_gift.asm
index a8bad8935..9e097e6d4 100755
--- a/engine/mystery_gift.asm
+++ b/engine/mystery_gift.asm
@@ -264,7 +264,7 @@ Function104a95: ; 104a95 (41:4a95)
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 @@ Function104a95: ; 104a95 (41:4a95)
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 @@ Function104ddd: ; 104ddd (41:4ddd)
.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 @@ Function104ddd: ; 104ddd (41:4ddd)
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 @@ Function104e3a: ; 104e3a (41:4e3a)
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 @@ Function104e93: ; 104e93 (41:4e93)
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 @@ Function104e93: ; 104e93 (41:4e93)
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 @@ Function104f57: ; 104f57 (41:4f57)
ret
Function104faf: ; 104faf (41:4faf)
- ld c, rRP % $100
+ ld c, LOW(rRP)
ld d, $0
call Function104db7
jp z, Function104f42
diff --git a/engine/namingscreen.asm b/engine/namingscreen.asm
index 484bbe753..3c4bfff5b 100755
--- a/engine/namingscreen.asm
+++ b/engine/namingscreen.asm
@@ -235,10 +235,10 @@ NamingScreen: ; 116c1
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
diff --git a/engine/odd_eggs.asm b/engine/odd_eggs.asm
index 5d67358f0..4cbeb34dc 100644
--- a/engine/odd_eggs.asm
+++ b/engine/odd_eggs.asm
@@ -15,10 +15,10 @@ GiveOddEgg: ; 1fb4b6
; 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 @@ GiveOddEgg: ; 1fb4b6
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 @@ GiveOddEgg: ; 1fb4b6
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
diff --git a/engine/overworld.asm b/engine/overworld.asm
index a505ecd66..a1b4545a9 100755
--- a/engine/overworld.asm
+++ b/engine/overworld.asm
@@ -663,10 +663,10 @@ rept 4
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
diff --git a/engine/party_menu.asm b/engine/party_menu.asm
index e89fdab19..0415e29e4 100644
--- a/engine/party_menu.asm
+++ b/engine/party_menu.asm
@@ -587,10 +587,10 @@ PlacePartyMonMobileBattleSelection: ; 50307
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]
diff --git a/engine/player_step.asm b/engine/player_step.asm
index bdd6d9907..b55584ab1 100755
--- a/engine/player_step.asm
+++ b/engine/player_step.asm
@@ -156,7 +156,7 @@ UpdateOverworldMap: ; d536 (3:5536)
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 @@ UpdateOverworldMap: ; d536 (3:5536)
ld a, [wBGMapAnchor + 1]
dec a
and $3
- or VBGMap0 / $100
+ or HIGH(VBGMap0)
ld [wBGMapAnchor + 1], a
.not_underflowed
ld hl, wMetatileStandingY
diff --git a/engine/pokegear.asm b/engine/pokegear.asm
index 2529e3b0e..96959205b 100755
--- a/engine/pokegear.asm
+++ b/engine/pokegear.asm
@@ -35,9 +35,9 @@ PokeGear: ; 90b8d (24:4b8d)
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,18 +243,18 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
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
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 @@ _FlyMap: ; 91af3
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 @@ INCBIN "gfx/pokegear/flymap_label_border.1bpp"
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
diff --git a/engine/printer_serial.asm b/engine/printer_serial.asm
index 6909a38b2..06891db5b 100755
--- a/engine/printer_serial.asm
+++ b/engine/printer_serial.asm
@@ -109,9 +109,9 @@ Printer_StartTransmittingTilemap: ; 84099 (21:4099)
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 @@ Printer_SignalSendHeader: ; 840de (21:40de)
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
diff --git a/engine/printnum.asm b/engine/printnum.asm
index 7b814a042..d1d7e7ad3 100755
--- a/engine/printnum.asm
+++ b/engine/printnum.asm
@@ -80,51 +80,51 @@ _PrintNum:: ; c4c7
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
diff --git a/engine/routines/loadpushoam.asm b/engine/routines/loadpushoam.asm
index 6fcccbcae..6af0ddf6d 100644
--- a/engine/routines/loadpushoam.asm
+++ b/engine/routines/loadpushoam.asm
@@ -11,7 +11,7 @@ LoadPushOAM:: ; 4031
ret
.PushOAM: ; 403f
- ld a, Sprites / $100
+ ld a, HIGH(Sprites)
ld [rDMA], a
ld a, (SpritesEnd - Sprites) / 4 ; 40
.pushoam_loop
diff --git a/engine/routines/phonering_copytilemapatonce.asm b/engine/routines/phonering_copytilemapatonce.asm
index 2ffa688a9..1780136d1 100644
--- a/engine/routines/phonering_copytilemapatonce.asm
+++ b/engine/routines/phonering_copytilemapatonce.asm
@@ -50,7 +50,7 @@ PhoneRing_CopyTilemapAtOnce: ; 4d188
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
diff --git a/engine/routines/savemenu_copytilemapatonce.asm b/engine/routines/savemenu_copytilemapatonce.asm
index de7cbaa8f..0adce91c6 100644
--- a/engine/routines/savemenu_copytilemapatonce.asm
+++ b/engine/routines/savemenu_copytilemapatonce.asm
@@ -47,7 +47,7 @@ SaveMenu_CopyTilemapAtOnce: ; 4cf45 (13:4f45)
ld a, SCREEN_HEIGHT
ld [hTilesPerCycle], a
ld b, 1 << 1
- ld c, rSTAT % $100
+ ld c, LOW(rSTAT)
.loop
rept SCREEN_WIDTH / 2
diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm
index db5a2735f..4ab673652 100755
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -471,10 +471,10 @@ Slots_LoadReelState: ; 929f6 (24:69f6)
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 @@ Function92bbe: ; 92bbe
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
diff --git a/engine/specials.asm b/engine/specials.asm
index 95f7cdf03..82b42d8c1 100644
--- a/engine/specials.asm
+++ b/engine/specials.asm
@@ -617,9 +617,9 @@ SpecialGameboyCheck: ; c478
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
diff --git a/engine/sprites.asm b/engine/sprites.asm
index afccc114a..755ee0835 100755
--- a/engine/sprites.asm
+++ b/engine/sprites.asm
@@ -23,7 +23,7 @@ PlaySpriteAnimations: ; 8cf69
push bc
push af
- ld a, Sprites % $100
+ ld a, LOW(Sprites)
ld [wCurrSpriteOAMAddr], a
call DoNextFrameForAllSprites
@@ -60,11 +60,11 @@ DoNextFrameForAllSprites: ; 8cf7a
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 @@ DoNextFrameForFirst16Sprites: ; 8cfa8 (23:4fa8)
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 @@ UpdateAnimFrame: ; 8d04c
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 @@ UpdateAnimFrame: ; 8d04c
inc de
ld a, e
ld [wCurrSpriteOAMAddr], a
- cp SpritesEnd % $100
+ cp LOW(SpritesEnd)
jr nc, .reached_the_end
dec c
jr nz, .loop
diff --git a/engine/start_battle.asm b/engine/start_battle.asm
index d23fe1f15..8d510b72e 100644
--- a/engine/start_battle.asm
+++ b/engine/start_battle.asm
@@ -191,7 +191,7 @@ ClearBattleRAM: ; 2ef18
call ClearWindowData
ld hl, hBGMapAddress
- xor a
+ xor a ; LOW(VBGMap0)
ld [hli], a
- ld [hl], VBGMap0 / $100
+ ld [hl], HIGH(VBGMap0)
ret
diff --git a/engine/timeset.asm b/engine/timeset.asm
index 417517005..e68f5930a 100755
--- a/engine/timeset.asm
+++ b/engine/timeset.asm
@@ -9,9 +9,9 @@ InitClock: ; 90672 (24:4672)
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
diff --git a/engine/trade_animation.asm b/engine/trade_animation.asm
index 711ba4d19..fa631ae4e 100755
--- a/engine/trade_animation.asm
+++ b/engine/trade_animation.asm
@@ -627,7 +627,7 @@ TradeAnim_PlaceTrademonStatsOnTubeAnim: ; 292f6
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 @@ TradeAnim_PlaceTrademonStatsOnTubeAnim: ; 292f6
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_TextboxScrollStart: ; 293de
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 @@ TradeAnim_ScrollOutRight: ; 293ea
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,14 +802,14 @@ TradeAnim_ScrollOutRight2: ; 2940c
ret
.done
- ld a, VBGMap1 / $100
+ ld a, HIGH(VBGMap1)
ld [hBGMapAddress + 1], a
call WaitBGMap
ld a, $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 @@ ShowOTTrademonStats: ; 29549
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_MonTemplate: ; 29573
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_Egg: ; 295a1
TrademonStats_WaitBGMap: ; 295d8
call WaitBGMap
call WaitTop
- ld a, VBGMap0 / $100
+ ld a, HIGH(VBGMap0)
ld [hBGMapAddress + 1], a
ret
diff --git a/engine/warp_connection.asm b/engine/warp_connection.asm
index fadf7d4a6..13a624d7f 100755
--- a/engine/warp_connection.asm
+++ b/engine/warp_connection.asm
@@ -233,9 +233,9 @@ LoadMapTimeOfDay: ; 104750
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
diff --git a/event/halloffame.asm b/event/halloffame.asm
index 3fadb233a..5fa1dc270 100755
--- a/event/halloffame.asm
+++ b/event/halloffame.asm
@@ -36,9 +36,9 @@ HallOfFame:: ; 0x8640e
; 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 @@ RedCredits:: ; 86455
; 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
diff --git a/event/happiness_egg.asm b/event/happiness_egg.asm
index 0c9b5a4df..a1ade1364 100755
--- a/event/happiness_egg.asm
+++ b/event/happiness_egg.asm
@@ -159,9 +159,9 @@ DayCareStep:: ; 7282
dec hl
inc [hl]
ld a, [hl]
- cp 5242880 / $10000
+ cp HIGH(MAX_DAY_CARE_EXP >> 8)
jr c, .day_care_lady
- ld a, 5242880 / $10000
+ ld a, HIGH(MAX_DAY_CARE_EXP >> 8)
ld [hl], a
.day_care_lady
@@ -181,9 +181,9 @@ DayCareStep:: ; 7282
dec hl
inc [hl]
ld a, [hl]
- cp 5242880 / $10000
+ cp HIGH(MAX_DAY_CARE_EXP >> 8)
jr c, .check_egg
- ld a, 5242880 / $10000
+ ld a, HIGH(MAX_DAY_CARE_EXP >> 8)
ld [hl], a
.check_egg
@@ -199,7 +199,7 @@ DayCareStep:: ; 7282
callfar CheckBreedmonCompatibility
ld a, [wd265]
cp 230
- ld b, -1 + 32 percent
+ ld b, 32 percent - 1
jr nc, .okay
ld a, [wd265]
cp 170
diff --git a/event/magikarp.asm b/event/magikarp.asm
index 4dab89816..02c4b10cd 100644
--- a/event/magikarp.asm
+++ b/event/magikarp.asm
@@ -127,7 +127,7 @@ CalcMagikarpLength: ; fbbfc
; 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:
diff --git a/event/mom_phone.asm b/event/mom_phone.asm
index 35021dd42..bef7d5688 100755
--- a/event/mom_phone.asm
+++ b/event/mom_phone.asm
@@ -83,11 +83,11 @@ CheckBalance_MomItem2: ; fd044
.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
diff --git a/event/poisonstep_pals.asm b/event/poisonstep_pals.asm
index 8930d4c5d..088be8848 100644
--- a/event/poisonstep_pals.asm
+++ b/event/poisonstep_pals.asm
@@ -32,9 +32,9 @@ LoadPoisonBGPals: ; cbcdd
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
diff --git a/event/special.asm b/event/special.asm
index 8937698f5..d28d0de64 100755
--- a/event/special.asm
+++ b/event/special.asm
@@ -85,10 +85,10 @@ SpecialReturnShuckle: ; 737e
; 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
diff --git a/event/unown.asm b/event/unown.asm
index 1be858bd6..6c0e972f8 100644
--- a/event/unown.asm
+++ b/event/unown.asm
@@ -59,10 +59,10 @@ SpecialAerodactylChamber: ; 8ae30
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 @@ SpecialKabutoChamber: ; 8ae4e
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
diff --git a/home.asm b/home.asm
index d7eb44258..8bd081707 100644
--- a/home.asm
+++ b/home.asm
@@ -606,7 +606,7 @@ CopyTilemapAtOnce:: ; 323d
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 @@ PushLYOverrides:: ; 3b0c
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
diff --git a/home/copy.asm b/home/copy.asm
index 8ee1c90f9..210fb773e 100644
--- a/home/copy.asm
+++ b/home/copy.asm
@@ -72,16 +72,16 @@ OldDMATransfer:: ; dfd
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
diff --git a/home/game_time.asm b/home/game_time.asm
index 09d558eef..91dd381fc 100644
--- a/home/game_time.asm
+++ b/home/game_time.asm
@@ -106,11 +106,11 @@ UpdateGameTimer:: ; 20ad
; 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
diff --git a/home/init.asm b/home/init.asm
index 630cfe622..9023fada2 100644
--- a/home/init.asm
+++ b/home/init.asm
@@ -141,9 +141,9 @@ Init:: ; 17d
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 @@ ClearWRAM:: ; 25a
push af
ld [rSVBK], a
xor a
- ld hl, $d000
+ ld hl, wRAM1Start
ld bc, $1000
call ByteFill
pop af
diff --git a/home/lcd.asm b/home/lcd.asm
index b73e9e5be..8ec1e02ce 100644
--- a/home/lcd.asm
+++ b/home/lcd.asm
@@ -23,7 +23,7 @@ LCD:: ; 552
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]
diff --git a/home/map.asm b/home/map.asm
index 37022e234..1becaa64a 100644
--- a/home/map.asm
+++ b/home/map.asm
@@ -1241,10 +1241,10 @@ ScrollMapUp:: ; 2748
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 @@ UpdateBGMapColumn:: ; 27f8
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
diff --git a/home/movement.asm b/home/movement.asm
index 0a2623a09..a7c9dbb5b 100644
--- a/home/movement.asm
+++ b/home/movement.asm
@@ -4,9 +4,9 @@ InitMovementBuffer:: ; 1b1e
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
diff --git a/home/palettes.asm b/home/palettes.asm
index 4eec68b5d..80e4e25ec 100644
--- a/home/palettes.asm
+++ b/home/palettes.asm
@@ -24,18 +24,18 @@ ForceUpdateCGBPals:: ; c37
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 @@ endr
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 @@ DmgToCgbBGPals:: ; c9f
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 @@ DmgToCgbObjPals:: ; ccb
ld a, [rSVBK]
push af
- ld a, 5
+ ld a, BANK(OBPals)
ld [rSVBK], a
; copy & reorder obj pal buffer
@@ -178,11 +178,11 @@ DmgToCgbObjPal0:: ; cf8
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 @@ DmgToCgbObjPal1:: ; d24
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 @@ Special_ReloadSpritesNoPalettes:: ; d91
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
diff --git a/home/video.asm b/home/video.asm
index e3c231b4f..3efa32550 100644
--- a/home/video.asm
+++ b/home/video.asm
@@ -143,9 +143,9 @@ UpdateBGMap:: ; 164c
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]
diff --git a/lib/mobile/main.asm b/lib/mobile/main.asm
index 0d2003f2e..a383979e2 100644
--- a/lib/mobile/main.asm
+++ b/lib/mobile/main.asm
@@ -108,10 +108,10 @@ Function110030:: ; 110030 (44:4030)
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 @@ Function11032c: ; 11032c
; 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 @@ Function110d37: ; 110d37
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 @@ Function110d37: ; 110d37
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 @@ Function110d37: ; 110d37
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 @@ Function1136c1: ; 1136c1
.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 @@ endr
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
diff --git a/macros.asm b/macros.asm
index 48c2ceca4..cce53b45f 100644
--- a/macros.asm
+++ b/macros.asm
@@ -19,7 +19,6 @@ INCLUDE "macros/scripts/move_anim.asm"
INCLUDE "macros/scripts/trade_anim.asm"
INCLUDE "macros/scripts/gfx_anim.asm"
-
percent EQUS "* $ff / 100"
tiles EQUS "* LEN_2BPP_TILE"
diff --git a/macros/data.asm b/macros/data.asm
index cf4af0338..ee812d43a 100644
--- a/macros/data.asm
+++ b/macros/data.asm
@@ -95,7 +95,7 @@ dsprite: MACRO
; 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
diff --git a/main.asm b/main.asm
index 6abdc9242..cb57726da 100644
--- a/main.asm
+++ b/main.asm
@@ -85,9 +85,16 @@ INCLUDE "event/daycare.asm"
INCLUDE "event/print_unown.asm"
INCLUDE "event/print_photo.asm"
INCLUDE "engine/breeding.asm"
+
+
INCLUDE "tilesets/data.asm"
+SECTION "Roofs", ROMX
+
+INCLUDE "tilesets/roofs.asm"
+
+
SECTION "Clock Reset", ROMX
INCLUDE "engine/clock_reset.asm"
diff --git a/mobile/battle_tower_5c.asm b/mobile/battle_tower_5c.asm
index da1691038..8770505c1 100755
--- a/mobile/battle_tower_5c.asm
+++ b/mobile/battle_tower_5c.asm
@@ -116,13 +116,13 @@ Function170139: ; 170139
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 @@ ReadBTTrainerParty: ; 1702b7
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
diff --git a/mobile/fixed_words.asm b/mobile/fixed_words.asm
index 5f6fc1808..a0f65599c 100755
--- a/mobile/fixed_words.asm
+++ b/mobile/fixed_words.asm
@@ -3015,26 +3015,26 @@ EZChat_GetSeenPokemonByKana: ; 11d3ba
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
diff --git a/mobile/mobile_12.asm b/mobile/mobile_12.asm
index d3c1c0be3..b6e20ef03 100755
--- a/mobile/mobile_12.asm
+++ b/mobile/mobile_12.asm
@@ -39,9 +39,9 @@ InitMobileProfile: ; 4802f (12:402f)
.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
diff --git a/mobile/mobile_40.asm b/mobile/mobile_40.asm
index fc8ea13cf..c25178715 100644
--- a/mobile/mobile_40.asm
+++ b/mobile/mobile_40.asm
@@ -2736,9 +2736,9 @@ LoadSelectedPartiesForColosseum: ; 1010f2
.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 @@ Function1030cd: ; 1030cd
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
diff --git a/mobile/mobile_42.asm b/mobile/mobile_42.asm
index e551b5245..bdb002757 100644
--- a/mobile/mobile_42.asm
+++ b/mobile/mobile_42.asm
@@ -1297,7 +1297,7 @@ MobileTradeAnim_DisplayReceivedMon:
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 @@ MobileTradeAnim_DisplayEggData
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 @@ Function108a33: ; 108a33
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_LoadMonTemplate: ; 108a5b
MobileTradeAnim_MonDisplay_UpdateBGMap: ; 108a87
call WaitBGMap
call WaitTop
- ld a, VBGMap0 / $100
+ ld a, HIGH(VBGMap0)
ld [hBGMapAddress + 1], a
ret
; 108a92
diff --git a/mobile/mobile_45.asm b/mobile/mobile_45.asm
index 1c2adbfce..ff3f41102 100644
--- 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 @@ Function117c4a:
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
diff --git a/mobile/mobile_46.asm b/mobile/mobile_46.asm
index 150f9baa7..71cf49467 100755
--- a/mobile/mobile_46.asm
+++ b/mobile/mobile_46.asm
@@ -1901,17 +1901,17 @@ Function118f68:
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 @@ Function1193a0:
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 @@ Function1198f7:
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 @@ Function119b6b: ; 119b6b
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 @@ Function11a90f: ; 11a90f
.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 @@ Function11b6b4: ; 11b6b4
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 @@ Function11b93b: ; 11b93b
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
diff --git a/tilesets/animations.asm b/tilesets/animations.asm
index 3de67ee6e..dc84a0cba 100644
--- a/tilesets/animations.asm
+++ b/tilesets/animations.asm
@@ -1,4 +1,3 @@
-
_AnimateTileset:: ; fc000
; Iterate over a given pointer array of
; animation functions (one per frame).
@@ -476,10 +475,10 @@ AnimateWaterTile: ; fc402
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.
@@ -514,10 +513,10 @@ ForestTreeLeftAnimation: ; fc45c
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
@@ -556,10 +555,10 @@ ForestTreeRightAnimation: ; fc4c4
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
@@ -592,10 +591,10 @@ ForestTreeLeftAnimation2: ; fc4f2
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
@@ -624,10 +623,10 @@ ForestTreeRightAnimation2: ; fc51c
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
diff --git a/tilesets/data.asm b/tilesets/data.asm
index 7cd1b9072..c26b7d3d1 100644
--- a/tilesets/data.asm
+++ b/tilesets/data.asm
@@ -1,8 +1,3 @@
-SECTION "Roofs", ROMX
-
-INCLUDE "tilesets/roofs.asm"
-
-
SECTION "Tileset Data 1", ROMX
TilesetKantoGFX: ; 0x18000
diff --git a/tilesets/battle_tower.pal b/tilesets/palettes/battle_tower.pal
index 4e71a5575..4e71a5575 100644
--- a/tilesets/battle_tower.pal
+++ b/tilesets/palettes/battle_tower.pal
diff --git a/tilesets/house_1.pal b/tilesets/palettes/house_1.pal
index a9f8b74b6..a9f8b74b6 100644
--- a/tilesets/house_1.pal
+++ b/tilesets/palettes/house_1.pal
diff --git a/tilesets/ice_path.pal b/tilesets/palettes/ice_path.pal
index cb7659f50..cb7659f50 100644
--- a/tilesets/ice_path.pal
+++ b/tilesets/palettes/ice_path.pal
diff --git a/tilesets/pokecom_center.pal b/tilesets/palettes/pokecom_center.pal
index 9fe7b765a..9fe7b765a 100644
--- a/tilesets/pokecom_center.pal
+++ b/tilesets/palettes/pokecom_center.pal
diff --git a/tilesets/radio_tower.pal b/tilesets/palettes/radio_tower.pal
index 5799b6f77..5799b6f77 100644
--- a/tilesets/radio_tower.pal
+++ b/tilesets/palettes/radio_tower.pal
diff --git a/tilesets/roofs.asm b/tilesets/roofs.asm
index 0e43854dd..a9fd8a654 100644
--- a/tilesets/roofs.asm
+++ b/tilesets/roofs.asm
@@ -18,12 +18,3 @@ LoadMapGroupRoof:: ; 1c000
INCLUDE "data/maps/mapgroup_roofs.asm"
-
-
-Roofs: ; 1c03c
-INCBIN "gfx/tilesets/roofs/0.2bpp"
-INCBIN "gfx/tilesets/roofs/1.2bpp"
-INCBIN "gfx/tilesets/roofs/2.2bpp"
-INCBIN "gfx/tilesets/roofs/3.2bpp"
-INCBIN "gfx/tilesets/roofs/4.2bpp"
-; 1c30c
diff --git a/tilesets/special_palettes.asm b/tilesets/special_palettes.asm
index 5674d9f80..7ec2537e0 100644
--- a/tilesets/special_palettes.asm
+++ b/tilesets/special_palettes.asm
@@ -63,7 +63,7 @@ LoadPokeComPalette: ; 494f2
; 49501
PokeComPalette: ; 49501
-INCLUDE "tilesets/pokecom_center.pal"
+INCLUDE "tilesets/palettes/pokecom_center.pal"
; 49541
LoadBattleTowerPalette: ; 49541
@@ -76,7 +76,7 @@ LoadBattleTowerPalette: ; 49541
; 49550
BattleTowerPalette: ; 49550
-INCLUDE "tilesets/battle_tower.pal"
+INCLUDE "tilesets/palettes/battle_tower.pal"
; 49590
LoadIcePathPalette: ; 49590
@@ -89,7 +89,7 @@ LoadIcePathPalette: ; 49590
; 4959f
IcePathPalette: ; 4959f
-INCLUDE "tilesets/ice_path.pal"
+INCLUDE "tilesets/palettes/ice_path.pal"
; 495df
LoadHousePalette: ; 495df
@@ -102,7 +102,7 @@ LoadHousePalette: ; 495df
; 495ee
HousePalette: ; 495ee
-INCLUDE "tilesets/house_1.pal"
+INCLUDE "tilesets/palettes/house_1.pal"
; 4962e
LoadRadioTowerPalette: ; 4962e
@@ -115,7 +115,7 @@ LoadRadioTowerPalette: ; 4962e
; 4963d
RadioTowerPalette: ; 4963d
-INCLUDE "tilesets/radio_tower.pal"
+INCLUDE "tilesets/palettes/radio_tower.pal"
; 4967d
MansionPalette1: ; 4967d