Mercurial > touhou
comparison pytouhou/vm/anmrunner.py @ 376:69ec72b990a4
Support more than one version of a vm.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 06 Aug 2012 23:10:09 +0200 |
parents | f3099ebf4f61 |
children | 40d5f3083ebc |
comparison
equal
deleted
inserted
replaced
375:8f2f3053906a | 376:69ec72b990a4 |
---|---|
22 | 22 |
23 | 23 |
24 class ANMRunner(object): | 24 class ANMRunner(object): |
25 __metaclass__ = MetaRegistry | 25 __metaclass__ = MetaRegistry |
26 __slots__ = ('_anm_wrapper', '_sprite', 'running', | 26 __slots__ = ('_anm_wrapper', '_sprite', 'running', |
27 'sprite_index_offset', | 27 'sprite_index_offset', 'script', 'instruction_pointer', |
28 'script', 'instruction_pointer', 'frame', | 28 'frame', 'waiting', 'handlers') |
29 'waiting') | |
30 | 29 |
31 | 30 |
32 def __init__(self, anm_wrapper, script_id, sprite, sprite_index_offset=0): | 31 def __init__(self, anm_wrapper, script_id, sprite, sprite_index_offset=0): |
33 self._anm_wrapper = anm_wrapper | 32 self._anm_wrapper = anm_wrapper |
34 self._sprite = sprite | 33 self._sprite = sprite |
34 self.handlers = self._handlers[6] | |
35 self.running = True | 35 self.running = True |
36 self.waiting = False | 36 self.waiting = False |
37 | 37 |
38 anm, self.script = anm_wrapper.get_script(script_id) | 38 anm, self.script = anm_wrapper.get_script(script_id) |
39 self.frame = 0 | 39 self.frame = 0 |
69 else: | 69 else: |
70 self.instruction_pointer += 1 | 70 self.instruction_pointer += 1 |
71 | 71 |
72 if frame == self.frame: | 72 if frame == self.frame: |
73 try: | 73 try: |
74 callback = self._handlers[opcode] | 74 callback = self.handlers[opcode] |
75 except KeyError: | 75 except KeyError: |
76 logger.warn('unhandled opcode %d (args: %r)', opcode, args) | 76 logger.warn('unhandled opcode %d (args: %r)', opcode, args) |
77 else: | 77 else: |
78 callback(self, *args) | 78 callback(self, *args) |
79 sprite.changed = True | 79 sprite.changed = True |