Skip to content

Commit

Permalink
Merge pull request #275 from clone2727/pegasus
Browse files Browse the repository at this point in the history
Pegasus engine (The Journeyman Project: Pegasus Prime)
  • Loading branch information
clone2727 committed Sep 20, 2012
2 parents 2a3ba6a + 1677686 commit 2e4ee0b
Show file tree
Hide file tree
Showing 203 changed files with 54,197 additions and 60 deletions.
6 changes: 6 additions & 0 deletions AUTHORS
Expand Up @@ -141,6 +141,9 @@ ScummVM Team
Parallaction:
peres

Pegasus:
Matthew Hoops

Queen:
David Eriksson - (retired)
Gregory Montoir - (retired)
Expand Down Expand Up @@ -621,3 +624,6 @@ Special thanks to
Jan Nedoma for providing the sources to the Wintermute-engine, and for his
support while porting the engine to ScummVM.

Bob Bell, Michel Kripalani, Tommy Yune, from Presto Studios for providing
the source code of The Journeyman Project: Pegasus Prime.

1 change: 1 addition & 0 deletions audio/decoders/aiff.h
Expand Up @@ -23,6 +23,7 @@
/**
* @file
* Sound decoder used in engines:
* - pegasus
* - saga
* - sci
* - sword1
Expand Down
1 change: 1 addition & 0 deletions audio/decoders/quicktime.h
Expand Up @@ -25,6 +25,7 @@
* Sound decoder used in engines:
* - groovie
* - mohawk
* - pegasus
* - sci
*/

Expand Down
2 changes: 2 additions & 0 deletions backends/events/sdl/sdl-events.cpp
Expand Up @@ -191,6 +191,8 @@ void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
#endif
if (mod & KMOD_CTRL)
event.kbd.flags |= Common::KBD_CTRL;
if (mod & KMOD_META)
event.kbd.flags |= Common::KBD_META;

