diff options
-rw-r--r-- | backends/dc/dc.h | 3 | ||||
-rw-r--r-- | backends/dc/dcmain.cpp | 11 | ||||
-rw-r--r-- | backends/gp32/gp32_main.cpp | 3 | ||||
-rw-r--r-- | backends/intern.h | 18 | ||||
-rw-r--r-- | backends/maemo/main.cpp | 5 | ||||
-rw-r--r-- | backends/morphos/morphos_start.cpp | 3 | ||||
-rw-r--r-- | backends/null/null.cpp | 2 | ||||
-rw-r--r-- | backends/ps2/systemps2.cpp | 11 | ||||
-rw-r--r-- | backends/psp/psp_main.cpp | 3 | ||||
-rw-r--r-- | backends/sdl/sdl.cpp | 6 | ||||
-rw-r--r-- | backends/wince/wince-sdl.cpp | 2 | ||||
-rw-r--r-- | backends/x11/x11.cpp | 7 | ||||
-rw-r--r-- | base/main.cpp | 9 | ||||
-rw-r--r-- | common/system.cpp | 39 | ||||
-rw-r--r-- | common/system.h | 16 | ||||
-rw-r--r-- | engines/queen/journal.cpp | 2 | ||||
-rw-r--r-- | graphics/imagedec.cpp | 2 | ||||
-rw-r--r-- | gui/ThemeNew.cpp | 10 | ||||
-rw-r--r-- | gui/newgui.cpp | 2 | ||||
-rw-r--r-- | sound/mixer.cpp | 2 |
20 files changed, 54 insertions, 102 deletions
diff --git a/backends/dc/dc.h b/backends/dc/dc.h index bc74906766..dd390c7f2d 100644 --- a/backends/dc/dc.h +++ b/backends/dc/dc.h @@ -188,9 +188,6 @@ class OSystem_Dreamcast : public OSystem { void mouseToSoftKbd(int x, int y, int &rx, int &ry) const; - static OSystem *create(); - - private: SoftKeyboard _softkbd; diff --git a/backends/dc/dcmain.cpp b/backends/dc/dcmain.cpp index d622c35019..5e59f80813 100644 --- a/backends/dc/dcmain.cpp +++ b/backends/dc/dcmain.cpp @@ -36,14 +36,6 @@ 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), @@ -211,6 +203,9 @@ int main() dc_init_hardware(); initSound(); + g_system = new OSystem_Dreamcast(); + assert(g_system); + scummvm_main(argc, argv); exit(0); diff --git a/backends/gp32/gp32_main.cpp b/backends/gp32/gp32_main.cpp index 8abdb4a7ce..3fb32aa9b2 100644 --- a/backends/gp32/gp32_main.cpp +++ b/backends/gp32/gp32_main.cpp @@ -71,5 +71,8 @@ void GpMain(void *arg) { //scummvm_main(argc, argv); + g_system = new OSystem_GP32_create(); + assert(g_system); + scummvm_main(1, NULL); } diff --git a/backends/intern.h b/backends/intern.h index 079107140f..f6304fb7b5 100644 --- a/backends/intern.h +++ b/backends/intern.h @@ -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 diff --git a/backends/maemo/main.cpp b/backends/maemo/main.cpp index 231f319158..3d155cc625 100644 --- a/backends/maemo/main.cpp +++ b/backends/maemo/main.cpp @@ -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 @@ int main(int argc, char *argv[]) { setpriority(PRIO_PROCESS, 0, 0); set_doubling(0); + + g_system = new OSystem_SDL(); + assert(g_system); + scummvm_main(argc, argv); /* Deinitialize OSSO */ diff --git a/backends/morphos/morphos_start.cpp b/backends/morphos/morphos_start.cpp index f7ec56f224..6a8299d2cd 100644 --- a/backends/morphos/morphos_start.cpp +++ b/backends/morphos/morphos_start.cpp @@ -434,6 +434,9 @@ int main() if (ScummStory) argv[argc++] = ScummStory; + g_system = OSystem_MorphOS_create(); + assert(g_system); + return scummvm_main(argc, argv); } diff --git a/backends/null/null.cpp b/backends/null/null.cpp index d60206f4f4..03939896b1 100644 --- a/backends/null/null.cpp +++ b/backends/null/null.cpp @@ -108,6 +108,8 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { 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); } diff --git a/backends/ps2/systemps2.cpp b/backends/ps2/systemps2.cpp index d0154ab590..f277648c27 100644 --- a/backends/ps2/systemps2.cpp +++ b/backends/ps2/systemps2.cpp @@ -72,8 +72,6 @@ static int g_MainWaitSema = -1, g_TimerWaitSema = -1; 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 @@ void sioprintf(const char *zFormat, ...) { 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 @@ extern "C" int main(int argc, char *argv[]) { 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); diff --git a/backends/psp/psp_main.cpp b/backends/psp/psp_main.cpp index d981c314dc..cbdaad68e0 100644 --- a/backends/psp/psp_main.cpp +++ b/backends/psp/psp_main.cpp @@ -144,6 +144,9 @@ int main(void) 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(); diff --git a/backends/sdl/sdl.cpp b/backends/sdl/sdl.cpp index 4fa64e75d2..2d567ea769 100644 --- a/backends/sdl/sdl.cpp +++ b/backends/sdl/sdl.cpp @@ -92,14 +92,14 @@ int main(int argc, char *argv[]) { #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); diff --git a/backends/wince/wince-sdl.cpp b/backends/wince/wince-sdl.cpp index 46c95f9ed5..e08cc965ff 100644 --- a/backends/wince/wince-sdl.cpp +++ b/backends/wince/wince-sdl.cpp @@ -147,6 +147,8 @@ int SDL_main(int argc, char **argv) { GUI::Actions::init(_gameDetector); __try { + g_system = OSystem_WINCE3_create(); + assert(g_system); return scummvm_main(_gameDetector, argc, argv); } __except (handleException(GetExceptionInformation())) { diff --git a/backends/x11/x11.cpp b/backends/x11/x11.cpp index f52f5fdad5..778028b031 100644 --- a/backends/x11/x11.cpp +++ b/backends/x11/x11.cpp @@ -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; diff --git a/base/main.cpp b/base/main.cpp index 0a4a7b670c..4baa6a6ca4 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -275,6 +275,11 @@ extern "C" int scummvm_main(int argc, char *argv[]) { 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 @@ extern "C" int scummvm_main(int argc, char *argv[]) { 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 diff --git a/common/system.cpp b/common/system.cpp index 7b3a8064e8..642012badc 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -34,44 +34,7 @@ #include "common/system.h" #include "common/util.h" -DECLARE_SINGLETON(OSystem); - -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 -} +OSystem *g_system = 0; bool OSystem::setGraphicsMode(const char *name) { if (!name) diff --git a/common/system.h b/common/system.h index 115b9e7afa..2c22fb4132 100644 --- a/common/system.h +++ b/common/system.h @@ -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 @@ namespace Common { * 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 @@ public: }; -/** The global OSystem instance. Inited in main(). */ -#define g_system (&OSystem::instance()) +/** The global OSystem instance. Initialised in main(). */ +extern OSystem *g_system; #endif diff --git a/engines/queen/journal.cpp b/engines/queen/journal.cpp index 0aeb71e083..d6298777c2 100644 --- a/engines/queen/journal.cpp +++ b/engines/queen/journal.cpp @@ -48,7 +48,7 @@ void Journal::use() { _prevJoeY = joe->y; _panelMode = PM_NORMAL; - _system = &OSystem::instance(); + _system = g_system; _panelTextCount = 0; memset(_panelTextY, 0, sizeof(_panelTextY)); diff --git a/graphics/imagedec.cpp b/graphics/imagedec.cpp index 6dfb286f11..2cc21aa62f 100644 --- a/graphics/imagedec.cpp +++ b/graphics/imagedec.cpp @@ -123,7 +123,7 @@ Surface *BMPDecoder::decodeImage(Common::SeekableReadStream &stream) { 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); diff --git a/gui/ThemeNew.cpp b/gui/ThemeNew.cpp index 8be57bb725..8ae1854e10 100644 --- a/gui/ThemeNew.cpp +++ b/gui/ThemeNew.cpp @@ -47,7 +47,7 @@ extern int gBitFormat; 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 @@ static void getColorFromConfig(const Common::ConfigFile &cfg, const Common::Stri 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 @@ Common::Rect ThemeNew::shadowRect(const Common::Rect &r, uint32 shadowStyle) { 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 @@ void ThemeNew::drawShadowRect(const Common::Rect &r, const Common::Rect &area, c ++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 diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 02e0580664..881b12766e 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -87,7 +87,7 @@ GuiObject::GuiObject(Common::String name) : _firstWidget(0) { NewGui::NewGui() : _needRedraw(false), _stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0) { - _system = &OSystem::instance(); + _system = g_system; // Clear the cursor memset(_cursor, 0xFF, sizeof(_cursor)); diff --git a/sound/mixer.cpp b/sound/mixer.cpp index ba71f0098c..5e26c04f66 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -104,7 +104,7 @@ public: Mixer::Mixer() { - _syst = &OSystem::instance(); + _syst = g_system; _handleSeed = 0; |