diff options
author | yenatch <yenatch@gmail.com> | 2015-07-21 23:39:12 -0700 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2015-07-21 23:40:33 -0700 |
commit | 8c8868813a783063b776fece9addfcbc2f2530c1 (patch) | |
tree | e4383b1ac3f5ad750fb0e315c7162c6cbce76f7a | |
parent | bf76a6b84a2f57edbcd01d6b2841cb813b2afce4 (diff) |
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.
-rw-r--r-- | pokemontools/crystal.py | 17 |
1 files 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) |