[Scummvm-cvs-logs] SF.net SVN: scummvm: [21557] scummvm/trunk/gui
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sun Apr 2 07:18:02 CEST 2006
Revision: 21557
Author: fingolfin
Date: 2006-04-02 07:16:31 -0700 (Sun, 02 Apr 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=21557&view=rev
Log Message:
-----------
With this change, backends are now responsible for instantiating their OSystem class before calling scummvm_main (Note: PalmOS and Symbian are not yet converted, and won't work currently)
Modified Paths:
--------------
scummvm/trunk/backends/dc/dc.h
scummvm/trunk/backends/dc/dcmain.cpp
scummvm/trunk/backends/gp32/gp32_main.cpp
scummvm/trunk/backends/intern.h
scummvm/trunk/backends/maemo/main.cpp
scummvm/trunk/backends/morphos/morphos_start.cpp
scummvm/trunk/backends/null/null.cpp
scummvm/trunk/backends/ps2/systemps2.cpp
scummvm/trunk/backends/psp/psp_main.cpp
scummvm/trunk/backends/sdl/sdl.cpp
scummvm/trunk/backends/wince/wince-sdl.cpp
scummvm/trunk/backends/x11/x11.cpp
scummvm/trunk/base/main.cpp
scummvm/trunk/common/system.cpp
scummvm/trunk/common/system.h
scummvm/trunk/engines/queen/journal.cpp
scummvm/trunk/graphics/imagedec.cpp
scummvm/trunk/gui/ThemeNew.cpp
scummvm/trunk/gui/newgui.cpp
scummvm/trunk/sound/mixer.cpp
Modified: scummvm/trunk/backends/dc/dc.h
===================================================================
--- scummvm/trunk/backends/dc/dc.h 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/backends/dc/dc.h 2006-04-02 14:16:31 UTC (rev 21557)
@@ -188,9 +188,6 @@
void mouseToSoftKbd(int x, int y, int &rx, int &ry) const;
- static OSystem *create();
-
-
private:
SoftKeyboard _softkbd;
Modified: scummvm/trunk/backends/dc/dcmain.cpp
===================================================================
--- scummvm/trunk/backends/dc/dcmain.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/backends/dc/dcmain.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -36,15 +36,7 @@
Icon icon;
const char *gGameName;
-OSystem *OSystem_Dreamcast_create() {
- return OSystem_Dreamcast::create();
-}
-OSystem *OSystem_Dreamcast::create() {
- OSystem_Dreamcast *syst = new OSystem_Dreamcast();
- return syst;
-}
-
OSystem_Dreamcast::OSystem_Dreamcast()
: _devpoll(0), screen(NULL), mouse(NULL), overlay(NULL), _softkbd(this),
_ms_buf(NULL), _sound_proc(NULL), _timer_active(false),
@@ -211,6 +203,9 @@
dc_init_hardware();
initSound();
+ g_system = new OSystem_Dreamcast();
+ assert(g_system);
+
scummvm_main(argc, argv);
exit(0);
Modified: scummvm/trunk/backends/gp32/gp32_main.cpp
===================================================================
--- scummvm/trunk/backends/gp32/gp32_main.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/backends/gp32/gp32_main.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -71,5 +71,8 @@
//scummvm_main(argc, argv);
+ g_system = new OSystem_GP32_create();
+ assert(g_system);
+
scummvm_main(1, NULL);
}
Modified: scummvm/trunk/backends/intern.h
===================================================================
--- scummvm/trunk/backends/intern.h 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/backends/intern.h 2006-04-02 14:16:31 UTC (rev 21557)
@@ -25,24 +25,6 @@
#include "common/system.h"
-/* Factory functions. This means we don't have to include the headers for
- * all backends.
- */
-extern OSystem *OSystem_SDL_create();
-extern OSystem *OSystem_NULL_create();
-extern OSystem *OSystem_MorphOS_create();
-extern OSystem *OSystem_Dreamcast_create();
-extern OSystem *OSystem_WINCE3_create();
-extern OSystem *OSystem_X11_create();
-extern OSystem *OSystem_GP32_create();
-extern OSystem *OSystem_PALMOS_create();
-extern OSystem *OSystem_PS2_create();
-extern OSystem *OSystem_PSP_create();
-extern OSystem *OSystem_SymbianOS_create();
-
-extern OSystem *OSystem_PalmOS5_create();
-extern OSystem *OSystem_PalmZodiac_create();
-
#ifdef _WIN32_WCE
#define SAMPLES_PER_SEC 22050
#define SAMPLES_PER_SEC_OLD 11025
Modified: scummvm/trunk/backends/maemo/main.cpp
===================================================================
--- scummvm/trunk/backends/maemo/main.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/backends/maemo/main.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -28,6 +28,7 @@
#include <SDL/SDL.h>
#include <SDL/SDL_syswm.h>
+#include "backends/sdl/sdl-common.h"
#include "base/main.h"
#include <hildon-widgets/hildon-app.h>
#include <gtk/gtk.h>
@@ -63,6 +64,10 @@
setpriority(PRIO_PROCESS, 0, 0);
set_doubling(0);
+
+ g_system = new OSystem_SDL();
+ assert(g_system);
+
scummvm_main(argc, argv);
/* Deinitialize OSSO */
Modified: scummvm/trunk/backends/morphos/morphos_start.cpp
===================================================================
--- scummvm/trunk/backends/morphos/morphos_start.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/backends/morphos/morphos_start.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -434,6 +434,9 @@
if (ScummStory)
argv[argc++] = ScummStory;
+ g_system = OSystem_MorphOS_create();
+ assert(g_system);
+
return scummvm_main(argc, argv);
}
Modified: scummvm/trunk/backends/null/null.cpp
===================================================================
--- scummvm/trunk/backends/null/null.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/backends/null/null.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -108,6 +108,8 @@
int main(int argc, char *argv[]) {
// Invoke the actual ScummVM main entry point:
+ g_system = OSystem_NULL_create();
+ assert(g_system);
return scummvm_main(argc, argv);
}
Modified: scummvm/trunk/backends/ps2/systemps2.cpp
===================================================================
--- scummvm/trunk/backends/ps2/systemps2.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/backends/ps2/systemps2.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -72,8 +72,6 @@
static volatile int32 g_MainWakeUp = 0, g_TimerWakeUp = 0;
static volatile uint32 msecCount = 0;
-OSystem_PS2 *g_systemPs2 = NULL;
-
int gBitFormat = 555;
#define FOREVER 2147483647
@@ -93,12 +91,6 @@
sio_puts(resStr);
}
-OSystem *OSystem_PS2_create(void) {
- if (!g_systemPs2)
- g_systemPs2 = new OSystem_PS2();
- return g_systemPs2;
-}
-
extern "C" int main(int argc, char *argv[]) {
SifInitRpc(0);
#ifndef USE_PS2LINK // reset the IOP if this is a CD build
@@ -137,7 +129,8 @@
sioprintf("Creating system");
/* The OSystem has to be created before we enter ScummVM's main.
It sets up the memory card, etc. */
- OSystem_PS2_create();
+ g_system = new OSystem_PS2();
+ assert(g_system);
sioprintf("init done. starting ScummVM.");
return scummvm_main(argc, argv);
Modified: scummvm/trunk/backends/psp/psp_main.cpp
===================================================================
--- scummvm/trunk/backends/psp/psp_main.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/backends/psp/psp_main.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -144,6 +144,9 @@
static char *argv[] = { "scummvm", "--force-1x-overlay", NULL };
static int argc = sizeof(argv)/sizeof(char *)-1;
+ g_system = OSystem_PSP_create();
+ assert(g_system);
+
scummvm_main(argc, argv);
sceKernelSleepThread();
Modified: scummvm/trunk/backends/sdl/sdl.cpp
===================================================================
--- scummvm/trunk/backends/sdl/sdl.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/backends/sdl/sdl.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -92,14 +92,14 @@
#endif // defined(__SYMBIAN32__)
+ g_system = new OSystem_SDL();
+ assert(g_system);
+
// Invoke the actual ScummVM main entry point:
return scummvm_main(argc, argv);
}
#endif
-OSystem *OSystem_SDL_create() {
- return new OSystem_SDL();
-}
void OSystem_SDL::initBackend() {
assert(!_inited);
Modified: scummvm/trunk/backends/wince/wince-sdl.cpp
===================================================================
--- scummvm/trunk/backends/wince/wince-sdl.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/backends/wince/wince-sdl.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -147,6 +147,8 @@
GUI::Actions::init(_gameDetector);
__try {
+ g_system = OSystem_WINCE3_create();
+ assert(g_system);
return scummvm_main(_gameDetector, argc, argv);
}
__except (handleException(GetExceptionInformation())) {
Modified: scummvm/trunk/backends/x11/x11.cpp
===================================================================
--- scummvm/trunk/backends/x11/x11.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/backends/x11/x11.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -59,14 +59,13 @@
#include <backends/x11/x11.h>
int main(int argc, char *argv[]) {
+ g_system = OSystem_X11::create(0, 0);
+ assert(g_system);
+
// Invoke the actual ScummVM main entry point:
return scummvm_main(argc, argv);
}
-OSystem *OSystem_X11_create() {
- return OSystem_X11::create(0, 0);
-}
-
OSystem *OSystem_X11::create(int gfx_mode, bool full_screen) {
OSystem_X11 *syst = new OSystem_X11();
return syst;
Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/base/main.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -275,6 +275,11 @@
char *s=NULL;//argv[1]; SumthinWicked says: cannot assume that argv!=NULL here! eg. Symbian's CEBasicAppUI::SDLStartL() calls as main(0,NULL), if you want to change plz #ifdef __SYMBIAN32__
bool running = true;
+ // Verify that the backend has been initialised (i.e. g_system has been set).
+ assert(g_system);
+ OSystem &system = *g_system;
+
+
// Quick preparse of command-line, looking for alt configfile path
for (int i = argc - 1; i >= 1; i--) {
s = argv[i];
@@ -342,10 +347,6 @@
GUI::Actions::init(detector);
#endif
- // Ensure the system object exists (it may have already been created
- // at an earlier point, though!)
- OSystem &system = OSystem::instance();
-
detector.parseCommandLine(argc, argv);
#ifdef PALMOS_68K
Modified: scummvm/trunk/common/system.cpp
===================================================================
--- scummvm/trunk/common/system.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/common/system.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -34,45 +34,8 @@
#include "common/system.h"
#include "common/util.h"
-DECLARE_SINGLETON(OSystem);
+OSystem *g_system = 0;
-OSystem *OSystem::makeInstance() {
- // Attention: Do not call parseGraphicsMode() here, nor any other function
- // which needs to access the OSystem instance, else you get stuck in an
- // endless loop.
-
-#if defined(USE_NULL_DRIVER)
- return OSystem_NULL_create();
-#elif defined(__DC__)
- return OSystem_Dreamcast_create();
-#elif defined(X11_BACKEND)
- return OSystem_X11_create();
-#elif defined(__MORPHOS__)
- return OSystem_MorphOS_create();
-#elif defined(_WIN32_WCE)
- return OSystem_WINCE3_create();
-#elif defined(__GP32__) // ph0x
- return OSystem_GP32_create();
-#elif defined(PALMOS_MODE) //chrilith
-# if defined(COMPILE_OS5)
- return OSystem_PalmOS5_create();
-# elif defined(COMPILE_ZODIAC)
- return OSystem_PalmZodiac_create();
-# else
- return OSystem_PALMOS_create(); // old backend
-# endif
-#elif defined(__PLAYSTATION2__)
- return OSystem_PS2_create();
-#elif defined(__PSP__)
- return OSystem_PSP_create();
-#elif defined(__SYMBIAN32__) // SumthinWicked / Sprawl
- return OSystem_SymbianOS_create();
-#else
- /* SDL is the default driver for now */
- return OSystem_SDL_create();
-#endif
-}
-
bool OSystem::setGraphicsMode(const char *name) {
if (!name)
return false;
Modified: scummvm/trunk/common/system.h
===================================================================
--- scummvm/trunk/common/system.h 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/common/system.h 2006-04-02 14:16:31 UTC (rev 21557)
@@ -27,7 +27,6 @@
#include "common/scummsys.h"
#include "common/mutex.h"
#include "common/rect.h"
-#include "common/singleton.h"
namespace Graphics {
struct Surface;
@@ -47,10 +46,15 @@
* methods to create timers, to handle user input events,
* control audio CD playback, and sound output.
*/
-class OSystem : public Common::Singleton<OSystem> {
+class OSystem {
+private:
+ // Prevent copying OSystem objects by accident.
+ OSystem(const OSystem&);
+ OSystem& operator= (const OSystem&);
+
protected:
- static OSystem *makeInstance();
- friend class Common::Singleton<SingletonBaseType>;
+ OSystem() { }
+ virtual ~OSystem() { }
public:
@@ -926,8 +930,8 @@
};
-/** The global OSystem instance. Inited in main(). */
-#define g_system (&OSystem::instance())
+/** The global OSystem instance. Initialised in main(). */
+extern OSystem *g_system;
#endif
Modified: scummvm/trunk/engines/queen/journal.cpp
===================================================================
--- scummvm/trunk/engines/queen/journal.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/engines/queen/journal.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -48,7 +48,7 @@
_prevJoeY = joe->y;
_panelMode = PM_NORMAL;
- _system = &OSystem::instance();
+ _system = g_system;
_panelTextCount = 0;
memset(_panelTextY, 0, sizeof(_panelTextY));
Modified: scummvm/trunk/graphics/imagedec.cpp
===================================================================
--- scummvm/trunk/graphics/imagedec.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/graphics/imagedec.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -123,7 +123,7 @@
b = stream.readByte();
g = stream.readByte();
r = stream.readByte();
- *curPixel = OSystem::instance().RGBToColor(r, g, b);
+ *curPixel = g_system->RGBToColor(r, g, b);
++curPixel;
}
stream.seek(pitchAdd, SEEK_CUR);
Modified: scummvm/trunk/gui/ThemeNew.cpp
===================================================================
--- scummvm/trunk/gui/ThemeNew.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/gui/ThemeNew.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -47,7 +47,7 @@
static void getColorFromConfig(const Common::ConfigFile &cfg, const Common::String &value, OverlayColor &color) {
Common::String temp;
if (!cfg.hasKey(value, "colors")) {
- color = OSystem::instance().RGBToColor(0, 0, 0);
+ color = g_system->RGBToColor(0, 0, 0);
return;
}
cfg.getKey(value, "colors", temp);
@@ -59,7 +59,7 @@
rgb[cnt] = atoi(colors + pos);
pos = strchr(colors + pos, ' ') - colors + 1;
}
- color = OSystem::instance().RGBToColor(rgb[0], rgb[1], rgb[2]);
+ color = g_system->RGBToColor(rgb[0], rgb[1], rgb[2]);
}
static void getValueFromConfig(const Common::ConfigFile &cfg, const Common::String §ion, const Common::String &value, uint &val, uint defaultVal) {
@@ -1027,7 +1027,7 @@
void ThemeNew::drawShadow(const Common::Rect &r, const Graphics::Surface *corner, const Graphics::Surface *top,
const Graphics::Surface *left, const Graphics::Surface *fill, uint32 shadowStyle,
bool full, bool skipLastRow) {
- OverlayColor col = OSystem::instance().RGBToColor(0, 0, 0);
+ OverlayColor col = g_system->RGBToColor(0, 0, 0);
switch (shadowStyle) {
case kShadowFull: {
@@ -1125,8 +1125,8 @@
++partsW;
}
- OverlayColor startCol = OSystem::instance().RGBToColor(0, 0, 0);
- OverlayColor endCol = OSystem::instance().RGBToColor(0, 0, 0);
+ OverlayColor startCol = g_system->RGBToColor(0, 0, 0);
+ OverlayColor endCol = g_system->RGBToColor(0, 0, 0);
for (int y = 0; y < partsH; ++y) {
// calculate the correct drawing height
Modified: scummvm/trunk/gui/newgui.cpp
===================================================================
--- scummvm/trunk/gui/newgui.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/gui/newgui.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -87,7 +87,7 @@
NewGui::NewGui() : _needRedraw(false),
_stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0) {
- _system = &OSystem::instance();
+ _system = g_system;
// Clear the cursor
memset(_cursor, 0xFF, sizeof(_cursor));
Modified: scummvm/trunk/sound/mixer.cpp
===================================================================
--- scummvm/trunk/sound/mixer.cpp 2006-04-02 13:46:46 UTC (rev 21556)
+++ scummvm/trunk/sound/mixer.cpp 2006-04-02 14:16:31 UTC (rev 21557)
@@ -104,7 +104,7 @@
Mixer::Mixer() {
- _syst = &OSystem::instance();
+ _syst = g_system;
_handleSeed = 0;
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