Mercurial > touhou
annotate src/th06/ecl_vm.rs @ 723:420cec4005b5
ecl_vm: patchouli spellcard selector
author | Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com> |
---|---|
date | Tue, 29 Oct 2019 04:06:28 +0100 |
parents | e71ea8214ee2 |
children | 8acaf45b47d0 |
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}; |
716
5016c09e5d7c
Fix some warnings.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
711
diff
changeset
|
4 use crate::th06::enemy::{Enemy, 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) => { |
711
464c1b02a996
ecl_vm: Fix SetPosition.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
703
diff
changeset
|
497 let (x, y, z) = (self.get_f32(x), self.get_f32(y), self.get_f32(z)); |
660
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
498 let mut enemy = self.enemy.borrow_mut(); |
711
464c1b02a996
ecl_vm: Fix SetPosition.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
703
diff
changeset
|
499 enemy.set_pos(x, y, z); |
659
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
diff
changeset
|
500 } |
660
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 // 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
|
502 /* |
672
d20cf9ede914
Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
666
diff
changeset
|
503 SubInstruction::SetAngularSpeed(x, y, z) => { |
d20cf9ede914
Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
666
diff
changeset
|
504 // 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
|
505 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
|
506 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
|
507 } |
660
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
508 */ |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
509 // 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
|
510 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
|
511 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
|
512 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
|
513 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
|
514 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
|
515 enemy.angle = angle; |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
516 enemy.speed = speed; |
659
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
diff
changeset
|
517 } |
660
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 // 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
|
519 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
|
520 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
|
521 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
|
522 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
|
523 enemy.rotation_speed = rotation_speed; |
659
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
diff
changeset
|
524 } |
660
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 // 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
|
526 SubInstruction::SetSpeed(speed) => { |
690
eecb8626f472
ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
688
diff
changeset
|
527 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
|
528 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
|
529 enemy.update_mode = 0; |
690
eecb8626f472
ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
688
diff
changeset
|
530 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
|
531 } |
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 // 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
|
533 SubInstruction::SetAcceleration(acceleration) => { |
690
eecb8626f472
ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
688
diff
changeset
|
534 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
|
535 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
|
536 enemy.update_mode = 0; |
690
eecb8626f472
ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
688
diff
changeset
|
537 enemy.acceleration = acceleration; |
659
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
diff
changeset
|
538 } |
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
diff
changeset
|
539 // 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
|
540 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
|
541 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
|
542 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
|
543 enemy.angle = angle; |
659
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
diff
changeset
|
544 } |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
545 // 51 |
693
14fddc27e6f5
ecl_vm: implement TargetPlayer, and add a dummy Player to Game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
692
diff
changeset
|
546 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
|
547 let speed = self.get_f32(speed); |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
548 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
|
549 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
|
550 let player = game.borrow().get_player(); |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
551 enemy.update_mode = 0; |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
552 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
|
553 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
|
554 } |
659
53786d834444
Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
655
diff
changeset
|
555 |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
556 // 52 to 64 are different interlacing fields |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
557 |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
558 // 65 |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
559 // 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
|
560 // 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
|
561 // changed without setting a flag :) |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
562 SubInstruction::SetScreenBox(xmin, ymin, xmax, ymax) => { |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
563 let mut enemy = self.enemy.borrow_mut(); |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
564 enemy.screen_box = Some((xmin, ymin, xmax, ymax)); |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
565 } |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
566 // 66 |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
567 SubInstruction::ClearScreenBox() => { |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
568 let mut enemy = self.enemy.borrow_mut(); |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
569 enemy.screen_box = None; |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
570 } |
686
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
571 |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
572 // 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
|
573 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
|
574 number_of_shots, speed, speed2, launch_angle, |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
575 angle, flags) => { |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
576 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
|
577 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
|
578 flags); |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
579 } |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
580 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
|
581 number_of_shots, speed, speed2, launch_angle, |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
582 angle, flags) => { |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
583 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
|
584 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
|
585 flags); |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
586 } |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
587 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
|
588 number_of_shots, speed, speed2, launch_angle, |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
589 angle, flags) => { |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
590 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
|
591 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
|
592 flags); |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
593 } |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
594 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
|
595 number_of_shots, speed, speed2, launch_angle, |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
596 angle, flags) => { |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
597 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
|
598 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
|
599 flags); |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
600 } |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
601 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
|
602 number_of_shots, speed, speed2, launch_angle, |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
603 angle, flags) => { |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
604 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
|
605 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
|
606 flags); |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
607 } |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
608 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
|
609 number_of_shots, speed, speed2, launch_angle, |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
610 angle, flags) => { |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
611 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
|
612 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
|
613 flags); |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
614 } |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
615 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
|
616 number_of_shots, speed, speed2, launch_angle, |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
617 angle, flags) => { |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
618 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
|
619 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
|
620 flags); |
aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
685
diff
changeset
|
621 } |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
622 |
688
1adecaddf442
ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
686
diff
changeset
|
623 // 76 |
1adecaddf442
ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
686
diff
changeset
|
624 SubInstruction::SetBulletInterval(interval) => { |
1adecaddf442
ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
686
diff
changeset
|
625 let mut enemy = self.enemy.borrow_mut(); |
1adecaddf442
ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
686
diff
changeset
|
626 enemy.set_bullet_launch_interval(0, interval); |
1adecaddf442
ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
686
diff
changeset
|
627 } |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
628 |
688
1adecaddf442
ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
686
diff
changeset
|
629 // 77 |
1adecaddf442
ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
686
diff
changeset
|
630 SubInstruction::SetBulletIntervalEx(interval) => { |
1adecaddf442
ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
686
diff
changeset
|
631 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
|
632 |
1adecaddf442
ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
686
diff
changeset
|
633 let mut enemy = self.enemy.borrow_mut(); |
1adecaddf442
ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
686
diff
changeset
|
634 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
|
635 } |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
636 |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
637 // 78-79 are more interpolation flags |
678
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
638 // 78 |
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
639 SubInstruction::DelayAttack() => { |
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
640 let mut enemy = self.enemy.borrow_mut(); |
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
641 enemy.delay_attack = true; |
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
642 } |
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
643 // 79 |
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
644 SubInstruction::NoDelayAttack() => { |
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
645 let mut enemy = self.enemy.borrow_mut(); |
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
646 enemy.delay_attack = false; |
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
647 } |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
648 // 80 |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
649 /* |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
650 SubInstruction::NoClue() => { |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
651 let mut enemy = self.enemy.borrow_mut(); |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
652 //bullet_pos = launch offset |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
653 (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
|
654 (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
|
655 (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
|
656 enemy.fire(bullet_attributes=bullet_attributes) |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
657 } |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
658 */ |
690
eecb8626f472
ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
688
diff
changeset
|
659 |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
660 // 81 |
690
eecb8626f472
ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
688
diff
changeset
|
661 SubInstruction::SetBulletLaunchOffset(dx, dy, dz) => { |
eecb8626f472
ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
688
diff
changeset
|
662 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
|
663 let mut enemy = self.enemy.borrow_mut(); |
690
eecb8626f472
ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
688
diff
changeset
|
664 enemy.bullet_offset = Offset { dx, dy }; |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
665 } |
690
eecb8626f472
ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
688
diff
changeset
|
666 |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
667 // 82 |
691
f5d85a646975
ecl_vm: implement SetExtendedBulletAttributes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
690
diff
changeset
|
668 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
|
669 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
|
670 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
|
671 let mut enemy = self.enemy.borrow_mut(); |
691
f5d85a646975
ecl_vm: implement SetExtendedBulletAttributes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
690
diff
changeset
|
672 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
|
673 } |
678
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
674 |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
675 // 83 |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
676 /* |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
677 SubInstruction::ChangeBulletsIntoStarBonus() => { |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
678 let mut game = self.game.borrow_mut(); |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
679 game.change_bullets_into_star_items(); |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
680 } |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
681 */ |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
682 // 84 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
683 // 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
|
684 // sets it, never using the parameter ever |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
685 /* |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
686 SubInstruction::UNK_ins84() => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
687 let mut enemy = self.enemy.borrow_mut(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
688 enemy.bullet_flag_something |
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 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
692 // 85-86 ire newlaser functions |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
693 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
694 // 87 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
695 SubInstruction::SetUpcomingLaserId(laser_id) => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
696 let mut enemy = self.enemy.borrow_mut(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
697 enemy.current_laser_id = laser_id; |
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 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
700 // 88 |
684
c8bb28961d31
ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
683
diff
changeset
|
701 /* |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
702 SubInstruction::AlterLaserAngle(laser_id, delta) => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
703 let mut enemy = self.enemy.borrow_mut(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
704 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
|
705 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
|
706 laser.angle += self.get_f32(delta); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
707 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
708 } |
684
c8bb28961d31
ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
683
diff
changeset
|
709 */ |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
710 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
711 // 89 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
712 /* |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
713 SubInstruction::AlterLaserAnglePlayer(laser_id, delta) => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
714 let mut enemy = self.enemy.borrow_mut(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
715 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
|
716 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
|
717 let player = enemy.select_player(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
718 laser.angle = enemy.get_angle(player) + angle; |
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 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
723 // 90 |
684
c8bb28961d31
ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
683
diff
changeset
|
724 /* |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
725 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
726 let mut enemy = self.enemy.borrow_mut(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
727 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
|
728 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
|
729 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
|
730 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
731 } |
684
c8bb28961d31
ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
683
diff
changeset
|
732 */ |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
733 // 91 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
734 // wat |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
735 SubInstruction::LaserSetCompare(laser_id) => { |
716
5016c09e5d7c
Fix some warnings.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
711
diff
changeset
|
736 let enemy = self.enemy.borrow_mut(); |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
737 // 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
|
738 // 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
|
739 // 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
|
740 // 1/100000 chance to continue, otherwise crash |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
741 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
|
742 // 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
|
743 self.frame.comparison_reg = 1; |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
744 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
745 else{ |
696
7ae576a418ff
ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
695
diff
changeset
|
746 self.frame.comparison_reg = 0; |
683
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 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
750 // 92 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
751 /* |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
752 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
753 let mut enemy = self.enemy.borrow_mut(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
754 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
|
755 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
|
756 laser.cancel(); |
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 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
759 */ |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
760 // 93 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
761 // TODO: actually implement that hell |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
762 SubInstruction::SetSpellcard(face, number, name) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
763 unimplemented!("spellcard start"); |
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 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
766 // 94 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
767 SubInstruction::EndSpellcard() => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
768 unimplemented!("spellcard end"); |
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 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
772 // 95 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
773 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
774 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
|
775 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
|
776 self.get_f32(y), |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
777 self.get_f32(z), |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
778 life, bonus_dropped, die_score) |
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 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
781 */ |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
782 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
783 |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
784 // 96 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
785 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
786 SubInstruction::KillEnemies() => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
787 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
|
788 game.kill_enemies(); |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
789 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
790 */ |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
791 |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
792 |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
793 |
661
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
794 // 97 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
795 SubInstruction::SetAnim(index) => { |
672
d20cf9ede914
Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
666
diff
changeset
|
796 // 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
|
797 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
|
798 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
|
799 } |
666
838d9402b12f
Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
665
diff
changeset
|
800 // 98 |
838d9402b12f
Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
665
diff
changeset
|
801 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
|
802 // _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
|
803 // assigns it 0xff |
d20cf9ede914
Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
666
diff
changeset
|
804 // 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
|
805 // 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
|
806 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
|
807 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
|
808 None |
838d9402b12f
Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
665
diff
changeset
|
809 } else { |
838d9402b12f
Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
665
diff
changeset
|
810 enemy.set_anim(default as u8); |
838d9402b12f
Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
665
diff
changeset
|
811 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
|
812 }; |
838d9402b12f
Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
665
diff
changeset
|
813 } |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
814 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
815 // 99 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
816 SubInstruction::SetAuxAnims(number, script) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
817 assert!(7 < number); |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
818 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
|
819 enemy.set_aux_anm(number, script) |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
820 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
821 */ |
661
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
822 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
823 // 100 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
824 SubInstruction::SetDeathAnim(index) => { |
673
81ad01910f4b
ecl_vm: instr 100 fix.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
672
diff
changeset
|
825 // 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
|
826 // To reverse! |
661
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
827 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
|
828 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
|
829 } |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
830 // 101 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
831 SubInstruction::SetBossMode(value) => { |
716
5016c09e5d7c
Fix some warnings.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
711
diff
changeset
|
832 let enemy = self.enemy.borrow_mut(); |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
833 if value < 0 { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
834 enemy.set_boss(false); |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
835 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
836 else { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
837 // 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
|
838 // 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
|
839 enemy.set_boss(true); |
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 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
843 // 102 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
844 // TODO: title says it all |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
845 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
846 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
|
847 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
848 */ |
661
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
849 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
850 // 103 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
851 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
|
852 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
|
853 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
|
854 } |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
855 |
674
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
856 // 104 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
857 SubInstruction::SetCollidable(collidable) => { |
681
1209e7f855a4
ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
678
diff
changeset
|
858 // 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
|
859 // 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
|
860 // 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
|
861 // 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
|
862 // 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
|
863 let mut enemy = self.enemy.borrow_mut(); |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
864 enemy.collidable = (collidable&1) != 0; |
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 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
867 // 105 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
868 SubInstruction::SetDamageable(damageable) => { |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
869 let mut enemy = self.enemy.borrow_mut(); |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
870 enemy.damageable = (damageable&1) != 0; |
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 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
873 // 106 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
874 SubInstruction::PlaySound(index) => { |
716
5016c09e5d7c
Fix some warnings.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
711
diff
changeset
|
875 let enemy = self.enemy.borrow_mut(); |
674
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
876 enemy.play_sound(index); |
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 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
879 // 107 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
880 SubInstruction::SetDeathFlags(death_flags) => { |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
881 let mut enemy = self.enemy.borrow_mut(); |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
882 enemy.death_flags = death_flags; |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
883 } |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
884 // 108 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
885 SubInstruction::SetDeathCallback(sub) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
886 let mut enemy = self.enemy.borrow_mut(); |
698
05e0425a8bc5
ecl_vm: enable SetDeathCallback.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
697
diff
changeset
|
887 enemy.death_callback = Some(sub); |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
888 } |
674
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
889 |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
890 // 109 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
891 SubInstruction::MemoryWriteInt(value, index) => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
892 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
|
893 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
894 |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
895 // 110 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
896 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
897 SubInstruction::KillEnemy(enemy) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
898 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
|
899 game.kill_enemy(enemy); |
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 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
903 // 111 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
904 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
905 SubInstruction::SetLife(value) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
906 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
|
907 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
|
908 enemy.life = value; |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
909 game.interface.set_boss_life(); |
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 */ |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
912 // 112 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
913 SubInstruction::SetElapsedTime(value) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
914 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
|
915 enemy.frame = value as u32; |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
916 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
917 // 113 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
918 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
919 SubInstruction::SetLowLifeTrigger(value) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
920 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
|
921 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
|
922 enemy.low_life_trigger = value; |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
923 game.interface.set_spell_life(); |
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 */ |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
926 // 114 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
927 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
928 SubInstruction::SetLowLifeCallback(sub) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
929 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
|
930 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
|
931 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
932 */ |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
933 // 115 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
934 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
935 SubInstruction::SetTimeout(timeout) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
936 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
|
937 enemy.frame = value; |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
938 enemy.timeout = timeout; |
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 */ |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
941 // 116 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
942 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
943 SubInstruction::SetTimeoutCallback(sub) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
944 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
|
945 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
|
946 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
947 */ |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
948 |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
949 |
681
1209e7f855a4
ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
678
diff
changeset
|
950 // 117 |
1209e7f855a4
ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
678
diff
changeset
|
951 SubInstruction::SetTouchable(touchable) => { |
1209e7f855a4
ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
678
diff
changeset
|
952 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
|
953 enemy.touchable = touchable != 0; |
1209e7f855a4
ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
678
diff
changeset
|
954 } |
1209e7f855a4
ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
678
diff
changeset
|
955 |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
956 // 121 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
957 // Here lies the Di Sword of sadness |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
958 SubInstruction::CallSpecialFunction(function, arg) => { |
718
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
959 match function { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
960 0 => { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
961 let mut enemy = self.enemy.borrow_mut(); |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
962 let game = enemy.game.upgrade().unwrap(); |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
963 let mut game = game.borrow_mut(); |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
964 //game.drop_particle(12, enemy.pos, 1, 0xffffffff); |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
965 //game.iter_bullets(|mut bullet| { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
966 for bullet in game.bullets.iter() { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
967 //game.new_effect(bullet.sprite, TODO); |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
968 let mut bullet = bullet.borrow_mut(); |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
969 if arg == 0 { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
970 bullet.speed = 0.; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
971 bullet.dpos = [0., 0., 0.]; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
972 } else if arg == 1 { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
973 bullet.flags |= 0x10; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
974 bullet.frame = 220; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
975 let rand_angle = game.prng.borrow_mut().get_f64() * 2. * std::f64::consts::PI - std::f64::consts::PI; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
976 bullet.attributes[0] = (rand_angle.cos() * 0.01) as f32; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
977 bullet.attributes[1] = (rand_angle.sin() * 0.01) as f32; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
978 } |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
979 } |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
980 } |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
981 1 => { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
982 let range_x = arg as f64; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
983 let range_y = (arg as f32 * 0.75) as f64; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
984 let rand_x = self.get_prng().borrow_mut().get_f64(); |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
985 let rand_y = self.get_prng().borrow_mut().get_f64(); |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
986 let mut enemy = self.enemy.borrow_mut(); |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
987 let pos = [rand_x * range_x + enemy.pos.x as f64 - range_x / 2., |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
988 rand_y * range_y + enemy.pos.x as f64 - range_y / 2.]; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
989 enemy.bullet_attributes.fire(); |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
990 } |
723
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
991 3 => { // Patchouli’s dual sign spellcard selector |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
992 let mut enemy = self.enemy.borrow_mut(); |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
993 let mut knowledge: [[i32; 3]; 4] = |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
994 [[0, 3, 1], |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
995 [2, 3, 4], |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
996 [1, 4, 0], |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
997 [4, 2, 3]]; |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
998 |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
999 //TODO: implement select_player and replace character by the correct one |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1000 //let character = enemy.select_player().character; |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1001 let character = 0; |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1002 for i in 1..=3 { |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1003 self.frame.ints1[i] = knowledge[character][i]; |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1004 } |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1005 } |
722
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1006 8 => { // Vampire Fantasy |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1007 /* |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1008 let mut n = 0: |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1009 for bullet in game.bullets{ |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1010 if bullet._bullet_type.state != 0 && bullet._bullet_type.state != 5 && (30. <= (bullet.sprites[0].additional_infos)->height) { |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1011 local_5c.pos[0] = local_bullet_vec->pos[0]; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1012 local_5c.pos[1] = local_bullet_vec->pos[1]; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1013 local_5c.pos[2] = local_bullet_vec->pos[2]; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1014 local_5c.anim = 3; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1015 local_5c.sprite_index_offset = 1; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1016 fVar3 = prng_double(&PRNG_STATE); |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1017 local_5c.launch_angle = (self.get_prng().borrow_mut().get_f64() * (2. * std::f64::consts::PI) - std::f64::consts::PI) as f32; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1018 local_5c.speed = 0.00000000; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1019 local_5c.bullets_per_shot = 1; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1020 local_5c.nb_of_shots = 1; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1021 local_5c.flags = 8; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1022 local_5c.bullet_type = 1; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1023 bullet_fire(&local_5c,&ETAMA_ARRAY); |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1024 } |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1025 n += 1 |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1026 } |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1027 //TODO: this variable might not always be correct! it uses the argument in |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1028 //th06: *(int *)(param_1 + 0x9b0) = local_60; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1029 self._setval(-10004, n) |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1030 */ |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1031 } |
721
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1032 14 => { // Lävatein |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1033 let mut enemy = self.enemy.borrow_mut(); |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1034 self.frame.ints1[3] = 0; |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1035 for laser in enemy.laser_by_id.values() { |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1036 //for pos in laser.get_bullets_pos(){ |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1037 //TODO: the game checks for laser end_offset before firing |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1038 // enemy.fire(launch_pos=pos); |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1039 //} |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1040 self.frame.ints1[3] += 1; |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1041 } |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1042 } |
720
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1043 16 => { // QED: Ripples of 495 years |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1044 let mut enemy = self.enemy.borrow_mut(); |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1045 let game = enemy.game.upgrade().unwrap(); |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1046 let mut game = game.borrow_mut(); |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1047 if arg == 0 { |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1048 self.frame.floats[3] = 2. - (enemy.life as f32) / 6000.; |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1049 self.frame.ints2[1] = ((enemy.life * 240) / 6000 + 40) as i32; |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1050 } else { |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1051 let fx = (320. - ((enemy.life as f32) * 160.) / 6000.) as f64; |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1052 let fy = (128. - ((enemy.life as f32) * 64.) / 6000.) as f64; |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1053 let rand_x = game.prng.borrow_mut().get_f64(); |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1054 let rand_y = game.prng.borrow_mut().get_f64(); |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1055 self.frame.floats[2] = (rand_x * fx + (192. - fx / 2.)) as f32; |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1056 self.frame.floats[3] = (rand_y * fy + (96. - fy / 2.)) as f32; |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1057 } |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1058 } |
718
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
1059 _ => unimplemented!("spellcards are a bitch and a half") |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
1060 } |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
1061 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
1062 |
678
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
1063 _ => 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
|
1064 } |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
1065 } |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
1066 } |
695
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1067 |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1068 #[cfg(test)] |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1069 mod tests { |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1070 use super::*; |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1071 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
|
1072 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
|
1073 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
|
1074 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
|
1075 use std::fs::File; |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1076 |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1077 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
|
1078 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
|
1079 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
|
1080 let mut buf = vec![]; |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1081 file.read_to_end(&mut buf).unwrap(); |
701
b6c351ca0a35
anm0: return the nom IResult and the list of Anm0s.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
699
diff
changeset
|
1082 let (_, mut anms) = Anm0::from_slice(&buf).unwrap(); |
b6c351ca0a35
anm0: return the nom IResult and the list of Anm0s.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
699
diff
changeset
|
1083 let anm0 = anms.pop().unwrap(); |
695
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1084 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
|
1085 let prng = Rc::new(RefCell::new(Prng::new(0))); |
703
81232dac8136
ecl: simplify parsing with more combinators.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
701
diff
changeset
|
1086 let game = Game::new(prng, Rank::EASY); |
695
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1087 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
|
1088 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
|
1089 (game, enemy) |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1090 } |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1091 |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1092 #[test] |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1093 fn call_and_return() { |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1094 let (game, enemy) = setup(); |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1095 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
|
1096 Sub { instructions: vec![ |
703
81232dac8136
ecl: simplify parsing with more combinators.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
701
diff
changeset
|
1097 CallSub::new(0, Rank::EASY, SubInstruction::Call(1, 13, 12.)), |
695
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1098 ]}, |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1099 Sub { instructions: vec![ |
703
81232dac8136
ecl: simplify parsing with more combinators.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
701
diff
changeset
|
1100 CallSub::new(0, Rank::EASY, SubInstruction::Noop()), |
81232dac8136
ecl: simplify parsing with more combinators.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
701
diff
changeset
|
1101 CallSub::new(1, Rank::EASY, SubInstruction::Return()), |
695
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1102 ]}, |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1103 ]}; |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1104 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
|
1105 ecl_runner.run_frame(); |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1106 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
|
1107 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
|
1108 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
|
1109 ecl_runner.run_frame(); |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1110 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
|
1111 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
|
1112 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
|
1113 } |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1114 } |