Mercurial > touhou
changeset 64:d469012368b3
Implement conditional jumps.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 24 Aug 2011 22:44:40 -0700 |
parents | 8527fe640844 |
children | 0efec109f798 |
files | pytouhou/formats/ecl.py pytouhou/game/eclrunner.py |
diffstat | 2 files changed, 35 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/pytouhou/formats/ecl.py +++ b/pytouhou/formats/ecl.py @@ -44,12 +44,12 @@ class ECL(object): 26: ('i', None), 27: ('ii', 'compare_ints'), 28: ('ff', 'compare_floats'), - 29: ('ii', 'relative_jump?'), - 30: ('ii', 'relative_jump?'), + 29: ('ii', 'relative_jump_if_lower_than'), + 30: ('ii', 'relative_jump_if_lower_or_equal'), 31: ('ii', 'relative_jump_if_equal'), - 32: ('ii', 'relative_jump?'), - 33: ('ii', 'relative_jump?'), - 34: ('ii', 'relative_jump?'), + 32: ('ii', 'relative_jump_if_greater_than'), + 33: ('ii', 'relative_jump_if_greater_or_equal'), + 34: ('ii', 'relative_jump_if_not_equal'), 35: ('iif', 'call'), 36: ('', 'return?'), 39: ('iifii', 'call_if_equal'),
--- a/pytouhou/game/eclrunner.py +++ b/pytouhou/game/eclrunner.py @@ -288,12 +288,42 @@ class ECLRunner(object): self.comparison_reg = 1 + @instruction(29) + def relative_jump_if_lower_than(self, frame, instruction_pointer): + if self.comparison_reg == -1: + self.relative_jump(frame, instruction_pointer) + + + @instruction(30) + def relative_jump_if_lower_or_equal(self, frame, instruction_pointer): + if self.comparison_reg != 1: + self.relative_jump(frame, instruction_pointer) + + @instruction(31) def relative_jump_if_equal(self, frame, instruction_pointer): if self.comparison_reg == 0: self.relative_jump(frame, instruction_pointer) + @instruction(32) + def relative_jump_if_greater_than(self, frame, instruction_pointer): + if self.comparison_reg == 1: + self.relative_jump(frame, instruction_pointer) + + + @instruction(33) + def relative_jump_if_greater_or_equal(self, frame, instruction_pointer): + if self.comparison_reg != -1: + self.relative_jump(frame, instruction_pointer) + + + @instruction(34) + def relative_jump_if_not_equal(self, frame, instruction_pointer): + if self.comparison_reg != 0: + self.relative_jump(frame, instruction_pointer) + + @instruction(35) def call(self, sub, param1, param2): self.stack.append((self.sub, self.frame, self.instruction_pointer,