Commit Graph

80 Commits

Author SHA1 Message Date
relrelb 65ecb4fe8f avm2: Remove `From<Box<dyn std::error::Error>> for Error<'gc>` 2022-09-26 19:51:38 +03:00
= ddaee950f8 avm1: Removed all public access into Avm1 modules, export only what's needed 2022-09-04 12:27:29 -07:00
relrelb 3da3567365 core: Avoid some allocations on JPEG tags
Read a slice instead of allocating a new `Vec`.
2022-09-02 10:42:09 -07:00
relrelb 72d8c152b9 core: Make `Player::load_device_font` infallible
It is always called with the same known data, which should parse
successfully.
2022-08-26 12:24:15 -07:00
relrelb 4d8e4111e3 core: Remove `AvmType`
Simply use `is_action_script_3()` instead.
2022-08-16 13:04:02 +03:00
Nathan Adams 824b4aa8d1 render: Moved render backend from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams bc0c7cbccb render: Made new render crate, moved Bitmap stuff to it 2022-08-14 18:38:14 -07:00
relrelb b6c7cc1ca3 core: Cleanup `Avm1ConstructorRegistry`
Instead of storing shared pointers to `Avm1ConstructorRegistry` in
`MovieLibrary`, access the `PropertyMap` directly, without an extra
abstraction.

Also, move the constructor registries to `Avm1`, for better
encapsulation.
2022-02-10 07:58:30 +02:00
Moulins 79d47a9863 avm1: Requires a WStr<'_> to access PropertyMap 2021-11-27 11:20:47 -07:00
Moulins 9aa601d43b core: Store AvmString<'gc>s in avm1::PropertyMap 2021-10-06 19:47:35 -06:00
Adrian Wielgosik 87625fa302 avm2: Change core types from Object to ClassObject where possible 2021-09-27 11:03:48 +02:00
David Wendt 1e0d259075 avm2: Allow nulling `Bitmap.bitmapData`.
One of the two tests in this PR relies upon the backend storing bitmap data, but the test rendering backend does not yet do this.
2021-09-11 12:11:35 -07:00
David Wendt 8af0481a23 avm2: Retire the use of "constructor" outside of literal reference to class initializer or instance initializer code.
Instead, the following terms are used:

 * Static classes, to refer to `Class<'gc>`. Shortened to "class" in contexts where this is not ambiguous.
 * Class objects, to refer to objects that represent a particular class. Also shortened to "class" in non-ambiguous contexts.

Downstream of this, the `base_constr` (referring to the class that a currently called trait has been pulled from) is now called `subclass_object` and several `TObject` methods have also been renamed.
2021-07-20 22:12:23 -04:00
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