scummvm/engines/private/funcs.cpp

170 lines
3.9 KiB
C++
Raw Normal View History

2021-01-02 00:58:58 -03:00
#include "common/str.h"
#include "common/debug.h"
#include "common/system.h"
2021-01-02 00:58:58 -03:00
#include "grammar.h"
2021-01-05 21:03:34 -03:00
#include "grammar.tab.h"
2021-01-02 00:58:58 -03:00
#include "private.h"
namespace Private {
2021-01-02 10:22:07 -03:00
void ChgMode(ArgArray args) {
2021-01-05 21:03:34 -03:00
// assert types
debug("ChgMode(%d, %s)", args[0].u.val, args[1].u.str);
_mode = args[0].u.val;
Common::String *s = new Common::String(args[1].u.str);
2021-01-02 10:22:07 -03:00
_nextSetting = s;
}
void Goto(ArgArray args) { // should be goto, but this is a reserved word
2021-01-05 21:03:34 -03:00
// assert types
debug("goto(%s)", args[0].u.str);
Common::String *s = new Common::String(args[0].u.str);
2021-01-02 10:22:07 -03:00
_nextSetting = s;
}
void Quit(ArgArray args) {
debug("quit()");
_private->quitGame();
}
2021-01-02 10:22:07 -03:00
void SetFlag(ArgArray args) {
2021-01-05 21:03:34 -03:00
// assert types
debug("SetFlag(%s, %d)", args[0].u.sym->name->c_str(), args[1].u.val);
args[0].u.sym->u.val = args[1].u.val;
2021-01-02 10:22:07 -03:00
}
void Exit(ArgArray args) {
// assert types
assert(args[2].type == RECT || args[2].type == NAME);
debug("Exit(%s, %s, %s)", args[0].u.str, args[1].u.sym->name->c_str(), "RECT");
ExitInfo *e = (ExitInfo*) malloc(sizeof(ExitInfo));
e->nextSetting = new Common::String(args[0].u.str);
e->cursor = args[1].u.sym->name;
e->rect = args[2].u.rect;
_exits.push_front(*e);
}
2021-01-04 08:14:40 -03:00
void SetModifiedFlag(ArgArray args) {
2021-01-05 21:03:34 -03:00
// assert types
debug("SetModifiedFlag(%d)", args[0].u.val);
_modified = (bool) args[0].u.val;
2021-01-04 08:14:40 -03:00
}
2021-01-02 10:22:07 -03:00
void Sound(ArgArray args) {
2021-01-05 21:03:34 -03:00
// assert types
debug("Sound(%s)", args[0].u.str);
if (strcmp("\"\"", args[0].u.str) != 0) {
Common::String *s = new Common::String(args[0].u.str);
2021-01-02 10:22:07 -03:00
_private->playSound(*s);
//assert(0);
} else {
_private->stopSound();
}
}
2021-01-04 08:14:40 -03:00
void Transition(ArgArray args) {
2021-01-05 21:03:34 -03:00
// assert types
debug("Transition(%s, %s)", args[0].u.str, args[1].u.str);
_nextMovie = new Common::String(args[0].u.str);
_nextSetting = new Common::String(args[1].u.str);
}
void CRect(ArgArray args) {
// assert types
int x1, y1, x2, y2;
debug("CRect(%d, %d, %d, %d)", args[0].u.val, args[1].u.val, args[0].u.val, args[1].u.val);
//assert(0);
x1 = args[0].u.val;
y1 = args[1].u.val;
x2 = args[2].u.val;
y2 = args[3].u.val;
Datum *d = new Datum();
Common::Rect *rect = new Common::Rect(x1, y1, x2, y2);
d->type = RECT;
2021-01-05 21:03:34 -03:00
d->u.rect = rect;
push(*d);
2021-01-04 08:14:40 -03:00
}
void Bitmap(ArgArray args) {
assert(args.size() == 1 || args.size() == 3);
int x = 0;
int y = 0;
2021-01-05 21:03:34 -03:00
char *f = args[0].u.str;
if (args.size() == 3) {
2021-01-05 21:03:34 -03:00
x = args[1].u.val;
y = args[2].u.val;
}
debug("Bitmap(%s, %d, %d)", f, x, y);
2021-01-05 21:03:34 -03:00
Common::String *s = new Common::String(args[0].u.str);
_private->loadImage(*s, x, y);
}
void Timer(ArgArray args) {
2021-01-05 21:03:34 -03:00
debug("Timer(%d, %s, %s)", args[0].u.val, args[1].u.str, args[2].u.str);
g_system->delayMillis(100 * args[0].u.val);
Common::String *s = new Common::String(args[1].u.str);
_nextSetting = s;
}
2021-01-02 10:22:07 -03:00
2021-01-02 00:58:58 -03:00
void execFunction(char *name, ArgArray args) {
if (strcmp(name, "ChgMode") == 0) {
2021-01-02 10:22:07 -03:00
ChgMode(args);
2021-01-02 00:58:58 -03:00
}
2021-01-02 10:22:07 -03:00
else if (strcmp(name, "goto") == 0) {
Goto(args);
}
2021-01-02 00:58:58 -03:00
else if (strcmp(name, "SetFlag") == 0) {
2021-01-02 10:22:07 -03:00
SetFlag(args);
}
else if (strcmp(name, "Sound") == 0) {
Sound(args);
2021-01-02 00:58:58 -03:00
}
else if (strcmp(name, "Bitmap") == 0) {
Bitmap(args);
}
else if (strcmp(name, "Timer") == 0) {
Timer(args);
}
2021-01-04 08:14:40 -03:00
else if (strcmp(name, "Transition") == 0) {
Transition(args);
}
else if (strcmp(name, "SetModifiedFlag") == 0) {
SetModifiedFlag(args);
}
else if (strcmp(name, "Exit") == 0) {
Exit(args);
}
else if (strcmp(name, "Quit") == 0) {
Quit(args);
}
else if (strcmp(name, "LoadGame") == 0) {
;
}
2021-01-05 21:03:34 -03:00
else if (strcmp(name, "CRect") == 0) {
CRect(args);
}
2021-01-04 08:14:40 -03:00
else {
debug("I don't know how to exec %s", name);
2021-01-02 00:58:58 -03:00
assert(0);
2021-01-04 08:14:40 -03:00
}
2021-01-02 00:58:58 -03:00
}
}