David Wendt
0c7a1fe667
Text and comment nodes are stored plain and must be escaped for XML
2020-01-04 19:00:36 -05:00
David Wendt
c7e1f34a5d
Print empty nodes as empty tags rather than start/end
2020-01-04 19:00:35 -05:00
David Wendt
c76e5ce447
appendChild also refuses to orphan nodes already part of another XML tree.
2020-01-04 19:00:35 -05:00
David Wendt
34cbe2e04b
insertNode rejects child nodes that already have a parent
2020-01-04 19:00:34 -05:00
David Wendt
7b4a509ebc
Avoid double-borrows when moving a child within it's parent
2020-01-04 19:00:33 -05:00
David Wendt
30266b2ce7
remove_child should also ensure the child disowns the parent.
2020-01-04 19:00:33 -05:00
David Wendt
8c5dcfe662
Swap in newly constructed nodes *before* filling them with content.
...
Fixes a bug where new XML("<node />").childNode[0].parentNode did NOT refer to the overall document object, but to a phantom text node.
This is because the swap operation used to construct an XMLObject's node in-place was happening AFTER parsing, which means that referents already existed to the temporary XMLNode created by XMLObject::new. swap is not to be called after tree structure has been created; it does not update referents to the swapped nodes.
In the future I should examine the implications of explicitly reconstructing already existing nodes, e.g. through XML.apply(some_xml). Right now, the existing node will be swapped with a new one, and two nodes will exist pointing to the same script object, which is a huge problem with our overall design. We should, at the very least, disassociate swapped nodes from their script object, just in case they still have referents.
Ideally, we wouldn't have to swap nodes, but to avoid a swap, I'd have to instead have a second layer of indirection just to hold a rewritable pointer that every XMLObject points to. This isn't really worth it unless I HAVE to do it, so I'm not going to do it.
2020-01-04 19:00:32 -05:00
David Wendt
568d90f4dc
Warn if XML.removeNode fails for whatever reason
2020-01-04 19:00:32 -05:00
David Wendt
1577f51730
Expose elided objects as pointers when debugging XML nodes
2020-01-04 19:00:32 -05:00
David Wendt
19ca11b08c
Impl `toString`
2020-01-04 19:00:31 -05:00
David Wendt
513460e4e0
Implement `insertBefore`
2020-01-04 19:00:31 -05:00
David Wendt
b0dce445b0
Impl `removeNode`
2020-01-04 19:00:29 -05:00
David Wendt
00319f14a8
Implement `namespaceURI`
2020-01-04 19:00:29 -05:00
David Wendt
7c95eff048
Flag an error if we accidentally introduce a second script object by accident.
2020-01-04 19:00:28 -05:00
David Wendt
abb2690367
When constructing new XML nodes or documents, always ensure that the new node we swap in is properly linked to the same script object so that we don't accidentally recreate them.
2020-01-04 19:00:28 -05:00
David Wendt
8939dae90c
Implement `XMLNode.attributes` w/ read tests
2020-01-04 19:00:27 -05:00
David Wendt
6f48f3436f
Expose `previousSibling` and `nextSibling` to ActionScript.
...
This commit also fixes a bug caused by excessive use of copypaste, which was detected by the included test.
2020-01-04 19:00:25 -05:00
David Wendt
223320c98c
Expose `parentNode` to ActionScript
2020-01-04 19:00:24 -05:00
David Wendt
807725d7aa
Expose `firstChild` and `lastChild` to ActionScript w/ tests
2020-01-04 19:00:24 -05:00
David Wendt
1d1e493e0e
Refactor the child adoption process to ensure the child also adopts it's siblings.
2020-01-04 19:00:23 -05:00
David Wendt
48d68bebc4
Implement `hasChildNodes()` and add test
2020-01-04 19:00:23 -05:00
David Wendt
881dcb76ab
`cloneNode` without arguments is morally equivalent to `false`
2020-01-04 19:00:21 -05:00
David Wendt
69a1ab1649
Expose namespace prefix and URI lookups to ActionScript.
...
Also, fix the previous commit's half-assed impl.
2020-01-04 19:00:20 -05:00
David Wendt
fe7d2b5173
Extremely WIP impl of `lookup_uri_for_namespace`
2020-01-04 19:00:20 -05:00
David Wendt
55fa6ef09b
Add node cloning support
2020-01-04 19:00:19 -05:00
David Wendt
37f6efb753
Expose `appendChild` to ActionScript
2020-01-04 19:00:19 -05:00
David Wendt
08c0f273a6
Add sibling links to nodes.
2020-01-04 19:00:18 -05:00
David Wendt
7e45dee8cf
Clippy said so.
2020-01-04 19:00:18 -05:00
David Wendt
eec449422b
`XMLDocument.roots` is not necessary since you can just get the children of it's node form anyway...
2020-01-04 19:00:18 -05:00
David Wendt
cfacd397cf
Most XML properties return `null`, not `undefined`.
...
Furthermore, `prefix` does not distinguish between `<test>` and `<:test>` - they both have a `prefix` of `""`.
2020-01-04 19:00:17 -05:00
David Wendt
b491dd034e
Don't overflow stack when debug-printing an entire document, either.
2020-01-04 19:00:16 -05:00
David Wendt
e47a1d1e38
Fix newly constructed XML trees not actually containing the XML they just parsed.
2020-01-04 19:00:16 -05:00
David Wendt
960e4dad90
Don't cause stack overflow when debug-printing XML nodes.
2020-01-04 19:00:16 -05:00
David Wendt
bec60acc1e
`XML.prototype` should be an `XMLObject` so that instances of `XML` can hold a node
2020-01-04 19:00:15 -05:00
David Wendt
d058c83ac0
Document roots should accept children.
2020-01-04 19:00:15 -05:00
David Wendt
571c4bbd52
Cargo fmt compliance
2020-01-04 19:00:15 -05:00
David Wendt
0af248d81f
Expose `childNodes` to ActionScript
2020-01-04 19:00:14 -05:00
David Wendt
e7768d0802
Add methods to allow storing XML objects on the accompanying tree nodes, so that expando properties on child nodes will work.
2020-01-04 19:00:13 -05:00
David Wendt
b06dd5d15e
Add a special node to represent the document root in the node tree, and get rid of the explicit document reference type in `XMLObject`.
2020-01-04 19:00:12 -05:00
David Wendt
0fe0e4fe90
Separate `XMLName` into another module
2020-01-04 19:00:11 -05:00
David Wendt
3928c7cc51
Reject empty text nodes
2020-01-04 19:00:11 -05:00
David Wendt
7a9a16e598
Don't repeat yourself.
2020-01-04 19:00:11 -05:00
David Wendt
bd1ea56cc3
Implement `XMLNode` properties that don't require child or attribute iteration.
2020-01-04 19:00:10 -05:00
David Wendt
e2eb3d0bde
Add a test of XMLDocument::from_str.
...
This test technically works, but the results were slightly surprising. If it turns out Flash works differently from `quick_xml`, we'll change this test to match Flash.
2020-01-04 19:00:10 -05:00
David Wendt
6ae5ae3038
Add Comment parsing support
2020-01-04 19:00:10 -05:00
David Wendt
4f5ac09b73
Expose XML document constructor, including text parsing ability
2020-01-04 19:00:09 -05:00
David Wendt
554f0dc1e5
Add XMLNode class and constructor impl
2020-01-04 19:00:07 -05:00
David Wendt
6a65e984ae
Add a new `XMLObject` variant to the AVM1 object ecosystem.
...
This particular variant is actually a two-in-one deal: `XMLObject`s may either refer to a document or a node.
2020-01-04 18:58:42 -05:00
David Wendt
89c9753520
Add rudimentary custom DOM impl on top of `quick_xml`.
...
`quick_xml` was chosen due to it's high performance and support for zero-copy use cases. However, we are not using `minidom`, which is the already-extant DOM impl that uses `quick_xml` as it's parsing provider. This is because `minidom` nodes are not amenable to garbage collection.
Specifically: we want to be able to construct a new `Object` variant that holds part of an XML node. However, `minidom::Element` directly owns it's children, meaning that we can't hold references to it from within `Object` while also keeping those objects to the `'gc` lifetime. Hence, we provide a GC-exclusive DOM implementation.
I ruled out solutions such as holding an entire XML tree in an `Rc` and having AVM objects that shadow them. This works for `SwfSlice` because indexing an array is cheap; but traversing a tree can get very expensive. XML is used in many places in Flash Player, so it's important that we treat it like a first-class citizen.
2020-01-04 18:48:17 -05:00
Mike Welsh
36b3e5b34f
avm1: Implement Color class
2020-01-03 20:31:32 -08:00
Mike Welsh
4bf29f677f
avm1: Implement Sound.duration
...
Add AudioBackend::get_sound_duration.
2020-01-03 17:11:00 -08:00
Mike Welsh
b9d24d9a49
avm1: First pass at implementing Sound.stop
2020-01-03 17:11:00 -08:00
Mike Welsh
d0142f1d67
audio: Add AudioBackend::stop_sound
2020-01-03 17:11:00 -08:00
Mike Welsh
63dd92259b
avm1: First pass of Sound object
2020-01-03 17:11:00 -08:00
Mike Welsh
87158647d1
core: Implement keyPress button events
2019-12-24 03:06:03 -08:00
Mike Welsh
2f0963fa6c
core: Fix button action with multiple conditions not firing ( fix #195 )
...
If a button event had both a keyPress condition and another
condition:
on(release, keyPress "A") { }
these actions would not fire on click, because it would still
check if the key was down (which doesn't apply to clicks!)
Fixes #195 .
2019-12-22 15:55:03 -08:00
Nathan Adams
9000451d58
core: Implemented Mouse.show() & Mouse.hide()
2019-12-22 14:33:46 -08:00
Mike Welsh
4cdeec5b64
avm1: Fix number coercion in arithmetic ops
...
A lot of the arithmetic ops were still using SWFv4 style coercion
(`Value::into_number_v1`) even though they use full ECMA-262
coercion in SWF5+. This would cause `undefined` to turn into 0
isntead of NaN, for example.
Fixes disappearing player in Achievement Unlocked
(https://www.newgrounds.com/portal/view/474371 )
It's possible even the older ops such as ActionAdd should do this,
too. Handcrafted bytecode will need to be used to test as you
cannot export these ops in newer SWF versions from the Flash IDE.
2019-12-22 03:01:58 -08:00
Mike Welsh
c9e0bdeaf5
core: GC trace Button::object
2019-12-21 23:54:50 -08:00
Mike Welsh
a4a307cf9a
avm1: Use proper bool conversions for logical ops
...
ActionAnd, ActionOr, and ActionNot were incorrectly comparing
to 0. This only works for SWF<4. Now they all go through the
Value::as_bool method to handle version specific behavior.
Value::from_bool_v1 was also renamed to Value::from_bool.
2019-12-21 23:01:10 -08:00
Mike Welsh
fd92bd5f78
core: Fix PlaceObject modifications in fast-forward gotos
...
When fast-forwarding with a goto, modifications were not taking
effect to objects that exist both in the starting and the final
frame.
2019-12-21 21:16:27 -08:00
Nathan Adams
eedc4bbe24
core: Added Input backend, currently unimplemented, for polling user input
2019-12-21 19:08:06 -08:00
Nathan Adams
6c484fe29d
core: Changed KeyCode into an enum that maps out every Flash key code
2019-12-21 19:08:06 -08:00
Mike Welsh
d7df15989f
core: Clear drag if object is removed while dragging
2019-12-21 16:28:41 -08:00
Mike Welsh
531e4d640d
avm1: Implement StartDrag/EndDrag
2019-12-21 16:28:41 -08:00
Mike Welsh
713e959ce4
core: Implement DisplayObject::object for Button
2019-12-21 16:28:41 -08:00
Mike Welsh
4bd54cc2ea
core: Fix DisplayObject::global_to_local and local_to_global
2019-12-21 16:28:41 -08:00
Mike Welsh
f2d31b222b
core: Implement DefineButtonCxform SWF tag
...
(Although nothing uses this... it was only used in SWF version 2
and below!)
2019-12-20 19:20:25 -08:00
Mike Welsh
4026e22bbf
core: Handle DefineButtonSound SWF tag
...
This plays sounds whenever a button is hovered/clicked. Fixes
gun sounds in Pico's School.
2019-12-20 01:08:28 -08:00
Mike Welsh
d459bbe010
avm1: Functions store their base clip
...
Functions now store their base clip (the code that contains the
executing bytecode). This is because `GotoFrame` and other actions
will execute on the clip the bytecode exists on, not on `this`.
(Note that `this.gotoAndStop` uses `GetMember` actions, which
worked correctly).
`Activation` now stores `target_clip`, and `Avm1::target_clip` and
`target_clip_or_root` grab this from the current stack frame.
Renamed `start_clip` to `base_clip` to match Flash conventions.
Removed `active_clip` as this was superfluous. Now you can use
`Avm1::target_clip_or_root`.
`UpdateContext` no longer contains `target_clip` etc.
2019-12-19 17:30:50 -08:00
Mike Welsh
540b03090a
avm1: hitTest point is actually in root coordinates ( fix #185 )
2019-12-19 12:35:56 -08:00
Nathan Adams
f6f358b4de
avm1: Expose TextFields and allow setting their .text
2019-12-19 10:19:43 -08:00
Mike Welsh
c9a5d2dbb3
chore: Fix clippy lints in 1.40
2019-12-19 09:10:41 -08:00
Nathan Adams
d3848f97ea
avm1: Implemented MovieClip.hittest, without shape flag
2019-12-18 15:21:14 -08:00
Nathan Adams
5f6eea6f25
chore: Refactor system listeners into a reusable system
2019-12-18 15:15:56 -08:00
Mike Welsh
3a8256a993
avm1: Allow setting _name
2019-12-18 14:07:32 -08:00
Mike Welsh
9079b69991
avm1: Push Undefined when trying to construct invalid object
2019-12-18 13:47:01 -08:00
Mike Welsh
bb6a4c119c
avm1: Warn and clear operand stack if not empty after execution
...
Add a check and clear the stack if it isn't empty at the end of
`run_stack_till_empty`. This is probably a bug on our side
and we a good place for breakpoints.
2019-12-18 13:47:01 -08:00
Mike Welsh
8b9aedc4c8
avm1: Fix extra stack frame in event handlers
...
When running an clip event handler (e.g. onEnterFrame), a stack
frame is pushed to get the property value. However, this frame
was causing an extra Undefined to be pushed on the operand stack in
`Avm1::retire_stack_frame`, which would blow out the stack.
Now this stack frame is popped after the property is resolved and
before the function is executed. The function will push its own
stack frame when it executes.
2019-12-18 13:47:01 -08:00
Mike Welsh
3e003ed9dd
avm1: Add missing stage.rs
2019-12-17 22:36:53 -08:00
Mike Welsh
3ebc1ed928
avm1: Stub out Stage properties
...
This is a very rough stub out of Stage.width and height to get
basic V-cams to start functioning.
TODO: Implement the different stage scaling modes. We will probably
want to add a "Stage" display object to handle this.
2019-12-17 22:28:44 -08:00
Mike Welsh
2af76e10f8
core: Mark scale/rotation as dirty when matrix changes
2019-12-17 22:06:34 -08:00
Mike Welsh
74aa127b74
avm1: Fix double borrow in Executable::exec
2019-12-17 21:35:22 -08:00
Mike Welsh
32953d5c5c
avm1: Allow objects in ActionSetTarget2
...
Fixes 8-Bit Theater 3 soft locking on the first frame.
2019-12-17 18:32:25 -08:00
Mike Welsh
a9baf72c53
avm1: Handle trailing / in slash paths
2019-12-17 04:00:01 -08:00
Mike Welsh
dae3e27fb3
avm1: Rename Library::instantiate_by_id
2019-12-17 03:27:05 -08:00
Mike Welsh
1476930e0c
avm1: Implement MovieClip.removeMovieClip
2019-12-17 03:20:01 -08:00
Mike Welsh
1668e823e6
avm1: Implement MovieClip.createEmptyMovieClip
2019-12-17 03:02:07 -08:00
Mike Welsh
d33a8278d7
avm1: Implement MovieClip.duplicateMovieClip
2019-12-17 03:00:56 -08:00
Mike Welsh
009da39f12
avm1: Implement MovieClip.attachMovie
2019-12-17 03:00:56 -08:00
Mike Welsh
d0504104b7
core: Use i32 for display object depth
2019-12-17 02:48:55 -08:00
Mike Welsh
4cb2cefc5b
swf: Switch depth to u16
2019-12-17 02:48:55 -08:00
Mike Welsh
0f3bad8f1b
core: Wrap Font in a Gc
2019-12-17 02:48:55 -08:00
Mike Welsh
289e0b8aff
core: Handle ExportAssets SWF tag
2019-12-16 19:32:34 -08:00
Mike Welsh
b6df9fded0
core: Remove boxes from library items
2019-12-16 19:32:34 -08:00
Nathan Adams
45e497826b
avm1: Implement `Mouse` listeners & events (excluding scroll)
2019-12-16 19:22:10 -08:00
Mike Welsh
c2f4633cdb
avm1: Trace constant_pool in Collect for Activation
2019-12-16 16:14:49 -08:00
Mike Welsh
f270a278c0
avm1: Push Undefined on GetVariable with invalid slash path
2019-12-16 15:33:16 -08:00
Mike Welsh
8b85212513
avm1: Handle .. in slash syntax
2019-12-16 15:24:25 -08:00
Mike Welsh
f4f755e958
avm1: Remove warnings on _currentframe/_totalframe
2019-12-16 10:21:37 -08:00
Nathan Adams
84ff69854a
avm1: Pass mouse events down to movie clips
2019-12-16 10:11:23 -08:00
Nathan Adams
c8e42123cf
avm1: Implemented `_xmouse` and `_ymouse`
2019-12-16 10:11:23 -08:00
Nathan Adams
783037e8cc
chore: Removed array debug code that snuck in. Oops!
2019-12-16 09:56:46 -08:00
Mike Welsh
e4af2502dc
avm1: Fix mismatched action/init_action stack frames
...
DoAction was accidentally creating its stack frame using
Avm1::insert_stack_frame_for_init_action, causing a dummy
Undefined to be pushed and blowing out the stack.
2019-12-16 01:14:06 -08:00
Mike Welsh
bf0b777246
avm1: Use ECMA-262 ToInt32 modulo behavior
...
Everything is a double in ES land, so when converting a number to
int, the double is modulo'd to allow for wrapping 32-bit int
semantics.
See ToInt32 and ToUInt32 in the specs:
https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%202nd%20edition,%20August%201998.pdf
2019-12-16 00:52:27 -08:00
Mike Welsh
39f54b4a16
avm1: Add gotoAndPlay and gotoAndStop MovieClip methods
2019-12-16 00:52:27 -08:00
Mike Welsh
a3e316847b
core: Clamp goto frame in range
2019-12-16 00:52:27 -08:00
Mike Welsh
fa5a168fad
avm1: Clean up MovieClip prototype
2019-12-16 00:52:27 -08:00
Mike Welsh
46365c5702
avm1: Implement clip event method callbacks
2019-12-15 20:01:50 -08:00
Mike Welsh
eb3aa1c878
core: Move `ClipAction` into crate::events
2019-12-15 19:22:23 -08:00
Mike Welsh
76e94dda1c
core: Implement "unload" clip event
...
Fire unload clip event when a movie clip is removed. Added
`ActionType` enum used by `ActionQueue::queue_actions` that
determines the type of action that is running (replaces `is_init`
parameter).
2019-12-15 19:00:16 -08:00
Mike Welsh
38ebdd9d05
core: Fire "load" and "enterFrame" clip events
...
MovieClips will now fire their "load" and "enterFrame" clip events.
Added `MovieClipFlags` to store various flags for the movie clip.
2019-12-15 19:00:16 -08:00
Mike Welsh
174426856f
avm1: Use `EnumSet::from_bits` in `object::as_set_prop_func`
2019-12-15 14:26:43 -08:00
David Wendt
d9aac0f2cf
Adjust `SuperObject` based on actual Flash behavior.
2019-12-15 13:32:04 -08:00
David Wendt
edf7a19eb7
Implement `Function.prototype.toString`.
2019-12-15 13:32:04 -08:00
David Wendt
33c66571f5
Allow `is_instance_of` to inspect the prototype chains of implemented interfaces.
...
This makes the `extends_chain` test pass.
2019-12-15 13:32:04 -08:00
David Wendt
854526923e
Calls to `super` inherently bind to itself.
...
This requires some subclassing nonsense to be able to smuggle a self-reference into `SuperObject`s. When successfully smuggled, all calls to `call` will be invoked with the `super` object as `this`. This allows constructor chaining to work.
Note that not all `Object` trait methods are implemented on `SuperObject`, so things like `delete this.x` in super constructors will randomly fail. This should be fixed.
2019-12-15 13:32:04 -08:00
David Wendt
548f19ffbb
`ActionExtends` uses the class's explicit prototype, not it's implicit prototype which should almost always be `Function.prototype`.
2019-12-15 13:32:04 -08:00
David Wendt
eb06501492
Since `get_local` doesn't scale the prototype chain anymore, we don't need to change the prototype chain traversal anymore.
2019-12-15 13:32:04 -08:00
David Wendt
5c1ac19c1b
Implement `super`, mostly.
...
We implement `super` by way of a new `Object` impl which wraps arbitrary objects with a modified prototype chain. Specifically, the lowest layer of the prototype chain is omitted. This new `SuperObject` script is composable: a chain of two `SuperObject`s will go two levels of inheritance upwards while still maintaining non-prototype property access.
2019-12-15 13:32:04 -08:00
David Wendt
681b4adfa4
Functions close over the constant pool they were defined with.
2019-12-15 13:17:41 -08:00
David Wendt
71d9655f6d
Implement `ASSetPropFlags`
2019-12-15 13:17:41 -08:00
David Wendt
213b3cfca1
Store implemented interfaces on the prototype, not the constructor, so that InstanceOf can get at them.
2019-12-15 13:17:41 -08:00
David Wendt
fcb37bd273
Implement `ActionCastOp`.
2019-12-15 13:17:41 -08:00
David Wendt
1b459f522d
Implement `ActionImplementsOp`.
...
This commit title has won the "World's Lowest-Entropy Commit Title" award for 2019.
2019-12-15 13:17:41 -08:00
David Wendt
ee4b47d062
Add interface support, and add interface checking to `ActionInstanceOf`.
2019-12-15 13:17:41 -08:00
David Wendt
ca93bba5c1
Implement ActionExtends.
2019-12-15 13:14:21 -08:00
Mike Welsh
81e5c7ba1d
core: Rename get_length etc. -> length
2019-12-15 12:33:24 -08:00
Mike Welsh
bc42004db5
core: Implement From for Object variants to Value/ReturnValue
2019-12-15 12:33:24 -08:00
Nathan Adams
133a1c3c91
core: Interacting with memebers on something that isn't an object isn't a hard error
2019-12-15 12:33:24 -08:00
Nathan Adams
aca746eee7
core: Implemented Array.splice with tests
2019-12-15 12:33:24 -08:00
Nathan Adams
31b84c5f19
core: Made arrays a storage property of objects, not a unique object type. Added more corner case tests.
2019-12-15 12:33:24 -08:00
Nathan Adams
32a1eda080
core: Implement Arrays & array prototype
2019-12-15 12:33:24 -08:00
Mike Welsh
3c83d9ac9d
docs: Shuffle some docs in DisplayObject
2019-12-15 10:17:33 -08:00
Mike Welsh
d7393dc81d
core: Add DisplayObjectFlags::TransformedByScript
...
This is set when a DisplayObject is dynamically moved by AS code,
which causes further modification from PlaceObject tags to be
ignored.
2019-12-15 10:17:33 -08:00
Mike Welsh
8c27097240
core: Implement _target property
...
Add DisplayObject::slash_path to get the Flash 4-style slash path
to the clip. This fixes the tellTarget regression test and removes
the superfluous `target_path` from `UpdateContext`.
2019-12-15 10:17:33 -08:00
Mike Welsh
d5f7521061
core: Ignore NaN in StageObject setters
2019-12-15 10:17:33 -08:00
Mike Welsh
c9864eb557
core: Add StageObject properties
2019-12-15 10:17:33 -08:00
Mike Welsh
f2422a2c9f
avm1: Add attributes for _global/_root/_parent
2019-12-15 08:54:26 -08:00
Mike Welsh
c29b042f5e
avm1: Get child clip instances in StageObject
...
Add the logic to get children display objects as properties in
`StageObject`.
2019-12-15 08:54:26 -08:00
Mike Welsh
783ede6f79
core: Add DisplayObject::path
2019-12-15 08:54:26 -08:00
Mike Welsh
73604a891e
core: Move get_child_by_name to DisplayObject
2019-12-15 08:54:26 -08:00
David Wendt
724f845037
Remove the `DisplayNode` slot from `ScriptObject`, since all display node objects should be `StageObject`s now.
2019-12-15 08:54:26 -08:00
David Wendt
fa9329df68
Instantiate all MovieClips as StageObjects.
2019-12-15 08:54:26 -08:00
David Wendt
3df6c7eeef
Always post-instantiate display objects when running tests.
2019-12-15 08:54:26 -08:00
David Wendt
73655c0c88
Add a separate native object type for objects tied to the stage.
2019-12-15 08:54:26 -08:00
Mike Welsh
f0c6b2d8d8
core: Remove this from Object::get/set
2019-12-15 08:54:26 -08:00
Mike Welsh
b59bf40c78
core: Remove this from Object::get/set
2019-12-10 01:36:02 -08:00
Mike Welsh
f7822141b7
core: Rename display_node methods to display_object
2019-12-10 01:36:02 -08:00
Mike Welsh
71e4eb87d7
core: Remove as_*_mut methods on DisplayObject/Object
2019-12-10 01:36:02 -08:00
Mike Welsh
d7740bc3ad
core: Don't touch UpdateContext::active_clip in DisplayObjects
...
DisplayObject code no longer has to manage
UpdateContext::active_clip before calling out to children, because
each child still has access to its Gc pointer.
2019-12-10 01:36:02 -08:00
Mike Welsh
25b86c14ae
core: Move method impls from Button to ButtonData
2019-12-10 01:36:02 -08:00
Mike Welsh
78e65a01df
core: Move method impls from MovieClip to MovieClipData
2019-12-10 01:36:01 -08:00
Mike Welsh
12c1bf7cf1
core: Clean up UpdateContext creation
...
Added Player::mutate_with_update_context, which takes a closure
and passes it an UpdateContext.
2019-12-10 01:36:01 -08:00
Mike Welsh
30ecbd0ecc
core: Use enum_trait_object for DisplayObject
2019-12-10 01:36:01 -08:00
Mike Welsh
23ca66a7e3
avm1: Use enum_trait_object for avm1::Object
2019-12-10 01:36:01 -08:00
Mike Welsh
90b6858bb2
avm1: Fix return value of `Object.addProperty`
2019-12-03 14:59:37 -08:00
Mike Welsh
28364f7d00
avm1: Fix `this` object in GetMember/SetMember
2019-12-03 14:59:01 -08:00
Mike Welsh
1a1cdfa757
desktop: Allow audio creation to fail
...
Switch to NullAudioBackend if CpalAudioBackend fails to initialize.
(This happens on my laptop which doesn't have an audio device!)
2019-11-30 20:08:34 -08:00
Nathan Adams
eb185982cd
Add more Number(x) tests, and corrected primitive_as_number to match
2019-11-29 16:07:35 -08:00
Nathan Adams
85b9ffe102
core: Merge both test macros into a generic test_method
2019-11-29 13:12:00 -08:00
Nathan Adams
1f4405189a
core: Make math test_std also take in versions
2019-11-29 13:12:00 -08:00
Nathan Adams
999bb128de
core: Allow global test_std to test multiple swf versions
2019-11-29 13:12:00 -08:00
Nathan Adams
4c7d37c498
core: Added `avm_debug!` macro
2019-11-29 12:59:45 -08:00
Nathan Adams
d1b73582ce
core: Add feature `avm_debug` that toggles tracing avm actions and stack history
2019-11-29 12:59:45 -08:00
David Wendt
9ec85c3892
Add tests for SWF6 numerical coercions.
2019-11-28 21:32:10 -05:00
David Wendt
f856243247
Primitive coercions should not yield an object just because valueOf is undefined.
2019-11-28 20:53:32 -05:00
David Wendt
ec3ac4e5d6
`undefined` coerces to `0.0` on SWF6
2019-11-28 20:53:32 -05:00
David Wendt
16259ad74a
Calling uncallable values does not actually cause a runtime error in Flash; it just returns null.
...
This was discovered almost by accident: @Dinnerbone noticed that `_global == null`, and surmised that `valueOf` was the culprit. However, this doesn't really make sense: `_global` is a bare object, so it shouldn't have a `valueOf` (and in practice, it doesn't).
The ultimate cause of such an odd comparison is as such:
1. Flash coerces the `_global` object to a numerical primitive by calling `valueOf`.
2. `_global.valueOf` is undefined. Flash handles calls to any uncallable value by literally just having it return `undefined`. In other words, all values are implicitly callable as empty functions.
3. `undefined` is then compared to `null`. These two values *are* equal under abstract equality (`==`). Hence, `_global == null`.
For comparison, modern ECMAScript engines throw errors on calls to uncallable values; and won't attempt to use an invalid `valueOf` to coerce objects. So none of this applies to, say, standard JavaScript in your browser.
2019-11-28 20:53:31 -05:00
Nathan Adams
68760007fc
Lessthan can return `undefined`, not just booleans
2019-11-28 20:53:30 -05:00
Nathan Adams
638231e7fb
swf4 doesn't have NaN or Infinity
2019-11-28 20:53:20 -05:00
Nathan Adams
581d0940b2
NaN == NaN without coercion
2019-11-28 20:43:59 -05:00
Nathan Adams
f33229a2a1
`_global` == null && `_global` == undefined
2019-11-28 20:43:58 -05:00
David Wendt
129d50bfa6
Implement ECMAScript compliant type coercions.
...
This includes ECMA-262 2ed `ToNumber`, `ToPrimitive` (Number), `ToString`, and abstract equality and less-than implementations. Note that `ToPrimitive` is only the "number hint" variant, and Flash specifically *never* calls `toString` like how ECMA-262 specifies.
Several builtins inherit numerical coercion - I'm not 100% sure if that's correct.
The following ActionScript opcodes now perform ECMA-262 style coercions:
`ActionAdd2` (uses `valueOf` / "ToPrimitive hint Number")
`ActionDecrement` (uses `valueOf`)
`ActionEquals2` (uses `valueOf`)
`ActionGetMember` (member names, uses `toString`)
`ActionIncrement` (uses `valueOf`)
`ActionLess2` (uses `valueOf`)
`ActionGreater` (uses `valueOf`)
`ActionSetMember` (member names, uses `toString`)
`ActionStringEquals` (uses `toString`)
`ActionStringGreater` (uses `toString`)
`ActionStringLess` (uses `toString`)
`ActionToNumber` (uses `valueOf`)
`ActionToString` (uses `toString`)
`ActionTrace` (uses `toString`)
The following functions now gained user-specified coercions via `toString`:
`_global.number` (uses `valueOf`)
`_global.is_nan` (uses `valueOf`)
Every function in `Math` (uses `valueOf`)
2019-11-28 20:23:39 -05:00
Nathan Adams
2650433271
Fixed get_keys with prototypes
2019-11-27 22:30:31 +01:00
David Wendt
46e58c3ecd
Remove `ReturnValue.ignore` entirely, since you really *do* need to resolve `ReturnValue`s, even if you don't want the result.
2019-11-27 14:52:07 -05:00
David Wendt
2c87888e28
Implement prototype chain recursion limit of 255 prototypes.
...
In Flash, this also at least claims to halt ActionScript execution on the movie. No such implementation of AVM poisoning currently exists in Ruffle, primarily because it's unclear what gets poisoned and implementing some of these options isn't yet possible:
1. AVM (e.g. all movies) - we would need to make the AVM fail silently in this case. This is the most straightforward way to poison the movie, but I'm not sure if this is how Flash actually does it, or if it poisons...
2. Movie - the current structure of movies is incompatible with adding arbitrary data to them. We need to merge `moviefetch` in before we can attach data to loaded movies.
3. MovieClip - this would also be implementable but has problems. How do child MovieClips know that their parent has been poisoned, or vice versa? What if a movie clip is loaded from one movie and moved into another?
As a result, I have decided to hold off on implementing recursion poisoning until I know where it's supposed to go and how to implement that.
2019-11-27 08:59:16 -05:00
David Wendt
4655ebe73f
Always push the constructed object on the stack.
2019-11-26 15:07:59 -05:00
David Wendt
b9f02c290c
Functions should be traceable.
2019-11-26 15:07:03 -05:00
David Wendt
0b1afcf8be
Implement `ActionInstanceOf` (for non-interface types)
2019-11-26 14:51:06 -05:00
David Wendt
3c8d9b9c1c
`new` should be called on the prototype - not the constructor function. This will allow different host object impls to subclass correctly.
2019-11-26 14:51:06 -05:00
David Wendt
e8632bbcaa
Implement `valueOf` for `Object` and fix the `toString` impl.
2019-11-26 14:51:06 -05:00
David Wendt
73c3b42cd4
Move `force_set` and `force_set_virtual` into the `Object` trait. They are now called `define_value` and `add_property`, respectively.
...
While I don't expect every host object to implement it correctly, this also gets rid of a lot of unnecessary `unwrap` calls that would allow a poorly-written Flash file to kill the interpreter.
2019-11-26 14:51:06 -05:00
David Wendt
983c0fb200
Add proto chain inspection to the object interface.
2019-11-26 14:51:06 -05:00
David Wendt
0e59e1c961
Allow host-provided constructors to override `new` and provide host objects to the AVM when a particular constructor is called.
2019-11-26 14:51:06 -05:00
David Wendt
d25bdbacf8
Separate `Object` into an interface trait and a standard implementation. Host object implementations may bypass `ScriptObject` and directly interface with the AVM using this trait.
...
Note that host objects that do so will *not* have access to their standard representation from within member functions - you will need to extend the interface to accomodate for them. This is due to long-standing limitations with type IDs and downcasting with types that bear lifetimes - it's entirely an unsafe operation and exposing such a facility to safe Rust is unsound. However, this will at least let us separate out several things from ScriptObject that don't need to be there for the time being.
2019-11-26 14:51:05 -05:00
David Wendt
6dd40f8354
Split properties into a separate module.
2019-11-26 14:51:05 -05:00
David Wendt
813783881b
Implement explicit prototypes on user-generated functions.
...
`Object::function` now returns a pre-allocated function object. You may supply it an explicit prototype to have it linked into the function object (which is why we have to return a cell).
2019-11-26 14:51:05 -05:00
David Wendt
f347992eeb
Add `as_usize` method to `Value`
2019-11-26 14:51:05 -05:00
David Wendt
207a157f20
Add missing usize conversion
2019-11-26 14:51:05 -05:00
kmeisthax
fb34f73159
Manually constructing `Value` should no longer be necessary
...
Co-Authored-By: Nathan Adams <dinnerbone@dinnerbone.com>
2019-11-26 14:51:05 -05:00
David Wendt
1cb374da8a
`ActionSetMember` accepts non-String names as parameters.
2019-11-26 14:51:04 -05:00
David Wendt
fafad818d4
Implement `ActionInitObject`
2019-11-26 14:51:04 -05:00
David Wendt
da315c7311
Fix docstrings on these modules
2019-11-26 14:51:04 -05:00
David Wendt
b4e9b8442e
Implement `isPropertyEnumerable` and `isPrototypeOf`.
2019-11-26 14:51:04 -05:00
David Wendt
aa7997b658
Expose user-defined virtual properties to AVM code
2019-11-26 14:51:04 -05:00
David Wendt
a8e1654c9e
Implement `ActionNewMethod` and `ActionNewObject`
2019-11-26 14:51:04 -05:00
David Wendt
2f965d1c64
First stab at moving system builtins to explicit prototypes
2019-11-26 14:51:03 -05:00
Nathan Adams
882373d969
Object prototyping
2019-11-26 14:51:03 -05:00
Mike Welsh
6eaab8efdf
core: Merge #113 , interworking of Rust + ActionScript
...
Internal support for interworking Rust and ActionScript code
2019-11-25 04:27:05 -08:00
David Wendt
b8c24890fc
Allow overwriting read-only virtual properties in scope chains.
...
The previous behavior had an oversight: if you tried to set a variable with the same name as an in-scope property, it would always try to overwrite that property. This can fail silently and doesn't match with Flash Player behavior. Now, an attempt to overwrite a read-only property is instead correctly rejected so that it can be defined in local scope.
2019-11-23 22:00:37 -05:00
Nathan Adams
ae064b62be
chore: Change to no_drop from empty_drop for new gc-arena
2019-11-22 17:53:05 +00:00
David Wendt
bae0476113
Don't panic when double-locking a stack frame.
2019-11-20 14:30:34 -05:00
David Wendt
17215cc787
Remove the `NoResult` variant of `ReturnValue` as it is no longer useful or in use.
2019-11-20 14:30:33 -05:00
David Wendt
8c1d25b0f7
Add conversions for all the same conversions regular `Value`s have, so that you don't have to constantly mark things as `ReturnValue::Immediate`
2019-11-20 14:30:33 -05:00
David Wendt
e4eb930d44
Remove all references to stack continuations from our documentation.
2019-11-20 14:30:33 -05:00
David Wendt
5bf90653c4
Add implicit coercions to remove most instances of manually constructing a `ReturnValue`.
2019-11-20 14:30:33 -05:00
David Wendt
4b824370f4
Remove the stack continuation system. If we decide to structure this system in the same way in the future, we'll probably use async functions or something like that.
2019-11-20 14:30:33 -05:00
David Wendt
2aa5b62b44
Make most code that might touch user-defined functions falliable.
2019-11-20 14:30:32 -05:00
David Wendt
a49af7815c
Resolve all existing return values on the Rust stack.
2019-11-20 14:30:32 -05:00
David Wendt
bb1cde5557
Avoid double borrow panic caused by unreasonably long lifetime of `.write()` temporary
2019-11-20 14:30:32 -05:00
David Wendt
7284794c0b
Store the return value on the activation object when it's retired.
2019-11-20 14:30:32 -05:00
David Wendt
e2dcf47c56
Add a method to force resolve a `ReturnValue` on the Rust stack via recursion.
2019-11-20 14:30:31 -05:00
David Wendt
bc74b2fc4a
Track the no-double-reader flag on a per-frame basis, and add a "run until current frame exits" routine.
2019-11-20 14:30:31 -05:00
David Wendt
dd4462c104
Warn when attempting to attach a second continuation onto an existing stack frame, since we don't support that use case.
2019-11-20 14:30:31 -05:00
David Wendt
a2ee7f9e3a
Replace `Option<Value<'gc>>` with a dedicated `ReturnValue<'gc>` type with associated methods.
...
This type explicitly signals if an immediate value is to be returned, if a value is to be returned on the stack, or if no return value is to be generated. Holders of a `ReturnValue` can also use `and_then` to schedule a `StackContinuation` to be executed when and if that value is ready.
`StackContinuations` now yield `ReturnValues` as well, so they have a moderate level of composability. For example, if you need to get a property from an object and push it on the stack, you can return the result of calling `get` directly and the machinery ensures it eventually gets there.
2019-11-20 14:30:31 -05:00
David Wendt
2a3d324a33
Implement the "reschedule same continuation" behavior in AVM
2019-11-20 14:30:31 -05:00
David Wendt
40dbc535fc
Remove force_get now that everything can read virtual properties correctly.
2019-11-20 14:30:30 -05:00
David Wendt
e36a0d8350
Allow native functions to resolve on the AVM stack for whatever reason.
2019-11-20 14:30:30 -05:00
David Wendt
4dffe448e4
Get rid of the automatic `this` on stack continuations
2019-11-20 14:30:30 -05:00
David Wendt
9d422dc269
Allow getters to resolve on the AVM1 stack.
...
This involved yet another macro, `and_then!`, to avoid a ridiculous amount of duplicate code. It calls a continuation whenever it's value is ready, even if the value resolved on the Rust stack.
`locals_into_form_values` does not currently support this. It skips any property that does not resolve on the Rust stack. Future work is required to resolve this.
2019-11-20 14:30:30 -05:00
David Wendt
a59fffbc4e
Ensure that the value of the newly constructed `this` is returned in all cases.
...
This involves the use of a "stack continuation" system. Due to previous lifetime issues with using closures directly (see `8ea6c6234dba925ec5fbc61502627fb62b05916c`), we instead use a macro that constructs a `Collect`able type holding the things the continuation needs to continue working with. The syntax is largely similar to Rust closures but with the addition of an explicit list of bound variables, all of which must be `Collect`.
2019-11-20 14:30:29 -05:00
David Wendt
a95861d596
Stack continuations can now directly manipulate the return value of an ActionScript function.
2019-11-20 14:30:29 -05:00
David Wendt
8485e919db
Add a notion of "and_then" to activation objects.
...
This effectively constitutes the ability to assign arbitrary native contiuations to the AVM stack.
2019-11-20 14:30:29 -05:00
Mike Welsh
e3d0d9031d
core: Handle empty JPEGTables tags ( fix #116 )
2019-11-11 17:08:08 -05:00
David Wendt
1236b5491e
Ensure calls to `getURL`, invocations of `ActionGetURL`, and other functionality that writes locals doesn't panic due to double mutable borrows.
2019-11-11 14:09:25 -05:00
David Wendt
4e16c91dbb
Add tests for `locals_into_form_values`.
2019-11-11 14:09:25 -05:00
Mike Welsh
b05745da01
audio: Fix uninit warnings in MP3 decoder in Rust 1.39
2019-11-11 14:06:41 -05:00
Mike Welsh
7d98c87a33
desktop: Implement event sound envelopes
2019-10-30 19:26:19 -07:00
David Wendt
0d4e21162a
Implement `ActionEnumerate2`.
2019-10-30 19:26:06 -07:00
Mike Welsh
63be104739
docs: Add module documentation for MovieClip
...
(Really an excuse to kick CI to re-run)
2019-10-30 10:59:53 -07:00
Mike Welsh
ab58c37feb
core: Handle gaps between StreamSoundBlocks
2019-10-29 23:36:51 -07:00
Mike Welsh
443dcfaeea
core: Stop stream sound when gaps are encountered
...
Generally there is one SoundStreamBlock per frame in a MovieClip.
However, if there are gaps between stream sounds, the stream must
stop and then pick up when the next block is encountered.
TODO: Sometimes Flash will do weird stuff and export a stream that
is plainly out of sync if there are gaps between sounds (the old
trick was to put a silent stream across the entire timeline to fix
this). This happens when the streams are too close together with
MP3 encoding. Investigate this more.
2019-10-29 23:36:51 -07:00
Mike Welsh
1a7959b96d
audio: Initial syncing of stream sound to MovieClip timeline
2019-10-29 23:36:51 -07:00
David Wendt
6a81b5327d
Implement `DoInitAction`.
...
This pushes an extra `undefined` onto the stack to fix underflow in AS2 interface declarations.
It is currently unknown if this is a miscompilation or if some other value is supposed to be there.
# Conflicts:
# core/src/avm1.rs
# core/src/avm1/object.rs
2019-10-29 11:11:25 -07:00
Mike Welsh
33c0bbd0ce
desktop: Fix incorrect rendering of bitmaps w/ color transforms
...
The premultiplied alpha was not properly considered when there was
a color transform on a bitmap. Now the shader unmultiplies the
alpha before applying the color transform, and the remultiplies it.
2019-10-29 00:03:29 -07:00
Mike Welsh
35be57553e
desktop: Improve animation sync
...
The timing on desktop was causing the movie to run too slow,
causing it to get out of sync. Now it should run at the correct
speed.
2019-10-28 21:05:18 -07:00
Mike Welsh
cb26342a24
core: Fix regression in goto when replacing a previous child
...
Goto forward that did a replace was not replacing the previous child.
TODO: Figure out how to write a regression test for this; will
need a special test harness probably because this only happens with
Graphics, not MovieClips, so we can't attach AS to them to get
trace output.
2019-10-28 03:47:57 -07:00
Mike Welsh
eaea6aaf20
audio: Fix audio for ADPCM stream sounds
...
When a stream sound uses ADPCM compression, the ADPCM header is
included in each SoundStreamBlock (as opposed to stream sounds
in the other formats). This header wasn't being parsed, resulting
in corrupted audio (see https://homestarrunner.com/main12.swf ).
2019-10-28 02:51:46 -07:00
Mike Welsh
01f47d675c
core: Move UpdateContext into context submodule
2019-10-27 13:49:47 -07:00
Mike Welsh
dddfb42e1e
core: Merge ActionContext into UpdateContext
2019-10-27 13:49:47 -07:00
Mike Welsh
c4c895c6c9
core: Move display objects to display_object module
2019-10-26 15:04:52 -07:00
Mike Welsh
247fd3b9c6
core: Run gotos immediately
...
Gotos now goto the specified frames immediately as opposed to
queuing. Actions on the new frame will still be queued,
and are executed after any current actions are completed.
2019-10-26 03:35:58 -07:00
Mike Welsh
e78be0f06f
core: Remove avm from UpdateContext
2019-10-26 02:21:48 -07:00
Mike Welsh
c718a6c8cb
core: Add more properties to ActionContext
...
ActionContext needs to be able to call goto, so it needs access
to most of UpdateContext.
TODO: Remove ActionContext, and only have UpdateContext?
2019-10-26 02:21:46 -07:00
Mike Welsh
09fa755405
core: Make Library::device_font optional
2019-10-26 02:20:42 -07:00
Mike Welsh
57a737357b
core: Remove RefMut/Ref from UpdateContext
2019-10-26 02:20:42 -07:00
Mike Welsh
a4bed6c643
core: Improve execution order of AS
2019-10-26 01:52:42 -07:00
Nathan Adams
6a2806b44a
chore: Allow Into<Value> for test results
2019-10-21 17:22:03 +02:00
Nathan Adams
348e7f6adb
chore: Impl From<numeric> for Value, better dev ergonomics
2019-10-21 17:14:00 +02:00
Nathan Adams
83b7d679ed
chore: Impl From<GcCell<'gc, Object<'gc>>> for Value, better dev ergonomics
2019-10-21 13:00:52 +02:00
Nathan Adams
fa5616a4f9
chore: Impl From<bool> for Value, better dev ergonomics
2019-10-21 12:55:17 +02:00
Nathan Adams
4c81ac8a6d
chore: Take Into<Value> for Object.(force_)set
2019-10-21 12:48:45 +02:00
Nathan Adams
0ba9cef2f0
chore: Take Into<Value> for tests
2019-10-21 12:44:21 +02:00
Nathan Adams
f24ab37810
chore: Impl From<&str> for Value, better dev ergonomics
2019-10-21 12:33:49 +02:00
Nathan Adams
796c641b3b
chore: Impl From<String> for Value, better dev ergonomics
2019-10-21 12:30:59 +02:00
Mike Welsh
84cb00b44b
chore: Fix clippy lint in Value::as_bool
2019-10-21 02:11:50 -07:00
Will Brindle
019ea79551
core: return true for objects as boolean
2019-10-20 10:00:18 +01:00
Will Brindle
d3006cb37b
chore fix formatting
2019-10-19 10:36:24 +01:00
Will Brindle
5b298a0814
chore: refactor test code to share common methods
2019-10-19 10:31:37 +01:00
Will Brindle
3fa198d8f2
core: Add extra test cases for Number function and resolve the issues they highlight
2019-10-19 10:29:26 +01:00
Will Brindle
463d0fc352
core: implement isNaN and Number functions. Involves updating to_number function in Value. Note: this varies a little from the ECMA spec such as not allowing spaces in numbers (i.e. ' 5' => NaN). No definitive reference for this but was found experimentally. Same with not supporting 'Infinity'
2019-10-19 10:29:26 +01:00
Will Brindle
38c66b5b8d
core: implement Boolean function
2019-10-19 10:29:26 +01:00
Mike Welsh
f5710854b2
avm1: Fix off-by-one bug in Activation::has_local_register
2019-10-15 17:10:34 -07:00
Mike Welsh
e315fcb6b3
swf: Store register count from DefineFunction2
...
Also update avm1::Function to use register_count.
2019-10-15 17:09:14 -07:00
David Wendt
ad17166c63
Store the player version in `Avm1` so that `current_swf_version` doesn't require the context.
2019-10-13 18:55:39 -04:00
David Wendt
7e2cf03789
Implement register underflow behavior.
...
This has the side effect of letting us remove the `Option` on register_count since setting this to `0` is equivalent now. Furthermore, we can skip an allocation if a function requests no registers.
2019-10-13 18:41:07 -04:00
David Wendt
911cf64cb0
Fix clippy lints
2019-10-13 17:58:21 -04:00
David Wendt
e830273fe5
Don't pull multiple borrows on the same `GcCell`
2019-10-13 17:54:09 -04:00
David Wendt
911de06584
Only version MovieClips. Unversioned display objects recursively read their parents' versions, or the default version otherwise.
2019-10-13 17:27:04 -04:00
David Wendt
269775c0e1
Implement the SWF5 version negotiation algorithm.
...
On SWF5, the SWF version of the callee depends on it's this parameter. Calling it as a function rather than a method downgrades the callee. SWF6+ use the callee's inherent SWF version and do not allow changing the SWF version like this.
2019-10-12 10:39:55 -04:00
David Wendt
d543e67528
Inline the first 8 registers with a `SmallVec`.
2019-10-12 10:39:54 -04:00
David Wendt
d909fb01bb
Use player version as a fallback when the current SWF version is requested without a valid stack.
2019-10-12 10:39:53 -04:00
David Wendt
17b1e0429c
Explicitly allow `_global` and `_root` to be overwritten.
2019-10-12 10:39:53 -04:00
David Wendt
4709d2d0b4
Revert "Allow overwriting virtual properties via setting `set` to `None`."
...
This reverts commit 0a8adfca6e5fce8835552c1c7aba063649ba3aeb.
2019-10-12 10:39:53 -04:00
David Wendt
59dc35b8a4
Allow scope chain resolution to retrieve virtual properties
2019-10-12 10:39:53 -04:00
David Wendt
a92190a456
Support pre-resolving `_parent`
2019-10-12 10:39:52 -04:00
David Wendt
0f04d97002
Move `_global` and `_root` to the MovieClip object, and implement `_parent` while we're in here.
2019-10-12 10:39:52 -04:00
David Wendt
d35e36def5
Allow overwriting virtual properties via setting `set` to `None`.
2019-10-12 10:39:52 -04:00
David Wendt
feaa3dd203
Add a version parameter to every DisplayObject impl
2019-10-12 10:39:52 -04:00
David Wendt
8668d47403
Add a player version parameter and expose it to AVM
2019-10-12 10:39:51 -04:00
David Wendt
2f257c83e8
Remove the representation split between functions defined with `DefineFunction` and `DefineFunction2`. Both are now represented with a single struct and enum.
2019-10-12 10:39:51 -04:00
David Wendt
b4ddd323f2
Use the same methodology to construct new scopes for tellTarget.
2019-10-12 10:39:51 -04:00
David Wendt
1b62ead082
Construct the closure scope chain in one pass, which lets us skip the vec allocation.
2019-10-12 10:39:50 -04:00
Mike Welsh
1ab5211bfe
swf: Fix compiling with lzma feature
2019-10-11 23:18:57 -07:00
Mike Welsh
4aec120ffb
core: Add Bitmap display object
...
Converts the Bitmap character to a proper display object. This can
be instantiated directly in a PlaceObject tag in SWFv9 movies,
compared to the previous versions which indirectly references
bitmaps from Shape tags.
2019-10-11 16:33:58 -07:00
Mike Welsh
800147043a
swf: Try to recover from incorrect zlib streams
...
Some SWFs are compressed incorrectly, often with incorrect
compressed/uncompressed lengths, causing the zlib decoders
to vomit if you try to decompress them fully. However, often times
the data still decompresses all the way to the End tag, and we
still want to try to play it even if it's corrupt.
Now these errors only omit a warning, and we'll continue to run
the SWF.
Addresses #86 .
2019-10-10 13:41:43 -07:00
Mike Welsh
40722dcef0
avm1: Merge#81, add property attributes
...
Added object property attributes
2019-10-09 10:24:21 -07:00
Will Brindle
ba939fc00b
chore: add comment explaining the weird NaN situation
2019-10-09 06:17:41 +01:00
Will Brindle
32554e271f
chore: remove trailing whitespace
2019-10-08 21:40:15 +01:00
Will Brindle
f84f807bf1
core: refactor to make use of equality implementation
2019-10-08 21:36:50 +01:00
Will Brindle
70b7b1c807
chore: fix clippy & fmt issues
2019-10-08 21:04:26 +01:00
Will Brindle
6508ec6b6c
core: nan equality
2019-10-08 20:51:21 +01:00
Will Brindle
e2c7af5cda
core: fix boolean strict comparison
2019-10-08 19:59:32 +01:00
Will Brindle
9cf381b0e0
core: add support for actions GreaterThan, StringGreaterThan and StrictEquals
2019-10-08 19:59:32 +01:00
Nathan Adams
d697d03cf0
Drop the `Attribute::` everywhere
2019-10-08 20:35:23 +02:00
Mike Welsh
fb442688cb
chore: Change edit_text.rs to LF line endings
2019-10-08 11:15:15 -07:00
Nathan Adams
3d09ec81e2
Add Attribute::DontEnum
2019-10-08 16:36:39 +02:00
Nathan Adams
f782aaee18
Add Attribute::ReadOnly
2019-10-08 15:24:57 +02:00
Nathan Adams
f2a4000ee2
Added object property attributes (initially just DontDelete)
2019-10-08 14:30:36 +02:00
Will Brindle
2e3748438a
core: define globals for NaN, Infinity, -Infinity. Should fix `typeof NaN`
2019-10-08 02:59:26 -07:00
Mike Welsh
3b288272d4
text: Hack to skip HTML in dynamic text fields
2019-10-07 23:23:45 -07:00
Mike Welsh
eded29ce6d
text: Add dummy implementation of device text
...
Embed an SWF version of Noto Sans (core/assets/*) into the player.
The player will load this font and use it to render device text.
This is a quicky implementation to get dynamic device text
rendering.
2019-10-07 23:23:45 -07:00
Mike Welsh
de1cedb653
core: Initial EditText implementation
2019-10-07 23:23:45 -07:00
Mike Welsh
9084524580
core: Render DefineFont3 at proper size ( fixes #47 )
...
Per SWF19, shape coordinates in DefineFont3 are at 20x the size of
DefineFont1/2.
2019-10-07 12:05:27 -07:00
Mike Welsh
574ede0541
avm1: Return proper root object for Avm1::root_object
...
Was returning start_clip instead. Also call
DisplayObject::post_instantiation for root after it's created in
Player::new.
2019-10-07 01:36:05 -07:00
Mike Welsh
4477e8458f
avm1: Return dummy value 1 for getBytesLoaded/getBytesTotal
...
Previously returned 0 which would cause divide by 0 in many
preloaders.
2019-10-07 00:33:30 -07:00
Mike Welsh
18a3494de2
chore: Typo supress -> suppress
2019-10-06 15:24:38 -07:00
Mike Welsh
b6eba80ebd
chore: cargo fmt
2019-10-06 14:57:43 -07:00
Mike Welsh
1c3e4406b3
chore: Fix clippy lints
...
* Remove clone calls from Copy objects
* Used Iterator::cloned() instead of manually cloning
* Pass swf::Function into AvmFunction2::new()
* Use action_clone_sprite
2019-10-06 14:57:36 -07:00
David Wendt
2d365856a7
Fix tellTarget being broken by the introduction of scopes. We now create a new scope chain based off the selected active clip.
2019-10-06 13:02:31 -07:00
David Wendt
588b2bb061
Fixes to make tests compile again
2019-10-06 13:02:31 -07:00
David Wendt
5873eefb06
Since it is possible to have virtual properties in the scope chain, overwriting them should trigger their setters.
...
Define, since it's intended for setting locals only, always uses force-set and does not trigger setters.
2019-10-06 13:02:31 -07:00
David Wendt
06d0cf5ed1
Add a stern warning to be triggered if multiple readers are open at once.
2019-10-06 13:02:31 -07:00
David Wendt
8ed09e22ba
Refactor: Since `function.rs` handles calling conventions it should just hand the avm an activation object directly
2019-10-06 13:02:31 -07:00
David Wendt
cf5420e2e1
Implement register preloading, for variables we already have implemented.
2019-10-06 13:02:31 -07:00
David Wendt
8734c036a7
Removed unused function
2019-10-06 13:02:31 -07:00
David Wendt
91cbbb4e9c
`ActionWaitForFrame`/`2` should not create their own readers either.
2019-10-06 13:02:31 -07:00
David Wendt
a5865d7c7d
Implement DefineFunction2
2019-10-06 13:02:31 -07:00
David Wendt
ec1b5c457e
Allow activations to hold their own private register set.
2019-10-06 13:02:31 -07:00
David Wendt
d822a35404
Fix `ActionIf` and `ActionJump`
2019-10-06 13:02:31 -07:00
David Wendt
171cb9f014
GetMember needs to support string coercions (e.g. `array[1]` should work)
2019-10-06 13:02:31 -07:00
David Wendt
deecd85c81
Implement `SetMember`
2019-10-06 13:02:31 -07:00
David Wendt
697a02bd05
Implement `GetMember`
2019-10-06 13:02:31 -07:00
David Wendt
51a7b426fd
Implement registers, including register pushes and `ActionStoreRegister`.
2019-10-06 13:02:31 -07:00
David Wendt
582b3a8968
Adjust GetVariable/SetVariable based on test results
2019-10-06 13:02:31 -07:00
David Wendt
17482b8810
ActionDelete and ActionDelete2 return a bool
2019-10-06 13:02:31 -07:00
David Wendt
002dd9904c
Implement `ActionDelete` / `ActionDelete2`
2019-10-06 13:02:31 -07:00
David Wendt
9b81a92516
Fix a number of bugs preventing the with-scope test from working at all:
...
1. We no longer implicitly return Undefined unless we're specifically returning from a function (this also keeps actions from filling the stack with Undefined)
2. With scopes are now always inserted behind the current set of locals rather than overriding them
3. `ActionSubtract` now subtracts (instead of adds)
2019-10-06 13:02:31 -07:00
David Wendt
fc1ce7692b
Implement ActionWith
2019-10-06 13:02:31 -07:00
David Wendt
7bf6e22714
Minor refactor/adjustment of GetVariable/SetVariable impl to explicitly check for slashpaths
2019-10-06 13:02:31 -07:00
David Wendt
face06f268
Impl `ActionEnumerate`
2019-10-06 13:02:31 -07:00
David Wendt
22f75b7a4c
Implement closure scope
2019-10-06 13:02:31 -07:00
David Wendt
d757ce0cd2
Implement arguments object.
2019-10-06 13:02:31 -07:00
David Wendt
90b0140ac2
Don't lock up when running scope operations
2019-10-06 13:02:31 -07:00
David Wendt
9ede91df4f
Move `this` into the activation object.
...
Also, change the implicit `this` on functions to `active_clip` as per the `ActionContext` docstrings.
2019-10-06 13:02:31 -07:00
David Wendt
ca1fb713a3
Execute actions in MovieClip scope
2019-10-06 13:02:31 -07:00
David Wendt
215d4f2df4
Provide arguments as local variables as some functions look for these
2019-10-06 13:02:31 -07:00
David Wendt
3ab2eecc3c
Support implicit return via boundary break
2019-10-06 13:02:31 -07:00
David Wendt
f3d83908ab
All activation frames share the same stack (and can see each other's garbage).
2019-10-06 13:02:31 -07:00
David Wendt
667b30f4b5
Add scope chains for local variable resolution.
2019-10-06 13:02:31 -07:00
David Wendt
13a88143d6
Off-the-end execution should implicitly return undefined if there's another stack frame to run.
2019-10-06 13:02:31 -07:00
David Wendt
edc37dee5d
Add support for calling bare functions and returning from them.
2019-10-06 13:02:31 -07:00
David Wendt
00b5d9ecf5
Implement DefineFunction
2019-10-06 13:02:31 -07:00
David Wendt
83c832ce86
Distinguish between Native and ActionScript functions.
2019-10-06 13:02:31 -07:00
David Wendt
728c3d18db
Allow stack frames to hold SwfSlices, which are `Rc` already.
...
Functions that manipulate the stack now run inside of `with_current_reader_mut`, which calls a given function with a Reader for the current stack frame. If the stack frame still exists after that code runs, we update it's PC with the Reader's position.
2019-10-06 13:02:31 -07:00
David Wendt
617b493733
Give AVM1 the notion of a stack frame.
...
This necessitates the use of a copy of SWF data into the GC arena, along with unsafe (and possibly unsound) pointer manipulation to get the action reader to hold a GC pointer.
2019-10-06 13:02:30 -07:00
David Wendt
693e791d75
Make `do_action` execute out of a code stack.
2019-10-06 13:02:30 -07:00
Will Brindle
06c81d6cc1
chore: combine DefineText functions into 1 and paramterise
2019-10-06 13:02:30 -07:00
Will Brindle
acfe0cc478
chore: follow naming conventions for functions
2019-10-06 13:02:30 -07:00
Will Brindle
b0f25c9266
swf: implement DefineText2
2019-10-06 13:02:30 -07:00
Will Brindle
06b0d42c8b
core: Add matrix tests ( #72 )
...
* Add matrix tests. Requires the approx crate
2019-10-03 02:44:26 -07:00
Mike Welsh
2740f3ccc1
chore: Globally allow clippy::unneeded_field_pattern
...
Often times we want to explicty destructure instead of using ..
because the compiler will emit errors if the structure changes.
(see https://github.com/rust-lang/rust-clippy/issues/1741 and #69 )
2019-10-02 12:57:58 -07:00
Mike Welsh
b157354fef
chore: Fix clippy lints
2019-10-02 12:39:04 -07:00
Nathan Adams
2b54791cbb
Changed storage of object values to allow for dynamic (vs stored) properties
2019-10-02 10:49:08 -07:00
Will Brindle
bd5bed0327
Get rid of constant from atan2 test and remove now unneeded clippy directives
2019-09-30 10:38:42 -07:00
Will Brindle
5a36e4d78e
Fix remaining tests
2019-09-30 10:38:42 -07:00
Will Brindle
abe80806ab
Use f64 methods for tests to resolve rounding errors
2019-09-30 10:38:42 -07:00
Mike Welsh
e0811be40d
avm1: Fix Random action
2019-09-27 19:32:22 -07:00
Mike Welsh
c8cec3132f
avm1: Fix GotoFrame2 one-frame-off error
...
Frame numbers pushed/popped from the stack for GotoFrame2 are
1-based. This differs for GotoFrame which is 0-based and encodes
the frame alongside the instruction.
2019-09-27 18:09:52 -07:00
Mike Welsh
1c88de5132
avm1: Fix doc typo
2019-09-27 17:58:40 -07:00
Mike Welsh
67506e54ca
avm1: Remove debug print
2019-09-27 17:57:37 -07:00
Mike Welsh
646ad967a2
avm1: Fix Subtract action
2019-09-27 17:56:34 -07:00
Mike Welsh
4ec8765f7f
avm1: Fix Subtract action
2019-09-27 17:32:51 -07:00
Mike Welsh
06d91a2b0d
avm1: Stub out CloneSprite/RemoveSprite
2019-09-27 17:28:14 -07:00
Mike Welsh
5ee7b9c8aa
avm1: Use into_number_v1 for GetProperty ( fix #55 )
...
Flash 4 published actions using Strings, so `into_number_v1`
should be used to coerce them to numbers.
2019-09-27 17:21:50 -07:00
Mike Welsh
af163d9183
core: Support start, stop, event sounds in audio backend
...
Event sounds on the timeline in Flash have a "sync" setting,
which allows them to stop other sounds or only play if the
sound is not already playing.
2019-09-27 13:50:03 -07:00
Mike Welsh
875f250b86
chore: cargo fmt for 1.38
2019-09-26 12:25:07 -07:00
Mike Welsh
8c2113bbdf
chore: cargo fmt pcm.rs
2019-09-26 11:46:44 -07:00
Mike Welsh
b38552204d
chore: cargo fmt
2019-09-26 11:45:45 -07:00
David Wendt
a0ed4d339d
Add fscommand checking to `ActionGetUrl2`.
2019-09-20 21:38:37 -04:00
David Wendt
b61f264ac7
Add a check for `fscommand:` URLs
2019-09-20 15:11:33 -04:00
Mike Welsh
c2eb96eed0
core: Fix incorrect clamping in ADPCM decoder
...
Caused artifacts in ADPCM encoded audio.
2019-09-19 11:05:27 -07:00
Mike Welsh
547da84c9c
core: Add stop_all_sounds to audio backend
...
Implemented in web and desktop.
2019-09-19 00:47:05 -07:00
Mike Welsh
e052a70a5a
desktop: Support looping and start/end points for event sounds
...
Renamed `AudioBackend::play_sound` to `start_sound`, and this
also takes a `SoundInfo` parameter with the event sound settings
from the SWF file.
Desktop now obeys the loop and start/end point settings. Envelopes
are still TODO.
2019-09-19 00:47:05 -07:00
Mike Welsh
9c8721c127
core: Drop rodio and use only cpal for audio backend
...
Drop the rodio dependency and directly use cpal for the audio
backend. Use the sample crate for audio mixing and resampling.
2019-09-19 00:47:05 -07:00
Mike Welsh
be0bb0b803
core: Fix looping movieclips
2019-09-17 19:24:55 -05:00
Mike Welsh
a331c565b3
core: More goto fixes
2019-09-17 19:24:55 -05:00
Mike Welsh
7b63dc05c4
core: Initial implementation of SetTarget2
...
Implement the SetTarget2 action, which pops the target off of the
stack, and GetProperty 11, which pushes _target.
However, our implementation of _target is not accurate yet,
because it requires dynamically building the target path. Currently
we fake it by caching the last path to tellTarget.
2019-09-17 12:51:44 -05:00
Mike Welsh
856a4c6130
core: Improve TellTarget support
...
The AVM1 contains an explicit "target clip" that is used for older
Flash 4-era actions. This target clip can be set to an invalid
value, at which point Play, Stop, etc. will fail silently.
For GetVariable and SetVariable, if the target is invalid,
the variables will be modified on root ("/").
2019-09-17 12:51:44 -05:00
Mike Welsh
82c1116c42
chore: cargo fmt
2019-09-16 20:37:11 -07:00
David Wendt
f00e938299
Clean up unused functionality in preparation of a PR.
2019-09-16 20:04:30 -07:00
David Wendt
b40b10daf6
Support form submission from `getURL` function
2019-09-16 20:04:30 -07:00
David Wendt
eb1b474528
Propagate AVM locals to `NavigationBackend`.
2019-09-16 20:04:30 -07:00
David Wendt
130d9736bc
Allow builtins access to the AVM1 state directly.
2019-09-16 20:04:30 -07:00
David Wendt
7deb33c231
Fail remote SWF loads rather than jamming a download in the user's face
2019-09-16 20:04:30 -07:00
David Wendt
63e1484d38
Support legacy `GetURL`/`GetURL2` actions
2019-09-16 20:04:30 -07:00
David Wendt
359d3e4780
Propagate the RNG to the action context. This lets random work.
2019-09-16 20:04:30 -07:00
David Wendt
26c928b68f
Add a better error message for missing object methods
2019-09-16 20:04:30 -07:00
David Wendt
70d4f6c7c2
Implement more math builtins.
...
Random is currently a stub.
2019-09-16 20:04:30 -07:00
David Wendt
4e9fb2676b
Add `getURL` global builtin
2019-09-16 20:04:30 -07:00
David Wendt
0f9db1744b
Add a backend for controlling the enclosing web browser.
2019-09-16 20:04:30 -07:00
Mike Welsh
2d2b473fe1
core: Clean up MovieClip::place_object
2019-09-16 22:03:34 -05:00
Mike Welsh
f0e345bea8
core: Improve handing of gotos ( fix #33 )
...
Display objects will now properly persist during gotos instead
of erroneously being recreated.
2019-09-16 22:03:34 -05:00
Mike Welsh
4222701c9c
chore: cargo fmt
2019-09-15 11:44:18 -07:00
Mike Welsh
94afcfb2e1
core: Add DisplayObject::id
2019-09-15 11:35:04 -07:00
Mike Welsh
28f0ce3c83
Mask work
2019-09-09 20:42:08 -05:00
Mike Welsh
3c38405a71
avm1: Update swf-rs and use byte slices for functions
2019-09-09 13:57:29 -07:00
Mike Welsh
545af9379a
chore: cargo fmt pass
2019-09-06 15:19:59 -07:00
Mike Welsh
ae10092c97
core: Clean up button states
2019-09-06 15:15:34 -07:00
Mike Welsh
0849826c48
core: Add static data for morph shape and text
2019-09-06 15:15:34 -07:00
Nathan Adams
4ba12517d9
Implemented more Math methods (with tests)
2019-09-04 20:35:48 +02:00
Nathan Adams
a4cdbc4f70
Added `Math` unit tests, first avm tests :)
2019-09-02 22:19:09 +02:00
Nathan Adams
63f85446b7
Renamed builtins to globals, `_global` is a reference to the globals object
2019-09-02 20:45:19 +02:00
Nathan Adams
200129452a
Pass along `ActionContext` to functions
2019-09-02 19:28:38 +02:00
Nathan Adams
002272d7b5
Functions return `[type Function]` when converted to strings
2019-08-31 18:28:28 +02:00
Nathan Adams
7a18ece455
`DisplayObject`s all have a AVM1 `Value`. Added `toString()` default method for Objects (but not functions)
2019-08-31 17:54:15 +02:00
Nathan Adams
bd63a82e9e
Split off `Value` into its own file, for slightly less code clutter
2019-08-31 14:29:46 +02:00
Nathan Adams
2eca394a58
Implemented `typeof` for movieclips and functions
2019-08-31 14:09:37 +02:00
Nathan Adams
14786aeba6
Implemented more movie clip methods + added a basic macro to cut down on boilerplate for movie clip methods
2019-08-31 01:25:14 +02:00
Nathan Adams
543419abee
Added `Object::set_function` helper method
2019-08-30 20:49:56 +02:00
Nathan Adams
2fd7d456a4
Movie clip access from AS. Functions are now callable objects, and receive `this`.
2019-08-30 20:37:48 +02:00
Nathan Adams
87e6b766c2
Use named functions for builtins
2019-08-28 21:43:20 -05:00
Nathan Adams
2378ea3881
Shuffled around some avm1 builtins & types
2019-08-28 21:43:20 -05:00
Nathan Adams
a74d1734af
Initial work on avm1 method calling, local and global variables.
...
This contains just enough AS1 support for early trivial loading screens to not crash (ie badgers badgers badgers)
2019-08-28 21:43:20 -05:00
Mike Welsh
0b72ad1c00
core: Fix text position with multiple text blocks
...
The text x position would not be remembered between text blocks,
so the positioning of such text would be incorrect. Now the x position
is properly advanced.
Fixes #42 .
2019-08-26 17:46:38 -07:00
Mike Welsh
6a5c5ab1df
chore: Add rustfmt.toml and rustfmt pass
2019-08-26 16:38:48 -07:00
Nathan Adams
06d9f39c0e
More verbose avm1 value conversion errors
2019-08-26 14:45:35 -05:00
Mike Welsh
d9f70ddde8
core: GC trace through DisplayObject base
2019-08-22 23:28:51 -07:00
Mike Welsh
5998876271
core: Don't panic on missing characters in button
2019-08-22 21:54:00 -07:00
Mike Welsh
0214b3e447
core: Use matrix in DefineText ( fix #34 )
...
Text was not rendered in the correct position because it did not
use the matrix specified in the DefineText tag. I think this is an
extra Matrix used to adjust text alignment.
Fixes #34 .
2019-08-22 18:40:47 -07:00
Mike Welsh
324a410cb1
render: Properly render premultiplied alpha bitmaps
2019-08-22 15:24:50 -07:00
Mike Welsh
c1b8978555
core: Add max frames-per-tick as sanity
...
Avoid running too many frames at once.
2019-08-22 13:31:24 -07:00
Mike Welsh
8117b0cfdc
avm1: Remove some debug spew
2019-08-22 10:24:38 -07:00
Mike Welsh
7b6a3d525a
core: Single frame movieclips should stop
2019-08-22 09:54:40 -07:00
Mike Welsh
b0eff353a9
tests: Add initial SWF tests
2019-08-22 09:54:40 -07:00
Mike Welsh
dd3748a520
core: GC collect_debt each frame
2019-08-19 22:34:49 -07:00
Mike Welsh
9cbeacd7b2
core: Transform mouse coordinates from viewport to stage
2019-08-19 22:27:38 -07:00
Mike Welsh
637588fae5
core: Store view matrix in player
...
Player is now in charge of scaling/cropping/translating the content
to fit the viewport size supplied by the frontend.
Added backend::render::Letterbox, which stores the margin sizes
for letter/pillarboxing.
2019-08-19 22:27:38 -07:00
Mike Welsh
f3f4fa6179
web: Add mouse up/down/move handlers
2019-08-19 22:27:38 -07:00
Mike Welsh
8be9b9089b
avm1: Stub out StartDrag/EndDrag
2019-08-19 22:27:38 -07:00
Mike Welsh
ff74409d20
core: Tick audio backend each frame
2019-08-19 22:27:38 -07:00
Mike Welsh
7922aca921
core: Mouse pick in top-to-bottom order
2019-08-19 22:27:38 -07:00
Mike Welsh
59c9385cb7
core: Collect GC debt at the end of each frame
2019-08-19 22:27:38 -07:00
Mike Welsh
0143d9716e
core: Button work
2019-08-19 22:27:38 -07:00
Mike Welsh
91a0272773
avm1: Log errors/unimplemented actions
2019-08-19 22:27:38 -07:00
Mike Welsh
9d962fd634
core: Improve button support
2019-08-19 22:27:38 -07:00
Mike Welsh
d8ddf78bdc
avm1: Implement _rotation and improve SetProperty
...
Implement _rotation and add SetProperty/GetProperty for these
values.
2019-08-19 22:27:38 -07:00
Mike Welsh
017cd563dc
avm1: Implement ActionPush for constant pool vals
2019-08-19 22:27:38 -07:00
Mike Welsh
e890ad33e6
avm1: Allow String for ActionGotoFrame2
2019-08-19 22:27:38 -07:00
Mike Welsh
fe086c11ff
core: Store clip frame labels
...
Bump swf-rs revision to allow for read_frame_label calls.
Also fix read_place_object to take an explicit length.
2019-08-19 22:27:38 -07:00
Mike Welsh
7e1b1e0357
avm1: Adjust for Twips in GetProperty/SetProperty
2019-08-19 22:27:38 -07:00
Mike Welsh
6c923930e6
avm1: Stub out ActionSetProperty
...
Rough impl of ActionSetProperty action. Not all properties
implemented. Add DisplayObject::matrix_mut.
2019-08-19 22:27:38 -07:00
Mike Welsh
0ab20e01c1
Add dyn
2019-08-19 22:27:38 -07:00
Mike Welsh
20ec170552
avm1: Implement GetVariable/SetVariable
2019-08-19 22:27:38 -07:00
Mike Welsh
ecd9b18e90
core: Squelch warning in Button
2019-08-19 22:27:37 -07:00
Mike Welsh
1b86162bf1
avm1: Fix warning in SetTarget
2019-08-19 22:27:37 -07:00
Mike Welsh
49cc48d2d1
core: Run actions after a goto
2019-08-19 22:27:37 -07:00
Mike Welsh
ce606cece8
core: Re-enable AVM1
2019-08-19 22:27:37 -07:00
Mike Welsh
5bba546a53
core: Add BoundingBox calculations
...
TODO: Add dirty flag and cache matrices.
2019-08-19 17:29:55 -07:00
Mike Welsh
2c4639eb6c
core: Add BoundingBox and static data to Graphic
...
Add BoundingBox, which will store the AABB of dispaly objects.
Added static_data to Graphic, which is a reference to constant data
shared between each instance of a specific graphic. Currently
holds the render handle, bounding box, and character ID.
2019-08-19 17:29:55 -07:00
Mike Welsh
2c7e3c835f
core: Add parent to DisplayObjectBase
2019-08-19 17:29:55 -07:00
Mike Welsh
39f1853440
core: Bump swf-rs revision to support ProductInfo
...
swf-rs now reads ProductInfo and DebugId SWF tags. These are not
documented by SWF19.
See: http://wahlers.com.br/claus/blog/undocumented-swf-tags-written-by-mxmlc/
Fixes #20 .
2019-08-16 10:03:16 -07:00
Mike Welsh
4666d211a7
core: Add dyn to fix Rust 1.37 warnings
...
Omitting dyn on trait objects now emits a warning, so add missing
dyn where necessary.
2019-08-15 13:54:20 -07:00
Mike Welsh
4c6395bd83
core: Use latest git branch for jpeg-decoder
...
The current version of jpeg-decoder on crates.io (0.1.15) panics
when encountering a valid JPEG marker of length 2. Some SWF files
contained JPEGs with a COM segment of length 2. This is fixed
on the master branch of jpeg-decoder.
2019-08-14 23:19:10 -07:00
Mike Welsh
746b9d8518
core: Support for DefineBitsJPEG3/4
...
TODO: Pull out all JPEG decoding into core, remove jpeg-decoder
dependency from backend crates.
2019-08-12 16:44:49 -07:00
Mike Welsh
a3998b657b
core: Remove invalid JPEG data from DefineBitsJPEG
...
DefineBitsJPEG tags can have some extraneous bytes inside the
stream. Splice these out when decoding the JPEG.
TODO: Docs say this should only happen for SWF versions before 8?
2019-08-12 15:45:40 -07:00
Mike Welsh
23db688e6f
core: Add DefineBitsLossless decoding function
...
Pulled out the code for decoding DefinieBitsLossless tags into
backend::render::define_bits_lossless_to_rgba. Switch to libflate
for zlib decoding.
2019-08-12 15:45:40 -07:00
Mike Welsh
f3a746de21
core: Improve morph shape
...
Morph shapes where move_to was not in a matching pair would crash.
Now the previous pen position is used to generate the matching
move_to.
The ratio was backwards, causing the shape tween to run in
reverse. Morph shapes should now animate in the proper direction.
2019-08-11 23:58:06 -07:00
Mike Welsh
af2287a658
desktop: Add letterbox to viewport
...
Add getters to Player to allow access to the type Renderer.
Letter/pillarboxes added as window resized.
2019-08-10 10:18:32 -07:00
Mike Welsh
24fc403e06
core: Make player generic over backend
2019-08-09 22:34:15 -07:00
Mike Welsh
2accd5bdd4
core: Remove audio struct
2019-08-09 16:03:13 -07:00
Mike Welsh
3edc3c3d3e
web: Disable auto-play, add click-to-play
2019-08-09 14:50:20 -07:00
Mike Welsh
e64e306137
Rework audio to allow for streaming decoding
2019-08-08 15:59:32 -07:00
Mike Welsh
725cdae6c5
Begin AVM1 cleanup
2019-08-08 15:58:45 -07:00
Mike Welsh
ce5faefe1f
Work
2019-08-08 15:57:10 -07:00
Mike Welsh
fd8f58c6c2
Work
2019-07-10 21:04:59 -07:00
Mike Welsh
2a365288e8
Update to latest swf-rs
2019-06-17 02:59:32 -07:00
Mike Welsh
3cefeeba6a
Use twips for internal calculations
...
Switch from pixels to twips for internal calculations. swf crate
was updated to add a Twips wrapper-type. Ruffle will use this type
internally for transforms and shapes. This fixes some precision
errors in rendering (see heroes_of_cybertron.swf) and will match
what the Flash Player does internally more closely. (e.g.
DisplayObject x and y will be quantized to 1/20 pixel units). It
is up to the renderer to convert units from twip space to pixels
when rendering.
2019-05-17 13:40:56 -07:00
Mike Welsh
6673527b0a
core: Add clip depth to DisplayObject
2019-05-12 13:48:00 -04:00
Mike Welsh
79b3a7007d
core: Initial morph shape implementation
2019-05-12 12:55:48 -04:00
Mike Welsh
af33b8538e
desktop: Better event sounds
2019-05-09 17:43:53 -07:00
Mike Welsh
61189cfb84
core: Fix text transforms
2019-05-09 14:14:21 -07:00
Mike Welsh
efe3270ce0
web: Decode streams completely on preload (for now)
2019-05-09 12:43:26 -07:00
Mike Welsh
74743f327c
core: Remove unused file
2019-05-09 12:43:03 -07:00
Mike Welsh
12d6d3342b
core: Switch to rust-gc
2019-05-08 18:10:43 -07:00
Mike Welsh
20844185d7
core: Set preload flag
2019-05-07 12:11:32 -07:00
Mike Welsh
cb6d96955d
Remove debug spew
2019-05-07 09:52:22 -07:00
Mike Welsh
e6e8536672
Clean up DisplayObject traits
2019-05-07 03:34:17 -07:00
Mike Welsh
7983d9eb96
Clean up DisplayObject instantiation
2019-05-07 03:22:58 -07:00
Mike Welsh
60b673986b
Work
2019-05-06 23:31:34 -07:00
Mike Welsh
598b342106
core: Add name property to DisplayObject
2019-05-06 11:15:52 -07:00
Mike Welsh
8262db3991
ADPCM decoder
2019-05-06 02:34:45 -07:00
Mike Welsh
cf2091477d
Support uncompressed event sounds
2019-05-05 22:04:35 -07:00
Mike Welsh
a0c478379d
Preload assets for web
...
Run through all definition tags to preload assets on web.
TODO: Keep track of which assets are done loading.
2019-05-05 17:35:00 -07:00
Mike Welsh
1a4734896d
Event sounds and text on web
2019-05-05 15:55:27 -07:00
Mike Welsh
2480469c2c
First pass of static text
2019-05-04 11:45:11 -07:00
Mike Welsh
1f6aa4e4e1
Add MorphShape stub
2019-05-03 14:25:54 -07:00
Mike Welsh
34f31a37f0
Use BTreeMap for display list
2019-05-03 14:25:01 -07:00
Mike Welsh
1dfedae485
Add some button functionality
2019-05-03 11:44:12 -07:00
Mike Welsh
884b7c915a
Gradients on desktop
2019-05-02 22:09:25 -07:00
Mike Welsh
6e8082f01b
Reorganized backend structure
2019-05-02 19:56:17 -07:00
Mike Welsh
ae8df0486b
Use a handle for the JS<->Rust Player object
2019-05-02 17:17:02 -07:00
Mike Welsh
747aeba2ed
First pass of Button
2019-05-01 22:34:02 -07:00
Mike Welsh
708175419a
Add AVM1 opcodes
2019-05-01 22:00:40 -07:00
Mike Welsh
d6e68dd43e
Add initial AVM1 implementation
2019-05-01 17:46:49 -07:00
Mike Welsh
5e88f43280
Color transforms
2019-05-01 09:55:54 -07:00
Mike Welsh
ded41dffb0
work
2019-04-30 17:46:32 -07:00
Mike Welsh
eb6c23d967
Work
2019-04-30 01:53:21 -07:00
Mike Welsh
663ad9f663
Work
2019-04-29 13:24:29 -07:00
Mike Welsh
ed3797f28c
work
2019-04-28 22:55:44 -07:00
Mike Welsh
ee64cc77bc
Reforactor
2019-04-27 23:08:59 -07:00