annotate src/th06/ecl_vm.rs @ 660:31fc0d881105

Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 10 Aug 2019 14:41:30 +0200
parents 53786d834444
children 598f3125cbac
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
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
3 use crate::th06::ecl::{Ecl, SubInstruction};
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
4 use crate::th06::enemy::Enemy;
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
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
9 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
10
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
11 /// 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
12 #[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
13 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
14 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
15 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
16 sub: u8,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
17 running: bool,
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
18 /// 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
19 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
20 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
21 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
22 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
23 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
24 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
25
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
26 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
27 /// 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
28 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
29 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
30 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
31 // 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
32 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
33 sub,
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 ..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
35 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
36 }
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
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 /// 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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 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
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
49 };
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
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 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
52 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
53 }
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 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
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 let rank = self.enemy.borrow().get_rank();
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 if call.rank_mask & (0x100 << rank) == 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
58 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
59 }
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
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 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
62 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
63 }
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 }
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 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
66 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
67
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
68 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
69 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
70 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
71 -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
72 -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
73 -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
74 -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
75 -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
76 -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
77 -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
78 -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
79 -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
80 -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
81 -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
82 -10012 => self.variables.2[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
83 -10013 => enemy.get_rank(),
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 -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
85 -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
86 -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
87 -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
88 -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
89 -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
90 -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
91 -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
92 -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
93 -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
94 -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
95 -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
96 _ => 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
97 }
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 }
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
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 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
101 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
102 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
103 -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
104 -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
105 -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
106 -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
107 -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
108 -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
109 -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
110 -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
111 -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
112 -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
113 -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
114 -10012.0 => self.variables.2[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
115 -10013.0 => enemy.get_rank() 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
116 -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
117 -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
118 -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
119 -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
120 -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
121 -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
122 -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
123 -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
124 -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
125 -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
126 -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
127 -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
128 _ => 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
129 }
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 }
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
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 fn set_i32(&mut self, var: i32, value: 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
133 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
134 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
135
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 fn set_f32(&mut self, var: f32, value: 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 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
138 }
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
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 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
141 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
142 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
143 }
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
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 fn run_instruction(&mut self, instruction: SubInstruction) {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
146 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
147 SubInstruction::Noop() => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
148 // really
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
149 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
150 // 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
151 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
152 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
153 enemy.removed = true;
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
154 }
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
155 // 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
156 SubInstruction::RelativeJump(frame, ip) => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
157 self.frame = frame;
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
158 // ip = ip + flag in th06
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
159 self.ip = ip;
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
160 // 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
161 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
162 // 3
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
163 // 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
164 //
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
165 // 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
166 // CMP dword ptr [0x9d4 + ECX],0x0
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
167 // JLE LAB_00407abb
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
168 // aka ECX = enemy pointer
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
169 // 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
170 // 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
171 SubInstruction::RelativeJumpEx(frame, ip, var_id) => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
172 // 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
173 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
174 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
175 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
176 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
177 }
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
178 // 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
179 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
180 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
181 }
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 // 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
183 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
184 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
185 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
186 // 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
187 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
188 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
189 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
190 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
191 // 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
192 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
193 SubInstruction::SetRandomIntMin(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
194 self.set_i32(var_id, (self.get_prng().borrow_mut().get_u32() % 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
195 }
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
196 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
197 // 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
198 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
199 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
200 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
201 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
202 // 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
203 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
204 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
205 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
206 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
207 // 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
208 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
209 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
210 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
211 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
212 };
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
213 // 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
214 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
215 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
216 // 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
217 /*
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 SubInstruction::StoreY(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
219 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
220 self.set_i32(var_id, enemy.pos.y);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
221 }
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
222 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
223 // 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
224 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
225 SubInstruction::StoreZ(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
226 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
227 self.set_i32(var_id, enemy.z);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
228 }
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
229 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
230 // 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
231 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
232 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
233 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
234 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
235 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
236 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
237 // 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
238 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
239 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
240 }
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 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
242 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
243 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
244 // 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
245 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
246 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
247 }
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 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
249 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
250 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
251 }
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 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
253 // 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
254 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
255 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
256 }
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
257 /*
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 SubInstruction::Divide(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
259 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
260 }
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 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
262 // 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
263 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
264 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
265 }
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
266 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
267 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
268 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
269 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
270 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
271 // 18
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
272 // 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
273 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
274 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
275 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
276 // 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
277 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
278 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
279 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
280 }
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
281 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
282 //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
283 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
284 //__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
285 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
286 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
287
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
288 // 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
289 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
290 // 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
291 // 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
292 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
293 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
294
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
295 // 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
296 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
297 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
298 let b = self.get_i32(b);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
299 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
300 self.comparison_reg = -1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
301 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
302 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
303 self.comparison_reg = 0;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
304 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
305 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
306 self.comparison_reg = 1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
307 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
308 }
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::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
310 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
311 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
312 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
313 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
314 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
315 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
316 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
317 }
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 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
319 self.comparison_reg = 1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
320 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
321 }
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
322 // 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
323 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
324 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
325 SubInstruction::RelativeJump(frame, ip);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
326 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
327 }
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
328 // 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
329 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
330 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
331 SubInstruction::RelativeJump(frame, ip);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
332 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
333 }
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
334 // 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
335 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
336 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
337 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
338 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
339 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
340 // 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
341 SubInstruction::RelativeJumpIfGreaterThan(frame, ip) => {
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
342 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
343 SubInstruction::RelativeJump(frame, ip);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
344 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
345 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
346 // 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
347 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
348 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
349 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
350 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
351 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
352 // 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
353 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
354 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
355 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
356 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
357 }
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
358 // 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
359 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
360 // 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
361 unimplemented!()
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
362 }
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
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
364 // 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
365 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
366 // 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
367 unimplemented!()
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
368 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
369 // 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
370 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
371 SubInstruction::CallIfSuperior(sub, param1, param2, 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
372 if self.get_i32(b) <= 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
373 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
374 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
375 }
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
376 */
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
377 // 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
378 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
379 SubInstruction::CallIfSuperiorOrEqual(sub, param1, param2, 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
380 if self.get_i32(b) <= 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
381 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
382 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
383 }
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 */
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
385 // 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
386 SubInstruction::CallIfEqual(sub, param1, param2, 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
387 if self.get_i32(b) == 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
388 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
389 }
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 }
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 // 40
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 SubInstruction::CallIfEqual(sub, param1, param2, 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 if self.get_i32(b) == 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
395 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
396 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
397 }
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
398 */
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
399 //41
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 /*
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::CallIfInferior(sub, param1, param2, 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
402 if 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
403 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
404 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
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 */
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 //42
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 /*
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::CallIfInferiorOrEqual(sub, param1, param2, 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
410 if 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
411 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
412 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
413 }
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
414 */
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 // 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
416 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
417 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
418 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
419 }
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
420 // 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
421 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
422 SubInstruction::SetPositionInterlacing(x, y, z) => {
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
423 //TODO: almost the same as setpos, except with 3 different values and sets the
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
424 //interlacing, should double check
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 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
426 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
427 }
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
428 */
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
429 // 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
430 SubInstruction::SetAngleAndSpeed(angle, 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
431 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
432 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
433 enemy.angle = self.get_f32(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
434 enemy.speed = self.get_f32(speed);
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
435 }
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
436 // 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
437 SubInstruction::SetRotationSpeed(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
438 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
439 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
440 enemy.rotation_speed = self.get_f32(speed);
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
441 }
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
442 // 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
443 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
444 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
445 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
446 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
447 }
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 // 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
449 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
450 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
451 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
452 enemy.acceleration = self.get_f32(acceleration);
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
453 }
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
454 // 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
455 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
456 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
457 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
458 enemy.angle = angle;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
459 }
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
460
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
461 // 83 -> star items >>> life items
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
462
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
463 _ => 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
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 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
466 }