annotate src/th06/ecl_vm.rs @ 685:11d7e4d6947a

ecl_vm: nearing the complete list
author Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
date Fri, 16 Aug 2019 23:27:09 +0200
parents c8bb28961d31
children aefe5b5f481e
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 SubInstruction::SetRandomIntMin(var_id, maxval, minval) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
252 let random = self.get_prng().borrow_mut().get_u32() as i32;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
253 self.set_i32(var_id, (random % self.get_i32(maxval)) + self.get_i32(minval));
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
254 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
255 // 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
256 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
257 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
258 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
259 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
260 // 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
261 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
262 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
263 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
264 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
265 // 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
266 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
267 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
268 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
269 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
270 };
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 // 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
272 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
273 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
274 // 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
275 SubInstruction::StoreY(var_id) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
276 let y = {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
277 let enemy = self.enemy.borrow();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
278 enemy.pos.y
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
279 };
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
280 self.set_i32(var_id, y as i32);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
281 }
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 SubInstruction::StoreZ(var_id) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
284 let z = {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
285 let enemy = self.enemy.borrow();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
286 enemy.z
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
287 };
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
288 self.set_i32(var_id, z as i32);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
289 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
290 // 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
291 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
292 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
293 }
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 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
295 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
296 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
297 // 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
298 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
299 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
300 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
301 SubInstruction::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
302 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
303 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
304 // 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
305 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
306 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
307 }
660
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 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
309 SubInstruction::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
310 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
311 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
312 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
313 // 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
314 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
315 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
316 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
317
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
318 SubInstruction::DivideFloat(var_id, a, b) => {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
319 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
320 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
321
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
322 // 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
323 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
324 self.set_i32(var_id, self.get_i32(a) % self.get_i32(b));
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
325 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
326
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
327 SubInstruction::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
328 self.set_f32(var_id as f32, self.get_f32(a) % self.get_f32(b));
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
329 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
330
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
331 // 18
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
332 // 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
333 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
334 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
335 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
336
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
337 // 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
338 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
339 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
340 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
341
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
342 //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
343 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
344 //__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
345 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
346 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
347
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
348 // 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
349 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
350 // 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
351 // 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
352 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
353 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
354
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
355 // 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
356 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
357 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
358 let b = self.get_i32(b);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
359 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
360 self.comparison_reg = -1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
361 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
362 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
363 self.comparison_reg = 0;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
364 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
365 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
366 self.comparison_reg = 1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
367 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
368 }
660
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 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
370 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
371 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
372 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
373 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
374 }
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 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
376 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
377 }
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 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
379 self.comparison_reg = 1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
380 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
381 }
660
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 // 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
383 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
384 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
385 SubInstruction::RelativeJump(frame, ip);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
386 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
387 }
660
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 // 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
389 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
390 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
391 SubInstruction::RelativeJump(frame, ip);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
392 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
393 }
660
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 // 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
395 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
396 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
397 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
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 }
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 // 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
401 SubInstruction::RelativeJumpIfGreaterThan(frame, ip) => {
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
402 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
403 SubInstruction::RelativeJump(frame, ip);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
404 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
405 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
406 // 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
407 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
408 if self.comparison_reg != -1 {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
409 SubInstruction::RelativeJump(frame, ip);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
410 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
411 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
412 // 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
413 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
414 if self.comparison_reg != 0 {
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
415 SubInstruction::RelativeJump(frame, ip);
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
416 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
417 }
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
418 // 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
419 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
420 // 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
421 unimplemented!()
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
422 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
423
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
424 // 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
425 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
426 // 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
427 unimplemented!()
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
428 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
429 // 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
430 SubInstruction::CallIfSuperior(sub, param1, param2, a, b) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
431 if self.get_i32(a) < self.get_i32(b) {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
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 // 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
436 SubInstruction::CallIfSuperiorOrEqual(sub, param1, param2, a, b) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
437 if self.get_i32(a) <= self.get_i32(b) {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
438 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
439 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
440 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
441 // 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
442 SubInstruction::CallIfEqual(sub, param1, param2, a, b) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
443 if self.get_i32(a) == self.get_i32(b) {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
444 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
445 }
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 }
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 // 40
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
448 SubInstruction::CallIfInferior(sub, param1, param2, a, b) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
449 if self.get_i32(b) < self.get_i32(a) {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
450 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
451 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
452 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
453
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
454 // 41
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
455 SubInstruction::CallIfInferiorOrEqual(sub, param1, param2, a, b) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
456 if self.get_i32(b) <= self.get_i32(a) {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
457 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
458 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
459 }
660
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 //42
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
461 SubInstruction::CallIfNotEqual(sub, param1, param2, a, b) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
462 if self.get_i32(a) != self.get_i32(b) {
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
463 SubInstruction::Call(sub, param1, param2);
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
464 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
465 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
466
660
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 // 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
468 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
469 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
470 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
471 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
472 // 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
473 /*
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
474 SubInstruction::SetAngularSpeed(x, y, z) => {
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
475 // 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
476 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
477 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
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 */
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 // 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
481 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
482 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
483 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
484 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
485 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
486 enemy.angle = angle;
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
487 enemy.speed = speed;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
488 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
489 // 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
490 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
491 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
492 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
493 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
494 enemy.rotation_speed = rotation_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 // 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
497 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
498 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
499 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
500 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
501 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
502 // 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
503 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
504 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
505 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
506 enemy.acceleration = self.get_f32(acceleration);
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
507 }
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
508 // 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
509 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
510 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
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.angle = angle;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
513 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
514 // 51
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
515 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
516 SubInstruction::TargetPlayer(angle, speed) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
517 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
518 let player = enemy.select_player();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
519 enemy.update_mode = 0;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
520 enemy.speed = speed;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
521 enemy.angle = enemy.get_angle(player) + angle;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
522
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
523 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
524 */
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
525 // 52 to 64 are different interlacing fields
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
526
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
527 // 65
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
528 // 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
529 // 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
530 // changed without setting a flag :)
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
531 SubInstruction::SetScreenBox(xmin, ymin, xmax, ymax) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
532 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
533 enemy.screen_box = Some((xmin, ymin, xmax, ymax));
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
534 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
535 // 66
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
536 SubInstruction::ClearScreenBox() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
537 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
538 enemy.screen_box = None;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
539 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
540 // 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
541
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
542
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
543
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
544 // 78-79 are more interpolation flags
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
545 // 78
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
546 SubInstruction::DelayAttack() => {
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
547 let mut enemy = self.enemy.borrow_mut();
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
548 enemy.delay_attack = true;
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
549 }
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
550 // 79
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
551 SubInstruction::NoDelayAttack() => {
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
552 let mut enemy = self.enemy.borrow_mut();
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
553 enemy.delay_attack = false;
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
554 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
555 // 80
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
556 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
557 SubInstruction::NoClue() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
558 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
559 //bullet_pos = launch offset
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
560 (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
561 (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
562 (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
563 enemy.fire(bullet_attributes=bullet_attributes)
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
564 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
565 */
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
566 // 81
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
567 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
568 SubInstruction::SetBulletLaunchOffset(x, y, z) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
569 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
570 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
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 // 82
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
574 // 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
575 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
576 SubInstruction::SetExtendedBulletAttributes(x, y, z) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
577 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
578
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
579 // 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
580 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
581 */
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
582 // 83
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
583 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
584 SubInstruction::ChangeBulletsIntoStarBonus() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
585 let mut game = self.game.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
586 game.change_bullets_into_star_items();
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 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
589 // 84
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
590 // 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
591 // sets it, never using the parameter ever
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
592 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
593 SubInstruction::UNK_ins84() => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
594 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
595 enemy.bullet_flag_something
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
596 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
597 */
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
598
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
599 // 85-86 ire newlaser functions
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
600
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
601 // 87
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
602 SubInstruction::SetUpcomingLaserId(laser_id) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
603 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
604 enemy.current_laser_id = laser_id;
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
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
607 // 88
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
608 /*
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
609 SubInstruction::AlterLaserAngle(laser_id, delta) => {
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 if enemy.laser_by_id.contains_key(&laser_id) {
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
612 let mut laser = enemy.laser_by_id.get(&laser_id);
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
613 laser.angle += self.get_f32(delta);
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
614 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
615 }
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
616 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
617
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
618 // 89
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
619 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
620 SubInstruction::AlterLaserAnglePlayer(laser_id, delta) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
621 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
622 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
623 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
624 let player = enemy.select_player();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
625 laser.angle = enemy.get_angle(player) + angle;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
626 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
627 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
628 */
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
629
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
630 // 90
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
631 /*
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
632 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
633 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
634 if enemy.laser_by_id.contains_key(&laser_id) {
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
635 let mut laser = enemy.laser_by_id.get(&laser_id);
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
636 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
637 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
638 }
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
639 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
640 // 91
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
641 // wat
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
642 SubInstruction::LaserSetCompare(laser_id) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
643 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
644 // 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
645 // 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
646 // 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
647 // 1/100000 chance to continue, otherwise crash
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
648 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
649 // let's assume we gud
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
650 self.comparison_reg = 1;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
651 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
652 else{
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
653 self.comparison_reg = 0;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
654 }
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
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
657 // 92
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 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
660 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
661 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
662 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
663 laser.cancel();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
664 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
665 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
666 */
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
667 // 93
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
668 // TODO: actually implement that hell
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
669 SubInstruction::SetSpellcard(face, number, name) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
670 unimplemented!("spellcard start");
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
671
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
672 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
673 // 94
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
674 SubInstruction::EndSpellcard() => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
675 unimplemented!("spellcard end");
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
676
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
677 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
678
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
679 // 95
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
680 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
681 SubInstruction::PopEnemy(sub, x, y, z, life, bonus_dropped, die_score) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
682 self._pop_enemy(sub, 0, self.get_f32(x),
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
683 self.get_f32(y),
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
684 self.get_f32(z),
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
685 life, bonus_dropped, die_score)
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
686
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
687 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
688 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
689
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
690
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
691 // 96
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
692 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
693 SubInstruction::KillEnemies() => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
694 let mut game = self.game.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
695 game.kill_enemies();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
696 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
697 */
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
698
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
699
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
700
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
701 // 97
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
702 SubInstruction::SetAnim(index) => {
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
703 // 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
704 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
705 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
706 }
666
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
707 // 98
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
708 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
709 // _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
710 // assigns it 0xff
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
711 // 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
712 // 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
713 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
714 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
715 None
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
716 } else {
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
717 enemy.set_anim(default as u8);
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
718 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
719 };
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
720 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
721 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
722 // 99
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
723 SubInstruction::SetAuxAnims(number, script) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
724 assert!(7 < number);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
725 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
726 enemy.set_aux_anm(number, script)
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
727 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
728 */
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
729
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
730 // 100
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
731 SubInstruction::SetDeathAnim(index) => {
673
81ad01910f4b ecl_vm: instr 100 fix.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 672
diff changeset
732 // 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
733 // To reverse!
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
734 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
735 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
736 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
737 // 101
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
738 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
739 SubInstruction::SetBossMode(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
740 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
741 if value < 0 {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
742 enemy.set_boss(false);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
743 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
744 else {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
745 // the boss pointer is written somewhere in memory and overwrote by a 0 when
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
746 // the boss mode is false, might want to look into that
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
747 enemy.set_boss(true);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
748 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
749 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
750 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
751
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
752 // 102
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
753 // TODO: title says it all
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
754 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
755 SubInstruction::ParticlesVoodooMagic(unk1, unk2, unk3, unk4, unk5) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
756 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
757 */
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
758
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
759 // 103
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
760 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
761 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
762 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
763 }
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
764
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
765 // 104
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
766 SubInstruction::SetCollidable(collidable) => {
681
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
767 // 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
768 // 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
769 // 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
770 // 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
771 // 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
772 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
773 enemy.collidable = (collidable&1) != 0;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
774 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
775
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
776 // 105
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
777 SubInstruction::SetDamageable(damageable) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
778 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
779 enemy.damageable = (damageable&1) != 0;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
780 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
781
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
782 // 106
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
783 /*
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
784 SubInstruction::PlaySound(index) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
785 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
786 enemy.play_sound(index);
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
787 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
788 */
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
789
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
790 // 107
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
791 SubInstruction::SetDeathFlags(death_flags) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
792 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
793 enemy.death_flags = death_flags;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
794 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
795 // 108
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
796 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
797 SubInstruction::SetDeathCallback(sub) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
798 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
799 enemy.death_callback.enable(self.switch_to_sub, (sub,));
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
800 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
801 */
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
802
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
803 // 109
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
804 SubInstruction::MemoryWriteInt(value, index) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
805 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
806 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
807
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
808 // 110
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
809 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
810 SubInstruction::KillEnemy(enemy) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
811 let mut game = self.game.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
812 game.kill_enemy(enemy);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
813 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
814 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
815
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
816 // 111
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
817 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
818 SubInstruction::SetLife(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
819 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
820 let mut game = self.game.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
821 enemy.life = value;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
822 game.interface.set_boss_life();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
823 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
824 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
825 // 112
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
826 SubInstruction::SetElapsedTime(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
827 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
828 enemy.frame = value as u32;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
829 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
830 // 113
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
831 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
832 SubInstruction::SetLowLifeTrigger(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
833 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
834 let mut game = self.game.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
835 enemy.low_life_trigger = value;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
836 game.interface.set_spell_life();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
837 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
838 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
839 // 114
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
840 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
841 SubInstruction::SetLowLifeCallback(sub) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
842 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
843 enemy.low_life_callback.enable(self.switch_to_sub, (sub,));
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
844 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
845 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
846 // 115
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
847 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
848 SubInstruction::SetTimeout(timeout) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
849 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
850 enemy.frame = value;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
851 enemy.timeout = timeout;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
852 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
853 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
854 // 116
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
855 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
856 SubInstruction::SetTimeoutCallback(sub) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
857 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
858 enemy.timeout_callback.enable(self.switch_to_sub, (sub,));
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
859 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
860 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
861
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
862
681
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
863 // 117
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
864 SubInstruction::SetTouchable(touchable) => {
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
865 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
866 enemy.touchable = touchable != 0;
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
867 }
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
868
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
869 // 121
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
870 // Here lies the Di Sword of sadness
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
871 SubInstruction::CallSpecialFunction(function, arg) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
872 unimplemented!("spellcards are a bitch and a half");
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
873 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
874
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
875 _ => 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
876 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
877 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
878 }