summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/battle/ai/scoring.asm69
-rw-r--r--engine/battle/core.asm2
-rw-r--r--engine/battle/trainer_huds.asm2
-rw-r--r--engine/battle_anims/bg_effects.asm2
-rw-r--r--engine/events/happiness_egg.asm2
-rw-r--r--engine/events/pokerus/pokerus.asm30
-rw-r--r--engine/games/slot_machine.asm42
-rw-r--r--engine/gfx/color.asm10
-rw-r--r--engine/gfx/dma_transfer.asm4
-rw-r--r--engine/gfx/load_font.asm48
-rw-r--r--engine/gfx/mon_icons.asm2
-rw-r--r--engine/gfx/sgb_layouts.asm4
-rw-r--r--engine/items/print_item_description.asm2
-rw-r--r--engine/items/tmhm.asm8
-rw-r--r--engine/link/init_list.asm1
-rw-r--r--engine/link/link.asm4
-rw-r--r--engine/link/link_trade.asm4
-rw-r--r--engine/link/mystery_gift_2.asm2
-rw-r--r--engine/menus/menu_2.asm3
-rw-r--r--engine/menus/savemenu_copytilemapatonce.asm25
-rw-r--r--engine/menus/scrolling_menu.asm4
-rw-r--r--engine/menus/trainer_card.asm11
-rw-r--r--engine/movie/credits.asm4
-rw-r--r--engine/overworld/player_movement.asm13
-rw-r--r--engine/overworld/player_object.asm2
-rw-r--r--engine/phone/phonering_copytilemapatonce.asm15
-rw-r--r--engine/pokedex/pokedex.asm6
-rw-r--r--engine/pokemon/mon_menu.asm2
-rw-r--r--engine/pokemon/party_menu.asm4
-rw-r--r--engine/pokemon/print_move_description.asm4
30 files changed, 178 insertions, 153 deletions
diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm
index 75efcf920..10ad045ff 100644
--- a/engine/battle/ai/scoring.asm
+++ b/engine/battle/ai/scoring.asm
@@ -1,5 +1,6 @@
AIScoring: ; used only for BANK(AIScoring)
+
AI_Basic:
; Don't do anything redundant:
; -Using status-only moves if the player can't be statused
@@ -458,15 +459,15 @@ AI_Smart_LockOn:
.asm_38834
ld a, [wPlayerEvaLevel]
- cp $a
+ cp BASE_STAT_LEVEL + 3
jr nc, .asm_3887a
- cp $8
+ cp BASE_STAT_LEVEL + 1
jr nc, .asm_38875
ld a, [wEnemyAccLevel]
- cp $5
+ cp BASE_STAT_LEVEL - 2
jr c, .asm_3887a
- cp $7
+ cp BASE_STAT_LEVEL
jr c, .asm_38875
ld hl, wEnemyMonMoves
@@ -572,7 +573,7 @@ AI_Smart_Selfdestruct:
; If enemy's HP is between 25% and 50%,
; over 90% chance to greatly discourage this move.
call Random
- cp 9 percent - 2
+ cp 8 percent
ret c
.asm_388c6
@@ -596,7 +597,7 @@ AI_Smart_DreamEater:
AI_Smart_EvasionUp:
; Dismiss this move if enemy's evasion can't raise anymore.
ld a, [wEnemyEvaLevel]
- cp $d
+ cp MAX_STAT_LEVEL
jp nc, AIDiscourageMove
; If enemy's HP is full...
@@ -707,12 +708,12 @@ AI_Smart_AlwaysHit:
; ...enemy's accuracy level has been lowered three or more stages
ld a, [wEnemyAccLevel]
- cp $5
+ cp BASE_STAT_LEVEL - 2
jr c, .asm_38954
; ...or player's evasion level has been raised three or more stages.
ld a, [wPlayerEvaLevel]
- cp $a
+ cp BASE_STAT_LEVEL + 3
ret c
.asm_38954
@@ -872,12 +873,12 @@ AI_Smart_ResetStats:
; 85% chance to encourage this move if any of enemy's stat levels is lower than -2.
push hl
ld hl, wEnemyAtkLevel
- ld c, $8
+ ld c, NUM_LEVEL_STATS
.asm_389fb
dec c
jr z, .asm_38a05
ld a, [hli]
- cp $5
+ cp BASE_STAT_LEVEL - 2
jr c, .asm_38a12
jr .asm_389fb
@@ -889,7 +890,7 @@ AI_Smart_ResetStats:
dec c
jr z, .asm_38a1b
ld a, [hli]
- cp $a
+ cp BASE_STAT_LEVEL + 3
jr c, .asm_38a0a
.asm_38a12
@@ -1045,7 +1046,7 @@ AI_Smart_Unused2B:
.asm_38aaa
push hl
ld hl, wPlayerUsedMoves
- ld c, 4
+ ld c, NUM_MOVES
.asm_38ab0
ld a, [hli]
@@ -1108,12 +1109,12 @@ AI_Smart_SpDefenseUp2:
; Discourage this move if enemy's special defense level is higher than +3.
ld a, [wEnemySDefLevel]
- cp $b
+ cp BASE_STAT_LEVEL + 4
jr nc, .asm_38b10
; 80% chance to greatly encourage this move if
; enemy's Special Defense level is lower than +2, and the player is of a special type.
- cp $9
+ cp BASE_STAT_LEVEL + 2
ret nc
ld a, [wBattleMonType1]
@@ -1252,11 +1253,11 @@ AI_Smart_Rage:
; Encourage this move based on Rage's counter.
.asm_38b8c
ld a, [wEnemyRageCounter]
- cp $2
+ cp 2
ret c
dec [hl]
ld a, [wEnemyRageCounter]
- cp $3
+ cp 3
ret c
dec [hl]
ret
@@ -1328,7 +1329,7 @@ AI_Smart_Mimic:
AI_Smart_Counter:
push hl
ld hl, wPlayerUsedMoves
- ld c, 4
+ ld c, NUM_MOVES
ld b, 0
.asm_38bf9
@@ -1467,8 +1468,8 @@ AI_Smart_SleepTalk:
; Greatly discourage this move otherwise.
ld a, [wEnemyMonStatus]
- and $7
- cp $1
+ and SLP
+ cp 1
jr z, .asm_38cc7
dec [hl]
@@ -1510,7 +1511,7 @@ AI_Smart_Spite:
.asm_38ce7
push hl
ld b, a
- ld c, 4
+ ld c, NUM_MOVES
ld hl, wBattleMonMoves
ld de, wBattleMonPP
@@ -1529,9 +1530,9 @@ AI_Smart_Spite:
.asm_38cfb
pop hl
ld a, [de]
- cp $6
+ cp 6
jr c, .asm_38d0d
- cp $f
+ cp 15
jr nc, .asm_38d0b
call Random
@@ -1828,9 +1829,9 @@ AI_Smart_Curse:
jr nc, .asm_38e93
ld a, [wEnemyAtkLevel]
- cp $b
+ cp BASE_STAT_LEVEL + 4
jr nc, .asm_38e93
- cp $9
+ cp BASE_STAT_LEVEL + 2
ret nc
ld a, [wBattleMonType1]
@@ -1954,10 +1955,10 @@ AI_Smart_Protect:
AI_Smart_Foresight:
ld a, [wEnemyAccLevel]
- cp $5
+ cp BASE_STAT_LEVEL - 2
jr c, .asm_38f41
ld a, [wPlayerEvaLevel]
- cp $a
+ cp BASE_STAT_LEVEL + 3
jr nc, .asm_38f41
ld a, [wBattleMonType1]
@@ -2146,10 +2147,10 @@ AI_Smart_Rollout:
jr nc, .asm_39020
ld a, [wEnemyAccLevel]
- cp 7
+ cp BASE_STAT_LEVEL
jr c, .asm_39020
ld a, [wPlayerEvaLevel]
- cp 8
+ cp BASE_STAT_LEVEL + 1
jr nc, .asm_39020
; Otherwise, 80% chance to greatly encourage this move.
@@ -2417,7 +2418,7 @@ AI_Smart_BellyDrum:
; Else, discourage this move if enemy's HP is not full.
ld a, [wEnemyAtkLevel]
- cp $a
+ cp BASE_STAT_LEVEL + 3
jr nc, .asm_3914d
call AICheckEnemyMaxHP
@@ -2472,12 +2473,12 @@ AI_Smart_PsychUp:
; Else, 80% chance to encourage this move unless player's accuracy level is lower than -1...
ld a, [wPlayerAccLevel]
- cp $6
+ cp BASE_STAT_LEVEL - 1
ret c
; ...or enemy's evasion level is higher than +0.
ld a, [wEnemyEvaLevel]
- cp $8
+ cp BASE_STAT_LEVEL + 1
ret nc
call AI_80_20
@@ -2494,8 +2495,8 @@ AI_Smart_PsychUp:
AI_Smart_MirrorCoat:
push hl
ld hl, wPlayerUsedMoves
- ld c, $4
- ld b, $0
+ ld c, NUM_MOVES
+ ld b, 0
.asm_39193
ld a, [hli]
@@ -2828,7 +2829,7 @@ AIHasMoveInArray:
.next
ld a, [hli]
- cp $ff
+ cp -1
jr z, .done
ld b, a
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 4d561c7ae..d51e4cdd5 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -6200,7 +6200,7 @@ LoadEnemyMon:
jr z, .Happiness
; 40% chance of not flooring
call Random
- cp 40 percent - 2
+ cp 39 percent + 1
jr c, .Happiness
; Try again if length < 1024 mm (i.e. if HIGH(length) < 3 feet)
ld a, [wMagikarpLength]
diff --git a/engine/battle/trainer_huds.asm b/engine/battle/trainer_huds.asm
index bc55c7423..f701a4dfc 100644
--- a/engine/battle/trainer_huds.asm
+++ b/engine/battle/trainer_huds.asm
@@ -225,7 +225,7 @@ LoadBallIconGFX:
ld de, .gfx
ld hl, vTiles0 tile $31
lb bc, BANK(LoadBallIconGFX), 4
- call Get2bpp_2
+ call Get2bppViaHDMA
ret
.gfx
diff --git a/engine/battle_anims/bg_effects.asm b/engine/battle_anims/bg_effects.asm
index 41d87275a..6116056b9 100644
--- a/engine/battle_anims/bg_effects.asm
+++ b/engine/battle_anims/bg_effects.asm
@@ -2606,7 +2606,7 @@ BattleBGEffect_GetNextDMGPal:
BattleBGEffects_ClearLYOverrides:
xor a
BattleBGEffects_SetLYOverrides:
- ld hl, wLYOverrides ; wListPointer
+ ld hl, wLYOverrides
ld e, $99
.loop1
ld [hli], a
diff --git a/engine/events/happiness_egg.asm b/engine/events/happiness_egg.asm
index 1d33edb74..bb2e949cb 100644
--- a/engine/events/happiness_egg.asm
+++ b/engine/events/happiness_egg.asm
@@ -198,7 +198,7 @@ DayCareStep::
callfar CheckBreedmonCompatibility
ld a, [wBreedingCompatibility]
cp 230
- ld b, 32 percent - 1
+ ld b, 31 percent + 1
jr nc, .okay
ld a, [wBreedingCompatibility]
cp 170
diff --git a/engine/events/pokerus/pokerus.asm b/engine/events/pokerus/pokerus.asm
index 63eb7fe10..99a5652cd 100644
--- a/engine/events/pokerus/pokerus.asm
+++ b/engine/events/pokerus/pokerus.asm
@@ -26,8 +26,8 @@ GivePokerusAndConvertBerries:
and a
ret nz
ldh a, [hRandomSub]
- cp $3
- ret nc ; 3/65536 chance (00 00, 00 01 or 00 02)
+ cp 3
+ ret nc ; 3/65536 chance (00 00, 00 01 or 00 02)
ld a, [wPartyCount]
ld b, a
.randomMonSelectLoop
@@ -36,11 +36,11 @@ GivePokerusAndConvertBerries:
cp b
jr nc, .randomMonSelectLoop
ld hl, wPartyMon1PokerusStatus
- call GetPartyLocation ; get pokerus byte of random mon
+ call GetPartyLocation ; get pokerus byte of random mon
ld a, [hl]
and $f0
- ret nz ; if it already has pokerus, do nothing
-.randomPokerusLoop ; Simultaneously sample the strain and duration
+ ret nz ; if it already has pokerus, do nothing
+.randomPokerusLoop ; Simultaneously sample the strain and duration
call Random
and a
jr z, .randomPokerusLoop
@@ -62,20 +62,20 @@ GivePokerusAndConvertBerries:
.TrySpreadPokerus:
call Random
cp 33 percent + 1
- ret nc ; 1/3 chance
+ ret nc ; 1/3 chance
ld a, [wPartyCount]
cp 1
- ret z ; only one mon, nothing to do
+ ret z ; only one mon, nothing to do
ld c, [hl]
ld a, b
cp 2
- jr c, .checkPreviousMonsLoop ; no more mons after this one, go backwards
+ jr c, .checkPreviousMonsLoop ; no more mons after this one, go backwards
call Random
cp 50 percent + 1
- jr c, .checkPreviousMonsLoop ; 1/2 chance, go backwards
+ jr c, .checkPreviousMonsLoop ; 1/2 chance, go backwards
.checkFollowingMonsLoop
add hl, de
ld a, [hl]
@@ -83,8 +83,8 @@ GivePokerusAndConvertBerries:
jr z, .infectMon
ld c, a
and $3
- ret z ; if mon has cured pokerus, stop searching
- dec b ; go on to next mon
+ ret z ; if mon has cured pokerus, stop searching
+ dec b ; go on to next mon
ld a, b
cp 1
jr nz, .checkFollowingMonsLoop ; no more mons left
@@ -93,7 +93,7 @@ GivePokerusAndConvertBerries:
.checkPreviousMonsLoop
ld a, [wPartyCount]
cp b
- ret z ; no more mons
+ ret z ; no more mons
ld a, l
sub e
ld l, a
@@ -105,8 +105,8 @@ GivePokerusAndConvertBerries:
jr z, .infectMon
ld c, a
and $3
- ret z ; if mon has cured pokerus, stop searching
- inc b ; go on to next mon
+ ret z ; if mon has cured pokerus, stop searching
+ inc b ; go on to next mon
jr .checkPreviousMonsLoop
.infectMon
@@ -128,7 +128,7 @@ ConvertBerriesToBerryJuice:
bit STATUSFLAGS2_REACHED_GOLDENROD_F, [hl]
ret z
call Random
- cp 6 percent + 1 ; 1/16 chance
+ cp 1 out_of 16 ; 6.25% chance
ret nc
ld hl, wPartyMons
ld a, [wPartyCount]
diff --git a/engine/games/slot_machine.asm b/engine/games/slot_machine.asm
index eaf7999bd..30f6c45af 100644
--- a/engine/games/slot_machine.asm
+++ b/engine/games/slot_machine.asm
@@ -586,7 +586,7 @@ Slots_StopReel2:
call .CheckReel1ForASeven
jr nz, .dont_jump
call Random
- cp $50 ; 32%
+ cp 31 percent + 1
jr nc, .dont_jump
ld a, REEL_ACTION_SET_UP_REEL2_SKIP_TO_7
ret
@@ -632,20 +632,20 @@ Slots_StopReel3:
and a
jr nz, .biased
call Random
- cp 180
+ cp 71 percent - 1
jr nc, .stop
- cp 120
+ cp 47 percent + 1
jr nc, .slow_advance
- cp 60
+ cp 24 percent - 1
jr nc, .golem
ld a, REEL_ACTION_INIT_CHANSEY
ret
.biased
call Random
- cp 160
+ cp 63 percent
jr nc, .stop
- cp 80
+ cp 31 percent + 1
jr nc, .slow_advance
.golem
ld a, REEL_ACTION_INIT_GOLEM
@@ -1608,7 +1608,7 @@ Slots_GetNumberOfGolems:
.not_biased_to_seven
call Random
and $7
- cp $4 ; ((50 percent) & 7) + 1
+ cp $8 / 2 ; 50%
jr c, .not_biased_to_seven
ld e, a
.loop2
@@ -1649,22 +1649,22 @@ Slots_InitBias:
ret
.Normal:
- db $01, SLOTS_SEVEN ; 1/256
- db $03, SLOTS_POKEBALL ; 1/128
- db $0a, SLOTS_STARYU ; 7/256
- db $14, SLOTS_SQUIRTLE ; 5/128
- db $28, SLOTS_PIKACHU ; 5/64
- db $30, SLOTS_CHERRY ; 1/32
- db $ff, SLOTS_NO_BIAS ; everything else
+ db 1 percent - 1, SLOTS_SEVEN
+ db 1 percent + 1, SLOTS_POKEBALL
+ db 4 percent, SLOTS_STARYU
+ db 8 percent, SLOTS_SQUIRTLE
+ db 16 percent, SLOTS_PIKACHU
+ db 19 percent, SLOTS_CHERRY
+ db 100 percent, SLOTS_NO_BIAS
.Lucky:
- db $02, SLOTS_SEVEN ; 1/128
- db $03, SLOTS_POKEBALL ; 1/256
- db $08, SLOTS_STARYU ; 5/256
- db $10, SLOTS_SQUIRTLE ; 1/32
- db $1e, SLOTS_PIKACHU ; 7/128
- db $50, SLOTS_CHERRY ; 25/128
- db $ff, SLOTS_NO_BIAS ; everything else
+ db 1 percent, SLOTS_SEVEN
+ db 1 percent + 1, SLOTS_POKEBALL
+ db 3 percent + 1, SLOTS_STARYU
+ db 6 percent + 1, SLOTS_SQUIRTLE
+ db 12 percent, SLOTS_PIKACHU
+ db 31 percent + 1, SLOTS_CHERRY
+ db 100 percent, SLOTS_NO_BIAS
Slots_IlluminateBetLights:
ld b, $14 ; turned on
diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm
index 35ad66f7f..0064edfc3 100644
--- a/engine/gfx/color.asm
+++ b/engine/gfx/color.asm
@@ -277,13 +277,13 @@ Unreferenced_Function8bec:
ldh a, [hCGB]
and a
jr nz, .cgb
- ld hl, wPlayerLightScreenCount
+ ld hl, wBetaPokerSGBPals
jp PushSGBPals
.cgb
- ld a, [wEnemyLightScreenCount] ; col
+ ld a, [wBetaPokerSGBCol]
ld c, a
- ld a, [wEnemyReflectCount] ; row
+ ld a, [wBetaPokerSGBRow]
hlcoord 0, 0, wAttrmap
ld de, SCREEN_WIDTH
.loop
@@ -294,10 +294,10 @@ Unreferenced_Function8bec:
jr .loop
.done
- ld b, $0
+ ld b, 0
add hl, bc
lb bc, 6, 4
- ld a, [wEnemySafeguardCount] ; value
+ ld a, [wBetaPokerSGBAttr]
and $3
call FillBoxCGB
call CopyTilemapAtOnce
diff --git a/engine/gfx/dma_transfer.asm b/engine/gfx/dma_transfer.asm
index a3cdb6dd3..f30c5eb45 100644
--- a/engine/gfx/dma_transfer.asm
+++ b/engine/gfx/dma_transfer.asm
@@ -450,7 +450,7 @@ PadMapForHDMATransfer:
ldh [hMapObjectIndexBuffer], a
ret
-_Get2bpp::
+HDMATransfer2bpp::
; 2bpp when [rLCDC] & $80
; switch to WRAM bank 6
ldh a, [rSVBK]
@@ -494,7 +494,7 @@ _Get2bpp::
ldh [rSVBK], a
ret
-_Get1bpp::
+HDMATransfer1bpp::
; 1bpp when [rLCDC] & $80
.loop
ld a, c
diff --git a/engine/gfx/load_font.asm b/engine/gfx/load_font.asm
index db24dced1..bd5e29d52 100644
--- a/engine/gfx/load_font.asm
+++ b/engine/gfx/load_font.asm
@@ -8,13 +8,13 @@ Unreferenced_fb434:
Unreferenced_Functionfb435:
ld a, [Unreferenced_fb434]
and a
- jp nz, Get1bpp_2
+ jp nz, Get1bppViaHDMA
jp Get1bpp
Unreferenced_Functionfb43f:
ld a, [Unreferenced_fb434]
and a
- jp nz, Get2bpp_2
+ jp nz, Get2bppViaHDMA
jp Get2bpp
; End unreferenced block
@@ -29,34 +29,34 @@ _LoadStandardFont::
ld de, Font
ld hl, vTiles1
lb bc, BANK(Font), 32 ; "A" to "]"
- call Get1bpp_2
+ call Get1bppViaHDMA
ld de, Font + 32 * LEN_1BPP_TILE
ld hl, vTiles1 tile $20
lb bc, BANK(Font), 32 ; "a" to $bf
- call Get1bpp_2
+ call Get1bppViaHDMA
ld de, Font + 64 * LEN_1BPP_TILE
ld hl, vTiles1 tile $40
lb bc, BANK(Font), 32 ; "Ä" to "←"
- call Get1bpp_2
+ call Get1bppViaHDMA
ld de, Font + 96 * LEN_1BPP_TILE
ld hl, vTiles1 tile $60
lb bc, BANK(Font), 32 ; "'" to "9"
- call Get1bpp_2
+ call Get1bppViaHDMA
ret
_LoadFontsExtra1::
ld de, FontsExtra_SolidBlackGFX
ld hl, vTiles2 tile "■" ; $60
lb bc, BANK(FontsExtra_SolidBlackGFX), 1
- call Get1bpp_2
+ call Get1bppViaHDMA
ld de, PokegearPhoneIconGFX
ld hl, vTiles2 tile "☎" ; $62
lb bc, BANK(PokegearPhoneIconGFX), 1
- call Get2bpp_2
+ call Get2bppViaHDMA
ld de, FontExtra + 3 tiles ; "<BOLD_D>"
ld hl, vTiles2 tile "<BOLD_D>"
lb bc, BANK(FontExtra), 22 ; "<BOLD_D>" to "ぉ"
- call Get2bpp_2
+ call Get2bppViaHDMA
jr LoadFrame
_LoadFontsExtra2::
@@ -64,14 +64,14 @@ _LoadFontsExtra2::
ld hl, vTiles2 tile "▲" ; $61
ld b, BANK(FontsExtra2_UpArrowGFX)
ld c, 1
- call Get2bpp_2
+ call Get2bppViaHDMA
ret
_LoadFontsBattleExtra::
ld de, FontBattleExtra
ld hl, vTiles2 tile $60
lb bc, BANK(FontBattleExtra), 25
- call Get2bpp_2
+ call Get2bppViaHDMA
jr LoadFrame
LoadFrame:
@@ -84,41 +84,41 @@ LoadFrame:
ld e, l
ld hl, vTiles2 tile "┌" ; $79
lb bc, BANK(Frames), 6 ; "┌" to "┘"
- call Get1bpp_2
+ call Get1bppViaHDMA
ld hl, vTiles2 tile " " ; $7f
ld de, TextboxSpaceGFX
lb bc, BANK(TextboxSpaceGFX), 1
- call Get1bpp_2
+ call Get1bppViaHDMA
ret
LoadBattleFontsHPBar:
ld de, FontBattleExtra
ld hl, vTiles2 tile $60
lb bc, BANK(FontBattleExtra), 12
- call Get2bpp_2
+ call Get2bppViaHDMA
ld hl, vTiles2 tile $70
ld de, FontBattleExtra + 16 tiles ; "<DO>"
lb bc, BANK(FontBattleExtra), 3 ; "<DO>" to "『"
- call Get2bpp_2
+ call Get2bppViaHDMA
call LoadFrame
LoadHPBar:
ld de, EnemyHPBarBorderGFX
ld hl, vTiles2 tile $6c
lb bc, BANK(EnemyHPBarBorderGFX), 4
- call Get1bpp_2
+ call Get1bppViaHDMA
ld de, HPExpBarBorderGFX
ld hl, vTiles2 tile $73
lb bc, BANK(HPExpBarBorderGFX), 6
- call Get1bpp_2
+ call Get1bppViaHDMA
ld de, ExpBarGFX
ld hl, vTiles2 tile $55
lb bc, BANK(ExpBarGFX), 9
- call Get2bpp_2
+ call Get2bppViaHDMA
ld de, MobilePhoneTilesGFX + 7 tiles ; mobile phone icon
ld hl, vTiles2 tile $5e
lb bc, BANK(MobilePhoneTilesGFX), 2
- call Get2bpp_2
+ call Get2bppViaHDMA
ret
StatsScreen_LoadFont:
@@ -126,22 +126,22 @@ StatsScreen_LoadFont:
ld de, EnemyHPBarBorderGFX
ld hl, vTiles2 tile $6c
lb bc, BANK(EnemyHPBarBorderGFX), 4
- call Get1bpp_2
+ call Get1bppViaHDMA
ld de, HPExpBarBorderGFX
ld hl, vTiles2 tile $78
lb bc, BANK(HPExpBarBorderGFX), 1
- call Get1bpp_2
+ call Get1bppViaHDMA
ld de, HPExpBarBorderGFX + 3 * LEN_1BPP_TILE
ld hl, vTiles2 tile $76
lb bc, BANK(HPExpBarBorderGFX), 2
- call Get1bpp_2
+ call Get1bppViaHDMA
ld de, ExpBarGFX
ld hl, vTiles2 tile $55
lb bc, BANK(ExpBarGFX), 8
- call Get2bpp_2
+ call Get2bppViaHDMA
LoadStatsScreenPageTilesGFX:
ld de, StatsScreenPageTilesGFX
ld hl, vTiles2 tile $31
lb bc, BANK(StatsScreenPageTilesGFX), 17
- call Get2bpp_2
+ call Get2bppViaHDMA
ret
diff --git a/engine/gfx/mon_icons.asm b/engine/gfx/mon_icons.asm
index ac25712d1..68e9b1b84 100644
--- a/engine/gfx/mon_icons.asm
+++ b/engine/gfx/mon_icons.asm
@@ -347,7 +347,7 @@ GetGFXUnlessMobile:
ld a, [wLinkMode]
cp LINK_MOBILE
jp nz, Request2bpp
- jp Get2bpp_2
+ jp Get2bppViaHDMA
FreezeMonIcons:
ld hl, wSpriteAnimationStructs
diff --git a/engine/gfx/sgb_layouts.asm b/engine/gfx/sgb_layouts.asm
index a0727c939..f4a523df8 100644
--- a/engine/gfx/sgb_layouts.asm
+++ b/engine/gfx/sgb_layouts.asm
@@ -333,7 +333,7 @@ endr
.SGB_BetaPoker:
ld hl, BlkPacket_9a86
- ld de, wPlayerLightScreenCount ; ???
+ ld de, wBetaPokerSGBPals
ld bc, PALPACKET_LENGTH
call CopyBytes
ld hl, PalPacket_BetaPoker
@@ -547,7 +547,7 @@ endr
ret
.route
- ld a, PREDEFPAL_00
+ ld a, PREDEFPAL_ROUTES
ret
.cave
diff --git a/engine/items/print_item_description.asm b/engine/items/print_item_description.asm
index 5d944e206..999c2075a 100644
--- a/engine/items/print_item_description.asm
+++ b/engine/items/print_item_description.asm
@@ -11,7 +11,7 @@ PrintItemDescription:
pop hl
ld a, [wTempTMHM]
ld [wCurSpecies], a
- predef PrintMoveDesc
+ predef PrintMoveDescription
ret
.not_a_tm
diff --git a/engine/items/tmhm.asm b/engine/items/tmhm.asm
index 736f00cdb..ecc2d45cb 100644
--- a/engine/items/tmhm.asm
+++ b/engine/items/tmhm.asm
@@ -252,7 +252,7 @@ TMHM_ShowTMMoveDescription:
ld a, [wTempTMHM]
ld [wCurSpecies], a
hlcoord 1, 14
- call PrintMoveDesc
+ call PrintMoveDescription
jp TMHM_JoypadLoop
TMHM_ChooseTMorHM:
@@ -417,7 +417,7 @@ TMHM_DisplayPocketItems:
inc hl
inc hl
push de
- ld de, TMHM_String_Cancel
+ ld de, TMHM_CancelString
call PlaceString
pop de
.done
@@ -449,7 +449,7 @@ Unreferenced_Function2ca95:
pop hl
ret
-TMHM_String_Cancel:
+TMHM_CancelString:
db "CANCEL@"
TMHM_GetCurrentPocketPosition:
@@ -472,7 +472,7 @@ TMHM_GetCurrentPocketPosition:
Tutorial_TMHMPocket:
hlcoord 9, 3
push de
- ld de, TMHM_String_Cancel
+ ld de, TMHM_CancelString
call PlaceString
pop de
ret
diff --git a/engine/link/init_list.asm b/engine/link/init_list.asm
index 8557b2e9f..470280c4b 100644
--- a/engine/link/init_list.asm
+++ b/engine/link/init_list.asm
@@ -1,4 +1,5 @@
InitList:
+; This entire function is useless.
ld a, [wInitListType]
cp INIT_ENEMYOT_LIST
diff --git a/engine/link/link.asm b/engine/link/link.asm
index 31c189112..521cfdd8b 100644
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -1571,10 +1571,10 @@ Unreferenced_Function28b42:
ld bc, SCREEN_WIDTH - 2
call ByteFill
hlcoord 2, 16
- ld de, .Cancel
+ ld de, .CancelString
jp PlaceString
-.Cancel:
+.CancelString:
db "CANCEL@"
Function28b68:
diff --git a/engine/link/link_trade.asm b/engine/link/link_trade.asm
index 4119e48a7..14386ae23 100644
--- a/engine/link/link_trade.asm
+++ b/engine/link/link_trade.asm
@@ -115,11 +115,11 @@ InitTradeSpeciesList:
farcall InitMG_Mobile_LinkTradePalMap
farcall PlaceTradePartnerNamesAndParty
hlcoord 10, 17
- ld de, .CANCEL
+ ld de, .CancelString
call PlaceString
ret
-.CANCEL:
+.CancelString:
db "CANCEL@"
_LoadTradeScreenBorder:
diff --git a/engine/link/mystery_gift_2.asm b/engine/link/mystery_gift_2.asm
index b9c7eccb4..9712c665d 100644
--- a/engine/link/mystery_gift_2.asm
+++ b/engine/link/mystery_gift_2.asm
@@ -80,7 +80,7 @@ PrepMysteryGiftDataToSend:
.tenpercent
call Random
- cp 20 percent - 1
+ cp 20 percent - 1 ; 50
jr c, .twopercent
call Random
and %011
diff --git a/engine/menus/menu_2.asm b/engine/menus/menu_2.asm
index 67a93c74f..3c68c2c49 100644
--- a/engine/menus/menu_2.asm
+++ b/engine/menus/menu_2.asm
@@ -110,8 +110,7 @@ CoinString:
ShowMoney_TerminatorString:
db "@"
-Unreferenced_Function24b8f:
-; related to safari?
+Unreferenced_StartMenu_PrintSafariGameStatus:
ld hl, wOptions
ld a, [hl]
push af
diff --git a/engine/menus/savemenu_copytilemapatonce.asm b/engine/menus/savemenu_copytilemapatonce.asm
index 51b7ea8fe..2f30b7c7e 100644
--- a/engine/menus/savemenu_copytilemapatonce.asm
+++ b/engine/menus/savemenu_copytilemapatonce.asm
@@ -3,33 +3,37 @@ SaveMenu_CopyTilemapAtOnce:
and a
jp z, WaitBGMap
-; The following is a modified version of CopyTilemapAtOnce.
+; The following is a modified version of _CopyTilemapAtOnce
+; that waits for [rLY] to be $60 instead of $80 - 1.
ldh a, [hBGMapMode]
push af
xor a
ldh [hBGMapMode], a
+
ldh a, [hMapAnims]
push af
xor a
ldh [hMapAnims], a
-.WaitLY:
+
+.wait
ldh a, [rLY]
cp $60
- jr c, .WaitLY
+ jr c, .wait
di
ld a, BANK(vBGMap2)
ldh [rVBK], a
hlcoord 0, 0, wAttrmap
- call .CopyTilemapAtOnce
+ call .CopyBGMapViaStack
ld a, BANK(vBGMap0)
ldh [rVBK], a
hlcoord 0, 0
- call .CopyTilemapAtOnce
-.WaitLY2:
+ call .CopyBGMapViaStack
+
+.wait2
ldh a, [rLY]
cp $60
- jr c, .WaitLY2
+ jr c, .wait2
ei
pop af
@@ -38,7 +42,8 @@ SaveMenu_CopyTilemapAtOnce:
ldh [hBGMapMode], a
ret
-.CopyTilemapAtOnce:
+.CopyBGMapViaStack:
+; Copy all tiles to vBGMap
ld [hSPBuffer], sp
ld sp, hl
ldh a, [hBGMapAddress + 1]
@@ -46,16 +51,18 @@ SaveMenu_CopyTilemapAtOnce:
ld l, 0
ld a, SCREEN_HEIGHT
ldh [hTilesPerCycle], a
- ld b, 1 << 1
+ ld b, 1 << 1 ; not in v/hblank
ld c, LOW(rSTAT)
.loop
rept SCREEN_WIDTH / 2
pop de
+; if in v/hblank, wait until not in v/hblank
.loop\@
ldh a, [c]
and b
jr nz, .loop\@
+; load vBGMap
ld [hl], e
inc l
ld [hl], d
diff --git a/engine/menus/scrolling_menu.asm b/engine/menus/scrolling_menu.asm
index 6b0572a6d..0574bc730 100644
--- a/engine/menus/scrolling_menu.asm
+++ b/engine/menus/scrolling_menu.asm
@@ -401,11 +401,11 @@ ScrollingMenu_UpdateDisplay:
ld a, [wMenuDataFlags]
bit 0, a ; call function on cancel
jr nz, .call_function
- ld de, .string_2485f
+ ld de, .CancelString
call PlaceString
ret
-.string_2485f
+.CancelString
db "CANCEL@"
.call_function
diff --git a/engine/menus/trainer_card.asm b/engine/menus/trainer_card.asm
index 712032cbe..726148e20 100644
--- a/engine/menus/trainer_card.asm
+++ b/engine/menus/trainer_card.asm
@@ -356,7 +356,8 @@ TrainerCard_InitBorder:
ld a, $23
ld [hli], a
- ld e, SCREEN_HEIGHT - 1
+
+ ld e, SCREEN_WIDTH - 3
ld a, " "
.loop2
ld [hli], a
@@ -367,11 +368,12 @@ TrainerCard_InitBorder:
ld [hli], a
ld a, $23
ld [hli], a
+
.loop3
ld a, $23
ld [hli], a
- ld e, SCREEN_HEIGHT
+ ld e, SCREEN_WIDTH - 2
ld a, " "
.loop4
ld [hli], a
@@ -380,6 +382,7 @@ TrainerCard_InitBorder:
ld a, $23
ld [hli], a
+
dec d
jr nz, .loop3
@@ -388,14 +391,16 @@ TrainerCard_InitBorder:
ld a, $24
ld [hli], a
- ld e, SCREEN_HEIGHT - 1
+ ld e, SCREEN_WIDTH - 3
ld a, " "
.loop5
ld [hli], a
dec e
jr nz, .loop5
+
ld a, $23
ld [hli], a
+
ld e, SCREEN_WIDTH
.loop6
ld a, $23
diff --git a/engine/movie/credits.asm b/engine/movie/credits.asm
index a494d3681..650e056b7 100644
--- a/engine/movie/credits.asm
+++ b/engine/movie/credits.asm
@@ -245,7 +245,7 @@ ParseCredits:
xor a
ldh [hBGMapMode], a
hlcoord 0, 5
- ld bc, 20 * 12
+ ld bc, SCREEN_WIDTH * 12
ld a, " "
call ByteFill
@@ -306,7 +306,7 @@ ParseCredits:
.print
; Print strings spaced every two lines.
call .get
- ld bc, 20 * 2
+ ld bc, SCREEN_WIDTH * 2
call AddNTimes
call PlaceString
jr .loop
diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm
index 3beec6ccb..74ca50d70 100644
--- a/engine/overworld/player_movement.asm
+++ b/engine/overworld/player_movement.asm
@@ -577,11 +577,14 @@ DoPlayerMovement::
; Standing
jr .update
-.d_down add hl, de
-.d_up add hl, de
-.d_left add hl, de
-.d_right add hl, de
-
+.d_down
+ add hl, de
+.d_up
+ add hl, de
+.d_left
+ add hl, de
+.d_right
+ add hl, de
.update
ld a, [hli]
ld [wWalkingDirection], a
diff --git a/engine/overworld/player_object.asm b/engine/overworld/player_object.asm
index 6905c83f0..3446a00c6 100644
--- a/engine/overworld/player_object.asm
+++ b/engine/overworld/player_object.asm
@@ -124,7 +124,7 @@ RefreshPlayerCoords:
ld e, a
; the next three lines are useless
ld a, [wObjectFollow_Leader]
- cp $0
+ cp PLAYER
ret nz
ret
diff --git a/engine/phone/phonering_copytilemapatonce.asm b/engine/phone/phonering_copytilemapatonce.asm
index 0ddb3c852..029c2958c 100644
--- a/engine/phone/phonering_copytilemapatonce.asm
+++ b/engine/phone/phonering_copytilemapatonce.asm
@@ -6,15 +6,18 @@ PhoneRing_CopyTilemapAtOnce:
cp $0
jp z, WaitBGMap
-; What follows is a modified version of CopyTilemapAtOnce.
+; The following is a modified version of _CopyTilemapAtOnce
+; that waits for [rLY] to be LY_VBLANK - 1 instead of $80 - 1.
ldh a, [hBGMapMode]
push af
xor a
ldh [hBGMapMode], a
+
ldh a, [hMapAnims]
push af
xor a
ldh [hMapAnims], a
+
.wait
ldh a, [rLY]
cp LY_VBLANK - 1
@@ -24,11 +27,12 @@ PhoneRing_CopyTilemapAtOnce:
ld a, BANK(vBGMap2)
ldh [rVBK], a
hlcoord 0, 0, wAttrmap
- call .CopyTilemapAtOnce
+ call .CopyBGMapViaStack
ld a, BANK(vBGMap0)
ldh [rVBK], a
hlcoord 0, 0
- call .CopyTilemapAtOnce
+ call .CopyBGMapViaStack
+
.wait2
ldh a, [rLY]
cp LY_VBLANK - 1
@@ -41,7 +45,8 @@ PhoneRing_CopyTilemapAtOnce:
ldh [hBGMapMode], a
ret
-.CopyTilemapAtOnce:
+.CopyBGMapViaStack:
+; Copy all tiles to vBGMap
ld [hSPBuffer], sp
ld sp, hl
ldh a, [hBGMapAddress + 1]
@@ -55,10 +60,12 @@ PhoneRing_CopyTilemapAtOnce:
.loop
rept SCREEN_WIDTH / 2
pop de
+; if in v/hblank, wait until not in v/hblank
.loop\@
ldh a, [c]
and b
jr nz, .loop\@
+; load vBGMap
ld [hl], e
inc l
ld [hl], d
diff --git a/engine/pokedex/pokedex.asm b/engine/pokedex/pokedex.asm
index 6f500bc37..e60ba1450 100644
--- a/engine/pokedex/pokedex.asm
+++ b/engine/pokedex/pokedex.asm
@@ -887,7 +887,7 @@ Pokedex_UnownModeEraseCursor:
Pokedex_UnownModePlaceCursor:
ld a, [wDexCurUnownIndex]
- ld c, $5a ; diamond cursor
+ ld c, FIRST_UNOWN_CHAR + NUM_UNOWN ; diamond cursor
Pokedex_UnownModeUpdateCursorGfx:
ld e, a
@@ -1333,7 +1333,7 @@ endr
ld h, [hl]
ld l, a
pop af
- add $40 - 1 ; Unown A
+ add FIRST_UNOWN_CHAR - 1 ; Unown A
ld [hl], a
inc de
inc b
@@ -2489,7 +2489,7 @@ Pokedex_LoadUnownFont:
ld bc, (NUM_UNOWN + 1) tiles
call Pokedex_InvertTiles
ld de, sScratch + $188
- ld hl, vTiles2 tile $40
+ ld hl, vTiles2 tile FIRST_UNOWN_CHAR
lb bc, BANK(Pokedex_LoadUnownFont), NUM_UNOWN + 1
call Request2bpp
call CloseSRAM
diff --git a/engine/pokemon/mon_menu.asm b/engine/pokemon/mon_menu.asm
index d25d6cc2b..8ffba32bf 100644
--- a/engine/pokemon/mon_menu.asm
+++ b/engine/pokemon/mon_menu.asm
@@ -1214,7 +1214,7 @@ PlaceMoveData:
.description
hlcoord 1, 14
- predef PrintMoveDesc
+ predef PrintMoveDescription
ld a, $1
ldh [hBGMapMode], a
ret
diff --git a/engine/pokemon/party_menu.asm b/engine/pokemon/party_menu.asm
index 12036497d..cf82c38ee 100644
--- a/engine/pokemon/party_menu.asm
+++ b/engine/pokemon/party_menu.asm
@@ -105,11 +105,11 @@ PlacePartyNicknames:
.end
dec hl
dec hl
- ld de, .CANCEL
+ ld de, .CancelString
call PlaceString
ret
-.CANCEL:
+.CancelString:
db "CANCEL@"
PlacePartyHPBar:
diff --git a/engine/pokemon/print_move_description.asm b/engine/pokemon/print_move_description.asm
index c461f2f3d..3647e1c54 100644
--- a/engine/pokemon/print_move_description.asm
+++ b/engine/pokemon/print_move_description.asm
@@ -1,4 +1,4 @@
-PrintMoveDesc:
+PrintMoveDescription:
push hl
ld hl, MoveDescriptions
ld a, [wCurSpecies]
@@ -12,3 +12,5 @@ PrintMoveDesc:
ld d, [hl]
pop hl
jp PlaceString
+
+INCLUDE "data/moves/descriptions.asm"