diff --git a/engine/billspc.asm b/engine/billspc.asm index ace4eb873..33792477a 100755 --- a/engine/billspc.asm +++ b/engine/billspc.asm @@ -205,7 +205,7 @@ BillsPCDepositFuncRelease: ; e24e0 (38:64e0) ld [CurPartyMon], a xor a ld [wPokemonWithdrawDepositParameter], a - callba Functione039 + callba RemoveMonFromPartyOrBox call Functione3180 ld a, $0 ld [wJumptableIndex], a @@ -468,7 +468,7 @@ endr ld [CurPartyMon], a ld a, PC_DEPOSIT ld [wPokemonWithdrawDepositParameter], a - callba Functione039 + callba RemoveMonFromPartyOrBox call Functione3180 ld a, $0 ld [wJumptableIndex], a @@ -1880,7 +1880,7 @@ Functione307c: ; e307c (38:707c) jr c, .asm_boxisfull xor a ld [wPokemonWithdrawDepositParameter], a - callba Functione039 + callba RemoveMonFromPartyOrBox ld a, [CurPartySpecies] call PlayCry hlcoord 0, 0 @@ -1935,7 +1935,7 @@ TryWithdrawPokemon: ; e30fa (38:70fa) jr c, .PartyFull ld a, PC_DEPOSIT ld [wPokemonWithdrawDepositParameter], a - callba Functione039 + callba RemoveMonFromPartyOrBox ld a, [CurPartySpecies] call PlayCry hlcoord 0, 0 @@ -2173,7 +2173,7 @@ Functione32b0: ; e32b0 callba Function5088b ld a, PC_DEPOSIT ld [wPokemonWithdrawDepositParameter], a - callba Functione039 + callba RemoveMonFromPartyOrBox ret ; e32fa @@ -2206,7 +2206,7 @@ Functione3316: ; e3316 call CopyMonToTemp xor a ld [wPokemonWithdrawDepositParameter], a - callba Functione039 + callba RemoveMonFromPartyOrBox ret ; e3346 diff --git a/engine/buy_sell_toss.asm b/engine/buy_sell_toss.asm index db1acddbc..7f2ad2727 100755 --- a/engine/buy_sell_toss.asm +++ b/engine/buy_sell_toss.asm @@ -114,7 +114,7 @@ BuySellToss_InterpretJoypad: ; 2500e .right ld a, [wItemQuantityChangeBuffer] - add $a + add 10 ld b, a ld a, [wItemQuantityBuffer] cp b diff --git a/engine/link.asm b/engine/link.asm index 0e6fe4b7c..222d1eedb 100755 --- a/engine/link.asm +++ b/engine/link.asm @@ -1886,7 +1886,7 @@ Function28b87: ; 28b87 ld [wd002], a xor a ld [wPokemonWithdrawDepositParameter], a - callab Functione039 + callab RemoveMonFromPartyOrBox ld a, [PartyCount] dec a ld [CurPartyMon], a diff --git a/engine/mail.asm b/engine/mail.asm index dec445d94..6eef16a8c 100755 --- a/engine/mail.asm +++ b/engine/mail.asm @@ -177,7 +177,7 @@ CheckPokeItem:: ; 44654 jr c, .close_sram_return xor a ld [wPokemonWithdrawDepositParameter], a - callba Functione039 + callba RemoveMonFromPartyOrBox ld a, $1 .close_sram_return diff --git a/engine/npctrade.asm b/engine/npctrade.asm index 71ab03ee3..79a25495d 100755 --- a/engine/npctrade.asm +++ b/engine/npctrade.asm @@ -40,7 +40,7 @@ NPCTrade:: ; fcba8 ; Select givemon from party ld b, 6 - callba Function5001d + callba SelectTradeOrDaycareMon ld a, TRADE_CANCEL jr c, .done @@ -100,23 +100,23 @@ CheckTradeGender: ; fcc23 call GetTradeAttribute ld a, [hl] and a - jr z, .asm_fcc46 + jr z, .matching cp 1 - jr z, .asm_fcc3e + jr z, .check_male callba GetGender - jr nz, .asm_fcc48 - jr .asm_fcc46 + jr nz, .not_matching + jr .matching -.asm_fcc3e +.check_male callba GetGender - jr z, .asm_fcc48 + jr z, .not_matching -.asm_fcc46 +.matching and a ret -.asm_fcc48 +.not_matching scf ret ; fcc4a @@ -211,7 +211,7 @@ DoNPCTrade: ; fcc63 xor a ld [MonType], a ld [wPokemonWithdrawDepositParameter], a - callab Functione039 + callab RemoveMonFromPartyOrBox predef TryAddMonToParty ld e, TRADE_DIALOG @@ -219,9 +219,9 @@ DoNPCTrade: ; fcc63 ld a, [hl] cp TRADE_COMPLETE ld b, RESET_FLAG - jr c, .asm_fcd1c + jr c, .incomplete ld b, SET_FLAG -.asm_fcd1c +.incomplete callba SetGiftPartyMonCaughtData ld e, TRADE_NICK @@ -291,7 +291,7 @@ DoNPCTrade: ; fcc63 ld a, [PartyCount] dec a ld [CurPartyMon], a - callba Functione134 + callba ComputeNPCTrademonStats pop af ld [CurPartyMon], a pop hl diff --git a/engine/party_menu.asm b/engine/party_menu.asm index e5d8cbd1e..0da558272 100644 --- a/engine/party_menu.asm +++ b/engine/party_menu.asm @@ -13,7 +13,7 @@ SelectMonFromParty: ; 50000 ; 5001d -Function5001d: ; 5001d +SelectTradeOrDaycareMon: ; 5001d ld a, b ld [PartyMenuActionText], a call DisableSpriteUpdates diff --git a/engine/warp_connection.asm b/engine/warp_connection.asm index e9a38257d..1a857ab43 100755 --- a/engine/warp_connection.asm +++ b/engine/warp_connection.asm @@ -62,9 +62,9 @@ EnterWestConnection: ; 1045ed .skip_to_load ld a, l - ld [wd194], a + ld [wOverworldMapAnchor], a ld a, h - ld [wd194 + 1], a + ld [wOverworldMapAnchor + 1], a jp EnteredConnection ; 104629 @@ -99,9 +99,9 @@ EnterEastConnection: ; 104629 .skip_to_load ld a, l - ld [wd194], a + ld [wOverworldMapAnchor], a ld a, h - ld [wd194 + 1], a + ld [wOverworldMapAnchor + 1], a jp EnteredConnection ; 104665 @@ -126,9 +126,9 @@ EnterNorthConnection: ; 104665 srl c add hl, bc ld a, l - ld [wd194], a + ld [wOverworldMapAnchor], a ld a, h - ld [wd194 + 1], a + ld [wOverworldMapAnchor + 1], a jp EnteredConnection ; 104696 @@ -153,9 +153,9 @@ EnterSouthConnection: ; 104696 srl c add hl, bc ld a, l - ld [wd194], a + ld [wOverworldMapAnchor], a ld a, h - ld [wd194 + 1], a + ld [wOverworldMapAnchor + 1], a ; fallthrough ; 1046c4 @@ -427,14 +427,14 @@ GetCoordOfUpperLeftCorner:: ; 10486d .resume2 call AddNTimes ld a, l - ld [wd194], a + ld [wOverworldMapAnchor], a ld a, h - ld [wd194 + 1], a + ld [wOverworldMapAnchor + 1], a ld a, [YCoord] and $1 - ld [wd196], a + ld [wMetatileStandingY], a ld a, [XCoord] and $1 - ld [wd197], a + ld [wMetatileStandingX], a ret ; 1048ba diff --git a/event/daycare.asm b/event/daycare.asm index 2d7c9dea3..42e3d62f0 100755 --- a/event/daycare.asm +++ b/event/daycare.asm @@ -103,7 +103,7 @@ Function16798: ; 16798 ld a, 4 call Function1689b ld b, 6 - callba Function5001d + callba SelectTradeOrDaycareMon jr c, .asm_167dd ld a, [CurPartySpecies] cp EGG diff --git a/event/magnet_train.asm b/event/magnet_train.asm index c92a715ec..55a3a77fa 100755 --- a/event/magnet_train.asm +++ b/event/magnet_train.asm @@ -322,7 +322,7 @@ Function8ce14: ; 8ce14 Function8ce19: ; 8ce19 ld d, $55 - ld a, [wd194 + 1] + ld a, [wOverworldMapAnchor + 1] ld e, a ld b, SPRITE_ANIM_INDEX_15 ld a, [rSVBK] @@ -386,7 +386,7 @@ Function8ce6d: ; 8ce6d ; 8ce7a Function8ce7a: ; 8ce7a - ld hl, wd194 + ld hl, wOverworldMapAnchor ld a, [wcf65] cp [hl] jr z, .asm_8ce9e diff --git a/home/map.asm b/home/map.asm index ad8b69389..d049623e6 100644 --- a/home/map.asm +++ b/home/map.asm @@ -124,10 +124,10 @@ LoadMapPart:: ; 217a ; 2198 LoadMetatiles:: ; 2198 -; de <- wd194 - ld a, [wd194] +; de <- wOverworldMapAnchor + ld a, [wOverworldMapAnchor] ld e, a - ld a, [wd194 + 1] + ld a, [wOverworldMapAnchor + 1] ld d, a ld hl, wMisc ld b, 5 ; SCREEN_WIDTH / 4 @@ -1272,7 +1272,7 @@ ScrollMapUp:: ; 2748 ret ; 2771 -ScrollMapLeft:: ; 2771 +ScrollMapRight:: ; 2771 hlcoord 0, 0 ld de, BGMapBuffer call BackupBGMapColumn @@ -1288,7 +1288,7 @@ ScrollMapLeft:: ; 2771 ret ; 278f -ScrollMapRight:: ; 278f +ScrollMapLeft:: ; 278f hlcoord SCREEN_WIDTH - 2, 0 ld de, BGMapBuffer call BackupBGMapColumn @@ -1468,7 +1468,7 @@ LoadTileset:: ; 2821 ; 2879 BufferScreen:: ; 2879 - ld hl, wd194 + ld hl, wOverworldMapAnchor ld a, [hli] ld h, [hl] ld l, a @@ -1497,7 +1497,7 @@ BufferScreen:: ; 2879 ; 289d SaveScreen:: ; 289d - ld hl, wd194 + ld hl, wOverworldMapAnchor ld a, [hli] ld h, [hl] ld l, a @@ -1547,7 +1547,7 @@ SaveScreen:: ; 289d LoadNeighboringBlockData:: ; 28e3 - ld hl, wd194 + ld hl, wOverworldMapAnchor ld a, [hli] ld h, [hl] ld l, a diff --git a/main.asm b/main.asm index cbc56c5d5..1c680b53c 100644 --- a/main.asm +++ b/main.asm @@ -435,9 +435,9 @@ DaycareStep:: ; 7282 dec hl inc [hl] ld a, [hl] - cp $50 + cp 5242880 / $10000 jr c, .daycare_lady - ld a, $50 + ld a, 5242880 / $10000 ld [hl], a .daycare_lady @@ -620,9 +620,8 @@ SpecialReturnShuckle: ; 737e jr nc, .HappyToStayWithYou xor a ; take from pc ld [wPokemonWithdrawDepositParameter], a - callab Functione039 + callab RemoveMonFromPartyOrBox ld a, $2 - .HappyToStayWithYou ld [ScriptVar], a ret @@ -4812,21 +4811,24 @@ Functiond497:: ; d497 (3:5497) and a ret z bit 7, a - jr nz, .asm_d4a9 + jr nz, .update_overworld_map bit 6, a - jr nz, .asm_d4b3 + jr nz, .update_player_coords bit 5, a - jr nz, .asm_d4b8 + jr nz, .finish ret -.asm_d4a9 + +.update_overworld_map ld a, $4 ld [wd13f], a - call Functiond536 - jr .asm_d4b8 -.asm_d4b3 - call Functiond511 - jr .asm_d4b8 -.asm_d4b8 + call UpdateOverworldMap + jr .finish + +.update_player_coords + call UpdatePlayerCoords + jr .finish + +.finish call Functiond4e5 ld a, [wPlayerStepVectorX] ld d, a @@ -4860,22 +4862,23 @@ Functiond4e5: ; d4e5 (3:54e5) ret z dec [hl] ld a, [hl] - ld hl, Jumptable_d4f2 + ld hl, .Jumptable rst JumpTable ret -Jumptable_d4f2: ; d4f2 (3:54f2) - dw GetMovementPermissions - dw BufferScreen - dw .mobile - dw .fail2 - dw .fail1 - dw .fail1 - dw .fail1 - dw .fail1 - dw .fail1 - dw .fail1 - dw .fail1 +.Jumptable: ; d4f2 (3:54f2) + jumptable_start + jumptable GetMovementPermissions + jumptable BufferScreen + jumptable .mobile + jumptable .fail2 + jumptable .fail1 + jumptable .fail1 + jumptable .fail1 + jumptable .fail1 + jumptable .fail1 + jumptable .fail1 + jumptable .fail1 .fail1: ; d508 (3:5508) ret @@ -4887,71 +4890,74 @@ Jumptable_d4f2: ; d4f2 (3:54f2) .fail2: ; d510 (3:5510) ret -Functiond511: ; d511 (3:5511) +UpdatePlayerCoords: ; d511 (3:5511) ld a, [wPlayerStepDirection] and a - jr nz, .asm_d51c + jr nz, .check_step_down ld hl, YCoord inc [hl] ret -.asm_d51c - cp $1 - jr nz, .asm_d525 + +.check_step_down + cp UP + jr nz, .check_step_left ld hl, YCoord dec [hl] ret -.asm_d525 - cp $2 - jr nz, .asm_d52e + +.check_step_left + cp LEFT + jr nz, .check_step_right ld hl, XCoord dec [hl] ret -.asm_d52e - cp $3 + +.check_step_right + cp RIGHT ret nz ld hl, XCoord inc [hl] ret -Functiond536: ; d536 (3:5536) +UpdateOverworldMap: ; d536 (3:5536) ld a, [wPlayerStepDirection] and a - jr z, .asm_d549 - cp $1 - jr z, .asm_d553 - cp $2 - jr z, .asm_d55d - cp $3 - jr z, .asm_d567 + jr z, .step_down + cp UP + jr z, .step_up + cp LEFT + jr z, .step_left + cp RIGHT + jr z, .step_right ret -.asm_d549 - call Functiond571 +.step_down + call .ScrollOverworldMapDown call LoadMapPart call ScrollMapUp ret -.asm_d553 - call Functiond5a2 +.step_up + call .ScrollOverworldMapUp call LoadMapPart call ScrollMapDown ret -.asm_d55d - call Functiond5d5 - call LoadMapPart - call ScrollMapLeft - ret - -.asm_d567 - call Functiond5fe +.step_left + call .ScrollOverworldMapLeft call LoadMapPart call ScrollMapRight ret -Functiond571: ; d571 (3:5571) +.step_right + call .ScrollOverworldMapRight + call LoadMapPart + call ScrollMapLeft + ret + +.ScrollOverworldMapDown: ; d571 (3:5571) ld a, [wBGMapAnchor] - add $40 + add 2 * BG_MAP_WIDTH ld [wBGMapAnchor], a jr nc, .not_overflowed ld a, [wBGMapAnchor + 1] @@ -4960,29 +4966,29 @@ Functiond571: ; d571 (3:5571) or VBGMap0 / $100 ld [wBGMapAnchor + 1], a .not_overflowed - ld hl, wd196 + ld hl, wMetatileStandingY inc [hl] ld a, [hl] - cp $2 ; was 1 - jr nz, .skip - ld [hl], $0 - call Functiond595 -.skip + cp 2 ; was 1 + jr nz, .done_down + ld [hl], 0 + call .Add6ToOverworldMapAnchor +.done_down ret -Functiond595: ; d595 (3:5595) - ld hl, wd194 +.Add6ToOverworldMapAnchor: ; d595 (3:5595) + ld hl, wOverworldMapAnchor ld a, [MapWidth] - add $6 + add 6 add [hl] ld [hli], a ret nc inc [hl] ret -Functiond5a2: ; d5a2 (3:55a2) +.ScrollOverworldMapUp: ; d5a2 (3:55a2) ld a, [wBGMapAnchor] - sub $40 + sub 2 * BG_MAP_WIDTH ld [wBGMapAnchor], a jr nc, .not_underflowed ld a, [wBGMapAnchor + 1] @@ -4991,20 +4997,20 @@ Functiond5a2: ; d5a2 (3:55a2) or VBGMap0 / $100 ld [wBGMapAnchor + 1], a .not_underflowed - ld hl, wd196 + ld hl, wMetatileStandingY dec [hl] ld a, [hl] - cp $ff ; was 0 - jr nz, .skip + cp -1 ; was 0 + jr nz, .done_up ld [hl], $1 - call Functiond5c6 -.skip + call .Sub6FromOverworldMapAnchor +.done_up ret -Functiond5c6: ; d5c6 (3:55c6) - ld hl, wd194 +.Sub6FromOverworldMapAnchor: ; d5c6 (3:55c6) + ld hl, wOverworldMapAnchor ld a, [MapWidth] - add $6 + add 6 ld b, a ld a, [hl] sub b @@ -5013,7 +5019,7 @@ Functiond5c6: ; d5c6 (3:55c6) dec [hl] ret -Functiond5d5: ; d5d5 (3:55d5) +.ScrollOverworldMapLeft: ; d5d5 (3:55d5) ld a, [wBGMapAnchor] ld e, a and $e0 @@ -5023,26 +5029,26 @@ Functiond5d5: ; d5d5 (3:55d5) and $1f or d ld [wBGMapAnchor], a - ld hl, wd197 + ld hl, wMetatileStandingX dec [hl] ld a, [hl] - cp $ff - jr nz, .asm_d5f3 - ld [hl], $1 - call Functiond5f4 -.asm_d5f3 + cp -1 + jr nz, .done_left + ld [hl], 1 + call .DecrementwOverworldMapAnchor +.done_left ret -Functiond5f4: ; d5f4 (3:55f4) - ld hl, wd194 +.DecrementwOverworldMapAnchor: ; d5f4 (3:55f4) + ld hl, wOverworldMapAnchor ld a, [hl] - sub $1 + sub 1 ld [hli], a ret nc dec [hl] ret -Functiond5fe: ; d5fe (3:55fe) +.ScrollOverworldMapRight: ; d5fe (3:55fe) ld a, [wBGMapAnchor] ld e, a and $e0 @@ -5052,20 +5058,20 @@ Functiond5fe: ; d5fe (3:55fe) and $1f or d ld [wBGMapAnchor], a - ld hl, wd197 + ld hl, wMetatileStandingX inc [hl] ld a, [hl] - cp $2 - jr nz, .asm_d61c - ld [hl], $0 - call .Incrementwd194 -.asm_d61c + cp 2 + jr nz, .done_right + ld [hl], 0 + call .IncrementwOverworldMapAnchor +.done_right ret -.Incrementwd194: ; d61d (3:561d) - ld hl, wd194 +.IncrementwOverworldMapAnchor: ; d61d (3:561d) + ld hl, wOverworldMapAnchor ld a, [hl] - add $1 + add 1 ld [hli], a ret nc inc [hl] @@ -5645,13 +5651,13 @@ endr ld d, a callab CalcExpAtLevel pop de - ld a, [hMultiplicand] + ld a, [hProduct + 1] ld [de], a inc de - ld a, [$ffb5] + ld a, [hProduct + 2] ld [de], a inc de - ld a, [$ffb6] + ld a, [hProduct + 3] ld [de], a inc de xor a @@ -5733,10 +5739,10 @@ endr ld c, a ld b, $0 call CalcPkmnStatC - ld a, [$ffb5] + ld a, [hProduct + 2] ld [de], a inc de - ld a, [$ffb6] + ld a, [hProduct + 3] ld [de], a inc de jr .next2 @@ -6165,7 +6171,6 @@ endr dec a ld b, a call Functiondcb6 - .CloseSRAM_And_ClearCarryFlag call CloseSRAM and a @@ -6211,7 +6216,7 @@ Functiondcb6: ; dcb6 ld a, [hli] and a jr z, .asm_dd18 - ld [TempMonMoves+0], a + ld [TempMonMoves], a ld a, BOXMON ld [MonType], a ld a, b @@ -6388,7 +6393,7 @@ Functionde2a: ; de2a call Functionde44 xor a ld [wPokemonWithdrawDepositParameter], a - jp Functione039 + jp RemoveMonFromPartyOrBox ; de37 Functionde37: ; de37 @@ -6396,7 +6401,7 @@ Functionde37: ; de37 call Functionde44 xor a ld [wPokemonWithdrawDepositParameter], a - jp Functione039 + jp RemoveMonFromPartyOrBox ; de44 Functionde44: ; de44 @@ -6423,14 +6428,14 @@ SentPkmnIntoBox: ; de6e ld de, sBoxCount ld a, [de] cp MONS_PER_BOX - jp nc, Functiondf42 + jp nc, .full inc a ld [de], a ld a, [CurPartySpecies] ld [CurSpecies], a ld c, a -.asm_de85 +.loop inc de ld a, [de] ld b, a @@ -6438,7 +6443,7 @@ SentPkmnIntoBox: ; de6e ld c, b ld [de], a inc a - jr nz, .asm_de85 + jr nz, .loop call GetBaseData call ShiftBoxMon @@ -6474,33 +6479,33 @@ SentPkmnIntoBox: ; de6e ld d, a callab CalcExpAtLevel pop de - ld a, [hMultiplicand] + ld a, [hProduct + 1] ld [de], a inc de - ld a, [$ffb5] + ld a, [hProduct + 2] ld [de], a inc de - ld a, [$ffb6] + ld a, [hProduct + 3] ld [de], a inc de ; Set all 5 Experience Values to 0 xor a - ld b, 2*5 -.asm_dee5 + ld b, 2 * 5 +.loop2 ld [de], a inc de dec b - jr nz, .asm_dee5 + jr nz, .loop2 ld hl, EnemyMonDVs ld b, 2 + NUM_MOVES ; DVs and PP ; EnemyMonHappiness - EnemyMonDVs -.asm_deef +.loop3 ld a, [hli] ld [de], a inc de dec b - jr nz, .asm_deef + jr nz, .loop3 ld a, BASE_HAPPINESS ld [de], a @@ -6519,12 +6524,12 @@ SentPkmnIntoBox: ; de6e call SetSeenAndCaughtMon ld a, [CurPartySpecies] cp UNOWN - jr nz, .asm_df20 + jr nz, .not_unown ld hl, sBoxMon1DVs predef GetUnownLetter callab UpdateUnownDex -.asm_df20 +.not_unown ld hl, sBoxMon1Moves ld de, TempMonMoves ld bc, NUM_MOVES @@ -6543,7 +6548,7 @@ SentPkmnIntoBox: ; de6e ret ; df42 -Functiondf42: ; df42 +.full: ; df42 call CloseSRAM and a ret @@ -6552,16 +6557,16 @@ Functiondf42: ; df42 ShiftBoxMon: ; df47 ld hl, sBoxMonOT ld bc, NAME_LENGTH - call .asm_df5f + call .shift ld hl, sBoxMonNicknames ld bc, PKMN_NAME_LENGTH - call .asm_df5f + call .shift ld hl, sBoxMons ld bc, BOXMON_STRUCT_LENGTH -.asm_df5f +.shift ld a, [sBoxCount] cp 2 ret c @@ -6678,11 +6683,11 @@ GiveEgg:: ; df8c call AddNTimes ld a, [wc2cc] bit 1, a - ld a, $1 - jr nz, .asm_e022 + ld a, 1 + jr nz, .got_init_happiness ld a, [BaseEggSteps] -.asm_e022 +.got_init_happiness ld [hl], a ld a, [PartyCount] dec a @@ -6700,7 +6705,7 @@ String_Egg: ; e035 db "EGG@" ; e039 -Functione039: ; e039 +RemoveMonFromPartyOrBox: ; e039 ld hl, PartyCount ld a, [wPokemonWithdrawDepositParameter] @@ -6722,30 +6727,33 @@ Functione039: ; e039 ld e, l ld d, h inc de -.asm_e057 +.loop ld a, [de] inc de ld [hli], a inc a - jr nz, .asm_e057 + jr nz, .loop ld hl, PartyMonOT ld d, PARTY_LENGTH - 1 ld a, [wPokemonWithdrawDepositParameter] and a - jr z, .asm_e06d + jr z, .party ld hl, sBoxMonOT ld d, MONS_PER_BOX - 1 -.asm_e06d +.party + ; If this is the last mon in our party (box), + ; shift all the other mons up to close the gap. ld a, [CurPartyMon] call SkipNames ld a, [CurPartyMon] cp d - jr nz, .asm_e07e - ld [hl], $ff - jp .asm_60f0 + jr nz, .delete_inside + ld [hl], -1 + jp .finish -.asm_e07e +.delete_inside + ; Shift the OT names ld d, h ld e, l ld bc, PKMN_NAME_LENGTH @@ -6753,46 +6761,44 @@ Functione039: ; e039 ld bc, PartyMonNicknames ld a, [wPokemonWithdrawDepositParameter] and a - jr z, .asm_e090 + jr z, .party2 ld bc, sBoxMonNicknames -.asm_e090 +.party2 call CopyDataUntil - + ; Shift the struct ld hl, PartyMons ld bc, PARTYMON_STRUCT_LENGTH ld a, [wPokemonWithdrawDepositParameter] and a - jr z, .asm_e0a5 + jr z, .party4 ld hl, sBoxMons ld bc, BOXMON_STRUCT_LENGTH - -.asm_e0a5 +.party4 ld a, [CurPartyMon] call AddNTimes ld d, h ld e, l ld a, [wPokemonWithdrawDepositParameter] and a - jr z, .asm_e0bc + jr z, .party5 ld bc, BOXMON_STRUCT_LENGTH add hl, bc ld bc, sBoxMonOT - jr .asm_e0c3 + jr .copy -.asm_e0bc +.party5 ld bc, PARTYMON_STRUCT_LENGTH add hl, bc ld bc, PartyMonOT - -.asm_e0c3 +.copy call CopyDataUntil + ; Shift the nicknames ld hl, PartyMonNicknames ld a, [wPokemonWithdrawDepositParameter] and a - jr z, .asm_e0d2 + jr z, .party6 ld hl, sBoxMonNicknames - -.asm_e0d2 +.party6 ld bc, PKMN_NAME_LENGTH ld a, [CurPartyMon] call AddNTimes @@ -6803,25 +6809,27 @@ Functione039: ; e039 ld bc, PartyMonNicknamesEnd ld a, [wPokemonWithdrawDepositParameter] and a - jr z, .asm_e0ed + jr z, .party7 ld bc, sBoxMonNicknamesEnd - -.asm_e0ed +.party7 call CopyDataUntil - -.asm_60f0 + ; Mail time! +.finish ld a, [wPokemonWithdrawDepositParameter] and a jp nz, CloseSRAM ld a, [wLinkMode] and a ret nz + ; Shift mail ld a, BANK(sPartyMail) call GetSRAMBank + ; If this is the last mon in our party, no need to shift mail. ld hl, PartyCount ld a, [CurPartyMon] cp [hl] - jr z, .asm_e131 + jr z, .close_sram + ; Shift our mail messages up. ld hl, sPartyMail ld bc, MAIL_STRUCT_LENGTH call AddNTimes @@ -6830,7 +6838,7 @@ Functione039: ; e039 pop de ld a, [CurPartyMon] ld b, a -.asm_e11a +.loop2 push bc push hl ld bc, MAIL_STRUCT_LENGTH @@ -6844,13 +6852,12 @@ Functione039: ; e039 inc b ld a, [PartyCount] cp b - jr nz, .asm_e11a - -.asm_e131 + jr nz, .loop2 +.close_sram jp CloseSRAM ; e134 -Functione134: ; e134 +ComputeNPCTrademonStats: ; e134 ld a, MON_LEVEL call GetPartyParamLocation ld a, [hl] @@ -7116,7 +7123,7 @@ GivePoke:: ; e277 ld e, l pop bc ld a, b - ld b, $0 + ld b, 0 push bc push de push af @@ -7136,15 +7143,15 @@ GivePoke:: ; e277 ld [TempEnemyMonSpecies], a callab LoadEnemyMon call SentPkmnIntoBox - jp nc, Functione3d4 - ld a, $2 + jp nc, .FailedToGiveMon + ld a, BOXMON ld [MonType], a xor a ld [CurPartyMon], a - ld de, wd050 + ld de, wd050_MonNick pop bc ld a, b - ld b, $1 + ld b, 1 push bc push de push af @@ -7160,12 +7167,12 @@ GivePoke:: ; e277 ld [TempEnemyMonSpecies], a call GetPokemonName ld hl, StringBuffer1 - ld de, wd050 + ld de, wd050_MonNick ld bc, PKMN_NAME_LENGTH call CopyBytes pop af and a - jp z, .asm_e390 + jp z, .wildmon pop de pop bc pop hl @@ -7187,7 +7194,7 @@ endr and a push de push bc - jr nz, .asm_e35e + jr nz, .send_to_box push hl ld a, [CurPartyMon] @@ -7219,7 +7226,7 @@ endr callba SetGiftPartyMonCaughtData jr .skip_nickname -.asm_e35e +.send_to_box ld a, BANK(sBoxMonOT) call GetSRAMBank ld de, sBoxMonOT @@ -7243,21 +7250,20 @@ endr callba SetGiftBoxMonCaughtData jr .skip_nickname -.asm_e390 +.wildmon pop de pop bc push bc push de ld a, b and a - jr z, .asm_e3a0 + jr z, .party callba SetBoxMonCaughtData - jr .asm_e3a6 + jr .set_caught_data -.asm_e3a0 +.party callba SetCaughtData - -.asm_e3a6 +.set_caught_data callba GiveANickname_YesNo pop de jr c, .skip_nickname @@ -7282,7 +7288,7 @@ endr ret ; e3d4 -Functione3d4: ; e3d4 +.FailedToGiveMon: ; e3d4 pop bc pop de ld b, $2 @@ -12396,14 +12402,14 @@ INCLUDE "engine/map_triggers.asm" Function4d15b:: ; 4d15b ld hl, wc608 - ld a, [wd196] + ld a, [wMetatileStandingY] and a jr z, .skip ld bc, $30 add hl, bc .skip - ld a, [wd197] + ld a, [wMetatileStandingX] and a jr z, .next_dw rept 2 diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm index 1c99ceb9e..6e0988f41 100644 --- a/misc/mobile_40.asm +++ b/misc/mobile_40.asm @@ -5406,7 +5406,7 @@ Function1023c6: ; 1023c6 ld [CurPartyMon], a xor a ld [wd10b], a - callba Functione039 + callba RemoveMonFromPartyOrBox ld hl, PartyCount inc [hl] ld a, [hli] diff --git a/misc/mobile_46.asm b/misc/mobile_46.asm index 50e1437a7..8a5a79b93 100755 --- a/misc/mobile_46.asm +++ b/misc/mobile_46.asm @@ -7459,7 +7459,7 @@ Function11b5c0: ; 11b5c0 ld [CurPartyMon], a xor a ld [wPokemonWithdrawDepositParameter], a - callba Functione039 + callba RemoveMonFromPartyOrBox callba Function170807 callba Function14a58 jp Function11ad8a diff --git a/wram.asm b/wram.asm index f16413d39..888bb3957 100644 --- a/wram.asm +++ b/wram.asm @@ -1984,11 +1984,9 @@ wd182:: ds 1 wd191:: ds 1 wd192:: ds 1 wd193:: ds 1 -wd194:: dw -wMetatileStandingY:: -wd196:: ds 1 -wMetatileStandingX:: -wd197:: ds 1 +wOverworldMapAnchor:: dw +wMetatileStandingY:: ds 1 +wMetatileStandingX:: ds 1 wSecondMapHeaderBank:: ds 1 wTileset:: ds 1 wPermission:: ds 1