Commit Graph

387 Commits

Author SHA1 Message Date
Tal Hayon 7b9049cedf core: Add DefineBinaryData and SymbolClass connection (Part of #1368) 2021-08-21 12:24:46 -06:00
dependabot[bot] b8a9e28acb chore: Bump bitstream-io from 1.1.0 to 1.2.0
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/tuffy/bitstream-io/releases)
- [Commits](https://github.com/tuffy/bitstream-io/compare/v1.1.0...v1.2.0)

---
updated-dependencies:
- dependency-name: bitstream-io
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-17 08:24:29 +03:00
dependabot[bot] a317a09d17 chore: Bump bitflags from 1.2.1 to 1.3.2
Bumps [bitflags](https://github.com/bitflags/bitflags) from 1.2.1 to 1.3.2.
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitflags/bitflags/compare/1.2.1...1.3.2)

---
updated-dependencies:
- dependency-name: bitflags
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-16 23:41:06 +03:00
relrelb 3d8779b377 swf: Ignore length mismatch in `read_action`
Flash continues in such case, so just warn instead of failing.
2021-08-03 14:40:59 -07:00
relrelb 04af276ecb swf: Extract `Opcode::format` and `TagCode::format` 2021-08-03 14:40:59 -07:00
Chris Midgley 0c6f7101b8 docs: update swf README to have working examples 2021-08-03 12:04:58 -07:00
David Wendt 7dc86fdeb0 swf: Throw an error if an ABC bitstream calls for a parameter with more optional parameters than actual ones. 2021-07-20 22:10:30 -04:00
David Wendt 4122c1b96e swf: Default method parameters are indexed starting from the first optional parameter, not from zero. 2021-07-20 22:05:29 -04:00
relrelb d2eb46d3be chore: Reserve capacity for vectors
This avoids unnecessary re-allocations and thus should improve
performance in both memory and time terms.
2021-07-20 16:25:23 -07:00
relrelb 5dde3ecabf swf: Optimize `read_f64_me` and `write_f64_me`
Each function is reduced to just 3 opcodes on x86:
https://godbolt.org/z/n6q6zxnh6

WebAssembly benefits as well: https://godbolt.org/z/fcETE9GYn

This should improve load-time performance because read_f64_me is
used frequently (for each AVM1 double constant).
2021-07-16 01:29:49 +03:00
relrelb c2378416a9 tests: Simplify `read_tag_bytes_from_file_with_index`
Let the `Reader` outlive outside the loop, so it tracks its own
position, instead of doing so manually.
Also move `read_from_file` outside and reuse it.
2021-07-12 23:09:29 +03:00
relrelb 99deb90a1f swf: Avoid using `Reader::input` directly
Change two cases to use `Reader::read_slice` instead of `self.input`.
Not only this avoids relying on an implementation detail, this also
raises an `UnexpectedEof` error if the read is beyond the SWF.
2021-07-12 23:09:29 +03:00
relrelb ef9c073d26 swf: General cleanup
Just mechanical cleanups to ease future refactors.
2021-07-12 23:09:29 +03:00
relrelb 9e18e32b40 swf: Fix read_i24
Only the third byte should be cast to i8 in order to sign extend correctly.
avmplus reference: https://github.com/adobe/avmplus/blob/master/core/AvmCore-inlines.h#L387-L395
2021-07-09 19:56:52 +03:00
relrelb 32c6d8dba0 swf: Fix write_i24
It was writing in the wrong endian.
2021-07-09 19:56:52 +03:00
relrelb 1cbbdecccf swf: Introduce and use `Color::to_rgba` 2021-07-09 19:56:52 +03:00
relrelb 580d8c3562 chore: Use to_le_bytes in more places 2021-07-09 19:56:52 +03:00
relrelb 87e9dda250 chore: Use from_le_bytes in more places 2021-07-09 19:56:52 +03:00
relrelb 169c79fa3a chore: Minor cleanups 2021-06-26 23:05:11 +03:00
relrelb 9c1ebc7f20 swf: Cleanup Error 2021-06-26 23:05:11 +03:00
relrelb 7b37bf6809 chore: Avoid spelling "movieclip"
* Prefer "MovieClip" in comments.
* Prefer "mc" for variable names.
2021-06-24 14:36:45 +03:00
relrelb 0fd1c05fd5 chore: Use into() in more places 2021-06-22 11:49:41 -07:00
Mike Welsh 56c260fa74 swf: Add NameCharacter tag 2021-06-20 14:01:07 -07:00
dependabot[bot] c22c18b809 chore: Bump bitstream-io from 1.0.0 to 1.1.0
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/tuffy/bitstream-io/releases)
- [Commits](https://github.com/tuffy/bitstream-io/commits)

---
updated-dependencies:
- dependency-name: bitstream-io
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-20 03:10:31 -07:00
Mike Welsh 21c351fe5b swf: Change Twips::zero fn to Twips::ZERO const 2021-06-08 14:57:15 -07:00
Mike Welsh d23ea90459 swf: Change Matrix to use Fixed16 for a, b, c, d
Matrices in an SWF file store their scale/skew components in
in 16.16 format (fbits).

Split `ruffle_core::Matrix` and `swf::Matrix`. `swf::Matrix` now
stores its data as `Fixed16` instead of immediately converting to
`f32`.
2021-06-08 14:57:15 -07:00
dependabot[bot] 2f1dc0cbb1 chore: Bump approx from 0.4.0 to 0.5.0
Bumps [approx](https://github.com/brendanzab/approx) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/brendanzab/approx/releases)
- [Commits](https://github.com/brendanzab/approx/compare/v0.4.0...v0.5.0)

---
updated-dependencies:
- dependency-name: approx
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-07 11:30:59 -07:00
relrelb b8eae51888 swf: Move num_colors into BitmapFormat::ColorMap8 2021-06-07 11:29:28 -07:00
relrelb 53cc9f38fc swf: Use casting instead of ToPrimitive 2021-06-07 11:29:28 -07:00
relrelb de6e2a04a4 swf: Number enum VideoCodec 2021-06-07 11:29:28 -07:00
relrelb 50a4643253 swf: Number enum VideoDeblocking 2021-06-07 11:29:28 -07:00
relrelb 636775f1e2 swf: Number enum TextGridFit 2021-06-07 11:29:28 -07:00
relrelb a45fdba4d1 swf: Number enum FontThickness 2021-06-07 11:29:28 -07:00
relrelb 88b6632188 swf: Number enum TextAlign 2021-06-07 11:29:28 -07:00
relrelb 781e3ff0cd swf: Number enum AudioCompression 2021-06-07 11:29:28 -07:00
relrelb ee14945974 swf: Number enum LineCapStyle 2021-06-07 11:29:28 -07:00
relrelb f6d04061b0 swf: Number enum GradientSpread 2021-06-07 11:29:28 -07:00
relrelb fed4facd8a swf: Number enum SoundEvent 2021-06-07 11:29:28 -07:00
relrelb 0d279a05c2 swf: Number enum BlendMode 2021-06-07 11:29:28 -07:00
relrelb 72113dbcf2 swf: Number enum Language 2021-06-07 11:29:28 -07:00
relrelb f82faf9603 chore: Appease clippy 2021-06-05 10:16:00 -07:00
Mike Welsh f173b81e38 swf: Use bitflags for Function flags 2021-05-30 22:14:32 -07:00
Mike Welsh 2b98c878f0 swf: Use Fixed in more places 2021-05-30 21:24:03 -07:00
Mike Welsh e1439f4105 swf: Add HeaderExt struct providing additional info
When reading an SWF, search for FileAttributes and
SetBackgroundColor and return this along with the header data
because it's useful (in particular, the AS3 flag).
2021-05-23 23:02:38 -07:00
Mike Welsh 8960414436 swf: Use bitflags for FileAttributes 2021-05-22 15:53:02 -07:00
Eduardo Sánchez Muñoz e3dc8ff28e swf: SwfStr: reimplement `Debug` with `std::ascii::escape_default`
The string will now be surrounded with quotes (`"`), non-ASCII characters (UTF-8 or not) will be escaped in hexadecimal form (`\xNN`) and ASCII control characters will be escaped (`\x01`, `\n`, `\t`).
2021-05-12 10:53:26 -07:00
Mike Welsh 9538647422 tests: Fix swf::Fixed tests in --release (fix #4313)
Use `#[cfg_attr(debug_assertions, should_panic)]` to ensure that
the tests only expect to panic in debug builds.

Fixes #4313.
2021-05-11 20:53:23 -07:00
dependabot[bot] 185a4f5b8f chore: Bump lzma-rs from 0.1.3 to 0.2.0
Bumps [lzma-rs](https://github.com/gendx/lzma-rs) from 0.1.3 to 0.2.0.
- [Release notes](https://github.com/gendx/lzma-rs/releases)
- [Changelog](https://github.com/gendx/lzma-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gendx/lzma-rs/compare/v0.1.3...v0.2.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-03 15:37:29 -07:00
CUB3D 12a198f671 avm2: Implement Op::Coerce and add tests 2021-04-21 00:33:11 -07:00
CUB3D 89c01dca18 swf: Add support for AVM2 domain memory opcodes 2021-04-21 00:33:11 -07:00
Mike Welsh 0552d26551 core: Use Fixed8 and i16 for ColorTransform
Use the proper types for ColorTransform:
 * Fixed8 (8.8) format for multiplicative component
 * i16 format for additive component

This matches the behavior of Flash (for example, alpha only changes
in units of 1/256).
2021-04-19 15:47:52 -07:00
Mike Welsh 50f2ecb1b5 swf: Add Fixed8 and Fixed16 types 2021-04-19 15:47:52 -07:00
Mike Welsh db6000f071 avm2: Fix parsing of variable-length s32 values
The values are not sign-extended as the spec suggests; a negative
value must use all 5 bytes.
2021-04-18 17:32:01 -07:00
dependabot-preview[bot] 9832a7385e build(deps): bump libflate from 1.0.4 to 1.1.0
Bumps [libflate](https://github.com/sile/libflate) from 1.0.4 to 1.1.0.
- [Release notes](https://github.com/sile/libflate/releases)
- [Commits](https://github.com/sile/libflate/compare/1.0.4...1.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-17 10:25:29 -07:00
Mike Welsh b9d84c0a82 chore: Appease clippy
Honor the branches-sharing-code lint.
2021-04-15 00:02:27 -07:00
EmperorBale a39a1dd64f swf: Add missing opcodes 2021-04-14 21:41:31 -07:00
relrelb 20d6fcc128 chore: Remove unnecessary type annotations 2021-04-10 18:39:16 -07:00
CUB3D d5c2e5559b avm2: Don't mutably borrow for pos() 2021-04-03 16:37:47 -06:00
relrelb 15c1cf5bf6 chore: Appease clippy 2021-03-23 16:16:35 -07:00
relrelb e840dce803 common_tess: Make Vertex layout-agnostic
And define a specific layout in webgl instead.
This brings common_tess closer to serve wgpu (which has a different
Vertex layout).
2021-03-23 16:16:35 -07:00
relrelb e594f602b6 chore: Twips::new(0) -> Twips::zero() 2021-03-13 00:56:04 -08:00
Adrian Wielgosik 1c2492005c
avm2: Fix AVM2 reader not reading variable-length numbers correctly 2021-03-11 19:55:08 -08:00
Mads Marquart 121ae43d25 swf: Remove unused encoding from avm1::read::Reader 2021-02-27 17:04:42 -08:00
Mads Marquart 66f5c856d7 swf: Make a few functions const 2021-02-27 17:04:42 -08:00
Mads Marquart 1455671cd7 swf: Change read_tag_with_code to take an already parsed tag 2021-02-27 17:04:42 -08:00
Mads Marquart 9243010cc0 swf: Clean up a few imports 2021-02-27 17:04:42 -08:00
Mads Marquart 24780003e7 swf: Deduplicate different read methods 2021-02-27 17:04:42 -08:00
Mads Marquart dad21d4398 swf: Make avm2 Reader operate directly with byte slices 2021-02-27 17:04:42 -08:00
Mike Welsh 3099914374 chore: Appease clippy 2021-02-27 16:10:46 -08:00
David Wendt 92bfc18e1d swf: Make video-related tags publicly parsable 2021-02-16 19:03:48 -08:00
relrelb bb89391f3a chore: Avoid deprecated constants
The Rust documentation considers numeric constants prefixed with std::
as deprecated.
For example: https://doc.rust-lang.org/std/u16/constant.MAX.html.
2021-02-12 06:36:17 -08:00
Mike Welsh e5fb1f09e7 chore: Appease clippy
* #[derive(Collect)] should be before #[collect]
 * Replace redunant `&buf[..]` with `buf`
 * Changes most cases of UPPERCase to UpperCase
 * Allow upper_case_acronym on most SWF types, as they are from
   SWF spec/more annoying to change.
2021-02-12 06:32:42 -08:00
TÖRÖK Attila 80b0bd3b33 swf: Add VideoCodec::ScreenVideoV2 variant 2021-02-12 03:37:14 -08:00
Napen123 a132f68688 docs: Update the documentation of SwfStr 2021-02-07 23:44:19 -08:00
Napen123 1ef3de8556 docs: Document the Rectangle type in the swf crate 2021-02-07 23:44:19 -08:00
Napen123 404fc72cb5 docs: Document the Color type in the swf crate 2021-02-07 23:44:19 -08:00
Napen123 52ebc48b2c docs: Update the documentation of Twips
Add code examples to all Twips methods and convert method references to actual links.
2021-02-07 23:44:19 -08:00
dependabot-preview[bot] dd4860c469 build(deps): bump encoding_rs from 0.8.26 to 0.8.28
Bumps [encoding_rs](https://github.com/hsivonen/encoding_rs) from 0.8.26 to 0.8.28.
- [Release notes](https://github.com/hsivonen/encoding_rs/releases)
- [Commits](https://github.com/hsivonen/encoding_rs/compare/v0.8.26...v0.8.28)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-04 11:22:31 -08:00
Mike Welsh 47f0f980b8 core: Handle PlaceObject tags with malformed clip actions
Some SWFs in the wild have PlaceObject tags with ending ClipActions
that are 2 bytes instead of the required 4 bytes (see #2899).
Swallow the error in this case so that the tag can run.
2021-02-02 23:56:48 -08:00
Mike Welsh 02d99c3686 core: CSMTextSettings tag alters text hit testing
Normally, a hit test on static text will consider the text glyphs.
However, a CSMTextSettings tag can change the text to use the
"advanced rendering engine", which causes hit tests to only consider
the bounds. This is toggled by the "Anti-alias for readibility"
setting in the Flash IDE.

Wire up the CSMTextSettings tag and adjust hit test behavior based
on this flag.

Fixes #2987.
2021-02-01 17:17:41 -08:00
relrelb a2dcad683d swf: Refactor read_tag_list 2021-01-29 13:05:37 -08:00
Mads Marquart bb4240ad1f chore: Add a few comments about unsafe usage 2021-01-28 14:39:35 -08:00
Mads Marquart 8eddde76a2 swf: Add safe and simpler string parsing 2021-01-28 14:39:35 -08:00
relrelb 19662503ca swf: Convert ButtonActionCondition to bitflags 2021-01-23 11:59:24 -08:00
relrelb 7f4845d777 swf: Convert ButtonState to bitflags 2021-01-23 11:59:24 -08:00
relrelb b05c6540e1
chore: Migrate from enumset to bitflags 2021-01-21 16:35:46 -08:00
Mike Welsh 2254589e71 swf: Don't error on focal gradients in DefineShape tags (fix #2730) 2021-01-21 15:47:04 -08:00
Mike Welsh 66256dd3be swf: SwfStr no longer contains encoding
SwfStr is now an unsized slice analogous to `str` or `bstr`.
The desired encoding must be supplied when converting to String.
2021-01-20 15:02:31 -08:00
Mike Welsh 700c3c1767 chore: Appease clippy 2021-01-20 15:02:31 -08:00
Mike Welsh 303a2620a7 swf: Fix uncompressed length check 2021-01-20 15:02:31 -08:00
Mike Welsh c063264d1c swf: Use bitstream_io 2021-01-20 15:02:31 -08:00
Mike Welsh 61628a74fc swf: Rename and organize some util methods
* SwfRead -> SwfReadExt
 * SwfWrite -> SwfWriteExt
 * read_swf_header -> decompress_swf
 * read_swf -> parse_swf
2021-01-20 15:02:31 -08:00
Mike Welsh 1d9c11e145 swf: Add SwfStr type to handle encodings in SWF<6 2021-01-20 15:02:31 -08:00
Mike Welsh 19034b76e4 swf: Return slices in swf::Reader
Avoid copies by returning slices of the decompressed input.
2021-01-20 15:02:31 -08:00
Mike Welsh bf94f5dbaa swf: Split out bit i/o into SwfBitsReader/Writer types 2021-01-20 15:02:31 -08:00
Mike Welsh da1e2801a2 chore: Appease clippy 2021-01-18 21:23:50 -08:00
MrCheeze 5915f2a841 core: Return uncompressed length for getBytesLoaded/Total 2021-01-09 14:29:19 -08:00
dependabot-preview[bot] f80d74a3d7 build(deps): bump smallvec from 1.6.0 to 1.6.1
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.6.0...v1.6.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-08 12:09:49 -08:00
dependabot-preview[bot] dbb1bfb845 build(deps): bump byteorder from 1.3.4 to 1.4.2
Bumps [byteorder](https://github.com/BurntSushi/byteorder) from 1.3.4 to 1.4.2.
- [Release notes](https://github.com/BurntSushi/byteorder/releases)
- [Changelog](https://github.com/BurntSushi/byteorder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/byteorder/compare/1.3.4...1.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-08 12:09:34 -08:00
dependabot-preview[bot] 6a3b9f9f53 build(deps): bump smallvec from 1.5.1 to 1.6.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.5.1 to 1.6.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.5.1...v1.6.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-31 14:37:38 -08:00
Mike Welsh 7cf217a911 swf: Use lzma-rs for LZMA SWFs (fix #405)
Pure Rust decoder that functions on desktop and wasm.
Enable lzma feature by default.

TODO: Switch to lzma-rs streaming API when stable on crates.io.
Currently decodes entire stream at once.
2020-12-17 16:40:21 -08:00
Adrian Wielgosik 484bd2c11a
avm1: Revert #1470 to improve wasm performance 2020-12-17 12:47:22 -08:00
Mike Welsh cec0ca74e1 chore: Fix swf doctests working directory
Rust 12-09 nightly changed the working dir of doctests to be the
workspace root instead of the subcrate root. This broke the
doctests for swf. Now do some setup to ensure the same working
directory on both stable and nightly.

cc https://github.com/rust-lang/cargo/pull/8954
2020-12-10 12:25:02 -08:00
David Wendt 0069d51dad swf: `pushshort` should be read as a `u30` and then cast to an `i16` as it's parsed representation. 2020-12-09 14:00:06 -08:00
David Wendt 3225cd40e2 core: Avoid panic when display objects are manipulated in clearly invalid ways. 2020-12-09 14:00:06 -08:00
jmckiern 3cab11d18e avm1: Implement TextField.textColor (close #1863) 2020-12-07 15:09:36 -08:00
Mike Welsh 2757bc4dad chore: Appease clippy
Allow suspicious_operation_groupings for Matrix.
2020-12-07 10:14:31 -08:00
dependabot-preview[bot] f45fa80e29 build(deps): bump smallvec from 1.5.0 to 1.5.1
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.5.0...v1.5.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-04 17:54:47 -08:00
Mike Welsh 53212f192c chore: Appease clippy, squelch unnecessary_wraps lint 2020-11-24 18:59:42 -08:00
Mike Welsh eb0b16790c swf: Allow construct clip events in SWFv6 2020-11-22 19:34:29 -08:00
dependabot-preview[bot] 6bfa3144c3 build(deps): bump smallvec from 1.4.2 to 1.5.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.4.2 to 1.5.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.4.2...v1.5.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-18 16:30:15 -08:00
Mike Welsh 316bc4e920 chore: Appease clippy 2020-11-09 01:52:57 -08:00
Mike Welsh 0c38dafd0d avm1: Switch to SmallVec for ActionPush
While switching swf to return slices, I noticed ActionPush was
potentially allocating a huge vector by mistake.
Switch to SmallVec<[Value; 4]> to fix this and avoid the
allocation in general (this was fairly high up in the profiler).

TODO: Return an iterator instead of any sort of vec.
2020-11-03 13:47:12 -08:00
dependabot-preview[bot] 55d16c200a build(deps): bump approx from 0.3.2 to 0.4.0
Bumps [approx](https://github.com/brendanzab/approx) from 0.3.2 to 0.4.0.
- [Release notes](https://github.com/brendanzab/approx/releases)
- [Commits](https://github.com/brendanzab/approx/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-25 12:07:13 -07:00
relrelb 083e2a2ff5 core: Implement getBytes{Loaded,Total} (simpler approach) 2020-10-23 13:13:00 -07:00
relrelb 14a71b69cc core: Implement getBytes{Loaded,Total} 2020-10-23 13:13:00 -07:00
Mike Welsh a6b952e44e core: Switch from libflate to flate2 2020-10-12 13:47:35 -07:00
Mike Welsh 4467ccf7e3 tests: Add swf test for bitmap line style 2020-10-10 16:35:37 -07:00
Mike Welsh ed99a15dee swf: Fill styles are byte aligned
A bitmap fill style ends in a matrix, but the overall type should
still be byte aligned. This could cause certain shapes with bitmap
line styles to be incorrectly parsed. Fixes #1192.
2020-10-10 16:35:37 -07:00
Luca Weiss d5cb396331 *: fix spelling mistakes 2020-09-19 16:17:58 -07:00
Mike Welsh 5ea06b0ce6 swf: Use Option for more PlaceObject parameters
There is a difference between empty/default (change value to default)
and none (don't modify), so make this explicit for some PlaceObject
parameters where it wasn't.

Fixes #1104.
2020-09-03 19:09:48 -07:00
Mike Welsh d7a186b2cd avm1: Implement shape hit testing 2020-09-02 17:51:55 -07:00
David Wendt 345a244ed4 `read_i32` no longer panics if more than 28 bits are defined within the read-in integer constant.
The underlying problem is actually shift overflow - on the fifth byte in the sequence, it attempts to mask bits by shifting them off the left of the value, which doesn't work here, as we'll be shifting by -3. For those unaware, shifting by a negative does NOT shift in the opposite direction, it instead gives your C compiler permission to stuff demons up your nose.

I wouldn't be surprised if this is just outright UB in Flash Player.
2020-08-10 16:38:04 -07:00
David Wendt 95ca978034 f64 constants in ABC files are not stored in Flash mixed-endian. 2020-08-10 16:38:04 -07:00
dependabot-preview[bot] 04b146ffc4 build(deps): bump enumset from 1.0.0 to 1.0.1
Bumps [enumset](https://github.com/Lymia/enumset) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/Lymia/enumset/releases)
- [Changelog](https://github.com/Lymia/enumset/blob/master/RELEASES.md)
- [Commits](https://github.com/Lymia/enumset/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-09 13:15:38 -07:00
Mike Welsh 4680b01f03 swf: Allow StyleChangeRecord in DefineShape v1
The spec says that StyleChangeRecord is only supported in
DefineShape2+, but SWFs exist with StyleChangeRecord in
DefineShape1 tags, and these play correctly in the Flash Player.
(see #929 HAGIMURA_EXTREME.swf).
2020-07-24 18:46:18 -07:00
David Wendt ccacc540bf Remove dead code on all now-in-use structs and methods. 2020-07-18 16:12:24 -04:00
David Wendt a44e700e81 Sign extend negative `s24` values correctly. 2020-07-13 17:44:30 -04:00
David Wendt 9c5ea1d30c Implement `jump`, `iftrue`, `iffalse`, `ifstricteq`, and `ifstrictne`. 2020-07-13 17:44:30 -04:00
David Wendt 7f60fab1e5 Add the bare minimum necessary to get opcodes out of an ABC and into an interpreter loop.
Surprisingly enough, the "bare minimum" includes a stack, object model, and values already.
2020-07-13 17:42:45 -04:00
Mike Welsh 08569ae979 core: Limit tag parsing to slice of tag data 2020-07-03 18:52:26 -07:00
Nathan Adams e01f78df61 swf: Fixed parsing of try {...} blocks 2020-07-01 17:30:56 -07:00
Mike Welsh 12d9ba4583 chore: Fix swf clippy lint 2020-05-30 02:53:25 -07:00
Nathan Adams 4c1ce6d765 core: Print swf version on startup, and warn when we run into avm2 2020-05-30 02:48:54 -07:00
Nathan Adams 1f8abc92fd core: Keep track of cursor position in drawings 2020-05-21 18:38:10 +02:00
Nathan Adams 5098eb079d avm1: Implement most of flash.geom.Matrix (#303) 2020-05-20 14:54:41 +02:00
Nathan Adams eda862c719 swf: Merged core::Matrix into swf::Matrix 2020-05-20 14:54:41 +02:00
Mike Welsh 081f6a556a swf: Avoid undefined behavior in write_fbits 2020-05-13 02:41:50 -07:00
Mike Welsh deef891c30 swf: Don't error if both libflate and flate2 features are enabled
Fixes errors I was getting from rust-analyzer checking with all
features enabled.
2020-05-13 00:16:50 -07:00
Nathan Adams 5767fb1772 swf: Added utility method for `Color::from_rgb(rgb, alpha)` 2020-05-10 22:03:56 -07:00
dependabot-preview[bot] 08a786a213 build(deps): bump libflate from 0.1.27 to 1.0.0
Bumps [libflate](https://github.com/sile/libflate) from 0.1.27 to 1.0.0.
- [Release notes](https://github.com/sile/libflate/releases)
- [Commits](https://github.com/sile/libflate/compare/0.1.27...1.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-05 08:12:26 +00:00
Mike Welsh b7d464f367 chore: Bump enumset to 1.0.0 2020-04-13 04:14:29 -07:00
dependabot-preview[bot] 3f28554285 build(deps): bump enumset from 0.4.4 to 0.4.5
Bumps [enumset](https://github.com/Lymia/enumset) from 0.4.4 to 0.4.5.
- [Release notes](https://github.com/Lymia/enumset/releases)
- [Changelog](https://github.com/Lymia/enumset/blob/master/RELEASES.md)
- [Commits](https://github.com/Lymia/enumset/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 18:14:25 +00:00
David Wendt 5ed5876e9a Merge SWF data and version into a single structure. Refactor everything that interacts with it to use `SwfSlice`s. 2020-02-21 23:57:53 -05:00
dependabot-preview[bot] 6681e843a9 build(deps): bump byteorder from 1.3.2 to 1.3.4
Bumps [byteorder](https://github.com/BurntSushi/byteorder) from 1.3.2 to 1.3.4.
- [Release notes](https://github.com/BurntSushi/byteorder/releases)
- [Changelog](https://github.com/BurntSushi/byteorder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/byteorder/compare/1.3.2...1.3.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-12 00:57:11 +00:00
David Wendt 63b7d172f4 `TextRecord.height` is also in `Twips`.
Notably, the `Text` rendering code does not appear to actually work in pixel scale.
2020-02-03 14:46:34 -05:00
David Wendt fde7715fb8 `EditText.height` is in `Twips` 2020-02-03 14:46:33 -05:00
David Wendt 93b06483c8 Fix misparsing of `ActionGetURL2`.
Adobe's documentation has the flags in opposite order to what they should be. This fixes that.
2020-01-16 17:09:56 -08:00
Mike Welsh bc872cbf9c swf: Clean up DefineButtonCxform tag 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 4cb2cefc5b swf: Switch depth to u16 2019-12-17 02:48:55 -08:00
Mike Welsh 24d8fa6298 swf: Add public method for read_export_assets 2019-12-16 19:32:34 -08:00
Mike Welsh da13b36e47 swf: Use EnumSet for ClipEventFlag 2019-12-15 19:00:16 -08:00
Mike Welsh e5472aab91 avm2: Improve error when reading invalid opcode 2019-12-10 11:26:58 -08:00
Mike Welsh 0f9895cfa5 avm2: Don't parse the opcode stream when parsing ABC 2019-12-10 11:26:58 -08:00
dependabot-preview[bot] c3c82ffbe4 build(deps): bump num-derive from 0.2.5 to 0.3.0
Bumps [num-derive](https://github.com/rust-num/num-derive) from 0.2.5 to 0.3.0.
- [Release notes](https://github.com/rust-num/num-derive/releases)
- [Changelog](https://github.com/rust-num/num-derive/blob/master/RELEASES.md)
- [Commits](https://github.com/rust-num/num-derive/compare/num-derive-0.2.5...num-derive-0.3.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-22 17:13:32 +00: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
Mike Welsh 2b90c61a69 core: Fix error message when LZMA feature is disabled 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 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
Mike Welsh 3058b88011 swf: Add custom error type for SWF/AVM1 parse errors
Improves the error handling for the swf crate:

 * Custom swf::error::Error type added to handle various errors
   in SWF parsing.
 * Invalid parsing of tags/AVM1 ops results in a Error::ParseError
   that can include info about the underlying failure.
 * Implement Display for these errors. Output descriptive
   names for the tag/opcode when it fails to parse.
 * Handle out of bounds reads in avm1::Reader::read_slice.
   Previously this would panic, now it returns an io::Error.

Closes #85.
2019-10-10 00:55:09 -07:00
Mike Welsh 3fddb659fb swf: Fix incorrect parsing of clip actions in SWFv5
Clip action flags in SWFv5 are only 2 bytes big.
2019-10-08 02:13:53 -07:00
Mike Welsh 782174aa75 swf: Make read_define_edit_text public 2019-10-07 23:23:45 -07:00
Will Brindle 2ff0522509 chore: combine DefineText functions into 1 and paramterise 2019-10-05 06:49:03 +01:00
Will Brindle 8844e1b48d chore: follow naming conventions for functions 2019-10-04 22:18:37 +01:00
Will Brindle 1b6848d060 swf: implement DefineText2 2019-10-04 21:09:24 +01:00
Mike Welsh 6650a7a924 swf: Remove stale build badge from README 2019-10-03 02:31:11 -07:00
Mike Welsh 862120dac0 swf: Use consistent naming for test SWF filenames 2019-10-03 02:18:09 -07:00
Mike Welsh e0015c9d14 swf: cargo fmt 2019-10-03 00:46:38 -07:00
Mike Welsh 65866842a7 swf: Change respoitory URL in swf crate 2019-10-03 00:27:47 -07:00
Mike Welsh 336eace45e chore: Delete old dotfiles from swf-rs 2019-10-03 00:26:23 -07:00
Mike Welsh 0de44d61b3 Merge swf-rs into ruffle repo
git-subtree-dir: swf
git-subtree-mainline: 2740f3ccc1
git-subtree-split: 1b04015326
2019-10-02 17:25:30 -07:00