2021-01-02 00:58:58 -03:00
|
|
|
#include "common/str.h"
|
|
|
|
#include "common/debug.h"
|
2021-01-02 14:19:23 -03:00
|
|
|
#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-07 23:38:18 -03:00
|
|
|
// assert types
|
|
|
|
debug("ChgMode(%d, %s)", args[0].u.val, args[1].u.str);
|
2021-01-07 23:32:17 -03:00
|
|
|
g_private->_mode = args[0].u.val;
|
2021-01-05 21:03:34 -03:00
|
|
|
Common::String *s = new Common::String(args[1].u.str);
|
2021-01-07 23:32:17 -03:00
|
|
|
g_private->_nextSetting = s;
|
2021-01-08 22:42:34 -03:00
|
|
|
|
|
|
|
if (g_private->_mode == 0) {
|
|
|
|
g_private->_origin->x = 0;
|
|
|
|
g_private->_origin->y = 0;
|
2021-01-09 19:11:41 -03:00
|
|
|
// TODO: should clear the screen?
|
|
|
|
}
|
2021-01-08 22:42:34 -03:00
|
|
|
else if (g_private->_mode == 1) {
|
|
|
|
g_private->_origin->x = 63;
|
|
|
|
g_private->_origin->y = 48;
|
2021-01-09 16:11:30 -03:00
|
|
|
g_private->drawScreenFrame();
|
2021-01-08 22:42:34 -03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VSPicture(ArgArray args) {
|
|
|
|
// assert types
|
|
|
|
debug("VSPicture(%s)", args[0].u.str);
|
|
|
|
g_private->_nextVS = new Common::String(args[0].u.str);
|
2021-01-02 10:22:07 -03:00
|
|
|
}
|
|
|
|
|
2021-01-08 22:42:34 -03:00
|
|
|
|
2021-01-02 10:22:07 -03:00
|
|
|
void Goto(ArgArray args) { // should be goto, but this is a reserved word
|
2021-01-05 21:03:34 -03:00
|
|
|
// assert types
|
2021-01-07 23:38:18 -03:00
|
|
|
debug("goto(%s)", args[0].u.str);
|
2021-01-05 21:03:34 -03:00
|
|
|
Common::String *s = new Common::String(args[0].u.str);
|
2021-01-07 23:32:17 -03:00
|
|
|
g_private->_nextSetting = s;
|
2021-01-02 10:22:07 -03:00
|
|
|
}
|
|
|
|
|
2021-01-07 23:38:18 -03:00
|
|
|
void Quit(ArgArray args) {
|
2021-01-07 23:10:19 -03:00
|
|
|
debug("quit()");
|
2021-01-07 23:38:18 -03:00
|
|
|
g_private->quitGame();
|
2021-01-07 23:10:19 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-08 22:42:34 -03:00
|
|
|
void RestartGame(ArgArray args) {
|
|
|
|
// assert types
|
|
|
|
debug("WARNING: RestartGame is not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
void DossierAdd(ArgArray args) {
|
|
|
|
// assert types
|
|
|
|
debug("WARNING: DossierAdd is not implemented");
|
|
|
|
}
|
2021-01-07 23:10:19 -03:00
|
|
|
|
2021-01-09 16:11:30 -03:00
|
|
|
void Inventory(ArgArray args) {
|
|
|
|
// assert types
|
|
|
|
debug("WARNING: Inventory is not implemented");
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-01-07 23:10:19 -03:00
|
|
|
void Exit(ArgArray args) {
|
|
|
|
// assert types
|
|
|
|
assert(args[2].type == RECT || args[2].type == NAME);
|
2021-01-09 16:11:30 -03:00
|
|
|
debug("Exit(%d %d %d)", args[0].type, args[1].type, args[2].type); //, args[0].u.str, args[1].u.sym->name->c_str(), "RECT");
|
2021-01-07 23:10:19 -03:00
|
|
|
ExitInfo *e = (ExitInfo*) malloc(sizeof(ExitInfo));
|
2021-01-08 22:42:34 -03:00
|
|
|
|
|
|
|
if (args[0].type == NUM && args[0].u.val == 0)
|
|
|
|
e->nextSetting = NULL;
|
|
|
|
else
|
|
|
|
e->nextSetting = new Common::String(args[0].u.str);
|
|
|
|
|
|
|
|
if (args[1].type == NUM && args[1].u.val == 0)
|
|
|
|
e->cursor = NULL;
|
|
|
|
else
|
|
|
|
e->cursor = args[1].u.sym->name;
|
|
|
|
|
2021-01-09 16:11:30 -03:00
|
|
|
if (args[2].type == NAME) {
|
2021-01-09 19:11:41 -03:00
|
|
|
assert(args[2].u.sym->type == RECT);
|
|
|
|
args[2].u.rect = args[2].u.sym->u.rect;
|
2021-01-09 16:11:30 -03:00
|
|
|
}
|
|
|
|
|
2021-01-07 23:10:19 -03:00
|
|
|
e->rect = args[2].u.rect;
|
2021-01-09 16:11:30 -03:00
|
|
|
debug("Rect %d %d %d %d", args[2].u.rect->top, args[2].u.rect->left, args[2].u.rect->bottom, args[2].u.rect->right);
|
2021-01-07 23:32:17 -03:00
|
|
|
g_private->_exits.push_front(*e);
|
2021-01-07 23:10:19 -03:00
|
|
|
}
|
|
|
|
|
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);
|
2021-01-07 23:32:17 -03:00
|
|
|
g_private->_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) {
|
2021-01-07 23:38:18 -03:00
|
|
|
Common::String *s = new Common::String(args[0].u.str);
|
|
|
|
g_private->playSound(*s);
|
|
|
|
//assert(0);
|
2021-01-02 10:22:07 -03:00
|
|
|
} else {
|
2021-01-07 23:38:18 -03:00
|
|
|
g_private->stopSound();
|
2021-01-02 10:22:07 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-09 16:11:30 -03:00
|
|
|
void LoopedSound(ArgArray args) {
|
|
|
|
// assert types
|
|
|
|
assert(args.size() == 1);
|
|
|
|
debug("LoopedSound(%s)", args[0].u.str);
|
|
|
|
if (strcmp("\"\"", args[0].u.str) != 0) {
|
|
|
|
Common::String *s = new Common::String(args[0].u.str);
|
|
|
|
g_private->playSound(*s);
|
|
|
|
//assert(0);
|
|
|
|
} else {
|
|
|
|
g_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);
|
2021-01-09 16:11:30 -03:00
|
|
|
g_private->_nextMovie = new Common::String(args[0].u.str);
|
2021-01-08 22:42:34 -03:00
|
|
|
g_private->_nextSetting = new Common::String(args[1].u.str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Movie(ArgArray args) {
|
|
|
|
// assert types
|
|
|
|
debug("Movie(%s, %s)", args[0].u.str, args[1].u.str);
|
|
|
|
if (strcmp(args[0].u.str, "\"\"") != 0)
|
|
|
|
g_private->_nextMovie = new Common::String(args[0].u.str);
|
2021-01-07 23:32:17 -03:00
|
|
|
g_private->_nextSetting = new Common::String(args[1].u.str);
|
2021-01-05 21:03:34 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-08 22:42:34 -03:00
|
|
|
|
2021-01-05 21:03:34 -03:00
|
|
|
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);
|
|
|
|
|
2021-01-07 23:10:19 -03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-01-02 14:19:23 -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;
|
2021-01-02 14:19:23 -03:00
|
|
|
if (args.size() == 3) {
|
2021-01-07 23:38:18 -03:00
|
|
|
x = args[1].u.val;
|
|
|
|
y = args[2].u.val;
|
2021-01-02 14:19:23 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2021-01-07 23:32:17 -03:00
|
|
|
g_private->loadImage(*s, x, y);
|
2021-01-02 14:19:23 -03:00
|
|
|
}
|
|
|
|
|
2021-01-08 22:42:34 -03:00
|
|
|
void Mask(ArgArray args, bool drawn) {
|
|
|
|
assert(args.size() == 3 || args.size() == 5);
|
|
|
|
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
|
|
|
|
char *f = args[0].u.str;
|
|
|
|
char *e = args[1].u.str;
|
|
|
|
Common::String *c = args[2].u.sym->name;
|
2021-01-09 19:11:41 -03:00
|
|
|
|
2021-01-08 22:42:34 -03:00
|
|
|
if (args.size() == 5) {
|
|
|
|
x = args[3].u.val;
|
|
|
|
y = args[4].u.val;
|
|
|
|
}
|
|
|
|
|
|
|
|
debug("Mask(%s, %s, %s, %d, %d)", f, e, c->c_str(), x, y);
|
|
|
|
const Common::String *s = new Common::String(f);
|
|
|
|
//if (drawed)
|
|
|
|
// g_private->loadImage(*s, x, y);
|
|
|
|
|
|
|
|
MaskInfo *m = (MaskInfo*) malloc(sizeof(MaskInfo));
|
|
|
|
m->surf = g_private->loadMask(*s, x, y, drawn);
|
|
|
|
m->nextSetting = new Common::String(e);
|
|
|
|
m->cursor = c;
|
|
|
|
m->point = new Common::Point(x,y);
|
|
|
|
g_private->_masks.push_front(*m);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 14:19:23 -03:00
|
|
|
void Timer(ArgArray args) {
|
2021-01-09 16:11:30 -03:00
|
|
|
assert (args.size() == 2 || args.size() == 3);
|
|
|
|
|
|
|
|
if (args.size() == 3)
|
|
|
|
debug("Timer(%d, %s, %s)", args[0].u.val, args[1].u.str, args[2].u.str);
|
2021-01-09 19:11:41 -03:00
|
|
|
else
|
2021-01-09 16:11:30 -03:00
|
|
|
debug("Timer(%d, %s)", args[0].u.val, args[1].u.str);
|
2021-01-09 19:11:41 -03:00
|
|
|
|
2021-01-05 21:03:34 -03:00
|
|
|
g_system->delayMillis(100 * args[0].u.val);
|
|
|
|
Common::String *s = new Common::String(args[1].u.str);
|
2021-01-07 23:38:18 -03:00
|
|
|
g_private->_nextSetting = s;
|
2021-01-02 14:19:23 -03:00
|
|
|
}
|
|
|
|
|
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-07 23:38:18 -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) {
|
2021-01-07 23:38:18 -03:00
|
|
|
Goto(args);
|
2021-01-02 10:22:07 -03:00
|
|
|
}
|
|
|
|
|
2021-01-02 00:58:58 -03:00
|
|
|
else if (strcmp(name, "SetFlag") == 0) {
|
2021-01-07 23:38:18 -03:00
|
|
|
SetFlag(args);
|
2021-01-02 10:22:07 -03:00
|
|
|
}
|
|
|
|
else if (strcmp(name, "Sound") == 0) {
|
2021-01-07 23:38:18 -03:00
|
|
|
Sound(args);
|
2021-01-02 00:58:58 -03:00
|
|
|
}
|
2021-01-09 16:11:30 -03:00
|
|
|
else if (strcmp(name, "SoundEffect") == 0) {
|
|
|
|
Sound(args); // Unclear how this is different from Sound
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "LoopedSound") == 0) {
|
|
|
|
LoopedSound(args);
|
|
|
|
}
|
2021-01-02 14:19:23 -03:00
|
|
|
else if (strcmp(name, "Bitmap") == 0) {
|
2021-01-07 23:38:18 -03:00
|
|
|
Bitmap(args);
|
2021-01-02 14:19:23 -03:00
|
|
|
}
|
2021-01-08 22:42:34 -03:00
|
|
|
else if (strcmp(name, "Mask") == 0) {
|
|
|
|
Mask(args, false);
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "MaskDrawn") == 0) {
|
|
|
|
Mask(args, true);
|
|
|
|
}
|
2021-01-09 19:11:41 -03:00
|
|
|
|
2021-01-02 14:19:23 -03:00
|
|
|
else if (strcmp(name, "Timer") == 0) {
|
2021-01-07 23:38:18 -03:00
|
|
|
Timer(args);
|
2021-01-02 14:19:23 -03:00
|
|
|
}
|
2021-01-04 08:14:40 -03:00
|
|
|
else if (strcmp(name, "Transition") == 0) {
|
2021-01-07 23:38:18 -03:00
|
|
|
Transition(args);
|
2021-01-04 08:14:40 -03:00
|
|
|
}
|
2021-01-08 22:42:34 -03:00
|
|
|
else if (strcmp(name, "Movie") == 0) {
|
|
|
|
Movie(args);
|
|
|
|
}
|
2021-01-04 08:14:40 -03:00
|
|
|
else if (strcmp(name, "SetModifiedFlag") == 0) {
|
2021-01-07 23:38:18 -03:00
|
|
|
SetModifiedFlag(args);
|
2021-01-04 08:14:40 -03:00
|
|
|
}
|
2021-01-02 14:19:23 -03:00
|
|
|
else if (strcmp(name, "Exit") == 0) {
|
2021-01-07 23:38:18 -03:00
|
|
|
Exit(args);
|
2021-01-07 23:10:19 -03:00
|
|
|
}
|
|
|
|
else if (strcmp(name, "Quit") == 0) {
|
2021-01-07 23:38:18 -03:00
|
|
|
Quit(args);
|
2021-01-02 14:19:23 -03:00
|
|
|
}
|
2021-01-06 21:46:54 -03:00
|
|
|
else if (strcmp(name, "LoadGame") == 0) {
|
2021-01-07 23:38:18 -03:00
|
|
|
;
|
2021-01-06 21:46:54 -03:00
|
|
|
}
|
2021-01-08 22:42:34 -03:00
|
|
|
else if (strcmp(name, "DossierAdd") == 0) {
|
|
|
|
DossierAdd(args);
|
|
|
|
}
|
2021-01-09 16:11:30 -03:00
|
|
|
else if (strcmp(name, "Inventory") == 0) {
|
|
|
|
Inventory(args);
|
|
|
|
}
|
2021-01-08 22:42:34 -03:00
|
|
|
else if (strcmp(name, "VSPicture") == 0) {
|
|
|
|
VSPicture(args);
|
|
|
|
}
|
2021-01-05 21:03:34 -03:00
|
|
|
else if (strcmp(name, "CRect") == 0) {
|
2021-01-07 23:38:18 -03:00
|
|
|
CRect(args);
|
|
|
|
}
|
2021-01-08 22:42:34 -03:00
|
|
|
else if (strcmp(name, "RestartGame") == 0) {
|
|
|
|
RestartGame(args);
|
|
|
|
}
|
2021-01-04 08:14:40 -03:00
|
|
|
else {
|
2021-01-07 23:38:18 -03:00
|
|
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|