// Residual - Virtual machine to run LucasArts' 3D adventure games // Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org) // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library 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 // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "stdafx.h" #include #include #include #include "bitmap.h" #include "resource.h" #include "debug.h" #include "lua.h" #include "registry.h" #include "engine.h" #include "sound.h" #include "timer.h" #include "mixer/mixer.h" #ifndef _MSC_VER #include #endif // Hacky includes for temporary font rendering #ifndef WIN32 #include #include #else #include #include #endif // Hacky global toggles for experimental/debug code int ZBUFFER_GLOBAL, SCREENBLOCKS_GLOBAL; static void saveRegistry() { Registry::instance()->save(); } #ifdef __MINGW32__ int PASCAL WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpCmdLine*/, int /*iShowCmd*/) { return main(0, NULL); } #endif extern SoundMixer *g_mixer; extern Timer *g_timer; int main(int argc, char *argv[]) { char GLDriver[1024]; int i; // Parse command line ZBUFFER_GLOBAL = 0; SCREENBLOCKS_GLOBAL = 0; for (i=1;iloadBitmap("splash.bm"); SDL_Event event; while (SDL_PollEvent(&event)) { if (event.type == SDL_VIDEOEXPOSE) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Bitmap::prepareGL(); splash_bm->draw(); SDL_GL_SwapBuffers(); } } g_mixer = new SoundMixer(); g_timer = new Timer(); Mixer::instance()->start(); lua_open(); lua_beginblock(); lua_iolibopen(); lua_strlibopen(); lua_mathlibopen(); lua_endblock(); lua_beginblock(); register_lua(); lua_endblock(); lua_beginblock(); bundle_dofile("_system.lua"); lua_endblock(); lua_beginblock(); lua_pushnil(); // resumeSave lua_pushnumber(0); // bootParam lua_call("BOOT"); lua_endblock(); // FIXME: Hacky temporary font renderer code Engine::instance()->font = glGenLists(256); #ifdef WIN32 { HDC hDC; HFONT font; SDL_SysWMinfo wmi; SDL_VERSION(&wmi.version); SDL_GetWMInfo(&wmi); hDC = GetDC(wmi.window); font = CreateFont(0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, 0 , FF_DONTCARE|DEFAULT_PITCH, "Courier New"); SelectObject(hDC, font); wglUseFontBitmaps(hDC, 0, 256, Engine::instance()->font); } #else { Display *dpy = XOpenDisplay(NULL); XFontStruct *XFont = XLoadQueryFont(dpy, "-misc-fixed-medium-r-*-*-20-*-*-*-*-*-*-*" ); glXUseXFont(XFont->fid, 0, 256, Engine::instance()->font); XFreeFont(dpy, XFont); XCloseDisplay(dpy); } #endif Engine::instance()->mainLoop(); delete g_timer; delete g_mixer; return 0; } StackLock::StackLock(MutexRef mutex) : _mutex(mutex) { lock_mutex(_mutex); } StackLock::~StackLock() { unlock_mutex(_mutex); } MutexRef create_mutex() { return (MutexRef) SDL_CreateMutex(); } void lock_mutex(MutexRef mutex) { SDL_mutexP((SDL_mutex *) mutex); } void unlock_mutex(MutexRef mutex) { SDL_mutexV((SDL_mutex *) mutex); } void delete_mutex(MutexRef mutex) { SDL_DestroyMutex((SDL_mutex *) mutex); }