New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACTIONSCRIPT: Initial ActionScript byte code interpreter #294

Closed
wants to merge 7 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@Nostritius
Contributor

Nostritius commented Jun 11, 2018

This is an initial attempt for an actionscript interpreter, usable for the dragonage and dragonage2 scaleform ui. It is not feature complete, to interpret all actionscript used in both dragon age games, mainly because scaleform utilizes a subset of the flash Api which needs to be implemented as additional PRs. This should be considered a Proof of Concept demo.

@Nostritius Nostritius force-pushed the Nostritius:actionscript_initial branch from 844f6bb to f565d3d Jun 11, 2018

@DrMcCoy

Neat!

There's some issues I'd like you to address first, though. See below. Also, AppVeyor fails for this PR. I think you forgot to include somewhere.

} // End of namespace ActionScript
} // End of namespace Aurora

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 11, 2018

Member

Missing end-of-line at the end of the file

size_t startPos = _script->pos();
switch (opcode) {
case kActionStop: actionStop(avm);break;

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 11, 2018

Member

Please use spaces for alignment. As you can see, when you mix spaces and tabs for alignment, it suddenly doesn't align.

(Of course, the indentation at the start of the line should still be tabs)

void ASBuffer::execute(AVM &avm) {
byte opcode;
if (_printAssembly)
info("-----");

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 11, 2018

Member

That should rather be a debug channel.

See, for example, how src/aurora/nwscript/ncsfile.cpp handles it with debugC(). You should add a relevant debug channel into the Common::DebugManager.

(Possible, the "kDebugScripts" channel should be renamed to say that it's about NWScript. Lua (and now ActionScript) should be their own debug channels)

#include "src/aurora/actionscript/variable.h"
#include "src/aurora/actionscript/object.h"
#include "variable.h"
#include "function.h"

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 11, 2018

Member

These two need a full path

#include <vector>
#include "src/aurora/actionscript/variable.h"
#include "asbuffer.h"

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 11, 2018

Member

Full paths, please

* @param value
* The parameters of the fscommand
*/
void fscommand(const Common::UString &name, const Common::UString &value);

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 11, 2018

Member

Should be fsCommand, then, I guess?

This comment has been minimized.

@Nostritius

Nostritius Jun 11, 2018

Contributor

yes and no, since the fscommand is written this way in the actionscript code, i wanted to make an exception here, to match it with the actionscript specification. But if you want i will change this.

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 11, 2018

Member

Yes, please change it, thanks

#include <boost/none_t.hpp>
#include <src/common/bitstream.h>
#include <src/common/memreadstream.h>

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 11, 2018

Member

Please include our own includes with #include "", not #include <>

@Nostritius Nostritius force-pushed the Nostritius:actionscript_initial branch from f565d3d to 65c5eda Jun 11, 2018

@Nostritius Nostritius force-pushed the Nostritius:actionscript_initial branch from 65c5eda to 31dc0ba Jun 11, 2018

@Nostritius

This comment has been minimized.

Contributor

Nostritius commented Jun 11, 2018

The issues should now be fixed and appveyor works again.

class ASBuffer {
public:
ASBuffer(Common::SeekableReadStream *as, bool printAssembly = false);

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 11, 2018

Member

The parameter printAssembly can go now

void ASBuffer::execute(AVM &avm) {
byte opcode;
debugC(kDebugEngineActionScript, 2, "--- Start Actionscript ---");

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 11, 2018

Member

Start is debug level 2, end is debug level 1? Is that correct?

kDebugEngineLogic , ///< "ELogic", engine game logic.
kDebugEngineScripts , ///< "EScripts", engine nwscripts
kDebugEngineActionScript, ///< "EActionScript", engine actionscript

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 11, 2018

Member

kDebugEngineActionScript is the wrong debug channel for the action script there.

If you look into NWScript, it uses kDebugScripts for the general script disassembly, things that are the same for every engine. kDebugEngineScripts is for things that the engine modifies or does, like engine functions.

I.e. you should rather use kDebugActionScript for most (all?) of the debug stuff in the ActionScript interpreter there.

@Nostritius Nostritius force-pushed the Nostritius:actionscript_initial branch from 31dc0ba to ad3511b Jun 11, 2018

@Nostritius

This comment has been minimized.

Contributor

Nostritius commented Jun 11, 2018

The issues should now be fixed

namespace ActionScript {
const static byte kActionNextFrame = 0x04;

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 12, 2018

Member

These should probably rather be an enum.

size_t startPos = _script->pos();
switch (opcode) {
case kActionStop: actionStop(avm);break;

This comment has been minimized.

@DrMcCoy

DrMcCoy Jun 12, 2018

Member

Could you add a space before the "break;"? And also an extra one after the ":", so that "kActionDefineFunction2:" isn't squished against the actionDefineFunction2() without any space.

@Nostritius Nostritius force-pushed the Nostritius:actionscript_initial branch from ad3511b to d0aacf6 Jun 13, 2018

@Nostritius

This comment has been minimized.

Contributor

Nostritius commented Jun 13, 2018

The issues should now be fixed

@DrMcCoy

This comment has been minimized.

Member

DrMcCoy commented Jun 13, 2018

Merged as 3efa87d...bb83638, thanks! :)

@DrMcCoy DrMcCoy closed this Jun 13, 2018

@Nostritius Nostritius deleted the Nostritius:actionscript_initial branch Jun 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment