Skip to content

Commit

Permalink
DIRECTOR: Added stub for Lingo interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 3, 2016
1 parent f471b48 commit fd7b2f3
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 5 deletions.
13 changes: 9 additions & 4 deletions engines/director/director.cpp
Expand Up @@ -31,15 +31,16 @@
#include "common/stream.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "director/dib.h"

#include "engines/util.h"

#include "director/director.h"
#include "director/score.h"
#include "director/resource.h"
#include "graphics/surface.h"

#include "director/director.h"
#include "director/dib.h"
#include "director/resource.h"
#include "director/score.h"
#include "director/lingo/lingo.h"

namespace Director {

Expand All @@ -66,6 +67,8 @@ DirectorEngine::~DirectorEngine() {
Common::Error DirectorEngine::run() {
debug("Starting v%d Director game", getVersion());

_lingo = new Lingo();

//FIXME
_mainArchive = new RIFFArchive();
_mainArchive->openFile("bookshelf_example.mmm");
Expand All @@ -86,6 +89,8 @@ void DirectorEngine::loadEXE() {
if (!exeStream)
error("Failed to open EXE '%s'", getEXEName().c_str());

_lingo->processEvent(kEventStart, 0);

exeStream->seek(-4, SEEK_END);
exeStream->seek(exeStream->readUint32LE());

Expand Down
3 changes: 3 additions & 0 deletions engines/director/director.h
Expand Up @@ -41,6 +41,7 @@ enum DirectorGameID {

class Archive;
struct DirectorGameDescription;
class Lingo;

class DirectorEngine : public ::Engine {
public:
Expand Down Expand Up @@ -76,6 +77,8 @@ class DirectorEngine : public ::Engine {

Archive *_mainArchive;
Common::MacResManager *_macBinary;

Lingo *_lingo;
};

} // End of namespace Director
Expand Down
61 changes: 61 additions & 0 deletions engines/director/lingo/lingo.cpp
@@ -0,0 +1,61 @@
/* 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.
*
*/

#include "director/lingo/lingo.h"

namespace Director {

struct EventHandlerType {
LEvent handler;
const char *name;
} static const eventHanlerDescs[] = {
{ kEventEnterFrame, "enterFrame" },
{ kEventPrepareFrame, "prepareFrame" },
{ kEventExitFrame, "exitFrame" },

{ kEventActivateWindow, "activateWindow" },
{ kEventDeactivateWindow, "deactivateWindow" },
{ kEventMoveWindow, "moveWindow" },
{ kEventResizeWindow, "resizeWindow" },
{ kEventOpenWindow, "openWindow" },
{ kEventCloseWindow, "closeWindow" },
{ kEventStart, "start" },
{ kEventNone, 0 },
};

Lingo::Lingo() {
for (const EventHandlerType *t = &eventHanlerDescs[0]; t->handler != kEventNone; ++t)
_eventHandlerTypes[t->handler] = t->name;
}

Lingo::~Lingo() {
}

void Lingo::processEvent(LEvent event, int entityId) {
if (!_eventHandlerTypes.contains(event))
error("processEvent: Unknown event %d for entity %d", event, entityId);

debug(0, "processEvent(%s) for %d", _eventHandlerTypes[event], entityId);
}


} // End of namespace Director
60 changes: 60 additions & 0 deletions engines/director/lingo/lingo.h
@@ -0,0 +1,60 @@
/* 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.
*
*/

#ifndef DIRECTOR_LINGO_LINGO_H
#define DIRECTOR_LINGO_LINGO_H

#include "common/debug.h"
#include "common/hashmap.h"

namespace Director {

enum LEvent {
kEventNone,
kEventEnterFrame,
kEventPrepareFrame,
kEventExitFrame,

kEventActivateWindow,
kEventDeactivateWindow,
kEventMoveWindow,
kEventResizeWindow,
kEventOpenWindow,
kEventCloseWindow,

kEventStart
};

class Lingo {
public:
Lingo();
~Lingo();

void processEvent(LEvent event, int entityId);

private:
Common::HashMap<uint32, const char *> _eventHandlerTypes;
};

} // End of namespace Director

#endif
4 changes: 3 additions & 1 deletion engines/director/module.mk
Expand Up @@ -5,7 +5,9 @@ MODULE_OBJS = \
dib.o \
director.o \
resource.o \
score.o
score.o \
lingo/lingo.o

# This module can be built as a plugin
ifeq ($(ENABLE_DIRECTOR), DYNAMIC_PLUGIN)
PLUGIN := 1
Expand Down

0 comments on commit fd7b2f3

Please sign in to comment.