annotate src/th06/ecl_vm.rs @ 683:8c50a7b19425

ecl_vm: more work
author Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
date Fri, 16 Aug 2019 23:45:28 +0200
parents d6cc9086058c
children c8bb28961d31
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
1 //! ECL runner.
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
2
665
965ecdbf0316 Make rank user-defined in eclrenderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 664
diff changeset
3 use crate::th06::ecl::{Ecl, SubInstruction};
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
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();
664
f08e8e3c6196 Use bitflags for the rank, instead of an u16.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 663
diff changeset
59 if (call.rank_mask & rank).is_empty() {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
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],
664
f08e8e3c6196 Use bitflags for the rank, instead of an u16.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 663
diff changeset
85 -10013 => enemy.get_rank().bits() as i32,
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
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,
664
f08e8e3c6196 Use bitflags for the rank, instead of an u16.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 663
diff changeset
117 -10013.0 => enemy.get_rank().bits() as f32,
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
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) {
663
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
135 let mut enemy = self.enemy.borrow_mut();
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
136 match var {
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
137 -10001 => self.variables.0[0] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
138 -10002 => self.variables.0[1] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
139 -10003 => self.variables.0[2] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
140 -10004 => self.variables.0[3] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
141 -10005 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
142 -10006 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
143 -10007 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
144 -10008 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
145 -10009 => self.variables.2[0] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
146 -10010 => self.variables.2[1] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
147 -10011 => self.variables.2[2] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
148 -10012 => self.variables.2[3] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
149 -10013 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
150 -10014 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
151 -10015 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
152 -10016 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
153 -10017 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
154 -10018 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
155 -10019 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
156 -10020 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
157 -10021 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
158 -10022 => enemy.frame = value as u32,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
159 -10023 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
160 -10024 => enemy.life = value as u32,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
161 -10025 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
162 _ => panic!("Unknown variable {}", var)
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
163 }
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
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
166 fn set_f32(&mut self, var: f32, value: f32) {
663
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
167 let mut enemy = self.enemy.borrow_mut();
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
168 match var {
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
169 -10001.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
170 -10002.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
171 -10003.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
172 -10004.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
173 -10005.0 => self.variables.1[0] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
174 -10006.0 => self.variables.1[1] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
175 -10007.0 => self.variables.1[2] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
176 -10008.0 => self.variables.1[3] = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
177 -10009.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
178 -10010.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
179 -10011.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
180 -10012.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
181 -10013.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
182 -10014.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
183 -10015.0 => enemy.pos.x = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
184 -10016.0 => enemy.pos.y = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
185 -10017.0 => enemy.z = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
186 -10018.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
187 -10019.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
188 -10020.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
189 -10021.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
190 -10022.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
191 -10023.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
192 -10024.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
193 -10025.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
194 _ => panic!("Unknown variable {}", var)
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
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 }
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
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 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
199 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
200 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
201 }
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
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 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
204 println!("Running instruction {:?}", instruction);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
205 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
206 SubInstruction::Noop() => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
207 // really
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
208 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
209 // 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
210 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
211 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
212 enemy.removed = true;
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
213 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
214 // 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
215 SubInstruction::RelativeJump(frame, ip) => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
216 self.frame = frame;
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
217 // ip = ip + flag in th06
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
218 self.ip = ip;
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
219 // 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
220 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
221 // 3
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
222 // 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
223 //
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 // 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
225 // CMP dword ptr [0x9d4 + ECX],0x0
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
226 // JLE LAB_00407abb
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
227 // aka ECX = enemy pointer
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
228 // 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
229 // 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
230 SubInstruction::RelativeJumpEx(frame, ip, var_id) => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
231 // 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
232 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
233 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
234 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
235 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
236 }
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
237 // 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
238 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
239 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
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 // 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
242 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
243 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
244 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
245 // 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
246 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
247 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
248 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
249 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
250 // 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
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::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
253 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
254 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
255 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
256 // 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
257 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
258 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
259 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
260 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
261 // 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
262 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
263 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
264 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
265 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
266 // 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
267 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
268 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
269 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
270 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
271 };
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 // 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
273 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
274 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
275 // 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
276 /*
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 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
278 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
279 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
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 // 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
283 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
284 SubInstruction::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
285 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
286 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
287 }
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 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
289 // 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
290 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
291 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
292 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
293 SubInstruction::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
294 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
295 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
296 // 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
297 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
298 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
299 }
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 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
301 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
302 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
303 // 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
304 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
305 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
306 }
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
307 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
308 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
309 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
310 }
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 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
312 // 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
313 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
314 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
315 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
316 /*
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 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
318 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
319 }
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 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
321 // 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
322 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
323 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
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 /*
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::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
327 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
328 }
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 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
330 // 18
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
331 // 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
332 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
333 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
334 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
335 // 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
336 /*
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::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
338 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
339 }
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
340 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
341 //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
342 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
343 //__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
344 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
345 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
346
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
347 // 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
348 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
349 // 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
350 // 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
351 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
352 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
353
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
354 // 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
355 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
356 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
357 let b = self.get_i32(b);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
358 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
359 self.comparison_reg = -1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
360 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
361 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
362 self.comparison_reg = 0;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
363 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
364 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
365 self.comparison_reg = 1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
366 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
367 }
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::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
369 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
370 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
371 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
372 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
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 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
375 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
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 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
378 self.comparison_reg = 1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
379 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
380 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
381 // 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
382 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
383 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
384 SubInstruction::RelativeJump(frame, ip);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
385 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
386 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
387 // 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
388 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
389 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
390 SubInstruction::RelativeJump(frame, ip);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
391 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
392 }
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
393 // 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
394 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
395 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
396 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
397 }
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 // 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
400 SubInstruction::RelativeJumpIfGreaterThan(frame, ip) => {
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
401 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
402 SubInstruction::RelativeJump(frame, ip);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
403 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
404 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
405 // 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
406 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
407 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
408 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
409 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
410 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
411 // 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
412 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
413 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
414 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
415 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
416 }
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
417 // 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
418 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
419 // 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
420 unimplemented!()
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
421 }
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
422
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
423 // 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
424 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
425 // 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
426 unimplemented!()
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
427 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
428 // 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
429 /*
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::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
431 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
432 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
433 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
434 }
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
435 */
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 // 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
437 /*
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 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
439 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
440 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
441 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
442 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
443 */
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 // 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
445 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
446 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
447 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
448 }
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 }
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 // 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
451 /*
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 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
453 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
454 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
455 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
456 }
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
457 */
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 //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
459 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
460 SubInstruction::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
461 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
462 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
463 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
464 }
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
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 //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
467 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
468 SubInstruction::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
469 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
470 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
471 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
472 }
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
473 */
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
474 // 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
475 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
476 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
477 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
478 }
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
479 // 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
480 /*
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
481 SubInstruction::SetAngularSpeed(x, y, z) => {
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
482 // same as above, except for angular speed
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
483 let mut enemy = self.enemy.borrow_mut();
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
484 enemy.set_angular_speed(self.get_f32(x), self.get_f32(y), self.get_f32(z));
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
485 }
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
486 */
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
487 // 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
488 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
489 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
490 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
491 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
492 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
493 enemy.angle = angle;
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
494 enemy.speed = speed;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
495 }
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
496 // 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
497 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
498 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
499 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
500 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
501 enemy.rotation_speed = rotation_speed;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
502 }
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
503 // 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
504 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
505 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
506 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
507 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
508 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
509 // 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
510 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
511 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
512 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
513 enemy.acceleration = self.get_f32(acceleration);
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
514 }
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
515 // 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
516 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
517 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
518 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
519 enemy.angle = angle;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
520 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
521 // 51
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
522 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
523 SubInstruction::TargetPlayer(angle, speed) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
524 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
525 let player = enemy.select_player();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
526 enemy.update_mode = 0;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
527 enemy.speed = speed;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
528 enemy.angle = enemy.get_angle(player) + angle;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
529
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
530 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
531 */
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
532 // 52 to 64 are different interlacing fields
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
533
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
534 // 65
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
535 // to note: in game a flag is set to enable the screenbox and is set by 66 to disable
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
536 // it on top of setting our values. But we have a good engine and can detect if that's
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
537 // changed without setting a flag :)
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
538 SubInstruction::SetScreenBox(xmin, ymin, xmax, ymax) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
539 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
540 enemy.screen_box = Some((xmin, ymin, xmax, ymax));
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
541 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
542 // 66
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
543 SubInstruction::ClearScreenBox() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
544 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
545 enemy.screen_box = None;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
546 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
547 // 67 to 75 are set bullet attributes and it seems a pain to reverse rn
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
548
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
549
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
550
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
551 // 78-79 are more interpolation flags
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
552 // 78
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
553 SubInstruction::DelayAttack() => {
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
554 let mut enemy = self.enemy.borrow_mut();
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
555 enemy.delay_attack = true;
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
556 }
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
557 // 79
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
558 SubInstruction::NoDelayAttack() => {
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
559 let mut enemy = self.enemy.borrow_mut();
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
560 enemy.delay_attack = false;
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
561 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
562 // 80
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
563 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
564 SubInstruction::NoClue() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
565 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
566 //bullet_pos = launch offset
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
567 (enemy->bullet_attributes).bullets_per_shot = enemy.pos.x + enemy->bullet_pos.pos.x;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
568 (enemy->bullet_attributes).number_of_shots = enemy.pos.pos.y + enemy.bullet_pos.pos.y;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
569 (enemy->bullet_attributes).speed = enemy.z + bullet_pos.z;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
570 enemy.fire(bullet_attributes=bullet_attributes)
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
571 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
572 */
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
573 // 81
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
574 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
575 SubInstruction::SetBulletLaunchOffset(x, y, z) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
576 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
577 enemy.bullet_launch_offset = (self._getval(x), self._getval(y), self._getval(z));
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
578 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
579 */
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
580 // 82
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
581 // TODO: correct but how to implement that in a rusty way?
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
582 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
583 SubInstruction::SetExtendedBulletAttributes(x, y, z) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
584 let mut enemy = self.enemy.borrow_mut();
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
585
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
586 // self._enemy.extended_bullet_attributes = tuple(self._getval(attr) for attr in attributes)
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
587 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
588 */
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
589 // 83
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
590 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
591 SubInstruction::ChangeBulletsIntoStarBonus() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
592 let mut game = self.game.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
593 game.change_bullets_into_star_items();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
594 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
595 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
596 // 84
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
597 // WARNING: dead code. If the parameter is < 0 it unsets a bullet_flag, otherwise it
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
598 // sets it, never using the parameter ever
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
599 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
600 SubInstruction::UNK_ins84() => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
601 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
602 enemy.bullet_flag_something
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
603 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
604 */
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
605
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
606 // 85-86 ire newlaser functions
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
607
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
608 // 87
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
609 SubInstruction::SetUpcomingLaserId(laser_id) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
610 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
611 enemy.current_laser_id = laser_id;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
612 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
613
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
614 // 88
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
615
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
616 SubInstruction::AlterLaserAngle(laser_id, delta) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
617 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
618 if enemy.laser_by_id.contains_key(&laser_id) {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
619 let mut laser = enemy.laser_by_id.get(laser_id);
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
620 laser.angle += self.get_f32(delta);
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
621 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
622 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
623
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
624 // 89
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
625 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
626 SubInstruction::AlterLaserAnglePlayer(laser_id, delta) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
627 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
628 if enemy.laser_by_id.contains_key(&laser_id) {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
629 let mut laser = enemy.laser_by_id.get(laser_id);
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
630 let player = enemy.select_player();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
631 laser.angle = enemy.get_angle(player) + angle;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
632 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
633 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
634 */
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
635
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
636 // 90
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
637 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
638 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
639 if enemy.laser_by_id.contains_key(&laser_id) {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
640 let mut laser = enemy.laser_by_id.get(laser_id);
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
641 laser.set_base_pos(enemy.pos.x + ox, enemy.pos.y + oy, enemy.z + oz)
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
642 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
643 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
644 // 91
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
645 // wat
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
646 SubInstruction::LaserSetCompare(laser_id) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
647 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
648 // in game it checks if either the laser exists OR if one of its member is set to 0
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
649 // which, uhhhh, we are not going to reimplement for obvious reasons
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
650 // the correct implementation would be: if this laser does not exist have a
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
651 // 1/100000 chance to continue, otherwise crash
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
652 if enemy.laser_by_id.contains_key(&laser_id) {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
653 // let's assume we gud
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
654 self.comparison_reg = 1;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
655 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
656 else{
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
657 self.comparison_reg = 0;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
658 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
659 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
660
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
661 // 92
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
662 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
663 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
664 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
665 if enemy.laser_by_id.contains_key(&laser_id) {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
666 let mut laser = enemy.laser_by_id.get(laser_id);
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
667 laser.cancel();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
668 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
669 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
670 */
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
671
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
672
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
673
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
674
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
675
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
676
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
677 // 97
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
678 SubInstruction::SetAnim(index) => {
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
679 // seems correct, game internally gets base_addr =(iVar13 + 0x1c934), pointer_addr = iVar14 * 4
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
680 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
681 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
682 }
666
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
683 // 98
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
684 SubInstruction::SetMultipleAnims(default, end_left, end_right, left, right, _unused) => {
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
685 // _unused was supposed to set movement_dependant_sprites, but internally the game
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
686 // assigns it 0xff
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
687 // TODO: THIS DOES NOT CALL set_anim. this only assigns all parameters to their
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
688 // internal struct. To check if the anims are set somewhere else
666
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
689 let mut enemy = self.enemy.borrow_mut();
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
690 enemy.movement_dependant_sprites = if left == -1 {
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
691 None
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
692 } else {
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
693 enemy.set_anim(default as u8);
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
694 Some((end_left as u8, end_right as u8, left as u8, right as u8))
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
695 };
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
696 }
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
697
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
698 // 100
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
699 SubInstruction::SetDeathAnim(index) => {
673
81ad01910f4b ecl_vm: instr 100 fix.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 672
diff changeset
700 // TODO: takes 3 parameters in game as u8 unlike our single u32.
81ad01910f4b ecl_vm: instr 100 fix.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 672
diff changeset
701 // To reverse!
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
702 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
703 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
704 }
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
705
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
706 // 103
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
707 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
708 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
709 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
710 }
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
711
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
712 // 104
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
713 SubInstruction::SetCollidable(collidable) => {
681
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
714 // TODO: me and my siblings(105, 107, 117) are implemented as a single variable in the touhou 6
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
715 // original engine. While our behaviour seems correct we might want to implement
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
716 // that as a single variable
681
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
717 // TODO[2]: THE BITFLAG MIGHT BE INCORRECT FOR OTHER SIBLING INSTRUCTIONS, the
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
718 // behavior was DEFINITELY incorrect in pytouhou for SetTouchable at the very least
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
719 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
720 enemy.collidable = (collidable&1) != 0;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
721 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
722
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
723 // 105
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
724 SubInstruction::SetDamageable(damageable) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
725 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
726 enemy.damageable = (damageable&1) != 0;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
727 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
728
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
729 // 106
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
730 /*
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
731 SubInstruction::PlaySound(index) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
732 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
733 enemy.play_sound(index);
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
734 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
735 */
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
736
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
737 // 107
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
738 SubInstruction::SetDeathFlags(death_flags) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
739 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
740 enemy.death_flags = death_flags;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
741 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
742
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
743 // 109
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
744 SubInstruction::MemoryWriteInt(value, index) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
745 unimplemented!("not again that damn foe corrupted my ret\\x41\\x41\\x41\\x41");
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
746 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
747
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
748
681
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
749 // 117
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
750 SubInstruction::SetTouchable(touchable) => {
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
751 let mut enemy = self.enemy.borrow_mut();
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
752 enemy.touchable = touchable != 0;
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
753 }
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
754
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
755 // 121
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
756 // Here lies the Di Sword of sadness
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
757 SubInstruction::CallSpecialFunction(function, arg) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
758 unimplemented!("spellcards are a bitch and a half");
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
759 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
760
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
761 _ => unimplemented!("{:?}", instruction)
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
762 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
763 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
764 }