Mercurial > touhou
annotate src/th06/ecl_vm.rs @ 732:5f00b2e0c06a
ecl_vm: remilia lasers done
author | Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com> |
---|---|
date | Sun, 03 Nov 2019 02:07:18 +0100 |
parents | ca46b4312df1 |
children | 770e5057f6bc |
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 */ |
728
414f8611f344
ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
725
diff
changeset
|
682 |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
683 // 84 |
728
414f8611f344
ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
725
diff
changeset
|
684 SubInstruction::SetBulletSound(sound) => { |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
685 let mut enemy = self.enemy.borrow_mut(); |
728
414f8611f344
ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
725
diff
changeset
|
686 if sound < 0 { |
414f8611f344
ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
725
diff
changeset
|
687 enemy.bullet_attributes.sound = None; |
414f8611f344
ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
725
diff
changeset
|
688 } else { |
414f8611f344
ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
725
diff
changeset
|
689 // This assert isn’t part of the original engine, but it would crash on high |
414f8611f344
ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
725
diff
changeset
|
690 // values anyway. |
414f8611f344
ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
725
diff
changeset
|
691 assert!(sound <= 255); |
414f8611f344
ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
725
diff
changeset
|
692 enemy.bullet_attributes.sound = Some(sound as u8); |
414f8611f344
ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
725
diff
changeset
|
693 } |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
694 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
695 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
696 // 85-86 ire newlaser functions |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
697 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
698 // 87 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
699 SubInstruction::SetUpcomingLaserId(laser_id) => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
700 let mut enemy = self.enemy.borrow_mut(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
701 enemy.current_laser_id = laser_id; |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
702 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
703 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
704 // 88 |
684
c8bb28961d31
ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
683
diff
changeset
|
705 /* |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
706 SubInstruction::AlterLaserAngle(laser_id, delta) => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
707 let mut enemy = self.enemy.borrow_mut(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
708 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
|
709 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
|
710 laser.angle += self.get_f32(delta); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
711 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
712 } |
684
c8bb28961d31
ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
683
diff
changeset
|
713 */ |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
714 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
715 // 89 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
716 /* |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
717 SubInstruction::AlterLaserAnglePlayer(laser_id, delta) => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
718 let mut enemy = self.enemy.borrow_mut(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
719 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
|
720 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
|
721 let player = enemy.select_player(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
722 laser.angle = enemy.get_angle(player) + angle; |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
723 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
724 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
725 */ |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
726 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
727 // 90 |
684
c8bb28961d31
ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
683
diff
changeset
|
728 /* |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
729 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
730 let mut enemy = self.enemy.borrow_mut(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
731 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
|
732 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
|
733 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
|
734 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
735 } |
684
c8bb28961d31
ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
683
diff
changeset
|
736 */ |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
737 // 91 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
738 // wat |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
739 SubInstruction::LaserSetCompare(laser_id) => { |
716
5016c09e5d7c
Fix some warnings.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
711
diff
changeset
|
740 let enemy = self.enemy.borrow_mut(); |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
741 // 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
|
742 // 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
|
743 // 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
|
744 // 1/100000 chance to continue, otherwise crash |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
745 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
|
746 // 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
|
747 self.frame.comparison_reg = 1; |
683
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 else{ |
696
7ae576a418ff
ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
695
diff
changeset
|
750 self.frame.comparison_reg = 0; |
683
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 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
753 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
754 // 92 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
755 /* |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
756 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
757 let mut enemy = self.enemy.borrow_mut(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
758 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
|
759 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
|
760 laser.cancel(); |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
761 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
762 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
763 */ |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
764 // 93 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
765 // TODO: actually implement that hell |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
766 SubInstruction::SetSpellcard(face, number, name) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
767 unimplemented!("spellcard start"); |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
768 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
769 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
770 // 94 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
771 SubInstruction::EndSpellcard() => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
772 unimplemented!("spellcard end"); |
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 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
775 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
776 // 95 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
777 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
778 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
|
779 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
|
780 self.get_f32(y), |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
781 self.get_f32(z), |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
782 life, bonus_dropped, die_score) |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
783 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
784 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
785 */ |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
786 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
787 |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
788 // 96 |
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 SubInstruction::KillEnemies() => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
791 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
|
792 game.kill_enemies(); |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
793 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
794 */ |
682
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
795 |
d6cc9086058c
ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
681
diff
changeset
|
796 |
653
16aa9a636d35
Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff
changeset
|
797 |
661
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
798 // 97 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
799 SubInstruction::SetAnim(index) => { |
672
d20cf9ede914
Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
666
diff
changeset
|
800 // 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
|
801 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
|
802 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
|
803 } |
666
838d9402b12f
Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
665
diff
changeset
|
804 // 98 |
838d9402b12f
Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
665
diff
changeset
|
805 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
|
806 // _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
|
807 // assigns it 0xff |
d20cf9ede914
Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
666
diff
changeset
|
808 // 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
|
809 // 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
|
810 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
|
811 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
|
812 None |
838d9402b12f
Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
665
diff
changeset
|
813 } else { |
838d9402b12f
Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
665
diff
changeset
|
814 enemy.set_anim(default as u8); |
838d9402b12f
Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
665
diff
changeset
|
815 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
|
816 }; |
838d9402b12f
Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
665
diff
changeset
|
817 } |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
818 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
819 // 99 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
820 SubInstruction::SetAuxAnims(number, script) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
821 assert!(7 < number); |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
822 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
|
823 enemy.set_aux_anm(number, script) |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
824 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
825 */ |
661
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
826 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
827 // 100 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
828 SubInstruction::SetDeathAnim(index) => { |
673
81ad01910f4b
ecl_vm: instr 100 fix.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
672
diff
changeset
|
829 // 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
|
830 // To reverse! |
661
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
831 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
|
832 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
|
833 } |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
834 // 101 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
835 SubInstruction::SetBossMode(value) => { |
716
5016c09e5d7c
Fix some warnings.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
711
diff
changeset
|
836 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
|
837 if value < 0 { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
838 enemy.set_boss(false); |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
839 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
840 else { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
841 // 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
|
842 // 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
|
843 enemy.set_boss(true); |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
844 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
845 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
846 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
847 // 102 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
848 // TODO: title says it all |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
849 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
850 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
|
851 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
852 */ |
661
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
853 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
854 // 103 |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
855 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
|
856 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
|
857 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
|
858 } |
598f3125cbac
Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
660
diff
changeset
|
859 |
674
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
860 // 104 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
861 SubInstruction::SetCollidable(collidable) => { |
681
1209e7f855a4
ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
678
diff
changeset
|
862 // 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
|
863 // 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
|
864 // 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
|
865 // 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
|
866 // 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
|
867 let mut enemy = self.enemy.borrow_mut(); |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
868 enemy.collidable = (collidable&1) != 0; |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
869 } |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
870 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
871 // 105 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
872 SubInstruction::SetDamageable(damageable) => { |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
873 let mut enemy = self.enemy.borrow_mut(); |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
874 enemy.damageable = (damageable&1) != 0; |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
875 } |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
876 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
877 // 106 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
878 SubInstruction::PlaySound(index) => { |
716
5016c09e5d7c
Fix some warnings.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
711
diff
changeset
|
879 let enemy = self.enemy.borrow_mut(); |
674
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
880 enemy.play_sound(index); |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
881 } |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
882 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
883 // 107 |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
884 SubInstruction::SetDeathFlags(death_flags) => { |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
885 let mut enemy = self.enemy.borrow_mut(); |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
886 enemy.death_flags = death_flags; |
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
887 } |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
888 // 108 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
889 SubInstruction::SetDeathCallback(sub) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
890 let mut enemy = self.enemy.borrow_mut(); |
698
05e0425a8bc5
ecl_vm: enable SetDeathCallback.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
697
diff
changeset
|
891 enemy.death_callback = Some(sub); |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
892 } |
674
3e4cc64a254d
ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
673
diff
changeset
|
893 |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
894 // 109 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
895 SubInstruction::MemoryWriteInt(value, index) => { |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
896 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
|
897 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
898 |
685
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
899 // 110 |
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 SubInstruction::KillEnemy(enemy) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
902 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
|
903 game.kill_enemy(enemy); |
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 */ |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
906 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
907 // 111 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
908 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
909 SubInstruction::SetLife(value) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
910 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
|
911 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
|
912 enemy.life = value; |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
913 game.interface.set_boss_life(); |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
914 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
915 */ |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
916 // 112 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
917 SubInstruction::SetElapsedTime(value) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
918 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
|
919 enemy.frame = value as u32; |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
920 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
921 // 113 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
922 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
923 SubInstruction::SetLowLifeTrigger(value) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
924 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
|
925 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
|
926 enemy.low_life_trigger = value; |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
927 game.interface.set_spell_life(); |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
928 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
929 */ |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
930 // 114 |
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 SubInstruction::SetLowLifeCallback(sub) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
933 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
|
934 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
|
935 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
936 */ |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
937 // 115 |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
938 /* |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
939 SubInstruction::SetTimeout(timeout) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
940 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
|
941 enemy.frame = value; |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
942 enemy.timeout = timeout; |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
943 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
944 */ |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
945 // 116 |
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 SubInstruction::SetTimeoutCallback(sub) => { |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
948 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
|
949 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
|
950 } |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
951 */ |
11d7e4d6947a
ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
684
diff
changeset
|
952 |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
953 |
681
1209e7f855a4
ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
678
diff
changeset
|
954 // 117 |
1209e7f855a4
ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
678
diff
changeset
|
955 SubInstruction::SetTouchable(touchable) => { |
1209e7f855a4
ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
678
diff
changeset
|
956 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
|
957 enemy.touchable = touchable != 0; |
1209e7f855a4
ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
678
diff
changeset
|
958 } |
1209e7f855a4
ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
678
diff
changeset
|
959 |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
960 // 121 |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
961 // Here lies the Di Sword of sadness |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
962 SubInstruction::CallSpecialFunction(function, arg) => { |
718
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
963 match function { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
964 0 => { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
965 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
|
966 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
|
967 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
|
968 //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
|
969 //game.iter_bullets(|mut bullet| { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
970 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
|
971 //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
|
972 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
|
973 if arg == 0 { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
974 bullet.speed = 0.; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
975 bullet.dpos = [0., 0., 0.]; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
976 } else if arg == 1 { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
977 bullet.flags |= 0x10; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
978 bullet.frame = 220; |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
979 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
|
980 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
|
981 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
|
982 } |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
983 } |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
984 } |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
985 1 => { |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
986 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
|
987 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
|
988 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
|
989 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
|
990 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
|
991 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
|
992 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
|
993 enemy.bullet_attributes.fire(); |
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
994 } |
723
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
995 3 => { // Patchouli’s dual sign spellcard selector |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
996 let mut enemy = self.enemy.borrow_mut(); |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
997 let mut knowledge: [[i32; 3]; 4] = |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
998 [[0, 3, 1], |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
999 [2, 3, 4], |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1000 [1, 4, 0], |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1001 [4, 2, 3]]; |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1002 |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1003 //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
|
1004 //let character = enemy.select_player().character; |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1005 let character = 0; |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1006 for i in 1..=3 { |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1007 self.frame.ints1[i] = knowledge[character][i]; |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1008 } |
420cec4005b5
ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
722
diff
changeset
|
1009 } |
732
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1010 7 => { // Remilia's lazer maze |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1011 // so what this does is kinda complex: 2 rounds of 3 subrounds of 8 shots, either |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1012 // laser or standard bullets depending on the argument passed. |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1013 // it is done in 2 steps: first we precalculate coordinates of the 8 shots for the first subround |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1014 // set the shot properties depending on difficulties and current round and then |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1015 // edit the coordinates for the next round |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1016 let rnd_pos = self.get_prng().borrow_mut().get_f64() * 2. * std::f64::consts::PI; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1017 let enemy = self.enemy.borrow(); |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1018 for i in 0..2 { |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1019 let mut pos: [f64; 8*3] = [0.; 8*3]; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1020 let mut offset = rnd_pos -((std::f64::consts::PI/8.)*7.); |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1021 let mut next_offset = -std::f64::consts::PI/4.; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1022 if (i == 0) { |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1023 offset = rnd_pos -std::f64::consts::PI; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1024 next_offset = std::f64::consts::PI/4.; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1025 } |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1026 |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1027 // we calculate angle, speed and offset for the 8 shots |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1028 let mut offset_copy=offset; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1029 for y in 0..8 { |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1030 pos[y * 3] = offset_copy.cos() * 32. + enemy.pos.x as f64; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1031 pos[y * 3 + 1] = offset_copy.sin() * 32. + enemy.pos.y as f64; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1032 pos[y * 3 + 2] = enemy.z as f64; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1033 offset_copy += std::f64::consts::PI/4.; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1034 } |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1035 |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1036 // 3 rounds of 8 shots |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1037 for z in 0..3 { |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1038 |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1039 let mut length = 112.; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1040 // last subround |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1041 if (z == 2) {length = 480.;} |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1042 |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1043 for y in 0..8 { |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1044 /* |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1045 if (arg == 0) { |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1046 let (mut si, mut ged, mut ed) = (8, 20.,ed=430.); |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1047 if (LEVEL.rank < 2) {si=2; ged=28.; ed=length;} |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1048 laser_args.angle = pos[y * 3]; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1049 laser_args.speed = pos[y * 3 + 1]; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1050 laser_args.start_offset = pos[y * 3 + 2]; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1051 laser_args.type = 1; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1052 laser_args.sprite_index_offset = si; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1053 laser_args.end_offset = offset; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1054 laser_args.width = 0.; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1055 laser_args.duration = 0; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1056 laser_args.grazing_extra_duration = ged; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1057 laser_args.end_duration = ed; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1058 laser_args.UNK1 = z * 0x10 + 0x3c; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1059 laser_args.grazing_delay = laser_args.end_duration; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1060 fire_laser(&ETAMA_ARRAY,&laser_args); |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1061 } |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1062 else { |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1063 (enemy->bullet_attributes).pos[0] = pos[y * 3]; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1064 (enemy->bullet_attributes).pos[1] = pos[y*3+1]; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1065 (enemy->bullet_attributes).pos[2] = pos[y*3+2]; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1066 bullet_fire(&enemy->bullet_attributes,&ETAMA_ARRAY); |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1067 } |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1068 */ |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1069 pos[y * 3] = offset.cos() * length + pos[y * 3]; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1070 pos[y * 3 + 1] = offset.sin() * length + pos[y * 3 + 1]; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1071 offset = offset + std::f64::consts::PI/4.; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1072 } |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1073 offset = (next_offset - 2.*std::f64::consts::PI) + offset; |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1074 } |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1075 } |
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1076 } |
722
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1077 8 => { // Vampire Fantasy |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1078 /* |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1079 let mut n = 0: |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1080 for bullet in game.bullets{ |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1081 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
|
1082 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
|
1083 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
|
1084 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
|
1085 local_5c.anim = 3; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1086 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
|
1087 fVar3 = prng_double(&PRNG_STATE); |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1088 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
|
1089 local_5c.speed = 0.00000000; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1090 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
|
1091 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
|
1092 local_5c.flags = 8; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1093 local_5c.bullet_type = 1; |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1094 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
|
1095 } |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1096 n += 1 |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1097 } |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1098 //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
|
1099 //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
|
1100 self._setval(-10004, n) |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1101 */ |
e71ea8214ee2
ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
721
diff
changeset
|
1102 } |
732
5f00b2e0c06a
ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
731
diff
changeset
|
1103 |
731
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1104 9 => { |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1105 let mut rnd = self.get_prng().borrow_mut().get_f64(); |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1106 //TODO: the game does that |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1107 //drop_particle(&PARTICLES_ARRAY,0xc,enemy->pos,1,0xffffffff); |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1108 //self._game.new_effect((enemy.x, enemy.y), 17) |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1109 /* |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1110 for bullet in game.bullets { |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1111 if bullet._bullet_type.state != 0 && bullet._bullet_type.state != 5 && (30. <= (bullet.sprites[0].additional_infos)->height) && bullet.speed == 0. { |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1112 bullet.flags = bullet.flags | 0x10; |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1113 //TODO: reverse this field and effect |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1114 bullet->field_0x5ba = 2; |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1115 new_effect(GAME_OBJECT,(sprite *)bullet, (int)bullet->sprites[0].sometimes_copy_of_UNK1 + (int)bullet->field_0x5ba); |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1116 bullet.speed=0.01; |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1117 bullet.frame=0x78; |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1118 |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1119 let mut dx = bullet.x - enemy.x; |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1120 let mut distance = dx.hypot(bullet.y - enemy.y); |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1121 |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1122 if distance > 0.01 { |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1123 distance = sqrt(distance); |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1124 }else{distance = 0.;} |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1125 let mut angle = (distance * std::f64::consts::PI) / 256. + (rnd * (2*std::f64::consts::PI) - std::f64::consts::PI); |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1126 bullet->attributes[0] = cos(angle) * 0.01000000; |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1127 bullet->attributes[1] = sin(angle) * 0.01000000; |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1128 } |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1129 } |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1130 */ |
ca46b4312df1
ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
728
diff
changeset
|
1131 } |
725
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1132 11 => { |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1133 self.get_prng().borrow_mut().get_f64(); |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1134 //TODO: the game does that |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1135 //drop_particle(&PARTICLES_ARRAY,0xc,enemy->pos,1,0xffffffff); |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1136 //self._game.new_effect((enemy.x, enemy.y), 17) |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1137 /* |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1138 for bullet in game.bullets { |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1139 if bullet._bullet_type.state != 0 && bullet._bullet_type.state != 5 && (30. <= (bullet.sprites[0].additional_infos)->height) && bullet.speed == 0. { |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1140 bullet.flags = bullet.flags | 0x10; |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1141 //TODO: reverse this field and effect |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1142 bullet->field_0x5ba = 2; |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1143 new_effect(GAME_OBJECT,(sprite *)bullet, (int)bullet->sprites[0].sometimes_copy_of_UNK1 + (int)bullet->field_0x5ba); |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1144 bullet.speed=0.01; |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1145 bullet.frame=0x78; |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1146 let mut angle = self.get_prng().borrow_mut().get_f64() * (2*std::f64::consts::PI) - std::f64::consts::PI; |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1147 bullet->attributes[0] = cos(angle) * 0.01000000; |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1148 bullet->attributes[1] = sin(angle) * 0.01000000; |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1149 |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1150 |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1151 } |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1152 } |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1153 */ |
fbf89cba04e2
ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
724
diff
changeset
|
1154 } |
724
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1155 13 => { |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1156 if self.frame.ints1[3] % 6 == 0 { |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1157 let mut _angle=self.frame.floats[2]; |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1158 /* |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1159 (type_, anim, sprite_idx_offset, bullets_per_shot, number_of_shots, |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1160 speed, speed2, launch_angle, angle, flags) = self._enemy.bullet_attributes |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1161 for i in range(arg) { |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1162 //TODO: distance is obtained directly by copying bullet attributes |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1163 //in memory |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1164 launch_pos = (192 + cos(_angle) * _distance, |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1165 224 + sin(_angle) * _distance); |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1166 |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1167 bullet_attributes = (type_, anim, sprite_idx_offset, |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1168 bullets_per_shot, number_of_shots, |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1169 speed, speed2, |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1170 _angle + self.frame.floats[1], angle, flags); |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1171 enemy.fire(launch_pos=launch_pos,bullet_attributes=bullet_attributes); |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1172 _angle += 2*std::f64::consts::PI/arg; |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1173 }*/ |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1174 } |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1175 self.frame.ints1[3] += 1; |
8acaf45b47d0
ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
723
diff
changeset
|
1176 } |
721
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1177 14 => { // Lävatein |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1178 let mut enemy = self.enemy.borrow_mut(); |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1179 self.frame.ints1[3] = 0; |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1180 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
|
1181 //for pos in laser.get_bullets_pos(){ |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1182 //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
|
1183 // enemy.fire(launch_pos=pos); |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1184 //} |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1185 self.frame.ints1[3] += 1; |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1186 } |
bbf0da7de481
ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
720
diff
changeset
|
1187 } |
720
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1188 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
|
1189 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
|
1190 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
|
1191 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
|
1192 if arg == 0 { |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1193 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
|
1194 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
|
1195 } else { |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1196 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
|
1197 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
|
1198 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
|
1199 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
|
1200 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
|
1201 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
|
1202 } |
cffb0f1531fc
ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
718
diff
changeset
|
1203 } |
718
c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
716
diff
changeset
|
1204 _ => 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
|
1205 } |
683
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
1206 } |
8c50a7b19425
ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
682
diff
changeset
|
1207 |
678
1d81a449c436
Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
674
diff
changeset
|
1208 _ => 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
|
1209 } |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
1210 } |
31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
659
diff
changeset
|
1211 } |
695
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1212 |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1213 #[cfg(test)] |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1214 mod tests { |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1215 use super::*; |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1216 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
|
1217 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
|
1218 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
|
1219 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
|
1220 use std::fs::File; |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1221 |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1222 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
|
1223 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
|
1224 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
|
1225 let mut buf = vec![]; |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1226 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
|
1227 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
|
1228 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
|
1229 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
|
1230 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
|
1231 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
|
1232 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
|
1233 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
|
1234 (game, enemy) |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1235 } |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1236 |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1237 #[test] |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1238 fn call_and_return() { |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1239 let (game, enemy) = setup(); |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1240 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
|
1241 Sub { instructions: vec![ |
703
81232dac8136
ecl: simplify parsing with more combinators.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
701
diff
changeset
|
1242 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
|
1243 ]}, |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1244 Sub { instructions: vec![ |
703
81232dac8136
ecl: simplify parsing with more combinators.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
701
diff
changeset
|
1245 CallSub::new(0, Rank::EASY, SubInstruction::Noop()), |
81232dac8136
ecl: simplify parsing with more combinators.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
701
diff
changeset
|
1246 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
|
1247 ]}, |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1248 ]}; |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1249 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
|
1250 ecl_runner.run_frame(); |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1251 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
|
1252 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
|
1253 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
|
1254 ecl_runner.run_frame(); |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1255 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
|
1256 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
|
1257 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
|
1258 } |
f5b34a1c2707
ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
693
diff
changeset
|
1259 } |