From e78b19a650e27fe9a24d0e4c9c938294c7b08650 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 31 Jul 2010 06:23:38 +0000 Subject: 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. svn-id: r53184 --- engines/sword25/kernel/kernel.h | 405 +++++++++++++++++++--------------------- 1 file changed, 197 insertions(+), 208 deletions(-) (limited to 'engines/sword25/kernel/kernel.h') diff --git a/engines/sword25/kernel/kernel.h b/engines/sword25/kernel/kernel.h index 0e488eb38b..787eda4200 100755 --- a/engines/sword25/kernel/kernel.h +++ b/engines/sword25/kernel/kernel.h @@ -1,52 +1,53 @@ -// ----------------------------------------------------------------------------- -// This file is part of Broken Sword 2.5 -// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer -// -// 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 -// ----------------------------------------------------------------------------- - -/* - 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 übernommen. - - Autor: Malte Thiesen -*/ +/* 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$ + * + * 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 -#include -#include -#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_PackageManager; class BS_MoviePlayer; /** - @brief Dies ist die Hauptklasse der Engine. - - Diese Klasse erzeugt und verwaltet alle anderen Engineelemente, wie Soundengine, Graphikengine...
- Es ist nicht notwendig alle Enginenelemente einzeln freizugeben, dieses wird von der Kernelklasse übernommen. + * 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ück. - @return Gibt einen Pointer auf das Fensterobjekt zurück. - */ - 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 übergebenen Identifier. - @param SuperclassIdentifier der Name der Superclass des Services
- z.B: "sfx", "gfx", "package" ... - @param ServiceIdentifier der Name des Services
- Für die Superclass "sfx" könnten das z.B. "fmod" oder "directsound" sein. - @return Gibt einen Pointer auf den Service zurück, oder NULL wenn der Service nicht erstellt werden konnte. - @remark Alle Services müssen in service_ids.h eingetragen sein, sonst können 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
- z.B: "sfx", "gfx", "package" ... - @return Gibt bei Erfolg true zurück 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ück. - @param SuperclassIdentfier der Name der Superclass
- z.B: "sfx", "gfx", "package" ... - @return Gibt einen Pointer auf den Service zurück, 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ück. - @param SuperclassIdentfier der Name der Superclass
- z.B: "sfx", "gfx", "package" ... - @return Gibt den Namen des Serviceobjektes zurück, 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ück. - @return Gibt die Anzahl der Registrierten Superclasses zurück. - */ + * Returns the number of register superclasses + */ unsigned int GetSuperclassCount(); - // Gibt den Identifier der mit Number bezeichneten Superclass zurück /** - @brief Gibt den Identifier einer Superclass zurück. - @param Number die Nummer der Superclass, dessen Bezeichner man erfahren möchte
- Hierbei ist zu beachten, dass die erste Superclass die Nummer 0 erhält. Number muss also eine Zahl zwischen - 0 und GetSuperclassCount() - 1 sein. - @return Gibt den Identifier der Superclass zurück. - @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ür die mit SuperclassIdentifier bezeichneten Superclass vorhandenen - // Services zurück /** - @brief Gibt die Anzahl an Services zurück, die in einer Superclass registriert sind. - @param SuperclassIdentifier der Name der Superclass
- z.B: "sfx", "gfx", "package" ... - @return Gibt die Anzahl an Services zurück, 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ück. - @param SuperclassIdentifier der Name der Superclass
- z.B: "sfx", "gfx", "package" ... - @param Number die Nummer des Services, dessen Bezeichner man erfahren will.
- Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen - 0 und GetServiceCount() - 1 sein. - @return Gibt den Identifier des Services zurück - @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.
+ * Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. 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ück. + * Returns the elapsed time since startup in milliseconds */ unsigned int GetMilliTicks(); + /** - @brief Gibt die vergangene Zeit seit dem Systemstart in Microsekunden zurück. - @remark Diese Methode sollte nur verwendet werden, falls GetMilliTick() für den gewünschten 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ück, 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ück. - */ - BS_ResourceManager* GetResourceManager() { return _pResourceManager; } + * Returns a pointer to the BS_ResourceManager + */ + BS_ResourceManager *GetResourceManager() { return _pResourceManager; } /** - @brief Gibt zurück wie viel Speicher von diesem Prozess belegt ist. - */ + * Returns how much memory is being used + */ size_t GetUsedMemory(); /** - @brief Gibt eine Zufallszahl zurück. - @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ück, 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ück 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ück 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ück 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ück 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ück 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ück 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ür 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ück (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ört das einzige Exemplar des Kernels. - @remark Diese Methode darf nur zum Beenden des System aufgerufen werden. Nachfolgende Aufrufe sämtlicher 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öst 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 _SuperclassList; - std::stack _ServiceCreationOrder; - Superclass* GetSuperclassByIdentifier(const std::string& Identifier); + Common::Array _SuperclassList; + Common::Stack _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ächsten 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 @@ private: 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ön, ich weiss, aber mit std::string ließ 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 -- cgit v1.2.3