Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
397 changes: 232 additions & 165 deletions core/src/avm1/activation.rs

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions core/src/avm1/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ use crate::tag_utils::SwfSlice;
use gc_arena::{Collect, CollectionContext, Gc, GcCell, MutationContext};
use std::borrow::Cow;
use std::fmt;
use swf::{avm1::types::FunctionParam, SwfStr};
use swf::{
avm1::types::{FunctionParam, RegisterIndex},
SwfStr,
};

/// Represents a function defined in Ruffle's code.
///
Expand Down Expand Up @@ -56,7 +59,7 @@ pub struct Avm1Function<'gc> {

/// The number of registers to allocate for this function's private register
/// set. Any register beyond this ID will be served from the global one.
register_count: u8,
register_count: RegisterIndex,

preload_parent: bool,
preload_root: bool,
Expand Down Expand Up @@ -137,7 +140,7 @@ impl<'gc> Avm1Function<'gc> {
pub fn from_df2(
swf_version: u8,
actions: SwfSlice,
swf_function: &swf::avm1::types::Function,
swf_function: &swf::avm1::types::DefineFunction2,
scope: GcCell<'gc, Scope<'gc>>,
constant_pool: GcCell<'gc, Vec<Value<'gc>>>,
base_clip: DisplayObject<'gc>,
Expand Down Expand Up @@ -197,7 +200,7 @@ impl<'gc> Avm1Function<'gc> {
self.scope
}

pub fn register_count(&self) -> u8 {
pub fn register_count(&self) -> RegisterIndex {
self.register_count
}
}
Expand Down
4 changes: 1 addition & 3 deletions core/src/display_object/movie_clip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ use std::collections::HashMap;
use std::convert::TryFrom;
use std::sync::Arc;
use swf::extensions::ReadSwfExt;
use swf::{FillStyle, FrameLabelData, LineStyle, Tag};

type FrameNumber = u16;
use swf::{FillStyle, FrameLabelData, FrameNumber, LineStyle, Tag};

/// A movie clip is a display object with its own timeline that runs independently of the root timeline.
/// The SWF19 spec calls this "Sprite" and the SWF tag defines it is "DefineSprite".
Expand Down
2 changes: 1 addition & 1 deletion swf/src/avm1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub(crate) mod opcode;
pub mod opcode;
pub mod read;
pub mod types;
pub mod write;
6 changes: 6 additions & 0 deletions swf/src/avm1/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,9 @@ pub enum OpCode {
Call = 0x9E,
GotoFrame2 = 0x9F,
}

impl OpCode {
pub fn from_u8(n: u8) -> Option<Self> {
num_traits::FromPrimitive::from_u8(n)
}
}
Loading