ref: ce50d1b2cb4eebf8484cf12e6280c441ec94ae39
parent: 11556196ba546f5c45b97fffc2c263a79eb639b9
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Tue Jan 9 11:55:11 EST 2018
Clearer Battle Tower code
--- a/constants/battle_tower_constants.asm
+++ b/constants/battle_tower_constants.asm
@@ -42,10 +42,10 @@
const BATTLETOWER_RECEIVED_REWARD
BATTLETOWER_NROFPKMNS EQU 3
-BATTLETOWER_TRAINERDATALENGTH EQU $24
BATTLETOWER_NROFTRAINERS EQU 7
-BATTLETOWER_NRMONSPERLEVELBRACKET EQU BATTLETOWER_NROFPKMNS * BATTLETOWER_NROFTRAINERS
-BATTLE_TOWER_STRUCT_LENGTH EQU $e0 ; NAME_LENGTH + 3 * (PARTYMON_STRUCT_LENGTH + PKMN_NAME_LENGTH) + BATTLETOWER_TRAINERDATALENGTH
+
+BATTLETOWER_TRAINERDATALENGTH EQU $24
+BATTLE_TOWER_STRUCT_LENGTH EQU $e0 ; NAME_LENGTH + BATTLETOWER_NROFPKMNS * (PARTYMON_STRUCT_LENGTH + PKMN_NAME_LENGTH) + BATTLETOWER_TRAINERDATALENGTH
; return value from BattleTowerAction(BATTLETOWERACTION_CHECKMOBILEEVENT)
MOBILE_EVENT_OBJECT_GS_BALL EQU $b
--- /dev/null
+++ b/data/battle_tower/classes.asm
@@ -1,0 +1,82 @@
+BattleTowerTrainers: ; 1f814e
+; The trainer class is not used in Crystal 1.0 due to a bug.
+; Instead, the sixth character in the trainer's name is used.
+; See BattleTowerText in engine/events/battle_tower/trainer_text.asm.
+ db "HANSON@@@@", FISHER
+ db "SAWYER@@@@", POKEMANIAC
+ db "MASUDA@@@@", GUITARIST
+ db "NICKEL@@@@", SCIENTIST
+ db "OLSON@@@@@", POKEFANM
+ db "ZABOROWSKI", LASS
+ db "WRIGHT@@@@", YOUNGSTER
+ db "ALEXANDER@", HIKER
+ db "KAWAKAMI@@", TEACHER
+ db "BICKETT@@@", POKEFANM
+ db "SAITO@@@@@", KIMONO_GIRL
+ db "CRAWFORD@@", BOARDER
+ db "DIAZ@@@@@@", PICNICKER
+ db "ERICKSON@@", BIKER
+ db "FAIRFIELD@", JUGGLER
+ db "HUNTER@@@@", POKEFANF
+ db "HILL@@@@@@", FIREBREATHER
+ db "JAVIER@@@@", SWIMMERF
+ db "KAUFMAN@@@", SWIMMERM
+ db "LANCASTER@", SKIER
+ db "McMAHILL@@", CAMPER
+if !DEF(CRYSTAL11)
+BattleTowerTrainersEnd:
+endc
+; The following can only be sampled in Crystal 1.1.
+ db "OBRIEN@@@@", GENTLEMAN
+ db "FROST@@@@@", BEAUTY
+ db "MORSE@@@@@", SUPER_NERD
+ db "YUFUNE@@@@", BLACKBELT_T
+ db "RAJAN@@@@@", COOLTRAINERF
+ db "RODRIGUEZ@", OFFICER
+ db "SANTIAGO@@", PSYCHIC_T
+ db "STOCK@@@@@", POKEFANM
+ db "THURMAN@@@", SCIENTIST
+ db "VALENTINO@", BEAUTY
+ db "WAGNER@@@@", CAMPER
+ db "YATES@@@@@", BIRD_KEEPER
+ db "ANDREWS@@@", PICNICKER
+ db "BAHN@@@@@@", POKEMANIAC
+ db "MORI@@@@@@", SCIENTIST
+ db "BUCKMAN@@@", SAGE
+ db "COBB@@@@@@", SCHOOLBOY
+ db "HUGHES@@@@", FISHER
+ db "ARITA@@@@@", KIMONO_GIRL
+ db "EASTON@@@@", PSYCHIC_T
+ db "FREEMAN@@@", CAMPER
+ db "GIESE@@@@@", LASS
+ db "HATCHER@@@", GENTLEMAN
+ db "JACKSON@@@", POKEFANF
+ db "KAHN@@@@@@", POKEMANIAC
+ db "LEONG@@@@@", YOUNGSTER
+ db "MARINO@@@@", TEACHER
+ db "NEWMAN@@@@", SAILOR
+ db "NGUYEN@@@@", BLACKBELT_T
+ db "OGDEN@@@@@", SUPER_NERD
+ db "PARK@@@@@@", COOLTRAINERF
+ db "RAINE@@@@@", SWIMMERM
+ db "SELLS@@@@@", BIRD_KEEPER
+ db "ROCKWELL@@", BOARDER
+ db "THORNTON@@", LASS
+ db "TURNER@@@@", OFFICER
+ db "VAN DYKE@@", SKIER
+ db "WALKER@@@@", SCHOOLBOY
+ db "MEYER@@@@@", SWIMMERF
+ db "JOHNSON@@@", YOUNGSTER
+ db "ADAMS@@@@@", GUITARIST
+ db "SMITH@@@@@", BUG_CATCHER
+ db "TAJIRI@@@@", BUG_CATCHER
+ db "BAKER@@@@@", POKEMANIAC
+ db "COLLINS@@@", SCIENTIST
+ db "SMART@@@@@", SUPER_NERD
+ db "DYKSTRA@@@", SWIMMERF
+ db "EATON@@@@@", BIKER
+ db "WONG@@@@@@", FIREBREATHER
+if DEF(CRYSTAL11)
+BattleTowerTrainersEnd:
+endc
+; 1f8450
--- a/data/battle_tower/parties.asm
+++ b/data/battle_tower/parties.asm
@@ -1,83 +1,7 @@
-BattleTowerTrainers: ; 1f814e
-; The trainer class is not used in Crystal 1.0 due to a bug.
-; Instead, the sixth character in the trainer's name is used.
-; See mobile/battle_tower_47.asm
- db "HANSON@@@@", FISHER
- db "SAWYER@@@@", POKEMANIAC
- db "MASUDA@@@@", GUITARIST
- db "NICKEL@@@@", SCIENTIST
- db "OLSON@@@@@", POKEFANM
- db "ZABOROWSKI", LASS
- db "WRIGHT@@@@", YOUNGSTER
- db "ALEXANDER@", HIKER
- db "KAWAKAMI@@", TEACHER
- db "BICKETT@@@", POKEFANM
- db "SAITO@@@@@", KIMONO_GIRL
- db "CRAWFORD@@", BOARDER
- db "DIAZ@@@@@@", PICNICKER
- db "ERICKSON@@", BIKER
- db "FAIRFIELD@", JUGGLER
- db "HUNTER@@@@", POKEFANF
- db "HILL@@@@@@", FIREBREATHER
- db "JAVIER@@@@", SWIMMERF
- db "KAUFMAN@@@", SWIMMERM
- db "LANCASTER@", SKIER
- db "McMAHILL@@", CAMPER
-; The following can only be sampled in Crystal 1.1.
- db "OBRIEN@@@@", GENTLEMAN
- db "FROST@@@@@", BEAUTY
- db "MORSE@@@@@", SUPER_NERD
- db "YUFUNE@@@@", BLACKBELT_T
- db "RAJAN@@@@@", COOLTRAINERF
- db "RODRIGUEZ@", OFFICER
- db "SANTIAGO@@", PSYCHIC_T
- db "STOCK@@@@@", POKEFANM
- db "THURMAN@@@", SCIENTIST
- db "VALENTINO@", BEAUTY
- db "WAGNER@@@@", CAMPER
- db "YATES@@@@@", BIRD_KEEPER
- db "ANDREWS@@@", PICNICKER
- db "BAHN@@@@@@", POKEMANIAC
- db "MORI@@@@@@", SCIENTIST
- db "BUCKMAN@@@", SAGE
- db "COBB@@@@@@", SCHOOLBOY
- db "HUGHES@@@@", FISHER
- db "ARITA@@@@@", KIMONO_GIRL
- db "EASTON@@@@", PSYCHIC_T
- db "FREEMAN@@@", CAMPER
- db "GIESE@@@@@", LASS
- db "HATCHER@@@", GENTLEMAN
- db "JACKSON@@@", POKEFANF
- db "KAHN@@@@@@", POKEMANIAC
- db "LEONG@@@@@", YOUNGSTER
- db "MARINO@@@@", TEACHER
- db "NEWMAN@@@@", SAILOR
- db "NGUYEN@@@@", BLACKBELT_T
- db "OGDEN@@@@@", SUPER_NERD
- db "PARK@@@@@@", COOLTRAINERF
- db "RAINE@@@@@", SWIMMERM
- db "SELLS@@@@@", BIRD_KEEPER
- db "ROCKWELL@@", BOARDER
- db "THORNTON@@", LASS
- db "TURNER@@@@", OFFICER
- db "VAN DYKE@@", SKIER
- db "WALKER@@@@", SCHOOLBOY
- db "MEYER@@@@@", SWIMMERF
- db "JOHNSON@@@", YOUNGSTER
- db "ADAMS@@@@@", GUITARIST
- db "SMITH@@@@@", BUG_CATCHER
- db "TAJIRI@@@@", BUG_CATCHER
- db "BAKER@@@@@", POKEMANIAC
- db "COLLINS@@@", SCIENTIST
- db "SMART@@@@@", SUPER_NERD
- db "DYKSTRA@@@", SWIMMERF
- db "EATON@@@@@", BIKER
- db "WONG@@@@@@", FIREBREATHER
-; 1f8450
-
-
BattleTowerMons: ; 1f8450
; 10 groups of 21 mons.
+
+
BattleTowerMons1:
db JOLTEON
--- a/engine/events/battle_tower/load_trainer.asm
+++ b/engine/events/battle_tower/load_trainer.asm
@@ -27,12 +27,11 @@
add b
ld b, a ; b contains the nr of the trainer
if DEF(CRYSTAL11)
- and (1 << 7) - 1
- cp 70
+ and $7f
else
- and (1 << 5) - 1
- cp 21
+ and $1f
endc
+ cp (BattleTowerTrainersEnd - BattleTowerTrainers) / NAME_LENGTH
jr nc, .resample
ld b, a
@@ -114,7 +113,7 @@
add b
ld b, a
and $1f
- cp BATTLETOWER_NRMONSPERLEVELBRACKET
+ cp BATTLETOWER_NROFPKMNS * BATTLETOWER_NROFTRAINERS
jr nc, .resample
; in register 'a' is the chosen Pkmn of the LevelGroup
@@ -206,5 +205,7 @@
call CloseSRAM
ret
; 1f814e
+
+INCLUDE "data/battle_tower/classes.asm"
INCLUDE "data/battle_tower/parties.asm"