From 8c8868813a783063b776fece9addfcbc2f2530c1 Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 21 Jul 2015 23:39:12 -0700 Subject: Fix event flags, and read them only if necessary. Event flags are enumerated using macros defined outside of event_flags.asm, so parse the macros too. --- pokemontools/crystal.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pokemontools/crystal.py b/pokemontools/crystal.py index 610f4f7..df66774 100644 --- a/pokemontools/crystal.py +++ b/pokemontools/crystal.py @@ -1453,15 +1453,26 @@ class DataByteWordMacro(Command): def to_asm(self): pass -event_flags = wram.read_constants(os.path.join(conf.path, 'constants/event_flags.asm')) -engine_flags = wram.read_constants(os.path.join(conf.path, 'constants/engine_flags.asm')) +event_flags = None +def read_event_flags(): + global event_flags + constants = wram.read_constants(os.path.join(conf.path, 'constants.asm')) + event_flags = dict(filter(lambda (key, value): value.startswith('EVENT_'), constants.items())) + +engine_flags = None +def read_engine_flags(): + global engine_flags + constants = wram.read_constants(os.path.join(conf.path, 'constants.asm')) + engine_flags = dict(filter(lambda (key, value): value.startswith('ENGINE_'), constants.items())) class EventFlagParam(MultiByteParam): def to_asm(self): - return event_flags.get(self.parsed_number) or MultiByteParam.to_asm(self) + if event_flags is None: read_event_flags() + return event_flags.get(self.parsed_number) or MultiByteParam.to_asm(self) class EngineFlagParam(MultiByteParam): def to_asm(self): + if engine_flags is None: read_engine_flags() return engine_flags.get(self.parsed_number) or MultiByteParam.to_asm(self) -- cgit v1.2.3