Commit Graph

710 Commits

Author SHA1 Message Date
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 45a5eae86a
avm1: Merge #84, AVM1 function cleanup 2019-10-15 17:39:40 -07: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 2b90c61a69 core: Fix error message when LZMA feature is disabled 2019-10-12 00:09:10 -07: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 160ec4d0c3 swf: > to >= in read_button_action 2019-10-11 17:57:23 -07:00
Mike Welsh d9facdd89b swf: Fix underflow in parsing corrupt DefineButton2 tags
401799_pre_Scene_1.swf has a DefineButton2 tag with an invalid
CondActionSize field (it should be at least 4). It's unclear how
Flash handles this. For now, avoid the underflow and return an
error instead.

Fixes #92.
2019-10-11 17:55:38 -07:00
Mike Welsh 7a5b2607d4 chore: Renormalize line endings in misc files 2019-10-11 16:53:36 -07:00
Mike Welsh 1ec90b8a14 chore: Add gitattributes to normalize line endings 2019-10-11 16:53:36 -07:00
Nathan Adams 59d39d6572 Added a bulk swf scanning tool 2019-10-11 16:37:15 -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 d95e31905e swf: Handle missing null byte on metadata tag 2019-10-10 21:52:41 -07:00
Mike Welsh ae0bf52a53 swf: Handle shortened DefineButtonSound tag 2019-10-10 21:52:41 -07:00
Mike Welsh b0aa2ff952 tests: Use pretty printing on failure 2019-10-10 21:52:41 -07:00
Mike Welsh 8fc0ae3630 tests: Add swf tests for PlaceObject3 image tag 2019-10-10 21:52:41 -07:00
Mike Welsh 3609095b97 swf: Fix parsing image PlaceObject3 tags 2019-10-10 21:52:41 -07:00
Mike Welsh 58642d0e0e tests: Add swf tests for DefineMorphShape gradient flags 2019-10-10 21:52:41 -07:00
Mike Welsh 1b7449e651 swf: Fix reading DefineMorphShape gradient flags
The interpolation and spread modes of morph shape gradients were
not being properly parsed. Fixed this and cleaned up some of the
gradient parsing code.
2019-10-10 21:52:41 -07:00
Mike Welsh bb4b931610 swf: Allow for missing latency seek value in SoundStreamHead
Some software would export SWFs with a missing LatencySeek field
in SoundStreamHead (e.g., CoffeeCup Firestarter). Silently ignore
this error if the field is missing.
2019-10-10 21:52:41 -07:00
Mike Welsh 9957a4b8ae swf: Add test for DefineFont3 w/ device font 2019-10-10 21:52:41 -07:00
Mike Welsh 657a0baec0 swf: Fix incorrect parsing of DefineFont2/3 with device fonts 2019-10-10 21:52:41 -07:00
Mike Welsh 614903bdec swf: Remove panic when data left over in tag 2019-10-10 21:52:41 -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 93a221aea4 swf: Add tests for errors on incorrect parse 2019-10-10 00:55:09 -07:00