Commit Graph

396 Commits

Author SHA1 Message Date
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
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 ae80900f17 core: Add tellTarget regression test 2019-09-17 12:51:44 -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
Mike Welsh 1ff86012ae chore: Fix jpeg-decoder warnings in Cargo.toml 2019-09-04 15:56:10 -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
Mike Welsh 35652ae87e chore: Update dependencies
Run cargo update. Remove git dependency on jpeg-decoder (the latest
version was published to crates.io). Update swf-rs to latest to
disable smoothing in SWFv7 and lower (addresses #28).
2019-08-29 14:57:12 -07: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 a220a98c5b tests: Add looping clip test 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