diff options
author | Matthew Hoops | 2011-09-05 16:46:00 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-09-05 16:46:39 -0400 |
commit | 593aec681d138f7106b034530f5b5eb89643bce1 (patch) | |
tree | cd45642b5f8af6e92cbd0e038cc3688626a1f4a6 | |
parent | 74054cff2d43ee641ac87b9d27ac915523b63e83 (diff) | |
download | scummvm-rg350-593aec681d138f7106b034530f5b5eb89643bce1.tar.gz scummvm-rg350-593aec681d138f7106b034530f5b5eb89643bce1.tar.bz2 scummvm-rg350-593aec681d138f7106b034530f5b5eb89643bce1.zip |
PEGASUS: Restructure remaining MMShell code into the base code
MMTimeValue has been removed, as Common::Timestamp will just be used instead
-rwxr-xr-x | engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp | 48 | ||||
-rwxr-xr-x | engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h | 51 | ||||
-rwxr-xr-x | engines/pegasus/MMShell/Utilities/MMTimeValue.cpp | 60 | ||||
-rwxr-xr-x | engines/pegasus/MMShell/Utilities/MMTimeValue.h | 52 | ||||
-rwxr-xr-x | engines/pegasus/MMShell/Utilities/MMUtilities.h | 43 | ||||
-rwxr-xr-x | engines/pegasus/hotspot.cpp | 2 | ||||
-rwxr-xr-x | engines/pegasus/hotspot.h | 4 | ||||
-rwxr-xr-x | engines/pegasus/items/item.cpp | 2 | ||||
-rwxr-xr-x | engines/pegasus/items/item.h | 4 | ||||
-rw-r--r-- | engines/pegasus/module.mk | 4 | ||||
-rw-r--r-- | engines/pegasus/neighborhood/neighborhood.cpp | 2 | ||||
-rw-r--r-- | engines/pegasus/neighborhood/neighborhood.h | 4 | ||||
-rwxr-xr-x | engines/pegasus/notification.cpp | 2 | ||||
-rwxr-xr-x | engines/pegasus/notification.h | 4 | ||||
-rwxr-xr-x | engines/pegasus/util.cpp (renamed from engines/pegasus/MMShell/Utilities/MMUtilities.cpp) | 47 | ||||
-rwxr-xr-x | engines/pegasus/util.h (renamed from engines/pegasus/MMShell/Utilities/MMIDObject.h) | 44 |
16 files changed, 79 insertions, 294 deletions
diff --git a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp b/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp deleted file mode 100755 index 9a2543db7b..0000000000 --- a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* 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/MMShell/Base_Classes/MMFunctionPtr.h" - -namespace Pegasus { - -MMFunctionPtr::MMFunctionPtr() { - fTheFunction = 0; - fFunctionArg = 0; -} - -MMFunctionPtr::~MMFunctionPtr() { -} - -void MMFunctionPtr::SetFunctionPtr(tFunctionPtr theFunction, void *functionArg) { - fTheFunction = theFunction; - fFunctionArg = functionArg; -} - -void MMFunctionPtr::CallFunction() { - if (fTheFunction != 0) - (*fTheFunction)(this, fFunctionArg); -} - -} // End of namespace Pegasus diff --git a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h b/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h deleted file mode 100755 index 4aa18cac81..0000000000 --- a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h +++ /dev/null @@ -1,51 +0,0 @@ -/* 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. - * - */ - -#ifndef PEGASUS_MMSHELL_BASECLASSES_MMFUNCTIONPTR_H -#define PEGASUS_MMSHELL_BASECLASSES_MMFUNCTIONPTR_H - -namespace Pegasus { - -class MMFunctionPtr; - -typedef void (*tFunctionPtr)(MMFunctionPtr *theFunction, void *functionArg); - -class MMFunctionPtr { -public: - MMFunctionPtr(); - virtual ~MMFunctionPtr(); - - void SetFunctionPtr(tFunctionPtr theFunction, void *functionArg); - -protected: - void CallFunction(); - - tFunctionPtr fTheFunction; - void *fFunctionArg; -}; - -} // End of namespace Pegasus - -#endif diff --git a/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp b/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp deleted file mode 100755 index 92971a6636..0000000000 --- a/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* 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/constants.h" -#include "pegasus/MMShell/Utilities/MMTimeValue.h" - -namespace Pegasus { - -MMTimeValue::MMTimeValue() { - fTheTime = 0; - fTheScale = kDefaultTimeScale; -} - -TimeValue MMTimeValue::GetTime() const { - return fTheTime; -} - -void MMTimeValue::GetTime(TimeValue &time, const TimeScale scale) const { - time = fTheTime * fTheScale / scale; -} - -void MMTimeValue::SetTime(const TimeValue time) { - fTheTime = time; -} - -void MMTimeValue::SetTime(const TimeValue time, const TimeScale scale) { - fTheTime = time * scale / fTheScale; -} - -TimeScale MMTimeValue::GetScale() const { - return fTheScale; -} - -void MMTimeValue::SetScale(const TimeScale scale) { - fTheScale = scale; -} - -} // End of namespace Pegasus diff --git a/engines/pegasus/MMShell/Utilities/MMTimeValue.h b/engines/pegasus/MMShell/Utilities/MMTimeValue.h deleted file mode 100755 index a112f9c233..0000000000 --- a/engines/pegasus/MMShell/Utilities/MMTimeValue.h +++ /dev/null @@ -1,52 +0,0 @@ -/* 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. - * - */ - -#ifndef PEGASUS_MMSHELL_MMTIMEVALUE_H -#define PEGASUS_MMSHELL_MMTIMEVALUE_H - -#include "pegasus/types.h" - -namespace Pegasus { - -class MMTimeValue { -public: - MMTimeValue(); - - TimeValue GetTime() const; - void GetTime(TimeValue &time, const TimeScale scale) const; - void SetTime(const TimeValue time); - void SetTime(const TimeValue time, const TimeScale scale); - - TimeScale GetScale() const; - void SetScale(const TimeScale scale); - -protected: - TimeValue fTheTime; - TimeScale fTheScale; -}; - -} // End of namespace Pegasus - -#endif diff --git a/engines/pegasus/MMShell/Utilities/MMUtilities.h b/engines/pegasus/MMShell/Utilities/MMUtilities.h deleted file mode 100755 index d5f7e541de..0000000000 --- a/engines/pegasus/MMShell/Utilities/MMUtilities.h +++ /dev/null @@ -1,43 +0,0 @@ -/* 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. - * - */ - -#ifndef PEGASUS_MMSHELL_UTILITIES_MMUTILITIES_H -#define PEGASUS_MMSHELL_UTILITIES_MMUTILITIES_H - -#include "common/scummsys.h" - -namespace Common { - class RandomSource; -} - -namespace Pegasus { - -int32 LinearInterp(const int32 start1, const int32 stop1, const int32 current1, const int32 start2, const int32 stop2); - -void ShuffleArray(int32 *arr, int32 count, Common::RandomSource &random); - -} // End of namespace Pegasus - -#endif diff --git a/engines/pegasus/hotspot.cpp b/engines/pegasus/hotspot.cpp index f97ad1d290..58ca353831 100755 --- a/engines/pegasus/hotspot.cpp +++ b/engines/pegasus/hotspot.cpp @@ -29,7 +29,7 @@ namespace Pegasus { HotspotList g_allHotspots; -Hotspot::Hotspot(const tHotSpotID id) : MMIDObject(id) { +Hotspot::Hotspot(const tHotSpotID id) : IDObject(id) { _spotFlags = kNoHotSpotFlags; _spotActive = false; } diff --git a/engines/pegasus/hotspot.h b/engines/pegasus/hotspot.h index 97bbf37832..d5a2fb0f6f 100755 --- a/engines/pegasus/hotspot.h +++ b/engines/pegasus/hotspot.h @@ -31,7 +31,7 @@ #include "pegasus/constants.h" #include "pegasus/types.h" -#include "pegasus/MMShell/Utilities/MMIDObject.h" +#include "pegasus/util.h" /* @@ -46,7 +46,7 @@ namespace Pegasus { -class Hotspot : public MMIDObject { +class Hotspot : public IDObject { public: Hotspot(const tHotSpotID); virtual ~Hotspot(); diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp index 2043317f5f..cdd81293cc 100755 --- a/engines/pegasus/items/item.cpp +++ b/engines/pegasus/items/item.cpp @@ -33,7 +33,7 @@ namespace Pegasus { -Item::Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) : MMIDObject(id) { +Item::Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) : IDObject(id) { _itemNeighborhood = neighborhood; _itemRoom = room; _itemDirection = direction; diff --git a/engines/pegasus/items/item.h b/engines/pegasus/items/item.h index 517ffc0c6e..f623df5a4b 100755 --- a/engines/pegasus/items/item.h +++ b/engines/pegasus/items/item.h @@ -28,8 +28,8 @@ #include "common/endian.h" -#include "pegasus/MMShell/Utilities/MMIDObject.h" #include "pegasus/types.h" +#include "pegasus/util.h" namespace Common { class Error; @@ -285,7 +285,7 @@ enum tItemType { */ -class Item : public MMIDObject { +class Item : public IDObject { public: Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction); virtual ~Item(); diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk index d3bcbcb500..5b8898ff85 100644 --- a/engines/pegasus/module.mk +++ b/engines/pegasus/module.mk @@ -12,15 +12,13 @@ MODULE_OBJS = \ overview.o \ pegasus.o \ sound.o \ + util.o \ video.o \ items/inventory.o \ items/item.o \ items/itemlist.o \ items/biochips/biochipitem.o \ items/inventory/inventoryitem.o \ - MMShell/Base_Classes/MMFunctionPtr.o \ - MMShell/Utilities/MMTimeValue.o \ - MMShell/Utilities/MMUtilities.o \ neighborhood/door.o \ neighborhood/exit.o \ neighborhood/extra.o \ diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp index 8048fa4240..39efda35e5 100644 --- a/engines/pegasus/neighborhood/neighborhood.cpp +++ b/engines/pegasus/neighborhood/neighborhood.cpp @@ -32,7 +32,7 @@ namespace Pegasus { -Neighborhood::Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) : MMIDObject(id), _vm(vm), _resName(resName) { +Neighborhood::Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) : IDObject(id), _vm(vm), _resName(resName) { GameState.setOpenDoorLocation(kNoRoomID, kNoDirection); _currentAlternate = 0; _interruptionFilter = kFilterAllInput; diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h index d567a5b3d3..baeed7d124 100644 --- a/engines/pegasus/neighborhood/neighborhood.h +++ b/engines/pegasus/neighborhood/neighborhood.h @@ -32,7 +32,7 @@ #include "pegasus/hotspot.h" #include "pegasus/notification.h" #include "pegasus/sound.h" -#include "pegasus/MMShell/Utilities/MMIDObject.h" +#include "pegasus/util.h" #include "pegasus/neighborhood/door.h" #include "pegasus/neighborhood/exit.h" #include "pegasus/neighborhood/extra.h" @@ -84,7 +84,7 @@ bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2); typedef Common::Queue<tQueueRequest> NeighborhoodActionQueue; -class Neighborhood : public MMIDObject, public NotificationReceiver { +class Neighborhood : public IDObject, public NotificationReceiver { public: Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id); virtual ~Neighborhood(); diff --git a/engines/pegasus/notification.cpp b/engines/pegasus/notification.cpp index f03e4705b7..9725cfbe1e 100755 --- a/engines/pegasus/notification.cpp +++ b/engines/pegasus/notification.cpp @@ -30,7 +30,7 @@ namespace Pegasus { typedef tReceiverList::iterator tReceiverIterator; -Notification::Notification(const tNotificationID id, NotificationManager *owner) : MMIDObject(id) { +Notification::Notification(const tNotificationID id, NotificationManager *owner) : IDObject(id) { _owner = owner; _currentFlags = kNoNotificationFlags; if (_owner) diff --git a/engines/pegasus/notification.h b/engines/pegasus/notification.h index d276f456ad..ded66478fc 100755 --- a/engines/pegasus/notification.h +++ b/engines/pegasus/notification.h @@ -29,7 +29,7 @@ #include "common/list.h" #include "pegasus/types.h" -#include "pegasus/MMShell/Utilities/MMIDObject.h" +#include "pegasus/util.h" namespace Pegasus { @@ -50,7 +50,7 @@ typedef Common::List<tReceiverEntry> tReceiverList; A notification can have 32 flags associated with it, which can be user-defined. */ -class Notification : public MMIDObject { +class Notification : public IDObject { friend class NotificationManager; public: diff --git a/engines/pegasus/MMShell/Utilities/MMUtilities.cpp b/engines/pegasus/util.cpp index e6bd146a08..a4c9a351c2 100755 --- a/engines/pegasus/MMShell/Utilities/MMUtilities.cpp +++ b/engines/pegasus/util.cpp @@ -26,11 +26,48 @@ #include "common/random.h" #include "common/util.h" -#include "pegasus/MMShell/Utilities/MMUtilities.h" +#include "pegasus/util.h" namespace Pegasus { -inline int32 Round(const int32 a, const int32 b) { +IDObject::IDObject(const tMM32BitID id) { + _objectID = id; +} + +IDObject::~IDObject() { +} + +tMM32BitID IDObject::getObjectID() const { + return _objectID; +} + +int operator==(const IDObject &arg1, const IDObject &arg2) { + return arg1.getObjectID() == arg2.getObjectID(); +} + +int operator!=(const IDObject &arg1, const IDObject &arg2) { + return arg1.getObjectID() != arg2.getObjectID(); +} + +FunctionPtr::FunctionPtr() { + _function = 0; + _functionArg = 0; +} + +FunctionPtr::~FunctionPtr() { +} + +void FunctionPtr::setFunctionPtr(tFunctionPtr function, void *functionArg) { + _function = function; + _functionArg = functionArg; +} + +void FunctionPtr::callFunction() { + if (_function != 0) + (*_function)(this, _functionArg); +} + +inline int32 pegasusRound(const int32 a, const int32 b) { if (b < 0) if (a < 0) return -((a - (-b >> 1)) / -b); @@ -43,14 +80,14 @@ inline int32 Round(const int32 a, const int32 b) { return (a + (b >> 1)) / b; } -int32 LinearInterp(const int32 start1, const int32 stop1, const int32 current1, const int32 start2, const int32 stop2) { +int32 linearInterp(const int32 start1, const int32 stop1, const int32 current1, const int32 start2, const int32 stop2) { if (start2 == stop2) return start2; else - return start2 + Round((current1 - start1) * (stop2 - start2), (stop1 - start1)); + return start2 + pegasusRound((current1 - start1) * (stop2 - start2), (stop1 - start1)); } -void ShuffleArray(int32 *arr, int32 count, Common::RandomSource &random) { +void shuffleArray(int32 *arr, int32 count, Common::RandomSource &random) { if (count > 1) { for (int32 i = 1; i < count; ++i) { int32 j = random.getRandomNumber(i); diff --git a/engines/pegasus/MMShell/Utilities/MMIDObject.h b/engines/pegasus/util.h index 112d3b8275..83c0c33324 100755 --- a/engines/pegasus/MMShell/Utilities/MMIDObject.h +++ b/engines/pegasus/util.h @@ -28,15 +28,16 @@ #include "pegasus/types.h" -namespace Pegasus { +namespace Common { + class RandomSource; +} -class MMIDObject { -friend inline int operator==(const MMIDObject &arg1, const MMIDObject &arg1); -friend inline int operator!=(const MMIDObject &arg2, const MMIDObject &arg2); +namespace Pegasus { +class IDObject { public: - MMIDObject(const tMM32BitID id); - ~MMIDObject(); + IDObject(const tMM32BitID id); + ~IDObject(); tMM32BitID getObjectID() const; @@ -44,24 +45,27 @@ private: tMM32BitID _objectID; }; -inline MMIDObject::MMIDObject(const tMM32BitID id) { - _objectID = id; -} +class FunctionPtr; -inline MMIDObject::~MMIDObject() { -} +typedef void (*tFunctionPtr)(FunctionPtr *theFunction, void *functionArg); -inline tMM32BitID MMIDObject::getObjectID() const { - return _objectID; -} +class FunctionPtr { +public: + FunctionPtr(); + virtual ~FunctionPtr(); + + void setFunctionPtr(tFunctionPtr function, void *functionArg); -inline int operator==(const MMIDObject &arg1, const MMIDObject &arg2) { - return arg1._objectID == arg2._objectID; -} +protected: + void callFunction(); + + tFunctionPtr _function; + void *_functionArg; +}; -inline int operator!=(const MMIDObject &arg1, const MMIDObject &arg2) { - return arg1._objectID != arg2._objectID; -} +int32 linearInterp(const int32 start1, const int32 stop1, const int32 current1, const int32 start2, const int32 stop2); + +void shuffleArray(int32 *arr, int32 count, Common::RandomSource &random); } // End of namespace Pegasus |