// Sticky flags
if (mod & KMOD_NUM)
Expand Down
9 changes: 5 additions & 4 deletions common/keyboard.h
Expand Up @@ -224,12 +224,13 @@ enum {
KBD_CTRL = 1 << 0,
KBD_ALT = 1 << 1,
KBD_SHIFT = 1 << 2,
KBD_NON_STICKY = (KBD_CTRL|KBD_ALT|KBD_SHIFT),
KBD_META = 1 << 3,
KBD_NON_STICKY = (KBD_CTRL|KBD_ALT|KBD_SHIFT|KBD_META),

// Sticky modifier flags
KBD_NUM = 1 << 3,
KBD_CAPS = 1 << 4,
KBD_SCRL = 1 << 5,
KBD_NUM = 1 << 4,
KBD_CAPS = 1 << 5,
KBD_SCRL = 1 << 6,
KBD_STICKY = (KBD_NUM|KBD_CAPS|KBD_SCRL)

};
Expand Down
22 changes: 19 additions & 3 deletions common/macresman.cpp
Expand Up @@ -124,7 +124,7 @@ bool MacResManager::open(String filename) {
File *file = new File();

// First, let's try to see if the Mac converted name exists
if (file->open("._" + filename) && loadFromAppleDouble(*file)) {
if (file->open(constructAppleDoubleName(filename)) && loadFromAppleDouble(*file)) {
_baseFileName = filename;
return true;
}
Expand Down Expand Up @@ -185,7 +185,7 @@ bool MacResManager::open(FSNode path, String filename) {
#endif

// First, let's try to see if the Mac converted name exists
FSNode fsNode = path.getChild("._" + filename);
FSNode fsNode = path.getChild(constructAppleDoubleName(filename));
if (fsNode.exists() && !fsNode.isDirectory()) {
SeekableReadStream *stream = fsNode.createReadStream();
if (loadFromAppleDouble(*stream)) {
Expand Down Expand Up @@ -253,7 +253,7 @@ bool MacResManager::exists(const String &filename) {
return true;

// Check if we have an AppleDouble file
if (tempFile.open("._" + filename) && tempFile.readUint32BE() == 0x00051607)
if (tempFile.open(constructAppleDoubleName(filename)) && tempFile.readUint32BE() == 0x00051607)
return true;

return false;
Expand Down Expand Up @@ -574,4 +574,20 @@ void MacResManager::readMap() {
}
}

Common::String MacResManager::constructAppleDoubleName(Common::String name) {
// Insert "._" before the last portion of a path name
for (int i = name.size() - 1; i >= 0; i--) {
if (i == 0) {
name.insertChar('_', 0);
name.insertChar('.', 0);
} else if (name[i] == '/') {
name.insertChar('_', i + 1);
name.insertChar('.', i + 1);
break;
}
}

return name;
}

} // End of namespace Common
3 changes: 3 additions & 0 deletions common/macresman.h
Expand Up @@ -25,6 +25,7 @@
* Macintosh resource fork manager used in engines:
* - groovie
* - mohawk
* - pegasus
* - sci
* - scumm
*/
Expand Down Expand Up @@ -175,6 +176,8 @@ class MacResManager {
bool loadFromMacBinary(SeekableReadStream &stream);
bool loadFromAppleDouble(SeekableReadStream &stream);

static Common::String constructAppleDoubleName(Common::String name);

enum {
kResForkNone = 0,
kResForkRaw,
Expand Down
3 changes: 3 additions & 0 deletions common/rational.h
Expand Up @@ -80,6 +80,9 @@ class Rational {
double toDouble() const;
frac_t toFrac() const;

int getNumerator() const { return _num; }
int getDenominator() const { return _denom; }

void debugPrint(int debuglevel = 0, const char *caption = "Rational:") const;

private:
Expand Down
14 changes: 14 additions & 0 deletions common/rect.h
Expand Up @@ -169,6 +169,20 @@ struct Rect {
return (left < r.right) && (r.left < right) && (top < r.bottom) && (r.top < bottom);
}

/**
* Find the intersecting rectangle between this rectangle and the given rectangle
*
* @param r the intersecting rectangle
*
* @return the intersection of the rectangles or an empty rectangle if not intersecting
*/
Rect findIntersectingRect(const Rect &r) const {
if (!intersects(r))
return Rect();

return Rect(MAX(r.left, left), MAX(r.top, top), MIN(r.right, right), MIN(r.bottom, bottom));
}

/**
* Extend this rectangle so that it contains r
*
Expand Down
8 changes: 8 additions & 0 deletions devtools/credits.pl
Expand Up @@ -616,6 +616,10 @@ sub add_paragraph {
add_person("", "peres", "");
end_section();

begin_section("Pegasus");
add_person("Matthew Hoops", "clone2727", "");
end_section();

begin_section("Queen");
add_person("David Eriksson", "twogood", "(retired)");
add_person("Gregory Montoir", "cyx", "(retired)");
Expand Down Expand Up @@ -1153,6 +1157,10 @@ sub add_paragraph {
"Jan Nedoma for providing the sources to the Wintermute-engine, and for his ".
"support while porting the engine to ScummVM.");

add_paragraph(
"Bob Bell, Michel Kripalani, Tommy Yune, from Presto Studios for ".
"providing the source code of The Journeyman Project: Pegasus Prime.");

end_section();

end_credits();
1 change: 1 addition & 0 deletions engines/configure.engines
Expand Up @@ -28,6 +28,7 @@ add_engine cstime "Where in Time is Carmen Sandiego?" no
add_engine riven "Riven: The Sequel to Myst" no
add_engine myst "Myst" no
add_engine parallaction "Parallaction" yes
add_engine pegasus "The Journeyman Project: Pegasus Prime" no
add_engine queen "Flight of the Amazon Queen" yes
add_engine saga "SAGA" yes "ihnm saga2" "ITE"
add_engine ihnm "IHNM" yes
Expand Down
5 changes: 5 additions & 0 deletions engines/engines.mk
Expand Up @@ -130,6 +130,11 @@ DEFINES += -DENABLE_PARALLACTION=$(ENABLE_PARALLACTION)
MODULES += engines/parallaction
endif

ifdef ENABLE_PEGASUS
DEFINES += -DENABLE_PEGASUS=$(ENABLE_PEGASUS)
MODULES += engines/pegasus
endif

ifdef ENABLE_QUEEN
DEFINES += -DENABLE_QUEEN=$(ENABLE_QUEEN)
MODULES += engines/queen
Expand Down
78 changes: 78 additions & 0 deletions engines/pegasus/ai/ai_action.cpp
@@ -0,0 +1,78 @@
/* 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.
*
* Additional copyright for this file:
* Copyright (C) 1995-1997 Presto Studios, Inc.
*
* 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 "pegasus/ai/ai_action.h"
#include "pegasus/ai/ai_area.h"

namespace Pegasus {

AICompoundAction::~AICompoundAction() {
for (AIActionList::iterator it = _compoundActions.begin(); it != _compoundActions.end(); it++)
delete *it;
}

void AICompoundAction::performAIAction(AIRule *rule) {
for (AIActionList::iterator it = _compoundActions.begin(); it != _compoundActions.end(); it++)
(*it)->performAIAction(rule);
}

AIPlayMessageAction::AIPlayMessageAction(const Common::String &movieName, bool keepLastFrame, const InputBits interruptionFilter) {
_movieName = movieName;
_keepLastFrame = keepLastFrame;
_interruptionFilter = interruptionFilter;
}

void AIPlayMessageAction::performAIAction(AIRule *) {
if (g_AIArea) {
g_AIArea->checkMiddleArea();
g_AIArea->playAIMovie(kRightAreaSignature, _movieName, _keepLastFrame, _interruptionFilter);
}
}

AIStartTimerAction::AIStartTimerAction(AITimerCondition *timerCondition) {
_timerCondition = timerCondition;
}

void AIStartTimerAction::performAIAction(AIRule *) {
_timerCondition->startTimer();
}

AIActivateRuleAction::AIActivateRuleAction(AIRule *rule) {
_rule = rule;
}

void AIActivateRuleAction::performAIAction(AIRule *) {
_rule->activateRule();
}

AIDeactivateRuleAction::AIDeactivateRuleAction(AIRule *rule) {
_rule = rule;
}

void AIDeactivateRuleAction::performAIAction(AIRule *) {
_rule->deactivateRule();
}

} // End of namespace Pegasus

0 comments on commit 2e4ee0b

Please sign in to comment.