2014-05-05 16:59:17 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on original Sfinx source code
|
|
|
|
* Copyright (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sound.h"
|
|
|
|
#include "cge2/cge2_main.h"
|
|
|
|
#include "cge2/cge2.h"
|
|
|
|
#include "cge2/vga13h.h"
|
|
|
|
#include "cge2/text.h"
|
2014-05-08 12:32:51 +00:00
|
|
|
#include "cge2/snail.h"
|
2014-05-08 17:23:36 +00:00
|
|
|
#include "cge2/hero.h"
|
2014-05-05 16:59:17 +00:00
|
|
|
|
|
|
|
namespace CGE2 {
|
|
|
|
|
2014-05-08 12:32:51 +00:00
|
|
|
void CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos) {
|
|
|
|
int shpcnt = 0;
|
|
|
|
int seqcnt = 0;
|
|
|
|
int cnt[kActions];
|
2014-05-08 17:23:36 +00:00
|
|
|
for (int i = 0; i < kActions; i++)
|
|
|
|
cnt[i] = 0;
|
|
|
|
int section = kIdPhase;
|
2014-05-08 12:32:51 +00:00
|
|
|
bool frnt = true;
|
|
|
|
bool east = false;
|
|
|
|
bool port = false;
|
|
|
|
bool tran = false;
|
2014-05-08 17:23:36 +00:00
|
|
|
Hero *h;
|
|
|
|
|
|
|
|
char tmpStr[kLineMax];
|
|
|
|
mergeExt(tmpStr, fname, kSprExt);
|
|
|
|
|
|
|
|
if (_resman->exist(tmpStr)) { // sprite description file exist
|
|
|
|
EncryptedStream sprf(this, tmpStr);
|
|
|
|
if (sprf.err())
|
|
|
|
error("Bad SPR [%s]", tmpStr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-08 12:32:51 +00:00
|
|
|
warning("STUB: CGE2Engine::loadSprite()");
|
2014-05-06 19:02:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGE2Engine::loadScript(const char *fname) {
|
|
|
|
EncryptedStream scrf(this, fname);
|
|
|
|
|
|
|
|
if (scrf.err())
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
int lcnt = 0;
|
|
|
|
|
|
|
|
char tmpStr[kLineMax + 1];
|
|
|
|
Common::String line;
|
|
|
|
|
|
|
|
for (line = scrf.readLine(); !scrf.eos(); line = scrf.readLine()) {
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
lcnt++;
|
|
|
|
Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr));
|
|
|
|
if ((line.size() == 0) || (*tmpStr == ';')) // Comments start with ';' - don't bother with them.
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ok = false; // not OK if break
|
|
|
|
|
2014-05-08 12:32:51 +00:00
|
|
|
V3D P;
|
|
|
|
|
2014-05-06 19:02:58 +00:00
|
|
|
// sprite ident number
|
2014-05-08 08:45:38 +00:00
|
|
|
if ((p = EncryptedStream::token(tmpStr)) == NULL)
|
2014-05-06 19:02:58 +00:00
|
|
|
break;
|
2014-05-08 08:45:38 +00:00
|
|
|
int SpI = EncryptedStream::number(p);
|
2014-05-06 19:02:58 +00:00
|
|
|
|
|
|
|
// sprite file name
|
|
|
|
char *SpN;
|
2014-05-08 11:43:02 +00:00
|
|
|
if ((SpN = EncryptedStream::token(nullptr)) == NULL)
|
2014-05-06 19:02:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// sprite scene
|
2014-05-08 11:43:02 +00:00
|
|
|
if ((p = EncryptedStream::token(nullptr)) == NULL)
|
2014-05-06 19:02:58 +00:00
|
|
|
break;
|
2014-05-08 08:45:38 +00:00
|
|
|
int SpA = EncryptedStream::number(p);
|
2014-05-06 19:02:58 +00:00
|
|
|
|
|
|
|
// sprite column
|
2014-05-08 11:43:02 +00:00
|
|
|
if ((p = EncryptedStream::token(nullptr)) == NULL)
|
2014-05-06 19:02:58 +00:00
|
|
|
break;
|
2014-05-08 12:32:51 +00:00
|
|
|
P._x = EncryptedStream::number(p);
|
2014-05-06 19:02:58 +00:00
|
|
|
|
|
|
|
// sprite row
|
2014-05-08 11:43:02 +00:00
|
|
|
if ((p = EncryptedStream::token(nullptr)) == NULL)
|
2014-05-06 19:02:58 +00:00
|
|
|
break;
|
2014-05-08 12:32:51 +00:00
|
|
|
P._y = EncryptedStream::number(p);
|
2014-05-06 19:02:58 +00:00
|
|
|
|
|
|
|
// sprite Z pos
|
2014-05-08 11:43:02 +00:00
|
|
|
if ((p = EncryptedStream::token(nullptr)) == NULL)
|
2014-05-06 19:02:58 +00:00
|
|
|
break;
|
2014-05-08 12:32:51 +00:00
|
|
|
P._z = EncryptedStream::number(p);
|
2014-05-06 19:02:58 +00:00
|
|
|
|
|
|
|
// sprite life
|
2014-05-08 11:43:02 +00:00
|
|
|
if ((p = EncryptedStream::token(nullptr)) == NULL)
|
2014-05-06 19:02:58 +00:00
|
|
|
break;
|
2014-05-08 08:45:38 +00:00
|
|
|
bool BkG = EncryptedStream::number(p) == 0;
|
2014-05-06 19:02:58 +00:00
|
|
|
|
|
|
|
ok = true; // no break: OK
|
|
|
|
|
|
|
|
_sprite = NULL;
|
2014-05-08 12:32:51 +00:00
|
|
|
loadSprite(SpN, SpI, SpA, P);
|
2014-05-06 19:02:58 +00:00
|
|
|
if (_sprite) {
|
|
|
|
warning("STUB: CGE2Engine::loadScript - SPARE:: thing");
|
|
|
|
if (BkG)
|
|
|
|
_sprite->_flags._back = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
2014-05-08 17:23:36 +00:00
|
|
|
error("Bad INI line %d [%s]", scrf.getLineCount(), fname);
|
2014-05-06 19:02:58 +00:00
|
|
|
}
|
|
|
|
|
2014-05-05 16:59:17 +00:00
|
|
|
void CGE2Engine::movie(const char *ext) {
|
2014-05-06 19:02:58 +00:00
|
|
|
assert(ext);
|
|
|
|
|
|
|
|
if (_quitFlag)
|
|
|
|
return;
|
|
|
|
|
|
|
|
char fn[12];
|
|
|
|
sprintf(fn, "CGE.%s", (*ext == '.') ? ext + 1 : ext);
|
|
|
|
|
|
|
|
if (_resman->exist(fn)) {
|
|
|
|
int now = _now;
|
|
|
|
_now = atoi(ext + 1);
|
|
|
|
loadScript(fn);
|
|
|
|
|
2014-05-08 08:45:38 +00:00
|
|
|
warning("STUB: CGE2Engine::movie()");
|
2014-05-06 19:02:58 +00:00
|
|
|
|
|
|
|
_now = now;
|
|
|
|
}
|
2014-05-05 16:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGE2Engine::runGame() {
|
|
|
|
warning("STUB: CGE2Engine::runGame()");
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGE2Engine::cge2_main() {
|
|
|
|
warning("STUB: CGE2Engine::cge2_main()");
|
|
|
|
|
|
|
|
_mode++;
|
|
|
|
|
|
|
|
if (showTitle("WELCOME")) {
|
|
|
|
if (_mode == 1)
|
|
|
|
movie(kIntroExt);
|
|
|
|
if (_text->getText(255) != NULL) {
|
|
|
|
runGame();
|
|
|
|
_startupMode = 2;
|
|
|
|
} else
|
|
|
|
_vga->sunset();
|
|
|
|
} else
|
|
|
|
_vga->sunset();
|
|
|
|
}
|
|
|
|
|
|
|
|
char *CGE2Engine::mergeExt(char *buf, const char *name, const char *ext) {
|
|
|
|
strcpy(buf, name);
|
|
|
|
char *dot = strrchr(buf, '.');
|
|
|
|
if (!dot)
|
|
|
|
strcat(buf, ext);
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace CGE2
|