diff options
author | Bryan Bishop <kanzure@gmail.com> | 2013-11-14 01:08:08 -0600 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2013-11-14 01:08:08 -0600 |
commit | 1bbfb2869fd011416d4ca4883105d7308a562655 (patch) | |
tree | 0edb514a1d24fec785968ed89542c6510f4982f1 /pokemontools/vba/battle.py | |
parent | dc0a7ac670915a089d1b1ba27df0b5daca2b56f3 (diff) |
a faster way to detect the stats screen in battles
The other way was way too slow since it had to parse 1000 characters
every frame.
Diffstat (limited to 'pokemontools/vba/battle.py')
-rw-r--r-- | pokemontools/vba/battle.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/pokemontools/vba/battle.py b/pokemontools/vba/battle.py index 898a594..8ba534c 100644 --- a/pokemontools/vba/battle.py +++ b/pokemontools/vba/battle.py @@ -38,7 +38,7 @@ class Battle(EmulatorController): """ Detects if the battle is waiting for player input. """ - return self.is_player_turn() or self.is_mandatory_switch() or self.is_switch_prompt() + return self.is_player_turn() or self.is_mandatory_switch() or self.is_switch_prompt() or self.is_levelup_screen() def is_fight_pack_run_menu(self): """ @@ -224,17 +224,17 @@ class Battle(EmulatorController): """ Detects the levelup stats screen. """ - requirements = [ - "ATTACK ", - "DEFENSE ", - "SPCL.ATK ", - "SPCL.DEF ", - "SPEED ", - ] + # This is implemented as reading some text on the screen instead of + # using get_text() because checking every loop is really slow. - screen_text = self.emulator.get_text() + address = 0xc50f + values = [146, 143, 130, 139] - return all([requirement in screen_text for requirement in requirements]) + for (index, value) in enumerate(values): + if self.emulator.vba.read_memory_at(address + index) != value: + return False + else: + return True def skip_start_text(self, max_loops=20): """ |