From 2b4becf41fad4e3413044b024177931206a9417d Mon Sep 17 00:00:00 2001 From: CUB3D Date: Tue, 6 Apr 2021 22:20:53 +0100 Subject: [PATCH] avm2: Implement Op::Lf32 --- core/src/avm2/activation.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/core/src/avm2/activation.rs b/core/src/avm2/activation.rs index df28fb964..71b8bf1c9 100644 --- a/core/src/avm2/activation.rs +++ b/core/src/avm2/activation.rs @@ -699,10 +699,11 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { Op::Si8 => self.op_si8(), Op::Si16 => self.op_si16(), Op::Si32 => self.op_si32(), + Op::Sf32 => self.op_sf32(), Op::Li8 => self.op_li8(), Op::Li16 => self.op_li16(), Op::Li32 => self.op_li32(), - Op::Sf32 => self.op_sf32(), + Op::Lf32 => self.op_lf32(), _ => self.unknown_op(op), }; @@ -2636,6 +2637,28 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { Ok(FrameControl::Continue) } + /// Implements `Op::Lf32` + fn op_lf32(&mut self) -> Result, Error> { + let address = self.context.avm2.pop().coerce_to_u32(self)? as usize; + + let dm = self.domain_memory().expect("Not domain memory?"); + let r = dm.read(); + let val = r.get_range(address..address + 4); + drop(dm); + + if let Some(val) = val { + let buf: [u8; 4] = [val[0], val[1], val[2], val[3]]; + + self.context + .avm2 + .push(Value::Number(f32::from_le_bytes(buf) as f64)); + } else { + return Err("RangeError: The specified range is invalid".into()); + } + + Ok(FrameControl::Continue) + } + #[allow(unused_variables)] #[cfg(avm_debug)] fn op_debug(