summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--audio/engine.asm8
-rw-r--r--battle/ai/items.asm4
-rwxr-xr-xbattle/ai/move.asm4
-rw-r--r--battle/ai/scoring.asm52
-rw-r--r--battle/anim_commands.asm6
-rw-r--r--battle/bg_effects.asm8
-rw-r--r--battle/core.asm16
-rw-r--r--battle/effect_commands.asm20
-rwxr-xr-xbattle/trainer_huds.asm8
-rw-r--r--constants/misc_constants.asm2
-rwxr-xr-xengine/buy_sell_toss.asm2
-rwxr-xr-xengine/clock_reset.asm2
-rw-r--r--engine/color.asm16
-rwxr-xr-xengine/crystal_intro.asm12
-rwxr-xr-xengine/debug.asm8
-rw-r--r--engine/events.asm4
-rw-r--r--engine/events_2.asm4
-rwxr-xr-xengine/events_3.asm4
-rwxr-xr-xengine/evolution_animation.asm4
-rw-r--r--engine/fish.asm4
-rw-r--r--engine/fruit_trees.asm4
-rwxr-xr-xengine/healmachineanim.asm4
-rwxr-xr-xengine/link.asm8
-rw-r--r--engine/map_objects.asm4
-rw-r--r--engine/map_setup.asm4
-rwxr-xr-xengine/mart.asm16
-rwxr-xr-xengine/menu.asm4
-rwxr-xr-xengine/mon_icons.asm5
-rwxr-xr-xengine/move_mon.asm4
-rw-r--r--engine/predef.asm12
-rwxr-xr-xengine/printer.asm6
-rw-r--r--engine/scripting.asm12
-rwxr-xr-xengine/search.asm4
-rwxr-xr-xengine/slot_machine.asm12
-rw-r--r--engine/specials.asm4
-rwxr-xr-xengine/sprite_anims.asm8
-rwxr-xr-xengine/sprites.asm8
-rwxr-xr-xengine/startmenu.asm6
-rwxr-xr-xengine/time.asm8
-rw-r--r--engine/timeofdaypals.asm12
-rwxr-xr-xengine/timeset.asm4
-rw-r--r--engine/title.asm4
-rwxr-xr-xengine/tmhm2.asm4
-rwxr-xr-xengine/trainer_card.asm4
-rwxr-xr-xengine/variables.asm4
-rwxr-xr-xengine/warp_connection.asm2
-rwxr-xr-xengine/wildmons.asm12
-rw-r--r--event/battle_tower.asm4
-rwxr-xr-xevent/bug_contest_judging.asm4
-rwxr-xr-xevent/celebi.asm4
-rwxr-xr-xevent/field_moves.asm4
-rwxr-xr-xevent/happiness_egg.asm4
-rwxr-xr-xevent/magnet_train.asm8
-rw-r--r--event/mom.asm4
-rwxr-xr-xevent/special.asm4
-rw-r--r--gfx/pics/animation.asm2
-rw-r--r--home.asm31
-rw-r--r--home/copy.asm4
-rw-r--r--home/fade.asm2
-rw-r--r--home/init.asm17
-rw-r--r--home/map.asm14
-rw-r--r--home/menu.asm26
-rw-r--r--home/movement.asm4
-rw-r--r--home/text.asm10
-rw-r--r--home/window.asm6
-rw-r--r--items/item_effects.asm4
-rw-r--r--lib/mobile/main.asm24
-rw-r--r--main.asm53
-rw-r--r--misc/crystal_misc.asm8
-rwxr-xr-xmisc/gfx_41.asm4
-rwxr-xr-xmisc/mobile_12_2.asm4
-rw-r--r--misc/mobile_22.asm255
-rw-r--r--misc/mobile_22_2.asm105
-rw-r--r--misc/mobile_40.asm8
-rwxr-xr-xmisc/mobile_41.asm16
-rw-r--r--misc/mobile_45.asm12
-rwxr-xr-xmisc/mobile_46.asm4
-rwxr-xr-xmisc/mobile_5c.asm4
-rw-r--r--misc/mobile_5f.asm4
-rwxr-xr-xmisc/mobile_menu.asm4
-rwxr-xr-xmisc/printer_77.asm2
-rw-r--r--misc/unused_title.asm4
-rwxr-xr-xpredef/crystal.asm4
-rw-r--r--predef/sgb.asm4
-rw-r--r--tilesets/animations.asm24
-rwxr-xr-xtrainers/read_party.asm4
86 files changed, 556 insertions, 514 deletions
diff --git a/audio/engine.asm b/audio/engine.asm
index 311b6e760..eecc86e07 100644
--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -2489,9 +2489,9 @@ _PlayCryHeader:: ; e8b79
; 3-byte pointers (bank, address)
ld hl, Cries
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
ld a, [hli]
ld [MusicBank], a
@@ -2708,9 +2708,9 @@ PlayStereoSFX:: ; e8ca6
; get sfx ptr
ld hl, SFX
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
; bank
ld a, [hli]
diff --git a/battle/ai/items.asm b/battle/ai/items.asm
index bd7f2d8d2..ae367c83c 100644
--- a/battle/ai/items.asm
+++ b/battle/ai/items.asm
@@ -196,9 +196,9 @@ AI_TryItem: ; 38105
jr z, .has_item
dec de
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
jr .loop
.has_item
diff --git a/battle/ai/move.asm b/battle/ai/move.asm
index a267cad8c..6e5aca358 100755
--- a/battle/ai/move.asm
+++ b/battle/ai/move.asm
@@ -19,9 +19,9 @@ AIChooseMove: ; 440ce
; The default score is 20. Unusable moves are given a score of 80.
ld a, 20
ld hl, Buffer1
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
; Don't pick disabled moves.
diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm
index 9f568e9fd..3091697e5 100644
--- a/battle/ai/scoring.asm
+++ b/battle/ai/scoring.asm
@@ -596,9 +596,9 @@ AI_Smart_Explosion: ; 388a6
ret c
.asm_388c6
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ret
; 388ca
@@ -610,9 +610,9 @@ AI_Smart_DreamEater: ; 388ca
call Random
cp 25
ret c
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 388d4
@@ -1208,9 +1208,9 @@ AI_Smart_Fly: ; 38b12
call AICompareSpeed
ret nc
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 38b20
@@ -1515,9 +1515,9 @@ AI_Smart_Encore: ; 38c3b
ret
.asm_38c81
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ret
.EncoreMoves:
@@ -1587,15 +1587,15 @@ AI_Smart_SleepTalk: ; 38cba
cp $1
jr z, .asm_38cc7
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
.asm_38cc7
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ret
; 38ccb
@@ -1607,9 +1607,9 @@ AI_Smart_DefrostOpponent: ; 38ccb
ld a, [EnemyMonStatus]
and $20
ret z
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 38cd5
@@ -1708,9 +1708,9 @@ AI_Smart_HealBell: ; 38d1f
jr z, .next
; status
-rept 3
dec hl
-endr
+ dec hl
+ dec hl
ld a, [hl]
or c
ld c, a
@@ -1774,9 +1774,9 @@ AI_Smart_PriorityHit: ; 38d5a
ld a, [BattleMonHP]
sbc b
ret nc
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 38d93
@@ -1900,9 +1900,9 @@ AI_Smart_MeanLook: ; 38dfb
.asm_38e26
call AI_80_20
ret c
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 38e2e
@@ -2233,9 +2233,9 @@ AI_Smart_Endure: ; 38fac
call AI_80_20
ret c
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
.asm_38fcb
@@ -2274,9 +2274,9 @@ AI_Smart_FuryCutter: ; 38fdb
cp 3
jr c, .end
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
.end
@@ -2579,9 +2579,9 @@ AI_Smart_WeatherMove: ; 3910d
; 3911e
AIBadWeatherType: ; 3911e
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ret
; 39122
diff --git a/battle/anim_commands.asm b/battle/anim_commands.asm
index 352dc77a7..957b2a066 100644
--- a/battle/anim_commands.asm
+++ b/battle/anim_commands.asm
@@ -108,7 +108,7 @@ RunBattleAnimScript: ; cc163
call RunBattleAnimCommand
call _ExecuteBGEffects
call BattleAnim_UpdateOAM_All
- call Function3b0c
+ call PushLYOverrides
call BattleAnimRequestPals
; Speed up Rollout's animation.
@@ -265,9 +265,9 @@ BattleAnim_ClearCGB_OAMFlags: ; cc23d
ld a, [hl]
and $f0
ld [hli], a
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
dec c
jr nz, .loop
ret
diff --git a/battle/bg_effects.asm b/battle/bg_effects.asm
index 0aae0c5f3..d3253eb97 100644
--- a/battle/bg_effects.asm
+++ b/battle/bg_effects.asm
@@ -738,9 +738,9 @@ BattleBGEffect_RunPicResizeScript: ; c83ed (32:43ed)
ld l, a
ld a, [wBattleAnimTemp2]
ld h, a
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
ld a, [hl]
cp -1
jr z, .end
@@ -805,9 +805,9 @@ endr
ld e, [hl]
ld d, 0
ld hl, .BGSquares
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
ld a, [hli]
ld b, a
and $f
diff --git a/battle/core.asm b/battle/core.asm
index 91c1fe509..39d4dfaee 100644
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -4080,9 +4080,9 @@ InitBattleMon: ; 3da0d
ld de, BattleMonDVs
ld bc, MON_PKRUS - MON_DVS
call CopyBytes
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld de, BattleMonLevel
ld bc, PARTYMON_STRUCT_LENGTH - MON_LEVEL
call CopyBytes
@@ -4172,9 +4172,9 @@ InitEnemyMon: ; 3dabd
ld de, EnemyMonDVs
ld bc, MON_PKRUS - MON_DVS
call CopyBytes
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld de, EnemyMonLevel
ld bc, PARTYMON_STRUCT_LENGTH - MON_LEVEL
call CopyBytes
@@ -4302,9 +4302,9 @@ rept 4
endr
ld [hl], a
ld hl, PlayerUsedMoves
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
ld [PlayerDisableCount], a
ld [PlayerFuryCutterCount], a
@@ -6637,9 +6637,9 @@ LoadEnemyMon: ; 3e8eb
xor a
ld h, d
ld l, e
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
; Make sure the predef knows this isn't a partymon
ld [MagikarpLength], a
diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm
index 32d247e8c..6cc4db94e 100644
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -3402,9 +3402,9 @@ HitSelfInConfusion: ; 355dd
sla c
rl b
.mimic_screen
-rept 3
dec hl
-endr
+ dec hl
+ dec hl
ld a, [hli]
ld l, [hl]
ld h, a
@@ -3948,9 +3948,9 @@ BattleCommand_Encore: ; 35864
set SUBSTATUS_ENCORED, [hl]
call BattleRandom
and $3
-rept 3
inc a
-endr
+ inc a
+ inc a
ld [de], a
call CheckOpponentWentFirst
jr nz, .finish_move
@@ -4089,12 +4089,12 @@ BattleCommand_PainSplit: ; 35926
ld a, [CurDamage + 1]
rr a
ld [CurDamage + 1], a
-rept 3
inc hl
-endr
-rept 3
+ inc hl
+ inc hl
+ inc de
+ inc de
inc de
-endr
.EnemyShareHP: ; 359ac
ld c, [hl]
@@ -7442,9 +7442,9 @@ BattleCommand_TrapTarget: ; 36c2d
ret nz
call BattleRandom
and 3
-rept 3
inc a
-endr
+ inc a
+ inc a
ld [hl], a
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar
diff --git a/battle/trainer_huds.asm b/battle/trainer_huds.asm
index ad32df1cd..9a72700cc 100755
--- a/battle/trainer_huds.asm
+++ b/battle/trainer_huds.asm
@@ -81,9 +81,9 @@ StageBallTilesData: ; 2c059
jr z, .fainted
.got_hp
-rept 3
dec hl
-endr
+ dec hl
+ dec hl
ld a, [hl]
and a
ld b, $32 ; statused
@@ -92,9 +92,9 @@ endr
jr .load
.fainted
-rept 3
dec hl
-endr
+ dec hl
+ dec hl
.load
ld a, b
diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm
index 41a6f7da0..62581bf47 100644
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -18,10 +18,12 @@ LV_CHAR EQU $6e
; GetName types
PKMN_NAME EQU 1
MOVE_NAME EQU 2
+; dummied out EQU 3
ITEM_NAME EQU 4
PARTY_OT_NAME EQU 5
ENEMY_OT_NAME EQU 6
TRAINER_NAME EQU 7
+; broken ptr EQU 8
; hp
HP_GREEN EQU 0
diff --git a/engine/buy_sell_toss.asm b/engine/buy_sell_toss.asm
index 7f2ad2727..bd18cc83a 100755
--- a/engine/buy_sell_toss.asm
+++ b/engine/buy_sell_toss.asm
@@ -48,7 +48,7 @@ Toss_Sell_Loop: ; 24ff9
; 2500e
BuySellToss_InterpretJoypad: ; 2500e
- call Function354b ; get joypad
+ call JoyTextDelay_ForcehJoyDown ; get joypad
bit B_BUTTON_F, c
jr nz, .b
bit A_BUTTON_F, c
diff --git a/engine/clock_reset.asm b/engine/clock_reset.asm
index 546cc8c13..4e6f588e9 100755
--- a/engine/clock_reset.asm
+++ b/engine/clock_reset.asm
@@ -121,7 +121,7 @@ RestartClock: ; 20021 (8:4021)
; 0x200ba
.joy_loop
- call Function354b
+ call JoyTextDelay_ForcehJoyDown
ld c, a
push af
call .PrintTime
diff --git a/engine/color.asm b/engine/color.asm
index 74d194176..d9961613a 100644
--- a/engine/color.asm
+++ b/engine/color.asm
@@ -405,9 +405,9 @@ LoadStatsScreenPals:
Function8cb4:
ld l, e
ld h, 0
-rept 3
add hl, hl
-endr
+ add hl, hl
+ add hl, hl
ld de, Palettes_8d05
add hl, de
call CheckCGB
@@ -855,9 +855,9 @@ Function97e5:
GetMonPalettePointer:
ld l, a
ld h, $0
-rept 3
add hl, hl
-endr
+ add hl, hl
+ add hl, hl
ld bc, PokemonPalettes
add hl, bc
ret
@@ -1101,9 +1101,9 @@ endr
call SGBDelayCycles
ld a, $30
ld [rJOYP], a
-rept 3
ld a, [rJOYP]
-endr
+ ld a, [rJOYP]
+ ld a, [rJOYP]
call SGBDelayCycles
call SGBDelayCycles
ld a, [rJOYP]
@@ -1946,9 +1946,9 @@ LoadMapPals:
ld a, [MapGroup]
ld l, a
ld h, 0
-rept 3
add hl,hl
-endr
+ add hl,hl
+ add hl,hl
ld de, RoofPals
add hl, de
ld a, [TimeOfDayPal]
diff --git a/engine/crystal_intro.asm b/engine/crystal_intro.asm
index c40062c1a..8dde2fa0a 100755
--- a/engine/crystal_intro.asm
+++ b/engine/crystal_intro.asm
@@ -1655,9 +1655,9 @@ CrystalIntro_InitUnownAnim: ; e51dc (39:51dc)
ret
CrystalIntro_UnownFade: ; e5223 (39:5223)
-rept 3
add a
-endr
+ add a
+ add a
ld e, a
ld d, $0
ld hl, BGPals
@@ -1777,9 +1777,9 @@ Intro_Scene20_AppearUnown: ; e5348 (39:5348)
.got_pointer
ld a, [wcf65]
and $7
-rept 3
add a
-endr
+ add a
+ add a
ld c, a
ld a, [rSVBK]
push af
@@ -1835,9 +1835,9 @@ endr
; e539d
Intro_FadeUnownWordPals: ; e539d (39:539d)
-rept 3
add a
-endr
+ add a
+ add a
ld e, a
ld d, $0
ld hl, BGPals
diff --git a/engine/debug.asm b/engine/debug.asm
index 79d477dc1..78fc52489 100755
--- a/engine/debug.asm
+++ b/engine/debug.asm
@@ -573,9 +573,9 @@ Function81c33: ; 81c33
; 81ca7
Function81ca7: ; 81ca7
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld a, [de]
call Function81cbc
ld a, [de]
@@ -1233,9 +1233,9 @@ Function8220f: ; 8220f
ld a, [wcf64]
ld l, a
ld h, $0
-rept 3
add hl, hl
-endr
+ add hl, hl
+ add hl, hl
ld de, UnknBGPals
add hl, de
ld de, wc608
diff --git a/engine/events.asm b/engine/events.asm
index 3bcac8925..495211141 100644
--- a/engine/events.asm
+++ b/engine/events.asm
@@ -1030,9 +1030,9 @@ DoPlayerEvent: ; 96beb
ld c, a
ld b, 0
ld hl, PlayerEventScriptPointers
-rept 3
add hl, bc
-endr
+ add hl, bc
+ add hl, bc
ld a, [hli]
ld [ScriptBank], a
ld a, [hli]
diff --git a/engine/events_2.asm b/engine/events_2.asm
index 2e7c37c92..af0f8df17 100644
--- a/engine/events_2.asm
+++ b/engine/events_2.asm
@@ -459,9 +459,9 @@ HandleQueuedCommand: ; 97e79
ld e, a
ld d, 0
ld hl, .Jumptable_ba
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
ld a, [hli]
push af
ld a, [hli]
diff --git a/engine/events_3.asm b/engine/events_3.asm
index 1ec8ae986..dfcf60e73 100755
--- a/engine/events_3.asm
+++ b/engine/events_3.asm
@@ -704,9 +704,9 @@ SelectTreeMon: ; b841f
.loop
sub [hl]
jr c, .ok
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
jr .loop
.ok
diff --git a/engine/evolution_animation.asm b/engine/evolution_animation.asm
index 42df7eea4..bc0c0924a 100755
--- a/engine/evolution_animation.asm
+++ b/engine/evolution_animation.asm
@@ -353,9 +353,9 @@ EvolutionAnimation: ; 4e5e1
ld a, [hl]
or b
ld [hli], a
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
dec c
jr nz, .loop6
pop bc
diff --git a/engine/fish.asm b/engine/fish.asm
index e21bab03d..44fe57b25 100644
--- a/engine/fish.asm
+++ b/engine/fish.asm
@@ -50,9 +50,9 @@ endr
cp [hl]
jr z, .ok
jr c, .ok
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
jr .loop
.ok
inc hl
diff --git a/engine/fruit_trees.asm b/engine/fruit_trees.asm
index cbbe5faaf..09619cfa5 100644
--- a/engine/fruit_trees.asm
+++ b/engine/fruit_trees.asm
@@ -66,9 +66,9 @@ PickedFruitTree: ; 4405f
ResetFruitTrees: ; 4406a
xor a
ld hl, FruitTreeFlags
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
ld hl, DailyFlags
set 4, [hl]
diff --git a/engine/healmachineanim.asm b/engine/healmachineanim.asm
index 2b8f3b868..5162b3830 100755
--- a/engine/healmachineanim.asm
+++ b/engine/healmachineanim.asm
@@ -218,9 +218,9 @@ INCBIN "gfx/unknown/0123fc.2bpp"
ld [hld], a
ld a, e
ld [hli], a
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
dec c
jr nz, .palette_loop_2
pop de
diff --git a/engine/link.asm b/engine/link.asm
index 03148abe7..759caecbc 100755
--- a/engine/link.asm
+++ b/engine/link.asm
@@ -579,9 +579,9 @@ FixDataForLinkTransfer: ; 28434
jr nz, .loop2
ld hl, wMisc
ld a, $fd
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld b, $c8
xor a
.loop3
@@ -1213,9 +1213,9 @@ InitTradeMenuDisplay: ; 287e3
callba InitTradeSpeciesList
xor a
ld hl, wOtherPlayerLinkMode
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
ld a, 1
ld [wMenuCursorY], a
diff --git a/engine/map_objects.asm b/engine/map_objects.asm
index 629e87fc7..a78e11f25 100644
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -268,9 +268,9 @@ EndSpriteMovement: ; 467b
ld [hl], a
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
add hl, bc
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a ; OBJECT_30
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
diff --git a/engine/map_setup.asm b/engine/map_setup.asm
index 047f66533..38aaf5fec 100644
--- a/engine/map_setup.asm
+++ b/engine/map_setup.asm
@@ -204,9 +204,9 @@ ReadMapSetupScript: ; 1541d
ld c, a
ld b, 0
ld hl, MapSetupCommands
-rept 3
add hl, bc
-endr
+ add hl, bc
+ add hl, bc
; bank
ld b, [hl]
diff --git a/engine/mart.asm b/engine/mart.asm
index dfe7d89cd..7002902cc 100755
--- a/engine/mart.asm
+++ b/engine/mart.asm
@@ -418,9 +418,9 @@ GetMartDialogGroup: ; 15ca3
ld e, a
ld d, 0
ld hl, .MartTextFunctionPointers
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
ret
; 15cb0
@@ -576,9 +576,9 @@ BargainShopAskPurchaseQuantity:
ld h, [hl]
ld l, a
inc hl
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
inc hl
ld a, [hli]
ld [hMoneyTemp + 2], a
@@ -617,9 +617,9 @@ RooftopSaleAskPurchaseQuantity:
ld h, [hl]
ld l, a
inc hl
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
inc hl
ld e, [hl]
inc hl
@@ -663,9 +663,9 @@ MenuDataHeader_Buy: ; 0x15e18
ld c, a
ld b, 0
ld hl, wMartItem1BCD
-rept 3
add hl, bc
-endr
+ add hl, bc
+ add hl, bc
push de
ld d, h
ld e, l
diff --git a/engine/menu.asm b/engine/menu.asm
index 11c5098e8..e84d8d597 100755
--- a/engine/menu.asm
+++ b/engine/menu.asm
@@ -836,8 +836,8 @@ _InitVerticalMenuCursor:: ; 2446d
ld [hli], a
; wCursorOffCharacter, wCursorCurrentTile
xor a
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ret
; 244c3
diff --git a/engine/mon_icons.asm b/engine/mon_icons.asm
index 4b7f03bfb..0b4b60060 100755
--- a/engine/mon_icons.asm
+++ b/engine/mon_icons.asm
@@ -169,9 +169,10 @@ InitPartyMenuIcon: ; 8e908 (23:6908)
call GetMemIconGFX
ld a, [hObjectStructIndexBuffer]
; y coord
-rept 4
add a
-endr
+ add a
+ add a
+ add a
add $1c
ld d, a
; x coord
diff --git a/engine/move_mon.asm b/engine/move_mon.asm
index 100cb3f0e..55a5b9201 100755
--- a/engine/move_mon.asm
+++ b/engine/move_mon.asm
@@ -1459,9 +1459,9 @@ CalcPkmnStatC: ; e17b
ld a, [hl]
swap a
and $1
-rept 3
add a
-endr
+ add a
+ add a
ld b, a
ld a, [hli]
and $1
diff --git a/engine/predef.asm b/engine/predef.asm
index b028cd9ac..e47cca90a 100644
--- a/engine/predef.asm
+++ b/engine/predef.asm
@@ -12,9 +12,9 @@ GetPredefPointer:: ; 854b
ld e, a
ld d, 0
ld hl, PredefPointers
-rept 3
- add hl,de
-endr
+ add hl, de
+ add hl, de
+ add hl, de
pop de
ld a, [hli]
@@ -64,7 +64,7 @@ PredefPointers:: ; 856b
add_predef CopyPkmnToTempMon
add_predef ListMoves ; $20
add_predef PlaceNonFaintStatus
- add_predef Function50cdb
+ add_predef Predef22
add_predef ListMovePP
add_predef GetGender
add_predef StatsScreenInit
@@ -102,7 +102,7 @@ PredefPointers:: ; 856b
add_predef PlaceStatusString
add_predef LoadMonAnimation
add_predef AnimateFrontpic
- add_predef Functiond0669 ; $48
+ add_predef Predef48 ; $48
add_predef HOF_AnimateFrontpic
- dbw $ff, Function2d43 ; ????
+ dwb $43ff, $2d
; 864c
diff --git a/engine/printer.asm b/engine/printer.asm
index 409c8a461..1762a5b81 100755
--- a/engine/printer.asm
+++ b/engine/printer.asm
@@ -293,9 +293,9 @@ Function841e2: ; 841e2 (21:41e2)
Function841fb: ; 841fb (21:41fb)
xor a
ld hl, wca82
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
ld hl, wca86
ld [hli], a
@@ -1362,7 +1362,7 @@ Function848ed: ; 848ed (21:48ed)
call AddNTimes
ld a, [hl]
pop hl
- call Function383d
+ call PrintLevel_Force3Digits
.ok2
ld hl, wd002
inc [hl]
diff --git a/engine/scripting.asm b/engine/scripting.asm
index d068d8044..076ca3b79 100644
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -1652,9 +1652,9 @@ ScriptCall: ; 974cb
inc [hl]
ld d, $0
ld hl, wScriptStack
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
pop de
ld a, [ScriptBank]
ld [hli], a
@@ -1825,9 +1825,9 @@ StdScript: ; 9757b
call GetScriptByte
ld d, a
ld hl, StdScripts
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
ld a, BANK(StdScripts)
call GetFarByte
ld b, a
@@ -3160,9 +3160,9 @@ ExitScriptSubroutine: ; 97b9a
ld e, [hl]
ld d, $0
ld hl, wScriptStack
-rept 3
add hl,de
-endr
+ add hl,de
+ add hl,de
ld a, [hli]
ld b, a
and " "
diff --git a/engine/search.asm b/engine/search.asm
index 662623296..9543ecfbb 100755
--- a/engine/search.asm
+++ b/engine/search.asm
@@ -117,9 +117,9 @@ CheckOwnMonAnywhere: ; 0x4a721
; Load the box.
ld hl, BoxAddressTable1
ld b, 0
-rept 3
add hl, bc
-endr
+ add hl, bc
+ add hl, bc
ld a, [hli]
call GetSRAMBank
ld a, [hli]
diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm
index c31dbd2b3..626989999 100755
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -201,9 +201,9 @@ Function9282c: ; 9282c
ld a, [hl]
xor $20
ld [hli], a
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
dec c
jr nz, .loop
ret
@@ -686,9 +686,9 @@ Slots_SpinReels: ; 92b0f (24:6b0f)
ld a, [hl]
add d
ld [hli], a
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
dec e
jr nz, .loop
ret
@@ -1844,9 +1844,9 @@ SlotPayoutText: ; 93158 (24:7158)
ld e, a
ld d, 0
ld hl, .PayoutStrings
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
ld de, StringBuffer2
ld bc, 4
call CopyBytes
diff --git a/engine/specials.asm b/engine/specials.asm
index 06d3d2edd..841a59cd3 100644
--- a/engine/specials.asm
+++ b/engine/specials.asm
@@ -2,9 +2,9 @@
Special:: ; c01b
; Run script special de.
ld hl, SpecialsPointers
-rept 3
add hl,de
-endr
+ add hl,de
+ add hl,de
ld b, [hl]
inc hl
ld a, [hli]
diff --git a/engine/sprite_anims.asm b/engine/sprite_anims.asm
index 5addaad5d..1b3f720c9 100755
--- a/engine/sprite_anims.asm
+++ b/engine/sprite_anims.asm
@@ -630,9 +630,9 @@ DoAnimFrame: ; 8d24b
ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
push af
push de
call .Sprites_Sine
@@ -807,9 +807,9 @@ endr
ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
ld d, [hl]
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
diff --git a/engine/sprites.asm b/engine/sprites.asm
index b88c2a8ed..74a56a38c 100755
--- a/engine/sprites.asm
+++ b/engine/sprites.asm
@@ -154,9 +154,9 @@ InitSpriteAnimStruct:: ; 8cfd6
ld e, a
ld d, 0
ld hl, SpriteAnimSeqData
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
ld e, l
ld d, h
; Set hl to the first field (field 0) in the current structure.
@@ -521,9 +521,9 @@ GetFrameOAMPointer: ; 8d1a2
ld e, a
ld d, 0
ld hl, SpriteAnimOAMData
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
ret
; 8d1ac
diff --git a/engine/startmenu.asm b/engine/startmenu.asm
index 68ac65e12..f289e4184 100755
--- a/engine/startmenu.asm
+++ b/engine/startmenu.asm
@@ -19,9 +19,9 @@ StartMenu:: ; 125cd
ld a, [wd0d2]
ld [wMenuCursorBuffer], a
call .DrawMenuAccount_
- call MenuFunc_1e7f
+ call DrawVariableLengthMenuBox
call .DrawBugContestStatusBox
- call Function2e31
+ call SafeUpdateSprites
call _OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
callba LoadFonts_NoOAMUpdate
call .DrawBugContestStatus
@@ -142,7 +142,7 @@ StartMenu:: ; 125cd
call Call_ExitMenu
call ReloadTilesetAndPalettes
call .DrawMenuAccount_
- call MenuFunc_1e7f
+ call DrawVariableLengthMenuBox
call .DrawBugContestStatus
call UpdateSprites
call ret_d90
diff --git a/engine/time.asm b/engine/time.asm
index 8ea807972..2112ec35c 100755
--- a/engine/time.asm
+++ b/engine/time.asm
@@ -102,9 +102,9 @@ CheckDailyResetTimer:: ; 11452
ret nc
xor a
ld hl, DailyFlags
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
ld hl, wDailyRematchFlags
rept 4
@@ -381,9 +381,9 @@ CalcMinsHoursDaysSince: ; 115d6
; 115db
CalcSecsMinsHoursDaysSince: ; 115db
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld a, [hSeconds]
ld c, a
sub [hl]
diff --git a/engine/timeofdaypals.asm b/engine/timeofdaypals.asm
index 3bba41f53..e9b19c6f7 100644
--- a/engine/timeofdaypals.asm
+++ b/engine/timeofdaypals.asm
@@ -140,9 +140,9 @@ Special_BattleTowerFade: ; 8c092
ld b, $4
.asm_8c09c
call DmgToCgbTimePals
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld c, $7
call DelayFrames
dec b
@@ -304,9 +304,9 @@ DmgToCgbTimePals: ; 8c14e
ConvertTimePalsIncHL: ; 8c15e
.loop
call DmgToCgbTimePals
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld c, 2
call DelayFrames
dec b
@@ -317,9 +317,9 @@ endr
ConvertTimePalsDecHL: ; 8c16d
.loop
call DmgToCgbTimePals
-rept 3
dec hl
-endr
+ dec hl
+ dec hl
ld c, 2
call DelayFrames
dec b
diff --git a/engine/timeset.asm b/engine/timeset.asm
index b21e62ea1..0abb7e88c 100755
--- a/engine/timeset.asm
+++ b/engine/timeset.asm
@@ -215,9 +215,9 @@ UnreferencedFunction907f1: ; 907f1
ld [hl], a
pop hl
call DisplayMinutesWithMinString
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ret
; 90810
diff --git a/engine/title.asm b/engine/title.asm
index 31fbe091e..012242491 100644
--- a/engine/title.asm
+++ b/engine/title.asm
@@ -377,9 +377,9 @@ AnimateTitleCrystal: ; 10ef32
ld a, [hl]
add 2
ld [hli], a
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
dec c
jr nz, .loop
diff --git a/engine/tmhm2.asm b/engine/tmhm2.asm
index 7062149f8..6efd07294 100755
--- a/engine/tmhm2.asm
+++ b/engine/tmhm2.asm
@@ -423,9 +423,9 @@ TMHM_DisplayPocketItems: ; 2c9e2 (b:49e2)
.NotTMHM:
call TMHMPocket_GetCurrentLineCoord
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
push de
ld de, TMHM_String_Cancel
call PlaceString
diff --git a/engine/trainer_card.asm b/engine/trainer_card.asm
index b6fac7f7c..a993ce4ba 100755
--- a/engine/trainer_card.asm
+++ b/engine/trainer_card.asm
@@ -62,9 +62,9 @@ TrainerCard: ; 25105
call WaitBGMap
ld hl, wJumptableIndex
xor a
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
ret
diff --git a/engine/variables.asm b/engine/variables.asm
index 3ddfce8d6..fde2583b7 100755
--- a/engine/variables.asm
+++ b/engine/variables.asm
@@ -7,9 +7,9 @@ _GetVarAction:: ; 80648 (20:4648)
ld c, a
ld b, 0
ld hl, .VarActionTable
-rept 3
add hl, bc
-endr
+ add hl, bc
+ add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
diff --git a/engine/warp_connection.asm b/engine/warp_connection.asm
index 084343a33..515edce40 100755
--- a/engine/warp_connection.asm
+++ b/engine/warp_connection.asm
@@ -326,7 +326,7 @@ RefreshMapSprites: ; 1047f0
jr nz, .skip
ld hl, VramState
set 0, [hl]
- call Function2e31
+ call SafeUpdateSprites
.skip
ld a, [wPlayerSpriteSetupFlags]
and %00011100
diff --git a/engine/wildmons.asm b/engine/wildmons.asm
index 557630686..6208cfbce 100755
--- a/engine/wildmons.asm
+++ b/engine/wildmons.asm
@@ -62,9 +62,9 @@ FindNest: ; 2a01f
ld b, a
ld a, [hli]
ld c, a
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld a, NUM_WILDMONS_PER_AREA_TIME_OF_DAY * 3
call .SearchMapForMon
jr nc, .next_grass
@@ -267,9 +267,9 @@ ChooseWildEncounter: ; 2a14f
call CheckEncounterRoamMon
jp c, .startwildbattle
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
call CheckOnWater
ld de, .WaterMonTable
jr z, .watermon
@@ -595,9 +595,9 @@ CheckEncounterRoamMon: ; 2a2ce
cp [hl]
jr nz, .DontEncounterRoamMon
; We've decided to take on a beast, so stage its information for battle.
-rept 3
dec hl
-endr
+ dec hl
+ dec hl
ld a, [hli]
ld [TempWildMonSpecies], a
ld a, [hl]
diff --git a/event/battle_tower.asm b/event/battle_tower.asm
index 0f4117c01..de6022145 100644
--- a/event/battle_tower.asm
+++ b/event/battle_tower.asm
@@ -157,9 +157,9 @@ BattleTower_ExecuteJumptable: ; 8b25b
; 8b281
.GetTextPointers: ; 8b281
-rept 3
inc de
-endr
+ inc de
+ inc de
ld a, [de]
ld l, a
inc de
diff --git a/event/bug_contest_judging.asm b/event/bug_contest_judging.asm
index be66b6ba0..1ece896d6 100755
--- a/event/bug_contest_judging.asm
+++ b/event/bug_contest_judging.asm
@@ -340,9 +340,9 @@ ComputeAIContestantScores: ; 138b0
jr z, .loop2
ld c, a
ld b, 0
-rept 3
add hl, bc
-endr
+ add hl, bc
+ add hl, bc
ld a, [hli]
ld [wBugContestTempMon], a
ld a, [hli]
diff --git a/event/celebi.asm b/event/celebi.asm
index 2c2f6e57b..05f26fe2e 100755
--- a/event/celebi.asm
+++ b/event/celebi.asm
@@ -55,9 +55,9 @@ Special_CelebiShrineEvent: ; 4989a
ld c, $4
.OAMloop:
ld [hli], a
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
inc a
dec c
jr nz, .OAMloop
diff --git a/event/field_moves.asm b/event/field_moves.asm
index 1218a6f11..c1b3bc236 100755
--- a/event/field_moves.asm
+++ b/event/field_moves.asm
@@ -398,9 +398,9 @@ FlyToAnim: ; 8cb33
ld c, $4
.loop2
ld [hli], a
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
inc a
dec c
jr nz, .loop2
diff --git a/event/happiness_egg.asm b/event/happiness_egg.asm
index 1e8c2a853..e7eece7c8 100755
--- a/event/happiness_egg.asm
+++ b/event/happiness_egg.asm
@@ -67,9 +67,9 @@ ChangeHappiness: ; 71c2
dec c
ld b, 0
ld hl, .Actions
-rept 3
add hl, bc
-endr
+ add hl, bc
+ add hl, bc
ld d, 0
add hl, de
ld a, [hl]
diff --git a/event/magnet_train.asm b/event/magnet_train.asm
index 001352ce0..84b420f2f 100755
--- a/event/magnet_train.asm
+++ b/event/magnet_train.asm
@@ -48,7 +48,7 @@ Special_MagnetTrain: ; 8cc04
callab PlaySpriteAnimations
call MagnetTrain_Jumptable
call MagnetTrain_UpdateLYOverrides
- call Function3b0c
+ call PushLYOverrides
call DelayFrame
jr .loop
@@ -149,9 +149,9 @@ MagntTrain_LoadGFX_PlayMusic: ; 8ccc9
xor a
ld [hli], a
ld a, [wMagnetTrainInitPosition]
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld de, MUSIC_MAGNET_TRAIN
call PlayMusic2
ret
@@ -426,7 +426,7 @@ MagnetTrain_Jumptable_FirstRunThrough: ; 8ceae
callba PlaySpriteAnimations
call MagnetTrain_Jumptable
call MagnetTrain_UpdateLYOverrides
- call Function3b0c
+ call PushLYOverrides
call DelayFrame
ld a, [rSVBK]
push af
diff --git a/event/mom.asm b/event/mom.asm
index 0a1e7d1ae..70f22d6a1 100644
--- a/event/mom.asm
+++ b/event/mom.asm
@@ -588,9 +588,9 @@ Function16571: ; 16571
push de
ld e, a
ld d, 0
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
pop de
ret
; 16613
diff --git a/event/special.asm b/event/special.asm
index c5ddabbcf..f1228abc6 100755
--- a/event/special.asm
+++ b/event/special.asm
@@ -188,9 +188,9 @@ MassageOrHaircut: ; 7420
.loop
sub [hl]
jr c, .ok
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
jr .loop
.ok
diff --git a/gfx/pics/animation.asm b/gfx/pics/animation.asm
index 5dd376b9e..8392f2a12 100644
--- a/gfx/pics/animation.asm
+++ b/gfx/pics/animation.asm
@@ -1109,7 +1109,7 @@ PokeAnim_GetSpeciesOrUnown: ; d065c
ret
; d0669
-Functiond0669: ; d0669 Predef 48
+Predef48: ; d0669 Predef 48
ld a, $1
ld [wBoxAlignment], a
diff --git a/home.asm b/home.asm
index ef3d1fde2..46247aaab 100644
--- a/home.asm
+++ b/home.asm
@@ -798,12 +798,7 @@ NamesPointers:: ; 33ab
dbw 0, PartyMonOT
dbw 0, OTPartyMonOT
dba TrainerClassNames
-; 33c0
-
-Function33c0:
- inc b
- ld d, d
- ld c, e
+ dbw $4, $4b52 ; within PackMenuGFX
; 33c3
GetName:: ; 33c3
@@ -834,9 +829,9 @@ GetName:: ; 33c3
ld e, a
ld d, 0
ld hl, NamesPointers
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
ld a, [hli]
rst Bankswitch
ld a, [hli]
@@ -1142,7 +1137,7 @@ InitScrollingMenu:: ; 352f
jp TextBox
; 354b
-Function354b:: ; 354b joypad
+JoyTextDelay_ForcehJoyDown:: ; 354b joypad
call DelayFrame
ld a, [hInMenu]
@@ -1692,22 +1687,22 @@ PrintLevel:: ; 382d
; How many digits?
ld c, 2
cp 100
- jr c, Function3842
+ jr c, Print8BitNumRightAlign
; 3-digit numbers overwrite the :L.
dec hl
inc c
- jr Function3842
+ jr Print8BitNumRightAlign
; 383d
-Function383d:: ; 383d
+PrintLevel_Force3Digits:: ; 383d
; Print :L and all 3 digits
ld [hl], "<LV>"
inc hl
ld c, 3
; 3842
-Function3842:: ; 3842
+Print8BitNumRightAlign:: ; 3842
ld [wd265], a
ld de, wd265
ld b, PRINTNUM_RIGHTALIGN | 1
@@ -1715,6 +1710,8 @@ Function3842:: ; 3842
; 384d
Function384d:: ; 384d
+; XXX
+; GetNthMove
ld hl, wListMoves_MoveIndicesBuffer
ld c, a
ld b, 0
@@ -1907,13 +1904,17 @@ GetPartyLocation:: ; 3927
; 392d
Function392d:: ; 392d
+; XXX
+; GetDexNumber
+; Probably used in gen 1 to convert index number to dex number
+; Not required in gen 2 because index number == dex number
push hl
ld a, b
dec a
ld b, 0
add hl, bc
ld hl, BaseData + 0
- ld bc, $0020
+ ld bc, BaseData1 - BaseData0
call AddNTimes
ld a, BANK(BaseData)
call GetFarHalfword
@@ -1925,7 +1926,7 @@ Function392d:: ; 392d
INCLUDE "home/battle.asm"
-Function3b0c:: ; 3b0c
+PushLYOverrides:: ; 3b0c
ld a, [hFFC6]
and a
diff --git a/home/copy.asm b/home/copy.asm
index 183a19811..bf2dee3fb 100644
--- a/home/copy.asm
+++ b/home/copy.asm
@@ -421,9 +421,9 @@ Copy1bpp:: ; fa4
push af
ld h, 0
ld l, c
-rept 3
add hl, hl
-endr
+ add hl, hl
+ add hl, hl
ld b, h
ld c, l
pop af
diff --git a/home/fade.asm b/home/fade.asm
index 579a4125a..c5eb2c2eb 100644
--- a/home/fade.asm
+++ b/home/fade.asm
@@ -2,6 +2,8 @@
Function48c:: ; 48c
+; XXX
+; TimeOfDayFade
ld a, [TimeOfDayPal]
ld b, a
ld hl, IncGradGBPalTable_11
diff --git a/home/init.asm b/home/init.asm
index 69a709769..a479b4b5f 100644
--- a/home/init.asm
+++ b/home/init.asm
@@ -100,7 +100,7 @@ Init:: ; 17d
ld [rSVBK], a
call ClearVRAM
call ClearSprites
- call Function270
+ call ClearsScratch
ld a, BANK(LoadPushOAM)
@@ -194,9 +194,10 @@ ClearVRAM:: ; 245
ClearWRAM:: ; 25a
; Wipe swappable WRAM banks (1-7)
+; Assumes CGB or AGB
ld a, 1
-.asm_25c
+.bank_loop
push af
ld [rSVBK], a
xor a
@@ -206,15 +207,17 @@ ClearWRAM:: ; 25a
pop af
inc a
cp 8
- jr nc, .asm_25c
+ jr nc, .bank_loop
ret
; 270
-Function270:: ; 270
- ld a, $0
+ClearsScratch:: ; 270
+; Wipe the first 32 bytes of sScratch
+
+ ld a, BANK(sScratch)
call GetSRAMBank
- ld hl, $a000
- ld bc, $0020
+ ld hl, sScratch
+ ld bc, $20
xor a
call ByteFill
call CloseSRAM
diff --git a/home/map.asm b/home/map.asm
index 96eae7d37..7f15afc96 100644
--- a/home/map.asm
+++ b/home/map.asm
@@ -155,9 +155,9 @@ LoadMetatiles:: ; 2198
add a
ld l, a
ld h, 0
-rept 3
add hl, hl
-endr
+ add hl, hl
+ add hl, hl
ld a, [TilesetBlocksAddress]
add l
ld l, a
@@ -694,9 +694,9 @@ RestoreFacingAfterWarp:: ; 248a
ld a, [hli]
ld h, [hl]
ld l, a
-rept 3
inc hl ; get to the warp coords
-endr
+ inc hl ; get to the warp coords
+ inc hl ; get to the warp coords
ld a, [WarpNumber]
dec a
ld c, a
@@ -751,9 +751,9 @@ ChangeMap:: ; 24e4
ld [hConnectionStripLength], a
ld c, a
ld b, 0
-rept 3
add hl, bc
-endr
+ add hl, bc
+ add hl, bc
ld c, 3
add hl, bc
ld a, [MapBlockDataBank]
@@ -1072,7 +1072,7 @@ MapTextbox:: ; 269a
push hl
call SpeechTextBox
- call Function2e31
+ call SafeUpdateSprites
ld a, 1
ld [hOAMUpdate], a
call ApplyTilemap
diff --git a/home/menu.asm b/home/menu.asm
index b7755de08..563ee9f99 100644
--- a/home/menu.asm
+++ b/home/menu.asm
@@ -229,9 +229,9 @@ _OffsetMenuDataHeader:: ; 1e35
; 1e5d
DoNthMenu:: ; 1e5d
- call MenuFunc_1e7f
+ call DrawVariableLengthMenuBox
call MenuWriteText
- call Function1eff
+ call InitMenuCursorAndButtonPermissions
call GetStaticMenuJoypad
call GetMenuJoypad
call MenuClickSound
@@ -239,17 +239,17 @@ DoNthMenu:: ; 1e5d
; 1e70
SetUpMenu:: ; 1e70
- call MenuFunc_1e7f ; ???
+ call DrawVariableLengthMenuBox ; ???
call MenuWriteText
- call Function1eff ; set up selection pointer
+ call InitMenuCursorAndButtonPermissions ; set up selection pointer
ld hl, w2DMenuFlags1
set 7, [hl]
ret
-MenuFunc_1e7f::
+DrawVariableLengthMenuBox::
call CopyMenuData2
call GetMenuIndexSet
- call Function1ea6
+ call AutomaticGetMenuBottomCoord
call MenuBox
ret
@@ -257,8 +257,8 @@ MenuWriteText::
xor a
ld [hBGMapMode], a
call GetMenuIndexSet ; sort out the text
- call Function1eda ; actually write it
- call Function2e31
+ call RunMenuItemPrintingFunction ; actually write it
+ call SafeUpdateSprites
ld a, [hOAMUpdate]
push af
ld a, $1
@@ -269,7 +269,7 @@ MenuWriteText::
ret
; 0x1ea6
-Function1ea6:: ; 1ea6
+AutomaticGetMenuBottomCoord:: ; 1ea6
ld a, [wMenuBorderLeftCoord]
ld c, a
ld a, [wMenuBorderRightCoord]
@@ -310,7 +310,7 @@ GetMenuIndexSet:: ; 1ebd
ret
; 1eda
-Function1eda:: ; 1eda
+RunMenuItemPrintingFunction:: ; 1eda
call MenuBoxCoord2Tile
ld bc, 2 * SCREEN_WIDTH + 2
add hl, bc
@@ -325,7 +325,7 @@ Function1eda:: ; 1eda
ld d, h
ld e, l
ld hl, wMenuData2DisplayFunctionPointer
- call .__wMenuData2DisplayFunction__
+ call ._hl_
pop hl
ld de, 2 * SCREEN_WIDTH
add hl, de
@@ -333,14 +333,14 @@ Function1eda:: ; 1eda
jr .loop
; 1efb
-.__wMenuData2DisplayFunction__ ; 1efb
+._hl_ ; 1efb
ld a, [hli]
ld h, [hl]
ld l, a
jp [hl]
; 1eff
-Function1eff:: ; 1eff
+InitMenuCursorAndButtonPermissions:: ; 1eff
call InitVerticalMenuCursor
ld hl, wMenuJoypadFilter
ld a, [wMenuData2Flags]
diff --git a/home/movement.asm b/home/movement.asm
index 8471e81ca..c7f785f09 100644
--- a/home/movement.asm
+++ b/home/movement.asm
@@ -150,9 +150,9 @@ SetMenuAttributes:: ; 1bb1
ld [hli], a
ld [hli], a
xor a
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
pop bc
pop hl
ret
diff --git a/home/text.asm b/home/text.asm
index 08b3f3660..a5ddf43c9 100644
--- a/home/text.asm
+++ b/home/text.asm
@@ -525,7 +525,7 @@ Paragraph:: ; 12f2
call LoadBlinkingCursor
.linkbattle
- call Function13b6
+ call Text_WaitBGMap
call ButtonSound
hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY
lb bc, TEXTBOX_INNERH - 1, TEXTBOX_INNERW
@@ -546,7 +546,7 @@ Char4B:: ; 131f
call LoadBlinkingCursor
.communication
- call Function13b6
+ call Text_WaitBGMap
push de
call ButtonSound
@@ -598,7 +598,7 @@ PromptText:: ; 135a
call LoadBlinkingCursor
.ok
- call Function13b6
+ call Text_WaitBGMap
call ButtonSound
ld a, [wLinkMode]
cp LINK_COLOSSEUM
@@ -655,7 +655,7 @@ TextScroll:: ; 138c
ret
; 13b6
-Function13b6:: ; 13b6
+Text_WaitBGMap:: ; 13b6
push bc
ld a, [hOAMUpdate]
push af
@@ -1029,6 +1029,8 @@ Text_PlaySound:: ; 1500
; 1522
Function1522:: ; 1522
+; XXX
+; TX_CRY
push de
ld e, [hl]
inc hl
diff --git a/home/window.asm b/home/window.asm
index 5922905a9..5832f1f94 100644
--- a/home/window.asm
+++ b/home/window.asm
@@ -39,7 +39,7 @@ CloseText:: ; 2dcf
call _OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
xor a
ld [hBGMapMode], a
- call Function2e31
+ call SafeUpdateSprites
ld a, $90
ld [hWY], a
call ReplaceKrisSprite
@@ -78,7 +78,7 @@ _OpenAndCloseMenu_HDMATransferTileMapAndAttrMap:: ; 2e20
ret
; 2e31
-Function2e31:: ; 2e31
+SafeUpdateSprites:: ; 2e31
ld a, [hOAMUpdate]
push af
ld a, [hBGMapMode]
@@ -87,7 +87,9 @@ Function2e31:: ; 2e31
ld [hBGMapMode], a
ld a, $1
ld [hOAMUpdate], a
+
call UpdateSprites
+
xor a
ld [hOAMUpdate], a
call DelayFrame
diff --git a/items/item_effects.asm b/items/item_effects.asm
index 7fde473ab..6f58524d6 100644
--- a/items/item_effects.asm
+++ b/items/item_effects.asm
@@ -937,9 +937,9 @@ GLOBAL EvosAttacksPointers
pop bc
ret nz
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
; Moon Stone's constant from Pokémon Red is used.
; No Pokémon evolve with Burn Heal,
diff --git a/lib/mobile/main.asm b/lib/mobile/main.asm
index 248763093..0261bc564 100644
--- a/lib/mobile/main.asm
+++ b/lib/mobile/main.asm
@@ -745,9 +745,9 @@ Function110438: ; 110438
ld a, $c8
ld [hli], a
xor a
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
ld a, $ff
ld [$c86e], a
@@ -968,9 +968,9 @@ Function1105dd: ; 1105dd
ld a, $c8
ld [hli], a
xor a
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
ld a, $ff
ld [$c86e], a
@@ -2274,9 +2274,9 @@ Function110ddd: ; 110ddd
.asm_110ee3
ld hl, $c98b
xor a
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
pop bc
pop de
@@ -3081,9 +3081,9 @@ Function1113fe: ; 1113fe
push hl
ld hl, $c829
xor a
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
ld de, $cb47
ld hl, Unknown_112072
@@ -3578,9 +3578,9 @@ _MobileReceive:: ; 1116c5 (44:56c5)
ld [$c800], a
xor a
ld hl, $c80a
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld hl, $c81f
ld a, [hli]
ld b, a
@@ -9143,9 +9143,9 @@ Function113c8e: ; 113c8e
ld bc, $0003
.asm_113ccf
-rept 3
dec bc
-endr
+ dec bc
+ dec bc
ld a, c
ld [$cc10], a
ld a, b
diff --git a/main.asm b/main.asm
index 78e118cde..b994433d8 100644
--- a/main.asm
+++ b/main.asm
@@ -127,7 +127,7 @@ LoadFonts_NoOAMUpdate:: ; 64bf
call LoadFontsExtra
ld a, $90
ld [hWY], a
- call Function2e31
+ call SafeUpdateSprites
call LoadStandardFont
ret
@@ -933,8 +933,8 @@ StartMenu_PrintBugContestStatus: ; 24be7
ld h, b
ld l, c
inc hl
- ld c, $3
- call Function3842
+ ld c, 3
+ call Print8BitNumRightAlign
.skip_level
pop af
@@ -1517,9 +1517,9 @@ ClearBattleRAM: ; 2ef18
ld [wBattleResult], a
ld hl, wPartyMenuCursor
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
ld [wMenuScrollPosition], a
@@ -2782,9 +2782,9 @@ Special_CheckForLuckyNumberWinners: ; 4d87a
jr z, .SkipBox
ld hl, .BoxBankAddresses
ld b, 0
-rept 3
add hl, bc
-endr
+ add hl, bc
+ add hl, bc
ld a, [hli]
call GetSRAMBank
ld a, [hli]
@@ -3505,7 +3505,7 @@ CheckBattleScene: ; 4ea44
.mobile
ld a, [wcd2f]
and a
- jr nz, .asm_4ea72
+ jr nz, .from_wram
ld a, $4
call GetSRAMBank
@@ -3520,7 +3520,7 @@ CheckBattleScene: ; 4ea44
and a
ret
-.asm_4ea72
+.from_wram
ld a, $5
ld hl, w5_dc00
call GetFarWRAMByte
@@ -3782,9 +3782,10 @@ DrawHP: ; 50b10
ld [wWhichHPBar], a
push hl
push bc
+ ; box mons have full HP
ld a, [MonType]
cp BOXMON
- jr z, .asm_50b30
+ jr z, .at_least_1_hp
ld a, [TempMonHP]
ld b, a
@@ -3793,34 +3794,34 @@ DrawHP: ; 50b10
; Any HP?
or b
- jr nz, .asm_50b30
+ jr nz, .at_least_1_hp
xor a
ld c, a
ld e, a
ld a, 6
ld d, a
- jp .asm_50b4a
+ jp .fainted
-.asm_50b30
+.at_least_1_hp
ld a, [TempMonMaxHP]
ld d, a
ld a, [TempMonMaxHP + 1]
ld e, a
ld a, [MonType]
cp BOXMON
- jr nz, .asm_50b41
+ jr nz, .not_boxmon
ld b, d
ld c, e
-.asm_50b41
+.not_boxmon
predef ComputeHPBarPixels
ld a, 6
ld d, a
ld c, a
-.asm_50b4a
+.fainted
ld a, c
pop bc
ld c, a
@@ -3832,14 +3833,14 @@ DrawHP: ; 50b10
pop hl
; Print HP
- ld bc, $15 ; move (1,1)
+ bccoord 1, 1, 0
add hl, bc
ld de, TempMonHP
ld a, [MonType]
cp BOXMON
- jr nz, .asm_50b66
+ jr nz, .not_boxmon_2
ld de, TempMonMaxHP
-.asm_50b66
+.not_boxmon_2
lb bc, 2, 3
call PrintNum
@@ -4029,9 +4030,9 @@ ListMovePP: ; 50c50
.skip
pop hl
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld d, h
ld e, l
ld hl, TempMonMoves
@@ -4108,7 +4109,7 @@ Function50cd0: ; 50cd0
jr nz, .loop
ret
-Function50cdb: ; unreferenced predef
+Predef22: ; unreferenced predef
push hl
push hl
ld hl, PartyMonNicknames
@@ -5659,19 +5660,19 @@ String_PM: db "PM@" ; 1dd6ff
INCLUDE "engine/diploma.asm"
LoadSGBPokedexGFX: ; 1ddf1c
- ld hl, LZ_1ddf33
+ ld hl, SGBPokedexGFX_LZ
ld de, VTiles2 tile $31
call Decompress
ret
LoadSGBPokedexGFX2: ; 1ddf26 (77:5f26)
- ld hl, LZ_1ddf33
+ ld hl, SGBPokedexGFX_LZ
ld de, VTiles2 tile $31
- lb bc, BANK(LZ_1ddf33), $3a
+ lb bc, BANK(SGBPokedexGFX_LZ), $3a
call DecompressRequest2bpp
ret
-LZ_1ddf33: ; 1ddf33
+SGBPokedexGFX_LZ: ; 1ddf33
INCBIN "gfx/pokedex/sgb.2bpp.lz"
LoadQuestionMarkPic: ; 1de0d7
diff --git a/misc/crystal_misc.asm b/misc/crystal_misc.asm
index 296e59305..66f0a92ae 100644
--- a/misc/crystal_misc.asm
+++ b/misc/crystal_misc.asm
@@ -576,16 +576,16 @@ Function17aa22: ; 17aa22 (5e:6a22)
push de
ld a, $3
call Function17aae0
-rept 3
add a
-endr
+ add a
+ add a
add $0
push af
ld a, $4
call Function17aae0
-rept 3
add a
-endr
+ add a
+ add a
add $8
ld c, a
pop af
diff --git a/misc/gfx_41.asm b/misc/gfx_41.asm
index 691ee7099..e3a1a0375 100755
--- a/misc/gfx_41.asm
+++ b/misc/gfx_41.asm
@@ -550,9 +550,9 @@ _Get1bpp:: ; 1042b2
ld a, b
ld l, c
ld h, $0
-rept 3
add hl, hl ; multiply by 8
-endr
+ add hl, hl ; multiply by 8
+ add hl, hl ; multiply by 8
ld c, l
ld b, h
ld h, d
diff --git a/misc/mobile_12_2.asm b/misc/mobile_12_2.asm
index dcf37aa70..2bdd6ddc3 100755
--- a/misc/mobile_12_2.asm
+++ b/misc/mobile_12_2.asm
@@ -53,9 +53,9 @@ MobileCheckOwnMonAnywhere: ; 4a843
jr z, .asm_4a8d1
ld hl, .BoxAddrs
ld b, 0
-rept 3
add hl, bc
-endr
+ add hl, bc
+ add hl, bc
ld a, [hli]
call GetSRAMBank
ld a, [hli]
diff --git a/misc/mobile_22.asm b/misc/mobile_22.asm
index c5b15db84..565b54200 100644
--- a/misc/mobile_22.asm
+++ b/misc/mobile_22.asm
@@ -45,7 +45,9 @@ Function8917a: ; 8917a (22:517a)
ret
Function89185: ; 89185 (22:5185)
-; Compares c bytes starting at de and hl and incrementing together until a match is found.
+; strcmp(hl, de, c)
+; Compares c bytes starting at de and hl and incrementing together until a mismatch is found.
+; Preserves hl and de.
push de
push hl
.loop
@@ -62,7 +64,9 @@ Function89185: ; 89185 (22:5185)
ret
Function89193: ; 89193
+; copy(hl, de, 4)
; Copies c bytes from hl to de.
+; Preserves hl and de.
push de
push hl
.loop
@@ -355,10 +359,10 @@ Function89305: ; 89305 (22:5305)
Function8931b: ; 8931b
push hl
- ld hl, $a03b
+ ld hl, $a03b ; 4:a03b
ld a, [MenuSelection]
dec a
- ld bc, $0025
+ ld bc, 37
call AddNTimes
ld b, h
ld c, l
@@ -371,7 +375,9 @@ Function8932d: ; 8932d
add hl, bc
Function89331: ; 89331
-; Scans up to 5 characters starting at hl, looking for a nonspace character up to the next terminator. Sets carry if it does not find a nonspace character. Returns the location of the following character in hl.
+; Scans up to 5 characters starting at hl, looking for a nonspace character up to the next terminator.
+; Sets carry if it does not find a nonspace character.
+; Returns the location of the following character in hl.
push bc
ld c, 5
.loop
@@ -1649,44 +1655,44 @@ String_89a53: ; 89a53
; 89a57
Function89a57: ; 89a57
- call Function354b
- bit 6, c
- jr nz, .asm_89a78
- bit 7, c
- jr nz, .asm_89a81
- bit 0, c
- jr nz, .asm_89a70
- bit 1, c
- jr nz, .asm_89a70
- bit 3, c
- jr nz, .asm_89a74
+ call JoyTextDelay_ForcehJoyDown ; joypad
+ bit D_UP_F, c
+ jr nz, .d_up
+ bit D_DOWN_F, c
+ jr nz, .d_down
+ bit A_BUTTON_F, c
+ jr nz, .a_b_button
+ bit B_BUTTON_F, c
+ jr nz, .a_b_button
+ bit START_F, c
+ jr nz, .start_button
scf
ret
-.asm_89a70
+.a_b_button
ld a, $1
and a
ret
-.asm_89a74
+.start_button
ld a, $2
and a
ret
-.asm_89a78
- call Function89a9b
- call nc, Function89a8a
+.d_up
+ call .MoveCursorUp
+ call nc, .PlayPocketSwitchSFX
ld a, $0
ret
-.asm_89a81
- call Function89a93
- call nc, Function89a8a
+.d_down
+ call .MoveCursorDown
+ call nc, .PlayPocketSwitchSFX
ld a, $0
ret
; 89a8a
-Function89a8a: ; 89a8a
+.PlayPocketSwitchSFX: ; 89a8a
push af
ld de, SFX_SWITCH_POCKETS
call PlaySFX
@@ -1694,42 +1700,42 @@ Function89a8a: ; 89a8a
ret
; 89a93
-Function89a93: ; 89a93
- ld d, $28
- ld e, $1
- call Function89aa3
+.MoveCursorDown: ; 89a93
+ ld d, 40
+ ld e, 1
+ call .ApplyCursorMovement
ret
; 89a9b
-Function89a9b: ; 89a9b
- ld d, $1
- ld e, $ff
- call Function89aa3
+.MoveCursorUp: ; 89a9b
+ ld d, 1
+ ld e, -1
+ call .ApplyCursorMovement
ret
; 89aa3
-Function89aa3: ; 89aa3
+.ApplyCursorMovement: ; 89aa3
ld a, [MenuSelection]
ld c, a
push bc
-.asm_89aa8
+.loop
ld a, [MenuSelection]
cp d
- jr z, .asm_89ac0
+ jr z, .equal_to_d
add e
- jr nz, .asm_89ab2
+ jr nz, .not_zero
inc a
-.asm_89ab2
+.not_zero
ld [MenuSelection], a
- call Function89ac7
- jr nc, .asm_89aa8
- call Function89ae6
+ call .Function89ac7 ; BCD conversion of data in SRAM?
+ jr nc, .loop
+ call .Function89ae6 ; split [MenuSelection] into [wd030] + [wd031] where [wd030] <= 5
pop bc
and a
ret
-.asm_89ac0
+.equal_to_d
pop bc
ld a, c
ld [MenuSelection], a
@@ -1737,48 +1743,48 @@ Function89aa3: ; 89aa3
ret
; 89ac7
-Function89ac7: ; 89ac7
+.Function89ac7: ; 89ac7
call OpenSRAMBank4
call Function8931b
- call Function89ad4
+ call .Function89ad4
call CloseSRAM
ret
; 89ad4
-Function89ad4: ; 89ad4
+.Function89ad4: ; 89ad4
push de
- call Function8932d
- jr c, .asm_89ae3
- ld hl, $0011
+ call Function8932d ; find a non-space character within 5 bytes of bc
+ jr c, .no_nonspace_character
+ ld hl, 17
add hl, bc
call Function89b45
- jr c, .asm_89ae4
+ jr c, .finish_decode
-.asm_89ae3
+.no_nonspace_character
and a
-.asm_89ae4
+.finish_decode
pop de
ret
; 89ae6
-Function89ae6: ; 89ae6
+.Function89ae6: ; 89ae6
ld hl, wd031
xor a
ld [hl], a
ld a, [MenuSelection]
-.asm_89aee
- cp $6
- jr c, .asm_89afc
- sub $5
+.loop2
+ cp 6
+ jr c, .load_and_ret
+ sub 5
ld c, a
ld a, [hl]
- add $5
+ add 5
ld [hl], a
ld a, c
- jr .asm_89aee
+ jr .loop2
-.asm_89afc
+.load_and_ret
ld [wd030], a
ret
; 89b00
@@ -1823,48 +1829,50 @@ Function89b3b: ; 89b3b (22:5b3b)
ret
Function89b45: ; 89b45
+ ; some sort of decoder?
+ ; BCD?
push hl
push bc
ld c, $10
ld e, $0
-.asm_89b4b
+.loop
ld a, [hli]
ld b, a
and $f
- cp $a
- jr c, .asm_89b5a
+ cp 10
+ jr c, .low_nybble_less_than_10
ld a, c
cp $b
- jr nc, .asm_89b74
- jr .asm_89b71
+ jr nc, .clear_carry
+ jr .set_carry
-.asm_89b5a
+.low_nybble_less_than_10
dec c
swap b
inc e
ld a, b
and $f
- cp $a
- jr c, .asm_89b6c
+ cp 10
+ jr c, .high_nybble_less_than_10
ld a, c
cp $b
- jr nc, .asm_89b74
- jr .asm_89b71
+ jr nc, .clear_carry
+ jr .set_carry
-.asm_89b6c
+.high_nybble_less_than_10
inc e
dec c
- jr nz, .asm_89b4b
+ jr nz, .loop
dec e
-.asm_89b71
+.set_carry
scf
- jr .asm_89b75
+ jr .finish
-.asm_89b74
+.clear_carry
and a
-.asm_89b75
+.finish
pop bc
pop hl
ret
@@ -2027,56 +2035,59 @@ Function89c44: ; 89c44 (22:5c44)
ret
Function89c67: ; 89c67 (22:5c67)
- call Function354b
+; menu scrolling?
+ call JoyTextDelay_ForcehJoyDown ; joypad
ld b, $0
- bit 0, c
- jr z, .asm_89c74
+ bit A_BUTTON_F, c
+ jr z, .not_a_button
ld b, $1
and a
ret
-.asm_89c74
- bit 1, c
- jr z, .asm_89c7a
+
+.not_a_button
+ bit B_BUTTON_F, c
+ jr z, .not_b_button
scf
ret
-.asm_89c7a
+
+.not_b_button
xor a
- bit 6, c
- jr z, .asm_89c81
+ bit D_UP_F, c
+ jr z, .not_d_up
ld a, $1
-.asm_89c81
- bit 7, c
- jr z, .asm_89c87
+.not_d_up
+ bit D_DOWN_F, c
+ jr z, .not_d_down
ld a, $2
-.asm_89c87
- bit 5, c
- jr z, .asm_89c8d
+.not_d_down
+ bit D_LEFT_F, c
+ jr z, .not_d_left
ld a, $3
-.asm_89c8d
- bit 4, c
- jr z, .asm_89c93
+.not_d_left
+ bit D_RIGHT_F, c
+ jr z, .not_d_right
ld a, $4
-.asm_89c93
+.not_d_right
and a
- ret z
+ ret z ; no dpad pressed
dec a
ld c, a
ld d, $0
- ld hl, Unknown_89cbf
+ ld hl, .ScrollData0
ld a, [wd02f]
and a
- jr z, .asm_89ca5
- ld hl, Unknown_89ccf
-.asm_89ca5
+ jr z, .got_data
+ ld hl, .ScrollData1
+.got_data
ld a, [wd011]
and a
- jr z, .asm_89cb1
+ jr z, .got_row
ld e, $4
-.asm_89cad
+.add_n_times
add hl, de
dec a
- jr nz, .asm_89cad
-.asm_89cb1
+ jr nz, .add_n_times
+.got_row
ld e, c
add hl, de
ld a, [hl]
@@ -2089,13 +2100,13 @@ Function89c67: ; 89c67 (22:5c67)
ret
; 89cbf (22:5cbf)
-Unknown_89cbf: ; 89cbf
+.ScrollData0: ; 89cbf
db 0, 2, 0, 0
db 1, 3, 0, 0
db 2, 4, 0, 0
db 3, 0, 0, 0
-Unknown_89ccf: ; 89ccf
+.ScrollData1: ; 89ccf
db 0, 0, 0, 0
db 0, 3, 0, 0
db 2, 4, 0, 0
@@ -2305,7 +2316,7 @@ Jumptable_89e18: ; 89e18 (22:5e18)
Function89e1e: ; 89e1e (22:5e1e)
call OpenSRAMBank4
- ld bc, $a037
+ ld bc, $a037 ; 4:a037
call Function8b36c
call CloseSRAM
xor a
@@ -2648,9 +2659,9 @@ Function8a055: ; 8a055 (22:6055)
ld a, $5
call Function8a5a3
pop hl
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld a, $6
call Function8a5a3
call CGBOnly_LoadEDTile
@@ -4061,7 +4072,7 @@ Function8aab6: ; 8aab6 (22:6ab6)
; 8aaf0 (22:6af0)
String_8aaf0: ; 8aaf0
- db "あたらしい めいし", $4a, "できまし", $22, "@"
+ db "あたらしい めいし<PKMN>できまし<LNBRK>@"
; 8ab00
Function8ab00: ; 8ab00
@@ -4096,6 +4107,7 @@ Function8ab11: ; 8ab11 (22:6b11)
ret
Function8ab3b: ; 8ab3b (22:6b3b)
+.pressed_start
call Function891fe
call ClearBGPalettes
call Function893cc
@@ -4114,23 +4126,24 @@ Function8ab3b: ; 8ab3b (22:6b3b)
call Function89a0c
call CloseSRAM
call Function891ab
- call Function8ab77
- jr c, Function8ab3b
- ret
-
-Function8ab77: ; 8ab77 (22:6b77)
- call Function354b
- bit 0, c
- jr nz, .asm_8ab8e
- bit 1, c
- jr nz, .asm_8ab8e
- bit 3, c
- jr z, Function8ab77
+ call .JoypadLoop
+ jr c, .pressed_start
+ ret
+
+.JoypadLoop: ; 8ab77 (22:6b77)
+ call JoyTextDelay_ForcehJoyDown
+ bit A_BUTTON_F, c
+ jr nz, .a_b_button
+ bit B_BUTTON_F, c
+ jr nz, .a_b_button
+ bit START_F, c
+ jr z, .JoypadLoop
call PlayClickSFX
call Function89d0d
scf
ret
-.asm_8ab8e
+
+.a_b_button
call PlayClickSFX
and a
ret
diff --git a/misc/mobile_22_2.asm b/misc/mobile_22_2.asm
index 616c16ae0..7085f8899 100644
--- a/misc/mobile_22_2.asm
+++ b/misc/mobile_22_2.asm
@@ -54,16 +54,18 @@ Function8b363: ; 8b363
; 8b36c
Function8b36c: ; 8b36c (22:736c)
+ ; [bc + (0:4)] = -1
push bc
ld h, b
ld l, c
- ld bc, $4
+ ld bc, 4
ld a, -1
call ByteFill
pop bc
ret
Function8b379: ; 8b379 (22:7379)
+ ; d = [bc + e]
push bc
ld a, c
add e
@@ -77,6 +79,7 @@ Function8b379: ; 8b379 (22:7379)
ret
Function8b385: ; 8b385 (22:7385)
+ ; [bc + e] = d
push bc
ld a, c
add e
@@ -90,36 +93,39 @@ Function8b385: ; 8b385 (22:7385)
ret
Function8b391: ; 8b391 (22:7391)
+ ; find first e in range(4) such that [bc + e] == -1
+ ; if none exist, return carry
push bc
- ld e, $0
- ld d, $4
-.asm_8b396
+ ld e, 0
+ ld d, 4
+.loop
ld a, [bc]
inc bc
- cp $ff
- jr z, .asm_8b3a2
+ cp -1
+ jr z, .done
inc e
dec d
- jr nz, .asm_8b396
+ jr nz, .loop
dec e
scf
-.asm_8b3a2
+.done
pop bc
ret
Function8b3a4: ; 8b3a4 (22:73a4)
+ ; strcmp(hl, bc, 4)
push de
push bc
ld d, b
ld e, c
- ld c, $4
+ ld c, 4
call Function89185
pop bc
pop de
ret
Function8b3b0: ; 8b3b0 (22:73b0)
- ld bc, $a037
+ ld bc, $a037 ; 4:a037
ld a, [$a60b]
and a
jr z, .asm_8b3c2
@@ -153,82 +159,88 @@ Function8b3cd: ; 8b3cd (22:73cd)
Function8b3dd: ; 8b3dd (22:73dd)
push de
push bc
- call Function354b
+ call JoyTextDelay_ForcehJoyDown ; joypad
ld a, c
pop bc
pop de
- bit 0, a
- jr nz, .asm_8b3f7
- bit 1, a
- jr nz, .asm_8b40e
- bit 6, a
- jr nz, .asm_8b429
- bit 7, a
- jr nz, .asm_8b443
+ bit A_BUTTON_F, a
+ jr nz, .a_button
+ bit B_BUTTON_F, a
+ jr nz, .b_button
+ bit D_UP_F, a
+ jr nz, .d_up
+ bit D_DOWN_F, a
+ jr nz, .d_down
and a
ret
-.asm_8b3f7
+
+.a_button
ld a, e
cp $3
- jr z, .asm_8b407
+ jr z, .e_is_zero
inc e
- ld d, $0
+ ld d, 0
call Function8b385
xor a
ld [wd010], a
ret
-.asm_8b407
+
+.e_is_zero
call PlayClickSFX
ld d, $0
scf
ret
-.asm_8b40e
+
+.b_button
ld a, e
and a
- jr nz, .asm_8b41e
+ jr nz, .e_is_not_zero
call PlayClickSFX
- ld d, $ff
+ ld d, -1
call Function8b385
- ld d, $1
+ ld d, 1
scf
ret
-.asm_8b41e
- ld d, $ff
+
+.e_is_not_zero
+ ld d, -1
call Function8b385
dec e
xor a
ld [wd010], a
ret
-.asm_8b429
+
+.d_up
call Function8b379
ld a, d
cp $a
- jr c, .asm_8b433
+ jr c, .less_than_10_up_1
ld d, $9
-.asm_8b433
+.less_than_10_up_1
inc d
ld a, d
cp $a
- jr c, .asm_8b43b
+ jr c, .less_than_10_up_2
ld d, $0
-.asm_8b43b
+.less_than_10_up_2
call Function8b385
xor a
ld [wd010], a
ret
-.asm_8b443
+
+.d_down
call Function8b379
ld a, d
cp $a
- jr c, .asm_8b44d
+ jr c, .less_than_10_down
ld d, $0
-.asm_8b44d
+.less_than_10_down
ld a, d
dec d
and a
- jr nz, .asm_8b454
+ jr nz, .nonzero_down
ld d, $9
-.asm_8b454
+.nonzero_down
call Function8b385
xor a
ld [wd010], a
@@ -403,6 +415,7 @@ Function8b539: ; 8b539 (22:7539)
ret
Function8b555: ; 8b555 (22:7555)
+.loop
ld hl, UnknownText_0x8b5ce
call PrintText
ld bc, wd017
@@ -416,27 +429,29 @@ Function8b555: ; 8b555 (22:7555)
jr nz, .asm_8b57c
ld hl, UnknownText_0x8b5e2
call PrintText
- jr Function8b555
+ jr .loop
+
.asm_8b57c
ld hl, UnknownText_0x8b5d3
call PrintText
ld bc, wd013
call Function8b45c
- jr c, Function8b555
+ jr c, .loop
ld bc, wd017
ld hl, wd013
call Function8b3a4
- jr z, .asm_8b5a6
+ jr z, .strings_equal
call Function89448
ld bc, wd013
call Function8b493
ld hl, UnknownText_0x8b5d8
call PrintText
jr .asm_8b57c
-.asm_8b5a6
+
+.strings_equal
call OpenSRAMBank4
ld hl, wd013
- ld de, $a037
+ ld de, $a037 ; 4:a037
ld bc, $4
call CopyBytes
call CloseSRAM
@@ -504,7 +519,7 @@ Function8b5e7: ; 8b5e7 (22:75e7)
ld bc, wd013
call Function8b493
call OpenSRAMBank4
- ld hl, $a037
+ ld hl, $a037 ; 4:a037
call Function8b3a4
call CloseSRAM
jr z, .asm_8b635
diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm
index 91ed8cfb3..98d4e6858 100644
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -1167,9 +1167,9 @@ Function1006fd: ; 1006fd
ld hl, $a800
call GetSRAMBank
xor a
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
call CloseSRAM
ret
; 10070d
@@ -7211,9 +7211,9 @@ Function1030cd: ; 1030cd
ld a, [wcf44]
ld l, a
ld h, 0
-rept 3
add hl, hl
-endr
+ add hl, hl
+ add hl, hl
ld bc, Unknown_103112
add hl, bc
ld b, $30
diff --git a/misc/mobile_41.asm b/misc/mobile_41.asm
index bd90cd894..b68336a28 100755
--- a/misc/mobile_41.asm
+++ b/misc/mobile_41.asm
@@ -181,9 +181,9 @@ MobileFn_105fe3: mobile ; 105fe3
inc [hl]
jr nz, .asm_106001
ld a, $ff
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
.asm_106001
@@ -211,9 +211,9 @@ MobileFn_106008: mobile ; 106008
inc [hl]
jr nz, .asm_106027
ld a, $ff
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
.asm_106027
@@ -606,9 +606,9 @@ _MobilePrintNum:: ; 1061ef
ld de, ._9
.three_to_nine_digits
-rept 3
inc de
-endr
+ inc de
+ inc de
dec a
dec a
@@ -689,9 +689,9 @@ endr
sbc b
ld [hPrintNum6], a
ld a, [de]
-rept 3
inc de
-endr
+ inc de
+ inc de
ld b, a
ld a, [hPrintNum1]
sbc b
diff --git a/misc/mobile_45.asm b/misc/mobile_45.asm
index 0b4bb7017..10242b77e 100644
--- a/misc/mobile_45.asm
+++ b/misc/mobile_45.asm
@@ -634,9 +634,9 @@ Function1144d1: ; 1144d1
dec de
dec de
push de
-rept 3
inc de
-endr
+ inc de
+ inc de
inc hl
ld a, [de]
ld [hli], a
@@ -4460,9 +4460,9 @@ Function1158c2: ; 1158c2
ld bc, $0003
.asm_115914
-rept 3
dec bc
-endr
+ dec bc
+ dec bc
ld a, c
ld [$dc19], a
ld a, b
@@ -5139,9 +5139,9 @@ endr
ld e, [hl]
inc hl
ld d, [hl]
-rept 3
inc de
-endr
+ inc de
+ inc de
ld [hl], d
dec hl
ld [hl], e
diff --git a/misc/mobile_46.asm b/misc/mobile_46.asm
index 220c9e0b1..78fcc8418 100755
--- a/misc/mobile_46.asm
+++ b/misc/mobile_46.asm
@@ -3767,9 +3767,9 @@ Function119b6b: ; 119b6b
ld [hld], a
dec hl
pop de
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld a, h
cp $e0
jr c, .asm_119b93
diff --git a/misc/mobile_5c.asm b/misc/mobile_5c.asm
index fe8432262..ef5bff597 100755
--- a/misc/mobile_5c.asm
+++ b/misc/mobile_5c.asm
@@ -495,9 +495,9 @@ Function171aec: ; 171aec (5c:5aec)
.asm_171b34
pop hl
ld bc, $14
-rept 3
add hl, bc
-endr
+ add hl, bc
+ add hl, bc
pop af
dec a
jr nz, .asm_171b1b
diff --git a/misc/mobile_5f.asm b/misc/mobile_5f.asm
index 0ff92bc3e..12a018d73 100644
--- a/misc/mobile_5f.asm
+++ b/misc/mobile_5f.asm
@@ -4393,9 +4393,9 @@ Function17f3f0: ; 17f3f0
pop hl
add hl, de
add hl, de
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld e, l
ld d, h
ld l, c
diff --git a/misc/mobile_menu.asm b/misc/mobile_menu.asm
index 75fc58f5f..fcea61728 100755
--- a/misc/mobile_menu.asm
+++ b/misc/mobile_menu.asm
@@ -836,9 +836,9 @@ Function4a680: ; 4a680 (12:6680)
ld [hli], a
ld [hli], a
xor a
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ret
Function4a6ab: ; 4a6ab (12:66ab)
diff --git a/misc/printer_77.asm b/misc/printer_77.asm
index 32f5c734f..de377b397 100755
--- a/misc/printer_77.asm
+++ b/misc/printer_77.asm
@@ -164,7 +164,7 @@ Function1dc381: ; 1dc381
call TextBox
hlcoord 8, 2
ld a, [TempMonLevel]
- call Function383d
+ call PrintLevel_Force3Digits
hlcoord 12, 2
ld [hl], "◀" ; Filled left triangle
inc hl
diff --git a/misc/unused_title.asm b/misc/unused_title.asm
index a74a376a3..0f25e8a52 100644
--- a/misc/unused_title.asm
+++ b/misc/unused_title.asm
@@ -10,9 +10,9 @@ UnusedTitleScreen: ; 10c000
ld [hBGMapMode], a
ld hl, wJumptableIndex
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
ld hl, UnusedTitleBG_GFX
diff --git a/predef/crystal.asm b/predef/crystal.asm
index c006a96e0..52c859bb6 100755
--- a/predef/crystal.asm
+++ b/predef/crystal.asm
@@ -554,9 +554,9 @@ _InitMG_Mobile_LinkTradePalMap: ; 49797
hlcoord 2, 16, AttrMap
ld [hli], a
ld a, $7
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld a, $2
ld [hl], a
hlcoord 2, 17, AttrMap
diff --git a/predef/sgb.asm b/predef/sgb.asm
index f9e8348d9..c2a04478e 100644
--- a/predef/sgb.asm
+++ b/predef/sgb.asm
@@ -472,9 +472,9 @@ endr
ld a, [CurPartySpecies]
ld l, a
ld h, 0
-rept 3
add hl, hl
-endr
+ add hl, hl
+ add hl, hl
ld de, PokemonPalettes
add hl, de
ld a, [wcf65]
diff --git a/tilesets/animations.asm b/tilesets/animations.asm
index a4af6cbc0..a3b0c4f06 100644
--- a/tilesets/animations.asm
+++ b/tilesets/animations.asm
@@ -472,9 +472,9 @@ AnimateWaterTile: ; fc402
and 3 << 1
; 2 x 8 = 16 bytes per tile
-rept 3
add a
-endr
+ add a
+ add a
add WaterTileFrames % $100
ld l, a
@@ -511,9 +511,9 @@ ForestTreeLeftAnimation: ; fc45c
.asm_fc46c
ld a, [TileAnimationTimer]
call GetForestTreeFrame
-rept 3
add a
-endr
+ add a
+ add a
add ForestTreeLeftFrames % $100
ld l, a
ld a, 0
@@ -553,9 +553,9 @@ ForestTreeRightAnimation: ; fc4c4
.asm_fc4d4
ld a, [TileAnimationTimer]
call GetForestTreeFrame
-rept 3
add a
-endr
+ add a
+ add a
add ForestTreeLeftFrames % $100
ld l, a
ld a, 0
@@ -589,9 +589,9 @@ ForestTreeLeftAnimation2: ; fc4f2
ld a, [TileAnimationTimer]
call GetForestTreeFrame
xor 2
-rept 3
add a
-endr
+ add a
+ add a
add ForestTreeLeftFrames % $100
ld l, a
ld a, 0
@@ -621,9 +621,9 @@ ForestTreeRightAnimation2: ; fc51c
ld a, [TileAnimationTimer]
call GetForestTreeFrame
xor 2
-rept 3
add a
-endr
+ add a
+ add a
add ForestTreeLeftFrames % $100
ld l, a
ld a, 0
@@ -734,9 +734,9 @@ SafariFountainAnim2: ; fc5eb
ld c, l
ld a, [TileAnimationTimer]
and 6
-rept 3
add a
-endr
+ add a
+ add a
ld e, a
ld d, 0
ld hl, SafariFountainFrames
diff --git a/trainers/read_party.asm b/trainers/read_party.asm
index 1f4ec1c9b..c74d4c6dc 100755
--- a/trainers/read_party.asm
+++ b/trainers/read_party.asm
@@ -310,9 +310,9 @@ TrainerType4: ; 3989d
ComputeTrainerReward: ; 3991b (e:591b)
ld hl, hProduct
xor a
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld a, [wEnemyTrainerBaseReward]
ld [hli], a
ld a, [CurPartyLevel]