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