summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/battle/ai/items.asm2
-rwxr-xr-xengine/battle/ai/move.asm6
-rw-r--r--engine/battle/ai/scoring.asm24
-rw-r--r--engine/battle/battle_transition.asm69
-rw-r--r--engine/battle/checkbattlescene.asm8
-rw-r--r--engine/battle/core.asm365
-rw-r--r--engine/battle/effect_commands.asm183
-rwxr-xr-xengine/battle/effect_commands/present.asm4
-rw-r--r--engine/battle/hidden_power.asm14
-rwxr-xr-xengine/battle/menu.asm23
-rw-r--r--engine/battle/misc.asm54
-rwxr-xr-xengine/battle/sliding_intro.asm6
-rw-r--r--engine/battle/start_battle.asm8
-rwxr-xr-xengine/battle/trainer_huds.asm18
-rwxr-xr-xengine/battle/used_move_text.asm105
-rw-r--r--engine/battle_anims/anim_commands.asm59
-rw-r--r--engine/battle_anims/bg_effects.asm8
-rwxr-xr-xengine/battle_anims/core.asm (renamed from engine/battle_anims/engine.asm)0
-rwxr-xr-xengine/battle_anims/functions.asm17
-rwxr-xr-xengine/battle_anims/getpokeballwobble.asm2
-rwxr-xr-xengine/billspc.asm156
-rwxr-xr-xengine/billspctop.asm13
-rwxr-xr-xengine/breeding.asm47
-rwxr-xr-xengine/buy_sell_toss.asm15
-rwxr-xr-xengine/card_flip.asm314
-rw-r--r--engine/caught_data.asm30
-rw-r--r--engine/cgb_layouts.asm160
-rwxr-xr-xengine/clock_reset.asm1
-rw-r--r--engine/color.asm214
-rw-r--r--engine/credits.asm20
-rwxr-xr-xengine/crystal_intro.asm130
-rwxr-xr-xengine/crystal_layouts.asm (renamed from engine/crystal_colors.asm)19
-rwxr-xr-xengine/debug.asm120
-rwxr-xr-xengine/decorations.asm37
-rwxr-xr-xengine/delete_save_change_clock.asm14
-rwxr-xr-xengine/dma_transfer.asm14
-rwxr-xr-xengine/dummy_game.asm2
-rw-r--r--engine/events.asm31
-rwxr-xr-xengine/events/battle_tower/battle_tower.asm1669
-rw-r--r--engine/events/battle_tower/get_trainer_class.asm46
-rw-r--r--engine/events/battle_tower/load_trainer.asm (renamed from engine/events/battle_tower.asm)34
-rw-r--r--engine/events/battle_tower/rules.asm (renamed from engine/events/battle_tower_rules.asm)6
-rwxr-xr-xengine/events/battle_tower/trainer_text.asm718
-rw-r--r--engine/events/buena.asm38
-rw-r--r--engine/events/buena_menu.asm2
-rwxr-xr-xengine/events/bug_contest/contest_2.asm29
-rw-r--r--engine/events/bug_contest/display_stats.asm10
-rwxr-xr-xengine/events/bug_contest/judging.asm37
-rwxr-xr-xengine/events/celebi.asm59
-rw-r--r--engine/events/checkforhiddenitems.asm85
-rwxr-xr-xengine/events/daycare.asm38
-rw-r--r--engine/events/dratini.asm2
-rwxr-xr-xengine/events/elevator.asm65
-rwxr-xr-xengine/events/field_moves.asm44
-rw-r--r--engine/events/fish.asm2
-rw-r--r--engine/events/fruit_trees.asm4
-rwxr-xr-xengine/events/halloffame.asm22
-rwxr-xr-xengine/events/happiness_egg.asm6
-rwxr-xr-xengine/events/heal_machine_anim.asm55
-rw-r--r--engine/events/kurt.asm21
-rw-r--r--engine/events/loadfishinggfx.asm46
-rw-r--r--engine/events/lucky_number.asm2
-rw-r--r--engine/events/magikarp.asm10
-rwxr-xr-xengine/events/magnet_train.asm71
-rw-r--r--engine/events/map_name_sign.asm274
-rwxr-xr-xengine/events/misc_scripts.asm2
-rw-r--r--engine/events/misc_scripts_2.asm2
-rw-r--r--engine/events/mom.asm11
-rwxr-xr-xengine/events/mom_phone.asm10
-rw-r--r--engine/events/move_deleter.asm2
-rw-r--r--engine/events/move_tutor.asm12
-rw-r--r--engine/events/name_rater.asm10
-rw-r--r--engine/events/odd_egg.asm4
-rwxr-xr-xengine/events/overworld.asm14
-rw-r--r--engine/events/poisonstep_pals.asm7
-rw-r--r--engine/events/poke_seer.asm34
-rwxr-xr-xengine/events/pokecenter_pc.asm22
-rwxr-xr-xengine/events/pokepic.asm5
-rwxr-xr-xengine/events/print_photo.asm2
-rw-r--r--engine/events/print_unown.asm4
-rw-r--r--engine/events/print_unown_2.asm2
-rwxr-xr-xengine/events/prof_oaks_pc.asm4
-rwxr-xr-xengine/events/sacred_ash.asm12
-rwxr-xr-xengine/events/special.asm32
-rw-r--r--engine/events/std_scripts.asm97
-rwxr-xr-xengine/events/treemons.asm285
-rw-r--r--engine/events/unown_walls.asm (renamed from engine/events/crystal_unown.asm)97
-rwxr-xr-xengine/events/whiteout.asm8
-rw-r--r--engine/events_2.asm6
-rwxr-xr-xengine/events_3.asm689
-rwxr-xr-xengine/evolution_animation.asm16
-rwxr-xr-xengine/evolve.asm10
-rw-r--r--engine/gbc_only.asm8
-rwxr-xr-xengine/init_gender.asm16
-rw-r--r--engine/init_hof_credits.asm6
-rw-r--r--engine/init_map.asm4
-rwxr-xr-xengine/intro_menu.asm55
-rw-r--r--engine/item_effects.asm99
-rw-r--r--engine/landmarks.asm4
-rwxr-xr-xengine/learn.asm2
-rwxr-xr-xengine/link.asm350
-rw-r--r--engine/link_2.asm6
-rwxr-xr-xengine/link_trade.asm24
-rw-r--r--engine/load_font.asm156
-rwxr-xr-xengine/load_pics.asm494
-rwxr-xr-xengine/mail.asm24
-rwxr-xr-xengine/mail_2.asm5
-rwxr-xr-xengine/main_menu.asm9
-rw-r--r--engine/map_objects.asm63
-rw-r--r--engine/map_setup.asm8
-rw-r--r--engine/mapgroup_roofs.asm20
-rwxr-xr-xengine/mart.asm24
-rwxr-xr-xengine/menu.asm34
-rw-r--r--engine/menu_2.asm34
-rwxr-xr-xengine/mon_icons.asm7
-rwxr-xr-xengine/mon_menu.asm14
-rw-r--r--engine/mon_stats.asm7
-rwxr-xr-xengine/move_mon.asm36
-rwxr-xr-xengine/move_mon_wo_mail.asm4
-rwxr-xr-xengine/mystery_gift.asm84
-rwxr-xr-xengine/mystery_gift_2.asm16
-rwxr-xr-xengine/naming_screen.asm (renamed from engine/namingscreen.asm)110
-rwxr-xr-xengine/npc_movement.asm48
-rwxr-xr-xengine/npctrade.asm45
-rwxr-xr-xengine/overworld.asm22
-rw-r--r--engine/pack.asm325
-rw-r--r--engine/party_menu.asm59
-rw-r--r--engine/phone/buenas_password.asm2
-rw-r--r--engine/phone/generic_calls.asm2
-rw-r--r--engine/phone/phone.asm36
-rw-r--r--engine/phone/phone_callers.asm10
-rw-r--r--engine/phone/phone_scripts.asm532
-rw-r--r--engine/pic_animation.asm25
-rw-r--r--engine/player_gfx.asm11
-rwxr-xr-xengine/player_movement.asm10
-rwxr-xr-xengine/player_object.asm2
-rwxr-xr-xengine/player_step.asm6
-rw-r--r--engine/pokedex/newpokedexentry.asm (renamed from engine/routines/newpokedexentry.asm)6
-rw-r--r--engine/pokedex/pokedex.asm (renamed from engine/pokedex.asm)434
-rw-r--r--engine/pokedex/pokedex_2.asm (renamed from engine/pokedex_2.asm)42
-rw-r--r--engine/pokedex/pokedex_3.asm (renamed from engine/pokedex_3.asm)2
-rwxr-xr-xengine/pokedex/unown_dex.asm (renamed from engine/unown_dex.asm)0
-rwxr-xr-xengine/pokegear.asm301
-rw-r--r--engine/predef.asm81
-rwxr-xr-xengine/print_party.asm16
-rwxr-xr-xengine/printer.asm11
-rwxr-xr-xengine/printnum.asm2
-rw-r--r--engine/radio.asm178
-rw-r--r--engine/routines/checknickerrors.asm10
-rw-r--r--engine/routines/correcterrorsinplayerparty.asm4
-rw-r--r--engine/routines/drawkrispackgfx.asm8
-rw-r--r--engine/routines/emptyallsrambanks.asm8
-rw-r--r--engine/routines/flagpredef.asm4
-rw-r--r--engine/routines/getsquareroot.asm14
-rw-r--r--engine/routines/initlist.asm2
-rw-r--r--engine/routines/loadoverworldfont.asm17
-rw-r--r--engine/routines/loadpushoam.asm2
-rw-r--r--engine/routines/placegraphic.asm1
-rw-r--r--engine/routines/placewaitingtext.asm2
-rw-r--r--engine/routines/playslowcry.asm6
-rw-r--r--engine/routines/printhoursmins.asm3
-rw-r--r--engine/routines/printitemdescription.asm31
-rwxr-xr-xengine/routines/sine.asm4
-rw-r--r--engine/routines/switchpartymons.asm10
-rw-r--r--engine/routines/trademonfrontpic.asm2
-rw-r--r--engine/routines/unreferenced_getgen1trainerclassname.asm21
-rwxr-xr-xengine/rtc.asm14
-rw-r--r--engine/save.asm71
-rw-r--r--engine/scripting.asm511
-rwxr-xr-xengine/scrolling_menu.asm2
-rwxr-xr-xengine/search.asm4
-rw-r--r--engine/sgb_layouts.asm219
-rwxr-xr-xengine/slot_machine.asm117
-rw-r--r--engine/specials.asm216
-rwxr-xr-xengine/sprite_anims.asm24
-rwxr-xr-xengine/sprites.asm55
-rwxr-xr-xengine/start_menu.asm38
-rwxr-xr-xengine/stats_screen.asm91
-rw-r--r--engine/tileset_anims.asm1060
-rw-r--r--engine/tileset_palettes.asm151
-rwxr-xr-xengine/time.asm12
-rwxr-xr-xengine/time_capsule.asm2
-rw-r--r--engine/time_capsule_2.asm2
-rw-r--r--engine/timeofdaypals.asm18
-rwxr-xr-xengine/timeset.asm17
-rw-r--r--engine/title.asm36
-rwxr-xr-xengine/tmhm.asm2
-rwxr-xr-xengine/tmhm2.asm8
-rwxr-xr-xengine/trade_animation.asm96
-rwxr-xr-xengine/trainer_card.asm162
-rw-r--r--engine/types.asm8
-rwxr-xr-xengine/unown_puzzle.asm59
-rw-r--r--engine/unused_title.asm119
-rwxr-xr-xengine/variables.asm9
-rwxr-xr-xengine/warp_connection.asm17
-rwxr-xr-xengine/wildmons.asm55
196 files changed, 8891 insertions, 5490 deletions
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm
index 09595077a..d0867fb33 100644
--- a/engine/battle/ai/items.asm
+++ b/engine/battle/ai/items.asm
@@ -291,7 +291,7 @@ AI_Items: ; 39196
dbw X_DEFEND, .XDefend
dbw X_SPEED, .XSpeed
dbw X_SPECIAL, .XSpecial
- db $ff
+ db -1 ; end
; 381be
.FullHeal: ; 381be
diff --git a/engine/battle/ai/move.asm b/engine/battle/ai/move.asm
index 11586c0da..7ccb20972 100755
--- a/engine/battle/ai/move.asm
+++ b/engine/battle/ai/move.asm
@@ -56,7 +56,7 @@ AIChooseMove: ; 440ce
inc hl
ld a, [de]
inc de
- and $3f
+ and PP_MASK
jr nz, .CheckMovePP
ld [hl], 80
jr .CheckMovePP
@@ -92,7 +92,7 @@ AIChooseMove: ; 440ce
push bc
ld d, BANK(TrainerClassAttributes)
- predef FlagPredef
+ predef SmallFarFlagAction
ld d, c
pop bc
@@ -186,7 +186,7 @@ AIChooseMove: ; 440ce
.ChooseMove:
ld hl, Buffer1
call Random
- and 3
+ maskbits NUM_MOVES
ld c, a
ld b, 0
add hl, bc
diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm
index 44194d6f7..73284435a 100644
--- a/engine/battle/ai/scoring.asm
+++ b/engine/battle/ai/scoring.asm
@@ -68,7 +68,7 @@ AI_Basic: ; 38591
db EFFECT_TOXIC
db EFFECT_POISON
db EFFECT_PARALYZE
- db $ff
+ db -1 ; end
; 385e0
@@ -400,7 +400,7 @@ AI_Smart: ; 386be
dbw EFFECT_SOLARBEAM, AI_Smart_Solarbeam
dbw EFFECT_THUNDER, AI_Smart_Thunder
dbw EFFECT_FLY, AI_Smart_Fly
- db $ff
+ db -1 ; end
; 387e3
@@ -1553,7 +1553,7 @@ AI_Smart_Encore: ; 38c3b
db AEROBLAST
db COTTON_SPORE
db POWDER_SNOW
- db $ff
+ db -1 ; end
; 38ca4
@@ -2214,7 +2214,7 @@ AI_Smart_Sandstorm: ; 38f7a
db ROCK
db GROUND
db STEEL
- db $ff
+ db -1 ; end
; 38fac
@@ -2533,7 +2533,7 @@ RainDanceMoves: ; 390e7
db CRABHAMMER
db OCTAZOOKA
db WHIRLPOOL
- db $ff
+ db -1 ; end
; 390f3
@@ -2622,7 +2622,7 @@ SunnyDayMoves: ; 39134
db SACRED_FIRE
db MORNING_SUN
db SYNTHESIS
- db $ff
+ db -1 ; end
; 3913d
@@ -3125,7 +3125,7 @@ UsefulMoves: ; 39301
db FIRE_BLAST
db SOFTBOILED
db SUPER_FANG
- db $ff
+ db -1 ; end
; 39315
@@ -3209,7 +3209,7 @@ AI_Opportunist: ; 39315
db CONVERSION
db SUBSTITUTE
db FLAME_WHEEL
- db $ff
+ db -1 ; end
; 39369
@@ -3324,7 +3324,7 @@ AI_Aggressive: ; 39369
db EFFECT_RAMPAGE
db EFFECT_MULTI_HIT
db EFFECT_DOUBLE_HIT
- db $ff
+ db -1 ; end
; 393e7
@@ -3350,7 +3350,7 @@ AIDamageCalc: ; 393e7
db EFFECT_STATIC_DAMAGE
db EFFECT_LEVEL_DAMAGE
db EFFECT_PSYWAVE
- db $ff
+ db -1 ; end
; 39418
@@ -3406,7 +3406,7 @@ AI_Cautious: ; 39418
db CONVERSION
db SUBSTITUTE
db SPIKES
- db $ff
+ db -1 ; end
; 39453
@@ -3544,7 +3544,7 @@ endr
.RiskyMoves:
db EFFECT_SELFDESTRUCT
db EFFECT_OHKO
- db $ff
+ db -1 ; end
; 39502
diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm
index 85ba44072..452339e81 100644
--- a/engine/battle/battle_transition.asm
+++ b/engine/battle/battle_transition.asm
@@ -1,4 +1,4 @@
-Predef_StartBattle: ; 8c20f
+DoBattleTransition: ; 8c20f
call .InitGFX
ld a, [rBGP]
ld [wBGP], a
@@ -16,14 +16,14 @@ Predef_StartBattle: ; 8c20f
ld a, [wJumptableIndex]
bit 7, a
jr nz, .done
- call FlashyTransitionToBattle
+ call BattleTransitionJumptable
call DelayFrame
jr .loop
.done
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, wBGPals1
@@ -44,7 +44,7 @@ Predef_StartBattle: ; 8c20f
ld [hLYOverrideEnd], a
ld [hSCY], a
- ld a, $1
+ ld a, 1 ; unnecessary bankswitch?
ld [rSVBK], a
pop af
ld [hVBlank], a
@@ -116,7 +116,7 @@ LoadTrainerBattlePokeballTiles:
ConvertTrainerBattlePokeballTilesTo2bpp: ; 8c2cf
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
push hl
ld hl, wDecompressScratch
@@ -144,7 +144,7 @@ TrainerBattlePokeballTiles: ; 8c2f4
INCBIN "gfx/overworld/trainer_battle_pokeball_tiles.2bpp"
-FlashyTransitionToBattle: ; 8c314
+BattleTransitionJumptable: ; 8c314
jumptable .dw, wJumptableIndex
; 8c323
@@ -298,7 +298,7 @@ StartTrainerBattle_Flash: ; 8c3ab (23:43ab)
StartTrainerBattle_SetUpForWavyOutro: ; 8c3e8 (23:43e8)
farcall Function5602
- ld a, $5 ; BANK(LYOverrides)
+ ld a, BANK(LYOverrides)
ld [rSVBK], a
call StartTrainerBattle_NextScene
@@ -356,7 +356,7 @@ StartTrainerBattle_SineWave: ; 8c408 (23:4408)
StartTrainerBattle_SetUpForSpinOutro: ; 8c43d (23:443d)
farcall Function5602
- ld a, $5 ; BANK(LYOverrides)
+ ld a, BANK(LYOverrides)
ld [rSVBK], a
call StartTrainerBattle_NextScene
xor a
@@ -498,7 +498,7 @@ ENDM
StartTrainerBattle_SetUpForRandomScatterOutro: ; 8c578 (23:4578)
farcall Function5602
- ld a, $5 ; BANK(LYOverrides)
+ ld a, BANK(LYOverrides)
ld [rSVBK], a
call StartTrainerBattle_NextScene
ld a, $10
@@ -589,7 +589,7 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc)
dec b
jr nz, .loop
- call .loadpokeballgfx ; ld a, [OtherTrainerClass] \ ld de, PokeBallTransition \ ret
+ call .loadpokeballgfx
hlcoord 2, 1
ld b, SCREEN_WIDTH - 4
@@ -640,14 +640,14 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc)
.cgb
ld hl, .daypals
ld a, [TimeOfDayPal]
- and (1 << 2) - 1
- cp 3
+ maskbits NUM_DAYTIMES
+ cp DARKNESS_F
jr nz, .daytime
ld hl, .nightpals
.daytime
ld a, [rSVBK]
push af
- ld a, $5 ; WRAM5 = palettes
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
call .copypals
push hl
@@ -691,17 +691,12 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc)
; 8c6a1 (23:46a1)
.daypals ; 8c6a1
- RGB 31, 18, 29
- RGB 31, 11, 15
- RGB 31, 05, 05
- RGB 07, 07, 07
+INCLUDE "gfx/overworld/trainer_battle_day.pal"
; 8c6a9
.nightpals ; 8c6a9
- RGB 31, 18, 29
- RGB 31, 05, 05
- RGB 31, 05, 05
- RGB 31, 05, 05
+INCLUDE "gfx/overworld/trainer_battle_nite.pal"
+; 8c6b1
.loadpokeballgfx
ld a, [OtherTrainerClass]
@@ -729,7 +724,7 @@ PokeBallTransition:
WipeLYOverrides: ; 8c6d8
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(LYOverrides)
ld [rSVBK], a
ld hl, LYOverrides
@@ -754,22 +749,23 @@ WipeLYOverrides: ; 8c6d8
StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7)
- and (1 << 6) - 1
- cp 1 << 5
- jr nc, .okay
- call .DoSineWave
+; a = d * sin(a * pi/32)
+ and %111111
+ cp %100000
+ jr nc, .negative
+ call .ApplySineWave
ld a, h
ret
-.okay
- and (1 << 5) - 1
- call .DoSineWave
+.negative
+ and %011111
+ call .ApplySineWave
ld a, h
- xor -1 ; cpl
+ xor $ff
inc a
ret
-.DoSineWave: ; 8c70c (23:470c)
+.ApplySineWave: ; 8c70c (23:470c)
ld e, a
ld a, d
ld d, 0
@@ -780,15 +776,15 @@ StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7)
inc hl
ld d, [hl]
ld hl, 0
-.loop
+.multiply
srl a
- jr nc, .skip
+ jr nc, .even
add hl, de
-.skip
+.even
sla e
rl d
and a
- jr nz, .loop
+ jr nz, .multiply
ret
; 8c728 (23:4728)
@@ -863,8 +859,7 @@ ENDM
ret
; 8c7c9 (23:47c9)
-Function8c7c9:
-; XXX
+Unreferenced_Function8c7c9:
ld a, $1
ld [hBGMapMode], a
call WaitBGMap
diff --git a/engine/battle/checkbattlescene.asm b/engine/battle/checkbattlescene.asm
index b63f00907..a33cc62e3 100644
--- a/engine/battle/checkbattlescene.asm
+++ b/engine/battle/checkbattlescene.asm
@@ -1,7 +1,7 @@
CheckBattleScene: ; 4ea44
; Return carry if battle scene is turned off.
- ld a, 0
+ ld a, BANK(wLinkMode)
ld hl, wLinkMode
call GetFarWRAMByte
cp LINK_MOBILE
@@ -19,9 +19,9 @@ CheckBattleScene: ; 4ea44
and a
jr nz, .from_wram
- ld a, $4
+ ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
- ld a, [$a60c]
+ ld a, [$a60c] ; address of MBC30 bank
ld c, a
call CloseSRAM
@@ -33,7 +33,7 @@ CheckBattleScene: ; 4ea44
ret
.from_wram
- ld a, $5
+ ld a, BANK(w5_dc00)
ld hl, w5_dc00
call GetFarWRAMByte
bit 0, a
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 08021fc8b..1a58b3df5 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -26,8 +26,8 @@ DoBattle: ; 3c000
and a
jr z, .not_linked
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr z, .player_2
.not_linked
@@ -97,8 +97,8 @@ DoBattle: ; 3c000
ld a, [wLinkMode]
and a
jr z, .not_linked_2
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr nz, .not_linked_2
xor a
ld [wEnemySwitchMonIndex], a
@@ -160,7 +160,7 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5
BattleTurn: ; 3c12f
.loop
- call MobileFn_3c1bf
+ call Stubbed_Function3c1bf
call CheckContestBattleOver
jp c, .quit
@@ -231,10 +231,11 @@ BattleTurn: ; 3c12f
ret
; 3c1bf
-MobileFn_3c1bf: mobile
- ld a, $5
+Stubbed_Function3c1bf:
+ ret
+ ld a, 5 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
- ld hl, $a89b ; s5_a89b
+ ld hl, $a89b ; address of MBC30 bank
inc [hl]
jr nz, .finish
dec hl
@@ -250,8 +251,8 @@ MobileFn_3c1bf: mobile
; 3c1d6
HandleBetweenTurnEffects: ; 3c1d6
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .CheckEnemyFirst
call CheckFaint_PlayerThenEnemy
ret c
@@ -349,8 +350,8 @@ CheckFaint_EnemyThenPlayer: ; 3c25c
; 3c27c
HandleBerserkGene: ; 3c27c
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .reverse
call .player
@@ -457,8 +458,8 @@ DetermineMoveOrder: ; 3c314
ld a, [wPlayerAction]
cp $2
jr nz, .switch
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr z, .player_2
call BattleRandom
@@ -514,8 +515,8 @@ DetermineMoveOrder: ; 3c314
jp .enemy_first
.both_have_quick_claw
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr z, .player_2b
call BattleRandom
cp c
@@ -544,8 +545,8 @@ DetermineMoveOrder: ; 3c314
jp .enemy_first
.speed_tie
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr z, .player_2c
call BattleRandom
cp 1 + (50 percent)
@@ -708,8 +709,8 @@ ParsePlayerAction: ; 3c434
; 3c4df
HandleEncore: ; 3c4df
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .player_1
call .do_player
jr .do_enemy
@@ -730,7 +731,7 @@ HandleEncore: ; 3c4df
ld b, 0
add hl, bc
ld a, [hl]
- and $3f
+ and PP_MASK
ret nz
.end_player_encore
@@ -754,7 +755,7 @@ HandleEncore: ; 3c4df
ld b, 0
add hl, bc
ld a, [hl]
- and $3f
+ and PP_MASK
ret nz
.end_enemy_encore
@@ -857,7 +858,7 @@ GetMovePriority: ; 3c5c5
cp -1
jr nz, .loop
- ld a, 1
+ ld a, BASE_PRIORITY
ret
.done
@@ -865,15 +866,7 @@ GetMovePriority: ; 3c5c5
ret
; 3c5df
-MoveEffectPriorities: ; 3c5df
- db EFFECT_PROTECT, 3
- db EFFECT_ENDURE, 3
- db EFFECT_PRIORITY_HIT, 2
- db EFFECT_FORCE_SWITCH, 0
- db EFFECT_COUNTER, 0
- db EFFECT_MIRROR_COAT, 0
- db -1
-; 3c5ec
+INCLUDE "data/moves/effects_priorities.asm"
GetMoveEffect: ; 3c5ec
ld a, b
@@ -1168,8 +1161,8 @@ ResidualDamage: ; 3c716
; 3c801
HandlePerishSong: ; 3c801
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .EnemyFirst
call SetPlayerTurn
call .do_it
@@ -1237,8 +1230,8 @@ HandlePerishSong: ; 3c801
; 3c874
HandleWrap: ; 3c874
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .EnemyFirst
call SetPlayerTurn
call .do_it
@@ -1309,8 +1302,8 @@ SwitchTurnCore: ; 3c8e4
; 3c8eb
HandleLeftovers: ; 3c8eb
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .DoEnemyFirst
call SetPlayerTurn
call .do_it
@@ -1359,8 +1352,8 @@ HandleLeftovers: ; 3c8eb
; 3c93c
HandleMysteryberry: ; 3c93c
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .DoEnemyFirst
call SetPlayerTurn
call .do_it
@@ -1409,7 +1402,7 @@ HandleMysteryberry: ; 3c93c
and a
jr z, .quit
ld a, [de]
- and $3f
+ and PP_MASK
jr z, .restore
inc hl
inc de
@@ -1498,8 +1491,8 @@ HandleMysteryberry: ; 3c93c
; 3ca26
HandleFutureSight: ; 3ca26
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .enemy_first
call SetPlayerTurn
call .do_it
@@ -1557,8 +1550,8 @@ HandleFutureSight: ; 3ca26
; 3ca8f
HanleDefrost: ; 3ca8f
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .enemy_first
call .do_player_turn
jr .do_enemy_turn
@@ -1617,8 +1610,8 @@ HanleDefrost: ; 3ca8f
; 3cafb
HandleSafeguard: ; 3cafb
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .player1
call .CheckPlayer
jr .CheckEnemy
@@ -1654,8 +1647,8 @@ HandleSafeguard: ; 3cafb
jp StdBattleTextBox
HandleScreens: ; 3cb36
- ld a, [hLinkPlayerNumber]
- cp 1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .Both
call .CheckPlayer
jr .CheckEnemy
@@ -1738,8 +1731,8 @@ HandleWeather: ; 3cb9e
cp WEATHER_SANDSTORM
ret nz
- ld a, [hLinkPlayerNumber]
- cp 1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .enemy_first
.player_first
@@ -1951,8 +1944,7 @@ GetMaxHP: ; 3ccac
ret
; 3ccc2
-GetHalfHP: ; 3ccc2
-; unreferenced
+Unreferenced_GetHalfHP: ; 3ccc2
ld hl, BattleMonHP
ld a, [hBattleTurn]
and a
@@ -2123,8 +2115,8 @@ HandleEnemyMonFaint: ; 3cd55
; 3cdca
DoubleSwitch: ; 3cdca
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .player_1
call ClearSprites
hlcoord 1, 0
@@ -2460,7 +2452,7 @@ WinTrainerBattle: ; 3cfa4
ld c, 40
call DelayFrames
call EmptyBattleTextBox
- ld c, $3
+ ld c, BATTLETOWERTEXT_LOSS_TEXT
farcall BattleTowerText
call WaitPressAorB_BlinkCursor
ld hl, wPayDayMoney
@@ -2589,7 +2581,7 @@ AddBattleMoneyToAccount: ; 3d0be
push bc
ld b, h
ld c, l
- farcall TrainerRankings_AddToBattlePayouts
+ farcall StubbedTrainerRankings_AddToBattlePayouts
pop bc
pop hl
.loop
@@ -2640,7 +2632,7 @@ PlayVictoryMusic: ; 3d0ea
.trainer_victory
ld de, MUSIC_GYM_VICTORY
- call IsJohtoGymLeader
+ call IsGymLeader
jr c, .play_music
ld de, MUSIC_TRAINER_VICTORY
@@ -2652,58 +2644,22 @@ PlayVictoryMusic: ; 3d0ea
ret
; 3d123
-; These functions check if the current opponent is a gym leader or one of a
-; few other special trainers.
-
-; Note: KantoGymLeaders is a subset of JohtoGymLeaders. If you wish to
-; differentiate between the two, call IsKantoGymLeader first.
-
-; The Lance and Red entries are unused for music checks; those trainers are
-; accounted for elsewhere.
-
IsKantoGymLeader: ; 0x3d123
ld hl, KantoGymLeaders
jr IsGymLeaderCommon
-IsJohtoGymLeader: ; 0x3d128
- ld hl, JohtoGymLeaders
+IsGymLeader: ; 0x3d128
+ ld hl, GymLeaders
IsGymLeaderCommon:
push de
ld a, [OtherTrainerClass]
- ld de, $0001
+ ld de, $1
call IsInArray
pop de
ret
; 0x3d137
-JohtoGymLeaders:
- db FALKNER
- db WHITNEY
- db BUGSY
- db MORTY
- db PRYCE
- db JASMINE
- db CHUCK
- db CLAIR
- db WILL
- db BRUNO
- db KAREN
- db KOGA
-; fallthrough
-; these two entries are unused
- db CHAMPION
- db RED
-; fallthrough
-KantoGymLeaders:
- db BROCK
- db MISTY
- db LT_SURGE
- db ERIKA
- db JANINE
- db SABRINA
- db BLAINE
- db BLUE
- db -1
+INCLUDE "data/trainers/leaders.asm"
HandlePlayerMonFaint: ; 3d14e
call FaintYourPokemon
@@ -2760,7 +2716,7 @@ PlayerMonFaintHappinessMod: ; 3d1aa
ld c, a
ld hl, wBattleParticipantsNotFainted
ld b, RESET_FLAG
- predef FlagPredef
+ predef SmallFarFlagAction
ld hl, EnemySubStatus3
res SUBSTATUS_IN_LOOP, [hl]
xor a
@@ -3066,7 +3022,7 @@ LostBattle: ; 3d38e
call DelayFrames
call EmptyBattleTextBox
- ld c, 2
+ ld c, BATTLETOWERTEXT_WIN_TEXT
farcall BattleTowerText
call WaitPressAorB_BlinkCursor
call ClearTileMap
@@ -3357,10 +3313,10 @@ AddBattleParticipant: ; 3d581
ld hl, wBattleParticipantsNotFainted
ld b, SET_FLAG
push bc
- predef FlagPredef
+ predef SmallFarFlagAction
pop bc
ld hl, wBattleParticipantsIncludingFainted
- predef_jump FlagPredef
+ predef_jump SmallFarFlagAction
; 3d599
FindPkmnInOTPartyToSwitchIntoBattle: ; 3d599
@@ -4033,7 +3989,7 @@ InitBattleMon: ; 3da0d
ld a, [CurBattleMon]
call SkipNames
ld de, BattleMonNick
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
ld hl, BattleMonAttack
ld de, PlayerStats
@@ -4118,7 +4074,7 @@ InitEnemyMon: ; 3dabd
ld a, [CurPartyMon]
call SkipNames
ld de, EnemyMonNick
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
ld hl, EnemyMonAttack
ld de, EnemyStats
@@ -4350,7 +4306,7 @@ PursuitSwitch: ; 3dc5b
ld c, a
ld hl, wBattleParticipantsNotFainted
ld b, RESET_FLAG
- predef FlagPredef
+ predef SmallFarFlagAction
call PlayerMonFaintedAnimation
ld hl, BattleText_PkmnFainted
jr .done_fainted
@@ -4394,8 +4350,8 @@ RecallPlayerMon: ; 3dce6
; 3dcf9
HandleHealingItems: ; 3dcf9
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .player_1
call SetPlayerTurn
call HandleHPHealingItem
@@ -4586,13 +4542,13 @@ UseHeldStatusHealingItem: ; 3dde9
; 3de44
.Statuses: ; 3de44
- db HELD_HEAL_POISON, 1 << PSN
- db HELD_HEAL_FREEZE, 1 << FRZ
- db HELD_HEAL_BURN, 1 << BRN
- db HELD_HEAL_SLEEP, SLP
+ db HELD_HEAL_POISON, 1 << PSN
+ db HELD_HEAL_FREEZE, 1 << FRZ
+ db HELD_HEAL_BURN, 1 << BRN
+ db HELD_HEAL_SLEEP, SLP
db HELD_HEAL_PARALYZE, 1 << PAR
- db HELD_HEAL_STATUS, ALL_STATUS
- db $ff
+ db HELD_HEAL_STATUS, ALL_STATUS
+ db -1 ; end
; 3de51
UseConfusionHealingItem: ; 3de51
@@ -4639,8 +4595,8 @@ UseConfusionHealingItem: ; 3de51
HandleStatBoostingHeldItems: ; 3de97
; The effects handled here are not used in-game.
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .player_1
call .DoPlayer
jp .DoEnemy
@@ -4716,7 +4672,7 @@ HandleStatBoostingHeldItems: ; 3de97
dbw HELD_SP_DEFENSE_UP, BattleCommand_SpecialDefenseUp
dbw HELD_ACCURACY_UP, BattleCommand_AccuracyUp
dbw HELD_EVASION_UP, BattleCommand_EvasionUp
- db $ff
+ db -1 ; end
; 3df12
GetPartymonItem: ; 3df12
@@ -4852,7 +4808,7 @@ PrintPlayerHUD: ; 3dfbf
ld [de], a
ld hl, BattleMonLevel
ld de, TempMonLevel
- ld bc, $0011
+ ld bc, $11
call CopyBytes
ld a, [CurBattleMon]
ld hl, PartyMon1Species
@@ -5418,8 +5374,8 @@ PlayerSwitch: ; 3e3ad
ret
.dont_run
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .player_1
call BattleMonEntrance
call EnemyMonEntrance
@@ -5694,7 +5650,7 @@ MoveSelectionScreen: ; 3e4bc
ld b, 0
add hl, bc
ld a, [hl]
- and $3f
+ and PP_MASK
jr z, .no_pp_left
ld a, [PlayerDisableCount]
swap a
@@ -5893,7 +5849,7 @@ MoveInfoBox: ; 3e6c8
ld hl, BattleMonPP
add hl, bc
ld a, [hl]
- and $3f
+ and PP_MASK
ld [StringBuffer1], a
call .PrintPP
@@ -5956,7 +5912,7 @@ CheckPlayerHasUsableMoves: ; 3e786
or [hl]
inc hl
or [hl]
- and $3f
+ and PP_MASK
ret nz
jr .force_struggle
@@ -5978,8 +5934,7 @@ CheckPlayerHasUsableMoves: ; 3e786
.done
; Bug: this will result in a move with PP Up confusing the game.
- ; Replace with "and $3f" to fix.
- and a
+ and a ; should be "and PP_MASK"
ret nz
.force_struggle
@@ -6058,7 +6013,7 @@ ParseEnemyAction: ; 3e7c1
cp [hl]
jr z, .disabled
ld a, [de]
- and $3f
+ and PP_MASK
jr nz, .enough_pp
.disabled
@@ -6076,7 +6031,7 @@ ParseEnemyAction: ; 3e7c1
.loop2
ld hl, EnemyMonMoves
call BattleRandom
- and 3 ; TODO factor in NUM_MOVES
+ maskbits NUM_MOVES
ld c, a
ld b, 0
add hl, bc
@@ -6093,7 +6048,7 @@ ParseEnemyAction: ; 3e7c1
add hl, bc
ld b, a
ld a, [hl]
- and $3f
+ and PP_MASK
jr z, .loop2
ld a, c
ld [CurEnemyMoveNum], a
@@ -6376,9 +6331,9 @@ LoadEnemyMon: ; 3e8eb
; but the value is in feet and inches (one byte each).
; The first filter is supposed to make very large Magikarp even rarer,
-; by targeting those 1600 mm or larger.
+; by targeting those 1600 mm (= 5'3") or larger.
; After the conversion to feet, it is unable to target any,
-; as the largest possible Magikarp is 5'3'', which reads as 1283.
+; since the largest possible Magikarp is 5'3", and $0503 = 1283 mm.
ld a, [TempEnemyMonSpecies]
cp MAGIKARP
jr nz, .Happiness
@@ -6388,42 +6343,43 @@ LoadEnemyMon: ; 3e8eb
ld bc, PlayerID
callfar CalcMagikarpLength
-; No reason to keep going if length > 1536 (i.e. if length / 256 != 6)
+; No reason to keep going if length > 1536 mm (i.e. if HIGH(length) > 6 feet)
ld a, [wMagikarpLength]
- cp HIGH(1536) ; this compares to 6'0'', should be cp 5
+ cp HIGH(1536) ; should be "cp 5", since 1536 mm = 5'0", but HIGH(1536) = 6
jr nz, .CheckMagikarpArea
; 5% chance of skipping both size checks
call Random
cp 5 percent
jr c, .CheckMagikarpArea
-; Try again if length > 1615
+; Try again if length >= 1616 mm (i.e. if LOW(length) >= 3 inches)
ld a, [wMagikarpLength + 1]
- cp LOW(1616) ; this compares to 6'80'', should be cp 3
+ cp LOW(1616) ; should be "cp 3", since 1616 mm = 5'3", but LOW(1616) = 80
jr nc, .GenerateDVs
; 20% chance of skipping this check
call Random
cp 20 percent - 1
jr c, .CheckMagikarpArea
-; Try again if length > 1599
+; Try again if length >= 1600 mm (i.e. if LOW(length) >= 2 inches)
ld a, [wMagikarpLength + 1]
- cp LOW(1600) ; this compares to 6'64'', should be cp 2
+ cp LOW(1600) ; should be "cp 2", since 1600 mm = 5'2", but LOW(1600) = 64
jr nc, .GenerateDVs
.CheckMagikarpArea:
-; The z checks are supposed to be nz
-; Instead, all maps in GROUP_LAKE_OF_RAGE (mahogany area)
-; and routes 20 and 44 are treated as Lake of Rage
+; The "jr z" checks are supposed to be "jr nz".
+
+; Instead, all maps in GROUP_LAKE_OF_RAGE (Mahogany area)
+; and Routes 20 and 44 are treated as Lake of Rage.
; This also means Lake of Rage Magikarp can be smaller than ones
-; caught elsewhere rather than the other way around
+; caught elsewhere rather than the other way around.
-; Intended behavior enforces a minimum size at Lake of Rage
-; The real behavior prevents size flooring in the Lake of Rage area
+; Intended behavior enforces a minimum size at Lake of Rage.
+; The real behavior prevents a minimum size in the Lake of Rage area.
-; Moreover, due to the check not being translated to feet, all Magikarp
-; smaller than 4'0'' may be caught by the filter, a lot more than intended
+; Moreover, due to the check not being translated to feet+inches, all Magikarp
+; smaller than 4'0" may be caught by the filter, a lot more than intended.
ld a, [MapGroup]
cp GROUP_LAKE_OF_RAGE
jr z, .Happiness
@@ -6434,9 +6390,9 @@ LoadEnemyMon: ; 3e8eb
call Random
cp 40 percent - 2
jr c, .Happiness
-; Floor at length 1024
+; Try again if length < 1024 mm (i.e. if HIGH(length) < 3 feet)
ld a, [wMagikarpLength]
- cp HIGH(1024) ; compares to 4'0'', cp 3 would be closer to intended value
+ cp HIGH(1024) ; should be "cp 3", since 1024 mm = 3'4", but HIGH(1024) = 4
jr c, .GenerateDVs ; try again
; Finally done with DVs
@@ -6622,7 +6578,7 @@ LoadEnemyMon: ; 3e8eb
; Update enemy nick
ld hl, StringBuffer1
ld de, EnemyMonNick
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
; Saw this mon
@@ -6631,7 +6587,7 @@ LoadEnemyMon: ; 3e8eb
ld c, a
ld b, SET_FLAG
ld hl, PokedexSeen
- predef FlagPredef
+ predef SmallFarFlagAction
ld hl, EnemyMonStats
ld de, EnemyStats
@@ -6651,13 +6607,13 @@ CheckSleepingTreeMon: ; 3eb38
jr nz, .NotSleeping
; Get list for the time of day
- ld hl, .Morn
+ ld hl, AsleepTreeMonsMorn
ld a, [TimeOfDay]
cp DAY_F
jr c, .Check
- ld hl, .Day
+ ld hl, AsleepTreeMonsDay
jr z, .Check
- ld hl, .Nite
+ ld hl, AsleepTreeMonsNite
.Check:
ld a, [TempEnemyMonSpecies]
@@ -6670,36 +6626,7 @@ CheckSleepingTreeMon: ; 3eb38
and a
ret
-.Nite:
- db CATERPIE
- db METAPOD
- db BUTTERFREE
- db WEEDLE
- db KAKUNA
- db BEEDRILL
- db SPEAROW
- db EKANS
- db EXEGGCUTE
- db LEDYBA
- db AIPOM
- db -1 ; end
-
-.Day:
- db VENONAT
- db HOOTHOOT
- db NOCTOWL
- db SPINARAK
- db HERACROSS
- db -1 ; end
-
-.Morn:
- db VENONAT
- db HOOTHOOT
- db NOCTOWL
- db SPINARAK
- db HERACROSS
- db -1 ; end
-; 3eb75
+INCLUDE "data/wild/treemons_asleep.asm"
CheckUnownLetter: ; 3eb75
; Return carry if the Unown letter hasn't been unlocked yet
@@ -6769,8 +6696,7 @@ CheckUnownLetter: ; 3eb75
; 3ebc7
-SwapBattlerLevels: ; 3ebc7
-; unreferenced
+Unreferenced_SwapBattlerLevels: ; 3ebc7
push bc
ld a, [BattleMonLevel]
ld b, a
@@ -7162,7 +7088,7 @@ _LoadHPBar: ; 3eda6
ret
; 3edad
-LoadHPExpBarGFX: ; unreferenced
+Unreferenced_LoadHPExpBarGFX:
ld de, EnemyHPBarBorderGFX
ld hl, vTiles2 tile $6c
lb bc, BANK(EnemyHPBarBorderGFX), 4
@@ -7314,7 +7240,7 @@ GiveExperiencePoints: ; 3ee3b
ld c, a
ld b, CHECK_FLAG
ld d, $0
- predef FlagPredef
+ predef SmallFarFlagAction
ld a, c
and a
pop bc
@@ -7643,7 +7569,7 @@ GiveExperiencePoints: ; 3ee3b
ld a, [CurPartyMon]
ld c, a
ld b, SET_FLAG
- predef FlagPredef
+ predef SmallFarFlagAction
pop af
ld [CurPartyLevel], a
@@ -7840,7 +7766,7 @@ AnimateExpBar: ; 3f136
call PrintPlayerHUD
ld hl, BattleMonNick
ld de, StringBuffer1
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
call TerminateExpBarSound
ld de, SFX_HIT_END_OF_EXP_BAR
@@ -8093,7 +8019,7 @@ TextJump_GoodComeBack: ; 3f352
db "@"
; 3f357
-UnusedFunction_TextJump_ComeBack: ; 3f357
+Unreferenced_TextJump_ComeBack: ; 3f357
; this function doesn't seem to be used
ld hl, TextJump_ComeBack
ret
@@ -8104,7 +8030,7 @@ TextJump_ComeBack: ; 3f35b
db "@"
; 3f360
-HandleSafariAngerEatingStatus: ; unreferenced
+Unreferenced_HandleSafariAngerEatingStatus:
ld hl, wSafariMonEating
ld a, [hl]
and a
@@ -8335,7 +8261,7 @@ DropEnemySub: ; 3f486
ld hl, EnemyMonDVs
predef GetUnownLetter
ld de, vTiles2
- predef GetAnimatedFrontpicPredef
+ predef GetAnimatedFrontpic
pop af
ld [CurPartySpecies], a
ret
@@ -8371,14 +8297,13 @@ StartBattle: ; 3f4c1
ret
; 3f4d9
-_DoBattle: ; 3f4d9
-; unreferenced
+Unreferenced_DoBattle: ; 3f4d9
call DoBattle
ret
; 3f4dd
BattleIntro: ; 3f4dd
- farcall TrainerRankings_Battles ; mobile
+ farcall StubbedTrainerRankings_Battles ; mobile
call LoadTrainerOrWildMonPic
xor a
ld [TempBattleMonSpecies], a
@@ -8440,7 +8365,7 @@ InitEnemy: ; 3f55e
BackUpBGMap2: ; 3f568
ld a, [rSVBK]
push af
- ld a, $6 ; BANK(wDecompressScratch)
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
ld hl, wDecompressScratch
ld bc, $40 tiles ; vBGMap3 - vBGMap2
@@ -8463,12 +8388,13 @@ BackUpBGMap2: ; 3f568
InitEnemyTrainer: ; 3f594
ld [TrainerClass], a
- farcall TrainerRankings_TrainerBattles
+ farcall StubbedTrainerRankings_TrainerBattles
xor a
ld [TempEnemyMonSpecies], a
callfar GetTrainerAttributes
callfar ReadTrainerParty
+ ; RIVAL1's first mon has no held item
ld a, [TrainerClass]
cp RIVAL1
jr nz, .ok
@@ -8490,7 +8416,7 @@ InitEnemyTrainer: ; 3f594
ld a, TRAINER_BATTLE
ld [wBattleMode], a
- call IsJohtoGymLeader
+ call IsGymLeader
jr nc, .done
xor a
ld [CurPartyMon], a
@@ -8519,7 +8445,7 @@ InitEnemyTrainer: ; 3f594
InitEnemyWildmon: ; 3f607
ld a, WILD_BATTLE
ld [wBattleMode], a
- farcall TrainerRankings_WildBattles
+ farcall StubbedTrainerRankings_WildBattles
call LoadEnemyMon
ld hl, EnemyMonMoves
ld de, wWildMonMoves
@@ -8541,7 +8467,7 @@ InitEnemyWildmon: ; 3f607
ld [wFirstUnownSeen], a
.skip_unown
ld de, vTiles2
- predef GetAnimatedFrontpicPredef
+ predef GetAnimatedFrontpic
xor a
ld [TrainerClass], a
ld [hGraphicStartTile], a
@@ -8551,8 +8477,7 @@ InitEnemyWildmon: ; 3f607
ret
; 3f662
-Function3f662: ; 3f662
-; XXX
+Unreferenced_Function3f662: ; 3f662
ld hl, EnemyMonMoves
ld de, wListMoves_MoveIndicesBuffer
ld b, NUM_MOVES
@@ -8702,7 +8627,7 @@ CheckPayDay: ; 3f71d
; 3f759
ShowLinkBattleParticipantsAfterEnd: ; 3f759
- farcall TrainerRankings_LinkBattles
+ farcall StubbedTrainerRankings_LinkBattles
farcall BackupMobileEventIndex
ld a, [CurOTMon]
ld hl, OTPartyMon1Status
@@ -8732,17 +8657,17 @@ DisplayLinkBattleResult: ; 3f77c
cp $1
jr c, .victory
jr z, .loss
- farcall TrainerRankings_ColosseumDraws
+ farcall StubbedTrainerRankings_ColosseumDraws
ld de, .Draw
jr .store_result
.victory
- farcall TrainerRankings_ColosseumWins
+ farcall StubbedTrainerRankings_ColosseumWins
ld de, .Win
jr .store_result
.loss
- farcall TrainerRankings_ColosseumLosses
+ farcall StubbedTrainerRankings_ColosseumLosses
ld de, .Lose
jr .store_result
@@ -9320,7 +9245,7 @@ InitBattleDisplay: ; 3fb6c
.BlankBGMap: ; 3fbd6
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
ld hl, wDecompressScratch
@@ -9373,15 +9298,15 @@ GetTrainerBackpic: ; 3fbff
.Decompress:
ld de, vTiles2 tile $31
- ld c, $31
- predef DecompressPredef
+ ld c, 7 * 7
+ predef DecompressGet2bpp
ret
; 3fc30
CopyBackpic: ; 3fc30
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
ld hl, vTiles0
ld de, vTiles2 tile $31
@@ -9401,27 +9326,27 @@ CopyBackpic: ; 3fc30
; 3fc5b
.LoadTrainerBackpicAsOAM: ; 3fc5b
- ld hl, Sprites
+ ld hl, Sprite01
xor a
ld [hMapObjectIndexBuffer], a
- ld b, $6
- ld e, 21 * 8
+ ld b, 6
+ ld e, (SCREEN_WIDTH + 1) * TILE_WIDTH
.outer_loop
- ld c, $3
- ld d, 8 * 8
+ ld c, 3
+ ld d, 8 * TILE_WIDTH
.inner_loop
- ld [hl], d
+ ld [hl], d ; y
inc hl
- ld [hl], e
+ ld [hl], e ; x
inc hl
ld a, [hMapObjectIndexBuffer]
- ld [hli], a
+ ld [hli], a ; tile id
inc a
ld [hMapObjectIndexBuffer], a
- ld a, $1
- ld [hli], a
+ ld a, PAL_BATTLE_OB_PLAYER
+ ld [hli], a ; attributes
ld a, d
- add $8
+ add 1 * TILE_WIDTH
ld d, a
dec c
jr nz, .inner_loop
@@ -9429,7 +9354,7 @@ CopyBackpic: ; 3fc30
add $3
ld [hMapObjectIndexBuffer], a
ld a, e
- add $8
+ add 1 * TILE_WIDTH
ld e, a
dec b
jr nz, .outer_loop
@@ -9490,7 +9415,7 @@ BattleStartMessage: ; 3fc8b
cp BATTLETYPE_FISH
jr nz, .NotFishing
- farcall TrainerRankings_HookedEncounters
+ farcall StubbedTrainerRankings_HookedEncounters
ld hl, HookedPokemonAttackedText
jr .PlaceBattleStartText
diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm
index f86f90479..c1bc3752a 100644
--- a/engine/battle/effect_commands.asm
+++ b/engine/battle/effect_commands.asm
@@ -64,7 +64,7 @@ DoMove: ; 3402c
inc hl
ld [de], a
inc de
- cp $ff
+ cp -1
jr nz, .GetMoveEffect
; Start at the first command.
@@ -138,7 +138,7 @@ BattleCommand_CheckTurn: ; 34084
ld [AlreadyFailed], a
ld [wSomeoneIsRampaging], a
- ld a, 10 ; 1.0
+ ld a, EFFECTIVE
ld [TypeModifier], a
ld a, [hBattleTurn]
@@ -282,7 +282,7 @@ CheckPlayerTurn:
; 50% chance of hitting itself
call BattleRandom
- cp $80
+ cp 50 percent + 1
jr nc, .not_confused
; clear confusion-dependent substatus
@@ -311,7 +311,7 @@ CheckPlayerTurn:
; 50% chance of infatuation
call BattleRandom
- cp $80
+ cp 50 percent + 1
jr c, .not_infatuated
ld hl, InfatuationText
@@ -345,7 +345,7 @@ CheckPlayerTurn:
; 25% chance to be fully paralyzed
call BattleRandom
- cp $3f
+ cp 25 percent
ret nc
ld hl, FullyParalyzedText
@@ -457,6 +457,8 @@ CheckEnemyTurn: ; 3421f
ld hl, EnemyMonStatus
bit FRZ, [hl]
jr z, .not_frozen
+
+ ; Flame Wheel and Sacred Fire thaw the user.
ld a, [CurEnemyMove]
cp FLAME_WHEEL
jr z, .not_frozen
@@ -611,7 +613,7 @@ CheckEnemyTurn: ; 3421f
; 25% chance to be fully paralyzed
call BattleRandom
- cp $3f
+ cp 25 percent
ret nc
ld hl, FullyParalyzedText
@@ -844,19 +846,20 @@ BattleCommand_CheckObedience: ; 343db
.DoNothing:
+ ; 4 random choices
call BattleRandom
- and 3
+ and %11
ld hl, LoafingAroundText
- and a
+ and a ; 0
jr z, .Print
ld hl, WontObeyText
- dec a
+ dec a ; 1
jr z, .Print
ld hl, TurnedAwayText
- dec a
+ dec a ; 2
jr z, .Print
ld hl, IgnoredOrdersText
@@ -886,7 +889,7 @@ BattleCommand_CheckObedience: ; 343db
.GetTotalPP:
ld a, [hli]
- and $3f ; exclude pp up
+ and PP_MASK
add b
ld b, a
@@ -909,7 +912,7 @@ BattleCommand_CheckObedience: ; 343db
; Can't use another move if only one move has PP.
ld a, [hl]
- and $3f
+ and PP_MASK
cp b
jr z, .DoNothing
@@ -929,7 +932,7 @@ BattleCommand_CheckObedience: ; 343db
.RandomMove:
call BattleRandom
- and 3 ; TODO NUM_MOVES
+ maskbits NUM_MOVES
cp b
jr nc, .RandomMove
@@ -945,7 +948,7 @@ BattleCommand_CheckObedience: ; 343db
ld d, 0
add hl, de
ld a, [hl]
- and $3f
+ and PP_MASK
jr z, .RandomMove
@@ -989,6 +992,7 @@ IgnoreSleepOnly: ; 3451f
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar
+ ; Snore and Sleep Talk bypass sleep.
cp SNORE
jr z, .CheckSleep
cp SLEEP_TALK
@@ -1115,7 +1119,7 @@ BattleCommand_DoTurn: ; 34555
ld b, 0
add hl, bc
ld a, [hl]
- and $3f
+ and PP_MASK
jr z, .out_of_pp
dec [hl]
ld b, 0
@@ -1172,7 +1176,7 @@ BattleCommand_DoTurn: ; 34555
db EFFECT_ROLLOUT
db EFFECT_BIDE
db EFFECT_RAMPAGE
- db $ff
+ db -1
; 3460b
CheckMimicUsed: ; 3460b
@@ -1266,7 +1270,7 @@ BattleCommand_Critical: ; 34631
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar
ld de, 1
- ld hl, .Criticals
+ ld hl, CriticalHitMoves
push bc
call IsInArray
pop bc
@@ -1288,7 +1292,7 @@ BattleCommand_Critical: ; 34631
inc c
.Tally:
- ld hl, .Chances
+ ld hl, CriticalHitChances
ld b, 0
add hl, bc
call BattleRandom
@@ -1298,12 +1302,7 @@ BattleCommand_Critical: ; 34631
ld [CriticalHit], a
ret
-.Criticals:
- db KARATE_CHOP, RAZOR_WIND, RAZOR_LEAF, CRABHAMMER, SLASH, AEROBLAST, CROSS_CHOP, $ff
-.Chances:
- ; 6.25% 12.1% 24.6% 33.2% 49.6% 49.6% 49.6%
- db $11, $20, $40, $55, $80, $80, $80
- ; 0 1 2 3 4 5 6
+INCLUDE "data/battle/critical_hits.asm"
; 346b2
@@ -1433,11 +1432,11 @@ BattleCommand_Stab: ; 346d2
.TypesLoop:
ld a, [hli]
- cp $ff
+ cp -1
jr z, .end
; foresight
- cp $fe
+ cp -2
jr nz, .SkipForesightCheck
ld a, BATTLE_VARS_SUBSTATUS1_OPP
call GetBattleVar
@@ -1543,8 +1542,8 @@ BattleCheckTypeMatchup: ; 347c8
ld hl, BattleMonType1
CheckTypeMatchup: ; 347d3
; There is an incorrect assumption about this function made in the AI related code: when
-; the AI calls CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing the
-; offensive type in a will make this function do the right thing. Since a is overwritten,
+; the AI calls CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing
+; the offensive type in a will make this function do the right thing. Since a is overwritten,
; this assumption is incorrect. A simple fix would be to load the move type for the
; current move into a in BattleCheckTypeMatchup, before falling through, which is
; consistent with how the rest of the code assumes this code works like.
@@ -1562,9 +1561,9 @@ CheckTypeMatchup: ; 347d3
ld hl, TypeMatchups
.TypesLoop:
ld a, [hli]
- cp $ff
+ cp -1
jr z, .End
- cp $fe
+ cp -2
jr nz, .Next
ld a, BATTLE_VARS_SUBSTATUS1_OPP
call GetBattleVar
@@ -1640,7 +1639,7 @@ BattleCommand_ResetTypeMatchup: ; 34833
INCLUDE "engine/battle/ai/switch.asm"
-INCLUDE "data/type_matchups.asm"
+INCLUDE "data/battle/type_matchups.asm"
BattleCommand_DamageVariation: ; 34cfd
; damagevariation
@@ -1675,7 +1674,7 @@ BattleCommand_DamageVariation: ; 34cfd
.loop
call BattleRandom
rrca
- cp $d9 ; 85%
+ cp 85 percent + 1
jr c, .loop
ld [hMultiplier], a
@@ -1756,7 +1755,7 @@ BattleCommand_CheckHit: ; 34d32
.skip_brightpowder
ld a, b
- cp $ff
+ cp -1
jr z, .Hit
call BattleRandom
@@ -1954,7 +1953,7 @@ BattleCommand_CheckHit: ; 34d32
.skip_foresight_check
; subtract evasion from 14
- ld a, 14
+ ld a, MAX_STAT_LEVEL + 1
sub c
ld c, a
; store the base move accuracy for math ops
@@ -1969,7 +1968,7 @@ BattleCommand_CheckHit: ; 34d32
.accuracy_loop
; look up the multiplier from the table
push bc
- ld hl, .AccProb
+ ld hl, AccuracyLevelMultipliers
dec b
sla b
ld c, b
@@ -2013,21 +2012,7 @@ BattleCommand_CheckHit: ; 34d32
ld [hl], a
ret
-.AccProb:
- db 33, 100 ; 33% -6
- db 36, 100 ; 36% -5
- db 43, 100 ; 43% -4
- db 50, 100 ; 50% -3
- db 60, 100 ; 60% -2
- db 75, 100 ; 75% -1
- db 1, 1 ; 100% 0
- db 133, 100 ; 133% +1
- db 166, 100 ; 166% +2
- db 2, 1 ; 200% +3
- db 233, 100 ; 233% +4
- db 133, 50 ; 266% +5
- db 3, 1 ; 300% +6
-
+INCLUDE "data/battle/accuracy_multipliers.asm"
; 34ecc
@@ -2199,7 +2184,7 @@ BattleCommand_HitTargetNoSub: ; 34f60
xor 1
ld [wKickCounter], a
ld a, [de]
- cp $1
+ cp 1
push af
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar
@@ -2438,7 +2423,7 @@ GetFailureResultText: ; 350e4
ld hl, AttackMissedText
ld de, AttackMissed2Text
ld a, [CriticalHit]
- cp $ff
+ cp -1
jr nz, .got_text
ld hl, UnaffectedText
.got_text
@@ -3519,7 +3504,7 @@ BattleCommand_DamageCalc: ; 35612
.NextItem:
ld a, [hli]
- cp $ff
+ cp -1
jr z, .DoneItem
; Item effect
@@ -3657,26 +3642,7 @@ BattleCommand_DamageCalc: ; 35612
; 35703
-TypeBoostItems: ; 35703
- db HELD_NORMAL_BOOST, NORMAL ; Pink/Polkadot Bow
- db HELD_FIGHTING_BOOST, FIGHTING ; Blackbelt
- db HELD_FLYING_BOOST, FLYING ; Sharp Beak
- db HELD_POISON_BOOST, POISON ; Poison Barb
- db HELD_GROUND_BOOST, GROUND ; Soft Sand
- db HELD_ROCK_BOOST, ROCK ; Hard Stone
- db HELD_BUG_BOOST, BUG ; Silverpowder
- db HELD_GHOST_BOOST, GHOST ; Spell Tag
- db HELD_FIRE_BOOST, FIRE ; Charcoal
- db HELD_WATER_BOOST, WATER ; Mystic Water
- db HELD_GRASS_BOOST, GRASS ; Miracle Seed
- db HELD_ELECTRIC_BOOST, ELECTRIC ; Magnet
- db HELD_PSYCHIC_BOOST, PSYCHIC ; Twistedspoon
- db HELD_ICE_BOOST, ICE ; Nevermeltice
- db HELD_DRAGON_BOOST, DRAGON ; Dragon Scale
- db HELD_DARK_BOOST, DARK ; Blackglasses
- db HELD_STEEL_BOOST, STEEL ; Metal Coat
- db $ff
-; 35726
+INCLUDE "data/battle/type_boost_items.asm"
BattleCommand_ConstantDamage: ; 35726
@@ -3941,7 +3907,7 @@ BattleCommand_Encore: ; 35864
ld bc, BattleMonPP - BattleMonMoves - 1
add hl, bc
ld a, [hl]
- and $3f
+ and PP_MASK
jp z, .failed
ld a, [AttackMissed]
and a
@@ -4421,7 +4387,7 @@ BattleCommand_SleepTalk: ; 35b33
.sample_move
push hl
call BattleRandom
- and 3 ; TODO factor in NUM_MOVES
+ maskbits NUM_MOVES
ld c, a
ld b, 0
add hl, bc
@@ -4585,17 +4551,18 @@ BattleCommand_Spite: ; 35c0f
add hl, bc
pop bc
ld a, [hl]
- and $3f
+ and PP_MASK
jr z, .failed
push bc
call GetMoveName
+ ; lose 2-5 PP
call BattleRandom
- and 3
+ and %11
inc a
inc a
ld b, a
ld a, [hl]
- and $3f
+ and PP_MASK
cp b
jr nc, .deplete_pp
ld b, a
@@ -4671,7 +4638,7 @@ BattleCommand_FalseSwipe: ; 35c94
ld [de], a
.okay
ld a, [CriticalHit]
- cp $2
+ cp 2
jr nz, .carry
xor a
ld [CriticalHit], a
@@ -5049,7 +5016,7 @@ BattleCommand_SleepTarget: ; 35e5c
jr nz, .dont_fail
call BattleRandom
- cp $40 ; 25%
+ cp 25 percent + 1 ; 25% chance AI fails
ret c
.dont_fail
@@ -5149,7 +5116,7 @@ BattleCommand_Poison: ; 35f2c
jr nz, .mimic_random
call BattleRandom
- cp $40 ; 25% chance AI fails
+ cp 25 percent + 1 ; 25% chance AI fails
jr c, .failed
.mimic_random
@@ -5827,7 +5794,7 @@ BattleCommand_StatDown: ; 362e3
inc b
.ComputerMiss:
-; Computer opponents have a 1/4 chance of failing.
+; Computer opponents have a 25% chance of failing.
ld a, [hBattleTurn]
and a
jr z, .DidntMiss
@@ -5852,7 +5819,7 @@ BattleCommand_StatDown: ; 362e3
jr z, .DidntMiss
call BattleRandom
- cp $40
+ cp 25 percent + 1 ; 25% chance AI fails
jr c, .Failed
.DidntMiss:
@@ -6104,7 +6071,7 @@ BattleCommand_StatDownFailText: ; 3646a
GetStatName: ; 3648f
- ld hl, .names
+ ld hl, StatNames
ld c, "@"
.CheckName:
dec b
@@ -6120,33 +6087,10 @@ GetStatName: ; 3648f
ld bc, StringBuffer3 - StringBuffer2
jp CopyBytes
-.names
- db "ATTACK@"
- db "DEFENSE@"
- db "SPEED@"
- db "SPCL.ATK@"
- db "SPCL.DEF@"
- db "ACCURACY@"
- db "EVASION@"
- db "ABILITY@"
-; 364e6
-
-
-StatLevelMultipliers: ; 364e6
- db 25, 100 ; 0.25x
- db 28, 100 ; 0.28x
- db 33, 100 ; 0.33x
- db 40, 100 ; 0.40x
- db 50, 100 ; 0.50x
- db 66, 100 ; 0.66x
- db 1, 1 ; 1.00x
- db 15, 10 ; 1.50x
- db 2, 1 ; 2.00x
- db 25, 10 ; 2.50x
- db 3, 1 ; 3.00x
- db 35, 10 ; 3.50x
- db 4, 1 ; 4.00x
-; 36500
+INCLUDE "data/battle/stat_names.asm"
+
+
+INCLUDE "data/battle/stat_multipliers.asm"
BattleCommand_AllStatsUp: ; 36500
@@ -6266,13 +6210,12 @@ BattleCommand_TriStatusChance: ; 3658f
call BattleCommand_EffectChance
-; 1/3 chance of each status
.loop
+ ; 1/3 chance of each status
call BattleRandom
swap a
- and 3
+ and %11
jr z, .loop
-; jump
dec a
ld hl, .ptrs
rst JumpTable
@@ -7450,7 +7393,8 @@ BattleCommand_TrapTarget: ; 36c2d
bit SUBSTATUS_SUBSTITUTE, a
ret nz
call BattleRandom
- and 3
+ ; trapped for 2-5 turns
+ and %11
inc a
inc a
inc a
@@ -7648,8 +7592,9 @@ BattleCommand_FinishConfusingTarget: ; 36d70
.got_confuse_count
set SUBSTATUS_CONFUSED, [hl]
+ ; confused for 2-5 turns
call BattleRandom
- and 3
+ and %11
inc a
inc a
ld [bc], a
@@ -8078,7 +8023,7 @@ BattleCommand_LeechSeed: ; 36f9d
BattleCommand_Splash: ; 36fe1
call AnimateCurrentMove
- farcall TrainerRankings_Splash
+ farcall StubbedTrainerRankings_Splash
jp PrintNothingHappened
; 36fed
@@ -8259,7 +8204,7 @@ BattleCommand_Conversion: ; 3707f
.done
.loop3
call BattleRandom
- and 3 ; TODO factor in NUM_MOVES
+ maskbits NUM_MOVES
ld c, a
ld b, 0
ld hl, StringBuffer1
@@ -8605,7 +8550,7 @@ CheckSubstituteOpp: ; 37378
BattleCommand_Selfdestruct: ; 37380
- farcall TrainerRankings_Selfdestruct
+ farcall StubbedTrainerRankings_Selfdestruct
ld a, BATTLEANIM_PLAYER_DAMAGE
ld [wNumHits], a
ld c, 3
diff --git a/engine/battle/effect_commands/present.asm b/engine/battle/effect_commands/present.asm
index 819294f8c..2b358e8b9 100755
--- a/engine/battle/effect_commands/present.asm
+++ b/engine/battle/effect_commands/present.asm
@@ -31,7 +31,7 @@ BattleCommand_Present: ; 37874
ld c, 0
.next
ld a, [hli]
- cp $ff
+ cp -1
jr z, .heal_effect ; 378a4 $11
cp b
jr nc, .got_power ; 378a7 $4
@@ -89,5 +89,5 @@ BattleCommand_Present: ; 37874
db 40 percent, 40
db 70 percent + 1, 80
db 80 percent, 120
- db $ff
+ db -1 ; end
; 3790e
diff --git a/engine/battle/hidden_power.asm b/engine/battle/hidden_power.asm
index c75a67ab3..a1d3957e4 100644
--- a/engine/battle/hidden_power.asm
+++ b/engine/battle/hidden_power.asm
@@ -16,12 +16,12 @@ HiddenPowerDamage: ; fbced
; Attack
ld a, [hl]
swap a
- and 8
+ and %1000
; Defense
ld b, a
ld a, [hli]
- and 8
+ and %1000
srl a
or b
@@ -29,7 +29,7 @@ HiddenPowerDamage: ; fbced
ld b, a
ld a, [hl]
swap a
- and 8
+ and %1000
srl a
srl a
or b
@@ -37,7 +37,7 @@ HiddenPowerDamage: ; fbced
; Special
ld b, a
ld a, [hl]
- and 8
+ and %1000
srl a
srl a
srl a
@@ -52,7 +52,7 @@ HiddenPowerDamage: ; fbced
; Add Special & 3
ld b, a
ld a, [hld]
- and 3
+ and %0011
add b
; Divide by 2 and add 30 + 1
@@ -67,12 +67,12 @@ HiddenPowerDamage: ; fbced
; Def & 3
ld a, [hl]
- and 3
+ and %0011
ld b, a
; + (Atk & 3) << 2
ld a, [hl]
- and 3 << 4
+ and %0011 << 4
swap a
add a
add a
diff --git a/engine/battle/menu.asm b/engine/battle/menu.asm
index 07d3e6081..c97cd7854 100755
--- a/engine/battle/menu.asm
+++ b/engine/battle/menu.asm
@@ -33,15 +33,14 @@ Function24f19: ; 24f19
; 24f2c
BattleMenuDataHeader: ; 24f2c
- db $40 ; flags
- db 12, 08 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 8, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw MenuData_0x24f34
db 1 ; default option
; 24f34
MenuData_0x24f34: ; 0x24f34
- db $81 ; flags
+ db STATICMENU_CURSOR | STATICMENU_DISABLE_B ; flags
dn 2, 2 ; rows, columns
db 6 ; spacing
dba Strings24f3d
@@ -56,15 +55,14 @@ Strings24f3d: ; 0x24f3d
; 24f4e
MenuDataHeader_0x24f4e: ; 24f4e
- db $40 ; flags
- db 12, 00 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw MenuData_0x24f56
db 1 ; default option
; 24f56
MenuData_0x24f56: ; 24f56
- db $81 ; flags
+ db STATICMENU_CURSOR | STATICMENU_DISABLE_B ; flags
dn 2, 2 ; rows, columns
db 11 ; spacing
dba Strings24f5f
@@ -72,7 +70,7 @@ MenuData_0x24f56: ; 24f56
; 24f5f
Strings24f5f: ; 24f5f
- db "サファりボール× @" ; "SAFARI BALL× @"
+ db "サファりボール×  @" ; "SAFARI BALL× @"
db "エサをなげる@" ; "THROW BAIT"
db "いしをなげる@" ; "THROW ROCK"
db "にげる@" ; "RUN"
@@ -87,15 +85,14 @@ Function24f7c: ; 24f7c
; 24f89
MenuDataHeader_0x24f89: ; 24f89
- db $40 ; flags
- db 12, 02 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 2, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw MenuData_0x24f91
db 1 ; default option
; 24f91
MenuData_0x24f91: ; 24f91
- db $81 ; flags
+ db STATICMENU_CURSOR | STATICMENU_DISABLE_B ; flags
dn 2, 2 ; rows, columns
db 12 ; spacing
dba Strings24f9a
diff --git a/engine/battle/misc.asm b/engine/battle/misc.asm
index c78e9fd84..a41d31d9a 100644
--- a/engine/battle/misc.asm
+++ b/engine/battle/misc.asm
@@ -146,15 +146,15 @@ DoWeatherModifiers: ; fbda4
ret
.WeatherTypeModifiers:
- db WEATHER_RAIN, WATER, 15
- db WEATHER_RAIN, FIRE, 05
- db WEATHER_SUN, FIRE, 15
- db WEATHER_SUN, WATER, 05
- db $ff
+ db WEATHER_RAIN, WATER, MORE_EFFECTIVE
+ db WEATHER_RAIN, FIRE, NOT_VERY_EFFECTIVE
+ db WEATHER_SUN, FIRE, MORE_EFFECTIVE
+ db WEATHER_SUN, WATER, NOT_VERY_EFFECTIVE
+ db -1 ; end
.WeatherMoveModifiers:
- db WEATHER_RAIN, EFFECT_SOLARBEAM, 05
- db $ff
+ db WEATHER_RAIN, EFFECT_SOLARBEAM, NOT_VERY_EFFECTIVE
+ db -1 ; end
; fbe24
@@ -183,7 +183,7 @@ DoBadgeTypeBoosts: ; fbe24
.CheckBadge:
ld a, [hl]
- cp $ff
+ cp -1
jr z, .done
srl b
@@ -236,22 +236,24 @@ DoBadgeTypeBoosts: ; fbe24
ret
.BadgeTypes:
- db FLYING ; zephyrbadge
- db BUG ; hivebadge
- db NORMAL ; plainbadge
- db GHOST ; fogbadge
- db STEEL ; mineralbadge
- db FIGHTING ; stormbadge
- db ICE ; glacierbadge
- db DRAGON ; risingbadge
-
- db ROCK ; boulderbadge
- db WATER ; cascadebadge
- db ELECTRIC ; thunderbadge
- db GRASS ; rainbowbadge
- db POISON ; soulbadge
- db PSYCHIC ; marshbadge
- db FIRE ; volcanobadge
- db GROUND ; earthbadge
- db $ff
+; entries correspond to wJohtoBadges constants
+ db FLYING ; ZEPHYRBADGE
+ db BUG ; HIVEBADGE
+ db NORMAL ; PLAINBADGE
+ db GHOST ; FOGBADGE
+ db STEEL ; MINERALBADGE
+ db FIGHTING ; STORMBADGE
+ db ICE ; GLACIERBADGE
+ db DRAGON ; RISINGBADGE
+ ; fallthrough
+; entries correspond to wKantoBadges constants
+ db ROCK ; BOULDERBADGE
+ db WATER ; CASCADEBADGE
+ db ELECTRIC ; THUNDERBADGE
+ db GRASS ; RAINBOWBADGE
+ db POISON ; SOULBADGE
+ db PSYCHIC ; MARSHBADGE
+ db FIRE ; VOLCANOBADGE
+ db GROUND ; EARTHBADGE
+ db -1 ; end
; fbe91
diff --git a/engine/battle/sliding_intro.asm b/engine/battle/sliding_intro.asm
index ed78add8e..418454283 100755
--- a/engine/battle/sliding_intro.asm
+++ b/engine/battle/sliding_intro.asm
@@ -1,7 +1,7 @@
BattleIntroSlidingPics: ; 4e980
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(LYOverrides)
ld [rSVBK], a
call .subfunction1
ld a, rSCX - $ff00
@@ -60,9 +60,9 @@ BattleIntroSlidingPics: ; 4e980
; 4e9d6
.subfunction3 ; 4e9d6
- ld hl, Sprites + 1 ; x pixel
+ ld hl, Sprite01XCoord
ld c, $12 ; 18
- ld de, $4
+ ld de, SPRITEOAMSTRUCT_LENGTH
.loop3
dec [hl]
dec [hl]
diff --git a/engine/battle/start_battle.asm b/engine/battle/start_battle.asm
index 7f0bff96b..e1377eec0 100644
--- a/engine/battle/start_battle.asm
+++ b/engine/battle/start_battle.asm
@@ -33,7 +33,7 @@ FindFirstAliveMonAndStartBattle: ; 2ee2f
add hl, de
ld a, [hl]
ld [BattleMonLevel], a
- predef Predef_StartBattle
+ predef DoBattleTransition
farcall _LoadBattleFontsHPBar
ld a, 1
ld [hBGMapMode], a
@@ -93,7 +93,7 @@ PlayBattleMusic: ; 2ee6c
cp RED
jr z, .done
- ; really, they should have included admins and scientists here too...
+ ; They should have included EXECUTIVEM, EXECUTIVEF, and SCIENTIST too...
ld de, MUSIC_ROCKET_BATTLE
cp GRUNTM
jr z, .done
@@ -104,8 +104,10 @@ PlayBattleMusic: ; 2ee6c
farcall IsKantoGymLeader
jr c, .done
+ ; IsGymLeader also counts CHAMPION, RED, and the Kanto gym leaders
+ ; but they have been taken care of before this
ld de, MUSIC_JOHTO_GYM_LEADER_BATTLE
- farcall IsJohtoGymLeader
+ farcall IsGymLeader
jr c, .done
ld de, MUSIC_RIVAL_BATTLE
diff --git a/engine/battle/trainer_huds.asm b/engine/battle/trainer_huds.asm
index b236fc56b..317e72214 100755
--- a/engine/battle/trainer_huds.asm
+++ b/engine/battle/trainer_huds.asm
@@ -28,7 +28,7 @@ ShowPlayerMonsRemaining: ; 2c01c
ld [hl], a
ld a, 8
ld [wPlaceBallsDirection], a
- ld hl, Sprites
+ ld hl, Sprite01
jp LoadTrainerHudOAM
; 2c03a
@@ -44,7 +44,7 @@ ShowOTTrainerMonsRemaining: ; 2c03a
ld [hl], 4 * 8
ld a, -8
ld [wPlaceBallsDirection], a
- ld hl, Sprites + PARTY_LENGTH * 4
+ ld hl, Sprite01 + PARTY_LENGTH * SPRITEOAMSTRUCT_LENGTH
jp LoadTrainerHudOAM
; 2c059
@@ -193,7 +193,7 @@ LinkBattle_TrainerHuds: ; 2c10d
ld [hl], 8 * 8
ld a, $8
ld [wPlaceBallsDirection], a
- ld hl, Sprites
+ ld hl, Sprite01
call LoadTrainerHudOAM
ld hl, OTPartyMon1HP
@@ -203,7 +203,7 @@ LinkBattle_TrainerHuds: ; 2c10d
ld a, 10 * 8
ld [hli], a
ld [hl], 13 * 8
- ld hl, Sprites + PARTY_LENGTH * 4
+ ld hl, Sprite01 + PARTY_LENGTH * SPRITEOAMSTRUCT_LENGTH
jp LoadTrainerHudOAM
; 2c143
@@ -212,13 +212,13 @@ LoadTrainerHudOAM: ; 2c143
ld c, PARTY_LENGTH
.loop
ld a, [wPlaceBallsY]
- ld [hli], a
+ ld [hli], a ; y
ld a, [wPlaceBallsX]
- ld [hli], a
+ ld [hli], a ; x
ld a, [de]
- ld [hli], a
- ld a, $3
- ld [hli], a
+ ld [hli], a ; tile id
+ ld a, PAL_BATTLE_OB_YELLOW
+ ld [hli], a ; attributes
ld a, [wPlaceBallsX]
ld b, a
ld a, [wPlaceBallsDirection]
diff --git a/engine/battle/used_move_text.asm b/engine/battle/used_move_text.asm
index ce9e51359..1b5aa564c 100755
--- a/engine/battle/used_move_text.asm
+++ b/engine/battle/used_move_text.asm
@@ -157,12 +157,12 @@ GetMoveGrammar: ; 105e5c
.loop
ld a, [hli]
; end of table?
- cp $ff
+ cp -1
jr z, .end
; match?
cp c
jr z, .end
-; advance grammar type at $00
+; advance grammar type at 0
and a
jr nz, .loop
; next grammar type
@@ -179,106 +179,7 @@ GetMoveGrammar: ; 105e5c
ret
; 105e7a
-MoveGrammar: ; 105e7a
-; made redundant in localization
-; each move is given an identifier for what usedmovetext to use (0-4):
-
-; 0
- db SWORDS_DANCE
- db GROWTH
- db STRENGTH
- db HARDEN
- db MINIMIZE
- db SMOKESCREEN
- db WITHDRAW
- db DEFENSE_CURL
- db EGG_BOMB
- db SMOG
- db BONE_CLUB
- db FLASH
- db SPLASH
- db ACID_ARMOR
- db BONEMERANG
- db REST
- db SHARPEN
- db SUBSTITUTE
- db MIND_READER
- db SNORE
- db PROTECT
- db SPIKES
- db ENDURE
- db ROLLOUT
- db SWAGGER
- db SLEEP_TALK
- db HIDDEN_POWER
- db PSYCH_UP
- db EXTREMESPEED
- db 0 ; end set
-
-; 1
- db RECOVER
- db TELEPORT
- db BIDE
- db SELFDESTRUCT
- db AMNESIA
- db FLAIL
- db 0 ; end set
-
-; 2
- db MEDITATE
- db AGILITY
- db MIMIC
- db DOUBLE_TEAM
- db BARRAGE
- db TRANSFORM
- db STRUGGLE
- db SCARY_FACE
- db 0 ; end set
-
-; 3
- db POUND
- db SCRATCH
- db VICEGRIP
- db WING_ATTACK
- db FLY
- db BIND
- db SLAM
- db HORN_ATTACK
- db WRAP
- db THRASH
- db TAIL_WHIP
- db LEER
- db BITE
- db GROWL
- db ROAR
- db SING
- db PECK
- db ABSORB
- db STRING_SHOT
- db EARTHQUAKE
- db FISSURE
- db DIG
- db TOXIC
- db SCREECH
- db METRONOME
- db LICK
- db CLAMP
- db CONSTRICT
- db POISON_GAS
- db BUBBLE
- db SLASH
- db SPIDER_WEB
- db NIGHTMARE
- db CURSE
- db FORESIGHT
- db CHARM
- db ATTRACT
- db ROCK_SMASH
- db 0 ; end set
-
-; all other moves = 4
- db $ff ; end
-; 105ed0
+INCLUDE "data/moves/grammar.asm"
UpdateUsedMoves: ; 105ed0
diff --git a/engine/battle_anims/anim_commands.asm b/engine/battle_anims/anim_commands.asm
index 27d57e68f..0bbedf909 100644
--- a/engine/battle_anims/anim_commands.asm
+++ b/engine/battle_anims/anim_commands.asm
@@ -5,7 +5,7 @@ PlayBattleAnim: ; cc0d6
ld a, [rSVBK]
push af
- ld a, 5
+ ld a, BANK(ActiveAnimObjects)
ld [rSVBK], a
call _PlayBattleAnim
@@ -163,7 +163,7 @@ BattleAnimRestoreHuds: ; cc1bb
ld a, [rSVBK]
push af
- ld a, $1
+ ld a, BANK(CurBattleMon) ; alternatively: BANK(TempMon), BANK(PartyMon1), several others
ld [rSVBK], a
ld hl, UpdateBattleHuds
@@ -232,8 +232,7 @@ ClearActorHud: ; cc207
ret
; cc220
-Functioncc220: ; cc220
-; Appears to be unused.
+Unreferenced_Functioncc220: ; cc220
xor a
ld [hBGMapMode], a
ld a, LOW(vBGMap0 tile $28)
@@ -258,15 +257,15 @@ BattleAnim_ClearCGB_OAMFlags: ; cc23d
bit 3, a
jr z, .delete
- ld hl, Sprites + 3
- ld c, (SpritesEnd - Sprites) / 4
+ ld hl, Sprite01Attributes
+ ld c, NUM_SPRITE_OAM_STRUCTS
.loop
ld a, [hl]
and $f0
ld [hli], a
+rept SPRITEOAMSTRUCT_LENGTH +- 1
inc hl
- inc hl
- inc hl
+endr
dec c
jr nz, .loop
ret
@@ -917,7 +916,7 @@ BattleAnimCmd_E7: ; cc5db (33:45db)
BattleAnimCmd_Transform: ; cc5dc (33:45dc)
ld a, [rSVBK]
push af
- ld a, 1
+ ld a, BANK(CurPartySpecies)
ld [rSVBK], a
ld a, [CurPartySpecies] ; CurPartySpecies
push af
@@ -973,9 +972,9 @@ BattleAnimCmd_RaiseSub: ; cc640 (33:4640)
ld a, [rSVBK]
push af
- ld a, 1
+ ld a, 1 ; unnecessary bankswitch?
ld [rSVBK], a
- xor a
+ xor a ; sScratch
call GetSRAMBank
GetSubstitutePic: ; cc64c
@@ -1047,9 +1046,9 @@ GetSubstitutePic: ; cc64c
BattleAnimCmd_MinimizeOpp: ; cc6cf (33:46cf)
ld a, [rSVBK]
push af
- ld a, $1
+ ld a, 1 ; unnecessary bankswitch?
ld [rSVBK], a
- xor a
+ xor a ; sScratch
call GetSRAMBank
call GetMinimizePic
call Request2bpp
@@ -1077,7 +1076,7 @@ GetMinimizePic: ; cc6e7 (33:46e7)
call CopyMinimizePic
ld hl, vTiles2 tile $00
ld de, sScratch
- lb bc, BANK(GetMinimizePic), $31
+ lb bc, BANK(GetMinimizePic), 7 * 7
ret
.player
@@ -1085,7 +1084,7 @@ GetMinimizePic: ; cc6e7 (33:46e7)
call CopyMinimizePic
ld hl, vTiles2 tile $31
ld de, sScratch
- lb bc, BANK(GetMinimizePic), $24
+ lb bc, BANK(GetMinimizePic), 6 * 6
ret
CopyMinimizePic: ; cc719 (33:4719)
@@ -1103,9 +1102,9 @@ INCBIN "gfx/battle/minimize.2bpp"
BattleAnimCmd_Minimize: ; cc735 (33:4735)
ld a, [rSVBK]
push af
- ld a, $1
+ ld a, 1 ; unnecessary bankswitch?
ld [rSVBK], a
- xor a
+ xor a ; sScratch
call GetSRAMBank
call GetMinimizePic
ld hl, vTiles0 tile $00
@@ -1118,7 +1117,7 @@ BattleAnimCmd_Minimize: ; cc735 (33:4735)
BattleAnimCmd_DropSub: ; cc750 (33:4750)
ld a, [rSVBK]
push af
- ld a, $1
+ ld a, BANK(CurPartySpecies)
ld [rSVBK], a
ld a, [CurPartySpecies] ; CurPartySpecies
@@ -1143,7 +1142,7 @@ BattleAnimCmd_DropSub: ; cc750 (33:4750)
BattleAnimCmd_BeatUp: ; cc776 (33:4776)
ld a, [rSVBK]
push af
- ld a, $1
+ ld a, BANK(CurPartySpecies)
ld [rSVBK], a
ld a, [CurPartySpecies] ; CurPartySpecies
push af
@@ -1207,7 +1206,7 @@ BattleAnimCmd_Sound: ; cc7cd (33:47cd)
srl a
ld [wSFXDuration], a
call .GetCryTrack
- and 3
+ maskbits NUM_NOISE_CHANS
ld [CryTracks], a ; CryTracks
ld e, a
@@ -1244,7 +1243,7 @@ BattleAnimCmd_Sound: ; cc7cd (33:47cd)
BattleAnimCmd_Cry: ; cc807 (33:4807)
call GetBattleAnimByte
- and 3
+ maskbits NUM_NOISE_CHANS
ld e, a
ld d, 0
ld hl, .CryData
@@ -1254,7 +1253,7 @@ endr
ld a, [rSVBK]
push af
- ld a, 1
+ ld a, BANK(EnemyMon) ; BattleMon is in WRAM0, but EnemyMon is in WRAMX
ld [rSVBK], a
ld a, [hBattleTurn]
@@ -1262,18 +1261,18 @@ endr
jr nz, .enemy
ld a, $f0
- ld [CryTracks], a ; CryTracks
- ld a, [BattleMonSpecies] ; BattleMonSpecies
+ ld [CryTracks], a
+ ld a, [BattleMonSpecies]
jr .done_cry_tracks
.enemy
ld a, $0f
- ld [CryTracks], a ; CryTracks
- ld a, [EnemyMonSpecies] ; EnemyMon
+ ld [CryTracks], a
+ ld a, [EnemyMonSpecies]
.done_cry_tracks
push hl
- call LoadCryHeader
+ call LoadCry
pop hl
jr c, .done
@@ -1310,7 +1309,7 @@ endr
ld a, 1
ld [wStereoPanningMask], a
- callfar _PlayCryHeader
+ callfar _PlayCry
.done
pop af
@@ -1431,7 +1430,7 @@ BattleAnim_SetBGPals: ; cc91a
ret z
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, wBGPals2
ld de, wBGPals1
@@ -1459,7 +1458,7 @@ BattleAnim_SetOBPals: ; cc94b
ret z
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wOBPals1)
ld [rSVBK], a
ld hl, wOBPals2 palette PAL_BATTLE_OB_GRAY
ld de, wOBPals1 palette PAL_BATTLE_OB_GRAY
diff --git a/engine/battle_anims/bg_effects.asm b/engine/battle_anims/bg_effects.asm
index bb8feb1f9..a7c2012e5 100644
--- a/engine/battle_anims/bg_effects.asm
+++ b/engine/battle_anims/bg_effects.asm
@@ -506,13 +506,13 @@ BattleBGEffect_HeadFollow: ; c8281 (32:4281)
push bc
call BGEffect_CheckBattleTurn
jr nz, .player_turn
- ld a, ANIM_OBJ_BA
+ ld a, ANIM_OBJ_PLAYERHEADFOLLOW
ld [wBattleAnimTemp0], a
ld a, 16 * 8 + 4
jr .okay
.player_turn
- ld a, ANIM_OBJ_BB
+ ld a, ANIM_OBJ_ENEMYHEADFOLLOW
ld [wBattleAnimTemp0], a
ld a, 6 * 8
.okay
@@ -2578,7 +2578,7 @@ BGEffects_LoadBGPal0_OBPal1: ; c8e52 (32:4e52)
ld h, a
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld a, h
push bc
@@ -2605,7 +2605,7 @@ BGEffects_LoadBGPal1_OBPal0: ; c8e7f (32:4e7f)
ld h, a
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld a, h
push bc
diff --git a/engine/battle_anims/engine.asm b/engine/battle_anims/core.asm
index 55adeae8c..55adeae8c 100755
--- a/engine/battle_anims/engine.asm
+++ b/engine/battle_anims/core.asm
diff --git a/engine/battle_anims/functions.asm b/engine/battle_anims/functions.asm
index ea9fb70b3..5e85ffdb0 100755
--- a/engine/battle_anims/functions.asm
+++ b/engine/battle_anims/functions.asm
@@ -428,9 +428,9 @@ GetBallAnimPal: ; cd249 (33:5249)
ld hl, BallColors
ld a, [rSVBK]
push af
- ld a, $1
+ ld a, BANK(CurItem)
ld [rSVBK], a
- ld a, [CurItem] ; CurItem
+ ld a, [CurItem]
ld e, a
pop af
ld [rSVBK], a
@@ -4083,18 +4083,19 @@ BattleAnim_IncAnonJumptableIndex: ; ce72c (33:672c)
ret
BattleAnim_Cosine: ; ce732 (33:6732)
- add $10
+; a = d * cos(a * pi/32)
+ add %010000
BattleAnim_Sine: ; ce734 (33:6734)
-; a = d sin a
- and $3f
- cp $20
+; a = d * sin(a * pi/32)
+ and %111111
+ cp %100000
jr nc, .negative
call .ApplySineWave
ld a, h
ret
.negative
- and $1f
+ and %011111
call .ApplySineWave
ld a, h
xor $ff
@@ -4111,7 +4112,7 @@ BattleAnim_Sine: ; ce734 (33:6734)
ld e, [hl]
inc hl
ld d, [hl]
- ld hl, $0
+ ld hl, 0
.multiply
srl a
jr nc, .even
diff --git a/engine/battle_anims/getpokeballwobble.asm b/engine/battle_anims/getpokeballwobble.asm
index 7fb4d3e38..2bc53d798 100755
--- a/engine/battle_anims/getpokeballwobble.asm
+++ b/engine/battle_anims/getpokeballwobble.asm
@@ -8,7 +8,7 @@ GetPokeBallWobble: ; f971 (3:7971)
ld d, a
push de
- ld a, 1 ; BANK(Buffer2)
+ ld a, BANK(Buffer2)
ld [rSVBK], a
ld a, [Buffer2]
diff --git a/engine/billspc.asm b/engine/billspc.asm
index f94f495c6..5fa590c41 100755
--- a/engine/billspc.asm
+++ b/engine/billspc.asm
@@ -136,7 +136,7 @@ _DepositPKMN: ; e2391 (38:6391)
jp c, BillsPCDepositFuncCancel
ld a, [wMenuCursorY]
dec a
- and $3
+ and %11
ld e, a
ld d, 0
ld hl, BillsPCDepositJumptable
@@ -229,15 +229,14 @@ BillsPCDepositFuncCancel: ; e2537 (38:6537)
; e253d (38:653d)
BillsPCDepositMenuDataHeader: ; 0xe253d (38:653d)
- db $40 ; flags
- db 04, 09 ; start coords
- db 13, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 9, 4, SCREEN_WIDTH - 1, 13
dw .MenuData2
db 1 ; default option
; 0xe2545
.MenuData2: ; 0xe2545 (38:6545)
- db $80 ; flags
+ db STATICMENU_CURSOR ; flags
db 4 ; items
db "DEPOSIT@"
db "STATS@"
@@ -245,8 +244,7 @@ BillsPCDepositMenuDataHeader: ; 0xe253d (38:653d)
db "CANCEL@"
; 0xe2564 (38:6564)
-BillsPC_ClearThreeBoxes: ; e2564
-; unreferenced
+Unreferenced_BillsPCClearThreeBoxes: ; e2564
hlcoord 0, 0
ld b, 4
ld c, 8
@@ -401,7 +399,7 @@ BillsPC_Withdraw: ; e2675 (38:6675)
jp c, .cancel
ld a, [wMenuCursorY]
dec a
- and 3
+ and %11
ld e, a
ld d, 0
ld hl, .dw
@@ -490,15 +488,14 @@ BillsPC_Withdraw: ; e2675 (38:6675)
; e2731 (38:6731)
.MenuDataHeader: ; 0xe2731
- db $40 ; flags
- db 04, 09 ; start coords
- db 13, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 9, 4, SCREEN_WIDTH - 1, 13
dw .MenuData
db 1 ; default option
; 0xe2739
.MenuData: ; 0xe2739
- db $80 ; flags
+ db STATICMENU_CURSOR ; flags
db 4 ; items
db "WITHDRAW@"
db "STATS@"
@@ -663,7 +660,7 @@ _MovePKMNWithoutMail: ; e2759
jp c, .Cancel
ld a, [wMenuCursorY]
dec a
- and 3
+ and %11
ld e, a
ld d, 0
ld hl, .Jumptable2
@@ -714,15 +711,14 @@ _MovePKMNWithoutMail: ; e2759
; e28c3
.MenuDataHeader: ; 0xe28c3
- db $40 ; flags
- db 04, 09 ; start coords
- db 13, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 9, 4, SCREEN_WIDTH - 1, 13
dw .MenuData2
db 1 ; default option
; 0xe28cb
.MenuData2: ; 0xe28cb
- db $80 ; flags
+ db STATICMENU_CURSOR ; flags
db 3 ; items
db "MOVE@"
db "STATS@"
@@ -1335,11 +1331,11 @@ BillsPC_RefreshTextboxes: ; e2c2c (38:6c2c)
jr z, .boxfail
ld bc, sBoxMonNicknames - sBox
add hl, bc
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
ld a, e
call AddNTimes
ld de, StringBuffer1
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
call CloseSRAM
pop hl
@@ -1361,11 +1357,11 @@ BillsPC_RefreshTextboxes: ; e2c2c (38:6c2c)
and a
jr z, .partyfail
ld hl, PartyMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
ld a, e
call AddNTimes
ld de, StringBuffer1
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
pop hl
ld de, StringBuffer1
@@ -1387,11 +1383,11 @@ BillsPC_RefreshTextboxes: ; e2c2c (38:6c2c)
and a
jr z, .sBoxFail
ld hl, sBoxMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
ld a, e
call AddNTimes
ld de, StringBuffer1
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
call CloseSRAM
pop hl
@@ -1502,7 +1498,7 @@ BillsPC_UpdateSelectionCursor: ; e2e01 (38:6e01)
.place_cursor
ld hl, .OAM
- ld de, Sprites
+ ld de, Sprite01
.loop
ld a, [hl]
cp -1
@@ -1512,9 +1508,9 @@ BillsPC_UpdateSelectionCursor: ; e2e01 (38:6e01)
swap a
add [hl]
inc hl
- ld [de], a
+ ld [de], a ; y
inc de
-rept 3
+rept SPRITEOAMSTRUCT_LENGTH +- 1
ld a, [hli]
ld [de], a
inc de
@@ -1523,36 +1519,36 @@ endr
; e2e2b (38:6e2b)
.OAM: ; e2e2b
- dsprite 4, 6, 10, 0, $00, $00
- dsprite 4, 6, 11, 0, $00, $00
- dsprite 4, 6, 12, 0, $00, $00
- dsprite 4, 6, 13, 0, $00, $00
- dsprite 4, 6, 14, 0, $00, $00
- dsprite 4, 6, 15, 0, $00, $00
- dsprite 4, 6, 16, 0, $00, $00
- dsprite 4, 6, 17, 0, $00, $00
- dsprite 4, 6, 18, 0, $00, $00
- dsprite 4, 6, 18, 7, $00, $00
- dsprite 7, 1, 10, 0, $00, $40
- dsprite 7, 1, 11, 0, $00, $40
- dsprite 7, 1, 12, 0, $00, $40
- dsprite 7, 1, 13, 0, $00, $40
- dsprite 7, 1, 14, 0, $00, $40
- dsprite 7, 1, 15, 0, $00, $40
- dsprite 7, 1, 16, 0, $00, $40
- dsprite 7, 1, 17, 0, $00, $40
- dsprite 7, 1, 18, 0, $00, $40
- dsprite 7, 1, 18, 7, $00, $40
- dsprite 5, 6, 9, 6, $01, $00
- dsprite 6, 1, 9, 6, $01, $40
- dsprite 5, 6, 19, 1, $01, $20
- dsprite 6, 1, 19, 1, $01, $60
+ dsprite 4, 6, 10, 0, $00, 0
+ dsprite 4, 6, 11, 0, $00, 0
+ dsprite 4, 6, 12, 0, $00, 0
+ dsprite 4, 6, 13, 0, $00, 0
+ dsprite 4, 6, 14, 0, $00, 0
+ dsprite 4, 6, 15, 0, $00, 0
+ dsprite 4, 6, 16, 0, $00, 0
+ dsprite 4, 6, 17, 0, $00, 0
+ dsprite 4, 6, 18, 0, $00, 0
+ dsprite 4, 6, 18, 7, $00, 0
+ dsprite 7, 1, 10, 0, $00, 0 | Y_FLIP
+ dsprite 7, 1, 11, 0, $00, 0 | Y_FLIP
+ dsprite 7, 1, 12, 0, $00, 0 | Y_FLIP
+ dsprite 7, 1, 13, 0, $00, 0 | Y_FLIP
+ dsprite 7, 1, 14, 0, $00, 0 | Y_FLIP
+ dsprite 7, 1, 15, 0, $00, 0 | Y_FLIP
+ dsprite 7, 1, 16, 0, $00, 0 | Y_FLIP
+ dsprite 7, 1, 17, 0, $00, 0 | Y_FLIP
+ dsprite 7, 1, 18, 0, $00, 0 | Y_FLIP
+ dsprite 7, 1, 18, 7, $00, 0 | Y_FLIP
+ dsprite 5, 6, 9, 6, $01, 0
+ dsprite 6, 1, 9, 6, $01, 0 | Y_FLIP
+ dsprite 5, 6, 19, 1, $01, 0 | X_FLIP
+ dsprite 6, 1, 19, 1, $01, 0 | X_FLIP | Y_FLIP
db -1
; e2e8c
BillsPC_UpdateInsertCursor: ; e2e8c
ld hl, .OAM
- ld de, Sprites
+ ld de, Sprite01
.loop
ld a, [hl]
cp -1
@@ -1562,9 +1558,9 @@ BillsPC_UpdateInsertCursor: ; e2e8c
swap a
add [hl]
inc hl
- ld [de], a
+ ld [de], a ; y
inc de
-rept 3
+rept SPRITEOAMSTRUCT_LENGTH +- 1
ld a, [hli]
ld [de], a
inc de
@@ -1573,20 +1569,20 @@ endr
; e2eac
.OAM: ; e2eac
- dsprite 4, 7, 10, 0, $06, $00
- dsprite 5, 3, 11, 0, $00, $40
- dsprite 5, 3, 12, 0, $00, $40
- dsprite 5, 3, 13, 0, $00, $40
- dsprite 5, 3, 14, 0, $00, $40
- dsprite 5, 3, 15, 0, $00, $40
- dsprite 5, 3, 16, 0, $00, $40
- dsprite 5, 3, 17, 0, $00, $40
- dsprite 5, 3, 18, 0, $00, $40
- dsprite 4, 7, 19, 0, $07, $00
+ dsprite 4, 7, 10, 0, $06, 0
+ dsprite 5, 3, 11, 0, $00, 0 | Y_FLIP
+ dsprite 5, 3, 12, 0, $00, 0 | Y_FLIP
+ dsprite 5, 3, 13, 0, $00, 0 | Y_FLIP
+ dsprite 5, 3, 14, 0, $00, 0 | Y_FLIP
+ dsprite 5, 3, 15, 0, $00, 0 | Y_FLIP
+ dsprite 5, 3, 16, 0, $00, 0 | Y_FLIP
+ dsprite 5, 3, 17, 0, $00, 0 | Y_FLIP
+ dsprite 5, 3, 18, 0, $00, 0 | Y_FLIP
+ dsprite 4, 7, 19, 0, $07, 0
db -1
; e2ed5
-BillsPC_UnusedFillBox: ; e2ed5
+Unreferenced_BillsPC_FillBox: ; e2ed5
.row
push bc
push hl
@@ -1823,13 +1819,13 @@ DepositPokemon: ; e307c (38:707c)
call GetNick
ld a, PC_DEPOSIT
ld [wPokemonWithdrawDepositParameter], a
- predef SentGetPkmnIntoFromBox
+ predef SendGetPkmnIntoFromBox
jr c, .asm_boxisfull
xor a
ld [wPokemonWithdrawDepositParameter], a
farcall RemoveMonFromPartyOrBox
ld a, [CurPartySpecies]
- call PlayCry
+ call PlayMonCry
hlcoord 0, 0
lb bc, 15, 8
call ClearBox
@@ -1878,13 +1874,13 @@ TryWithdrawPokemon: ; e30fa (38:70fa)
call CloseSRAM
xor a
ld [wPokemonWithdrawDepositParameter], a
- predef SentGetPkmnIntoFromBox
+ predef SendGetPkmnIntoFromBox
jr c, .PartyFull
ld a, PC_DEPOSIT
ld [wPokemonWithdrawDepositParameter], a
farcall RemoveMonFromPartyOrBox
ld a, [CurPartySpecies]
- call PlayCry
+ call PlayMonCry
hlcoord 0, 0
lb bc, 15, 8
call ClearBox
@@ -1938,7 +1934,7 @@ ReleasePKMN_ByePKMN: ; e3180 (38:7180)
jr c, .skip_cry
ld e, c
ld d, b
- call PlayCryHeader
+ call PlayCry
.skip_cry
ld a, [CurPartySpecies]
@@ -2104,7 +2100,7 @@ MovePKMNWitoutMail_InsertMon: ; e31e7
ld hl, wBillsPC_BackupScrollPosition
add [hl]
ld [CurPartyMon], a
- ld a, $1
+ ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxSpecies
call CopySpeciesToTemp
@@ -2175,11 +2171,11 @@ CopySpeciesToTemp: ; e3357 (38:7357)
ret
CopyNicknameToTemp: ; e3363 (38:7363)
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
ld a, [CurPartyMon]
call AddNTimes
ld de, wBufferMonNick
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
ret
@@ -2333,15 +2329,14 @@ BillsPC_ClearTilemap: ; e35e2 (38:75e2)
; e35f1 (38:75f1)
_ChangeBox_menudataheader: ; 0xe35f1
- db $40 ; flags
- db 05, 01 ; start coords
- db 12, 09 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 1, 5, 9, 12
dw .menudata2
db 1 ; default option
; 0xe35f9
.menudata2 ; 0xe35f9
- db $22 ; flags
+ db MENU_UNUSED_1 | MENU_UNUSED_3 ; flags
db 4, 0
db 1
dba .boxes
@@ -2559,18 +2554,17 @@ BillsPC_ChangeBoxSubmenu: ; e36f9 (38:76f9)
ret
; e3778 (38:7778)
- hlcoord 11, 7 ; XXX
+ hlcoord 11, 7 ; unused
.MenuDataHeader: ; 0xe377b
- db $40 ; flags
- db 04, 11 ; start coords
- db 13, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 11, 4, SCREEN_WIDTH - 1, 13
dw .MenuData2
db 1 ; default option
; 0xe3783
.MenuData2: ; 0xe3783
- db $80 ; flags
+ db STATICMENU_CURSOR ; flags
db 4 ; items
db "SWITCH@"
db "NAME@"
diff --git a/engine/billspctop.asm b/engine/billspctop.asm
index c36cbe45d..ac70082d6 100755
--- a/engine/billspctop.asm
+++ b/engine/billspctop.asm
@@ -69,14 +69,13 @@ _BillsPC: ; e3fd
ret
.MenuDataHeader: ; 0xe46f
- db $40 ; flags
- db 00, 00 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw .MenuData2
db 1 ; default option
.MenuData2: ; 0xe477
- db $80 ; flags
+ db STATICMENU_CURSOR ; flags
db 0 ; items
dw .items
dw PlaceMenuStrings
@@ -143,7 +142,7 @@ BillsPC_DepositMenu: ; e4fe (3:64fe)
and a
ret
-Functione512: ; unused
+Unreferenced_Functione512:
ld a, [PartyCount]
and a
jr z, .no_pkmn
@@ -212,7 +211,7 @@ BillsPC_WithdrawMenu: ; e559 (3:6559)
and a
ret
-Functione56d: ; unused
+Unreferenced_Functione56d:
ld a, [PartyCount]
cp PARTY_LENGTH
jr nc, .asm_e576
@@ -268,7 +267,7 @@ CopyBoxmonToTempMon: ; e5bb
call CloseSRAM
ret
-Functione5d9: ; unreferenced
+Unreferenced_Functione5d9:
ld a, [wCurBox]
cp b
jr z, .same_box
diff --git a/engine/breeding.asm b/engine/breeding.asm
index 234e05448..b16747089 100755
--- a/engine/breeding.asm
+++ b/engine/breeding.asm
@@ -232,7 +232,7 @@ HatchEggs: ; 16f70 (5:6f70)
push de
farcall SetEggMonCaughtData
- farcall TrainerRankings_EggsHatched
+ farcall StubbedTrainerRankings_EggsHatched
ld a, [CurPartyMon]
ld hl, PartyMon1Species
ld bc, PARTYMON_STRUCT_LENGTH
@@ -320,7 +320,7 @@ HatchEggs: ; 16f70 (5:6f70)
call PrintText
ld a, [CurPartyMon]
ld hl, PartyMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call AddNTimes
ld d, h
ld e, l
@@ -345,7 +345,7 @@ HatchEggs: ; 16f70 (5:6f70)
.nonickname
ld hl, StringBuffer1
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
.next ; 1707d (5:707d)
@@ -659,7 +659,7 @@ GetHatchlingFrontpic: ; 1723c (5:723c)
ld hl, BattleMonDVs
predef GetUnownLetter
pop de
- predef_jump GetAnimatedFrontpicPredef
+ predef_jump GetAnimatedFrontpic
Hatch_UpdateFrontpicBGMapCenter: ; 17254 (5:7254)
push af
@@ -726,11 +726,11 @@ EggHatch_AnimationSequence: ; 1728f (5:728f)
ld c, 80
call DelayFrames
xor a
- ld [wcf64], a
+ ld [wFrameCounter], a
ld a, [hSCX]
ld b, a
.outerloop
- ld hl, wcf64
+ ld hl, wFrameCounter
ld a, [hl]
inc [hl]
cp 8
@@ -791,7 +791,7 @@ Hatch_LoadFrontpicPal: ; 17363 (5:7363)
jp GetSGBLayout
EggHatch_CrackShell: ; 1736d (5:736d)
- ld a, [wcf64]
+ ld a, [wFrameCounter]
dec a
and $7
cp $7
@@ -860,18 +860,22 @@ Hatch_InitShellFragments: ; 173b3 (5:73b3)
ret
; 173ef (5:73ef)
+shell_fragment: MACRO
+; y tile, y pxl, x tile, x pxl, frameset offset, ???
+ db (\1 * 8) % $100 + \2, (\3 * 8) % $100 + \4, \5 - SPRITE_ANIM_FRAMESET_EGG_HATCH_1, \6
+ENDM
+
.SpriteData: ; 173ef
-; Probably OAM.
- dsprite 10, 4, 9, 0, $00, $3c
- dsprite 11, 4, 9, 0, $01, $04
- dsprite 10, 4, 10, 0, $00, $30
- dsprite 11, 4, 10, 0, $01, $10
- dsprite 10, 4, 11, 0, $02, $24
- dsprite 11, 4, 11, 0, $03, $1c
- dsprite 10, 0, 9, 4, $00, $36
- dsprite 12, 0, 9, 4, $01, $0a
- dsprite 10, 0, 10, 4, $02, $2a
- dsprite 12, 0, 10, 4, $03, $16
+ shell_fragment 10, 4, 9, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_1, $3c
+ shell_fragment 11, 4, 9, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_2, $04
+ shell_fragment 10, 4, 10, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_1, $30
+ shell_fragment 11, 4, 10, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_2, $10
+ shell_fragment 10, 4, 11, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_3, $24
+ shell_fragment 11, 4, 11, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_4, $1c
+ shell_fragment 10, 0, 9, 4, SPRITE_ANIM_FRAMESET_EGG_HATCH_1, $36
+ shell_fragment 12, 0, 9, 4, SPRITE_ANIM_FRAMESET_EGG_HATCH_2, $0a
+ shell_fragment 10, 0, 10, 4, SPRITE_ANIM_FRAMESET_EGG_HATCH_3, $2a
+ shell_fragment 12, 0, 10, 4, SPRITE_ANIM_FRAMESET_EGG_HATCH_4, $16
db -1
; 17418
@@ -887,7 +891,7 @@ Special_DayCareMon1: ; 17421
ld hl, DayCareMon1Text
call PrintText
ld a, [wBreedMon1Species]
- call PlayCry
+ call PlayMonCry
ld a, [wDayCareLady]
bit 0, a
jr z, DayCareMonCursor
@@ -900,7 +904,7 @@ Special_DayCareMon2: ; 17440
ld hl, DayCareMon2Text
call PrintText
ld a, [wBreedMon2Species]
- call PlayCry
+ call PlayMonCry
ld a, [wDayCareMan]
bit 0, a
jr z, DayCareMonCursor
@@ -981,8 +985,7 @@ DayCareMonCompatibilityText: ; 1746c
db "@"
; 0x174b5
-DayCareMonPrintEmptyString: ; 174b5
-; unreferenced
+Unreferenced_DayCareMonPrintEmptyString: ; 174b5
ld hl, .string
ret
; 174b9
diff --git a/engine/buy_sell_toss.asm b/engine/buy_sell_toss.asm
index 37bee86b1..ff2bd2967 100755
--- a/engine/buy_sell_toss.asm
+++ b/engine/buy_sell_toss.asm
@@ -214,25 +214,22 @@ BuySell_DisplaySubtotal: ; 250d1
; 250ed
TossItem_MenuDataHeader: ; 0x250ed
- db $40 ; flags
- db 09, 15 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 15, 9, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw ret_25097
db 0 ; default option
; 0x250f5
BuyItem_MenuDataHeader: ; 0x250f5
- db $40 ; flags
- db 15, 07 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 15, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw DisplayPurchasePrice
db -1 ; default option
; 0x250fd
SellItem_MenuDataHeader: ; 0x250fd
- db $40 ; flags
- db 15, 07 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 15, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw DisplaySellingPrice
db 0 ; default option
; 0x25105
diff --git a/engine/card_flip.asm b/engine/card_flip.asm
index 158f3fa05..ae90b124a 100755
--- a/engine/card_flip.asm
+++ b/engine/card_flip.asm
@@ -1,7 +1,15 @@
CARDFLIP_LIGHT_OFF EQU $ef
CARDFLIP_LIGHT_ON EQU $f5
+
CARDFLIP_DECK_SIZE EQU 4 * 6
+; two labels below called from inside ./dummy_game.asm
+Unknown_e00ed: ; e00ed (38:40ed)
+; Graphics for an unused Game Corner
+; game were meant to be here.
+ret_e00ed: ; e00ed (38:40ed)
+ ret
+
_CardFlip: ; e00ee (38:40ee)
ld hl, Options
set 4, [hl]
@@ -25,11 +33,11 @@ _CardFlip: ; e00ee (38:40ee)
ld de, vTiles0 tile $00
call Decompress
ld hl, CardFlipOffButtonGFX
- ld de, vTiles1 tile $6f
+ ld de, vTiles0 tile CARDFLIP_LIGHT_OFF
ld bc, 1 tiles
call CopyBytes
ld hl, CardFlipOnButtonGFX
- ld de, vTiles1 tile $75
+ ld de, vTiles0 tile CARDFLIP_LIGHT_ON
ld bc, 1 tiles
call CopyBytes
@@ -593,23 +601,23 @@ CardFlip_CopyToBox: ; e04f7 (38:44f7)
; e0509 (38:4509)
CardFlip_CopyOAM: ; e0509
- ld de, Sprites
+ ld de, Sprite01
ld a, [hli]
.loop
push af
ld a, [hli]
add b
- ld [de], a
+ ld [de], a ; y
inc de
ld a, [hli]
add c
- ld [de], a
+ ld [de], a ; x
inc de
ld a, [hli]
- ld [de], a
+ ld [de], a ; tile id
inc de
ld a, [hli]
- ld [de], a
+ ld [de], a ; attributes
inc de
pop af
dec a
@@ -618,11 +626,11 @@ CardFlip_CopyOAM: ; e0509
; e0521
CardFlip_ShiftDigitsLeftTwoPixels: ; e0521 (38:4521)
- ld de, vTiles1 tile ("0" & $7f)
- ld hl, vTiles1 tile ("0" & $7f) + 2
+ ld de, vTiles0 tile "0"
+ ld hl, vTiles0 tile "0" + 2
ld bc, 10 tiles - 2
call CopyBytes
- ld hl, vTiles1 tile $7f + 1 tiles - 2
+ ld hl, vTiles0 tile "9" + 1 tiles - 2
xor a
ld [hli], a
ld [hl], a
@@ -1210,29 +1218,29 @@ PlaceOAMCardBorder: ; e0849
.SpriteData: ; e0853
db 18
- dsprite 0, 0, 0, 0, $04, $00
- dsprite 0, 0, 1, 0, $06, $00
- dsprite 0, 0, 2, 0, $06, $00
- dsprite 0, 0, 3, 0, $06, $00
- dsprite 0, 0, 4, 0, $04, $20
+ dsprite 0, 0, 0, 0, $04, 0
+ dsprite 0, 0, 1, 0, $06, 0
+ dsprite 0, 0, 2, 0, $06, 0
+ dsprite 0, 0, 3, 0, $06, 0
+ dsprite 0, 0, 4, 0, $04, 0 | X_FLIP
- dsprite 1, 0, 0, 0, $05, $00
- dsprite 1, 0, 4, 0, $05, $20
+ dsprite 1, 0, 0, 0, $05, 0
+ dsprite 1, 0, 4, 0, $05, 0 | X_FLIP
- dsprite 2, 0, 0, 0, $05, $00
- dsprite 2, 0, 4, 0, $05, $20
+ dsprite 2, 0, 0, 0, $05, 0
+ dsprite 2, 0, 4, 0, $05, 0 | X_FLIP
- dsprite 3, 0, 0, 0, $05, $00
- dsprite 3, 0, 4, 0, $05, $20
+ dsprite 3, 0, 0, 0, $05, 0
+ dsprite 3, 0, 4, 0, $05, 0 | X_FLIP
dsprite 4, 0, 0, 0, $05, $00
- dsprite 4, 0, 4, 0, $05, $20
+ dsprite 4, 0, 4, 0, $05, 0 | X_FLIP
- dsprite 5, 0, 0, 0, $04, $40
- dsprite 5, 0, 1, 0, $06, $40
- dsprite 5, 0, 2, 0, $06, $40
- dsprite 5, 0, 3, 0, $06, $40
- dsprite 5, 0, 4, 0, $04, $60
+ dsprite 5, 0, 0, 0, $04, 0 | Y_FLIP
+ dsprite 5, 0, 1, 0, $06, 0 | Y_FLIP
+ dsprite 5, 0, 2, 0, $06, 0 | Y_FLIP
+ dsprite 5, 0, 3, 0, $06, 0 | Y_FLIP
+ dsprite 5, 0, 4, 0, $04, 0 | X_FLIP | Y_FLIP
; e089c
ChooseCard_HandleJoypad: ; e089c
@@ -1471,145 +1479,145 @@ ENDM
.SingleTile: ; e0a41
db 6
- dsprite 0, 0, -1, 7, $00, $80
- dsprite 0, 0, 0, 0, $02, $80
- dsprite 0, 0, 1, 0, $03, $80
- dsprite 0, 5, -1, 7, $00, $c0
- dsprite 0, 5, 0, 0, $02, $c0
- dsprite 0, 5, 1, 0, $03, $80
+ dsprite 0, 0, -1, 7, $00, 0 | PRIORITY
+ dsprite 0, 0, 0, 0, $02, 0 | PRIORITY
+ dsprite 0, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 0, 5, -1, 7, $00, 0 | Y_FLIP | PRIORITY
+ dsprite 0, 5, 0, 0, $02, 0 | Y_FLIP | PRIORITY
+ dsprite 0, 5, 1, 0, $03, 0 | PRIORITY
.PokeGroup: ; e0a5a
db 26
- dsprite 0, 0, -1, 7, $00, $80
- dsprite 0, 0, 0, 0, $02, $80
- dsprite 0, 0, 1, 0, $00, $a0
- dsprite 1, 0, -1, 7, $01, $80
- dsprite 1, 0, 1, 0, $01, $a0
- dsprite 2, 0, -1, 7, $01, $80
- dsprite 2, 0, 1, 0, $03, $80
- dsprite 3, 0, -1, 7, $01, $80
- dsprite 3, 0, 1, 0, $03, $80
- dsprite 4, 0, -1, 7, $01, $80
- dsprite 4, 0, 1, 0, $03, $80
- dsprite 5, 0, -1, 7, $01, $80
- dsprite 5, 0, 1, 0, $03, $80
- dsprite 6, 0, -1, 7, $01, $80
- dsprite 6, 0, 1, 0, $03, $80
- dsprite 7, 0, -1, 7, $01, $80
- dsprite 7, 0, 1, 0, $03, $80
- dsprite 8, 0, -1, 7, $01, $80
- dsprite 8, 0, 1, 0, $03, $80
- dsprite 9, 0, -1, 7, $01, $80
- dsprite 9, 0, 1, 0, $03, $80
- dsprite 10, 0, -1, 7, $01, $80
- dsprite 10, 0, 1, 0, $03, $80
- dsprite 10, 1, -1, 7, $00, $c0
- dsprite 10, 1, 0, 0, $02, $c0
- dsprite 10, 1, 1, 0, $03, $80
+ dsprite 0, 0, -1, 7, $00, 0 | PRIORITY
+ dsprite 0, 0, 0, 0, $02, 0 | PRIORITY
+ dsprite 0, 0, 1, 0, $00, 0 | X_FLIP | PRIORITY
+ dsprite 1, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 1, 0, 1, 0, $01, 0 | X_FLIP | PRIORITY
+ dsprite 2, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 2, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 3, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 3, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 4, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 4, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 5, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 5, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 6, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 6, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 7, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 7, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 8, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 8, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 9, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 9, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 10, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 10, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 10, 1, -1, 7, $00, 0 | Y_FLIP | PRIORITY
+ dsprite 10, 1, 0, 0, $02, 0 | Y_FLIP | PRIORITY
+ dsprite 10, 1, 1, 0, $03, 0 | PRIORITY
.NumGroup: ; e0ac3
db 20
- dsprite 0, 0, -1, 7, $00, $80
- dsprite 0, 0, 0, 0, $02, $80
- dsprite 0, 0, 1, 0, $02, $80
- dsprite 0, 0, 2, 0, $03, $80
- dsprite 0, 0, 3, 0, $02, $80
- dsprite 0, 0, 4, 0, $03, $80
- dsprite 0, 0, 5, 0, $02, $80
- dsprite 0, 0, 6, 0, $03, $80
- dsprite 0, 0, 7, 0, $02, $80
- dsprite 0, 0, 8, 0, $03, $80
- dsprite 0, 5, -1, 7, $00, $c0
- dsprite 0, 5, 0, 0, $02, $c0
- dsprite 0, 5, 1, 0, $02, $c0
- dsprite 0, 5, 2, 0, $03, $80
- dsprite 0, 5, 3, 0, $02, $c0
- dsprite 0, 5, 4, 0, $03, $80
- dsprite 0, 5, 5, 0, $02, $c0
- dsprite 0, 5, 6, 0, $03, $80
- dsprite 0, 5, 7, 0, $02, $c0
- dsprite 0, 5, 8, 0, $03, $80
+ dsprite 0, 0, -1, 7, $00, 0 | PRIORITY
+ dsprite 0, 0, 0, 0, $02, 0 | PRIORITY
+ dsprite 0, 0, 1, 0, $02, 0 | PRIORITY
+ dsprite 0, 0, 2, 0, $03, 0 | PRIORITY
+ dsprite 0, 0, 3, 0, $02, 0 | PRIORITY
+ dsprite 0, 0, 4, 0, $03, 0 | PRIORITY
+ dsprite 0, 0, 5, 0, $02, 0 | PRIORITY
+ dsprite 0, 0, 6, 0, $03, 0 | PRIORITY
+ dsprite 0, 0, 7, 0, $02, 0 | PRIORITY
+ dsprite 0, 0, 8, 0, $03, 0 | PRIORITY
+ dsprite 0, 5, -1, 7, $00, 0 | Y_FLIP | PRIORITY
+ dsprite 0, 5, 0, 0, $02, 0 | Y_FLIP | PRIORITY
+ dsprite 0, 5, 1, 0, $02, 0 | Y_FLIP | PRIORITY
+ dsprite 0, 5, 2, 0, $03, 0 | PRIORITY
+ dsprite 0, 5, 3, 0, $02, 0 | Y_FLIP | PRIORITY
+ dsprite 0, 5, 4, 0, $03, 0 | PRIORITY
+ dsprite 0, 5, 5, 0, $02, 0 | Y_FLIP | PRIORITY
+ dsprite 0, 5, 6, 0, $03, 0 | PRIORITY
+ dsprite 0, 5, 7, 0, $02, 0 | Y_FLIP | PRIORITY
+ dsprite 0, 5, 8, 0, $03, 0 | PRIORITY
.NumGroupPair: ; e0b14
db 30
- dsprite 0, 0, 0, 0, $00, $80
- dsprite 0, 0, 1, 0, $02, $80
- dsprite 0, 0, 2, 0, $02, $80
- dsprite 0, 0, 3, 0, $03, $80
- dsprite 0, 0, 4, 0, $02, $80
- dsprite 0, 0, 5, 0, $03, $80
- dsprite 0, 0, 6, 0, $02, $80
- dsprite 0, 0, 7, 0, $03, $80
- dsprite 0, 0, 8, 0, $02, $80
- dsprite 0, 0, 9, 0, $03, $80
- dsprite 1, 0, 0, 0, $01, $80
- dsprite 1, 0, 3, 0, $03, $80
- dsprite 1, 0, 5, 0, $03, $80
- dsprite 1, 0, 7, 0, $03, $80
- dsprite 1, 0, 9, 0, $03, $80
- dsprite 2, 0, 0, 0, $01, $80
- dsprite 2, 0, 3, 0, $03, $80
- dsprite 2, 0, 5, 0, $03, $80
- dsprite 2, 0, 7, 0, $03, $80
- dsprite 2, 0, 9, 0, $03, $80
- dsprite 2, 1, 0, 0, $00, $c0
- dsprite 2, 1, 1, 0, $02, $c0
- dsprite 2, 1, 2, 0, $02, $c0
- dsprite 2, 1, 3, 0, $03, $80
- dsprite 2, 1, 4, 0, $03, $80
- dsprite 2, 1, 5, 0, $03, $80
- dsprite 2, 1, 6, 0, $03, $80
- dsprite 2, 1, 7, 0, $03, $80
- dsprite 2, 1, 8, 0, $03, $80
- dsprite 2, 1, 9, 0, $03, $80
+ dsprite 0, 0, 0, 0, $00, 0 | PRIORITY
+ dsprite 0, 0, 1, 0, $02, 0 | PRIORITY
+ dsprite 0, 0, 2, 0, $02, 0 | PRIORITY
+ dsprite 0, 0, 3, 0, $03, 0 | PRIORITY
+ dsprite 0, 0, 4, 0, $02, 0 | PRIORITY
+ dsprite 0, 0, 5, 0, $03, 0 | PRIORITY
+ dsprite 0, 0, 6, 0, $02, 0 | PRIORITY
+ dsprite 0, 0, 7, 0, $03, 0 | PRIORITY
+ dsprite 0, 0, 8, 0, $02, 0 | PRIORITY
+ dsprite 0, 0, 9, 0, $03, 0 | PRIORITY
+ dsprite 1, 0, 0, 0, $01, 0 | PRIORITY
+ dsprite 1, 0, 3, 0, $03, 0 | PRIORITY
+ dsprite 1, 0, 5, 0, $03, 0 | PRIORITY
+ dsprite 1, 0, 7, 0, $03, 0 | PRIORITY
+ dsprite 1, 0, 9, 0, $03, 0 | PRIORITY
+ dsprite 2, 0, 0, 0, $01, 0 | PRIORITY
+ dsprite 2, 0, 3, 0, $03, 0 | PRIORITY
+ dsprite 2, 0, 5, 0, $03, 0 | PRIORITY
+ dsprite 2, 0, 7, 0, $03, 0 | PRIORITY
+ dsprite 2, 0, 9, 0, $03, 0 | PRIORITY
+ dsprite 2, 1, 0, 0, $00, 0 | Y_FLIP | PRIORITY
+ dsprite 2, 1, 1, 0, $02, 0 | Y_FLIP | PRIORITY
+ dsprite 2, 1, 2, 0, $02, 0 | Y_FLIP | PRIORITY
+ dsprite 2, 1, 3, 0, $03, 0 | PRIORITY
+ dsprite 2, 1, 4, 0, $03, 0 | PRIORITY
+ dsprite 2, 1, 5, 0, $03, 0 | PRIORITY
+ dsprite 2, 1, 6, 0, $03, 0 | PRIORITY
+ dsprite 2, 1, 7, 0, $03, 0 | PRIORITY
+ dsprite 2, 1, 8, 0, $03, 0 | PRIORITY
+ dsprite 2, 1, 9, 0, $03, 0 | PRIORITY
.PokeGroupPair: ; e0b8d
db 38
- dsprite 0, 0, -1, 7, $00, $80
- dsprite 0, 0, 3, 0, $00, $a0
- dsprite 1, 0, -1, 7, $01, $80
- dsprite 1, 0, 3, 0, $01, $a0
- dsprite 2, 0, -1, 7, $01, $80
- dsprite 2, 0, 3, 0, $01, $a0
- dsprite 3, 0, -1, 7, $01, $80
- dsprite 3, 0, 1, 0, $03, $80
- dsprite 3, 0, 3, 0, $03, $80
- dsprite 4, 0, -1, 7, $01, $80
- dsprite 4, 0, 1, 0, $03, $80
- dsprite 4, 0, 3, 0, $03, $80
- dsprite 5, 0, -1, 7, $01, $80
- dsprite 5, 0, 1, 0, $03, $80
- dsprite 5, 0, 3, 0, $03, $80
- dsprite 6, 0, -1, 7, $01, $80
- dsprite 6, 0, 1, 0, $03, $80
- dsprite 6, 0, 3, 0, $03, $80
- dsprite 7, 0, -1, 7, $01, $80
- dsprite 7, 0, 1, 0, $03, $80
- dsprite 7, 0, 3, 0, $03, $80
- dsprite 8, 0, -1, 7, $01, $80
- dsprite 8, 0, 1, 0, $03, $80
- dsprite 8, 0, 3, 0, $03, $80
- dsprite 9, 0, -1, 7, $01, $80
- dsprite 9, 0, 1, 0, $03, $80
- dsprite 9, 0, 3, 0, $03, $80
- dsprite 10, 0, -1, 7, $01, $80
- dsprite 10, 0, 1, 0, $03, $80
- dsprite 10, 0, 3, 0, $03, $80
- dsprite 11, 0, -1, 7, $01, $80
- dsprite 11, 0, 1, 0, $03, $80
- dsprite 11, 0, 3, 0, $03, $80
- dsprite 11, 1, -1, 7, $00, $c0
- dsprite 11, 1, 0, 0, $02, $c0
- dsprite 11, 1, 1, 0, $03, $c0
- dsprite 11, 1, 2, 0, $02, $c0
- dsprite 11, 1, 3, 0, $03, $e0
+ dsprite 0, 0, -1, 7, $00, 0 | PRIORITY
+ dsprite 0, 0, 3, 0, $00, 0 | X_FLIP | PRIORITY
+ dsprite 1, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 1, 0, 3, 0, $01, 0 | X_FLIP | PRIORITY
+ dsprite 2, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 2, 0, 3, 0, $01, 0 | X_FLIP | PRIORITY
+ dsprite 3, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 3, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 3, 0, 3, 0, $03, 0 | PRIORITY
+ dsprite 4, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 4, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 4, 0, 3, 0, $03, 0 | PRIORITY
+ dsprite 5, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 5, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 5, 0, 3, 0, $03, 0 | PRIORITY
+ dsprite 6, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 6, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 6, 0, 3, 0, $03, 0 | PRIORITY
+ dsprite 7, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 7, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 7, 0, 3, 0, $03, 0 | PRIORITY
+ dsprite 8, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 8, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 8, 0, 3, 0, $03, 0 | PRIORITY
+ dsprite 9, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 9, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 9, 0, 3, 0, $03, 0 | PRIORITY
+ dsprite 10, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 10, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 10, 0, 3, 0, $03, 0 | PRIORITY
+ dsprite 11, 0, -1, 7, $01, 0 | PRIORITY
+ dsprite 11, 0, 1, 0, $03, 0 | PRIORITY
+ dsprite 11, 0, 3, 0, $03, 0 | PRIORITY
+ dsprite 11, 1, -1, 7, $00, 0 | Y_FLIP | PRIORITY
+ dsprite 11, 1, 0, 0, $02, 0 | Y_FLIP | PRIORITY
+ dsprite 11, 1, 1, 0, $03, 0 | Y_FLIP | PRIORITY
+ dsprite 11, 1, 2, 0, $02, 0 | Y_FLIP | PRIORITY
+ dsprite 11, 1, 3, 0, $03, 0 | X_FLIP | Y_FLIP | PRIORITY
.Impossible: ; e0c26
db 4
- dsprite 0, 0, 0, 0, $00, $80
- dsprite 0, 0, 1, 0, $00, $a0
- dsprite 1, 0, 0, 0, $00, $c0
- dsprite 1, 0, 1, 0, $00, $e0
+ dsprite 0, 0, 0, 0, $00, 0 | PRIORITY
+ dsprite 0, 0, 1, 0, $00, 0 | X_FLIP | PRIORITY
+ dsprite 1, 0, 0, 0, $00, 0 | Y_FLIP | PRIORITY
+ dsprite 1, 0, 1, 0, $00, 0 | X_FLIP | Y_FLIP | PRIORITY
; e0c37
CardFlip_InitAttrPals: ; e0c37 (38:4c37)
@@ -1649,7 +1657,7 @@ CardFlip_InitAttrPals: ; e0c37 (38:4c37)
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, .palettes
ld de, wBGPals1
@@ -1661,7 +1669,7 @@ CardFlip_InitAttrPals: ; e0c37 (38:4c37)
; e0c93 (38:4c93)
.palettes ; e0c93
-INCLUDE "data/palettes/card_flip.pal"
+INCLUDE "gfx/card_flip/card_flip.pal"
; e0cdb
CardFlipLZ03: ; e0cdb
diff --git a/engine/caught_data.asm b/engine/caught_data.asm
index 1f8b8cac4..9310b7b90 100644
--- a/engine/caught_data.asm
+++ b/engine/caught_data.asm
@@ -1,4 +1,4 @@
-CheckPartyFullAfterContest: ; 4d9e5
+Special_CheckPartyFullAfterContest: ; 4d9e5
ld a, [wContestMon]
and a
jp z, .DidntCatchAnything
@@ -7,17 +7,17 @@ CheckPartyFullAfterContest: ; 4d9e5
call GetBaseData
ld hl, PartyCount
ld a, [hl]
- cp 6
+ cp PARTY_LENGTH
jp nc, .TryAddToBox
inc a
ld [hl], a
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [wContestMon]
ld [hli], a
ld [CurSpecies], a
- ld a, $ff
+ ld a, -1
ld [hl], a
ld hl, PartyMon1Species
ld a, [PartyCount]
@@ -42,7 +42,7 @@ CheckPartyFullAfterContest: ; 4d9e5
call GetPokemonName
ld hl, StringBuffer1
ld de, wMonOrItemNameBuffer
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
call GiveANickname_YesNo
jr c, .Party_SkipNickname
@@ -75,13 +75,13 @@ CheckPartyFullAfterContest: ; 4d9e5
ld hl, PartyMon1CaughtLocation
call GetPartyLocation
ld a, [hl]
- and $80
- ld b, $13
+ and CAUGHT_GENDER_MASK
+ ld b, NATIONAL_PARK
or b
ld [hl], a
xor a
ld [wContestMon], a
- and a
+ and a ; BUGCONTEST_CAUGHT_MON
ld [ScriptVar], a
ret
@@ -120,7 +120,7 @@ CheckPartyFullAfterContest: ; 4d9e5
ld a, BANK(sBoxMonNicknames)
call GetSRAMBank
ld de, sBoxMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
call CloseSRAM
@@ -135,19 +135,19 @@ CheckPartyFullAfterContest: ; 4d9e5
call GetSRAMBank
ld hl, sBoxMon1CaughtLocation
ld a, [hl]
- and $80
- ld b, $13
+ and CAUGHT_GENDER_MASK
+ ld b, NATIONAL_PARK
or b
ld [hl], a
call CloseSRAM
xor a
ld [wContestMon], a
- ld a, $1
+ ld a, BUGCONTEST_BOXED_MON
ld [ScriptVar], a
ret
.DidntCatchAnything: ; 4db35
- ld a, $2
+ ld a, BUGCONTEST_NO_CATCH
ld [ScriptVar], a
ret
@@ -227,7 +227,7 @@ SetGiftPartyMonCaughtData: ; 4dba3
SetGiftMonCaughtData: ; 4dbaf
xor a
ld [hli], a
- ld a, $7e
+ ld a, GIFT_LOCATION
rrc b
or b
ld [hl], a
@@ -239,7 +239,7 @@ SetEggMonCaughtData: ; 4dbb8 (13:5bb8)
call GetPartyLocation
ld a, [CurPartyLevel]
push af
- ld a, $1
+ ld a, CAUGHT_EGG_LEVEL
ld [CurPartyLevel], a
call SetBoxmonOrEggmonCaughtData
pop af
diff --git a/engine/cgb_layouts.asm b/engine/cgb_layouts.asm
index 74d476dec..84fb6c9de 100644
--- a/engine/cgb_layouts.asm
+++ b/engine/cgb_layouts.asm
@@ -6,7 +6,7 @@ CheckCGB: ; 8d55
ret
; 8d59
-Predef_LoadSGBLayoutCGB: ; 8d59
+LoadSGBLayoutCGB: ; 8d59
ld a, b
cp SCGB_RAM
jr nz, .not_ram
@@ -40,12 +40,12 @@ Predef_LoadSGBLayoutCGB: ; 8d59
dw _CGB_Pokedex
dw _CGB_SlotMachine
dw _CGB06
- dw _CGB07
+ dw _CGB_GSIntro
dw _CGB_Diploma
dw _CGB_MapPals
dw _CGB_PartyMenu
dw _CGB_Evolution
- dw _CGB0c
+ dw _CGB_GSTitleScreen
dw _CGB0d
dw _CGB_MoveList
dw _CGB0f
@@ -58,7 +58,7 @@ Predef_LoadSGBLayoutCGB: ; 8d59
dw _CGB_PokedexUnownMode
dw _CGB_BillsPC
dw _CGB_UnownPuzzle
- dw _CGB_GamefreakLogo ; called before copyright
+ dw _CGB_GamefreakLogo
dw _CGB_PlayerOrMonFrontpicPals
dw _CGB_TradeTube
dw _CGB_TrainerOrMonFrontpicPals
@@ -67,15 +67,15 @@ Predef_LoadSGBLayoutCGB: ; 8d59
; 8db8
_CGB_BattleGrayscale: ; 8db8
- ld hl, PalPacket_9c66 + 1
+ ld hl, PalPacket_BattleGrayscale + 1
ld de, wBGPals1
ld c, 4
call CopyPalettes
- ld hl, PalPacket_9c66 + 1
+ ld hl, PalPacket_BattleGrayscale + 1
ld de, wBGPals1 palette PAL_BATTLE_BG_EXP
ld c, 4
call CopyPalettes
- ld hl, PalPacket_9c66 + 1
+ ld hl, PalPacket_BattleGrayscale + 1
ld de, wOBPals1
ld c, 2
call CopyPalettes
@@ -158,9 +158,9 @@ _CGB_FinishBattleScreenLayout: ; 8e23
InitPartyMenuBGPal7: ; 8e85
farcall Function100dc0
Mobile_InitPartyMenuBGPal7: ; 8e8b
- ld hl, Palette_b311
+ ld hl, PartyMenuBGPalette
jr nc, .not_mobile
- ld hl, Palette_b309
+ ld hl, PartyMenuBGMobilePalette
.not_mobile
ld de, wBGPals1 palette 7
ld bc, 1 palettes
@@ -171,9 +171,9 @@ Mobile_InitPartyMenuBGPal7: ; 8e8b
InitPartyMenuBGPal0: ; 8e9f
farcall Function100dc0
- ld hl, Palette_b311
+ ld hl, PartyMenuBGPalette
jr nc, .not_mobile
- ld hl, Palette_b309
+ ld hl, PartyMenuBGMobilePalette
.not_mobile
ld de, wBGPals1 palette 0
ld bc, 1 palettes
@@ -258,35 +258,16 @@ _CGB_StatsScreenHPPals: ; 8edb
; 8f52
StatsScreenPagePals: ; 8f52
-; pink
- RGB 31, 31, 31
- RGB 31, 19, 31
- RGB 31, 15, 31
- RGB 00, 00, 00
-; green
- RGB 31, 31, 31
- RGB 21, 31, 14
- RGB 17, 31, 00
- RGB 00, 00, 00
-; blue
- RGB 31, 31, 31
- RGB 17, 31, 31
- RGB 17, 31, 31
- RGB 00, 00, 00
+INCLUDE "gfx/stats/pages.pal"
; 8f6a
StatsScreenPals: ; 8f6a
-; pink
- RGB 31, 19, 31
-; green
- RGB 21, 31, 14
-; blue
- RGB 17, 31, 31
+INCLUDE "gfx/stats/stats.pal"
; 8f70
_CGB_Pokedex: ; 8f70
ld de, wBGPals1
- ld a, $1d
+ ld a, PREDEFPAL_POKEDEX
call GetPredefPal
call LoadHLPaletteIntoDE ; dex interface palette
ld a, [CurPartySpecies]
@@ -319,21 +300,16 @@ _CGB_Pokedex: ; 8f70
; 8fba
.PokedexQuestionMarkPalette: ; 8fba
- RGB 11, 23, 00
- RGB 07, 17, 00
- RGB 06, 16, 03
- RGB 05, 12, 01
+INCLUDE "gfx/pokedex/question_mark.pal"
+; 8fc2
.PokedexCursorPalette: ; 8fc2
- RGB 00, 00, 00
- RGB 11, 23, 00
- RGB 07, 17, 00
- RGB 00, 00, 00
+INCLUDE "gfx/pokedex/cursor.pal"
; 8fca
_CGB_BillsPC: ; 8fca
ld de, wBGPals1
- ld a, $1d
+ ld a, PREDEFPAL_POKEDEX
call GetPredefPal
call LoadHLPaletteIntoDE
ld a, [CurPartySpecies]
@@ -385,15 +361,12 @@ _CGB_BillsPC: ; 8fca
; 9036
.BillsPCOrangePalette: ; 9036
- RGB 31, 15, 00
- RGB 23, 12, 00
- RGB 15, 07, 00
- RGB 00, 00, 00
+INCLUDE "gfx/pc/orange.pal"
; 903e
_CGB_PokedexUnownMode: ; 903e
ld de, wBGPals1
- ld a, $1d
+ ld a, PREDEFPAL_POKEDEX
call GetPredefPal
call LoadHLPaletteIntoDE
ld a, [CurPartySpecies]
@@ -467,11 +440,11 @@ _CGB_SlotMachine: ; 906e
; 90f8
_CGB06: ; 90f8
- ld hl, PalPacket_9ca6 + 1
+ ld hl, PalPacket_SCGB_06 + 1
call CopyFourPalettes
call WipeAttrMap
ld de, wOBPals1
- ld a, $3c
+ ld a, PREDEFPAL_PACK
call GetPredefPal
call LoadHLPaletteIntoDE
hlcoord 0, 6, AttrMap
@@ -485,7 +458,7 @@ _CGB06: ; 90f8
ret
; 9122
-_CGB07: ; 9122
+_CGB_GSIntro: ; 9122
ld b, 0
ld hl, .Jumptable
add hl, bc
@@ -497,16 +470,16 @@ _CGB07: ; 9122
; 912d
.Jumptable: ; 912d
- dw .Function9133
- dw .Function9166
- dw .Function9180
+ dw .ShellderLaprasScene
+ dw .JigglypuffPikachuScene
+ dw .StartersCharizardScene
; 9133
-.Function9133: ; 9133
- ld hl, .Palette_914e
+.ShellderLaprasScene: ; 9133
+ ld hl, .ShellderLaprasBGPalette
ld de, wBGPals1
call LoadHLPaletteIntoDE
- ld hl, .Palette_9156
+ ld hl, .ShellderLaprasOBPals
ld de, wOBPals1
ld bc, 2 palettes
ld a, BANK(wOBPals1)
@@ -515,13 +488,13 @@ _CGB07: ; 9122
ret
; 914e
-.Palette_914e: ; 914e
+.ShellderLaprasBGPalette: ; 914e
RGB 19, 31, 19
RGB 18, 23, 31
RGB 11, 21, 28
RGB 04, 16, 24
-.Palette_9156: ; 9156
+.ShellderLaprasOBPals: ; 9156
RGB 29, 29, 29
RGB 20, 19, 20
RGB 19, 06, 04
@@ -533,25 +506,25 @@ _CGB07: ; 9122
RGB 03, 04, 06
; 9166
-.Function9166: ; 9166
+.JigglypuffPikachuScene: ; 9166
ld de, wBGPals1
- ld a, $38
+ ld a, PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_BG
call GetPredefPal
call LoadHLPaletteIntoDE
ld de, wOBPals1
- ld a, $39
+ ld a, PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_OB
call GetPredefPal
call LoadHLPaletteIntoDE
call WipeAttrMap
ret
; 9180
-.Function9180: ; 9180
- ld hl, PalPacket_9c36 + 1
+.StartersCharizardScene: ; 9180
+ ld hl, PalPacket_Pack + 1
call CopyFourPalettes
ld de, wOBPals1
- ld a, $3a
+ ld a, PREDEFPAL_GS_INTRO_STARTERS_TRANSITION
call GetPredefPal
call LoadHLPaletteIntoDE
call WipeAttrMap
@@ -559,7 +532,7 @@ _CGB07: ; 9122
; 9195
_CGB11: ; 9195
- ld hl, Palettes_b789
+ ld hl, Palettes_SCGB_11
ld de, wBGPals1
ld bc, 5 palettes
ld a, BANK(wBGPals1)
@@ -577,7 +550,7 @@ _CGB_Diploma: ; 91ad
ld a, BANK(wBGPals1)
call FarCopyWRAM
- ld hl, PalPacket_9cb6 + 1
+ ld hl, PalPacket_Diploma + 1
call CopyFourPalettes
call WipeAttrMap
call ApplyAttrMap
@@ -592,7 +565,7 @@ _CGB_MapPals: ; 91c8
; 91d1
_CGB_PartyMenu: ; 91d1
- ld hl, PalPacket_9c56 + 1
+ ld hl, PalPacket_PartyMenu + 1
call CopyFourPalettes
call InitPartyMenuBGPal0
call InitPartyMenuBGPal7
@@ -606,7 +579,7 @@ _CGB_Evolution: ; 91e4
ld a, c
and a
jr z, .pokemon
- ld a, $1a
+ ld a, PREDEFPAL_BLACKOUT
call GetPredefPal
call LoadHLPaletteIntoDE
jr .got_palette
@@ -636,13 +609,13 @@ _CGB_Evolution: ; 91e4
ret
; 9228
-_CGB0c: ; 9228
- ld hl, Palettes_b6f1
+_CGB_GSTitleScreen: ; 9228
+ ld hl, UnusedGSTitleBGPals
ld de, wBGPals1
ld bc, 5 palettes
ld a, BANK(wBGPals1)
call FarCopyWRAM
- ld hl, Palettes_b719
+ ld hl, UnusedGSTitleOBPals
ld de, wOBPals1
ld bc, 2 palettes
ld a, BANK(wOBPals1)
@@ -656,7 +629,7 @@ _CGB0c: ; 9228
; 9251
_CGB0d: ; 9251
- ld hl, PalPacket_9cb6 + 1
+ ld hl, PalPacket_Diploma + 1
call CopyFourPalettes
call WipeAttrMap
call ApplyAttrMap
@@ -664,10 +637,10 @@ _CGB0d: ; 9251
; 925e
_CGB_UnownPuzzle: ; 925e
- ld hl, PalPacket_9bc6 + 1
+ ld hl, PalPacket_UnownPuzzle + 1
call CopyFourPalettes
ld de, wOBPals1
- ld a, $4c
+ ld a, PREDEFPAL_UNOWN_PUZZLE
call GetPredefPal
call LoadHLPaletteIntoDE
ld a, [rSVBK]
@@ -675,9 +648,9 @@ _CGB_UnownPuzzle: ; 925e
ld a, BANK(wOBPals1)
ld [rSVBK], a
ld hl, wOBPals1
- ld a, $1f
+ ld a, LOW(palred 31 + palgreen 0 + palblue 0)
ld [hli], a
- ld a, $0
+ ld a, HIGH(palred 31 + palgreen 0 + palblue 0)
ld [hl], a
pop af
ld [rSVBK], a
@@ -712,7 +685,7 @@ _CGB_TrainerCard: ; 9289
ld a, PRYCE
call GetTrainerPalettePointer
call LoadPalette_White_Col1_Col2_Black
- ld a, $24
+ ld a, PREDEFPAL_CGB_BADGE
call GetPredefPal
call LoadHLPaletteIntoDE
@@ -794,7 +767,7 @@ _CGB_TrainerCard: ; 9289
_CGB_MoveList: ; 9373
ld de, wBGPals1
- ld a, $10
+ ld a, PREDEFPAL_GOLDENROD
call GetPredefPal
call LoadHLPaletteIntoDE
ld a, [PlayerHPPal]
@@ -818,7 +791,7 @@ _CGB_MoveList: ; 9373
; 93a6
_CGB0f: ; 93a6
- ld hl, PalPacket_9c46 + 1
+ ld hl, PalPacket_SCGB_0F + 1
call CopyFourPalettes
call WipeAttrMap
call ApplyAttrMap
@@ -830,7 +803,7 @@ _CGB0f: ; 93a6
_CGB_PokedexSearchOption: ; 93ba
ld de, wBGPals1
- ld a, $1d
+ ld a, PREDEFPAL_POKEDEX
call GetPredefPal
call LoadHLPaletteIntoDE
call WipeAttrMap
@@ -891,11 +864,11 @@ _CGB_PackPals: ; 93d3
; 9439
.ChrisPackPals: ; 9439
-INCLUDE "data/palettes/pack.pal"
+INCLUDE "gfx/pack/pack.pal"
; 9469
.KrisPackPals: ; 9469
-INCLUDE "data/palettes/pack_f.pal"
+INCLUDE "gfx/pack/pack_f.pal"
; 9499
_CGB_Pokepic: ; 9499
@@ -934,7 +907,7 @@ _CGB_Pokepic: ; 9499
; 94d0
_CGB13: ; 94d0
- ld hl, PalPacket_9ba6 + 1
+ ld hl, PalPacket_SCGB_13 + 1
call CopyFourPalettes
call WipeAttrMap
hlcoord 0, 4, AttrMap
@@ -954,7 +927,7 @@ _CGB13: ; 94d0
_CGB_GamefreakLogo: ; 94fa
ld de, wBGPals1
- ld a, $4e
+ ld a, PREDEFPAL_GAMEFREAK_LOGO
call GetPredefPal
call LoadHLPaletteIntoDE
ld hl, .Palette
@@ -970,10 +943,7 @@ _CGB_GamefreakLogo: ; 94fa
; 9521
.Palette: ; 9521
- RGB 31, 31, 31
- RGB 13, 11, 00
- RGB 23, 12, 28
- RGB 00, 00, 00
+INCLUDE "gfx/splash/logo.pal"
; 9529
_CGB_PlayerOrMonFrontpicPals: ; 9529
@@ -999,7 +969,7 @@ _CGB1e: ; 9542
; 9555
_CGB_TradeTube: ; 9555
- ld hl, PalPacket_9cc6 + 1
+ ld hl, PalPacket_TradeTube + 1
call CopyFourPalettes
ld hl, PartyMenuOBPals
ld de, wOBPals1
@@ -1007,7 +977,7 @@ _CGB_TradeTube: ; 9555
ld a, BANK(wOBPals1)
call FarCopyWRAM
ld de, wOBPals1 palette 7
- ld a, $1c
+ ld a, PREDEFPAL_TRADE_TUBE
call GetPredefPal
call LoadHLPaletteIntoDE
call WipeAttrMap
@@ -1059,13 +1029,5 @@ _CGB_MysteryGift: ; 9591
; 95e0
.Palettes: ; 95e0
- RGB 31, 31, 31
- RGB 16, 31, 14
- RGB 05, 14, 21
- RGB 05, 13, 10
-
- RGB 31, 31, 31
- RGB 11, 21, 25
- RGB 05, 14, 21
- RGB 00, 03, 19
+INCLUDE "gfx/mystery_gift/mystery_gift.pal"
; 95f0
diff --git a/engine/clock_reset.asm b/engine/clock_reset.asm
index c81271442..82b81b85c 100755
--- a/engine/clock_reset.asm
+++ b/engine/clock_reset.asm
@@ -220,6 +220,7 @@ RestartClock: ; 20021 (8:4021)
ret
; 20160 (8:4160)
+; unused
.unreferenced ; 20160
ld a, [Buffer3]
ld b, a
diff --git a/engine/color.asm b/engine/color.asm
index 04b24fde9..485125821 100644
--- a/engine/color.asm
+++ b/engine/color.asm
@@ -43,8 +43,7 @@ CheckShininess:
and a
ret
-; unreferenced
-CheckContestMon:
+Unused_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.
@@ -78,8 +77,7 @@ CheckContestMon:
and a
ret
-Function8aa4:
-; XXX
+Unreferenced_Function8aa4:
push de
push bc
ld hl, PalPacket_9ce6
@@ -103,7 +101,7 @@ Function8aa4:
ret
InitPartyMenuPalettes:
- ld hl, PalPacket_9c56 + 1
+ ld hl, PalPacket_PartyMenu + 1
call CopyFourPalettes
call InitPartyMenuOBPals
call WipeAttrMap
@@ -136,21 +134,20 @@ SGB_ApplyPartyMenuHPPals: ; 8ade
ld [hl], e
ret
-Function8b07:
-; Unreferenced
+Unreferenced_Function8b07:
call CheckCGB
ret z
; CGB only
ld hl, .BGPal
ld de, wBGPals1
ld bc, 1 palettes
- ld a, $5
+ ld a, BANK(wBGPals1)
call FarCopyWRAM
ld hl, .OBPal
ld de, wOBPals1
ld bc, 1 palettes
- ld a, $5
+ ld a, BANK(wOBPals1)
call FarCopyWRAM
call ApplyPals
@@ -170,8 +167,7 @@ Function8b07:
RGB 08, 16, 28
RGB 00, 00, 00
-Function8b3f:
-; Unreferenced
+Unreferenced_Function8b3f:
call CheckCGB
ret nz
ld a, [hSGB]
@@ -180,40 +176,37 @@ Function8b3f:
ld hl, BlkPacket_9a86
jp PushSGBPals_
-Function8b4d:
-; XXX
+Unreferenced_Function8b4d:
call CheckCGB
jr nz, .cgb
ld a, [hSGB]
and a
ret z
- ld hl, PalPacket_9c26
+ ld hl, PalPacket_Function8b4d
jp PushSGBPals_
.cgb
ld de, wOBPals1
- ld a, $3b
+ ld a, PREDEFPAL_3B
call GetPredefPal
jp LoadHLPaletteIntoDE
-Function8b67:
-; XXX
+Unreferenced_Function8b67:
call CheckCGB
jr nz, .cgb
ld a, [hSGB]
and a
ret z
- ld hl, PalPacket_9c36
+ ld hl, PalPacket_Pack
jp PushSGBPals_
.cgb
ld de, wOBPals1
- ld a, $3c
+ ld a, PREDEFPAL_PACK
call GetPredefPal
jp LoadHLPaletteIntoDE
-Function8b81:
-; XXX
+Unreferenced_Function8b81:
call CheckCGB
jr nz, .cgb
ld a, [hSGB]
@@ -281,8 +274,7 @@ got_palette_pointer_8bd7
call LoadPalette_White_Col1_Col2_Black
ret
-Function8bec:
-; XXX
+Unreferenced_Function8bec:
ld a, [hCGB]
and a
jr nz, .cgb
@@ -359,7 +351,7 @@ ApplyHPBarPals:
ld bc, HPBarPals
add hl, bc
ld bc, 4
- ld a, $5
+ ld a, BANK(wBGPals2)
call FarCopyWRAM
ld a, $1
ld [hCGBPalUpdate], a
@@ -394,7 +386,7 @@ LoadStatsScreenPals:
add hl, bc
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld a, [hli]
ld [wBGPals1 palette 0], a
@@ -443,7 +435,7 @@ LoadMailPalettes:
.cgb
ld de, wBGPals1
ld bc, 1 palettes
- ld a, $5
+ ld a, BANK(wBGPals1)
call FarCopyWRAM
call ApplyPals
call WipeAttrMap
@@ -451,16 +443,15 @@ LoadMailPalettes:
ret
.MailPals:
-INCLUDE "data/palettes/mail.pal"
+INCLUDE "gfx/mail/mail.pal"
INCLUDE "engine/cgb_layouts.asm"
-Function95f0:
-; XXX
+Unreferenced_Function95f0:
ld hl, .Palette
ld de, wBGPals1
ld bc, 1 palettes
- ld a, $5
+ ld a, BANK(wBGPals1)
call FarCopyWRAM
call ApplyPals
call WipeAttrMap
@@ -475,7 +466,7 @@ Function95f0:
CopyFourPalettes:
ld de, wBGPals1
- ld c, $4
+ ld c, 4
CopyPalettes:
.loop
@@ -504,7 +495,7 @@ GetPredefPal:
LoadHLPaletteIntoDE:
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wOBPals1)
ld [rSVBK], a
ld c, $8
.loop
@@ -520,13 +511,13 @@ LoadHLPaletteIntoDE:
LoadPalette_White_Col1_Col2_Black:
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
- ld a, LOW(palred 31 + palgreen 31 + palblue 31)
+ ld a, LOW(PALRGB_WHITE)
ld [de], a
inc de
- ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
+ ld a, HIGH(PALRGB_WHITE)
ld [de], a
inc de
@@ -572,7 +563,7 @@ ResetBGPals:
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, wBGPals1
@@ -611,7 +602,7 @@ ApplyPals:
ld hl, wBGPals1
ld de, wBGPals2
ld bc, 16 palettes
- ld a, $5
+ ld a, BANK(wPals)
call FarCopyWRAM
ret
@@ -688,7 +679,7 @@ InitPartyMenuOBPals:
ld hl, PartyMenuOBPals
ld de, wOBPals1
ld bc, 2 palettes
- ld a, $5
+ ld a, BANK(wOBPals1)
call FarCopyWRAM
ret
@@ -746,7 +737,8 @@ GetMonPalettePointer_:
call GetMonPalettePointer
ret
-Function9779: mobile
+Unreferenced_Function9779:
+ ret
call CheckCGB
ret z
ld hl, BattleObjectPals
@@ -761,23 +753,22 @@ Function9779: mobile
ld hl, BattleObjectPals
ld de, wOBPals1 palette 2
ld bc, 2 palettes
- ld a, $5
+ ld a, BANK(wOBPals1)
call FarCopyWRAM
ret
BattleObjectPals:
-INCLUDE "data/palettes/battle_objects.pal"
+INCLUDE "gfx/battle_anims/battle_anims.pal"
-Function97cc:
-; XXX
+Unreferenced_Function97cc:
call CheckCGB
ret z
ld a, $90
ld [rOBPI], a
- ld a, $1c
+ ld a, PREDEFPAL_TRADE_TUBE
call GetPredefPal
call .PushPalette
- ld a, $21
+ ld a, PREDEFPAL_RB_GREENMON
call GetPredefPal
call .PushPalette
ret
@@ -887,7 +878,7 @@ InitSGBBorder:
call PushSGBBorder
call SGBDelayCycles
call SGB_ClearVRAM
- ld hl, PalPacket_9d66
+ ld hl, MaskEnCancelPacket
call PushSGBPals
.skip
@@ -900,21 +891,21 @@ InitCGBPals::
call CheckCGB
ret z
; CGB only
- ld a, $1
+ ld a, BANK(vTiles3)
ld [rVBK], a
- ld hl, vTiles0
+ ld hl, vTiles3
ld bc, $200 tiles
xor a
call ByteFill
- ld a, $0
+ ld a, BANK(vTiles0)
ld [rVBK], a
ld a, 1 << rBGPI_AUTO_INCREMENT
ld [rBGPI], a
ld c, 4 * 8
.bgpals_loop
- ld a, LOW(palred 31 + palgreen 31 + palblue 31)
+ ld a, LOW(PALRGB_WHITE)
ld [rBGPD], a
- ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
+ ld a, HIGH(PALRGB_WHITE)
ld [rBGPD], a
dec c
jr nz, .bgpals_loop
@@ -922,15 +913,15 @@ InitCGBPals::
ld [rOBPI], a
ld c, 4 * 8
.obpals_loop
- ld a, LOW(palred 31 + palgreen 31 + palblue 31)
+ ld a, LOW(PALRGB_WHITE)
ld [rOBPD], a
- ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
+ ld a, HIGH(PALRGB_WHITE)
ld [rOBPD], a
dec c
jr nz, .obpals_loop
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, wBGPals1
call .LoadWhitePals
@@ -943,16 +934,16 @@ InitCGBPals::
.LoadWhitePals:
ld c, 4 * 16
.loop
- ld a, LOW(palred 31 + palgreen 31 + palblue 31)
+ ld a, LOW(PALRGB_WHITE)
ld [hli], a
- ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
+ ld a, HIGH(PALRGB_WHITE)
ld [hli], a
dec c
jr nz, .loop
ret
_InitSGBBorderPals:
- ld hl, .PalPacketPointerTable
+ ld hl, .PacketPointerTable
ld c, 9
.loop
push bc
@@ -968,28 +959,27 @@ _InitSGBBorderPals:
jr nz, .loop
ret
-.PalPacketPointerTable:
- dw PalPacket_9d56
- dw PalPacket_9d76
- dw PalPacket_9d86
- dw PalPacket_9d96
- dw PalPacket_9da6
- dw PalPacket_9db6
- dw PalPacket_9dc6
- dw PalPacket_9dd6
- dw PalPacket_9de6
-
-Function9911:
-; XXX
+.PacketPointerTable:
+ dw MaskEnFreezePacket
+ dw DataSndPacket1
+ dw DataSndPacket2
+ dw DataSndPacket3
+ dw DataSndPacket4
+ dw DataSndPacket5
+ dw DataSndPacket6
+ dw DataSndPacket7
+ dw DataSndPacket8
+
+Unreferenced_Function9911:
di
xor a
ld [rJOYP], a
- ld hl, PalPacket_9d56
+ ld hl, MaskEnFreezePacket
call PushSGBPals
call PushSGBBorder
call SGBDelayCycles
call SGB_ClearVRAM
- ld hl, PalPacket_9d66
+ ld hl, MaskEnCancelPacket
call PushSGBPals
ei
ret
@@ -1015,7 +1005,7 @@ SGB_ClearVRAM:
ret
PushSGBBorderPalsAndWait:
- ld hl, PalPacket_9d26
+ ld hl, MltReq2Packet
call PushSGBPals
call SGBDelayCycles
ld a, [rJOYP]
@@ -1060,7 +1050,7 @@ endr
ret
.FinalPush:
- ld hl, PalPacket_9d16
+ ld hl, MltReq1Packet
call PushSGBPals
jp SGBDelayCycles
@@ -1075,7 +1065,7 @@ SGBBorder_PushBGPals:
call DrawDefaultTiles
ld a, LCDC_DEFAULT
ld [rLCDC], a
- ld hl, PalPacket_9d06
+ ld hl, PalTrnPacket
call PushSGBPals
xor a
ld [rBGP], a
@@ -1109,7 +1099,7 @@ SGBBorder_MorePalPushing:
call DrawDefaultTiles
ld a, LCDC_DEFAULT
ld [rLCDC], a
- ld hl, PalPacket_9d46
+ ld hl, PctTrnPacket
call PushSGBPals
xor a
ld [rBGP], a
@@ -1133,7 +1123,7 @@ SGBBorder_YetMorePalPushing:
call DrawDefaultTiles
ld a, LCDC_DEFAULT
ld [rLCDC], a
- ld hl, PalPacket_9d36
+ ld hl, ChrTrnPacket
call PushSGBPals
xor a
ld [rBGP], a
@@ -1197,26 +1187,28 @@ SGBDelayCycles:
jr nz, .wait
ret
-INCLUDE "data/palettes/blk_packets.asm"
-
-INCLUDE "data/palettes/pal_packets.asm"
+INCLUDE "gfx/sgb/blk_packets.asm"
+INCLUDE "gfx/sgb/pal_packets.asm"
+INCLUDE "data/sgb_ctrl_packets.asm"
PredefPals:
-INCLUDE "data/palettes/predef.pal"
+INCLUDE "gfx/sgb/predef.pal"
-INCLUDE "data/sgb_border_map.asm"
+SGBBorderMap:
+; interleaved tile ids and palette ids
+INCBIN "gfx/sgb/sgb_border.bin"
SGBBorderPalettes:
-INCLUDE "data/palettes/sgb_border.pal"
+INCLUDE "gfx/sgb/sgb_border.pal"
SGBBorder:
INCBIN "gfx/sgb/sgb_border.2bpp"
HPBarPals:
-INCLUDE "data/palettes/hp_bar.pal"
+INCLUDE "gfx/battle/hp_bar.pal"
ExpBarPalette:
-INCLUDE "data/palettes/exp_bar.pal"
+INCLUDE "gfx/battle/exp_bar.pal"
INCLUDE "data/pokemon/palettes.asm"
@@ -1239,7 +1231,7 @@ LoadMapPals:
ld l, a
; Futher refine by time of day
ld a, [TimeOfDayPal]
- and 3
+ maskbits NUM_DAYTIMES
add a
add a
add a
@@ -1251,7 +1243,7 @@ LoadMapPals:
; Switch to palettes WRAM bank
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, wBGPals1
ld b, 8
@@ -1285,7 +1277,7 @@ LoadMapPals:
.got_pals
ld a, [TimeOfDayPal]
- and 3
+ maskbits NUM_DAYTIMES
ld bc, 8 palettes
ld hl, MapObjectPals
call AddNTimes
@@ -1309,7 +1301,7 @@ LoadMapPals:
ld de, RoofPals
add hl, de
ld a, [TimeOfDayPal]
- and 3
+ maskbits NUM_DAYTIMES
cp NITE_F
jr c, .morn_day
rept 4
@@ -1318,53 +1310,47 @@ endr
.morn_day
ld de, wBGPals1 palette PAL_BG_ROOF + 2
ld bc, 4
- ld a, $5
+ ld a, BANK(wBGPals1)
call FarCopyWRAM
ret
INCLUDE "data/maps/environment_colors.asm"
-Palette_b309: ; b309 mobile
- RGB 31, 31, 31
- RGB 31, 19, 24
- RGB 30, 10, 06
- RGB 00, 00, 00
+PartyMenuBGMobilePalette:
+INCLUDE "gfx/stats/party_menu_bg_mobile.pal"
-Palette_b311: ; b311 not mobile
- RGB 31, 31, 31
- RGB 17, 19, 31
- RGB 14, 16, 31
- RGB 00, 00, 00
+PartyMenuBGPalette:
+INCLUDE "gfx/stats/party_menu_bg.pal"
TilesetBGPalette:
-INCLUDE "data/palettes/overworld/tileset_bg.pal"
+INCLUDE "gfx/tilesets/bg_tiles.pal"
MapObjectPals::
-INCLUDE "data/palettes/overworld/map_objects.pal"
+INCLUDE "gfx/overworld/npc_sprites.pal"
RoofPals:
-INCLUDE "data/palettes/overworld/roofs.pal"
+INCLUDE "gfx/tilesets/roofs.pal"
DiplomaPalettes:
-INCLUDE "data/palettes/diploma.pal"
+INCLUDE "gfx/diploma/diploma.pal"
PartyMenuOBPals:
-INCLUDE "data/palettes/party_menu.pal"
+INCLUDE "gfx/stats/party_menu_ob.pal"
-Palettes_b6f1:
-INCLUDE "data/palettes/unknown/b6f1.pal"
+UnusedGSTitleBGPals:
+INCLUDE "gfx/title/unused_gs_bg.pal"
-Palettes_b719:
-INCLUDE "data/palettes/unknown/b719.pal"
+UnusedGSTitleOBPals:
+INCLUDE "gfx/title/unused_gs_fg.pal"
MalePokegearPals:
-INCLUDE "data/palettes/pokegear.pal"
+INCLUDE "gfx/pokegear/pokegear.pal"
FemalePokegearPals:
-INCLUDE "data/palettes/pokegear_f.pal"
+INCLUDE "gfx/pokegear/pokegear_f.pal"
-Palettes_b789:
-INCLUDE "data/palettes/unknown/b789.pal"
+Palettes_SCGB_11:
+INCLUDE "gfx/unknown/b789.pal"
SlotMachinePals:
-INCLUDE "data/palettes/slot_machine.pal"
+INCLUDE "gfx/slots/slots.pal"
diff --git a/engine/credits.asm b/engine/credits.asm
index 3dddb4126..ac5064a41 100644
--- a/engine/credits.asm
+++ b/engine/credits.asm
@@ -1,4 +1,4 @@
-INCLUDE "includes.asm"
+INCLUDE "constants.asm"
SECTION "Credits", ROMX
@@ -13,7 +13,7 @@ Credits:: ; 109847
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wPals)
ld [rSVBK], a
call ClearBGPalettes
@@ -34,17 +34,17 @@ Credits:: ; 109847
ld de, CreditsBorderGFX
ld hl, vTiles2 tile $20
- lb bc, BANK(CreditsBorderGFX), $09
+ lb bc, BANK(CreditsBorderGFX), 9
call Request2bpp
ld de, CopyrightGFX
ld hl, vTiles2 tile $60
- lb bc, BANK(CopyrightGFX), $1d
+ lb bc, BANK(CopyrightGFX), 29
call Request2bpp
ld de, TheEndGFX
ld hl, vTiles2 tile $40
- lb bc, BANK(TheEndGFX), $10
+ lb bc, BANK(TheEndGFX), 16
call Request2bpp
ld a, $ff
@@ -504,7 +504,7 @@ GetCreditsPalette: ; 109b2c
.GetPalAddress:
; Each set of palette data is 24 bytes long.
ld a, [wCreditsBorderMon] ; scene
- and 3
+ and %11
add a
add a ; * 8
add a
@@ -540,7 +540,7 @@ GetCreditsPalette: ; 109b2c
ret
CreditsPalettes:
-INCLUDE "data/palettes/credits.pal"
+INCLUDE "gfx/credits/credits.pal"
; 109bca
Credits_LoadBorderGFX: ; 109bca (42:5bca)
@@ -549,13 +549,13 @@ Credits_LoadBorderGFX: ; 109bca (42:5bca)
cp $ff
jr z, .init
- and 3
+ and %11
ld e, a
inc a
- and 3
+ and %11
ld [hl], a
ld a, [wCreditsBorderMon]
- and 3
+ and %11
add a
add a
add e
diff --git a/engine/crystal_intro.asm b/engine/crystal_intro.asm
index 302490a3b..ea6828f14 100755
--- a/engine/crystal_intro.asm
+++ b/engine/crystal_intro.asm
@@ -52,12 +52,12 @@ Copyright_GFPresents: ; e4579
.GetGFLogoGFX: ; e45e8
ld de, GameFreakLogo
ld hl, vTiles2
- lb bc, BANK(GameFreakLogo), $1c
+ lb bc, BANK(GameFreakLogo), 28
call Get1bpp
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
ld hl, IntroLogoGFX
@@ -94,7 +94,7 @@ Copyright_GFPresents: ; e4579
xor a
ld [wJumptableIndex], a
ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
ld [hSCX], a
ld [hSCY], a
ld a, $1
@@ -146,7 +146,7 @@ PlaceGameFreakPresents_0: ; e468c
; e468d
PlaceGameFreakPresents_1: ; e468d
- ld hl, wcf65
+ ld hl, wIntroSceneTimer
ld a, [hl]
cp $20
jr nc, .PlaceGameFreak
@@ -173,7 +173,7 @@ PlaceGameFreakPresents_1: ; e468d
; e46ba
PlaceGameFreakPresents_2: ; e46ba
- ld hl, wcf65
+ ld hl, wIntroSceneTimer
ld a, [hl]
cp $40
jr nc, .place_presents
@@ -197,7 +197,7 @@ PlaceGameFreakPresents_2: ; e46ba
; e46dd
PlaceGameFreakPresents_3: ; e46dd
- ld hl, wcf65
+ ld hl, wIntroSceneTimer
ld a, [hl]
cp $80
jr nc, .finish
@@ -247,10 +247,10 @@ GameFreakLogoScene2: ; e470d (39:470d)
ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
- and $3f
- cp $20
+ and %111111
+ cp %100000
jr nc, .asm_e4723
- add $20
+ add %100000
.asm_e4723
ld e, a
farcall BattleAnim_Sine_e
@@ -319,7 +319,7 @@ GameFreakLogoScene4: ; e4776 (39:4776)
add hl, de
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wOBPals2)
ld [rSVBK], a
ld a, [hli]
ld [wOBPals2 + 12], a
@@ -341,7 +341,7 @@ GameFreakLogoScene5: ; e47ab (39:47ab)
; e47ac (39:47ac)
GameFreakLogoPalettes: ; e47ac
-INCLUDE "data/palettes/crystal_intro/gamefreak_logo.pal"
+INCLUDE "gfx/intro/gamefreak_logo.pal"
; e47cc
GameFreakLogo: ; e47cc
@@ -352,7 +352,7 @@ INCBIN "gfx/splash/logo2.1bpp"
CrystalIntro: ; e48ac
ld a, [rSVBK]
push af
- ld a, 5
+ ld a, BANK(wPals)
ld [rSVBK], a
ld a, [hInMenu]
push af
@@ -480,7 +480,7 @@ IntroScene1: ; e495b (39:495b)
call Intro_DecompressRequest2bpp_64Tiles
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, Palette_365ad
ld de, wBGPals1
@@ -503,7 +503,7 @@ IntroScene1: ; e495b (39:495b)
call Intro_SetCGBPalUpdate
xor a
ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
call NextIntroScene
ret
@@ -523,7 +523,7 @@ IntroScene2: ; e49d6 (39:49d6)
call PlaySFX
pop af
.DontPlaySound:
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
xor a
call CrystalIntro_UnownFade
ret
@@ -553,7 +553,7 @@ IntroScene3: ; e49fd (39:49fd)
call Intro_DecompressRequest2bpp_64Tiles
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, Palette_e5edd
ld de, wBGPals1
@@ -619,7 +619,7 @@ IntroScene5: ; e4a7a (39:4a7a)
call Intro_DecompressRequest2bpp_64Tiles
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, Palette_365ad
ld de, wBGPals1
@@ -642,7 +642,7 @@ IntroScene5: ; e4a7a (39:4a7a)
call Intro_SetCGBPalUpdate
xor a
ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
call NextIntroScene
ret
@@ -669,7 +669,7 @@ IntroScene6: ; e4af7 (39:4af7)
call PlaySFX
pop af
.NoUnown:
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
xor a
call CrystalIntro_UnownFade
ret
@@ -682,7 +682,7 @@ IntroScene6: ; e4af7 (39:4af7)
call PlaySFX
pop af
.StopUnown:
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
ld a, $1
call CrystalIntro_UnownFade
ret
@@ -725,7 +725,7 @@ IntroScene7: ; e4b3f (39:4b3f)
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, Palette_e5edd
@@ -758,7 +758,7 @@ IntroScene7: ; e4b3f (39:4b3f)
call Intro_SetCGBPalUpdate
xor a
ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
call NextIntroScene
ret
@@ -884,7 +884,7 @@ IntroScene11: ; e4c86 (39:4c86)
call Intro_DecompressRequest2bpp_64Tiles
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, Palette_365ad
ld de, wBGPals1
@@ -907,7 +907,7 @@ IntroScene11: ; e4c86 (39:4c86)
call Intro_SetCGBPalUpdate
xor a
ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
call NextIntroScene
ret
@@ -925,7 +925,7 @@ IntroScene12: ; e4cfa (39:4cfa)
ld c, a
and $1f
sla a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
ld a, c
and $e0
srl a
@@ -939,7 +939,7 @@ IntroScene12: ; e4cfa (39:4cfa)
and $f
sla a
sla a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
ld a, c
and $70
or $40
@@ -1011,7 +1011,7 @@ IntroScene13: ; e4d6d (39:4d6d)
call Intro_DecompressRequest2bpp_64Tiles
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, Palette_e5edd
ld de, wBGPals1
@@ -1041,7 +1041,7 @@ IntroScene13: ; e4d6d (39:4d6d)
call Intro_SetCGBPalUpdate
xor a
ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
call NextIntroScene
ret
@@ -1068,7 +1068,7 @@ IntroScene14: ; e4dfa (39:4dfa)
.asm_e4e1a
ld a, $1
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
ld a, [wGlobalAnimXOffset]
cp $88
jr c, .asm_e4e2c
@@ -1120,7 +1120,7 @@ IntroScene15: ; e4e40 (39:4e40)
call Intro_LoadTilemap
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, Palette_e77dd
ld de, wBGPals1
@@ -1150,7 +1150,7 @@ IntroScene15: ; e4e40 (39:4e40)
call _InitSpriteAnimStruct
xor a
ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
call NextIntroScene
ret
@@ -1194,7 +1194,7 @@ IntroScene17: ; e4ef5 (39:4ef5)
call Intro_DecompressRequest2bpp_64Tiles
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, Palette_e6d6d
ld de, wBGPals1
@@ -1217,7 +1217,7 @@ IntroScene17: ; e4ef5 (39:4ef5)
call Intro_SetCGBPalUpdate
xor a
ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
call NextIntroScene
ret
@@ -1268,7 +1268,7 @@ IntroScene19: ; e4f7e (39:4f7e)
call Intro_LoadTilemap
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, Palette_e77dd
ld de, wBGPals1
@@ -1299,7 +1299,7 @@ IntroScene19: ; e4f7e (39:4f7e)
call _InitSpriteAnimStruct
xor a
ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
call NextIntroScene
ret
@@ -1331,7 +1331,7 @@ IntroScene20: ; e5019 (39:5019)
and $1c
srl a
srl a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
xor a
call Intro_Scene20_AppearUnown
ret
@@ -1341,7 +1341,7 @@ IntroScene20: ; e5019 (39:5019)
and $1c
srl a
srl a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
ld a, 1
call Intro_Scene20_AppearUnown
ret
@@ -1358,7 +1358,7 @@ IntroScene21: ; e505d (39:505d)
xor a
ld [hBGMapMode], a
ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
call NextIntroScene
ret
@@ -1438,7 +1438,7 @@ IntroScene26: ; e50bb (39:50bb)
call Intro_DecompressRequest2bpp_64Tiles
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, Palette_e679d
ld de, wBGPals1
@@ -1461,13 +1461,13 @@ IntroScene26: ; e50bb (39:50bb)
call Intro_SetCGBPalUpdate
xor a
ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
call NextIntroScene
ret
IntroScene27: ; e512d (39:512d)
; Spell out C R Y S T A L with Unown.
- ld hl, wcf65
+ ld hl, wIntroSceneTimer
inc [hl]
ld hl, wIntroSceneFrameCounter
ld a, [hl]
@@ -1477,7 +1477,7 @@ IntroScene27: ; e512d (39:512d)
ld c, a
and $f
- ld [wcf65], a
+ ld [wIntroSceneTimer], a
ld a, c
and $70
swap a
@@ -1526,7 +1526,7 @@ Intro_Scene24_ApplyPaletteFade: ; e5172 (39:5172)
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals2)
ld [rSVBK], a
ld de, wBGPals2
ld b, 8 ; number of BG pals
@@ -1550,7 +1550,7 @@ Intro_Scene24_ApplyPaletteFade: ; e5172 (39:5172)
; e519c (39:519c)
.FadePals: ; e519c
-INCLUDE "data/palettes/crystal_intro/fade.pal"
+INCLUDE "gfx/intro/fade.pal"
; e51dc
CrystalIntro_InitUnownAnim: ; e51dc (39:51dc)
@@ -1603,13 +1603,13 @@ CrystalIntro_UnownFade: ; e5223 (39:5223)
add hl, de
inc hl
inc hl
- ld a, [wcf65]
- and $3f
- cp $1f
+ ld a, [wIntroSceneTimer]
+ and %111111
+ cp %011111
jr z, .okay
jr c, .okay
ld c, a
- ld a, $3f
+ ld a, %111111
sub c
.okay
@@ -1617,7 +1617,7 @@ CrystalIntro_UnownFade: ; e5223 (39:5223)
ld b, $0
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals2)
ld [rSVBK], a
push hl
@@ -1714,7 +1714,7 @@ Intro_Scene20_AppearUnown: ; e5348 (39:5348)
ld hl, .pal2
.got_pointer
- ld a, [wcf65]
+ ld a, [wIntroSceneTimer]
and $7
add a
add a
@@ -1722,7 +1722,7 @@ Intro_Scene20_AppearUnown: ; e5348 (39:5348)
ld c, a
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals2)
ld [rSVBK], a
push bc
@@ -1784,14 +1784,14 @@ Intro_FadeUnownWordPals: ; e539d (39:539d)
rept 4
inc hl
endr
- ld a, [wcf65]
+ ld a, [wIntroSceneTimer]
add a
ld c, a
ld b, $0
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals2)
ld [rSVBK], a
push hl
@@ -1846,7 +1846,7 @@ endr
Intro_LoadTilemap: ; e541b (39:541b)
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
ld hl, wDecompressScratch
@@ -1946,7 +1946,7 @@ Intro_SetCGBPalUpdate: ; e549e (39:549e)
Intro_ClearBGPals: ; e54a3 (39:54a3)
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals2)
ld [rSVBK], a
ld hl, wBGPals2
@@ -1965,7 +1965,7 @@ Intro_ClearBGPals: ; e54a3 (39:54a3)
Intro_DecompressRequest2bpp_128Tiles: ; e54c2 (39:54c2)
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
push de
@@ -1984,7 +1984,7 @@ Intro_DecompressRequest2bpp_128Tiles: ; e54c2 (39:54c2)
Intro_DecompressRequest2bpp_255Tiles: ; e54de (39:54de)
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
push de
@@ -2003,7 +2003,7 @@ Intro_DecompressRequest2bpp_255Tiles: ; e54de (39:54de)
Intro_DecompressRequest2bpp_64Tiles: ; e54fa (39:54fa)
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
push de
@@ -2022,7 +2022,7 @@ Intro_DecompressRequest2bpp_64Tiles: ; e54fa (39:54fa)
Intro_ResetLYOverrides: ; e5516 (39:5516)
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(LYOverrides)
ld [rSVBK], a
ld hl, LYOverrides
@@ -2039,7 +2039,7 @@ Intro_ResetLYOverrides: ; e5516 (39:5516)
Intro_PerspectiveScrollBG: ; e552f (39:552f)
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(LYOverrides)
ld [rSVBK], a
; Scroll the grass every frame.
; Scroll the trees every other frame and at half speed.
@@ -2088,7 +2088,7 @@ INCBIN "gfx/intro/003.tilemap.lz"
; e5edd
Palette_e5edd: ; e5edd
-INCLUDE "data/palettes/crystal_intro/intro_1.pal"
+INCLUDE "gfx/intro/intro_1.pal"
; e5f5d
IntroUnownsGFX: ; e5f5d
@@ -2124,7 +2124,7 @@ INCBIN "gfx/intro/007.tilemap.lz"
; e65ad
Palette_365ad: ; e65ad
-INCLUDE "data/palettes/crystal_intro/intro_2.pal"
+INCLUDE "gfx/intro/intro_2.pal"
; e662d
IntroCrystalUnownsGFX: ; e662d
@@ -2140,7 +2140,7 @@ INCBIN "gfx/intro/015.tilemap.lz"
; e679d
Palette_e679d: ; e679d
-INCLUDE "data/palettes/crystal_intro/intro_3.pal"
+INCLUDE "gfx/intro/intro_3.pal"
; e681d
IntroSuicuneCloseGFX: ; e681d
@@ -2156,7 +2156,7 @@ INCBIN "gfx/intro/011.tilemap.lz"
; e6d6d
Palette_e6d6d: ; e6d6d
-INCLUDE "data/palettes/crystal_intro/intro_4.pal"
+INCLUDE "gfx/intro/intro_4.pal"
; e6ded
IntroSuicuneJumpGFX: ; e6ded
@@ -2184,7 +2184,7 @@ INCBIN "gfx/intro/013.tilemap.lz"
; e77dd
Palette_e77dd: ; e77dd
-INCLUDE "data/palettes/crystal_intro/intro_5.pal"
+INCLUDE "gfx/intro/intro_5.pal"
IntroUnownBackGFX: ; e785d
INCBIN "gfx/intro/unown_back.2bpp.lz"
diff --git a/engine/crystal_colors.asm b/engine/crystal_layouts.asm
index 5d2ba236c..9fd01aac0 100755
--- a/engine/crystal_colors.asm
+++ b/engine/crystal_layouts.asm
@@ -23,7 +23,6 @@ GetMysteryGift_MobileAdapterLayout: ; 4930f (mobile)
; 49330 (12:5330)
.dw ; 49330
-
dw MG_Mobile_Layout00
dw MG_Mobile_Layout01
dw MG_Mobile_Layout02
@@ -113,7 +112,7 @@ MG_Mobile_Layout_CreatePalBoxes: ; 49384 (12:5384)
; 493e1 (12:53e1)
Palette_493e1: ; 493e1
-INCLUDE "data/palettes/mg_mobile.pal"
+INCLUDE "gfx/mystery_gift/mg_mobile.pal"
; 49409
LoadOW_BGPal7:: ; 49409
@@ -126,11 +125,11 @@ LoadOW_BGPal7:: ; 49409
; 49418
Palette_TextBG7: ; 49418
-INCLUDE "data/palettes/overworld/bg_text.pal"
+INCLUDE "gfx/font/bg_text.pal"
; 49420
Function49420:: ; 49420 (12:5420)
- ld hl, MansionPalette4
+ ld hl, MansionPalette1 + 8 palettes
ld de, wBGPals1 palette PAL_BG_ROOF
ld bc, 1 palettes
ld a, BANK(wBGPals1)
@@ -204,7 +203,7 @@ Function49496: ; 49496
ret
; 494ac
-INCLUDE "tilesets/special_palettes.asm"
+INCLUDE "engine/tileset_palettes.asm"
MG_Mobile_Layout02: ; 49706
ld hl, .Palette_49732
@@ -241,14 +240,14 @@ Function49742: ; 49742
ld hl, .Palette_49757
ld de, wBGPals1
ld bc, 8 palettes
- ld a, $5
+ ld a, BANK(wBGPals1)
call FarCopyWRAM
farcall ApplyPals
ret
; 49757
.Palette_49757: ; 49757
-INCLUDE "data/palettes/unknown/49757.pal"
+INCLUDE "gfx/unknown/49757.pal"
; 49797
_InitMG_Mobile_LinkTradePalMap: ; 49797
@@ -314,7 +313,7 @@ LoadTradeRoomBGPals: ; 49811
; 49826
TradeRoomPalette: ; 49826
-INCLUDE "data/palettes/trade_room.pal"
+INCLUDE "gfx/trade/border.pal"
; 49856
InitMG_Mobile_LinkTradePalMap: ; 49856
@@ -322,5 +321,5 @@ InitMG_Mobile_LinkTradePalMap: ; 49856
ret
; 4985a
-Unknown_4985a: ; unreferenced
-INCLUDE "data/palettes/unknown/4985a.asm"
+; unused
+INCLUDE "gfx/unknown/4985a.asm"
diff --git a/engine/debug.asm b/engine/debug.asm
index 1e0d042e0..c15481926 100755
--- a/engine/debug.asm
+++ b/engine/debug.asm
@@ -1,3 +1,27 @@
+const_value set $6a
+ const DEBUGTEST_UP_ARROW ; $6a
+ const DEBUGTEST_TICKS ; $6b
+ const DEBUGTEST_WHITE ; $6c
+ const DEBUGTEST_LIGHT ; $6d
+ const DEBUGTEST_DARK ; $6e
+ const DEBUGTEST_BLACK ; $6f
+ const DEBUGTEST_0 ; $70
+ const DEBUGTEST_1 ; $71
+ const DEBUGTEST_2 ; $72
+ const DEBUGTEST_3 ; $73
+ const DEBUGTEST_4 ; $74
+ const DEBUGTEST_5 ; $75
+ const DEBUGTEST_6 ; $76
+ const DEBUGTEST_7 ; $77
+ const DEBUGTEST_8 ; $78
+ const DEBUGTEST_9 ; $79
+ const DEBUGTEST_A ; $7a
+ const DEBUGTEST_B ; $7b
+ const DEBUGTEST_C ; $7c
+ const DEBUGTEST_D ; $7d
+ const DEBUGTEST_E ; $7e
+ const DEBUGTEST_F ; $7f
+
ColorTest: ; 818ac
; A debug menu to test monster and trainer palettes at runtime.
@@ -127,13 +151,13 @@ Function81948: ; 81948
; 8197c
Function8197c: ; 8197c
- ld hl, DebugColorTestGFX + $10
- ld de, vTiles2 tile $6a
- ld bc, $160
+ ld hl, DebugColorTestGFX + 1 tiles
+ ld de, vTiles2 tile DEBUGTEST_UP_ARROW
+ ld bc, 22 tiles
call CopyBytes
ld hl, DebugColorTestGFX
ld de, vTiles0
- ld bc, $10
+ ld bc, 1 tiles
call CopyBytes
call LoadStandardFont
ld hl, vTiles1
@@ -155,7 +179,7 @@ Function819a7: ; 819a7
ret z
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals2)
ld [rSVBK], a
ld hl, Palette_819f4
ld de, wBGPals2
@@ -193,10 +217,10 @@ Function819a7: ; 819a7
; 819f4
Palette_819f4: ; 819f4
-INCLUDE "data/palettes/debug/bg.pal"
+INCLUDE "gfx/debug/bg.pal"
Palette_81a34: ; 81a34
-INCLUDE "data/palettes/debug/ob.pal"
+INCLUDE "gfx/debug/ob.pal"
; 81a74
Function81a74: ; 81a74
@@ -278,19 +302,19 @@ Function81adb: ; 81adb
ld [hBGMapMode], a
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, $6f
+ ld a, DEBUGTEST_BLACK
call ByteFill
hlcoord 1, 3
lb bc, 7, 18
- ld a, $6c
+ ld a, DEBUGTEST_WHITE
call Bank20_FillBoxWithByte
hlcoord 11, 0
lb bc, 2, 3
- ld a, $6d
+ ld a, DEBUGTEST_LIGHT
call Bank20_FillBoxWithByte
hlcoord 16, 0
lb bc, 2, 3
- ld a, $6e
+ ld a, DEBUGTEST_DARK
call Bank20_FillBoxWithByte
call Function81bc0
call Function81bf4
@@ -360,9 +384,9 @@ Function81adb: ; 81adb
ret
; 81baf
-String_81baf: db "レア", $6f, $6f, "@" ; rare (shiny)
+String_81baf: db "レア", DEBUGTEST_BLACK, DEBUGTEST_BLACK, "@" ; rare (shiny)
String_81bb4: db "ノーマル@" ; normal
-String_81bb9: db $7a, "きりかえ▶@" ; (A) switches
+String_81bb9: db DEBUGTEST_A, "きりかえ▶@" ; (A) switches
; 81bc0
Function81bc0: ; 81bc0
@@ -380,10 +404,10 @@ Function81bc0: ; 81bc0
Function81bde: ; 81bde
push af
- ld a, $6a
+ ld a, DEBUGTEST_UP_ARROW
ld [hli], a
ld bc, $f
- ld a, $6b
+ ld a, DEBUGTEST_TICKS
call ByteFill
ld l, e
ld h, d
@@ -436,7 +460,7 @@ Function81c33: ; 81c33
jr z, .asm_81c69
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals2)
ld [rSVBK], a
ld hl, wBGPals2
ld de, wc608
@@ -458,11 +482,11 @@ Function81c33: ; 81c33
.asm_81c69
ld hl, wSGBPals
- ld a, $1
+ ld a, 1
ld [hli], a
- ld a, $ff
+ ld a, LOW(PALRGB_WHITE)
ld [hli], a
- ld a, $7f
+ ld a, HIGH(PALRGB_WHITE)
ld [hli], a
ld a, [wc608]
ld [hli], a
@@ -506,7 +530,7 @@ Function81ca7: ; 81ca7
Function81cbc: ; 81cbc
and $f
- add $70
+ add DEBUGTEST_0
ld [hld], a
ret
; 81cc2
@@ -657,7 +681,7 @@ Function81d89: ; 81d89
Function81d8e: ; 81d8e
hlcoord 0, 10
ld bc, $a0
- ld a, $6f
+ ld a, DEBUGTEST_BLACK
call ByteFill
hlcoord 2, 12
ld de, String_81fcd
@@ -777,8 +801,8 @@ Function81e55: ; 81e55
; 81e5e
Function81e5e: ; 81e5e
- ld bc, $a
- ld a, $6f
+ ld bc, 10
+ ld a, DEBUGTEST_BLACK
call ByteFill
ret
; 81e67
@@ -864,9 +888,9 @@ Function81eca: ; 81eca
Function81ee3: ; 81ee3
.asm_81ee3
- ld a, $ff
+ ld a, LOW(PALRGB_WHITE)
ld [hli], a
- ld a, $7f
+ ld a, HIGH(PALRGB_WHITE)
ld [hli], a
ld a, [de]
inc de
@@ -968,7 +992,7 @@ Function81f1d: ; 81f1d
; 81f5e
Function81f5e: ; 81f5e
- ld a, $6f
+ ld a, DEBUGTEST_BLACK
hlcoord 10, 0
ld [hl], a
hlcoord 15, 0
@@ -1016,17 +1040,17 @@ Function81f5e: ; 81f5e
.asm_81fb7
ld a, b
- ld [hli], a
+ ld [hli], a ; y
ld a, [de]
add a
add a
- add $18
- ld [hli], a
+ add 3 * TILE_WIDTH
+ ld [hli], a ; x
xor a
- ld [hli], a
+ ld [hli], a ; tile id
ld a, c
- ld [hli], a
- ld a, $10
+ ld [hli], a ; attributes
+ ld a, 2 * TILE_WIDTH
add b
ld b, a
inc c
@@ -1038,9 +1062,9 @@ Function81f5e: ; 81f5e
; 81fcd
String_81fcd: ; 81fcd
- db "おわりますか?" ; Are you finished?
- next "はい", $f2, $f2, $f2, $7a ; YES (A)
- next "いいえ", $f2, $f2, $7b ; NO (B)
+ db "おわりますか?" ; Are you finished?
+ next "はい<DOT><DOT><DOT>", DEBUGTEST_A ; YES...(A)
+ next "いいえ<DOT><DOT>", DEBUGTEST_B ; NO..(B)
db "@"
; 81fe3
@@ -1061,9 +1085,9 @@ TilesetColorTest:
call WaitBGMap2
xor a
ld [hBGMapMode], a
- ld de, DebugColorTestGFX + $10
- ld hl, vTiles2 tile $6a
- lb bc, BANK(DebugColorTestGFX), $16
+ ld de, DebugColorTestGFX + 1 tiles
+ ld hl, vTiles2 tile DEBUGTEST_UP_ARROW
+ lb bc, BANK(DebugColorTestGFX), 22
call Request2bpp
ld de, DebugColorTestGFX
ld hl, vTiles1
@@ -1073,23 +1097,23 @@ TilesetColorTest:
ld [hBGMapAddress + 1], a
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, $6f
+ ld a, DEBUGTEST_BLACK
call ByteFill
hlcoord 0, 0, AttrMap
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, $7
call ByteFill
ld de, $15
- ld a, $6c
+ ld a, DEBUGTEST_WHITE
call Function821d2
ld de, $1a
- ld a, $6d
+ ld a, DEBUGTEST_LIGHT
call Function821d2
ld de, $1f
- ld a, $6e
+ ld a, DEBUGTEST_DARK
call Function821d2
ld de, $24
- ld a, $6f
+ ld a, DEBUGTEST_BLACK
call Function821d2
call Function821f4
call Function8220f
@@ -1134,10 +1158,10 @@ Function821f4: ; 821f4
hlcoord 2, 8
Function82203: ; 82203
- ld a, $6a
+ ld a, DEBUGTEST_UP_ARROW
ld [hli], a
ld bc, $10 - 1
- ld a, $6b
+ ld a, DEBUGTEST_TICKS
call ByteFill
ret
; 8220f
@@ -1145,7 +1169,7 @@ Function82203: ; 82203
Function8220f: ; 8220f
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld a, [wcf64]
ld l, a
@@ -1198,7 +1222,7 @@ Function82236: ; 82236
call Function821d8
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals2)
ld [rSVBK], a
ld hl, wBGPals2
ld a, [wcf64]
@@ -1228,7 +1252,7 @@ Function82236: ; 82236
Function822a3: ; 822a3
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals2)
ld [rSVBK], a
ld hl, wBGPals2
ld a, [wcf64]
diff --git a/engine/decorations.asm b/engine/decorations.asm
index c1b703fb6..413a049a2 100755
--- a/engine/decorations.asm
+++ b/engine/decorations.asm
@@ -37,15 +37,14 @@ _KrisDecorationMenu: ; 0x2675c
; 0x2679a
.MenuDataHeader: ; 0x2679a
- db $40 ; flags
- db 00, 05 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 5, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw .MenuData2
db 1 ; default option
; 0x267a2
.MenuData2: ; 0x267a2
- db $a0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_WRAP ; flags
db 0 ; items
dw wd002
dw PlaceNthMenuStrings
@@ -423,15 +422,14 @@ PopulateDecoCategoryMenu: ; 2695b
; 0x269b5
.NonscrollingMenuDataHeader: ; 0x269b5
- db $40 ; flags
- db 00, 00 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw .NonscrollingMenuData2
db 1 ; default option
; 0x269bd
.NonscrollingMenuData2: ; 0x269bd
- db $a0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_WRAP ; flags
db 0 ; items
dw wd002
dw DecorationMenuFunction
@@ -439,15 +437,14 @@ PopulateDecoCategoryMenu: ; 2695b
; 0x269c5
.ScrollingMenuDataHeader: ; 0x269c5
- db $40 ; flags
- db 01, 01 ; start coords
- db 16, 18 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 1, 1, SCREEN_WIDTH - 2, SCREEN_HEIGHT - 2
dw .ScrollingMenuData2
db 1 ; default option
; 0x269cd
.ScrollingMenuData2: ; 0x269cd
- db $10 ; flags
+ db SCROLLINGMENU_DISPLAY_ARROWS ; flags
db 8, 0 ; rows, columns
db 1 ; horizontal spacing
dbw 0, wd002 ; text pointer
@@ -951,15 +948,14 @@ QueryWhichSide: ; 26e9a
; 26eab
MenuDataHeader_0x26eab: ; 0x26eab
- db $40 ; flags
- db 00, 00 ; start coords
- db 07, 13 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, 13, 7
dw MenuData2_0x26eb3
db 1 ; default option
; 0x26eb3
MenuData2_0x26eb3: ; 0x26eb3
- db $80 ; flags
+ db STATICMENU_CURSOR ; flags
db 3 ; items
db "RIGHT SIDE@"
db "LEFT SIDE@"
@@ -1061,12 +1057,13 @@ INCLUDE "data/decorations/decorations.asm"
DescribeDecoration:: ; 26f59
ld a, b
- ld hl, JumpTable_DecorationDesc
+ ld hl, .JumpTable
rst JumpTable
ret
; 26f5f
-JumpTable_DecorationDesc: ; 26f5f
+.JumpTable: ; 26f5f
+; entries correspond to DECODESC_* constants
dw DecorationDesc_Poster
dw DecorationDesc_LeftOrnament
dw DecorationDesc_RightOrnament
@@ -1197,7 +1194,7 @@ DecorationDesc_GiantOrnament: ; 26fdd
db "@"
; 0x26feb
-ToggleMaptileDecorations: ; 26feb
+Special_ToggleMaptileDecorations: ; 26feb
lb de, 0, 4
ld a, [Bed]
call SetDecorationTile
@@ -1251,7 +1248,7 @@ SetDecorationTile: ; 27037
ret
; 27043
-ToggleDecorationsVisibility: ; 27043
+Special_ToggleDecorationsVisibility: ; 27043
ld de, EVENT_KRISS_HOUSE_2F_CONSOLE
ld hl, VariableSprites + SPRITE_CONSOLE - SPRITE_VARS
ld a, [Console]
diff --git a/engine/delete_save_change_clock.asm b/engine/delete_save_change_clock.asm
index e77874e1c..8a711cc5e 100755
--- a/engine/delete_save_change_clock.asm
+++ b/engine/delete_save_change_clock.asm
@@ -47,14 +47,13 @@ _ResetClock: ; 4d3b1
db "@"
.NoYes_MenuDataHeader: ; 0x4d40d
- db $00 ; flags
- db 07, 14 ; start coords
- db 11, 19 ; end coords
+ db 0 ; flags
+ menu_coords 14, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .NoYes_MenuData2
db 1 ; default option
.NoYes_MenuData2: ; 0x4d415
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 2 ; items
db "NO@"
db "YES@"
@@ -285,14 +284,13 @@ _DeleteSaveData: ; 4d54c
db "@"
.NoYesMenuDataHeader: ; 0x4d585
- db $00 ; flags
- db 07, 14 ; start coords
- db 11, 19 ; end coords
+ db 0 ; flags
+ menu_coords 14, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
.MenuData2: ; 0x4d58d
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 2 ; items
db "NO@"
db "YES@"
diff --git a/engine/dma_transfer.asm b/engine/dma_transfer.asm
index 56e7d56da..60b515acf 100755
--- a/engine/dma_transfer.asm
+++ b/engine/dma_transfer.asm
@@ -112,14 +112,14 @@ Mobile_ReloadMapPart: ; 104099
ret
; 1040d4
-; XXX
+; unused
ld hl, .unreferenced_1040da
jp CallInSafeGFXMode
.unreferenced_1040da
ld a, $1
ld [rVBK], a
- ld a, $3
+ ld a, BANK(w3_d800)
ld [rSVBK], a
ld de, w3_d800
ld a, [hBGMapAddress + 1]
@@ -136,14 +136,14 @@ Mobile_ReloadMapPart: ; 104099
ret
; 1040fb
-; XXX
+; unused
ld hl, .unreferenced_104101
jp CallInSafeGFXMode
.unreferenced_104101
ld a, $1
ld [rVBK], a
- ld a, $3
+ ld a, BANK(w3_d800)
ld [rSVBK], a
ld hl, w3_d800
call HDMATransferToWRAMBank3
@@ -221,7 +221,7 @@ CallInSafeGFXMode: ; 104177
ld [hMapAnims], a
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wScratchTileMap)
ld [rSVBK], a
ld a, [rVBK]
push af
@@ -472,7 +472,7 @@ _Get2bpp:: ; 104284
; switch to WRAM bank 6
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wScratchTileMap)
ld [rSVBK], a
push bc
@@ -542,7 +542,7 @@ _Get1bpp:: ; 1042b2
.bankswitch ; 1042d6
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wScratchTileMap)
ld [rSVBK], a
push bc
diff --git a/engine/dummy_game.asm b/engine/dummy_game.asm
index aecaa7425..6d7e12196 100755
--- a/engine/dummy_game.asm
+++ b/engine/dummy_game.asm
@@ -482,7 +482,7 @@ DummyGame_InitStrings: ; e2152
.japstr1
db "とったもの@"
.japstr2
- db "あと かい@"
+ db "あと かい@"
; e2183
DummyGame_Card2Coord: ; e2183
diff --git a/engine/events.asm b/engine/events.asm
index 7356a8910..96108730a 100644
--- a/engine/events.asm
+++ b/engine/events.asm
@@ -1,4 +1,5 @@
-INCLUDE "includes.asm"
+INCLUDE "constants.asm"
+
SECTION "Events", ROMX
@@ -395,7 +396,7 @@ CheckTileEvent: ; 96874
ld a, [hli]
ld h, [hl]
ld l, a
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
call CallScript
ret
; 968c7
@@ -449,7 +450,7 @@ RunSceneScript: ; 968ec
ld e, a
ld d, 0
- ld hl, wCurrMapSceneScriptHeaderPointer
+ ld hl, wCurrMapSceneScriptsPointer
ld a, [hli]
ld h, [hl]
ld l, a
@@ -457,9 +458,9 @@ rept 4
add hl, de
endr
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
call GetFarHalfword
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
call CallScript
ld hl, ScriptFlags
@@ -634,7 +635,7 @@ TryObjectEvent: ; 969b5
ld a, [hli]
ld h, [hl]
ld l, a
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
call CallScript
ret
; 96a12
@@ -645,7 +646,7 @@ TryObjectEvent: ; 969b5
ld a, [hli]
ld h, [hl]
ld l, a
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
ld de, EngineBuffer1
ld bc, 2
call FarCopyBytes
@@ -730,7 +731,7 @@ TryBGEvent: ; 96a38
ld a, [hli]
ld h, [hl]
ld l, a
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
call CallScript
scf
ret
@@ -739,7 +740,7 @@ TryBGEvent: ; 96a38
call CheckBGEventFlag
jp nz, .dontread
call PlayTalkObject
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
ld de, EngineBuffer1
ld bc, 3
call FarCopyBytes
@@ -752,7 +753,7 @@ TryBGEvent: ; 96a38
.copy
call CheckBGEventFlag
jr nz, .dontread
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
ld de, EngineBuffer1
ld bc, 3
call FarCopyBytes
@@ -773,9 +774,9 @@ TryBGEvent: ; 96a38
pop hl
inc hl
inc hl
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
call GetFarHalfword
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
call CallScript
scf
ret
@@ -791,7 +792,7 @@ CheckBGEventFlag: ; 96ad8
ld h, [hl]
ld l, a
push hl
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
call GetFarHalfword
ld e, l
ld d, h
@@ -994,6 +995,7 @@ CountStep: ; 96b79
ret
; 96bd3
+; unused
.unreferenced ; 96bd3
ld a, 7
scf
@@ -1060,7 +1062,7 @@ Invalid_0x96c2d: ; 96c2d
end
; 96c2e
-; unreferenced
+; unused
end
; 96c2f
@@ -1105,4 +1107,5 @@ ChangeDirectionScript: ; 9
; 96c56
INCLUDE "engine/scripting.asm"
+
INCLUDE "engine/events_2.asm"
diff --git a/engine/events/battle_tower/battle_tower.asm b/engine/events/battle_tower/battle_tower.asm
new file mode 100755
index 000000000..94a29cdab
--- /dev/null
+++ b/engine/events/battle_tower/battle_tower.asm
@@ -0,0 +1,1669 @@
+Special_BattleTowerRoomMenu: ; 1700b0
+; special
+ call InitBattleTowerChallengeRAM
+ farcall _BattleTowerRoomMenu
+ ret
+; 1700ba
+
+Special_Function1700ba: ; 1700ba
+ call InitBattleTowerChallengeRAM
+ farcall Function11811a
+ ret
+; 1700c4
+
+Function1700c4: ; 1700c4
+ ld a, [rSVBK]
+ push af
+ ld a, $3
+ ld [rSVBK], a
+
+ call Function17042c
+
+ ld a, $5
+ call GetSRAMBank
+ ld a, $1
+ ld [$be45], a
+ xor a
+ ld [$be46], a
+ ld hl, w3_dffc
+ ld de, $aa41
+ ld bc, 4
+ call CopyBytes
+ ld hl, w3_d202Name
+ ld de, $aa8e
+ ld bc, 7 * $cc ; length of battle tower struct from japanese games?
+ call CopyBytes
+ ld hl, $aa5d ; some sort of count
+ ld a, [hl]
+ inc [hl]
+ inc hl
+ sla a
+ sla a
+ ld e, a
+ ld d, $0
+ add hl, de
+ ld e, l
+ ld d, h
+ ld hl, w3_dffc
+ ld bc, 4
+ call CopyBytes
+ call CloseSRAM
+ pop af
+ ld [rSVBK], a
+ ret
+; 170114
+
+Special_Function170114: ; 170114
+ call InitBattleTowerChallengeRAM
+ call .Function170121
+ farcall Function11805f
+ ret
+; 170121
+
+.Function170121: ; 170121
+ ld a, $5
+ call GetSRAMBank
+ ld hl, $a948
+ ld de, wMisc
+ ld bc, $f6 ; 246
+ call CopyBytes
+ call CloseSRAM
+ call Function170c8b
+ ret
+; 170139
+
+Function170139: ; 170139
+; Convert the 4-digit decimal number at 5:aa41 into binary
+ ld a, $5
+ call GetSRAMBank
+ ld de, $aa41
+ ld h, $0
+ ld l, h
+ ld bc, 1000
+ call .DecToBin
+ ld bc, 100
+ call .DecToBin
+ ld bc, 10
+ call .DecToBin
+ ld a, [de]
+ ld c, a
+ ld b, $0
+ add hl, bc
+ call CloseSRAM
+; Store that number in wMisc
+ ld a, h
+ ld [wMisc], a
+ ld a, l
+ ld [wMisc + 1], a
+ ld hl, wBT_OTTempPkmn1DVs
+ ld a, [PlayerID]
+ ld [hli], a
+ ld a, [PlayerID + 1]
+ ld [hli], a
+ ld a, [wSecretID]
+ ld [hli], a
+ ld a, [wSecretID + 1]
+ ld [hli], a
+ ld e, l
+ ld d, h
+ ld hl, PlayerName
+ ld bc, NAME_LENGTH_JAPANESE - 1
+ call CopyBytes
+ ld bc, PlayerID
+ ld de, wPlayerGender
+ farcall GetMobileOTTrainerClass
+ ld de, wBT_OTTempPkmn1CaughtGender
+ ld a, c
+ ld [de], a
+ inc de
+ ld a, LOW(PartyMons)
+ ld [wcd49], a
+ ld a, HIGH(PartyMons)
+ ld [wcd4a], a
+ ld a, LOW(PartyMonNicknames)
+ ld [wcd4b], a
+ ld a, HIGH(PartyMonNicknames)
+ ld [wcd4c], a
+ ld a, 3
+.CopyLoop:
+ push af
+ ld a, [wcd49]
+ ld l, a
+ ld a, [wcd4a]
+ ld h, a
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call CopyBytes
+ ld a, l
+ ld [wcd49], a
+ ld a, h
+ ld [wcd4a], a
+ ld a, [wcd4b]
+ ld l, a
+ ld a, [wcd4c]
+ ld h, a
+ ld bc, $0006
+ call CopyBytes
+ ld a, l
+ ld [wcd4b], a
+ ld a, h
+ ld [wcd4c], a
+ pop af
+ dec a
+ jr nz, .CopyLoop
+ ld a, $4
+ call GetSRAMBank
+ ld hl, $a013
+ ld bc, $24
+ call CopyBytes
+ call CloseSRAM
+ ld a, $5
+ call GetSRAMBank
+ ld hl, $a894
+ ld bc, NAME_LENGTH_JAPANESE
+ call CopyBytes
+ ld hl, wMisc
+ ld de, $a948
+ ld bc, $f6
+ call CopyBytes
+ call CloseSRAM
+ ret
+; 17020c
+
+.DecToBin: ; 17020c
+ ld a, [de]
+ inc de
+ and a
+ ret z
+
+.digit_loop
+ add hl, bc
+ dec a
+ jr nz, .digit_loop
+ ret
+; 170215
+
+Special_BattleTowerBattle: ; 170215
+ xor a
+ ld [wBattleTowerBattleEnded], a
+ call _BattleTowerBattle
+ ret
+; 17021d
+
+DummySpecial_17021d: ; 17021d
+ ret
+; 17021e
+
+InitBattleTowerChallengeRAM: ; 17021e
+ xor a
+ ld [wBattleTowerBattleEnded], a
+ ld [wNrOfBeatenBattleTowerTrainers], a
+ ld [wcf65], a
+ ld [wcf66], a
+ ret
+; 17022c
+
+_BattleTowerBattle: ; 17022c
+.loop
+ call .do_dw
+ call DelayFrame
+ ld a, [wBattleTowerBattleEnded]
+ cp $1
+ jr nz, .loop
+ ret
+; 17023a
+
+.do_dw ; 17023a
+ ld a, [wBattleTowerBattleEnded]
+ ld e, a
+ ld d, 0
+ ld hl, .dw
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+; 170249
+
+.dw ; 170249
+ dw RunBattleTowerTrainer
+ dw SkipBattleTowerTrainer
+; 17024d
+
+RunBattleTowerTrainer: ; 17024d
+ ld a, [Options]
+ push af
+ ld hl, Options
+ set BATTLE_SHIFT, [hl] ; SET MODE
+
+ ld a, [InBattleTowerBattle]
+ push af
+ or $1
+ ld [InBattleTowerBattle], a
+
+ xor a
+ ld [wLinkMode], a
+ farcall Special_StubbedTrainerRankings_Healings
+ farcall HealParty
+ call ReadBTTrainerParty
+ call Clears5_a89a
+
+ predef StartBattle
+
+ farcall LoadPokemonData
+ farcall HealParty
+ ld a, [wBattleResult]
+ ld [ScriptVar], a
+ and a
+ jr nz, .lost
+ ld a, BANK(sNrOfBeatenBattleTowerTrainers)
+ call GetSRAMBank
+ ld a, [sNrOfBeatenBattleTowerTrainers]
+ ld [wNrOfBeatenBattleTowerTrainers], a
+ call CloseSRAM
+ ld hl, StringBuffer3
+ ld a, [wNrOfBeatenBattleTowerTrainers]
+ add "1"
+ ld [hli], a
+ ld a, "@"
+ ld [hl], a
+
+.lost
+ pop af
+ ld [InBattleTowerBattle], a
+ pop af
+ ld [Options], a
+ ld a, $1
+ ld [wBattleTowerBattleEnded], a
+ ret
+
+
+ReadBTTrainerParty: ; 1702b7
+; Initialise the BattleTower-Trainer and his Pkmn
+ call CopyBTTrainer_FromBT_OT_TowBT_OTTemp
+
+; Check the nicknames for illegal characters, and replace bad nicknames
+; with their species names.
+ ld de, wBT_OTTempPkmn1Name ; $c643
+ ld c, MON_NAME_LENGTH
+ farcall CheckStringForErrors
+ jr nc, .skip_mon_1
+
+ ld a, [wBT_OTTempPkmn1]
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ ld l, e
+ ld h, d
+ ld de, wBT_OTTempPkmn1Name ; $c643
+ ld bc, MON_NAME_LENGTH
+ call CopyBytes
+
+.skip_mon_1
+ ld de, wBT_OTTempPkmn2Name ; $c67e
+ ld c, MON_NAME_LENGTH
+ farcall CheckStringForErrors
+ jr nc, .skip_mon_2
+ ld a, [wBT_OTTempPkmn2] ; [$c64e]
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ ld l, e
+ ld h, d
+ ld de, wBT_OTTempPkmn2Name ; $c67e
+ ld bc, MON_NAME_LENGTH
+ call CopyBytes
+
+.skip_mon_2
+ ld de, wBT_OTTempPkmn3Name ; $c686 + 51 = $c6b9
+ ld c, MON_NAME_LENGTH
+ farcall CheckStringForErrors
+ jr nc, .skip_mon_3
+ ld a, [wBT_OTTempPkmn3] ; [$c689]
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ ld l, e
+ ld h, d
+ ld de, wBT_OTTempPkmn3Name ; $c686 + 51 = $c6b9
+ ld bc, MON_NAME_LENGTH
+ call CopyBytes
+
+.skip_mon_3
+; Add the terminator character to each of these names
+ ld a, "@"
+ ld [wBT_OTTempPkmn1NameEnd - 1], a ; $c64d
+ ld [wBT_OTTempPkmn2NameEnd - 1], a ; $c688
+ ld [wBT_OTTempPkmn3NameEnd - 1], a ; $c68a + 57 = $c6c3
+; Fix errors in the movesets
+ call CheckBTMonMovesForErrors
+; Repair the trainer name if needed, then copy it to OTPlayerName
+ ld de, wBT_OTTempName
+ ld c, NAME_LENGTH - 1
+ farcall CheckStringForErrors
+ jr nc, .trainer_name_okay
+ ld hl, BT_ChrisName
+ jr .done_trainer_name
+
+.trainer_name_okay
+ ld hl, wBT_OTTempName ; 0xc608
+
+.done_trainer_name
+ ld de, OTPlayerName
+ ld bc, NAME_LENGTH - 1
+ call CopyBytes
+ ld a, "@"
+ ld [de], a
+
+ ld hl, wBT_OTTempTrainerClass
+ ld a, [hli]
+ ld [OtherTrainerClass], a
+ ld a, LOW(OTPartyMonNicknames)
+ ld [BGMapBuffer], a
+ ld a, HIGH(OTPartyMonNicknames)
+ ld [BGMapBuffer + 1], a
+
+ ; Copy Pkmn into Memory from the address in hl
+ ld de, OTPartyMon1Species
+ ld bc, OTPartyCount
+ ld a, BATTLETOWER_PARTY_LENGTH
+ ld [bc], a
+ inc bc
+.otpartymon_loop
+ push af
+ ld a, [hl]
+ ld [bc], a
+ inc bc
+ push bc
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call CopyBytes
+ push de
+ ld a, [BGMapBuffer]
+ ld e, a
+ ld a, [BGMapBuffer + 1]
+ ld d, a
+ ld bc, MON_NAME_LENGTH
+ call CopyBytes
+ ld a, e
+ ld [BGMapBuffer], a
+ ld a, d
+ ld [BGMapBuffer + 1], a
+ pop de
+ pop bc
+ pop af
+ dec a
+ and a
+ jr nz, .otpartymon_loop
+ ld a, -1
+ ld [bc], a
+ ret
+; 170394
+
+ValidateBTParty: ; 170394
+; Check for and fix errors in party data
+ ld hl, wBT_OTTempPkmn1Species
+ ld d, BATTLETOWER_PARTY_LENGTH
+.pkmn_loop
+ push de
+ push hl
+ ld b, h
+ ld c, l
+ ld a, [hl]
+ and a
+idx = $ff
+rept ($ff +- NUM_POKEMON)
+ jr z, .invalid
+ cp idx
+idx = idx +- 1
+endr
+ jr nz, .valid
+
+.invalid
+ ld a, SMEARGLE
+ ld [hl], a
+
+.valid
+ ld [CurSpecies], a
+ call GetBaseData
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$b2fb] ; s5_b2fb ; max level?
+ call CloseSRAM
+ ld e, a
+ ld hl, MON_LEVEL
+ add hl, bc
+ ld a, [hl]
+ cp MIN_LEVEL
+ ld a, MIN_LEVEL
+ jr c, .load
+ ld a, [hl]
+ cp e
+ jr c, .dont_load
+ ld a, e
+
+.load
+ ld [hl], a
+
+.dont_load
+ ld [CurPartyLevel], a
+ ld hl, MON_MOVES
+ add hl, bc
+ ld d, NUM_MOVES - 1
+ ld a, [hli]
+ and a
+ jr z, .not_move
+ cp NUM_ATTACKS + 1
+ jr nc, .not_move
+ jr .valid_move
+
+.not_move
+ dec hl
+ ld a, POUND
+ ld [hli], a
+ xor a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ jr .done_moves
+
+.valid_move
+ ld a, [hl]
+ cp NUM_ATTACKS + 1
+ jr c, .next
+ ld [hl], $0
+
+.next
+ inc hl
+ dec d
+ jr nz, .valid_move
+
+.done_moves
+ ld hl, MON_MAXHP
+ add hl, bc
+ ld d, h
+ ld e, l
+ push hl
+ push de
+ ld hl, MON_STAT_EXP - 1
+ add hl, bc
+ ld b, $1
+ predef CalcPkmnStats
+ pop de
+ pop hl
+ dec de
+ dec de
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ ld [de], a
+ pop hl
+ ld bc, PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH
+ add hl, bc
+ pop de
+ dec d
+ jp nz, .pkmn_loop
+ ret
+; 170426
+
+BT_ChrisName: ; 170426
+ db "CHRIS@"
+; 17042c
+
+Function17042c: ; 17042c
+ ld hl, w3_d202TrainerData
+ ld a, BATTLETOWER_STREAK_LENGTH
+.loop
+ push af
+ push hl
+ ld c, BATTLETOWER_TRAINERDATALENGTH / 2
+.loop2
+ ; First byte is a comparison value.
+ ld a, [hli]
+ ld b, a
+ ; Second byte is a lookup index.
+ ld a, [hli]
+ and a
+ jr z, .empty
+ cp 15
+ jr nc, .copy_data
+
+ push hl
+ ld hl, Unknown_170470
+ dec a
+ ld e, a
+ ld d, 0
+ add hl, de
+ ld a, [hl]
+ pop hl
+
+ ; If Unknown_170470[a-1] <= b, overwrite the current trainer's data
+ ; with Unknown17047e, and exit the inner loop.
+ cp b
+ jr c, .copy_data
+ jr z, .copy_data
+ jr .next_iteration
+
+.empty
+ ; If a == 0 and b >= $fc, overwrite the current trainer's data with
+ ; Unknown17047e, and exit the inner loop.
+ ld a, b
+ cp $fc
+ jr nc, .copy_data
+
+.next_iteration
+ dec c
+ jr nz, .loop2
+ jr .next_trainer
+
+.copy_data
+ pop de
+ push de
+ ld hl, Unknown_17047e
+ ld bc, BATTLETOWER_TRAINERDATALENGTH
+ call CopyBytes
+
+.next_trainer
+ pop hl
+ ld de, BATTLE_TOWER_STRUCT_LENGTH
+ add hl, de
+ pop af
+ dec a
+ jr nz, .loop
+ ret
+; 170470
+
+INCLUDE "data/battle_tower/unknown_levels.asm"
+
+
+CopyBTTrainer_FromBT_OT_TowBT_OTTemp: ; 1704a2
+; copy the BattleTower-Trainer data that lies at 'BT_OTTrainer' to 'wBT_OTTemp'
+ ld a, [rSVBK]
+ push af
+ ld a, BANK(BT_OTTrainer)
+ ld [rSVBK], a
+
+ ld hl, BT_OTTrainer
+ ld de, wBT_OTTemp
+ ld bc, BATTLE_TOWER_STRUCT_LENGTH
+ call CopyBytes
+
+ pop af
+ ld [rSVBK], a
+
+ ld a, BANK(sBattleTowerChallengeState)
+ call GetSRAMBank
+ ld a, BATTLETOWER_CHALLENGE_IN_PROGESS
+ ld [sBattleTowerChallengeState], a
+ ld hl, sNrOfBeatenBattleTowerTrainers
+ inc [hl]
+ call CloseSRAM
+SkipBattleTowerTrainer: ; 1704c9
+ ret
+; 1704ca
+
+Unreferenced_Function1704ca: ; 1704ca
+ ld a, [$be46]
+ cp $7
+ jr c, .asm_1704d3
+ ld a, $6
+
+.asm_1704d3
+ ld hl, $afce
+ ld de, -$e0
+.asm_1704d9
+ and a
+ jr z, .asm_1704e0
+ add hl, de
+ dec a
+ jr .asm_1704d9
+
+.asm_1704e0
+ ret
+; 1704e1
+
+UnusedSpecial_Function1704e1: ; 1704e1
+ call SpeechTextBox
+ call FadeToMenu
+ call InitBattleTowerChallengeRAM
+ call .JumptableLoop
+ call CloseSubmenu
+ ret
+; 1704f1
+
+.JumptableLoop: ; 1704f1
+ call ClearBGPalettes
+ call ClearSprites
+ call ClearScreen
+.loop
+ call JoyTextDelay
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .done
+ call .DoJumptable
+ farcall ReloadMapPart
+ jr .loop
+
+.done
+ ret
+; 170510
+
+.DoJumptable: ; 170510
+ ld a, [wJumptableIndex]
+ ld e, a
+ ld d, 0
+ ld hl, .dw
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+; 17051f
+
+.dw ; 17051f
+ dw .Jumptable_0
+ dw .Jumptable_1
+ dw .Jumptable_2
+; 170525
+
+.Jumptable_0: ; 170525
+ ld a, $5
+ call GetSRAMBank
+
+ ld hl, $a89c
+ ld de, StringBuffer3
+ ld bc, $16
+ call CopyBytes
+
+ ld hl, $a8b2
+ ld de, wMisc
+ ld bc, $0096
+ call CopyBytes
+
+ call CloseSRAM
+ hlcoord 1, 1
+ ld de, StringBuffer3
+ call PlaceString
+ hlcoord 1, 3
+ ld de, .String_Mail
+ call PlaceString
+ hlcoord 4, 3
+ ld de, StringBuffer4
+ call PlaceString
+ hlcoord 8, 3
+ ld de, .String_PastReaders
+ call PlaceString
+ call .DrawBorder
+ call .PlaceTextItems
+ jr .NextJumptableFunction
+
+
+.Jumptable_1:
+ call SetPalettes
+ call .NextJumptableFunction
+
+
+.Jumptable_2:
+ ld hl, hJoyPressed
+ ld a, [hl]
+ and A_BUTTON
+ jr nz, .pressed_a_or_b
+ ld a, [hl]
+ and B_BUTTON
+ jr nz, .pressed_a_or_b
+ ld a, [hl]
+ and D_UP
+ jr nz, .pressed_up
+ ld a, [hl]
+ and D_DOWN
+ jr nz, .pressed_down
+ ret
+
+.pressed_up
+ ld a, [wNrOfBeatenBattleTowerTrainers]
+ and a
+ ret z
+ sub 15
+ ld [wNrOfBeatenBattleTowerTrainers], a
+ call .PlaceTextItems
+ ret
+
+.pressed_down
+ ld a, [wNrOfBeatenBattleTowerTrainers]
+ cp 60
+ ret z
+ add 15
+ ld [wNrOfBeatenBattleTowerTrainers], a
+ call .PlaceTextItems
+ ret
+
+.pressed_a_or_b
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+
+.NextJumptableFunction:
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+; 1705b7
+
+.DrawBorder: ; 1705b7
+ hlcoord 0, 4
+ ld a, "┌"
+ ld [hli], a
+ ld c, SCREEN_WIDTH - 2
+.top_border_loop
+ ld a, "─"
+ ld [hli], a
+ dec c
+ jr nz, .top_border_loop
+ ld a, "┐"
+ ld [hli], a
+ ld de, SCREEN_WIDTH
+ ld c, 12
+.left_border_loop
+ ld a, "│"
+ ld [hl], a
+ add hl, de
+ dec c
+ jr nz, .left_border_loop
+ ld a, "└"
+ ld [hli], a
+ ld c, SCREEN_WIDTH - 2
+.bottom_border_loop
+ ld a, "─"
+ ld [hli], a
+ dec c
+ jr nz, .bottom_border_loop
+ ld a, "┘"
+ ld [hl], a
+ ld de, -SCREEN_WIDTH
+ add hl, de
+ ld c, 12
+.right_border_loop
+ ld a, "│"
+ ld [hl], a
+ add hl, de
+ dec c
+ jr nz, .right_border_loop
+ ret
+; 1705f0
+
+.PlaceTextItems: ; 1705f0
+ call .ClearBox
+ call .PlaceUpDownArrows
+ ld a, $50
+ ld [wcd4e], a
+ ld hl, wMisc
+ ld a, [wNrOfBeatenBattleTowerTrainers]
+ ld c, a
+ xor a
+ ld b, a
+ add hl, bc
+ push hl
+ pop bc
+ hlcoord 1, 6
+ ld a, 6
+.loop1
+ push af
+ push hl
+ ld a, 3
+.loop2
+ push af
+ ld de, wcd49
+ ld a, [bc]
+ and a
+ jr z, .fill_with_e3
+; .copy
+ ld a, 5
+.loop3a
+ push af
+ ld a, [bc]
+ ld [de], a
+ inc bc
+ inc de
+ pop af
+ dec a
+ jr nz, .loop3a
+ jr .rejoin
+
+.fill_with_e3
+ ld a, 5
+.loop3b
+ push af
+ ld a, $e3
+ ld [de], a
+ inc de
+ inc bc
+ pop af
+ dec a
+ jr nz, .loop3b
+
+.rejoin
+ ld de, wcd49
+ push bc
+ call PlaceString
+ ld de, NAME_LENGTH_JAPANESE
+ add hl, de
+ pop bc
+ pop af
+ dec a
+ jr nz, .loop2
+ pop hl
+ ld de, $28
+ add hl, de
+ pop af
+ dec a
+ jr nz, .loop1
+ ret
+; 17064b
+
+.ClearBox: ; 17064b
+ hlcoord 1, 5
+ xor a
+ ld b, 12
+.clearbox_row
+ ld c, SCREEN_WIDTH - 2
+.clearbox_column
+ ld [hli], a
+ dec c
+ jr nz, .clearbox_column
+ inc hl
+ inc hl
+ dec b
+ jr nz, .clearbox_row
+ ret
+; 17065d
+
+.PlaceUpDownArrows: ; 17065d
+ ld a, [wNrOfBeatenBattleTowerTrainers]
+ and a
+ jr z, .nope
+ hlcoord 18, 5
+ ld a, "▲"
+ ld [hl], a
+
+.nope
+ ld a, [wNrOfBeatenBattleTowerTrainers]
+ cp 60
+ ret z
+ hlcoord 18, 16
+ ld a, "▼"
+ ld [hl], a
+ ret
+; 170676
+
+.String_Mail: ; 170676
+ db "ルーム@"
+; 17067a
+
+.String_PastReaders: ; 17067a
+ db "れきだいりーダーいちらん@"
+; 170687
+
+Special_BattleTowerAction: ; 170687
+ ld a, [ScriptVar]
+ ld e, a
+ ld d, 0
+ ld hl, .dw
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+; 170696
+
+
+.dw ; 170696 (5c:4696)
+ dw BattleTowerAction_CheckExplanationRead ; 0x00
+ dw BattleTowerAction_SetExplanationRead ; 0x01
+ dw BattleTowerAction_GetChallengeState ; 0x02
+ dw BattleTowerAction_SetByteToQuickSaveChallenge ; 0x03
+ dw BattleTowerAction_SetByteToCancelChallenge ; 0x04
+ dw Function1707ac ; 0x05
+ dw Function1707f4 ; 0x06
+ dw SaveBattleTowerLevelGroup ; 0x07
+ dw LoadBattleTowerLevelGroup ; 0x08
+ dw BattleTower_CheckSaveFileExistsAndIsYours ; 0x09
+ dw Function1708b1 ; 0x0a
+ dw CheckMobileEventIndex ; 0x0b
+ dw Function1708c8 ; 0x0c
+ dw Function1708f0 ; 0x0d
+ dw BattleTowerAction_EggTicket ; 0x0e
+ dw Function1709aa ; 0x0f
+ dw Function1709bb ; 0x10
+ dw Function170a9c ; 0x11
+ dw Function170aa0 ; 0x12
+ dw Function170aaf ; 0x13
+ dw Function170abe ; 0x14
+ dw Function170ad7 ; 0x15
+ dw Function170807 ; 0x16
+ dw Function17081d ; 0x17
+ dw BattleTowerAction_LevelCheck ; 0x18
+ dw BattleTowerAction_UbersCheck ; 0x19
+ dw ResetBattleTowerTrainersSRAM ; 0x1a
+ dw BattleTower_GiveReward ; 0x1b
+ dw Function17071b ; 0x1c
+ dw Function170729 ; 0x1d
+ dw BattleTower_RandomlyChooseReward ; 0x1e
+ dw BattleTower_SaveOptions ; 0x1f
+
+
+; Reset the save memory for BattleTower-Trainers (Counter and all 7 TrainerBytes)
+ResetBattleTowerTrainersSRAM: ; 1706d6 (5c:46d6) BattleTowerAction $1a
+ ld a, BANK(sBTTrainers)
+ call GetSRAMBank
+
+ ld a, $ff
+ ld hl, sBTTrainers
+ ld bc, BATTLETOWER_STREAK_LENGTH
+ call ByteFill
+
+ xor a
+ ld [sNrOfBeatenBattleTowerTrainers], a
+
+ call CloseSRAM
+
+ ret
+
+BattleTower_GiveReward: ; 1706ee (5c:46ee) BattleTowerAction $1b
+ ld a, BANK(sBattleTowerReward)
+ call GetSRAMBank
+
+ ld a, [sBattleTowerReward]
+ call CloseSRAM
+ ld [ScriptVar], a
+ ld hl, NumItems
+ ld a, [hli]
+ cp MAX_ITEMS
+ ret c
+ ld b, MAX_ITEMS
+ ld a, [ScriptVar]
+ ld c, a
+.loop
+ ld a, [hli]
+ cp c
+ jr nz, .next
+ ld a, [hl]
+ cp 95
+ ret c
+.next
+ inc hl
+ dec b
+ jr nz, .loop
+ ld a, POTION
+ ld [ScriptVar], a
+ ret
+
+Function17071b: ; 17071b (5c:471b) BattleTowerAction $1c
+ ld a, BANK(sBattleTowerChallengeState)
+ call GetSRAMBank
+ ld a, BATTLETOWER_WON_CHALLENGE
+ ld [sBattleTowerChallengeState], a
+ call CloseSRAM
+ ret
+
+Function170729: ; 170729 (5c:4729) BattleTowerAction $1d
+ ld a, BANK(sBattleTowerChallengeState)
+ call GetSRAMBank
+ ld a, BATTLETOWER_RECEIVED_REWARD
+ ld [sBattleTowerChallengeState], a
+ call CloseSRAM
+ ret
+
+BattleTower_SaveOptions: ; 170737 (5c:4737) BattleTowerAction $1f
+ farcall SaveOptions
+ ret
+
+BattleTower_RandomlyChooseReward: ; 17073e (5c:473e) BattleTowerAction $1e
+; Generate a random stat boosting item.
+.loop
+ call Random
+ ld a, [hRandomAdd]
+ and $7
+ cp 6
+ jr c, .okay
+ sub 6
+.okay
+ add HP_UP
+ cp LUCKY_PUNCH
+ jr z, .loop
+ push af
+ ld a, BANK(sBattleTowerReward)
+ call GetSRAMBank
+ pop af
+ ld [sBattleTowerReward], a
+ call CloseSRAM
+ ret
+
+BattleTowerAction_CheckExplanationRead: ; 17075f (5c:475f) BattleTowerAction $00
+ call BattleTower_CheckSaveFileExistsAndIsYours
+ ld a, [ScriptVar]
+ and a
+ ret z
+
+ ld a, BANK(sBattleTowerSaveFileFlags)
+ call GetSRAMBank
+ ld a, [sBattleTowerSaveFileFlags]
+ and $2
+ ld [ScriptVar], a
+ call CloseSRAM
+ ret
+
+BattleTowerAction_GetChallengeState: ; 170778 (5c:4778) BattleTowerAction $02
+ ld hl, sBattleTowerChallengeState
+ ld a, BANK(sBattleTowerChallengeState)
+ call GetSRAMBank
+ ld a, [hl]
+ ld [ScriptVar], a
+ call CloseSRAM
+ ret
+
+BattleTowerAction_SetExplanationRead: ; 170788 (5c:4788) BattleTowerAction $01
+ ld a, BANK(sBattleTowerSaveFileFlags)
+ call GetSRAMBank
+ ld a, [sBattleTowerSaveFileFlags]
+ or $2
+ ld [sBattleTowerSaveFileFlags], a
+ call CloseSRAM
+ ret
+
+BattleTowerAction_SetByteToQuickSaveChallenge: ; 170799 (5c:4799) BattleTowerAction $03
+ ld c, BATTLETOWER_SAVED_AND_LEFT
+ jr asm_17079f
+
+BattleTowerAction_SetByteToCancelChallenge: ; 17079d (5c:479d) BattleTowerAction $04
+ ld c, BATTLETOWER_NO_CHALLENGE
+asm_17079f: ; 17079f (5c:479f)
+ ld a, BANK(sBattleTowerChallengeState)
+ call GetSRAMBank
+ ld a, c
+ ld [sBattleTowerChallengeState], a
+ call CloseSRAM
+ ret
+
+Function1707ac: ; 1707ac (5c:47ac) BattleTowerAction $05
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$aa8c]
+ ld b, a
+ ld a, [$be46]
+ ld [ScriptVar], a
+ call CloseSRAM
+ and a
+ ret z
+ ld a, b
+ cp $2
+ jr nc, .asm_1707ef
+ push bc
+ call UpdateTime
+ pop bc
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$aa8b]
+ call CloseSRAM
+ ld c, a
+ ld a, [CurDay]
+ sub c
+ jr c, .asm_1707e5
+ cp $8
+ jr nc, .asm_1707ef
+ ld a, b
+ and a
+ jr nz, .asm_1707ef
+ ret
+.asm_1707e5
+ ld hl, CurDay
+ ld a, $8c
+ sub c
+ add [hl]
+ cp $8
+ ret c
+.asm_1707ef
+ ld a, $8
+ ld [ScriptVar], a
+
+Function1707f4: ; 1707f4 (5c:47f4) BattleTowerAction $06
+ ld a, $5
+ call GetSRAMBank
+ xor a
+ ld [$be46], a
+ ld [$aa8b], a
+ ld [$aa8c], a
+ call CloseSRAM
+ ret
+
+Function170807: ; 170807 (5c:4807) BattleTowerAction $16
+ call UpdateTime
+ ld a, $5
+ call GetSRAMBank
+ ld a, [CurDay]
+ ld [$b2f9], a
+ xor a
+ ld [$b2fa], a
+ call CloseSRAM
+ ret
+
+Function17081d: ; 17081d (5c:481d) BattleTowerAction $17
+ xor a
+ ld [ScriptVar], a
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$b2f9]
+ ld c, a
+ ld a, [$b2fa]
+ ld b, a
+ call CloseSRAM
+ cp $2
+ jr nc, .asm_170853
+ push bc
+ call UpdateTime
+ pop bc
+ ld a, [CurDay]
+ sub c
+ jr c, .asm_170849
+ cp $b
+ jr nc, .asm_170853
+ ld a, b
+ and a
+ jr nz, .asm_170853
+ ret
+
+.asm_170849
+ ld hl, CurDay
+ ld a, 140
+ sub c
+ add [hl]
+ cp $b
+ ret c
+.asm_170853
+ ld a, $1
+ ld [ScriptVar], a
+ ld a, $5
+ call GetSRAMBank
+ xor a
+ ld [$b2f9], a
+ ld [$b2fa], a
+ call CloseSRAM
+ ret
+
+SaveBattleTowerLevelGroup: ; 170868 (5c:4868) BattleTowerAction $07
+ ld a, BANK(sBTChoiceOfLevelGroup)
+ call GetSRAMBank
+ ld a, [rSVBK]
+ push af
+ ld a, $3
+ ld [rSVBK], a
+ ld a, [wBTChoiceOfLvlGroup]
+ ld [sBTChoiceOfLevelGroup], a
+ pop af
+ ld [rSVBK], a
+ call CloseSRAM
+ ret
+
+LoadBattleTowerLevelGroup: ; 170881 (5c:4881) BattleTowerAction $08 ; Load level group choice
+ ld a, BANK(sBTChoiceOfLevelGroup)
+ call GetSRAMBank
+ ld a, [rSVBK]
+ push af
+ ld a, $3
+ ld [rSVBK], a
+ ld a, [sBTChoiceOfLevelGroup]
+ ld [wBTChoiceOfLvlGroup], a
+ pop af
+ ld [rSVBK], a
+ call CloseSRAM
+ ret
+
+BattleTower_CheckSaveFileExistsAndIsYours: ; 17089a BattleTowerAction $09
+ ld a, [wSaveFileExists]
+ and a
+ jr z, .nope
+ farcall CompareLoadedAndSavedPlayerID
+ jr z, .yes
+ xor a
+ jr .nope
+
+.yes
+ ld a, $1
+
+.nope
+ ld [ScriptVar], a
+ ret
+; 1708b1
+
+
+Function1708b1: ; 1708b1 (5c:48b1) BattleTowerAction $0a
+ xor a
+ ld [MusicFade], a
+ call MaxVolume
+ ret
+
+CheckMobileEventIndex: ; 1708b9 (5c:48b9) BattleTowerAction $0b something to do with GS Ball
+ ld a, BANK(sMobileEventIndex)
+ call GetSRAMBank
+ ld a, [sMobileEventIndex]
+ ld [ScriptVar], a
+ call CloseSRAM
+ ret
+
+Function1708c8: ; 1708c8 (5c:48c8) BattleTowerAction $0c
+ call UpdateTime
+ ld a, $5
+ call GetSRAMBank
+ ld a, [CurDay]
+ ld [$aa8b], a
+ xor a
+ ld [$aa8c], a
+ ld a, [$aa5d]
+ cp $2
+ jr nc, .asm_1708ec
+ ld a, [CurDay]
+ ld [$aa48], a
+ ld a, $1
+ ld [$aa47], a
+.asm_1708ec
+ call CloseSRAM
+ ret
+
+Function1708f0: ; 1708f0 (5c:48f0) BattleTowerAction $0d
+ xor a
+ ld [ScriptVar], a
+ call UpdateTime
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$aa48]
+ ld c, a
+ ld a, [$aa47]
+ call CloseSRAM
+ and a
+ ret z
+ ld hl, CurDay
+ ld a, c
+ cp [hl]
+ jr nz, Function170923
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$aa5d]
+ call CloseSRAM
+ cp $5
+ ret c
+ ld a, $1
+ ld [ScriptVar], a
+ ret
+
+
+Function170923: ; 170923
+ ld a, $5
+ call GetSRAMBank
+ xor a
+ ld [$aa48], a
+ ld [$aa47], a
+ ld hl, $aa5d
+ ld bc, $0011
+ call ByteFill
+ call CloseSRAM
+ ret
+; 17093c
+
+
+BattleTowerAction_EggTicket: ; 17093c (5c:493c) BattleTowerAction $0e
+ xor a
+ ld [ScriptVar], a
+ ld a, EGG_TICKET
+ ld [CurItem], a
+ ld hl, NumItems
+ call CheckItem
+ ret nc
+ ld a, [PartyCount]
+ ld b, 0
+ ld c, a
+ ld hl, PartySpecies
+.loop
+ ld a, [hli]
+ cp EGG
+ jr nz, .not_egg
+ push hl
+ ld hl, PartyMonOT
+ ld de, NAME_LENGTH_JAPANESE
+ ld a, b
+ and a
+ jr z, .skip
+.loop2
+ add hl, de
+ dec a
+ jr nz, .loop2
+.skip
+ ld de, String_1709a4
+ ld a, NAME_LENGTH_JAPANESE
+.compare_loop
+ push af
+ ld a, [de]
+ inc de
+ cp [hl]
+ inc hl
+ jr nz, .different
+ pop af
+ dec a
+ jr nz, .compare_loop
+rept 4
+ dec hl
+endr
+ ld a, "@"
+ ld [hli], a
+ ld [hli], a
+ pop hl
+ ld a, EGG_TICKET
+ ld [CurItem], a
+ ld a, 1
+ ld [wItemQuantityChangeBuffer], a
+ ld a, -1
+ ld [CurItemQuantity], a
+ ld hl, NumItems
+ call TossItem
+ ld a, $1
+ ld [ScriptVar], a
+ ret
+
+.different
+ pop af
+ pop hl
+.not_egg
+ inc b
+ dec c
+ jr nz, .loop
+ ret
+; 1709a4 (5c:49a4)
+
+String_1709a4: ; 1709a4
+ db "なぞナゾ@@"
+
+Function1709aa: ; 1709aa (5c:49aa) BattleTowerAction $0f
+ ld a, [rSVBK]
+ push af
+ ld a, BANK(w3_d090)
+ ld [rSVBK], a
+ ld a, [w3_d090]
+ ld [ScriptVar], a
+ pop af
+ ld [rSVBK], a
+ ret
+
+Function1709bb: ; 1709bb (5c:49bb) BattleTowerAction $10
+ xor a
+ ld [ScriptVar], a
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$a800]
+ call CloseSRAM
+ cp 6
+ jr nc, .invalid
+ ld e, a
+ ld d, 0
+ ld hl, Jumptable_1709e7
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+.invalid
+ ld a, $5
+ call GetSRAMBank
+ xor a
+ ld [$a800], a
+ call CloseSRAM
+ ret
+; 1709e7 (5c:49e7)
+
+Jumptable_1709e7: ; 1709e7
+ dw .NoAction
+ dw .NoAction
+ dw .DoAction1
+ dw .DoAction1
+ dw .Action4
+ dw .Action5
+; 1709f3
+
+.DoAction1: ; 1709f3
+ ld a, $5
+ call GetSRAMBank
+ ld a, $1
+ ld [$a800], a
+ call CloseSRAM
+
+.NoAction: ; 170a00
+ ret
+; 170a01
+
+.Action4: ; 170a01
+ ld a, $5
+ call GetSRAMBank
+ ld hl, $b023
+ ld de, wMisc
+ ld bc, $0069
+ call CopyBytes
+ ld a, [$a825]
+ ld [wcd30], a
+ ld a, [$a826]
+ ld [wcd31], a
+ call CloseSRAM
+ farcall Function11b6b4
+ farcall Function17d0f3
+ ld a, $1
+ ld [ScriptVar], a
+ ret
+; 170a33
+
+.Action5: ; 170a33
+ ld a, $0
+ call GetSRAMBank
+ ld hl, wRTC
+ ld de, wMisc
+ ld bc, $0004
+ call CopyBytes
+ call CloseSRAM
+ ld a, $5
+ call GetSRAMBank
+ ld hl, $b08c
+ ld de, wMisc
+ ld c, $4
+.compare_loop
+ ld a, [de]
+ inc de
+ cp [hl]
+ jr nz, .different
+ inc hl
+ dec c
+ jr nz, .compare_loop
+ call CloseSRAM
+ ld a, [MapGroup]
+ ld b, a
+ ld a, [MapNumber]
+ ld c, a
+ call GetMapSceneID
+ ld a, d
+ or e
+ jr z, .no_scene
+ ld a, [de]
+ and a
+ ret nz
+
+.no_scene
+ ld a, $1
+ ld [ScriptVar], a
+ ret
+
+.different
+ call CloseSRAM
+ ld a, $5
+ call GetSRAMBank
+ xor a
+ ld [$a800], a
+ call CloseSRAM
+ ld [ScriptVar], a
+ ld a, [MapGroup]
+ ld b, a
+ ld a, [MapNumber]
+ ld c, a
+ call GetMapSceneID
+ ld a, d
+ or e
+ jr z, .no_scene_2
+ xor a
+ ld [de], a
+
+.no_scene_2
+ ret
+; 170a9c
+
+Function170a9c: ; 170a9c (5c:4a9c) BattleTowerAction $11
+ ld c, $0
+ jr asm_170aa2
+
+Function170aa0: ; 170aa0 (5c:4aa0) BattleTowerAction $12
+ ld c, $1
+asm_170aa2: ; 170aa2 (5c:4aa2)
+ ld a, $5
+ call GetSRAMBank
+ ld a, c
+ ld [$aa8d], a
+ call CloseSRAM
+ ret
+
+Function170aaf: ; 170aaf (5c:4aaf) BattleTowerAction $13
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$aa8d]
+ ld [ScriptVar], a
+ call CloseSRAM
+ ret
+
+Function170abe: ; 170abe (5c:4abe) BattleTowerAction $14
+ call BattleTower_CheckSaveFileExistsAndIsYours
+ ld a, [ScriptVar]
+ and a
+ ret z
+
+ ld a, BANK(sBattleTowerSaveFileFlags)
+ call GetSRAMBank
+ ld a, [sBattleTowerSaveFileFlags]
+ and $1
+ ld [ScriptVar], a
+ call CloseSRAM
+ ret
+
+Function170ad7: ; 170ad7 (5c:4ad7) BattleTowerAction $15
+ ld a, BANK(sBattleTowerSaveFileFlags)
+ call GetSRAMBank
+ ld a, [sBattleTowerSaveFileFlags]
+ or $1
+ ld [sBattleTowerSaveFileFlags], a
+ call CloseSRAM
+ ret
+
+BattleTowerAction_LevelCheck: ; 170ae8 (5c:4ae8) BattleTowerAction $18
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$b2fb]
+ call CloseSRAM
+ ld c, 10
+ call SimpleDivide
+ ld a, b
+ ld [wcd4f], a
+ xor a
+ ld [ScriptVar], a
+ farcall BattleTower_LevelCheck ; level check
+ ret nc
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$b2fb]
+ call CloseSRAM
+ ld [ScriptVar], a
+ ret
+
+BattleTowerAction_UbersCheck: ; 170b16 (5c:4b16) BattleTowerAction $19
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$b2fb]
+ call CloseSRAM
+ ld c, 10
+ call SimpleDivide
+ ld a, b
+ ld [wcd4f], a
+ xor a
+ ld [ScriptVar], a
+ farcall BattleTower_UbersCheck
+ ret nc
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$b2fb]
+ call CloseSRAM
+ ld [ScriptVar], a
+ ret
+
+Special_LoadOpponentTrainerAndPokemonWithOTSprite: ; 0x170b44
+ farcall Function_LoadOpponentTrainerAndPokemons
+ ld a, [rSVBK]
+ push af
+ ld a, $3
+ ld [rSVBK], a
+ ld hl, BT_OTTrainerClass
+ ld a, [hl]
+ dec a
+ ld c, a
+ ld b, $0
+ pop af
+ ld [rSVBK], a
+ ld hl, BTTrainerClassSprites
+ add hl, bc
+ ld a, [hl]
+ ld [wBTTempOTSprite], a
+
+; Load sprite of the opponent trainer
+; because s/he is chosen randomly and appears out of nowhere
+ ld a, [ScriptVar]
+ dec a
+ sla a
+ ld e, a
+ sla a
+ sla a
+ sla a
+ ld c, a
+ ld b, 0
+ ld d, 0
+ ld hl, MapObjects
+ add hl, bc
+ inc hl
+ ld a, [wBTTempOTSprite]
+ ld [hl], a
+ ld hl, UsedSprites
+ add hl, de
+ ld [hli], a
+ ld [hUsedSpriteIndex], a
+ ld a, [hl]
+ ld [hUsedSpriteTile], a
+ farcall GetUsedSprite
+ ret
+; 170b90
+
+INCLUDE "data/trainers/sprites.asm"
+
+DummySpecial_170bd2: ; 170bd2
+ ret
+; 170bd3
+
+Special_CheckForBattleTowerRules: ; 170bd3
+ farcall CheckForBattleTowerRules
+ jr c, .asm_170bde
+ xor a ; FALSE
+ jr .asm_170be0
+
+.asm_170bde
+ ld a, TRUE
+
+.asm_170be0
+ ld [ScriptVar], a
+ ret
+; 170be4
diff --git a/engine/events/battle_tower/get_trainer_class.asm b/engine/events/battle_tower/get_trainer_class.asm
new file mode 100644
index 000000000..37fe91c56
--- /dev/null
+++ b/engine/events/battle_tower/get_trainer_class.asm
@@ -0,0 +1,46 @@
+GetMobileOTTrainerClass: ; mobile function
+ ld h, b
+ ld l, c
+ call .GetMobileOTTrainerClass
+ ld c, a
+ ret
+
+.GetMobileOTTrainerClass: ; 4e930
+ ld a, [hli]
+ xor [hl]
+ ld c, a
+ jr z, .skip_male_trainers
+ srl c
+ srl c
+.male_trainer_loop
+ srl c
+ ld a, c
+ cp MaleTrainersEnd - MaleTrainers - 1
+ jr nc, .male_trainer_loop
+ inc c
+
+.skip_male_trainers
+ ld a, [de]
+ cp $1
+ ld hl, MaleTrainers
+ jr nz, .finished
+
+ ld hl, FemaleTrainers
+ ld a, c
+ and a
+ jr z, .finished
+
+.female_trainer_loop
+ srl c
+ ld a, c
+ cp FemaleTrainersEnd - FemaleTrainers - 1
+ jr nc, .female_trainer_loop
+ inc c
+
+.finished
+ ld b, $0
+ add hl, bc
+ ld a, [hl]
+ ret
+
+INCLUDE "data/trainers/gendered_trainers.asm"
diff --git a/engine/events/battle_tower.asm b/engine/events/battle_tower/load_trainer.asm
index a0de6ee84..e0e4a5ca1 100644
--- a/engine/events/battle_tower.asm
+++ b/engine/events/battle_tower/load_trainer.asm
@@ -26,12 +26,14 @@ Function_LoadOpponentTrainerAndPokemons: ; 1f8000
ld a, [hRandomAdd]
add b
ld b, a ; b contains the nr of the trainer
-if DEF(CRYSTAL11)
- and (1 << 7) - 1
- cp 70
+if DEF(_CRYSTAL11)
+ maskbits BATTLETOWER_NUM_UNIQUE_TRAINERS
+ cp BATTLETOWER_NUM_UNIQUE_TRAINERS
else
- and (1 << 5) - 1
- cp 21
+; Crystal 1.0 used the wrong constant here, so only the first 21
+; trainers in BattleTowerTrainers can be sampled.
+ maskbits BATTLETOWER_NUM_UNIQUE_PKMN
+ cp BATTLETOWER_NUM_UNIQUE_PKMN
endc
jr nc, .resample
ld b, a
@@ -39,7 +41,7 @@ endc
ld a, BANK(sBTTrainers)
call GetSRAMBank
- ld c, BATTLETOWER_NROFTRAINERS
+ ld c, BATTLETOWER_STREAK_LENGTH
ld hl, sBTTrainers
.next_trainer
ld a, [hli]
@@ -91,7 +93,7 @@ endc
Function_LoadRandomBattleTowerPkmn: ; 1f8081
- ld c, BATTLETOWER_NROFPKMNS
+ ld c, BATTLETOWER_PARTY_LENGTH
.loop
push bc
ld a, BANK(sBTPkmnPrevTrainer1)
@@ -100,7 +102,7 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081
.FindARandomBattleTowerPkmn:
; From Which LevelGroup are the Pkmn loaded
; a = 1..10
- ld a, [wBTChoiceOfLvlGroup] ; [$d800]
+ ld a, [wBTChoiceOfLvlGroup]
dec a
ld hl, BattleTowerMons
ld bc, BattleTowerMons2 - BattleTowerMons1
@@ -113,15 +115,15 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081
ld a, [hRandomAdd]
add b
ld b, a
- and $1f
- cp BATTLETOWER_NRMONSPERLEVELBRACKET
+ maskbits BATTLETOWER_NUM_UNIQUE_PKMN
+ cp BATTLETOWER_NUM_UNIQUE_PKMN
jr nc, .resample
; in register 'a' is the chosen Pkmn of the LevelGroup
; Check if Pkmn was already loaded before
; Check current and the 2 previous teams
; includes check if item is double at the current team
- ld bc, PARTYMON_STRUCT_LENGTH + PKMN_NAME_LENGTH
+ ld bc, PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH
call AddNTimes
ld a, [hli]
ld b, a
@@ -164,13 +166,13 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081
cp b
jr z, .FindARandomBattleTowerPkmn
- ld bc, PARTYMON_STRUCT_LENGTH + PKMN_NAME_LENGTH
+ ld bc, PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH
call CopyBytes
ld a, [wNamedObjectIndexBuffer]
push af
push de
- ld hl, - (PARTYMON_STRUCT_LENGTH + PKMN_NAME_LENGTH)
+ ld hl, - (PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH)
add hl, de
ld a, [hl]
ld [wNamedObjectIndexBuffer], a
@@ -181,7 +183,7 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081
ld h, d
ld l, e
pop de
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
pop de
@@ -207,4 +209,6 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081
ret
; 1f814e
-INCLUDE "data/battle_tower.asm"
+INCLUDE "data/battle_tower/classes.asm"
+
+INCLUDE "data/battle_tower/parties.asm"
diff --git a/engine/events/battle_tower_rules.asm b/engine/events/battle_tower/rules.asm
index de6022145..0e994c27e 100644
--- a/engine/events/battle_tower_rules.asm
+++ b/engine/events/battle_tower/rules.asm
@@ -213,7 +213,7 @@ BattleTower_ExecuteJumptable: ; 8b25b
BattleTower_CheckPartyLengthIs3: ; 8b2bb
ld a, [PartyCount]
- cp 3
+ cp BATTLETOWER_PARTY_LENGTH
ret
; 8b2c1
@@ -235,13 +235,13 @@ BattleTower_CheckPartyHasThreeMonsThatAreNotEggs: ; 8b2c1
cp b
ret z
ld a, b
- cp 3
+ cp BATTLETOWER_PARTY_LENGTH
ret
; 8b2da
Function_PartyCountEq3: ; 8b2da
ld a, [PartyCount]
- cp 3
+ cp BATTLETOWER_PARTY_LENGTH
ret z
scf
ret
diff --git a/engine/events/battle_tower/trainer_text.asm b/engine/events/battle_tower/trainer_text.asm
new file mode 100755
index 000000000..96c91caa9
--- /dev/null
+++ b/engine/events/battle_tower/trainer_text.asm
@@ -0,0 +1,718 @@
+BattleTowerText:: ; 11c000
+; Print text c for trainer [BT_OTTrainerClass]
+; 1: Intro text
+; 2: Player lost
+; 3: Player won
+ ld a, [rSVBK]
+ push af
+ ld a, BANK(BT_OTTrainerClass)
+ ld [rSVBK], a
+if DEF(_CRYSTAL11)
+ ld hl, BT_OTTrainerClass
+else
+; BUG ALERT
+; Instead of loading the Trainer Class, this routine
+; loads the 6th character in the Trainer's name, then
+; uses it to get the gender of the trainer.
+; As a consequence, the enemy trainer's dialog will
+; always be sampled from the female array.
+ ld hl, BT_OTName + NAME_LENGTH_JAPANESE - 1
+endc
+ ld a, [hl]
+ dec a
+ ld e, a
+ ld d, 0
+ ld hl, BTTrainerClassGenders
+ add hl, de
+ ld a, [hl]
+ and a
+ jr nz, .female
+ ; generate a random number between 0 and 24
+ ld a, [hRandomAdd]
+ and $1f
+ cp 25
+ jr c, .okay0
+ sub 25
+
+.okay0
+ ld hl, BTMaleTrainerTexts
+ jr .proceed
+
+.female
+ ; generate a random number between 0 and 14
+ ld a, [hRandomAdd]
+ and $f
+ cp 15
+ jr c, .okay1
+ sub 15
+
+.okay1
+ ld hl, BTFemaleTrainerTexts
+
+.proceed
+ ld b, 0
+ dec c
+ jr nz, .restore
+ ld [BT_TrainerTextIndex], a
+ jr .okay2
+
+.restore
+ ld a, [BT_TrainerTextIndex]
+
+.okay2
+ push af
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld c, a
+ ld a, [hl]
+ ld h, a
+ ld l, c
+ pop af
+ ld c, a
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld c, a
+ ld a, [hl]
+ ld l, c
+ ld h, a
+ bccoord 1, 14
+ pop af
+ ld [rSVBK], a
+ call PlaceHLTextAtBC
+ ret
+; 11c05d
+
+INCLUDE "mobile/fixed_words.asm"
+
+INCLUDE "data/trainers/genders.asm"
+
+
+BTMaleTrainerTexts: ; 11f332
+ dw .Greetings
+ dw .PlayerLost
+ dw .PlayerWon
+
+.Greetings: ; 11f338
+ dw BTGreetingM1
+ dw BTGreetingM2
+ dw BTGreetingM3
+ dw BTGreetingM4
+ dw BTGreetingM5
+ dw BTGreetingM6
+ dw BTGreetingM7
+ dw BTGreetingM8
+ dw BTGreetingM9
+ dw BTGreetingM10
+ dw BTGreetingM11
+ dw BTGreetingM12
+ dw BTGreetingM13
+ dw BTGreetingM14
+ dw BTGreetingM15
+ dw BTGreetingM16
+ dw BTGreetingM17
+ dw BTGreetingM18
+ dw BTGreetingM19
+ dw BTGreetingM20
+ dw BTGreetingM21
+ dw BTGreetingM22
+ dw BTGreetingM23
+ dw BTGreetingM24
+ dw BTGreetingM25
+
+.PlayerLost: ; 11f36a
+ dw BTLossM1
+ dw BTLossM2
+ dw BTLossM3
+ dw BTLossM4
+ dw BTLossM5
+ dw BTLossM6
+ dw BTLossM7
+ dw BTLossM8
+ dw BTLossM9
+ dw BTLossM10
+ dw BTLossM11
+ dw BTLossM12
+ dw BTLossM13
+ dw BTLossM14
+ dw BTLossM15
+ dw BTLossM16
+ dw BTLossM17
+ dw BTLossM18
+ dw BTLossM19
+ dw BTLossM20
+ dw BTLossM21
+ dw BTLossM22
+ dw BTLossM23
+ dw BTLossM24
+ dw BTLossM25
+
+.PlayerWon: ; 11f39c
+ dw BTWinM1
+ dw BTWinM2
+ dw BTWinM3
+ dw BTWinM4
+ dw BTWinM5
+ dw BTWinM6
+ dw BTWinM7
+ dw BTWinM8
+ dw BTWinM9
+ dw BTWinM10
+ dw BTWinM11
+ dw BTWinM12
+ dw BTWinM13
+ dw BTWinM14
+ dw BTWinM15
+ dw BTWinM16
+ dw BTWinM17
+ dw BTWinM18
+ dw BTWinM19
+ dw BTWinM20
+ dw BTWinM21
+ dw BTWinM22
+ dw BTWinM23
+ dw BTWinM24
+ dw BTWinM25
+
+
+BTFemaleTrainerTexts:
+ dw .Greetings
+ dw .PlayerLost
+ dw .PlayerWon
+
+.Greetings: ; 11f3d4
+ dw BTGreetingF1
+ dw BTGreetingF2
+ dw BTGreetingF3
+ dw BTGreetingF4
+ dw BTGreetingF5
+ dw BTGreetingF6
+ dw BTGreetingF7
+ dw BTGreetingF8
+ dw BTGreetingF9
+ dw BTGreetingF10
+ dw BTGreetingF11
+ dw BTGreetingF12
+ dw BTGreetingF13
+ dw BTGreetingF14
+ dw BTGreetingF15
+
+.PlayerLost: ; 11f3f2
+ dw BTLossF1
+ dw BTLossF2
+ dw BTLossF3
+ dw BTLossF4
+ dw BTLossF5
+ dw BTLossF6
+ dw BTLossF7
+ dw BTLossF8
+ dw BTLossF9
+ dw BTLossF10
+ dw BTLossF11
+ dw BTLossF12
+ dw BTLossF13
+ dw BTLossF14
+ dw BTLossF15
+
+.PlayerWon: ; 11f410
+ dw BTWinF1
+ dw BTWinF2
+ dw BTWinF3
+ dw BTWinF4
+ dw BTWinF5
+ dw BTWinF6
+ dw BTWinF7
+ dw BTWinF8
+ dw BTWinF9
+ dw BTWinF10
+ dw BTWinF11
+ dw BTWinF12
+ dw BTWinF13
+ dw BTWinF14
+ dw BTWinF15
+
+
+BTGreetingM1: ; 0x11f42e
+ text_jump BattleTowerText_0x1ec000
+ db "@"
+
+BTLossM1: ; 0x11f433
+ text_jump BattleTowerText_0x1ec03b
+ db "@"
+
+BTWinM1: ; 0x11f438
+ text_jump UnknownText_0x1ec060
+ db "@"
+
+BTGreetingM2: ; 0x11f43d
+ text_jump BattleTowerText_0x1ec080
+ db "@"
+
+BTLossM2: ; 0x11f442
+ text_jump UnknownText_0x1ec0a3
+ db "@"
+
+BTWinM2: ; 0x11f447
+ text_jump UnknownText_0x1ec0c4
+ db "@"
+
+BTGreetingM3: ; 0x11f44c
+ text_jump UnknownText_0x1ec0e1
+ db "@"
+
+BTLossM3: ; 0x11f451
+ text_jump UnknownText_0x1ec108
+ db "@"
+
+BTWinM3: ; 0x11f456
+ text_jump UnknownText_0x1ec12a
+ db "@"
+
+BTGreetingM4: ; 0x11f45b
+ text_jump UnknownText_0x1ec14d
+ db "@"
+
+BTLossM4: ; 0x11f460
+ text_jump UnknownText_0x1ec16f
+ db "@"
+
+BTWinM4: ; 0x11f465
+ text_jump UnknownText_0x1ec190
+ db "@"
+
+BTGreetingM5: ; 0x11f46a
+ text_jump UnknownText_0x1ec1ae
+ db "@"
+
+BTLossM5: ; 0x11f46f
+ text_jump UnknownText_0x1ec1d0
+ db "@"
+
+BTWinM5: ; 0x11f474
+ text_jump UnknownText_0x1ec1f4
+ db "@"
+
+BTGreetingM6: ; 0x11f479
+ text_jump UnknownText_0x1ec216
+ db "@"
+
+BTLossM6: ; 0x11f47e
+ text_jump UnknownText_0x1ec238
+ db "@"
+
+BTWinM6: ; 0x11f483
+ text_jump UnknownText_0x1ec259
+ db "@"
+
+BTGreetingM7: ; 0x11f488
+ text_jump UnknownText_0x1ec27b
+ db "@"
+
+BTLossM7: ; 0x11f48d
+ text_jump UnknownText_0x1ec2a0
+ db "@"
+
+BTWinM7: ; 0x11f492
+ text_jump UnknownText_0x1ec2c0
+ db "@"
+
+BTGreetingM8: ; 0x11f497
+ text_jump UnknownText_0x1ec2d9
+ db "@"
+
+BTLossM8: ; 0x11f49c
+ text_jump UnknownText_0x1ec2fe
+ db "@"
+
+BTWinM8: ; 0x11f4a1
+ text_jump UnknownText_0x1ec320
+ db "@"
+
+BTGreetingM9: ; 0x11f4a6
+ text_jump UnknownText_0x1ec33f
+ db "@"
+
+BTLossM9: ; 0x11f4ab
+ text_jump UnknownText_0x1ec36c
+ db "@"
+
+BTWinM9: ; 0x11f4b0
+ text_jump UnknownText_0x1ec389
+ db "@"
+
+BTGreetingM10: ; 0x11f4b5
+ text_jump UnknownText_0x1ec3ad
+ db "@"
+
+BTLossM10: ; 0x11f4ba
+ text_jump UnknownText_0x1ec3c5
+ db "@"
+
+BTWinM10: ; 0x11f4bf
+ text_jump UnknownText_0x1ec3e5
+ db "@"
+
+BTGreetingM11: ; 0x11f4c4
+ text_jump UnknownText_0x1ec402
+ db "@"
+
+BTLossM11: ; 0x11f4c9
+ text_jump UnknownText_0x1ec411
+ db "@"
+
+BTWinM11: ; 0x11f4ce
+ text_jump UnknownText_0x1ec41f
+ db "@"
+
+BTGreetingM12: ; 0x11f4d3
+ text_jump UnknownText_0x1ec42e
+ db "@"
+
+BTLossM12: ; 0x11f4d8
+ text_jump UnknownText_0x1ec461
+ db "@"
+
+BTWinM12: ; 0x11f4dd
+ text_jump UnknownText_0x1ec4a0
+ db "@"
+
+BTGreetingM13: ; 0x11f4e2
+ text_jump UnknownText_0x1ec4d6
+ db "@"
+
+BTLossM13: ; 0x11f4e7
+ text_jump UnknownText_0x1ec4f5
+ db "@"
+
+BTWinM13: ; 0x11f4ec
+ text_jump UnknownText_0x1ec512
+ db "@"
+
+BTGreetingM14: ; 0x11f4f1
+ text_jump UnknownText_0x1ec532
+ db "@"
+
+BTLossM14: ; 0x11f4f6
+ text_jump UnknownText_0x1ec54b
+ db "@"
+
+BTWinM14: ; 0x11f4fb
+ text_jump UnknownText_0x1ec565
+ db "@"
+
+BTGreetingM15: ; 0x11f500
+ text_jump UnknownText_0x1ec580
+ db "@"
+
+BTLossM15: ; 0x11f505
+ text_jump UnknownText_0x1ec59d
+ db "@"
+
+BTWinM15: ; 0x11f50a
+ text_jump UnknownText_0x1ec5b5
+ db "@"
+
+BTGreetingM16: ; 0x11f50f
+ text_jump UnknownText_0x1ec5d3
+ db "@"
+
+BTLossM16: ; 0x11f514
+ text_jump UnknownText_0x1ec5ee
+ db "@"
+
+BTWinM16: ; 0x11f519
+ text_jump UnknownText_0x1ec60d
+ db "@"
+
+BTGreetingM17: ; 0x11f51e
+ text_jump UnknownText_0x1ec631
+ db "@"
+
+BTLossM17: ; 0x11f523
+ text_jump UnknownText_0x1ec651
+ db "@"
+
+BTWinM17: ; 0x11f528
+ text_jump UnknownText_0x1ec68f
+ db "@"
+
+BTGreetingM18: ; 0x11f52d
+ text_jump UnknownText_0x1ec6b1
+ db "@"
+
+BTLossM18: ; 0x11f532
+ text_jump UnknownText_0x1ec6d0
+ db "@"
+
+BTWinM18: ; 0x11f537
+ text_jump UnknownText_0x1ec708
+ db "@"
+
+BTGreetingM19: ; 0x11f53c
+ text_jump UnknownText_0x1ec720
+ db "@"
+
+BTLossM19: ; 0x11f541
+ text_jump UnknownText_0x1ec73e
+ db "@"
+
+BTWinM19: ; 0x11f546
+ text_jump UnknownText_0x1ec75b
+ db "@"
+
+BTGreetingM20: ; 0x11f54b
+ text_jump UnknownText_0x1ec77f
+ db "@"
+
+BTLossM20: ; 0x11f550
+ text_jump UnknownText_0x1ec798
+ db "@"
+
+BTWinM20: ; 0x11f555
+ text_jump UnknownText_0x1ec7bb
+ db "@"
+
+BTGreetingM21: ; 0x11f55a
+ text_jump UnknownText_0x1ec7d8
+ db "@"
+
+BTLossM21: ; 0x11f55f
+ text_jump UnknownText_0x1ec818
+ db "@"
+
+BTWinM21: ; 0x11f564
+ text_jump UnknownText_0x1ec837
+ db "@"
+
+BTGreetingM22: ; 0x11f569
+ text_jump UnknownText_0x1ec858
+ db "@"
+
+BTLossM22: ; 0x11f56e
+ text_jump UnknownText_0x1ec876
+ db "@"
+
+BTWinM22: ; 0x11f573
+ text_jump UnknownText_0x1ec898
+ db "@"
+
+BTGreetingM23: ; 0x11f578
+ text_jump UnknownText_0x1ec8b1
+ db "@"
+
+BTLossM23: ; 0x11f57d
+ text_jump UnknownText_0x1ec8d5
+ db "@"
+
+BTWinM23: ; 0x11f582
+ text_jump UnknownText_0x1ec8f0
+ db "@"
+
+BTGreetingM24: ; 0x11f587
+ text_jump UnknownText_0x1ec911
+ db "@"
+
+BTLossM24: ; 0x11f58c
+ text_jump UnknownText_0x1ec928
+ db "@"
+
+BTWinM24: ; 0x11f591
+ text_jump UnknownText_0x1ec949
+ db "@"
+
+BTGreetingM25: ; 0x11f596
+ text_jump UnknownText_0x1ec969
+ db "@"
+
+BTLossM25: ; 0x11f59b
+ text_jump UnknownText_0x1ec986
+ db "@"
+
+BTWinM25: ; 0x11f5a0
+ text_jump UnknownText_0x1ec99b
+ db "@"
+
+
+
+
+BTGreetingF1: ; 0x11f5a5
+ text_jump UnknownText_0x1ec9bd
+ db "@"
+
+BTLossF1: ; 0x11f5aa
+ text_jump UnknownText_0x1ec9d9
+ db "@"
+
+BTWinF1: ; 0x11f5af
+ text_jump UnknownText_0x1ec9f7
+ db "@"
+
+BTGreetingF2: ; 0x11f5b4
+ text_jump UnknownText_0x1eca0a
+ db "@"
+
+BTLossF2: ; 0x11f5b9
+ text_jump UnknownText_0x1eca2a
+ db "@"
+
+BTWinF2: ; 0x11f5be
+ text_jump UnknownText_0x1eca47
+ db "@"
+
+BTGreetingF3: ; 0x11f5c3
+ text_jump UnknownText_0x1eca64
+ db "@"
+
+BTLossF3: ; 0x11f5c8
+ text_jump UnknownText_0x1eca82
+ db "@"
+
+BTWinF3: ; 0x11f5cd
+ text_jump UnknownText_0x1eca9d
+ db "@"
+
+BTGreetingF4: ; 0x11f5d2
+ text_jump UnknownText_0x1ecabf
+ db "@"
+
+BTLossF4: ; 0x11f5d7
+ text_jump UnknownText_0x1ecade
+ db "@"
+
+BTWinF4: ; 0x11f5dc
+ text_jump UnknownText_0x1ecafa
+ db "@"
+
+BTGreetingF5: ; 0x11f5e1
+ text_jump UnknownText_0x1ecb19
+ db "@"
+
+BTLossF5: ; 0x11f5e6
+ text_jump UnknownText_0x1ecb37
+ db "@"
+
+BTWinF5: ; 0x11f5eb
+ text_jump UnknownText_0x1ecb55
+ db "@"
+
+BTGreetingF6: ; 0x11f5f0
+ text_jump UnknownText_0x1ecb70
+ db "@"
+
+BTLossF6: ; 0x11f5f5
+ text_jump UnknownText_0x1ecb92
+ db "@"
+
+BTWinF6: ; 0x11f5fa
+ text_jump UnknownText_0x1ecbb6
+ db "@"
+
+BTGreetingF7: ; 0x11f5ff
+ text_jump UnknownText_0x1ecbd9
+ db "@"
+
+BTLossF7: ; 0x11f604
+ text_jump UnknownText_0x1ecbf3
+ db "@"
+
+BTWinF7: ; 0x11f609
+ text_jump UnknownText_0x1ecc15
+ db "@"
+
+BTGreetingF8: ; 0x11f60e
+ text_jump UnknownText_0x1ecc39
+ db "@"
+
+BTLossF8: ; 0x11f613
+ text_jump UnknownText_0x1ecc55
+ db "@"
+
+BTWinF8: ; 0x11f618
+ text_jump UnknownText_0x1ecc75
+ db "@"
+
+BTGreetingF9: ; 0x11f61d
+ text_jump UnknownText_0x1ecc92
+ db "@"
+
+BTLossF9: ; 0x11f622
+ text_jump UnknownText_0x1ecca7
+ db "@"
+
+BTWinF9: ; 0x11f627
+ text_jump UnknownText_0x1eccc1
+ db "@"
+
+BTGreetingF10: ; 0x11f62c
+ text_jump UnknownText_0x1eccd7
+ db "@"
+
+BTLossF10: ; 0x11f631
+ text_jump UnknownText_0x1eccef
+ db "@"
+
+BTWinF10: ; 0x11f636
+ text_jump UnknownText_0x1ecd0e
+ db "@"
+
+BTGreetingF11: ; 0x11f63b
+ text_jump UnknownText_0x1ecd2b
+ db "@"
+
+BTLossF11: ; 0x11f640
+ text_jump UnknownText_0x1ecd4d
+ db "@"
+
+BTWinF11: ; 0x11f645
+ text_jump UnknownText_0x1ecd6b
+ db "@"
+
+BTGreetingF12: ; 0x11f64a
+ text_jump UnknownText_0x1ecd8d
+ db "@"
+
+BTLossF12: ; 0x11f64f
+ text_jump UnknownText_0x1ecdaf
+ db "@"
+
+BTWinF12: ; 0x11f654
+ text_jump UnknownText_0x1ecdcf
+ db "@"
+
+BTGreetingF13: ; 0x11f659
+ text_jump UnknownText_0x1ecded
+ db "@"
+
+BTLossF13: ; 0x11f65e
+ text_jump UnknownText_0x1ece0d
+ db "@"
+
+BTWinF13: ; 0x11f663
+ text_jump UnknownText_0x1ece2a
+ db "@"
+
+BTGreetingF14: ; 0x11f668
+ text_jump UnknownText_0x1ece4b
+ db "@"
+
+BTLossF14: ; 0x11f66d
+ text_jump UnknownText_0x1ece70
+ db "@"
+
+BTWinF14: ; 0x11f672
+ text_jump UnknownText_0x1ece8a
+ db "@"
+
+BTGreetingF15: ; 0x11f677
+ text_jump UnknownText_0x1ecea8
+ db "@"
+
+BTLossF15: ; 0x11f67c
+ text_jump UnknownText_0x1ecec9
+ db "@"
+
+BTWinF15: ; 0x11f681
+ text_jump UnknownText_0x1ecee8
+ db "@"
diff --git a/engine/events/buena.asm b/engine/events/buena.asm
index 1227593eb..d5a80ef2e 100644
--- a/engine/events/buena.asm
+++ b/engine/events/buena.asm
@@ -1,4 +1,4 @@
-SpecialBuenasPassword: ; 8af6b
+Special_BuenasPassword: ; 8af6b
xor a
ld [wWhichIndexSet], a
ld hl, .MenuDataHeader
@@ -17,7 +17,7 @@ SpecialBuenasPassword: ; 8af6b
ld a, [MenuSelection]
ld c, a
ld a, [wBuenasPassword]
- and $3
+ maskbits NUM_PASSWORDS_PER_CATEGORY
cp c
jr nz, .wrong
ld b, $1
@@ -29,9 +29,8 @@ SpecialBuenasPassword: ; 8af6b
; 8afa9
.MenuDataHeader: ; 0x8afa9
- db $40 ; flags
- db 00, 00 ; start coords
- db 07, 10 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, 10, 7
dw .MenuData2
db 1 ; default option
; 0x8afb1
@@ -39,15 +38,19 @@ SpecialBuenasPassword: ; 8af6b
db 0
.MenuData2: ; 0x8afb2
- db $81 ; flags
+ db STATICMENU_CURSOR | STATICMENU_DISABLE_B ; flags
db 0 ; items
dw .PasswordIndices
dw .PlacePasswordChoices
; 0x8afb4
.PasswordIndices: ; 8afb8
- db 3
- db 0, 1, 2
+ db NUM_PASSWORDS_PER_CATEGORY
+x = 0
+rept NUM_PASSWORDS_PER_CATEGORY
+ db x
+x = x + 1
+endr
db -1
.PlacePasswordChoices: ; 8afbd
@@ -64,7 +67,7 @@ SpecialBuenasPassword: ; 8af6b
ret
; 8afd4
-SpecialBuenaPrize: ; 8afd4
+Special_BuenaPrize: ; 8afd4
xor a
ld [wMenuScrollPosition], a
ld a, $1
@@ -225,9 +228,8 @@ PrintBlueCardBalance: ; 8b097
; 8b0d1
BlueCardBalanceMenuDataHeader: ; 0x8b0d1
- db $40 ; flags
- db 11, 00 ; start coords
- db 13, 11 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 11, 11, 13
; 8b0d6
Buena_PlacePrizeMenuBox: ; 8b0d6
@@ -237,9 +239,8 @@ Buena_PlacePrizeMenuBox: ; 8b0d6
; 8b0dd
.menudataheader ; 0x8b0dd
- db $40 ; flags
- db 00, 00 ; start coords
- db 11, 17 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, 17, TEXTBOX_Y - 1
; 8b0e2
Buena_PrizeMenu: ; 8b0e2
@@ -270,9 +271,8 @@ Buena_PrizeMenu: ; 8b0e2
; 8b113
.MenuDataHeader: ; 0x8b113
- db $40 ; flags
- db 01, 01 ; start coords
- db 09, 16 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 1, 1, 16, 9
dw .MenuData2
db 1 ; default option
; 0x8b11b
@@ -280,7 +280,7 @@ Buena_PrizeMenu: ; 8b0e2
db 0
.MenuData2: ; 0x8b11c
- db $10 ; flags
+ db SCROLLINGMENU_DISPLAY_ARROWS ; flags
db 4, 13 ; rows, columns
db 1 ; spacing
dba .indices
diff --git a/engine/events/buena_menu.asm b/engine/events/buena_menu.asm
index b453da783..cf6fecf72 100644
--- a/engine/events/buena_menu.asm
+++ b/engine/events/buena_menu.asm
@@ -1,4 +1,4 @@
-AskRememberPassword: ; 4ae12
+Special_AskRememberPassword: ; 4ae12
call .DoMenu
ld a, $0
jr c, .okay
diff --git a/engine/events/bug_contest/contest_2.asm b/engine/events/bug_contest/contest_2.asm
index 493c69d0c..7ade44815 100755
--- a/engine/events/bug_contest/contest_2.asm
+++ b/engine/events/bug_contest/contest_2.asm
@@ -2,7 +2,7 @@ Special_SelectRandomBugContestContestants: ; 139a8
; Select five random people to participate in the current contest.
; First we have to make sure that any old data is cleared away.
- ld c, 10 ; Number of people to choose from.
+ ld c, NUM_BUG_CONTESTANTS
ld hl, BugCatchingContestantEventFlagTable
.loop1
push bc
@@ -26,9 +26,9 @@ Special_SelectRandomBugContestContestants: ; 139a8
.next
; Choose a flag at uniform random to be set.
call Random
- cp 250
+ cp $ff / NUM_BUG_CONTESTANTS * NUM_BUG_CONTESTANTS
jr nc, .next
- ld c, 25
+ ld c, $ff / NUM_BUG_CONTESTANTS
call SimpleDivide
ld e, b
ld d, 0
@@ -59,7 +59,7 @@ Special_SelectRandomBugContestContestants: ; 139a8
Special_CheckBugContestContestantFlag: ; 139ed
; Checks the flag of the Bug Catching Contestant whose index is loaded in a.
-; Bug: If a >= 10 when this is called, it will read beyond the table.
+; Bug: If a >= NUM_BUG_CONTESTANTS when this is called, it will read beyond the table.
ld hl, BugCatchingContestantEventFlagTable
ld e, a
@@ -74,20 +74,9 @@ Special_CheckBugContestContestantFlag: ; 139ed
ret
; 139fe
-BugCatchingContestantEventFlagTable: ; 139fe
- dw EVENT_BUG_CATCHING_CONTESTANT_1A
- dw EVENT_BUG_CATCHING_CONTESTANT_2A
- dw EVENT_BUG_CATCHING_CONTESTANT_3A
- dw EVENT_BUG_CATCHING_CONTESTANT_4A
- dw EVENT_BUG_CATCHING_CONTESTANT_5A
- dw EVENT_BUG_CATCHING_CONTESTANT_6A
- dw EVENT_BUG_CATCHING_CONTESTANT_7A
- dw EVENT_BUG_CATCHING_CONTESTANT_8A
- dw EVENT_BUG_CATCHING_CONTESTANT_9A
- dw EVENT_BUG_CATCHING_CONTESTANT_10A
-; 13a12
+INCLUDE "data/bug_contest_flags.asm"
-ContestDropOffMons: ; 13a12
+Special_ContestDropOffMons: ; 13a12
ld hl, PartyMon1HP
ld a, [hli]
or [hl]
@@ -101,7 +90,7 @@ ContestDropOffMons: ; 13a12
ld a, [hl]
ld [wBugContestSecondPartySpecies], a
; ... and replacing it with the terminator byte
- ld [hl], $ff
+ ld [hl], -1
xor a
ld [ScriptVar], a
ret
@@ -112,13 +101,13 @@ ContestDropOffMons: ; 13a12
ret
; 13a31
-ContestReturnMons: ; 13a31
+Special_ContestReturnMons: ; 13a31
; Restore the species of the second mon.
ld hl, PartySpecies + 1
ld a, [wBugContestSecondPartySpecies]
ld [hl], a
; Restore the party count, which must be recomputed.
- ld b, $1
+ ld b, 1
.loop
ld a, [hli]
cp -1
diff --git a/engine/events/bug_contest/display_stats.asm b/engine/events/bug_contest/display_stats.asm
index d6ad3997e..92b89a38f 100644
--- a/engine/events/bug_contest/display_stats.asm
+++ b/engine/events/bug_contest/display_stats.asm
@@ -82,9 +82,9 @@ DisplayCaughtContestMonStats: ; cc000
.Health:
db "HEALTH@"
.Stock:
- db " STOCK ", $4a, " @"
+ db " STOCK <PKMN> @"
.This:
- db " THIS ", $4a, " @"
+ db " THIS <PKMN> @"
SwitchMonText: ; cc0c2
; Switch #MON?
@@ -101,7 +101,7 @@ DisplayAlreadyCaughtText: ; cc0c7
text_jump UnknownText_0x1c10dd
db "@"
-Predef2F:
-Predef38:
-Predef39: ; cc0d5
+DummyPredef2F:
+DummyPredef38:
+DummyPredef39: ; cc0d5
ret
diff --git a/engine/events/bug_contest/judging.asm b/engine/events/bug_contest/judging.asm
index 901ae88fa..a8cb80efe 100755
--- a/engine/events/bug_contest/judging.asm
+++ b/engine/events/bug_contest/judging.asm
@@ -1,6 +1,6 @@
_BugContestJudging: ; 1369d
call ContestScore
- farcall TrainerRankings_BugContestScore
+ farcall StubbedTrainerRankings_BugContestScore
call BugContest_JudgeContestants
ld a, [wBugContestThirdPlaceWinnerID]
call LoadContestantName
@@ -77,9 +77,8 @@ BugContest_ThirdPlaceScoreText: ; 0x1372b
; 0x13730
LoadContestantName: ; 13730
-
-; If a = 0, get your name.
- dec a
+; If a = 1, get your name.
+ dec a ; BUG_CONTEST_PLAYER
jr z, .player
; Find the pointer for the trainer class of the Bug Catching Contestant whose ID is in a.
ld c, a
@@ -141,11 +140,11 @@ INCLUDE "data/bug_contest_winners.asm"
BugContest_GetPlayersResult: ; 13807
ld hl, wBugContestThirdPlaceWinnerID
- ld de, -4
- ld b, 3
+ ld de, - BUG_CONTESTANT_SIZE
+ ld b, 3 ; 3rd, 2nd, or 1st
.loop
ld a, [hl]
- cp 1 ; Player
+ cp BUG_CONTEST_PLAYER
jr z, .done
add hl, de
dec b
@@ -159,7 +158,7 @@ BugContest_JudgeContestants: ; 13819
call ClearContestResults
call ComputeAIContestantScores
ld hl, wBugContestTempWinnerID
- ld a, 1 ; Player
+ ld a, BUG_CONTEST_PLAYER
ld [hli], a
ld a, [wContestMon]
ld [hli], a
@@ -190,11 +189,11 @@ DetermineContestWinners: ; 1383e
jr c, .not_first_place
ld hl, wBugContestSecondPlaceWinnerID
ld de, wBugContestThirdPlaceWinnerID
- ld bc, 4
+ ld bc, BUG_CONTESTANT_SIZE
call CopyBytes
ld hl, wBugContestFirstPlaceWinnerID
ld de, wBugContestSecondPlaceWinnerID
- ld bc, 4
+ ld bc, BUG_CONTESTANT_SIZE
call CopyBytes
ld hl, wBugContestFirstPlaceWinnerID
call CopyTempContestant
@@ -208,7 +207,7 @@ DetermineContestWinners: ; 1383e
jr c, .not_second_place
ld hl, wBugContestSecondPlaceWinnerID
ld de, wBugContestThirdPlaceWinnerID
- ld bc, 4
+ ld bc, BUG_CONTESTANT_SIZE
call CopyBytes
ld hl, wBugContestSecondPlaceWinnerID
call CopyTempContestant
@@ -230,7 +229,7 @@ DetermineContestWinners: ; 1383e
CopyTempContestant: ; 138a0
; Could've just called CopyBytes.
ld de, wBugContestTempWinnerID
-rept 3
+rept BUG_CONTESTANT_SIZE +- 1
ld a, [de]
inc de
ld [hli], a
@@ -264,6 +263,7 @@ ComputeAIContestantScores: ; 138b0
inc hl
inc hl
.loop2
+ ; 0, 1, or 2 for 1st, 2nd, or 3rd
call Random
and 3
cp 3
@@ -278,8 +278,9 @@ ComputeAIContestantScores: ; 138b0
ld a, [hli]
ld h, [hl]
ld l, a
+ ; randomly perturb score
call Random
- and 7
+ and %111
ld c, a
ld b, 0
add hl, bc
@@ -294,7 +295,7 @@ ComputeAIContestantScores: ; 138b0
.done
inc e
ld a, e
- cp 10
+ cp NUM_BUG_CONTESTANTS
jr nz, .loop
ret
; 13900
@@ -337,26 +338,26 @@ ContestScore: ; 13900
; DVs
ld a, [wContestMonDVs + 0]
ld b, a
- and 2
+ and %0010
add a
add a
ld c, a
swap b
ld a, b
- and 2
+ and %0010
add a
add c
ld d, a
ld a, [wContestMonDVs + 1]
ld b, a
- and 2
+ and %0010
ld c, a
swap b
ld a, b
- and 2
+ and %0010
srl a
add c
add c
diff --git a/engine/events/celebi.asm b/engine/events/celebi.asm
index 1139ad3d5..81565c27e 100755
--- a/engine/events/celebi.asm
+++ b/engine/events/celebi.asm
@@ -1,3 +1,5 @@
+SPECIALCELEBIEVENT_CELEBI EQU $84
+
Special_CelebiShrineEvent: ; 4989a
call DelayFrame
ld a, [VramState]
@@ -10,7 +12,7 @@ Special_CelebiShrineEvent: ; 4989a
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
- ld [hl], $84
+ ld [hl], SPECIALCELEBIEVENT_CELEBI
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], SPRITE_ANIM_SEQ_CELEBI
@@ -19,7 +21,7 @@ Special_CelebiShrineEvent: ; 4989a
ld a, $80
ld [hl], a
ld a, 160 ; frame count
- ld [wcf64], a
+ ld [wFrameCounter], a
ld d, $0
.loop
ld a, [wJumptableIndex]
@@ -43,26 +45,26 @@ Special_CelebiShrineEvent: ; 4989a
.done
pop af
ld [VramState], a
- call .RefreshPlayerSprite_ClearAllOthers
+ call .RestorePlayerSprite_DespawnLeaves
call CelebiEvent_SetBattleType
ret
; 498f9
-.RefreshPlayerSprite_ClearAllOthers: ; 498f9
- ld hl, Sprites + 2
+.RestorePlayerSprite_DespawnLeaves: ; 498f9
+ ld hl, Sprite01TileID
xor a
- ld c, $4
+ ld c, 4
.OAMloop:
- ld [hli], a
- inc hl
- inc hl
+ ld [hli], a ; tile id
+rept SPRITEOAMSTRUCT_LENGTH +- 1
inc hl
+endr
inc a
dec c
jr nz, .OAMloop
- ld hl, Sprites + 4 * 4
- ld bc, 36 * 4
+ ld hl, Sprite05
+ ld bc, SpritesEnd - Sprite05
xor a
call ByteFill
ret
@@ -76,8 +78,8 @@ LoadCelebiGFX: ; 49912
lb bc, BANK(SpecialCelebiLeafGFX), 4
call Request2bpp
ld de, SpecialCelebiGFX
- ld hl, vTiles0 tile $84
- lb bc, BANK(SpecialCelebiGFX), $10
+ ld hl, vTiles0 tile SPECIALCELEBIEVENT_CELEBI
+ lb bc, BANK(SpecialCelebiGFX), 4 * 4
call Request2bpp
xor a
ld [wJumptableIndex], a
@@ -86,7 +88,7 @@ LoadCelebiGFX: ; 49912
; 49935
CelebiEvent_CountDown: ; 49935
- ld hl, wcf64
+ ld hl, wFrameCounter
ld a, [hl]
and a
jr z, .done
@@ -238,27 +240,27 @@ UpdateCelebiPosition: ; 49aa2 (12:5aa2)
CelebiEvent_Cosine: ; 49b3b (12:5b3b)
- add $10
- and $3f
- cp $20
+; a = d * cos(a * pi/32)
+ add %010000
+ and %111111
+ cp %100000
jr nc, .negative
- call .SineFunction
+ call .ApplySineWave
ld a, h
ret
.negative
- and $1f
- call .SineFunction
+ and %011111
+ call .ApplySineWave
ld a, h
xor $ff
inc a
ret
-
-.SineFunction: ; 49b52 (12:5b52)
+.ApplySineWave: ; 49b52 (12:5b52)
ld e, a
ld a, d
- ld d, $0
+ ld d, 0
ld hl, .sinewave
add hl, de
add hl, de
@@ -276,7 +278,6 @@ CelebiEvent_Cosine: ; 49b3b (12:5b3b)
and a
jr nz, .multiply
ret
-
; 49b6e (12:5b6e)
.sinewave ; 49b6e
@@ -307,22 +308,22 @@ GetCelebiSpriteTile: ; 49bae
.Frame1:
- ld a, $84
+ ld a, SPECIALCELEBIEVENT_CELEBI
jr .load_tile
.Frame2:
- ld a, $88
+ ld a, SPECIALCELEBIEVENT_CELEBI + 4
jr .load_tile
.Frame3:
- ld a, $8c
+ ld a, SPECIALCELEBIEVENT_CELEBI + 8
jr .load_tile
.Frame4:
- ld a, $90
+ ld a, SPECIALCELEBIEVENT_CELEBI + 12
.load_tile
ld hl, SPRITEANIMSTRUCT_TILE_ID
@@ -361,7 +362,7 @@ CelebiEvent_SetBattleType: ; 49bf3
; 49bf9
-CheckCaughtCelebi: ; 49bf9
+Special_CheckCaughtCelebi: ; 49bf9
ld a, [wBattleResult]
bit 6, a
jr z, .false
diff --git a/engine/events/checkforhiddenitems.asm b/engine/events/checkforhiddenitems.asm
new file mode 100644
index 000000000..3cad2b821
--- /dev/null
+++ b/engine/events/checkforhiddenitems.asm
@@ -0,0 +1,85 @@
+CheckForHiddenItems: ; b8172
+; Checks to see if there are hidden items on the screen that have not yet been found. If it finds one, returns carry.
+ call GetMapScriptsBank
+ ld [Buffer1], a
+; Get the coordinate of the bottom right corner of the screen, and load it in Buffer3/Buffer4.
+ ld a, [XCoord]
+ add SCREEN_WIDTH / 4
+ ld [Buffer4], a
+ ld a, [YCoord]
+ add SCREEN_HEIGHT / 4
+ ld [Buffer3], a
+; Get the pointer for the first bg_event in the map...
+ ld hl, wCurrMapBGEventsPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+; ... before even checking to see if there are any BG events on this map.
+ ld a, [wCurrMapBGEventCount]
+ and a
+ jr z, .nobgeventitems
+; For i = 1:wCurrMapBGEventCount...
+.loop
+; Store the counter in Buffer2, and store the bg_event pointer in the stack.
+ ld [Buffer2], a
+ push hl
+; Get the Y coordinate of the BG event.
+ call .GetFarByte
+ ld e, a
+; Is the Y coordinate of the BG event on the screen? If not, go to the next BG event.
+ ld a, [Buffer3]
+ sub e
+ jr c, .next
+ cp SCREEN_HEIGHT / 2
+ jr nc, .next
+; Is the X coordinate of the BG event on the screen? If not, go to the next BG event.
+ call .GetFarByte
+ ld d, a
+ ld a, [Buffer4]
+ sub d
+ jr c, .next
+ cp SCREEN_WIDTH / 2
+ jr nc, .next
+; Is this BG event a hidden item? If not, go to the next BG event.
+ call .GetFarByte
+ cp BGEVENT_ITEM
+ jr nz, .next
+; Has this item already been found? If not, set off the Itemfinder.
+ ld a, [Buffer1]
+ call GetFarHalfword
+ ld a, [Buffer1]
+ call GetFarHalfword
+ ld d, h
+ ld e, l
+ ld b, CHECK_FLAG
+ call EventFlagAction
+ ld a, c
+ and a
+ jr z, .itemnearby
+
+.next
+; Restore the bg_event pointer and increment it by the length of a bg_event.
+ pop hl
+ ld bc, 5
+ add hl, bc
+; Restore the BG event counter and decrement it. If it hits zero, there are no hidden items in range.
+ ld a, [Buffer2]
+ dec a
+ jr nz, .loop
+
+.nobgeventitems
+ xor a
+ ret
+
+.itemnearby
+ pop hl
+ scf
+ ret
+; b81e2
+
+.GetFarByte: ; b81e2
+ ld a, [Buffer1]
+ call GetFarByte
+ inc hl
+ ret
+; b81ea
diff --git a/engine/events/daycare.asm b/engine/events/daycare.asm
index 6395a40fb..f65464a8d 100755
--- a/engine/events/daycare.asm
+++ b/engine/events/daycare.asm
@@ -1,3 +1,4 @@
+; PrintDayCareText.TextTable indexes
const_def
const DAYCARETEXT_MAN_INTRO
const DAYCARETEXT_MAN_EGG
@@ -13,12 +14,12 @@
const DAYCARETEXT_GENIUSES
const DAYCARETEXT_ASK_WITHDRAW
const DAYCARETEXT_WITHDRAW
+ const DAYCARETEXT_GOT_BACK
const DAYCARETEXT_TOO_SOON
const DAYCARETEXT_PARTY_FULL
const DAYCARETEXT_NOT_ENOUGH_MONEY
const DAYCARETEXT_OH_FINE
const DAYCARETEXT_COME_AGAIN
- const DAYCARETEXT_13
Special_DayCareMan: ; 166d6
ld hl, wDayCareMan
@@ -44,7 +45,7 @@ Special_DayCareMan: ; 166d6
call DayCare_AskWithdrawBreedMon
jr c, .print_text
farcall RetrievePokemonFromDayCareMan
- call DayCare_TakeMoney_PlayCry
+ call DayCare_GetBackMonForMoney
ld hl, wDayCareMan
res 0, [hl]
res 5, [hl]
@@ -54,7 +55,7 @@ Special_DayCareMan: ; 166d6
call PrintDayCareText
.cancel
- ld a, DAYCARETEXT_13
+ ld a, DAYCARETEXT_COME_AGAIN
call PrintDayCareText
ret
; 1672a
@@ -83,7 +84,7 @@ Special_DayCareLady: ; 1672a
call DayCare_AskWithdrawBreedMon
jr c, .print_text
farcall RetrievePokemonFromDayCareLady
- call DayCare_TakeMoney_PlayCry
+ call DayCare_GetBackMonForMoney
ld hl, wDayCareLady
res 0, [hl]
ld hl, wDayCareMan
@@ -94,7 +95,7 @@ Special_DayCareLady: ; 1672a
call PrintDayCareText
.cancel
- ld a, DAYCARETEXT_13
+ ld a, DAYCARETEXT_COME_AGAIN
call PrintDayCareText
ret
; 16781
@@ -145,7 +146,7 @@ DayCareAskDepositPokemon: ; 16798
ret
.Declined:
- ld a, DAYCARETEXT_COME_AGAIN
+ ld a, DAYCARETEXT_OH_FINE
scf
ret
@@ -180,7 +181,7 @@ DayCare_DepositPokemonText: ; 167f6
ld a, DAYCARETEXT_DEPOSIT
call PrintDayCareText
ld a, [CurPartySpecies]
- call PlayCry
+ call PlayMonCry
ld a, DAYCARETEXT_COME_BACK_LATER
call PrintDayCareText
ret
@@ -190,7 +191,7 @@ DayCare_AskWithdrawBreedMon: ; 16807
ld a, [StringBuffer2 + 1]
and a
jr nz, .grew_at_least_one_level
- ld a, DAYCARETEXT_PARTY_FULL
+ ld a, DAYCARETEXT_TOO_SOON
call PrintDayCareText
call YesNoBox
jr c, .refused
@@ -218,30 +219,30 @@ DayCare_AskWithdrawBreedMon: ; 16807
ret
.refused
- ld a, DAYCARETEXT_COME_AGAIN
+ ld a, DAYCARETEXT_OH_FINE
scf
ret
.not_enough_money
- ld a, DAYCARETEXT_OH_FINE
+ ld a, DAYCARETEXT_NOT_ENOUGH_MONEY
scf
ret
.PartyFull:
- ld a, DAYCARETEXT_NOT_ENOUGH_MONEY
+ ld a, DAYCARETEXT_PARTY_FULL
scf
ret
; 16850
-DayCare_TakeMoney_PlayCry: ; 16850
+DayCare_GetBackMonForMoney: ; 16850
ld bc, StringBuffer2 + 2
ld de, Money
farcall TakeMoney
ld a, DAYCARETEXT_WITHDRAW
call PrintDayCareText
ld a, [CurPartySpecies]
- call PlayCry
- ld a, DAYCARETEXT_TOO_SOON
+ call PlayMonCry
+ ld a, DAYCARETEXT_GOT_BACK
call PrintDayCareText
ret
; 1686d
@@ -283,6 +284,7 @@ PrintDayCareText: ; 1689b
; 168aa
.TextTable: ; 168aa
+; entries correspond to DAYCARETEXT_* constants
dw .DayCareManIntro ; 00
dw .DayCareManOddEgg ; 01
dw .DayCareLadyIntro ; 02
@@ -465,14 +467,14 @@ Special_DayCareManOutside: ; 16936
.Load0:
call PrintText
- xor a
+ xor a ; FALSE
ld [ScriptVar], a
ret
.PartyFull:
ld hl, .PartyFullText
call PrintText
- ld a, $1
+ ld a, TRUE
ld [ScriptVar], a
ret
; 16993
@@ -529,7 +531,7 @@ DayCare_GiveEgg: ; 169ac
ld [hl], a
ld hl, PartyMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call DayCare_GetCurrentPartyMember
ld hl, wEggNick
call CopyBytes
@@ -618,7 +620,7 @@ DayCare_InitBreeding: ; 16a3b
ld bc, wEggMonEnd - wEggMon
call ByteFill
ld hl, wEggNick
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call ByteFill
ld hl, wEggOT
ld bc, NAME_LENGTH
diff --git a/engine/events/dratini.asm b/engine/events/dratini.asm
index f110b34ab..83732bef2 100644
--- a/engine/events/dratini.asm
+++ b/engine/events/dratini.asm
@@ -1,4 +1,4 @@
-SpecialDratini: ; 0x8b170
+Special_Dratini: ; 0x8b170
; if ScriptVar is 0 or 1, change the moveset of the last Dratini in the party.
; 0: give it a special moveset with Extremespeed.
; 1: give it the normal moveset of a level 15 Dratini.
diff --git a/engine/events/elevator.asm b/engine/events/elevator.asm
index 9170b642d..e0426c5bd 100755
--- a/engine/events/elevator.asm
+++ b/engine/events/elevator.asm
@@ -188,24 +188,23 @@ Elevator_GetCurrentFloorString: ; 1353f
; 13550
Elevator_MenuDataHeader: ; 0x13550
- db $40 ; flags
- db 01, 12 ; start coords
- db 09, 18 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 12, 1, 18, 9
dw Elevator_MenuData2
db 1 ; default option
; 0x13558
Elevator_MenuData2: ; 0x13558
- db $10 ; flags
+ db SCROLLINGMENU_DISPLAY_ARROWS ; flags
db 4, 0 ; rows, columns
db 1 ; horizontal spacing
dbw 0, CurElevator
- dba GetElevatorFlorStrings
+ dba GetElevatorFloorStrings
dba NULL
dba NULL
; 13568
-GetElevatorFlorStrings: ; 13568
+GetElevatorFloorStrings: ; 13568
ld a, [MenuSelection]
GetFloorString: ; 1356b
push de
@@ -220,7 +219,7 @@ FloorToString: ; 13575
push de
ld e, a
ld d, 0
- ld hl, .floors
+ ld hl, ElevatorFloorNames
add hl, de
add hl, de
ld a, [hli]
@@ -230,54 +229,4 @@ FloorToString: ; 13575
ret
; 13583
-.floors
- dw .b4f
- dw .b3f
- dw .b2f
- dw .b1f
- dw ._1f
- dw ._2f
- dw ._3f
- dw ._4f
- dw ._5f
- dw ._6f
- dw ._7f
- dw ._8f
- dw ._9f
- dw ._10f
- dw ._11f
- dw .roof
-
-.b4f
- db "B4F@"
-.b3f
- db "B3F@"
-.b2f
- db "B2F@"
-.b1f
- db "B1F@"
-._1f
- db "1F@"
-._2f
- db "2F@"
-._3f
- db "3F@"
-._4f
- db "4F@"
-._5f
- db "5F@"
-._6f
- db "6F@"
-._7f
- db "7F@"
-._8f
- db "8F@"
-._9f
- db "9F@"
-._10f
- db "10F@"
-._11f
- db "11F@"
-.roof
- db "ROOF@"
-; 135db
+INCLUDE "data/elevator_floors.asm"
diff --git a/engine/events/field_moves.asm b/engine/events/field_moves.asm
index a1a2e2e79..3fb1fe9e6 100755
--- a/engine/events/field_moves.asm
+++ b/engine/events/field_moves.asm
@@ -7,7 +7,7 @@ PlayWhirlpoolSound: ; 8c7d4
; 8c7e1
BlindingFlash: ; 8c7e1
- farcall FadeOutPalettes
+ farcall Special_FadeOutPalettes
ld hl, wStatusFlags
set 2, [hl] ; Flash
farcall ReplaceTimeOfDayPals
@@ -15,7 +15,7 @@ BlindingFlash: ; 8c7e1
ld b, SCGB_MAPPALS
call GetSGBLayout
farcall LoadOW_BGPal7
- farcall FadeInPalettes
+ farcall Special_FadeInPalettes
ret
; 8c80a
@@ -39,13 +39,13 @@ ShakeHeadbuttTree: ; 8c80a
ld [wCurrSpriteOAMAddr], a
farcall DoNextFrameForAllSprites
call HideHeadbuttTree
- ld a, $20
- ld [wcf64], a
+ ld a, 32
+ ld [wFrameCounter], a
call WaitSFX
ld de, SFX_SANDSTORM
call PlaySFX
.loop
- ld hl, wcf64
+ ld hl, wFrameCounter
ld a, [hl]
and a
jr z, .done
@@ -62,8 +62,8 @@ ShakeHeadbuttTree: ; 8c80a
xor a
ld [hBGMapMode], a
farcall ClearSpriteAnims
- ld hl, Sprites + 36 * 4
- ld bc, SpritesEnd - (Sprites + 36 * 4)
+ ld hl, Sprite37
+ ld bc, SpritesEnd - Sprite37
xor a
call ByteFill
ld de, Font
@@ -188,7 +188,7 @@ Cut_SpawnAnimateTree: ; 8ca23 (23:4a23)
add hl, bc
ld [hl], $84
ld a, 32
- ld [wcf64], a
+ ld [wFrameCounter], a
; Cut_StartWaiting
ld hl, wJumptableIndex
inc [hl]
@@ -206,7 +206,7 @@ Cut_SpawnAnimateLeaves: ; 8ca3c (23:4a3c)
ld a, $30
call Cut_SpawnLeaf
ld a, 32 ; frames
- ld [wcf64], a
+ ld [wFrameCounter], a
; Cut_StartWaiting
ld hl, wJumptableIndex
inc [hl]
@@ -220,7 +220,7 @@ Cut_StartWaiting: ; 8ca5c (23:4a5c)
inc [hl]
Cut_WaitAnimSFX: ; 8ca64 (23:4a64)
- ld hl, wcf64
+ ld hl, wFrameCounter
ld a, [hl]
and a
jr z, .finished
@@ -336,7 +336,7 @@ FlyFromAnim: ; 8caed
add hl, bc
ld [hl], SPRITE_ANIM_SEQ_FLY_FROM
ld a, 128
- ld [wcf64], a
+ ld [wFrameCounter], a
.loop
ld a, [wJumptableIndex]
bit 7, a
@@ -374,7 +374,7 @@ FlyToAnim: ; 8cb33
add hl, bc
ld [hl], 11 * 8
ld a, 64
- ld [wcf64], a
+ ld [wFrameCounter], a
.loop
ld a, [wJumptableIndex]
bit 7, a
@@ -393,19 +393,19 @@ FlyToAnim: ; 8cb33
ret
.RestorePlayerSprite_DespawnLeaves: ; 8cb82 (23:4b82)
- ld hl, Sprites + 2 ; Tile ID
+ ld hl, Sprite01TileID
xor a
- ld c, $4
-.loop2
- ld [hli], a
- inc hl
- inc hl
+ ld c, 4
+.OAMloop
+ ld [hli], a ; tile id
+rept SPRITEOAMSTRUCT_LENGTH +- 1
inc hl
+endr
inc a
dec c
- jr nz, .loop2
- ld hl, Sprites + 4 * 4
- ld bc, SpritesEnd - (Sprites + 4 * 4)
+ jr nz, .OAMloop
+ ld hl, Sprite05
+ ld bc, SpritesEnd - Sprite05
xor a
call ByteFill
ret
@@ -431,7 +431,7 @@ FlyFunction_InitGFX: ; 8cb9b (23:4b9b)
FlyFunction_FrameTimer: ; 8cbc8 (23:4bc8)
call .SpawnLeaf
- ld hl, wcf64
+ ld hl, wFrameCounter
ld a, [hl]
and a
jr z, .exit
diff --git a/engine/events/fish.asm b/engine/events/fish.asm
index 9d1ea63ae..39644847d 100644
--- a/engine/events/fish.asm
+++ b/engine/events/fish.asm
@@ -80,7 +80,7 @@ rept 4
endr
ld a, [TimeOfDay]
- and 3
+ maskbits NUM_DAYTIMES
cp NITE_F
jr c, .time_species
inc hl
diff --git a/engine/events/fruit_trees.asm b/engine/events/fruit_trees.asm
index d0b0bac15..44f2315a0 100644
--- a/engine/events/fruit_trees.asm
+++ b/engine/events/fruit_trees.asm
@@ -2,7 +2,7 @@ FruitTreeScript:: ; 44000
callasm GetCurTreeFruit
opentext
copybytetovar CurFruit
- itemtotext $0, $0
+ itemtotext USE_SCRIPT_VAR, MEM_BUFFER_0
writetext FruitBearingTreeText
buttonsound
callasm TryResetFruitTrees
@@ -58,7 +58,7 @@ CheckFruitTree: ; 44055
; 4405f
PickedFruitTree: ; 4405f
- farcall TrainerRankings_FruitPicked
+ farcall StubbedTrainerRankings_FruitPicked
ld b, 1
jp GetFruitTreeFlag
; 4406a
diff --git a/engine/events/halloffame.asm b/engine/events/halloffame.asm
index f1981c2fd..dbd3a2d5a 100755
--- a/engine/events/halloffame.asm
+++ b/engine/events/halloffame.asm
@@ -42,7 +42,7 @@ RedCredits:: ; 86455
ld [MusicFadeID + 1], a
ld a, 10
ld [MusicFade], a
- farcall FadeOutPalettes
+ farcall Special_FadeOutPalettes
xor a
ld [VramState], a
ld [hMapAnims], a
@@ -65,7 +65,7 @@ HallOfFame_FadeOutMusic: ; 8648e
ld [MusicFadeID + 1], a
ld a, 10
ld [MusicFade], a
- farcall FadeOutPalettes
+ farcall Special_FadeOutPalettes
xor a
ld [VramState], a
ld [hMapAnims], a
@@ -92,9 +92,9 @@ AnimateHallOfFame: ; 864c3
ld de, MUSIC_HALL_OF_FAME
call HallOfFame_PlayMusicDE
xor a
- ld [wcf64], a
+ ld [wHallOfFameMonCounter], a
.loop
- ld a, [wcf64]
+ ld a, [wHallOfFameMonCounter]
cp PARTY_LENGTH
jr nc, .done
ld hl, wHallOfFameTempMon1
@@ -108,7 +108,7 @@ AnimateHallOfFame: ; 864c3
pop hl
call .DisplayNewHallOfFamer
jr c, .done
- ld hl, wcf64
+ ld hl, wHallOfFameMonCounter
inc [hl]
jr .loop
@@ -208,9 +208,9 @@ GetHallOfFameParty: ; 8653f
push bc
ld a, c
ld hl, PartyMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call AddNTimes
- ld bc, PKMN_NAME_LENGTH - 1
+ ld bc, MON_NAME_LENGTH - 1
call CopyBytes
pop bc
@@ -321,7 +321,7 @@ _HallOfFamePC: ; 86650
.DisplayTeam:
xor a
- ld [wcf64], a
+ ld [wHallOfFameMonCounter], a
.next
call .DisplayMonAndStrings
jr c, .start_button
@@ -341,7 +341,7 @@ _HallOfFamePC: ; 86650
jr .loop
.a_button
- ld hl, wcf64
+ ld hl, wHallOfFameMonCounter
inc [hl]
jr .next
@@ -356,7 +356,7 @@ _HallOfFamePC: ; 86650
.DisplayMonAndStrings:
; Print the number of times the player has entered the Hall of Fame.
; If that number is above 200, print "HOF Master!" instead.
- ld a, [wcf64]
+ ld a, [wHallOfFameMonCounter]
cp PARTY_LENGTH
jr nc, .fail
ld hl, wHallOfFameTempMon1
@@ -460,7 +460,7 @@ DisplayHOFMon: ; 86748
ld a, [hli]
ld [TempMonLevel], a
ld de, StringBuffer2
- ld bc, PKMN_NAME_LENGTH - 1
+ ld bc, MON_NAME_LENGTH - 1
call CopyBytes
ld a, "@"
ld [StringBuffer2 + 10], a
diff --git a/engine/events/happiness_egg.asm b/engine/events/happiness_egg.asm
index a4ae8b7e6..2db54a1a7 100755
--- a/engine/events/happiness_egg.asm
+++ b/engine/events/happiness_egg.asm
@@ -1,4 +1,4 @@
-GetFirstPokemonHappiness: ; 718d
+Special_GetFirstPokemonHappiness: ; 718d
ld hl, PartyMon1Happiness
ld bc, PARTYMON_STRUCT_LENGTH
ld de, PartySpecies
@@ -17,11 +17,11 @@ GetFirstPokemonHappiness: ; 718d
call GetPokemonName
jp CopyPokemonName_Buffer1_Buffer3
-CheckFirstMonIsEgg: ; 71ac
+Special_CheckFirstMonIsEgg: ; 71ac
ld a, [PartySpecies]
ld [wd265], a
cp EGG
- ld a, $1
+ ld a, 1
jr z, .egg
xor a
diff --git a/engine/events/heal_machine_anim.asm b/engine/events/heal_machine_anim.asm
index 493330e58..067b2f554 100755
--- a/engine/events/heal_machine_anim.asm
+++ b/engine/events/heal_machine_anim.asm
@@ -1,4 +1,13 @@
-HealMachineAnim: ; 12324
+; Special_HealMachineAnim.Jumptable indexes
+ const_def
+ const HEALMACHINESTATE_LOADGFX
+ const HEALMACHINESTATE_PCLOADBALLS
+ const HEALMACHINESTATE_HOFLOADBALLS
+ const HEALMACHINESTATE_PLAYMUSIC
+ const HEALMACHINESTATE_HOFPLAYSFX
+ const HEALMACHINESTATE_FINISH
+
+Special_HealMachineAnim: ; 12324
; If you have no Pokemon, don't change the buffer. This can lead to some glitchy effects if you have no Pokemon.
ld a, [PartyCount]
and a
@@ -36,7 +45,7 @@ HealMachineAnim: ; 12324
ld [Buffer3], a
add hl, de
ld a, [hl]
- cp 5
+ cp HEALMACHINESTATE_FINISH
jr z, .finish
ld hl, .Jumptable
rst JumpTable
@@ -47,20 +56,29 @@ HealMachineAnim: ; 12324
; 12365
.Pointers: ; 12365
+; entries correspond to HEALMACHINE_* constants
dw .Pokecenter
dw .ElmLab
dw .HallOfFame
; 1236b
+healmachineanimseq: MACRO
+rept _NARG
+ db HEALMACHINESTATE_\1
+ shift
+endr
+ENDM
+
.Pokecenter: ; 1236b
- db 0, 1, 3, 5
+ healmachineanimseq LOADGFX, PCLOADBALLS, PLAYMUSIC, FINISH
.ElmLab: ; 1236f
- db 0, 1, 3, 5
+ healmachineanimseq LOADGFX, PCLOADBALLS, PLAYMUSIC, FINISH
.HallOfFame: ; 12373
- db 0, 2, 4, 5
+ healmachineanimseq LOADGFX, HOFLOADBALLS, HOFPLAYSFX, FINISH
; 12377
.Jumptable: ; 12377
+; entries correspond to HEALMACHINESTATE_* constants
dw .LoadGFX
dw .PC_LoadBallsOntoMachine
dw .HOF_LoadBallsOntoMachine
@@ -73,20 +91,20 @@ HealMachineAnim: ; 12324
call .LoadPalettes
ld de, .HealMachineGFX
ld hl, vTiles0 tile $7c
- lb bc, BANK(.HealMachineGFX), $2
+ lb bc, BANK(.HealMachineGFX), 2
call Request2bpp
ret
; 12393
.PC_LoadBallsOntoMachine: ; 12393
- ld hl, Sprites + $80
+ ld hl, Sprite33
ld de, .PC_ElmsLab_OAM
call .PlaceHealingMachineTile
call .PlaceHealingMachineTile
jr .LoadBallsOntoMachine
.HOF_LoadBallsOntoMachine: ; 123a1
- ld hl, Sprites + $80
+ ld hl, Sprite33
ld de, .HOF_OAM
.LoadBallsOntoMachine: ; 123a7
@@ -160,7 +178,7 @@ INCBIN "gfx/overworld/heal_machine.2bpp"
ld hl, .palettes
ld de, wOBPals2 palette PAL_OW_TREE
ld bc, 1 palettes
- ld a, $5
+ ld a, BANK(wOBPals2)
call FarCopyWRAM
ld a, $1
ld [hCGBPalUpdate], a
@@ -168,14 +186,11 @@ INCBIN "gfx/overworld/heal_machine.2bpp"
; 12451
.palettes ; 12451
- RGB 31, 31, 31
- RGB 31, 19, 10
- RGB 31, 07, 01
- RGB 00, 00, 00
+INCLUDE "gfx/overworld/heal_machine.pal"
; 12459
.FlashPalettes8Times: ; 12459
- ld c, $8
+ ld c, 8
.palette_loop
push bc
call .FlashPalettes
@@ -198,7 +213,7 @@ INCBIN "gfx/overworld/heal_machine.2bpp"
.go
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wOBPals2)
ld [rSVBK], a
ld hl, wOBPals2 palette PAL_OW_TREE
@@ -241,7 +256,7 @@ INCBIN "gfx/overworld/heal_machine.2bpp"
push bc
ld a, [Buffer1]
bcpixel 2, 4
- cp $1 ; ElmsLab
+ cp HEALMACHINE_ELMS_LAB
jr z, .okay
bcpixel 0, 0
@@ -249,17 +264,17 @@ INCBIN "gfx/overworld/heal_machine.2bpp"
ld a, [de]
add c
inc de
- ld [hli], a
+ ld [hli], a ; y
ld a, [de]
add b
inc de
- ld [hli], a
+ ld [hli], a ; x
ld a, [de]
inc de
- ld [hli], a
+ ld [hli], a ; tile id
ld a, [de]
inc de
- ld [hli], a
+ ld [hli], a ; attributes
pop bc
ret
; 124c1
diff --git a/engine/events/kurt.asm b/engine/events/kurt.asm
index 9bc06a613..13bde6f7e 100644
--- a/engine/events/kurt.asm
+++ b/engine/events/kurt.asm
@@ -76,7 +76,7 @@ Kurt_SelectApricorn: ; 88055
jr nz, .done
.nope
- xor a
+ xor a ; FALSE
.done
ld c, a
@@ -84,17 +84,16 @@ Kurt_SelectApricorn: ; 88055
; 88086
.MenuDataHeader: ; 0x88086
- db $40 ; flags
- db 01, 01 ; start coords
- db 10, 13 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 1, 1, 13, 10
dw .MenuData2
db 1 ; default option
; 0x8808e
- db 0
+ db 0 ; XXX
.MenuData2: ; 0x8808f
- db $10 ; flags
+ db SCROLLINGMENU_DISPLAY_ARROWS ; flags
db 4, 7
db 1
dbw 0, Buffer1
@@ -159,11 +158,11 @@ Kurt_SelectQuantity: ; 880c2
; 8810d
.MenuDataHeader: ; 0x8810d
- db $40 ; flags
- db 09, 06 ; start coords
- db 12, 19 ; end coords
-
- db 0, 0, -1, 0 ; XXX
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 6, 9, SCREEN_WIDTH - 1, 12
+ dw NULL
+ db -1 ; default option
+ db 0
.PlaceApricornName: ; 88116
call MenuBoxCoord2Tile
diff --git a/engine/events/loadfishinggfx.asm b/engine/events/loadfishinggfx.asm
new file mode 100644
index 000000000..f67c51d8b
--- /dev/null
+++ b/engine/events/loadfishinggfx.asm
@@ -0,0 +1,46 @@
+LoadFishingGFX: ; b84b3
+ ld a, [rVBK]
+ push af
+ ld a, $1
+ ld [rVBK], a
+
+ ld de, FishingGFX
+ ld a, [wPlayerGender]
+ bit 0, a
+ jr z, .got_gender
+ ld de, KrisFishingGFX
+.got_gender
+
+ ld hl, vTiles0 tile $02
+ call .LoadGFX
+ ld hl, vTiles0 tile $06
+ call .LoadGFX
+ ld hl, vTiles0 tile $0a
+ call .LoadGFX
+ ld hl, vTiles1 tile $7c
+ call .LoadGFX
+
+ pop af
+ ld [rVBK], a
+ ret
+; b84e3
+
+.LoadGFX: ; b84e3
+ lb bc, BANK(FishingGFX), 2
+ push de
+ call Get2bpp
+ pop de
+ ld hl, 2 tiles
+ add hl, de
+ ld d, h
+ ld e, l
+ ret
+; b84f2
+
+FishingGFX: ; b84f2
+INCBIN "gfx/overworld/chris_fish.2bpp"
+; b8582
+
+KrisFishingGFX: ; b8582
+INCBIN "gfx/overworld/kris_fish.2bpp"
+; b8612
diff --git a/engine/events/lucky_number.asm b/engine/events/lucky_number.asm
index 4488cfcc9..a172fc431 100644
--- a/engine/events/lucky_number.asm
+++ b/engine/events/lucky_number.asm
@@ -103,7 +103,7 @@ Special_CheckForLuckyNumberWinners: ; 4d87a
ld a, [ScriptVar]
and a
ret z ; found nothing
- farcall TrainerRankings_LuckyNumberShow
+ farcall StubbedTrainerRankings_LuckyNumberShow
ld a, [wFoundMatchingIDInParty]
and a
push af
diff --git a/engine/events/magikarp.asm b/engine/events/magikarp.asm
index 68e8baad7..6588295b8 100644
--- a/engine/events/magikarp.asm
+++ b/engine/events/magikarp.asm
@@ -28,7 +28,7 @@ Special_CheckMagikarpLength: ; fbb32
ld c, l
call CalcMagikarpLength
call PrintMagikarpLength
- farcall TrainerRankings_MagikarpLength
+ farcall StubbedTrainerRankings_MagikarpLength
ld hl, .MeasureItText
call PrintText
@@ -52,22 +52,22 @@ Special_CheckMagikarpLength: ; fbb32
ld hl, PartyMonOT
call SkipNames
call CopyBytes
- ld a, 3
+ ld a, MAGIKARPLENGTH_BEAT_RECORD
ld [ScriptVar], a
ret
.not_long_enough
- ld a, 2
+ ld a, MAGIKARPLENGTH_TOO_SHORT
ld [ScriptVar], a
ret
.declined
- ld a, 1
+ ld a, MAGIKARPLENGTH_REFUSED
ld [ScriptVar], a
ret
.not_magikarp
- xor a
+ xor a ; MAGIKARPLENGTH_NOT_MAGIKARP
ld [ScriptVar], a
ret
; fbba9
diff --git a/engine/events/magnet_train.asm b/engine/events/magnet_train.asm
index c85642ab8..232372dbd 100755
--- a/engine/events/magnet_train.asm
+++ b/engine/events/magnet_train.asm
@@ -16,7 +16,7 @@ Special_MagnetTrain: ; 8cc04
ld h, a
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wMagnetTrain)
ld [rSVBK], a
ld a, h
@@ -86,20 +86,20 @@ Special_MagnetTrain: ; 8cc04
MagnetTrain_UpdateLYOverrides: ; 8cc99
ld hl, LYOverridesBackup
ld c, $2f
- ld a, [wcf64]
+ ld a, [wMagnetTrainOffset]
add a
ld [hSCX], a
call .loadloop
ld c, $30
- ld a, [wcf65]
+ ld a, [wMagnetTrainPosition]
call .loadloop
ld c, $31
- ld a, [wcf64]
+ ld a, [wMagnetTrainOffset]
add a
call .loadloop
ld a, [wMagnetTrainDirection]
ld d, a
- ld hl, wcf64
+ ld hl, wMagnetTrainOffset
ld a, [hl]
add d
add d
@@ -129,7 +129,7 @@ MagntTrain_LoadGFX_PlayMusic: ; 8ccc9
ld [hSCY], a
ld a, [rSVBK]
push af
- ld a, $1
+ ld a, BANK(wPlayerGender)
ld [rSVBK], a
farcall GetPlayerIcon
pop af
@@ -147,11 +147,11 @@ MagntTrain_LoadGFX_PlayMusic: ; 8ccc9
call MagnetTrain_InitLYOverrides
ld hl, wJumptableIndex
xor a
- ld [hli], a
+ ld [hli], a ; wJumptableIndex
ld a, [wMagnetTrainInitPosition]
- ld [hli], a
- ld [hli], a
- ld [hli], a
+ ld [hli], a ; wMagnetTrainOffset
+ ld [hli], a ; wMagnetTrainPosition
+ ld [hli], a ; wMagnetTrainWaitCounter
ld de, MUSIC_MAGNET_TRAIN
call PlayMusic2
ret
@@ -220,8 +220,7 @@ GetMagnetTrainBGTiles: ; 8cd74
; 8cd82
MagnetTrainBGTiles: ; 8cd82
-; Alternating tiles for each line
-; of the Magnet Train tilemap.
+; Alternating tiles for each line of the Magnet Train tilemap.
db $4c, $4d ; bush
db $5c, $5d ; bush
db $4c, $4d ; bush
@@ -263,25 +262,25 @@ SetMagnetTrainPals: ; 8cdc3
; bushes
hlbgcoord 0, 0
ld bc, 4 * BG_MAP_WIDTH
- ld a, $2
+ ld a, PAL_BG_GREEN
call ByteFill
; train
hlbgcoord 0, 4
ld bc, 10 * BG_MAP_WIDTH
- xor a
+ xor a ; PAL_BG_GRAY
call ByteFill
; more bushes
hlbgcoord 0, 14
ld bc, 4 * BG_MAP_WIDTH
- ld a, $2
+ ld a, PAL_BG_GREEN
call ByteFill
; train window
hlbgcoord 7, 8
ld bc, 6
- ld a, $4
+ ld a, PAL_BG_YELLOW
call ByteFill
ld a, $0
@@ -325,7 +324,7 @@ MagnetTrain_Jumptable: ; 8cdf7
ld b, SPRITE_ANIM_INDEX_MAGNET_TRAIN_RED
ld a, [rSVBK]
push af
- ld a, $1
+ ld a, BANK(wPlayerGender)
ld [rSVBK], a
ld a, [wPlayerGender]
bit 0, a
@@ -342,13 +341,13 @@ MagnetTrain_Jumptable: ; 8cdf7
ld [hl], $0
call .Next
ld a, $80
- ld [wcf66], a
+ ld [wMagnetTrainWaitCounter], a
ret
; 8ce47
.MoveTrain1: ; 8ce47
ld hl, wMagnetTrainHoldPosition
- ld a, [wcf65]
+ ld a, [wMagnetTrainPosition]
cp [hl]
jr z, .PrepareToHoldTrain
ld e, a
@@ -356,7 +355,7 @@ MagnetTrain_Jumptable: ; 8cdf7
xor $ff
inc a
add e
- ld [wcf65], a
+ ld [wMagnetTrainPosition], a
ld hl, wGlobalAnimXOffset
ld a, [wMagnetTrainDirection]
add [hl]
@@ -366,12 +365,12 @@ MagnetTrain_Jumptable: ; 8cdf7
.PrepareToHoldTrain:
call .Next
ld a, $80
- ld [wcf66], a
+ ld [wMagnetTrainWaitCounter], a
ret
; 8ce6d
.WaitScene: ; 8ce6d
- ld hl, wcf66
+ ld hl, wMagnetTrainWaitCounter
ld a, [hl]
and a
jr z, .DoneWaiting
@@ -385,7 +384,7 @@ MagnetTrain_Jumptable: ; 8cdf7
.MoveTrain2: ; 8ce7a
ld hl, wMagnetTrainFinalPosition
- ld a, [wcf65]
+ ld a, [wMagnetTrainPosition]
cp [hl]
jr z, .PrepareToFinishAnim
ld e, a
@@ -396,7 +395,7 @@ MagnetTrain_Jumptable: ; 8cdf7
ld a, e
add d
add d
- ld [wcf65], a
+ ld [wMagnetTrainPosition], a
ld hl, wGlobalAnimXOffset
ld a, [wMagnetTrainDirection]
ld d, a
@@ -429,14 +428,14 @@ MagnetTrain_Jumptable_FirstRunThrough: ; 8ceae
call DelayFrame
ld a, [rSVBK]
push af
- ld a, $1
+ ld a, BANK(wEnvironment)
ld [rSVBK], a
ld a, [TimeOfDayPal]
push af
ld a, [wEnvironment]
push af
ld a, [TimeOfDay]
- and $3
+ maskbits NUM_DAYTIMES
ld [TimeOfDayPal], a
ld a, $1
ld [wEnvironment], a
@@ -459,23 +458,11 @@ MagnetTrain_Jumptable_FirstRunThrough: ; 8ceae
; 8ceff
MagnetTrainTilemap1:
- db $1f, $05, $06, $0a, $0a
- db $0a, $09, $0a, $0a, $0a
- db $0a, $0a, $0a, $09, $0a
- db $0a, $0a, $0b, $0c, $1f
+ db $1f, $05, $06, $0a, $0a, $0a, $09, $0a, $0a, $0a, $0a, $0a, $0a, $09, $0a, $0a, $0a, $0b, $0c, $1f
MagnetTrainTilemap2:
- db $14, $15, $16, $1a, $1a
- db $1a, $19, $1a, $1a, $1a
- db $1a, $1a, $1a, $19, $1a
- db $1a, $1a, $1b, $1c, $1d
+ db $14, $15, $16, $1a, $1a, $1a, $19, $1a, $1a, $1a, $1a, $1a, $1a, $19, $1a, $1a, $1a, $1b, $1c, $1d
MagnetTrainTilemap3:
- db $24, $25, $26, $27, $07
- db $2f, $29, $28, $28, $28
- db $28, $28, $28, $29, $07
- db $2f, $2a, $2b, $2c, $2d
+ db $24, $25, $26, $27, $07, $2f, $29, $28, $28, $28, $28, $28, $28, $29, $07, $2f, $2a, $2b, $2c, $2d
MagnetTrainTilemap4:
- db $20, $1f, $2e, $1f, $17
- db $00, $2e, $1f, $1f, $1f
- db $1f, $1f, $1f, $2e, $17
- db $00, $1f, $2e, $1f, $0f
+ db $20, $1f, $2e, $1f, $17, $00, $2e, $1f, $1f, $1f, $1f, $1f, $1f, $2e, $17, $00, $1f, $2e, $1f, $0f
; 8cf4f
diff --git a/engine/events/map_name_sign.asm b/engine/events/map_name_sign.asm
new file mode 100644
index 000000000..b20d74ee4
--- /dev/null
+++ b/engine/events/map_name_sign.asm
@@ -0,0 +1,274 @@
+MAP_NAME_SIGN_START EQU $60
+
+ReturnFromMapSetupScript:: ; b8000
+ xor a
+ ld [hBGMapMode], a
+ farcall .inefficient_farcall ; this is a waste of 6 ROM bytes and 6 stack bytes
+ ret
+; b800a
+
+; should have just been a fallthrough
+.inefficient_farcall ; b800a
+ ld a, [MapGroup]
+ ld b, a
+ ld a, [MapNumber]
+ ld c, a
+ call GetWorldMapLocation
+ ld [wCurrentLandmark], a
+ call .CheckNationalParkGate
+ jr z, .nationalparkgate
+
+ call GetMapEnvironment
+ cp GATE
+ jr nz, .not_gate
+
+.nationalparkgate
+ ld a, -1
+ ld [wCurrentLandmark], a
+
+.not_gate
+ ld hl, wEnteredMapFromContinue
+ bit 1, [hl]
+ res 1, [hl]
+ jr nz, .dont_do_map_sign
+
+ call .CheckMovingWithinLandmark
+ jr z, .dont_do_map_sign
+ ld a, [wCurrentLandmark]
+ ld [wPreviousLandmark], a
+
+ call .CheckSpecialMap
+ jr z, .dont_do_map_sign
+
+; Display for 60 frames
+ ld a, 60
+ ld [wLandmarkSignTimer], a
+ call LoadMapNameSignGFX
+ call InitMapNameFrame
+ farcall HDMATransfer_OnlyTopFourRows
+ ret
+
+.dont_do_map_sign
+ ld a, [wCurrentLandmark]
+ ld [wPreviousLandmark], a
+ ld a, $90
+ ld [rWY], a
+ ld [hWY], a
+ xor a
+ ld [hLCDCPointer], a
+ ret
+; b8064
+
+.CheckMovingWithinLandmark: ; b8064
+ ld a, [wCurrentLandmark]
+ ld c, a
+ ld a, [wPreviousLandmark]
+ cp c
+ ret z
+ cp SPECIAL_MAP
+ ret
+; b8070
+
+.CheckSpecialMap: ; b8070
+; These landmarks do not get pop-up signs.
+ cp -1
+ ret z
+ cp SPECIAL_MAP
+ ret z
+ cp RADIO_TOWER
+ ret z
+ cp LAV_RADIO_TOWER
+ ret z
+ cp UNDERGROUND_PATH
+ ret z
+ cp INDIGO_PLATEAU
+ ret z
+ cp POWER_PLANT
+ ret z
+ ld a, $1
+ and a
+ ret
+; b8089
+
+.CheckNationalParkGate: ; b8089
+ ld a, [MapGroup]
+ cp GROUP_ROUTE_35_NATIONAL_PARK_GATE
+ ret nz
+ ld a, [MapNumber]
+ cp MAP_ROUTE_35_NATIONAL_PARK_GATE
+ ret z
+ cp MAP_ROUTE_36_NATIONAL_PARK_GATE
+ ret
+; b8098
+
+
+PlaceMapNameSign:: ; b8098 (2e:4098)
+ ld hl, wLandmarkSignTimer
+ ld a, [hl]
+ and a
+ jr z, .disappear
+ dec [hl]
+ cp 60
+ ret z
+ cp 59
+ jr nz, .skip2
+ call InitMapNameFrame
+ call PlaceMapNameCenterAlign
+ farcall HDMATransfer_OnlyTopFourRows
+.skip2
+ ld a, $80
+ ld a, $70
+ ld [rWY], a
+ ld [hWY], a
+ ret
+
+.disappear
+ ld a, $90
+ ld [rWY], a
+ ld [hWY], a
+ xor a
+ ld [hLCDCPointer], a
+ ret
+
+
+LoadMapNameSignGFX: ; b80c6
+ ld de, MapEntryFrameGFX
+ ld hl, vTiles2 tile MAP_NAME_SIGN_START
+ lb bc, BANK(MapEntryFrameGFX), 14
+ call Get2bpp
+ ret
+; b80d3
+
+InitMapNameFrame: ; b80d3
+ hlcoord 0, 0
+ ld b, 2
+ ld c, 18
+ call InitMapSignAttrMap
+ call PlaceMapNameFrame
+ ret
+; b80e1
+
+
+PlaceMapNameCenterAlign: ; b80e1 (2e:40e1)
+ ld a, [wCurrentLandmark]
+ ld e, a
+ farcall GetLandmarkName
+ call .GetNameLength
+ ld a, SCREEN_WIDTH
+ sub c
+ srl a
+ ld b, $0
+ ld c, a
+ hlcoord 0, 2
+ add hl, bc
+ ld de, StringBuffer1
+ call PlaceString
+ ret
+
+.GetNameLength: ; b8101 (2e:4101)
+ ld c, 0
+ push hl
+ ld hl, StringBuffer1
+.loop
+ ld a, [hli]
+ cp "@"
+ jr z, .stop
+ cp "%"
+ jr z, .loop
+ inc c
+ jr .loop
+.stop
+ pop hl
+ ret
+
+
+InitMapSignAttrMap: ; b8115
+ ld de, AttrMap - TileMap
+ add hl, de
+ inc b
+ inc b
+ inc c
+ inc c
+ ld a, PAL_BG_TEXT | PRIORITY
+.loop
+ push bc
+ push hl
+.inner_loop
+ ld [hli], a
+ dec c
+ jr nz, .inner_loop
+ pop hl
+ ld de, SCREEN_WIDTH
+ add hl, de
+ pop bc
+ dec b
+ jr nz, .loop
+ ret
+; b812f
+
+PlaceMapNameFrame: ; b812f
+ hlcoord 0, 0
+ ; top left
+ ld a, MAP_NAME_SIGN_START + 1
+ ld [hli], a
+ ; top row
+ ld a, MAP_NAME_SIGN_START + 2
+ call .FillTopBottom
+ ; top right
+ ld a, MAP_NAME_SIGN_START + 4
+ ld [hli], a
+ ; left, first line
+ ld a, MAP_NAME_SIGN_START + 5
+ ld [hli], a
+ ; first line
+ call .FillMiddle
+ ; right, first line
+ ld a, MAP_NAME_SIGN_START + 11
+ ld [hli], a
+ ; left, second line
+ ld a, MAP_NAME_SIGN_START + 6
+ ld [hli], a
+ ; second line
+ call .FillMiddle
+ ; right, second line
+ ld a, MAP_NAME_SIGN_START + 12
+ ld [hli], a
+ ; bottom left
+ ld a, MAP_NAME_SIGN_START + 7
+ ld [hli], a
+ ; bottom
+ ld a, MAP_NAME_SIGN_START + 8
+ call .FillTopBottom
+ ; bottom right
+ ld a, MAP_NAME_SIGN_START + 10
+ ld [hl], a
+ ret
+; b815b
+
+.FillMiddle: ; b815b
+ ld c, SCREEN_WIDTH - 2
+ ld a, MAP_NAME_SIGN_START + 13
+.loop
+ ld [hli], a
+ dec c
+ jr nz, .loop
+ ret
+; b8164
+
+.FillTopBottom: ; b8164
+ ld c, 5
+ jr .enterloop
+
+.continueloop
+ ld [hli], a
+ ld [hli], a
+
+.enterloop
+ inc a
+ ld [hli], a
+ ld [hli], a
+ dec a
+ dec c
+ jr nz, .continueloop
+ ret
+; b8172
diff --git a/engine/events/misc_scripts.asm b/engine/events/misc_scripts.asm
index 97372a57a..73ed89143 100755
--- a/engine/events/misc_scripts.asm
+++ b/engine/events/misc_scripts.asm
@@ -2,7 +2,7 @@ Script_AbortBugContest: ; 0x122c1
checkflag ENGINE_BUG_CONTEST_TIMER
iffalse .finish
setflag ENGINE_DAILY_BUG_CONTEST
- special ContestReturnMons
+ special Special_ContestReturnMons
.finish
end
diff --git a/engine/events/misc_scripts_2.asm b/engine/events/misc_scripts_2.asm
index c4c51d5e6..29416a9e5 100644
--- a/engine/events/misc_scripts_2.asm
+++ b/engine/events/misc_scripts_2.asm
@@ -13,7 +13,7 @@ RepelWoreOffScript:: ; 0x13619
HiddenItemScript:: ; 0x13625
opentext
copybytetovar EngineBuffer3
- itemtotext 0, 0
+ itemtotext USE_SCRIPT_VAR, MEM_BUFFER_0
writetext .found_text
giveitem ITEM_FROM_MEM
iffalse .bag_full
diff --git a/engine/events/mom.asm b/engine/events/mom.asm
index 6e3c7b320..c7e1cd6e9 100644
--- a/engine/events/mom.asm
+++ b/engine/events/mom.asm
@@ -146,7 +146,7 @@ Special_BankOfMom: ; 16218
ld [hli], a
ld [hl], a
ld a, $5
- ld [wcf64], a
+ ld [wMomBankDigitCursorPosition], a
call LoadStandardMenuDataHeader
call Mom_SetUpDepositMenu
call Mom_Wait10Frames
@@ -213,7 +213,7 @@ Special_BankOfMom: ; 16218
ld [hli], a
ld [hl], a
ld a, $5
- ld [wcf64], a
+ ld [wMomBankDigitCursorPosition], a
call LoadStandardMenuDataHeader
call Mom_SetUpWithdrawMenu
call Mom_Wait10Frames
@@ -728,15 +728,14 @@ Mom_HeldString: ; 166b0
; 166b5
MenuDataHeader_0x166b5: ; 0x166b5
- db $40 ; flags
- db 00, 00 ; start coords
- db 10, 10 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, 10, 10
dw MenuData2_0x166bd
db 1 ; default option
; 0x166bd
MenuData2_0x166bd: ; 0x166bd
- db $80 ; flags
+ db STATICMENU_CURSOR ; flags
db 4 ; items
db "GET@"
db "SAVE@"
diff --git a/engine/events/mom_phone.asm b/engine/events/mom_phone.asm
index bef7d5688..d12bf0155 100755
--- a/engine/events/mom_phone.asm
+++ b/engine/events/mom_phone.asm
@@ -9,7 +9,7 @@ MomTriesToBuySomething:: ; fcfec
ld a, [wMapReentryScriptQueueFlag]
and a
ret nz
- call GetMapHeaderPhoneServiceNybble
+ call GetMapPhoneService
and a
ret nz
xor a
@@ -217,7 +217,7 @@ endr
INCLUDE "data/items/mom_phone.asm"
- db 0, 0, 0 ; XXX
+ db 0, 0, 0 ; unused
_MomText_HiHowAreYou: ; 0xfd1b1
; Hi, ! How are you?
@@ -255,10 +255,10 @@ _MomText_ItsInRoom: ; 0xfd1ca
db "@"
; 0xfd1cf
- db 0 ; XXX
+ db 0 ; unused
-Predef3A: ; fd1d0
+DummyPredef3A: ; fd1d0
ret
; fd1d1
- ret ; XXX
+ ret ; unused
diff --git a/engine/events/move_deleter.asm b/engine/events/move_deleter.asm
index 95fc0f1d8..3e06113ae 100644
--- a/engine/events/move_deleter.asm
+++ b/engine/events/move_deleter.asm
@@ -1,4 +1,4 @@
-MoveDeletion:
+Special_MoveDeletion:
ld hl, .IntroText
call PrintText
call YesNoBox
diff --git a/engine/events/move_tutor.asm b/engine/events/move_tutor.asm
index a15ecaf93..be5f37564 100644
--- a/engine/events/move_tutor.asm
+++ b/engine/events/move_tutor.asm
@@ -22,7 +22,7 @@ Special_MoveTutor: ; 4925b
.enter_loop
call CheckCanLearnMoveTutorMove
jr nc, .loop
- xor a
+ xor a ; FALSE
ld [ScriptVar], a
jr .quit
@@ -35,10 +35,11 @@ Special_MoveTutor: ; 4925b
.GetMoveTutorMove: ; 492a5
ld a, [ScriptVar]
- cp 1
+ cp MOVETUTOR_FLAMETHROWER
jr z, .flamethrower
- cp 2
+ cp MOVETUTOR_THUNDERBOLT
jr z, .thunderbolt
+ ; MOVETUTOR_ICE_BEAM
ld a, ICE_BEAM
ret
@@ -98,6 +99,5 @@ CheckCanLearnMoveTutorMove: ; 492b9
ret
.MenuDataHeader: ; 0x4930a
- db $40 ; flags
- db 12, 00 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
diff --git a/engine/events/name_rater.asm b/engine/events/name_rater.asm
index 771c5090a..796647f48 100644
--- a/engine/events/name_rater.asm
+++ b/engine/events/name_rater.asm
@@ -45,13 +45,13 @@ NameRater: ; fb6ed
jr c, .samename
; Copy the new name from StringBuffer2
ld hl, PartyMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
ld a, [CurPartyMon]
call AddNTimes
ld e, l
ld d, h
ld hl, StringBuffer2
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
ld hl, NameRaterEvenBetterText
@@ -115,7 +115,7 @@ CheckIfMonIsYourOT: ; fb78a
IsNewNameEmpty: ; fb7be
; Checks to see if the nickname loaded in StringBuffer2 is empty. If so, return carry.
ld hl, StringBuffer2
- ld c, PKMN_NAME_LENGTH - 1
+ ld c, MON_NAME_LENGTH - 1
.loop
ld a, [hli]
cp "@"
@@ -137,7 +137,7 @@ IsNewNameEmpty: ; fb7be
CompareNewToOld: ; fb7d3
; Compares the nickname in StringBuffer2 to the previous nickname. If they are the same, return carry.
ld hl, PartyMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
ld a, [CurPartyMon]
call AddNTimes
push hl
@@ -178,7 +178,7 @@ GetNicknameLength: ; fb802
ret z
inc c
ld a, c
- cp PKMN_NAME_LENGTH - 1
+ cp MON_NAME_LENGTH - 1
jr nz, .loop
ret
; fb80f
diff --git a/engine/events/odd_egg.asm b/engine/events/odd_egg.asm
index 4cbeb34dc..de3107804 100644
--- a/engine/events/odd_egg.asm
+++ b/engine/events/odd_egg.asm
@@ -43,7 +43,7 @@ GiveOddEgg: ; 1fb4b6
call AddNTimes
ld de, OddEggSpecies
- ld bc, PARTYMON_STRUCT_LENGTH + 2 * PKMN_NAME_LENGTH
+ ld bc, PARTYMON_STRUCT_LENGTH + 2 * MON_NAME_LENGTH
call CopyBytes
ld a, EGG_TICKET
@@ -73,7 +73,7 @@ GiveOddEgg: ; 1fb4b6
; load Odd Egg Name in wTempOddEggNickname
ld hl, .Odd
ld de, wTempOddEggNickname
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
; load pointer to wTempOddEggNickname in wMobileMonOTNamePointerBuffer
diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm
index 17ec54bb1..c9e0a5fe5 100755
--- a/engine/events/overworld.asm
+++ b/engine/events/overworld.asm
@@ -427,7 +427,7 @@ UsedSurfScript: ; c986
end
.empty_fn ; c9a2
- farcall TrainerRankings_Surf
+ farcall StubbedTrainerRankings_Surf
ret
UsedSurfText: ; c9a9
@@ -623,7 +623,7 @@ FlyFunction: ; ca3b
special UpdateTimePals
callasm FlyFromAnim
farscall Script_AbortBugContest
- special WarpToSpawnPoint
+ special Special_WarpToSpawnPoint
callasm DelayLoadingNewSprites
writecode VAR_MOVEMENT, PLAYER_NORMAL
newloadmap MAPSETUP_FLY
@@ -700,7 +700,7 @@ Script_UsedWaterfall: ; 0xcb20
ld a, [PlayerStandingTile]
call CheckWaterfallTile
ret z
- farcall TrainerRankings_Waterfall
+ farcall StubbedTrainerRankings_Waterfall
ld a, $1
ld [ScriptVar], a
ret
@@ -871,7 +871,7 @@ dig_incave
playsound SFX_WARP_TO
applymovement PLAYER, .DigOut
farscall Script_AbortBugContest
- special WarpToSpawnPoint
+ special Special_WarpToSpawnPoint
writecode VAR_MOVEMENT, PLAYER_NORMAL
newloadmap MAPSETUP_DOOR
playsound SFX_WARP_FROM
@@ -958,7 +958,7 @@ TeleportFunction: ; cc61
playsound SFX_WARP_TO
applymovement PLAYER, .TeleportFrom
farscall Script_AbortBugContest
- special WarpToSpawnPoint
+ special Special_WarpToSpawnPoint
writecode VAR_MOVEMENT, PLAYER_NORMAL
newloadmap MAPSETUP_TELEPORT
playsound SFX_WARP_FROM
@@ -986,7 +986,7 @@ StrengthFunction: ; cce5
jr c, .Failed
jr .UseStrength
-.AlreadyUsing: ; unreferenced
+.Unreferenced_AlreadyUsing:
ld hl, .JumpText
call MenuTextBoxBackup
ld a, $80
@@ -1749,7 +1749,7 @@ Script_GetOnBike_Register: ; 0xd14e
special ReplaceKrisSprite
end
-; XXX
+; unused
nop
ret
diff --git a/engine/events/poisonstep_pals.asm b/engine/events/poisonstep_pals.asm
index 498ae8f18..5b5b642ce 100644
--- a/engine/events/poisonstep_pals.asm
+++ b/engine/events/poisonstep_pals.asm
@@ -10,8 +10,8 @@ LoadPoisonBGPals: ; cbcdd
and a
jr nz, .cgb
ld a, [TimeOfDayPal]
- and $3
- cp $3
+ maskbits NUM_DAYTIMES
+ cp DARKNESS_F
ld a, %00000000
jr z, .convert_pals
ld a, %10101010
@@ -26,12 +26,11 @@ LoadPoisonBGPals: ; cbcdd
.cgb
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals2)
ld [rSVBK], a
ld hl, wBGPals2
ld c, 4 palettes
.loop
-; RGB 28, 21, 31
ld a, LOW(palred 28 + palgreen 21 + palblue 31)
ld [hli], a
ld a, HIGH(palred 28 + palgreen 21 + palblue 31)
diff --git a/engine/events/poke_seer.asm b/engine/events/poke_seer.asm
index d6e335298..fb9c6d9f9 100644
--- a/engine/events/poke_seer.asm
+++ b/engine/events/poke_seer.asm
@@ -15,12 +15,12 @@
const SEERACTION_CANT_TELL_2
const SEERACTION_LEVEL_ONLY
-SpecialPokeSeer: ; 4f0bc
+Special_PokeSeer: ; 4f0bc
ld a, SEER_INTRO
call PrintSeerText
call JoyWaitAorB
- ld b, $6
+ ld b, PARTY_LENGTH
farcall SelectMonFromParty
jr c, .cancel
@@ -148,10 +148,10 @@ ReadCaughtData: ; 4f134
GetCaughtName: ; 4f176
ld a, [CurPartyMon]
ld hl, PartyMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call AddNTimes
ld de, wSeerNickname
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
ret
; 4f18c
@@ -163,11 +163,11 @@ GetCaughtLevel: ; 4f18c
call ByteFill
; caught level
- ; Limited to between 1 and 63 for some reason.
+ ; Limited to between 1 and 63 since it's a 6-bit quantity.
ld a, [wSeerCaughtData]
- and $3f
+ and CAUGHT_LEVEL_MASK
jr z, .unknown
- cp 1 ; hatched from an egg
+ cp CAUGHT_EGG_LEVEL ; egg marker value
jr nz, .print
ld a, EGG_LEVEL ; egg hatch level
@@ -193,7 +193,7 @@ GetCaughtLevel: ; 4f18c
GetCaughtTime: ; 4f1c5
ld a, [wSeerCaughtData]
- and $c0
+ and CAUGHT_TIME_MASK
jr z, .none
rlca
@@ -233,11 +233,11 @@ UnknownCaughtData: ; 4f1f8
GetCaughtLocation: ; 4f20a
ld a, [wSeerCaughtGender]
- and $7f
+ and CAUGHT_LOCATION_MASK
jr z, .Unknown
- cp $7f
+ cp EVENT_LOCATION
jr z, .event
- cp $7e
+ cp GIFT_LOCATION
jr z, .fail
ld e, a
farcall GetLandmarkName
@@ -440,22 +440,22 @@ GetCaughtGender: ; 4f301
add hl, bc
ld a, [hl]
- and $7f
+ and CAUGHT_LOCATION_MASK
jr z, .genderless
- cp $7f
+ cp EVENT_LOCATION
jr z, .genderless
ld a, [hl]
- and $80
+ and CAUGHT_GENDER_MASK
jr nz, .male
- ld c, 1
+ ld c, CAUGHT_BY_GIRL
ret
.male
- ld c, 2
+ ld c, CAUGHT_BY_BOY
ret
.genderless
- ld c, 0
+ ld c, CAUGHT_BY_UNKNOWN
ret
; 4f31c
diff --git a/engine/events/pokecenter_pc.asm b/engine/events/pokecenter_pc.asm
index 7045dc1c8..75d2d5392 100755
--- a/engine/events/pokecenter_pc.asm
+++ b/engine/events/pokecenter_pc.asm
@@ -1,4 +1,4 @@
-PokemonCenterPC: ; 1559a
+Special_PokemonCenterPC: ; 1559a
call PC_CheckPartyForPokemon
ret c
call PC_PlayBootSound
@@ -27,14 +27,13 @@ PokemonCenterPC: ; 1559a
ret
.TopMenu:
- db $48 ; flags
- db 00, 00 ; start coords
- db 12, 15 ; end coords
+ db MENU_BACKUP_TILES | MENU_NO_CLICK_SFX ; flags
+ menu_coords 0, 0, 15, 12
dw .MenuData2
db 1 ; default option
.MenuData2:
- db $a0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_WRAP ; flags
db 0 ; items
dw .WhichPC
dw PlaceNthMenuStrings
@@ -232,14 +231,14 @@ Function15715: ; 15715
; 15736
KrissPCMenuData: ; 0x15736
- db %01000000
+ db MENU_BACKUP_TILES ; flags
db 0, 0 ; top left corner coords (y, x)
db 12, 15 ; bottom right corner coords (y, x)
dw .KrissPCMenuData2
db 1 ; default selected option
.KrissPCMenuData2:
- db %10100000 ; bit7
+ db STATICMENU_CURSOR | STATICMENU_WRAP ; flags
db 0 ; # items?
dw .KrissPCMenuList1
dw PlaceNthMenuStrings
@@ -421,7 +420,7 @@ KrisDepositItemMenu: ; 0x1588b
farcall DepositSellInitPackBuffers
.loop
farcall DepositSellPack
- ld a, [wcf66]
+ ld a, [wPackUsedItem]
and a
jr z, .close
call .TryDepositItem
@@ -620,14 +619,13 @@ PCItemsJoypad: ; 0x15985
ret
.PCItemsMenuData:
- db %01000000
- db 1, 4 ; start coords
- db 10, 18 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 4, 1, 18, 10
dw .MenuData2
db 1 ; default option
.MenuData2:
- db %10110000
+ db SCROLLINGMENU_ENABLE_SELECT | SCROLLINGMENU_ENABLE_FUNCTION3 | SCROLLINGMENU_DISPLAY_ARROWS ; flags
db 4, 8 ; rows/cols?
db 2 ; horizontal spacing?
dbw 0, PCItems
diff --git a/engine/events/pokepic.asm b/engine/events/pokepic.asm
index 82016403b..e9e14bbf4 100755
--- a/engine/events/pokepic.asm
+++ b/engine/events/pokepic.asm
@@ -42,8 +42,7 @@ ClosePokepic:: ; 24528
ret
PokepicMenuDataHeader: ; 0x24547
- db $40 ; flags
- db 04, 06 ; start coords
- db 13, 14 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 6, 4, 14, 13
dw NULL
db 1 ; default option
diff --git a/engine/events/print_photo.asm b/engine/events/print_photo.asm
index 06b01bbcf..54aa1892d 100755
--- a/engine/events/print_photo.asm
+++ b/engine/events/print_photo.asm
@@ -1,4 +1,4 @@
-PhotoStudio: ; 16dc7
+Special_PhotoStudio: ; 16dc7
ld hl, .Text_AskWhichMon
call PrintText
farcall SelectMonFromParty
diff --git a/engine/events/print_unown.asm b/engine/events/print_unown.asm
index 72248a67b..771d3ea5a 100644
--- a/engine/events/print_unown.asm
+++ b/engine/events/print_unown.asm
@@ -154,7 +154,7 @@ UnownPrinter: ; 16be4
.Load2bppToSRAM: ; 16cff
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
ld a, BANK(sScratch)
@@ -178,7 +178,7 @@ UnownPrinter: ; 16be4
hlcoord 1, 9
ld de, UnownDexVacantString
call PlaceString
- xor a
+ xor a ; sScratch
call GetSRAMBank
ld hl, sScratch
ld bc, $31 tiles
diff --git a/engine/events/print_unown_2.asm b/engine/events/print_unown_2.asm
index c932ded38..1e0b90fc5 100644
--- a/engine/events/print_unown_2.asm
+++ b/engine/events/print_unown_2.asm
@@ -1,7 +1,7 @@
RotateUnownFrontpic: ; e0000
; something to do with Unown printer
push de
- xor a
+ xor a ; sScratch
call GetSRAMBank
ld hl, sScratch
ld bc, 0
diff --git a/engine/events/prof_oaks_pc.asm b/engine/events/prof_oaks_pc.asm
index 69949940b..ae84a43a5 100755
--- a/engine/events/prof_oaks_pc.asm
+++ b/engine/events/prof_oaks_pc.asm
@@ -3,7 +3,7 @@ ProfOaksPC: ; 0x265d3
call MenuTextBox
call YesNoBox
jr c, .shutdown
- call ProfOaksPCBoot ; player chose "yes"?
+ call Special_ProfOaksPCBoot ; player chose "yes"?
.shutdown
ld hl, OakPCText4
call PrintText
@@ -11,7 +11,7 @@ ProfOaksPC: ; 0x265d3
call ExitMenu
ret
-ProfOaksPCBoot ; 0x265ee
+Special_ProfOaksPCBoot ; 0x265ee
ld hl, OakPCText2
call PrintText
call Rate
diff --git a/engine/events/sacred_ash.asm b/engine/events/sacred_ash.asm
index cc46eac9f..65ed83438 100755
--- a/engine/events/sacred_ash.asm
+++ b/engine/events/sacred_ash.asm
@@ -52,12 +52,12 @@ SacredAshScript: ; 0x50821
special HealParty
reloadmappart
playsound SFX_WARP_TO
- special FadeOutPalettes
- special FadeInPalettes
- special FadeOutPalettes
- special FadeInPalettes
- special FadeOutPalettes
- special FadeInPalettes
+ special Special_FadeOutPalettes
+ special Special_FadeInPalettes
+ special Special_FadeOutPalettes
+ special Special_FadeInPalettes
+ special Special_FadeOutPalettes
+ special Special_FadeInPalettes
waitsfx
writetext UnknownText_0x50845
playsound SFX_CAUGHT_MON
diff --git a/engine/events/special.asm b/engine/events/special.asm
index 939db4a25..128e7af29 100755
--- a/engine/events/special.asm
+++ b/engine/events/special.asm
@@ -1,4 +1,6 @@
-SpecialGiveShuckle: ; 7305
+MANIA_OT_ID EQU 00518
+
+Special_GiveShuckle: ; 7305
; Adding to the party.
xor a
@@ -32,9 +34,9 @@ SpecialGiveShuckle: ; 7305
; OT ID.
ld hl, PartyMon1ID
call AddNTimes
- ld a, $2
+ ld a, HIGH(MANIA_OT_ID)
ld [hli], a
- ld [hl], $6
+ ld [hl], LOW(MANIA_OT_ID)
; Nickname.
ld a, [PartyCount]
@@ -54,8 +56,7 @@ SpecialGiveShuckle: ; 7305
; Engine flag for this event.
ld hl, wDailyFlags
- set 5, [hl]
-; setflag ENGINE_SHUCKLE_GIVEN
+ set 5, [hl] ; ENGINE_SHUCKLE_GIVEN
ld a, 1
ld [ScriptVar], a
ret
@@ -70,7 +71,7 @@ SpecialShuckleOT:
SpecialShuckleNick:
db "SHUCKIE@"
-SpecialReturnShuckle: ; 737e
+Special_ReturnShuckle: ; 737e
farcall SelectMonFromParty
jr c, .refused
@@ -85,10 +86,10 @@ SpecialReturnShuckle: ; 737e
; OT ID
ld a, [hli]
- cp HIGH(00518)
+ cp HIGH(MANIA_OT_ID)
jr nz, .DontReturn
ld a, [hl]
- cp LOW(00518)
+ cp LOW(MANIA_OT_ID)
jr nz, .DontReturn
; OT
@@ -115,28 +116,28 @@ SpecialReturnShuckle: ; 737e
call AddNTimes
ld a, [hl]
cp 150
- ld a, $3
+ ld a, SHUCKIE_HAPPY
jr nc, .HappyToStayWithYou
xor a ; take from pc
ld [wPokemonWithdrawDepositParameter], a
callfar RemoveMonFromPartyOrBox
- ld a, $2
+ ld a, SHUCKIE_RETURNED
.HappyToStayWithYou:
ld [ScriptVar], a
ret
.refused
- ld a, $1
+ ld a, SHUCKIE_REFUSED
ld [ScriptVar], a
ret
.DontReturn:
- xor a
+ xor a ; SHUCKIE_WRONG_MON
ld [ScriptVar], a
ret
.fainted
- ld a, $4
+ ld a, SHUCKIE_FAINTED
ld [ScriptVar], a
ret
@@ -227,9 +228,8 @@ Data_DaisyMassage: ; 746b
CopyPokemonName_Buffer1_Buffer3: ; 746e
ld hl, StringBuffer1
ld de, StringBuffer3
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
jp CopyBytes
-Predef1: ; 747a
-; not used
+DummyPredef1: ; 747a
ret
diff --git a/engine/events/std_scripts.asm b/engine/events/std_scripts.asm
index 297725c60..216ce0058 100644
--- a/engine/events/std_scripts.asm
+++ b/engine/events/std_scripts.asm
@@ -1,4 +1,5 @@
StdScripts::
+; entries correspond to constants/std_constants.asm
dba PokecenterNurseScript
dba DifficultBookshelfScript
dba PictureBookshelfScript
@@ -107,13 +108,13 @@ PokecenterNurseScript:
farwritetext NurseTakePokemonText
pause 20
- special TrainerRankings_Healings
+ special Special_StubbedTrainerRankings_Healings
spriteface LAST_TALKED, LEFT
pause 10
special HealParty
playmusic MUSIC_NONE
- writebyte 0 ; Machine is at a Pokemon Center
- special HealMachineAnim
+ writebyte HEALMACHINE_POKECENTER
+ special Special_HealMachineAnim
pause 30
special RestartMapMusic
spriteface LAST_TALKED, DOWN
@@ -123,7 +124,7 @@ PokecenterNurseScript:
iftrue .no
checkflag ENGINE_POKERUS ; nurse already talked about pokerus
iftrue .no
- special SpecialCheckPokerus
+ special Special_CheckPokerus
iftrue .pokerus
.no
@@ -203,7 +204,7 @@ HomepageScript:
Radio1Script:
opentext
writebyte MAPRADIO_POKEMON_CHANNEL
- special MapRadio
+ special Special_MapRadio
closetext
end
@@ -211,7 +212,7 @@ Radio2Script:
; Lucky Channel
opentext
writebyte MAPRADIO_LUCKY_CHANNEL
- special MapRadio
+ special Special_MapRadio
closetext
end
@@ -220,7 +221,7 @@ TrashCanScript: ; 0xbc1a5
PCScript:
opentext
- special PokemonCenterPC
+ special Special_PokemonCenterPC
closetext
end
@@ -250,25 +251,25 @@ DayToTextScript:
if_equal THURSDAY, .Thursday
if_equal FRIDAY, .Friday
if_equal SATURDAY, .Saturday
- stringtotext .SundayText, 0
+ stringtotext .SundayText, MEM_BUFFER_0
end
.Monday:
- stringtotext .MondayText, 0
+ stringtotext .MondayText, MEM_BUFFER_0
end
.Tuesday:
- stringtotext .TuesdayText, 0
+ stringtotext .TuesdayText, MEM_BUFFER_0
end
.Wednesday:
- stringtotext .WednesdayText, 0
+ stringtotext .WednesdayText, MEM_BUFFER_0
end
.Thursday:
- stringtotext .ThursdayText, 0
+ stringtotext .ThursdayText, MEM_BUFFER_0
end
.Friday:
- stringtotext .FridayText, 0
+ stringtotext .FridayText, MEM_BUFFER_0
end
.Saturday:
- stringtotext .SaturdayText, 0
+ stringtotext .SaturdayText, MEM_BUFFER_0
end
.SundayText:
db "SUNDAY@"
@@ -297,7 +298,7 @@ RadioTowerRocketsScript:
clearevent EVENT_USED_THE_CARD_KEY_IN_THE_RADIO_TOWER
setevent EVENT_MAHOGANY_TOWN_POKEFAN_M_BLOCKS_EAST
specialphonecall SPECIALCALL_WEIRDBROADCAST
- setmapscene MAHOGANY_TOWN, $1
+ setmapscene MAHOGANY_TOWN, 1
end
BugContestResultsWarpScript:
@@ -306,7 +307,7 @@ BugContestResultsWarpScript:
setevent EVENT_ROUTE_36_NATIONAL_PARK_GATE_OFFICER_CONTEST_DAY
clearevent EVENT_ROUTE_36_NATIONAL_PARK_GATE_OFFICER_NOT_CONTEST_DAY
setevent EVENT_WARPED_FROM_ROUTE_35_NATIONAL_PARK_GATE
- warp ROUTE_36_NATIONAL_PARK_GATE, $0, $4
+ warp ROUTE_36_NATIONAL_PARK_GATE, 0, 4
applymovement PLAYER, Movement_ContestResults_WalkAfterWarp
BugContestResultsScript:
@@ -319,8 +320,8 @@ BugContestResultsScript:
opentext
farwritetext ContestResults_ReadyToJudgeText
waitbutton
- special BugContestJudging
- RAM2MEM $0
+ special Special_BugContestJudging
+ vartomem MEM_BUFFER_0
if_equal 1, BugContestResults_FirstPlace
if_equal 2, BugContestResults_SecondPlace
if_equal 3, BugContestResults_ThirdPlace
@@ -345,17 +346,18 @@ BugContestResults_FinishUp
iffalse BugContestResults_DidNotLeaveMons
farwritetext ContestResults_ReturnPartyText
waitbutton
- special ContestReturnMons
+ special Special_ContestReturnMons
BugContestResults_DidNotLeaveMons
- special CheckPartyFullAfterContest
- if_equal $0, BugContestResults_CleanUp
- if_equal $2, BugContestResults_CleanUp
+ special Special_CheckPartyFullAfterContest
+ if_equal BUGCONTEST_CAUGHT_MON, BugContestResults_CleanUp
+ if_equal BUGCONTEST_NO_CATCH, BugContestResults_CleanUp
+ ; BUGCONTEST_BOXED_MON
farwritetext ContestResults_PartyFullText
waitbutton
BugContestResults_CleanUp
closetext
- setscene $0
- setmapscene ROUTE_35_NATIONAL_PARK_GATE, $0
+ setscene 0
+ setmapscene ROUTE_35_NATIONAL_PARK_GATE, 0
setevent EVENT_BUG_CATCHING_CONTESTANT_1A
setevent EVENT_BUG_CATCHING_CONTESTANT_2A
setevent EVENT_BUG_CATCHING_CONTESTANT_3A
@@ -383,7 +385,7 @@ BugContestResults_CleanUp
BugContestResults_FirstPlace ; 0xbc31e
setevent EVENT_GAVE_KURT_APRICORNS
- itemtotext SUN_STONE, $1
+ itemtotext SUN_STONE, MEM_BUFFER_1
farwritetext ContestResults_PlayerWonAPrizeText
waitbutton
verbosegiveitem SUN_STONE
@@ -392,7 +394,7 @@ BugContestResults_FirstPlace ; 0xbc31e
; 0xbc332
BugContestResults_SecondPlace ; 0xbc332
- itemtotext EVERSTONE, $1
+ itemtotext EVERSTONE, MEM_BUFFER_1
farwritetext ContestResults_PlayerWonAPrizeText
waitbutton
verbosegiveitem EVERSTONE
@@ -401,7 +403,7 @@ BugContestResults_SecondPlace ; 0xbc332
; 0xbc343
BugContestResults_ThirdPlace ; 0xbc343
- itemtotext GOLD_BERRY, $1
+ itemtotext GOLD_BERRY, MEM_BUFFER_1
farwritetext ContestResults_PlayerWonAPrizeText
waitbutton
verbosegiveitem GOLD_BERRY
@@ -620,7 +622,7 @@ InitializeEventsScript:
return
AskNumber1MScript:
- special RandomPhoneMon
+ special Special_RandomPhoneMon
checkcode VAR_CALLERID
if_equal PHONE_SCHOOLBOY_JACK, .Jack
if_equal PHONE_SAILOR_HUEY, .Huey
@@ -705,7 +707,7 @@ AskNumber1MScript:
end
AskNumber2MScript:
- special RandomPhoneMon
+ special Special_RandomPhoneMon
checkcode VAR_CALLERID
if_equal PHONE_SCHOOLBOY_JACK, .Jack
if_equal PHONE_SAILOR_HUEY, .Huey
@@ -1758,7 +1760,7 @@ RematchGiftFScript:
end
GymStatue1Script:
- mapnametotext $0
+ mapnametotext MEM_BUFFER_0
opentext
farwritetext GymStatue_CityGymText
waitbutton
@@ -1766,7 +1768,7 @@ GymStatue1Script:
end
GymStatue2Script:
- mapnametotext $0
+ mapnametotext MEM_BUFFER_0
opentext
farwritetext GymStatue_CityGymText
buttonsound
@@ -1812,18 +1814,18 @@ CoinVendor_IntroScript: ; 0xbcde0
loadmenudata .MenuDataHeader
verticalmenu
closewindow
- if_equal $1, .Buy50
- if_equal $2, .Buy500
+ if_equal 1, .Buy50
+ if_equal 2, .Buy500
jump .Cancel
; 0xbcdf7
.Buy50: ; 0xbcdf7
- checkcoins 9949
- if_equal $0, .CoinCaseFull
- checkmoney $0, 1000
- if_equal $2, .NotEnoughMoney
+ checkcoins MAX_COINS - 50
+ if_equal HAVE_MORE, .CoinCaseFull
+ checkmoney YOUR_MONEY, 1000
+ if_equal HAVE_LESS, .NotEnoughMoney
givecoins 50
- takemoney $0, 1000
+ takemoney YOUR_MONEY, 1000
waitsfx
playsound SFX_TRANSACTION
farwritetext CoinVendor_Buy50CoinsText
@@ -1832,12 +1834,12 @@ CoinVendor_IntroScript: ; 0xbcde0
; 0xbce1b
.Buy500: ; 0xbce1b
- checkcoins 9499
- if_equal $0, .CoinCaseFull
- checkmoney $0, 10000
- if_equal $2, .NotEnoughMoney
+ checkcoins MAX_COINS - 500
+ if_equal HAVE_MORE, .CoinCaseFull
+ checkmoney YOUR_MONEY, 10000
+ if_equal HAVE_LESS, .NotEnoughMoney
givecoins 500
- takemoney $0, 10000
+ takemoney YOUR_MONEY, 10000
waitsfx
playsound SFX_TRANSACTION
farwritetext CoinVendor_Buy500CoinsText
@@ -1868,14 +1870,13 @@ CoinVendor_IntroScript: ; 0xbcde0
.MenuDataHeader:
- db $40 ; flags
- db 04, 00 ; start coords
- db 11, 15 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 4, 15, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
.MenuData2:
- db $80 ; flags
+ db STATICMENU_CURSOR ; flags
db 3 ; items
db " 50 : ¥1000@"
db "500 : ¥10000@"
@@ -1886,7 +1887,7 @@ CoinVendor_IntroScript: ; 0xbcde0
HappinessCheckScript:
faceplayer
opentext
- special GetFirstPokemonHappiness
+ special Special_GetFirstPokemonHappiness
if_less_than 50, .Unhappy
if_less_than 150, .KindaHappy
farwritetext HappinessText3
diff --git a/engine/events/treemons.asm b/engine/events/treemons.asm
new file mode 100755
index 000000000..780fef2cc
--- /dev/null
+++ b/engine/events/treemons.asm
@@ -0,0 +1,285 @@
+TreeMonEncounter: ; b81ea
+ farcall StubbedTrainerRankings_TreeEncounters
+
+ xor a
+ ld [TempWildMonSpecies], a
+ ld [CurPartyLevel], a
+
+ ld hl, TreeMonMaps
+ call GetTreeMonSet
+ jr nc, .no_battle
+
+ call GetTreeMons
+ jr nc, .no_battle
+
+ call GetTreeMon
+ jr nc, .no_battle
+
+ ld a, BATTLETYPE_TREE
+ ld [BattleType], a
+ ld a, 1
+ ld [ScriptVar], a
+ ret
+
+.no_battle
+ xor a
+ ld [ScriptVar], a
+ ret
+; b8219
+
+RockMonEncounter: ; b8219
+
+ xor a
+ ld [TempWildMonSpecies], a
+ ld [CurPartyLevel], a
+
+ ld hl, RockMonMaps
+ call GetTreeMonSet
+ jr nc, .no_battle
+
+ call GetTreeMons
+ jr nc, .no_battle
+
+ ; 40% chance of an encounter
+ ld a, 10
+ call RandomRange
+ cp 4
+ jr nc, .no_battle
+
+ call SelectTreeMon
+ jr nc, .no_battle
+
+ ret
+
+.no_battle
+ xor a
+ ret
+; b823e
+
+ db $05 ; ????
+
+GetTreeMonSet: ; b823f
+; Return carry and treemon set in a
+; if the current map is in table hl.
+ ld a, [MapNumber]
+ ld e, a
+ ld a, [MapGroup]
+ ld d, a
+.loop
+ ld a, [hli]
+ cp -1
+ jr z, .not_in_table
+
+ cp d
+ jr nz, .skip2
+
+ ld a, [hli]
+ cp e
+ jr nz, .skip1
+
+ jr .in_table
+
+.skip2
+ inc hl
+.skip1
+ inc hl
+ jr .loop
+
+.not_in_table
+ xor a
+ ret
+
+.in_table
+ ld a, [hl]
+ scf
+ ret
+; b825e
+
+INCLUDE "data/wild/treemon_maps.asm"
+
+GetTreeMons: ; b82d2
+; Return the address of TreeMon table a in hl.
+; Return nc if table a doesn't exist.
+
+ cp NUM_TREEMON_SETS
+ jr nc, .quit
+
+ and a
+ jr z, .quit
+
+ ld e, a
+ ld d, 0
+ ld hl, TreeMons
+ add hl, de
+ add hl, de
+
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ scf
+ ret
+
+.quit
+ xor a
+ ret
+; b82e8
+
+INCLUDE "data/wild/treemons.asm"
+
+GetTreeMon: ; b83e5
+ push hl
+ call GetTreeScore
+ pop hl
+ and a ; TREEMON_SCORE_BAD
+ jr z, .bad
+ cp TREEMON_SCORE_GOOD
+ jr z, .good
+ cp TREEMON_SCORE_RARE
+ jr z, .rare
+ ret
+
+.bad
+ ; 10% chance of an encounter
+ ld a, 10
+ call RandomRange
+ and a
+ jr nz, NoTreeMon
+ jr SelectTreeMon
+
+.good
+ ; 50% chance of an encounter
+ ld a, 10
+ call RandomRange
+ cp 5
+ jr nc, NoTreeMon
+ jr SelectTreeMon
+
+.rare
+ ; 80% chance of an encounter
+ ld a, 10
+ call RandomRange
+ cp 8
+ jr nc, NoTreeMon
+ jr .skip
+.skip
+ ld a, [hli]
+ cp -1
+ jr nz, .skip
+ call SelectTreeMon
+ ret
+; b841f
+
+SelectTreeMon: ; b841f
+; Read a TreeMons table and pick one monster at random.
+
+ ld a, 100
+ call RandomRange
+.loop
+ sub [hl]
+ jr c, .ok
+ inc hl
+ inc hl
+ inc hl
+ jr .loop
+
+.ok
+ ld a, [hli]
+ cp -1
+ jr z, NoTreeMon
+
+ ld a, [hli]
+ ld [TempWildMonSpecies], a
+ ld a, [hl]
+ ld [CurPartyLevel], a
+ scf
+ ret
+
+NoTreeMon: ; b843b
+ xor a
+ ld [TempWildMonSpecies], a
+ ld [CurPartyLevel], a
+ ret
+; b8443
+
+GetTreeScore: ; b8443
+ call .CoordScore
+ ld [Buffer1], a
+ call .OTIDScore
+ ld [Buffer2], a
+ ld c, a
+ ld a, [Buffer1]
+ sub c
+ jr z, .rare
+ jr nc, .ok
+ add 10
+.ok
+ cp 5
+ jr c, .good
+
+.bad
+ xor a ; TREEMON_SCORE_BAD
+ ret
+
+.good
+ ld a, TREEMON_SCORE_GOOD
+ ret
+
+.rare
+ ld a, TREEMON_SCORE_RARE
+ ret
+; b8466
+
+.CoordScore: ; b8466
+ call GetFacingTileCoord
+ ld hl, 0
+ ld c, e
+ ld b, 0
+ ld a, d
+
+ and a
+ jr z, .next
+.loop
+ add hl, bc
+ dec a
+ jr nz, .loop
+.next
+
+ add hl, bc
+ ld c, d
+ add hl, bc
+
+ ld a, h
+ ld [hDividend], a
+ ld a, l
+ ld [hDividend + 1], a
+ ld a, 5
+ ld [hDivisor], a
+ ld b, 2
+ call Divide
+
+ ld a, [hQuotient + 1]
+ ld [hDividend], a
+ ld a, [hQuotient + 2]
+ ld [hDividend + 1], a
+ ld a, 10
+ ld [hDivisor], a
+ ld b, 2
+ call Divide
+
+ ld a, [hQuotient + 3]
+ ret
+; b849d
+
+.OTIDScore: ; b849d
+ ld a, [PlayerID]
+ ld [hDividend], a
+ ld a, [PlayerID + 1]
+ ld [hDividend + 1], a
+ ld a, 10
+ ld [hDivisor], a
+ ld b, 2
+ call Divide
+ ld a, [hQuotient + 3]
+ ret
+; b84b3
diff --git a/engine/events/crystal_unown.asm b/engine/events/unown_walls.asm
index 09d44bb9a..4d59a2f7a 100644
--- a/engine/events/crystal_unown.asm
+++ b/engine/events/unown_walls.asm
@@ -1,9 +1,9 @@
-SpecialHoOhChamber: ; 0x8addb
+Special_HoOhChamber: ; 0x8addb
ld hl, PartySpecies
ld a, [hl]
cp HO_OH ; is Ho-oh the first Pokémon in the party?
jr nz, .done ; if not, we're done
- call GetSecondaryMapHeaderPointer
+ call GetMapDataPointer ; pointless?
ld de, EVENT_WALL_OPENED_IN_HO_OH_CHAMBER
ld b, SET_FLAG
call EventFlagAction
@@ -11,8 +11,8 @@ SpecialHoOhChamber: ; 0x8addb
ret
; 0x8adef
-SpecialOmanyteChamber: ; 8adef
- call GetSecondaryMapHeaderPointer
+Special_OmanyteChamber: ; 8adef
+ call GetMapDataPointer ; pointless?
ld de, EVENT_WALL_OPENED_IN_OMANYTE_CHAMBER
ld b, CHECK_FLAG
call EventFlagAction
@@ -44,7 +44,7 @@ SpecialOmanyteChamber: ; 8adef
jr nz, .loop
.open
- call GetSecondaryMapHeaderPointer
+ call GetMapDataPointer ; pointless?
ld de, EVENT_WALL_OPENED_IN_OMANYTE_CHAMBER
ld b, SET_FLAG
call EventFlagAction
@@ -57,12 +57,12 @@ SpecialAerodactylChamber: ; 8ae30
push de
push bc
- call GetSecondaryMapHeaderPointer
+ call GetMapDataPointer
ld a, h
- cp HIGH(RuinsOfAlphAerodactylChamber_SecondMapHeader)
+ cp HIGH(RuinsOfAlphAerodactylChamber_MapData)
jr nz, .nope
ld a, l
- cp LOW(RuinsOfAlphAerodactylChamber_SecondMapHeader)
+ cp LOW(RuinsOfAlphAerodactylChamber_MapData)
jr nz, .nope
ld de, EVENT_WALL_OPENED_IN_AERODACTYL_CHAMBER
@@ -85,12 +85,12 @@ SpecialKabutoChamber: ; 8ae4e
push hl
push de
- call GetSecondaryMapHeaderPointer
+ call GetMapDataPointer
ld a, h
- cp HIGH(RuinsOfAlphKabutoChamber_SecondMapHeader)
+ cp HIGH(RuinsOfAlphKabutoChamber_MapData)
jr nz, .done
ld a, l
- cp LOW(RuinsOfAlphKabutoChamber_SecondMapHeader)
+ cp LOW(RuinsOfAlphKabutoChamber_MapData)
jr nz, .done
ld de, EVENT_WALL_OPENED_IN_KABUTO_CHAMBER
@@ -105,7 +105,7 @@ SpecialKabutoChamber: ; 8ae4e
Special_DisplayUnownWords: ; 8ae68
ld a, [ScriptVar]
- ld hl, .MenuDataHeaders_UnownWalls
+ ld hl, MenuDataHeaders_UnownWalls
and a
jr z, .load
@@ -131,21 +131,21 @@ Special_DisplayUnownWords: ; 8ae68
add hl, de
ld a, [ScriptVar]
ld c, a
- ld de, .UnownText
+ ld de, UnownWalls
and a
jr z, .copy
.loop2
ld a, [de]
inc de
- cp $ff
+ cp -1
jr nz, .loop2
dec c
jr nz, .loop2
.copy
- call .CopyWord
+ call _DisplayUnownWords_CopyWord
ld bc, AttrMap - TileMap
add hl, bc
- call .FillAttr
+ call _DisplayUnownWords_FillAttr
call WaitBGMap2
call JoyWaitAorB
call PlayClickSFX
@@ -153,66 +153,9 @@ Special_DisplayUnownWords: ; 8ae68
ret
; 8aebc
-unownwall: MACRO
-rept _NARG
-if \1 == "-"
-x = $64
-else
-if \1 >= "Y"
-x = 2 * (\1 - "Y") + $60
-else
-if \1 >= "Q"
-x = 2 * (\1 - "Q") + $40
-else
-if \1 >= "I"
-x = 2 * (\1 - "I") + $20
-else
-x = 2 * (\1 - "A")
-endc
-endc
-endc
-endc
- db x
-shift
-endr
- db $ff
-ENDM
-
-.UnownText: ; 8aebc
-;.UnownText_Escape:
- ; db $08, $44, $04, $00, $2e, $08, $ff
- unownwall "E", "S", "C", "A", "P", "E"
-;.UnownText_Light:
- ; db $26, $20, $0c, $0e, $46, $ff
- unownwall "L", "I", "G", "H", "T"
-;.UnownText_Water:
- ; db $4c, $00, $46, $08, $42, $ff
- unownwall "W", "A", "T", "E", "R"
-;.UnownText_Ho_Oh:
- ; db $0e, $2c, $64, $2c, $0e, $ff
- unownwall "H", "O", "-", "O", "H"
-; 8aed5
-
-.MenuDataHeaders_UnownWalls: ; 0x8aed5
-;.MenuDataHeader_Escape:
- db $40 ; flags
- db 04, 03 ; start coords
- db 09, 16 ; end coords
-;.MenuDataHeader_Light:
- db $40 ; flags
- db 04, 04 ; start coords
- db 09, 15 ; end coords
-;.MenuDataHeader_Water:
- db $40 ; flags
- db 04, 04 ; start coords
- db 09, 15 ; end coords
-;.MenuDataHeader_Ho_Oh:
- db $40 ; flags
- db 04, 04 ; start coords
- db 09, 15 ; end coords
-; 8aee9
+INCLUDE "data/unown_walls.asm"
-.FillAttr: ; 8aee9
+_DisplayUnownWords_FillAttr: ; 8aee9
ld a, [de]
cp $ff
ret z
@@ -226,7 +169,7 @@ ENDM
inc hl
inc hl
inc de
- jr .FillAttr
+ jr _DisplayUnownWords_FillAttr
; 8aefd
.PlaceSquare: ; 8aefd
@@ -242,7 +185,7 @@ ENDM
ret
; 8af09
-.CopyWord: ; 8af09
+_DisplayUnownWords_CopyWord: ; 8af09
push hl
push de
.word_loop
diff --git a/engine/events/whiteout.asm b/engine/events/whiteout.asm
index a9d6f900e..aa629682f 100755
--- a/engine/events/whiteout.asm
+++ b/engine/events/whiteout.asm
@@ -4,13 +4,13 @@ Script_BattleWhiteout:: ; 0x124c1
; 0x124c8
Script_OverworldWhiteout:: ; 0x124c8
- refreshscreen $0
+ refreshscreen
callasm OverworldBGMap
Script_Whiteout: ; 0x124ce
writetext .WhitedOutText
waitbutton
- special FadeOutPalettes
+ special Special_FadeOutPalettes
pause 40
special HealParty
checkflag ENGINE_BUG_CONTEST_TIMER
@@ -18,7 +18,7 @@ Script_Whiteout: ; 0x124ce
callasm HalveMoney
callasm GetWhiteoutSpawn
farscall Script_AbortBugContest
- special WarpToSpawnPoint
+ special Special_WarpToSpawnPoint
newloadmap MAPSETUP_WARP
end_all
@@ -49,7 +49,7 @@ BattleBGMap: ; 1250a
; 12513
HalveMoney: ; 12513
- farcall TrainerRankings_WhiteOuts
+ farcall StubbedTrainerRankings_WhiteOuts
; Halve the player's money.
ld hl, Money
diff --git a/engine/events_2.asm b/engine/events_2.asm
index cac736bab..1149c2431 100644
--- a/engine/events_2.asm
+++ b/engine/events_2.asm
@@ -1,7 +1,7 @@
; More overworld event handling.
-WarpToSpawnPoint:: ; 97c28
+Special_WarpToSpawnPoint:: ; 97c28
ld hl, wStatusFlags2
res 1, [hl] ; safari zone?
res 2, [hl] ; bug contest
@@ -274,7 +274,7 @@ DoBikeStep:: ; 97db3
; If we're not in an area of phone service, we don't
; have to be here.
- call GetMapHeaderPhoneServiceNybble
+ call GetMapPhoneService
and a
jr nz, .NoCall
@@ -361,7 +361,7 @@ HandleCmdQueue:: ; 97e08
ret
; 97e25
-GetNthCmdQueueEntry: ; 97e25 unreferenced
+Unreferenced_GetNthCmdQueueEntry: ; 97e25
ld hl, wCmdQueue
ld bc, CMDQUEUE_ENTRY_SIZE
call AddNTimes
diff --git a/engine/events_3.asm b/engine/events_3.asm
deleted file mode 100755
index 5ee113a95..000000000
--- a/engine/events_3.asm
+++ /dev/null
@@ -1,689 +0,0 @@
-ReturnFromMapSetupScript:: ; b8000
- xor a
- ld [hBGMapMode], a
- ; For some reson, GameFreak chose to use a farcall here instead of just falling through.
- ; No other function in the game references the function at 2E:400A, here labeled
- ; ReturnFromMapSetupScript.inefficient_farcall.
- farcall .inefficient_farcall ; this is a waste of 6 ROM bytes and 6 stack bytes
- ret
-; b800a
-
-.inefficient_farcall ; b800a
- ld a, [MapGroup]
- ld b, a
- ld a, [MapNumber]
- ld c, a
- call GetWorldMapLocation
- ld [wCurrentLandmark], a
- call .CheckNationalParkGate
- jr z, .nationalparkgate
-
- call GetMapEnvironment
- cp GATE
- jr nz, .not_gate
-
-.nationalparkgate
- ld a, -1
- ld [wCurrentLandmark], a
-
-.not_gate
- ld hl, wEnteredMapFromContinue
- bit 1, [hl]
- res 1, [hl]
- jr nz, .dont_do_map_sign
-
- call .CheckMovingWithinLandmark
- jr z, .dont_do_map_sign
- ld a, [wCurrentLandmark]
- ld [wPreviousLandmark], a
-
- call .CheckSpecialMap
- jr z, .dont_do_map_sign
-
-; Display for 60 frames
- ld a, 60
- ld [wLandmarkSignTimer], a
- call LoadMapNameSignGFX
- call InitMapNameFrame
- farcall HDMATransfer_OnlyTopFourRows
- ret
-
-.dont_do_map_sign
- ld a, [wCurrentLandmark]
- ld [wPreviousLandmark], a
- ld a, $90
- ld [rWY], a
- ld [hWY], a
- xor a
- ld [hLCDCPointer], a
- ret
-; b8064
-
-.CheckMovingWithinLandmark: ; b8064
- ld a, [wCurrentLandmark]
- ld c, a
- ld a, [wPreviousLandmark]
- cp c
- ret z
- cp SPECIAL_MAP
- ret
-; b8070
-
-.CheckSpecialMap: ; b8070
- cp -1
- ret z
- cp SPECIAL_MAP
- ret z
- cp RADIO_TOWER
- ret z
- cp LAV_RADIO_TOWER
- ret z
- cp UNDERGROUND_PATH
- ret z
- cp INDIGO_PLATEAU
- ret z
- cp POWER_PLANT
- ret z
- ld a, $1
- and a
- ret
-; b8089
-
-.CheckNationalParkGate: ; b8089
- ld a, [MapGroup]
- cp GROUP_ROUTE_35_NATIONAL_PARK_GATE
- ret nz
- ld a, [MapNumber]
- cp MAP_ROUTE_35_NATIONAL_PARK_GATE
- ret z
- cp MAP_ROUTE_36_NATIONAL_PARK_GATE
- ret
-; b8098
-
-
-PlaceMapNameSign:: ; b8098 (2e:4098)
- ld hl, wLandmarkSignTimer
- ld a, [hl]
- and a
- jr z, .disappear
- dec [hl]
- cp 60
- ret z
- cp 59
- jr nz, .skip2
- call InitMapNameFrame
- call PlaceMapNameCenterAlign
- farcall HDMATransfer_OnlyTopFourRows
-.skip2
- ld a, $80
- ld a, $70
- ld [rWY], a
- ld [hWY], a
- ret
-
-.disappear
- ld a, $90
- ld [rWY], a
- ld [hWY], a
- xor a
- ld [hLCDCPointer], a
- ret
-
-
-LoadMapNameSignGFX: ; b80c6
- ld de, MapEntryFrameGFX
- ld hl, vTiles2 tile $60
- lb bc, BANK(MapEntryFrameGFX), $e
- call Get2bpp
- ret
-; b80d3
-
-InitMapNameFrame: ; b80d3
- hlcoord 0, 0
- ld b, 2
- ld c, 18
- call InitMapSignAttrMap
- call PlaceMapNameFrame
- ret
-; b80e1
-
-
-PlaceMapNameCenterAlign: ; b80e1 (2e:40e1)
- ld a, [wCurrentLandmark]
- ld e, a
- farcall GetLandmarkName
- call .GetNameLength
- ld a, SCREEN_WIDTH
- sub c
- srl a
- ld b, $0
- ld c, a
- hlcoord 0, 2
- add hl, bc
- ld de, StringBuffer1
- call PlaceString
- ret
-
-.GetNameLength: ; b8101 (2e:4101)
- ld c, 0
- push hl
- ld hl, StringBuffer1
-.loop
- ld a, [hli]
- cp "@"
- jr z, .stop
- cp "%"
- jr z, .loop
- inc c
- jr .loop
-.stop
- pop hl
- ret
-
-
-InitMapSignAttrMap: ; b8115
- ld de, AttrMap - TileMap
- add hl, de
- inc b
- inc b
- inc c
- inc c
- ld a, $87
-.loop
- push bc
- push hl
-.inner_loop
- ld [hli], a
- dec c
- jr nz, .inner_loop
- pop hl
- ld de, SCREEN_WIDTH
- add hl, de
- pop bc
- dec b
- jr nz, .loop
- ret
-; b812f
-
-PlaceMapNameFrame: ; b812f
- hlcoord 0, 0
- ; top left
- ld a, $61
- ld [hli], a
- ; top row
- ld a, $62
- call .FillTopBottom
- ; top right
- ld a, $64
- ld [hli], a
- ; left, first line
- ld a, $65
- ld [hli], a
- ; first line
- call .FillMiddle
- ; right, first line
- ld a, $6b
- ld [hli], a
- ; left, second line
- ld a, $66
- ld [hli], a
- ; second line
- call .FillMiddle
- ; right, second line
- ld a, $6c
- ld [hli], a
- ; bottom left
- ld a, $67
- ld [hli], a
- ; bottom
- ld a, $68
- call .FillTopBottom
- ; bottom right
- ld a, $6a
- ld [hl], a
- ret
-; b815b
-
-.FillMiddle: ; b815b
- ld c, 18
- ld a, $6d
-.loop
- ld [hli], a
- dec c
- jr nz, .loop
- ret
-; b8164
-
-.FillTopBottom: ; b8164
- ld c, 5
- jr .enterloop
-
-.continueloop
- ld [hli], a
- ld [hli], a
-
-.enterloop
- inc a
- ld [hli], a
- ld [hli], a
- dec a
- dec c
- jr nz, .continueloop
- ret
-; b8172
-
-CheckForHiddenItems: ; b8172
-; Checks to see if there are hidden items on the screen that have not yet been found. If it finds one, returns carry.
- call GetMapScriptHeaderBank
- ld [Buffer1], a
-; Get the coordinate of the bottom right corner of the screen, and load it in Buffer3/Buffer4.
- ld a, [XCoord]
- add SCREEN_WIDTH / 4
- ld [Buffer4], a
- ld a, [YCoord]
- add SCREEN_HEIGHT / 4
- ld [Buffer3], a
-; Get the pointer for the first BG event header in the map...
- ld hl, wCurrMapBGEventHeaderPointer
- ld a, [hli]
- ld h, [hl]
- ld l, a
-; ... before even checking to see if there are any BG events on this map.
- ld a, [wCurrMapBGEventCount]
- and a
- jr z, .nobgeventitems
-; For i = 1:wCurrMapBGEventCount...
-.loop
-; Store the counter in Buffer2, and store the BG event header pointer in the stack.
- ld [Buffer2], a
- push hl
-; Get the Y coordinate of the BG event.
- call .GetFarByte
- ld e, a
-; Is the Y coordinate of the BG event on the screen? If not, go to the next BG event.
- ld a, [Buffer3]
- sub e
- jr c, .next
- cp SCREEN_HEIGHT / 2
- jr nc, .next
-; Is the X coordinate of the BG event on the screen? If not, go to the next BG event.
- call .GetFarByte
- ld d, a
- ld a, [Buffer4]
- sub d
- jr c, .next
- cp SCREEN_WIDTH / 2
- jr nc, .next
-; Is this BG event a hidden item? If not, go to the next BG event.
- call .GetFarByte
- cp BGEVENT_ITEM
- jr nz, .next
-; Has this item already been found? If not, set off the Itemfinder.
- ld a, [Buffer1]
- call GetFarHalfword
- ld a, [Buffer1]
- call GetFarHalfword
- ld d, h
- ld e, l
- ld b, CHECK_FLAG
- call EventFlagAction
- ld a, c
- and a
- jr z, .itemnearby
-
-.next
-; Restore the BG event header pointer and increment it by the length of a BG event header.
- pop hl
- ld bc, 5
- add hl, bc
-; Restore the BG event counter and decrement it. If it hits zero, there are no hidden items in range.
- ld a, [Buffer2]
- dec a
- jr nz, .loop
-
-.nobgeventitems
- xor a
- ret
-
-.itemnearby
- pop hl
- scf
- ret
-; b81e2
-
-.GetFarByte: ; b81e2
- ld a, [Buffer1]
- call GetFarByte
- inc hl
- ret
-; b81ea
-
-
-TreeMonEncounter: ; b81ea
- farcall TrainerRankings_TreeEncounters
-
- xor a
- ld [TempWildMonSpecies], a
- ld [CurPartyLevel], a
-
- ld hl, TreeMonMaps
- call GetTreeMonSet
- jr nc, .no_battle
-
- call GetTreeMons
- jr nc, .no_battle
-
- call GetTreeMon
- jr nc, .no_battle
-
- ld a, BATTLETYPE_TREE
- ld [BattleType], a
- ld a, 1
- ld [ScriptVar], a
- ret
-
-.no_battle
- xor a
- ld [ScriptVar], a
- ret
-; b8219
-
-RockMonEncounter: ; b8219
-
- xor a
- ld [TempWildMonSpecies], a
- ld [CurPartyLevel], a
-
- ld hl, RockMonMaps
- call GetTreeMonSet
- jr nc, .no_battle
-
- call GetTreeMons
- jr nc, .no_battle
-
- ld a, 10
- call RandomRange
- cp 4
- jr nc, .no_battle
-
- call SelectTreeMon
- jr nc, .no_battle
-
- ret
-
-.no_battle
- xor a
- ret
-; b823e
-
- db $05 ; ????
-
-GetTreeMonSet: ; b823f
-; Return carry and treemon set in a
-; if the current map is in table hl.
- ld a, [MapNumber]
- ld e, a
- ld a, [MapGroup]
- ld d, a
-.loop
- ld a, [hli]
- cp -1
- jr z, .not_in_table
-
- cp d
- jr nz, .skip2
-
- ld a, [hli]
- cp e
- jr nz, .skip1
-
- jr .in_table
-
-.skip2
- inc hl
-.skip1
- inc hl
- jr .loop
-
-.not_in_table
- xor a
- ret
-
-.in_table
- ld a, [hl]
- scf
- ret
-; b825e
-
-INCLUDE "data/wild/treemon_maps.asm"
-
-GetTreeMons: ; b82d2
-; Return the address of TreeMon table a in hl.
-; Return nc if table a doesn't exist.
-
- cp 8
- jr nc, .quit
-
- and a
- jr z, .quit
-
- ld e, a
- ld d, 0
- ld hl, TreeMons
- add hl, de
- add hl, de
-
- ld a, [hli]
- ld h, [hl]
- ld l, a
-
- scf
- ret
-
-.quit
- xor a
- ret
-; b82e8
-
-INCLUDE "data/wild/treemons.asm"
-
-GetTreeMon: ; b83e5
- push hl
- call GetTreeScore
- pop hl
- and a
- jr z, .bad
- cp 1
- jr z, .good
- cp 2
- jr z, .rare
- ret
-
-.bad
- ld a, 10
- call RandomRange
- and a
- jr nz, NoTreeMon
- jr SelectTreeMon
-
-.good
- ld a, 10
- call RandomRange
- cp 5
- jr nc, NoTreeMon
- jr SelectTreeMon
-
-.rare
- ld a, 10
- call RandomRange
- cp 8
- jr nc, NoTreeMon
- jr .skip
-.skip
- ld a, [hli]
- cp -1
- jr nz, .skip
- call SelectTreeMon
- ret
-; b841f
-
-SelectTreeMon: ; b841f
-; Read a TreeMons table and pick one monster at random.
-
- ld a, 100
- call RandomRange
-.loop
- sub [hl]
- jr c, .ok
- inc hl
- inc hl
- inc hl
- jr .loop
-
-.ok
- ld a, [hli]
- cp $ff
- jr z, NoTreeMon
-
- ld a, [hli]
- ld [TempWildMonSpecies], a
- ld a, [hl]
- ld [CurPartyLevel], a
- scf
- ret
-
-NoTreeMon: ; b843b
- xor a
- ld [TempWildMonSpecies], a
- ld [CurPartyLevel], a
- ret
-; b8443
-
-GetTreeScore: ; b8443
- call .CoordScore
- ld [Buffer1], a
- call .OTIDScore
- ld [Buffer2], a
- ld c, a
- ld a, [Buffer1]
- sub c
- jr z, .rare
- jr nc, .ok
- add 10
-.ok
- cp 5
- jr c, .good
-
-.bad
- xor a
- ret
-
-.good
- ld a, 1
- ret
-
-.rare
- ld a, 2
- ret
-; b8466
-
-.CoordScore: ; b8466
- call GetFacingTileCoord
- ld hl, 0
- ld c, e
- ld b, 0
- ld a, d
-
- and a
- jr z, .next
-.loop
- add hl, bc
- dec a
- jr nz, .loop
-.next
-
- add hl, bc
- ld c, d
- add hl, bc
-
- ld a, h
- ld [hDividend], a
- ld a, l
- ld [hDividend + 1], a
- ld a, 5
- ld [hDivisor], a
- ld b, 2
- call Divide
-
- ld a, [hQuotient + 1]
- ld [hDividend], a
- ld a, [hQuotient + 2]
- ld [hDividend + 1], a
- ld a, 10
- ld [hDivisor], a
- ld b, 2
- call Divide
-
- ld a, [hQuotient + 3]
- ret
-; b849d
-
-.OTIDScore: ; b849d
- ld a, [PlayerID]
- ld [hDividend], a
- ld a, [PlayerID + 1]
- ld [hDividend + 1], a
- ld a, 10
- ld [hDivisor], a
- ld b, 2
- call Divide
- ld a, [hQuotient + 3]
- ret
-; b84b3
-
-LoadFishingGFX: ; b84b3
- ld a, [rVBK]
- push af
- ld a, $1
- ld [rVBK], a
-
- ld de, FishingGFX
- ld a, [wPlayerGender]
- bit 0, a
- jr z, .got_gender
- ld de, KrisFishingGFX
-.got_gender
-
- ld hl, vTiles0 tile $02
- call .LoadGFX
- ld hl, vTiles0 tile $06
- call .LoadGFX
- ld hl, vTiles0 tile $0a
- call .LoadGFX
- ld hl, vTiles1 tile $7c
- call .LoadGFX
-
- pop af
- ld [rVBK], a
- ret
-; b84e3
-
-.LoadGFX: ; b84e3
- lb bc, BANK(FishingGFX), 2
- push de
- call Get2bpp
- pop de
- ld hl, 2 tiles
- add hl, de
- ld d, h
- ld e, l
- ret
-; b84f2
-
-FishingGFX: ; b84f2
-INCBIN "gfx/overworld/chris_fish.2bpp"
-; b8582
-
-KrisFishingGFX: ; b8582
-INCBIN "gfx/overworld/kris_fish.2bpp"
-; b8612
diff --git a/engine/evolution_animation.asm b/engine/evolution_animation.asm
index 1fa55c10a..2e6e82e25 100755
--- a/engine/evolution_animation.asm
+++ b/engine/evolution_animation.asm
@@ -80,7 +80,7 @@ EvolutionAnimation: ; 4e5e1
jr c, .skip_cry
ld a, [wEvolutionOldSpecies]
- call PlayCry
+ call PlayMonCry
.skip_cry
ld de, MUSIC_EVOLUTION
@@ -148,7 +148,7 @@ EvolutionAnimation: ; 4e5e1
ret c
ld a, [PlayerHPPal]
- call PlayCry
+ call PlayMonCry
ret
; 4e703
@@ -168,7 +168,7 @@ EvolutionAnimation: ; 4e5e1
ld a, $1
ld [wBoxAlignment], a
ld de, vTiles2
- predef GetAnimatedFrontpicPredef
+ predef GetAnimatedFrontpic
xor a
ld [wBoxAlignment], a
ret
@@ -346,15 +346,15 @@ EvolutionAnimation: ; 4e5e1
inc a
and $7
ld b, a
- ld hl, Sprites + 3 ; attributes
- ld c, 40
+ ld hl, Sprite01Attributes
+ ld c, NUM_SPRITE_OAM_STRUCTS
.loop6
ld a, [hl]
or b
- ld [hli], a
- inc hl
- inc hl
+ ld [hli], a ; attributes
+rept SPRITEOAMSTRUCT_LENGTH +- 1
inc hl
+endr
dec c
jr nz, .loop6
pop bc
diff --git a/engine/evolve.asm b/engine/evolve.asm
index c335229d6..2e72320d4 100755
--- a/engine/evolve.asm
+++ b/engine/evolve.asm
@@ -247,7 +247,7 @@ EvolveAfterBattle_MasterLoop
push hl
ld hl, Text_EvolvedIntoPKMN
call PrintTextBoxText
- farcall TrainerRankings_MonsEvolved
+ farcall StubbedTrainerRankings_MonsEvolved
ld de, MUSIC_NONE
call PlayMusic
@@ -333,7 +333,7 @@ EvolveAfterBattle_MasterLoop
inc hl
jp .loop
-; XXX
+; unused
pop hl
.ReturnToMap:
pop de
@@ -371,7 +371,7 @@ UpdateSpeciesNameIfNotNicknamed: ; 42414
jr nz, .loop
ld a, [CurPartyMon]
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
ld hl, PartyMonNicknames
call AddNTimes
push hl
@@ -380,7 +380,7 @@ UpdateSpeciesNameIfNotNicknamed: ; 42414
call GetPokemonName
ld hl, StringBuffer1
pop de
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
jp CopyBytes
; 42454
@@ -621,7 +621,7 @@ ShiftMoves: ; 4256e
EvoFlagAction: ; 42577
push de
ld d, $0
- predef FlagPredef
+ predef SmallFarFlagAction
pop de
ret
; 42581
diff --git a/engine/gbc_only.asm b/engine/gbc_only.asm
index efceae701..badd953aa 100644
--- a/engine/gbc_only.asm
+++ b/engine/gbc_only.asm
@@ -10,18 +10,18 @@ GBCOnlyScreen: ; 4ea82
call ClearTileMap
ld hl, GBCOnlyGFX
- ld de, $d000
+ ld de, wGBCOnlyDecompressBuffer
ld a, [rSVBK]
push af
- ld a, 0
+ ld a, 0 ; this has the same effect as selecting bank 1
ld [rSVBK], a
call Decompress
pop af
ld [rSVBK], a
- ld de, $d000
+ ld de, wGBCOnlyDecompressBuffer
ld hl, vTiles2
- lb bc, BANK(GBCOnlyGFX), $54
+ lb bc, BANK(GBCOnlyGFX), 84
call Get2bpp
ld de, Font
diff --git a/engine/init_gender.asm b/engine/init_gender.asm
index 588709b88..76b1640d9 100755
--- a/engine/init_gender.asm
+++ b/engine/init_gender.asm
@@ -44,15 +44,14 @@ InitGender: ; 48dcb (12:4dcb)
; 48dfc (12:4dfc)
.MenuDataHeader: ; 0x48dfc
- db $40 ; flags
- db 04, 06 ; start coords
- db 09, 12 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 6, 4, 12, 9
dw .MenuData2
db 1 ; default option
; 0x48e04
.MenuData2: ; 0x48e04
- db $a1 ; flags
+ db STATICMENU_CURSOR | STATICMENU_WRAP | STATICMENU_DISABLE_B ; flags
db 2 ; items
db "Boy@"
db "Girl@"
@@ -90,17 +89,14 @@ LoadGenderScreenPal: ; 48e47 (12:4e47)
ld hl, .Palette
ld de, wBGPals1
ld bc, 1 palettes
- ld a, $5
+ ld a, BANK(wBGPals1)
call FarCopyWRAM
farcall ApplyPals
ret
; 48e5c (12:4e5c)
.Palette: ; 48e5c
- RGB 31, 31, 31
- RGB 09, 30, 31
- RGB 01, 11, 31
- RGB 00, 00, 00
+INCLUDE "gfx/new_game/gender_screen.pal"
; 48e64
LoadGenderScreenLightBlueTile: ; 48e64 (12:4e64)
@@ -112,4 +108,4 @@ LoadGenderScreenLightBlueTile: ; 48e64 (12:4e64)
; 48e71 (12:4e71)
.LightBlueTile: ; 48e71
-INCBIN "gfx/intro/gender_screen.2bpp"
+INCBIN "gfx/new_game/gender_screen.2bpp"
diff --git a/engine/init_hof_credits.asm b/engine/init_hof_credits.asm
index 8e3db75eb..d8eb7670a 100644
--- a/engine/init_hof_credits.asm
+++ b/engine/init_hof_credits.asm
@@ -46,9 +46,9 @@ InitDisplayForRedCredits: ; 4e8c2
ld hl, wBGPals1
ld c, 4 tiles
.load_white_palettes
- ld a, LOW(palred 31 + palgreen 31 + palblue 31)
+ ld a, LOW(PALRGB_WHITE)
ld [hli], a
- ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
+ ld a, HIGH(PALRGB_WHITE)
ld [hli], a
dec c
jr nz, .load_white_palettes
@@ -63,7 +63,7 @@ InitDisplayForRedCredits: ; 4e8c2
ResetDisplayBetweenHallOfFameMons: ; 4e906
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
ld hl, wDecompressScratch
ld bc, wScratchAttrMap - wDecompressScratch
diff --git a/engine/init_map.asm b/engine/init_map.asm
index e5bee971d..0ea2379d2 100644
--- a/engine/init_map.asm
+++ b/engine/init_map.asm
@@ -79,10 +79,10 @@ LoadFonts_NoOAMUpdate:: ; 64bf
HDMATransfer_FillBGMap0WithBlack: ; 64db
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
- ld a, "<BLACK>" ; $60
+ ld a, "■"
ld hl, wDecompressScratch
ld bc, wScratchAttrMap - wDecompressScratch
call ByteFill
diff --git a/engine/intro_menu.asm b/engine/intro_menu.asm
index 7d17b62e5..a26ac1f81 100755
--- a/engine/intro_menu.asm
+++ b/engine/intro_menu.asm
@@ -10,7 +10,7 @@ _MainMenu: ; 5ae8
jp StartTitleScreen
; 5b04
-; unreferenced
+; unused
ret
; 5b05
@@ -542,10 +542,10 @@ Continue_LoadMenuHeader: ; 5ebf
ld hl, .MenuDataHeader_Dex
ld a, [wStatusFlags]
bit 0, a ; pokedex
- jr nz, .pokedex_header
+ jr nz, .show_menu
ld hl, .MenuDataHeader_NoDex
-.pokedex_header
+.show_menu
call _OffsetMenuDataHeader
call MenuBox
call PlaceVerticalMenuItems
@@ -553,15 +553,14 @@ Continue_LoadMenuHeader: ; 5ebf
; 5ed9
.MenuDataHeader_Dex: ; 5ed9
- db $40 ; flags
- db 00, 00 ; start coords
- db 09, 15 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, 15, 9
dw .MenuData2_Dex
db 1 ; default option
; 5ee1
.MenuData2_Dex: ; 5ee1
- db $00 ; flags
+ db 0 ; flags
db 4 ; items
db "PLAYER@"
db "BADGES@"
@@ -570,15 +569,14 @@ Continue_LoadMenuHeader: ; 5ebf
; 5efb
.MenuDataHeader_NoDex: ; 5efb
- db $40 ; flags
- db 00, 00 ; start coords
- db 09, 15 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, 15, 9
dw .MenuData2_NoDex
db 1 ; default option
; 5f03
.MenuData2_NoDex: ; 5f03
- db $00 ; flags
+ db 0 ; flags
db 4 ; items
db "PLAYER <PLAYER>@"
db "BADGES@"
@@ -756,7 +754,7 @@ OakText2: ; 0x604a
text_jump _OakText2
start_asm
ld a, WOOPER
- call PlayCry
+ call PlayMonCry
call WaitSFX
ld hl, OakText3
ret
@@ -827,7 +825,7 @@ NamePlayer: ; 0x6074
db "KRIS@@@@@@@"
; 60e9
-Function60e9: ; Unreferenced
+Unreferenced_Function60e9:
call LoadMenuDataHeader
call VerticalMenu
ld a, [wMenuCursorY]
@@ -853,7 +851,7 @@ ShrinkPlayer: ; 610f
ld a, [hROMBank]
push af
- ld a, 0 << 7 | 32 ; fade out
+ ld a, 32 ; fade time
ld [MusicFade], a
ld de, MUSIC_NONE
ld a, e
@@ -954,8 +952,8 @@ Intro_PrepTrainerPic: ; 619c
ShrinkFrame: ; 61b4
ld de, vTiles2
- ld c, $31
- predef DecompressPredef
+ ld c, 7 * 7
+ predef DecompressGet2bpp
xor a
ld [hGraphicStartTile], a
hlcoord 6, 4
@@ -971,7 +969,7 @@ Intro_PlacePlayerSprite: ; 61cd
ld hl, vTiles0
call Request2bpp
- ld hl, Sprites
+ ld hl, Sprite01
ld de, .sprites
ld a, [de]
inc de
@@ -980,19 +978,19 @@ Intro_PlacePlayerSprite: ; 61cd
.loop
ld a, [de]
inc de
- ld [hli], a
+ ld [hli], a ; y
ld a, [de]
inc de
- ld [hli], a
+ ld [hli], a ; x
ld a, [de]
inc de
- ld [hli], a
+ ld [hli], a ; tile id
- ld b, 0
+ ld b, PAL_OW_RED
ld a, [wPlayerGender]
bit 0, a
jr z, .male
- ld b, 1
+ ld b, PAL_OW_BLUE
.male
ld a, b
@@ -1004,6 +1002,7 @@ Intro_PlacePlayerSprite: ; 61cd
.sprites ; 61fe
db 4
+ ; y pxl, x pxl, tile offset
db 9 * 8 + 4, 9 * 8, 0
db 9 * 8 + 4, 10 * 8, 1
db 10 * 8 + 4, 9 * 8, 2
@@ -1019,7 +1018,7 @@ CrystalIntroSequence: ; 620b
StartTitleScreen: ; 6219
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
call .TitleScreen
@@ -1094,7 +1093,7 @@ RunTitleScreen: ; 627b
ret
; 6292
-Function6292: ; 6292 ; unreferenced
+Unreferenced_Function6292: ; 6292
ld a, [hVBlankCounter]
and $7
ret nz
@@ -1125,7 +1124,7 @@ TitleScreenScene: ; 62a3
dw TitleScreenEnd
; 62b7
-.NextScene: ; Unreferenced
+.Unreferenced_NextScene:
ld hl, wJumptableIndex
inc [hl]
ret
@@ -1329,10 +1328,10 @@ ResetClock: ; 6392
jp Init
; 639b
-Function639b: ; unreferenced
+Unreferenced_Function639b:
; If bit 0 or 1 of [wTitleScreenTimer] is set, we don't need to be here.
ld a, [wTitleScreenTimer]
- and $3
+ and %00000011
ret nz
ld bc, SpriteAnim10
ld hl, SPRITEANIMSTRUCT_FRAME
@@ -1377,7 +1376,7 @@ Copyright: ; 63e2
call LoadFontsExtra
ld de, CopyrightGFX
ld hl, vTiles2 tile $60
- lb bc, BANK(CopyrightGFX), $1d
+ lb bc, BANK(CopyrightGFX), 29
call Request2bpp
hlcoord 2, 7
ld de, CopyrightString
diff --git a/engine/item_effects.asm b/engine/item_effects.asm
index 90dfdc7e0..c2bdd1f61 100644
--- a/engine/item_effects.asm
+++ b/engine/item_effects.asm
@@ -517,7 +517,7 @@ ParkBall: ; e8a2
cp BATTLETYPE_TUTORIAL
jp z, .FinishTutorial
- farcall TrainerRankings_WildMonsCaught
+ farcall StubbedTrainerRankings_WildMonsCaught
ld hl, Text_GotchaMonWasCaught
call PrintText
@@ -599,7 +599,7 @@ ParkBall: ; e8a2
dec a
ld [CurPartyMon], a
ld hl, PartyMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call AddNTimes
ld d, h
@@ -623,7 +623,7 @@ ParkBall: ; e8a2
.SendToPC:
call ClearSprites
- predef SentPkmnIntoBox
+ predef SendPkmnIntoBox
farcall SetBoxMonCaughtData
@@ -668,7 +668,7 @@ ParkBall: ; e8a2
ld hl, wMonOrItemNameBuffer
ld de, sBoxMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
ld hl, sBoxMonNicknames
@@ -683,7 +683,7 @@ ParkBall: ; e8a2
ld hl, sBoxMonNicknames
ld de, wMonOrItemNameBuffer
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
call CloseSRAM
@@ -748,7 +748,7 @@ BallMultiplierFunctionTable:
dbw MOON_BALL, MoonBallMultiplier
dbw LOVE_BALL, LoveBallMultiplier
dbw PARK_BALL, ParkBallMultiplier
- db $ff
+ db -1 ; end
UltraBallMultiplier:
; multiply catch rate by 2
@@ -775,7 +775,7 @@ GetPokedexEntryBank:
ld a, [EnemyMonSpecies]
rlca
rlca
- and 3
+ maskbits NUM_DEX_ENTRY_BANKS
ld hl, .PokedexEntryBanks
ld d, 0
ld e, a
@@ -786,12 +786,6 @@ GetPokedexEntryBank:
ret
.PokedexEntryBanks:
-
-GLOBAL PokedexEntries1
-GLOBAL PokedexEntries2
-GLOBAL PokedexEntries3
-GLOBAL PokedexEntries4
-
db BANK(PokedexEntries1)
db BANK(PokedexEntries2)
db BANK(PokedexEntries3)
@@ -1436,7 +1430,7 @@ RareCandy: ; ef14
call TextBox
hlcoord 11, 1
- ld bc, $0004
+ ld bc, 4
predef PrintTempMonStats
call WaitPressAorB_BlinkCursor
@@ -1576,7 +1570,7 @@ HealStatus: ; f030 (3:7030)
GetItemHealingAction: ; f058 (3:7058)
push hl
ld a, [CurItem]
- ld hl, .healingactions
+ ld hl, StatusHealingActions
ld bc, 3
.next
cp [hl]
@@ -1595,24 +1589,7 @@ GetItemHealingAction: ; f058 (3:7058)
ret
; f071 (3:7071)
-.healingactions ; f071
-; item, party menu action text, status
- db ANTIDOTE, PARTYMENUTEXT_HEAL_PSN, 1 << PSN
- db BURN_HEAL, PARTYMENUTEXT_HEAL_BRN, 1 << BRN
- db ICE_HEAL, PARTYMENUTEXT_HEAL_FRZ, 1 << FRZ
- db AWAKENING, PARTYMENUTEXT_HEAL_SLP, SLP
- db PARLYZ_HEAL, PARTYMENUTEXT_HEAL_PAR, 1 << PAR
- db FULL_HEAL, PARTYMENUTEXT_HEAL_ALL, %11111111
- db FULL_RESTORE, PARTYMENUTEXT_HEAL_ALL, %11111111
- db HEAL_POWDER, PARTYMENUTEXT_HEAL_ALL, %11111111
- db PSNCUREBERRY, PARTYMENUTEXT_HEAL_PSN, 1 << PSN
- db PRZCUREBERRY, PARTYMENUTEXT_HEAL_PAR, 1 << PAR
- db BURNT_BERRY, PARTYMENUTEXT_HEAL_FRZ, 1 << FRZ
- db ICE_BERRY, PARTYMENUTEXT_HEAL_BRN, 1 << BRN
- db MINT_BERRY, PARTYMENUTEXT_HEAL_SLP, SLP
- db MIRACLEBERRY, PARTYMENUTEXT_HEAL_ALL, %11111111
- db -1, 0, 0
-; f09e
+INCLUDE "data/items/heal_status.asm"
StatusHealer_Jumptable: ; f09e (3:709e)
ld hl, .dw
@@ -1668,7 +1645,7 @@ RevivePokemon: ; f0d6
ld d, 0
ld hl, wBattleParticipantsIncludingFainted
ld b, CHECK_FLAG
- predef FlagPredef
+ predef SmallFarFlagAction
ld a, c
and a
jr z, .skip_to_revive
@@ -1677,7 +1654,7 @@ RevivePokemon: ; f0d6
ld c, a
ld hl, wBattleParticipantsNotFainted
ld b, SET_FLAG
- predef FlagPredef
+ predef SmallFarFlagAction
.skip_to_revive
xor a
@@ -2118,7 +2095,7 @@ GetOneFifthMaxHP: ; f378 (3:7378)
GetHealingItemAmount: ; f395 (3:7395)
push hl
ld a, [CurItem]
- ld hl, .Healing
+ ld hl, HealingHPAmounts
ld d, a
.next
ld a, [hli]
@@ -2140,24 +2117,7 @@ GetHealingItemAmount: ; f395 (3:7395)
ret
; f3af (3:73af)
-.Healing: ; f3af
- dbw FRESH_WATER, 50
- dbw SODA_POP, 60
- dbw LEMONADE, 80
- dbw HYPER_POTION, 200
- dbw SUPER_POTION, 50
- dbw POTION, 20
- dbw MAX_POTION, MAX_STAT_VALUE
- dbw FULL_RESTORE, MAX_STAT_VALUE
- dbw MOOMOO_MILK, 100
- dbw BERRY, 10
- dbw GOLD_BERRY, 30
- dbw ENERGYPOWDER, 50
- dbw ENERGY_ROOT, 200
- dbw RAGECANDYBAR, 20
- dbw BERRY_JUICE, 20
- dbw -1, 0
-; f3df
+INCLUDE "data/items/heal_hp.asm"
Softboiled_MilkDrinkFunction: ; f3df (3:73df)
; Softboiled/Milk Drink in the field
@@ -2291,7 +2251,7 @@ PokeDoll: ; f48f
inc a
ld [wForcedSwitch], a
ld a, [wBattleResult]
- and 3 << 6
+ and $c0
or $2
ld [wBattleResult], a
jp UseItemText
@@ -2328,7 +2288,7 @@ XSpecial: ; f4c5
call UseItemText
ld a, [CurItem]
- ld hl, .x_item_table
+ ld hl, XItemStats
.loop
cp [hl]
@@ -2357,12 +2317,7 @@ XSpecial: ; f4c5
ret
; f504
-.x_item_table ; f504
- db X_ATTACK, ATTACK
- db X_DEFEND, DEFENSE
- db X_SPEED, SPEED
- db X_SPECIAL, SP_ATTACK
-; f50c
+INCLUDE "data/items/x_stats.asm"
PokeFlute: ; f50c
@@ -2572,10 +2527,10 @@ Mysteryberry: ; f5bf
cp SKETCH
jr z, .CantUsePPUpOnSketch
- ld bc, $0015
+ ld bc, MON_PP - MON_MOVES
add hl, bc
ld a, [hl]
- cp 3 << 6 ; have 3 PP Ups already been used?
+ cp PP_UP_MASK
jr c, .do_ppup
.CantUsePPUpOnSketch:
@@ -2586,7 +2541,7 @@ Mysteryberry: ; f5bf
.do_ppup
ld a, [hl]
- add 1 << 6 ; increase PP Up count by 1
+ add PP_UP_ONE
ld [hl], a
ld a, $1
ld [wd265], a
@@ -2714,7 +2669,7 @@ RestorePP: ; f6e8
ld a, [wd265]
ld b, a
ld a, [hl]
- and (1 << 6) - 1
+ and PP_MASK
cp b
jr nc, .dont_restore
@@ -2732,7 +2687,7 @@ RestorePP: ; f6e8
.restore_some
ld a, [hl]
- and (1 << 6) - 1
+ and PP_MASK
add c
cp b
jr nc, .restore_all
@@ -2740,7 +2695,7 @@ RestorePP: ; f6e8
.restore_all
ld a, [hl]
- and 3 << 6
+ and PP_UP_MASK
or b
ld [hl], a
ret
@@ -3125,7 +3080,7 @@ ApplyPPUp: ; f84c
.use
ld a, [hl]
- and 3 << 6
+ and PP_UP_MASK
ld a, [de] ; wasted cycle
call nz, ComputeMaxPP
@@ -3209,7 +3164,7 @@ RestoreAllPP: ; f8b9
pop bc
pop de
ld a, [de]
- and 3 << 6
+ and PP_UP_MASK
ld b, a
ld a, [wd265]
add b
@@ -3282,7 +3237,7 @@ GetMaxPPOfMove: ; f8ec
.notwild
add hl, bc
ld a, [hl]
- and 3 << 6
+ and PP_UP_MASK
pop bc
or b
@@ -3293,7 +3248,7 @@ GetMaxPPOfMove: ; f8ec
ld a, b ; this gets lost anyway
call ComputeMaxPP
ld a, [hl]
- and (1 << 6) - 1
+ and PP_MASK
ld [wd265], a
pop af
diff --git a/engine/landmarks.asm b/engine/landmarks.asm
index 75605bbd9..452bd2e92 100644
--- a/engine/landmarks.asm
+++ b/engine/landmarks.asm
@@ -80,8 +80,8 @@ RegionCheck: ; 0x1caea1
jr c, .kanto
.johto
- ld e, 0
+ ld e, JOHTO_REGION
ret
.kanto
- ld e, 1
+ ld e, KANTO_REGION
ret
diff --git a/engine/learn.asm b/engine/learn.asm
index d2751235f..2f1038d7f 100755
--- a/engine/learn.asm
+++ b/engine/learn.asm
@@ -5,7 +5,7 @@ LearnMove: ; 6508
call GetNick
ld hl, StringBuffer1
ld de, wMonOrItemNameBuffer
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
.loop
diff --git a/engine/link.asm b/engine/link.asm
index 5c45707d7..86a593284 100755
--- a/engine/link.asm
+++ b/engine/link.asm
@@ -28,9 +28,9 @@ LinkCommunications: ; 28000
call SetTradeRoomBGPals
call WaitBGMap2
ld hl, wcf5d
- xor a
+ xor a ; LOW($5000)
ld [hli], a
- ld [hl], $50
+ ld [hl], HIGH($5000)
ld a, [wLinkMode]
cp LINK_TIMECAPSULE
jp nz, Gen2ToGen2LinkComms
@@ -42,29 +42,31 @@ TimeCapsule: ; 2805d
xor a
ld [wPlayerLinkAction], a
call WaitLinkTransfer
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr nz, .player_1
+
ld c, 3
call DelayFrames
xor a
ld [hSerialSend], a
- ld a, $1
+ ld a, (0 << rSC_ON) | 1
ld [rSC], a
- ld a, $81
+ ld a, (1 << rSC_ON) | 1
ld [rSC], a
+
call DelayFrame
xor a
ld [hSerialSend], a
- ld a, $1
+ ld a, (0 << rSC_ON) | 1
ld [rSC], a
- ld a, $81
+ ld a, (1 << rSC_ON) | 1
ld [rSC], a
.player_1
ld de, MUSIC_NONE
call PlayMusic
- ld c, $3
+ ld c, 3
call DelayFrames
xor a
ld [rIF], a
@@ -73,19 +75,19 @@ TimeCapsule: ; 2805d
ld hl, wd1f3
ld de, EnemyMonSpecies
ld bc, $11
- call Function75f
- ld a, $fe
+ call Serial_ExchangeBytes
+ ld a, SERIAL_NO_DATA_BYTE
ld [de], a
ld hl, wLinkData
ld de, OTPlayerName
ld bc, $1a8
- call Function75f
- ld a, $fe
+ call Serial_ExchangeBytes
+ ld a, SERIAL_NO_DATA_BYTE
ld [de], a
ld hl, wMisc
ld de, wPlayerTrademonSpecies
ld bc, wPlayerTrademonSpecies - wMisc
- call Function75f
+ call Serial_ExchangeBytes
xor a
ld [rIF], a
ld a, $1d
@@ -107,25 +109,25 @@ TimeCapsule: ; 2805d
call Link_CopyOTData
ld de, wPlayerTrademonSpecies
ld hl, wTimeCapsulePartyMon1Species
- ld c, $2
+ ld c, 2
.loop
ld a, [de]
inc de
and a
jr z, .loop
- cp $fd
+ cp SERIAL_PREAMBLE_BYTE
jr z, .loop
- cp $fe
+ cp SERIAL_NO_DATA_BYTE
jr z, .loop
- cp $ff
+ cp SERIAL_PATCH_LIST_PART_TERMINATOR
jr z, .next
push hl
push bc
- ld b, $0
+ ld b, 0
dec a
ld c, a
add hl, bc
- ld a, $fe
+ ld a, SERIAL_NO_DATA_BYTE
ld [hl], a
pop bc
pop hl
@@ -168,8 +170,8 @@ TimeCapsule: ; 2805d
ld [wUnusedD102 + 1], a
ld de, MUSIC_NONE
call PlayMusic
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
ld c, 66
call z, DelayFrames
ld de, MUSIC_ROUTE_30
@@ -185,23 +187,25 @@ Gen2ToGen2LinkComms: ; 28177
ld a, [ScriptVar]
and a
jp z, LinkTimeout
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr nz, .Player1
+
ld c, 3
call DelayFrames
xor a
ld [hSerialSend], a
- ld a, $1
+ ld a, (0 << rSC_ON) | 1
ld [rSC], a
- ld a, $81
+ ld a, (1 << rSC_ON) | 1
ld [rSC], a
+
call DelayFrame
xor a
ld [hSerialSend], a
- ld a, $1
+ ld a, (0 << rSC_ON) | 1
ld [rSC], a
- ld a, $81
+ ld a, (1 << rSC_ON) | 1
ld [rSC], a
.Player1:
@@ -216,26 +220,26 @@ Gen2ToGen2LinkComms: ; 28177
ld hl, wd1f3
ld de, EnemyMonSpecies
ld bc, $11
- call Function75f
- ld a, $fe
+ call Serial_ExchangeBytes
+ ld a, SERIAL_NO_DATA_BYTE
ld [de], a
ld hl, wLinkData
ld de, OTPlayerName
ld bc, $1c2
- call Function75f
- ld a, $fe
+ call Serial_ExchangeBytes
+ ld a, SERIAL_NO_DATA_BYTE
ld [de], a
ld hl, wMisc
ld de, wPlayerTrademonSpecies
ld bc, $c8
- call Function75f
+ call Serial_ExchangeBytes
ld a, [wLinkMode]
cp LINK_TRADECENTER
jr nz, .not_trading
ld hl, wc9f4
ld de, wcb84
ld bc, $186
- call Function283f2
+ call ExchangeBytes
.not_trading
xor a
@@ -252,25 +256,25 @@ Gen2ToGen2LinkComms: ; 28177
call Link_CopyOTData
ld de, wPlayerTrademonSpecies
ld hl, wLinkPlayerPartyMon1Species
- ld c, $2
+ ld c, 2
.loop1
ld a, [de]
inc de
and a
jr z, .loop1
- cp $fd
+ cp SERIAL_PREAMBLE_BYTE
jr z, .loop1
- cp $fe
+ cp SERIAL_NO_DATA_BYTE
jr z, .loop1
- cp $ff
+ cp SERIAL_PATCH_LIST_PART_TERMINATOR
jr z, .next1
push hl
push bc
- ld b, $0
+ ld b, 0
dec a
ld c, a
add hl, bc
- ld a, $fe
+ ld a, SERIAL_NO_DATA_BYTE
ld [hl], a
pop bc
pop hl
@@ -286,13 +290,13 @@ Gen2ToGen2LinkComms: ; 28177
ld hl, wcb84
.loop2
ld a, [hli]
- cp $20
+ cp MAIL_MSG_LENGTH
jr nz, .loop2
.loop3
ld a, [hli]
- cp $fe
+ cp SERIAL_NO_DATA_BYTE
jr z, .loop3
- cp $20
+ cp MAIL_MSG_LENGTH
jr z, .loop3
dec hl
ld de, wcb84
@@ -302,9 +306,9 @@ Gen2ToGen2LinkComms: ; 28177
ld bc, $c6 ; 198
.loop4
ld a, [hl]
- cp $21
+ cp MAIL_MSG_LENGTH + 1
jr nz, .okay1
- ld [hl], $fe
+ ld [hl], SERIAL_NO_DATA_BYTE
.okay1
inc hl
dec bc
@@ -315,14 +319,14 @@ Gen2ToGen2LinkComms: ; 28177
.loop5
ld a, [de]
inc de
- cp $ff
+ cp SERIAL_PATCH_LIST_PART_TERMINATOR
jr z, .start_copying_mail
ld hl, wcc4a
dec a
ld b, $0
ld c, a
add hl, bc
- ld [hl], $fe
+ ld [hl], SERIAL_NO_DATA_BYTE
jr .loop5
.start_copying_mail
@@ -395,7 +399,7 @@ Gen2ToGen2LinkComms: ; 28177
ld bc, NAME_LENGTH
call CopyBytes
ld de, OTPartyCount
- ld bc, 8
+ ld bc, 1 + PARTY_LENGTH + 1
call CopyBytes
ld de, OTPlayerID
ld bc, 2
@@ -409,8 +413,8 @@ Gen2ToGen2LinkComms: ; 28177
ld [wUnusedD102 + 1], a
ld de, MUSIC_NONE
call PlayMusic
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
ld c, 66
call z, DelayFrames
ld a, [wLinkMode]
@@ -423,8 +427,8 @@ Gen2ToGen2LinkComms: ; 28177
ld hl, Options
ld a, [hl]
push af
- and $20
- or $3
+ and 1 << STEREO
+ or TEXT_DELAY_MED
ld [hl], a
ld hl, OTPlayerName
ld de, OTClassName
@@ -510,28 +514,28 @@ LinkTimeout: ; 283b2
db "@"
; 0x283f2
-Function283f2: ; 283f2
- ld a, $1
- ld [hFFCC], a
+ExchangeBytes: ; 283f2
+ ld a, TRUE
+ ld [hSerialIgnoringInitialData], a
.loop
ld a, [hl]
ld [hSerialSend], a
- call Function78a
+ call Serial_ExchangeByte
push bc
ld b, a
inc hl
- ld a, $30
+ ld a, 48
.delay_cycles
dec a
jr nz, .delay_cycles
- ld a, [hFFCC]
+ ld a, [hSerialIgnoringInitialData]
and a
ld a, b
pop bc
jr z, .load
dec hl
xor a
- ld [hFFCC], a
+ ld [hSerialIgnoringInitialData], a
jr .loop
.load
@@ -563,7 +567,7 @@ ClearLinkData: ; 28426
FixDataForLinkTransfer: ; 28434
ld hl, wd1f3
- ld a, $fd
+ ld a, SERIAL_PREAMBLE_BYTE
ld b, LinkBattleRNs - wd1f3
.loop1
ld [hli], a
@@ -572,13 +576,13 @@ FixDataForLinkTransfer: ; 28434
ld b, TempEnemyMonSpecies - LinkBattleRNs
.loop2
call Random
- cp $fd
+ cp SERIAL_PREAMBLE_BYTE
jr nc, .loop2
ld [hli], a
dec b
jr nz, .loop2
ld hl, wMisc
- ld a, $fd
+ ld a, SERIAL_PREAMBLE_BYTE
ld [hli], a
ld [hli], a
ld [hli], a
@@ -594,7 +598,7 @@ FixDataForLinkTransfer: ; 28434
.loop4
inc c
ld a, c
- cp $fd
+ cp SERIAL_PREAMBLE_BYTE
jr z, .next1
ld a, b
dec a
@@ -613,31 +617,31 @@ FixDataForLinkTransfer: ; 28434
.next2
inc hl
ld a, [hl]
- cp $fe
+ cp SERIAL_NO_DATA_BYTE
jr nz, .loop4
ld a, c
ld [de], a
inc de
- ld [hl], $ff
+ ld [hl], SERIAL_PATCH_LIST_PART_TERMINATOR
jr .loop4
.next1
- ld a, $ff
+ ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
ld [de], a
inc de
lb bc, 1, 0
jr .loop4
.done
- ld a, $ff
+ ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
ld [de], a
ret
; 28499
Link_PrepPartyData_Gen1: ; 28499
ld de, wLinkData
- ld a, $fd
- ld b, 6
+ ld a, SERIAL_PREAMBLE_BYTE
+ ld b, PARTY_LENGTH
.loop1
ld [de], a
inc de
@@ -804,38 +808,31 @@ Link_PrepPartyData_Gen1: ; 28499
Link_PrepPartyData_Gen2: ; 28595
ld de, wLinkData
- ld a, $fd
- ld b, 6
+ ld a, SERIAL_PREAMBLE_BYTE
+ ld b, PARTY_LENGTH
.loop1
ld [de], a
inc de
dec b
jr nz, .loop1
- ; de = $c806
ld hl, PlayerName
ld bc, NAME_LENGTH
call CopyBytes
- ; de = $c811
ld hl, PartyCount
ld bc, 1 + PARTY_LENGTH + 1
call CopyBytes
- ; de = $c819
ld hl, PlayerID
ld bc, 2
call CopyBytes
- ; de = $c81b
ld hl, PartyMon1Species
ld bc, PARTY_LENGTH * PARTYMON_STRUCT_LENGTH
call CopyBytes
- ; de = $c93b
ld hl, PartyMonOT
ld bc, PARTY_LENGTH * NAME_LENGTH
call CopyBytes
- ; de = $c97d
ld hl, PartyMonNicknames
- ld bc, PARTY_LENGTH * PKMN_NAME_LENGTH
+ ld bc, PARTY_LENGTH * MON_NAME_LENGTH
call CopyBytes
- ; de = $c9bf
; Okay, we did all that. Now, are we in the trade center?
ld a, [wLinkMode]
@@ -914,7 +911,7 @@ Link_PrepPartyData_Gen2: ; 28595
ld bc, PARTY_LENGTH * (sPartyMon1MailAuthor - sPartyMon1Mail)
.loop5
ld a, [hl]
- cp $fe
+ cp SERIAL_NO_DATA_BYTE
jr nz, .skip2
ld [hl], sPartyMon1MailAuthor - sPartyMon1Mail
@@ -931,9 +928,9 @@ Link_PrepPartyData_Gen2: ; 28595
.loop6
inc c
ld a, [hl]
- cp $fe
+ cp SERIAL_NO_DATA_BYTE
jr nz, .skip3
- ld [hl], $ff
+ ld [hl], SERIAL_PATCH_LIST_PART_TERMINATOR
ld a, c
ld [de], a
inc de
@@ -942,13 +939,13 @@ Link_PrepPartyData_Gen2: ; 28595
inc hl
dec b
jr nz, .loop6
- ld a, $ff
+ ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
ld [de], a
ret
; 28682
Function28682: ; 28682
- ld c, $5
+ ld c, 5
.loop
ld [de], a
inc de
@@ -981,7 +978,7 @@ Function2868a: ; 2868a
ld bc, PARTY_LENGTH * NAME_LENGTH
call CopyBytes
ld de, OTPartyMonNicknames
- ld bc, PARTY_LENGTH * PKMN_NAME_LENGTH
+ ld bc, PARTY_LENGTH * MON_NAME_LENGTH
jp CopyBytes
; 286ba
@@ -1130,13 +1127,13 @@ TimeCapsule_ReplaceTeruSama: ; 28771
ret
-INCLUDE "data/time_capsule/catch_rate_items.asm"
+INCLUDE "data/items/catch_rate_items.asm"
Link_CopyOTData: ; 2879e
.loop
ld a, [hli]
- cp $fe
+ cp SERIAL_NO_DATA_BYTE
jr z, .loop
ld [de], a
inc de
@@ -1148,8 +1145,8 @@ Link_CopyOTData: ; 2879e
; 287ab
Link_CopyRandomNumbers: ; 287ab
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
ret z
ld hl, EnemyMonSpecies
call Link_FindFirstNonControlCharacter_AllowZero
@@ -1157,9 +1154,9 @@ Link_CopyRandomNumbers: ; 287ab
ld c, 10
.loop
ld a, [hli]
- cp $fe
+ cp SERIAL_NO_DATA_BYTE
jr z, .loop
- cp $fd
+ cp SERIAL_PREAMBLE_BYTE
jr z, .loop
ld [de], a
inc de
@@ -1173,9 +1170,9 @@ Link_FindFirstNonControlCharacter_SkipZero: ; 287ca
ld a, [hli]
and a
jr z, .loop
- cp $fd
+ cp SERIAL_PREAMBLE_BYTE
jr z, .loop
- cp $fe
+ cp SERIAL_NO_DATA_BYTE
jr z, .loop
dec hl
ret
@@ -1184,9 +1181,9 @@ Link_FindFirstNonControlCharacter_SkipZero: ; 287ca
Link_FindFirstNonControlCharacter_AllowZero: ; 287d8
.loop
ld a, [hli]
- cp $fd
+ cp SERIAL_PREAMBLE_BYTE
jr z, .loop
- cp $fe
+ cp SERIAL_NO_DATA_BYTE
jr z, .loop
dec hl
ret
@@ -1226,7 +1223,7 @@ LinkTrade_OTPartyMenu: ; 28803
ld [wMenuCursorX], a
ln a, 1, 0
ld [w2DMenuCursorOffsets], a
- ld a, $20
+ ld a, MENU_UNUSED_3
ld [w2DMenuFlags1], a
xor a
ld [w2DMenuFlags2], a
@@ -1238,7 +1235,7 @@ LinkTradeOTPartymonMenuLoop: ; 28835
jp z, LinkTradePartiesMenuMasterLoop
bit A_BUTTON_F, a
jr z, .not_a_button
- ld a, $1
+ ld a, INIT_ENEMYOT_LIST
ld [wInitListType], a
callfar InitList
ld hl, OTPartyMon1Species
@@ -1291,7 +1288,7 @@ LinkTrade_PlayerPartyMenu: ; 2888b
ld [wMenuCursorX], a
ln a, 1, 0
ld [w2DMenuCursorOffsets], a
- ld a, $20
+ ld a, MENU_UNUSED_3
ld [w2DMenuFlags1], a
xor a
ld [w2DMenuFlags2], a
@@ -1362,7 +1359,7 @@ Function28926: ; 28926
hlcoord 0, 15
ld b, 1
ld c, 18
- call Predef_LinkTextbox
+ call LinkTextboxAtHL
hlcoord 2, 16
ld de, .String_Stats_Trade
call PlaceString
@@ -1431,7 +1428,7 @@ Function28926: ; 28926
.show_stats
pop af
ld [wMenuCursorY], a
- ld a, $4
+ ld a, INIT_PLAYEROT_LIST
ld [wInitListType], a
callfar InitList
farcall LinkMonStatsScreen
@@ -1471,7 +1468,7 @@ Function28926: ; 28926
hlcoord 0, 12
ld b, 4
ld c, 18
- call Predef_LinkTextbox
+ call LinkTextboxAtHL
farcall Link_WaitBGMap
ld hl, .Text_CantTradeLastMon
bccoord 1, 14
@@ -1485,7 +1482,7 @@ Function28926: ; 28926
ld a, [wd003]
ld hl, OTPartySpecies
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
ld [wd265], a
@@ -1493,7 +1490,7 @@ Function28926: ; 28926
hlcoord 0, 12
ld b, 4
ld c, 18
- call Predef_LinkTextbox
+ call LinkTextboxAtHL
farcall Link_WaitBGMap
ld hl, .Text_Abnormal
bccoord 1, 14
@@ -1503,7 +1500,7 @@ Function28926: ; 28926
hlcoord 0, 12
ld b, 4
ld c, 18
- call Predef_LinkTextbox
+ call LinkTextboxAtHL
hlcoord 1, 14
ld de, String_TooBadTheTradeWasCanceled
call PlaceString
@@ -1590,15 +1587,14 @@ Function28b22: ; 28b22
xor a
ld [rSB], a
ld [hSerialSend], a
- ld a, $1
+ ld a, (0 << rSC_ON) | 1
ld [rSC], a
- ld a, $81
+ ld a, (1 << rSC_ON) | 1
ld [rSC], a
ret
; 28b42
-Function28b42: ; 28b42
-; unreferenced
+Unreferenced_Function28b42: ; 28b42
hlcoord 0, 16
ld a, "┘"
ld bc, 2 * SCREEN_WIDTH
@@ -1647,26 +1643,26 @@ LinkTrade: ; 28b87
ld [wcf57], a
ld [wOtherPlayerLinkAction], a
hlcoord 0, 12
- ld b, $4
- ld c, $12
- call Predef_LinkTextbox
+ ld b, 4
+ ld c, 18
+ call LinkTextboxAtHL
farcall Link_WaitBGMap
ld a, [wd002]
ld hl, PartySpecies
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
ld [wd265], a
call GetPokemonName
ld hl, StringBuffer1
ld de, wd004
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
ld a, [wd003]
ld hl, OTPartySpecies
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
ld [wd265], a
@@ -1678,7 +1674,7 @@ LinkTrade: ; 28b87
hlcoord 10, 7
ld b, 3
ld c, 7
- call Predef_LinkTextbox
+ call LinkTextboxAtHL
ld de, String28eab
hlcoord 12, 8
call PlaceString
@@ -1718,7 +1714,7 @@ LinkTrade: ; 28b87
hlcoord 0, 12
ld b, 4
ld c, 18
- call Predef_LinkTextbox
+ call LinkTextboxAtHL
hlcoord 1, 14
ld de, String_TooBadTheTradeWasCanceled
call PlaceString
@@ -1735,7 +1731,7 @@ LinkTrade: ; 28b87
hlcoord 0, 12
ld b, 4
ld c, 18
- call Predef_LinkTextbox
+ call LinkTextboxAtHL
hlcoord 1, 14
ld de, String_TooBadTheTradeWasCanceled
call PlaceString
@@ -1757,7 +1753,7 @@ LinkTrade: ; 28b87
.asm_28c96
inc c
ld a, c
- cp $6
+ cp PARTY_LENGTH
jr z, .asm_28ca6
push bc
ld bc, MAIL_STRUCT_LENGTH
@@ -1786,7 +1782,7 @@ LinkTrade: ; 28b87
call CopyBytes
ld a, [wd002]
ld hl, PartySpecies
- ld b, $0
+ ld b, 0
ld c, a
add hl, bc
ld a, [hl]
@@ -1826,7 +1822,7 @@ LinkTrade: ; 28b87
call CopyBytes
ld a, [wd003]
ld hl, OTPartySpecies
- ld b, $0
+ ld b, 0
ld c, a
add hl, bc
ld a, [hl]
@@ -1862,7 +1858,7 @@ LinkTrade: ; 28b87
ld a, [wd002]
ld [CurPartyMon], a
ld hl, PartySpecies
- ld b, $0
+ ld b, 0
ld c, a
add hl, bc
ld a, [hl]
@@ -1873,12 +1869,12 @@ LinkTrade: ; 28b87
ld a, [PartyCount]
dec a
ld [CurPartyMon], a
- ld a, $1
+ ld a, TRUE
ld [wForceEvolution], a
ld a, [wd003]
push af
ld hl, OTPartySpecies
- ld b, $0
+ ld b, 0
ld c, a
add hl, bc
ld a, [hl]
@@ -1889,8 +1885,8 @@ LinkTrade: ; 28b87
call LoadFontsBattleExtra
ld b, SCGB_DIPLOMA
call GetSGBLayout
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .player_2
predef TradeAnimation
jr .done_animation
@@ -1903,7 +1899,7 @@ LinkTrade: ; 28b87
ld c, a
ld [CurPartyMon], a
ld hl, OTPartySpecies
- ld d, $0
+ ld d, 0
ld e, a
add hl, de
ld a, [hl]
@@ -1944,7 +1940,7 @@ LinkTrade: ; 28b87
ld a, b
ld [wPlayerLinkAction], a
push bc
- call Function862
+ call Serial_PrintWaitingTextAndSyncAndExchangeNybble
pop bc
ld a, [wLinkMode]
cp LINK_TIMECAPSULE
@@ -1958,14 +1954,14 @@ LinkTrade: ; 28b87
.save
farcall SaveAfterLinkTrade
- farcall TrainerRankings_Trades
+ farcall StubbedTrainerRankings_Trades
farcall BackupMobileEventIndex
ld c, 40
call DelayFrames
hlcoord 0, 12
ld b, 4
ld c, 18
- call Predef_LinkTextbox
+ call LinkTextboxAtHL
hlcoord 1, 14
ld de, String28ebd
call PlaceString
@@ -2002,7 +1998,7 @@ String_TooBadTheTradeWasCanceled: ; 28ece
next "was canceled!@"
-Predef_LinkTextbox: ; 28eef
+LinkTextboxAtHL: ; 28eef
ld d, h
ld e, l
farcall LinkTextbox
@@ -2020,16 +2016,15 @@ SetTradeRoomBGPals: ; 28eff
ret
; 28f09
-Function28f09: ; 28f09
-; unreferenced
+Unreferenced_Function28f09: ; 28f09
hlcoord 0, 0
ld b, 6
ld c, 18
- call Predef_LinkTextbox
+ call LinkTextboxAtHL
hlcoord 0, 8
ld b, 6
ld c, 18
- call Predef_LinkTextbox
+ call LinkTextboxAtHL
farcall PlaceTradePartnerNamesAndParty
ret
; 28f24
@@ -2045,12 +2040,12 @@ Special_CheckTimeCapsuleCompatibility: ; 29bfb
; If any party Pokemon was introduced in the generation 2 games, don't let it in.
ld hl, PartySpecies
- ld b, PARTY_LENGTH ; 6
+ ld b, PARTY_LENGTH
.loop
ld a, [hli]
cp -1
jr z, .checkitem
- cp CHIKORITA ; MEW + 1 ; 151 + 1
+ cp JOHTO_POKEMON
jr nc, .mon_too_new
dec b
jr nz, .loop
@@ -2122,7 +2117,7 @@ Function29c67: ; 29c67
sub b
ld c, a
inc c
- ld b, $0
+ ld b, 0
ld hl, PartyCount
add hl, bc
ld a, [hl]
@@ -2145,28 +2140,28 @@ Special_EnterTimeCapsule: ; 29c7b
ret
; 29c92
-WaitForOtherPlayerToExit: ; 29c92
+Special_WaitForOtherPlayerToExit: ; 29c92
ld c, 3
call DelayFrames
- ld a, -1
- ld [hLinkPlayerNumber], a
+ ld a, CONNECTION_NOT_ESTABLISHED
+ ld [hSerialConnectionStatus], a
xor a
ld [rSB], a
ld [hSerialReceive], a
- ld a, $1
+ ld a, (0 << rSC_ON) | 1
ld [rSC], a
- ld a, $81
+ ld a, (1 << rSC_ON) | 1
ld [rSC], a
ld c, 3
call DelayFrames
xor a
ld [rSB], a
ld [hSerialReceive], a
- ld a, $0
+ ld a, (0 << rSC_ON) | 0
ld [rSC], a
- ld a, $80
+ ld a, (1 << rSC_ON) | 0
ld [rSC], a
- ld c, $3
+ ld c, 3
call DelayFrames
xor a
ld [rSB], a
@@ -2174,8 +2169,8 @@ WaitForOtherPlayerToExit: ; 29c92
ld [rSC], a
ld c, 3
call DelayFrames
- ld a, -1
- ld [hLinkPlayerNumber], a
+ ld a, CONNECTION_NOT_ESTABLISHED
+ ld [hSerialConnectionStatus], a
ld a, [rIF]
push af
xor a
@@ -2212,9 +2207,9 @@ Special_SetBitsForTimeCapsuleRequest: ; 29cfa
ld [rSB], a
xor a
ld [hSerialReceive], a
- ld a, $0
+ ld a, (0 << rSC_ON) | 0
ld [rSC], a
- ld a, $80
+ ld a, (1 << rSC_ON) | 0
ld [rSC], a
xor a ; LINK_TIMECAPSULE - 1
ld [wPlayerLinkAction], a
@@ -2230,9 +2225,9 @@ Special_WaitForLinkedFriend: ; 29d11
ld [rSB], a
xor a
ld [hSerialReceive], a
- ld a, $0
+ ld a, (0 << rSC_ON) | 0
ld [rSC], a
- ld a, $80
+ ld a, (1 << rSC_ON) | 0
ld [rSC], a
call DelayFrame
call DelayFrame
@@ -2244,20 +2239,20 @@ Special_WaitForLinkedFriend: ; 29d11
ld a, $ff
ld [wLinkTimeoutFrames], a
.loop
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr z, .connected
- cp $1
+ cp USING_EXTERNAL_CLOCK
jr z, .connected
- ld a, -1
- ld [hLinkPlayerNumber], a
+ ld a, CONNECTION_NOT_ESTABLISHED
+ ld [hSerialConnectionStatus], a
ld a, $2
ld [rSB], a
xor a
ld [hSerialReceive], a
- ld a, $0
+ ld a, (0 << rSC_ON) | 0
ld [rSC], a
- ld a, $80
+ ld a, (1 << rSC_ON) | 0
ld [rSC], a
ld a, [wLinkTimeoutFrames]
dec a
@@ -2271,9 +2266,9 @@ Special_WaitForLinkedFriend: ; 29d11
.not_done
ld a, $1
ld [rSB], a
- ld a, $1
+ ld a, (0 << rSC_ON) | 1
ld [rSC], a
- ld a, $81
+ ld a, (1 << rSC_ON) | 1
ld [rSC], a
call DelayFrame
jr .loop
@@ -2366,7 +2361,7 @@ Function29dba: ; 29dba
Link_CheckCommunicationError: ; 29e0c
xor a
- ld [hFFCA], a
+ ld [hSerialReceivedNewData], a
ld a, [wLinkTimeoutFrames]
ld h, a
ld a, [wLinkTimeoutFrames + 1]
@@ -2418,7 +2413,7 @@ Link_CheckCommunicationError: ; 29e0c
.ConvertDW: ; 29e53
; [wLinkTimeoutFrames] = ((hl - $100) / 4) + $100
- ; = (hl / 4) + $c0
+ ; = (hl / 4) + $c0
dec h
srl h
rr l
@@ -2436,9 +2431,9 @@ Special_TryQuickSave: ; 29e66
ld a, [wd265]
push af
farcall Link_SaveGame
- ld a, $1
+ ld a, TRUE
jr nc, .return_result
- xor a
+ xor a ; FALSE
.return_result
ld [ScriptVar], a
ld c, 30
@@ -2465,12 +2460,12 @@ Special_CheckBothSelectedSameRoom: ; 29e82
ld [wLinkMode], a
xor a
ld [hVBlank], a
- ld a, $1
+ ld a, TRUE
ld [ScriptVar], a
ret
.fail
- xor a
+ xor a ; FALSE
ld [ScriptVar], a
ret
; 29eaf
@@ -2526,8 +2521,8 @@ Special_FailedLinkToPast: ; 29efa
Link_ResetSerialRegistersAfterLinkClosure: ; 29f04
ld c, 3
call DelayFrames
- ld a, -1
- ld [hLinkPlayerNumber], a
+ ld a, CONNECTION_NOT_ESTABLISHED
+ ld [hSerialConnectionStatus], a
ld a, $2
ld [rSB], a
xor a
@@ -2545,7 +2540,7 @@ Link_EnsureSync: ; 29f17
call DelayFrame
call DelayFrame
.receive_loop
- call Function83b
+ call Serial_ExchangeLinkMenuSelection
ld a, [wOtherPlayerLinkMode]
ld b, a
and $f0
@@ -2566,28 +2561,27 @@ Link_EnsureSync: ; 29f17
; 29f47
Special_CableClubCheckWhichChris: ; 29f47
- ld a, [hLinkPlayerNumber]
- cp $1
- ld a, $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
+ ld a, TRUE
jr z, .yes
- dec a
+ dec a ; FALSE
.yes
ld [ScriptVar], a
ret
; 29f54
-UnusedGen1LinkCommsBorderGFX: ; 29f54
-; unreferenced
+Unreferenced_Gen1LinkCommsBorderGFX: ; 29f54
INCBIN "gfx/trade/unused_gen_1_border_tiles.2bpp"
; 29fe4
-Function29fe4: ; unreferenced
+Unreferenced_Function29fe4:
ld a, BANK(sPartyMail)
call GetSRAMBank
- ld d, $0
+ ld d, FALSE
ld b, CHECK_FLAG
- predef FlagPredef
+ predef SmallFarFlagAction
call CloseSRAM
ld a, c
and a
diff --git a/engine/link_2.asm b/engine/link_2.asm
index 72e5262b3..866126cd2 100644
--- a/engine/link_2.asm
+++ b/engine/link_2.asm
@@ -30,13 +30,14 @@ LinkTextbox2: ; 4d35b
call .PlaceBorder
pop hl
pop bc
+
ld de, AttrMap - TileMap
add hl, de
inc b
inc b
inc c
inc c
- ld a, $7
+ ld a, PAL_BG_TEXT
.row
push bc
push hl
@@ -51,6 +52,7 @@ LinkTextbox2: ; 4d35b
dec b
jr nz, .row
ret
+; 4d37e
.PlaceBorder: ; 4d37e
push hl
@@ -75,12 +77,14 @@ LinkTextbox2: ; 4d35b
add hl, de
dec b
jr nz, .loop
+
ld a, "┐"
ld [hli], a
ld a, "│"
call .PlaceRow
ld [hl], "└"
ret
+; 4d3ab
.PlaceRow: ; 4d3ab
ld d, c
diff --git a/engine/link_trade.asm b/engine/link_trade.asm
index f85403a29..504dc6d95 100755
--- a/engine/link_trade.asm
+++ b/engine/link_trade.asm
@@ -48,7 +48,7 @@ _LinkTextbox: ; 16d61d
ld l, e
push bc
push hl
- call .draw_border
+ call .PlaceBorder
pop hl
pop bc
@@ -58,7 +58,7 @@ _LinkTextbox: ; 16d61d
inc b
inc c
inc c
- ld a, $7
+ ld a, PAL_BG_TEXT
.row
push bc
push hl
@@ -75,12 +75,12 @@ _LinkTextbox: ; 16d61d
ret
; 16d640
-.draw_border ; 16d640
+.PlaceBorder ; 16d640
push hl
ld a, $30
ld [hli], a
inc a
- call .fill_row
+ call .PlaceRow
inc a
ld [hl], a
pop hl
@@ -91,7 +91,7 @@ _LinkTextbox: ; 16d61d
ld a, $33
ld [hli], a
ld a, " "
- call .fill_row
+ call .PlaceRow
ld [hl], $34
pop hl
ld de, SCREEN_WIDTH
@@ -102,17 +102,17 @@ _LinkTextbox: ; 16d61d
ld a, $35
ld [hli], a
ld a, $36
- call .fill_row
+ call .PlaceRow
ld [hl], $37
ret
; 16d66d
-.fill_row ; 16d66d
+.PlaceRow ; 16d66d
ld d, c
-.loop4
+.row_loop
ld [hli], a
dec d
- jr nz, .loop4
+ jr nz, .row_loop
ret
; 16d673
@@ -181,7 +181,7 @@ Function16d6e1: ; 16d6e1
hlcoord 4, 10
ld b, 1
ld c, 10
- predef Predef_LinkTextbox
+ predef LinkTextboxAtHL
hlcoord 5, 11
ld de, .Waiting
call PlaceString
@@ -283,7 +283,7 @@ LinkTradeMenu: ; 16d70c
ld [hl], a
push hl
push bc
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
add hl, bc
ld [hl], a
pop bc
@@ -335,7 +335,7 @@ LinkTradeMenu: ; 16d70c
ld [hl], $1f
push hl
push bc
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
add hl, bc
ld [hl], $1f
pop bc
diff --git a/engine/load_font.asm b/engine/load_font.asm
new file mode 100644
index 000000000..345fa6ff6
--- /dev/null
+++ b/engine/load_font.asm
@@ -0,0 +1,156 @@
+INCLUDE "gfx/font.asm"
+
+; This and the following two functions are unreferenced.
+; Debug, perhaps?
+Unreferenced_fb434:
+ db 0
+
+Unreferenced_Functionfb435: ; 4b435
+ ld a, [Unreferenced_fb434]
+ and a
+ jp nz, Get1bpp_2
+ jp Get1bpp
+; fb43f
+
+Unreferenced_Functionfb43f: ; fb43f
+ ld a, [Unreferenced_fb434]
+ and a
+ jp nz, Get2bpp_2
+ jp Get2bpp
+; End unreferenced block
+; fb449
+
+_LoadStandardFont:: ; fb449
+ ld de, Font
+ ld hl, vTiles1
+ lb bc, BANK(Font), 128 ; "A" to "9"
+ ld a, [rLCDC]
+ bit rLCDC_ENABLE, a
+ jp z, Copy1bpp
+
+ ld de, Font
+ ld hl, vTiles1
+ lb bc, BANK(Font), 32 ; "A" to "]"
+ call Get1bpp_2
+ ld de, Font + 32 * LEN_1BPP_TILE
+ ld hl, vTiles1 tile $20
+ lb bc, BANK(Font), 32 ; "a" to $bf
+ call Get1bpp_2
+ ld de, Font + 64 * LEN_1BPP_TILE
+ ld hl, vTiles1 tile $40
+ lb bc, BANK(Font), 32 ; "Ä" to "←"
+ call Get1bpp_2
+ ld de, Font + 96 * LEN_1BPP_TILE
+ ld hl, vTiles1 tile $60
+ lb bc, BANK(Font), 32 ; "'" to "9"
+ call Get1bpp_2
+ ret
+; fb48a
+
+_LoadFontsExtra1:: ; fb48a
+ ld de, FontsExtra_SolidBlackGFX
+ ld hl, vTiles2 tile "■" ; $60
+ lb bc, BANK(FontsExtra_SolidBlackGFX), 1
+ call Get1bpp_2
+ ld de, PokegearPhoneIconGFX
+ ld hl, vTiles2 tile "☎" ; $62
+ lb bc, BANK(PokegearPhoneIconGFX), 1
+ call Get2bpp_2
+ ld de, FontExtra + 3 tiles ; "<BOLD_D>"
+ ld hl, vTiles2 tile "<BOLD_D>"
+ lb bc, BANK(FontExtra), 22 ; "<BOLD_D>" to "ぉ"
+ call Get2bpp_2
+ jr LoadFrame
+; fb4b0
+
+_LoadFontsExtra2:: ; fb4b0
+ ld de, FontsExtra2_UpArrowGFX
+ ld hl, vTiles2 tile "▲" ; $61
+ ld b, BANK(FontsExtra2_UpArrowGFX)
+ ld c, 1
+ call Get2bpp_2
+ ret
+; fb4be
+
+_LoadFontsBattleExtra:: ; fb4be
+ ld de, FontBattleExtra
+ ld hl, vTiles2 tile $60
+ lb bc, BANK(FontBattleExtra), 25
+ call Get2bpp_2
+ jr LoadFrame
+; fb4cc
+
+LoadFrame: ; fb4cc
+ ld a, [TextBoxFrame]
+ maskbits NUM_FRAMES
+ ld bc, 6 * LEN_1BPP_TILE
+ ld hl, Frames
+ call AddNTimes
+ ld d, h
+ ld e, l
+ ld hl, vTiles2 tile "┌" ; $79
+ lb bc, BANK(Frames), 6 ; "┌" to "┘"
+ call Get1bpp_2
+ ld hl, vTiles2 tile " " ; $7f
+ ld de, TextBoxSpaceGFX
+ lb bc, BANK(TextBoxSpaceGFX), 1
+ call Get1bpp_2
+ ret
+; fb4f2
+
+LoadBattleFontsHPBar: ; fb4f2
+ ld de, FontBattleExtra
+ ld hl, vTiles2 tile $60
+ lb bc, BANK(FontBattleExtra), 12
+ call Get2bpp_2
+ ld hl, vTiles2 tile $70
+ ld de, FontBattleExtra + 16 tiles ; "<DO>"
+ lb bc, BANK(FontBattleExtra), 3 ; "<DO>" to "『"
+ call Get2bpp_2
+ call LoadFrame
+
+LoadHPBar: ; fb50d
+ ld de, EnemyHPBarBorderGFX
+ ld hl, vTiles2 tile $6c
+ lb bc, BANK(EnemyHPBarBorderGFX), 4
+ call Get1bpp_2
+ ld de, HPExpBarBorderGFX
+ ld hl, vTiles2 tile $73
+ lb bc, BANK(HPExpBarBorderGFX), 6
+ call Get1bpp_2
+ ld de, ExpBarGFX
+ ld hl, vTiles2 tile $55
+ lb bc, BANK(ExpBarGFX), 9
+ call Get2bpp_2
+ ld de, MobilePhoneTilesGFX + 7 tiles ; mobile phone icon
+ ld hl, vTiles2 tile $5e
+ lb bc, BANK(MobilePhoneTilesGFX), 2
+ call Get2bpp_2
+ ret
+; fb53e
+
+StatsScreen_LoadFont: ; fb53e
+ call _LoadFontsBattleExtra
+ ld de, EnemyHPBarBorderGFX
+ ld hl, vTiles2 tile $6c
+ lb bc, BANK(EnemyHPBarBorderGFX), 4
+ call Get1bpp_2
+ ld de, HPExpBarBorderGFX
+ ld hl, vTiles2 tile $78
+ lb bc, BANK(HPExpBarBorderGFX), 1
+ call Get1bpp_2
+ ld de, HPExpBarBorderGFX + 3 * LEN_1BPP_TILE
+ ld hl, vTiles2 tile $76
+ lb bc, BANK(HPExpBarBorderGFX), 2
+ call Get1bpp_2
+ ld de, ExpBarGFX
+ ld hl, vTiles2 tile $55
+ lb bc, BANK(ExpBarGFX), 8
+ call Get2bpp_2
+LoadStatsScreenPageTilesGFX: ; fb571
+ ld de, StatsScreenPageTilesGFX
+ ld hl, vTiles2 tile $31
+ lb bc, BANK(StatsScreenPageTilesGFX), 17
+ call Get2bpp_2
+ ret
+; fb57e
diff --git a/engine/load_pics.asm b/engine/load_pics.asm
new file mode 100755
index 000000000..5d3becf42
--- /dev/null
+++ b/engine/load_pics.asm
@@ -0,0 +1,494 @@
+GetUnownLetter: ; 51040
+; Return Unown letter in UnownLetter based on DVs at hl
+
+; Take the middle 2 bits of each DV and place them in order:
+; atk def spd spc
+; .ww..xx. .yy..zz.
+
+ ; atk
+ ld a, [hl]
+ and %01100000
+ sla a
+ ld b, a
+ ; def
+ ld a, [hli]
+ and %00000110
+ swap a
+ srl a
+ or b
+ ld b, a
+
+ ; spd
+ ld a, [hl]
+ and %01100000
+ swap a
+ sla a
+ or b
+ ld b, a
+ ; spc
+ ld a, [hl]
+ and %00000110
+ srl a
+ or b
+
+; Divide by 10 to get 0-25
+ ld [hDividend + 3], a
+ xor a
+ ld [hDividend], a
+ ld [hDividend + 1], a
+ ld [hDividend + 2], a
+ ld a, $ff / NUM_UNOWN + 1
+ ld [hDivisor], a
+ ld b, 4
+ call Divide
+
+; Increment to get 1-26
+ ld a, [hQuotient + 2]
+ inc a
+ ld [UnownLetter], a
+ ret
+
+GetMonFrontpic: ; 51077
+ ld a, [CurPartySpecies]
+ ld [CurSpecies], a
+ call IsAPokemon
+ ret c
+ ld a, [rSVBK]
+ push af
+ call _GetFrontpic
+ pop af
+ ld [rSVBK], a
+ ret
+
+GetAnimatedFrontpic: ; 5108b
+ ld a, [CurPartySpecies]
+ ld [CurSpecies], a
+ call IsAPokemon
+ ret c
+ ld a, [rSVBK]
+ push af
+ xor a
+ ld [hBGMapMode], a
+ call _GetFrontpic
+ call GetAnimatedEnemyFrontpic
+ pop af
+ ld [rSVBK], a
+ ret
+
+_GetFrontpic: ; 510a5
+ push de
+ call GetBaseData
+ ld a, [BasePicSize]
+ and $f
+ ld b, a
+ push bc
+ call GetFrontpicPointer
+ ld a, BANK(wDecompressEnemyFrontpic)
+ ld [rSVBK], a
+ ld a, b
+ ld de, wDecompressEnemyFrontpic
+ call FarDecompress
+ pop bc
+ ld hl, wDecompressScratch
+ ld de, wDecompressEnemyFrontpic
+ call PadFrontpic
+ pop hl
+ push hl
+ ld de, wDecompressScratch
+ ld c, 7 * 7
+ ld a, [hROMBank]
+ ld b, a
+ call Get2bpp
+ pop hl
+ ret
+
+GetFrontpicPointer: ; 510d7
+GLOBAL PokemonPicPointers, UnownPicPointers
+
+ ld a, [CurPartySpecies]
+ cp UNOWN
+ jr z, .unown
+ ld a, [CurPartySpecies]
+ ld d, BANK(PokemonPicPointers)
+ jr .ok
+
+.unown
+ ld a, [UnownLetter]
+ ld d, BANK(UnownPicPointers)
+
+.ok
+ ld hl, PokemonPicPointers ; UnownPicPointers
+ dec a
+ ld bc, 6
+ call AddNTimes
+ ld a, d
+ call GetFarByte
+ call FixPicBank
+ push af
+ inc hl
+ ld a, d
+ call GetFarHalfword
+ pop bc
+ ret
+
+GetAnimatedEnemyFrontpic: ; 51103
+ ld a, BANK(vTiles3)
+ ld [rVBK], a
+ push hl
+ ld de, wDecompressScratch
+ ld c, 7 * 7
+ ld a, [hROMBank]
+ ld b, a
+ call Get2bpp
+ pop hl
+ ld de, 7 * 7 tiles
+ add hl, de
+ push hl
+ ld a, BANK(BasePicSize)
+ ld hl, BasePicSize
+ call GetFarWRAMByte
+ pop hl
+ and $f
+ ld de, wDecompressEnemyFrontpic + 5 * 5 tiles
+ ld c, 5 * 5
+ cp 5
+ jr z, .got_dims
+ ld de, wDecompressEnemyFrontpic + 6 * 6 tiles
+ ld c, 6 * 6
+ cp 6
+ jr z, .got_dims
+ ld de, wDecompressEnemyFrontpic + 7 * 7 tiles
+ ld c, 7 * 7
+.got_dims
+
+ push hl
+ push bc
+ call LoadFrontpicTiles
+ pop bc
+ pop hl
+ ld de, wDecompressScratch
+ ld a, [hROMBank]
+ ld b, a
+ call Get2bpp
+ xor a
+ ld [rVBK], a
+ ret
+
+LoadFrontpicTiles: ; 5114f
+ ld hl, wDecompressScratch
+ swap c
+ ld a, c
+ and $f
+ ld b, a
+ ld a, c
+ and $f0
+ ld c, a
+ push bc
+ call LoadOrientedFrontpic
+ pop bc
+.loop
+ push bc
+ ld c, 0
+ call LoadOrientedFrontpic
+ pop bc
+ dec b
+ jr nz, .loop
+ ret
+
+GetMonBackpic: ; 5116c
+ ld a, [CurPartySpecies]
+ call IsAPokemon
+ ret c
+
+ ld a, [CurPartySpecies]
+ ld b, a
+ ld a, [UnownLetter]
+ ld c, a
+ ld a, [rSVBK]
+ push af
+ ld a, BANK(wDecompressScratch)
+ ld [rSVBK], a
+ push de
+
+ ; These are assumed to be at the same address in their respective banks.
+ GLOBAL PokemonPicPointers, UnownPicPointers
+ ld hl, PokemonPicPointers ; UnownPicPointers
+ ld a, b
+ ld d, BANK(PokemonPicPointers)
+ cp UNOWN
+ jr nz, .ok
+ ld a, c
+ ld d, BANK(UnownPicPointers)
+.ok
+ dec a
+ ld bc, 6
+ call AddNTimes
+ ld bc, 3
+ add hl, bc
+ ld a, d
+ call GetFarByte
+ call FixPicBank
+ push af
+ inc hl
+ ld a, d
+ call GetFarHalfword
+ ld de, wDecompressScratch
+ pop af
+ call FarDecompress
+ ld hl, wDecompressScratch
+ ld c, 6 * 6
+ call FixBackpicAlignment
+ pop hl
+ ld de, wDecompressScratch
+ ld a, [hROMBank]
+ ld b, a
+ call Get2bpp
+ pop af
+ ld [rSVBK], a
+ ret
+
+FixPicBank: ; 511c5
+; This is a thing for some reason.
+
+PICS_FIX EQU $36
+GLOBAL PICS_FIX
+
+ push hl
+ push bc
+ sub BANK(Pics_1) - PICS_FIX
+ ld c, a
+ ld b, 0
+ ld hl, .PicsBanks
+ add hl, bc
+ ld a, [hl]
+ pop bc
+ pop hl
+ ret
+
+.PicsBanks: ; 511d4
+ db BANK(Pics_1) + 0
+ db BANK(Pics_1) + 1
+ db BANK(Pics_1) + 2
+ db BANK(Pics_1) + 3
+ db BANK(Pics_1) + 4
+ db BANK(Pics_1) + 5
+ db BANK(Pics_1) + 6
+ db BANK(Pics_1) + 7
+ db BANK(Pics_1) + 8
+ db BANK(Pics_1) + 9
+ db BANK(Pics_1) + 10
+ db BANK(Pics_1) + 11
+ db BANK(Pics_1) + 12
+ db BANK(Pics_1) + 13
+ db BANK(Pics_1) + 14
+ db BANK(Pics_1) + 15
+ db BANK(Pics_1) + 16
+ db BANK(Pics_1) + 17
+ db BANK(Pics_1) + 18
+ db BANK(Pics_1) + 19
+ db BANK(Pics_1) + 20
+ db BANK(Pics_1) + 21
+ db BANK(Pics_1) + 22
+ db BANK(Pics_1) + 23
+
+Function511ec: ; 511ec
+ ld a, c
+ push de
+ ld hl, PokemonPicPointers
+ dec a
+ ld bc, 6
+ call AddNTimes
+ ld a, BANK(PokemonPicPointers)
+ call GetFarByte
+ call FixPicBank
+ push af
+ inc hl
+ ld a, BANK(PokemonPicPointers)
+ call GetFarHalfword
+ pop af
+ pop de
+ call FarDecompress
+ ret
+
+GetTrainerPic: ; 5120d
+ ld a, [TrainerClass]
+ and a
+ ret z
+ cp NUM_TRAINER_CLASSES
+ ret nc
+ call WaitBGMap
+ xor a
+ ld [hBGMapMode], a
+ ld hl, TrainerPicPointers
+ ld a, [TrainerClass]
+ dec a
+ ld bc, 3
+ call AddNTimes
+ ld a, [rSVBK]
+ push af
+ ld a, BANK(wDecompressScratch)
+ ld [rSVBK], a
+ push de
+ ld a, BANK(TrainerPicPointers)
+ call GetFarByte
+ call FixPicBank
+ push af
+ inc hl
+ ld a, BANK(TrainerPicPointers)
+ call GetFarHalfword
+ pop af
+ ld de, wDecompressScratch
+ call FarDecompress
+ pop hl
+ ld de, wDecompressScratch
+ ld c, 7 * 7
+ ld a, [hROMBank]
+ ld b, a
+ call Get2bpp
+ pop af
+ ld [rSVBK], a
+ call WaitBGMap
+ ld a, $1
+ ld [hBGMapMode], a
+ ret
+
+DecompressGet2bpp: ; 5125d
+; Decompress lz data from b:hl to scratch space at 6:d000, then copy it to address de.
+
+ ld a, [rSVBK]
+ push af
+ ld a, BANK(wDecompressScratch)
+ ld [rSVBK], a
+
+ push de
+ push bc
+ ld a, b
+ ld de, wDecompressScratch
+ call FarDecompress
+ pop bc
+ ld de, wDecompressScratch
+ pop hl
+ ld a, [hROMBank]
+ ld b, a
+ call Get2bpp
+
+ pop af
+ ld [rSVBK], a
+ ret
+
+FixBackpicAlignment: ; 5127c
+ push de
+ push bc
+ ld a, [wBoxAlignment]
+ and a
+ jr z, .keep_dims
+ ld a, c
+ cp 7 * 7
+ ld de, 7 * 7 tiles
+ jr z, .got_dims
+ cp 6 * 6
+ ld de, 6 * 6 tiles
+ jr z, .got_dims
+ ld de, 5 * 5 tiles
+
+.got_dims
+ ld a, [hl]
+ ld b, 0
+ ld c, 8
+.loop
+ rra
+ rl b
+ dec c
+ jr nz, .loop
+ ld a, b
+ ld [hli], a
+ dec de
+ ld a, e
+ or d
+ jr nz, .got_dims
+
+.keep_dims
+ pop bc
+ pop de
+ ret
+
+PadFrontpic: ; 512ab
+; pads frontpic to fill 7x7 box
+ ld a, b
+ cp 6
+ jr z, .six
+ cp 5
+ jr z, .five
+
+.seven_loop
+ ld c, $70
+ call LoadOrientedFrontpic
+ dec b
+ jr nz, .seven_loop
+ ret
+
+.six
+ ld c, $70
+ xor a
+ call .Fill
+.six_loop
+ ld c, $10
+ xor a
+ call .Fill
+ ld c, $60
+ call LoadOrientedFrontpic
+ dec b
+ jr nz, .six_loop
+ ret
+
+.five
+ ld c, $70
+ xor a
+ call .Fill
+.five_loop
+ ld c, $20
+ xor a
+ call .Fill
+ ld c, $50
+ call LoadOrientedFrontpic
+ dec b
+ jr nz, .five_loop
+ ld c, $70
+ xor a
+ call .Fill
+ ret
+
+.Fill:
+ ld [hli], a
+ dec c
+ jr nz, .Fill
+ ret
+
+LoadOrientedFrontpic: ; 512f2
+ ld a, [wBoxAlignment]
+ and a
+ jr nz, .x_flip
+.left_loop
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec c
+ jr nz, .left_loop
+ ret
+
+.x_flip
+ push bc
+.right_loop
+ ld a, [de]
+ inc de
+ ld b, a
+ xor a
+rept 8
+ rr b
+ rla
+endr
+ ld [hli], a
+ dec c
+ jr nz, .right_loop
+ pop bc
+ ret
diff --git a/engine/mail.asm b/engine/mail.asm
index 0335a6dfe..68b16fd10 100755
--- a/engine/mail.asm
+++ b/engine/mail.asm
@@ -128,7 +128,7 @@ CheckPokeItem:: ; 44654
push bc
push de
farcall SelectMonFromParty
- ld a, $2
+ ld a, POKEMAIL_REFUSED
jr c, .pop_return
ld a, [CurPartyMon]
@@ -137,7 +137,7 @@ CheckPokeItem:: ; 44654
call AddNTimes
ld d, [hl]
farcall ItemIsMail
- ld a, $3
+ ld a, POKEMAIL_NO_MAIL
jr nc, .pop_return
ld a, BANK(sPartyMail)
@@ -162,7 +162,7 @@ CheckPokeItem:: ; 44654
cp "@"
jr z, .done
cp c
- ld a, $0
+ ld a, POKEMAIL_WRONG_MAIL
jr nz, .close_sram_return
inc hl
inc de
@@ -173,12 +173,12 @@ CheckPokeItem:: ; 44654
.done
farcall CheckCurPartyMonFainted
- ld a, $4
+ ld a, POKEMAIL_LAST_MON
jr c, .close_sram_return
xor a
ld [wPokemonWithdrawDepositParameter], a
farcall RemoveMonFromPartyOrBox
- ld a, $1
+ ld a, POKEMAIL_CORRECT
.close_sram_return
call CloseSRAM
@@ -558,14 +558,13 @@ MailboxPC: ; 0x44806
ret
.TopMenuDataHeader: ; 0x4494c
- db %01000000 ; flags
- db 1, 8 ; start coords
- db 10, 18 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 8, 1, SCREEN_WIDTH - 2, 10
dw .TopMenuData2
db 1 ; default option
.TopMenuData2:
- db %00010000 ; flags
+ db SCROLLINGMENU_DISPLAY_ARROWS ; flags
db 4, 0 ; rows/columns?
db 1 ; horizontal spacing?
dbw 0, wMailboxCount ; text pointer
@@ -574,14 +573,13 @@ MailboxPC: ; 0x44806
dba NULL
.SubMenuDataHeader: ; 0x44964
- db %01000000 ; flags
- db 0, 0 ; start coords
- db 9, 13 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, 13, 9
dw .SubMenuData2
db 1 ; default option
.SubMenuData2:
- db %10000000 ; flags
+ db STATICMENU_CURSOR ; flags
db 4 ; items
db "READ MAIL@"
db "PUT IN PACK@"
diff --git a/engine/mail_2.asm b/engine/mail_2.asm
index d66bbbbd7..4450063a4 100755
--- a/engine/mail_2.asm
+++ b/engine/mail_2.asm
@@ -69,7 +69,7 @@ ReadAnyMail: ; b9237
ld h, d
ld l, e
push hl
- ld a, $0
+ ld a, BANK(sPartyMail)
call GetSRAMBank
ld de, sPartyMon1MailAuthorID - sPartyMon1Mail
add hl, de
@@ -725,8 +725,7 @@ MailGFX_PlaceMessage: ; b9803
jp PlaceString
; b984e
-Functionb984e: ; b984e
-; XXX
+Unreferenced_Functionb984e: ; b984e
.loop
ld a, [hl]
xor $ff
diff --git a/engine/main_menu.asm b/engine/main_menu.asm
index cbd516cd7..f82c6072a 100755
--- a/engine/main_menu.asm
+++ b/engine/main_menu.asm
@@ -30,15 +30,14 @@ MainMenu: ; 49cdc
; 49d14
.MenuDataHeader: ; 49d14
- db $40 ; flags
- db 00, 00 ; start coords
- db 07, 16 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, 16, 7
dw .MenuData2
db 1 ; default option
; 49d1c
.MenuData2: ; 49d1c
- db $80 ; flags
+ db STATICMENU_CURSOR ; flags
db 0 ; items
dw MainMenuItems
dw PlaceMenuStrings
@@ -279,7 +278,7 @@ MainMenu_PrintCurrentTimeAndDay: ; 49e09
ret
.min
-; unreferenced
+; unused
db "min.@"
; 49e75
diff --git a/engine/map_objects.asm b/engine/map_objects.asm
index fe3c13a13..00ce599e3 100644
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -1,6 +1,6 @@
-INCLUDE "data/facings.asm"
+INCLUDE "data/sprites/facings.asm"
-INCLUDE "data/map_objects.asm"
+INCLUDE "data/sprites/map_objects.asm"
; 4357
@@ -392,6 +392,7 @@ StepVectors: ; 4700
db -4, 0, 4, 4
db 4, 0, 4, 4
; 4730
+
GetStepVectorSign: ; 4730
add a
ret z ; 0 or 128
@@ -400,6 +401,7 @@ GetStepVectorSign: ; 4730
ld a, -1
ret ; 129 - 255
; 4738
+
UpdatePlayerStep: ; 4738
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
@@ -418,8 +420,7 @@ UpdatePlayerStep: ; 4738
ret
; 4759
-Function4759: ; 4759
-; unreferenced
+Unreferenced_Function4759: ; 4759
push bc
ld e, a
ld d, 0
@@ -892,7 +893,7 @@ MapObjectMovementPattern: ; 47dd
ld hl, OBJECT_DIRECTION_WALKING
add hl, de
ld a, [hl]
- and 3
+ maskbits NUM_DIRECTIONS
ld d, 1 * 8 + 6
cp DOWN
jr z, .ok_13
@@ -1571,7 +1572,7 @@ StepType05: ; 4e0c
ld [hl], a
call IncrementObjectStructField1c
StepType04: ; 4e21
- call MobileFn_4fb2
+ call Stubbed_Function4fb2
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld [hl], STANDING
@@ -1579,7 +1580,7 @@ StepType04: ; 4e21
; 4e2b
NPCStep: ; 4e2b
- call MobileFn_4fb2
+ call Stubbed_Function4fb2
call AddStepVector
ld hl, OBJECT_STEP_DURATION
add hl, bc
@@ -1842,7 +1843,8 @@ SkyfallTop: ; 4f83
ret
; 4fb2
-MobileFn_4fb2: mobile
+Stubbed_Function4fb2:
+ ret
ld hl, OBJECT_1D
add hl, bc
inc [hl]
@@ -2087,6 +2089,7 @@ SpawnShadow: ; 5529
; vtile, palette, movement
db $00, PAL_OW_SILVER, SPRITEMOVEDATA_SHADOW
; 5538
+
SpawnStrengthBoulderDust: ; 5538
push bc
ld de, .BoulderDustObject
@@ -2098,6 +2101,7 @@ SpawnStrengthBoulderDust: ; 5538
.BoulderDustObject:
db $00, PAL_OW_SILVER, SPRITEMOVEDATA_BOULDERDUST
; 5547
+
SpawnEmote: ; 5547
push bc
ld de, .EmoteObject
@@ -2109,6 +2113,7 @@ SpawnEmote: ; 5547
.EmoteObject:
db $00, PAL_OW_SILVER, SPRITEMOVEDATA_EMOTE
; 5556
+
ShakeGrass: ; 5556
push bc
ld de, .data_5562
@@ -2120,6 +2125,7 @@ ShakeGrass: ; 5556
.data_5562
db $00, PAL_OW_TREE, SPRITEMOVEDATA_GRASS
; 5565
+
ShakeScreen: ; 5565
push bc
push af
@@ -2357,7 +2363,7 @@ Function56a3: ; 56a3
cp d
jr z, .equal_x
jr nc, .nope
- add $b
+ add MAPOBJECT_SCREEN_WIDTH - 1
cp d
jr c, .nope
.equal_x
@@ -2365,7 +2371,7 @@ Function56a3: ; 56a3
cp e
jr z, .equal_y
jr nc, .nope
- add $a
+ add MAPOBJECT_SCREEN_HEIGHT - 1
cp e
jr c, .nope
.equal_y
@@ -2404,7 +2410,7 @@ Function56cd: ; 56cd
srl a
cp SCREEN_WIDTH
jr c, .ok3
- sub $20
+ sub BG_MAP_WIDTH
.ok3
ld [hUsedSpriteIndex], a
ld a, [wPlayerBGMapOffsetY]
@@ -2431,9 +2437,9 @@ Function56cd: ; 56cd
srl a
srl a
srl a
- cp $12
+ cp SCREEN_HEIGHT
jr c, .ok6
- sub $20
+ sub BG_MAP_HEIGHT
.ok6
ld [hUsedSpriteTile], a
ld hl, OBJECT_PALETTE
@@ -2455,21 +2461,23 @@ Function56cd: ; 56cd
ld a, [hUsedSpriteTile]
add e
dec a
- cp $12
+ cp SCREEN_HEIGHT
jr nc, .ok9
ld b, a
.next
ld a, [hUsedSpriteIndex]
add d
dec a
- cp $14
+ cp SCREEN_WIDTH
jr nc, .ok8
ld c, a
push bc
call Coord2Tile
pop bc
+; NPCs disappear if standing on tile $60-$7f (or $e0-$ff),
+; since those IDs are for text characters and textbox frames.
ld a, [hl]
- cp $60
+ cp FIRST_REGULAR_TEXT_CHAR
jr nc, .nope
.ok8
dec d
@@ -2793,6 +2801,7 @@ Function5903: ; 5903
db SPRITEMOVEDATA_STANDING_LEFT
db SPRITEMOVEDATA_STANDING_RIGHT
; 5920
+
_UpdateSprites:: ; 5920
ld a, [VramState]
bit 0, a
@@ -2814,18 +2823,18 @@ _UpdateSprites:: ; 5920
bit 1, a
ld b, LOW(SpritesEnd)
jr z, .ok
- ld b, 28 * 4
+ ld b, 28 * SPRITEOAMSTRUCT_LENGTH
.ok
ld a, [hUsedSpriteIndex]
cp b
ret nc
ld l, a
ld h, HIGH(Sprites)
- ld de, 4
+ ld de, SPRITEOAMSTRUCT_LENGTH
ld a, b
- ld c, SCREEN_HEIGHT_PX + 16
+ ld c, SCREEN_HEIGHT_PX + 2 * TILE_WIDTH
.loop
- ld [hl], c
+ ld [hl], c ; y
add hl, de
cp l
jr nz, .loop
@@ -2873,10 +2882,12 @@ ApplyBGMapAnchorToObjects: ; 5958
ret
; 5991
-InitSprites: ; 5991
+
PRIORITY_LOW EQU $10
PRIORITY_NORM EQU $20
PRIORITY_HIGH EQU $30
+
+InitSprites: ; 5991
call .DeterminePriorities
ld c, PRIORITY_HIGH
call .InitSpritesByPriority
@@ -3042,12 +3053,12 @@ PRIORITY_HIGH EQU $30
ld a, [hFFC0]
add [hl]
inc hl
- ld [bc], a
+ ld [bc], a ; y
inc c
ld a, [hFFBF]
add [hl]
inc hl
- ld [bc], a
+ ld [bc], a ; x
inc c
ld e, [hl]
inc hl
@@ -3058,7 +3069,7 @@ PRIORITY_HIGH EQU $30
.nope1
add [hl]
inc hl
- ld [bc], a
+ ld [bc], a ; tile id
inc c
ld a, e
bit 1, a
@@ -3066,9 +3077,9 @@ PRIORITY_HIGH EQU $30
ld a, [hFFC2]
or e
.nope2
- and %11110000
+ and OBP_NUM | X_FLIP | Y_FLIP | PRIORITY
or d
- ld [bc], a
+ ld [bc], a ; attributes
inc c
ld a, [hUsedSpriteTile]
dec a
diff --git a/engine/map_setup.asm b/engine/map_setup.asm
index 078e6a2fd..b3905b71e 100644
--- a/engine/map_setup.asm
+++ b/engine/map_setup.asm
@@ -79,7 +79,7 @@ MapSetupCommands: ; 15440
dba LoadGraphics ; 0e
dba LoadTileset ; 0f
dba LoadMapTimeOfDay ; 10
- dba LoadMapPalettes ; 11
+ dba Special_LoadMapPalettes ; 11
dba LoadWildMonData ; 12
dba RefreshMapSprites ; 13
dba HandleNewMap ; 14
@@ -91,8 +91,8 @@ MapSetupCommands: ; 15440
dba LoadMapAttributes ; 1a
dba LoadMapAttributes_SkipPeople ; 1b
dba ClearBGPalettes ; 1c
- dba FadeOutPalettes ; 1d
- dba FadeInPalettes ; 1e
+ dba Special_FadeOutPalettes ; 1d
+ dba Special_FadeInPalettes ; 1e
dba GetCoordOfUpperLeftCorner ; 1f
dba RestoreFacingAfterWarp ; 20
dba SpawnInFacingDown ; 21
@@ -137,7 +137,7 @@ LoadObjectsRunCallback_02: ; 154d7
ret
; 154ea (5:54ea)
-; unreferenced
+; unused
ret
; 154eb
diff --git a/engine/mapgroup_roofs.asm b/engine/mapgroup_roofs.asm
new file mode 100644
index 000000000..2cd734234
--- /dev/null
+++ b/engine/mapgroup_roofs.asm
@@ -0,0 +1,20 @@
+LoadMapGroupRoof:: ; 1c000
+ ld a, [MapGroup]
+ ld e, a
+ ld d, 0
+ ld hl, MapGroupRoofs
+ add hl, de
+ ld a, [hl]
+ cp -1
+ ret z
+ ld hl, Roofs
+ ld bc, 9 tiles
+ call AddNTimes
+ ld de, vTiles2 tile $0a
+ ld bc, 9 tiles
+ call CopyBytes
+ ret
+; 1c021
+
+
+INCLUDE "data/maps/roofs.asm"
diff --git a/engine/mart.asm b/engine/mart.asm
index 4a8d9e17b..d4c0b623b 100755
--- a/engine/mart.asm
+++ b/engine/mart.asm
@@ -443,7 +443,7 @@ GetMartDialogGroup: ; 15ca3
BuyMenuLoop: ; 15cef
- farcall PlaceMoneyTopRight
+ farcall Special_PlaceMoneyTopRight
call UpdateSprites
ld hl, MenuDataHeader_Buy
call CopyMenuDataHeader
@@ -617,15 +617,14 @@ Text_Mart_CostsThisMuch: ; 0x15e13
; 0x15e18
MenuDataHeader_Buy: ; 0x15e18
- db $40 ; flags
- db 03, 01 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 1, 3, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .menudata2
db 1 ; default option
; 0x15e20
.menudata2 ; 0x15e20
- db $30 ; pointers
+ db SCROLLINGMENU_DISPLAY_ARROWS | SCROLLINGMENU_ENABLE_FUNCTION3 ; flags
db 4, 8 ; rows, columns
db 1 ; horizontal spacing
dbw 0, CurMart
@@ -785,7 +784,7 @@ SellMenu: ; 15eb3
farcall DepositSellInitPackBuffers
.loop
farcall DepositSellPack
- ld a, [wcf66]
+ ld a, [wPackUsedItem]
and a
jp z, .quit
call .TryToSellItem
@@ -797,7 +796,7 @@ SellMenu: ; 15eb3
ret
; 15ed3
-.NothingToSell: ; unreferenced
+.Unreferenced_NothingToSell:
ld hl, .NothingToSellText
call MenuTextBoxBackup
and a
@@ -892,8 +891,8 @@ Text_Mart_ICanPayThisMuch: ; 0x15f78
db "@"
; 0x15f7d
-DummyString ; 15f7d
- db "!ダミー!@"
+.UnusedString15f7d: ; 15f7d
+ db "!ダミー!@"
Text_Mart_HowMayIHelpYou: ; 0x15f83
; Welcome! How may I help you?
@@ -902,15 +901,14 @@ Text_Mart_HowMayIHelpYou: ; 0x15f83
; 0x15f88
MenuDataHeader_BuySell: ; 0x15f88
- db $40 ; flags
- db 00, 00 ; start coords
- db 08, 07 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, 7, 8
dw .menudata2
db 1 ; default option
; 0x15f90
.menudata2 ; 0x15f90
- db $80 ; strings
+ db STATICMENU_CURSOR ; strings
db 3 ; items
db "BUY@"
db "SELL@"
diff --git a/engine/menu.asm b/engine/menu.asm
index 6fbed2848..802bece08 100755
--- a/engine/menu.asm
+++ b/engine/menu.asm
@@ -110,14 +110,14 @@ Mobile_GetMenuSelection: ; 24098
ret
; 240cd
-GetMenuNumberOfColumns: ; 240cd
- ld a, [wMenuData2Items]
+Get2DMenuNumberOfColumns: ; 240cd
+ ld a, [wMenuData2_2DMenuDimensions]
and $f
ret
; 240d3
-GetMenuNumberOfRows: ; 240d3
- ld a, [wMenuData2Items]
+Get2DMenuNumberOfRows: ; 240d3
+ ld a, [wMenuData2_2DMenuDimensions]
swap a
and $f
ret
@@ -130,19 +130,19 @@ Place2DMenuItemStrings: ; 240db
ld d, [hl]
call GetMenuTextStartCoord
call Coord2Tile
- call GetMenuNumberOfRows
+ call Get2DMenuNumberOfRows
ld b, a
.row
push bc
push hl
- call GetMenuNumberOfColumns
+ call Get2DMenuNumberOfColumns
ld c, a
.col
push bc
ld a, [wMenuData2_2DMenuItemStringsBank]
call Place2DMenuItemName
inc de
- ld a, [wMenuData2Spacing]
+ ld a, [wMenuData2_2DMenuSpacing]
ld c, a
ld b, 0
add hl, bc
@@ -174,9 +174,9 @@ Init2DMenuCursorPosition: ; 2411a (9:411a)
dec c
ld a, c
ld [w2DMenuCursorInitX], a
- call GetMenuNumberOfRows
+ call Get2DMenuNumberOfRows
ld [w2DMenuNumRows], a
- call GetMenuNumberOfColumns
+ call Get2DMenuNumberOfColumns
ld [w2DMenuNumCols], a
call .InitFlags_a
call .InitFlags_b
@@ -238,7 +238,7 @@ Init2DMenuCursorPosition: ; 2411a (9:411a)
; 2418a
.InitFlags_b: ; 2418a
- ld a, [wMenuData2Spacing]
+ ld a, [wMenuData2_2DMenuSpacing]
or $20
ld [w2DMenuCursorOffsets], a
ret
@@ -291,8 +291,7 @@ MobileMenuJoypad: ; 241ba
; 241d5
-Function241d5: ; 241d5
-; Unreferenced
+Unreferenced_Function241d5: ; 241d5
call Place2DMenuCursor
.loop
call Move2DMenuCursor
@@ -586,7 +585,7 @@ Place2DMenuCursor: ; 24329
_PushWindow:: ; 24374
ld a, [rSVBK]
push af
- ld a, $7
+ ld a, BANK(wWindowStack)
ld [rSVBK], a
ld hl, wWindowStackPointer
@@ -691,7 +690,7 @@ _ExitMenu:: ; 243e8
ld a, [rSVBK]
push af
- ld a, $7
+ ld a, BANK(wWindowStack)
ld [rSVBK], a
call GetWindowStackTop
@@ -725,12 +724,11 @@ _ExitMenu:: ; 243e8
ret
; 24423
-Function24423: ; 24423
-; Unreferenced
+Unreferenced_Function24423: ; 24423
ld a, [VramState]
bit 0, a
ret z
- xor a
+ xor a ; sScratch
call GetSRAMBank
hlcoord 0, 0
ld de, sScratch
@@ -738,7 +736,7 @@ Function24423: ; 24423
call CopyBytes
call CloseSRAM
call OverworldTextModeSwitch
- xor a
+ xor a ; sScratch
call GetSRAMBank
ld hl, sScratch
decoord 0, 0
diff --git a/engine/menu_2.asm b/engine/menu_2.asm
index d88b75152..c8c4ebf5d 100644
--- a/engine/menu_2.asm
+++ b/engine/menu_2.asm
@@ -27,7 +27,7 @@ PlaceMenuItemQuantity: ; 0x24ac3
.done
ret
-PlaceMoneyTopRight: ; 24ae8
+Special_PlaceMoneyTopRight: ; 24ae8
ld hl, MenuDataHeader_0x24b15
call CopyMenuDataHeader
jr PlaceMoneyDataHeader
@@ -53,16 +53,14 @@ PlaceMoneyDataHeader: ; 24b01
ret
MenuDataHeader_0x24b15: ; 0x24b15
- db $40 ; flags
- db 00, 11 ; start coords
- db 02, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 11, 0, SCREEN_WIDTH - 1, 2
dw NULL
db 1 ; default option
MenuDataHeader_0x24b1d: ; 0x24b1d
- db $40 ; flags
- db 11, 00 ; start coords
- db 13, 08 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 11, 8, 13
dw NULL
db 1 ; default option
@@ -112,8 +110,8 @@ CoinString: ; 24b89
ShowMoney_TerminatorString: ; 24b8e
db "@"
-Function24b8f: ; 24b8f
-; unreferenced, related to safari?
+Unreferenced_Function24b8f: ; 24b8f
+; related to safari?
ld hl, Options
ld a, [hl]
push af
@@ -141,9 +139,9 @@ Function24b8f: ; 24b8f
ret
.slash_500 ; 24bcf
- db "/500@"
+ db "/500@"
.booru_ko ; 24bd4
- db "ボール こ@"
+ db "ボール   こ@"
StartMenu_DrawBugContestStatusBox: ; 24bdc
hlcoord 0, 0
@@ -197,7 +195,7 @@ StartMenu_PrintBugContestStatus: ; 24be7
ret
.Balls_JP: ; 24c43
- db "ボール こ@"
+ db "ボール   こ@"
.CAUGHT: ; 24c4b
db "CAUGHT@"
.Balls_EN: ; 24c52
@@ -216,7 +214,7 @@ FindApricornsInBag: ; 24c64
ld bc, 10
call ByteFill
- ld hl, .ApricornBalls
+ ld hl, ApricornBalls
.loop
ld a, [hl]
cp -1
@@ -252,12 +250,4 @@ FindApricornsInBag: ; 24c64
pop hl
ret
-.ApricornBalls: ; 24ca0
- db RED_APRICORN, LEVEL_BALL
- db BLU_APRICORN, LURE_BALL
- db YLW_APRICORN, MOON_BALL
- db GRN_APRICORN, FRIEND_BALL
- db WHT_APRICORN, FAST_BALL
- db BLK_APRICORN, HEAVY_BALL
- db PNK_APRICORN, LOVE_BALL
- db -1
+INCLUDE "data/items/apricorn_balls.asm"
diff --git a/engine/mon_icons.asm b/engine/mon_icons.asm
index 316ff3bac..db1a68ceb 100755
--- a/engine/mon_icons.asm
+++ b/engine/mon_icons.asm
@@ -281,8 +281,7 @@ FlyFunction_GetMonIcon: ; 8e9bc (23:69bc)
ret
; 8e9cc (23:69cc)
-GetMonIcon2: ; 8e9cc
-; unreferenced
+Unreferenced_GetMonIcon2: ; 8e9cc
push de
ld a, [wd265]
call ReadMonMenuIcon
@@ -307,8 +306,8 @@ GetIconGFX: ; 8e9de
ret
HeldItemIcons:
-INCBIN "gfx/icon/mail.2bpp"
-INCBIN "gfx/icon/item.2bpp"
+INCBIN "gfx/icons/mail.2bpp"
+INCBIN "gfx/icons/item.2bpp"
; 8ea17
GetIcon_de: ; 8ea17
diff --git a/engine/mon_menu.asm b/engine/mon_menu.asm
index e3570ab70..d7e8446d0 100755
--- a/engine/mon_menu.asm
+++ b/engine/mon_menu.asm
@@ -55,9 +55,8 @@ MonSubmenu: ; 24d19
; 24d3f
.MenuDataHeader: ; 24d3f
- db $40 ; tile backup
- db 00, 06 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 6, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw 0
db 1 ; default option
; 24d47
@@ -78,7 +77,7 @@ MonSubmenu: ; 24d19
MonMenuLoop: ; 24d59
.loop
- ld a, $a0 ; flags
+ ld a, MENU_UNUSED_3 | MENU_BACKUP_TILES_2 ; flags
ld [wMenuData2Flags], a
ld a, [Buffer1] ; items
ld [wMenuData2Items], a
@@ -325,15 +324,14 @@ BattleMonMenu: ; 24e99
; 24ed4
MenuDataHeader_0x24ed4: ; 24ed4
- db $00 ; flags
- db 11, 11 ; start coords
- db 17, 19 ; end coords
+ db 0 ; flags
+ menu_coords 11, 11, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw MenuData2_0x24edc
db 1 ; default option
; 24edc
MenuData2_0x24edc: ; 24edc
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 3 ; items
db "SWITCH@"
db "STATS@"
diff --git a/engine/mon_stats.asm b/engine/mon_stats.asm
index a3039eefd..7a493c591 100644
--- a/engine/mon_stats.asm
+++ b/engine/mon_stats.asm
@@ -174,7 +174,7 @@ GetGender: ; 50bdd
; sBoxMon data is read directly from SRAM.
ld a, [MonType]
cp BOXMON
- ld a, 1
+ ld a, BANK(sBox)
call z, GetSRAMBank
; Attack DV
@@ -324,8 +324,7 @@ ListMovePP: ; 50c50
jr nz, .load_loop
ret
-Function50cd0: ; 50cd0
-; XXX
+Unreferenced_Function50cd0: ; 50cd0
.loop
ld [hl], $32
inc hl
@@ -336,7 +335,7 @@ Function50cd0: ; 50cd0
jr nz, .loop
ret
-Predef22: ; unreferenced predef
+Unused_PlaceEnemyHPLevel:
push hl
push hl
ld hl, PartyMonNicknames
diff --git a/engine/move_mon.asm b/engine/move_mon.asm
index 90728e84c..52894359e 100755
--- a/engine/move_mon.asm
+++ b/engine/move_mon.asm
@@ -60,7 +60,7 @@ TryAddMonToParty: ; d88c
ld d, h
ld e, l
ld hl, StringBuffer1
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
.skipnickname
@@ -397,7 +397,7 @@ AddTempmonToParty: ; da96
ld hl, OTPartyMonNicknames
ld a, [CurPartyMon]
call SkipNames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
ld a, [CurPartySpecies]
@@ -434,7 +434,7 @@ AddTempmonToParty: ; da96
and a
ret
-SentGetPkmnIntoFromBox: ; db3f
+SendGetPkmnIntoFromBox: ; db3f
; Sents/Gets Pkmn into/from Box depending on Parameter
; wPokemonWithdrawDepositParameter == 0: get Pkmn into Party
; wPokemonWithdrawDepositParameter == 1: sent Pkmn into Box
@@ -583,7 +583,7 @@ SentGetPkmnIntoFromBox: ; db3f
call SkipNames
.okay12
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
pop hl
@@ -904,8 +904,8 @@ DepositBreedmon: ; de44
ld bc, BOXMON_STRUCT_LENGTH
jp CopyBytes
-SentPkmnIntoBox: ; de6e
-; Sents the Pkmn into one of Bills Boxes
+SendPkmnIntoBox: ; de6e
+; Sends the Pkmn into one of Bills Boxes
; the data comes mainly from 'EnemyMon:'
ld a, BANK(sBoxCount)
call GetSRAMBank
@@ -943,7 +943,7 @@ SentPkmnIntoBox: ; de6e
ld de, sBoxMonNicknames
ld hl, StringBuffer1
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
ld hl, EnemyMon
@@ -1044,7 +1044,7 @@ ShiftBoxMon: ; df47
call .shift
ld hl, sBoxMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call .shift
ld hl, sBoxMons
@@ -1119,7 +1119,7 @@ GiveEgg:: ; df8c
ld d, $0
ld hl, PokedexCaught
ld b, RESET_FLAG
- predef FlagPredef
+ predef SmallFarFlagAction
.skip_caught_flag
; If we haven't seen this Pokemon before receiving
@@ -1135,7 +1135,7 @@ GiveEgg:: ; df8c
ld d, $0
ld hl, PokedexSeen
ld b, RESET_FLAG
- predef FlagPredef
+ predef SmallFarFlagAction
.skip_seen_flag
pop af
@@ -1240,7 +1240,7 @@ RemoveMonFromPartyOrBox: ; e039
; Shift the OT names
ld d, h
ld e, l
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
add hl, bc
ld bc, PartyMonNicknames
ld a, [wPokemonWithdrawDepositParameter]
@@ -1283,12 +1283,12 @@ RemoveMonFromPartyOrBox: ; e039
jr z, .party6
ld hl, sBoxMonNicknames
.party6
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
ld a, [CurPartyMon]
call AddNTimes
ld d, h
ld e, l
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
add hl, bc
ld bc, PartyMonNicknamesEnd
ld a, [wPokemonWithdrawDepositParameter]
@@ -1626,7 +1626,7 @@ GivePoke:: ; e277
ld a, [CurPartySpecies]
ld [TempEnemyMonSpecies], a
callfar LoadEnemyMon
- call SentPkmnIntoBox
+ call SendPkmnIntoBox
jp nc, .FailedToGiveMon
ld a, BOXMON
ld [MonType], a
@@ -1652,7 +1652,7 @@ GivePoke:: ; e277
call GetPokemonName
ld hl, StringBuffer1
ld de, wMonOrItemNameBuffer
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
pop af
and a
@@ -1664,7 +1664,7 @@ GivePoke:: ; e277
push hl
ld a, [ScriptBank]
call GetFarHalfword
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
ld a, [ScriptBank]
call FarCopyBytes
pop hl
@@ -1764,7 +1764,7 @@ GivePoke:: ; e277
call GetSRAMBank
ld hl, wMonOrItemNameBuffer
ld de, sBoxMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
call CloseSRAM
ld b, $1
@@ -1795,7 +1795,7 @@ InitNickname: ; e3de
pop hl
ld de, StringBuffer1
call InitName
- ld a, $4 ; XXX could this be in bank 4 in pokered?
+ ld a, $4 ; ExitAllMenus is in bank 0, XXX could this be in bank 4 in pokered?
ld hl, ExitAllMenus
rst FarCall
ret
diff --git a/engine/move_mon_wo_mail.asm b/engine/move_mon_wo_mail.asm
index c96823d28..e5e1d6e49 100755
--- a/engine/move_mon_wo_mail.asm
+++ b/engine/move_mon_wo_mail.asm
@@ -7,7 +7,7 @@ InsertPokemonIntoBox: ; 51322
dec a
ld [wd265], a
ld hl, sBoxMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
ld de, wBufferMonNick
call InsertDataIntoBoxOrParty
ld a, [sBoxCount]
@@ -44,7 +44,7 @@ InsertPokemonIntoParty: ; 5138b
dec a
ld [wd265], a
ld hl, PartyMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
ld de, wBufferMonNick
call InsertDataIntoBoxOrParty
ld a, [PartyCount]
diff --git a/engine/mystery_gift.asm b/engine/mystery_gift.asm
index 67ce10168..fccdcfcbc 100755
--- a/engine/mystery_gift.asm
+++ b/engine/mystery_gift.asm
@@ -63,7 +63,7 @@ DoMysteryGift: ; 1048ba (41:48ba)
jr z, .skip_append_save
call .SaveMysteryGiftTrainerName
farcall RestoreMobileEventIndex
- farcall TrainerRankings_MysteryGift
+ farcall StubbedTrainerRankings_MysteryGift
farcall BackupMobileEventIndex
.skip_append_save
ld a, [wMysteryGiftPartnerSentDeco]
@@ -1117,7 +1117,7 @@ MysteryGift_CheckAndSetDecorationAlreadyReceived: ; 105069 (41:5069)
ld d, $0
ld b, CHECK_FLAG
ld hl, sMysteryGiftDecorationsReceived
- predef_id FlagPredef
+ predef_id SmallFarFlagAction
push hl
push bc
call Predef
@@ -1129,7 +1129,7 @@ MysteryGift_CheckAndSetDecorationAlreadyReceived: ; 105069 (41:5069)
ret nz
call GetMysteryGiftBank
ld b, SET_FLAG
- predef FlagPredef
+ predef SmallFarFlagAction
call CloseSRAM
xor a
ret
@@ -1142,7 +1142,7 @@ MysteryGift_CopyReceivedDecosToPC: ; 105091 (41:5091)
ld d, $0
ld b, CHECK_FLAG
ld hl, sMysteryGiftDecorationsReceived
- predef FlagPredef
+ predef SmallFarFlagAction
ld a, c
and a
pop bc
@@ -1369,7 +1369,7 @@ InitMysteryGiftLayout: ; 105153 (41:5153)
jr .gfx_loop
; 105232 (41:5232)
-.Load6GFX: ; unreferenced
+.Unreferenced_Load6GFX:
ld b, 6
jr .gfx_loop
@@ -1456,33 +1456,33 @@ Function105688: ; 105688 (41:5688)
jr asm_105726
Function1056eb: ; 1056eb (41:56eb)
- ld c, $10
-.asm_1056ed
- ld hl, Sprites
- ld b, $8
-.asm_1056f2
+ ld c, 16
+.loop
+ ld hl, Sprite01YCoord
+ ld b, 8
+.dec_y_loop
dec [hl]
-rept 4
+rept SPRITEOAMSTRUCT_LENGTH
inc hl
endr
dec b
- jr nz, .asm_1056f2
- ld hl, Sprites + $20
- ld b, $8
-.asm_1056ff
+ jr nz, .dec_y_loop
+ ld hl, Sprite09YCoord
+ ld b, 8
+.inc_y_loop
inc [hl]
-rept 4
+rept SPRITEOAMSTRUCT_LENGTH
inc hl
endr
dec b
- jr nz, .asm_1056ff
+ jr nz, .inc_y_loop
dec c
ret z
push bc
ld c, 4
call DelayFrames
pop bc
- jr .asm_1056ed
+ jr .loop
Function105712: ; 105712 (41:5712)
call Function105777
@@ -1504,9 +1504,9 @@ asm_105726: ; 105726 (41:5726)
String_10572e: ; 10572e
db "エーボタン¯おすと"
- next "つうしん<PKMN>おこなわれるよ!"
+ next "つうしん<PKMN>おこなわれるよ!"
next "ビーボタン¯おすと"
- next "つうしん¯ちゅうし します"
+ next "つうしん¯ちゅうし します"
db "@"
; 10575e
@@ -1561,12 +1561,12 @@ Function10578c: ; 10578c (41:578c)
ld a, [sCrystalData + 0]
ld [de], a
inc de
- ld a, $4
+ ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
- ld hl, $a603
+ ld hl, $a603 ; address of MBC30 bank
ld bc, $8
call CopyBytes
- ld hl, $a007
+ ld hl, $a007 ; address of MBC30 bank
ld bc, $c
call CopyBytes
call CloseSRAM
@@ -1580,7 +1580,7 @@ Function1057d7: ; 1057d7 (41:57d7)
ld a, BANK(MysteryGiftJP_GFX)
lb bc, 4, 0
call FarCopyBytes
- ld hl, MysteryGiftJP_GFX + $400
+ ld hl, MysteryGiftJP_GFX + $40 tiles
ld de, vTiles0 tile $00
ld a, BANK(MysteryGiftJP_GFX)
ld bc, $80
@@ -1656,9 +1656,9 @@ Function1057d7: ; 1057d7 (41:57d7)
ld [hl], $3c
hlcoord 17, 15
ld [hl], $3e
- ld de, Sprites
+ ld de, Sprite01
ld hl, .OAM_data
- ld bc, $40
+ ld bc, 16 * SPRITEOAMSTRUCT_LENGTH
call CopyBytes
call EnableLCD
call WaitBGMap
@@ -1713,22 +1713,22 @@ Function1057d7: ; 1057d7 (41:57d7)
; 1058f0 (41:58f0)
.OAM_data: ; 1058f0
- dsprite 2, 1, 6, 4, $00, $00
- dsprite 2, 1, 7, 4, $01, $00
- dsprite 2, 1, 8, 4, $02, $00
- dsprite 2, 1, 9, 4, $03, $00
- dsprite 3, 1, 6, 4, $04, $00
- dsprite 3, 1, 7, 4, $05, $00
- dsprite 3, 1, 8, 4, $06, $00
- dsprite 3, 1, 9, 4, $07, $00
- dsprite 0, 1, 11, 4, $00, $00
- dsprite 0, 1, 12, 4, $01, $00
- dsprite 0, 1, 13, 4, $02, $00
- dsprite 0, 1, 14, 4, $03, $00
- dsprite 1, 1, 11, 4, $04, $00
- dsprite 1, 1, 12, 4, $05, $00
- dsprite 1, 1, 13, 4, $06, $00
- dsprite 1, 1, 14, 4, $07, $00
+ dsprite 2, 1, 6, 4, $00, 0
+ dsprite 2, 1, 7, 4, $01, 0
+ dsprite 2, 1, 8, 4, $02, 0
+ dsprite 2, 1, 9, 4, $03, 0
+ dsprite 3, 1, 6, 4, $04, 0
+ dsprite 3, 1, 7, 4, $05, 0
+ dsprite 3, 1, 8, 4, $06, 0
+ dsprite 3, 1, 9, 4, $07, 0
+ dsprite 0, 1, 11, 4, $00, 0
+ dsprite 0, 1, 12, 4, $01, 0
+ dsprite 0, 1, 13, 4, $02, 0
+ dsprite 0, 1, 14, 4, $03, 0
+ dsprite 1, 1, 11, 4, $04, 0
+ dsprite 1, 1, 12, 4, $05, 0
+ dsprite 1, 1, 13, 4, $06, 0
+ dsprite 1, 1, 14, 4, $07, 0
; japanese mystery gift gfx
MysteryGiftJP_GFX: ; 105930
diff --git a/engine/mystery_gift_2.asm b/engine/mystery_gift_2.asm
index 1d180f714..72767aa17 100755
--- a/engine/mystery_gift_2.asm
+++ b/engine/mystery_gift_2.asm
@@ -29,7 +29,7 @@ PrepMysteryGiftDataToSend: ; 2c642 (b:4642)
inc de ; wc80f
call CloseSRAM
call Random
- and $1
+ and 1
ld [de], a
inc de ; wc810
call .RandomSample
@@ -59,10 +59,10 @@ PrepMysteryGiftDataToSend: ; 2c642 (b:4642)
.RandomSample: ; 2c6ac (b:46ac)
push de
call Random
- cp $19 ; 10 percent
+ cp 10 percent
jr c, .tenpercent
call Random
- and $7
+ and %111
ld d, a
rl d
ld e, $80
@@ -80,10 +80,10 @@ PrepMysteryGiftDataToSend: ; 2c642 (b:4642)
.tenpercent
call Random
- cp $32 ; 20 percent
+ cp 20 percent - 1
jr c, .twopercent
call Random
- and $3
+ and %011
ld d, a
rl d
ld e, $80
@@ -102,7 +102,7 @@ PrepMysteryGiftDataToSend: ; 2c642 (b:4642)
.twopercent
call Random
- cp $32 ; 50 ; 20 percent
+ cp 20 percent - 1
jr c, .pointfourpercent
ld a, b
swap a
@@ -147,6 +147,6 @@ MysteryGiftFallbackItem: ; 2c722 (b:4722)
; 2c725 (b:4725)
-INCLUDE "data/mystery_gift_items.asm"
+INCLUDE "data/items/mystery_gift_items.asm"
-INCLUDE "data/mystery_gift_decos.asm"
+INCLUDE "data/decorations/mystery_gift_decos.asm"
diff --git a/engine/namingscreen.asm b/engine/naming_screen.asm
index 177f06f73..b53a3b09d 100755
--- a/engine/namingscreen.asm
+++ b/engine/naming_screen.asm
@@ -1,3 +1,9 @@
+NAMINGSCREEN_CURSOR EQU $7e
+
+NAMINGSCREEN_BORDER EQUS "\"■\"" ; $60
+NAMINGSCREEN_MIDDLELINE EQUS "\"→\"" ; $eb
+NAMINGSCREEN_UNDERLINE EQUS "\"<DOT>\"" ; $f2
+
_NamingScreen: ; 0x116b7
call DisableSpriteUpdates
call NamingScreen
@@ -176,7 +182,7 @@ NamingScreen: ; 116c1
.Box: ; 117f5 (4:57f5)
ld de, PokeBallSpriteGFX
ld hl, vTiles0 tile $00
- lb bc, BANK(PokeBallSpriteGFX), $4
+ lb bc, BANK(PokeBallSpriteGFX), 4
call Request2bpp
xor a
ld hl, wSpriteAnimDict
@@ -211,7 +217,7 @@ NamingScreen: ; 116c1
; 11839 (4:5839)
.oTomodachi_no_namae_sutoringu ; 11839
- db "おともだち の なまえは?@"
+ db "おともだち の なまえは?@"
; 11847
@@ -248,7 +254,7 @@ NamingScreen: ; 116c1
ret
.StoreMonIconParams: ; 1187b (4:587b)
- ld a, PKMN_NAME_LENGTH - 1
+ ld a, MON_NAME_LENGTH - 1
hlcoord 5, 6
jr .StoreParams
@@ -287,7 +293,7 @@ NamingScreen_InitText: ; 118a8
call WaitTop
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, $60
+ ld a, NAMINGSCREEN_BORDER
call ByteFill
hlcoord 1, 1
lb bc, 6, 18
@@ -490,7 +496,7 @@ NamingScreenJoypadLoop: ; 11915
ret
.select
- ld hl, wcf64
+ ld hl, wNamingScreenLetterCase
ld a, [hl]
xor 1
ld [hl], a
@@ -562,14 +568,14 @@ NamingScreen_AnimateCursor: ; 11a3b (4:5a3b)
.ok
cp d
ld de, .LetterEntries
- ld a, $0
+ ld a, SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR - SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR ; 0
jr nz, .ok2
ld de, .CaseDelEnd
- ld a, $1
+ ld a, SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR_BIG - SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR ; 1
.ok2
ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
- add [hl]
+ add [hl] ; default SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], a
@@ -729,7 +735,7 @@ NamingScreen_AdvanceCursor_CheckEndOfString: ; 11b27
ld a, [hl]
cp "@"
jr z, .end_of_string
- ld [hl], $f2
+ ld [hl], NAMINGSCREEN_UNDERLINE
and a
ret
@@ -739,7 +745,7 @@ NamingScreen_AdvanceCursor_CheckEndOfString: ; 11b27
; 11b39 (4:5b39)
-; XXX
+; unused
ld a, [wNamingScreenCurrNameLength]
and a
ret z
@@ -765,21 +771,7 @@ NamingScreen_AdvanceCursor_CheckEndOfString: ; 11b27
; 11b56
-Dakutens: ; Dummied out
- db "かが", "きぎ", "くぐ", "けげ", "こご"
- db "さざ", "しじ", "すず", "せぜ", "そぞ"
- db "ただ", "ちぢ", "つづ", "てで", "とど"
- db "はば", "ひび", "ふぶ", "へべ", "ほぼ"
- db "カガ", "キギ", "クグ", "ケゲ", "コゴ"
- db "サザ", "シジ", "スズ", "セゼ", "ソゾ"
- db "タダ", "チヂ", "ツヅ", "テデ", "トド"
- db "ハバ", "ヒビ", "フブ", "へべ", "ホボ"
- db $ff
-
-Handakutens: ; Dummied out
- db "はぱ", "ひぴ", "ふぷ", "へぺ", "ほぽ"
- db "ハパ", "ヒピ", "フプ", "へぺ", "ホポ"
- db $ff
+INCLUDE "data/unused/dakutens.asm"
; 11bbc
@@ -790,12 +782,12 @@ NamingScreen_DeleteCharacter: ; 11bbc (4:5bbc)
ret z
dec [hl]
call NamingScreen_GetTextCursorPosition
- ld [hl], $f2
+ ld [hl], NAMINGSCREEN_UNDERLINE
inc hl
ld a, [hl]
- cp $f2
+ cp NAMINGSCREEN_UNDERLINE
ret nz
- ld [hl], $eb
+ ld [hl], NAMINGSCREEN_MIDDLELINE
ret
NamingScreen_GetTextCursorPosition: ; 11bd0 (4:5bd0)
@@ -814,17 +806,17 @@ NamingScreen_GetTextCursorPosition: ; 11bd0 (4:5bd0)
; 11be0
NamingScreen_InitNameEntry: ; 11be0
-; load $f2, ($eb * [wNamingScreenMaxNameLength]), $50 into the dw address at wNamingScreenDestinationPointer
+; load NAMINGSCREEN_UNDERLINE, (NAMINGSCREEN_MIDDLELINE * [wNamingScreenMaxNameLength]), "@" into the dw address at wNamingScreenDestinationPointer
ld hl, wNamingScreenDestinationPointer
ld a, [hli]
ld h, [hl]
ld l, a
- ld [hl], $f2
+ ld [hl], NAMINGSCREEN_UNDERLINE
inc hl
ld a, [wNamingScreenMaxNameLength]
dec a
ld c, a
- ld a, $eb
+ ld a, NAMINGSCREEN_MIDDLELINE
.loop
ld [hli], a
dec c
@@ -843,9 +835,9 @@ NamingScreen_StoreEntry: ; 11bf7 (4:5bf7)
ld c, a
.loop
ld a, [hl]
- cp $eb
+ cp NAMINGSCREEN_MIDDLELINE
jr z, .terminator
- cp $f2
+ cp NAMINGSCREEN_UNDERLINE
jr nz, .not_terminator
.terminator
ld [hl], "@"
@@ -905,22 +897,22 @@ LoadNamingScreenGFX: ; 11c51
call LoadFontsExtra
ld de, NamingScreenGFX_MiddleLine
- ld hl, vTiles1 tile $6b
+ ld hl, vTiles0 tile NAMINGSCREEN_MIDDLELINE
lb bc, BANK(NamingScreenGFX_MiddleLine), 1
call Get1bpp
ld de, NamingScreenGFX_UnderLine
- ld hl, vTiles1 tile $72
+ ld hl, vTiles0 tile NAMINGSCREEN_UNDERLINE
lb bc, BANK(NamingScreenGFX_UnderLine), 1
call Get1bpp
- ld de, vTiles2 tile $60
+ ld de, vTiles2 tile NAMINGSCREEN_BORDER
ld hl, NamingScreenGFX_Border
ld bc, 1 tiles
ld a, BANK(NamingScreenGFX_Border)
call FarCopyBytes
- ld de, vTiles0 tile $7e
+ ld de, vTiles0 tile NAMINGSCREEN_CURSOR
ld hl, NamingScreenGFX_Cursor
ld bc, 2 tiles
ld a, BANK(NamingScreenGFX_Cursor)
@@ -929,14 +921,14 @@ LoadNamingScreenGFX: ; 11c51
ld a, $5
ld hl, wSpriteAnimDict + 9 * 2
ld [hli], a
- ld [hl], $7e
+ ld [hl], NAMINGSCREEN_CURSOR
xor a
ld [hSCY], a
ld [wGlobalAnimYOffset], a
ld [hSCX], a
ld [wGlobalAnimXOffset], a
ld [wJumptableIndex], a
- ld [wcf64], a
+ ld [wNamingScreenLetterCase], a
ld [hBGMapMode], a
ld [wNamingScreenCurrNameLength], a
ld a, $7
@@ -946,26 +938,26 @@ LoadNamingScreenGFX: ; 11c51
; 11cb7
NamingScreenGFX_Border: ; 11cb7
-INCBIN "gfx/namingscreen/border.2bpp"
+INCBIN "gfx/naming_screen/border.2bpp"
; 11cc7
NamingScreenGFX_Cursor: ; 11cc7
-INCBIN "gfx/namingscreen/cursor.2bpp"
+INCBIN "gfx/naming_screen/cursor.2bpp"
; 11ce7
INCLUDE "data/name_input_chars.asm"
; 11e5d
NamingScreenGFX_End: ; unused
-INCBIN "gfx/namingscreen/end.1bpp"
+INCBIN "gfx/naming_screen/end.1bpp"
; 11e6d
NamingScreenGFX_MiddleLine:
-INCBIN "gfx/namingscreen/middle_line.1bpp"
+INCBIN "gfx/naming_screen/middle_line.1bpp"
; 11e6d
NamingScreenGFX_UnderLine: ; 11e6d
-INCBIN "gfx/namingscreen/underline.1bpp"
+INCBIN "gfx/naming_screen/underline.1bpp"
; 11e75
_ComposeMailMessage: ; 11e75 (mail?)
@@ -1033,15 +1025,15 @@ _ComposeMailMessage: ; 11e75 (mail?)
ld e, [hl]
inc hl
ld d, [hl]
- ld hl, $10
+ ld hl, MAIL_LINE_LENGTH
add hl, de
- ld [hl], $4e
+ ld [hl], "<NEXT>"
ret
; 11ef4 (4:5ef4)
.MailIcon: ; 11ef4
-INCBIN "gfx/icon/mail2.2bpp"
+INCBIN "gfx/icons/mail_big.2bpp"
; 11f74
.initwNamingScreenMaxNameLength ; 11f74 (4:5f74)
@@ -1051,8 +1043,8 @@ INCBIN "gfx/icon/mail2.2bpp"
; 11f7a (4:5f7a)
-.Dummy: ; dummied out
- db "メールを かいてね@"
+.UnusedString11f7a:
+ db "メールを かいてね@"
; 11f84
@@ -1060,7 +1052,7 @@ INCBIN "gfx/icon/mail2.2bpp"
call WaitTop
hlcoord 0, 0
ld bc, 6 * SCREEN_WIDTH
- ld a, $60 ; border
+ ld a, NAMINGSCREEN_BORDER
call ByteFill
hlcoord 0, 6
ld bc, 12 * SCREEN_WIDTH
@@ -1190,13 +1182,13 @@ INCBIN "gfx/icon/mail2.2bpp"
jr c, .start
ld hl, wNamingScreenCurrNameLength
ld a, [hl]
- cp $10
+ cp MAIL_LINE_LENGTH
ret nz
inc [hl]
call NamingScreen_GetTextCursorPosition
- ld [hl], $f2
+ ld [hl], NAMINGSCREEN_UNDERLINE
dec hl
- ld [hl], $4e
+ ld [hl], "<NEXT>"
ret
.start
@@ -1216,13 +1208,13 @@ INCBIN "gfx/icon/mail2.2bpp"
call NamingScreen_DeleteCharacter
ld hl, wNamingScreenCurrNameLength
ld a, [hl]
- cp $10
+ cp MAIL_LINE_LENGTH
ret nz
dec [hl]
call NamingScreen_GetTextCursorPosition
- ld [hl], $f2
+ ld [hl], NAMINGSCREEN_UNDERLINE
inc hl
- ld [hl], $4e
+ ld [hl], "<NEXT>"
ret
.finished
@@ -1232,9 +1224,9 @@ INCBIN "gfx/icon/mail2.2bpp"
ret
.select
- ld hl, wcf64
+ ld hl, wNamingScreenLetterCase
ld a, [hl]
- xor $1
+ xor 1
ld [hl], a
jr nz, .switch_to_lowercase
ld de, MailEntry_Uppercase
@@ -1434,7 +1426,7 @@ MailComposition_TryAddLastCharacter: ; 121ac (4:61ac)
; 121b2 (4:61b2)
-; XXX
+; unused
ld a, [wNamingScreenCurrNameLength]
and a
ret z
diff --git a/engine/npc_movement.asm b/engine/npc_movement.asm
index a2508e0f6..e8b353fa6 100755
--- a/engine/npc_movement.asm
+++ b/engine/npc_movement.asm
@@ -70,14 +70,14 @@ Function6f07: ; 6f07
ld e, [hl]
ld hl, OBJECT_PALETTE
add hl, bc
- bit 7, [hl]
+ bit OAM_PRIORITY, [hl]
jp nz, Function6fa1
ld hl, OBJECT_NEXT_TILE
add hl, bc
ld a, [hl]
ld d, a
call GetTileCollision
- and a ; land
+ and a ; LANDTILE
jr z, Function6f3e
scf
ret
@@ -106,7 +106,7 @@ Function6f3e: ; 6f3e
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld a, [hl]
- and 3
+ maskbits NUM_DIRECTIONS
ld e, a
ld d, 0
ld hl, .data_6f5b
@@ -131,7 +131,7 @@ Function6f5f: ; 6f5f
push af
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
- and 3
+ maskbits NUM_DIRECTIONS
ld e, a
ld d, 0
ld hl, .data_6f7b
@@ -178,49 +178,49 @@ Function6fa1: ; 6fa1
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld a, [hl]
- and 3
- jr z, .asm_6fb2
+ maskbits NUM_DIRECTIONS
+ jr z, .down
dec a
- jr z, .asm_6fb7
+ jr z, .up
dec a
- jr z, .asm_6fbb
- jr .asm_6fbf
+ jr z, .left
+ jr .right
-.asm_6fb2
+.down
inc e
push de
inc d
- jr .asm_6fc2
+ jr .continue
-.asm_6fb7
+.up
push de
inc d
- jr .asm_6fc2
+ jr .continue
-.asm_6fbb
+.left
push de
inc e
- jr .asm_6fc2
+ jr .continue
-.asm_6fbf
+.right
inc d
push de
inc e
-.asm_6fc2
+.continue
call GetCoordTile
call GetTileCollision
pop de
- and a ; land
- jr nz, .asm_6fd7
+ and a ; LANDTILE
+ jr nz, .not_land
call GetCoordTile
call GetTileCollision
- and a ; land
- jr nz, .asm_6fd7
+ and a ; LANDTILE
+ jr nz, .not_land
xor a
ret
-.asm_6fd7
+.not_land
scf
ret
; 6fd9
@@ -279,7 +279,7 @@ WillObjectBumpIntoSomeoneElse: ; 7009
jr IsNPCAtCoord
; 7015
-Function7015: ; unreferenced
+Unreferenced_Function7015:
ld a, [hMapObjectIndexBuffer]
call GetObjectStruct
call .CheckWillBeFacingNPC
@@ -482,7 +482,7 @@ IsObjectMovingOffEdgeOfScreen: ; 70ed
ret
; 7113
-Function7113: ; unreferenced
+Unreferenced_Function7113:
ld a, [PlayerStandingMapX]
ld d, a
ld a, [PlayerStandingMapY]
diff --git a/engine/npctrade.asm b/engine/npctrade.asm
index 1455dce62..40f6dd638 100755
--- a/engine/npctrade.asm
+++ b/engine/npctrade.asm
@@ -1,11 +1,3 @@
-; Trade dialogs
- const_def
- const TRADE_INTRO
- const TRADE_CANCEL
- const TRADE_WRONG
- const TRADE_COMPLETE
- const TRADE_AFTER
-
NPCTrade:: ; fcba8
ld a, e
ld [wJumptableIndex], a
@@ -83,9 +75,9 @@ CheckTradeGender: ; fcc23
ld e, TRADE_GENDER
call GetTradeAttribute
ld a, [hl]
- and a
+ and a ; TRADE_EITHER_GENDER
jr z, .matching
- cp 1
+ cp TRADE_MALE_ONLY
jr z, .check_male
farcall GetGender
@@ -109,7 +101,7 @@ TradeFlagAction: ; fcc4a
ld hl, wTradeFlags
ld a, [wJumptableIndex]
ld c, a
- predef FlagPredef
+ predef SmallFarFlagAction
ld a, c
and a
ret
@@ -178,10 +170,10 @@ DoNPCTrade: ; fcc63
ld e, TRADE_DIALOG
call GetTradeAttribute
ld a, [hl]
- cp 3
- ld a, 1
+ cp TRADE_DIALOG_GIRL
+ ld a, CAUGHT_BY_GIRL
jr c, .okay
- ld a, 2
+ ld a, CAUGHT_BY_BOY
.okay
ld [wOTTrademonCaughtData], a
@@ -214,7 +206,7 @@ DoNPCTrade: ; fcc63
call CopyTradeName
ld hl, PartyMonNicknames
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call Trade_GetAttributeOfLastPartymon
ld hl, wOTTrademonNickname
call CopyTradeName
@@ -332,8 +324,7 @@ CopyTradeName: ; fcdf4
ret
; fcdfb
-Functionfcdfb: ; fcdfb
-; unreferenced
+Unreferenced_Functionfcdfb: ; fcdfb
ld bc, 4
call CopyBytes
ld a, "@"
@@ -341,8 +332,7 @@ Functionfcdfb: ; fcdfb
ret
; fce05
-Functionfce05: ; fce05
-; unreferenced
+Unreferenced_Functionfce05: ; fce05
ld bc, 3
call CopyBytes
ld a, "@"
@@ -400,7 +390,7 @@ GetTradeMonNames: ; fce1b
and a
ret z
- cp 1
+ cp TRADE_MALE_ONLY
ld a, "♂"
jr z, .done
ld a, "♀"
@@ -433,31 +423,28 @@ PrintTradeText: ; fcf38
; fcf53
TradeTexts: ; fcf53
-; intro
+; entries correspond to TRADE_* × TRADE_DIALOG_* constants
+; TRADE_INTRO
dw TradeIntroText1
dw TradeIntroText2
dw TradeIntroText3
dw TradeIntroText4
-
-; cancel
+; TRADE_CANCEL
dw TradeCancelText1
dw TradeCancelText2
dw TradeCancelText3
dw TradeCancelText4
-
-; wrong mon
+; TRADE_WRONG
dw TradeWrongText1
dw TradeWrongText2
dw TradeWrongText3
dw TradeWrongText4
-
-; completed
+; TRADE_COMPLETE
dw TradeCompleteText1
dw TradeCompleteText2
dw TradeCompleteText3
dw TradeCompleteText4
-
-; after
+; TRADE_AFTER
dw TradeAfterText1
dw TradeAfterText2
dw TradeAfterText3
diff --git a/engine/overworld.asm b/engine/overworld.asm
index 68b8adaed..4c379711d 100755
--- a/engine/overworld.asm
+++ b/engine/overworld.asm
@@ -23,7 +23,7 @@ Function14146: ; mobile
push af
res 7, [hl]
set 6, [hl]
- call MapCallbackSprites_LoadUsedSpritesGFX
+ call Special_LoadUsedSpritesGFX
pop af
ld [wSpriteFlags], a
ret
@@ -35,15 +35,15 @@ Function14157: ; mobile
push af
set 7, [hl]
res 6, [hl]
- call MapCallbackSprites_LoadUsedSpritesGFX
+ call Special_LoadUsedSpritesGFX
pop af
ld [wSpriteFlags], a
ret
; 14168
-RefreshSprites:: ; 14168
+Special_RefreshSprites:: ; 14168
call .Refresh
- call MapCallbackSprites_LoadUsedSpritesGFX
+ call Special_LoadUsedSpritesGFX
ret
; 1416f
@@ -77,7 +77,7 @@ GetPlayerSprite: ; 14183
cp c
jr z, .good
inc hl
- cp $ff
+ cp -1
jr nz, .loop
; Any player state not in the array defaults to Chris's sprite.
@@ -100,14 +100,14 @@ GetPlayerSprite: ; 14183
db PLAYER_BIKE, SPRITE_CHRIS_BIKE
db PLAYER_SURF, SPRITE_SURF
db PLAYER_SURF_PIKA, SPRITE_SURFING_PIKACHU
- db $ff
+ db -1 ; end
.Kris:
db PLAYER_NORMAL, SPRITE_KRIS
db PLAYER_BIKE, SPRITE_KRIS_BIKE
db PLAYER_SURF, SPRITE_SURF
db PLAYER_SURF_PIKA, SPRITE_SURFING_PIKACHU
- db $ff
+ db -1 ; end
; 141c9
@@ -164,7 +164,7 @@ AddOutdoorSprites: ; 141ee
; 14209
-MapCallbackSprites_LoadUsedSpritesGFX: ; 14209
+Special_LoadUsedSpritesGFX: ; 14209
ld a, MAPCALLBACK_SPRITES
call RunMapCallback
call GetUsedSprites
@@ -719,10 +719,10 @@ LoadEmote:: ; 1442f
; 1444d
-INCLUDE "data/emotes.asm"
+INCLUDE "data/sprites/emotes.asm"
-INCLUDE "data/sprite_mons.asm"
+INCLUDE "data/sprites/sprite_mons.asm"
INCLUDE "data/maps/outdoor_sprites.asm"
-INCLUDE "data/sprites.asm"
+INCLUDE "data/sprites/sprites.asm"
diff --git a/engine/pack.asm b/engine/pack.asm
index 047924cb0..f9c7490af 100644
--- a/engine/pack.asm
+++ b/engine/pack.asm
@@ -1,3 +1,17 @@
+; Pack.Jumptable and BattlePack.Jumptable indexes
+ const_def
+ const PACKSTATE_INITGFX ; 0
+ const PACKSTATE_INITITEMSPOCKET ; 1
+ const PACKSTATE_ITEMSPOCKETMENU ; 2
+ const PACKSTATE_INITBALLSPOCKET ; 3
+ const PACKSTATE_BALLSPOCKETMENU ; 4
+ const PACKSTATE_INITKEYITEMSPOCKET ; 5
+ const PACKSTATE_KEYITEMSPOCKETMENU ; 6
+ const PACKSTATE_INITTMHMPOCKET ; 7
+ const PACKSTATE_TMHMPOCKETMENU ; 8
+ const PACKSTATE_QUITNOSCRIPT ; 9
+ const PACKSTATE_QUITRUNSCRIPT ; 10
+
Pack: ; 10000
ld hl, Options
set NO_TEXT_SCROLL, [hl]
@@ -28,6 +42,7 @@ Pack: ; 10000
; 10030
.Jumptable: ; 10030 (4:4030)
+; entries correspond to PACKSTATE_* constants
dw .InitGFX ; 0
dw .InitItemsPocket ; 1
dw .ItemsPocketMenu ; 2
@@ -44,13 +59,13 @@ Pack: ; 10000
xor a
ld [hBGMapMode], a
call Pack_InitGFX
- ld a, [wcf64]
+ ld a, [wPackJumptableIndex]
ld [wJumptableIndex], a
call Pack_InitColors
ret
.InitItemsPocket: ; 10056 (4:4056)
- xor a
+ xor a ; ITEM_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@@ -70,15 +85,15 @@ Pack: ; 10000
ld [wItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wItemsPocketCursor], a
- ld b, $7
- ld c, $3
+ ld b, PACKSTATE_INITTMHMPOCKET ; left
+ ld c, PACKSTATE_INITBALLSPOCKET ; right
call Pack_InterpretJoypad
ret c
call .ItemBallsKey_LoadSubmenu
ret
.InitKeyItemsPocket: ; 10094 (4:4094)
- ld a, $2
+ ld a, KEY_ITEM_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@@ -98,15 +113,15 @@ Pack: ; 10000
ld [wKeyItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wKeyItemsPocketCursor], a
- ld b, $3
- ld c, $7
+ ld b, PACKSTATE_INITBALLSPOCKET ; left
+ ld c, PACKSTATE_INITTMHMPOCKET ; right
call Pack_InterpretJoypad
ret c
call .ItemBallsKey_LoadSubmenu
ret
.InitTMHMPocket: ; 100d3 (4:40d3)
- ld a, $3
+ ld a, TM_HM_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@@ -118,8 +133,8 @@ Pack: ; 10000
.TMHMPocketMenu: ; 100e8 (4:40e8)
farcall TMHMPocket
- ld b, $5
- ld c, $1
+ ld b, PACKSTATE_INITKEYITEMSPOCKET ; left
+ ld c, PACKSTATE_INITITEMSPOCKET ; right
call Pack_InterpretJoypad
ret c
farcall _CheckTossableItem
@@ -147,37 +162,34 @@ Pack: ; 10000
; 10124 (4:4124)
.MenuDataHeader1: ; 0x10124
- db $40 ; flags
- db 07, 13 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 13, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2_1
db 1 ; default option
; 0x1012c
.MenuData2_1: ; 0x1012c
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 2 ; items
db "USE@"
db "QUIT@"
; 0x10137
.Jumptable1: ; 10137
-
dw .UseItem
dw QuitItemSubmenu
; 1013b
.MenuDataHeader2: ; 0x1013b
- db $40 ; flags
- db 05, 13 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 13, 5, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2_2
db 1 ; default option
; 0x10143
.MenuData2_2: ; 0x10143
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 3 ; items
db "USE@"
db "GIVE@"
@@ -211,7 +223,7 @@ Pack: ; 10000
ret
.InitBallsPocket: ; 10186 (4:4186)
- ld a, $1
+ ld a, BALL_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@@ -231,8 +243,8 @@ Pack: ; 10000
ld [wBallsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wBallsPocketCursor], a
- ld b, $1
- ld c, $5
+ ld b, PACKSTATE_INITITEMSPOCKET ; left
+ ld c, PACKSTATE_INITKEYITEMSPOCKET ; right
call Pack_InterpretJoypad
ret c
call .ItemBallsKey_LoadSubmenu
@@ -309,15 +321,14 @@ Pack: ; 10000
; 10249 (4:4249)
MenuDataHeader_UsableKeyItem: ; 0x10249
- db $40 ; flags
- db 01, 13 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 13, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
; 0x10251
.MenuData2: ; 0x10251
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 5 ; items
db "USE@"
db "GIVE@"
@@ -327,7 +338,6 @@ MenuDataHeader_UsableKeyItem: ; 0x10249
; 0x1026a
Jumptable_UseGiveTossRegisterQuit: ; 1026a
-
dw UseItem
dw GiveItem
dw TossMenu
@@ -336,15 +346,14 @@ Jumptable_UseGiveTossRegisterQuit: ; 1026a
; 10274
MenuDataHeader_UsableItem: ; 0x10274
- db $40 ; flags
- db 03, 13 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 13, 3, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
; 0x1027c
.MenuData2: ; 0x1027c
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 4 ; items
db "USE@"
db "GIVE@"
@@ -353,7 +362,6 @@ MenuDataHeader_UsableItem: ; 0x10274
; 0x10291
Jumptable_UseGiveTossQuit: ; 10291
-
dw UseItem
dw GiveItem
dw TossMenu
@@ -361,36 +369,33 @@ Jumptable_UseGiveTossQuit: ; 10291
; 10299
MenuDataHeader_UnusableItem: ; 0x10299
- db %01000000 ; flags
- db 07, 13 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 13, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
; 0x102a1
.MenuData2: ; 0x102a1
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 2 ; items
db "USE@"
db "QUIT@"
; 0x102ac
Jumptable_UseQuit: ; 102ac
-
dw UseItem
dw QuitItemSubmenu
; 102b0
MenuDataHeader_UnusableKeyItem: ; 0x102b0
- db %01000000 ; flags
- db 05, 13 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 13, 5, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
; 0x102b8
.MenuData2: ; 0x102b8
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 3 ; items
db "USE@"
db "SEL@"
@@ -398,22 +403,20 @@ MenuDataHeader_UnusableKeyItem: ; 0x102b0
; 0x102c7
Jumptable_UseRegisterQuit: ; 102c7
-
dw UseItem
dw RegisterItem
dw QuitItemSubmenu
; 102cd
MenuDataHeader_HoldableKeyItem: ; 0x102cd
- db $40 ; flags
- db 03, 13 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 13, 3, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
; 0x102d5
.MenuData2: ; 0x102d5
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 4 ; items
db "GIVE@"
db "TOSS@"
@@ -422,7 +425,6 @@ MenuDataHeader_HoldableKeyItem: ; 0x102cd
; 0x102ea
Jumptable_GiveTossRegisterQuit: ; 102ea
-
dw GiveItem
dw TossMenu
dw RegisterItem
@@ -430,15 +432,14 @@ Jumptable_GiveTossRegisterQuit: ; 102ea
; 102f2
MenuDataHeader_HoldableItem: ; 0x102f2
- db $40 ; flags
- db 05, 13 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 13, 5, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
; 0x102fa
.MenuData2: ; 0x102fa
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 3 ; items
db "GIVE@"
db "TOSS@"
@@ -446,7 +447,6 @@ MenuDataHeader_HoldableItem: ; 0x102f2
; 0x1030b
Jumptable_GiveTossQuit: ; 1030b
-
dw GiveItem
dw TossMenu
dw QuitItemSubmenu
@@ -462,14 +462,14 @@ UseItem: ; 10311
; 1031f
.dw ; 1031f (4:431f)
-
+; entries correspond to ITEMMENU_* constants
+ dw .Oak ; ITEMMENU_NOUSE
dw .Oak
dw .Oak
dw .Oak
- dw .Oak
- dw .Current
- dw .Party
- dw .Field
+ dw .Current ; ITEMMENU_CURRENT
+ dw .Party ; ITEMMENU_PARTY
+ dw .Field ; ITEMMENU_CLOSE
; 1035c
.Oak: ; 1032d (4:432d)
@@ -503,7 +503,7 @@ UseItem: ; 10311
ld a, [wItemEffectSucceeded]
and a
jr z, .Oak
- ld a, $a
+ ld a, PACKSTATE_QUITRUNSCRIPT
ld [wJumptableIndex], a
ret
; 10364 (4:4364)
@@ -534,14 +534,13 @@ TossMenu: ; 10364
ret
; 1039d
-ResetPocketCursorPositions: ; 1039d
-; unreferenced
+Unreferenced_ResetPocketCursorPositions: ; 1039d
ld a, [wCurrPocket]
- and a
+ and a ; ITEM_POCKET
jr z, .items
- dec a
+ dec a ; BALL_POCKET
jr z, .balls
- dec a
+ dec a ; KEY_ITEM_POCKET
jr z, .key
ret
@@ -626,16 +625,16 @@ GiveItem: ; 103fd
.give
ld a, [wJumptableIndex]
push af
- ld a, [wcf64]
+ ld a, [wPackJumptableIndex]
push af
call GetCurNick
ld hl, StringBuffer1
ld de, wMonOrItemNameBuffer
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
call TryGiveItemToPartymon
pop af
- ld [wcf64], a
+ ld [wPackJumptableIndex], a
pop af
ld [wJumptableIndex], a
.finish
@@ -693,6 +692,7 @@ BattlePack: ; 10493
; 104c3
.Jumptable: ; 104c3 (4:44c3)
+; entries correspond to PACKSTATE_* constants
dw .InitGFX ; 0
dw .InitItemsPocket ; 1
dw .ItemsPocketMenu ; 2
@@ -709,13 +709,13 @@ BattlePack: ; 10493
xor a
ld [hBGMapMode], a
call Pack_InitGFX
- ld a, [wcf64]
+ ld a, [wPackJumptableIndex]
ld [wJumptableIndex], a
call Pack_InitColors
ret
.InitItemsPocket: ; 104e9 (4:44e9)
- xor a
+ xor a ; ITEM_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@@ -735,15 +735,15 @@ BattlePack: ; 10493
ld [wItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wItemsPocketCursor], a
- ld b, $7
- ld c, $3
+ ld b, PACKSTATE_INITTMHMPOCKET ; left
+ ld c, PACKSTATE_INITBALLSPOCKET ; right
call Pack_InterpretJoypad
ret c
call ItemSubmenu
ret
.InitKeyItemsPocket: ; 10527 (4:4527)
- ld a, $2
+ ld a, KEY_ITEM_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@@ -763,15 +763,15 @@ BattlePack: ; 10493
ld [wKeyItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wKeyItemsPocketCursor], a
- ld b, $3
- ld c, $7
+ ld b, PACKSTATE_INITBALLSPOCKET ; left
+ ld c, PACKSTATE_INITTMHMPOCKET ; right
call Pack_InterpretJoypad
ret c
call ItemSubmenu
ret
.InitTMHMPocket: ; 10566 (4:4566)
- ld a, $3
+ ld a, TM_HM_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@@ -785,8 +785,8 @@ BattlePack: ; 10493
.TMHMPocketMenu: ; 10581 (4:4581)
farcall TMHMPocket
- ld b, $5
- ld c, $1
+ ld b, PACKSTATE_INITKEYITEMSPOCKET ; left
+ ld c, PACKSTATE_INITITEMSPOCKET ; right
call Pack_InterpretJoypad
ret c
xor a
@@ -794,7 +794,7 @@ BattlePack: ; 10493
ret
.InitBallsPocket: ; 10594 (4:4594)
- ld a, $1
+ ld a, BALL_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@@ -814,8 +814,8 @@ BattlePack: ; 10493
ld [wBallsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wBallsPocketCursor], a
- ld b, $1
- ld c, $5
+ ld b, PACKSTATE_INITITEMSPOCKET ; left
+ ld c, PACKSTATE_INITKEYITEMSPOCKET ; right
call Pack_InterpretJoypad
ret c
call ItemSubmenu
@@ -848,15 +848,14 @@ TMHMSubmenu: ; 105dc (4:45dc)
; 10601 (4:4601)
.UsableMenuDataHeader: ; 0x10601
- db $40 ; flags
- db 07, 13 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 13, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .UsableMenuData2
db 1 ; default option
; 0x10609
.UsableMenuData2: ; 0x10609
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 2 ; items
db "USE@"
db "QUIT@"
@@ -868,15 +867,14 @@ TMHMSubmenu: ; 105dc (4:45dc)
; 10618
.UnusableMenuDataHeader: ; 0x10618
- db $40 ; flags
- db 09, 13 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 13, 9, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .UnusableMenuData2
db 1 ; default option
; 0x10620
.UnusableMenuData2: ; 0x10620
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 1 ; items
db "QUIT@"
; 0x10627
@@ -893,13 +891,14 @@ TMHMSubmenu: ; 105dc (4:45dc)
ret
.ItemFunctionJumptable: ; 10637 (4:4637)
+; entries correspond to ITEMMENU_* constants
+ dw .Oak ; ITEMMENU_NOUSE
dw .Oak
dw .Oak
dw .Oak
- dw .Oak
- dw .Unused
- dw .BattleField
- dw .BattleOnly
+ dw .Unused ; ITEMMENU_CURRENT
+ dw .BattleField ; ITEMMENU_PARTY
+ dw .BattleOnly ; ITEMMENU_CLOSE
.Oak: ; 10645 (4:4645)
ld hl, Text_ThisIsntTheTime
@@ -937,7 +936,7 @@ TMHMSubmenu: ; 105dc (4:45dc)
cp $2
jr z, .didnt_use_item
.quit_run_script ; 1067e (4:467e)
- ld a, 10
+ ld a, PACKSTATE_QUITRUNSCRIPT
ld [wJumptableIndex], a
ret
@@ -953,15 +952,16 @@ TMHMSubmenu: ; 105dc (4:45dc)
InitPackBuffers: ; 1068a
xor a
ld [wJumptableIndex], a
+ ; pocket id -> jumptable index
ld a, [wLastPocket]
- and $3
+ maskbits NUM_POCKETS
ld [wCurrPocket], a
inc a
add a
dec a
- ld [wcf64], a
- xor a
- ld [wcf66], a
+ ld [wPackJumptableIndex], a
+ xor a ; FALSE
+ ld [wPackUsedItem], a
xor a
ld [wSwitchItem], a
ret
@@ -970,10 +970,10 @@ InitPackBuffers: ; 1068a
DepositSellInitPackBuffers: ; 106a5
xor a
ld [hBGMapMode], a
- ld [wJumptableIndex], a
- ld [wcf64], a
- ld [wCurrPocket], a
- ld [wcf66], a
+ ld [wJumptableIndex], a ; PACKSTATE_INITGFX
+ ld [wPackJumptableIndex], a ; PACKSTATE_INITGFX
+ ld [wCurrPocket], a ; ITEM_POCKET
+ ld [wPackUsedItem], a
ld [wSwitchItem], a
call Pack_InitGFX
call Pack_InitColors
@@ -997,13 +997,14 @@ DepositSellPack: ; 106be
; 106d1
.Jumptable: ; 106d1 (4:46d1)
+; entries correspond to *_POCKET constants
dw .ItemsPocket
dw .BallsPocket
dw .KeyItemsPocket
dw .TMHMPocket
.ItemsPocket: ; 106d9 (4:46d9)
- xor a
+ xor a ; ITEM_POCKET
call InitPocket
ld hl, PC_Mart_ItemsPocketMenuDataHeader
call CopyMenuDataHeader
@@ -1019,7 +1020,7 @@ DepositSellPack: ; 106be
ret
.KeyItemsPocket: ; 106ff (4:46ff)
- ld a, 2
+ ld a, KEY_ITEM_POCKET
call InitPocket
ld hl, PC_Mart_KeyItemsPocketMenuDataHeader
call CopyMenuDataHeader
@@ -1035,7 +1036,7 @@ DepositSellPack: ; 106be
ret
.TMHMPocket: ; 10726 (4:4726)
- ld a, 3
+ ld a, TM_HM_POCKET
call InitPocket
call WaitBGMap_DrawPackGFX
farcall TMHMPocket
@@ -1044,7 +1045,7 @@ DepositSellPack: ; 106be
ret
.BallsPocket: ; 1073b (4:473b)
- ld a, 1
+ ld a, BALL_POCKET
call InitPocket
ld hl, PC_Mart_BallsPocketMenuDataHeader
call CopyMenuDataHeader
@@ -1085,20 +1086,20 @@ DepositSellTutorial_InterpretJoypad: ; 1076f
.a_button
ld a, TRUE
- ld [wcf66], a
+ ld [wPackUsedItem], a
and a
ret
.b_button
- xor a
- ld [wcf66], a
+ xor a ; FALSE
+ ld [wPackUsedItem], a
and a
ret
.d_left
ld a, [wJumptableIndex]
dec a
- and $3
+ maskbits NUM_POCKETS
ld [wJumptableIndex], a
push de
ld de, SFX_SWITCH_POCKETS
@@ -1110,7 +1111,7 @@ DepositSellTutorial_InterpretJoypad: ; 1076f
.d_right
ld a, [wJumptableIndex]
inc a
- and $3
+ maskbits NUM_POCKETS
ld [wJumptableIndex], a
push de
ld de, SFX_SWITCH_POCKETS
@@ -1130,8 +1131,8 @@ TutorialPack: ; 107bb
call .RunJumptable
call DepositSellTutorial_InterpretJoypad
jr c, .loop
- xor a
- ld [wcf66], a
+ xor a ; FALSE
+ ld [wPackUsedItem], a
ret
; 107d7
@@ -1144,28 +1145,27 @@ TutorialPack: ; 107bb
; 107e1
.dw ; 107e1 (4:47e1)
-
+; entries correspond to *_POCKET constants
dw .Items
dw .Balls
dw .KeyItems
dw .TMHM
.Items: ; 107e9 (4:47e9)
- xor a
+ xor a ; ITEM_POCKET
ld hl, .ItemsMenuDataHeader
jr .DisplayPocket
; 107ef (4:47ef)
.ItemsMenuDataHeader: ; 0x107ef
- db $40 ; flags
- db 01, 07 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .ItemsMenuData2
db 1 ; default option
; 0x107f7
.ItemsMenuData2: ; 0x107f7
- db $ae ; flags
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
db 5, 8 ; rows, columns
db 2 ; horizontal spacing
dbw 0, wDudeNumItems
@@ -1175,21 +1175,20 @@ TutorialPack: ; 107bb
; 10807
.KeyItems: ; 10807 (4:4807)
- ld a, 2
+ ld a, KEY_ITEM_POCKET
ld hl, .KeyItemsMenuDataHeader
jr .DisplayPocket
; 1080e (4:480e)
.KeyItemsMenuDataHeader: ; 0x1080e
- db $40 ; flags
- db 01, 07 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .KeyItemsMenuData2
db 1 ; default option
; 0x10816
.KeyItemsMenuData2: ; 0x10816
- db $ae ; flags
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
db 5, 8 ; rows, columns
db 1 ; horizontal spacing
dbw 0, wDudeNumKeyItems
@@ -1199,7 +1198,7 @@ TutorialPack: ; 107bb
; 10826
.TMHM: ; 10826 (4:4826)
- ld a, 3
+ ld a, TM_HM_POCKET
call InitPocket
call WaitBGMap_DrawPackGFX
farcall TMHMPocket
@@ -1208,21 +1207,20 @@ TutorialPack: ; 107bb
ret
.Balls: ; 1083b (4:483b)
- ld a, 1
+ ld a, BALL_POCKET
ld hl, .BallsMenuDataHeader
jr .DisplayPocket
; 10842 (4:4842)
.BallsMenuDataHeader: ; 0x10842
- db $40 ; flags
- db 01, 07 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .BallsMenuData2
db 1 ; default option
; 0x1084a
.BallsMenuData2: ; 0x1084a
- db $ae ; flags
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
db 5, 8 ; rows, columns
db 2 ; horizontal spacing
dbw 0, wDudeNumBalls
@@ -1258,15 +1256,15 @@ Pack_GetJumptablePointer: ; 1086b
Pack_QuitNoScript: ; 10874 (4:4874)
ld hl, wJumptableIndex
set 7, [hl]
- xor a
- ld [wcf66], a
+ xor a ; FALSE
+ ld [wPackUsedItem], a
ret
Pack_QuitRunScript: ; 1087e (4:487e)
ld hl, wJumptableIndex
set 7, [hl]
ld a, TRUE
- ld [wcf66], a
+ ld [wPackUsedItem], a
ret
Pack_PrintTextNoScroll: ; 10889 (4:4889)
@@ -1283,7 +1281,7 @@ WaitBGMap_DrawPackGFX: ; 1089a (4:489a)
call WaitBGMap
DrawPackGFX: ; 1089d
ld a, [wCurrPocket]
- and $3
+ maskbits NUM_POCKETS
ld e, a
ld d, $0
ld a, [BattleType]
@@ -1310,10 +1308,10 @@ DrawPackGFX: ; 1089d
; 108cc
PackGFXPointers: ; 108cc
- dw PackGFX + (15 tiles) * 1
- dw PackGFX + (15 tiles) * 3
- dw PackGFX + (15 tiles) * 0
- dw PackGFX + (15 tiles) * 2
+ dw PackGFX + (15 tiles) * 1 ; ITEM_POCKET
+ dw PackGFX + (15 tiles) * 3 ; BALL_POCKET
+ dw PackGFX + (15 tiles) * 0 ; KEY_ITEM_POCKET
+ dw PackGFX + (15 tiles) * 2 ; TM_HM_POCKET
; 108d4
Pack_InterpretJoypad: ; 108d4 (4:48d4)
@@ -1344,7 +1342,7 @@ Pack_InterpretJoypad: ; 108d4 (4:48d4)
ret
.b_button
- ld a, 9
+ ld a, PACKSTATE_QUITNOSCRIPT
ld [wJumptableIndex], a
scf
ret
@@ -1352,7 +1350,7 @@ Pack_InterpretJoypad: ; 108d4 (4:48d4)
.d_left
ld a, b
ld [wJumptableIndex], a
- ld [wcf64], a
+ ld [wPackJumptableIndex], a
push de
ld de, SFX_SWITCH_POCKETS
call PlaySFX
@@ -1363,7 +1361,7 @@ Pack_InterpretJoypad: ; 108d4 (4:48d4)
.d_right
ld a, c
ld [wJumptableIndex], a
- ld [wcf64], a
+ ld [wPackJumptableIndex], a
push de
ld de, SFX_SWITCH_POCKETS
call PlaySFX
@@ -1489,15 +1487,19 @@ DrawPocketName: ; 109bb
; 109e1
.tilemap ; 109e1
+; ITEM_POCKET
db $00, $04, $04, $04, $01 ; top border
db $06, $07, $08, $09, $0a ; Items
db $02, $05, $05, $05, $03 ; bottom border
+; BALL_POCKET
db $00, $04, $04, $04, $01 ; top border
db $15, $16, $17, $18, $19 ; Balls
db $02, $05, $05, $05, $03 ; bottom border
+; KEY_ITEM_POCKET
db $00, $04, $04, $04, $01 ; top border
db $0b, $0c, $0d, $0e, $0f ; Key Items
db $02, $05, $05, $05, $03 ; bottom border
+; TM_HM_POCKET
db $00, $04, $04, $04, $01 ; top border
db $10, $11, $12, $13, $14 ; TM/HM
db $02, $05, $05, $05, $03 ; bottom border
@@ -1511,8 +1513,7 @@ Pack_GetItemName: ; 10a1d
ret
; 10a2a
-Pack_ClearTilemap: ; 10a2a
-; unreferenced
+Unreferenced_Pack_ClearTilemap: ; 10a2a
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, " "
@@ -1536,15 +1537,14 @@ Pack_InitColors: ; 10a40
; 10a4f
ItemsPocketMenuDataHeader: ; 0x10a4f
- db $40 ; flags
- db 01, 07 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
; 0x10a57
.MenuData2: ; 0x10a57
- db $ae ; flags
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
db 5, 8 ; rows, columns
db 2 ; horizontal spacing
dbw 0, NumItems
@@ -1554,15 +1554,14 @@ ItemsPocketMenuDataHeader: ; 0x10a4f
; 10a67
PC_Mart_ItemsPocketMenuDataHeader: ; 0x10a67
- db $40 ; flags
- db 01, 07 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
; 0x10a6f
.MenuData2: ; 0x10a6f
- db $2e ; flags
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags
db 5, 8 ; rows, columns
db 2 ; horizontal spacing
dbw 0, NumItems
@@ -1572,15 +1571,14 @@ PC_Mart_ItemsPocketMenuDataHeader: ; 0x10a67
; 10a7f
KeyItemsPocketMenuDataHeader: ; 0x10a7f
- db $40 ; flags
- db 01, 07 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
; 0x10a87
.MenuData2: ; 0x10a87
- db $ae ; flags
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
db 5, 8 ; rows, columns
db 1 ; horizontal spacing
dbw 0, NumKeyItems
@@ -1590,15 +1588,14 @@ KeyItemsPocketMenuDataHeader: ; 0x10a7f
; 10a97
PC_Mart_KeyItemsPocketMenuDataHeader: ; 0x10a97
- db $40 ; flags
- db 01, 07 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
; 0x10a9f
.MenuData2: ; 0x10a9f
- db $2e ; flags
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags
db 5, 8 ; rows, columns
db 1 ; horizontal spacing
dbw 0, NumKeyItems
@@ -1608,15 +1605,14 @@ PC_Mart_KeyItemsPocketMenuDataHeader: ; 0x10a97
; 10aaf
BallsPocketMenuDataHeader: ; 0x10aaf
- db $40 ; flags
- db 01, 07 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
; 0x10ab7
.MenuData2: ; 0x10ab7
- db $ae ; flags
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
db 5, 8 ; rows, columns
db 2 ; horizontal spacing
dbw 0, NumBalls
@@ -1626,15 +1622,14 @@ BallsPocketMenuDataHeader: ; 0x10aaf
; 10ac7
PC_Mart_BallsPocketMenuDataHeader: ; 0x10ac7
- db $40 ; flags
- db 01, 07 ; start coords
- db 11, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData2
db 1 ; default option
; 0x10acf
.MenuData2: ; 0x10acf
- db $2e ; flags
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags
db 5, 8 ; rows, columns
db 2 ; horizontal spacing
dbw 0, NumBalls
diff --git a/engine/party_menu.asm b/engine/party_menu.asm
index 0415e29e4..5ef9b50de 100644
--- a/engine/party_menu.asm
+++ b/engine/party_menu.asm
@@ -50,23 +50,23 @@ WritePartyMenuTilemap: ; 0x5005f
ld hl, Options
ld a, [hl]
push af
- set 4, [hl] ; Disable text delay
+ set NO_TEXT_SCROLL, [hl]
xor a
ld [hBGMapMode], a
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, " "
call ByteFill ; blank the tilemap
- call GetPartyMenuTilemapPointers ; This reads from a pointer table???
+ call GetPartyMenuQualityIndexes
.loop
ld a, [hli]
- cp $ff
- jr z, .end ; 0x5007a $8
+ cp -1
+ jr z, .end
push hl
ld hl, .Jumptable
rst JumpTable
pop hl
- jr .loop ; 0x50082 $f3
+ jr .loop
.end
pop af
ld [Options], a
@@ -74,6 +74,7 @@ WritePartyMenuTilemap: ; 0x5005f
; 0x50089
.Jumptable: ; 50089
+; entries correspond to PARTYMENUQUALITY_* constants
dw PlacePartyNicknames
dw PlacePartyHPBar
dw PlacePartyMenuHPDigits
@@ -523,7 +524,7 @@ PlacePartyMonMobileBattleSelection: ; 50307
dec c
jr nz, .loop
ld a, l
- ld e, PKMN_NAME_LENGTH
+ ld e, MON_NAME_LENGTH
sub e
ld l, a
ld a, h
@@ -573,16 +574,16 @@ PlacePartyMonMobileBattleSelection: ; 50307
; 5036b
.String_Banme: ; 5036b
- db " ばんめ @" ; Place
+ db " ばんめ  @" ; Place
; 50372
.String_Sanka_Shinai: ; 50372
db "さんかしない@" ; Cancel
; 50379
.String_Kettei_Yameru: ; 50379
- db "けってい やめる@" ; Quit
+ db "けってい  やめる@" ; Quit
; 50383
.Strings_1_2_3: ; 50383
- db "1@", "2@", "3@" ; 1st, 2nd, 3rd
+ db "1@", "2@", "3@" ; 1st, 2nd, 3rd
; 50389
@@ -598,7 +599,7 @@ PartyMenuCheckEgg: ; 50389
ret
; 50396
-GetPartyMenuTilemapPointers: ; 50396
+GetPartyMenuQualityIndexes: ; 50396
ld a, [PartyMenuActionText]
and $f0
jr nz, .skip
@@ -606,7 +607,7 @@ GetPartyMenuTilemapPointers: ; 50396
and $f
ld e, a
ld d, 0
- ld hl, .Pointers
+ ld hl, PartyMenuQualityPointers
add hl, de
add hl, de
ld a, [hli]
@@ -615,29 +616,11 @@ GetPartyMenuTilemapPointers: ; 50396
ret
.skip
- ld hl, .Default
+ ld hl, PartyMenuQualityPointers.Default
ret
; 503b2
-.Pointers: ; 503b2
- dw .Default
- dw .Default
- dw .Default
- dw .TMHM
- dw .Default
- dw .EvoStone
- dw .Gender
- dw .Gender
- dw .Default
- dw .Mobile
-; 503c6
-
-.Default: db 0, 1, 2, 3, 4, $ff
-.TMHM: db 0, 5, 3, 4, $ff
-.EvoStone: db 0, 6, 3, 4, $ff
-.Gender: db 0, 7, 3, 4, $ff
-.Mobile: db 0, 8, 3, 4, $ff
-; 503e0
+INCLUDE "data/party_menu_qualities.asm"
InitPartyMenuGFX: ; 503e0
@@ -817,25 +800,33 @@ PartyMenuStrings: ; 0x504d2
ChooseAMonString: ; 0x504e4
db "Choose a #MON.@"
+
UseOnWhichPKMNString: ; 0x504f3
db "Use on which <PK><MN>?@"
+
WhichPKMNString: ; 0x50504
db "Which <PK><MN>?@"
+
TeachWhichPKMNString: ; 0x5050e
db "Teach which <PK><MN>?@"
+
MoveToWhereString: ; 0x5051e
db "Move to where?@"
-ChooseAFemalePKMNString: ; 0x5052d ; UNUSED
+
+ChooseAFemalePKMNString: ; 0x5052d
+; unused
db "Choose a ♀<PK><MN>.@"
-ChooseAMalePKMNString: ; 0x5053b ; UNUSED
+
+ChooseAMalePKMNString: ; 0x5053b
+; unused
db "Choose a ♂<PK><MN>.@"
+
ToWhichPKMNString: ; 0x50549
db "To which <PK><MN>?@"
YouHaveNoPKMNString: ; 0x50556
db "You have no <PK><MN>!@"
-
PrintPartyMenuActionText: ; 50566
ld a, [CurPartyMon]
ld hl, PartyMonNicknames
diff --git a/engine/phone/buenas_password.asm b/engine/phone/buenas_password.asm
index 858ce5540..0d144afa6 100644
--- a/engine/phone/buenas_password.asm
+++ b/engine/phone/buenas_password.asm
@@ -167,4 +167,4 @@ BuenaPhoneScript_Random1:
end
; a0c28
-INCLUDE "text/phone/buena.asm"
+INCLUDE "data/phone/text/buena.asm"
diff --git a/engine/phone/generic_calls.asm b/engine/phone/generic_calls.asm
index e1b53a950..937fc67c0 100644
--- a/engine/phone/generic_calls.asm
+++ b/engine/phone/generic_calls.asm
@@ -1240,7 +1240,7 @@ PhoneScript_Generic_Female:
end
PhoneScript_MonFlavorText:
- special RandomPhoneMon
+ special Special_RandomPhoneMon
farscall PhoneScript_Random2
if_equal $0, .TooEnergetic
farwritetext UnknownText_0x1b518b
diff --git a/engine/phone/phone.asm b/engine/phone/phone.asm
index 53bb519b3..f402e9102 100644
--- a/engine/phone/phone.asm
+++ b/engine/phone/phone.asm
@@ -75,20 +75,20 @@ GetRemainingSpaceInPhoneList: ; 90040
cp -1
jr z, .done
cp c
- jr z, .elm_or_mom
+ jr z, .continue
+
push bc
push hl
ld c, a
call _CheckCellNum
- jr c, .elm_or_mom_in_list
+ jr c, .permanent
ld hl, Buffer1
inc [hl]
-
-.elm_or_mom_in_list
+.permanent
pop hl
pop bc
-.elm_or_mom
+.continue
jr .loop
.done
@@ -98,9 +98,7 @@ GetRemainingSpaceInPhoneList: ; 90040
ret
; 90066
-PermanentNumbers: ; 90066
- db PHONECONTACT_MOM, PHONECONTACT_ELM, -1
-; 90069
+INCLUDE "data/phone/permanent_numbers.asm"
FarPlaceString: ; 90069
@@ -133,7 +131,7 @@ CheckPhoneCall:: ; 90074 (24:4074)
cp b
jr nz, .no_call
- call GetMapHeaderPhoneServiceNybble
+ call GetMapPhoneService
and a
jr nz, .no_call
@@ -165,7 +163,7 @@ CheckPhoneContactTimeOfDay: ; 900ad (24:40ad)
farcall CheckTime
pop af
- and MORN | DAY | NITE
+ and ANYTIME
and c
pop de
@@ -330,7 +328,7 @@ Function90199: ; 90199 (24:4199)
and a
jr nz, .OutOfArea
; If you're in an area without phone service, don't do the call
- call GetMapHeaderPhoneServiceNybble
+ call GetMapPhoneService
and a
jr nz, .OutOfArea
; If the person can't take a call at that time, don't do the call
@@ -439,7 +437,7 @@ WrongNumber: ; 90233
; 90241
Script_ReceivePhoneCall: ; 0x90241
- refreshscreen $0
+ refreshscreen
callasm RingTwice_StartCall
ptcall wPhoneScriptPointer
waitbutton
@@ -471,7 +469,7 @@ UnknownScript_0x90261: ; 0x90261
RingTwice_StartCall: ; 9026f
call .Ring
call .Ring
- farcall TrainerRankings_PhoneCalls
+ farcall StubbedTrainerRankings_PhoneCalls
ret
; 9027c
@@ -500,7 +498,7 @@ PhoneCall:: ; 9029a
ld [PhoneCaller + 1], a
call Phone_FirstOfTwoRings
call Phone_FirstOfTwoRings
- farcall TrainerRankings_PhoneCalls
+ farcall StubbedTrainerRankings_PhoneCalls
ret
; 902b3
@@ -518,7 +516,7 @@ Phone_FirstOfTwoRings: ; 902b3
Phone_CallerTextboxWithName2: ; 902c9
call Phone_CallerTextbox
hlcoord 1, 2
- ld [hl], "<PHONE>"
+ ld [hl], "☎"
inc hl
inc hl
ld a, [PhoneScriptBank]
@@ -618,7 +616,7 @@ Function90363: ; 90363 (24:4363)
push bc
call Phone_CallerTextbox
hlcoord 1, 1
- ld [hl], "<PHONE>"
+ ld [hl], "☎"
inc hl
inc hl
ld d, h
@@ -719,7 +717,7 @@ NonTrainerCallerNames: ; 903d6
.bill db "BILL:@"
.elm db "PROF.ELM:@"
.bikeshop db "BIKE SHOP:@"
-.buena db "BUENA:", $22, " DISC JOCKEY@"
+.buena db "BUENA:<LNBRK> DISC JOCKEY@"
; 90423
Phone_GetTrainerName: ; 90423 (24:4423)
@@ -761,9 +759,9 @@ GetCallerLocation: ; 90439
; 9045f
-INCLUDE "data/phone_contacts.asm"
+INCLUDE "data/phone/phone_contacts.asm"
-INCLUDE "data/phone_special.asm"
+INCLUDE "data/phone/special_calls.asm"
UnknownScript_0x90657: ; 0x90657
diff --git a/engine/phone/phone_callers.asm b/engine/phone/phone_callers.asm
index c90448d33..cb333ae8d 100644
--- a/engine/phone/phone_callers.asm
+++ b/engine/phone/phone_callers.asm
@@ -1,5 +1,5 @@
Phone_GenericCall_Male:
- special RandomPhoneMon
+ special Special_RandomPhoneMon
farscall PhoneScript_Random2
if_equal 0, .Bragging
farscall PhoneScript_Generic_Male
@@ -9,7 +9,7 @@ Phone_GenericCall_Male:
farjump Phone_BraggingCall_Male
Phone_GenericCall_Female:
- special RandomPhoneMon
+ special Special_RandomPhoneMon
farscall PhoneScript_Random2
if_equal 0, .Bragging
farscall PhoneScript_Generic_Female
@@ -27,7 +27,7 @@ Phone_BraggingCall_Female:
farjump Phone_FoundAMon_Female
Phone_FoundAMon_Male:
- special RandomPhoneWildMon
+ special Special_RandomPhoneWildMon
farscall PhoneScript_Random2
if_equal 0, .GotAway
farscall Phone_WhoDefeatedMon_Male
@@ -37,7 +37,7 @@ Phone_FoundAMon_Male:
farjump Phone_GotAwayCall_Male
Phone_FoundAMon_Female:
- special RandomPhoneWildMon
+ special Special_RandomPhoneWildMon
farscall PhoneScript_Random2
if_equal 0, .GotAway
farscall Phone_WhoDefeatedMon_Female
@@ -851,7 +851,7 @@ Phone_CheckIfUnseenRare_Female:
farjump PhoneScript_HangupText_Female
PhoneScriptRareWildMon:
- special RandomUnseenWildMon
+ special Special_RandomUnseenWildMon
end
PhoneScript_BugCatchingContest:
diff --git a/engine/phone/phone_scripts.asm b/engine/phone/phone_scripts.asm
index 62eb4ac87..646040641 100644
--- a/engine/phone/phone_scripts.asm
+++ b/engine/phone/phone_scripts.asm
@@ -20,10 +20,10 @@ MomPhoneScript: ; 0xbceaa
iftrue MomPhoneHangUpScript
farwritetext MomPhoneGreetingText
buttonsound
- mapnametotext $0
+ mapnametotext MEM_BUFFER_0
checkcode VAR_ROOFPALETTE
- if_equal $1, MomPhonePalette1
- if_equal $2, MomPhonePalette2
+ if_equal 1, MomPhonePalette1
+ if_equal 2, MomPhonePalette2
jump MomPhoneOther
MomPhoneLandmark: ; 0xbcedf
@@ -53,13 +53,13 @@ MomPhonePalette1: ; 0xbcee7
jump MomSavingMoney
.violet ; 0xbcf15
- landmarktotext SPROUT_TOWER, 1
+ landmarktotext SPROUT_TOWER, MEM_BUFFER_1
jump MomPhoneLandmark
.azalea ; 0xbcf1b
- landmarktotext SLOWPOKE_WELL, 1
+ landmarktotext SLOWPOKE_WELL, MEM_BUFFER_1
jump MomPhoneLandmark
.goldenrod ; 0xbcf21
- landmarktotext RADIO_TOWER, 1
+ landmarktotext RADIO_TOWER, MEM_BUFFER_1
jump MomPhoneLandmark
MomPhonePalette2: ; 0xbcf27
@@ -75,17 +75,17 @@ MomPhoneOther: ; 0xbcf2f
MomSavingMoney: ; 0xbcf37
checkflag ENGINE_MOM_SAVING_MONEY
iffalse MomIsNotSaving
- checkmoney $1, 0
- if_equal $0, MomSavingHasMoney
+ checkmoney MOMS_MONEY, 0
+ if_equal HAVE_MORE, MomSavingHasMoney
jump MomSavingButBroke
MomIsNotSaving: ; 0xbcf49
- checkmoney $1, 0
- if_equal $0, MomHasMoney
+ checkmoney MOMS_MONEY, 0
+ if_equal HAVE_MORE, MomHasMoney
jump MomHasNoMoney
MomSavingHasMoney: ; 0xbcf55
- readmoney $1, $0
+ readmoney MOMS_MONEY, MEM_BUFFER_0
farwritetext MomCheckBalanceText
yesorno
iftrue MomPhoneSaveMoneyScript
@@ -104,7 +104,7 @@ MomHasNoMoney: ; 0xbcf6e
jump MomPhoneWontSaveMoneyScript
MomHasMoney: ; 0xbcf79
- readmoney $1, $0
+ readmoney MOMS_MONEY, MEM_BUFFER_0
farwritetext MomYouveSavedText
yesorno
iftrue MomPhoneSaveMoneyScript
@@ -172,9 +172,9 @@ BillPhoneScript1: ; 0xbcfc5
farwritetext BillPhoneGeneriText
buttonsound
checkcode VAR_BOXSPACE
- RAM2MEM $0
- if_equal $0, .full
- if_less_than $6, .nearlyfull
+ vartomem MEM_BUFFER_0
+ if_equal 0, .full
+ if_less_than PARTY_LENGTH, .nearlyfull
farwritetext BillPhoneNotFullText
end
@@ -195,7 +195,7 @@ BillPhoneScript2: ; 0xbd007
ElmPhoneScript1: ; 0xbd00d
checkcode VAR_SPECIALPHONECALL
- if_equal $1, .pokerus
+ if_equal SPECIALCALL_POKERUS, .pokerus
checkevent EVENT_SHOWED_TOGEPI_TO_ELM
iftrue .discovery
checkevent EVENT_GOT_TOGEPI_EGG_FROM_ELMS_AIDE
@@ -242,8 +242,8 @@ ElmPhoneScript1: ; 0xbd00d
end
.discovery ; 0xbd069
- random $2
- if_equal $0, .nextdiscovery
+ random 2
+ if_equal 0, .nextdiscovery
farwritetext ElmPhoneDiscovery1Text
end
@@ -258,11 +258,11 @@ ElmPhoneScript1: ; 0xbd00d
ElmPhoneScript2: ; 0xbd081
checkcode VAR_SPECIALPHONECALL
- if_equal $2, .disaster
- if_equal $3, .assistant
- if_equal $4, .rocket
- if_equal $5, .gift
- if_equal $8, .gift
+ if_equal SPECIALCALL_ROBBED, .disaster
+ if_equal SPECIALCALL_ASSISTANT, .assistant
+ if_equal SPECIALCALL_WEIRDBROADCAST, .rocket
+ if_equal SPECIALCALL_SSTICKET, .gift
+ if_equal SPECIALCALL_MASTERBALL, .gift
farwritetext ElmPhonePokerusText
specialphonecall SPECIALCALL_NONE
end
@@ -299,7 +299,7 @@ ElmPhoneScript2: ; 0xbd081
; Jack
JackPhoneScript1:
- trainertotext SCHOOLBOY, JACK1, $0
+ trainertotext SCHOOLBOY, JACK1, MEM_BUFFER_0
checkflag ENGINE_JACK
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -314,31 +314,31 @@ JackPhoneScript1:
farjump JackPhoneTips
.WantsBattle:
- landmarktotext NATIONAL_PARK, $2
+ landmarktotext NATIONAL_PARK, MEM_BUFFER_2
farjump JackWantsBattleScript
JackPhoneScript2:
- trainertotext SCHOOLBOY, JACK1, $0
+ trainertotext SCHOOLBOY, JACK1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
farscall PhoneScript_Random2
- if_equal $0, JackBattleTrivia
+ if_equal 0, JackBattleTrivia
checkflag ENGINE_JACK
iftrue .WaitingForBattle
checkflag ENGINE_JACK_MONDAY_MORNING
iftrue .WaitingForBattle
farscall PhoneScript_Random2
- if_equal $0, JackWantsToBattle
+ if_equal 0, JackWantsToBattle
.WaitingForBattle:
farscall PhoneScript_Random3
- if_equal $0, JackFindsRare
+ if_equal 0, JackFindsRare
farjump Phone_GenericCall_Male
JackMondayMorning:
setflag ENGINE_JACK_MONDAY_MORNING
JackWantsToBattle:
- landmarktotext NATIONAL_PARK, $2
+ landmarktotext NATIONAL_PARK, MEM_BUFFER_2
setflag ENGINE_JACK
farjump PhoneScript_WantsToBattle_Male
@@ -351,36 +351,36 @@ JackBattleTrivia:
; Beverly
BeverlyPhoneScript1:
- trainertotext POKEFANF, BEVERLY1, $0
+ trainertotext POKEFANF, BEVERLY1, MEM_BUFFER_0
farscall PhoneScript_AnswerPhone_Female
checkflag ENGINE_BEVERLY_HAS_NUGGET
iftrue .HasNugget
farjump UnknownScript_0xa0900
.HasNugget:
- landmarktotext NATIONAL_PARK, $2
+ landmarktotext NATIONAL_PARK, MEM_BUFFER_2
farjump UnknownScript_0xa0aa5
BeverlyPhoneScript2:
- trainertotext POKEFANF, BEVERLY1, $0
+ trainertotext POKEFANF, BEVERLY1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Female
checkflag ENGINE_BEVERLY_HAS_NUGGET
iftrue .HasNugget
farscall PhoneScript_Random4
- if_equal $0, .FoundNugget
+ if_equal 0, .FoundNugget
.HasNugget:
farjump Phone_GenericCall_Female
.FoundNugget:
setflag ENGINE_BEVERLY_HAS_NUGGET
- landmarktotext NATIONAL_PARK, $2
+ landmarktotext NATIONAL_PARK, MEM_BUFFER_2
farjump PhoneScript_FoundItem_Female
; Huey
HueyPhoneScript1:
- trainertotext SAILOR, HUEY1, $0
+ trainertotext SAILOR, HUEY1, MEM_BUFFER_0
checkflag ENGINE_HUEY
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -392,23 +392,23 @@ HueyPhoneScript1:
iftrue HueyWednesdayNight
.NotWednesday:
- special RandomPhoneMon
+ special Special_RandomPhoneMon
farjump UnknownScript_0xa0908
.WantsBattle:
- landmarktotext LIGHTHOUSE, $2
+ landmarktotext LIGHTHOUSE, MEM_BUFFER_2
farjump HueyWantsBattleScript
HueyPhoneScript2:
- trainertotext SAILOR, HUEY1, $0
+ trainertotext SAILOR, HUEY1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_HUEY
iftrue .Flavor
checkflag ENGINE_HUEY_WEDNESDAY_NIGHT
iftrue .Flavor
farscall PhoneScript_Random3
- if_equal $0, HueyWantsBattle
- if_equal $1, HueyWantsBattle
+ if_equal 0, HueyWantsBattle
+ if_equal 1, HueyWantsBattle
.Flavor:
farjump PhoneScript_MonFlavorText
@@ -417,14 +417,14 @@ HueyWednesdayNight:
setflag ENGINE_HUEY_WEDNESDAY_NIGHT
HueyWantsBattle:
- landmarktotext LIGHTHOUSE, $2
+ landmarktotext LIGHTHOUSE, MEM_BUFFER_2
setflag ENGINE_HUEY
farjump PhoneScript_WantsToBattle_Male
; Gaven
GavenPhoneScript1:
- trainertotext COOLTRAINERM, GAVEN3, $0
+ trainertotext COOLTRAINERM, GAVEN3, MEM_BUFFER_0
checkflag ENGINE_GAVEN
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -439,29 +439,29 @@ GavenPhoneScript1:
farjump UnknownScript_0xa0910
.WantsBattle:
- landmarktotext ROUTE_26, $2
+ landmarktotext ROUTE_26, MEM_BUFFER_2
farjump UnknownScript_0xa0a37
GavenPhoneScript2:
- trainertotext COOLTRAINERM, GAVEN3, $0
+ trainertotext COOLTRAINERM, GAVEN3, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_GAVEN
iftrue .WaitingForBattle
checkflag ENGINE_GAVEN_THURSDAY_MORNING
iftrue .WaitingForBattle
farscall PhoneScript_Random2
- if_equal $0, GavenWantsRematch
+ if_equal 0, GavenWantsRematch
.WaitingForBattle:
farscall PhoneScript_Random3
- if_equal $0, GavenFoundRare
+ if_equal 0, GavenFoundRare
farjump Phone_GenericCall_Male
GavenThursdayMorning:
setflag ENGINE_GAVEN_THURSDAY_MORNING
GavenWantsRematch:
- landmarktotext ROUTE_26, $2
+ landmarktotext ROUTE_26, MEM_BUFFER_2
setflag ENGINE_GAVEN
farjump PhoneScript_WantsToBattle_Male
@@ -471,7 +471,7 @@ GavenFoundRare:
; Beth
BethPhoneScript1:
- trainertotext COOLTRAINERF, BETH1, $0
+ trainertotext COOLTRAINERF, BETH1, MEM_BUFFER_0
checkflag ENGINE_BETH
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Female
@@ -486,18 +486,18 @@ BethPhoneScript1:
farjump UnknownScript_0xa0918
.WantsBattle:
- landmarktotext ROUTE_26, $2
+ landmarktotext ROUTE_26, MEM_BUFFER_2
farjump BethBattleReminderScript
BethPhoneScript2:
- trainertotext COOLTRAINERF, BETH1, $0
+ trainertotext COOLTRAINERF, BETH1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Female
checkflag ENGINE_BETH
iftrue .Generic
checkflag ENGINE_BETH_FRIDAY_AFTERNOON
iftrue .Generic
farscall PhoneScript_Random2
- if_equal $0, BethWantsBattle
+ if_equal 0, BethWantsBattle
.Generic:
farjump Phone_GenericCall_Female
@@ -506,14 +506,14 @@ BethFridayAfternoon:
setflag ENGINE_BETH_FRIDAY_AFTERNOON
BethWantsBattle:
- landmarktotext ROUTE_26, $2
+ landmarktotext ROUTE_26, MEM_BUFFER_2
setflag ENGINE_BETH
farjump PhoneScript_WantsToBattle_Female
; Jose
JosePhoneScript1:
- trainertotext BIRD_KEEPER, JOSE2, $0
+ trainertotext BIRD_KEEPER, JOSE2, MEM_BUFFER_0
checkflag ENGINE_JOSE
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -530,15 +530,15 @@ JosePhoneScript1:
farjump UnknownScript_0xa0920
.WantsBattle:
- landmarktotext ROUTE_27, $2
+ landmarktotext ROUTE_27, MEM_BUFFER_2
farjump UnknownScript_0xa0a41
.HasItem:
- landmarktotext ROUTE_27, $2
+ landmarktotext ROUTE_27, MEM_BUFFER_2
farjump UnknownScript_0xa0a41
JosePhoneScript2:
- trainertotext BIRD_KEEPER, JOSE2, $0
+ trainertotext BIRD_KEEPER, JOSE2, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_JOSE
iftrue .Generic
@@ -547,20 +547,20 @@ JosePhoneScript2:
checkflag ENGINE_JOSE_HAS_STAR_PIECE
iftrue .Generic
farscall PhoneScript_Random3
- if_equal $0, JoseWantsBattle
+ if_equal 0, JoseWantsBattle
farscall PhoneScript_Random3
- if_equal $0, JoseHasStarPiece
+ if_equal 0, JoseHasStarPiece
.Generic:
farscall PhoneScript_Random3
- if_equal $0, JoseFoundRare
+ if_equal 0, JoseFoundRare
farjump Phone_GenericCall_Male
JoseSaturdayNight:
setflag ENGINE_JOSE_SATURDAY_NIGHT
JoseWantsBattle:
- landmarktotext ROUTE_27, $2
+ landmarktotext ROUTE_27, MEM_BUFFER_2
setflag ENGINE_JOSE
farjump PhoneScript_WantsToBattle_Male
@@ -569,13 +569,13 @@ JoseFoundRare:
JoseHasStarPiece:
setflag ENGINE_JOSE_HAS_STAR_PIECE
- landmarktotext ROUTE_27, $2
+ landmarktotext ROUTE_27, MEM_BUFFER_2
farjump PhoneScript_FoundItem_Male
; Reena
ReenaPhoneScript1:
- trainertotext COOLTRAINERF, REENA1, $0
+ trainertotext COOLTRAINERF, REENA1, MEM_BUFFER_0
checkflag ENGINE_REENA
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Female
@@ -590,18 +590,18 @@ ReenaPhoneScript1:
farjump UnknownScript_0xa0928
.WantsBattle:
- landmarktotext ROUTE_27, $2
+ landmarktotext ROUTE_27, MEM_BUFFER_2
farjump UnknownScript_0xa0a46
ReenaPhoneScript2:
- trainertotext COOLTRAINERF, REENA1, $0
+ trainertotext COOLTRAINERF, REENA1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Female
checkflag ENGINE_REENA
iftrue .Generic
checkflag ENGINE_REENA_SUNDAY_MORNING
iftrue .Generic
farscall PhoneScript_Random2
- if_equal $0, ReenaWantsBattle
+ if_equal 0, ReenaWantsBattle
.Generic:
farjump Phone_GenericCall_Female
@@ -610,14 +610,14 @@ ReenaSundayMorning:
setflag ENGINE_REENA_SUNDAY_MORNING
ReenaWantsBattle:
- landmarktotext ROUTE_27, $2
+ landmarktotext ROUTE_27, MEM_BUFFER_2
setflag ENGINE_REENA
farjump PhoneScript_WantsToBattle_Female
; Joey
JoeyPhoneScript1:
- trainertotext YOUNGSTER, JOEY1, $0
+ trainertotext YOUNGSTER, JOEY1, MEM_BUFFER_0
checkflag ENGINE_JOEY
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -629,23 +629,23 @@ JoeyPhoneScript1:
iftrue JoeyMondayAfternoon
.NotMonday:
- special RandomPhoneMon
+ special Special_RandomPhoneMon
farjump UnknownScript_0xa0930
.WantsBattle:
- landmarktotext ROUTE_30, $2
+ landmarktotext ROUTE_30, MEM_BUFFER_2
farjump UnknownScript_0xa0a4b
JoeyPhoneScript2:
- trainertotext YOUNGSTER, JOEY1, $0
+ trainertotext YOUNGSTER, JOEY1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_JOEY
iftrue .Generic
checkflag ENGINE_JOEY_MONDAY_AFTERNOON
iftrue .Generic
farscall PhoneScript_Random3
- if_equal $0, JoeyWantsBattle
- if_equal $1, JoeyWantsBattle
+ if_equal 0, JoeyWantsBattle
+ if_equal 1, JoeyWantsBattle
.Generic:
farjump Phone_GenericCall_Male
@@ -654,14 +654,14 @@ JoeyMondayAfternoon:
setflag ENGINE_JOEY_MONDAY_AFTERNOON
JoeyWantsBattle:
- landmarktotext ROUTE_30, $2
+ landmarktotext ROUTE_30, MEM_BUFFER_2
setflag ENGINE_JOEY
farjump PhoneScript_WantsToBattle_Male
; Wade
WadePhoneScript1:
- trainertotext BUG_CATCHER, WADE1, $0
+ trainertotext BUG_CATCHER, WADE1, MEM_BUFFER_0
checkflag ENGINE_WADE
iftrue WadeWantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -676,7 +676,7 @@ WadePhoneScript1:
.NotTuesday:
farscall PhoneScript_Random2
- if_equal $0, .NoContest
+ if_equal 0, .NoContest
checkflag ENGINE_DAILY_BUG_CONTEST
iftrue .NoContest
checkcode VAR_WEEKDAY
@@ -691,18 +691,18 @@ WadeContestToday:
farjump PhoneScript_BugCatchingContest
WadeWantsBattle:
- landmarktotext ROUTE_31, $2
+ landmarktotext ROUTE_31, MEM_BUFFER_2
farjump UnknownScript_0xa0a50
WadeHasItem:
- landmarktotext ROUTE_31, $2
+ landmarktotext ROUTE_31, MEM_BUFFER_2
farjump UnknownScript_0xa0ab5
WadePhoneScript2:
- trainertotext BUG_CATCHER, WADE1, $0
+ trainertotext BUG_CATCHER, WADE1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
farscall PhoneScript_Random2
- if_equal $0, .NoContest
+ if_equal 0, .NoContest
checkflag ENGINE_DAILY_BUG_CONTEST
iftrue .NoContest
checkcode VAR_WEEKDAY
@@ -718,15 +718,15 @@ WadePhoneScript2:
checkflag ENGINE_WADE_HAS_ITEM
iftrue .next
farscall PhoneScript_Random2
- if_equal $0, WadeHasItem2
+ if_equal 0, WadeHasItem2
checkflag ENGINE_FLYPOINT_GOLDENROD
iffalse .next
farscall PhoneScript_Random2
- if_equal $0, WadeWantsBattle2
+ if_equal 0, WadeWantsBattle2
.next:
farscall PhoneScript_Random3
- if_equal $0, WadeFoundRare
+ if_equal 0, WadeFoundRare
farjump Phone_GenericCall_Male
Wade_ContestToday:
@@ -736,7 +736,7 @@ WadeTuesdayNight:
setflag ENGINE_WADE_TUESDAY_NIGHT
WadeWantsBattle2:
- landmarktotext ROUTE_31, $2
+ landmarktotext ROUTE_31, MEM_BUFFER_2
setflag ENGINE_WADE
farjump PhoneScript_WantsToBattle_Male
@@ -745,16 +745,16 @@ WadeFoundRare:
WadeHasItem2:
setflag ENGINE_WADE_HAS_ITEM
- landmarktotext ROUTE_31, $2
+ landmarktotext ROUTE_31, MEM_BUFFER_2
clearevent EVENT_WADE_HAS_BERRY
clearevent EVENT_WADE_HAS_PSNCUREBERRY
clearevent EVENT_WADE_HAS_PRZCUREBERRY
clearevent EVENT_WADE_HAS_BITTER_BERRY
- random $4
- if_equal $0, .Berry
- if_equal $1, .PsnCureBerry
- if_equal $2, .PrzCureBerry
- if_equal $3, .Bitterberry
+ random 4
+ if_equal 0, .Berry
+ if_equal 1, .PsnCureBerry
+ if_equal 2, .PrzCureBerry
+ if_equal 3, .Bitterberry
.Berry:
setevent EVENT_WADE_HAS_BERRY
@@ -777,7 +777,7 @@ WadeHasItem2:
; Ralph
RalphPhoneScript1:
- trainertotext FISHER, RALPH1, $0
+ trainertotext FISHER, RALPH1, MEM_BUFFER_0
checkflag ENGINE_RALPH
iftrue Ralph_Rematch
farscall PhoneScript_AnswerPhone_Male
@@ -793,15 +793,15 @@ Ralph_CheckSwarm:
farjump UnknownScript_0xa0940
Ralph_Rematch:
- landmarktotext ROUTE_32, $2
+ landmarktotext ROUTE_32, MEM_BUFFER_2
farjump UnknownScript_0xa0a55
Ralph_ReportSwarm:
- landmarktotext ROUTE_32, $2
+ landmarktotext ROUTE_32, MEM_BUFFER_2
farjump UnknownScript_0xa0af5
RalphPhoneScript2:
- trainertotext FISHER, RALPH1, $0
+ trainertotext FISHER, RALPH1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_FLYPOINT_GOLDENROD
iffalse Ralph_CheckSwarm2
@@ -810,16 +810,16 @@ RalphPhoneScript2:
checkflag ENGINE_RALPH_WEDNESDAY_MORNING
iftrue Ralph_CheckSwarm2
farscall PhoneScript_Random2
- if_equal $0, Ralph_FightMe
+ if_equal 0, Ralph_FightMe
Ralph_CheckSwarm2:
farscall PhoneScript_Random5
- if_equal $0, Ralph_SetUpSwarm
+ if_equal 0, Ralph_SetUpSwarm
farjump Phone_GenericCall_Male
Ralph_WednesdayMorning:
setflag ENGINE_RALPH_WEDNESDAY_MORNING
Ralph_FightMe:
- landmarktotext ROUTE_32, $2
+ landmarktotext ROUTE_32, MEM_BUFFER_2
setflag ENGINE_RALPH
farjump PhoneScript_WantsToBattle_Male
@@ -827,8 +827,8 @@ Ralph_SetUpSwarm:
checkflag ENGINE_SPECIAL_WILDDATA
iftrue .Generic
setflag ENGINE_SPECIAL_WILDDATA
- pokenamemem QWILFISH, $1
- landmarktotext ROUTE_32, $2
+ pokenamemem QWILFISH, MEM_BUFFER_1
+ landmarktotext ROUTE_32, MEM_BUFFER_2
writebyte FISHSWARM_QWILFISH
special Special_ActivateFishingSwarm
farjump UnknownScript_0xa05d6
@@ -839,7 +839,7 @@ Ralph_SetUpSwarm:
; Liz
LizPhoneScript1:
- trainertotext PICNICKER, LIZ1, $0
+ trainertotext PICNICKER, LIZ1, MEM_BUFFER_0
checkflag ENGINE_LIZ
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Female
@@ -851,17 +851,17 @@ LizPhoneScript1:
iftrue LizThursdayAfternoon
.NotThursday:
- special RandomPhoneMon
+ special Special_RandomPhoneMon
farjump UnknownScript_0xa0948
.WantsBattle:
- landmarktotext ROUTE_32, $2
+ landmarktotext ROUTE_32, MEM_BUFFER_2
farjump UnknownScript_0xa0a5a
LizPhoneScript2:
- trainertotext PICNICKER, LIZ1, $0
+ trainertotext PICNICKER, LIZ1, MEM_BUFFER_0
farscall PhoneScript_Random4
- if_equal $0, LizWrongNumber
+ if_equal 0, LizWrongNumber
farscall PhoneScript_GreetPhone_Female
checkflag ENGINE_LIZ
iftrue .next
@@ -870,11 +870,11 @@ LizPhoneScript2:
.next:
farscall PhoneScript_Random2
- if_equal $0, LizGossip
+ if_equal 0, LizGossip
checkflag ENGINE_FLYPOINT_GOLDENROD
iffalse .Generic
farscall PhoneScript_Random2
- if_equal $0, LizWantsBattle
+ if_equal 0, LizWantsBattle
.Generic:
farjump Phone_GenericCall_Female
@@ -883,7 +883,7 @@ LizThursdayAfternoon:
setflag ENGINE_LIZ_THURSDAY_AFTERNOON
LizWantsBattle:
- landmarktotext ROUTE_32, $2
+ landmarktotext ROUTE_32, MEM_BUFFER_2
setflag ENGINE_LIZ
farjump PhoneScript_WantsToBattle_Female
@@ -891,51 +891,51 @@ LizWrongNumber:
farjump LizWrongNumberScript
LizGossip:
- random $9
- if_equal $0, .CoolTrainerM
- if_equal $1, .Beauty
- if_equal $2, .Grunt
- if_equal $3, .Teacher
- if_equal $4, .SwimmerF
- if_equal $5, .KimonoGirl
- if_equal $6, .Skier
- if_equal $7, .Medium
- if_equal $8, .PokefanM
+ random 9
+ if_equal 0, .CoolTrainerM
+ if_equal 1, .Beauty
+ if_equal 2, .Grunt
+ if_equal 3, .Teacher
+ if_equal 4, .SwimmerF
+ if_equal 5, .KimonoGirl
+ if_equal 6, .Skier
+ if_equal 7, .Medium
+ if_equal 8, .PokefanM
.CoolTrainerM:
- trainerclassname COOLTRAINERM, $1
+ trainerclassname COOLTRAINERM, NICK
jump LizGossipScript
.Beauty:
- trainerclassname BEAUTY, $1
+ trainerclassname BEAUTY, VICTORIA
jump LizGossipScript
.Grunt:
- trainerclassname GRUNTM, $1
+ trainerclassname GRUNTM, GRUNTM_1
jump LizGossipScript
.Teacher:
- trainerclassname TEACHER, $1
+ trainerclassname TEACHER, COLETTE
jump LizGossipScript
.SwimmerF:
- trainerclassname SWIMMERF, $1
+ trainerclassname SWIMMERF, ELAINE
jump LizGossipScript
.KimonoGirl:
- trainerclassname KIMONO_GIRL, $1
+ trainerclassname KIMONO_GIRL, NAOKO1
jump LizGossipScript
.Skier:
- trainerclassname SKIER, $1
+ trainerclassname SKIER, ROXANNE
jump LizGossipScript
.Medium:
- trainerclassname MEDIUM, $1
+ trainerclassname MEDIUM, MARTHA
jump LizGossipScript
.PokefanM:
- trainerclassname POKEFANM, $1
+ trainerclassname POKEFANM, WILLIAM
jump LizGossipScript
LizGossipScript:
@@ -944,7 +944,7 @@ LizGossipScript:
; Anthony
AnthonyPhoneScript1:
- trainertotext HIKER, ANTHONY2, $0
+ trainertotext HIKER, ANTHONY2, MEM_BUFFER_0
checkflag ENGINE_ANTHONY
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -961,15 +961,15 @@ AnthonyPhoneScript1:
farjump UnknownScript_0xa0950
.WantsBattle:
- landmarktotext ROUTE_33, $2
+ landmarktotext ROUTE_33, MEM_BUFFER_2
farjump UnknownScript_0xa0a5f
.AlreadySwarming:
- landmarktotext ROUTE_33, $2
+ landmarktotext ROUTE_33, MEM_BUFFER_2
farjump UnknownScript_0xa0afa
AnthonyPhoneScript2:
- trainertotext HIKER, ANTHONY2, $0
+ trainertotext HIKER, ANTHONY2, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_FLYPOINT_GOLDENROD
iffalse .TriesSwarm
@@ -978,18 +978,18 @@ AnthonyPhoneScript2:
checkflag ENGINE_ANTHONY_FRIDAY_NIGHT
iftrue .TriesSwarm
farscall PhoneScript_Random2
- if_equal $0, AnthonyWantsBattle
+ if_equal 0, AnthonyWantsBattle
.TriesSwarm:
farscall PhoneScript_Random5
- if_equal $0, AnthonyTriesDunsparceSwarm
+ if_equal 0, AnthonyTriesDunsparceSwarm
farjump Phone_GenericCall_Male
AnthonyFridayNight:
setflag ENGINE_ANTHONY_FRIDAY_NIGHT
AnthonyWantsBattle:
- landmarktotext ROUTE_33, $2
+ landmarktotext ROUTE_33, MEM_BUFFER_2
setflag ENGINE_ANTHONY
farjump PhoneScript_WantsToBattle_Male
@@ -997,9 +997,9 @@ AnthonyTriesDunsparceSwarm:
checkflag ENGINE_DUNSPARCE_SWARM
iftrue .Generic
setflag ENGINE_DUNSPARCE_SWARM
- pokenamemem DUNSPARCE, $1
+ pokenamemem DUNSPARCE, MEM_BUFFER_1
swarm SWARM_DUNSPARCE, DARK_CAVE_VIOLET_ENTRANCE
- landmarktotext DARK_CAVE, $2
+ landmarktotext DARK_CAVE, MEM_BUFFER_2
farjump UnknownScript_0xa05de
.Generic:
@@ -1008,7 +1008,7 @@ AnthonyTriesDunsparceSwarm:
; Todd
ToddPhoneScript1:
- trainertotext CAMPER, TODD1, $0
+ trainertotext CAMPER, TODD1, MEM_BUFFER_0
checkflag ENGINE_TODD
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -1025,14 +1025,14 @@ ToddPhoneScript1:
farjump UnknownScript_0xa0958
.WantsBattle:
- landmarktotext ROUTE_34, $2
+ landmarktotext ROUTE_34, MEM_BUFFER_2
farjump UnknownScript_0xa0a64
.SaleOn:
farjump UnknownScript_0xa0b04
ToddPhoneScript2:
- trainertotext CAMPER, TODD1, $0
+ trainertotext CAMPER, TODD1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_TODD
iftrue .TryForSale
@@ -1041,22 +1041,22 @@ ToddPhoneScript2:
checkflag ENGINE_FLYPOINT_GOLDENROD
iffalse ToddNoGoldenrod
farscall PhoneScript_Random2
- if_equal $0, ToddWantsBattle
+ if_equal 0, ToddWantsBattle
.TryForSale:
farscall PhoneScript_Random2
- if_equal $0, ToddDeptStoreSale
+ if_equal 0, ToddDeptStoreSale
ToddNoGoldenrod:
farscall PhoneScript_Random3
- if_equal $0, ToddFoundRare
+ if_equal 0, ToddFoundRare
farjump Phone_GenericCall_Male
ToddSaturdayMorning:
setflag ENGINE_TODD_SATURDAY_MORNING
ToddWantsBattle:
- landmarktotext ROUTE_34, $2
+ landmarktotext ROUTE_34, MEM_BUFFER_2
setflag ENGINE_TODD
farjump PhoneScript_WantsToBattle_Male
@@ -1070,7 +1070,7 @@ ToddDeptStoreSale:
; Gina
GinaPhoneScript1:
- trainertotext PICNICKER, GINA1, $0
+ trainertotext PICNICKER, GINA1, MEM_BUFFER_0
checkflag ENGINE_GINA
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Female
@@ -1092,15 +1092,15 @@ GinaPhoneScript1:
farjump UnknownScript_0xa05c6
.WantsBattle:
- landmarktotext ROUTE_34, $2
+ landmarktotext ROUTE_34, MEM_BUFFER_2
farjump UnknownScript_0xa0a69
.HasLeafStone:
- landmarktotext ROUTE_34, $2
+ landmarktotext ROUTE_34, MEM_BUFFER_2
farjump UnknownScript_0xa0abd
GinaPhoneScript2:
- trainertotext PICNICKER, GINA1, $0
+ trainertotext PICNICKER, GINA1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Female
checkflag ENGINE_ROCKETS_IN_RADIO_TOWER
iftrue GinaRockets
@@ -1113,15 +1113,15 @@ GinaPhoneScript2:
checkevent EVENT_GINA_GAVE_LEAF_STONE
iftrue .GaveLeafStone
farscall PhoneScript_Random2
- if_equal $0, GinaHasLeafStone
+ if_equal 0, GinaHasLeafStone
.GaveLeafStone:
farscall PhoneScript_Random11
- if_equal $0, GinaHasLeafStone
+ if_equal 0, GinaHasLeafStone
checkflag ENGINE_FLYPOINT_GOLDENROD
iffalse .Generic
farscall PhoneScript_Random3
- if_equal $0, GinaWantsBattle
+ if_equal 0, GinaWantsBattle
.Generic:
farjump Phone_GenericCall_Female
@@ -1130,7 +1130,7 @@ GinaSundayDay:
setflag ENGINE_GINA_SUNDAY_AFTERNOON
GinaWantsBattle:
- landmarktotext ROUTE_34, $2
+ landmarktotext ROUTE_34, MEM_BUFFER_2
setflag ENGINE_GINA
farjump PhoneScript_WantsToBattle_Female
@@ -1139,13 +1139,13 @@ GinaRockets:
GinaHasLeafStone:
setflag ENGINE_GINA_HAS_LEAF_STONE
- landmarktotext ROUTE_34, $2
+ landmarktotext ROUTE_34, MEM_BUFFER_2
farjump PhoneScript_FoundItem_Female
; Irwin
IrwinPhoneScript1:
- trainertotext JUGGLER, IRWIN1, $0
+ trainertotext JUGGLER, IRWIN1, MEM_BUFFER_0
farscall PhoneScript_AnswerPhone_Male
checkflag ENGINE_ROCKETS_IN_RADIO_TOWER
iftrue .Rockets
@@ -1155,7 +1155,7 @@ IrwinPhoneScript1:
farjump IrwinRocketRumor
IrwinPhoneScript2:
- trainertotext JUGGLER, IRWIN1, $0
+ trainertotext JUGGLER, IRWIN1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_ROCKETS_IN_RADIO_TOWER
iftrue .Rockets
@@ -1167,7 +1167,7 @@ IrwinPhoneScript2:
; Arnie
ArniePhoneScript1:
- trainertotext BUG_CATCHER, ARNIE1, $0
+ trainertotext BUG_CATCHER, ARNIE1, MEM_BUFFER_0
checkflag ENGINE_ARNIE
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -1184,35 +1184,35 @@ ArniePhoneScript1:
farjump UnknownScript_0xa0968
.WantsBattle:
- landmarktotext ROUTE_35, $2
+ landmarktotext ROUTE_35, MEM_BUFFER_2
farjump UnknownScript_0xa0a6e
.AlreadySwarming:
- landmarktotext ROUTE_35, $2
+ landmarktotext ROUTE_35, MEM_BUFFER_2
farjump UnknownScript_0xa0aff
ArniePhoneScript2:
- trainertotext BUG_CATCHER, ARNIE1, $0
+ trainertotext BUG_CATCHER, ARNIE1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_ARNIE
iftrue .Swarm
checkflag ENGINE_ARNIE_TUESDAY_MORNING
iftrue .Swarm
farscall PhoneScript_Random2
- if_equal $0, ArnieWantsBattle
+ if_equal 0, ArnieWantsBattle
.Swarm:
farscall PhoneScript_Random5
- if_equal $0, ArnieYanmaSwarm
+ if_equal 0, ArnieYanmaSwarm
farscall PhoneScript_Random3
- if_equal $0, ArnieFoundRare
+ if_equal 0, ArnieFoundRare
farjump Phone_GenericCall_Male
ArnieTuesdayMorning:
setflag ENGINE_ARNIE_TUESDAY_MORNING
ArnieWantsBattle:
- landmarktotext ROUTE_35, $2
+ landmarktotext ROUTE_35, MEM_BUFFER_2
setflag ENGINE_ARNIE
farjump PhoneScript_WantsToBattle_Male
@@ -1220,9 +1220,9 @@ ArnieYanmaSwarm: ; start swarm
checkflag ENGINE_YANMA_SWARM
iftrue ArnieYanmaAlreadySwarming
setflag ENGINE_YANMA_SWARM
- pokenamemem YANMA, $1
+ pokenamemem YANMA, MEM_BUFFER_1
swarm SWARM_YANMA, ROUTE_35
- landmarktotext ROUTE_35, $2
+ landmarktotext ROUTE_35, MEM_BUFFER_2
farjump UnknownScript_0xa05ce
ArnieFoundRare:
@@ -1234,7 +1234,7 @@ ArnieYanmaAlreadySwarming:
; Alan
AlanPhoneScript1:
- trainertotext SCHOOLBOY, ALAN1, $0
+ trainertotext SCHOOLBOY, ALAN1, MEM_BUFFER_0
checkflag ENGINE_ALAN
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -1251,15 +1251,15 @@ AlanPhoneScript1:
farjump UnknownScript_0xa0970
.WantsBattle:
- landmarktotext ROUTE_36, $2
+ landmarktotext ROUTE_36, MEM_BUFFER_2
farjump UnknownScript_0xa0a73
.FireStone:
- landmarktotext ROUTE_36, $2
+ landmarktotext ROUTE_36, MEM_BUFFER_2
farjump UnknownScript_0xa0ac5
AlanPhoneScript2:
- trainertotext SCHOOLBOY, ALAN1, $0
+ trainertotext SCHOOLBOY, ALAN1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_ALAN
iftrue AlanGenericCall
@@ -1268,15 +1268,15 @@ AlanPhoneScript2:
checkflag ENGINE_ALAN_HAS_FIRE_STONE
iftrue AlanGenericCall
farscall PhoneScript_Random3
- if_equal $0, AlanWantsBattle
+ if_equal 0, AlanWantsBattle
checkevent EVENT_ALAN_GAVE_FIRE_STONE
iftrue .FireStone
farscall PhoneScript_Random2
- if_equal $0, AlanHasFireStone
+ if_equal 0, AlanHasFireStone
.FireStone:
farscall PhoneScript_Random11
- if_equal $0, AlanHasFireStone
+ if_equal 0, AlanHasFireStone
AlanGenericCall:
farjump Phone_GenericCall_Male
@@ -1285,19 +1285,19 @@ AlanWednesdayDay:
setflag ENGINE_ALAN_WEDNESDAY_AFTERNOON
AlanWantsBattle:
- landmarktotext ROUTE_36, $2
+ landmarktotext ROUTE_36, MEM_BUFFER_2
setflag ENGINE_ALAN
farjump PhoneScript_WantsToBattle_Male
AlanHasFireStone:
setflag ENGINE_ALAN_HAS_FIRE_STONE
- landmarktotext ROUTE_36, $2
+ landmarktotext ROUTE_36, MEM_BUFFER_2
farjump PhoneScript_FoundItem_Male
; Dana
DanaPhoneScript1:
- trainertotext LASS, DANA1, $0
+ trainertotext LASS, DANA1, MEM_BUFFER_0
checkflag ENGINE_DANA
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Female
@@ -1314,15 +1314,15 @@ DanaPhoneScript1:
farjump UnknownScript_0xa0978
.WantsBattle:
- landmarktotext ROUTE_38, $2
+ landmarktotext ROUTE_38, MEM_BUFFER_2
farjump UnknownScript_0xa0a78
.HasThunderstone:
- landmarktotext ROUTE_38, $2
+ landmarktotext ROUTE_38, MEM_BUFFER_2
farjump UnknownScript_0xa0acd
DanaPhoneScript2:
- trainertotext LASS, DANA1, $0
+ trainertotext LASS, DANA1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Female
checkflag ENGINE_DANA
iftrue .Generic
@@ -1331,26 +1331,26 @@ DanaPhoneScript2:
checkflag ENGINE_DANA_HAS_THUNDERSTONE
iftrue .Generic
farscall PhoneScript_Random3
- if_equal $0, DanaWantsBattle
+ if_equal 0, DanaWantsBattle
checkevent EVENT_DANA_GAVE_THUNDERSTONE
iftrue .Thunderstone
farscall PhoneScript_Random2
- if_equal $0, DanaHasThunderstone
+ if_equal 0, DanaHasThunderstone
.Thunderstone:
farscall PhoneScript_Random11
- if_equal $0, DanaHasThunderstone
+ if_equal 0, DanaHasThunderstone
.Generic:
farscall PhoneScript_Random3
- if_equal $0, DanaFoundRare
+ if_equal 0, DanaFoundRare
farjump Phone_GenericCall_Female
DanaThursdayNight:
setflag ENGINE_DANA_THURSDAY_NIGHT
DanaWantsBattle:
- landmarktotext ROUTE_38, $2
+ landmarktotext ROUTE_38, MEM_BUFFER_2
setflag ENGINE_DANA
farjump PhoneScript_WantsToBattle_Female
@@ -1359,13 +1359,13 @@ DanaFoundRare:
DanaHasThunderstone:
setflag ENGINE_DANA_HAS_THUNDERSTONE
- landmarktotext ROUTE_38, $2
+ landmarktotext ROUTE_38, MEM_BUFFER_2
farjump PhoneScript_FoundItem_Female
; Chad
ChadPhoneScript1:
- trainertotext SCHOOLBOY, CHAD1, $0
+ trainertotext SCHOOLBOY, CHAD1, MEM_BUFFER_0
checkflag ENGINE_CHAD
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -1380,31 +1380,31 @@ ChadPhoneScript1:
farjump UnknownScript_0xa0980
.WantsBattle:
- landmarktotext ROUTE_38, $2
+ landmarktotext ROUTE_38, MEM_BUFFER_2
farjump UnknownScript_0xa0a7d
ChadPhoneScript2:
- trainertotext SCHOOLBOY, CHAD1, $0
+ trainertotext SCHOOLBOY, CHAD1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
farscall PhoneScript_Random2
- if_equal $0, ChadOakGossip
+ if_equal 0, ChadOakGossip
checkflag ENGINE_CHAD
iftrue .Generic
checkflag ENGINE_CHAD_FRIDAY_MORNING
iftrue .Generic
farscall PhoneScript_Random2
- if_equal $0, ChadWantsBattle
+ if_equal 0, ChadWantsBattle
.Generic:
farscall PhoneScript_Random3
- if_equal $0, ChadFoundRare
+ if_equal 0, ChadFoundRare
farjump Phone_GenericCall_Male
ChadFridayMorning:
setflag ENGINE_CHAD_FRIDAY_MORNING
ChadWantsBattle:
- landmarktotext ROUTE_38, $2
+ landmarktotext ROUTE_38, MEM_BUFFER_2
setflag ENGINE_CHAD
farjump PhoneScript_WantsToBattle_Male
@@ -1415,12 +1415,12 @@ ChadOakGossip:
farjump ChadOakGossipScript
DerekPhoneScript1:
- trainertotext POKEFANM, DEREK1, $0
+ trainertotext POKEFANM, DEREK1, MEM_BUFFER_0
farscall PhoneScript_AnswerPhone_Male
checkflag ENGINE_DEREK_HAS_NUGGET
iftrue .Nugget
farscall PhoneScript_Random2
- if_equal $0, .NoContest
+ if_equal 0, .NoContest
checkflag ENGINE_DAILY_BUG_CONTEST
iftrue .NoContest
checkcode VAR_WEEKDAY
@@ -1435,14 +1435,14 @@ DerekPhoneScript1:
farjump PhoneScript_BugCatchingContest
.Nugget:
- landmarktotext ROUTE_39, $2
+ landmarktotext ROUTE_39, MEM_BUFFER_2
farjump UnknownScript_0xa0ad5
DerekPhoneScript2:
- trainertotext POKEFANM, DEREK1, $0
+ trainertotext POKEFANM, DEREK1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
farscall PhoneScript_Random2
- if_equal $0, .NoContest
+ if_equal 0, .NoContest
checkflag ENGINE_DAILY_BUG_CONTEST
iftrue .NoContest
checkcode VAR_WEEKDAY
@@ -1452,7 +1452,7 @@ DerekPhoneScript2:
.NoContest:
farscall PhoneScript_Random4
- if_equal $0, .Nugget
+ if_equal 0, .Nugget
farjump Phone_GenericCall_Male
.ContestToday:
@@ -1460,11 +1460,11 @@ DerekPhoneScript2:
.Nugget:
setflag ENGINE_DEREK_HAS_NUGGET
- landmarktotext ROUTE_39, $2
+ landmarktotext ROUTE_39, MEM_BUFFER_2
farjump PhoneScript_FoundItem_Male
TullyPhoneScript1:
- trainertotext FISHER, TULLY1, $0
+ trainertotext FISHER, TULLY1, MEM_BUFFER_0
checkflag ENGINE_TULLY
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -1481,15 +1481,15 @@ TullyPhoneScript1:
farjump UnknownScript_0xa0990
.WantsBattle:
- landmarktotext ROUTE_42, $2
+ landmarktotext ROUTE_42, MEM_BUFFER_2
farjump UnknownScript_0xa0a82
TullyHasWaterStone:
- landmarktotext ROUTE_42, $2
+ landmarktotext ROUTE_42, MEM_BUFFER_2
farjump UnknownScript_0xa0add
TullyPhoneScript2:
- trainertotext FISHER, TULLY1, $0
+ trainertotext FISHER, TULLY1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_TULLY
iftrue .Generic
@@ -1498,15 +1498,15 @@ TullyPhoneScript2:
checkflag ENGINE_TULLY_HAS_WATER_STONE
iftrue .Generic
farscall PhoneScript_Random3
- if_equal $0, TullyWantsBattle
+ if_equal 0, TullyWantsBattle
checkevent EVENT_TULLY_GAVE_WATER_STONE
iftrue .WaterStone
farscall PhoneScript_Random2
- if_equal $0, TullyFoundWaterStone
+ if_equal 0, TullyFoundWaterStone
.WaterStone:
farscall PhoneScript_Random11
- if_equal $0, TullyFoundWaterStone
+ if_equal 0, TullyFoundWaterStone
.Generic:
farjump Phone_GenericCall_Male
@@ -1515,17 +1515,17 @@ TullySundayNight:
setflag ENGINE_TULLY_SUNDAY_NIGHT
TullyWantsBattle:
- landmarktotext ROUTE_42, $2
+ landmarktotext ROUTE_42, MEM_BUFFER_2
setflag ENGINE_TULLY
farjump PhoneScript_WantsToBattle_Male
TullyFoundWaterStone:
setflag ENGINE_TULLY_HAS_WATER_STONE
- landmarktotext ROUTE_42, $2
+ landmarktotext ROUTE_42, MEM_BUFFER_2
farjump PhoneScript_FoundItem_Male
BrentPhoneScript1:
- trainertotext POKEMANIAC, BRENT1, $0
+ trainertotext POKEMANIAC, BRENT1, MEM_BUFFER_0
checkflag ENGINE_BRENT
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -1540,20 +1540,20 @@ BrentPhoneScript1:
farjump UnknownScript_0xa0998
.WantsBattle:
- landmarktotext ROUTE_43, $2
+ landmarktotext ROUTE_43, MEM_BUFFER_2
farjump UnknownScript_0xa0a87
BrentPhoneScript2:
- trainertotext POKEMANIAC, BRENT1, $0
+ trainertotext POKEMANIAC, BRENT1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
farscall PhoneScript_Random2
- if_equal $0, BrentBillTrivia
+ if_equal 0, BrentBillTrivia
checkflag ENGINE_BRENT
iftrue .Generic
checkflag ENGINE_BRENT_MONDAY_MORNING
iftrue .Generic
farscall PhoneScript_Random2
- if_equal $0, BrentWantsBattle
+ if_equal 0, BrentWantsBattle
.Generic:
farjump Phone_GenericCall_Male
@@ -1562,7 +1562,7 @@ BrentMondayMorning:
setflag ENGINE_BRENT_MONDAY_MORNING
BrentWantsBattle:
- landmarktotext ROUTE_43, $2
+ landmarktotext ROUTE_43, MEM_BUFFER_2
setflag ENGINE_BRENT
farjump PhoneScript_WantsToBattle_Male
@@ -1570,7 +1570,7 @@ BrentBillTrivia:
farjump BrentBillTriviaScript
TiffanyPhoneScript1:
- trainertotext PICNICKER, TIFFANY3, $0
+ trainertotext PICNICKER, TIFFANY3, MEM_BUFFER_0
checkflag ENGINE_TIFFANY
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Female
@@ -1587,17 +1587,17 @@ TiffanyPhoneScript1:
farjump UnknownScript_0xa09a0
.WantsBattle:
- landmarktotext ROUTE_43, $2
+ landmarktotext ROUTE_43, MEM_BUFFER_2
farjump UnknownScript_0xa0a8c
.HasItem:
- landmarktotext ROUTE_43, $2
+ landmarktotext ROUTE_43, MEM_BUFFER_2
farjump UnknownScript_0xa0ae5
TiffanyPhoneScript2:
- trainertotext PICNICKER, TIFFANY3, $0
+ trainertotext PICNICKER, TIFFANY3, MEM_BUFFER_0
farscall PhoneScript_Random4
- if_equal $0, TiffanysFamilyMembers
+ if_equal 0, TiffanysFamilyMembers
farscall PhoneScript_GreetPhone_Female
checkflag ENGINE_TIFFANY
iftrue TiffanyGenericCall
@@ -1606,15 +1606,15 @@ TiffanyPhoneScript2:
checkflag ENGINE_TIFFANY_HAS_PINK_BOW
iftrue TiffanyGenericCall
farscall PhoneScript_Random3
- if_equal $0, TiffanyWantsBattle
+ if_equal 0, TiffanyWantsBattle
checkevent EVENT_TIFFANY_GAVE_PINK_BOW
iftrue .PinkBow
farscall PhoneScript_Random2
- if_equal $0, TiffanyHasPinkBow
+ if_equal 0, TiffanyHasPinkBow
.PinkBow:
farscall PhoneScript_Random11
- if_equal $0, TiffanyHasPinkBow
+ if_equal 0, TiffanyHasPinkBow
TiffanyGenericCall:
farjump Phone_GenericCall_Female
@@ -1623,41 +1623,41 @@ TiffanyTuesdayAfternoon:
setflag ENGINE_TIFFANY_TUESDAY_AFTERNOON
TiffanyWantsBattle:
- landmarktotext ROUTE_43, $2
+ landmarktotext ROUTE_43, MEM_BUFFER_2
setflag ENGINE_TIFFANY
farjump PhoneScript_WantsToBattle_Female
TiffanysFamilyMembers:
- random $6
- if_equal $0, .Grandma
- if_equal $1, .Grandpa
- if_equal $2, .Mom
- if_equal $3, .Dad
- if_equal $4, .Sister
- if_equal $5, .Brother
+ random 6
+ if_equal 0, .Grandma
+ if_equal 1, .Grandpa
+ if_equal 2, .Mom
+ if_equal 3, .Dad
+ if_equal 4, .Sister
+ if_equal 5, .Brother
.Grandma:
- stringtotext GrandmaString, $1
+ stringtotext GrandmaString, MEM_BUFFER_1
jump TiffanysPoorClefairy
.Grandpa:
- stringtotext GrandpaString, $1
+ stringtotext GrandpaString, MEM_BUFFER_1
jump TiffanysPoorClefairy
.Mom:
- stringtotext MomString, $1
+ stringtotext MomString, MEM_BUFFER_1
jump TiffanysPoorClefairy
.Dad:
- stringtotext DadString, $1
+ stringtotext DadString, MEM_BUFFER_1
jump TiffanysPoorClefairy
.Sister:
- stringtotext SisterString, $1
+ stringtotext SisterString, MEM_BUFFER_1
jump TiffanysPoorClefairy
.Brother:
- stringtotext BrotherString, $1
+ stringtotext BrotherString, MEM_BUFFER_1
jump TiffanysPoorClefairy
TiffanysPoorClefairy:
@@ -1665,13 +1665,13 @@ TiffanysPoorClefairy:
TiffanyHasPinkBow:
setflag ENGINE_TIFFANY_HAS_PINK_BOW
- landmarktotext ROUTE_43, $2
+ landmarktotext ROUTE_43, MEM_BUFFER_2
farjump PhoneScript_FoundItem_Female
; Vance
VancePhoneScript1:
- trainertotext BIRD_KEEPER, VANCE1, $0
+ trainertotext BIRD_KEEPER, VANCE1, MEM_BUFFER_0
checkflag ENGINE_VANCE
iftrue VanceWantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -1686,19 +1686,19 @@ VancePhoneScript1:
farjump VanceLookingForward
VanceWantsBattle:
- landmarktotext ROUTE_44, $2
+ landmarktotext ROUTE_44, MEM_BUFFER_2
farjump VanceHurryHurry
VancePhoneScript2:
- trainertotext BIRD_KEEPER, VANCE1, $0
+ trainertotext BIRD_KEEPER, VANCE1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_VANCE
iftrue .WantsBattle
checkflag ENGINE_VANCE_WEDNESDAY_NIGHT
iftrue .WantsBattle
farscall PhoneScript_Random3
- if_equal $0, VanceWantsRematch
- if_equal $1, VanceWantsRematch
+ if_equal 0, VanceWantsRematch
+ if_equal 1, VanceWantsRematch
.WantsBattle:
farjump Phone_GenericCall_Male
@@ -1707,12 +1707,12 @@ VanceWednesdayNight:
setflag ENGINE_VANCE_WEDNESDAY_NIGHT
VanceWantsRematch:
- landmarktotext ROUTE_44, $2
+ landmarktotext ROUTE_44, MEM_BUFFER_2
setflag ENGINE_VANCE
farjump PhoneScript_WantsToBattle_Male
WiltonPhoneScript1:
- trainertotext FISHER, WILTON1, $0
+ trainertotext FISHER, WILTON1, MEM_BUFFER_0
checkflag ENGINE_WILTON
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -1729,15 +1729,15 @@ WiltonPhoneScript1:
farjump WiltonHaventFoundAnything
.WantsBattle:
- landmarktotext ROUTE_44, $2
+ landmarktotext ROUTE_44, MEM_BUFFER_2
farjump WiltonNotBiting
.HasItem:
- landmarktotext ROUTE_44, $2
+ landmarktotext ROUTE_44, MEM_BUFFER_2
farjump WiltonWantThis
WiltonPhoneScript2:
- trainertotext FISHER, WILTON1, $0
+ trainertotext FISHER, WILTON1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_WILTON
iftrue .GenericCall
@@ -1746,9 +1746,9 @@ WiltonPhoneScript2:
checkflag ENGINE_WILTON_HAS_ITEM
iftrue .GenericCall
farscall PhoneScript_Random2
- if_equal $0, WiltonWantsBattle
+ if_equal 0, WiltonWantsBattle
farscall PhoneScript_Random2
- if_equal $0, WiltonHasItem
+ if_equal 0, WiltonHasItem
.GenericCall:
farjump Phone_GenericCall_Male
@@ -1757,20 +1757,20 @@ WiltonThursdayMorning:
setflag ENGINE_WILTON_THURSDAY_MORNING
WiltonWantsBattle:
- landmarktotext ROUTE_44, $2
+ landmarktotext ROUTE_44, MEM_BUFFER_2
setflag ENGINE_WILTON
farjump PhoneScript_WantsToBattle_Male
WiltonHasItem:
setflag ENGINE_WILTON_HAS_ITEM
- landmarktotext ROUTE_44, $2
+ landmarktotext ROUTE_44, MEM_BUFFER_2
clearevent EVENT_WILTON_HAS_ULTRA_BALL
clearevent EVENT_WILTON_HAS_GREAT_BALL
clearevent EVENT_WILTON_HAS_POKE_BALL
- random $5
- if_equal $0, .UltraBall
- random $3
- if_equal $0, .GreatBall
+ random 5
+ if_equal 0, .UltraBall
+ random 3
+ if_equal 0, .GreatBall
jump .PokeBall
.UltraBall:
@@ -1790,19 +1790,19 @@ WiltonHasItem:
; Kenji
KenjiPhoneScript1:
- trainertotext BLACKBELT_T, KENJI3, $0
+ trainertotext BLACKBELT_T, KENJI3, MEM_BUFFER_0
farscall PhoneScript_AnswerPhone_Male
farjump KenjiAnswerPhoneScript
KenjiPhoneScript2:
- trainertotext BLACKBELT_T, KENJI3, $0
+ trainertotext BLACKBELT_T, KENJI3, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
farjump KenjiCallingPhoneScript
; Parry
ParryPhoneScript1:
- trainertotext HIKER, PARRY1, $0
+ trainertotext HIKER, PARRY1, MEM_BUFFER_0
checkflag ENGINE_PARRY
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Male
@@ -1817,19 +1817,19 @@ ParryPhoneScript1:
farjump ParryBattleWithMe
.WantsBattle:
- landmarktotext ROUTE_45, $2
+ landmarktotext ROUTE_45, MEM_BUFFER_2
farjump ParryHaventYouGottenTo
ParryPhoneScript2:
- trainertotext HIKER, PARRY1, $0
+ trainertotext HIKER, PARRY1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Male
checkflag ENGINE_PARRY
iftrue .GenericCall
checkflag ENGINE_PARRY_FRIDAY_AFTERNOON
iftrue .GenericCall
farscall PhoneScript_Random2
- if_equal $0, ParryWantsBattle
- if_equal $1, ParryWantsBattle
+ if_equal 0, ParryWantsBattle
+ if_equal 1, ParryWantsBattle
.GenericCall:
farjump Phone_GenericCall_Male
@@ -1838,14 +1838,14 @@ ParryFridayDay:
setflag ENGINE_PARRY_FRIDAY_AFTERNOON
ParryWantsBattle:
- landmarktotext ROUTE_45, $2
+ landmarktotext ROUTE_45, MEM_BUFFER_2
setflag ENGINE_PARRY
farjump PhoneScript_WantsToBattle_Male
; Erin
ErinPhoneScript1:
- trainertotext PICNICKER, ERIN1, $0
+ trainertotext PICNICKER, ERIN1, MEM_BUFFER_0
checkflag ENGINE_ERIN
iftrue .WantsBattle
farscall PhoneScript_AnswerPhone_Female
@@ -1860,19 +1860,19 @@ ErinPhoneScript1:
farjump ErinWorkingHardScript
.WantsBattle:
- landmarktotext ROUTE_46, $2
+ landmarktotext ROUTE_46, MEM_BUFFER_2
farjump ErinComeBattleScript
ErinPhoneScript2:
- trainertotext PICNICKER, ERIN1, $0
+ trainertotext PICNICKER, ERIN1, MEM_BUFFER_0
farscall PhoneScript_GreetPhone_Female
checkflag ENGINE_ERIN
iftrue .GenericCall
checkflag ENGINE_ERIN_SATURDAY_NIGHT
iftrue .GenericCall
farscall PhoneScript_Random3
- if_equal $0, ErinWantsBattle
- if_equal $1, ErinWantsBattle
+ if_equal 0, ErinWantsBattle
+ if_equal 1, ErinWantsBattle
.GenericCall:
farjump Phone_GenericCall_Female
@@ -1881,6 +1881,6 @@ ErinSaturdayNight:
setflag ENGINE_ERIN_SATURDAY_NIGHT
ErinWantsBattle:
- landmarktotext ROUTE_46, $2
+ landmarktotext ROUTE_46, MEM_BUFFER_2
setflag ENGINE_ERIN
farjump PhoneScript_WantsToBattle_Female
diff --git a/engine/pic_animation.asm b/engine/pic_animation.asm
index 33b770b14..4317d96f8 100644
--- a/engine/pic_animation.asm
+++ b/engine/pic_animation.asm
@@ -1,6 +1,6 @@
; Pic animation arrangement.
-AnimateMon_Slow_Normal: ; d0000
+Unused_AnimateMon_Slow_Normal: ; d0000
hlcoord 12, 0
ld a, [wBattleMode]
cp WILD_BATTLE
@@ -249,7 +249,7 @@ PokeAnim_Finish: ; d0171
PokeAnim_Cry: ; d017a
ld a, [wPokeAnimSpecies]
- call _PlayCry
+ call _PlayMonCry
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
@@ -258,7 +258,7 @@ PokeAnim_Cry: ; d017a
PokeAnim_CryNoWait: ; d0188
ld a, [wPokeAnimSpecies]
- call PlayCry2
+ call PlayMonCry2
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
@@ -279,7 +279,7 @@ PokeAnim_StereoCry: ; d0196
PokeAnim_DeinitFrames: ; d01a9
ld a, [rSVBK]
push af
- ld a, $2
+ ld a, BANK(wPokeAnimCoord)
ld [rSVBK], a
call PokeAnim_PlaceGraphic
farcall HDMATransferTileMapToWRAMBank3
@@ -335,12 +335,12 @@ PokeAnim_InitPicAttributes: ; d01d6
ld a, d
ld [wPokeAnimGraphicStartTile], a
- ld a, $1
+ ld a, BANK(CurPartySpecies)
ld hl, CurPartySpecies
call GetFarWRAMByte
ld [wPokeAnimSpecies], a
- ld a, $1
+ ld a, BANK(UnownLetter)
ld hl, UnownLetter
call GetFarWRAMByte
ld [wPokeAnimUnownLetter], a
@@ -695,7 +695,7 @@ PokeAnim_ConvertAndApplyBitmask: ; d036b
ret
; d03f4
-; XXX
+; unused
db 6, 5, 4
.GetTilemap: ; d03f7
@@ -876,7 +876,7 @@ PokeAnim_PlaceGraphic: ; d04bd
PokeAnim_SetVBank1: ; d0504
ld a, [rSVBK]
push af
- ld a, $2
+ ld a, BANK(wPokeAnimCoord)
ld [rSVBK], a
xor a
ld [hBGMapMode], a
@@ -1024,7 +1024,7 @@ GetMonFramesPointer: ; d05ce
ld hl, UnownFramesPointers
jr z, .got_frames
ld a, [wPokeAnimSpecies]
- cp CHIKORITA
+ cp JOHTO_POKEMON
ld b, BANK(FramesPointers)
ld c, BANK(KantoFrames)
ld hl, FramesPointers
@@ -1110,10 +1110,11 @@ PokeAnim_GetSpeciesOrUnown: ; d065c
ret
; d0669
-Predef48: ; d0669 Predef 48
+Unused_HOF_AnimateAlignedFrontpic: ; d0669
ld a, $1
ld [wBoxAlignment], a
-HOF_AnimateFrontpic: ; d066e Predef 49
+
+HOF_AnimateFrontpic: ; d066e
call AnimateMon_CheckIfPokemon
jr c, .fail
ld h, d
@@ -1121,7 +1122,7 @@ HOF_AnimateFrontpic: ; d066e Predef 49
push bc
push hl
ld de, vTiles2
- predef GetAnimatedFrontpicPredef
+ predef GetAnimatedFrontpic
pop hl
pop bc
ld d, 0
diff --git a/engine/player_gfx.asm b/engine/player_gfx.asm
index 98a54684b..21929e32c 100644
--- a/engine/player_gfx.asm
+++ b/engine/player_gfx.asm
@@ -1,5 +1,4 @@
-Function88248: ; 88248
-; XXX
+Unreferenced_Function88248: ; 88248
ld c, CAL
ld a, [wPlayerGender]
bit 0, a
@@ -57,11 +56,11 @@ MovePlayerPic: ; 88266
jr .loop
ShowPlayerNamingChoices: ; 88297
- ld hl, ChrisNameMenuHeader
+ ld hl, ChrisNameMenuDataHeader
ld a, [wPlayerGender]
bit 0, a
jr z, .GotGender
- ld hl, KrisNameMenuHeader
+ ld hl, KrisNameMenuDataHeader
.GotGender:
call LoadMenuDataHeader
call VerticalMenu
@@ -71,7 +70,7 @@ ShowPlayerNamingChoices: ; 88297
call CloseWindow
ret
-INCLUDE "data/default_names.asm"
+INCLUDE "data/player_names.asm"
GetPlayerNameArray: ; 88318 This Function is never called
ld hl, PlayerName
@@ -142,7 +141,7 @@ GetChrisBackpic: ; 88830
ld b, BANK(ChrisBackpic)
ld de, vTiles2 tile $31
ld c, 7 * 7
- predef DecompressPredef
+ predef DecompressGet2bpp
ret
HOF_LoadTrainerFrontpic: ; 88840
diff --git a/engine/player_movement.asm b/engine/player_movement.asm
index fa7cc84a5..d6d10aea1 100755
--- a/engine/player_movement.asm
+++ b/engine/player_movement.asm
@@ -140,7 +140,7 @@ DoPlayerMovement:: ; 80000
.water
ld a, c
- and 3
+ maskbits NUM_DIRECTIONS
ld c, a
ld b, 0
ld hl, .water_table
@@ -244,7 +244,7 @@ DoPlayerMovement:: ; 80000
ld a, [PlayerDirection]
rrca
rrca
- and 3
+ maskbits NUM_DIRECTIONS
cp e
jr z, .not_turning
@@ -316,7 +316,7 @@ DoPlayerMovement:: ; 80000
scf
ret
-; unused?
+; unused
xor a
ret
@@ -430,7 +430,7 @@ DoPlayerMovement:: ; 80000
ld a, [PlayerDirection]
rrca
rrca
- and 3
+ maskbits NUM_DIRECTIONS
cp e
jr nz, .not_warp
call WarpCheck
@@ -559,7 +559,7 @@ DoPlayerMovement:: ; 80000
cp 0
ret z
- and 3
+ maskbits NUM_DIRECTIONS
ld e, a
ld d, 0
ld hl, .forced_dpad
diff --git a/engine/player_object.asm b/engine/player_object.asm
index 6d5cb7e84..b630078a2 100755
--- a/engine/player_object.asm
+++ b/engine/player_object.asm
@@ -589,7 +589,7 @@ Special_SurfStartStep: ; 8379
ld a, [PlayerDirection]
srl a
srl a
- and 3
+ maskbits NUM_DIRECTIONS
ld e, a
ld d, 0
ld hl, .movement_data
diff --git a/engine/player_step.asm b/engine/player_step.asm
index 996a9b422..3af41be59 100755
--- a/engine/player_step.asm
+++ b/engine/player_step.asm
@@ -76,7 +76,7 @@ HandlePlayerStep: ; d4e5 (3:54e5)
ret
.mobile ; d509 (3:5509)
- farcall TrainerRankings_StepCount
+ farcall StubbedTrainerRankings_StepCount
ret
.fail2 ; d510 (3:5510)
@@ -154,7 +154,7 @@ UpdateOverworldMap: ; d536 (3:5536)
jr nc, .not_overflowed
ld a, [wBGMapAnchor + 1]
inc a
- and $3
+ and %11
or HIGH(vBGMap0)
ld [wBGMapAnchor + 1], a
.not_overflowed
@@ -185,7 +185,7 @@ UpdateOverworldMap: ; d536 (3:5536)
jr nc, .not_underflowed
ld a, [wBGMapAnchor + 1]
dec a
- and $3
+ and %11
or HIGH(vBGMap0)
ld [wBGMapAnchor + 1], a
.not_underflowed
diff --git a/engine/routines/newpokedexentry.asm b/engine/pokedex/newpokedexentry.asm
index acf9fca7b..d6b755200 100644
--- a/engine/routines/newpokedexentry.asm
+++ b/engine/pokedex/newpokedexentry.asm
@@ -11,13 +11,13 @@ NewPokedexEntry: ; fb877
ld a, [wPokedexStatus]
push af
ld a, [hSCX]
- add $5
+ add POKEDEX_SCX
ld [hSCX], a
xor a
ld [wPokedexStatus], a
farcall _NewPokedexEntry
call WaitPressAorB_BlinkCursor
- ld a, $1
+ ld a, 1 ; page 2
ld [wPokedexStatus], a
farcall DisplayDexEntry
call WaitPressAorB_BlinkCursor
@@ -26,7 +26,7 @@ NewPokedexEntry: ; fb877
call MaxVolume
call RotateThreePalettesRight
ld a, [hSCX]
- add -5 ; 251 ; NUM_POKEMON
+ add -POKEDEX_SCX
ld [hSCX], a
call .ReturnFromDexRegistration
pop af
diff --git a/engine/pokedex.asm b/engine/pokedex/pokedex.asm
index 5dc3dc2a7..e96d0a7d7 100644
--- a/engine/pokedex.asm
+++ b/engine/pokedex/pokedex.asm
@@ -1,3 +1,4 @@
+; Pokedex_RunJumptable.Jumptable indexes
const_def
const DEXSTATE_MAIN_SCR
const DEXSTATE_UPDATE_MAIN_SCR
@@ -14,6 +15,9 @@
const DEXSTATE_UPDATE_UNOWN_MODE
const DEXSTATE_EXIT
+POKEDEX_SCX EQU 5
+GLOBAL POKEDEX_SCX
+
Pokedex: ; 40000
ld a, [hWX]
@@ -86,8 +90,8 @@ InitPokedex: ; 40063
xor a
ld [wJumptableIndex], a
- ld [wDexEntryPrevJumptableIndex], a
- ld [wcf65], a
+ ld [wPrevDexEntryJumptableIndex], a
+ ld [wPrevDexEntryBackup], a
ld [wcf66], a
call Pokedex_CheckUnlockedUnownMode
@@ -118,7 +122,7 @@ Pokedex_CheckUnlockedUnownMode: ; 400a2
Pokedex_InitCursorPosition: ; 400b4
ld hl, wPokedexOrder
- ld a, [wLastDexEntry]
+ ld a, [wPrevDexEntry]
and a
jr z, .done
cp NUM_POKEMON + 1
@@ -185,6 +189,7 @@ Pokedex_RunJumptable: ; 4010b
jp hl
.Jumptable: ; 40115 (10:4115)
+; entries correspond to DEXSTATE_* constants
dw Pokedex_InitMainScreen
dw Pokedex_UpdateMainScreen
dw Pokedex_InitDexEntryScreen
@@ -228,7 +233,7 @@ Pokedex_InitMainScreen: ; 4013c (10:413c)
call Pokedex_SetBGMapMode_3ifDMG_4ifCGB
call Pokedex_ResetBGMapMode
call Pokedex_DrawMainScreenBG
- ld a, $5
+ ld a, POKEDEX_SCX
ld [hSCX], a
ld a, [wCurrentDexMode]
@@ -289,7 +294,7 @@ Pokedex_UpdateMainScreen: ; 401ae (10:41ae)
ld a, DEXSTATE_DEX_ENTRY_SCR
ld [wJumptableIndex], a
ld a, DEXSTATE_MAIN_SCR
- ld [wDexEntryPrevJumptableIndex], a
+ ld [wPrevDexEntryJumptableIndex], a
ret
.select
@@ -321,7 +326,7 @@ Pokedex_UpdateMainScreen: ; 401ae (10:41ae)
Pokedex_InitDexEntryScreen: ; 40217 (10:4217)
call LowVolume
- xor a
+ xor a ; page 1
ld [wPokedexStatus], a
xor a
ld [hBGMapMode], a
@@ -330,7 +335,7 @@ Pokedex_InitDexEntryScreen: ; 40217 (10:4217)
call Pokedex_DrawDexEntryScreenBG
call Pokedex_InitArrowCursor
call Pokedex_GetSelectedMon
- ld [wLastDexEntry], a
+ ld [wPrevDexEntry], a
farcall DisplayDexEntry
call Pokedex_DrawFootprint
call WaitBGMap
@@ -341,7 +346,7 @@ Pokedex_InitDexEntryScreen: ; 40217 (10:4217)
ld a, SCGB_POKEDEX
call Pokedex_GetSGBLayout
ld a, [CurPartySpecies]
- call PlayCry
+ call PlayMonCry
call Pokedex_IncrementDexPointer
ret
@@ -375,16 +380,16 @@ Pokedex_UpdateDexEntryScreen: ; 40258 (10:4258)
.max_volume
call MaxVolume
- ld a, [wDexEntryPrevJumptableIndex]
+ ld a, [wPrevDexEntryJumptableIndex]
ld [wJumptableIndex], a
ret
Pokedex_Page: ; 40292
ld a, [wPokedexStatus]
- xor $1
+ xor 1 ; toggle page
ld [wPokedexStatus], a
call Pokedex_GetSelectedMon
- ld [wLastDexEntry], a
+ ld [wPrevDexEntry], a
farcall DisplayDexEntry
call WaitBGMap
ret
@@ -392,7 +397,7 @@ Pokedex_Page: ; 40292
Pokedex_ReinitDexEntryScreen: ; 402aa (10:42aa)
; Reinitialize the Pokédex entry screen after changing the selected mon.
call Pokedex_BlackOutBG
- xor a
+ xor a ; page 1
ld [wPokedexStatus], a
xor a
ld [hBGMapMode], a
@@ -400,7 +405,7 @@ Pokedex_ReinitDexEntryScreen: ; 402aa (10:42aa)
call Pokedex_InitArrowCursor
call Pokedex_LoadCurrentFootprint
call Pokedex_GetSelectedMon
- ld [wLastDexEntry], a
+ ld [wPrevDexEntry], a
farcall DisplayDexEntry
call Pokedex_DrawFootprint
call Pokedex_LoadSelectedMonTiles
@@ -410,17 +415,17 @@ Pokedex_ReinitDexEntryScreen: ; 402aa (10:42aa)
ld a, SCGB_POKEDEX
call Pokedex_GetSGBLayout
ld a, [CurPartySpecies]
- call PlayCry
+ call PlayMonCry
ld hl, wJumptableIndex
dec [hl]
ret
DexEntryScreen_ArrowCursorData: ; 402e8
db D_RIGHT | D_LEFT, 4
- dwcoord 1, 17
- dwcoord 6, 17
- dwcoord 11, 17
- dwcoord 15, 17
+ dwcoord 1, 17 ; PAGE
+ dwcoord 6, 17 ; AREA
+ dwcoord 11, 17 ; CRY
+ dwcoord 15, 17 ; PRNT
DexEntryScreen_MenuActionJumptable: ; 402f2
@@ -441,14 +446,14 @@ DexEntryScreen_MenuActionJumptable: ; 402f2
call Pokedex_GetSelectedMon
ld a, [wDexCurrentLocation]
ld e, a
- predef _Area
+ predef Pokedex_GetArea
call Pokedex_BlackOutBG
call DelayFrame
xor a
ld [hBGMapMode], a
ld a, $90
ld [hWY], a
- ld a, $5
+ ld a, POKEDEX_SCX
ld [hSCX], a
call DelayFrame
call Pokedex_RedisplayDexEntry
@@ -466,16 +471,16 @@ DexEntryScreen_MenuActionJumptable: ; 402f2
call GetCryIndex
ld e, c
ld d, b
- call PlayCryHeader
+ call PlayCry
ret
.Print: ; 4034f
call Pokedex_ApplyPrintPals
xor a
ld [hSCX], a
- ld a, [wcf65]
+ ld a, [wPrevDexEntryBackup]
push af
- ld a, [wDexEntryPrevJumptableIndex]
+ ld a, [wPrevDexEntryJumptableIndex]
push af
ld a, [wJumptableIndex]
push af
@@ -483,16 +488,16 @@ DexEntryScreen_MenuActionJumptable: ; 402f2
pop af
ld [wJumptableIndex], a
pop af
- ld [wDexEntryPrevJumptableIndex], a
+ ld [wPrevDexEntryJumptableIndex], a
pop af
- ld [wcf65], a
+ ld [wPrevDexEntryBackup], a
call ClearBGPalettes
call DisableLCD
call Pokedex_LoadInvertedFont
call Pokedex_RedisplayDexEntry
call EnableLCD
call WaitBGMap
- ld a, $5
+ ld a, POKEDEX_SCX
ld [hSCX], a
call Pokedex_ApplyUsualPals
ret
@@ -553,16 +558,16 @@ Pokedex_UpdateOptionScreen: ; 403be (10:43be)
.NoUnownModeArrowCursorData: ; 403f3
db D_UP | D_DOWN, 3
- dwcoord 2, 4
- dwcoord 2, 6
- dwcoord 2, 8
+ dwcoord 2, 4 ; NEW
+ dwcoord 2, 6 ; OLD
+ dwcoord 2, 8 ; ABC
.ArrowCursorData: ; 403fb
db D_UP | D_DOWN, 4
- dwcoord 2, 4
- dwcoord 2, 6
- dwcoord 2, 8
- dwcoord 2, 10
+ dwcoord 2, 4 ; NEW
+ dwcoord 2, 6 ; OLD
+ dwcoord 2, 8 ; ABC
+ dwcoord 2, 10 ; UNOWN
.MenuActionJumptable: ; 40405 (10:4405)
dw .MenuAction_NewMode
@@ -655,10 +660,10 @@ Pokedex_UpdateSearchScreen: ; 40471 (10:4471)
.ArrowCursorData: ; 4049e
db D_UP | D_DOWN, 4
- dwcoord 2, 4
- dwcoord 2, 6
- dwcoord 2, 13
- dwcoord 2, 15
+ dwcoord 2, 4 ; TYPE 1
+ dwcoord 2, 6 ; TYPE 2
+ dwcoord 2, 13 ; BEGIN SEARCH
+ dwcoord 2, 15 ; CANCEL
.MenuActionJumptable: ; 404a8
dw .MenuAction_MonSearchType
@@ -695,8 +700,8 @@ Pokedex_UpdateSearchScreen: ; 40471 (10:4471)
ld [wDexListingScrollOffsetBackup], a
ld a, [wDexListingCursor]
ld [wDexListingCursorBackup], a
- ld a, [wLastDexEntry]
- ld [wcf65], a
+ ld a, [wPrevDexEntry]
+ ld [wPrevDexEntryBackup], a
xor a
ld [wDexListingScrollOffset], a
ld [wDexListingCursor], a
@@ -728,7 +733,7 @@ Pokedex_InitSearchResultsScreen: ; 4050a (10:450a)
call Pokedex_SetBGMapMode3
call Pokedex_ResetBGMapMode
call Pokedex_DrawSearchResultsScreenBG
- ld a, $5
+ ld a, POKEDEX_SCX
ld [hSCX], a
ld a, $4a
ld [hWX], a
@@ -739,7 +744,7 @@ Pokedex_InitSearchResultsScreen: ; 4050a (10:450a)
farcall DrawPokedexSearchResultsWindow
call Pokedex_PlaceSearchResultsTypeStrings
call Pokedex_UpdateSearchResultsCursorOAM
- ld a, $ff
+ ld a, -1
ld [CurPartySpecies], a
ld a, SCGB_POKEDEX
call Pokedex_GetSGBLayout
@@ -771,7 +776,7 @@ Pokedex_UpdateSearchResultsScreen: ; 40562 (10:4562)
ld a, DEXSTATE_DEX_ENTRY_SCR
ld [wJumptableIndex], a
ld a, DEXSTATE_SEARCH_RESULTS_SCR
- ld [wDexEntryPrevJumptableIndex], a
+ ld [wPrevDexEntryJumptableIndex], a
ret
.return_to_search_screen
@@ -779,8 +784,8 @@ Pokedex_UpdateSearchResultsScreen: ; 40562 (10:4562)
ld [wDexListingScrollOffset], a
ld a, [wDexListingCursorBackup]
ld [wDexListingCursor], a
- ld a, [wcf65]
- ld [wLastDexEntry], a
+ ld a, [wPrevDexEntryBackup]
+ ld [wPrevDexEntry], a
call Pokedex_BlackOutBG
call ClearSprites
call Pokedex_OrderMonsByMode
@@ -827,7 +832,7 @@ Pokedex_UpdateUnownMode: ; 405df (10:45df)
.decompress
ld hl, PokedexLZ
ld de, vTiles2 tile $31
- lb bc, BANK(PokedexLZ), $3a
+ lb bc, BANK(PokedexLZ), 58
call DecompressRequest2bpp
.done
@@ -1123,13 +1128,14 @@ Pokedex_DrawMainScreenBG: ; 4074c (10:474c)
ret
String_SEEN: ; 407e1
- db "SEEN", $ff
+ db "SEEN", -1
String_OWN: ; 407e6
- db "OWN", $ff
+ db "OWN", -1
String_SELECT_OPTION: ; 407ea
db $3b, $48, $49, $4a, $44, $45, $46, $47 ; SELECT > OPTION
+ ; fallthrough
String_START_SEARCH: ; 407f2
- db $3c, $3b, $41, $42, $43, $4b, $4c, $4d, $4e, $3c, $ff ; START > SEARCH
+ db $3c, $3b, $41, $42, $43, $4b, $4c, $4d, $4e, $3c, -1 ; START > SEARCH
Pokedex_DrawDexEntryScreenBG: ; 407fd
call Pokedex_FillBackgroundColor2
@@ -1164,13 +1170,13 @@ Pokedex_DrawDexEntryScreenBG: ; 407fd
ret
.Unused: ; 4084f
- db $5c, $5d, $ff ; No.
+ db $5c, $5d, -1 ; No.
.Height: ; 40852
- db "HT ?", $5e, "??", $5f, $ff ; HT ?'??"
+ db "HT ?", $5e, "??", $5f, -1 ; HT ?'??"
.Weight: ; 4085c
- db "WT ???lb", $ff ; WT ???lb
+ db "WT ???lb", -1 ; WT ???lb
.MenuItems: ; 40867
- db $3b, " PAGE AREA CRY PRNT", $ff
+ db $3b, " PAGE AREA CRY PRNT", -1
Pokedex_DrawOptionScreenBG: ; 4087c (10:487c)
call Pokedex_FillBackgroundColor2
@@ -1195,7 +1201,7 @@ Pokedex_DrawOptionScreenBG: ; 4087c (10:487c)
ret
.Title: ; 408b2
- db $3b, " OPTION ", $3c, $ff
+ db $3b, " OPTION ", $3c, -1
.Modes: ; 408bd
db "NEW #DEX MODE"
@@ -1229,10 +1235,10 @@ Pokedex_DrawSearchScreenBG: ; 408f0 (10:48f0)
ret
.Title: ; 4092a
- db $3b, " SEARCH ", $3c, $ff
+ db $3b, " SEARCH ", $3c, -1
.TypeLeftRightArrows: ; 40935
- db $3d, " ", $3e, $ff
+ db $3d, " ", $3e, -1
.Types: ; 40940
db "TYPE1"
@@ -1342,33 +1348,34 @@ endr
ret
UnownModeLetterAndCursorCoords: ; 40a3e
+; entries correspond to Unown forms
; letter, cursor
- dwcoord 4,11, 3,11
- dwcoord 4,10, 3,10
- dwcoord 4, 9, 3, 9
- dwcoord 4, 8, 3, 8
- dwcoord 4, 7, 3, 7
- dwcoord 4, 6, 3, 6
- dwcoord 4, 5, 3, 5
- dwcoord 4, 4, 3, 4
- dwcoord 4, 3, 3, 2
- dwcoord 5, 3, 5, 2
- dwcoord 6, 3, 6, 2
- dwcoord 7, 3, 7, 2
- dwcoord 8, 3, 8, 2
- dwcoord 9, 3, 9, 2
- dwcoord 10, 3, 10, 2
- dwcoord 11, 3, 11, 2
- dwcoord 12, 3, 12, 2
- dwcoord 13, 3, 13, 2
- dwcoord 14, 3, 15, 2
- dwcoord 14, 4, 15, 4
- dwcoord 14, 5, 15, 5
- dwcoord 14, 6, 15, 6
- dwcoord 14, 7, 15, 7
- dwcoord 14, 8, 15, 8
- dwcoord 14, 9, 15, 9
- dwcoord 14,10, 15,10
+ dwcoord 4,11, 3,11 ; A
+ dwcoord 4,10, 3,10 ; B
+ dwcoord 4, 9, 3, 9 ; C
+ dwcoord 4, 8, 3, 8 ; D
+ dwcoord 4, 7, 3, 7 ; E
+ dwcoord 4, 6, 3, 6 ; F
+ dwcoord 4, 5, 3, 5 ; G
+ dwcoord 4, 4, 3, 4 ; H
+ dwcoord 4, 3, 3, 2 ; I
+ dwcoord 5, 3, 5, 2 ; J
+ dwcoord 6, 3, 6, 2 ; K
+ dwcoord 7, 3, 7, 2 ; L
+ dwcoord 8, 3, 8, 2 ; M
+ dwcoord 9, 3, 9, 2 ; N
+ dwcoord 10, 3, 10, 2 ; O
+ dwcoord 11, 3, 11, 2 ; P
+ dwcoord 12, 3, 12, 2 ; Q
+ dwcoord 13, 3, 13, 2 ; R
+ dwcoord 14, 3, 15, 2 ; S
+ dwcoord 14, 4, 15, 4 ; T
+ dwcoord 14, 5, 15, 5 ; U
+ dwcoord 14, 6, 15, 6 ; V
+ dwcoord 14, 7, 15, 7 ; W
+ dwcoord 14, 8, 15, 8 ; X
+ dwcoord 14, 9, 15, 9 ; Y
+ dwcoord 14,10, 15,10 ; Z
Pokedex_FillBackgroundColor2: ; 40aa6
hlcoord 0, 0
@@ -1794,7 +1801,7 @@ Pokedex_PrevSearchMonType: ; 40f65
ld hl, wDexSearchMonType1
ld a, [hl]
- cp $1
+ cp 1
jr z, .wrap_around
dec [hl]
jr .done
@@ -1808,7 +1815,7 @@ Pokedex_PrevSearchMonType: ; 40f65
jr .done
.wrap_around
- ld [hl], $11
+ ld [hl], NUM_TYPES - 1
.done
scf
@@ -1821,18 +1828,18 @@ Pokedex_NextSearchMonType: ; 40f84
ld hl, wDexSearchMonType1
ld a, [hl]
- cp $11
+ cp NUM_TYPES - 1
jr nc, .type1_wrap_around
inc [hl]
jr .done
.type1_wrap_around
- ld [hl], $1
+ ld [hl], 1
jr .done
.type2
ld hl, wDexSearchMonType2
ld a, [hl]
- cp $11
+ cp NUM_TYPES - 1
jr nc, .type2_wrap_around
inc [hl]
jr .done
@@ -1864,7 +1871,7 @@ Pokedex_PlaceTypeString: ; 40fcd (10:4fcd)
push hl
ld e, a
ld d, 0
- ld hl, .TypeStrings
+ ld hl, PokedexTypeSearchStrings
rept 9
add hl, de
endr
@@ -1874,25 +1881,7 @@ endr
call PlaceString
ret
-.TypeStrings: ; 40fe4
- db " ---- @"
- db " NORMAL @"
- db " FIRE @"
- db " WATER @"
- db " GRASS @"
- db "ELECTRIC@"
- db " ICE @"
- db "FIGHTING@"
- db " POISON @"
- db " GROUND @"
- db " FLYING @"
- db "PSYCHIC @"
- db " BUG @"
- db " ROCK @"
- db " GHOST @"
- db " DRAGON @"
- db " DARK @"
- db " STEEL @"
+INCLUDE "data/types/search_strings.asm"
Pokedex_SearchForMons: ; 41086
ld a, [wDexSearchMonType2]
@@ -1907,7 +1896,7 @@ Pokedex_SearchForMons: ; 41086
dec a
ld e, a
ld d, 0
- ld hl, .TypeConversionTable
+ ld hl, PokedexTypeSearchConversionTable
add hl, de
ld a, [hl]
ld [wDexConvertedMonType], a
@@ -1969,24 +1958,7 @@ Pokedex_SearchForMons: ; 41086
.done
ret
-.TypeConversionTable: ; 410f6
- db NORMAL
- db FIRE
- db WATER
- db GRASS
- db ELECTRIC
- db ICE
- db FIGHTING
- db POISON
- db GROUND
- db FLYING
- db PSYCHIC
- db BUG
- db ROCK
- db GHOST
- db DRAGON
- db DARK
- db STEEL
+INCLUDE "data/types/search_types.asm"
Pokedex_DisplayTypeNotFoundMessage: ; 41107
xor a
@@ -2026,60 +1998,60 @@ Pokedex_PutOldModeCursorOAM: ; 41157 (10:5157)
ret
.CursorOAM: ; 41167
- db $18, $47, $30, $07
- db $10, $47, $31, $07
- db $10, $4f, $32, $07
- db $10, $57, $32, $07
- db $10, $5f, $32, $07
- db $10, $67, $33, $07
- db $10, $7e, $33, $27
- db $10, $86, $32, $27
- db $10, $8e, $32, $27
- db $10, $96, $32, $27
- db $10, $9e, $31, $27
- db $18, $9e, $30, $27
- db $20, $47, $30, $47
- db $28, $47, $31, $47
- db $28, $4f, $32, $47
- db $28, $57, $32, $47
- db $28, $5f, $32, $47
- db $28, $67, $33, $47
- db $28, $7e, $33, $67
- db $28, $86, $32, $67
- db $28, $8e, $32, $67
- db $28, $96, $32, $67
- db $28, $9e, $31, $67
- db $20, $9e, $30, $67
- db $ff
+ dsprite 3, 0, 9, -1, $30, 7
+ dsprite 2, 0, 9, -1, $31, 7
+ dsprite 2, 0, 10, -1, $32, 7
+ dsprite 2, 0, 11, -1, $32, 7
+ dsprite 2, 0, 12, -1, $32, 7
+ dsprite 2, 0, 13, -1, $33, 7
+ dsprite 2, 0, 16, -2, $33, 7 | X_FLIP
+ dsprite 2, 0, 17, -2, $32, 7 | X_FLIP
+ dsprite 2, 0, 18, -2, $32, 7 | X_FLIP
+ dsprite 2, 0, 19, -2, $32, 7 | X_FLIP
+ dsprite 2, 0, 20, -2, $31, 7 | X_FLIP
+ dsprite 3, 0, 20, -2, $30, 7 | X_FLIP
+ dsprite 4, 0, 9, -1, $30, 7 | Y_FLIP
+ dsprite 5, 0, 9, -1, $31, 7 | Y_FLIP
+ dsprite 5, 0, 10, -1, $32, 7 | Y_FLIP
+ dsprite 5, 0, 11, -1, $32, 7 | Y_FLIP
+ dsprite 5, 0, 12, -1, $32, 7 | Y_FLIP
+ dsprite 5, 0, 13, -1, $33, 7 | Y_FLIP
+ dsprite 5, 0, 16, -2, $33, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 0, 17, -2, $32, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 0, 18, -2, $32, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 0, 19, -2, $32, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 0, 20, -2, $31, 7 | X_FLIP | Y_FLIP
+ dsprite 4, 0, 20, -2, $30, 7 | X_FLIP | Y_FLIP
+ db -1
.CursorAtTopOAM: ; 411c8
; OAM data for when the cursor is at the top of the list. The tiles at the top
; are cut off so they don't show up outside the list area.
- db $18, $47, $30, $07
- db $10, $47, $34, $07
- db $10, $4f, $35, $07
- db $10, $57, $35, $07
- db $10, $5f, $35, $07
- db $10, $67, $36, $07
- db $10, $7e, $36, $27
- db $10, $86, $35, $27
- db $10, $8e, $35, $27
- db $10, $96, $35, $27
- db $10, $9e, $34, $27
- db $18, $9e, $30, $27
- db $20, $47, $30, $47
- db $28, $47, $31, $47
- db $28, $4f, $32, $47
- db $28, $57, $32, $47
- db $28, $5f, $32, $47
- db $28, $67, $33, $47
- db $28, $7e, $33, $67
- db $28, $86, $32, $67
- db $28, $8e, $32, $67
- db $28, $96, $32, $67
- db $28, $9e, $31, $67
- db $20, $9e, $30, $67
- db $ff
+ dsprite 3, 0, 9, -1, $30, 7
+ dsprite 2, 0, 9, -1, $34, 7
+ dsprite 2, 0, 10, -1, $35, 7
+ dsprite 2, 0, 11, -1, $35, 7
+ dsprite 2, 0, 12, -1, $35, 7
+ dsprite 2, 0, 13, -1, $36, 7
+ dsprite 2, 0, 16, -2, $36, 7 | X_FLIP
+ dsprite 2, 0, 17, -2, $35, 7 | X_FLIP
+ dsprite 2, 0, 18, -2, $35, 7 | X_FLIP
+ dsprite 2, 0, 19, -2, $35, 7 | X_FLIP
+ dsprite 2, 0, 20, -2, $34, 7 | X_FLIP
+ dsprite 3, 0, 20, -2, $30, 7 | X_FLIP
+ dsprite 4, 0, 9, -1, $30, 7 | Y_FLIP
+ dsprite 5, 0, 9, -1, $31, 7 | Y_FLIP
+ dsprite 5, 0, 10, -1, $32, 7 | Y_FLIP
+ dsprite 5, 0, 11, -1, $32, 7 | Y_FLIP
+ dsprite 5, 0, 12, -1, $32, 7 | Y_FLIP
+ dsprite 5, 0, 13, -1, $33, 7 | Y_FLIP
+ dsprite 5, 0, 16, -2, $33, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 0, 17, -2, $32, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 0, 18, -2, $32, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 0, 19, -2, $32, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 0, 20, -2, $31, 7 | X_FLIP | Y_FLIP
+ dsprite 4, 0, 20, -2, $30, 7 | X_FLIP | Y_FLIP
+ db -1
Pokedex_PutNewModeABCModeCursorOAM: ; 41229 (10:5229)
ld hl, .CursorOAM
@@ -2087,27 +2059,27 @@ Pokedex_PutNewModeABCModeCursorOAM: ; 41229 (10:5229)
ret
.CursorOAM: ; 41230
- db $1b, $47, $30, $07
- db $13, $47, $31, $07
- db $13, $4f, $32, $07
- db $13, $57, $32, $07
- db $13, $5f, $33, $07
- db $13, $80, $33, $27
- db $13, $88, $32, $27
- db $13, $90, $32, $27
- db $13, $98, $31, $27
- db $1b, $98, $30, $27
- db $23, $47, $30, $47
- db $2b, $47, $31, $47
- db $2b, $4f, $32, $47
- db $2b, $57, $32, $47
- db $2b, $5f, $33, $47
- db $2b, $80, $33, $67
- db $2b, $88, $32, $67
- db $2b, $90, $32, $67
- db $2b, $98, $31, $67
- db $23, $98, $30, $67
- db $ff
+ dsprite 3, 3, 9, -1, $30, 7
+ dsprite 2, 3, 9, -1, $31, 7
+ dsprite 2, 3, 10, -1, $32, 7
+ dsprite 2, 3, 11, -1, $32, 7
+ dsprite 2, 3, 12, -1, $33, 7
+ dsprite 2, 3, 16, 0, $33, 7 | X_FLIP
+ dsprite 2, 3, 17, 0, $32, 7 | X_FLIP
+ dsprite 2, 3, 18, 0, $32, 7 | X_FLIP
+ dsprite 2, 3, 19, 0, $31, 7 | X_FLIP
+ dsprite 3, 3, 19, 0, $30, 7 | X_FLIP
+ dsprite 4, 3, 9, -1, $30, 7 | Y_FLIP
+ dsprite 5, 3, 9, -1, $31, 7 | Y_FLIP
+ dsprite 5, 3, 10, -1, $32, 7 | Y_FLIP
+ dsprite 5, 3, 11, -1, $32, 7 | Y_FLIP
+ dsprite 5, 3, 12, -1, $33, 7 | Y_FLIP
+ dsprite 5, 3, 16, 0, $33, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 3, 17, 0, $32, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 3, 18, 0, $32, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 3, 19, 0, $31, 7 | X_FLIP | Y_FLIP
+ dsprite 4, 3, 19, 0, $30, 7 | X_FLIP | Y_FLIP
+ db -1
Pokedex_UpdateSearchResultsCursorOAM: ; 41281 (10:5281)
ld a, [wCurrentDexMode]
@@ -2118,52 +2090,52 @@ Pokedex_UpdateSearchResultsCursorOAM: ; 41281 (10:5281)
ret
.CursorOAM: ; 41290
- db $1b, $47, $30, $07
- db $13, $47, $31, $07
- db $13, $4f, $32, $07
- db $13, $57, $32, $07
- db $13, $5f, $32, $07
- db $13, $67, $33, $07
- db $13, $7e, $33, $27
- db $13, $86, $32, $27
- db $13, $8e, $32, $27
- db $13, $96, $32, $27
- db $13, $9e, $31, $27
- db $1b, $9e, $30, $27
- db $23, $47, $30, $47
- db $2b, $47, $31, $47
- db $2b, $4f, $32, $47
- db $2b, $57, $32, $47
- db $2b, $5f, $32, $47
- db $2b, $67, $33, $47
- db $2b, $7e, $33, $67
- db $2b, $86, $32, $67
- db $2b, $8e, $32, $67
- db $2b, $96, $32, $67
- db $2b, $9e, $31, $67
- db $23, $9e, $30, $67
- db $ff
+ dsprite 3, 3, 9, -1, $30, 7
+ dsprite 2, 3, 9, -1, $31, 7
+ dsprite 2, 3, 10, -1, $32, 7
+ dsprite 2, 3, 11, -1, $32, 7
+ dsprite 2, 3, 12, -1, $32, 7
+ dsprite 2, 3, 13, -1, $33, 7
+ dsprite 2, 3, 16, -2, $33, 7 | X_FLIP
+ dsprite 2, 3, 17, -2, $32, 7 | X_FLIP
+ dsprite 2, 3, 18, -2, $32, 7 | X_FLIP
+ dsprite 2, 3, 19, -2, $32, 7 | X_FLIP
+ dsprite 2, 3, 20, -2, $31, 7 | X_FLIP
+ dsprite 3, 3, 20, -2, $30, 7 | X_FLIP
+ dsprite 4, 3, 9, -1, $30, 7 | Y_FLIP
+ dsprite 5, 3, 9, -1, $31, 7 | Y_FLIP
+ dsprite 5, 3, 10, -1, $32, 7 | Y_FLIP
+ dsprite 5, 3, 11, -1, $32, 7 | Y_FLIP
+ dsprite 5, 3, 12, -1, $32, 7 | Y_FLIP
+ dsprite 5, 3, 13, -1, $33, 7 | Y_FLIP
+ dsprite 5, 3, 16, -2, $33, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 3, 17, -2, $32, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 3, 18, -2, $32, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 3, 19, -2, $32, 7 | X_FLIP | Y_FLIP
+ dsprite 5, 3, 20, -2, $31, 7 | X_FLIP | Y_FLIP
+ dsprite 4, 3, 20, -2, $30, 7 | X_FLIP | Y_FLIP
+ db -1
Pokedex_LoadCursorOAM: ; 412f1 (10:52f1)
- ld de, Sprites
+ ld de, Sprite01
.loop
ld a, [hl]
- cp $ff
+ cp -1
ret z
ld a, [wDexListingCursor]
and $7
swap a
- add [hl]
+ add [hl] ; y
inc hl
ld [de], a
inc de
- ld a, [hli]
+ ld a, [hli] ; x
ld [de], a
inc de
- ld a, [hli]
+ ld a, [hli] ; tile id
ld [de], a
inc de
- ld a, [hli]
+ ld a, [hli] ; attributes
ld [de], a
inc de
jr .loop
@@ -2348,7 +2320,7 @@ Pokedex_BlackOutBG: ; 41401 (10:5401)
; Make BG palettes black so that the BG becomes all black.
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, wBGPals1
ld bc, 8 palettes
@@ -2422,7 +2394,7 @@ Pokedex_LoadCurrentFootprint: ; 41478 (10:5478)
Pokedex_LoadAnyFootprint: ; 4147b
ld a, [wd265]
dec a
- and ($ff ^ $07) ; $f8 ; $1f << 3
+ and %11111000
srl a
srl a
srl a
@@ -2430,7 +2402,7 @@ Pokedex_LoadAnyFootprint: ; 4147b
ld d, a
ld a, [wd265]
dec a
- and 7
+ and %111
swap a ; * $10
ld l, a
ld h, 0
@@ -2586,7 +2558,7 @@ _NewPokedexEntry: ; 41a7f
ld a, SCGB_POKEDEX
call Pokedex_GetSGBLayout
ld a, [CurPartySpecies]
- call PlayCry
+ call PlayMonCry
ret
diff --git a/engine/pokedex_2.asm b/engine/pokedex/pokedex_2.asm
index 83b366017..4dd608ac0 100644
--- a/engine/pokedex_2.asm
+++ b/engine/pokedex/pokedex_2.asm
@@ -40,16 +40,16 @@ AnimateDexSearchSlowpoke: ; 441cf
DoDexSearchSlowpokeFrame: ; 44207
ld a, [wDexSearchSlowpokeFrame]
- ld hl, .SpriteData
- ld de, Sprites
+ ld hl, .SlowpokeSpriteData
+ ld de, Sprite01
.loop
ld a, [hli]
cp -1
ret z
- ld [de], a
+ ld [de], a ; y
inc de
ld a, [hli]
- ld [de], a
+ ld [de], a ; x
inc de
ld a, [wDexSearchSlowpokeFrame]
ld b, a
@@ -57,23 +57,23 @@ DoDexSearchSlowpokeFrame: ; 44207
add b
add [hl]
inc hl
- ld [de], a
+ ld [de], a ; tile id
inc de
ld a, [hli]
- ld [de], a
+ ld [de], a ; attributes
inc de
jr .loop
-.SpriteData: ; 44228
- dsprite 11, 0, 9, 0, $00, $00
- dsprite 11, 0, 10, 0, $01, $00
- dsprite 11, 0, 11, 0, $02, $00
- dsprite 12, 0, 9, 0, $10, $00
- dsprite 12, 0, 10, 0, $11, $00
- dsprite 12, 0, 11, 0, $12, $00
- dsprite 13, 0, 9, 0, $20, $00
- dsprite 13, 0, 10, 0, $21, $00
- dsprite 13, 0, 11, 0, $22, $00
+.SlowpokeSpriteData: ; 44228
+ dsprite 11, 0, 9, 0, $00, 0
+ dsprite 11, 0, 10, 0, $01, 0
+ dsprite 11, 0, 11, 0, $02, 0
+ dsprite 12, 0, 9, 0, $10, 0
+ dsprite 12, 0, 10, 0, $11, 0
+ dsprite 12, 0, 11, 0, $12, 0
+ dsprite 13, 0, 9, 0, $20, 0
+ dsprite 13, 0, 10, 0, $21, 0
+ dsprite 13, 0, 11, 0, $22, 0
db -1
DisplayDexEntry: ; 4424d
@@ -182,7 +182,7 @@ DisplayDexEntry: ; 4424d
call FarString
pop bc
ld a, [wPokedexStatus]
- or a
+ or a ; check for page 2
ret z
; Page 2
@@ -230,7 +230,7 @@ GetDexEntryPointer: ; 44333
push de
rlca
rlca
- and $3
+ maskbits NUM_DEX_ENTRY_BANKS
ld hl, .PokedexEntryBanks
ld d, 0
ld e, a
@@ -241,12 +241,6 @@ GetDexEntryPointer: ; 44333
ret
.PokedexEntryBanks: ; 44351
-
-GLOBAL PokedexEntries1
-GLOBAL PokedexEntries2
-GLOBAL PokedexEntries3
-GLOBAL PokedexEntries4
-
db BANK(PokedexEntries1)
db BANK(PokedexEntries2)
db BANK(PokedexEntries3)
diff --git a/engine/pokedex_3.asm b/engine/pokedex/pokedex_3.asm
index 482f55799..dc52f83d3 100644
--- a/engine/pokedex_3.asm
+++ b/engine/pokedex/pokedex_3.asm
@@ -7,7 +7,7 @@ LoadSGBPokedexGFX: ; 1ddf1c
LoadSGBPokedexGFX2: ; 1ddf26 (77:5f26)
ld hl, SGBPokedexGFX_LZ
ld de, vTiles2 tile $31
- lb bc, BANK(SGBPokedexGFX_LZ), $3a
+ lb bc, BANK(SGBPokedexGFX_LZ), 58
call DecompressRequest2bpp
ret
diff --git a/engine/unown_dex.asm b/engine/pokedex/unown_dex.asm
index dc6db9dc6..dc6db9dc6 100755
--- a/engine/unown_dex.asm
+++ b/engine/pokedex/unown_dex.asm
diff --git a/engine/pokegear.asm b/engine/pokegear.asm
index dba071b28..f65f394be 100755
--- a/engine/pokegear.asm
+++ b/engine/pokegear.asm
@@ -1,3 +1,27 @@
+; Pokégear cards
+ const_def
+ const POKEGEARCARD_CLOCK ; 0
+ const POKEGEARCARD_MAP ; 1
+ const POKEGEARCARD_PHONE ; 2
+ const POKEGEARCARD_RADIO ; 3
+NUM_POKEGEAR_CARDS EQU const_value
+
+; PokegearJumptable.Jumptable indexes
+ const_def
+ const POKEGEARSTATE_CLOCKINIT ; 0
+ const POKEGEARSTATE_CLOCKJOYPAD ; 1
+ const POKEGEARSTATE_MAPCHECKREGION ; 2
+ const POKEGEARSTATE_JOHTOMAPINIT ; 3
+ const POKEGEARSTATE_JOHTOMAPJOYPAD ; 4
+ const POKEGEARSTATE_KANTOMAPINIT ; 5
+ const POKEGEARSTATE_KANTOMAPJOYPAD ; 6
+ const POKEGEARSTATE_PHONEINIT ; 7
+ const POKEGEARSTATE_PHONEJOYPAD ; 8
+ const POKEGEARSTATE_MAKEPHONECALL ; 9
+ const POKEGEARSTATE_FINISHPHONECALL ; a
+ const POKEGEARSTATE_RADIOINIT ; b
+ const POKEGEARSTATE_RADIOJOYPAD ; c
+
PokeGear: ; 90b8d (24:4b8d)
ld hl, Options
ld a, [hl]
@@ -63,9 +87,9 @@ PokeGear: ; 90b8d (24:4b8d)
ld [rLCDC], a
call TownMap_InitCursorAndPlayerIconPositions
xor a
- ld [wJumptableIndex], a
- ld [wcf64], a
- ld [wcf65], a
+ ld [wJumptableIndex], a ; POKEGEARSTATE_CLOCKINIT
+ ld [wPokegearCard], a ; POKEGEARCARD_CLOCK
+ ld [wPokegearMapRegion], a ; JOHTO_REGION
ld [wcf66], a
ld [wPokegearPhoneScrollPosition], a
ld [wPokegearPhoneCursorPosition], a
@@ -92,7 +116,7 @@ Pokegear_LoadGFX: ; 90c4e
ld a, BANK(TownMapGFX)
call FarDecompress
ld hl, PokegearGFX
- ld de, vTiles2 + $30 tiles
+ ld de, vTiles2 tile $30
ld a, BANK(PokegearGFX)
call FarDecompress
ld hl, PokegearSpritesGFX
@@ -149,7 +173,7 @@ InitPokegearModeIndicatorArrow: ; 90d32 (24:4d32)
ret
AnimatePokegearModeIndicatorArrow: ; 90d41 (24:4d41)
- ld hl, wcf64
+ ld hl, wPokegearCard
ld e, [hl]
ld d, 0
ld hl, .XCoords
@@ -163,7 +187,10 @@ AnimatePokegearModeIndicatorArrow: ; 90d41 (24:4d41)
; 90d52 (24:4d52)
.XCoords: ; 90d52
- db $00, $10, $20, $30
+ db $00 ; POKEGEARCARD_CLOCK
+ db $10 ; POKEGEARCARD_MAP
+ db $20 ; POKEGEARCARD_PHONE
+ db $30 ; POKEGEARCARD_RADIO
; 90d56
TownMap_GetCurrentLandmark: ; 90d56
@@ -210,10 +237,10 @@ TownMap_InitCursorAndPlayerIconPositions: ; 90d70 (24:4d70)
ret
Pokegear_InitJumptableIndices: ; 90d9e (24:4d9e)
- ld a, $0
+ ld a, POKEGEARSTATE_CLOCKINIT
ld [wJumptableIndex], a
- xor a
- ld [wcf64], a
+ xor a ; POKEGEARCARD_CLOCK
+ ld [wPokegearCard], a
ret
InitPokegearTilemap: ; 90da8 (24:4da8)
@@ -223,8 +250,8 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
ld bc, TileMapEnd - TileMap
ld a, $4f
call ByteFill
- ld a, [wcf64]
- and $3
+ ld a, [wPokegearCard]
+ maskbits NUM_POKEGEAR_CARDS
add a
ld e, a
ld d, 0
@@ -240,7 +267,7 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
.return_from_jumptable
call Pokegear_FinishTilemap
farcall TownMapPals
- ld a, [wcf65]
+ ld a, [wPokegearMapRegion]
and a
jr nz, .kanto_0
xor a ; LOW(vBGMap0)
@@ -260,10 +287,11 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
xor a
.finish
ld [hWY], a
- ld a, [wcf65]
- and 1
+ ; swap region maps
+ ld a, [wPokegearMapRegion]
+ maskbits NUM_REGIONS
xor 1
- ld [wcf65], a
+ ld [wPokegearMapRegion], a
ret
.UpdateBGMap: ; 90e00 (24:4e00)
@@ -281,6 +309,7 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
; 90e12 (24:4e12)
.Jumptable: ; 90e12
+; entries correspond to POKEGEARCARD_* constants
dw .Clock
dw .Map
dw .Phone
@@ -319,12 +348,12 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
ld e, 1
.ok
farcall PokegearMap
- ld a, $7
+ ld a, $07
ld bc, $12
hlcoord 1, 2
call ByteFill
hlcoord 0, 2
- ld [hl], $6
+ ld [hl], $06
hlcoord 19, 2
ld [hl], $17
ld a, [wPokegearMapCursorLandmark]
@@ -364,7 +393,7 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
hlcoord 17, 2
inc a
ld [hli], a
- call GetMapHeaderPhoneServiceNybble
+ call GetMapPhoneService
and a
ret nz
hlcoord 18, 2
@@ -382,13 +411,13 @@ Pokegear_FinishTilemap: ; 90eb0 (24:4eb0)
call ByteFill
ld de, wPokegearFlags
ld a, [de]
- bit 0, a
+ bit 0, a ; ENGINE_MAP_CARD
call nz, .PlaceMapIcon
ld a, [de]
- bit 2, a
+ bit 2, a ; ENGINE_PHONE_CARD
call nz, .PlacePhoneIcon
ld a, [de]
- bit 1, a
+ bit 1, a ; ENGINE_RADIO_CARD
call nz, .PlaceRadioIcon
hlcoord 0, 0
ld a, $46
@@ -433,6 +462,7 @@ PokegearJumptable: ; 90f04 (24:4f04)
jp hl
.Jumptable: ; 90f13 (24:4f13)
+; entries correspond to POKEGEARSTATE_* constants
dw PokegearClock_Init
dw PokegearClock_Joypad
dw PokegearMap_CheckRegion
@@ -460,32 +490,32 @@ PokegearClock_Joypad: ; 90f3e (24:4f3e)
call .UpdateClock
ld hl, hJoyLast
ld a, [hl]
- and A_BUTTON + B_BUTTON + START + SELECT
+ and A_BUTTON | B_BUTTON | START | SELECT
jr nz, .quit
ld a, [hl]
and D_RIGHT
ret z
ld a, [wPokegearFlags]
- bit 0, a
+ bit 0, a ; ENGINE_MAP_CARD
jr z, .no_map_card
- ld c, $2
- ld b, $1
+ ld c, POKEGEARSTATE_MAPCHECKREGION
+ ld b, POKEGEARCARD_MAP
jr .done
.no_map_card
ld a, [wPokegearFlags]
- bit 2, a
+ bit 2, a ; ENGINE_PHONE_CARD
jr z, .no_phone_card
- ld c, $7
- ld b, $2
+ ld c, POKEGEARSTATE_PHONEINIT
+ ld b, POKEGEARCARD_PHONE
jr .done
.no_phone_card
ld a, [wPokegearFlags]
- bit 1, a
+ bit 1, a ; ENGINE_RADIO_CARD
ret z
- ld c, $b
- ld b, $3
+ ld c, POKEGEARSTATE_RADIOINIT
+ ld b, POKEGEARCARD_RADIO
.done
call Pokegear_SwitchPage
ret
@@ -535,12 +565,12 @@ PokegearMap_CheckRegion: ; 90fb4 (24:4fb4)
cp KANTO_LANDMARK
jr nc, .kanto
.johto
- ld a, 3
+ ld a, POKEGEARSTATE_JOHTOMAPINIT
jr .done
ret
.kanto
- ld a, 5
+ ld a, POKEGEARSTATE_KANTOMAPINIT
.done
ld [wJumptableIndex], a
call ExitPokegearRadio_HandleMusic
@@ -583,23 +613,23 @@ PokegearMap_ContinueMap: ; 90ff2 (24:4ff2)
.right
ld a, [wPokegearFlags]
- bit 2, a
+ bit 2, a ; ENGINE_PHONE_CARD
jr z, .no_phone
- ld c, $7
- ld b, $2
+ ld c, POKEGEARSTATE_PHONEINIT
+ ld b, POKEGEARCARD_PHONE
jr .done
.no_phone
ld a, [wPokegearFlags]
- bit 1, a
+ bit 1, a ; ENGINE_RADIO_CARD
ret z
- ld c, $b
- ld b, $3
+ ld c, POKEGEARSTATE_RADIOINIT
+ ld b, POKEGEARCARD_RADIO
jr .done
.left
- ld c, $0
- ld b, $0
+ ld c, POKEGEARSTATE_CLOCKINIT
+ ld b, POKEGEARCARD_CLOCK
.done
call Pokegear_SwitchPage
ret
@@ -657,7 +687,7 @@ PokegearMap_InitPlayerIcon: ; 9106a
depixel 0, 0
ld b, SPRITE_ANIM_INDEX_RED_WALK
ld a, [wPlayerGender]
- bit 0, a
+ bit 0, a ; ENGINE_PLAYER_IS_FEMALE
jr z, .got_gender
ld b, SPRITE_ANIM_INDEX_BLUE_WALK
.got_gender
@@ -688,7 +718,7 @@ PokegearMap_InitCursor: ; 91098
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
- ld [hl], $4
+ ld [hl], $04
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], SPRITE_ANIM_SEQ_NULL
@@ -734,7 +764,7 @@ PokegearMap_UpdateCursorPosition: ; 910d4
TownMap_GetKantoLandmarkLimits: ; 910e8
ld a, [wStatusFlags]
- bit 6, a
+ bit 6, a ; ENGINE_CREDITS_SKIP
jr z, .not_hof
ld d, ROUTE_28
ld e, PALLET_TOWN
@@ -754,7 +784,7 @@ PokegearRadio_Init: ; 910f9 (24:50f9)
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
- ld [hl], $8
+ ld [hl], $08
call _UpdateRadioStation
ld hl, wJumptableIndex
inc [hl]
@@ -780,23 +810,23 @@ PokegearRadio_Joypad: ; 91112 (24:5112)
.left
ld a, [wPokegearFlags]
- bit 2, a
+ bit 2, a ; ENGINE_PHONE_CARD
jr z, .no_phone
- ld c, $7
- ld b, $2
+ ld c, POKEGEARSTATE_PHONEINIT
+ ld b, POKEGEARCARD_PHONE
jr .switch_page
.no_phone
ld a, [wPokegearFlags]
- bit 0, a
+ bit 0, a ; ENGINE_MAP_CARD
jr z, .no_map
- ld c, $2
- ld b, $1
+ ld c, POKEGEARSTATE_MAPCHECKREGION
+ ld b, POKEGEARCARD_MAP
jr .switch_page
.no_map
- ld c, $0
- ld b, $0
+ ld c, POKEGEARSTATE_CLOCKINIT
+ ld b, POKEGEARCARD_CLOCK
.switch_page
call Pokegear_SwitchPage
ret
@@ -839,23 +869,23 @@ PokegearPhone_Joypad: ; 91171 (24:5171)
.left
ld a, [wPokegearFlags]
- bit 0, a
+ bit 0, a ; ENGINE_MAP_CARD
jr z, .no_map
- ld c, $2
- ld b, $1
+ ld c, POKEGEARSTATE_MAPCHECKREGION
+ ld b, POKEGEARCARD_MAP
jr .switch_page
.no_map
- ld c, $0
- ld b, $0
+ ld c, POKEGEARSTATE_CLOCKINIT
+ ld b, POKEGEARCARD_CLOCK
jr .switch_page
.right
ld a, [wPokegearFlags]
- bit 1, a
+ bit 1, a ; ENGINE_RADIO_CARD
ret z
- ld c, $b
- ld b, $3
+ ld c, POKEGEARSTATE_RADIOINIT
+ ld b, POKEGEARCARD_RADIO
.switch_page
call Pokegear_SwitchPage
ret
@@ -891,12 +921,12 @@ PokegearPhone_Joypad: ; 91171 (24:5171)
ret
.quit_submenu
- ld a, $8
+ ld a, POKEGEARSTATE_PHONEJOYPAD
ld [wJumptableIndex], a
ret
PokegearPhone_MakePhoneCall: ; 911eb (24:51eb)
- call GetMapHeaderPhoneServiceNybble
+ call GetMapPhoneService
and a
jr nz, .no_service
ld hl, Options
@@ -931,7 +961,7 @@ PokegearPhone_MakePhoneCall: ; 911eb (24:51eb)
farcall Phone_NoSignal
ld hl, .OutOfServiceArea
call PrintText
- ld a, $8
+ ld a, POKEGEARSTATE_PHONEJOYPAD
ld [wJumptableIndex], a
ld hl, PokegearText_WhomToCall
call PrintText
@@ -958,7 +988,7 @@ PokegearPhone_FinishPhoneCall: ; 91256 (24:5256)
and A_BUTTON | B_BUTTON
ret z
farcall HangUp
- ld a, $8
+ ld a, POKEGEARSTATE_PHONEJOYPAD
ld [wJumptableIndex], a
ld hl, PokegearText_WhomToCall
call PrintText
@@ -993,7 +1023,7 @@ PokegearPhone_GetDPad: ; 9126d (24:526d)
.down
ld hl, wPokegearPhoneCursorPosition
ld a, [hl]
- cp $3
+ cp 3
jr nc, .scroll_page_down
inc [hl]
jr .done_joypad_same_page
@@ -1001,7 +1031,7 @@ PokegearPhone_GetDPad: ; 9126d (24:526d)
.scroll_page_down
ld hl, wPokegearPhoneScrollPosition
ld a, [hl]
- cp $6
+ cp 6
ret nc
inc [hl]
jr .done_joypad_update_page
@@ -1075,7 +1105,7 @@ PokegearPhone_UpdateDisplayList: ; 912d8 (24:52d8)
ld a, [wPokegearPhoneLoadNameBuffer]
inc a
ld [wPokegearPhoneLoadNameBuffer], a
- cp $4
+ cp 4
jr c, .loop
call PokegearPhone_UpdateCursor
ret
@@ -1309,7 +1339,7 @@ PokegearPhoneContactSubmenu: ; 91342 (24:5342)
; 9146e
-; XXX
+; unused
ld a, [hHours]
cp 12
jr c, .am
@@ -1331,15 +1361,15 @@ Pokegear_SwitchPage: ; 91480 (24:5480)
ld a, c
ld [wJumptableIndex], a
ld a, b
- ld [wcf64], a
+ ld [wPokegearCard], a
call DeleteSpriteAnimStruct2ToEnd
ret
ExitPokegearRadio_HandleMusic: ; 91492
ld a, [wPokegearRadioMusicPlaying]
- cp $fe
+ cp RESTART_MAP_MUSIC
jr z, .restart_map_music
- cp $ff
+ cp ENTER_MAP_MUSIC
call z, EnterMapMusic
xor a
ld [wPokegearRadioMusicPlaying], a
@@ -1364,11 +1394,11 @@ DeleteSpriteAnimStruct2ToEnd: ; 914ab (24:54ab)
Pokegear_LoadTilemapRLE: ; 914bb (24:54bb)
; Format: repeat count, tile ID
- ; Terminated with $FF
+ ; Terminated with -1
hlcoord 0, 0
.loop
ld a, [de]
- cp $ff
+ cp -1
ret z
ld b, a
inc de
@@ -1499,7 +1529,7 @@ UpdateRadioStation: ; 9166f (24:566f)
; 916a1 (24:56a1)
-; XXX
+; unused
ld [wPokegearRadioChannelBank], a
ld a, [hli]
ld [wPokegearRadioChannelAddr], a
@@ -1510,7 +1540,7 @@ UpdateRadioStation: ; 9166f (24:566f)
; 916ad
RadioChannels:
-; frequencies and the shows that play on them.
+; entries correspond to constants/radio_constants.asm
; frequency value given here = 4 × ingame_frequency − 2
dbw 16, .PkmnTalkAndPokedexShow
@@ -1560,7 +1590,7 @@ RadioChannels:
call .InJohto
jr c, .NoSignal
ld a, [wPokegearFlags]
- bit 3, a
+ bit 3, a ; ENGINE_EXPN_CARD
jr z, .NoSignal
jp LoadStation_PlacesAndPeople
@@ -1568,7 +1598,7 @@ RadioChannels:
call .InJohto
jr c, .NoSignal
ld a, [wPokegearFlags]
- bit 3, a
+ bit 3, a ; ENGINE_EXPN_CARD
jr z, .NoSignal
jp LoadStation_LetsAllSing
@@ -1576,14 +1606,14 @@ RadioChannels:
call .InJohto
jr c, .NoSignal
ld a, [wPokegearFlags]
- bit 3, a
+ bit 3, a ; ENGINE_EXPN_CARD
jr z, .NoSignal
jp LoadStation_PokeFluteRadio
.EvolutionRadio:
; This station airs in the Lake of Rage area when Rocket are still in Mahogany.
ld a, [wStatusFlags]
- bit 4, a
+ bit 4, a ; ENGINE_ROCKET_SIGNAL_ON_CH20
jr z, .NoSignal
ld a, [wPokegearMapPlayerIconLandmark]
cp MAHOGANY_TOWN
@@ -1669,7 +1699,7 @@ LoadStation_BuenasPassword: ; 917a5 (24:57a5)
call Radio_BackUpFarCallParams
ld de, NotBuenasPasswordName
ld a, [wStatusFlags2]
- bit 0, a
+ bit 0, a ; ENGINE_ROCKETS_IN_RADIO_TOWER
ret z
ld de, BuenasPasswordName
ret
@@ -1751,7 +1781,7 @@ LoadStation_EvolutionRadio: ; 9183e (24:583e)
; 91853 (24:5853)
-LoadStation_Dummy: ; 91853
+Unreferenced_LoadStation: ; 91853
ret
RadioMusicRestartDE: ; 91854 (24:5854)
@@ -1768,7 +1798,7 @@ RadioMusicRestartDE: ; 91854 (24:5854)
RadioMusicRestartPokemonChannel: ; 91868 (24:5868)
push de
- ld a, $fe
+ ld a, RESTART_MAP_MUSIC
ld [wPokegearRadioMusicPlaying], a
ld de, MUSIC_NONE
call PlayMusic
@@ -1799,7 +1829,7 @@ NoRadioStation: ; 91888 (24:5888)
NoRadioMusic: ; 9189d (24:589d)
ld de, MUSIC_NONE
call PlayMusic
- ld a, $ff
+ ld a, ENTER_MAP_MUSIC
ld [wPokegearRadioMusicPlaying], a
ret
@@ -1810,7 +1840,7 @@ NoRadioName: ; 918a9 (24:58a9)
lb bc, 3, 18
call ClearBox
hlcoord 0, 12
- ld bc, $412
+ lb bc, 4, 18
call TextBox
ret
@@ -1966,26 +1996,26 @@ _TownMap: ; 9191c
ld a, [wTownMapPlayerIconLandmark]
cp KANTO_LANDMARK
jr nc, .kanto2
- ld e, $0
+ ld e, JOHTO_REGION
jr .okay_tilemap
.kanto2
- ld e, $1
+ ld e, KANTO_REGION
.okay_tilemap
farcall PokegearMap
- ld a, $7
+ ld a, $07
ld bc, 6
hlcoord 1, 0
call ByteFill
hlcoord 0, 0
- ld [hl], $6
+ ld [hl], $06
hlcoord 7, 0
ld [hl], $17
hlcoord 7, 1
ld [hl], $16
hlcoord 7, 2
ld [hl], $26
- ld a, $7
+ ld a, $07
ld bc, NAME_LENGTH
hlcoord 8, 2
call ByteFill
@@ -2001,7 +2031,7 @@ PlayRadio: ; 91a53
ld hl, Options
ld a, [hl]
push af
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
call .PlayStation
ld c, 100
call DelayFrames
@@ -2031,10 +2061,10 @@ PlayRadio: ; 91a53
; 91a87
.PlayStation: ; 91a87
- ld a, -1
- ld [EnemyTurnsTaken], a
+ ld a, ENTER_MAP_MUSIC
+ ld [wPokegearRadioMusicPlaying], a
ld hl, .StationPointers
- ld d, $0
+ ld d, 0
add hl, de
add hl, de
ld a, [hli]
@@ -2063,6 +2093,7 @@ PlayRadio: ; 91a53
; 91ab9
.StationPointers: ; 91ab9
+; entries correspond to MAPRADIO_* constants
dw .OakOrPnP
dw LoadStation_OaksPokemonTalk
dw LoadStation_PokedexShow
@@ -2286,7 +2317,7 @@ TownMapBubble: ; 91bb5
GetMapCursorCoordinates: ; 91c17
ld a, [wTownMapPlayerIconLandmark]
ld l, a
- ld h, $0
+ ld h, 0
add hl, hl
ld de, Flypoints
add hl, de
@@ -2296,10 +2327,10 @@ GetMapCursorCoordinates: ; 91c17
ld c, a
ld a, [wTownMapCursorCoordinates + 1]
ld b, a
- ld hl, $4
+ ld hl, 4
add hl, bc
ld [hl], e
- ld hl, $5
+ ld hl, 5
add hl, bc
ld [hl], d
ret
@@ -2331,7 +2362,7 @@ HasVisitedSpawn: ; 91c50
ld hl, wVisitedSpawns
ld b, CHECK_FLAG
ld d, 0
- predef FlagPredef
+ predef SmallFarFlagAction
ld a, c
ret
@@ -2440,7 +2471,7 @@ FlyMap: ; 91c90
; 91d11
-_Area: ; 91d11
+Pokedex_GetArea: ; 91d11
; e: Current landmark
ld a, [wTownMapPlayerIconLandmark]
push af
@@ -2477,7 +2508,7 @@ _Area: ; 91d11
call SetPalettes
xor a
ld [hBGMapMode], a
- xor a ; Johto
+ xor a ; JOHTO_REGION
call .GetAndPlaceNest
.loop
call JoyTextDelay
@@ -2524,13 +2555,13 @@ _Area: ; 91d11
call ClearSprites
ld a, $90
ld [hWY], a
- xor a ; Johto
+ xor a ; JOHTO_REGION
call .GetAndPlaceNest
ret
.right
ld a, [wStatusFlags]
- bit 6, a ; hall of fame
+ bit 6, a ; ENGINE_CREDITS_SKIP
ret z
ld a, [hWY]
and a
@@ -2538,7 +2569,7 @@ _Area: ; 91d11
call ClearSprites
xor a
ld [hWY], a
- ld a, 1 ; Kanto
+ ld a, KANTO_REGION
call .GetAndPlaceNest
ret
@@ -2596,7 +2627,7 @@ _Area: ; 91d11
ld e, a
farcall FindNest ; load nest landmarks into TileMap[0,0]
decoord 0, 0
- ld hl, Sprites
+ ld hl, Sprite01
.nestloop
ld a, [de]
and a
@@ -2609,14 +2640,14 @@ _Area: ; 91d11
; load into OAM
ld a, d
sub 4
- ld [hli], a
+ ld [hli], a ; y
ld a, e
sub 4
- ld [hli], a
- ld a, $7f ; nest icon in this context
- ld [hli], a
+ ld [hli], a ; x
+ ld a, $7f ; nest icon
+ ld [hli], a ; tile id
xor a
- ld [hli], a
+ ld [hli], a ; attributes
; next
pop de
inc de
@@ -2640,37 +2671,37 @@ _Area: ; 91d11
ld c, e
ld b, d
ld de, .PlayerOAM
- ld hl, Sprites
+ ld hl, Sprite01
.ShowPlayerLoop:
ld a, [de]
cp $80
jr z, .clear_oam
add b
- ld [hli], a
+ ld [hli], a ; y
inc de
ld a, [de]
add c
- ld [hli], a
+ ld [hli], a ; x
inc de
ld a, [de]
add $78 ; where the player's sprite is loaded
- ld [hli], a
+ ld [hli], a ; tile id
inc de
push bc
- ld c, 0 ; RED
+ ld c, PAL_OW_RED
ld a, [wPlayerGender]
bit 0, a
- jr z, .got_gender
- inc c ; BLUE
-.got_gender
+ jr z, .male
+ inc c ; PAL_OW_BLUE
+.male
ld a, c
- ld [hli], a
+ ld [hli], a ; attributes
pop bc
jr .ShowPlayerLoop
.clear_oam
- ld hl, Sprites + 4 * 4
- ld bc, SpritesEnd - (Sprites + 4 * 4)
+ ld hl, Sprite05
+ ld bc, SpritesEnd - Sprite05
xor a
call ByteFill
ret
@@ -2678,10 +2709,11 @@ _Area: ; 91d11
; 91e9c
.PlayerOAM: ; 91e9c
- db -1 * 8, -1 * 8, 0 ; top left
- db -1 * 8, 0 * 8, 1 ; top right
- db 0 * 8, -1 * 8, 2 ; bottom left
- db 0 * 8, 0 * 8, 3 ; bottom right
+ ; y pxl, x pxl, tile offset
+ db -1 * 8, -1 * 8, 0 ; top left
+ db -1 * 8, 0 * 8, 1 ; top right
+ db 0 * 8, -1 * 8, 2 ; bottom left
+ db 0 * 8, 0 * 8, 3 ; bottom right
db $80 ; terminator
; 91ea9
@@ -2790,12 +2822,11 @@ TownMapPals: ; 91f13
; Current tile
ld a, [hli]
push hl
-; HP/borders use palette 0
+; The palette map covers tiles $00 to $5f; $60 and above use palette 0
cp $60
jr nc, .pal0
-; The palette data is condensed to nybbles,
-; least-significant first.
+; The palette data is condensed to nybbles, least-significant first.
ld hl, .PalMap
srl a
jr c, .odd
@@ -2806,7 +2837,7 @@ TownMapPals: ; 91f13
adc 0
ld h, a
ld a, [hl]
- and %111
+ and PALETTE_MASK
jr .update
.odd
@@ -2818,7 +2849,7 @@ TownMapPals: ; 91f13
ld h, a
ld a, [hl]
swap a
- and %111
+ and PALETTE_MASK
jr .update
.pal0
@@ -2834,11 +2865,11 @@ TownMapPals: ; 91f13
ret
.PalMap:
-INCLUDE "data/palettes/town_map.asm"
+INCLUDE "gfx/pokegear/town_map_palette_map.asm"
; 91f7b
TownMapMon: ; 91f7b
-; Draw the FlyMon icon at town map location in
+; Draw the FlyMon icon at town map location
; Get FlyMon species
ld a, [CurPartyMon]
@@ -2849,7 +2880,7 @@ TownMapMon: ; 91f7b
ld a, [hl]
ld [wd265], a
; Get FlyMon icon
- ld e, 8 ; starting tile in VRAM
+ ld e, $08 ; starting tile in VRAM
farcall GetSpeciesIcon
; Animation/palette
depixel 0, 0
@@ -2857,7 +2888,7 @@ TownMapMon: ; 91f7b
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
- ld [hl], $8
+ ld [hl], $08
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], SPRITE_ANIM_SEQ_NULL
@@ -2913,7 +2944,7 @@ TownMapPlayerIcon: ; 91fa6
LoadTownMapGFX: ; 91ff2
ld hl, TownMapGFX
ld de, vTiles2
- lb bc, BANK(TownMapGFX), $30
+ lb bc, BANK(TownMapGFX), 48
call DecompressRequest2bpp
ret
@@ -2932,7 +2963,7 @@ INCBIN "gfx/pokegear/dexmap_nest_icon.2bpp"
FlyMapLabelBorderGFX: ; 922e1
INCBIN "gfx/pokegear/flymap_label_border.1bpp"
-; XXX
+Unreferenced_Function92311:
xor a
ld [wTownMapPlayerIconLandmark], a
call ClearBGPalettes
diff --git a/engine/predef.asm b/engine/predef.asm
index 837f7b96b..6c8c2c5f2 100644
--- a/engine/predef.asm
+++ b/engine/predef.asm
@@ -26,83 +26,4 @@ GetPredefPointer:: ; 854b
ret
; 856b
-PredefPointers:: ; 856b
-; $4b Predef pointers
-; address, bank
-
- add_predef LearnMove ; $0
- add_predef Predef1
- add_predef HealParty
- add_predef FlagPredef
- add_predef ComputeHPBarPixels
- add_predef FillPP
- add_predef TryAddMonToParty
- add_predef AddTempmonToParty
- add_predef SentGetPkmnIntoFromBox
- add_predef SentPkmnIntoBox
- add_predef GiveEgg
- add_predef AnimateHPBar
- add_predef CalcPkmnStats
- add_predef CalcPkmnStatC
- add_predef CanLearnTMHMMove
- add_predef GetTMHMMove
- add_predef Predef_LinkTextbox ; $ 10
- add_predef PrintMoveDesc
- add_predef UpdatePlayerHUD
- add_predef PlaceGraphic
- add_predef CheckPlayerPartyForFitPkmn
- add_predef UpdateEnemyHUD
- add_predef StartBattle
- add_predef FillInExpBar
- add_predef GetBattleMonBackpic ; $18
- add_predef GetEnemyMonFrontpic
- add_predef LearnLevelMoves
- add_predef FillMoves
- add_predef EvolveAfterBattle
- add_predef TradeAnimationPlayer2
- add_predef TradeAnimation
- add_predef CopyPkmnToTempMon
- add_predef ListMoves ; $20
- add_predef PlaceNonFaintStatus
- add_predef Predef22
- add_predef ListMovePP
- add_predef GetGender
- add_predef StatsScreenInit
- add_predef DrawPlayerHP
- add_predef DrawEnemyHP
- add_predef PrintTempMonStats ; $28
- add_predef GetTypeName
- add_predef PrintMoveType
- add_predef PrintType
- add_predef PrintMonTypes
- add_predef GetUnownLetter
- add_predef LoadPoisonBGPals
- add_predef Predef2F
- add_predef InitSGBBorder ; $30
- add_predef Predef_LoadSGBLayout
- add_predef _Area
- add_predef CheckContestMon
- add_predef Predef_StartBattle
- add_predef Predef35
- add_predef Predef36
- add_predef PlayBattleAnim
- add_predef Predef38 ; $38
- add_predef Predef39
- add_predef Predef3A
- add_predef PartyMonItemName
- add_predef GetMonFrontpic
- add_predef GetMonBackpic
- add_predef GetAnimatedFrontpicPredef
- add_predef GetTrainerPic
- add_predef DecompressPredef ; $40
- add_predef CheckTypeMatchup
- add_predef ConvertMon_1to2
- add_predef NewPokedexEntry
- add_predef AnimateMon_Slow_Normal
- add_predef PlaceStatusString
- add_predef LoadMonAnimation
- add_predef AnimateFrontpic
- add_predef Predef48 ; $48
- add_predef HOF_AnimateFrontpic
- dbw $ff, InexplicablyEmptyFunction ; ???
-; 864c
+INCLUDE "data/predef_pointers.asm"
diff --git a/engine/print_party.asm b/engine/print_party.asm
index f2420dfe8..7c23528f3 100755
--- a/engine/print_party.asm
+++ b/engine/print_party.asm
@@ -1,3 +1,5 @@
+PRINTPARTY_HP EQUS "\"◀\"" ; $71
+
PrintPage1: ; 1dc1b0
hlcoord 0, 0
decoord 0, 0, wPrinterTileMapBuffer
@@ -141,18 +143,18 @@ PrintPartyMonPage1: ; 1dc381
call LoadFontsBattleExtra
ld de, GBPrinterHPIcon
- ld hl, vTiles2 tile $71
+ ld hl, vTiles2 tile PRINTPARTY_HP
lb bc, BANK(GBPrinterHPIcon), 1
call Request1bpp
ld de, GBPrinterLvIcon
- ld hl, vTiles2 tile $6e
+ ld hl, vTiles2 tile "<LV>"
lb bc, BANK(GBPrinterLvIcon), 1
call Request1bpp
- ld de, ShinyIconGFX
- ld hl, vTiles2 tile $3f
- lb bc, BANK(ShinyIconGFX), 1
+ ld de, StatsScreenPageTilesGFX + 14 tiles ; shiny icon
+ ld hl, vTiles2 tile "⁂"
+ lb bc, BANK(StatsScreenPageTilesGFX), 1
call Get2bpp
xor a
@@ -166,7 +168,7 @@ PrintPartyMonPage1: ; 1dc381
ld a, [TempMonLevel]
call PrintLevel_Force3Digits
hlcoord 12, 2
- ld [hl], "◀" ; Filled left triangle
+ ld [hl], PRINTPARTY_HP
inc hl
ld de, TempMonMaxHP
lb bc, 2, 3
@@ -330,7 +332,7 @@ Function1dc52c: ; 1dc52c
farcall CheckShininess
ret nc
hlcoord 18, 2
- ld [hl], "<SHINY>"
+ ld [hl], "⁂"
ret
; 1dc550
diff --git a/engine/printer.asm b/engine/printer.asm
index 68c3c6c9f..4479d5d0b 100755
--- a/engine/printer.asm
+++ b/engine/printer.asm
@@ -596,8 +596,7 @@ PlacePrinterStatusString: ; 84785
ret
; 847bd
-Function847bd: ; 847bd
-; XXX
+Unreferenced_Function847bd: ; 847bd
ld a, [wPrinterStatus]
and a
ret z
@@ -775,10 +774,10 @@ Printer_PrintBoxListSegment: ; 848e7 (21:48e7)
pop hl
jr z, .ok2
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
add hl, bc
call Printer_GetMonGender
- ld bc, SCREEN_WIDTH - PKMN_NAME_LENGTH
+ ld bc, SCREEN_WIDTH - MON_NAME_LENGTH
add hl, bc
ld a, "/"
ld [hli], a
@@ -796,7 +795,7 @@ Printer_PrintBoxListSegment: ; 848e7 (21:48e7)
ld h, a
ld bc, sBoxMonNicknames - sBox
add hl, bc
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
ld a, [wWhichBoxMonToPrint]
call AddNTimes
ld e, l
@@ -807,7 +806,7 @@ Printer_PrintBoxListSegment: ; 848e7 (21:48e7)
call PlaceString
pop hl
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
add hl, bc
push hl
ld a, [wAddrOfBoxToPrint]
diff --git a/engine/printnum.asm b/engine/printnum.asm
index d1d7e7ad3..fec798d5c 100755
--- a/engine/printnum.asm
+++ b/engine/printnum.asm
@@ -165,7 +165,7 @@ _PrintNum:: ; c4c7
dec e
jr nz, .money_leading_zero
inc hl
- ld [hl], $f2 ; XXX
+ ld [hl], "<DOT>"
.money_leading_zero
call .AdvancePointer
diff --git a/engine/radio.asm b/engine/radio.asm
index 42db63ab0..df0d81679 100644
--- a/engine/radio.asm
+++ b/engine/radio.asm
@@ -28,6 +28,7 @@ PlayRadioShow:
jp hl
RadioJumptable:
+; entries correspond to constants/radio_constants.asm
dw OaksPkmnTalk1 ; $00
dw PokedexShow1 ; $01
dw BenMonMusic1 ; $02
@@ -133,7 +134,7 @@ PrintRadioLine:
cp 2
jr nc, .print
inc hl
- ld [hl], "<START>"
+ ld [hl], TX_START
inc a
ld [wNumRadioLinesPrinted], a
cp 2
@@ -203,11 +204,11 @@ OaksPkmnTalk4:
; Choose a random route, and a random Pokemon from that route.
.sample
call Random
- and $1f
- cp $f ; so wasteful
+ and %11111
+ cp (OaksPkmnTalkRoutesEnd - OaksPkmnTalkRoutes) / 2
jr nc, .sample
; We now have a number between 0 and 14.
- ld hl, .routes
+ ld hl, OaksPkmnTalkRoutes
ld c, a
ld b, 0
add hl, bc
@@ -239,14 +240,15 @@ OaksPkmnTalk4:
jr .loop
.done
+ ; Point hl to the list of morning Pokémon., skipping percentages
rept 4
inc hl
endr
; Generate a number, either 0, 1, or 2, to choose a time of day.
.loop2
call Random
- and 3
- cp 3
+ maskbits NUM_DAYTIMES
+ cp DARKNESS_F
jr z, .loop2
ld bc, 2 * NUM_GRASSMON
@@ -271,8 +273,9 @@ endr
call GetPokemonName
ld hl, StringBuffer1
ld de, wMonOrItemNameBuffer
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
+
; Now that we've chosen our wild Pokemon,
; let's recover the map index info and get its name.
pop bc
@@ -289,22 +292,7 @@ endr
ld a, OAKS_POKEMON_TALK
jp PrintRadioLine
-.routes
- map ROUTE_29
- map ROUTE_46
- map ROUTE_30
- map ROUTE_32
- map ROUTE_34
- map ROUTE_35
- map ROUTE_37
- map ROUTE_38
- map ROUTE_39
- map ROUTE_42
- map ROUTE_43
- map ROUTE_44
- map ROUTE_45
- map ROUTE_36
- map ROUTE_31
+INCLUDE "data/radio/oaks_pkmn_talk_routes.asm"
OaksPkmnTalk5:
ld hl, OPT_OakText2
@@ -360,11 +348,13 @@ OPT_MaryText1:
db "@"
OaksPkmnTalk8:
+ ; 0-15 are all valid indexes into .Adverbs,
+ ; so no need for a retry loop
call Random
- and $f
+ maskbits NUM_OAKS_MON_TALK_ADVERBS
ld e, a
ld d, 0
- ld hl, .Descriptors
+ ld hl, .Adverbs
add hl, de
add hl, de
ld a, [hli]
@@ -373,7 +363,8 @@ OaksPkmnTalk8:
ld a, OAKS_POKEMON_TALK_9
jp NextRadioLine
-.Descriptors:
+.Adverbs:
+; there are NUM_OAKS_MON_TALK_ADVERBS entries
dw .sweetadorably
dw .wigglyslickly
dw .aptlynamed
@@ -472,11 +463,13 @@ OaksPkmnTalk8:
db "@"
OaksPkmnTalk9:
+ ; 0-15 are all valid indexes into .Adjectives,
+ ; so no need for a retry loop
call Random
- and $f
+ maskbits NUM_OAKS_MON_TALK_ADJECTIVES
ld e, a
ld d, 0
- ld hl, .Descriptors
+ ld hl, .Adjectives
add hl, de
add hl, de
ld a, [hli]
@@ -493,7 +486,8 @@ OaksPkmnTalk9:
.ok
jp NextRadioLine
-.Descriptors:
+.Adjectives:
+; there are NUM_OAKS_MON_TALK_ADJECTIVES entries
dw .cute
dw .weird
dw .pleasant
@@ -652,7 +646,7 @@ OaksPkmnTalk14:
ld hl, wRadioTextDelay
dec [hl]
ret nz
- ld de, $1d
+ ld de, MUSIC_POKEMON_TALK
callfar RadioMusicRestartDE
ld hl, .terminator
call PrintText
@@ -698,8 +692,8 @@ PokedexShow_GetDexEntryBank:
dec a
rlca
rlca
- and 3
- ld hl, .pokedexbanks
+ maskbits NUM_DEX_ENTRY_BANKS
+ ld hl, .PokedexEntryBanks
ld d, 0
ld e, a
add hl, de
@@ -708,7 +702,7 @@ PokedexShow_GetDexEntryBank:
pop hl
ret
-.pokedexbanks
+.PokedexEntryBanks
db BANK(PokedexEntries1)
db BANK(PokedexEntries2)
db BANK(PokedexEntries3)
@@ -819,7 +813,7 @@ CopyDexEntryPart1:
ld bc, SCREEN_WIDTH - 1
call FarCopyBytes
ld hl, wPokedexShowPointerAddr
- ld [hl], "<START>"
+ ld [hl], TX_START
inc hl
ld [hl], "<LINE>"
inc hl
@@ -1146,7 +1140,7 @@ PeoplePlaces2:
PeoplePlaces3:
ld hl, PnP_Text3
call Random
- cp $7b ; 48 percent
+ cp 49 percent - 1
ld a, PLACES_AND_PEOPLE_4 ; People
jr c, .ok
ld a, PLACES_AND_PEOPLE_6 ; Places
@@ -1170,20 +1164,20 @@ PnP_Text3:
PeoplePlaces4: ; People
call Random
- and $7f
+ maskbits NUM_TRAINER_CLASSES
inc a
cp NUM_TRAINER_CLASSES - 1
jr nc, PeoplePlaces4
push af
- ld hl, .E4Names
+ ld hl, PnP_HiddenPeople
ld a, [wStatusFlags]
bit 6, a ; ENGINE_CREDITS_SKIP
jr z, .ok
- ld hl, .KantoLeaderNames
+ ld hl, PnP_HiddenPeople_BeatE4
ld a, [wKantoBadges]
- cp %11111111
+ cp %11111111 ; all badges
jr nz, .ok
- ld hl, .MiscNames
+ ld hl, PnP_HiddenPeople_BeatKanto
.ok
pop af
ld c, a
@@ -1203,10 +1197,7 @@ PeoplePlaces4: ; People
ld a, PLACES_AND_PEOPLE_5
jp NextRadioLine
-.E4Names: db WILL, BRUNO, KAREN, KOGA, CHAMPION
-.KantoLeaderNames: db BROCK, MISTY, LT_SURGE, ERIKA, JANINE, SABRINA, BLAINE, BLUE
-.MiscNames: db RIVAL1, POKEMON_PROF, CAL, RIVAL2, RED
- db -1
+INCLUDE "data/radio/pnp_hidden_people.asm"
PnP_Text4:
; @ @ @
@@ -1214,29 +1205,32 @@ PnP_Text4:
db "@"
PeoplePlaces5:
+ ; 0-15 are all valid indexes into .Adjectives,
+ ; so no need for a retry loop
call Random
- and $f
+ maskbits NUM_PNP_PEOPLE_ADJECTIVES
ld e, a
ld d, 0
- ld hl, .Descriptors
+ ld hl, .Adjectives
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
call Random
- cp $a ; 6.25 percent
+ cp 4 percent
ld a, PLACES_AND_PEOPLE
jr c, .ok
call Random
- cp $7b ; 48 percent
+ cp 49 percent - 1
ld a, PLACES_AND_PEOPLE_4 ; People
jr c, .ok
ld a, PLACES_AND_PEOPLE_6 ; Places
.ok
jp NextRadioLine
-.Descriptors:
+.Adjectives:
+; there are NUM_PNP_PEOPLE_ADJECTIVES entries
dw PnP_cute
dw PnP_lazy
dw PnP_happy
@@ -1336,9 +1330,9 @@ PnP_odd:
PeoplePlaces6: ; Places
call Random
- cp 9
+ cp (PnP_HiddenPlacesEnd - PnP_HiddenPlaces) / 2
jr nc, PeoplePlaces6
- ld hl, .Maps
+ ld hl, PnP_HiddenPlaces
ld c, a
ld b, 0
add hl, bc
@@ -1353,16 +1347,7 @@ PeoplePlaces6: ; Places
ld a, PLACES_AND_PEOPLE_7
jp NextRadioLine
-.Maps:
- map PALLET_TOWN
- map ROUTE_22
- map PEWTER_CITY
- map CERULEAN_POLICE_STATION
- map ROUTE_12
- map ROUTE_11
- map ROUTE_16
- map ROUTE_14
- map CINNABAR_POKECENTER_2F_BETA
+INCLUDE "data/radio/pnp_hidden_places.asm"
PnP_Text5:
; @ @
@@ -1370,11 +1355,13 @@ PnP_Text5:
db "@"
PeoplePlaces7:
+ ; 0-15 are all valid indexes into .Adjectives,
+ ; so no need for a retry loop
call Random
- and $f
+ maskbits NUM_PNP_PLACES_ADJECTIVES
ld e, a
ld d, 0
- ld hl, .Descriptors
+ ld hl, .Adjectives
add hl, de
add hl, de
ld a, [hli]
@@ -1386,14 +1373,15 @@ PeoplePlaces7:
ld a, PLACES_AND_PEOPLE
jr c, .ok
call Random
- cp 1 + 48 percent
+ cp 49 percent - 1
ld a, PLACES_AND_PEOPLE_4 ; People
jr c, .ok
ld a, PLACES_AND_PEOPLE_6 ; Places
.ok
jp PrintRadioLine
-.Descriptors:
+.Adjectives:
+; there are NUM_PNP_PLACES_ADJECTIVES entries
dw PnP_cute
dw PnP_lazy
dw PnP_happy
@@ -1572,7 +1560,7 @@ BuenasPassword4:
ld a, [wBuenasPassword]
; If we already generated the password today, we don't need to generate a new one.
ld hl, wWeeklyFlags
- bit 7, [hl]
+ bit 7, [hl] ; ENGINE_BUENAS_PASSWORD
jr nz, .AlreadyGotIt
; There are only 11 groups to choose from.
.greater_than_11
@@ -1586,7 +1574,7 @@ BuenasPassword4:
; For each group, choose one of the three passwords.
.greater_than_three
call Random
- and $3
+ maskbits NUM_PASSWORDS_PER_CATEGORY
cp NUM_PASSWORDS_PER_CATEGORY
jr nc, .greater_than_three
; The high nybble of wBuenasPassword will now contain the password group index, and the low nybble contains the actual password.
@@ -1594,7 +1582,7 @@ BuenasPassword4:
ld [wBuenasPassword], a
; Set the flag so that we don't generate a new password this week.
ld hl, wWeeklyFlags
- set 7, [hl]
+ set 7, [hl] ; ENGINE_BUENAS_PASSWORD
.AlreadyGotIt:
ld c, a
call GetBuenasPassword
@@ -1608,7 +1596,7 @@ GetBuenasPassword:
ld a, c
swap a
and $f
- ld hl, PasswordTable
+ ld hl, BuenasPasswordTable
ld d, 0
ld e, a
add hl, de
@@ -1640,11 +1628,11 @@ GetBuenasPassword:
ret
.StringFunctionJumpTable:
- dw .Mon
- dw .Item
- dw .Move
- dw .RawString
-
+; entries correspond to BUENA_* constants
+ dw .Mon ; BUENA_MON
+ dw .Item ; BUENA_ITEM
+ dw .Move ; BUENA_MOVE
+ dw .RawString ; BUENA_STRING
.Mon:
call .GetTheIndex
@@ -1693,30 +1681,7 @@ GetBuenasPassword:
ld de, StringBuffer1
ret
-PasswordTable:
- dw .JohtoStarters
- dw .Beverages
- dw .HealingItems
- dw .Balls
- dw .Pokemon1
- dw .Pokemon2
- dw .JohtoTowns
- dw .Types
- dw .Moves
- dw .XItems
- dw .RadioStations
- ; string type, points, option 1, option 2, option 3
-.JohtoStarters: db BUENA_MON, 10, CYNDAQUIL, TOTODILE, CHIKORITA
-.Beverages: db BUENA_ITEM, 12, FRESH_WATER, SODA_POP, LEMONADE
-.HealingItems: db BUENA_ITEM, 12, POTION, ANTIDOTE, PARLYZ_HEAL
-.Balls: db BUENA_ITEM, 12, POKE_BALL, GREAT_BALL, ULTRA_BALL
-.Pokemon1: db BUENA_MON, 10, PIKACHU, RATTATA, GEODUDE
-.Pokemon2: db BUENA_MON, 10, HOOTHOOT, SPINARAK, DROWZEE
-.JohtoTowns: db BUENA_STRING, 16, "NEW BARK TOWN@", "CHERRYGROVE CITY@", "AZALEA TOWN@"
-.Types: db BUENA_STRING, 6, "FLYING@", "BUG@", "GRASS@"
-.Moves: db BUENA_MOVE, 12, TACKLE, GROWL, MUD_SLAP
-.XItems: db BUENA_ITEM, 12, X_ATTACK, X_DEFEND, X_SPEED
-.RadioStations: db BUENA_STRING, 13, "#MON Talk@", "#MON Music@", "Lucky Channel@"
+INCLUDE "data/radio/buenas_passwords.asm"
BuenasPassword5:
ld hl, BuenaRadioText5
@@ -1738,14 +1703,14 @@ BuenasPassword7:
BuenasPasswordAfterMidnight:
push hl
ld hl, wWeeklyFlags
- res 7, [hl]
+ res 7, [hl] ; ENGINE_BUENAS_PASSWORD
pop hl
ld a, BUENAS_PASSWORD_8
jp NextRadioLine
BuenasPassword8:
ld hl, wWeeklyFlags
- res 7, [hl]
+ res 7, [hl] ; ENGINE_BUENAS_PASSWORD
ld hl, BuenaRadioMidnightText10
ld a, BUENAS_PASSWORD_9
jp NextRadioLine
@@ -1958,18 +1923,7 @@ StartRadioStation:
callfar RadioMusicRestartDE
ret
-RadioChannelSongs:
- dw MUSIC_POKEMON_TALK
- dw MUSIC_POKEMON_CENTER
- dw MUSIC_TITLE
- dw MUSIC_GAME_CORNER
- dw MUSIC_BUENAS_PASSWORD
- dw MUSIC_VIRIDIAN_CITY
- dw MUSIC_BICYCLE
- dw MUSIC_ROCKET_OVERTURE
- dw MUSIC_POKE_FLUTE_CHANNEL
- dw MUSIC_RUINS_OF_ALPH_RADIO
- dw MUSIC_LAKE_OF_RAGE_ROCKET_RADIO
+INCLUDE "data/radio/channel_music.asm"
NextRadioLine:
push af
diff --git a/engine/routines/checknickerrors.asm b/engine/routines/checknickerrors.asm
index 1cedca420..87ebd6bb3 100644
--- a/engine/routines/checknickerrors.asm
+++ b/engine/routines/checknickerrors.asm
@@ -6,7 +6,7 @@ CheckNickErrors:: ; 669f
push bc
push de
- ld b, PKMN_NAME_LENGTH
+ ld b, MON_NAME_LENGTH
.checkchar
; end of nick?
@@ -64,10 +64,10 @@ CheckNickErrors:: ; 669f
; table defining which characters are actually text commands
; format:
; ≥ <
- db "<START>", TX_BOX + 1
- db "<PLAY_G>", $18 + 1
- db $1d, "%" + 1
- db $35, "<GREEN>" + 1
+ db TX_START, TX_BOX + 1
+ db "<PLAY_G>", "<JP_18>" + 1
+ db "<NI>", "<NO>" + 1
+ db "<ROUTE>", "<GREEN>" + 1
db "<ENEMY>", "<ENEMY>" + 1
db "<MOM>", "<TM>" + 1
db "<ROCKET>", "┘" + 1
diff --git a/engine/routines/correcterrorsinplayerparty.asm b/engine/routines/correcterrorsinplayerparty.asm
index 2fa98a545..42e550900 100644
--- a/engine/routines/correcterrorsinplayerparty.asm
+++ b/engine/routines/correcterrorsinplayerparty.asm
@@ -1,4 +1,4 @@
-CorrectErrorsInPlayerParty: ; unreferenced
+Unreferenced_CorrectErrorsInPlayerParty:
ld hl, PartyCount
ld a, [hl]
and a
@@ -128,7 +128,7 @@ CorrectErrorsInPlayerParty: ; unreferenced
ld hl, StringBuffer1
.got_nickname
pop de
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
pop bc
diff --git a/engine/routines/drawkrispackgfx.asm b/engine/routines/drawkrispackgfx.asm
index 457dd7110..54a21e447 100644
--- a/engine/routines/drawkrispackgfx.asm
+++ b/engine/routines/drawkrispackgfx.asm
@@ -11,10 +11,10 @@ DrawKrisPackGFX: ; 48e81
ret
PackFGFXPointers: ; 48e93
- dw PackFGFX + (15 tiles) * 1
- dw PackFGFX + (15 tiles) * 3
- dw PackFGFX + (15 tiles) * 0
- dw PackFGFX + (15 tiles) * 2
+ dw PackFGFX + (15 tiles) * 1 ; ITEM_POCKET
+ dw PackFGFX + (15 tiles) * 3 ; BALL_POCKET
+ dw PackFGFX + (15 tiles) * 0 ; KEY_ITEM_POCKET
+ dw PackFGFX + (15 tiles) * 2 ; TM_HM_POCKET
PackFGFX: ; 48e9b
INCBIN "gfx/pack/pack_f.2bpp"
diff --git a/engine/routines/emptyallsrambanks.asm b/engine/routines/emptyallsrambanks.asm
index aa4b28e0d..8b060f3ef 100644
--- a/engine/routines/emptyallsrambanks.asm
+++ b/engine/routines/emptyallsrambanks.asm
@@ -1,11 +1,11 @@
EmptyAllSRAMBanks: ; 4cf1f
- ld a, $0
+ ld a, 0
call .EmptyBank
- ld a, $1
+ ld a, 1
call .EmptyBank
- ld a, $2
+ ld a, 2
call .EmptyBank
- ld a, $3
+ ld a, 3
call .EmptyBank
ret
diff --git a/engine/routines/flagpredef.asm b/engine/routines/flagpredef.asm
index bd4f37882..2a6d91ee1 100644
--- a/engine/routines/flagpredef.asm
+++ b/engine/routines/flagpredef.asm
@@ -1,5 +1,5 @@
-FlagPredef: ; 4d7c1
-; Perform action b on flag c in flag array hl.
+SmallFarFlagAction: ; 4d7c1
+; Perform action b on bit c in flag array hl.
; If checking a flag, check flag array d:hl unless d is 0.
; For longer flag arrays, see FlagAction.
diff --git a/engine/routines/getsquareroot.asm b/engine/routines/getsquareroot.asm
index 0ba2e50a5..412fd04ff 100644
--- a/engine/routines/getsquareroot.asm
+++ b/engine/routines/getsquareroot.asm
@@ -1,3 +1,5 @@
+NUM_SQUARE_ROOTS EQU 255
+
GetSquareRoot: ; 13b87
; Return the square root of de in b.
@@ -10,7 +12,7 @@ GetSquareRoot: ; 13b87
; Make sure we don't go past the end of the table.
inc b
ld a, b
- cp $ff
+ cp NUM_SQUARE_ROOTS
ret z
; Iterate over the table until b**2 >= de.
@@ -23,8 +25,8 @@ GetSquareRoot: ; 13b87
ret
.Squares: ; 13b98
-root = 1
- rept $ff
- dw root * root
-root = root + 1
- endr
+x = 1
+rept NUM_SQUARE_ROOTS
+ dw x * x
+x = x + 1
+endr
diff --git a/engine/routines/initlist.asm b/engine/routines/initlist.asm
index e2b7235ab..b7260e552 100644
--- a/engine/routines/initlist.asm
+++ b/engine/routines/initlist.asm
@@ -21,7 +21,7 @@ InitList: ; 50db9
jr nz, .check_item_name
ld hl, CurMart
ld de, PokemonNames
- ld a, PKMN_NAME
+ ld a, MON_NAME
jr .done
.check_item_name
diff --git a/engine/routines/loadoverworldfont.asm b/engine/routines/loadoverworldfont.asm
new file mode 100644
index 000000000..f23f01c4e
--- /dev/null
+++ b/engine/routines/loadoverworldfont.asm
@@ -0,0 +1,17 @@
+LoadOverworldFont:: ; 106594
+ ld de, .OverworldFontGFX
+ ld hl, vTiles1
+ lb bc, BANK(.OverworldFontGFX), $80
+ call Get2bpp
+ ld de, .OverworldFontSpaceGFX
+ ld hl, vTiles2 tile " "
+ lb bc, BANK(.OverworldFontSpaceGFX), 1
+ call Get2bpp
+ ret
+; 1065ad
+
+.OverworldFontGFX:
+INCBIN "gfx/font/overworld.2bpp"
+
+.OverworldFontSpaceGFX:
+INCBIN "gfx/font/overworld_space.2bpp"
diff --git a/engine/routines/loadpushoam.asm b/engine/routines/loadpushoam.asm
index 6af0ddf6d..c07c06d0f 100644
--- a/engine/routines/loadpushoam.asm
+++ b/engine/routines/loadpushoam.asm
@@ -13,7 +13,7 @@ LoadPushOAM:: ; 4031
.PushOAM: ; 403f
ld a, HIGH(Sprites)
ld [rDMA], a
- ld a, (SpritesEnd - Sprites) / 4 ; 40
+ ld a, NUM_SPRITE_OAM_STRUCTS
.pushoam_loop
dec a
jr nz, .pushoam_loop
diff --git a/engine/routines/placegraphic.asm b/engine/routines/placegraphic.asm
index d72364776..21b914950 100644
--- a/engine/routines/placegraphic.asm
+++ b/engine/routines/placegraphic.asm
@@ -1,7 +1,6 @@
PlaceGraphic: ; 2ef6e
; Fill wBoxAlignment-aligned box width b height c
; with iterating tile starting from hGraphicStartTile at hl.
-; Predef $13
ld de, SCREEN_WIDTH
diff --git a/engine/routines/placewaitingtext.asm b/engine/routines/placewaitingtext.asm
index 37fc2a056..9b2260722 100644
--- a/engine/routines/placewaitingtext.asm
+++ b/engine/routines/placewaitingtext.asm
@@ -11,7 +11,7 @@ PlaceWaitingText:: ; 4000
jr .proceed
.notinbattle
- predef Predef_LinkTextbox
+ predef LinkTextboxAtHL
.proceed
hlcoord 4, 11
diff --git a/engine/routines/playslowcry.asm b/engine/routines/playslowcry.asm
index 3cc347a55..545629e51 100644
--- a/engine/routines/playslowcry.asm
+++ b/engine/routines/playslowcry.asm
@@ -1,6 +1,6 @@
-PlaySlowCry: ; fb841
+Special_PlaySlowCry: ; fb841
ld a, [ScriptVar]
- call LoadCryHeader
+ call LoadCry
jr c, .done
ld hl, CryPitch
@@ -23,7 +23,7 @@ PlaySlowCry: ; fb841
ld [CryLength], a
ld a, h
ld [CryLength + 1], a
- farcall _PlayCryHeader
+ farcall _PlayCry
call WaitSFX
.done
diff --git a/engine/routines/printhoursmins.asm b/engine/routines/printhoursmins.asm
index 50117188c..eb7dc1619 100644
--- a/engine/routines/printhoursmins.asm
+++ b/engine/routines/printhoursmins.asm
@@ -1,5 +1,4 @@
-Function1dd6a9: ; 1dd6a9
-; XXX
+Unreferenced_Function1dd6a9: ; 1dd6a9
ld a, b
ld b, c
ld c, a
diff --git a/engine/routines/printitemdescription.asm b/engine/routines/printitemdescription.asm
new file mode 100644
index 000000000..e6d087dae
--- /dev/null
+++ b/engine/routines/printitemdescription.asm
@@ -0,0 +1,31 @@
+PrintItemDescription: ; 0x1c8955
+; Print the description for item [CurSpecies] at de.
+
+ ld a, [CurSpecies]
+ cp TM01
+ jr c, .not_a_tm
+
+ ld [CurItem], a
+ push de
+ farcall GetTMHMItemMove
+ pop hl
+ ld a, [wd265]
+ ld [CurSpecies], a
+ predef PrintMoveDesc
+ ret
+
+.not_a_tm
+ push de
+ ld hl, ItemDescriptions
+ ld a, [CurSpecies]
+ dec a
+ ld c, a
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ pop hl
+ jp PlaceString
+; 0x1c8987
diff --git a/engine/routines/sine.asm b/engine/routines/sine.asm
index 89a905d2e..5f56a10a8 100755
--- a/engine/routines/sine.asm
+++ b/engine/routines/sine.asm
@@ -7,7 +7,6 @@ _Sine:: ; 84d9
and %111111
cp %100000
jr nc, .negative
-
call .ApplySineWave
ld a, h
ret
@@ -16,7 +15,7 @@ _Sine:: ; 84d9
and %011111
call .ApplySineWave
ld a, h
- xor -1
+ xor $ff
inc a
ret
@@ -31,7 +30,6 @@ _Sine:: ; 84d9
inc hl
ld d, [hl]
ld hl, 0
-
; Factor amplitude
.multiply
srl a
diff --git a/engine/routines/switchpartymons.asm b/engine/routines/switchpartymons.asm
index cde9c82b2..1379dff9c 100644
--- a/engine/routines/switchpartymons.asm
+++ b/engine/routines/switchpartymons.asm
@@ -25,13 +25,13 @@ _SwitchPartyMons:
ld a, " "
call ByteFill
pop af
- ld hl, Sprites
- ld bc, $10
+ ld hl, Sprite01
+ ld bc, 4 * SPRITEOAMSTRUCT_LENGTH
call AddNTimes
- ld de, $4
- ld c, $4
+ ld de, SPRITEOAMSTRUCT_LENGTH
+ ld c, 4
.gfx_loop
- ld [hl], $a0
+ ld [hl], SCREEN_WIDTH_PX ; y (off-screen)
add hl, de
dec c
jr nz, .gfx_loop
diff --git a/engine/routines/trademonfrontpic.asm b/engine/routines/trademonfrontpic.asm
index e312042ff..e9611553b 100644
--- a/engine/routines/trademonfrontpic.asm
+++ b/engine/routines/trademonfrontpic.asm
@@ -10,7 +10,7 @@ GetTrademonFrontpic: ; 4d7fd
ld [CurSpecies], a
call GetBaseData
pop de
- predef GetAnimatedFrontpicPredef
+ predef GetAnimatedFrontpic
ret
AnimateTrademonFrontpic: ; 4d81e
diff --git a/engine/routines/unreferenced_getgen1trainerclassname.asm b/engine/routines/unreferenced_getgen1trainerclassname.asm
new file mode 100644
index 000000000..64c55ed84
--- /dev/null
+++ b/engine/routines/unreferenced_getgen1trainerclassname.asm
@@ -0,0 +1,21 @@
+Unreferenced_GetGen1TrainerClassName: ; 50a28
+ ld hl, Gen1TrainerClassNames
+ ld a, [TrainerClass]
+ dec a
+ ld c, a
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, StringBuffer1
+.copy
+ ld a, [hli]
+ ld [de], a
+ inc de
+ cp "@"
+ jr nz, .copy
+ ret
+
+INCLUDE "data/unused/gen_1_trainer_names.asm"
diff --git a/engine/rtc.asm b/engine/rtc.asm
index dc49a9630..571de9284 100755
--- a/engine/rtc.asm
+++ b/engine/rtc.asm
@@ -1,4 +1,4 @@
-StopRTC: ; Unreferenced???
+Unreferenced_StopRTC:
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
call LatchClock
@@ -58,7 +58,7 @@ TimesOfDay: ; 14044
db -1, MORN_F
; 1404e
-Unknown_1404e: ; unreferenced
+Unreferenced_1404e:
db 20, NITE_F
db 40, MORN_F
db 60, DAY_F
@@ -146,14 +146,14 @@ Function140ae: ; 140ae
farcall ClearDailyTimers
farcall Function170923
; mobile
- ld a, $5
+ ld a, 5 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
- ld a, [$aa8c]
+ ld a, [$aa8c] ; address of MBC30 bank
inc a
- ld [$aa8c], a
- ld a, [$b2fa]
+ ld [$aa8c], a ; address of MBC30 bank
+ ld a, [$b2fa] ; address of MBC30 bank
inc a
- ld [$b2fa], a
+ ld [$b2fa], a ; address of MBC30 bank
call CloseSRAM
ret
diff --git a/engine/save.asm b/engine/save.asm
index af24b4d2f..4291754e9 100644
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -415,13 +415,12 @@ EraseHallOfFame: ; 14d06
jp CloseSRAM
; 14d18
-Function14d18: ; 14d18
-; XXX
+Unreferenced_Function14d18: ; 14d18
; copy .Data to SRA4:a007
- ld a, $4
+ ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld hl, .Data
- ld de, $a007
+ ld de, $a007 ; address of MBC30 bank
ld bc, .DataEnd - .Data
call CopyBytes
jp CloseSRAM
@@ -452,11 +451,10 @@ SaveData: ; 14d68
ret
; 14d6c
-Function14d6c: ; 14d6c
-; XXX
- ld a, $4
+Unreferenced_Function14d6c: ; 14d6c
+ ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
- ld a, [$a60b]
+ ld a, [$a60b] ; address of MBC30 bank
ld b, $0
and a
jr z, .ok
@@ -464,28 +462,26 @@ Function14d6c: ; 14d6c
.ok
ld a, b
- ld [$a60b], a
+ ld [$a60b], a ; address of MBC30 bank
call CloseSRAM
ret
; 14d83
-Function14d83: ; 14d83
-; XXX
- ld a, $4
+Unreferenced_Function14d83: ; 14d83
+ ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
xor a
- ld [$a60c], a
- ld [$a60d], a
+ ld [$a60c], a ; address of MBC30 bank
+ ld [$a60d], a ; address of MBC30 bank
call CloseSRAM
ret
; 14d93
-Function14d93: ; 14d93
-; XXX
- ld a, $7
+Unreferenced_Function14d93: ; 14d93
+ ld a, 7 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
xor a
- ld [$a000], a
+ ld [$a000], a ; address of MBC30 bank
call CloseSRAM
ret
; 14da0
@@ -529,9 +525,9 @@ SavePlayerData: ; 14dd7
ld de, sPlayerData
ld bc, wPlayerDataEnd - wPlayerData
call CopyBytes
- ld hl, wMapData
- ld de, sMapData
- ld bc, wMapDataEnd - wMapData
+ ld hl, wCurrMapData
+ ld de, sCurrMapData
+ ld bc, wCurrMapDataEnd - wCurrMapData
call CopyBytes
jp CloseSRAM
; 14df7
@@ -596,9 +592,9 @@ SaveBackupPlayerData: ; 14e55
ld de, sBackupPlayerData
ld bc, wPlayerDataEnd - wPlayerData
call CopyBytes
- ld hl, wMapData
- ld de, sBackupMapData
- ld bc, wMapDataEnd - wMapData
+ ld hl, wCurrMapData
+ ld de, sBackupCurrMapData
+ ld bc, wCurrMapDataEnd - wCurrMapData
call CopyBytes
call CloseSRAM
ret
@@ -781,9 +777,9 @@ LoadPlayerData: ; 14fd7 (5:4fd7)
ld de, wPlayerData
ld bc, wPlayerDataEnd - wPlayerData
call CopyBytes
- ld hl, sMapData
- ld de, wMapData
- ld bc, wMapDataEnd - wMapData
+ ld hl, sCurrMapData
+ ld de, wCurrMapData
+ ld bc, wCurrMapDataEnd - wCurrMapData
call CopyBytes
call CloseSRAM
ld a, BANK(sBattleTowerChallengeState)
@@ -837,9 +833,9 @@ LoadBackupPlayerData: ; 15046 (5:5046)
ld de, wPlayerData
ld bc, wPlayerDataEnd - wPlayerData
call CopyBytes
- ld hl, sBackupMapData
- ld de, wMapData
- ld bc, wMapDataEnd - wMapData
+ ld hl, sBackupCurrMapData
+ ld de, wCurrMapData
+ ld bc, wCurrMapDataEnd - wCurrMapData
call CopyBytes
call CloseSRAM
ret
@@ -873,6 +869,11 @@ VerifyBackupChecksum: ; 1507c (5:507c)
_SaveData: ; 1509a
+ ; This is called within two scenarios:
+ ; a) ErasePreviousSave (the process of erasing the save from a previous game file)
+ ; b) unused mobile functionality
+ ; It is not part of a regular save.
+
ld a, BANK(sCrystalData)
call GetSRAMBank
ld hl, wCrystalData
@@ -880,7 +881,11 @@ _SaveData: ; 1509a
ld bc, wCrystalDataEnd - wCrystalData
call CopyBytes
- ; XXX SRAM bank 7
+ ; This block originally had some mobile functionality, but since we're still in
+ ; BANK(sCrystalData), it instead overwrites the sixteen EventFlags starting at 1:a603 with
+ ; garbage from wd479. This isn't an issue, since ErasePreviousSave is followed by a regular
+ ; save that unwrites the garbage.
+
ld hl, wd479
ld a, [hli]
ld [$a60e + 0], a
@@ -898,7 +903,9 @@ _LoadData: ; 150b9
ld bc, wCrystalDataEnd - wCrystalData
call CopyBytes
- ; XXX SRAM bank 7
+ ; This block originally had some mobile functionality to mirror _SaveData above, but instead it
+ ; (harmlessly) writes the aforementioned EventFlags to the unused wd479.
+
ld hl, wd479
ld a, [$a60e + 0]
ld [hli], a
diff --git a/engine/scripting.asm b/engine/scripting.asm
index 9a89c375a..84590f3c0 100644
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -128,7 +128,7 @@ ScriptCommandTable:
dw Script_warp ; 3c
dw Script_readmoney ; 3d
dw Script_readcoins ; 3e
- dw Script_RAM2MEM ; 3f
+ dw Script_vartomem ; 3f
dw Script_pokenamemem ; 40
dw Script_itemtotext ; 41
dw Script_mapnametotext ; 42
@@ -255,8 +255,7 @@ StopScript:
Script_callasm:
; script command 0xe
-; parameters:
-; asm (AsmPointerParam)
+; parameters: asm
call GetScriptByte
ld b, a
@@ -270,8 +269,7 @@ Script_callasm:
Script_special:
; script command 0xf
-; parameters:
-; predefined_script (MultiByteParam)
+; parameters: predefined_script
call GetScriptByte
ld e, a
@@ -282,8 +280,7 @@ Script_special:
Script_ptcallasm:
; script command 0x10
-; parameters:
-; asm (PointerToAsmPointerParam)
+; parameters: asm
call GetScriptByte
ld l, a
@@ -300,8 +297,7 @@ Script_ptcallasm:
Script_jumptextfaceplayer:
; script command 0x51
-; parameters:
-; text_pointer (RawTextPointerLabelParam)
+; parameters: text_pointer
ld a, [ScriptBank]
ld [wScriptTextBank], a
@@ -315,8 +311,7 @@ Script_jumptextfaceplayer:
Script_jumptext:
; script command 0x53
-; parameters:
-; text_pointer (RawTextPointerLabelParam)
+; parameters: text_pointer
ld a, [ScriptBank]
ld [wScriptTextBank], a
@@ -342,8 +337,7 @@ if _CRYSTAL
Script_farjumptext:
; script command 0x52
-; parameters:
-; text_pointer (PointerLabelBeforeBank)
+; parameters: text_pointer
call GetScriptByte
ld [wScriptTextBank], a
@@ -360,8 +354,7 @@ endc
Script_writetext:
; script command 0x4c
-; parameters:
-; text_pointer (RawTextPointerLabelParam)
+; parameters: text_pointer
call GetScriptByte
ld l, a
@@ -374,8 +367,7 @@ Script_writetext:
Script_farwritetext:
; script command 0x4b
-; parameters:
-; text_pointer (PointerLabelBeforeBank)
+; parameters: text_pointer
call GetScriptByte
ld b, a
@@ -388,9 +380,7 @@ Script_farwritetext:
Script_repeattext:
; script command 0x4d
-; parameters:
-; byte (SingleByteParam)
-; byte (SingleByteParam)
+; parameters: byte, byte
call GetScriptByte
ld l, a
@@ -444,8 +434,7 @@ Script_yesorno:
Script_loadmenudata:
; script command 0x4f
-; parameters:
-; data (MenuDataPointerParam)
+; parameters: data
call GetScriptByte
ld l, a
@@ -466,8 +455,7 @@ Script_closewindow:
Script_pokepic:
; script command 0x56
-; parameters:
-; pokemon (PokemonParam)
+; parameters: pokemon
call GetScriptByte
and a
@@ -512,9 +500,7 @@ Script__2dmenu:
Script_battletowertext:
; script command 0xa4
-; parameters:
-; pointer (PointerLabelBeforeBank)
-; memory (SingleByteParam)
+; parameters: pointer, memory
call SetUpTextBox
call GetScriptByte
@@ -524,9 +510,7 @@ Script_battletowertext:
Script_verbosegiveitem:
; script command 0x9e
-; parameters:
-; item (ItemLabelByte)
-; quantity (DecimalParam)
+; parameters: item, quantity
call Script_giveitem
call CurItemName
@@ -563,9 +547,7 @@ ReceivedItemText:
Script_verbosegiveitem2:
; script command 0x9f
-; parameters:
-; item (ItemLabelByte)
-; var (SingleByteParam)
+; parameters: item, var
call GetScriptByte
cp -1
@@ -632,7 +614,7 @@ GetPocketName:
ld a, [wItemAttributeParamBuffer]
dec a
ld hl, .Pockets
- and 3
+ maskbits NUM_POCKETS
add a
ld e, a
ld d, 0
@@ -677,9 +659,7 @@ PocketIsFullText:
Script_pokemart:
; script command 0x94
-; parameters:
-; dialog_id (SingleByteParam)
-; mart_id (MultiByteParam)
+; parameters: dialog_id, mart_id
call GetScriptByte
ld c, a
@@ -694,8 +674,7 @@ Script_pokemart:
Script_elevator:
; script command 0x95
-; parameters:
-; floor_list_pointer (PointerLabelParam)
+; parameters: floor_list_pointer
xor a
ld [ScriptVar], a
@@ -713,8 +692,7 @@ Script_elevator:
Script_trade:
; script command 0x96
-; parameters:
-; trade_id (SingleByteParam)
+; parameters: trade_id
call GetScriptByte
ld e, a
@@ -723,8 +701,7 @@ Script_trade:
Script_phonecall:
; script command 0x98
-; parameters:
-; caller_name (RawTextPointerLabelParam)
+; parameters: caller_name
call GetScriptByte
ld e, a
@@ -743,8 +720,7 @@ Script_hangup:
Script_askforphonenumber:
; script command 0x97
-; parameters:
-; number (SingleByteParam)
+; parameters: number
call YesNoBox
jr c, .refused
@@ -752,22 +728,21 @@ Script_askforphonenumber:
ld c, a
farcall AddPhoneNumber
jr c, .phonefull
- xor a
+ xor a ; PHONE_CONTACT_GOT
jr .done
.phonefull
- ld a, 1
+ ld a, PHONE_CONTACTS_FULL
jr .done
.refused
call GetScriptByte
- ld a, 2
+ ld a, PHONE_CONTACT_REFUSED
.done
ld [ScriptVar], a
ret
Script_describedecoration:
; script command 0x9a
-; parameters:
-; byte (SingleByteParam)
+; parameters: byte
call GetScriptByte
ld b, a
@@ -778,8 +753,7 @@ Script_describedecoration:
Script_fruittree:
; script command 0x9b
-; parameters:
-; tree_id (SingleByteParam)
+; parameters: tree_id
call GetScriptByte
ld [CurFruitTree], a
@@ -789,10 +763,7 @@ Script_fruittree:
Script_swarm:
; script command 0xa0
-; parameters:
-; flag (SingleByteParam)
-; map_group (MapGroupParam)
-; map_id (MapIdParam)
+; parameters: flag, map_group, map_id
call GetScriptByte
ld c, a
@@ -805,8 +776,7 @@ Script_swarm:
Script_trainertext:
; script command 0x62
-; parameters:
-; which_text (SingleByteParam)
+; parameters: which_text
call GetScriptByte
ld c, a
@@ -835,8 +805,7 @@ Script_scripttalkafter:
Script_trainerflagaction:
; script command 0x63
-; parameters:
-; action (SingleByteParam)
+; parameters: action
xor a
ld [ScriptVar], a
@@ -856,9 +825,7 @@ Script_trainerflagaction:
Script_winlosstext:
; script command 0x64
-; parameters:
-; win_text_pointer (TextPointerLabelParam)
-; loss_text_pointer (TextPointerLabelParam)
+; parameters: win_text_pointer, loss_text_pointer
ld hl, wWinTextPointer
call GetScriptByte
@@ -908,8 +875,7 @@ Script_playmapmusic:
Script_playmusic:
; script command 0x7f
-; parameters:
-; music_pointer (MultiByteParam)
+; parameters: music_pointer
ld de, MUSIC_NONE
call PlayMusic
@@ -925,23 +891,20 @@ Script_playmusic:
Script_musicfadeout:
; script command 0x81
-; parameters:
-; music (MultiByteParam)
-; fadetime (SingleByteParam)
+; parameters: music, fadetime
call GetScriptByte
ld [MusicFadeID], a
call GetScriptByte
ld [MusicFadeID + 1], a
call GetScriptByte
- and $7f
+ and $ff ^ (1 << MUSIC_FADE_IN_F)
ld [MusicFade], a
ret
Script_playsound:
; script command 0x85
-; parameters:
-; sound_pointer (MultiByteParam)
+; parameters: sound_pointer
call GetScriptByte
ld e, a
@@ -965,8 +928,7 @@ Script_warpsound:
Script_cry:
; script command 0x84
-; parameters:
-; cry_id (MultiByteParam)
+; parameters: cry_id
call GetScriptByte
push af
@@ -976,7 +938,7 @@ Script_cry:
jr nz, .ok
ld a, [ScriptVar]
.ok
- call PlayCry
+ call PlayMonCry
ret
GetScriptObject:
@@ -989,8 +951,7 @@ GetScriptObject:
Script_setlasttalked:
; script command 0x68
-; parameters:
-; object id (SingleByteParam)
+; parameters: object_id
call GetScriptByte
call GetScriptObject
@@ -999,9 +960,7 @@ Script_setlasttalked:
Script_applymovement:
; script command 0x69
-; parameters:
-; object id (SingleByteParam)
-; data (MovementPointerLabelParam)
+; parameters: object_id, data
call GetScriptByte
call GetScriptObject
@@ -1036,10 +995,9 @@ SetFlagsForMovement_2:
ret
Script_applymovement2:
-; apply movement to last talked
; script command 0x6a
-; parameters:
-; data (MovementPointerLabelParam)
+; parameters: data
+; apply movement to last talked
ld a, [hLastTalked]
ld c, a
@@ -1066,9 +1024,7 @@ Script_faceplayer:
Script_faceobject:
; script command 0x6c
-; parameters:
-; object1 (SingleByteParam)
-; object2 (SingleByteParam)
+; parameters: object1, object2
call GetScriptByte
call GetScriptObject
@@ -1098,9 +1054,7 @@ Script_faceobject:
Script_spriteface:
; script command 0x76
-; parameters:
-; object id (SingleByteParam)
-; facing (SingleByteParam)
+; parameters: object_id, facing
call GetScriptByte
call GetScriptObject
@@ -1163,9 +1117,7 @@ ApplyObjectFacing:
Script_variablesprite:
; script command 0x6d
-; parameters:
-; byte (SingleByteParam)
-; sprite (SingleByteParam)
+; parameters: byte, sprite
call GetScriptByte
ld e, a
@@ -1178,8 +1130,7 @@ Script_variablesprite:
Script_appear:
; script command 0x6f
-; parameters:
-; object id (SingleByteParam)
+; parameters: object_id
call GetScriptByte
call GetScriptObject
@@ -1191,8 +1142,7 @@ Script_appear:
Script_disappear:
; script command 0x6e
-; parameters:
-; object id (SingleByteParam)
+; parameters: object_id
call GetScriptByte
call GetScriptObject
@@ -1229,9 +1179,7 @@ ApplyEventActionAppearDisappear:
Script_follow:
; script command 0x70
-; parameters:
-; object2 (SingleByteParam)
-; object1 (SingleByteParam)
+; parameters: object2, object1
call GetScriptByte
call GetScriptObject
@@ -1250,10 +1198,7 @@ Script_stopfollow:
Script_moveobject:
; script command 0x72
-; parameters:
-; object id (SingleByteParam)
-; x (SingleByteParam)
-; y (SingleByteParam)
+; parameters: object id, x, y
call GetScriptByte
call GetScriptObject
@@ -1269,8 +1214,7 @@ Script_moveobject:
Script_writeobjectxy:
; script command 0x73
-; parameters:
-; object id (SingleByteParam)
+; parameters: object_id
call GetScriptByte
call GetScriptObject
@@ -1284,9 +1228,7 @@ Script_writeobjectxy:
Script_follownotexact:
; script command 0x77
-; parameters:
-; object2 (SingleByteParam)
-; object1 (SingleByteParam)
+; parameters: object2, object1
call GetScriptByte
call GetScriptObject
@@ -1299,8 +1241,7 @@ Script_follownotexact:
Script_loademote:
; script command 0x74
-; parameters:
-; bubble (SingleByteParam)
+; parameters: bubble
call GetScriptByte
cp -1
@@ -1313,10 +1254,7 @@ Script_loademote:
Script_showemote:
; script command 0x75
-; parameters:
-; bubble (SingleByteParam)
-; object id (SingleByteParam)
-; time (DecimalParam)
+; parameters: bubble, object_id, time
call GetScriptByte
ld [ScriptVar], a
@@ -1352,8 +1290,7 @@ ShowEmoteScript:
Script_earthquake:
; script command 0x78
-; parameters:
-; param (DecimalParam)
+; parameters: param
ld hl, EarthquakeMovement
ld de, wEarthquakeMovementDataBuffer
@@ -1407,9 +1344,7 @@ Script_loadmemtrainer:
Script_loadwildmon:
; script command 0x5d
-; parameters:
-; pokemon (PokemonParam)
-; level (DecimalParam)
+; parameters: pokemon, level
ld a, (1 << 7)
ld [wBattleScriptFlags], a
@@ -1421,9 +1356,7 @@ Script_loadwildmon:
Script_loadtrainer:
; script command 0x5e
-; parameters:
-; trainer_group (TrainerGroupParam)
-; trainer_id (TrainerIdParam)
+; parameters: trainer_group, trainer_id
ld a, (1 << 7) | 1
ld [wBattleScriptFlags], a
@@ -1445,8 +1378,7 @@ Script_startbattle:
Script_catchtutorial:
; script command 0x61
-; parameters:
-; byte (SingleByteParam)
+; parameters: byte
call GetScriptByte
ld [BattleType], a
@@ -1498,8 +1430,7 @@ Script_reloadmap:
Script_scall:
; script command 0x0
-; parameters:
-; pointer (ScriptPointerLabelParam)
+; parameters: pointer
ld a, [ScriptBank]
ld b, a
@@ -1511,8 +1442,7 @@ Script_scall:
Script_farscall:
; script command 0x1
-; parameters:
-; pointer (ScriptPointerLabelBeforeBank)
+; parameters: pointer
call GetScriptByte
ld b, a
@@ -1524,8 +1454,7 @@ Script_farscall:
Script_ptcall:
; script command 0x2
-; parameters:
-; pointer (PointerLabelToScriptPointer)
+; parameters: pointer
call GetScriptByte
ld l, a
@@ -1577,8 +1506,7 @@ CallCallback::
Script_jump:
; script command 0x3
-; parameters:
-; pointer (ScriptPointerLabelParam)
+; parameters: pointer
call GetScriptByte
ld l, a
@@ -1590,8 +1518,7 @@ Script_jump:
Script_farjump:
; script command 0x4
-; parameters:
-; pointer (ScriptPointerLabelBeforeBank)
+; parameters: pointer
call GetScriptByte
ld b, a
@@ -1603,8 +1530,7 @@ Script_farjump:
Script_ptjump:
; script command 0x5
-; parameters:
-; pointer (PointerLabelToScriptPointer)
+; parameters: pointer
call GetScriptByte
ld l, a
@@ -1619,8 +1545,7 @@ Script_ptjump:
Script_iffalse:
; script command 0x8
-; parameters:
-; pointer (ScriptPointerLabelParam)
+; parameters: pointer
ld a, [ScriptVar]
and a
@@ -1629,8 +1554,7 @@ Script_iffalse:
Script_iftrue:
; script command 0x9
-; parameters:
-; pointer (ScriptPointerLabelParam)
+; parameters: pointer
ld a, [ScriptVar]
and a
@@ -1639,9 +1563,7 @@ Script_iftrue:
Script_if_equal:
; script command 0x6
-; parameters:
-; byte (SingleByteParam)
-; pointer (ScriptPointerLabelParam)
+; parameters: byte, pointer
call GetScriptByte
ld hl, ScriptVar
@@ -1651,9 +1573,7 @@ Script_if_equal:
Script_if_not_equal:
; script command 0x7
-; parameters:
-; byte (SingleByteParam)
-; pointer (ScriptPointerLabelParam)
+; parameters: byte, pointer
call GetScriptByte
ld hl, ScriptVar
@@ -1663,9 +1583,7 @@ Script_if_not_equal:
Script_if_greater_than:
; script command 0xa
-; parameters:
-; byte (SingleByteParam)
-; pointer (ScriptPointerLabelParam)
+; parameters: byte, pointer
ld a, [ScriptVar]
ld b, a
@@ -1676,9 +1594,7 @@ Script_if_greater_than:
Script_if_less_than:
; script command 0xb
-; parameters:
-; byte (SingleByteParam)
-; pointer (ScriptPointerLabelParam)
+; parameters: byte, pointer
call GetScriptByte
ld b, a
@@ -1689,16 +1605,14 @@ Script_if_less_than:
Script_jumpstd:
; script command 0xc
-; parameters:
-; predefined_script (MultiByteParam)
+; parameters: predefined_script
call StdScript
jr ScriptJump
Script_callstd:
; script command 0xd
-; parameters:
-; predefined_script (MultiByteParam)
+; parameters: predefined_script
call StdScript
ld d, h
@@ -1738,8 +1652,7 @@ ScriptJump:
Script_priorityjump:
; script command 0x8d
-; parameters:
-; pointer (ScriptPointerLabelParam)
+; parameters: pointer
ld a, [ScriptBank]
ld [wPriorityScriptBank], a
@@ -1766,9 +1679,7 @@ Script_checkscene:
Script_checkmapscene:
; script command 0x11
-; parameters:
-; map_group (SingleByteParam)
-; map_id (SingleByteParam)
+; parameters: map_group, map_id
call GetScriptByte
ld b, a
@@ -1789,8 +1700,7 @@ Script_checkmapscene:
Script_setscene:
; script command 0x14
-; parameters:
-; scene_id (SingleByteParam)
+; parameters: scene_id
ld a, [MapGroup]
ld b, a
@@ -1800,10 +1710,7 @@ Script_setscene:
Script_setmapscene:
; script command 0x12
-; parameters:
-; map_group (MapGroupParam)
-; map_id (MapIdParam)
-; scene_id (SingleByteParam)
+; parameters: map_group, map_id, scene_id
call GetScriptByte
ld b, a
@@ -1821,8 +1728,7 @@ DoScene:
Script_copybytetovar:
; script command 0x19
-; parameters:
-; address (RAMAddressParam)
+; parameters: address
call GetScriptByte
ld l, a
@@ -1834,8 +1740,7 @@ Script_copybytetovar:
Script_copyvartobyte:
; script command 0x1a
-; parameters:
-; address (RAMAddressParam)
+; parameters: address
call GetScriptByte
ld l, a
@@ -1847,9 +1752,7 @@ Script_copyvartobyte:
Script_loadvar:
; script command 0x1b
-; parameters:
-; address (RAMAddressParam)
-; value (SingleByteParam)
+; parameters: address, value
call GetScriptByte
ld l, a
@@ -1861,8 +1764,7 @@ Script_loadvar:
Script_writebyte:
; script command 0x15
-; parameters:
-; value (SingleByteParam)
+; parameters: value
call GetScriptByte
ld [ScriptVar], a
@@ -1870,8 +1772,7 @@ Script_writebyte:
Script_addvar:
; script command 0x16
-; parameters:
-; value (SingleByteParam)
+; parameters: value
call GetScriptByte
ld hl, ScriptVar
@@ -1881,8 +1782,7 @@ Script_addvar:
Script_random:
; script command 0x17
-; parameters:
-; input (SingleByteParam)
+; parameters: input
call GetScriptByte
ld [ScriptVar], a
@@ -1935,8 +1835,7 @@ Script_random:
Script_checkcode:
; script command 0x1c
-; parameters:
-; variable_id (SingleByteParam)
+; parameters: variable_id
call GetScriptByte
call GetVarAction
@@ -1946,8 +1845,7 @@ Script_checkcode:
Script_writevarcode:
; script command 0x1d
-; parameters:
-; variable_id (SingleByteParam)
+; parameters: variable_id
call GetScriptByte
call GetVarAction
@@ -1957,9 +1855,7 @@ Script_writevarcode:
Script_writecode:
; script command 0x1e
-; parameters:
-; variable_id (SingleByteParam)
-; value (SingleByteParam)
+; parameters: variable_id, value
call GetScriptByte
call GetVarAction
@@ -1975,18 +1871,16 @@ GetVarAction:
Script_checkver:
; script command 0x18
- ld a, [Version]
+ ld a, [.gs_version]
ld [ScriptVar], a
ret
-Version:
- db VERSION
+.gs_version:
+ db GS_VERSION
Script_pokenamemem:
; script command 0x40
-; parameters:
-; pokemon (PokemonParam); leave $0 to draw from script var
-; memory (SingleByteParam)
+; parameters: pokemon (0 aka USE_SCRIPT_VAR to use ScriptVar), memory
call GetScriptByte
and a
@@ -1999,7 +1893,7 @@ Script_pokenamemem:
ConvertMemToText:
call GetScriptByte
- cp 3
+ cp NUM_MEM_BUFFERS
jr c, .ok
xor a
.ok
@@ -2013,12 +1907,10 @@ CopyConvertedText:
Script_itemtotext:
; script command 0x41
-; parameters:
-; item (ItemLabelByte); use 0 to draw from ScriptVar
-; memory (SingleByteParam)
+; parameters: item (0 aka USE_SCRIPT_VAR to use ScriptVar), memory
call GetScriptByte
- and a
+ and a ; USE_SCRIPT_VAR
jr nz, .ok
ld a, [ScriptVar]
.ok
@@ -2029,8 +1921,7 @@ Script_itemtotext:
Script_mapnametotext:
; script command 0x42
-; parameters:
-; memory (SingleByteParam)
+; parameters: memory
ld a, [MapGroup]
ld b, a
@@ -2046,19 +1937,14 @@ ConvertLandmarkToText:
Script_landmarktotext:
; script command 0xa5
-; parameters:
-; id (SingleByteParam)
-; memory (SingleByteParam)
+; parameters: id, memory
call GetScriptByte
jr ConvertLandmarkToText
Script_trainertotext:
; script command 0x43
-; parameters:
-; trainer_id (TrainerGroupParam)
-; trainer_group (TrainerIdParam)
-; memory (SingleByteParam)
+; parameters: trainer_id, trainer_group, memory
call GetScriptByte
ld c, a
@@ -2069,10 +1955,7 @@ Script_trainertotext:
Script_name:
; script command 0xa7
-; parameters:
-; type (SingleByteParam)
-; id (SingleByteParam)
-; memory (SingleByteParam)
+; parameters: type, id, memory
call GetScriptByte
ld [wNamedObjectTypeBuffer], a
@@ -2086,9 +1969,7 @@ ContinueToGetName:
Script_trainerclassname:
; script command 0xa6
-; parameters:
-; id (SingleByteParam)
-; memory (SingleByteParam)
+; parameters: id, memory
ld a, TRAINER_NAME
ld [wNamedObjectTypeBuffer], a
@@ -2096,9 +1977,7 @@ Script_trainerclassname:
Script_readmoney:
; script command 0x3d
-; parameters:
-; account (SingleByteParam)
-; memory (SingleByteParam)
+; parameters: account, memory
call ResetStringBuffer1
call GetMoneyAccount
@@ -2110,8 +1989,7 @@ Script_readmoney:
Script_readcoins:
; script command 0x3e
-; parameters:
-; memory (SingleByteParam)
+; parameters: memory
call ResetStringBuffer1
ld hl, StringBuffer1
@@ -2121,10 +1999,9 @@ Script_readcoins:
ld de, StringBuffer1
jp ConvertMemToText
-Script_RAM2MEM:
+Script_vartomem:
; script command 0x3f
-; parameters:
-; memory (SingleByteParam)
+; parameters: memory
call ResetStringBuffer1
ld de, ScriptVar
@@ -2143,9 +2020,7 @@ ResetStringBuffer1:
Script_stringtotext:
; script command 0x44
-; parameters:
-; text_pointer (EncodedTextLabelParam)
-; memory (SingleByteParam)
+; parameters: text_pointer, memory
call GetScriptByte
ld e, a
@@ -2159,8 +2034,7 @@ Script_stringtotext:
Script_givepokeitem:
; script command 0x2f
-; parameters:
-; pointer (PointerParamToItemAndLetter)
+; parameters: pointer
call GetScriptByte
ld l, a
@@ -2181,8 +2055,7 @@ Script_givepokeitem:
Script_checkpokeitem:
; script command 0x30
-; parameters:
-; pointer (PointerParamToItemAndLetter)
+; parameters: pointer
call GetScriptByte
ld e, a
@@ -2195,9 +2068,7 @@ Script_checkpokeitem:
Script_giveitem:
; script command 0x1f
-; parameters:
-; item (ItemLabelByte)
-; quantity (SingleByteParam)
+; parameters: item, quantity
call GetScriptByte
cp ITEM_FROM_MEM
@@ -2220,9 +2091,7 @@ Script_giveitem:
Script_takeitem:
; script command 0x20
-; parameters:
-; item (ItemLabelByte)
-; quantity (DecimalParam)
+; parameters: item, quantity
xor a
ld [ScriptVar], a
@@ -2241,8 +2110,7 @@ Script_takeitem:
Script_checkitem:
; script command 0x21
-; parameters:
-; item (ItemLabelByte)
+; parameters: item
xor a
ld [ScriptVar], a
@@ -2257,9 +2125,7 @@ Script_checkitem:
Script_givemoney:
; script command 0x22
-; parameters:
-; account (SingleByteParam)
-; money (MoneyByteParam)
+; parameters: account, money
call GetMoneyAccount
call LoadMoneyAmountToMem
@@ -2268,9 +2134,7 @@ Script_givemoney:
Script_takemoney:
; script command 0x23
-; parameters:
-; account (SingleByteParam)
-; money (MoneyByteParam)
+; parameters: account, money
call GetMoneyAccount
call LoadMoneyAmountToMem
@@ -2279,24 +2143,22 @@ Script_takemoney:
Script_checkmoney:
; script command 0x24
-; parameters:
-; account (SingleByteParam)
-; money (MoneyByteParam)
+; parameters: account, money
call GetMoneyAccount
call LoadMoneyAmountToMem
farcall CompareMoney
CompareMoneyAction:
- jr c, .two
- jr z, .one
- ld a, 0
+ jr c, .less
+ jr z, .exact
+ ld a, HAVE_MORE
jr .done
-.one
- ld a, 1
+.exact
+ ld a, HAVE_AMOUNT
jr .done
-.two
- ld a, 2
+.less
+ ld a, HAVE_LESS
.done
ld [ScriptVar], a
ret
@@ -2304,9 +2166,9 @@ CompareMoneyAction:
GetMoneyAccount:
call GetScriptByte
and a
- ld de, Money
+ ld de, Money ; YOUR_MONEY
ret z
- ld de, wMomsMoney
+ ld de, wMomsMoney ; MOMS_MONEY
ret
LoadMoneyAmountToMem:
@@ -2325,8 +2187,7 @@ LoadMoneyAmountToMem:
Script_givecoins:
; script command 0x25
-; parameters:
-; coins (CoinByteParam)
+; parameters: coins
call LoadCoinAmountToMem
farcall GiveCoins
@@ -2334,8 +2195,7 @@ Script_givecoins:
Script_takecoins:
; script command 0x26
-; parameters:
-; coins (CoinByteParam)
+; parameters: coins
call LoadCoinAmountToMem
farcall TakeCoins
@@ -2343,8 +2203,7 @@ Script_takecoins:
Script_checkcoins:
; script command 0x27
-; parameters:
-; coins (CoinByteParam)
+; parameters: coins
call LoadCoinAmountToMem
farcall CheckCoins
@@ -2360,8 +2219,7 @@ LoadCoinAmountToMem:
Script_checktime:
; script command 0x2b
-; parameters:
-; time (SingleByteParam)
+; parameters: time
xor a
ld [ScriptVar], a
@@ -2375,8 +2233,7 @@ Script_checktime:
Script_checkpoke:
; script command 0x2c
-; parameters:
-; pkmn (PokemonParam)
+; parameters: pokemon
xor a
ld [ScriptVar], a
@@ -2391,8 +2248,7 @@ Script_checkpoke:
Script_addcellnum:
; script command 0x28
-; parameters:
-; person (SingleByteParam)
+; parameters: person
xor a
ld [ScriptVar], a
@@ -2406,8 +2262,7 @@ Script_addcellnum:
Script_delcellnum:
; script command 0x29
-; parameters:
-; person (SingleByteParam)
+; parameters: person
xor a
ld [ScriptVar], a
@@ -2421,8 +2276,7 @@ Script_delcellnum:
Script_checkcellnum:
; script command 0x2a
-; parameters:
-; person (SingleByteParam)
+; parameters: person
; returns false if the cell number is not in your phone
xor a
@@ -2437,8 +2291,7 @@ Script_checkcellnum:
Script_specialphonecall:
; script command 0x9c
-; parameters:
-; call_id (MultiByteParam)
+; parameters: call_id
call GetScriptByte
ld [wSpecialPhoneCallID], a
@@ -2460,13 +2313,7 @@ Script_checkphonecall:
Script_givepoke:
; script command 0x2d
-; parameters:
-; pokemon (PokemonParam)
-; level (DecimalParam)
-; item (ItemLabelByte)
-; trainer (DecimalParam)
-; trainer_name_pointer (MultiByteParam)
-; pkmn_nickname (MultiByteParam)
+; parameters: pokemon, level, item, trainer, trainer_name_pointer, pkmn_nickname
call GetScriptByte
ld [CurPartySpecies], a
@@ -2494,9 +2341,7 @@ Script_givepoke:
Script_giveegg:
; script command 0x2e
-; parameters:
-; pkmn (PokemonParam)
-; level (DecimalParam)
+; parameters: pokemon, level
; if no room in the party, return 0 in ScriptVar; else, return 2
xor a ; PARTYMON
@@ -2514,8 +2359,7 @@ Script_giveegg:
Script_setevent:
; script command 0x33
-; parameters:
-; bit_number (MultiByteParam)
+; parameters: bit_number
call GetScriptByte
ld e, a
@@ -2527,8 +2371,7 @@ Script_setevent:
Script_clearevent:
; script command 0x32
-; parameters:
-; bit_number (MultiByteParam)
+; parameters: bit_number
call GetScriptByte
ld e, a
@@ -2540,8 +2383,7 @@ Script_clearevent:
Script_checkevent:
; script command 0x31
-; parameters:
-; bit_number (MultiByteParam)
+; parameters: bit_number
call GetScriptByte
ld e, a
@@ -2559,8 +2401,7 @@ Script_checkevent:
Script_setflag:
; script command 0x36
-; parameters:
-; bit_number (MultiByteParam)
+; parameters: bit_number
call GetScriptByte
ld e, a
@@ -2572,8 +2413,7 @@ Script_setflag:
Script_clearflag:
; script command 0x35
-; parameters:
-; bit_number (MultiByteParam)
+; parameters: bit_number
call GetScriptByte
ld e, a
@@ -2585,14 +2425,13 @@ Script_clearflag:
Script_checkflag:
; script command 0x34
-; parameters:
-; bit_number (MultiByteParam)
+; parameters: bit_number
call GetScriptByte
ld e, a
call GetScriptByte
ld d, a
- ld b, 2 ; check
+ ld b, CHECK_FLAG
call _EngineFlagAction
ld a, c
and a
@@ -2622,8 +2461,7 @@ Script_wildon:
Script_xycompare:
; script command 0x39
-; parameters:
-; pointer (MultiByteParam)
+; parameters: pointer
call GetScriptByte
ld [wXYComparePointer], a
@@ -2633,15 +2471,10 @@ Script_xycompare:
Script_warpfacing:
; script command 0xa3
-; parameters:
-; facing (SingleByteParam)
-; map_group (MapGroupParam)
-; map_id (MapIdParam)
-; x (SingleByteParam)
-; y (SingleByteParam)
+; parameters: facing, map_group, map_id, x, y
call GetScriptByte
- and $3
+ maskbits NUM_DIRECTIONS
ld c, a
ld a, [wPlayerSpriteSetupFlags]
set 5, a
@@ -2651,11 +2484,7 @@ Script_warpfacing:
Script_warp:
; script command 0x3c
-; parameters:
-; map_group (MapGroupParam)
-; map_id (MapIdParam)
-; x (SingleByteParam)
-; y (SingleByteParam)
+; parameters: map_group, map_id, x, y
; This seems to be some sort of error handling case.
call GetScriptByte
@@ -2692,10 +2521,7 @@ Script_warp:
Script_warpmod:
; script command 0x3a
-; parameters:
-; warp_id (SingleByteParam)
-; map_group (MapGroupParam)
-; map_id (MapIdParam)
+; parameters: warp_id, map_group, map_id
call GetScriptByte
ld [BackupWarpNumber], a
@@ -2707,9 +2533,7 @@ Script_warpmod:
Script_blackoutmod:
; script command 0x3b
-; parameters:
-; map_group (MapGroupParam)
-; map_id (MapIdParam)
+; parameters: map_group, map_id
call GetScriptByte
ld [wLastSpawnMapGroup], a
@@ -2726,8 +2550,7 @@ Script_dontrestartmapmusic:
Script_writecmdqueue:
; script command 0x7d
-; parameters:
-; queue_pointer (MultiByteParam)
+; parameters: queue_pointer
call GetScriptByte
ld e, a
@@ -2740,8 +2563,7 @@ Script_writecmdqueue:
Script_delcmdqueue:
; script command 0x7e
-; parameters:
-; byte (SingleByteParam)
+; parameters: byte
xor a
ld [ScriptVar], a
@@ -2755,25 +2577,21 @@ Script_delcmdqueue:
Script_changemap:
; script command 0x79
-; parameters:
-; map_data_pointer (MapDataPointerParam)
+; parameters: map_data_pointer
call GetScriptByte
- ld [MapBlockDataBank], a
+ ld [MapBlocksBank], a
call GetScriptByte
- ld [MapBlockDataPointer], a
+ ld [MapBlocksPointer], a
call GetScriptByte
- ld [MapBlockDataPointer + 1], a
+ ld [MapBlocksPointer + 1], a
call ChangeMap
call BufferScreen
ret
Script_changeblock:
; script command 0x7a
-; parameters:
-; x (SingleByteParam)
-; y (SingleByteParam)
-; block (SingleByteParam)
+; parameters: x, y, block
call GetScriptByte
add 4
@@ -2806,14 +2624,14 @@ Script_warpcheck:
farcall EnableEvents
ret
-Script_enableevents: ; unreferenced
+Script_enableevents:
+; unused
farcall EnableEvents
ret
Script_newloadmap:
; script command 0x8a
-; parameters:
-; which_method (SingleByteParam)
+; parameters: which_method
call GetScriptByte
ld [hMapEntryMethod], a
@@ -2836,8 +2654,7 @@ Script_textbox:
Script_refreshscreen:
; script command 0x48
-; parameters:
-; dummy (SingleByteParam)
+; parameters: dummy
call RefreshScreen
call GetScriptByte
@@ -2845,14 +2662,13 @@ Script_refreshscreen:
Script_loadbytec2cf:
; script command 0x4a
-; parameters:
-; byte (SingleByteParam)
+; parameters: byte
call GetScriptByte
ld [wc2cf], a
ret
- ld c, c ; XXX
+ db closetext_command ; unused
Script_closetext:
; script command 0x49
@@ -2864,8 +2680,7 @@ Script_closetext:
Script_passtoengine:
; script command 0x89
-; parameters:
-; data_pointer (PointerLabelBeforeBank)
+; parameters: data_pointer
call GetScriptByte
push af
@@ -2879,8 +2694,7 @@ Script_passtoengine:
Script_pause:
; script command 0x8b
-; parameters:
-; length (DecimalParam)
+; parameters: length
call GetScriptByte
and a
@@ -2896,8 +2710,7 @@ Script_pause:
Script_deactivatefacing:
; script command 0x8c
-; parameters:
-; time (SingleByteParam)
+; parameters: time
call GetScriptByte
and a
@@ -2911,8 +2724,7 @@ Script_deactivatefacing:
Script_ptpriorityjump:
; script command 0x8f
-; parameters:
-; pointer (ScriptPointerLabelParam)
+; parameters: pointer
call StopScript
jp Script_jump
@@ -2993,8 +2805,8 @@ Script_halloffame:
ld hl, wGameTimerPause
res 0, [hl]
- farcall TrainerRankings_HallOfFame
- farcall TrainerRankings_HallOfFame2
+ farcall StubbedTrainerRankings_HallOfFame
+ farcall StubbedTrainerRankings_HallOfFame2
farcall HallOfFame
ld hl, wGameTimerPause
set 0, [hl]
@@ -3013,8 +2825,7 @@ ReturnFromCredits:
Script_wait:
; script command 0xa8
-; parameters:
-; unknown (SingleByteParam)
+; parameters: unknown
push bc
call GetScriptByte
@@ -3037,7 +2848,7 @@ Script_check_save:
ret
-; unreferenced
+; unused
ld a, [.byte]
ld [ScriptVar], a
ret
diff --git a/engine/scrolling_menu.asm b/engine/scrolling_menu.asm
index 32f22188a..32acf2def 100755
--- a/engine/scrolling_menu.asm
+++ b/engine/scrolling_menu.asm
@@ -84,7 +84,7 @@ ScrollingMenuJoyAction: ; 24609
jr .loop
; 24640
-.unreferenced ; unreferenced
+.unreferenced ; unused
ld a, -1
and a
ret
diff --git a/engine/search.asm b/engine/search.asm
index 76be0e159..495d4cc5e 100755
--- a/engine/search.asm
+++ b/engine/search.asm
@@ -1,4 +1,4 @@
-SpecialBeastsCheck: ; 0x4a6e8
+Special_BeastsCheck: ; 0x4a6e8
; Check if the player owns all three legendary beasts.
; They must exist in either party or PC, and have the player's OT and ID.
; Return the result in ScriptVar.
@@ -29,7 +29,7 @@ SpecialBeastsCheck: ; 0x4a6e8
ret
-SpecialMonCheck: ; 0x4a711
+Special_MonCheck: ; 0x4a711
; Check if the player owns any monsters of the species in ScriptVar.
; Return the result in ScriptVar.
diff --git a/engine/sgb_layouts.asm b/engine/sgb_layouts.asm
index 36dbde84c..5f2b8e12e 100644
--- a/engine/sgb_layouts.asm
+++ b/engine/sgb_layouts.asm
@@ -1,7 +1,6 @@
-Predef_LoadSGBLayout: ; 864c
-; LoadSGBLayout
+LoadSGBLayout: ; 864c
call CheckCGB
- jp nz, Predef_LoadSGBLayoutCGB
+ jp nz, LoadSGBLayoutCGB
ld a, b
cp SCGB_RAM
@@ -18,7 +17,7 @@ Predef_LoadSGBLayout: ; 864c
ld a, [hli]
ld h, [hl]
ld l, a
- ld de, .Finish
+ ld de, _LoadSGBLayout_ReturnFromJumpTable
push de
jp hl
; 866f
@@ -31,12 +30,12 @@ Predef_LoadSGBLayout: ; 864c
dw .SGB_Pokedex
dw .SGB_SlotMachine
dw .SGB06
- dw .SGB07
+ dw .SGB_GSIntro
dw .SGB_Diploma
dw .SGB_MapPals
dw .SGB_PartyMenu
dw .SGB_Evolution
- dw .SGB0c
+ dw .SGB_GSTitleScreen
dw .SGB0d
dw .SGB_MoveList
dw .SGB0f
@@ -49,7 +48,7 @@ Predef_LoadSGBLayout: ; 864c
dw .SGB_PokedexUnownMode
dw .SGB_BillsPC
dw .SGB_UnownPuzzle
- dw .SGB19
+ dw .SGB_GamefreakLogo
dw .SGB_PlayerOrMonFrontpicPals
dw .SGB_TradeTube
dw .SGB_TrainerOrMonFrontpicPals
@@ -58,18 +57,18 @@ Predef_LoadSGBLayout: ; 864c
; 86ad
.SGB_BattleGrayscale: ; 86ad
- ld hl, PalPacket_9c66
- ld de, BlkPacket_9aa6
+ ld hl, PalPacket_BattleGrayscale
+ ld de, BlkPacket_Battle
ret
; 86b4
.SGB_BattleColors: ; 86b4
- ld hl, BlkPacket_9aa6
+ ld hl, BlkPacket_Battle
call PushSGBPals_
ld hl, PalPacket_9ce6
ld de, wSGBPals
- ld bc, $10
+ ld bc, PALPACKET_LENGTH
call CopyBytes
ld a, [PlayerHPPal]
@@ -107,32 +106,32 @@ Predef_LoadSGBLayout: ; 864c
ld [wSGBPals + 12], a
ld hl, PalPacket_9cf6
- ld de, wSGBPals + $10
- ld bc, $10
+ ld de, wSGBPals + PALPACKET_LENGTH
+ ld bc, PALPACKET_LENGTH
call CopyBytes
call GetBattlemonBackpicPalettePointer
ld a, [hli]
- ld [wSGBPals + $13], a
+ ld [wSGBPals + 19], a
ld a, [hli]
- ld [wSGBPals + $14], a
+ ld [wSGBPals + 20], a
ld a, [hli]
- ld [wSGBPals + $15], a
+ ld [wSGBPals + 21], a
ld a, [hl]
- ld [wSGBPals + $16], a
+ ld [wSGBPals + 22], a
call GetEnemyFrontpicPalettePointer
ld a, [hli]
- ld [wSGBPals + $19], a
+ ld [wSGBPals + 25], a
ld a, [hli]
- ld [wSGBPals + $1a], a
+ ld [wSGBPals + 26], a
ld a, [hli]
- ld [wSGBPals + $1b], a
+ ld [wSGBPals + 27], a
ld a, [hl]
- ld [wSGBPals + $1c], a
+ ld [wSGBPals + 28], a
ld hl, wSGBPals
- ld de, wSGBPals + $10
+ ld de, wSGBPals + PALPACKET_LENGTH
ld a, SCGB_BATTLE_COLORS
ld [SGBPredef], a
ret
@@ -141,7 +140,7 @@ Predef_LoadSGBLayout: ; 864c
.SGB_MoveList: ; 873c
ld hl, PalPacket_9bd6
ld de, wSGBPals
- ld bc, $10
+ ld bc, PALPACKET_LENGTH
call CopyBytes
ld hl, wSGBPals + 1
@@ -150,15 +149,15 @@ Predef_LoadSGBLayout: ; 864c
inc hl
ld a, [PlayerHPPal]
- add $2f
+ add PREDEFPAL_HP_GREEN
ld [hl], a
ld hl, wSGBPals
- ld de, BlkPacket_9ad6
+ ld de, BlkPacket_MoveList
ret
; 875c
.SGB_PokegearPals: ; 875c
- ld hl, PalPacket_9c76
+ ld hl, PalPacket_Pokegear
ld de, BlkPacket_9a86
ret
; 8763
@@ -166,7 +165,7 @@ Predef_LoadSGBLayout: ; 864c
.SGB_StatsScreenHPPals: ; 8763
ld hl, PalPacket_9ce6
ld de, wSGBPals
- ld bc, $10
+ ld bc, PALPACKET_LENGTH
call CopyBytes
ld a, [wCurHPPal]
ld l, a
@@ -195,12 +194,12 @@ Predef_LoadSGBLayout: ; 864c
ld a, [hl]
ld [wSGBPals + 12], a
ld hl, wSGBPals
- ld de, BlkPacket_9ac6
+ ld de, BlkPacket_StatsScreen
ret
; 87ab
.SGB_PartyMenu: ; 87ab
- ld hl, PalPacket_9c56
+ ld hl, PalPacket_PartyMenu
ld de, wSGBPals + 1
ret
; 87b2
@@ -208,16 +207,16 @@ Predef_LoadSGBLayout: ; 864c
.SGB_Pokedex: ; 87b2
ld hl, PalPacket_9ce6
ld de, wSGBPals
- ld bc, $10
+ ld bc, PALPACKET_LENGTH
call CopyBytes
ld hl, wSGBPals + 3
- ld [hl], $9f
+ ld [hl], LOW(palred 31 + palgreen 20 + palblue 10)
inc hl
- ld [hl], $2a
+ ld [hl], HIGH(palred 31 + palgreen 20 + palblue 10)
inc hl
- ld [hl], $5a
+ ld [hl], LOW(palred 26 + palgreen 10 + palblue 6)
inc hl
- ld [hl], $19
+ ld [hl], HIGH(palred 26 + palgreen 10 + palblue 6)
ld a, [CurPartySpecies]
call GetMonPalettePointer_
ld a, [hli]
@@ -229,23 +228,23 @@ Predef_LoadSGBLayout: ; 864c
ld a, [hl]
ld [wSGBPals + 12], a
ld hl, wSGBPals
- ld de, BlkPacket_9ae6
+ ld de, BlkPacket_Pokedex_PC
ret
; 87e9
.SGB_BillsPC: ; 87e9
ld hl, PalPacket_9ce6
ld de, wSGBPals
- ld bc, $10
+ ld bc, PALPACKET_LENGTH
call CopyBytes
ld hl, wSGBPals + 3
- ld [hl], $9f
+ ld [hl], LOW(palred 31 + palgreen 20 + palblue 10)
inc hl
- ld [hl], $2a
+ ld [hl], HIGH(palred 31 + palgreen 20 + palblue 10)
inc hl
- ld [hl], $5a
+ ld [hl], LOW(palred 26 + palgreen 10 + palblue 6)
inc hl
- ld [hl], $19
+ ld [hl], HIGH(palred 26 + palgreen 10 + palblue 6)
ld a, [CurPartySpecies]
ld bc, TempMonDVs
call GetPlayerOrMonPalettePointer
@@ -258,62 +257,62 @@ Predef_LoadSGBLayout: ; 864c
ld a, [hl]
ld [wSGBPals + 12], a
ld hl, wSGBPals
- ld de, BlkPacket_9ae6
+ ld de, BlkPacket_Pokedex_PC
ret
; 8823
.SGB_PokedexUnownMode: ; 8823
call .SGB_Pokedex
- ld de, BlkPacket_9af6
+ ld de, BlkPacket_PokedexUnownMode
ret
; 882a
.SGB_PokedexSearchOption: ; 882a
ld hl, PalPacket_9ce6
ld de, wSGBPals
- ld bc, $10
+ ld bc, PALPACKET_LENGTH
call CopyBytes
ld hl, wSGBPals + 3
- ld [hl], $9f
+ ld [hl], LOW(palred 31 + palgreen 20 + palblue 10)
inc hl
- ld [hl], $2a
+ ld [hl], HIGH(palred 31 + palgreen 20 + palblue 10)
inc hl
- ld [hl], $5a
+ ld [hl], LOW(palred 26 + palgreen 10 + palblue 6)
inc hl
- ld [hl], $19
+ ld [hl], HIGH(palred 26 + palgreen 10 + palblue 6)
ld hl, wSGBPals
ld de, BlkPacket_9a86
ret
; 884b
.SGB_PackPals: ; 884b
- ld hl, PalPacket_9c36
+ ld hl, PalPacket_Pack
ld de, BlkPacket_9a86
ret
; 8852
.SGB_SlotMachine: ; 8852
- ld hl, PalPacket_9c96
- ld de, BlkPacket_9b06
+ ld hl, PalPacket_SlotMachine
+ ld de, BlkPacket_SlotMachine
ret
; 8859
.SGB06: ; 8859
- ld hl, PalPacket_9ca6
- ld de, BlkPacket_9b76
+ ld hl, PalPacket_SCGB_06
+ ld de, BlkPacket_SCGB_06
ret
; 8860
.SGB_Diploma:
.SGB_MysteryGift: ; 8860
- ld hl, PalPacket_9cb6
+ ld hl, PalPacket_Diploma
ld de, BlkPacket_9a86
ret
; 8867
-.SGB07: ; 8867
+.SGB_GSIntro: ; 8867
ld b, 0
- ld hl, .BlkPacketTable_SGB07
+ ld hl, .BlkPacketTable_GSIntro
rept 4
add hl, bc
endr
@@ -327,38 +326,38 @@ endr
ret
; 8878
-.BlkPacketTable_SGB07: ; 8878
- dw BlkPacket_9a86, PalPacket_9be6
- dw BlkPacket_9a96, PalPacket_9c06
- dw BlkPacket_9a86, PalPacket_9c16
+.BlkPacketTable_GSIntro: ; 8878
+ dw BlkPacket_9a86, PalPacket_GSIntroShellderLapras
+ dw BlkPacket_GSIntroJigglypuffPikachu, PalPacket_GSIntroJigglypuffPikachu
+ dw BlkPacket_9a86, PalPacket_GSIntroStartersTransition
; 8884
-.SGB0c: ; 8884
- ld hl, PalPacket_9b96
- ld de, BlkPacket_9b56
+.SGB_GSTitleScreen: ; 8884
+ ld hl, PalPacket_GSTitleScreen
+ ld de, BlkPacket_GSTitleScreen
ld a, SCGB_DIPLOMA
ld [SGBPredef], a
ret
; 8890
.SGB13: ; 8890
- ld hl, PalPacket_9ba6
- ld de, BlkPacket_9b86
+ ld hl, PalPacket_SCGB_13
+ ld de, BlkPacket_SCGB_13
ret
; 8897
.SGB0f: ; 8897
- ld hl, PalPacket_9c46
+ ld hl, PalPacket_SCGB_0F
ld de, BlkPacket_9a86
ret
; 889e
.SGB11: ; 889e
ld hl, BlkPacket_9a86
- ld de, PlayerLightScreenCount
- ld bc, $10
+ ld de, PlayerLightScreenCount ; ???
+ ld bc, PALPACKET_LENGTH
call CopyBytes
- ld hl, PalPacket_9bb6
+ ld hl, PalPacket_SCGB_11
ld de, BlkPacket_9a86
ret
; 88b1
@@ -366,7 +365,7 @@ endr
.SGB_MapPals: ; 88b1
ld hl, PalPacket_9bd6
ld de, wSGBPals
- ld bc, $10
+ ld bc, PALPACKET_LENGTH
call CopyBytes
call .GetMapPalsIndex
ld hl, wSGBPals + 1
@@ -381,7 +380,7 @@ endr
push bc
ld hl, PalPacket_9ce6
ld de, wSGBPals
- ld bc, $10
+ ld bc, PALPACKET_LENGTH
call CopyBytes
pop bc
ld a, c
@@ -389,15 +388,13 @@ endr
jr z, .partymon
; Egg
ld hl, wSGBPals + 3
- ; RGB 7, 7, 7
- ld [hl], $e7
+ ld [hl], LOW(palred 7 + palgreen 7 + palblue 7)
inc hl
- ld [hl], $1c
+ ld [hl], HIGH(palred 7 + palgreen 7 + palblue 7)
inc hl
- ; RGB 2, 3, 3
- ld [hl], $62
+ ld [hl], LOW(palred 2 + palgreen 3 + palblue 3)
inc hl
- ld [hl], $c
+ ld [hl], HIGH(palred 2 + palgreen 3 + palblue 3)
jr .done
.partymon
@@ -426,13 +423,13 @@ endr
.SGB0d:
.SGB_TrainerCard: ; 891a
- ld hl, PalPacket_9cb6
+ ld hl, PalPacket_Diploma
ld de, BlkPacket_9a86
ret
; 8921
.SGB_UnownPuzzle: ; 8921
- ld hl, PalPacket_9bc6
+ ld hl, PalPacket_UnownPuzzle
ld de, BlkPacket_9a86
ret
; 8928
@@ -440,11 +437,11 @@ endr
.SGB12: ; 8928
ld hl, PalPacket_9bd6
ld de, wSGBPals
- ld bc, $10
+ ld bc, PALPACKET_LENGTH
call CopyBytes
ld hl, BlkPacket_9a86
- ld de, wSGBPals + $10
- ld bc, $10
+ ld de, wSGBPals + PALPACKET_LENGTH
+ ld bc, PALPACKET_LENGTH
call CopyBytes
call .GetMapPalsIndex
ld hl, wSGBPals + 1
@@ -463,14 +460,14 @@ endr
ld a, [wMenuBorderBottomCoord]
ld [hl], a
ld hl, wSGBPals
- ld de, wSGBPals + $10
+ ld de, wSGBPals + PALPACKET_LENGTH
ret
; 8969
.SGB1e: ; 8969
ld hl, PalPacket_9ce6
ld de, wSGBPals
- ld bc, $10
+ ld bc, PALPACKET_LENGTH
call CopyBytes
ld a, [CurPartySpecies]
ld l, a
@@ -500,8 +497,8 @@ endr
ret
; 89a6
-.SGB19: ; 89a6
- ld hl, PalPacket_9cd6
+.SGB_GamefreakLogo: ; 89a6
+ ld hl, PalPacket_GamefreakLogo
ld de, BlkPacket_9a86
ret
; 89ad
@@ -509,7 +506,7 @@ endr
.SGB_PlayerOrMonFrontpicPals: ; 89ad
ld hl, PalPacket_9ce6
ld de, wSGBPals
- ld bc, $10
+ ld bc, PALPACKET_LENGTH
call CopyBytes
ld a, [CurPartySpecies]
ld bc, TempMonDVs
@@ -528,7 +525,7 @@ endr
; 89d9
.SGB_TradeTube: ; 89d9
- ld hl, PalPacket_9cc6
+ ld hl, PalPacket_TradeTube
ld de, BlkPacket_9a86
ret
; 89e0
@@ -536,7 +533,7 @@ endr
.SGB_TrainerOrMonFrontpicPals: ; 89e0
ld hl, PalPacket_9ce6
ld de, wSGBPals
- ld bc, $10
+ ld bc, PALPACKET_LENGTH
call CopyBytes
ld a, [CurPartySpecies]
ld bc, TempMonDVs
@@ -558,7 +555,7 @@ endr
ld a, [TimeOfDayPal]
cp NITE_F
jr c, .morn_day
- ld a, $19
+ ld a, PREDEFPAL_NITE
ret
.morn_day
@@ -576,59 +573,31 @@ endr
ld a, [MapGroup]
ld e, a
ld d, 0
- ld hl, .SGBRoofPalInds
+ ld hl, MapGroupRoofSGBPalInds
add hl, de
ld a, [hl]
ret
.route
- ld a, $00
+ ld a, PREDEFPAL_00
ret
.cave
- ld a, $18
+ ld a, PREDEFPAL_DUNGEONS
ret
.perm5
- ld a, $06
+ ld a, PREDEFPAL_VERMILION
ret
.gate
- ld a, $03
+ ld a, PREDEFPAL_PEWTER
ret
; 8a45
-.SGBRoofPalInds: ; 8a45
- db $00 ; Unused
- db $12 ; Olivine
- db $14 ; Mahogany
- db $18 ; Various Dungeons
- db $11 ; Ecruteak
- db $15 ; Blackthorn
- db $09 ; Cinnabar
- db $04 ; Cerulean
- db $0f ; Azalea
- db $16 ; Lake Of Rage
- db $0e ; Violet
- db $10 ; Goldenrod
- db $06 ; Vermilion
- db $01 ; Palette
- db $03 ; Pewter
- db $06 ; Fast Ship
- db $0b ; Indigo Plateau
- db $08 ; Fuchsia
- db $05 ; Lavender
- db $17 ; Silver Cave Outside
- db $08 ; Pokemon Center 2F
- db $07 ; Celadon
- db $13 ; Cianwood
- db $02 ; Viridian
- db $0c ; New Bark
- db $0a ; Saffron
- db $0d ; Cherrygrove
-; 8a60
-
-.Finish: ; 8a60
+INCLUDE "data/maps/sgb_roof_pal_inds.asm"
+
+_LoadSGBLayout_ReturnFromJumpTable: ; 8a60
push de
call PushSGBPals_
pop hl
diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm
index aea08f16a..cfec11091 100755
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -1,11 +1,13 @@
-SLOTS_NOBIAS EQU -1
-SLOTS_NOMATCH EQU -1
-SLOTS_SEVEN EQU $00
+SLOTS_NO_BIAS EQU -1
+SLOTS_NO_MATCH EQU -1
+
+SLOTS_SEVEN EQU $00
SLOTS_POKEBALL EQU $04
-SLOTS_CHERRY EQU $08
-SLOTS_PIKACHU EQU $0c
+SLOTS_CHERRY EQU $08
+SLOTS_PIKACHU EQU $0c
SLOTS_SQUIRTLE EQU $10
-SLOTS_STARYU EQU $14
+SLOTS_STARYU EQU $14
+
REEL_SIZE EQU 15
; Constants for slot_reel offsets (see macros/wram.asm)
@@ -85,7 +87,7 @@ _SlotMachine:
call PlaySFX
call WaitSFX
call ClearBGPalettes
- farcall TrainerRankings_EndSlotsWinStreak
+ farcall StubbedTrainerRankings_EndSlotsWinStreak
ld hl, Options
res NO_TEXT_SCROLL, [hl]
ld hl, rLCDC
@@ -148,7 +150,7 @@ _SlotMachine:
ld [hl], $40
xor a ; SLOTS_INIT
ld [wJumptableIndex], a
- ld a, SLOTS_NOBIAS
+ ld a, SLOTS_NO_BIAS
ld [wSlotBias], a
ld de, MUSIC_GAME_CORNER
call PlayMusic
@@ -183,7 +185,7 @@ SlotsLoop: ; 927af (24:67af)
ld [wCurrSpriteOAMAddr], a
callfar DoNextFrameForFirst16Sprites
call .PrintCoinsAndPayout
- call .DummyFunc
+ call .Stubbed_Function927d3
call DelayFrame
and a
ret
@@ -192,7 +194,7 @@ SlotsLoop: ; 927af (24:67af)
scf
ret
-.DummyFunc: ; 927d3 (24:67d3)
+.Stubbed_Function927d3: ; 927d3 (24:67d3)
; dummied out
ret
ld a, [wReel1ReelAction]
@@ -232,8 +234,8 @@ SlotsLoop: ; 927af (24:67af)
; 92811 (24:6811)
-Function92811: ; 92811
-; unreferenced - debug function?
+Unreferenced_Function92811: ; 92811
+; debug function?
ld a, [wSlotBias]
add 0
daa
@@ -252,23 +254,22 @@ Function92811: ; 92811
; 9282c
-Function9282c: ; 9282c
-; unreferenced
+Unreferenced_Function9282c: ; 9282c
; animate OAM tiles?
ld hl, wcf66
ld a, [hl]
inc [hl]
and $7
ret nz
- ld hl, Sprites + 16 * 4 + 2
- ld c, 40 - 16
+ ld hl, Sprite17TileID
+ ld c, NUM_SPRITE_OAM_STRUCTS - 16
.loop
ld a, [hl]
- xor $20
- ld [hli], a
- inc hl
- inc hl
+ xor %00100000
+ ld [hli], a ; tile id
+rept SPRITEOAMSTRUCT_LENGTH +- 1
inc hl
+endr
dec c
jr nz, .loop
ret
@@ -309,7 +310,7 @@ SlotsAction_Init: ; 9287e (24:687e)
xor a
ld [wFirstTwoReelsMatching], a
ld [wFirstTwoReelsMatchingSevens], a
- ld a, SLOTS_NOMATCH
+ ld a, SLOTS_NO_MATCH
ld [wSlotMatched], a
ret
@@ -417,7 +418,7 @@ SlotsAction_WaitStopReel3: ; 9293a (24:693a)
SlotsAction_FlashIfWin: ; 92955 (24:6955)
ld a, [wSlotMatched]
- cp SLOTS_NOMATCH
+ cp SLOTS_NO_MATCH
jr nz, .GotIt
call SlotsAction_Next
call SlotsAction_Next
@@ -587,7 +588,7 @@ Slots_StopReel2: ; 92a2e (24:6a2e)
ld a, [wSlotBias]
and a
jr z, .skip
- cp SLOTS_NOBIAS
+ cp SLOTS_NO_BIAS
jr nz, .dont_jump
.skip
call .CheckReel1ForASeven
@@ -670,7 +671,7 @@ Slots_InitReelTiles: ; 92a98 (24:6a98)
ld bc, wReel1
ld hl, REEL_OAM_ADDR
add hl, bc
- ld de, Sprites + 16 * 4
+ ld de, Sprite17
ld [hl], e
inc hl
ld [hl], d
@@ -688,7 +689,7 @@ Slots_InitReelTiles: ; 92a98 (24:6a98)
ld bc, wReel2
ld hl, REEL_OAM_ADDR
add hl, bc
- ld de, Sprites + 24 * 4
+ ld de, Sprite25
ld [hl], e
inc hl
ld [hl], d
@@ -706,7 +707,7 @@ Slots_InitReelTiles: ; 92a98 (24:6a98)
ld bc, wReel3
ld hl, REEL_OAM_ADDR
add hl, bc
- ld de, Sprites + 32 * 4
+ ld de, Sprite33
ld [hl], e
inc hl
ld [hl], d
@@ -821,41 +822,40 @@ Slots_UpdateReelPositionAndOAM: ; 92b53 (24:6b53)
ld l, a
.loop
ld a, [wCurrReelYCoord]
- ld [hli], a
+ ld [hli], a ; y
ld a, [wCurrReelXCoord]
- ld [hli], a
+ ld [hli], a ; x
ld a, [de]
- ld [hli], a
+ ld [hli], a ; tile id
srl a
srl a
- set 7, a
- ld [hli], a
+ set OAM_PRIORITY, a
+ ld [hli], a ; attributes
ld a, [wCurrReelYCoord]
- ld [hli], a
+ ld [hli], a ; y
ld a, [wCurrReelXCoord]
- add 1 * 8
- ld [hli], a
+ add 1 * TILE_WIDTH
+ ld [hli], a ; x
ld a, [de]
inc a
inc a
- ld [hli], a
+ ld [hli], a ; tile id
srl a
srl a
- set 7, a
- ld [hli], a
+ set OAM_PRIORITY, a
+ ld [hli], a ; attributes
inc de
ld a, [wCurrReelYCoord]
- sub 2 * 8
+ sub 2 * TILE_WIDTH
ld [wCurrReelYCoord], a
- cp 2 * 8
+ cp 2 * TILE_WIDTH
jr nz, .loop
ret
; 92bbe (24:6bbe)
-; unreferenced
-Function92bbe: ; 92bbe
+Unreferenced_Function92bbe: ; 92bbe
push hl
srl a
srl a
@@ -997,7 +997,7 @@ ReelAction_StopReel1: ; 92c5e
; even if the current bet won't allow lining it up.
ld a, [wSlotBias]
- cp SLOTS_NOBIAS
+ cp SLOTS_NO_BIAS
jr z, .NoBias
ld hl, REEL_MANIP_COUNTER
add hl, bc
@@ -1043,7 +1043,7 @@ ReelAction_StopReel2: ; 92c86
jr z, .NoBias
.nope
ld a, [wSlotBias]
- cp SLOTS_NOBIAS
+ cp SLOTS_NO_BIAS
jr z, .NoBias
ld hl, REEL_MANIP_COUNTER
add hl, bc
@@ -1079,7 +1079,7 @@ ReelAction_StopReel3: ; 92ca9
.NoMatch:
ld a, [wSlotBias]
- cp SLOTS_NOBIAS
+ cp SLOTS_NO_BIAS
jr z, .NoBias
ld hl, REEL_MANIP_COUNTER
add hl, bc
@@ -1532,7 +1532,7 @@ Slots_CheckMatchedFirstTwoReels: ; 92e94
; 92f1d
Slots_CheckMatchedAllThreeReels: ; 92f1d
- ld a, SLOTS_NOMATCH
+ ld a, SLOTS_NO_MATCH
ld [wSlotMatched], a
call Slots_GetCurrentReelState
call Slots_CopyReelState
@@ -1552,7 +1552,7 @@ Slots_CheckMatchedAllThreeReels: ; 92f1d
.return
ld a, [wSlotMatched]
- cp SLOTS_NOMATCH
+ cp SLOTS_NO_MATCH
jr nz, .matched_nontrivial
and a
ret
@@ -1753,7 +1753,7 @@ Slots_InitBias: ; 93002 (24:7002)
db $14, SLOTS_SQUIRTLE ; 5/128
db $28, SLOTS_PIKACHU ; 5/64
db $30, SLOTS_CHERRY ; 1/32
- db $ff, SLOTS_NOBIAS ; everything else
+ db $ff, SLOTS_NO_BIAS ; everything else
; 93031
.Lucky: ; 93031
@@ -1763,7 +1763,7 @@ Slots_InitBias: ; 93002 (24:7002)
db $10, SLOTS_SQUIRTLE ; 1/32
db $1e, SLOTS_PIKACHU ; 7/128
db $50, SLOTS_CHERRY ; 25/128
- db $ff, SLOTS_NOBIAS ; everything else
+ db $ff, SLOTS_NO_BIAS ; everything else
; 9303f
Slots_IlluminateBetLights: ; 9303f (24:703f)
@@ -1868,15 +1868,14 @@ Slots_AskBet: ; 9307c (24:707c)
; 0x930d6
.MenuDataHeader: ; 0x930d6
- db $40 ; flags
- db 10, 14 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 14, 10, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw .MenuData2
db 1 ; default option
; 0x930de
.MenuData2: ; 0x930de
- db $80 ; flags
+ db STATICMENU_CURSOR ; flags
db 3 ; items
db " 3@"
db " 2@"
@@ -1924,7 +1923,7 @@ Slots_AskPlayAgain: ; 930e9 (24:70e9)
Slots_GetPayout: ; 93124 (24:7124)
ld a, [wSlotMatched]
- cp SLOTS_NOMATCH
+ cp SLOTS_NO_MATCH
jr z, .no_win
srl a
ld e, a
@@ -1937,7 +1936,7 @@ Slots_GetPayout: ; 93124 (24:7124)
ld a, [hl]
ld [wPayout], a
ld d, a
- farcall TrainerRankings_AddToSlotsPayouts
+ farcall StubbedTrainerRankings_AddToSlotsPayouts
ret
.PayoutTable:
@@ -1957,11 +1956,11 @@ Slots_GetPayout: ; 93124 (24:7124)
Slots_PayoutText: ; 93158 (24:7158)
ld a, [wSlotMatched]
- cp SLOTS_NOMATCH
+ cp SLOTS_NO_MATCH
jr nz, .MatchedSomething
ld hl, .Text_Darn
call PrintText
- farcall TrainerRankings_EndSlotsWinStreak
+ farcall StubbedTrainerRankings_EndSlotsWinStreak
ret
.MatchedSomething:
@@ -1985,7 +1984,7 @@ Slots_PayoutText: ; 93158 (24:7158)
.return
ld hl, .Text_PrintPayout
call PrintText
- farcall TrainerRankings_AddToSlotsWinStreak
+ farcall StubbedTrainerRankings_AddToSlotsWinStreak
ret
; 93195 (24:7195)
@@ -2047,7 +2046,7 @@ endr
call Random
and %0010100
ret z ; 25% chance to stick with seven symbol bias
- ld a, SLOTS_NOBIAS
+ ld a, SLOTS_NO_BIAS
ld [wSlotBias], a
ret
@@ -2055,7 +2054,7 @@ endr
call Random
and %0011100
ret z ; 12.5% chance to stick with seven symbol bias
- ld a, SLOTS_NOBIAS
+ ld a, SLOTS_NO_BIAS
ld [wSlotBias], a
ret
diff --git a/engine/specials.asm b/engine/specials.asm
index cd2394b96..965e3d58b 100644
--- a/engine/specials.asm
+++ b/engine/specials.asm
@@ -14,185 +14,9 @@ Special:: ; c01b
ret
; c029
-SpecialsPointers:: ; c029
- add_special WarpToSpawnPoint
-
-; Communications
- add_special Special_SetBitsForLinkTradeRequest
- add_special Special_WaitForLinkedFriend
- add_special Special_CheckLinkTimeout
- add_special Special_TryQuickSave
- add_special Special_CheckBothSelectedSameRoom
- add_special Special_FailedLinkToPast
- add_special Special_CloseLink
- add_special WaitForOtherPlayerToExit
- add_special Special_SetBitsForBattleRequest
- add_special Special_SetBitsForTimeCapsuleRequest
- add_special Special_CheckTimeCapsuleCompatibility
- add_special Special_EnterTimeCapsule
- add_special Special_TradeCenter
- add_special Special_Colosseum
- add_special Special_TimeCapsule
- add_special Special_CableClubCheckWhichChris
- add_special Special_CheckMysteryGift
- add_special Special_GetMysteryGiftItem
- add_special Special_UnlockMysteryGift
-
-; Map Events
- add_special BugContestJudging
- add_special CheckPartyFullAfterContest
- add_special ContestDropOffMons
- add_special ContestReturnMons
- add_special Special_GiveParkBalls
- add_special Special_CheckMagikarpLength
- add_special Special_MagikarpHouseSign
- add_special HealParty
- add_special PokemonCenterPC
- add_special Special_KrissHousePC
- add_special Special_DayCareMan
- add_special Special_DayCareLady
- add_special Special_DayCareManOutside
- add_special MoveDeletion
- add_special Special_BankOfMom
- add_special Special_MagnetTrain
- add_special SpecialNameRival
- add_special Special_SetDayOfWeek
- add_special Special_TownMap
- add_special Special_UnownPrinter
- add_special MapRadio
- add_special Special_UnownPuzzle
- add_special Special_SlotMachine
- add_special Special_CardFlip
- add_special Special_DummyNonfunctionalGameCornerGame
- add_special Special_ClearBGPalettesBufferScreen
- add_special FadeOutPalettes
- add_special Special_BattleTowerFade
- add_special Special_FadeBlackQuickly
- add_special FadeInPalettes
- add_special Special_FadeInQuickly
- add_special Special_ReloadSpritesNoPalettes
- add_special ClearBGPalettes
- add_special UpdateTimePals
- add_special ClearTileMap
- add_special UpdateSprites
- add_special ReplaceKrisSprite
- add_special Special_GameCornerPrizeMonCheckDex
- add_special SpecialSeenMon
- add_special WaitSFX
- add_special PlayMapMusic
- add_special RestartMapMusic
- add_special HealMachineAnim
- add_special Special_SurfStartStep
- add_special Special_FindGreaterThanThatLevel
- add_special Special_FindAtLeastThatHappy
- add_special Special_FindThatSpecies
- add_special Special_FindThatSpeciesYourTrainerID
- add_special Special_CheckUnusedTwoDayTimer ; unreferenced
- add_special Special_DayCareMon1
- add_special Special_DayCareMon2
- add_special Special_SelectRandomBugContestContestants
- add_special Special_ActivateFishingSwarm
- add_special ToggleMaptileDecorations
- add_special ToggleDecorationsVisibility
- add_special SpecialGiveShuckle
- add_special SpecialReturnShuckle
- add_special Special_BillsGrandfather
- add_special SpecialCheckPokerus
- add_special Special_DisplayCoinCaseBalance
- add_special Special_DisplayMoneyAndCoinBalance
- add_special PlaceMoneyTopRight
- add_special Special_CheckForLuckyNumberWinners
- add_special Special_CheckLuckyNumberShowFlag
- add_special Special_ResetLuckyNumberShowFlag
- add_special Special_PrintTodaysLuckyNumber
- add_special Special_SelectApricornForKurt
- add_special SpecialNameRater
- add_special Special_DisplayLinkRecord
- add_special GetFirstPokemonHappiness
- add_special CheckFirstMonIsEgg
- add_special RandomUnseenWildMon
- add_special RandomPhoneWildMon
- add_special RandomPhoneMon
- add_special MapCallbackSprites_LoadUsedSpritesGFX
- add_special PlaySlowCry
- add_special SpecialSnorlaxAwake
- add_special Special_YoungerHaircutBrother
- add_special Special_OlderHaircutBrother
- add_special Special_DaisyMassage
- add_special PlayCurMonCry
- add_special ProfOaksPCBoot
- add_special SpecialGameboyCheck
- add_special SpecialTrainerHouse
- add_special PhotoStudio
- add_special InitRoamMons
- add_special Special_FadeOutMusic
- add_special Diploma
- add_special PrintDiploma
-
- ; Crystal
- add_special Function11ac3e
- add_special Function11b444
- add_special Function11b5e8
- add_special Function11b7e5
- add_special Function11b879
- add_special Function11b920
- add_special Function11b93b
- add_special BattleTowerRoomMenu
- add_special Function1700ba
- add_special Function170114
- add_special BattleTowerBattle
- add_special Function1704e1
- add_special EmptySpecial_17021d
- add_special Function_LoadOpponentTrainerAndPokemonsWithOTSprite
- add_special Function11ba38
- add_special SpecialCheckForBattleTowerRules
- add_special Special_GiveOddEgg
- add_special Reset
- add_special Function1011f1
- add_special Function101220
- add_special Function101225
- add_special Function101231
- add_special Special_MoveTutor
- add_special SpecialOmanyteChamber
- add_special Function11c1ab
- add_special BattleTowerAction
- add_special Special_DisplayUnownWords
- add_special Special_Menu_ChallengeExplanationCancel
- add_special Function17d2b6
- add_special Function17d2ce
- add_special BattleTowerMobileError
- add_special AskMobileOrCable
- add_special SpecialHoOhChamber
- add_special Function102142
- add_special Special_CelebiShrineEvent
- add_special CheckCaughtCelebi
- add_special SpecialPokeSeer
- add_special SpecialBuenasPassword
- add_special SpecialBuenaPrize
- add_special SpecialDratini
- add_special Special_SampleKenjiBreakCountdown
- add_special SpecialBeastsCheck
- add_special SpecialMonCheck
- add_special Special_SetPlayerPalette
- add_special ret_170bd2
- add_special Mobile_SelectThreeMons
- add_special Function1037eb
- add_special Function10383c
- add_special TrainerRankings_Healings
- add_special RefreshSprites
- add_special Function1037c2
- add_special Mobile_DummyReturnFalse
- add_special Function103780
- add_special Function10387b
- add_special AskRememberPassword
- add_special LoadMapPalettes
- add_special FindItemInPCOrBag
- add_special Special_InitialSetDSTFlag
- add_special Special_InitialClearDSTFlag
- add_special SpecialNone
-; c224
-
-SpecialNone: ; c224
+INCLUDE "data/special_pointers.asm"
+
+DummySpecial_c224: ; c224
ret
; c225
@@ -219,7 +43,7 @@ Special_GameCornerPrizeMonCheckDex: ; c230
ret
; c252
-SpecialSeenMon: ; c252
+UnusedSpecial_SeenMon: ; c252
ld a, [ScriptVar]
dec a
call SetSeenMon
@@ -265,7 +89,7 @@ FoundNone: ; c298
ret
; c29d
-SpecialNameRival: ; 0xc29d
+Special_NameRival: ; 0xc29d
ld b, $2 ; rival
ld de, RivalName
farcall _NamingScreen
@@ -279,7 +103,7 @@ SpecialNameRival: ; 0xc29d
DefaultRivalName: ; 0xc2b2
db "SILVER@"
-SpecialNameRater: ; c2b9
+Special_NameRater: ; c2b9
farcall NameRater
ret
; c2c0
@@ -363,14 +187,14 @@ Special_GetMysteryGiftItem: ; c309
db "@"
; 0xc34a
-BugContestJudging: ; c34a
+Special_BugContestJudging: ; c34a
farcall _BugContestJudging
ld a, b
ld [ScriptVar], a
ret
; c355
-MapRadio: ; c355
+Special_MapRadio: ; c355
ld a, [ScriptVar]
ld e, a
farcall PlayRadio
@@ -483,7 +307,7 @@ ScriptReturnCarry: ; c3e2
ret
; c3ef
-Special_CheckUnusedTwoDayTimer: ; c3ef
+UnusedSpecial_CheckUnusedTwoDayTimer: ; c3ef
farcall CheckUnusedTwoDayTimer
ld a, [wUnusedTwoDayTimer]
ld [ScriptVar], a
@@ -517,7 +341,7 @@ StoreSwarmMapIndices:: ; c403
; c419
-SpecialCheckPokerus: ; c419
+Special_CheckPokerus: ; c419
; Check if a monster in your party has Pokerus
farcall CheckPokerus
jp ScriptReturnCarry
@@ -536,7 +360,7 @@ Special_CheckLuckyNumberShowFlag: ; c434
jp ScriptReturnCarry
; c43d
-SpecialSnorlaxAwake: ; 0xc43d
+Special_SnorlaxAwake: ; 0xc43d
; Check if the Poké Flute channel is playing, and if the player is standing
; next to Snorlax.
@@ -587,13 +411,13 @@ SpecialSnorlaxAwake: ; 0xc43d
db -1
-PlayCurMonCry: ; c472
+Special_PlayCurMonCry: ; c472
ld a, [CurPartySpecies]
- jp PlayCry
+ jp PlayMonCry
; c478
-SpecialGameboyCheck: ; c478
+Special_GameboyCheck: ; c478
ld a, [hCGB]
and a
jr nz, .cgb
@@ -603,13 +427,13 @@ SpecialGameboyCheck: ; c478
jr nz, .sgb
.gb
- xor a
+ xor a ; GBCHECK_GB
jr .done
.sgb
- ld a, 1
+ ld a, GBCHECK_SGB
jr .done
.cgb
- ld a, 2
+ ld a, GBCHECK_CGB
.done
ld [ScriptVar], a
ret
@@ -625,21 +449,21 @@ Special_FadeOutMusic: ; c48f
ret
; c49f
-Diploma: ; c49f
+Special_Diploma: ; c49f
call FadeToMenu
farcall _Diploma
call ExitAllMenus
ret
; c4ac
-PrintDiploma: ; c4ac
+Special_PrintDiploma: ; c4ac
call FadeToMenu
farcall _PrintDiploma
call ExitAllMenus
ret
; c4b9
-SpecialTrainerHouse: ; 0xc4b9
+Special_TrainerHouse: ; 0xc4b9
ld a, BANK(sMysteryGiftTrainerHouseFlag)
call GetSRAMBank
ld a, [sMysteryGiftTrainerHouseFlag]
diff --git a/engine/sprite_anims.asm b/engine/sprite_anims.asm
index 9fb78a5d7..9353b71c9 100755
--- a/engine/sprite_anims.asm
+++ b/engine/sprite_anims.asm
@@ -27,7 +27,7 @@ DoAnimFrame: ; 8d24b
dw .SlotsChansey
dw .SlotsChanseyEgg
dw .MailCursor
- dw .ForUnusedCursor
+ dw .UnusedCursor
dw .DummyGameCursor
dw .PokegearArrow
dw .TradePokeBall
@@ -39,11 +39,11 @@ DoAnimFrame: ; 8d24b
dw .FlyFrom
dw .FlyLeaf
dw .FlyTo
- dw .sprite_anim_seq_19
- dw .sprite_anim_seq_1A
- dw .sprite_anim_seq_1B
- dw .sprite_anim_seq_1C
- dw .IntroSuicune
+ dw .GSIntroHoOh
+ dw .EZChatCursor
+ dw .MobileTradeSentPulse
+ dw .MobileTradeOTPulse
+ dw .IntroSuicune
dw .IntroPichuWooper
dw .Celebi
dw .IntroUnown
@@ -202,7 +202,7 @@ DoAnimFrame: ; 8d24b
ret
; 8d35a
-.sprite_anim_seq_19 ; 8d35a (23:535a)
+.GSIntroHoOh ; 8d35a (23:535a)
ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
@@ -403,7 +403,7 @@ DoAnimFrame: ; 8d24b
ld [hl], a
ret
-.ForUnusedCursor ; 8d46e (23:546e)
+.UnusedCursor ; 8d46e (23:546e)
callfar ret_e00ed
ret
@@ -430,7 +430,7 @@ DoAnimFrame: ; 8d24b
; 8d493
.TradePokeBall_zero ; 8d493
- ld a, SPRITE_ANIM_FRAMESET_TRADE_POKE_BALL_0
+ ld a, SPRITE_ANIM_FRAMESET_TRADE_POKE_BALL_WOBBLE
call _ReinitSpriteAnimFrame
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
@@ -748,11 +748,11 @@ DoAnimFrame: ; 8d24b
ld [hl], a
ret
-.sprite_anim_seq_1B ; 8d630 (23:5630)
+.MobileTradeSentPulse ; 8d630 (23:5630)
farcall Function108bc7
ret
-.sprite_anim_seq_1C ; 8d637 (23:5637)
+.MobileTradeOTPulse ; 8d637 (23:5637)
farcall Function108be0
ret
@@ -845,7 +845,7 @@ DoAnimFrame: ; 8d24b
ld [hl], a
ret
-.sprite_anim_seq_1A ; 8d6b7 (23:56b7)
+.EZChatCursor ; 8d6b7 (23:56b7)
farcall AnimateEZChatCursor
ret
diff --git a/engine/sprites.asm b/engine/sprites.asm
index e1aad4832..7928fe1f0 100755
--- a/engine/sprites.asm
+++ b/engine/sprites.asm
@@ -36,7 +36,7 @@ PlaySpriteAnimations: ; 8cf69
DoNextFrameForAllSprites: ; 8cf7a
ld hl, wSpriteAnimationStructs
- ld e, 10 ; There are 10 structs here.
+ ld e, NUM_SPRITE_ANIM_STRUCTS
.loop
ld a, [hl]
@@ -53,7 +53,7 @@ DoNextFrameForAllSprites: ; 8cf7a
jr c, .done
.next
- ld bc, $10
+ ld bc, SPRITEANIMSTRUCT_LENGTH
add hl, bc
dec e
jr nz, .loop
@@ -76,7 +76,7 @@ DoNextFrameForAllSprites: ; 8cf7a
DoNextFrameForFirst16Sprites: ; 8cfa8 (23:4fa8)
ld hl, wSpriteAnimationStructs
- ld e, 10
+ ld e, NUM_SPRITE_ANIM_STRUCTS
.loop
ld a, [hl]
@@ -93,18 +93,18 @@ DoNextFrameForFirst16Sprites: ; 8cfa8 (23:4fa8)
jr c, .done
.next
- ld bc, $10
+ ld bc, SPRITEANIMSTRUCT_LENGTH
add hl, bc
dec e
jr nz, .loop
ld a, [wCurrSpriteOAMAddr]
ld l, a
- ld h, HIGH(Sprites + 16 * 4)
+ ld h, HIGH(Sprite17)
.loop2 ; Clear (Sprites + [wCurrSpriteOAMAddr] --> Sprites + $40)
ld a, l
- cp LOW(Sprites + 16 * 4)
+ cp LOW(Sprite17)
jr nc, .done
xor a
ld [hli], a
@@ -119,12 +119,12 @@ InitSpriteAnimStruct:: ; 8cfd6
push de
push af
ld hl, wSpriteAnimationStructs
- ld e, 10
+ ld e, NUM_SPRITE_ANIM_STRUCTS
.loop
ld a, [hl]
and a
jr z, .found
- ld bc, $10
+ ld bc, SPRITEANIMSTRUCT_LENGTH
add hl, bc
dec e
jr nz, .loop
@@ -222,8 +222,8 @@ DeinitializeSprite: ; 8d036
DeinitializeAllSprites: ; 8d03d (23:503d)
; Clear the index field of every struct in the wSpriteAnimationStructs array.
ld hl, wSpriteAnimationStructs
- ld bc, $10
- ld e, 10
+ ld bc, SPRITEANIMSTRUCT_LENGTH
+ ld e, NUM_SPRITE_ANIM_STRUCTS
xor a
.loop
ld [hl], a
@@ -391,7 +391,7 @@ GetSpriteAnimVTile: ; 8d109
push bc
ld hl, wSpriteAnimDict
ld b, a
- ld c, 10
+ ld c, NUM_SPRITE_ANIM_STRUCTS
.loop
ld a, [hli]
cp b
@@ -527,8 +527,7 @@ GetFrameOAMPointer: ; 8d1a2
ret
; 8d1ac
-BrokenGetStdGraphics: ; 8d1ac
-; dummied out
+Unreferenced_BrokenGetStdGraphics: ; 8d1ac
push hl
ld l, a
ld h, 0
@@ -576,21 +575,22 @@ BrokenStdGFXPointers: ; Broken 2bpp pointers
Sprites_Cosine: ; 8e72a
- add $10
+; a = d * cos(a * pi/32)
+ add %010000
Sprites_Sine: ; 8e72c
-; floor(d * sin(a * pi/32))
- and $3f
- cp $20
+; a = d * sin(a * pi/32)
+ and %111111
+ cp %100000
jr nc, .negative
call .ApplySineWave
ld a, h
ret
.negative
- and $1f
+ and %011111
call .ApplySineWave
ld a, h
- xor $ff ; cpl
+ xor $ff
inc a
ret
; 8e741
@@ -610,7 +610,6 @@ Sprites_Sine: ; 8e72c
srl a
jr nc, .even
add hl, de
-
.even
sla e
rl d
@@ -650,8 +649,8 @@ AnimateEndOfExpBar: ; 8e79d
; 8e7c6
.AnimateFrame: ; 8e7c6
- ld hl, Sprites
- ld c, $8
+ ld hl, Sprite01
+ ld c, 8 ; number of animated circles
.anim_loop
ld a, c
and a
@@ -669,8 +668,8 @@ AnimateEndOfExpBar: ; 8e79d
call Sprites_Sine
pop hl
pop de
- add 13 * 8
- ld [hli], a
+ add 13 * TILE_WIDTH
+ ld [hli], a ; y
pop af
push de
@@ -678,13 +677,13 @@ AnimateEndOfExpBar: ; 8e79d
call Sprites_Cosine
pop hl
pop de
- add 10 * 8 + 4
- ld [hli], a
+ add 10 * TILE_WIDTH + 4
+ ld [hli], a ; x
ld a, $0
- ld [hli], a
+ ld [hli], a ; tile id
ld a, PAL_BATTLE_OB_BLUE
- ld [hli], a
+ ld [hli], a ; attributes
jr .anim_loop
; 8e7f4
diff --git a/engine/start_menu.asm b/engine/start_menu.asm
index 913bf3780..c0c4a38a3 100755
--- a/engine/start_menu.asm
+++ b/engine/start_menu.asm
@@ -152,21 +152,19 @@ StartMenu:: ; 125cd
.MenuDataHeader:
- db $40 ; tile backup
- db 0, 10 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 10, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw .MenuData
db 1 ; default selection
.ContestMenuDataHeader:
- db $40 ; tile backup
- db 2, 10 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 10, 2, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw .MenuData
db 1 ; default selection
.MenuData:
- db %10101000 ; x padding, wrap around, start can close
+ db STATICMENU_CURSOR | STATICMENU_WRAP | STATICMENU_ENABLE_START ; flags
dn 0, 0 ; rows, columns
dw MenuItemsList
dw .MenuString
@@ -190,13 +188,13 @@ StartMenu:: ; 125cd
.SaveString: db "SAVE@"
.OptionString: db "OPTION@"
.ExitString: db "EXIT@"
-.PokegearString: db $24, "GEAR@"
+.PokegearString: db "<POKE>GEAR@"
.QuitString: db "QUIT@"
.PokedexDesc: db "#MON"
next "database@"
-.PartyDesc: db "Party ", $4a
+.PartyDesc: db "Party <PKMN>"
next "status@"
.PackDesc: db "Contains"
@@ -503,7 +501,7 @@ StartMenu_Pack: ; 1295b
call FadeToMenu
farcall Pack
- ld a, [wcf66]
+ ld a, [wPackUsedItem]
and a
jr nz, .used_item
call CloseSubmenu
@@ -800,7 +798,7 @@ GiveTakePartyMonItem: ; 12b60
call GetCurNick
ld hl, StringBuffer1
ld de, wMonOrItemNameBuffer
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
ld a, [wMenuCursorY]
cp 1
@@ -976,14 +974,13 @@ TakePartyItem: ; 12c60
GiveTakeItemMenuData: ; 12c9b
- db %01010000
- db 12, 12 ; start coords
- db 17, 19 ; end coords
+ db MENU_SPRITE_ANIMS | MENU_BACKUP_TILES ; flags
+ menu_coords 12, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw .Items
db 1 ; default option
.Items:
- db %10000000 ; x padding
+ db STATICMENU_CURSOR ; flags
db 2 ; # items
db "GIVE@"
db "TAKE@"
@@ -1165,15 +1162,14 @@ MonMailAction: ; 12d45
.MenuDataHeader:
- db $40 ; flags
- db 10, 12 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 12, 10, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw .MenuData2
db 1 ; default option
; 0x12dd1
.MenuData2:
- db $80 ; flags
+ db STATICMENU_CURSOR ; flags
db 3 ; items
db "READ@"
db "TAKE@"
@@ -1255,7 +1251,7 @@ MonMenu_Fly: ; 12e30
jr z, .Fail
cp $0
jr z, .Error
- farcall TrainerRankings_Fly
+ farcall StubbedTrainerRankings_Fly
ld b, $4
ld a, $2
ret
@@ -1268,7 +1264,7 @@ MonMenu_Fly: ; 12e30
ld a, $0
ret
-.Unused:
+.Unreferenced:
ld a, $1
ret
; 12e55
diff --git a/engine/stats_screen.asm b/engine/stats_screen.asm
index 9f632f388..a65cecc8a 100755
--- a/engine/stats_screen.asm
+++ b/engine/stats_screen.asm
@@ -1,3 +1,9 @@
+const_value set 1
+ const PINK_PAGE ; 1
+ const GREEN_PAGE ; 2
+ const BLUE_PAGE ; 3
+NUM_STAT_PAGES EQU const_value +- 1
+
BattleStatsScreenInit: ; 4dc7b (13:5c7b)
ld a, [wLinkMode]
cp LINK_MOBILE
@@ -58,12 +64,12 @@ StatsScreenMain: ; 0x4dcd2
; stupid interns
ld [wcf64], a
ld a, [wcf64]
- and $fc
- or $1
+ and %11111100
+ or 1
ld [wcf64], a
.loop ; 4dce3
ld a, [wJumptableIndex]
- and $7f
+ and $ff ^ (1 << 7)
ld hl, StatsScreenPointerTable
rst JumpTable
call StatsScreen_WaitAnim ; check for keys?
@@ -79,13 +85,13 @@ StatsScreenMobile: ; 4dcf7
; stupid interns
ld [wcf64], a
ld a, [wcf64]
- and $fc
- or $1
+ and %11111100
+ or 1
ld [wcf64], a
.loop
farcall Mobile_SetOverworldDelay
ld a, [wJumptableIndex]
- and $7f
+ and $ff ^ (1 << 7)
ld hl, StatsScreenPointerTable
rst JumpTable
call StatsScreen_WaitAnim
@@ -277,7 +283,7 @@ StatsScreen_GetJoypad: ; 4de2c (13:5e2c)
StatsScreen_JoypadAction: ; 4de54 (13:5e54)
push af
ld a, [wcf64]
- and $3
+ maskbits NUM_STAT_PAGES
ld c, a
pop af
bit B_BUTTON_F, a
@@ -335,20 +341,20 @@ StatsScreen_JoypadAction: ; 4de54 (13:5e54)
.a_button
ld a, c
- cp $3
+ cp BLUE_PAGE ; last page
jr z, .b_button
.d_right
inc c
- ld a, $3
+ ld a, BLUE_PAGE ; last page
cp c
jr nc, .set_page
- ld c, $1
+ ld c, PINK_PAGE ; first page
jr .set_page
.d_left
dec c
jr nz, .set_page
- ld c, $3
+ ld c, BLUE_PAGE ; last page
jr .set_page
.done
@@ -447,13 +453,12 @@ StatsScreen_InitUpperHalf: ; 4deea (13:5eea)
dw wBufferMonNick
; 4df7f
-Function4df7f: ; 4df7f
-; unreferenced
+Unreferenced_Function4df7f: ; 4df7f
hlcoord 7, 0
ld bc, SCREEN_WIDTH
ld d, SCREEN_HEIGHT
.loop
- ld a, "|"
+ ld a, $31 ; vertical divider
ld [hl], a
add hl, bc
dec d
@@ -464,7 +469,7 @@ Function4df7f: ; 4df7f
StatsScreen_PlaceHorizontalDivider: ; 4df8f (13:5f8f)
hlcoord 0, 7
ld b, SCREEN_WIDTH
- ld a, "_"
+ ld a, $62 ; horizontal divider (empty HP/exp bar)
.loop
ld [hli], a
dec b
@@ -483,7 +488,7 @@ StatsScreen_PlaceShinyIcon: ; 4dfa6 (13:5fa6)
farcall CheckShininess
ret nc
hlcoord 19, 0
- ld [hl], "<SHINY>"
+ ld [hl], "⁂"
ret
StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
@@ -507,7 +512,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
.ClearBox: ; 4dfda (13:5fda)
ld a, [wcf64]
- and $3
+ maskbits NUM_STAT_PAGES
ld c, a
call StatsScreen_LoadPageIndicators
hlcoord 0, 8
@@ -517,7 +522,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
.LoadPals: ; 4dfed (13:5fed)
ld a, [wcf64]
- and $3
+ maskbits NUM_STAT_PAGES
ld c, a
farcall LoadStatsScreenPals
call DelayFrame
@@ -527,13 +532,14 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
.PageTilemap: ; 4e002 (13:6002)
ld a, [wcf64]
- and $3
+ maskbits NUM_STAT_PAGES
dec a
ld hl, .Jumptable
rst JumpTable
ret
.Jumptable: ; 4e00d (13:600d)
+; entries correspond to *_PAGE constants
dw .PinkPage
dw .GreenPage
dw .BluePage
@@ -543,7 +549,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
ld b, $0
predef DrawPlayerHP
hlcoord 8, 9
- ld [hl], $41
+ ld [hl], $41 ; right HP/exp bar end cap
ld de, .Status_Type
hlcoord 0, 12
call PlaceString
@@ -555,7 +561,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
and $f0
jr z, .NotImmuneToPkrs
hlcoord 8, 8
- ld [hl], "."
+ ld [hl], "." ; Pokérus immunity dot
.NotImmuneToPkrs:
ld a, [MonType]
cp BOXMON
@@ -581,7 +587,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
hlcoord 9, 8
ld de, SCREEN_WIDTH
ld b, 10
- ld a, "|"
+ ld a, $31 ; vertical divider
.vertical_divider
ld [hl], a
add hl, de
@@ -613,9 +619,9 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
ld de, TempMonExp + 2
predef FillInExpBar
hlcoord 10, 16
- ld [hl], $40
+ ld [hl], $40 ; left exp bar end cap
hlcoord 19, 16
- ld [hl], $41
+ ld [hl], $41 ; right exp bar end cap
ret
.PrintNextLevel: ; 4e0d3 (13:60d3)
@@ -741,7 +747,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
hlcoord 10, 8
ld de, SCREEN_WIDTH
ld b, 10
- ld a, "|"
+ ld a, $31 ; vertical divider
.BluePageVerticalDivider:
ld [hl], a
add hl, de
@@ -823,7 +829,7 @@ StatsScreen_PlaceFrontpic: ; 4e226 (13:6226)
call SetPalettes
call .AnimateMon
ld a, [CurPartySpecies]
- call PlayCry2
+ call PlayMonCry2
ret
.AnimateMon: ; 4e253 (13:6253)
@@ -864,7 +870,7 @@ StatsScreen_PlaceFrontpic: ; 4e226 (13:6226)
ret c
call StatsScreen_LoadTextBoxSpaceGFX
ld de, vTiles2 tile $00
- predef GetAnimatedFrontpicPredef
+ predef GetAnimatedFrontpic
hlcoord 0, 0
ld d, $0
ld e, ANIM_MON_MENU
@@ -951,7 +957,7 @@ StatsScreen_LoadTextBoxSpaceGFX: ; 4e307 (13:6307)
ld [rVBK], a
ld de, TextBoxSpaceGFX
lb bc, BANK(TextBoxSpaceGFX), 1
- ld hl, vTiles2 tile $7f
+ ld hl, vTiles2 tile " "
call Get2bpp
pop af
ld [rVBK], a
@@ -962,9 +968,8 @@ StatsScreen_LoadTextBoxSpaceGFX: ; 4e307 (13:6307)
ret
; 4e32a (13:632a)
-; unreferenced
-Unknown_4e32a: ; 4e32a
-; A blank tile?
+Unreferenced_4e32a: ; 4e32a
+; A blank space tile?
ds 16
; 4e33a
@@ -1069,7 +1074,7 @@ StatsScreen_AnimateEgg: ; 4e497 (13:6497)
ld [wBoxAlignment], a
call StatsScreen_LoadTextBoxSpaceGFX
ld de, vTiles2 tile $00
- predef GetAnimatedFrontpicPredef
+ predef GetAnimatedFrontpic
pop de
hlcoord 0, 0
ld d, $0
@@ -1080,22 +1085,22 @@ StatsScreen_AnimateEgg: ; 4e497 (13:6497)
StatsScreen_LoadPageIndicators: ; 4e4cd (13:64cd)
hlcoord 13, 5
- ld a, $36
+ ld a, $36 ; first of 4 small square tiles
call .load_square
hlcoord 15, 5
- ld a, $36
+ ld a, $36 ; " " " "
call .load_square
hlcoord 17, 5
- ld a, $36
+ ld a, $36 ; " " " "
call .load_square
ld a, c
- cp $2
- ld a, $3a
- hlcoord 13, 5
+ cp GREEN_PAGE
+ ld a, $3a ; first of 4 large square tiles
+ hlcoord 13, 5 ; PINK_PAGE (< GREEN_PAGE)
jr c, .load_square
- hlcoord 15, 5
+ hlcoord 15, 5 ; GREEN_PAGE (= GREEN_PAGE)
jr z, .load_square
- hlcoord 17, 5
+ hlcoord 17, 5 ; BLUE_PAGE (> GREEN_PAGE)
.load_square ; 4e4f7 (13:64f7)
push bc
ld [hli], a
@@ -1112,8 +1117,8 @@ StatsScreen_LoadPageIndicators: ; 4e4cd (13:64cd)
CopyNickname: ; 4e505 (13:6505)
ld de, StringBuffer1
- ld bc, PKMN_NAME_LENGTH
- jr .okay ; uuterly pointless
+ ld bc, MON_NAME_LENGTH
+ jr .okay ; utterly pointless
.okay
ld a, [MonType]
cp BOXMON
@@ -1157,7 +1162,7 @@ CheckFaintedFrzSlp: ; 4e53f
ld hl, MON_STATUS
add hl, bc
ld a, [hl]
- and (1 << FRZ) | SLP
+ and 1 << FRZ | SLP
jr nz, .fainted_frz_slp
and a
ret
diff --git a/engine/tileset_anims.asm b/engine/tileset_anims.asm
new file mode 100644
index 000000000..5113ae9a3
--- /dev/null
+++ b/engine/tileset_anims.asm
@@ -0,0 +1,1060 @@
+_AnimateTileset:: ; fc000
+; Iterate over a given pointer array of
+; animation functions (one per frame).
+
+; Typically in wra1, vra0
+
+ ld a, [TilesetAnim]
+ ld e, a
+ ld a, [TilesetAnim + 1]
+ ld d, a
+
+ ld a, [hTileAnimFrame]
+ ld l, a
+ inc a
+ ld [hTileAnimFrame], a
+
+ ld h, 0
+ add hl, hl
+ add hl, hl
+ add hl, de
+
+; 2-byte parameter
+; All functions take input de.
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ inc hl
+
+; Function address
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ jp hl
+; fc01b
+
+Tileset0Anim: ; 0xfc01b
+TilesetJohtoModernAnim: ; 0xfc01b
+TilesetKantoAnim: ; 0xfc01b
+ dw vTiles2 tile $14, AnimateWaterTile
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, TileAnimationPalette
+ dw NULL, WaitTileAnimation
+ dw NULL, AnimateFlowerTile
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, StandingTileFrame8
+ dw NULL, DoneTileAnimation
+; 0xfc047
+
+TilesetParkAnim: ; 0xfc047
+ dw vTiles2 tile $14, AnimateWaterTile
+ dw NULL, WaitTileAnimation
+ dw vTiles2 tile $5f, AnimateFountain
+ dw NULL, WaitTileAnimation
+ dw NULL, TileAnimationPalette
+ dw NULL, WaitTileAnimation
+ dw NULL, AnimateFlowerTile
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, StandingTileFrame8
+ dw NULL, DoneTileAnimation
+; 0xfc073
+
+TilesetForestAnim: ; 0xfc073
+ dw NULL, ForestTreeLeftAnimation
+ dw NULL, ForestTreeRightAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, ForestTreeLeftAnimation2
+ dw NULL, ForestTreeRightAnimation2
+ dw NULL, AnimateFlowerTile
+ dw vTiles2 tile $14, AnimateWaterTile
+ dw NULL, TileAnimationPalette
+ dw NULL, StandingTileFrame8
+ dw NULL, DoneTileAnimation
+; 0xfc0a3
+
+TilesetJohtoAnim: ; 0xfc0a3
+ dw vTiles2 tile $14, AnimateWaterTile
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, TileAnimationPalette
+ dw NULL, WaitTileAnimation
+ dw NULL, AnimateFlowerTile
+ dw WhirlpoolFrames1, AnimateWhirlpoolTile
+ dw WhirlpoolFrames2, AnimateWhirlpoolTile
+ dw WhirlpoolFrames3, AnimateWhirlpoolTile
+ dw WhirlpoolFrames4, AnimateWhirlpoolTile
+ dw NULL, WaitTileAnimation
+ dw NULL, StandingTileFrame8
+ dw NULL, DoneTileAnimation
+; 0xfc0d7
+
+UnusedTilesetAnim_fc0d7: ; 0xfc0d7
+ dw vTiles2 tile $03, WriteTileToBuffer
+ dw wTileAnimBuffer, ScrollTileRightLeft
+ dw vTiles2 tile $03, WriteTileFromBuffer
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, AnimateFlowerTile
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, DoneTileAnimation
+; 0xfc103
+
+UnusedTilesetAnim_fc103: ; 0xfc103
+ dw vTiles2 tile $14, WriteTileToBuffer
+ dw wTileAnimBuffer, ScrollTileRightLeft
+ dw vTiles2 tile $14, WriteTileFromBuffer
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, DoneTileAnimation
+; 0xfc12f
+
+TilesetPortAnim: ; 0xfc12f
+ dw vTiles2 tile $14, AnimateWaterTile
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, TileAnimationPalette
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, StandingTileFrame8
+ dw NULL, DoneTileAnimation
+; 0xfc15f
+
+TilesetEliteFourRoomAnim: ; 0xfc15f
+ dw NULL, LavaBubbleAnim2
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, LavaBubbleAnim1
+ dw NULL, WaitTileAnimation
+ dw NULL, StandingTileFrame8
+ dw NULL, DoneTileAnimation
+; 0xfc17f
+
+UnusedTilesetAnim_fc17f: ; 0xfc17f
+ dw vTiles2 tile $53, WriteTileToBuffer
+ dw wTileAnimBuffer, ScrollTileDown
+ dw wTileAnimBuffer, ScrollTileDown
+ dw vTiles2 tile $53, WriteTileFromBuffer
+ dw vTiles2 tile $03, WriteTileToBuffer
+ dw wTileAnimBuffer, ScrollTileRightLeft
+ dw vTiles2 tile $03, WriteTileFromBuffer
+ dw vTiles2 tile $53, WriteTileToBuffer
+ dw wTileAnimBuffer, ScrollTileDown
+ dw wTileAnimBuffer, ScrollTileDown
+ dw vTiles2 tile $53, WriteTileFromBuffer
+ dw NULL, DoneTileAnimation
+; 0xfc1af
+
+UnusedTilesetAnim_fc1af: ; 0xfc1af
+ dw vTiles2 tile $54, WriteTileToBuffer
+ dw wTileAnimBuffer, ScrollTileDown
+ dw wTileAnimBuffer, ScrollTileDown
+ dw vTiles2 tile $54, WriteTileFromBuffer
+ dw NULL, WaitTileAnimation
+ dw vTiles2 tile $03, WriteTileToBuffer
+ dw wTileAnimBuffer, ScrollTileRightLeft
+ dw vTiles2 tile $03, WriteTileFromBuffer
+ dw NULL, WaitTileAnimation
+ dw vTiles2 tile $54, WriteTileToBuffer
+ dw wTileAnimBuffer, ScrollTileDown
+ dw wTileAnimBuffer, ScrollTileDown
+ dw vTiles2 tile $54, WriteTileFromBuffer
+ dw NULL, DoneTileAnimation
+; 0xfc1e7
+
+TilesetCaveAnim: ; 0xfc1e7
+TilesetDarkCaveAnim: ; 0xfc1e7
+ dw vTiles2 tile $14, WriteTileToBuffer
+ dw NULL, FlickeringCaveEntrancePalette
+ dw wTileAnimBuffer, ScrollTileRightLeft
+ dw NULL, FlickeringCaveEntrancePalette
+ dw vTiles2 tile $14, WriteTileFromBuffer
+ dw NULL, FlickeringCaveEntrancePalette
+ dw NULL, TileAnimationPalette
+ dw NULL, FlickeringCaveEntrancePalette
+ dw vTiles2 tile $40, WriteTileToBuffer
+ dw NULL, FlickeringCaveEntrancePalette
+ dw wTileAnimBuffer, ScrollTileDown
+ dw NULL, FlickeringCaveEntrancePalette
+ dw wTileAnimBuffer, ScrollTileDown
+ dw NULL, FlickeringCaveEntrancePalette
+ dw wTileAnimBuffer, ScrollTileDown
+ dw NULL, FlickeringCaveEntrancePalette
+ dw vTiles2 tile $40, WriteTileFromBuffer
+ dw NULL, FlickeringCaveEntrancePalette
+ dw NULL, DoneTileAnimation
+; 0xfc233
+
+TilesetIcePathAnim: ; 0xfc233
+ dw vTiles2 tile $35, WriteTileToBuffer
+ dw NULL, FlickeringCaveEntrancePalette
+ dw wTileAnimBuffer, ScrollTileRightLeft
+ dw NULL, FlickeringCaveEntrancePalette
+ dw vTiles2 tile $35, WriteTileFromBuffer
+ dw NULL, FlickeringCaveEntrancePalette
+ dw NULL, TileAnimationPalette
+ dw NULL, FlickeringCaveEntrancePalette
+ dw vTiles2 tile $31, WriteTileToBuffer
+ dw NULL, FlickeringCaveEntrancePalette
+ dw wTileAnimBuffer, ScrollTileDown
+ dw NULL, FlickeringCaveEntrancePalette
+ dw wTileAnimBuffer, ScrollTileDown
+ dw NULL, FlickeringCaveEntrancePalette
+ dw wTileAnimBuffer, ScrollTileDown
+ dw NULL, FlickeringCaveEntrancePalette
+ dw vTiles2 tile $31, WriteTileFromBuffer
+ dw NULL, FlickeringCaveEntrancePalette
+ dw NULL, DoneTileAnimation
+; 0xfc27f
+
+TilesetTowerAnim: ; 0xfc27f
+ dw TowerPillarTilePointer9, AnimateTowerPillarTile
+ dw TowerPillarTilePointer10, AnimateTowerPillarTile
+ dw TowerPillarTilePointer7, AnimateTowerPillarTile
+ dw TowerPillarTilePointer8, AnimateTowerPillarTile
+ dw TowerPillarTilePointer5, AnimateTowerPillarTile
+ dw TowerPillarTilePointer6, AnimateTowerPillarTile
+ dw TowerPillarTilePointer3, AnimateTowerPillarTile
+ dw TowerPillarTilePointer4, AnimateTowerPillarTile
+ dw TowerPillarTilePointer1, AnimateTowerPillarTile
+ dw TowerPillarTilePointer2, AnimateTowerPillarTile
+ dw NULL, StandingTileFrame
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, DoneTileAnimation
+; 0xfc2bf
+
+UnusedTilesetAnim_fc2bf: ; 0xfc2bf
+ dw vTiles2 tile $4f, WriteTileToBuffer
+ dw wTileAnimBuffer, ScrollTileRightLeft
+ dw vTiles2 tile $4f, WriteTileFromBuffer
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, DoneTileAnimation
+; 0xfc2e7
+
+TilesetBattleTowerOutsideAnim: ; 0xfc2e7
+TilesetHouseAnim: ; 0xfc2e7
+TilesetPlayersHouseAnim: ; 0xfc2e7
+TilesetPokecenterAnim: ; 0xfc2e7
+TilesetGateAnim: ; 0xfc2e7
+TilesetLabAnim: ; 0xfc2e7
+TilesetFacilityAnim: ; 0xfc2e7
+TilesetMartAnim: ; 0xfc2e7
+TilesetMansionAnim: ; 0xfc2e7
+TilesetGameCornerAnim: ; 0xfc2e7
+TilesetTraditionalHouseAnim: ; 0xfc2e7
+TilesetTrainStationAnim: ; 0xfc2e7
+TilesetChampionsRoomAnim: ; 0xfc2e7
+TilesetLighthouseAnim: ; 0xfc2e7
+TilesetPlayersRoomAnim: ; 0xfc2e7
+TilesetPokeComCenterAnim: ; 0xfc2e7
+TilesetBattleTowerAnim: ; 0xfc2e7
+TilesetRuinsOfAlphAnim: ; 0xfc2e7
+TilesetRadioTowerAnim: ; 0xfc2e7
+TilesetUndergroundAnim: ; 0xfc2e7
+TilesetBetaWordRoomAnim: ; 0xfc2e7
+TilesetHoOhWordRoomAnim: ; 0xfc2e7
+TilesetKabutoWordRoomAnim: ; 0xfc2e7
+TilesetOmanyteWordRoomAnim: ; 0xfc2e7
+TilesetAerodactylWordRoomAnim: ; 0xfc2e7
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, WaitTileAnimation
+ dw NULL, DoneTileAnimation
+; 0xfc2fb
+
+DoneTileAnimation: ; fc2fb
+; Reset the animation command loop.
+ xor a
+ ld [hTileAnimFrame], a
+
+WaitTileAnimation: ; fc2fe
+; Do nothing this frame.
+ ret
+; fc2ff
+
+StandingTileFrame8: ; fc2ff
+ ld a, [TileAnimationTimer]
+ inc a
+ and %111
+ ld [TileAnimationTimer], a
+ ret
+; fc309
+
+
+ScrollTileRightLeft: ; fc309
+; Scroll right for 4 ticks, then left for 4 ticks.
+ ld a, [TileAnimationTimer]
+ inc a
+ and %111
+ ld [TileAnimationTimer], a
+ and %100
+ jr nz, ScrollTileLeft
+ jr ScrollTileRight
+; fc318
+
+ScrollTileUpDown: ; fc318
+; Scroll up for 4 ticks, then down for 4 ticks.
+ ld a, [TileAnimationTimer]
+ inc a
+ and %111
+ ld [TileAnimationTimer], a
+ and %100
+ jr nz, ScrollTileDown
+ jr ScrollTileUp
+; fc327
+
+ScrollTileLeft: ; fc327
+ ld h, d
+ ld l, e
+ ld c, 4
+.loop
+rept 4
+ ld a, [hl]
+ rlca
+ ld [hli], a
+endr
+ dec c
+ jr nz, .loop
+ ret
+; fc33b
+
+ScrollTileRight: ; fc33b
+ ld h, d
+ ld l, e
+ ld c, 4
+.loop
+rept 4
+ ld a, [hl]
+ rrca
+ ld [hli], a
+endr
+ dec c
+ jr nz, .loop
+ ret
+; fc34f
+
+ScrollTileUp: ; fc34f
+ ld h, d
+ ld l, e
+ ld d, [hl]
+ inc hl
+ ld e, [hl]
+ ld bc, TILE_WIDTH * 2 - 2
+ add hl, bc
+ ld a, TILE_WIDTH / 2
+.loop
+ ld c, [hl]
+ ld [hl], e
+ dec hl
+ ld b, [hl]
+ ld [hl], d
+ dec hl
+ ld e, [hl]
+ ld [hl], c
+ dec hl
+ ld d, [hl]
+ ld [hl], b
+ dec hl
+ dec a
+ jr nz, .loop
+ ret
+; fc36a
+
+ScrollTileDown: ; fc36a
+ ld h, d
+ ld l, e
+ ld de, TILE_WIDTH * 2 - 2
+ push hl
+ add hl, de
+ ld d, [hl]
+ inc hl
+ ld e, [hl]
+ pop hl
+ ld a, TILE_WIDTH / 2
+.loop
+ ld b, [hl]
+ ld [hl], d
+ inc hl
+ ld c, [hl]
+ ld [hl], e
+ inc hl
+ ld d, [hl]
+ ld [hl], b
+ inc hl
+ ld e, [hl]
+ ld [hl], c
+ inc hl
+ dec a
+ jr nz, .loop
+ ret
+; fc387
+
+
+AnimateFountain: ; fc387
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+ ld hl, .frames
+ ld a, [TileAnimationTimer]
+ and %111
+ add a
+ add l
+ ld l, a
+ jr nc, .okay
+ inc h
+.okay
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld sp, hl
+ ld l, e
+ ld h, d
+ jp WriteTile
+
+.frames
+ dw .frame1
+ dw .frame2
+ dw .frame3
+ dw .frame4
+ dw .frame3
+ dw .frame4
+ dw .frame5
+ dw .frame1
+
+.frame1 INCBIN "gfx/tilesets/fountain/1.2bpp"
+.frame2 INCBIN "gfx/tilesets/fountain/2.2bpp"
+.frame3 INCBIN "gfx/tilesets/fountain/3.2bpp"
+.frame4 INCBIN "gfx/tilesets/fountain/4.2bpp"
+.frame5 INCBIN "gfx/tilesets/fountain/5.2bpp"
+; fc402
+
+
+AnimateWaterTile: ; fc402
+; Draw a water tile for the current frame in VRAM tile at de.
+
+; Save sp in bc (see WriteTile).
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+
+ ld a, [TileAnimationTimer]
+
+; 4 tile graphics, updated every other frame.
+ and %110
+
+; 2 x 8 = 16 bytes per tile
+ add a
+ add a
+ add a
+
+ add LOW(WaterTileFrames)
+ ld l, a
+ ld a, 0
+ adc HIGH(WaterTileFrames)
+ ld h, a
+
+; Stack now points to the start of the tile for this frame.
+ ld sp, hl
+
+ ld l, e
+ ld h, d
+
+ jp WriteTile
+; fc41c
+
+WaterTileFrames: ; fc41c
+ INCBIN "gfx/tilesets/water/water.2bpp"
+; fc45c
+
+
+ForestTreeLeftAnimation: ; fc45c
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+
+; Only during the Celebi event.
+ ld a, [wCelebiEvent]
+ bit 2, a
+ jr nz, .asm_fc46c
+ ld hl, ForestTreeLeftFrames
+ jr .asm_fc47d
+
+.asm_fc46c
+ ld a, [TileAnimationTimer]
+ call GetForestTreeFrame
+ add a
+ add a
+ add a
+ add LOW(ForestTreeLeftFrames)
+ ld l, a
+ ld a, 0
+ adc HIGH(ForestTreeLeftFrames)
+ ld h, a
+
+.asm_fc47d
+ ld sp, hl
+ ld hl, vTiles2 tile $0c
+ jp WriteTile
+; fc484
+
+
+ForestTreeLeftFrames: ; fc484
+ INCBIN "gfx/tilesets/forest-tree/1.2bpp"
+ INCBIN "gfx/tilesets/forest-tree/2.2bpp"
+; fc4a4
+
+ForestTreeRightFrames: ; fc4a4
+ INCBIN "gfx/tilesets/forest-tree/3.2bpp"
+ INCBIN "gfx/tilesets/forest-tree/4.2bpp"
+; fc4c4
+
+
+ForestTreeRightAnimation: ; fc4c4
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+
+; Only during the Celebi event.
+ ld a, [wCelebiEvent]
+ bit 2, a
+ jr nz, .asm_fc4d4
+ ld hl, ForestTreeRightFrames
+ jr .asm_fc4eb
+
+.asm_fc4d4
+ ld a, [TileAnimationTimer]
+ call GetForestTreeFrame
+ add a
+ add a
+ add a
+ add LOW(ForestTreeLeftFrames)
+ ld l, a
+ ld a, 0
+ adc HIGH(ForestTreeLeftFrames)
+ ld h, a
+ push bc
+ ld bc, ForestTreeRightFrames - ForestTreeLeftFrames
+ add hl, bc
+ pop bc
+
+.asm_fc4eb
+ ld sp, hl
+ ld hl, vTiles2 tile $0f
+ jp WriteTile
+; fc4f2
+
+
+ForestTreeLeftAnimation2: ; fc4f2
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+
+; Only during the Celebi event.
+ ld a, [wCelebiEvent]
+ bit 2, a
+ jr nz, .asm_fc502
+ ld hl, ForestTreeLeftFrames
+ jr .asm_fc515
+
+.asm_fc502
+ ld a, [TileAnimationTimer]
+ call GetForestTreeFrame
+ xor 2
+ add a
+ add a
+ add a
+ add LOW(ForestTreeLeftFrames)
+ ld l, a
+ ld a, 0
+ adc HIGH(ForestTreeLeftFrames)
+ ld h, a
+
+.asm_fc515
+ ld sp, hl
+ ld hl, vTiles2 tile $0c
+ jp WriteTile
+; fc51c
+
+
+ForestTreeRightAnimation2: ; fc51c
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+
+; Only during the Celebi event.
+ ld a, [wCelebiEvent]
+ bit 2, a
+ jr nz, .asm_fc52c
+ ld hl, ForestTreeRightFrames
+ jr .asm_fc545
+
+.asm_fc52c
+ ld a, [TileAnimationTimer]
+ call GetForestTreeFrame
+ xor 2
+ add a
+ add a
+ add a
+ add LOW(ForestTreeLeftFrames)
+ ld l, a
+ ld a, 0
+ adc HIGH(ForestTreeLeftFrames)
+ ld h, a
+ push bc
+ ld bc, ForestTreeRightFrames - ForestTreeLeftFrames
+ add hl, bc
+ pop bc
+
+.asm_fc545
+ ld sp, hl
+ ld hl, vTiles2 tile $0f
+ jp WriteTile
+; fc54c
+
+
+GetForestTreeFrame: ; fc54c
+; Return 0 if a is even, or 2 if odd.
+ and a
+ jr z, .even
+ cp 1
+ jr z, .odd
+ cp 2
+ jr z, .even
+ cp 3
+ jr z, .odd
+ cp 4
+ jr z, .even
+ cp 5
+ jr z, .odd
+ cp 6
+ jr z, .even
+.odd
+ ld a, 2
+ scf
+ ret
+.even
+ xor a
+ ret
+; fc56d
+
+
+AnimateFlowerTile: ; fc56d
+; No parameters.
+
+; Save sp in bc (see WriteTile).
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+
+; Alternate tile graphic every other frame
+ ld a, [TileAnimationTimer]
+ and %10
+ ld e, a
+
+; CGB has different color mappings for flowers.
+ ld a, [hCGB]
+ and 1
+
+ add e
+ swap a
+ ld e, a
+ ld d, 0
+ ld hl, FlowerTileFrames
+ add hl, de
+ ld sp, hl
+
+ ld hl, vTiles2 tile $03
+
+ jp WriteTile
+; fc58c
+
+FlowerTileFrames: ; fc58c
+ INCBIN "gfx/tilesets/flower/dmg_1.2bpp"
+ INCBIN "gfx/tilesets/flower/cgb_1.2bpp"
+ INCBIN "gfx/tilesets/flower/dmg_2.2bpp"
+ INCBIN "gfx/tilesets/flower/cgb_2.2bpp"
+; fc5cc
+
+
+LavaBubbleAnim1: ; fc5cc
+; Splash in the bottom-right corner of the fountain.
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+ ld a, [TileAnimationTimer]
+ and %110
+ srl a
+ inc a
+ inc a
+ and %011
+ swap a
+ ld e, a
+ ld d, 0
+ ld hl, LavaBubbleFrames
+ add hl, de
+ ld sp, hl
+ ld hl, vTiles2 tile $5b
+ jp WriteTile
+; fc5eb
+
+
+LavaBubbleAnim2: ; fc5eb
+; Splash in the top-left corner of the fountain.
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+ ld a, [TileAnimationTimer]
+ and %110
+ add a
+ add a
+ add a
+ ld e, a
+ ld d, 0
+ ld hl, LavaBubbleFrames
+ add hl, de
+ ld sp, hl
+ ld hl, vTiles2 tile $38
+ jp WriteTile
+; fc605
+
+
+LavaBubbleFrames: ; fc605
+ INCBIN "gfx/tilesets/lava/1.2bpp"
+ INCBIN "gfx/tilesets/lava/2.2bpp"
+ INCBIN "gfx/tilesets/lava/3.2bpp"
+ INCBIN "gfx/tilesets/lava/4.2bpp"
+; fc645
+
+
+AnimateTowerPillarTile: ; fc645
+; Read from struct at de:
+; Destination (VRAM)
+; Address of the first tile in the frame array
+
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+
+ ld a, [TileAnimationTimer]
+ and %111
+
+; Get frame index a
+ ld hl, .frames
+ add l
+ ld l, a
+ ld a, 0
+ adc h
+ ld h, a
+ ld a, [hl]
+
+; Destination
+ ld l, e
+ ld h, d
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ inc hl
+
+; Add the frame index to the starting address
+ add [hl]
+ inc hl
+ ld h, [hl]
+ ld l, a
+ ld a, 0
+ adc h
+ ld h, a
+
+ ld sp, hl
+ ld l, e
+ ld h, d
+ jr WriteTile
+
+.frames
+ db $00, $10, $20, $30, $40, $30, $20, $10
+; fc673
+
+
+StandingTileFrame: ; fc673
+ ld hl, TileAnimationTimer
+ inc [hl]
+ ret
+; fc678
+
+
+AnimateWhirlpoolTile: ; fc678
+; Update whirlpool tile using struct at de.
+
+; Struct:
+; VRAM address
+; Address of the first tile
+
+; Only does one of 4 tiles at a time.
+
+; Save sp in bc (see WriteTile).
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+
+; de = VRAM address
+ ld l, e
+ ld h, d
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ inc hl
+; Tile address is now at hl.
+
+; Get the tile for this frame.
+ ld a, [TileAnimationTimer]
+ and %11 ; 4 frames x2
+ swap a ; * 16 bytes per tile
+
+ add [hl]
+ inc hl
+ ld h, [hl]
+ ld l, a
+ ld a, 0
+ adc h
+ ld h, a
+
+; Stack now points to the desired frame.
+ ld sp, hl
+
+ ld l, e
+ ld h, d
+
+ jr WriteTile
+; fc696
+
+
+WriteTileFromBuffer: ; fc696
+; Write tiledata at wTileAnimBuffer to de.
+; wTileAnimBuffer is loaded to sp for WriteTile.
+
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+
+ ld hl, wTileAnimBuffer
+ ld sp, hl
+
+ ld h, d
+ ld l, e
+ jr WriteTile
+; fc6a2
+
+
+WriteTileToBuffer: ; fc6a2
+; Write tiledata de to wTileAnimBuffer.
+; de is loaded to sp for WriteTile.
+
+ ld hl, sp+0
+ ld b, h
+ ld c, l
+
+ ld h, d
+ ld l, e
+ ld sp, hl
+
+ ld hl, wTileAnimBuffer
+
+ ; fallthrough
+
+WriteTile: ; fc6ac
+; Write one 8x8 tile ($10 bytes) from sp to hl.
+
+; Warning: sp is saved in bc so we can abuse pop.
+; sp is restored to address bc. Save sp in bc before calling.
+
+ pop de
+ ld [hl], e
+ inc hl
+ ld [hl], d
+
+rept 7
+ pop de
+ inc hl
+ ld [hl], e
+ inc hl
+ ld [hl], d
+endr
+
+; restore sp
+ ld h, b
+ ld l, c
+ ld sp, hl
+ ret
+; fc6d7
+
+
+TileAnimationPalette: ; fc6d7
+; Transition between color values 0-2 for color 0 in palette 3.
+
+; No palette changes on DMG.
+ ld a, [hCGB]
+ and a
+ ret z
+
+; We don't want to mess with non-standard palettes.
+ ld a, [rBGP] ; BGP
+ cp %11100100
+ ret nz
+
+; Only update on even frames.
+ ld a, [TileAnimationTimer]
+ ld l, a
+ and 1 ; odd
+ ret nz
+
+; Ready for BGPD input...
+
+ ld a, (1 << rBGPI_AUTO_INCREMENT) palette PAL_BG_WATER
+ ld [rBGPI], a
+
+ ld a, [rSVBK]
+ push af
+ ld a, BANK(wBGPals1)
+ ld [rSVBK], a
+
+; Update color 0 in order 0 1 2 1
+ ld a, l
+ and %110 ; frames 0 2 4 6
+ jr z, .color0
+ cp %100 ; frame 4
+ jr z, .color2
+
+.color1
+ ld hl, wBGPals1 palette PAL_BG_WATER + 2
+ ld a, [hli]
+ ld [rBGPD], a
+ ld a, [hli]
+ ld [rBGPD], a
+ jr .end
+
+.color0
+ ld hl, wBGPals1 palette PAL_BG_WATER
+ ld a, [hli]
+ ld [rBGPD], a
+ ld a, [hli]
+ ld [rBGPD], a
+ jr .end
+
+.color2
+ ld hl, wBGPals1 palette PAL_BG_WATER + 4
+ ld a, [hli]
+ ld [rBGPD], a
+ ld a, [hli]
+ ld [rBGPD], a
+
+.end
+ pop af
+ ld [rSVBK], a
+ ret
+; fc71e
+
+
+FlickeringCaveEntrancePalette: ; fc71e
+; No palette changes on DMG.
+ ld a, [hCGB]
+ and a
+ ret z
+; We don't want to mess with non-standard palettes.
+ ld a, [rBGP]
+ cp %11100100
+ ret nz
+; We only want to be here if we're in a dark cave.
+ ld a, [wTimeOfDayPalset]
+ cp %11111111 ; 3,3,3,3
+ ret nz
+
+ ld a, [rSVBK]
+ push af
+ ld a, BANK(wBGPals1)
+ ld [rSVBK], a
+; Ready for BGPD input...
+ ld a, (1 << rBGPI_AUTO_INCREMENT) palette PAL_BG_YELLOW
+ ld [rBGPI], a
+ ld a, [hVBlankCounter]
+ and %10
+ jr nz, .bit1set
+ ld hl, wBGPals1 palette PAL_BG_YELLOW
+ jr .okay
+
+.bit1set
+ ld hl, wBGPals1 palette PAL_BG_YELLOW + 2
+
+.okay
+ ld a, [hli]
+ ld [rBGPD], a
+ ld a, [hli]
+ ld [rBGPD], a
+
+ pop af
+ ld [rSVBK], a
+ ret
+; fc750
+
+
+TowerPillarTilePointer1: dw vTiles2 tile $2d, TowerPillarTile1
+TowerPillarTilePointer2: dw vTiles2 tile $2f, TowerPillarTile2
+TowerPillarTilePointer3: dw vTiles2 tile $3d, TowerPillarTile3
+TowerPillarTilePointer4: dw vTiles2 tile $3f, TowerPillarTile4
+TowerPillarTilePointer5: dw vTiles2 tile $3c, TowerPillarTile5
+TowerPillarTilePointer6: dw vTiles2 tile $2c, TowerPillarTile6
+TowerPillarTilePointer7: dw vTiles2 tile $4d, TowerPillarTile7
+TowerPillarTilePointer8: dw vTiles2 tile $4f, TowerPillarTile8
+TowerPillarTilePointer9: dw vTiles2 tile $5d, TowerPillarTile9
+TowerPillarTilePointer10: dw vTiles2 tile $5f, TowerPillarTile10
+
+TowerPillarTile1: INCBIN "gfx/tilesets/tower-pillar/1.2bpp"
+TowerPillarTile2: INCBIN "gfx/tilesets/tower-pillar/2.2bpp"
+TowerPillarTile3: INCBIN "gfx/tilesets/tower-pillar/3.2bpp"
+TowerPillarTile4: INCBIN "gfx/tilesets/tower-pillar/4.2bpp"
+TowerPillarTile5: INCBIN "gfx/tilesets/tower-pillar/5.2bpp"
+TowerPillarTile6: INCBIN "gfx/tilesets/tower-pillar/6.2bpp"
+TowerPillarTile7: INCBIN "gfx/tilesets/tower-pillar/7.2bpp"
+TowerPillarTile8: INCBIN "gfx/tilesets/tower-pillar/8.2bpp"
+TowerPillarTile9: INCBIN "gfx/tilesets/tower-pillar/9.2bpp"
+TowerPillarTile10: INCBIN "gfx/tilesets/tower-pillar/10.2bpp"
+; fca98
+
+
+WhirlpoolFrames1: dw vTiles2 tile $32, WhirlpoolTiles1
+WhirlpoolFrames2: dw vTiles2 tile $33, WhirlpoolTiles2
+WhirlpoolFrames3: dw vTiles2 tile $42, WhirlpoolTiles3
+WhirlpoolFrames4: dw vTiles2 tile $43, WhirlpoolTiles4
+; fcaa8
+
+WhirlpoolTiles1: INCBIN "gfx/tilesets/whirlpool/1.2bpp"
+WhirlpoolTiles2: INCBIN "gfx/tilesets/whirlpool/2.2bpp"
+WhirlpoolTiles3: INCBIN "gfx/tilesets/whirlpool/3.2bpp"
+WhirlpoolTiles4: INCBIN "gfx/tilesets/whirlpool/4.2bpp"
+; fcba8
diff --git a/engine/tileset_palettes.asm b/engine/tileset_palettes.asm
new file mode 100644
index 000000000..5a2190fc7
--- /dev/null
+++ b/engine/tileset_palettes.asm
@@ -0,0 +1,151 @@
+LoadSpecialMapPalette: ; 494ac
+ ld a, [wTileset]
+ cp TILESET_POKECOM_CENTER
+ jr z, .pokecom_2f
+ cp TILESET_BATTLE_TOWER
+ jr z, .battle_tower
+ cp TILESET_ICE_PATH
+ jr z, .ice_path
+ cp TILESET_HOUSE
+ jr z, .house
+ cp TILESET_RADIO_TOWER
+ jr z, .radio_tower
+ cp TILESET_MANSION
+ jr z, .mansion_mobile
+ jr .do_nothing
+
+.pokecom_2f
+ call LoadPokeComPalette
+ scf
+ ret
+
+.battle_tower
+ call LoadBattleTowerPalette
+ scf
+ ret
+
+.ice_path
+ ld a, [wEnvironment]
+ and $7
+ cp INDOOR ; Hall of Fame
+ jr z, .do_nothing
+ call LoadIcePathPalette
+ scf
+ ret
+
+.house
+ call LoadHousePalette
+ scf
+ ret
+
+.radio_tower
+ call LoadRadioTowerPalette
+ scf
+ ret
+
+.mansion_mobile
+ call LoadMansionPalette
+ scf
+ ret
+
+.do_nothing
+ and a
+ ret
+; 494f2
+
+LoadPokeComPalette: ; 494f2
+ ld a, BANK(wBGPals1)
+ ld de, wBGPals1
+ ld hl, PokeComPalette
+ ld bc, 8 palettes
+ call FarCopyWRAM
+ ret
+; 49501
+
+PokeComPalette: ; 49501
+INCLUDE "gfx/tilesets/pokecom_center.pal"
+; 49541
+
+LoadBattleTowerPalette: ; 49541
+ ld a, BANK(wBGPals1)
+ ld de, wBGPals1
+ ld hl, BattleTowerPalette
+ ld bc, 8 palettes
+ call FarCopyWRAM
+ ret
+; 49550
+
+BattleTowerPalette: ; 49550
+INCLUDE "gfx/tilesets/battle_tower.pal"
+; 49590
+
+LoadIcePathPalette: ; 49590
+ ld a, BANK(wBGPals1)
+ ld de, wBGPals1
+ ld hl, IcePathPalette
+ ld bc, 8 palettes
+ call FarCopyWRAM
+ ret
+; 4959f
+
+IcePathPalette: ; 4959f
+INCLUDE "gfx/tilesets/ice_path.pal"
+; 495df
+
+LoadHousePalette: ; 495df
+ ld a, BANK(wBGPals1)
+ ld de, wBGPals1
+ ld hl, HousePalette
+ ld bc, 8 palettes
+ call FarCopyWRAM
+ ret
+; 495ee
+
+HousePalette: ; 495ee
+INCLUDE "gfx/tilesets/house.pal"
+; 4962e
+
+LoadRadioTowerPalette: ; 4962e
+ ld a, BANK(wBGPals1)
+ ld de, wBGPals1
+ ld hl, RadioTowerPalette
+ ld bc, 8 palettes
+ call FarCopyWRAM
+ ret
+; 4963d
+
+RadioTowerPalette: ; 4963d
+INCLUDE "gfx/tilesets/radio_tower.pal"
+; 4967d
+
+MansionPalette1: ; 4967d
+INCLUDE "gfx/tilesets/mansion_1.pal"
+; 496c5
+
+LoadMansionPalette: ; 496c5
+ ld a, BANK(wBGPals1)
+ ld de, wBGPals1
+ ld hl, MansionPalette1
+ ld bc, 8 palettes
+ call FarCopyWRAM
+ ld a, BANK(wBGPals1)
+ ld de, wBGPals1 palette PAL_BG_YELLOW
+ ld hl, MansionPalette2
+ ld bc, 1 palettes
+ call FarCopyWRAM
+ ld a, BANK(wBGPals1)
+ ld de, wBGPals1 palette PAL_BG_WATER
+ ld hl, MansionPalette1 + 6 palettes
+ ld bc, 1 palettes
+ call FarCopyWRAM
+ ld a, BANK(wBGPals1)
+ ld de, wBGPals1 palette PAL_BG_ROOF
+ ld hl, MansionPalette1 + 8 palettes
+ ld bc, 1 palettes
+ call FarCopyWRAM
+ ret
+; 496fe
+
+MansionPalette2: ; 496fe
+INCLUDE "gfx/tilesets/mansion_2.pal"
+; 49706
diff --git a/engine/time.asm b/engine/time.asm
index 799a24f49..29c811810 100755
--- a/engine/time.asm
+++ b/engine/time.asm
@@ -133,16 +133,16 @@ endr
Special_SampleKenjiBreakCountdown: ; 11485
; Generate a random number between 3 and 6
call Random
- and 3
+ and %11
add 3
ld [wKenjiBreakTimer], a
ret
; 11490
StartBugContestTimer: ; 11490
- ld a, 20
+ ld a, BUG_CONTEST_MINUTES
ld [wBugContestMinsRemaining], a
- ld a, 0
+ ld a, BUG_CONTEST_SECONDS
ld [wBugContestSecsRemaining], a
call UpdateTime
ld hl, wBugContestStartTime
@@ -225,13 +225,13 @@ CheckUnusedTwoDayTimer: ; 1150c
ret
; 1151c
-; XXX
+; unused
ld hl, wDailyFlags
set 2, [hl]
ret
; 11522
-; XXX
+; unused
and a
ld hl, wDailyFlags
bit 2, [hl]
@@ -252,7 +252,7 @@ RestartLuckyNumberCountdown: ; 1152b
ld a, FRIDAY
sub c
jr z, .friday_saturday
- jr nc, .earlier ; should've done "ret nc"
+ jr nc, .earlier ; could have done "ret nc"
.friday_saturday
add 7
diff --git a/engine/time_capsule.asm b/engine/time_capsule.asm
index 577b2dce8..96f61833b 100755
--- a/engine/time_capsule.asm
+++ b/engine/time_capsule.asm
@@ -144,4 +144,4 @@ PlaceTradePartnerNamesAndParty: ; fb60d
jr .loop
; fb656
-INCLUDE "data/time_capsule/special_stats.asm"
+INCLUDE "data/pokemon/rby_base_special.asm"
diff --git a/engine/time_capsule_2.asm b/engine/time_capsule_2.asm
index 5da72e7c8..0378ed697 100644
--- a/engine/time_capsule_2.asm
+++ b/engine/time_capsule_2.asm
@@ -36,4 +36,4 @@ ConvertMon_1to2: ; fb908
; fb91c
-INCLUDE "data/time_capsule/mon_order.asm"
+INCLUDE "data/pokemon/rby_order.asm"
diff --git a/engine/timeofdaypals.asm b/engine/timeofdaypals.asm
index 0b1ea71a2..6dfa5657a 100644
--- a/engine/timeofdaypals.asm
+++ b/engine/timeofdaypals.asm
@@ -1,5 +1,5 @@
-Predef35: ; 8c000
-Predef36:
+DummyPredef35: ; 8c000
+DummyPredef36:
ret
UpdateTimeOfDayPal:: ; 8c001
@@ -47,8 +47,8 @@ _TimeOfDayPals:: ; 8c011
; save wram bank
ld a, [rSVBK]
ld b, a
-; wram bank 5
- ld a, $5
+
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
; push palette
@@ -78,8 +78,8 @@ _TimeOfDayPals:: ; 8c011
; save wram bank
ld a, [rSVBK]
ld d, a
-; wram bank 5
- ld a, 5
+
+ ld a, BANK(wOBPals1)
ld [rSVBK], a
; pop palette
@@ -119,7 +119,7 @@ _UpdateTimePals:: ; 8c070
ret
; 8c079
-FadeInPalettes:: ; 8c079
+Special_FadeInPalettes:: ; 8c079
ld c, $12
call GetTimePalFade
ld b, $4
@@ -127,7 +127,7 @@ FadeInPalettes:: ; 8c079
ret
; 8c084
-FadeOutPalettes:: ; 8c084
+Special_FadeOutPalettes:: ; 8c084
call FillWhiteBGColor
ld c, $9
call GetTimePalFade
@@ -173,7 +173,7 @@ Special_FadeBlackQuickly: ; 8c0b6
FillWhiteBGColor: ; 8c0c1
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, wBGPals1
diff --git a/engine/timeset.asm b/engine/timeset.asm
index f05e31ab5..67aa9973e 100755
--- a/engine/timeset.asm
+++ b/engine/timeset.asm
@@ -1,3 +1,6 @@
+TIMESET_UP_ARROW EQUS "\"♂\"" ; $ef
+TIMESET_DOWN_ARROW EQUS "\"♀\"" ; $f5
+
InitClock: ; 90672 (24:4672)
; Ask the player to set the time.
ld a, [hInMenu]
@@ -397,11 +400,11 @@ OakText_ResponseToSetTime: ; 0x908b8
; 0x908fb
TimeSetBackgroundGFX: ; 908fb
-INCBIN "gfx/timeset/background.1bpp"
+INCBIN "gfx/new_game/timeset_bg.1bpp"
TimeSetUpArrowGFX: ; 90903
-INCBIN "gfx/timeset/up_arrow.1bpp"
+INCBIN "gfx/new_game/up_arrow.1bpp"
TimeSetDownArrowGFX: ; 9090b
-INCBIN "gfx/timeset/down_arrow.1bpp"
+INCBIN "gfx/new_game/down_arrow.1bpp"
; 90913
Special_SetDayOfWeek: ; 90913
@@ -410,11 +413,11 @@ Special_SetDayOfWeek: ; 90913
ld a, $1
ld [hInMenu], a
ld de, TimeSetUpArrowGFX
- ld hl, vTiles1 tile $6f
+ ld hl, vTiles0 tile TIMESET_UP_ARROW
lb bc, BANK(TimeSetUpArrowGFX), 1
call Request1bpp
ld de, TimeSetDownArrowGFX
- ld hl, vTiles1 tile $75
+ ld hl, vTiles0 tile TIMESET_DOWN_ARROW
lb bc, BANK(TimeSetDownArrowGFX), 1
call Request1bpp
xor a
@@ -431,9 +434,9 @@ Special_SetDayOfWeek: ; 90913
ld c, 9
call TextBox
hlcoord 14, 3
- ld [hl], "♂" ; gets overwritten with special up arrow
+ ld [hl], TIMESET_UP_ARROW
hlcoord 14, 6
- ld [hl], "♀" ; gets overwritten with special down arrow
+ ld [hl], TIMESET_DOWN_ARROW
hlcoord 10, 5
call .PlaceWeekdayString
call ApplyTilemap
diff --git a/engine/title.asm b/engine/title.asm
index 2380cfedf..55ba145bf 100644
--- a/engine/title.asm
+++ b/engine/title.asm
@@ -139,7 +139,7 @@ _TitleScreen: ; 10ed67
ld a, [rSVBK]
push af
; WRAM bank 5
- ld a, 5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
; Update palette colors
@@ -162,13 +162,13 @@ _TitleScreen: ; 10ed67
ld a, [rSVBK]
push af
- ld a, 5 ; BANK(LYOverrides)
+ ld a, BANK(LYOverrides)
ld [rSVBK], a
; Make alternating lines come in from opposite sides
-; ( This part is actually totally pointless, you can't
-; see anything until these values are overwritten! )
+; (This part is actually totally pointless, you can't
+; see anything until these values are overwritten!)
ld b, 80 / 2 ; alternate for 80 lines
ld hl, LYOverrides
@@ -237,11 +237,11 @@ SuicuneFrameIterator: ; 10eea7
inc [hl]
; Only do this once every eight frames
- and (1 << 3) - 1
+ and %111
ret nz
ld a, c
- and 3 << 3
+ and %11000
sla a
swap a
ld e, a
@@ -323,7 +323,7 @@ DrawTitleGraphic: ; 10eeef
; 10ef06
InitializeBackground: ; 10ef06
- ld hl, Sprites
+ ld hl, Sprite01
ld d, -$22
ld e, $0
ld c, 5
@@ -344,17 +344,17 @@ InitializeBackground: ; 10ef06
ld b, $40
.loop2
ld a, d
- ld [hli], a
+ ld [hli], a ; y
ld a, b
- ld [hli], a
+ ld [hli], a ; x
add $8
ld b, a
ld a, e
- ld [hli], a
+ ld [hli], a ; tile id
inc e
inc e
- ld a, $80
- ld [hli], a
+ ld a, 0 | PRIORITY
+ ld [hli], a ; attributes
dec c
jr nz, .loop2
ret
@@ -366,9 +366,9 @@ AnimateTitleCrystal: ; 10ef32
; Stop at y=6
; y is really from the bottom of the sprite, which is two tiles high
- ld hl, Sprites
+ ld hl, Sprite01YCoord
ld a, [hl]
- cp 6 + $10
+ cp 6 + 2 * TILE_WIDTH
ret z
; Move all 30 parts of the crystal down by 2
@@ -376,10 +376,10 @@ AnimateTitleCrystal: ; 10ef32
.loop
ld a, [hl]
add 2
- ld [hli], a
- inc hl
- inc hl
+ ld [hli], a ; y
+rept SPRITEOAMSTRUCT_LENGTH +- 1
inc hl
+endr
dec c
jr nz, .loop
@@ -399,4 +399,4 @@ INCBIN "gfx/title/crystal.2bpp.lz"
; 10fede
TitleScreenPalettes:
-INCLUDE "data/palettes/title.pal"
+INCLUDE "gfx/title/title.pal"
diff --git a/engine/tmhm.asm b/engine/tmhm.asm
index 6a9c76f00..1cdbe1fff 100755
--- a/engine/tmhm.asm
+++ b/engine/tmhm.asm
@@ -23,7 +23,7 @@ CanLearnTMHMMove: ; 11639
ld b, CHECK_FLAG
push de
ld d, 0
- predef FlagPredef
+ predef SmallFarFlagAction
pop de
ret
diff --git a/engine/tmhm2.asm b/engine/tmhm2.asm
index c111fa7f9..e000ef6ba 100755
--- a/engine/tmhm2.asm
+++ b/engine/tmhm2.asm
@@ -146,7 +146,7 @@ TeachTMHM: ; 2c867
and a
jr z, .nope
- farcall TrainerRankings_TMsHMsTaught
+ farcall StubbedTrainerRankings_TMsHMsTaught
ld a, [CurItem]
call IsHM
ret c
@@ -447,8 +447,7 @@ TMHMPocket_GetCurrentLineCoord: ; 2ca86 (b:4a86)
ret
; 2ca95 (b:4a95)
-Function2ca95: ; 2ca95
-; unreferenced
+Unreferenced_Function2ca95: ; 2ca95
pop hl
ld bc, 3
add hl, bc
@@ -499,8 +498,7 @@ TMHM_PlaySFX_ReadText2: ; 2cad6 (b:4ad6)
ret
; 2cadf (b:4adf)
-Function2cadf: ; 2cadf
-; unreferenced
+Unreferenced_Function2cadf: ; 2cadf
call ConvertCurItemIntoCurTMHM
call .CheckHaveRoomForTMHM
ld hl, .NoRoomText
diff --git a/engine/trade_animation.asm b/engine/trade_animation.asm
index d5b97d563..d662a7894 100755
--- a/engine/trade_animation.asm
+++ b/engine/trade_animation.asm
@@ -1,3 +1,14 @@
+TRADEANIM_RIGHT_ARROW EQU $ed
+TRADEANIM_LEFT_ARROW EQU $ee
+
+; TradeAnim_TubeAnimJumptable.Jumptable indexes
+ const_def
+ const TRADEANIMSTATE_0 ; 0
+ const TRADEANIMSTATE_1 ; 1
+ const TRADEANIMSTATE_2 ; 2
+ const TRADEANIMSTATE_3 ; 3
+TRADEANIMJUMPTABLE_LENGTH EQU const_value
+
TradeAnimation: ; 28f24
xor a
ld [wcf66], a
@@ -165,13 +176,13 @@ RunTradeAnimScript: ; 28fa1
ld de, vTiles2 tile $31
call Decompress
ld hl, TradeArrowGFX
- ld de, vTiles1 tile $6d
- ld bc, $10
+ ld de, vTiles0 tile TRADEANIM_RIGHT_ARROW
+ ld bc, 1 tiles
ld a, BANK(TradeArrowGFX)
call FarCopyBytes
- ld hl, TradeArrowGFX + $10
- ld de, vTiles1 tile $6e
- ld bc, $10
+ ld hl, TradeArrowGFX + 1 tiles
+ ld de, vTiles0 tile TRADEANIM_LEFT_ARROW
+ ld bc, 1 tiles
ld a, BANK(TradeArrowGFX)
call FarCopyBytes
xor a
@@ -317,7 +328,7 @@ TradeAnim_End: ; 29123
; 29129
TradeAnim_TubeToOT1: ; 29129
- ld a, $ed ; >>>>>>>>
+ ld a, TRADEANIM_RIGHT_ARROW
call TradeAnim_PlaceTrademonStatsOnTubeAnim
ld a, [wLinkTradeSendmonSpecies]
ld [wd265], a
@@ -327,11 +338,11 @@ TradeAnim_TubeToOT1: ; 29129
jr TradeAnim_InitTubeAnim
TradeAnim_TubeToPlayer1: ; 2913c
- ld a, $ee ; <<<<<<<<
+ ld a, TRADEANIM_LEFT_ARROW
call TradeAnim_PlaceTrademonStatsOnTubeAnim
ld a, [wLinkTradeGetmonSpecies]
ld [wd265], a
- ld a, $2
+ ld a, TRADEANIMSTATE_2
depixel 9, 18, 4, 4
ld b, $4
TradeAnim_InitTubeAnim: ; 2914e
@@ -387,8 +398,8 @@ TradeAnim_InitTubeAnim: ; 2914e
call DmgToCgbObjPal0
call TradeAnim_IncrementJumptableIndex
- ld a, $5c
- ld [wcf64], a
+ ld a, 92
+ ld [wFrameCounter], a
ret
; 291af
@@ -400,7 +411,7 @@ TradeAnim_TubeToOT2: ; 291af
ld [hSCX], a
cp $50
ret nz
- ld a, $1
+ ld a, TRADEANIMSTATE_1
call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex
ret
@@ -414,7 +425,7 @@ TradeAnim_TubeToOT3: ; 291c4
ld [hSCX], a
cp $a0
ret nz
- ld a, $2
+ ld a, TRADEANIMSTATE_2
call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex
ret
@@ -440,7 +451,7 @@ TradeAnim_TubeToPlayer3: ; 291e8
ld [hSCX], a
cp $b0
ret nz
- ld a, $1
+ ld a, TRADEANIMSTATE_1
call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex
ret
@@ -454,7 +465,7 @@ TradeAnim_TubeToPlayer4: ; 291fd
ld [hSCX], a
cp $60
ret nz
- xor a
+ xor a ; TRADEANIMSTATE_0
call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex
ret
@@ -475,8 +486,8 @@ TradeAnim_TubeToPlayer5: ; 29211
TradeAnim_TubeToOT6:
TradeAnim_TubeToPlayer6: ; 29220
- ld a, $80
- ld [wcf64], a
+ ld a, 128
+ ld [wFrameCounter], a
call TradeAnim_IncrementJumptableIndex
ret
@@ -511,7 +522,7 @@ TradeAnim_TubeToOT7:
TradeAnim_TubeToPlayer2:
TradeAnim_TubeToPlayer7: ; 2925d
call TradeAnim_FlashBGPals
- ld hl, wcf64
+ ld hl, wFrameCounter
ld a, [hl]
and a
jr z, .done
@@ -541,7 +552,7 @@ TradeAnim_GetTrademonSFX: ; 29277
; 29281
TradeAnim_TubeAnimJumptable: ; 29281
- and 3
+ maskbits TRADEANIMJUMPTABLE_LENGTH
ld e, a
ld d, 0
ld hl, .Jumptable
@@ -554,6 +565,7 @@ TradeAnim_TubeAnimJumptable: ; 29281
; 2928f
.Jumptable: ; 2928f
+; entries correspond to TRADEANIMSTATE_* constants
dw .Zero
dw .One
dw .Two
@@ -835,7 +847,7 @@ TradeAnim_ShowGivemonData: ; 2942e
jr c, .skip_cry
ld e, c
ld d, b
- call PlayCryHeader
+ call PlayCry
.skip_cry
call TradeAnim_AdvanceScriptPointer
@@ -1114,8 +1126,8 @@ TradeAnim_RockingBall: ; 2961b
ld a, SPRITE_ANIM_INDEX_TRADE_POKE_BALL
call _InitSpriteAnimStruct
call TradeAnim_AdvanceScriptPointer
- ld a, $20
- ld [wcf64], a
+ ld a, 32
+ ld [wFrameCounter], a
ret
; 2962c
@@ -1131,8 +1143,8 @@ TradeAnim_DropBall: ; 2962c
add hl, bc
ld [hl], $dc
call TradeAnim_AdvanceScriptPointer
- ld a, $38
- ld [wcf64], a
+ ld a, 56
+ ld [wFrameCounter], a
ret
; 29649
@@ -1142,8 +1154,8 @@ TradeAnim_Poof: ; 29649
ld a, SPRITE_ANIM_INDEX_TRADE_POOF
call _InitSpriteAnimStruct
call TradeAnim_AdvanceScriptPointer
- ld a, $10
- ld [wcf64], a
+ ld a, 16
+ ld [wFrameCounter], a
ld de, SFX_BALL_POOF
call PlaySFX
ret
@@ -1157,8 +1169,8 @@ TradeAnim_BulgeThroughTube: ; 29660
ld a, SPRITE_ANIM_INDEX_TRADE_TUBE_BULGE
call _InitSpriteAnimStruct
call TradeAnim_AdvanceScriptPointer
- ld a, $40
- ld [wcf64], a
+ ld a, 64
+ ld [wFrameCounter], a
ret
; 29676
@@ -1500,15 +1512,15 @@ LoadTradeBallAndCableGFX: ; 2982b
call DelayFrame
ld de, TradeBallGFX
ld hl, vTiles0 tile $62
- lb bc, BANK(TradeBallGFX), $6
+ lb bc, BANK(TradeBallGFX), 6
call Request2bpp
ld de, TradePoofGFX
ld hl, vTiles0 tile $68
- lb bc, BANK(TradePoofGFX), $c
+ lb bc, BANK(TradePoofGFX), 12
call Request2bpp
ld de, TradeCableGFX
ld hl, vTiles0 tile $74
- lb bc, BANK(TradeCableGFX), $4
+ lb bc, BANK(TradeCableGFX), 4
call Request2bpp
xor a
ld hl, wSpriteAnimDict
@@ -1524,7 +1536,7 @@ LoadTradeBubbleGFX: ; 2985a
callfar LoadMenuMonIcon
ld de, TradeBubbleGFX
ld hl, vTiles0 tile $72
- lb bc, BANK(TradeBubbleGFX), $4
+ lb bc, BANK(TradeBubbleGFX), 4
call Request2bpp
xor a
ld hl, wSpriteAnimDict
@@ -1535,7 +1547,7 @@ LoadTradeBubbleGFX: ; 2985a
; 29879
TradeAnim_WaitAnim: ; 29879
- ld hl, wcf64
+ ld hl, wFrameCounter
ld a, [hl]
and a
jr z, .done
@@ -1549,7 +1561,7 @@ TradeAnim_WaitAnim: ; 29879
; 29886
TradeAnim_WaitAnim2: ; 29886
- ld hl, wcf64
+ ld hl, wFrameCounter
ld a, [hl]
and a
jr z, .done
@@ -1563,8 +1575,8 @@ TradeAnim_WaitAnim2: ; 29886
; 29893
-DebugTrade: ; 29893
-; This function is unreferenced.
+Unreferenced_DebugTrade: ; 29893
+; This function is not referenced.
; It was meant for use in Japanese versions, so the
; constant used for copy length was changed by accident.
@@ -1573,7 +1585,7 @@ DebugTrade: ; 29893
ld a, [hli]
ld [wPlayerTrademonSpecies], a
ld de, wPlayerTrademonSenderName
- ld c, 11 + 2 ; jp: 6 + 2
+ ld c, NAME_LENGTH + 2 ; JP: NAME_LENGTH_JAPANESE + 2
.loop1
ld a, [hli]
ld [de], a
@@ -1584,7 +1596,7 @@ DebugTrade: ; 29893
ld a, [hli]
ld [wOTTrademonSpecies], a
ld de, wOTTrademonSenderName
- ld c, 11 + 2 ; jp: 6 + 2
+ ld c, NAME_LENGTH + 2 ; JP: NAME_LENGTH_JAPANESE + 2
.loop2
ld a, [hli]
ld [de], a
@@ -1595,9 +1607,15 @@ DebugTrade: ; 29893
; 298b5
+debugtrade: MACRO
+; species, ot name, ot id (?)
+ db \1, \2
+ dw \3
+ENDM
+
.DebugTradeData: ; 298b5
- db VENUSAUR, "ゲーフり@@", $23, $01 ; GAME FREAK
- db CHARIZARD, "クりーチャ@", $56, $04 ; Creatures Inc.
+ debugtrade VENUSAUR, "ゲーフり@@", $0123 ; GAME FREAK
+ debugtrade CHARIZARD, "クりーチャ@", $0456 ; Creatures Inc.
; 298c7
diff --git a/engine/trainer_card.asm b/engine/trainer_card.asm
index 87cab0103..6d59660f7 100755
--- a/engine/trainer_card.asm
+++ b/engine/trainer_card.asm
@@ -1,3 +1,13 @@
+; TrainerCard.Jumptable indexes
+ const_def
+ const TRAINERCARDSTATE_PAGE1_LOADGFX ; 0
+ const TRAINERCARDSTATE_PAGE1_JOYPAD ; 1
+ const TRAINERCARDSTATE_PAGE2_LOADGFX ; 2
+ const TRAINERCARDSTATE_PAGE2_JOYPAD ; 3
+ const TRAINERCARDSTATE_PAGE3_LOADGFX ; 4
+ const TRAINERCARDSTATE_PAGE3_JOYPAD ; 5
+ const TRAINERCARDSTATE_QUIT ; 6
+
TrainerCard: ; 25105
ld a, [VramState]
push af
@@ -6,7 +16,7 @@ TrainerCard: ; 25105
ld hl, Options
ld a, [hl]
push af
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
call .InitRAM
.loop
call UpdateTime
@@ -61,17 +71,18 @@ TrainerCard: ; 25105
call SetPalettes
call WaitBGMap
ld hl, wJumptableIndex
- xor a
- ld [hli], a
- ld [hli], a
- ld [hli], a
- ld [hl], a
+ xor a ; TRAINERCARDSTATE_PAGE1_LOADGFX
+ ld [hli], a ; wJumptableIndex
+ ld [hli], a ; wTrainerCardBadgeFrameCounter
+ ld [hli], a ; wTrainerCardBadgeTileID
+ ld [hl], a ; wTrainerCardBadgeAttributes
ret
.RunJumptable: ; 2518e (9:518e)
jumptable .Jumptable, wJumptableIndex
.Jumptable: ; 2519d (9:519d)
+; entries correspond to TRAINERCARDSTATE_* constants
dw TrainerCard_Page1_LoadGFX
dw TrainerCard_Page1_Joypad
dw TrainerCard_Page2_LoadGFX
@@ -113,16 +124,15 @@ TrainerCard_Page1_Joypad: ; 251d7 (9:51d7)
ret
.pressed_right_a
- ld a, $2
+ ld a, TRAINERCARDSTATE_PAGE2_LOADGFX
ld [wJumptableIndex], a
ret
-.KantoCheck:
-; unreferenced
+.Unreferenced_KantoCheck:
ld a, [wKantoBadges]
and a
ret z
- ld a, $4
+ ld a, TRAINERCARDSTATE_PAGE3_LOADGFX
ld [wJumptableIndex], a
ret
@@ -136,11 +146,11 @@ TrainerCard_Page2_LoadGFX: ; 251f4 (9:51f4)
call WaitBGMap
ld de, LeaderGFX
ld hl, vTiles2 tile $29
- lb bc, BANK(LeaderGFX), $56
+ lb bc, BANK(LeaderGFX), 86
call Request2bpp
ld de, BadgeGFX
ld hl, vTiles0 tile $00
- lb bc, BANK(BadgeGFX), $2c
+ lb bc, BANK(BadgeGFX), 44
call Request2bpp
call TrainerCard_Page2_3_InitObjectsAndStrings
call TrainerCard_IncrementJumptable
@@ -159,21 +169,20 @@ TrainerCard_Page2_Joypad: ; 25221 (9:5221)
ret
.d_left
- ld a, $0
+ ld a, TRAINERCARDSTATE_PAGE1_LOADGFX
ld [wJumptableIndex], a
ret
-.KantoCheck:
-; unreferenced
+.Unreferenced_KantoCheck:
ld a, [wKantoBadges]
and a
ret z
- ld a, $4
+ ld a, TRAINERCARDSTATE_PAGE3_LOADGFX
ld [wJumptableIndex], a
ret
.Quit:
- ld a, $6
+ ld a, TRAINERCARDSTATE_QUIT
ld [wJumptableIndex], a
ret
@@ -185,11 +194,11 @@ TrainerCard_Page3_LoadGFX: ; 2524c (9:524c)
call WaitBGMap
ld de, LeaderGFX2
ld hl, vTiles2 tile $29
- lb bc, BANK(LeaderGFX2), $56
+ lb bc, BANK(LeaderGFX2), 86
call Request2bpp
ld de, BadgeGFX2
ld hl, vTiles0 tile $00
- lb bc, BANK(BadgeGFX2), $2c
+ lb bc, BANK(BadgeGFX2), 44
call Request2bpp
call TrainerCard_Page2_3_InitObjectsAndStrings
call TrainerCard_IncrementJumptable
@@ -208,12 +217,12 @@ TrainerCard_Page3_Joypad: ; 25279 (9:5279)
ret
.left
- ld a, $2
+ ld a, TRAINERCARDSTATE_PAGE2_LOADGFX
ld [wJumptableIndex], a
ret
.right
- ld a, $0
+ ld a, TRAINERCARDSTATE_PAGE1_LOADGFX
ld [wJumptableIndex], a
ret
@@ -256,10 +265,10 @@ TrainerCard_PrintTopHalfOfCard: ; 25299 (9:5299)
next "MONEY@"
.ID_No: ; 252f9
- db $27, $28, $ff ; ID NO
+ db $27, $28, -1 ; ID NO
.HorizontalDivider: ; 252fc
- db $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $26, $ff ; ____________>
+ db $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $26, -1 ; ____________>
; 2530a
TrainerCard_Page1_PrintDexCaught_GameTime: ; 2530a (9:530a)
@@ -281,7 +290,7 @@ TrainerCard_Page1_PrintDexCaught_GameTime: ; 2530a (9:530a)
ld de, .StatusTilemap
call TrainerCardSetup_PlaceTilemapString
ld a, [wStatusFlags]
- bit 0, a
+ bit 0, a ; ENGINE_POKEDEX
ret nz
hlcoord 1, 9
lb bc, 2, 17
@@ -296,7 +305,7 @@ TrainerCard_Page1_PrintDexCaught_GameTime: ; 2530a (9:530a)
db " BADGES▶@"
.StatusTilemap: ; 25366
- db $29, $2a, $2b, $2c, $2d, $ff
+ db $29, $2a, $2b, $2c, $2d, -1
; 2536c
TrainerCard_Page2_3_InitObjectsAndStrings: ; 2536c (9:536c)
@@ -324,7 +333,7 @@ endr
dec c
jr nz, .loop2
xor a
- ld [wcf64], a
+ ld [wTrainerCardBadgeFrameCounter], a
ld hl, TrainerCard_JohtoBadgesOAM
call TrainerCard_Page2_3_OAMUpdate
ret
@@ -332,20 +341,20 @@ endr
; 253a2 (9:53a2)
.BadgesTilemap: ; 253a2
- db $79, $7a, $7b, $7c, $7d, $ff ; "BADGES"
+ db $79, $7a, $7b, $7c, $7d, -1 ; "BADGES"
; 253a8
TrainerCardSetup_PlaceTilemapString: ; 253a8 (9:53a8)
.loop
ld a, [de]
- cp $ff
+ cp -1
ret z
ld [hli], a
inc de
jr .loop
TrainerCard_InitBorder: ; 253b0 (9:53b0)
- ld e, 20
+ ld e, SCREEN_WIDTH
.loop1
ld a, $23
ld [hli], a
@@ -354,7 +363,7 @@ TrainerCard_InitBorder: ; 253b0 (9:53b0)
ld a, $23
ld [hli], a
- ld e, 17
+ ld e, SCREEN_HEIGHT - 1
ld a, " "
.loop2
ld [hli], a
@@ -369,7 +378,7 @@ TrainerCard_InitBorder: ; 253b0 (9:53b0)
ld a, $23
ld [hli], a
- ld e, 18
+ ld e, SCREEN_HEIGHT
ld a, " "
.loop4
ld [hli], a
@@ -386,7 +395,7 @@ TrainerCard_InitBorder: ; 253b0 (9:53b0)
ld a, $24
ld [hli], a
- ld e, 17
+ ld e, SCREEN_HEIGHT - 1
ld a, " "
.loop5
ld [hli], a
@@ -394,7 +403,7 @@ TrainerCard_InitBorder: ; 253b0 (9:53b0)
jr nz, .loop5
ld a, $23
ld [hli], a
- ld e, 20
+ ld e, SCREEN_WIDTH
.loop6
ld a, $23
ld [hli], a
@@ -453,12 +462,12 @@ TrainerCard_Page1_PrintGameTime: ; 25415 (9:5415)
TrainerCard_Page2_3_AnimateBadges: ; 25438 (9:5438)
ld a, [hVBlankCounter]
- and $7
+ and %111
ret nz
- ld a, [wcf64]
+ ld a, [wTrainerCardBadgeFrameCounter]
inc a
- and $7
- ld [wcf64], a
+ and %111
+ ld [wTrainerCardBadgeFrameCounter], a
jr TrainerCard_Page2_3_OAMUpdate
TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448)
@@ -470,8 +479,8 @@ TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448)
ld d, a
ld a, [de]
ld c, a
- ld de, Sprites
- ld b, 8
+ ld de, Sprite01
+ ld b, NUM_JOHTO_BADGES
.loop
srl c
push bc
@@ -482,15 +491,15 @@ TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448)
ld a, [hli] ; x
ld c, a
ld a, [hli] ; pal
- ld [wcf66], a
- ld a, [wcf64]
+ ld [wTrainerCardBadgeAttributes], a
+ ld a, [wTrainerCardBadgeFrameCounter]
add l
ld l, a
ld a, 0
adc h
ld h, a
ld a, [hl]
- ld [wcf65], a
+ ld [wTrainerCardBadgeTileID], a
call .PrepOAM
pop hl
.skip_badge
@@ -502,8 +511,8 @@ TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448)
ret
.PrepOAM: ; 2547b (9:547b)
- ld a, [wcf65]
- and $80
+ ld a, [wTrainerCardBadgeTileID]
+ and 1 << 7
jr nz, .xflip
ld hl, .facing1
jr .loop2
@@ -512,27 +521,27 @@ TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448)
ld hl, .facing2
.loop2
ld a, [hli]
- cp $ff
+ cp -1
ret z
add b
- ld [de], a
+ ld [de], a ; y
inc de
ld a, [hli]
add c
- ld [de], a
+ ld [de], a ; x
inc de
- ld a, [wcf65]
- and $7f
+ ld a, [wTrainerCardBadgeTileID]
+ and $ff ^ (1 << 7)
add [hl]
- ld [de], a
+ ld [de], a ; tile id
inc hl
inc de
- ld a, [wcf66]
+ ld a, [wTrainerCardBadgeAttributes]
add [hl]
- ld [de], a
+ ld [de], a ; attributes
inc hl
inc de
jr .loop2
@@ -540,18 +549,17 @@ TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448)
; 254a7 (9:54a7)
.facing1 ; 254a7
- ; y, x, tile, OAM attributes
- db 0, 0, 0, 0
- db 0, 8, 1, 0
- db 8, 0, 2, 0
- db 8, 8, 3, 0
+ dsprite 0, 0, 0, 0, $00, 0
+ dsprite 0, 0, 1, 0, $01, 0
+ dsprite 1, 0, 0, 0, $02, 0
+ dsprite 1, 0, 1, 0, $03, 0
db -1
.facing2 ; 254b8
- db 0, 0, 1, X_FLIP
- db 0, 8, 0, X_FLIP
- db 8, 0, 3, X_FLIP
- db 8, 8, 2, X_FLIP
+ dsprite 0, 0, 0, 0, $01, 0 | X_FLIP
+ dsprite 0, 0, 1, 0, $00, 0 | X_FLIP
+ dsprite 1, 0, 0, 0, $03, 0 | X_FLIP
+ dsprite 1, 0, 1, 0, $02, 0 | X_FLIP
db -1
TrainerCard_JohtoBadgesOAM: ; 254c9
@@ -565,44 +573,44 @@ TrainerCard_JohtoBadgesOAM: ; 254c9
; Zephyrbadge
db $68, $18, 0
- db $00, $20, $24, $20 | $80
- db $00, $20, $24, $20 | $80
+ db $00, $20, $24, $20 | (1 << 7)
+ db $00, $20, $24, $20 | (1 << 7)
; Hivebadge
db $68, $38, 0
- db $04, $20, $24, $20 | $80
- db $04, $20, $24, $20 | $80
+ db $04, $20, $24, $20 | (1 << 7)
+ db $04, $20, $24, $20 | (1 << 7)
; Plainbadge
db $68, $58, 0
- db $08, $20, $24, $20 | $80
- db $08, $20, $24, $20 | $80
+ db $08, $20, $24, $20 | (1 << 7)
+ db $08, $20, $24, $20 | (1 << 7)
; Fogbadge
db $68, $78, 0
- db $0c, $20, $24, $20 | $80
- db $0c, $20, $24, $20 | $80
+ db $0c, $20, $24, $20 | (1 << 7)
+ db $0c, $20, $24, $20 | (1 << 7)
; Mineralbadge
db $80, $38, 0
- db $10, $20, $24, $20 | $80
- db $10, $20, $24, $20 | $80
+ db $10, $20, $24, $20 | (1 << 7)
+ db $10, $20, $24, $20 | (1 << 7)
; Stormbadge
db $80, $18, 0
- db $14, $20, $24, $20 | $80
- db $14, $20, $24, $20 | $80
+ db $14, $20, $24, $20 | (1 << 7)
+ db $14, $20, $24, $20 | (1 << 7)
; Glacierbadge
db $80, $58, 0
- db $18, $20, $24, $20 | $80
- db $18, $20, $24, $20 | $80
+ db $18, $20, $24, $20 | (1 << 7)
+ db $18, $20, $24, $20 | (1 << 7)
; Risingbadge
; X-flips on alternate cycles.
db $80, $78, 0
- db $1c, $20, $24, $20 | $80
- db $1c | $80, $20, $24, $20 | $80
+ db $1c, $20, $24, $20 | (1 << 7)
+ db $1c | (1 << 7), $20, $24, $20 | (1 << 7)
; 25523
CardStatusGFX: INCBIN "gfx/trainer_card/card_status.2bpp"
diff --git a/engine/types.asm b/engine/types.asm
index 375bfe434..931e98b92 100644
--- a/engine/types.asm
+++ b/engine/types.asm
@@ -35,7 +35,7 @@ PrintMonTypes: ; 5090d
ld [hl], a
inc bc
add hl, bc
- ld bc, 5
+ ld bc, NAME_LENGTH_JAPANESE - 1
jp ByteFill
; 5093a
@@ -91,11 +91,9 @@ GetTypeName: ; 50964
ld h, [hl]
ld l, a
ld de, StringBuffer1
- ld bc, 13
+ ld bc, MOVE_NAME_LENGTH
jp CopyBytes
; 5097b
-INCLUDE "data/type_names.asm"
-
-; 50a28
+INCLUDE "data/types/names.asm"
diff --git a/engine/unown_puzzle.asm b/engine/unown_puzzle.asm
index ee76f817c..36f6dacd2 100755
--- a/engine/unown_puzzle.asm
+++ b/engine/unown_puzzle.asm
@@ -157,7 +157,7 @@ PlaceStartCancelBoxBorder: ; e128d
ld a, $f3
ld [hli], a
ld bc, 10
- ld a, $ef
+ ld a, PUZZLE_VOID
call ByteFill
hlcoord 15, 16
ld a, $f3
@@ -218,7 +218,7 @@ UnownPuzzleJumptable: ; e12ca
ld a, [hl]
cp 1 puzcoord 0
ret c
- sub $6
+ sub 6
ld [hl], a
jr .done_joypad
@@ -235,7 +235,7 @@ UnownPuzzleJumptable: ; e12ca
ret z
cp 5 puzcoord 0
ret nc
- add $6
+ add 6
ld [hl], a
jr .done_joypad
@@ -549,51 +549,51 @@ RedrawUnownPuzzlePieces: ; e14d9
ld hl, .OAM_NotHoldingPiece
.load
- ld de, Sprites
+ ld de, Sprite01
.loop
ld a, [hli]
cp -1
ret z
add b
- ld [de], a
+ ld [de], a ; y
inc de
ld a, [hli]
add c
- ld [de], a
+ ld [de], a ; x
inc de
ld a, [wd002]
add [hl]
- ld [de], a
+ ld [de], a ; tile id
inc hl
inc de
ld a, [hli]
- ld [de], a
+ ld [de], a ; attributes
inc de
jr .loop
; e150f
.OAM_HoldingPiece: ; e150f
- dsprite -1, -4, -1, -4, $00, $00
- dsprite -1, -4, 0, -4, $01, $00
- dsprite -1, -4, 0, 4, $02, $00
- dsprite 0, -4, -1, -4, $0c, $00
- dsprite 0, -4, 0, -4, $0d, $00
- dsprite 0, -4, 0, 4, $0e, $00
- dsprite 0, 4, -1, -4, $18, $00
- dsprite 0, 4, 0, -4, $19, $00
- dsprite 0, 4, 0, 4, $1a, $00
+ dsprite -1, -4, -1, -4, $00, 0
+ dsprite -1, -4, 0, -4, $01, 0
+ dsprite -1, -4, 0, 4, $02, 0
+ dsprite 0, -4, -1, -4, $0c, 0
+ dsprite 0, -4, 0, -4, $0d, 0
+ dsprite 0, -4, 0, 4, $0e, 0
+ dsprite 0, 4, -1, -4, $18, 0
+ dsprite 0, 4, 0, -4, $19, 0
+ dsprite 0, 4, 0, 4, $1a, 0
db -1
.OAM_NotHoldingPiece: ; e1534
- dsprite -1, -4, -1, -4, $00, $00
- dsprite -1, -4, 0, -4, $01, $00
- dsprite -1, -4, 0, 4, $00, $20 ; xflip
- dsprite 0, -4, -1, -4, $02, $00
- dsprite 0, -4, 0, -4, $03, $00
- dsprite 0, -4, 0, 4, $02, $20 ; xflip
- dsprite 0, 4, -1, -4, $00, $40 ; yflip
- dsprite 0, 4, 0, -4, $01, $40 ; yflip
- dsprite 0, 4, 0, 4, $00, $60 ; xflip, yflip
+ dsprite -1, -4, -1, -4, $00, 0
+ dsprite -1, -4, 0, -4, $01, 0
+ dsprite -1, -4, 0, 4, $00, 0 | X_FLIP
+ dsprite 0, -4, -1, -4, $02, 0
+ dsprite 0, -4, 0, -4, $03, 0
+ dsprite 0, -4, 0, 4, $02, 0 | X_FLIP
+ dsprite 0, 4, -1, -4, $00, 0 | Y_FLIP
+ dsprite 0, 4, 0, -4, $01, 0 | Y_FLIP
+ dsprite 0, 4, 0, 4, $00, 0 | X_FLIP | Y_FLIP
db -1
UnownPuzzleCoordData: ; e1559
@@ -763,7 +763,7 @@ endr
; e16c7
UnownPuzzle_AddPuzzlePieceBorders: ; e16c7
- ld hl, GFXHeaders
+ ld hl, PuzzlePieceBorderData
ld a, 8
.loop
push af
@@ -819,7 +819,7 @@ endr
ret
; e1703
-GFXHeaders: ; e1703
+PuzzlePieceBorderData: ; e1703
dw .TileBordersGFX + 0 tiles, vTiles0 tile $00
dw .TileBordersGFX + 1 tiles, vTiles0 tile $01
dw .TileBordersGFX + 2 tiles, vTiles0 tile $02
@@ -835,7 +835,7 @@ INCBIN "gfx/unown_puzzle/tile_borders.2bpp"
LoadUnownPuzzlePiecesGFX: ; e17a3
ld a, [ScriptVar]
- and 3
+ maskbits NUM_UNOWN_PUZZLES
ld e, a
ld d, 0
ld hl, .LZPointers
@@ -851,6 +851,7 @@ LoadUnownPuzzlePiecesGFX: ; e17a3
; e17bd
.LZPointers: ; e17bd
+; entries correspond to UNOWNPUZZLE_* constants
dw KabutoPuzzleLZ
dw OmanytePuzzleLZ
dw AerodactylPuzzleLZ
diff --git a/engine/unused_title.asm b/engine/unused_title.asm
index f0b59b527..516fc902e 100644
--- a/engine/unused_title.asm
+++ b/engine/unused_title.asm
@@ -32,7 +32,7 @@ UnusedTitleScreen: ; 10c000
ld hl, UnusedTitleBG_Tilemap
debgcoord 0, 0
- ld bc, 32 * 32
+ ld bc, BG_MAP_WIDTH * BG_MAP_HEIGHT
.copy
ld a, 0
ld [rVBK], a
@@ -49,8 +49,8 @@ UnusedTitleScreen: ; 10c000
jr nz, .copy
ld hl, UnusedTitleFG_OAM
- ld de, Sprites
- ld bc, $a0
+ ld de, Sprite01
+ ld bc, SPRITEOAMSTRUCT_LENGTH * NUM_SPRITE_OAM_STRUCTS
call CopyBytes
call EnableLCD
@@ -63,7 +63,7 @@ UnusedTitleScreen: ; 10c000
ld a, [rSVBK]
push af
- ld a, $5
+ ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, UnusedTitleBG_Palettes
@@ -103,60 +103,12 @@ INCBIN "gfx/title/old_bg.2bpp"
; 10d0b1
UnusedTitleBG_Tilemap: ; 10d0b1
-; 32x32 (tile, attributes)
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $01,$00, $02,$01, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $03,$00, $04,$00, $05,$01, $06,$01, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $07,$05, $08,$05, $09,$05, $0a,$05, $0b,$00, $0c,$00, $0d,$00, $0e,$00, $0f,$01, $10,$01, $11,$01, $12,$01, $13,$05, $14,$05, $15,$05, $16,$05, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $17,$04, $18,$04, $19,$04, $1a,$04, $1b,$00, $1c,$00, $1d,$02, $1e,$02, $1f,$07, $20,$07, $21,$01, $22,$01, $23,$04, $24,$04, $25,$04, $26,$04, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $27,$04, $28,$04, $29,$04, $2a,$04, $2b,$00, $2c,$00, $2d,$03, $2e,$01, $2f,$01, $30,$01, $31,$01, $32,$01, $33,$04, $34,$04, $35,$04, $36,$04, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $37,$04, $38,$04, $39,$04, $3a,$04, $3b,$00, $3c,$00, $3d,$01, $00,$00, $00,$00, $3e,$07, $3f,$01, $40,$01, $41,$04, $42,$04, $43,$04, $44,$04, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $45,$04, $46,$04, $47,$04, $48,$04, $49,$00, $3c,$00, $4a,$01, $00,$00, $00,$00, $4b,$07, $3f,$01, $4c,$01, $4d,$06, $4e,$06, $4f,$06, $50,$06, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $51,$04, $52,$06, $53,$06, $54,$06, $55,$00, $3c,$00, $56,$01, $00,$00, $00,$00, $57,$07, $58,$01, $59,$01, $5a,$06, $5b,$06, $5c,$06, $5d,$06, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $5e,$06, $5f,$06, $60,$06, $61,$06, $62,$00, $63,$00, $64,$03, $65,$01, $66,$01, $67,$07, $68,$01, $69,$01, $26,$04, $6a,$06, $26,$04, $26,$04, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $6b,$00, $6c,$05, $6d,$05, $6e,$05, $6f,$00, $70,$02, $71,$02, $72,$01, $73,$00, $74,$02, $75,$01, $76,$01, $77,$05, $78,$05, $79,$05, $6b,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $7a,$00, $7b,$00, $7c,$00, $7d,$00, $0f,$01, $7e,$01, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $a2,$00, $80,$00, $81,$00, $82,$00, $83,$00, $84,$07, $85,$01, $86,$01, $87,$01, $88,$01, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $89,$00, $8a,$00, $8b,$00, $8c,$07, $8d,$01, $8e,$01, $8f,$01, $90,$01, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $91,$01, $92,$01, $93,$01, $94,$01, $95,$01, $00,$00, $00,$00, $00,$00, $96,$05, $97,$05, $98,$05, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $99,$05, $9a,$05, $9b,$05, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $9c,$05, $9d,$05, $9e,$05, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $9f,$05, $a0,$05, $a1,$05, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $6b,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
- db $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
+; 32x32 (alternating tiles and attributes)
+INCBIN "gfx/title/old_bg.tilemap"
; 10d8b1
UnusedTitleBG_Palettes: ; 10d8b1
-INCLUDE "data/palettes/unused_title/bg.pal"
-
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
-
- RGB 31, 31, 31
- RGB 20, 04, 20
- RGB 16, 08, 16
- RGB 24, 00, 24
-
-rept 54
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
-endr
+INCLUDE "gfx/title/old_bg.pal"
; 10dab1
UnusedTitleFG_GFX: ; 10dab1
@@ -164,27 +116,52 @@ INCBIN "gfx/title/old_fg.2bpp"
; 10eab1
UnusedTitleFG_Palettes: ; 10eab1
-INCLUDE "data/palettes/unused_title/ob.pal"
+INCLUDE "gfx/title/old_fg.pal"
; 10ecb1
UnusedTitleFG_OAM: ; 10ecb1
- db $18, $38, $00, $01, $18, $40, $02, $01, $18, $48, $04, $01, $18, $50, $06, $01
- db $18, $58, $08, $01, $18, $60, $0a, $01, $18, $68, $0c, $01, $18, $70, $0e, $01
-
- db $28, $38, $10, $00, $28, $40, $12, $00, $28, $48, $14, $00, $28, $50, $16, $00
- db $28, $58, $18, $00, $28, $60, $1a, $00, $28, $68, $1c, $00, $28, $70, $1e, $00
-
- db $38, $38, $20, $00, $38, $40, $22, $00, $38, $48, $24, $00, $38, $50, $26, $00
- db $38, $58, $28, $00, $38, $60, $2a, $00, $38, $68, $2c, $00, $38, $70, $2e, $00
-
- db $48, $38, $30, $02, $48, $40, $32, $02, $48, $48, $34, $02, $48, $50, $36, $02
- db $48, $58, $38, $02, $48, $60, $3a, $02, $48, $68, $3c, $02, $48, $70, $3e, $02
-
- db $58, $38, $40, $01, $58, $40, $42, $01, $58, $48, $44, $01, $58, $50, $46, $01
- db $58, $58, $48, $01, $58, $60, $4a, $01, $58, $68, $4c, $01, $58, $70, $4e, $01
+ dsprite 3, 0, 7, 0, $00, 1
+ dsprite 3, 0, 8, 0, $02, 1
+ dsprite 3, 0, 9, 0, $04, 1
+ dsprite 3, 0, 10, 0, $06, 1
+ dsprite 3, 0, 11, 0, $08, 1
+ dsprite 3, 0, 12, 0, $0a, 1
+ dsprite 3, 0, 13, 0, $0c, 1
+ dsprite 3, 0, 14, 0, $0e, 1
+ dsprite 5, 0, 7, 0, $10, 0
+ dsprite 5, 0, 8, 0, $12, 0
+ dsprite 5, 0, 9, 0, $14, 0
+ dsprite 5, 0, 10, 0, $16, 0
+ dsprite 5, 0, 11, 0, $18, 0
+ dsprite 5, 0, 12, 0, $1a, 0
+ dsprite 5, 0, 13, 0, $1c, 0
+ dsprite 5, 0, 14, 0, $1e, 0
+ dsprite 7, 0, 7, 0, $20, 0
+ dsprite 7, 0, 8, 0, $22, 0
+ dsprite 7, 0, 9, 0, $24, 0
+ dsprite 7, 0, 10, 0, $26, 0
+ dsprite 7, 0, 11, 0, $28, 0
+ dsprite 7, 0, 12, 0, $2a, 0
+ dsprite 7, 0, 13, 0, $2c, 0
+ dsprite 7, 0, 14, 0, $2e, 0
+ dsprite 9, 0, 7, 0, $30, 2
+ dsprite 9, 0, 8, 0, $32, 2
+ dsprite 9, 0, 9, 0, $34, 2
+ dsprite 9, 0, 10, 0, $36, 2
+ dsprite 9, 0, 11, 0, $38, 2
+ dsprite 9, 0, 12, 0, $3a, 2
+ dsprite 9, 0, 13, 0, $3c, 2
+ dsprite 9, 0, 14, 0, $3e, 2
+ dsprite 11, 0, 7, 0, $40, 1
+ dsprite 11, 0, 8, 0, $42, 1
+ dsprite 11, 0, 9, 0, $44, 1
+ dsprite 11, 0, 10, 0, $46, 1
+ dsprite 11, 0, 11, 0, $48, 1
+ dsprite 11, 0, 12, 0, $4a, 1
+ dsprite 11, 0, 13, 0, $4c, 1
+ dsprite 11, 0, 14, 0, $4e, 1
; 10ed51
-
Function10ed51: ; 10ed51
call _TitleScreen
.loop
diff --git a/engine/variables.asm b/engine/variables.asm
index 1b418ea3c..56c49f085 100755
--- a/engine/variables.asm
+++ b/engine/variables.asm
@@ -35,9 +35,10 @@ _GetVarAction:: ; 80648 (20:4648)
; 80671 (20:4671)
.VarActionTable: ; 80671
-; RETVAR_STRBUF2: copy [de] to StringBuffer2
-; RETVAR_ADDR_DE: return address in de
-; RETVAR_EXECUTE: call function
+; entries correspond to VAR_* constants
+ ; RETVAR_STRBUF2: copy [de] to StringBuffer2
+ ; RETVAR_ADDR_DE: return address in de
+ ; RETVAR_EXECUTE: call function
dwb StringBuffer2, RETVAR_STRBUF2
dwb PartyCount, RETVAR_STRBUF2
dwb .BattleResult, RETVAR_EXECUTE
@@ -125,7 +126,7 @@ _GetVarAction:: ; 80648 (20:4648)
ret z
inc b
ld a, b
- cp 26
+ cp NUM_UNOWN
jr c, .loop
ret
; 80715
diff --git a/engine/warp_connection.asm b/engine/warp_connection.asm
index a0784caac..e15809c04 100755
--- a/engine/warp_connection.asm
+++ b/engine/warp_connection.asm
@@ -11,7 +11,7 @@ InitCommandQueue: ; 1045c4
farcall ClearCmdQueue
ld a, MAPCALLBACK_CMDQUEUE
call RunMapCallback
- call GetMapHeaderTimeOfDayNybble
+ call GetMapTimeOfDay
ld [wMapTimeOfDay], a
ret
@@ -174,8 +174,11 @@ LoadWarpData: ; 1046c6
call GetAnyMapEnvironment
call CheckIndoorMap
ret nz
+
+; MOUNT_MOON_SQUARE and TIN_TOWER_ROOF are outdoor maps within indoor maps.
+; Dig and Escape Rope should not take you to them.
ld a, [wPrevMapGroup]
- cp GROUP_MOUNT_MOON_SQUARE
+ cp GROUP_MOUNT_MOON_SQUARE ; GROUP_TIN_TOWER_ROOF
jr nz, .not_mt_moon_or_tin_tower
ld a, [wPrevMapNumber]
cp MAP_MOUNT_MOON_SQUARE
@@ -183,6 +186,7 @@ LoadWarpData: ; 1046c6
cp MAP_TIN_TOWER_ROOF
ret z
.not_mt_moon_or_tin_tower
+
ld a, [wPrevWarp]
ld [wDigWarpNumber], a
ld a, [wPrevMapGroup]
@@ -206,6 +210,8 @@ LoadWarpData: ; 1046c6
ld b, a
ld a, [wNextMapNumber]
ld c, a
+
+; Respawn in Pokémon Centers.
call GetAnyMapTileset
ld a, c
cp TILESET_POKECENTER
@@ -214,6 +220,7 @@ LoadWarpData: ; 1046c6
jr z, .pokecenter_pokecom
ret
.pokecenter_pokecom
+
ld a, [wPrevMapGroup]
ld [wLastSpawnMapGroup], a
ld a, [wPrevMapNumber]
@@ -254,7 +261,7 @@ LoadMapTimeOfDay: ; 104750
pop af
ld [rVBK], a
- ld a, "<BLACK>"
+ ld a, "■"
ld bc, vBGMap1 - vBGMap0
hlbgcoord 0, 0
call ByteFill
@@ -298,12 +305,12 @@ LoadGraphics: ; 1047cf
ld [hMapAnims], a
xor a
ld [hTileAnimFrame], a
- farcall RefreshSprites
+ farcall Special_RefreshSprites
call LoadFontsExtra
farcall LoadOverworldFont
ret
-LoadMapPalettes: ; 1047eb
+Special_LoadMapPalettes: ; 1047eb
ld b, SCGB_MAPPALS
jp GetSGBLayout
; 1047f0
diff --git a/engine/wildmons.asm b/engine/wildmons.asm
index dc62093b8..50d4ea250 100755
--- a/engine/wildmons.asm
+++ b/engine/wildmons.asm
@@ -212,7 +212,7 @@ TryWildEncounter:: ; 2a0e7
GetMapEncounterRate: ; 2a111
ld hl, wMornEncounterRate
call CheckOnWater
- ld a, 3
+ ld a, wWaterEncounterRate - wMornEncounterRate
jr z, .ok
ld a, [TimeOfDay]
.ok
@@ -508,7 +508,7 @@ LookUpWildmonsForMapDE: ; 2a288
; 2a2a0
-InitRoamMons: ; 2a2a0
+Special_InitRoamMons: ; 2a2a0
; initialize wRoamMon structs
; species
@@ -571,7 +571,7 @@ CheckEncounterRoamMon: ; 2a2ce
ld hl, wRoamMon1MapGroup
ld c, a
ld b, 0
- ld a, 7 ; length of the RoamMon struct
+ ld a, 7 ; length of the roam_struct
call AddNTimes
ld a, d
cp [hl]
@@ -678,9 +678,9 @@ UpdateRoamMons: ; 2a30d
ld l, e
; Choose which map to warp to.
call Random
- and $1f ; 1/8n chance it moves to a completely random map, where n is the number of roaming connections from the current map.
+ and %00011111 ; 1/8n chance it moves to a completely random map, where n is the number of roaming connections from the current map.
jr z, JumpRoamMon
- and 3
+ and %11
cp [hl]
jr nc, .update_loop ; invalid index, try again
inc hl
@@ -739,11 +739,11 @@ JumpRoamMons: ; 2a394
JumpRoamMon: ; 2a3cd
.loop
ld hl, RoamMaps
-.innerloop1 ; This loop is completely unnecessary.
- call Random ; Choose a random number
- and $f ; Take the lower nybble only. This gives a number between 0 and 15.
- cp $10 ; If the number is greater than or equal to 16, loop back and try again.
- jr nc, .innerloop1 ; I'm sure you can guess why this check is bogus.
+.innerloop1 ; This loop happens to be unnecessary.
+ call Random ; Choose a random number.
+ maskbits NUM_ROAMMON_MAPS ; Mask the number to limit it between 0 and 15.
+ cp NUM_ROAMMON_MAPS ; If the number is not less than 16, try again.
+ jr nc, .innerloop1 ; I'm sure you can guess why this check is bogus.
inc a
ld b, a
.innerloop2 ; Loop to get hl to the address of the chosen roam map.
@@ -804,7 +804,7 @@ ValidateTempWildMonSpecies: ; 2a4a0
; Finds a rare wild Pokemon in the route of the trainer calling, then checks if it's been Seen already.
; The trainer will then tell you about the Pokemon if you haven't seen it.
-RandomUnseenWildMon: ; 2a4ab
+Special_RandomUnseenWildMon: ; 2a4ab
farcall GetCallerLocation
ld d, b
ld e, c
@@ -821,11 +821,11 @@ RandomUnseenWildMon: ; 2a4ab
ld bc, 5 + 4 * 2 ; Location of the level of the 5th wild Pokemon in that map
add hl, bc
ld a, [TimeOfDay]
- ld bc, 7 * 2
+ ld bc, NUM_GRASSMON * 2
call AddNTimes
.randloop1
call Random
- and $3
+ and %11
jr z, .randloop1
dec a
ld c, a
@@ -877,7 +877,7 @@ RandomUnseenWildMon: ; 2a4ab
db "@"
; 0x2a51f
-RandomPhoneWildMon: ; 2a51f
+Special_RandomPhoneWildMon: ; 2a51f
farcall GetCallerLocation
ld d, b
ld e, c
@@ -893,7 +893,7 @@ RandomPhoneWildMon: ; 2a51f
add hl, bc
ld a, [TimeOfDay]
inc a
- ld bc, 7 * 2
+ ld bc, NUM_GRASSMON * 2
.loop
dec a
jr z, .done
@@ -902,7 +902,7 @@ RandomPhoneWildMon: ; 2a51f
.done
call Random
- and $3
+ and %11
ld c, a
ld b, $0
add hl, bc
@@ -913,11 +913,11 @@ RandomPhoneWildMon: ; 2a51f
call GetPokemonName
ld hl, StringBuffer1
ld de, StringBuffer4
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
jp CopyBytes
; 2a567
-RandomPhoneMon: ; 2a567
+Special_RandomPhoneMon: ; 2a567
; Get a random monster owned by the trainer who's calling.
farcall GetCallerLocation
ld hl, TrainerGroups
@@ -952,16 +952,17 @@ RandomPhoneMon: ; 2a567
ld a, BANK(Trainers)
call GetFarByte
inc hl
- ld bc, 2
- cp 0
+ ld bc, 2 ; level, species
+ cp TRAINERTYPE_NORMAL
jr z, .got_mon_length
- ld bc, 2 + NUM_MOVES
- cp 1
+ ld bc, 2 + NUM_MOVES ; level, species, moves
+ cp TRAINERTYPE_MOVES
jr z, .got_mon_length
- ld bc, 2 + 1
- cp 2
+ ld bc, 2 + 1 ; level, species, item
+ cp TRAINERTYPE_ITEM
jr z, .got_mon_length
- ld bc, 2 + 1 + NUM_MOVES
+ ; TRAINERTYPE_ITEM_MOVES
+ ld bc, 2 + 1 + NUM_MOVES ; level, species, item, moves
.got_mon_length
ld e, 0
@@ -977,7 +978,7 @@ RandomPhoneMon: ; 2a567
.rand
call Random
- and 7
+ maskbits PARTY_LENGTH
cp e
jr nc, .rand
@@ -996,7 +997,7 @@ RandomPhoneMon: ; 2a567
call GetPokemonName
ld hl, StringBuffer1
ld de, StringBuffer4
- ld bc, PKMN_NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
jp CopyBytes
; 2a5e9