comparison pytouhou/vm/anmrunner.py @ 430:c9433188ffdb

Remove AnmWrapper, since ANMs are lists of entries now.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 03 Aug 2013 15:49:04 +0200
parents 40d5f3083ebc
children d4874ebaa06e
comparison
equal deleted inserted replaced
429:40d5f3083ebc 430:c9433188ffdb
21 logger = get_logger(__name__) 21 logger = get_logger(__name__)
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', '_sprite', 'running', 'sprite_index_offset', 'script',
27 'sprite_index_offset', 'script', 'instruction_pointer', 27 'instruction_pointer', 'frame', 'waiting', 'handlers',
28 'frame', 'waiting', 'handlers', 'variables', 'version', 'timeout') 28 'variables', 'version', 'timeout')
29 29
30 #TODO: check! 30 #TODO: check!
31 formulae = {0: lambda x: x, 31 formulae = {0: lambda x: x,
32 1: lambda x: x ** 2, 32 1: lambda x: x ** 2,
33 2: lambda x: x ** 3, 33 2: lambda x: x ** 3,
36 5: lambda x: 2 * x - x ** 3, 36 5: lambda x: 2 * x - x ** 3,
37 6: lambda x: 2 * x - x ** 4, 37 6: lambda x: 2 * x - x ** 4,
38 7: lambda x: x, 38 7: lambda x: x,
39 255: lambda x: x} #XXX 39 255: lambda x: x} #XXX
40 40
41 def __init__(self, anm_wrapper, script_id, sprite, sprite_index_offset=0): 41 def __init__(self, anm, script_id, sprite, sprite_index_offset=0):
42 self._anm_wrapper = anm_wrapper 42 self._anm = anm
43 self._sprite = sprite 43 self._sprite = sprite
44 self.running = True 44 self.running = True
45 self.waiting = False 45 self.waiting = False
46 46
47 anm, self.script = anm_wrapper.get_script(script_id) 47 self.script = anm.scripts[script_id]
48 self.version = anm.version 48 self.version = anm.version
49 self.handlers = self._handlers[{0: 6, 2: 7}[anm.version]] 49 self.handlers = self._handlers[{0: 6, 2: 7}[anm.version]]
50 self.frame = 0 50 self.frame = 0
51 self.timeout = -1 51 self.timeout = -1
52 self.instruction_pointer = 0 52 self.instruction_pointer = 0
164 164
165 @instruction(1) 165 @instruction(1)
166 @instruction(3, 7) 166 @instruction(3, 7)
167 def load_sprite(self, sprite_index): 167 def load_sprite(self, sprite_index):
168 #TODO: version 2 only: do not crash when assigning a non-existant sprite. 168 #TODO: version 2 only: do not crash when assigning a non-existant sprite.
169 self._sprite.anm, self._sprite.texcoords = self._anm_wrapper.get_sprite(sprite_index + self.sprite_index_offset) 169 self._sprite.anm, self._sprite.texcoords = self._anm, self._anm.sprites[sprite_index + self.sprite_index_offset]
170 170
171 171
172 @instruction(2) 172 @instruction(2)
173 @instruction(7, 7) 173 @instruction(7, 7)
174 def set_scale(self, sx, sy): 174 def set_scale(self, sx, sy):