Commit Graph

67 Commits

Author SHA1 Message Date
relrelb e3f1fe2004 chore: Prefer spelling "Graphic" 2021-06-24 14:36:45 +03:00
Mike Welsh 554aa7fd63 core: Add backend::render::BitmapSource trait
This interface handles returning a bitmap given an ID and is used
by the render backend to get the bitmap used for a bitmap fill.
This will allow for bitmap fills in the drawing API, as these will
manage their own list of bitmaps.
This also  removes the MovieLibrary dependency from render backends
and will allow for better decoupling in the future.
2021-06-13 20:03:53 -07:00
Mike Welsh 5462b8a522 core: Allow MorphShapes and Texts to be replaced via PlaceObject
PR #4540 allowed shapes to replace their inner art handles via
replace PlaceObject tags. This can also happen for morph shapes and
static texts.

Add MorphShape::replace_with and Text::repalce_with. This fixes the
incorrect art in main menu buttons of Super Mario 63.
2021-06-09 23:37:38 -07:00
Mike Welsh b1318ecb01 core: PlaceObjectAction::Replace swaps out graphic handles
A `PlaceObjectAction::Replace` signals that a shape should
be swapped with a different shape. Previously we instantiated a
completely new `Graphic`, but this is incorrect; instead the
underlying shape handle should be swapped out, but the outer object
remains. This is visible in AVM2 where you can access `Shape` as
a normal display object.
2021-06-08 19:47:16 -07:00
Mike Welsh bec6eb9dd3 core: Use SwfMovie::avm_type instead of MovieLibrary::avm_type 2021-05-23 23:02:38 -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
Mike Welsh 9b58dac841 avm2: Fix up DisplayObject root and stage properties
Move `MovieClip::is_swf` flag to `DisplayObject::is_root`, and use
this flag to handle the behavior of `DisplayObject.root` crawling
upwards until it hits a top-most loaded SWF/Bitmap.

Simplify `root` and `stage` so that they don't have to consider
buttons. Instead, do some trickery to ensure the button's states
see the proper values of `parent`, `root`, and `stage` during
construction.
2021-05-16 17:53:07 -07:00
David Wendt 6a9249e52f core: Store the root of each loaded movie and use it as a last-ditch way to get the root 2021-05-16 17:53:07 -07:00
David Wendt 25473ac1dc core: Allow AVM2 movies to define `Avm2Button` characters in their libraries 2021-05-16 17:53:07 -07:00
David Wendt c0296d9963 core: Rename `Button` to `Avm1Button` 2021-05-16 17:53:07 -07:00
Moulins 78627acc92 chore: Move core::property_map to core::avm1::property_map 2021-05-03 13:47:14 -07:00
David Wendt f33976f4c0 avm2: Store symbol / class relationships using the class constructor, not the prototype. 2021-04-23 00:26:10 -07:00
David Wendt 9b19cc1570 Store the movie associated with a given symbol being constructed. 2021-04-23 00:26:10 -07:00
David Wendt 282508a281 core: Make the AVM2 constructor registry global 2021-04-23 00:26:10 -07:00
David Wendt 555d97006a core: Add an AVM2 constructor registry 2021-04-23 00:26:10 -07:00
David Wendt 78c519cce0 avm2: Don't except when creating a dynamic TextField. 2021-03-19 12:39:57 -07:00
David Wendt 6dc96f5d58 core: Allow instantiation of videos 2021-02-16 19:03:48 -08:00
Adrian Wielgosik 1454e0d126
core: Don't copy Glyphs around; make Font methods take &self 2021-02-04 11:54:17 -08:00
relrelb abfa08c964 core: Allow exports to be overridden
Per SWF19 p.54, the latter export name is used.
2021-01-15 11:48:29 -08:00
Mike Welsh 3c31336c93 chore: Rename some getters 2021-01-13 15:38:38 -08:00
Moulins f394953331 core: Reimplement `Object.registerClass`.
Maintain an external mapping from symbol names to registered
constructors to properly handle `registerClass` being called on
not-yet-available symbols.

SWFs v6 and v7+ each have a separate global mapping, with
different case sensitivities.

Also returns the correct boolean value to the AVM.

