diff options
-rw-r--r-- | constants/misc_constants.asm | 1 | ||||
-rw-r--r-- | data/battle_tower.asm | 18 | ||||
-rw-r--r-- | maps/BattleTowerBattleRoom.asm | 4 | ||||
-rw-r--r-- | maps/BattleTowerHallway.asm | 2 | ||||
-rw-r--r-- | misc/mobile_45.asm | 67 | ||||
-rw-r--r-- | wram.asm | 16 |
6 files changed, 65 insertions, 43 deletions
diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 597e46efa..425801e8e 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -108,6 +108,7 @@ const_value = 1 const MOM_ITEM const MOM_DOLL +BATTLETOWER_PKMNSTRUCTLENGTH EQU $30 BATTLETOWER_NROFPKMNS EQU 3 BATTLETOWER_TRAINERDATALENGTH EQU $24 BATTLETOWER_NROFTRAINERS EQU 7 diff --git a/data/battle_tower.asm b/data/battle_tower.asm index dc96b3822..281c359d7 100644 --- a/data/battle_tower.asm +++ b/data/battle_tower.asm @@ -36,7 +36,7 @@ ENDC jr nc, .asm_1f8022 ld b, a - ld a, BANK(sbe46) + ld a, BANK(sNrOfBeatenBattleTowerTrainers) call GetSRAMBank ld c, BATTLETOWER_NROFTRAINERS @@ -49,12 +49,13 @@ ENDC jr nz, .asm_1f803a ; c <= 7 initialise all 7 trainers? ld hl, sBTTrainers - ld a, [sbe46] + ld a, [sNrOfBeatenBattleTowerTrainers] ld c, a ld a, b ld b, 0 add hl, bc ld [hl], a + call CloseSRAM push af @@ -82,10 +83,13 @@ ENDC ld a, b or c jr nz, .asm_1f8070 + pop af ld [rSVBK], a + ret + Function_LoadRandomBattleTowerPkmn: ; 1f8081 ld c, BATTLETOWER_NROFPKMNS .loop @@ -96,7 +100,7 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081 .FindARandomBattleTowerPkmn ; From Which LevelGroup are the Pkmn loaded ; a = 1..10 - ld a, [$d800] + ld a, [wBTChoiceOfLvlGroup] ; [$d800] dec a ld hl, BattleTowerMons ld bc, BattleTowerMons2 - BattleTowerMons1 @@ -117,7 +121,7 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081 ; Check if Pkmn was already loaded before ; Check current and the 2 previous teams ; includes check if item is double at the current team - ld bc, $3b + ld bc, BATTLETOWER_PKMNSTRUCTLENGTH + $b call AddNTimes ld a, [hli] ld b, a @@ -160,17 +164,17 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081 cp b jr z, .FindARandomBattleTowerPkmn - ld bc, $3b + ld bc, BATTLETOWER_PKMNSTRUCTLENGTH + $b call CopyBytes ld a, [wd265] push af push de - ld hl, -$3b + ld hl, - (BATTLETOWER_PKMNSTRUCTLENGTH + $b) add hl, de ld a, [hl] ld [wd265], a - ld bc, $0030 + ld bc, BATTLETOWER_PKMNSTRUCTLENGTH add hl, bc push hl call GetPokemonName diff --git a/maps/BattleTowerBattleRoom.asm b/maps/BattleTowerBattleRoom.asm index bda8bf906..ab40bd1be 100644 --- a/maps/BattleTowerBattleRoom.asm +++ b/maps/BattleTowerBattleRoom.asm @@ -34,8 +34,8 @@ Script_BattleRoomLoop: ; 0x9f425 special FadeBlackBGMap reloadmap if_not_equal $0, UnknownScript_0x9f4c2 - copybytetovar wcf64 - if_equal $7, Script_BeatenAllTrainers + copybytetovar wNrOfBeatenBattleTowerTrainers ; wcf64 + if_equal BATTLETOWER_NROFTRAINERS, Script_BeatenAllTrainers applymovement $2, MovementData_0x9e597 warpsound disappear $2 diff --git a/maps/BattleTowerHallway.asm b/maps/BattleTowerHallway.asm index 9da7ccf3f..4c46d5857 100644 --- a/maps/BattleTowerHallway.asm +++ b/maps/BattleTowerHallway.asm @@ -27,7 +27,7 @@ Function_0x9f5cb: ld a, 3 ld [rSVBK], a - ld a, [w3_d800] + ld a, [wBTChoiceOfLvlGroup] ld [ScriptVar], a pop af diff --git a/misc/mobile_45.asm b/misc/mobile_45.asm index 28821b189..8f98d1faf 100644 --- a/misc/mobile_45.asm +++ b/misc/mobile_45.asm @@ -9728,12 +9728,12 @@ Function118903: ; 118903 (46:4903) ld [wcd3c], a call Function119ed8 jp Function119e2e -; 11891c (46:491c) + Function11891c: ; 11891c call Function118b42 jp Function119e2e -; 118922 + Function118922: ; 118922 ld a, [wcd38] @@ -9770,13 +9770,13 @@ Function118936: ld a, [StatusFlags] bit 6, a jr nz, .asm_11896b - ld hl, Strings_Ll0ToL40 ; Address to list of strings with the choosable levels - ld a, 5 ; 4 levels to choose from, including 'Cancel'-option + ld hl, Strings_Ll0ToL40 ; Address to list of strings with the choosable levels + ld a, 5 ; 4 levels to choose from, including 'Cancel'-option jr .asm_118970 .asm_11896b - ld hl, Strings_L10ToL100 ; Address to list of strings with the choosable levels - ld a, 11 ; 10 levels to choose from, including 'Cancel'-option + ld hl, Strings_L10ToL100 ; Address to list of strings with the choosable levels + ld a, 11 ; 10 levels to choose from, including 'Cancel'-option .asm_118970 ld [wcd4a], a @@ -9915,7 +9915,8 @@ Function118982: ld a, $0 ld [wcd46], a ret -; 118a54 + + Function118a54: ; 118a54 ld a, [wcd55] @@ -22852,13 +22853,13 @@ Function17024d: ; 17024d ld [ScriptVar], a and a jr nz, .asm_1702a9 - ld a, BANK(sbe46) + ld a, BANK(sNrOfBeatenBattleTowerTrainers) call GetSRAMBank - ld a, [sbe46] - ld [wcf64], a + ld a, [sNrOfBeatenBattleTowerTrainers] + ld [wNrOfBeatenBattleTowerTrainers], a ; wcf64 call CloseSRAM ld hl, StringBuffer3 - ld a, [wcf64] + ld a, [wNrOfBeatenBattleTowerTrainers] ; wcf64 add $f7 ld [hli], a ld a, $50 @@ -22872,13 +22873,13 @@ Function17024d: ; 17024d ld a, $1 ld [wcf63], a ret -; 1702b7 + ; Initialise the BattleTower-Trainer and his Pkmn Function1702b7: ; 1702b7 - call Function1704a2 + call CopyBTTrainer_FromBT_OTrainer_TowBT_OTTempCopy ld de, wBT_OTTempCopy + wBT_OTTempCopy_Pkmn1Name ; $c643 - ld c, $b + ld c, PKMN_NAME_LENGTH callba Function17d073 jr nc, .asm_1702db @@ -22893,7 +22894,7 @@ Function1702b7: ; 1702b7 .asm_1702db ld de, wBT_OTTempCopy + wBT_OTTempCopy_Pkmn2Name ; $c67e - ld c, $b + ld c, PKMN_NAME_LENGTH callba Function17d073 jr nc, .asm_1702fc ld a, [wBT_OTTempCopy + wBT_OTTempCopy_Pkmn2] ; [$c64e] @@ -22907,7 +22908,7 @@ Function1702b7: ; 1702b7 .asm_1702fc ld de, wBT_OTTempCopy + wBT_OTTempCopy_Pkmn3Name ; $c686 + 51 = $c6b9 - ld c, $b + ld c, PKMN_NAME_LENGTH callba Function17d073 jr nc, .asm_17031d ld a, [wBT_OTTempCopy + wBT_OTTempCopy_Pkmn3] ; [$c689] @@ -22961,7 +22962,7 @@ Function1702b7: ; 1702b7 ld [bc], a inc bc push bc - ld bc, $0030 + ld bc, BATTLETOWER_PKMNSTRUCTLENGTH call CopyBytes push de ld a, [BGMapBuffer] @@ -23167,16 +23168,18 @@ Unknown_17047e: db $0f, $05, $14, $07 db $05, $05, $11, $0c db $0c, $06, $06, $04 -; 1704a2 -Function1704a2: ; 1704a2 + +CopyBTTrainer_FromBT_OTrainer_TowBT_OTTempCopy: ; 1704a2 +; copy the BattleTower-Trainer data that lies at 'BT_OTrainer' to 'wBT_OTTempCopy' ld a, [rSVBK] push af ld a, $3 ld [rSVBK], a - ld hl, $d100 ; this is NOT LYOverrides - ld de, $c608 - ld bc, BT_OTrainerEnd - BT_OTrainer + ld hl, BT_OTrainer ; $d100 + ld de, wBT_OTTempCopy ; $c608 + ld bc, BT_OTrainerEnd - BT_OTrainer ; $e0 = $a + $1 + 3*$3b + $24 + ; = $a + $1 + BATTLETOWER_NROFPKMNS * (BATTLETOWER_PKMNSTRUCTLENGTH + PKMN_NAME_LENGTH) + BATTLETOWER_TRAINERDATALENGTH call CopyBytes pop af ld [rSVBK], a @@ -23184,7 +23187,7 @@ Function1704a2: ; 1704a2 call GetSRAMBank ld a, $2 ld [s1_be45], a - ld hl, sbe46 + ld hl, sNrOfBeatenBattleTowerTrainers inc [hl] call CloseSRAM Function1704c9: @@ -23260,14 +23263,17 @@ Jumptable_17051f: ; 17051f Function170525: ; 170525 ld a, $5 call GetSRAMBank + ld hl, $a89c ld de, StringBuffer3 ld bc, $0016 call CopyBytes + ld hl, $a8b2 ld de, $c608 ld bc, $0096 call CopyBytes + call CloseSRAM hlcoord 1, 1 ld de, StringBuffer3 @@ -23285,10 +23291,12 @@ Function170525: ; 170525 call Function1705f0 jr Function1705b2 + Function170571: call Function32f9 call Function1705b2 + Function170577: ld hl, hJoyPressed ld a, [hl] @@ -23530,7 +23538,7 @@ Jumptable_170696: ; 170696 (5c:4696) dw Function17081d ; 0x17 dw Function170ae8 ; 0x18 dw Function170b16 ; 0x19 - dw Function1706d6 ; 0x1a + dw ResetBattleTowerTrainersSRAM ; 0x1a dw Function1706ee ; 0x1b dw Function17071b ; 0x1c dw Function170729 ; 0x1d @@ -23539,21 +23547,26 @@ Jumptable_170696: ; 170696 (5c:4696) ; Reset the save memory for BattleTower-Trainers (Counter and all 7 TrainerBytes) -Function1706d6: ; 1706d6 (5c:46d6) +ResetBattleTowerTrainersSRAM: ; 1706d6 (5c:46d6) ld a, BANK(sBTTrainers) call GetSRAMBank + ld a, $ff ld hl, sBTTrainers - ld bc, $7 + ld bc, BATTLETOWER_NROFTRAINERS call ByteFill + xor a - ld [sbe46], a + ld [sNrOfBeatenBattleTowerTrainers], a + call CloseSRAM + ret Function1706ee: ; 1706ee (5c:46ee) ld a, BANK(sbe50) call GetSRAMBank + ld a, [sbe50] call CloseSRAM ld [ScriptVar], a @@ -443,7 +443,7 @@ SECTION "Battle", WRAM0 wMisc:: wBattle:: -wBT_OTTempCopy:: ; also used to copy the data of the BattleTower-Trainer and the 3 Pkmn +wBT_OTTempCopy:: ; used to copy the data of the BattleTower-Trainer and the 3 Pkmn wc608:: wEnemyMoveStruct:: ds MOVE_LENGTH ; c608 @@ -886,7 +886,7 @@ wc7e8:: ds 24 RSSET 0 ; Offsets for wBT_OTTempCopy:: @ $c608 -wBT_OTTempCopy_0 RB $a ; $c608 +wBT_OTTempCopy_0 RB $A ; $c608 wBT_OTTempCopy_TrainerClass RB $1 ; $c608 + $a = $c612 wBT_OTTempCopy_Pkmn1 RB $30 ; $c608 + $b = $c613 wBT_OTTempCopy_Pkmn1Name RB $A ; $c608 + $3b = $c643 @@ -897,7 +897,6 @@ wBT_OTTempCopy_80 RB $1 ; $c608 + $80 = $c688 wBT_OTTempCopy_Pkmn3 RB $30 ; $c608 + $81 = $c689 wBT_OTTempCopy_Pkmn3Name RB $A ; $c608 + $b1 = $c6b9 wBT_OTTempCopy_BB RB $1 ; $c608 + $bb = $c6c3 -;str_SIZEOF RB 0 GLOBAL wBT_OTTempCopy_TrainerClass, wBT_OTTempCopy_Pkmn1, wBT_OTTempCopy_Pkmn1Name, wBT_OTTempCopy_45, wBT_OTTempCopy_Pkmn2, wBT_OTTempCopy_Pkmn2Name, wBT_OTTempCopy_80, wBT_OTTempCopy_Pkmn3, wBT_OTTempCopy_Pkmn3Name, wBT_OTTempCopy_BB @@ -1191,6 +1190,7 @@ CurSpecies:: ; cf60 wcf61:: ds 2 wcf63:: ds 1 +wNrOfBeatenBattleTowerTrainers:: wcf64:: ds 1 IF !DEF(CRYSTAL11) wPokedexStatus:: @@ -2621,9 +2621,11 @@ SECTION "WRAM 3", WRAMX, BANK [3] ds $100 BT_OTrainer:: -w3_d100:: ; BattleTower OpponentTrainer-Data (lengt = 0xe0) - ds $6 - ds $5 +w3_d100:: ; BattleTower OpponentTrainer-Data (length = 0xe0 = $a + $1 + 3*$3b + $24) +BT_OTrainer_Name:: + ds $A +BT_OTrainer_TrainerClass:: + ds $1 BT_OTPkmn1:: ; w3_d10b ds $1 BT_OTPkmn1Item:: @@ -2642,6 +2644,7 @@ BT_OTrainerEnd:: ds $620 +wBTChoiceOfLvlGroup:: w3_d800:: ds 1 @@ -2813,6 +2816,7 @@ s1_be45:: ds 1 ; data of the BattleTower must be in SRAM because you can save and leave between battles sBattleTower:: ; be46 +sNrOfBeatenBattleTowerTrainers:: sbe46:: ds 1 sbe47:: ds 1 ; The 7 trainers of the BattleTower are saved here, so nobody appears more than once |