Commit Graph

396 Commits

Author SHA1 Message Date
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
Mike Welsh 9e83f27afd tests: Add test for DoInitAction 2019-10-29 11:11:25 -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 2cdb8d3656 tests: execution_order -> execution_order1 2019-10-26 03:35:58 -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 838944b5a1 tests: Add tests for goto execution order 2019-10-26 02:20:42 -07:00
Mike Welsh 863801371b tests: Better output when regression test fails 2019-10-26 01:52:42 -07:00
Mike Welsh 6da55f4fc2 tests: Remove ignore on execution order test 2019-10-26 01:52:42 -07:00
Mike Welsh a4bed6c643 core: Improve execution order of AS 2019-10-26 01:52:42 -07:00
Mike Welsh 666075c651 tests: Allow attributes in swf_tests macro
Also ignore failing execution_order test
2019-10-26 01:52:42 -07:00
Mike Welsh 008581f1bd tests: Add test for parent-child execution order
(currently fails)
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 b0624a3654 tests: Add define_function2 and register test 2019-10-15 17:20:48 -07: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 ff7fe94e90 Add test for `_global`, `_root`, and `_parent` as movie clip properties 2019-10-12 10:39:54 -04:00
David Wendt b3c955b4d8 Install the remainder of tests that currently pass, but needed to have child clips removed 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 caa36bfecc Add `closure_scope` and `variable_args` tests. 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 3b42c70e48 core: Disable LZMA support by default 2019-10-12 00:09:10 -07:00
Mike Welsh 1ab5211bfe swf: Fix compiling with lzma feature 2019-10-11 23:18:57 -07:00
Mike Welsh 7a5b2607d4 chore: Renormalize line endings in misc files 2019-10-11 16:53:36 -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 0814b17fd8 chore: add tests for equality and greaterthan 2019-10-08 20:45:39 +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 4856efe7d8 chore: add integration tests for typeof 2019-10-08 02:59:26 -07: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 7ed4ea0a2b tests: Rename integration_tests -> regression_tests 2019-10-06 23:58:52 -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 52b6832db2 chore: Move swf-rs to ruffle workspace
Move the swf-rs crate into the Ruffle workspace proper instead of
having a separate repo. This makes it easier to make changes to
the SWF parsing code during development. swf-rs can still be
published as its own crate from the subfolder.
2019-10-02 18:58:58 -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