Fixes #2343 and #1864.
2021-01-13 15:38:38 -08:00
Mike Welsh 9b6295f33a render: Pass library to RenderBackend::register_shape (fix #2037)
Pass the movie library to `register_shape` methods so that bitmap
charcter IDs can be resolved immediately on the proper SWF.

This fixes #2037, which cause incorrect bitmaps to be used when
multiple movies were loaded.
2020-12-31 13:10:21 -08:00
Mike Welsh 326a5b6212 core: Move device font to Library (fix #1995) 2020-12-17 23:20:22 -08:00
Mike Welsh 41f77fade1 avm1: Export names are case insensitive
Fixes capital letters not appearing in #1346
2020-10-21 17:09:31 -07:00
David Wendt d27360b282 avm2: Enable lazy initialization for ABCs that request it. 2020-10-17 03:32:09 -07:00
David Wendt 0d1676afda avm2: Create a separate domain for each loaded movie and pull symbols out of each. 2020-10-17 03:32:09 -07:00
Mike Welsh 2c9cf6802d core: Squelch false AS3 error before initial SWF loads 2020-10-10 19:28:01 -07:00
David Wendt 1a10f1e004 avm2: Lock old movies (SWFv8 and earlier) to always use AVM1 2020-10-06 06:03:22 -07:00
David Wendt 7c719bfb0c Only the first tag in a SWF file should be trusted to deliver file attributes. 2020-10-06 06:03:22 -07:00
David Wendt ddccede9d3 avm2: Make VM type non-optional.
This has the side effect of forcing the AVM check to happen at the time of library construction, which is already very early on in movie loading.
2020-10-06 06:03:22 -07:00
David Wendt e2f21d0a7d avm2: Retire old references to the "VM tendency" nomenclature 2020-10-06 06:03:22 -07:00
David Wendt a70e1be466 Add code to instantiate AVM2 movie clips correctly.
This also includes several bits to build an effective VM barrier.
2020-10-06 06:03:22 -07:00
David Wendt 247e79e61a core: Track the VM each movie has pledged to execute on.
This uses a "VM tendency" system wherein the presence of `DoAction` or `DoInitAction` tags defaults the movie to AVM1, while the presence of `DoABC` defaults to AVM2. The presence of a `FileAttributes` tag allows setting the VM tendency in the same manner using it's AS3 bit.

Particularly malformed SWFs may cause execution issues if Flash Player uses a dramatically different system from this.
2020-10-06 06:03:22 -07:00
David Wendt 361ea1f774 Index fonts by font name, boldness, and italicization.
This involves a new struct called a `FontDescriptor` which is generated whenever a font is registered and used to index the font in the library. When a font is requested, it goes through the descriptor system to get found.
2020-06-20 19:26:43 -04:00
David Wendt 4a2fac28d1 Add iterator for text spans 2020-06-20 19:16:17 -04:00
Nathan Adams d850443c84 avm1: Refactor to expose `avm, context` in `post_instantiate` 2020-02-29 23:05:15 +01:00
David Wendt 5ce499d11e Add separate libraries for each loaded movie. 2020-02-21 23:57:56 -05:00
Nathan Adams f6f358b4de avm1: Expose TextFields and allow setting their .text 2019-12-19 10:19:43 -08:00
Mike Welsh dae3e27fb3 avm1: Rename Library::instantiate_by_id 2019-12-17 03:27:05 -08:00
Mike Welsh 009da39f12 avm1: Implement MovieClip.attachMovie 2019-12-17 03:00:56 -08:00
Mike Welsh 0f3bad8f1b core: Wrap Font in a Gc 2019-12-17 02:48:55 -08:00
Mike Welsh 289e0b8aff core: Handle ExportAssets SWF tag 2019-12-16 19:32:34 -08:00
Mike Welsh 30ecbd0ecc core: Use enum_trait_object for DisplayObject 2019-12-10 01:36:01 -08:00
Mike Welsh 23ca66a7e3 avm1: Use enum_trait_object for avm1::Object 2019-12-10 01:36:01 -08:00
David Wendt d25bdbacf8 Separate `Object` into an interface trait and a standard implementation. Host object implementations may bypass `ScriptObject` and directly interface with the AVM using this trait.
Note that host objects that do so will *not* have access to their standard representation from within member functions - you will need to extend the interface to accomodate for them. This is due to long-standing limitations with type IDs and downcasting with types that bear lifetimes - it's entirely an unsafe operation and exposing such a facility to safe Rust is unsound. However, this will at least let us separate out several things from ScriptObject that don't need to be there for the time being.
2019-11-26 14:51:05 -05:00
David Wendt 2f965d1c64 First stab at moving system builtins to explicit prototypes 2019-11-26 14:51:03 -05:00
Mike Welsh e3d0d9031d core: Handle empty JPEGTables tags (fix #116) 2019-11-11 17:08:08 -05:00
Mike Welsh 09fa755405 core: Make Library::device_font optional 2019-10-26 02:20:42 -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