diff --git a/battle/ai/items.asm b/battle/ai/items.asm index f91f45ee5..cf78980b3 100644 --- a/battle/ai/items.asm +++ b/battle/ai/items.asm @@ -16,7 +16,7 @@ AI_SwitchOrTryItem: ; 38000 bit SUBSTATUS_CANT_RUN, a jr nz, DontSwitch - ld a, [wc731] + ld a, [wEnemyWrapCount] and a jr nz, DontSwitch diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm index 39d2a8eca..dbdbb9db8 100644 --- a/battle/ai/scoring.asm +++ b/battle/ai/scoring.asm @@ -1062,7 +1062,7 @@ AI_Smart_Bind: ; 38a71 ; Bind, Wrap, Fire Spin, Clamp ; 50% chance to discourage this move if the player is already trapped. - ld a, [wc730] + ld a, [wPlayerWrapCount] and a jr nz, .asm_38a8b @@ -2466,7 +2466,7 @@ AI_Smart_RapidSpin: ; 39084 ; 80% chance to greatly encourage this move if the enemy is ; trapped (Bind effect), seeded, or scattered with spikes. - ld a, [wc731] + ld a, [wEnemyWrapCount] and a jr nz, .asm_39097 diff --git a/battle/core.asm b/battle/core.asm index f6f8fbf0f..a772794a1 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -166,8 +166,8 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5 Function3c12f: ; 3c12f .loop - call Function3c1bf - call Function3c3f5 + call MobileFn_3c1bf + call CheckContestBattleOver jp c, .quit xor a @@ -192,8 +192,8 @@ Function3c12f: ; 3c12f .not_disconnected call Function3c410 - jr c, .asm_3c18a -.asm_3c179 + jr c, .skip_iteration +.loop1 call BattleMenu jr c, .quit ld a, [BattleEnded] @@ -202,20 +202,20 @@ Function3c12f: ; 3c12f ld a, [wd232] ; roared/whirlwinded/teleported and a jr nz, .quit -.asm_3c18a +.skip_iteration call Function3c434 - jr nz, .asm_3c179 + jr nz, .loop1 call Function3c300 jr c, .quit call DetermineMoveOrder - jr c, .asm_3c19e + jr c, .false call Function3c5fe - jr .asm_3c1a1 -.asm_3c19e + jr .proceed +.false call Function3c664 -.asm_3c1a1 +.proceed call Function3d2e0 jr c, .quit @@ -227,7 +227,7 @@ Function3c12f: ; 3c12f and a jr nz, .quit - call Function3c1d6 + call HandleBetweenTurnEffects ld a, [BattleEnded] and a jr nz, .quit @@ -237,46 +237,41 @@ Function3c12f: ; 3c12f ret ; 3c1bf -Function3c1bf: ; 3c1bf - ret -; 3c1c0 - - -Function3c1c0: ; 3c1c0 +MobileFn_3c1bf: mobile ld a, $5 call GetSRAMBank ld hl, $a89b inc [hl] - jr nz, .asm_3c1d2 + jr nz, .finish dec hl inc [hl] - jr nz, .asm_3c1d2 + jr nz, .finish dec [hl] inc hl dec [hl] -.asm_3c1d2 +.finish call CloseSRAM ret ; 3c1d6 -Function3c1d6: ; 3c1d6 +HandleBetweenTurnEffects: ; 3c1d6 ld a, [hLinkPlayerNumber] cp $1 jr z, .CheckEnemyFirst call CheckFaint_PlayerThenEnemy ret c - call Function3ca26 + call HandleFutureSight call CheckFaint_PlayerThenEnemy ret c call HandleWeather call CheckFaint_PlayerThenEnemy ret c - call Function3c874 + call HandleWrap call CheckFaint_PlayerThenEnemy ret c - call Function3c801 + call HandlePerishSong call CheckFaint_PlayerThenEnemy ret c jr .NoMoreFaintingConditions @@ -284,27 +279,27 @@ Function3c1d6: ; 3c1d6 .CheckEnemyFirst call CheckFaint_EnemyThenPlayer ret c - call Function3ca26 + call HandleFutureSight call CheckFaint_EnemyThenPlayer ret c call HandleWeather call CheckFaint_EnemyThenPlayer ret c - call Function3c874 + call HandleWrap call CheckFaint_EnemyThenPlayer ret c - call Function3c801 + call HandlePerishSong call CheckFaint_EnemyThenPlayer ret c .NoMoreFaintingConditions - call Function3c8eb - call Function3c93c + call HandleLeftovers + call HandleMysteryberry call HanleDefrost call HandleSafeguard call HandleScreens - call Function3de97 - call Function3dcf9 + call HandleStatBoostingHeldItems + call HandleHealingItems call UpdateBattleMonInParty call LoadTileMapToTempTileMap jp Function3c4df @@ -578,13 +573,13 @@ DetermineMoveOrder: ; 3c314 ret ; 3c3f5 -Function3c3f5: ; 3c3f5 +CheckContestBattleOver: ; 3c3f5 ld a, [BattleType] cp BATTLETYPE_CONTEST - jr nz, .asm_3c40e - ld a, [wdc79] + jr nz, .contest_not_over + ld a, [wParkBallsRemaining] and a - jr nz, .asm_3c40e + jr nz, .contest_not_over ld a, [wBattleResult] and $c0 add $2 @@ -592,7 +587,7 @@ Function3c3f5: ; 3c3f5 scf ret -.asm_3c40e +.contest_not_over and a ret ; 3c410 @@ -787,7 +782,7 @@ TryEnemyFlee: ; 3c543 bit SUBSTATUS_CANT_RUN, a jr nz, .Stay - ld a, [wc731] + ld a, [wEnemyWrapCount] and a jr nz, .Stay @@ -1217,27 +1212,28 @@ ResidualDamage: ; 3c716 ret ; 3c801 -Function3c801: ; 3c801 +HandlePerishSong: ; 3c801 ld a, [hLinkPlayerNumber] cp $1 - jr z, .asm_3c813 + jr z, .EnemyFirst call SetPlayerTurn - call .asm_3c81c + call .do_it call SetEnemyTurn - jp .asm_3c81c + jp .do_it -.asm_3c813 +.EnemyFirst call SetEnemyTurn - call .asm_3c81c + call .do_it call SetPlayerTurn -.asm_3c81c + +.do_it ld hl, PlayerPerishCount ld a, [hBattleTurn] and a - jr z, .asm_3c827 + jr z, .got_count ld hl, EnemyPerishCount -.asm_3c827 +.got_count ld a, BATTLE_VARS_SUBSTATUS1 call GetBattleVar bit SUBSTATUS_PERISH, a @@ -1285,46 +1281,51 @@ Function3c801: ; 3c801 ret ; 3c874 -Function3c874: ; 3c874 +HandleWrap: ; 3c874 ld a, [hLinkPlayerNumber] cp $1 - jr z, .asm_3c886 + jr z, .EnemyFirst call SetPlayerTurn - call .asm_3c88f + call .do_it call SetEnemyTurn - jp .asm_3c88f + jp .do_it -.asm_3c886 +.EnemyFirst call SetEnemyTurn - call .asm_3c88f + call .do_it call SetPlayerTurn -.asm_3c88f - ld hl, wc730 - ld de, wc72e + +.do_it + ld hl, wPlayerWrapCount + ld de, wPlayerTrappingMove ld a, [hBattleTurn] and a - jr z, .asm_3c8a0 - ld hl, wc731 - ld de, wc72f + jr z, .got_addrs + ld hl, wEnemyWrapCount + ld de, wEnemyTrappingMove -.asm_3c8a0 +.got_addrs ld a, [hl] and a ret z + ld a, BATTLE_VARS_SUBSTATUS4 call GetBattleVar bit SUBSTATUS_SUBSTITUTE, a ret nz + ld a, [de] ld [wd265], a ld [FXAnimIDLo], a call GetMoveName dec [hl] - jr z, .asm_3c8de + jr z, .release_from_bounds + ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVar and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND - jr nz, .asm_3c8d3 + jr nz, .skip_anim + call SwitchTurnCore xor a ld [wcfca], a @@ -1332,13 +1333,13 @@ Function3c874: ; 3c874 predef PlayBattleAnim call SwitchTurnCore -.asm_3c8d3 +.skip_anim call GetSixteenthMaxHP call SubtractHPFromUser ld hl, BattleText_UsersHurtByStringBuffer1 jr .asm_3c8e1 -.asm_3c8de +.release_from_bounds ld hl, BattleText_UserWasReleasedFromStringBuffer1 .asm_3c8e1 @@ -1352,20 +1353,21 @@ SwitchTurnCore: ; 3c8e4 ret ; 3c8eb -Function3c8eb: ; 3c8eb +HandleLeftovers: ; 3c8eb ld a, [hLinkPlayerNumber] cp $1 - jr z, .asm_3c8fd + jr z, .DoEnemyFirst call SetPlayerTurn - call .asm_3c906 + call .do_it call SetEnemyTurn - jp .asm_3c906 + jp .do_it -.asm_3c8fd +.DoEnemyFirst call SetEnemyTurn - call .asm_3c906 + call .do_it call SetPlayerTurn -.asm_3c906 +.do_it + callab GetUserItem ld a, [hl] ld [wd265], a @@ -1373,25 +1375,27 @@ Function3c8eb: ; 3c8eb ld a, b cp HELD_LEFTOVERS ret nz + ld hl, BattleMonHP ld a, [hBattleTurn] and a - jr z, .asm_3c922 + jr z, .got_hp ld hl, EnemyMonHP -.asm_3c922 +.got_hp +; Don't restore if we're already at max HP ld a, [hli] ld b, a ld a, [hli] ld c, a ld a, [hli] cp b - jr nz, .asm_3c92d + jr nz, .restore ld a, [hl] cp c ret z -.asm_3c92d +.restore call GetSixteenthMaxHP call SwitchTurnCore call RestoreHP @@ -1399,24 +1403,25 @@ Function3c8eb: ; 3c8eb jp StdBattleTextBox ; 3c93c -Function3c93c: ; 3c93c +HandleMysteryberry: ; 3c93c ld a, [hLinkPlayerNumber] cp $1 - jr z, .asm_3c94e + jr z, .DoEnemyFirst call SetPlayerTurn - call .asm_3c957 + call .do_it call SetEnemyTurn - jp .asm_3c957 + jp .do_it -.asm_3c94e +.DoEnemyFirst call SetEnemyTurn - call .asm_3c957 + call .do_it call SetPlayerTurn -.asm_3c957 + +.do_it callab GetUserItem ld a, b cp HELD_RESTORE_PP - jr nz, .asm_3c9ae + jr nz, .quit ld hl, PartyMon1PP ld a, [CurBattleMon] call GetPartyLocation @@ -1427,12 +1432,12 @@ Function3c93c: ; 3c93c call GetPartyLocation ld a, [hBattleTurn] and a - jr z, .asm_3c99b + jr z, .wild ld de, wc739 ld hl, wc735 ld a, [wBattleMode] dec a - jr z, .asm_3c99b + jr z, .wild ld hl, OTPartyMon1PP ld a, [CurOTMon] call GetPartyLocation @@ -1442,33 +1447,33 @@ Function3c93c: ; 3c93c ld a, [CurOTMon] call GetPartyLocation -.asm_3c99b +.wild ld c, $0 -.asm_3c99d +.loop ld a, [hl] and a - jr z, .asm_3c9ae + jr z, .quit ld a, [de] and $3f - jr z, .asm_3c9af + jr z, .restore inc hl inc de inc c ld a, c cp NUM_MOVES - jr nz, .asm_3c99d + jr nz, .loop -.asm_3c9ae +.quit ret -.asm_3c9af +.restore ; lousy hack ld a, [hl] cp SKETCH ld b, 1 - jr z, .asm_3c9b8 + jr z, .sketch ld b, 5 -.asm_3c9b8 +.sketch ld a, [de] add b ld [de], a @@ -1480,10 +1485,10 @@ Function3c93c: ; 3c93c ld hl, BattleMonPP ld a, [hBattleTurn] and a - jr z, .asm_3c9d2 + jr z, .player_pp ld de, EnemyMonMoves - 1 ld hl, EnemyMonPP -.asm_3c9d2 +.player_pp inc de pop bc ld b, 0 @@ -1497,38 +1502,38 @@ Function3c93c: ; 3c93c ld a, [wd265] cp [hl] - jr nz, .asm_3c9f5 + jr nz, .skip_checks ld a, [hBattleTurn] and a ld a, [PlayerSubStatus5] - jr z, .asm_3c9ee + jr z, .check_transform ld a, [EnemySubStatus5] -.asm_3c9ee +.check_transform bit SUBSTATUS_TRANSFORMED, a - jr nz, .asm_3c9f5 + jr nz, .skip_checks ld a, [de] add b ld [de], a -.asm_3c9f5 +.skip_checks callab GetUserItem ld a, [hl] ld [wd265], a xor a ld [hl], a - call Function3df12 + call GetPartymonItem ld a, [hBattleTurn] and a - jr z, .asm_3ca12 + jr z, .consume_item ld a, [wBattleMode] dec a - jr z, .asm_3ca14 - call Function3df1f + jr z, .skip_consumption + call GetOTPartymonItem -.asm_3ca12 +.consume_item xor a ld [hl], a -.asm_3ca14 +.skip_consumption call GetItemName call SwitchTurnCore call ItemRecoveryAnim @@ -1537,27 +1542,28 @@ Function3c93c: ; 3c93c jp StdBattleTextBox ; 3ca26 -Function3ca26: ; 3ca26 +HandleFutureSight: ; 3ca26 ld a, [hLinkPlayerNumber] cp $1 - jr z, .asm_3ca38 + jr z, .enemy_first call SetPlayerTurn - call .asm_3ca41 + call .do_it call SetEnemyTurn - jp .asm_3ca41 + jp .do_it -.asm_3ca38 +.enemy_first call SetEnemyTurn - call .asm_3ca41 + call .do_it call SetPlayerTurn -.asm_3ca41 - ld hl, wc71d + +.do_it + ld hl, wPlayerFutureSightCount ld a, [hBattleTurn] and a - jr z, .asm_3ca4c - ld hl, wc71e + jr z, .okay + ld hl, wEnemyFutureSightCount -.asm_3ca4c +.okay ld a, [hl] and a ret z @@ -3402,7 +3408,7 @@ ResetEnemyBattleVars: ; 3d557 dec a ld [wc6e6], a xor a - ld [wc730], a + ld [wPlayerWrapCount], a hlcoord 18, 0 ld a, $8 call Function3d490 @@ -3809,8 +3815,8 @@ endr ld [wEnemyRageCounter], a ld [EnemyDisabledMove], a ld [wc6fa], a - ld [wc730], a - ld [wc731], a + ld [wPlayerWrapCount], a + ld [wEnemyWrapCount], a ld [EnemyTurnsTaken], a ld hl, PlayerSubStatus5 res SUBSTATUS_CANT_RUN, [hl] @@ -3907,7 +3913,7 @@ TryToRunAwayFromBattle: ; 3d8b3 bit SUBSTATUS_CANT_RUN, a jp nz, .cant_escape - ld a, [wc730] + ld a, [wPlayerWrapCount] and a jp nz, .cant_escape @@ -4258,7 +4264,7 @@ SendOutPlayerMon: ; 3db5f call CheckAmuletCoin call Function3ee27 xor a - ld [wc731], a + ld [wEnemyWrapCount], a call SetPlayerTurn xor a ld [wcfca], a @@ -4312,8 +4318,8 @@ endr ld [wPlayerRageCounter], a ld [DisabledMove], a ld [wc6fe], a - ld [wc731], a - ld [wc730], a + ld [wEnemyWrapCount], a + ld [wPlayerWrapCount], a ld [PlayerTurnsTaken], a ld hl, EnemySubStatus5 res SUBSTATUS_CANT_RUN, [hl] @@ -4462,31 +4468,31 @@ Function3dce6: ; 3dce6 ret ; 3dcf9 -Function3dcf9: ; 3dcf9 +HandleHealingItems: ; 3dcf9 ld a, [hLinkPlayerNumber] cp $1 jr z, .player_1 call SetPlayerTurn - call Function3dd2f + call HandleHPHealingItem call UseHeldStatusHealingItem - call Function3de51 + call HandleStatusHealingItem call SetEnemyTurn - call Function3dd2f + call HandleHPHealingItem call UseHeldStatusHealingItem - jp Function3de51 + jp HandleStatusHealingItem .player_1 call SetEnemyTurn - call Function3dd2f + call HandleHPHealingItem call UseHeldStatusHealingItem - call Function3de51 + call HandleStatusHealingItem call SetPlayerTurn - call Function3dd2f + call HandleHPHealingItem call UseHeldStatusHealingItem - jp Function3de51 + jp HandleStatusHealingItem ; 3dd2f -Function3dd2f: ; 3dd2f +HandleHPHealingItem: ; 3dd2f callab GetOpponentItem ld a, b cp $1 @@ -4495,11 +4501,11 @@ Function3dd2f: ; 3dd2f ld hl, EnemyMonMaxHP ld a, [hBattleTurn] and a - jr z, .asm_3dd4a + jr z, .go ld de, BattleMonHP + 1 ld hl, BattleMonMaxHP -.asm_3dd4a +.go push bc ld a, [de] ld [wd1ec], a @@ -4515,17 +4521,17 @@ Function3dd2f: ; 3dd2f cp [hl] ld a, c pop bc - jr z, .asm_3dd62 - jr c, .asm_3dd66 + jr z, .equal + jr c, .less ret -.asm_3dd62 +.equal inc hl cp [hl] dec hl ret nc -.asm_3dd66 +.less call ItemRecoveryAnim ld a, [hli] ld [Buffer2], a @@ -4544,13 +4550,13 @@ Function3dd2f: ; 3dd2f cp c ld a, [hl] sbc b - jr nc, .asm_3dd8d + jr nc, .okay ld a, [hli] ld [wd1ef], a ld a, [hl] ld [wd1ee], a -.asm_3dd8d +.okay ld a, [wd1ef] ld [de], a inc de @@ -4560,10 +4566,10 @@ Function3dd2f: ; 3dd2f ld [wd10a], a and a hlcoord 2, 2 - jr z, .asm_3dda4 + jr z, .got_hp_bar_coords hlcoord 10, 9 -.asm_3dda4 +.got_hp_bar_coords ld [wd10a], a predef AnimateHPBar UseOpponentItem: @@ -4627,7 +4633,7 @@ UseHeldStatusHealingItem: ; 3dde9 and [hl] res SUBSTATUS_NIGHTMARE, [hl] ld a, b - cp 1 << PSN | 1 << FRZ | 1 << BRN | SLP | 1 << PAR + cp ALL_STATUS jr nz, .skip_confuse ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVarAddr @@ -4658,12 +4664,12 @@ UseHeldStatusHealingItem: ; 3dde9 db HELD_HEAL_BURN, 1 << BRN db HELD_HEAL_SLEEP, SLP db HELD_HEAL_PARALYZE, 1 << PAR - db HELD_HEAL_STATUS, 1 << PSN | 1 << FRZ | 1 << BRN | SLP | 1 << PAR + db HELD_HEAL_STATUS, ALL_STATUS db $ff ; 3de51 -Function3de51: ; 3de51 +HandleStatusHealingItem: ; 3de51 ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar bit SUBSTATUS_CONFUSED, a @@ -4671,11 +4677,11 @@ Function3de51: ; 3de51 callab GetOpponentItem ld a, b cp HELD_HEAL_CONFUSION - jr z, .asm_3de67 + jr z, .heal_status cp HELD_HEAL_STATUS ret nz -.asm_3de67 +.heal_status ld a, [hl] ld [wd265], a ld a, BATTLE_VARS_SUBSTATUS3_OPP @@ -4687,8 +4693,8 @@ Function3de51: ; 3de51 call StdBattleTextBox ld a, [hBattleTurn] and a - jr nz, .asm_3de90 - call Function3df1f + jr nz, .do_partymon + call GetOTPartymonItem xor a ld [bc], a ld a, [wBattleMode] @@ -4697,36 +4703,37 @@ Function3de51: ; 3de51 ld [hl], $0 ret -.asm_3de90 - call Function3df12 +.do_partymon + call GetPartymonItem xor a ld [bc], a ld [hl], a ret ; 3de97 -Function3de97: ; 3de97 +HandleStatBoostingHeldItems: ; 3de97 +; The effects handled here are not used in-game. ld a, [hLinkPlayerNumber] cp $1 jr z, .player_1 - call Function3dea9 - jp Function3deb1 + call .DoEnemy + jp .DoPlayer .player_1 - call Function3deb1 - jp Function3dea9 + call .DoPlayer + jp .DoEnemy ; 3dea9 -Function3dea9: ; 3dea9 - call Function3df12 +.DoEnemy: ; 3dea9 + call GetPartymonItem ld a, $0 - jp Function3deb6 + jp .HandleItem ; 3deb1 -Function3deb1: ; 3deb1 - call Function3df1f +.DoPlayer: ; 3deb1 + call GetOTPartymonItem ld a, $1 -Function3deb6: ; 3deb6 +.HandleItem: ; 3deb6 ld [hBattleTurn], a ld d, h ld e, l @@ -4735,16 +4742,16 @@ Function3deb6: ; 3deb6 ld a, [bc] ld b, a callab GetItem - ld hl, .data_3defc -.asm_3dec7 + ld hl, .StatUpItems +.loop ld a, [hli] cp $ff - jr z, .asm_3def9 + jr z, .finish rept 2 inc hl endr cp b - jr nz, .asm_3dec7 + jr nz, .loop pop bc ld a, [bc] ld [wd265], a @@ -4771,13 +4778,13 @@ endr callab BattleCommand_StatUpMessage ret -.asm_3def9 +.finish pop bc pop de ret ; 3defc -.data_3defc +.StatUpItems dbw HELD_ATTACK_UP, BattleCommand_AttackUp dbw HELD_DEFENSE_UP, BattleCommand_DefenseUp dbw HELD_SPEED_UP, BattleCommand_SpeedUp @@ -4789,7 +4796,7 @@ endr ; 3df12 -Function3df12: ; 3df12 +GetPartymonItem: ; 3df12 ld hl, PartyMon1Item ld a, [CurBattleMon] call GetPartyLocation @@ -4797,7 +4804,7 @@ Function3df12: ; 3df12 ret ; 3df1f -Function3df1f: ; 3df1f +GetOTPartymonItem: ; 3df1f ld hl, OTPartyMon1Item ld a, [CurOTMon] call GetPartyLocation @@ -4805,7 +4812,7 @@ Function3df1f: ; 3df1f ret ; 3df2c -Function3df2c: ; 3df2c +UpdateBattleHUDs: ; 3df2c push hl push de push bc @@ -5298,7 +5305,7 @@ Function3e234: ; 3e234 ld a, $1 ld [MenuSelection2], a call ExitMenu - call Function3df2c + call UpdateBattleHUDs call WaitBGMap call LoadTileMapToTempTileMap call ResetTextRelatedRAM @@ -5421,7 +5428,7 @@ Function3e358: ; 3e358 jp Function3e299 .asm_3e36b - ld a, [wc730] + ld a, [wPlayerWrapCount] and a jr nz, .asm_3e378 ld a, [EnemySubStatus5] diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index a9f32942f..e93284c72 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -7247,13 +7247,13 @@ BattleCommand_TrapTarget: ; 36c2d ld a, [AttackMissed] and a ret nz - ld hl, wc731 - ld de, wc72f + ld hl, wEnemyWrapCount + ld de, wEnemyTrappingMove ld a, [hBattleTurn] and a jr z, .asm_36c43 - ld hl, wc730 - ld de, wc72e + ld hl, wPlayerWrapCount + ld de, wPlayerTrappingMove .asm_36c43 ld a, [hl] @@ -7494,7 +7494,7 @@ endr cp HELD_HEAL_CONFUSION ret nz .asm_36db0 - ld hl, Function3de51 + ld hl, HandleStatusHealingItem jp CallBattleCore ; 36db6 @@ -7674,13 +7674,13 @@ endr call GetBattleVarAddr set SUBSTATUS_SUBSTITUTE, [hl] - ld hl, wc730 - ld de, wc72e + ld hl, wPlayerWrapCount + ld de, wPlayerTrappingMove ld a, [hBattleTurn] and a jr z, .player - ld hl, wc731 - ld de, wc72f + ld hl, wEnemyWrapCount + ld de, wEnemyTrappingMove .player xor a @@ -9077,8 +9077,8 @@ ResetBatonPassStatus: ; 37ab1 ld [hl], 0 xor a - ld [wc730], a - ld [wc731], a + ld [wPlayerWrapCount], a + ld [wEnemyWrapCount], a ret ; 37ae9 @@ -9181,12 +9181,12 @@ BattleCommand_ClearHazards: ; 37b39 .asm_37b4a ld hl, PlayerScreens - ld de, wc730 + ld de, wPlayerWrapCount ld a, [hBattleTurn] and a jr z, .asm_37b5b ; 37b53 $6 ld hl, EnemyScreens - ld de, wc731 + ld de, wEnemyWrapCount .asm_37b5b bit SCREENS_SPIKES, [hl] jr z, .asm_37b69 ; 37b5d $a @@ -9526,12 +9526,12 @@ BattleCommand_SkipSunCharge: ; 37d02 BattleCommand_CheckFutureSight: ; 37d0d ; checkfuturesight - ld hl, wc71d + ld hl, wPlayerFutureSightCount ld de, wc727 ld a, [hBattleTurn] and a jr z, .ok - ld hl, wc71e + ld hl, wEnemyFutureSightCount ld de, wc729 .ok @@ -9566,11 +9566,11 @@ BattleCommand_FutureSight: ; 37d34 call GetBattleVarAddr ld [hl], b .asm_37d4b - ld hl, wc71d + ld hl, wPlayerFutureSightCount ld a, [hBattleTurn] and a jr z, .asm_37d56 ; 37d51 $3 - ld hl, wc71e + ld hl, wEnemyFutureSightCount .asm_37d56 ld a, [hl] and a diff --git a/constants/battle_constants.asm b/constants/battle_constants.asm index 99cc04d4d..804f223cb 100644 --- a/constants/battle_constants.asm +++ b/constants/battle_constants.asm @@ -98,6 +98,8 @@ const_value SET 3 const PAR const SLP ; 7 turns +ALL_STATUS EQU (1 << PSN) + (1 << BRN) + (1 << FRZ) + (1 << PAR) + SLP + ; substatus enum_start 7, -1 enum SUBSTATUS_IN_LOVE diff --git a/constants/sprite_constants.asm b/constants/sprite_constants.asm index 209fbf59c..a017d41b0 100644 --- a/constants/sprite_constants.asm +++ b/constants/sprite_constants.asm @@ -219,7 +219,7 @@ NUM_SPRITEHEADER_FIELDS EQU const_value const SPRITEMOVEDATA_SUDOWOODO const SPRITEMOVEDATA_SMASHABLE_ROCK const SPRITEMOVEDATA_STRENGTH_BOULDER - const SPRITEMOVEDATA_1A + const SPRITEMOVEDATA_FOLLOWNOTEXACT const SPRITEMOVEDATA_1B const SPRITEMOVEDATA_1C const SPRITEMOVEDATA_1D @@ -254,7 +254,7 @@ SPRITEMOVEDATA_FIELDS EQU 6 const SPRITEMOVEFN_FOLLOW const SPRITEMOVEFN_SCRIPTED const SPRITEMOVEFN_STRENGTH - const SPRITEMOVEFN_12 + const SPRITEMOVEFN_FOLLOWNOTEXACT const SPRITEMOVEFN_13 const SPRITEMOVEFN_14 const SPRITEMOVEFN_BIG_SNORLAX diff --git a/engine/map_objects.asm b/engine/map_objects.asm index 8c8fcb3c5..7addafd23 100644 --- a/engine/map_objects.asm +++ b/engine/map_objects.asm @@ -29,7 +29,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_STANDING, DOWN, $01, $0c, $00, $00 ; 17 db SPRITEMOVEFN_STANDING, DOWN, $01, $2e, $10, $00 ; 18 db SPRITEMOVEFN_STRENGTH, DOWN, $01, $2e, $00, $40 ; 19 - db SPRITEMOVEFN_12, DOWN, $01, $02, $00, $00 ; 1a + db SPRITEMOVEFN_FOLLOWNOTEXACT, DOWN, $01, $02, $00, $00 ; 1a db SPRITEMOVEFN_13, DOWN, $00, $8e, $01, $00 ; 1b db SPRITEMOVEFN_14, DOWN, $08, $8e, $02, $00 ; 1c db SPRITEMOVEFN_17, DOWN, $00, $82, $00, $00 ; 1d @@ -963,7 +963,7 @@ Function47dd: ; 47dd dw .Follow ; 0f dw .Script ; 10 dw .Strength ; 11 - dw .Movement12 ; 12 + dw .FollowNotExact ; 12 dw .Movement13 ; 13 dw .Movement14 ; 14 dw .MovementBigStanding ; 15 @@ -1145,7 +1145,7 @@ Function47dd: ; 47dd ret ; 48ff -.Movement12: ; 48ff +.FollowNotExact: ; 48ff ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] diff --git a/engine/phone_scripts.asm b/engine/phone_scripts.asm index 5d8afd028..33541e224 100644 --- a/engine/phone_scripts.asm +++ b/engine/phone_scripts.asm @@ -3154,38 +3154,3 @@ String_be657: db "Dad@" String_be65b: db "Sister@" String_be662: db "Brother@" - -TalkToTrainerScript:: ; 0xbe66a - faceplayer - trainerstatus $2 - iftrue AlreadyBeatenTrainerScript - loadtrainerdata - playrammusic - jump StartBattleWithMapTrainerScript -; 0xbe675 - -SeenByTrainerScript:: ; 0xbe675 - loadtrainerdata - playrammusic - showemote EMOTE_SHOCK, LAST_TALKED, 30 - callasm Function831e - applymovement2 MovementBuffer - writepersonxy LAST_TALKED - faceperson PLAYER, LAST_TALKED - jump StartBattleWithMapTrainerScript -; 0xbe68a - -StartBattleWithMapTrainerScript: ; 0xbe68a - loadfont - trainertext $0 - closetext - loadmovesprites - loadtrainerdata - startbattle - returnafterbattle - trainerstatus 1 - loadvar wd04d, -1 - -AlreadyBeatenTrainerScript: - scripttalkafter -; 0xbe699 diff --git a/engine/scripting.asm b/engine/scripting.asm index 360360f79..296f69ecd 100644 --- a/engine/scripting.asm +++ b/engine/scripting.asm @@ -1360,7 +1360,7 @@ Script_writepersonxy: ; 0x9735b ld a, [hLastTalked] .ok ld b, a - callba Function80a1 + callba WritePersonXY ret ; 0x9736f @@ -1376,7 +1376,7 @@ Script_follownotexact: ; 0x9736f call GetScriptByte call GetScriptPerson ld c, a - callba Function839e + callba FollowNotExact ret ; 0x97384 @@ -1546,7 +1546,7 @@ Script_catchtutorial: ; 0x97447 call GetScriptByte ld [BattleType], a call BufferScreen - callba Function4e554 + callba CatchTutorial jp Script_reloadmap ; 0x97459 diff --git a/items/item_effects.asm b/items/item_effects.asm index 0024e3f50..0c1fcc8ac 100644 --- a/items/item_effects.asm +++ b/items/item_effects.asm @@ -724,7 +724,7 @@ endr jp TossItem .used_park_ball - ld hl, wdc79 + ld hl, wParkBallsRemaining dec [hl] ret ; ec0a diff --git a/main.asm b/main.asm index d1eaf8ccd..7334dbb15 100644 --- a/main.asm +++ b/main.asm @@ -3267,10 +3267,11 @@ PlayerSpawn_ConvertCoords: ; 808f ; 80a1 -Function80a1:: ; 80a1 +WritePersonXY:: ; 80a1 ld a, b call CheckObjectVisibility ret c + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] @@ -3685,7 +3686,7 @@ Function830d: ; 830d ret ; 831e -Function831e: ; 831e +TrainerWalkToPlayer: ; 831e ld a, [hLastTalked] call Function1b1e ld a, $3e @@ -3770,7 +3771,7 @@ Function8388: ; 8388 ; 839e -Function839e:: ; 839e +FollowNotExact:: ; 839e push bc ld a, c call CheckObjectVisibility @@ -3778,9 +3779,12 @@ Function839e:: ; 839e ld e, c pop bc ret c + ld a, b call CheckObjectVisibility ret c + +; Person 2 is now in bc, person 1 is now in de ld hl, OBJECT_MAP_X add hl, bc ld a, [hl] @@ -3788,33 +3792,34 @@ Function839e:: ; 839e add hl, bc ld c, [hl] ld b, a + ld hl, OBJECT_MAP_X add hl, de ld a, [hl] cp b - jr z, .asm_83c7 - jr c, .asm_83c4 + jr z, .same_x + jr c, .to_the_left inc b - jr .asm_83d5 + jr .continue -.asm_83c4 +.to_the_left dec b - jr .asm_83d5 + jr .continue -.asm_83c7 +.same_x ld hl, OBJECT_MAP_Y add hl, de ld a, [hl] cp c - jr z, .asm_83d5 - jr c, .asm_83d4 + jr z, .continue + jr c, .below inc c - jr .asm_83d5 + jr .continue -.asm_83d4 +.below dec c -.asm_83d5 +.continue ld hl, OBJECT_MAP_X add hl, de ld [hl], b @@ -3847,7 +3852,7 @@ Function839e:: ; 839e ld [hl], a ld hl, OBJECT_MOVEMENTTYPE add hl, de - ld [hl], SPRITEMOVEDATA_1A + ld [hl], SPRITEMOVEDATA_FOLLOWNOTEXACT ld hl, OBJECT_09 add hl, de ld [hl], $0 @@ -9760,7 +9765,7 @@ Functione41c: ; e41c (3:641c) ld hl, Options ld a, [hl] push af - set 4, [hl] + set NO_TEXT_SCROLL, [hl] ld hl, UnknownText_0xe43a call PrintText pop af @@ -10477,7 +10482,7 @@ Function116c1: ; 116c1 ld hl, Options ld a, [hl] push af - set 4, [hl] + set NO_TEXT_SCROLL, [hl] ld a, [hMapAnims] push af xor a @@ -13919,7 +13924,7 @@ Function12f5b: ; 12f5b ld hl, Options ld a, [hl] push af - set 4, [hl] + set NO_TEXT_SCROLL, [hl] call LoadFontsBattleExtra call Function12f73 pop bc @@ -13983,7 +13988,7 @@ ManagePokemonMoves: ; 12fba ld hl, Options ld a, [hl] push af - set 4, [hl] + set NO_TEXT_SCROLL, [hl] call MoveScreenLoop pop af ld [Options], a @@ -14781,10 +14786,10 @@ Elevator_GetCurrentFloorText: ; 13512 ld hl, Options ld a, [hl] push af - set 4, [hl] + set NO_TEXT_SCROLL, [hl] hlcoord 0, 0 - ld b, $4 - ld c, $8 + ld b, 4 + ld c, 8 call TextBox hlcoord 1, 2 ld de, Elevator_CurrentFloorText @@ -14916,7 +14921,7 @@ Special_GiveParkBalls: ; 135db xor a ld [wContestMon], a ld a, 20 - ld [wdc79], a + ld [wParkBallsRemaining], a callba StartBugContestTimer ret ; 135eb @@ -14926,7 +14931,7 @@ BugCatchingContestBattleScript:: ; 0x135eb battlecheck startbattle returnafterbattle - copybytetovar wdc79 + copybytetovar wParkBallsRemaining iffalse BugCatchingContestOutOfBallsScript end ; 0x135f8 @@ -16605,7 +16610,7 @@ LOG_OFF EQU 6 PC_DisplayTextWaitMenu: ; 157bb ld a, [Options] push af - set 4, a + set NO_TEXT_SCROLL, a ld [Options], a call MenuTextBox pop af @@ -18989,7 +18994,7 @@ Function16be4: ; 16be4 ld [hInMenu], a ld a, [Options] push af - set 4, a + set NO_TEXT_SCROLL, a ld [Options], a call WhiteBGMap call ClearTileMap @@ -20310,7 +20315,7 @@ Function20021: ; 20021 (8:4021) ld hl, Options ld a, [hl] push af - set 4, [hl] + set NO_TEXT_SCROLL, [hl] call LoadPartyMenuDataHeader call ClearTileMap ld hl, UnknownText_0x2004c @@ -20978,7 +20983,7 @@ Function245f1: ; 245f1 ld hl, Options ld a, [hl] push af - set 4, [hl] + set NO_TEXT_SCROLL, [hl] call Function247f0 call Function2488b call Function248b8 @@ -21868,26 +21873,27 @@ ShowMoney_TerminatorString: ; 24b8e ; 24b8f Function24b8f: ; 24b8f +; unreferenced, related to safari? ld hl, Options ld a, [hl] push af - set 4, [hl] + set NO_TEXT_SCROLL, [hl] hlcoord 0, 0 - ld b, $3 - ld c, $7 + ld b, 3 + ld c, 7 call TextBox hlcoord 1, 1 - ld de, wdc7a + ld de, wSafariTimeRemaining lb bc, 2, 3 call PrintNum hlcoord 4, 1 - ld de, String24bcf + ld de, .slash_500 call PlaceString hlcoord 1, 3 - ld de, String24bd4 + ld de, .booru_ko call PlaceString hlcoord 5, 3 - ld de, wdc79 + ld de, wSafariBallsRemaining lb bc, 1, 2 call PrintNum pop af @@ -21895,9 +21901,9 @@ Function24b8f: ; 24b8f ret ; 24bcf -String24bcf: ; 24bcf +.slash_500: ; 24bcf db "/500@" -String24bd4: ; 24bd4 +.booru_ko: ; 24bd4 db "ボール こ@" ; 24bdc @@ -21919,7 +21925,7 @@ Function24be7: ; 24be7 ld de, String24c52 call PlaceString hlcoord 8, 5 - ld de, wdc79 + ld de, wSafariBallsRemaining lb bc, PRINTNUM_RIGHTALIGN | 1, 2 call PrintNum hlcoord 1, 1 @@ -22459,7 +22465,7 @@ Strings24f5f: ; 24f5f Function24f7c: ; 24f7c hlcoord 17, 13 - ld de, wdc79 + ld de, wSafariBallsRemaining lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ret @@ -22484,14 +22490,14 @@ MenuData_0x24f91: ; 24f91 Strings24f9a: ; 24f9a db "FIGHT@" - db $4a, "@" + db "", "@" db "PARKBALL× @" db "RUN@" ; 24fb2 Function24fb2: ; 24fb2 hlcoord 13, 16 - ld de, wdc79 + ld de, wParkBallsRemaining lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ret @@ -27020,16 +27026,16 @@ Function28b87: ; 28b87 ld a, [wd003] call GetPartyLocation ld a, [hli] - ld [wc731], a + ld [wEnemyWrapCount], a ld a, [hl] ld [wPlayerCharging], a ld hl, OTPartyMon1DVs ld a, [wd003] call GetPartyLocation ld a, [hli] - ld [wc72f], a + ld [wEnemyTrappingMove], a ld a, [hl] - ld [wc730], a + ld [wPlayerWrapCount], a ld a, [wd003] ld hl, OTPartyMon1Species call GetPartyLocation @@ -27400,7 +27406,7 @@ Function28fdb: ; 28fdb ld de, VTiles0 call Function29491 ld a, [wc702] - ld hl, wc72f + ld hl, wEnemyTrappingMove ld de, VTiles0 tile $31 call Function29491 ld a, [wc6d0] @@ -28011,9 +28017,9 @@ Function29461: ; 29461 call Function29549 ld a, [wc702] ld [CurPartySpecies], a - ld a, [wc72f] + ld a, [wEnemyTrappingMove] ld [TempMonDVs], a - ld a, [wc730] + ld a, [wPlayerWrapCount] ld [TempMonDVs + 1], a ld b, $1a call GetSGBLayout @@ -28153,7 +28159,7 @@ Function29549: ; 29549 ld a, [wEnemyCharging] ld de, wc724 call Function295f6 - ld de, wc731 + ld de, wEnemyWrapCount call Function29611 call Function295d8 ret @@ -41188,7 +41194,7 @@ FlagPredef: ; 4d7c1 Function4d7fd: ; 4d7fd ld a, [wc702] - ld hl, wc72f + ld hl, wEnemyTrappingMove ld de, VTiles2 push de push af @@ -41209,9 +41215,9 @@ Function4d81e: ; 4d81e callba Function29549 ld a, [wc702] ld [CurPartySpecies], a - ld a, [wc72f] + ld a, [wEnemyTrappingMove] ld [TempMonDVs], a - ld a, [wc730] + ld a, [wPlayerWrapCount] ld [TempMonDVs + 1], a ld b, $1a call GetSGBLayout @@ -43043,11 +43049,11 @@ CheckFaintedFrzSlp: ; 4e53f ; 4e554 -Function4e554:: ; 4e554 +CatchTutorial:: ; 4e554 ld a, [BattleType] dec a ld c, a - ld hl, Jumptable_4e564 + ld hl, .jumptable ld b, 0 rept 2 add hl, bc @@ -43058,23 +43064,24 @@ endr jp [hl] ; 4e564 -Jumptable_4e564: ; 4e564 (13:6564) - dw Function4e56a - dw Function4e56a - dw Function4e56a +.jumptable: ; 4e564 (13:6564) + dw .DudeTutorial + dw .DudeTutorial + dw .DudeTutorial -Function4e56a: ; 4e56a (13:656a) +.DudeTutorial: ; 4e56a (13:656a) +; Back up your name to your Mom's name. ld hl, PlayerName ld de, MomsName ld bc, NAME_LENGTH call CopyBytes - - ld hl, DudeString +; Copy Dude's name to your name + ld hl, .Dude ld de, PlayerName ld bc, NAME_LENGTH call CopyBytes - call Function4e5b7 + call .LoadDudeData xor a ld [hJoyDown], a @@ -43084,8 +43091,8 @@ Function4e56a: ; 4e56a (13:656a) and $f8 add $3 ld [Options], a - ld hl, AutoInput_4e5df - ld a, BANK(AutoInput_4e5df) + ld hl, .AutoInput + ld a, BANK(.AutoInput) call StartAutoInput callab StartBattle call StopAutoInput @@ -43098,13 +43105,13 @@ Function4e56a: ; 4e56a (13:656a) call CopyBytes ret -Function4e5b7: ; 4e5b7 (13:65b7) +.LoadDudeData: ; 4e5b7 (13:65b7) ld hl, OTPartyMon1 - ld [hl], $1 + ld [hl], BULBASAUR inc hl - ld [hl], $12 + ld [hl], POTION inc hl - ld [hl], $1 + ld [hl], POUND inc hl ld [hl], $ff ld hl, OTPartyMon1Exp + 2 @@ -43122,474 +43129,17 @@ endr ret ; 4e5da (13:65da) -DudeString: ; 4e5da +.Dude: ; 4e5da db "DUDE@" ; 4e5df -AutoInput_4e5df: ; 4e5df +.AutoInput: ; 4e5df db NO_INPUT, $ff ; end ; 4e5e1 +INCLUDE "engine/evolution_animation.asm" -EvolutionAnimation: ; 4e5e1 - push hl - push de - push bc - ld a, [CurSpecies] - push af - ld a, [rOBP0] - push af - ld a, [BaseDexNo] - push af - - call _EvolutionAnimation - - pop af - ld [BaseDexNo], a - pop af - ld [rOBP0], a - pop af - ld [CurSpecies], a - pop bc - pop de - pop hl - - ld a, [wd1ed] - and a - ret z - - scf - ret -; 4e607 - -_EvolutionAnimation: ; 4e607 - ld a, $e4 - ld [rOBP0], a - - ld de, MUSIC_NONE - call PlayMusic - - callba Function8cf53 - - ld de, EvolutionGFX - ld hl, VTiles0 - lb bc, BANK(EvolutionGFX), 8 - call Request2bpp - - xor a - ld [Danger], a - call WaitBGMap - xor a - ld [hBGMapMode], a - ld a, [Buffer1] - ld [PlayerHPPal], a - - ld c, $0 - call Function4e703 - ld a, [Buffer1] - ld [CurPartySpecies], a - ld [CurSpecies], a - call Function4e708 - - ld de, VTiles2 - ld hl, VTiles2 tile $31 - ld bc, $31 - call Request2bpp - - ld a, $31 - ld [wd1ec], a - call Function4e755 - ld a, [Buffer2] - ld [CurPartySpecies], a - ld [CurSpecies], a - call Function4e711 - ld a, [Buffer1] - ld [CurPartySpecies], a - ld [CurSpecies], a - - ld a, $1 - ld [hBGMapMode], a - call Function4e794 - jr c, .asm_4e67c - - ld a, [Buffer1] - call PlayCry - -.asm_4e67c - ld de, MUSIC_EVOLUTION - call PlayMusic - - ld c, 80 - call DelayFrames - - ld c, $1 - call Function4e703 - call Function4e726 - jr c, .asm_4e6df - - ld a, $cf - ld [wd1ec], a - - call Function4e755 - xor a - ld [wd1ed], a - - ld a, [Buffer2] - ld [PlayerHPPal], a - - ld c, $0 - call Function4e703 - call Function4e7a6 - callba Function8cf53 - call Function4e794 - jr c, .asm_4e6de - - ld a, [wc2c6] - push af - ld a, $1 - ld [wc2c6], a - ld a, [CurPartySpecies] - push af - - ld a, [PlayerHPPal] - ld [CurPartySpecies], a - hlcoord 7, 2 - ld d, $0 - ld e, ANIM_MON_EVOLVE - predef AnimateFrontpic - - pop af - ld [CurPartySpecies], a - pop af - ld [wc2c6], a - ret - -.asm_4e6de - ret - -.asm_4e6df - ld a, $1 - ld [wd1ed], a - - ld a, [Buffer1] - ld [PlayerHPPal], a - - ld c, $0 - call Function4e703 - call Function4e7a6 - callba Function8cf53 - call Function4e794 - ret c - - ld a, [PlayerHPPal] - call PlayCry - ret -; 4e703 - -Function4e703: ; 4e703 - ld b, $b - jp GetSGBLayout -; 4e708 - -Function4e708: ; 4e708 - call GetBaseData - hlcoord 7, 2 - jp Function3786 -; 4e711 - -Function4e711: ; 4e711 - call GetBaseData - ld a, $1 - ld [wc2c6], a - ld de, VTiles2 - predef Function5108b - xor a - ld [wc2c6], a - ret -; 4e726 - -Function4e726: ; 4e726 - call ClearJoypad - lb bc, 1, 14 -.asm_4e72c - push bc - call Function4e779 - pop bc - jr c, .asm_4e73f - push bc - call Function4e741 - pop bc - inc b -rept 2 - dec c -endr - jr nz, .asm_4e72c - and a - ret - -.asm_4e73f - scf - ret -; 4e741 - -Function4e741: ; 4e741 -.asm_4e741 - ld a, $cf - ld [wd1ec], a - call Function4e755 - ld a, $31 - ld [wd1ec], a - call Function4e755 - dec b - jr nz, .asm_4e741 - ret -; 4e755 - -Function4e755: ; 4e755 - push bc - xor a - ld [hBGMapMode], a - hlcoord 7, 2 - lb bc, 7, 7 - ld de, $d -.asm_4e762 - push bc -.asm_4e763 - ld a, [wd1ec] - add [hl] - ld [hli], a - dec c - jr nz, .asm_4e763 - pop bc - add hl, de - dec b - jr nz, .asm_4e762 - ld a, $1 - ld [hBGMapMode], a - call WaitBGMap - pop bc - ret -; 4e779 - -Function4e779: ; 4e779 -.asm_4e779 - call DelayFrame - push bc - call JoyTextDelay - ld a, [hJoyDown] - pop bc - and B_BUTTON - jr nz, .asm_4e78c -.asm_4e787 - dec c - jr nz, .asm_4e779 - and a - ret - -.asm_4e78c - ld a, [wd1e9] - and a - jr nz, .asm_4e787 - scf - ret -; 4e794 - -Function4e794: ; 4e794 - ld a, [CurPartyMon] - ld hl, PartyMon1Species - call GetPartyLocation - ld b, h - ld c, l - callba CheckFaintedFrzSlp - ret -; 4e7a6 - -Function4e7a6: ; 4e7a6 - ld a, [wd1ed] - and a - ret nz - ld de, SFX_EVOLVED - call PlaySFX - ld hl, wJumptableIndex - ld a, [hl] - push af - ld [hl], $0 -.asm_4e7b8 - call Function4e7cf - jr nc, .asm_4e7c2 - call Function4e80c - jr .asm_4e7b8 - -.asm_4e7c2 - ld c, $20 -.asm_4e7c4 - call Function4e80c - dec c - jr nz, .asm_4e7c4 - pop af - ld [wJumptableIndex], a - ret -; 4e7cf - -Function4e7cf: ; 4e7cf - ld hl, wJumptableIndex - ld a, [hl] - cp $20 - ret nc - ld d, a - inc [hl] - and $1 - jr nz, .asm_4e7e6 - ld e, $0 - call Function4e7e8 - ld e, $10 - call Function4e7e8 - -.asm_4e7e6 - scf - ret -; 4e7e8 - -Function4e7e8: ; 4e7e8 - push de - ld de, $4858 - ld a, $13 - call Function3b2a - ld hl, $b - add hl, bc - ld a, [wJumptableIndex] - and $e - sla a - pop de - add e - ld [hl], a - ld hl, $3 - add hl, bc - ld [hl], $0 - ld hl, $c - add hl, bc - ld [hl], $10 - ret -; 4e80c - -Function4e80c: ; 4e80c - push bc - callab Function8cf69 - ld a, [$ff9b] - and $e - srl a -rept 2 - inc a -endr - and $7 - ld b, a - ld hl, Sprites + 3 - ld c, $28 -.asm_4e823 - ld a, [hl] - or b - ld [hli], a -rept 3 - inc hl -endr - dec c - jr nz, .asm_4e823 - pop bc - call DelayFrame - ret -; 4e831 - - -EvolutionGFX: -INCBIN "gfx/evo/bubble_large.2bpp" -INCBIN "gfx/evo/bubble.2bpp" - -Function4e881: ; 4e881 - call WhiteBGMap - call ClearTileMap - call ClearSprites - call DisableLCD - call LoadStandardFont - call LoadFontsBattleExtra - ld hl, VBGMap0 - ld bc, VBGMap1 - VBGMap0 - ld a, " " - call ByteFill - hlcoord 0, 0, AttrMap - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - xor a - call ByteFill - xor a - ld [hSCY], a - ld [hSCX], a - call EnableLCD - ld hl, UnknownText_0x4e8bd - call PrintText - call Function3200 - call SetPalettes - ret -; 4e8bd - -UnknownText_0x4e8bd: ; 0x4e8bd - ; SAVING RECORD… DON'T TURN OFF! - text_jump UnknownText_0x1bd39e - db "@" -; 0x4e8c2 - - -Function4e8c2: ; 4e8c2 - call WhiteBGMap - call ClearTileMap - call ClearSprites - call DisableLCD - call LoadStandardFont - call LoadFontsBattleExtra - ld hl, VBGMap0 - ld bc, VBGMap1 - VBGMap0 - ld a, " " - call ByteFill - hlcoord 0, 0, AttrMap - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - xor a - call ByteFill - ld hl, wd000 - ld c, $40 -.asm_4e8ee - ld a, -1 - ld [hli], a - ld a, " " - ld [hli], a - dec c - jr nz, .asm_4e8ee - xor a - ld [hSCY], a - ld [hSCX], a - call EnableLCD - call Function3200 - call SetPalettes - ret -; 4e906 - -Function4e906: ; 4e906 - ld a, [rSVBK] - push af - ld a, $6 - ld [rSVBK], a - ld hl, w6_d000 - ld bc, w6_d400 - w6_d000 - ld a, " " - call ByteFill - ld hl, VBGMap0 - ld de, w6_d000 - ld b, $0 - ld c, $40 - call Request2bpp - pop af - ld [rSVBK], a - ret -; 4e929 - -Function4e929: ; 4e929 +Function4e929: ; mobile function ld h, b ld l, c call Function4e930 @@ -43601,35 +43151,35 @@ Function4e930: ; 4e930 ld a, [hli] xor [hl] ld c, a - jr z, .asm_4e941 + jr z, .skip_male_trainers srl c srl c -.asm_4e939 +.male_trainer_loop srl c ld a, c cp MaleTrainersEnd - MaleTrainers - 1 - jr nc, .asm_4e939 + jr nc, .male_trainer_loop inc c -.asm_4e941 +.skip_male_trainers ld a, [de] cp $1 ld hl, MaleTrainers - jr nz, .asm_4e958 + jr nz, .finished ld hl, FemaleTrainers ld a, c and a - jr z, .asm_4e958 + jr z, .finished -.asm_4e950 +.female_trainer_loop srl c ld a, c cp FemaleTrainersEnd - FemaleTrainers - 1 - jr nc, .asm_4e950 + jr nc, .female_trainer_loop inc c -.asm_4e958 +.finished ld b, $0 add hl, bc ld a, [hl] @@ -64133,6 +63683,42 @@ INCLUDE "engine/std_scripts.asm" INCLUDE "engine/phone_scripts.asm" +TalkToTrainerScript:: ; 0xbe66a + faceplayer + trainerstatus CHECK_FLAG + iftrue AlreadyBeatenTrainerScript + loadtrainerdata + playrammusic + jump StartBattleWithMapTrainerScript +; 0xbe675 + +SeenByTrainerScript:: ; 0xbe675 + loadtrainerdata + playrammusic + showemote EMOTE_SHOCK, LAST_TALKED, 30 + callasm TrainerWalkToPlayer + applymovement2 MovementBuffer + writepersonxy LAST_TALKED + faceperson PLAYER, LAST_TALKED + jump StartBattleWithMapTrainerScript +; 0xbe68a + +StartBattleWithMapTrainerScript: ; 0xbe68a + loadfont + trainertext $0 + closetext + loadmovesprites + loadtrainerdata + startbattle + returnafterbattle + trainerstatus SET_FLAG + loadvar wd04d, -1 + +AlreadyBeatenTrainerScript: + scripttalkafter +; 0xbe699 + + SECTION "bank30", ROMX, BANK[$30] @@ -74748,13 +74334,13 @@ Functionfcc63: ; fcc63 ld e, TRADE_DVS call GetTradeAttribute - ld de, wc72f + ld de, wEnemyTrappingMove call Functionfce0f ld hl, PartyMon1DVs ld bc, PARTYMON_STRUCT_LENGTH call Functionfcdde - ld hl, wc72f + ld hl, wEnemyTrappingMove call Functionfce0f ld e, TRADE_OT_ID @@ -74765,7 +74351,7 @@ Functionfcc63: ; fcc63 ld hl, PartyMon1ID ld bc, PARTYMON_STRUCT_LENGTH call Functionfcdde - ld hl, wc731 + ld hl, wEnemyWrapCount call Functionfce0f ld e, TRADE_ITEM diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm index 851b6d2c6..e7b73aa36 100644 --- a/misc/mobile_40.asm +++ b/misc/mobile_40.asm @@ -6382,7 +6382,7 @@ Function102a3b: ; 102a3b ld hl, OTPartyMon1ID call GetPartyLocation ld a, [hli] - ld [wc731], a + ld [wEnemyWrapCount], a ld a, [hl] ld [wPlayerCharging], a ld a, [wcd4d] @@ -6390,9 +6390,9 @@ Function102a3b: ; 102a3b ld hl, OTPartyMon1DVs call GetPartyLocation ld a, [hli] - ld [wc72f], a + ld [wEnemyTrappingMove], a ld a, [hl] - ld [wc730], a + ld [wPlayerWrapCount], a ld a, [wcd4d] dec a ld hl, OTPartyMon1Species diff --git a/misc/mobile_42.asm b/misc/mobile_42.asm index fcd99e927..72a8f9e8c 100644 --- a/misc/mobile_42.asm +++ b/misc/mobile_42.asm @@ -170,7 +170,7 @@ Function1080b7: ; 1080b7 ld de, VTiles0 tile $30 call Function1081e9 ld a, [wc702] - ld hl, wc72f + ld hl, wEnemyTrappingMove ld de, VTiles2 tile $31 call Function1081e9 ld a, [$c6d0] @@ -515,7 +515,7 @@ Function10839b: ; 10839b call Function1081ca ld a, [wc702] ld [CurPartySpecies], a - ld hl, wc72f + ld hl, wEnemyTrappingMove ld de, VTiles2 call Function108201 call EnableLCD @@ -548,9 +548,9 @@ Function10839b: ; 10839b ld [hWY], a ld a, [wc702] ld [CurPartySpecies], a - ld a, [wc72f] + ld a, [wEnemyTrappingMove] ld [TempMonDVs], a - ld a, [wc730] + ld a, [wPlayerWrapCount] ld [TempMonDVs + 1], a ld b, $1a call GetSGBLayout @@ -650,7 +650,7 @@ Function1084d7: ; 1084d7 call Function1081ca ld a, [wc702] ld [CurPartySpecies], a - ld hl, wc72f + ld hl, wEnemyTrappingMove ld de, VTiles2 call Function108201 call EnableLCD @@ -692,16 +692,16 @@ Function1084d7: ; 1084d7 ld [hWY], a ld a, [wc702] ld [CurPartySpecies], a - ld a, [wc72f] + ld a, [wEnemyTrappingMove] ld [TempMonDVs], a - ld a, [wc730] + ld a, [wPlayerWrapCount] ld [TempMonDVs + 1], a ld b, $1a call GetSGBLayout ld a, $e4 call DmgToCgbBGPals ld a, [wc702] - ld hl, wc72f + ld hl, wEnemyTrappingMove call Function10898a ld a, [wc702] call Function108229 @@ -719,7 +719,7 @@ Function108589: ; 108589 call Function1081ca ld a, [wc702] ld [CurPartySpecies], a - ld hl, wc72f + ld hl, wEnemyTrappingMove ld de, VTiles2 call Function108201 call EnableLCD @@ -761,16 +761,16 @@ Function108589: ; 108589 ld [hWY], a ld a, [wc702] ld [CurPartySpecies], a - ld a, [wc72f] + ld a, [wEnemyTrappingMove] ld [TempMonDVs], a - ld a, [wc730] + ld a, [wPlayerWrapCount] ld [TempMonDVs + 1], a ld b, $1a call GetSGBLayout ld a, $e4 call DmgToCgbBGPals ld a, [wc702] - ld hl, wc72f + ld hl, wEnemyTrappingMove call Function10898a ld a, [wc702] call Function108229 @@ -1262,7 +1262,7 @@ Function1089d2: ld a, [wEnemyCharging] ld de, wc724 call Function108aa3 - ld de, wc731 + ld de, wEnemyWrapCount call Function108abe call Function108a87 ret @@ -1737,7 +1737,7 @@ Function108c9b: ; 108c9b dec c jr nz, .asm_108ccc - ld de, wc731 + ld de, wEnemyWrapCount ld c, $2 .asm_108cd7 ld a, [hli] diff --git a/misc/mobile_46.asm b/misc/mobile_46.asm index 8462331d6..9e22761b4 100755 --- a/misc/mobile_46.asm +++ b/misc/mobile_46.asm @@ -7656,14 +7656,14 @@ Function11b7e5: ; 11b7e5 ld a, $50 ld [de], a ld a, [$c608 + 11] - ld [wc731], a + ld [wEnemyWrapCount], a ld a, [$c608 + 12] ld [wPlayerCharging], a ld hl, $c608 + 26 ld a, [hli] - ld [wc72f], a + ld [wEnemyTrappingMove], a ld a, [hl] - ld [wc730], a + ld [wPlayerWrapCount], a ld bc, $c608 + 5 callba GetCaughtGender ld a, c diff --git a/misc/mobile_5c.asm b/misc/mobile_5c.asm index 54d22b8ec..d82b84e82 100755 --- a/misc/mobile_5c.asm +++ b/misc/mobile_5c.asm @@ -55,12 +55,12 @@ Function17005a: ; 17005a ld [de], a ld hl, $a841 ld a, [hli] - ld [wc72f], a + ld [wEnemyTrappingMove], a ld a, [hl] - ld [wc730], a + ld [wPlayerWrapCount], a ld hl, $a832 ld a, [hli] - ld [wc731], a + ld [wEnemyWrapCount], a ld a, [hl] ld [wPlayerCharging], a ld bc, $a82c @@ -177,7 +177,7 @@ Function170139: ; 170139 ld e, l ld d, h ld hl, PlayerName - ld bc, $0005 + ld bc, $0005 ; Japanese name length call CopyBytes ld bc, PlayerID ld de, PlayerGender diff --git a/misc/mobile_5f.asm b/misc/mobile_5f.asm index a912c2770..54b1d9203 100644 --- a/misc/mobile_5f.asm +++ b/misc/mobile_5f.asm @@ -283,14 +283,14 @@ Function17d0f3: ; 17d0f3 ld a, $50 ld [de], a ld a, [$c608 + 11] - ld [wc731], a + ld [wEnemyWrapCount], a ld a, [$c608 + 12] ld [wPlayerCharging], a ld hl, $c608 + 26 ld a, [hli] - ld [wc72f], a + ld [wEnemyTrappingMove], a ld a, [hl] - ld [wc730], a + ld [wPlayerWrapCount], a ld bc, $c608 + 5 callba GetCaughtGender ld a, c diff --git a/wram.asm b/wram.asm index ef7ee6916..49e691e97 100644 --- a/wram.asm +++ b/wram.asm @@ -841,8 +841,8 @@ LastPlayerMove:: ; c71b LastEnemyMove:: ; c71c ds 1 -wc71d:: ds 1 -wc71e:: ds 1 +wPlayerFutureSightCount:: ds 1 +wEnemyFutureSightCount:: ds 1 wc71f:: ds 1 wc720:: ds 4 ; copy from/to EnemyMonBaseStats, length=7 wc724:: ds 3 @@ -851,10 +851,10 @@ wc729:: ds 2 wPlayerRageCounter:: ds 1 wEnemyRageCounter:: ds 1 wc72d:: ds 1 ; if 0 then PrintButItFailed -wc72e:: ds 1 -wc72f:: ds 1 -wc730:: ds 1 -wc731:: ds 1 +wPlayerTrappingMove:: ds 1 +wEnemyTrappingMove:: ds 1 +wPlayerWrapCount:: ds 1 +wEnemyWrapCount:: ds 1 wPlayerCharging:: ds 1 wEnemyCharging:: ds 1 wc734:: @@ -1636,8 +1636,8 @@ wd148:: ds 1 wd149:: ds 1 wd14a:: ds 1 wd14b:: ds 1 -wd14c:: ds 1 -wd14d:: ds 1 +wd14c:: ds 1 ; used in FollowNotExact +wd14d:: ds 1 ; used in FollowNotExact wd14e:: ds 1 wd14f:: ds 1 wd150:: ds 1 @@ -2512,8 +2512,10 @@ PoisonStepCount:: ; dc74 ds 2 wdc77:: ds 2 -wdc79:: ds 1 -wdc7a:: ds 2 +wdc79:: +wParkBallsRemaining:: +wSafariBallsRemaining:: ds 1 +wSafariTimeRemaining:: ds 2 wPhoneList:: ds CONTACT_LIST_SIZE ds 23 wLuckyNumberShowFlag:: ds 2 ; dc9d