PRIVATE: more code
This commit is contained in:
parent
942addd3a1
commit
89f95256e7
5 changed files with 188 additions and 109 deletions
|
@ -162,6 +162,7 @@ int eval() {
|
|||
} else if (d.u.sym->type == STRING) {
|
||||
d.type = STRING;
|
||||
d.u.str = d.u.sym->u.str;
|
||||
debug("eval returned %s", d.u.str );
|
||||
} else if (d.u.sym->type == RECT) {
|
||||
d.type = RECT;
|
||||
d.u.rect = d.u.sym->u.rect;
|
||||
|
|
|
@ -16,14 +16,12 @@ void ChgMode(ArgArray args) {
|
|||
g_private->_nextSetting = s;
|
||||
|
||||
if (g_private->_mode == 0) {
|
||||
g_private->_origin->x = 0;
|
||||
g_private->_origin->x = 0; // use a constant
|
||||
g_private->_origin->y = 0;
|
||||
// TODO: should clear the screen?
|
||||
}
|
||||
else if (g_private->_mode == 1) {
|
||||
g_private->_origin->x = 64;
|
||||
g_private->_origin->x = 64; // use a constant
|
||||
g_private->_origin->y = 48;
|
||||
//g_private->drawScreenFrame();
|
||||
}
|
||||
else
|
||||
assert(0);
|
||||
|
@ -44,11 +42,19 @@ void Goto(ArgArray args) { // should be goto, but this is a reserved word
|
|||
}
|
||||
|
||||
|
||||
void SyncSound(ArgArray args) { // should be goto, but this is a reserved word
|
||||
void SyncSound(ArgArray args) {
|
||||
// assert types
|
||||
debug("SyncSound(%s, %s)", args[0].u.str, args[1].u.str);
|
||||
Common::String *s = new Common::String(args[1].u.str);
|
||||
g_private->_nextSetting = s;
|
||||
|
||||
if (strcmp("\"\"", args[0].u.str) != 0) {
|
||||
Common::String *s = new Common::String(args[0].u.str);
|
||||
g_private->playSound(*s, 1);
|
||||
//assert(0);
|
||||
} else {
|
||||
g_private->stopSound();
|
||||
}
|
||||
}
|
||||
|
||||
void Quit(ArgArray args) {
|
||||
|
@ -63,7 +69,10 @@ void LoadGame(ArgArray args) {
|
|||
MaskInfo *m = (MaskInfo*) malloc(sizeof(MaskInfo));
|
||||
m->surf = g_private->loadMask(*s, 0, 0, true);
|
||||
m->cursor = args[2].u.sym->name;
|
||||
m->nextSetting = NULL;
|
||||
m->flag = NULL;
|
||||
g_private->_loadGameMask = m;
|
||||
g_private->_masks.push_front(*m);
|
||||
}
|
||||
|
||||
void SaveGame(ArgArray args) {
|
||||
|
@ -73,12 +82,16 @@ void SaveGame(ArgArray args) {
|
|||
MaskInfo *m = (MaskInfo*) malloc(sizeof(MaskInfo));
|
||||
m->surf = g_private->loadMask(*s, 0, 0, true);
|
||||
m->cursor = args[1].u.sym->name;
|
||||
m->nextSetting = NULL;
|
||||
m->flag = NULL;
|
||||
g_private->_saveGameMask = m;
|
||||
g_private->_masks.push_front(*m);
|
||||
}
|
||||
|
||||
void RestartGame(ArgArray args) {
|
||||
// assert types
|
||||
debug("WARNING: RestartGame is not implemented");
|
||||
g_private->restartGame();
|
||||
//debug("WARNING: RestartGame is not implemented");
|
||||
}
|
||||
|
||||
void PoliceBust(ArgArray args) {
|
||||
|
@ -307,14 +320,20 @@ void MaskDrawn(ArgArray args) {
|
|||
_Mask(args, true);
|
||||
}
|
||||
|
||||
void AddSound(char *s, char *t) {
|
||||
Common::String str(t);
|
||||
void AddSound(char *s, char *t, Symbol *flag = NULL, int val = 0) {
|
||||
Common::String *sound = new Common::String(s);
|
||||
if (strcmp(t, "AMRadioClip") == 0)
|
||||
g_private->_radio.push_front(str);
|
||||
g_private->_AMRadio.push_front(*sound);
|
||||
else if (strcmp(t, "PoliceClip") == 0)
|
||||
g_private->_police.push_front(str);
|
||||
else if (strcmp(t, "PhoneClip") == 0)
|
||||
g_private->_phone.push_front(str);
|
||||
g_private->_policeRadio.push_front(*sound);
|
||||
else if (strcmp(t, "PhoneClip") == 0) {
|
||||
PhoneInfo *p = (PhoneInfo*) malloc(sizeof(PhoneInfo));
|
||||
p->sound = sound;
|
||||
p->flag = flag;
|
||||
p->val = val;
|
||||
g_private->_phone.push_front(*p);
|
||||
}
|
||||
|
||||
else
|
||||
debug("error: invalid sound type %s", t);
|
||||
}
|
||||
|
@ -326,12 +345,45 @@ void PoliceClip(ArgArray args) {
|
|||
AddSound(args[0].u.str, "PoliceClip");
|
||||
}
|
||||
void PhoneClip(ArgArray args) {
|
||||
AddSound(args[0].u.str, "PhoneClip");
|
||||
if (args.size() == 2) {
|
||||
debug("Unimplemented PhoneClip special case");
|
||||
return;
|
||||
}
|
||||
AddSound(args[0].u.str, "PhoneClip", args[5].u.sym, args[6].u.val);
|
||||
}
|
||||
|
||||
void SoundArea(ArgArray args) {
|
||||
// assert types
|
||||
debug("WARNING: SoundArea not implemented!");
|
||||
char *n;
|
||||
|
||||
if (args[1].type == NAME)
|
||||
n = (char *) args[1].u.sym->name->c_str();
|
||||
else if (args[1].type == STRING)
|
||||
n = args[1].u.str;
|
||||
else
|
||||
assert(0);
|
||||
|
||||
debug("SoundArea(%s, %s)", args[0].u.str, n);
|
||||
if (strcmp(n, "kAMRadio") == 0) {
|
||||
Common::String *s = new Common::String(args[0].u.str);
|
||||
MaskInfo *m = (MaskInfo*) malloc(sizeof(MaskInfo));
|
||||
m->surf = g_private->loadMask(*s, 0, 0, true);
|
||||
m->cursor = args[2].u.sym->name;
|
||||
m->nextSetting = NULL;
|
||||
m->flag = NULL;
|
||||
g_private->_AMRadioArea = m;
|
||||
g_private->_masks.push_front(*m);
|
||||
} else if (strcmp(n, "kPoliceRadio") == 0) {
|
||||
Common::String *s = new Common::String(args[0].u.str);
|
||||
MaskInfo *m = (MaskInfo*) malloc(sizeof(MaskInfo));
|
||||
m->surf = g_private->loadMask(*s, 0, 0, true);
|
||||
debug("size %d %d", m->surf->h, m->surf->w);
|
||||
m->cursor = args[2].u.sym->name;
|
||||
m->nextSetting = NULL;
|
||||
m->flag = NULL;
|
||||
g_private->_policeRadioArea = m;
|
||||
g_private->_masks.push_front(*m);
|
||||
}
|
||||
}
|
||||
|
||||
void AskSave(ArgArray args) {
|
||||
|
|
|
@ -57,10 +57,19 @@ PrivateEngine::PrivateEngine(OSystem *syst)
|
|||
|
||||
_nextSetting = NULL;
|
||||
_nextMovie = NULL;
|
||||
_nextVS = NULL;
|
||||
_modified = false;
|
||||
_mode = -1;
|
||||
_frame = new Common::String("inface/general/inface2.bmp");
|
||||
|
||||
_policeRadioArea = NULL;
|
||||
_AMRadioArea = NULL;
|
||||
_phoneArea = NULL;
|
||||
|
||||
_AMRadioPrefix = new Common::String("inface/radio/comm_/");
|
||||
_policeRadioPrefix = new Common::String("inface/radio/police/");
|
||||
_phonePrefix = new Common::String("inface/telephon/");
|
||||
_phoneCallSound = new Common::String("phone.wav");
|
||||
|
||||
}
|
||||
|
||||
|
@ -83,11 +92,16 @@ Common::Error PrivateEngine::run() {
|
|||
assert(_installerArchive.open("SUPPORT/ASSETS.Z"));
|
||||
Common::SeekableReadStream *file = NULL;
|
||||
|
||||
if (_installerArchive.hasFile("GAME.DAT")) // if the full game is used
|
||||
// if the full game is used
|
||||
if (_installerArchive.hasFile("GAME.DAT"))
|
||||
file = _installerArchive.createReadStreamForMember("GAME.DAT");
|
||||
else if (_installerArchive.hasFile("GAME.TXT")) // if the archive.org demo is used
|
||||
|
||||
// if the demo from archive.org is used
|
||||
else if (_installerArchive.hasFile("GAME.TXT"))
|
||||
file = _installerArchive.createReadStreamForMember("GAME.TXT");
|
||||
else if (_installerArchive.hasFile("DEMOGAME.DAT")) // if full retail CDROM demo is used
|
||||
|
||||
// if the demo from the full retail CDROM is used
|
||||
else if (_installerArchive.hasFile("DEMOGAME.DAT"))
|
||||
file = _installerArchive.createReadStreamForMember("DEMOGAME.DAT");
|
||||
|
||||
assert(file != NULL);
|
||||
|
@ -124,15 +138,6 @@ Common::Error PrivateEngine::run() {
|
|||
// Additional setup.
|
||||
debug("PrivateEngine::init");
|
||||
|
||||
// Your main even loop should be (invoked from) here.
|
||||
//debug("PrivateEngine::go: Hello, World!");
|
||||
|
||||
// This test will show up if -d1 and --debugflags=example are specified on the commandline
|
||||
//debugC(1, kPrivateDebugExample, "Example debug call");
|
||||
|
||||
// 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");
|
||||
|
||||
// Simple main event loop
|
||||
Common::Event event;
|
||||
Common::Point mousePos;
|
||||
|
@ -160,6 +165,8 @@ Common::Error PrivateEngine::run() {
|
|||
break;
|
||||
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
selectPoliceRadioArea(mousePos);
|
||||
selectAMRadioArea(mousePos);
|
||||
selectLoadGame(mousePos);
|
||||
selectSaveGame(mousePos);
|
||||
selectMask(mousePos);
|
||||
|
@ -169,10 +176,7 @@ Common::Error PrivateEngine::run() {
|
|||
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
changeCursor("default");
|
||||
|
||||
if (cursorLoadGame(mousePos)) {}
|
||||
else if (cursorSaveGame(mousePos)) {}
|
||||
else if (cursorMask(mousePos)) {}
|
||||
if (cursorMask(mousePos)) {}
|
||||
else if (cursorExit(mousePos)) {}
|
||||
//
|
||||
break;
|
||||
|
@ -192,6 +196,11 @@ Common::Error PrivateEngine::run() {
|
|||
|
||||
}
|
||||
|
||||
if (_nextVS != NULL) {
|
||||
loadImage(*_nextVS, 160, 120, true);
|
||||
_nextVS = NULL;
|
||||
}
|
||||
|
||||
if (_videoDecoder) {
|
||||
|
||||
stopSound();
|
||||
|
@ -256,24 +265,31 @@ bool PrivateEngine::cursorExit(Common::Point mousePos) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool PrivateEngine::cursorMask(Common::Point mousePos) {
|
||||
//debug("Mousepos %d %d", mousePos.x, mousePos.y);
|
||||
bool PrivateEngine::inMask(Graphics::ManagedSurface *surf, Common::Point mousePos) {
|
||||
if (surf == NULL)
|
||||
return false;
|
||||
|
||||
mousePos = mousePos - *_origin;
|
||||
if (mousePos.x < 0 || mousePos.y < 0)
|
||||
return false;
|
||||
|
||||
if (mousePos.x > surf->w || mousePos.y > surf->h)
|
||||
return false;
|
||||
|
||||
return ( *((uint32*) surf->getBasePtr(mousePos.x, mousePos.y)) != _transparentColor);
|
||||
}
|
||||
|
||||
|
||||
bool PrivateEngine::cursorMask(Common::Point mousePos) {
|
||||
//debug("Mousepos %d %d", mousePos.x, mousePos.y);
|
||||
MaskInfo m;
|
||||
bool inside = false;
|
||||
for (MaskList::iterator it = _masks.begin(); it != _masks.end(); ++it) {
|
||||
m = *it;
|
||||
|
||||
if (mousePos.x > m.surf->h || mousePos.y > m.surf->w)
|
||||
continue;
|
||||
|
||||
//debug("Testing mask %s", m.nextSetting->c_str());
|
||||
if ( *((uint32*) m.surf->getBasePtr(mousePos.x, mousePos.y)) != _transparentColor) {
|
||||
if (inMask(m.surf, mousePos)) {
|
||||
//debug("Inside!");
|
||||
if (m.nextSetting != NULL) { // TODO: check this
|
||||
if (m.cursor != NULL) { // TODO: check this
|
||||
inside = true;
|
||||
//debug("Rendering cursor mask %s", m.cursor->c_str());
|
||||
changeCursor(*m.cursor);
|
||||
|
@ -316,18 +332,13 @@ void PrivateEngine::selectExit(Common::Point mousePos) {
|
|||
}
|
||||
|
||||
void PrivateEngine::selectMask(Common::Point mousePos) {
|
||||
//debug("Mousepos %d %d", mousePos.x, mousePos.y);
|
||||
mousePos = mousePos - *_origin;
|
||||
if (mousePos.x < 0 || mousePos.y < 0)
|
||||
return;
|
||||
|
||||
Common::String *ns = NULL;
|
||||
MaskInfo m;
|
||||
for (MaskList::iterator it = _masks.begin(); it != _masks.end(); ++it) {
|
||||
m = *it;
|
||||
|
||||
//debug("Testing mask %s", m.nextSetting->c_str());
|
||||
if ( *((uint32*) m.surf->getBasePtr(mousePos.x, mousePos.y)) != _transparentColor) {
|
||||
if (inMask(m.surf, mousePos)) {
|
||||
//debug("Inside!");
|
||||
if (m.nextSetting != NULL) { // TODO: check this
|
||||
//debug("Found Mask %s", m.nextSetting->c_str());
|
||||
|
@ -348,79 +359,72 @@ void PrivateEngine::selectMask(Common::Point mousePos) {
|
|||
}
|
||||
}
|
||||
|
||||
void PrivateEngine::selectAMRadioArea(Common::Point mousePos) {
|
||||
if (_AMRadioArea == NULL)
|
||||
return;
|
||||
|
||||
if (_AMRadio.empty())
|
||||
return;
|
||||
|
||||
debug("AMRadio");
|
||||
if (inMask(_AMRadioArea->surf, mousePos)) {
|
||||
Common::String sound = *_AMRadioPrefix + _AMRadio.back() + ".wav";
|
||||
playSound(sound.c_str(), 1);
|
||||
_AMRadio.pop_back();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PrivateEngine::selectPoliceRadioArea(Common::Point mousePos) {
|
||||
if (_policeRadioArea == NULL)
|
||||
return;
|
||||
|
||||
if (_policeRadio.empty())
|
||||
return;
|
||||
|
||||
debug("PoliceRadio");
|
||||
if (inMask(_policeRadioArea->surf, mousePos)) {
|
||||
Common::String sound = *_policeRadioPrefix + _policeRadio.back() + ".wav";
|
||||
playSound(sound.c_str(), 1);
|
||||
_policeRadio.pop_back();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PrivateEngine::selectLoadGame(Common::Point mousePos) {
|
||||
if (_loadGameMask == NULL)
|
||||
return;
|
||||
//debug("Mousepos %d %d", mousePos.x, mousePos.y);
|
||||
mousePos = mousePos - *_origin;
|
||||
if (mousePos.x < 0 || mousePos.y < 0)
|
||||
return;
|
||||
|
||||
//debug("Testing mask %s", m.nextSetting->c_str());
|
||||
if ( *((uint32*) _loadGameMask->surf->getBasePtr(mousePos.x, mousePos.y)) != _transparentColor) {
|
||||
//debug("loadGame!");
|
||||
if (inMask(_loadGameMask->surf, mousePos)) {
|
||||
loadGameDialog();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool PrivateEngine::cursorLoadGame(Common::Point mousePos) {
|
||||
if (_loadGameMask == NULL)
|
||||
return false;
|
||||
//debug("Mousepos %d %d", mousePos.x, mousePos.y);
|
||||
mousePos = mousePos - *_origin;
|
||||
if (mousePos.x < 0 || mousePos.y < 0)
|
||||
return false;
|
||||
|
||||
if (mousePos.x > _loadGameMask->surf->h || mousePos.y > _loadGameMask->surf->w)
|
||||
return false;
|
||||
|
||||
if ( *((uint32*) _loadGameMask->surf->getBasePtr(mousePos.x, mousePos.y)) != _transparentColor) {
|
||||
changeCursor(*_loadGameMask->cursor);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PrivateEngine::selectSaveGame(Common::Point mousePos) {
|
||||
if (_saveGameMask == NULL)
|
||||
return;
|
||||
//debug("Mousepos %d %d", mousePos.x, mousePos.y);
|
||||
mousePos = mousePos - *_origin;
|
||||
if (mousePos.x < 0 || mousePos.y < 0)
|
||||
return;
|
||||
|
||||
//debug("Testing mask %s", m.nextSetting->c_str());
|
||||
if ( *((uint32*) _saveGameMask->surf->getBasePtr(mousePos.x, mousePos.y)) != _transparentColor) {
|
||||
if (inMask(_saveGameMask->surf, mousePos)) {
|
||||
saveGameDialog();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool PrivateEngine::cursorSaveGame(Common::Point mousePos) {
|
||||
if (_saveGameMask == NULL)
|
||||
return false;
|
||||
//debug("Mousepos %d %d", mousePos.x, mousePos.y);
|
||||
mousePos = mousePos - *_origin;
|
||||
if (mousePos.x < 0 || mousePos.y < 0)
|
||||
return false;
|
||||
|
||||
if (mousePos.x > _saveGameMask->surf->h || mousePos.y > _saveGameMask->surf->w)
|
||||
return false;
|
||||
|
||||
if ( *((uint32*) _saveGameMask->surf->getBasePtr(mousePos.x, mousePos.y)) != _transparentColor) {
|
||||
changeCursor(*_saveGameMask->cursor);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool PrivateEngine::hasFeature(EngineFeature f) const {
|
||||
return
|
||||
(f == kSupportsReturnToLauncher);
|
||||
}
|
||||
|
||||
void PrivateEngine::restartGame() {
|
||||
debug("restartGame");
|
||||
|
||||
for (VariableList::iterator it = variableList.begin(); it != variableList.end(); ++it) {
|
||||
Private::Symbol *sym = variables.getVal(*it);
|
||||
if (strcmp("kAlternateGame", sym->name->c_str()) != 0)
|
||||
sym->u.val = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Common::Error PrivateEngine::loadGameStream(Common::SeekableReadStream *stream) {
|
||||
Common::Serializer s(stream, nullptr);
|
||||
debug("loadGameStream");
|
||||
|
@ -524,10 +528,6 @@ void PrivateEngine::loadImage(const Common::String &name, int x, int y, bool dra
|
|||
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));
|
||||
|
||||
_compositeSurface->transBlitFrom(*_image->getSurface()->convertTo(_pixelFormat, _image->getPalette()), *_origin + Common::Point(x,y), _transparentColor);
|
||||
drawScreen();
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ enum {
|
|||
// the current limitation is 32 debug channels (1 << 31 is the last one)
|
||||
};
|
||||
|
||||
// exits
|
||||
// structs
|
||||
|
||||
typedef struct ExitInfo {
|
||||
Common::String *nextSetting;
|
||||
|
@ -51,9 +51,20 @@ typedef struct MaskInfo {
|
|||
Common::String *cursor;
|
||||
} MaskInfo;
|
||||
|
||||
typedef struct PhoneInfo {
|
||||
Common::String *sound;
|
||||
Symbol *flag;
|
||||
int val;
|
||||
} PhoneInfo;
|
||||
|
||||
// lists
|
||||
|
||||
typedef Common::List<ExitInfo> ExitList;
|
||||
typedef Common::List<MaskInfo> MaskList;
|
||||
typedef Common::List<Common::String> SoundList;
|
||||
typedef Common::List<PhoneInfo> PhoneList;
|
||||
|
||||
// hash tables
|
||||
|
||||
class PrivateEngine : public Engine {
|
||||
private:
|
||||
|
@ -75,6 +86,7 @@ public:
|
|||
Common::InstallerArchive _installerArchive;
|
||||
|
||||
Common::Error run() override;
|
||||
void restartGame();
|
||||
void initializePath(const Common::FSNode &gamePath) override;
|
||||
void selectMask(Common::Point);
|
||||
void selectExit(Common::Point);
|
||||
|
@ -88,10 +100,8 @@ public:
|
|||
bool canSaveGameStateCurrently() override { return true; }
|
||||
|
||||
void selectLoadGame(Common::Point);
|
||||
bool cursorLoadGame(Common::Point);
|
||||
|
||||
void selectSaveGame(Common::Point);
|
||||
bool cursorSaveGame(Common::Point);
|
||||
|
||||
|
||||
Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
|
||||
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
|
||||
|
@ -110,7 +120,7 @@ public:
|
|||
void initCursors();
|
||||
|
||||
Graphics::ManagedSurface *loadMask(const Common::String &, int, int, bool);
|
||||
|
||||
bool inMask(Graphics::ManagedSurface*, Common::Point);
|
||||
uint32 _transparentColor;
|
||||
void drawScreen();
|
||||
|
||||
|
@ -132,9 +142,25 @@ public:
|
|||
MaskList _masks;
|
||||
|
||||
// Radios
|
||||
SoundList _radio;
|
||||
SoundList _police;
|
||||
SoundList _phone;
|
||||
|
||||
MaskInfo *_AMRadioArea;
|
||||
Common::String *_AMRadioPrefix;
|
||||
|
||||
MaskInfo *_policeRadioArea;
|
||||
Common::String *_policeRadioPrefix;
|
||||
|
||||
MaskInfo *_phoneArea;
|
||||
Common::String *_phonePrefix;
|
||||
Common::String *_phoneCallSound;
|
||||
|
||||
SoundList _AMRadio;
|
||||
SoundList _policeRadio;
|
||||
PhoneList _phone;
|
||||
|
||||
void selectAMRadioArea(Common::Point);
|
||||
void selectPoliceRadioArea(Common::Point);
|
||||
|
||||
// Random values
|
||||
|
||||
bool getRandomBool(uint);
|
||||
|
||||
|
|
|
@ -74,8 +74,8 @@ Symbol *lookupName(char *n) {
|
|||
return lookup(*s, rects);
|
||||
|
||||
else {
|
||||
debug("WARNING: %s not defined", n);
|
||||
return constant(NAME, 0, n);
|
||||
debug("WARNING: %s not defined", s->c_str());
|
||||
return constant(STRING, 0, (char*) s->c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue