diff --git a/battle/ai/items.asm b/battle/ai/items.asm index 8898fdff5..46f04bf65 100644 --- a/battle/ai/items.asm +++ b/battle/ai/items.asm @@ -21,7 +21,7 @@ AI_SwitchOrTryItem: ; 38000 jr nz, DontSwitch ld hl, TrainerClassAttributes + 5 - ld a, [wcfc0] + ld a, [InBattleTowerBattle] ; Load always the first TrainerClass for BattleTower-Trainers and a jr nz, .ok ld a, [TrainerClass] @@ -157,7 +157,8 @@ CheckSubstatusCantRun: ; 380ff AI_TryItem: ; 38105 - ld a, [wcfc0] + ; items are not allowed in the BattleTower + ld a, [InBattleTowerBattle] and a ret nz diff --git a/battle/core.asm b/battle/core.asm index 3696b2bb5..7e85e996d 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -2462,7 +2462,7 @@ Function3cfa4: ; 3cfa4 ld a, [InLinkBattle] and a ret nz - ld a, [wcfc0] + ld a, [InBattleTowerBattle] bit 0, a jr nz, .asm_3d006 call Function3ebd8 @@ -3068,7 +3068,7 @@ LostBattle: ; 3d38e ld a, 1 ld [BattleEnded], a - ld a, [wcfc0] + ld a, [InBattleTowerBattle] bit 0, a jr nz, .asm_3d3bd @@ -5175,7 +5175,7 @@ BattleMenu_Pack: ; 3e1c7 and a jp nz, ItemsCantBeUsed - ld a, [wcfc0] + ld a, [InBattleTowerBattle] and a jp nz, ItemsCantBeUsed @@ -6214,7 +6214,8 @@ LoadEnemyMon: ; 3e8eb and a jp nz, Function3dabd - ld a, [wcfc0] ; ???? +; and also not in a BattleTower-Battle + ld a, [InBattleTowerBattle] ; ???? bit 0, a jp nz, Function3dabd @@ -7107,7 +7108,7 @@ BadgeStatBoosts: ; 3ed45 and a ret nz - ld a, [wcfc0] + ld a, [InBattleTowerBattle] and a ret nz @@ -7329,7 +7330,7 @@ Function3ee3b: ; 3ee3b and a ret nz - ld a, [wcfc0] + ld a, [InBattleTowerBattle] bit 0, a ret nz @@ -8716,7 +8717,7 @@ endr call Function3d0be ld hl, BattleText_0x80730 call StdBattleTextBox - ld a, [wcfc0] + ld a, [InBattleTowerBattle] bit 0, a ret z call ClearTileMap diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index 4d53eec08..15598120b 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -700,7 +700,7 @@ BattleCommand02: ; 343db and a ret nz - ld a, [wcfc0] + ld a, [InBattleTowerBattle] and a ret nz @@ -3841,7 +3841,7 @@ BattleCommanda1: ; 35461 and a jr nz, .asm_35532 - ld a, [wcfc0] + ld a, [InBattleTowerBattle] and a jr nz, .asm_35532 @@ -5544,7 +5544,7 @@ BattleCommand14: ; 35e5c call AnimateCurrentMove ld b, $7 - ld a, [wcfc0] + ld a, [InBattleTowerBattle] and a jr z, .asm_35ea4 ld b, $3 @@ -5587,7 +5587,7 @@ Function35ece: ; 35ece and a jr nz, .asm_35eec - ld a, [wcfc0] + ld a, [InBattleTowerBattle] and a jr nz, .asm_35eec @@ -5676,18 +5676,23 @@ BattleCommand2f: ; 35f2c call GetBattleVar and a jr nz, .asm_35fb8 + ld a, [hBattleTurn] and a jr z, .asm_35f89 + ld a, [InLinkBattle] and a jr nz, .asm_35f89 - ld a, [wcfc0] + + ld a, [InBattleTowerBattle] and a jr nz, .asm_35f89 + ld a, [PlayerSubStatus5] bit SUBSTATUS_LOCK_ON, a jr nz, .asm_35f89 + call BattleRandom cp $40 jr c, .asm_35fb8 @@ -6323,11 +6328,12 @@ BattleCommand1d: ; 362e3 ld a, [hBattleTurn] and a jr z, .DidntMiss + ld a, [InLinkBattle] and a jr nz, .DidntMiss - ld a, [wcfc0] + ld a, [InBattleTowerBattle] and a jr nz, .DidntMiss @@ -8168,18 +8174,23 @@ BattleCommand30: ; 36dc7 ld a, [hBattleTurn] and a jr z, .asm_36e0e + ld a, [InLinkBattle] and a jr nz, .asm_36e0e - ld a, [wcfc0] + + ld a, [InBattleTowerBattle] and a jr nz, .asm_36e0e + ld a, [PlayerSubStatus5] bit SUBSTATUS_LOCK_ON, a jr nz, .asm_36e0e + call BattleRandom cp $40 jr c, .asm_36e52 + .asm_36e0e ld a, BATTLE_VARS_STATUS_OPP call GetBattleVarAddr diff --git a/main.asm b/main.asm index 76d8881e0..7268c985e 100644 --- a/main.asm +++ b/main.asm @@ -35575,7 +35575,7 @@ INCLUDE "trainers/attributes.asm" ReadTrainerParty: ; 39771 - ld a, [wcfc0] + ld a, [InBattleTowerBattle] bit 0, a ret nz @@ -35906,7 +35906,7 @@ endr Battle_GetTrainerName:: ; 39939 - ld a, [wcfc0] + ld a, [InBattleTowerBattle] bit 0, a ld hl, wd26b jp nz, CopyTrainerName @@ -36818,7 +36818,9 @@ endr .ApplyLayers ld hl, TrainerClassAttributes + 3 - ld a, [wcfc0] + ; If we have a battle in BattleTower just load the Attributes of the first TrainerClass (Falkner) + ; so we have always the same AI, regardless of the loaded cass of trainer + ld a, [InBattleTowerBattle] bit 0, a jr nz, .asm_4412f @@ -87453,7 +87455,7 @@ DoBadgeTypeBoosts: ; fbe24 and a ret nz - ld a, [wcfc0] + ld a, [InBattleTowerBattle] and a ret nz diff --git a/misc/mobile_45.asm b/misc/mobile_45.asm index 8f98d1faf..7ae4f8327 100644 --- a/misc/mobile_45.asm +++ b/misc/mobile_45.asm @@ -16530,7 +16530,7 @@ ENDC sub $19 .asm_11c021 - ld hl, Unknown_11f332 + ld hl, BTTrainerTexts jr .asm_11c033 .asm_11c026 @@ -20672,14 +20672,14 @@ Unknown_11f2f0: db $01, $01, $00, $00, $00, $01 -Unknown_11f332: - dw Unknown_11f338 - dw Unknown_11f36a - dw Unknown_11f39c +BTTrainerTexts: ; 11f332 + dw BTTrainerGreetings + dw BTTrainerPlayerLostTexts + dw BTTrainerPlayerWonTexts -Unknown_11f338: ; 11f338 - dw UnknownText_0x11f42e - dw UnknownText_0x11f43d +BTTrainerGreetings: ; 11f338 + dw BattleTowerTextJump_0x11f42e + dw BattleTowerTextJump_0x11f43d dw UnknownText_0x11f44c dw UnknownText_0x11f45b dw UnknownText_0x11f46a @@ -20704,8 +20704,8 @@ Unknown_11f338: ; 11f338 dw UnknownText_0x11f587 dw UnknownText_0x11f596 -Unknown_11f36a: ; 11f36a - dw UnknownText_0x11f433 +BTTrainerPlayerLostTexts: ; 11f36a + dw BattleTowerTextJump_0x11f433 dw UnknownText_0x11f442 dw UnknownText_0x11f451 dw UnknownText_0x11f460 @@ -20731,7 +20731,7 @@ Unknown_11f36a: ; 11f36a dw UnknownText_0x11f58c dw UnknownText_0x11f59b -Unknown_11f39c: ; 11f39c +BTTrainerPlayerWonTexts: ; 11f39c dw UnknownText_0x11f438 dw UnknownText_0x11f447 dw UnknownText_0x11f456 @@ -20816,20 +20816,20 @@ Unknown_11f410: ; 11f410 dw UnknownText_0x11f681 -UnknownText_0x11f42e: ; 0x11f42e - text_jump UnknownText_0x1ec000 +BattleTowerTextJump_0x11f42e: ; 0x11f42e + text_jump BattleTowerText_0x1ec000 db "@" -UnknownText_0x11f433: ; 0x11f433 - text_jump UnknownText_0x1ec03b +BattleTowerTextJump_0x11f433: ; 0x11f433 + text_jump BattleTowerText_0x1ec03b db "@" UnknownText_0x11f438: ; 0x11f438 text_jump UnknownText_0x1ec060 db "@" -UnknownText_0x11f43d: ; 0x11f43d - text_jump UnknownText_0x1ec080 +BattleTowerTextJump_0x11f43d: ; 0x11f43d + text_jump BattleTowerText_0x1ec080 db "@" UnknownText_0x11f442: ; 0x11f442 @@ -22804,7 +22804,7 @@ Function17021e: ; 17021e Function17022c: ; 17022c .asm_17022c - call Function17023a + call Jumpto_BattleTowerBattleFunction call DelayFrame ld a, [wcf63] cp $1 @@ -22812,11 +22812,11 @@ Function17022c: ; 17022c ret ; 17023a -Function17023a: ; 17023a +Jumpto_BattleTowerBattleFunction: ; 17023a ld a, [wcf63] ld e, a ld d, 0 - ld hl, Jumptable_170249 + ld hl, Jumptable_BattleTowerBattleFunctions rept 2 add hl, de endr @@ -22826,20 +22826,20 @@ endr jp [hl] ; 170249 -Jumptable_170249: ; 170249 - dw Function17024d - dw Function1704c9 +Jumptable_BattleTowerBattleFunctions: ; 170249 + dw RunBattleTowerBattle + dw SkipBattleTowerBattle ; 17024d -Function17024d: ; 17024d +RunBattleTowerBattle: ; 17024d ld a, [Options] push af ld hl, Options set 6, [hl] - ld a, [wcfc0] + ld a, [InBattleTowerBattle] push af or $1 - ld [wcfc0], a + ld [InBattleTowerBattle], a xor a ld [InLinkBattle], a callba Mobile_HealParty @@ -22867,7 +22867,7 @@ Function17024d: ; 17024d .asm_1702a9 pop af - ld [wcfc0], a + ld [InBattleTowerBattle], a pop af ld [Options], a ld a, $1 @@ -22875,8 +22875,8 @@ Function17024d: ; 17024d ret -; Initialise the BattleTower-Trainer and his Pkmn Function1702b7: ; 1702b7 +; Initialise the BattleTower-Trainer and his Pkmn call CopyBTTrainer_FromBT_OTrainer_TowBT_OTTempCopy ld de, wBT_OTTempCopy + wBT_OTTempCopy_Pkmn1Name ; $c643 ld c, PKMN_NAME_LENGTH @@ -23190,7 +23190,7 @@ CopyBTTrainer_FromBT_OTrainer_TowBT_OTTempCopy: ; 1704a2 ld hl, sNrOfBeatenBattleTowerTrainers inc [hl] call CloseSRAM -Function1704c9: +SkipBattleTowerBattle: ; 1704c9 ret ; 1704ca diff --git a/text/battle_tower.asm b/text/battle_tower.asm index 9ef4f0299..af90b2666 100644 --- a/text/battle_tower.asm +++ b/text/battle_tower.asm @@ -1,5 +1,5 @@ -UnknownText_0x1ec000: ; 0x1ec000 +BattleTowerText_0x1ec000: ; 0x1ec000 text "Hello, glad to" line "meet you!" @@ -8,7 +8,7 @@ UnknownText_0x1ec000: ; 0x1ec000 done ; 0x1ec03b -UnknownText_0x1ec03b: ; 0x1ec03b +BattleTowerText_0x1ec03b: ; 0x1ec03b text "Thank you! A most" line "enjoyable battle!" done @@ -20,7 +20,7 @@ UnknownText_0x1ec060: ; 0x1ec060 done ; 0x1ec080 -UnknownText_0x1ec080: ; 0x1ec080 +BattleTowerText_0x1ec080: ; 0x1ec080 text "Work, work, work…" line "I'm always busy!" done diff --git a/wram.asm b/wram.asm index 6c9ede290..5c8ca7e09 100644 --- a/wram.asm +++ b/wram.asm @@ -1279,7 +1279,13 @@ GameTimerPause:: ; cfbc ds 1 wcfbe:: ds 2 -wcfc0:: ds 2 + +InBattleTowerBattle:: ; cfc0 +; 0 not in BattleTower-Battle +; 1 BattleTower-Battle + ds 1 + + ds 1 FXAnimID:: FXAnimIDLo:: ; cfc2 @@ -2618,6 +2624,7 @@ w2_d188:: ds 1 SECTION "WRAM 3", WRAMX, BANK [3] +w3_d000:: ; d000 ds $100 BT_OTrainer:: @@ -2640,9 +2647,11 @@ BT_OTPkmn3Item:: ds $3b-1 ds $24 -BT_OTrainerEnd:: +BT_OTrainerEnd:: ; we_d1e0 - ds $620 + ds $20 + + ds $600 wBTChoiceOfLvlGroup:: w3_d800:: ds 1