comparison src/th06/ecl_vm.rs @ 664:f08e8e3c6196

Use bitflags for the rank, instead of an u16.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 11 Aug 2019 19:55:45 +0200
parents 994f41154be8
children 965ecdbf0316
comparison
equal deleted inserted replaced
663:994f41154be8 664:f08e8e3c6196
1 //! ECL runner. 1 //! ECL runner.
2 2
3 use crate::th06::ecl::{Ecl, SubInstruction}; 3 use crate::th06::ecl::{Ecl, SubInstruction, Rank};
4 use crate::th06::enemy::Enemy; 4 use crate::th06::enemy::Enemy;
5 use crate::util::prng::Prng; 5 use crate::util::prng::Prng;
6 use std::cell::RefCell; 6 use std::cell::RefCell;
7 use std::rc::Rc; 7 use std::rc::Rc;
8 8
54 break; 54 break;
55 } 55 }
56 self.ip += 1; 56 self.ip += 1;
57 57
58 let rank = self.enemy.borrow().get_rank(); 58 let rank = self.enemy.borrow().get_rank();
59 if call.rank_mask & (0x100 << rank) == 0 { 59 if (call.rank_mask & rank).is_empty() {
60 continue; 60 continue;
61 } 61 }
62 62
63 if call.time == self.frame { 63 if call.time == self.frame {
64 self.run_instruction(call.instr.clone()); 64 self.run_instruction(call.instr.clone());
80 -10008 => self.variables.1[3] as i32, 80 -10008 => self.variables.1[3] as i32,
81 -10009 => self.variables.2[0], 81 -10009 => self.variables.2[0],
82 -10010 => self.variables.2[1], 82 -10010 => self.variables.2[1],
83 -10011 => self.variables.2[2], 83 -10011 => self.variables.2[2],
84 -10012 => self.variables.2[3], 84 -10012 => self.variables.2[3],
85 -10013 => enemy.get_rank(), 85 -10013 => enemy.get_rank().bits() as i32,
86 -10014 => enemy.get_difficulty(), 86 -10014 => enemy.get_difficulty(),
87 -10015 => enemy.pos.x as i32, 87 -10015 => enemy.pos.x as i32,
88 -10016 => enemy.pos.y as i32, 88 -10016 => enemy.pos.y as i32,
89 -10017 => enemy.z as i32, 89 -10017 => enemy.z as i32,
90 -10018 => unimplemented!(), 90 -10018 => unimplemented!(),
112 -10008.0 => self.variables.1[3], 112 -10008.0 => self.variables.1[3],
113 -10009.0 => self.variables.2[0] as f32, 113 -10009.0 => self.variables.2[0] as f32,
114 -10010.0 => self.variables.2[1] as f32, 114 -10010.0 => self.variables.2[1] as f32,
115 -10011.0 => self.variables.2[2] as f32, 115 -10011.0 => self.variables.2[2] as f32,
116 -10012.0 => self.variables.2[3] as f32, 116 -10012.0 => self.variables.2[3] as f32,
117 -10013.0 => enemy.get_rank() as f32, 117 -10013.0 => enemy.get_rank().bits() as f32,
118 -10014.0 => enemy.get_difficulty() as f32, 118 -10014.0 => enemy.get_difficulty() as f32,
119 -10015.0 => enemy.pos.x, 119 -10015.0 => enemy.pos.x,
120 -10016.0 => enemy.pos.y, 120 -10016.0 => enemy.pos.y,
121 -10017.0 => enemy.z, 121 -10017.0 => enemy.z,
122 -10018.0 => unimplemented!(), 122 -10018.0 => unimplemented!(),