annotate src/th06/ecl_vm.rs @ 699:2a60f12bd5bd

ecl_vm: stub SetBossMode.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 23 Aug 2019 02:40:27 +0200
parents 05e0425a8bc5
children b6c351ca0a35
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};
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
4 use crate::th06::enemy::{Enemy, BulletAttributes, Offset};
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
5 use crate::util::prng::Prng;
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
6 use std::cell::RefCell;
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
7 use std::rc::Rc;
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
8
686
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
9 macro_rules! gen_SetBulletAttributes {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
10 ($self:ident, $opcode:tt, $anim:ident, $sprite_index_offset:ident, $bullets_per_shot:ident,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
11 $number_of_shots:ident, $speed:ident, $speed2:ident, $launch_angle:ident, $angle:ident,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
12 $flags:ident) => {{
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
13 let sprite_index_offset = $self.get_i32($sprite_index_offset as i32) as i16;
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
14 let bullets_per_shot = $self.get_i32($bullets_per_shot) as i16;
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
15 let number_of_shots = $self.get_i32($number_of_shots) as i16;
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
16 let speed = $self.get_f32($speed);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
17 let speed2 = $self.get_f32($speed2);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
18 let launch_angle = $self.get_f32($launch_angle);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
19 let angle = $self.get_f32($angle);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
20
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
21 let mut enemy = $self.enemy.borrow_mut();
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
22 enemy.set_bullet_attributes($opcode, $anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
23 number_of_shots, speed, speed2, launch_angle, angle, $flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
24 }};
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
25 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
26
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
27 #[derive(Clone, Default)]
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
28 struct StackFrame {
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
29 frame: i32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
30 ip: i32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
31 //ins122_callback: Option<Box<FnMut(Enemy)>>,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
32 ints1: [i32; 4],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
33 floats: [f32; 4],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
34 ints2: [i32; 4],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
35 comparison_reg: i32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
36 sub: u16,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
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
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 /// 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
40 #[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
41 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
42 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
43 ecl: Option<Ecl>,
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
44 /// XXX
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
45 pub running: bool,
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
46 frame: StackFrame,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
47 // TODO: there are only 8 of these.
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
48 stack: Vec<StackFrame>,
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
49 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
50
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
51 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
52 /// Create a new ECL runner.
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
53 pub fn new(ecl: &Ecl, enemy: Rc<RefCell<Enemy>>, sub: u16) -> EclRunner {
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
54 let mut ecl_runner = EclRunner {
660
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 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
56 // 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
57 ecl: Some(ecl.clone()),
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
58 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
59 ..Default::default()
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
60 };
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
61 ecl_runner.frame.sub = sub;
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
62 ecl_runner
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
63 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
64
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
65 /// 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
66 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
67 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
68 let ecl = self.ecl.clone().unwrap();
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
69 let sub = &ecl.subs[self.frame.sub as usize];
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
70 let call = match sub.instructions.get(self.frame.ip as usize) {
660
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 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
72 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
73 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
74 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
75 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
76 };
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
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
78 if call.time > self.frame.frame {
660
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 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
80 }
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
81 self.frame.ip += 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
82
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 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
84 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
85 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
86 }
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
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
88 if call.time == self.frame.frame {
660
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 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
90 }
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 }
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
92 self.frame.frame += 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
93 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
94
660
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 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
96 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
97 match var {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
98 -10001 => self.frame.ints1[0],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
99 -10002 => self.frame.ints1[1],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
100 -10003 => self.frame.ints1[2],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
101 -10004 => self.frame.ints1[3],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
102 -10005 => self.frame.floats[0] as i32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
103 -10006 => self.frame.floats[1] as i32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
104 -10007 => self.frame.floats[2] as i32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
105 -10008 => self.frame.floats[3] as i32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
106 -10009 => self.frame.ints2[0],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
107 -10010 => self.frame.ints2[1],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
108 -10011 => self.frame.ints2[2],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
109 -10012 => self.frame.ints2[3],
664
f08e8e3c6196 Use bitflags for the rank, instead of an u16.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 663
diff changeset
110 -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
111 -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
112 -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
113 -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
114 -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
115 -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
116 -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
117 -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
118 -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
119 -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
120 -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
121 -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
122 -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
123 _ => 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
124 }
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 }
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
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 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
128 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
129 match var {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
130 -10001.0 => self.frame.ints1[0] as f32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
131 -10002.0 => self.frame.ints1[1] as f32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
132 -10003.0 => self.frame.ints1[2] as f32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
133 -10004.0 => self.frame.ints1[3] as f32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
134 -10005.0 => self.frame.floats[0],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
135 -10006.0 => self.frame.floats[1],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
136 -10007.0 => self.frame.floats[2],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
137 -10008.0 => self.frame.floats[3],
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
138 -10009.0 => self.frame.ints2[0] as f32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
139 -10010.0 => self.frame.ints2[1] as f32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
140 -10011.0 => self.frame.ints2[2] as f32,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
141 -10012.0 => self.frame.ints2[3] as f32,
664
f08e8e3c6196 Use bitflags for the rank, instead of an u16.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 663
diff changeset
142 -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
143 -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
144 -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
145 -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
146 -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
147 -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
148 -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
149 -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
150 -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
151 -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
152 -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
153 -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
154 -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
155 _ => 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
156 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
157 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
158
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
159 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
160 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
161 match var {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
162 -10001 => self.frame.ints1[0] = value,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
163 -10002 => self.frame.ints1[1] = value,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
164 -10003 => self.frame.ints1[2] = value,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
165 -10004 => self.frame.ints1[3] = value,
663
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
166 -10005 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
167 -10006 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
168 -10007 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
169 -10008 => unimplemented!(),
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
170 -10009 => self.frame.ints2[0] = value,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
171 -10010 => self.frame.ints2[1] = value,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
172 -10011 => self.frame.ints2[2] = value,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
173 -10012 => self.frame.ints2[3] = value,
663
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
174 -10013 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
175 -10014 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
176 -10015 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
177 -10016 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
178 -10017 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
179 -10018 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
180 -10019 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
181 -10020 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
182 -10021 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
183 -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
184 -10023 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
185 -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
186 -10025 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
187 _ => panic!("Unknown variable {}", var)
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
188 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
189 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
190
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
191 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
192 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
193 match var {
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
194 -10001.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
195 -10002.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
196 -10003.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
197 -10004.0 => unimplemented!(),
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
198 -10005.0 => self.frame.floats[0] = value,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
199 -10006.0 => self.frame.floats[1] = value,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
200 -10007.0 => self.frame.floats[2] = value,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
201 -10008.0 => self.frame.floats[3] = value,
663
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
202 -10009.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
203 -10010.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
204 -10011.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
205 -10012.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
206 -10013.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
207 -10014.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
208 -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
209 -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
210 -10017.0 => enemy.z = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
211 -10018.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
212 -10019.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
213 -10020.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
214 -10021.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
215 -10022.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
216 -10023.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
217 -10024.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
218 -10025.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
219 _ => panic!("Unknown variable {}", var)
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
220 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
221 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
222
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 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
224 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
225 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
226 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
227
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
228 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
229 println!("Running instruction {:?}", instruction);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
230 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
231 SubInstruction::Noop() => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
232 // really
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
233 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
234 // 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
235 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
236 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
237 enemy.removed = true;
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
238 }
660
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 // 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
240 SubInstruction::RelativeJump(frame, ip) => {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
241 self.frame.frame = frame;
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
242 // ip = ip + flag in th06
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
243 self.frame.ip = ip;
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
244 // 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
245 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
246 // 3
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
247 // 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
248 //
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
249 // 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
250 // CMP dword ptr [0x9d4 + ECX],0x0
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
251 // JLE LAB_00407abb
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
252 // aka ECX = enemy pointer
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
253 // 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
254 // 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
255 SubInstruction::RelativeJumpEx(frame, ip, var_id) => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
256 // 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
257 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
258 if counter_value > 0 {
697
600eb0a69b25 ecl_vm: fix RelativeJump* instructions to actually call RelativeJump.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 696
diff changeset
259 self.run_instruction(SubInstruction::RelativeJump(frame, ip));
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
260 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
261 }
660
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 // 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
263 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
264 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
265 }
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 // 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
267 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
268 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
269 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
270 // 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
271 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
272 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
273 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
274 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
275 // 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
276 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
277 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
278 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
279 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
280 // 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
281 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
282 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
283 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
284 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
285 // 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
286 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
287 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
288 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
289 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
290 // 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
291 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
292 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
293 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
294 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
295 };
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
296 // 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
297 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
298 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
299 // 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
300 SubInstruction::StoreY(var_id) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
301 let y = {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
302 let enemy = self.enemy.borrow();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
303 enemy.pos.y
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
304 };
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
305 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
306 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
307 // 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
308 SubInstruction::StoreZ(var_id) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
309 let z = {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
310 let enemy = self.enemy.borrow();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
311 enemy.z
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
312 };
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
313 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
314 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
315 // 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
316 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
317 self.set_i32(var_id, self.get_i32(a) + self.get_i32(b));
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
318 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
319 SubInstruction::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
320 self.set_f32(var_id as f32, self.get_f32(a) + self.get_f32(b));
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
321 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
322 // 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
323 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
324 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
325 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
326 SubInstruction::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
327 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
328 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
329 // 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
330 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
331 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
332 }
660
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 /*
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
334 SubInstruction::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
335 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
336 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
337 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
338 // 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
339 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
340 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
341 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
342
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
343 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
344 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
345 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
346
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
347 // 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
348 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
349 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
350 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
351
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
352 SubInstruction::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
353 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
354 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
355
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
356 // 18
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
357 // 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
358 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
359 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
360 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
361
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
362 // 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
363 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
364 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
365 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
366
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
367 //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
368 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
369 //__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
370 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
371 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
372
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
373 // 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
374 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
375 // 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
376 // 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
377 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
378 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
379
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
380 // 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
381 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
382 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
383 let b = self.get_i32(b);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
384 if a < b {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
385 self.frame.comparison_reg = -1;
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 else if a == b {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
388 self.frame.comparison_reg = 0;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
389 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
390 else {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
391 self.frame.comparison_reg = 1;
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 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
395 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
396 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
397 if a < b {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
398 self.frame.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
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 else if a == b {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
401 self.frame.comparison_reg = 0;
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
402 }
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 else {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
404 self.frame.comparison_reg = 1;
654
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 }
660
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 // 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
408 SubInstruction::RelativeJumpIfLowerThan(frame, ip) => {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
409 if self.frame.comparison_reg == -1 {
697
600eb0a69b25 ecl_vm: fix RelativeJump* instructions to actually call RelativeJump.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 696
diff changeset
410 self.run_instruction(SubInstruction::RelativeJump(frame, ip));
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
411 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
412 }
660
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 // 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
414 SubInstruction::RelativeJumpIfLowerOrEqual(frame, ip) => {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
415 if self.frame.comparison_reg != 1 {
697
600eb0a69b25 ecl_vm: fix RelativeJump* instructions to actually call RelativeJump.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 696
diff changeset
416 self.run_instruction(SubInstruction::RelativeJump(frame, ip));
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
417 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
418 }
660
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 // 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
420 SubInstruction::RelativeJumpIfEqual(frame, ip) => {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
421 if self.frame.comparison_reg == 0 {
697
600eb0a69b25 ecl_vm: fix RelativeJump* instructions to actually call RelativeJump.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 696
diff changeset
422 self.run_instruction(SubInstruction::RelativeJump(frame, ip));
660
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 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
424 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
425 // 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
426 SubInstruction::RelativeJumpIfGreaterThan(frame, ip) => {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
427 if self.frame.comparison_reg == 1 {
697
600eb0a69b25 ecl_vm: fix RelativeJump* instructions to actually call RelativeJump.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 696
diff changeset
428 self.run_instruction(SubInstruction::RelativeJump(frame, ip));
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
429 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
430 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
431 // 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
432 SubInstruction::RelativeJumpIfGreaterOrEqual(frame, ip) => {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
433 if self.frame.comparison_reg != -1 {
697
600eb0a69b25 ecl_vm: fix RelativeJump* instructions to actually call RelativeJump.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 696
diff changeset
434 self.run_instruction(SubInstruction::RelativeJump(frame, ip));
660
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 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
436 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
437 // 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
438 SubInstruction::RelativeJumpIfNotEqual(frame, ip) => {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
439 if self.frame.comparison_reg != 0 {
697
600eb0a69b25 ecl_vm: fix RelativeJump* instructions to actually call RelativeJump.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 696
diff changeset
440 self.run_instruction(SubInstruction::RelativeJump(frame, ip));
660
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 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
442 }
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
443 // 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
444 SubInstruction::Call(sub, param1, param2) => {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
445 self.stack.push(self.frame.clone());
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
446 self.frame.sub = sub as u16;
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
447 self.frame.ints1[0] = param1;
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
448 self.frame.floats[0] = param2;
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
449 self.frame.frame = 0;
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
450 self.frame.ip = 0;
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
451 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
452
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
453 // 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
454 SubInstruction::Return() => {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
455 self.frame = self.stack.pop().unwrap();
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
456 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
457 // 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
458 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
459 if self.get_i32(a) < self.get_i32(b) {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
460 self.run_instruction(SubInstruction::Call(sub, param1, param2));
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
461 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
462 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
463 // 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
464 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
465 if self.get_i32(a) <= self.get_i32(b) {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
466 self.run_instruction(SubInstruction::Call(sub, param1, param2));
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
467 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
468 }
660
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 // 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
470 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
471 if self.get_i32(a) == self.get_i32(b) {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
472 self.run_instruction(SubInstruction::Call(sub, param1, param2));
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
473 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
474 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
475 // 40
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
476 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
477 if self.get_i32(b) < self.get_i32(a) {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
478 self.run_instruction(SubInstruction::Call(sub, param1, param2));
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
479 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
480 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
481
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
482 // 41
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
483 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
484 if self.get_i32(b) <= self.get_i32(a) {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
485 self.run_instruction(SubInstruction::Call(sub, param1, param2));
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
486 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
487 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
488 //42
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
489 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
490 if self.get_i32(a) != self.get_i32(b) {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
491 self.run_instruction(SubInstruction::Call(sub, param1, param2));
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
492 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
493 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
494
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
495 // 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
496 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
497 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
498 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
499 }
660
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 // 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
501 /*
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
502 SubInstruction::SetAngularSpeed(x, y, z) => {
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
503 // 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
504 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
505 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
506 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
507 */
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
508 // 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
509 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
510 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
511 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
512 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
513 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
514 enemy.angle = angle;
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
515 enemy.speed = speed;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
516 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
517 // 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
518 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
519 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
520 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
521 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
522 enemy.rotation_speed = rotation_speed;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
523 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
524 // 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
525 SubInstruction::SetSpeed(speed) => {
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
526 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
527 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
528 enemy.update_mode = 0;
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
529 enemy.speed = 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
530 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
531 // 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
532 SubInstruction::SetAcceleration(acceleration) => {
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
533 let acceleration = self.get_f32(acceleration);
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
534 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
535 enemy.update_mode = 0;
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
536 enemy.acceleration = acceleration;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
537 }
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
538 // 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
539 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
540 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
541 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
542 enemy.angle = angle;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
543 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
544 // 51
693
14fddc27e6f5 ecl_vm: implement TargetPlayer, and add a dummy Player to Game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 692
diff changeset
545 SubInstruction::TargetPlayer(delta_angle, speed) => {
14fddc27e6f5 ecl_vm: implement TargetPlayer, and add a dummy Player to Game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 692
diff changeset
546 let speed = self.get_f32(speed);
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
547 let mut enemy = self.enemy.borrow_mut();
693
14fddc27e6f5 ecl_vm: implement TargetPlayer, and add a dummy Player to Game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 692
diff changeset
548 let game = enemy.game.upgrade().unwrap();
14fddc27e6f5 ecl_vm: implement TargetPlayer, and add a dummy Player to Game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 692
diff changeset
549 let player = game.borrow().get_player();
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
550 enemy.update_mode = 0;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
551 enemy.speed = speed;
693
14fddc27e6f5 ecl_vm: implement TargetPlayer, and add a dummy Player to Game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 692
diff changeset
552 enemy.angle = enemy.get_angle_to(player) + delta_angle;
14fddc27e6f5 ecl_vm: implement TargetPlayer, and add a dummy Player to Game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 692
diff changeset
553 }
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
554
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
555 // 52 to 64 are different interlacing fields
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 // 65
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
558 // 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
559 // 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
560 // changed without setting a flag :)
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
561 SubInstruction::SetScreenBox(xmin, ymin, xmax, ymax) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
562 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
563 enemy.screen_box = Some((xmin, ymin, xmax, ymax));
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 // 66
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
566 SubInstruction::ClearScreenBox() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
567 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
568 enemy.screen_box = None;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
569 }
686
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
570
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
571 // 67 to 75 are set bullet attributes and it seems a pain to reverse rn
686
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
572 SubInstruction::SetBulletAttributes1(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
573 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
574 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
575 gen_SetBulletAttributes!(self, 67, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
576 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
577 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
578 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
579 SubInstruction::SetBulletAttributes2(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
580 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
581 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
582 gen_SetBulletAttributes!(self, 68, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
583 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
584 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
585 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
586 SubInstruction::SetBulletAttributes3(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
587 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
588 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
589 gen_SetBulletAttributes!(self, 69, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
590 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
591 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
592 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
593 SubInstruction::SetBulletAttributes4(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
594 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
595 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
596 gen_SetBulletAttributes!(self, 70, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
597 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
598 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
599 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
600 SubInstruction::SetBulletAttributes5(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
601 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
602 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
603 gen_SetBulletAttributes!(self, 71, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
604 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
605 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
606 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
607 SubInstruction::SetBulletAttributes6(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
608 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
609 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
610 gen_SetBulletAttributes!(self, 74, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
611 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
612 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
613 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
614 SubInstruction::SetBulletAttributes7(anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
615 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
616 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
617 gen_SetBulletAttributes!(self, 75, anim, sprite_index_offset, bullets_per_shot,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
618 number_of_shots, speed, speed2, launch_angle, angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
619 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
620 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
621
688
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
622 // 76
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
623 SubInstruction::SetBulletInterval(interval) => {
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
624 let mut enemy = self.enemy.borrow_mut();
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
625 enemy.set_bullet_launch_interval(0, interval);
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
626 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
627
688
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
628 // 77
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
629 SubInstruction::SetBulletIntervalEx(interval) => {
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
630 let rand_start = self.get_prng().borrow_mut().get_u32();
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
631
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
632 let mut enemy = self.enemy.borrow_mut();
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
633 enemy.set_bullet_launch_interval(rand_start, interval);
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
634 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
635
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
636 // 78-79 are more interpolation flags
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
637 // 78
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
638 SubInstruction::DelayAttack() => {
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
639 let mut enemy = self.enemy.borrow_mut();
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
640 enemy.delay_attack = true;
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
641 }
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
642 // 79
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
643 SubInstruction::NoDelayAttack() => {
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
644 let mut enemy = self.enemy.borrow_mut();
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
645 enemy.delay_attack = false;
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
646 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
647 // 80
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
648 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
649 SubInstruction::NoClue() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
650 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
651 //bullet_pos = launch offset
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
652 (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
653 (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
654 (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
655 enemy.fire(bullet_attributes=bullet_attributes)
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
656 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
657 */
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
658
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
659 // 81
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
660 SubInstruction::SetBulletLaunchOffset(dx, dy, dz) => {
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
661 let (dx, dy, dz) = (self.get_f32(dx), self.get_f32(dy), self.get_f32(dz));
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
662 let mut enemy = self.enemy.borrow_mut();
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
663 enemy.bullet_offset = Offset { dx, dy };
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
664 }
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
665
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
666 // 82
691
f5d85a646975 ecl_vm: implement SetExtendedBulletAttributes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 690
diff changeset
667 SubInstruction::SetExtendedBulletAttributes(a, b, c, d, e, f, g, h) => {
f5d85a646975 ecl_vm: implement SetExtendedBulletAttributes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 690
diff changeset
668 let (a, b, c, d) = (self.get_i32(a), self.get_i32(b), self.get_i32(c), self.get_i32(d));
f5d85a646975 ecl_vm: implement SetExtendedBulletAttributes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 690
diff changeset
669 let (e, f, g, h) = (self.get_f32(e), self.get_f32(f), self.get_f32(g), self.get_f32(h));
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
670 let mut enemy = self.enemy.borrow_mut();
691
f5d85a646975 ecl_vm: implement SetExtendedBulletAttributes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 690
diff changeset
671 enemy.bullet_attributes.extended_attributes = (a, b, c, d, e, f, g, h);
f5d85a646975 ecl_vm: implement SetExtendedBulletAttributes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 690
diff changeset
672 }
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
673
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
674 // 83
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
675 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
676 SubInstruction::ChangeBulletsIntoStarBonus() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
677 let mut game = self.game.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
678 game.change_bullets_into_star_items();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
679 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
680 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
681 // 84
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
682 // 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
683 // sets it, never using the parameter ever
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
684 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
685 SubInstruction::UNK_ins84() => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
686 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
687 enemy.bullet_flag_something
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
688 }
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
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
691 // 85-86 ire newlaser functions
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
692
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
693 // 87
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
694 SubInstruction::SetUpcomingLaserId(laser_id) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
695 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
696 enemy.current_laser_id = laser_id;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
697 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
698
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
699 // 88
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
700 /*
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
701 SubInstruction::AlterLaserAngle(laser_id, delta) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
702 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
703 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
704 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
705 laser.angle += self.get_f32(delta);
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
706 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
707 }
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
708 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
709
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
710 // 89
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
711 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
712 SubInstruction::AlterLaserAnglePlayer(laser_id, delta) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
713 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
714 if enemy.laser_by_id.contains_key(&laser_id) {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
715 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
716 let player = enemy.select_player();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
717 laser.angle = enemy.get_angle(player) + angle;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
718 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
719 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
720 */
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
721
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
722 // 90
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
723 /*
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
724 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
725 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
726 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
727 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
728 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
729 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
730 }
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
731 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
732 // 91
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
733 // wat
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
734 SubInstruction::LaserSetCompare(laser_id) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
735 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
736 // 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
737 // 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
738 // 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
739 // 1/100000 chance to continue, otherwise crash
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
740 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
741 // let's assume we gud
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
742 self.frame.comparison_reg = 1;
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
743 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
744 else{
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
745 self.frame.comparison_reg = 0;
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
746 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
747 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
748
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
749 // 92
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
750 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
751 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
752 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
753 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
754 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
755 laser.cancel();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
756 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
757 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
758 */
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
759 // 93
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
760 // TODO: actually implement that hell
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
761 SubInstruction::SetSpellcard(face, number, name) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
762 unimplemented!("spellcard start");
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
763
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
764 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
765 // 94
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
766 SubInstruction::EndSpellcard() => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
767 unimplemented!("spellcard end");
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
768
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
769 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
770
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
771 // 95
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
772 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
773 SubInstruction::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
774 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
775 self.get_f32(y),
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
776 self.get_f32(z),
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
777 life, bonus_dropped, die_score)
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
778
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
779 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
780 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
781
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
782
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
783 // 96
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
784 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
785 SubInstruction::KillEnemies() => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
786 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
787 game.kill_enemies();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
788 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
789 */
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
790
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
791
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
792
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
793 // 97
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
794 SubInstruction::SetAnim(index) => {
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
795 // 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
796 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
797 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
798 }
666
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
799 // 98
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
800 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
801 // _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
802 // assigns it 0xff
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
803 // 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
804 // 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
805 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
806 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
807 None
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
808 } else {
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
809 enemy.set_anim(default as u8);
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
810 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
811 };
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
812 }
685
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 // 99
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
815 SubInstruction::SetAuxAnims(number, script) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
816 assert!(7 < number);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
817 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
818 enemy.set_aux_anm(number, script)
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
819 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
820 */
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
821
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
822 // 100
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
823 SubInstruction::SetDeathAnim(index) => {
673
81ad01910f4b ecl_vm: instr 100 fix.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 672
diff changeset
824 // 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
825 // To reverse!
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
826 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
827 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
828 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
829 // 101
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
830 SubInstruction::SetBossMode(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
831 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
832 if value < 0 {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
833 enemy.set_boss(false);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
834 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
835 else {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
836 // 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
837 // 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
838 enemy.set_boss(true);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
839 }
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
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
842 // 102
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
843 // TODO: title says it all
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 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
846 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
847 */
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
848
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
849 // 103
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
850 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
851 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
852 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
853 }
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
854
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
855 // 104
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
856 SubInstruction::SetCollidable(collidable) => {
681
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
857 // 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
858 // 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
859 // 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
860 // 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
861 // 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
862 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
863 enemy.collidable = (collidable&1) != 0;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
864 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
865
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
866 // 105
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
867 SubInstruction::SetDamageable(damageable) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
868 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
869 enemy.damageable = (damageable&1) != 0;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
870 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
871
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
872 // 106
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
873 SubInstruction::PlaySound(index) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
874 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
875 enemy.play_sound(index);
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
876 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
877
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
878 // 107
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
879 SubInstruction::SetDeathFlags(death_flags) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
880 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
881 enemy.death_flags = death_flags;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
882 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
883 // 108
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
884 SubInstruction::SetDeathCallback(sub) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
885 let mut enemy = self.enemy.borrow_mut();
698
05e0425a8bc5 ecl_vm: enable SetDeathCallback.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 697
diff changeset
886 enemy.death_callback = Some(sub);
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
887 }
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
888
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
889 // 109
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
890 SubInstruction::MemoryWriteInt(value, index) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
891 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
892 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
893
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
894 // 110
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
895 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
896 SubInstruction::KillEnemy(enemy) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
897 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
898 game.kill_enemy(enemy);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
899 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
900 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
901
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
902 // 111
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
903 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
904 SubInstruction::SetLife(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
905 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
906 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
907 enemy.life = value;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
908 game.interface.set_boss_life();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
909 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
910 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
911 // 112
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
912 SubInstruction::SetElapsedTime(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
913 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
914 enemy.frame = value as u32;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
915 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
916 // 113
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
917 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
918 SubInstruction::SetLowLifeTrigger(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
919 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
920 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
921 enemy.low_life_trigger = value;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
922 game.interface.set_spell_life();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
923 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
924 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
925 // 114
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
926 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
927 SubInstruction::SetLowLifeCallback(sub) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
928 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
929 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
930 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
931 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
932 // 115
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
933 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
934 SubInstruction::SetTimeout(timeout) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
935 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
936 enemy.frame = value;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
937 enemy.timeout = timeout;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
938 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
939 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
940 // 116
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
941 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
942 SubInstruction::SetTimeoutCallback(sub) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
943 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
944 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
945 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
946 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
947
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
948
681
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
949 // 117
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
950 SubInstruction::SetTouchable(touchable) => {
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
951 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
952 enemy.touchable = touchable != 0;
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
953 }
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
954
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
955 // 121
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
956 // Here lies the Di Sword of sadness
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
957 SubInstruction::CallSpecialFunction(function, arg) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
958 unimplemented!("spellcards are a bitch and a half");
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
959 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
960
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
961 _ => 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
962 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
963 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
964 }
695
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
965
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
966 #[cfg(test)]
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
967 mod tests {
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
968 use super::*;
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
969 use crate::th06::anm0::Anm0;
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
970 use crate::th06::ecl::{Sub, CallSub, Rank};
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
971 use crate::th06::enemy::{Game, Position};
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
972 use std::io::{self, Read};
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
973 use std::fs::File;
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
974
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
975 fn setup() -> (Rc<RefCell<Game>>, Rc<RefCell<Enemy>>) {
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
976 let file = File::open("EoSD/ST/stg1enm.anm").unwrap();
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
977 let mut file = io::BufReader::new(file);
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
978 let mut buf = vec![];
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
979 file.read_to_end(&mut buf).unwrap();
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
980 let anm0 = Anm0::from_slice(&buf).unwrap();
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
981 let anm0 = Rc::new(RefCell::new(anm0));
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
982 let prng = Rc::new(RefCell::new(Prng::new(0)));
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
983 let game = Game::new(prng, Rank::Easy);
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
984 let game = Rc::new(RefCell::new(game));
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
985 let enemy = Enemy::new(Position::new(0., 0.), 500, 0, 640, Rc::downgrade(&anm0), Rc::downgrade(&game));
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
986 (game, enemy)
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
987 }
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
988
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
989 #[test]
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
990 fn call_and_return() {
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
991 let (game, enemy) = setup();
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
992 let ecl = Ecl { mains: vec![], subs: vec![
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
993 Sub { instructions: vec![
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
994 CallSub::new(0, Rank::Easy, SubInstruction::Call(1, 13, 12.)),
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
995 ]},
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
996 Sub { instructions: vec![
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
997 CallSub::new(0, Rank::Easy, SubInstruction::Noop()),
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
998 CallSub::new(1, Rank::Easy, SubInstruction::Return()),
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
999 ]},
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1000 ]};
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1001 let mut ecl_runner = EclRunner::new(&ecl, enemy, 0);
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1002 ecl_runner.run_frame();
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1003 assert_eq!(ecl_runner.frame.ints1[0], 13);
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1004 assert_eq!(ecl_runner.frame.floats[0], 12.);
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1005 assert_eq!(ecl_runner.stack.len(), 1);
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1006 ecl_runner.run_frame();
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1007 assert_eq!(ecl_runner.frame.ints1[0], 0);
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1008 assert_eq!(ecl_runner.frame.floats[0], 0.);
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1009 assert_eq!(ecl_runner.stack.len(), 0);
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1010 }
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1011 }