PRIVATE: fixes + more functiions
This commit is contained in:
parent
2ce4159f16
commit
cae1b214a8
4 changed files with 70 additions and 14 deletions
|
@ -70,7 +70,7 @@ int constpush() /* push constant onto stack */
|
|||
Symbol *s = (Symbol *)*pc++;
|
||||
d.val = s->u.val;
|
||||
|
||||
debug("pushing const %d with name %s\n", d.val, s->name->c_str());
|
||||
debug("pushing const %d with name %s", d.val, s->name->c_str());
|
||||
push(d);
|
||||
return 0;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ int funcpush() //(char *name, int nargs)
|
|||
}
|
||||
|
||||
execFunction(s.str, args);
|
||||
pc++;
|
||||
//pc++;
|
||||
//d.sym = (Symbol *)(*pc++);
|
||||
//printf("var pushing %s", d.sym->name);
|
||||
//push(d);
|
||||
|
|
|
@ -6,19 +6,49 @@
|
|||
|
||||
namespace Private {
|
||||
|
||||
void execFunction(char *name, ArgArray args) {
|
||||
if (strcmp(name, "ChgMode") == 0) {
|
||||
void ChgMode(ArgArray args) {
|
||||
debug("ChgMode(%d, %s)", args[0].val, args[1].str);
|
||||
_mode = args[0].val;
|
||||
Common::String *s = new Common::String(args[1].str);
|
||||
_nextSetting = s;
|
||||
}
|
||||
else if (strcmp(name, "SetFlag") == 0) {
|
||||
|
||||
void Goto(ArgArray args) { // should be goto, but this is a reserved word
|
||||
debug("goto(%s)", args[0].str);
|
||||
Common::String *s = new Common::String(args[0].str);
|
||||
_nextSetting = s;
|
||||
}
|
||||
|
||||
void SetFlag(ArgArray args) {
|
||||
debug("SetFlag(%s, %d)", args[0].sym->name->c_str(), args[1].val);
|
||||
args[0].sym->u.val = args[1].val;
|
||||
//_mode = args[0].val;
|
||||
//Common::String *s = new Common::String(args[1].str);
|
||||
//_nextSetting = s;
|
||||
}
|
||||
|
||||
void Sound(ArgArray args) {
|
||||
debug("Sound(%s)", args[0].str);
|
||||
if (strcmp("\"\"", args[0].str) != 0) {
|
||||
Common::String *s = new Common::String(args[0].str);
|
||||
_private->playSound(*s);
|
||||
//assert(0);
|
||||
} else {
|
||||
_private->stopSound();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void execFunction(char *name, ArgArray args) {
|
||||
if (strcmp(name, "ChgMode") == 0) {
|
||||
ChgMode(args);
|
||||
}
|
||||
else if (strcmp(name, "goto") == 0) {
|
||||
Goto(args);
|
||||
}
|
||||
|
||||
else if (strcmp(name, "SetFlag") == 0) {
|
||||
SetFlag(args);
|
||||
}
|
||||
else if (strcmp(name, "Sound") == 0) {
|
||||
Sound(args);
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
@ -24,9 +24,18 @@ namespace Private {
|
|||
|
||||
Common::String *_nextSetting = NULL;
|
||||
int _mode = -1;
|
||||
PrivateEngine *_private = NULL;
|
||||
|
||||
extern int parse(char*);
|
||||
|
||||
Common::String &lowercase(Common::String &val) {
|
||||
Common::String::iterator i;
|
||||
for (i = val.begin(); i != val.end(); i++)
|
||||
*i = tolower(*i);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
PrivateEngine::PrivateEngine(OSystem *syst)
|
||||
: Engine(syst) {
|
||||
// Put your engine in a sane state, but do nothing big yet;
|
||||
|
@ -48,6 +57,7 @@ PrivateEngine::PrivateEngine(OSystem *syst)
|
|||
_rnd = new Common::RandomSource("private");
|
||||
|
||||
debug("PrivateEngine::PrivateEngine");
|
||||
_private = this;
|
||||
}
|
||||
|
||||
PrivateEngine::~PrivateEngine() {
|
||||
|
@ -170,9 +180,23 @@ void PrivateEngine::syncGameStream(Common::Serializer &s) {
|
|||
|
||||
void PrivateEngine::playSound(const Common::String &name) {
|
||||
debugC(1, kPrivateDebugExample, "%s : %s", __FUNCTION__, name.c_str());
|
||||
|
||||
Common::String path(name);
|
||||
Common::String s1("\\");
|
||||
Common::String s2("/");
|
||||
|
||||
Common::replace(path, s1, s2);
|
||||
s1 = Common::String("\"");
|
||||
s2 = Common::String("");
|
||||
|
||||
Common::replace(path, s1, s2);
|
||||
Common::replace(path, s1, s2);
|
||||
|
||||
lowercase(path);
|
||||
|
||||
Common::File *file = new Common::File();
|
||||
if (!file->open(name))
|
||||
error("unable to find sound file %s", name.c_str());
|
||||
if (!file->open(path))
|
||||
error("unable to find sound file %s", path.c_str());
|
||||
|
||||
Audio::AudioStream *stream;
|
||||
stream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
|
||||
|
|
|
@ -58,6 +58,8 @@ public:
|
|||
|
||||
};
|
||||
|
||||
extern PrivateEngine *_private;
|
||||
|
||||
// Example console class
|
||||
class Console : public GUI::Debugger {
|
||||
public:
|
||||
|
@ -67,6 +69,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
} // End of namespace Quux
|
||||
} // End of namespace Private
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue