annotate interpreters/src/th06/ecl.rs @ 769:cae5f15ca5ed

formats: Fix possible panic in PBG3 checksum check
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 30 Aug 2022 18:22:53 +0200
parents 21b186be2590
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
1 //! ECL runner.
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
2
757
21b186be2590 Split the Rust version into multiple crates.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 739
diff changeset
3 use touhou_formats::th06::ecl::{Ecl, SubInstruction};
739
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
4 use crate::th06::enemy::{Enemy, Offset, BulletAttributes, Position};
757
21b186be2590 Split the Rust version into multiple crates.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 739
diff changeset
5 use touhou_utils::prng::Prng;
653
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 {
738
817c453b7223 stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 737
diff changeset
42 /// XXX
817c453b7223 stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 737
diff changeset
43 pub enemy: Rc<RefCell<Enemy>>,
817c453b7223 stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 737
diff changeset
44
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
45 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
46 /// XXX
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
47 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
48 frame: StackFrame,
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
49 // 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
50 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
51 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
52
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
53 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
54 /// 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
55 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
56 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
57 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
58 // 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
59 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
60 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
61 ..Default::default()
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
62 };
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
63 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
64 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
65 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
66
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
67 /// 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
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 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
76 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
77 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
78 };
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
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
80 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
81 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
82 }
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
83 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
84
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 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
86 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
87 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
88 }
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
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
90 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
91 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
92 }
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 }
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
94 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
95 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
96
660
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 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
98 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
99 match var {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
100 -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
101 -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
102 -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
103 -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
104 -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
105 -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
106 -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
107 -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
108 -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
109 -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
110 -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
111 -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
112 -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
113 -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
114 -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
115 -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
116 -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
117 -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
118 -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
119 -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
120 -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
121 -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
122 -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
123 -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
124 -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
125 _ => 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
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 }
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
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 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
130 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
131 match var {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
132 -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
133 -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
134 -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
135 -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
136 -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
137 -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
138 -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
139 -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
140 -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
141 -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
142 -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
143 -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
144 -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
145 -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
146 -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
147 -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
148 -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
149 -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
150 -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
151 -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
152 -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
153 -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
154 -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
155 -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
156 -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
157 _ => 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
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 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
160
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
161 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
162 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
163 match var {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
164 -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
165 -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
166 -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
167 -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
168 -10005 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
169 -10006 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
170 -10007 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
171 -10008 => unimplemented!(),
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
172 -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
173 -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
174 -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
175 -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
176 -10013 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
177 -10014 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
178 -10015 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
179 -10016 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
180 -10017 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
181 -10018 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
182 -10019 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
183 -10020 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
184 -10021 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
185 -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
186 -10023 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
187 -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
188 -10025 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
189 _ => panic!("Unknown variable {}", var)
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
190 }
660
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 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
192
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
193 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
194 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
195 match var {
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
196 -10001.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
197 -10002.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
198 -10003.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
199 -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
200 -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
201 -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
202 -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
203 -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
204 -10009.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
205 -10010.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
206 -10011.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
207 -10012.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
208 -10013.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
209 -10014.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
210 -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
211 -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
212 -10017.0 => enemy.z = value,
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
213 -10018.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
214 -10019.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
215 -10020.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
216 -10021.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
217 -10022.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
218 -10023.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
219 -10024.0 => unimplemented!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
220 -10025.0 => unreachable!(),
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
221 _ => panic!("Unknown variable {}", var)
994f41154be8 Implement EclRunner::set_i32 and EclRunner::set_f32.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 661
diff changeset
222 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
223 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
224
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 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
226 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
227 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
228 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
229
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
230 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
231 println!("Running instruction {:?}", instruction);
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
232 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
233 SubInstruction::Noop() => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
234 // really
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
235 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
236 // 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
237 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
238 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
239 enemy.removed = true;
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
240 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
241 // 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
242 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
243 self.frame.frame = frame;
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
244 // 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
245 self.frame.ip = ip;
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
246 // 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
247 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
248 // 3
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
249 // 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
250 //
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
251 // 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
252 // CMP dword ptr [0x9d4 + ECX],0x0
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
253 // JLE LAB_00407abb
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
254 // aka ECX = enemy pointer
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
255 // 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
256 // 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
257 SubInstruction::RelativeJumpEx(frame, ip, var_id) => {
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
258 // 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
259 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
260 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
261 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
262 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
263 }
660
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 // 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
265 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
266 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
267 }
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 // 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
269 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
270 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
271 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
272 // 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
273 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
274 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
275 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
276 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
277 // 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
278 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
279 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
280 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
281 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
282 // 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
283 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
284 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
285 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
286 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
287 // 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
288 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
289 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
290 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
291 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
292 // 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
293 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
294 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
295 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
296 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
297 };
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
298 // 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
299 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
300 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
301 // 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
302 SubInstruction::StoreY(var_id) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
303 let y = {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
304 let enemy = self.enemy.borrow();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
305 enemy.pos.y
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
306 };
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
307 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
308 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
309 // 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
310 SubInstruction::StoreZ(var_id) => {
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
311 let z = {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
312 let enemy = self.enemy.borrow();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
313 enemy.z
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
314 };
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
315 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
316 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
317 // 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
318 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
319 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
320 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
321 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
322 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
323 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
324 // 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
325 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
326 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
327 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
328 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
329 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
330 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
331 // 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
332 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
333 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
334 }
660
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 /*
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 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
337 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
338 }
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 */
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
340 // 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
341 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
342 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
343 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
344
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
345 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
346 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
347 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
348
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
349 // 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
350 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
351 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
352 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
353
660
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 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
355 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
356 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
357
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
358 // 18
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
359 // 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
360 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
361 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
362 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
363
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
364 // 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
365 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
366 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
367 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
368
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
369 //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
370 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
371 //__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
372 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
373 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
374
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
375 // 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
376 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
377 // 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
378 // 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
379 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
380 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
381
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
382 // 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
383 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
384 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
385 let b = self.get_i32(b);
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
386 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
387 self.frame.comparison_reg = -1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
388 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
389 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
390 self.frame.comparison_reg = 0;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
391 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
392 else {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
393 self.frame.comparison_reg = 1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
394 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
395 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
396 SubInstruction::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
397 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
398 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
399 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
400 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
401 }
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 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
403 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
404 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
405 else {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
406 self.frame.comparison_reg = 1;
654
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
407 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
408 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
409 // 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
410 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
411 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
412 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
413 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
414 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
415 // 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
416 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
417 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
418 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
419 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
420 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
421 // 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
422 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
423 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
424 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
425 }
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 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
427 // 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
428 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
429 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
430 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
431 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
432 }
ec7e888e88f3 Up to instruction 34 validated.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 653
diff changeset
433 // 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
434 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
435 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
436 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
437 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
438 }
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
439 // 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
440 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
441 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
442 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
443 }
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
444 }
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
445 // 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
446 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
447 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
448 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
449 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
450 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
451 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
452 self.frame.ip = 0;
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
453 }
660
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
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
455 // 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
456 SubInstruction::Return() => {
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
457 self.frame = self.stack.pop().unwrap();
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
458 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
459 // 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
460 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
461 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
462 self.run_instruction(SubInstruction::Call(sub, param1, param2));
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
463 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
464 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
465 // 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
466 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
467 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
468 self.run_instruction(SubInstruction::Call(sub, param1, param2));
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
469 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
470 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
471 // 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
472 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
473 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
474 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
475 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
476 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
477 // 40
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
478 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
479 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
480 self.run_instruction(SubInstruction::Call(sub, param1, param2));
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
481 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
482 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
483
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
484 // 41
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
485 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
486 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
487 self.run_instruction(SubInstruction::Call(sub, param1, param2));
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
488 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
489 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
490 //42
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
491 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
492 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
493 self.run_instruction(SubInstruction::Call(sub, param1, param2));
655
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
494 }
6b4d2b405442 More ECL stuff.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 654
diff changeset
495 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
496
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
497 // 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
498 SubInstruction::SetPosition(x, y, z) => {
711
464c1b02a996 ecl_vm: Fix SetPosition.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 703
diff changeset
499 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
500 let mut enemy = self.enemy.borrow_mut();
711
464c1b02a996 ecl_vm: Fix SetPosition.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 703
diff changeset
501 enemy.set_pos(x, y, z);
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
502 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
503 // 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
504 /*
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
505 SubInstruction::SetAngularSpeed(x, y, z) => {
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
506 // 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
507 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
508 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
509 }
660
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 */
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
511 // 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
512 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
513 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
514 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
515 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
516 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
517 enemy.angle = angle;
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
518 enemy.speed = speed;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
519 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
520 // 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
521 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
522 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
523 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
524 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
525 enemy.rotation_speed = rotation_speed;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
526 }
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
527 // 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
528 SubInstruction::SetSpeed(speed) => {
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
529 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
530 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
531 enemy.update_mode = 0;
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
532 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
533 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
534 // 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
535 SubInstruction::SetAcceleration(acceleration) => {
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
536 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
537 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
538 enemy.update_mode = 0;
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
539 enemy.acceleration = acceleration;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
540 }
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
541 // 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
542 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
543 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
544 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
545 enemy.angle = angle;
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
546 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
547 // 51
693
14fddc27e6f5 ecl_vm: implement TargetPlayer, and add a dummy Player to Game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 692
diff changeset
548 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
549 let speed = self.get_f32(speed);
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
550 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
551 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
552 let player = game.borrow().get_player();
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
553 enemy.update_mode = 0;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
554 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
555 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
556 }
659
53786d834444 Yet more ecl.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 655
diff changeset
557
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
558 // 52 to 64 are different interlacing fields
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
559
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
560 // 65
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
561 // 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
562 // 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
563 // changed without setting a flag :)
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
564 SubInstruction::SetScreenBox(xmin, ymin, xmax, ymax) => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
565 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
566 enemy.screen_box = Some((xmin, ymin, xmax, ymax));
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
567 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
568 // 66
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
569 SubInstruction::ClearScreenBox() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
570 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
571 enemy.screen_box = None;
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
572 }
686
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
573
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
574 // 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
575 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
576 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
577 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
578 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
579 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
580 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
581 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
582 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
583 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
584 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
585 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
586 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
587 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
588 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
589 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
590 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
591 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
592 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
593 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
594 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
595 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
596 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
597 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
598 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
599 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
600 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
601 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
602 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
603 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
604 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
605 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
606 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
607 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
608 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
609 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
610 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
611 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
612 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
613 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
614 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
615 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
616 }
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
617 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
618 number_of_shots, speed, speed2, launch_angle,
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
619 angle, flags) => {
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
620 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
621 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
622 flags);
aefe5b5f481e ecl_vm: implement the SetBulletAttributes opcodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 685
diff changeset
623 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
624
688
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
625 // 76
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
626 SubInstruction::SetBulletInterval(interval) => {
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
627 let mut enemy = self.enemy.borrow_mut();
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
628 enemy.set_bullet_launch_interval(0, interval);
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
629 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
630
688
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
631 // 77
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
632 SubInstruction::SetBulletIntervalEx(interval) => {
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
633 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
634
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
635 let mut enemy = self.enemy.borrow_mut();
1adecaddf442 ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 686
diff changeset
636 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
637 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
638
736
ff9651cfe1b0 ecl_vm: Remove trailing whitespace.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 735
diff changeset
639 // 78-79 are more interpolation flags
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
640 // 78
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
641 SubInstruction::DelayAttack() => {
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
642 let mut enemy = self.enemy.borrow_mut();
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
643 enemy.delay_attack = true;
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
644 }
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
645 // 79
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
646 SubInstruction::NoDelayAttack() => {
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
647 let mut enemy = self.enemy.borrow_mut();
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
648 enemy.delay_attack = false;
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
649 }
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
650 // 80
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
651 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
652 SubInstruction::NoClue() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
653 let mut enemy = self.enemy.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
654 //bullet_pos = launch offset
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
655 (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
656 (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
657 (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
658 enemy.fire(bullet_attributes=bullet_attributes)
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
659 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
660 */
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
661
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
662 // 81
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
663 SubInstruction::SetBulletLaunchOffset(dx, dy, dz) => {
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
664 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
665 let mut enemy = self.enemy.borrow_mut();
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
666 enemy.bullet_offset = Offset { dx, dy };
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
667 }
690
eecb8626f472 ecl_vm: implement SetBulletLaunchOffset.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 688
diff changeset
668
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
669 // 82
691
f5d85a646975 ecl_vm: implement SetExtendedBulletAttributes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 690
diff changeset
670 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
671 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
672 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
673 let mut enemy = self.enemy.borrow_mut();
691
f5d85a646975 ecl_vm: implement SetExtendedBulletAttributes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 690
diff changeset
674 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
675 }
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
676
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
677 // 83
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
678 /*
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
679 SubInstruction::ChangeBulletsIntoStarBonus() => {
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
680 let mut game = self.game.borrow_mut();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
681 game.change_bullets_into_star_items();
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
682 }
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
683 */
728
414f8611f344 ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 725
diff changeset
684
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
685 // 84
728
414f8611f344 ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 725
diff changeset
686 SubInstruction::SetBulletSound(sound) => {
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
687 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
688 if sound < 0 {
414f8611f344 ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 725
diff changeset
689 enemy.bullet_attributes.sound = None;
414f8611f344 ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 725
diff changeset
690 } else {
414f8611f344 ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 725
diff changeset
691 // 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
692 // values anyway.
414f8611f344 ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 725
diff changeset
693 assert!(sound <= 255);
414f8611f344 ecl: Add support for bullet sounds, instruction 84.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 725
diff changeset
694 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
695 }
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
696 }
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 // 85-86 ire newlaser functions
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
699
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
700 // 87
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
701 SubInstruction::SetUpcomingLaserId(laser_id) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
702 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
703 enemy.current_laser_id = laser_id;
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
704 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
705
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
706 // 88
736
ff9651cfe1b0 ecl_vm: Remove trailing whitespace.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 735
diff changeset
707 /*
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
708 SubInstruction::AlterLaserAngle(laser_id, delta) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
709 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
710 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
711 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
712 laser.angle += self.get_f32(delta);
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
713 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
714 }
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
715 */
736
ff9651cfe1b0 ecl_vm: Remove trailing whitespace.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 735
diff changeset
716
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
717 // 89
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
718 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
719 SubInstruction::AlterLaserAnglePlayer(laser_id, delta) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
720 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
721 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
722 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
723 let player = enemy.select_player();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
724 laser.angle = enemy.get_angle(player) + angle;
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 */
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
728
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
729 // 90
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
730 /*
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
731 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
732 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
733 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
734 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
735 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
736 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
737 }
684
c8bb28961d31 ecl_vm: fixes for previous instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 683
diff changeset
738 */
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
739 // 91
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
740 // wat
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
741 SubInstruction::LaserSetCompare(laser_id) => {
716
5016c09e5d7c Fix some warnings.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 711
diff changeset
742 let enemy = self.enemy.borrow_mut();
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
743 // 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
744 // 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
745 // 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
746 // 1/100000 chance to continue, otherwise crash
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
747 if enemy.laser_by_id.contains_key(&laser_id) {
736
ff9651cfe1b0 ecl_vm: Remove trailing whitespace.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 735
diff changeset
748 // 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
749 self.frame.comparison_reg = 1;
736
ff9651cfe1b0 ecl_vm: Remove trailing whitespace.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 735
diff changeset
750 }
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
751 else{
696
7ae576a418ff ecl_vm: implement Call, Return, and the call stack thingy.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 695
diff changeset
752 self.frame.comparison_reg = 0;
683
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 }
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 // 92
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
757 /*
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
758 SubInstruction::RepositionLaser(laser_id, ox, oy, oz) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
759 let mut enemy = self.enemy.borrow_mut();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
760 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
761 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
762 laser.cancel();
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
763 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
764 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
765 */
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
766 // 93
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
767 // TODO: actually implement that hell
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
768 SubInstruction::SetSpellcard(face, number, name) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
769 unimplemented!("spellcard start");
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
770
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
771 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
772 // 94
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
773 SubInstruction::EndSpellcard() => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
774 unimplemented!("spellcard end");
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 }
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 // 95
739
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
779 SubInstruction::SpawnEnemy(sub, x, y, z, life, bonus, score) => {
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
780 let x = self.get_f32(x);
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
781 let y = self.get_f32(y);
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
782 let _z = self.get_f32(z);
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
783 let enemy = self.enemy.borrow_mut();
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
784 let anm0 = enemy.anm0.upgrade().unwrap();
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
785 let game = enemy.game.upgrade().unwrap();
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
786 let enemy = Enemy::new(Position::new(x, y), life, bonus, score as u32, false, Rc::downgrade(&anm0), Rc::downgrade(&game));
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
787 let ecl = self.ecl.clone().unwrap();
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
788 let mut runner = EclRunner::new(&ecl, enemy, sub as u16);
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
789 runner.run_frame();
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
790 }
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
791
736
ff9651cfe1b0 ecl_vm: Remove trailing whitespace.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 735
diff changeset
792 // 96
ff9651cfe1b0 ecl_vm: Remove trailing whitespace.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 735
diff changeset
793 /*
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
794 SubInstruction::KillEnemies() => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
795 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
796 game.kill_enemies();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
797 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
798 */
682
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
799
d6cc9086058c ecl_vm: more instructions
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 681
diff changeset
800
653
16aa9a636d35 Some starting point for ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents:
diff changeset
801
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
802 // 97
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
803 SubInstruction::SetAnim(index) => {
672
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
804 // 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
805 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
806 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
807 }
666
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
808 // 98
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
809 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
810 // _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
811 // assigns it 0xff
d20cf9ede914 Verified some more of ecl_vm.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 666
diff changeset
812 // 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
813 // 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
814 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
815 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
816 None
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
817 } else {
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
818 enemy.set_anim(default as u8);
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
819 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
820 };
838d9402b12f Implement ECL instruction 98, for directional sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 665
diff changeset
821 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
822 // 99
735
b9928db975e1 ecl: Enable instruction 99.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 734
diff changeset
823 SubInstruction::SetAuxAnm(number, script) => {
b9928db975e1 ecl: Enable instruction 99.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 734
diff changeset
824 assert!(number < 8);
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
825 let mut enemy = self.enemy.borrow_mut();
735
b9928db975e1 ecl: Enable instruction 99.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 734
diff changeset
826 enemy.set_aux_anm(number, script);
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
827 }
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
828
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
829 // 100
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
830 SubInstruction::SetDeathAnim(index) => {
673
81ad01910f4b ecl_vm: instr 100 fix.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 672
diff changeset
831 // 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
832 // To reverse!
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
833 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
834 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
835 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
836 // 101
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
837 SubInstruction::SetBossMode(value) => {
716
5016c09e5d7c Fix some warnings.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 711
diff changeset
838 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
839 if value < 0 {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
840 enemy.set_boss(false);
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
841 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
842 else {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
843 // the boss pointer is written somewhere in memory and overwrote by a 0 when
736
ff9651cfe1b0 ecl_vm: Remove trailing whitespace.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 735
diff changeset
844 // the boss mode is false, might want to look into that
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
845 enemy.set_boss(true);
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 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
848
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
849 // 102
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
850 // TODO: title says it all
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 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
853 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
854 */
661
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
855
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
856 // 103
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
857 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
858 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
859 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
860 }
598f3125cbac Implement enough instructions to execute sub 0 from stage 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 660
diff changeset
861
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
862 // 104
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
863 SubInstruction::SetCollidable(collidable) => {
681
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
864 // 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
865 // 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
866 // 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
867 // 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
868 // 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
869 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
870 enemy.collidable = (collidable&1) != 0;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
871 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
872
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
873 // 105
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
874 SubInstruction::SetDamageable(damageable) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
875 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
876 enemy.damageable = (damageable&1) != 0;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
877 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
878
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
879 // 106
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
880 SubInstruction::PlaySound(index) => {
716
5016c09e5d7c Fix some warnings.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 711
diff changeset
881 let enemy = self.enemy.borrow_mut();
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
882 enemy.play_sound(index);
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
883 }
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
884
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
885 // 107
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
886 SubInstruction::SetDeathFlags(death_flags) => {
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
887 let mut enemy = self.enemy.borrow_mut();
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
888 enemy.death_flags = death_flags;
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
889 }
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
890 // 108
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
891 SubInstruction::SetDeathCallback(sub) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
892 let mut enemy = self.enemy.borrow_mut();
698
05e0425a8bc5 ecl_vm: enable SetDeathCallback.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 697
diff changeset
893 enemy.death_callback = Some(sub);
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
894 }
674
3e4cc64a254d ecl_vm: more instructions.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 673
diff changeset
895
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
896 // 109
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
897 SubInstruction::MemoryWriteInt(value, index) => {
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
898 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
899 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
900
736
ff9651cfe1b0 ecl_vm: Remove trailing whitespace.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 735
diff changeset
901 // 110
685
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
902 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
903 SubInstruction::KillEnemy(enemy) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
904 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
905 game.kill_enemy(enemy);
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 */
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 // 111
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
910 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
911 SubInstruction::SetLife(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
912 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
913 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
914 enemy.life = value;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
915 game.interface.set_boss_life();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
916 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
917 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
918 // 112
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
919 SubInstruction::SetElapsedTime(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
920 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
921 enemy.frame = value as u32;
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 // 113
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
924 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
925 SubInstruction::SetLowLifeTrigger(value) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
926 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
927 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
928 enemy.low_life_trigger = value;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
929 game.interface.set_spell_life();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
930 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
931 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
932 // 114
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
933 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
934 SubInstruction::SetLowLifeCallback(sub) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
935 let mut enemy = self.enemy.borrow_mut();
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
936 enemy.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
937 }
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 // 115
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
940 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
941 SubInstruction::SetTimeout(timeout) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
942 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
943 enemy.frame = value;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
944 enemy.timeout = timeout;
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
945 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
946 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
947 // 116
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
948 /*
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
949 SubInstruction::SetTimeoutCallback(sub) => {
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
950 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
951 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
952 }
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
953 */
11d7e4d6947a ecl_vm: nearing the complete list
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 684
diff changeset
954
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
955
681
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
956 // 117
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
957 SubInstruction::SetTouchable(touchable) => {
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
958 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
959 enemy.touchable = touchable != 0;
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
960 }
1209e7f855a4 ecl_vm: added sibling function and a warning.
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 678
diff changeset
961
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
962 // 121
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
963 // Here lies the Di Sword of sadness
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
964 SubInstruction::CallSpecialFunction(function, arg) => {
718
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
965 match function {
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
966 0 => {
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
967 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
968 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
969 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
970 //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
971 //game.iter_bullets(|mut bullet| {
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
972 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
973 //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
974 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
975 if arg == 0 {
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
976 bullet.speed = 0.;
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
977 bullet.dpos = [0., 0., 0.];
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
978 } else if arg == 1 {
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
979 bullet.flags |= 0x10;
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
980 bullet.frame = 220;
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
981 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
982 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
983 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
984 }
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
985 }
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
986 }
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
987 1 => {
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
988 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
989 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
990 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
991 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
992 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
993 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
994 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
995 enemy.bullet_attributes.fire();
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
996 }
723
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
997 3 => { // Patchouli’s dual sign spellcard selector
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
998 let mut enemy = self.enemy.borrow_mut();
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
999 let mut knowledge: [[i32; 3]; 4] =
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
1000 [[0, 3, 1],
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
1001 [2, 3, 4],
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
1002 [1, 4, 0],
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
1003 [4, 2, 3]];
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
1004
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
1005 //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
1006 //let character = enemy.select_player().character;
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
1007 let character = 0;
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
1008 for i in 1..=3 {
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
1009 self.frame.ints1[i] = knowledge[character][i];
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
1010 }
420cec4005b5 ecl_vm: patchouli spellcard selector
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 722
diff changeset
1011 }
733
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1012 4 => { // Sakuya random daggers and time stop
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1013 /*
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1014 if arg < 2 {
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1015 drop_particle(&PARTICLES_ARRAY,0xc,enemy->pos,1,0xffffffff);
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1016 //TODO: is that the timestop?
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1017 LEVEL.field_0x2c = arg;
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1018 return;
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1019 }
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1020 // this changes the orientation of random bullets
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1021 let mut max_bullets = 0xe;
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1022 if (LEVEL.rank >= 2) {max_bullets = 0x34;}
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1023 i = 0;
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1024 for bullet in game.bullets {
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1025 if bullet->state != 0 && bullet->state != 5 && 30. <= (bullet->sprites[0].additional_infos)->height && bullet->field_0x5ba != 5 && (uVar3 = prng16(&PRNG_STATE), (uVar3 & 3) == 0) {
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1026 bullet->field_0x5ba = 5;
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1027 new_effect(GAME_OBJECT,(sprite *)bullet, (int)bullet->sprites[0].sometimes_copy_of_UNK1 + (int)bullet->field_0x5ba);
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1028 x = bullet->pos[0] - PLAYER.pos[0];
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1029 y = bullet->pos[1] - PLAYER.pos[1];
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1030 if sqrt(x*x+y*y) > 128. {
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1031 if LEVEL.rank >= 2 {bullet->automatic_angle = prng_double() * 2*pi;}
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1032 else{bullet->automatic_angle = (prng_double() * ((pi/8)*6) + pi/4);}
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1033 else {
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1034 // TODO: check player_get_angle, might be what ST0 is
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1035 player_get_angle_to(&PLAYER,bullet->pos,local_38);
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1036 bullet->automatic_angle = (extraout_ST0_00 + pi/2 + (prng_double() * pi*2));
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1037 }
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1038 bullet->dpos[0] = cos(bullet->automatic_angle) * bullet->speed;
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1039 bullet->dpos[1] = sin(bullet->automatic_angle) * bullet->speed;
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1040 max_bullets -= 1;
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1041 if (max_bullets == 0) break;
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1042 }
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1043 }
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1044 (enemy->ecl_frame).var_ints_1[2] = 0;*/
770e5057f6bc ecl_vm: time stop/random sakuya bullets impl
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 732
diff changeset
1045 }
732
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1046 7 => { // Remilia's lazer maze
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1047 // 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
1048 // 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
1049 // 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
1050 // 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
1051 // edit the coordinates for the next round
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1052 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
1053 let enemy = self.enemy.borrow();
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1054 for i in 0..2 {
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1055 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
1056 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
1057 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
1058 if (i == 0) {
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1059 offset = rnd_pos -std::f64::consts::PI;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1060 next_offset = std::f64::consts::PI/4.;
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
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1063 // 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
1064 let mut offset_copy=offset;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1065 for y in 0..8 {
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1066 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
1067 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
1068 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
1069 offset_copy += std::f64::consts::PI/4.;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1070 }
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1071
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1072 // 3 rounds of 8 shots
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1073 for z in 0..3 {
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 let mut length = 112.;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1076 // last subround
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1077 if (z == 2) {length = 480.;}
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1078
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1079 for y in 0..8 {
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1080 /*
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1081 if (arg == 0) {
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1082 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
1083 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
1084 laser_args.angle = pos[y * 3];
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1085 laser_args.speed = pos[y * 3 + 1];
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1086 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
1087 laser_args.type = 1;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1088 laser_args.sprite_index_offset = si;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1089 laser_args.end_offset = offset;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1090 laser_args.width = 0.;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1091 laser_args.duration = 0;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1092 laser_args.grazing_extra_duration = ged;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1093 laser_args.end_duration = ed;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1094 laser_args.UNK1 = z * 0x10 + 0x3c;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1095 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
1096 fire_laser(&ETAMA_ARRAY,&laser_args);
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1097 }
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1098 else {
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1099 (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
1100 (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
1101 (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
1102 bullet_fire(&enemy->bullet_attributes,&ETAMA_ARRAY);
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1103 }
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1104 */
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1105 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
1106 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
1107 offset = offset + std::f64::consts::PI/4.;
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1108 }
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1109 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
1110 }
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1111 }
5f00b2e0c06a ecl_vm: remilia lasers done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 731
diff changeset
1112 }
722
e71ea8214ee2 ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 721
diff changeset
1113 8 => { // Vampire Fantasy
737
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1114 let n = {
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1115 let enemy = self.enemy.borrow();
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1116 let game = enemy.game.upgrade().unwrap();
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1117 let mut game = game.borrow_mut();
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1118 let mut n = 0;
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1119 for bullet in game.bullets.iter() {
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1120 let mut bullet = bullet.borrow();
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1121 // TODO: uncomment that one.
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1122 if bullet.state != 0 && bullet.state != 5 /* && (30. <= (bullet.sprites[0].additional_infos).height) */ {
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1123 let prng = enemy.prng.upgrade().unwrap();
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1124 let random = prng.borrow_mut().get_f64();
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1125 let launch_angle = (random * (2. * std::f64::consts::PI) - std::f64::consts::PI) as f32;
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1126 let mut attribs = BulletAttributes {
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1127 // TODO: check if the z value of this pos is really used.
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1128 pos: bullet.pos,
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1129 anim: 3,
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1130 sprite_index_offset: 1,
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1131 launch_angle,
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1132 speed: 0.,
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1133 angle: 0.,
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1134 speed2: 0.,
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1135 bullets_per_shot: 1,
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1136 number_of_shots: 1,
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1137 flags: 8,
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1138 bullet_type: 1,
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1139 extended_attributes: Default::default(),
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1140 sound: None,
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1141 };
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1142 attribs.fire();
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1143 n += 1
722
e71ea8214ee2 ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 721
diff changeset
1144 }
737
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1145 }
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1146 n
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1147 };
722
e71ea8214ee2 ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 721
diff changeset
1148 //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
1149 //th06: *(int *)(param_1 + 0x9b0) = local_60;
737
0977d479e37d ecl_vm: Uncomment instruction 121 function 8.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 736
diff changeset
1150 self.set_i32(-10004, n);
722
e71ea8214ee2 ecl_vm: some work on vampire fantasy
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 721
diff changeset
1151 }
736
ff9651cfe1b0 ecl_vm: Remove trailing whitespace.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 735
diff changeset
1152
731
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1153 9 => {
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1154 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
1155 //TODO: the game does that
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1156 //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
1157 //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
1158 /*
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1159 for bullet in game.bullets {
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1160 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
1161 bullet.flags = bullet.flags | 0x10;
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1162 //TODO: reverse this field and effect
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1163 bullet->field_0x5ba = 2;
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1164 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
1165 bullet.speed=0.01;
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1166 bullet.frame=0x78;
736
ff9651cfe1b0 ecl_vm: Remove trailing whitespace.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 735
diff changeset
1167
731
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1168 let mut dx = bullet.x - enemy.x;
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1169 let mut distance = dx.hypot(bullet.y - enemy.y);
736
ff9651cfe1b0 ecl_vm: Remove trailing whitespace.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 735
diff changeset
1170
731
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1171 if distance > 0.01 {
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1172 distance = sqrt(distance);
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1173 }else{distance = 0.;}
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1174 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
1175 bullet->attributes[0] = cos(angle) * 0.01000000;
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1176 bullet->attributes[1] = sin(angle) * 0.01000000;
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1177 }
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1178 }
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1179 */
ca46b4312df1 ecl_vm: spellcard 9
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 728
diff changeset
1180 }
725
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1181 11 => {
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1182 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
1183 //TODO: the game does that
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1184 //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
1185 //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
1186 /*
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1187 for bullet in game.bullets {
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1188 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
1189 bullet.flags = bullet.flags | 0x10;
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1190 //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
1191 bullet->field_0x5ba = 2;
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1192 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
1193 bullet.speed=0.01;
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1194 bullet.frame=0x78;
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1195 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
1196 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
1197 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
1198
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1199
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1200 }
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1201 }
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1202 */
fbf89cba04e2 ecl_vm: some work on spellcard 11
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 724
diff changeset
1203 }
724
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1204 13 => {
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1205 if self.frame.ints1[3] % 6 == 0 {
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1206 let mut _angle=self.frame.floats[2];
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1207 /*
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1208 (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
1209 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
1210 for i in range(arg) {
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1211 //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
1212 //in memory
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1213 launch_pos = (192 + cos(_angle) * _distance,
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1214 224 + sin(_angle) * _distance);
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1215
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1216 bullet_attributes = (type_, anim, sprite_idx_offset,
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1217 bullets_per_shot, number_of_shots,
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1218 speed, speed2,
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1219 _angle + self.frame.floats[1], angle, flags);
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1220 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
1221 _angle += 2*std::f64::consts::PI/arg;
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1222 }*/
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1223 }
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1224 self.frame.ints1[3] += 1;
8acaf45b47d0 ecl_vm: added spellcard 13
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 723
diff changeset
1225 }
721
bbf0da7de481 ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 720
diff changeset
1226 14 => { // Lävatein
bbf0da7de481 ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 720
diff changeset
1227 let mut enemy = self.enemy.borrow_mut();
bbf0da7de481 ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 720
diff changeset
1228 self.frame.ints1[3] = 0;
bbf0da7de481 ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 720
diff changeset
1229 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
1230 //for pos in laser.get_bullets_pos(){
bbf0da7de481 ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 720
diff changeset
1231 //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
1232 // enemy.fire(launch_pos=pos);
bbf0da7de481 ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 720
diff changeset
1233 //}
bbf0da7de481 ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 720
diff changeset
1234 self.frame.ints1[3] += 1;
bbf0da7de481 ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 720
diff changeset
1235 }
bbf0da7de481 ecl_vm: work on laevateinn
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 720
diff changeset
1236 }
720
cffb0f1531fc ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 718
diff changeset
1237 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
1238 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
1239 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
1240 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
1241 if arg == 0 {
cffb0f1531fc ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 718
diff changeset
1242 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
1243 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
1244 } else {
cffb0f1531fc ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 718
diff changeset
1245 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
1246 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
1247 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
1248 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
1249 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
1250 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
1251 }
cffb0f1531fc ecl_vm: implemented spellcard QED: Ripple of 495 years
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 718
diff changeset
1252 }
734
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1253 _ => unimplemented!("Special function {:?} not found!", function)
718
c187e0a6b751 ecl_vm: Implement 121 functions 0 and 1.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 716
diff changeset
1254 }
683
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
1255 }
8c50a7b19425 ecl_vm: more work
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 682
diff changeset
1256
734
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1257 // 122
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1258 // Here lies the Di Sword of despair
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1259 SubInstruction::SetSpecialFunctionCallback(function) => {
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1260 //TODO: those functions are executed at each frame and needs to be written to the
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1261 //callback function but so far i'm simply focusing on the implementation
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1262 //NB: the original engine doesn't differenciate between function blocks for ins 121
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1263 //and 122 but we do here, since it wouldn't make sense the other way around.
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1264 match function {
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1265 12 => {
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1266 for i in 0..8 {
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1267 /*
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1268 if ((enemy->lasers[i] != (laser *)0x0) && (enemy->lasers[i]->state != 0)) {
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1269 (enemy->bullet_attributes).pos[0] = cos(enemy->lasers[i]->angle) * 64. + enemy.pos.x;
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1270 // yes, it reads pos[0] after it has been modified and yes, this most
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1271 // likely is a bug
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1272 (enemy->bullet_attributes).pos[1] = cos(enemy->lasers[i]->angle) * (enemy->bullet_attributes).pos[0] + enemy.pos.y;
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1273 (enemy->bullet_attributes).pos[2] = enemy.z;
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1274 bullet_fire(&enemy->bullet_attributes,&ETAMA_ARRAY);
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1275 }*/
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1276 }
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1277 }
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1278 _ => unimplemented!("Special function {:?} not found!", function)
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1279 }
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1280 }
678
1d81a449c436 Implement ECL instructions DelayAttack and NoDelayAttack.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 674
diff changeset
1281 _ => 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
1282 }
734
7886a1a5d226 ecl_vm: instruction 122 beginnings, sf 12 done
Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
parents: 733
diff changeset
1283
660
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
1284 }
31fc0d881105 Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 659
diff changeset
1285 }
695
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1286
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1287 #[cfg(test)]
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1288 mod tests {
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1289 use super::*;
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1290 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
1291 use crate::th06::ecl::{Sub, CallSub, Rank};
739
01915da33b99 ecl_vm: Let enemies spawn other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 738
diff changeset
1292 use crate::th06::enemy::Game;
695
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1293 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
1294 use std::fs::File;
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1295
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1296 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
1297 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
1298 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
1299 let mut buf = vec![];
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1300 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
1301 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
1302 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
1303 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
1304 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
1305 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
1306 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
1307 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
1308 (game, enemy)
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1309 }
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1310
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1311 #[test]
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1312 fn call_and_return() {
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1313 let (game, enemy) = setup();
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1314 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
1315 Sub { instructions: vec![
703
81232dac8136 ecl: simplify parsing with more combinators.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 701
diff changeset
1316 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
1317 ]},
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1318 Sub { instructions: vec![
703
81232dac8136 ecl: simplify parsing with more combinators.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 701
diff changeset
1319 CallSub::new(0, Rank::EASY, SubInstruction::Noop()),
81232dac8136 ecl: simplify parsing with more combinators.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 701
diff changeset
1320 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
1321 ]},
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1322 ]};
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1323 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
1324 ecl_runner.run_frame();
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1325 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
1326 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
1327 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
1328 ecl_runner.run_frame();
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1329 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
1330 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
1331 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
1332 }
f5b34a1c2707 ecl_vm: add a test for Call and Return.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 693
diff changeset
1333 }