mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-17 07:07:10 +00:00
PRIVATE: used astyle to improve code formatting
This commit is contained in:
parent
5c48056948
commit
536fcd5605
@ -19,330 +19,330 @@ Inst *pc = NULL; /* program counter during execution */
|
||||
|
||||
|
||||
static struct FuncDescr {
|
||||
const Inst func;
|
||||
const char *name;
|
||||
const char *args;
|
||||
const Inst func;
|
||||
const char *name;
|
||||
const char *args;
|
||||
} funcDescr[] = {
|
||||
{ 0, "STOP", "" },
|
||||
{ constpush, "constpush", "" },
|
||||
{ strpush, "strpush", "" },
|
||||
{ varpush, "varpush", "" },
|
||||
{ funcpush, "funcpush", "" },
|
||||
{ eval, "eval", "" },
|
||||
{ ifcode, "ifcode", "" },
|
||||
{ add, "add", "" },
|
||||
{ negate, "negate", "" },
|
||||
|
||||
{ 0, 0, 0 }
|
||||
{ 0, "STOP", "" },
|
||||
{ constpush, "constpush", "" },
|
||||
{ strpush, "strpush", "" },
|
||||
{ varpush, "varpush", "" },
|
||||
{ funcpush, "funcpush", "" },
|
||||
{ eval, "eval", "" },
|
||||
{ ifcode, "ifcode", "" },
|
||||
{ add, "add", "" },
|
||||
{ negate, "negate", "" },
|
||||
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
FuncHash _functions;
|
||||
|
||||
void initFuncs() {
|
||||
for (FuncDescr *fnc = funcDescr; fnc->name; fnc++) {
|
||||
_functions[(void *)fnc->func] = new Common::String(fnc->name);
|
||||
}
|
||||
for (FuncDescr *fnc = funcDescr; fnc->name; fnc++) {
|
||||
_functions[(void *)fnc->func] = new Common::String(fnc->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void initSetting() /* initialize for code generation */
|
||||
{
|
||||
psetting = (Setting*) malloc(sizeof(Setting));
|
||||
memset((void *) psetting, 0, sizeof(Setting));
|
||||
psetting = (Setting*) malloc(sizeof(Setting));
|
||||
memset((void *) psetting, 0, sizeof(Setting));
|
||||
|
||||
prog = (Inst *) &psetting->prog;
|
||||
stack = (Datum *) &psetting->stack;
|
||||
prog = (Inst *) &psetting->prog;
|
||||
stack = (Datum *) &psetting->stack;
|
||||
|
||||
stackp = stack;
|
||||
progp = prog;
|
||||
stackp = stack;
|
||||
progp = prog;
|
||||
}
|
||||
|
||||
void saveSetting(char *name)
|
||||
{
|
||||
Common::String s(name);
|
||||
settingcode.setVal(s, psetting);
|
||||
//debug("setting %s", name);
|
||||
Common::String s(name);
|
||||
settingcode.setVal(s, psetting);
|
||||
//debug("setting %s", name);
|
||||
}
|
||||
|
||||
void loadSetting(Common::String *name)
|
||||
void loadSetting(Common::String *name)
|
||||
{
|
||||
assert(settingcode.contains(*name));
|
||||
psetting = settingcode.getVal(*name);
|
||||
assert(settingcode.contains(*name));
|
||||
psetting = settingcode.getVal(*name);
|
||||
|
||||
debug("loading setting %s", name->c_str());
|
||||
debug("loading setting %s", name->c_str());
|
||||
|
||||
prog = (Inst *) &psetting->prog;
|
||||
stack = (Datum *) &psetting->stack;
|
||||
prog = (Inst *) &psetting->prog;
|
||||
stack = (Datum *) &psetting->stack;
|
||||
|
||||
stackp = stack;
|
||||
progp = prog;
|
||||
stackp = stack;
|
||||
progp = prog;
|
||||
|
||||
|
||||
for (Inst *pc_ = progp; pc_-progp < 100; pc_++) {
|
||||
if (_functions.contains((void *) *pc_))
|
||||
debug("%x: %s", pc_, _functions.getVal((void*) *pc_)->c_str());
|
||||
else if ( (Inst *) *pc_ >= progp && (Inst *) *pc_ <= (progp + NPROG))
|
||||
debug("%x: %x", pc_, (void*) *pc_);
|
||||
else {
|
||||
debugN("%x:", pc_);
|
||||
showSymbol((Symbol *) *pc_);
|
||||
}
|
||||
for (Inst *pc_ = progp; pc_-progp < 100; pc_++) {
|
||||
if (_functions.contains((void *) *pc_))
|
||||
debug("%p: %s", (void*) pc_, _functions.getVal((void*) *pc_)->c_str());
|
||||
else if ( (Inst *) *pc_ >= progp && (Inst *) *pc_ <= (progp + NPROG))
|
||||
debug("%p: %p", (void*) pc_, (void*) *pc_);
|
||||
else {
|
||||
debugN("%p:", (void*) pc_);
|
||||
showSymbol((Symbol *) *pc_);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int push(Datum d) /* push d onto stack */
|
||||
{
|
||||
assert (!(stackp >= &stack[NSTACK]));
|
||||
*stackp++ = d;
|
||||
return 0;
|
||||
assert (!(stackp >= &stack[NSTACK]));
|
||||
*stackp++ = d;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Datum pop() /* pop and return top elem from stack */
|
||||
{
|
||||
assert (!(stackp <= stack));
|
||||
return *--stackp;
|
||||
assert (!(stackp <= stack));
|
||||
return *--stackp;
|
||||
}
|
||||
|
||||
int constpush() /* push constant onto stack */
|
||||
{
|
||||
Datum d;
|
||||
Symbol *s = (Symbol *)*pc++;
|
||||
d.type = NUM;
|
||||
d.u.val = s->u.val;
|
||||
|
||||
debug("pushing const %d with name %s", d.u.val, s->name->c_str());
|
||||
push(d);
|
||||
return 0;
|
||||
Datum d;
|
||||
Symbol *s = (Symbol *)*pc++;
|
||||
d.type = NUM;
|
||||
d.u.val = s->u.val;
|
||||
|
||||
debug("pushing const %d with name %s", d.u.val, s->name->c_str());
|
||||
push(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int strpush() /* push constant onto stack */
|
||||
{
|
||||
Datum d;
|
||||
d.type = STRING;
|
||||
Symbol *s = (Symbol *)*pc++;
|
||||
d.u.str = s->u.str;
|
||||
debug("pushing const %s with name %s", d.u.str, s->name->c_str());
|
||||
push(d);
|
||||
return 0;
|
||||
Datum d;
|
||||
d.type = STRING;
|
||||
Symbol *s = (Symbol *)*pc++;
|
||||
d.u.str = s->u.str;
|
||||
debug("pushing const %s with name %s", d.u.str, s->name->c_str());
|
||||
push(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int varpush() /* push variable onto stack */
|
||||
{
|
||||
Datum d;
|
||||
d.type = NAME;
|
||||
d.u.sym = (Symbol *)(*pc++);
|
||||
debug("var pushing %s", d.u.sym->name->c_str());
|
||||
push(d);
|
||||
return 0;
|
||||
Datum d;
|
||||
d.type = NAME;
|
||||
d.u.sym = (Symbol *)(*pc++);
|
||||
debug("var pushing %s", d.u.sym->name->c_str());
|
||||
push(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int funcpush() //(char *name, int nargs)
|
||||
int funcpush() //(char *name, int nargs)
|
||||
{
|
||||
Datum s, n, arg;
|
||||
s = pop();
|
||||
n = pop();
|
||||
ArgArray args;
|
||||
Datum s, n, arg;
|
||||
s = pop();
|
||||
n = pop();
|
||||
ArgArray args;
|
||||
|
||||
debug("executing %s with %d params", s.u.str, n.u.val);
|
||||
for (int i = 0; i < n.u.val; i++) {
|
||||
arg = pop();
|
||||
//debug("%d", arg.val);
|
||||
args.insert(args.begin(), arg) ;
|
||||
}
|
||||
debug("executing %s with %d params", s.u.str, n.u.val);
|
||||
for (int i = 0; i < n.u.val; i++) {
|
||||
arg = pop();
|
||||
//debug("%d", arg.val);
|
||||
args.insert(args.begin(), arg) ;
|
||||
}
|
||||
|
||||
execFunction(s.u.str, args);
|
||||
return 0;
|
||||
execFunction(s.u.str, args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int eval() /* evaluate variable on stack */
|
||||
{
|
||||
Datum d;
|
||||
d = pop();
|
||||
debug("eval %s", d.u.sym->name->c_str());
|
||||
//if (d.sym->type == UNDEF)
|
||||
// execerror("undefined variable", d.sym->name);
|
||||
if (d.u.sym->type == NUM) {
|
||||
d.type = NUM;
|
||||
d.u.val = d.u.sym->u.val;
|
||||
} else if (d.u.sym->type == STRING) {
|
||||
d.type = STRING;
|
||||
d.u.str = d.u.sym->u.str;
|
||||
} else if (d.u.sym->type == NAME) {
|
||||
//debug("NAME %s", d.sym->name->c_str());
|
||||
//d.sym = d.sym;
|
||||
}
|
||||
else
|
||||
assert(0);
|
||||
|
||||
|
||||
push(d);
|
||||
return 0;
|
||||
Datum d;
|
||||
d = pop();
|
||||
debug("eval %s", d.u.sym->name->c_str());
|
||||
//if (d.sym->type == UNDEF)
|
||||
// execerror("undefined variable", d.sym->name);
|
||||
if (d.u.sym->type == NUM) {
|
||||
d.type = NUM;
|
||||
d.u.val = d.u.sym->u.val;
|
||||
} else if (d.u.sym->type == STRING) {
|
||||
d.type = STRING;
|
||||
d.u.str = d.u.sym->u.str;
|
||||
} else if (d.u.sym->type == NAME) {
|
||||
//debug("NAME %s", d.sym->name->c_str());
|
||||
//d.sym = d.sym;
|
||||
}
|
||||
else
|
||||
assert(0);
|
||||
|
||||
|
||||
push(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int add() /* add top two elems on stack */
|
||||
{
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
//printf("adding %d %d\n",d1.val, d2.val);
|
||||
d1.u.val += d2.u.val;
|
||||
push(d1);
|
||||
return 0;
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
//printf("adding %d %d\n",d1.val, d2.val);
|
||||
d1.u.val += d2.u.val;
|
||||
push(d1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int negate()
|
||||
{
|
||||
Datum d;
|
||||
d = pop();
|
||||
int v;
|
||||
if (d.type == NAME) {
|
||||
debug("negating %s", d.u.sym->name->c_str());
|
||||
v = d.u.sym->u.val;
|
||||
d.type = NUM;
|
||||
}
|
||||
else if (d.type == NUM) {
|
||||
v = d.u.val;
|
||||
}
|
||||
else
|
||||
assert(0);
|
||||
Datum d;
|
||||
d = pop();
|
||||
int v;
|
||||
if (d.type == NAME) {
|
||||
debug("negating %s", d.u.sym->name->c_str());
|
||||
v = d.u.sym->u.val;
|
||||
d.type = NUM;
|
||||
}
|
||||
else if (d.type == NUM) {
|
||||
v = d.u.val;
|
||||
}
|
||||
else
|
||||
assert(0);
|
||||
|
||||
d.u.val = !v;
|
||||
push(d);
|
||||
return 0;
|
||||
d.u.val = !v;
|
||||
push(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int assign() /* assign top value to next value */
|
||||
{
|
||||
Datum d1, d2;
|
||||
d1 = pop();
|
||||
d2 = pop();
|
||||
/*if (d1.sym->type != VAR && d1.sym->type != UNDEF)
|
||||
execerror("assignment to non-variable",
|
||||
d1.sym->name);*/
|
||||
d1.u.sym->u.val = d2.u.val;
|
||||
d1.u.sym->type = NAME;
|
||||
push(d2);
|
||||
return 0;
|
||||
Datum d1, d2;
|
||||
d1 = pop();
|
||||
d2 = pop();
|
||||
/*if (d1.sym->type != VAR && d1.sym->type != UNDEF)
|
||||
execerror("assignment to non-variable",
|
||||
d1.sym->name);*/
|
||||
d1.u.sym->u.val = d2.u.val;
|
||||
d1.u.sym->type = NAME;
|
||||
push(d2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gt()
|
||||
{
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
d1.u.val = (int)(d1.u.val > d2.u.val);
|
||||
push(d1);
|
||||
return 0;
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
d1.u.val = (int)(d1.u.val > d2.u.val);
|
||||
push(d1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lt()
|
||||
{
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
d1.u.val = (int)(d1.u.val < d2.u.val);
|
||||
push(d1);
|
||||
return 0;
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
d1.u.val = (int)(d1.u.val < d2.u.val);
|
||||
push(d1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ge()
|
||||
{
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
d1.u.val = (int)(d1.u.val >= d2.u.val);
|
||||
push(d1);
|
||||
return 0;
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
d1.u.val = (int)(d1.u.val >= d2.u.val);
|
||||
push(d1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int le()
|
||||
{
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
d1.u.val = (int)(d1.u.val <= d2.u.val);
|
||||
push(d1);
|
||||
return 0;
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
d1.u.val = (int)(d1.u.val <= d2.u.val);
|
||||
push(d1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int eq()
|
||||
{
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
d1.u.val = (int)(d1.u.val == d2.u.val);
|
||||
push(d1);
|
||||
return 0;
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
d1.u.val = (int)(d1.u.val == d2.u.val);
|
||||
push(d1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ne()
|
||||
{
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
d1.u.val = (int)(d1.u.val != d2.u.val);
|
||||
push(d1);
|
||||
return 0;
|
||||
Datum d1, d2;
|
||||
d2 = pop();
|
||||
d1 = pop();
|
||||
d1.u.val = (int)(d1.u.val != d2.u.val);
|
||||
push(d1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Inst *code(Inst f) /* install one instruction or operand */
|
||||
{
|
||||
//debug("pushing code at %d", progp);
|
||||
Inst *oprogp = progp;
|
||||
assert (!(progp >= &prog[NPROG]));
|
||||
*progp++ = f;
|
||||
return oprogp;
|
||||
//debug("pushing code at %d", progp);
|
||||
Inst *oprogp = progp;
|
||||
assert (!(progp >= &prog[NPROG]));
|
||||
*progp++ = f;
|
||||
return oprogp;
|
||||
}
|
||||
|
||||
int ifcode()
|
||||
{
|
||||
Datum d;
|
||||
Inst *savepc = pc; /* then part */
|
||||
debug("ifcode: evaluating condition");
|
||||
Datum d;
|
||||
Inst *savepc = pc; /* then part */
|
||||
debug("ifcode: evaluating condition");
|
||||
|
||||
execute(savepc+3); /* condition */
|
||||
d = pop();
|
||||
execute(savepc+3); /* condition */
|
||||
d = pop();
|
||||
|
||||
debug("ifcode: selecting branch");
|
||||
debug("ifcode: selecting branch");
|
||||
|
||||
if (d.type == NAME) {
|
||||
debug("name %s", d.u.sym->name->c_str()); //, d.sym->u.val);
|
||||
d.u.val = d.u.sym->u.val;
|
||||
}
|
||||
//debug("ptr: %x", *((Inst **)(savepc+1)));
|
||||
//debug("ptr: %x", *((Inst **)(savepc+2)));
|
||||
//debug("ptr: %x", *((Inst **)(savepc+3)));
|
||||
|
||||
//assert(0);
|
||||
if (d.u.val) {
|
||||
debug("ifcode: true branch");
|
||||
execute(*((Inst **)(savepc)));
|
||||
}
|
||||
else if (*((Inst **)(savepc+1))) /* else part? */ {
|
||||
debug("ifcode: false branch");
|
||||
execute(*((Inst **)(savepc+1)));
|
||||
}
|
||||
debug("ifcode finished");
|
||||
pc = *((Inst **)(savepc+2)); /* next stmt */
|
||||
return 0;
|
||||
if (d.type == NAME) {
|
||||
debug("name %s", d.u.sym->name->c_str()); //, d.sym->u.val);
|
||||
d.u.val = d.u.sym->u.val;
|
||||
}
|
||||
//debug("ptr: %x", *((Inst **)(savepc+1)));
|
||||
//debug("ptr: %x", *((Inst **)(savepc+2)));
|
||||
//debug("ptr: %x", *((Inst **)(savepc+3)));
|
||||
|
||||
//assert(0);
|
||||
if (d.u.val) {
|
||||
debug("ifcode: true branch");
|
||||
execute(*((Inst **)(savepc)));
|
||||
}
|
||||
else if (*((Inst **)(savepc+1))) { /* else part? */
|
||||
debug("ifcode: false branch");
|
||||
execute(*((Inst **)(savepc+1)));
|
||||
}
|
||||
debug("ifcode finished");
|
||||
pc = *((Inst **)(savepc+2)); /* next stmt */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fail()
|
||||
int fail()
|
||||
{
|
||||
assert(0);
|
||||
return 0;
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void execute(Inst *p) /* run the machine */
|
||||
{
|
||||
for (pc = p; *pc != STOP; ) {
|
||||
(*(*pc++))();
|
||||
}
|
||||
for (pc = p; *pc != STOP; ) {
|
||||
(*(*pc++))();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,48 +3,48 @@
|
||||
|
||||
namespace Private {
|
||||
static const PlainGameDescriptor privateGames[] = {
|
||||
{ "private-eye", "Private Eye" },
|
||||
{ 0, 0 }
|
||||
{ "private-eye", "Private Eye" },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
static const ADGameDescription gameDescriptions[] = {
|
||||
{
|
||||
"private-eye",
|
||||
0,
|
||||
AD_ENTRY1s("GAME.DAT", "7a3eb7d9dedf40680ac3d088524f976e", 190735),
|
||||
Common::EN_ANY,
|
||||
Common::kPlatformWindows,
|
||||
ADGF_NO_FLAGS,
|
||||
GUIO1(GUIO_NOMIDI)
|
||||
},
|
||||
AD_TABLE_END_MARKER
|
||||
{
|
||||
"private-eye",
|
||||
0,
|
||||
AD_ENTRY1s("GAME.DAT", "7a3eb7d9dedf40680ac3d088524f976e", 190735),
|
||||
Common::EN_ANY,
|
||||
Common::kPlatformWindows,
|
||||
ADGF_NO_FLAGS,
|
||||
GUIO1(GUIO_NOMIDI)
|
||||
},
|
||||
AD_TABLE_END_MARKER
|
||||
};
|
||||
} // End of namespace Private
|
||||
|
||||
static const char *const directoryGlobs[] = {
|
||||
"support", // english CD
|
||||
0
|
||||
"support", // english CD
|
||||
0
|
||||
};
|
||||
|
||||
class PrivateMetaEngineDetection : public AdvancedMetaEngineDetection {
|
||||
public:
|
||||
PrivateMetaEngineDetection() : AdvancedMetaEngineDetection(Private::gameDescriptions, sizeof(ADGameDescription), Private::privateGames) {
|
||||
_maxScanDepth = 2;
|
||||
_directoryGlobs = directoryGlobs;
|
||||
}
|
||||
PrivateMetaEngineDetection() : AdvancedMetaEngineDetection(Private::gameDescriptions, sizeof(ADGameDescription), Private::privateGames) {
|
||||
_maxScanDepth = 2;
|
||||
_directoryGlobs = directoryGlobs;
|
||||
}
|
||||
|
||||
const char *getEngineId() const override {
|
||||
return "private";
|
||||
}
|
||||
const char *getEngineId() const override {
|
||||
return "private";
|
||||
}
|
||||
|
||||
const char *getName() const override {
|
||||
return "Private Eye";
|
||||
}
|
||||
const char *getName() const override {
|
||||
return "Private Eye";
|
||||
}
|
||||
|
||||
const char *getOriginalCopyright() const override {
|
||||
return "Copyright (C) Brooklyn Multimedia";
|
||||
}
|
||||
const char *getOriginalCopyright() const override {
|
||||
return "Copyright (C) Brooklyn Multimedia";
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_PLUGIN_STATIC(PRIVATE_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, PrivateMetaEngineDetection);
|
||||
|
@ -9,8 +9,8 @@
|
||||
namespace Private {
|
||||
|
||||
void ChgMode(ArgArray args) {
|
||||
// assert types
|
||||
debug("ChgMode(%d, %s)", args[0].u.val, args[1].u.str);
|
||||
// assert types
|
||||
debug("ChgMode(%d, %s)", args[0].u.val, args[1].u.str);
|
||||
g_private->_mode = args[0].u.val;
|
||||
Common::String *s = new Common::String(args[1].u.str);
|
||||
g_private->_nextSetting = s;
|
||||
@ -18,14 +18,14 @@ void ChgMode(ArgArray args) {
|
||||
|
||||
void Goto(ArgArray args) { // should be goto, but this is a reserved word
|
||||
// assert types
|
||||
debug("goto(%s)", args[0].u.str);
|
||||
debug("goto(%s)", args[0].u.str);
|
||||
Common::String *s = new Common::String(args[0].u.str);
|
||||
g_private->_nextSetting = s;
|
||||
}
|
||||
|
||||
void Quit(ArgArray args) {
|
||||
void Quit(ArgArray args) {
|
||||
debug("quit()");
|
||||
g_private->quitGame();
|
||||
g_private->quitGame();
|
||||
}
|
||||
|
||||
|
||||
@ -60,11 +60,11 @@ void Sound(ArgArray args) {
|
||||
// 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);
|
||||
g_private->playSound(*s);
|
||||
//assert(0);
|
||||
Common::String *s = new Common::String(args[0].u.str);
|
||||
g_private->playSound(*s);
|
||||
//assert(0);
|
||||
} else {
|
||||
g_private->stopSound();
|
||||
g_private->stopSound();
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,8 +104,8 @@ void Bitmap(ArgArray args) {
|
||||
|
||||
char *f = args[0].u.str;
|
||||
if (args.size() == 3) {
|
||||
x = args[1].u.val;
|
||||
y = args[2].u.val;
|
||||
x = args[1].u.val;
|
||||
y = args[2].u.val;
|
||||
}
|
||||
|
||||
debug("Bitmap(%s, %d, %d)", f, x, y);
|
||||
@ -117,50 +117,50 @@ void Timer(ArgArray args) {
|
||||
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);
|
||||
g_private->_nextSetting = s;
|
||||
g_private->_nextSetting = s;
|
||||
}
|
||||
|
||||
|
||||
void execFunction(char *name, ArgArray args) {
|
||||
if (strcmp(name, "ChgMode") == 0) {
|
||||
ChgMode(args);
|
||||
ChgMode(args);
|
||||
}
|
||||
else if (strcmp(name, "goto") == 0) {
|
||||
Goto(args);
|
||||
Goto(args);
|
||||
}
|
||||
|
||||
else if (strcmp(name, "SetFlag") == 0) {
|
||||
SetFlag(args);
|
||||
SetFlag(args);
|
||||
}
|
||||
else if (strcmp(name, "Sound") == 0) {
|
||||
Sound(args);
|
||||
Sound(args);
|
||||
}
|
||||
else if (strcmp(name, "Bitmap") == 0) {
|
||||
Bitmap(args);
|
||||
Bitmap(args);
|
||||
}
|
||||
else if (strcmp(name, "Timer") == 0) {
|
||||
Timer(args);
|
||||
Timer(args);
|
||||
}
|
||||
else if (strcmp(name, "Transition") == 0) {
|
||||
Transition(args);
|
||||
Transition(args);
|
||||
}
|
||||
else if (strcmp(name, "SetModifiedFlag") == 0) {
|
||||
SetModifiedFlag(args);
|
||||
SetModifiedFlag(args);
|
||||
}
|
||||
else if (strcmp(name, "Exit") == 0) {
|
||||
Exit(args);
|
||||
Exit(args);
|
||||
}
|
||||
else if (strcmp(name, "Quit") == 0) {
|
||||
Quit(args);
|
||||
Quit(args);
|
||||
}
|
||||
else if (strcmp(name, "LoadGame") == 0) {
|
||||
;
|
||||
;
|
||||
}
|
||||
else if (strcmp(name, "CRect") == 0) {
|
||||
CRect(args);
|
||||
}
|
||||
CRect(args);
|
||||
}
|
||||
else {
|
||||
debug("I don't know how to exec %s", name);
|
||||
debug("I don't know how to exec %s", name);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
@ -3,16 +3,16 @@
|
||||
|
||||
class PrivateMetaEngine : public AdvancedMetaEngine {
|
||||
public:
|
||||
const char *getName() const override {
|
||||
return "private";
|
||||
}
|
||||
const char *getName() const override {
|
||||
return "private";
|
||||
}
|
||||
|
||||
Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
|
||||
Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
|
||||
};
|
||||
|
||||
Common::Error PrivateMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
||||
*engine = new Private::PrivateEngine(syst);
|
||||
return Common::kNoError;
|
||||
*engine = new Private::PrivateEngine(syst);
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
#if PLUGIN_ENABLED_DYNAMIC(PRIVATE)
|
||||
|
@ -29,336 +29,336 @@ PrivateEngine *g_private = NULL;
|
||||
extern int parse(char*);
|
||||
|
||||
static const byte MOUSECURSOR_SCI[] = {
|
||||
1,1,0,0,0,0,0,0,0,0,0,
|
||||
1,2,1,0,0,0,0,0,0,0,0,
|
||||
1,2,2,1,0,0,0,0,0,0,0,
|
||||
1,2,2,2,1,0,0,0,0,0,0,
|
||||
1,2,2,2,2,1,0,0,0,0,0,
|
||||
1,2,2,2,2,2,1,0,0,0,0,
|
||||
1,2,2,2,2,2,2,1,0,0,0,
|
||||
1,2,2,2,2,2,2,2,1,0,0,
|
||||
1,2,2,2,2,2,2,2,2,1,0,
|
||||
1,2,2,2,2,2,2,2,2,2,1,
|
||||
1,2,2,2,2,2,1,0,0,0,0,
|
||||
1,2,1,0,1,2,2,1,0,0,0,
|
||||
1,1,0,0,1,2,2,1,0,0,0,
|
||||
0,0,0,0,0,1,2,2,1,0,0,
|
||||
0,0,0,0,0,1,2,2,1,0,0,
|
||||
0,0,0,0,0,0,1,2,2,1,0
|
||||
1,1,0,0,0,0,0,0,0,0,0,
|
||||
1,2,1,0,0,0,0,0,0,0,0,
|
||||
1,2,2,1,0,0,0,0,0,0,0,
|
||||
1,2,2,2,1,0,0,0,0,0,0,
|
||||
1,2,2,2,2,1,0,0,0,0,0,
|
||||
1,2,2,2,2,2,1,0,0,0,0,
|
||||
1,2,2,2,2,2,2,1,0,0,0,
|
||||
1,2,2,2,2,2,2,2,1,0,0,
|
||||
1,2,2,2,2,2,2,2,2,1,0,
|
||||
1,2,2,2,2,2,2,2,2,2,1,
|
||||
1,2,2,2,2,2,1,0,0,0,0,
|
||||
1,2,1,0,1,2,2,1,0,0,0,
|
||||
1,1,0,0,1,2,2,1,0,0,0,
|
||||
0,0,0,0,0,1,2,2,1,0,0,
|
||||
0,0,0,0,0,1,2,2,1,0,0,
|
||||
0,0,0,0,0,0,1,2,2,1,0
|
||||
};
|
||||
|
||||
static const byte cursorPalette[] = {
|
||||
0, 0, 0, // Black / Transparent
|
||||
0x80, 0x80, 0x80, // Gray
|
||||
0xff, 0xff, 0xff // White
|
||||
0, 0, 0, // Black / Transparent
|
||||
0x80, 0x80, 0x80, // Gray
|
||||
0xff, 0xff, 0xff // White
|
||||
};
|
||||
|
||||
PrivateEngine::PrivateEngine(OSystem *syst)
|
||||
: Engine(syst) {
|
||||
// Put your engine in a sane state, but do nothing big yet;
|
||||
// in particular, do not load data from files; rather, if you
|
||||
// need to do such things, do them from run().
|
||||
: Engine(syst) {
|
||||
// Put your engine in a sane state, but do nothing big yet;
|
||||
// in particular, do not load data from files; rather, if you
|
||||
// need to do such things, do them from run().
|
||||
|
||||
// Do not initialize graphics here
|
||||
// Do not initialize audio devices here
|
||||
// Do not initialize graphics here
|
||||
// Do not initialize audio devices here
|
||||
|
||||
// However this is the place to specify all default directories
|
||||
//const Common::FSNode gameDataDir(ConfMan.get("path"));
|
||||
//SearchMan.addSubDirectoryMatching(gameDataDir, "..");
|
||||
// However this is the place to specify all default directories
|
||||
//const Common::FSNode gameDataDir(ConfMan.get("path"));
|
||||
//SearchMan.addSubDirectoryMatching(gameDataDir, "..");
|
||||
|
||||
// Here is the right place to set up the engine specific debug channels
|
||||
//DebugMan.addDebugChannel(kPrivateDebugExample, "example", "this is just an example for a engine specific debug channel");
|
||||
//DebugMan.addDebugChannel(kPrivateDebugExample2, "example2", "also an example");
|
||||
// Here is the right place to set up the engine specific debug channels
|
||||
//DebugMan.addDebugChannel(kPrivateDebugExample, "example", "this is just an example for a engine specific debug channel");
|
||||
//DebugMan.addDebugChannel(kPrivateDebugExample2, "example2", "also an example");
|
||||
|
||||
// Don't forget to register your random source
|
||||
_rnd = new Common::RandomSource("private");
|
||||
// Don't forget to register your random source
|
||||
_rnd = new Common::RandomSource("private");
|
||||
|
||||
g_private = this;
|
||||
g_private = this;
|
||||
|
||||
_nextSetting = NULL;
|
||||
_nextMovie = NULL;
|
||||
_modified = false;
|
||||
_mode = -1;
|
||||
_nextSetting = NULL;
|
||||
_nextMovie = NULL;
|
||||
_modified = false;
|
||||
_mode = -1;
|
||||
|
||||
}
|
||||
|
||||
PrivateEngine::~PrivateEngine() {
|
||||
debug("PrivateEngine::~PrivateEngine");
|
||||
debug("PrivateEngine::~PrivateEngine");
|
||||
|
||||
// Dispose your resources here
|
||||
delete _rnd;
|
||||
// Dispose your resources here
|
||||
delete _rnd;
|
||||
|
||||
// Remove all of our debug levels here
|
||||
DebugMan.clearAllDebugChannels();
|
||||
// Remove all of our debug levels here
|
||||
DebugMan.clearAllDebugChannels();
|
||||
}
|
||||
|
||||
Common::Error PrivateEngine::run() {
|
||||
Common::File *file = new Common::File();
|
||||
assert(file->open("GAME.DAT"));
|
||||
void *buf = malloc(191000);
|
||||
file->read(buf, 191000);
|
||||
initFuncs();
|
||||
parse((char *) buf);
|
||||
assert(constants.size() > 0);
|
||||
|
||||
// Initialize graphics using following:
|
||||
_screenW = 640;
|
||||
_screenH = 480;
|
||||
//_pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
|
||||
_pixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
|
||||
initGraphics(_screenW, _screenH, &_pixelFormat);
|
||||
Common::File *file = new Common::File();
|
||||
assert(file->open("GAME.DAT"));
|
||||
void *buf = malloc(191000);
|
||||
file->read(buf, 191000);
|
||||
initFuncs();
|
||||
parse((char *) buf);
|
||||
assert(constants.size() > 0);
|
||||
|
||||
CursorMan.replaceCursor(MOUSECURSOR_SCI, 11, 16, 0, 0, 0);
|
||||
CursorMan.replaceCursorPalette(cursorPalette, 0, 3);
|
||||
// Initialize graphics using following:
|
||||
_screenW = 640;
|
||||
_screenH = 480;
|
||||
//_pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
|
||||
_pixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
|
||||
initGraphics(_screenW, _screenH, &_pixelFormat);
|
||||
|
||||
_image = new Image::BitmapDecoder();
|
||||
_compositeSurface = new Graphics::ManagedSurface();
|
||||
_compositeSurface->create(_screenW, _screenH, _pixelFormat);
|
||||
_compositeSurface->setTransparentColor(0x00ff00);
|
||||
CursorMan.replaceCursor(MOUSECURSOR_SCI, 11, 16, 0, 0, 0);
|
||||
CursorMan.replaceCursorPalette(cursorPalette, 0, 3);
|
||||
|
||||
// You could use backend transactions directly as an alternative,
|
||||
// but it isn't recommended, until you want to handle the error values
|
||||
// from OSystem::endGFXTransaction yourself.
|
||||
// This is just an example template:
|
||||
//_system->beginGFXTransaction();
|
||||
// // This setup the graphics mode according to users seetings
|
||||
// initCommonGFX(false);
|
||||
//
|
||||
// // Specify dimensions of game graphics window.
|
||||
// // In this example: 320x200
|
||||
// _system->initSize(320, 200);
|
||||
//FIXME: You really want to handle
|
||||
//OSystem::kTransactionSizeChangeFailed here
|
||||
//_system->endGFXTransaction();
|
||||
_image = new Image::BitmapDecoder();
|
||||
_compositeSurface = new Graphics::ManagedSurface();
|
||||
_compositeSurface->create(_screenW, _screenH, _pixelFormat);
|
||||
_compositeSurface->setTransparentColor(0x00ff00);
|
||||
|
||||
// Create debugger console. It requires GFX to be initialized
|
||||
Console *console = new Console(this);
|
||||
setDebugger(console);
|
||||
// You could use backend transactions directly as an alternative,
|
||||
// but it isn't recommended, until you want to handle the error values
|
||||
// from OSystem::endGFXTransaction yourself.
|
||||
// This is just an example template:
|
||||
//_system->beginGFXTransaction();
|
||||
// // This setup the graphics mode according to users seetings
|
||||
// initCommonGFX(false);
|
||||
//
|
||||
// // Specify dimensions of game graphics window.
|
||||
// // In this example: 320x200
|
||||
// _system->initSize(320, 200);
|
||||
//FIXME: You really want to handle
|
||||
//OSystem::kTransactionSizeChangeFailed here
|
||||
//_system->endGFXTransaction();
|
||||
|
||||
// Additional setup.
|
||||
debug("PrivateEngine::init");
|
||||
// Create debugger console. It requires GFX to be initialized
|
||||
Console *console = new Console(this);
|
||||
setDebugger(console);
|
||||
|
||||
// Your main even loop should be (invoked from) here.
|
||||
//debug("PrivateEngine::go: Hello, World!");
|
||||
// Additional setup.
|
||||
debug("PrivateEngine::init");
|
||||
|
||||
// This test will show up if -d1 and --debugflags=example are specified on the commandline
|
||||
//debugC(1, kPrivateDebugExample, "Example debug call");
|
||||
// Your main even loop should be (invoked from) here.
|
||||
//debug("PrivateEngine::go: Hello, World!");
|
||||
|
||||
// This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline
|
||||
//debugC(3, kPrivateDebugExample | kPrivateDebugExample2, "Example debug call two");
|
||||
// This test will show up if -d1 and --debugflags=example are specified on the commandline
|
||||
//debugC(1, kPrivateDebugExample, "Example debug call");
|
||||
|
||||
// Simple main event loop
|
||||
Common::Event event;
|
||||
Common::Point mousePos;
|
||||
_videoDecoder = nullptr; //new Video::SmackerDecoder();
|
||||
// This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline
|
||||
//debugC(3, kPrivateDebugExample | kPrivateDebugExample2, "Example debug call two");
|
||||
|
||||
_nextSetting = new Common::String("kGoIntro");
|
||||
// Simple main event loop
|
||||
Common::Event event;
|
||||
Common::Point mousePos;
|
||||
_videoDecoder = nullptr; //new Video::SmackerDecoder();
|
||||
|
||||
while (!shouldQuit()) {
|
||||
g_system->getEventManager()->pollEvent(event);
|
||||
mousePos = g_system->getEventManager()->getMousePos();
|
||||
|
||||
g_system->delayMillis(10);
|
||||
_nextSetting = new Common::String("kGoIntro");
|
||||
|
||||
// Events
|
||||
switch (event.type) {
|
||||
case Common::EVENT_QUIT:
|
||||
case Common::EVENT_RETURN_TO_LAUNCHER:
|
||||
break;
|
||||
while (!shouldQuit()) {
|
||||
g_system->getEventManager()->pollEvent(event);
|
||||
mousePos = g_system->getEventManager()->getMousePos();
|
||||
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
selectExit(mousePos);
|
||||
g_system->delayMillis(10);
|
||||
|
||||
}
|
||||
// Events
|
||||
switch (event.type) {
|
||||
case Common::EVENT_QUIT:
|
||||
case Common::EVENT_RETURN_TO_LAUNCHER:
|
||||
break;
|
||||
|
||||
// Movies
|
||||
if (_nextMovie != NULL) {
|
||||
_videoDecoder = new Video::SmackerDecoder();
|
||||
playVideo(*_nextMovie);
|
||||
_nextMovie = NULL;
|
||||
continue;
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
selectExit(mousePos);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (_videoDecoder) {
|
||||
stopSound();
|
||||
if (_videoDecoder->endOfVideo()) {
|
||||
_videoDecoder->close();
|
||||
delete _videoDecoder;
|
||||
_videoDecoder = nullptr;
|
||||
} else if (_videoDecoder->needsUpdate()) {
|
||||
drawScreen();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Movies
|
||||
if (_nextMovie != NULL) {
|
||||
_videoDecoder = new Video::SmackerDecoder();
|
||||
playVideo(*_nextMovie);
|
||||
_nextMovie = NULL;
|
||||
continue;
|
||||
|
||||
//if (_compositeSurface)
|
||||
// drawScreen();
|
||||
}
|
||||
|
||||
if (_nextSetting != NULL) {
|
||||
debug("Executing %s", _nextSetting->c_str());
|
||||
_exits.clear();
|
||||
loadSetting(_nextSetting);
|
||||
_nextSetting = NULL;
|
||||
CursorMan.showMouse(false);
|
||||
execute(prog);
|
||||
CursorMan.showMouse(true);
|
||||
if (_videoDecoder) {
|
||||
stopSound();
|
||||
if (_videoDecoder->endOfVideo()) {
|
||||
_videoDecoder->close();
|
||||
delete _videoDecoder;
|
||||
_videoDecoder = nullptr;
|
||||
} else if (_videoDecoder->needsUpdate()) {
|
||||
drawScreen();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//if (_compositeSurface)
|
||||
// drawScreen();
|
||||
|
||||
if (_nextSetting != NULL) {
|
||||
debug("Executing %s", _nextSetting->c_str());
|
||||
_exits.clear();
|
||||
loadSetting(_nextSetting);
|
||||
_nextSetting = NULL;
|
||||
CursorMan.showMouse(false);
|
||||
execute(prog);
|
||||
CursorMan.showMouse(true);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
g_system->updateScreen();
|
||||
|
||||
}
|
||||
g_system->updateScreen();
|
||||
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
void PrivateEngine::selectExit(Common::Point mousePos) {
|
||||
Common::String *ns = NULL;
|
||||
int rs = 1 << 31;
|
||||
int cs = 0;
|
||||
Common::String *ns = NULL;
|
||||
int rs = 1 << 31;
|
||||
int cs = 0;
|
||||
|
||||
for (ExitList::const_iterator it = _exits.begin(); it != _exits.end(); ++it) {
|
||||
const ExitInfo e = *it;
|
||||
cs = e.rect->width()*e.rect->height();
|
||||
if (e.rect->contains(mousePos)) {
|
||||
debug("Exit %s %d", e.nextSetting->c_str(), cs);
|
||||
if (cs < rs) {
|
||||
rs = cs;
|
||||
ns = e.nextSetting;
|
||||
}
|
||||
for (ExitList::const_iterator it = _exits.begin(); it != _exits.end(); ++it) {
|
||||
const ExitInfo e = *it;
|
||||
cs = e.rect->width()*e.rect->height();
|
||||
if (e.rect->contains(mousePos)) {
|
||||
debug("Exit %s %d", e.nextSetting->c_str(), cs);
|
||||
if (cs < rs) {
|
||||
rs = cs;
|
||||
ns = e.nextSetting;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (cs > 0)
|
||||
_nextSetting = ns;
|
||||
}
|
||||
if (cs > 0)
|
||||
_nextSetting = ns;
|
||||
}
|
||||
|
||||
|
||||
bool PrivateEngine::hasFeature(EngineFeature f) const {
|
||||
return
|
||||
(f == kSupportsReturnToLauncher) ||
|
||||
(f == kSupportsLoadingDuringRuntime) ||
|
||||
(f == kSupportsSavingDuringRuntime);
|
||||
return
|
||||
(f == kSupportsReturnToLauncher) ||
|
||||
(f == kSupportsLoadingDuringRuntime) ||
|
||||
(f == kSupportsSavingDuringRuntime);
|
||||
}
|
||||
|
||||
Common::Error PrivateEngine::loadGameStream(Common::SeekableReadStream *stream) {
|
||||
Common::Serializer s(stream, nullptr);
|
||||
syncGameStream(s);
|
||||
return Common::kNoError;
|
||||
Common::Serializer s(stream, nullptr);
|
||||
syncGameStream(s);
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
Common::Error PrivateEngine::saveGameStream(Common::WriteStream *stream, bool isAutosave) {
|
||||
Common::Serializer s(nullptr, stream);
|
||||
syncGameStream(s);
|
||||
return Common::kNoError;
|
||||
Common::Serializer s(nullptr, stream);
|
||||
syncGameStream(s);
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
void PrivateEngine::syncGameStream(Common::Serializer &s) {
|
||||
// Use methods of Serializer to save/load fields
|
||||
int dummy = 0;
|
||||
s.syncAsUint16LE(dummy);
|
||||
// Use methods of Serializer to save/load fields
|
||||
int dummy = 0;
|
||||
s.syncAsUint16LE(dummy);
|
||||
}
|
||||
|
||||
Common::String PrivateEngine::convertPath(Common::String name) {
|
||||
Common::String path(name);
|
||||
Common::String s1("\\");
|
||||
Common::String s2("/");
|
||||
|
||||
while (path.contains(s1))
|
||||
Common::replace(path, s1, s2);
|
||||
|
||||
s1 = Common::String("\"");
|
||||
s2 = Common::String("");
|
||||
Common::String path(name);
|
||||
Common::String s1("\\");
|
||||
Common::String s2("/");
|
||||
|
||||
while (path.contains(s1))
|
||||
Common::replace(path, s1, s2);
|
||||
Common::replace(path, s1, s2);
|
||||
|
||||
path.toLowercase();
|
||||
return path;
|
||||
|
||||
s1 = Common::String("\"");
|
||||
s2 = Common::String("");
|
||||
|
||||
Common::replace(path, s1, s2);
|
||||
Common::replace(path, s1, s2);
|
||||
|
||||
path.toLowercase();
|
||||
return path;
|
||||
}
|
||||
|
||||
void PrivateEngine::playSound(const Common::String &name) {
|
||||
debugC(1, kPrivateDebugExample, "%s : %s", __FUNCTION__, name.c_str());
|
||||
debugC(1, kPrivateDebugExample, "%s : %s", __FUNCTION__, name.c_str());
|
||||
|
||||
Common::File *file = new Common::File();
|
||||
Common::String path = convertPath(name);
|
||||
Common::File *file = new Common::File();
|
||||
Common::String path = convertPath(name);
|
||||
|
||||
if (!file->open(path))
|
||||
error("unable to find sound file %s", path.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);
|
||||
stopSound();
|
||||
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, stream, -1, Audio::Mixer::kMaxChannelVolume);
|
||||
Audio::AudioStream *stream;
|
||||
stream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
|
||||
stopSound();
|
||||
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, stream, -1, Audio::Mixer::kMaxChannelVolume);
|
||||
}
|
||||
|
||||
void PrivateEngine::playVideo(const Common::String &name) {
|
||||
debugC(1, kPrivateDebugExample, "%s : %s", __FUNCTION__, name.c_str());
|
||||
Common::File *file = new Common::File();
|
||||
Common::String path = convertPath(name);
|
||||
debugC(1, kPrivateDebugExample, "%s : %s", __FUNCTION__, name.c_str());
|
||||
Common::File *file = new Common::File();
|
||||
Common::String path = convertPath(name);
|
||||
|
||||
if (!file->open(path))
|
||||
error("unable to find video file %s", path.c_str());
|
||||
if (!file->open(path))
|
||||
error("unable to find video file %s", path.c_str());
|
||||
|
||||
if (!_videoDecoder->loadStream(file))
|
||||
error("unable to load video %s", path.c_str());
|
||||
_videoDecoder->start();
|
||||
if (!_videoDecoder->loadStream(file))
|
||||
error("unable to load video %s", path.c_str());
|
||||
_videoDecoder->start();
|
||||
|
||||
}
|
||||
|
||||
void PrivateEngine::stopSound() {
|
||||
debugC(3, kPrivateDebugExample, "%s", __FUNCTION__);
|
||||
if (_mixer->isSoundHandleActive(_soundHandle))
|
||||
_mixer->stopHandle(_soundHandle);
|
||||
debugC(3, kPrivateDebugExample, "%s", __FUNCTION__);
|
||||
if (_mixer->isSoundHandleActive(_soundHandle))
|
||||
_mixer->stopHandle(_soundHandle);
|
||||
}
|
||||
|
||||
void PrivateEngine::loadImage(const Common::String &name, int x, int y) {
|
||||
debugC(1, kPrivateDebugExample, "%s : %s", __FUNCTION__, name.c_str());
|
||||
Common::File file;
|
||||
Common::String path = convertPath(name);
|
||||
if (!file.open(path))
|
||||
error("unable to load image %s", path.c_str());
|
||||
debugC(1, kPrivateDebugExample, "%s : %s", __FUNCTION__, name.c_str());
|
||||
Common::File file;
|
||||
Common::String path = convertPath(name);
|
||||
if (!file.open(path))
|
||||
error("unable to load image %s", path.c_str());
|
||||
|
||||
_image->loadStream(file);
|
||||
//debug("palette %d %d", _image->getPaletteStartIndex(), _image->getPaletteColorCount());
|
||||
//for (int i = 0; i < 30; i=i+3)
|
||||
// debug("%x %x %x", *(_image->getPalette()+i), *(_image->getPalette()+i+1), *(_image->getPalette()+i+2));
|
||||
_image->loadStream(file);
|
||||
//debug("palette %d %d", _image->getPaletteStartIndex(), _image->getPaletteColorCount());
|
||||
//for (int i = 0; i < 30; i=i+3)
|
||||
// debug("%x %x %x", *(_image->getPalette()+i), *(_image->getPalette()+i+1), *(_image->getPalette()+i+2));
|
||||
|
||||
_compositeSurface->transBlitFrom(*_image->getSurface()->convertTo(_pixelFormat, _image->getPalette()), Common::Point(x,y), _pixelFormat.RGBToColor(0,255,0));
|
||||
drawScreen();
|
||||
_compositeSurface->transBlitFrom(*_image->getSurface()->convertTo(_pixelFormat, _image->getPalette()), Common::Point(x,y), _pixelFormat.RGBToColor(0,255,0));
|
||||
drawScreen();
|
||||
}
|
||||
|
||||
|
||||
void PrivateEngine::drawScreen() {
|
||||
if (_videoDecoder ? _videoDecoder->needsUpdate() : false || _compositeSurface) {
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
//screen->fillRect(Common::Rect(0, 0, g_system->getWidth(), g_system->getHeight()), 0);
|
||||
if (_videoDecoder ? _videoDecoder->needsUpdate() : false || _compositeSurface) {
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
//screen->fillRect(Common::Rect(0, 0, g_system->getWidth(), g_system->getHeight()), 0);
|
||||
|
||||
Graphics::ManagedSurface *surface = _compositeSurface;
|
||||
Graphics::ManagedSurface *surface = _compositeSurface;
|
||||
|
||||
if (_videoDecoder) {
|
||||
Graphics::Surface *frame = new Graphics::Surface;
|
||||
frame->create(_screenW, _screenH, _pixelFormat);
|
||||
frame->copyFrom(*_videoDecoder->decodeNextFrame());
|
||||
surface->transBlitFrom(*frame->convertTo(_pixelFormat, _videoDecoder->getPalette()));
|
||||
}
|
||||
if (_videoDecoder) {
|
||||
Graphics::Surface *frame = new Graphics::Surface;
|
||||
frame->create(_screenW, _screenH, _pixelFormat);
|
||||
frame->copyFrom(*_videoDecoder->decodeNextFrame());
|
||||
surface->transBlitFrom(*frame->convertTo(_pixelFormat, _videoDecoder->getPalette()));
|
||||
}
|
||||
|
||||
int w = surface->w; //CLIP<int>(surface->w, 0, _screenW);
|
||||
int h = surface->h; //CLIP<int>(surface->h, 0, _screenH);
|
||||
assert(w == _screenW && h == _screenH);
|
||||
int w = surface->w; //CLIP<int>(surface->w, 0, _screenW);
|
||||
int h = surface->h; //CLIP<int>(surface->h, 0, _screenH);
|
||||
assert(w == _screenW && h == _screenH);
|
||||
|
||||
screen->copyRectToSurface(*surface, 0, 0, Common::Rect(0, 0, _screenW, _screenH));
|
||||
screen->copyRectToSurface(*surface, 0, 0, Common::Rect(0, 0, _screenW, _screenH));
|
||||
|
||||
g_system->unlockScreen();
|
||||
//if (_image->getPalette() != nullptr)
|
||||
// g_system->getPaletteManager()->setPalette(_image->getPalette(), _image->getPaletteStartIndex(), _image->getPaletteColorCount());
|
||||
//if (_image->getPalette() != nullptr)
|
||||
// g_system->getPaletteManager()->setPalette(_image->getPalette(), 0, 256);
|
||||
//g_system->getPaletteManager()->setPalette(_videoDecoder->getPalette(), 0, 256);
|
||||
g_system->updateScreen();
|
||||
}
|
||||
g_system->unlockScreen();
|
||||
//if (_image->getPalette() != nullptr)
|
||||
// g_system->getPaletteManager()->setPalette(_image->getPalette(), _image->getPaletteStartIndex(), _image->getPaletteColorCount());
|
||||
//if (_image->getPalette() != nullptr)
|
||||
// g_system->getPaletteManager()->setPalette(_image->getPalette(), 0, 256);
|
||||
//g_system->getPaletteManager()->setPalette(_videoDecoder->getPalette(), 0, 256);
|
||||
g_system->updateScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,63 +10,63 @@ StringQueue stringToDefine;
|
||||
RectQueue rectToDefine;
|
||||
|
||||
void define(char *n, Common::Rect *r) {
|
||||
Common::String *s = new Common::String(n);
|
||||
stringToDefine.push(*s);
|
||||
rectToDefine.push(r);
|
||||
Common::String *s = new Common::String(n);
|
||||
stringToDefine.push(*s);
|
||||
rectToDefine.push(r);
|
||||
}
|
||||
|
||||
char *emalloc(unsigned n) /* check return from malloc */
|
||||
{
|
||||
char *p;
|
||||
char *p;
|
||||
|
||||
p = (char*) malloc(n);
|
||||
assert(p != NULL);
|
||||
return p;
|
||||
p = (char*) malloc(n);
|
||||
assert(p != NULL);
|
||||
return p;
|
||||
}
|
||||
|
||||
void showSymbol(Symbol *s)
|
||||
{
|
||||
if (s->type == NUM)
|
||||
debug("%s %d",s->name->c_str(), s->u.val);
|
||||
else if (s->type == STRING)
|
||||
debug("%s %s", s->name->c_str(), s->u.str);
|
||||
else if (s->type == NAME)
|
||||
debug("%s",s->name->c_str());
|
||||
else
|
||||
debug("%s %d", s->name->c_str(), s->type);
|
||||
if (s->type == NUM)
|
||||
debug("%s %d",s->name->c_str(), s->u.val);
|
||||
else if (s->type == STRING)
|
||||
debug("%s %s", s->name->c_str(), s->u.str);
|
||||
else if (s->type == NAME)
|
||||
debug("%s",s->name->c_str());
|
||||
else
|
||||
debug("%s %d", s->name->c_str(), s->type);
|
||||
}
|
||||
|
||||
|
||||
Symbol *lookup(Common::String s, SymbolMap symlist) /* find s in symbol table symlist */
|
||||
{
|
||||
//debug("looking up %s", s.c_str());
|
||||
return symlist.getVal(s);
|
||||
//debug("looking up %s", s.c_str());
|
||||
return symlist.getVal(s);
|
||||
}
|
||||
|
||||
Symbol *lookupName(char *n) /* install s in some symbol table */
|
||||
{
|
||||
//debug("looking up %s", n);
|
||||
Common::String *s = new Common::String(n);
|
||||
|
||||
if (settings.contains(*s))
|
||||
return lookup(*s, settings);
|
||||
//debug("looking up %s", n);
|
||||
Common::String *s = new Common::String(n);
|
||||
|
||||
else if (variables.contains(*s))
|
||||
return lookup(*s, variables);
|
||||
if (settings.contains(*s))
|
||||
return lookup(*s, settings);
|
||||
|
||||
else if (cursors.contains(*s))
|
||||
return lookup(*s, cursors);
|
||||
else if (variables.contains(*s))
|
||||
return lookup(*s, variables);
|
||||
|
||||
else if (locations.contains(*s))
|
||||
return lookup(*s, locations);
|
||||
else if (cursors.contains(*s))
|
||||
return lookup(*s, cursors);
|
||||
|
||||
else if (rects.contains(*s))
|
||||
return lookup(*s, rects);
|
||||
else if (locations.contains(*s))
|
||||
return lookup(*s, locations);
|
||||
|
||||
else {
|
||||
debug("WARNING: %s not defined", n);
|
||||
return addconstant(NAME, 0, n);
|
||||
}
|
||||
else if (rects.contains(*s))
|
||||
return lookup(*s, rects);
|
||||
|
||||
else {
|
||||
debug("WARNING: %s not defined", n);
|
||||
return addconstant(NAME, 0, n);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -74,88 +74,88 @@ Symbol *lookupName(char *n) /* install s in some symbol table */
|
||||
|
||||
|
||||
void installall(char *n) {
|
||||
Common::String *s;
|
||||
Common::Rect *r;
|
||||
Common::String *s;
|
||||
Common::Rect *r;
|
||||
|
||||
assert(stringToDefine.size() > 0);
|
||||
assert(stringToDefine.size() > 0);
|
||||
|
||||
while (!stringToDefine.empty()) {
|
||||
s = new Common::String(stringToDefine.pop());
|
||||
r = rectToDefine.pop();
|
||||
while (!stringToDefine.empty()) {
|
||||
s = new Common::String(stringToDefine.pop());
|
||||
r = rectToDefine.pop();
|
||||
|
||||
//debug("name %s", s->c_str());
|
||||
if (strcmp(n, "settings") == 0) {
|
||||
assert(r == NULL);
|
||||
install(s, STRING, 0, (char*) s->c_str(), r, &settings);
|
||||
}
|
||||
//debug("name %s", s->c_str());
|
||||
if (strcmp(n, "settings") == 0) {
|
||||
assert(r == NULL);
|
||||
install(s, STRING, 0, (char*) s->c_str(), r, &settings);
|
||||
}
|
||||
|
||||
else if (strcmp(n, "variables") == 0) {
|
||||
assert(r == NULL);
|
||||
install(s, NAME, 0, NULL, r, &variables);
|
||||
}
|
||||
else if (strcmp(n, "variables") == 0) {
|
||||
assert(r == NULL);
|
||||
install(s, NAME, 0, NULL, r, &variables);
|
||||
}
|
||||
|
||||
else if (strcmp(n, "cursors") == 0) {
|
||||
assert(r == NULL);
|
||||
install(s, NAME, 0, NULL, r, &cursors);
|
||||
}
|
||||
else if (strcmp(n, "cursors") == 0) {
|
||||
assert(r == NULL);
|
||||
install(s, NAME, 0, NULL, r, &cursors);
|
||||
}
|
||||
|
||||
else if (strcmp(n, "locations") == 0) {
|
||||
assert(r == NULL);
|
||||
install(s, NAME, 0, NULL, r, &locations);
|
||||
}
|
||||
else if (strcmp(n, "locations") == 0) {
|
||||
assert(r == NULL);
|
||||
install(s, NAME, 0, NULL, r, &locations);
|
||||
}
|
||||
|
||||
else if (strcmp(n, "rects") == 0) {
|
||||
assert(r != NULL);
|
||||
install(s, NAME, 0, NULL, r, &rects);
|
||||
}
|
||||
else
|
||||
assert(0);
|
||||
else if (strcmp(n, "rects") == 0) {
|
||||
assert(r != NULL);
|
||||
install(s, NAME, 0, NULL, r, &rects);
|
||||
}
|
||||
else
|
||||
assert(0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Symbol *addconstant(int t, int d, char *s)
|
||||
Symbol *addconstant(int t, int d, char *s)
|
||||
{
|
||||
Symbol *sp;
|
||||
Common::String *n = new Common::String("<constant>");
|
||||
Symbol *sp;
|
||||
Common::String *n = new Common::String("<constant>");
|
||||
|
||||
sp = (Symbol *) emalloc(sizeof(Symbol));
|
||||
sp->name = n;
|
||||
sp->type = t;
|
||||
if (t == NUM || t == NAME)
|
||||
sp->u.val = d;
|
||||
else if (t == STRING)
|
||||
sp->u.str = s;
|
||||
else
|
||||
assert(0);
|
||||
sp = (Symbol *) emalloc(sizeof(Symbol));
|
||||
sp->name = n;
|
||||
sp->type = t;
|
||||
if (t == NUM || t == NAME)
|
||||
sp->u.val = d;
|
||||
else if (t == STRING)
|
||||
sp->u.str = s;
|
||||
else
|
||||
assert(0);
|
||||
|
||||
constants.push_front(sp);
|
||||
return sp;
|
||||
constants.push_front(sp);
|
||||
return sp;
|
||||
}
|
||||
|
||||
|
||||
Symbol *install(Common::String *n, int t, int d, char *s, Common::Rect *r, SymbolMap *symlist) /* install s in symbol table */
|
||||
{
|
||||
Common::String *name = new Common::String(*n);
|
||||
|
||||
Symbol *sp;
|
||||
Common::String *name = new Common::String(*n);
|
||||
|
||||
sp = (Symbol *) emalloc(sizeof(Symbol));
|
||||
sp->name = name;
|
||||
sp->type = t;
|
||||
if (t == NUM || t == NAME)
|
||||
sp->u.val = d;
|
||||
else if (t == STRING)
|
||||
sp->u.str = s;
|
||||
else if (t == RECT)
|
||||
sp->u.rect = r;
|
||||
else
|
||||
assert(0);
|
||||
Symbol *sp;
|
||||
|
||||
symlist->setVal(*n, sp);
|
||||
assert(symlist->size() > 0);
|
||||
return sp;
|
||||
sp = (Symbol *) emalloc(sizeof(Symbol));
|
||||
sp->name = name;
|
||||
sp->type = t;
|
||||
if (t == NUM || t == NAME)
|
||||
sp->u.val = d;
|
||||
else if (t == STRING)
|
||||
sp->u.str = s;
|
||||
else if (t == RECT)
|
||||
sp->u.rect = r;
|
||||
else
|
||||
assert(0);
|
||||
|
||||
symlist->setVal(*n, sp);
|
||||
assert(symlist->size() > 0);
|
||||
return sp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user