diff options
Diffstat (limited to 'battle')
-rw-r--r-- | battle/ai/items.asm | 6 | ||||
-rw-r--r-- | battle/anim_commands.asm | 44 | ||||
-rw-r--r-- | battle/core.asm | 489 | ||||
-rw-r--r-- | battle/effect_commands.asm | 58 | ||||
-rw-r--r-- | battle/effects/thief.asm | 4 | ||||
-rw-r--r-- | battle/magikarp_length.asm | 215 | ||||
-rw-r--r-- | battle/misc.asm | 2 |
7 files changed, 524 insertions, 294 deletions
diff --git a/battle/ai/items.asm b/battle/ai/items.asm index 7d847b9da..95997a67e 100644 --- a/battle/ai/items.asm +++ b/battle/ai/items.asm @@ -1,11 +1,11 @@ AI_SwitchOrTryItem: ; 38000 and a - ld a, [IsInBattle] + ld a, [wBattleMode] dec a ret z - ld a, [InLinkBattle] + ld a, [wLinkMode] and a ret nz @@ -731,7 +731,7 @@ AI_Switch: ; 3846c callba Function3d57a xor a ld [wd264], a - ld a, [InLinkBattle] + ld a, [wLinkMode] and a ret nz scf diff --git a/battle/anim_commands.asm b/battle/anim_commands.asm index 80b9bf41d..82d5eab62 100644 --- a/battle/anim_commands.asm +++ b/battle/anim_commands.asm @@ -237,16 +237,16 @@ Functioncc220: ; cc220 ; Appears to be unused. xor a ld [hBGMapMode], a - ld a, $80 + ld a, (VBGMap0 tile $28) % $100 ld [hBGMapAddress], a - ld a, $9a + ld a, (VBGMap0 tile $28) / $100 ld [hBGMapAddress + 1], a call Function3200 ld a, $60 ld [hWY], a xor a ld [hBGMapAddress], a - ld a, $98 + ld a, VBGMap0 / $100 ld [hBGMapAddress + 1], a call BattleAnimDelayFrame ret @@ -709,7 +709,7 @@ BattleAnimCmd_D5: ; cc485 (33:4485) rept 4 add hl, hl endr - ld de, $8310 + ld de, VTiles0 tile $31 add hl, de ld a, [BattleAnimByte] call Functionce846 @@ -817,13 +817,13 @@ endr ld a, $49 ld [hl], a - ld hl, $8730 - ld de, $9060 + ld hl, VTiles0 tile $73 + ld de, VTiles2 tile $06 ld a, $70 ld [BattleAnimTemps], a ld a, $7 call Functioncc561 - ld de, $9310 + ld de, VTiles2 tile $31 ld a, $60 ld [BattleAnimTemps], a ld a, $6 @@ -873,13 +873,13 @@ endr ld a, $43 ld [hl], a - ld hl, $8660 - ld de, $9050 + ld hl, VTiles0 tile $66 + ld de, VTiles2 tile $05 ld a, $70 ld [BattleAnimTemps], a ld a, $7 call Functioncc5b3 - ld de, $9310 + ld de, VTiles2 tile $31 ld a, $60 ld [BattleAnimTemps], a ld a, $6 @@ -932,7 +932,7 @@ BattleAnimCmd_DC: ; cc5dc (33:45dc) ld [CurPartySpecies], a ; CurPartySpecies ld hl, BattleMonDVs ; BattleMonDVs predef GetUnownLetter - ld de, $8000 + ld de, VTiles0 tile $00 predef GetFrontpic jr .done @@ -941,7 +941,7 @@ BattleAnimCmd_DC: ; cc5dc (33:45dc) ld [CurPartySpecies], a ; CurPartySpecies ld hl, EnemyMonDVs ; EnemyMonDVs predef GetUnownLetter - ld de, $8000 + ld de, VTiles0 tile $00 predef GetBackpic .done @@ -953,19 +953,19 @@ BattleAnimCmd_DC: ; cc5dc (33:45dc) BattleAnimCmd_E8: ; cc622 (33:4622) - ld de, $8000 + ld de, VTiles0 tile $00 ld a, [hBattleTurn] ; $ff00+$e4 and a jr z, .player - ld hl, $9000 + ld hl, VTiles2 tile $00 ld b, 0 ld c, $31 call Request2bpp ret .player - ld hl, $9310 + ld hl, VTiles2 tile $31 ld b, 0 ld c, $24 call Request2bpp @@ -1009,7 +1009,7 @@ GetSubstitutePic: ; cc64c ld de, sScratch + $1b0 call CopyMonsterSpriteTile - ld hl, $9000 + ld hl, VTiles2 tile $00 ld de, sScratch lb bc, BANK(GetSubstitutePic), 7 * 7 call Request2bpp @@ -1029,7 +1029,7 @@ GetSubstitutePic: ; cc64c ld de, sScratch + $170 call CopyMonsterSpriteTile - ld hl, $9310 + ld hl, VTiles2 tile $31 ld de, sScratch lb bc, BANK(GetSubstitutePic), 6 * 6 call Request2bpp @@ -1077,7 +1077,7 @@ GetMinimizePic: ; cc6e7 (33:46e7) ld de, sScratch + $1a0 call CopyMinimizePic - ld hl, $9000 + ld hl, VTiles2 tile $00 ld de, sScratch lb bc, BANK(GetMinimizePic), $31 ret @@ -1085,7 +1085,7 @@ GetMinimizePic: ; cc6e7 (33:46e7) .player ld de, sScratch + $160 call CopyMinimizePic - ld hl, $9310 + ld hl, VTiles2 tile $31 ld de, sScratch lb bc, BANK(GetMinimizePic), $24 ret @@ -1110,7 +1110,7 @@ BattleAnimCmd_E9: ; cc735 (33:4735) xor a call GetSRAMBank call GetMinimizePic - ld hl, $8000 + ld hl, VTiles0 tile $00 call Request2bpp call CloseSRAM pop af @@ -1159,14 +1159,14 @@ BattleAnimCmd_E6: ; cc776 (33:4776) ld hl, BattleMonDVs ; BattleMonDVs predef GetUnownLetter - ld de, $9000 + ld de, VTiles2 tile $00 predef GetFrontpic jr .done .player ld hl, EnemyMonDVs ; EnemyMonDVs predef GetUnownLetter - ld de, $9310 + ld de, VTiles2 tile $31 predef GetBackpic .done diff --git a/battle/core.asm b/battle/core.asm index 5f355fc27..f3227150a 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -25,7 +25,7 @@ Function3c000: ; 3c000 .asm_3c021 ld a, d ld [wBattleAction], a - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, .asm_3c031 @@ -34,7 +34,7 @@ Function3c000: ; 3c000 jr z, .asm_3c04c .asm_3c031 - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr z, .asm_3c047 xor a @@ -97,7 +97,7 @@ Function3c000: ; 3c000 call Function309d call SetPlayerTurn call SpikesDamage - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, .asm_3c0df ld a, [$ffcb] @@ -123,18 +123,18 @@ Function3c000: ; 3c000 WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5 call Function30b4 - ld a, [wd0ee] + ld a, [wBattleResult] and $c0 add $2 - ld [wd0ee], a - ld a, [InLinkBattle] + ld [wBattleResult], a + ld a, [wLinkMode] and a ld hl, BattleText_WildFled jr z, .asm_3c115 - ld a, [wd0ee] + ld a, [wBattleResult] and $c0 - ld [wd0ee], a + ld [wBattleResult], a ld hl, BattleText_EnemyFled call Function3d2e0 jr nc, .asm_3c115 @@ -149,7 +149,7 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5 call StdBattleTextBox .asm_3c118 - call Function3ceec + call StopDangerSound call Function3d2e0 jr c, .asm_3c126 @@ -264,40 +264,40 @@ Function3c1c0: ; 3c1c0 Function3c1d6: ; 3c1d6 ld a, [$ffcb] cp $1 - jr z, .asm_3c1fe - call Function3c23c + jr z, .CheckEnemyFirst + call CheckFaint_PlayerThenEnemy ret c call Function3ca26 - call Function3c23c + call CheckFaint_PlayerThenEnemy ret c call HandleWeather - call Function3c23c + call CheckFaint_PlayerThenEnemy ret c call Function3c874 - call Function3c23c + call CheckFaint_PlayerThenEnemy ret c call Function3c801 - call Function3c23c + call CheckFaint_PlayerThenEnemy ret c - jr .asm_3c21e + jr .NoMoreFaintingConditions -.asm_3c1fe - call Function3c25c +.CheckEnemyFirst + call CheckFaint_EnemyThenPlayer ret c call Function3ca26 - call Function3c25c + call CheckFaint_EnemyThenPlayer ret c call HandleWeather - call Function3c25c + call CheckFaint_EnemyThenPlayer ret c call Function3c874 - call Function3c25c + call CheckFaint_EnemyThenPlayer ret c call Function3c801 - call Function3c25c + call CheckFaint_EnemyThenPlayer ret c -.asm_3c21e +.NoMoreFaintingConditions call Function3c8eb call Function3c93c call HanleDefrost @@ -310,52 +310,52 @@ Function3c1d6: ; 3c1d6 jp Function3c4df ; 3c23c -Function3c23c: ; 3c23c +CheckFaint_PlayerThenEnemy: ; 3c23c call HasPlayerFainted - jr nz, .asm_3c24a - call Function3d14e + jr nz, .PlayerNotFainted + call HandlePlayerMonFaint ld a, [BattleEnded] and a - jr nz, .asm_3c25a + jr nz, .BattleIsOver -.asm_3c24a +.PlayerNotFainted call HasEnemyFainted - jr nz, .asm_3c258 - call Function3cd55 + jr nz, .BattleContinues + call HandleEnemyMonFaint ld a, [BattleEnded] and a - jr nz, .asm_3c25a + jr nz, .BattleIsOver -.asm_3c258 +.BattleContinues and a ret -.asm_3c25a +.BattleIsOver scf ret ; 3c25c -Function3c25c: ; 3c25c +CheckFaint_EnemyThenPlayer: ; 3c25c call HasEnemyFainted - jr nz, .asm_3c26a - call Function3cd55 + jr nz, .EnemyNotFainted + call HandleEnemyMonFaint ld a, [BattleEnded] and a - jr nz, .asm_3c27a + jr nz, .BattleIsOver -.asm_3c26a +.EnemyNotFainted call HasPlayerFainted - jr nz, .asm_3c278 - call Function3d14e + jr nz, .BattleContinues + call HandlePlayerMonFaint ld a, [BattleEnded] and a - jr nz, .asm_3c27a + jr nz, .BattleIsOver -.asm_3c278 +.BattleContinues and a ret -.asm_3c27a +.BattleIsOver scf ret ; 3c27c @@ -438,7 +438,7 @@ Function3c27c: ; 3c27c ; 3c300 Function3c300: ; 3c300 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, .asm_3c30d ld a, [wBattleAction] @@ -456,7 +456,7 @@ Function3c300: ; 3c300 ; 3c314 Function3c314: ; 3c314 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, .asm_3c35b ld a, [wBattleAction] @@ -584,10 +584,10 @@ Function3c3f5: ; 3c3f5 ld a, [wdc79] and a jr nz, .asm_3c40e - ld a, [wd0ee] + ld a, [wBattleResult] and $c0 add $2 - ld [wd0ee], a + ld [wBattleResult], a scf ret @@ -778,7 +778,7 @@ Function3c4df: ; 3c4df Function3c543: ; 3c543 - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr nz, .Stay @@ -952,14 +952,14 @@ Function3c5fe: ; 3c5fe and a ret nz call HasPlayerFainted - jp z, Function3d14e + jp z, HandlePlayerMonFaint call HasEnemyFainted - jp z, Function3cd55 + jp z, HandleEnemyMonFaint .asm_3c62f call SetEnemyTurn call ResidualDamage - jp z, Function3cd55 + jp z, HandleEnemyMonFaint call RefreshBattleHuds call Function3c6cf call Function3d2e0 @@ -968,12 +968,12 @@ Function3c5fe: ; 3c5fe and a ret nz call HasEnemyFainted - jp z, Function3cd55 + jp z, HandleEnemyMonFaint call HasPlayerFainted - jp z, Function3d14e + jp z, HandlePlayerMonFaint call SetPlayerTurn call ResidualDamage - jp z, Function3d14e + jp z, HandlePlayerMonFaint call RefreshBattleHuds xor a ld [wd0ec], a @@ -994,14 +994,14 @@ Function3c664: ; 3c664 call Function3d2e0 ret c call HasEnemyFainted - jp z, Function3cd55 + jp z, HandleEnemyMonFaint call HasPlayerFainted - jp z, Function3d14e + jp z, HandlePlayerMonFaint push bc call SetPlayerTurn call ResidualDamage pop bc - jp z, Function3d14e + jp z, HandlePlayerMonFaint push bc call RefreshBattleHuds pop af @@ -1016,14 +1016,14 @@ Function3c664: ; 3c664 and a ret nz call HasPlayerFainted - jp z, Function3d14e + jp z, HandlePlayerMonFaint call HasEnemyFainted - jp z, Function3cd55 + jp z, HandleEnemyMonFaint .asm_3c6be call SetEnemyTurn call ResidualDamage - jp z, Function3cd55 + jp z, HandleEnemyMonFaint call RefreshBattleHuds xor a ld [wd0ec], a @@ -1272,7 +1272,7 @@ Function3c801: ; 3c801 xor a ld [hli], a ld [hl], a - ld a, [IsInBattle] + ld a, [wBattleMode] dec a ret z ld hl, OTPartyMon1HP @@ -1429,7 +1429,7 @@ Function3c93c: ; 3c93c jr z, .asm_3c99b ld de, wc739 ld hl, wc735 - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr z, .asm_3c99b ld hl, OTPartyMon1PP @@ -1518,7 +1518,7 @@ Function3c93c: ; 3c93c ld a, [hBattleTurn] and a jr z, .asm_3ca12 - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr z, .asm_3ca14 call Function3df1f @@ -1637,7 +1637,7 @@ HanleDefrost: ; 3ca8f xor a ld [EnemyMonStatus], a - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr z, .asm_3caef ld a, [CurOTMon] @@ -2095,12 +2095,12 @@ Function3cd3c: ; 3cd3c ret ; 3cd55 -Function3cd55: ; 3cd55 - call Function3cf14 +HandleEnemyMonFaint: ; 3cd55 + call FaintEnemyPokemon ld hl, BattleMonHP ld a, [hli] or [hl] - call z, Function3cef1 + call z, FaintYourPokemon xor a ld [wc6f7], a call Function3ce01 @@ -2119,17 +2119,17 @@ Function3cd55: ; 3cd55 ld c, 60 call DelayFrames - ld a, [IsInBattle] + ld a, [wBattleMode] dec a - jr nz, .asm_3cd8c + jr nz, .trainer ld a, 1 ld [BattleEnded], a ret -.asm_3cd8c - call Function3cf35 - jp z, Function3cfa4 +.trainer + call CheckEnemyTrainerDefeated + jp z, WinTrainerBattle ld hl, BattleMonHP ld a, [hli] @@ -2196,7 +2196,7 @@ Function3cdca: ; 3cdca Function3ce01: ; 3ce01 call UpdateBattleMonInParty - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr z, .asm_3ce16 ld a, [CurOTMon] @@ -2215,13 +2215,13 @@ Function3ce01: ; 3ce01 ld [hl], a call NewEnemyMonStatus call BreakAttraction - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr z, .asm_3ce2f jr .asm_3ce37 .asm_3ce2f - call Function3ceec + call StopDangerSound ld a, $1 ld [wc6fd], a @@ -2240,14 +2240,14 @@ Function3ce01: ; 3ce01 ld a, d and a ret z - ld a, [IsInBattle] + ld a, [wBattleMode] dec a call z, Function3d0ea call EmptyBattleTextBox call Function309d - ld a, [wd0ee] + ld a, [wBattleResult] and $c0 - ld [wd0ee], a + ld [wBattleResult], a call Function3ceaa jr z, .asm_3ce72 ld hl, EnemyMonBaseStats @@ -2342,20 +2342,20 @@ Function3ceaa: ; 3ceaa -Function3ceec: ; 3ceec +StopDangerSound: ; 3ceec xor a ld [Danger], a ret ; 3cef1 -Function3cef1: ; 3cef1 - call Function3ceec +FaintYourPokemon: ; 3cef1 + call StopDangerSound call WaitSFX ld a, $f0 ld [CryTracks], a ld a, [BattleMonSpecies] call PlayStereoCry - call Function3d43b + call PlayerMonFaintedAnimation hlcoord 9, 7 lb bc, 5, 11 call ClearBox @@ -2363,11 +2363,11 @@ Function3cef1: ; 3cef1 jp StdBattleTextBox ; 3cf14 -Function3cf14: ; 3cf14 +FaintEnemyPokemon: ; 3cf14 call WaitSFX ld de, SFX_KINESIS call PlaySFX - call Function3d432 + call EnemyMonFaintedAnimation ld de, SFX_FAINT call PlaySFX hlcoord 1, 0 @@ -2377,20 +2377,22 @@ Function3cf14: ; 3cf14 jp StdBattleTextBox ; 3cf35 -Function3cf35: ; 3cf35 +CheckEnemyTrainerDefeated: ; 3cf35 ld a, [OTPartyCount] ld b, a xor a ld hl, OTPartyMon1HP ld de, PartyMon2 - PartyMon1 -.asm_3cf40 + +.loop or [hl] inc hl or [hl] dec hl add hl, de dec b - jr nz, .asm_3cf40 + jr nz, .loop + and a ret ; 3cf4a @@ -2401,7 +2403,7 @@ Function3cf4a: ; 3cf4a call Function3e12e call WaitBGMap callba Function2c012 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, .asm_3cf6d call Function3e8e4 @@ -2447,12 +2449,12 @@ EnemyPartyMonEntrance: ; 3cf78 ret ; 3cfa4 -Function3cfa4: ; 3cfa4 - call Function3ceec +WinTrainerBattle: ; 3cfa4 + call StopDangerSound ld a, $1 ld [wc6fd], a ld [BattleEnded], a - ld a, [InLinkBattle] + ld a, [wLinkMode] and a ld a, b call z, Function3d0ea @@ -2461,7 +2463,7 @@ Function3cfa4: ; 3cfa4 call StdBattleTextBox call IsMobileBattle jr z, .asm_3cff5 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a ret nz @@ -2631,7 +2633,7 @@ Function3d0be: ; 3d0be push bc ld b, h ld c, l - callba Function106008 + callba MobileFn_106008 pop bc pop hl .asm_3d0ce @@ -2664,7 +2666,7 @@ Function3d0ea: ; 3d0ea call PlayMusic call DelayFrame ld de, MUSIC_WILD_VICTORY - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr nz, .asm_3d113 push de @@ -2747,15 +2749,15 @@ KantoGymLeaders: db SABRINA db BLAINE db BLUE - db $ff + db -1 -Function3d14e: ; 3d14e - call Function3cef1 +HandlePlayerMonFaint: ; 3d14e + call FaintYourPokemon ld hl, EnemyMonHP ld a, [hli] or [hl] - call z, Function3cf14 + call z, FaintEnemyPokemon ld a, $1 ld [wc6f7], a call Function3d1aa @@ -2766,20 +2768,20 @@ Function3d14e: ; 3d14e ld hl, EnemyMonHP ld a, [hli] or [hl] - jr nz, .asm_3d185 + jr nz, .notfainted call Function3ce01 - ld a, [IsInBattle] + ld a, [wBattleMode] dec a - jr nz, .asm_3d17f + jr nz, .trainer ld a, $1 ld [BattleEnded], a ret -.asm_3d17f - call Function3cf35 - jp z, Function3cfa4 +.trainer + call CheckEnemyTrainerDefeated + jp z, WinTrainerBattle -.asm_3d185 +.notfainted call Function3d1f8 jr nc, .asm_3d190 ld a, $1 @@ -2829,10 +2831,10 @@ Function3d1aa: ; 3d1aa ld a, [CurBattleMon] ld [CurPartyMon], a callab ChangeHappiness - ld a, [wd0ee] + ld a, [wBattleResult] and %11000000 add $1 - ld [wd0ee], a + ld [wBattleResult], a ld a, [wc6f7] and a ret z @@ -2842,7 +2844,7 @@ Function3d1aa: ; 3d1aa Function3d1f8: ; 3d1f8 call EmptyBattleTextBox call Function309d - ld a, [IsInBattle] + ld a, [wBattleMode] and a dec a ret nz @@ -2870,7 +2872,7 @@ Function3d227: ; 3d227 call Function1d6e call Function3d2f7 call ForcePickPartyMonInBattle - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, .asm_3d241 ld a, $1 @@ -2949,8 +2951,8 @@ Function3d2b3: ; 3d2b3 Function3d2e0: ; 3d2e0 - ld a, [InLinkBattle] - cp $4 + ld a, [wLinkMode] + cp LINK_MOBILE jr nz, .asm_3d2ef ; It's not a mobile battle ld a, [wcd2b] @@ -2967,8 +2969,8 @@ Function3d2e0: ; 3d2e0 ; 3d2f1 IsMobileBattle: ; 3d2f1 - ld a, [InLinkBattle] - cp $4 + ld a, [wLinkMode] + cp LINK_MOBILE ret ; 3d2f7 @@ -3086,7 +3088,7 @@ LostBattle: ; 3d38e ; Remove the enemy from the screen. hlcoord 0, 0 - ld bc, $0815 + lb bc, 8, 21 call ClearBox call Function3ebd8 @@ -3103,7 +3105,7 @@ LostBattle: ; 3d38e .asm_3d3bd ; Remove the enemy from the screen. hlcoord 0, 0 - ld bc, $0815 + lb bc, 8, 21 call ClearBox call Function3ebd8 @@ -3119,7 +3121,7 @@ LostBattle: ; 3d38e ret .asm_3d3e3 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr nz, .LostLinkBattle @@ -3131,13 +3133,13 @@ LostBattle: ; 3d38e .LostLinkBattle call UpdateEnemyMonInParty - call Function3cf35 + call CheckEnemyTrainerDefeated jr nz, .asm_3d40a ld hl, TiedAgainstText - ld a, [wd0ee] + ld a, [wBattleResult] and $c0 add 2 - ld [wd0ee], a + ld [wBattleResult], a jr .text .asm_3d40a @@ -3155,7 +3157,7 @@ LostBattle: ; 3d38e .asm_3d417 ; Remove the enemy from the screen. hlcoord 0, 0 - ld bc, $0815 + lb bc, 8, 21 call ClearBox call Function3ebd8 @@ -3169,38 +3171,40 @@ LostBattle: ; 3d38e ; 3d432 -Function3d432: ; 3d432 +EnemyMonFaintedAnimation: ; 3d432 hlcoord 12, 5 decoord 12, 6 - jp Function3d444 + jp MonFaintedAnimation ; 3d43b -Function3d43b: ; 3d43b +PlayerMonFaintedAnimation: ; 3d43b hlcoord 1, 10 decoord 1, 11 - jp Function3d444 + jp MonFaintedAnimation ; 3d444 -Function3d444: ; 3d444 +MonFaintedAnimation: ; 3d444 ld a, [wcfbe] push af set 6, a ld [wcfbe], a - ld b, $7 -.asm_3d44f + ld b, 7 + +.OuterLoop push bc push de push hl - ld b, $6 -.asm_3d454 + ld b, 6 + +.InnerLoop push bc push hl push de - ld bc, $0007 + ld bc, 7 call CopyBytes pop de pop hl - ld bc, -20 + ld bc, -SCREEN_WIDTH add hl, bc push hl ld h, d @@ -3211,7 +3215,8 @@ Function3d444: ; 3d444 pop hl pop bc dec b - jr nz, .asm_3d454 + jr nz, .InnerLoop + ld bc, 20 add hl, bc ld de, .Spaces @@ -3222,7 +3227,8 @@ Function3d444: ; 3d444 pop de pop bc dec b - jr nz, .asm_3d44f + jr nz, .OuterLoop + pop af ld [wcfbe], a ret @@ -3337,7 +3343,7 @@ Function3d517: ; 3d517 ; 3d533 Function3d533: ; 3d533 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, .asm_3d541 @@ -3630,7 +3636,7 @@ Function3d714: ; 3d714 ld a, [PartyCount] dec a jp z, .asm_3d749 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jp nz, .asm_3d749 ld a, [Options] @@ -3862,11 +3868,11 @@ Function3d8b3: ; 3d8b3 cp BATTLETYPE_SUICUNE jp z, .asm_3d98d - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jp nz, .asm_3d9a2 - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jp nz, .asm_3d992 @@ -3979,7 +3985,7 @@ Function3d8b3: ; 3d8b3 ret .asm_3d9a2 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a ld a, $2 jr z, .asm_3d9cf @@ -4003,11 +4009,11 @@ Function3d8b3: ; 3d8b3 dec a .asm_3d9cf ld b, a - ld a, [wd0ee] + ld a, [wBattleResult] and $c0 add b - ld [wd0ee], a - call Function3ceec + ld [wBattleResult], a + call StopDangerSound push de ld de, SFX_RUN call WaitPlaySFX @@ -4021,7 +4027,7 @@ Function3d8b3: ; 3d8b3 ret .asm_3d9f5 - call Function3ceec + call StopDangerSound ld hl, wcd2a bit 4, [hl] jr nz, .asm_3da05 @@ -4107,7 +4113,7 @@ Function3da97: ; 3da97 bit SUBSTATUS_TRANSFORMED, a ret z ld hl, wc6f2 - ld a, [IsInBattle] + ld a, [wBattleMode] dec a ret z ld hl, OTPartyMon1DVs @@ -4387,7 +4393,7 @@ Function3dc5b: ; 3dc5b ld hl, wc664 ld b, $0 predef FlagPredef - call Function3d43b + call PlayerMonFaintedAnimation ld hl, BattleText_PkmnFainted jr .asm_3dcdf @@ -4403,7 +4409,7 @@ Function3dc5b: ; 3dc5b ld de, SFX_FAINT call PlaySFX call WaitSFX - call Function3d432 + call EnemyMonFaintedAnimation ld hl, BattleText_EnemyPkmnFainted .asm_3dcdf @@ -4658,7 +4664,7 @@ Function3de51: ; 3de51 call Function3df1f xor a ld [bc], a - ld a, [IsInBattle] + ld a, [wBattleMode] dec a ret z ld [hl], $0 @@ -5127,7 +5133,7 @@ BattleMenu: ; 3e139 ld a, [InputType] or a jr z, .asm_3e171 - callba Function1de294 + callba _DudeAutoInput_DownA .asm_3e171 call LoadBattleMenu2 @@ -5183,7 +5189,7 @@ LoadBattleMenu2: ; 3e19b ; 3e1c7 BattleMenu_Pack: ; 3e1c7 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jp nz, ItemsCantBeUsed @@ -5245,7 +5251,7 @@ Function3e234: ; 3e234 and a jr nz, .asm_3e279 callab CheckItemPocket - ld a, [wd142] + ld a, [wItemAttributeParamBuffer] cp $3 jr z, .asm_3e24a call WhiteBGMap @@ -5268,7 +5274,7 @@ Function3e234: ; 3e234 call Function3df2c call WaitBGMap call Function309d - call Function1fbf + call ResetTextRelatedRAM call Function3ee27 and a ret @@ -5276,10 +5282,10 @@ Function3e234: ; 3e234 .asm_3e279 xor a ld [wc64e], a - ld a, [wd0ee] + ld a, [wBattleResult] and $c0 - ld [wd0ee], a - call Function1fbf + ld [wBattleResult], a + call ResetTextRelatedRAM call Function32f9 scf ret @@ -5348,12 +5354,12 @@ Function3e2f5: ; 3e2f5 Function3e308: ; 3e308 call DisableLCD - ld hl, $9310 + ld hl, VTiles2 tile $31 ld de, VTiles0 ld bc, $0110 call CopyBytes ld hl, VTiles2 - ld de, $8110 + ld de, VTiles0 tile $11 ld bc, $0310 call CopyBytes call EnableLCD @@ -5365,10 +5371,10 @@ Function3e308: ; 3e308 call MaxVolume call DisableLCD ld hl, VTiles0 - ld de, $9310 + ld de, VTiles2 tile $31 ld bc, $0110 call CopyBytes - ld hl, $8110 + ld hl, VTiles0 tile $11 ld de, VTiles2 ld bc, $0310 call CopyBytes @@ -5422,7 +5428,7 @@ Function3e358: ; 3e358 Function3e3ad: ; 3e3ad ld a, 1 ld [wPlayerIsSwitching], a - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, .asm_3e3c1 call Function1d6e @@ -5431,7 +5437,7 @@ Function3e3ad: ; 3e3ad .asm_3e3c1 call Function3e7c1 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr nz, .asm_3e3cf @@ -5587,7 +5593,7 @@ Function3e4bc: ; 3e4bc call GetPartyParamLocation .asm_3e4e2 - ld de, wd25e + ld de, wListMoves_MoveIndicesBuffer ld bc, NUM_MOVES call CopyBytes xor a @@ -5650,7 +5656,7 @@ Function3e4bc: ; 3e4bc dec a ld b, $c3 jr z, .asm_3e569 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr nz, .asm_3e569 ld b, $c7 @@ -5960,8 +5966,8 @@ MoveInfoBox: ; 3e6c8 Function3e75f: ; 3e75f hlcoord 5, 11 - ld a, [InLinkBattle] - cp $4 + ld a, [wLinkMode] ; What's the point of this check? + cp LINK_MOBILE jr c, .ok hlcoord 5, 11 .ok @@ -6034,7 +6040,7 @@ Function3e7c1: ; 3e7c1 ld a, [wEnemyIsSwitching] and a ret nz - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, .asm_3e817 call EmptyBattleTextBox @@ -6108,7 +6114,7 @@ Function3e7c1: ; 3e7c1 jr .asm_3e8bd .asm_3e84f - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr nz, .asm_3e882 .asm_3e855 @@ -6222,7 +6228,7 @@ LoadEnemyMon: ; 3e8eb call ByteFill ; We don't need to be here if we're in a link battle - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jp nz, Function3dabd @@ -6244,7 +6250,7 @@ LoadEnemyMon: ; 3e8eb ; Let's get the item: ; Is the item predetermined? - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr z, .WildItem @@ -6293,7 +6299,7 @@ LoadEnemyMon: ; 3e8eb ; Initialize DVs ; If we're in a trainer battle, DVs are predetermined - ld a, [IsInBattle] + ld a, [wBattleMode] and a jr z, .InitDVs @@ -6320,7 +6326,7 @@ LoadEnemyMon: ; 3e8eb ; See GetTrainerDVs for more on that callba GetTrainerDVs ; These are the DVs we'll use if we're actually in a trainer battle - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr nz, .UpdateDVs @@ -6396,7 +6402,7 @@ LoadEnemyMon: ; 3e8eb ; We've still got more to do if we're dealing with a wild monster - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr nz, .Happiness @@ -6496,7 +6502,7 @@ LoadEnemyMon: ; 3e8eb ; If we're in a trainer battle, ; get the rest of the parameters from the party struct - ld a, [IsInBattle] + ld a, [wBattleMode] cp a, TRAINER_BATTLE jr z, .OpponentParty @@ -6586,7 +6592,7 @@ LoadEnemyMon: ; 3e8eb ; Get moves ld de, EnemyMonMoves ; Are we in a trainer battle? - ld a, [IsInBattle] + ld a, [wBattleMode] cp a, TRAINER_BATTLE jr nz, .WildMoves ; Then copy moves from the party struct @@ -6613,7 +6619,7 @@ endr .PP ; Trainer battle? - ld a, [IsInBattle] + ld a, [wBattleMode] cp a, TRAINER_BATTLE jr z, .TrainerPP @@ -6657,7 +6663,7 @@ endr call GetPokemonName ; Did we catch it? - ld a, [IsInBattle] + ld a, [wBattleMode] and a ret z @@ -6725,7 +6731,7 @@ CheckSleepingTreeMon: ; 3eb38 db EXEGGCUTE db LEDYBA db AIPOM - db $ff ; end + db -1 ; end .Day db VENONAT @@ -6733,7 +6739,7 @@ CheckSleepingTreeMon: ; 3eb38 db NOCTOWL db SPINARAK db HERACROSS - db $ff ; end + db -1 ; end .Morn db VENONAT @@ -6741,7 +6747,7 @@ CheckSleepingTreeMon: ; 3eb38 db NOCTOWL db SPINARAK db HERACROSS - db $ff ; end + db -1 ; end ; 3eb75 @@ -6837,7 +6843,8 @@ Function3ebd8: ; 3ebd8 callab GetTrainerPic hlcoord 19, 0 ld c, $0 -.asm_3ebf3 + +.outer_loop inc c ld a, c cp $7 @@ -6848,14 +6855,16 @@ Function3ebd8: ; 3ebd8 ld d, $0 push bc push hl -.asm_3ec01 + +.inner_loop call Function3ec1a inc hl ld a, $7 add d ld d, a dec c - jr nz, .asm_3ec01 + jr nz, .inner_loop + ld a, $1 ld [hBGMapMode], a ld c, $4 @@ -6863,7 +6872,7 @@ Function3ebd8: ; 3ebd8 pop hl pop bc dec hl - jr .asm_3ebf3 + jr .outer_loop ; 3ec1a Function3ec1a: ; 3ec1a @@ -6871,13 +6880,15 @@ Function3ec1a: ; 3ec1a push de push bc ld e, $7 -.asm_3ec1f + +.loop ld [hl], d - ld bc, $0014 + ld bc, SCREEN_WIDTH add hl, bc inc d dec e - jr nz, .asm_3ec1f + jr nz, .loop + pop bc pop de pop hl @@ -7116,7 +7127,7 @@ BadgeStatBoosts: ; 3ed45 ; The boosted stats are in order, except PlainBadge and MineralBadge's boosts are swapped. - ld a, [InLinkBattle] + ld a, [wLinkMode] and a ret nz @@ -7210,15 +7221,15 @@ Function3eda6: ; 3eda6 Function3edad: ; 3edad ld de, GFX_f8ac0 - ld hl, $96c0 + ld hl, VTiles2 tile $6c lb bc, BANK(GFX_f8ac0), 4 call Get1bpp ld de, GFX_f8ae0 - ld hl, $9730 + ld hl, VTiles2 tile $73 lb bc, BANK(GFX_f8ae0), 6 call Get1bpp ld de, GFX_f8b10 - ld hl, $9550 + ld hl, VTiles2 tile $55 lb bc, BANK(GFX_f8b10), 8 jp Get2bpp ; 3edd1 @@ -7237,7 +7248,7 @@ _BattleRandom:: ; 3edd8 ; To circumvent this a shared PRNG is used instead. ; But if we're in a non-link battle we're safe to use it - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jp z, Random @@ -7338,7 +7349,7 @@ Function3ee27: ; 3ee27 Function3ee3b: ; 3ee3b ; Give experience. - ld a, [InLinkBattle] + ld a, [wLinkMode] and a ret nz @@ -7452,7 +7463,7 @@ endr .asm_3eee2 ld [StringBuffer2 + 2], a - ld a, [IsInBattle] + ld a, [wBattleMode] dec a call nz, DoubleExp push bc @@ -7977,7 +7988,7 @@ Function3f22c: ; 3f22c SendOutPkmnText: ; 3f26d - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, .asm_3f27c @@ -8333,7 +8344,7 @@ Function3f447: ; 3f447 ld [CurPartySpecies], a ld hl, BattleMonDVs predef GetUnownLetter - ld de, $9310 + ld de, VTiles2 tile $31 predef GetBackpic pop af ld [CurPartySpecies], a @@ -8392,9 +8403,13 @@ Function3f4b4: ; 3f4b4 StartBattle: ; 3f4c1 +; This check prevents you from entering a battle without any Pokemon. +; Those using walk-through-walls to bypass getting a Pokemon experience +; the effects of this check. ld a, [PartyCount] and a ret z + ld a, [TimeOfDayPal] push af call Function3f4dd @@ -8414,17 +8429,17 @@ Function3f4d9: ; 3f4d9 Function3f4dd: ; 3f4dd - callba Function106050 - call Function3f54e + callba MobileFn_106050 ; mobile + call LoadTrainerOrWildMonPic xor a ld [TempBattleMonSpecies], a ld [wd0d2], a xor a ld [$ffde], a callba PlayBattleMusic - callba Function2ee18 - callba Function2ee2f - call Function2ed3 + callba ShowLinkBattleParticipants + callba FindFirstAliveMon + call DisableSpriteUpdates callba ClearBattleRAM call Function3f55e call Function3f568 @@ -8446,7 +8461,7 @@ Function3f4dd: ; 3f4dd ld bc, 4 << 8 + 10 call ClearBox call ClearSprites - ld a, [IsInBattle] + ld a, [wBattleMode] cp $1 call z, UpdateEnemyHUD ld a, $1 @@ -8454,14 +8469,14 @@ Function3f4dd: ; 3f4dd ret ; 3f54e -Function3f54e: ; 3f54e +LoadTrainerOrWildMonPic: ; 3f54e ld a, [OtherTrainerClass] and a - jr nz, .asm_3f55a + jr nz, .Trainer ld a, [TempWildMonSpecies] ld [CurPartySpecies], a -.asm_3f55a +.Trainer ld [TempEnemyMonSpecies], a ret ; 3f55e @@ -8469,8 +8484,8 @@ Function3f54e: ; 3f54e Function3f55e: ; 3f55e ld a, [OtherTrainerClass] and a - jp nz, Function3f594 - jp Function3f607 + jp nz, Function3f594 ; trainer + jp Function3f607 ; wild ; 3f568 Function3f568: ; 3f568 @@ -8499,7 +8514,7 @@ Function3f568: ; 3f568 Function3f594: ; 3f594 ld [TrainerClass], a - callba Function10606a + callba MobileFn_10606a xor a ld [TempEnemyMonSpecies], a callab Function3957b @@ -8521,10 +8536,10 @@ Function3f594: ; 3f594 hlcoord 12, 0 lb bc, 7, 7 predef FillBox - ld a, $ff + ld a, -1 ld [CurOTMon], a ld a, TRAINER_BATTLE - ld [IsInBattle], a + ld [wBattleMode], a call IsJohtoGymLeader jr nc, .done @@ -8554,8 +8569,8 @@ Function3f594: ; 3f594 Function3f607: ; 3f607 ld a, $1 - ld [IsInBattle], a - callba Function10605d + ld [wBattleMode], a + callba MobileFn_10605d call LoadEnemyMon ld hl, EnemyMonMoves ld de, wc735 @@ -8589,7 +8604,7 @@ Function3f607: ; 3f607 Function3f662: ; 3f662 ld hl, EnemyMonMoves - ld de, wd25e + ld de, wListMoves_MoveIndicesBuffer ld b, NUM_MOVES .loop ld a, [de] @@ -8647,17 +8662,17 @@ Function3f69e: ; 3f69e ; 3f6a5 Function3f6a5: ; 3f6a5 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a - jr z, .asm_3f6b7 + jr z, .not_linked call Function3f759 ld c, 150 call DelayFrames call Function3f77c ret -.asm_3f6b7 - ld a, [wd0ee] +.not_linked + ld a, [wBattleResult] and $f ret nz call Function3f71d @@ -8672,7 +8687,7 @@ Function3f6d0: ; 3f6d0 call Function3f998 xor a ld [Danger], a - ld [IsInBattle], a + ld [wBattleMode], a ld [BattleType], a ld [AttackMissed], a ld [TempWildMonSpecies], a @@ -8681,11 +8696,11 @@ Function3f6d0: ; 3f6d0 ld [wd267], a ld [wd232], a ld [wd0d8], a - ld [wd0da], a - ld [wd0d9], a + ld [wKeyItemsPocketPointerLocation], a + ld [wItemsPocketPointerLocation], a ld [wd0d2], a ld [CurMoveNum], a - ld [wd0db], a + ld [wBallsPocketPointerLocation], a ld [wd0d6], a ld [wd0e4], a ld [wd0e0], a @@ -8739,7 +8754,7 @@ endr ; 3f759 Function3f759: ; 3f759 - callba Function1060df + callba MobileFn_1060df callba Function106187 ld a, [CurOTMon] ld hl, OTPartyMon1Status @@ -8747,7 +8762,7 @@ Function3f759: ; 3f759 ld a, [EnemyMonStatus] ld [hl], a call ClearTileMap - callba Function2c1b2 + callba _ShowLinkBattleParticipants ret ; 3f77c @@ -8762,22 +8777,22 @@ Function3f77c: ; 3f77c callba Function2b930 .asm_3f797 - ld a, [wd0ee] + ld a, [wBattleResult] and $f cp $1 jr c, .asm_3f7ad jr z, .asm_3f7b8 - callba Function106107 + callba MobileFn_106107 ld de, .Draw jr .asm_3f7c3 .asm_3f7ad - callba Function1060fb + callba MobileFn_1060fb ld de, .Win jr .asm_3f7c3 .asm_3f7b8 - callba Function106101 + callba MobileFn_106101 ld de, .Lose jr .asm_3f7c3 @@ -8830,8 +8845,8 @@ Function3f80f: ; 3f80f Function3f830: ; 3f830 - ld a, [InLinkBattle] - cp $4 + ld a, [wLinkMode] + cp LINK_MOBILE ret ; 3f836 @@ -8870,7 +8885,7 @@ Function3f85f: ; 3f85f ld a, [de] and a jr z, .asm_3f8c9 - ld a, [wd4b4] + ld a, [wSavedAtLeastOnce] and a jr z, .asm_3f8c9 push hl @@ -8967,7 +8982,7 @@ Function3f85f: ; 3f85f ret .asm_3f92b - ld a, [wd4b4] + ld a, [wSavedAtLeastOnce] and a ret nz ld de, .Scores @@ -8981,9 +8996,9 @@ Function3f85f: ; 3f85f ; 3f947 .Format ; 3f947 - db " --- ", $22, " - - -@" + db " --- <LNBRK> - - -@" .Record ; 3f964 - db $52, "'s RECORD@" + db "<PLAYER>'s RECORD@" .Result ; 3f96e db "RESULT WIN LOSE DRAW@" .Total ; 3f983 @@ -8995,7 +9010,7 @@ Function3f998: ; 3f998 ld a, [BattleType] cp BATTLETYPE_ROAMING jr nz, .asm_3f9c4 - ld a, [wd0ee] + ld a, [wBattleResult] and $f jr z, .asm_3f9af call GetRoamMonHP @@ -9159,7 +9174,7 @@ endr ; 3faa0 Function3faa0: ; 3faa0 - ld a, [wd0ee] + ld a, [wBattleResult] and $f cp $1 ld bc, $000d @@ -9394,7 +9409,7 @@ GetBattleBackpic: ; 3fbff jr z, .Decompress ; What gender are we? - ld a, [wd45b] + ld a, [wPlayerSpriteSetupFlags] bit 2, a jr nz, .Chris ld a, [PlayerGender] @@ -9411,7 +9426,7 @@ GetBattleBackpic: ; 3fbff ld hl, ChrisBackpic .Decompress - ld de, $9310 + ld de, VTiles2 tile $31 ld c, $31 predef DecompressPredef ret @@ -9424,7 +9439,7 @@ Function3fc30: ; 3fc30 ld a, $6 ld [rSVBK], a ld hl, VTiles0 - ld de, $9310 + ld de, VTiles2 tile $31 ld a, [hROMBank] ld b, a ld c, $31 @@ -9478,7 +9493,7 @@ Function3fc5b: ; 3fc5b BattleStartMessage: ; 3fc8b - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr z, .asm_3fcaa @@ -9531,7 +9546,7 @@ BattleStartMessage: ; 3fc8b cp BATTLETYPE_FISH jr nz, .asm_3fcfd - callba Function106086 + callba MobileFn_106086 ld hl, HookedPokemonAttackedText jr .asm_3fd0e diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index 63e27359d..95ce78a80 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -12,7 +12,7 @@ DoPlayerTurn: ; 34000 DoEnemyTurn: ; 3400a call SetEnemyTurn - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, DoTurn @@ -696,7 +696,7 @@ BattleCommand02: ; 343db ; No obedience in link battles ; (since no handling exists for enemy) - ld a, [InLinkBattle] + ld a, [wLinkMode] and a ret nz @@ -1080,7 +1080,7 @@ endr jr z, .asm_345a4 ; skip this part entirely if wildbattle - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr z, .asm_345c5 @@ -3521,7 +3521,7 @@ Function3534d: ; 3534d inc l .asm_3536b - ld a, [InLinkBattle] + ld a, [wLinkMode] cp 3 jr z, .done @@ -3835,11 +3835,11 @@ BattleCommanda1: ; 35461 sub b ld [DefaultFlypoint], a .asm_3550d - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr z, .asm_3556b - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr nz, .asm_35532 @@ -4825,7 +4825,7 @@ BattleCommand46: ; 35a74 call Function372d8 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, .asm_35a83 call AnimateFailedMove @@ -4888,7 +4888,7 @@ BattleCommand46: ; 35a74 ld a, [hBattleTurn] and a jr z, .asm_35af6 - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr nz, .asm_35af6 ld a, [hl] @@ -5180,7 +5180,7 @@ endr ld a, [hBattleTurn] and a jr nz, .asm_35c81 - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr nz, .asm_35c81 ld hl, wc739 @@ -5585,7 +5585,7 @@ Function35ece: ; 35ece jr z, .asm_35eec ; Not in link battle - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr nz, .asm_35eec @@ -5683,7 +5683,7 @@ BattleCommand2f: ; 35f2c and a jr z, .asm_35f89 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr nz, .asm_35f89 @@ -6331,7 +6331,7 @@ BattleCommand1d: ; 362e3 and a jr z, .DidntMiss - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr nz, .DidntMiss @@ -7124,7 +7124,7 @@ BattleCommanda0: ; 36778 ld a, [hBattleTurn] and a jr nz, .asm_367bf - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr nz, .failed ld a, [CurPartyLevel] @@ -7149,7 +7149,7 @@ BattleCommanda0: ; 36778 jp PrintButItFailed .asm_367bf - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr nz, .failed ld a, [BattleMonLevel] @@ -7188,10 +7188,10 @@ BattleCommanda0: ; 36778 Function36804: ; 36804 - ld a, [wd0ee] + ld a, [wBattleResult] and $c0 or $2 - ld [wd0ee], a + ld [wBattleResult], a ret ; 3680f @@ -7214,7 +7214,7 @@ BattleCommand23: ; 3680f ld a, [AttackMissed] and a jr nz, .asm_36852 ; 36830 $20 - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr nz, .asm_36869 ; 36836 $31 ld a, [CurPartyLevel] @@ -7300,7 +7300,7 @@ BattleCommand23: ; 3680f and a jr nz, .asm_368f3 - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr nz, .asm_36908 @@ -7496,7 +7496,7 @@ BattleCommand24: ; 369b6 dec a jr .asm_36a3a .asm_36a0b - ld a, [IsInBattle] + ld a, [wBattleMode] cp $1 jp z, .asm_36a1e ld a, [OTPartyCount] @@ -8177,7 +8177,7 @@ BattleCommand30: ; 36dc7 and a jr z, .asm_36e0e - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr nz, .asm_36e0e @@ -8519,7 +8519,7 @@ BattleCommand35: ; 36f9d BattleCommand36: ; 36fe1 call AnimateCurrentMove - callba Function1060e5 + callba MobileFn_1060e5 jp PrintNothingHappened ; 36fed @@ -9152,7 +9152,7 @@ CheckSubstituteOpp: ; 37378 BattleCommand1a: ; 37380 - callba Function10610d + callba MobileFn_10610d ld a, $4 ld [wcfca], a ld c, $3 @@ -9281,7 +9281,7 @@ BattleCommand53: ; 37563 and a jr z, .party - ld a, [IsInBattle] + ld a, [wBattleMode] dec a jr z, .done @@ -9493,7 +9493,7 @@ BattleCommand60: ; 3784b BattleCommand61: ; 37874 ; present - ld a, [InLinkBattle] + ld a, [wLinkMode] cp $3 jr z, .asm_3787d push bc @@ -9502,7 +9502,7 @@ BattleCommand61: ; 37874 call BattleCommand07 - ld a, [InLinkBattle] + ld a, [wLinkMode] cp $3 jr z, .asm_37889 pop de @@ -9765,7 +9765,7 @@ BattleCommand67: ; 379c9 .Enemy ; Wildmons don't have anything to switch to - ld a, [IsInBattle] + ld a, [wBattleMode] dec a ; WILDMON jp z, FailedBatonPass @@ -9800,7 +9800,7 @@ BattleCommand67: ; 379c9 BatonPass_LinkPlayerSwitch: ; 37a67 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a ret z @@ -9819,7 +9819,7 @@ BatonPass_LinkPlayerSwitch: ; 37a67 BatonPass_LinkEnemySwitch: ; 37a82 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a ret z @@ -10057,7 +10057,7 @@ BattleCommand6a6c: ; 37b7e jr z, .Full ; Don't factor in time of day in link battles. - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr nz, .Weather diff --git a/battle/effects/thief.asm b/battle/effects/thief.asm index dbbe0396b..730fcd66c 100644 --- a/battle/effects/thief.asm +++ b/battle/effects/thief.asm @@ -30,11 +30,11 @@ BattleCommand50: ; 37492 and a ret nz - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr z, .stealenemyitem - ld a, [IsInBattle] + ld a, [wBattleMode] dec a ret z diff --git a/battle/magikarp_length.asm b/battle/magikarp_length.asm new file mode 100644 index 000000000..237450928 --- /dev/null +++ b/battle/magikarp_length.asm @@ -0,0 +1,215 @@ +CalcMagikarpLength: ; fbbfc +; Return Magikarp's length (in mm) at MagikarpLength (big endian). +; +; input: +; de: EnemyMonDVs +; bc: PlayerID + +; This function is poorly commented. + +; In short, it generates a value between 190 and 1786 using +; a Magikarp's DVs and its trainer ID. This value is further +; filtered in LoadEnemyMon to make longer Magikarp even rarer. + +; The value is generated from a lookup table. +; The index is determined by the dv xored with the player's trainer id. + +; bc = rrc(dv[0]) ++ rrc(dv[1]) ^ rrc(id) + +; if bc < 10: [MagikarpLength] = c + 190 +; if bc >= $ff00: [MagikarpLength] = c + 1370 +; else: [MagikarpLength] = z * 100 + (bc - x) / y + +; X, Y, and Z depend on the value of b as follows: + +; if b = 0: x = 310, y = 2, z = 3 +; if b = 1: x = 710, y = 4, z = 4 +; if b = 2-9: x = 2710, y = 20, z = 5 +; if b = 10-29: x = 7710, y = 50, z = 6 +; if b = 30-68: x = 17710, y = 100, z = 7 +; if b = 69-126: x = 32710, y = 150, z = 8 +; if b = 127-185: x = 47710, y = 150, z = 9 +; if b = 186-224: x = 57710, y = 100, z = 10 +; if b = 225-243: x = 62710, y = 50, z = 11 +; if b = 244-251: x = 64710, y = 20, z = 12 +; if b = 252-253: x = 65210, y = 5, z = 13 +; if b = 254: x = 65410, y = 2, z = 14 + + + ; bc = rrc(dv[0]) ++ rrc(dv[1]) ^ rrc(id) + + ; id + ld h, b + ld l, c + ld a, [hli] + ld b, a + ld c, [hl] + rrc b + rrc c + + ; dv + ld a, [de] + inc de + rrca + rrca + xor b + ld b, a + + ld a, [de] + rrca + rrca + xor c + ld c, a + + ; if bc < 10: + ; de = bc + 190 + ; break + + ld a, b + and a + jr nz, .no + ld a, c + cp 10 + jr nc, .no + + ld hl, 190 + add hl, bc + ld d, h + ld e, l + jr .done + +.no + + ld hl, .Lengths + ld a, 2 + ld [wd265], a + +.read + ld a, [hli] + ld e, a + ld a, [hli] + ld d, a + call .BCLessThanDE + jr nc, .next + + ; c = (bc - de) / [hl] + call .BCMinusDE + ld a, b + ld [hDividend + 0], a + ld a, c + ld [hDividend + 1], a + ld a, [hl] + ld [hDivisor], a + ld b, 2 + call Divide + ld a, [hQuotient + 2] + ld c, a + + ; de = c + 100 * (2 + i) + xor a + ld [hMultiplicand + 0], a + ld [hMultiplicand + 1], a + ld a, 100 + ld [hMultiplicand + 2], a + ld a, [wd265] + ld [hMultiplier], a + call Multiply + ld b, 0 + ld a, [hProduct + 3] + add c + ld e, a + ld a, [hProduct + 2] + adc b + ld d, a + jr .done + +.next + inc hl ; align to next triplet + ld a, [wd265] + inc a + ld [wd265], a + cp 16 + jr c, .read + + call .BCMinusDE + ld hl, 1600 + add hl, bc + ld d, h + ld e, l + +.done + ; hl = de * 10 + ld h, d + ld l, e +rept 2 + add hl, hl +endr + add hl, de + add hl, hl + + ; hl = hl / 254 + ld de, -254 + ld a, -1 +.div_254 + inc a + add hl, de + jr c, .div_254 + + ; d, e = hl / 12, hl % 12 + ld d, 0 +.mod_12 + cp 12 + jr c, .ok + sub 12 + inc d + jr .mod_12 +.ok + ld e, a + + ld hl, MagikarpLength + ld [hl], d + inc hl + ld [hl], e + ret +; fbc9a + +.BCLessThanDE: ; fbc9a +; Intention: Return bc < de. +; Reality: Return b < d. + ld a, b + cp d + ret c + ret nc ; whoops + ld a, c + cp e + ret +; fbca1 + +.BCMinusDE: ; fbca1 +; bc -= de + ld a, c + sub e + ld c, a + ld a, b + sbc d + ld b, a + ret +; fbca8 + +.Lengths: ; fbca8 +; ????, divisor + dwb 110, 1 + dwb 310, 2 + dwb 710, 4 + dwb 2710, 20 + dwb 7710, 50 + dwb 17710, 100 + dwb 32710, 150 + dwb 47710, 150 + dwb 57710, 100 + dwb 62710, 50 + dwb 64710, 20 + dwb 65210, 5 + dwb 65410, 2 + dwb 65510, 1 ; not used +; fbcd2 diff --git a/battle/misc.asm b/battle/misc.asm index a8dccca84..6d38b8e2f 100644 --- a/battle/misc.asm +++ b/battle/misc.asm @@ -161,7 +161,7 @@ endr DoBadgeTypeBoosts: ; fbe24 - ld a, [InLinkBattle] + ld a, [wLinkMode] and a ret nz |