comparison src/th06/ecl.rs @ 660:31fc0d881105

Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 10 Aug 2019 14:41:30 +0200
parents 5f02984dd12a
children 598f3125cbac
comparison
equal deleted inserted replaced
659:53786d834444 660:31fc0d881105
9 9
10 /// A single instruction, part of a `Script`. 10 /// A single instruction, part of a `Script`.
11 #[derive(Debug, Clone)] 11 #[derive(Debug, Clone)]
12 pub struct CallSub { 12 pub struct CallSub {
13 /// Time at which this instruction will be called. 13 /// Time at which this instruction will be called.
14 pub time: u32, 14 pub time: i32,
15 15
16 /// TODO 16 /// TODO
17 pub rank_mask: u16, 17 pub rank_mask: u16,
18 18
19 /// TODO 19 /// TODO
147 } 147 }
148 148
149 declare_sub_instructions!{ 149 declare_sub_instructions!{
150 0 => fn Noop(), 150 0 => fn Noop(),
151 1 => fn Destroy(unused: u32), 151 1 => fn Destroy(unused: u32),
152 2 => fn RelativeJump(frame: u32, ip: i32), 152 2 => fn RelativeJump(frame: i32, ip: i32),
153 3 => fn RelativeJumpEx(frame: u32, ip: i32, variable_id: i32), 153 3 => fn RelativeJumpEx(frame: i32, ip: i32, variable_id: i32),
154 4 => fn SetInt(var: i32, value: i32), 154 4 => fn SetInt(var: i32, value: i32),
155 5 => fn SetFloat(var: i32, value: f32), 155 5 => fn SetFloat(var: i32, value: f32),
156 6 => fn SetRandomInt(var: i32, max: i32), 156 6 => fn SetRandomInt(var: i32, max: i32),
157 8 => fn SetRandomFloat(var: i32, max: f32), 157 8 => fn SetRandomFloat(var: i32, max: f32),
158 9 => fn SetRandomFloat2(var: i32, amplitude: f32, min: f32), 158 9 => fn SetRandomFloatMin(var: i32, amplitude: f32, min: f32),
159 10 => fn StoreX(var: i32), 159 10 => fn StoreX(var: i32),
160 13 => fn AddInt(var: i32, a: i32, b: i32), 160 13 => fn AddInt(var: i32, a: i32, b: i32),
161 14 => fn SubstractInt(var: i32, a: i32, b: i32), 161 14 => fn SubstractInt(var: i32, a: i32, b: i32),
162 15 => fn MultiplyInt(var: i32, a: i32, b: i32), 162 15 => fn MultiplyInt(var: i32, a: i32, b: i32),
163 16 => fn DivideInt(var: i32, a: i32, b: i32), 163 16 => fn DivideInt(var: i32, a: i32, b: i32),
164 17 => fn Modulo(var: i32, a: i32, b: i32), 164 17 => fn ModuloInt(var: i32, a: i32, b: i32),
165 18 => fn Increment(var: i32), 165 18 => fn Increment(var: i32),
166 20 => fn AddFloat(var: i32, a: f32, b: f32), 166 20 => fn AddFloat(var: i32, a: f32, b: f32),
167 21 => fn SubstractFloat(var: i32, a: f32, b: f32), 167 21 => fn SubstractFloat(var: i32, a: f32, b: f32),
168 23 => fn DivideFloat(var: i32, a: f32, b: f32), 168 23 => fn DivideFloat(var: i32, a: f32, b: f32),
169 25 => fn GetDirection(var: i32, x1: f32, y1: f32, x2: f32, y2: f32), 169 25 => fn GetDirection(var: i32, x1: f32, y1: f32, x2: f32, y2: f32),
285 let mut subs = Vec::new(); 285 let mut subs = Vec::new();
286 for offset in sub_offsets { 286 for offset in sub_offsets {
287 let mut i = &input[offset..]; 287 let mut i = &input[offset..];
288 let mut instructions = Vec::new(); 288 let mut instructions = Vec::new();
289 loop { 289 loop {
290 let (i2, time) = le_u32(i)?; 290 let (i2, time) = le_i32(i)?;
291 let (i2, opcode) = le_u16(i2)?; 291 let (i2, opcode) = le_u16(i2)?;
292 if time == 0xffffffff || opcode == 0xffff { 292 if time == -1 || opcode == 0xffff {
293 break; 293 break;
294 } 294 }
295 295
296 let (i2, size) = le_u16(i2)?; 296 let (i2, size) = le_u16(i2)?;
297 let (i2, rank_mask) = le_u16(i2)?; 297 let (i2, rank_mask) = le_u16(i2)?;