From e384ea25ec1f28beac2b6bf08d6ae30aa742fbec Mon Sep 17 00:00:00 2001 From: DrippingYellow <106562603+DrippingYellow@users.noreply.github.com> Date: Wed, 30 Jul 2025 16:35:58 -0500 Subject: [PATCH] Finish labelling and split off bank03, bank09, and bank0b (#119) * Fully labelled bank09.asm, started bank03.asm * Finished labelling bank03.asm and bank0b.asm * Tying up loose ends, splitting most of the completely labelled bank dumps * Moved pokedex letter graphics out of charmap --- constants/battle_constants.asm | 4 - constants/charmap.asm | 2 +- constants/item_constants.asm | 8 +- constants/item_data_constants.asm | 4 +- constants/menu_constants.asm | 7 +- constants/pokemon_data_constants.asm | 1 + constants/sprite_anim_constants.asm | 10 +- constants/text_constants.asm | 5 +- constants/wram_constants.asm | 16 + data/items/super_rod.inc | 97 + data/mon_menu.inc | 83 + data/pokemon/evos_attacks.asm | 4 +- data/pokemon/gen1_order.inc | 260 + data/predef_pointers.inc | 32 +- data/sgb/blk_packets.inc | 2 +- data/sprite_anims/framesets.inc | 6 +- data/sprite_anims/oam.inc | 2 +- data/sprite_anims/objects.inc | 4 +- engine/battle/menu.asm | 220 + .../bank33.asm => battle_anims/helpers.asm} | 2 +- engine/battle_anims/pokeball_wobble.asm | 72 + engine/debug/debug_menu.asm | 12 +- engine/debug/field/change_tileset.inc | 2 +- engine/debug/field/change_transportation.inc | 2 +- engine/debug/field/item_test.inc | 14 +- engine/debug/field/map_viewer.inc | 6 +- engine/debug/field/minigames.inc | 2 +- engine/debug/field/move_to_entrance.inc | 2 +- engine/debug/field/pokemart_menu.inc | 18 +- engine/debug/field/sprite_viewer.inc | 2 +- engine/debug/field/toolgear.inc | 2 +- engine/debug/field/warp.inc | 2 +- engine/debug/field_debug_menu.asm | 6 +- engine/dumps/bank03.asm | 5658 +---------------- engine/dumps/bank09.asm | 2042 ------ engine/dumps/bank0b.asm | 475 -- engine/dumps/bank0d.asm | 6 +- engine/dumps/bank0f.asm | 544 +- engine/dumps/bank14.asm | 384 +- engine/events/breeder.asm | 275 + engine/events/field_moves.asm | 6 +- engine/events/pokecenter_pc.asm | 2 +- engine/events/pokepic.asm | 46 + engine/events/starter_dex.asm | 32 + engine/events/town_map.asm | 322 + engine/gfx/load_minor_object_gfx.asm | 143 + engine/gfx/sgb_layouts.asm | 4 +- engine/items/buy_sell_toss.asm | 185 + engine/items/inventory.asm | 234 +- engine/items/item_effects.asm | 2492 ++++++++ engine/items/print_item_description.asm | 20 + engine/items/switch_items.asm | 241 + engine/items/tm_holder.asm | 459 ++ engine/items/tmhm.asm | 2 +- engine/items/update_item_description.asm | 14 + engine/link/time_capsule_2.asm | 43 + engine/menu/frame_type_dialog.asm | 2 +- engine/menu/main_menu.asm | 2 +- engine/menu/menu.asm | 384 ++ engine/menu/menu_2.asm | 201 + engine/menu/scrolling_menu.asm | 514 ++ engine/menu/start_menu.asm | 74 +- engine/movie/evolution_animation.inc | 239 + engine/movie/oak_speech.asm | 4 +- .../player_object.asm} | 462 +- engine/overworld/player_step.asm | 565 ++ engine/overworld/spawn_points.asm | 15 + engine/pokedex/display_dex_entry.asm | 138 + .../{dumps/bank10.asm => pokedex/pokedex.asm} | 1285 +--- engine/pokedex/pokedex_2.asm | 970 +++ engine/pokemon/bills_pc.asm | 653 ++ engine/pokemon/evolve.asm | 554 ++ engine/pokemon/knows_move.asm | 131 + engine/pokemon/learn.asm | 4 +- engine/pokemon/mon_submenu.asm | 290 + engine/pokemon/move_mon.asm | 1503 +++++ engine/pokemon/print_move_description.asm | 20 + engine/sprite_anims/functions.inc | 9 +- engine/unknown_boxes.asm | 20 +- gfx/evo/bubbles.png | Bin 0 -> 166 bytes gfx/gfx.asm | 2 +- gfx/gfx.mk | 2 + home/jumptable.asm | 11 +- home/map.asm | 6 +- home/menu.asm | 136 +- home/menu_window.asm | 251 +- home/misc_32c8.asm | 2 +- home/misc_3c43.asm | 4 +- home/overworld.asm | 6 +- home/scrolling_menu.asm | 46 +- home/talk_to_npc.asm | 16 +- home/tileset.asm | 8 +- home/unknown_388f.asm | 4 +- home/unknown_3e32.asm | 8 +- home/window.asm | 3 +- layout.link | 54 +- macros/wram.asm | 28 +- ram/hram.asm | 10 +- ram/sram.asm | 34 +- ram/wram.asm | 214 +- scripts/PlayerHouse2F.asm | 4 +- scripts/SilentHill.asm | 2 +- scripts/SilentHillHouse.asm | 2 +- scripts/SilentHillLabBack.asm | 4 +- scripts/SilentHillLabFront.asm | 8 +- shim.sym | 62 +- utils/tests/charmap.asm | 4 +- 107 files changed, 12604 insertions(+), 10906 deletions(-) create mode 100644 data/items/super_rod.inc create mode 100644 data/mon_menu.inc create mode 100644 data/pokemon/gen1_order.inc create mode 100644 engine/battle/menu.asm rename engine/{dumps/bank33.asm => battle_anims/helpers.asm} (97%) create mode 100644 engine/battle_anims/pokeball_wobble.asm delete mode 100644 engine/dumps/bank09.asm delete mode 100644 engine/dumps/bank0b.asm create mode 100644 engine/events/breeder.asm create mode 100644 engine/events/pokepic.asm create mode 100644 engine/events/starter_dex.asm create mode 100644 engine/events/town_map.asm create mode 100644 engine/gfx/load_minor_object_gfx.asm create mode 100644 engine/items/buy_sell_toss.asm create mode 100644 engine/items/print_item_description.asm create mode 100644 engine/items/switch_items.asm create mode 100644 engine/items/tm_holder.asm create mode 100644 engine/items/update_item_description.asm create mode 100644 engine/link/time_capsule_2.asm create mode 100644 engine/menu/menu.asm create mode 100644 engine/menu/menu_2.asm create mode 100644 engine/menu/scrolling_menu.asm create mode 100644 engine/movie/evolution_animation.inc rename engine/{dumps/bank02.asm => overworld/player_object.asm} (59%) create mode 100644 engine/overworld/player_step.asm create mode 100644 engine/pokedex/display_dex_entry.asm rename engine/{dumps/bank10.asm => pokedex/pokedex.asm} (55%) create mode 100644 engine/pokedex/pokedex_2.asm create mode 100644 engine/pokemon/bills_pc.asm create mode 100644 engine/pokemon/evolve.asm create mode 100644 engine/pokemon/knows_move.asm create mode 100644 engine/pokemon/mon_submenu.asm create mode 100644 engine/pokemon/move_mon.asm create mode 100644 engine/pokemon/print_move_description.asm create mode 100644 gfx/evo/bubbles.png diff --git a/constants/battle_constants.asm b/constants/battle_constants.asm index 175d417..1bf6747 100644 --- a/constants/battle_constants.asm +++ b/constants/battle_constants.asm @@ -175,10 +175,6 @@ DEF ALL_STATUS EQU (1 << PSN) | (1 << BRN) | (1 << FRZ) | (1 << PAR) | SLP const SUBSTATUS_ROLLOUT const SUBSTATUS_IN_LOVE -; wPlayerSubStatus2 or wEnemySubStatus2 bit flags - const_def - const SUBSTATUS_CURLED - ; wPlayerSubStatus3 or wEnemySubStatus3 bit flags const_def const SUBSTATUS_BIDE diff --git a/constants/charmap.asm b/constants/charmap.asm index 2278957..2d5c2bc 100755 --- a/constants/charmap.asm +++ b/constants/charmap.asm @@ -273,7 +273,7 @@ charmap "▷", $ec charmap "▶", $ed - charmap "▲", $ed +; charmap "▲", $ed charmap "▼", $ee charmap "♂", $ef charmap "円", $f0 diff --git a/constants/item_constants.asm b/constants/item_constants.asm index da282a1..b886220 100644 --- a/constants/item_constants.asm +++ b/constants/item_constants.asm @@ -267,5 +267,9 @@ DEF NUM_HMS = const_value - ITEM_HM01 DEF NUM_TM_HM = NUM_TMS + NUM_HMS ; leftovers from pokered -DEF ITEM_HM01_RED EQU $c4 -DEF ITEM_TM01_RED EQU $c9 +DEF ITEM_X_ATTACK_RED EQU $41 +DEF ITEM_ETHER_RED EQU $50 +DEF ITEM_MAX_ETHER_RED EQU $51 +DEF ITEM_ELIXER_RED EQU $52 +DEF ITEM_HM01_RED EQU $c4 +DEF ITEM_TM01_RED EQU $c9 diff --git a/constants/item_data_constants.asm b/constants/item_data_constants.asm index a92dc4f..df92610 100755 --- a/constants/item_data_constants.asm +++ b/constants/item_data_constants.asm @@ -17,7 +17,7 @@ DEF ITEMATTR_STRUCT_LENGTH EQU const_value const TM_HM ; 4 ; item menu types -; UseItem.dw indexes (see engine/items/pack.asm) +; DoItemEffect.dw indexes (see engine/items/pack.asm) ; UseRegisteredItem.SwitchTo indexes (see engine/overworld/select_menu.asm) const_def const ITEMMENU_NOUSE ; 0 @@ -46,6 +46,8 @@ DEF MAX_ITEMS EQU 20 DEF MAX_KEY_ITEMS EQU 20 DEF MAX_PC_ITEMS EQU 50 +DEF MAX_ITEM_STACK EQU 99 + ; held item effects const_def const HELD_NONE diff --git a/constants/menu_constants.asm b/constants/menu_constants.asm index f0f3a3c..0c7a713 100644 --- a/constants/menu_constants.asm +++ b/constants/menu_constants.asm @@ -24,8 +24,8 @@ const_def shift_const SCROLLINGMENU_CALL_FUNCTION1_CANCEL shift_const SCROLLINGMENU_CALL_FUNCTION3_NO_SWITCH - shift_const SCROLLINGMENU_ENABLE_LEFT shift_const SCROLLINGMENU_ENABLE_RIGHT + shift_const SCROLLINGMENU_ENABLE_LEFT shift_const SCROLLINGMENU_DISPLAY_ARROWS shift_const SCROLLINGMENU_ENABLE_FUNCTION3 shift_const SCROLLINGMENU_ENABLE_START @@ -82,7 +82,7 @@ DEF HMENURETURN_SCRIPT EQU %10000000 DEF HMENURETURN_ASM EQU %11111111 -; PartyMenuQualityPointers indexes (see data/party_menu_qualities.asm) +; PrintPartyMenuText indexes (see data/party_menu_qualities.asm) const_def const PARTYMENUACTION_CHOOSE_POKEMON const PARTYMENUACTION_HEALING_ITEM @@ -93,7 +93,6 @@ DEF HMENURETURN_ASM EQU %11111111 const PARTYMENUACTION_GIVE_MON const PARTYMENUACTION_GIVE_MON_FEMALE ; unused const PARTYMENUACTION_GIVE_ITEM - const PARTYMENUACTION_MOBILE ; mobile ; PrintPartyMenuActionText arguments (see engine/pokemon/party_menu.asm) const_def $f0 const PARTYMENUTEXT_HEAL_PSN @@ -111,6 +110,8 @@ DEF HMENURETURN_ASM EQU %11111111 const_def 1 const SCROLLINGMENU_ITEMS_NORMAL const SCROLLINGMENU_ITEMS_QUANTITY + const_skip 4 + shift_const SCROLLINGMENU_BALL_POCKET ; Naming types (see engine/menus/naming_screen.asm) const_def diff --git a/constants/pokemon_data_constants.asm b/constants/pokemon_data_constants.asm index 5bf0f82..33a811f 100644 --- a/constants/pokemon_data_constants.asm +++ b/constants/pokemon_data_constants.asm @@ -126,6 +126,7 @@ DEF NUM_WATERMON EQU 3 ; data/wild/*_water.asm table size DEF GRASS_WILDDATA_LENGTH EQU (NUM_GRASSMON * 2 + 1) * 3 + 2 DEF WATER_WILDDATA_LENGTH EQU (NUM_WATERMON * 2 + 1) * 1 + 2 +DEF BASE_HAPPINESS EQU 70 ; PP DEF PP_UP_MASK EQU %11000000 diff --git a/constants/sprite_anim_constants.asm b/constants/sprite_anim_constants.asm index ebbf084..8dea659 100755 --- a/constants/sprite_anim_constants.asm +++ b/constants/sprite_anim_constants.asm @@ -146,7 +146,7 @@ DEF NUM_SPRITEANIMDICT_ENTRIES EQU 10 const SPRITE_ANIM_OBJ_TRADE_TUBE_BULGE ; 47 const SPRITE_ANIM_OBJ_TRADEMON_ICON ; 48 const SPRITE_ANIM_OBJ_TRADEMON_BUBBLE ; 49 - const SPRITE_ANIM_OBJ_4A ; 4a + const SPRITE_ANIM_OBJ_EVOLUTION_BALL_OF_LIGHT ; 4a const SPRITE_ANIM_OBJ_RADIO_FREQUENCY_METER ; 4b DEF NUM_SPRITE_ANIM_OBJS EQU const_value @@ -192,7 +192,7 @@ const_def const SPRITE_ANIM_FUNC_TRADE_POKE_BALL ; 25 const SPRITE_ANIM_FUNC_TRADE_TUBE_BULGE ; 26 const SPRITE_ANIM_FUNC_TRADEMON_IN_TUBE ; 27 - const SPRITE_ANIM_FUNC_UNKNOWN ; 28 + const SPRITE_ANIM_FUNC_REVEAL_NEW_MON ; 28 const SPRITE_ANIM_FUNC_RADIO_FREQUENCY_METER ; 29 DEF NUM_SPRITE_ANIM_FUNCS EQU const_value @@ -235,7 +235,7 @@ DEF NUM_SPRITE_ANIM_FUNCS EQU const_value const SPRITE_ANIM_FRAMESET_SLOTS_CHANSEY ; 22 const SPRITE_ANIM_FRAMESET_SLOTS_CHANSEY_2 ; 23 const SPRITE_ANIM_FRAMESET_SLOTS_EGG ; 24 - const SPRITE_ANIM_FRAMESET_WALK ; 25 + const SPRITE_ANIM_FRAMESET_WALK ; 25 const SPRITE_ANIM_FRAMESET_STILL_CURSOR ; 26 const SPRITE_ANIM_FRAMESET_TRADE_POKE_BALL ; 27 const SPRITE_ANIM_FRAMESET_TRADE_POKE_BALL_WOBBLE ; 28 @@ -243,7 +243,7 @@ DEF NUM_SPRITE_ANIM_FUNCS EQU const_value const SPRITE_ANIM_FRAMESET_TRADE_TUBE_BULGE ; 2a const SPRITE_ANIM_FRAMESET_TRADEMON_ICON ; 2b const SPRITE_ANIM_FRAMESET_TRADEMON_BUBBLE ; 2c - const SPRITE_ANIM_FRAMESET_UNKNOWN ; 2d + const SPRITE_ANIM_FRAMESET_EVOLUTION_BALL_OF_LIGHT ; 2d const SPRITE_ANIM_FRAMESET_RADIO_FREQUENCY_METER ; 2e DEF NUM_SPRITE_ANIM_FRAMESETS EQU const_value @@ -314,5 +314,5 @@ DEF NUM_SPRITE_ANIM_FRAMESETS EQU const_value const SPRITE_ANIM_OAMSET_TRADEMON_ICON_1 ; 3e const SPRITE_ANIM_OAMSET_TRADEMON_ICON_2 ; 3f const SPRITE_ANIM_OAMSET_TRADEMON_BUBBLE ; 40 - const SPRITE_ANIM_OAMSET_UNKNOWN_41 ; 41 + const SPRITE_ANIM_OAMSET_EVOLUTION_BALL_OF_LIGHT ; 41 const SPRITE_ANIM_OAMSET_RADIO_FREQUENCY_METER ; 42 diff --git a/constants/text_constants.asm b/constants/text_constants.asm index 9cdd1fb..ce19fe5 100644 --- a/constants/text_constants.asm +++ b/constants/text_constants.asm @@ -1,9 +1,10 @@ ; name lengths DEF NAME_LENGTH EQU 11 ; English DEF PLAYER_NAME_LENGTH EQU 6 ; Japanese -DEF BOX_NAME_LENGTH EQU 9 ; English +DEF BOX_NAME_LENGTH EQU 9 DEF MON_NAME_LENGTH EQU 6 -DEF MOVE_NAME_LENGTH EQU 5 +DEF TYPE_NAME_LENGTH EQU 5 +DEF MOVE_NAME_LENGTH EQU 8 DEF ITEM_NAME_LENGTH EQU 11 DEF TRAINER_CLASS_NAME_LENGTH EQU 13 ; English diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm index fbfe342..bab67ea 100644 --- a/constants/wram_constants.asm +++ b/constants/wram_constants.asm @@ -21,6 +21,22 @@ DEF SCRIPTED_MOVEMENT_STATE_F EQU 7 DEF SPRITES_SKIP_WALKING_GFX_F EQU 6 DEF SPRITES_SKIP_STANDING_GFX_F EQU 7 +; wPokemonWithdrawDepositParameter:: +DEF PC_WITHDRAW EQU 0 +DEF PC_DEPOSIT EQU 1 +DEF REMOVE_PARTY EQU 0 +DEF REMOVE_BOX EQU 1 +DEF BUFFERMON_WITHDRAW EQU 2 +DEF BUFFERMON_DEPOSIT EQU 3 +DEF GET_BUFFER_MON EQU 0 +DEF GET_BREED_MON EQU 1 + +; wBreederStatus:: +DEF BREEDER_ONE_BREEDMON EQU 1 +DEF BREEDER_TWO_BREEDMON EQU 2 +DEF BREEDER_EGG_READY EQU 3 +DEF BREEDER_GAVE_EGG EQU 4 + ; wPlayerStepFlags:: const_def 4 const PLAYERSTEP_MIDAIR_F ; 4 diff --git a/data/items/super_rod.inc b/data/items/super_rod.inc new file mode 100644 index 0000000..3f7b9fb --- /dev/null +++ b/data/items/super_rod.inc @@ -0,0 +1,97 @@ +; Old super rod encounter table. +SuperRodData: + dbw $00, .Group1 ; PALLET_TOWN + dbw $01, .Group1 ; VIRIDIAN_CITY + dbw $03, .Group3 ; CERULEAN_CITY + dbw $05, .Group4 ; VERMILION_CITY + dbw $06, .Group5 ; CELADON_CITY + dbw $07, .Group10 ; FUCHSIA_CITY + dbw $08, .Group8 ; CINNABAR_ISLAND + dbw $0f, .Group3 ; ROUTE_4 + dbw $11, .Group4 ; ROUTE_6 + dbw $15, .Group5 ; ROUTE_10 + dbw $16, .Group4 ; ROUTE_11 + dbw $17, .Group7 ; ROUTE_12 + dbw $18, .Group7 ; ROUTE_13 + dbw $1c, .Group7 ; ROUTE_17 + dbw $1d, .Group7 ; ROUTE_18 + dbw $1e, .Group8 ; ROUTE_19 + dbw $1f, .Group8 ; ROUTE_20 + dbw $20, .Group8 ; ROUTE_21 + dbw $21, .Group2 ; ROUTE_22 + dbw $22, .Group9 ; ROUTE_23 + dbw $23, .Group3 ; ROUTE_24 + dbw $24, .Group3 ; ROUTE_25 + dbw $41, .Group3 ; CERULEAN_GYM + dbw $5e, .Group4 ; VERMILION_DOCK + dbw $a1, .Group8 ; SEAFOAM_ISLANDS_B3F + dbw $a2, .Group8 ; SEAFOAM_ISLANDS_B4F + dbw $d9, .Group6 ; SAFARI_ZONE_EAST + dbw $da, .Group6 ; SAFART_ZONE_NORTH + dbw $db, .Group6 ; SAFARI_ZONE_WEST + dbw $dc, .Group6 ; SAFARI_ZONE_CENTER + dbw $e2, .Group9 ; CERULEAN_CAVE_2F + dbw $e3, .Group9 ; CERULEAN_CAVE_B1F + dbw $e4, .Group9 ; CERLIEAN_CAVE_1F + db -1 ; end + +.Group1: + db 2 + db 15, MON_TENTACOOL + db 15, MON_POLIWAG + +.Group2: + db 2 + db 15, MON_GOLDEEN + db 15, MON_POLIWAG + +.Group3: + db 3 + db 15, MON_PSYDUCK + db 15, MON_GOLDEEN + db 15, MON_KRABBY + +.Group4: + db 2 + db 15, MON_KRABBY + db 15, MON_SHELLDER + +.Group5: + db 2 + db 23, MON_POLIWHIRL + db 15, MON_SLOWPOKE + +.Group6: + db 4 + db 15, MON_DRATINI + db 15, MON_KRABBY + db 15, MON_PSYDUCK + db 15, MON_SLOWPOKE + +.Group7: + db 4 + db 5, MON_TENTACOOL + db 15, MON_KRABBY + db 15, MON_GOLDEEN + db 15, MON_MAGIKARP + +.Group8: + db 4 + db 15, MON_STARYU + db 15, MON_HORSEA + db 15, MON_SHELLDER + db 15, MON_GOLDEEN + +.Group9: + db 4 + db 23, MON_SLOWBRO + db 23, MON_SEAKING + db 23, MON_KINGLER + db 23, MON_SEADRA + +.Group10: + db 4 + db 23, MON_SEAKING + db 15, MON_KRABBY + db 15, MON_GOLDEEN + db 15, MON_MAGIKARP diff --git a/data/mon_menu.inc b/data/mon_menu.inc new file mode 100644 index 0000000..b147f53 --- /dev/null +++ b/data/mon_menu.inc @@ -0,0 +1,83 @@ +; An unreferenced, nonfunctional menu that resembles the field debug menu. +Unreferenced_FieldMoveMenu: + ld hl, .MenuData + call LoadMenuHeader + call VerticalMenu + ret + +.MenuData: + db MENU_BACKUP_TILES + menu_coords 0, 0, 6, 10 + dw .MenuText + db 1 + +.MenuText: + db (STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING) + db 3 ; amount of options + db "うる@" ; Switch + db "かう@" ; Buy + db "やめる@" ; Cancel + db "くさかり@" ; "Mower"? (replaced by Uproot) + db "とんでけ@" ; "Flight"? (replaced by Wind Ride) + db "どんぶらこ@" ; "Splash"? (replaced by Water Sport) + db "フルパワー@" ; "Full Power" (replaced by Strong Arm) + db "ひかりゴケ@" ; Bright Moss + db "うずしお@" ; Whirlpool + db "とびはねる@" ; Bounce + db "あなをほる@" ; Dig + db "テレポート@" ; Teleport + db "タマゴうみ@" ; Softboiled + +; MonMenuOptionStrings indexes + const_def 1 + const MONMENUVALUE_STATS ; 1 + const MONMENUVALUE_SWITCH ; 2 + const MONMENUVALUE_ITEM ; 3 + const MONMENUVALUE_CANCEL ; 4 + const MONMENUVALUE_MOVE ; 5 + const MONMENUVALUE_MAIL ; 6 + const MONMENUVALUE_ERROR ; 7 +DEF NUM_MONMENUVALUES EQU const_value - 1 + +MonMenuOptionStrings: + db "つよさをみる@" ; Stats + db "ならびかえ@" ; Switch + db "そうび@" ; Item + db "キャンセル@" ; Cancel + db "もちわざ@" ; Moves + db "メール@" ; Mail + db "エラー!@" ; Error! + +Unreferenced_FieldMoveList: + db MOVE_UPROOT, MONMENUITEM_CUT + db MOVE_WIND_RIDE, MONMENUITEM_FLY + db MOVE_WATER_SPORT, MONMENUITEM_SURF + db MOVE_STRONG_ARM, MONMENUITEM_STRENGTH + db MOVE_BRIGHT_MOSS, MONMENUITEM_FLASH + db MOVE_WHIRLPOOL, MONMENUITEM_WHIRLPOOL + db MOVE_BOUNCE, MONMENUITEM_BOUNCE + db MOVE_DIG, MONMENUITEM_DIG + db MOVE_TELEPORT, MONMENUITEM_TELEPORT + db MOVE_SOFTBOILED, MONMENUITEM_SOFTBOILED + db -1 + +MonMenuOptions: + db MONMENU_FIELD_MOVE, MONMENUITEM_CUT, MOVE_UPROOT + db MONMENU_FIELD_MOVE, MONMENUITEM_FLY, MOVE_WIND_RIDE + db MONMENU_FIELD_MOVE, MONMENUITEM_SURF, MOVE_WATER_SPORT + db MONMENU_FIELD_MOVE, MONMENUITEM_STRENGTH, MOVE_STRONG_ARM + db MONMENU_FIELD_MOVE, MONMENUITEM_FLASH, MOVE_BRIGHT_MOSS + db MONMENU_FIELD_MOVE, MONMENUITEM_WHIRLPOOL, MOVE_WHIRLPOOL + db MONMENU_FIELD_MOVE, MONMENUITEM_BOUNCE, MOVE_BOUNCE + db MONMENU_FIELD_MOVE, MONMENUITEM_DIG, MOVE_DIG + db MONMENU_FIELD_MOVE, MONMENUITEM_TELEPORT, MOVE_TELEPORT + db MONMENU_FIELD_MOVE, MONMENUITEM_SOFTBOILED, MOVE_SOFTBOILED + db MONMENU_MENUOPTION, MONMENUITEM_STATS, MONMENUVALUE_STATS + db MONMENU_MENUOPTION, MONMENUITEM_SWITCH, MONMENUVALUE_SWITCH + db MONMENU_MENUOPTION, MONMENUITEM_ITEM, MONMENUVALUE_ITEM + db MONMENU_MENUOPTION, MONMENUITEM_CANCEL, MONMENUVALUE_CANCEL + db MONMENU_MENUOPTION, MONMENUITEM_MOVE, MONMENUVALUE_MOVE + db MONMENU_MENUOPTION, MONMENUITEM_MAIL, MONMENUVALUE_MAIL + db MONMENU_MENUOPTION, MONMENUITEM_ERROR, MONMENUVALUE_ERROR + db -1 + \ No newline at end of file diff --git a/data/pokemon/evos_attacks.asm b/data/pokemon/evos_attacks.asm index c0bea1b..2d6d339 100644 --- a/data/pokemon/evos_attacks.asm +++ b/data/pokemon/evos_attacks.asm @@ -17,8 +17,8 @@ EvosAttacks:: ; - Evolution methods: ; * db EVOLVE_LEVEL, level, dex ; * db EVOLVE_STONE, 1, used item, dex -; * db EVOLVE_ITEM, 1, held? item, dex -; * db EVOLVE_TRADE, 1, dex +; * db EVOLVE_ITEM, min level (1), held? item, dex +; * db EVOLVE_TRADE, min level (1), dex ; - db 0 ; no more evolutions ; - Learnset (in increasing level order): ; * db level, move diff --git a/data/pokemon/gen1_order.inc b/data/pokemon/gen1_order.inc new file mode 100644 index 0000000..fdd9d19 --- /dev/null +++ b/data/pokemon/gen1_order.inc @@ -0,0 +1,260 @@ +Pokered_MonIndices:: +; BUG: Notice anything odd about this list? There are only 250 entries; Riifi is missing! +; Presumably, it was such a recent addition that it hadn't yet been included in this list. +; This causes ConvertMon_2to1 to search out of bounds for byte $FB, eventually finding it and loading Nidorina's cry. + +; Note that in the final game, Celebi is also missing from this list, meaning that they never actually fixed this +; before they switched the cry order to match the Pokédex order. + db DEX_RHYDON ; 01 + db DEX_KANGASKHAN ; 02 + db DEX_NIDORAN_M ; 03 + db DEX_CLEFAIRY ; 04 + db DEX_SPEAROW ; 05 + db DEX_VOLTORB ; 06 + db DEX_NIDOKING ; 07 + db DEX_SLOWBRO ; 08 + db DEX_IVYSAUR ; 09 + db DEX_EXEGGUTOR ; 0a + db DEX_LICKITUNG ; 0b + db DEX_EXEGGCUTE ; 0c + db DEX_GRIMER ; 0d + db DEX_GENGAR ; 0e + db DEX_NIDORAN_F ; 0f + db DEX_NIDOQUEEN ; 10 + db DEX_CUBONE ; 11 + db DEX_RHYHORN ; 12 + db DEX_LAPRAS ; 13 + db DEX_ARCANINE ; 14 + db DEX_MEW ; 15 + db DEX_GYARADOS ; 16 + db DEX_SHELLDER ; 17 + db DEX_TENTACOOL ; 18 + db DEX_GASTLY ; 19 + db DEX_SCYTHER ; 1a + db DEX_STARYU ; 1b + db DEX_BLASTOISE ; 1c + db DEX_PINSIR ; 1d + db DEX_TANGELA ; 1e + db DEX_KAPOERER ; 1f + db DEX_PUDIE ; 20 + db DEX_GROWLITHE ; 21 + db DEX_ONIX ; 22 + db DEX_FEAROW ; 23 + db DEX_PIDGEY ; 24 + db DEX_SLOWPOKE ; 25 + db DEX_KADABRA ; 26 + db DEX_GRAVELER ; 27 + db DEX_CHANSEY ; 28 + db DEX_MACHOKE ; 29 + db DEX_MRMIME ; 2a + db DEX_HITMONLEE ; 2b + db DEX_HITMONCHAN ; 2c + db DEX_ARBOK ; 2d + db DEX_PARASECT ; 2e + db DEX_PSYDUCK ; 2f + db DEX_DROWZEE ; 30 + db DEX_GOLEM ; 31 + db DEX_HANEKO ; 32 + db DEX_MAGMAR ; 33 + db DEX_TAIL ; 34 + db DEX_ELECTABUZZ ; 35 + db DEX_MAGNETON ; 36 + db DEX_KOFFING ; 37 + db DEX_POPONEKO ; 38 + db DEX_MANKEY ; 39 + db DEX_SEEL ; 3a + db DEX_DIGLETT ; 3b + db DEX_TAUROS ; 3c + db DEX_WATANEKO ; 3d + db DEX_BARIRINA ; 3e + db DEX_LIP ; 3f + db DEX_FARFETCHD ; 40 + db DEX_VENONAT ; 41 + db DEX_DRAGONITE ; 42 + db DEX_ELEBABY ; 43 + db DEX_BOOBY ; 44 + db DEX_KIREIHANA ; 45 + db DEX_DODUO ; 46 + db DEX_POLIWAG ; 47 + db DEX_JYNX ; 48 + db DEX_MOLTRES ; 49 + db DEX_ARTICUNO ; 4a + db DEX_ZAPDOS ; 4b + db DEX_DITTO ; 4c + db DEX_MEOWTH ; 4d + db DEX_KRABBY ; 4e + db DEX_TSUBOMITTO ; 4f + db DEX_MILTANK ; 50 + db DEX_BOMBSEEKER ; 51 + db DEX_VULPIX ; 52 + db DEX_NINETALES ; 53 + db DEX_PIKACHU ; 54 + db DEX_RAICHU ; 55 + db DEX_GIFT ; 56 + db DEX_KOTORA ; 57 + db DEX_DRATINI ; 58 + db DEX_DRAGONAIR ; 59 + db DEX_KABUTO ; 5a + db DEX_KABUTOPS ; 5b + db DEX_HORSEA ; 5c + db DEX_SEADRA ; 5d + db DEX_RAITORA ; 5e + db DEX_MADAME ; 5f + db DEX_SANDSHREW ; 60 + db DEX_SANDSLASH ; 61 + db DEX_OMANYTE ; 62 + db DEX_OMASTAR ; 63 + db DEX_JIGGLYPUFF ; 64 + db DEX_WIGGLYTUFF ; 65 + db DEX_EEVEE ; 66 + db DEX_FLAREON ; 67 + db DEX_JOLTEON ; 68 + db DEX_VAPOREON ; 69 + db DEX_MACHOP ; 6a + db DEX_ZUBAT ; 6b + db DEX_EKANS ; 6c + db DEX_PARAS ; 6d + db DEX_POLIWHIRL ; 6e + db DEX_POLIWRATH ; 6f + db DEX_WEEDLE ; 70 + db DEX_KAKUNA ; 71 + db DEX_BEEDRILL ; 72 + db DEX_NOROWARA ; 73 + db DEX_DODRIO ; 74 + db DEX_PRIMEAPE ; 75 + db DEX_DUGTRIO ; 76 + db DEX_VENOMOTH ; 77 + db DEX_DEWGONG ; 78 + db DEX_KYONPAN ; 79 + db DEX_YAMIKARASU ; 7a + db DEX_CATERPIE ; 7b + db DEX_METAPOD ; 7c + db DEX_BUTTERFREE ; 7d + db DEX_MACHAMP ; 7e + db DEX_HAPPI ; 7f + db DEX_GOLDUCK ; 80 + db DEX_HYPNO ; 81 + db DEX_GOLBAT ; 82 + db DEX_MEWTWO ; 83 + db DEX_SNORLAX ; 84 + db DEX_MAGIKARP ; 85 + db DEX_SCISSORS ; 86 + db DEX_PURAKKUSU ; 87 + db DEX_MUK ; 88 + db DEX_DEVIL ; 89 + db DEX_KINGLER ; 8a + db DEX_CLOYSTER ; 8b + db DEX_HELGAA ; 8c + db DEX_ELECTRODE ; 8d + db DEX_CLEFABLE ; 8e + db DEX_WEEZING ; 8f + db DEX_PERSIAN ; 90 + db DEX_MAROWAK ; 91 + db DEX_WOLFMAN ; 92 + db DEX_HAUNTER ; 93 + db DEX_ABRA ; 94 + db DEX_ALAKAZAM ; 95 + db DEX_PIDGEOTTO ; 96 + db DEX_PIDGEOT ; 97 + db DEX_STARMIE ; 98 + db DEX_BULBASAUR ; 99 + db DEX_VENUSAUR ; 9a + db DEX_TENTACRUEL ; 9b + db DEX_WARWOLF ; 9c + db DEX_GOLDEEN ; 9d + db DEX_SEAKING ; 9e + db DEX_PORYGON2 ; 9f + db DEX_NAMEIL ; a0 + db DEX_HAGANEIL ; a1 + db DEX_KINGDRA ; a2 + db DEX_PONYTA ; a3 + db DEX_RAPIDASH ; a4 + db DEX_RATTATA ; a5 + db DEX_RATICATE ; a6 + db DEX_NIDORINO ; a7 + db DEX_NIDORINA ; a8 + db DEX_GEODUDE ; a9 + db DEX_PORYGON ; aa + db DEX_AERODACTYL ; ab + db DEX_RAI ; ac + db DEX_MAGNEMITE ; ad + db DEX_EN ; ae + db DEX_SUI ; af + db DEX_CHARMANDER ; b0 + db DEX_SQUIRTLE ; b1 + db DEX_CHARMELEON ; b2 + db DEX_WARTORTLE ; b3 + db DEX_CHARIZARD ; b4 + db DEX_NYULA ; b5 + db DEX_HOUOU ; b6 + db DEX_TOGEPY ; b7 + db DEX_BULU ; b8 + db DEX_ODDISH ; b9 + db DEX_GLOOM ; ba + db DEX_VILEPLUME ; bb + db DEX_BELLSPROUT ; bc + db DEX_WEEPINBELL ; bd + db DEX_VICTREEBEL ; be + db DEX_HAPPA ; bf + db DEX_HANAMOGURA ; c0 + db DEX_HANARYU ; c1 + db DEX_HONOGUMA ; c2 + db DEX_VOLBEAR ; c3 + db DEX_DYNABEAR ; c4 + db DEX_KURUSU ; c5 + db DEX_AQUA ; c6 + db DEX_AQUARIA ; c7 + db DEX_HOHO ; c8 + db DEX_BOBO ; c9 + db DEX_PACHIMEE ; ca + db DEX_MOKOKO ; cb + db DEX_DENRYU ; cc + db DEX_MIKON ; cd + db DEX_MONJA ; ce + db DEX_JARANRA ; cf + db DEX_HANEEI ; d0 + db DEX_PUKU ; d1 + db DEX_SHIBIREFUGU ; d2 + db DEX_PICHU ; d3 + db DEX_PY ; d4 + db DEX_PUPURIN ; d5 + db DEX_MIZUUO ; d6 + db DEX_NATY ; d7 + db DEX_NATIO ; d8 + db DEX_GYOPIN ; d9 + db DEX_MARIL ; da + db DEX_MANBO1 ; db + db DEX_IKARI ; dc + db DEX_GROTESS ; dd + db DEX_EKSING ; de + db DEX_PARA ; df + db DEX_KOKUMO ; e0 + db DEX_TWOHEAD ; e1 + db DEX_YOROIDORI ; e2 + db DEX_ANIMON ; e3 + db DEX_HINAZU ; e4 + db DEX_SUNNY ; e5 + db DEX_PAON ; e6 + db DEX_DONPHAN ; e7 + db DEX_TWINZ ; e8 + db DEX_KIRINRIKI ; e9 + db DEX_PAINTER ; ea + db DEX_KOUNYA ; eb + db DEX_RINRIN ; ec + db DEX_BERURUN ; ed + db DEX_NYOROTONO ; ee + db DEX_YADOKING ; ef + db DEX_ANNON ; f0 + db DEX_REDIBA ; f1 + db DEX_MITSUBOSHI ; f2 + db DEX_PUCHICORN ; f3 + db DEX_EIFIE ; f4 + db DEX_BLACKY ; f5 + db DEX_TURBAN ; f6 + db DEX_BETBABY ; f7 + db DEX_TEPPOUO ; f8 + db DEX_OKUTANK ; f9 + db DEX_GONGU ; fa + db DEX_REDIBA ; fb + db DEX_REDIBA ; fc + \ No newline at end of file diff --git a/data/predef_pointers.inc b/data/predef_pointers.inc index 7559c6c..bbd24e4 100644 --- a/data/predef_pointers.inc +++ b/data/predef_pointers.inc @@ -28,34 +28,34 @@ GiveItemPredef:: dbw 3, GiveItem add_predef ComputeHPBarPixels add_predef FillPP - add_predef Functiond886 ; 10 - add_predef Functionda4f - add_predef Functiondac8 - add_predef Functiondcfc - add_predef Functiondc16 - add_predef Functiondd5c - add_predef Functionde79 + add_predef TryAddMonToParty ; 10 + add_predef AddTempmonToParty + add_predef SendGetMonIntoFromBox + add_predef DepositBreedmonOrBuffermon + add_predef RetrieveBreedmonOrBuffermon + add_predef SendMonIntoBox + add_predef GiveEgg add_predef UpdateHPBar add_predef CalcMonStats ; 18 add_predef CalcMonStatC add_predef CanLearnTMHMMove add_predef GetTMHMMove add_predef LinkTextboxAtHL - add_predef Function2d663 + add_predef PrintMoveDescription add_predef UpdatePlayerHUD add_predef PlaceGraphic add_predef Function3f068 ; 20 add_predef LoadMonBackPic add_predef AnyPartyAlive add_predef UpdateEnemyHUD - add_predef Function3e1a4 + add_predef DoubleOrHalveSelectedStats_Old add_predef Function3ef19 add_predef CalcAndPlaceExpBar add_predef GetBattleMonBackpic add_predef GetEnemyMonFrontpic ; 28 - add_predef Function421f8 + add_predef LearnLevelMoves add_predef FillMoves - add_predef Function41fa1 + add_predef EvolveAfterBattle add_predef Function28da4 add_predef Function28d6e add_predef NewPokedexEntry @@ -65,13 +65,13 @@ GiveItemPredef:: add_predef ListMoves add_predef GetMonBackpic add_predef PlaceNonFaintStatus - add_predef Function508c4 - add_predef PartyMenuInBattle_Setup - add_predef PartyMenuInBattle - add_predef Function5081f ; 38 + add_predef PlacePartyMember + add_predef OpenPartyMenu_ClearGraphics + add_predef OpenPartyMenu + add_predef InitPartyMenuLayout ; 38 add_predef ListMovePP add_predef GetGender - add_predef Function502b5 + add_predef StatsScreenMain add_predef DrawPlayerHP add_predef DrawEnemyHP add_predef GetTypeName diff --git a/data/sgb/blk_packets.inc b/data/sgb/blk_packets.inc index b614985..c163871 100644 --- a/data/sgb/blk_packets.inc +++ b/data/sgb/blk_packets.inc @@ -50,7 +50,7 @@ BlkPacket_SlotMachine: attr_blk_data %011, 0,0,0, 04,04, 15,09 attr_blk_data %011, 0,0,0, 00,12, 19,17 -BlkPacket_98fc: +BlkPacket_PartyMenu: attr_blk 7 attr_blk_data %111, 0,0,1, 00,00, 02,12 attr_blk_data %010, 0,0,0, 12,00, 18,01 diff --git a/data/sprite_anims/framesets.inc b/data/sprite_anims/framesets.inc index f45a1dc..6f1f51f 100644 --- a/data/sprite_anims/framesets.inc +++ b/data/sprite_anims/framesets.inc @@ -44,7 +44,7 @@ SpriteAnimFrameData: dw .Frameset_TradeTubeBulge ; SPRITE_ANIM_FRAMESET_TRADE_TUBE_BULGE dw .Frameset_TrademonIcon ; SPRITE_ANIM_FRAMESET_TRADEMON_ICON dw .Frameset_TrademonBubble ; SPRITE_ANIM_FRAMESET_TRADEMON_BUBBLE - dw .Frameset_Unknown ; SPRITE_ANIM_FRAMESET_UNKNOWN + dw .Frameset_EvolutionBallOfLight ; SPRITE_ANIM_FRAMESET_EVOLUTION_BALL_OF_LIGHT dw .Frameset_RadioFrequencyMeter ; SPRITE_ANIM_FRAMESET_RADIO_FREQUENCY_METER .Frameset_00: @@ -275,8 +275,8 @@ SpriteAnimFrameData: oamframe SPRITE_ANIM_OAMSET_TRADEMON_BUBBLE, 32 oamend -.Frameset_Unknown: - oamframe SPRITE_ANIM_OAMSET_UNKNOWN_41, 32 +.Frameset_EvolutionBallOfLight: + oamframe SPRITE_ANIM_OAMSET_EVOLUTION_BALL_OF_LIGHT, 32 oamend .Frameset_RadioFrequencyMeter: diff --git a/data/sprite_anims/oam.inc b/data/sprite_anims/oam.inc index 8d7e2fd..b0fd86c 100644 --- a/data/sprite_anims/oam.inc +++ b/data/sprite_anims/oam.inc @@ -70,7 +70,7 @@ SpriteAnimOAMData: spriteanimoam $00, .OAMData_Walk ; SPRITE_ANIM_OAMSET_TRADEMON_ICON_1 spriteanimoam $04, .OAMData_Walk ; SPRITE_ANIM_OAMSET_TRADEMON_ICON_2 spriteanimoam $10, .OAMData_TradePoofBubble ; SPRITE_ANIM_OAMSET_TRADEMON_BUBBLE - spriteanimoam $00, .OAMData_Unknown1 ; SPRITE_ANIM_OAMSET_UNKNOWN_41 + spriteanimoam $00, .OAMData_Unknown1 ; SPRITE_ANIM_OAMSET_EVOLUTION_BALL_OF_LIGHT spriteanimoam $00, .OAMData_RadioFrequencyMeter ; SPRITE_ANIM_OAMSET_RADIO_FREQUENCY_METER .OAMData_1x1_Palette0: diff --git a/data/sprite_anims/objects.inc b/data/sprite_anims/objects.inc index f9b8e17..f0c0ab7 100644 --- a/data/sprite_anims/objects.inc +++ b/data/sprite_anims/objects.inc @@ -149,7 +149,7 @@ SpriteAnimObjects: db SPRITE_ANIM_FRAMESET_TRADEMON_ICON, SPRITE_ANIM_FUNC_TRADEMON_IN_TUBE, SPRITE_ANIM_DICT_DEFAULT ; SPRITE_ANIM_OBJ_TRADEMON_BUBBLE db SPRITE_ANIM_FRAMESET_TRADEMON_BUBBLE, SPRITE_ANIM_FUNC_TRADEMON_IN_TUBE, SPRITE_ANIM_DICT_DEFAULT -; SPRITE_ANIM_OBJ_4A - db SPRITE_ANIM_FRAMESET_UNKNOWN, SPRITE_ANIM_FUNC_UNKNOWN, SPRITE_ANIM_DICT_DEFAULT +; SPRITE_ANIM_OBJ_EVOLUTION_BALL_OF_LIGHT + db SPRITE_ANIM_FRAMESET_EVOLUTION_BALL_OF_LIGHT, SPRITE_ANIM_FUNC_REVEAL_NEW_MON, SPRITE_ANIM_DICT_DEFAULT ; SPRITE_ANIM_OBJ_RADIO_FREQUENCY_METER db SPRITE_ANIM_FRAMESET_RADIO_FREQUENCY_METER, SPRITE_ANIM_FUNC_RADIO_FREQUENCY_METER, SPRITE_ANIM_DICT_DEFAULT diff --git a/engine/battle/menu.asm b/engine/battle/menu.asm new file mode 100644 index 0000000..3324314 --- /dev/null +++ b/engine/battle/menu.asm @@ -0,0 +1,220 @@ +INCLUDE "constants.asm" + +SECTION "engine/battle/menu.asm", ROMX + +LoadBattleMenu:: + ld hl, BattleMenuHeader + jr CommonBattleMenu + +; Unreferenced. +SafariBattleMenu:: + ld hl, SafariBattleMenuHeader + ; fallthrough +CommonBattleMenu: + call LoadMenuHeader + ld a, [wBattleMenuCursorPosition] + ld [wMenuCursorPosition], a + call Battle_2DMenu + ld a, [wMenuCursorPosition] + ld [wBattleMenuCursorPosition], a + call ExitMenu + ret + +BattleMenuHeader: + db MENU_BACKUP_TILES + menu_coords 9, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 + dw .MenuData + db 1 + +.MenuData: + db STATICMENU_CURSOR + dn 2, 2 + db 5 + db "たたかう@" ; "FIGHT" + db "どうぐ@" ; "ITEM" + db "#@" ; "" + db "にげる@" ; "RUN" + +SafariBattleMenuHeader: + db MENU_BACKUP_TILES + menu_coords 0, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 + dw .MenuData + db 1 + +.MenuData: + db STATICMENU_CURSOR + dn 2, 2 + db 11 + db "サファりボール×   @" ; "SAFARI BALL× @" + db "エサをなげる@" ; "THROW BAIT" + db "いしをなげる@" ; "THROW ROCK" + db "にげる@" ; "RUN" + +Battle_2DMenu: + call CopyMenuData + call MenuBox + ld a, [wMenuData_2DMenuDimensions] + ld b, a + and $0f + ld [wBattleMenuRows], a ; rows + + ld a, b + and $f0 + swap a + ld [wBattleMenuColumns], a ; columns + + call .PlaceStrings + call .InitAndHandleCursor + call StaticMenuJoypad + ldh a, [hJoySum] + bit SELECT_F, a + jr nz, .quit + + ld a, [w2DMenuNumRows] + ld c, a + ld a, [wMenuCursorY] + dec a + call .GetNewCursorPos + ld c, a + ld a, [wMenuCursorX] + add c + ld [wMenuCursorPosition], a + and a + ret + +.quit + scf + ret + +.GetNewCursorPos: + and a + ret z + push bc + ld b, a + xor a +.loop + add c + dec b + jr nz, .loop + pop bc + ret + +.unreferenced_24baf: + ld b, 0 +.loop2 + inc b + sub c + jr nc, .loop2 + dec b + add c + ret + +.PlaceStrings: + ld hl, wMenuDataPointer + ld a, [hli] + ld h, [hl] + ld l, a + ld de, 3 + add hl, de + ld d, h + ld e, l + call GetMenuTextStartCoord + call Coord2Tile + ld a, [wBattleMenuRows] + ld b, a +.column_loop + push bc + push hl + ld a, [wBattleMenuColumns] + ld c, a +.row_loop + push bc + call PlaceString + inc de + ld a, [wMenuData_2DMenuSpacing] + ld c, a + ld b, 0 + add hl, bc + pop bc + dec c + jr nz, .row_loop + + pop hl + ld bc, 2 * SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .column_loop + ret + +.InitAndHandleCursor: + call GetMenuTextStartCoord + ld a, b + ld [w2DMenuCursorInitY], a + dec c + ld a, c + ld [w2DMenuCursorInitX], a + ld a, [wBattleMenuRows] + ld [w2DMenuNumRows], a + ld a, [wBattleMenuColumns] + ld [w2DMenuNumCols], a + + ld a, [wMenuDataFlags] + ld d, a + bit STATICMENU_WRAP_F, d + ld a, 0 + jr z, .no_wrap + ld a, _2DMENU_WRAP_LEFT_RIGHT | _2DMENU_WRAP_UP_DOWN + +.no_wrap + ld [w2DMenuFlags1], a + ld a, [wMenuData_2DMenuSpacing] + or $20 + ld [w2DMenuCursorOffsets], a + ld a, A_BUTTON | SELECT + ld [wMenuJoypadFilter], a + ld a, [w2DMenuNumCols] + ld e, a + ld a, [wMenuCursorPosition] + ld b, a + xor a + ld d, 0 + +.loop3 + inc d + add e + cp b + jr c, .loop3 + + sub e + ld c, a + ld a, b + sub c + and a + jr z, .left_wrap + cp e + jr z, .right_wrap + jr c, .right_wrap + +.left_wrap + ld a, 1 +.right_wrap + ld [wMenuCursorX], a + ld a, [w2DMenuNumRows] + ld e, a + ld a, d + and a + jr z, .up_wrap + cp e + jr z, .down_wrap + jr c, .down_wrap + +.up_wrap + ld a, 1 +.down_wrap + ld [wMenuCursorY], a + xor a + ld [wCursorOffCharacter], a + ld [wCursorCurrentTile], a + ld [wCursorCurrentTile + 1], a + ret diff --git a/engine/dumps/bank33.asm b/engine/battle_anims/helpers.asm similarity index 97% rename from engine/dumps/bank33.asm rename to engine/battle_anims/helpers.asm index 56f5eda..dd35daf 100644 --- a/engine/dumps/bank33.asm +++ b/engine/battle_anims/helpers.asm @@ -1,6 +1,6 @@ INCLUDE "constants.asm" -SECTION "engine/battle_anims/helper.asm", ROMX +SECTION "engine/battle_anims/helpers.asm", ROMX ReinitBattleAnimFrameset: ld hl, BATTLEANIMSTRUCT_FRAMESET_ID diff --git a/engine/battle_anims/pokeball_wobble.asm b/engine/battle_anims/pokeball_wobble.asm new file mode 100644 index 0000000..ba1f8b2 --- /dev/null +++ b/engine/battle_anims/pokeball_wobble.asm @@ -0,0 +1,72 @@ +INCLUDE "constants.asm" + +SECTION "engine/battle_anims/pokeball_wobble.asm", ROMX + +GetPokeBallWobble: +; Returns whether a Poke Ball will wobble in the catch animation. +; Whether a Pokemon is caught is determined beforehand. + + ld a, [wThrownBallWobbleCount] + inc a + ld [wThrownBallWobbleCount], a + +; Wobble up to 3 times. + cp 3 + 1 + jr z, .finished + ld a, [wWildMon] + and a + ld c, 0 ; next + ret nz + ld hl, WobbleProbabilities + ld a, [wFinalCatchRate] + ld b, a +.loop + ld a, [hli] + cp b + jr nc, .checkwobble + inc hl + jr .loop +.checkwobble + ld b, [hl] + call Random + cp b + ld c, 0 ; next + ret c + ld c, 2 ; escaped + ret + +.finished + ld a, [wWildMon] + and a + ld c, 1 ; caught + ret nz + ld c, 2 ; escaped + ret + +WobbleProbabilities: +; catch rate, chance of wobbling / 255 +; nLeft/255 = (nRight/255) ** 4 + db 1, 63 + db 2, 75 + db 3, 84 + db 4, 90 + db 5, 95 + db 7, 103 + db 10, 113 + db 15, 126 + db 20, 134 + db 30, 149 + db 40, 160 + db 50, 169 + db 60, 177 + db 80, 191 + db 100, 201 + db 120, 211 + db 140, 220 + db 160, 227 + db 180, 234 + db 200, 240 + db 220, 246 + db 240, 251 + db 254, 253 + db 255, 255 diff --git a/engine/debug/debug_menu.asm b/engine/debug/debug_menu.asm index 4bc00cc..51f5667 100644 --- a/engine/debug/debug_menu.asm +++ b/engine/debug/debug_menu.asm @@ -137,17 +137,17 @@ SetDemoEventFlags: set 2, [hl] ; beat rival in lab ld hl, wd41b set 2, [hl] ; chose a starter - ld a, %1 + ld a, 1 ld [wd29a], a - ld a, %1 + ld a, 1 ld [wd29b], a - ld a, %110 + ld a, 6 ld [wd29c], a - ld a, %10010 + ld a, 18 ld [wd29d], a - ld a, %110 + ld a, 6 ld [wd29e], a - ld a, %10 + ld a, 2 ld [wd2a0], a ret diff --git a/engine/debug/field/change_tileset.inc b/engine/debug/field/change_tileset.inc index bc7f3bc..8d2ab80 100644 --- a/engine/debug/field/change_tileset.inc +++ b/engine/debug/field/change_tileset.inc @@ -5,7 +5,7 @@ FieldDebug_ChangeTileset: call LoadMenuHeader ld a, [wMapTileset] inc a - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a call VerticalMenu call CloseWindow jr c, .reopen diff --git a/engine/debug/field/change_transportation.inc b/engine/debug/field/change_transportation.inc index 88c8780..c8b51d1 100644 --- a/engine/debug/field/change_transportation.inc +++ b/engine/debug/field/change_transportation.inc @@ -3,7 +3,7 @@ FieldDebug_ChangeTransportation: call LoadMenuHeader ld a, [wPlayerState] call GetActiveTransportation - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a dec a call CopyNameFromMenu call VerticalMenu diff --git a/engine/debug/field/item_test.inc b/engine/debug/field/item_test.inc index 7ff5b4b..f21366e 100644 --- a/engine/debug/field/item_test.inc +++ b/engine/debug/field/item_test.inc @@ -10,7 +10,7 @@ ItemTest_BagMenu: db 1 .MenuData: - db SCROLLINGMENU_ENABLE_LEFT | SCROLLINGMENU_ENABLE_RIGHT | SCROLLINGMENU_ENABLE_FUNCTION3 + db SCROLLINGMENU_ENABLE_RIGHT | SCROLLINGMENU_ENABLE_LEFT | SCROLLINGMENU_ENABLE_FUNCTION3 db 4, 8 ; rows, columns db SCROLLINGMENU_ITEMS_QUANTITY dbw 0, wItems @@ -34,7 +34,7 @@ ItemTest_KeyItemMenu: db 1 .MenuData: - db SCROLLINGMENU_ENABLE_LEFT | SCROLLINGMENU_ENABLE_RIGHT | SCROLLINGMENU_ENABLE_FUNCTION3 + db SCROLLINGMENU_ENABLE_RIGHT | SCROLLINGMENU_ENABLE_LEFT | SCROLLINGMENU_ENABLE_FUNCTION3 db 4, 8 ; rows, columns db SCROLLINGMENU_ITEMS_QUANTITY dbw 0, wNumKeyItems @@ -73,7 +73,7 @@ FieldDebug_ItemTest: call .ClearTilemap .bag_menu ld hl, ItemTest_BagMenu - call Function3810 + call ScrollingMenu_FromTable ld a, [wMenuJoypad] cp B_BUTTON jr z, .exit_menu @@ -85,7 +85,7 @@ FieldDebug_ItemTest: .key_item_menu ld hl, ItemTest_KeyItemMenu - call Function3810 + call ScrollingMenu_FromTable ld a, [wMenuJoypad] cp B_BUTTON jr z, .exit_menu @@ -243,11 +243,11 @@ FieldDebug_ItemTest: ld a, [wCurItem] call ItemTest_FindUsableItem jr c, .use_item2 - call UseItem + call DoItemEffect jp .restart .use_item - call UseItem + call DoItemEffect ld a, [wFieldMoveSucceeded] and a jp z, .restart @@ -255,7 +255,7 @@ FieldDebug_ItemTest: ret .use_item2 - call UseItem + call DoItemEffect call ClearBGPalettes call RestoreScreenAndReloadTiles jp .restart diff --git a/engine/debug/field/map_viewer.inc b/engine/debug/field/map_viewer.inc index 3cbb95a..57b47e2 100644 --- a/engine/debug/field/map_viewer.inc +++ b/engine/debug/field/map_viewer.inc @@ -178,7 +178,7 @@ DebugMapViewer_ShowViewerPrompt: ld a, DEBUGMAPVIEWER_MOVE_CURSOR_TO_PLAYER ldh [hDebugMapViewerJumptable], a .no - call Function1fea + call ScreenCleanup ret .ChangeViewerPrompt: @@ -194,7 +194,7 @@ DebugMapViewer_ShowSelectedDetails: jr nc, .skip call RefreshScreen call .DisplayActorCastID - call Function1fea + call ScreenCleanup ret .skip call DisplayBGEventDetails @@ -370,7 +370,7 @@ DisplayBGEventDetails: call .PrintTableDetails call .WaitInput call CloseWindow - call Function1fea + call ScreenCleanup ret .Functionfd0cc: diff --git a/engine/debug/field/minigames.inc b/engine/debug/field/minigames.inc index 55d867a..cdc5b67 100644 --- a/engine/debug/field/minigames.inc +++ b/engine/debug/field/minigames.inc @@ -46,7 +46,7 @@ FieldDebug_Minigames: call ClearTileMap call WaitBGMap ld hl, wQueuedScriptBank - call CallFar_atHL + call CallPointerAt call ClearPalettes call ReloadSpritesAndFont call LoadTilesetGFX diff --git a/engine/debug/field/move_to_entrance.inc b/engine/debug/field/move_to_entrance.inc index 2be15b6..9405e37 100644 --- a/engine/debug/field/move_to_entrance.inc +++ b/engine/debug/field/move_to_entrance.inc @@ -36,7 +36,7 @@ FieldDebug_MoveToRoute1Entrance: ld a, PLAYER_OBJECT ld hl, wMovementBuffer call LoadMovementDataPointer - call Function1fea + call ScreenCleanup ret .MoveText: diff --git a/engine/debug/field/pokemart_menu.inc b/engine/debug/field/pokemart_menu.inc index e2e1b4e..a8574ba 100644 --- a/engine/debug/field/pokemart_menu.inc +++ b/engine/debug/field/pokemart_menu.inc @@ -8,7 +8,7 @@ FieldDebug_PokemartMenu: .DoPokemartMenu: call LoadStandardMenuHeader - callfar asm_24860 + callfar PlaceMoneyTopRight ld hl, DebugMart_PokemartMenuText call PrintText ld hl, .MenuHeader @@ -118,11 +118,11 @@ DebugMart_Buy: cp A_BUTTON jr z, .buy_item .buy_item - ld a, 99 + ld a, MAX_ITEM_STACK ld [wItemQuantityBuffer], a ld hl, .HowManyText call PrintText - callfar asm_24c64 + callfar SelectQuantityToBuy call ExitMenu jr c, .done predef LoadItemData @@ -152,10 +152,10 @@ DebugMart_Buy: .ConfirmPurchaseText: text_from_ram wStringBuffer2 text "を @" - deciram wItemQuantity, 1, $2 + deciram wItemQuantity, 1, 2 text "こで" line "@" - deciram hFFCD, 3, $6 + deciram hMoneyTemp, 3, 6 text "円 おかいあげですか?" done @@ -260,7 +260,7 @@ DebugMart_Sell: .ItemQuantityPrompt: ld hl, .HowManyItemsText call PrintText - callfar asm_24c64 + callfar SelectQuantityToBuy jr c, .got_quantity jr .CannotSellItem @@ -300,11 +300,11 @@ DebugMart_LoadItems: ld [wCurItem], a callfar GetItemPrice ld a, d - ld [wMiscStringBuffer], a + ld [wBuySellItemPrice], a ld a, e - ld [wMiscStringBuffer + 1], a + ld [wBuySellItemPrice + 1], a ld hl, wStringBuffer1 - ld de, wMiscStringBuffer + ld de, wBuySellItemPrice lb bc, PRINTNUM_LEADINGZEROS | 2, 6 call PrintNumber pop hl diff --git a/engine/debug/field/sprite_viewer.inc b/engine/debug/field/sprite_viewer.inc index 5b4ede6..0c2229d 100644 --- a/engine/debug/field/sprite_viewer.inc +++ b/engine/debug/field/sprite_viewer.inc @@ -169,7 +169,7 @@ FieldDebug_SpriteViewer: .UpdateMenu: call .SetMenuAttributes .loop2 - call Get2DMenuJoypad + call StaticMenuJoypad ld a, [wMenuCursorY] ld [wSpriteViewerSavedMenuPointerY], a ldh a, [hJoySum] diff --git a/engine/debug/field/toolgear.inc b/engine/debug/field/toolgear.inc index c702f71..f075e66 100644 --- a/engine/debug/field/toolgear.inc +++ b/engine/debug/field/toolgear.inc @@ -62,7 +62,7 @@ OpenToolgearMenu: ld hl, .MenuHeader call LoadMenuHeader call .AfterToolgearOpen - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a call VerticalMenu call CloseWindow ret diff --git a/engine/debug/field/warp.inc b/engine/debug/field/warp.inc index 1151897..200f74d 100644 --- a/engine/debug/field/warp.inc +++ b/engine/debug/field/warp.inc @@ -35,7 +35,7 @@ FieldDebug_ShowWarpToText: call CopyStringToStringBuffer2 ld hl, .WarpToText call FieldDebug_ShowTextboxAndExit - call Function1fea + call ScreenCleanup ret .WarpToText: diff --git a/engine/debug/field_debug_menu.asm b/engine/debug/field_debug_menu.asm index 9ff7426..7047e28 100644 --- a/engine/debug/field_debug_menu.asm +++ b/engine/debug/field_debug_menu.asm @@ -41,10 +41,10 @@ FieldDebugMenu:: call UpdateTimePals call UpdateSprites ld a, [wFieldDebugMenuCursorBuffer] - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a call OpenMenu jr c, .WaitInput - ld a, [wMenuCursorBuffer] + ld a, [wMenuCursorPosition] ld [wFieldDebugMenuCursorBuffer], a call PlaceHollowCursor @@ -83,7 +83,7 @@ FieldDebugMenu:: .Cleanup: push af - call Function1fea + call ScreenCleanup pop af ret diff --git a/engine/dumps/bank03.asm b/engine/dumps/bank03.asm index e5963f2..0562358 100755 --- a/engine/dumps/bank03.asm +++ b/engine/dumps/bank03.asm @@ -1,5641 +1,41 @@ INCLUDE "constants.asm" -SECTION "engine/dumps/bank03.asm@GetFlyPointMapLocation", ROMX - -GetFlyPointMapLocation: - ld a, [wFlyDestination] - ld l, a - ld h, $00 - add hl, hl - add hl, hl - ld de, SpawnPoints - add hl, de - ld b, [hl] ; SpawnPoints + (wFlyDestination * 4) - inc hl - ld c, [hl] - call GetWorldMapLocation - ld e, a - ret - SECTION "engine/dumps/bank03.asm@Functionc9c1", ROMX -Functionc9c1: +_Functionc9c1: xor a - ld bc, $0020 + ld bc, $0020 ; presumably size of wCurrMapInlineTrainers ld hl, wCurrMapInlineTrainers call ByteFill ld de, wMap2Object - ld a, $02 -.sub_c9d0 - push af - push de - ld hl, $0008 - add hl, de - ld a, [hl] - cp $00 - jr nz, .sub_c9e7 - ld hl, $0000 - add hl, de - ld a, [hl] - cp $ff - jr z, .sub_c9e7 - call .sub_c9f5 -.sub_c9e7 - pop de - ld hl, $0010 - add hl, de - ld d, h - ld e, l - pop af - inc a - cp $10 - jr nz, .sub_c9d0 - ret -.sub_c9f5 - jp CheckInlineTrainer - -Functionc9f8: - ld a, [wItemQuantity] - push af - push bc - push de - push hl - push hl - ld d, $32 - push hl - ld bc, $2e62 - add hl, bc - ld a, h - or l - pop hl - jr nz, .sub_ca0e - ld d, $14 -.sub_ca0e - ld a, [hl] - sub d - ld d, a - ld a, [hli] - and a - jr z, .sub_ca24 -.sub_ca15 - ld a, [hli] - ld b, a - ld a, [wCurItem] - cp b - jp z, .sub_ca3e - inc hl - ld a, [hl] - cp $ff - jr nz, .sub_ca15 -.sub_ca24 - pop hl - ld a, d - and a - jr z, .sub_ca5f - inc [hl] - ld a, [hl] - add a - dec a - ld c, a - ld b, $00 - add hl, bc - ld a, [wCurItem] - ld [hli], a - ld a, [wItemQuantity] - ld [hli], a - ld [hl], $ff - jp .sub_ca5e -.sub_ca3e - ld a, [wItemQuantity] - ld b, a - ld a, [hl] - add b - cp $64 - jp c, .sub_ca5c - sub $63 - ld [wItemQuantity], a - ld a, d - and a - jr z, .sub_ca58 - ld a, $63 - ld [hli], a - jp .sub_ca15 -.sub_ca58 - pop hl - and a - jr .sub_ca5f -.sub_ca5c - ld [hl], a - pop hl -.sub_ca5e - scf -.sub_ca5f - pop hl - pop de - pop bc - pop bc - ld a, b - ld [wItemQuantity], a - ret - -Functionca68: - push hl - inc hl - ld a, [wItemIndex] - ld e, a - ld d, $00 - add hl, de - add hl, de - inc hl - ld a, [wItemQuantity] - ld e, a - ld a, [hl] - sub e - ld [hld], a - ld [wItemQuantityBuffer], a - and a - jr nz, .sub_ca9f - ld e, l - ld d, h - inc de - inc de -.sub_ca84 - ld a, [de] - inc de - ld [hli], a - cp $ff - jr nz, .sub_ca84 - xor a - ld [wMenuScrollPosition], a - ld [wRegularItemsCursor], a - pop hl - ld a, [hl] - dec a - ld [hl], a - ld [wCurPartyLevel+1], a - cp $02 - jr c, .sub_caa0 - jr .sub_caa0 -.sub_ca9f - pop hl -.sub_caa0 - ret - - -SECTION "engine/dumps/bank03.asm@Functiond41d", ROMX - -Functiond41d: - push hl - call Functiond4b2 - ld a, [wItemAttributeValue] - and a - jr nz, .sub_d45f - ld a, [wCurItem] - ld [wce37], a - call GetItemName - call CopyStringToStringBuffer2 - ld hl, ItemsThrowAwayText - call MenuTextBox - call YesNoBox - call CloseWindow - jr c, .sub_d468 - ld a, [wItemIndex] - pop hl - call TossItem - ld a, [wCurItem] - ld [wce37], a - call GetItemName - call CopyStringToStringBuffer2 - ld hl, ItemsDiscardedText - call MenuTextBox - call CloseWindow - and a - ret -.sub_d45f - ld hl, ItemsTooImportantText - call MenuTextBox - call CloseWindow -.sub_d468 - pop hl - scf - ret - -ItemsDiscardedText: - text_from_ram wStringBuffer1 - text "を" ; "Threw away" - line "すてました!" ; "(item?)!" - prompt - -ItemsThrowAwayText: - text_from_ram wStringBuffer2 - text "を すてます" ; "Are you sure you want" - line "ほんとに よろしいですか?" ; "to throw (item?) away?" - prompt - -ItemsTooImportantText: - text "それは とても たいせつなモノです" ; "You can't throw away" - line "すてることは できません!" ; "something that special!" - prompt - -Functiond4b2: - push hl - push bc - ld a, $01 - ld [wItemAttributeValue], a - ld a, [wCurItem] - cp $c4 - jr nc, .sub_d4d7 - ld hl, ItemAttributes + 4 - dec a - ld c, a - ld b, $00 - add hl, bc - add hl, bc - add hl, bc - add hl, bc - add hl, bc - ld a, BANK(ItemAttributes) - call GetFarByte - bit 0, a - jr nz, .sub_d4e3 - jr .sub_d4df -.sub_d4d7 - ld a, [wCurItem] - call IsHM - jr c, .sub_d4e3 -.sub_d4df - xor a - ld [wItemAttributeValue], a -.sub_d4e3 - pop bc - pop hl - ret - -Functiond4e6: - ld a, [wPlayerStepFlags] - and a - ret z - bit PLAYERSTEP_START_F, a - jr nz, .sub_d4f8 - bit PLAYERSTEP_STOP_F, a - jr nz, Functiond519 - bit PLAYERSTEP_CONTINUE_F, a - jr nz, Functiond543 - ret -.sub_d4f8 - jr Functiond505 - -Functiond4fa: - call Functiond51e - callfar EmptyFunction8261 - -Functiond505: - ld a, $04 - ld [wcdb2], a - ldh a, [hOverworldFlashlightEffect] - and a - jr nz, .sub_d514 - call Functiond5f3 - jr Functiond543 -.sub_d514 - call Functiond708 - jr Functiond543 - -Functiond519: - call Functiond51e - jr Functiond543 - -Functiond51e: - ld a, [wPlayerStepDirection] - and a - jr nz, .sub_d529 - ld hl, wYCoord - inc [hl] - ret -.sub_d529 - cp $01 - jr nz, .sub_d532 - ld hl, wYCoord - dec [hl] - ret -.sub_d532 - cp $02 - jr nz, .sub_d53b - ld hl, wXCoord - dec [hl] - ret -.sub_d53b - cp $03 - ret nz - ld hl, wXCoord - inc [hl] - ret - -Functiond543: - call .sub_d5bf - ld a, [wPlayerStepVectorX] - ld d, a - ld a, [wPlayerStepVectorY] - ld e, a - call .sub_d55f - call .sub_d591 - ldh a, [hSCX] - add d - ldh [hSCX], a - ldh a, [hSCY] - add e - ldh [hSCY], a - ret -.sub_d55f - ld bc, wObjectStructs - xor a -.sub_d563 - ldh [hConnectionStripLength], a - ld hl, $0000 - add hl, bc - ld a, [hl] - and a - jr z, .sub_d583 - ld hl, $0004 - add hl, bc - bit 7, [hl] - jr nz, .sub_d583 - ld hl, $0018 - add hl, bc - ld a, [hl] - sub d - ld [hl], a - ld hl, $0019 - add hl, bc - ld a, [hl] - sub e - ld [hl], a -.sub_d583 - ld hl, $0028 - add hl, bc - ld b, h - ld c, l - ldh a, [hConnectionStripLength] - inc a - cp $0a - jr nz, .sub_d563 - ret -.sub_d591 - ld bc, wMinorObjects - ld a, $01 -.sub_d596 - ldh [hConnectionStripLength], a - ld hl, $0000 - add hl, bc - ld a, [wCenteredObject] - inc a - cp [hl] - jr z, .sub_d5b1 - ld hl, $0004 - add hl, bc - ld a, [hl] - sub d - ld [hl], a - ld hl, $0005 - add hl, bc - ld a, [hl] - sub e - ld [hl], a -.sub_d5b1 - ld hl, $0010 - add hl, bc - ld b, h - ld c, l - ldh a, [hConnectionStripLength] - inc a - cp $05 - jr nz, .sub_d596 - ret -.sub_d5bf - ld hl, wcdb2 - ld a, [hl] - and a - ret z - dec [hl] - ld a, [hl] - add a - ld e, a - ld d, $00 - ld hl, Tabled5d3 - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - jp hl - -Tabled5d3: - dw RefreshTiles - dw Functiond5ea - dw BufferScreen - dw Functiond5e9 - dw Functiond5e9 - dw Functiond5e9 - dw Functiond5e9 - dw Functiond5e9 - dw Functiond5e9 - dw Functiond5e9 - dw Functiond5e9 - -Functiond5e9: - ret - -Functiond5ea: - ld hl, Functionc9c1 - ld a, BANK(Functionc9c1) - call FarCall_hl - ret - -Functiond5f3: - ld a, [wPlayerStepDirection] - and a - jr z, .sub_d606 - cp $01 - jr z, .sub_d610 - cp $02 - jr z, .sub_d61a - cp $03 - jr z, .sub_d624 - ret -.sub_d606 - call Functiond62e - call LoadMapPart - call ScheduleSouthRowRedraw - ret -.sub_d610 - call Functiond65f - call LoadMapPart - call ScheduleNorthRowRedraw - ret -.sub_d61a - call Functiond692 - call LoadMapPart - call ScheduleWestColumnRedraw - ret -.sub_d624 - call Functiond6bb - call LoadMapPart - call ScheduleEastColumnRedraw - ret - -Functiond62e: - ld a, [wBGMapAnchor] - add $40 - ld [wBGMapAnchor], a - jr nc, .sub_d643 - ld a, [wBGMapAnchor+1] - inc a - and $03 - or $98 - ld [wBGMapAnchor+1], a -.sub_d643 - ld hl, wMetatileNextY - inc [hl] - ld a, [hl] - cp $02 - jr nz, .sub_d651 - ld [hl], $00 - call .sub_d652 -.sub_d651 - ret -.sub_d652 - ld hl, wOverworldMapAnchor - ld a, [wMapWidth] - add $06 - add [hl] - ld [hli], a - ret nc - inc [hl] - ret - -Functiond65f: - ld a, [wBGMapAnchor] - sub $40 - ld [wBGMapAnchor], a - jr nc, .sub_d674 - ld a, [wBGMapAnchor+1] - dec a - and $03 - or $98 - ld [wBGMapAnchor+1], a -.sub_d674 - ld hl, wMetatileNextY - dec [hl] - ld a, [hl] - cp $ff - jr nz, .sub_d682 - ld [hl], $01 - call .sub_d683 -.sub_d682 - ret -.sub_d683 - ld hl, wOverworldMapAnchor - ld a, [wMapWidth] - add $06 - ld b, a - ld a, [hl] - sub b - ld [hli], a - ret nc - dec [hl] - ret - -Functiond692: - ld a, [wBGMapAnchor] - ld e, a - and $e0 - ld d, a - ld a, e - sub $02 - and $1f - or d - ld [wBGMapAnchor], a - ld hl, wMetatileNextX - dec [hl] - ld a, [hl] - cp $ff - jr nz, .sub_d6b0 - ld [hl], $01 - call .sub_d6b1 -.sub_d6b0 - ret -.sub_d6b1 - ld hl, wOverworldMapAnchor - ld a, [hl] - sub $01 - ld [hli], a - ret nc - dec [hl] - ret - -Functiond6bb: - ld a, [wBGMapAnchor] - ld e, a - and $e0 - ld d, a - ld a, e - add $02 - and $1f - or d - ld [wBGMapAnchor], a - ld hl, wMetatileNextX - inc [hl] - ld a, [hl] - cp $02 - jr nz, .sub_d6d9 - ld [hl], $00 - call .sub_d6da -.sub_d6d9 - ret -.sub_d6da - ld hl, wOverworldMapAnchor - ld a, [hl] - add $01 - ld [hli], a - ret nc - inc [hl] - ret - -Functiond6e4: - ld a, [wPlayerStepFlags] - and a - ret z - bit PLAYERSTEP_START_F, a - jr nz, .sub_d6f7 - bit PLAYERSTEP_STOP_F, a - jr nz, .sub_d702 - bit PLAYERSTEP_CONTINUE_F, a - jp nz, Functiond543 - ret -.sub_d6f7 - ld a, $04 - ld [wcdb2], a - call Functiond708 - jp Functiond543 -.sub_d702 - call Functiond51e - jp Functiond543 - -Functiond708: - ld a, [wPlayerStepDirection] - and a - jr z, .sub_d71b - cp $01 - jr z, .sub_d727 - cp $02 - jr z, .sub_d733 - cp $03 - jr z, .sub_d73f - ret -.sub_d71b - call Functiond62e - call LoadMapPart - ld a, $02 - call .sub_d74b - ret -.sub_d727 - call Functiond65f - call LoadMapPart - ld a, $01 - call .sub_d74b - ret -.sub_d733 - call Functiond692 - call LoadMapPart - ld a, $03 - call .sub_d74b - ret -.sub_d73f - call Functiond6bb - call LoadMapPart - ld a, $04 - call .sub_d74b - ret -.sub_d74b - push af - call .sub_d758 - call Functiond873 - pop af - add $02 - ldh [hRedrawRowOrColumnMode], a - ret -.sub_d758 - dec a - ld l, a - ld h, $00 - add hl, hl - add hl, hl - add hl, hl - ldh a, [hOverworldFlashlightEffect] - dec a - swap a - sla a - ld e, a - ld d, $00 - add hl, de - ld de, Datad7b1 - add hl, de - call Functiond831 - ld a, e - ld [wOverworldMapBlocksEnd], a - ld a, d - ld [wRedrawFlashlightDst0+1], a - call Functiond85f - ld a, e - ld [wRedrawFlashlightSrc0], a - ld a, d - ld [wRedrawFlashlightSrc0+1], a - call Functiond831 - ld a, e - ld [wRedrawFlashlightBlackDst0], a - ld a, d - ld [wRedrawFlashlightBlackDst0+1], a - call Functiond831 - ld a, e - ld [wRedrawFlashlightDst1], a - ld a, d - ld [wRedrawFlashlightDst1+1], a - call Functiond85f - ld a, e - ld [wRedrawFlashlightSrc1], a - ld a, d - ld [wRedrawFlashlightSrc1+1], a - call Functiond831 - ld a, e - ld [wRedrawFlashlightBlackDst1], a - ld a, d - ld [wRedrawFlashlightBlackDst1+1], a - ret - -Datad7b1: - db $02, $03, $02, $11, $02, $02, $02, $10 - db $02, $0e, $02, $00, $02, $0f, $02, $01 - db $03, $02, $11, $02, $02, $02, $10, $02 - db $0e, $02, $00, $02, $0f, $02, $01, $02 - db $04, $05, $04, $0f, $04, $04, $04, $0e - db $04, $0c, $04, $02, $04, $0d, $04, $03 - db $05, $04, $0f, $04, $04, $04, $0e, $04 - db $0c, $04, $02, $04, $0d, $04, $03, $04 - db $06, $07, $06, $0d, $06, $06, $06, $0c - db $06, $0a, $06, $04, $06, $0b, $06, $05 - db $07, $06, $0d, $06, $06, $06, $0c, $06 - db $0a, $06, $04, $06, $0b, $06, $05, $06 - db $08, $09, $08, $0b, $08, $08, $08, $0a - db $08, $08, $08, $06, $08, $09, $08, $07 - db $09, $08, $0b, $08, $08, $08, $0a, $08 - db $08, $08, $06, $08, $09, $08, $07, $08 - -Functiond831: - ld c, [hl] - inc hl - ld b, [hl] - inc hl - push hl - push bc - ld a, [wBGMapAnchor] - ld e, a - ld a, [wBGMapAnchor+1] - ld d, a -.sub_d83f - ld a, $20 - add e - ld e, a - jr nc, .sub_d846 - inc d -.sub_d846 - ld a, d - and $03 - or $98 - ld d, a - dec b - jr nz, .sub_d83f -.sub_d84f - ld a, e - inc a - and $1f - ld b, a - ld a, e - and $e0 - or b - ld e, a - dec c - jr nz, .sub_d84f - pop bc - pop hl - ret - -Functiond85f: - push hl - ld hl, wTileMap - ld de, $0014 -.sub_d866 - ld a, b - and a - jr z, .sub_d86e - add hl, de - dec b - jr .sub_d866 -.sub_d86e - add hl, bc - ld e, l - ld d, h - pop hl - ret - -Functiond873: - ldh a, [hOverworldFlashlightEffect] - dec a - ld l, a - ld h, $00 - ld de, Datad882 - add hl, de - ld a, [hl] - ld [wRedrawFlashlightWidthHeight], a - ret - -Datad882: - db $07, $05, $03, $01 - -Functiond886: - ld de, wPartyCount - ld a, [wMonType] - and $0f - jr z, .sub_d893 - ld de, wOTPartyCount -.sub_d893 - ld a, [de] - inc a - cp $07 - ret nc - ld [de], a - ld a, [de] - ldh [hMoveMon], a - add e - ld e, a - jr nc, .sub_d8a1 - inc d -.sub_d8a1 - ld a, [wCurPartySpecies] - ld [de], a - inc de - ld a, $ff - ld [de], a - ld hl, wPartyMon6StatsEnd - ld a, [wMonType] - and $0f - jr z, Functiond8b6 - ld hl, wOTPartyMonOT - -Functiond8b6: - ldh a, [hMoveMon] - dec a - call SkipNames - ld d, h - ld e, l - ld hl, wPlayerName - ld bc, $0006 - call CopyBytes - ld a, [wMonType] - and a - jr nz, .sub_d8ea - ld a, [wCurPartySpecies] - ld [wce37], a - call GetPokemonName - ld hl, wPartyMonNicknames - ldh a, [hMoveMon] - dec a - call SkipNames - ld d, h - ld e, l - ld hl, wStringBuffer1 - ld bc, $0006 - call CopyBytes -.sub_d8ea - ld hl, wPartyMon1 - ld a, [wMonType] - and $0f - jr z, .sub_d8f7 - ld hl, wWildMons -.sub_d8f7 - ldh a, [hMoveMon] - dec a - ld bc, $0030 - call AddNTimes - ld e, l - ld d, h - push hl - ld a, [wCurPartySpecies] - ld [wCurSpecies], a - call GetBaseData - ld a, [wMonHeader] - ld [de], a - inc de - ld a, [wBattleMode] - and a - jr z, .sub_d91b - ld a, [wEnemyMonItem] - ld [de], a -.sub_d91b - inc de - push de - xor a - ld [wFieldMoveScriptID], a - predef FillMoves - pop de - inc de - inc de - inc de - inc de - ld a, [wPlayerID] - ld [de], a - inc de - ld a, [wPlayerID + 1] - ld [de], a - inc de - push de - ld a, [wCurPartyLevel] - ld d, a - ld hl, CalcExpAtLevel - ld a, BANK(CalcExpAtLevel) - call FarCall_hl - pop de - ldh a, [hMultiplicand] - ld [de], a - inc de - ldh a, [hDividend+2] - ld [de], a - inc de - ldh a, [hDividend+3] - ld [de], a - inc de - xor a - ld b, $0a -.sub_d952 - ld [de], a - inc de - dec b - jr nz, .sub_d952 - pop hl - push hl - ld a, [wMonType] - and $0f - ld a, $98 - ld b, $88 - jr nz, .sub_d99a - ld a, [wCurPartySpecies] - ld [wce37], a - dec a - ld c, a - ld b, $02 - ld hl, wPartyMonNicknamesEnd - push de - ld d, $03 - call SmallFarFlagAction - pop de - ld a, c - ld a, [wce37] - dec a - ld c, a - ld b, $01 - push bc - call SmallFarFlagAction - pop bc - ld hl, wEndPokedexCaught - call SmallFarFlagAction - pop hl - push hl - ld a, [wBattleMode] - and a - jr nz, .sub_d9d3 - call Random - ld b, a - call Random -.sub_d99a - ld [de], a - inc de - ld a, b - ld [de], a - inc de - push hl - push de - inc hl - inc hl - call FillPP - pop de - pop hl - inc de - inc de - inc de - inc de - ld a, $46 - ld [de], a - inc de - inc de - inc de - inc de - ld a, [wCurPartyLevel] - ld [de], a - inc de - xor a - ld [de], a - inc de - ld [de], a - inc de - ld bc, $000a - add hl, bc - ld a, $01 - ld c, a - xor a - ld b, a - call CalcMonStatC - ldh a, [hDividend+2] - ld [de], a - inc de - ldh a, [hDividend+3] - ld [de], a - inc de - jr .sub_da0a -.sub_d9d3 - ld a, [wEnemyMonDVs] - ld [de], a - inc de - ld a, [wEnemyMonDVs + 1] - ld [de], a - inc de - push hl - ld hl, wEnemyMonPP - ld b, $04 -.sub_d9e3 - ld a, [hli] - ld [de], a - inc de - dec b - jr nz, .sub_d9e3 - pop hl - ld a, $46 - ld [de], a - inc de - inc de - inc de - inc de - ld a, [wCurPartyLevel] - ld [de], a - inc de - ld a, [wEnemyMonStatus] - ld [de], a - inc de - ld a, [wEnemyMonStatus + 1] - ld [de], a - inc de - ld a, [wEnemyMonHP] - ld [de], a - inc de - ld a, [wEnemyMonHP + 1] - ld [de], a - inc de -.sub_da0a - ld a, [wBattleMode] - dec a - jr nz, .sub_da1c - ld hl, wEnemyMonMaxHP - ld bc, $000c - call CopyBytes - pop hl - jr .sub_da26 -.sub_da1c - pop hl - ld bc, $000a - add hl, bc - ld b, $00 - call CalcMonStats -.sub_da26 - scf - ret - -FillPP: - ld b, $04 -.sub_da2a - ld a, [hli] - and a - jr z, .sub_da49 - dec a - push hl - push de - push bc - ld hl, Functiond8b6 - ld bc, $0007 - call AddNTimes - ld de, wStringBuffer1 - ld a, $10 - call FarCopyBytes - pop bc - pop de - pop hl - ld a, [wStringBuffer1+5] -.sub_da49 - ld [de], a - inc de - dec b - jr nz, .sub_da2a - ret - - -Functionda4f: - ld hl, wPartyCount - ld a, [hl] - cp $06 - scf - ret z - inc a - ld [hl], a - ld c, a - ld b, $00 - add hl, bc - ld a, [wCurPartySpecies] - ld [hli], a - ld [hl], $ff - ld hl, wPartyMon1 - ld a, [wPartyCount] - dec a - ld bc, $0030 - call AddNTimes - ld e, l - ld d, h - ld hl, wTempMon - call CopyBytes - ld hl, wPartyMon6StatsEnd - ld a, [wPartyCount] - dec a - call SkipNames - ld d, h - ld e, l - ld hl, wOTPartyMonOT - ld a, [wCurPartyMon] - call SkipNames - ld bc, $0006 - call CopyBytes - ld hl, wPartyMonNicknames - ld a, [wPartyCount] - dec a - call SkipNames - ld d, h - ld e, l - ld hl, wOTPartyMonNicknames - ld a, [wCurPartyMon] - call SkipNames - ld bc, $0006 - call CopyBytes - ld a, [wCurPartySpecies] - ld [wce37], a - dec a - ld c, a - ld b, $01 - ld hl, wPartyMonNicknamesEnd - push bc - call SmallFarFlagAction - pop bc - ld hl, wEndPokedexCaught - call SmallFarFlagAction - and a - ret - -Functiondac8: - ld a, [wPokemonWithdrawDepositParameter] - and a - jr z, .sub_dae3 - cp $02 - jr z, .sub_dae3 - cp $03 - ld hl, wd882 - jr z, .sub_db1f - ld hl, wBoxListLength - ld a, [hl] - cp $1e - jr nz, .sub_daed - jr .sub_daeb -.sub_dae3 - ld hl, wPartyCount - ld a, [hl] - cp $06 - jr nz, .sub_daed -.sub_daeb - scf - ret -.sub_daed - inc a - ld [hl], a - ld c, a - ld b, $00 - add hl, bc - ld a, [wPokemonWithdrawDepositParameter] - cp $02 - ld a, [wd882] - jr z, .sub_db00 - ld a, [wCurPartySpecies] -.sub_db00 - ld [hli], a - ld [hl], $ff - ld a, [wPokemonWithdrawDepositParameter] - dec a - ld hl, wPartyMon1 - ld bc, $0030 - ld a, [wPartyCount] - jr nz, .sub_db1b - ld hl, wBoxMon1 - ld bc, $0020 - ld a, [wBoxListLength] -.sub_db1b - dec a - call AddNTimes -.sub_db1f - push hl - ld e, l - ld d, h - ld a, [wPokemonWithdrawDepositParameter] - and a - ld hl, wBoxMon1 - ld bc, BOXMON_STRUCT_LENGTH - jr z, .sub_db3b - cp $02 - ld hl, wd882 - jr z, .sub_db41 - ld hl, wPartyMon1 - ld bc, PARTYMON_STRUCT_LENGTH -.sub_db3b - ld a, [wCurPartyMon] - call AddNTimes -.sub_db41 - ld bc, BOXMON_STRUCT_LENGTH - call CopyBytes - ld a, [wPokemonWithdrawDepositParameter] - cp $03 - ld de, wBufferMonOT - jr z, .sub_db66 - dec a - ld hl, wPartyMon6StatsEnd - ld a, [wPartyCount] - jr nz, .sub_db60 - ld hl, wBoxMonOT - ld a, [wBoxListLength] -.sub_db60 - dec a - call SkipNames - ld d, h - ld e, l -.sub_db66 - ld hl, wBoxMonOT - ld a, [wPokemonWithdrawDepositParameter] - and a - jr z, .sub_db79 - ld hl, wBufferMonOT - cp $02 - jr z, .sub_db7f - ld hl, wPartyMon6StatsEnd -.sub_db79 - ld a, [wCurPartyMon] - call SkipNames -.sub_db7f - ld bc, PLAYER_NAME_LENGTH - call CopyBytes - ld a, [wPokemonWithdrawDepositParameter] - cp $03 - ld de, wBufferMonNickname - jr z, .sub_dba4 - dec a - ld hl, wPartyMonNicknames - ld a, [wPartyCount] - jr nz, .sub_db9e - ld hl, wBoxMonNicknames - ld a, [wBoxListLength] -.sub_db9e - dec a - call SkipNames - ld d, h - ld e, l -.sub_dba4 - ld hl, wBoxMonNicknames - ld a, [wPokemonWithdrawDepositParameter] - and a - jr z, .sub_dbb7 - ld hl, wBufferMonNickname - cp $02 - jr z, .sub_dbbd - ld hl, wPartyMonNicknames -.sub_dbb7 - ld a, [wCurPartyMon] - call SkipNames -.sub_dbbd - ld bc, $0006 - call CopyBytes - pop hl - ld a, [wPokemonWithdrawDepositParameter] - cp $01 - jr z, .sub_dc14 - cp $03 - jr z, .sub_dc14 - push hl - srl a - add $02 - ld [wMonType], a - predef CopyMonToTempMon - ld a, BANK(Function50caa) - ld hl, Function50caa - call FarCall_hl - ld a, d - ld [wCurPartyLevel], a - pop hl - ld b, h - ld c, l - ld hl, $001f - add hl, bc - ld [hl], a - ld hl, $0024 - add hl, bc - ld d, h - ld e, l - ld hl, $000a - add hl, bc - push bc - ld b, $01 - call CalcMonStats - pop bc - ld a, [wPokemonWithdrawDepositParameter] - and a - jr nz, .sub_dc14 - ld hl, $0022 - add hl, bc - ld d, h - ld e, l - inc hl - inc hl - ld a, [hli] - ld [de], a - ld a, [hl] - inc de - ld [de], a -.sub_dc14 - and a - ret - -Functiondc16: - ld hl, wPartyCount - ld a, [hl] - cp $06 - push af - jr nz, .sub_dc2a - ld hl, wBoxListLength - ld a, [hl] - cp $1e - jr nz, .sub_dc2a - pop af - scf - ret -.sub_dc2a - inc a - ld [hl], a - ld c, a - ld b, $00 - add hl, bc - ld a, [wPokemonWithdrawDepositParameter] - and a - ld a, [wd882] - ld de, wBufferMonNickname - jr z, .sub_dc42 - ld a, [wBreedMon1Species] - ld de, wBreedMon1Nickname -.sub_dc42 - ld [hli], a - ld [wCurSpecies], a - ld a, $ff - ld [hl], a - pop af - jr z, .sub_dcad - ld hl, wPartyMonNicknames - ld a, [wPartyCount] - dec a - ld bc, $0006 - call AddNTimes - push hl - ld h, d - ld l, e - pop de - call CopyBytes - push hl - ld hl, wPartyMon6StatsEnd - ld a, [wPartyCount] - dec a - ld bc, $0006 - call AddNTimes - ld d, h - ld e, l - pop hl - call CopyBytes - push hl - ld hl, wPartyMon1 - ld a, [wPartyCount] - dec a - ld bc, $0030 - call AddNTimes - ld d, h - ld e, l - pop hl - ld bc, $0020 - call CopyBytes - call GetBaseData - ld h, d - ld l, e - dec hl - ld a, [hl] - ld [wCurPartyLevel], a - inc de - inc de - push de - inc de - inc de - push de - ld bc, hFFEB - add hl, bc - ld b, $01 - call CalcMonStats - pop hl - pop de - ld a, [hli] - ld [de], a - inc de - ld a, [hl] - ld [de], a - jr .sub_dce9 -.sub_dcad - ld hl, wBoxMonNicknames - ld a, [wBoxListLength] - ld bc, $0006 - call AddNTimes - push hl - ld h, d - ld l, e - pop de - call CopyBytes - push hl - ld hl, wBoxMonOT - ld a, [wBoxListLength] - ld bc, $0006 - call AddNTimes - ld d, h - ld e, l - pop hl - call CopyBytes - push hl - ld hl, wBoxMon1 - ld a, [wBoxListLength] - ld bc, $0030 - call AddNTimes - ld d, h - ld e, l - pop hl - ld bc, $0020 - call CopyBytes -.sub_dce9 - ld a, [wPokemonWithdrawDepositParameter] - and a - ret z - ld hl, wBreedMon2Nickname - ld de, wBreedMon1Nickname - ld bc, $002c - call CopyBytes - and a - ret - -Functiondcfc: - ld a, [wPokemonWithdrawDepositParameter] - ld de, wBufferMonNickname - and a - jr z, .sub_dd2c - ld hl, wBreedMon1Nickname - ld de, wBreedMon2Nickname - ld bc, $0006 - call CopyBytes - ld hl, wBreedMon1OT - ld de, wBreedMon2OT - ld bc, $0006 - call CopyBytes - ld hl, wBreedMon1 - ld de, wBreedMon2 - ld bc, $0020 - call CopyBytes - ld de, wBreedMon1Nickname -.sub_dd2c - ld a, [wCurPartyMon] - ld hl, wPartyMonNicknames - ld bc, $0006 - call AddNTimes - call CopyBytes - ld a, [wCurPartyMon] - ld hl, wPartyMon6StatsEnd - ld bc, $0006 - call AddNTimes - call CopyBytes - ld a, [wCurPartyMon] - ld hl, wPartyMon1 - ld bc, $0030 - call AddNTimes - ld bc, $0020 - jp CopyBytes - -Functiondd5c: - ld de, wBoxListLength - ld a, [de] - cp MONS_PER_BOX - ret nc - inc a - ld [de], a - ld a, [wCurPartySpecies] - ld [wCurSpecies], a - ld c, a -.sub_dd6c - inc de - ld a, [de] - ld b, a - ld a, c - ld c, b - ld [de], a - cp $ff - jr nz, .sub_dd6c - call GetBaseData - ld hl, wBoxMonOT - ld bc, PLAYER_NAME_LENGTH - ld a, [wBoxListLength] - dec a - jr z, .sub_dda9 - dec a - call AddNTimes - push hl - ld bc, $0006 - add hl, bc - ld d, h - ld e, l - pop hl - ld a, [wBoxListLength] - dec a - ld b, a -.sub_dd96 - push bc - push hl - ld bc, $0006 - call CopyBytes - pop hl - ld d, h - ld e, l - ld bc, $fffa - add hl, bc - pop bc - dec b - jr nz, .sub_dd96 -.sub_dda9 - ld hl, wPlayerName - ld de, wBoxMonOT - ld bc, $0006 - call CopyBytes - ld a, [wBoxListLength] - dec a - jr z, .sub_dde5 - ld hl, wBoxMonNicknames - ld bc, $0006 - dec a - call AddNTimes - push hl - ld bc, $0006 - add hl, bc - ld d, h - ld e, l - pop hl - ld a, [wBoxListLength] - dec a - ld b, a -.sub_ddd2 - push bc - push hl - ld bc, $0006 - call CopyBytes - pop hl - ld d, h - ld e, l - ld bc, $fffa - add hl, bc - pop bc - dec b - jr nz, .sub_ddd2 -.sub_dde5 - ld a, [wCurPartySpecies] - ld [wce37], a - call GetPokemonName - ld de, wBoxMonNicknames - ld hl, wStringBuffer1 - ld bc, $0006 - call CopyBytes - ld a, [wBoxListLength] - dec a - jr z, .sub_de2a - ld hl, wBoxMon1 - ld bc, $0020 - dec a - call AddNTimes - push hl - ld bc, $0020 - add hl, bc - ld d, h - ld e, l - pop hl - ld a, [wBoxListLength] - dec a - ld b, a -.sub_de17 - push bc - push hl - ld bc, $0020 - call CopyBytes - pop hl - ld d, h - ld e, l - ld bc, hBGMapAddress - add hl, bc - pop bc - dec b - jr nz, .sub_de17 -.sub_de2a - ld hl, wEnemyMon - ld de, wBoxMon1 - ld bc, $0006 - call CopyBytes - ld hl, wPlayerID - ld a, [hli] - ld [de], a - inc de - ld a, [hl] - ld [de], a - inc de - push de - ld a, [wCurPartyLevel] - ld d, a - ld hl, CalcExpAtLevel - ld a, BANK(CalcExpAtLevel) - call FarCall_hl - pop de - ldh a, [hMultiplicand] - ld [de], a - inc de - ldh a, [hDividend+2] - ld [de], a - inc de - ldh a, [hDividend+3] - ld [de], a - inc de - xor a - ld b, $0a -.sub_de5c - ld [de], a - inc de - dec b - jr nz, .sub_de5c - ld hl, wEnemyMonDVs - ld b, $07 -.sub_de66 - ld a, [hli] - ld [de], a - inc de - dec b - jr nz, .sub_de66 - xor a - ld [de], a - inc de - ld [de], a - inc de - ld [de], a - inc de - ld a, [wCurPartyLevel] - ld [de], a - scf - ret - -Functionde79: - ld a, [wPartyCount] - cp $06 - jr z, .sub_de8b - call Functiond886 - ld de, wPartyMonNicknames - ld hl, wPartyCount - jr .sub_dead -.sub_de8b - ld a, [wBoxListLength] - cp $1e - scf - ret z - ld a, [wCurPartySpecies] - ld [wTempEnemyMonSpecies], a - xor a - ld [wEnemySubStatus5], a - ld hl, LoadEnemyMon - ld a, BANK(LoadEnemyMon) - call FarCall_hl - call Functiondd5c - ld de, wBoxMonNicknames - ld hl, wBoxListLength -.sub_dead - ld a, [hl] - push af - ld b, $00 - ld c, a - add hl, bc - ld a, $fd - ld [hl], a - pop af - dec a - ld h, d - ld l, e - ld bc, $0006 - call AddNTimes - ld a, $c0 - ld [hli], a - ld a, $cf - ld [hli], a - ld a, $2a - ld [hli], a - ld [hl], $50 - and a - ret - -Functiondecd: - ld hl, wPartyCount - ld a, [wPokemonWithdrawDepositParameter] - and a - jr z, .sub_ded9 - ld hl, wBoxListLength -.sub_ded9 - ld a, [hl] - dec a - ld [hli], a - ld a, [wCurPartyMon] - ld c, a - ld b, $00 - add hl, bc - ld e, l - ld d, h - inc de -.sub_dee6 - ld a, [de] - inc de - ld [hli], a - inc a - jr nz, .sub_dee6 - ld hl, wPartyMon6StatsEnd - ld d, $05 - ld a, [wPokemonWithdrawDepositParameter] - and a - jr z, .sub_defc - ld hl, wBoxMonOT - ld d, $1d -.sub_defc - ld a, [wCurPartyMon] - call SkipNames - ld a, [wCurPartyMon] - cp d - jr nz, .sub_df0b - ld [hl], $ff - ret -.sub_df0b - ld d, h - ld e, l - ld bc, $0006 - add hl, bc - ld bc, wPartyMonNicknames - ld a, [wPokemonWithdrawDepositParameter] - and a - jr z, .sub_df1d - ld bc, wBoxMonNicknames -.sub_df1d - call CopyDataUntil - ld hl, wPartyMon1 - ld bc, $0030 - ld a, [wPokemonWithdrawDepositParameter] - and a - jr z, .sub_df32 - ld hl, wBoxMon1 - ld bc, $0020 -.sub_df32 - ld a, [wCurPartyMon] - call AddNTimes - ld d, h - ld e, l - ld a, [wPokemonWithdrawDepositParameter] - and a - jr z, .sub_df49 - ld bc, $0020 - add hl, bc - ld bc, wBoxMonOT - jr .sub_df50 -.sub_df49 - ld bc, $0030 - add hl, bc - ld bc, wPartyMon6StatsEnd -.sub_df50 - call CopyDataUntil - ld hl, wPartyMonNicknames - ld a, [wPokemonWithdrawDepositParameter] - and a - jr z, .sub_df5f - ld hl, wBoxMonNicknames -.sub_df5f - ld bc, $0006 - ld a, [wCurPartyMon] - call AddNTimes - ld d, h - ld e, l - ld bc, $0006 - add hl, bc - ld bc, wPartyMonNicknamesEnd - ld a, [wPokemonWithdrawDepositParameter] - and a - jr z, .sub_df7a - ld bc, wBoxMonNicknamesEnd -.sub_df7a - jp CopyDataUntil - -CalcMonStats: - ld c, $00 + ld a, 2 ; skip the player .loop - inc c - call CalcMonStatC - ldh a, [hMultiplicand + 1] - ld [de], a - inc de - ldh a, [hMultiplicand + 2] - ld [de], a - inc de - ld a, c - cp STAT_SDEF + push af + push de + ld hl, MAPOBJECT_PALETTE + add hl, de + ld a, [hl] + cp 0 + jr nz, .skip + + ld hl, MAPOBJECT_OBJECT_STRUCT_ID + add hl, de + ld a, [hl] + cp -1 + jr z, .skip + call .check_inline_trainer + +.skip + pop de + ld hl, MAPOBJECT_LENGTH + add hl, de + ld d, h + ld e, l + pop af + inc a + cp NUM_OBJECTS jr nz, .loop ret -CalcMonStatC: -; 'c' is 1-6 and points to the BaseStat -; 1: HP -; 2: Attack -; 3: Defense -; 4: Speed -; 5: SpAtk -; 6: SpDef - push hl - push de - push bc - ld a, b - ld d, a - - push hl - ld hl, wMonHBaseStats - dec hl - ld b, $0 - add hl, bc - ld a, [hl] - ld e, a - pop hl - push hl - ld a, c -; Special defense shares stat exp with special attack - cp STAT_SDEF - jr nz, .not_spdef - dec hl - dec hl - -.not_spdef - sla c - ld a, d - and a - jr z, .no_stat_exp - add hl, bc - -.sqrt_loop - xor a - ldh [hMultiplicand], a - ldh [hMultiplicand + 1], a - inc b - ld a, b - cp -1 - jr z, .no_stat_exp - - ldh [hMultiplicand + 2], a - ldh [hMultiplier], a - call Multiply - - ld a, [hld] - ld d, a - ldh a, [hProduct + 3] - sub d - ld a, [hli] - ld d, a - ldh a, [hProduct + 2] - sbc d - jr c, .sqrt_loop - -.no_stat_exp - srl c - pop hl - push bc - ld bc, MON_DVS - MON_HP_EXP + 1 - add hl, bc - pop bc - ld a, c - cp STAT_ATK - jr z, .Attack - cp STAT_DEF - jr z, .Defense - cp STAT_SPD - jr z, .Speed - cp STAT_SATK - jr z, .Special - cp STAT_SDEF - jr z, .Special -; DV_HP = (DV_ATK & 1) << 3 | (DV_DEF & 1) << 2 | (DV_SPD & 1) << 1 | (DV_SPC & 1) - push bc - ld a, [hl] - swap a - and $01 - add a - add a - add a - ld b, a - ld a, [hli] - and $01 - add a - add a - add b - ld b, a - ld a, [hl] - swap a - and $01 - add b - add b - ld b, a - ld a, [hl] - and $01 - add b - pop bc - jr .GotDV - -.Attack - ld a, [hl] - swap a - and $f - jr .GotDV - -.Defense - ld a, [hl] - and $f - jr .GotDV - -.Speed - inc hl - ld a, [hl] - swap a - and $f - jr .GotDV - -.Special - inc hl - ld a, [hl] - and $f - -.GotDV - ld d, $00 - add e - ld e, a - jr nc, .no_overflow_1 - inc d - -.no_overflow_1 - sla e - rl d - srl b - srl b - ld a, b - add e - jr nc, .no_overflow_2 - inc d - -.no_overflow_2 - ldh [hMultiplicand + 2], a - ld a, d - ldh [hMultiplicand + 1], a - xor a - ldh [hMultiplicand], a - ld a, [wCurPartyLevel] - ldh [hMultiplier], a - call Multiply - - ldh a, [hProduct + 1] - ldh [hDividend], a - ldh a, [hMultiplicand + 1] - ldh [hDividend + 1], a - ldh a, [hMultiplicand + 2] - ldh [hDividend + 2], a - ld a, MAX_LEVEL - ldh [hDivisor], a - ld a, 3 - ld b, a - call Divide - - ld a, c - cp STAT_HP - ld a, STAT_MIN_NORMAL - jr nz, .not_hp - ld a, [wCurPartyLevel] - ld b, a - ldh a, [hDividend+3] - add b - ldh [hDividend+3], a - jr nc, .no_overflow_3 - ldh a, [hDividend+2] - inc a - ldh [hDividend+2], a - -.no_overflow_3 - ld a, STAT_MIN_HP - -.not_hp - ld b, a - ldh a, [hDividend+3] - add b - ldh [hDividend+3], a - jr nc, .no_overflow_4 - ldh a, [hDividend+2] - inc a - ldh [hDividend+2], a - -.no_overflow_4 - ldh a, [hDividend+2] - cp HIGH(MAX_STAT_VALUE + 1) + 1 - jr nc, .max_stat - cp HIGH(MAX_STAT_VALUE + 1) - jr c, .stat_value_okay - ldh a, [hDividend+3] - cp LOW(MAX_STAT_VALUE + 1) - jr c, .stat_value_okay - -.max_stat - ld a, HIGH(MAX_STAT_VALUE) - ldh [hDividend+2], a - ld a, LOW(MAX_STAT_VALUE) - ldh [hDividend+3], a - -.stat_value_okay - pop bc - pop de - pop hl - ret - -Function60a0: - ld a, [wCurPartySpecies] - dec a - ld c, a - ld d, $00 - ld hl, wPartyMonNicknamesEnd - ld b, $02 - predef SmallFarFlagAction - push bc - xor a - ld [wMonType], a - call Functiond886 - jr nc, .sub_e0d2 - ld hl, wPartyMonNicknames - ld a, [wPartyCount] - dec a - ld bc, $0006 - call AddNTimes - ld d, h - ld e, l - pop bc - ld a, c - ld b, $00 - push bc - push de - jr .sub_e0e1 -.sub_e0d2 - call Functiondd5c - pop bc - jp nc, .sub_e165 - ld a, c - ld de, wBoxMonNicknames - ld b, $01 - push bc - push de -.sub_e0e1 - push af - ld a, [wCurPartySpecies] - ld [wce37], a - call GetPokemonName - pop af - and a - jr nz, .sub_e10d - ld hl, wd41c - bit 4, [hl] - jr z, .sub_e10d - ld hl, NewDexDataText - call PrintText - call ClearSprites - ld a, [wCurPartySpecies] - ld [wce37], a - predef NewPokedexEntry - call LoadTilesetGFX_LCDOff -.sub_e10d - ld hl, GotItText - call PrintText - call YesNoBox - pop de - jr c, .sub_e155 - push de - ld b, NAME_MON - farcall NamingScreen - pop de - ld a, [de] - cp $50 - jr nz, .sub_e133 - ld hl, wStringBuffer1 - ld bc, $0006 - call CopyBytes -.sub_e133 - call ClearBGPalettes - ld hl, wSpriteFlags - ld a, [hl] - push af - res SPRITES_SKIP_STANDING_GFX_F, [hl] - set SPRITES_SKIP_WALKING_GFX_F, [hl] - call RedrawPlayerSprite - pop af - ld [wSpriteFlags], a - call LoadFontExtra - call LoadMapPart - call GetMemSGBLayout - call WaitBGMap - call GBFadeInFromWhite -.sub_e155 - pop bc - ld a, b - and a - ret z - ld hl, BallSentToPCText - ld hl, BallSentToSomeonesPCText - call PrintText - ld b, $01 - ret -.sub_e165 - ld b, $02 - ret - -BallSentToPCText: - text_from_ram wStringBuffer1 - text "は マサキの ところへ" - line "てんそうされた!" - prompt - -BallSentToSomeonesPCText: - text_from_ram wStringBuffer1 - text "は だれかの に" ; "was transferred to" - line "てんそうされた!" ; "Someone's PC!" - prompt - -NewDexDataText: - text_from_ram wStringBuffer1 - text "の データが あたらしく" ; "New Dex data will" - line "#ずかんに セーブされます!@" ; "be added for (MON)!" - -Texte1b8: - db "ドギ@" - -GotItText: - text "ゲットした @" ; "Got it!" - -AskGiveNicknameText: - text_from_ram wStringBuffer1 - text "に" ; "Would you like to" - line "なまえを つけますか?" ; "give it a name?" - done - -_BillsPC: - call Functione284 - ret c - call LoadStandardMenuHeader - call ClearTileMap - call LoadFontsBattleExtra - ld hl, vChars2 tile $78 - ld de, PokeBallsGFX - lb bc, BANK(PokeBallsGFX), $01 - call Request2bpp - ld hl, WhatAreYouGoingToDoText - call MenuTextBox - ld hl, Datae22e - call LoadMenuHeader -.sub_e1fa - call SetPalettes - xor a - ld [wActiveBackpackPocket], a - call OpenMenu - jr c, .sub_e211 - ld a, [wMenuSelection] - ld hl, Tablee270 - call CallJumptable - jr nc, .sub_e1fa -.sub_e211 - call CloseWindow - call CloseWindow - call LoadTilesetGFX - call RestoreScreenAndReloadTiles - call LoadFontExtra - call CloseWindow - ret - -WhatAreYouGoingToDoText: - text "なんに するん?" ; (lit. "What are you going to do?") - done - -Datae22e: - db $40, $00, $00, $11, $0e - dw Datae236 - db $01 - -Datae236: - db $80, $00 - dw Datae27c - db $8a, $1f - dw LookAtPokemonText - -LookAtPokemonText: - db "#の ようすをみる@" ; (lit "look at Pokemon") - -WithdrawMonText: - db "#を つれていく@" ; "Withdraw (Pokemon)" - -DepositMonText: - db "#を あずける@" ; "Deposit (Pokemon)" - -ReleaseMonText: - db "#を にがす@" ; "Release (Pokemon)" - -ChangeBoxText: - db "ボックスを かえる@" ; "Change Box" - -GoodbyeText: - db "さようなら@" ; "Goodbye" - -Tablee270: - dw Functione5c5 - dw Functione31b - dw BillsPC_DepositMon - dw BillsPC_ReleaseMon - dw BillsPC_ChangeBoxMenu - dw BillsPC_SeeYa - -Datae27c: - db $05, $00, $01, $02, $03, $04, $05, $ff - -Functione284: - ld a, [wPartyCount] - and a - ret nz - ld hl, Texte291 - call MenuTextBoxBackup - scf - ret - -Texte291: - text "#もってへんやつは" - line "おことわりや!" - prompt - -BillsPC_SeeYa: - scf - ret - -BillsPC_DepositMon: - call Functione2b0 - jr c, .sub_e2ae - call Functione2f0 -.sub_e2ae - and a - ret - -Functione2b0: - ld a, [wPartyCount] - and a - jr z, .sub_e2bc - cp $02 - jr c, .sub_e2c4 - and a - ret -.sub_e2bc - ld hl, YouDontEventHaveOnePokemonText - call MenuTextBoxBackup - scf - ret -.sub_e2c4 - ld hl, CantDepositLastMonText - call MenuTextBoxBackup - scf - ret - -YouDontEventHaveOnePokemonText: - text "1ぴきも もってへんやんか!" ; (lit: "I can't even have one!") - prompt - -CantDepositLastMonText: - text "それ あずけたら" ; "You can't deposit" - line "こまるんとちゃう?" ; "the last #MON!" - prompt - -Functione2f0: - call LoadStandardMenuHeader - ld hl, Tablee6da - call Functione6a4 - call CloseWindow - ret c - ld a, [wScrollingMenuCursorPosition] - ld [wCurPartyMon], a - ld a, [wMenuSelection] - ld [wCurPartySpecies], a - ld a, $01 - ld [wPokemonWithdrawDepositParameter], a - predef Functiondac8 - xor a - ld [wPokemonWithdrawDepositParameter], a - call Functiondecd - ret - -Functione31b: - call .sub_e325 - jr c, .sub_e323 - call Functione350 -.sub_e323 - and a - ret -.sub_e325 - ld a, [wPartyCount] - cp $06 - jr nc, .sub_e32e - and a - ret -.sub_e32e - ld hl, Texte336 - call MenuTextBoxBackup - scf - ret - -Texte336: - text "それいじょう よくばったって" - line "# もたれへんで!" - prompt - -Functione350: - call LoadStandardMenuHeader - ld hl, Datae6f8 - call Functione6a4 - call CloseWindow - ret c - ld a, [wScrollingMenuCursorPosition] - ld [wCurPartyMon], a - ld a, [wMenuSelection] - ld [wCurPartySpecies], a - xor a - ld [wPokemonWithdrawDepositParameter], a - predef Functiondac8 - ld a, $01 - ld [wPokemonWithdrawDepositParameter], a - call Functiondecd - ret - -BillsPC_ReleaseMon: - call .sub_e380 - and a - ret -.sub_e380 - call LoadStandardMenuHeader - ld hl, Datae6f8 - call Functione6a4 - call CloseWindow - ld a, [wScrollingMenuCursorPosition] - ld [wCurPartyMon], a - ld a, [wMenuSelection] - ld [wCurPartySpecies], a - ret c - ld hl, OnceReleasedText - call MenuTextBox - call YesNoBox - call CloseWindow - ret c - ld a, $01 - ld [wPokemonWithdrawDepositParameter], a - call Functiondecd - ret - -OnceReleasedText: - text_from_ram wStringBuffer1 - text " をほんとうに" ; "Are you sure you" - next "にがしますか?" ; "want to release (MON)?" - done - -BillsPC_ChangeBoxMenu: - call _ChangeBox - and a - ret - -_ChangeBox: - call BoxSelectFunc - call LoadStandardMenuHeader - call ClearPalettes - call ClearTileMap -.sub_e3d4 - ld hl, Datae414 - call CopyMenuHeader - call ScrollingMenu - ld a, [wMenuJoypad] - cp $02 - jr z, .sub_e3e9 - call BoxEditMenu - jr .sub_e3d4 -.sub_e3e9 - call CloseWindow - ret - -BoxSelectFunc: - ld hl, wd4b9 - ld c, $00 -.sub_e3f2 - push hl - ld de, DummyBoxText - call CopyString - ld a, "0" - add c - dec hl - ld [hli], a - ld [hl], "@" - pop hl - ld de, $0009 - add hl, de - inc c - ld a, c - cp $0a - jr c, .sub_e3f2 - ret - -DummyBoxText: - db "ダミーボックス@" ; "Dummy Box" - -Datae414: - db $40, $00, $00, $0c, $13, $1c, $64, $01 - db $20, $04, $00, $01, $03, $2c, $64, $03 - db $38, $64, $00, $00, $00, $03, $9d, $64 - db $0a, $01, $02, $03, $04, $05, $06, $07 - db $08, $09, $0a, $ff - -Functione438: - push de - ld a, [wMenuSelection] - dec a - ld bc, $0006 - ld hl, Texte461 - call AddNTimes - ld d, h - ld e, l - pop hl - call PlaceString - push bc - ld a, [wMenuSelection] - dec a - ld bc, $0009 - ld hl, wd4b9 - call AddNTimes - ld d, h - ld e, l - pop hl - call PlaceString - ret - -Texte461: - db "№.01 @" - db "№.02 @" - db "№.03 @" - db "№.04 @" - db "№.05 @" - db "№.06 @" - db "№.07 @" - db "№.08 @" - db "№.09 @" - db "№.10 @" - -Functione49d: ; change box screen items - ld h, d - ld l, e - ld de, MonInMyCareText - call PlaceString - ld hl, $0003 - add hl, bc - push hl - call Functione4ce - pop hl - ld de, wStringBuffer1 - ld [de], a - ld bc, $0102 - call PrintNumber - ld de, OutOfThirtyText - call PlaceString - ret - -MonInMyCareText: ; unfinished feature to show how many mon are in your box - db "あずかっている#" ; "Mon in my care" - next " @" - -OutOfThirtyText: ; max mon per box - db "/30@" - -Functione4ce: ; counts available mon in highlighted box - ld a, [wMenuSelection] - dec a - ld c, a - ld b, $00 - ld hl, Datae4e7 - add hl, bc - add hl, bc - add hl, bc - ld a, [hli] - call OpenSRAM - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [hl] - call CloseSRAM - ret - -Datae4e7: ; checks box slots for mon counting - db $02, $00, $a0 - db $02, $48, $a5 - db $02, $90, $aa - db $02, $d8, $af - db $02, $20, $b5 - db $03, $00, $a0 - db $03, $48, $a5 - db $03, $90, $aa - db $03, $d8, $af - db $03, $20, $b5 - -BoxEditMenu: - ld hl, BoxEditMenuList - call LoadMenuHeader - call VerticalMenu - call CloseWindow - ret c - ld a, [w2DMenuDataEnd] - cp $01 - jr z, PromptChangeBoxWillYouSave - cp $02 - jr z, ChangeBoxName - and a - ret - -PrintBoxChangeUnderDev: - ld hl, BoxChangeUnderDevText - call MenuTextBox - call CloseWindow - ret - -BoxChangeUnderDevText: - text "バンクチェンジは" ; "Box change is" - next "かいはつちゅうです!" ; "under development!" - prompt - -PromptChangeBoxWillYouSave: - ld hl, WhenYouChangeBoxText - call MenuTextBox - call YesNoBox - call CloseWindow - ret c - jr PrintBoxChangeUnderDev - -Functione54d: - ld a, [wMenuSelection] - ret - -WhenYouChangeBoxText: - text "# ボックスを かえると" ; "When you change a box" - line "どうじに レポートが かかれます" ; "data will be saved." - para "<⋯⋯> それでも いいですか?" ; "Is that okay?" - done - -ChangeBoxName: - ld b, NAME_BOX - ld de, wMovementBufferCount - ld a, BANK(NamingScreen) - ld hl, NamingScreen - call FarCall_hl - ld a, [wMovementBufferCount] - cp $50 - ret z - ld hl, wd4b9 - ld bc, $0009 - ld a, [wMenuSelection] - dec a - call AddNTimes - ld de, wMovementBufferCount - call CopyString - ret - -BoxEditMenuList: - db $40, $06, $00, $0e, $0e - dw BoxEditMenuListItems - db $01 - -BoxEditMenuListItems: - db $80, $03 - db "ボックスきりかえ@" ; "Change Box" - db "なまえを かえる@" ; " Change Name" - db "やめる@" ; (lit "stop") - -Functione5c5: - call LoadStandardMenuHeader - call Functione5d3 - call ClearPalettes - call CloseWindow - and a - ret - -Functione5d3: - call ClearBGPalettes - call .sub_e62a - call SetPalettes - ld hl, Datae71c - call CopyMenuHeader - ld a, [wcd3c] - ld [wMenuCursorBuffer], a - ld a, [wcd46] - ld [wMenuScrollPosition], a - call ScrollingMenu - ld a, [wMenuScrollPosition] - ld [wcd46], a - ld a, [w2DMenuDataEnd] - ld [wcd3c], a - call ClearPalettes - ld a, [wMenuJoypad] - cp $02 - jr z, .sub_e60c - call .sub_e60d - jr Functione5d3 -.sub_e60c - ret -.sub_e60d - ld a, [wScrollingMenuCursorPosition] - ld [wCurPartyMon], a - ld a, $02 - ld [wMonType], a - call LoadStandardMenuHeader - call LowVolume - predef Function502b5 - call MaxVolume - call ExitMenu - ret -.sub_e62a - ld hl, wOptions - ld a, [hl] - push af - set 4, [hl] - call ClearTileMap - ld a, [wd4b6] - ld hl, wd4b9 - ld bc, $0009 - call AddNTimes - ld d, h - ld e, l - coord hl, 1, 1 - ld de, CurrentBoxText - call PlaceString - coord hl, 0, 3 - ld a, $79 - ld [hli], a - ld a, $7a - ld c, $13 -.sub_e655 - ld [hli], a - dec c - jr nz, .sub_e655 - ld de, $0014 - ld a, $7c - ld c, $08 -.sub_e660 - ld [hl], a - add hl, de - dec c - jr nz, .sub_e660 - coord hl, 2, 3 - ld de, SpeciesNameLevelText - call PlaceString - ld hl, WhichOneWouldYouLikeToSeeText - call PrintText - pop af - ld [wOptions], a - ret - -CurrentBoxText: - db "ボックス/いまの ボックス@" ; "Box/Current Box (Name)" - -SpeciesNameLevelText: - db "しゅるい  なまえ   レべル@" ; "Species Name Level" - -WhichOneWouldYouLikeToSeeText: - text "どの#が みたいねん?" ; "Which would you like to see?" - done - -Functione6a4: ; has something to do with releasing mon from PC - ld a, l - ld [wListPointer], a - ld a, h - ld [wListPointer + 1], a - coord hl, 4, 2 - ld b, $09 - ld c, $0e - call DrawTextBox - ld hl, wListPointer - ld a, [hli] - ld h, [hl] - ld l, a - call Function3810 ; in home/scrolling_menu.asm and appears to be related to the smaller mon selection box like G1 (still investigating) - ld a, [wMenuJoypad] - cp $02 - jr z, .sub_e6ce - ld hl, MonSelectedText - call MenuTextBoxBackup - and a - ret -.sub_e6ce - scf - ret - -MonSelectedText: - text "#を えらんだ!" ; "(MON) selected!" - prompt - -Tablee6da: - dw Datae6e0 - dw wcd3c - dw wcd46 - -Datae6e0: - db $40, $03, $05, $0b, $12 - dw Datae6e8 - db $01 - -Datae6e8: - db $00, $04 - -Datae6ea: - db $08, $01, $00, $aa, $d6, $09, $a6 - db $47, $09, $ba, $47, $00, $00, $00 - -Datae6f8: - dw Datae6fe - dw wcd3c - dw wcd46 - -Datae6fe: - db $40, $03, $05, $0b, $12 - dw Datae706 - db $01 - -Datae706: - db $00, $04, $08, $01, $00, $83, $da, $09 - db $ab, $47, $09, $c1, $47, $00, $00, $00 - -Datae716: - dw Datae71c - dw wcd3c - dw wcd46 - -Datae71c: - db $40, $04, $01, $0b, $13, $24, $67, $01 - db $00, $04, $00, $01, $00, $83, $da, $09 - db $d8, $47, $00, $00, $00, $00, $00, $00 - -Function6734: - call RefreshScreen - call LowVolume - ldh a, [hMapAnims] - push af - xor a - ldh [hMapAnims], a - ld hl, wStateFlags - res SPRITE_UPDATES_DISABLED_F, [hl] - call ClearBGPalettes - call ClearSprites - call LoadStandardMenuHeader - ld hl, LoadPokeDexGraphics - ld a, BANK(LoadPokeDexGraphics) - call FarCall_hl - call ClearTileMap - ld hl, _NewPokedexEntry - ld a, BANK(_NewPokedexEntry) - call FarCall_hl - call ClearBGPalettes - ld hl, wStateFlags - set SPRITE_UPDATES_DISABLED_F, [hl] - call ExitMenu - call LoadTilesetGFX_LCDOff - call RestoreScreenAndReloadTiles - call UpdateTimePals - pop af - ldh [hMapAnims], a - call MaxVolume - call Function1fea - ret - -_UseItem: - ld a, [wCurItem] - ld [wNamedObjectIndexBuffer], a - call GetItemName - call CopyStringToStringBuffer2 - ld a, $01 - ld [wItemEffectSucceeded], a - ld a, [wCurItem] - cp $c4 - jp nc, Functionf678 - ld hl, Tablee7a5 - dec a - ld c, a - ld b, $00 - add hl, bc - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - jp hl - -Tablee7a5: - dw PokeBallEffect ; ITEM_MASTER_BALL - dw PokeBallEffect ; ITEM_ULTRA_BALL - dw Functionf66f - dw PokeBallEffect ; ITEM_GREAT_BALL - dw PokeBallEffect ; ITEM_POKE_BALL - dw TownMapEffect ; ITEM_TOWN_MAP - dw Functioneca4 - dw Functioned00 - dw Functionef02 - dw Functionef02 - dw Functionef02 - dw Functionef02 - dw Functionef02 - dw Functionefee - dw Functionf05b - dw Functionf05b - dw Functionf05b - dw Functionf05b - dw Functionf2b5 - dw Functionf2cc - dw Functionf4d1 - dw Functioned00 - dw Functioned00 - dw Functioned00 - dw Functionf66f - dw Functioned37 - dw Functioned37 - dw Functioned37 - dw Functioned37 - dw Functionf66f - dw Functioned37 - dw Functionee42 - dw Functionf2dc - dw Functioned00 - dw Functionf66f - dw Functionf66c - dw Functionf2eb - dw Functionef02 - dw Functionef8c - dw Functionef8c - dw Functionf2fa - dw Functionf2c2 - dw Functionf2c7 - dw Functionf309 - dw Functionf66f - dw Functionf05b - dw Functionf05b - dw Functionf05b - dw Functionf318 - dw Functionf66f - dw Functionf318 - dw Functionf318 - dw Functionf318 - dw Functionf413 - dw Functionf4ca - dw Functionf354 - dw Functionf66f - dw Functionf437 - dw Functionf444 - dw Functionf66f - dw Functionf46e - dw Functionf4ca - dw Functionf4d1 - dw Functionf4d1 - dw Functionf4d1 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf65d - dw Functionfd45 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - dw Functionf672 - -PokeBallEffect: - ld a, [wBattleMode] - and a - jp z, IsntTheTimeMessage - dec a - jp nz, UseBallInTrainerBattle - - ld a, [wPartyCount] - cp PARTY_LENGTH - jr nz, .room_in_party - - ld a, [wBoxListLength] - cp MONS_PER_BOX - jp z, Ball_BoxIsFullMessage - -.room_in_party - xor a - ld [wWildMon], a - call ReturnToBattle_UseBall - - ld hl, ItemUsedText - call PrintText - - ld a, [wEnemyMonCatchRate] - ld b, a - ld a, [wCurItem] - cp ITEM_MASTER_BALL - jp z, .sub_e9d6 - - cp ITEM_ULTRA_BALL - jr z, .ultra_ball_modifier - - cp ITEM_GREAT_BALL - jr z, .great_ball_modifier - - ; POKE_BALL - jr .regular_ball - -; 1.5x modifier -.great_ball_modifier - ld a, b - srl a - add b - ld b, a - jr nc, .regular_ball - ld b, $ff - jr .regular_ball - -; 2.0x modifier -.ultra_ball_modifier - sla b - jr nc, .regular_ball - ld b, $ff - -.regular_ball - ld a, b - ldh [hMultiplicand + 2], a - ld hl, wEnemyMonHP - ld b, [hl] - inc hl - ld c, [hl] - inc hl - ld d, [hl] - inc hl - ld e, [hl] - sla c - rl b - ld h, d - ld l, e - add hl, de - add hl, de - ld d, h - ld e, l - ld a, d - and a - jr z, .sub_e978 - srl d - rr e - srl d - rr e - srl b - rr c - srl b - rr c - ld a, c - and a - jr nz, .sub_e978 - ld c, $01 -.sub_e978 - ld b, e - push bc - ld a, b - sub c - ldh [hDivisor], a - xor a - ldh [hQuotient], a - ldh [hQuotient + 1], a - ldh [hQuotient + 2], a - call Multiply - pop bc - ld a, b - ldh [hDivisor], a - ld b, $04 - call Divide - ldh a, [hQuotient + 3] - and a - jr nz, .sub_e998 - ld a, $01 -.sub_e998 - ld b, a - ld a, [wEnemyMonStatus] - and $27 - ld c, $0a - jr nz, .sub_e9a9 - and a - ld c, $05 - jr nz, .sub_e9a9 - ld c, $00 -.sub_e9a9 - ld a, b - add c - jr nc, .sub_e9af - ld a, $ff -.sub_e9af - ld d, a - push de - ld a, [wBattleMonItem] - ld hl, GetItemHeldEffect - ld a, BANK(GetItemHeldEffect) - call FarCall_hl - ld a, b - cp $46 - pop de - ld a, d - jr nz, .sub_e9c8 - add c - jr nc, .sub_e9c8 - ld a, $ff -.sub_e9c8 - ld b, a - ld [wFieldMoveScriptID], a - call Random - cp b - ld a, $00 - jr z, .sub_e9d6 - jr nc, .sub_e9d9 -.sub_e9d6 - ld a, [wEnemyMonSpecies] -.sub_e9d9 - ld [wWildMon], a - ld c, $14 - call DelayFrames - ld a, [wCurItem] - ld [wBattleAnimParam], a - ld de, ANIM_THROW_POKE_BALL - ld a, e - ld [wFXAnimID], a - ld a, d - ld [wFXAnimID + 1], a - xor a - ldh [hBattleTurn], a - ld [wMapBlocksAddress], a - ld [wNumHits], a - predef PlayBattleAnim - ld a, [wWildMon] - and a - jr nz, .sub_ea29 - ld a, [wMapBlocksAddress] - cp $01 - ld hl, BallBrokeFreeText - jp z, .sub_eb59 - cp $02 - ld hl, BallAppearedCaughtText - jp z, .sub_eb59 - cp $03 - ld hl, BallAlmostHadItText - jp z, .sub_eb59 - cp $04 - ld hl, BallSoCloseText - jp z, .sub_eb59 -.sub_ea29 - ld hl, wEnemyMonHP - ld a, [hli] - push af - ld a, [hli] - push af - inc hl - ld a, [hl] - push af - push hl - ld hl, wEnemyMonItem - ld a, [hl] - push af - push hl - ld hl, wEnemySubStatus5 - bit 3, [hl] - jr z, .sub_ea48 - ld a, $84 - ld [wTempEnemyMonSpecies], a - jr .sub_ea55 -.sub_ea48 - set 3, [hl] - ld hl, wEnemyBackupDVs - ld a, [wEnemyMonDVs] - ld [hli], a - ld a, [wEnemyMonDVs + 1] - ld [hl], a -.sub_ea55 - ld a, [wTempEnemyMonSpecies] - ld [wCurPartySpecies], a - ld a, [wEnemyMonLevel] - ld [wCurPartyLevel], a - ld hl, LoadEnemyMon - ld a, BANK(LoadEnemyMon) - call FarCall_hl - pop hl - pop af - ld [hl], a - pop hl - pop af - ld [hld], a - dec hl - pop af - ld [hld], a - pop af - ld [hl], a - ld a, [wEnemyMonSpecies] - ld [wWildMon], a - ld [wCurPartySpecies], a - ld [wce37], a - ld a, [wce03] - dec a - jp z, .sub_eb56 - ld hl, GotchaText - call PrintText - call ClearSprites - ld a, [wce37] - dec a - ld c, a - ld d, $00 - ld hl, wPartyMonNicknamesEnd - ld b, $02 - predef SmallFarFlagAction - ld a, c - push af - ld a, [wce37] - dec a - ld c, a - ld b, $01 - predef SmallFarFlagAction - pop af - and a - jr nz, .sub_eac7 - ld hl, NewDexDataText_2 - call PrintText - call ClearSprites - ld a, [wEnemyMonSpecies] - ld [wce37], a - predef NewPokedexEntry -.sub_eac7 - ld a, [wPartyCount] - cp $06 - jr z, .sub_eb13 - xor a - ld [wMonType], a - call ClearSprites - predef Functiond886 - ld hl, Textec61 - call PrintText - call YesNoBox - jr c, .sub_eb5f - ld a, [wPartyCount] - dec a - ld hl, wPartyMonNicknames - ld bc, MON_NAME_LENGTH - call AddNTimes - ld d, h - ld e, l - ld b, NAME_MON - ld a, BANK(NamingScreen) - ld hl, NamingScreen - push de - call FarCall_hl - call GBFadeOutToWhite - pop de - ld a, [de] - cp "@" - jr nz, .sub_eb5f - ld hl, wStringBuffer1 - ld bc, MON_NAME_LENGTH - call CopyBytes - jr .sub_eb5f -.sub_eb13 - call ClearSprites - predef Functiondd5c - ld hl, Textec61 - call PrintText - call YesNoBox - jr c, .sub_eb47 - ld de, wBoxMonNicknames - ld b, NAME_MON - ld a, BANK(NamingScreen) - ld hl, NamingScreen - call FarCall_hl - call GBFadeOutToWhite - ld de, wBoxMonNicknames - ld a, [de] - cp "@" - jr nz, .sub_eb47 - ld hl, wStringBuffer1 - ld bc, MON_NAME_LENGTH - call CopyBytes -.sub_eb47 - ld hl, Textec0e - bit 0, a - jr nz, .sub_eb51 - ld hl, BallSentToSomeonesPCText_2 -.sub_eb51 - call PrintText - jr .sub_eb5f -.sub_eb56 - ld hl, GotchaText -.sub_eb59 - call PrintText - call ClearSprites -.sub_eb5f - ld a, [wce03] - and a - ret nz - ld hl, wItems - inc a - ld [wItemQuantity], a - jp TossItem - -BallDodgedText: - text "よけられた!" ; "It dodged the thrown BALL!" - line "こいつは つかまりそうにないぞ!" ; "This MON can't be caught!" - prompt - -BallMissedText: - text "#に" ; "You missed the" - line "うまく あたらなかった!" ; "(MON)!" - prompt - -BallBrokeFreeText: - text "だめだ! #が" ; "Oh no! The (MON)" - line "ボールから でてしまった!" ; "broke free!" - prompt - -BallAppearedCaughtText: - text "ああ!" ; "Aww! It appeared" - line "つかまえたと おもったのに!" ; "to be caught!" - prompt - -BallAlmostHadItText: - text "ざんねん!" ; "Aargh!" - line "もうすこしで つかまえられたのに!" ; "Almost had it!" - prompt - -BallSoCloseText: - text "おしい!" ; "Shoot! It was so" - line "あと ちょっとの ところだったのに!" ; "close too!" - prompt - -GotchaText: - text "やったー!" ; "Gotcha" - line "@" - -Textebfd: - text_from_ram wEnemyMonNickname - text "を つかまえたぞ!@" - -Textec0b: - sound_caught_mon - text_waitbutton - text_end - -Textec0e: - text_from_ram wBoxMonNicknames - text "は マサキの ところへ" - line "てんそうされた!" - prompt - -BallSentToSomeonesPCText_2: - text_from_ram wBoxMonNicknames - text "は だれかの に" ; "was transferred to" - line "てんそうされた!" ; "Someone's PC!" - prompt - -NewDexDataText_2: - text_from_ram wEnemyMonNickname - text "の データが あたらしく" ; "New Dex data will" - line "#ずかんに セーブされます!@" ; "be added for (MON)!" - -Textec5e: - sound_slot_machine_start - text_waitbutton - text_end - -Textec61: - text "つかまえた @" - -Textec69: - text_from_ram wStringBuffer1 - text "に" - line "なまえを つけますか" - done - -ReturnToBattle_UseBall: - call ClearPalettes - ld hl, Call_LoadBattleFontsHPBar - ld a, BANK(Call_LoadBattleFontsHPBar) - call FarCall_hl - call GetMemSGBLayout - call CloseWindow - call LoadStandardMenuHeader - call WaitBGMap - call SetPalettes - ret - -TownMapEffect: - ld a, [wBattleMode] - and a - jp nz, IsntTheTimeMessage - farjp TownMap - -Functioneca4: - xor a - ld [wFieldMoveSucceeded], a - call .sub_ecba - ret c - ldh a, [hROMBank] - ld hl, Functionecd5 - call QueueScript - ld a, $01 - ld [wFieldMoveSucceeded], a - ret -.sub_ecba - call GetMapEnvironment - cp $01 - jr z, .sub_eccb - cp $02 - jr z, .sub_eccb - cp $04 - jr z, .sub_eccb - jr .sub_ecd3 -.sub_eccb - ld a, [wPlayerState] - and a - ret z - cp $01 - ret z -.sub_ecd3 - scf - ret - -Functionecd5: - call RefreshScreen - ld a, [wPlayerState] - cp $01 - jr z, .sub_ece9 - ld a, $01 - ld [wPlayerState], a - ld hl, ItemGotOnText - jr .sub_ecf0 -.sub_ece9 - xor a - ld [wPlayerState], a - ld hl, ItemGotOffText -.sub_ecf0 - call MenuTextBox - call CloseWindow - call RedrawPlayerSprite - call PlayMapMusic - call Function1fea - ret - -Functioned00: - ld a, [wBattleMode] - and a - jp nz, IsntTheTimeMessage - ld a, PARTYMENUACTION_EVO_STONE - call Functionf0cf - jr c, .sub_ed32 - ld a, $01 - ld [wcab9], a - push de - ld de, SFX_FULL_HEAL - call WaitPlaySFX - call WaitSFX - pop de - ld hl, Function4af93 - ld a, BANK(Function4af93) - call FarCall_hl - ld a, [wce3a] - and a - jr z, .sub_ed2f - jp Functionf7a2 -.sub_ed2f - call WontHaveAnyEffectMessage -.sub_ed32 - xor a - ld [wFieldMoveSucceeded], a - ret - -Functioned37: - ld a, [wBattleMode] - and a - jp nz, IsntTheTimeMessage - ld a, PARTYMENUACTION_HEALING_ITEM - call Functionf0cf - jp c, Functionedbe - ld a, $00 - call GetPartyParamLocation - push hl - ld a, [wCurPartySpecies] - ld [wCurSpecies], a - ld [wce37], a - ld bc, $001f - add hl, bc - ld a, [hl] - ld [wCurPartyLevel], a - call GetBaseData - ld a, [wCurPartyMon] - ld hl, wPartyMonNicknames - call GetNick - call Functionee26 - pop hl - push hl - add hl, bc - ld bc, $000b - add hl, bc - ld a, [hl] - cp $64 - jr nc, Functioneda1 - add $0a - ld [hl], a - pop hl - call Functionedab - call Functionee26 - ld hl, Tableedf7 - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - ld de, wHPBarTempHP - ld bc, $000a - call CopyBytes - ld de, SFX_FULL_HEAL - call WaitPlaySFX - ld hl, Textedcb - call PrintText - jp Functionf7a2 - -Functioneda1: - pop hl - ld hl, Textede7 - call PrintText - jp ClearPalettes - -Functionedab: - push hl - ld bc, $0024 - add hl, bc - ld d, h - ld e, l - pop hl - ld bc, $000a - add hl, bc - ld b, $01 - predef_jump CalcMonStats - -Functionedbe: - xor a - ld [wFieldMoveSucceeded], a - call ClearPalettes - call z, GetMemSGBLayout - jp ReloadFontAndTileset - -Textedcb: - text_from_ram wStringBuffer1 - text "の @" - -Textedd2: - text_from_ram wStringBuffer2 - text "の" - line "きそ ポイントが あがった!" - prompt - - - -Textede7: - text "つかっても こうかが ないよ" - prompt - -Tableedf7: - dw Textee01 - dw Textee07 - dw Textee0f - dw Textee17 - dw Textee1c - -Textee01: - db "たいりょく@" - -Textee07: - db "こうげきりょく@" - -Textee0f: - db "ぼうぎょりょく@" - -Textee17: - db "すばやさ@" - -Textee1c: - db "とくしゅのうりょく@" - -Functionee26: - ld a, [wCurItem] - ld hl, Dataee38 -.sub_ee2c - cp [hl] - inc hl - jr z, .sub_ee33 - inc hl - jr .sub_ee2c -.sub_ee33 - ld a, [hl] - ld c, a - ld b, $00 - ret - -Dataee38: - db $1a, $00 - db $1b, $02 - db $1c, $04 - db $1d, $06 - db $1f, $08 - -Functionee42: - ld a, [wBattleMode] - and a - jp nz, IsntTheTimeMessage - ld a, PARTYMENUACTION_HEALING_ITEM - call Functionf0cf - jp c, Functionedbe - ld a, $00 - call GetPartyParamLocation - ld a, [wCurPartySpecies] - ld [wCurSpecies], a - ld [wce37], a - push hl - ld bc, $001f - add hl, bc - ld a, [hl] - ld [wCurPartyLevel], a - call GetBaseData - ld a, [wCurPartyMon] - ld hl, wPartyMonNicknames - call GetNick - pop hl - push hl - ld bc, $001f - add hl, bc - ld a, [hl] - cp $64 - jp nc, Functioneda1 - inc a - ld [hl], a - ld [wCurPartyLevel], a - push de - ld d, a - ld hl, CalcExpAtLevel - ld a, BANK(CalcExpAtLevel) - call FarCall_hl - pop de - pop hl - push hl - ld bc, $0008 - add hl, bc - ldh a, [hQuotient + 1] - ld [hli], a - ldh a, [hQuotient + 2] - ld [hli], a - ldh a, [hQuotient + 3] - ld [hl], a - pop hl - push hl - ld bc, $0024 - add hl, bc - ld a, [hli] - ld b, a - ld c, [hl] - pop hl - push bc - push hl - call Functionedab - pop hl - ld bc, $0025 - add hl, bc - pop bc - ld a, [hld] - sub c - ld c, a - ld a, [hl] - sbc b - ld b, a - dec hl - ld a, [hl] - add c - ld [hld], a - ld a, [hl] - adc b - ld [hl], a - ld a, PARTYMENUTEXT_LEVEL_UP - ld [wPartyMenuActionText], a - callfar Function5087e - xor a - ld [wMonType], a - predef CopyMonToTempMon - ld d, $01 - ld hl, Function50628 - ld a, BANK(Function50628) - call FarCall_hl - call TextboxWaitPressAorB_BlinkCursor - xor a - ld [wMonType], a - ld a, [wCurPartySpecies] - ld [wce37], a - predef Function421f8 - xor a - ld [wcab9], a - ld hl, Function4af93 - ld a, BANK(Function4af93) - call FarCall_hl - jp Functionf7a2 - -Functionef02: - ld a, [wPartyCount] - and a - jp z, IsntTheTimeMessage - ld a, PARTYMENUACTION_HEALING_ITEM - call Functionf0cf - jp c, Functionf100 - ld a, [wCurPartySpecies] - ld [wCurSpecies], a - -Functionef17: - call .sub_ef61 - ld a, $20 - call GetPartyParamLocation - ld a, [hl] - and c - jp z, Functionf0fb - xor a - ld [hl], a - ld a, b - ld [wPartyMenuActionText], a - call Functionf113 - jr nc, .sub_ef50 - xor a - ld [wBattleMonStatus], a - ld hl, wPlayerSubStatus5 - res 0, [hl] - ld hl, wPlayerSubStatus1 - res 0, [hl] - ld a, $24 - call GetPartyParamLocation - ld de, wBattleMonMaxHP - ld bc, $000a - call CopyBytes - predef Function3e1a4 -.sub_ef50 - call Functionf7a2 - push de - ld de, SFX_FULL_HEAL - call WaitPlaySFX - pop de - call Functionf0d8 - jp Functionf104 -.sub_ef61 - push hl - ld a, [wCurItem] - ld hl, Dataef77 - ld bc, $0003 -.sub_ef6b - cp [hl] - jr z, .sub_ef71 - add hl, bc - jr .sub_ef6b -.sub_ef71 - inc hl - ld b, [hl] - inc hl - ld c, [hl] - pop hl - ret - -Dataef77: - db $09, $f0, $08 - db $0a, $f1, $10 - db $0b, $f2, $20 - db $0c, $f3, $07 - db $0d, $f4, $40 - db $26, $f6, $ff - db $ff, $00, $00 - -Functionef8c: - ld a, [wPartyCount] - and a - jp z, IsntTheTimeMessage - ld a, PARTYMENUACTION_HEALING_ITEM - call Functionf0cf - jp c, Functionf100 - call Functionf165 - jp nz, Functionf0fb - ld a, [wBattleMode] - and a - jr z, .sub_efc9 - ld a, [wCurPartyMon] - ld c, a - ld d, $00 - ld hl, wBattleParticipantsIncludingFainted - ld b, $02 - predef SmallFarFlagAction - ld a, c - and a - jr z, .sub_efc9 - ld a, [wCurPartyMon] - ld c, a - ld hl, wBattleParticipantsNotFainted - ld b, $01 - predef SmallFarFlagAction -.sub_efc9 - xor a - ld [wLowHealthAlarmBuffer], a - ld a, [wCurItem] - cp $27 - jr z, .sub_efd9 - call Functionf130 - jr .sub_efdc -.sub_efd9 - call Functionf127 -.sub_efdc - call Functionf0b0 - ld a, PARTYMENUTEXT_REVIVE - ld [wPartyMenuActionText], a - call Functionf0d8 - call Functionf7a2 - jp Functionf104 - -Functionefed: - ret - -Functionefee: - ld a, [wPartyCount] - and a - jp z, IsntTheTimeMessage - ld a, PARTYMENUACTION_HEALING_ITEM - call Functionf0cf - jp c, Functionf100 - call Functionf165 - jp z, Functionf0fb - call Functionf171 - jr c, .sub_f01a - ld a, $20 - call GetPartyParamLocation - ld a, [hl] - and a - jp z, Functionf0fb - ld a, $26 - ld [wCurItem], a - jp Functionef17 -.sub_f01a - xor a - ld [wLowHealthAlarmBuffer], a - call Functionf130 - ld a, $20 - call GetPartyParamLocation - xor a - ld [hli], a - ld [hl], a - call Functionf113 - jr nc, .sub_f049 - ld hl, wPlayerSubStatus5 - res 0, [hl] - ld hl, wPlayerSubStatus1 - res 0, [hl] - xor a - ld [wBattleMonStatus], a - ld a, $22 - call GetPartyParamLocation - ld a, [hli] - ld [wBattleMonHP], a - ld a, [hld] - ld [wBattleMonHP + 1], a -.sub_f049 - call Functionf0b0 - ld a, PARTYMENUTEXT_HEAL_HP - ld [wPartyMenuActionText], a - call Functionf0d8 - call Functionf7a2 - jp Functionf104 - -Functionf05a: - ret - -Functionf05b: - ld a, [wPartyCount] - and a - jp z, IsntTheTimeMessage - ld a, PARTYMENUACTION_HEALING_ITEM - call Functionf0cf - jp c, Functionf100 - call Functionf165 - jp z, Functionf0fb - call Functionf171 - jp nc, Functionf0fb - xor a - ld [wLowHealthAlarmBuffer], a - ld a, [wCurItem] - cp $0f - jr nz, .sub_f086 - call Functionf130 - jr .sub_f08c -.sub_f086 - call Functionf1e9 - call Functionf13f -.sub_f08c - call Functionf113 - jr nc, .sub_f09e - ld a, $22 - call GetPartyParamLocation - ld a, [hli] - ld [wBattleMonHP], a - ld a, [hld] - ld [wBattleMonHP + 1], a -.sub_f09e - call Functionf0b0 - ld a, PARTYMENUTEXT_HEAL_HP - ld [wPartyMenuActionText], a - call Functionf0d8 - call Functionf7a2 - jp Functionf104 - -Functionf0af: - ret - -Functionf0b0: - push de - ld de, SFX_POTION - call WaitPlaySFX - pop de - ld a, [wCurPartyMon] - coord hl, 11, 0 - ld bc, $0028 - call AddNTimes - ld a, $02 - ld [wWhichHPBar], a - predef UpdateHPBar - ret - -Functionf0cf: - ld [wPartyMenuActionText], a - predef PartyMenuInBattle_Setup - ret - -Functionf0d8: - xor a - ldh [hBGMapMode], a - ld hl, wTileMap - ld bc, VBlank.return - ld a, $7f - call ByteFill - callfar Function5087e - ld a, $01 - ldh [hBGMapMode], a - ld c, $32 - call DelayFrames - call TextboxWaitPressAorB_BlinkCursor - ret - -Functionf0fb: - call WontHaveAnyEffectMessage - jr Functionf104 - -Functionf100: - xor a - ld [wFieldMoveSucceeded], a - -Functionf104: - call ClearPalettes - call z, GetMemSGBLayout - ld a, [wBattleMode] - and a - ret nz - call ReloadFontAndTileset - ret - -Functionf113: - ld a, [wBattleMode] - and a - ret z - ld a, [wCurPartyMon] - push hl - ld hl, wCurBattleMon - cp [hl] - pop hl - jr nz, .sub_f125 - scf - ret -.sub_f125 - xor a - ret - -Functionf127: - call Functionf1c5 - srl d - rr e - jr Functionf133 - -Functionf130: - call Functionf1c5 - -Functionf133: - ld a, $22 - call GetPartyParamLocation - ld [hl], d - inc hl - ld [hl], e - call Functionf17e - ret - -Functionf13f: - ld a, $23 - call GetPartyParamLocation - ld a, [hl] - add e - ld [hld], a - ld a, [hl] - adc d - ld [hl], a - call Functionf17e - ld a, $23 - call GetPartyParamLocation - ld d, h - ld e, l - ld a, $25 - call GetPartyParamLocation - ld a, [de] - sub [hl] - dec de - dec hl - ld a, [de] - sbc [hl] - jr c, .sub_f164 - call Functionf130 -.sub_f164 - ret - -Functionf165: - call Functionf1b5 - call Functionf19e - call Functionf1ac - ld a, d - or e - ret - -Functionf171: - call Functionf1ac - ld h, d - ld l, e - call Functionf1c5 - ld a, l - sub e - ld a, h - sbc d - ret - -Functionf17e: - ld a, $22 - call GetPartyParamLocation - ld a, [hli] - ld [wHPBarNewHP+1], a - ld a, [hl] - ld [wHPBarNewHP], a - ret - -Functionf18c: - ld a, d - ld [wHPBarNewHP+1], a - ld a, e - ld [wHPBarNewHP], a - ret - -Functionf195: - ld a, [wHPBarNewHP+1] - ld d, a - ld a, [wHPBarNewHP] - ld e, a - ret - -Functionf19e: - ld a, $22 - call GetPartyParamLocation - ld a, [hli] - ld [wReplacementBlock], a - ld a, [hl] - ld [wHPBarOldHP], a - ret - -Functionf1ac: - ld a, [wReplacementBlock] - ld d, a - ld a, [wHPBarOldHP] - ld e, a - ret - -Functionf1b5: - push hl - ld a, $24 - call GetPartyParamLocation - ld a, [hli] - ld [wMapBlocksAddress], a - ld a, [hl] - ld [wFieldMoveScriptID], a - pop hl - ret - -Functionf1c5: - ld a, [wMapBlocksAddress] - ld d, a - ld a, [wFieldMoveScriptID] - ld e, a - ret - -Functionf1ce: - ld a, MON_MAXHP - call GetPartyParamLocation - ld a, [hli] - ldh [hDividend], a - ld a, [hl] - ldh [hDividend + 1], a - ld a, $05 - ldh [hDivisor], a - ld b, $02 - call Divide - ldh a, [hQuotient + 2] - ld d, a - ldh a, [hQuotient + 3] - ld e, a - ret - -Functionf1e9: - push hl - ld a, [wCurItem] - ld hl, Dataf203 - ld d, a -.sub_f1f1 - ld a, [hli] - cp $ff - jr z, .sub_f1fd - cp d - jr z, .sub_f1fe - inc hl - inc hl - jr .sub_f1f1 -.sub_f1fd - scf -.sub_f1fe - ld e, [hl] - inc hl - ld d, [hl] - pop hl - ret - -Dataf203: - db $2e, $32, $00 - db $2f, $3c, $00 - db $30, $50, $00 - db $10, $c8, $00 - db $11, $32, $00 - db $12, $14, $00 - db $ff, $00, $00 - -Functionf218: - ld a, [wcd3c] - dec a - ld b, a -.sub_f21d - push bc - ld a, PARTYMENUACTION_HEALING_ITEM - ld [wPartyMenuActionText], a - predef PartyMenuInBattle - pop bc - jr c, .sub_f28c - ld a, [wcd3c] - dec a - ld c, a - ld a, b - cp c - jr z, .sub_f21d - push bc - ld a, c - ld [wCurPartyMon], a - call Functionf165 - jr z, .sub_f292 - call Functionf171 - jp nc, .sub_f29c - pop bc - push bc - ld a, b - ld [wCurPartyMon], a - call Functionf165 - call Functionf1ce - push de - ld a, $23 - call GetPartyParamLocation - ld a, [hl] - sub e - ld [hld], a - ld e, a - ld a, [hl] - sbc d - ld [hl], a - ld d, a - call Functionf18c - call Functionf0b0 - pop de - pop bc - push bc - push de - ld a, c - ld [wCurPartyMon], a - call Functionf165 - pop de - call Functionf13f - call Functionf0b0 - xor a - ldh [hBGMapMode], a - call ClearTileMap - ld a, PARTYMENUTEXT_HEAL_HP - ld [wPartyMenuActionText], a - predef Function5081f - ld c, $c8 - call Function3872 - pop bc -.sub_f28c - ld a, b - inc a - ld [wcd3c], a - ret -.sub_f292 - ld hl, Textf2a6 - call Function385a - pop bc - jp .sub_f21d -.sub_f29c - ld hl, Textf2a6 - call Function385a - pop bc - jp .sub_f21d - -Textf2a6: - text "その#には " - line "つかえません" - done - -Functionf2b5: - xor a - ld [wFieldMoveSucceeded], a - ld hl, DigFunction - ld a, $03 - call FarCall_hl - ret - -Functionf2c2: - ld b, $c8 - jp Functionf2ce - -Functionf2c7: - ld b, $fa - jp Functionf2ce - -Functionf2cc: - ld b, $64 - -Functionf2ce: - ld a, [wBattleMode] - and a - jp nz, IsntTheTimeMessage - ld a, b - ld [wce2d], a - jp Functionf793 - -Functionf2dc: - ld a, [wBattleMode] - and a - jp z, IsntTheTimeMessage - ld hl, wPlayerSubStatus4 - set 0, [hl] - jp Functionf793 - -Functionf2eb: - ld a, [wBattleMode] - dec a - jp nz, IsntTheTimeMessage - ld a, LOSE - ld [wBattleResult], a - jp Functionf793 - -Functionf2fa: - ld a, [wBattleMode] - and a - jp z, IsntTheTimeMessage - ld hl, wPlayerSubStatus4 - set 1, [hl] - jp Functionf793 - -Functionf309: - ld a, [wBattleMode] - and a - jp z, IsntTheTimeMessage - ld hl, wPlayerSubStatus4 - set 2, [hl] - jp Functionf793 - -Functionf318: - ld a, [wBattleMode] - and a - jr nz, .sub_f327 - call IsntTheTimeMessage - ld a, $02 - ld [wFieldMoveSucceeded], a - ret -.sub_f327 - ld hl, wPlayerMoveStruct - ld a, [hli] - push af - ld a, [hl] - push af - push hl - ld a, [wCurItem] - sub $37 - ld [hl], a - call Functionf793 - ld a, $ae - ld [wPlayerMoveStruct], a - call ReloadTilesFromBuffer - call WaitBGMap - xor a - ldh [hBattleTurn], a -; wrong bank - ld a, $f - ld hl, BattleCommand_StatUp - call FarCall_hl - pop hl - pop af - ld [hld], a - pop af - ld [hl], a - ret - -Functionf354: - ret - -Functionf355: - xor a - ld [wMovementBufferCount], a - ld b, $f8 - ld hl, wPartyMon1Status - call Functionf397 - ld a, [wBattleMode] - cp $01 - jr z, .sub_f36e - ld hl, wOTPartyMon1Status - call Functionf397 -.sub_f36e - ld hl, wBattleMonStatus - ld a, [hl] - and b - ld [hl], a - ld hl, wEnemyMonStatus - ld a, [hl] - and b - ld [hl], a - ld a, [wMovementBufferCount] - and a - ld hl, Textf3bd - jp z, PrintText - ld hl, Textf3ec - call PrintText - ld a, [wLowHealthAlarmBuffer] - and $80 - jr nz, .sub_f391 -.sub_f391 - ld hl, Textf3da - jp PrintText - -Functionf397: - ld de, $0030 - ld c, $06 -.sub_f39c - ld a, [hl] - push af - and $07 - jr z, .sub_f3a7 - ld a, $01 - ld [wMovementBufferCount], a -.sub_f3a7 - pop af - and b - ld [hl], a - add hl, de - dec c - jr nz, .sub_f39c - ret - -Dataf3af: - db $3e, $09 - db $3d, $0a - db $3f, $0a - db $3e, $0b - db $ff - -Dataf3b8: - db $0a, $1b - db $0a, $19 - db $ff - -Textf3bd: - text "#のふえを ふいた!" - para "うーん!" - line "すばらしい ねいろだ!" - prompt - -Textf3da: - text "すべての #が" - line "めを さました!" - prompt - -Textf3ec: - text "は" - line "#のふえを ふいてみた!@" - -Functionf3fd: - ld b, $08 - ld a, [wBattleMode] - and a - jr nz, .sub_f410 - push de - ld de, SFX_POKEFLUTE - call WaitPlaySFX - call WaitSFX - pop de -.sub_f410 - jp Function32d0 - -Functionf413: - ld a, [wBattleMode] - and a - jp nz, IsntTheTimeMessage - ld hl, Textf424 - call MenuTextBox - call CloseWindow - ret - -Textf424: - text "あなたの コイン" - line "@" - -Textf42f: - deciram wCoins, 2, 4 - text "まい" - prompt - -Functionf437: - call Functionf49f - jp c, IsntTheTimeMessage - ld bc, $0585 - ld a, $01 - jr Functionf478 - -Functionf444: - call Functionf49f - jp c, IsntTheTimeMessage -.sub_f44a - call Random - srl a - jr c, .sub_f463 - and $03 - cp $02 - jr nc, .sub_f44a - ld hl, Dataf46a - ld c, a - ld b, $00 - add hl, bc - add hl, bc - ld b, [hl] - inc hl - ld c, [hl] - and a -.sub_f463 - ld a, $00 - rla - xor $01 - jr Functionf478 - -Dataf46a: - db $0a, $9d, $0a, $47 - -Functionf46e: - call Functionf49f - jp c, IsntTheTimeMessage - call Functionf9d9 - ld a, e - -Functionf478: - ld [wMovementBufferCount], a - dec a - jr nz, .sub_f48b - ld a, $01 - ld [wca3a], a - ld a, b - ld [wCurPartyLevel], a - ld a, c - ld [wce01], a -.sub_f48b - ld hl, wPlayerState - ld a, [hl] - push af - ld [hl], $00 - push hl - ld a, $23 - ld hl, PutItemInPocket.loop - call FarCall_hl - pop hl - pop af - ld [hl], a - ret - -Functionf49f: - ld a, [wBattleMode] - and a - jr z, .sub_f4a7 - scf - ret -.sub_f4a7 - call Functionf9d7 - ret c - ld a, [wPlayerState] - cp $02 - jr z, .sub_f4c8 - call Functionfab4 - ld hl, ItemUsedText - call PrintText - ld de, SFX_FULL_HEAL - call WaitPlaySFX - ld c, $50 - call DelayFrames - and a - ret -.sub_f4c8 - scf - ret - -Functionf4ca: - ld a, [wBattleMode] - and a - jp nz, IsntTheTimeMessage - -Functionf4d1: - ld a, [wCurItem] - ld [wMovementBufferCount], a -.sub_f4d7 - ld a, PARTYMENUACTION_HEALING_ITEM - call Functionf0cf - jr nc, .sub_f4e1 - jp Functionf5f3 -.sub_f4e1 - ld a, [wMovementBufferCount] - cp $52 - jp nc, Functionf5bd - ld a, $02 - ld [wcac0], a - ld hl, Textf5ff - ld a, [wMovementBufferCount] - cp $50 - jr c, .sub_f4fb - ld hl, Textf610 -.sub_f4fb - call PrintText - callfar Function3daa7 - jr nz, .sub_f4d7 - ld hl, wPartyMon1Moves - ld bc, $0030 - call GetMthMoveOfNthPartymon - push hl - ld a, [hl] - ld [wce37], a - call GetMoveName - call CopyStringToStringBuffer2 - pop hl - ld a, [wMovementBufferCount] - cp $50 - jr nc, Functionf580 - ld bc, $0015 - add hl, bc - ld a, [hl] - cp $c0 - jr c, .sub_f535 - ld hl, Textf61f - call PrintText - jr .sub_f4e1 -.sub_f535 - ld a, [hl] - add $40 - ld [hl], a - ld a, $01 - ld [wce37], a - call ApplyPPUp - ld hl, Textf639 - call PrintText - -Functionf547: - call ClearPalettes - call GetMemSGBLayout - jp Functionf7a2 - -Functionf550: - ld a, [wBattleMode] - and a - jr z, .sub_f572 - ld a, [wCurPartyMon] - ld b, a - ld a, [wCurBattleMon] - cp b - jr nz, .sub_f572 - ld hl, wPartyMon1PP - ld bc, $0030 - call AddNTimes - ld de, wBattleMonPP - ld bc, $0004 - call CopyBytes -.sub_f572 - ld de, SFX_FULL_HEAL - call WaitPlaySFX - ld hl, Textf64c - call PrintText - jr Functionf547 - -Functionf580: - call Functionf588 - jr nz, Functionf550 - jp Functionf5f0 - -Functionf588: - xor a - ld [wMonType], a - call GetMaxPPOfMove - ld hl, wPartyMon1Moves - ld bc, PARTYMON_STRUCT_LENGTH - call GetMthMoveOfNthPartymon - ld bc, $0015 - add hl, bc - ld a, [wce37] - ld b, a - ld a, [wMovementBufferCount] - cp $51 - jr z, .sub_f5b8 - ld a, [hl] - and $3f - cp b - ret z - add $0a - cp b - jr nc, .sub_f5b2 - ld b, a -.sub_f5b2 - ld a, [hl] - and $c0 - add b - ld [hl], a - ret -.sub_f5b8 - ld a, [hl] - cp b - ret z - jr .sub_f5b2 - -Functionf5bd: - ld hl, wMovementBufferCount - dec [hl] - dec [hl] - xor a - ld hl, w2DMenuDataEnd - ld [hli], a - ld [hl], a - ld b, $04 -.sub_f5ca - push bc - ld hl, wPartyMon1Moves - ld bc, PARTYMON_STRUCT_LENGTH - call GetMthMoveOfNthPartymon - ld a, [hl] - and a - jr z, .sub_f5e1 - call Functionf588 - jr z, .sub_f5e1 - ld hl, wMenuCursorX - inc [hl] -.sub_f5e1 - ld hl, w2DMenuDataEnd - inc [hl] - pop bc - dec b - jr nz, .sub_f5ca - ld a, [wMenuCursorX] - and a - jp nz, Functionf550 - -Functionf5f0: - call WontHaveAnyEffectMessage - -Functionf5f3: - call ClearPalettes - call GetMemSGBLayout - pop af - xor a - ld [wFieldMoveSucceeded], a - ret - -Textf5ff: - text "どのわざの" - line "ポイントをふやす?" - done - -Textf610: - text "どのわざを" - line "かいふくする?" - done - -Textf61f: - text_from_ram wStringBuffer2 - text "は これいじょう" - line "ふやすことが できません" - prompt - -Textf639: - text_from_ram wStringBuffer2 - text "の" - line "わざポイントが ふえた!" - prompt - -Textf64c: - text "わざポイントが" - line "かいふくした!" - prompt - -Functionf65d: - ld a, [wBattleMode] - and a - jp nz, IsntTheTimeMessage - ld hl, TryTeleport - ld a, $0b - jp FarCall_hl - -Functionf66c: - jp IsntTheTimeMessage - -Functionf66f: - jp IsntTheTimeMessage - -Functionf672: - jp IsntTheTimeMessage - -Functionf675: - jp Functionfaba - -Functionf678: - ld a, [wBattleMode] - and a - jp nz, IsntTheTimeMessage - ld a, [wCurItem] - sub $c9 - push af - jr nc, .sub_f689 - add $37 -.sub_f689 - inc a - ld [wce37], a - predef GetTMHMMove - ld a, [wce37] - ld [wPutativeTMHMMove], a - call GetMoveName - call CopyStringToStringBuffer2 - pop af - ld hl, Textf723 - jr nc, .sub_f6a7 - ld hl, Textf72e -.sub_f6a7 - call PrintText - ld hl, Textf73d - call PrintText - call YesNoBox - jr nc, .sub_f6bb - ld a, $02 - ld [wFieldMoveSucceeded], a - ret -.sub_f6bb - ld hl, wHPBarTempHP - ld de, wMonOrItemNameBuffer - ld bc, $0008 - call CopyBytes - ld a, PARTYMENUACTION_TEACH_TMHM - call Functionf0cf - push af - ld hl, wMonOrItemNameBuffer - ld de, wHPBarTempHP - ld bc, $0008 - call CopyBytes - pop af - jr nc, .sub_f6ea - pop af - pop af - call ClearBGPalettes - call ClearSprites - call GetMemSGBLayout - jp ReloadTilesFromBuffer -.sub_f6ea - predef CanLearnTMHMMove - push bc - ld a, [wCurPartyMon] - ld hl, wPartyMonNicknames - call GetNick - pop bc - ld a, c - and a - jr nz, .sub_f70c - ld de, SFX_WRONG - call WaitPlaySFX - ld hl, Textf768 - call PrintText - jr .sub_f6bb -.sub_f70c - call Functionfdab - jr c, .sub_f6bb - predef LearnMove - ld a, b - and a - ret z - ld a, [wCurItem] - call IsHM - ret c - jp Functionf7a2 - -Textf723: - text "を きどうした!" - prompt - -Textf72e: - text "ひでんマシンを きどうした!" - -Textf73d: - text "なかには @" - -Textf744: - text_from_ram wStringBuffer2 - text "が" - line "きろくされていた!" - para "@" - -Textf755: - text_from_ram wStringBuffer2 - text "を" - line "#に おぼえさせますか?" - done - -Textf768: - text_from_ram wStringBuffer1 - text "と @" - -Textf76f: - text_from_ram wStringBuffer2 - text "は" - line "あいしょうが わるかった!" - para "@" - -Textf784: - text_from_ram wStringBuffer2 - text "は おぼえられない!" - prompt - -Functionf793: - ld hl, ItemUsedText - call PrintText - ld de, SFX_FULL_HEAL - call WaitPlaySFX - call TextboxWaitPressAorB_BlinkCursor - -Functionf7a2: - ld hl, wItems - ld a, $01 - ld [wItemQuantity], a - call TossItem - ret - -UseBallInTrainerBattle: - call ReturnToBattle_UseBall - ld de, ANIM_THROW_POKE_BALL - ld a, e - ld [wFXAnimID], a - ld a, d - ld [wFXAnimID + 1], a - xor a - ld [wBattleAnimParam], a - ldh [hBattleTurn], a - ld [wNumHits], a - predef PlayBattleAnim - ld hl, BallBlockedText - call PrintText - ld hl, BallDontBeAThiefText - call PrintText - jr Functionf7a2 - -Ball_BoxIsFullMessage: - ld hl, BallBoxFullText - jr CantUseItemMessage - -IsntTheTimeMessage: - ld hl, ItemOakWarningText - jr CantUseItemMessage - -WontHaveAnyEffectMessage: - ld hl, ItemWontHaveAnyEffectText - jr CantUseItemMessage - -BelongsToSomeoneElseMessage: ; unreferenced - ld hl, ItemBelongsToSomeoneElseText - jr CantUseItemMessage - -CyclingIsntAllowedMessage: ; unreferenced - ld hl, NoCyclingText - jr CantUseItemMessage - -CantGetOnYourBikeMessage: ; unreferenced - ld hl, ItemCantGetOnText - -CantUseItemMessage: - xor a - ld [wItemEffectSucceeded], a - jp PrintText - -ItemOakWarningText: - text "オーキドの ことば<⋯⋯>" - line "よ! こういうものには" - cont "つかいどきが あるのじゃ!" - prompt - -ItemBelongsToSomeoneElseText: - text "たいせつな あずかりものです!" - -Unreferenced_CantUseText: - db "" - next "つかうことは できません!" - prompt - -ItemWontHaveAnyEffectText: - text "つかっても こうかがないよ" - prompt - -BallBlockedText: - text "に ボールを はじかれた!" - prompt - -BallDontBeAThiefText: - text "ひとの ものを とったら どろぼう!" - prompt - -NoCyclingText: - text "ここでは じてんしゃに" - next "のることは できません" - prompt - -ItemCantGetOnText: - text "ここでは@" -Textf893: - text_from_ram wStringBuffer1 - text "に" - line "のることは できません" - prompt - -BallBoxFullText: - text "ボックスに あずけている #が" - line "いっぱいなので つかえません!" - prompt - -ItemUsedText: - text "は@" -Textf8ca: - text_low - text_from_ram wStringBuffer2 - text "を つかった!" - done - -ItemGotOnText: - text "は@" -Textf8db: - text_low - text_from_ram wStringBuffer2 - text "に のった" - prompt - -ItemGotOffText: - text "は@" -Textf8ea: - text_low - text_from_ram wStringBuffer2 - text "から おりた" - prompt - -SECTION "engine/dumps/bank03.asm@GetMaxPPOfMove", ROMX - -GetMaxPPOfMove: - ld a, [wMonType] - and a - - ld hl, wPartyMon1Moves - ld bc, PARTYMON_STRUCT_LENGTH - jr z, .got_partymon ; PARTYMON - - ld hl, wOTPartyMon1Moves - dec a - jr z, .got_partymon ; OTPARTYMON - - ld hl, wBoxMon1Moves - ld bc, BOXMON_STRUCT_LENGTH - dec a - jr z, .got_partymon ; BOXMON - - ld hl, wd884 - dec a - jr z, .got_nonpartymon ; TEMPMON - - ld hl, wBattleMonMoves ; WILDMON - -.got_nonpartymon ; TEMPMON, WILDMON - call GetMthMoveOfCurrentMon - jr .gotdatmove - -.got_partymon ; PARTYMON, OTPARTYMON, BOXMON - call GetMthMoveOfNthPartymon - -.gotdatmove - ld a, [hl] - dec a - - push hl - ld hl, Moves + MOVE_PP - ld bc, MOVE_LENGTH - call AddNTimes - ld a, BANK(Moves) - call GetFarByte - ld b, a - ld de, wStringBuffer1 - ld [de], a - pop hl - - push bc - ld bc, MON_PP - MON_MOVES - ld a, [wMonType] - cp WILDMON - jr nz, .notwild - ld bc, $0006 -.notwild - add hl, bc - ld a, [hl] - and PP_UP_MASK - pop bc - - or b - ld hl, wStringBuffer1 + 1 - ld [hl], a - xor a - ld [wce37], a - call ComputeMaxPP - ld a, [hl] - and PP_MASK - ld [wce37], a - ret - -GetMthMoveOfNthPartymon: - ld a, [wCurPartyMon] - call AddNTimes - -GetMthMoveOfCurrentMon: - ld a, [w2DMenuDataEnd] - ld c, a - ld b, $00 - add hl, bc - ret - -Functionf9d7: - scf - ret - -Functionf9d9: - ld a, [wMapId] - ld de, $0003 - ld hl, Datafa08 - call FindItemInTable - jr c, .sub_f9ea - ld e, $02 - ret -.sub_f9ea - inc hl - ld a, [hli] - ld h, [hl] - ld l, a - ld b, [hl] - inc hl - ld e, $00 -.sub_f9f2 - call Random - srl a - ret c - and $03 - cp b - jr nc, .sub_f9f2 - add a - ld c, a - ld b, $00 - add hl, bc - ld b, [hl] - inc hl - ld c, [hl] - ld e, $01 - ret - -Datafa08: - dbw $00, Datafa6c - dbw $01, Datafa6c - dbw $03, Datafa76 - dbw $05, Datafa7d - dbw $06, Datafa82 - dbw $07, Datafaab - dbw $08, Datafa99 - dbw $0f, Datafa76 - dbw $11, Datafa7d - dbw $15, Datafa82 - dbw $16, Datafa7d - dbw $17, Datafa90 - dbw $18, Datafa90 - dbw $1c, Datafa90 - dbw $1d, Datafa90 - dbw $1e, Datafa99 - dbw $1f, Datafa99 - dbw $20, Datafa99 - dbw $21, Datafa71 - dbw $22, Datafaa2 - dbw $23, Datafa76 - dbw $24, Datafa76 - dbw $41, Datafa76 - dbw $5e, Datafa7d - dbw $a1, Datafa99 - dbw $a2, Datafa99 - dbw $d9, Datafa87 - dbw $da, Datafa87 - dbw $db, Datafa87 - dbw $dc, Datafa87 - dbw $e2, Datafaa2 - dbw $e3, Datafaa2 - dbw $e4, Datafaa2 - db $ff - -Datafa6c: - db $02, $0f, $18, $0f, $47 - -Datafa71: - db $02, $0f, $9d, $0f, $47 - -Datafa76: - db $03, $0f, $2f, $0f, $9d, $0f, $4e - -Datafa7d: - db $02, $0f, $4e, $0f, $17 - -Datafa82: - db $02, $17, $6e, $0f, $25 - -Datafa87: - db $04, $0f, $58, $0f, $4e, $0f, $2f, $0f, $25 - -Datafa90: - db $04, $05, $18, $0f, $4e, $0f, $9d, $0f, $85 - -Datafa99: - db $04, $0f, $1b, $0f, $5c, $0f, $17, $0f, $9d - -Datafaa2: - db $04, $17, $08, $17, $9e, $17, $8a, $17, $5d - -Datafaab: - db $04, $17, $9e, $0f, $4e, $0f, $9d, $0f, $85 - -Functionfab4: - call LoadMapPart - jp UpdateSprites - -Functionfaba: - ld a, [wd8a2] - cp $02 - jr c, .sub_fade - cp $03 - jp z, Functionfd03 - cp $04 - jr z, .sub_fade - call Functionfbf0 - ld a, [wce37] - and a - jr z, .sub_fad8 - ld a, $03 - ld [wd8a2], a -.sub_fad8 - ld hl, Breeder_NoEggYetText - call PrintText -.sub_fade - ld hl, Breeder_IntroText - call PrintText - ld hl, Breeder_Menu - call LoadMenuHeader - call VerticalMenu - push af - call CloseWindow - pop af - jp c, Functionfbde - ld a, [w2DMenuDataEnd] - cp $03 - jp z, Functionfbde - cp $01 - jr z, .sub_fb4c - ld a, [wd8a2] - and a - jr z, .sub_fb19 - cp $02 - jr nz, .sub_fb22 - ld hl, Breeder_CheckOnPokemonText - call PrintText - call YesNoBox - jp c, Functionfbde - jr .sub_fb22 -.sub_fb19 - ld hl, Breeder_DoesntHavePokemonText - call PrintText - jp Functionfbde -.sub_fb22 - ld a, $01 - ld [wPokemonWithdrawDepositParameter], a - predef Functiondc16 - jp c, Functionfbea - ld a, [wd8a2] - sub $01 - jr z, .sub_fb38 - ld a, $01 -.sub_fb38 - ld [wd8a2], a - ld a, [wd8fd] - srl a - ld [wd8fd], a - ld hl, Breeder_WithdrawnText - call PrintText - jp Functionfbde -.sub_fb4c - ld a, [wd8a2] - cp $02 - jp nc, .sub_fbd6 - add PARTYMENUACTION_GIVE_MON - call Functionf0cf - jp c, Functionfbde - ld a, [wCurPartySpecies] - ld [wCurSpecies], a - call GetBaseData - xor a - ld [wMonType], a - predef GetGender - ld a, [wd8fd] - rla - ld [wd8fd], a - ld a, [wCurPartyMon] - ld hl, wPartyMonNicknames - call GetNick - ld a, $01 - ld [wPokemonWithdrawDepositParameter], a - predef Functiondcfc - xor a - ld [wPokemonWithdrawDepositParameter], a - ld hl, Functiondecd - ld a, BANK(Functiondecd) - call FarCall_hl - ld a, [wCurPartySpecies] - call PlayCry - ld hl, Breeder_DepositedText - call PrintText - ld a, [wd8a2] - inc a - ld [wd8a2], a - cp $02 - jr nz, Functionfbde - ld hl, Breeder_LetsMakeBabiesText - call PrintText - call Functionfbf0 - ld a, [wce37] - cp $50 - ld hl, Breeder_SeemToGetAlongText - call z, PrintText - ld a, [wce37] - cp $14 - ld hl, Breeder_DontSeemToGetAlongText - call z, PrintText - ld a, [wce37] - and a - ld hl, Breeder_GendersDontMatchText - call z, PrintText - jr Functionfbde -.sub_fbd6 - ld hl, Breeder_AlreadyHasTwoPokemonText - call PrintText - jr Functionfbde - -Functionfbde: - call ClearBGPalettes - call RestoreScreenAndReloadTiles - call GetMemSGBLayout - jp ReloadFontAndTileset - -Functionfbea: - ld hl, Textfc91 - jp PrintText - -Functionfbf0: - ld a, [wd8fd] - ld b, a - srl b - xor b - and $01 - jr z, .sub_fc15 - ld a, [wBreedMon1ID] - ld b, a - ld a, [wBreedMon2ID] - cp b - jr nz, .sub_fc13 - ld a, [wBreedMon1ID + 1] - ld b, a - ld a, [wBreedMon2ID + 1] - cp b - jr nz, .sub_fc13 - ld a, $14 - jr .sub_fc15 -.sub_fc13 - ld a, $50 -.sub_fc15 - ld [wce37], a - ret - -Breeder_IntroText: - text "わたしは こずくりやさん" - line "さて どうする?" - done - -Breeder_Menu: - db $40, $04, $0d, $0b, $13 - dw Breeder_MenuOptions - db $01 - -Breeder_MenuOptions: - db $80, $03 - db "あずける@" ; Deposit - db "ひきとる@" ; Withdraw - db "やめる@" ; Cancel - -Breeder_DepositedText: - text "あずけた!" - prompt - -Breeder_AlreadyHasTwoPokemonText: - text "すでに 2ひきの#を" - line "あずかっています" - prompt - -Breeder_CheckOnPokemonText: - text "こずくりを ちゅうししますか?" - done - -Breeder_DoesntHavePokemonText: - text "#は いっぴきも" - line "あずかってませんが" - prompt - -Breeder_WithdrawnText: - text "ひきとった!" - prompt - -Textfc91: - text "てもちも マサキの も" - line "#で いっぱいのようです" - prompt - -Breeder_LetsMakeBabiesText: - text "それでは こづくりします!" - prompt - -Breeder_SeemToGetAlongText: - text "あいしょうが いいようです" - prompt - -Breeder_DontSeemToGetAlongText: - text "あいしょうが わるいようです" - prompt - -Breeder_GendersDontMatchText: - text "せいべつが あわないようです" - prompt - -Breeder_NoEggYetText: - text "ざんねんながら まだ うまれて" - line "こないようです" - prompt - -Functionfd03: - ld hl, Breeder_EggLaidText - call PrintText - call YesNoBox - jp c, Functionfbde - ld a, $04 - ld [wd8a2], a - ld a, [wBreedMon1Species] - ld [wCurPartySpecies], a - call PlayCry - xor a - ld [wMonType], a - ld a, $05 - ld [wCurPartyLevel], a - predef Functionde79 - jp Functionfbde - -Breeder_EggLaidText: - text "タマゴが うまれました!" - line "ひきとりますか?" - done - -Functionfd45: - ret - -GetPokeBallWobble: -; Returns whether a Poke Ball will wobble in the catch animation. -; Whether a Pokemon is caught is determined beforehand. - - ld a, [wThrownBallWobbleCount] - inc a - ld [wThrownBallWobbleCount], a - -; Wobble up to 3 times. - cp 3 + 1 - jr z, .finished - ld a, [wWildMon] - and a - ld c, 0 ; next - ret nz - ld hl, WobbleProbabilities - ld a, [wFinalCatchRate] - ld b, a -.loop - ld a, [hli] - cp b - jr nc, .checkwobble - inc hl - jr .loop -.checkwobble - ld b, [hl] - call Random - cp b - ld c, 0 ; next - ret c - ld c, 2 ; escaped - ret - -.finished - ld a, [wWildMon] - and a - ld c, 1 ; caught - ret nz - ld c, 2 ; escaped - ret - -WobbleProbabilities: -; catch rate, chance of wobbling / 255 -; nLeft/255 = (nRight/255) ** 4 - db 1, 63 - db 2, 75 - db 3, 84 - db 4, 90 - db 5, 95 - db 7, 103 - db 10, 113 - db 15, 126 - db 20, 134 - db 30, 149 - db 40, 160 - db 50, 169 - db 60, 177 - db 80, 191 - db 100, 201 - db 120, 211 - db 140, 220 - db 160, 227 - db 180, 234 - db 200, 240 - db 220, 246 - db 240, 251 - db 254, 253 - db 255, 255 - -Functionfdab: - ld a, $02 - call GetPartyParamLocation - ld a, [wPutativeTMHMMove] - ld b, a - ld c, $04 -.sub_fdb6 - ld a, [hli] - cp b - jr z, .sub_fdbf - dec c - jr nz, .sub_fdb6 - and a - ret -.sub_fdbf - ld hl, .knows_move_text - call PrintText - scf - ret - -.knows_move_text - text_from_ram wStringBuffer1 - text "は すでに" - line "@" -Textfdd2: - text_from_ram wStringBuffer2 - text "を おぼえています" - prompt - -Textfde0: - db "います" - prompt - -; NOTE: This is missing the preceeding "text_from_ram" byte -Textfde4: - dw wStringBuffer2 - text "を おぼえています" - prompt - -Datafdf1: - db $28, $3c - -Functionfdf3: - ld a, [wPutativeTMHMMove] - ld b, a - ld c, $04 -.sub_fdf9 - ld a, [hli] - cp b - jr z, .sub_fe02 - dec c - jr nz, .sub_fdf9 - and a - ret -.sub_fe02 - ld hl, .knows_move_text - call PrintText - scf - ret - -.knows_move_text - text_from_ram wStringBuffer1 - text "は すでに" - line "@" -Textfe15: - text_from_ram wStringBuffer2 - text "を おぼえています" - prompt - -Datafe23: - db $e0, $22, $47, $24, $80, $a3, $01, $50 - db $02, $85, $b0, $09, $35, $51, $2c, $08 - db $24, $25, $0b, $84, $84, $00, $4e, $3b - db $4b, $02, $60, $2a, $26, $21, $01, $40 - db $10, $1f, $31, $44, $80, $08, $02, $3c - db $41, $00, $68, $49, $57, $41, $94, $00 - db $34, $36, $9c, $e4, $01, $0c, $60, $01 - db $81, $23, $a2, $26, $43, $05, $81, $5f - db $16, $a2, $80, $34, $0c, $82, $63, $91 - db $44, $52, $02, $ce, $00, $10, $44, $01 - db $96, $0e, $ac, $10, $23, $84, $28, $00 - db $22, $45, $22, $55, $00, $ef, $ff, $77 - db $5b, $fe, $87, $db, $df, $b5, $bf, $d7 - db $1f, $d9, $fc, $e9, $fd, $df, $79, $96 - db $7d, $af, $d7, $5e, $17, $37, $e7, $ef - db $3e, $ff, $f9, $d4, $7d, $bf, $fb, $df - db $bb, $fe, $db, $53, $fb, $cc, $d3, $fe - db $92, $7f, $bb, $bc, $d7, $3b, $dd, $6f - db $7b, $2f, $b7, $ff, $b9, $d0, $b7, $e5 - db $7b, $e0, $c7, $bf, $dd, $df, $6d, $bb - db $f6, $f7, $73, $f9, $ff, $bc, $bb, $f7 - db $fd, $bd, $db, $e7, $be, $7b, $35, $5b - db $f3, $98, $df, $f4, $2f, $fb, $ff, $6b - db $fe, $ef, $6b, $ec, $1f, $7a, $3e, $ea - db $9b, $dd, $df, $ed, $ff, $fe, $bf, $26 - db $7d, $9e, $ef, $be, $ff, $77, $fb, $ff - db $ff, $5e, $f2, $bc, $fd, $7a, $aa, $fa - db $af, $9d, $ed, $f1, $fd, $10, $10, $2d - db $d1, $00, $21, $14, $d3, $1b, $27, $22 - db $85, $45, $5a, $43, $0c, $b1, $74, $61 - db $48, $40, $2f, $8c, $84, $08, $c2, $90 - db $f7, $44, $45, $80, $90, $12, $c5, $93 - db $1c, $11, $6e, $c8, $26, $25, $c1, $25 - db $00, $1e, $55, $02, $54, $04, $0f, $10 - db $20, $d7, $a2, $3c, $04, $3b, $02, $01 - db $22, $00, $c0, $00, $13, $d2, $05, $02 - db $48, $2a, $89, $40, $1f, $3e, $44, $12 - db $40, $16, $d8, $91, $10, $01, $54, $87 - db $1f, $99, $40, $d0, $79, $f8, $25, $4c - db $d0, $a0, $02, $13, $1c, $02, $03, $11 - db $a0, $19, $06, $0e, $70, $97, $44, $0e - db $11, $24, $0f, $80, $60, $06, $09, $01 - db $c5, $e1, $30, $13, $15, $14, $59, $02 - db $4c, $a9, $11, $08, $04, $eb, $df, $9d - db $55, $ff, $b7, $57, $fb, $78, $7e, $7e - db $c7, $3a, $e1, $ff, $5f, $7d, $5f, $fd - db $5f, $f8, $6d, $2f, $bd, $75, $6f, $3f - db $ff, $9f, $fc, $b5, $f6, $c5, $14, $fa - db $d9, $ff, $9d, $fb, $7f, $f3, $ff, $6b - db $fb, $9f, $eb, $5f, $df, $de, $ed, $bf - db $7f, $59, $26, $df, $ee, $b3, $5f, $fd - db $f7, $ff, $ff, $ff, $5b, $f8, $db, $fa - db $7f, $de, $af, $5f, $df, $9f, $d8, $be - db $ea, $bf, $fe, $eb, $dd, $eb, $f9, $e5 - db $bd, $f3, $ff, $fe, $ff, $f7, $f7, $d5 - db $f5, $f9, $5f, $bf, $fd, $5e, $df, $de - db $ff, $bf, $bb, $93, $fc, $ff, $cc, $af - db $f5, $d7, $7f, $ff, $fe, $b5, $ff, $9f - db $95, $7a, $6b, $7b, $ff, $6f, $bb, $c7 - db $ef, $34, $ff, $d7, $3d +.check_inline_trainer + jp CheckInlineTrainer diff --git a/engine/dumps/bank09.asm b/engine/dumps/bank09.asm deleted file mode 100644 index 97a1bc8..0000000 --- a/engine/dumps/bank09.asm +++ /dev/null @@ -1,2042 +0,0 @@ -INCLUDE "constants.asm" - -SECTION "engine/dumps/bank09.asm@Function24000", ROMX - -Function24000: - xor a - call OpenSRAM - ld hl, wWindowStackPointer - ld e, [hl] - inc hl - ld d, [hl] - push de - ld b, $10 - ld hl, wMenuDataHeader -.asm_24010 - ld a, [hli] - ld [de], a - dec de - dec b - jr nz, .asm_24010 - ld a, [wMenuDataHeader] - bit 6, a - jr nz, .asm_24028 - bit 7, a - jr z, .asm_2404e - push de - call asm_240b3 - pop de - jr nc, .asm_2404e -.asm_24028 - ld hl, wWindowStackPointer - ld a, [hli] - ld h, [hl] - ld l, a - set 0, [hl] - call MenuBoxCoord2Tile - call GetMenuBoxDims - inc b - inc c - call Function2406d - -.asm_2403b - push bc - push hl -.asm_2403d - ld a, [hli] - ld [de], a - dec de - dec c - jr nz, .asm_2403d - pop hl - ld bc, SCREEN_WIDTH - add hl, bc - pop bc - dec b - jr nz, .asm_2403b - jr .asm_24055 - -.asm_2404e - pop hl - push hl - ld a, [hld] - ld l, [hl] - ld h, a - res 0, [hl] - -.asm_24055 - pop hl - call Function2406d - ld a, h - ld [de], a - dec de - ld a, l - ld [de], a - dec de - ld hl, wWindowStackPointer - ld [hl], e - inc hl - ld [hl], d - call CloseSRAM - ld hl, wWindowStackSize - inc [hl] - ret - -Function2406d: - push bc - push de - push hl - xor a - ld l, c - ld h, $00 - ld c, b - ld b, $00 - ld a, $14 - call AddNTimes - ld a, h - cpl - ld h, a - ld a, l - cpl - ld l, a - inc hl - add hl, de - ld a, e - sub $00 - ld a, d - sbc $b8 - jr c, Function24090 - pop hl - pop de - pop bc - ret - -Function24090: - ld hl, .text_2409c - call PrintText - call WaitBGMap -.asm_24099 - nop - jr .asm_24099 - -.text_2409c: - text "ウィンドウセーブエりアが" - next "オーバーしました" - done - -asm_240b3: - ld hl, wWindowStackPointer - ld a, [hli] - ld h, [hl] - ld l, a -asm_240b9: - inc hl - ld a, [hli] - ld h, [hl] - ld l, a - or h - jr z, asm_240d0 - push hl - dec hl - ld b, [hl] - dec hl - ld c, [hl] - dec hl - ld d, [hl] - dec hl - ld e, [hl] - call asm_240f2 - pop hl - ret c - jr asm_240b9 -asm_240d0: - ld hl, wMenuBorderTopCoord - ld b, [hl] - inc hl - ld c, [hl] - inc hl - ld d, [hl] - inc hl - ld e, [hl] - inc hl - ld hl, wWindowStackPointer - ld a, [hli] - ld h, [hl] - ld l, a -asm_240e1: - inc hl - ld a, [hli] - ld h, [hl] - ld l, a - or h - ret z - push hl - ld a, [hld] - ld l, [hl] - ld h, a - call asm_24116 - pop hl - ret c - jr asm_240e1 -asm_240f2: - ld a, [wMenuBorderTopCoord] - ld h, a - ld a, [wMenuBorderLeftCoord] - ld l, a - call asm_24116 - ret c - ld a, [wMenuBorderBottomCoord] - ld h, a - call asm_24116 - ret c - ld a, [wMenuBorderRightCoord] - ld l, a - call asm_24116 - ret c - ld a, [wMenuBorderTopCoord] - ld h, a - call asm_24116 - ret - -asm_24116: - ld a, h - cp b - jr c, asm_2412a - cp d - jr c, asm_2411f - jr nz, asm_2412a -asm_2411f: - ld a, l - cp c - jr c, asm_2412a - cp e - jr c, asm_24128 - jr nz, asm_2412a -asm_24128: - scf - ret - -asm_2412a: - and a - ret - -_ExitMenu:: - xor a - ldh [hBGMapMode], a - xor a - call OpenSRAM - call GetWindowStackTop - ld a, l - or h - jp z, Function24164 - ld a, l - ld [wWindowStackPointer], a - ld a, h - ld [wWindowStackPointer + 1], a - call PopWindow - ld a, [wMenuDataHeader] - bit 0, a - jr z, asm_24152 - ld d, h - ld e, l - call RestoreTileBackup -asm_24152: - call GetWindowStackTop - ld a, h - or l - jr z, asm_2415c - call PopWindow -asm_2415c: - call CloseSRAM - ld hl, wWindowStackSize - dec [hl] - ret - -Function24164: - ld hl, .text_2416f - call PrintText - call WaitBGMap -.loop - jr .loop - -.text_2416f: - text "ポップできる ウィンドウが" - next "ありません!" - done - -Function24185:: - xor a - call OpenSRAM - call GetWindowStackTop - ld a, l - or h - jr z, asm_24195 - call _ExitMenu - jr Function24185 -asm_24195: - call CloseSRAM - ret - -_InitVerticalMenuCursor:: - ld a, [wMenuDataHeaderEnd] - ld b, a - ld hl, wMenuData3 - ld a, [wMenuBorderTopCoord] - inc a - bit 6, b - jr nz, asm_241a9 - inc a -asm_241a9: - ld [hli], a - ld a, [wMenuBorderLeftCoord] - inc a - ld [hli], a - ld a, [wMenuDataItems] - ld [hli], a - ld a, $01 - ld [hli], a - ld [hl], $00 - bit 5, b - jr z, asm_241be - set 5, [hl] -asm_241be: - ld a, [wMenuDataHeader] - bit 4, a - jr z, asm_241c7 - set 6, [hl] -asm_241c7: - inc hl - xor a - ld [hli], a - ld a, $20 - ld [hli], a - ld a, $01 - bit 0, b - jr nz, asm_241d5 - add $02 -asm_241d5: - ld [hli], a - ld a, [wMenuCursorBuffer] - and a - jr z, asm_241e3 - ld c, a - ld a, [wMenuDataItems] - cp c - jr nc, asm_241e5 -asm_241e3: - ld c, $01 -asm_241e5: - ld [hl], c - inc hl - ld a, $01 - ld [hli], a - xor a - ld [hli], a - ld [hli], a - ld [hli], a - ret - -UpdateItemDescription:: - ld a, [wMenuSelection] - ld [wSelectedItem], a - hlcoord 0, 12 - ld b, $04 - ld c, $12 - call DrawTextBox - decoord 1, 14 - callfar ShowItemDescription - ret - -Pokepic: - ld a, $01 - ldh [hBGMapMode], a - ld hl, .PokepicMenuHeader - call LoadMenuHeader - call MenuBox - call UpdateSprites - ld b, SGB_POKEPIC - call GetSGBLayout - xor a - ldh [hBGMapMode], a - ld a, [wCurPartySpecies] - ld [wCurSpecies], a - call GetBaseData - ld de, vFont - call LoadMonFrontSprite - ld a, [wMenuBorderTopCoord] - inc a - ld b, a - ld a, [wMenuBorderLeftCoord] - inc a - ld c, a - call Coord2Tile - ld a, $80 - ldh [hGraphicStartTile], a - lb bc, 7, 7 - predef PlaceGraphic - ld a, $01 - ldh [hBGMapMode], a - call TextboxWaitPressAorB_BlinkCursor - call ClearMenuBoxInterior - call WaitBGMap - call GetMemSGBLayout - call CloseWindow - call LoadFont - ret - -.PokepicMenuHeader: - db MENU_BACKUP_TILES - menu_coords 6, 4, $e, $d - dw 0 - db 1 - -_InitScrollingMenu:: - xor a - ld [wMenuJoypad], a - ldh [hBGMapMode], a - inc a - ldh [hInMenu], a - ld hl, wOptions - set NO_TEXT_SCROLL_F, [hl] - call asm_243c3 - call asm_243fc - ld c, $0a - call DelayFrames - call Function242a3 - ret - -_ScrollingMenu:: - call Function242b6 - jp c, .asm_24296 - ld a, $00 - ldh [hJoypadSum], a - call z, Function242a3 - jr _ScrollingMenu -.asm_24296 - ld [wMenuJoypad], a - ld a, $00 - ldh [hInMenu], a - ld hl, wOptions - res NO_TEXT_SCROLL_F, [hl] - ret - -Function242a3: - xor a - ldh [hBGMapMode], a - call Function24475 - call Function244ff - call Function2452c - xor a - ldh [hJoypadSum], a - call WaitBGMap - ret - -Function242b6: - call Get2DMenuJoypad_NoPlaceCursor - ldh a, [hJoySum] - and $f0 - ld b, a - ldh a, [hJoypadSum] - and $0f - or b - bit 0, a - jp nz, Function242f1 - bit 1, a - jp nz, asm_2431c - bit 2, a - jp nz, Function24320 - bit 3, a - jp nz, Function24342 - bit 4, a - jp nz, asm_24362 - bit 5, a - jp nz, asm_2434e - bit 6, a - jp nz, asm_24376 - bit 7, a - jp nz, asm_2438a - jr Function242b6 - ld a, $ff - and a - ret - -Function242f1: - call PlaceHollowCursor - ld a, [w2DMenuDataEnd] - dec a - call asm_24555 - ld a, [wMenuSelection] - ld [wCurItem], a - ld a, [wMenuSelectionQuantity] - ld [wItemQuantityBuffer], a - call asm_243a5 - dec a - ld [wScrollingMenuCursorPosition], a - ld [wItemIndex], a - ld a, [wMenuSelection] - cp $ff - jr z, asm_2431c - ld a, $01 - scf - ret - -asm_2431c: - ld a, $02 - scf - ret - -Function24320: - ld a, [wMenuDataHeaderEnd] - bit 7, a - jp z, SetFFInAccumulator - ld a, [w2DMenuDataEnd] - dec a - call asm_24555 - ld a, [wMenuSelection] - cp $ff - jp z, SetFFInAccumulator - call asm_243a5 - dec a - ld [wScrollingMenuCursorPosition], a - ld a, $04 - scf - ret - -Function24342: - ld a, [wMenuDataHeaderEnd] - bit 6, a - jp z, SetFFInAccumulator - ld a, $08 - scf - ret - -asm_2434e: - ld hl, w2DMenuFlags2 - bit 7, [hl] - jp z, SetFFInAccumulator - ld a, [wMenuDataHeaderEnd] - bit 3, a - jp z, SetFFInAccumulator - ld a, $20 - scf - ret - -asm_24362: - ld hl, w2DMenuFlags2 - bit 7, [hl] - jp z, SetFFInAccumulator - ld a, [wMenuDataHeaderEnd] - bit 2, a - jp z, SetFFInAccumulator - ld a, $10 - scf - ret - -asm_24376: - ld hl, w2DMenuFlags2 - bit 7, [hl] - jp z, ClearAccumulator - ld hl, wMenuScrollPosition - ld a, [hl] - and a - jp z, ClearAccumulator - dec [hl] - jp ClearAccumulator - -asm_2438a: - ld hl, w2DMenuFlags2 - bit 7, [hl] - jp z, ClearAccumulator - ld hl, wMenuScrollPosition - ld a, [wMenuDataItems] - add [hl] - ld b, a - ld a, [wScrollingMenuListSize] - cp b - jp c, ClearAccumulator - inc [hl] - jp ClearAccumulator - -asm_243a5: - ld a, [wMenuScrollPosition] - ld c, a - ld a, [w2DMenuDataEnd] - add c - ld c, a - ret - -ScrollingMenu_ClearLeftColumn:: - call MenuBoxCoord2Tile - ld de, $14 - add hl, de - ld de, $28 - ld a, [wMenuDataItems] -asm_243bc: - ld [hl], $7f - add hl, de - dec a - jr nz, asm_243bc - ret - -asm_243c3: - ld hl, wMenuDataDisplayFunctionPointer + 1 - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [wMenuDataDisplayFunctionPointer] - call GetFarByte - ld [wScrollingMenuListSize], a - ld a, [wMenuScrollPosition] - ld c, a - ld a, [wMenuCursorBuffer] - add c - ld b, a - ld a, [wScrollingMenuListSize] - inc a - cp b - jr c, .asm_243f2 - ld a, [wMenuScrollPosition] - ld c, a - ld a, [wMenuDataItems] - add c - ld b, a - ld a, [wScrollingMenuListSize] - inc a - cp b - jr nc, .asm_243fb -.asm_243f2 - xor a - ld [wMenuScrollPosition], a - ld a, $01 - ld [wMenuCursorBuffer], a -.asm_243fb - ret - -asm_243fc: - ld a, [wMenuDataHeaderEnd] - ld c, a - ld a, [wScrollingMenuListSize] - ld b, a - ld a, [wMenuBorderTopCoord] - add $01 - ld [wMenuData3], a - ld a, [wMenuBorderLeftCoord] - add $00 - ld [w2DMenuCursorInitX], a - ld a, [wMenuDataItems] - cp b - jr c, asm_2441e - jr z, asm_2441e - ld a, b - inc a -asm_2441e: - ld [w2DMenuNumRows], a - ld a, $01 - ld [w2DMenuNumCols], a - ld a, $8c - bit 2, c - jr z, asm_2442e - set 0, a -asm_2442e: - bit 3, c - jr z, asm_24434 - set 1, a -asm_24434: - ld [w2DMenuFlags1], a - xor a - ld [w2DMenuFlags2], a - ld a, $20 - ld [w2DMenuCursorOffsets], a - ld a, $c3 - bit 7, c - jr z, asm_24448 - add $04 -asm_24448: - bit 6, c - jr z, asm_2444e - add $08 -asm_2444e: - ld [wMenuJoypadFilter], a - ld a, [w2DMenuNumRows] - ld b, a - ld a, [wMenuCursorBuffer] - and a - jr z, asm_24460 - cp b - jr z, asm_24462 - jr c, asm_24462 -asm_24460: - ld a, $01 -asm_24462: - ld [w2DMenuDataEnd], a - ld a, $01 - ld [wMenuCursorX], a - xor a - ld [wCursorCurrentTile], a - ld [wCursorCurrentTile + 1], a - ld [wCursorOffCharacter], a - ret - -Function24475: - call ClearWholeMenuBox - ld a, [wMenuScrollPosition] - and a - jr z, asm_2448b - ld a, [wMenuBorderTopCoord] - ld b, a - ld a, [wMenuBorderRightCoord] - ld c, a - call Coord2Tile - ld [hl], $61 -asm_2448b: - call MenuBoxCoord2Tile - ld bc, $0015 - add hl, bc - ld a, [wMenuDataItems] - ld b, a - ld c, $00 -asm_24498: - ld a, [wMenuScrollPosition] - add c - ld [wScrollingMenuCursorPosition], a - ld a, c - call asm_24555 - ld a, [wMenuSelection] - cp $ff - jr z, asm_244c8 - push bc - push hl - call asm_244e2 - pop hl - ld bc, $0028 - add hl, bc - pop bc - inc c - ld a, c - cp b - jr nz, asm_24498 - ld a, [wMenuBorderBottomCoord] - ld b, a - ld a, [wMenuBorderRightCoord] - ld c, a - call Coord2Tile - ld [hl], $ee - ret - -asm_244c8: - ld a, [wMenuDataHeaderEnd] - bit 0, a - jr nz, asm_244da - ld de, .text_244d6 - call PlaceString - ret - -.text_244d6: - db "やめる@" - -asm_244da: - ld d, h - ld e, l - ld hl, wMenuDataPointerTableAddr + 1 - jp CallFar_atHL - -asm_244e2: - push hl - ld d, h - ld e, l - ld hl, wMenuDataPointerTableAddr + 1 - call CallFar_atHL - pop hl - ld a, [wMenuDataIndicesPointer] - and a - jr z, asm_244fe - ld e, a - ld d, $00 - add hl, de - ld d, h - ld e, l - ld hl, wcc1c - call CallFar_atHL -asm_244fe: - ret - -Function244ff: - ld a, [wSelectedSwapPosition] - and a - jr z, asm_2452b - ld b, a - ld a, [wMenuScrollPosition] - cp b - jr nc, asm_2452b - ld c, a - ld a, [wMenuDataItems] - add c - cp b - jr c, asm_2452b - ld a, b - sub c - dec a - add a - add $01 - ld c, a - ld a, [wMenuBorderTopCoord] - add c - ld b, a - ld a, [wMenuBorderLeftCoord] - add $00 - ld c, a - call Coord2Tile - ld [hl], $ec -asm_2452b: - ret - -Function2452c: - ld a, [wMenuDataHeaderEnd] - bit 5, a - ret z - hlcoord 0, 12 - ld b, $04 - ld c, $12 - call DrawTextBox - ld a, [w2DMenuDataEnd] - dec a - call asm_24555 - ld a, [wMenuSelection] - cp $ff - jr z, .done - decoord 1, 14 - ld hl, wcc1f - call CallFar_atHL - ret - -.done - ret - -asm_24555: - push de - push hl - ld e, a - ld a, [wMenuScrollPosition] - add e - ld e, a - ld d, $00 - ld hl, wMenuDataDisplayFunctionPointer + 1 - ld a, [hli] - ld h, [hl] - ld l, a - inc hl - ld a, [wMenuDataIndicesPointer + 1] - cp $01 - jr z, asm_24576 - cp $02 - jr z, asm_24575 - cp $80 - jr z, asm_24590 -asm_24575: - add hl, de -asm_24576: - add hl, de - ld a, [wMenuDataDisplayFunctionPointer] - call GetFarByte - ld [wMenuSelection], a - ld [wCurItem], a - inc hl - ld a, [wMenuDataDisplayFunctionPointer] - call GetFarByte - ld [wMenuSelectionQuantity], a - pop hl - pop de - ret - -asm_24590: - ld a, [wScrollingMenuListSize] - ld d, a - ld a, e - cp d - jr nc, asm_245b5 - inc e - ld d, $00 -asm_2459b: - inc d - ld a, [hli] - and a - jr z, asm_2459b - dec e - jr nz, asm_2459b - dec hl - dec d - push bc - push hl - ld c, d - callfar GetBallByIndex - ld d, c - pop hl - pop bc - jr asm_245b7 -asm_245b5: - ld d, $ff -asm_245b7: - ld a, d - ld [wMenuSelection], a - ld [wCurItem], a - ld a, [hl] - ld [wMenuSelectionQuantity], a - pop hl - pop de - ret - -SwitchItemsInBag:: - ld a, [wSelectedSwapPosition] - and a - jr z, asm_24602 - ld b, a - ld a, [wScrollingMenuCursorPosition] - inc a - cp b - jr z, asm_2460a - ld a, [wScrollingMenuCursorPosition] - call asm_246f7 - ld a, [hl] - cp $ff - ret z - ld a, [wSelectedSwapPosition] - dec a - ld [wSelectedSwapPosition], a - ld a, [wSelectedSwapPosition] - call asm_246f7 - push hl - ld a, [wScrollingMenuCursorPosition] - call asm_246f7 - ld a, [hl] - pop hl - cp [hl] - jr z, asm_2466c - ld a, [wScrollingMenuCursorPosition] - ld c, a - ld a, [wSelectedSwapPosition] - cp c - jr c, asm_2463f - jr asm_2460f -asm_24602: - ld a, [wScrollingMenuCursorPosition] - inc a - ld [wSelectedSwapPosition], a - ret - -asm_2460a: - xor a - ld [wSelectedSwapPosition], a - ret - -asm_2460f: - ld a, [wSelectedSwapPosition] - call asm_246db - ld a, [wScrollingMenuCursorPosition] - ld d, a - ld a, [wSelectedSwapPosition] - ld e, a - call asm_24707 - push bc - ld a, [wSelectedSwapPosition] - call asm_246f7 - dec hl - push hl - call asm_2471b - add hl, bc - ld d, h - ld e, l - pop hl - pop bc - call asm_24732 - ld a, [wScrollingMenuCursorPosition] - call asm_246e8 - xor a - ld [wSelectedSwapPosition], a - ret - -asm_2463f: - ld a, [wSelectedSwapPosition] - call asm_246db - ld a, [wScrollingMenuCursorPosition] - ld d, a - ld a, [wSelectedSwapPosition] - ld e, a - call asm_24707 - push bc - ld a, [wSelectedSwapPosition] - call asm_246f7 - ld d, h - ld e, l - call asm_2471b - add hl, bc - pop bc - call CopyBytes - ld a, [wScrollingMenuCursorPosition] - call asm_246e8 - xor a - ld [wSelectedSwapPosition], a - ret - -asm_2466c: - ld a, [wSelectedSwapPosition] - call asm_246f7 - inc hl - push hl - ld a, [wScrollingMenuCursorPosition] - call asm_246f7 - inc hl - ld a, [hl] - pop hl - add [hl] - cp $64 - jr c, asm_2469c - sub $63 - push af - ld a, [wScrollingMenuCursorPosition] - call asm_246f7 - inc hl - ld [hl], $63 - ld a, [wSelectedSwapPosition] - call asm_246f7 - inc hl - pop af - ld [hl], a - xor a - ld [wSelectedSwapPosition], a - ret - -asm_2469c: - push af - ld a, [wScrollingMenuCursorPosition] - call asm_246f7 - inc hl - pop af - ld [hl], a - ld hl, wMenuDataDisplayFunctionPointer + 1 - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [wSelectedSwapPosition] - cp [hl] - jr nz, asm_246c0 - dec [hl] - ld a, [wSelectedSwapPosition] - call asm_246f7 - ld [hl], $ff - xor a - ld [wSelectedSwapPosition], a - ret - -asm_246c0: - dec [hl] - call asm_2471b - push bc - ld a, [wSelectedSwapPosition] - call asm_246f7 - pop bc - push hl - add hl, bc - pop de -asm_246cf: - ld a, [hli] - ld [de], a - inc de - cp $ff - jr nz, asm_246cf - xor a - ld [wSelectedSwapPosition], a - ret - -asm_246db: - call asm_246f7 - ld de, wMovementBufferCount - call asm_2471b - call CopyBytes - ret - -asm_246e8: - call asm_246f7 - ld d, h - ld e, l - ld hl, wMovementBufferCount - call asm_2471b - call CopyBytes - ret - -asm_246f7: - push af - call asm_2471b - ld hl, wMenuDataDisplayFunctionPointer + 1 - ld a, [hli] - ld h, [hl] - ld l, a - inc hl - pop af - call AddNTimes - ret - -asm_24707: - push hl - call asm_2471b - ld a, d - sub e - jr nc, asm_24711 - dec a - cpl -asm_24711: - ld hl, 0 - call AddNTimes - ld b, h - ld c, l - pop hl - ret - -asm_2471b: - push hl - ld a, [wMenuDataIndicesPointer + 1] - ld c, a - ld b, $00 - ld hl, .data_2472c - add hl, bc - add hl, bc - ld c, [hl] - inc hl - ld b, [hl] - pop hl - ret - -.data_2472c: - dw 0 - dw 1 - dw 2 - -asm_24732: - ld a, [hld] - ld [de], a - dec de - dec bc - ld a, b - or c - jr nz, asm_24732 - ret - -Function2473b:: - ld a, [wMenuSelection] - cp $ff - jr z, .asm_24762 - push de - callfar CheckItemMenu - ld a, [wItemAttributeValue] - ld e, a - ld d, $00 - ld hl, .data_2475b - add hl, de - ld a, [hl] - pop de - ld [de], a - inc de - jr PlaceMenuItemName - -.data_2475b: - db $7f, $62, $64, $63, $7f, $7f, $7f - -.asm_24762 - ld h, d - ld l, e - ld de, .text_2476b - call PlaceString - ret - -.text_2476b: - db " ーーやめるーー@" - -PlaceMenuItemName:: - push de - ld a, [wMenuSelection] - ld [wNamedObjectIndexBuffer], a - call GetItemName - pop hl - call PlaceString - ret - -PlaceMenuItemQuantity:: - push de - ld a, [wMenuSelection] - ld [wCurItem], a - callfar _CheckTossableItem - ld a, [wItemAttributeValue] - pop hl - and a - jr nz, .done - ld [hl], $f1 - inc hl - ld de, wMenuSelectionQuantity - ld bc, $0102 - call PrintNumber -.done - ret - -asm_247a6: - ld hl, wPartyMonNicknames - jr .asm_247ae - ld hl, wBoxMonNicknames -.asm_247ae - push de - ld a, [wScrollingMenuCursorPosition] - call GetNick - pop hl - call PlaceString - ret - -asm_247ba: - ld a, $00 - ld [wMonType], a - jr .asm_247c6 - ld a, $02 - ld [wMonType], a -.asm_247c6 - push de - ld a, [wScrollingMenuCursorPosition] - ld [wCurPartyMon], a - predef CopyMonToTempMon - pop hl - call PrintLevel - ret - -ret_247d7: - ret - -asm_247d8: - push de - ld a, [wScrollingMenuCursorPosition] - ld c, a - ld b, $00 - ld hl, wBoxList - add hl, bc - ld a, [hl] - ld [wNamedObjectIndexBuffer], a - call GetPokemonName - pop hl - call PlaceString - ld de, 6 - add hl, de - push hl - ld a, [wScrollingMenuCursorPosition] - ld hl, wBoxMonNicknames - call GetNick - pop hl - call PlaceString - ld de, 6 - add hl, de - push hl - ld a, [wScrollingMenuCursorPosition] - ld [wCurPartyMon], a - ld a, $02 - ld [wMonType], a - predef CopyMonToTempMon - pop hl - push hl - call PrintLevel - pop hl - ld de, 3 - add hl, de - push hl - callfar GetGender - ld a, $ef - jr c, .asm_2482e - ld a, $f5 -.asm_2482e - pop hl - ld [hl], a - ret - -asm_4831: - ld hl, .MenuHeader2484e - call CopyMenuHeader - call MenuBox - call PlaceVerticalMenuItems - call MenuBoxCoord2Tile - ld de, SCREEN_WIDTH + 1 - add hl, de - ld de, wMoney - ld bc, $4306 - call PrintNumber - ret - -.MenuHeader2484e: - db 0 - menu_coords 11, 0, $13, 2 - dw .data_24856 - db 1 - -.data_24856: - db $40, $01 - db "      円@" - -asm_24860: - ld hl, MenuHeader24888 - call CopyMenuHeader - jr asm_24872 - -asm_24868: - ld hl, MenuHeader24888 - ld d, $0b - ld e, $00 - call OffsetMenuHeader - -asm_24872: - call MenuBox - call MenuBoxCoord2Tile - ld de, SCREEN_WIDTH + 1 - add hl, de - ld de, wMoney - ld bc, $4306 - call PrintNumber - ld [hl], $f0 - ret - -MenuHeader24888: - db MENU_BACKUP_TILES - menu_coords 11, 0, $13, 2 - dw 0 - db 1 - -UnreferencedMenu_24890: -; An unreferenced, nonfunctional menu that resembles the field debug menu. - ld hl, .MenuData - call LoadMenuHeader - call VerticalMenu - ret - -.MenuData: - db MENU_BACKUP_TILES - menu_coords 0, 0, 6, 10 - dw .MenuText - db 1 - -.MenuText: - db (STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING) - db 3 ; amount of options - db "うる@" ; Switch - db "かう@" ; Buy - db "やめる@" ; Cancel - db "くさかり@" ; "Mower"? (replaced by Uproot) - db "とんでけ@" ; "Flight"? (replaced by Wind Ride) - db "どんぶらこ@" ; "Splash"? (replaced by Water Sport) - db "フルパワー@" ; "Full Power" (replaced by Strong Arm) - db "ひかりゴケ@" ; Bright Moss - db "うずしお@" ; Whirlpool - db "とびはねる@" ; Bounce - db "あなをほる@" ; Dig - db "テレポート@" ; Teleport - db "タマゴうみ@" ; Softboiled - -; MonMenuOptionStrings indexes - const_def 1 - const MONMENUVALUE_STATS ; 1 - const MONMENUVALUE_SWITCH ; 2 - const MONMENUVALUE_ITEM ; 3 - const MONMENUVALUE_CANCEL ; 4 - const MONMENUVALUE_MOVE ; 5 - const MONMENUVALUE_MAIL ; 6 - const MONMENUVALUE_ERROR ; 7 -DEF NUM_MONMENUVALUES EQU const_value - 1 - -MonMenuOptionStrings: - db "つよさをみる@" ; Stats - db "ならびかえ@" ; Switch - db "そうび@" ; Item - db "キャンセル@" ; Cancel - db "もちわざ@" ; Moves - db "メール@" ; Mail - db "エラー!@" ; Error! - -Unreferenced_FieldMoveList: - db MOVE_UPROOT, MONMENUITEM_CUT - db MOVE_WIND_RIDE, MONMENUITEM_FLY - db MOVE_WATER_SPORT, MONMENUITEM_SURF - db MOVE_STRONG_ARM, MONMENUITEM_STRENGTH - db MOVE_BRIGHT_MOSS, MONMENUITEM_FLASH - db MOVE_WHIRLPOOL, MONMENUITEM_WHIRLPOOL - db MOVE_BOUNCE, MONMENUITEM_BOUNCE - db MOVE_DIG, MONMENUITEM_DIG - db MOVE_TELEPORT, MONMENUITEM_TELEPORT - db MOVE_SOFTBOILED, MONMENUITEM_SOFTBOILED - db -1 - -MonMenuOptions: - db MONMENU_FIELD_MOVE, MONMENUITEM_CUT, MOVE_UPROOT - db MONMENU_FIELD_MOVE, MONMENUITEM_FLY, MOVE_WIND_RIDE - db MONMENU_FIELD_MOVE, MONMENUITEM_SURF, MOVE_WATER_SPORT - db MONMENU_FIELD_MOVE, MONMENUITEM_STRENGTH, MOVE_STRONG_ARM - db MONMENU_FIELD_MOVE, MONMENUITEM_FLASH, MOVE_BRIGHT_MOSS - db MONMENU_FIELD_MOVE, MONMENUITEM_WHIRLPOOL, MOVE_WHIRLPOOL - db MONMENU_FIELD_MOVE, MONMENUITEM_BOUNCE, MOVE_BOUNCE - db MONMENU_FIELD_MOVE, MONMENUITEM_DIG, MOVE_DIG - db MONMENU_FIELD_MOVE, MONMENUITEM_TELEPORT, MOVE_TELEPORT - db MONMENU_FIELD_MOVE, MONMENUITEM_SOFTBOILED, MOVE_SOFTBOILED - db MONMENU_MENUOPTION, MONMENUITEM_STATS, MONMENUVALUE_STATS - db MONMENU_MENUOPTION, MONMENUITEM_SWITCH, MONMENUVALUE_SWITCH - db MONMENU_MENUOPTION, MONMENUITEM_ITEM, MONMENUVALUE_ITEM - db MONMENU_MENUOPTION, MONMENUITEM_CANCEL, MONMENUVALUE_CANCEL - db MONMENU_MENUOPTION, MONMENUITEM_MOVE, MONMENUVALUE_MOVE - db MONMENU_MENUOPTION, MONMENUITEM_MAIL, MONMENUVALUE_MAIL - db MONMENU_MENUOPTION, MONMENUITEM_ERROR, MONMENUVALUE_ERROR - db -1 - -MonSubmenu:: - xor a - ldh [hBGMapMode], a - call GetMonSubmenuItems - callfar FreezeMonIcons - ld hl, .MenuHeader - call LoadMenuHeader - call .GetTopCoord - call PopulateMonMenu - - ld a, 1 - ldh [hBGMapMode], a - call MonMenuLoop - ld [wMenuSelection], a - call CloseWindow - ret - -.MenuHeader: - db MENU_BACKUP_TILES ; flags - menu_coords 11, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 - dw 0 - db 1 ; default option - -.GetTopCoord: - ld a, [wMonSubmenuCount] - inc a - add a - ld b, a - ld a, [wMenuBorderBottomCoord] - sub b - inc a - ld [wMenuBorderTopCoord], a - call MenuBox - ret - -MonMenuLoop: - ld a, (STATICMENU_CURSOR | STATICMENU_WRAP) - ld [wMenuDataFlags], a - ld a, [wMonSubmenuCount] - ld [wMenuDataItems], a - call InitVerticalMenuCursor - - ld hl, w2DMenuFlags1 - set _2DMENU_ENABLE_SPRITE_ANIMS_F, [hl] - - call Get2DMenuJoypad - ldh a, [hJoyDown] - bit A_BUTTON_F, a - jr nz, .select - bit B_BUTTON_F, a - jr nz, .cancel - jr MonMenuLoop - -.cancel: - ld a, MONMENUITEM_CANCEL - ret - -.select: - ld a, [wMenuCursorY] - dec a - ld c, a - ld b, 0 - ld hl, wMonSubmenuItems - add hl, bc - ld a, [hl] - ret - -PopulateMonMenu: - call MenuBoxCoord2Tile - ld bc, 2*SCREEN_WIDTH + 2 - add hl, bc - ld de, wMonSubmenuItems -.loop - ld a, [de] - inc de - cp $ff - ret z - push de - push hl - call GetMonMenuString - pop hl - call PlaceString - ld bc, 2*SCREEN_WIDTH - add hl, bc - pop de - jr .loop - -GetMonMenuString: - dec a - ld b, a - add a - add b - ld c, a - ld b, $00 - ld hl, MonMenuOptions - add hl, bc - ld a, [hli] - and a ; if MONMENU_MENUOPTION - jr z, .NotMove - inc hl - ld a, [hl] - ld [wNamedObjectIndexBuffer], a - call GetMoveName - ret - -.NotMove: - inc hl - ld a, [hl] - dec a - ld hl, MonMenuOptionStrings - call GetNthString - ld d, h - ld e, l - ret - -GetMonSubmenuItems: - call ResetMonSubmenu - ld a, MON_MOVES - call GetPartyParamLocation - ld d, h - ld e, l - ld hl, wMonSubmenuItems - ld c, NUM_MOVES - -.loop - push bc - push de - ld a, [de] - and a ; no move in this slot - jr z, .next - - push hl - call IsFieldMove - - pop hl - jr nc, .next - call AddMonMenuItem - -.next - pop de - inc de - pop bc - dec c - jr nz, .loop - - ld a, MONMENUITEM_STATS - call AddMonMenuItem - ld a, MONMENUITEM_SWITCH - call AddMonMenuItem - ld a, MONMENUITEM_MOVE - call AddMonMenuItem - - push hl - ld a, MON_ITEM - call GetPartyParamLocation - ld a, [hl] - pop hl - cp ITEM_MAIL - ld a, MONMENUITEM_ITEM - jr nz, .notmail - ld a, MONMENUITEM_MAIL - -.notmail - call AddMonMenuItem - ld a, [wMonSubmenuCount] - cp NUM_MONMENU_ITEMS - jr z, .maxitems - - ld a, MONMENUITEM_CANCEL - call AddMonMenuItem - -.maxitems - call TerminateMonSubmenu - ret - -IsFieldMove: - ld b, a - ld hl, MonMenuOptions -.next - ld a, [hli] - cp -1 - jr z, .nope - and a ; MONMENU_MENUOPTION - jr z, .nope - ld d, [hl] - inc hl - ld a, [hli] - cp b - jr nz, .next - ld a, d - scf - -.nope - ret - -ResetMonSubmenu: - xor a - ld [wMonSubmenuCount], a - ld hl, wMonSubmenuItems - ld bc, NUM_MONMENU_ITEMS + 1 - call ByteFill - ret - -TerminateMonSubmenu: - ld a, [wMonSubmenuCount] - ld e, a - ld d, 0 - ld hl, wMonSubmenuItems - add hl, de - ld [hl], -1 - ret - -AddMonMenuItem: - push hl - push de - push af - ld a, [wMonSubmenuCount] - ld e, a - inc a - ld [wMonSubmenuCount], a - ld d, $00 - ld hl, wMonSubmenuItems - add hl, de - pop af - ld [hl], a - pop de - pop hl - ret - -BattleMonMenu: - ld hl, .MenuHeader - call CopyMenuHeader - xor a - ldh [hBGMapMode], a - call MenuBox - call UpdateSprites - call PlaceVerticalMenuItems - call WaitBGMap - - ld hl, wMenuDataPointer - ld a, [hli] - ld h, [hl] - ld l, a - ld de, wMenuData2 - ld bc, $8 ; TODO: constantify - call CopyBytes - - ld a, [wMenuDataFlags] - bit STATICMENU_CURSOR_F, a - jr z, .set_carry - call InitVerticalMenuCursor - ld hl, w2DMenuFlags1 - set _2DMENU_ENABLE_SPRITE_ANIMS_F, [hl] - call Get2DMenuJoypad - bit B_BUTTON_F, a - jr z, .clear_carry - ret z - -.set_carry: - scf - ret - -.clear_carry: - and a - ret - - ret - -.MenuHeader: - db 0 ; flags - menu_coords 11, 11, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 - dw .MenuText - db 1 ; default option - -.MenuText: - db (STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING) - db 3 - db "とりかえる@" ; Switch - db "つよさをみる@" ; Stats - db "キャンセル@" ; Cancel - -LoadBattleMenu: - ld hl, MenuHeader24b24 - jr asm_24b0e - -asm_24b0b: - ld hl, MenuHeader24b3e -asm_24b0e: - call LoadMenuHeader - ld a, [wStartmenuCursor] - ld [wMenuCursorBuffer], a - call asm_24b67 - ld a, [wMenuCursorBuffer] - ld [wStartmenuCursor], a - call ExitMenu - ret - -MenuHeader24b24: - db MENU_BACKUP_TILES - menu_coords 9, 12, $13, $11 - dw .text_24b2c - db 1 - -.text_24b2c: - db STATICMENU_CURSOR - dn 2, 2 - db 5 - db "たたかう@" ; "FIGHT" - db "どうぐ@" ; "ITEM" - db "#@" ; "" - db "にげる@" ; "RUN" - -MenuHeader24b3e: - db MENU_BACKUP_TILES - menu_coords 0, 12, $13, $11 - dw .text_24b46 - db 1 - -.text_24b46: - db STATICMENU_CURSOR - dn 2, 2 - db 11 - db "サファりボール×   @" ; "SAFARI BALL× @" - db "エサをなげる@" ; "BAIT" - db "いしをなげる@" ; "THROW ROCK" - db "にげる@" ; "RUN" - -asm_24b67: - call CopyMenuData - call MenuBox - ld a, [wMenuDataItems] - ld b, a - and $0f - ld [wMovementBufferCount], a - ld a, b - and $f0 - swap a - ld [wMovementBufferObject], a - call asm_24bb8 - call asm_24bee - call Get2DMenuJoypad - ldh a, [hJoySum] - bit 2, a - jr nz, asm_24ba2 - ld a, [w2DMenuNumRows] - ld c, a - ld a, [w2DMenuDataEnd] - dec a - call asm_24ba4 - ld c, a - ld a, [wMenuCursorX] - add c - ld [wMenuCursorBuffer], a - and a - ret - -asm_24ba2: - scf - ret - -asm_24ba4: - and a - ret z - push bc - ld b, a - xor a -asm_24ba9: - add c - dec b - jr nz, asm_24ba9 - pop bc - ret - -asm_24baf: - ld b, $00 -asm_24bb1: - inc b - sub c - jr nc, asm_24bb1 - dec b - add c - ret - -asm_24bb8: - ld hl, wMenuDataPointer - ld a, [hli] - ld h, [hl] - ld l, a - ld de, $0003 - add hl, de - ld d, h - ld e, l - call GetMenuTextStartCoord - call Coord2Tile - ld a, [wMovementBufferCount] - ld b, a -asm_24bce: - push bc - push hl - ld a, [wMovementBufferObject] - ld c, a -asm_24bd4: - push bc - call PlaceString - inc de - ld a, [wMenuDataIndicesPointer] - ld c, a - ld b, $00 - add hl, bc - pop bc - dec c - jr nz, asm_24bd4 - pop hl - ld bc, $0028 - add hl, bc - pop bc - dec b - jr nz, asm_24bce - ret - -asm_24bee: - call GetMenuTextStartCoord - ld a, b - ld [wMenuData3], a - dec c - ld a, c - ld [w2DMenuCursorInitX], a - ld a, [wMovementBufferCount] - ld [w2DMenuNumRows], a - ld a, [wMovementBufferObject] - ld [w2DMenuNumCols], a - ld a, [wMenuDataHeaderEnd] - ld d, a - bit 5, d - ld a, $00 - jr z, asm_24c12 - ld a, $30 -asm_24c12: - ld [w2DMenuFlags1], a - ld a, [wMenuDataIndicesPointer] - or $20 - ld [w2DMenuCursorOffsets], a - ld a, $05 - ld [wMenuJoypadFilter], a - ld a, [w2DMenuNumCols] - ld e, a - ld a, [wMenuCursorBuffer] - ld b, a - xor a - ld d, $00 -asm_24c2d: - inc d - add e - cp b - jr c, asm_24c2d - sub e - ld c, a - ld a, b - sub c - and a - jr z, asm_24c3e - cp e - jr z, asm_24c40 - jr c, asm_24c40 -asm_24c3e: - ld a, $01 -asm_24c40: - ld [wMenuCursorX], a - ld a, [w2DMenuNumRows] - ld e, a - ld a, d - and a - jr z, asm_24c50 - cp e - jr z, asm_24c52 - jr c, asm_24c52 -asm_24c50: - ld a, $01 -asm_24c52: - ld [w2DMenuDataEnd], a - xor a - ld [wCursorOffCharacter], a - ld [wCursorCurrentTile], a - ld [wCursorCurrentTile + 1], a - ret - -SelectQuantityToToss:: - ld hl, MenuHeader24d64 - call LoadMenuHeader - call asm_24c84 - ret - -asm_24c64: - callfar GetItemPrice - ld a, d - ld [wFieldMoveScriptID], a - ld a, e - ld [wMapBlocksAddress], a - ld hl, MenuHeader24d6c - call LoadMenuHeader - call asm_24c84 - ret - -asm_24c84: - ld a, 1 - ld [wItemQuantity], a -asm_24c89: - call GetJoypad - ldh a, [hJoyState] - bit 0, a - jr nz, asm_24c89 -asm_24c92: - call asm_24d15 - call asm_24ca2 - jr nc, asm_24c92 - cp $ff - jr nz, asm_24ca0 - scf - ret - -asm_24ca0: - and a - ret - -asm_24ca2: - call DelayFrame - ldh a, [hInMenu] - push af - ld a, $01 - ldh [hInMenu], a - call GetJoypadDebounced - pop af - ldh [hInMenu], a - ldh a, [hJoyDown] - bit 1, a - jr nz, asm_24cd0 - bit 0, a - jr nz, asm_24cd4 - ldh a, [hJoySum] - bit 7, a - jr nz, asm_24cd6 - bit 6, a - jr nz, asm_24ce2 - bit 5, a - jr nz, asm_24cf0 - bit 4, a - jr nz, asm_24d02 - jr asm_24ca2 -asm_24cd0: - ld a, $ff - scf - ret - -asm_24cd4: - scf - ret - -asm_24cd6: - ld hl, wItemQuantity - dec [hl] - jr nz, asm_24ce0 - ld a, [wItemQuantityBuffer] - ld [hl], a -asm_24ce0: - and a - ret - -asm_24ce2: - ld hl, wItemQuantity - inc [hl] - ld a, [wItemQuantityBuffer] - cp [hl] - jr nc, asm_24cee - ld [hl], 1 -asm_24cee: - and a - ret - -asm_24cf0: - ld a, [wItemQuantity] - sub 10 - jr c, asm_24cfb - jr z, asm_24cfb - jr asm_24cfd -asm_24cfb: - ld a, 1 -asm_24cfd: - ld [wItemQuantity], a - and a - ret - -asm_24d02: - ld a, [wItemQuantity] - add 10 - ld b, a - ld a, [wItemQuantityBuffer] - cp b - jr nc, asm_24d0f - ld b, a -asm_24d0f: - ld a, b - ld [wItemQuantity], a - and a - ret - -asm_24d15: - call MenuBox - call MenuBoxCoord2Tile - ld de, $15 - add hl, de - ld [hl], $f1 - inc hl - ld de, wItemQuantity - ld bc, $8102 - call PrintNumber - ld a, [wMenuDataPointer] - cp $ff - ret nz - xor a - ldh [hMultiplicand], a - ld a, [wFieldMoveScriptID] - ldh [hMultiplicand + 1], a - ld a, [wMapBlocksAddress] - ldh [hMultiplicand + 2], a - ld a, [wItemQuantity] - ldh [hMultiplier], a - push hl - call Multiply - ld hl, hFFCD - ldh a, [hMultiplicand] - ld [hli], a - ldh a, [hMultiplicand + 1] - ld [hli], a - ldh a, [hMultiplicand + 2] - ld [hl], a - pop hl - inc hl - ld de, hFFCD - ld bc, $0406 - call PrintNumber - ld [hl], $f0 - call WaitBGMap - ret - -MenuHeader24d64: - db MENU_BACKUP_TILES - menu_coords 15, 9, $13, 11 - dw 0 - db 0 - -MenuHeader24d6c: - db MENU_BACKUP_TILES - menu_coords 7, 15, $13, $11 - dw $ff - db $ff - diff --git a/engine/dumps/bank0b.asm b/engine/dumps/bank0b.asm deleted file mode 100644 index 9f8b40a..0000000 --- a/engine/dumps/bank0b.asm +++ /dev/null @@ -1,475 +0,0 @@ -INCLUDE "constants.asm" - -SECTION "engine/dumps/bank0b.asm", ROMX - -ShowItemDescription:: - push de - ld hl, ItemDescriptions - ld a, [wSelectedItem] - 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 - -INCLUDE "data/items/descriptions.inc" - -Function2d2fc: - ld a, $1 - ldh [hInMenu], a - call sub_2d436 - ld a, $0 - ldh [hInMenu], a - ret nc - call PlaceHollowCursor - call WaitBGMap - ld a, $1 - ldh [hBGMapMode], a - ld a, [wCurItem] - cp $3a - ret nc - ld [wce37], a - ld a, $1b - call Predef - ld a, [wce37] - ld [wPutativeTMHMMove], a - call GetMoveName - call CopyStringToStringBuffer2 - ld hl, text_2d3bf - call PrintText - ld hl, text_2d3d9 - call PrintText - call YesNoBox - jp c, asm_2d3a8 - -asm_2d33e: - ld hl, wStringBuffer2 - ld de, wcd1d - ld bc, $8 - call CopyBytes - ld hl, wStateFlags - res SPRITE_UPDATES_DISABLED_F, [hl] - ld a, $3 - ld [wPartyMenuActionText], a - ld a, $36 - call Predef - push af - ld hl, wcd1d - ld de, wStringBuffer2 - ld bc, $8 - call CopyBytes - pop af - jr nc, asm_2d36c - jp asm_2d3ad - -asm_2d36c: - ld a, $1a - call Predef - push bc - ld a, [wCurPartyMon] - ld hl, wPartyMonNicknames - call GetNick - pop bc - ld a, c - and a - jr nz, asm_2d390 - push de - ld de, $14 - call PlaySFX - pop de - ld hl, text_2d404 - call PrintText - jr asm_2d33e - -asm_2d390: - callfar Functionfdab - jr c, asm_2d33e - ld a, $0 - call Predef - ld a, b - and a - jr z, asm_2d3a8 - call sub_2d64e - jr asm_2d3ad - -asm_2d3a8: - ld a, $2 - ld [wFieldMoveSucceeded], a - -asm_2d3ad: - call ClearBGPalettes - call ClearSprites - ld hl, wStateFlags - set SPRITE_UPDATES_DISABLED_F, [hl] - call RestoreScreenAndReloadTiles - call GetMemSGBLayout - ret - -text_2d3bf: - text "を きどうした!" - prompt - text "ひでんマシンを きどうした!" - -text_2d3d9: - text "なかには @" - text_from_ram wStringBuffer2 - text "が" - line "きろくされていた!" - para "@" - text_from_ram wStringBuffer2 - text "を" - line "#に おぼえさせますか?" - done - -text_2d404: - text_from_ram wStringBuffer1 - text "と @" - text_from_ram wStringBuffer2 - text "は" - line "あいしょうが わるかった!" - para "@" - text_from_ram wStringBuffer2 - text "は おぼえられない!" - prompt - db $02, $04, $00, $01 - db $0c, $20 - db $c3 - -sub_2d436: - xor a - ldh [hBGMapMode], a - call sub_2d577 - ld a, $2 - ld [w2DMenuCursorInitY], a - ld a, $4 - ld [w2DMenuCursorInitY + 1], a - ld a, $1 - ld [w2DMenuNumCols], a - ld a, $4 - sub d - inc a - cp $5 - jr nz, asm_2d454 - dec a - -asm_2d454: - ld [w2DMenuNumRows], a - ld a, $c - ld [w2DMenuFlags1], a - xor a - ld [w2DMenuFlags2], a - ld a, $20 - ld [w2DMenuCursorOffsets], a - ld a, $c3 - ld [w2DMenuCursorOffsets + 1], a - ld a, [wcd42] - inc a - ld [wMenuCursorY], a - ld a, $1 - ld [wMenuCursorX], a - jr asm_2d4a3 - -asm_2d478: - call sub_2d577 - -asm_2d47b: - call WaitBGMap - ld a, $1 - ldh [hBGMapMode], a - call Get2DMenuJoypad - ld b, a - ld a, [wMenuCursorY] - dec a - ld [wcd42], a - xor a - ldh [hBGMapMode], a - ld a, [w2DMenuFlags2] - bit 7, a - jp nz, asm_2d537 - ld a, b - bit 0, a - jp nz, sub_2d51a - bit 1, a - jp nz, asm_2d535 - -asm_2d4a3: - call sub_2d51a - ld hl, $c368 - ld b, $6 - ld c, $12 - call DrawTextBox - call UpdateSprites - ld a, [wCurItem] - cp $3a - jr nc, asm_2d47b - ld [wce37], a - ld hl, $c391 - ld de, string_2d572 - call PlaceString - ld a, $1b - call Predef - ld a, [wce37] - ld [wCurSpecies], a - ld b, a - ld hl, $c395 - predef PrintMoveType - ld hl, $c3b9 - call Function2d663 - ld hl, $c39b - ld de, string_2d568 - call PlaceString - ld a, [wCurSpecies] - dec a - ld hl, Moves + MOVE_POWER - ld bc, MOVE_LENGTH - call AddNTimes - ld a, BANK(Moves) - call GetFarByte - ld hl, $c3a0 - cp $2 - jr c, asm_2d511 - ld [wce37], a - ld de, wce37 - ld bc, $103 - call PrintNumber - jp asm_2d478 - -asm_2d511: - ld de, string_2d56e - call PlaceString - jp asm_2d478 - -sub_2d51a: - call sub_2d5f8 - ld a, [wMenuCursorY] - ld b, a - -asm_2d521: - inc c - ld a, c - cp $3a - jr nc, asm_2d52f - ld a, [hli] - and a - jr z, asm_2d521 - dec b - jr nz, asm_2d521 - ld a, c - -asm_2d52f: - ld [wCurItem], a - cp $ff - ret - -asm_2d535: - and a - ret - -asm_2d537: - ld a, b - bit 7, a - jr nz, asm_2d54b - ld hl, wcd47 - ld a, [hl] - and a - jp z, asm_2d478 - dec [hl] - call sub_2d577 - jp asm_2d4a3 - -asm_2d54b: - call sub_2d5f8 - ld b, $5 - -asm_2d550: - inc c - ld a, c - cp $3a - jp nc, asm_2d478 - ld a, [hli] - and a - jr z, asm_2d550 - dec b - jr nz, asm_2d550 - ld hl, wcd47 - inc [hl] - call sub_2d577 - jp asm_2d4a3 - -string_2d568: - db "いりょく/@" - -string_2d56e: - db "ーーー@" - -string_2d572: - db "タイプ/@" - -sub_2d577: - ld hl, $c2a3 - ld b, $8 - ld c, $f - call DrawTextBox - call sub_2d5f8 - ld d, $4 - -asm_2d586: - inc c - ld a, c - cp $3a - jr nc, asm_2d5dd - ld a, [hli] - and a - jr z, asm_2d586 - ld b, a - ld a, c - ld [wce37], a - push hl - push de - push bc - call sub_2d5e9 - push hl - ld de, wce37 - ld bc, $8102 - call PrintNumber - ld a, $1b - call Predef - ld a, [wce37] - ld [wPutativeTMHMMove], a - call GetMoveName - pop hl - ld bc, $3 - add hl, bc - push hl - call PlaceString - pop hl - ld bc, $8 - add hl, bc - ld [hl], $f1 - inc hl - ld a, $f6 - pop bc - push bc - ld a, b - ld [wce37], a - ld de, wce37 - ld bc, $102 - call PrintNumber - pop bc - pop de - pop hl - dec d - jr nz, asm_2d586 - jr asm_2d5e8 - -asm_2d5dd: - call sub_2d5e9 - ld a, $d4 - ld [hli], a - ld a, $d2 - ld [hli], a - ld [hl], $d9 - -asm_2d5e8: - ret - -sub_2d5e9: - ld hl, $c2a5 - ld bc, $28 - ld a, $5 - sub d - ld d, a - -asm_2d5f3: - add hl, bc - dec d - jr nz, asm_2d5f3 - ret - -sub_2d5f8: - ld hl, wTMsHMs - ld a, [wcd47] - ld b, a - inc b - ld c, $0 - -asm_2d602: - inc c - ld a, [hli] - and a - jr z, asm_2d602 - dec b - jr nz, asm_2d602 - dec hl - dec c - ret - call sub_2d63c - ld hl, text_2d61b - jr nc, asm_2d618 - ld hl, text_2d62f - -asm_2d618: - jp PrintText - -text_2d61b: - text_from_ram wStringBuffer1 - text "は これいじょう" - line "もてません!" - prompt - -text_2d62f: - text_from_ram wStringBuffer1 - text "を てにいれた!" - prompt - -sub_2d63c: - ld a, [wCurItem] - dec a - ld hl, wTMsHMs - ld b, $0 - ld c, a - add hl, bc - ld a, [hl] - inc a - cp $a - ret nc - ld [hl], a - ret - -sub_2d64e: - ld a, [wCurItem] - dec a - ld hl, wTMsHMs - ld b, $0 - ld c, a - add hl, bc - ld a, [hl] - and a - ret z - dec a - ld [hl], a - ret nz - ld [wcd47], a - ret - -Function2d663: - push hl - ld hl, MoveDescriptions - ld a, [wCurSpecies] - dec a - ld c, a - ld b, $0 - add hl, bc - add hl, bc - ld a, [hli] - ld e, a - ld d, [hl] - pop hl - jp PlaceString - -INCLUDE "data/moves/descriptions.inc" diff --git a/engine/dumps/bank0d.asm b/engine/dumps/bank0d.asm index df04d4d..9215a91 100644 --- a/engine/dumps/bank0d.asm +++ b/engine/dumps/bank0d.asm @@ -4382,7 +4382,7 @@ UpdateMoveData: push bc ld a, [wCurPlayerSelectedMove] ld b, a - ld a, [wcabe] + ld a, [wPlayerDebugSelectedMove] and a jr z, .get_move_data ld b, a @@ -8437,7 +8437,7 @@ BattleCommand_BatonPass: call LoadStandardMenuHeader ld a, PARTYMENUACTION_SWITCH ld [wPartyMenuActionText], a - predef PartyMenuInBattle_Setup + predef OpenPartyMenu_ClearGraphics .player_loop jr c, .pressed_b @@ -8450,7 +8450,7 @@ BattleCommand_BatonPass: call PrintText .pressed_b - predef PartyMenuInBattle + predef OpenPartyMenu jr .player_loop .picked_mon diff --git a/engine/dumps/bank0f.asm b/engine/dumps/bank0f.asm index 6f971aa..a84ce67 100644 --- a/engine/dumps/bank0f.asm +++ b/engine/dumps/bank0f.asm @@ -261,7 +261,7 @@ asm_3c229: ld hl, wBattleMonPP add hl, bc ld a, [hl] - and $3f ; Power points? + and PP_MASK jr z, asm_3c219 ld a, [wCurPlayerMove] ld [wCurPlayerSelectedMove], a @@ -275,10 +275,10 @@ asm_3c246: and a jr nz, asm_3c281 xor a - ld [wcac0], a + ld [wMoveSelectionMenuType], a inc a ld [wFXAnimID], a - call Function3daa7 + call MoveSelectionScreen push af call ReloadTilesFromBuffer call DrawHUDsAndHPBars @@ -1554,13 +1554,13 @@ sub_3cbdb: call LoadStandardMenuHeader ld a, PARTYMENUACTION_SWITCH ld [wPartyMenuActionText], a - predef PartyMenuInBattle_Setup + predef OpenPartyMenu_ClearGraphics asm_3cbe8: jr nc, asm_3cbf1 asm_3cbea: - predef PartyMenuInBattle + predef OpenPartyMenu jr asm_3cbe8 asm_3cbf1: @@ -1763,7 +1763,7 @@ EnemySwitch: ld a, [wCurBattleMon] ld c, a - ld b, 1 ; SET_FLAG + ld b, SET_FLAG push bc predef SmallFarFlagAction ld hl, wBattleParticipantsIncludingFainted @@ -2047,7 +2047,7 @@ LoadEnemyMonToSwitchTo: ld a, PARTYMENUACTION_SWITCH ld [wPartyMenuActionText], a - predef PartyMenuInBattle_Setup + predef OpenPartyMenu_ClearGraphics .pick ld a, 1 @@ -2063,7 +2063,7 @@ LoadEnemyMonToSwitchTo: call PrintText .fainted - predef PartyMenuInBattle + predef OpenPartyMenu jr .pick .notout @@ -3272,13 +3272,13 @@ BattleMenuPack_SelectItem: ret .normal_item_effect: - call UseItem + call DoItemEffect call ClearPalettes callfar DrawBackpack ret .menu_close: - call UseItem + call DoItemEffect ret BattleMenu_PKMN: @@ -3289,7 +3289,7 @@ asm_3d8c0: call LoadStandardMenuHeader xor a ld [wPartyMenuActionText], a - predef PartyMenuInBattle_Setup + predef OpenPartyMenu_ClearGraphics jp c, asm_3d918 jp asm_3d8eb @@ -3300,7 +3300,7 @@ asm_3d8d5: call ByteFill xor a ld [wPartyMenuActionText], a - predef PartyMenuInBattle + predef OpenPartyMenu jr c, asm_3d918 asm_3d8eb: @@ -3347,7 +3347,7 @@ sub_3d930: xor a ld [wMonType], a ld hl, wPartyMon1Species - predef Function502b5 + predef StatsScreenMain call MaxVolume call DisableLCD ld hl, vSprites @@ -3448,7 +3448,7 @@ PassedBattleMonEntrance: ld a, [wCurPartyMon] ld [wCurBattleMon], a ld c, a - ld b, 1 ; SET_FLAG + ld b, SET_FLAG push bc ld hl, wBattleParticipantsNotFainted predef SmallFarFlagAction @@ -3494,70 +3494,71 @@ BattleMenu_Run: ret nz jp DisplayBattleMenu -Function3daa7: +MoveSelectionScreen:: ld hl, wEnemyMonMoves - ld a, [wcac0] + ld a, [wMoveSelectionMenuType] dec a - jr z, asm_3dac8 + jr z, .got_menu_type dec a - jr z, asm_3dabc - call sub_3dce0 + jr z, .ether_elixer_menu + call .CheckPlayerHasUsableMoves ret z ld hl, wBattleMonMoves - jr asm_3dac8 + jr .got_menu_type -asm_3dabc: +.ether_elixer_menu ld a, [wCurPartyMon] ld hl, wPartyMon1Moves ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes -asm_3dac8: +.got_menu_type ld de, wListMoves_MoveIndicesBuffer - ld bc, 4 + ld bc, NUM_MOVES call CopyBytes xor a ldh [hBGMapMode], a - ld hl, $c340 + hlcoord 0, 17 - (NUM_MOVES * 2) - 1 ld b, 8 ld c, 8 - ld a, [wcac0] + ld a, [wMoveSelectionMenuType] cp 2 - jr nz, asm_3dae9 - ld hl, $c34a + jr nz, .got_dims + hlcoord 10, 17 - (NUM_MOVES * 2) - 1 ld b, 8 ld c, 8 -asm_3dae9: +.got_dims call DrawTextBox - ld hl, $c36a - ld a, [wcac0] + hlcoord 2, 17 - (NUM_MOVES * 2) + 1 + ld a, [wMoveSelectionMenuType] cp 2 - jr nz, asm_3daf9 - ld hl, $c374 + jr nz, .got_start_coord + hlcoord 12, 17 - (NUM_MOVES * 2) + 1 -asm_3daf9: - ld a, $28 +.got_start_coord + ld a, SCREEN_WIDTH * 2 ld [wHPBarMaxHP], a predef ListMoves - ld b, 1 - ld a, [wcac0] - cp 2 - jr nz, asm_3db0e - ld b, $b -asm_3db0e: - ld a, $a + ld b, 1 + ld a, [wMoveSelectionMenuType] + cp 2 + jr nz, .got_default_coord + ld b, 11 + +.got_default_coord + ld a, 17 - (NUM_MOVES * 2) + 1 ld [w2DMenuCursorInitY], a ld a, b ld [w2DMenuCursorInitX], a - ld a, [wcac0] + ld a, [wMoveSelectionMenuType] cp 1 - jr z, asm_3db22 + jr z, .skip_inc ld a, [wCurMoveNum] inc a -asm_3db22: +.skip_inc ld [wMenuCursorY], a ld a, 1 ld [wMenuCursorX], a @@ -3566,25 +3567,30 @@ asm_3db22: ld [w2DMenuNumRows], a ld a, 1 ld [w2DMenuNumCols], a - ld c, $2c - ld a, [wcac0] - dec a - ld b, $c1 - jr z, asm_3db59 - dec a - ld b, $c3 - jr z, asm_3db59 - ld a, [wLinkMode] - cp 3 - jr z, asm_3db59 - ld a, [wDebugFlags] - bit 0, a - ld b, $c7 - jr z, asm_3db59 - ld b, $ff - ld c, $2f -asm_3db59: + ld c, STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP + ld a, [wMoveSelectionMenuType] + dec a + ld b, D_DOWN | D_UP | A_BUTTON + jr z, .okay + + dec a + ld b, D_DOWN | D_UP | A_BUTTON | B_BUTTON + jr z, .okay + + ld a, [wLinkMode] + cp 3 ; LINK_COLOSSEUM + jr z, .okay + + ld a, [wDebugFlags] + bit DEBUG_BATTLE_F, a + ld b, D_DOWN | D_UP | A_BUTTON | B_BUTTON | SELECT + jr z, .okay + + ld b, D_DOWN | D_UP | D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON | START | SELECT + ld c, STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_SELECT | STATICMENU_DISABLE_B | STATICMENU_ENABLE_START | STATICMENU_WRAP + +.okay ld a, b ld [wMenuJoypadFilter], a ld a, c @@ -3594,92 +3600,100 @@ asm_3db59: ld a, $20 ld [w2DMenuCursorOffsets], a -asm_3db6a: - ld a, [wcac0] +.menu_loop + ld a, [wMoveSelectionMenuType] and a - jr z, asm_3db7e - dec a - jr nz, asm_3db9a - ld hl, $c3c3 - ld de, Data3dc47 - call PlaceString - jr asm_3db9a + jr z, .battle_player_moves -asm_3db7e: + dec a + jr nz, .interpret_joypad + hlcoord 11, 14 + ld de, .Unused_BattleText_MimicWhichMove + call PlaceString + jr .interpret_joypad + +.battle_player_moves ld a, [wDebugFlags] bit 0, a - jr nz, asm_3db9a - call sub_3ddba + jr nz, .interpret_joypad + + call MoveInfoBox ld a, [wSelectedSwapPosition] and a - jr z, asm_3db9a - ld hl, $c369 + jr z, .interpret_joypad + hlcoord 1, 18 - (NUM_MOVES * 2) dec a - ld bc, $28 + ld bc, SCREEN_WIDTH * 2 call AddNTimes - ld [hl], $ec + ld [hl], "▷" -asm_3db9a: +.interpret_joypad call WaitBGMap ld a, 1 ldh [hBGMapMode], a - call Get2DMenuJoypad_NoPlaceCursor - bit 6, a - jp nz, asm_3dc55 - bit 7, a - jp nz, asm_3dc66 - bit 2, a - jp nz, asm_3dd31 - bit 3, a - jp nz, asm_3dc7b - bit 4, a - jp nz, asm_3dcaa - bit 5, a - jp nz, asm_3dca4 - bit 1, a + call ScrollingMenuJoypad + bit D_UP_F, a + jp nz, .pressed_up + bit D_DOWN_F, a + jp nz, .pressed_down + bit SELECT_F, a + jp nz, .pressed_select + bit START_F, a + jp nz, .pressed_start + bit D_RIGHT_F, a + jp nz, .pressed_right + bit D_LEFT_F, a + jp nz, .pressed_left + bit B_BUTTON_F, a + ; A button push af + xor a ld [wSelectedSwapPosition], a ld a, [wMenuCursorY] dec a ld [wMenuCursorY], a ld b, a - ld a, [wcac0] + ld a, [wMoveSelectionMenuType] dec a - jr nz, asm_3dbd9 + jr nz, .not_enemy_moves_process_b pop af ret -asm_3dbd9: +.not_enemy_moves_process_b dec a ld a, b ld [wCurMoveNum], a - jr nz, asm_3dbe2 + jr nz, .use_move + pop af ret -asm_3dbe2: +.use_move pop af ret nz + ld hl, wBattleMonPP ld a, [wMenuCursorY] ld c, a ld b, 0 add hl, bc ld a, [hl] - and $3f - jr z, asm_3dc1a + and PP_MASK + jr z, .no_pp_left + ld a, [wPlayerDisableCount] swap a and $f dec a cp c - jr z, asm_3dc15 - ld a, [wPlayerSubStatus5] - bit 3, a - jr nz, asm_3dc05 + jr z, .move_disabled -asm_3dc05: + ld a, [wPlayerSubStatus5] + bit SUBSTATUS_TRANSFORMED, a + jr nz, .transformed + ; something was commented out here +.transformed ld a, [wMenuCursorY] ld hl, wBattleMonMoves ld c, a @@ -3690,162 +3704,174 @@ asm_3dc05: xor a ret -asm_3dc15: - ld hl, Data3dc38 - jr asm_3dc1d +.move_disabled + ld hl, .BattleText_TheMoveIsDisabled + jr .place_textbox_start_over -asm_3dc1a: - ld hl, Data3dc26 +.no_pp_left + ld hl, .BattleText_TheresNoPPLeftForThisMove -asm_3dc1d: +.place_textbox_start_over call PrintText call ReloadTilesFromBuffer - jp Function3daa7 + jp MoveSelectionScreen -Data3dc26: - text "わざの のこりポイントが ない!" +.BattleText_TheresNoPPLeftForThisMove: + text "わざの のこりポイントが ない!" + prompt -Data3dc38: - text "わざを ふうじられている!" +.BattleText_TheMoveIsDisabled: + text "わざを ふうじられている!" + prompt -Data3dc47: - db "どのわざをものまねする?@" +.Unused_BattleText_MimicWhichMove: + db "どのわざを" + next "ものまねする?@" -asm_3dc55: +.pressed_up ld a, [wMenuCursorY] and a - jp nz, asm_3db6a + jp nz, .menu_loop ld a, [wNumMoves] inc a ld [wMenuCursorY], a - jp asm_3db6a + jp .menu_loop -asm_3dc66: +.pressed_down ld a, [wMenuCursorY] ld b, a ld a, [wNumMoves] inc a inc a cp b - jp nz, asm_3db6a + jp nz, .menu_loop ld a, 1 ld [wMenuCursorY], a - jp asm_3db6a + jp .menu_loop -asm_3dc7b: - bit 3, a +.DebugMovePreview: +.pressed_start + bit START_F, a ld a, 0 - jr nz, asm_3dc83 + jr nz, .player_side ld a, 1 -asm_3dc83: +.player_side ldh [hBattleTurn], a call ReloadTilesFromBuffer - call sub_3dcb7 - ld a, [wcabe] + call .DrawDebugMoveSelection + ld a, [wPlayerDebugSelectedMove] and a - jp z, Function3daa7 + jp z, MoveSelectionScreen ld [wFXAnimID], a xor a ld [wNumHits], a ld [wFXAnimID + 1], a predef PlayBattleAnim - jp Function3daa7 + jp MoveSelectionScreen -asm_3dca4: - ld a, [wcabe] +.pressed_left + ld a, [wPlayerDebugSelectedMove] dec a - jr asm_3dcae + jr .pressed_left_right_continue -asm_3dcaa: - ld a, [wcabe] +.pressed_right + ld a, [wPlayerDebugSelectedMove] inc a -asm_3dcae: - ld [wcabe], a - call sub_3dcb7 - jp Function3daa7 +.pressed_left_right_continue + ld [wPlayerDebugSelectedMove], a + call .DrawDebugMoveSelection + jp MoveSelectionScreen -sub_3dcb7: - ld hl, $c3ea - ld bc, $020a +.DrawDebugMoveSelection: + hlcoord 10, 16 + lb bc, 2, 10 call ClearBox - ld hl, $c3fe - ld de, wcabe - ld bc, $8103 + + hlcoord 10, 17 + ld de, wPlayerDebugSelectedMove + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNumber - ld a, [wcabe] + + ld a, [wPlayerDebugSelectedMove] and a ret z - cp $fc + cp NUM_ATTACKS + 1 ret nc - ld [wNumSetBits], a + + ld [wNamedObjectIndexBuffer], a call GetMoveName - ld hl, $c401 + hlcoord 13, 17 jp PlaceString -sub_3dce0: - ld a, $a5 +.CheckPlayerHasUsableMoves: + ld a, MOVE_STRUGGLE ld [wCurPlayerSelectedMove], a ld a, [wPlayerDisableCount] and a ld hl, wBattleMonPP - jr nz, asm_3dcf7 + jr nz, .disabled + ld a, [hli] or [hl] inc hl or [hl] inc hl or [hl] +; BUG: There should be "and PP_MASK" here ret nz - jr asm_3dd0c + jr .force_struggle -asm_3dcf7: +.disabled swap a and $f ld b, a - ld d, 5 + ld d, NUM_MOVES + 1 xor a - -asm_3dcff: +.loop dec d - jr z, asm_3dd0a + jr z, .done ld c, [hl] inc hl dec b - jr z, asm_3dcff + jr z, .loop or c - jr asm_3dcff + jr .loop -asm_3dd0a: - and a +.done + ; BUG: This will result in a move with PP Up confusing the game. + and a ; should be "and PP_MASK" ret nz -asm_3dd0c: - ld hl, Data3dd19 +.force_struggle + ld hl, .BattleText_MonHasNoMovesLeft call PrintText - ld c, $3c + ld c, 60 call DelayFrames xor a ret -Data3dd19: +.BattleText_MonHasNoMovesLeft: text_from_ram wBattleMonNickname - text "は だすことの できるわざが ない!" + text "は だすことの できる" + line "わざが ない!" + done -asm_3dd31: +.pressed_select ld a, [wDebugFlags] - bit 0, a - jp nz, asm_3dc7b + bit DEBUG_BATTLE_F, a + jp nz, .DebugMovePreview + ld a, [wSelectedSwapPosition] and a - jr z, asm_3ddb1 + jr z, .start_swap ld hl, wBattleMonMoves - call sub_3dd97 + call .swap_bytes ld hl, wBattleMonPP - call sub_3dd97 + call .swap_bytes ld hl, wPlayerDisableCount ld a, [hl] swap a @@ -3853,7 +3879,7 @@ asm_3dd31: ld b, a ld a, [wMenuCursorY] cp b - jr nz, asm_3dd67 + jr nz, .not_swapping_disabled_move ld a, [hl] and $f ld b, a @@ -3861,12 +3887,12 @@ asm_3dd31: swap a add b ld [hl], a - jr asm_3dd78 + jr .swap_moves_in_party_struct -asm_3dd67: +.not_swapping_disabled_move ld a, [wSelectedSwapPosition] cp b - jr nz, asm_3dd78 + jr nz, .swap_moves_in_party_struct ld a, [hl] and $f ld b, a @@ -3875,22 +3901,23 @@ asm_3dd67: add b ld [hl], a -asm_3dd78: +.swap_moves_in_party_struct +; BUG: COOLTRAINER glitch from Generation I still exists here. ld hl, wPartyMon1Moves ld a, [wCurBattleMon] - ld bc, $30 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes push hl - call sub_3dd97 + call .swap_bytes pop hl - ld bc, $15 + ld bc, MON_PP - MON_MOVES add hl, bc - call sub_3dd97 + call .swap_bytes xor a ld [wSelectedSwapPosition], a - jp Function3daa7 + jp MoveSelectionScreen -sub_3dd97: +.swap_bytes push hl ld a, [wSelectedSwapPosition] dec a @@ -3912,33 +3939,37 @@ sub_3dd97: ld [de], a ret -asm_3ddb1: +.start_swap ld a, [wMenuCursorY] ld [wSelectedSwapPosition], a - jp Function3daa7 + jp MoveSelectionScreen -sub_3ddba: +MoveInfoBox: xor a ldh [hBGMapMode], a - ld hl, $c399 + + hlcoord 9, 12 ld b, 4 ld c, 9 call DrawTextBox + ld a, [wPlayerDisableCount] and a - jr z, asm_3dde3 + jr z, .not_disabled + swap a and $f ld b, a ld a, [wMenuCursorY] cp b - jr nz, asm_3dde3 - ld hl, $c3d6 - ld de, DisabledText - call PlaceString - jr asm_3de5b + jr nz, .not_disabled -asm_3dde3: + hlcoord 10, 15 + ld de, .Disabled + call PlaceString + jr .done + +.not_disabled ld hl, wMenuCursorY dec [hl] xor a @@ -3950,11 +3981,13 @@ asm_3dde3: add hl, bc ld a, [hl] ld [wCurPlayerSelectedMove], a + ld a, [wCurBattleMon] ld [wCurPartyMon], a - ld a, 4 + ld a, WILDMON ld [wMonType], a callfar GetMaxPPOfMove + ld hl, wMenuCursorY ld c, [hl] inc [hl] @@ -3962,39 +3995,38 @@ asm_3dde3: ld hl, wBattleMonPP add hl, bc ld a, [hl] - and $3f + and PP_MASK ld [wStringBuffer1], a - - ; Untranslated references to VRAM! Hooray? - - ld hl, $c3d6 - ld de, MoveTypeText + hlcoord 10, 15 + ld de, .Type call PlaceString - ld hl, $c3b4 + + hlcoord 16, 13 ld [hl], "/" - ld hl, $c3ee + hlcoord 14, 16 ld [hl], "/" - ld hl, $c3b2 + hlcoord 14, 13 ld de, wStringBuffer1 - ld bc, $0102 + lb bc, 1, 2 call PrintNumber - ld hl, $c3b5 - ld de, wNumSetBits - ld bc, $0102 + + hlcoord 17, 13 + ld de, wTempPP + lb bc, 1, 2 call PrintNumber + callfar UpdateMoveData ld a, [wPlayerMoveStruct] ld b, a - ld hl, $c3ef + hlcoord 15, 16 predef PrintMoveType -asm_3de5b: +.done jp WaitBGMap -DisabledText: +.Disabled: db "ふうじられている!@" - -MoveTypeText: +.Type: db "わざタイプ@" sub_3de6e: @@ -4321,8 +4353,8 @@ LoadEnemyMon: ; Load preset middle-class DVs for trainer battles. ld a, [wBattleMode] cp TRAINER_BATTLE - ld a, $98 - ld b, $88 + ln a, 9, 8 + ln b, 8, 8 jr z, .UpdateDVs ; Otherwise randomly generate DVs for wild encounters @@ -4489,33 +4521,36 @@ asm_3e193: pop bc ret -Function3e1a4: - call Function3e1aa - jp asm_3e1d1 +; A leftover from Generation I, where it had no effect due to no stats actually being selected. +; BUG: Remarkably, this is STILL run from HealStatus despite the stat double/halve bitfields +; being overwritten with variables that are actually used as substatuses. +DoubleOrHalveSelectedStats_Old:: + call DoubleSelectedStats + jp HalveSelectedStats -Function3e1aa: +DoubleSelectedStats: ldh a, [hBattleTurn] and a - ld a, [wPlayerSubStatus1] + ld a, [wPlayerSubStatus1] ; wPlayerStatsToDouble ld hl, wBattleMonAttack + 1 - jr z, asm_3e1bb - ld a, [wEnemySubStatus1] + jr z, .notEnemyTurn + ld a, [wEnemySubStatus1] ; wEnemyStatsToDouble ld hl, wEnemyMonAttack + 1 -asm_3e1bb: +.notEnemyTurn ld c, 4 ld b, a -asm_3e1be: +.loop srl b - call c, sub_3e1c9 + call c, .doubleStat inc hl inc hl dec c ret z - jr asm_3e1be + jr .loop -sub_3e1c9: +.doubleStat ld a, [hl] add a ld [hld], a @@ -4524,29 +4559,27 @@ sub_3e1c9: ld [hli], a ret -asm_3e1d1: +HalveSelectedStats: ldh a, [hBattleTurn] and a - ld a, [wPlayerSubStatus2] + ld a, [wPlayerSubStatus2] ; wPlayerStatsToHalve ld hl, wBattleMonAttack - jr z, asm_3e1e2 - ld a, [wEnemySubStatus2] + jr z, .notEnemyTurn + ld a, [wEnemySubStatus2] ; wEnemyStatsToHalve ld hl, wEnemyMonAttack - -asm_3e1e2: +.notEnemyTurn ld c, 4 ld b, a - -asm_3e1e5: +.loop srl b - call c, sub_3e1f0 + call c, .halveStat inc hl inc hl dec c ret z - jr asm_3e1e5 + jr .loop -sub_3e1f0: +.halveStat ld a, [hl] srl a ld [hli], a @@ -4555,11 +4588,10 @@ sub_3e1f0: rr a ld [hl], a or d - jr nz, asm_3e1ff + jr nz, .nonzeroStat ld a, 1 ld [hl], a - -asm_3e1ff: +.nonzeroStat dec hl ret @@ -5081,7 +5113,7 @@ asm_3e507: xor a ld [wMonType], a predef CopyMonToTempMon - farcall Function50caa + farcall CalcLevel pop bc ld hl, $1f add hl, bc @@ -5178,15 +5210,15 @@ asm_3e5d3: ld [wMonType], a predef CopyMonToTempMon ld d, 1 - callfar Function50628 + callfar PrintTempMonStats call TextboxWaitPressAorB_BlinkCursor call ReloadTilesFromBuffer xor a ld [wMonType], a ld a, [wCurSpecies] ld [wNumSetBits], a - predef Function421f8 - ld hl, wcdc2 + predef LearnLevelMoves + ld hl, wEvolvableFlags ld a, [wCurPartyMon] ld c, a ld b, 1 @@ -5843,12 +5875,12 @@ endr SECTION "engine/dumps/bank0f.asm@Function3ee3e", ROMX Function3ee3e: - ld a, [wce2d] + ld a, [wRepelEffect] and a jr z, asm_3ee4b dec a jp z, asm_3eeba - ld [wce2d], a + ld [wRepelEffect], a asm_3ee4b: call sub_3eec8 @@ -5906,7 +5938,7 @@ asm_3ee91: jr c, asm_3eebd ld [wCurPartySpecies], a ld [wTempEnemyMonSpecies], a - ld a, [wce2d] + ld a, [wRepelEffect] and a jr z, asm_3eec1 ld a, [wPartyMon1Level] @@ -5917,7 +5949,7 @@ asm_3ee91: jr asm_3eec1 asm_3eeba: - ld [wce2d], a + ld [wRepelEffect], a asm_3eebd: ld a, 1 @@ -6012,7 +6044,7 @@ Function3ef19: ld a, [wOtherTrainerClass] and a jr nz, InitBattleCommon - ld a, [wce01] + ld a, [wTempWildMonSpecies] and a jr z, InitBattleCommon ld [wCurPartySpecies], a @@ -6338,8 +6370,8 @@ asm_3f148: asm_3f151: xor a - ld [wcab9], a - predef Function41fa1 + ld [wForceEvolution], a + predef EvolveAfterBattle asm_3f15a: xor a @@ -6347,7 +6379,7 @@ asm_3f15a: ld [wBattleMode], a ld [wBattleType], a ld [wAttackMissed], a - ld [wce01], a + ld [wTempWildMonSpecies], a ld [wOtherTrainerClass], a ld [wce38], a ld [wce39], a diff --git a/engine/dumps/bank14.asm b/engine/dumps/bank14.asm index 0dc21be..e5a29c9 100644 --- a/engine/dumps/bank14.asm +++ b/engine/dumps/bank14.asm @@ -23,7 +23,7 @@ CopyMonToTempMon:: ld bc, BOXMON_STRUCT_LENGTH cp BOXMON jr z, .getmonaddress - ld hl, wd882 + ld hl, wBufferMon jr .copywholestruct .getmonaddress @@ -44,7 +44,7 @@ GetMonSpecies:: cp BOXMON jr z, .boxmon cp TEMPMON - jr z, .breedmon + jr z, .buffermon ; WILDMON .partymon @@ -56,11 +56,11 @@ GetMonSpecies:: jr .done .boxmon - ld hl, wBoxList + ld hl, wBoxSpecies jr .done -.breedmon - ld a, [wd882] +.buffermon + ld a, [wBufferMonSpecies] jr .done2 .done @@ -148,7 +148,7 @@ GetTypeName:: ld h, [hl] ld l, a ld de, wStringBuffer1 - ld bc, MOVE_NAME_LENGTH + ld bc, TYPE_NAME_LENGTH jp CopyBytes SECTION "engine/dumps/bank14.asm@GetTrainerClassName_Old", ROMX @@ -338,15 +338,16 @@ DrawHP: pop de ret -Function502b5:: +; TODO: Finish this baby up. +StatsScreenMain:: ld a, [wCurPartySpecies] cp DEX_EGG - jr z, .asm_502d9 + jr z, .got_stats call CopyMonToTempMon ld a, [wMonType] - cp 2 - jr c, .asm_502d9 + cp BOXMON + jr c, .got_stats ld a, [wTempMonLevel] ld [wCurPartyLevel], a @@ -354,7 +355,8 @@ Function502b5:: ld de, wTempMonMaxHP ld b, 1 predef CalcMonStats -.asm_502d9 + +.got_stats ld hl, wd4a7 set 1, [hl] call ClearBGPalettes @@ -732,7 +734,7 @@ Function50562:: ld de, wStringBuffer1 push de - ld bc, 6 + ld bc, MON_NAME_LENGTH call CopyBytes pop de @@ -741,7 +743,7 @@ Function50562:: call PlaceString ld d, 0 - call Function50628 + call PrintTempMonStats hlcoord 10, 6 ld de, .Parameters call PlaceString @@ -762,7 +764,7 @@ Function50562:: .OTPointers dw wPartyMonOTs dw wOTPartyMonOT - dw wBoxMonOT + dw wBoxMonOTs dw wBufferMonOT Function505d9:: @@ -812,10 +814,12 @@ GetNicknamePointer:: ld a, [wCurPartyMon] jp SkipNames -Function50628:: +; Prints a text box containing wTempMon's stats. +; If d = 0, print it closer to the middle. Else, print it on the side. +PrintTempMonStats:: ld a, d and a - jr nz, .asm_5063e + jr nz, .level_up_screen hlcoord 8, 6 ld b, 10 @@ -823,57 +827,58 @@ Function50628:: call DrawTextBox hlcoord 9, 8 - ld bc, $0006 - jr .asm_5064e + lb bc, 0, 6 + jr .next -.asm_5063e +.level_up_screen hlcoord 9, 0 ld b, 10 ld c, 9 call DrawTextBox hlcoord 11, 2 - ld bc, $0004 -.asm_5064e + lb bc, 0, 4 + +.next push bc push hl - ld de, Data_50684 + ld de, .StatNames call PlaceString pop hl pop bc add hl, bc ld de, wTempMonAttack - ld bc, $0203 - call .asm_5067a + lb bc, 2, 3 + call .PrintStat ld de, wTempMonDefense - call .asm_5067a + call .PrintStat ld de, wTempMonSpclAtk - call .asm_5067a + call .PrintStat ld de, wTempMonSpclDef - call .asm_5067a + call .PrintStat ld de, wTempMonSpeed jp PrintNumber -.asm_5067a +.PrintStat push hl call PrintNumber pop hl ; Print next numbers two tiles lower - ld de, $0028 + ld de, 2 * SCREEN_WIDTH add hl, de ret -Data_50684: - db "こうげき" - next "ぼうぎょ" - next "とくこう" - next "とくぼう" - next "すばやさ" +.StatNames: + db "こうげき" ; "ATTACK" + next "ぼうぎょ" ; "DEFENSE" + next "とくこう" ; "SPCL.ATK" + next "とくぼう" ; "SPCL.DEF" + next "すばやさ" ; "SPEED" next "@" GetGender:: @@ -1036,10 +1041,10 @@ ClearGraphicsForPartyMenu:: call UpdateSprites ret -PartyMenuInBattle_Setup:: +OpenPartyMenu_ClearGraphics:: call ClearGraphicsForPartyMenu ; Fallthrough -PartyMenuInBattle:: +OpenPartyMenu:: ldh a, [hMapAnims] push af xor a @@ -1047,9 +1052,9 @@ PartyMenuInBattle:: ld hl, wOptions set NO_TEXT_SCROLL_F, [hl] - call PartyMenuInBattle_SetMenuAttributes - call Function5081f - call Function507cf + call .SetMenuAttributes + call InitPartyMenuLayout + call PartyMenuSelect ld hl, wOptions res NO_TEXT_SCROLL_F, [hl] @@ -1058,7 +1063,7 @@ PartyMenuInBattle:: ldh [hMapAnims], a ret -PartyMenuInBattle_SetMenuAttributes:: +.SetMenuAttributes: call LoadFontsBattleExtra xor a ld [wMonType], a @@ -1078,7 +1083,7 @@ PartyMenuInBattle_SetMenuAttributes:: ld a, $01 .asm_507b4 ld [wMenuJoypadFilter], a - ld a, [wcd3c] + ld a, [wPartyMenuCursor] and a jr z, .asm_507c1 inc b @@ -1093,11 +1098,11 @@ PartyMenuInBattle_SetMenuAttributes:: Data_507c7: db $01, $00, $00, $01, $60, $00, $20, $00 -Function507cf:: - call Get2DMenuJoypad +PartyMenuSelect:: + call StaticMenuJoypad call PlaceHollowCursor ld a, [wMenuCursorY] - ld [wcd3c], a + ld [wPartyMenuCursor], a ldh a, [hJoySum] ld b, a ld a, [wSelectedSwapPosition] @@ -1131,20 +1136,21 @@ Function507cf:: jr nz, .asm_5080f call _SwitchPartyMons .asm_5080f - call Function50eca + call PartyMenu_ClearCursor xor a ld [wSelectedSwapPosition], a ld [wPartyMenuActionText], a - call Function5081f - jp Function507cf + call InitPartyMenuLayout + jp PartyMenuSelect -Function5081f:: +InitPartyMenuLayout:: ld a, [wPartyMenuActionText] cp PARTYMENUACTION_MOVE - jp z, Function509dd + jp z, PrintPartyMenuText + callfar LoadOverworldMonIcon - call Function50eca - callfar Function95f8 + call PartyMenu_ClearCursor + callfar InitPartyMenuPalettes hlcoord 3, 1 ld de, wPartySpecies ld a, [wCurPartyMon] @@ -1152,12 +1158,12 @@ Function5081f:: xor a ld [wCurPartyMon], a ld [wcce1], a -.asm_5084b +.loop ld a, [de] - cp $FF - jp z, .asm_50877 + cp -1 + jp z, .done push de - call Function508c4 + call PlacePartyMember pop de ld a, [wCurPartyMon] ldh [hObjectStructIndex], a @@ -1165,60 +1171,62 @@ Function5081f:: push de ld hl, LoadMenuMonIcon - ld a, BANK(LoadMenuMonIcon) ; ...What macro do I use here? + ld a, BANK(LoadMenuMonIcon) ld e, MONICON_PARTYMENU call FarCall_hl pop de inc de pop hl - ld bc, $0028 + ld bc, 2 * SCREEN_WIDTH add hl, bc ld a, [wCurPartyMon] inc a ld [wCurPartyMon], a + jr .loop - jr .asm_5084b - -.asm_50877 +.done pop af ld [wCurPartyMon], a - jp Function509d8 + jp PrintPartyText_GetSGBLayout -Function5087e:: +WritePartyMenuTilemapAndText:: ld a, [wPartyMenuActionText] cp PARTYMENUACTION_MOVE - jp z, Function509dd - callfar Function95f8 - ld hl, $c2b7 + jp z, PrintPartyMenuText + + callfar InitPartyMenuPalettes + hlcoord 3, 1 ld de, wPartySpecies ld a, [wCurPartyMon] push af xor a ld [wCurPartyMon], a ld [wcce1], a -.asm_5089f +.loop ld a, [de] - cp $FF - jp z, .asm_508bd + cp -1 + jp z, .done push de - call Function508c4 + call PlacePartyMember pop de ld a, [wCurPartyMon] ldh [hEventID], a inc de - ld bc, $0028 + ld bc, 2 * SCREEN_WIDTH add hl, bc - ld a, [wCurPartyMon] + ld a, [wCurPartyMon] ; redundant inc a ld [wCurPartyMon], a - jr .asm_5089f -.asm_508bd + jr .loop + +.done pop af ld [wCurPartyMon], a - jp Function509d8 + jp PrintPartyText_GetSGBLayout -Function508c4:: +; Places the tilemap of the party member at wCurPartyMon. +PlacePartyMember:: push bc push hl push hl @@ -1229,15 +1237,18 @@ Function508c4:: call PlaceString call CopyMonToTempMon pop hl + push hl ld a, [wSelectedSwapPosition] and a - jr z, .asm_508ef + jr z, .not_switching + dec a ld b, a ld a, [wCurPartyMon] cp b - jr nz, .asm_508ef + jr nz, .not_switching + dec hl dec hl dec hl @@ -1245,50 +1256,51 @@ Function508c4:: ld [hli], a inc hl inc hl -.asm_508ef + +.not_switching ld a, [wPartyMenuActionText] cp PARTYMENUACTION_TEACH_TMHM - jr z, .asm_50922 + jr z, .PlacePartyMonTMHMCompatibility cp PARTYMENUACTION_EVO_STONE - jr z, .DetermineCompatibility + jr z, .PlacePartyMonEvoStoneCompatibility cp PARTYMENUACTION_GIVE_MON - jp z, .asm_509b5 + jp z, .PlacePartyMonGender cp PARTYMENUACTION_GIVE_MON_FEMALE - jp z, .asm_509b5 + jp z, .PlacePartyMonGender push hl - ld bc, hRTCRandom + ld bc, -15 add hl, bc ld de, wTempMonStatus call PlaceStatusString pop hl push hl - ld bc, hCurMapTextSubroutinePtr + 1 + ld bc, -12 add hl, bc - ld b, $00 + ld b, 0 call DrawEnemyHP push de - call Function50b66 + call SetPartyHPBarPalette pop de pop hl - jr .asm_5093c + jr .PrintLevel -.asm_50922 +.PlacePartyMonTMHMCompatibility push hl predef CanLearnTMHMMove pop hl - ld de, .text_50948 + ld de, .string_able ld a, c and a - jr nz, .asm_50933 - ld de, .text_5094f -.asm_50933 + jr nz, .able + ld de, .string_not_able +.able push hl - ld bc, $0009 + ld bc, 9 add hl, bc call PlaceString pop hl -.asm_5093c - ld bc, $0005 +.PrintLevel + ld bc, 5 add hl, bc push de call PrintLevel @@ -1297,21 +1309,24 @@ Function508c4:: pop bc ret -.text_50948: - db "おぼえられる@" +.string_able: + db "おぼえられる@" ; "ABLE" -.text_5094f: - db "おぼえられない@" +.string_not_able: + db "おぼえられない@" ; "NOT ABLE" -.DetermineCompatibility: +.PlacePartyMonEvoStoneCompatibility: push hl ld hl, EvosAttacksPointers - ld a, [wTempMonSpecies] ; Species of selected pokemon? + ld a, [wTempMonSpecies] dec a ld c, a - ld b, $00 + ld b, 0 add hl, bc add hl, bc +; BUG: Only the first three evolution entries can have Stone compatibility reported correctly. +; While this never comes up in the final game, this prototype has Espeon and Umbreon evolving from +; Heart Stones and Poison Stones respectively, making it five evolution stone entries for Eevee. ld de, wStringBuffer1 ld a, BANK(EvosAttacksPointers) ld bc, 2 @@ -1325,16 +1340,16 @@ Function508c4:: ld bc, 10 call FarCopyBytes ld hl, wStringBuffer1 - ld de, .string_not_able - ; Fallthrough -.asm_50986 + ld de, .string_cant_use + +.loop ld a, [hli] and a - jr z, .asm_5099e + jr z, .nope inc hl inc hl cp EVOLVE_STONE - jr nz, .asm_50986 + jr nz, .loop dec hl dec hl ld b, [hl] @@ -1342,23 +1357,24 @@ Function508c4:: inc hl inc hl cp b - jr nz, .asm_50986 - ld de, .string_able -.asm_5099e + jr nz, .loop + ld de, .string_can_use + +.nope pop hl push hl - ld bc, $0009 + ld bc, 9 add hl, bc call PlaceString pop hl - jr .asm_5093c + jr .PrintLevel -.string_able - db "つかえる@" -.string_not_able - db "つかえない@" +.string_can_use + db "つかえる@" ; "ABLE" +.string_cant_use + db "つかえない@" ; "NOT ABLE" -.asm_509b5 +.PlacePartyMonGender xor a ld [wMonType], a push hl @@ -1369,11 +1385,11 @@ Function508c4:: ld de, .female .got_gender push hl - ld bc, $0009 + ld bc, 9 add hl, bc call PlaceString pop hl - jp .asm_5093c + jp .PrintLevel .male db "オス@" @@ -1381,35 +1397,37 @@ Function508c4:: .female db "メス@" -Function509d8:: - ld b, $0a +PrintPartyText_GetSGBLayout:: + ld b, SGB_PARTY_MENU call GetSGBLayout -Function509dd:: +PrintPartyMenuText:: ld hl, wOptions ld a, [hl] push af push hl set NO_TEXT_SCROLL_F, [hl] + ld a, [wPartyMenuActionText] cp PARTYMENUTEXT_HEAL_PSN - jr nc, .asm_509fc + jr nc, .heal + add a ld c, a - ld b, $00 - ld hl, .data_50a33 + ld b, 0 + ld hl, .PartyMenuStrings add hl, bc ld a, [hli] ld h, [hl] ld l, a call PrintText - jr .asm_50a17 + jr .done -.asm_509fc - and $0f +.heal + and $f add a ld c, a - ld b, $00 - ld hl, .data_50a21 + ld b, 0 + ld hl, .MenuActionStrings add hl, bc ld a, [hli] ld h, [hl] @@ -1420,7 +1438,7 @@ Function509dd:: call GetNick pop hl call PrintText -.asm_50a17 +.done pop hl pop af ld [hl], a @@ -1428,58 +1446,58 @@ Function509dd:: call SetPalettes ret -.data_50a21 - dw Text_50acb - dw Text_50af9 - dw Text_50b09 - dw Text_50b1d - dw Text_50ae5 - dw Text_50ab0 - dw Text_50b2b - dw Text_50b3b - dw Text_50b4e +.MenuActionStrings + dw CuredOfPoisonText + dw BurnWasHealedText + dw _WasDefrostedText + dw _WokeUpText + dw RidOfParalysisText + dw RecoveredSomeHPText + dw HealthReturnedText + dw RevitalizedText + dw _GrewToLevelText -.data_50a33 - dw Text_50a43 - dw Text_50a51 - dw Text_50a5f - dw Text_50a6c - dw Text_50a7a - dw Text_50a51 - dw Text_50a88 - dw Text_50a9c +.PartyMenuStrings + dw ChooseAMonString + dw UseOnWhichPKMNString + dw WhichPKMNString + dw TeachWhichPKMNString + dw MoveToWhereString + dw UseOnWhichPKMNString + dw ChooseFirstMonString + dw ChooseSecondMonString -Text_50a43: ; Choose a pokemon +ChooseAMonString: text "#を えらんで ください" done -Text_50a51: +UseOnWhichPKMNString: text "どの#に つかいますか?" done -Text_50a5f: +WhichPKMNString: text "どの#を だしますか?" done -Text_50a6c: +TeachWhichPKMNString: text "どの#に おしえますか?" done -Text_50a7a: +MoveToWhereString: text "どこに いどうしますか?" done -Text_50a88: ; first Pokemon in Daycare? +ChooseFirstMonString: text "1ぴきめの #を" line "えらんで ください" done -Text_50a9c: ; second Pokemon in Daycare? +ChooseSecondMonString: text "2ひきめの #を" line "えらんで ください" done -Text_50ab0: ; restored hp +RecoveredSomeHPText: text_from_ram wStringBuffer1 text "の たいりょくが" line "@" @@ -1487,62 +1505,62 @@ Text_50ab0: ; restored hp text " かいふくした" done -Text_50acb: ; cured poison +CuredOfPoisonText: text_from_ram wStringBuffer1 text "の どくは" line "きれい さっぱり なくなった!" done -Text_50ae5: ; cured paralysis +RidOfParalysisText: text_from_ram wStringBuffer1 text "の からだの" line "しびれが とれた" done -Text_50af9: ; cured burn +BurnWasHealedText: text_from_ram wStringBuffer1 text "の" line "やけどが なおった" done -Text_50b09: ; cured frozen +_WasDefrostedText: text_from_ram wStringBuffer1 text "の からだの" line "こおりが とけた" done -Text_50b1d: ; cured asleep +_WokeUpText: text_from_ram wStringBuffer1 text "は" line "めを さました" done -Text_50b2b: ; health returned (presumably for Sacred Fire) +HealthReturnedText: text_from_ram wStringBuffer1 text "は" line "けんこうになった!" done -Text_50b3b: ; revived +RevitalizedText: text_from_ram wStringBuffer1 text "は" line "げんきを とりもどした!" done -Text_50b4e: ; leveled up +_GrewToLevelText: text_from_ram wStringBuffer1 text "の レべルが@" deciram wCurPartyLevel, 1, 3 text "になった@" sound_dex_fanfare_50_79 text_waitbutton - db "@" - -Function50b66:: + text_end + +SetPartyHPBarPalette:: ld hl, wHPPals ld a, [wcce1] ld c, a - ld b, $00 + ld b, 0 add hl, bc call SetHPPal ld b, SGB_PARTY_MENU_HP_PALS @@ -1755,12 +1773,12 @@ Function50c48:: ld [wItemAttributesPointer + 1], a ret -Function50caa:: +CalcLevel:: ld a, [wTempMonSpecies] ld [wCurSpecies], a call GetBaseData - ld d, $01 -.asm_50cb5 + ld d, 1 +.next_level inc d call CalcExpAtLevel push hl @@ -1778,7 +1796,9 @@ Function50caa:: ld a, [hl] sbc c pop hl - jr nc, .asm_50cb5 + jr nc, .next_level + +.got_level dec d ret @@ -2077,15 +2097,15 @@ _SwitchPartyMons:: call CopyBytes ret -Function50eca:: +PartyMenu_ClearCursor:: hlcoord 0, 1 - ld bc, $0028 - ld a, $06 -.asm_50ed2 - ld [hl], $7f + ld bc, 2 * SCREEN_WIDTH + ld a, PARTY_LENGTH +.next + ld [hl], " " add hl, bc dec a - jr nz, .asm_50ed2 + jr nz, .next ret GetUnownLetter:: @@ -2135,5 +2155,5 @@ GetUnownLetter:: ; Increment to get 1-26 ldh a, [hQuotient + 3] inc a - ld [wAnnonID], a ; $d874 + ld [wAnnonID], a ret diff --git a/engine/events/breeder.asm b/engine/events/breeder.asm new file mode 100644 index 0000000..1b76e1d --- /dev/null +++ b/engine/events/breeder.asm @@ -0,0 +1,275 @@ +INCLUDE "constants.asm" + +SECTION "engine/events/breeder.asm", ROMX + +_Breeder:: + ld a, [wBreederStatus] + cp BREEDER_TWO_BREEDMON + jr c, .continue + cp BREEDER_EGG_READY + jp z, .AskGiveEgg + cp BREEDER_GAVE_EGG + jr z, .continue + + call .CheckBreedmonCompatibility + ld a, [wBreedingCompatibility] + and a + jr z, .no_egg_yet +; Autogenerates an egg if the Pokémon are compatible. + ld a, BREEDER_EGG_READY + ld [wBreederStatus], a +.no_egg_yet + ld hl, .NoEggYetText + call PrintText + +.continue + ld hl, .IntroText + call PrintText + ld hl, .MenuHeader + call LoadMenuHeader + call VerticalMenu + push af + call CloseWindow + pop af + jp c, .Exit + ld a, [wMenuCursorY] + cp 3 + jp z, .Exit + cp 1 + jr z, .Deposit + + ld a, [wBreederStatus] + and a + jr z, .no_breedmons + cp BREEDER_TWO_BREEDMON + jr nz, .Withdraw + + ld hl, .CheckOnPokemonText + call PrintText + call YesNoBox + jp c, .Exit + + jr .Withdraw + +.no_breedmons + ld hl, .DoesntHavePokemonText + call PrintText + jp .Exit + +.Withdraw: + ld a, GET_BREED_MON + ld [wPokemonWithdrawDepositParameter], a + predef RetrieveBreedmonOrBuffermon + jp c, .party_full + + ld a, [wBreederStatus] + sub 1 + jr z, .last_mon + ld a, BREEDER_ONE_BREEDMON +.last_mon + ld [wBreederStatus], a + ld a, [wBreedMonGenders] + srl a + ld [wBreedMonGenders], a + ld hl, .WithdrawnText + call PrintText + jp .Exit + +.Deposit: + ld a, [wBreederStatus] + cp BREEDER_TWO_BREEDMON + jp nc, .empty + + add PARTYMENUACTION_GIVE_MON + call UseItem_SelectMon + jp c, .Exit + + ld a, [wCurPartySpecies] + ld [wCurSpecies], a + call GetBaseData + xor a + ld [wMonType], a + predef GetGender + + ld a, [wBreedMonGenders] + rla + ld [wBreedMonGenders], a + + ld a, [wCurPartyMon] + ld hl, wPartyMonNicknames + call GetNick + ld a, GET_BREED_MON + ld [wPokemonWithdrawDepositParameter], a + predef DepositBreedmonOrBuffermon + + xor a ; REMOVE_PARTY + ld [wPokemonWithdrawDepositParameter], a + callfar RemoveMonFromPartyOrBox ; in the same bank, no need to farcall! + ld a, [wCurPartySpecies] + call PlayCry + + ld hl, .DepositedText + call PrintText + ld a, [wBreederStatus] + inc a + ld [wBreederStatus], a + cp BREEDER_TWO_BREEDMON + jr nz, .Exit + + ld hl, .LetsMakeBabiesText + call PrintText + + call .CheckBreedmonCompatibility + ld a, [wBreedingCompatibility] + cp 80 + ld hl, .SeemToGetAlongText + call z, PrintText + + ld a, [wBreedingCompatibility] + cp 20 + ld hl, .DontSeemToGetAlongText + call z, PrintText + + ld a, [wBreedingCompatibility] + and a + ld hl, .GendersDontMatchText + call z, PrintText + jr .Exit +.empty + ld hl, .AlreadyHasTwoPokemonText + call PrintText + jr .Exit + +.Exit: + call ClearBGPalettes + call RestoreScreenAndReloadTiles + call GetMemSGBLayout + jp ReloadFontAndTileset + +.party_full + ld hl, .BoxAndPartyFullText + jp PrintText + +.CheckBreedmonCompatibility: +; Assumes that wBreedMonGenders has already been set from opening the Breeder menu with 1 or fewer Pokémon. +; If you open the breeder after saving and resetting the game while they have two Pokémon +; (assuming the BreedMons GET saved at this point in development), +; then this check will fail until you change out the BreedMons again. + ld a, [wBreedMonGenders] + ld b, a + srl b + xor b + and $1 + jr z, .done + + ld a, [wBreedMon1ID] + ld b, a + ld a, [wBreedMon2ID] + cp b + jr nz, .different_id + + ld a, [wBreedMon1ID + 1] + ld b, a + ld a, [wBreedMon2ID + 1] + cp b + jr nz, .different_id + ld a, 20 + jr .done +.different_id + ld a, 80 +.done + ld [wBreedingCompatibility], a + ret + +.IntroText: + text "わたしは こずくりやさん" + line "さて どうする?" + done + +.MenuHeader: + db MENU_BACKUP_TILES + menu_coords 13, 4, 19, 11 + dw .MenuData + db 1 + +.MenuData: + db STATICMENU_CURSOR + db 3 + db "あずける@" ; Deposit + db "ひきとる@" ; Withdraw + db "やめる@" ; Cancel + +.DepositedText: + text "あずけた!" + prompt + +.AlreadyHasTwoPokemonText: + text "すでに 2ひきの#を" + line "あずかっています" + prompt + +.CheckOnPokemonText: + text "こずくりを ちゅうししますか?" + done + +.DoesntHavePokemonText: + text "#は いっぴきも" + line "あずかってませんが" + prompt + +.WithdrawnText: + text "ひきとった!" + prompt + +.BoxAndPartyFullText: + text "てもちも マサキの も" + line "#で いっぱいのようです" + prompt + +.LetsMakeBabiesText: + text "それでは こづくりします!" + prompt + +.SeemToGetAlongText: + text "あいしょうが いいようです" + prompt + +.DontSeemToGetAlongText: + text "あいしょうが わるいようです" + prompt + +.GendersDontMatchText: + text "せいべつが あわないようです" + prompt + +.NoEggYetText: + text "ざんねんながら まだ うまれて" + line "こないようです" + prompt + +.AskGiveEgg: + ld hl, .EggLaidText + call PrintText + call YesNoBox + jp c, .Exit + + ld a, BREEDER_GAVE_EGG + ld [wBreederStatus], a + ld a, [wBreedMon1Species] + ld [wCurPartySpecies], a + call PlayCry + + xor a + ld [wMonType], a + ld a, 5 + ld [wCurPartyLevel], a + predef GiveEgg + jp .Exit + +.EggLaidText: + text "タマゴが うまれました!" + line "ひきとりますか?" + done + +Stub_MailEffect:: + ret diff --git a/engine/events/field_moves.asm b/engine/events/field_moves.asm index 98f36fe..b4dd7ed 100755 --- a/engine/events/field_moves.asm +++ b/engine/events/field_moves.asm @@ -168,7 +168,7 @@ CutScript: call LoadMapPart call UpdateSprites call WaitBGMap - call Function1fea + call ScreenCleanup scf ret @@ -252,7 +252,7 @@ SurfScript: call RedrawPlayerSprite call PlayMapMusic call MovePlayerIntoWater - call Function1fea + call ScreenCleanup ret Text_UsedSurf: @@ -531,7 +531,7 @@ TeleportScript: ld c, 60 call DelayFrames call CloseWindow - call Function1fea + call ScreenCleanup ld a, MAPSETUP_TELEPORT ldh [hMapEntryMethod], a jpfar DoTeleportAnimation diff --git a/engine/events/pokecenter_pc.asm b/engine/events/pokecenter_pc.asm index 99b72ec..a42a61d 100644 --- a/engine/events/pokecenter_pc.asm +++ b/engine/events/pokecenter_pc.asm @@ -462,7 +462,7 @@ PCItemsJoypad: ld hl, .MenuHeader call CopyMenuHeader ld a, [wBackpackAndKeyItemsCursor] - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a ld a, [wBackpackAndKeyItemsScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu diff --git a/engine/events/pokepic.asm b/engine/events/pokepic.asm new file mode 100644 index 0000000..314da85 --- /dev/null +++ b/engine/events/pokepic.asm @@ -0,0 +1,46 @@ +INCLUDE "constants.asm" + +SECTION "engine/events/pokepic.asm", ROMX + +Pokepic:: + ld a, 1 + ldh [hBGMapMode], a + ld hl, .PokepicMenuHeader + call LoadMenuHeader + call MenuBox + call UpdateSprites + ld b, SGB_POKEPIC + call GetSGBLayout + xor a + ldh [hBGMapMode], a + ld a, [wCurPartySpecies] + ld [wCurSpecies], a + call GetBaseData + ld de, vChars1 + call LoadMonFrontSprite + ld a, [wMenuBorderTopCoord] + inc a + ld b, a + ld a, [wMenuBorderLeftCoord] + inc a + ld c, a + call Coord2Tile + ld a, $80 + ldh [hGraphicStartTile], a + lb bc, 7, 7 + predef PlaceGraphic + ld a, 1 + ldh [hBGMapMode], a + call TextboxWaitPressAorB_BlinkCursor + call ClearMenuBoxInterior + call WaitBGMap + call GetMemSGBLayout + call CloseWindow + call LoadFont + ret + +.PokepicMenuHeader: + db MENU_BACKUP_TILES + menu_coords 6, 4, 14, 13 + dw 0 + db 1 diff --git a/engine/events/starter_dex.asm b/engine/events/starter_dex.asm new file mode 100644 index 0000000..a48ed0e --- /dev/null +++ b/engine/events/starter_dex.asm @@ -0,0 +1,32 @@ +INCLUDE "constants.asm" + +SECTION "engine/events/starter_dex.asm", ROMX + +; Brings up the Pokédex entry of the index in wTempSpecies/wNamedObjectIndex to show as if it were caught. +StarterDex:: + call RefreshScreen + call LowVolume + ldh a, [hMapAnims] + push af + xor a + ldh [hMapAnims], a + ld hl, wStateFlags + res SPRITE_UPDATES_DISABLED_F, [hl] + call ClearBGPalettes + call ClearSprites + call LoadStandardMenuHeader + callfar LoadPokeDexGraphics + call ClearTileMap + callfar _NewPokedexEntry + call ClearBGPalettes + ld hl, wStateFlags + set SPRITE_UPDATES_DISABLED_F, [hl] + call ExitMenu + call LoadTilesetGFX_LCDOff + call RestoreScreenAndReloadTiles + call UpdateTimePals + pop af + ldh [hMapAnims], a + call MaxVolume + call ScreenCleanup + ret diff --git a/engine/events/town_map.asm b/engine/events/town_map.asm new file mode 100644 index 0000000..b678c95 --- /dev/null +++ b/engine/events/town_map.asm @@ -0,0 +1,322 @@ +INCLUDE "constants.asm" + +SECTION "engine/events/town_map.asm", ROMX + +TownMap:: + call InitTownMap + callfar ClearSpriteAnims + call TownMap_InitPlayerIcon + call WaitBGMap + call SetPalettes +.loop + call DelayFrame + call GetJoypadDebounced + callfar PlaySpriteAnimations + ld hl, hJoyDown + ld a, [hl] + and A_BUTTON | B_BUTTON + jr z, .loop + ret + +FlyMap:: + ld hl, hInMenu + ld a, [hl] + push af + ld [hl], 1 + call InitTownMap + callfar ClearSpriteAnims + call TownMap_InitPlayerIcon + call FlyMap_InitPidgeyIcon + ld hl, wFlyIconAnimStructPointer + ld [hl], c + inc hl + ld [hl], b + hlcoord 1, 15 + ld de, ChooseADestinationText + call PlaceString + call WaitBGMap + call SetPalettes + xor a + ld [wFlyDestination], a +.loop + call DelayFrame + call GetJoypadDebounced + callfar PlaySpriteAnimations + ld hl, hJoyDown + ld a, [hl] + and B_BUTTON + jr nz, .cancel + ld a, [hl] + and A_BUTTON + jr nz, .fly + call .HandleDPad + callfar GetFlyPointMapLocation + ld d, 0 + ld hl, LandmarkPositions + add hl, de + add hl, de + ld d, [hl] + inc hl + ld e, [hl] + ld hl, wFlyIconAnimStructPointer + ld c, [hl] + inc hl + ld b, [hl] + ld hl, SPRITEANIMSTRUCT_XCOORD + add hl, bc + ld [hl], e + ld hl, SPRITEANIMSTRUCT_YCOORD + add hl, bc + ld [hl], d + jr .loop + +.cancel + ld a, -1 + ld [wFlyDestination], a +.fly + pop af + ldh [hInMenu], a + ret + +.HandleDPad: + ld a, [wFlyDestination] + ld l, a + ld h, 0 + add hl, hl + add hl, hl + ld de, FlyPointPaths + add hl, de + ld de, hJoySum + ld a, [de] + and D_UP + jr nz, .get_point + inc hl + ld a, [de] + and D_DOWN + jr nz, .get_point + inc hl + ld a, [de] + and D_LEFT + jr nz, .get_point + inc hl + ld a, [de] + and D_RIGHT + jr nz, .get_point + ret +.get_point + ld a, [hl] + cp -1 + ret z + ld [wFlyDestination], a + ret + +ChooseADestinationText: + db "とびさき を えらんでください@" + +Pokedex_GetArea: + ld a, [wNestIconBlinkCounter] + push af + xor a + ld [wNestIconBlinkCounter], a + + call InitTownMap + ld de, PokedexNestIconGFX + ld hl, vChars0 tile $7f + lb bc, BANK(PokedexNestIconGFX), 1 + call Request1bpp + + call GetPokemonName + hlcoord 4, 15 + call PlaceString + + hlcoord 9, 15 + ld de, .String_SNest + call PlaceString + + call WaitBGMap + call SetPalettes + xor a + ldh [hBGMapMode], a + ld hl, wTileMap + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + xor a + call ByteFill + callfar FindNest +.loop + call .PlaceNest + call GetJoypadDebounced + ldh a, [hJoyDown] + and A_BUTTON | B_BUTTON + jr nz, .done + + ld hl, wNestIconBlinkCounter + inc [hl] + call DelayFrame + jr .loop +.done + pop af + ld [wNestIconBlinkCounter], a + ret + +.String_SNest: + db "の すみか@" + +.PlaceNest: + ld a, [wNestIconBlinkCounter] + and $10 + jr z, .done_nest + + ld de, wTileMap + ld hl, wShadowOAMSprite00 +.nestloop + ld a, [de] + and a + ret z + + push de + push hl + ld e, a + ld d, $00 + ld hl, LandmarkPositions + add hl, de + add hl, de + ld e, l + ld d, h + + ; load into OAM + pop hl +; X position + ld a, [de] + inc de + sub 4 + ld [hli], a +; Y position + ld a, [de] + inc de + sub 4 + ld [hli], a +; Nest icon -> Tile ID + ld a, $7f + ld [hli], a +; Blank out attributes + xor a + ld [hli], a + + pop de + inc de + jr .nestloop +.done_nest + call ClearSprites + ret + +InitTownMap: + call ClearBGPalettes + call ClearTileMap + call UpdateSprites + call DisableLCD + + ld hl, TownMapGFX + ld de, vTilesetEnd + ld bc, TownMapGFX.End - TownMapGFX + ld a, BANK(TownMapGFX) + call FarCopyData + + ld hl, wTileMap + call DecompTownMapTilemap + hlcoord 0, 13 + ld b, 3 + ld c, 18 + call DrawTextBox + + ld a, 3 + call UpdateSoundNTimes + call EnableLCD + ld b, SGB_TOWN_MAP + call GetSGBLayout + ret + +DecompTownMapTilemap: + ld de, TownMapTilemap +.loop + ld a, [de] + and a + ret z + + ld b, a + inc de + ld a, [de] + ld c, a + ld a, b + add $60 +.keep_placing_tile + ld [hli], a + dec c + jr nz, .keep_placing_tile + inc de + jr .loop + +TownMap_InitPlayerIcon: + ld de, GoldSpriteGFX + ld hl, vChars0 + lb bc, BANK(GoldSpriteGFX), $04 + call Request2bpp + + ld de, GoldSpriteGFX + 12 tiles + ld hl, vChars0 tile $04 + lb bc, BANK(GoldSpriteGFX), $04 + call Request2bpp + + depixel 0, 0 + ld a, SPRITE_ANIM_OBJ_MAP_CHARACTER_ICON + call InitSpriteAnimStruct + + ld hl, SPRITEANIMSTRUCT_TILE_ID + add hl, bc + ld [hl], $00 + + push bc + ld a, [wMapGroup] + ld b, a + ld a, [wMapId] + ld c, a + call GetWorldMapLocation + + ld e, a + ld d, $00 + ld hl, LandmarkPositions + add hl, de + add hl, de + ld d, [hl] + inc hl + ld e, [hl] + pop bc + ld hl, SPRITEANIMSTRUCT_XCOORD + add hl, bc + ld [hl], e + ld hl, SPRITEANIMSTRUCT_YCOORD + add hl, bc + ld [hl], d + ret + +FlyMap_InitPidgeyIcon: + ld de, PidgeySpriteGFX + ld hl, vChars0 tile $08 + lb bc, BANK(PidgeySpriteGFX), 4 + call Request2bpp + + ld de, PidgeySpriteGFX + 12 tiles + ld hl, vChars0 tile $0c + lb bc, BANK(PidgeySpriteGFX), 4 + call Request2bpp + + depixel 0, 0 + ld a, SPRITE_ANIM_OBJ_MAP_CHARACTER_ICON + call InitSpriteAnimStruct + + ld hl, SPRITEANIMSTRUCT_TILE_ID + add hl, bc + ld [hl], 8 + ret + +TownMapTilemap: +INCBIN "gfx/trainer_gear/town_map.tilemap.rle" diff --git a/engine/gfx/load_minor_object_gfx.asm b/engine/gfx/load_minor_object_gfx.asm new file mode 100644 index 0000000..35b08fc --- /dev/null +++ b/engine/gfx/load_minor_object_gfx.asm @@ -0,0 +1,143 @@ +INCLUDE "constants.asm" + +SECTION "engine/gfx/load_minor_object_gfx.asm", ROMX + + +_LoadMinorObjectGFX:: + ld hl, wQueuedMinorObjectGFX + push hl + ld a, [hl] + ld l, a + ld h, 0 + ld de, .MinorObjectGFX + add hl, hl + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + pop hl + push de + ret + +.MinorObjectGFX: + dw .LoadNull + dw .LoadJumpShadow + dw .LoadUnknownBouncingOrb + dw .LoadShockEmote + dw .LoadQuestionEmote + dw .LoadHappyEmote + dw .LoadBoulderDust + dw .LoadGrampsSpriteStandPt0 + dw .LoadGrampsSpriteStandPt1 + dw .LoadGrampsSpriteWalkPt0 + dw .LoadGrampsSpriteWalkPt1 + dw .LoadClefairySpriteStandPt0 + dw .LoadClefairySpriteStandPt1 + dw .LoadClefairySpriteWalkPt0 + dw .LoadClefairySpriteWalkPt1 + +.FarCopy: + ld a, c + ld [wVBCopyFarSrcBank], a + ld a, l + ld [wVBCopyFarSrc], a + ld a, h + ld [wVBCopyFarSrc+1], a +.ContinueFarCopyNewDst: + ld a, e + ld [wVBCopyFarDst], a + ld a, d + ld [wVBCopyFarDst+1], a +.ContinueFarCopy: + ld a, b + ld [wVBCopyFarSize], a + ret + +.LoadNull: + ret + +.LoadShockEmote: + ld hl, ShockEmoteGFX + jr .load_emote +.LoadQuestionEmote: + ld hl, QuestionEmoteGFX + jr .load_emote +.LoadHappyEmote: + ld hl, HappyEmoteGFX +.load_emote: + ld de, vChars1 tile $78 + ld b, (HappyEmoteGFX.end - HappyEmoteGFX) / LEN_2BPP_TILE + ld c, BANK(EmoteGFX) + jp .FarCopy + +.LoadJumpShadow: + ld [hl], $00 + ld hl, JumpShadowGFX + ld de, vChars1 tile $7c + ld b, (JumpShadowGFX.end - JumpShadowGFX) / LEN_2BPP_TILE + ld c, BANK(JumpShadowGFX) + jp .FarCopy + +.LoadUnknownBouncingOrb: + ld [hl], $00 + ld hl, UnknownBouncingOrbGFX + ld de, vChars1 tile $7c + ld b, (UnknownBouncingOrbGFX.end - UnknownBouncingOrbGFX) / LEN_2BPP_TILE + ld c, BANK(UnknownBouncingOrbGFX) + jp .FarCopy + +.LoadBoulderDust: + ld [hl], $00 + ld hl, BoulderDustGFX + ld de, vChars1 tile $7c + ld b, (BoulderDustGFX.end - BoulderDustGFX) / LEN_2BPP_TILE + ld c, BANK(BoulderDustGFX) + jp .FarCopy + +.LoadGrampsSpriteStandPt0: + inc [hl] + ld hl, GrampsSpriteGFX + ld de, vChars0 + ld b, (GrampsSpriteGFX.end - GrampsSpriteGFX) / LEN_2BPP_TILE / 4 + ld c, BANK(GrampsSpriteGFX) + jp .FarCopy + +.LoadGrampsSpriteStandPt1: + inc [hl] + ld b, (GrampsSpriteGFX.end - GrampsSpriteGFX) / LEN_2BPP_TILE / 4 + jp .ContinueFarCopy + +.LoadGrampsSpriteWalkPt0: + inc [hl] + ld de, vChars1 + ld b, (GrampsSpriteGFX.end - GrampsSpriteGFX) / LEN_2BPP_TILE / 4 + jp .ContinueFarCopyNewDst + +.LoadGrampsSpriteWalkPt1: + ld [hl], $00 + ld b, (GrampsSpriteGFX.end - GrampsSpriteGFX) / LEN_2BPP_TILE / 4 + jp .ContinueFarCopy + +.LoadClefairySpriteStandPt0: + inc [hl] + ld hl, ClefairySpriteGFX + ld de, vChars0 + ld b, (ClefairySpriteGFX.end - ClefairySpriteGFX) / LEN_2BPP_TILE / 4 + ld c, BANK(ClefairySpriteGFX) + jp .FarCopy + +.LoadClefairySpriteStandPt1: + inc [hl] + ld b, (ClefairySpriteGFX.end - ClefairySpriteGFX) / LEN_2BPP_TILE / 4 + jp .ContinueFarCopy + +.LoadClefairySpriteWalkPt0: + inc [hl] + ld de, vChars1 + ld b, (ClefairySpriteGFX.end - ClefairySpriteGFX) / LEN_2BPP_TILE / 4 + jp .ContinueFarCopyNewDst + +.LoadClefairySpriteWalkPt1: + ld [hl], $00 + ld b, (ClefairySpriteGFX.end - ClefairySpriteGFX) / LEN_2BPP_TILE / 4 + jp .ContinueFarCopy diff --git a/engine/gfx/sgb_layouts.asm b/engine/gfx/sgb_layouts.asm index 10ab945..94e00e5 100644 --- a/engine/gfx/sgb_layouts.asm +++ b/engine/gfx/sgb_layouts.asm @@ -533,8 +533,8 @@ GetMonSGBPaletteFlags: .return ret -Function95f8: - ld hl, BlkPacket_98fc +InitPartyMenuPalettes: + ld hl, BlkPacket_PartyMenu ld de, wcce2 ld bc, $0030 jp CopyBytes diff --git a/engine/items/buy_sell_toss.asm b/engine/items/buy_sell_toss.asm new file mode 100644 index 0000000..147fa46 --- /dev/null +++ b/engine/items/buy_sell_toss.asm @@ -0,0 +1,185 @@ +INCLUDE "constants.asm" + +SECTION "engine/items/buy_sell_toss.asm", ROMX + +SelectQuantityToToss:: + ld hl, TossItem_MenuHeader + call LoadMenuHeader + call Toss_Sell_Loop + ret + +SelectQuantityToBuy:: + callfar GetItemPrice + ld a, d + ld [wBuySellItemPrice], a + ld a, e + ld [wBuySellItemPrice + 1], a + ld hl, BuyItem_MenuHeader + call LoadMenuHeader + call Toss_Sell_Loop + ret + +Toss_Sell_Loop: + ld a, 1 + ld [wItemQuantity], a +.preloop +; It won't progress if you're holding the A Button... + call GetJoypad + ldh a, [hJoyState] + bit A_BUTTON_F, a + jr nz, .preloop + +.loop + call BuySellToss_UpdateQuantityDisplayAndPrice + call BuySellToss_InterpretJoypad + jr nc, .loop + cp -1 + jr nz, .nope ; pressed B + scf + ret + +.nope + and a + ret + +BuySellToss_InterpretJoypad: +.loop + call DelayFrame + ldh a, [hInMenu] + push af + ld a, 1 + ldh [hInMenu], a + call GetJoypadDebounced + pop af + ldh [hInMenu], a + + ldh a, [hJoyDown] + bit B_BUTTON_F, a + jr nz, .b + bit A_BUTTON_F, a + jr nz, .a + + ldh a, [hJoySum] + bit D_DOWN_F, a + jr nz, .down + bit D_UP_F, a + jr nz, .up + bit D_LEFT_F, a + jr nz, .left + bit D_RIGHT_F, a + jr nz, .right + jr .loop +.b + ld a, -1 + scf + ret + +.a + scf + ret + +.down + ld hl, wItemQuantity + dec [hl] + jr nz, .finish_down + ld a, [wItemQuantityBuffer] + ld [hl], a + +.finish_down + and a + ret + +.up + ld hl, wItemQuantity + inc [hl] + ld a, [wItemQuantityBuffer] + cp [hl] + jr nc, .finish_up + ld [hl], 1 + +.finish_up + and a + ret + +.left + ld a, [wItemQuantity] + sub 10 + jr c, .load_1 + jr z, .load_1 + jr .finish_left + +.load_1 + ld a, 1 + +.finish_left + ld [wItemQuantity], a + and a + ret + +.right + ld a, [wItemQuantity] + add 10 + ld b, a + ld a, [wItemQuantityBuffer] + cp b + jr nc, .finish_right + ld b, a + +.finish_right + ld a, b + ld [wItemQuantity], a + and a + ret + +BuySellToss_UpdateQuantityDisplayAndPrice: + call MenuBox + call MenuBoxCoord2Tile + ld de, SCREEN_WIDTH + 1 + add hl, de + ld [hl], "×" + inc hl + ld de, wItemQuantity + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 + call PrintNumber + ld a, [wMenuDataPointer] + cp -1 + ret nz + + xor a + ldh [hMultiplicand], a + ld a, [wBuySellItemPrice] + ldh [hMultiplicand + 1], a + ld a, [wBuySellItemPrice + 1] + ldh [hMultiplicand + 2], a + ld a, [wItemQuantity] + ldh [hMultiplier], a + push hl + call Multiply + + ld hl, hMoneyTemp + ldh a, [hProduct + 1] + ld [hli], a + ldh a, [hProduct + 2] + ld [hli], a + ldh a, [hProduct + 3] + ld [hl], a + pop hl + inc hl + ld de, hMoneyTemp + lb bc, 4, 6 + call PrintNumber + ld [hl], "円" + call WaitBGMap + ret + +TossItem_MenuHeader: + db MENU_BACKUP_TILES + menu_coords 15, 9, $13, 11 + dw NULL + db 0 + +BuyItem_MenuHeader: + db MENU_BACKUP_TILES + menu_coords 7, 15, $13, $11 + dw $ff + db $ff diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm index 5bdd06b..eeb6b53 100755 --- a/engine/items/inventory.asm +++ b/engine/items/inventory.asm @@ -2,6 +2,141 @@ INCLUDE "constants.asm" SECTION "engine/items/inventory.asm@Inventory", ROMX +; Leftover from Generation I. Equivalent to pokered's AddItemToInventory_. +Unreferenced_ReceiveItem_Old: + ld a, [wItemQuantity] + push af + push bc + push de + push hl + push hl + ld d, 50 ; PC_ITEM_CAPACITY + push hl + ld bc, $2e62 ; TODO: ??? + add hl, bc + ld a, h + or l + pop hl + jr nz, .check_if_inventory_full + + ld d, 20 ; BAG_ITEM_CAPACITY +.check_if_inventory_full + ld a, [hl] + sub d + ld d, a + ld a, [hli] + and a + jr z, .add_new_item + +.not_at_end_of_inventory + ld a, [hli] + ld b, a + ld a, [wCurItem] + cp b + jp z, .increase_item_quantity + inc hl + ld a, [hl] + cp -1 + jr nz, .not_at_end_of_inventory + +.add_new_item + pop hl + ld a, d + and a + jr z, .done + + inc [hl] + ld a, [hl] + add a + dec a + ld c, a + ld b, 0 + add hl, bc ; address to store item + ld a, [wCurItem] + ld [hli], a + ld a, [wItemQuantity] + ld [hli], a + ld [hl], -1 + jp .success + +.increase_item_quantity + ld a, [wItemQuantity] + ld b, a + ld a, [hl] + add b + cp MAX_ITEM_STACK + 1 + jp c, .store_new_quantity + sub MAX_ITEM_STACK + ld [wItemQuantity], a + ld a, d + and a + jr z, .increase_item_quantity_failed + ld a, MAX_ITEM_STACK + ld [hli], a + jp .not_at_end_of_inventory + +.increase_item_quantity_failed + pop hl + and a + jr .done + +.store_new_quantity + ld [hl], a + pop hl +.success + scf +.done + pop hl + pop de + pop bc + pop bc + ld a, b + ld [wItemQuantity], a + ret + +Unreferenced_RemoveItemFromInventory_Old: + push hl + inc hl + ld a, [wItemIndex] + ld e, a + ld d, 0 + add hl, de + add hl, de + inc hl + ld a, [wItemQuantity] + ld e, a + ld a, [hl] + sub e + ld [hld], a + ld [wItemQuantityBuffer], a + and a + jr nz, .skip_moving_up_slots + ld e, l + ld d, h + inc de + inc de +.loop + ld a, [de] + inc de + ld [hli], a + cp -1 + jr nz, .loop + xor a + ld [wMenuScrollPosition], a + ld [wRegularItemsCursor], a + pop hl + ld a, [hl] + dec a + ld [hl], a + ld [wScrollingMenuListSize], a + cp 2 + jr c, .done + jr .done +.skip_moving_up_slots + pop hl +.done + ret + _ReceiveItem: call DoesHLEqualwNumBagItems jp nz, PutItemInPocket @@ -149,7 +284,7 @@ PutItemInPocket: jr z, .terminator cp c jr nz, .next - ld a, 99 + ld a, MAX_ITEM_STACK sub [hl] add b ld b, a @@ -192,12 +327,12 @@ PutItemInPocket: ld [hl], a jr .done -; set this slot's quantity to 99, +; set this slot's quantity to MAX_ITEM_STACK, ; and keep iterating through list ; to add remaining amount .set_max - ld [hl], 99 - sub 99 + ld [hl], MAX_ITEM_STACK + sub MAX_ITEM_STACK ld [wItemQuantity], a jr .loop2 @@ -721,3 +856,94 @@ GetItemPrice: pop bc pop hl ret + +Unreferenced_TossItem_Old: + push hl + call Unused_IsKeyItem_Old + ld a, [wItemAttributeValue] + and a + jr nz, .cant_toss + + ld a, [wCurItem] + ld [wNamedObjectIndexBuffer], a + call GetItemName + call CopyStringToStringBuffer2 + ld hl, .ItemsThrowAwayText + call MenuTextBox + call YesNoBox + call CloseWindow + jr c, .cancel + + ld a, [wItemIndex] + pop hl + call TossItem + ld a, [wCurItem] + ld [wNamedObjectIndexBuffer], a + call GetItemName + call CopyStringToStringBuffer2 + ld hl, .ItemsDiscardedText + call MenuTextBox + call CloseWindow + + and a + ret + +.cant_toss + ld hl, .ItemsTooImportantText + call MenuTextBox + call CloseWindow +.cancel + pop hl + scf + ret + +.ItemsDiscardedText: + text_from_ram wStringBuffer1 + text "を" ; "Threw away" + line "すてました!" ; "(item?)!" + prompt + +.ItemsThrowAwayText: + text_from_ram wStringBuffer2 + text "を すてます" ; "Are you sure you want" + line "ほんとに よろしいですか?" ; "to throw (item?) away?" + prompt + +.ItemsTooImportantText: + text "それは とても たいせつなモノです" ; "You can't throw away" + line "すてることは できません!" ; "something that special!" + prompt + +Unused_IsKeyItem_Old: + push hl + push bc + ld a, 1 + ld [wItemAttributeValue], a + ld a, [wCurItem] + cp ITEM_HM01_RED + jr nc, .check_if_hm + ld hl, ItemAttributes + ITEMATTR_PERMISSIONS + dec a + ld c, a + ld b, 0 +rept 5 + add hl, bc +endr + ld a, BANK(ItemAttributes) + call GetFarByte + bit 0, a + jr nz, .cant_toss + jr .can_toss + +.check_if_hm + ld a, [wCurItem] + call IsHM + jr c, .cant_toss + +.can_toss + xor a + ld [wItemAttributeValue], a +.cant_toss + pop bc + pop hl + ret diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index 1586c64..50621c4 100755 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -2,6 +2,2370 @@ INCLUDE "constants.asm" SECTION "engine/items/item_effects.asm", ROMX +_DoItemEffect:: + ld a, [wCurItem] + ld [wNamedObjectIndexBuffer], a + call GetItemName + call CopyStringToStringBuffer2 + ld a, 1 + ld [wItemEffectSucceeded], a + ld a, [wCurItem] + cp ITEM_TM01 + jp nc, AskTeachTMHM_Old + ld hl, ItemEffects + dec a + ld c, a + ld b, 0 + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +ItemEffects: +; entries correspond to item ids (see constants/item_constants.asm) + dw PokeBallEffect ; ITEM_MASTER_BALL + dw PokeBallEffect ; ITEM_ULTRA_BALL + dw NoEffect ; ITEM_03 + dw PokeBallEffect ; ITEM_GREAT_BALL + dw PokeBallEffect ; ITEM_POKE_BALL + dw TownMapEffect ; ITEM_TOWN_MAP + dw BicycleEffect ; ITEM_BICYCLE + dw EvoStoneEffect ; ITEM_MOON_STONE + dw StatusHealingEffect ; ITEM_ANTIDOTE + dw StatusHealingEffect ; ITEM_BURN_HEAL + dw StatusHealingEffect ; ITEM_ICE_HEAL + dw StatusHealingEffect ; ITEM_AWAKENING + dw StatusHealingEffect ; ITEM_PARLYZ_HEAL + dw FullRestoreEffect ; ITEM_FULL_RESTORE + dw RestoreHPEffect ; ITEM_MAX_POTION + dw RestoreHPEffect ; ITEM_HYPER_POTION + dw RestoreHPEffect ; ITEM_SUPER_POTION + dw RestoreHPEffect ; ITEM_POTION + dw EscapeRopeEffect ; ITEM_ESCAPE_ROPE + dw RepelEffect ; ITEM_REPEL + dw RestorePPEffect ; ITEM_MAX_ELIXER + dw EvoStoneEffect ; ITEM_FIRE_STONE + dw EvoStoneEffect ; ITEM_THUNDERSTONE + dw EvoStoneEffect ; ITEM_WATER_STONE + dw NoEffect ; ITEM_19 + dw VitaminEffect ; ITEM_HP_UP + dw VitaminEffect ; ITEM_PROTEIN + dw VitaminEffect ; ITEM_IRON + dw VitaminEffect ; ITEM_CARBOS + dw NoEffect ; ITEM_1E + dw VitaminEffect ; ITEM_CALCIUM + dw RareCandyEffect ; ITEM_RARE_CANDY + dw XAccuracyEffect ; ITEM_X_ACCURACY + dw EvoStoneEffect ; ITEM_LEAF_STONE + dw NoEffect ; ITEM_23 + dw Stub_NuggetEffect ; ITEM_NUGGET + dw PokeDollEffect ; ITEM_POKE_DOLL + dw StatusHealingEffect ; ITEM_FULL_HEAL + dw ReviveEffect ; ITEM_REVIVE + dw ReviveEffect ; ITEM_MAX_REVIVE + dw GuardSpecEffect ; ITEM_GUARD_SPEC + dw SuperRepelEffect ; ITEM_SUPER_REPEL + dw MaxRepelEffect ; ITEM_MAX_REPEL + dw DireHitEffect ; ITEM_DIRE_HIT + dw NoEffect ; ITEM_2D + dw RestoreHPEffect ; ITEM_FRESH_WATER + dw RestoreHPEffect ; ITEM_SODA_POP + dw RestoreHPEffect ; ITEM_LEMONADE + dw XItemEffect ; ITEM_X_ATTACK + dw NoEffect ; ITEM_32 + dw XItemEffect ; ITEM_X_DEFENSE + dw XItemEffect ; ITEM_X_SPEED + dw XItemEffect ; ITEM_X_SPECIAL + dw CoinCaseEffect ; ITEM_COIN_CASE + dw PPUpEffect ; ITEM_ITEMFINDER + dw PokeFluteEffect ; ITEM_POKE_FLUTE + dw NoEffect ; ITEM_EXP_SHARE + dw OldRodEffect_Old ; ITEM_OLD_ROD + dw GoodRodEffect_Old ; ITEM_GOOD_ROD + dw NoEffect ; ITEM_3C + dw SuperRodEffect_Old ; ITEM_SUPER_ROD + dw PPUpEffect ; ITEM_PP_UP + dw RestorePPEffect ; ITEM_ETHER + dw RestorePPEffect ; ITEM_MAX_ETHER + dw RestorePPEffect ; ITEM_ELIXER + dw Dummy_NewItemEffect ; ITEM_MYSTIC_PETAL + dw Dummy_NewItemEffect ; ITEM_WHITE_FEATHER + dw Dummy_NewItemEffect ; ITEM_CONFUSE_CLAW + dw Dummy_NewItemEffect ; ITEM_WISDOM_ORB + dw Dummy_NewItemEffect ; ITEM_STEEL_SHELL + dw Dummy_NewItemEffect ; ITEM_UP_GRADE + dw Dummy_NewItemEffect ; ITEM_STRANGE_THREAD + dw Dummy_NewItemEffect ; ITEM_BIG_LEAF + dw Dummy_NewItemEffect ; ITEM_QUICK_NEEDLE + dw Dummy_NewItemEffect ; ITEM_4B + dw Dummy_NewItemEffect ; ITEM_SHARP_STONE + dw Dummy_NewItemEffect ; ITEM_BLACK_FEATHER + dw Dummy_NewItemEffect ; ITEM_SHARP_FANG + dw Dummy_NewItemEffect ; ITEM_SNAKESKIN + dw Dummy_NewItemEffect ; ITEM_ELECTRIC_POUCH + dw Dummy_NewItemEffect ; ITEM_TOXIC_NEEDLE + dw Dummy_NewItemEffect ; ITEM_KINGS_ROCK + dw Dummy_NewItemEffect ; ITEM_STRANGE_POWER + dw Dummy_NewItemEffect ; ITEM_LIFE_TAG + dw Dummy_NewItemEffect ; ITEM_POISON_FANG + dw Dummy_NewItemEffect ; ITEM_CORDYCEPS + dw Dummy_NewItemEffect ; ITEM_DRAGON_FANG + dw Dummy_NewItemEffect ; ITEM_SILVERPOWDER + dw Dummy_NewItemEffect ; ITEM_DIGGING_CLAW + dw Dummy_NewItemEffect ; ITEM_5A + dw Dummy_NewItemEffect ; ITEM_AMULET_COIN + dw Dummy_NewItemEffect ; ITEM_MIGRAINE_SEED + dw Dummy_NewItemEffect ; ITEM_COUNTER_CUFF + dw Dummy_NewItemEffect ; ITEM_TALISMAN_TAG + dw Dummy_NewItemEffect ; ITEM_STRANGE_WATER + dw Dummy_NewItemEffect ; ITEM_TWISTEDSPOON + dw Dummy_NewItemEffect ; ITEM_ATTACK_NEEDLE + dw Dummy_NewItemEffect ; ITEM_POWER_BRACER + dw Dummy_NewItemEffect ; ITEM_HARD_STONE + dw Dummy_NewItemEffect ; ITEM_64 + dw Dummy_NewItemEffect ; ITEM_JIGGLING_BALLOON + dw Dummy_NewItemEffect ; ITEM_FIRE_MANE + dw Dummy_NewItemEffect ; ITEM_SLOWPOKETAIL + dw Dummy_NewItemEffect ; ITEM_EARTH + dw Dummy_NewItemEffect ; ITEM_STICK + dw Dummy_NewItemEffect ; ITEM_FLEE_FEATHER + dw Dummy_NewItemEffect ; ITEM_ICE_FANG + dw Dummy_NewItemEffect ; ITEM_FOSSIL_SHARD + dw Dummy_NewItemEffect ; ITEM_GROSS_GARBAGE + dw Dummy_NewItemEffect ; ITEM_BIG_PEARL + dw Dummy_NewItemEffect ; ITEM_CHAMPION_BELT + dw Dummy_NewItemEffect ; ITEM_TAG + dw Dummy_NewItemEffect ; ITEM_SPELL_TAG + dw Dummy_NewItemEffect ; ITEM_5_YEN_COIN + dw Dummy_NewItemEffect ; ITEM_GUARD_THREAD + dw Dummy_NewItemEffect ; ITEM_STIMULUS_ORB + dw Dummy_NewItemEffect ; ITEM_CALM_BERRY + dw Dummy_NewItemEffect ; ITEM_THICK_CLUB + dw Dummy_NewItemEffect ; ITEM_FOCUS_ORB + dw Dummy_NewItemEffect ; ITEM_78 + dw Dummy_NewItemEffect ; ITEM_DETECT_ORB + dw Dummy_NewItemEffect ; ITEM_LONG_TONGUE + dw Dummy_NewItemEffect ; ITEM_LOTTO_TICKET + dw Dummy_NewItemEffect ; ITEM_EVERSTONE + dw Dummy_NewItemEffect ; ITEM_SHARP_HORN + dw Dummy_NewItemEffect ; ITEM_LUCKY_EGG + dw Dummy_NewItemEffect ; ITEM_LONG_VINE + dw Dummy_NewItemEffect ; ITEM_MOMS_LOVE + dw Dummy_NewItemEffect ; ITEM_SMOKESCREEN + dw Dummy_NewItemEffect ; ITEM_WET_HORN + dw Dummy_NewItemEffect ; ITEM_SKATEBOARD + dw Dummy_NewItemEffect ; ITEM_CRIMSON_JEWEL + dw Dummy_NewItemEffect ; ITEM_INVISIBLE_WALL + dw Dummy_NewItemEffect ; ITEM_SHARP_SCYTHE + dw Dummy_NewItemEffect ; ITEM_87 + dw Dummy_NewItemEffect ; ITEM_ICE_BIKINI + dw Dummy_NewItemEffect ; ITEM_THUNDER_FANG + dw Dummy_NewItemEffect ; ITEM_FIRE_CLAW + dw Dummy_NewItemEffect ; ITEM_TWIN_HORNS + dw Dummy_NewItemEffect ; ITEM_SPIKE + dw Dummy_NewItemEffect ; ITEM_BERRY + dw Dummy_NewItemEffect ; ITEM_APPLE + dw Dummy_NewItemEffect ; ITEM_METAL_COAT + dw Dummy_NewItemEffect ; ITEM_PRETTY_TAIL + dw Dummy_NewItemEffect ; ITEM_WATER_TAIL + dw Dummy_NewItemEffect ; ITEM_LEFTOVERS + dw Dummy_NewItemEffect ; ITEM_ICE_WING + dw Dummy_NewItemEffect ; ITEM_THUNDER_WING + dw Dummy_NewItemEffect ; ITEM_FIRE_WING + dw Dummy_NewItemEffect ; ITEM_96 + dw Dummy_NewItemEffect ; ITEM_DRAGON_SCALE + dw Dummy_NewItemEffect ; ITEM_BERSERK_GENE + dw Dummy_NewItemEffect ; ITEM_HEART_STONE + dw Dummy_NewItemEffect ; ITEM_FIRE_TAIL + dw Dummy_NewItemEffect ; ITEM_THUNDER_TAIL + dw Dummy_NewItemEffect ; ITEM_SACRED_ASH + dw TMHolderEffect ; ITEM_TM_HOLDER + dw Stub_MailEffect ; ITEM_MAIL + dw Dummy_NewItemEffect ; ITEM_BALL_HOLDER + dw Dummy_NewItemEffect ; ITEM_BAG + dw Dummy_NewItemEffect ; ITEM_IMPORTANT_BAG + dw Dummy_NewItemEffect ; ITEM_POISON_STONE + dw Dummy_NewItemEffect ; ITEM_A3 + dw Dummy_NewItemEffect ; ITEM_A4 + dw Dummy_NewItemEffect ; ITEM_A5 + dw Dummy_NewItemEffect ; ITEM_A6 + dw Dummy_NewItemEffect ; ITEM_A7 + dw Dummy_NewItemEffect ; ITEM_A8 + dw Dummy_NewItemEffect ; ITEM_A9 + dw Dummy_NewItemEffect ; ITEM_AA +; ITEM_AB through ITEM_C3 have no entries. + +PokeBallEffect: + ld a, [wBattleMode] + and a + jp z, IsntTheTimeMessage + dec a + jp nz, UseBallInTrainerBattle + + ld a, [wPartyCount] + cp PARTY_LENGTH + jr nz, .room_in_party + + ld a, [wBoxCount] + cp MONS_PER_BOX + jp z, Ball_BoxIsFullMessage + +.room_in_party + xor a + ld [wWildMon], a + call ReturnToBattle_UseBall + + ld hl, ItemUsedText + call PrintText + + ld a, [wEnemyMonCatchRate] + ld b, a + ld a, [wCurItem] + cp ITEM_MASTER_BALL + jp z, .catch_without_fail + + cp ITEM_ULTRA_BALL + jr z, .ultra_ball_modifier + + cp ITEM_GREAT_BALL + jr z, .great_ball_modifier + + ; POKE_BALL + jr .regular_ball + +; 1.5x modifier +.great_ball_modifier + ld a, b + srl a + add b + ld b, a + jr nc, .regular_ball + ld b, $ff + jr .regular_ball + +; 2.0x modifier +.ultra_ball_modifier + sla b + jr nc, .regular_ball + ld b, $ff + +.regular_ball + ld a, b + ldh [hMultiplicand + 2], a + + ld hl, wEnemyMonHP + ld b, [hl] + inc hl + ld c, [hl] + inc hl + ld d, [hl] + inc hl + ld e, [hl] + sla c + rl b + + ld h, d + ld l, e + add hl, de + add hl, de + ld d, h + ld e, l + ld a, d + and a + jr z, .okay_1 + + srl d + rr e + srl d + rr e + srl b + rr c + srl b + rr c + + ld a, c + and a + jr nz, .okay_1 + ld c, 1 +.okay_1 + ld b, e + + push bc + ld a, b + sub c + ldh [hMultiplier], a + xor a + ldh [hDividend + 0], a + ldh [hMultiplicand + 0], a + ldh [hMultiplicand + 1], a + call Multiply + pop bc + + ld a, b + ldh [hDivisor], a + ld b, 4 + call Divide + + ldh a, [hQuotient + 3] + and a + jr nz, .statuscheck + ld a, 1 +.statuscheck +; This routine is buggy, even in the final game. +; It was intended that SLP and FRZ provide a higher catch rate than BRN/PSN/PAR, +; which in turn provide a higher catch rate than no status effect at all. +; But instead, it makes BRN/PSN/PAR provide no benefit. +; Uncomment the line below to fix this. + ld b, a + ld a, [wEnemyMonStatus] + and 1 << FRZ | SLP + ld c, 10 + jr nz, .addstatus + ; ld a, [wEnemyMonStatus] + and a + ld c, 5 + jr nz, .addstatus + ld c, 0 +.addstatus + ld a, b + add c + jr nc, .max_1 + ld a, $ff +.max_1 + ; BUG: farcall overwrites a, and GetItemHeldEffect takes b anyway. + ; This might be the reason the HELD_CATCH_CHANCE effect goes unused in the final game. + ; Uncomment the line below to fix. + ld d, a + push de + ld a, [wBattleMonItem] + ; ld b, a + callfar GetItemHeldEffect + ld a, b + cp HELD_CATCH_CHANCE + pop de + ld a, d + jr nz, .max_2 + add c + jr nc, .max_2 + ld a, $ff +.max_2 + ld b, a + ld [wFieldMoveScriptID], a + call Random + + cp b + ld a, 0 + jr z, .catch_without_fail + jr nc, .fail_to_catch + +.catch_without_fail + ld a, [wEnemyMonSpecies] + +.fail_to_catch + ld [wWildMon], a + ld c, 20 + call DelayFrames + + ld a, [wCurItem] + ld [wBattleAnimParam], a + + ld de, ANIM_THROW_POKE_BALL + ld a, e + ld [wFXAnimID], a + ld a, d + ld [wFXAnimID + 1], a + xor a + ldh [hBattleTurn], a + ld [wThrownBallWobbleCount], a + ld [wNumHits], a + predef PlayBattleAnim + + ld a, [wWildMon] + and a + jr nz, .caught + ld a, [wThrownBallWobbleCount] + cp 1 + ld hl, BallBrokeFreeText + jp z, .shake_and_break_free + cp 2 + ld hl, BallAppearedCaughtText + jp z, .shake_and_break_free + cp 3 + ld hl, BallAlmostHadItText + jp z, .shake_and_break_free + cp 4 + ld hl, BallSoCloseText + jp z, .shake_and_break_free + +.caught + ld hl, wEnemyMonHP + ld a, [hli] + push af + ld a, [hli] + push af + inc hl + ld a, [hl] + + push af + push hl + ld hl, wEnemyMonItem + ld a, [hl] + push af + push hl + +; BUG: If a Pokémon is caught while transformed, it is assumed to be a Ditto, +; even if it used Transform via Mirror Move/Mimic or is Mew. + ld hl, wEnemySubStatus5 + bit SUBSTATUS_TRANSFORMED, [hl] + jr z, .not_ditto + + ld a, DEX_DITTO + ld [wTempEnemyMonSpecies], a +; This doesn't seem right... aren't transformed Pokémon the only ones that use backup DVs anyway? + jr .load_data + +.not_ditto + set SUBSTATUS_TRANSFORMED, [hl] + ld hl, wEnemyBackupDVs + ld a, [wEnemyMonDVs] + ld [hli], a + ld a, [wEnemyMonDVs + 1] + ld [hl], a + +.load_data + ld a, [wTempEnemyMonSpecies] + ld [wCurPartySpecies], a + ld a, [wEnemyMonLevel] + ld [wCurPartyLevel], a + callfar LoadEnemyMon + + pop hl + pop af + ld [hl], a + pop hl + pop af + ld [hld], a + dec hl + pop af + ld [hld], a + pop af + ld [hl], a + + ld a, [wEnemyMonSpecies] + ld [wWildMon], a + ld [wCurPartySpecies], a + ld [wTempSpecies], a + ld a, [wBattleType] + dec a ; BATTLETYPE_TUTORIAL? + jp z, .FinishTutorial + + ld hl, Text_GotchaMonWasCaught + call PrintText + + call ClearSprites + + ld a, [wTempSpecies] + dec a + ld c, a + ld d, 0 + ld hl, wPokedexCaught + ld b, CHECK_FLAG + predef SmallFarFlagAction + + ld a, c + push af + ld a, [wTempSpecies] + dec a + ld c, a + ld b, SET_FLAG + predef SmallFarFlagAction + +; Notably doesn't skip the Pokédex if you actually don't have the Pokédex yet, unlike in GivePoke. +; Not a big deal, since you shouldn't have Poké Balls yet anyway. + pop af + and a + jr nz, .skip_pokedex + + ld hl, NewDexDataText_CaughtMon + call PrintText + + call ClearSprites + + ld a, [wEnemyMonSpecies] + ld [wTempSpecies], a + predef NewPokedexEntry + +.skip_pokedex + ld a, [wPartyCount] + cp PARTY_LENGTH + jr z, .SendToPC + + xor a ; PARTYMON + ld [wMonType], a + call ClearSprites + + predef TryAddMonToParty + + ld hl, AskGiveNicknameText_CaughtMon + call PrintText + call YesNoBox + jr c, .return_from_capture + + ld a, [wPartyCount] + dec a + ld hl, wPartyMonNicknames + ld bc, MON_NAME_LENGTH + call AddNTimes + + ld d, h + ld e, l + ld b, NAME_MON + ld a, BANK(NamingScreen) + ld hl, NamingScreen + push de + call FarCall_hl + + call GBFadeOutToWhite + + pop de + ld a, [de] + cp "@" ; Did we just leave the name empty? + jr nz, .return_from_capture + ld hl, wStringBuffer1 + ld bc, MON_NAME_LENGTH + call CopyBytes + jr .return_from_capture + +.SendToPC + call ClearSprites + + predef SendMonIntoBox + + ld hl, AskGiveNicknameText_CaughtMon + call PrintText + call YesNoBox + jr c, .done_with_nickname_pc + + ld de, wBoxMonNicknames + ld b, NAME_MON + farcall NamingScreen + + call GBFadeOutToWhite + ld de, wBoxMonNicknames + ld a, [de] + cp "@" + jr nz, .done_with_nickname_pc + + ld hl, wStringBuffer1 + ld bc, MON_NAME_LENGTH + call CopyBytes + +.done_with_nickname_pc +; BUG: Clearly there was supposed to be some kind of event flag check, but no flag address is actually loaded. +; 'a' is still the last byte copied in CopyBytes, which is most likely $50 (string terminator), which does not have bit 0 set. + ld hl, BallSentToBillsPCText + bit 0, a + jr nz, .met_bill + ld hl, BallSentToSomeonesPCText +.met_bill + call PrintText + jr .return_from_capture + +.FinishTutorial: + ld hl, Text_GotchaMonWasCaught + +.shake_and_break_free + call PrintText + call ClearSprites + +.return_from_capture + ld a, [wBattleType] + and a + ret nz + ld hl, wItems + inc a + ld [wItemQuantity], a + jp TossItem + +Unreferenced_BallDodgedText: + text "よけられた!" ; "It dodged the thrown BALL!" + line "こいつは つかまりそうにないぞ!" ; "This MON can't be caught!" + prompt + +Unreferenced_BallMissedText: + text "#に" ; "You missed the" + line "うまく あたらなかった!" ; "(MON)!" + prompt + +BallBrokeFreeText: + text "だめだ! #が" ; "Oh no! The (MON)" + line "ボールから でてしまった!" ; "broke free!" + prompt + +BallAppearedCaughtText: + text "ああ!" ; "Aww! It appeared" + line "つかまえたと おもったのに!" ; "to be caught!" + prompt + +BallAlmostHadItText: + text "ざんねん!" ; "Aargh!" + line "もうすこしで つかまえられたのに!" ; "Almost had it!" + prompt + +BallSoCloseText: + text "おしい!" ; "Shoot! It was so" + line "あと ちょっとの ところだったのに!" ; "close too!" + prompt + +Text_GotchaMonWasCaught: + text "やったー!" ; "Gotcha!" + line "@" + text_from_ram wEnemyMonNickname + text "を つかまえたぞ!@" ; "(MON) was caught!" + sound_caught_mon + text_waitbutton + text_end + +BallSentToBillsPCText: + text_from_ram wBoxMonNicknames + text "は マサキの ところへ" ; "was transferred to" + line "てんそうされた!" ; "BILL's PC!" + prompt + +BallSentToSomeonesPCText: + text_from_ram wBoxMonNicknames + text "は だれかの に" ; "was transferred to" + line "てんそうされた!" ; "Someone's PC!" + prompt + +NewDexDataText_CaughtMon: + text_from_ram wEnemyMonNickname + text "の データが あたらしく" ; "New Dex data will" + line "#ずかんに セーブされます!@" ; "be added for (MON)!" + sound_slot_machine_start + text_waitbutton + text_end + +AskGiveNicknameText_CaughtMon: + text "つかまえた @" + text_from_ram wStringBuffer1 + text "に" + line "なまえを つけますか" + done + +ReturnToBattle_UseBall: + call ClearPalettes + callfar Call_LoadBattleFontsHPBar + call GetMemSGBLayout + call CloseWindow + call LoadStandardMenuHeader + call WaitBGMap + call SetPalettes + ret + +TownMapEffect: + ld a, [wBattleMode] + and a + jp nz, IsntTheTimeMessage + farjp TownMap + +BicycleEffect: + xor a + ld [wItemEffectSucceeded], a + call .CheckEnvironment + ret c + ldh a, [hROMBank] + ld hl, .UseBike + call QueueScript + ld a, 1 + ld [wItemEffectSucceeded], a + ret + +.CheckEnvironment: + call GetMapEnvironment + cp TOWN + jr z, .ok + cp ROUTE + jr z, .ok + cp CAVE + jr z, .ok + jr .nope + +.ok +; POSSIBLE BUG: Can't get onto the Bike while on the Skateboard. + ld a, [wPlayerState] + and a + ret z + cp PLAYER_BIKE + ret z + +.nope + scf + ret + +.UseBike: + call RefreshScreen + ld a, [wPlayerState] + cp PLAYER_BIKE + jr z, .get_off_bike + ld a, PLAYER_BIKE + ld [wPlayerState], a + ld hl, ItemGotOnText + jr .done + +.get_off_bike + xor a + ld [wPlayerState], a + ld hl, ItemGotOffText +.done + call MenuTextBox + call CloseWindow + call RedrawPlayerSprite + call PlayMapMusic + call ScreenCleanup + ret + +EvoStoneEffect: + ld a, [wBattleMode] + and a + jp nz, IsntTheTimeMessage + + ld a, PARTYMENUACTION_EVO_STONE + call UseItem_SelectMon + + jr c, .DecidedNotToUse + + ld a, TRUE + ld [wForceEvolution], a + push de + ld de, SFX_FULL_HEAL + call WaitPlaySFX + call WaitSFX + pop de + callfar EvolvePokemon + + ld a, [wMonTriedToEvolve] + and a + jr z, .NoEffect + jp UseDisposableItem + +.NoEffect: + call WontHaveAnyEffectMessage + +.DecidedNotToUse + xor a + ld [wItemEffectSucceeded], a + ret + +VitaminEffect: + ld a, [wBattleMode] + and a + jp nz, IsntTheTimeMessage + + ld a, PARTYMENUACTION_HEALING_ITEM + call UseItem_SelectMon + jp c, RareCandy_StatBooster_ExitMenu + + ld a, MON_SPECIES + call GetPartyParamLocation + push hl + ld a, [wCurPartySpecies] + ld [wCurSpecies], a + ld [wTempSpecies], a + + ld bc, MON_LEVEL + add hl, bc + ld a, [hl] + ld [wCurPartyLevel], a + + call GetBaseData + ld a, [wCurPartyMon] + ld hl, wPartyMonNicknames + call GetNick + + call GetStatExpRelativePointer + + pop hl + push hl + add hl, bc + ld bc, MON_STAT_EXP + add hl, bc + ld a, [hl] + cp 100 + jr nc, NoEffectMessage + + add 10 + ld [hl], a + pop hl + call UpdateStatsAfterItem + + call GetStatExpRelativePointer + + ld hl, StatStrings + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ld de, wStringBuffer2 + ld bc, STRING_BUFFER_LENGTH + call CopyBytes + + ld de, SFX_FULL_HEAL + call WaitPlaySFX + ld hl, ItemStatRoseText + call PrintText + jp UseDisposableItem + +NoEffectMessage: + pop hl + ld hl, ItemWontHaveEffectText + call PrintText + jp ClearPalettes + +UpdateStatsAfterItem: + push hl + ld bc, MON_MAXHP + add hl, bc + ld d, h + ld e, l + pop hl + ld bc, MON_STAT_EXP - 1 + add hl, bc + ld b, TRUE + predef_jump CalcMonStats + +RareCandy_StatBooster_ExitMenu: + xor a + ld [wItemEffectSucceeded], a + call ClearPalettes + call z, GetMemSGBLayout + jp ReloadFontAndTileset + +ItemStatRoseText: + text_from_ram wStringBuffer1 ; "(MON)'s" + text "の @" + text_from_ram wStringBuffer2 ; "(STAT) rose." + text "の" + line "きそ ポイントが あがった!" + prompt + +ItemWontHaveEffectText: + text "つかっても こうかが ないよ" ; "It won't have any effect." + prompt + +StatStrings: + dw .health + dw .attack + dw .defense + dw .speed + dw .special + +.health: db "たいりょく@" ; "HEALTH" +.attack: db "こうげきりょく@" ; "ATTACK" +.defense: db "ぼうぎょりょく@" ; "DEFENSE" +.speed: db "すばやさ@" ; "SPEED" +.special: db "とくしゅのうりょく@" ; "SPECIAL" + +GetStatExpRelativePointer: + ld a, [wCurItem] + ld hl, StatExpItemPointerOffsets +.next + cp [hl] + inc hl + jr z, .got_it + inc hl + jr .next + +.got_it + ld a, [hl] + ld c, a + ld b, 0 + ret + +StatExpItemPointerOffsets: + db ITEM_HP_UP, MON_HP_EXP - MON_STAT_EXP + db ITEM_PROTEIN, MON_ATK_EXP - MON_STAT_EXP + db ITEM_IRON, MON_DEF_EXP - MON_STAT_EXP + db ITEM_CARBOS, MON_SPD_EXP - MON_STAT_EXP + db ITEM_CALCIUM, MON_SPC_EXP - MON_STAT_EXP + +RareCandyEffect: + ld a, [wBattleMode] + and a + jp nz, IsntTheTimeMessage + + ld a, PARTYMENUACTION_HEALING_ITEM + call UseItem_SelectMon + jp c, RareCandy_StatBooster_ExitMenu + + ld a, MON_SPECIES + call GetPartyParamLocation + ld a, [wCurPartySpecies] + ld [wCurSpecies], a + ld [wTempSpecies], a + push hl + + ld bc, MON_LEVEL + add hl, bc + ld a, [hl] + ld [wCurPartyLevel], a + call GetBaseData + ld a, [wCurPartyMon] + ld hl, wPartyMonNicknames + call GetNick + pop hl + + push hl + ld bc, MON_LEVEL + add hl, bc + ld a, [hl] + cp MAX_LEVEL + jp nc, NoEffectMessage + + inc a + ld [hl], a + ld [wCurPartyLevel], a + push de + ld d, a + callfar CalcExpAtLevel + pop de + pop hl + + push hl + ld bc, MON_EXP + add hl, bc + ldh a, [hProduct + 1] + ld [hli], a + ldh a, [hProduct + 2] + ld [hli], a + ldh a, [hProduct + 3] + ld [hl], a + pop hl + + push hl + ld bc, MON_MAXHP + add hl, bc + ld a, [hli] + ld b, a + ld c, [hl] + pop hl + push bc + push hl + call UpdateStatsAfterItem + + pop hl + ld bc, MON_MAXHP + 1 + add hl, bc + pop bc + ld a, [hld] + sub c + ld c, a + ld a, [hl] + sbc b + ld b, a + dec hl + ld a, [hl] + add c + ld [hld], a + ld a, [hl] + adc b + ld [hl], a + + ld a, PARTYMENUTEXT_LEVEL_UP + ld [wPartyMenuActionText], a + callfar WritePartyMenuTilemapAndText + + xor a + ld [wMonType], a + predef CopyMonToTempMon + + ld d, 1 + callfar PrintTempMonStats + call TextboxWaitPressAorB_BlinkCursor + + xor a + ld [wMonType], a + ld a, [wCurPartySpecies] + ld [wTempSpecies], a + predef LearnLevelMoves + + xor a + ld [wForceEvolution], a + callfar EvolvePokemon + jp UseDisposableItem + +StatusHealingEffect: + ld a, [wPartyCount] + and a + jp z, IsntTheTimeMessage + + ld a, PARTYMENUACTION_HEALING_ITEM + call UseItem_SelectMon + jp c, StatusHealer_ExitMenu + ld a, [wCurPartySpecies] + ld [wCurSpecies], a + +HealStatus: + call GetItemHealingAction + ld a, MON_STATUS + call GetPartyParamLocation + ld a, [hl] + and c + jp z, StatusHealer_NoEffect + xor a + ld [hl], a + ld a, b + ld [wPartyMenuActionText], a + + call IsItemUsedOnBattleMon + jr nc, .not_in_battle + xor a + ld [wBattleMonStatus], a + ld hl, wPlayerSubStatus5 + res SUBSTATUS_TOXIC, [hl] + ld hl, wPlayerSubStatus1 + res SUBSTATUS_NIGHTMARE, [hl] + +; This whole section is leftover from an unused mechanic in Generation I, which is broken now + ld a, MON_MAXHP + call GetPartyParamLocation + ld de, wBattleMonMaxHP + ld bc, (NUM_STATS - 1) * 2 ; Doesn't include special defense + call CopyBytes + predef DoubleOrHalveSelectedStats_Old + +.not_in_battle + call UseDisposableItem + push de + ld de, SFX_FULL_HEAL + call WaitPlaySFX + pop de + call ItemActionTextWaitButton + jp StatusHealer_ClearPalettes + +GetItemHealingAction: + push hl + ld a, [wCurItem] + ld hl, StatusHealingActions + ld bc, 3 +.next + cp [hl] + jr z, .found_it + add hl, bc + jr .next + +.found_it + inc hl + ld b, [hl] + inc hl + ld c, [hl] + pop hl + ret + +StatusHealingActions: + ; item, party menu action text, status + db ITEM_ANTIDOTE, PARTYMENUTEXT_HEAL_PSN, 1 << PSN + db ITEM_BURN_HEAL, PARTYMENUTEXT_HEAL_BRN, 1 << BRN + db ITEM_ICE_HEAL, PARTYMENUTEXT_HEAL_FRZ, 1 << FRZ + db ITEM_AWAKENING, PARTYMENUTEXT_HEAL_SLP, SLP + db ITEM_PARLYZ_HEAL, PARTYMENUTEXT_HEAL_PAR, 1 << PAR + db ITEM_FULL_HEAL, PARTYMENUTEXT_HEAL_ALL, %11111111 + db -1, 0, 0 ; end + +ReviveEffect: + ld a, [wPartyCount] + and a + jp z, IsntTheTimeMessage + + ld a, PARTYMENUACTION_HEALING_ITEM + call UseItem_SelectMon + jp c, StatusHealer_ExitMenu + + call IsMonFainted + jp nz, StatusHealer_NoEffect + + ld a, [wBattleMode] + and a + jr z, .skip_to_revive + + ld a, [wCurPartyMon] + ld c, a + ld d, 0 + ld hl, wBattleParticipantsIncludingFainted + ld b, CHECK_FLAG + predef SmallFarFlagAction + ld a, c + and a + jr z, .skip_to_revive + + ld a, [wCurPartyMon] + ld c, a + ld hl, wBattleParticipantsNotFainted + ld b, SET_FLAG + predef SmallFarFlagAction + +.skip_to_revive + xor a + ld [wLowHealthAlarmBuffer], a + ld a, [wCurItem] + cp ITEM_REVIVE + jr z, .revive_half_hp + + call ReviveFullHP + jr .finish_revive + +.revive_half_hp + call ReviveHalfHP +.finish_revive + call HealHP_SFX_GFX + ld a, PARTYMENUTEXT_REVIVE + ld [wPartyMenuActionText], a + call ItemActionTextWaitButton + call UseDisposableItem + jp StatusHealer_ClearPalettes + +Unreferenced_EmptyFunctionefed: + ret + +FullRestoreEffect: + ld a, [wPartyCount] + and a + jp z, IsntTheTimeMessage + + ld a, PARTYMENUACTION_HEALING_ITEM + call UseItem_SelectMon + jp c, StatusHealer_ExitMenu + + call IsMonFainted + jp z, StatusHealer_NoEffect + + call IsMonAtFullHealth + jr c, .NotAtFullHealth + + ld a, MON_STATUS + call GetPartyParamLocation + ld a, [hl] + and a + jp z, StatusHealer_NoEffect + + ld a, ITEM_FULL_HEAL + ld [wCurItem], a + jp HealStatus + +.NotAtFullHealth + xor a + ld [wLowHealthAlarmBuffer], a + call ReviveFullHP + ld a, MON_STATUS + call GetPartyParamLocation + xor a + ld [hli], a + ld [hl], a + + call IsItemUsedOnBattleMon + jr nc, .not_in_battle + + ld hl, wPlayerSubStatus5 + res SUBSTATUS_TOXIC, [hl] + ld hl, wPlayerSubStatus1 + res SUBSTATUS_NIGHTMARE, [hl] + xor a + ld [wBattleMonStatus], a + + ld a, MON_HP + call GetPartyParamLocation + ld a, [hli] + ld [wBattleMonHP], a + ld a, [hld] + ld [wBattleMonHP + 1], a + +.not_in_battle + call HealHP_SFX_GFX + ld a, PARTYMENUTEXT_HEAL_HP + ld [wPartyMenuActionText], a + call ItemActionTextWaitButton + call UseDisposableItem + jp StatusHealer_ClearPalettes + +Unreferenced_EmptyFunctionf05a: + ret + +RestoreHPEffect: + ld a, [wPartyCount] + and a + jp z, IsntTheTimeMessage + + ld a, PARTYMENUACTION_HEALING_ITEM + call UseItem_SelectMon + jp c, StatusHealer_ExitMenu + + call IsMonFainted + jp z, StatusHealer_NoEffect + call IsMonAtFullHealth + jp nc, StatusHealer_NoEffect + + xor a + ld [wLowHealthAlarmBuffer], a + ld a, [wCurItem] + cp ITEM_MAX_POTION + jr nz, .get_heal_amount + call ReviveFullHP + jr .continue_heal + +.get_heal_amount + call GetHealingItemAmount + call RestoreHealth +.continue_heal + call IsItemUsedOnBattleMon + jr nc, .not_in_battle + + ld a, MON_HP + call GetPartyParamLocation + ld a, [hli] + ld [wBattleMonHP], a + ld a, [hld] + ld [wBattleMonHP + 1], a +.not_in_battle + call HealHP_SFX_GFX + ld a, PARTYMENUTEXT_HEAL_HP + ld [wPartyMenuActionText], a + call ItemActionTextWaitButton + call UseDisposableItem + jp StatusHealer_ClearPalettes + +Unreferenced_EmptyFunctionf0af: + ret + +HealHP_SFX_GFX: + push de + ld de, SFX_POTION + call WaitPlaySFX + pop de + ld a, [wCurPartyMon] + hlcoord 11, 0 + ld bc, SCREEN_WIDTH * 2 + call AddNTimes + ld a, $2 + ld [wWhichHPBar], a + predef UpdateHPBar + ret + +UseItem_SelectMon: + ld [wPartyMenuActionText], a + predef OpenPartyMenu_ClearGraphics + ret + +ItemActionTextWaitButton: + xor a + ldh [hBGMapMode], a + ld hl, wTileMap + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, " " + call ByteFill + callfar WritePartyMenuTilemapAndText + ld a, 1 + ldh [hBGMapMode], a + ld c, 50 + call DelayFrames + call TextboxWaitPressAorB_BlinkCursor + ret + +StatusHealer_NoEffect: + call WontHaveAnyEffectMessage + jr StatusHealer_ClearPalettes + +StatusHealer_ExitMenu: + xor a + ld [wFieldMoveSucceeded], a + +StatusHealer_ClearPalettes: + call ClearPalettes + call z, GetMemSGBLayout + ld a, [wBattleMode] + and a + ret nz + call ReloadFontAndTileset + ret + +IsItemUsedOnBattleMon: + ld a, [wBattleMode] + and a + ret z + ld a, [wCurPartyMon] + push hl + ld hl, wCurBattleMon + cp [hl] + pop hl + jr nz, .nope + scf + ret + +.nope + xor a + ret + +ReviveHalfHP: + call LoadHPFromBuffer1 + srl d + rr e + jr ContinueRevive + +ReviveFullHP: + call LoadHPFromBuffer1 +ContinueRevive: + ld a, MON_HP + call GetPartyParamLocation + ld [hl], d + inc hl + ld [hl], e + call LoadCurHPIntoBuffer3 + ret + +RestoreHealth: + ld a, MON_HP + 1 + call GetPartyParamLocation + ld a, [hl] + add e + ld [hld], a + ld a, [hl] + adc d + ld [hl], a + call LoadCurHPIntoBuffer3 + ld a, MON_HP + 1 + call GetPartyParamLocation + ld d, h + ld e, l + ld a, MON_MAXHP + 1 + call GetPartyParamLocation + ld a, [de] + sub [hl] + dec de + dec hl + ld a, [de] + sbc [hl] + jr c, .finish + call ReviveFullHP +.finish + ret + +IsMonFainted: + call LoadMaxHPIntoBuffer1 + call LoadCurHPIntoBuffer2 + call LoadHPFromBuffer2 + ld a, d + or e + ret + +IsMonAtFullHealth: + call LoadHPFromBuffer2 + ld h, d + ld l, e + call LoadHPFromBuffer1 + ld a, l + sub e + ld a, h + sbc d + ret + +LoadCurHPIntoBuffer3: + ld a, MON_HP + call GetPartyParamLocation + ld a, [hli] + ld [wHPBuffer3 + 1], a + ld a, [hl] + ld [wHPBuffer3], a + ret + +; Unreferenced +LoadHPIntoBuffer3: + ld a, d + ld [wHPBuffer3 + 1], a + ld a, e + ld [wHPBuffer3], a + ret + +; Unreferenced +LoadHPFromBuffer3: + ld a, [wHPBuffer3 + 1] + ld d, a + ld a, [wHPBuffer3] + ld e, a + ret + +LoadCurHPIntoBuffer2: + ld a, MON_HP + call GetPartyParamLocation + ld a, [hli] + ld [wHPBuffer2 + 1], a + ld a, [hl] + ld [wHPBuffer2], a + ret + +LoadHPFromBuffer2: + ld a, [wHPBuffer2 + 1] + ld d, a + ld a, [wHPBuffer2] + ld e, a + ret + +LoadMaxHPIntoBuffer1: + push hl + ld a, MON_MAXHP + call GetPartyParamLocation + ld a, [hli] + ld [wHPBuffer1 + 1], a + ld a, [hl] + ld [wHPBuffer1], a + pop hl + ret + +LoadHPFromBuffer1: + ld a, [wHPBuffer1 + 1] + ld d, a + ld a, [wHPBuffer1] + ld e, a + ret + +GetOneFifthMaxHP: + ld a, MON_MAXHP + call GetPartyParamLocation + ld a, [hli] + ldh [hDividend], a + ld a, [hl] + ldh [hDividend + 1], a + ld a, 5 + ldh [hDivisor], a + ld b, 2 + call Divide + ldh a, [hQuotient + 2] + ld d, a + ldh a, [hQuotient + 3] + ld e, a + ret + +GetHealingItemAmount: + push hl + ld a, [wCurItem] + ld hl, HealingHPAmounts + ld d, a +.next + ld a, [hli] + cp -1 + jr z, .NotFound + cp d + jr z, .done + inc hl + inc hl + jr .next + +.NotFound: + scf +.done + ld e, [hl] + inc hl + ld d, [hl] + pop hl + ret + +; INCLUDE IN: "data/items/heal_hp.inc" + +HealingHPAmounts: + dbw ITEM_FRESH_WATER, 50 + dbw ITEM_SODA_POP, 60 + dbw ITEM_LEMONADE, 80 + dbw ITEM_HYPER_POTION, 200 + dbw ITEM_SUPER_POTION, 50 + dbw ITEM_POTION, 20 + dbw -1, 0 ; end + +SoftboiledFunction: + ld a, [wPartyMenuCursor] + dec a + ld b, a +.loop + push bc + ld a, PARTYMENUACTION_HEALING_ITEM + ld [wPartyMenuActionText], a + predef OpenPartyMenu + pop bc + jr c, .skip + + ld a, [wPartyMenuCursor] + dec a + ld c, a + ld a, b + cp c + jr z, .loop + + push bc + ld a, c + ld [wCurPartyMon], a + call IsMonFainted + jr z, .fainted + call IsMonAtFullHealth + jp nc, .full_health + + pop bc + push bc + ld a, b + ld [wCurPartyMon], a + call IsMonFainted + call GetOneFifthMaxHP + push de + ld a, MON_HP + 1 + call GetPartyParamLocation + ld a, [hl] + sub e + ld [hld], a + ld e, a + ld a, [hl] + sbc d + ld [hl], a + ld d, a + call LoadHPIntoBuffer3 + call HealHP_SFX_GFX + pop de + pop bc + + push bc + push de + ld a, c + ld [wCurPartyMon], a + call IsMonFainted + pop de + call RestoreHealth + call HealHP_SFX_GFX + + xor a + ldh [hBGMapMode], a + call ClearTileMap + ld a, PARTYMENUTEXT_HEAL_HP + ld [wPartyMenuActionText], a + predef InitPartyMenuLayout + ld c, 200 + call PartyMenu_WaitForAorB + pop bc +.skip + ld a, b + inc a + ld [wPartyMenuCursor], a + ret + +.fainted + ld hl, .ItemCantUseOnMonText + call PartyMenu_TextboxBackup + pop bc + jp .loop + +; Looks like they might have been intended to have different messages at one point? +.full_health + ld hl, .ItemCantUseOnMonText + call PartyMenu_TextboxBackup + pop bc + jp .loop + +.ItemCantUseOnMonText: + text "その#には " + line "つかえません" + done + +EscapeRopeEffect: + xor a + ld [wItemEffectSucceeded], a + callfar DigFunction + ret + +SuperRepelEffect: + ld b, 200 + jp UseRepel + +MaxRepelEffect: + ld b, 250 + jp UseRepel + +RepelEffect: + ld b, 100 + +UseRepel: + ld a, [wBattleMode] + and a + jp nz, IsntTheTimeMessage + + ld a, b + ld [wRepelEffect], a + jp UseItemText + +XAccuracyEffect: + ld a, [wBattleMode] + and a + jp z, IsntTheTimeMessage + + ld hl, wPlayerSubStatus4 + set SUBSTATUS_X_ACCURACY, [hl] + jp UseItemText + +PokeDollEffect: + ld a, [wBattleMode] + dec a ; WILD_BATTLE? + jp nz, IsntTheTimeMessage + + ld a, LOSE + ld [wBattleResult], a + jp UseItemText + +GuardSpecEffect: + ld a, [wBattleMode] + and a + jp z, IsntTheTimeMessage + + ld hl, wPlayerSubStatus4 + set SUBSTATUS_MIST, [hl] + jp UseItemText + +DireHitEffect: + ld a, [wBattleMode] + and a + jp z, IsntTheTimeMessage + + ld hl, wPlayerSubStatus4 + set SUBSTATUS_FOCUS_ENERGY, [hl] + jp UseItemText + +XItemEffect: + ld a, [wBattleMode] + and a + jr nz, .in_battle + + call IsntTheTimeMessage + ld a, 2 + ld [wItemEffectSucceeded], a + ret + +.in_battle + ld hl, wPlayerMoveStructAnimation + ld a, [hli] + push af + ld a, [hl] + push af + push hl +; Uses old index from pokered... + ld a, [wCurItem] + sub ITEM_X_ATTACK_RED - EFFECT_ATTACK_UP + ld [hl], a + call UseItemText + ld a, $ae ; XSTATITEM_ANIM in pokered + ld [wPlayerMoveStructAnimation], a + call ReloadTilesFromBuffer + call WaitBGMap + xor a + ldh [hBattleTurn], a +; BUG: Wrong bank. Replace $f with BANK(BattleCommand_StatUp) to fix it. + ld a, $f + ld hl, BattleCommand_StatUp + call FarCall_hl + + pop hl + pop af + ld [hld], a + pop af + ld [hl], a + ret + +; Stubbed with a ret. The rest of the leftover code is intact below here though. +PokeFluteEffect: + ret + + xor a + ld [wPokeFluteCuredSleep], a + ld b, ~SLP + ld hl, wPartyMon1Status + call .CureSleep + + ld a, [wBattleMode] + cp WILD_BATTLE + jr z, .skip_otrainer + ld hl, wOTPartyMon1Status + call .CureSleep +.skip_otrainer + + ld hl, wBattleMonStatus + ld a, [hl] + and b + ld [hl], a + ld hl, wEnemyMonStatus + ld a, [hl] + and b + ld [hl], a + + ld a, [wPokeFluteCuredSleep] + and a + ld hl, .PlayedFluteText + jp z, PrintText + ld hl, .PlayedTheFlute + call PrintText + + ld a, [wLowHealthAlarmBuffer] + and 1 << DANGER_ON_F + jr nz, .dummy + ; more code was dummied out here +.dummy + ld hl, .FluteWakeUpText + jp PrintText + +.CureSleep: + ld de, PARTYMON_STRUCT_LENGTH + ld c, PARTY_LENGTH +.loop + ld a, [hl] + push af + and SLP + jr z, .not_asleep + ld a, TRUE + ld [wPokeFluteCuredSleep], a +.not_asleep + pop af + and b + ld [hl], a + add hl, de + dec c + jr nz, .loop + ret + +MACRO dbmapcoord + db \2, \1 +ENDM + +.Unreferenced_Route12SnorlaxFluteCoords: + dbmapcoord 9, 62 ; one space West of Snorlax + dbmapcoord 10, 61 ; one space North of Snorlax + dbmapcoord 10, 63 ; one space South of Snorlax + dbmapcoord 11, 62 ; one space East of Snorlax + db -1 ; end + +.Unreferenced_Route16SnorlaxFluteCoords: + dbmapcoord 27, 10 ; one space East of Snorlax + dbmapcoord 25, 10 ; one space West of Snorlax + db -1 ; end + +.PlayedFluteText: + text "#のふえを ふいた!" + para "うーん!" + line "すばらしい ねいろだ!" + prompt + +.FluteWakeUpText: + text "すべての #が" + line "めを さました!" + prompt + +.PlayedTheFlute: + text "は" + line "#のふえを ふいてみた!@" +; BUG: No text_asm. + ld b, 8 + ld a, [wBattleMode] + and a + jr nz, .battle + + push de + ld de, SFX_POKEFLUTE + call WaitPlaySFX + call WaitSFX + pop de + +.battle + jp GetTerminatingString + +CoinCaseEffect: + ld a, [wBattleMode] + and a + jp nz, IsntTheTimeMessage + + ld hl, CoinCaseCountText + call MenuTextBox + call CloseWindow + ret + +CoinCaseCountText: + text "あなたの コイン" + line "@" + deciram wCoins, 2, 4 + text "まい" + prompt + +; These rod effects haven't been touched since Generation I... like, at all. +; The only change was in FishingInit_Old to force the water check to always fail. +OldRodEffect_Old: + call FishingInit_Old + jp c, IsntTheTimeMessage + lb bc, 5, MON_MAGIKARP + ld a, $1 + jr RodResponse_Old + +GoodRodEffect_Old: + call FishingInit_Old + jp c, IsntTheTimeMessage +.random_loop + call Random + srl a + jr c, .set_bite + and %11 + cp $2 + jr nc, .random_loop + ld hl, .GoodRodMons + ld c, a + ld b, 0 + add hl, bc + add hl, bc + ld b, [hl] + inc hl + ld c, [hl] + and a +.set_bite + ld a, 0 + rla + xor 1 + jr RodResponse_Old + +; random choice of 2 good rod encounters +.GoodRodMons: + ; level, species + db 10, MON_GOLDEEN + db 10, MON_POLIWAG + +SuperRodEffect_Old: + call FishingInit_Old + jp c, IsntTheTimeMessage + call ReadSuperRodData_Old + ld a, e + +RodResponse_Old: + ld [wRodResponse_Old], a + + dec a + jr nz, .next + + ld a, 1 + ld [wAttackMissed], a + ld a, b + ld [wCurPartyLevel], a + ld a, c + ld [wTempWildMonSpecies], a + +.next + ld hl, wPlayerState + ld a, [hl] + push af + ld [hl], 0 + push hl + farcall FishingAnim_Old + pop hl + pop af + ld [hl], a + ret + +FishingInit_Old: + ld a, [wBattleMode] + and a + jr z, .not_in_battle + scf + ret + +.not_in_battle + call Stub_IsNextTileShoreOrWater_Old + ret c + ld a, [wPlayerState] + cp $2 ; PLAYER_SURF at one point + jr z, .surfing + call ItemUseReloadOverworldData_Old + ld hl, ItemUsedText + call PrintText + ld de, SFX_FULL_HEAL + call WaitPlaySFX + ld c, 80 + call DelayFrames + and a + ret + +.surfing + scf + ret + +PPUpEffect: + ld a, [wBattleMode] + and a + jp nz, IsntTheTimeMessage + +RestorePPEffect: + ld a, [wCurItem] + ld [wTempRestorePPItem], a + +.loop + ; Party Screen opens to choose on which mon to use the Item + ld a, PARTYMENUACTION_HEALING_ITEM + call UseItem_SelectMon + jr nc, .loop2 + jp PPRestoreItem_Cancel + +.loop2 + ld a, [wTempRestorePPItem] + cp ITEM_ELIXER_RED + jp nc, Elixer_RestorePPofAllMoves + ld a, 2 + ld [wMoveSelectionMenuType], a + ld hl, RaiseThePPOfWhichMoveText + ld a, [wTempRestorePPItem] + cp ITEM_ETHER_RED + jr c, .ppup + ld hl, RestoreThePPOfWhichMoveText + +.ppup + call PrintText + callfar MoveSelectionScreen + jr nz, .loop + + ld hl, wPartyMon1Moves + ld bc, PARTYMON_STRUCT_LENGTH + call GetMthMoveOfNthPartymon + push hl + ld a, [hl] + ld [wNamedObjectIndexBuffer], a + call GetMoveName + call CopyStringToStringBuffer2 + pop hl + + ld a, [wTempRestorePPItem] + cp ITEM_ETHER_RED + jr nc, Not_PP_Up + + ld bc, MON_PP - MON_MOVES + add hl, bc + ld a, [hl] + cp PP_UP_MASK + jr c, .do_ppup + + ld hl, PPIsMaxedOutText + call PrintText + jr .loop2 + +.do_ppup + ld a, [hl] + add PP_UP_ONE + ld [hl], a + ld a, TRUE + ld [wUsePPUp], a + call ApplyPPUp + ld hl, PPsIncreasedText + call PrintText + +FinishPPRestore: + call ClearPalettes + call GetMemSGBLayout + jp UseDisposableItem + +BattleRestorePP: + ld a, [wBattleMode] + and a + jr z, .not_in_battle + + ld a, [wCurPartyMon] + ld b, a + ld a, [wCurBattleMon] + cp b + jr nz, .not_in_battle + + ld hl, wPartyMon1PP + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + ld de, wBattleMonPP + ld bc, NUM_MOVES + call CopyBytes +.not_in_battle + ld de, SFX_FULL_HEAL + call WaitPlaySFX + ld hl, PPRestoredText + call PrintText + jr FinishPPRestore + +Not_PP_Up: + call RestorePP + jr nz, BattleRestorePP + jp PPRestoreItem_NoEffect + +RestorePP: + xor a ; PARTYMON + ld [wMonType], a + call GetMaxPPOfMove + ld hl, wPartyMon1Moves + ld bc, PARTYMON_STRUCT_LENGTH + call GetMthMoveOfNthPartymon + + ld bc, MON_PP - MON_MOVES + add hl, bc + ld a, [wTempPP] + ld b, a + + ld a, [wTempRestorePPItem] + cp ITEM_MAX_ETHER_RED + jr z, .restore_all + + ld a, [hl] + and PP_MASK + cp b + ret z + + add 10 + cp b + jr nc, .restore_some + ld b, a + +.restore_some + ld a, [hl] + and PP_UP_MASK + add b + ld [hl], a + ret +.restore_all + ld a, [hl] + cp b + ret z + jr .restore_some + +Elixer_RestorePPofAllMoves: + ld hl, wTempRestorePPItem + dec [hl] + dec [hl] + + xor a + ld hl, wMenuCursorY + ld [hli], a + ld [hl], a + ld b, NUM_MOVES +.move_loop + push bc + ld hl, wPartyMon1Moves + ld bc, PARTYMON_STRUCT_LENGTH + call GetMthMoveOfNthPartymon + ld a, [hl] + and a + jr z, .next + + call RestorePP + jr z, .next + ld hl, wMenuCursorX + inc [hl] + +.next + ld hl, wMenuCursorY + inc [hl] + pop bc + dec b + jr nz, .move_loop + ld a, [wMenuCursorX] + and a + jp nz, BattleRestorePP + +PPRestoreItem_NoEffect: + call WontHaveAnyEffectMessage + +PPRestoreItem_Cancel: + call ClearPalettes + call GetMemSGBLayout + pop af + xor a + ld [wItemEffectSucceeded], a + ret + +RaiseThePPOfWhichMoveText: + text "どのわざの" + line "ポイントをふやす?" + done + +RestoreThePPOfWhichMoveText: + text "どのわざを" + line "かいふくする?" + done + +PPIsMaxedOutText: + text_from_ram wStringBuffer2 + text "は これいじょう" + line "ふやすことが できません" + prompt + +PPsIncreasedText: + text_from_ram wStringBuffer2 + text "の" + line "わざポイントが ふえた!" + prompt + +PPRestoredText: + text "わざポイントが" + line "かいふくした!" + prompt + +TMHolderEffect: + ld a, [wBattleMode] + and a + jp nz, IsntTheTimeMessage + jpfar _TMHolder + +Stub_NuggetEffect: + jp IsntTheTimeMessage + +NoEffect: + jp IsntTheTimeMessage + +Dummy_NewItemEffect: + jp IsntTheTimeMessage + +Unreferenced_EnterBreeder: + jp _Breeder + +AskTeachTMHM_Old: + ld a, [wBattleMode] + and a + jp nz, IsntTheTimeMessage + + ld a, [wCurItem] + sub ITEM_TM01_RED + push af + jr nc, .is_tm_or_hm + add NUM_TM_HM - 2 ; Generation I only had 5 HMs +.is_tm_or_hm + inc a + ld [wTempTMHM], a + predef GetTMHMMove + ld a, [wTempTMHM] + ld [wPutativeTMHMMove], a + call GetMoveName + call CopyStringToStringBuffer2 + pop af + ld hl, .BootedTMText + jr nc, .TM + ld hl, .BootedHMText +.TM + call PrintText + ld hl, .ContainedMoveText + call PrintText + call YesNoBox + jr nc, .ChooseMonToLearnTMHM + + ld a, 2 + ld [wItemEffectSucceeded], a + ret + +.ChooseMonToLearnTMHM: +.loopback + ld hl, wStringBuffer2 + ld de, wMonOrItemNameBuffer + ld bc, MOVE_NAME_LENGTH + call CopyBytes + + ld a, PARTYMENUACTION_TEACH_TMHM + call UseItem_SelectMon + push af + ld hl, wMonOrItemNameBuffer + ld de, wStringBuffer2 + ld bc, MOVE_NAME_LENGTH + call CopyBytes + pop af + jr nc, .TeachTMHM + + pop af + pop af + call ClearBGPalettes + call ClearSprites + call GetMemSGBLayout + jp ReloadTilesFromBuffer + +.TeachTMHM: + predef CanLearnTMHMMove + push bc + ld a, [wCurPartyMon] + ld hl, wPartyMonNicknames + call GetNick + pop bc + + ld a, c + and a + jr nz, .compatible + ld de, SFX_WRONG + call WaitPlaySFX + + ld hl, .TMHMNotCompatibleText + call PrintText + jr .loopback + +.compatible + call KnowsMove + jr c, .loopback + + predef LearnMove + ld a, b + and a + ret z + + ld a, [wCurItem] + call IsHM + ret c + + jp UseDisposableItem + +.BootedTMText: + text "を きどうした!" + prompt + +.BootedHMText: + text "ひでんマシンを きどうした!" + +.ContainedMoveText: + text "なかには @" + text_from_ram wStringBuffer2 + text "が" + line "きろくされていた!" + para "@" + text_from_ram wStringBuffer2 + text "を" + line "#に おぼえさせますか?" + done + +.TMHMNotCompatibleText: + text_from_ram wStringBuffer1 + text "と @" + text_from_ram wStringBuffer2 + text "は" + line "あいしょうが わるかった!" + para "@" + text_from_ram wStringBuffer2 + text "は おぼえられない!" + prompt + +UseItemText: + ld hl, ItemUsedText + call PrintText + ld de, SFX_FULL_HEAL + call WaitPlaySFX + call TextboxWaitPressAorB_BlinkCursor + +UseDisposableItem: + ld hl, wItems + ld a, 1 + ld [wItemQuantity], a + call TossItem + ret + +UseBallInTrainerBattle: + call ReturnToBattle_UseBall + ld de, ANIM_THROW_POKE_BALL + ld a, e + ld [wFXAnimID], a + ld a, d + ld [wFXAnimID + 1], a + xor a + ld [wBattleAnimParam], a + ldh [hBattleTurn], a + ld [wNumHits], a + predef PlayBattleAnim + ld hl, BallBlockedText + call PrintText + ld hl, BallDontBeAThiefText + call PrintText + jr UseDisposableItem + +Ball_BoxIsFullMessage: + ld hl, BallBoxFullText + jr CantUseItemMessage + +IsntTheTimeMessage: + ld hl, ItemOakWarningText + jr CantUseItemMessage + +WontHaveAnyEffectMessage: + ld hl, ItemWontHaveAnyEffectText + jr CantUseItemMessage + +; Unreferenced +BelongsToSomeoneElseMessage: + ld hl, ItemBelongsToSomeoneElseText + jr CantUseItemMessage + +; Unreferenced +CyclingIsntAllowedMessage: + ld hl, NoCyclingText + jr CantUseItemMessage + +; Unreferenced +CantGetOnYourBikeMessage: + ld hl, ItemCantGetOnText + +CantUseItemMessage: + xor a + ld [wItemEffectSucceeded], a + jp PrintText + +ItemOakWarningText: + text "オーキドの ことば<⋯⋯>" + line "よ! こういうものには" + cont "つかいどきが あるのじゃ!" + prompt + +ItemBelongsToSomeoneElseText: + text "たいせつな あずかりものです!" + next "つかうことは できません!" + prompt + +ItemWontHaveAnyEffectText: + text "つかっても こうかがないよ" + prompt + +BallBlockedText: + text "に ボールを はじかれた!" + prompt + +BallDontBeAThiefText: + text "ひとの ものを とったら どろぼう!" + prompt + +NoCyclingText: + text "ここでは じてんしゃに" + next "のることは できません" + prompt + +ItemCantGetOnText: + text "ここでは@" + text_from_ram wStringBuffer1 + text "に" + line "のることは できません" + prompt + +BallBoxFullText: + text "ボックスに あずけている #が" + line "いっぱいなので つかえません!" + prompt + +ItemUsedText: + text "は@" + text_low + text_from_ram wStringBuffer2 + text "を つかった!" + done + +ItemGotOnText: + text "は@" + text_low + text_from_ram wStringBuffer2 + text "に のった" + prompt + +ItemGotOffText: + text "は@" + text_low + text_from_ram wStringBuffer2 + text "から おりた" + prompt + ApplyPPUp: ld a, MON_MOVES call GetPartyParamLocation @@ -77,3 +2441,131 @@ ComputeMaxPP: ld [hl], b pop bc ret + +GetMaxPPOfMove:: + ld a, [wMonType] + and a + + ld hl, wPartyMon1Moves + ld bc, PARTYMON_STRUCT_LENGTH + jr z, .got_partymon ; PARTYMON + + ld hl, wOTPartyMon1Moves + dec a + jr z, .got_partymon ; OTPARTYMON + + ld hl, wBoxMon1Moves + ld bc, BOXMON_STRUCT_LENGTH + dec a + jr z, .got_partymon ; BOXMON + + ld hl, wBufferMonMoves + dec a + jr z, .got_nonpartymon ; TEMPMON + + ld hl, wBattleMonMoves ; WILDMON + +.got_nonpartymon ; TEMPMON, WILDMON + call GetMthMoveOfCurrentMon + jr .gotdatmove + +.got_partymon ; PARTYMON, OTPARTYMON, BOXMON + call GetMthMoveOfNthPartymon + +.gotdatmove + ld a, [hl] + dec a + + push hl + ld hl, Moves + MOVE_PP + ld bc, MOVE_LENGTH + call AddNTimes + ld a, BANK(Moves) + call GetFarByte + ld b, a + ld de, wStringBuffer1 + ld [de], a + pop hl + + push bc + ld bc, MON_PP - MON_MOVES + ld a, [wMonType] + cp WILDMON + jr nz, .notwild + ld bc, wEnemyMonPP - wEnemyMonMoves +.notwild + add hl, bc + ld a, [hl] + and PP_UP_MASK + pop bc + + or b + ld hl, wStringBuffer1 + 1 + ld [hl], a + xor a + ld [wTempPP], a + call ComputeMaxPP + ld a, [hl] + and PP_MASK + ld [wTempPP], a + ret + +GetMthMoveOfNthPartymon: + ld a, [wCurPartyMon] + call AddNTimes + +GetMthMoveOfCurrentMon: + ld a, [wMenuCursorY] + ld c, a + ld b, $00 + add hl, bc + ret + +; Dummied out to always return the carry flag. +Stub_IsNextTileShoreOrWater_Old: + scf + ret + +ReadSuperRodData_Old: + ld a, [wMapId] + ld de, 3 + ld hl, SuperRodData + call FindItemInTable + jr c, .ReadFishingGroup + ld e, 2 + ret + +.ReadFishingGroup + inc hl + + ld a, [hli] + ld h, [hl] + ld l, a + + ld b, [hl] + inc hl + ld e, $00 + +.random_loop + call Random + srl a + ret c + and %11 + cp b + jr nc, .random_loop + + add a + ld c, a + ld b, 0 + add hl, bc + ld b, [hl] + inc hl + ld c, [hl] + ld e, 1 + ret + +INCLUDE "data/items/super_rod.inc" + +ItemUseReloadOverworldData_Old:: + call LoadMapPart + jp UpdateSprites diff --git a/engine/items/print_item_description.asm b/engine/items/print_item_description.asm new file mode 100644 index 0000000..338c3af --- /dev/null +++ b/engine/items/print_item_description.asm @@ -0,0 +1,20 @@ +INCLUDE "constants.asm" + +SECTION "engine/items/print_item_description.asm", ROMX + +PrintItemDescription:: + push de + ld hl, ItemDescriptions + ld a, [wSelectedItem] + 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 + +INCLUDE "data/items/descriptions.inc" \ No newline at end of file diff --git a/engine/items/switch_items.asm b/engine/items/switch_items.asm new file mode 100644 index 0000000..a69ec9c --- /dev/null +++ b/engine/items/switch_items.asm @@ -0,0 +1,241 @@ +INCLUDE "constants.asm" + +SECTION "engine/items/switch_items.asm", ROMX + +SwitchItemsInBag:: + ld a, [wSelectedSwapPosition] + and a + jr z, .init + ld b, a + ld a, [wScrollingMenuCursorPosition] + inc a + cp b + jr z, .trivial + ld a, [wScrollingMenuCursorPosition] + call ItemSwitch_GetNthItem + ld a, [hl] + cp -1 + ret z + ld a, [wSelectedSwapPosition] + dec a + ld [wSelectedSwapPosition], a + ld a, [wSelectedSwapPosition] + call ItemSwitch_GetNthItem + push hl + ld a, [wScrollingMenuCursorPosition] + call ItemSwitch_GetNthItem + ld a, [hl] + pop hl + cp [hl] + jr z, .combine_stacks + ld a, [wScrollingMenuCursorPosition] + ld c, a + ld a, [wSelectedSwapPosition] + cp c + jr c, .above + jr .below + +.init: + ld a, [wScrollingMenuCursorPosition] + inc a + ld [wSelectedSwapPosition], a + ret + +.trivial: + xor a + ld [wSelectedSwapPosition], a + ret + +.below: + ld a, [wSelectedSwapPosition] + call ItemSwitch_CopyItemToBuffer + ld a, [wScrollingMenuCursorPosition] + ld d, a + ld a, [wSelectedSwapPosition] + ld e, a + call ItemSwitch_GetItemOffset + push bc + ld a, [wSelectedSwapPosition] + call ItemSwitch_GetNthItem + dec hl + push hl + call ItemSwitch_GetItemFormatSize + add hl, bc + ld d, h + ld e, l + pop hl + pop bc + call ItemSwitch_BackwardsCopyBytes + ld a, [wScrollingMenuCursorPosition] + call ItemSwitch_CopyBufferToItem + xor a + ld [wSelectedSwapPosition], a + ret + +.above: + ld a, [wSelectedSwapPosition] + call ItemSwitch_CopyItemToBuffer + ld a, [wScrollingMenuCursorPosition] + ld d, a + ld a, [wSelectedSwapPosition] + ld e, a + call ItemSwitch_GetItemOffset + push bc + ld a, [wSelectedSwapPosition] + call ItemSwitch_GetNthItem + ld d, h + ld e, l + call ItemSwitch_GetItemFormatSize + add hl, bc + pop bc + call CopyBytes + ld a, [wScrollingMenuCursorPosition] + call ItemSwitch_CopyBufferToItem + xor a + ld [wSelectedSwapPosition], a + ret + +.combine_stacks: + ld a, [wSelectedSwapPosition] + call ItemSwitch_GetNthItem + inc hl + push hl + ld a, [wScrollingMenuCursorPosition] + call ItemSwitch_GetNthItem + inc hl + ld a, [hl] + pop hl + add [hl] + cp MAX_ITEM_STACK + 1 + jr c, .merge_stacks + sub MAX_ITEM_STACK + push af + ld a, [wScrollingMenuCursorPosition] + call ItemSwitch_GetNthItem + inc hl + ld [hl], MAX_ITEM_STACK + ld a, [wSelectedSwapPosition] + call ItemSwitch_GetNthItem + inc hl + pop af + ld [hl], a + xor a + ld [wSelectedSwapPosition], a + ret + +.merge_stacks: + push af + ld a, [wScrollingMenuCursorPosition] + call ItemSwitch_GetNthItem + inc hl + pop af + ld [hl], a + ld hl, wMenuData_ItemsPointerAddr + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wSelectedSwapPosition] + cp [hl] + jr nz, .not_combining_last_item + dec [hl] + ld a, [wSelectedSwapPosition] + call ItemSwitch_GetNthItem + ld [hl], -1 ; end + xor a + ld [wSelectedSwapPosition], a + ret + +.not_combining_last_item: + dec [hl] + call ItemSwitch_GetItemFormatSize + push bc + ld a, [wSelectedSwapPosition] + call ItemSwitch_GetNthItem + pop bc + push hl + add hl, bc + pop de +.copy_loop + ld a, [hli] + ld [de], a + inc de + cp -1 ; end? + jr nz, .copy_loop + xor a + ld [wSelectedSwapPosition], a + ret + +ItemSwitch_CopyItemToBuffer: + call ItemSwitch_GetNthItem + ld de, wSwitchItemBuffer + call ItemSwitch_GetItemFormatSize + call CopyBytes + ret + +ItemSwitch_CopyBufferToItem: + call ItemSwitch_GetNthItem + ld d, h + ld e, l + ld hl, wSwitchItemBuffer + call ItemSwitch_GetItemFormatSize + call CopyBytes + ret + +ItemSwitch_GetNthItem: + push af + call ItemSwitch_GetItemFormatSize + ld hl, wMenuDataDisplayFunctionPointer + 1 + ld a, [hli] + ld h, [hl] + ld l, a + inc hl + pop af + call AddNTimes + ret + +ItemSwitch_GetItemOffset: + push hl + call ItemSwitch_GetItemFormatSize + ld a, d + sub e + jr nc, .dont_negate + dec a + cpl +.dont_negate + ld hl, 0 + call AddNTimes + ld b, h + ld c, l + pop hl + ret + +ItemSwitch_GetItemFormatSize: + push hl + ld a, [wMenuData_ScrollingMenuItemFormat] + ld c, a + ld b, 0 + ld hl, .item_format_sizes + add hl, bc + add hl, bc + ld c, [hl] + inc hl + ld b, [hl] + pop hl + ret + +.item_format_sizes: +; entries correspond to SCROLLINGMENU_ITEMS_* constants + dw 0 ; unused + dw 1 ; SCROLLINGMENU_ITEMS_NORMAL + dw 2 ; SCROLLINGMENU_ITEMS_QUANTITY + +ItemSwitch_BackwardsCopyBytes: +.loop + ld a, [hld] + ld [de], a + dec de + dec bc + ld a, b + or c + jr nz, .loop + ret diff --git a/engine/items/tm_holder.asm b/engine/items/tm_holder.asm new file mode 100644 index 0000000..2b982ae --- /dev/null +++ b/engine/items/tm_holder.asm @@ -0,0 +1,459 @@ +INCLUDE "constants.asm" + +SECTION "engine/items/tm_holder.asm", ROMX + +_TMHolder: + ld a, 1 + ldh [hInMenu], a + + call TM_HolderLoop + + ld a, 0 + ldh [hInMenu], a + ret nc + + call PlaceHollowCursor + call WaitBGMap + ld a, 1 + ldh [hBGMapMode], a + + ld a, [wCurItem] + cp NUM_TM_HM + 1 + ret nc + + ld [wTempTMHM], a + predef GetTMHMMove + ld a, [wTempTMHM] + ld [wPutativeTMHMMove], a + call GetMoveName + call CopyStringToStringBuffer2 + + ld hl, BootedTMText + call PrintText + ld hl, ContainedMoveText + call PrintText + call YesNoBox + jp c, .cancel + +.AskTeachTMHM: +.loopback + ld hl, wStringBuffer2 + ld de, wTMHMMoveNameBackup + ld bc, MOVE_NAME_LENGTH + call CopyBytes + + ld hl, wStateFlags + res SPRITE_UPDATES_DISABLED_F, [hl] + ld a, PARTYMENUACTION_TEACH_TMHM + ld [wPartyMenuActionText], a + predef OpenPartyMenu_ClearGraphics + push af + + ld hl, wTMHMMoveNameBackup + ld de, wStringBuffer2 + ld bc, MOVE_NAME_LENGTH + call CopyBytes + + pop af + jr nc, .TeachTMHM + jp .done + +.TeachTMHM: + predef CanLearnTMHMMove + push bc + ld a, [wCurPartyMon] + ld hl, wPartyMonNicknames + call GetNick + pop bc + + ld a, c + and a + jr nz, .compatible + push de + ld de, SFX_WRONG + call PlaySFX + pop de + ld hl, TMHMNotCompatibleText + call PrintText + jr .loopback + +.compatible + callfar KnowsMove + jr c, .loopback + predef LearnMove + ld a, b + and a + jr z, .cancel + call ConsumeTM + jr .done + +.cancel + ld a, $2 + ld [wItemEffectSucceeded], a +.done + call ClearBGPalettes + call ClearSprites + ld hl, wStateFlags + set SPRITE_UPDATES_DISABLED_F, [hl] + call RestoreScreenAndReloadTiles + call GetMemSGBLayout + ret + +BootedTMText: + text "を きどうした!" + prompt + +Unreferenced_BootedHMText: + text "ひでんマシンを きどうした!" + +ContainedMoveText: + text "なかには @" + text_from_ram wStringBuffer2 + text "が" + line "きろくされていた!" + para "@" + text_from_ram wStringBuffer2 + text "を" + line "#に おぼえさせますか?" + done + +TMHMNotCompatibleText: + text_from_ram wStringBuffer1 + text "と @" + text_from_ram wStringBuffer2 + text "は" + line "あいしょうが わるかった!" + para "@" + text_from_ram wStringBuffer2 + text "は おぼえられない!" + prompt + db $02, $04, $00, $01 + db $0c, $20 + db $c3 + +TM_HolderLoop: + xor a + ldh [hBGMapMode], a + call TMHolder_DisplayItems + ld a, 2 + ld [w2DMenuCursorInitY], a + ld a, 4 + ld [w2DMenuCursorInitX], a + ld a, 1 + ld [w2DMenuNumCols], a + ld a, 4 + sub d + inc a + cp 5 + jr nz, .okay + dec a + +.okay + ld [w2DMenuNumRows], a + ld a, _2DMENU_EXIT_UP | _2DMENU_EXIT_DOWN + ld [w2DMenuFlags1], a + xor a + ld [w2DMenuFlags2], a + ld a, $20 + ld [w2DMenuCursorOffsets], a + ld a, D_UP | D_DOWN | A_BUTTON | B_BUTTON + ld [wMenuJoypadFilter], a + ld a, [wTMHolderCursor] + inc a + ld [wMenuCursorY], a + ld a, 1 + ld [wMenuCursorX], a + jr TMHolder_ShowTMMoveDescription + +TMHolder_JoypadLoop: + call TMHolder_DisplayItems + +TMHolder_JoypadLoop_SkipDisplay: + call WaitBGMap + ld a, $1 + ldh [hBGMapMode], a + call StaticMenuJoypad + ld b, a + ld a, [wMenuCursorY] + dec a + ld [wTMHolderCursor], a + xor a + ldh [hBGMapMode], a + ld a, [w2DMenuFlags2] + bit _2DMENU_EXITING_F, a + jp nz, TMHM_ScrollHolder + ld a, b + bit A_BUTTON_F, a + jp nz, TMHM_CheckHoveringOverCancel + bit B_BUTTON_F, a + jp nz, ExitTMHolder + +TMHolder_ShowTMMoveDescription: + call TMHM_CheckHoveringOverCancel + hlcoord 0, 10 + ld b, 6 + ld c, SCREEN_WIDTH - 2 + call DrawTextBox + call UpdateSprites + + ld a, [wCurItem] + cp NUM_TM_HM + 1 + jr nc, TMHolder_JoypadLoop_SkipDisplay + + ld [wTempTMHM], a + hlcoord 1, 12 + ld de, TMHM_TypeString + call PlaceString + predef GetTMHMMove + ld a, [wTempTMHM] + + ld [wSelectedItem], a + ld b, a + hlcoord 5, 12 + predef PrintMoveType + hlcoord 1, 14 + call PrintMoveDescription + + hlcoord 11, 12 + ld de, TMHM_PowerString + call PlaceString + + ld a, [wSelectedItem] + dec a + ld hl, Moves + MOVE_POWER + ld bc, MOVE_LENGTH + call AddNTimes + + ld a, BANK(Moves) + call GetFarByte + hlcoord 16, 12 + cp 2 + jr c, .no_power +; Store the power of the move in wTempByteValue. + ld [wTempByteValue], a + ld de, wTempByteValue + lb bc, 1, 3 + call PrintNumber + jp TMHolder_JoypadLoop + +.no_power + ld de, TMHM_ThreeDashesString + call PlaceString + jp TMHolder_JoypadLoop + +TMHM_CheckHoveringOverCancel: + call TMHM_GetCurrentHolderPosition + ld a, [wMenuCursorY] + ld b, a + +.loop + inc c + ld a, c + cp NUM_TM_HM + 1 + jr nc, .okay + ld a, [hli] + and a + jr z, .loop + dec b + jr nz, .loop + ld a, c + +.okay + ld [wCurItem], a + cp -1 + ret + +ExitTMHolder: + and a + ret + +TMHM_ScrollHolder: + ld a, b + bit D_DOWN_F, a + jr nz, .down + ld hl, wTMHolderScrollPosition + ld a, [hl] + and a + jp z, TMHolder_JoypadLoop + dec [hl] + call TMHolder_DisplayItems + jp TMHolder_ShowTMMoveDescription + +.down + call TMHM_GetCurrentHolderPosition + ld b, $5 +.loop: + inc c + ld a, c + cp NUM_TM_HM + 1 + jp nc, TMHolder_JoypadLoop + ld a, [hli] + and a + jr z, .loop + dec b + jr nz, .loop + ld hl, wTMHolderScrollPosition + inc [hl] + call TMHolder_DisplayItems + jp TMHolder_ShowTMMoveDescription + +TMHM_PowerString: + db "いりょく/@" + +TMHM_ThreeDashesString: + db "ーーー@" + +TMHM_TypeString: + db "タイプ/@" + +TMHolder_DisplayItems: + hlcoord 3, 0 + ld b, 8 + ld c, 15 + call DrawTextBox + call TMHM_GetCurrentHolderPosition + ld d, 4 + +.next + inc c + ld a, c + cp NUM_TM_HM + 1 + jr nc, .cancel + ld a, [hli] + and a + jr z, .next + + ld b, a + ld a, c + ld [wTempTMHM], a + push hl + push de + push bc + call .GetCurrentLineCoord + push hl + + ld de, wTempTMHM + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 + call PrintNumber + predef GetTMHMMove + ld a, [wTempTMHM] + ld [wPutativeTMHMMove], a + call GetMoveName + + pop hl + ld bc, $3 + add hl, bc + push hl + call PlaceString + + pop hl + ld bc, $8 + add hl, bc + ld [hl], "×" + inc hl + ld a, "0" + + pop bc + push bc + ld a, b + ld [wTempTMHM], a + ld de, wTempTMHM + lb bc, 1, 2 + call PrintNumber + + pop bc + pop de + pop hl + dec d + jr nz, .next + jr .done + +.cancel + call .GetCurrentLineCoord +; Write "CANCEL" + ld a, "や" + ld [hli], a + ld a, "め" + ld [hli], a + ld [hl], "る" +.done + ret + +.GetCurrentLineCoord: + hlcoord 5, 0 + ld bc, SCREEN_WIDTH * 2 + ld a, 5 + sub d + ld d, a +.line_loop + add hl, bc + dec d + jr nz, .line_loop + ret + +TMHM_GetCurrentHolderPosition: + ld hl, wTMsHMs + ld a, [wTMHolderScrollPosition] + ld b, a + inc b + ld c, 0 +.loop + inc c + ld a, [hli] + and a + jr z, .loop + dec b + jr nz, .loop + dec hl + dec c + ret + +Unreferenced_VerboseReceiveTMHM_Old: + call .CheckHaveRoomForTMHM + ld hl, .NoRoomTMHMText + jr nc, .full + ld hl, .ReceivedTMHMText + +.full + jp PrintText + +.NoRoomTMHMText: + text_from_ram wStringBuffer1 + text "は これいじょう" + line "もてません!" + prompt + +.ReceivedTMHMText: + text_from_ram wStringBuffer1 + text "を てにいれた!" + prompt + +.CheckHaveRoomForTMHM: + ld a, [wCurItem] + dec a + ld hl, wTMsHMs + ld b, $0 + ld c, a + add hl, bc + ld a, [hl] + inc a + cp 10 + ret nc + ld [hl], a + ret + +ConsumeTM: + ld a, [wCurItem] + dec a + ld hl, wTMsHMs + ld b, $0 + ld c, a + add hl, bc + ld a, [hl] + and a + ret z + dec a + ld [hl], a + ret nz + ld [wTMHolderScrollPosition], a + ret diff --git a/engine/items/tmhm.asm b/engine/items/tmhm.asm index b02f17c..652dcab 100644 --- a/engine/items/tmhm.asm +++ b/engine/items/tmhm.asm @@ -8,7 +8,7 @@ CanLearnTMHMMove: ; Sets register c to 1 if TM/HM is in learnset OR if debug is enabled. ld a, [wDebugFlags] ld c, 01 - bit 1, a + bit DEBUG_FIELD_F, a ret nz ld a, [wCurPartySpecies] diff --git a/engine/items/update_item_description.asm b/engine/items/update_item_description.asm new file mode 100644 index 0000000..3c8d708 --- /dev/null +++ b/engine/items/update_item_description.asm @@ -0,0 +1,14 @@ +INCLUDE "constants.asm" + +SECTION "engine/items/update_item_description.asm", ROMX + +UpdateItemDescription:: + ld a, [wMenuSelection] + ld [wSelectedItem], a + hlcoord 0, 12 + ld b, 4 + ld c, 18 + call DrawTextBox + decoord 1, 14 + callfar PrintItemDescription + ret diff --git a/engine/link/time_capsule_2.asm b/engine/link/time_capsule_2.asm new file mode 100644 index 0000000..3ca6ae4 --- /dev/null +++ b/engine/link/time_capsule_2.asm @@ -0,0 +1,43 @@ +INCLUDE "constants.asm" + +SECTION "engine/link/time_capsule_2.asm", ROMX + +; Takes the DEX_* index stored in wTempSpecies, +; finds its MON_* in the Pokered_MonIndices table, +; and returns its index in wTempSpecies. +ConvertMon_2to1:: + push bc + push hl + ld a, [wTempSpecies] + ld b, a + ld c, $00 + ld hl, Pokered_MonIndices +.loop + inc c + ld a, [hli] + cp b + jr nz, .loop + ld a, c + ld [wTempSpecies], a + pop hl + pop bc + ret + +; Takes the MON_* value stored in wTempSpecies +; and returns the corresponding DEX_* value from Pokered_MonIndices in wTempSpecies. +ConvertMon_1to2:: + push bc + push hl + ld a, [wTempSpecies] + dec a + ld hl, Pokered_MonIndices + ld b, $00 + ld c, a + add hl, bc + ld a, [hl] + ld [wTempSpecies], a + pop hl + pop bc + ret + +INCLUDE "data/pokemon/gen1_order.inc" diff --git a/engine/menu/frame_type_dialog.asm b/engine/menu/frame_type_dialog.asm index b36168d..bb0f8a7 100644 --- a/engine/menu/frame_type_dialog.asm +++ b/engine/menu/frame_type_dialog.asm @@ -7,7 +7,7 @@ FrameTypeDialog: call LoadMenuHeader ld a, [wActiveFrame] inc a - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a call VerticalMenu jr c, .close ld a, [wMenuCursorY] diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index 9395027..8f31c1b 100644 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -51,7 +51,7 @@ InitializeNewGameWRAM: ld hl, wPartyCount call .InitList - ld hl, wBoxListLength + ld hl, wBoxCount call .InitList ld hl, wNumBagItems call .InitList diff --git a/engine/menu/menu.asm b/engine/menu/menu.asm new file mode 100644 index 0000000..572773b --- /dev/null +++ b/engine/menu/menu.asm @@ -0,0 +1,384 @@ +INCLUDE "constants.asm" + +SECTION "engine/menu/menu.asm", ROMX + +_PushWindow:: + xor a ; BANK(sWindowStack) + call OpenSRAM + + ld hl, wWindowStackPointer + ld e, [hl] + inc hl + ld d, [hl] + push de + + ld b, wMenuDataHeaderEnd - wMenuDataHeader + ld hl, wMenuDataHeader +.loop + ld a, [hli] + ld [de], a + dec de + dec b + jr nz, .loop + +; If bit MENU_BACKUP_TILES_F or MENU_BACKUP_TILES_2_F of the menu flags is set, +; also set bit MENU_RESTORE_TILES_F of the address at 7:[wWindowStackPointer], +; and draw the menu using the coordinates from the header. +; Otherwise, reset bit MENU_RESTORE_TILES_F of 7:[wWindowStackPointer]. + ld a, [wMenuFlags] + bit MENU_BACKUP_TILES_F, a + jr nz, .backup_tiles + bit MENU_BACKUP_TILES_2_F, a + jr z, .no_backup_tiles + +; Don't bother backing up tiles if it doesn't overlap with any other windows. + push de + call PushWindow_CheckForOtherWindowOverlap + pop de + jr nc, .no_backup_tiles + +.backup_tiles + ld hl, wWindowStackPointer + ld a, [hli] + ld h, [hl] + ld l, a + set MENU_RESTORE_TILES_F, [hl] + call MenuBoxCoord2Tile + call GetMenuBoxDims + inc b + inc c + call .CheckForOverflow + +.row + push bc + push hl +.col + ld a, [hli] + ld [de], a + dec de + dec c + jr nz, .col + + pop hl + ld bc, SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .row + jr .done + +.no_backup_tiles + pop hl ; last-pushed register was de + push hl + ld a, [hld] + ld l, [hl] + ld h, a + res MENU_RESTORE_TILES_F, [hl] + +.done + pop hl ; last-pushed register was de + call .CheckForOverflow + +; Push the previous window address onto the bottom for easy access + ld a, h + ld [de], a + dec de + ld a, l + ld [de], a + dec de + + ld hl, wWindowStackPointer + ld [hl], e + inc hl + ld [hl], d + + call CloseSRAM + ld hl, wWindowStackSize + inc [hl] + ret + +; Dummied out in the final game. See _PushWindow.ret in pokegold. +; hl = starting position of search. +; de = ending position of search. +; bc = dimensions of menu box (optional) +.CheckForOverflow: + push bc + push de + push hl + xor a + ld l, c + ld h, 0 + ld c, b + ld b, 0 + ld a, SCREEN_WIDTH + call AddNTimes + ld a, h + cpl + ld h, a + ld a, l + cpl + ld l, a + inc hl + add hl, de + + ld a, e + sub LOW(sWindowStackBottom) + ld a, d + sbc HIGH(sWindowStackBottom) + jr c, .window_stack_overflow + pop hl + pop de + pop bc + ret + +.window_stack_overflow: + ld hl, .WindowSaveAreaOverflowText + call PrintText + call WaitBGMap +.indefinite_loop + nop + jr .indefinite_loop + +.WindowSaveAreaOverflowText: + text "ウィンドウセーブエりアが" + next "オーバーしました" + done + +; Returns the carry flag if any of the other windows overlap with the current window. +PushWindow_CheckForOtherWindowOverlap: + ld hl, wWindowStackPointer + ld a, [hli] + ld h, [hl] + ld l, a +.loop + inc hl + ld a, [hli] + ld h, [hl] + ld l, a + or h + jr z, .stack_bottom_reached + + push hl + dec hl ; top coord + ld b, [hl] + dec hl ; left coord + ld c, [hl] + dec hl ; bottom coord + ld d, [hl] + dec hl ; right coord + ld e, [hl] + call .AvoidRedundantTiles + pop hl + ret c + jr .loop + +; Check again, but in reverse: if the current window overlaps with any other windows, set the carry flag. +.stack_bottom_reached: + ld hl, wMenuBorderTopCoord + ld b, [hl] + inc hl ; wMenuBorderLeftCoord + ld c, [hl] + inc hl ; wMenuBorderBottomCoord + ld d, [hl] + inc hl ; wMenuBorderRightCoord + ld e, [hl] + inc hl ; not necessary if we're overwriting hl right after + ld hl, wWindowStackPointer + ld a, [hli] + ld h, [hl] + ld l, a +.loop2 + inc hl + ld a, [hli] + ld h, [hl] + ld l, a + or h + ret z + + push hl + ld a, [hld] ; top coord + ld l, [hl] ; left coord + ld h, a + call .CheckIfInCoordRange + pop hl + ret c + jr .loop2 + +.AvoidRedundantTiles: + ld a, [wMenuBorderTopCoord] + ld h, a + ld a, [wMenuBorderLeftCoord] + ld l, a + call .CheckIfInCoordRange + ret c + ld a, [wMenuBorderBottomCoord] + ld h, a + call .CheckIfInCoordRange + ret c + ld a, [wMenuBorderRightCoord] + ld l, a + call .CheckIfInCoordRange + ret c + ld a, [wMenuBorderTopCoord] + ld h, a + call .CheckIfInCoordRange + ret + +; If b <= h <= d && c <= l <= e, set carry flag. +; b, h, and d are generally used for vertical positioning, and the others for horizontal positioning. +; It doesn't really matter which one has which, though. +.CheckIfInCoordRange: + ld a, h + cp b + jr c, .out_of_range + cp d + jr c, .next_range + jr nz, .out_of_range +.next_range + ld a, l + cp c + jr c, .out_of_range + cp e + jr c, .in_range + jr nz, .out_of_range +.in_range + scf + ret + +.out_of_range + and a + ret + +_ExitMenu:: + xor a + ldh [hBGMapMode], a + + xor a ; BANK(sWindowStack) + call OpenSRAM + + call GetWindowStackTop + ld a, l + or h + jp z, Error_Cant_ExitMenu + + ld a, l + ld [wWindowStackPointer], a + ld a, h + ld [wWindowStackPointer + 1], a + call PopWindow + ld a, [wMenuFlags] + bit MENU_RESTORE_TILES_F, a + jr z, .loop + ld d, h + ld e, l + call RestoreTileBackup + +.loop + call GetWindowStackTop + ld a, h + or l + jr z, .done + call PopWindow + +.done + call CloseSRAM + ld hl, wWindowStackSize + dec [hl] + ret + +Error_Cant_ExitMenu: + ld hl, .WindowPoppingErrorText + call PrintText + call WaitBGMap +.infinite_loop + jr .infinite_loop + +.WindowPoppingErrorText: + text "ポップできる ウィンドウが" + next "ありません!" + done + +_ExitAllMenus:: +.loop + xor a ; BANK(sWindowStack) + call OpenSRAM + call GetWindowStackTop + ld a, l + or h + jr z, .stack_bottom_reached + + call _ExitMenu + jr .loop + +.stack_bottom_reached + call CloseSRAM + ret + +_InitVerticalMenuCursor:: + ld a, [wMenuDataHeaderEnd] + ld b, a + ld hl, wMoreMenuData + ld a, [wMenuBorderTopCoord] + inc a + bit STATICMENU_NO_TOP_SPACING_F, b + jr nz, .skip_offset + inc a +.skip_offset + ld [hli], a +; w2DMenuCursorInitX + ld a, [wMenuBorderLeftCoord] + inc a + ld [hli], a +; w2DMenuNumRows + ld a, [wMenuDataItems] + ld [hli], a +; w2DMenuNumCols + ld a, 1 + ld [hli], a +; w2DMenuFlags1 + ld [hl], 0 + bit STATICMENU_WRAP_F, b + jr z, .skip_bit_5 + set _2DMENU_WRAP_UP_DOWN_F, [hl] +.skip_bit_5 + ld a, [wMenuFlags] + bit MENU_SPRITE_ANIMS_F, a + jr z, .skip_bit_6 + set _2DMENU_ENABLE_SPRITE_ANIMS_F, [hl] +.skip_bit_6 + inc hl +; w2DMenuFlags2 + xor a + ld [hli], a +; w2DMenuCursorOffsets + ln a, 2, 0 + ld [hli], a +; wMenuJoypadFilter + ld a, A_BUTTON + bit STATICMENU_DISABLE_B_F, b + jr nz, .skip_bit_1 + add B_BUTTON +.skip_bit_1 + ld [hli], a +; wMenuCursorY + ld a, [wMenuCursorPosition] + and a + jr z, .load_at_the_top + ld c, a + ld a, [wMenuDataItems] + cp c + jr nc, .load_position +.load_at_the_top + ld c, 1 +.load_position + ld [hl], c + inc hl +; wMenuCursorX + ld a, 1 + ld [hli], a +; wCursorOffCharacter, wCursorCurrentTile + xor a + ld [hli], a + ld [hli], a + ld [hli], a + ret diff --git a/engine/menu/menu_2.asm b/engine/menu/menu_2.asm new file mode 100644 index 0000000..cbf8c09 --- /dev/null +++ b/engine/menu/menu_2.asm @@ -0,0 +1,201 @@ +INCLUDE "constants.asm" + +SECTION "engine/menu/menu_2.asm", ROMX + +PlacePackItems:: + ld a, [wMenuSelection] + cp -1 + jr z, .cancel + push de + callfar CheckItemMenu + ld a, [wItemAttributeValue] + ld e, a + ld d, 0 + ld hl, .attribute_icons + add hl, de + ld a, [hl] + pop de + ld [de], a + inc de + jr PlaceMenuItemName + +.attribute_icons: + db " " + db $62 ; TM Holder icon + db $64 ; Ball Holder icon + db $63 ; Key Items icon + db " " + db " " + db " " + +.cancel + ld h, d + ld l, e + ld de, .CancelString + call PlaceString + ret + +.CancelString: + db " ーーやめるーー@" + +PlaceMenuItemName:: + push de + ld a, [wMenuSelection] + ld [wNamedObjectIndexBuffer], a + call GetItemName + pop hl + call PlaceString + ret + +PlaceMenuItemQuantity:: + push de + ld a, [wMenuSelection] + ld [wCurItem], a + callfar _CheckTossableItem + ld a, [wItemAttributeValue] + pop hl + and a + jr nz, .done + ld [hl], "×" + inc hl + ld de, wMenuSelectionQuantity + lb bc, 1, 2 + call PrintNumber +.done + ret + +PlacePartyMonNicknames:: + ld hl, wPartyMonNicknames + jr PlaceMonNicknames + +PlaceBoxMonNicknames:: + ld hl, wBoxMonNicknames +PlaceMonNicknames: + push de + ld a, [wScrollingMenuCursorPosition] + call GetNick + pop hl + call PlaceString + ret + +PlacePartyMonLevels:: + ld a, PARTYMON + ld [wMonType], a + jr PlaceMonLevels + +PlaceBoxMonLevels:: + ld a, BOXMON + ld [wMonType], a +PlaceMonLevels: + push de + ld a, [wScrollingMenuCursorPosition] + ld [wCurPartyMon], a + predef CopyMonToTempMon + pop hl + call PrintLevel + ret + +; Unreferenced. + ret + +; Prints the names, nicknames, levels, and genders of Pokémon. +PlaceDetailedBoxMonView:: + push de + ld a, [wScrollingMenuCursorPosition] + ld c, a + ld b, 0 + ld hl, wBoxSpecies + add hl, bc + + ld a, [hl] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + pop hl + call PlaceString + ld de, MON_NAME_LENGTH + add hl, de + push hl + + ld a, [wScrollingMenuCursorPosition] + ld hl, wBoxMonNicknames + call GetNick + pop hl + call PlaceString + ld de, MON_NAME_LENGTH + add hl, de + push hl + + ld a, [wScrollingMenuCursorPosition] + ld [wCurPartyMon], a + ld a, BOXMON + ld [wMonType], a + predef CopyMonToTempMon + pop hl + push hl + call PrintLevel + pop hl + ld de, 3 + add hl, de + push hl + + callfar GetGender + ld a, "♂" + jr c, .male + ld a, "♀" +.male + pop hl + ld [hl], a + ret + +Unreferenced_PlaceMoneyTextbox_Old:: + ld hl, .MenuHeader + call CopyMenuHeader + call MenuBox + call PlaceVerticalMenuItems + call MenuBoxCoord2Tile + ld de, SCREEN_WIDTH + 1 + add hl, de + ld de, wMoney + lb bc, PRINTNUM_RIGHTALIGN | 3, 6 + call PrintNumber + ret + +.MenuHeader: + db 0 + menu_coords 11, 0, SCREEN_WIDTH - 1, 2 + dw .MenuData + db 1 + +.MenuData: + db STATICMENU_NO_TOP_SPACING + db 1 + db "      円@" + +PlaceMoneyTopRight:: + ld hl, MoneyTopRightMenuHeader + call CopyMenuHeader + jr PlaceMoneyTextbox + +; Unreferenced. +PlaceMoneyAtTopLeftOfTextbox:: + ld hl, MoneyTopRightMenuHeader + ld d, 11 + ld e, 0 + call OffsetMenuHeader + +PlaceMoneyTextbox: + call MenuBox + call MenuBoxCoord2Tile + ld de, SCREEN_WIDTH + 1 + add hl, de + ld de, wMoney + lb bc, PRINTNUM_RIGHTALIGN | 3, 6 + call PrintNumber + ld [hl], "円" + ret + +MoneyTopRightMenuHeader: + db MENU_BACKUP_TILES + menu_coords 11, 0, SCREEN_WIDTH - 1, 2 + dw NULL + db 1 diff --git a/engine/menu/scrolling_menu.asm b/engine/menu/scrolling_menu.asm new file mode 100644 index 0000000..3ca2b8b --- /dev/null +++ b/engine/menu/scrolling_menu.asm @@ -0,0 +1,514 @@ +INCLUDE "constants.asm" + +SECTION "engine/menu/scrolling_menu.asm", ROMX + +_InitScrollingMenu:: + xor a + ld [wMenuJoypad], a + ldh [hBGMapMode], a + inc a + ldh [hInMenu], a + ld hl, wOptions + set NO_TEXT_SCROLL_F, [hl] + call InitScrollingMenuCursor + call ScrollingMenu_InitFlags + ld c, 10 + call DelayFrames + call ScrollingMenuMain + ret + +_ScrollingMenu:: +.loop + call ScrollingMenuJoyAction + jp c, .exit + ld a, 0 + ldh [hJoypadSum], a + call z, ScrollingMenuMain + jr .loop +.exit + ld [wMenuJoypad], a + ld a, 0 + ldh [hInMenu], a + ld hl, wOptions + res NO_TEXT_SCROLL_F, [hl] + ret + +ScrollingMenuMain:: + xor a + ldh [hBGMapMode], a + call ScrollingMenu_UpdateDisplay + call ScrollingMenu_PlaceCursor + call ScrollingMenu_CheckCallFunction3 + xor a + ldh [hJoypadSum], a + call WaitBGMap + ret + +ScrollingMenuJoyAction:: + call ScrollingMenuJoypad + ldh a, [hJoySum] + and D_PAD + ld b, a + ldh a, [hJoypadSum] + and BUTTONS + or b + bit A_BUTTON_F, a + jp nz, .a_button + bit B_BUTTON_F, a + jp nz, .b_button + bit SELECT_F, a + jp nz, .select + bit START_F, a + jp nz, .start + bit D_RIGHT_F, a + jp nz, .d_right + bit D_LEFT_F, a + jp nz, .d_left + bit D_UP_F, a + jp nz, .d_up + bit D_DOWN_F, a + jp nz, .d_down + jr ScrollingMenuJoyAction + + ; unreferenced +.no_zero_no_carry + ld a, -1 + and a + ret + +.a_button + call PlaceHollowCursor + ld a, [wMenuCursorY] + dec a + call ScrollingMenu_GetListItemCoordAndFunctionArgs + ld a, [wMenuSelection] + ld [wCurItem], a + ld a, [wMenuSelectionQuantity] + ld [wItemQuantityBuffer], a + call ScrollingMenu_GetCursorPosition + dec a + ld [wScrollingMenuCursorPosition], a + ld [wCurItemQuantity], a + ld a, [wMenuSelection] + cp -1 + jr z, .b_button + ld a, A_BUTTON + scf + ret + +.b_button + ld a, B_BUTTON + scf + ret + +.select + ld a, [wMenuDataFlags] + bit SCROLLINGMENU_ENABLE_SELECT_F, a + jp z, xor_a_dec_a + ld a, [wMenuCursorY] + dec a + call ScrollingMenu_GetListItemCoordAndFunctionArgs + ld a, [wMenuSelection] + cp -1 + jp z, xor_a_dec_a + call ScrollingMenu_GetCursorPosition + dec a + ld [wScrollingMenuCursorPosition], a + ld a, SELECT + scf + ret + +.start + ld a, [wMenuDataFlags] + bit SCROLLINGMENU_ENABLE_START_F, a + jp z, xor_a_dec_a + ld a, START + scf + ret + +.d_left + ld hl, w2DMenuFlags2 + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, [hl] + jp z, xor_a_dec_a + ld a, [wMenuDataHeaderEnd] + bit SCROLLINGMENU_ENABLE_LEFT_F, a + jp z, xor_a_dec_a + ld a, D_LEFT + scf + ret + +.d_right + ld hl, w2DMenuFlags2 + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, [hl] + jp z, xor_a_dec_a + ld a, [wMenuDataHeaderEnd] + bit SCROLLINGMENU_ENABLE_RIGHT_F, a + jp z, xor_a_dec_a + ld a, D_RIGHT + scf + ret + +.d_up + ld hl, w2DMenuFlags2 + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, [hl] + jp z, xor_a + ld hl, wMenuScrollPosition + ld a, [hl] + and a + jp z, xor_a ; xor_a_dec_a in final game + dec [hl] + jp xor_a + +.d_down + ld hl, w2DMenuFlags2 + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, [hl] + jp z, xor_a + ld hl, wMenuScrollPosition + ld a, [wMenuData_ScrollingMenuHeight] + add [hl] + ld b, a + ld a, [wScrollingMenuListSize] + cp b + jp c, xor_a ; xor_a_dec_a in final game + inc [hl] + jp xor_a + +ScrollingMenu_GetCursorPosition: + ld a, [wMenuScrollPosition] + ld c, a + ld a, [wMenuCursorY] + add c + ld c, a + ret + +ScrollingMenu_ClearLeftColumn:: + call MenuBoxCoord2Tile + ld de, SCREEN_WIDTH + add hl, de + ld de, 2 * SCREEN_WIDTH + ld a, [wMenuData_ScrollingMenuHeight] +.loop + ld [hl], " " + add hl, de + dec a + jr nz, .loop + ret + +InitScrollingMenuCursor:: + ld hl, wMenuData_ItemsPointerAddr + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wMenuData_ItemsPointerBank] + call GetFarByte + ld [wScrollingMenuListSize], a + ld a, [wMenuScrollPosition] + ld c, a + ld a, [wMenuCursorPosition] + add c + ld b, a + ld a, [wScrollingMenuListSize] + inc a + cp b + jr c, .wrap + + ld a, [wMenuScrollPosition] + ld c, a + ld a, [wMenuData_ScrollingMenuHeight] + add c + ld b, a + ld a, [wScrollingMenuListSize] + inc a + cp b + jr nc, .done + +.wrap + xor a + ld [wMenuScrollPosition], a + ld a, 1 + ld [wMenuCursorPosition], a +.done + ret + +ScrollingMenu_InitFlags:: + ld a, [wMenuDataFlags] + ld c, a + ld a, [wScrollingMenuListSize] + ld b, a + ld a, [wMenuBorderTopCoord] + add 1 + ld [w2DMenuCursorInitY], a + ld a, [wMenuBorderLeftCoord] + add 0 + ld [w2DMenuCursorInitX], a + ld a, [wMenuData_ScrollingMenuHeight] + cp b + jr c, .no_extra_row + jr z, .no_extra_row + ld a, b + inc a +.no_extra_row + ld [w2DMenuNumRows], a + ld a, 1 + ld [w2DMenuNumCols], a + ld a, _2DMENU_EXIT_UP | _2DMENU_EXIT_DOWN | _2DMENU_DISABLE_JOYPAD_FILTER + bit SCROLLINGMENU_ENABLE_RIGHT_F, c + jr z, .skip_set_0 + set _2DMENU_EXIT_RIGHT_F, a + +.skip_set_0 + bit SCROLLINGMENU_ENABLE_LEFT_F, c + jr z, .skip_set_1 + set _2DMENU_EXIT_LEFT_F, a + +.skip_set_1 + ld [w2DMenuFlags1], a + xor a + ld [w2DMenuFlags2], a + ld a, $20 + ld [w2DMenuCursorOffsets], a + ld a, A_BUTTON | B_BUTTON | D_UP | D_DOWN + bit SCROLLINGMENU_ENABLE_SELECT_F, c + jr z, .disallow_select + add SELECT +.disallow_select + bit SCROLLINGMENU_ENABLE_START_F, c + jr z, .disallow_start + add START + +.disallow_start + ld [wMenuJoypadFilter], a + ld a, [w2DMenuNumRows] + ld b, a + ld a, [wMenuCursorPosition] + and a + jr z, .reset_cursor + cp b + jr z, .cursor_okay + jr c, .cursor_okay + +.reset_cursor + ld a, 1 +.cursor_okay + ld [wMenuCursorY], a + ld a, 1 + ld [wMenuCursorX], a + xor a + ld [wCursorCurrentTile], a + ld [wCursorCurrentTile + 1], a + ld [wCursorOffCharacter], a + ret + +ScrollingMenu_UpdateDisplay:: + call ClearWholeMenuBox + ld a, [wMenuScrollPosition] + and a + jr z, .okay + ld a, [wMenuBorderTopCoord] + ld b, a + ld a, [wMenuBorderRightCoord] + ld c, a + call Coord2Tile + ld [hl], "▲" + +.okay + call MenuBoxCoord2Tile + ld bc, SCREEN_WIDTH + 1 + add hl, bc + ld a, [wMenuDataItems] + ld b, a + ld c, 0 +.loop + ld a, [wMenuScrollPosition] + add c + ld [wScrollingMenuCursorPosition], a + ld a, c + call ScrollingMenu_GetListItemCoordAndFunctionArgs + ld a, [wMenuSelection] + cp -1 + jr z, .cancel + push bc + push hl + call ScrollingMenu_CallFunctions1and2 + pop hl + ld bc, 2 * SCREEN_WIDTH + add hl, bc + pop bc + inc c + ld a, c + cp b + jr nz, .loop + ld a, [wMenuBorderBottomCoord] + ld b, a + ld a, [wMenuBorderRightCoord] + ld c, a + call Coord2Tile + ld [hl], "▼" + ret + +.cancel + ld a, [wMenuDataHeaderEnd] + bit SCROLLINGMENU_CALL_FUNCTION1_CANCEL_F, a + jr nz, .call_function + ld de, .CancelString + call PlaceString + ret + +.CancelString: + db "やめる@" + +.call_function + ld d, h + ld e, l + ld hl, wMenuData_ScrollingMenuFunction1 + jp CallPointerAt + +ScrollingMenu_CallFunctions1and2:: + push hl + ld d, h + ld e, l + ld hl, wMenuData_ScrollingMenuFunction1 + call CallPointerAt + pop hl + ld a, [wMenuDataIndicesPointer] + and a + jr z, .done + ld e, a + ld d, 0 + add hl, de + ld d, h + ld e, l + ld hl, wMenuData_ScrollingMenuFunction2 + call CallPointerAt +.done + ret + +ScrollingMenu_PlaceCursor: + ld a, [wSelectedSwapPosition] + and a + jr z, .done + ld b, a + ld a, [wMenuScrollPosition] + cp b + jr nc, .done + ld c, a + ld a, [wMenuData_ScrollingMenuHeight] + add c + cp b + jr c, .done + ld a, b + sub c + dec a + add a + add $1 + ld c, a + ld a, [wMenuBorderTopCoord] + add c + ld b, a + ld a, [wMenuBorderLeftCoord] + add $0 + ld c, a + call Coord2Tile + ld [hl], "▷" + +.done + ret + +; Seems to be more specialized compared to the final game... +; It automatically draws a text box and predefines a decoord. +ScrollingMenu_CheckCallFunction3: + ld a, [wMenuDataFlags] + bit SCROLLINGMENU_ENABLE_FUNCTION3_F, a + ret z + hlcoord 0, 12 + ld b, 4 + ld c, SCREEN_HEIGHT + call DrawTextBox + ld a, [wMenuCursorY] + dec a + call ScrollingMenu_GetListItemCoordAndFunctionArgs + ld a, [wMenuSelection] + cp -1 + jr z, .done + decoord 1, 14 + ld hl, wMenuData_ScrollingMenuFunction3 + call CallPointerAt + ret + +.done + ret + +ScrollingMenu_GetListItemCoordAndFunctionArgs:: + push de + push hl + ld e, a + ld a, [wMenuScrollPosition] + add e + ld e, a + ld d, 0 + ld hl, wMenuData_ItemsPointerAddr + ld a, [hli] + ld h, [hl] + ld l, a + inc hl + ld a, [wMenuData_ScrollingMenuItemFormat] + cp SCROLLINGMENU_ITEMS_NORMAL + jr z, .got_spacing + cp SCROLLINGMENU_ITEMS_QUANTITY + jr z, .pointless_jump + cp SCROLLINGMENU_BALL_POCKET + jr z, .ball_pocket + +.pointless_jump + add hl, de +.got_spacing + add hl, de + ld a, [wMenuData_ItemsPointerBank] + call GetFarByte + ld [wMenuSelection], a + ld [wCurItem], a + inc hl + ld a, [wMenuData_ItemsPointerBank] + call GetFarByte + ld [wMenuSelectionQuantity], a + pop hl + pop de + ret + +.ball_pocket: + ld a, [wScrollingMenuListSize] + ld d, a + ld a, e + cp d ; if menu scroll position <= menu list size + jr nc, .failure + inc e + ld d, 0 +.loop + inc d + ld a, [hli] + and a + jr z, .loop + dec e + jr nz, .loop + dec hl + dec d + push bc + push hl + ld c, d + callfar GetBallByIndex + ld d, c + pop hl + pop bc + jr .done + +.failure + ld d, -1 +.done + ld a, d + ld [wMenuSelection], a + ld [wCurItem], a + ld a, [hl] + ld [wMenuSelectionQuantity], a + pop hl + pop de + ret diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm index 04d2677..468fff9 100644 --- a/engine/menu/start_menu.asm +++ b/engine/menu/start_menu.asm @@ -14,10 +14,10 @@ DisplayStartMenu: call ClearJoypad call GetStartMenuState ld a, [wStartmenuCursor] - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a call OpenMenu jr c, .MainReturn - ld a, [wMenuCursorBuffer] + ld a, [wMenuCursorPosition] ld [wStartmenuCursor], a call PlaceHollowCursor ld a, [wMenuSelection] @@ -39,7 +39,7 @@ DisplayStartMenu: .exit call ExitMenu .UpdateTime - call Function1fea + call ScreenCleanup call UpdateTimePals ret @@ -72,7 +72,7 @@ DisplayStartMenu: db $A8 ; flags db 0 ; items dw StartMenuItems - db $8A, $1F + dw PlaceMenuStrings dw .Strings .Strings: @@ -263,7 +263,7 @@ ToolsPocketHeader: db 4, 9, 2, 0 dw wNumBagItems - dba Function2473b + dba PlacePackItems dba PlaceMenuItemQuantity dba UpdateItemDescription @@ -282,7 +282,7 @@ KeyItemsPocketHeader: db 4, 9, 1, 0 dw wNumKeyItems - dba Function2473b + dba PlacePackItems dba PlaceMenuItemQuantity dba UpdateItemDescription @@ -297,7 +297,7 @@ BackpackMenuHeader: db 4, 9, 2, 0 dw wNumBagItems - dba Function2473b + dba PlacePackItems dba PlaceMenuItemQuantity dba UpdateItemDescription @@ -392,7 +392,7 @@ StartMenu_Backpack: DebugBackpackLoop: ; checks the field debug flag, if set this runs ; otherwise NondebugBackpackLoop runs -; if wactivebackpackpocket is 1 (doesn't have key items) then jumps below +; if wActiveBackpackPocket is 1 (doesn't have key items) then jumps below ld a, [wDebugFlags] bit DEBUG_FIELD_F, a jp z, NondebugBackpackLoop @@ -404,7 +404,7 @@ DebugBackpackLoop: ld de, .ToolsPocketText call DrawBackpackTitleRow ld a, [wRegularItemsCursor] - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a ld a, [wRegularItemsScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu @@ -424,7 +424,7 @@ DebugBackpackLoop: ld de, KeyItemsPocketText call DrawBackpackTitleRow ld a, [wBackpackAndKeyItemsCursor] - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a ld a, [wBackpackAndKeyItemsScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu @@ -444,7 +444,7 @@ NondebugBackpackLoop: ld de, BackpackHeaderText call DrawBackpackTitleRow ld a, [wBackpackAndKeyItemsCursor] - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a ld a, [wBackpackAndKeyItemsScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu @@ -509,7 +509,7 @@ BackpackSelected: .BagSelectJumptable: dw SelectItem - dw .UnknownSelection + dw .TMHolder dw BallPocketLoop dw .SwapPocket dw SelectItem @@ -523,9 +523,9 @@ BackpackSelected: and a ret -.UnknownSelection +.TMHolder call LoadStandardMenuHeader - callfar Function2d2fc + callfar _TMHolder call ExitMenu call DrawBackpack and a @@ -630,14 +630,14 @@ UseItemSelection: ret .SimpleItem: - call UseItem + call DoItemEffect and a ret .SpriteItem: ; might be a better name for this once ; bank 5 gets sorted out - call UseItem + call DoItemEffect call ClearBGPalettes call StartMenuLoadSprites call DrawBackpack @@ -645,7 +645,7 @@ UseItemSelection: ret .FieldMove: - call UseItem + call DoItemEffect ld a, [wFieldMoveSucceeded] and a jr z, .FailedMove @@ -794,10 +794,8 @@ BallPocket: .MenuData: db SCROLLINGMENU_ENABLE_FUNCTION3 ; flags db 4, 8 ; rows, columns - db $80 ; horizontal spacing? - db 0 ; ??? - dw wNumBallItems - + db SCROLLINGMENU_BALL_POCKET + dbw 0, wNumBallItems dba PlaceMenuItemName dba PlaceMenuItemQuantity dba UpdateItemDescription @@ -901,7 +899,7 @@ HandleSelectedPokemon: xor a ld [wPartyMenuActionText], a ld [wSelectedSwapPosition], a - predef PartyMenuInBattle + predef OpenPartyMenu jr PartyPrompt.partypromptreturn PartyPrompt: @@ -911,7 +909,7 @@ PartyPrompt: callfar UnfreezeMonIcons ld a, PARTYMENUACTION_MOVE ld [wPartyMenuActionText], a - predef PartyMenuInBattle + predef OpenPartyMenu .partypromptreturn jr c, .return jp SelectedPokemonSubmenu @@ -1361,7 +1359,7 @@ PartyPokemonSummary: xor a ld [wMonType], a call LowVolume - predef Function502b5 + predef StatsScreenMain call MaxVolume call ReloadFontAndTileset call Call_ExitMenu @@ -1416,7 +1414,7 @@ PartyTryDig: jp PartyPromptExit PartyCalculateHealth: - ld a, MON_MAXHP ; might be wrong, was $24 + ld a, MON_MAXHP call GetPartyParamLocation ld a, [hli] ldh [hDividend], a @@ -1426,7 +1424,7 @@ PartyCalculateHealth: ldh [hDivisor], a ld b, 2 call Divide - ld a, MON_HP + 1 ; might be wrong, was $23 + ld a, MON_HP + 1 call GetPartyParamLocation ldh a, [hQuotient + 3] sub [hl] @@ -1434,7 +1432,7 @@ PartyCalculateHealth: ldh a, [hQuotient + 2] sbc [hl] jp nc, PrintNotHealthyEnoughText - callfar Functionf218 + callfar SoftboiledFunction jp HandleSelectedPokemon PrintNotHealthyEnoughText: @@ -1492,7 +1490,7 @@ PokeSummary: lb bc, 2, $12 call ClearBox hlcoord 3, 1 - predef Function508c4 + predef PlacePartyMember ld hl, wPlayerHPPal call SetHPPal ld b, $0E @@ -1546,7 +1544,7 @@ SummaryDrawPoke: set 6, [hl] jr PartySelectionInputs.PartySelectSkipInputs PartySelectionInputs: - call Get2DMenuJoypad + 3 + call StaticMenuJoypad + 3 bit B_BUTTON_F, a jp nz, PartySelectionBackOut bit A_BUTTON_F, a @@ -1600,7 +1598,7 @@ PartySelectionInputs: call PlaceString .step hlcoord 1, 14 - predef Function2d663 + predef PrintMoveDescription jp PartySelectionInputs .DrawMovePokeText @@ -1737,7 +1735,7 @@ CheckRegisteredItem: call RefreshScreen ld hl, .NothingRegisteredText call MenuTextBoxBackup - call Function1fea + call ScreenCleanup ret .NothingRegisteredText: @@ -1811,14 +1809,14 @@ UseRegisteredItem: .CantUse call RefreshScreen call PrintCantUseText - call Function1fea + call ScreenCleanup and a ret .UnusedSimpleUse call RefreshScreen - call UseItem - call Function1fea + call DoItemEffect + call ScreenCleanup and a ret @@ -1826,16 +1824,16 @@ UseRegisteredItem: call RefreshScreen ld hl, wStateFlags res SPRITE_UPDATES_DISABLED_F, [hl] - call UseItem + call DoItemEffect call ClearPalettes call StartMenuLoadSprites call UpdateTimePals - call Function1fea + call ScreenCleanup and a ret .FieldMove - call UseItem + call DoItemEffect ld a, [wFieldMoveSucceeded] and a jr z, .CantUse2 @@ -1848,7 +1846,7 @@ UseRegisteredItem: .CantUse2 call RefreshScreen call PrintCantUseText - call Function1fea + call ScreenCleanup and a ret diff --git a/engine/movie/evolution_animation.inc b/engine/movie/evolution_animation.inc new file mode 100644 index 0000000..2786fcf --- /dev/null +++ b/engine/movie/evolution_animation.inc @@ -0,0 +1,239 @@ +EvolutionAnimation:: + push hl + push de + push bc + ld a, [wCurSpecies] + push af + + ld de, MUSIC_NONE + call PlayMusic + + xor a + ld [wLowHealthAlarm], a + + ld a, 1 + ldh [hBGMapMode], a + + call WaitBGMap + xor a + ldh [hBGMapMode], a + ldh [hMapAnims], a + + ld a, [wEvolutionOldSpecies] + ld [wPlayerHPPal], a + + ld c, FALSE + call .GetSGBLayout + + ld a, [wEvolutionNewSpecies] + ld [wCurPartySpecies], a + ld [wCurSpecies], a + call .PlaceFrontpic + + ld de, vChars2 + ld hl, vChars2 tile $31 + ld bc, 7 * 7 + call Request2bpp + + ld a, [wEvolutionOldSpecies] + ld [wCurPartySpecies], a + ld [wCurSpecies], a + call .PlaceFrontpic + + ld a, 1 + ldh [hBGMapMode], a + + ld a, [wEvolutionOldSpecies] + call PlayCry + + ld de, MUSIC_EVOLUTION + call PlayMusic + + ld c, 80 + call DelayFrames + + ld c, TRUE + call .GetSGBLayout + + lb bc, 1, 16 ; flash b times, wait c frames in between +.loop + push bc + call .WaitFrames_CheckPressedB + jr c, .cancel_evo + call .Flash + pop bc + inc b + dec c + dec c + jr nz, .loop + + xor a + ld [wEvolutionCanceled], a + + ld a, 7 * 7 + ld [wEvolutionPicOffset], a + call .ReplaceFrontpic + + ld a, [wEvolutionNewSpecies] +.return + ld [wPlayerHPPal], a + + ld a, [wPlayerHPPal] + call PlayCry + + ld c, FALSE + call .GetSGBLayout + + call .PlayEvolvedSFX + + pop af + ld [wCurSpecies], a + pop bc + pop de + pop hl + + ld a, [wEvolutionCanceled] + and a + ret z + + scf + ret + +.cancel_evo + pop bc + ld a, TRUE + ld [wEvolutionCanceled], a + + ld a, [wEvolutionOldSpecies] + jr .return + +.GetSGBLayout: + ld b, SGB_EVOLUTION + jp GetSGBLayout + +.PlaceFrontpic: + call GetBaseData + hlcoord 7, 2 + jp PrepMonFrontpic + +.Flash: + ld a, 7 * 7 ; previous stage + ld [wEvolutionPicOffset], a + call .ReplaceFrontpic + ld a, -7 * 7 ; new stage + ld [wEvolutionPicOffset], a + call .ReplaceFrontpic + dec b + jr nz, .Flash + ret + +.ReplaceFrontpic: + push bc + xor a + ldh [hBGMapMode], a + hlcoord 7, 2 + lb bc, 7, 7 + ld de, SCREEN_WIDTH - 7 +.loop1 + push bc +.loop2 + ld a, [wEvolutionPicOffset] + add [hl] + ld [hli], a + dec c + jr nz, .loop2 + pop bc + add hl, de + dec b + jr nz, .loop1 + ld a, $1 + ldh [hBGMapMode], a + call WaitBGMap + pop bc + ret + +.WaitFrames_CheckPressedB: + call DelayFrame + push bc + call GetJoypadDebounced + ldh a, [hJoySum] + pop bc + and B_BUTTON + jr nz, .pressed_b +.loop3 + dec c + jr nz, .WaitFrames_CheckPressedB + and a + ret + +.pressed_b + ld a, [wForceEvolution] + and a + jr nz, .loop3 + scf + ret + +.PlayEvolvedSFX: + ret + + ld a, [wEvolutionCanceled] + and a + ret nz + ldh a, [rOBP0] + push af + ld a, %11100100 + ldh [rOBP0], a + callfar ClearSpriteAnims + ld de, .GFX + ld hl, vChars0 + lb bc, BANK(.GFX), 2 + call Request2bpp + xor a + ld [wJumptableIndex], a +.loop4 + call .balls_of_light + jr nc, .done + call .AnimateBallsOfLight + jr .loop4 + +.done + ld c, 16 ; half as much as final +.loop5 + call .AnimateBallsOfLight + dec c + jr nz, .loop5 + pop af + ldh [rOBP0], a + ret + +.balls_of_light + ld hl, wJumptableIndex + ld a, [hl] + cp 64 + ret nc + inc [hl] + depixel 9, 11 + ld a, SPRITE_ANIM_OBJ_EVOLUTION_BALL_OF_LIGHT + call InitSpriteAnimStruct + ld hl, SPRITEANIMSTRUCT_TILE_ID + add hl, bc + ld [hl], 0 + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + ld a, [wJumptableIndex] + and %1110 + sla a + sla a + ld [hl], a + scf + ret + +.AnimateBallsOfLight: + push bc + callfar PlaySpriteAnimations + pop bc + call DelayFrame + ret + +.GFX: + INCBIN "gfx/evo/bubbles.2bpp" diff --git a/engine/movie/oak_speech.asm b/engine/movie/oak_speech.asm index 3390109..b4a0338 100644 --- a/engine/movie/oak_speech.asm +++ b/engine/movie/oak_speech.asm @@ -281,7 +281,7 @@ GivePokemon:: ld [wCurPartySpecies], a ld a, b ld [wCurPartyLevel], a - predef Functiond886 + predef TryAddMonToParty ret AddRandomPokemonToBox: @@ -298,7 +298,7 @@ AddRandomPokemonToBox: callfar LoadEnemyMon ld a, [wTempEnemyMonSpecies] ld [wCurPartySpecies], a - callfar Functiondd5c + callfar SendMonIntoBox pop af dec a jr nz, .loop diff --git a/engine/dumps/bank02.asm b/engine/overworld/player_object.asm similarity index 59% rename from engine/dumps/bank02.asm rename to engine/overworld/player_object.asm index 6d7162c..1faac8e 100755 --- a/engine/dumps/bank02.asm +++ b/engine/overworld/player_object.asm @@ -1,6 +1,6 @@ INCLUDE "constants.asm" -SECTION "engine/dumps/bank02.asm@_SpawnPlayer", ROMX +SECTION "engine/overworld/player_object.asm", ROMX _SpawnPlayer:: ld a, PLAYER @@ -669,146 +669,7 @@ ObjectWalkToPlayer:: call ComputePathToWalkToDestination ret -_LoadMinorObjectGFX:: - ld hl, wQueuedMinorObjectGFX - push hl - ld a, [hl] - ld l, a - ld h, 0 - ld de, .MinorObjectGFX - add hl, hl - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - pop hl - push de - ret - -.MinorObjectGFX: - dw .LoadNull - dw .LoadJumpShadow - dw .LoadUnknownBouncingOrb - dw .LoadShockEmote - dw .LoadQuestionEmote - dw .LoadHappyEmote - dw .LoadBoulderDust - dw .LoadGrampsSpriteStandPt0 - dw .LoadGrampsSpriteStandPt1 - dw .LoadGrampsSpriteWalkPt0 - dw .LoadGrampsSpriteWalkPt1 - dw .LoadClefairySpriteStandPt0 - dw .LoadClefairySpriteStandPt1 - dw .LoadClefairySpriteWalkPt0 - dw .LoadClefairySpriteWalkPt1 - -.FarCopy: - ld a, c - ld [wVBCopyFarSrcBank], a - ld a, l - ld [wVBCopyFarSrc], a - ld a, h - ld [wVBCopyFarSrc+1], a -.ContinueFarCopyNewDst: - ld a, e - ld [wVBCopyFarDst], a - ld a, d - ld [wVBCopyFarDst+1], a -.ContinueFarCopy: - ld a, b - ld [wVBCopyFarSize], a - ret - -.LoadNull: - ret - -.LoadShockEmote: - ld hl, ShockEmoteGFX - jr .load_emote -.LoadQuestionEmote: - ld hl, QuestionEmoteGFX - jr .load_emote -.LoadHappyEmote: - ld hl, HappyEmoteGFX -.load_emote: - ld de, vChars1 tile $78 - ld b, (HappyEmoteGFX.end - HappyEmoteGFX) / LEN_2BPP_TILE - ld c, BANK(EmoteGFX) - jp .FarCopy - -.LoadJumpShadow: - ld [hl], $00 - ld hl, JumpShadowGFX - ld de, vChars1 tile $7c - ld b, (JumpShadowGFX.end - JumpShadowGFX) / LEN_2BPP_TILE - ld c, BANK(JumpShadowGFX) - jp .FarCopy - -.LoadUnknownBouncingOrb: - ld [hl], $00 - ld hl, UnknownBouncingOrbGFX - ld de, vChars1 tile $7c - ld b, (UnknownBouncingOrbGFX.end - UnknownBouncingOrbGFX) / LEN_2BPP_TILE - ld c, BANK(UnknownBouncingOrbGFX) - jp .FarCopy - -.LoadBoulderDust: - ld [hl], $00 - ld hl, BoulderDustGFX - ld de, vChars1 tile $7c - ld b, (BoulderDustGFX.end - BoulderDustGFX) / LEN_2BPP_TILE - ld c, BANK(BoulderDustGFX) - jp .FarCopy - -.LoadGrampsSpriteStandPt0: - inc [hl] - ld hl, GrampsSpriteGFX - ld de, vChars0 - ld b, (GrampsSpriteGFX.end - GrampsSpriteGFX) / LEN_2BPP_TILE / 4 - ld c, BANK(GrampsSpriteGFX) - jp .FarCopy - -.LoadGrampsSpriteStandPt1: - inc [hl] - ld b, (GrampsSpriteGFX.end - GrampsSpriteGFX) / LEN_2BPP_TILE / 4 - jp .ContinueFarCopy - -.LoadGrampsSpriteWalkPt0: - inc [hl] - ld de, vChars1 - ld b, (GrampsSpriteGFX.end - GrampsSpriteGFX) / LEN_2BPP_TILE / 4 - jp .ContinueFarCopyNewDst - -.LoadGrampsSpriteWalkPt1: - ld [hl], $00 - ld b, (GrampsSpriteGFX.end - GrampsSpriteGFX) / LEN_2BPP_TILE / 4 - jp .ContinueFarCopy - -.LoadClefairySpriteStandPt0: - inc [hl] - ld hl, ClefairySpriteGFX - ld de, vChars0 - ld b, (ClefairySpriteGFX.end - ClefairySpriteGFX) / LEN_2BPP_TILE / 4 - ld c, BANK(ClefairySpriteGFX) - jp .FarCopy - -.LoadClefairySpriteStandPt1: - inc [hl] - ld b, (ClefairySpriteGFX.end - ClefairySpriteGFX) / LEN_2BPP_TILE / 4 - jp .ContinueFarCopy - -.LoadClefairySpriteWalkPt0: - inc [hl] - ld de, vChars1 - ld b, (ClefairySpriteGFX.end - ClefairySpriteGFX) / LEN_2BPP_TILE / 4 - jp .ContinueFarCopyNewDst - -.LoadClefairySpriteWalkPt1: - ld [hl], $00 - ld b, (ClefairySpriteGFX.end - ClefairySpriteGFX) / LEN_2BPP_TILE / 4 - jp .ContinueFarCopy - -SECTION "engine/dumps/bank02.asm@QueueFollowerFirstStep", ROMX +SECTION "engine/overworld/player_object.asm@QueueFollowerFirstStep", ROMX QueueFollowerFirstStep:: call .QueueFirstStep @@ -873,322 +734,3 @@ QueueFollowerFirstStep:: _Sine:: ld a, e calc_sine_wave - -TownMap:: - call InitTownMap - callfar ClearSpriteAnims - call TownMap_InitPlayerIcon - call WaitBGMap - call SetPalettes -.loop - call DelayFrame - call GetJoypadDebounced - callfar PlaySpriteAnimations - ld hl, hJoyDown - ld a, [hl] - and A_BUTTON | B_BUTTON - jr z, .loop - ret - -FlyMap:: - ld hl, hInMenu - ld a, [hl] - push af - ld [hl], 1 - call InitTownMap - callfar ClearSpriteAnims - call TownMap_InitPlayerIcon - call FlyMap_InitPidgeyIcon - ld hl, wFlyIconAnimStructPointer - ld [hl], c - inc hl - ld [hl], b - hlcoord 1, 15 - ld de, ChooseADestinationText - call PlaceString - call WaitBGMap - call SetPalettes - xor a - ld [wFlyDestination], a -.loop - call DelayFrame - call GetJoypadDebounced - callfar PlaySpriteAnimations - ld hl, hJoyDown - ld a, [hl] - and B_BUTTON - jr nz, .cancel - ld a, [hl] - and A_BUTTON - jr nz, .fly - call .HandleDPad - callfar GetFlyPointMapLocation - ld d, 0 - ld hl, LandmarkPositions - add hl, de - add hl, de - ld d, [hl] - inc hl - ld e, [hl] - ld hl, wFlyIconAnimStructPointer - ld c, [hl] - inc hl - ld b, [hl] - ld hl, SPRITEANIMSTRUCT_XCOORD - add hl, bc - ld [hl], e - ld hl, SPRITEANIMSTRUCT_YCOORD - add hl, bc - ld [hl], d - jr .loop - -.cancel - ld a, -1 - ld [wFlyDestination], a -.fly - pop af - ldh [hInMenu], a - ret - -.HandleDPad: - ld a, [wFlyDestination] - ld l, a - ld h, 0 - add hl, hl - add hl, hl - ld de, FlyPointPaths - add hl, de - ld de, hJoySum - ld a, [de] - and D_UP - jr nz, .get_point - inc hl - ld a, [de] - and D_DOWN - jr nz, .get_point - inc hl - ld a, [de] - and D_LEFT - jr nz, .get_point - inc hl - ld a, [de] - and D_RIGHT - jr nz, .get_point - ret -.get_point - ld a, [hl] - cp -1 - ret z - ld [wFlyDestination], a - ret - -ChooseADestinationText: - db "とびさき を えらんでください@" - -Pokedex_GetArea: - ld a, [wNestIconBlinkCounter] - push af - xor a - ld [wNestIconBlinkCounter], a - - call InitTownMap - ld de, PokedexNestIconGFX - ld hl, vChars0 tile $7f - lb bc, BANK(PokedexNestIconGFX), 1 - call Request1bpp - - call GetPokemonName - hlcoord 4, 15 - call PlaceString - - hlcoord 9, 15 - ld de, .String_SNest - call PlaceString - - call WaitBGMap - call SetPalettes - xor a - ldh [hBGMapMode], a - ld hl, wTileMap - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - xor a - call ByteFill - callfar FindNest -.loop - call .PlaceNest - call GetJoypadDebounced - ldh a, [hJoyDown] - and A_BUTTON | B_BUTTON - jr nz, .done - - ld hl, wNestIconBlinkCounter - inc [hl] - call DelayFrame - jr .loop -.done - pop af - ld [wNestIconBlinkCounter], a - ret - -.String_SNest: - db "の すみか@" - -.PlaceNest: - ld a, [wNestIconBlinkCounter] - and $10 - jr z, .done_nest - - ld de, wTileMap - ld hl, wShadowOAMSprite00 -.nestloop - ld a, [de] - and a - ret z - - push de - push hl - ld e, a - ld d, $00 - ld hl, LandmarkPositions - add hl, de - add hl, de - ld e, l - ld d, h - - ; load into OAM - pop hl -; X position - ld a, [de] - inc de - sub 4 - ld [hli], a -; Y position - ld a, [de] - inc de - sub 4 - ld [hli], a -; Nest icon -> Tile ID - ld a, $7f - ld [hli], a -; Blank out attributes - xor a - ld [hli], a - - pop de - inc de - jr .nestloop -.done_nest - call ClearSprites - ret - -InitTownMap: - call ClearBGPalettes - call ClearTileMap - call UpdateSprites - call DisableLCD - - ld hl, TownMapGFX - ld de, vTilesetEnd - ld bc, TownMapGFX.End - TownMapGFX - ld a, BANK(TownMapGFX) - call FarCopyData - - ld hl, wTileMap - call DecompTownMapTilemap - hlcoord 0, 13 - ld b, 3 - ld c, 18 - call DrawTextBox - - ld a, 3 - call UpdateSoundNTimes - call EnableLCD - ld b, SGB_TOWN_MAP - call GetSGBLayout - ret - -DecompTownMapTilemap: - ld de, TownMapTilemap -.loop - ld a, [de] - and a - ret z - - ld b, a - inc de - ld a, [de] - ld c, a - ld a, b - add $60 -.keep_placing_tile - ld [hli], a - dec c - jr nz, .keep_placing_tile - inc de - jr .loop - -TownMap_InitPlayerIcon: - ld de, GoldSpriteGFX - ld hl, vChars0 - lb bc, BANK(GoldSpriteGFX), $04 - call Request2bpp - - ld de, GoldSpriteGFX + 12 tiles - ld hl, vChars0 tile $04 - lb bc, BANK(GoldSpriteGFX), $04 - call Request2bpp - - depixel 0, 0 - ld a, SPRITE_ANIM_OBJ_MAP_CHARACTER_ICON - call InitSpriteAnimStruct - - ld hl, SPRITEANIMSTRUCT_TILE_ID - add hl, bc - ld [hl], $00 - - push bc - ld a, [wMapGroup] - ld b, a - ld a, [wMapId] - ld c, a - call GetWorldMapLocation - - ld e, a - ld d, $00 - ld hl, LandmarkPositions - add hl, de - add hl, de - ld d, [hl] - inc hl - ld e, [hl] - pop bc - ld hl, SPRITEANIMSTRUCT_XCOORD - add hl, bc - ld [hl], e - ld hl, SPRITEANIMSTRUCT_YCOORD - add hl, bc - ld [hl], d - ret - -FlyMap_InitPidgeyIcon: - ld de, PidgeySpriteGFX - ld hl, vChars0 tile $08 - lb bc, BANK(PidgeySpriteGFX), 4 - call Request2bpp - - ld de, PidgeySpriteGFX + 12 tiles - ld hl, vChars0 tile $0c - lb bc, BANK(PidgeySpriteGFX), 4 - call Request2bpp - - depixel 0, 0 - ld a, SPRITE_ANIM_OBJ_MAP_CHARACTER_ICON - call InitSpriteAnimStruct - - ld hl, SPRITEANIMSTRUCT_TILE_ID - add hl, bc - ld [hl], 8 - ret - -TownMapTilemap: -INCBIN "gfx/trainer_gear/town_map.tilemap.rle" diff --git a/engine/overworld/player_step.asm b/engine/overworld/player_step.asm new file mode 100644 index 0000000..d8e0d62 --- /dev/null +++ b/engine/overworld/player_step.asm @@ -0,0 +1,565 @@ +INCLUDE "constants.asm" + +SECTION "engine/overworld/player_step.asm", ROMX + +; TODO: How does this differ from _HandlePlayerStep, aside from where it's called from? +_HandlePlayerStep_Limited: + ld a, [wPlayerStepFlags] + and a + ret z + bit PLAYERSTEP_START_F, a + jr nz, .start + bit PLAYERSTEP_STOP_F, a + jr nz, .update_player_coords + bit PLAYERSTEP_CONTINUE_F, a + jr nz, HandlePlayerStep_Finish + ret + +.start + jr ._start + +.unreferenced_d4fa + call UpdatePlayerCoords + callfar EmptyFunction8261 + +._start + ld a, 4 + ld [wHandlePlayerStep], a + ldh a, [hOverworldFlashlightEffect] + and a + jr nz, .update_overworld_map + call UpdateOverworldMap_Old + jr HandlePlayerStep_Finish + +.update_overworld_map + call UpdateOverworldMap + jr HandlePlayerStep_Finish + +.update_player_coords + call UpdatePlayerCoords + jr HandlePlayerStep_Finish + +UpdatePlayerCoords: + ld a, [wPlayerStepDirection] + and a + jr nz, .check_step_down + ld hl, wYCoord + inc [hl] + ret + +.check_step_down + cp UP + jr nz, .check_step_left + ld hl, wYCoord + dec [hl] + ret + +.check_step_left + cp LEFT + jr nz, .check_step_right + ld hl, wXCoord + dec [hl] + ret + +.check_step_right + cp RIGHT + ret nz + ld hl, wXCoord + inc [hl] + ret + +HandlePlayerStep_Finish: + call HandlePlayerStep + ld a, [wPlayerStepVectorX] + ld d, a + ld a, [wPlayerStepVectorY] + ld e, a + call ScrollNPCs + call ScrollMinorObjects + ldh a, [hSCX] + add d + ldh [hSCX], a + ldh a, [hSCY] + add e + ldh [hSCY], a + ret + +ScrollNPCs: + ld bc, wObjectStructs + xor a +.loop + ldh [hMapObjectIndex], a + ld hl, OBJECT_SPRITE + add hl, bc + ld a, [hl] + and a + jr z, .skip + ld hl, OBJECT_FLAGS1 + add hl, bc + bit CENTERED_OBJECT_F, [hl] + jr nz, .skip + + ld hl, OBJECT_SPRITE_X + add hl, bc + ld a, [hl] + sub d + ld [hl], a + ld hl, OBJECT_SPRITE_Y + add hl, bc + ld a, [hl] + sub e + ld [hl], a +.skip + ld hl, OBJECT_LENGTH + add hl, bc + ld b, h + ld c, l + ldh a, [hMapObjectIndex] + inc a + cp NUM_OBJECT_STRUCTS + jr nz, .loop + ret + +ScrollMinorObjects: + ld bc, wMinorObjects + ld a, 1 +.loop + ldh [hMapObjectIndex], a + ld hl, MINOR_OBJECT_PARENT_OBJECT + add hl, bc + ld a, [wCenteredObject] + inc a + cp [hl] + jr z, .skip + ld hl, MINOR_OBJECT_X_POS + add hl, bc + ld a, [hl] + sub d + ld [hl], a + ld hl, MINOR_OBJECT_Y_POS + add hl, bc + ld a, [hl] + sub e + ld [hl], a + +.skip + ld hl, MINOR_OBJECT_LENGTH + add hl, bc + ld b, h + ld c, l + ldh a, [hMapObjectIndex] + inc a + cp NUM_MINOR_OBJECTS + 1 + jr nz, .loop + ret + +HandlePlayerStep:: + ld hl, wHandlePlayerStep + ld a, [hl] + and a + ret z + dec [hl] + ld a, [hl] + add a + ld e, a + ld d, 0 + ld hl, .Jumptable + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +.Jumptable: + dw RefreshTiles + dw Functionc9c1 + dw BufferScreen + dw .fail + dw .fail + dw .fail + dw .fail + dw .fail + dw .fail + dw .fail + dw .fail + +.fail + ret + +Functionc9c1: + callfar _Functionc9c1 + ret + +UpdateOverworldMap_Old: + ld a, [wPlayerStepDirection] + and a ; DOWN + jr z, .step_down + cp UP + jr z, .step_up + cp LEFT + jr z, .step_left + cp RIGHT + jr z, .step_right + ret + +.step_down + call ScrollOverworldMapDown + call LoadMapPart + call ScheduleSouthRowRedraw + ret + +.step_up + call ScrollOverworldMapUp + call LoadMapPart + call ScheduleNorthRowRedraw + ret + +.step_left + call ScrollOverworldMapLeft + call LoadMapPart + call ScheduleWestColumnRedraw + ret + +.step_right + call ScrollOverworldMapRight + call LoadMapPart + call ScheduleEastColumnRedraw + ret + +ScrollOverworldMapDown: + ld a, [wBGMapAnchor] + add BG_MAP_WIDTH * 2 + ld [wBGMapAnchor], a + jr nc, .no_overflow + ld a, [wBGMapAnchor + 1] + inc a + and %11 + or HIGH(vBGMap0) + ld [wBGMapAnchor + 1], a +.no_overflow + ld hl, wMetatileNextY + inc [hl] + ld a, [hl] + cp 2 + jr nz, .done + ld [hl], 0 + call .ScrollMapDataDown +.done + ret + +.ScrollMapDataDown: + ld hl, wOverworldMapAnchor + ld a, [wMapWidth] + add 3 * 2 ; surrounding tiles + add [hl] + ld [hli], a + ret nc + inc [hl] + ret + +ScrollOverworldMapUp: + ld a, [wBGMapAnchor] + sub BG_MAP_WIDTH * 2 + ld [wBGMapAnchor], a + jr nc, .not_underflowed + ld a, [wBGMapAnchor+1] + dec a + and %11 + or HIGH(vBGMap0) + ld [wBGMapAnchor+1], a +.not_underflowed + ld hl, wMetatileNextY + dec [hl] + ld a, [hl] + cp -1 + jr nz, .done_up + ld [hl], 1 + call .ScrollMapDataUp +.done_up + ret + +.ScrollMapDataUp: + ld hl, wOverworldMapAnchor + ld a, [wMapWidth] + add 3 * 2 + ld b, a + ld a, [hl] + sub b + ld [hli], a + ret nc + dec [hl] + ret + +ScrollOverworldMapLeft: + ld a, [wBGMapAnchor] + ld e, a + and ~(BG_MAP_WIDTH - 1) + ld d, a + ld a, e + sub 2 + maskbits BG_MAP_WIDTH - 1 + or d + ld [wBGMapAnchor], a + ld hl, wMetatileNextX + dec [hl] + ld a, [hl] + cp -1 + jr nz, .done_left + ld [hl], 1 + call .ScrollMapDataLeft +.done_left + ret + +.ScrollMapDataLeft: + ld hl, wOverworldMapAnchor + ld a, [hl] + sub 1 + ld [hli], a + ret nc + dec [hl] + ret + +ScrollOverworldMapRight: + ld a, [wBGMapAnchor] + ld e, a + and ~(BG_MAP_WIDTH - 1) + ld d, a + ld a, e + add 2 + maskbits BG_MAP_WIDTH - 1 + or d + ld [wBGMapAnchor], a + ld hl, wMetatileNextX + inc [hl] + ld a, [hl] + cp 2 + jr nz, .done_right + ld [hl], $00 + call .ScrollMapDataRight +.done_right + ret + +.ScrollMapDataRight: + ld hl, wOverworldMapAnchor + ld a, [hl] + add 1 + ld [hli], a + ret nc + inc [hl] + ret + +_HandlePlayerStep: + ld a, [wPlayerStepFlags] + and a + ret z + bit PLAYERSTEP_START_F, a + jr nz, .update_overworld_map + bit PLAYERSTEP_STOP_F, a + jr nz, .update_player_coords + bit PLAYERSTEP_CONTINUE_F, a + jp nz, HandlePlayerStep_Finish + ret + +.update_overworld_map + ld a, 4 + ld [wHandlePlayerStep], a + call UpdateOverworldMap + jp HandlePlayerStep_Finish + +.update_player_coords + call UpdatePlayerCoords + jp HandlePlayerStep_Finish + +UpdateOverworldMap: + ld a, [wPlayerStepDirection] + and a + jr z, .step_down + cp UP + jr z, .step_up + cp LEFT + jr z, .step_left + cp RIGHT + jr z, .step_right + ret + +.step_down + call ScrollOverworldMapDown + call LoadMapPart + ld a, 2 + call ScrollOverworldFlashlight + ret +.step_up + call ScrollOverworldMapUp + call LoadMapPart + ld a, 1 + call ScrollOverworldFlashlight + ret +.step_left + call ScrollOverworldMapLeft + call LoadMapPart + ld a, 3 + call ScrollOverworldFlashlight + ret +.step_right + call ScrollOverworldMapRight + call LoadMapPart + ld a, 4 + call ScrollOverworldFlashlight + ret + +ScrollOverworldFlashlight:: + push af + call .GetFlashlightVariables + call .GetFlashlightSize + pop af + add 2 + ldh [hRedrawRowOrColumnMode], a + ret + +.GetFlashlightVariables: + dec a + ld l, a + ld h, 0 + add hl, hl + add hl, hl + add hl, hl + ldh a, [hOverworldFlashlightEffect] + dec a + swap a ; * 16 + sla a ; * 2 + ld e, a + ld d, 0 + add hl, de + ld de, .FlashlightColumns + add hl, de + call .ReadFlashlightDst + ld a, e + ld [wRedrawFlashlightDst0], a + ld a, d + ld [wRedrawFlashlightDst0 + 1], a + + call .GetFlashlightSrc + ld a, e + ld [wRedrawFlashlightSrc0], a + ld a, d + ld [wRedrawFlashlightSrc0 + 1], a + + call .ReadFlashlightDst + ld a, e + ld [wRedrawFlashlightBlackDst0], a + ld a, d + ld [wRedrawFlashlightBlackDst0 + 1], a + + call .ReadFlashlightDst + ld a, e + ld [wRedrawFlashlightDst1], a + ld a, d + ld [wRedrawFlashlightDst1 + 1], a + + call .GetFlashlightSrc + ld a, e + ld [wRedrawFlashlightSrc1], a + ld a, d + ld [wRedrawFlashlightSrc1 + 1], a + + call .ReadFlashlightDst + ld a, e + ld [wRedrawFlashlightBlackDst1], a + ld a, d + ld [wRedrawFlashlightBlackDst1 + 1], a + ret + +; The positions of the columns drawn. +; TODO: Wrap these in neat macros. +.FlashlightColumns: + db $02, $03, $02, $11, $02, $02, $02, $10 ; up + db $02, $0e, $02, $00, $02, $0f, $02, $01 ; down + db $03, $02, $11, $02, $02, $02, $10, $02 ; left + db $0e, $02, $00, $02, $0f, $02, $01, $02 ; right + + db $04, $05, $04, $0f, $04, $04, $04, $0e + db $04, $0c, $04, $02, $04, $0d, $04, $03 + db $05, $04, $0f, $04, $04, $04, $0e, $04 + db $0c, $04, $02, $04, $0d, $04, $03, $04 + + db $06, $07, $06, $0d, $06, $06, $06, $0c + db $06, $0a, $06, $04, $06, $0b, $06, $05 + db $07, $06, $0d, $06, $06, $06, $0c, $06 + db $0a, $06, $04, $06, $0b, $06, $05, $06 + + db $08, $09, $08, $0b, $08, $08, $08, $0a + db $08, $08, $08, $06, $08, $09, $08, $07 + db $09, $08, $0b, $08, $08, $08, $0a, $08 + db $08, $08, $06, $08, $09, $08, $07, $08 + +.ReadFlashlightDst: + ld c, [hl] + inc hl + ld b, [hl] + inc hl + push hl + push bc + ld a, [wBGMapAnchor] + ld e, a + ld a, [wBGMapAnchor + 1] + ld d, a +.row_loop + ld a, BG_MAP_WIDTH + add e + ld e, a + jr nc, .no_overflow + inc d +.no_overflow + ld a, d + and %11 + or HIGH(vBGMap0) ; equivalent of add $98 + ld d, a + dec b + jr nz, .row_loop +.tile_loop + ld a, e + inc a + maskbits BG_MAP_WIDTH - 1 ; only works if BG_MAP_WIDTH is 2^n + ld b, a + ld a, e + and ~(BG_MAP_WIDTH - 1) + or b + ld e, a + dec c + jr nz, .tile_loop + pop bc + pop hl + ret + +.GetFlashlightSrc: + push hl + ld hl, wTileMap + ld de, SCREEN_WIDTH +.loop + ld a, b + and a + jr z, .last_row + add hl, de + dec b + jr .loop + +.last_row + add hl, bc + ld e, l + ld d, h + pop hl + ret + +.GetFlashlightSize: + ldh a, [hOverworldFlashlightEffect] + dec a + ld l, a + ld h, 0 + ld de, .Sizes + add hl, de + ld a, [hl] + ld [wRedrawFlashlightWidthHeight], a + ret + +.Sizes: + db 7, 5, 3, 1 diff --git a/engine/overworld/spawn_points.asm b/engine/overworld/spawn_points.asm index e19eb54..2ddee0b 100755 --- a/engine/overworld/spawn_points.asm +++ b/engine/overworld/spawn_points.asm @@ -2,6 +2,21 @@ INCLUDE "constants.asm" SECTION "engine/overworld/spawn_points.asm", ROMX +GetFlyPointMapLocation: + ld a, [wFlyDestination] + ld l, a + ld h, $00 + add hl, hl + add hl, hl + ld de, SpawnPoints + add hl, de + ld b, [hl] ; SpawnPoints + (wFlyDestination * 4) + inc hl + ld c, [hl] + call GetWorldMapLocation + ld e, a + ret + LoadSpawnPoint: ; loads the spawn point in wDefaultSpawnPoint push hl diff --git a/engine/pokedex/display_dex_entry.asm b/engine/pokedex/display_dex_entry.asm new file mode 100644 index 0000000..43a3056 --- /dev/null +++ b/engine/pokedex/display_dex_entry.asm @@ -0,0 +1,138 @@ +INCLUDE "constants.asm" + +SECTION "engine/pokedex/display_dex_entry.asm", ROMX + +; Meters +DEF POKEDEX_m EQU $60 +; Kilograms +DEF POKEDEX_k EQU $61 +DEF POKEDEX_g EQU $62 + +_DisplayDexEntry: + hlcoord 9, 6 + ld de, PokedexText_HeightWeight + call PlaceString + call GetPokemonName + hlcoord 9, 2 + call PlaceString + ld hl, PokedexEntryPointers1 + ld a, [wTempSpecies] + cp DEX_VOLTORB + jr c, .got_dex_entries + sub DEX_VOLTORB - 1 + ld hl, PokedexEntryPointers2 + +.got_dex_entries + dec a + ld e, a + ld d, 0 + add hl, de + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + hlcoord 9, 4 + call PlaceString + ld h, b + ld l, c + push de + ld de, PokedexText_Pokemon + call PlaceString + hlcoord 2, 8 + ld a, "№" + ld [hli], a + ld a, "." + ld [hli], a + ld de, wTempSpecies + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 + call PrintNumber +; Return if species isn't caught + callfar Pokedex_CheckCaught + push af + ld a, [wCurPartySpecies] + ld [wCurSpecies], a + pop af + pop de + ret z + + inc de + ld a, [de] + and a + jr z, .skip_height + + hlcoord 13, 6 + lb bc, 1, 3 + call PrintNumber + + hlcoord 14, 6 + ld a, [de] + cp 10 + jr nc, .less_than_1_meter + ld [hl], "0" + +.less_than_1_meter +; Shift last digit to the right and put decimal point in its place. + inc hl + ld a, [hli] + ld [hld], a + ld [hl], "." + +.skip_height + inc de + ld a, [de] + ld b, a + inc de + ld a, [de] + or b + push de + jr z, .skip_weight + + ld hl, hPokedexTempWeight + ld a, [hl] + push af + ld a, [de] + ld [hli], a + ld a, [hl] + push af + dec de + ld a, [de] + ld [hl], a + ld de, hPokedexTempWeight + hlcoord 12, 8 + lb bc, 2, 4 + call PrintNumber + + hlcoord 14, 8 + ldh a, [hPokedexTempWeight + 1] + sub 10 + ldh a, [hPokedexTempWeight] + sbc 0 + jr nc, .less_than_1_kilogram + ld [hl], "0" + +.less_than_1_kilogram +; Shift last digit to the right and put decimal point in its place. + inc hl + ld a, [hli] + ld [hld], a + ld [hl], "." + + pop af + ldh [hPokedexTempWeight + 1], a + pop af + ldh [hPokedexTempWeight], a +.skip_weight + pop de + inc de + hlcoord 1, 11 + call PlaceString + ret + +PokedexText_HeightWeight: + db "たかさ  ???", POKEDEX_m + next "おもさ  ???", POKEDEX_k, POKEDEX_g + text_end + +PokedexText_Pokemon: + db "#" ; "Pokémon" (ポケモン) + text_end diff --git a/engine/dumps/bank10.asm b/engine/pokedex/pokedex.asm similarity index 55% rename from engine/dumps/bank10.asm rename to engine/pokedex/pokedex.asm index 9fb8c49..101961b 100644 --- a/engine/dumps/bank10.asm +++ b/engine/pokedex/pokedex.asm @@ -41,9 +41,9 @@ DEF NEXT_MENU_F EQU 7 const SELECT_BUTTON_MENU const A_BUTTON_MENU_UNOWN -SECTION "engine/dumps/bank10.asm", ROMX +SECTION "engine/pokedex/pokedex.asm", ROMX -Pokedex: +Pokedex:: ld hl, wOptions ld a, [hl] push af @@ -1719,7 +1719,7 @@ Pokedex_CopyButtonsGFX: call Get2bpp ret -NewPokedexEntry: +NewPokedexEntry:: call LowVolume call ClearBGPalettes call ClearTileMap @@ -1773,1282 +1773,3 @@ _NewPokedexEntry: jr z, .wait_for_input ret -; Takes the DEX_* index stored in wTempSpecies, -; finds its MON_* in the Pokered_MonIndices table, -; and returns its index in wTempSpecies. -ConvertMon_2to1:: - push bc - push hl - ld a, [wTempSpecies] - ld b, a - ld c, $00 - ld hl, Pokered_MonIndices -.loop - inc c - ld a, [hli] - cp b - jr nz, .loop - ld a, c - ld [wTempSpecies], a - pop hl - pop bc - ret - -; Takes the MON_* value stored in wTempSpecies -; and returns the corresponding DEX_* value from Pokered_MonIndices in wTempSpecies. -ConvertMon_1to2:: - push bc - push hl - ld a, [wTempSpecies] - dec a - ld hl, Pokered_MonIndices - ld b, $00 - ld c, a - add hl, bc - ld a, [hl] - ld [wTempSpecies], a - pop hl - pop bc - ret - -Pokered_MonIndices:: -; BUG: Notice anything odd about this list? There are only 250 entries; Riifi is missing! -; Presumably, it was such a recent addition that it hadn't yet been included in this list. -; This causes ConvertMon_2to1 to search out of bounds for byte $FB, eventually finding it and loading Nidorina's cry. - -; Note that in the final game, Celebi is also missing from this list, meaning that they never actually fixed this -; before they switched the cry order to match the Pokédex order. - db DEX_RHYDON ; 01 - db DEX_KANGASKHAN ; 02 - db DEX_NIDORAN_M ; 03 - db DEX_CLEFAIRY ; 04 - db DEX_SPEAROW ; 05 - db DEX_VOLTORB ; 06 - db DEX_NIDOKING ; 07 - db DEX_SLOWBRO ; 08 - db DEX_IVYSAUR ; 09 - db DEX_EXEGGUTOR ; 0a - db DEX_LICKITUNG ; 0b - db DEX_EXEGGCUTE ; 0c - db DEX_GRIMER ; 0d - db DEX_GENGAR ; 0e - db DEX_NIDORAN_F ; 0f - db DEX_NIDOQUEEN ; 10 - - db DEX_CUBONE ; 11 - db DEX_RHYHORN ; 12 - db DEX_LAPRAS ; 13 - db DEX_ARCANINE ; 14 - db DEX_MEW ; 15 - db DEX_GYARADOS ; 16 - db DEX_SHELLDER ; 17 - db DEX_TENTACOOL ; 18 - db DEX_GASTLY ; 19 - db DEX_SCYTHER ; 1a - db DEX_STARYU ; 1b - db DEX_BLASTOISE ; 1c - db DEX_PINSIR ; 1d - db DEX_TANGELA ; 1e - db DEX_KAPOERER ; 1f - db DEX_PUDIE ; 20 - - db DEX_GROWLITHE ; 21 - db DEX_ONIX ; 22 - db DEX_FEAROW ; 23 - db DEX_PIDGEY ; 24 - db DEX_SLOWPOKE ; 25 - db DEX_KADABRA ; 26 - db DEX_GRAVELER ; 27 - db DEX_CHANSEY ; 28 - db DEX_MACHOKE ; 29 - db DEX_MRMIME ; 2a - db DEX_HITMONLEE ; 2b - db DEX_HITMONCHAN ; 2c - db DEX_ARBOK ; 2d - db DEX_PARASECT ; 2e - db DEX_PSYDUCK ; 2f - db DEX_DROWZEE ; 30 - - db DEX_GOLEM ; 31 - db DEX_HANEKO ; 32 - db DEX_MAGMAR ; 33 - db DEX_TAIL ; 34 - db DEX_ELECTABUZZ ; 35 - db DEX_MAGNETON ; 36 - db DEX_KOFFING ; 37 - db DEX_POPONEKO ; 38 - db DEX_MANKEY ; 39 - db DEX_SEEL ; 3a - db DEX_DIGLETT ; 3b - db DEX_TAUROS ; 3c - db DEX_WATANEKO ; 3d - db DEX_BARIRINA ; 3e - db DEX_LIP ; 3f - db DEX_FARFETCHD ; 40 - - db DEX_VENONAT ; 41 - db DEX_DRAGONITE ; 42 - db DEX_ELEBABY ; 43 - db DEX_BOOBY ; 44 - db DEX_KIREIHANA ; 45 - db DEX_DODUO ; 46 - db DEX_POLIWAG ; 47 - db DEX_JYNX ; 48 - db DEX_MOLTRES ; 49 - db DEX_ARTICUNO ; 4a - db DEX_ZAPDOS ; 4b - db DEX_DITTO ; 4c - db DEX_MEOWTH ; 4d - db DEX_KRABBY ; 4e - db DEX_TSUBOMITTO ; 4f - db DEX_MILTANK ; 50 - - db DEX_BOMBSEEKER ; 51 - db DEX_VULPIX ; 52 - db DEX_NINETALES ; 53 - db DEX_PIKACHU ; 54 - db DEX_RAICHU ; 55 - db DEX_GIFT ; 56 - db DEX_KOTORA ; 57 - db DEX_DRATINI ; 58 - db DEX_DRAGONAIR ; 59 - db DEX_KABUTO ; 5a - db DEX_KABUTOPS ; 5b - db DEX_HORSEA ; 5c - db DEX_SEADRA ; 5d - db DEX_RAITORA ; 5e - db DEX_MADAME ; 5f - db DEX_SANDSHREW ; 60 - - db DEX_SANDSLASH ; 61 - db DEX_OMANYTE ; 62 - db DEX_OMASTAR ; 63 - db DEX_JIGGLYPUFF ; 64 - db DEX_WIGGLYTUFF ; 65 - db DEX_EEVEE ; 66 - db DEX_FLAREON ; 67 - db DEX_JOLTEON ; 68 - db DEX_VAPOREON ; 69 - db DEX_MACHOP ; 6a - db DEX_ZUBAT ; 6b - db DEX_EKANS ; 6c - db DEX_PARAS ; 6d - db DEX_POLIWHIRL ; 6e - db DEX_POLIWRATH ; 6f - db DEX_WEEDLE ; 70 - - db DEX_KAKUNA ; 71 - db DEX_BEEDRILL ; 72 - db DEX_NOROWARA ; 73 - db DEX_DODRIO ; 74 - db DEX_PRIMEAPE ; 75 - db DEX_DUGTRIO ; 76 - db DEX_VENOMOTH ; 77 - db DEX_DEWGONG ; 78 - db DEX_KYONPAN ; 79 - db DEX_YAMIKARASU ; 7a - db DEX_CATERPIE ; 7b - db DEX_METAPOD ; 7c - db DEX_BUTTERFREE ; 7d - db DEX_MACHAMP ; 7e - db DEX_HAPPI ; 7f - db DEX_GOLDUCK ; 80 - - db DEX_HYPNO ; 81 - db DEX_GOLBAT ; 82 - db DEX_MEWTWO ; 83 - db DEX_SNORLAX ; 84 - db DEX_MAGIKARP ; 85 - db DEX_SCISSORS ; 86 - db DEX_PURAKKUSU ; 87 - db DEX_MUK ; 88 - db DEX_DEVIL ; 89 - db DEX_KINGLER ; 8a - db DEX_CLOYSTER ; 8b - db DEX_HELGAA ; 8c - db DEX_ELECTRODE ; 8d - db DEX_CLEFABLE ; 8e - db DEX_WEEZING ; 8f - db DEX_PERSIAN ; 90 - - db DEX_MAROWAK ; 91 - db DEX_WOLFMAN ; 92 - db DEX_HAUNTER ; 93 - db DEX_ABRA ; 94 - db DEX_ALAKAZAM ; 95 - db DEX_PIDGEOTTO ; 96 - db DEX_PIDGEOT ; 97 - db DEX_STARMIE ; 98 - db DEX_BULBASAUR ; 99 - db DEX_VENUSAUR ; 9a - db DEX_TENTACRUEL ; 9b - db DEX_WARWOLF ; 9c - db DEX_GOLDEEN ; 9d - db DEX_SEAKING ; 9e - db DEX_PORYGON2 ; 9f - db DEX_NAMEIL ; a0 - - db DEX_HAGANEIL ; a1 - db DEX_KINGDRA ; a2 - db DEX_PONYTA ; a3 - db DEX_RAPIDASH ; a4 - db DEX_RATTATA ; a5 - db DEX_RATICATE ; a6 - db DEX_NIDORINO ; a7 - db DEX_NIDORINA ; a8 - db DEX_GEODUDE ; a9 - db DEX_PORYGON ; aa - db DEX_AERODACTYL ; ab - db DEX_RAI ; ac - db DEX_MAGNEMITE ; ad - db DEX_EN ; ae - db DEX_SUI ; af - db DEX_CHARMANDER ; b0 - - db DEX_SQUIRTLE ; b1 - db DEX_CHARMELEON ; b2 - db DEX_WARTORTLE ; b3 - db DEX_CHARIZARD ; b4 - db DEX_NYULA ; b5 - db DEX_HOUOU ; b6 - db DEX_TOGEPY ; b7 - db DEX_BULU ; b8 - db DEX_ODDISH ; b9 - db DEX_GLOOM ; ba - db DEX_VILEPLUME ; bb - db DEX_BELLSPROUT ; bc - db DEX_WEEPINBELL ; bd - db DEX_VICTREEBEL ; be - db DEX_HAPPA ; bf - db DEX_HANAMOGURA ; c0 - - db DEX_HANARYU ; c1 - db DEX_HONOGUMA ; c2 - db DEX_VOLBEAR ; c3 - db DEX_DYNABEAR ; c4 - db DEX_KURUSU ; c5 - db DEX_AQUA ; c6 - db DEX_AQUARIA ; c7 - db DEX_HOHO ; c8 - db DEX_BOBO ; c9 - db DEX_PACHIMEE ; ca - db DEX_MOKOKO ; cb - db DEX_DENRYU ; cc - db DEX_MIKON ; cd - db DEX_MONJA ; ce - db DEX_JARANRA ; cf - db DEX_HANEEI ; d0 - - db DEX_PUKU ; d1 - db DEX_SHIBIREFUGU ; d2 - db DEX_PICHU ; d3 - db DEX_PY ; d4 - db DEX_PUPURIN ; d5 - db DEX_MIZUUO ; d6 - db DEX_NATY ; d7 - db DEX_NATIO ; d8 - db DEX_GYOPIN ; d9 - db DEX_MARIL ; da - db DEX_MANBO1 ; db - db DEX_IKARI ; dc - db DEX_GROTESS ; dd - db DEX_EKSING ; de - db DEX_PARA ; df - db DEX_KOKUMO ; e0 - - db DEX_TWOHEAD ; e1 - db DEX_YOROIDORI ; e2 - db DEX_ANIMON ; e3 - db DEX_HINAZU ; e4 - db DEX_SUNNY ; e5 - db DEX_PAON ; e6 - db DEX_DONPHAN ; e7 - db DEX_TWINZ ; e8 - db DEX_KIRINRIKI ; e9 - db DEX_PAINTER ; ea - db DEX_KOUNYA ; eb - db DEX_RINRIN ; ec - db DEX_BERURUN ; ed - db DEX_NYOROTONO ; ee - db DEX_YADOKING ; ef - db DEX_ANNON ; f0 - - db DEX_REDIBA ; f1 - db DEX_MITSUBOSHI ; f2 - db DEX_PUCHICORN ; f3 - db DEX_EIFIE ; f4 - db DEX_BLACKY ; f5 - db DEX_TURBAN ; f6 - db DEX_BETBABY ; f7 - db DEX_TEPPOUO ; f8 - db DEX_OKUTANK ; f9 - db DEX_GONGU ; fa - db DEX_REDIBA ; fb - db DEX_REDIBA ; fc - -; Pokedex_UpdateSearchScreen.Jumptable indexes - const_def - const SEARCHSTATE_INIT_FIRST_MON_TYPE - const SEARCHSTATE_UPDATE_FIRST_MON_TYPE - const SEARCHSTATE_INIT_FIRST_TYPE_SELECTED_MENU - const SEARCHSTATE_UPDATE_FIRST_TYPE_SELECTED_MENU - const SEARCHSTATE_INIT_SECOND_MON_TYPE - const SEARCHSTATE_UPDATE_SECOND_MON_TYPE - const SEARCHSTATE_INIT_SECOND_TYPE_SELECTED_MENU - const SEARCHSTATE_UPDATE_SECOND_TYPE_SELECTED_MENU - const SEARCHSTATE_EXIT_NO_SLOWPOKE_ANIM - const SEARCHSTATE_EXIT_PLAY_SLOWPOKE_ANIM - -Pokedex_SearchByTypeScreen:: - ld hl, wJumptableIndex - ld a, [hl] - push af - xor a - ld [hl], a - - ld hl, hInMenu - ld a, [hl] - push af - ld a, 1 - ld [hl], a - call ClearSprites - call .Init - -.loop - ld a, [wJumptableIndex] - bit JUMPTABLE_EXIT_F, a - jr nz, .return - call Pokedex_UpdateSearchScreen - call DelayFrame - jr .loop - -.return - pop af - ldh [hInMenu], a - pop af - ld [wJumptableIndex], a - ret - -.Init - ld hl, wDexListingCursor - ld c, wDexPlaySlowpokeAnimation - wDexListingCursor - xor a -.init_loop: - ld [hli], a - dec c - jr nz, .init_loop - ret - -Pokedex_UpdateSearchScreen: - jumptable .SearchScreenJumptable, wJumptableIndex - -.SearchScreenJumptable: - dw Pokedex_InitSearchMonType, Pokedex_UpdateSearchMonType - dw Pokedex_InitFirstTypeSelectedMenu, Pokedex_UpdateFirstTypeSelectedMenu - dw Pokedex_InitNextSearchMonType, Pokedex_UpdateNextSearchMonType - dw Pokedex_InitSecondTypeSelectedMenu, Pokedex_UpdateSecondTypeSelectedMenu - dw Pokedex_ExitSearch_NoSlowpokeAnimation, Pokedex_ExitSearch_PlaySlowpokeAnimation - -Pokedex_InitSearchMonType: - xor a - ld hl, wDexSearchMonType1 - ld [hli], a - ld [hli], a - ld [hli], a - call Pokedex_DisplayTypeSearch - ld hl, wJumptableIndex ; SEARCHSTATE_UPDATE_FIRST_MON_TYPE - inc [hl] - ret - -Pokedex_UpdateSearchMonType: - call GetJoypadDebounced - ld de, wDexSearchMonType1 - call Pokedex_GetSearchMenuJoyDown - ret nc - ld a, SEARCHSTATE_EXIT_NO_SLOWPOKE_ANIM - ld [wJumptableIndex], a - ret - -Pokedex_InitFirstTypeSelectedMenu: - ld de, FirstTypeSelectedMenu - call Pokedex_DisplaySearchOptions - ret - -Pokedex_UpdateFirstTypeSelectedMenu: - call GetJoypadDebounced - ld hl, hJoyDown - ld a, [hl] - and A_BUTTON - jr nz, .a_pressed - - ld a, [hl] - and B_BUTTON - jr nz, .b_pressed - - call Pokedex_MoveTypeSelectedMenuCursor - ret - -.b_pressed - ld a, SEARCHSTATE_INIT_FIRST_MON_TYPE - ld [wJumptableIndex], a - ret - -.a_pressed - ld a, [wDexArrowCursorPosIndex] - and a - jr z, .search - - cp 1 - jr z, .select_next_type - - ld a, SEARCHSTATE_EXIT_NO_SLOWPOKE_ANIM - ld [wJumptableIndex], a - ret - -.search - call Pokedex_SearchForMons - ld a, SEARCHSTATE_EXIT_PLAY_SLOWPOKE_ANIM - ld [wJumptableIndex], a - ret - -.select_next_type - ld a, SEARCHSTATE_INIT_SECOND_MON_TYPE - ld [wJumptableIndex], a - ret - -Pokedex_InitNextSearchMonType: - xor a - ld [wDexSearchMonType2], a - ld [wDexArrowCursorPosIndex], a - call Pokedex_DisplayTypeSearch - ld hl, wJumptableIndex ; SEARCHSTATE_UPDATE_SECOND_MON_TYPE - inc [hl] - ret - -Pokedex_UpdateNextSearchMonType: - call GetJoypadDebounced - ld de, wDexSearchMonType2 - call Pokedex_GetSearchMenuJoyDown - ret nc - - ld a, SEARCHSTATE_INIT_FIRST_TYPE_SELECTED_MENU - ld [wJumptableIndex], a - ret - -Pokedex_InitSecondTypeSelectedMenu: - ld de, SecondTypeSelectedMenu - call Pokedex_DisplaySearchOptions - ret - -Pokedex_UpdateSecondTypeSelectedMenu: - call GetJoypadDebounced - ld hl, hJoyDown - ld a, [hl] - and A_BUTTON - jr nz, .a_pressed - - ld a, [hl] - and B_BUTTON - jr nz, .b_pressed - call Pokedex_MoveTypeSelectedMenuCursor - ret - -.b_pressed - ld a, SEARCHSTATE_INIT_SECOND_MON_TYPE - ld [wJumptableIndex], a - ret - -.a_pressed - ld a, [wDexArrowCursorPosIndex] - and a - jr z, .search - - cp 1 - jr z, .back_to_first_type - - ld a, SEARCHSTATE_EXIT_NO_SLOWPOKE_ANIM - ld [wJumptableIndex], a - ret - -.search - call Pokedex_SearchForMons - ld a, SEARCHSTATE_EXIT_PLAY_SLOWPOKE_ANIM - ld [wJumptableIndex], a - ret - -; Unreferenced -.reorder_dex - call Pokedex_OrderMonsByMode - -.back_to_first_type - ld a, SEARCHSTATE_INIT_FIRST_MON_TYPE - ld [wJumptableIndex], a - ret - -Pokedex_ExitSearch_NoSlowpokeAnimation: - xor a - ld [wDexPlaySlowpokeAnimation], a - ld hl, wJumptableIndex - set JUMPTABLE_EXIT_F, [hl] - ret - -Pokedex_ExitSearch_PlaySlowpokeAnimation: - ld a, SEARCHSTATE_UPDATE_FIRST_MON_TYPE - ld [wDexPlaySlowpokeAnimation], a - ld hl, wJumptableIndex - set JUMPTABLE_EXIT_F, [hl] - ret - -Pokedex_GetSearchMenuJoyDown: - ld hl, hJoyDown - ld a, [hl] - and A_BUTTON - jr nz, .a_pressed - - ld a, [hl] - and B_BUTTON - jr nz, .b_pressed - - call Pokedex_MoveSearchMenuCursor - and a - ret - -.b_pressed - scf - ret - -.a_pressed - ld hl, wDexListingCursor - ld a, [wDexArrowCursorPosIndex] - add [hl] - inc a - ld [de], a - call Pokedex_PlaceSearchScreenTypeStrings - call Pokedex_WaitBGMap - - ld hl, wJumptableIndex - inc [hl] - and a - ret - -Pokedex_DisplaySearchOptions: - ; Erase old cursor - push de - ld a, [wDexArrowCursorPosIndex] - call Pokedex_GetSearchScreenCursorPos - ld [hl], " " - - ; Place new cursor - hlcoord 13, 12 - ld [hl], "▶" - xor a - ld [wDexArrowCursorPosIndex], a - pop de - - ; Place the options loaded at de - hlcoord 14, 12 - call PlaceString - call Pokedex_WaitBGMap - - ; Move to update code for next Jumptable loop - ld hl, wJumptableIndex - inc [hl] - ret - -Pokedex_DisplayTypeSearch: - xor a - ldh [hBGMapMode], a - ld hl, wTileMap - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT -.fill_screen - ld [hl], $6b - inc hl - dec bc - ld a, c - or b - jr nz, .fill_screen - - hlcoord 1, 0 - lb bc, 2, 10 - call ClearBox - - hlcoord 13, 0 - lb bc, 2, 6 - call ClearBox - - hlcoord 0, 2 - lb bc, 16, 12 - call Pokedex_PlaceBorder - - hlcoord 12, 2 - lb bc, 6, 8 - call Pokedex_PlaceBorder - - hlcoord 12, 10 - lb bc, 8, 8 - call Pokedex_PlaceBorder - - hlcoord 1, 1 - ld de, .SearchByTypeString - call PlaceString - - hlcoord 13, 1 - ld de, .SelectedString - call PlaceString - - call Pokedex_PlaceSearchScreenTypeList - call Pokedex_PlaceSearchScreenTypeStrings - hlcoord 2, 4 - ld [hl], "▶" - call Pokedex_WaitBGMap - ret - -.SearchByTypeString: - db "ぞくせい で さがす@" - -.SelectedString: - db "えらんだもの@" - -FirstTypeSelectedMenu: - db "さがす" - next "もうひとつ" - next "やめる@" - -SecondTypeSelectedMenu: - db "さがす" - next "やりなおし" - next "やめる@" - -Pokedex_PlaceSearchScreenTypeList: - ld a, [wDexListingCursor] - call Pokedex_GetTypeString - hlcoord 3, 4 - ld c, 7 -.loop - push bc - push de - push hl - call PlaceString - pop hl - ld de, SCREEN_WIDTH * 2 - add hl, de - pop de -rept POKEDEX_TYPE_STRING_LENGTH - inc de -endr - pop bc - dec c - jr nz, .loop - ret - -Pokedex_PlaceSearchScreenTypeStrings: - ld a, [wDexSearchMonType1] - call .check_type - hlcoord 14, 4 - call PlaceString - - ld a, [wDexSearchMonType2] - call .check_type - hlcoord 14, 6 - call PlaceString - ret - -.check_type - and a - jr z, .no_type_selected - dec a - call Pokedex_GetTypeString - ret - -.no_type_selected - ld de, .NoTypeString - ret - -.NoTypeString -db "ーーーー@" - -Pokedex_GetTypeString: - ld e, a - ld d, $00 - ld hl, PokedexTypeSearchStrings -rept POKEDEX_TYPE_STRING_LENGTH - add hl, de -endr - ld e, l - ld d, h - ret - -INCLUDE "data/types/search_strings.inc" - -Pokedex_MoveSearchMenuCursor: - ld hl, hJoySum - ld a, [hl] - and D_UP - jr nz, .up - - ld a, [hl] - and D_DOWN - jr nz, .down - ret - -.up - call .MoveUp - ret nc - - ld hl, wDexListingCursor - ld a, [hl] - and a - ret z - - dec [hl] - hlcoord 3, 3 - lb bc, 14, 8 - call ClearBox - call Pokedex_PlaceSearchScreenTypeList - call Pokedex_WaitBGMap - ret - -.down - call .MoveDown - ret nc - - ld hl, wDexListingCursor - ld a, [hl] - cp $8 - ret nc - - inc [hl] - hlcoord 3, 3 - lb bc, 14, 8 - call ClearBox - call Pokedex_PlaceSearchScreenTypeList - call Pokedex_WaitBGMap - ret - -.MoveUp: - ld a, [wDexArrowCursorPosIndex] - and a - jr z, .set_carry_flag_up - - call Pokedex_GetSearchScreenCursorPos - ld [hl], " " - ld hl, wDexArrowCursorPosIndex - dec [hl] - jr .PutArrow - -.set_carry_flag_up - scf - ret - -.MoveDown: - ld a, [wDexArrowCursorPosIndex] - cp 6 - jr nc, .set_carry_flag_down - - call Pokedex_GetSearchScreenCursorPos - ld [hl], " " - ld hl, wDexArrowCursorPosIndex - inc [hl] - jr .PutArrow - -.set_carry_flag_down - scf - ret - -.PutArrow: - ld a, [hl] - call Pokedex_GetSearchScreenCursorPos - ld [hl], "▶" - call Pokedex_WaitBGMap - and a - ret - -Pokedex_GetSearchScreenCursorPos: - ld e, a - ld d, $00 - ld hl, .CursorPosTable - add hl, de - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - ret - -.CursorPosTable: - dwcoord 2, 4 - dwcoord 2, 6 - dwcoord 2, 8 - dwcoord 2, 10 - dwcoord 2, 12 - dwcoord 2, 14 - dwcoord 2, 16 - -Pokedex_MoveTypeSelectedMenuCursor: - ld hl, hJoyDown - ld a, [hl] - and D_UP - jr nz, .up - - ld a, [hl] - and D_DOWN - jr nz, .down - ret - -.up - ld a, [wDexArrowCursorPosIndex] - and a - ret z - - call Pokedex_GetTypeSelectedMenuCursorPos - ld [hl], " " - ld hl, wDexArrowCursorPosIndex - dec [hl] - jr .PutArrow - -.down - ld a, [wDexArrowCursorPosIndex] - cp $2 - ret nc - - call Pokedex_GetTypeSelectedMenuCursorPos - ld [hl], " " - ld hl, wDexArrowCursorPosIndex - inc [hl] - -.PutArrow: - ld a, [hl] - call Pokedex_GetTypeSelectedMenuCursorPos - ld [hl], "▶" - call Pokedex_WaitBGMap - and a - ret - -Pokedex_GetTypeSelectedMenuCursorPos: - ld e, a - ld d, 0 - ld hl, .CursorPosTable - add hl, de - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - ret - -.CursorPosTable: - dwcoord 13, 12 - dwcoord 13, 14 - dwcoord 13, 16 - -Pokedex_SearchForMons: - ld a, [wDexSearchMonType2] - and a - jr z, .next_type - call .Search -.next_type - ld a, [wDexSearchMonType1] - and a - ret z - call .Search - ret - -.Search: - dec a - ld e, a - ld d, $00 - ld hl, PokedexTypeSearchConversionTable - add hl, de - ld a, [hl] - ld [wDexConvertedMonType], a - ld hl, wPokedexOrder - ld de, wPokedexOrder - ld c, NUM_POKEMON - xor a - ld [wDexSearchResultCount], a -.loop - push bc - ld a, [hl] - and a - jr z, .next_mon - ld [wTempSpecies], a - ld [wCurSpecies], a - - call Pokedex_CheckCaught - jr z, .next_mon - push hl - push de - call GetBaseData - pop de - pop hl - - ld a, [wDexConvertedMonType] - ld b, a - ld a, [wMonHType1] - cp b - jr z, .match_found - - ld a, [wMonHType2] - cp b - jr nz, .next_mon - -.match_found - ld a, [wTempSpecies] - ld [de], a - inc de - ld a, [wDexSearchResultCount] - inc a - ld [wDexSearchResultCount], a -.next_mon - inc hl - pop bc - dec c - jr nz, .loop - - ld l, e - ld h, d - ld a, [wDexSearchResultCount] - ld [wDexListingEnd], a - ld c, $00 - -.zero_remaining_mons - cp NUM_POKEMON - jr z, .done - ld [hl], c - inc hl - inc a - jr .zero_remaining_mons - -.done - ret - -INCLUDE "data/types/search_types.inc" - -Pokedex_WaitBGMap: - call WaitBGMap - xor a - ldh [hBGMapMode], a - ret - -Pokedex_UnownMode: - ld hl, wJumptableIndex - ld a, [hl] - push af - xor a - ld [hl], a - - ld hl, hInMenu - ld a, [hl] - push af - ld a, $01 - ld [hl], a - - call ClearSprites - call GetDexUnownCount - -.Loop - ld a, [wJumptableIndex] - bit JUMPTABLE_EXIT_F, a - jr nz, .done - - call Pokedex_RunUnownModeJumptable - call DelayFrame - jr .Loop - -.done: - pop af - ldh [hInMenu], a - pop af - ld [wJumptableIndex], a - ret - -GetDexUnownCount: - ld hl, wDexListingCursor - ld bc, wDexPlaySlowpokeAnimation - wDexListingCursor - xor a - call ByteFill - ld hl, wUnownDex - ld bc, NUM_UNOWN -.annon_loop: - ld a, [hli] - and a - jr z, .no_annon - inc b -.no_annon - dec c - jr nz, .annon_loop - - ld a, b - ld [wDexUnownCount], a - ret - -Pokedex_RunUnownModeJumptable: - jumptable .Jumptable, wJumptableIndex - -.Jumptable -dw .Init, .Update, .ShowUnownLetter - -.Init: - ld hl, wJumptableIndex - inc [hl] - call Pokedex_InitUnownMode - ret - -.Update: - call GetJoypadDebounced - ld hl, hJoyDown - ld a, [hl] - and A_BUTTON - jr nz, .selected_unown - ld a, [hl] - and B_BUTTON - jr nz, .exit - call Pokedex_UnownModeHandleDPadInput - ret - -.exit - ld hl, wJumptableIndex - set JUMPTABLE_EXIT_F, [hl] - ret - -.selected_unown - ld hl, wJumptableIndex - inc [hl] - ret - -.ShowUnownLetter: - ld hl, wDexListingCursor - ld a, [wDexArrowCursorPosIndex] - add [hl] - ld e, a - inc a - ld [wDexCurUnownIndex], a - ld d, $00 - ld hl, wUnownDex - add hl, de - ld a, [hl] - ld [wAnnonID], a - ld a, DEX_ANNON - ld [wCurPartySpecies], a - ld [wCurSpecies], a - call GetBaseData - - xor a - ld [wSpriteFlipped], a - hlcoord 12, 10 - call _PrepMonFrontpic - - hlcoord 12, 8 - call PrintUnownListEntry - - call Pokedex_WaitBGMap - ld hl, wJumptableIndex - dec [hl] - ret - -Pokedex_InitUnownMode: - xor a - ldh [hBGMapMode], a - ld hl, wTileMap - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, $6b - call ByteFill - - hlcoord 0, 2 - lb bc, 16, 11 - call Pokedex_PlaceBorder - - hlcoord 11, 2 - lb bc, 6, 9 - call Pokedex_PlaceBorder - - hlcoord 11, 9 - lb bc, 9, 9 - call Pokedex_PlaceBorder - - hlcoord 4, 1 - ld de, .UnownVariantsString - call PlaceString - - hlcoord 13, 4 - ld de, .VariantsDiscoveredString - call PlaceString - - hlcoord 13, 4 - ld de, wDexUnownCount - lb bc, 1, 2 - call PrintNumber - - hlcoord 12, 8 - call PrintUnownListEntry - hlcoord 17, 8 - ld a, "?" - ld [hli], a - ld [hl], a - call PrintUnownList - hlcoord 2, 4 - ld [hl], "▶" - call Pokedex_WaitBGMap - ret - -.UnownVariantsString: - db "アンノーン の しゅるい@" - -.VariantsDiscoveredString: - db "  しゅるい はっけん!@" - - -PrintUnownList: - ld a, [wDexUnownCount] - cp 7 - jr c, .max_length - ld a, 7 - -.max_length - ld [wDexUnownModeListLength], a - ld a, [wDexListingCursor] - inc a - ld [wDexCurUnownIndex], a - hlcoord 3, 4 - ld a, [wDexUnownModeListLength] - -.loop - push af - push hl - call PrintUnownListEntry - ld hl, wDexCurUnownIndex - inc [hl] - pop hl - ld de, SCREEN_WIDTH * 2 - add hl, de - pop af - dec a - jr nz, .loop - ret - -PrintUnownListEntry: - ld de, .UnownString - call PlaceString - ld l, c - ld h, b - ld de, wDexCurUnownIndex - lb bc, 1 | %10000000, 2 - call PrintNumber - ret - -.UnownString: - db "アンノーン@" - -Pokedex_UnownModeHandleDPadInput: - ld hl, hJoySum - ld a, [hl] - and D_UP - jr nz, .up - - ld a, [hl] - and D_DOWN - jr nz, .down - ret - -.up - call .ScrollListUp - ret nc - ld hl, wDexListingCursor - ld a, [hl] - and a - ret z - - dec [hl] - hlcoord 3, 3 - lb bc, 14, 7 - call ClearBox - call PrintUnownList - call Pokedex_WaitBGMap - ret - -.down - call .ScrollListDown - ret nc - ld a, [wDexUnownCount] - cp 7 - ret c - - ld a, [wDexUnownCount] - sub 7 - ld e, a - ld hl, wDexListingCursor - ld a, [hl] - cp e - ret nc - - inc [hl] - hlcoord 3, 3 - lb bc, 14, 7 - call ClearBox - call PrintUnownList - call Pokedex_WaitBGMap - ret - -.ScrollListUp: - ld a, [wDexArrowCursorPosIndex] - and a - jr z, .top_of_list - - call .GetCursorPos - ld [hl], " " - ld hl, wDexArrowCursorPosIndex - dec [hl] - jr .PlaceArrow - -.top_of_list - scf - ret - -.ScrollListDown: - ld a, [wDexUnownCount] - cp 7 - jr c, .longer_than_7_entries - ld a, 7 - -.longer_than_7_entries - dec a - ld e, a - ld a, [wDexArrowCursorPosIndex] - cp e - jr nc, .bottom_of_list - - call .GetCursorPos - ld [hl], " " - ld hl, wDexArrowCursorPosIndex - inc [hl] - jr .PlaceArrow - -.bottom_of_list - scf - ret - -.PlaceArrow: - ld a, [hl] - call Pokedex_GetSearchScreenCursorPos - ld [hl], "▶" - call Pokedex_WaitBGMap - and a - ret - -.GetCursorPos: - ld e, a - ld d, $00 - ld hl, .CursorPosTable - add hl, de - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - ret - -.CursorPosTable: - dwcoord 2, 4 - dwcoord 2, 6 - dwcoord 2, 8 - dwcoord 2, 10 - dwcoord 2, 12 - dwcoord 2, 14 - dwcoord 2, 16 diff --git a/engine/pokedex/pokedex_2.asm b/engine/pokedex/pokedex_2.asm new file mode 100644 index 0000000..50b93ff --- /dev/null +++ b/engine/pokedex/pokedex_2.asm @@ -0,0 +1,970 @@ +INCLUDE "constants.asm" + +SECTION "engine/pokedex/pokedex_2.asm", ROMX + +; Pokedex_UpdateSearchScreen.Jumptable indexes + const_def + const SEARCHSTATE_INIT_FIRST_MON_TYPE + const SEARCHSTATE_UPDATE_FIRST_MON_TYPE + const SEARCHSTATE_INIT_FIRST_TYPE_SELECTED_MENU + const SEARCHSTATE_UPDATE_FIRST_TYPE_SELECTED_MENU + const SEARCHSTATE_INIT_SECOND_MON_TYPE + const SEARCHSTATE_UPDATE_SECOND_MON_TYPE + const SEARCHSTATE_INIT_SECOND_TYPE_SELECTED_MENU + const SEARCHSTATE_UPDATE_SECOND_TYPE_SELECTED_MENU + const SEARCHSTATE_EXIT_NO_SLOWPOKE_ANIM + const SEARCHSTATE_EXIT_PLAY_SLOWPOKE_ANIM + +Pokedex_SearchByTypeScreen:: + ld hl, wJumptableIndex + ld a, [hl] + push af + xor a + ld [hl], a + + ld hl, hInMenu + ld a, [hl] + push af + ld a, 1 + ld [hl], a + call ClearSprites + call .Init + +.loop + ld a, [wJumptableIndex] + bit JUMPTABLE_EXIT_F, a + jr nz, .return + call Pokedex_UpdateSearchScreen + call DelayFrame + jr .loop + +.return + pop af + ldh [hInMenu], a + pop af + ld [wJumptableIndex], a + ret + +.Init + ld hl, wDexListingCursor + ld c, wDexPlaySlowpokeAnimation - wDexListingCursor + xor a +.init_loop: + ld [hli], a + dec c + jr nz, .init_loop + ret + +Pokedex_UpdateSearchScreen: + jumptable .SearchScreenJumptable, wJumptableIndex + +.SearchScreenJumptable: + dw Pokedex_InitSearchMonType, Pokedex_UpdateSearchMonType + dw Pokedex_InitFirstTypeSelectedMenu, Pokedex_UpdateFirstTypeSelectedMenu + dw Pokedex_InitNextSearchMonType, Pokedex_UpdateNextSearchMonType + dw Pokedex_InitSecondTypeSelectedMenu, Pokedex_UpdateSecondTypeSelectedMenu + dw Pokedex_ExitSearch_NoSlowpokeAnimation, Pokedex_ExitSearch_PlaySlowpokeAnimation + +Pokedex_InitSearchMonType: + xor a + ld hl, wDexSearchMonType1 + ld [hli], a + ld [hli], a + ld [hli], a + call Pokedex_DisplayTypeSearch + ld hl, wJumptableIndex ; SEARCHSTATE_UPDATE_FIRST_MON_TYPE + inc [hl] + ret + +Pokedex_UpdateSearchMonType: + call GetJoypadDebounced + ld de, wDexSearchMonType1 + call Pokedex_GetSearchMenuJoyDown + ret nc + ld a, SEARCHSTATE_EXIT_NO_SLOWPOKE_ANIM + ld [wJumptableIndex], a + ret + +Pokedex_InitFirstTypeSelectedMenu: + ld de, FirstTypeSelectedMenu + call Pokedex_DisplaySearchOptions + ret + +Pokedex_UpdateFirstTypeSelectedMenu: + call GetJoypadDebounced + ld hl, hJoyDown + ld a, [hl] + and A_BUTTON + jr nz, .a_pressed + + ld a, [hl] + and B_BUTTON + jr nz, .b_pressed + + call Pokedex_MoveTypeSelectedMenuCursor + ret + +.b_pressed + ld a, SEARCHSTATE_INIT_FIRST_MON_TYPE + ld [wJumptableIndex], a + ret + +.a_pressed + ld a, [wDexArrowCursorPosIndex] + and a + jr z, .search + + cp 1 + jr z, .select_next_type + + ld a, SEARCHSTATE_EXIT_NO_SLOWPOKE_ANIM + ld [wJumptableIndex], a + ret + +.search + call Pokedex_SearchForMons + ld a, SEARCHSTATE_EXIT_PLAY_SLOWPOKE_ANIM + ld [wJumptableIndex], a + ret + +.select_next_type + ld a, SEARCHSTATE_INIT_SECOND_MON_TYPE + ld [wJumptableIndex], a + ret + +Pokedex_InitNextSearchMonType: + xor a + ld [wDexSearchMonType2], a + ld [wDexArrowCursorPosIndex], a + call Pokedex_DisplayTypeSearch + ld hl, wJumptableIndex ; SEARCHSTATE_UPDATE_SECOND_MON_TYPE + inc [hl] + ret + +Pokedex_UpdateNextSearchMonType: + call GetJoypadDebounced + ld de, wDexSearchMonType2 + call Pokedex_GetSearchMenuJoyDown + ret nc + + ld a, SEARCHSTATE_INIT_FIRST_TYPE_SELECTED_MENU + ld [wJumptableIndex], a + ret + +Pokedex_InitSecondTypeSelectedMenu: + ld de, SecondTypeSelectedMenu + call Pokedex_DisplaySearchOptions + ret + +Pokedex_UpdateSecondTypeSelectedMenu: + call GetJoypadDebounced + ld hl, hJoyDown + ld a, [hl] + and A_BUTTON + jr nz, .a_pressed + + ld a, [hl] + and B_BUTTON + jr nz, .b_pressed + call Pokedex_MoveTypeSelectedMenuCursor + ret + +.b_pressed + ld a, SEARCHSTATE_INIT_SECOND_MON_TYPE + ld [wJumptableIndex], a + ret + +.a_pressed + ld a, [wDexArrowCursorPosIndex] + and a + jr z, .search + + cp 1 + jr z, .back_to_first_type + + ld a, SEARCHSTATE_EXIT_NO_SLOWPOKE_ANIM + ld [wJumptableIndex], a + ret + +.search + call Pokedex_SearchForMons + ld a, SEARCHSTATE_EXIT_PLAY_SLOWPOKE_ANIM + ld [wJumptableIndex], a + ret + +; Unreferenced +.reorder_dex + call Pokedex_OrderMonsByMode + +.back_to_first_type + ld a, SEARCHSTATE_INIT_FIRST_MON_TYPE + ld [wJumptableIndex], a + ret + +Pokedex_ExitSearch_NoSlowpokeAnimation: + xor a + ld [wDexPlaySlowpokeAnimation], a + ld hl, wJumptableIndex + set JUMPTABLE_EXIT_F, [hl] + ret + +Pokedex_ExitSearch_PlaySlowpokeAnimation: + ld a, SEARCHSTATE_UPDATE_FIRST_MON_TYPE + ld [wDexPlaySlowpokeAnimation], a + ld hl, wJumptableIndex + set JUMPTABLE_EXIT_F, [hl] + ret + +Pokedex_GetSearchMenuJoyDown: + ld hl, hJoyDown + ld a, [hl] + and A_BUTTON + jr nz, .a_pressed + + ld a, [hl] + and B_BUTTON + jr nz, .b_pressed + + call Pokedex_MoveSearchMenuCursor + and a + ret + +.b_pressed + scf + ret + +.a_pressed + ld hl, wDexListingCursor + ld a, [wDexArrowCursorPosIndex] + add [hl] + inc a + ld [de], a + call Pokedex_PlaceSearchScreenTypeStrings + call Pokedex_WaitBGMap + + ld hl, wJumptableIndex + inc [hl] + and a + ret + +Pokedex_DisplaySearchOptions: + ; Erase old cursor + push de + ld a, [wDexArrowCursorPosIndex] + call Pokedex_GetSearchScreenCursorPos + ld [hl], " " + + ; Place new cursor + hlcoord 13, 12 + ld [hl], "▶" + xor a + ld [wDexArrowCursorPosIndex], a + pop de + + ; Place the options loaded at de + hlcoord 14, 12 + call PlaceString + call Pokedex_WaitBGMap + + ; Move to update code for next Jumptable loop + ld hl, wJumptableIndex + inc [hl] + ret + +Pokedex_DisplayTypeSearch: + xor a + ldh [hBGMapMode], a + ld hl, wTileMap + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT +.fill_screen + ld [hl], $6b + inc hl + dec bc + ld a, c + or b + jr nz, .fill_screen + + hlcoord 1, 0 + lb bc, 2, 10 + call ClearBox + + hlcoord 13, 0 + lb bc, 2, 6 + call ClearBox + + hlcoord 0, 2 + lb bc, 16, 12 + call Pokedex_PlaceBorder + + hlcoord 12, 2 + lb bc, 6, 8 + call Pokedex_PlaceBorder + + hlcoord 12, 10 + lb bc, 8, 8 + call Pokedex_PlaceBorder + + hlcoord 1, 1 + ld de, .SearchByTypeString + call PlaceString + + hlcoord 13, 1 + ld de, .SelectedString + call PlaceString + + call Pokedex_PlaceSearchScreenTypeList + call Pokedex_PlaceSearchScreenTypeStrings + hlcoord 2, 4 + ld [hl], "▶" + call Pokedex_WaitBGMap + ret + +.SearchByTypeString: + db "ぞくせい で さがす@" + +.SelectedString: + db "えらんだもの@" + +FirstTypeSelectedMenu: + db "さがす" + next "もうひとつ" + next "やめる@" + +SecondTypeSelectedMenu: + db "さがす" + next "やりなおし" + next "やめる@" + +Pokedex_PlaceSearchScreenTypeList: + ld a, [wDexListingCursor] + call Pokedex_GetTypeString + hlcoord 3, 4 + ld c, 7 +.loop + push bc + push de + push hl + call PlaceString + pop hl + ld de, SCREEN_WIDTH * 2 + add hl, de + pop de +rept POKEDEX_TYPE_STRING_LENGTH + inc de +endr + pop bc + dec c + jr nz, .loop + ret + +Pokedex_PlaceSearchScreenTypeStrings: + ld a, [wDexSearchMonType1] + call .check_type + hlcoord 14, 4 + call PlaceString + + ld a, [wDexSearchMonType2] + call .check_type + hlcoord 14, 6 + call PlaceString + ret + +.check_type + and a + jr z, .no_type_selected + dec a + call Pokedex_GetTypeString + ret + +.no_type_selected + ld de, .NoTypeString + ret + +.NoTypeString +db "ーーーー@" + +Pokedex_GetTypeString: + ld e, a + ld d, $00 + ld hl, PokedexTypeSearchStrings +rept POKEDEX_TYPE_STRING_LENGTH + add hl, de +endr + ld e, l + ld d, h + ret + +INCLUDE "data/types/search_strings.inc" + +Pokedex_MoveSearchMenuCursor: + ld hl, hJoySum + ld a, [hl] + and D_UP + jr nz, .up + + ld a, [hl] + and D_DOWN + jr nz, .down + ret + +.up + call .MoveUp + ret nc + + ld hl, wDexListingCursor + ld a, [hl] + and a + ret z + + dec [hl] + hlcoord 3, 3 + lb bc, 14, 8 + call ClearBox + call Pokedex_PlaceSearchScreenTypeList + call Pokedex_WaitBGMap + ret + +.down + call .MoveDown + ret nc + + ld hl, wDexListingCursor + ld a, [hl] + cp $8 + ret nc + + inc [hl] + hlcoord 3, 3 + lb bc, 14, 8 + call ClearBox + call Pokedex_PlaceSearchScreenTypeList + call Pokedex_WaitBGMap + ret + +.MoveUp: + ld a, [wDexArrowCursorPosIndex] + and a + jr z, .set_carry_flag_up + + call Pokedex_GetSearchScreenCursorPos + ld [hl], " " + ld hl, wDexArrowCursorPosIndex + dec [hl] + jr .PutArrow + +.set_carry_flag_up + scf + ret + +.MoveDown: + ld a, [wDexArrowCursorPosIndex] + cp 6 + jr nc, .set_carry_flag_down + + call Pokedex_GetSearchScreenCursorPos + ld [hl], " " + ld hl, wDexArrowCursorPosIndex + inc [hl] + jr .PutArrow + +.set_carry_flag_down + scf + ret + +.PutArrow: + ld a, [hl] + call Pokedex_GetSearchScreenCursorPos + ld [hl], "▶" + call Pokedex_WaitBGMap + and a + ret + +Pokedex_GetSearchScreenCursorPos: + ld e, a + ld d, $00 + ld hl, .CursorPosTable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + ret + +.CursorPosTable: + dwcoord 2, 4 + dwcoord 2, 6 + dwcoord 2, 8 + dwcoord 2, 10 + dwcoord 2, 12 + dwcoord 2, 14 + dwcoord 2, 16 + +Pokedex_MoveTypeSelectedMenuCursor: + ld hl, hJoyDown + ld a, [hl] + and D_UP + jr nz, .up + + ld a, [hl] + and D_DOWN + jr nz, .down + ret + +.up + ld a, [wDexArrowCursorPosIndex] + and a + ret z + + call Pokedex_GetTypeSelectedMenuCursorPos + ld [hl], " " + ld hl, wDexArrowCursorPosIndex + dec [hl] + jr .PutArrow + +.down + ld a, [wDexArrowCursorPosIndex] + cp $2 + ret nc + + call Pokedex_GetTypeSelectedMenuCursorPos + ld [hl], " " + ld hl, wDexArrowCursorPosIndex + inc [hl] + +.PutArrow: + ld a, [hl] + call Pokedex_GetTypeSelectedMenuCursorPos + ld [hl], "▶" + call Pokedex_WaitBGMap + and a + ret + +Pokedex_GetTypeSelectedMenuCursorPos: + ld e, a + ld d, 0 + ld hl, .CursorPosTable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + ret + +.CursorPosTable: + dwcoord 13, 12 + dwcoord 13, 14 + dwcoord 13, 16 + +Pokedex_SearchForMons: + ld a, [wDexSearchMonType2] + and a + jr z, .next_type + call .Search +.next_type + ld a, [wDexSearchMonType1] + and a + ret z + call .Search + ret + +.Search: + dec a + ld e, a + ld d, $00 + ld hl, PokedexTypeSearchConversionTable + add hl, de + ld a, [hl] + ld [wDexConvertedMonType], a + ld hl, wPokedexOrder + ld de, wPokedexOrder + ld c, NUM_POKEMON + xor a + ld [wDexSearchResultCount], a +.loop + push bc + ld a, [hl] + and a + jr z, .next_mon + ld [wTempSpecies], a + ld [wCurSpecies], a + + call Pokedex_CheckCaught + jr z, .next_mon + push hl + push de + call GetBaseData + pop de + pop hl + + ld a, [wDexConvertedMonType] + ld b, a + ld a, [wMonHType1] + cp b + jr z, .match_found + + ld a, [wMonHType2] + cp b + jr nz, .next_mon + +.match_found + ld a, [wTempSpecies] + ld [de], a + inc de + ld a, [wDexSearchResultCount] + inc a + ld [wDexSearchResultCount], a +.next_mon + inc hl + pop bc + dec c + jr nz, .loop + + ld l, e + ld h, d + ld a, [wDexSearchResultCount] + ld [wDexListingEnd], a + ld c, $00 + +.zero_remaining_mons + cp NUM_POKEMON + jr z, .done + ld [hl], c + inc hl + inc a + jr .zero_remaining_mons + +.done + ret + +INCLUDE "data/types/search_types.inc" + +Pokedex_WaitBGMap: + call WaitBGMap + xor a + ldh [hBGMapMode], a + ret + +Pokedex_UnownMode: + ld hl, wJumptableIndex + ld a, [hl] + push af + xor a + ld [hl], a + + ld hl, hInMenu + ld a, [hl] + push af + ld a, $01 + ld [hl], a + + call ClearSprites + call GetDexUnownCount + +.Loop + ld a, [wJumptableIndex] + bit JUMPTABLE_EXIT_F, a + jr nz, .done + + call Pokedex_RunUnownModeJumptable + call DelayFrame + jr .Loop + +.done: + pop af + ldh [hInMenu], a + pop af + ld [wJumptableIndex], a + ret + +GetDexUnownCount: + ld hl, wDexListingCursor + ld bc, wDexPlaySlowpokeAnimation - wDexListingCursor + xor a + call ByteFill + ld hl, wUnownDex + ld bc, NUM_UNOWN +.annon_loop: + ld a, [hli] + and a + jr z, .no_annon + inc b +.no_annon + dec c + jr nz, .annon_loop + + ld a, b + ld [wDexUnownCount], a + ret + +Pokedex_RunUnownModeJumptable: + jumptable .Jumptable, wJumptableIndex + +.Jumptable +dw .Init, .Update, .ShowUnownLetter + +.Init: + ld hl, wJumptableIndex + inc [hl] + call Pokedex_InitUnownMode + ret + +.Update: + call GetJoypadDebounced + ld hl, hJoyDown + ld a, [hl] + and A_BUTTON + jr nz, .selected_unown + ld a, [hl] + and B_BUTTON + jr nz, .exit + call Pokedex_UnownModeHandleDPadInput + ret + +.exit + ld hl, wJumptableIndex + set JUMPTABLE_EXIT_F, [hl] + ret + +.selected_unown + ld hl, wJumptableIndex + inc [hl] + ret + +.ShowUnownLetter: + ld hl, wDexListingCursor + ld a, [wDexArrowCursorPosIndex] + add [hl] + ld e, a + inc a + ld [wDexCurUnownIndex], a + ld d, $00 + ld hl, wUnownDex + add hl, de + ld a, [hl] + ld [wAnnonID], a + ld a, DEX_ANNON + ld [wCurPartySpecies], a + ld [wCurSpecies], a + call GetBaseData + + xor a + ld [wSpriteFlipped], a + hlcoord 12, 10 + call _PrepMonFrontpic + + hlcoord 12, 8 + call PrintUnownListEntry + + call Pokedex_WaitBGMap + ld hl, wJumptableIndex + dec [hl] + ret + +Pokedex_InitUnownMode: + xor a + ldh [hBGMapMode], a + ld hl, wTileMap + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, $6b + call ByteFill + + hlcoord 0, 2 + lb bc, 16, 11 + call Pokedex_PlaceBorder + + hlcoord 11, 2 + lb bc, 6, 9 + call Pokedex_PlaceBorder + + hlcoord 11, 9 + lb bc, 9, 9 + call Pokedex_PlaceBorder + + hlcoord 4, 1 + ld de, .UnownVariantsString + call PlaceString + + hlcoord 13, 4 + ld de, .VariantsDiscoveredString + call PlaceString + + hlcoord 13, 4 + ld de, wDexUnownCount + lb bc, 1, 2 + call PrintNumber + + hlcoord 12, 8 + call PrintUnownListEntry + hlcoord 17, 8 + ld a, "?" + ld [hli], a + ld [hl], a + call PrintUnownList + hlcoord 2, 4 + ld [hl], "▶" + call Pokedex_WaitBGMap + ret + +.UnownVariantsString: + db "アンノーン の しゅるい@" + +.VariantsDiscoveredString: + db "  しゅるい はっけん!@" + + +PrintUnownList: + ld a, [wDexUnownCount] + cp 7 + jr c, .max_length + ld a, 7 + +.max_length + ld [wDexUnownModeListLength], a + ld a, [wDexListingCursor] + inc a + ld [wDexCurUnownIndex], a + hlcoord 3, 4 + ld a, [wDexUnownModeListLength] + +.loop + push af + push hl + call PrintUnownListEntry + ld hl, wDexCurUnownIndex + inc [hl] + pop hl + ld de, SCREEN_WIDTH * 2 + add hl, de + pop af + dec a + jr nz, .loop + ret + +PrintUnownListEntry: + ld de, .UnownString + call PlaceString + ld l, c + ld h, b + ld de, wDexCurUnownIndex + lb bc, 1 | %10000000, 2 + call PrintNumber + ret + +.UnownString: + db "アンノーン@" + +Pokedex_UnownModeHandleDPadInput: + ld hl, hJoySum + ld a, [hl] + and D_UP + jr nz, .up + + ld a, [hl] + and D_DOWN + jr nz, .down + ret + +.up + call .ScrollListUp + ret nc + ld hl, wDexListingCursor + ld a, [hl] + and a + ret z + + dec [hl] + hlcoord 3, 3 + lb bc, 14, 7 + call ClearBox + call PrintUnownList + call Pokedex_WaitBGMap + ret + +.down + call .ScrollListDown + ret nc + ld a, [wDexUnownCount] + cp 7 + ret c + + ld a, [wDexUnownCount] + sub 7 + ld e, a + ld hl, wDexListingCursor + ld a, [hl] + cp e + ret nc + + inc [hl] + hlcoord 3, 3 + lb bc, 14, 7 + call ClearBox + call PrintUnownList + call Pokedex_WaitBGMap + ret + +.ScrollListUp: + ld a, [wDexArrowCursorPosIndex] + and a + jr z, .top_of_list + + call .GetCursorPos + ld [hl], " " + ld hl, wDexArrowCursorPosIndex + dec [hl] + jr .PlaceArrow + +.top_of_list + scf + ret + +.ScrollListDown: + ld a, [wDexUnownCount] + cp 7 + jr c, .longer_than_7_entries + ld a, 7 + +.longer_than_7_entries + dec a + ld e, a + ld a, [wDexArrowCursorPosIndex] + cp e + jr nc, .bottom_of_list + + call .GetCursorPos + ld [hl], " " + ld hl, wDexArrowCursorPosIndex + inc [hl] + jr .PlaceArrow + +.bottom_of_list + scf + ret + +.PlaceArrow: + ld a, [hl] + call Pokedex_GetSearchScreenCursorPos + ld [hl], "▶" + call Pokedex_WaitBGMap + and a + ret + +.GetCursorPos: + ld e, a + ld d, $00 + ld hl, .CursorPosTable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + ret + +.CursorPosTable: + dwcoord 2, 4 + dwcoord 2, 6 + dwcoord 2, 8 + dwcoord 2, 10 + dwcoord 2, 12 + dwcoord 2, 14 + dwcoord 2, 16 diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm new file mode 100644 index 0000000..327957c --- /dev/null +++ b/engine/pokemon/bills_pc.asm @@ -0,0 +1,653 @@ +INCLUDE "constants.asm" + +SECTION "engine/pokemon/bills_pc.asm", ROMX + +_BillsPC: + call .CheckCanUsePC + ret c + call LoadStandardMenuHeader + call ClearTileMap + call LoadFontsBattleExtra + ld hl, vChars2 tile $78 + ld de, PokeBallsGFX + lb bc, BANK(PokeBallsGFX), 1 + call Request2bpp + ld hl, .PCWhatText + call MenuTextBox + ld hl, .MenuHeader + call LoadMenuHeader +.loop + call SetPalettes + xor a + ld [wWhichIndexSet], a + call OpenMenu + jr c, .cancel + ld a, [wMenuSelection] + ld hl, .Jumptable + call CallJumptable + jr nc, .loop + +.cancel + call CloseWindow + call CloseWindow + call LoadTilesetGFX + call RestoreScreenAndReloadTiles + call LoadFontExtra + call CloseWindow + ret + +.PCWhatText: + text "なんに するん?" ; (lit. "What are you going to do?") + done + +.MenuHeader: + db MENU_BACKUP_TILES + menu_coords 0, 0, 14, 17 + dw .MenuData + db 1 + +.MenuData: + db MENU_BACKUP_TILES_2 + db 0 + dw .items + dw PlaceMenuStrings + dw .strings + +.strings + db "#の ようすをみる@" ; (lit "look at Pokemon") + db "#を つれていく@" ; "Withdraw (Pokemon)" + db "#を あずける@" ; "Deposit (Pokemon)" + db "#を にがす@" ; "Release (Pokemon)" + db "ボックスを かえる@" ; "Change Box" + db "さようなら@" ; "Goodbye" + +.Jumptable: + dw BillsPC_ViewPokemon + dw BillsPC_WithdrawPokemon + dw BillsPC_DepositMon + dw BillsPC_ReleaseMon + dw BillsPC_ChangeBoxMenu + dw BillsPC_SeeYa + +.items + db 5 ; # items + db 0 ; VIEW + db 1 ; WITHDRAW + db 2 ; DEPOSIT + db 3 ; RELEASE + db 4 ; CHANGE BOX + db 5 ; SEE YA! + db -1 + +.CheckCanUsePC: + ld a, [wPartyCount] + and a + ret nz + ld hl, .PCGottaHavePokemonText + call MenuTextBoxBackup + scf + ret + +.PCGottaHavePokemonText: + text "#もってへんやつは" + line "おことわりや!" + prompt + +BillsPC_SeeYa: + scf + ret + +BillsPC_DepositMon: + call .CheckPartySize + jr c, .cant_deposit + call _DepositPKMN + +.cant_deposit + and a + ret + +.CheckPartySize: + ld a, [wPartyCount] + and a + jr z, .no_mon + cp 2 + jr c, .only_one_mon + and a + ret + +.no_mon + ld hl, .PCNoSingleMonText + call MenuTextBoxBackup + scf + ret + +.only_one_mon + ld hl, .PCCantDepositLastMonText + call MenuTextBoxBackup + scf + ret + +.PCNoSingleMonText: + text "1ぴきも もってへんやんか!" ; (lit: "I can't even have one!") + prompt + +.PCCantDepositLastMonText: + text "それ あずけたら" ; "You can't deposit" + line "こまるんとちゃう?" ; "the last #MON!" + prompt + +_DepositPKMN: + call LoadStandardMenuHeader + ld hl, BillsPC_DepositMenu + call BillsPC_Menu + call CloseWindow + ret c + + ld a, [wScrollingMenuCursorPosition] + ld [wCurPartyMon], a + ld a, [wMenuSelection] + ld [wCurPartySpecies], a + ld a, PC_DEPOSIT + ld [wPokemonWithdrawDepositParameter], a + predef SendGetMonIntoFromBox + xor a ; REMOVE_PARTY + ld [wPokemonWithdrawDepositParameter], a + call RemoveMonFromPartyOrBox + ret + +BillsPC_WithdrawPokemon: + call .CheckPartySize + jr c, .cant_withdraw + call _WithdrawPKMN +.cant_withdraw + and a + ret + +.CheckPartySize: + ld a, [wPartyCount] + cp PARTY_LENGTH + jr nc, .party_full + and a + ret + +.party_full + ld hl, .PCCantTakeText + call MenuTextBoxBackup + scf + ret + +.PCCantTakeText: + text "それいじょう よくばったって" ; "You can't take any" + line "# もたれへんで!" ; "more #MON." + prompt + +_WithdrawPKMN: + call LoadStandardMenuHeader + ld hl, BillsPC_WithdrawReleaseMenu + call BillsPC_Menu + call CloseWindow + ret c + + ld a, [wScrollingMenuCursorPosition] + ld [wCurPartyMon], a + ld a, [wMenuSelection] + ld [wCurPartySpecies], a + xor a ; PC_WITHDRAW + ld [wPokemonWithdrawDepositParameter], a + predef SendGetMonIntoFromBox + ld a, REMOVE_BOX + ld [wPokemonWithdrawDepositParameter], a + call RemoveMonFromPartyOrBox + ret + +BillsPC_ReleaseMon: + call .ReleasePKMN + and a + ret + +.ReleasePKMN: + call LoadStandardMenuHeader + ld hl, BillsPC_WithdrawReleaseMenu + call BillsPC_Menu + call CloseWindow + ld a, [wScrollingMenuCursorPosition] + ld [wCurPartyMon], a + ld a, [wMenuSelection] + ld [wCurPartySpecies], a + ret c + + ld hl, .OnceReleasedText + call MenuTextBox + call YesNoBox + call CloseWindow + ret c + ld a, REMOVE_BOX + ld [wPokemonWithdrawDepositParameter], a + call RemoveMonFromPartyOrBox + ret + +.OnceReleasedText: + text_from_ram wStringBuffer1 + text " をほんとうに" ; "Are you sure you" + next "にがしますか?" ; "want to release (MON)?" + done + +BillsPC_ChangeBoxMenu: + call _ChangeBox + and a + ret + +_ChangeBox: + call InitDummyBoxNames + call LoadStandardMenuHeader + call ClearPalettes + call ClearTileMap +.sub_e3d4 + ld hl, _ChangeBox_MenuHeader + call CopyMenuHeader + call ScrollingMenu + ld a, [wMenuJoypad] + cp B_BUTTON + jr z, .sub_e3e9 + call BillsPC_ChangeBoxSubmenu + jr .sub_e3d4 +.sub_e3e9 + call CloseWindow + ret + +; Resets all box names to "ダミーボックス#" ("Dummy Box#"), where # is the box index. +InitDummyBoxNames: + ld hl, wBoxNames + ld c, 0 +.loop + push hl + ld de, .DummyBoxText + call CopyString + ld a, "0" + add c + dec hl + ld [hli], a + ld [hl], "@" + pop hl + ld de, BOX_NAME_LENGTH + add hl, de + inc c + ld a, c + cp NUM_BOXES + jr c, .loop + ret + +.DummyBoxText: + db "ダミーボックス@" ; "Dummy Box" + +_ChangeBox_MenuHeader: + db MENU_BACKUP_TILES + menu_coords 0, 0, SCREEN_WIDTH - 1, 12 + dw .MenuData + db 1 + +.MenuData: + db SCROLLINGMENU_ENABLE_FUNCTION3 + db 4, 0 + db SCROLLINGMENU_ITEMS_NORMAL + dba .Boxes + dba .PrintBoxNames + ds 3 + dba BillsPC_PrintBoxCountAndCapacity + +.Boxes: + db NUM_BOXES +for x, NUM_BOXES + db x + 1 +endr + db -1 + +.PrintBoxNames: + push de + ld a, [wMenuSelection] + dec a + ld bc, 6 ; length of "No. 0#" strings + ld hl, .BoxNumbers + call AddNTimes + ld d, h + ld e, l + pop hl + call PlaceString + push bc + ld a, [wMenuSelection] + dec a + ld bc, BOX_NAME_LENGTH + ld hl, wBoxNames + call AddNTimes + ld d, h + ld e, l + pop hl + call PlaceString + ret + +; TODO: rework this to use a nice macro? +.BoxNumbers: + db "№.01 @" + db "№.02 @" + db "№.03 @" + db "№.04 @" + db "№.05 @" + db "№.06 @" + db "№.07 @" + db "№.08 @" + db "№.09 @" + db "№.10 @" + +BillsPC_PrintBoxCountAndCapacity: + ld h, d + ld l, e + ld de, .Pokemon + call PlaceString + ld hl, 3 + add hl, bc + push hl + call .GetBoxCount + pop hl + ld de, wStringBuffer1 + ld [de], a + lb bc, 1, 2 + call PrintNumber + ld de, .OutOf30 + call PlaceString + ret + +.Pokemon: + db "あずかっている#" ; "Mon in my care" + next " @" + +.OutOf30: ; max mon per box + db "/30@" + +.GetBoxCount: + ld a, [wMenuSelection] + dec a + ld c, a + ld b, 0 + ld hl, .BoxBankAddresses + add hl, bc + add hl, bc + add hl, bc + ld a, [hli] + call OpenSRAM + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [hl] + call CloseSRAM + ret + +.BoxBankAddresses: + table_width 3, BillsPC_PrintBoxCountAndCapacity.BoxBankAddresses +for n, 1, NUM_BOXES + 1 + dba sBox{d:n} +endr + assert_table_length NUM_BOXES + +BillsPC_ChangeBoxSubmenu: + ld hl, .MenuHeader + call LoadMenuHeader + call VerticalMenu + call CloseWindow + ret c + ld a, [wMenuCursorY] + cp 1 + jr z, .Switch + cp 2 + jr z, .Name + and a + ret + +.UnderDev: + ld hl, .BoxChangeUnderDevText + call MenuTextBox + call CloseWindow + ret + +.BoxChangeUnderDevText: + text "バンクチェンジは" ; "Box change is" + next "かいはつちゅうです!" ; "under development!" + prompt + +.Switch: + ld hl, .ChangeBoxSaveText + call MenuTextBox + call YesNoBox + call CloseWindow + ret c + jr .UnderDev + +.Unreferenced_e54d: + ld a, [wMenuSelection] + ret + +.ChangeBoxSaveText: + text "# ボックスを かえると" ; "When you change a box" + line "どうじに レポートが かかれます" ; "data will be saved." + para "<⋯⋯> それでも いいですか?" ; "Is that okay?" + done + +.Name: + ld b, NAME_BOX + ld de, wTempBoxName + farcall NamingScreen + ld a, [wTempBoxName] + cp "@" + ret z + ld hl, wBoxNames + ld bc, BOX_NAME_LENGTH + ld a, [wMenuSelection] + dec a + call AddNTimes + ld de, wTempBoxName + call CopyString + ret + +.MenuHeader: + db MENU_BACKUP_TILES + menu_coords 0, 6, 14, 14 + dw .MenuData + db 1 + +.MenuData: + db STATICMENU_CURSOR + db 3 + db "ボックスきりかえ@" ; "Change Box" + db "なまえを かえる@" ; " Change Name" + db "やめる@" ; (lit "stop") + +BillsPC_ViewPokemon: + call LoadStandardMenuHeader + call _ViewPKMN + call ClearPalettes + call CloseWindow + and a + ret + +_ViewPKMN: +.loop + call ClearBGPalettes + call .InitViewPokemonDisplay + call SetPalettes + ld hl, BillsPC_ViewMenuHeader + call CopyMenuHeader + ld a, [wBillsPCCursor] + ld [wMenuCursorPosition], a + ld a, [wBillsPCScrollPosition] + ld [wMenuScrollPosition], a + call ScrollingMenu + ld a, [wMenuScrollPosition] + ld [wBillsPCScrollPosition], a + ld a, [wMenuCursorY] + ld [wBillsPCCursor], a + call ClearPalettes + ld a, [wMenuJoypad] + cp B_BUTTON + jr z, .exit + call .ViewStats + jr .loop + +.exit + ret +.ViewStats + ld a, [wScrollingMenuCursorPosition] + ld [wCurPartyMon], a + ld a, BOXMON + ld [wMonType], a + call LoadStandardMenuHeader + call LowVolume + predef StatsScreenMain + call MaxVolume + call ExitMenu + ret + +.InitViewPokemonDisplay + ld hl, wOptions + ld a, [hl] + push af + set NO_TEXT_SCROLL_F, [hl] + call ClearTileMap + +; Note that the name of the box doesn't actually gets printed yet: register 'de' is immediately overwritten, +; so the game displays the placeholder "いまの ボックス" ("Current Box"). The setup is here, though. + ld a, [wCurBox] + ld hl, wBoxNames + ld bc, BOX_NAME_LENGTH + call AddNTimes + ld d, h + ld e, l + + hlcoord 1, 1 + ld de, .CurrentBox + call PlaceString + hlcoord 0, 3 + ld a, "┌" + ld [hli], a + ld a, "─" + ld c, SCREEN_WIDTH - 1 + +.top_border_loop + ld [hli], a + dec c + jr nz, .top_border_loop + ld de, SCREEN_WIDTH + ld a, "│" + ld c, 8 +.left_border_loop + ld [hl], a + add hl, de + dec c + jr nz, .left_border_loop + + hlcoord 2, 3 + ld de, .SpeciesNameLevel + call PlaceString + ld hl, .PCString_ChooseaPKMN + call PrintText + pop af + ld [wOptions], a + ret + +.CurrentBox: + db "ボックス/いまの ボックス@" ; "Box/Current Box" + +.SpeciesNameLevel: + db "しゅるい  なまえ   レべル@" ; "Species Name Level" + +.PCString_ChooseaPKMN: + text "どの#が みたいねん?" ; "Which would you like to see?" + done + +BillsPC_Menu:: + ld a, l + ld [wListPointer], a + ld a, h + ld [wListPointer + 1], a + hlcoord 4, 2 + ld b, 9 + ld c, 14 + call DrawTextBox + ld hl, wListPointer + ld a, [hli] + ld h, [hl] + ld l, a + call ScrollingMenu_FromTable + ld a, [wMenuJoypad] + cp B_BUTTON + jr z, .exit + ld hl, .PokemonSelected + call MenuTextBoxBackup + and a + ret + +.exit + scf + ret + +.PokemonSelected: + text "#を えらんだ!" ; "POKéMON selected!" + prompt + +BillsPC_DepositMenu: + dw .MenuHeader + dw wBillsPCCursor + dw wBillsPCScrollPosition + +.MenuHeader: + db MENU_BACKUP_TILES + menu_coords 5, 3, 18, 11 + dw .MenuData + db 1 + +.MenuData: + db 0 + db 4, 8 + db SCROLLINGMENU_ITEMS_NORMAL + dbw 0, wPartyCount + dba PlacePartyMonNicknames + dba PlacePartyMonLevels + ds 3 + +BillsPC_WithdrawReleaseMenu: + dw .MenuHeader + dw wBillsPCCursor + dw wBillsPCScrollPosition + +.MenuHeader: + db MENU_BACKUP_TILES + menu_coords 5, 3, 18, 11 + dw .MenuData + db 1 + +.MenuData: + db 0 + db 4, 8 + db SCROLLINGMENU_ITEMS_NORMAL + dbw 0, wBoxCount + dba PlaceBoxMonNicknames + dba PlaceBoxMonLevels + ds 3 + +BillsPC_ViewMenu: + dw BillsPC_ViewMenuHeader + dw wBillsPCCursor + dw wBillsPCScrollPosition + +BillsPC_ViewMenuHeader: + db MENU_BACKUP_TILES + menu_coords 1, 4, SCREEN_WIDTH - 1, 11 + dw .MenuData + db 1 + +.MenuData: + db 0 + db 4, 0 + db SCROLLINGMENU_ITEMS_NORMAL + dbw 0, wBoxCount + dba PlaceDetailedBoxMonView + ds 3 + ds 3 diff --git a/engine/pokemon/evolve.asm b/engine/pokemon/evolve.asm new file mode 100644 index 0000000..1c5813e --- /dev/null +++ b/engine/pokemon/evolve.asm @@ -0,0 +1,554 @@ +INCLUDE "constants.asm" + +SECTION "engine/pokemon/evolve.asm", ROMX + +EvolvePokemon:: + ld hl, wEvolvableFlags + xor a + ld [hl], a + ld a, [wCurPartyMon] + ld c, a + ld b, SET_FLAG + call EvoFlagAction +EvolveAfterBattle:: + ldh a, [hMapAnims] + push af + xor a + + ld [wMonTriedToEvolve], a + dec a + ld [wCurPartyMon], a + push hl + push bc + push de + ld hl, wPartyCount + + push hl + +EvolveAfterBattle_MasterLoop: + ld hl, wCurPartyMon + inc [hl] + + pop hl + inc hl + + ld a, [hl] + cp -1 + jp z, .ReturnToMap + + ld [wEvolutionOldSpecies], a + push hl + + ld a, [wCurPartyMon] + ld c, a + ld hl, wEvolvableFlags + ld b, CHECK_FLAG + call EvoFlagAction + ld a, c + and a + jp z, EvolveAfterBattle_MasterLoop + + ld a, [wEvolutionOldSpecies] + dec a + ld b, 0 + ld c, a + ld hl, EvosAttacksPointers + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + + push hl + xor a + ld [wMonType], a + predef CopyMonToTempMon + pop hl + +.loop + ld a, [hli] + and a + jr z, EvolveAfterBattle_MasterLoop + + ld b, a + + cp EVOLVE_ITEM + jr z, .trade + + ld a, [wLinkMode] + and a + jr nz, EvolveAfterBattle_MasterLoop + + ld a, b + cp EVOLVE_STONE + jr z, .item + + ld a, [wForceEvolution] + and a + jr nz, EvolveAfterBattle_MasterLoop + + ld a, b + cp EVOLVE_LEVEL + jr z, .level + + ; EVOLVE_TRADE +.trade + ld a, [wLinkMode] + and a + jp z, .dont_evolve_1 + + ld a, [hli] + ld b, a + ld a, [wTempMonLevel] + cp b + jp c, EvolveAfterBattle_MasterLoop + + ld a, [hli] + ld b, a + and a + jr z, .proceed + ld a, [wTempMonItem] + cp b + jp nz, EvolveAfterBattle_MasterLoop + jr .proceed + +.item + ld a, [hli] + ld b, a + ld a, [wTempMonLevel] + cp b + jp c, .dont_evolve_2 + + ld a, [hli] + ld b, a + ld a, [wCurItem] + cp b + jp nz, .dont_evolve_3 + + jr .proceed + +.level + ld a, [hli] + ld b, a + ld a, [wTempMonLevel] + cp b + jp c, .dont_evolve_3 + +.proceed + ld a, [wTempMonLevel] + ld [wCurPartyLevel], a + ld a, 1 + ld [wMonTriedToEvolve], a + + push hl + + ld a, [hl] + ld [wEvolutionNewSpecies], a + ld a, [wCurPartyMon] + ld hl, wPartyMonNicknames + call GetNick + call CopyStringToStringBuffer2 + ld hl, EvolvingText + call PrintText + + ld c, 50 + call DelayFrames + + xor a + ldh [hBGMapMode], a + hlcoord 0, 0 + lb bc, 12, 20 + call ClearBox + + ld a, $1 + ldh [hBGMapMode], a + call ClearSprites + + call EvolutionAnimation + jp c, CancelEvolution + + ld hl, CongratulationsYourPokemonText + call PrintText + + pop hl + + ld a, [hl] + ld [wCurSpecies], a + ld [wTempMonSpecies], a + ld [wEvolutionNewSpecies], a + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + + push hl + + ld hl, EvolvedIntoText + call PrintTextBoxText + push de + ld de, MUSIC_NONE + call PlayMusic + ld de, SFX_GET_KEY_ITEM_RG + call PlaySFX + call WaitSFX + pop de + + ld c, 40 + call DelayFrames + + call ClearTileMap + call UpdateSpeciesNameIfNotNicknamed + call GetBaseData + + ld hl, wTempMonExp + 2 + ld de, wTempMonMaxHP + ld b, TRUE + predef CalcMonStats + + ld a, [wCurPartyMon] + ld hl, wPartyMons + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + ld e, l + ld d, h + ld bc, MON_MAXHP + add hl, bc + ld a, [hli] + ld b, a + ld c, [hl] + ld hl, wTempMonMaxHP + 1 + ld a, [hld] + sub c + ld c, a + ld a, [hl] + sbc b + ld b, a + ld hl, wTempMonHP + 1 + ld a, [hl] + add c + ld [hld], a + ld a, [hl] + adc b + ld [hl], a + + ld hl, wTempMonSpecies + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + + ld a, [wCurSpecies] + ld [wTempSpecies], a + xor a + ld [wMonType], a + call LearnLevelMoves + + ld a, [wBattleMode] + and a + call z, Evolve_ReloadTilesetIfNotLinked + + ld a, [wTempSpecies] + dec a + ld c, a + ld b, SET_FLAG + ld hl, wPokedexCaught + push bc + call EvoFlagAction + pop bc + ld hl, wPokedexSeen + call EvoFlagAction + pop de + pop hl + + ld a, [wTempMon] + ld [hl], a + push hl + ld l, e + ld h, d + jr .dont_evolve_3 + +.dont_evolve_1 + inc hl +.dont_evolve_2 + inc hl +.dont_evolve_3 + inc hl + jp .loop + +.ReturnToMap: + pop de + pop bc + pop hl + pop af + ldh [hMapAnims], a + ld a, [wLinkMode] + and a + ret nz + ld a, [wBattleMode] + and a + ret nz + ld a, [wMonTriedToEvolve] + and a + call nz, PlayMapMusic + ret + +UpdateSpeciesNameIfNotNicknamed: + ld a, [wCurSpecies] + push af + ld a, [wMonHIndex] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + pop af + ld [wCurSpecies], a + ld hl, wStringBuffer1 + ld de, wStringBuffer2 +.loop + ld a, [de] + inc de + cp [hl] + inc hl + ret nz + cp "@" + jr nz, .loop + + ld a, [wCurPartyMon] + ld bc, MON_NAME_LENGTH + ld hl, wPartyMonNicknames + call AddNTimes + push hl + ld a, [wCurSpecies] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld hl, wStringBuffer1 + pop de + ld bc, MON_NAME_LENGTH + jp CopyBytes + +CancelEvolution: + ld hl, StoppedEvolvingText + call PrintText + call ClearTileMap + pop hl + call Evolve_ReloadTilesetIfNotLinked + jp EvolveAfterBattle_MasterLoop + +CongratulationsYourPokemonText: + text "おめでとう! @" + text_from_ram wStringBuffer2 + text "は" + done + +EvolvedIntoText: + text "@" + text_from_ram wStringBuffer1 + text "に しんかした" + done + +StoppedEvolvingText: + text "あれ<⋯⋯>?" + line "@" + text_from_ram wStringBuffer2 + text "の へんかが とまった!" + prompt + +EvolvingText: + text "<⋯⋯> おや!?" + line "@" + text_from_ram wStringBuffer2 + text "の ようすが<⋯⋯>!" + done + +Evolve_ReloadTilesetIfNotLinked: + ld a, [wLinkMode] + and a + ret nz + jp LoadTilesetGFX_LCDOff + +LearnLevelMoves:: + ld a, [wTempSpecies] + ld [wCurPartySpecies], a + dec a + ld b, 0 + ld c, a + ld hl, EvosAttacksPointers + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + +.skip_evos + ld a, [hli] + and a + jr nz, .skip_evos + +.find_move + ld a, [hli] + and a + jr z, .done + + ld b, a + ld a, [wCurPartyLevel] + cp b + ld a, [hli] + jr nz, .find_move + + push hl + ld d, a + ld hl, wPartyMon1Moves + ld a, [wCurPartyMon] + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + + ld b, NUM_MOVES +.check_move + ld a, [hli] + cp d + jr z, .has_move + dec b + jr nz, .check_move + jr .learn +.has_move + + pop hl + jr .find_move + +.learn + ld a, d + ld [wPutativeTMHMMove], a + ld [wNamedObjectIndexBuffer], a + call GetMoveName + call CopyStringToStringBuffer2 + predef LearnMove + pop hl + jr .find_move + +.done + ld a, [wCurPartySpecies] + ld [wTempSpecies], a + ret + +FillMoves: +; Fill in moves at de for wCurPartySpecies at wCurPartyLevel + + push hl + push de + push bc + ld hl, EvosAttacksPointers + ld b, 0 + ld a, [wCurPartySpecies] + dec a + add a + rl b + ld c, a + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a +.GoToAttacks: + ld a, [hli] + and a + jr nz, .GoToAttacks + jr .GetLevel + +.NextMove: + pop de +.GetMove: + inc hl +.GetLevel: + ld a, [hli] + and a + jp z, .done + ld b, a + ld a, [wCurPartyLevel] + cp b + jp c, .done + ld a, [wSkipMovesBeforeLevelUp] + and a + jr z, .CheckMove + ld a, [wPrevPartyLevel] + cp b + jr nc, .GetMove + +.CheckMove: + push de + ld c, NUM_MOVES +.CheckRepeat: + ld a, [de] + inc de + cp [hl] + jr z, .NextMove + dec c + jr nz, .CheckRepeat + pop de + push de + ld c, NUM_MOVES +.CheckSlot: + ld a, [de] + and a + jr z, .LearnMove + inc de + dec c + jr nz, .CheckSlot + pop de + push de + push hl + ld h, d + ld l, e + call ShiftMoves + ld a, [wEvolutionOldSpecies] + and a + jr z, .ShiftedMove + push de + ld bc, wPartyMon1PP - (wPartyMon1Moves + NUM_MOVES - 1) + add hl, bc + ld d, h + ld e, l + call ShiftMoves + pop de + +.ShiftedMove: + pop hl + +.LearnMove: + ld a, [hl] + ld [de], a + ld a, [wEvolutionOldSpecies] + and a + jr z, .NextMove + push hl + ld a, [hl] + ld hl, MON_PP - MON_MOVES + add hl, de + push hl + dec a + ld hl, Moves + MOVE_PP + ld bc, MOVE_LENGTH + call AddNTimes + ld a, BANK(Moves) + call GetFarByte + pop hl + ld [hl], a + pop hl + jr .NextMove + +.done + pop bc + pop de + pop hl + ret + +ShiftMoves: + ld c, NUM_MOVES - 1 +.loop + inc de + ld a, [de] + ld [hli], a + dec c + jr nz, .loop + ret + +EvoFlagAction: + push de + ld d, $0 + predef SmallFarFlagAction + pop de + ret + +INCLUDE "engine/movie/evolution_animation.inc" diff --git a/engine/pokemon/knows_move.asm b/engine/pokemon/knows_move.asm new file mode 100644 index 0000000..65ba250 --- /dev/null +++ b/engine/pokemon/knows_move.asm @@ -0,0 +1,131 @@ +INCLUDE "constants.asm" + +SECTION "engine/pokemon/knows_move.asm", ROMX + +KnowsMove: + ld a, MON_MOVES + call GetPartyParamLocation + ld a, [wPutativeTMHMMove] + ld b, a + ld c, NUM_MOVES +.loop + ld a, [hli] + cp b + jr z, .knows_move + dec c + jr nz, .loop + and a + ret + +.knows_move + ld hl, KnowsMoveText + call PrintText + scf + ret + +KnowsMoveText: + text_from_ram wStringBuffer1 + text "は すでに" + line "@" + text_from_ram wStringBuffer2 + text "を おぼえています" + prompt + +Bank03_FillerStart:: +Unreferenced_BootedHMTextfde0: + db "います" + prompt +; This is missing the preceeding "text_from_ram" byte + dw wStringBuffer2 + text "を おぼえています" + prompt + db $28, $3c + +Unreferenced_KnowsMoveText_Old: + ld a, [wPutativeTMHMMove] + ld b, a + ld c, NUM_MOVES +.loop + ld a, [hli] + cp b + jr z, .knows_move + dec c + jr nz, .loop + and a + ret + +.knows_move + ld hl, .KnowsMoveText + call PrintText + scf + ret + +.KnowsMoveText + text_from_ram wStringBuffer1 + text "は すでに" + line "@" + text_from_ram wStringBuffer2 + text "を おぼえています" + prompt + +Unreferenced_Fillerfe23: + db $e0, $22, $47, $24, $80, $a3, $01, $50 + db $02, $85, $b0, $09, $35, $51, $2c, $08 + db $24, $25, $0b, $84, $84, $00, $4e, $3b + db $4b, $02, $60, $2a, $26, $21, $01, $40 + db $10, $1f, $31, $44, $80, $08, $02, $3c + db $41, $00, $68, $49, $57, $41, $94, $00 + db $34, $36, $9c, $e4, $01, $0c, $60, $01 + db $81, $23, $a2, $26, $43, $05, $81, $5f + db $16, $a2, $80, $34, $0c, $82, $63, $91 + db $44, $52, $02, $ce, $00, $10, $44, $01 + db $96, $0e, $ac, $10, $23, $84, $28, $00 + db $22, $45, $22, $55, $00, $ef, $ff, $77 + db $5b, $fe, $87, $db, $df, $b5, $bf, $d7 + db $1f, $d9, $fc, $e9, $fd, $df, $79, $96 + db $7d, $af, $d7, $5e, $17, $37, $e7, $ef + db $3e, $ff, $f9, $d4, $7d, $bf, $fb, $df + db $bb, $fe, $db, $53, $fb, $cc, $d3, $fe + db $92, $7f, $bb, $bc, $d7, $3b, $dd, $6f + db $7b, $2f, $b7, $ff, $b9, $d0, $b7, $e5 + db $7b, $e0, $c7, $bf, $dd, $df, $6d, $bb + db $f6, $f7, $73, $f9, $ff, $bc, $bb, $f7 + db $fd, $bd, $db, $e7, $be, $7b, $35, $5b + db $f3, $98, $df, $f4, $2f, $fb, $ff, $6b + db $fe, $ef, $6b, $ec, $1f, $7a, $3e, $ea + db $9b, $dd, $df, $ed, $ff, $fe, $bf, $26 + db $7d, $9e, $ef, $be, $ff, $77, $fb, $ff + db $ff, $5e, $f2, $bc, $fd, $7a, $aa, $fa + db $af, $9d, $ed, $f1, $fd, $10, $10, $2d + db $d1, $00, $21, $14, $d3, $1b, $27, $22 + db $85, $45, $5a, $43, $0c, $b1, $74, $61 + db $48, $40, $2f, $8c, $84, $08, $c2, $90 + db $f7, $44, $45, $80, $90, $12, $c5, $93 + db $1c, $11, $6e, $c8, $26, $25, $c1, $25 + db $00, $1e, $55, $02, $54, $04, $0f, $10 + db $20, $d7, $a2, $3c, $04, $3b, $02, $01 + db $22, $00, $c0, $00, $13, $d2, $05, $02 + db $48, $2a, $89, $40, $1f, $3e, $44, $12 + db $40, $16, $d8, $91, $10, $01, $54, $87 + db $1f, $99, $40, $d0, $79, $f8, $25, $4c + db $d0, $a0, $02, $13, $1c, $02, $03, $11 + db $a0, $19, $06, $0e, $70, $97, $44, $0e + db $11, $24, $0f, $80, $60, $06, $09, $01 + db $c5, $e1, $30, $13, $15, $14, $59, $02 + db $4c, $a9, $11, $08, $04, $eb, $df, $9d + db $55, $ff, $b7, $57, $fb, $78, $7e, $7e + db $c7, $3a, $e1, $ff, $5f, $7d, $5f, $fd + db $5f, $f8, $6d, $2f, $bd, $75, $6f, $3f + db $ff, $9f, $fc, $b5, $f6, $c5, $14, $fa + db $d9, $ff, $9d, $fb, $7f, $f3, $ff, $6b + db $fb, $9f, $eb, $5f, $df, $de, $ed, $bf + db $7f, $59, $26, $df, $ee, $b3, $5f, $fd + db $f7, $ff, $ff, $ff, $5b, $f8, $db, $fa + db $7f, $de, $af, $5f, $df, $9f, $d8, $be + db $ea, $bf, $fe, $eb, $dd, $eb, $f9, $e5 + db $bd, $f3, $ff, $fe, $ff, $f7, $f7, $d5 + db $f5, $f9, $5f, $bf, $fd, $5e, $df, $de + db $ff, $bf, $bb, $93, $fc, $ff, $cc, $af + db $f5, $d7, $7f, $ff, $fe, $b5, $ff, $9f + db $95, $7a, $6b, $7b, $ff, $6f, $bb, $c7 + db $ef, $34, $ff, $d7, $3d diff --git a/engine/pokemon/learn.asm b/engine/pokemon/learn.asm index d881f39..801a821 100644 --- a/engine/pokemon/learn.asm +++ b/engine/pokemon/learn.asm @@ -121,7 +121,7 @@ ForgetMove:: call PrintText hlcoord 10, 8 ld b, NUM_MOVES * 2 - ld c, MOVE_NAME_LENGTH + 3 + ld c, MOVE_NAME_LENGTH call DrawTextBox hlcoord 12, 10 ld a, SCREEN_WIDTH * 2 @@ -147,7 +147,7 @@ ForgetMove:: ld [w2DMenuFlags2], a ld a, $20 ld [w2DMenuCursorOffsets], a - call Get2DMenuJoypad + call StaticMenuJoypad push af call ReloadTilesFromBuffer pop af diff --git a/engine/pokemon/mon_submenu.asm b/engine/pokemon/mon_submenu.asm new file mode 100644 index 0000000..5ba5ee5 --- /dev/null +++ b/engine/pokemon/mon_submenu.asm @@ -0,0 +1,290 @@ +INCLUDE "constants.asm" + +SECTION "engine/pokemon/mon_submenu.asm", ROMX + +INCLUDE "data/mon_menu.inc" + +MonSubmenu:: + xor a + ldh [hBGMapMode], a + call GetMonSubmenuItems + callfar FreezeMonIcons + ld hl, .MenuHeader + call LoadMenuHeader + call .GetTopCoord + call PopulateMonMenu + + ld a, 1 + ldh [hBGMapMode], a + call MonMenuLoop + ld [wMenuSelection], a + + call CloseWindow + ret + +.MenuHeader: + db MENU_BACKUP_TILES ; flags + menu_coords 11, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 + dw 0 + db 1 ; default option + +.GetTopCoord: +; [wMenuBorderTopCoord] = 1 + [wMenuBorderBottomCoord] - 2 * ([wMonSubmenuCount] + 1) + ld a, [wMonSubmenuCount] + inc a + add a + ld b, a + ld a, [wMenuBorderBottomCoord] + sub b + inc a + ld [wMenuBorderTopCoord], a + call MenuBox + ret + +MonMenuLoop: +.loop + ld a, MENU_UNUSED | MENU_BACKUP_TILES_2 + ld [wMenuDataFlags], a + ld a, [wMonSubmenuCount] + ld [wMenuDataItems], a + call InitVerticalMenuCursor + + ld hl, w2DMenuFlags1 + set _2DMENU_ENABLE_SPRITE_ANIMS_F, [hl] + + call StaticMenuJoypad + ldh a, [hJoyDown] + bit A_BUTTON_F, a + jr nz, .select + bit B_BUTTON_F, a + jr nz, .cancel + jr .loop + +.cancel + ld a, MONMENUITEM_CANCEL + ret + +.select + ld a, [wMenuCursorY] + dec a + ld c, a + ld b, 0 + ld hl, wMonSubmenuItems + add hl, bc + ld a, [hl] + ret + +PopulateMonMenu: + call MenuBoxCoord2Tile + ld bc, 2 * SCREEN_WIDTH + 2 + add hl, bc + ld de, wMonSubmenuItems +.loop + ld a, [de] + inc de + cp -1 + ret z + push de + push hl + call GetMonMenuString + pop hl + call PlaceString + ld bc, 2 * SCREEN_WIDTH + add hl, bc + pop de + jr .loop + +GetMonMenuString: + dec a + ld b, a + add a + add b + ld c, a + ld b, 0 + ld hl, MonMenuOptions + add hl, bc + ld a, [hli] + and a ; if MONMENU_MENUOPTION + jr z, .NotMove + inc hl + ld a, [hl] + ld [wNamedObjectIndexBuffer], a + call GetMoveName + ret + +.NotMove: + inc hl + ld a, [hl] + dec a + ld hl, MonMenuOptionStrings + call GetNthString + ld d, h + ld e, l + ret + +GetMonSubmenuItems: + call ResetMonSubmenu + ld a, MON_MOVES + call GetPartyParamLocation + ld d, h + ld e, l + ld hl, wMonSubmenuItems + ld c, NUM_MOVES + +.loop + push bc + push de + ld a, [de] + and a ; no move in this slot + jr z, .next + + push hl + call IsFieldMove + + pop hl + jr nc, .next + call AddMonMenuItem + +.next + pop de + inc de + pop bc + dec c + jr nz, .loop + + ld a, MONMENUITEM_STATS + call AddMonMenuItem + ld a, MONMENUITEM_SWITCH + call AddMonMenuItem + ld a, MONMENUITEM_MOVE + call AddMonMenuItem + + push hl + ld a, MON_ITEM + call GetPartyParamLocation + ld a, [hl] + pop hl + cp ITEM_MAIL + ld a, MONMENUITEM_ITEM + jr nz, .notmail + ld a, MONMENUITEM_MAIL + +.notmail + call AddMonMenuItem + ld a, [wMonSubmenuCount] + cp NUM_MONMENU_ITEMS + jr z, .maxitems + + ld a, MONMENUITEM_CANCEL + call AddMonMenuItem + +.maxitems + call TerminateMonSubmenu + ret + +IsFieldMove: + ld b, a + ld hl, MonMenuOptions +.next + ld a, [hli] + cp -1 + jr z, .nope + and a ; MONMENU_MENUOPTION + jr z, .nope + ld d, [hl] + inc hl + ld a, [hli] + cp b + jr nz, .next + ld a, d + scf + +.nope + ret + +ResetMonSubmenu: + xor a + ld [wMonSubmenuCount], a + ld hl, wMonSubmenuItems + ld bc, NUM_MONMENU_ITEMS + 1 + call ByteFill + ret + +TerminateMonSubmenu: + ld a, [wMonSubmenuCount] + ld e, a + ld d, 0 + ld hl, wMonSubmenuItems + add hl, de + ld [hl], -1 + ret + +AddMonMenuItem: + push hl + push de + push af + ld a, [wMonSubmenuCount] + ld e, a + inc a + ld [wMonSubmenuCount], a + ld d, 0 + ld hl, wMonSubmenuItems + add hl, de + pop af + ld [hl], a + pop de + pop hl + ret + +BattleMonMenu: + ld hl, .MenuHeader + call CopyMenuHeader + xor a + ldh [hBGMapMode], a + call MenuBox + call UpdateSprites + call PlaceVerticalMenuItems + call WaitBGMap + + ld hl, wMenuDataPointer + ld a, [hli] + ld h, [hl] + ld l, a + ld de, wMenuData + ld bc, wMenuDataEnd - wMenuData + call CopyBytes + + ld a, [wMenuDataFlags] + bit STATICMENU_CURSOR_F, a + jr z, .set_carry + call InitVerticalMenuCursor + ld hl, w2DMenuFlags1 + set _2DMENU_ENABLE_SPRITE_ANIMS_F, [hl] + call StaticMenuJoypad + bit B_BUTTON_F, a + jr z, .clear_carry + ret z + +.set_carry + scf + ret + +.clear_carry + and a + ret + +; Unreferenced. + ret + +.MenuHeader: + db 0 ; flags + menu_coords 11, 11, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 + dw .MenuText + db 1 ; default option + +.MenuText: + db (STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING) + db 3 + db "とりかえる@" ; Switch + db "つよさをみる@" ; Stats + db "キャンセル@" ; Cancel diff --git a/engine/pokemon/move_mon.asm b/engine/pokemon/move_mon.asm new file mode 100644 index 0000000..4b4f5a1 --- /dev/null +++ b/engine/pokemon/move_mon.asm @@ -0,0 +1,1503 @@ +INCLUDE "constants.asm" + +SECTION "engine/pokemon/move_mon.asm", ROMX + +TryAddMonToParty:: +; Check if to copy wild mon or generate a new one + ; Whose is it? + ld de, wPartyCount + ld a, [wMonType] + and $f + jr z, .getpartylocation ; PARTYMON + ld de, wOTPartyCount + +.getpartylocation + ; Do we have room for it? + ld a, [de] + inc a + cp PARTY_LENGTH + 1 + ret nc + ; Increase the party count + ld [de], a + ld a, [de] ; Why are we doing this? + ldh [hMoveMon], a ; HRAM backup + add e + ld e, a + jr nc, .loadspecies + inc d + +.loadspecies + ; Load the species of the Pokemon into the party list. + ; The terminator is usually here, but it'll be back. + ld a, [wCurPartySpecies] + ld [de], a + ; Load the terminator into the next slot. + inc de + ld a, -1 + ld [de], a + ; Now let's load the OT name. + ld hl, wPartyMonOTs + ld a, [wMonType] + and $f + jr z, .loadOTname + ld hl, wOTPartyMonOT + +.loadOTname + ldh a, [hMoveMon] ; Restore index from backup + dec a + call SkipNames + ld d, h + ld e, l + ld hl, wPlayerName + ld bc, PLAYER_NAME_LENGTH + call CopyBytes + ; Only initialize the nickname for party mon + ld a, [wMonType] + and a + jr nz, .skipnickname + ld a, [wCurPartySpecies] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld hl, wPartyMonNicknames + ldh a, [hMoveMon] + dec a + call SkipNames + ld d, h + ld e, l + ld hl, wStringBuffer1 + ld bc, MON_NAME_LENGTH + call CopyBytes + +.skipnickname + ld hl, wPartyMon1 + ld a, [wMonType] + and $f + jr z, .initializeStats + ld hl, wOTPartyMons + +.initializeStats + ldh a, [hMoveMon] + dec a + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + ld e, l + ld d, h + push hl + ; Initialize the species + ld a, [wCurPartySpecies] + ld [wCurSpecies], a + call GetBaseData + ld a, [wMonHIndex] + ld [de], a + inc de + + ; Copy the item if it's a wild mon + ld a, [wBattleMode] + and a + jr z, .skipitem + ld a, [wEnemyMonItem] + ld [de], a +.skipitem + inc de + + ; Copy the moves if it's a wild mon + push de + xor a + ld [wFieldMoveScriptID], a + predef FillMoves + pop de +rept NUM_MOVES + inc de +endr + + ; Initialize ID. + ld a, [wPlayerID] + ld [de], a + inc de + ld a, [wPlayerID + 1] + ld [de], a + inc de + + ; Initialize Exp. + push de + ld a, [wCurPartyLevel] + ld d, a + callfar CalcExpAtLevel + pop de + ldh a, [hProduct + 1] + ld [de], a + inc de + ldh a, [hProduct + 2] + ld [de], a + inc de + ldh a, [hProduct + 3] + ld [de], a + inc de + + ; Initialize stat experience. + xor a + ld b, MON_DVS - MON_STAT_EXP + +.loop + ld [de], a + inc de + dec b + jr nz, .loop + pop hl + push hl + ld a, [wMonType] + and $f + ln a, 9, 8 + ln b, 8, 8 + jr nz, .initializeDVs + +; Check if mon is caught + ld a, [wCurPartySpecies] + ld [wTempSpecies], a + dec a + ld c, a + ld b, CHECK_FLAG + ld hl, wPokedexCaught + push de + ld d, 3 + call SmallFarFlagAction + pop de + +; Set the mon's caught and seen flags + ld a, c + ld a, [wTempSpecies] + dec a + ld c, a + ld b, SET_FLAG + push bc + call SmallFarFlagAction + pop bc + ld hl, wPokedexSeen + call SmallFarFlagAction + pop hl + push hl + ld a, [wBattleMode] + and a + jr nz, .copywildmonDVs + call Random + ld b, a + call Random +.initializeDVs + ld [de], a + inc de + ld a, b + ld [de], a + inc de + + ; Initialize PP. + push hl + push de + inc hl + inc hl + call FillPP + pop de + pop hl +rept NUM_MOVES + inc de +endr + + ; Initialize happiness. + ld a, BASE_HAPPINESS + ld [de], a + inc de + + ; Doesn't initialize these three values whatsoever. (Unused1 - Unused3) + inc de + inc de + inc de + + ; Initialize level. + ld a, [wCurPartyLevel] + ld [de], a + inc de + + xor a + ; Status + ld [de], a + inc de + ; Unused + ld [de], a + inc de + + ; Initialize HP. + ld bc, MON_STAT_EXP - 1 + add hl, bc + ld a, 1 + ld c, a + xor a ; FALSE + ld b, a + call CalcMonStatC + ldh a, [hProduct + 2] + ld [de], a + inc de + ldh a, [hProduct + 3] + ld [de], a + inc de + jr .initstats + +.copywildmonDVs + ld a, [wEnemyMonDVs] + ld [de], a + inc de + ld a, [wEnemyMonDVs + 1] + ld [de], a + inc de + + push hl + ld hl, wEnemyMonPP + ld b, NUM_MOVES +.wildmonpploop + ld a, [hli] + ld [de], a + inc de + dec b + jr nz, .wildmonpploop + pop hl + + ; Initialize happiness. + ld a, BASE_HAPPINESS + ld [de], a + inc de + + ; Doesn't initialize these three values whatsoever. (Unused1 - Unused3) + inc de + inc de + inc de + + ; Initialize level. + ld a, [wCurPartyLevel] + ld [de], a + inc de + + ld a, [wEnemyMonStatus] + ; Copy wEnemyMonStatus + ld [de], a + inc de + ld a, [wEnemyMonStatus + 1] + ; Copy EnemyMonUnused + ld [de], a + inc de + ; Copy wEnemyMonHP + ld a, [wEnemyMonHP] + ld [de], a + inc de + ld a, [wEnemyMonHP + 1] + ld [de], a + inc de + +.initstats + ld a, [wBattleMode] + dec a + jr nz, .generatestats + ld hl, wEnemyMonMaxHP + ld bc, PARTYMON_STRUCT_LENGTH - MON_MAXHP + call CopyBytes + pop hl + jr .done + +.generatestats + pop hl + ld bc, MON_STAT_EXP - 1 + add hl, bc + ld b, FALSE + call CalcMonStats +.done + scf + ret + +FillPP:: + ld b, NUM_MOVES +.loop + ld a, [hli] + and a + jr z, .next + dec a + push hl + push de + push bc + ld hl, Moves + ld bc, MOVE_LENGTH + call AddNTimes + ld de, wStringBuffer1 + ld a, BANK(Moves) + call FarCopyBytes + pop bc + pop de + pop hl + ld a, [wStringBuffer1 + MOVE_PP] +.next + ld [de], a + inc de + dec b + jr nz, .loop + ret + + +AddTempmonToParty: + ld hl, wPartyCount + ld a, [hl] + cp PARTY_LENGTH + scf + ret z + + inc a + ld [hl], a + ld c, a + ld b, 0 + add hl, bc + ld a, [wCurPartySpecies] + ld [hli], a + ld [hl], $ff + + ld hl, wPartyMon1Species + ld a, [wPartyCount] + dec a + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + ld e, l + ld d, h + ld hl, wTempMonSpecies + call CopyBytes + + ld hl, wPartyMonOTs + ld a, [wPartyCount] + dec a + call SkipNames + ld d, h + ld e, l + ld hl, wOTPartyMonOT + ld a, [wCurPartyMon] + call SkipNames + ld bc, MON_NAME_LENGTH + call CopyBytes + + ld hl, wPartyMonNicknames + ld a, [wPartyCount] + dec a + call SkipNames + ld d, h + ld e, l + ld hl, wOTPartyMonNicknames + ld a, [wCurPartyMon] + call SkipNames + ld bc, MON_NAME_LENGTH + call CopyBytes + + ld a, [wCurPartySpecies] + ld [wNamedObjectIndexBuffer], a + dec a + ld c, a + ld b, SET_FLAG + ld hl, wPokedexCaught + push bc + call SmallFarFlagAction + pop bc + ld hl, wPokedexSeen + call SmallFarFlagAction + and a + ret + +; Sents/Gets mon into/from Box depending on Parameter. +; wPokemonWithdrawDepositParameter == 0: get mon into Party. +; wPokemonWithdrawDepositParameter == 1: sent mon into Box. +; wPokemonWithdrawDepositParameter == 2: get mon from wBufferMon into Party. +; wPokemonWithdrawDepositParameter == 3: put mon into wBufferMon. +SendGetMonIntoFromBox:: + ld a, [wPokemonWithdrawDepositParameter] + and a + jr z, .check_IfPartyIsFull + cp BUFFERMON_WITHDRAW + jr z, .check_IfPartyIsFull + cp BUFFERMON_DEPOSIT + ld hl, wBufferMon + jr z, .buffermon + + ; we want to sent a mon into the Box + ; so check if there's enough space + ld hl, wBoxCount + ld a, [hl] + cp MONS_PER_BOX + jr nz, .there_is_room + jr .full + +.check_IfPartyIsFull + ld hl, wPartyCount + ld a, [hl] + cp PARTY_LENGTH + jr nz, .there_is_room + +.full + scf + ret +.there_is_room + inc a + ld [hl], a + ld c, a + ld b, 0 + add hl, bc + ld a, [wPokemonWithdrawDepositParameter] + cp BUFFERMON_WITHDRAW + ld a, [wBufferMonSpecies] + jr z, .okay1 + ld a, [wCurPartySpecies] + +.okay1 + ld [hli], a + ld [hl], -1 + ld a, [wPokemonWithdrawDepositParameter] + dec a + ld hl, wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH + ld a, [wPartyCount] + jr nz, .okay2 + ld hl, wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH + ld a, [wBoxCount] + +.okay2 + dec a ; wPartyCount - 1 + call AddNTimes +.buffermon + push hl + ld e, l + ld d, h + ld a, [wPokemonWithdrawDepositParameter] + and a + ld hl, wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH + jr z, .okay3 + cp BUFFERMON_WITHDRAW + ld hl, wBufferMon + jr z, .okay4 + ld hl, wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH + +.okay3 + ld a, [wCurPartyMon] + call AddNTimes + +.okay4 + ld bc, BOXMON_STRUCT_LENGTH + call CopyBytes + ld a, [wPokemonWithdrawDepositParameter] + cp BUFFERMON_DEPOSIT + ld de, wBufferMonOT + jr z, .okay5 + dec a + ld hl, wPartyMonOTs + ld a, [wPartyCount] + jr nz, .okay6 + ld hl, wBoxMonOTs + ld a, [wBoxCount] + +.okay6 + dec a + call SkipNames + ld d, h + ld e, l + +.okay5 + ld hl, wBoxMonOTs + ld a, [wPokemonWithdrawDepositParameter] + and a + jr z, .okay7 + ld hl, wBufferMonOT + cp BUFFERMON_WITHDRAW + jr z, .okay8 + ld hl, wPartyMonOTs + +.okay7 + ld a, [wCurPartyMon] + call SkipNames + +.okay8 + ld bc, PLAYER_NAME_LENGTH + call CopyBytes + ld a, [wPokemonWithdrawDepositParameter] + cp BUFFERMON_DEPOSIT + ld de, wBufferMonNickname + jr z, .okay9 + dec a + ld hl, wPartyMonNicknames + ld a, [wPartyCount] + jr nz, .okay10 + ld hl, wBoxMonNicknames + ld a, [wBoxCount] + +.okay10 + dec a + call SkipNames + ld d, h + ld e, l + +.okay9 + ld hl, wBoxMonNicknames + ld a, [wPokemonWithdrawDepositParameter] + and a + jr z, .okay11 + ld hl, wBufferMonNickname + cp BUFFERMON_WITHDRAW + jr z, .okay12 + ld hl, wPartyMonNicknames + +.okay11 + ld a, [wCurPartyMon] + call SkipNames +.okay12 + ld bc, MON_NAME_LENGTH + call CopyBytes + pop hl + + ld a, [wPokemonWithdrawDepositParameter] + cp PC_DEPOSIT + jr z, .done_clear_carry + cp BUFFERMON_DEPOSIT + jr z, .done_clear_carry + + push hl + srl a + add $2 + ld [wMonType], a + predef CopyMonToTempMon + farcall CalcLevel + ld a, d + ld [wCurPartyLevel], a + pop hl + ld b, h + ld c, l + ld hl, MON_LEVEL + add hl, bc + ld [hl], a + ld hl, MON_MAXHP + add hl, bc + ld d, h + ld e, l + ld hl, MON_STAT_EXP - 1 + add hl, bc + + push bc + ld b, TRUE + call CalcMonStats + pop bc + + ld a, [wPokemonWithdrawDepositParameter] + and a + jr nz, .done_clear_carry + ld hl, MON_HP + add hl, bc + ld d, h + ld e, l + inc hl + inc hl + ld a, [hli] + ld [de], a + ld a, [hl] + inc de + ld [de], a +.done_clear_carry + and a + ret + +; TODO: Might not be for breedmon? +RetrieveBreedmonOrBuffermon: + ld hl, wPartyCount + ld a, [hl] + cp PARTY_LENGTH + push af + jr nz, .room_in_party_or_box + ld hl, wBoxCount + ld a, [hl] + cp MONS_PER_BOX + jr nz, .room_in_party_or_box + pop af + scf + ret + +.room_in_party_or_box + inc a + ld [hl], a + ld c, a + ld b, 0 + add hl, bc + ld a, [wPokemonWithdrawDepositParameter] + and a + ld a, [wBufferMonSpecies] + ld de, wBufferMonNickname + jr z, .okay ; unused in practice + + ld a, [wBreedMon1Species] + ld de, wBreedMon1Nickname + +.okay + ld [hli], a + ld [wCurSpecies], a + ld a, -1 + ld [hl], a + pop af ; if wPartyCount = PARTY_LENGTH + jr z, .party_full + + ld hl, wPartyMonNicknames + ld a, [wPartyCount] + dec a + ld bc, MON_NAME_LENGTH + call AddNTimes + push hl + ld h, d + ld l, e + pop de + call CopyBytes + push hl + + ld hl, wPartyMonOTs + ld a, [wPartyCount] + dec a + ld bc, PLAYER_NAME_LENGTH + call AddNTimes + ld d, h + ld e, l + pop hl + call CopyBytes + push hl + + ld hl, wPartyMons + ld a, [wPartyCount] + dec a + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + ld d, h + ld e, l + pop hl + ld bc, BOXMON_STRUCT_LENGTH + call CopyBytes + call GetBaseData + + ld h, d + ld l, e + dec hl + ld a, [hl] + ld [wCurPartyLevel], a + inc de + inc de + push de + inc de + inc de + push de + ld bc, -(BOXMON_STRUCT_LENGTH - MON_STAT_EXP) + add hl, bc + ld b, TRUE + call CalcMonStats + pop hl + pop de + ld a, [hli] + ld [de], a + inc de + ld a, [hl] + ld [de], a + jr .done + +.party_full + ld hl, wBoxMonNicknames + ld a, [wBoxCount] + ld bc, MON_NAME_LENGTH + call AddNTimes + push hl + ld h, d + ld l, e + pop de + call CopyBytes + push hl + + ld hl, wBoxMonOTs + ld a, [wBoxCount] + ld bc, PLAYER_NAME_LENGTH + call AddNTimes + ld d, h + ld e, l + pop hl + call CopyBytes + push hl + + ld hl, wBoxMons + ld a, [wBoxCount] + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + ld d, h + ld e, l + pop hl + ld bc, BOXMON_STRUCT_LENGTH + call CopyBytes + +.done + ld a, [wPokemonWithdrawDepositParameter] + and a + ret z + ld hl, wBreedMon2Nickname + ld de, wBreedMon1Nickname + ld bc, MON_NAME_LENGTH + PLAYER_NAME_LENGTH + BOXMON_STRUCT_LENGTH + call CopyBytes + and a + ret + +DepositBreedmonOrBuffermon:: + ld a, [wPokemonWithdrawDepositParameter] + ld de, wBufferMonNickname + and a + jr z, .buffer_mon + + ld hl, wBreedMon1Nickname + ld de, wBreedMon2Nickname + ld bc, MON_NAME_LENGTH + call CopyBytes + + ld hl, wBreedMon1OT + ld de, wBreedMon2OT + ld bc, PLAYER_NAME_LENGTH + call CopyBytes + + ld hl, wBreedMon1 + ld de, wBreedMon2 + ld bc, BOXMON_STRUCT_LENGTH + call CopyBytes + ld de, wBreedMon1Nickname + +.buffer_mon + ld a, [wCurPartyMon] + ld hl, wPartyMonNicknames + ld bc, MON_NAME_LENGTH + call AddNTimes + call CopyBytes + + ld a, [wCurPartyMon] + ld hl, wPartyMonOTs + ld bc, PLAYER_NAME_LENGTH + call AddNTimes + call CopyBytes + + ld a, [wCurPartyMon] + ld hl, wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + ld bc, BOXMON_STRUCT_LENGTH + jp CopyBytes + +; Sends the mon into one of ???'s Boxes. +; The data comes mainly from 'wEnemyMon'. +SendMonIntoBox:: + ld de, wBoxCount + ld a, [de] + cp MONS_PER_BOX + ret nc + inc a + ld [de], a + + ld a, [wCurPartySpecies] + ld [wCurSpecies], a + ld c, a +.loop + inc de ; wBoxSpecies + ld a, [de] + ld b, a + ld a, c + ld c, b + ld [de], a + cp -1 + jr nz, .loop + + call GetBaseData + ld hl, wBoxMonOTs + ld bc, PLAYER_NAME_LENGTH + ld a, [wBoxCount] + dec a + jr z, .copy_ot + dec a + call AddNTimes + push hl + + ld bc, PLAYER_NAME_LENGTH + add hl, bc + ld d, h + ld e, l + pop hl + ld a, [wBoxCount] + dec a + ld b, a + +.shift_mon_ot + push bc + push hl + ld bc, PLAYER_NAME_LENGTH + call CopyBytes + pop hl + ld d, h + ld e, l + ld bc, -(PLAYER_NAME_LENGTH) + add hl, bc + pop bc + dec b + jr nz, .shift_mon_ot + +.copy_ot + ld hl, wPlayerName + ld de, wBoxMonOTs + ld bc, PLAYER_NAME_LENGTH + call CopyBytes + + ld a, [wBoxCount] + dec a + jr z, .copy_nickname + + ld hl, wBoxMonNicknames + ld bc, MON_NAME_LENGTH + dec a + call AddNTimes + push hl + + ld bc, MON_NAME_LENGTH + add hl, bc + ld d, h + ld e, l + pop hl + ld a, [wBoxCount] + dec a + ld b, a + +.shift_loop_mon_name + push bc + push hl + ld bc, MON_NAME_LENGTH + call CopyBytes + pop hl + ld d, h + ld e, l + ld bc, -(MON_NAME_LENGTH) + add hl, bc + pop bc + dec b + jr nz, .shift_loop_mon_name + +.copy_nickname + ld a, [wCurPartySpecies] + ld [wTempSpecies], a + call GetPokemonName + ld de, wBoxMonNicknames + ld hl, wStringBuffer1 + ld bc, MON_NAME_LENGTH + call CopyBytes + + ld a, [wBoxCount] + dec a + jr z, .copy_boxmon + + ld hl, wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH + dec a + call AddNTimes + push hl + ld bc, BOXMON_STRUCT_LENGTH + add hl, bc + ld d, h + ld e, l + pop hl + ld a, [wBoxCount] + dec a + ld b, a + +.shift_loop_boxmon + push bc + push hl + ld bc, BOXMON_STRUCT_LENGTH + call CopyBytes + pop hl + ld d, h + ld e, l + ld bc, -(BOXMON_STRUCT_LENGTH) + add hl, bc + pop bc + dec b + jr nz, .shift_loop_boxmon + +.copy_boxmon + ld hl, wEnemyMon + ld de, wBoxMons + ld bc, (wEnemyMonMovesEnd - wEnemyMon) + call CopyBytes + + ; Copy player ID + ld hl, wPlayerID + ld a, [hli] + ld [de], a + inc de + ld a, [hl] + ld [de], a + inc de + push de + + ; Get experience points + ld a, [wCurPartyLevel] + ld d, a + callfar CalcExpAtLevel + pop de + ldh a, [hProduct + 1] + ld [de], a + inc de + ldh a, [hProduct + 2] + ld [de], a + inc de + ldh a, [hProduct + 3] + ld [de], a + inc de + xor a + ld b, (NUM_EXP_STATS * 2) +.skip_stat_exp + ld [de], a + inc de + dec b + jr nz, .skip_stat_exp + ld hl, wEnemyMonDVs + ld b, (wBoxMon1Happiness - wBoxMon1DVs) + 1 +.copy_dvs_pp_happiness + ld a, [hli] + ld [de], a + inc de + dec b + jr nz, .copy_dvs_pp_happiness + + xor a + ld [de], a + inc de + ld [de], a + inc de + ld [de], a + inc de + ld a, [wCurPartyLevel] + ld [de], a + scf + ret + +; Generates a hybrid of the most recently deposited BreedMon and DEX_EGG. +GiveEgg:: + ld a, [wPartyCount] + cp PARTY_LENGTH + jr z, .party_full + call TryAddMonToParty + ld de, wPartyMonNicknames + ld hl, wPartyCount + jr .next + +.party_full + ld a, [wBoxCount] + cp MONS_PER_BOX + scf + ret z + ld a, [wCurPartySpecies] + ld [wTempEnemyMonSpecies], a + xor a + ld [wEnemySubStatus5], a ; ??? + callfar LoadEnemyMon + call SendMonIntoBox + ld de, wBoxMonNicknames + ld hl, wBoxCount + +.next + ld a, [hl] + push af + ld b, 0 + ld c, a + add hl, bc + ld a, DEX_EGG + ld [hl], a + pop af + + dec a + ld h, d + ld l, e + ld bc, MON_NAME_LENGTH + call AddNTimes + +; Print "EGG" as its name + ld a, "た" + ld [hli], a + ld a, "ま" + ld [hli], a + ld a, "ご" + ld [hli], a + ld [hl], "@" + and a + ret + +RemoveMonFromPartyOrBox: + ld hl, wPartyCount + + ld a, [wPokemonWithdrawDepositParameter] + and a + jr z, .okay + + ld hl, wBoxCount + +.okay + ld a, [hl] + dec a + ld [hli], a + ld a, [wCurPartyMon] + ld c, a + ld b, 0 + add hl, bc + ld e, l + ld d, h + inc de +.loop + ld a, [de] + inc de + ld [hli], a + inc a + jr nz, .loop + ld hl, wPartyMonOTs + ld d, PARTY_LENGTH - 1 + ld a, [wPokemonWithdrawDepositParameter] + and a + jr z, .party + ld hl, wBoxMonOTs + ld d, MONS_PER_BOX - 1 + +.party + ; If this is the last mon in our party (box), + ; shift all the other mons up to close the gap. + ld a, [wCurPartyMon] + call SkipNames + ld a, [wCurPartyMon] + cp d + jr nz, .delete_inside + ld [hl], -1 + ret + +.delete_inside + ; Shift the OT names + ld d, h + ld e, l + ld bc, MON_NAME_LENGTH + add hl, bc + ld bc, wPartyMonNicknames + ld a, [wPokemonWithdrawDepositParameter] + and a + jr z, .party2 + ld bc, wBoxMonNicknames +.party2 + call CopyDataUntil + ld hl, wPartyMons + ld bc, PARTYMON_STRUCT_LENGTH + ld a, [wPokemonWithdrawDepositParameter] + and a + jr z, .party3 + ld hl, wBoxMons + ld bc, BOXMON_STRUCT_LENGTH +.party3 + ld a, [wCurPartyMon] + call AddNTimes + ld d, h + ld e, l + ld a, [wPokemonWithdrawDepositParameter] + and a + jr z, .party4 + ld bc, BOXMON_STRUCT_LENGTH + add hl, bc + ld bc, wBoxMonOTs + jr .copy + +.party4 + ld bc, PARTYMON_STRUCT_LENGTH + add hl, bc + ld bc, wPartyMonOTs +.copy + call CopyDataUntil + ld hl, wPartyMonNicknames + ld a, [wPokemonWithdrawDepositParameter] + and a + jr z, .party5 + ld hl, wBoxMonNicknames +.party5 + ld bc, MON_NAME_LENGTH + ld a, [wCurPartyMon] + call AddNTimes + ld d, h + ld e, l + ld bc, MON_NAME_LENGTH + add hl, bc + ld bc, wPartyMonNicknamesEnd + ld a, [wPokemonWithdrawDepositParameter] + and a + jr z, .party6 + ld bc, wBoxMonNicknamesEnd +.party6 + jp CopyDataUntil + +CalcMonStats:: + ld c, $00 +.loop + inc c + call CalcMonStatC + ldh a, [hProduct + 2] + ld [de], a + inc de + ldh a, [hProduct + 3] + ld [de], a + inc de + ld a, c + cp STAT_SDEF + jr nz, .loop + ret + +CalcMonStatC:: +; 'c' is 1-6 and points to the BaseStat +; 1: HP +; 2: Attack +; 3: Defense +; 4: Speed +; 5: SpAtk +; 6: SpDef + push hl + push de + push bc + ld a, b + ld d, a + + push hl + ld hl, wMonHBaseStats + dec hl + ld b, $0 + add hl, bc + ld a, [hl] + ld e, a + pop hl + push hl + ld a, c +; Special defense shares stat exp with special attack + cp STAT_SDEF + jr nz, .not_spdef + dec hl + dec hl + +.not_spdef + sla c + ld a, d + and a + jr z, .no_stat_exp + add hl, bc + +.sqrt_loop + xor a + ldh [hMultiplicand], a + ldh [hMultiplicand + 1], a + inc b + ld a, b + cp -1 + jr z, .no_stat_exp + + ldh [hMultiplicand + 2], a + ldh [hMultiplier], a + call Multiply + + ld a, [hld] + ld d, a + ldh a, [hProduct + 3] + sub d + ld a, [hli] + ld d, a + ldh a, [hProduct + 2] + sbc d + jr c, .sqrt_loop + +.no_stat_exp + srl c + pop hl + push bc + ld bc, MON_DVS - MON_HP_EXP + 1 + add hl, bc + pop bc + ld a, c + cp STAT_ATK + jr z, .Attack + cp STAT_DEF + jr z, .Defense + cp STAT_SPD + jr z, .Speed + cp STAT_SATK + jr z, .Special + cp STAT_SDEF + jr z, .Special +; DV_HP = (DV_ATK & 1) << 3 | (DV_DEF & 1) << 2 | (DV_SPD & 1) << 1 | (DV_SPC & 1) + push bc + ld a, [hl] + swap a + and $01 + add a + add a + add a + ld b, a + ld a, [hli] + and $01 + add a + add a + add b + ld b, a + ld a, [hl] + swap a + and $01 + add b + add b + ld b, a + ld a, [hl] + and $01 + add b + pop bc + jr .GotDV + +.Attack + ld a, [hl] + swap a + and $f + jr .GotDV + +.Defense + ld a, [hl] + and $f + jr .GotDV + +.Speed + inc hl + ld a, [hl] + swap a + and $f + jr .GotDV + +.Special + inc hl + ld a, [hl] + and $f + +.GotDV + ld d, $00 + add e + ld e, a + jr nc, .no_overflow_1 + inc d + +.no_overflow_1 + sla e + rl d + srl b + srl b + ld a, b + add e + jr nc, .no_overflow_2 + inc d + +.no_overflow_2 + ldh [hMultiplicand + 2], a + ld a, d + ldh [hMultiplicand + 1], a + xor a + ldh [hMultiplicand], a + ld a, [wCurPartyLevel] + ldh [hMultiplier], a + call Multiply + + ldh a, [hProduct + 1] + ldh [hDividend], a + ldh a, [hMultiplicand + 1] + ldh [hDividend + 1], a + ldh a, [hMultiplicand + 2] + ldh [hDividend + 2], a + ld a, MAX_LEVEL + ldh [hDivisor], a + ld a, 3 + ld b, a + call Divide + + ld a, c + cp STAT_HP + ld a, STAT_MIN_NORMAL + jr nz, .not_hp + ld a, [wCurPartyLevel] + ld b, a + ldh a, [hDividend+3] + add b + ldh [hDividend+3], a + jr nc, .no_overflow_3 + ldh a, [hDividend+2] + inc a + ldh [hDividend+2], a + +.no_overflow_3 + ld a, STAT_MIN_HP + +.not_hp + ld b, a + ldh a, [hDividend+3] + add b + ldh [hDividend+3], a + jr nc, .no_overflow_4 + ldh a, [hDividend+2] + inc a + ldh [hDividend+2], a + +.no_overflow_4 + ldh a, [hDividend+2] + cp HIGH(MAX_STAT_VALUE + 1) + 1 + jr nc, .max_stat + cp HIGH(MAX_STAT_VALUE + 1) + jr c, .stat_value_okay + ldh a, [hDividend+3] + cp LOW(MAX_STAT_VALUE + 1) + jr c, .stat_value_okay + +.max_stat + ld a, HIGH(MAX_STAT_VALUE) + ldh [hDividend+2], a + ld a, LOW(MAX_STAT_VALUE) + ldh [hDividend+3], a + +.stat_value_okay + pop bc + pop de + pop hl + ret + +GivePoke:: + ld a, [wCurPartySpecies] + dec a + ld c, a + ld d, 0 + ld hl, wPokedexCaught + ld b, CHECK_FLAG + predef SmallFarFlagAction + + push bc + xor a ; PARTYMON + ld [wMonType], a + call TryAddMonToParty + jr nc, .party_full + ld hl, wPartyMonNicknames + ld a, [wPartyCount] + dec a + ld bc, MON_NAME_LENGTH + call AddNTimes + + ld d, h + ld e, l + pop bc + ld a, c + ld b, 0 + push bc + push de + jr .give_mon_success + +.party_full + call SendMonIntoBox + pop bc + jp nc, .give_mon_failure + ld a, c + ld de, wBoxMonNicknames + ld b, 1 + push bc + push de +.give_mon_success + push af + ld a, [wCurPartySpecies] + ld [wTempSpecies], a + call GetPokemonName + pop af + and a + jr nz, .skip_pokedex + + ld hl, wd41c + bit 4, [hl] ; flag for obtaining the pokedex + jr z, .skip_pokedex + + ld hl, NewDexDataText + call PrintText + call ClearSprites + ld a, [wCurPartySpecies] + ld [wTempSpecies], a + predef NewPokedexEntry + call LoadTilesetGFX_LCDOff +.skip_pokedex + ld hl, GotItText + call PrintText + call YesNoBox + pop de + jr c, .done + + push de + ld b, NAME_MON + farcall NamingScreen + pop de + ld a, [de] + cp "@" + jr nz, .not_empty + + ld hl, wStringBuffer1 + ld bc, MON_NAME_LENGTH + call CopyBytes +.not_empty + call ClearBGPalettes + ld hl, wSpriteFlags + ld a, [hl] + push af + res SPRITES_SKIP_STANDING_GFX_F, [hl] + set SPRITES_SKIP_WALKING_GFX_F, [hl] + call RedrawPlayerSprite + pop af + ld [wSpriteFlags], a + call LoadFontExtra + call LoadMapPart + call GetMemSGBLayout + call WaitBGMap + call GBFadeInFromWhite +.done + pop bc + ld a, b + and a + ret z + ld hl, WasSentToBillsPCText + ld hl, WasSentToSomeonesPCText + call PrintText + ld b, 1 + ret + +.give_mon_failure + ld b, 2 + ret + +WasSentToBillsPCText: + text_from_ram wStringBuffer1 + text "は マサキの ところへ" + line "てんそうされた!" + prompt + +WasSentToSomeonesPCText: + text_from_ram wStringBuffer1 + text "は だれかの に" ; "was transferred to" + line "てんそうされた!" ; "Someone's PC!" + prompt + +NewDexDataText: + text_from_ram wStringBuffer1 + text "の データが あたらしく" ; "New Dex data will" + line "#ずかんに セーブされます!@" ; "be added for (MON)!" + sound_slot_machine_start + text_waitbutton + text_end + +GotItText: + text "ゲットした @" ; "Got it!" + +AskGiveNicknameText: + text_from_ram wStringBuffer1 + text "に" ; "Would you like to" + line "なまえを つけますか?" ; "give it a name?" + done diff --git a/engine/pokemon/print_move_description.asm b/engine/pokemon/print_move_description.asm new file mode 100644 index 0000000..2cd0a04 --- /dev/null +++ b/engine/pokemon/print_move_description.asm @@ -0,0 +1,20 @@ +INCLUDE "constants.asm" + +SECTION "engine/pokemon/print_move_description.asm", ROMX + +PrintMoveDescription:: + push hl + ld hl, MoveDescriptions + ld a, [wSelectedItem] + dec a + ld c, a + ld b, 0 + add hl, bc + add hl, bc + ld a, [hli] + ld e, a + ld d, [hl] + pop hl + jp PlaceString + +INCLUDE "data/moves/descriptions.inc" diff --git a/engine/sprite_anims/functions.inc b/engine/sprite_anims/functions.inc index 0c367d1..021e8f0 100644 --- a/engine/sprite_anims/functions.inc +++ b/engine/sprite_anims/functions.inc @@ -52,7 +52,7 @@ DoSpriteAnimFrame: dw AnimSeq_TradePokeBall dw AnimSeq_TradeTubeBulge dw AnimSeq_TrademonInTube - dw AnimSeq_Unknown + dw AnimSeq_RevealNewMon dw AnimSeq_RadioFrequencyMeter AnimSeq_Null: @@ -1283,9 +1283,8 @@ AnimSeq_TrademonInTube: callfar TradeAnim_AnimateTrademonInTube ret -; Appears to resemble the final game's AnimSeq_RevealNewMon, but it doesn't seem to be used in this build... -; Who knows what it was used for? -AnimSeq_Unknown: +; Unused in this build. See EvolutionAnimation.PlayEvolvedSFX. +AnimSeq_RevealNewMon: ld hl, SPRITEANIMSTRUCT_VAR1 add hl, bc ld a, [hl] @@ -1298,6 +1297,7 @@ AnimSeq_Unknown: ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX add hl, bc ld a, [hl] + push af push de call AnimSeqs_Sine @@ -1305,6 +1305,7 @@ AnimSeq_Unknown: ld hl, SPRITEANIMSTRUCT_YOFFSET add hl, bc ld [hl], a + pop de pop af call AnimSeqs_Cosine diff --git a/engine/unknown_boxes.asm b/engine/unknown_boxes.asm index 57625ff..8ef5bf3 100644 --- a/engine/unknown_boxes.asm +++ b/engine/unknown_boxes.asm @@ -9,7 +9,7 @@ Function1130b: ld a, [wPartyCount] cp PARTY_LENGTH jr c, .bigjump - ld a, [wBoxListLength] + ld a, [wBoxCount] cp MONS_PER_BOX jr nc, .fullbox xor a @@ -18,7 +18,7 @@ Function1130b: ld [wTempEnemyMonSpecies], a callfar LoadEnemyMon call RecievePokemon - predef Functiondd5c + predef SendMonIntoBox and $7F add a, $F7 ld hl, wStringBuffer2 @@ -35,7 +35,7 @@ Function1130b: ret .bigjump call RecievePokemon - predef Functiond886 + predef TryAddMonToParty scf ret @@ -46,7 +46,7 @@ RecievePokemon: dec a ld c, a ld hl, wPokedexCaught - ld b, 01 ;SET_FLAG + ld b, SET_FLAG predef SmallFarFlagAction pop af ld [wNamedObjectIndexBuffer], a @@ -57,20 +57,18 @@ RecievePokemon: RecievePokemonText: text "は" line "@" - - db $01, $26, $CD - + text_from_ram wStringBuffer1 text "を てにいれた!@" - - db $0B, "@" + sound_dex_fanfare_50_79 + db "@" BoxCantHoldText: text "#を もちきれないので" line "の ボックス@" - db $01, $31, $CD + text_from_ram wStringBuffer2 text " に" cont "@" - db $01, $17, $DF + text_from_ram wBoxMonNicknames text "を てんそうした!" done diff --git a/gfx/evo/bubbles.png b/gfx/evo/bubbles.png new file mode 100644 index 0000000000000000000000000000000000000000..42c70dda8fc9eccc7e43201ae2053d563887599f GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRm0VEi%omRR4q!^2X+?^QKos)S9+n3Wm^uNg7nar2TW^|b&W$X9)FCW;KFfDp*dYm`VL0*T-G@yGywp>@HbNc literal 0 HcmV?d00001 diff --git a/gfx/gfx.asm b/gfx/gfx.asm index d9d91db..a4d6d46 100644 --- a/gfx/gfx.asm +++ b/gfx/gfx.asm @@ -4,7 +4,7 @@ SECTION "gfx.asm@Mon Nest Icon", ROMX PokedexNestIconGFX:: INCBIN "gfx/trainer_gear/dexmap_nest_icon.1bpp" -SECTION "gfx.asm@Bank 2 Misc GFX", ROMX +SECTION "gfx.asm@Minor Object GFX", ROMX UnknownBouncingOrbGFX:: INCBIN "gfx/overworld/gfx_84bf.2bpp" .end: JumpShadowGFX:: INCBIN "gfx/overworld/shadow.2bpp" diff --git a/gfx/gfx.mk b/gfx/gfx.mk index 01ebd4f..220e550 100644 --- a/gfx/gfx.mk +++ b/gfx/gfx.mk @@ -49,3 +49,5 @@ $(BUILD)/gfx/battle_anims/reflect.2bpp: tools/gfx += --remove-whitespace $(BUILD)/gfx/battle_anims/rocks.2bpp: tools/gfx += --remove-whitespace $(BUILD)/gfx/battle_anims/skyattack.2bpp: tools/gfx += --remove-whitespace $(BUILD)/gfx/battle_anims/status.2bpp: tools/gfx += --remove-whitespace + +$(BUILD)/gfx/evo/bubbles.2bpp: tools/gfx += --remove-xflip --remove-yflip --remove-whitespace diff --git a/home/jumptable.asm b/home/jumptable.asm index 03947bf..4c0b745 100644 --- a/home/jumptable.asm +++ b/home/jumptable.asm @@ -21,19 +21,20 @@ CallJumptable:: ld l, a jp hl -CallFar_atHL:: -; CallFar_atHL -; Call the function pointed to by -; the 3-byte pointer at hl -; Clobbers: a, hl +; Call the function pointed to by the 3-byte pointer at hl. +; Clobbers: a, hl. +CallPointerAt:: ldh a, [hROMBank] push af ld a, [hli] call Bankswitch + ld a, [hli] ld h, [hl] ld l, a + call ._hl_ + pop hl ld a, h call Bankswitch diff --git a/home/map.asm b/home/map.asm index fb3a35c..485ddc5 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1204,7 +1204,7 @@ ApplyFlashlight:: .no_flashlight ld de, wTileMap - ld b, SCREEN_HEIGHT ; TODO: constantify this + ld b, SCREEN_HEIGHT .row ld c, SCREEN_WIDTH .tile @@ -1692,9 +1692,9 @@ Function2ba8:: call Bankswitch call HandleNPCStep call LoadMinorObjectGFX - ld a, BANK(Functiond6e4) + ld a, BANK(_HandlePlayerStep) call Bankswitch - call Functiond6e4 + call _HandlePlayerStep ld a, BANK(InitSprites) call Bankswitch call InitSprites diff --git a/home/menu.asm b/home/menu.asm index 7bce6fc..3991b92 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -56,18 +56,18 @@ VerticalMenu:: call PlaceVerticalMenuItems call WaitBGMap call CopyMenuData - ld a, [wMenuData2] - bit 7, a - jr z, .asm_1daa + ld a, [wMenuData] + bit STATICMENU_CURSOR_F, a + jr z, .cancel call InitVerticalMenuCursor - call Get2DMenuJoypad - bit 1, a - jr z, .asm_1dac -.asm_1daa: + call StaticMenuJoypad + bit B_BUTTON_F, a + jr z, .okay +.cancel scf ret -.asm_1dac: +.okay and a ret @@ -102,6 +102,7 @@ YesNoBox:: PlaceYesNoBox:: jr _YesNoBox +; Unreferenced? PlaceGenericTwoOptionBox:: call LoadMenuHeader jr InterpretTwoOptionMenu @@ -169,7 +170,6 @@ _OffsetMenuHeader:: ld h, a ld a, [wMenuBorderRightCoord] sub h -.asm_1e3d: ld h, a ld a, d ld [wMenuBorderLeftCoord], a @@ -190,11 +190,11 @@ OpenMenu:: call CopyMenuData call GetMenuIndexSet push de - ld a, [wMenuCursorBuffer] + ld a, [wMenuCursorPosition] push af - call Function1e8a + call .ExitMenu_NoPoppingError pop af - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a call AutomaticGetMenuBottomCoord call PushWindow call MenuBox @@ -202,17 +202,19 @@ OpenMenu:: call GetMenuIndexSet push de call RunMenuItemPrintingFunction - ld a, $1 + ld a, 1 ldh [hBGMapMode], a call UpdateSprites call GetMenuIndexSet pop de - call Function1f27 + call GetStaticMenuJoypad ret -Function1e8a:: +; Unlike _ExitMenu, there is no error for trying to pop a window when none are available. +.ExitMenu_NoPoppingError: xor a ldh [hBGMapMode], a + xor a call OpenSRAM call GetWindowStackTop @@ -251,29 +253,31 @@ GetMenuIndexSet:: ld l, a ld a, [wWhichIndexSet] and a - jr z, .asm_1ed9 + jr z, .skip ld b, a ld c, -1 -.asm_1ed2: +.loop ld a, [hli] cp c - jr nz, .asm_1ed2 + jr nz, .loop dec b - jr nz, .asm_1ed2 -.asm_1ed9: + jr nz, .loop + +.skip ld d, h ld e, l inc hl - ld c, $ff -.asm_1ede: + ld c, -1 +.not_terminator inc c ld a, [hli] - cp $ff - jr nz, .asm_1ede + cp -1 + jr nz, .not_terminator ld a, c ld [wMenuDataItems], a ret +; Unreferenced? Function1ee9:: call MenuBoxCoord2Tile call GetMenuBoxDims @@ -297,7 +301,7 @@ RunMenuItemPrintingFunction:: call MenuBoxCoord2Tile ld bc, 2 * SCREEN_WIDTH + 2 add hl, bc -.asm_1f09: +.loop inc de ld a, [de] cp -1 @@ -313,70 +317,72 @@ RunMenuItemPrintingFunction:: ld de, 2 * SCREEN_WIDTH add hl, de pop de - jr .asm_1f09 + jr .loop -._hl_: +._hl_ ld a, [hli] ld h, [hl] ld l, a jp hl -Function1f27:: -; Combines Crystal functions "InitMenuCursorAndButtonPermissions" and "GetStaticMenuJoypad" +; Combines pokegold functions "InitMenuCursorAndButtonPermissions" and "GetStaticMenuJoypad". +GetStaticMenuJoypad:: push de call InitVerticalMenuCursor ld hl, wMenuJoypadFilter - ld a, [wMenuData2] - bit 3, a - jr z, .asm_1f37 - set 3, [hl] -.asm_1f37: - bit 2, a - jr z, .asm_1f3f + ld a, [wMenuDataFlags] + bit STATICMENU_ENABLE_START_F, a + jr z, .disallow_start + set START_F, [hl] + +.disallow_start + bit STATICMENU_ENABLE_LEFT_RIGHT_F, a + jr z, .disallow_left_right ld a, [hl] or D_LEFT | D_RIGHT ld [hl], a -.asm_1f3f: - call Get2DMenuJoypad + +.disallow_left_right: + call StaticMenuJoypad pop de - bit 0, a - jr nz, .asm_1f66 - bit 1, a - jr nz, .asm_1f7e - bit 3, a - jr nz, .asm_1f7e - bit 4, a - jr nz, .asm_1f58 - bit 5, a - jr nz, .asm_1f5f + bit A_BUTTON_F, a + jr nz, .a_pressed + bit B_BUTTON_F, a + jr nz, .b_start_pressed + bit START_F, a + jr nz, .b_start_pressed + bit D_RIGHT_F, a + jr nz, .right_pressed + bit D_LEFT_F, a + jr nz, .left_pressed ret -.asm_1f58: +.right_pressed ld a, D_RIGHT ld [wMenuJoypad], a - jr .asm_1f6b + jr .move_cursor -.asm_1f5f: +.left_pressed ld a, D_LEFT ld [wMenuJoypad], a - jr .asm_1f6b + jr .move_cursor -.asm_1f66: +.a_pressed ld a, A_BUTTON ld [wMenuJoypad], a -.asm_1f6b: +.move_cursor ld a, [wMenuCursorY] ld l, a - ld h, $0 + ld h, 0 add hl, de ld a, [hl] ld [wMenuSelection], a ld a, [wMenuCursorY] - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a and a ret -.asm_1f7e: +.b_start_pressed ld a, B_BUTTON ld [wMenuJoypad], a ld a, -1 @@ -400,19 +406,19 @@ PlaceMenuStrings:: ClearWindowData:: ld hl, wWindowStackPointer - call .clear + call .ClearMenuData ld hl, wMenuDataHeader - call .clear - ld hl, wMenuData2 - call .clear - ld hl, wMenuData3 - call .clear + call .ClearMenuData + ld hl, wMenuData + call .ClearMenuData + ld hl, wMoreMenuData + call .ClearMenuData xor a call OpenSRAM xor a - ld hl, sWindowStackTop + 1 + ld hl, sWindowStackTop ld [hld], a ld [hld], a ld a, l @@ -423,7 +429,7 @@ ClearWindowData:: call CloseSRAM ret -.clear: +.ClearMenuData: ld bc, wMenuDataHeaderEnd - wMenuDataHeader xor a call ByteFill diff --git a/home/menu_window.asm b/home/menu_window.asm index 48382d8..af0b37b 100644 --- a/home/menu_window.asm +++ b/home/menu_window.asm @@ -5,72 +5,77 @@ SECTION "home/menu_window.asm", ROM0 SetMenuAttributes:: push hl push bc - ld hl, wMenuData3 - ld b, $8 -.asm_1a6b: + ld hl, wMoreMenuData + ld b, w2DMenuDataEnd - wMoreMenuData +.loop ld a, [de] inc de ld [hli], a dec b - jr nz, .asm_1a6b - ld a, $1 - ld [hli], a - ld [hli], a + jr nz, .loop + + ld a, 1 + ld [hli], a ; wMenuCursorY + ld [hli], a ; wMenuCursorX xor a - ld [hli], a - ld [hli], a + ld [hli], a ; wCursorOffCharacter + ld [hli], a ; wCursorCurrentTile ld [hli], a pop bc pop hl ret -Get2DMenuJoypad:: +StaticMenuJoypad:: call Place2DMenuCursor -Get2DMenuJoypad_NoPlaceCursor:: +ScrollingMenuJoypad:: ld hl, w2DMenuFlags2 - res 7, [hl] -.loop: + res _2DMENU_DISABLE_JOYPAD_FILTER_F, [hl] + +.menu_joypad_loop call Move2DMenuCursor call WaitBGMap -.asm_1a8a: + +.loopRTC call UpdateTime call UpdateTimeOfDayPalettes call Menu_WasButtonPressed - jr c, .asm_1a9f + jr c, .pressed ld a, [w2DMenuFlags1] - bit 7, a + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, a jp nz, .done - jr .asm_1a8a + jr .loopRTC -.asm_1a9f: +.pressed call _2DMenuInterpretJoypad jp c, .done ld a, [w2DMenuFlags1] - bit 7, a + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, a jr nz, .done ldh a, [hJoySum] ld b, a ld a, [wMenuJoypadFilter] and b - jp z, .loop -.done: + jp z, .menu_joypad_loop + +.done ldh a, [hJoyDown] and A_BUTTON | B_BUTTON - jr z, .asm_1ac4 + jr z, .a_b_not_pressed push de ld de, SE_SELECT call PlaySFX pop de -.asm_1ac4: +.a_b_not_pressed ldh a, [hJoySum] ret Menu_WasButtonPressed:: ld a, [w2DMenuFlags1] - bit 6, a - jr z, .asm_1ad6 + bit _2DMENU_ENABLE_SPRITE_ANIMS_F, a + jr z, .skip_to_joypad farcall PlaySpriteAnimationsAndDelayFrame -.asm_1ad6: + +.skip_to_joypad call GetJoypadDebounced ldh a, [hJoySum] and a @@ -81,125 +86,125 @@ Menu_WasButtonPressed:: _2DMenuInterpretJoypad:: ldh a, [hJoySum] bit A_BUTTON_F, a - jp nz, .PressedABStartOrSelect + jp nz, .a_b_start_select bit B_BUTTON_F, a - jp nz, .PressedABStartOrSelect + jp nz, .a_b_start_select bit SELECT_F, a - jp nz, .PressedABStartOrSelect + jp nz, .a_b_start_select bit START_F, a - jp nz, .PressedABStartOrSelect + jp nz, .a_b_start_select bit D_RIGHT_F, a - jr nz, .PressedRight + jr nz, .d_right bit D_LEFT_F, a - jr nz, .PressedLeft + jr nz, .d_left bit D_UP_F, a - jr nz, .PressedUp + jr nz, .d_up bit D_DOWN_F, a - jr nz, .PressedDown + jr nz, .d_down and a ret -.SetFlag15AndCarry: +.set_bit_7 ld hl, w2DMenuFlags2 - set 7, [hl] + set _2DMENU_EXITING_F, [hl] scf ret -.PressedDown: +.d_down ld hl, wMenuCursorY ld a, [w2DMenuNumRows] cp [hl] - jr z, .asm_1b1a + jr z, .check_wrap_around_down inc [hl] xor a ret -.asm_1b1a: +.check_wrap_around_down ld a, [w2DMenuFlags1] - bit 5, a - jr nz, .asm_1b28 - bit 3, a - jp nz, .SetFlag15AndCarry + bit _2DMENU_WRAP_UP_DOWN_F, a + jr nz, .wrap_around_down + bit _2DMENU_EXIT_DOWN_F, a + jp nz, .set_bit_7 xor a ret -.asm_1b28: +.wrap_around_down ld [hl], $1 xor a ret -.PressedUp: +.d_up ld hl, wMenuCursorY ld a, [hl] dec a - jr z, .asm_1b36 + jr z, .check_wrap_around_up ld [hl], a xor a ret -.asm_1b36: +.check_wrap_around_up ld a, [w2DMenuFlags1] - bit 5, a - jr nz, .asm_1b44 - bit 2, a - jp nz, .SetFlag15AndCarry + bit _2DMENU_WRAP_UP_DOWN_F, a + jr nz, .wrap_around_up + bit _2DMENU_EXIT_UP_F, a + jp nz, .set_bit_7 xor a ret -.asm_1b44: +.wrap_around_up ld a, [w2DMenuNumRows] ld [hl], a xor a ret -.PressedLeft: +.d_left ld hl, wMenuCursorX ld a, [hl] dec a - jr z, .asm_1b54 + jr z, .check_wrap_around_left ld [hl], a xor a ret -.asm_1b54: +.check_wrap_around_left ld a, [w2DMenuFlags1] - bit 4, a - jr nz, .asm_1b62 - bit 1, a - jp nz, .SetFlag15AndCarry + bit _2DMENU_WRAP_LEFT_RIGHT_F, a + jr nz, .wrap_around_left + bit _2DMENU_EXIT_LEFT_F, a + jp nz, .set_bit_7 xor a ret -.asm_1b62: +.wrap_around_left ld a, [w2DMenuNumCols] ld [hl], a xor a ret -.PressedRight: +.d_right ld hl, wMenuCursorX ld a, [w2DMenuNumCols] cp [hl] - jr z, .asm_1b74 + jr z, .check_wrap_around_right inc [hl] xor a ret -.asm_1b74: +.check_wrap_around_right ld a, [w2DMenuFlags1] - bit 4, a - jr nz, .asm_1b82 - bit 0, a - jp nz, .SetFlag15AndCarry + bit _2DMENU_WRAP_LEFT_RIGHT_F, a + jr nz, .wrap_around_right + bit _2DMENU_EXIT_RIGHT_F, a + jp nz, .set_bit_7 xor a ret -.asm_1b82: +.wrap_around_right ld [hl], $1 xor a ret -.PressedABStartOrSelect: +.a_b_start_select xor a ret @@ -209,7 +214,7 @@ Move2DMenuCursor:: ld h, [hl] ld l, a ld a, [hl] - cp $ed + cp "▶" jr nz, Place2DMenuCursor ld a, [wCursorOffCharacter] ld [hl], a @@ -227,12 +232,13 @@ Place2DMenuCursor:: ld b, a xor a dec b - jr z, .asm_1bb6 -.asm_1bb2: + jr z, .got_row +.row_loop add c dec b - jr nz, .asm_1bb2 -.asm_1bb6: + jr nz, .row_loop + +.got_row ld c, SCREEN_WIDTH call AddNTimes ld a, [w2DMenuCursorOffsets] @@ -242,20 +248,22 @@ Place2DMenuCursor:: ld b, a xor a dec b - jr z, .asm_1bcd -.asm_1bc9: + jr z, .got_col +.col_loop add c dec b - jr nz, .asm_1bc9 -.asm_1bcd: + jr nz, .col_loop + +.got_col ld c, a add hl, bc ld a, [hl] - cp $ed - jr z, .asm_1bd9 + cp "▶" + jr z, .cursor_on ld [wCursorOffCharacter], a - ld [hl], $ed -.asm_1bd9: + ld [hl], "▶" + +.cursor_on ld a, l ld [wCursorCurrentTile], a ld a, h @@ -267,7 +275,7 @@ PlaceHollowCursor:: ld a, [hli] ld h, [hl] ld l, a - ld [hl], $ec + ld [hl], "▷" ret HideCursor:: @@ -275,31 +283,29 @@ HideCursor:: ld a, [hli] ld h, [hl] ld l, a - ld [hl], $7f + ld [hl], " " ret PushWindow:: - ld hl, PlaceWaitingText - ld a, $9 - jp FarCall_hl + jpfar _PushWindow ExitMenu:: push af callfar _ExitMenu - call Function1c0a + call .ResetBGMap pop af ret -Function1c0a:: +.ResetBGMap: ld a, [wStateFlags] bit SPRITE_UPDATES_DISABLED_F, a ret z - xor a + xor a ; BANK(sScratch) call OpenSRAM hlcoord 0, 0 - ld de, sSpriteBuffer0 - ld bc, $168 + ld de, sScratch + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call CopyBytes call CloseSRAM @@ -307,23 +313,22 @@ Function1c0a:: xor a call OpenSRAM - ld hl, sSpriteBuffer0 + ld hl, sScratch decoord 0, 0 - ld bc, $168 -.asm_1c33: + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT +.copy_loop ld a, [hl] - cp $61 - jr c, .asm_1c39 + cp "▲" + jr c, .skip ld [de], a -.asm_1c39: +.skip inc hl inc de dec bc ld a, c or b - jr nz, .asm_1c33 + jr nz, .copy_loop call CloseSRAM - ret InitVerticalMenuCursor:: @@ -337,40 +342,42 @@ CloseWindow:: pop af ret -Function1c58:: - jpfar Function24185 +; Unreferenced. +ExitAllMenus:: + jpfar _ExitAllMenus RestoreTileBackup:: call MenuBoxCoord2Tile call GetMenuBoxDims inc b inc c -.asm_1c68: +.row push bc push hl -.asm_1c6a: +.col ld a, [de] ld [hli], a dec de dec c - jr nz, .asm_1c6a + jr nz, .col + pop hl ld bc, SCREEN_WIDTH add hl, bc pop bc dec b - jr nz, .asm_1c68 + jr nz, .row ret PopWindow:: - ld b, $10 + ld b, wMenuDataHeaderEnd - wMenuDataHeader ld de, wMenuDataHeader -.asm_1c7f: +.loop ld a, [hld] ld [de], a inc de dec b - jr nz, .asm_1c7f + jr nz, .loop ret GetMenuBoxDims:: @@ -399,7 +406,7 @@ CopyMenuData:: ld h, [hl] ld l, a ld de, wMenuDataFlags - ld bc, $10 + ld bc, wMenuDataHeaderEnd - wMenuDataHeader call CopyBytes pop af pop bc @@ -430,7 +437,7 @@ PlaceVerticalMenuItems:: ld a, [de] inc de ld b, a -.asm_1ccc: +.loop push bc call PlaceString inc de @@ -438,17 +445,17 @@ PlaceVerticalMenuItems:: add hl, bc pop bc dec b - jr nz, .asm_1ccc + jr nz, .loop ld a, [wMenuDataFlags] - bit 4, a + bit STATICMENU_PLACE_TITLE_F, a ret z call MenuBoxCoord2Tile ld a, [de] ld c, a inc de - ld b, $0 + ld b, 0 add hl, bc jp PlaceString @@ -466,16 +473,20 @@ GetMenuTextStartCoord:: ld a, [wMenuBorderLeftCoord] ld c, a inc c +; if not set, leave extra room on top ld a, [wMenuDataFlags] - bit 6, a - jr nz, .asm_1d08 + bit STATICMENU_NO_TOP_SPACING_F, a + jr nz, .no_top_spacing inc b -.asm_1d08 + +.no_top_spacing +; if set, leave extra room on the left ld a, [wMenuDataFlags] - bit 7, a - jr z, .done + bit STATICMENU_CURSOR_F, a + jr z, .no_cursor inc c -.done + +.no_cursor ret ClearMenuBoxInterior:: diff --git a/home/misc_32c8.asm b/home/misc_32c8.asm index 352a6e1..895d239 100644 --- a/home/misc_32c8.asm +++ b/home/misc_32c8.asm @@ -8,7 +8,7 @@ Function32c8:: and a ret -Function32d0:: +GetTerminatingString:: ld hl, .EmptyString ret diff --git a/home/misc_3c43.asm b/home/misc_3c43.asm index dfdcce0..00f3bd1 100644 --- a/home/misc_3c43.asm +++ b/home/misc_3c43.asm @@ -15,8 +15,8 @@ GetPartyParamLocation:: pop bc ret -UseItem:: - farjp _UseItem +DoItemEffect:: + farjp _DoItemEffect CheckTossableItem:: push hl diff --git a/home/overworld.asm b/home/overworld.asm index 7259d21..f7338ec 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -39,7 +39,7 @@ CheckStartmenuSelectHook: Function2c4a: ; copy of Function2ba8 -; calling Functiond4e6 instead of Functiond6e4 +; calling _HandlePlayerStep_Limited instead of _HandlePlayerStep .loop call Function2c5a and a @@ -58,9 +58,9 @@ Function2c5a: call Bankswitch call HandleNPCStep call LoadMinorObjectGFX - ld a, BANK(Functiond4e6) + ld a, BANK(_HandlePlayerStep_Limited) call Bankswitch - call Functiond4e6 + call _HandlePlayerStep_Limited ld a, BANK(InitSprites) call Bankswitch call InitSprites diff --git a/home/scrolling_menu.asm b/home/scrolling_menu.asm index 2b2d82f..1d896ba 100644 --- a/home/scrolling_menu.asm +++ b/home/scrolling_menu.asm @@ -2,7 +2,11 @@ INCLUDE "constants.asm" SECTION "home/scrolling_menu.asm", ROM0 -Function3810:: +; Runs a scrolling menu from a table with the following: +; 1. A pointer to the menu header. +; 2. Pointer to the cursor in RAM. +; 3. Pointer to the menu scroll position in RAM. +ScrollingMenu_FromTable:: ld e, [hl] inc hl ld d, [hl] @@ -12,13 +16,15 @@ Function3810:: ld l, e call CopyMenuHeader pop hl + ld e, [hl] inc hl ld d, [hl] inc hl ld a, [de] - ld [wMenuCursorBuffer], a + ld [wMenuCursorPosition], a push de + ld e, [hl] inc hl ld d, [hl] @@ -26,11 +32,13 @@ Function3810:: ld a, [de] ld [wMenuScrollPosition], a push de + call ScrollingMenu pop de ld a, [wMenuScrollPosition] ld [de], a pop de + ld a, [wMenuCursorY] ld [de], a ld a, [wMenuJoypad] @@ -54,27 +62,34 @@ ScrollingMenu:: ld a, [wMenuJoypad] ret -Function385a:: +PartyMenu_TextboxBackup:: push hl - jr asm_3865 + jr .continue -Function385d:: +.unreferenced_385d: callfar FreezeMonIcons -asm_3865: +.continue pop hl call MenuTextBox - ld c, $0 - call Function3872 + ld c, 0 + call PartyMenu_WaitForAorB call CloseWindow ret -Function3872:: +; BUG: Supposed to wait for at most c frames until the player pushes a button. If c is 0, then wait indefinitely. +; However, there is a bit of a problem: it doesn't actually call DelayFrames at any point. +; Presumably, this function was intended to loop at .unreferenced_3875 at one point, +; but they forgot to add a DelayFrame when they added the jump at the beginning. +; +; TLDR: The Softboiled heal message only shows up for one frame due to a combination of two oversights. +PartyMenu_WaitForAorB:: +.loop push bc - jr asm_387d + jr .continue -Function3875:: +.unreferenced_3875: callfar PlaySpriteAnimationsAndDelayFrame -asm_387d: +.continue pop bc call GetJoypad ldh a, [hJoyDown] @@ -82,8 +97,9 @@ asm_387d: jr nz, .done ld a, c and a - jr z, Function3872 + jr z, .loop dec c - jr z, Function3872 -.done: +; BUG: This is supposed to be a jr nz, not jr z + jr z, .loop +.done ret diff --git a/home/talk_to_npc.asm b/home/talk_to_npc.asm index 8756624..d73e198 100644 --- a/home/talk_to_npc.asm +++ b/home/talk_to_npc.asm @@ -44,7 +44,7 @@ Function3055:: cp $ff ret z cp b - jp z, SetFFInAccumulator + jp z, xor_a_dec_a jr .Loop asm_3062: @@ -70,7 +70,7 @@ Function307a:: ld hl, wTalkingTargetType res 0, [hl] res 1, [hl] - call SetFFInAccumulator + call xor_a_dec_a ret PrintTextboxDebugNumbers:: @@ -105,7 +105,7 @@ PrintTextboxDebugNumbers:: QueueMapTextSubroutine:: ldh a, [hJoyState] bit A_BUTTON_F, a - jp z, ClearAccumulator ; if we didn't press a + jp z, xor_a ; if we didn't press a call GetFacingPersonText jp nc, Function30e8 ; if not talking to a person ld d, $0 @@ -127,12 +127,12 @@ QueueMapTextSubroutine:: ld [de], a ld hl, wTalkingTargetType set 0, [hl] ; we're talking to an NPC - call SetFFInAccumulator + call xor_a_dec_a ret Function30e8:: call GetFacingSignpost - jp nc, ClearAccumulator ; if not facing person or sign + jp nc, xor_a ; if not facing person or sign ld a, e ldh [hFFEB], a ld a, d @@ -143,7 +143,7 @@ Function30e8:: ldh [hFFEE], a ld hl, wTalkingTargetType set 1, [hl] ; we're talking to a sign - call SetFFInAccumulator + call xor_a_dec_a ret GetFacingPersonText:: @@ -345,11 +345,11 @@ CheckBPressedDebug: bit B_BUTTON_F, a ret -ClearAccumulator:: +xor_a:: xor a ret -SetFFInAccumulator:: +xor_a_dec_a:: xor a dec a ret diff --git a/home/tileset.asm b/home/tileset.asm index cf36ba0..30512d1 100644 --- a/home/tileset.asm +++ b/home/tileset.asm @@ -79,24 +79,24 @@ RefreshPlayerCoords:: ; This piece of code has been removed in pokegold (note that the conditions above were altered, as well) call GetObjectStruct - ld hl, 16 ; TODO: constantify this + ld hl, OBJECT_MAP_X add hl, bc ld a, [hl] add a, d ld [hl], a ld [wMap1ObjectXCoord], a - ld hl, 18 ; TODO: constantify this + ld hl, OBJECT_LAST_MAP_X add hl, bc ld a, [hl] add a, d ld [hl], a - ld hl, 17 ; TODO: constantify this + ld hl, OBJECT_MAP_Y add hl, bc ld a, [hl] add a, e ld [hl], a ld [wMap1ObjectYCoord], a - ld hl, 19 + ld hl, OBJECT_LAST_MAP_Y add hl, bc ld a, [hl] add a, e diff --git a/home/unknown_388f.asm b/home/unknown_388f.asm index 96c7026..119c691 100644 --- a/home/unknown_388f.asm +++ b/home/unknown_388f.asm @@ -49,14 +49,14 @@ TestWildBattleStart:: and D_PAD ret z ; if no directions are down, don't try and trigger a wild encounter call CheckBPressedDebug - jp nz, ClearAccumulator ; if b button is down, clear acc + jp nz, xor_a ; if b button is down, clear acc callfar Function3ee3e ld a, [wBattleMode] and a ret z ; if no battle, return ld a, $3 call WriteIntod637 - call SetFFInAccumulator + call xor_a_dec_a ret Function3904:: diff --git a/home/unknown_3e32.asm b/home/unknown_3e32.asm index c99a3f1..362779e 100644 --- a/home/unknown_3e32.asm +++ b/home/unknown_3e32.asm @@ -28,9 +28,9 @@ Unreferenced_GetPartyParamLocation_Old: pop bc ret -Unreferenced_UseItem_Old: - ld a, BANK(_UseItem) - ld hl, $67C4 ; Early location for _UseItem +Unreferenced_DoItemEffect_Old: + ld a, BANK(_DoItemEffect) + ld hl, $67C4 ; Early location for _DoItemEffect jp Old_FarCallFunctionAddress Unreferenced_CheckTossableItem_Old: @@ -293,7 +293,7 @@ Unreferenced_FadeToMapMusic_Old: jr c, .dont_change ld a, 8 ld [wMusicFade], a - call PlaceWaitingText + call _DisableAudio ld a, e ld [wMusicFadeID], a ld a, d diff --git a/home/window.asm b/home/window.asm index 4d54d6c..9ce80be 100644 --- a/home/window.asm +++ b/home/window.asm @@ -16,7 +16,8 @@ RefreshScreen:: call Bankswitch ret -Function1fea:: +; TODO: Better name for this? +ScreenCleanup:: call TextboxCleanup call ClearWindowData call InitToolgearBuffer diff --git a/layout.link b/layout.link index 3cf9bb0..46b8501 100644 --- a/layout.link +++ b/layout.link @@ -117,9 +117,11 @@ ROMX $01 "engine/menu_options_menu.asm" ROMX $02 - "engine/dumps/bank02.asm@_SpawnPlayer" - "gfx.asm@Bank 2 Misc GFX" - "engine/dumps/bank02.asm@QueueFollowerFirstStep" + "engine/overworld/player_object.asm" + "engine/gfx/load_minor_object_gfx.asm" + "gfx.asm@Minor Object GFX" + "engine/overworld/player_object.asm@QueueFollowerFirstStep" + "engine/events/town_map.asm" "gfx.asm@Mon Nest Icon" "data/maps/flypoints.asm" @@ -141,7 +143,6 @@ ROMX $03 "engine/overworld/player_movement.asm@Player Movement" "data/collision/collision_type_table.asm" "engine/overworld/player_movement.asm@Rest of Player Movement" - "engine/dumps/bank03.asm@GetFlyPointMapLocation" "engine/overworld/spawn_points.asm" "data/maps/spawn_points.asm" "data/tileset_headers.asm" @@ -154,9 +155,14 @@ ROMX $03 "engine/pokemon/health.asm@HP Bar" "engine/events/field_moves.asm" "engine/items/inventory.asm@_CheckTossableItem" - "engine/dumps/bank03.asm@Functiond41d" + "engine/overworld/player_step.asm" + "engine/pokemon/move_mon.asm" + "engine/pokemon/bills_pc.asm" + "engine/events/starter_dex.asm" "engine/items/item_effects.asm" - "engine/dumps/bank03.asm@GetMaxPPOfMove" + "engine/events/breeder.asm" + "engine/battle_anims/pokeball_wobble.asm" + "engine/pokemon/knows_move.asm" ROMX $04 org $4000 @@ -223,7 +229,15 @@ ROMX $08 ROMX $09 org $4000 - "engine/dumps/bank09.asm@Function24000" + "engine/menu/menu.asm" + "engine/items/update_item_description.asm" + "engine/events/pokepic.asm" + "engine/menu/scrolling_menu.asm" + "engine/items/switch_items.asm" + "engine/menu/menu_2.asm" + "engine/pokemon/mon_submenu.asm" + "engine/battle/menu.asm" + "engine/items/buy_sell_toss.asm" ROMX $0a org $4000 @@ -232,7 +246,9 @@ ROMX $0a ROMX $0b org $4000 - "engine/dumps/bank0b.asm" + "engine/items/print_item_description.asm" + "engine/items/tm_holder.asm" + "engine/pokemon/print_move_description.asm" ROMX $0c org $4000 @@ -273,19 +289,18 @@ ROMX $0f ROMX $10 org $4000 - "engine/dumps/bank10.asm" - org $52a1 + "engine/pokedex/pokedex.asm" + "engine/link/time_capsule_2.asm" + "engine/pokedex/pokedex_2.asm" "data/moves/names.asm" - org $58b6 "data/moves/moves.asm" - org $6493 + "engine/pokemon/evolve.asm" "data/pokemon/evos_attacks.asm" ROMX $11 org $4000 - org $40d5 + "engine/pokedex/display_dex_entry.asm" "gfx.asm@Pokedex GFX" - org $4945 "data/pokemon/dex_entries.asm" ROMX $12 @@ -778,7 +793,7 @@ ROMX $33 "engine/battle_anims/anim_commands.asm" "engine/dumps/bank33.asm" "engine/battle_anims/functions.asm" - "engine/battle_anims/helper.asm" + "engine/battle_anims/helpers.asm" ROMX $34 @@ -992,5 +1007,10 @@ SRAM 0 "Sprite Buffers" org $a600 "Unknown, bank 0" - org $bffe - "Window Stack Top" + org $b800 + "SRAM Window Stack" + +SRAM $02 + "Boxes 1-5" +SRAM $03 + "Boxes 6-10" diff --git a/macros/wram.asm b/macros/wram.asm index fa49a36..748a0e1 100644 --- a/macros/wram.asm +++ b/macros/wram.asm @@ -30,7 +30,7 @@ ENDM MACRO party_struct box_struct \1 \1Status:: db -\1Unused:: db +\1Unused4:: db \1HP:: dw \1MaxHP:: dw \1Stats:: ; big endian @@ -101,19 +101,27 @@ MACRO battle_struct ENDM MACRO box -\1:: -\1Count:: ds 1 -\1Species:: ds MONS_PER_BOX + 1 +\1Count:: db +\1Species:: ds MONS_PER_BOX + 1 \1Mons:: -\1Mon1:: box_struct \1Mon1 -\1Mon2:: ds BOXMON_STRUCT_LENGTH * (MONS_PER_BOX +- 1) -\1MonOT:: ds NAME_LENGTH * MONS_PER_BOX -\1MonNicknames:: ds PKMN_NAME_LENGTH * MONS_PER_BOX + ; \1Mon1 - \1Mon30 + for n, 1, MONS_PER_BOX + 1 + \1Mon{d:n}:: box_struct \1Mon{d:n} + endr +\1MonOTs:: + ; \1Mon1OT - \1Mon30OT + for n, 1, MONS_PER_BOX + 1 + \1Mon{d:n}OT:: ds PLAYER_NAME_LENGTH + endr +\1MonNicknames:: + ; \1Mon1Nickname - \1Mon30Nickname + for n, 1, MONS_PER_BOX + 1 + \1Mon{d:n}Nickname:: ds MON_NAME_LENGTH + endr \1MonNicknamesEnd:: -\1End:: ds 2 ; padding +\1End:: ENDM - MACRO map_connection_struct \1ConnectedMapGroup:: db \1ConnectedMapNumber:: db diff --git a/ram/hram.asm b/ram/hram.asm index 464b116..5543f7c 100644 --- a/ram/hram.asm +++ b/ram/hram.asm @@ -108,6 +108,11 @@ NEXTU hMapObjectIndex:: db hObjectStructIndex:: db hEnemyMonSpeed:: dw + +NEXTU + +hPokedexTempWeight:: dw + ENDU UNION @@ -173,8 +178,7 @@ hCurSpriteTile:: db hCurSpriteOAMFlags:: db ENDU -hFFCD:: db - ds 2 ; TODO +hMoneyTemp:: ds 3 hLCDCPointer:: db @@ -206,7 +210,7 @@ hWX:: db hWY:: db hOverworldFlashlightEffect:: db -; Influences draw distance of map around HIRO +; Influences draw distance of map around the player. ; Meant to go from 0 --> to desired distance ; or else graphical errors will occur. ; 0 - regular distance diff --git a/ram/sram.asm b/ram/sram.asm index 6f88795..4183b99 100644 --- a/ram/sram.asm +++ b/ram/sram.asm @@ -3,7 +3,7 @@ INCLUDE "constants.asm" SECTION "Sprite Buffers", SRAM UNION -sScratch:: ds SCREEN_WIDTH * SCREEN_HEIGHT +sScratch:: ds SCREEN_WIDTH * SCREEN_HEIGHT NEXTU sSpriteBuffer0:: ds SPRITEBUFFERSIZE sSpriteBuffer1:: ds SPRITEBUFFERSIZE @@ -19,5 +19,33 @@ s0_a600:: ds 7 ; TODO: properly label this and figure out exact size ENDU -SECTION "Window Stack Top", SRAM -sWindowStackTop:: dw +SECTION "SRAM Window Stack", SRAM + +sWindowStackBottom:: + ds $800 - 1 +sWindowStackTop:: + ds 1 + +; The PC boxes will not fit into one SRAM bank, +; so they use multiple SECTIONs +DEF box_n = 0 +MACRO boxes + rept \1 + DEF box_n += 1 + sBox{d:box_n}:: box sBox{d:box_n} + endr +ENDM + +SECTION "Boxes 1-5", SRAM + +; sBox1 - sBox5 + boxes 5 + +SECTION "Boxes 6-10", SRAM + +; sBox6 - sBox10 + boxes 5 + +; All 10 boxes fit exactly within 2 SRAM banks + assert box_n == NUM_BOXES, \ + "boxes: Expected {d:NUM_BOXES} total boxes, got {d:box_n}" diff --git a/ram/wram.asm b/ram/wram.asm index 22c76bc..ea9b124 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -618,18 +618,18 @@ wEnemyEvaLevel:: db ds 1 -wcab9:: ds 1 +wForceEvolution:: db wcaba:: ds 1 ds 1 wPlayerSubstituteHP:: ds 1 wEnemySubstituteHP:: ds 1 -wcabe:: ds 1 +wPlayerDebugSelectedMove:: ds 1 ds 1 -wcac0:: ds 1 +wMoveSelectionMenuType:: ds 1 wCurPlayerSelectedMove:: db wCurEnemySelectedMove:: db @@ -813,28 +813,46 @@ wWindowStackSize:: db SECTION "CC09", WRAM0[$CC02] wMenuDataHeader:: - db +wMenuFlags:: db wMenuBorderTopCoord:: db wMenuBorderLeftCoord:: db wMenuBorderBottomCoord:: db wMenuBorderRightCoord:: db wMenuDataPointer:: dw -wMenuCursorBuffer:: db - ds 8 ; TODO +wMenuCursorPosition:: db + ds 8 wMenuDataHeaderEnd:: -wMenuData2:: +wMenuData:: wMenuDataFlags:: db + +UNION wMenuDataItems:: db wMenuDataIndicesPointer:: dw wMenuDataDisplayFunctionPointer:: dw wMenuDataPointerTableAddr:: dw +wMenuDataEnd:: ds 2 -wcc1c:: dw - ds 1 -wcc1f:: dw - ds 1 -wMenuData3:: +NEXTU +; 2D Menu +wMenuData_2DMenuDimensions:: db +wMenuData_2DMenuSpacing:: db +wMenuData_2DMenuItemStringsBank:: db +wMenuData_2DMenuItemStringsAddr:: dw +wMenuData_2DMenuFunctionBank:: db +wMenuData_2DMenuFunctionAddr:: dw +NEXTU +wMenuData_ScrollingMenuHeight:: db +wMenuData_ScrollingMenuWidth:: db +wMenuData_ScrollingMenuItemFormat:: db +wMenuData_ItemsPointerBank:: db +wMenuData_ItemsPointerAddr:: dw +wMenuData_ScrollingMenuFunction1:: ds 3 +wMenuData_ScrollingMenuFunction2:: ds 3 +wMenuData_ScrollingMenuFunction3:: ds 3 +ENDU + +wMoreMenuData:: w2DMenuCursorInitY:: db w2DMenuCursorInitX:: db @@ -882,6 +900,13 @@ UNION wcc3a:: wChargeMoveNum:: +wPrevPartyLevel:: +wRodResponse_Old:: +wPokeFluteCuredSleep:: +wTempRestorePPItem:: db + +NEXTU + wMovementBufferCount:: db wMovementBufferObject:: db @@ -905,6 +930,19 @@ NEXTU wPlaceBallsDirection:: db wTrainerHUDTiles:: ds 4 +NEXTU +; switching items in pack +wSwitchItemBuffer:: ds 2 + +NEXTU + +wBattleMenuRows:: db +wBattleMenuColumns:: db + +NEXTU + +wTempBoxName:: ds BOX_NAME_LENGTH + ENDU SECTION "CC9A", WRAM0[$CC9A] @@ -991,21 +1029,13 @@ wMonOrItemNameBuffer:: ds MON_NAME_LENGTH ds MON_NAME_LENGTH -wcd1d:: ds 8 +wTMHMMoveNameBackup:: ds 8 ds 1 -UNION + wStringBuffer1:: ds STRING_BUFFER_LENGTH -NEXTU - ds 1 -wcd27:: ds 1 - ds 1 - -wcd29:: ds 1 -wcd2a:: ds 1 -ENDU SECTION "CD31", WRAM0[$CD31] UNION @@ -1029,7 +1059,9 @@ ENDU SECTION "CD3C", WRAM0[$CD3C] -wcd3c:: db +wcd3c:: +wPartyMenuCursor:: +wBillsPCCursor:: db wRegularItemsCursor:: db wBackpackAndKeyItemsCursor:: db @@ -1037,17 +1069,17 @@ wBattleMenuCursorPosition:: wStartmenuCursor:: db wCurMoveNum:: db +wCurBattleMon:: db -wCurBattleMon:: -wcd41:: db - -wcd42:: db +wTMHolderCursor:: db wFieldDebugMenuCursorBuffer:: wcd43:: db wRegularItemsScrollPosition:: db wBackpackAndKeyItemsScrollPosition:: db -wcd46:: ds 1 -wcd47:: ds 1 +wBillsPCScrollPosition:: db +wTMHolderScrollPosition:: db + +; TODO: change to wSwitchItem, wSwitchMon, wSwappingMove wSelectedSwapPosition:: db wMenuScrollPosition:: db @@ -1093,14 +1125,16 @@ wNamesPointer:: dw wItemAttributesPointer:: dw wCurItem:: db +wCurItemQuantity:: wItemIndex:: db + wCurPartySpecies: db wCurPartyMon: db -SECTION "CD7B", WRAM0[$CD7B] + ds 1 wWhichHPBar:: db -wPokemonWithdrawDepositParameter:: ds 1 +wPokemonWithdrawDepositParameter:: db wItemQuantity:: db wItemQuantityBuffer:: db @@ -1114,7 +1148,7 @@ wTalkingTargetType:: db ;bit 1 = has engaged sign in dialogue wcdb1:: ds 1 -wcdb2:: ds 1 +wHandlePlayerStep:: ds 1 ds 1 @@ -1143,7 +1177,7 @@ wNextMapGroup:: db wNextMapNumber:: db wPrevWarp:: db -wcdc2:: db +wEvolvableFlags:: db UNION wSkipMovesBeforeLevelUp:: @@ -1155,6 +1189,13 @@ wReplacementBlock:: db NEXTU wMonSubmenuCount:: db wMonSubmenuItems:: ds NUM_MONMENU_ITEMS + 1 + +NEXTU +; general-purpose HP buffers +wHPBuffer1:: dw +wHPBuffer2:: dw +wHPBuffer3:: dw + NEXTU wHPBarMaxHP:: dw @@ -1169,7 +1210,10 @@ wEnemyEffectivenessVsPlayerMons:: flag_array PARTY_LENGTH wPlayerEffectivenessVsEnemyMons:: flag_array PARTY_LENGTH NEXTU -; Used for an old nickname function and for storing the item price in the shop menu. +wBuySellItemPrice:: dw + +NEXTU +; Used for an old nickname function wMiscStringBuffer:: ds STRING_BUFFER_LENGTH NEXTU @@ -1195,6 +1239,13 @@ NEXTU wFinalCatchRate:: db wThrownBallWobbleCount:: db +NEXTU +; evolution data +wEvolutionOldSpecies:: db +wEvolutionNewSpecies:: db +wEvolutionPicOffset:: db +wEvolutionCanceled:: db + ENDU wLinkBattleRNs:: ds 10 @@ -1209,10 +1260,9 @@ wEnemyMonBaseStats:: ds NUM_EXP_STATS wEnemyMonCatchRate:: db wcdff:: ds 1 wBattleMode:: db -wce01:: ds 1 +wTempWildMonSpecies:: ds 1 wOtherTrainerClass:: ds 1 -wBattleType:: -wce03:: ds 1 +wBattleType:: db wce04:: ds 1 wOtherTrainerID:: ds 1 wBattleResult:: ds 1 @@ -1281,7 +1331,7 @@ wMonHLearnset:: ds 1 wMonHeaderEnd:: -SECTION "CE26", WRAM0[$CE26] + wce26:: ds 1 ds 2 @@ -1290,7 +1340,7 @@ wCurDamage:: dw ds 2 -wce2d:: ds 1 +wRepelEffect:: db wListMoves_MoveIndicesBuffer:: ds NUM_MOVES wPutativeTMHMMove:: db @@ -1303,10 +1353,14 @@ wNamedObjectIndexBuffer:: wNumSetBits:: wTextDecimalByte:: wTempIconSpecies:: +wTempPP:: +wTempTMHM:: +wUsePPUp:: wTempSpecies:: wMoveGrammar:: wTypeMatchup:: wCurType:: +wBreedingCompatibility:: wTempByteValue:: wApplyStatLevelMultipliersToEnemy:: wce37:: @@ -1317,9 +1371,7 @@ wce38:: ds 1 wNumFleeAttempts:: wce39:: ds 1 -SECTION "CE3A", WRAM0[$CE3A] - -wce3a:: ds 1 +wMonTriedToEvolve:: db wVBlankSavedROMBank:: db @@ -1472,9 +1524,7 @@ wJohtoBadges:: wKantoBadges:: flag_array NUM_KANTO_BADGES -wTMsHMs:: db - -SECTION "D19E", WRAM0[$D19E] +wTMsHMs:: ds NUM_TM_HM wItems:: wNumBagItems:: db @@ -1546,10 +1596,14 @@ wd41d:: db wd41e:: db SECTION "D4A9", WRAM0[$D4A7] +; Bit 0 set when exiting a battle. +; Bit 1 set when viewing summary/opening new dex entry, and reset when closing new dex entry. wd4a7:: db ds 1 wd4a9:: db ds 1 ; TODO + +; TODO: change to wJoypadDisable, constantify flags wJoypadFlags:: db ; 76543210 ; ||||\__/ @@ -1565,10 +1619,13 @@ wDigWarpNumber:: db wd4b3:: ds 1 wd4b4:: ds 1 wd4b5:: ds 1 -wd4b6:: ds 1 -wd4b7:: ds 1 -wd4b8:: ds 1 -wd4b9:: ds 1 + +; Doesn't get written to at any point yet, but it's read... once. +wCurBox:: db + + ds 2 + +wBoxNames:: ds BOX_NAME_LENGTH * NUM_BOXES SECTION "Warp data", WRAM0[$D513] @@ -1720,21 +1777,21 @@ wUnownDex:: ds NUM_UNOWN wAnnonID:: ds 1 -wd875:: ds 1 + ds 1 + +; Buffer used for withdrawing Breeder Pokémon, as well as checking gender. wBufferMonNickname:: ds MON_NAME_LENGTH - wBufferMonOT:: ds PLAYER_NAME_LENGTH +wBufferMon:: box_struct wBufferMon -wd882:: ds 1 -wd883:: ds 1 -wd884:: ds 1 +; 1 = One Pokémon deposited. +; 2 = Two Pokémon deposited. +; 3 = Egg laid. +; 4 = Egg received, don't lay another egg. +wBreederStatus:: ds 1 -SECTION "D8A2", WRAM0[$D8A2] - -wd8a2:: ds 1 -wd8a3:: ds 1 -wd8a4:: ds 1 + ds 2 wBreedMon1Nickname:: ds MON_NAME_LENGTH wBreedMon1OT:: ds PLAYER_NAME_LENGTH @@ -1744,9 +1801,9 @@ wBreedMon2Nickname:: ds MON_NAME_LENGTH wBreedMon2OT:: ds PLAYER_NAME_LENGTH wBreedMon2:: box_struct wBreedMon2 -SECTION "D8FD", WRAM0[$D8FD] - -wd8fd:: ds 1 +; Uses the last two bits to keep track of your breeder mons' genders. +; Bit clear = male, bit set = female +wBreedMonGenders:: db wd8fe:: ds 1 SECTION "D913", WRAM0[$D913] @@ -1781,38 +1838,7 @@ endr wOTPartyDataEnd:: ENDU -SECTION "DA83", WRAM0[$DA83] - -wBoxListLength:: db -wBoxList:: ds MONS_PER_BOX -wBoxListEnd:: db - -SECTION "DAA3", WRAM0[$DAA3] - -wBoxMons:: -; wBoxMon1 - wBoxMon30 -for n, 1, MONS_PER_BOX + 1 -wBoxMon{d:n}:: box_struct wBoxMon{d:n} -endr - -wBoxDataEnd:: - -SECTION "DE63", WRAM0[$DE63] - -wBoxMonOT:: -; wBoxMon1OT - wBoxMon30OT -for n, 1, MONS_PER_BOX + 1 -wBoxMon{d:n}OT:: ds PLAYER_NAME_LENGTH -endr -wBoxMonOTEnd:: - -wBoxMonNicknames:: -; wBoxMon1Nick - wBoxMon30Nick -for n, 1, MONS_PER_BOX + 1 -wBoxMon{d:n}Nick:: ds MON_NAME_LENGTH -endr -wBoxMonNicknamesEnd:: -wdfcb:: ds 1 +wBox:: box wBox SECTION "Stack Bottom", WRAM0 diff --git a/scripts/PlayerHouse2F.asm b/scripts/PlayerHouse2F.asm index 02a6de6..345f5a8 100644 --- a/scripts/PlayerHouse2F.asm +++ b/scripts/PlayerHouse2F.asm @@ -61,7 +61,7 @@ PlayerHouse2PositionCheck: ld hl, PlayerHouse2FTextString2 call OpenTextbox call PlayerHouse2FMovePlayer - call ClearAccumulator + call xor_a ret PlayerHouse2FMovePlayer: @@ -121,7 +121,7 @@ PlayerHouse2FComputerText: .jump call RefreshScreen callfar PokemonCenterPC - call Function1fea + call ScreenCleanup ret PlayerHouse2FCheckEmail: diff --git a/scripts/SilentHill.asm b/scripts/SilentHill.asm index d43e43b..0af03cc 100644 --- a/scripts/SilentHill.asm +++ b/scripts/SilentHill.asm @@ -310,7 +310,7 @@ CheckLabDoor: ld hl, SilentHillTextString1 call OpenTextbox call LabClosed - call ClearAccumulator + call xor_a ret LabClosed: diff --git a/scripts/SilentHillHouse.asm b/scripts/SilentHillHouse.asm index a348493..6ef0604 100644 --- a/scripts/SilentHillHouse.asm +++ b/scripts/SilentHillHouse.asm @@ -62,7 +62,7 @@ SilentHillHouseNPCText1: .jump call RefreshScreen callfar PokemonCenterPC - call Function1fea + call ScreenCleanup ret SilentHillHouseTextString1: diff --git a/scripts/SilentHillLabBack.asm b/scripts/SilentHillLabBack.asm index 502e567..d573bcf 100644 --- a/scripts/SilentHillLabBack.asm +++ b/scripts/SilentHillLabBack.asm @@ -230,7 +230,7 @@ ConfirmPokemonSelection: ld [wCurPartySpecies], a ld a, 5 ld [wCurPartyLevel], a - callfar Function60a0 + callfar GivePoke xor a ld [wPartyMon1 + 1], a ld a, 3 @@ -319,7 +319,7 @@ SilentHillLabBackFunc4: ld [wd265], a push hl ld [wNamedObjectIndexBuffer], a - farcall Function6734 + farcall StarterDex ld a, [wd265] ld [wNamedObjectIndexBuffer], a call GetPokemonName diff --git a/scripts/SilentHillLabFront.asm b/scripts/SilentHillLabFront.asm index 967b222..e48032a 100644 --- a/scripts/SilentHillLabFront.asm +++ b/scripts/SilentHillLabFront.asm @@ -160,7 +160,7 @@ SilentHillLabFrontMoveDown: ret nz ldh a, [hJoyState] bit 6, a - jp z, SetFFInAccumulator + jp z, xor_a_dec_a call SilentHillLabFrontText3 ld hl, wJoypadFlags set 4, [hl] @@ -173,7 +173,7 @@ SilentHillLabFrontMoveDown: set 7, [hl] ld a, 1 call WriteIntod637 - call ClearAccumulator + call xor_a ret SilentHillLabFrontMovement1: @@ -464,7 +464,7 @@ SilentHillLabFrontRivalMovePokemon: ld [wMapScriptNumber], a ld a, 1 call WriteIntod637 - call ClearAccumulator + call xor_a ret SilentHillLabFrontMovement9: @@ -595,7 +595,7 @@ SilentHillLabFrontMoveRivalLeave: ld [wMapScriptNumber], a ld a, 1 call WriteIntod637 - call ClearAccumulator + call xor_a ret Movememt12: diff --git a/shim.sym b/shim.sym index e60d82b..3eabf28 100644 --- a/shim.sym +++ b/shim.sym @@ -49,18 +49,9 @@ 0E:4F45 Function38f45 0E:50E9 Battle_GetTrainerName -10:5F93 Function4af93 -10:5FA1 Function41fa1 -10:61F8 Function421f8 -10:6252 FillMoves -10:58B8 Data418b8 - -11:4000 _DisplayDexEntry - -14:7274 Unknown53274 - 23:4940 Function8c940 23:49C6 Function8c9c6 +23:4b6d FishingAnim_Old 38:48A2 PokerMinigame 38:5AE3 FifteenPuzzleMinigame @@ -71,53 +62,14 @@ ; Poker Cursor AnimSeq Function 38:5054 Functione1054 - -; Cry header shims -3C:57C5 CryHeader_f17c5 -3C:57CE CryHeader_f17ce -3C:57D7 CryHeader_f17d7 -3C:57E0 CryHeader_f17e0 -3C:57E9 CryHeader_f17e9 -3C:57F2 CryHeader_f17f2 -3C:57FB CryHeader_f17fb -3C:5804 CryHeader_f1804 -3C:580D CryHeader_f180d -3C:5816 CryHeader_f1816 -3C:581F CryHeader_f181f -3C:5828 CryHeader_f1828 -3C:5831 CryHeader_f1831 -3C:583A CryHeader_f183a -3C:5843 CryHeader_f1843 -3C:584C CryHeader_f184c -3C:5855 CryHeader_f1855 -3C:585E CryHeader_f185e -3C:5867 CryHeader_f1867 -3C:5870 CryHeader_f1870 -3C:5879 CryHeader_f1879 -3C:5882 CryHeader_f1882 -3C:588B CryHeader_f188b -3C:5894 CryHeader_f1894 -3C:589D CryHeader_f189d -3C:58A6 CryHeader_f18a6 -3C:58AF CryHeader_f18af -3C:58B8 CryHeader_f18b8 -3C:58C1 CryHeader_f18c1 -3C:58CA CryHeader_f18ca -3C:58D3 CryHeader_f18d3 -3C:58DC CryHeader_f18dc -3C:58E5 CryHeader_f18e5 -3C:58EE CryHeader_f18ee -3C:58F7 CryHeader_f18f7 -3C:5900 CryHeader_f1900 -3C:5909 CryHeader_f1909 -3C:5912 CryHeader_f1912 - -;3E:40D6 LoadHPBarr - -3F:40E9 InGameDebugMenu -3F:4E3E Functionfce3e +;3F:40E9 InGameDebugMenu +;3F:4E3E Functionfce3e 3F:5B66 Functionfdb66 3F:64CE MonsterTest 3F:654E PicTest 3F:6750 PicTestMenu +; Filler. TODO: Determine the position of all filler and preferably extract it to binary files. +0B:786F Bank0b_FillerStart +14:7274 Bank14_FillerStart + diff --git a/utils/tests/charmap.asm b/utils/tests/charmap.asm index 1c01298..3221629 100644 --- a/utils/tests/charmap.asm +++ b/utils/tests/charmap.asm @@ -113,7 +113,7 @@ charmap "", $5f charmap "■", $60 - charmap "▲", $61 + charmap "▲", $61 charmap "☎", $62 charmap "A", $60 @@ -273,7 +273,7 @@ charmap "▷", $ec charmap "▶", $ed - charmap "▲", $ed + ; charmap "▲", $ed charmap "▼", $ee charmap "♂", $ef charmap "円", $f0