ref: bcc11712a578f1a0020fb0ab4543205324ec018d
parent: 051d9e416d0ab267065f2e9e23daab43527e827c
author: JimB16 <f1@jimb.de>
date: Mon Aug 31 10:31:13 EDT 2015
added 'wBT_OTTempCopy'-label and the data structure that comes after
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -108,3 +108,7 @@
const MOM_ITEM
const MOM_DOLL
+BATTLETOWER_NROFPKMNS EQU 3
+BATTLETOWER_TRAINERDATALENGTH EQU $24
+BATTLETOWER_NROFTRAINERS EQU 7
+
--- a/data/battle_tower.asm
+++ b/data/battle_tower.asm
@@ -35,9 +35,11 @@
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 @@
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 @@
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 @@
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 @@
ld bc, $3b
call CopyBytes
+
ld a, [wd265]
push af
push de
@@ -172,6 +179,7 @@
pop de
ld bc, PKMN_NAME_LENGTH
call CopyBytes
+
pop de
pop af
ld [wd265], a
--- a/engine/specials.asm
+++ b/engine/specials.asm
@@ -142,7 +142,7 @@
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
--- a/maps/BattleTowerBattleRoom.asm
+++ b/maps/BattleTowerBattleRoom.asm
@@ -21,7 +21,7 @@
; beat all 7 opponents in a row
Script_BattleRoomLoop: ; 0x9f425
writebyte $2
- special Function_LoadOpponentTrainerAndPokemons170b44
+ special Function_LoadOpponentTrainerAndPokemonsWithOTSprite
appear $2
warpsound
waitbutton
--- a/misc/mobile_45.asm
+++ b/misc/mobile_45.asm
@@ -22877,54 +22877,55 @@
; 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 @@
jr .asm_170340
.asm_17033d
- ld hl, BT_OTTempCopy ; 0xc608
+ ld hl, wBT_OTTempCopy ; 0xc608
.asm_170340
ld de, wd26b
@@ -22940,7 +22941,7 @@
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
@@ -22947,13 +22948,13 @@
ld [BGMapBuffer], a
ld a, $d3
ld [wcd21], a
+
+ ; Copy Pkmn into Memory from the address in hl
ld de, OTPartyMon1Species
ld bc, OTPartyCount
- ld a, $3 ; Number of Pkmn the BattleTower-Trainer has
+ ld a, BATTLETOWER_NROFPKMNS ; Number of Pkmn the BattleTower-Trainer has
ld [bc], a
inc bc
-
- ; Copy Pkmn into Memory from the address in hl
.asm_170367
push af
ld a, [hl]
@@ -24182,7 +24183,7 @@
ld [ScriptVar], a
ret
-Function_LoadOpponentTrainerAndPokemons170b44: ; 0x170b44
+Function_LoadOpponentTrainerAndPokemonsWithOTSprite: ; 0x170b44
callba Function_LoadOpponentTrainerAndPokemons
ld a, [rSVBK]
push af
@@ -24199,6 +24200,9 @@
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
--- a/wram.asm
+++ b/wram.asm
@@ -443,6 +443,7 @@
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 @@
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