diff options
author | entrpntr <entrpntr@gmail.com> | 2020-04-30 23:37:15 -0400 |
---|---|---|
committer | entrpntr <entrpntr@gmail.com> | 2020-04-30 23:50:43 -0400 |
commit | 03bc01bf4efea42661600089af1a8ff787a093a5 (patch) | |
tree | cade8dc8d5d3aff4d849d0275d5f7b99022f3d13 | |
parent | 35f6c55eac49c0357bb7939f0e4c2667f09821d3 (diff) |
Add engine/link/link.asm and engine/link/mystery_gift.asm
28 files changed, 5679 insertions, 1485 deletions
@@ -28,6 +28,9 @@ baserom-silver.txt pokegold.txt pokesilver.txt +# used_space.py +used_space.png + # for vim configuration # url: http://www.vim.org/scripts/script.php?script_id=441 .lvimrc diff --git a/constants/item_constants.asm b/constants/item_constants.asm index a12977d5..6578ce76 100644 --- a/constants/item_constants.asm +++ b/constants/item_constants.asm @@ -278,6 +278,8 @@ ENDM add_hm WATERFALL ; f9 NUM_HMS EQU const_value - HM01 + const ITEM_FA ; fa + USE_SCRIPT_VAR EQU $00 ITEM_FROM_MEM EQU $ff diff --git a/constants/pokemon_constants.asm b/constants/pokemon_constants.asm index 33494bcc..58aa684a 100644 --- a/constants/pokemon_constants.asm +++ b/constants/pokemon_constants.asm @@ -1,261 +1,274 @@ - -; pokemon -const_value set 1 - const BULBASAUR - const IVYSAUR - const VENUSAUR - const CHARMANDER - const CHARMELEON - const CHARIZARD - const SQUIRTLE - const WARTORTLE - const BLASTOISE - const CATERPIE - const METAPOD - const BUTTERFREE - const WEEDLE - const KAKUNA - const BEEDRILL - const PIDGEY - const PIDGEOTTO - const PIDGEOT - const RATTATA - const RATICATE - const SPEAROW - const FEAROW - const EKANS - const ARBOK - const PIKACHU - const RAICHU - const SANDSHREW - const SANDSLASH - const NIDORAN_F - const NIDORINA - const NIDOQUEEN - const NIDORAN_M - const NIDORINO - const NIDOKING - const CLEFAIRY - const CLEFABLE - const VULPIX - const NINETALES - const JIGGLYPUFF - const WIGGLYTUFF - const ZUBAT - const GOLBAT - const ODDISH - const GLOOM - const VILEPLUME - const PARAS - const PARASECT - const VENONAT - const VENOMOTH - const DIGLETT - const DUGTRIO - const MEOWTH - const PERSIAN - const PSYDUCK - const GOLDUCK - const MANKEY - const PRIMEAPE - const GROWLITHE - const ARCANINE - const POLIWAG - const POLIWHIRL - const POLIWRATH - const ABRA - const KADABRA - const ALAKAZAM - const MACHOP - const MACHOKE - const MACHAMP - const BELLSPROUT - const WEEPINBELL - const VICTREEBEL - const TENTACOOL - const TENTACRUEL - const GEODUDE - const GRAVELER - const GOLEM - const PONYTA - const RAPIDASH - const SLOWPOKE - const SLOWBRO - const MAGNEMITE - const MAGNETON - const FARFETCH_D - const DODUO - const DODRIO - const SEEL - const DEWGONG - const GRIMER - const MUK - const SHELLDER - const CLOYSTER - const GASTLY - const HAUNTER - const GENGAR - const ONIX - const DROWZEE - const HYPNO - const KRABBY - const KINGLER - const VOLTORB - const ELECTRODE - const EXEGGCUTE - const EXEGGUTOR - const CUBONE - const MAROWAK - const HITMONLEE - const HITMONCHAN - const LICKITUNG - const KOFFING - const WEEZING - const RHYHORN - const RHYDON - const CHANSEY - const TANGELA - const KANGASKHAN - const HORSEA - const SEADRA - const GOLDEEN - const SEAKING - const STARYU - const STARMIE - const MR__MIME - const SCYTHER - const JYNX - const ELECTABUZZ - const MAGMAR - const PINSIR - const TAUROS - const MAGIKARP - const GYARADOS - const LAPRAS - const DITTO - const EEVEE - const VAPOREON - const JOLTEON - const FLAREON - const PORYGON - const OMANYTE - const OMASTAR - const KABUTO - const KABUTOPS - const AERODACTYL - const SNORLAX - const ARTICUNO - const ZAPDOS - const MOLTRES - const DRATINI - const DRAGONAIR - const DRAGONITE - const MEWTWO - const MEW - const CHIKORITA - const BAYLEEF - const MEGANIUM - const CYNDAQUIL - const QUILAVA - const TYPHLOSION - const TOTODILE - const CROCONAW - const FERALIGATR - const SENTRET - const FURRET - const HOOTHOOT - const NOCTOWL - const LEDYBA - const LEDIAN - const SPINARAK - const ARIADOS - const CROBAT - const CHINCHOU - const LANTURN - const PICHU - const CLEFFA - const IGGLYBUFF - const TOGEPI - const TOGETIC - const NATU - const XATU - const MAREEP - const FLAAFFY - const AMPHAROS - const BELLOSSOM - const MARILL - const AZUMARILL - const SUDOWOODO - const POLITOED - const HOPPIP - const SKIPLOOM - const JUMPLUFF - const AIPOM - const SUNKERN - const SUNFLORA - const YANMA - const WOOPER - const QUAGSIRE - const ESPEON - const UMBREON - const MURKROW - const SLOWKING - const MISDREAVUS - const UNOWN - const WOBBUFFET - const GIRAFARIG - const PINECO - const FORRETRESS - const DUNSPARCE - const GLIGAR - const STEELIX - const SNUBBULL - const GRANBULL - const QWILFISH - const SCIZOR - const SHUCKLE - const HERACROSS - const SNEASEL - const TEDDIURSA - const URSARING - const SLUGMA - const MAGCARGO - const SWINUB - const PILOSWINE - const CORSOLA - const REMORAID - const OCTILLERY - const DELIBIRD - const MANTINE - const SKARMORY - const HOUNDOUR - const HOUNDOOM - const KINGDRA - const PHANPY - const DONPHAN - const PORYGON2 - const STANTLER - const SMEARGLE - const TYROGUE - const HITMONTOP - const SMOOCHUM - const ELEKID - const MAGBY - const MILTANK - const BLISSEY - const RAIKOU - const ENTEI - const SUICUNE - const LARVITAR - const PUPITAR - const TYRANITAR - const LUGIA - const HO_OH - const CELEBI +; pokemon ids +; indexes for: +; - PokemonNames (see data/pokemon/names.asm) +; - BaseData (see data/pokemon/base_stats.asm) +; - EvosAttacksPointers (see data/pokemon/evos_attacks_pointers.asm) +; - EggMovePointers (see data/pokemon/egg_move_pointers.asm) +; - PokemonCries (see data/pokemon/cries.asm) +; - MonMenuIcons (see data/pokemon/menu_icons.asm) +; - PokemonPicPointers (see data/pokemon/pic_pointers.asm) +; - PokemonPalettes (see data/pokemon/palettes.asm) +; - PokedexDataPointerTable (see data/pokemon/dex_entry_pointers.asm) +; - AlphabeticalPokedexOrder (see data/pokemon/dex_order_alpha.asm) +; - NewPokedexOrder (see data/pokemon/dex_order_new.asm) +; - Pokered_MonIndices (see data/pokemon/gen1_order.asm) + const_def 1 + const BULBASAUR ; 01 + const IVYSAUR ; 02 + const VENUSAUR ; 03 + const CHARMANDER ; 04 + const CHARMELEON ; 05 + const CHARIZARD ; 06 + const SQUIRTLE ; 07 + const WARTORTLE ; 08 + const BLASTOISE ; 09 + const CATERPIE ; 0a + const METAPOD ; 0b + const BUTTERFREE ; 0c + const WEEDLE ; 0d + const KAKUNA ; 0e + const BEEDRILL ; 0f + const PIDGEY ; 10 + const PIDGEOTTO ; 11 + const PIDGEOT ; 12 + const RATTATA ; 13 + const RATICATE ; 14 + const SPEAROW ; 15 + const FEAROW ; 16 + const EKANS ; 17 + const ARBOK ; 18 + const PIKACHU ; 19 + const RAICHU ; 1a + const SANDSHREW ; 1b + const SANDSLASH ; 1c + const NIDORAN_F ; 1d + const NIDORINA ; 1e + const NIDOQUEEN ; 1f + const NIDORAN_M ; 20 + const NIDORINO ; 21 + const NIDOKING ; 22 + const CLEFAIRY ; 23 + const CLEFABLE ; 24 + const VULPIX ; 25 + const NINETALES ; 26 + const JIGGLYPUFF ; 27 + const WIGGLYTUFF ; 28 + const ZUBAT ; 29 + const GOLBAT ; 2a + const ODDISH ; 2b + const GLOOM ; 2c + const VILEPLUME ; 2d + const PARAS ; 2e + const PARASECT ; 2f + const VENONAT ; 30 + const VENOMOTH ; 31 + const DIGLETT ; 32 + const DUGTRIO ; 33 + const MEOWTH ; 34 + const PERSIAN ; 35 + const PSYDUCK ; 36 + const GOLDUCK ; 37 + const MANKEY ; 38 + const PRIMEAPE ; 39 + const GROWLITHE ; 3a + const ARCANINE ; 3b + const POLIWAG ; 3c + const POLIWHIRL ; 3d + const POLIWRATH ; 3e + const ABRA ; 3f + const KADABRA ; 40 + const ALAKAZAM ; 41 + const MACHOP ; 42 + const MACHOKE ; 43 + const MACHAMP ; 44 + const BELLSPROUT ; 45 + const WEEPINBELL ; 46 + const VICTREEBEL ; 47 + const TENTACOOL ; 48 + const TENTACRUEL ; 49 + const GEODUDE ; 4a + const GRAVELER ; 4b + const GOLEM ; 4c + const PONYTA ; 4d + const RAPIDASH ; 4e + const SLOWPOKE ; 4f + const SLOWBRO ; 50 + const MAGNEMITE ; 51 + const MAGNETON ; 52 + const FARFETCH_D ; 53 + const DODUO ; 54 + const DODRIO ; 55 + const SEEL ; 56 + const DEWGONG ; 57 + const GRIMER ; 58 + const MUK ; 59 + const SHELLDER ; 5a + const CLOYSTER ; 5b + const GASTLY ; 5c + const HAUNTER ; 5d + const GENGAR ; 5e + const ONIX ; 5f + const DROWZEE ; 60 + const HYPNO ; 61 + const KRABBY ; 62 + const KINGLER ; 63 + const VOLTORB ; 64 + const ELECTRODE ; 65 + const EXEGGCUTE ; 66 + const EXEGGUTOR ; 67 + const CUBONE ; 68 + const MAROWAK ; 69 + const HITMONLEE ; 6a + const HITMONCHAN ; 6b + const LICKITUNG ; 6c + const KOFFING ; 6d + const WEEZING ; 6e + const RHYHORN ; 6f + const RHYDON ; 70 + const CHANSEY ; 71 + const TANGELA ; 72 + const KANGASKHAN ; 73 + const HORSEA ; 74 + const SEADRA ; 75 + const GOLDEEN ; 76 + const SEAKING ; 77 + const STARYU ; 78 + const STARMIE ; 79 + const MR__MIME ; 7a + const SCYTHER ; 7b + const JYNX ; 7c + const ELECTABUZZ ; 7d + const MAGMAR ; 7e + const PINSIR ; 7f + const TAUROS ; 80 + const MAGIKARP ; 81 + const GYARADOS ; 82 + const LAPRAS ; 83 + const DITTO ; 84 + const EEVEE ; 85 + const VAPOREON ; 86 + const JOLTEON ; 87 + const FLAREON ; 88 + const PORYGON ; 89 + const OMANYTE ; 8a + const OMASTAR ; 8b + const KABUTO ; 8c + const KABUTOPS ; 8d + const AERODACTYL ; 8e + const SNORLAX ; 8f + const ARTICUNO ; 90 + const ZAPDOS ; 91 + const MOLTRES ; 92 + const DRATINI ; 93 + const DRAGONAIR ; 94 + const DRAGONITE ; 95 + const MEWTWO ; 96 + const MEW ; 97 +JOHTO_POKEMON EQU const_value + const CHIKORITA ; 98 + const BAYLEEF ; 99 + const MEGANIUM ; 9a + const CYNDAQUIL ; 9b + const QUILAVA ; 9c + const TYPHLOSION ; 9d + const TOTODILE ; 9e + const CROCONAW ; 9f + const FERALIGATR ; a0 + const SENTRET ; a1 + const FURRET ; a2 + const HOOTHOOT ; a3 + const NOCTOWL ; a4 + const LEDYBA ; a5 + const LEDIAN ; a6 + const SPINARAK ; a7 + const ARIADOS ; a8 + const CROBAT ; a9 + const CHINCHOU ; aa + const LANTURN ; ab + const PICHU ; ac + const CLEFFA ; ad + const IGGLYBUFF ; ae + const TOGEPI ; af + const TOGETIC ; b0 + const NATU ; b1 + const XATU ; b2 + const MAREEP ; b3 + const FLAAFFY ; b4 + const AMPHAROS ; b5 + const BELLOSSOM ; b6 + const MARILL ; b7 + const AZUMARILL ; b8 + const SUDOWOODO ; b9 + const POLITOED ; ba + const HOPPIP ; bb + const SKIPLOOM ; bc + const JUMPLUFF ; bd + const AIPOM ; be + const SUNKERN ; bf + const SUNFLORA ; c0 + const YANMA ; c1 + const WOOPER ; c2 + const QUAGSIRE ; c3 + const ESPEON ; c4 + const UMBREON ; c5 + const MURKROW ; c6 + const SLOWKING ; c7 + const MISDREAVUS ; c8 + const UNOWN ; c9 + const WOBBUFFET ; ca + const GIRAFARIG ; cb + const PINECO ; cc + const FORRETRESS ; cd + const DUNSPARCE ; ce + const GLIGAR ; cf + const STEELIX ; d0 + const SNUBBULL ; d1 + const GRANBULL ; d2 + const QWILFISH ; d3 + const SCIZOR ; d4 + const SHUCKLE ; d5 + const HERACROSS ; d6 + const SNEASEL ; d7 + const TEDDIURSA ; d8 + const URSARING ; d9 + const SLUGMA ; da + const MAGCARGO ; db + const SWINUB ; dc + const PILOSWINE ; dd + const CORSOLA ; de + const REMORAID ; df + const OCTILLERY ; e0 + const DELIBIRD ; e1 + const MANTINE ; e2 + const SKARMORY ; e3 + const HOUNDOUR ; e4 + const HOUNDOOM ; e5 + const KINGDRA ; e6 + const PHANPY ; e7 + const DONPHAN ; e8 + const PORYGON2 ; e9 + const STANTLER ; ea + const SMEARGLE ; eb + const TYROGUE ; ec + const HITMONTOP ; ed + const SMOOCHUM ; ee + const ELEKID ; ef + const MAGBY ; f0 + const MILTANK ; f1 + const BLISSEY ; f2 + const RAIKOU ; f3 + const ENTEI ; f4 + const SUICUNE ; f5 + const LARVITAR ; f6 + const PUPITAR ; f7 + const TYRANITAR ; f8 + const LUGIA ; f9 + const HO_OH ; fa + const CELEBI ; fb NUM_POKEMON EQU const_value - 1 - const MON_FC - const EGG - const MON_FE + const MON_FC ; fc + const EGG ; fd + const MON_FE ; fe ; Unown forms ; indexes for: diff --git a/constants/sprite_anim_constants.asm b/constants/sprite_anim_constants.asm index 6f61a917..173fb57d 100644 --- a/constants/sprite_anim_constants.asm +++ b/constants/sprite_anim_constants.asm @@ -20,39 +20,14 @@ SPRITEANIMSTRUCT_LENGTH EQU const_value NUM_SPRITE_ANIM_STRUCTS EQU 10 ; see wSpriteAnimationStructs ; SpriteAnimSeqData indexes (see data/sprite_anims/sequences.asm) +SPRITE_ANIM_INDEX_TRADE_POKE_BALL EQU $20 +SPRITE_ANIM_INDEX_TRADE_POOF EQU $21 +SPRITE_ANIM_INDEX_TRADE_TUBE_BULGE EQU $22 +SPRITE_ANIM_INDEX_TRADEMON_ICON EQU $23 +SPRITE_ANIM_INDEX_TRADEMON_BUBBLE EQU $24 SPRITE_ANIM_INDEX_EGG_CRACK EQU $2b SPRITE_ANIM_INDEX_EGG_HATCH EQU $2e -; DoAnimFrame.Jumptable indexes (see engine/gfx/sprite_anims.asm) - const_def - const SPRITE_ANIM_SEQ_NULL ; 00 - const SPRITE_ANIM_SEQ_PARTY_MON ; 01 - const SPRITE_ANIM_SEQ_PARTY_MON_SWITCH ; 02 - const SPRITE_ANIM_SEQ_PARTY_MON_SELECTED ; 03 - const SPRITE_ANIM_SEQ_GS_TITLE_TRAIL ; 04 - const SPRITE_ANIM_SEQ_NAMING_SCREEN_CURSOR ; 05 - const SPRITE_ANIM_SEQ_GAMEFREAK_LOGO ; 06 - const SPRITE_ANIM_SEQ_GS_INTRO_STAR ; 07 - const SPRITE_ANIM_SEQ_GS_INTRO_SPARKLE ; 08 - const SPRITE_ANIM_SEQ_SLOTS_GOLEM ; 09 - const SPRITE_ANIM_SEQ_SLOTS_CHANSEY ; 0a - const SPRITE_ANIM_SEQ_SLOTS_EGG ; 0b - const SPRITE_ANIM_SEQ_MAIL_CURSOR ; 0c - const SPRITE_ANIM_SEQ_UNUSED_CURSOR ; 0d - const SPRITE_ANIM_SEQ_DUMMY_GAME_CURSOR ; 0e - const SPRITE_ANIM_SEQ_POKEGEAR_ARROW ; 0f - const SPRITE_ANIM_SEQ_TRADE_POKE_BALL ; 10 - const SPRITE_ANIM_SEQ_TRADE_TUBE_BULGE ; 11 - const SPRITE_ANIM_SEQ_TRADEMON_IN_TUBE ; 12 - const SPRITE_ANIM_SEQ_REVEAL_NEW_MON ; 13 - const SPRITE_ANIM_SEQ_RADIO_TUNING_KNOB ; 14 - const SPRITE_ANIM_SEQ_CUT_LEAVES ; 15 - const SPRITE_ANIM_SEQ_FLY_FROM ; 16 - const SPRITE_ANIM_SEQ_FLY_LEAF ; 17 - const SPRITE_ANIM_SEQ_FLY_TO ; 18 - const SPRITE_ANIM_SEQ_GS_INTRO_HO_OH ; 19 - const SPRITE_ANIM_SEQ_EZCHAT_CURSOR ; 1a - ; SpriteAnimFrameData indexes (see data/sprite_anims/framesets.asm) const_def const SPRITE_ANIM_FRAMESET_00 ; 00 diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm index d4d94d06..391894f0 100644 --- a/constants/wram_constants.asm +++ b/constants/wram_constants.asm @@ -98,6 +98,13 @@ DAY_CARE_DEPOSIT EQU 3 const PLAYERSTEP_STOP_F ; 6 const PLAYERSTEP_START_F ; 7 +; wInitListType:: ; d14e +INIT_ENEMYOT_LIST EQU 1 +INIT_BAG_ITEM_LIST EQU 2 +INIT_OTHER_ITEM_LIST EQU 3 +INIT_PLAYEROT_LIST EQU 4 +INIT_MON_LIST EQU 5 + ; wTimeOfDay:: ; d157 const_def const MORN_F ; 0 diff --git a/data/items/catch_rate_items.asm b/data/items/catch_rate_items.asm new file mode 100644 index 00000000..9c39afac --- /dev/null +++ b/data/items/catch_rate_items.asm @@ -0,0 +1,18 @@ +; Pokémon traded from RBY do not have held items, so GSC usually interprets the +; catch rate as an item. However, if the catch rate appears in this table, the +; item associated with the table entry is used instead. + +TimeCapsule_CatchRateItems: + db ITEM_19, LEFTOVERS + db ITEM_2D, BITTER_BERRY + db ITEM_32, GOLD_BERRY + db ITEM_5A, BERRY + db ITEM_64, BERRY + db ITEM_78, BERRY + db ITEM_87, BERRY + db ITEM_BE, BERRY + db ITEM_C3, BERRY + db ITEM_DC, BERRY + db ITEM_FA, BERRY + db -1, BERRY + db 0 ; end diff --git a/data/text/common_1.asm b/data/text/common_1.asm index 51fe6cf5..fab936d0 100755 --- a/data/text/common_1.asm +++ b/data/text/common_1.asm @@ -362,38 +362,38 @@ _LookGiantDecoText:: line "fluffy and cuddly." done -UnknownText_0x1bc615:: +_MomHiHowAreYouText:: text "Hi, <PLAYER>!" line "How are you?" prompt -UnknownText_0x1bc62a:: +_MomFoundAnItemText:: text "I found a useful" line "item shopping, so" prompt -UnknownText_0x1bc64e:: +_MomBoughtWithYourMoneyText:: text "I bought it with" line "your money. Sorry!" prompt -UnknownText_0x1bc673:: +_MomItsInPCText:: text "It's in your PC." line "You'll like it!" done -UnknownText_0x1bc693:: +_MomFoundADollText:: text "While shopping" line "today, I saw this" cont "adorable doll, so" prompt -UnknownText_0x1bc6c7:: +_MomItsInYourRoomText:: text "It's in your room." line "You'll love it!" done -UnknownText_0x1bc6e9:: +_MonWasSentToText:: text_ram wPlayerTrademonSpeciesName text " was" line "sent to @" @@ -401,29 +401,29 @@ UnknownText_0x1bc6e9:: text "." done -UnknownText_0x1bc701:: +_MonNameSentToText:: text_start done -UnknownText_0x1bc703:: +_BidsFarewellToMonText:: text_ram wOTTrademonSenderName text " bids" line "farewell to" done -UnknownText_0x1bc719:: +_MonNameBidsFarewellText:: text_ram wOTTrademonSpeciesName text "." done -UnknownText_0x1bc71f:: +_TakeGoodCareOfMonText:: text "Take good care of" line "@" text_ram wOTTrademonSpeciesName text "." done -UnknownText_0x1bc739:: +_ForYourMonSendsText:: text "For @" text_ram wPlayerTrademonSenderName text "'s" @@ -432,7 +432,7 @@ UnknownText_0x1bc739:: text "," done -UnknownText_0x1bc74c:: +_OTSendsText:: text_ram wOTTrademonSenderName text " sends" line "@" @@ -440,14 +440,14 @@ UnknownText_0x1bc74c:: text "." done -UnknownText_0x1bc75e:: +_WillTradeText:: text_ram wOTTrademonSenderName text " will" line "trade @" text_ram wOTTrademonSpeciesName db "@@" -UnknownText_0x1bc774:: +_ForYourMonWillTradeText:: text "for @" text_ram wPlayerTrademonSenderName text "'s" @@ -1705,15 +1705,15 @@ _PlayerPickedUpPayDayMoney:: text "!" prompt -UnknownText_0x1c0373:: +_BootedTMText:: text "Booted up a TM." prompt -UnknownText_0x1c0384:: +_BootedHMText:: text "Booted up an HM." prompt -UnknownText_0x1c0396:: +_ContainedMoveText:: text "It contained" line "@" text_ram wStringBuffer2 @@ -1725,7 +1725,7 @@ UnknownText_0x1c0396:: line "to a #MON?" done -UnknownText_0x1c03c2:: +_TMHMNotCompatibleText:: text_ram wStringBuffer2 text " is" line "not compatible" @@ -1739,7 +1739,7 @@ UnknownText_0x1c03c2:: text "." prompt -UnknownText_0x1c03fa:: +_NoRoomTMHMText:: text "You have no room" line "for any more" cont "@" @@ -1747,44 +1747,44 @@ UnknownText_0x1c03fa:: text "S." prompt -UnknownText_0x1c0421:: +_ReceivedTMHMText:: text "You received" line "@" text_ram wStringBuffer1 text "!" prompt -UnknownText_0x1c0436:: +_MysteryGiftCanceledText:: text "The link has been" line "cancelled." prompt -UnknownText_0x1c0454:: +_MysteryGiftCommErrorText:: text "Communication" line "error." prompt -UnknownText_0x1c046a:: +_RetrieveMysteryGiftText:: text "Must retrieve GIFT" line "at #MON CENTER." prompt -UnknownText_0x1c048e:: +_YourFriendIsNotReadyText:: text "Your friend isn't" line "ready." prompt -UnknownText_0x1c04a7:: +_MysteryGiftFiveADayText:: text "Sorry--only five" line "GIFTS a day." prompt -UnknownText_0x1c04c6:: +_MysteryGiftOneADayText:: text "Sorry. One GIFT" line "a day per person." prompt -UnknownText_0x1c04e9:: +_MysteryGiftSentText:: text_ram wMysteryGiftPartnerName text " sent" line "@" @@ -1792,7 +1792,7 @@ UnknownText_0x1c04e9:: text "." prompt -UnknownText_0x1c04fa:: +_MysteryGiftSentHomeText:: text_ram wMysteryGiftPartnerName text " sent" line "@" diff --git a/data/text/common_2.asm b/data/text/common_2.asm index d61544e2..b2ff0450 100644 --- a/data/text/common_2.asm +++ b/data/text/common_2.asm @@ -1207,7 +1207,7 @@ _OakText7:: line "later!" done -UnknownText_0x1c40e6:: +_ClockTimeMayBeWrongText:: text "The clock's time" line "may be wrong." @@ -1215,7 +1215,7 @@ UnknownText_0x1c40e6:: line "time." prompt -UnknownText_0x1c411c:: +_ClockSetWithControlPadText:: text "Set with the" line "Control Pad." @@ -1223,28 +1223,28 @@ UnknownText_0x1c411c:: line "Cancel: B Button" done -UnknownText_0x1c415b:: +_ClockIsThisOKText:: text "Is this OK?" done -UnknownText_0x1c4168:: +_ClockHasResetText:: text "The clock has been" line "reset." done -UnknownText_0x1c4183:: +_LinkTimeoutText:: text "Too much time has" line "elapsed. Please" cont "try again." prompt -UnknownText_0x1c41b1:: +_LinkTradeCantBattleText:: text "If you trade that" line "#MON, you won't" cont "be able to battle." prompt -UnknownText_0x1c41e6:: +_LinkAbnormalMonText:: text "Your friend's" line "@" text_ram wStringBuffer1 @@ -1252,7 +1252,7 @@ UnknownText_0x1c41e6:: cont "to be abnormal!" prompt -UnknownText_0x1c4212:: +_LinkAskTradeForText:: text "Trade @" text_ram wceef text_start diff --git a/engine/link/link.asm b/engine/link/link.asm new file mode 100644 index 00000000..fccb8f5c --- /dev/null +++ b/engine/link/link.asm @@ -0,0 +1,2345 @@ +LinkCommunications: + ld c, 80 + call DelayFrames + call ClearTilemap + call ClearSprites + call UpdateSprites + call WaitBGMap + call SetTradeRoomBGPals + xor a + ldh [hSCX], a + ldh [hSCY], a + ld c, 80 + call DelayFrames + call ClearTilemap + call UpdateSprites + call LoadStandardFont + call LoadFontsBattleExtra + call LoadTradeScreenBorder + call SetTradeRoomBGPals + call WaitBGMap + hlcoord 3, 8 + ld b, 2 + ld c, 12 + call LinkTextboxAtHL + hlcoord 4, 10 + ld de, String_PleaseWait + call PlaceString + ld hl, wce5d + xor a ; LOW($5000) + ld [hli], a + ld [hl], HIGH($5000) + ld a, [wLinkMode] + cp LINK_TIMECAPSULE + jp nz, Gen2ToGen2LinkComms + +Gen2ToGen1LinkComms: + call ClearLinkData + call Link_PrepPartyData_Gen1 + call FixDataForLinkTransfer + xor a + ld [wPlayerLinkAction], a + call WaitLinkTransfer + ldh a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr nz, .player_1 + + ld c, 3 + call DelayFrames + xor a + ldh [hSerialSend], a + ld a, (0 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + ld a, (1 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + + call DelayFrame + xor a + ldh [hSerialSend], a + ld a, (0 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + ld a, (1 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + +.player_1 + ld de, MUSIC_NONE + call PlayMusic + ld c, 3 + call DelayFrames + xor a + ldh [rIF], a + ld a, 1 << SERIAL + ldh [rIE], a + ld hl, wd0dc + ld de, wEnemyMonSpecies + ld bc, $11 + call Serial_ExchangeBytes + ld a, SERIAL_NO_DATA_BYTE + ld [de], a + ld hl, wLinkData + ld de, wOTPlayerName + ld bc, $1a8 + call Serial_ExchangeBytes + ld a, SERIAL_NO_DATA_BYTE + ld [de], a + ld hl, wc508 + ld de, wTrademons + ld bc, wTrademons - wc508 + call Serial_ExchangeBytes + xor a + ldh [rIF], a + ld a, (1 << JOYPAD) | (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK) + ldh [rIE], a + call Link_CopyRandomNumbers + ld hl, wOTPlayerName + call Link_FindFirstNonControlCharacter_SkipZero + push hl + ld bc, NAME_LENGTH + add hl, bc + ld a, [hl] + pop hl + and a + jp z, Function28b22 + cp $7 + jp nc, Function28b22 + ld de, wLinkData + ld bc, $1a2 + call Link_CopyOTData + ld de, wPlayerTrademonSpecies + ld hl, wTimeCapsulePartyMon1Species + ld c, 2 +.loop + ld a, [de] + inc de + and a + jr z, .loop + cp SERIAL_PREAMBLE_BYTE + jr z, .loop + cp SERIAL_NO_DATA_BYTE + jr z, .loop + cp SERIAL_PATCH_LIST_PART_TERMINATOR + jr z, .next + push hl + push bc + ld b, 0 + dec a + ld c, a + add hl, bc + ld a, SERIAL_NO_DATA_BYTE + ld [hl], a + pop bc + pop hl + jr .loop + +.next + ld hl, wc80f + dec c + jr nz, .loop + ld hl, wLinkPlayerName + ld de, wOTPlayerName + ld bc, NAME_LENGTH + call CopyBytes + ld de, wOTPartyCount + ld a, [hli] + ld [de], a + inc de +.party_loop + ld a, [hli] + cp -1 + jr z, .done_party + ld [wTempSpecies], a + push hl + push de + callfar ConvertMon_1to2 + pop de + pop hl + ld a, [wTempSpecies] + ld [de], a + inc de + jr .party_loop + +.done_party + ld [de], a + ld hl, wTimeCapsulePartyMon1Species + call Function2868a + ld a, LOW(wOTPartyMonOT) + ld [wUnusedCFFE], a + ld a, HIGH(wOTPartyMonOT) + ld [wUnusedCFFE + 1], a + ld de, MUSIC_NONE + call PlayMusic + ldh a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + ld c, 66 + call z, DelayFrames + ld de, MUSIC_ROUTE_30 + call PlayMusic + jp InitTradeMenuDisplay + +Gen2ToGen2LinkComms: + call ClearLinkData + call Link_PrepPartyData_Gen2 + call FixDataForLinkTransfer + call Function29dba + ld a, [wScriptVar] + and a + jp z, LinkTimeout + ldh a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr nz, .Player1 + + ld c, 3 + call DelayFrames + xor a + ldh [hSerialSend], a + ld a, (0 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + ld a, (1 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + + call DelayFrame + xor a + ldh [hSerialSend], a + ld a, (0 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + ld a, (1 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + +.Player1: + ld de, MUSIC_NONE + call PlayMusic + ld c, 3 + call DelayFrames + xor a + ldh [rIF], a + ld a, 1 << SERIAL + ldh [rIE], a + ld hl, wd0dc + ld de, wEnemyMonSpecies + ld bc, $11 + call Serial_ExchangeBytes + ld a, SERIAL_NO_DATA_BYTE + ld [de], a + ld hl, wLinkData + ld de, wOTPlayerName + ld bc, $1c2 + call Serial_ExchangeBytes + ld a, SERIAL_NO_DATA_BYTE + ld [de], a + ld hl, wc508 + ld de, wTrademons + ld bc, wTrademons - wc508 + call Serial_ExchangeBytes + ld a, [wLinkMode] + cp LINK_TRADECENTER + jr nz, .not_trading + ld hl, wc8f4 + ld de, wca84 + ld bc, $186 + call ExchangeBytes + +.not_trading + xor a + ldh [rIF], a + ld a, (1 << JOYPAD) | (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK) + ldh [rIE], a + ld de, MUSIC_NONE + call PlayMusic + call Link_CopyRandomNumbers + ld hl, wOTPlayerName + call Link_FindFirstNonControlCharacter_SkipZero + ld de, wLinkData + ld bc, $1b9 + call Link_CopyOTData + ld de, wPlayerTrademonSpecies + ld hl, wLinkPlayerPartyMon1Species + ld c, 2 +.loop1 + ld a, [de] + inc de + and a + jr z, .loop1 + cp SERIAL_PREAMBLE_BYTE + jr z, .loop1 + cp SERIAL_NO_DATA_BYTE + jr z, .loop1 + cp SERIAL_PATCH_LIST_PART_TERMINATOR + jr z, .next1 + push hl + push bc + ld b, 0 + dec a + ld c, a + add hl, bc + ld a, SERIAL_NO_DATA_BYTE + ld [hl], a + pop bc + pop hl + jr .loop1 + +.next1 + ld hl, wc80f + dec c + jr nz, .loop1 + ld a, [wLinkMode] + cp LINK_TRADECENTER + jr nz, .skip_mail + ld hl, wca84 +.loop2 + ld a, [hli] + cp MAIL_MSG_LENGTH + jr nz, .loop2 +.loop3 + ld a, [hli] + cp SERIAL_NO_DATA_BYTE + jr z, .loop3 + cp MAIL_MSG_LENGTH + jr z, .loop3 + dec hl + ld de, wca84 + ld bc, $190 ; 400 + call CopyBytes + ld hl, wca84 + ld bc, $c6 ; 198 +.loop4 + ld a, [hl] + cp MAIL_MSG_LENGTH + 1 + jr nz, .okay1 + ld [hl], SERIAL_NO_DATA_BYTE +.okay1 + inc hl + dec bc + ld a, b + or c + jr nz, .loop4 + ld de, wcb9e +.loop5 + ld a, [de] + inc de + cp SERIAL_PATCH_LIST_PART_TERMINATOR + jr z, .start_copying_mail + ld hl, wcb4a + dec a + ld b, $0 + ld c, a + add hl, bc + ld [hl], SERIAL_NO_DATA_BYTE + jr .loop5 + +.start_copying_mail + ld hl, wca84 + ld de, wc8f4 + ld b, PARTY_LENGTH +.copy_mail_loop + push bc + ld bc, MAIL_MSG_LENGTH + 1 + call CopyBytes + ld a, LOW(MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1)) + add e + ld e, a + ld a, HIGH(MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1)) + adc d + ld d, a + pop bc + dec b + jr nz, .copy_mail_loop + ld de, wc8f4 + ld b, PARTY_LENGTH +.fix_mail_loop + push bc + ld a, LOW(MAIL_MSG_LENGTH + 1) + add e + ld e, a + ld a, HIGH(MAIL_MSG_LENGTH + 1) + adc d + ld d, a + ld bc, MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1) + call CopyBytes + pop bc + dec b + jr nz, .fix_mail_loop + ld de, wca0e + xor a + ld [de], a + +.skip_mail + ld hl, wLinkPlayerName + ld de, wOTPlayerName + ld bc, NAME_LENGTH + call CopyBytes + ld de, wOTPartyCount + ld bc, 1 + PARTY_LENGTH + 1 + call CopyBytes + ld de, wOTPlayerID + ld bc, 2 + call CopyBytes + ld de, wOTPartyMons + ld bc, wOTPartyDataEnd - wOTPartyMons + call CopyBytes + ld a, LOW(wOTPartyMonOT) + ld [wUnusedCFFE], a + ld a, HIGH(wOTPartyMonOT) + ld [wUnusedCFFE + 1], a + ld de, MUSIC_NONE + call PlayMusic + ldh a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + ld c, 66 + call z, DelayFrames + ld a, [wLinkMode] + cp LINK_COLOSSEUM + jr nz, .ready_to_trade + ld a, CAL + ld [wOtherTrainerClass], a + call ClearTilemap + call WaitBGMap + ld hl, wOptions + ld a, [hl] + push af + and 1 << STEREO + or TEXT_DELAY_MED + ld [hl], a + ld hl, wOTPlayerName + ld de, wOTClassName + ld bc, NAME_LENGTH + call CopyBytes + call ReturnToMapFromSubmenu + + ; LET'S DO THIS + ld a, [wDisableTextAcceleration] + push af + ld a, 1 + ld [wDisableTextAcceleration], a + + predef StartBattle + + pop af + ld [wDisableTextAcceleration], a + pop af + ld [wOptions], a + farcall LoadPokemonData + jp Function28b22 + +.ready_to_trade + ld de, MUSIC_ROUTE_30 + call PlayMusic + jp InitTradeMenuDisplay + +LinkTimeout: + ld de, .LinkTimeoutText + ld b, 10 +.loop + call DelayFrame + call LinkDataReceived + dec b + jr nz, .loop + xor a + ld [hld], a + ld [hl], a + ldh [hVBlank], a + push de + hlcoord 0, 12 + ld b, 4 + ld c, 18 + call LinkTextboxAtHL + pop hl + bccoord 1, 14 + jp PlaceHLTextAtBC + +.LinkTimeoutText: + text_far _LinkTimeoutText + text_end + +ExchangeBytes: + ld a, TRUE + ldh [hSerialIgnoringInitialData], a +.loop + ld a, [hl] + ldh [hSerialSend], a + call Serial_ExchangeByte + push bc + ld b, a + inc hl + ld a, 48 +.delay_cycles + dec a + jr nz, .delay_cycles + ldh a, [hSerialIgnoringInitialData] + and a + ld a, b + pop bc + jr z, .load + dec hl + xor a + ldh [hSerialIgnoringInitialData], a + jr .loop + +.load + ld [de], a + inc de + dec bc + ld a, b + or c + jr nz, .loop + ret + +String_PleaseWait: + db "PLEASE WAIT!@" + +ClearLinkData: + ld hl, wLinkData + ld bc, wLinkDataEnd - wLinkData +.loop + xor a + ld [hli], a + dec bc + ld a, b + or c + jr nz, .loop + ret + +FixDataForLinkTransfer: + ld hl, wd0dc + ld a, SERIAL_PREAMBLE_BYTE + ld b, wLinkBattleRNs - wd0dc +.loop1 + ld [hli], a + dec b + jr nz, .loop1 + ld b, wTempEnemyMonSpecies - wLinkBattleRNs +.loop2 + call Random + cp SERIAL_PREAMBLE_BYTE + jr nc, .loop2 + ld [hli], a + dec b + jr nz, .loop2 + ld hl, wc508 + ld a, SERIAL_PREAMBLE_BYTE + ld [hli], a + ld [hli], a + ld [hli], a + ld b, $c8 + xor a +.loop3 + ld [hli], a + dec b + jr nz, .loop3 + ld hl, wTimeCapsulePartyMon1 - 1 + PARTY_LENGTH + ld de, wc512 + lb bc, 0, 0 +.loop4 + inc c + ld a, c + cp SERIAL_PREAMBLE_BYTE + jr z, .next1 + ld a, b + dec a + jr nz, .next2 + push bc + ld a, [wLinkMode] + cp LINK_TIMECAPSULE + ld b, $d + jr z, .got_value + ld b, $27 +.got_value + ld a, c + cp b + pop bc + jr z, .done +.next2 + inc hl + ld a, [hl] + cp SERIAL_NO_DATA_BYTE + jr nz, .loop4 + ld a, c + ld [de], a + inc de + ld [hl], SERIAL_PATCH_LIST_PART_TERMINATOR + jr .loop4 + +.next1 + ld a, SERIAL_PATCH_LIST_PART_TERMINATOR + ld [de], a + inc de + lb bc, 1, 0 + jr .loop4 + +.done + ld a, SERIAL_PATCH_LIST_PART_TERMINATOR + ld [de], a + ret + +Link_PrepPartyData_Gen1: + ld de, wLinkData + ld a, SERIAL_PREAMBLE_BYTE + ld b, PARTY_LENGTH +.loop1 + ld [de], a + inc de + dec b + jr nz, .loop1 + ld hl, wPlayerName + ld bc, NAME_LENGTH + call CopyBytes + push de + ld hl, wPartyCount + ld a, [hli] + ld [de], a + inc de +.loop2 + ld a, [hli] + cp -1 + jr z, .done_party + ld [wTempSpecies], a + push hl + push de + callfar ConvertMon_2to1 + pop de + pop hl + ld a, [wTempSpecies] + ld [de], a + inc de + jr .loop2 + +.done_party + ld [de], a + pop de + ld hl, 1 + PARTY_LENGTH + 1 + add hl, de + ld d, h + ld e, l + ld hl, wPartyMon1Species + ld c, PARTY_LENGTH +.mon_loop + push bc + call .ConvertPartyStruct2to1 + ld bc, PARTYMON_STRUCT_LENGTH + add hl, bc + pop bc + dec c + jr nz, .mon_loop + ld hl, wPartyMonOT + call .copy_ot_nicks + ld hl, wPartyMonNicknames +.copy_ot_nicks + ld bc, PARTY_LENGTH * NAME_LENGTH + jp CopyBytes + +.ConvertPartyStruct2to1: + ld b, h + ld c, l + push de + push bc + ld a, [hl] + ld [wTempSpecies], a + callfar ConvertMon_2to1 + pop bc + pop de + ld a, [wTempSpecies] + ld [de], a + inc de + ld hl, MON_HP + add hl, bc + ld a, [hli] + ld [de], a + inc de + ld a, [hl] + ld [de], a + inc de + xor a + ld [de], a + inc de + ld hl, MON_STATUS + add hl, bc + ld a, [hl] + ld [de], a + inc de + ld a, [bc] + cp MAGNEMITE + jr z, .steel_type + cp MAGNETON + jr nz, .skip_steel + +.steel_type + ld a, ELECTRIC + ld [de], a + inc de + ld [de], a + inc de + jr .done_steel + +.skip_steel + push bc + dec a + ld hl, BaseData + BASE_TYPES + ld bc, BASE_DATA_SIZE + call AddNTimes + ld bc, BASE_CATCH_RATE - BASE_TYPES + ld a, BANK(BaseData) + call FarCopyBytes + pop bc + +.done_steel + push bc + ld hl, MON_ITEM + add hl, bc + ld bc, MON_HAPPINESS - MON_ITEM + call CopyBytes + pop bc + + ld hl, MON_LEVEL + add hl, bc + ld a, [hl] + ld [de], a + ld [wCurPartyLevel], a + inc de + + push bc + ld hl, MON_MAXHP + add hl, bc + ld bc, MON_SAT - MON_MAXHP + call CopyBytes + pop bc + + push de + push bc + + ld a, [bc] + dec a + push bc + ld b, 0 + ld c, a + ld hl, KantoMonSpecials + add hl, bc + ld a, BANK(KantoMonSpecials) + call GetFarByte + ld [wBaseSpecialAttack], a + pop bc + + ld hl, MON_STAT_EXP - 1 + add hl, bc + ld c, STAT_SATK + ld b, TRUE + predef CalcMonStatC + + pop bc + pop de + + ldh a, [hQuotient + 2] + ld [de], a + inc de + ldh a, [hQuotient + 3] + ld [de], a + inc de + ld h, b + ld l, c + ret + +Link_PrepPartyData_Gen2: + ld de, wLinkData + ld a, SERIAL_PREAMBLE_BYTE + ld b, PARTY_LENGTH +.loop1 + ld [de], a + inc de + dec b + jr nz, .loop1 + ld hl, wPlayerName + ld bc, NAME_LENGTH + call CopyBytes + ld hl, wPartyCount + ld bc, 1 + PARTY_LENGTH + 1 + call CopyBytes + ld hl, wPlayerID + ld bc, 2 + call CopyBytes + ld hl, wPartyMon1Species + ld bc, PARTY_LENGTH * PARTYMON_STRUCT_LENGTH + call CopyBytes + ld hl, wPartyMonOT + ld bc, PARTY_LENGTH * NAME_LENGTH + call CopyBytes + ld hl, wPartyMonNicknames + ld bc, PARTY_LENGTH * MON_NAME_LENGTH + call CopyBytes + +; Okay, we did all that. Now, are we in the trade center? + ld a, [wLinkMode] + cp LINK_TRADECENTER + ret nz + +; Fill 5 bytes at wc8f4 with $20 + ld de, wc8f4 + ld a, $20 + call Function28682 + +; Copy all the mail messages to wc9f9 + ld a, BANK(sPartyMail) + call OpenSRAM + ld hl, sPartyMail + ld b, PARTY_LENGTH +.loop2 + push bc + ld bc, MAIL_MSG_LENGTH + 1 + call CopyBytes + ld bc, sPartyMon1MailEnd - sPartyMon1MailAuthor + add hl, bc + pop bc + dec b + jr nz, .loop2 +; Copy the mail data to wcabf + ld hl, sPartyMail + ld b, PARTY_LENGTH +.loop3 + push bc + ld bc, MAIL_MSG_LENGTH + 1 + add hl, bc + ld bc, sPartyMon1MailEnd - sPartyMon1MailAuthor + call CopyBytes + pop bc + dec b + jr nz, .loop3 + + call CloseSRAM + ld hl, wc8f9 + ld bc, PARTY_LENGTH * (sPartyMon1MailAuthor - sPartyMon1Mail) +.loop4 + ld a, [hl] + cp SERIAL_NO_DATA_BYTE + jr nz, .skip2 + ld [hl], sPartyMon1MailAuthor - sPartyMon1Mail + +.skip2 + inc hl + dec bc + ld a, b + or c + jr nz, .loop4 + ld hl, wc9bf + ld de, wca13 + ld b, PARTY_LENGTH * (sPartyMon1MailEnd - sPartyMon1MailAuthor) + ld c, $0 +.loop5 + inc c + ld a, [hl] + cp SERIAL_NO_DATA_BYTE + jr nz, .skip3 + ld [hl], SERIAL_PATCH_LIST_PART_TERMINATOR + ld a, c + ld [de], a + inc de + +.skip3 + inc hl + dec b + jr nz, .loop5 + ld a, SERIAL_PATCH_LIST_PART_TERMINATOR + ld [de], a + ret + +Function28682: + ld c, 5 +.loop + ld [de], a + inc de + dec c + jr nz, .loop + ret + +Function2868a: + push hl + ld d, h + ld e, l + ld bc, wLinkOTPartyMonTypes + ld hl, wcae8 + ld a, c + ld [hli], a + ld [hl], b + ld hl, wOTPartyMon1Species + ld c, PARTY_LENGTH +.loop + push bc + call .ConvertToGen2 + pop bc + dec c + jr nz, .loop + pop hl + ld bc, PARTY_LENGTH * REDMON_STRUCT_LENGTH + add hl, bc + ld de, wOTPartyMonOT + ld bc, PARTY_LENGTH * NAME_LENGTH + call CopyBytes + ld de, wOTPartyMonNicknames + ld bc, PARTY_LENGTH * MON_NAME_LENGTH + jp CopyBytes + +.ConvertToGen2: + ld b, h + ld c, l + ld a, [de] + inc de + push bc + push de + ld [wTempSpecies], a + callfar ConvertMon_1to2 + pop de + pop bc + ld a, [wTempSpecies] + ld [bc], a + ld [wCurSpecies], a + ld hl, MON_HP + add hl, bc + ld a, [de] + inc de + ld [hli], a + ld a, [de] + inc de + ld [hl], a + inc de + ld hl, MON_STATUS + add hl, bc + ld a, [de] + inc de + ld [hl], a + ld hl, wcae8 + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [de] + ld [hli], a + inc de + ld a, [de] + ld [hli], a + inc de + ld a, l + ld [wcae8], a + ld a, h + ld [wcae8 + 1], a + push bc + ld hl, MON_ITEM + add hl, bc + push hl + ld h, d + ld l, e + pop de + push bc + ld a, [hli] + ld b, a + call TimeCapsule_ReplaceTeruSama + ld a, b + ld [de], a + inc de + pop bc + ld bc, $19 + call CopyBytes + pop bc + ld d, h + ld e, l + ld hl, $1f + add hl, bc + ld a, [de] + inc de + ld [hl], a + ld [wCurPartyLevel], a + push bc + ld hl, $24 + add hl, bc + push hl + ld h, d + ld l, e + pop de + ld bc, 8 + call CopyBytes + pop bc + call GetBaseData + push de + push bc + ld d, h + ld e, l + ld hl, MON_STAT_EXP - 1 + add hl, bc + ld c, STAT_SATK + ld b, TRUE + predef CalcMonStatC + pop bc + pop hl + ldh a, [hQuotient + 2] + ld [hli], a + ldh a, [hQuotient + 3] + ld [hli], a + push hl + push bc + ld hl, MON_STAT_EXP - 1 + add hl, bc + ld c, STAT_SDEF + ld b, TRUE + predef CalcMonStatC + pop bc + pop hl + ldh a, [hQuotient + 2] + ld [hli], a + ldh a, [hQuotient + 3] + ld [hli], a + push hl + ld hl, $1b + add hl, bc + ld a, $46 + ld [hli], a + xor a + ld [hli], a + ld [hli], a + ld [hl], a + pop hl + inc de + inc de + ret + +TimeCapsule_ReplaceTeruSama: + ld a, b + and a + ret z + push hl + ld hl, TimeCapsule_CatchRateItems +.loop + ld a, [hli] + and a + jr z, .end + cp b + jr z, .found + inc hl + jr .loop + +.found + ld b, [hl] + +.end + pop hl + ret + +INCLUDE "data/items/catch_rate_items.asm" + +Link_CopyOTData: +.loop + ld a, [hli] + cp SERIAL_NO_DATA_BYTE + jr z, .loop + ld [de], a + inc de + dec bc + ld a, b + or c + jr nz, .loop + ret + +Link_CopyRandomNumbers: + ldh a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + ret z + ld hl, wEnemyMonSpecies + call Link_FindFirstNonControlCharacter_AllowZero + ld de, wLinkBattleRNs + ld c, 10 +.loop + ld a, [hli] + cp SERIAL_NO_DATA_BYTE + jr z, .loop + cp SERIAL_PREAMBLE_BYTE + jr z, .loop + ld [de], a + inc de + dec c + jr nz, .loop + ret + +Link_FindFirstNonControlCharacter_SkipZero: +.loop + ld a, [hli] + and a + jr z, .loop + cp SERIAL_PREAMBLE_BYTE + jr z, .loop + cp SERIAL_NO_DATA_BYTE + jr z, .loop + dec hl + ret + +Link_FindFirstNonControlCharacter_AllowZero: +.loop + ld a, [hli] + cp SERIAL_PREAMBLE_BYTE + jr z, .loop + cp SERIAL_NO_DATA_BYTE + jr z, .loop + dec hl + ret + +InitTradeMenuDisplay: + call ClearTilemap + call LoadTradeScreenBorder + call Function28dcf + call Function28a16 + xor a + ld hl, wOtherPlayerLinkMode + ld [hli], a + ld [hli], a + ld [hli], a + ld [hl], a + ld a, 1 + ld [wMenuCursorY], a + inc a + ld [wPlayerLinkAction], a + jp LinkTrade_PlayerPartyMenu + +LinkTrade_OTPartyMenu: + ld a, OTPARTYMON + ld [wMonType], a + ld a, A_BUTTON | D_UP | D_DOWN + ld [wMenuJoypadFilter], a + ld a, [wOTPartyCount] + ld [w2DMenuNumRows], a + ld a, 1 + ld [w2DMenuNumCols], a + ld a, 9 + ld [w2DMenuCursorInitY], a + ld a, 6 + ld [w2DMenuCursorInitX], a + ld a, 1 + ld [wMenuCursorX], a + ln a, 1, 0 + ld [w2DMenuCursorOffsets], a + ld a, MENU_UNUSED_3 + ld [w2DMenuFlags1], a + xor a + ld [w2DMenuFlags2], a + +LinkTradeOTPartymonMenuLoop: + call ScrollingMenuJoypad + and a + jp z, LinkTradePartiesMenuMasterLoop + bit A_BUTTON_F, a + jr z, .not_a_button + ld a, INIT_ENEMYOT_LIST + ld [wInitListType], a + callfar InitList + ld hl, wOTPartyMon1Species + call LinkMonStatsScreen + jp LinkTradePartiesMenuMasterLoop + +.not_a_button + bit D_UP_F, a + jr z, .not_d_up + ld a, [wMenuCursorY] + ld b, a + ld a, [wOTPartyCount] + cp b + jp nz, LinkTradePartiesMenuMasterLoop + xor a + ld [wMonType], a + call HideCursor + ld a, [wPartyCount] + ld [wMenuCursorY], a + jr LinkTrade_PlayerPartyMenu + +.not_d_up + bit D_DOWN_F, a + jp z, LinkTradePartiesMenuMasterLoop + jp Function28ac9 + +LinkTrade_PlayerPartyMenu: + xor a + ld [wMonType], a + ld a, A_BUTTON | D_UP | D_DOWN + ld [wMenuJoypadFilter], a + ld a, [wPartyCount] + ld [w2DMenuNumRows], a + ld a, 1 + ld [w2DMenuNumCols], a + ld a, 1 + ld [w2DMenuCursorInitY], a + ld a, 6 + ld [w2DMenuCursorInitX], a + ld a, 1 + ld [wMenuCursorX], a + ln a, 1, 0 + ld [w2DMenuCursorOffsets], a + ld a, MENU_UNUSED_3 + ld [w2DMenuFlags1], a + xor a + ld [w2DMenuFlags2], a + +LinkTradePartymonMenuLoop: + call ScrollingMenuJoypad + and a + jr nz, .check_joypad + jp LinkTradePartiesMenuMasterLoop + +.check_joypad + bit A_BUTTON_F, a + jr z, .not_a_button + jp Function28926 + +.not_a_button + bit D_DOWN_F, a + jr z, .not_d_down + ld a, [wMenuCursorY] + dec a + jp nz, LinkTradePartiesMenuMasterLoop + ld a, OTPARTYMON + ld [wMonType], a + call HideCursor + ld a, 1 + ld [wMenuCursorY], a + jp LinkTrade_OTPartyMenu + +.not_d_down + bit D_UP_F, a + jr z, LinkTradePartiesMenuMasterLoop + ld a, [wMenuCursorY] + ld b, a + ld a, [wPartyCount] + cp b + jr nz, LinkTradePartiesMenuMasterLoop + call HideCursor + ld a, 1 + ld [wMenuCursorY], a + jp LinkTrade_PlayerPartyMenu + +LinkTradePartiesMenuMasterLoop: + ld a, [wMonType] + and a + jp z, LinkTradePartymonMenuLoop ; PARTYMON + jp LinkTradeOTPartymonMenuLoop ; OTPARTYMON + +Function28926: + call HideCursor + call LoadTilemapToTempTilemap + call PlaceHollowCursor + ld a, [wMenuCursorY] + push af + hlcoord 0, 15 + ld b, 1 + ld c, 18 + call LinkTextboxAtHL + hlcoord 2, 16 + ld de, .String_Stats_Trade + call PlaceString + +.joy_loop + ld a, " " + ldcoord_a 11, 16 + ld a, A_BUTTON | B_BUTTON | D_RIGHT + ld [wMenuJoypadFilter], a + ld a, 1 + ld [w2DMenuNumRows], a + ld a, 1 + ld [w2DMenuNumCols], a + ld a, 16 + ld [w2DMenuCursorInitY], a + ld a, 1 + ld [w2DMenuCursorInitX], a + ld a, 1 + ld [wMenuCursorY], a + ld [wMenuCursorX], a + ln a, 2, 0 + ld [w2DMenuCursorOffsets], a + xor a + ld [w2DMenuFlags1], a + ld [w2DMenuFlags2], a + call ScrollingMenuJoypad + bit D_RIGHT_F, a + jr nz, .d_right + bit B_BUTTON_F, a + jr z, .show_stats +.b_button + pop af + ld [wMenuCursorY], a + call SafeLoadTempTilemapToTilemap + jp LinkTrade_PlayerPartyMenu + +.d_right + ld a, " " + ldcoord_a 1, 16 + ld a, A_BUTTON | B_BUTTON | D_LEFT + ld [wMenuJoypadFilter], a + ld a, 1 + ld [w2DMenuNumRows], a + ld a, 1 + ld [w2DMenuNumCols], a + ld a, 16 + ld [w2DMenuCursorInitY], a + ld a, 11 + ld [w2DMenuCursorInitX], a + ld a, 1 + ld [wMenuCursorY], a + ld [wMenuCursorX], a + ln a, 2, 0 + ld [w2DMenuCursorOffsets], a + xor a + ld [w2DMenuFlags1], a + ld [w2DMenuFlags2], a + call ScrollingMenuJoypad + bit D_LEFT_F, a + jp nz, .joy_loop + bit B_BUTTON_F, a + jr nz, .b_button + jr .try_trade + +.show_stats + pop af + ld [wMenuCursorY], a + ld a, INIT_PLAYEROT_LIST + ld [wInitListType], a + callfar InitList + call LinkMonStatsScreen + call SafeLoadTempTilemapToTilemap + jp LinkTrade_PlayerPartyMenu + +.try_trade + call PlaceHollowCursor + pop af + ld [wMenuCursorY], a + dec a + ld [wceed], a + ld [wPlayerLinkAction], a + call Serial_PrintWaitingTextAndSyncAndExchangeNybble + ld a, [wOtherPlayerLinkMode] + cp $f + jp z, InitTradeMenuDisplay + ld [wceee], a + call Function28a3c + ld c, 100 + call DelayFrames + farcall ValidateOTTrademon + jr c, .abnormal + farcall Functionfb6ed + jp nc, LinkTrade + xor a + ld [wce57], a + ld [wOtherPlayerLinkAction], a + hlcoord 0, 12 + ld b, 4 + ld c, 18 + call LinkTextboxAtHL + ld hl, .LinkTradeCantBattleText + bccoord 1, 14 + call PlaceHLTextAtBC + jr .cancel_trade + +.abnormal + xor a + ld [wce57], a + ld [wOtherPlayerLinkAction], a + ld a, [wceee] + ld hl, wOTPartySpecies + ld c, a + ld b, 0 + add hl, bc + ld a, [hl] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + hlcoord 0, 12 + ld b, 4 + ld c, 18 + call LinkTextboxAtHL + ld hl, .LinkAbnormalMonText + bccoord 1, 14 + call PlaceHLTextAtBC + +.cancel_trade + hlcoord 0, 12 + ld b, 4 + ld c, 18 + call LinkTextboxAtHL + hlcoord 1, 14 + ld de, String_TooBadTheTradeWasCanceled + call PlaceString + ld a, $1 + ld [wPlayerLinkAction], a + call Serial_PrintWaitingTextAndSyncAndExchangeNybble + ld c, 100 + call DelayFrames + jp InitTradeMenuDisplay + +.LinkTradeCantBattleText: + text_far _LinkTradeCantBattleText + text_end + +.String_Stats_Trade: + db "STATS TRADE@" + +.LinkAbnormalMonText: + text_far _LinkAbnormalMonText + text_end + +Function28ac9: + ld a, [wMenuCursorY] + cp 1 + jp nz, LinkTradePartiesMenuMasterLoop + call HideCursor +Function28ade: +.loop1 + ld a, "▶" + ldcoord_a 1, 16 +.loop2 + call JoyTextDelay + ldh a, [hJoyLast] + and a + jr z, .loop2 + bit A_BUTTON_F, a + jr nz, .a_button + bit D_UP_F, a + jr z, .loop2 + ld a, " " + ldcoord_a 1, 16 + ld a, [wOTPartyCount] + ld [wMenuCursorY], a + jp LinkTrade_OTPartyMenu + +.a_button + ld a, "▷" + ldcoord_a 1, 16 + ld a, $f + ld [wPlayerLinkAction], a + call Serial_PrintWaitingTextAndSyncAndExchangeNybble + ld a, [wOtherPlayerLinkMode] + cp $f + jr nz, .loop1 +Function28b22: + xor a + ld [wd8b7], a + xor a + ldh [rSB], a + ldh [hSerialSend], a + ld a, (0 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + ld a, (1 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + ret + +Function28a16: + hlcoord 0, 16 + ld a, "┘" + ld bc, 2 * SCREEN_WIDTH + call ByteFill + hlcoord 1, 16 + ld a, " " + ld bc, SCREEN_WIDTH - 2 + call ByteFill + hlcoord 2, 16 + ld de, .Cancel + jp PlaceString + +.Cancel: + db "CANCEL@" + +Function28a3c: + ld a, [wOtherPlayerLinkMode] + hlcoord 6, 9 + ld bc, SCREEN_WIDTH + call AddNTimes + ld [hl], "▷" + ret + +LinkMonStatsScreen: + ld a, [wMenuCursorY] + dec a + ld [wCurPartyMon], a + call LowVolume + predef StatsScreenInit + ld a, [wCurPartyMon] + inc a + ld [wMenuCursorY], a + call ClearTilemap + call ClearBGPalettes + call MaxVolume + call LoadTradeScreenBorder + call SetTradeRoomBGPals + call WaitBGMap + call Function28dcf + jp Function28a16 + +LinkTrade: + xor a + ld [wce57], a + ld [wOtherPlayerLinkAction], a + hlcoord 0, 12 + ld b, 4 + ld c, 18 + call LinkTextboxAtHL + ld a, [wceed] + ld hl, wPartySpecies + ld c, a + ld b, 0 + add hl, bc + ld a, [hl] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld hl, wStringBuffer1 + ld de, wceef + ld bc, MON_NAME_LENGTH + call CopyBytes + ld a, [wceee] + ld hl, wOTPartySpecies + ld c, a + ld b, 0 + add hl, bc + ld a, [hl] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld hl, LinkAskTradeForText + bccoord 1, 14 + call PlaceHLTextAtBC + call LoadTilemapToTempTilemap + hlcoord 10, 7 + ld b, 3 + ld c, 7 + call LinkTextboxAtHL + ld de, String28eab + hlcoord 12, 8 + call PlaceString + ld a, 8 + ld [w2DMenuCursorInitY], a + ld a, 11 + ld [w2DMenuCursorInitX], a + ld a, 1 + ld [w2DMenuNumCols], a + ld a, 2 + ld [w2DMenuNumRows], a + xor a + ld [w2DMenuFlags1], a + ld [w2DMenuFlags2], a + ld a, $20 + ld [w2DMenuCursorOffsets], a + ld a, A_BUTTON | B_BUTTON + ld [wMenuJoypadFilter], a + ld a, 1 + ld [wMenuCursorY], a + ld [wMenuCursorX], a + call ScrollingMenuJoypad + push af + call SafeLoadTempTilemapToTilemap + pop af + bit 1, a + jr nz, .asm_28c33 + ld a, [wMenuCursorY] + dec a + jr z, .asm_28c54 + +.asm_28c33 + ld a, $1 + ld [wPlayerLinkAction], a + hlcoord 0, 12 + ld b, 4 + ld c, 18 + call LinkTextboxAtHL + hlcoord 1, 14 + ld de, String_TooBadTheTradeWasCanceled + call PlaceString + call Serial_PrintWaitingTextAndSyncAndExchangeNybble + jp Function28ea3 + +.asm_28c54 + ld a, $2 + ld [wPlayerLinkAction], a + call Serial_PrintWaitingTextAndSyncAndExchangeNybble + ld a, [wOtherPlayerLinkMode] + dec a + jr nz, .asm_28c7b + hlcoord 0, 12 + ld b, 4 + ld c, 18 + call LinkTextboxAtHL + hlcoord 1, 14 + ld de, String_TooBadTheTradeWasCanceled + call PlaceString + jp Function28ea3 + +.asm_28c7b + ld hl, sPartyMail + ld a, [wceed] + ld bc, MAIL_STRUCT_LENGTH + call AddNTimes + ld a, BANK(sPartyMail) + call OpenSRAM + ld d, h + ld e, l + ld bc, MAIL_STRUCT_LENGTH + add hl, bc + ld a, [wceed] + ld c, a +.asm_28c96 + inc c + ld a, c + cp PARTY_LENGTH + jr z, .asm_28ca6 + push bc + ld bc, MAIL_STRUCT_LENGTH + call CopyBytes + pop bc + jr .asm_28c96 + +.asm_28ca6 + ld hl, sPartyMail + ld a, [wPartyCount] + dec a + ld bc, MAIL_STRUCT_LENGTH + call AddNTimes + push hl + ld hl, wc8f4 + ld a, [wceee] + ld bc, MAIL_STRUCT_LENGTH + call AddNTimes + pop de + ld bc, MAIL_STRUCT_LENGTH + call CopyBytes + call CloseSRAM + ld hl, wPlayerName + ld de, wPlayerTrademonSenderName + ld bc, NAME_LENGTH + call CopyBytes + ld a, [wceed] + ld hl, wPartySpecies + ld b, 0 + ld c, a + add hl, bc + ld a, [hl] + ld [wPlayerTrademonSpecies], a + push af + ld a, [wceed] + ld hl, wPartyMonOT + call SkipNames + ld de, wPlayerTrademonOTName + ld bc, NAME_LENGTH + call CopyBytes + ld hl, wPartyMon1ID + ld a, [wceed] + call GetPartyLocation + ld a, [hli] + ld [wPlayerTrademonID], a + ld a, [hl] + ld [wPlayerTrademonID + 1], a + ld hl, wPartyMon1DVs + ld a, [wceed] + call GetPartyLocation + ld a, [hli] + ld [wPlayerTrademonDVs], a + ld a, [hl] + ld [wPlayerTrademonDVs + 1], a + ld hl, wOTPlayerName + ld de, wOTTrademonSenderName + ld bc, NAME_LENGTH + call CopyBytes + ld a, [wceee] + ld hl, wOTPartySpecies + ld b, 0 + ld c, a + add hl, bc + ld a, [hl] + ld [wOTTrademonSpecies], a + ld a, [wceee] + ld hl, wOTPartyMonOT + call SkipNames + ld de, wOTTrademonOTName + ld bc, NAME_LENGTH + call CopyBytes + ld hl, wOTPartyMon1ID + ld a, [wceee] + call GetPartyLocation + ld a, [hli] + ld [wOTTrademonID], a + ld a, [hl] + ld [wOTTrademonID + 1], a + ld hl, wOTPartyMon1DVs + ld a, [wceee] + call GetPartyLocation + ld a, [hli] + ld [wOTTrademonDVs], a + ld a, [hl] + ld [wOTTrademonDVs + 1], a + ld a, [wceed] + ld [wCurPartyMon], a + ld hl, wPartySpecies + ld b, 0 + ld c, a + add hl, bc + ld a, [hl] + ld [wceed], a + xor a ; REMOVE_PARTY + ld [wPokemonWithdrawDepositParameter], a + callfar RemoveMonFromPartyOrBox + ld a, [wPartyCount] + dec a + ld [wCurPartyMon], a + ld a, TRUE + ld [wForceEvolution], a + ld a, [wceee] + push af + ld hl, wOTPartySpecies + ld b, 0 + ld c, a + add hl, bc + ld a, [hl] + ld [wceee], a + ld c, 100 + call DelayFrames + call ClearTilemap + call LoadFontsBattleExtra + ldh a, [hSerialConnectionStatus] + cp USING_EXTERNAL_CLOCK + jr z, .player_2 + predef TradeAnimation + jr .done_animation + +.player_2 + predef TradeAnimationPlayer2 + +.done_animation + pop af + ld c, a + ld [wCurPartyMon], a + ld hl, wOTPartySpecies + ld d, 0 + ld e, a + add hl, de + ld a, [hl] + ld [wCurPartySpecies], a + ld hl, wOTPartyMon1Species + ld a, c + call GetPartyLocation + ld de, wTempMonSpecies + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + predef AddTempmonToParty + ld a, [wPartyCount] + dec a + ld [wCurPartyMon], a + callfar EvolvePokemon + call ClearTilemap + call LoadTradeScreenBorder + call SetTradeRoomBGPals + call WaitBGMap + ld b, $1 + pop af + ld c, a + cp MEW + jr z, .loop + ld a, [wCurPartySpecies] + cp MEW + jr z, .loop + ld b, $2 + ld a, c + cp CELEBI + jr z, .loop + ld a, [wCurPartySpecies] + cp CELEBI + jr z, .loop + ld b, $0 + +.loop + ld a, b + ld [wPlayerLinkAction], a + push bc + call Serial_PrintWaitingTextAndSyncAndExchangeNybble + pop bc + ld a, [wLinkMode] + cp LINK_TIMECAPSULE + jr z, .save + ld a, b + and a + jr z, .save + ld a, [wOtherPlayerLinkAction] + cp b + jr nz, .loop + +.save + farcall SaveAfterLinkTrade + ld c, 40 + call DelayFrames + hlcoord 0, 12 + ld b, 4 + ld c, 18 + call LinkTextboxAtHL + hlcoord 1, 14 + ld de, String28ebd + call PlaceString + ld c, 50 + call DelayFrames + ld a, [wLinkMode] + cp LINK_TIMECAPSULE + jp z, Gen2ToGen1LinkComms + jp Gen2ToGen2LinkComms + +Function28ea3: + ld c, 100 + call DelayFrames + jp InitTradeMenuDisplay + +String28eab: + db "TRADE" + next "CANCEL@" + +LinkAskTradeForText: + text_far _LinkAskTradeForText + text_end + +String28ebd: + db "Trade completed!@" + +String_TooBadTheTradeWasCanceled: + db "Too bad! The trade" + next "was canceled!@" + +LinkTextboxAtHL: + push hl + ld a, $78 + ld [hli], a + inc a + call .PlaceRow + inc a + ld [hl], a + pop hl + ld de, SCREEN_WIDTH + add hl, de +.loop + push hl + ld a, $7b + ld [hli], a + ld a, " " + call .PlaceRow + ld [hl], $77 + pop hl + ld de, SCREEN_WIDTH + add hl, de + dec b + jr nz, .loop + + ld a, $7c + ld [hli], a + ld a, $76 + call .PlaceRow + ld [hl], $7d + ret + +.PlaceRow + ld d, c +.row_loop + ld [hli], a + dec d + jr nz, .row_loop + ret + +LoadTradeScreenBorder: + ld de, LinkCommsBorderGFX + ld hl, vTiles2 tile $76 + lb bc, BANK(LinkCommsBorderGFX), 9 + jp Get2bpp + +SetTradeRoomBGPals: + ld b, SCGB_DIPLOMA + call GetSGBLayout + jp SetPalettes + +Function28dcf: + hlcoord 0, 0 + ld b, 6 + ld c, 18 + call LinkTextboxAtHL + hlcoord 0, 8 + ld b, 6 + ld c, 18 + call LinkTextboxAtHL + farcall PlaceTradePartnerNamesAndParty + ret + +INCLUDE "engine/movie/trade_animation.asm" + +CheckTimeCapsuleCompatibility: +; Checks to see if your party is compatible with the Gen 1 games. +; Returns the following in wScriptVar: +; 0: Party is okay +; 1: At least one Pokémon was introduced in Gen 2 +; 2: At least one Pokémon has a move that was introduced in Gen 2 +; 3: At least one Pokémon is holding mail + +; If any party Pokémon was introduced in the Gen 2 games, don't let it in. + ld hl, wPartySpecies + ld b, PARTY_LENGTH +.loop + ld a, [hli] + cp -1 + jr z, .checkitem + cp JOHTO_POKEMON + jr nc, .mon_too_new + dec b + jr nz, .loop + +; If any party Pokémon is holding mail, don't let it in. +.checkitem + ld a, [wPartyCount] + ld b, a + ld hl, wPartyMon1Item +.itemloop + push hl + push bc + ld d, [hl] + farcall ItemIsMail + pop bc + pop hl + jr c, .mon_has_mail + ld de, PARTYMON_STRUCT_LENGTH + add hl, de + dec b + jr nz, .itemloop + +; If any party Pokémon has a move that was introduced in the Gen 2 games, don't let it in. + ld hl, wPartyMon1Moves + ld a, [wPartyCount] + ld b, a +.move_loop + ld c, NUM_MOVES +.move_next + ld a, [hli] + cp STRUGGLE + 1 + jr nc, .move_too_new + dec c + jr nz, .move_next + ld de, PARTYMON_STRUCT_LENGTH - NUM_MOVES + add hl, de + dec b + jr nz, .move_loop + xor a + jr .done + +.mon_too_new + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld a, $1 + jr .done + +.move_too_new + push bc + ld [wNamedObjectIndexBuffer], a + call GetMoveName + call CopyName1 + pop bc + call Function29c67 + ld a, $2 + jr .done + +.mon_has_mail + call Function29c67 + ld a, $3 + +.done + ld [wScriptVar], a + ret + +Function29c67: + ld a, [wPartyCount] + sub b + ld c, a + inc c + ld b, 0 + ld hl, wPartyCount + add hl, bc + ld a, [hl] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ret + +EnterTimeCapsule: + ld a, $4 + call Link_EnsureSync + ld c, 40 + call DelayFrames + xor a + ldh [hVBlank], a + inc a ; LINK_TIMECAPSULE + ld [wLinkMode], a + ret + +WaitForOtherPlayerToExit: + ld c, 3 + call DelayFrames + ld a, CONNECTION_NOT_ESTABLISHED + ldh [hSerialConnectionStatus], a + xor a + ldh [rSB], a + ldh [hSerialReceive], a + ld a, (0 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + ld a, (1 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + ld c, 3 + call DelayFrames + xor a + ldh [rSB], a + ldh [hSerialReceive], a + ld a, (0 << rSC_ON) | (0 << rSC_CLOCK) + ldh [rSC], a + ld a, (1 << rSC_ON) | (0 << rSC_CLOCK) + ldh [rSC], a + ld c, 3 + call DelayFrames + xor a + ldh [rSB], a + ldh [hSerialReceive], a + ldh [rSC], a + ld c, 3 + call DelayFrames + ld a, CONNECTION_NOT_ESTABLISHED + ldh [hSerialConnectionStatus], a + ld hl, wLinkTimeoutFrames + xor a + ld [hli], a + ld [hl], a + ldh [hVBlank], a + ld [wLinkMode], a + ret + +SetBitsForLinkTradeRequest: + ld a, LINK_TRADECENTER - 1 + ld [wPlayerLinkAction], a + ld [wChosenCableClubRoom], a + ret + +SetBitsForBattleRequest: + ld a, LINK_COLOSSEUM - 1 + ld [wPlayerLinkAction], a + ld [wChosenCableClubRoom], a + ret + +SetBitsForTimeCapsuleRequest: + ld a, $2 + ldh [rSB], a + xor a + ldh [hSerialReceive], a + ld a, (0 << rSC_ON) | (0 << rSC_CLOCK) + ldh [rSC], a + ld a, (1 << rSC_ON) | (0 << rSC_CLOCK) + ldh [rSC], a + xor a ; LINK_TIMECAPSULE - 1 + ld [wPlayerLinkAction], a + ld [wChosenCableClubRoom], a + ret + +WaitForLinkedFriend: + ld a, [wPlayerLinkAction] + and a + jr z, .no_link_action + ld a, $2 + ldh [rSB], a + xor a + ldh [hSerialReceive], a + ld a, (0 << rSC_ON) | (0 << rSC_CLOCK) + ldh [rSC], a + ld a, (1 << rSC_ON) | (0 << rSC_CLOCK) + ldh [rSC], a + call DelayFrame + call DelayFrame + call DelayFrame + +.no_link_action + ld a, $2 + ld [wLinkTimeoutFrames + 1], a + ld a, $ff + ld [wLinkTimeoutFrames], a +.loop + ldh a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr z, .connected + cp USING_EXTERNAL_CLOCK + jr z, .connected + ld a, CONNECTION_NOT_ESTABLISHED + ldh [hSerialConnectionStatus], a + ld a, $2 + ldh [rSB], a + xor a + ldh [hSerialReceive], a + ld a, (0 << rSC_ON) | (0 << rSC_CLOCK) + ldh [rSC], a + ld a, (1 << rSC_ON) | (0 << rSC_CLOCK) + ldh [rSC], a + ld a, [wLinkTimeoutFrames] + dec a + ld [wLinkTimeoutFrames], a + jr nz, .not_done + ld a, [wLinkTimeoutFrames + 1] + dec a + ld [wLinkTimeoutFrames + 1], a + jr z, .done + +.not_done + ld a, $1 + ldh [rSB], a + ld a, (0 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + ld a, (1 << rSC_ON) | (1 << rSC_CLOCK) + ldh [rSC], a + call DelayFrame + jr .loop + +.connected + call LinkDataReceived + call DelayFrame + call LinkDataReceived + ld c, 50 + call DelayFrames + ld a, $1 + ld [wScriptVar], a + ret + +.done + xor a + ld [wScriptVar], a + ret + +CheckLinkTimeout: + ld a, $1 + ld [wPlayerLinkAction], a + ld hl, wLinkTimeoutFrames + ld a, $3 + ld [hli], a + xor a + ld [hl], a + call WaitBGMap + ld a, $2 + ldh [hVBlank], a + call DelayFrame + call DelayFrame + call Link_CheckCommunicationError + xor a + ldh [hVBlank], a + ld a, [wScriptVar] + and a + ret nz + jp Link_ResetSerialRegistersAfterLinkClosure + +Function29dba: + ld a, $5 + ld [wPlayerLinkAction], a + ld hl, wLinkTimeoutFrames + ld a, $3 + ld [hli], a + xor a + ld [hl], a + call WaitBGMap + ld a, $2 + ldh [hVBlank], a + call DelayFrame + call DelayFrame + call Link_CheckCommunicationError + ld a, [wScriptVar] + and a + jr z, .vblank + ld bc, -1 +.wait + dec bc + ld a, b + or c + jr nz, .wait + ld a, [wOtherPlayerLinkMode] + cp $5 + jr nz, .script_var + ld a, $6 + ld [wPlayerLinkAction], a + ld hl, wLinkTimeoutFrames + ld a, $1 + ld [hli], a + ld [hl], $32 + call Link_CheckCommunicationError + ld a, [wOtherPlayerLinkMode] + cp $6 + jr z, .vblank + +.script_var + xor a + ld [wScriptVar], a + ret + +.vblank + xor a + ldh [hVBlank], a + ret + +Link_CheckCommunicationError: + xor a + ldh [hSerialReceivedNewData], a + call WaitLinkTransfer + ld hl, wLinkTimeoutFrames + ld a, [hli] + inc a + jr nz, .load_true + ld a, [hl] + inc a + jr nz, .load_true + ld b, 10 + +.acknowledge_serial +.loop + call DelayFrame + call LinkDataReceived + dec b + jr nz, .loop + + xor a + jr .load_scriptvar + +.load_true + ld a, $1 + +.load_scriptvar + ld [wScriptVar], a + ld hl, wLinkTimeoutFrames + xor a + ld [hli], a + ld [hl], a + ret + +TryQuickSave: + ld a, [wChosenCableClubRoom] + push af + farcall Link_SaveGame + ld a, TRUE + jr nc, .return_result + xor a ; FALSE +.return_result + ld [wScriptVar], a + ld c, 30 + call DelayFrames + pop af + ld [wChosenCableClubRoom], a + ret + +CheckBothSelectedSameRoom: + ld a, [wChosenCableClubRoom] + call Link_EnsureSync + push af + call LinkDataReceived + call DelayFrame + call LinkDataReceived + pop af + ld b, a + ld a, [wChosenCableClubRoom] + cp b + jr nz, .fail + ld a, [wChosenCableClubRoom] + inc a + ld [wLinkMode], a + xor a + ldh [hVBlank], a + ld a, TRUE + ld [wScriptVar], a + ret + +.fail + xor a ; FALSE + ld [wScriptVar], a + ret + +TimeCapsule: + ld a, LINK_TIMECAPSULE + ld [wLinkMode], a + call DisableSpriteUpdates + callfar LinkCommunications + call EnableSpriteUpdates + xor a + ldh [hVBlank], a + ret + +TradeCenter: + ld a, LINK_TRADECENTER + ld [wLinkMode], a + call DisableSpriteUpdates + callfar LinkCommunications + call EnableSpriteUpdates + xor a + ldh [hVBlank], a + ret + +Colosseum: + ld a, LINK_COLOSSEUM + ld [wLinkMode], a + call DisableSpriteUpdates + callfar LinkCommunications + call EnableSpriteUpdates + xor a + ldh [hVBlank], a + ret + +CloseLink: + ld c, 3 + call DelayFrames + jp Link_ResetSerialRegistersAfterLinkClosure + +FailedLinkToPast: + ld c, 40 + call DelayFrames + ld a, $e + jp Link_EnsureSync + +Link_ResetSerialRegistersAfterLinkClosure: + ld c, 3 + call DelayFrames + ld a, CONNECTION_NOT_ESTABLISHED + ldh [hSerialConnectionStatus], a + ld a, $2 + ldh [rSB], a + xor a + ldh [hSerialReceive], a + ldh [rSC], a + ret + +Link_EnsureSync: + add $d0 + ld [wPlayerLinkAction], a + ld [wce57], a + ld a, $2 + ldh [hVBlank], a + call DelayFrame + call DelayFrame +.receive_loop + call Serial_ExchangeLinkMenuSelection + ld a, [wOtherPlayerLinkMode] + ld b, a + and $f0 + cp $d0 + jr z, .done + ld a, [wOtherPlayerLinkAction] + ld b, a + and $f0 + cp $d0 + jr nz, .receive_loop + +.done + xor a + ldh [hVBlank], a + ld a, b + and $f + ret + +CableClubCheckWhichChris: + ldh a, [hSerialConnectionStatus] + cp USING_EXTERNAL_CLOCK + ld a, TRUE + jr z, .yes + dec a ; FALSE + +.yes + ld [wScriptVar], a + ret + +LinkCommsBorderGFX: +INCBIN "gfx/trade/border_tiles.2bpp" + +Unreferenced_Function29fe4: + ld a, BANK(sPartyMail) + call OpenSRAM + ld d, FALSE + ld b, CHECK_FLAG + predef SmallFarFlagAction + call CloseSRAM + ld a, c + and a + ret diff --git a/engine/link/mystery_gift.asm b/engine/link/mystery_gift.asm new file mode 100644 index 00000000..55a35982 --- /dev/null +++ b/engine/link/mystery_gift.asm @@ -0,0 +1,1077 @@ +DoMysteryGift: + call ClearTilemap + call ClearSprites + call WaitBGMap + farcall InitMysteryGiftLayout + hlcoord 3, 8 + ld de, .String_PressAToLink_BToCancel + call PlaceString + call WaitBGMap + farcall PrepMysteryGiftDataToSend + call MysteryGift_ClearTrainerData + ld a, $2 + ld [wc901], a + ld a, $14 + ld [wc902], a + ldh a, [rIE] + push af + + call Function29fc9 + + ld d, a + xor a + ldh [rIF], a + pop af + ldh [rIE], a + push de + call ClearTilemap + call EnableLCD + call WaitBGMap + ld b, SCGB_DIPLOMA + call GetSGBLayout + call SetPalettes + pop de + hlcoord 2, 8 + ld a, d + ld de, .MysteryGiftCanceledText ; Link has been canceled + cp $10 + jp z, .LinkCanceled + cp $6c + jp nz, .CommunicationError + ld a, [wc800] + cp 3 + jr z, .skip_checks + call .CheckAlreadyGotFiveGiftsToday + ld hl, .MysteryGiftFiveADayText ; Only 5 gifts a day + jp nc, .PrintTextAndExit + call .CheckAlreadyGotAGiftFromThatPerson + ld hl, .MysteryGiftOneADayText ; Only one gift a day per person + jp c, .PrintTextAndExit +.skip_checks + ld a, [wMysteryGiftPlayerBackupItem] + and a + jr nz, .GiftWaiting + ld a, [wMysteryGiftPartnerBackupItem] + and a + jr nz, .FriendNotReady + ld a, [wc800] + cp 3 + jr z, .skip_append_save + call .AddMysteryGiftPartnerID + ld a, [wc800] + cp 4 + jr z, .skip_append_save + call .SaveMysteryGiftTrainerName +.skip_append_save + ld a, [wMysteryGiftPartnerSentDeco] + and a + jr z, .item + ld a, [wMysteryGiftPartnerWhichDeco] + ld c, a + farcall MysteryGiftGetDecoration + push bc + call MysteryGift_CheckAndSetDecorationAlreadyReceived + pop bc + jr nz, .item + callfar GetDecorationName_c + ld h, d + ld l, e + ld de, wStringBuffer1 + ld bc, ITEM_NAME_LENGTH + call CopyBytes + ld hl, .MysteryGiftSentHomeText ; sent decoration to home + jr .PrintTextAndExit + +.item + call GetMysteryGiftBank + ld a, [wMysteryGiftPartnerWhichItem] + ld c, a + farcall MysteryGiftGetItemHeldEffect + ld a, c + ld [sBackupMysteryGiftItem], a + ld [wNamedObjectIndexBuffer], a + call CloseSRAM + call GetItemName + ld hl, .MysteryGiftSentText ; sent item + jr .PrintTextAndExit + +.LinkCanceled: + ld hl, .MysteryGiftCanceledText ; Link has been canceled + jr .PrintTextAndExit + +.CommunicationError: + ld hl, .MysteryGiftCommErrorText ; Communication error + call PrintText + jp DoMysteryGift + +.GiftWaiting: + ld hl, .RetrieveMysteryGiftText ; receive gift at counter + jr .PrintTextAndExit + +.FriendNotReady: + ld hl, .YourFriendIsNotReadyText ; friend not ready + +.PrintTextAndExit: + call PrintText + ld a, LCDC_DEFAULT + ldh [rLCDC], a + ret + +.String_PressAToLink_BToCancel: + db "Press A to" + next "link IR-Device" + next "Press B to" + next "cancel it." + db "@" + +.MysteryGiftCanceledText: + text_far _MysteryGiftCanceledText + text_end + +.MysteryGiftCommErrorText: + text_far _MysteryGiftCommErrorText + text_end + +.RetrieveMysteryGiftText: + text_far _RetrieveMysteryGiftText + text_end + +.YourFriendIsNotReadyText: + text_far _YourFriendIsNotReadyText + text_end + +.MysteryGiftFiveADayText: + text_far _MysteryGiftFiveADayText + text_end + +.MysteryGiftOneADayText: + text_far _MysteryGiftOneADayText + text_end + +.MysteryGiftSentText: + text_far _MysteryGiftSentText + text_end + +.MysteryGiftSentHomeText: + text_far _MysteryGiftSentHomeText + text_end + +.CheckAlreadyGotFiveGiftsToday: + call GetMysteryGiftBank + ld a, [sNumDailyMysteryGiftPartnerIDs] + cp $5 + jp CloseSRAM + +.CheckAlreadyGotAGiftFromThatPerson: + call GetMysteryGiftBank + ld a, [wMysteryGiftPartnerID] + ld b, a + ld a, [wMysteryGiftPartnerID + 1] + ld c, a + ld a, [sNumDailyMysteryGiftPartnerIDs] + ld d, a + ld hl, sDailyMysteryGiftPartnerIDs +.loop + ld a, d + and a + jr z, .No + ld a, [hli] + cp b + jr nz, .skip + ld a, [hl] + cp c + jr z, .Yes +.skip + inc hl + dec d + jr .loop +.Yes: + scf +.No: + jp CloseSRAM + +.AddMysteryGiftPartnerID: + call GetMysteryGiftBank + ld hl, sNumDailyMysteryGiftPartnerIDs + ld a, [hl] + inc [hl] + ld hl, sDailyMysteryGiftPartnerIDs ; inc hl + ld e, a + ld d, $0 + add hl, de + add hl, de + ld a, [wMysteryGiftPartnerID] + ld [hli], a + ld a, [wMysteryGiftPartnerID + 1] + ld [hl], a + jp CloseSRAM + +.SaveMysteryGiftTrainerName: + call GetMysteryGiftBank + ld a, $1 + ld [sMysteryGiftTrainerHouseFlag], a + ld hl, wMysteryGiftPartnerName + ld de, sMysteryGiftPartnerName + ld bc, NAME_LENGTH + call CopyBytes + ld a, $1 + ld [de], a + inc de + ld hl, wMysteryGiftTrainerData + ld bc, (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2 + call CopyBytes + jp CloseSRAM + +Function29fc9: + farcall ClearChannels + call Function2a18c + +.loop2 + call Function2a1c4 + call Function2a20b + ldh a, [hMGStatusFlags] + cp $10 + jp z, Function2a103 + cp $6c + jr nz, .loop2 + + ldh a, [hPrintNumBuffer + 8] + cp $2 + jr z, Function2a055 + ld hl, hPrintNumBuffer + ld b, $1 + call Function2a184 + jr nz, .ly_loop + call Function2a07c + jp nz, Function2a103 + jr Function2a03d + ; Delay frame +.ly_loop + ldh a, [rLY] + cp LY_VBLANK + jr c, .ly_loop + ld c, LOW(rRP) + ld a, $c0 + ldh [c], a + ld b, 240 ; This might have been intended as a 4-second timeout buffer. + ; However, it is reset with each frame. +.loop3 + push bc + call MysteryGift_ReadJoypad + + ld b, $2 + ld c, LOW(rRP) + ; Delay frame +.ly_loop2 + ldh a, [c] + and b + ld b, a + ldh a, [rLY] + cp LY_VBLANK + jr nc, .ly_loop2 +.ly_loop3 + ldh a, [c] + and b + ld b, a + ldh a, [rLY] + cp LY_VBLANK + jr c, .ly_loop3 + + ld a, b + pop bc + dec b + jr z, .loop2 ; we never jump here + or a + jr nz, .loop2 + ; Check if we've pressed the B button + ldh a, [hMGJoypadReleased] + bit B_BUTTON_F, a + jr z, .loop3 + ld a, $10 + ldh [hMGStatusFlags], a + jp Function2a103 + +Function2a037: + call Function2a073 + jp nz, Function2a103 +; fall through +Function2a03d: + call Function2a166 + jp nz, Function2a103 + call Function2a0bb + jp nz, Function2a103 + call Function2a171 + jp nz, Function2a103 + call Function2a461 + jp Function2a103 + +Function2a055: + call Function2a0bb + jp nz, Function2a103 + call Function2a171 + jp nz, Function2a103 + call Function2a073 + jp nz, Function2a103 + call Function2a166 + jp nz, Function2a103 + call Function2a45c + jp Function2a103 + +Function2a073: + ld hl, hPrintNumBuffer + ld b, $1 + call Function2a184 + ret nz +; fall through +Function2a07c: + call Function2a461 + ldh a, [hMGStatusFlags] + cp $6c + ret nz + ldh a, [hPrintNumBuffer] + cp $96 + jp nz, Function2a160 + ld a, $90 + ldh [hPrintNumBuffer], a + call Function2a166 + ret nz + ld hl, hPrintNumBuffer + ld b, $1 + call Function2a17c + ret nz + call Function2a45c + ldh a, [hMGStatusFlags] + cp $6c + ret nz + call Function2a171 + ret nz + ld hl, wMysteryGiftTrainerData + ld a, [wc902] + ld b, a + call Function2a184 + ret nz + call Function2a461 + ldh a, [hMGStatusFlags] + cp $6c + ret + +Function2a0bb: + ld a, $96 + ldh [hPrintNumBuffer], a + ld hl, hPrintNumBuffer + ld b, $1 + call Function2a17c + ret nz + call Function2a45c + ldh a, [hMGStatusFlags] + cp $6c + ret nz + call Function2a171 + ret nz + ld hl, hPrintNumBuffer + ld b, $1 + call Function2a184 + ret nz + call Function2a461 + ldh a, [hMGStatusFlags] + cp $6c + ret nz + ldh a, [hPrintNumBuffer] + cp $90 + jp nz, Function2a160 + call Function2a166 + ret nz + ld hl, wLinkData + ld a, [wc902] + ld b, a + call Function2a17c + ret nz + call Function2a45c + ldh a, [hMGStatusFlags] + cp $6c + ret + +Function2a103: + nop + ldh a, [hMGStatusFlags] + cp $10 + jr z, .quit + cp $6c + jr nz, .quit + ld hl, wc901 + dec [hl] + jr z, .quit + ld hl, wMysteryGiftTrainerData + ld de, wMysteryGiftPartnerData + ld bc, wMysteryGiftPartnerDataEnd - wMysteryGiftPartnerData + call CopyBytes + ld a, [wMysteryGiftTrainerData] + cp $3 + jr nc, .quit + farcall StagePartyDataForMysteryGift + call MysteryGift_ClearTrainerData + ld a, $26 + ld [wc902], a + ldh a, [hPrintNumBuffer + 8] + cp $2 + jr z, .asm_2a143 + call Function2a171 + jr nz, Function2a103 + jp Function2a037 + +.asm_2a143 + call Function2a166 + jr nz, Function2a103 + jp Function2a055 + +.quit: + xor a + ldh [rIF], a + ldh a, [rIE] + or 1 << VBLANK + ldh [rIE], a + ei + call DelayFrame + ldh a, [hMGStatusFlags] + push af + call Function2a1ce + pop af + ret + +Function2a160: + ld a, $80 + ldh [hMGStatusFlags], a + and a + ret + +Function2a166: + call Function2a1c4 + call Function2a274 + ldh a, [hMGStatusFlags] + cp $6c + ret + +Function2a171: + call Function2a1c4 + call Function2a22c + ldh a, [hMGStatusFlags] + cp $6c + ret + +Function2a17c: + call Function2a2c1 + ldh a, [hMGStatusFlags] + cp $6c + ret + +Function2a184: + call Function2a385 + ldh a, [hMGStatusFlags] + cp $6c + ret + +Function2a18c: + call Function2a1a2 + ld a, 1 << TIMER + ldh [rIE], a + xor a + ldh [rIF], a + call Function2a1c4 + xor a + ld b, a +.asm_2a19b + inc a + jr nz, .asm_2a19b + inc b + jr nz, .asm_2a19b + ret + +Function2a1a2: + xor a + ldh [rTAC], a + ld a, $fe + ldh [rTMA], a + ldh [rTIMA], a + ld a, $2 + ldh [rTAC], a + or $4 + ldh [rTAC], a + ret + +Function2a1b4: + xor a + ldh [rTAC], a + ldh [rTMA], a + ldh [rTIMA], a + ld a, $2 + ldh [rTAC], a + or $4 + ldh [rTAC], a + ret + +Function2a1c4: + ld a, $c0 + call Function2a2ba + ld a, $1 + ldh [hPrintNumBuffer + 8], a + ret + +Function2a1ce: + xor a + call Function2a2ba + ld a, $2 + ldh [rTAC], a + ret + +Function2a1d7: + inc d + ret z + xor a + ldh [rIF], a + halt + ldh a, [c] + bit 1, a + jr z, Function2a1d7 + or a + ret + +Function2a1e5: + inc d + ret z + xor a + ldh [rIF], a + halt + ldh a, [c] + bit 1, a + jr nz, Function2a1e5 + or a + ret + +Function2a1f3: + ld a, $c1 + ldh [c], a +.wait + dec d + ret z + xor a + ldh [rIF], a + halt + jr .wait + +Function2a1ff: + ld a, $c0 + ldh [c], a +.wait + dec d + ret z + xor a + ldh [rIF], a + halt + jr .wait + +Function2a20b: + ld d, $0 + ld e, d + ld a, $1 + ldh [hPrintNumBuffer + 8], a +.loop + call MysteryGift_ReadJoypad + ld b, $2 + ld c, LOW(rRP) + ldh a, [hMGJoypadReleased] + bit B_BUTTON_F, a + jr z, .next + ld a, $10 + ldh [hMGStatusFlags], a + ret + +.next + bit 0, a + jr nz, Function2a268 + ldh a, [c] + and b + jr nz, .loop + +Function2a22c: + ld c, LOW(rRP) + ld d, $0 + ld e, d + call Function2a1e5 + jp z, Function2a370 + ld d, e + call Function2a1d7 + jp z, Function2a370 + call Function2a1e5 + jp z, Function2a370 + call Function2a1d7 + jp z, Function2a370 + ld a, $6c + ldh [hMGStatusFlags], a + ld d, $3d + call Function2a1ff + ld d, $5 + call Function2a1f3 + ld d, $15 + call Function2a1ff + ld d, $5 + call Function2a1f3 + ld d, $5 + call Function2a1ff + ret + +Function2a268: + ; Wait a random amount of time + call Random + ld e, a + and $f + ld d, a +.loop + dec de + ld a, d + or e + jr nz, .loop +Function2a274: + ld a, $2 + ldh [hPrintNumBuffer + 8], a + ld c, LOW(rRP) + ld d, $0 + ld e, d + ld d, $3d + call Function2a1ff + ld d, $5 + call Function2a1f3 + ld d, $15 + call Function2a1ff + ld d, $5 + call Function2a1f3 + ld d, $5 + call Function2a1ff + ld d, e + call Function2a1e5 + jp z, Function2a370 + ld d, e + call Function2a1d7 + jp z, Function2a370 + call Function2a1e5 + jp z, Function2a370 + call Function2a1d7 + jp z, Function2a370 + ld d, $3d + call Function2a1ff + ld a, $6c + ldh [hMGStatusFlags], a + ret + +Function2a2ba: + ldh [rRP], a + ld a, $ff + ldh [hMGStatusFlags], a + ret + +Function2a2c1: + xor a + ldh [hPrintNumBuffer + 4], a + ldh [hPrintNumBuffer + 5], a + push hl + push bc + ld c, LOW(rRP) + ld d, $3d + call Function2a1ff + ld hl, hPrintNumBuffer + 1 + ld a, $5a + ld [hli], a + ld [hl], b + dec hl + ld b, $2 + call Function2a304 + pop bc + pop hl + call Function2a304 + ldh a, [hPrintNumBuffer + 4] + ldh [hPrintNumBuffer + 1], a + ldh a, [hPrintNumBuffer + 5] + ldh [hPrintNumBuffer + 2], a + push hl + ld hl, hPrintNumBuffer + 1 + ld b, $2 + call Function2a304 + ld hl, hMGStatusFlags + ld b, $1 + call Function2a3dd + ldh a, [hPrintNumBuffer + 1] + ldh [hPrintNumBuffer + 4], a + ldh a, [hPrintNumBuffer + 2] + ldh [hPrintNumBuffer + 5], a + pop hl + ret + +Function2a304: + ld c, LOW(rRP) + ld d, $5 + call Function2a1ff + ld d, $5 + call Function2a1f3 + ld d, $15 + call Function2a1ff + ld a, b + cpl + ld b, a + ld a, $f4 + ldh [rTMA], a +.asm_2a31c + inc b + jr z, .asm_2a35c + ld a, $8 + ldh [hPrintNumBuffer + 3], a + ld a, [hli] + ld e, a + ldh a, [hPrintNumBuffer + 4] + add e + ldh [hPrintNumBuffer + 4], a + ldh a, [hPrintNumBuffer + 5] + adc 0 + ldh [hPrintNumBuffer + 5], a +.asm_2a330 + xor a + ldh [rIF], a + halt + ld a, $c1 + ldh [rRP], a + ld d, $1 + ld a, e + rlca + ld e, a + jr nc, .asm_2a341 + inc d +.asm_2a341 + ldh a, [rTIMA] + cp $f8 + jr c, .asm_2a341 + ld a, $c0 + ldh [rRP], a + dec d + jr z, .asm_2a353 + xor a + ldh [rIF], a + halt +.asm_2a353 + ldh a, [hPrintNumBuffer + 3] + dec a + jr z, .asm_2a31c + ldh [hPrintNumBuffer + 3], a + jr .asm_2a330 +.asm_2a35c + ld a, $fe + ldh [rTMA], a + xor a + ldh [rIF], a + halt + ld d, $5 + call Function2a1f3 + ld d, $11 + call Function2a1ff + ret + +Function2a370: + ldh a, [hMGStatusFlags] + or $2 + ldh [hMGStatusFlags], a + ret + +Function2a377: + ldh a, [hMGStatusFlags] + or $1 + ldh [hMGStatusFlags], a + ret + +Function2a37e: + ldh a, [hMGStatusFlags] + or $80 + ldh [hMGStatusFlags], a + ret + +Function2a385: + xor a + ldh [hPrintNumBuffer + 4], a + ldh [hPrintNumBuffer + 5], a + push bc + push hl + ld hl, hPrintNumBuffer + 1 + ld b, $2 + call Function2a3dd + ldh a, [hPrintNumBuffer + 2] + ldh [hPrintNumBuffer + 7], a + ld b, a + pop hl + pop af + cp b + jp c, Function2a37e + ldh a, [hPrintNumBuffer + 1] + cp $5a + jp nz, Function2a37e + call Function2a3dd + ldh a, [hPrintNumBuffer + 4] + ld d, a + ldh a, [hPrintNumBuffer + 5] + ld e, a + push hl + push de + ld hl, hPrintNumBuffer + 1 + ld b, $2 + call Function2a3dd + pop de + ld hl, hPrintNumBuffer + 1 + ld a, [hli] + xor d + ld b, a + ld a, [hl] + xor e + or b + call nz, Function2a377 + push de + ld d, $3d + call Function2a1ff + ld hl, hMGStatusFlags + ld b, $1 + call Function2a304 + pop de + pop hl + ld a, d + ldh [hPrintNumBuffer + 4], a + ld a, e + ldh [hPrintNumBuffer + 5], a + ret + +Function2a3dd: + ld c, LOW(rRP) + ld d, $0 + call Function2a1e5 + jp z, Function2a370 + ld d, $0 + call Function2a1d7 + jp z, Function2a370 + ld d, $0 + call Function2a1e5 + jp z, Function2a370 + ld a, b + cpl + ld b, a + xor a + ldh [hMGPrevTIMA], a + call Function2a1b4 +.asm_2a400 + inc b + jr z, .asm_2a448 + ld a, $8 + ldh [hPrintNumBuffer + 3], a +.asm_2a407 + ld d, $0 +.asm_2a409 + inc d + jr z, .asm_2a413 + ldh a, [c] + bit 1, a + jr z, .asm_2a409 + ld d, $0 +.asm_2a413 + inc d + jr z, .asm_2a41b + ldh a, [c] + bit 1, a + jr nz, .asm_2a413 +.asm_2a41b + ldh a, [hMGPrevTIMA] + ld d, a + ldh a, [rTIMA] + ldh [hMGPrevTIMA], a + sub d + cp $12 + jr c, .asm_2a42b + set 0, e + jr .asm_2a42d +.asm_2a42b + res 0, e +.asm_2a42d + ldh a, [hPrintNumBuffer + 3] + dec a + ldh [hPrintNumBuffer + 3], a + jr z, .asm_2a439 + ld a, e + rlca + ld e, a + jr .asm_2a407 +.asm_2a439 + ld a, e + ld [hli], a + ldh a, [hPrintNumBuffer + 4] + add e + ldh [hPrintNumBuffer + 4], a + ldh a, [hPrintNumBuffer + 5] + adc 0 + ldh [hPrintNumBuffer + 5], a + jr .asm_2a400 +.asm_2a448 + call Function2a1a2 + xor a + ldh [rIF], a + ld d, $0 + call Function2a1d7 + jp z, Function2a370 + ld d, $10 + call Function2a1ff + ret + +Function2a45c: + ld b, $0 + jp Function2a2c1 + +Function2a461: + ld b, $0 + jp Function2a385 + +MysteryGift_ReadJoypad: +; We can only get four inputs at a time. +; We take d-pad first for no particular reason. + ld a, R_DPAD + ldh [rJOYP], a +; Read twice to give the request time to take. + ldh a, [rJOYP] + ldh a, [rJOYP] + +; The Joypad register output is in the lo nybble (inversed). +; We make the hi nybble of our new container d-pad input. + cpl + and $f + swap a + +; We'll keep this in b for now. + ld b, a + +; Buttons make 8 total inputs (A, B, Select, Start). +; We can fit this into one byte. + ld a, R_BUTTONS + ldh [rJOYP], a +; Wait for input to stabilize. +rept 6 + ldh a, [rJOYP] +endr +; Buttons take the lo nybble. + cpl + and $f + or b + ld c, a +; To get the delta we xor the last frame's input with the new one. + ldh a, [hMGJoypadPressed] + xor c +; Released this frame: + and c + ldh [hMGJoypadReleased], a +; Pressed this frame: + ld a, c + ldh [hMGJoypadPressed], a + ld a, $30 +; Reset the joypad register since we're done with it. + ldh [rJOYP], a + ret + +MysteryGift_CheckAndSetDecorationAlreadyReceived: + call GetMysteryGiftBank + ld d, $0 + ld b, CHECK_FLAG + ld hl, sMysteryGiftDecorationsReceived + predef_id SmallFarFlagAction + push hl + push bc + call Predef + call CloseSRAM + ld a, c + and a + pop bc + pop hl + ret nz + call GetMysteryGiftBank + ld b, SET_FLAG + predef SmallFarFlagAction + call CloseSRAM + xor a + ret + +MysteryGift_CopyReceivedDecosToPC: + call GetMysteryGiftBank + ld c, $0 +.loop + push bc + ld d, $0 + ld b, CHECK_FLAG + ld hl, sMysteryGiftDecorationsReceived + predef SmallFarFlagAction + ld a, c + and a + pop bc + jr z, .skip + push bc + callfar SetSpecificDecorationFlag + pop bc +.skip + inc c + ld a, c + cp TrophyIDs - DecorationIDs + jr c, .loop + jp CloseSRAM + +UnlockMysteryGift: + call GetMysteryGiftBank + ld hl, sMysteryGiftUnlocked + ld a, [hl] + inc a + jr nz, .ok + ld [hld], a + ld [hl], a +.ok + jp CloseSRAM + +Function2a4f6: + call GetMysteryGiftBank + ld a, [sNumDailyMysteryGiftPartnerIDs] + cp $ff + jr z, .okay + xor a + ld [sNumDailyMysteryGiftPartnerIDs], a +.okay + jp CloseSRAM + +BackupMysteryGift: + call GetMysteryGiftBank + ld hl, sMysteryGiftItem + ld de, sBackupMysteryGiftItem + ld a, [hli] + ld [de], a + inc de + ld a, [hl] + ld [de], a + jp CloseSRAM + +RestoreMysteryGift: + call GetMysteryGiftBank + ld hl, sBackupMysteryGiftItem + ld de, sMysteryGiftItem + ld a, [hli] + ld [de], a + inc de + ld a, [hl] + ld [de], a + jp CloseSRAM + +MysteryGift_ClearTrainerData: + ld hl, wMysteryGiftTrainerData + xor a + ld b, wMysteryGiftTrainerDataEnd - wMysteryGiftTrainerData +.loop + ld [hli], a + dec b + jr nz, .loop + ret + +GetMysteryGiftBank: + ld a, BANK(sBackupMysteryGiftItem) + jp OpenSRAM diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm index b4092ec7..1cd7e138 100644 --- a/engine/menus/intro_menu.asm +++ b/engine/menus/intro_menu.asm @@ -239,7 +239,7 @@ Function5bf7: ; 5bf7 (1:5bf7) MainMenu_MysteryGift: call UpdateTime farcall DoMysteryGiftIfDayHasPassed - farcall Function29dff + farcall DoMysteryGift ret MainMenu_Options: @@ -1201,7 +1201,7 @@ InitTitleScreen: ; 6291 (1:6291) call CopyBytes ld hl, wSpriteAnim1 ld [hl], $0 - ld hl, wc700 + ld hl, wLYOverrides ld bc, $90 xor a call ByteFill diff --git a/engine/movie/trade_animation.asm b/engine/movie/trade_animation.asm new file mode 100644 index 00000000..410c3c7c --- /dev/null +++ b/engine/movie/trade_animation.asm @@ -0,0 +1,1389 @@ +TRADEANIM_RIGHT_ARROW EQU "▶" ; $ed +TRADEANIM_LEFT_ARROW EQU "▼" ; $ee + +; TradeAnim_TubeAnimJumptable.Jumptable indexes + const_def + const TRADEANIMSTATE_0 ; 0 + const TRADEANIMSTATE_1 ; 1 + const TRADEANIMSTATE_2 ; 2 + const TRADEANIMSTATE_3 ; 3 +TRADEANIMJUMPTABLE_LENGTH EQU const_value + +TradeAnimation: + ld hl, wPlayerTrademonSenderName + ld de, wOTTrademonSenderName + call LinkTradeAnim_LoadTradePlayerNames + ld hl, wPlayerTrademonSpecies + ld de, wOTTrademonSpecies + call LinkTradeAnim_LoadTradeMonSpecies + ld de, .script + jr RunTradeAnimScript + +.script + tradeanim_setup_givemon_scroll + tradeanim_show_givemon_data + tradeanim_do_givemon_scroll + tradeanim_wait_80 + tradeanim_poof + tradeanim_rocking_ball + tradeanim_enter_link_tube + tradeanim_wait_anim + tradeanim_bulge_through_tube + tradeanim_wait_anim + tradeanim_textbox_scroll + tradeanim_give_trademon_sfx + tradeanim_tube_to_ot + tradeanim_sent_to_ot_text + tradeanim_scroll_out_right + + tradeanim_ot_sends_text_1 + tradeanim_ot_bids_farewell + tradeanim_scroll_out_right + tradeanim_get_trademon_sfx + tradeanim_tube_to_player + tradeanim_enter_link_tube + tradeanim_drop_ball + tradeanim_exit_link_tube + tradeanim_wait_anim + tradeanim_show_getmon_data + tradeanim_poof + tradeanim_wait_anim + tradeanim_frontpic_scroll + tradeanim_wait_80 + tradeanim_textbox_scroll + tradeanim_take_care_of_text + tradeanim_scroll_out_right + tradeanim_end + +TradeAnimationPlayer2: + ld hl, wOTTrademonSenderName + ld de, wPlayerTrademonSenderName + call LinkTradeAnim_LoadTradePlayerNames + ld hl, wOTTrademonSpecies + ld de, wPlayerTrademonSpecies + call LinkTradeAnim_LoadTradeMonSpecies + ld de, .script + jr RunTradeAnimScript + +.script + tradeanim_ot_sends_text_2 + tradeanim_ot_bids_farewell + tradeanim_scroll_out_right + tradeanim_get_trademon_sfx + tradeanim_tube_to_ot + tradeanim_enter_link_tube + tradeanim_drop_ball + tradeanim_exit_link_tube + tradeanim_wait_anim + tradeanim_show_getmon_data + tradeanim_poof + tradeanim_wait_anim + tradeanim_frontpic_scroll + tradeanim_wait_80 + tradeanim_textbox_scroll + tradeanim_take_care_of_text + tradeanim_scroll_out_right + + tradeanim_setup_givemon_scroll + tradeanim_show_givemon_data + tradeanim_do_givemon_scroll + tradeanim_wait_80 + tradeanim_poof + tradeanim_rocking_ball + tradeanim_enter_link_tube + tradeanim_wait_anim + tradeanim_bulge_through_tube + tradeanim_wait_anim + tradeanim_textbox_scroll + tradeanim_give_trademon_sfx + tradeanim_tube_to_player + tradeanim_sent_to_ot_text + tradeanim_scroll_out_right + tradeanim_end + +RunTradeAnimScript: + ld hl, wTradeAnimAddress + ld [hl], e + inc hl + ld [hl], d + ldh a, [hMapAnims] + push af + xor a + ldh [hMapAnims], a + ld hl, wVramState + ld a, [hl] + push af + res 0, [hl] + ld hl, wOptions + ld a, [hl] + push af + set NO_TEXT_SCROLL, [hl] + call .TradeAnimLayout + ld de, MUSIC_EVOLUTION + call PlayMusic2 +.anim_loop + call DoTradeAnimation + jr nc, .anim_loop + pop af + ld [wOptions], a + pop af + ld [wVramState], a + pop af + ldh [hMapAnims], a + ret + +.TradeAnimLayout: + xor a + ld [wJumptableIndex], a + call ClearBGPalettes + call ClearSprites + call ClearTilemap + call DisableLCD + call LoadFontsBattleExtra + callfar ClearSpriteAnims + ldh a, [hCGB] + and a + jr z, .NotCGB + ld a, $1 + ldh [rVBK], a + ld hl, vTiles0 + ld bc, sScratch - vTiles0 + xor a + call ByteFill + ld a, $0 + ldh [rVBK], a + +.NotCGB: + hlbgcoord 0, 0 + ld bc, sScratch - vBGMap0 + ld a, " " + call ByteFill + ld hl, TradeGameBoyLZ + ld de, vTiles2 tile $31 + call Decompress + ld hl, TradeArrowRightGFX + ld de, vTiles0 tile TRADEANIM_RIGHT_ARROW + ld bc, 1 tiles + ld a, BANK(TradeArrowRightGFX) + call FarCopyBytes + ld hl, TradeArrowLeftGFX + ld de, vTiles0 tile TRADEANIM_LEFT_ARROW + ld bc, 1 tiles + ld a, BANK(TradeArrowLeftGFX) + call FarCopyBytes + xor a + ldh [hSCX], a + ldh [hSCY], a + ld a, $7 + ldh [hWX], a + ld a, $90 + ldh [hWY], a + call EnableLCD + call LoadTradeBallAndCableGFX + ld a, [wPlayerTrademonSpecies] + ld hl, wPlayerTrademonDVs + ld de, vTiles0 + call TradeAnim_GetFrontpic + ld a, [wOTTrademonSpecies] + ld hl, wOTTrademonDVs + ld de, vTiles0 tile $31 + call TradeAnim_GetFrontpic + ld a, [wPlayerTrademonSpecies] + ld de, wPlayerTrademonSpeciesName + call TradeAnim_GetNickname + ld a, [wOTTrademonSpecies] + ld de, wOTTrademonSpeciesName + call TradeAnim_GetNickname + call TradeAnim_NormalPals + ret + +DoTradeAnimation: + ld a, [wJumptableIndex] + bit 7, a + jr nz, .finished + call .DoTradeAnimCommand + callfar PlaySpriteAnimations + ld hl, wce65 + inc [hl] + call DelayFrame + and a + ret + +.finished + call LoadStandardFont + scf + ret + +.DoTradeAnimCommand: + ld a, [wJumptableIndex] + ld e, a + ld d, 0 + ld hl, .JumpTable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +.JumpTable: +; entries correspond to macros/scripts/trade_anims.asm enumeration + dw TradeAnim_AdvanceScriptPointer ; 00 + dw TradeAnim_ShowGivemonData ; 01 + dw TradeAnim_ShowGetmonData ; 02 + dw TradeAnim_EnterLinkTube1 ; 03 + dw TradeAnim_EnterLinkTube2 ; 04 + dw TradeAnim_ExitLinkTube ; 05 + dw TradeAnim_TubeToOT1 ; 06 + dw TradeAnim_TubeToOT2 ; 07 + dw TradeAnim_TubeToOT3 ; 08 + dw TradeAnim_TubeToOT4 ; 09 + dw TradeAnim_TubeToOT5 ; 0a + dw TradeAnim_TubeToOT6 ; 0b + dw TradeAnim_TubeToOT7 ; 0c + dw TradeAnim_TubeToOT8 ; 0d + dw TradeAnim_TubeToPlayer1 ; 0e + dw TradeAnim_TubeToPlayer2 ; 0f + dw TradeAnim_TubeToPlayer3 ; 10 + dw TradeAnim_TubeToPlayer4 ; 11 + dw TradeAnim_TubeToPlayer5 ; 12 + dw TradeAnim_TubeToPlayer6 ; 13 + dw TradeAnim_TubeToPlayer7 ; 14 + dw TradeAnim_TubeToPlayer8 ; 15 + dw TradeAnim_SentToOTText ; 16 + dw TradeAnim_OTBidsFarewell ; 17 + dw TradeAnim_TakeCareOfText ; 18 + dw TradeAnim_OTSendsText1 ; 19 + dw TradeAnim_OTSendsText2 ; 1a + dw TradeAnim_SetupGivemonScroll ; 1b + dw TradeAnim_DoGivemonScroll ; 1c + dw TradeAnim_FrontpicScrollStart ; 1d + dw TradeAnim_TextboxScrollStart ; 1e + dw TradeAnim_ScrollOutRight ; 1f + dw TradeAnim_ScrollOutRight2 ; 20 + dw TradeAnim_Wait80 ; 21 + dw TradeAnim_RockingBall ; 22 + dw TradeAnim_DropBall ; 23 + dw TradeAnim_WaitAnim ; 24 + dw TradeAnim_Poof ; 25 + dw TradeAnim_BulgeThroughTube ; 26 + dw TradeAnim_GiveTrademonSFX ; 27 + dw TradeAnim_GetTrademonSFX ; 28 + dw TradeAnim_End ; 29 + +TradeAnim_IncrementJumptableIndex: + ld hl, wJumptableIndex + inc [hl] + ret + +TradeAnim_AdvanceScriptPointer: + ld hl, wTradeAnimAddress + ld e, [hl] + inc hl + ld d, [hl] + ld a, [de] + ld [wJumptableIndex], a + inc de + ld [hl], d + dec hl + ld [hl], e + ret + +TradeAnim_End: + ld hl, wJumptableIndex + set 7, [hl] + ret + +TradeAnim_TubeToOT1: + ld a, TRADEANIM_RIGHT_ARROW + call TradeAnim_PlaceTrademonStatsOnTubeAnim + ld a, [wLinkTradeSendmonSpecies] + ld [wTempIconSpecies], a + xor a + depixel 5, 11, 4, 0 + ld b, $0 + jr TradeAnim_InitTubeAnim + +TradeAnim_TubeToPlayer1: + ld a, TRADEANIM_LEFT_ARROW + call TradeAnim_PlaceTrademonStatsOnTubeAnim + ld a, [wLinkTradeGetmonSpecies] + ld [wTempIconSpecies], a + ld a, TRADEANIMSTATE_2 + depixel 9, 18, 4, 4 + ld b, $4 +TradeAnim_InitTubeAnim: + push bc + push de + push bc + push de + + push af + call DisableLCD + callfar ClearSpriteAnims + hlbgcoord 20, 3 + ld bc, 12 + ld a, $60 + call ByteFill + pop af + + call TradeAnim_TubeAnimJumptable + + xor a + ldh [hSCX], a + ld a, $7 + ldh [hWX], a + ld a, $70 + ldh [hWY], a + call EnableLCD + call LoadTradeBubbleGFX + + pop de + ld a, SPRITE_ANIM_INDEX_TRADEMON_ICON + call InitSpriteAnimStruct + + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + pop bc + ld [hl], b + + pop de + ld a, SPRITE_ANIM_INDEX_TRADEMON_BUBBLE + call InitSpriteAnimStruct + + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + pop bc + ld [hl], b + + call WaitBGMap + ld b, SCGB_TRADE_TUBE + call GetSGBLayout + ld a, %11100100 ; 3,2,1,0 + call DmgToCgbBGPals + ld a, %11010000 + call DmgToCgbObjPal0 + + call TradeAnim_IncrementJumptableIndex + ld a, 92 + ld [wFrameCounter], a + ret + +TradeAnim_TubeToOT2: + call TradeAnim_FlashBGPals + ldh a, [hSCX] + add $2 + ldh [hSCX], a + cp $50 + ret nz + ld a, TRADEANIMSTATE_1 + call TradeAnim_TubeAnimJumptable + call TradeAnim_IncrementJumptableIndex + ret + +TradeAnim_TubeToOT3: + call TradeAnim_FlashBGPals + ldh a, [hSCX] + add $2 + ldh [hSCX], a + cp $a0 + ret nz + ld a, TRADEANIMSTATE_2 + call TradeAnim_TubeAnimJumptable + call TradeAnim_IncrementJumptableIndex + ret + +TradeAnim_TubeToOT4: + call TradeAnim_FlashBGPals + ldh a, [hSCX] + add $2 + ldh [hSCX], a + and a + ret nz + call TradeAnim_IncrementJumptableIndex + ret + +TradeAnim_TubeToPlayer3: + call TradeAnim_FlashBGPals + ldh a, [hSCX] + sub $2 + ldh [hSCX], a + cp $b0 + ret nz + ld a, TRADEANIMSTATE_1 + call TradeAnim_TubeAnimJumptable + call TradeAnim_IncrementJumptableIndex + ret + +TradeAnim_TubeToPlayer4: + call TradeAnim_FlashBGPals + ldh a, [hSCX] + sub $2 + ldh [hSCX], a + cp $60 + ret nz + xor a ; TRADEANIMSTATE_0 + call TradeAnim_TubeAnimJumptable + call TradeAnim_IncrementJumptableIndex + ret + +TradeAnim_TubeToPlayer5: + call TradeAnim_FlashBGPals + ldh a, [hSCX] + sub $2 + ldh [hSCX], a + and a + ret nz + call TradeAnim_IncrementJumptableIndex + ret + +TradeAnim_TubeToOT6: +TradeAnim_TubeToPlayer6: + ld a, 128 + ld [wFrameCounter], a + call TradeAnim_IncrementJumptableIndex + ret + +TradeAnim_TubeToOT8: +TradeAnim_TubeToPlayer8: + call ClearBGPalettes + call ClearTilemap + call ClearSprites + call DisableLCD + callfar ClearSpriteAnims + hlbgcoord 0, 0 + ld bc, sScratch - vBGMap0 + ld a, " " + call ByteFill + xor a + ldh [hSCX], a + ld a, $90 + ldh [hWY], a + call EnableLCD + call LoadTradeBallAndCableGFX + call WaitBGMap + call TradeAnim_NormalPals + call TradeAnim_AdvanceScriptPointer + ret + +TradeAnim_TubeToOT5: +TradeAnim_TubeToOT7: +TradeAnim_TubeToPlayer2: +TradeAnim_TubeToPlayer7: + call TradeAnim_FlashBGPals + ld hl, wFrameCounter + ld a, [hl] + and a + jr z, .done + dec [hl] + ret + +.done + call TradeAnim_IncrementJumptableIndex + ret + +TradeAnim_GiveTrademonSFX: + call TradeAnim_AdvanceScriptPointer + ld de, SFX_GIVE_TRADEMON + call PlaySFX + ret + +TradeAnim_GetTrademonSFX: + call TradeAnim_AdvanceScriptPointer + ld de, SFX_GET_TRADEMON + call PlaySFX + ret + +TradeAnim_TubeAnimJumptable: + maskbits TRADEANIMJUMPTABLE_LENGTH + ld e, a + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +.Jumptable: +; entries correspond to TRADEANIMSTATE_* constants + dw .Zero + dw .One + dw .Two + dw .Three + +.Zero: +.Three: + call TradeAnim_BlankTilemap + hlcoord 9, 3 + ld [hl], $5b + inc hl + ld bc, 10 + ld a, $60 + call ByteFill + hlcoord 3, 2 + call TradeAnim_CopyTradeGameBoyTilemap + ret + +.One: + call TradeAnim_BlankTilemap + hlcoord 0, 3 + ld bc, SCREEN_WIDTH + ld a, $60 + call ByteFill + ret + +.Two: + call TradeAnim_BlankTilemap + hlcoord 0, 3 + ld bc, $11 + ld a, $60 + call ByteFill + hlcoord 17, 3 + ld a, $5d + ld [hl], a + + ld a, $61 + ld de, SCREEN_WIDTH + ld c, $3 +.loop + add hl, de + ld [hl], a + dec c + jr nz, .loop + + add hl, de + ld a, $5f + ld [hld], a + ld a, $5b + ld [hl], a + hlcoord 10, 6 + call TradeAnim_CopyTradeGameBoyTilemap + ret + +TradeAnim_CopyTradeGameBoyTilemap: + ld de, TradeGameBoyTilemap + lb bc, 8, 6 + call TradeAnim_CopyBoxFromDEtoHL + ret + +TradeAnim_PlaceTrademonStatsOnTubeAnim: + push af + call ClearBGPalettes + call WaitTop + ld a, HIGH(vBGMap1) + ldh [hBGMapAddress + 1], a + call ClearTilemap + hlcoord 0, 0 + ld bc, SCREEN_WIDTH + ld a, "─" + call ByteFill + hlcoord 0, 1 + ld de, wLinkPlayer1Name + call PlaceString + ld hl, wLinkPlayer2Name + ld de, 0 +.find_name_end_loop + ld a, [hli] + cp "@" + jr z, .done + dec de + jr .find_name_end_loop + +.done + hlcoord 0, 4 + add hl, de + ld de, wLinkPlayer2Name + call PlaceString + hlcoord 7, 2 + ld bc, 6 + pop af + call ByteFill + call WaitBGMap + call WaitTop + ld a, HIGH(vBGMap0) + ldh [hBGMapAddress + 1], a + call ClearTilemap + ret + +TradeAnim_EnterLinkTube1: + call ClearTilemap + call WaitTop + ld a, $a0 + ldh [hSCX], a + call DelayFrame + hlcoord 8, 2 + ld de, TradeLinkTubeTilemap + lb bc, 3, 12 + call TradeAnim_CopyBoxFromDEtoHL + call WaitBGMap + ld b, SCGB_TRADE_TUBE + call GetSGBLayout + ld a, %11100100 ; 3,2,1,0 + call DmgToCgbBGPals + lb de, %11100100, %11100100 ; 3,2,1,0, 3,2,1,0 + call DmgToCgbObjPals + ld de, SFX_POTION + call PlaySFX + call TradeAnim_IncrementJumptableIndex + ret + +TradeAnim_EnterLinkTube2: + ldh a, [hSCX] + and a + jr z, .done + add $4 + ldh [hSCX], a + ret + +.done + ld c, 80 + call DelayFrames + call TradeAnim_AdvanceScriptPointer + ret + +TradeAnim_ExitLinkTube: + ldh a, [hSCX] + cp $a0 + jr z, .done + sub $4 + ldh [hSCX], a + ret + +.done + call ClearTilemap + xor a + ldh [hSCX], a + call TradeAnim_AdvanceScriptPointer + ret + +TradeAnim_SetupGivemonScroll: + ld a, $8f + ldh [hWX], a + ld a, $88 + ldh [hSCX], a + ld a, $50 + ldh [hWY], a + call TradeAnim_AdvanceScriptPointer + ret + +TradeAnim_DoGivemonScroll: + ldh a, [hWX] + cp $7 + jr z, .done + sub $4 + ldh [hWX], a + ldh a, [hSCX] + sub $4 + ldh [hSCX], a + ret + +.done + ld a, $7 + ldh [hWX], a + xor a + ldh [hSCX], a + call TradeAnim_AdvanceScriptPointer + ret + +TradeAnim_FrontpicScrollStart: + ld a, $7 + ldh [hWX], a + ld a, $50 + ldh [hWY], a + call TradeAnim_AdvanceScriptPointer + ret + +TradeAnim_TextboxScrollStart: + ld a, $7 + ldh [hWX], a + ld a, $90 + ldh [hWY], a + call TradeAnim_AdvanceScriptPointer + ret + +TradeAnim_ScrollOutRight: + call WaitTop + ld a, HIGH(vBGMap1) + ldh [hBGMapAddress + 1], a + call WaitBGMap + ld a, $7 + ldh [hWX], a + xor a + ldh [hWY], a + call DelayFrame + call WaitTop + ld a, HIGH(vBGMap0) + ldh [hBGMapAddress + 1], a + call ClearTilemap + call TradeAnim_IncrementJumptableIndex + ret + +TradeAnim_ScrollOutRight2: + ldh a, [hWX] + cp $a1 + jr nc, .done + inc a + inc a + ldh [hWX], a + ret + +.done + ld a, HIGH(vBGMap1) + ldh [hBGMapAddress + 1], a + call WaitBGMap + ld a, $7 + ldh [hWX], a + ld a, $90 + ldh [hWY], a + ld a, HIGH(vBGMap0) + ldh [hBGMapAddress + 1], a + call TradeAnim_AdvanceScriptPointer + ret + +TradeAnim_ShowGivemonData: + call ShowPlayerTrademonStats + ld a, [wPlayerTrademonSpecies] + ld [wCurPartySpecies], a + ld a, [wPlayerTrademonDVs] + ld [wTempMonDVs], a + ld a, [wPlayerTrademonDVs + 1] + ld [wTempMonDVs + 1], a + ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS + call GetSGBLayout + ld a, %11100100 ; 3,2,1,0 + call DmgToCgbBGPals + call TradeAnim_ShowGivemonFrontpic + + ld a, [wPlayerTrademonSpecies] + call GetCryIndex + jr c, .skip_cry + ld e, c + ld d, b + call PlayCry +.skip_cry + + call TradeAnim_AdvanceScriptPointer + ret + +TradeAnim_ShowGetmonData: + call ShowOTTrademonStats + ld a, [wOTTrademonSpecies] + ld [wCurPartySpecies], a + ld a, [wOTTrademonDVs] + ld [wTempMonDVs], a + ld a, [wOTTrademonDVs + 1] + ld [wTempMonDVs + 1], a + ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS + call GetSGBLayout + ld a, %11100100 ; 3,2,1,0 + call DmgToCgbBGPals + call TradeAnim_ShowGetmonFrontpic + + ld a, [wOTTrademonSpecies] + call GetCryIndex + jr c, .skip_cry + ld e, c + ld d, b + call PlayCry +.skip_cry + + call TradeAnim_AdvanceScriptPointer + ret + +TradeAnim_GetFrontpic: + push de + push af + predef GetUnownLetter + pop af + ld [wCurPartySpecies], a + ld [wCurSpecies], a + call GetBaseData + pop de + predef GetMonFrontpic + ret + +TradeAnim_GetNickname: + push de + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld hl, wStringBuffer1 + pop de + ld bc, NAME_LENGTH + call CopyBytes + ret + +TradeAnim_ShowGivemonFrontpic: + ld de, vTiles0 + jr TradeAnim_ShowFrontpic + +TradeAnim_ShowGetmonFrontpic: + ld de, vTiles0 tile $31 +TradeAnim_ShowFrontpic: + call DelayFrame + ld hl, vTiles2 + lb bc, 10, $31 + call Request2bpp + call WaitTop + call TradeAnim_BlankTilemap + hlcoord 7, 2 + xor a + ldh [hGraphicStartTile], a + lb bc, 7, 7 + predef PlaceGraphic + call WaitBGMap + ret + +TradeAnim_Wait80: + ld c, 80 + call DelayFrames + call TradeAnim_AdvanceScriptPointer + ret + +ShowPlayerTrademonStats: + ld de, wPlayerTrademonSpecies + ld a, [de] + cp EGG + jr z, TrademonStats_Egg + call TrademonStats_MonTemplate + ld de, wPlayerTrademonSpecies + call TrademonStats_PrintSpeciesNumber + ld de, wPlayerTrademonSpeciesName + call TrademonStats_PrintSpeciesName + ld de, wPlayerTrademonOTName + call TrademonStats_PrintOTName + ld de, wPlayerTrademonID + call TrademonStats_PrintTrademonID + call TrademonStats_WaitBGMap + ret + +ShowOTTrademonStats: + ld de, wOTTrademonSpecies + ld a, [de] + cp EGG + jr z, TrademonStats_Egg + call TrademonStats_MonTemplate + ld de, wOTTrademonSpecies + call TrademonStats_PrintSpeciesNumber + ld de, wOTTrademonSpeciesName + call TrademonStats_PrintSpeciesName + ld de, wOTTrademonOTName + call TrademonStats_PrintOTName + ld de, wOTTrademonID + call TrademonStats_PrintTrademonID + call TrademonStats_WaitBGMap + ret + +TrademonStats_MonTemplate: + call WaitTop + call TradeAnim_BlankTilemap + ld a, HIGH(vBGMap1) + ldh [hBGMapAddress + 1], a + hlcoord 3, 0 + ld b, $6 + ld c, $d + call Textbox + hlcoord 4, 0 + ld de, .OTMonData + call PlaceString + ret + +.OTMonData: + db "─── №." + next "" + next "OT/" + next "<ID>№.@" + +TrademonStats_Egg: + call WaitTop + call TradeAnim_BlankTilemap + ld a, HIGH(vBGMap1) + ldh [hBGMapAddress + 1], a + hlcoord 3, 0 + ld b, 6 + ld c, 13 + call Textbox + hlcoord 4, 2 + ld de, .EggData + call PlaceString + call TrademonStats_WaitBGMap + ret + +.EggData: + db "EGG" + next "OT/?????" + next "<ID>№.?????@" + +TrademonStats_WaitBGMap: + call WaitBGMap + call WaitTop + ld a, HIGH(vBGMap0) + ldh [hBGMapAddress + 1], a + ret + +TrademonStats_PrintSpeciesNumber: + hlcoord 10, 0 + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 + call PrintNum + ret + +TrademonStats_PrintSpeciesName: + hlcoord 4, 2 + call PlaceString + ret + +TrademonStats_PrintOTName: + hlcoord 7, 4 + call PlaceString + ret + +TrademonStats_PrintTrademonID: + hlcoord 7, 6 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 + call PrintNum + ret + +TradeAnim_RockingBall: + depixel 10, 11, 4, 0 + ld a, SPRITE_ANIM_INDEX_TRADE_POKE_BALL + call InitSpriteAnimStruct + call TradeAnim_AdvanceScriptPointer + ld a, 64 + ld [wFrameCounter], a + ret + +TradeAnim_DropBall: + depixel 10, 11, 4, 0 + ld a, SPRITE_ANIM_INDEX_TRADE_POKE_BALL + call InitSpriteAnimStruct + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + ld [hl], $1 + ld hl, SPRITEANIMSTRUCT_YOFFSET + add hl, bc + ld [hl], $dc + call TradeAnim_AdvanceScriptPointer + ld a, 56 + ld [wFrameCounter], a + ret + +TradeAnim_Poof: + depixel 10, 11, 4, 0 + ld a, SPRITE_ANIM_INDEX_TRADE_POOF + call InitSpriteAnimStruct + call TradeAnim_AdvanceScriptPointer + ld a, 16 + ld [wFrameCounter], a + ld de, SFX_BALL_POOF + call PlaySFX + ret + +TradeAnim_BulgeThroughTube: + ld a, %11100100 ; 3,2,1,0 + call DmgToCgbObjPal0 + depixel 5, 11 + ld a, SPRITE_ANIM_INDEX_TRADE_TUBE_BULGE + call InitSpriteAnimStruct + call TradeAnim_AdvanceScriptPointer + ld a, 128 + ld [wFrameCounter], a + ret + +TradeAnim_AnimateTrademonInTube: + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + ld e, [hl] + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +.Jumptable: + dw .InitTimer + dw .WaitTimer1 + dw .MoveRight + dw .MoveDown + dw .MoveUp + dw .MoveLeft + dw .WaitTimer2 + +.JumptableNext: + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + inc [hl] + ret + +.InitTimer: + call .JumptableNext + ld hl, SPRITEANIMSTRUCT_0C + add hl, bc + ld [hl], $80 + ret + +.WaitTimer1: + ld hl, SPRITEANIMSTRUCT_0C + add hl, bc + ld a, [hl] + dec [hl] + and a + ret nz + call .JumptableNext + +.MoveRight: + ld hl, SPRITEANIMSTRUCT_XCOORD + add hl, bc + ld a, [hl] + cp $94 + jr nc, .done_move_right + inc [hl] + ret + +.done_move_right + call .JumptableNext + +.MoveDown: + ld hl, SPRITEANIMSTRUCT_YCOORD + add hl, bc + ld a, [hl] + cp $4c + jr nc, .done_move_down + inc [hl] + ret + +.done_move_down + ld hl, SPRITEANIMSTRUCT_INDEX + add hl, bc + ld [hl], $0 + ret + +.MoveUp: + ld hl, SPRITEANIMSTRUCT_YCOORD + add hl, bc + ld a, [hl] + cp $2c + jr z, .done_move_up + dec [hl] + ret + +.done_move_up + call .JumptableNext + +.MoveLeft: + ld hl, SPRITEANIMSTRUCT_XCOORD + add hl, bc + ld a, [hl] + cp $58 + jr z, .done_move_left + dec [hl] + ret + +.done_move_left + call .JumptableNext + ld hl, SPRITEANIMSTRUCT_0C + add hl, bc + ld [hl], $80 + ret + +.WaitTimer2: + ld hl, SPRITEANIMSTRUCT_0C + add hl, bc + ld a, [hl] + dec [hl] + and a + ret nz + ld hl, SPRITEANIMSTRUCT_INDEX + add hl, bc + ld [hl], $0 + ret + +TradeAnim_SentToOTText: + ld a, [wLinkMode] + cp LINK_TIMECAPSULE + jr z, .time_capsule + ld hl, .MonNameSentToText + call PrintText + ld c, 189 + call DelayFrames + ld hl, .MonWasSentToText + call PrintText + call TradeAnim_Wait80Frames + ld c, 128 + call DelayFrames + call TradeAnim_AdvanceScriptPointer + ret + +.time_capsule + ld hl, .MonWasSentToText + call PrintText + call TradeAnim_Wait80Frames + call TradeAnim_AdvanceScriptPointer + ret + +.MonWasSentToText: + text_far _MonWasSentToText + text_end + +.MonNameSentToText: + text_far _MonNameSentToText + text_end + +TradeAnim_OTBidsFarewell: + ld hl, .BidsFarewellToMonText + call PrintText + call TradeAnim_Wait80Frames + ld hl, .MonNameBidsFarewellText + call PrintText + call TradeAnim_Wait80Frames + call TradeAnim_AdvanceScriptPointer + ret + +.BidsFarewellToMonText: + text_far _BidsFarewellToMonText + text_end + +.MonNameBidsFarewellText: + text_far _MonNameBidsFarewellText + text_end + +TradeAnim_TakeCareOfText: + call WaitTop + hlcoord 0, 10 + ld bc, 8 * SCREEN_WIDTH + ld a, " " + call ByteFill + call WaitBGMap + ld hl, .TakeGoodCareOfMonText + call PrintText + call TradeAnim_Wait80Frames + call TradeAnim_AdvanceScriptPointer + ret + +.TakeGoodCareOfMonText: + text_far _TakeGoodCareOfMonText + text_end + +TradeAnim_OTSendsText1: + ld hl, .ForYourMonSendsText + call PrintText + call TradeAnim_Wait80Frames + ld hl, .OTSendsText + call PrintText + call TradeAnim_Wait80Frames + ld c, 14 + call DelayFrames + call TradeAnim_AdvanceScriptPointer + ret + +.ForYourMonSendsText: + text_far _ForYourMonSendsText + text_end + +.OTSendsText: + text_far _OTSendsText + text_end + +TradeAnim_OTSendsText2: + ld hl, .WillTradeText + call PrintText + call TradeAnim_Wait80Frames + ld hl, .ForYourMonWillTradeText + call PrintText + call TradeAnim_Wait80Frames + ld c, 14 + call DelayFrames + call TradeAnim_AdvanceScriptPointer + ret + +.WillTradeText: + text_far _WillTradeText + text_end + +.ForYourMonWillTradeText: + text_far _ForYourMonWillTradeText + text_end + +TradeAnim_Wait80Frames: + ld c, 80 + call DelayFrames + ret + +TradeAnim_BlankTilemap: + hlcoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, " " + call ByteFill + ret + +TradeAnim_CopyBoxFromDEtoHL: +.row + push bc + push hl +.col + ld a, [de] + inc de + ld [hli], a + dec c + jr nz, .col + pop hl + ld bc, SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .row + ret + +TradeAnim_NormalPals: + ldh a, [hSGB] + and a + ld a, %11100100 ; 3,2,1,0 + jr z, .not_sgb + ld a, $f0 + +.not_sgb + call DmgToCgbObjPal0 + ld a, %11100100 ; 3,2,1,0 + call DmgToCgbBGPals + ret + +LinkTradeAnim_LoadTradePlayerNames: + push de + ld de, wLinkPlayer1Name + ld bc, NAME_LENGTH + call CopyBytes + pop hl + ld de, wLinkPlayer2Name + ld bc, NAME_LENGTH + call CopyBytes + ret + +LinkTradeAnim_LoadTradeMonSpecies: + ld a, [hl] + ld [wLinkTradeSendmonSpecies], a + ld a, [de] + ld [wLinkTradeGetmonSpecies], a + ret + +TradeAnim_FlashBGPals: + ld a, [wce65] + and $7 + ret nz + ldh a, [rBGP] + xor %00111100 + call DmgToCgbBGPals + ret + +LoadTradeBallAndCableGFX: + call DelayFrame + ld de, TradeBallGFX + ld hl, vTiles0 tile $62 + lb bc, BANK(TradeBallGFX), 6 + call Request2bpp + ld de, TradePoofGFX + ld hl, vTiles0 tile $68 + lb bc, BANK(TradePoofGFX), 12 + call Request2bpp + ld de, TradeCableGFX + ld hl, vTiles0 tile $74 + lb bc, BANK(TradeCableGFX), 4 + call Request2bpp + xor a + ld hl, wSpriteAnimDict + ld [hli], a + ld [hl], $62 + ret + +LoadTradeBubbleGFX: + call DelayFrame + ld e, MONICON_TRADE + callfar LoadMenuMonIcon + ld de, TradeBubbleGFX + ld hl, vTiles0 tile $72 + lb bc, BANK(TradeBubbleGFX), 4 + call Request2bpp + xor a + ld hl, wSpriteAnimDict + ld [hli], a + ld [hl], $62 + ret + +TradeAnim_WaitAnim: + ld hl, wFrameCounter + ld a, [hl] + and a + jr z, .done + dec [hl] + ret + +.done + call TradeAnim_AdvanceScriptPointer + ret + +Unreferenced_DebugTrade: +; This function is not referenced. +; It was meant for use in Japanese versions, so the +; constant used for copy length was changed by accident. + + ld hl, .DebugTradeData + + ld a, [hli] + ld [wPlayerTrademonSpecies], a + ld de, wPlayerTrademonSenderName + ld c, NAME_LENGTH + 2 ; JP: NAME_LENGTH_JAPANESE + 2 +.loop1 + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .loop1 + + ld a, [hli] + ld [wOTTrademonSpecies], a + ld de, wOTTrademonSenderName + ld c, NAME_LENGTH + 2 ; JP: NAME_LENGTH_JAPANESE + 2 +.loop2 + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .loop2 + ret + +debugtrade: MACRO +; species, ot name, ot id (?) + db \1, \2 + dw \3 +ENDM + +.DebugTradeData: + debugtrade VENUSAUR, "ゲーフり@@", $0123 ; GAME FREAK + debugtrade CHARIZARD, "クりーチャ@", $0456 ; Creatures Inc. + +TradeGameBoyTilemap: +; 6x8 + db $31, $32, $32, $32, $32, $33 + db $34, $35, $36, $36, $37, $38 + db $34, $39, $3a, $3a, $3b, $38 + db $3c, $3d, $3e, $3e, $3f, $40 + db $41, $42, $43, $43, $44, $45 + db $46, $47, $43, $48, $49, $4a + db $41, $43, $4b, $4c, $4d, $4e + db $4f, $50, $50, $50, $51, $52 + +TradeLinkTubeTilemap: +; 12x3 + db $43, $55, $56, $53, $53, $53, $53, $53, $53, $53, $53, $53 + db $43, $57, $58, $54, $54, $54, $54, $54, $54, $54, $54, $54 + db $43, $59, $5a, $43, $43, $43, $43, $43, $43, $43, $43, $43 + +TradeArrowRightGFX: INCBIN "gfx/trade/arrow_right.2bpp" +TradeArrowLeftGFX: INCBIN "gfx/trade/arrow_left.2bpp" +TradeCableGFX: INCBIN "gfx/trade/cable.2bpp" +TradeBubbleGFX: INCBIN "gfx/trade/bubble.2bpp" +TradeGameBoyLZ: INCBIN "gfx/trade/game_boy.2bpp.lz" +TradeBallGFX: INCBIN "gfx/trade/ball.2bpp" +TradePoofGFX: INCBIN "gfx/trade/poof.2bpp" diff --git a/gfx/trade/arrow_left.2bpp b/gfx/trade/arrow_left.2bpp Binary files differnew file mode 100644 index 00000000..372fbec9 --- /dev/null +++ b/gfx/trade/arrow_left.2bpp diff --git a/gfx/trade/arrow_right.2bpp b/gfx/trade/arrow_right.2bpp Binary files differnew file mode 100644 index 00000000..5578d37c --- /dev/null +++ b/gfx/trade/arrow_right.2bpp diff --git a/gfx/trade/ball.2bpp b/gfx/trade/ball.2bpp Binary files differnew file mode 100644 index 00000000..b90cac27 --- /dev/null +++ b/gfx/trade/ball.2bpp diff --git a/gfx/trade/border_tiles.2bpp b/gfx/trade/border_tiles.2bpp Binary files differnew file mode 100644 index 00000000..4baf4888 --- /dev/null +++ b/gfx/trade/border_tiles.2bpp diff --git a/gfx/trade/bubble.2bpp b/gfx/trade/bubble.2bpp Binary files differnew file mode 100644 index 00000000..c4a7abf4 --- /dev/null +++ b/gfx/trade/bubble.2bpp diff --git a/gfx/trade/cable.2bpp b/gfx/trade/cable.2bpp Binary files differnew file mode 100644 index 00000000..1f9974e9 --- /dev/null +++ b/gfx/trade/cable.2bpp diff --git a/gfx/trade/game_boy.2bpp.lz b/gfx/trade/game_boy.2bpp.lz Binary files differnew file mode 100644 index 00000000..83216430 --- /dev/null +++ b/gfx/trade/game_boy.2bpp.lz diff --git a/gfx/trade/poof.2bpp b/gfx/trade/poof.2bpp Binary files differnew file mode 100644 index 00000000..c50e69e6 --- /dev/null +++ b/gfx/trade/poof.2bpp diff --git a/home/names.asm b/home/names.asm index 973af3e3..e3da8793 100755 --- a/home/names.asm +++ b/home/names.asm @@ -56,9 +56,9 @@ GetName:: .done ld a, e - ld [wcffe], a + ld [wUnusedCFFE], a ld a, d - ld [wcffe + 1], a + ld [wUnusedCFFE + 1], a pop de pop bc diff --git a/home/vblank.asm b/home/vblank.asm index 6bac4703..ce82f2cd 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -167,7 +167,7 @@ VBlank1:: or a jr z, .skip_lcd ld c, a - ld a, [wc700] + ld a, [wLYOverrides] ld [$ff00+c], a .skip_lcd diff --git a/layout.link b/layout.link index 6adf1ce0..d9bf86e2 100644 --- a/layout.link +++ b/layout.link @@ -274,12 +274,12 @@ WRAM0 "WRAM" "GBC Palettes" "Sprites" - "TileMap" + "Tilemap" "Animated Objects" "Video" WRAMX 1 org $d000 - "WRAM1" + "WRAM 1" "Game Data" "Party" org $dfff diff --git a/macros/scripts/trade_anims.asm b/macros/scripts/trade_anims.asm index 75a4a3db..ede20118 100755 --- a/macros/scripts/trade_anims.asm +++ b/macros/scripts/trade_anims.asm @@ -97,69 +97,42 @@ tradeanim_wait_80: macro db tradeanim_wait_80_command ; 21 endm - enum tradeanim_wait_40_command -tradeanim_wait_40: macro - db tradeanim_wait_40_command ; 22 -endm - enum tradeanim_rocking_ball_command tradeanim_rocking_ball: macro - db tradeanim_rocking_ball_command ; 23 + db tradeanim_rocking_ball_command ; 22 endm enum tradeanim_drop_ball_command tradeanim_drop_ball: macro - db tradeanim_drop_ball_command ; 24 + db tradeanim_drop_ball_command ; 23 endm enum tradeanim_wait_anim_command tradeanim_wait_anim: macro - db tradeanim_wait_anim_command ; 25 + db tradeanim_wait_anim_command ; 24 endm -__enum__ set $27 - enum tradeanim_poof_command tradeanim_poof: macro - db tradeanim_poof_command ; 27 + db tradeanim_poof_command ; 25 endm enum tradeanim_bulge_through_tube_command tradeanim_bulge_through_tube: macro - db tradeanim_bulge_through_tube_command ; 28 + db tradeanim_bulge_through_tube_command ; 26 endm enum tradeanim_give_trademon_sfx_command tradeanim_give_trademon_sfx: macro - db tradeanim_give_trademon_sfx_command ; 29 + db tradeanim_give_trademon_sfx_command ; 27 endm enum tradeanim_get_trademon_sfx_command tradeanim_get_trademon_sfx: macro - db tradeanim_get_trademon_sfx_command ; 2a + db tradeanim_get_trademon_sfx_command ; 28 endm enum tradeanim_end_command tradeanim_end: macro - db tradeanim_end_command ; 2b -endm - - enum tradeanim_animate_frontpic_command -tradeanim_animate_frontpic: macro - db tradeanim_animate_frontpic_command ; 2c -endm - - enum tradeanim_wait_96_command -tradeanim_wait_96: macro - db tradeanim_wait_96_command ; 2d -endm - - enum tradeanim_wait_80_if_ot_egg_command -tradeanim_wait_80_if_ot_egg: macro - db tradeanim_wait_80_if_ot_egg_command ; 2e -endm - - enum tradeanim_wait_180_if_ot_egg_command -tradeanim_wait_180_if_ot_egg: macro - db tradeanim_wait_180_if_ot_egg_command ; 2f + db tradeanim_end_command ; 29 endm @@ -251,59 +251,9 @@ INCLUDE "data/moves/effects.asm" SECTION "banka", ROMX - dr $28000, $28d88 -LinkTextboxAtHL:: - dr $28d88, $28dea -TradeAnimation:: - dr $28dea, $28e22 -TradeAnimationPlayer2:: - dr $28e22, $29a47 - -CheckTimeCapsuleCompatibility:: - dr $29a47, $29ac7 -EnterTimeCapsule:: - dr $29ac7, $29ad9 -WaitForOtherPlayerToExit:: - dr $29ad9, $29b22 -SetBitsForLinkTradeRequest:: - dr $29b22, $29b2b -SetBitsForBattleRequest:: - dr $29b2b, $29b34 -SetBitsForTimeCapsuleRequest:: - dr $29b34, $29b4b -WaitForLinkedFriend:: - dr $29b4b, $29bcc -CheckLinkTimeout:: - dr $29bcc, $29c71 -TryQuickSave:: - dr $29c71, $29c8d -CheckBothSelectedSameRoom:: - dr $29c8d, $29cba -TimeCapsule:: - dr $29cba, $29ccf -TradeCenter:: - dr $29ccf, $29ce4 -Colosseum:: - dr $29ce4, $29cf9 -CloseLink:: - dr $29cf9, $29d01 -FailedLinkToPast:: - dr $29d01, $29d4e -CableClubCheckWhichChris:: - dr $29d4e, $29dff -Function29dff:: - dr $29dff, $2a4bf - -MysteryGift_CopyReceivedDecosToPC:: - dr $2a4bf, $2a4e7 -UnlockMysteryGift:: - dr $2a4e7, $2a4f6 -Function2a4f6:: - dr $2a4f6, $2a507 -BackupMysteryGift:: - dr $2a507, $2a518 -RestoreMysteryGift:: - dr $2a518, $2a539 +INCLUDE "engine/link/link.asm" +INCLUDE "engine/link/mystery_gift.asm" + LoadWildMonData:: dr $2a539, $2a643 TryWildEncounter:: @@ -346,7 +296,13 @@ _ShowLinkBattleParticipants:: dr $2c1e4, $2c225 INCLUDE "engine/battle/ai/redundant.asm" MoveDeletion:: - dr $2c352, $2c57a + dr $2c352, $2c44d +PrepMysteryGiftDataToSend:: + dr $2c44d, $2c513 +MysteryGiftGetItemHeldEffect:: + dr $2c513, $2c520 +MysteryGiftGetDecoration:: + dr $2c520, $2c57a Pack_TMHMPocketMenu_:: dr $2c57a, $2c5ca AskTeachTMHM:: @@ -545,7 +501,9 @@ Unused_PlaceEnemyHPLevel:: PlaceNonFaintStatus:: dr $51437, $51478 ListMoves:: - dr $51478, $51524 + dr $51478, $514c2 +InitList:: + dr $514c2, $51524 CalcLevel:: dr $51524, $51550 CalcExpAtLevel:: @@ -923,13 +881,23 @@ TileCollisionTable:: Shrink1Pic:: dr $fb5be, $fb64e Shrink2Pic:: - dr $fb64e, $fb7f7 + dr $fb64e, $fb68e +ValidateOTTrademon:: + dr $fb68e, $fb6ed +Functionfb6ed:: + dr $fb6ed, $fb71d +PlaceTradePartnerNamesAndParty:: + dr $fb71d, $fb760 +KantoMonSpecials:: + dr $fb760, $fb7f7 _NameRater:: dr $fb7f7, $fb94b PlaySlowCry:: dr $fb94b, $fb981 NewPokedexEntry:: - dr $fb981, $fba12 + dr $fb981, $fb9fb +ConvertMon_2to1:: + dr $fb9fb, $fba12 ConvertMon_1to2:: dr $fba12, $fbb22 UpdateUnownDex:: @@ -1002,7 +970,11 @@ TilesetUndergroundAnim:: NPCTrade:: dr $fc9ae, $fcd87 MomTriesToBuySomething:: - dr $fcd87, $fde20 + dr $fcd87, $fcf6a +StagePartyDataForMysteryGift:: + dr $fcf6a, $fcfb2 +InitMysteryGiftLayout:: + dr $fcfb2, $fde20 SECTION "bank40", ROMX diff --git a/tools/mapreader.py b/tools/mapreader.py new file mode 100644 index 00000000..73c4ca14 --- /dev/null +++ b/tools/mapreader.py @@ -0,0 +1,173 @@ +# -*- coding: utf-8 -*- + +# A library for parsing the pokegold.map file output by rgbds. + +import re + +class MapReader: + + # {'ROM Bank': { 0: { 'sections': [ { 'beg': 1234, + # 'end': 5678, + # 'name': 'Section001', + # 'symbols': [ { 'symbol': 'Function1234', + # 'address: 1234, + # }, + # ] + # }, + # ], + # 'used': 1234, + # 'slack': 4567, + # }, + # }, + # 'OAM': { 'sections': [ { 'beg': 1234, + # 'end': 5678, + # 'name': 'Section002', + # 'symbols': [ { 'symbol': 'Data1234', + # 'address: 1234, + # }, + # ] + # }, + # ], + # 'used': 1234, + # 'slack': 4567, + # }, + # } + # + bank_data = {} + + bank_types = { + 'HRAM' : { 'size': 0x80, 'banked': False, }, + 'OAM' : { 'size': 0xA0, 'banked': False, }, + 'ROM0 bank': { 'size': 0x4000, 'banked': True, }, + 'ROMX bank': { 'size': 0x4000, 'banked': True, }, + 'SRAM bank': { 'size': 0x2000, 'banked': True, }, + 'VRAM bank': { 'size': 0x1000, 'banked': True, }, + 'WRAM bank': { 'size': 0x2000, 'banked': True, }, + } + + # FSM states + INIT, BANK, SECTION = range(3) + + # $506D-$519A ($012E bytes) ["Type Matchups"] + section_header_regex = re.compile('\$([0-9A-Fa-f]{4})-\$([0-9A-Fa-f]{4}) \(.*\) \["(.*)"\]') + # $506D = TypeMatchups + section_data_regex = re.compile('\$([0-9A-Fa-f]{4}) = (.*)') + # $3ED2 bytes + slack_regex = re.compile('\$([0-9A-Fa-f]{4}) bytes?') + + def __init__(self, *args, **kwargs): + self.__dict__.update(kwargs) + + def _parse_init(self, line): + + line = line.split(':', 1)[0] + parts = line.split(' #', 1) + + if (parts[0] in self.bank_types): + self._cur_bank_name = parts[0] + self._cur_bank_type = self.bank_types[self._cur_bank_name] + if (self._cur_bank_type['banked'] and len(parts) > 1): + parts[1] = parts[1].split(':', 1)[0] + parts[1] = parts[1].split(' ', 1)[0] + self._cur_bank = int(parts[1], 10) + if self._cur_bank_name not in self.bank_data: + self.bank_data[self._cur_bank_name] = {} + if self._cur_bank_type['banked']: + if self._cur_bank not in self.bank_data[self._cur_bank_name]: + self.bank_data[self._cur_bank_name][self._cur_bank] = {} + self._cur_data = self.bank_data[self._cur_bank_name][self._cur_bank] + else: + self._cur_data = self.bank_data[self._cur_bank_name] + + if ({} == self._cur_data): + self._cur_data['sections'] = [] + self._cur_data['used'] = 0 + self._cur_data['slack'] = self._cur_bank_type['size'] + return True + + return False + + def _parse_section_header(self, header): + + section_data = self.section_header_regex.match(header) + if section_data is not None: + beg = int(section_data.group(1), 16) + end = int(section_data.group(2), 16) + name = section_data.group(3) + self._cur_section = {'beg': beg, 'end': end, 'name': name, 'symbols': []} + self._cur_data['sections'].append(self._cur_section) + return True + return False + + def _parse_slack(self, data): + + slack_data = self.slack_regex.match(data) + slack_bytes = int(slack_data.group(1), 16) + self._cur_data['slack'] = slack_bytes + + used_bytes = 0 + + for s in self._cur_data['sections']: + used_bytes += s['end'] - s['beg'] + 1 + + self._cur_data['used'] = used_bytes + + def read_map_data(self, map): + + if type(map) is str: + map = map.split('\n') + + self._state = MapReader.INIT + self._cur_bank_name = '' + self._cur_bank_type = {} + self._cur_bank = 0 + self._cur_data = {} + + for line in map: + + line = line.rstrip() + if (MapReader.INIT == self._state): + + if (self._parse_init(line)): + self._state = MapReader.BANK + + elif (MapReader.BANK == self._state or MapReader.SECTION == self._state): + + if ('' == line): + self._state = MapReader.INIT + else: + + line = line.lstrip() + parts = line.split(': ', 1) + + if (MapReader.SECTION == self._state): + section_data = self.section_data_regex.match(parts[0]) + if section_data is not None: + address = int(section_data.group(1), 16) + name = section_data.group(2) + self._cur_section['symbols'].append({'name': name, 'address': address}) + continue + + if ('SECTION' == parts[0]): + if (self._parse_section_header(parts[1])): + self._state = MapReader.SECTION + elif ('SLACK' == parts[0]): + self._parse_slack(parts[1]) + self._state = MapReader.INIT + elif ('EMPTY' == parts[0]): + self._cur_data = {'sections': [], 'used': 0, 'slack': self._cur_bank_type['size']} + self._state = MapReader.INIT + + else: + pass + + for k, v in self.bank_data.items(): + if (self.bank_types[k]['banked']): + for _, vv in v.items(): + vv['sections'].sort(key=lambda x: x['beg']) + for vvv in vv['sections']: + vvv['symbols'].sort(key=lambda x: x['address']) + else: + v['sections'].sort(key=lambda x: x['beg']) + for vv in v['sections']: + vv['symbols'].sort(key=lambda x: x['address']) diff --git a/tools/used_space.py b/tools/used_space.py new file mode 100644 index 00000000..73ece93d --- /dev/null +++ b/tools/used_space.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +""" +Usage: python3 used_space.py [pokecrystal.map] [used_space.png] + +Generate a PNG visualizing the space used by each bank in the ROM. +""" + +import sys +from pokemontools import png +from colorsys import hls_to_rgb + +from mapreader import MapReader + +def main(): + mapfile = sys.argv[1] if len(sys.argv) >= 2 else 'pokegold.map' + filename = sys.argv[2] if len(sys.argv) >= 3 else 'used_space.png' + + num_banks = 0x80 + bank_mask = 0x3FFF + bank_size = 0x4000 # bytes + + bpp = 8 # bytes per pixel + height = 256 # pixels + assert bank_size % bpp == 0 and (bank_size // bpp) % height == 0 + + pixels_per_bank = bank_size // bpp # 2048 pixels + bank_width = pixels_per_bank // height # 8 pixels + width = bank_width * num_banks # 1024 pixels + + r = MapReader() + with open(mapfile, 'r', encoding='utf-8') as f: + l = f.readlines() + r.read_map_data(l) + + hit_data = [] + default_bank_data = {'sections': [], 'used': 0, 'slack': bank_size} + for bank in range(num_banks): + hits = [0] * pixels_per_bank + bank_data = r.bank_data['ROM0 bank'] if bank == 0 else r.bank_data['ROMX bank'] + data = bank_data.get(bank, default_bank_data) + for s in data['sections']: + beg = s['beg'] & bank_mask + end = s['end'] & bank_mask + for i in range(beg, end + 1): + hits[i // bpp] += 1 + hit_data.append(hits) + + pixels = [[(0xFF, 0xFF, 0xFF)] * width for _ in range(height)] + for bank, hits in enumerate(hit_data): + hue = 0 if not bank else 210 if bank % 2 else 270 + for i, h in enumerate(hits): + y = i // bank_width + x = i % bank_width + bank * bank_width + hls = (hue / 360.0, 1.0 - (h / bpp * (100 - 15)) / 100.0, 1.0) + rgb = tuple(c * 255 for c in hls_to_rgb(*hls)) + pixels[y][x] = rgb + + png_data = [tuple(c for pixel in row for c in pixel) for row in pixels] + with open(filename, 'wb') as f: + w = png.Writer(width, height) + w.write(f, png_data) + +if __name__ == '__main__': + main() @@ -242,7 +242,8 @@ wVirtualOAMSprite39:: sprite_oam_struct wVirtualOAMSprite39 wVirtualOAMEnd:: -SECTION "TileMap", WRAM0 +SECTION "Tilemap", WRAM0 + wTilemap:: ; c3a0 ds SCREEN_HEIGHT * SCREEN_WIDTH wTilemapEnd:: ; c508 @@ -256,6 +257,21 @@ UNION ; c508 wSurroundingTiles:: ds SURROUNDING_WIDTH * SURROUNDING_HEIGHT NEXTU ; c508 +; trade +wc508:: ds 10 +wc512:: ds 190 + +wTrademons:: +wPlayerTrademon:: trademon wPlayerTrademon +wOTTrademon:: trademon wOTTrademon +wTrademonsEnd:: +wTradeAnimAddress:: dw +wLinkPlayer1Name:: ds NAME_LENGTH +wLinkPlayer2Name:: ds NAME_LENGTH +wLinkTradeSendmonSpecies:: db +wLinkTradeGetmonSpecies:: db + +NEXTU ; c508 ; box save buffer ; SaveBoxAddress uses this buffer in three steps because it ; needs more space than the buffer can hold. @@ -263,10 +279,11 @@ wBoxPartialData:: ds 480 wBoxPartialDataEnd:: NEXTU ; c508 +; 20x18 grid of 8x8 tiles wTempTilemap:: - ds SCREEN_HEIGHT * SCREEN_WIDTH + ds SCREEN_WIDTH * SCREEN_HEIGHT ; $168 = 360 -NEXTU +NEXTU ; c508 ; wSpriteAnimDict is a 10x2 dictionary ; keys: taken from third column of SpriteAnimSeqData ; values: vTiles @@ -315,29 +332,6 @@ wc5cd:: ds 1 ; c5cd wc5ce:: ds 1 ; c5ce wc5cf:: ds 1 ; c5cf -UNION ; c5d0 -; trade -wTradeMons:: -wPlayerTrademon:: trademon wPlayerTrademon -wOTTrademon:: trademon wOTTrademon -wTrademonsEnd:: -wTradeAnimAddress:: dw -wLinkPlayer1Name:: ds NAME_LENGTH -wLinkPlayer2Name:: ds NAME_LENGTH -wLinkTradeSendmonSpecies:: db -wLinkTradeGetmonSpecies:: db - -NEXTU ; c5d0 -; engine/gfx/color.asm ? - ds 50 -wc602:: ds 1 ; c602 -wc603:: ds 1 ; c603 -wc604:: ds 1 ; c604 -wc605:: ds 1 ; c605 -wc606:: ds 1 ; c606 -wc607:: ds 1 ; c607 - -NEXTU ; c5d0 ; naming screen wNamingScreenDestinationPointer:: dw ; c5d0 wNamingScreenCurNameLength:: db ; c5d2 @@ -346,10 +340,20 @@ wNamingScreenType:: db ; c5d4 wNamingScreenCursorObjectPointer:: dw ; c5d5 wNamingScreenLastCharacter:: db ; c5d7 wNamingScreenStringEntryCoord:: dw ; c5d8 -ENDU - ds 126 + ds 40 + +; engine/gfx/color.asm ? +wc602:: ds 1 ; c602 +wc603:: ds 1 ; c603 +wc604:: ds 1 ; c604 +wc605:: ds 1 ; c605 +wc606:: ds 1 ; c606 +wc607:: ds 1 ; c607 + + ds 192 +; unidentifed wc6ca:: ds 1 ; c6ca wc6cb:: ds 1 ; c6cb wc6cc:: ds 1 ; c6cc @@ -380,1021 +384,194 @@ wc6e4:: ds 1 ; c6e4 wc6e5:: ds 1 ; c6e5 wc6e6:: ds 1 ; c6e6 wc6e7:: ds 1 ; c6e7 +ENDU ; c6e8 ; This was a buffer for map-related pointers in the 1997 G/S prototype. ; See wMapBuffer in pokegold-spaceworld's wram.asm. wUnusedMapBuffer:: ds 24 wUnusedMapBufferEnd:: -wOverworldMapBlocks:: -wLYOverrides:: -wHallOfFamePokemonList:: -wc700:: ds 1 ; c700 -wc701:: ds 1 ; c701 -wc702:: ds 1 ; c702 -wc703:: ds 1 ; c703 -wc704:: ds 1 ; c704 -wc705:: ds 1 ; c705 -wc706:: ds 1 ; c706 -wc707:: ds 1 ; c707 -wc708:: ds 1 ; c708 -wc709:: ds 1 ; c709 -wc70a:: ds 1 ; c70a -wc70b:: ds 1 ; c70b -wc70c:: ds 1 ; c70c -wc70d:: ds 1 ; c70d -wc70e:: ds 1 ; c70e -wc70f:: ds 1 ; c70f -wc710:: ds 1 ; c710 -wc711:: ds 1 ; c711 -wc712:: ds 1 ; c712 -wc713:: ds 1 ; c713 -wc714:: ds 1 ; c714 -wc715:: ds 1 ; c715 -wc716:: ds 1 ; c716 -wc717:: ds 1 ; c717 -wc718:: ds 1 ; c718 -wc719:: ds 1 ; c719 -wc71a:: ds 1 ; c71a -wc71b:: ds 1 ; c71b -wc71c:: ds 1 ; c71c -wc71d:: ds 1 ; c71d -wc71e:: ds 1 ; c71e -wc71f:: ds 1 ; c71f -wc720:: ds 1 ; c720 -wc721:: ds 1 ; c721 -wc722:: ds 1 ; c722 -wc723:: ds 1 ; c723 -wc724:: ds 1 ; c724 -wc725:: ds 1 ; c725 -wc726:: ds 1 ; c726 -wc727:: ds 1 ; c727 -wc728:: ds 1 ; c728 -wc729:: ds 1 ; c729 -wc72a:: ds 1 ; c72a -wc72b:: ds 1 ; c72b -wc72c:: ds 1 ; c72c -wc72d:: ds 1 ; c72d -wc72e:: ds 1 ; c72e -wc72f:: ds 1 ; c72f -wc730:: ds 1 ; c730 -wc731:: ds 1 ; c731 -wc732:: ds 1 ; c732 -wc733:: ds 1 ; c733 -wc734:: ds 1 ; c734 -wc735:: ds 1 ; c735 -wc736:: ds 1 ; c736 -wc737:: ds 1 ; c737 -wc738:: ds 1 ; c738 -wc739:: ds 1 ; c739 -wc73a:: ds 1 ; c73a -wc73b:: ds 1 ; c73b -wc73c:: ds 1 ; c73c -wc73d:: ds 1 ; c73d -wc73e:: ds 1 ; c73e -wc73f:: ds 1 ; c73f -wc740:: ds 1 ; c740 -wc741:: ds 1 ; c741 -wc742:: ds 1 ; c742 -wc743:: ds 1 ; c743 -wc744:: ds 1 ; c744 -wc745:: ds 1 ; c745 -wc746:: ds 1 ; c746 -wc747:: ds 1 ; c747 -wc748:: ds 1 ; c748 -wc749:: ds 1 ; c749 -wc74a:: ds 1 ; c74a -wc74b:: ds 1 ; c74b -wc74c:: ds 1 ; c74c -wc74d:: ds 1 ; c74d -wc74e:: ds 1 ; c74e -wc74f:: ds 1 ; c74f -wc750:: ds 1 ; c750 -wc751:: ds 1 ; c751 -wc752:: ds 1 ; c752 -wc753:: ds 1 ; c753 -wc754:: ds 1 ; c754 -wc755:: ds 1 ; c755 -wc756:: ds 1 ; c756 -wc757:: ds 1 ; c757 -wc758:: ds 1 ; c758 -wc759:: ds 1 ; c759 -wc75a:: ds 1 ; c75a -wc75b:: ds 1 ; c75b -wc75c:: ds 1 ; c75c -wc75d:: ds 1 ; c75d -wc75e:: ds 1 ; c75e -wc75f:: ds 1 ; c75f -wc760:: ds 1 ; c760 -wHallOfFamePokemonListEnd:: -wc761:: ds 1 ; c761 -wc762:: ds 1 ; c762 -wc763:: ds 1 ; c763 -wc764:: ds 1 ; c764 -wc765:: ds 1 ; c765 -wc766:: ds 1 ; c766 -wc767:: ds 1 ; c767 -wc768:: ds 1 ; c768 -wc769:: ds 1 ; c769 -wc76a:: ds 1 ; c76a -wc76b:: ds 1 ; c76b -wc76c:: ds 1 ; c76c -wc76d:: ds 1 ; c76d -wc76e:: ds 1 ; c76e -wc76f:: ds 1 ; c76f -wc770:: ds 1 ; c770 -wc771:: ds 1 ; c771 -wc772:: ds 1 ; c772 -wc773:: ds 1 ; c773 -wc774:: ds 1 ; c774 -wc775:: ds 1 ; c775 -wc776:: ds 1 ; c776 -wc777:: ds 1 ; c777 -wc778:: ds 1 ; c778 -wc779:: ds 1 ; c779 -wc77a:: ds 1 ; c77a -wc77b:: ds 1 ; c77b -wc77c:: ds 1 ; c77c -wc77d:: ds 1 ; c77d -wc77e:: ds 1 ; c77e -wc77f:: ds 1 ; c77f -wc780:: ds 1 ; c780 -wc781:: ds 1 ; c781 -wc782:: ds 1 ; c782 -wc783:: ds 1 ; c783 -wc784:: ds 1 ; c784 -wc785:: ds 1 ; c785 -wc786:: ds 1 ; c786 -wc787:: ds 1 ; c787 -wc788:: ds 1 ; c788 -wc789:: ds 1 ; c789 -wc78a:: ds 1 ; c78a -wc78b:: ds 1 ; c78b -wc78c:: ds 1 ; c78c -wc78d:: ds 1 ; c78d -wc78e:: ds 1 ; c78e -wc78f:: ds 1 ; c78f -wLYOverridesEnd:: -wc790:: ds 1 ; c790 -wc791:: ds 1 ; c791 -wc792:: ds 1 ; c792 -wc793:: ds 1 ; c793 -wc794:: ds 1 ; c794 -wc795:: ds 1 ; c795 -wc796:: ds 1 ; c796 -wc797:: ds 1 ; c797 -wc798:: ds 1 ; c798 -wc799:: ds 1 ; c799 -wc79a:: ds 1 ; c79a -wc79b:: ds 1 ; c79b -wc79c:: ds 1 ; c79c -wc79d:: ds 1 ; c79d -wc79e:: ds 1 ; c79e -wc79f:: ds 1 ; c79f -wc7a0:: ds 1 ; c7a0 -wc7a1:: ds 1 ; c7a1 -wc7a2:: ds 1 ; c7a2 -wc7a3:: ds 1 ; c7a3 -wc7a4:: ds 1 ; c7a4 -wc7a5:: ds 1 ; c7a5 -wc7a6:: ds 1 ; c7a6 -wc7a7:: ds 1 ; c7a7 -wc7a8:: ds 1 ; c7a8 -wc7a9:: ds 1 ; c7a9 -wc7aa:: ds 1 ; c7aa -wc7ab:: ds 1 ; c7ab -wc7ac:: ds 1 ; c7ac -wc7ad:: ds 1 ; c7ad -wc7ae:: ds 1 ; c7ae -wc7af:: ds 1 ; c7af -wc7b0:: ds 1 ; c7b0 -wc7b1:: ds 1 ; c7b1 -wc7b2:: ds 1 ; c7b2 -wc7b3:: ds 1 ; c7b3 -wc7b4:: ds 1 ; c7b4 -wc7b5:: ds 1 ; c7b5 -wc7b6:: ds 1 ; c7b6 -wc7b7:: ds 1 ; c7b7 -wc7b8:: ds 1 ; c7b8 -wc7b9:: ds 1 ; c7b9 -wc7ba:: ds 1 ; c7ba -wc7bb:: ds 1 ; c7bb -wc7bc:: ds 1 ; c7bc -wc7bd:: ds 1 ; c7bd -wc7be:: ds 1 ; c7be -wc7bf:: ds 1 ; c7bf -wc7c0:: ds 1 ; c7c0 -wc7c1:: ds 1 ; c7c1 -wc7c2:: ds 1 ; c7c2 -wc7c3:: ds 1 ; c7c3 -wc7c4:: ds 1 ; c7c4 -wc7c5:: ds 1 ; c7c5 -wc7c6:: ds 1 ; c7c6 -wc7c7:: ds 1 ; c7c7 -wc7c8:: ds 1 ; c7c8 -wc7c9:: ds 1 ; c7c9 -wc7ca:: ds 1 ; c7ca -wc7cb:: ds 1 ; c7cb -wc7cc:: ds 1 ; c7cc -wc7cd:: ds 1 ; c7cd -wc7ce:: ds 1 ; c7ce -wc7cf:: ds 1 ; c7cf -wc7d0:: ds 1 ; c7d0 -wc7d1:: ds 1 ; c7d1 -wc7d2:: ds 1 ; c7d2 -wc7d3:: ds 1 ; c7d3 -wc7d4:: ds 1 ; c7d4 -wc7d5:: ds 1 ; c7d5 -wc7d6:: ds 1 ; c7d6 -wc7d7:: ds 1 ; c7d7 -wc7d8:: ds 1 ; c7d8 -wc7d9:: ds 1 ; c7d9 -wc7da:: ds 1 ; c7da -wc7db:: ds 1 ; c7db -wc7dc:: ds 1 ; c7dc -wc7dd:: ds 1 ; c7dd -wc7de:: ds 1 ; c7de -wc7df:: ds 1 ; c7df -wc7e0:: ds 1 ; c7e0 -wc7e1:: ds 1 ; c7e1 -wc7e2:: ds 1 ; c7e2 -wc7e3:: ds 1 ; c7e3 -wc7e4:: ds 1 ; c7e4 -wc7e5:: ds 1 ; c7e5 -wc7e6:: ds 1 ; c7e6 -wc7e7:: ds 1 ; c7e7 -wc7e8:: ds 1 ; c7e8 -wc7e9:: ds 1 ; c7e9 -wc7ea:: ds 1 ; c7ea -wc7eb:: ds 1 ; c7eb -wc7ec:: ds 1 ; c7ec -wc7ed:: ds 1 ; c7ed -wc7ee:: ds 1 ; c7ee -wc7ef:: ds 1 ; c7ef -wc7f0:: ds 1 ; c7f0 -wc7f1:: ds 1 ; c7f1 -wc7f2:: ds 1 ; c7f2 -wc7f3:: ds 1 ; c7f3 -wc7f4:: ds 1 ; c7f4 -wc7f5:: ds 1 ; c7f5 -wc7f6:: ds 1 ; c7f6 -wc7f7:: ds 1 ; c7f7 -wc7f8:: ds 1 ; c7f8 -wc7f9:: ds 1 ; c7f9 -wc7fa:: ds 1 ; c7fa -wc7fb:: ds 1 ; c7fb -wc7fc:: ds 1 ; c7fc -wc7fd:: ds 1 ; c7fd -wc7fe:: ds 1 ; c7fe -wc7ff:: ds 1 ; c7ff - -wLYOverridesBackup:: -wc800:: ds 1 ; c800 -wc801:: ds 1 ; c801 -wc802:: ds 1 ; c802 -wMysteryGiftPartnerName:: -wc803:: ds 1 ; c803 -wc804:: ds 1 ; c804 -wc805:: ds 1 ; c805 -wc806:: ds 1 ; c806 -wc807:: ds 1 ; c807 -wc808:: ds 1 ; c808 -wc809:: ds 1 ; c809 -wc80a:: ds 1 ; c80a -wc80b:: ds 1 ; c80b -wc80c:: ds 1 ; c80c -wc80d:: ds 1 ; c80d -wc80e:: ds 1 ; c80e -wc80f:: ds 1 ; c80f -wc810:: ds 1 ; c810 -wc811:: ds 1 ; c811 -wc812:: ds 1 ; c812 -wc813:: ds 1 ; c813 -wc814:: ds 1 ; c814 -wc815:: ds 1 ; c815 -wc816:: ds 1 ; c816 -wc817:: ds 1 ; c817 -wc818:: ds 1 ; c818 -wc819:: ds 1 ; c819 -wc81a:: ds 1 ; c81a -wc81b:: ds 1 ; c81b -wc81c:: ds 1 ; c81c -wc81d:: ds 1 ; c81d -wc81e:: ds 1 ; c81e -wc81f:: ds 1 ; c81f -wc820:: ds 1 ; c820 -wc821:: ds 1 ; c821 -wc822:: ds 1 ; c822 -wc823:: ds 1 ; c823 -wc824:: ds 1 ; c824 -wc825:: ds 1 ; c825 -wc826:: ds 1 ; c826 -wc827:: ds 1 ; c827 -wc828:: ds 1 ; c828 -wc829:: ds 1 ; c829 -wc82a:: ds 1 ; c82a -wc82b:: ds 1 ; c82b -wc82c:: ds 1 ; c82c -wc82d:: ds 1 ; c82d -wc82e:: ds 1 ; c82e -wc82f:: ds 1 ; c82f -wc830:: ds 1 ; c830 -wc831:: ds 1 ; c831 -wc832:: ds 1 ; c832 -wc833:: ds 1 ; c833 -wc834:: ds 1 ; c834 -wc835:: ds 1 ; c835 -wc836:: ds 1 ; c836 -wc837:: ds 1 ; c837 -wc838:: ds 1 ; c838 -wc839:: ds 1 ; c839 -wc83a:: ds 1 ; c83a -wc83b:: ds 1 ; c83b -wc83c:: ds 1 ; c83c -wc83d:: ds 1 ; c83d -wc83e:: ds 1 ; c83e -wc83f:: ds 1 ; c83f -wc840:: ds 1 ; c840 -wc841:: ds 1 ; c841 -wc842:: ds 1 ; c842 -wc843:: ds 1 ; c843 -wc844:: ds 1 ; c844 -wc845:: ds 1 ; c845 -wc846:: ds 1 ; c846 -wc847:: ds 1 ; c847 -wc848:: ds 1 ; c848 -wc849:: ds 1 ; c849 -wc84a:: ds 1 ; c84a -wc84b:: ds 1 ; c84b -wc84c:: ds 1 ; c84c -wc84d:: ds 1 ; c84d -wc84e:: ds 1 ; c84e -wc84f:: ds 1 ; c84f -wc850:: ds 1 ; c850 -wc851:: ds 1 ; c851 -wc852:: ds 1 ; c852 -wMysteryGiftPlayerName:: -wc853:: ds 1 ; c853 -wc854:: ds 1 ; c854 -wc855:: ds 1 ; c855 -wc856:: ds 1 ; c856 -wc857:: ds 1 ; c857 -wc858:: ds 1 ; c858 -wc859:: ds 1 ; c859 -wc85a:: ds 1 ; c85a -wc85b:: ds 1 ; c85b -wc85c:: ds 1 ; c85c -wc85d:: ds 1 ; c85d -wc85e:: ds 1 ; c85e -wc85f:: ds 1 ; c85f -wc860:: ds 1 ; c860 -wc861:: ds 1 ; c861 -wc862:: ds 1 ; c862 -wc863:: ds 1 ; c863 -wc864:: ds 1 ; c864 -wc865:: ds 1 ; c865 -wc866:: ds 1 ; c866 -wc867:: ds 1 ; c867 -wc868:: ds 1 ; c868 -wc869:: ds 1 ; c869 -wc86a:: ds 1 ; c86a -wc86b:: ds 1 ; c86b -wc86c:: ds 1 ; c86c -wc86d:: ds 1 ; c86d -wc86e:: ds 1 ; c86e -wc86f:: ds 1 ; c86f -wc870:: ds 1 ; c870 -wc871:: ds 1 ; c871 -wc872:: ds 1 ; c872 -wc873:: ds 1 ; c873 -wc874:: ds 1 ; c874 -wc875:: ds 1 ; c875 -wc876:: ds 1 ; c876 -wc877:: ds 1 ; c877 -wc878:: ds 1 ; c878 -wc879:: ds 1 ; c879 -wc87a:: ds 1 ; c87a -wc87b:: ds 1 ; c87b -wc87c:: ds 1 ; c87c -wc87d:: ds 1 ; c87d -wc87e:: ds 1 ; c87e -wc87f:: ds 1 ; c87f -wc880:: ds 1 ; c880 -wc881:: ds 1 ; c881 -wc882:: ds 1 ; c882 -wc883:: ds 1 ; c883 -wc884:: ds 1 ; c884 -wc885:: ds 1 ; c885 -wc886:: ds 1 ; c886 -wc887:: ds 1 ; c887 -wc888:: ds 1 ; c888 -wc889:: ds 1 ; c889 -wc88a:: ds 1 ; c88a -wc88b:: ds 1 ; c88b -wc88c:: ds 1 ; c88c -wc88d:: ds 1 ; c88d -wc88e:: ds 1 ; c88e -wc88f:: ds 1 ; c88f +UNION ; c700 +; overworld map blocks +wOverworldMapBlocks:: ds 1300 ; c700 +wOverworldMapBlocksEnd:: + +NEXTU ; c700 +; GB Printer data +wGameboyPrinter2bppSource:: ds 40 tiles +wGameboyPrinter2bppSourceEnd:: +wc980:: db +wPrinterRowIndex:: db + +; Printer data +wPrinterData:: ds 4 +wPrinterChecksum:: dw ; c986 +wPrinterHandshake:: db +wPrinterStatusFlags:: +; bit 7: set if error 1 (battery low) +; bit 6: set if error 4 (too hot or cold) +; bit 5: set if error 3 (paper jammed or empty) +; if this and the previous byte are both $ff: error 2 (connection error) + db + +wHandshakeFrameDelay:: db +wPrinterSerialFrameDelay:: db +wPrinterSendByteOffset:: dw +wPrinterSendByteCounter:: dw + +; tilemap backup? +wPrinterTilemapBuffer:: ds SCREEN_HEIGHT * SCREEN_WIDTH ; c990 +wPrinterTilemapBufferEnd:: +wPrinterStatus:: db ; caf8 + ds 1 +; High nibble is for margin before the image, low nibble is for after. +wPrinterMargins:: db ; cafa +wPrinterExposureTime:: db ; cafb + ds 16 +wGameboyPrinterRAMEnd:: + +NEXTU ; c700 +; Hall of Fame data +wHallOfFamePokemonList:: hall_of_fame wHallOfFamePokemonList + +NEXTU ; c700 +; raw link data +wLinkData:: ds $514 +wLinkDataEnd:: + +NEXTU ; c700 +; link data members +wLinkPlayerName:: ds NAME_LENGTH +wLinkPartyCount:: db +wLinkPartySpecies:: ds PARTY_LENGTH +wLinkPartyEnd:: db ; older code doesn't check PartyCount + +UNION ; c713 +; time capsule party data +wTimeCapsulePlayerData:: +wTimeCapsulePartyMon1:: red_party_struct wTimeCapsulePartyMon1 +wTimeCapsulePartyMon2:: red_party_struct wTimeCapsulePartyMon2 +wTimeCapsulePartyMon3:: red_party_struct wTimeCapsulePartyMon3 +wTimeCapsulePartyMon4:: red_party_struct wTimeCapsulePartyMon4 +wTimeCapsulePartyMon5:: red_party_struct wTimeCapsulePartyMon5 +wTimeCapsulePartyMon6:: red_party_struct wTimeCapsulePartyMon6 +wTimeCapsulePartyMonOTNames:: ds PARTY_LENGTH * NAME_LENGTH +wTimeCapsulePartyMonNicks:: ds PARTY_LENGTH * MON_NAME_LENGTH +wTimeCapsulePlayerDataEnd:: + +NEXTU ; c713 +; link player data +wLinkPlayerData:: +wLinkPlayerPartyMon1:: party_struct wLinkPlayerPartyMon1 +wLinkPlayerPartyMon2:: party_struct wLinkPlayerPartyMon2 +wLinkPlayerPartyMon3:: party_struct wLinkPlayerPartyMon3 +wLinkPlayerPartyMon4:: party_struct wLinkPlayerPartyMon4 +wLinkPlayerPartyMon5:: party_struct wLinkPlayerPartyMon5 +wLinkPlayerPartyMon6:: party_struct wLinkPlayerPartyMon6 +wLinkPlayerPartyMonOTNames:: ds PARTY_LENGTH * NAME_LENGTH +wLinkPlayerPartyMonNicks:: ds PARTY_LENGTH * MON_NAME_LENGTH +wLinkPlayerDataEnd:: +ENDU + +NEXTU ; c700 + + ds 80 + +wMysteryGiftTrainerData:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2 +wMysteryGiftTrainerDataEnd:: + + ds 138 + +wMysteryGiftPartnerData:: +wc800:: db +wMysteryGiftPartnerID:: dw +wMysteryGiftPartnerName:: ds NAME_LENGTH +wMysteryGiftPartnerDexCaught:: db +wc80f:: +wMysteryGiftPartnerSentDeco:: db +wMysteryGiftPartnerWhichItem:: db +wMysteryGiftPartnerWhichDeco:: db +wMysteryGiftPartnerBackupItem:: db + ds 1 +wMysteryGiftPartnerDataEnd:: + + ds 60 + +wMysteryGiftPlayerData:: + ds 1 +wMysteryGiftPlayerID:: dw +wMysteryGiftPlayerName:: ds NAME_LENGTH +wMysteryGiftPlayerDexCaught:: db +wMysteryGiftPlayerSentDeco:: db +wMysteryGiftPlayerWhichItem:: db +wMysteryGiftPlayerWhichDeco:: db +wMysteryGiftPlayerBackupItem:: db + ds 1 +wMysteryGiftPlayerDataEnd:: + + ds 144 + +wc8f4:: ds 5 +wc8f9:: ds 7 + +wc900:: db +wc901:: db +wc902:: db + +NEXTU ; c700 +wLYOverrides:: ds 144 +wLYOverridesEnd:: ds 112 + +wLYOverridesBackup:: ds 144 wLYOverridesBackupEnd:: -wc890:: ds 1 ; c890 -wc891:: ds 1 ; c891 -wc892:: ds 1 ; c892 -wc893:: ds 1 ; c893 -wc894:: ds 1 ; c894 -wc895:: ds 1 ; c895 -wc896:: ds 1 ; c896 -wc897:: ds 1 ; c897 -wc898:: ds 1 ; c898 -wc899:: ds 1 ; c899 -wc89a:: ds 1 ; c89a -wc89b:: ds 1 ; c89b -wc89c:: ds 1 ; c89c -wc89d:: ds 1 ; c89d -wc89e:: ds 1 ; c89e -wc89f:: ds 1 ; c89f -wc8a0:: ds 1 ; c8a0 -wc8a1:: ds 1 ; c8a1 -wc8a2:: ds 1 ; c8a2 -wc8a3:: ds 1 ; c8a3 -wc8a4:: ds 1 ; c8a4 -wc8a5:: ds 1 ; c8a5 -wc8a6:: ds 1 ; c8a6 -wc8a7:: ds 1 ; c8a7 -wc8a8:: ds 1 ; c8a8 -wc8a9:: ds 1 ; c8a9 -wc8aa:: ds 1 ; c8aa -wc8ab:: ds 1 ; c8ab -wc8ac:: ds 1 ; c8ac -wc8ad:: ds 1 ; c8ad -wc8ae:: ds 1 ; c8ae -wc8af:: ds 1 ; c8af -wc8b0:: ds 1 ; c8b0 -wc8b1:: ds 1 ; c8b1 -wc8b2:: ds 1 ; c8b2 -wc8b3:: ds 1 ; c8b3 -wc8b4:: ds 1 ; c8b4 -wc8b5:: ds 1 ; c8b5 -wc8b6:: ds 1 ; c8b6 -wc8b7:: ds 1 ; c8b7 -wc8b8:: ds 1 ; c8b8 -wc8b9:: ds 1 ; c8b9 -wc8ba:: ds 1 ; c8ba -wc8bb:: ds 1 ; c8bb -wc8bc:: ds 1 ; c8bc -wc8bd:: ds 1 ; c8bd -wc8be:: ds 1 ; c8be -wc8bf:: ds 1 ; c8bf -wc8c0:: ds 1 ; c8c0 -wc8c1:: ds 1 ; c8c1 -wc8c2:: ds 1 ; c8c2 -wc8c3:: ds 1 ; c8c3 -wc8c4:: ds 1 ; c8c4 -wc8c5:: ds 1 ; c8c5 -wc8c6:: ds 1 ; c8c6 -wc8c7:: ds 1 ; c8c7 -wc8c8:: ds 1 ; c8c8 -wc8c9:: ds 1 ; c8c9 -wc8ca:: ds 1 ; c8ca -wc8cb:: ds 1 ; c8cb -wc8cc:: ds 1 ; c8cc -wc8cd:: ds 1 ; c8cd -wc8ce:: ds 1 ; c8ce -wc8cf:: ds 1 ; c8cf -wc8d0:: ds 1 ; c8d0 -wc8d1:: ds 1 ; c8d1 -wc8d2:: ds 1 ; c8d2 -wc8d3:: ds 1 ; c8d3 -wc8d4:: ds 1 ; c8d4 -wc8d5:: ds 1 ; c8d5 -wc8d6:: ds 1 ; c8d6 -wc8d7:: ds 1 ; c8d7 -wc8d8:: ds 1 ; c8d8 -wc8d9:: ds 1 ; c8d9 -wc8da:: ds 1 ; c8da -wc8db:: ds 1 ; c8db -wc8dc:: ds 1 ; c8dc -wc8dd:: ds 1 ; c8dd -wc8de:: ds 1 ; c8de -wc8df:: ds 1 ; c8df -wc8e0:: ds 1 ; c8e0 -wc8e1:: ds 1 ; c8e1 -wc8e2:: ds 1 ; c8e2 -wc8e3:: ds 1 ; c8e3 -wc8e4:: ds 1 ; c8e4 -wc8e5:: ds 1 ; c8e5 -wc8e6:: ds 1 ; c8e6 -wc8e7:: ds 1 ; c8e7 -wc8e8:: ds 1 ; c8e8 -wc8e9:: ds 1 ; c8e9 -wc8ea:: ds 1 ; c8ea -wc8eb:: ds 1 ; c8eb -wc8ec:: ds 1 ; c8ec -wc8ed:: ds 1 ; c8ed -wc8ee:: ds 1 ; c8ee -wc8ef:: ds 1 ; c8ef -wc8f0:: ds 1 ; c8f0 -wc8f1:: ds 1 ; c8f1 -wc8f2:: ds 1 ; c8f2 -wc8f3:: ds 1 ; c8f3 -wc8f4:: ds 1 ; c8f4 -wc8f5:: ds 1 ; c8f5 -wc8f6:: ds 1 ; c8f6 -wc8f7:: ds 1 ; c8f7 -wc8f8:: ds 1 ; c8f8 -wc8f9:: ds 1 ; c8f9 -wc8fa:: ds 1 ; c8fa -wc8fb:: ds 1 ; c8fb -wc8fc:: ds 1 ; c8fc -wc8fd:: ds 1 ; c8fd -wc8fe:: ds 1 ; c8fe -wc8ff:: ds 1 ; c8ff -wc900:: ds 1 ; c900 -wc901:: ds 1 ; c901 -wc902:: ds 1 ; c902 -wc903:: ds 1 ; c903 -wc904:: ds 1 ; c904 -wc905:: ds 1 ; c905 -wc906:: ds 1 ; c906 -wc907:: ds 1 ; c907 -wc908:: ds 1 ; c908 -wc909:: ds 1 ; c909 -wc90a:: ds 1 ; c90a -wc90b:: ds 1 ; c90b -wc90c:: ds 1 ; c90c -wc90d:: ds 1 ; c90d -wc90e:: ds 1 ; c90e -wc90f:: ds 1 ; c90f -wc910:: ds 1 ; c910 -wc911:: ds 1 ; c911 -wc912:: ds 1 ; c912 -wc913:: ds 1 ; c913 -wc914:: ds 1 ; c914 -wc915:: ds 1 ; c915 -wc916:: ds 1 ; c916 -wc917:: ds 1 ; c917 -wc918:: ds 1 ; c918 -wc919:: ds 1 ; c919 -wc91a:: ds 1 ; c91a -wc91b:: ds 1 ; c91b -wc91c:: ds 1 ; c91c -wc91d:: ds 1 ; c91d -wc91e:: ds 1 ; c91e -wc91f:: ds 1 ; c91f -wc920:: ds 1 ; c920 -wc921:: ds 1 ; c921 -wc922:: ds 1 ; c922 -wc923:: ds 1 ; c923 -wc924:: ds 1 ; c924 -wc925:: ds 1 ; c925 -wc926:: ds 1 ; c926 -wc927:: ds 1 ; c927 -wc928:: ds 1 ; c928 -wc929:: ds 1 ; c929 -wc92a:: ds 1 ; c92a -wc92b:: ds 1 ; c92b -wc92c:: ds 1 ; c92c -wc92d:: ds 1 ; c92d -wc92e:: ds 1 ; c92e -wc92f:: ds 1 ; c92f -wc930:: ds 1 ; c930 -wc931:: ds 1 ; c931 -wc932:: ds 1 ; c932 -wc933:: ds 1 ; c933 -wc934:: ds 1 ; c934 -wc935:: ds 1 ; c935 -wc936:: ds 1 ; c936 -wc937:: ds 1 ; c937 -wc938:: ds 1 ; c938 -wc939:: ds 1 ; c939 -wc93a:: ds 1 ; c93a -wc93b:: ds 1 ; c93b -wc93c:: ds 1 ; c93c -wc93d:: ds 1 ; c93d -wc93e:: ds 1 ; c93e -wc93f:: ds 1 ; c93f -wc940:: ds 1 ; c940 -wc941:: ds 1 ; c941 -wc942:: ds 1 ; c942 -wc943:: ds 1 ; c943 -wc944:: ds 1 ; c944 -wc945:: ds 1 ; c945 -wc946:: ds 1 ; c946 -wc947:: ds 1 ; c947 -wc948:: ds 1 ; c948 -wc949:: ds 1 ; c949 -wc94a:: ds 1 ; c94a -wc94b:: ds 1 ; c94b -wc94c:: ds 1 ; c94c -wc94d:: ds 1 ; c94d -wc94e:: ds 1 ; c94e -wc94f:: ds 1 ; c94f -wc950:: ds 1 ; c950 -wc951:: ds 1 ; c951 -wc952:: ds 1 ; c952 -wc953:: ds 1 ; c953 -wc954:: ds 1 ; c954 -wc955:: ds 1 ; c955 -wc956:: ds 1 ; c956 -wc957:: ds 1 ; c957 -wc958:: ds 1 ; c958 -wc959:: ds 1 ; c959 -wc95a:: ds 1 ; c95a -wc95b:: ds 1 ; c95b -wc95c:: ds 1 ; c95c -wc95d:: ds 1 ; c95d -wc95e:: ds 1 ; c95e -wc95f:: ds 1 ; c95f -wc960:: ds 1 ; c960 -wc961:: ds 1 ; c961 -wc962:: ds 1 ; c962 -wc963:: ds 1 ; c963 -wc964:: ds 1 ; c964 -wc965:: ds 1 ; c965 -wc966:: ds 1 ; c966 -wc967:: ds 1 ; c967 -wc968:: ds 1 ; c968 -wc969:: ds 1 ; c969 -wc96a:: ds 1 ; c96a -wc96b:: ds 1 ; c96b -wc96c:: ds 1 ; c96c -wc96d:: ds 1 ; c96d -wc96e:: ds 1 ; c96e -wc96f:: ds 1 ; c96f -wc970:: ds 1 ; c970 -wc971:: ds 1 ; c971 -wc972:: ds 1 ; c972 -wc973:: ds 1 ; c973 -wc974:: ds 1 ; c974 -wc975:: ds 1 ; c975 -wc976:: ds 1 ; c976 -wc977:: ds 1 ; c977 -wc978:: ds 1 ; c978 -wc979:: ds 1 ; c979 -wc97a:: ds 1 ; c97a -wc97b:: ds 1 ; c97b -wc97c:: ds 1 ; c97c -wc97d:: ds 1 ; c97d -wc97e:: ds 1 ; c97e -wc97f:: ds 1 ; c97f -wc980:: ds 1 ; c980 -wc981:: ds 1 ; c981 -wc982:: ds 1 ; c982 -wc983:: ds 1 ; c983 -wc984:: ds 1 ; c984 -wc985:: ds 1 ; c985 -wc986:: ds 1 ; c986 -wc987:: ds 1 ; c987 -wc988:: ds 1 ; c988 -wc989:: ds 1 ; c989 -wHandshakeFrameDelay:: ds 1 ; c98a -wc98b:: ds 1 ; c98b -wc98c:: ds 1 ; c98c -wc98d:: ds 1 ; c98d -wc98e:: ds 1 ; c98e -wc98f:: ds 1 ; c98f -wc990:: ds 1 ; c990 -wc991:: ds 1 ; c991 -wc992:: ds 1 ; c992 -wc993:: ds 1 ; c993 -wc994:: ds 1 ; c994 -wc995:: ds 1 ; c995 -wc996:: ds 1 ; c996 -wc997:: ds 1 ; c997 -wc998:: ds 1 ; c998 -wc999:: ds 1 ; c999 -wc99a:: ds 1 ; c99a -wc99b:: ds 1 ; c99b -wc99c:: ds 1 ; c99c -wc99d:: ds 1 ; c99d -wc99e:: ds 1 ; c99e -wc99f:: ds 1 ; c99f -wc9a0:: ds 1 ; c9a0 -wc9a1:: ds 1 ; c9a1 -wc9a2:: ds 1 ; c9a2 -wc9a3:: ds 1 ; c9a3 -wc9a4:: ds 1 ; c9a4 -wc9a5:: ds 1 ; c9a5 -wc9a6:: ds 1 ; c9a6 -wc9a7:: ds 1 ; c9a7 -wc9a8:: ds 1 ; c9a8 -wc9a9:: ds 1 ; c9a9 -wc9aa:: ds 1 ; c9aa -wc9ab:: ds 1 ; c9ab -wc9ac:: ds 1 ; c9ac -wc9ad:: ds 1 ; c9ad -wc9ae:: ds 1 ; c9ae -wc9af:: ds 1 ; c9af -wc9b0:: ds 1 ; c9b0 -wc9b1:: ds 1 ; c9b1 -wc9b2:: ds 1 ; c9b2 -wc9b3:: ds 1 ; c9b3 -wc9b4:: ds 1 ; c9b4 -wc9b5:: ds 1 ; c9b5 -wc9b6:: ds 1 ; c9b6 -wc9b7:: ds 1 ; c9b7 -wc9b8:: ds 1 ; c9b8 -wc9b9:: ds 1 ; c9b9 -wc9ba:: ds 1 ; c9ba -wc9bb:: ds 1 ; c9bb -wc9bc:: ds 1 ; c9bc -wc9bd:: ds 1 ; c9bd -wc9be:: ds 1 ; c9be -wc9bf:: ds 1 ; c9bf -wc9c0:: ds 1 ; c9c0 -wc9c1:: ds 1 ; c9c1 -wc9c2:: ds 1 ; c9c2 -wc9c3:: ds 1 ; c9c3 -wc9c4:: ds 1 ; c9c4 -wc9c5:: ds 1 ; c9c5 -wc9c6:: ds 1 ; c9c6 -wc9c7:: ds 1 ; c9c7 -wc9c8:: ds 1 ; c9c8 -wc9c9:: ds 1 ; c9c9 -wc9ca:: ds 1 ; c9ca -wc9cb:: ds 1 ; c9cb -wc9cc:: ds 1 ; c9cc -wc9cd:: ds 1 ; c9cd -wc9ce:: ds 1 ; c9ce -wc9cf:: ds 1 ; c9cf -wc9d0:: ds 1 ; c9d0 -wc9d1:: ds 1 ; c9d1 -wc9d2:: ds 1 ; c9d2 -wc9d3:: ds 1 ; c9d3 -wc9d4:: ds 1 ; c9d4 -wc9d5:: ds 1 ; c9d5 -wc9d6:: ds 1 ; c9d6 -wc9d7:: ds 1 ; c9d7 -wc9d8:: ds 1 ; c9d8 -wc9d9:: ds 1 ; c9d9 -wc9da:: ds 1 ; c9da -wc9db:: ds 1 ; c9db -wc9dc:: ds 1 ; c9dc -wc9dd:: ds 1 ; c9dd -wc9de:: ds 1 ; c9de -wc9df:: ds 1 ; c9df -wc9e0:: ds 1 ; c9e0 -wc9e1:: ds 1 ; c9e1 -wc9e2:: ds 1 ; c9e2 -wc9e3:: ds 1 ; c9e3 -wc9e4:: ds 1 ; c9e4 -wc9e5:: ds 1 ; c9e5 -wc9e6:: ds 1 ; c9e6 -wc9e7:: ds 1 ; c9e7 -wc9e8:: ds 1 ; c9e8 -wc9e9:: ds 1 ; c9e9 -wc9ea:: ds 1 ; c9ea -wc9eb:: ds 1 ; c9eb -wc9ec:: ds 1 ; c9ec -wc9ed:: ds 1 ; c9ed -wc9ee:: ds 1 ; c9ee -wc9ef:: ds 1 ; c9ef -wc9f0:: ds 1 ; c9f0 -wc9f1:: ds 1 ; c9f1 -wc9f2:: ds 1 ; c9f2 -wc9f3:: ds 1 ; c9f3 -wc9f4:: ds 1 ; c9f4 -wc9f5:: ds 1 ; c9f5 -wc9f6:: ds 1 ; c9f6 -wc9f7:: ds 1 ; c9f7 -wc9f8:: ds 1 ; c9f8 -wc9f9:: ds 1 ; c9f9 -wc9fa:: ds 1 ; c9fa -wc9fb:: ds 1 ; c9fb -wc9fc:: ds 1 ; c9fc -wc9fd:: ds 1 ; c9fd -wc9fe:: ds 1 ; c9fe -wc9ff:: ds 1 ; c9ff -wca00:: ds 1 ; ca00 -wca01:: ds 1 ; ca01 -wca02:: ds 1 ; ca02 -wca03:: ds 1 ; ca03 -wca04:: ds 1 ; ca04 -wca05:: ds 1 ; ca05 -wca06:: ds 1 ; ca06 -wca07:: ds 1 ; ca07 -wca08:: ds 1 ; ca08 -wca09:: ds 1 ; ca09 -wca0a:: ds 1 ; ca0a -wca0b:: ds 1 ; ca0b -wca0c:: ds 1 ; ca0c -wca0d:: ds 1 ; ca0d -wca0e:: ds 1 ; ca0e -wca0f:: ds 1 ; ca0f + +NEXTU ; c700 + + ds $5f + +wc75f:: db + + ds $25f + +UNION ; c9bf +; link +wc9bf:: ds 79 +wca0e:: ds 5 +wca13:: ds 50 +wca45:: ds 20 +wca59:: ds 20 +wca6d:: ds 1 +wca6e:: ds 22 +wca84:: ds 100 +wcae8:: dw +wLinkOTPartyMonTypes:: ds 2 * PARTY_LENGTH + ds 84 +wcb4a:: ds 22 + +wcb60:: ds 1 +wcb61:: ds 1 +wcb62:: ds 2 +wcb64:: ds 1 +wcb65:: ds 57 +wcb9e:: ds 22 +wcbb4:: ds 1 +wcbb5:: ds 3 +wcbb8:: ds 1 +wcbb9:: ds 1 +wcbba:: ds 102 + +NEXTU ; c9bf +; battle + ds 81 wBattleAnimAddress:: dw ; ca10 -wca12:: ds 1 ; ca12 -wca13:: ds 1 ; ca13 -wca14:: ds 1 ; ca14 -wca15:: ds 1 ; ca15 -wca16:: ds 1 ; ca16 +wBattleAnimDelay:: db ; ca12 +wBattleAnimParent:: dw ; ca13 +wBattleAnimLoops:: db ; ca15 +wBattleAnimVar:: db ; ca16 wBattleAnimByte:: db ; ca17 -wca18:: ds 1 ; ca18 -wca19:: ds 1 ; ca19 -wca1a:: ds 1 ; ca1a -wca1b:: ds 1 ; ca1b -wca1c:: ds 1 ; ca1c -wca1d:: ds 1 ; ca1d -wca1e:: ds 1 ; ca1e -wca1f:: ds 1 ; ca1f -wca20:: ds 1 ; ca20 -wca21:: ds 1 ; ca21 -wca22:: ds 1 ; ca22 -wca23:: ds 1 ; ca23 -wca24:: ds 1 ; ca24 -wca25:: ds 1 ; ca25 -wca26:: ds 1 ; ca26 -wca27:: ds 1 ; ca27 -wca28:: ds 1 ; ca28 -wca29:: ds 1 ; ca29 -wca2a:: ds 1 ; ca2a -wca2b:: ds 1 ; ca2b -wca2c:: ds 1 ; ca2c -wca2d:: ds 1 ; ca2d -wca2e:: ds 1 ; ca2e -wca2f:: ds 1 ; ca2f -wca30:: ds 1 ; ca30 -wca31:: ds 1 ; ca31 -wca32:: ds 1 ; ca32 -wca33:: ds 1 ; ca33 -wca34:: ds 1 ; ca34 -wca35:: ds 1 ; ca35 -wca36:: ds 1 ; ca36 -wca37:: ds 1 ; ca37 -wca38:: ds 1 ; ca38 -wca39:: ds 1 ; ca39 -wca3a:: ds 1 ; ca3a -wca3b:: ds 1 ; ca3b -wca3c:: ds 1 ; ca3c -wca3d:: ds 1 ; ca3d -wca3e:: ds 1 ; ca3e -wca3f:: ds 1 ; ca3f -wca40:: ds 1 ; ca40 -wca41:: ds 1 ; ca41 -wca42:: ds 1 ; ca42 -wca43:: ds 1 ; ca43 -wca44:: ds 1 ; ca44 -wca45:: ds 1 ; ca45 -wca46:: ds 1 ; ca46 -wca47:: ds 1 ; ca47 -wca48:: ds 1 ; ca48 -wca49:: ds 1 ; ca49 -wca4a:: ds 1 ; ca4a -wca4b:: ds 1 ; ca4b -wca4c:: ds 1 ; ca4c -wca4d:: ds 1 ; ca4d -wca4e:: ds 1 ; ca4e -wca4f:: ds 1 ; ca4f -wca50:: ds 1 ; ca50 -wca51:: ds 1 ; ca51 -wca52:: ds 1 ; ca52 -wca53:: ds 1 ; ca53 -wca54:: ds 1 ; ca54 -wca55:: ds 1 ; ca55 -wca56:: ds 1 ; ca56 -wca57:: ds 1 ; ca57 -wca58:: ds 1 ; ca58 -wca59:: ds 1 ; ca59 -wca5a:: ds 1 ; ca5a -wca5b:: ds 1 ; ca5b -wca5c:: ds 1 ; ca5c -wca5d:: ds 1 ; ca5d -wca5e:: ds 1 ; ca5e -wca5f:: ds 1 ; ca5f -wca60:: ds 1 ; ca60 -wca61:: ds 1 ; ca61 -wca62:: ds 1 ; ca62 -wca63:: ds 1 ; ca63 -wca64:: ds 1 ; ca64 -wca65:: ds 1 ; ca65 -wca66:: ds 1 ; ca66 -wca67:: ds 1 ; ca67 -wca68:: ds 1 ; ca68 -wca69:: ds 1 ; ca69 -wca6a:: ds 1 ; ca6a -wca6b:: ds 1 ; ca6b -wca6c:: ds 1 ; ca6c -wca6d:: ds 1 ; ca6d -wca6e:: ds 1 ; ca6e -wca6f:: ds 1 ; ca6f -wca70:: ds 1 ; ca70 -wca71:: ds 1 ; ca71 -wca72:: ds 1 ; ca72 -wca73:: ds 1 ; ca73 -wca74:: ds 1 ; ca74 -wca75:: ds 1 ; ca75 -wca76:: ds 1 ; ca76 -wca77:: ds 1 ; ca77 -wca78:: ds 1 ; ca78 -wca79:: ds 1 ; ca79 -wca7a:: ds 1 ; ca7a -wca7b:: ds 1 ; ca7b -wca7c:: ds 1 ; ca7c -wca7d:: ds 1 ; ca7d -wca7e:: ds 1 ; ca7e -wca7f:: ds 1 ; ca7f -wca80:: ds 1 ; ca80 -wca81:: ds 1 ; ca81 -wca82:: ds 1 ; ca82 -wca83:: ds 1 ; ca83 -wca84:: ds 1 ; ca84 -wca85:: ds 1 ; ca85 -wca86:: ds 1 ; ca86 -wca87:: ds 1 ; ca87 -wca88:: ds 1 ; ca88 -wca89:: ds 1 ; ca89 -wca8a:: ds 1 ; ca8a -wca8b:: ds 1 ; ca8b -wca8c:: ds 1 ; ca8c -wca8d:: ds 1 ; ca8d -wca8e:: ds 1 ; ca8e -wca8f:: ds 1 ; ca8f -wca90:: ds 1 ; ca90 -wca91:: ds 1 ; ca91 -wca92:: ds 1 ; ca92 -wca93:: ds 1 ; ca93 -wca94:: ds 1 ; ca94 -wca95:: ds 1 ; ca95 -wca96:: ds 1 ; ca96 -wca97:: ds 1 ; ca97 -wca98:: ds 1 ; ca98 -wca99:: ds 1 ; ca99 -wca9a:: ds 1 ; ca9a -wca9b:: ds 1 ; ca9b -wca9c:: ds 1 ; ca9c -wca9d:: ds 1 ; ca9d -wca9e:: ds 1 ; ca9e -wca9f:: ds 1 ; ca9f -wcaa0:: ds 1 ; caa0 -wcaa1:: ds 1 ; caa1 -wcaa2:: ds 1 ; caa2 -wcaa3:: ds 1 ; caa3 -wcaa4:: ds 1 ; caa4 -wcaa5:: ds 1 ; caa5 -wcaa6:: ds 1 ; caa6 -wcaa7:: ds 1 ; caa7 -wcaa8:: ds 1 ; caa8 -wcaa9:: ds 1 ; caa9 -wcaaa:: ds 1 ; caaa -wcaab:: ds 1 ; caab -wcaac:: ds 1 ; caac -wcaad:: ds 1 ; caad -wcaae:: ds 1 ; caae -wcaaf:: ds 1 ; caaf -wcab0:: ds 1 ; cab0 -wcab1:: ds 1 ; cab1 -wcab2:: ds 1 ; cab2 -wcab3:: ds 1 ; cab3 -wcab4:: ds 1 ; cab4 -wcab5:: ds 1 ; cab5 -wcab6:: ds 1 ; cab6 -wcab7:: ds 1 ; cab7 -wcab8:: ds 1 ; cab8 -wcab9:: ds 1 ; cab9 -wcaba:: ds 1 ; caba -wcabb:: ds 1 ; cabb -wcabc:: ds 1 ; cabc -wcabd:: ds 1 ; cabd -wcabe:: ds 1 ; cabe -wcabf:: ds 1 ; cabf -wcac0:: ds 1 ; cac0 -wcac1:: ds 1 ; cac1 -wcac2:: ds 1 ; cac2 -wcac3:: ds 1 ; cac3 -wcac4:: ds 1 ; cac4 -wcac5:: ds 1 ; cac5 -wcac6:: ds 1 ; cac6 -wcac7:: ds 1 ; cac7 -wcac8:: ds 1 ; cac8 -wcac9:: ds 1 ; cac9 -wcaca:: ds 1 ; caca -wcacb:: ds 1 ; cacb -wcacc:: ds 1 ; cacc -wcacd:: ds 1 ; cacd -wcace:: ds 1 ; cace -wcacf:: ds 1 ; cacf -wcad0:: ds 1 ; cad0 -wcad1:: ds 1 ; cad1 -wcad2:: ds 1 ; cad2 -wcad3:: ds 1 ; cad3 -wcad4:: ds 1 ; cad4 -wcad5:: ds 1 ; cad5 -wcad6:: ds 1 ; cad6 -wcad7:: ds 1 ; cad7 -wcad8:: ds 1 ; cad8 -wcad9:: ds 1 ; cad9 -wcada:: ds 1 ; cada -wcadb:: ds 1 ; cadb -wcadc:: ds 1 ; cadc -wcadd:: ds 1 ; cadd -wcade:: ds 1 ; cade -wcadf:: ds 1 ; cadf -wcae0:: ds 1 ; cae0 -wcae1:: ds 1 ; cae1 -wcae2:: ds 1 ; cae2 -wcae3:: ds 1 ; cae3 -wcae4:: ds 1 ; cae4 -wcae5:: ds 1 ; cae5 -wcae6:: ds 1 ; cae6 -wcae7:: ds 1 ; cae7 +wBattleAnimOAMPointerLo:: db ; ca18 + + ds 207 wEnemyMoveStruct:: move_struct wEnemyMoveStruct wPlayerMoveStruct:: move_struct wPlayerMoveStruct @@ -1432,6 +609,7 @@ wEnemySubStatus2:: ds 1 ; cb4c wEnemySubStatus3:: ds 1 ; cb4d wEnemySubStatus4:: ds 1 ; cb4e wEnemySubStatus5:: ds 1 ; cb4f + wPlayerRolloutCount:: db ; cb50 wPlayerConfuseCount:: db ; cb51 wPlayerToxicCount:: db ; cb52 @@ -1440,6 +618,7 @@ wPlayerEncoreCount:: db ; cb54 wPlayerPerishCount:: db ; cb55 wPlayerFuryCutterCount:: db ; cb56 wPlayerProtectCount:: db ; cb57 + wEnemyRolloutCount:: db ; cb58 wEnemyConfuseCount:: db ; cb59 wEnemyToxicCount:: db ; cb5a @@ -1448,16 +627,11 @@ wEnemyEncoreCount:: db ; cb5c wEnemyPerishCount:: db ; cb5d wEnemyFuryCutterCount:: db ; cb5e wEnemyProtectCount:: db ; cb5f -wPlayerDamageTaken:: -wcb60:: ds 1 ; cb60 -wcb61:: ds 1 ; cb61 -wEnemyDamageTaken:: -wcb62:: ds 1 ; cb62 -wcb63:: ds 1 ; cb63 -wBattleReward:: -wcb64:: ds 1 ; cb64 -wcb65:: ds 1 ; cb65 -wcb66:: ds 1 ; cb66 + +wPlayerDamageTaken:: dw ; cb60 +wEnemyDamageTaken:: dw ; cb62 + +wBattleReward:: ds 3 ; cb64 wBattleAnimParam:: wKickCounter:: wPresentPower:: @@ -1632,14 +806,8 @@ wPlayerCharging:: db ; cc10 wEnemyCharging:: db ; cc11 wBattleEnded:: db ; cc12 -UNION wWildMonMoves:: ; cc13 ds NUM_MOVES -NEXTU - ds 1 -wOverworldMapBlocksEnd:: - ds NUM_MOVES - 1 -ENDU wWildMonPP:: ds NUM_MOVES ; cc17 @@ -1647,16 +815,16 @@ wAmuletCoin:: db ; cc1b wSomeoneIsRampaging:: db ; cc1c wPlayerJustGotFrozen:: db ; cc1d wEnemyJustGotFrozen:: db ; cc1e - ds 1 +ENDU ENDU ; cc20 SECTION "Video", WRAM0 ; wBGMapBuffer -wBGMapBuffer:: ds 40 ; cd20 -wBGMapPalBuffer:: ds 40 ; cd48 -wBGMapBufferPtrs:: ds 40 ; cd70 ; 20 bg map addresses (16x8 tiles) +wBGMapBuffer:: ds 40 ; cc20 +wBGMapPalBuffer:: ds 40 ; cc48 +wBGMapBufferPtrs:: ds 40 ; cc70 ; 20 bg map addresses (16x8 tiles) wBGMapBufferEnd:: wColorLayoutPredefID:: ds 1 ; cc98 @@ -2289,10 +1457,10 @@ ENDU ; cffc wcffc:: ds 1 ; cffc wcffd:: ds 1 ; cffd -wcffe:: ds 1 ; cffe -wcfff:: ds 1 ; cfff +wUnusedCFFE:: dw ; cffe + +SECTION "WRAM 1", WRAMX -SECTION "WRAM1", WRAMX, BANK[$1] wd000:: ds 1 ; d000 wd001:: ds 1 ; d001 wCurItem:: db ; d002 @@ -2450,6 +1618,19 @@ wEvolutionNewSpecies:: db ; d0d4 wEvolutionPicOffset:: db ; d0d5 wEvolutionCanceled:: db ; d0d6 +NEXTU + +wd0d3:: ds 1 +wd0d4:: ds 1 +wd0d5:: ds 1 +wd0d6:: ds 1 +wd0d7:: ds 1 +wd0d8:: ds 1 +wd0d9:: ds 1 +wd0da:: ds 1 +wd0db:: ds 1 +wd0dc:: ds 1 + NEXTU ; d0d3 ; miscellaneous wMagikarpLength:: dw @@ -2533,8 +1714,8 @@ wd147:: ds 1 ; d147 wd148:: ds 1 ; d148 wListMoves_MoveIndicesBuffer:: ds NUM_MOVES wPutativeTMHMMove:: db ; d14d -wd14e:: ds 1 ; d14e -wWildMon:: ds 1 ; d14f +wInitListType:: db ; d14e +wWildMon:: db ; d14f wBattleHasJustStarted:: db ; d150 ; d151 has many different short-term uses @@ -2667,7 +1848,7 @@ wOptions2:: ; d19e wOptionsEnd:: -SECTION "Game Data", WRAMX, BANK[1] +SECTION "Game Data", WRAMX wGameData:: wPlayerData:: wPlayerData1:: @@ -3374,7 +2555,7 @@ wScreenSave:: ds SCREEN_META_WIDTH * SCREEN_META_HEIGHT wCurMapDataEnd:: -SECTION "Party", WRAMX, BANK[1] +SECTION "Party", WRAMX wPokemonData:: wPartyCount:: ds 1 ; da22 |