annotate src/th06/ecl_vm.rs @ 688:1adecaddf442

ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 17 Aug 2019 13:50:54 +0200
parents aefe5b5f481e
children eecb8626f472
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
1 //! ECL runner.
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
2
665
965ecdbf0316 Make rank user-defined in eclrenderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 664
diff changeset
3 use crate::th06::ecl::{Ecl, SubInstruction};
686
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
4 use crate::th06::enemy::{Enemy, BulletAttributes};
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
5 use crate::util::prng::Prng;
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
6 use std::cell::RefCell;
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
7 use std::rc::Rc;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
8
686
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
9 macro_rules! gen_SetBulletAttributes {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
10 ($self:ident, $opcode:tt, $anim:ident, $sprite_index_offset:ident, $bullets_per_shot:ident,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
11 $number_of_shots:ident, $speed:ident, $speed2:ident, $launch_angle:ident, $angle:ident,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
12 $flags:ident) => {{
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
13 let sprite_index_offset = $self.get_i32($sprite_index_offset as i32) as i16;
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
14 let bullets_per_shot = $self.get_i32($bullets_per_shot) as i16;
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
15 let number_of_shots = $self.get_i32($number_of_shots) as i16;
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
16 let speed = $self.get_f32($speed);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
17 let speed2 = $self.get_f32($speed2);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
18 let launch_angle = $self.get_f32($launch_angle);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
19 let angle = $self.get_f32($angle);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
20
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
21 let mut enemy = $self.enemy.borrow_mut();
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
22 enemy.set_bullet_attributes($opcode, $anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
23 number_of_shots, speed, speed2, launch_angle, angle, $flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
24 }};
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
25 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
26
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
27 type Variables = ([i32; 4], [f32; 4], [i32; 4]);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
28
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
29 /// Interpreter for enemy scripts.
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
30 #[derive(Default)]
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
31 pub struct EclRunner {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
32 enemy: Rc<RefCell<Enemy>>,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
33 ecl: Option<Ecl>,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
34 sub: u8,
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
35 /// XXX
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
36 pub running: bool,
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
37 /// XXX
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
38 pub frame: i32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
39 ip: i32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
40 variables: Variables,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
41 comparison_reg: i8,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
42 stack: Vec<Variables>,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
43 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
44
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
45 impl EclRunner {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
46 /// Create a new ECL runner.
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
47 pub fn new(ecl: &Ecl, enemy: Rc<RefCell<Enemy>>, sub: u8) -> EclRunner {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
48 EclRunner {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
49 enemy,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
50 // XXX: no clone.
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
51 ecl: Some(ecl.clone()),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
52 sub,
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
53 running: true,
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
54 ..Default::default()
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
55 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
56 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
57
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
58 /// Advance the ECL of a single frame.
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
59 pub fn run_frame(&mut self) {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
60 while self.running {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
61 let ecl = self.ecl.clone().unwrap();
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
62 let sub = &ecl.subs[self.sub as usize];
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
63 let call = match sub.instructions.get(self.ip as usize) {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
64 Some(call) => call,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
65 None => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
66 self.running = false;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
67 break;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
68 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
69 };
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
70
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
71 if call.time > self.frame {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
72 break;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
73 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
74 self.ip += 1;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
75
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
76 let rank = self.enemy.borrow().get_rank();
664
f08e8e3c6196 Use bitflags for the rank, instead of an u16.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 663
diff changeset
77 if (call.rank_mask & rank).is_empty() {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
78 continue;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
79 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
80
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
81 if call.time == self.frame {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
82 self.run_instruction(call.instr.clone());
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
83 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
84 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
85 self.frame += 1;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
86 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
87
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
88 fn get_i32(&self, var: i32) -> i32 {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
89 let enemy = self.enemy.borrow();
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
90 match var {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
91 -10001 => self.variables.0[0],
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
92 -10002 => self.variables.0[1],
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
93 -10003 => self.variables.0[2],
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
94 -10004 => self.variables.0[3],
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
95 -10005 => self.variables.1[0] as i32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
96 -10006 => self.variables.1[1] as i32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
97 -10007 => self.variables.1[2] as i32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
98 -10008 => self.variables.1[3] as i32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
99 -10009 => self.variables.2[0],
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
100 -10010 => self.variables.2[1],
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
101 -10011 => self.variables.2[2],
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
102 -10012 => self.variables.2[3],
664
f08e8e3c6196 Use bitflags for the rank, instead of an u16.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 663
diff changeset
103 -10013 => enemy.get_rank().bits() as i32,
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
104 -10014 => enemy.get_difficulty(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
105 -10015 => enemy.pos.x as i32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
106 -10016 => enemy.pos.y as i32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
107 -10017 => enemy.z as i32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
108 -10018 => unimplemented!(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
109 -10019 => unimplemented!(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
110 -10020 => unreachable!(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
111 -10021 => unimplemented!(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
112 -10022 => enemy.frame as i32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
113 -10023 => unreachable!(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
114 -10024 => enemy.life as i32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
115 -10025 => unimplemented!(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
116 _ => var
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
117 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
118 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
119
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
120 fn get_f32(&self, var: f32) -> f32 {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
121 let enemy = self.enemy.borrow();
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
122 match var {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
123 -10001.0 => self.variables.0[0] as f32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
124 -10002.0 => self.variables.0[1] as f32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
125 -10003.0 => self.variables.0[2] as f32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
126 -10004.0 => self.variables.0[3] as f32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
127 -10005.0 => self.variables.1[0],
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
128 -10006.0 => self.variables.1[1],
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
129 -10007.0 => self.variables.1[2],
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
130 -10008.0 => self.variables.1[3],
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
131 -10009.0 => self.variables.2[0] as f32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
132 -10010.0 => self.variables.2[1] as f32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
133 -10011.0 => self.variables.2[2] as f32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
134 -10012.0 => self.variables.2[3] as f32,
664
f08e8e3c6196 Use bitflags for the rank, instead of an u16.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 663
diff changeset
135 -10013.0 => enemy.get_rank().bits() as f32,
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
136 -10014.0 => enemy.get_difficulty() as f32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
137 -10015.0 => enemy.pos.x,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
138 -10016.0 => enemy.pos.y,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
139 -10017.0 => enemy.z,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
140 -10018.0 => unimplemented!(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
141 -10019.0 => unimplemented!(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
142 -10020.0 => unreachable!(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
143 -10021.0 => unimplemented!(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
144 -10022.0 => enemy.frame as f32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
145 -10023.0 => unreachable!(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
146 -10024.0 => enemy.life as f32,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
147 -10025.0 => unimplemented!(),
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
148 _ => var
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
149 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
150 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
151
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
152 fn set_i32(&mut self, var: i32, value: i32) {
663
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
153 let mut enemy = self.enemy.borrow_mut();
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
154 match var {
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
155 -10001 => self.variables.0[0] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
156 -10002 => self.variables.0[1] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
157 -10003 => self.variables.0[2] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
158 -10004 => self.variables.0[3] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
159 -10005 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
160 -10006 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
161 -10007 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
162 -10008 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
163 -10009 => self.variables.2[0] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
164 -10010 => self.variables.2[1] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
165 -10011 => self.variables.2[2] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
166 -10012 => self.variables.2[3] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
167 -10013 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
168 -10014 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
169 -10015 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
170 -10016 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
171 -10017 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
172 -10018 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
173 -10019 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
174 -10020 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
175 -10021 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
176 -10022 => enemy.frame = value as u32,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
177 -10023 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
178 -10024 => enemy.life = value as u32,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
179 -10025 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
180 _ => panic!("Unknown variable {}", var)
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
181 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
182 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
183
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
184 fn set_f32(&mut self, var: f32, value: f32) {
663
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
185 let mut enemy = self.enemy.borrow_mut();
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
186 match var {
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
187 -10001.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
188 -10002.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
189 -10003.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
190 -10004.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
191 -10005.0 => self.variables.1[0] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
192 -10006.0 => self.variables.1[1] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
193 -10007.0 => self.variables.1[2] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
194 -10008.0 => self.variables.1[3] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
195 -10009.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
196 -10010.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
197 -10011.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
198 -10012.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
199 -10013.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
200 -10014.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
201 -10015.0 => enemy.pos.x = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
202 -10016.0 => enemy.pos.y = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
203 -10017.0 => enemy.z = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
204 -10018.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
205 -10019.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
206 -10020.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
207 -10021.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
208 -10022.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
209 -10023.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
210 -10024.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
211 -10025.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
212 _ => panic!("Unknown variable {}", var)
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
213 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
214 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
215
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
216 fn get_prng(&mut self) -> Rc<RefCell<Prng>> {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
217 let enemy = self.enemy.borrow();
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
218 enemy.prng.upgrade().unwrap()
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
219 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
220
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
221 fn run_instruction(&mut self, instruction: SubInstruction) {
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
222 println!("Running instruction {:?}", instruction);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
223 match instruction {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
224 SubInstruction::Noop() => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
225 // really
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
226 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
227 // 1
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
228 SubInstruction::Destroy(_unused) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
229 let mut enemy = self.enemy.borrow_mut();
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
230 enemy.removed = true;
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
231 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
232 // 2
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
233 SubInstruction::RelativeJump(frame, ip) => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
234 self.frame = frame;
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
235 // ip = ip + flag in th06
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
236 self.ip = ip;
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
237 // we jump back to the main of the interpreter
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
238 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
239 // 3
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
240 // GHIDRA SAYS THERE IS A COMPARISON_REG BUFFER BUT THERE IS NOT!!!
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
241 //
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
242 // MOV ECX,dword ptr [EBP + 0x8] jumptable 00407544 case 31
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
243 // CMP dword ptr [0x9d4 + ECX],0x0
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
244 // JLE LAB_00407abb
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
245 // aka ECX = enemy pointer
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
246 // ECX->9d4 (aka enemy_pointer_copy->comparison_reg) == 0
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
247 // only the pointer is copied, not the value, thus we are safe
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
248 SubInstruction::RelativeJumpEx(frame, ip, var_id) => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
249 // TODO: counter_value is a field of "enemy" in th06, to check
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
250 let counter_value = self.get_i32(var_id) - 1;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
251 if counter_value > 0 {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
252 SubInstruction::RelativeJump(frame, ip);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
253 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
254 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
255 // 4
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
256 SubInstruction::SetInt(var_id, value) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
257 self.set_i32(var_id, value);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
258 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
259 // 5
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
260 SubInstruction::SetFloat(var_id, value) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
261 self.set_f32(var_id as f32, value);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
262 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
263 // 6
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
264 SubInstruction::SetRandomInt(var_id, maxval) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
265 let random = self.get_prng().borrow_mut().get_u32() as i32;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
266 self.set_i32(var_id, random % self.get_i32(maxval));
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
267 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
268 // 7
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
269 SubInstruction::SetRandomIntMin(var_id, maxval, minval) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
270 let random = self.get_prng().borrow_mut().get_u32() as i32;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
271 self.set_i32(var_id, (random % self.get_i32(maxval)) + self.get_i32(minval));
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
272 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
273 // 8
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
274 SubInstruction::SetRandomFloat(var_id, maxval) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
275 let random = self.get_prng().borrow_mut().get_f64() as f32;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
276 self.set_f32(var_id as f32, self.get_f32(maxval) * random)
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
277 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
278 // 9
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
279 SubInstruction::SetRandomFloatMin(var_id, maxval, minval) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
280 let random = self.get_prng().borrow_mut().get_f64() as f32;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
281 self.set_f32(var_id as f32, self.get_f32(maxval) * random + self.get_f32(minval))
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
282 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
283 // 10
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
284 SubInstruction::StoreX(var_id) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
285 let x = {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
286 let enemy = self.enemy.borrow();
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
287 enemy.pos.x
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
288 };
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
289 // TODO: is this really an i32?
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
290 self.set_i32(var_id, x as i32);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
291 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
292 // 11
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
293 SubInstruction::StoreY(var_id) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
294 let y = {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
295 let enemy = self.enemy.borrow();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
296 enemy.pos.y
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
297 };
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
298 self.set_i32(var_id, y as i32);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
299 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
300 // 12
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
301 SubInstruction::StoreZ(var_id) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
302 let z = {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
303 let enemy = self.enemy.borrow();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
304 enemy.z
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
305 };
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
306 self.set_i32(var_id, z as i32);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
307 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
308 // 13(int), 20(float), same impl in th06
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
309 SubInstruction::AddInt(var_id, a, b) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
310 self.set_i32(var_id, self.get_i32(a) + self.get_i32(b));
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
311 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
312 SubInstruction::AddFloat(var_id, a, b) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
313 self.set_f32(var_id as f32, self.get_f32(a) + self.get_f32(b));
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
314 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
315 // 14(int), 21(float), same impl in th06
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
316 SubInstruction::SubstractInt(var_id, a, b) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
317 self.set_i32(var_id, self.get_i32(a) - self.get_i32(b));
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
318 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
319 SubInstruction::SubstractFloat(var_id, a, b) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
320 self.set_f32(var_id as f32, self.get_f32(a) - self.get_f32(b));
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
321 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
322 // 15(int), 22(unused)
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
323 SubInstruction::MultiplyInt(var_id, a, b) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
324 self.set_i32(var_id, self.get_i32(a) * self.get_i32(b));
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
325 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
326 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
327 SubInstruction::MultiplyFloat(var_id, a, b) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
328 self.set_f32(var_id as f32, self.get_f32(a) * self.get_f32(b));
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
329 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
330 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
331 // 16(int), 23(unused)
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
332 SubInstruction::DivideInt(var_id, a, b) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
333 self.set_i32(var_id, self.get_i32(a) / self.get_i32(b));
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
334 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
335
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
336 SubInstruction::DivideFloat(var_id, a, b) => {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
337 self.set_f32(var_id as f32, self.get_f32(a) / self.get_f32(b));
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
338 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
339
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
340 // 17(int) 24(unused)
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
341 SubInstruction::ModuloInt(var_id, a, b) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
342 self.set_i32(var_id, self.get_i32(a) % self.get_i32(b));
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
343 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
344
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
345 SubInstruction::ModuloFloat(var_id, a, b) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
346 self.set_f32(var_id as f32, self.get_f32(a) % self.get_f32(b));
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
347 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
348
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
349 // 18
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
350 // setval used by pytouhou, but not in game(???)
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
351 SubInstruction::Increment(var_id) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
352 self.set_i32(var_id, self.get_i32(var_id) + 1);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
353 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
354
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
355 // 19
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
356 SubInstruction::Decrement(var_id) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
357 self.set_i32(var_id, self.get_i32(var_id) - 1);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
358 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
359
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
360 //25
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
361 SubInstruction::GetDirection(var_id, x1, y1, x2, y2) => {
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
362 //__ctrandisp2 in ghidra, let's assume from pytouhou it's atan2
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
363 self.set_f32(var_id as f32, (self.get_f32(y2) - self.get_f32(y1)).atan2(self.get_f32(x2) - self.get_f32(x1)));
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
364 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
365
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
366 // 26
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
367 SubInstruction::FloatToUnitCircle(var_id) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
368 // TODO: atan2(var_id, ??) is used by th06, maybe ?? is pi?
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
369 // we suck at trigonometry so let's use pytouhou for now
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
370 self.set_f32(var_id as f32, (self.get_f32(var_id as f32) + std::f32::consts::PI) % (2. * std::f32::consts::PI) - std::f32::consts::PI);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
371 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
372
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
373 // 27(int), 28(float)
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
374 SubInstruction::CompareInts(a, b) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
375 let a = self.get_i32(a);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
376 let b = self.get_i32(b);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
377 if a < b {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
378 self.comparison_reg = -1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
379 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
380 else if a == b {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
381 self.comparison_reg = 0;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
382 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
383 else {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
384 self.comparison_reg = 1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
385 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
386 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
387 SubInstruction::CompareFloats(a, b) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
388 let a = self.get_f32(a);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
389 let b = self.get_f32(b);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
390 if a < b {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
391 self.comparison_reg = -1;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
392 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
393 else if a == b {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
394 self.comparison_reg = 0;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
395 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
396 else {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
397 self.comparison_reg = 1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
398 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
399 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
400 // 29
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
401 SubInstruction::RelativeJumpIfLowerThan(frame, ip) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
402 if self.comparison_reg == -1 {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
403 SubInstruction::RelativeJump(frame, ip);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
404 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
405 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
406 // 30
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
407 SubInstruction::RelativeJumpIfLowerOrEqual(frame, ip) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
408 if self.comparison_reg != 1 {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
409 SubInstruction::RelativeJump(frame, ip);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
410 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
411 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
412 // 31
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
413 SubInstruction::RelativeJumpIfEqual(frame, ip) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
414 if self.comparison_reg == 0 {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
415 SubInstruction::RelativeJump(frame, ip);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
416 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
417 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
418 // 32
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
419 SubInstruction::RelativeJumpIfGreaterThan(frame, ip) => {
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
420 if self.comparison_reg == 1 {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
421 SubInstruction::RelativeJump(frame, ip);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
422 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
423 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
424 // 33
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
425 SubInstruction::RelativeJumpIfGreaterOrEqual(frame, ip) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
426 if self.comparison_reg != -1 {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
427 SubInstruction::RelativeJump(frame, ip);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
428 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
429 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
430 // 34
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
431 SubInstruction::RelativeJumpIfNotEqual(frame, ip) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
432 if self.comparison_reg != 0 {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
433 SubInstruction::RelativeJump(frame, ip);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
434 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
435 }
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
436 // 35
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
437 SubInstruction::Call(sub, param1, param2) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
438 // does insane stuff with the stack, not implemented
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
439 unimplemented!()
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
440 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
441
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
442 // 36
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
443 SubInstruction::Return() => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
444 // does insane stuff with the stack, not implemented
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
445 unimplemented!()
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
446 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
447 // 37
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
448 SubInstruction::CallIfSuperior(sub, param1, param2, a, b) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
449 if self.get_i32(a) < self.get_i32(b) {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
450 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
451 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
452 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
453 // 38
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
454 SubInstruction::CallIfSuperiorOrEqual(sub, param1, param2, a, b) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
455 if self.get_i32(a) <= self.get_i32(b) {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
456 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
457 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
458 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
459 // 39
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
460 SubInstruction::CallIfEqual(sub, param1, param2, a, b) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
461 if self.get_i32(a) == self.get_i32(b) {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
462 SubInstruction::Call(sub, param1, param2);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
463 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
464 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
465 // 40
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
466 SubInstruction::CallIfInferior(sub, param1, param2, a, b) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
467 if self.get_i32(b) < self.get_i32(a) {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
468 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
469 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
470 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
471
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
472 // 41
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
473 SubInstruction::CallIfInferiorOrEqual(sub, param1, param2, a, b) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
474 if self.get_i32(b) <= self.get_i32(a) {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
475 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
476 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
477 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
478 //42
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
479 SubInstruction::CallIfNotEqual(sub, param1, param2, a, b) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
480 if self.get_i32(a) != self.get_i32(b) {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
481 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
482 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
483 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
484
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
485 // 43
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
486 SubInstruction::SetPosition(x, y, z) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
487 let mut enemy = self.enemy.borrow_mut();
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
488 enemy.set_pos(self.get_f32(x), self.get_f32(y), self.get_f32(z));
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
489 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
490 // 44
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
491 /*
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
492 SubInstruction::SetAngularSpeed(x, y, z) => {
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
493 // same as above, except for angular speed
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
494 let mut enemy = self.enemy.borrow_mut();
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
495 enemy.set_angular_speed(self.get_f32(x), self.get_f32(y), self.get_f32(z));
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
496 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
497 */
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
498 // 45
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
499 SubInstruction::SetAngleAndSpeed(angle, speed) => {
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
500 let angle = self.get_f32(angle);
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
501 let speed = self.get_f32(speed);
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
502 let mut enemy = self.enemy.borrow_mut();
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
503 enemy.update_mode = 0;
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
504 enemy.angle = angle;
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
505 enemy.speed = speed;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
506 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
507 // 46
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
508 SubInstruction::SetRotationSpeed(speed) => {
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
509 let rotation_speed = self.get_f32(speed);
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
510 let mut enemy = self.enemy.borrow_mut();
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
511 enemy.update_mode = 0;
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
512 enemy.rotation_speed = rotation_speed;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
513 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
514 // 47
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
515 SubInstruction::SetSpeed(speed) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
516 let mut enemy = self.enemy.borrow_mut();
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
517 enemy.update_mode = 0;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
518 enemy.speed = self.get_f32(speed);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
519 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
520 // 48
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
521 SubInstruction::SetAcceleration(acceleration) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
522 let mut enemy = self.enemy.borrow_mut();
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
523 enemy.update_mode = 0;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
524 enemy.acceleration = self.get_f32(acceleration);
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
525 }
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
526 // 49
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
527 SubInstruction::SetRandomAngle(min_angle, max_angle) => {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
528 let angle = self.get_prng().borrow_mut().get_f64() as f32 * (max_angle - min_angle) + min_angle;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
529 let mut enemy = self.enemy.borrow_mut();
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
530 enemy.angle = angle;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
531 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
532 // 51
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
533 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
534 SubInstruction::TargetPlayer(angle, speed) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
535 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
536 let player = enemy.select_player();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
537 enemy.update_mode = 0;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
538 enemy.speed = speed;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
539 enemy.angle = enemy.get_angle(player) + angle;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
540
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
541 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
542 */
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
543 // 52 to 64 are different interlacing fields
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
544
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
545 // 65
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
546 // to note: in game a flag is set to enable the screenbox and is set by 66 to disable
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
547 // it on top of setting our values. But we have a good engine and can detect if that's
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
548 // changed without setting a flag :)
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
549 SubInstruction::SetScreenBox(xmin, ymin, xmax, ymax) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
550 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
551 enemy.screen_box = Some((xmin, ymin, xmax, ymax));
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
552 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
553 // 66
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
554 SubInstruction::ClearScreenBox() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
555 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
556 enemy.screen_box = None;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
557 }
686
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
558
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
559 // 67 to 75 are set bullet attributes and it seems a pain to reverse rn
686
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
560 SubInstruction::SetBulletAttributes1(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
561 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
562 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
563 gen_SetBulletAttributes!(self, 67, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
564 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
565 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
566 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
567 SubInstruction::SetBulletAttributes2(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
568 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
569 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
570 gen_SetBulletAttributes!(self, 68, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
571 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
572 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
573 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
574 SubInstruction::SetBulletAttributes3(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
575 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
576 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
577 gen_SetBulletAttributes!(self, 69, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
578 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
579 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
580 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
581 SubInstruction::SetBulletAttributes4(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
582 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
583 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
584 gen_SetBulletAttributes!(self, 70, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
585 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
586 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
587 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
588 SubInstruction::SetBulletAttributes5(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
589 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
590 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
591 gen_SetBulletAttributes!(self, 71, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
592 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
593 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
594 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
595 SubInstruction::SetBulletAttributes6(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
596 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
597 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
598 gen_SetBulletAttributes!(self, 74, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
599 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
600 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
601 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
602 SubInstruction::SetBulletAttributes7(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
603 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
604 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
605 gen_SetBulletAttributes!(self, 75, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
606 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
607 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
608 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
609
688
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
610 // 76
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
611 SubInstruction::SetBulletInterval(interval) => {
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
612 let mut enemy = self.enemy.borrow_mut();
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
613 enemy.set_bullet_launch_interval(0, interval);
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
614 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
615
688
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
616 // 77
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
617 SubInstruction::SetBulletIntervalEx(interval) => {
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
618 let rand_start = self.get_prng().borrow_mut().get_u32();
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
619
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
620 let mut enemy = self.enemy.borrow_mut();
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
621 enemy.set_bullet_launch_interval(rand_start, interval);
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
622 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
623
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
624 // 78-79 are more interpolation flags
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
625 // 78
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
626 SubInstruction::DelayAttack() => {
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
627 let mut enemy = self.enemy.borrow_mut();
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
628 enemy.delay_attack = true;
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
629 }
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
630 // 79
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
631 SubInstruction::NoDelayAttack() => {
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
632 let mut enemy = self.enemy.borrow_mut();
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
633 enemy.delay_attack = false;
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
634 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
635 // 80
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
636 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
637 SubInstruction::NoClue() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
638 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
639 //bullet_pos = launch offset
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
640 (enemy->bullet_attributes).bullets_per_shot = enemy.pos.x + enemy->bullet_pos.pos.x;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
641 (enemy->bullet_attributes).number_of_shots = enemy.pos.pos.y + enemy.bullet_pos.pos.y;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
642 (enemy->bullet_attributes).speed = enemy.z + bullet_pos.z;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
643 enemy.fire(bullet_attributes=bullet_attributes)
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
644 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
645 */
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
646 // 81
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
647 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
648 SubInstruction::SetBulletLaunchOffset(x, y, z) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
649 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
650 enemy.bullet_launch_offset = (self._getval(x), self._getval(y), self._getval(z));
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
651 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
652 */
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
653 // 82
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
654 // TODO: correct but how to implement that in a rusty way?
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
655 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
656 SubInstruction::SetExtendedBulletAttributes(x, y, z) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
657 let mut enemy = self.enemy.borrow_mut();
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
658
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
659 // self._enemy.extended_bullet_attributes = tuple(self._getval(attr) for attr in attributes)
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
660 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
661 */
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
662 // 83
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
663 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
664 SubInstruction::ChangeBulletsIntoStarBonus() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
665 let mut game = self.game.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
666 game.change_bullets_into_star_items();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
667 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
668 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
669 // 84
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
670 // WARNING: dead code. If the parameter is < 0 it unsets a bullet_flag, otherwise it
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
671 // sets it, never using the parameter ever
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
672 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
673 SubInstruction::UNK_ins84() => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
674 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
675 enemy.bullet_flag_something
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
676 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
677 */
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
678
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
679 // 85-86 ire newlaser functions
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
680
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
681 // 87
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
682 SubInstruction::SetUpcomingLaserId(laser_id) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
683 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
684 enemy.current_laser_id = laser_id;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
685 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
686
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
687 // 88
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
688 /*
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
689 SubInstruction::AlterLaserAngle(laser_id, delta) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
690 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
691 if enemy.laser_by_id.contains_key(&laser_id) {
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
692 let mut laser = enemy.laser_by_id.get(&laser_id);
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
693 laser.angle += self.get_f32(delta);
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
694 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
695 }
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
696 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
697
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
698 // 89
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
699 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
700 SubInstruction::AlterLaserAnglePlayer(laser_id, delta) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
701 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
702 if enemy.laser_by_id.contains_key(&laser_id) {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
703 let mut laser = enemy.laser_by_id.get(laser_id);
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
704 let player = enemy.select_player();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
705 laser.angle = enemy.get_angle(player) + angle;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
706 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
707 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
708 */
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
709
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
710 // 90
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
711 /*
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
712 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
713 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
714 if enemy.laser_by_id.contains_key(&laser_id) {
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
715 let mut laser = enemy.laser_by_id.get(&laser_id);
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
716 laser.set_base_pos(enemy.pos.x + ox, enemy.pos.y + oy, enemy.z + oz)
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
717 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
718 }
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
719 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
720 // 91
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
721 // wat
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
722 SubInstruction::LaserSetCompare(laser_id) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
723 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
724 // in game it checks if either the laser exists OR if one of its member is set to 0
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
725 // which, uhhhh, we are not going to reimplement for obvious reasons
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
726 // the correct implementation would be: if this laser does not exist have a
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
727 // 1/100000 chance to continue, otherwise crash
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
728 if enemy.laser_by_id.contains_key(&laser_id) {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
729 // let's assume we gud
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
730 self.comparison_reg = 1;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
731 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
732 else{
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
733 self.comparison_reg = 0;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
734 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
735 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
736
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
737 // 92
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
738 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
739 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
740 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
741 if enemy.laser_by_id.contains_key(&laser_id) {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
742 let mut laser = enemy.laser_by_id.get(laser_id);
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
743 laser.cancel();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
744 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
745 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
746 */
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
747 // 93
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
748 // TODO: actually implement that hell
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
749 SubInstruction::SetSpellcard(face, number, name) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
750 unimplemented!("spellcard start");
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
751
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
752 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
753 // 94
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
754 SubInstruction::EndSpellcard() => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
755 unimplemented!("spellcard end");
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
756
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
757 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
758
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
759 // 95
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
760 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
761 SubInstruction::PopEnemy(sub, x, y, z, life, bonus_dropped, die_score) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
762 self._pop_enemy(sub, 0, self.get_f32(x),
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
763 self.get_f32(y),
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
764 self.get_f32(z),
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
765 life, bonus_dropped, die_score)
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
766
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
767 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
768 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
769
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
770
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
771 // 96
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
772 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
773 SubInstruction::KillEnemies() => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
774 let mut game = self.game.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
775 game.kill_enemies();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
776 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
777 */
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
778
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
779
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
780
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
781 // 97
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
782 SubInstruction::SetAnim(index) => {
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
783 // seems correct, game internally gets base_addr =(iVar13 + 0x1c934), pointer_addr = iVar14 * 4
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
784 let mut enemy = self.enemy.borrow_mut();
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
785 enemy.set_anim(index as u8);
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
786 }
666
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
787 // 98
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
788 SubInstruction::SetMultipleAnims(default, end_left, end_right, left, right, _unused) => {
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
789 // _unused was supposed to set movement_dependant_sprites, but internally the game
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
790 // assigns it 0xff
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
791 // TODO: THIS DOES NOT CALL set_anim. this only assigns all parameters to their
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
792 // internal struct. To check if the anims are set somewhere else
666
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
793 let mut enemy = self.enemy.borrow_mut();
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
794 enemy.movement_dependant_sprites = if left == -1 {
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
795 None
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
796 } else {
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
797 enemy.set_anim(default as u8);
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
798 Some((end_left as u8, end_right as u8, left as u8, right as u8))
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
799 };
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
800 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
801 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
802 // 99
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
803 SubInstruction::SetAuxAnims(number, script) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
804 assert!(7 < number);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
805 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
806 enemy.set_aux_anm(number, script)
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
807 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
808 */
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
809
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
810 // 100
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
811 SubInstruction::SetDeathAnim(index) => {
673
81ad01910f4b ecl_vm: instr 100 fix.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 672
diff changeset
812 // TODO: takes 3 parameters in game as u8 unlike our single u32.
81ad01910f4b ecl_vm: instr 100 fix.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 672
diff changeset
813 // To reverse!
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
814 let mut enemy = self.enemy.borrow_mut();
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
815 enemy.death_anim = index;
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
816 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
817 // 101
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
818 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
819 SubInstruction::SetBossMode(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
820 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
821 if value < 0 {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
822 enemy.set_boss(false);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
823 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
824 else {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
825 // the boss pointer is written somewhere in memory and overwrote by a 0 when
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
826 // the boss mode is false, might want to look into that
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
827 enemy.set_boss(true);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
828 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
829 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
830 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
831
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
832 // 102
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
833 // TODO: title says it all
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
834 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
835 SubInstruction::ParticlesVoodooMagic(unk1, unk2, unk3, unk4, unk5) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
836 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
837 */
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
838
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
839 // 103
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
840 SubInstruction::SetHitbox(width, height, depth) => {
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
841 let mut enemy = self.enemy.borrow_mut();
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
842 enemy.set_hitbox(width, height);
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
843 }
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
844
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
845 // 104
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
846 SubInstruction::SetCollidable(collidable) => {
681
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
847 // TODO: me and my siblings(105, 107, 117) are implemented as a single variable in the touhou 6
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
848 // original engine. While our behaviour seems correct we might want to implement
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
849 // that as a single variable
681
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
850 // TODO[2]: THE BITFLAG MIGHT BE INCORRECT FOR OTHER SIBLING INSTRUCTIONS, the
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
851 // behavior was DEFINITELY incorrect in pytouhou for SetTouchable at the very least
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
852 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
853 enemy.collidable = (collidable&1) != 0;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
854 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
855
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
856 // 105
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
857 SubInstruction::SetDamageable(damageable) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
858 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
859 enemy.damageable = (damageable&1) != 0;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
860 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
861
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
862 // 106
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
863 /*
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
864 SubInstruction::PlaySound(index) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
865 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
866 enemy.play_sound(index);
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
867 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
868 */
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
869
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
870 // 107
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
871 SubInstruction::SetDeathFlags(death_flags) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
872 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
873 enemy.death_flags = death_flags;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
874 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
875 // 108
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
876 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
877 SubInstruction::SetDeathCallback(sub) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
878 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
879 enemy.death_callback.enable(self.switch_to_sub, (sub,));
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
880 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
881 */
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
882
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
883 // 109
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
884 SubInstruction::MemoryWriteInt(value, index) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
885 unimplemented!("not again that damn foe corrupted my ret\\x41\\x41\\x41\\x41");
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
886 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
887
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
888 // 110
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
889 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
890 SubInstruction::KillEnemy(enemy) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
891 let mut game = self.game.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
892 game.kill_enemy(enemy);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
893 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
894 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
895
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
896 // 111
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
897 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
898 SubInstruction::SetLife(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
899 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
900 let mut game = self.game.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
901 enemy.life = value;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
902 game.interface.set_boss_life();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
903 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
904 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
905 // 112
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
906 SubInstruction::SetElapsedTime(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
907 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
908 enemy.frame = value as u32;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
909 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
910 // 113
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
911 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
912 SubInstruction::SetLowLifeTrigger(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
913 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
914 let mut game = self.game.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
915 enemy.low_life_trigger = value;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
916 game.interface.set_spell_life();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
917 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
918 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
919 // 114
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
920 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
921 SubInstruction::SetLowLifeCallback(sub) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
922 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
923 enemy.low_life_callback.enable(self.switch_to_sub, (sub,));
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
924 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
925 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
926 // 115
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
927 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
928 SubInstruction::SetTimeout(timeout) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
929 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
930 enemy.frame = value;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
931 enemy.timeout = timeout;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
932 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
933 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
934 // 116
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
935 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
936 SubInstruction::SetTimeoutCallback(sub) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
937 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
938 enemy.timeout_callback.enable(self.switch_to_sub, (sub,));
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
939 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
940 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
941
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
942
681
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
943 // 117
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
944 SubInstruction::SetTouchable(touchable) => {
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
945 let mut enemy = self.enemy.borrow_mut();
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
946 enemy.touchable = touchable != 0;
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
947 }
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
948
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
949 // 121
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
950 // Here lies the Di Sword of sadness
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
951 SubInstruction::CallSpecialFunction(function, arg) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
952 unimplemented!("spellcards are a bitch and a half");
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
953 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
954
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
955 _ => unimplemented!("{:?}", instruction)
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
956 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
957 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
958 }