FlashpointProject / Shockwave-Projector-Redirector-for-Flashpoint

The Shockwave Projector Redirector (SPR) allows Shockwave Movies to be played via Flashpoint Redirector.
MIT License
26 stars 5 forks source link

Embeddable Shockwave Emulator #1

Open ChefFloyardee opened 4 years ago

ChefFloyardee commented 4 years ago

Hi all! Forgive me if this is the wrong place to post this, but I am trying to create an "Embeddable Shockwave Emulator".

I essentially want an embedded emulator that enables visitors to my GitHub website to play Shockwave Games that I have either set to pre-load or set to provide the DCR file download to.

I've seen this done with ROMS of various console games, so I hope that this can be done!

I do not know much about the inner workings of Shockwave games though, so would this even be feasible? Please let me know!

tomysshadow commented 4 years ago

This really is not feasible (without way more work than it's worth,) but it also isn't greatly necessary.

The existence of emulators such as Ruffle for Flash has created a slight increase in demand for something similar for Shockwave. However, Shockwave is a great deal more sophisticated than Flash is, so it would require more work than Ruffle to create such an emulator. There are also less people who are interested in having such an emulator, or indeed even know that Shockwave and Flash are not the same thing.

Flash was originally intended primarily for animation and graphics purposes, and basic interactivity was only really added as an afterthought. It eventually grew to be more robust with the features added by AS3, but in general, the Flash file format is fairly simple to understand. There is even official documentation for it. In contrast, the Director API (Shockwave's underlying technology) was intended to be used to create complex and media rich applications, and is more advanced with many features. It's format has no official documentation.

The biggest obstacle to having an open source Director implementation is Xtras, and their underlying technology, MOA (short for Macromedia Open Architecture.) Shockwave could be extended to add more features by using Xtras which are compiled natively for the system. There are first party Xtras by Macromedia/Adobe that are core, essential features of Shockwave that it depends upon to work, and it was also possible to create third party Xtras which allowed for any developer to add their own capabilities to Shockwave using the XDK (Xtra Development Kit.) This poses a problem because even if one were to rewrite every first and third party Xtra in existence to be open source, I could always just decide to create a new one. Because it's extensible, an open source implementation would never be complete.

The existence of Xtras effectively locks Shockwave to Windows and Mac only. Shockwave is dependent on the ability to run native code for these platforms, because anyone could create Xtras to do anything they wanted, and they were very commonly used. There are at least 700 Xtras in existence. One of the most common for example is Buddy API, which is a sort of "swiss army knife" to polyfill common features Shockwave didn't support out of the box. You can still buy it, in fact.

http://www.mods.com.au/budapi/

In order to create an open source Director implementation, it would need to be capable of loading Xtras, and this would involve recreating MOA. MOA is a series of interfaces Director provides so Xtras can communicate with it. It's very similar to how COM interfaces work - in fact almost identical. Director exports over 120 MOA interfaces (I've counted them in IDA,) most of them documented by the XDK, some of them undocumented, some with few methods, some with many.

It's worth mentioning that Director 4 did not have any Xtras, and at this point in time everything Director required was in the single, core package. This is why ScummVM has been able to fairly accurately recreate a Director 4 player, although it's still not a trivial task as it involves supporting Director's Lingo programming language, which is itself fairly intricate. However, Director 5 and later versions became increasingly dependent on Xtras over time. Most Shockwave content uses Director 8 or later.

Unfortunately, because ScummVM is cross-platform, the only way they could support Xtras is by "faking it," hardwiring their GUIDs to code in the main codebase, so it will never be entirely feature complete. I consider this an unsatisfactory solution, because in later Director versions, I consider the ability to load real Xtras are a core, essential feature - so much of Director's functionality had been moved into Xtras, they're practically required to start the program. It also ignores the third party Xtra ecosystem - many classic games used Xtras like the Beatnik Xtra or the 3D Groove Xtra. ScummVM would have to rewrite potentially hundreds of Xtras.

It's also worth mentioning that ScummVM is only focused on 2D games. Shockwave is capable of 3D rendering, and this has raised questions of whether or not this is within ScummVM's scope.

The good news is that having Shockwave emulation is not really greatly required, because... Director still works on Windows 10, pretty well in fact. It's possible to use Projectors to play Shockwave Movies without the need to install the Shockwave Player itself, instead providing them as standalone executables. This circumvents the issue of NPAPI being removed from browsers so the plugin cannot be used anymore. Some developers have taken this approach with their old games. Xform and Robotduck for example provide Projectors of their Shockwave games on itch.io, and it's easy to download and play them like any other desktop game.

https://xformgames.itch.io https://robotduck.itch.io

Furthermore, the Lingo programming language is pretty flexible, enough so to even mod existing games without editing the original binaries by creating "wrapper" movies. This is what was done for the game RobotRage: Rearmed, a multiplayer online Shockwave game that was originally peer-to-peer but has been retrofitted to go through a central server so it doesn't require portforwarding and router setup changes.

https://robotrage.pro

There are caveats, for example, if a game tries to download a file that is no longer online at the original website, then it will of course no longer load correctly, but this is the problem BlueMaxima's Flashpoint sets out to resolve.

https://bluemaxima.org/flashpoint/

I would argue that rather than going the route of emulation, it is better to go the route of modifying and patching the existing Director code as necessary and using Flashpoint or Projectors to accomplish offline playback.

tl;dr; creating an open source Director implementation would require the ability to load Xtras, which are compiled natively and would require recreating MOA to load them, which requires having a nearly feature perfect recreation of Director itself already, and none of it is really necessary because it still works on Windows 10 without emulation if you're just willing to provide the game as a download instead. Also, in comparison to Ruffle, there's both less demand for it, and would require more work.

ChefFloyardee commented 4 years ago

So it sounds like providing the game as a download is the route to go!

One question though; I still want the game to be embedded in a browser webpage. Would there be a way per your knowledge to have a projector such as what Blue Maxima uses appear on my webpage as a loader with the option to download various games,and play them from there?

So essentially I would be providing downloads for both the projector and the game, but the projector would appear to remain part of my webpage like an embedded ROM emulator would.

einstein95 commented 3 years ago

It's also worth mentioning that ScummVM is only focused on 2D games. Shockwave is capable of 3D rendering, and this has raised questions of whether or not this is within ScummVM's scope.

As a sidenote, ScummVM and ResidualVM got merged, so ScummVM now officially supports a few 3D games

ChefFloyardee commented 3 years ago

It's also worth mentioning that ScummVM is only focused on 2D games. Shockwave is capable of 3D rendering, and this has raised questions of whether or not this is within ScummVM's scope.

As a sidenote, ScummVM and ResidualVM got merged, so ScummVM now officially supports a few 3D games

Is ScummVM embeddable on a website for Shcokwave Games?

ahribellah commented 2 years ago

This is a really late response (I stumbled upon this completely by accident), but you might be able to virtualize the projector in-browser using something like v86. The only way to know for sure if it'll work would be to try it, though.

ChefFloyardee commented 2 years ago

This is a really late response (I stumbled upon this completely by accident), but you might be able to virtualize the projector in-browser using something like v86. The only way to know for sure if it'll work would be to try it, though.

Could you maybe help me do this? The only game I want to do this for is Captain Planet and the Robots of Zarm :D

thenickman100 commented 3 days ago

I came across a new project in development to run shockwave in web browsers. I don't think it has any compatibility yet, but it could be promising in the near future. https://github.com/igorlira/dirplayer-rs

Has anyone gotten any shockwave games to run with v86 yet?

TheWitheredStriker commented 3 days ago

I came across a new project in development to run shockwave in web browsers. I don't think it has any compatibility yet, but it could be promising in the near future. https://github.com/igorlira/dirplayer-rs

Has anyone gotten any shockwave games to run with v86 yet?

This is awesome! Thank you so much for spreading word!