Mercurial > touhou
annotate src/th06/ecl_vm.rs @ 661:598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 10 Aug 2019 21:04:54 +0200 |
parents | 31fc0d881105 |
children | 994f41154be8 |
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, |
661
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
17 /// XXX |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
18 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
|
19 /// 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
|
20 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
|
21 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
|
22 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
|
23 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
|
24 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
|
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 |
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 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
|
28 /// 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
|
29 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
|
30 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
|
31 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
|
32 // 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
|
33 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
|
34 sub, |
661
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
35 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
|
36 ..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
|
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 } |
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 |
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 /// 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 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
|
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 }; |
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 |
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 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
|
54 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
|
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 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
|
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 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
|
59 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
|
60 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
|
61 } |
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 |
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 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
|
64 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
|
65 } |
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 } |
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 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
|
68 } |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
69 |
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
|
70 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
|
71 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
|
72 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
|
73 -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
|
74 -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
|
75 -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
|
76 -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
|
77 -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
|
78 -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
|
79 -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
|
80 -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
|
81 -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
|
82 -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
|
83 -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
|
84 -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
|
85 -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
|
86 -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
|
87 -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
|
88 -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
|
89 -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
|
90 -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
|
91 -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
|
92 -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
|
93 -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
|
94 -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
|
95 -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
|
96 -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
|
97 -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
|
98 _ => 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
|
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 } |
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 |
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 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
|
103 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
|
104 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
|
105 -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
|
106 -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
|
107 -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
|
108 -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
|
109 -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
|
110 -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
|
111 -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
|
112 -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
|
113 -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
|
114 -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
|
115 -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
|
116 -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
|
117 -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
|
118 -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
|
119 -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
|
120 -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
|
121 -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
|
122 -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
|
123 -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
|
124 -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
|
125 -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
|
126 -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
|
127 -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
|
128 -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
|
129 -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
|
130 _ => 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
|
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 } |
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 |
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 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
|
135 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
|
136 } |
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 |
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 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
|
139 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
|
140 } |
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 |
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 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
|
143 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
|
144 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
|
145 } |
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 |
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 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
|
148 println!("Running instruction {:?}", instruction); |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
149 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
|
150 SubInstruction::Noop() => { |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
151 // really |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
152 } |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
153 // 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
|
154 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
|
155 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
|
156 enemy.removed = true; |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
157 } |
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
|
158 // 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
|
159 SubInstruction::RelativeJump(frame, ip) => { |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
160 self.frame = frame; |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
161 // ip = ip + flag in th06 |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
162 self.ip = ip; |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
163 // 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
|
164 } |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
165 // 3 |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
166 // 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
|
167 // |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
168 // 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
|
169 // CMP dword ptr [0x9d4 + ECX],0x0 |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
170 // JLE LAB_00407abb |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
171 // aka ECX = enemy pointer |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
172 // 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
|
173 // 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
|
174 SubInstruction::RelativeJumpEx(frame, ip, var_id) => { |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
175 // 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
|
176 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
|
177 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
|
178 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
|
179 } |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
180 } |
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
|
181 // 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
|
182 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
|
183 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
|
184 } |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
185 // 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
|
186 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
|
187 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
|
188 } |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
189 // 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
|
190 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
|
191 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
|
192 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
|
193 } |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
194 // 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
|
195 /* |
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 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
|
197 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
|
198 } |
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
|
199 */ |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
200 // 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
|
201 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
|
202 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
|
203 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
|
204 } |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
205 // 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
|
206 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
|
207 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
|
208 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
|
209 } |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
210 // 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
|
211 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
|
212 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
|
213 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
|
214 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
|
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 // 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
|
217 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
|
218 } |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
219 // 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
|
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 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
|
222 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
|
223 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
|
224 } |
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
|
225 */ |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
226 // 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
|
227 /* |
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::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
|
229 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
|
230 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
|
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 */ |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
233 // 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
|
234 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
|
235 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
|
236 } |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
237 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
|
238 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
|
239 } |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
240 // 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
|
241 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
|
242 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
|
243 } |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
244 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
|
245 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
|
246 } |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
247 // 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
|
248 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
|
249 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
|
250 } |
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
|
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 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
|
253 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
|
254 } |
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 */ |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
256 // 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
|
257 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
|
258 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
|
259 } |
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
|
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 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
|
262 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
|
263 } |
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 */ |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
265 // 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
|
266 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
|
267 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
|
268 } |
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 /* |
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 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
|
271 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
|
272 } |
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 */ |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
274 // 18 |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
275 // 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
|
276 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
|
277 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
|
278 } |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
279 // 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
|
280 /* |
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 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
|
282 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
|
283 } |
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 */ |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
285 //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
|
286 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
|
287 //__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
|
288 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
|
289 } |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
290 |
654
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
291 // 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
|
292 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
|
293 // 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
|
294 // 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
|
295 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
|
296 } |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
297 |
654
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
298 // 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
|
299 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
|
300 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
|
301 let b = self.get_i32(b); |
654
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
302 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 = -1; |
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 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
|
306 self.comparison_reg = 0; |
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 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
|
309 self.comparison_reg = 1; |
654
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
310 } |
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
311 } |
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
|
312 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
|
313 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
|
314 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
|
315 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 = -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
|
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 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
|
319 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
|
320 } |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
321 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
|
322 self.comparison_reg = 1; |
654
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
323 } |
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
324 } |
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
|
325 // 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
|
326 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
|
327 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
|
328 SubInstruction::RelativeJump(frame, ip); |
654
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
329 } |
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
330 } |
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
|
331 // 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
|
332 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
|
333 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
|
334 SubInstruction::RelativeJump(frame, ip); |
654
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
335 } |
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
336 } |
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 // 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
|
338 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
|
339 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
|
340 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
|
341 } |
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 } |
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 // 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
|
344 SubInstruction::RelativeJumpIfGreaterThan(frame, ip) => { |
654
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
345 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
|
346 SubInstruction::RelativeJump(frame, ip); |
654
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
347 } |
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
348 } |
ec7e888e88f3
Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
653
diff
changeset
|
349 // 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
|
350 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
|
351 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
|
352 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
|
353 } |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
354 } |
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
355 // 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
|
356 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
|
357 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
|
358 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
|
359 } |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
360 } |
655
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
361 // 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
|
362 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
|
363 // 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
|
364 unimplemented!() |
655
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
365 } |
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
|
366 |
655
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
367 // 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
|
368 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
|
369 // 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
|
370 unimplemented!() |
655
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
371 } |
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
372 // 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
|
373 /* |
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::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
|
375 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
|
376 SubInstruction::Call(sub, param1, param2); |
655
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
377 } |
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
378 } |
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
|
379 */ |
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 // 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
|
381 /* |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
382 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
|
383 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
|
384 SubInstruction::Call(sub, param1, param2); |
655
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
385 } |
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
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 */ |
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 // 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
|
389 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
|
390 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
|
391 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
|
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 } |
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 // 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
|
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 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
|
397 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
|
398 SubInstruction::Call(sub, param1, param2); |
655
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
399 } |
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
400 } |
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
|
401 */ |
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 //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
|
403 /* |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
404 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
|
405 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
|
406 SubInstruction::Call(sub, param1, param2); |
655
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
407 } |
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
408 } |
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
|
409 */ |
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 //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
|
411 /* |
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 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
|
413 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
|
414 SubInstruction::Call(sub, param1, param2); |
655
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
415 } |
6b4d2b405442
More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
654
diff
changeset
|
416 } |
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
|
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 // 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
|
419 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
|
420 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
|
421 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
|
422 } |
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
|
423 // 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
|
424 /* |
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::SetPositionInterlacing(x, y, z) => { |
659
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
diff
changeset
|
426 //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
|
427 //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
|
428 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
|
429 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
|
430 } |
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 */ |
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 // 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
|
433 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
|
434 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
|
435 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
|
436 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
|
437 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
|
438 enemy.angle = angle; |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
439 enemy.speed = speed; |
659
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
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 // 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
|
442 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
|
443 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
|
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; |
661
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
446 enemy.rotation_speed = rotation_speed; |
659
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
diff
changeset
|
447 } |
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 // 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
|
449 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
|
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.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
|
453 } |
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 // 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
|
455 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
|
456 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
|
457 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
|
458 enemy.acceleration = self.get_f32(acceleration); |
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 // 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
|
461 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
|
462 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
|
463 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
|
464 enemy.angle = angle; |
659
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
diff
changeset
|
465 } |
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
diff
changeset
|
466 |
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
diff
changeset
|
467 // 83 -> star items >>> life items |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
468 |
661
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
469 // 97 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
470 SubInstruction::SetAnim(index) => { |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
471 // TODO: check in ghidra! |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
472 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
|
473 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
|
474 } |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
475 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
476 // 100 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
477 SubInstruction::SetDeathAnim(index) => { |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
478 // TODO: check in ghidra! |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
479 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
|
480 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
|
481 } |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
482 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
483 // 103 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
484 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
|
485 // TODO: check in ghidra! |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
486 assert_eq!(depth, 32.); |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
487 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
|
488 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
|
489 } |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
490 |
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
|
491 _ => 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
|
492 } |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
493 } |
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 } |