Mercurial > touhou
comparison pytouhou/vm/eclrunner.py @ 180:5a1533677a9a
Freeze time during spellcards
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sun, 23 Oct 2011 23:28:22 +0200 |
parents | 0bd5e5f19a73 |
children | 184196480f59 |
comparison
equal
deleted
inserted
replaced
179:3c2a9e28198c | 180:5a1533677a9a |
---|---|
23 | 23 |
24 | 24 |
25 | 25 |
26 class ECLMainRunner(object): | 26 class ECLMainRunner(object): |
27 __metaclass__ = MetaRegistry | 27 __metaclass__ = MetaRegistry |
28 __slots__ = ('_ecl', '_game', 'processes', | 28 __slots__ = ('_ecl', '_game', 'processes', 'frame', |
29 'instruction_pointer') | 29 'instruction_pointer') |
30 | 30 |
31 def __init__(self, ecl, game): | 31 def __init__(self, ecl, game): |
32 self._ecl = ecl | 32 self._ecl = ecl |
33 self._game = game | 33 self._game = game |
34 self.frame = 0 | |
34 | 35 |
35 self.processes = [] | 36 self.processes = [] |
36 | 37 |
37 self.instruction_pointer = 0 | 38 self.instruction_pointer = 0 |
38 | 39 |
42 try: | 43 try: |
43 frame, sub, instr_type, args = self._ecl.main[self.instruction_pointer] | 44 frame, sub, instr_type, args = self._ecl.main[self.instruction_pointer] |
44 except IndexError: | 45 except IndexError: |
45 break | 46 break |
46 | 47 |
47 if frame > self._game.frame: | 48 if frame > self.frame: |
48 break | 49 break |
49 else: | 50 else: |
50 self.instruction_pointer += 1 | 51 self.instruction_pointer += 1 |
51 | 52 |
52 if frame == self._game.frame: | 53 if frame == self.frame: |
53 try: | 54 try: |
54 callback = self._handlers[instr_type] | 55 callback = self._handlers[instr_type] |
55 except KeyError: | 56 except KeyError: |
56 logger.warn('unhandled main opcode %d (args: %r)', instr_type, args) | 57 logger.warn('unhandled main opcode %d (args: %r)', instr_type, args) |
57 else: | 58 else: |
58 callback(self, sub, instr_type, *args) | 59 callback(self, sub, instr_type, *args) |
59 | 60 |
60 self.processes[:] = (process for process in self.processes | 61 self.processes[:] = (process for process in self.processes |
61 if process.run_iteration()) | 62 if process.run_iteration()) |
63 | |
64 if not self._game.spellcard: | |
65 self.frame += 1 | |
62 | 66 |
63 | 67 |
64 def _pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, die_score): | 68 def _pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, die_score): |
65 if instr_type & 4: | 69 if instr_type & 4: |
66 if x < -990: #102h.exe@0x411820 | 70 if x < -990: #102h.exe@0x411820 |
699 def set_spellcard(self, unknown, number, name): | 703 def set_spellcard(self, unknown, number, name): |
700 #TODO: display it on the game. | 704 #TODO: display it on the game. |
701 #TODO: change the background. | 705 #TODO: change the background. |
702 #TODO: make the enemies more resistants (and find how). | 706 #TODO: make the enemies more resistants (and find how). |
703 self._game.change_bullets_into_star_items() | 707 self._game.change_bullets_into_star_items() |
708 self._game.spellcard = number | |
704 print("%d - %s" % (number+1, name)) | 709 print("%d - %s" % (number+1, name)) |
705 | 710 |
706 | 711 |
707 @instruction(94) | 712 @instruction(94) |
708 def end_spellcard(self): | 713 def end_spellcard(self): |
709 #TODO: return everything back to normal | 714 #TODO: return everything back to normal |
710 #TODO: give the spellcard bonus. | 715 #TODO: give the spellcard bonus. |
711 self._game.change_bullets_into_star_items() | 716 if self._game.spellcard: |
717 self._game.change_bullets_into_star_items() | |
718 self._game.spellcard = None | |
712 | 719 |
713 | 720 |
714 @instruction(95) | 721 @instruction(95) |
715 def pop_enemy(self, sub, x, y, z, life, bonus_dropped, die_score): | 722 def pop_enemy(self, sub, x, y, z, life, bonus_dropped, die_score): |
716 self._game.ecl_runner._pop_enemy(sub, 0, self._getval(x), self._getval(y), 0, life, bonus_dropped, die_score) | 723 self._game.ecl_runner._pop_enemy(sub, 0, self._getval(x), self._getval(y), 0, life, bonus_dropped, die_score) |