From bcc11712a578f1a0020fb0ab4543205324ec018d Mon Sep 17 00:00:00 2001 From: JimB16 Date: Mon, 31 Aug 2015 14:31:13 +0200 Subject: [PATCH] added 'wBT_OTTempCopy'-label and the data structure that comes after --- constants/misc_constants.asm | 4 +++ data/battle_tower.asm | 18 +++++++++---- engine/specials.asm | 2 +- maps/BattleTowerBattleRoom.asm | 2 +- misc/mobile_45.asm | 46 ++++++++++++++++++---------------- wram.asm | 21 +++++++++++----- 6 files changed, 59 insertions(+), 34 deletions(-) diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 48471c5f8..597e46efa 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -108,3 +108,7 @@ const_value = 1 const MOM_ITEM const MOM_DOLL +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 f6d7b95de..dc96b3822 100644 --- a/data/battle_tower.asm +++ b/data/battle_tower.asm @@ -35,9 +35,11 @@ ELSE ENDC jr nc, .asm_1f8022 ld b, a + ld a, BANK(sbe46) call GetSRAMBank - ld c, $7 + + ld c, BATTLETOWER_NROFTRAINERS ld hl, sBTTrainers .asm_1f803a ld a, [hli] @@ -45,6 +47,7 @@ ENDC jr z, .asm_1f8022 dec c jr nz, .asm_1f803a ; c <= 7 initialise all 7 trainers? + ld hl, sBTTrainers ld a, [sbe46] ld c, a @@ -53,18 +56,22 @@ ENDC add hl, bc ld [hl], a call CloseSRAM + push af +; Copy name (10 bytes) and class (1 byte) of trainer ld hl, BattleTowerTrainers ld bc, 11 call AddNTimes ld bc, 11 call CopyBytes + call Function_LoadRandomBattleTowerPkmn pop af + ld hl, BattleTowerTrainerData - ld bc, $0024 + ld bc, BATTLETOWER_TRAINERDATALENGTH call AddNTimes - ld bc, $0024 + ld bc, BATTLETOWER_TRAINERDATALENGTH .asm_1f8070 ld a, BANK(BattleTowerTrainerData) call GetFarByte @@ -78,10 +85,9 @@ ENDC pop af ld [rSVBK], a ret -; 1f8081 Function_LoadRandomBattleTowerPkmn: ; 1f8081 - ld c, $3 + ld c, BATTLETOWER_NROFPKMNS .loop push bc ld a, BANK(sBTPkmnPrevTrainer1) @@ -156,6 +162,7 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081 ld bc, $3b call CopyBytes + ld a, [wd265] push af push de @@ -172,6 +179,7 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081 pop de ld bc, PKMN_NAME_LENGTH call CopyBytes + pop de pop af ld [wd265], a diff --git a/engine/specials.asm b/engine/specials.asm index 6139f4b30..5a10090ec 100644 --- a/engine/specials.asm +++ b/engine/specials.asm @@ -142,7 +142,7 @@ SpecialsPointers:: ; c029 add_special Function170215 add_special Function1704e1 add_special Function17021d - add_special Function_LoadOpponentTrainerAndPokemons170b44 + add_special Function_LoadOpponentTrainerAndPokemonsWithOTSprite add_special Function11ba38 add_special SpecialCheckForBattleTowerRules add_special Function117656 diff --git a/maps/BattleTowerBattleRoom.asm b/maps/BattleTowerBattleRoom.asm index 874b5a594..bda8bf906 100644 --- a/maps/BattleTowerBattleRoom.asm +++ b/maps/BattleTowerBattleRoom.asm @@ -21,7 +21,7 @@ Script_BattleRoom: ; 0x9f421 ; beat all 7 opponents in a row Script_BattleRoomLoop: ; 0x9f425 writebyte $2 - special Function_LoadOpponentTrainerAndPokemons170b44 + special Function_LoadOpponentTrainerAndPokemonsWithOTSprite appear $2 warpsound waitbutton diff --git a/misc/mobile_45.asm b/misc/mobile_45.asm index 9f76d36bc..28821b189 100644 --- a/misc/mobile_45.asm +++ b/misc/mobile_45.asm @@ -22877,54 +22877,55 @@ Function17024d: ; 17024d ; Initialise the BattleTower-Trainer and his Pkmn Function1702b7: ; 1702b7 call Function1704a2 - ld de, $c643 + ld de, wBT_OTTempCopy + wBT_OTTempCopy_Pkmn1Name ; $c643 ld c, $b callba Function17d073 jr nc, .asm_1702db - ld a, [BT_OTTempCopy + 11] + + ld a, [wBT_OTTempCopy + wBT_OTTempCopy_Pkmn1] ld [wd265], a call GetPokemonName ld l, e ld h, d - ld de, $c643 + ld de, wBT_OTTempCopy + wBT_OTTempCopy_Pkmn1Name ; $c643 ld bc, PKMN_NAME_LENGTH call CopyBytes .asm_1702db - ld de, $c67e + ld de, wBT_OTTempCopy + wBT_OTTempCopy_Pkmn2Name ; $c67e ld c, $b callba Function17d073 jr nc, .asm_1702fc - ld a, [$c64e] + ld a, [wBT_OTTempCopy + wBT_OTTempCopy_Pkmn2] ; [$c64e] ld [wd265], a call GetPokemonName ld l, e ld h, d - ld de, $c67e + ld de, wBT_OTTempCopy + wBT_OTTempCopy_Pkmn2Name ; $c67e ld bc, PKMN_NAME_LENGTH call CopyBytes .asm_1702fc - ld de, $c686 + 51 + ld de, wBT_OTTempCopy + wBT_OTTempCopy_Pkmn3Name ; $c686 + 51 = $c6b9 ld c, $b callba Function17d073 jr nc, .asm_17031d - ld a, [$c689] + ld a, [wBT_OTTempCopy + wBT_OTTempCopy_Pkmn3] ; [$c689] ld [wd265], a call GetPokemonName ld l, e ld h, d - ld de, $c686 + 51 + ld de, wBT_OTTempCopy + wBT_OTTempCopy_Pkmn3Name ; $c686 + 51 = $c6b9 ld bc, PKMN_NAME_LENGTH call CopyBytes .asm_17031d ld a, $50 - ld [$c64d], a - ld [$c688], a - ld [$c68a + 57], a + ld [wBT_OTTempCopy + wBT_OTTempCopy_45], a ; $c64d + ld [wBT_OTTempCopy + wBT_OTTempCopy_80], a ; $c688 + ld [wBT_OTTempCopy + wBT_OTTempCopy_BB], a ; $c68a + 57 = $c6c3 call Function170c98 - ld de, BT_OTTempCopy + ld de, wBT_OTTempCopy ld c, $a callba Function17d073 jr nc, .asm_17033d @@ -22932,7 +22933,7 @@ Function1702b7: ; 1702b7 jr .asm_170340 .asm_17033d - ld hl, BT_OTTempCopy ; 0xc608 + ld hl, wBT_OTTempCopy ; 0xc608 .asm_170340 ld de, wd26b @@ -22940,20 +22941,20 @@ Function1702b7: ; 1702b7 call CopyBytes ld a, $50 ld [de], a - ld hl, BT_OTTempCopy + $a + ld hl, wBT_OTTempCopy + wBT_OTTempCopy_TrainerClass ld a, [hli] ld [OtherTrainerClass], a ld a, $ea ld [BGMapBuffer], a ld a, $d3 ld [wcd21], a - ld de, OTPartyMon1Species - ld bc, OTPartyCount - ld a, $3 ; Number of Pkmn the BattleTower-Trainer has - ld [bc], a - inc bc ; Copy Pkmn into Memory from the address in hl + ld de, OTPartyMon1Species + ld bc, OTPartyCount + ld a, BATTLETOWER_NROFPKMNS ; Number of Pkmn the BattleTower-Trainer has + ld [bc], a + inc bc .asm_170367 push af ld a, [hl] @@ -24182,7 +24183,7 @@ Function170b16: ; 170b16 (5c:4b16) ld [ScriptVar], a ret -Function_LoadOpponentTrainerAndPokemons170b44: ; 0x170b44 +Function_LoadOpponentTrainerAndPokemonsWithOTSprite: ; 0x170b44 callba Function_LoadOpponentTrainerAndPokemons ld a, [rSVBK] push af @@ -24199,6 +24200,9 @@ Function_LoadOpponentTrainerAndPokemons170b44: ; 0x170b44 add hl, bc ld a, [hl] ld [wcd49], a + +; Load sprite of the opponent trainer +; because s/he is chosen randomly and appears out of nowhere ld a, [ScriptVar] dec a sla a diff --git a/wram.asm b/wram.asm index 7af5d3e1f..873193b08 100644 --- a/wram.asm +++ b/wram.asm @@ -443,6 +443,7 @@ SECTION "Battle", WRAM0 wMisc:: wBattle:: +wBT_OTTempCopy:: ; also used to copy the data of the BattleTower-Trainer and the 3 Pkmn wc608:: wEnemyMoveStruct:: ds MOVE_LENGTH ; c608 @@ -884,13 +885,21 @@ wMiscEnd:: wc7e8:: ds 24 -RSSET $c608 ;$c000+(wc608-wc000) ; compute the address through doesn't seem to work -BT_OTTempCopy RW 1 -str_tData RB 256 -str_bCount RB 1 -str_SIZEOF RB 0 +RSSET 0 ; Offsets for wBT_OTTempCopy:: @ $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 +wBT_OTTempCopy_45 RB $1 ; $c608 + $45 = $c64d +wBT_OTTempCopy_Pkmn2 RB $30 ; $c608 + $46 = $c64e +wBT_OTTempCopy_Pkmn2Name RB $A ; $c608 + $76 = $c67e +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 BT_OTTempCopy +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