[Scummvm-cvs-logs] SF.net SVN: scummvm:[53184] scummvm/trunk/engines/sword25
sev at users.sourceforge.net
sev at users.sourceforge.net
Tue Oct 12 23:55:39 CEST 2010
Revision: 53184
http://scummvm.svn.sourceforge.net/scummvm/?rev=53184&view=rev
Author: sev
Date: 2010-10-12 21:55:38 +0000 (Tue, 12 Oct 2010)
Log Message:
-----------
SWORD25: Converted kernel/kernel.cpp to compile under ScummVM
This commit creates a skeleton detection and engine class, as well as code necessary to call the kernel initiation.
The kernel/kernel.cpp has been converted to compile under ScummVM, along with all dependant header files.
Modified Paths:
--------------
scummvm/trunk/engines/sword25/fmv/movieplayer.h
scummvm/trunk/engines/sword25/gfx/framecounter.h
scummvm/trunk/engines/sword25/gfx/graphicengine.h
scummvm/trunk/engines/sword25/input/inputengine.h
scummvm/trunk/engines/sword25/kernel/bs_stdint.h
scummvm/trunk/engines/sword25/kernel/common.h
scummvm/trunk/engines/sword25/kernel/kernel.cpp
scummvm/trunk/engines/sword25/kernel/kernel.h
scummvm/trunk/engines/sword25/kernel/log.cpp
scummvm/trunk/engines/sword25/kernel/log.h
scummvm/trunk/engines/sword25/kernel/memleaks.h
scummvm/trunk/engines/sword25/kernel/persistable.h
scummvm/trunk/engines/sword25/kernel/persistenceservice.h
scummvm/trunk/engines/sword25/kernel/resmanager.h
scummvm/trunk/engines/sword25/kernel/resservice.h
scummvm/trunk/engines/sword25/kernel/service.h
scummvm/trunk/engines/sword25/kernel/service_ids.h
scummvm/trunk/engines/sword25/kernel/window.h
scummvm/trunk/engines/sword25/package/packagemanager.h
scummvm/trunk/engines/sword25/script/script.h
scummvm/trunk/engines/sword25/sfx/soundengine.h
scummvm/trunk/engines/sword25/sword25.cpp
Added Paths:
-----------
scummvm/trunk/engines/sword25/detection.cpp
scummvm/trunk/engines/sword25/sword25.h
Added: scummvm/trunk/engines/sword25/detection.cpp
===================================================================
--- scummvm/trunk/engines/sword25/detection.cpp (rev 0)
+++ scummvm/trunk/engines/sword25/detection.cpp 2010-10-12 21:55:38 UTC (rev 53184)
@@ -0,0 +1,123 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "base/plugins.h"
+
+#include "engines/advancedDetector.h"
+
+#include "sword25/sword25.h"
+
+namespace Sword25 {
+
+struct Sword25GameDescription {
+ ADGameDescription desc;
+
+ uint32 features;
+};
+
+uint32 Sword25Engine::getFeatures() const { return _gameDescription->features; }
+Common::Language Sword25Engine::getLanguage() const { return _gameDescription->desc.language; }
+Common::Platform Sword25Engine::getPlatform() const { return _gameDescription->desc.platform; }
+
+}
+
+static const PlainGameDescriptor Sword25Game[] = {
+ {"sword25", "Broken Sword 2.5"},
+ {0, 0}
+};
+
+namespace Sword25 {
+
+// TODO: Need to decide whether we're going to implement code to detect all the various languages allowed,
+// both by the core data package, as well as the extra languages added by the patch file; also, I don't
+// think that all the languages supported by the game currently have constants in ScummVM
+static const Sword25GameDescription gameDescriptions[] = {
+ {
+ {
+ "sword25",
+ "",
+ {
+ { "data.b25c", kFileTypeHash, "f8b6e03ada2d2f6cf27fbc11ad1572e9", 654310588},
+ { NULL, 0, NULL, 0}
+ },
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS
+ },
+ 0
+ },
+ { { NULL, NULL, { { NULL, 0, NULL, 0 } }, Common::UNK_LANG, Common::kPlatformUnknown, ADGF_NO_FLAGS }, 0 }
+};
+
+} // end of namespace Sword25
+
+static const ADParams detectionParams = {
+ // Pointer to ADGameDescription or its superset structure
+ (const byte *)Sword25::gameDescriptions,
+ // Size of that superset structure
+ sizeof(Sword25::Sword25GameDescription),
+ // Number of bytes to compute MD5 sum for
+ 5000,
+ // List of all engine targets
+ Sword25Game,
+ // Structure for autoupgrading obsolete targets
+ 0,
+ // Name of single gameid (optional)
+ NULL,
+ // List of files for file-based fallback detection (optional)
+ 0,
+ // Flags
+ 0
+};
+
+class Sword25MetaEngine : public AdvancedMetaEngine {
+public:
+ Sword25MetaEngine() : AdvancedMetaEngine(detectionParams) {}
+
+ virtual const char *getName() const {
+ return "The Broken Sword 2.5 Engine";
+ }
+
+ virtual const char *getOriginalCopyright() const {
+ return "Broken Sword 2.5 (C) Malte Thiesen, Daniel Queteschiner and Michael Elsdorfer";
+ }
+
+ virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+};
+
+bool Sword25MetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+ const Sword25::Sword25GameDescription *gd = (const Sword25::Sword25GameDescription *)desc;
+ if (gd) {
+ *engine = new Sword25::Sword25Engine(syst, gd);
+ }
+ return gd != 0;
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(SWORD25)
+ REGISTER_PLUGIN_DYNAMIC(SWORD25, PLUGIN_TYPE_ENGINE, Sword25MetaEngine);
+#else
+ REGISTER_PLUGIN_STATIC(SWORD25, PLUGIN_TYPE_ENGINE, Sword25MetaEngine);
+#endif
+
Property changes on: scummvm/trunk/engines/sword25/detection.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Modified: scummvm/trunk/engines/sword25/fmv/movieplayer.h
===================================================================
--- scummvm/trunk/engines/sword25/fmv/movieplayer.h 2010-10-12 21:54:43 UTC (rev 53183)
+++ scummvm/trunk/engines/sword25/fmv/movieplayer.h 2010-10-12 21:55:38 UTC (rev 53184)
@@ -1,22 +1,28 @@
-// -----------------------------------------------------------------------------
-// This file is part of Broken Sword 2.5
-// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsd\xF6rfer
-//
-// Broken Sword 2.5 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.
-//
-// Broken Sword 2.5 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 Broken Sword 2.5; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// -----------------------------------------------------------------------------
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
#ifndef SWORD25_MOVIEPLAYER_H
#define SWORD25_MOVIEPLAYER_H
@@ -27,112 +33,106 @@
#include "sword25/kernel/common.h"
#include "sword25/kernel/service.h"
-#include "sword25/kernel/memlog_off.h"
-#include <string>
-#include "sword25/kernel/memlog_on.h"
+namespace Sword25 {
// -----------------------------------------------------------------------------
-// Klassendefinition
+// Class definitions
// -----------------------------------------------------------------------------
-class BS_MoviePlayer : public BS_Service
-{
+class BS_MoviePlayer : public BS_Service {
public:
// -----------------------------------------------------------------------------
- // Konstruktion / Destruktion
+ // Constructor / Destructor
// -----------------------------------------------------------------------------
- BS_MoviePlayer(BS_Kernel * pKernel);
+ BS_MoviePlayer(BS_Kernel *pKernel);
virtual ~BS_MoviePlayer() {};
// -----------------------------------------------------------------------------
- // Abstraktes Interface, muss von jedem MoviePlayer implementiert werden
+ // Abstract interface must be implemented by each Movie Player
// -----------------------------------------------------------------------------
/**
- @brief L\xE4dt eine Filmdatei
-
- Diese Methode l\xE4dt eine Filmdatei und bereitet sie zur Wiedergabe vor.
- Es kann immer nur eine Filmdatei zur Zeit geladen sein. Falls bereits eine Filmdatei geladen
- ist, wird diese entladen und n\xF6tigenfalls die Wiedergabe gestoppt.
-
- @param Filename der Dateiname der zu ladenden Filmdatei
- @param Z gibt die Z Position des Films auf dem Graphik-Hauptlayer an
- @return Gibt false zur\xFCck, wenn beim Laden ein Fehler aufgetreten ist, ansonsten true.
+ * Loads a movie file
+ *
+ * This method loads a movie file and prepares it for playback.
+ * There can be oly one movie file loaded at a time. If you already have loaded a
+ * movie file, it will be unloaded and, if necessary, stopped playing.
+ * @param Filename The filename of the movie file to be loaded
+ * @param Z Z indicates the position of the film on the main graphics layer
+ * @return Returns false if an error occured while loading, otherwise true.
*/
virtual bool LoadMovie(const std::string & Filename, unsigned int Z) = 0;
/**
- @brief Entl\xE4dt die gerade geladene Filmdatei
-
- @return Gibt false zur\xFCck, wenn beim Entladen ein Fehler aufgetreten ist, ansonsten true.
- @remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zur\xFCckgibt.
- */
+ * Unloads the currently loaded movie file.
+ * @return Returns false if an error occurred while unloading, otherwise true.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
+ */
virtual bool UnloadMovie() = 0;
/**
- @brief Spielt den Film ab.
-
- Der Film wird unter Beibehaltung der Seitenverh\xE4ltnisse auf Bildschirmgr\xF6\xDFe skaliert.<br>
- Falls der Film mit einem Aufruf von Pause() pausiert wurde, f\xE4hrt der Film an dieser Stelle fort.
-
- @return Gibt false zur\xFCck, wenn ein Fehler aufgetreten ist, ansonsten true.
- @remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zur\xFCckgibt.
- */
+ * Plays the loaded movie.
+ *
+ * The film will be keeping the aspect ratio of the screen.
+ * If the film was previously paused with Pause(), then the film will resume playing.
+ * @return Returns false if an error occurred while starting, otherwise true.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
+ */
virtual bool Play() = 0;
/**
- @brief Pausiert die Filmwiedergabe.
-
- Bei einem sp\xE4teren Aufruf von Play() f\xE4hrt die Wiedergabe an der Stelle fort an der der Film Pausiert wurde.
-
- @return Gibt false zur\xFCck, wenn ein Fehler aufgetreten ist, ansonsten true.
- @remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zur\xFCckgibt.
- */
+ * Pauses movie playback.
+ *
+ * A paused movie can later be resumed by calling the Play() method again.
+ * @return Returns false if an error occurred while pausing, otherwise true.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
+ */
virtual bool Pause() = 0;
/**
- @brief Diese Funktion muss ein mal pro Frame aufgerufen werden.
- */
+ * This function must be called once per frame.
+ */
virtual void Update() = 0;
/**
- @brief Gibt zur\xFCck, ob ein Film zur Wiedergabe geladen wurde.
- */
+ * Returns whether a film is loaded for playback.
+ */
virtual bool IsMovieLoaded() = 0;
/**
- @brief Gibt zur\xFCck, ob die Filmwiedergabe pausiert wurde.
- @remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zur\xFCckgibt.
+ * Returns whether the movie playback is paused.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
*/
virtual bool IsPaused() = 0;
/**
- @brief Gibt den Faktor zur\xFCck um den der geladene Film skaliert wird.
-
- Beim Laden wird der Skalierungsfaktor automatisch so gew\xE4hlt, dass der Film die maximal m\xF6gliche Bildschirmfl\xE4che einnimmt, ohne dass der
- Film verzerrt wird.
-
- @return Gibt den Skalierungsfaktor des Filmes zur\xFCck.
- @remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zur\xFCckgibt.
- */
+ * Returns the scaling factor for the loaded film.
+ *
+ * When a movie is loaded, the scaling factor is automatically selected so that the film
+ * takes the maximum screen space, without the film being distorted.
+ * @return Returns the scaling factor of the film.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
+ */
virtual float GetScaleFactor() = 0;
/**
- @brief Legt den Faktor fest um den der geladene Film skaliert werden soll.
- @param ScaleFactor der gew\xFCnschte Skalierungsfaktor.
- @remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zur\xFCckgibt.
- */
+ * Sets the factor by which the loaded film is to be scaled.
+ * @param ScaleFactor The desired scale factor.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
+ */
virtual void SetScaleFactor(float ScaleFactor) = 0;
/**
- @brief Gibt die aktuelle Abspielposition in Sekunden zur\xFCck.
- @remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zur\xFCckgibt.
- */
+ * Returns the current playing position in seconds.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
+ */
virtual double GetTime() = 0;
private:
bool _RegisterScriptBindings();
};
+} // End of namespace Sword25
+
#endif
Modified: scummvm/trunk/engines/sword25/gfx/framecounter.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/framecounter.h 2010-10-12 21:54:43 UTC (rev 53183)
+++ scummvm/trunk/engines/sword25/gfx/framecounter.h 2010-10-12 21:55:38 UTC (rev 53184)
@@ -1,22 +1,28 @@
-// -----------------------------------------------------------------------------
-// This file is part of Broken Sword 2.5
-// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsd\xF6rfer
-//
-// Broken Sword 2.5 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.
-//
-// Broken Sword 2.5 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 Broken Sword 2.5; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// -----------------------------------------------------------------------------
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
#ifndef SWORD25_FRAMECOUNTER_H
#define SWORD25_FRAMECOUNTER_H
@@ -24,39 +30,39 @@
#include "sword25/kernel/common.h"
#include "sword25/kernel/bs_stdint.h"
+namespace Sword25 {
+
/**
- @brief Eine einfache Klasse die einen Framecounter implementiert.
-*/
-class BS_Framecounter
-{
+ * A simple class that implements a frame counter
+ */
+class BS_Framecounter {
private:
- enum
- {
+ enum {
DEFAULT_UPDATE_FREQUENCY = 10
};
public:
/**
- @brief Erzeugt ein neues BS_Framecounter Objekt.
- @param UpdateFrequency gibt an wie oft der Framecounter in einer Sekunde aktualisiert werden soll.<br>
- Der Standardwert ist 10.
- */
+ * Creates a new BS_Framecounter object
+ * @param UpdateFrequency Specifies how often the frame counter should be updated in a sceond.
+ * The default value is 10.
+ */
BS_Framecounter(int UpdateFrequency = DEFAULT_UPDATE_FREQUENCY);
/**
- @brief Bestimmt wie oft der Framecounter in einer Sekunde aktualisiert werden soll.
- @param UpdateFrequency gibt an wie oft der Framecounter in einer Sekunde aktualisiert werden soll.
- */
+ * Determines how often the frame counter should be updated in a second.
+ * @param UpdateFrequency Specifies how often the frame counter should be updated in a second.
+ */
inline void SetUpdateFrequency(int UpdateFrequency);
/**
- @brief Diese Methode muss einmal pro Frame aufgerufen werden.
- */
+ * This method must be called once per frame.
+ */
void Update();
/**
- @brief Gibt den aktuellen FPS-Wert zur\xFCck.
- */
+ * Returns the current FPS value.
+ */
int GetFPS() const { return m_FPS; }
private:
@@ -67,10 +73,11 @@
};
// Inlines
-void BS_Framecounter::SetUpdateFrequency(int UpdateFrequency)
-{
- // Frequenz in Laufzeit (in Microsekunden) umrechnen.
+void BS_Framecounter::SetUpdateFrequency(int UpdateFrequency) {
+ // Frequency in time (converted to microseconds)
m_UpdateDelay = 1000000 / UpdateFrequency;
}
+} // End of namespace Sword25
+
#endif
Modified: scummvm/trunk/engines/sword25/gfx/graphicengine.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/graphicengine.h 2010-10-12 21:54:43 UTC (rev 53183)
+++ scummvm/trunk/engines/sword25/gfx/graphicengine.h 2010-10-12 21:55:38 UTC (rev 53184)
@@ -1,39 +1,37 @@
-// -----------------------------------------------------------------------------
-// This file is part of Broken Sword 2.5
-// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsd\xF6rfer
-//
-// Broken Sword 2.5 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.
-//
-// Broken Sword 2.5 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 Broken Sword 2.5; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// -----------------------------------------------------------------------------
+/* 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.
-/*
- BS_GraphicEngine
- ----------------
- Dies ist das Graphik-Engine Interface, dass alle Methoden und Klassen enth\xE4lt, die eine
- Graphik-Engine implementieren muss.
+ * 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.
- Autor: Malte Thiesen
-*/
+ * 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ * BS_GraphicEngine
+ * ----------------
+ * This the graphics engine interface.
+ *
+ * Autor: Malte Thiesen
+ */
#ifndef SWORD25_GRAPHICENGINE_H
#define SWORD25_GRAPHICENGINE_H
// Includes
-#include "sword25/kernel/memlog_off.h"
-#include <vector>
-#include "sword25/kernel/memlog_on.h"
-
#include "sword25/kernel/common.h"
#include "sword25/kernel/bs_stdint.h"
#include "sword25/kernel/resservice.h"
@@ -42,6 +40,8 @@
#include "sword25/gfx/framecounter.h"
#include "sword25/gfx/renderobjectptr.h"
+namespace Sword25 {
+
class BS_Kernel;
class BS_Image;
class BS_Panel;
@@ -62,54 +62,55 @@
Die bisher einzige Implementation ist BS_DDrawGfx.
*/
-class BS_GraphicEngine : public BS_ResourceService, public BS_Persistable
-{
+class BS_GraphicEngine : public BS_ResourceService, public BS_Persistable {
public:
// Enums
// -----
- // Farbformate
+ // Colour formats
+ //
/**
- @brief Die von der Engine benutzten Farbformate
- */
- enum COLOR_FORMATS
- {
- /// Undefiniertes/unbekanntes Farbformat
+ * The colour format used by the engine
+ */
+ enum COLOR_FORMATS {
+ /// Undefined/unknown colour format
CF_UNKNOWN = 0,
- /// 16 Bit Farbformat (5 Bit Rot, 5 Bit Gr\xFCn, 5 Bit Blau)
+ /// 16-bit colour format (R5G5B5)
CF_RGB15,
- /// 16 Bit Farbformat (5 Bit Rot, 6 Bit Gr\xFCn, 5 Bit Blau)
+ /// 16-bit colour format (R5G6R5)
CF_RGB16,
/**
- Spezielles Alpha-Farbformat der Engine, welches besonders schnelles Darstellen unter Benutzung von MMX-Befehlen unterst\xFCtzt.<br>
- Die Pixel sind 16 Bit breit und haben das selbe Format wie #CF_RGB15. Zus\xE4tzlich besitzt jeder Pixel noch einen 8 Bit Alphawert.<br>
- Es werden jeweils 4 Pixel und 4 Alphawerte zu einem 12 Byte gro\xDFen Datenblock zusammengefasst.<br>
- Dabei werden die Daten in folgender Reihenfolge abgelegt:
- Alpha0 Alpha1 Alpha2 Alpha3 Pixel0 Pixel1 Pixel2 Pixel3
- Falls die Pixelanzahl einer Zeile nicht durch 4 teilbar ist, wird der letzte Pixelblock trotzdem komplett abgespeichert, die
- nicht verwendeten Pixel- und Alphawerte k\xF6nnen beliebige Werte haben.
- */
+ * Special alpha colour format of the engine, which supports very quick display using MMX instructions.
+ * The pixels are 16-bits wide and have the same format as #CF_RGB15. In addition, each pixel has an 8-bit
+ * alpha value.
+ * It summarises groupings of pixels pixels and four alpha values in a 12-byte data block.
+ * The data is stored in the following order:
+ * Alpha0 Alpha1 Alpha2 Alpha3 Pixel0 Pixel1 Pixel2 Pixel3
+ * If the number of pixels in a line is not divisible by 4, then unused pixels and alpha values can have
+ * arbitrary values.
+ */
CF_RGB15_INTERLEAVED,
/**
- Spezielles Alpha-Farbformat der Engine, welches besonders schnelles Darstellen unter Benutzung von MMX-Befehlen unterst\xFCtzt.<br>
- Die Pixel sind 16 Bit breit und haben das selbe Format wie #CF_RGB16. Zus\xE4tzlich besitzt jeder Pixel noch einen 8 Bit Alphawert.<br>
- Es werden jeweils 4 Pixel und 4 Alphawerte zu einem 12 Byte gro\xDFen Datenblock zusammengefasst.<br>
- Dabei werden die Daten in folgender Reihenfolge abgelegt:
- Alpha0 Alpha1 Alpha2 Alpha3 Pixel0 Pixel1 Pixel2 Pixel3
- Falls die Pixelanzahl einer Zeile nicht durch 4 teilbar ist, wird der letzte Pixelblock trotzdem komplett abgespeichert, die
- nicht verwendeten Pixel- und Alphawerte k\xF6nnen beliebige Werte haben.
- */
+ * Special alpha colour format of the engine, which supports very quick display using MMX instructions.
+ * The pixels are 16-bits wide and have the same format as #CF_RGB16. In addition, each pixel has an 8-bit
+ * alpha value.
+ * It summarises groupings of pixels pixels and four alpha values in a 12-byte data block.
+ * The data is stored in the following order:
+ * Alpha0 Alpha1 Alpha2 Alpha3 Pixel0 Pixel1 Pixel2 Pixel3
+ * If the number of pixels in a line is not divisible by 4, then unused pixels and alpha values can have
+ * arbitrary values.
+ */
CF_RGB16_INTERLEAVED,
/**
- 24 Bit Farbformat (8 Bit Rot, 8 Bit Gr\xFCn, 8 Bit Blau)
- */
+ * 24-bit colour format (R8G8B8)
+ */
CF_RGB24,
/**
- 32 Bit Farbformat (8 Bit Alpha, 8 Bit Rot, 8 Bit Gr\xFCn, 8 Bit Blau) (little endian)
+ * 32-bit colour format (A8R8G8B8) (little endian)
*/
CF_ARGB32,
/**
- 32 Bit Farbformat (8 Bit Alpha, 8 Bit Blau, 8 Bit Gr\xFCn, 8 Bit Rot) (little endian)
+ 32-bit colour format (A8B8G8R8) (little endian)
*/
CF_ABGR32
};
@@ -118,109 +119,84 @@
// ---------
/**
- @brief Initialisiert die Graphikengine und setzt den Bildschirmmodus.
- @param Width die Breite des Ausgabepuffers in Pixeln.<br>Der Standardwert ist 800.
- @param Height die H\xF6he des Ausgabepuffers in Pixeln.<br>Der Standardwert ist 600.
- @param BitDepth die Bittiefe des gew\xFCnschten Ausgabepuffers in Bit.<br>Der Standardwert ist 16.
- @param BackbufferCount die Anzahl an Backbuffern die erzeugt werden soll.<br>Der Standardwert ist 2.
- @param Windowed gibt an, ob die Engine im Fenstermodus laufen soll. Falls true angegeben wird, wird ein Fenster ge\xF6ffnet in das
- die Ausgaben gerendert werden. Ansonsten wird ein Vollbildmodus gesetzt der den Parametern das Ausgabepuffers
- entspricht.
- @return Gibt false zur\xFCck, falls die Initialisierung fehlgeschlagen ist.
- @remark Der Fenstermodus sollte nur zu Debuggingzwecken benutzt werden und ist nicht daf\xFCr gedacht im endg\xFCltigen Produkt benutzt
- zu werden.
- @remark Diese Methode sollte direkt nach der Initialisierung aller Services aufgerufen werden.
- */
+ * Initialises the graphics engine and sets the screen mode. Returns true if initialisation failed.
+ * Notes: This method should be called immediately after the initialisation of all services.
+ *
+ * @param Height The height of the output buffer in pixels. The default value is 600
+ * @param BitDepth The bit depth of the desired output buffer in bits. The default value is 16
+ * @param BackbufferCount The number of back buffers to be created. The default value is 2
+ * @param Windowed Indicates whether the engine is to run in windowed mode.
+ */
virtual bool Init(int Width = 800, int Height = 600, int BitDepth = 16, int BackbufferCount = 2, bool Windowed = false) = 0;
- //@{
- /** @name Frame-Methoden */
/**
- @brief Beginnt das Rendern eines neuen Frames.
- @param UpdateAll gibt an, ob der Renderer im n\xE4chsten Frame alles neu zeichnen soll.<br>
- Diese Funktion kann n\xFCtzlich sein, wenn der Renderer mit Dirty-Rectangles arbeitet, der Benutzer aber gelegentlich
- darauf angewiesen ist, dass der gesamte Bildschirminhalt neu gezeichnet werden soll.<br>
- Der Standardwert ist false.
- Diese Methode muss am Anfang das Main-Loops aufgerufen werden und vor dem Aufruf jeglicher Rendermethoden.
- @return Gibt false zur\xFCck, falls ein Fehler aufgetreten ist.
- @remark Implementationen dieser Methode m\xFCssen _UpdateLastFrameDuration() aufrufen.
+ * Begins rendering a new frame.
+ * Notes: This method must be called at the beginning of the main loop, before any rendering methods are used.
+ * Notes: Implementations of this method must call _UpdateLastFrameDuration()
+ * @param UpdateAll Specifies whether the renderer should redraw everything on the next frame.
+ * This feature can be useful if the renderer with Dirty Rectangles works, but sometimes the client may
*/
virtual bool StartFrame(bool UpdateAll = false) = 0;
/**
- @brief Beendet das Rendern des Frames und stellt diesen auf dem Bildschirm dar.
-
- Diese Methode muss am Ende des Main-Loops aufgerufen werden. Nach dem Aufruf d\xFCrfen keine weiteren Rendermethoden mehr aufgerufen
- werden. Daf\xFCr muss erst wieder ein Aufruf von #StartFrame erfolgen.
- @return Gibt false zur\xFCck, falls ein Fehler aufgetreten ist:
+ * Ends the rendering of a frame and draws it on the screen.
+ *
+ * This method must be at the end of the main loop. After this call, no further Render method may be called.
+ * This should only be called once for a given previous call to #StartFrame.
*/
virtual bool EndFrame() = 0;
- //@}
-
- //@{
- /** @name Debug-Methoden */
+ // Debug methods
/**
- @brief Zeichnet eine Line in den Framebuffer.
-
- Diese Methode muss zwischen StartFrame() und EndFrame() aufgerufen werden und ist nur f\xFCr Debugzwecke gedacht.
- Die Linie erscheint nur f\xFCr einen Frame. Wenn die Linie dauerhaft zu sehen sein soll, muss sie jeden Frame neu
- gezeichnet werden.
-
- @param Start der Startpunkt der Linie
- @param End der Endpunkt der Linie
- @param Color die Farbe der Linie. Der Standardwert ist BS_RGB(255, 255, 255) (Wei\xDF).
+ * Draws a line in the frame buffer
+ *
+ * This method must be called between calls to StartFrame() and EndFrame(), and is intended only for debugging
+ * purposes. The line will only appear for a single frame. If the line is to be shown permanently, it must be
+ * called for every frame.
+ * @param Start The starting point of the line
+ * @param End The ending point of the line
+ * @param Color The colour of the line. The default is BS_RGB (255,255,255) (White)
*/
- virtual void DrawDebugLine(const BS_Vertex & Start, const BS_Vertex & End, unsigned int Color = BS_RGB(255, 255, 255)) = 0;
+ virtual void DrawDebugLine(const BS_Vertex &Start, const BS_Vertex &End, unsigned int Color = BS_RGB(255, 255, 255)) = 0;
/**
- @brief Erstellt einen Screenshot.
-
- Erstellt einen Screenshot vom aktuellen Framebuffer und schreibt ihn in eine Grafikdatei.<br>
- Das verwendete Dateiformat ist PNG.
-
- @param Der Dateiname des Screenshots.
- @return Gibt true zur\xFCck, wenn der Screenshot gespeichert werden konnte, ansonsten false.
- @remark Diese Methode darf erst nach einem Aufruf von EndFrame() und vor dem n\xE4chsten Aufruf von StartFrame() aufgerufen werden.
- */
+ * Creates a screenshot of the current frame buffer and writes it to a graphic file in PNG format.
+ * Returns true if the screenshot was saved successfully.
+ * Notes: This method should only be called after a call to EndFrame(), and before the next call to StartFrame().
+ * @param Filename The filename for the screenshot
+ */
bool SaveScreenshot(const std::string & Filename);
/**
- @Brief Erstellt einen kleinen Screenshot.
-
- Erstellt einen Screenshot mit den Ma\xDFen 200x125. Hierf\xFCr werden am oberen und unteren Bildschirmrand die Interfaceleisten abgeschnitten und
- das Bild auf ein 16tel seiner Ursprungsgr\xF6\xDFe verkleinert.
-
- @param Der Dateiname des Screenshots.
- @return Gibt true zur\xFCck, wenn der Screenshot gespeichert werden konnte, ansonsten false.
- @remark Diese Methode darf erst nach einem Aufruf von EndFrame() und vor dem n\xE4chsten Aufruf von StartFrame() aufgerufen werden.
- @remark Der Framebuffer muss eine Aufl\xF6sung von 800x600 haben.
- */
+ * Creates a thumbnail with the dimensions of 200x125. This will not include the top and bottom of the screen..
+ * the interface boards the the image as a 16th of it's original size.
+ * Notes: This method should only be called after a call to EndFrame(), and before the next call to StartFrame().
+ * The frame buffer must have a resolution of 800x600.
+ * @param Filename The filename for the screenshot
+ */
bool SaveThumbnailScreenshot(const std::string & Filename);
/**
- @brief Liest den aktuellen Inhalt des Framebuffer aus.
- @param Width enth\xE4lt nach einem erfolgreichen Aufruf die Breite des Framebuffers.
- @param Height enth\xE4lt nach einem erfolgreichen Aufruf die H\xF6he des Framebuffers.
- @param Data enth\xE4lt nach einem erfolgreichen Aufruf den Inhalt des Framebuffers als 32-Bit Farbwerte.
- @return Gibt true zur\xFCck, wenn der Aufruf erfolgreich war, ansonsten false.
- @remark Diese Methode ist f\xFCr das Erstellen von Screenshots gedacht. Sie muss also nicht sehr effizient sein.
- @remark Diese Methode darf erst nach einem Aufruf von EndFrame() und vor dem n\xE4chsten Aufruf von StartFrame() aufgerufen werden.
+ * Reads the current contents of the frame buffer
+ * Notes: This method is for creating screenshots. It is not very optimised. It should only be called
+ * after a call to EndFrame(), and before the next call to StartFrame().
+ * @param Width Returns the width of the frame buffer
+ * @param Height Returns the height of the frame buffer
+ * @param Data Returns the raw data of the frame buffer as an array of 32-bit colour values.
*/
virtual bool GetScreenshot(unsigned int & Width, unsigned int & Height, std::vector<unsigned int> & Data) = 0;
- //@}
virtual BS_RenderObjectPtr<BS_Panel> GetMainPanel() = 0;
/**
- @brief Gibt die Zeit (in Microsekunden) zur\xFCck die seit dem letzten Frame vergangen ist.
- */
+ * Specifies the time (in microseconds) since the last frame has passed
+ */
int GetLastFrameDurationMicro() { if (m_TimerActive) return m_LastFrameDuration; else return 0; }
/**
- @brief Gibt die Zeit (in Sekunden) zur\xFCck die seit dem letzten Frame vergangen ist.
+ * Specifies the time (in microseconds) the previous frame took
*/
float GetLastFrameDuration() { if (m_TimerActive) return static_cast<float>(m_LastFrameDuration) / 1000000.0f; else return 0; }
@@ -228,85 +204,71 @@
void ResumeMainTimer() { m_TimerActive = true; }
float GetSecondaryFrameDuration() { return static_cast<float>(m_LastFrameDuration) / 1000000.0f; }
- //@{
- /** @name Accessor-Methoden */
+ // Accessor methods
/**
- @brief Gibt die Breite des Ausgabepuffers in Pixeln zur\xFCck.
- */
+ * Returns the width of the output buffer in pixels
+ */
int GetDisplayWidth() { return m_Width; }
/**
- @brief Gibt die H\xF6he des Ausgabepuffers in Pixeln zur\xFCck.
- */
+ * Returns the height of the output buffer in pixels
+ */
int GetDisplayHeight() { return m_Height; }
/**
- @brief Gibt die Bounding-Box des Ausgabepuffers zur\xFCck. (0, 0, Width, Height)
- */
+ * Returns the bounding box of the output buffer: (0, 0, Width, Height)
+ */
BS_Rect& GetDisplayRect() { return m_ScreenRect; }
/**
- @brief Gibt die Bittiefe des Ausgabepuffers zur\xFCck.
- */
+ * Returns the bit depth of the output buffer
+ */
int GetBitDepth() { return m_BitDepth; }
/**
- @brief Legt fest ob der Framebufferwechsel mit dem vertikalen Strahlenr\xFCcklauf synchronisiert werden soll.<br>
- Vsync ist standardm\xE4\xDFig eingeschaltet.
- @param Vsync gibt an, ob der Framebufferwechsel mit dem vertikalen Strahlenr\xFCcklauf synchronisiert werden soll.
- @remark Im Fenstermodus hat diese Einstellung keine Auswirkung.
- */
+ * Determines whether the frame buffer change is to be synchronised with Vsync. This is turned on by default.
+ * Notes: In windowed mode, this setting has no effect.
+ * @param Vsync Indicates whether the frame buffer changes are to be synchronised with Vsync.
+ */
virtual void SetVsync(bool Vsync) = 0;
/**
- @brief Gibt true zur\xFCck, wenn V-Sync an ist.
- @remark Im Fenstermodus hat diese Einstellung keine Auswirkung.
- */
+ * Returns true if V-Sync is on.
+ * Notes: In windowed mode, this setting has no effect.
+ */
virtual bool GetVsync() const = 0;
/**
- @brief Gibt true zur\xFCck, falls die Engine im Fenstermodus l\xE4uft.
- */
+ * Returns true if the engine is running in Windowed mode.
+ */
bool IsWindowed() { return m_Windowed; }
/**
- @brief F\xFCllt einen Rechteckigen Bereich des Framebuffers mit einer Farbe.
- @param FillRectPtr Pointer auf ein BS_Rect, welches den Ausschnitt des Framebuffers spezifiziert, der gef\xFCllt
- werden soll oder 0, falls das gesamte Bild gef\xFCllt werden soll.<br>
- Der Standardwert ist 0.
- @param Color der 32 Bit Farbwert mit dem der Bildbereich gef\xFCllt werden soll.<br>
- Der Standardwert ist BS_RGB(0, 0, 0) (Schwarz).
- @return Gibt true zur\xFCck, wenn der Aufruf erfolgreich war, ansonsten false.
- @remark Es ist m\xF6glich \xFCber die Methode transparente Rechtecke darzustellen, indem man eine Farbe mit einem
- Alphawert ungleich 255 angibt.
+ * Fills a rectangular area of the frame buffer with a colour.
+ * Notes: It is possible to create transparent rectangles by passing a colour with an Alpha value of 255.
+ * @param FillRectPtr Pointer to a BS_Rect, which specifies the section of the frame buffer to be filled.
+ * If the rectangle falls partly off-screen, then it is automatically trimmed.
+ * If a NULL value is passed, then the entire image is to be filled.
+ * @param Color The 32-bit colour with which the area is to be filled. The default is BS_RGB(0, 0, 0) (black)
@remark Falls das Rechteck nicht v\xF6llig innerhalb des Bildschirms ist, wird es automatisch zurechtgestutzt.
- */
+ */
virtual bool Fill(const BS_Rect * FillRectPtr = 0, unsigned int Color = BS_RGB(0, 0, 0)) = 0;
- //@}
+ // Debugging Methods
- //@{
- /** @name Debugging-Methoden */
-
int GetFPSCount() const { return m_FPSCounter.GetFPS(); }
int GetRepaintedPixels() const { return m_RepaintedPixels; }
- //@}
+ // Access methods
- //@{
- /** @name Auskunfts-Methoden */
-
/**
- @brief Gibt die Gr\xF6\xDFe eines Pixeleintrages in Byte f\xFCr ein bestimmtes Farbformat zur\xFCck
- @param ColorFormat das gew\xFCnschte Farbformat. Der Parameter muss vom Typ COLOR_FORMATS sein.
- @return Gibt die Gr\xF6\xDFe eines Pixeleintrages in Byte des Farbsformates ColorFormat zur\xFCck.<br>
- Falls das Farbformat unbekannt ist, wird -1 zur\xFCckgegeben.
- */
- static int GetPixelSize(BS_GraphicEngine::COLOR_FORMATS ColorFormat)
- {
- switch (ColorFormat)
- {
+ * Returns the size of a pixel entry in bytes for a particular colour format
+ * @param ColorFormat The desired colour format. The parameter must be of type COLOR_FORMATS
+ * @return Returns the size of a pixel in bytes. If the colour format is unknown, -1 is returned.
+ */
+ static int GetPixelSize(BS_GraphicEngine::COLOR_FORMATS ColorFormat) {
+ switch (ColorFormat) {
case BS_GraphicEngine::CF_RGB16:
case BS_GraphicEngine::CF_RGB15:
return 2;
@@ -323,16 +285,14 @@
}
/**
- @brief Berechnet die L\xE4nge einer Bildzeile eines Bilder in Byte, abh\xE4ngig vom Farbformat.
- @param ColorFormat das Farbformat des Bildes.
- @param Width die L\xE4nge einer Bildzeile in Pixel.
- @return Gibt die L\xE4nge einer Bildzeile in Byte wieder.<br>
- Falls das Farbformat unbekannt ist, wird -1 zur\xFCckgegeben.
- */
- static int CalcPitch(BS_GraphicEngine::COLOR_FORMATS ColorFormat, int Width)
- {
- switch (ColorFormat)
- {
+ * Calculates the length of an image line in bytes, depending on a given colour format.
+ * @param ColorFormat The colour format
+ * @param Width The width of the line in pixels
+ * @return Reflects the length of the line in bytes. If the colour format is
+ * unknown, -1 is returned
+ */
+ static int CalcPitch(BS_GraphicEngine::COLOR_FORMATS ColorFormat, int Width) {
+ switch (ColorFormat){
case BS_GraphicEngine::CF_RGB16:
case BS_GraphicEngine::CF_RGB15:
return Width * 2;
@@ -352,22 +312,20 @@
return -1;
}
- //@}
-
- // Persistenz Methoden
+ // Persistence Methods
// -------------------
- virtual bool Persist(BS_OutputPersistenceBlock & Writer);
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer);
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
- static void ARGBColorToLuaColor(lua_State * L, unsigned int Color);
- static unsigned int LuaColorToARGBColor(lua_State * L, int StackIndex);
+ static void ARGBColorToLuaColor(lua_State *L, unsigned int Color);
+ static unsigned int LuaColorToARGBColor(lua_State *L, int StackIndex);
protected:
- // Konstruktor
+ // Constructor
// -----------
BS_GraphicEngine(BS_Kernel* pKernel);
- // Display Variablen
+ // Display Variables
// -----------------
int m_Width;
int m_Height;
@@ -375,27 +333,29 @@
int m_BitDepth;
bool m_Windowed;
- // Debugging-Variablen
+ // Debugging Variables
// -------------------
BS_Framecounter m_FPSCounter;
unsigned int m_RepaintedPixels;
/**
- @brief Berechnet die Zeit die seit dem letzten Framebeginn vergangen ist.
- */
+ * Calculates the time since the last frame beginning has passed.
+ */
void UpdateLastFrameDuration();
private:
bool RegisterScriptBindings();
- // LastFrameDuration-Variablen
+ // LastFrameDuration Variables
// ---------------------------
- uint64_t m_LastTimeStamp;
+ uint64 m_LastTimeStamp;
unsigned int m_LastFrameDuration;
bool m_TimerActive;
- std::vector<unsigned int> m_FrameTimeSamples;
+ Common::Array<unsigned int> m_FrameTimeSamples;
unsigned int m_FrameTimeSampleSlot;
};
+} // End of namespace Sword25
+
#endif
Modified: scummvm/trunk/engines/sword25/input/inputengine.h
===================================================================
--- scummvm/trunk/engines/sword25/input/inputengine.h 2010-10-12 21:54:43 UTC (rev 53183)
+++ scummvm/trunk/engines/sword25/input/inputengine.h 2010-10-12 21:55:38 UTC (rev 53184)
@@ -1,30 +1,34 @@
-// -----------------------------------------------------------------------------
-// This file is part of Broken Sword 2.5
-// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsd\xF6rfer
-//
-// Broken Sword 2.5 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.
-//
-// Broken Sword 2.5 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 Broken Sword 2.5; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// -----------------------------------------------------------------------------
+/* 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.
-/**
- BS_InputEngine
- -------------
- Dies ist das Inputengine Interface, dass alle Methoden enth\xE4lt, die eine Inputengine implementieren muss.
- Implementationen der Inputengine m\xFCssen von dieser Klasse abgeleitet werden.
+ * 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.
- Autor: Alex Arnst
-**/
+ * 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ * BS_InputEngine
+ * -------------
+ * This is the input interface engine that contains all the methods that an
+ * input source must implement.
+ * All input engines must be derived from this class.
+ *
+ * Autor: Alex Arnst
+ */
#ifndef SWORD25_INPUTENGINE_H
#define SWORD25_INPUTENGINE_H
@@ -34,17 +38,18 @@
#include "sword25/kernel/service.h"
#include "sword25/kernel/persistable.h"
-/// Klassendefinition
-class BS_InputEngine : public BS_Service, public BS_Persistable
-{
+namespace Sword25 {
+
+/// Class definitions
+
+class BS_InputEngine : public BS_Service, public BS_Persistable {
public:
BS_InputEngine(BS_Kernel* pKernel);
virtual ~BS_InputEngine(){};
- // ACHTUNG: Diese Codes werden in inputengine_script.cpp beim Skript-Service registriert. Bei \xC4nderungen an diesem Enum muss auch diese
- // Datei angepasst werden.
- enum KEY_CODES
- {
+ // NOTE: These codes are registered in inputengine_script.cpp
+ // Any changes to these enums must also adjust the above file.
+ enum KEY_CODES {
KEY_BACKSPACE = 0x08,
KEY_TAB = 0x09,
KEY_CLEAR = 0x0C,
@@ -136,10 +141,9 @@
KEY_RCONTROL = 0xA3
};
- // ACHTUNG: Diese Codes werden in inputengine_script.cpp beim Skript-Service registriert. Bei \xC4nderungen an diesem Enum muss auch diese
- // Datei angepasst werden.
- enum KEY_COMMANDS
- {
+ // NOTE: These codes are registered in inputengine_script.cpp.
+ // Any changes to these enums must also adjust the above file.
+ enum KEY_COMMANDS {
KEY_COMMAND_ENTER = 1,
KEY_COMMAND_LEFT = 2,
KEY_COMMAND_RIGHT = 3,
@@ -152,133 +156,131 @@
};
/// --------------------------------------------------------------
- /// DIESE METHODEN M\xDCSSEN VON DER INPUTENGINE IMPLEMENTIERT WERDEN
+ /// THESE METHODS MUST BE IMPLEMENTED BY THE INPUT ENGINE
/// --------------------------------------------------------------
/**
- @brief Initialisiert die Inputengine
- @return Gibt bei Erfolg true zur\xFCck, ansonsten false.
- */
+ * Initialises the input engine
+ * @return Returns a true on success, otherwise false.
+ */
virtual bool Init() = 0;
/**
- @brief F\xFChrt einen "Tick" der Input-Engine aus
-
- Diese Methode sollte mindestens ein mal pro Frame aufgerufen werden. Sie dient dazu Implementationen der
- Input-Engine zu erm\xF6glichen, die nicht in einem eigenen Thread laufen oder zus\xE4tzliche Verwaltungsaufgaben
- durchf\xFChren m\xFCssen.
- */
+ * Performs a "tick" of the input engine.
+ *
+ * This method should be called once per frame. It can be used by implementations
+ * of the input engine that are not running in their own thread, or to perform
+ * additional administrative tasks that are needed.
+ */
virtual void Update() = 0;
/**
- @brief Gibt true zur\xFCck, wenn die linke Maustaste gedr\xFCckt ist.
- */
+ * Returns true if the left mouse button is pressed
+ */
virtual bool IsLeftMouseDown() = 0;
/**
- @brief Gibt true zur\xFCck, wenn die rechte Maustaste gedr\xFCckt ist.
+ * Returns true if the right mouse button is pressed.
*/
virtual bool IsRightMouseDown() = 0;
/**
- @brief Gibt true zur\xFCck, wenn die linke Maustaste gedr\xFCckt und losgelassen wurde.
-
- Der Unterschied zu IsLeftMouseDown() besteht darin, dass erst true zur\xFCckgegegen wird, wenn der Tastendruck beendet ist, die Taste also
- wieder losgelassen wurde.
+ * Returns true if the left mouse button was pressed and released.
+ *
+ * The difference between this and IsLeftMouseDown() is that this only returns
+ * true when the left mouse button is released.
*/
virtual bool WasLeftMouseDown() = 0;
/**
- @brief Gibt true zur\xFCck, wenn die linke Maustaste gedr\xFCckt und losgelassen wurde.
-
- Der Unterschied zu IsRightMouseDown() besteht darin, dass erst true zur\xFCckgegegen wird, wenn der Tastendruck beendet ist, die Taste also
- wieder losgelassen wurde.
+ * Returns true if the right mouse button was pressed and released.
+ *
+ * The difference between this and IsRightMouseDown() is that this only returns
+ * true when the right mouse button is released.
*/
virtual bool WasRightMouseDown() = 0;
/**
- @brief Gibt true zur\xFCck wenn mit der linken Maustaste ein Doppelklick ausgel\xF6st wurde.
- */
+ * Returns true if the left mouse button double click was done
+ */
virtual bool IsLeftDoubleClick() = 0;
/**
- @brief Gibt die Position des Mauszeigers auf der X-Achse in Pixeln zur\xFCck.
+ * Returns the X position of the cursor in pixels
*/
virtual int GetMouseX() = 0;
/**
- @brief Gibt die Position des Mauszeigers auf der Y-Achse in Pixeln zur\xFCck.
- */
+ * Returns the Y position of the cursor in pixels
+ */
virtual int GetMouseY() = 0;
/**
- @brief Setzt die Position des Mauszeigers auf der X-Achse in Pixeln.
- */
+ * Sets the X position of the cursor in pixels
+ */
virtual void SetMouseX(int PosX) = 0;
/**
- @brief Setzt die Position des Mauszeigers auf der Y-Achse in Pixeln.
- */
+ * Sets the Y position of the cursor in pixels
+ */
virtual void SetMouseY(int PosY) = 0;
/**
- @brief Gibt true zur\xFCck wenn eine bestimmte Taste gedr\xFCckt ist.
- @param KeyCode der Key-Code der zu testenden Taste
- @return Gibt true zur\xFCck, wenn die Taste mit dem \xFCbergebenen Key-Code gedr\xFCckt ist, ansonsten false.
- */
+ * Returns true if a given key was pressed
+ * @param KeyCode The key code to be checked
+ * @return Returns true if the given key is done, otherwise false.
+ */
virtual bool IsKeyDown(unsigned int KeyCode) = 0;
/**
- @brief Gibt true zur\xFCck wenn eine bestimmte Taste ger\xFCckt und losgelassen wurde.
-
- Der Unterschied zu IsKeyDown() besteht darin, dass erst true zur\xFCckgegegen wird, wenn der Tastendruck beendet ist, die Taste also
- wieder losgelassen wurde. Diese Methode erleichtert das Abfragen von Funktionstasten und das Einlesen von Zeichenketten, die vom
- Benutzer getippt werden.
-
- @param KeyCode der Key-Code der zu testenden Taste
- */
+ * Returns true if a certain key was pushed and released.
+ *
+ * The difference between IsKeyDown() is that this only returns true after the key
+ * has been released. This method facilitates the retrieval of keys, and reading
+ * strings that users type.
+ * @param KeyCode The key code to be checked
+ */
virtual bool WasKeyDown(unsigned int KeyCode) = 0;
typedef void (*CharacterCallback)(unsigned char Character);
/**
- @brief Registriert eine Callbackfunktion f\xFCr die Eingabe von Buchstaben.
-
- Die Callbacks, die mit dieser Funktion registriert werden, werden immer dann aufgerufen, wenn der Input-Service eine Buchstabeneingabe
- feststellt. Eine Buchstabeneingabe unterscheidet sich von der Abfrage mittels der Methoden IsKeyDown() und WasKeyDown() in der Hinsicht,
- dass statt Scan-Coded tats\xE4chliche Buchstaben behandelt werden. Dabei wurden unter anderem Ber\xFCcksichtigt:des Tastaturlayout, der Zustand
- der Shift und Caps Lock Tasten und die Wiederholung durch l\xE4ngeres Halten der Taste.<br>
- Die Eingabe von Zeichenketten durch den Benutzer sollte durch Benutzung dieses Callbacks realisiert werden.
-
- @return Gibt true zur\xFCck, wenn die Funktion registriert werden konnte, ansonsten false.
+ * Registers a callback function for keyboard input.
+ *
+ * The callbacks that are registered with this function will be called whenever an
+ * input key is pressed. A letter entry is different from the query using the
+ * methods IsKeyDown () and WasKeyDown () in the sense that are treated instead
+ * of actual scan-coded letters. These were taken into account, among other things:
+ * the keyboard layout, the condition the Shift and Caps Lock keys and the repetition
+ * of longer holding the key.
+ * The input of strings by the user through use of callbacks should be implemented.
+ * @return Returns true if the function was registered, otherwise false.
*/
virtual bool RegisterCharacterCallback(CharacterCallback Callback) = 0;
/**
- @brief Deregistriert eine Callbackfunktion f\xFCr die Eingabe von Buchstaben.
-
- @return Gibt true zur\xFCck, wenn die Funktion deregistriert werden konnte, ansonsten false.
- */
+ * De-registeres a previously registered callback function.
+ * @return Returns true if the function could be de-registered, otherwise false.
+ */
virtual bool UnregisterCharacterCallback(CharacterCallback Callback) = 0;
typedef void (*CommandCallback)(KEY_COMMANDS Command);
/**
- @brief Registriert eine Callbackfunktion f\xFCr die Eingabe von Kommandos, die auf die Zeichenketteneingabe Einfluss haben k\xF6nnen.
-
- Die Callbacks, die mit dieser Funktion registriert werden , werden immer dann aufgerufen, wenn der Input-Service einen Tastendruck
- feststellt, der die Zeichenketteneingabe beeinflussen kann. Dies k\xF6nnten folgende Tasten sein: Enter, Pos 1, Ende, Links, Rechts, ...<br>
- Die Eingabe von Zeichenketten durch den Benutzer sollte durch Benutzung dieses Callbacks realisiert werden.
-
- @return Gibt true zur\xFCck, wenn die Funktion registriert werden konnte, ansonsten false.
- */
+ * Registers a callback function for the input of commands that can have influence on the string input
+ *
+ * The callbacks that are registered with this function will be called whenever the input service
+ * has a key that affects the character string input. This could be the following keys:
+ * Enter, End, Left, Right, ...
+ * The input of strings by the user through the use of callbacks should be implemented.
+ * @return Returns true if the function was registered, otherwise false.
+ */
virtual bool RegisterCommandCallback(CommandCallback Callback) = 0;
/**
- @brief Deregistriert eine Callbackfunktion f\xFCr die Eingabe von Kommandos, die auf die Zeichenketteneingabe Einfluss haben k\xF6nnen.
-
- @return Gibt true zur\xFCck, wenn die Funktion deregistriert werden konnte, ansonsten false.
- */
+ * Un-register a callback function for the input of commands that can have an influence on the string input.
+ * @return Returns true if the function could be de-registered, otherwise false.
+ */
virtual bool UnregisterCommandCallback(CommandCallback Callback) = 0;
virtual void ReportCharacter(unsigned char Character) = 0;
@@ -288,4 +290,6 @@
bool _RegisterScriptBindings();
};
+} // End of namespace Sword25
+
#endif
Modified: scummvm/trunk/engines/sword25/kernel/bs_stdint.h
===================================================================
--- scummvm/trunk/engines/sword25/kernel/bs_stdint.h 2010-10-12 21:54:43 UTC (rev 53183)
+++ scummvm/trunk/engines/sword25/kernel/bs_stdint.h 2010-10-12 21:55:38 UTC (rev 53184)
@@ -1,17 +1,20 @@
+// TODO: Properly replace all game occurances that use these types with proper ScummVM types, and remove this file
+
#ifndef SWORD25_STDINT_H
#define SWORD25_STDINT_H
-#ifdef _MSC_VER
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int16 uint16_t;
- typedef unsigned __int32 uint32_t;
- typedef unsigned __int64 uint64_t;
- typedef signed __int8 int8_t;
- typedef signed __int16 int16_t;
- typedef signed __int32 int32_t;
- typedef signed __int64 int64_t;
-#else
- #include <stdint.h>
-#endif
+#include "common/scummsys.h"
+typedef uint8 uint8_t;
+typedef uint16 uint16_t;
+typedef uint32 uint32_t;
+typedef int8 int8_t;
+typedef int16 int16_t;
+typedef int32 int32_t;
+
+typedef unsigned long long uint64_t;
+typedef signed long long int64_t;
+typedef unsigned long long uint64;
+typedef signed long long int64;
+
#endif
Modified: scummvm/trunk/engines/sword25/kernel/common.h
===================================================================
--- scummvm/trunk/engines/sword25/kernel/common.h 2010-10-12 21:54:43 UTC (rev 53183)
+++ scummvm/trunk/engines/sword25/kernel/common.h 2010-10-12 21:55:38 UTC (rev 53184)
@@ -1,41 +1,44 @@
-// -----------------------------------------------------------------------------
-// This file is part of Broken Sword 2.5
-// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsd\xF6rfer
-//
-// Broken Sword 2.5 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.
-//
-// Broken Sword 2.5 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 Broken Sword 2.5; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// -----------------------------------------------------------------------------
+/* 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.
-/*
- common.h
- -----------
- Diese Datei enth\xE4lt Funktionen und Makros, die im gesamten Projekt bekannt sein m\xFCssen.
- Daher ist es \xE4u\xDFerst wichtig, dass diese Headerdatei in jede andere Headerdatei des Projektes
- eingef\xFCgt wird.
+ * 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.
- Autor: Malte Thiesen
-*/
+ * 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ * common.h
+ * -----------
+ * This file contains functions or macros that are used across the entire project.
+ * It is therefore extremely important that this header file be referenced in all
+ * the other header files in the project.
+ *
+ * Autor: Malte Thiesen
+ */
#ifndef SWORD25_COMMON_H
#define SWORD25_COMMON_H
-// Globale Konstanten
+// Global constants
#if _DEBUG && !DEBUG
#define DEBUG
#endif
-#define BS_ACTIVATE_LOGGING // Wenn definiert, wird Logging aktiviert
+#define BS_ACTIVATE_LOGGING // When defined, logging is activated
// Engine Includes
#include "sword25/kernel/memleaks.h"
Modified: scummvm/trunk/engines/sword25/kernel/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sword25/kernel/kernel.cpp 2010-10-12 21:54:43 UTC (rev 53183)
+++ scummvm/trunk/engines/sword25/kernel/kernel.cpp 2010-10-12 21:55:38 UTC (rev 53184)
@@ -1,112 +1,89 @@
-// -----------------------------------------------------------------------------
-// This file is part of Broken Sword 2.5
-// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsd\xF6rfer
-//
-// Broken Sword 2.5 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.
-//
-// Broken Sword 2.5 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 Broken Sword 2.5; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// -----------------------------------------------------------------------------
+/* 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.
-#define WIN32_LEAN_AND_MEAN
-#define NOMINMAX
-#include <windows.h>
-#include <psapi.h>
-#pragma comment(lib, "psapi.lib")
+ * 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.
-#include <math.h>
-#include <algorithm>
+ * 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+#include "common/system.h"
+#include "sword25/gfx/graphicengine.h"
+#include "sword25/fmv/movieplayer.h"
+#include "sword25/input/inputengine.h"
#include "sword25/kernel/kernel.h"
-#include "sword25/kernel/timer.h"
+#include "sword25/kernel/persistenceservice.h"
#include "sword25/kernel/service_ids.h"
-
-#include "sword25/gfx/graphicengine.h"
-#include "sword25/sfx/soundengine.h"
-#include "sword25/input/inputengine.h"
#include "sword25/package/packagemanager.h"
#include "sword25/script/script.h"
-#include "sword25/fmv/movieplayer.h"
-#include "sword25/kernel/persistenceservice.h"
+#include "sword25/sfx/soundengine.h"
+namespace Sword25 {
+
#define BS_LOG_PREFIX "KERNEL"
-BS_Kernel * BS_Kernel::_Instance = 0;
+BS_Kernel *BS_Kernel::_Instance = 0;
-// Konstruktion / Destruktion
-// --------------------------
BS_Kernel::BS_Kernel() :
_pWindow(NULL),
_Running(false),
_pResourceManager(NULL),
- _InitSuccess(false)
-{
- // TODO:
- // Messagebox ausgeben wenn nicht gelogged werden kann -> log.txt schreibgesch\xFCtzt
+ _InitSuccess(false) {
+
+ // Log that the kernel is beign created
BS_LOGLN("created.");
- // Feststellen, ob der Timer unterst\xFCtzt wird.
- if (!BS_Timer::IsTimerAvaliable())
- {
- BS_LOG_ERRORLN("This machine doesn't support a performance counter.");
- return;
- }
-
- // Die BS_SERVICE_TABLE auslesen und kernelinterne Strukturen vorbereiten
- for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++)
- {
- // Ist die Superclass schon registriert?
- Superclass* pCurSuperclass = NULL;
- std::vector<Superclass*>::iterator Iter;
+ // Read the BS_SERVICE_TABLE and prepare kernel structures
+ for (uint i = 0; i < BS_SERVICE_COUNT; i++) {
+ // Is the superclass already registered?
+ Superclass *pCurSuperclass = NULL;
+ Common::Array<Superclass *>::iterator Iter;
for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter)
- if ((*Iter)->GetIdentifier() == BS_SERVICE_TABLE[i].SuperclassIdentifier)
- {
+ if ((*Iter)->GetIdentifier() == BS_SERVICE_TABLE[i].SuperclassIdentifier) {
pCurSuperclass = *Iter;
break;
}
- // Falls die Superclass noch nicht registriert war, wird dies jetzt gemacht
+ // If the superclass isn't already registered, then add it in
if (!pCurSuperclass)
_SuperclassList.push_back(new Superclass(this, BS_SERVICE_TABLE[i].SuperclassIdentifier));
}
- // Fensterobjekt erstellen
- _pWindow = BS_Window::CreateBSWindow(0,0,0,0,false);
- if (!_pWindow)
- {
+ // Create window object
+ _pWindow = BS_Window::CreateBSWindow(0, 0, 0, 0, false);
+ if (!_pWindow) {
BS_LOG_ERRORLN("Failed to create the window.");
- }
- else
+ } else
BS_LOGLN("Window created.");
- // Resource-Manager erstellen
+ // Create the resource manager
_pResourceManager = new BS_ResourceManager(this);
- // Random-Number-Generator initialisieren
- srand(GetMilliTicks());
-
- // Die Skriptengine initialisieren
- // Die Skriptengine muss bereits von Kernel und nicht vom Benutzer gestartet werden, damit der Kernel seine Funktionen bei seiner Erzeugung
- // registrieren kann.
- BS_ScriptEngine * pScript = static_cast<BS_ScriptEngine *>(NewService("script", "lua"));
- if (!pScript || !pScript->Init())
- {
+ // Initialise the script engine
+ BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(NewService("script", "lua"));
+ if (!pScript || !pScript->Init()) {
_InitSuccess = false;
return;
}
- // Scriptbindings des Kernels registrieren
- if (!_RegisterScriptBindings())
- {
+ // Register kernel script bindings
+ if (!_RegisterScriptBindings()) {
BS_LOG_ERRORLN("Script bindings could not be registered.");
_InitSuccess = false;
return;
@@ -116,24 +93,21 @@
_InitSuccess = true;
}
-BS_Kernel::~BS_Kernel()
-{
- // Services in umgekehrter Reihenfolge der Erstellung endladen.
- while (!_ServiceCreationOrder.empty())
- {
- Superclass * superclass = GetSuperclassByIdentifier(_ServiceCreationOrder.top());
+BS_Kernel::~BS_Kernel() {
+ // Services are de-registered in reverse order of creation
+ while (!_ServiceCreationOrder.empty()) {
+ Superclass *superclass = GetSuperclassByIdentifier(_ServiceCreationOrder.top());
if (superclass) superclass->DisconnectService();
_ServiceCreationOrder.pop();
}
- // Superclasslist leeren
- while (_SuperclassList.size())
- {
+ // Empty the Superclass list
+ while (_SuperclassList.size()) {
delete _SuperclassList.back();
_SuperclassList.pop_back();
}
- // Fensterobjekt freigeben
+ // Release the window object
delete _pWindow;
BS_LOGLN("Window destroyed.");
@@ -145,7 +119,8 @@
// Service Methoden
// ----------------
-BS_Kernel::Superclass::Superclass (BS_Kernel* pKernel, const std::string& Identifier) :
+
+BS_Kernel::Superclass::Superclass (BS_Kernel* pKernel, const Common::String& Identifier) :
_pKernel(pKernel),
_Identifier(Identifier),
_ServiceCount(0),
@@ -156,18 +131,24 @@
_ServiceCount++;
}
-BS_Kernel::Superclass::~Superclass()
-{
+BS_Kernel::Superclass::~Superclass() {
DisconnectService();
}
-std::string BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number)
-{
+/**
+ * Gets the identifier of a service with a given superclass.
+ * The number of services in a superclass can be learned with GetServiceCount().
+ * @param SuperclassIdentifier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
+ * @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
+ * Hierbei ist zu beachten, dass der erste Service die Nummer 0 erh\xE4lt. Number muss also eine Zahl zwischen
+ * 0 und GetServiceCount() - 1 sein.
+ */
+Common::String BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number) {
if (Number > _ServiceCount) return NULL;
unsigned int CurServiceOrd = 0;
- for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++)
- {
+ for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) {
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier)
if (Number == CurServiceOrd)
return BS_SERVICE_TABLE[i].ServiceIdentifier;
@@ -175,11 +156,19 @@
CurServiceOrd++;
}
- return std::string("");
+ return Common::String("");
}
-BS_Service* BS_Kernel::Superclass::NewService(const std::string& ServiceIdentifier)
-{
+/**
+ * Creates a new service with the given identifier. Returns a pointer to the service, or null if the
+ * service could not be created
+ * Note: All services must be registered in service_ids.h, otherwise they cannot be created here
+ * @param SuperclassIdentifier The name of the superclass of the service
+ * z.B: "sfx", "gfx", "package" ...
+ * @param ServiceIdentifier The name of the service
+ * For the superclass "sfx" an example could be "Fmod" or "directsound"
+ */
+BS_Service *BS_Kernel::Superclass::NewService(const Common::String &ServiceIdentifier) {
for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++)
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier &&
BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier)
@@ -205,10 +194,14 @@
return NULL;
}
-bool BS_Kernel::Superclass::DisconnectService()
-{
- if (_ActiveService)
- {
+/**
+ * Ends the current service of a superclass. Returns true on success, and false if the superclass
+ * does not exist or if not service was active
+ * @param SuperclassIdentfier The name of the superclass which is to be disconnected
+ * z.B: "sfx", "gfx", "package" ...
+ */
+bool BS_Kernel::Superclass::DisconnectService() {
+ if (_ActiveService) {
delete _ActiveService;
_ActiveService = 0;
BS_LOGLN("Active service '%s' disconnected from superclass '%s'.", _ActiveServiceName.c_str(), _Identifier.c_str());
@@ -218,11 +211,9 @@
return false;
}
-BS_Kernel::Superclass* BS_Kernel::GetSuperclassByIdentifier(const std::string & Identifier)
-{
- std::vector<Superclass*>::iterator Iter;
- for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter)
- {
+BS_Kernel::Superclass *BS_Kernel::GetSuperclassByIdentifier(const Common::String &Identifier) {
+ Common::Array<Superclass*>::iterator Iter;
+ for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) {
if ((*Iter)->GetIdentifier() == Identifier)
return *Iter;
}
@@ -231,48 +222,75 @@
return NULL;
}
-unsigned int BS_Kernel::GetSuperclassCount()
-{
+/**
+ * Returns the number of register superclasses
+ */
+unsigned int BS_Kernel::GetSuperclassCount() {
return _SuperclassList.size();
}
-std::string BS_Kernel::GetSuperclassIdentifier(unsigned int Number)
-{
+/**
+ * Returns the name of a superclass with the specified index.
+ * Note: The number of superclasses can be retrieved using GetSuperclassCount
+ * @param Number The number of the superclass to return the identifier for.
+ * It should be noted that the number should be between 0 und GetSuperclassCount() - 1.
+ */
+Common::String BS_Kernel::GetSuperclassIdentifier(unsigned int Number) {
if (Number > _SuperclassList.size()) return NULL;
unsigned int CurSuperclassOrd = 0;
- std::vector<Superclass*>::iterator Iter;
- for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter)
- {
+ Common::Array<Superclass*>::iterator Iter;
+ for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) {
if (CurSuperclassOrd == Number)
return ((*Iter)->GetIdentifier());
CurSuperclassOrd++;
}
- return std::string("");
+ return Common::String("");
}
-unsigned int BS_Kernel::GetServiceCount(const std::string & SuperclassIdentifier)
-{
- Superclass* pSuperclass;
- if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return 0;
+/**
+ * Returns the number of services registered with a given superclass
+ * @param SuperclassIdentifier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
+ */
+unsigned int BS_Kernel::GetServiceCount(const Common::String & SuperclassIdentifier) {
+ Superclass *pSuperclass;
+ if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier)))
+ return 0;
return pSuperclass->GetServiceCount();
}
-std::string BS_Kernel::GetServiceIdentifier(const std::string & SuperclassIdentifier, unsigned int Number)
-{
+/**
+ * Gets the identifier of a service with a given superclass.
+ * The number of services in a superclass can be learned with GetServiceCount().
+ * @param SuperclassIdentifier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
+ * @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
+ * Hierbei ist zu beachten, dass der erste Service die Nummer 0 erh\xE4lt. Number muss also eine Zahl zwischen
+ * 0 und GetServiceCount() - 1 sein.
+ */
+Common::String BS_Kernel::GetServiceIdentifier(const Common::String & SuperclassIdentifier, unsigned int Number) {
Superclass* pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL;
return (pSuperclass->GetServiceIdentifier(Number));
}
-BS_Service* BS_Kernel::NewService(const std::string& SuperclassIdentifier, const std::string& ServiceIdentifier)
-{
- Superclass* pSuperclass;
+/**
+ * Creates a new service with the given identifier. Returns a pointer to the service, or null if the
+ * service could not be created
+ * Note: All services must be registered in service_ids.h, otherwise they cannot be created here
+ * @param SuperclassIdentifier The name of the superclass of the service
+ * z.B: "sfx", "gfx", "package" ...
+ * @param ServiceIdentifier The name of the service
+ * For the superclass "sfx" an example could be "Fmod" or "directsound"
+ */
+BS_Service *BS_Kernel::NewService(const Common::String& SuperclassIdentifier, const Common::String& ServiceIdentifier) {
+ Superclass *pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL;
// Die Reihenfolge merken, in der Services erstellt werden, damit sie sp\xE4ter in umgekehrter Reihenfolge entladen werden k\xF6nnen.
@@ -281,56 +299,82 @@
return pSuperclass->NewService(ServiceIdentifier);
}
-bool BS_Kernel::DisconnectService(const std::string& SuperclassIdentifier)
-{
- Superclass* pSuperclass;
+/**
+ * Ends the current service of a superclass. Returns true on success, and false if the superclass
+ * does not exist or if not service was active
+ * @param SuperclassIdentfier The name of the superclass which is to be disconnected
+ * z.B: "sfx", "gfx", "package" ...
+ */
+bool BS_Kernel::DisconnectService(const Common::String& SuperclassIdentifier) {
+ Superclass *pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return false;
return pSuperclass->DisconnectService();
}
-BS_Service* BS_Kernel::GetService(const std::string& SuperclassIdentifier)
-{
- Superclass* pSuperclass;
+/**
+ * Returns a pointer to the currently active service object of a superclass
+ * @param SuperclassIdentfier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
+ */
+BS_Service *BS_Kernel::GetService(const Common::String& SuperclassIdentifier) {
+ Superclass *pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL;
return (pSuperclass->GetActiveService());
}
-std::string BS_Kernel::GetActiveServiceIdentifier(const std::string& SuperclassIdentifier)
-{
+/**
+ * Returns the name of the currentl active service object of a superclass.
+ * If an error occurs, then an empty string is returned
+ * @param SuperclassIdentfier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
+ */
+Common::String BS_Kernel::GetActiveServiceIdentifier(const Common::String& SuperclassIdentifier) {
Superclass * pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier);
- if (!pSuperclass) return std::string("");
+ if (!pSuperclass) return Common::String("");
return (pSuperclass->GetActiveServiceName());
}
// -----------------------------------------------------------------------------
-int BS_Kernel::GetRandomNumber(int Min, int Max)
-{
+/**
+ * Returns a random number
+ * @param Min The minimum allowed value
+ * @param Max The maximum allowed value
+ */
+int BS_Kernel::GetRandomNumber(int Min, int Max) {
BS_ASSERT(Min <= Max);
- unsigned int MaxInternal = (Min - Max + 1) < 0 ? - (Min - Max + 1) : (Min - Max + 1);
- return (rand() % MaxInternal) + Min;
+
+ return Min + _rnd.getRandomNumber(Max - Min + 1);
}
-// Timer Methoden
-// --------------
-unsigned int BS_Kernel::GetMilliTicks()
-{
- return BS_Timer::GetMilliTicks();
+/**
+ * Returns the elapsed time since startup in milliseconds
+ */
+unsigned int BS_Kernel::GetMilliTicks() {
+ return g_system->getMillis();
}
-uint64_t BS_Kernel::GetMicroTicks()
-{
- return BS_Timer::GetMicroTicks();
+/**
+ * Returns the elapsed time since the system start in microseconds.
+ * This method should be used only if GetMilliTick() for the desired application is inaccurate.
+ */
+uint64 BS_Kernel::GetMicroTicks() {
+ return g_system->getMillis() * 1000;
}
-// Sonstige Methoden
+// Other methods
// -----------------
-size_t BS_Kernel::GetUsedMemory()
-{
+/**
+ * Returns how much memory is being used
+ */
+size_t BS_Kernel::GetUsedMemory() {
+ return 0;
+
+#ifdef SCUMMVM_DISABLED_CODE
PROCESS_MEMORY_COUNTERS pmc;
pmc.cb = sizeof(pmc);
if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)))
@@ -342,53 +386,67 @@
BS_LOG_ERRORLN("Call to GetProcessMemoryInfo() failed. Error code: %d", GetLastError());
return 0;
}
+#endif
}
// -----------------------------------------------------------------------------
-BS_GraphicEngine * BS_Kernel::GetGfx()
-{
+/**
+ * Returns a pointer to the active Gfx Service, or NULL if no Gfx service is active
+ */
+BS_GraphicEngine * BS_Kernel::GetGfx() {
return static_cast<BS_GraphicEngine *>(GetService("gfx"));
}
// -----------------------------------------------------------------------------
-BS_SoundEngine * BS_Kernel::GetSfx()
-{
+/**
+ * Returns a pointer to the active Sfx Service, or NULL if no Sfx service is active
+ */
+BS_SoundEngine * BS_Kernel::GetSfx() {
return static_cast<BS_SoundEngine *>(GetService("sfx"));
}
// -----------------------------------------------------------------------------
-BS_InputEngine * BS_Kernel::GetInput()
-{
+/**
+ * Returns a pointer to the active input service, or NULL if no input service is active
+ */
+BS_InputEngine * BS_Kernel::GetInput() {
return static_cast<BS_InputEngine *>(GetService("input"));
}
// -----------------------------------------------------------------------------
-BS_PackageManager * BS_Kernel::GetPackage()
-{
+/**
+ * Returns a pointer to the active package manager, or NULL if no manager is active
+ */
+BS_PackageManager * BS_Kernel::GetPackage() {
return static_cast<BS_PackageManager *>(GetService("package"));
}
// -----------------------------------------------------------------------------
-BS_ScriptEngine * BS_Kernel::GetScript()
-{
+/**
+ * Returns a pointer to the script engine, or NULL if it is not active
+ */
+BS_ScriptEngine * BS_Kernel::GetScript() {
return static_cast<BS_ScriptEngine *>(GetService("script"));
}
// -----------------------------------------------------------------------------
-BS_MoviePlayer * BS_Kernel::GetFMV()
-{
+/**
+ * Returns a pointer to the movie player, or NULL if it is not active
+ */
+BS_MoviePlayer * BS_Kernel::GetFMV() {
return static_cast<BS_MoviePlayer *>(GetService("fmv"));
}
// -----------------------------------------------------------------------------
-void BS_Kernel::Sleep(unsigned int Msecs) const
-{
- ::Sleep(Msecs);
+void BS_Kernel::Sleep(unsigned int Msecs) const {
+ g_system->delayMillis(Msecs);
}
+
+} // End of namespace Sword25
Modified: scummvm/trunk/engines/sword25/kernel/kernel.h
===================================================================
--- scummvm/trunk/engines/sword25/kernel/kernel.h 2010-10-12 21:54:43 UTC (rev 53183)
+++ scummvm/trunk/engines/sword25/kernel/kernel.h 2010-10-12 21:55:38 UTC (rev 53184)
@@ -1,52 +1,53 @@
-// -----------------------------------------------------------------------------
-// This file is part of Broken Sword 2.5
-// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsd\xF6rfer
-//
-// Broken Sword 2.5 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.
-//
-// Broken Sword 2.5 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 Broken Sword 2.5; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// -----------------------------------------------------------------------------
+/* 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.
-/*
- BS_Kernel
- ---------
- Dies ist die Hauptklasse der Engine.
- Diese Klasse erzeugt und verwaltet alle anderen Enginelemente, wie Soundengine, Graphikengine...
- Es ist nicht notwendig alle Enginenelemente einzeln freizugeben, dieses wird von der Kernelklasse \xFCbernommen.
+ * 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.
- Autor: Malte Thiesen
-*/
+ * 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ * BS_Kernel
+ * ---------
+ * This is the main class of the engine.
+ * This class creates and manages all other Engine elements: the sound engine, graphics engine ...
+ * It is not necessary to release all the items individually, this is performed by the Kernel class.
+ *
+ * Autor: Malte Thiesen
+ */
#ifndef SWORD25_KERNEL_H
#define SWORD25_KERNEL_H
+// Includes
+#include "common/scummsys.h"
+#include "common/random.h"
+#include "common/stack.h"
#include "common/util.h"
#include "engines/engine.h"
-// Includes
-#include "sword25/kernel/memlog_off.h"
-#include <vector>
-#include <stack>
-#include <string>
-#include "sword25/kernel/memlog_on.h"
-
#include "sword25/kernel/common.h"
#include "sword25/kernel/bs_stdint.h"
#include "sword25/kernel/window.h"
#include "sword25/kernel/resmanager.h"
+namespace Sword25 {
-// Klassendefinition
+// Class definitions
class BS_Service;
class BS_GraphicEngine;
class BS_ScriptEngine;
@@ -56,244 +57,230 @@
class BS_MoviePlayer;
/**
- @brief Dies ist die Hauptklasse der Engine.
-
- Diese Klasse erzeugt und verwaltet alle anderen Engineelemente, wie Soundengine, Graphikengine...<br>
- Es ist nicht notwendig alle Enginenelemente einzeln freizugeben, dieses wird von der Kernelklasse \xFCbernommen.
+ * This is the main engine class
+ *
+ * This class creates and manages all other engine components such as sound engine, graphics engine ...
+ * It is not necessary to release all the items individually, this is performed by the Kernel class.
*/
-class BS_Kernel
-{
+class BS_Kernel {
public:
- // Fenster Methoden
+ // Window methods
// ----------------
+
/**
- @brief Gibt einen Pointer auf das Fensterobjekt zur\xFCck.
- @return Gibt einen Pointer auf das Fensterobjekt zur\xFCck.
- */
- BS_Window* GetWindow() {return _pWindow; }
+ * Returns a pointer to the window object
+ */
+ BS_Window *GetWindow() { return _pWindow; }
- // Service Methoden
- // ----------------
+ // Service Methods
+ // ---------------
/**
- @brief Erzeugt einen neuen Service der angegebenen Superclass mit dem \xFCbergebenen Identifier.
- @param SuperclassIdentifier der Name der Superclass des Services<br>
- z.B: "sfx", "gfx", "package" ...
- @param ServiceIdentifier der Name des Services<br>
- F\xFCr die Superclass "sfx" k\xF6nnten das z.B. "fmod" oder "directsound" sein.
- @return Gibt einen Pointer auf den Service zur\xFCck, oder NULL wenn der Service nicht erstellt werden konnte.
- @remark Alle Services m\xFCssen in service_ids.h eingetragen sein, sonst k\xF6nnen sie hier nicht erstellt werden.
- */
- BS_Service* NewService(const std::string & SuperclassIdentifier, const std::string & ServiceIdentifier);
+ * Creates a new service with the given identifier. Returns a pointer to the service, or null if the
+ * service could not be created
+ * Note: All services must be registered in service_ids.h, otherwise they cannot be created here
+ * @param SuperclassIdentifier The name of the superclass of the service
+ * z.B: "sfx", "gfx", "package" ...
+ * @param ServiceIdentifier The name of the service
+ * For the superclass "sfx" an example could be "Fmod" or "directsound"
+ */
+ BS_Service *NewService(const Common::String &SuperclassIdentifier, const Common::String &ServiceIdentifier);
+
/**
- @brief Beendet den aktuellen Service einer Superclass.
- @param SuperclassIdentfier der Name der Superclass dessen aktiver Service beendet werden soll<br>
- z.B: "sfx", "gfx", "package" ...
- @return Gibt bei Erfolg true zur\xFCck und false wenn die Superclass nicht existiert oder wenn kein Service aktiv war.
- */
- bool DisconnectService(const std::string & SuperclassIdentifier);
+ * Ends the current service of a superclass. Returns true on success, and false if the superclass
+ * does not exist or if not service was active
+ * @param SuperclassIdentfier The name of the superclass which is to be disconnected
+ * z.B: "sfx", "gfx", "package" ...
+ */
+ bool DisconnectService(const Common::String &SuperclassIdentifier);
/**
- @brief Gibt einen Pointer auf das momentan aktive Serviceobjekt einer Superclass zur\xFCck.
- @param SuperclassIdentfier der Name der Superclass<br>
- z.B: "sfx", "gfx", "package" ...
- @return Gibt einen Pointer auf den Service zur\xFCck, oder NULL wenn kein Service aktiv war.
- */
- BS_Service* GetService(const std::string& SuperclassIdentifier);
+ * Returns a pointer to the currently active service object of a superclass
+ * @param SuperclassIdentfier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
+ */
+ BS_Service *GetService(const Common::String &SuperclassIdentifier);
/**
- @brief Gibt den Namen des aktuell aktiven Serviceobjektes einer Superclass zur\xFCck.
- @param SuperclassIdentfier der Name der Superclass<br>
- z.B: "sfx", "gfx", "package" ...
- @return Gibt den Namen des Serviceobjektes zur\xFCck, oder einen leeren String, wenn ein Fehler aufgetreten ist.
- */
- std::string GetActiveServiceIdentifier(const std::string& SuperclassIdentifier);
+ * Returns the name of the currentl active service object of a superclass.
+ * If an error occurs, then an empty string is returned
+ * @param SuperclassIdentfier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
+ */
+ Common::String GetActiveServiceIdentifier(const Common::String &SuperclassIdentifier);
/**
- @brief Gibt die Anzahl der Registrierten Superclasses zur\xFCck.
- @return Gibt die Anzahl der Registrierten Superclasses zur\xFCck.
- */
+ * Returns the number of register superclasses
+ */
unsigned int GetSuperclassCount();
- // Gibt den Identifier der mit Number bezeichneten Superclass zur\xFCck
/**
- @brief Gibt den Identifier einer Superclass zur\xFCck.
- @param Number die Nummer der Superclass, dessen Bezeichner man erfahren m\xF6chte<br>
- Hierbei ist zu beachten, dass die erste Superclass die Nummer 0 erh\xE4lt. Number muss also eine Zahl zwischen
- 0 und GetSuperclassCount() - 1 sein.
- @return Gibt den Identifier der Superclass zur\xFCck.
- @remark Die Anzahl der Superclasses kann man mit GetSuperclassCount() erfahren.
- */
- std::string GetSuperclassIdentifier(unsigned int Number);
+ * Returns the name of a superclass with the specified index.
+ * Note: The number of superclasses can be retrieved using GetSuperclassCount
+ * @param Number The number of the superclass to return the identifier for.
+ * It should be noted that the number should be between 0 und GetSuperclassCount() - 1.
+ */
+ Common::String GetSuperclassIdentifier(unsigned int Number);
- // Gibt die Anzahl der f\xFCr die mit SuperclassIdentifier bezeichneten Superclass vorhandenen
- // Services zur\xFCck
/**
- @brief Gibt die Anzahl an Services zur\xFCck, die in einer Superclass registriert sind.
- @param SuperclassIdentifier der Name der Superclass<br>
- z.B: "sfx", "gfx", "package" ...
- @return Gibt die Anzahl an Services zur\xFCck, die in der Superclass registriert sind.
- */
- unsigned int GetServiceCount(const std::string & SuperclassIdentifier);
+ * Returns the number of services registered with a given superclass
+ * @param SuperclassIdentifier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
+ */
+ unsigned int GetServiceCount(const Common::String & SuperclassIdentifier);
/**
- @brief Gibt den Identifier eines Services in einer Superclass zur\xFCck.
- @param SuperclassIdentifier der Name der Superclass<br>
- z.B: "sfx", "gfx", "package" ...
- @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
- Hierbei ist zu beachten, dass der erste Service die Nummer 0 erh\xE4lt. Number muss also eine Zahl zwischen
- 0 und GetServiceCount() - 1 sein.
- @return Gibt den Identifier des Services zur\xFCck
- @remark Die Anzahl der Services in einer Superclass kann man mit GetServiceCount() erfahren.
- */
- std::string GetServiceIdentifier(const std::string & SuperclassIdentifier, unsigned int Number);
+ * Gets the identifier of a service with a given superclass.
+ * The number of services in a superclass can be learned with GetServiceCount().
+ * @param SuperclassIdentifier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
+ * @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
+ * Hierbei ist zu beachten, dass der erste Service die Nummer 0 erh\xE4lt. Number muss also eine Zahl zwischen
+ * 0 und GetServiceCount() - 1 sein.
+ */
+ Common::String GetServiceIdentifier(const Common::String &SuperclassIdentifier, unsigned int Number);
+
/**
- @brief Gibt die vergangene Zeit seit dem Systemstart in Millisekunden zur\xFCck.
+ * Returns the elapsed time since startup in milliseconds
*/
unsigned int GetMilliTicks();
+
/**
- @brief Gibt die vergangene Zeit seit dem Systemstart in Microsekunden zur\xFCck.
- @remark Diese Methode sollte nur verwendet werden, falls GetMilliTick() f\xFCr den gew\xFCnschten Einsatz zu ungenau ist.
- */
- uint64_t GetMicroTicks();
+ * Returns the elapsed time since the system start in microseconds.
+ * This method should be used only if GetMilliTick() for the desired application is inaccurate.
+ */
+ uint64 GetMicroTicks();
+
/**
- @brief Gibt an, ob die Konstruktion erfolgreich war.
- @return Gibt true zur\xFCck, wenn die Konstruktion erfolgreich war.
+ * Specifies whether the kernel was successfully initialised
*/
bool GetInitSuccess() { return _InitSuccess; }
/**
- @brief Gibt einen Pointer auf den BS_ResourceManager zur\xFCck.
- */
- BS_ResourceManager* GetResourceManager() { return _pResourceManager; }
+ * Returns a pointer to the BS_ResourceManager
+ */
+ BS_ResourceManager *GetResourceManager() { return _pResourceManager; }
/**
- @brief Gibt zur\xFCck wie viel Speicher von diesem Prozess belegt ist.
- */
+ * Returns how much memory is being used
+ */
size_t GetUsedMemory();
/**
- @brief Gibt eine Zufallszahl zur\xFCck.
- @param Min der minimale Wert, den die Zufallszahl haben darf
- @param Max der maximale Wert, den die Zufallszahl haben darf
- @return Gibt eine Zufallszahl zur\xFCck, die zwischen Min und Max liegt.
- */
+ * Returns a random number
+ * @param Min The minimum allowed value
+ * @param Max The maximum allowed value
+ */
int GetRandomNumber(int Min, int Max);
/**
- @brief Gibt einen Pointer auf den aktiven Gfx-Service zur\xFCck oder NULL wenn kein Gfx-Service aktiv.
- */
- BS_GraphicEngine * GetGfx();
+ * Returns a pointer to the active Gfx Service, or NULL if no Gfx service is active
+ */
+ BS_GraphicEngine *GetGfx();
/**
- @brief Gibt einen Pointer auf den aktiven Sfx-Service zur\xFCck oder NULL wenn kein Sfx-Service aktiv.
- */
- BS_SoundEngine * GetSfx();
+ * Returns a pointer to the active Sfx Service, or NULL if no Sfx service is active
+ */
+ BS_SoundEngine *GetSfx();
/**
- @brief Gibt einen Pointer auf den aktiven Input-Service zur\xFCck oder NULL wenn kein Input-Service aktiv.
- */
- BS_InputEngine * GetInput();
+ * Returns a pointer to the active input service, or NULL if no input service is active
+ */
+ BS_InputEngine *GetInput();
/**
- @brief Gibt einen Pointer auf den aktiven Package-Service zur\xFCck oder NULL wenn kein Package-Service aktiv.
- */
- BS_PackageManager * GetPackage();
+ * Returns a pointer to the active package manager, or NULL if no manager is active
+ */
+ BS_PackageManager *GetPackage();
/**
- @brief Gibt einen Pointer auf den aktiven Script-Service zur\xFCck oder NULL wenn kein Script-Service aktiv.
- */
- BS_ScriptEngine * GetScript();
+ * Returns a pointer to the script engine, or NULL if it is not active
+ */
+ BS_ScriptEngine *GetScript();
/**
- @brief Gibt einen Pointer auf den aktiven FMV-Service zur\xFCck oder NULL wenn kein FMV-Service aktiv.
- */
- BS_MoviePlayer * GetFMV();
+ * Returns a pointer to the movie player, or NULL if it is not active
+ */
+ BS_MoviePlayer *GetFMV();
/**
- @brief Stoppt den Prozess f\xFCr eine gewisse Zeit.
- @param Msecs Zeit in Millisekunden, die der Prozess gestoppt werden soll.
- @remark Es wird nicht garantiert, dass der Prozess genau nach der angegebenen Zeit wieder aktiv wird.
- */
+ * Pauses for the specified amount of time
+ * @param Msecs The amount of time in milliseconds
+ */
void Sleep(unsigned int Msecs) const;
/**
- @brief Gibt das einzige Exemplar des Kernels zur\xFCck (Singleton).
- */
-
- static BS_Kernel * GetInstance()
- {
+ * Returns the singleton instance for the kernel
+ */
+ static BS_Kernel *GetInstance() {
if (!_Instance) _Instance = new BS_Kernel();
return _Instance;
}
/**
- @brief Zerst\xF6rt das einzige Exemplar des Kernels.
- @remark Diese Methode darf nur zum Beenden des System aufgerufen werden. Nachfolgende Aufrufe s\xE4mtlicher Kernelmethoden liefern
- undefinierte Ergebnisse.
- */
-
- static void DeleteInstance()
- {
- if (_Instance)
- {
- delete(_Instance);
- _Instance = 0;
+ * Destroys the kernel instance
+ * This method should only be called when the game is ended. No subsequent calls to any kernel
+ * methods should be done after calling this method.
+ */
+ static void DeleteInstance() {
+ if (_Instance) {
+ delete _Instance;
+ _Instance = NULL;
}
}
/**
- @brief L\xF6st eine Schutzverletzung aus.
- @remark Diese Methode dient zum Testen des Crash-Handlings.
- */
- void Crash() const
- {
- error(0);
+ * Raises an error. This method is used in crashing testing.
+ */
+ void Crash() const {
+ error("BS_Kernel::Crash");
}
private:
-
// -----------------------------------------------------------------------------
- // Konstruktion / Destruktion
- // Private da Singleton
+ // Constructor / destructor
+ // Private singleton methods
// -----------------------------------------------------------------------------
BS_Kernel();
virtual ~BS_Kernel();
// -----------------------------------------------------------------------------
- // Singleton-Exemplar
+ // Singleton instance
// -----------------------------------------------------------------------------
- static BS_Kernel * _Instance;
+ static BS_Kernel *_Instance;
- // Service Daten
- // -------------
- class Superclass
- {
+ // Superclass class
+ // ----------------
+ class Superclass {
private:
- BS_Kernel* _pKernel;
- unsigned int _ServiceCount;
- std::string _Identifier;
- BS_Service* _ActiveService;
- std::string _ActiveServiceName;
+ BS_Kernel *_pKernel;
+ unsigned int _ServiceCount;
+ Common::String _Identifier;
+ BS_Service *_ActiveService;
+ Common::String _ActiveServiceName;
public:
- Superclass (BS_Kernel* pKernel, const std::string& Identifier);
+ Superclass (BS_Kernel *pKernel, const Common::String &Identifier);
~Superclass();
unsigned int GetServiceCount() const { return _ServiceCount; }
- std::string GetIdentifier() const { return _Identifier; }
- BS_Service* GetActiveService() const { return _ActiveService; }
- std::string GetActiveServiceName() const { return _ActiveServiceName; }
- std::string GetServiceIdentifier(unsigned int Number);
- BS_Service* NewService(const std::string& ServiceIdentifier);
+ Common::String GetIdentifier() const { return _Identifier; }
+ BS_Service *GetActiveService() const { return _ActiveService; }
+ Common::String GetActiveServiceName() const { return _ActiveServiceName; }
+ Common::String GetServiceIdentifier(unsigned int Number);
+ BS_Service *NewService(const Common::String &ServiceIdentifier);
bool DisconnectService();
};
- std::vector<Superclass*> _SuperclassList;
- std::stack<std::string> _ServiceCreationOrder;
- Superclass* GetSuperclassByIdentifier(const std::string& Identifier);
+ Common::Array<Superclass*> _SuperclassList;
+ Common::Stack<Common::String> _ServiceCreationOrder;
+ Superclass *GetSuperclassByIdentifier(const Common::String &Identifier);
- bool _InitSuccess; // Gibt an, ob die Konstruktion erfolgreich war
- bool _Running; // Gibt an, ob die Applikation im n\xE4chsten Durchlauf des Main-Loops noch weiterlaufen soll
+ bool _InitSuccess; // Specifies whether the engine was set up correctly
+ bool _Running; // Specifies whether the application should keep running on the next main loop iteration
- // Fenster Variablen
- // -----------------
- BS_Window* _pWindow;
+ // Active window
+ // -------------
+ BS_Window *_pWindow;
+ // Random number generator
+ // -----------------------
+ Common::RandomSource _rnd;
+
/*
- // CPU-Feature Variablen und Methoden
+ // Features variables and methods
// ----------------------------------
enum _CPU_FEATURES_BITMASKS
{
@@ -312,32 +299,34 @@
bool _3DNowPresent;
bool _3DNowExtPresent;
CPU_TYPES _CPUType;
- std::string _CPUVendorID;
+ Common::String _CPUVendorID;
*/
// Resourcemanager
// ---------------
- BS_ResourceManager* _pResourceManager;
+ BS_ResourceManager *_pResourceManager;
bool _RegisterScriptBindings();
};
-// Dies ist nur eine kleine Klasse, die die Daten eines Services verwaltet.
-// Ist ein wenig unsch\xF6n, ich weiss, aber mit std::string lie\xDF sich dass nicht mit einer
-// einfachen struct bewerkstelligen.
-class BS_ServiceInfo
-{
+/**
+ * This is only a small class that manages the data of a service. It is a little ugly, I know,
+ * but with Common::String a simple struct could not be used.
+ */
+class BS_ServiceInfo {
public:
- BS_ServiceInfo(const std::string& SuperclassIdentifier_, const std::string& ServiceIdentifier_, BS_Service* (*CreateMethod_)(BS_Kernel*))
- {
+ BS_ServiceInfo(const Common::String &SuperclassIdentifier_, const Common::String& ServiceIdentifier_,
+ BS_Service* (*CreateMethod_)(BS_Kernel*)) {
this->SuperclassIdentifier = SuperclassIdentifier_;
this->ServiceIdentifier = ServiceIdentifier_;
this->CreateMethod = CreateMethod_;
};
- std::string SuperclassIdentifier;
- std::string ServiceIdentifier;
- BS_Service* (*CreateMethod)(BS_Kernel*);
+ Common::String SuperclassIdentifier;
+ Common::String ServiceIdentifier;
+ BS_Service* (*CreateMethod)(BS_Kernel *);
};
+}
+
#endif
Modified: scummvm/trunk/engines/sword25/kernel/log.cpp
===================================================================
--- scummvm/trunk/engines/sword25/kernel/log.cpp 2010-10-12 21:54:43 UTC (rev 53183)
+++ scummvm/trunk/engines/sword25/kernel/log.cpp 2010-10-12 21:55:38 UTC (rev 53184)
@@ -1,112 +1,107 @@
-// -----------------------------------------------------------------------------
-// This file is part of Broken Sword 2.5
-// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsd\xF6rfer
-//
-// Broken Sword 2.5 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.
-//
-// Broken Sword 2.5 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 Broken Sword 2.5; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// -----------------------------------------------------------------------------
+/* 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.
-#include <stdio.h>
-#include <stdarg.h>
-#include <string>
+ * 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.
-#include "sword25/kernel/filesystemutil.h"
+ * 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
#include "sword25/kernel/log.h"
-#include "sword25/kernel/debug/debugtools.h"
+#include "base/version.h"
+#include "common/config-manager.h"
+#include "common/fs.h"
-// Konstanten
-static const char* BF_LOG_FILENAME = "log.txt";
+namespace Sword25 {
+
+// Constants
+static const char *BF_LOG_FILENAME = "log.txt";
static const size_t LOG_BUFFERSIZE = 1024 * 16;
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list