comparison pytouhou/vm/anmrunner.py @ 240:02de1563fa18

Fix ANM wait, translation/rotation order, and partially implement ANM0 instruction 24
author Thibaut Girka <thib@sitedethib.com>
date Sun, 01 Jan 2012 23:51:01 +0100
parents 901489c21d19
children 3893a6fc66f1
comparison
equal deleted inserted replaced
239:901489c21d19 240:02de1563fa18
56 56
57 def run_frame(self): 57 def run_frame(self):
58 if not self._running: 58 if not self._running:
59 return False 59 return False
60 60
61 if self.waiting:
62 return True
63
64 sprite = self._sprite 61 sprite = self._sprite
65 62
66 while self._running: 63 while self._running and not self.waiting:
67 frame, opcode, args = self.script[self.instruction_pointer] 64 frame, opcode, args = self.script[self.instruction_pointer]
68 65
69 if frame > self.frame: 66 if frame > self.frame:
70 break 67 break
71 else: 68 else:
77 except KeyError: 74 except KeyError:
78 logger.warn('unhandled opcode %d (args: %r)', opcode, args) 75 logger.warn('unhandled opcode %d (args: %r)', opcode, args)
79 else: 76 else:
80 callback(self, *args) 77 callback(self, *args)
81 sprite._changed = True 78 sprite._changed = True
79
80 if self.waiting:
81 return True
82
82 self.frame += 1 83 self.frame += 1
83 84
84 # Update sprite 85 # Update sprite
85 sprite.frame += 1 86 sprite.frame += 1
86 87
228 @instruction(23) 229 @instruction(23)
229 def set_corner_relative_placement(self): 230 def set_corner_relative_placement(self):
230 self._sprite.corner_relative_placement = True #TODO 231 self._sprite.corner_relative_placement = True #TODO
231 232
232 233
234 @instruction(24)
235 def wait_ex(self):
236 """Hide/delete the sprite and wait for an interrupt.
237 """
238 #TODO: Hide/delete the sprite and figure what happens exactly
239 self.waiting = True
240
241
233 @instruction(25) 242 @instruction(25)
234 def set_allow_dest_offset(self, value): 243 def set_allow_dest_offset(self, value):
235 self._sprite.allow_dest_offset = bool(value) 244 self._sprite.allow_dest_offset = bool(value)
236 245
237 246