From 28ee7f3a6f8a50581e5aa3822e5ef842373fcd38 Mon Sep 17 00:00:00 2001 From: punkrockguy318 Date: Tue, 6 Mar 2012 11:40:42 +0000 Subject: [PATCH] sdl: tab cleanup --- src/drivers/sdl/sdl-video.cpp | 811 +++++++++++++++++----------------- src/drivers/sdl/sdl.cpp | 2 +- 2 files changed, 403 insertions(+), 410 deletions(-) diff --git a/src/drivers/sdl/sdl-video.cpp b/src/drivers/sdl/sdl-video.cpp index 000ede15..9ca25963 100644 --- a/src/drivers/sdl/sdl-video.cpp +++ b/src/drivers/sdl/sdl-video.cpp @@ -94,33 +94,32 @@ bool FCEUD_ShouldDrawInputAids() int KillVideo() { - // if the IconSurface has been initialized, destroy it - if(s_IconSurface) { - SDL_FreeSurface(s_IconSurface); - s_IconSurface=0; - } + // if the IconSurface has been initialized, destroy it + if(s_IconSurface) { + SDL_FreeSurface(s_IconSurface); + s_IconSurface=0; + } - - // return failure if the video system was not initialized - if(s_inited == 0) - return -1; + // return failure if the video system was not initialized + if(s_inited == 0) + return -1; - // if the rest of the system has been initialized, shut it down + // if the rest of the system has been initialized, shut it down #ifdef OPENGL - // check for OpenGL and shut it down - if(s_useOpenGL) - KillOpenGL(); - else + // check for OpenGL and shut it down + if(s_useOpenGL) + KillOpenGL(); + else #endif - // shut down the system that converts from 8 to 16/32 bpp - if(s_curbpp > 8) - KillBlitToHigh(); + // shut down the system that converts from 8 to 16/32 bpp + if(s_curbpp > 8) + KillBlitToHigh(); - // shut down the SDL video sub-system - SDL_QuitSubSystem(SDL_INIT_VIDEO); + // shut down the SDL video sub-system + SDL_QuitSubSystem(SDL_INIT_VIDEO); - s_inited = 0; - return 0; + s_inited = 0; + return 0; } @@ -132,11 +131,11 @@ static int s_sponge; */ inline double GetXScale(int xres) { - return ((double)xres) / NWIDTH; + return ((double)xres) / NWIDTH; } inline double GetYScale(int yres) { - return ((double)yres) / s_tlines; + return ((double)yres) / s_tlines; } void FCEUD_VideoChanged() { @@ -154,221 +153,216 @@ void FCEUD_VideoChanged() int InitVideo(FCEUGI *gi) { - // XXX soules - const? is this necessary? - const SDL_VideoInfo *vinf; - int error, flags = 0; - int doublebuf, xstretch, ystretch, xres, yres; - + // XXX soules - const? is this necessary? + const SDL_VideoInfo *vinf; + int error, flags = 0; + int doublebuf, xstretch, ystretch, xres, yres; - FCEUI_printf("Initializing video..."); + FCEUI_printf("Initializing video..."); - // load the relevant configuration variables - g_config->getOption("SDL.Fullscreen", &s_fullscreen); - g_config->getOption("SDL.DoubleBuffering", &doublebuf); + // load the relevant configuration variables + g_config->getOption("SDL.Fullscreen", &s_fullscreen); + g_config->getOption("SDL.DoubleBuffering", &doublebuf); #ifdef OPENGL - g_config->getOption("SDL.OpenGL", &s_useOpenGL); + g_config->getOption("SDL.OpenGL", &s_useOpenGL); #endif - g_config->getOption("SDL.SpecialFilter", &s_sponge); - g_config->getOption("SDL.XStretch", &xstretch); - g_config->getOption("SDL.YStretch", &ystretch); - g_config->getOption("SDL.XResolution", &xres); - g_config->getOption("SDL.YResolution", &yres); - g_config->getOption("SDL.ClipSides", &s_clipSides); - g_config->getOption("SDL.NoFrame", &noframe); + g_config->getOption("SDL.SpecialFilter", &s_sponge); + g_config->getOption("SDL.XStretch", &xstretch); + g_config->getOption("SDL.YStretch", &ystretch); + g_config->getOption("SDL.XResolution", &xres); + g_config->getOption("SDL.YResolution", &yres); + g_config->getOption("SDL.ClipSides", &s_clipSides); + g_config->getOption("SDL.NoFrame", &noframe); - // check the starting, ending, and total scan lines - FCEUI_GetCurrentVidSystem(&s_srendline, &s_erendline); - s_tlines = s_erendline - s_srendline + 1; + // check the starting, ending, and total scan lines + FCEUI_GetCurrentVidSystem(&s_srendline, &s_erendline); + s_tlines = s_erendline - s_srendline + 1; - - // check for OpenGL and set the global flags #if OPENGL - if(s_useOpenGL && !s_sponge) { - flags = SDL_OPENGL; - } + if(s_useOpenGL && !s_sponge) { + flags = SDL_OPENGL; + } #endif - // initialize the SDL video subsystem if it is not already active - if(!SDL_WasInit(SDL_INIT_VIDEO)) { - error = SDL_InitSubSystem(SDL_INIT_VIDEO); - if(error) { - FCEUD_PrintError(SDL_GetError()); - return -1; - } - } - s_inited = 1; + // initialize the SDL video subsystem if it is not already active + if(!SDL_WasInit(SDL_INIT_VIDEO)) { + error = SDL_InitSubSystem(SDL_INIT_VIDEO); + if(error) { + FCEUD_PrintError(SDL_GetError()); + return -1; + } + } + s_inited = 1; - // shows the cursor within the display window - SDL_ShowCursor(1); + // shows the cursor within the display window + SDL_ShowCursor(1); - // determine if we can allocate the display on the video card - vinf = SDL_GetVideoInfo(); - if(vinf->hw_available) { - flags |= SDL_HWSURFACE; - } + // determine if we can allocate the display on the video card + vinf = SDL_GetVideoInfo(); + if(vinf->hw_available) { + flags |= SDL_HWSURFACE; + } - // get the monitor's current resolution if we do not already have it - if(s_nativeWidth < 0) { - s_nativeWidth = vinf->current_w; - } - if(s_nativeHeight < 0) { - s_nativeHeight = vinf->current_h; - } + // get the monitor's current resolution if we do not already have it + if(s_nativeWidth < 0) { + s_nativeWidth = vinf->current_w; + } + if(s_nativeHeight < 0) { + s_nativeHeight = vinf->current_h; + } - // check if we are rendering fullscreen - if(s_fullscreen) { - flags |= SDL_FULLSCREEN; - SDL_ShowCursor(0); - } - else { + // check if we are rendering fullscreen + if(s_fullscreen) { + flags |= SDL_FULLSCREEN; + SDL_ShowCursor(0); + } + else { SDL_ShowCursor(1); } - if(noframe) { - flags |= SDL_NOFRAME; - } + if(noframe) { + flags |= SDL_NOFRAME; + } - // gives the SDL exclusive palette control... ensures the requested colors - flags |= SDL_HWPALETTE; + // gives the SDL exclusive palette control... ensures the requested colors + flags |= SDL_HWPALETTE; - - // enable double buffering if requested and we have hardware support + // enable double buffering if requested and we have hardware support #ifdef OPENGL - if(s_useOpenGL) { - FCEU_printf("Initializing with OpenGL (Disable with '-opengl 0').\n"); - if(doublebuf) { - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - } - } else + if(s_useOpenGL) { + FCEU_printf("Initializing with OpenGL (Disable with '-opengl 0').\n"); + if(doublebuf) { + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + } + } else #endif - if(doublebuf && (flags & SDL_HWSURFACE)) { - flags |= SDL_DOUBLEBUF; - } + if(doublebuf && (flags & SDL_HWSURFACE)) { + flags |= SDL_DOUBLEBUF; + } - if(s_fullscreen) { - int desbpp, autoscale; - g_config->getOption("SDL.BitsPerPixel", &desbpp); - g_config->getOption("SDL.AutoScale", &autoscale); - if (autoscale) - { - double auto_xscale = GetXScale(xres); - double auto_yscale = GetYScale(yres); - double native_ratio = ((double)NWIDTH) / s_tlines; - double screen_ratio = ((double)xres) / yres; - int keep_ratio; + if(s_fullscreen) { + int desbpp, autoscale; + g_config->getOption("SDL.BitsPerPixel", &desbpp); + g_config->getOption("SDL.AutoScale", &autoscale); + if (autoscale) + { + double auto_xscale = GetXScale(xres); + double auto_yscale = GetYScale(yres); + double native_ratio = ((double)NWIDTH) / s_tlines; + double screen_ratio = ((double)xres) / yres; + int keep_ratio; - g_config->getOption("SDL.KeepRatio", &keep_ratio); + g_config->getOption("SDL.KeepRatio", &keep_ratio); - // Try to choose resolution - if (screen_ratio < native_ratio) - { - // The screen is narrower than the original. Maximizing width will not clip - auto_xscale = auto_yscale = GetXScale(xres); - if (keep_ratio) - auto_yscale = GetYScale(yres); - } - else - { - auto_yscale = auto_xscale = GetYScale(yres); - if (keep_ratio) - auto_xscale = GetXScale(xres); - } - s_exs = auto_xscale; - s_eys = auto_yscale; - } - else - { - g_config->getOption("SDL.XScale", &s_exs); - g_config->getOption("SDL.YScale", &s_eys); - } + // Try to choose resolution + if (screen_ratio < native_ratio) + { + // The screen is narrower than the original. Maximizing width will not clip + auto_xscale = auto_yscale = GetXScale(xres); + if (keep_ratio) + auto_yscale = GetYScale(yres); + } + else + { + auto_yscale = auto_xscale = GetYScale(yres); + if (keep_ratio) + auto_xscale = GetXScale(xres); + } + s_exs = auto_xscale; + s_eys = auto_yscale; + } + else + { + g_config->getOption("SDL.XScale", &s_exs); + g_config->getOption("SDL.YScale", &s_eys); + } + g_config->getOption("SDL.SpecialFX", &s_eefx); + +#ifdef OPENGL + if(!s_useOpenGL) { + s_exs = (int)s_exs; + s_eys = (int)s_eys; + } else { + desbpp = 0; + } - g_config->getOption("SDL.SpecialFX", &s_eefx); + // -Video Modes Tag- + if(s_sponge) { + if(s_sponge == 4 || s_sponge == 5) { + s_exs = s_eys = 3; + } else { + s_exs = s_eys = 2; + } + s_eefx = 0; + if(s_sponge == 1 || s_sponge == 4) { + desbpp = 32; + } + } -#ifdef OPENGL - if(!s_useOpenGL) { - s_exs = (int)s_exs; - s_eys = (int)s_eys; - } else { - desbpp = 0; - } - - // -Video Modes Tag- - if(s_sponge) { - if(s_sponge == 4 || s_sponge == 5) { - s_exs = s_eys = 3; - } else { - s_exs = s_eys = 2; - } - s_eefx = 0; - if(s_sponge == 1 || s_sponge == 4) { - desbpp = 32; - } - } - - if((s_useOpenGL && !xstretch) || !s_useOpenGL) + if((s_useOpenGL && !xstretch) || !s_useOpenGL) #endif - if(xres < (NWIDTH * s_exs) || s_exs <= 0.01) { - FCEUD_PrintError("xscale out of bounds."); - KillVideo(); - return -1; - } + if(xres < (NWIDTH * s_exs) || s_exs <= 0.01) { + FCEUD_PrintError("xscale out of bounds."); + KillVideo(); + return -1; + } #ifdef OPENGL - if((s_useOpenGL && !ystretch) || !s_useOpenGL) + if((s_useOpenGL && !ystretch) || !s_useOpenGL) #endif - if(yres < s_tlines * s_eys || s_eys <= 0.01) { - FCEUD_PrintError("yscale out of bounds."); - KillVideo(); - return -1; - } + if(yres < s_tlines * s_eys || s_eys <= 0.01) { + FCEUD_PrintError("yscale out of bounds."); + KillVideo(); + return -1; + } #ifdef OPENGL - s_screen = SDL_SetVideoMode(s_useOpenGL ? s_nativeWidth : xres, - s_useOpenGL ? s_nativeHeight : yres, - desbpp, flags); + s_screen = SDL_SetVideoMode(s_useOpenGL ? s_nativeWidth : xres, + s_useOpenGL ? s_nativeHeight : yres, + desbpp, flags); #else - s_screen = SDL_SetVideoMode(xres, yres, desbpp, flags); + s_screen = SDL_SetVideoMode(xres, yres, desbpp, flags); #endif - if(!s_screen) { - FCEUD_PrintError(SDL_GetError()); - return -1; - } - } else { - int desbpp; - g_config->getOption("SDL.BitsPerPixel", &desbpp); + if(!s_screen) { + FCEUD_PrintError(SDL_GetError()); + return -1; + } + } else { + int desbpp; + g_config->getOption("SDL.BitsPerPixel", &desbpp); - g_config->getOption("SDL.XScale", &s_exs); - g_config->getOption("SDL.YScale", &s_eys); - g_config->getOption("SDL.SpecialFX", &s_eefx); + g_config->getOption("SDL.XScale", &s_exs); + g_config->getOption("SDL.YScale", &s_eys); + g_config->getOption("SDL.SpecialFX", &s_eefx); - // -Video Modes Tag- - if(s_sponge) { - if(s_sponge >= 4) { - s_exs = s_eys = 3; - } else { - s_exs = s_eys = 2; - } - s_eefx = 0; - } + // -Video Modes Tag- + if(s_sponge) { + if(s_sponge >= 4) { + s_exs = s_eys = 3; + } else { + s_exs = s_eys = 2; + } + s_eefx = 0; + } #ifdef OPENGL - if(!s_useOpenGL) { - s_exs = (int)s_exs; - s_eys = (int)s_eys; - } - if(s_exs <= 0.01) { - FCEUD_PrintError("xscale out of bounds."); - KillVideo(); - return -1; - } - if(s_eys <= 0.01) { - FCEUD_PrintError("yscale out of bounds."); - KillVideo(); - return -1; - } - if(s_sponge && s_useOpenGL) { + if(!s_useOpenGL) { + s_exs = (int)s_exs; + s_eys = (int)s_eys; + } + if(s_exs <= 0.01) { + FCEUD_PrintError("xscale out of bounds."); + KillVideo(); + return -1; + } + if(s_eys <= 0.01) { + FCEUD_PrintError("yscale out of bounds."); + KillVideo(); + return -1; + } + if(s_sponge && s_useOpenGL) { FCEUD_PrintError("scalers not compatible with openGL mode."); KillVideo(); return -1; @@ -396,32 +390,32 @@ InitVideo(FCEUGI *gi) } #endif - s_screen = SDL_SetVideoMode((int)(NWIDTH * s_exs), - (int)(s_tlines * s_eys), - desbpp, flags); - if(!s_screen) { - FCEUD_PrintError(SDL_GetError()); - return -1; - } + s_screen = SDL_SetVideoMode((int)(NWIDTH * s_exs), + (int)(s_tlines * s_eys), + desbpp, flags); + if(!s_screen) { + FCEUD_PrintError(SDL_GetError()); + return -1; + } #ifdef _GTK - if(noGui == 0) - { - GtkRequisition req; - gtk_widget_size_request(GTK_WIDGET(MainWindow), &req); - gtk_window_resize(GTK_WINDOW(MainWindow), req.width, req.height); - } + if(noGui == 0) + { + GtkRequisition req; + gtk_widget_size_request(GTK_WIDGET(MainWindow), &req); + gtk_window_resize(GTK_WINDOW(MainWindow), req.width, req.height); + } #endif - } - s_curbpp = s_screen->format->BitsPerPixel; - if(!s_screen) { - FCEUD_PrintError(SDL_GetError()); - KillVideo(); - return -1; - } + } + s_curbpp = s_screen->format->BitsPerPixel; + if(!s_screen) { + FCEUD_PrintError(SDL_GetError()); + KillVideo(); + return -1; + } #if 0 - // XXX soules - this would be creating a surface on the video + // XXX soules - this would be creating a surface on the video // card, but was commented out for some reason... s_BlitBuf = SDL_CreateRGBSurface(SDL_HWSURFACE, 256, 240, s_screen->format->BitsPerPixel, @@ -430,105 +424,104 @@ InitVideo(FCEUGI *gi) s_screen->format->Bmask, 0); #endif - FCEU_printf(" Video Mode: %d x %d x %d bpp %s\n", - s_screen->w, s_screen->h, s_screen->format->BitsPerPixel, - s_fullscreen ? "full screen" : ""); + FCEU_printf(" Video Mode: %d x %d x %d bpp %s\n", + s_screen->w, s_screen->h, s_screen->format->BitsPerPixel, + s_fullscreen ? "full screen" : ""); - if(s_curbpp != 8 && s_curbpp != 16 && s_curbpp != 24 && s_curbpp != 32) { - FCEU_printf(" Sorry, %dbpp modes are not supported by FCE Ultra. Supported bit depths are 8bpp, 16bpp, and 32bpp.\n", s_curbpp); - KillVideo(); - return -1; - } + if(s_curbpp != 8 && s_curbpp != 16 && s_curbpp != 24 && s_curbpp != 32) { + FCEU_printf(" Sorry, %dbpp modes are not supported by FCE Ultra. Supported bit depths are 8bpp, 16bpp, and 32bpp.\n", s_curbpp); + KillVideo(); + return -1; + } - // if the game being run has a name, set it as the window name - if(gi) - { - if(gi->name) { - SDL_WM_SetCaption((const char *)gi->name, (const char *)gi->name); - } else { - SDL_WM_SetCaption(FCEU_NAME_AND_VERSION,"FCE Ultra"); - } - } + // if the game being run has a name, set it as the window name + if(gi) + { + if(gi->name) { + SDL_WM_SetCaption((const char *)gi->name, (const char *)gi->name); + } else { + SDL_WM_SetCaption(FCEU_NAME_AND_VERSION,"FCE Ultra"); + } + } - // create the surface for displaying graphical messages + // create the surface for displaying graphical messages #ifdef LSB_FIRST - s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data, - 32, 32, 24, 32 * 3, - 0xFF, 0xFF00, 0xFF0000, 0x00); + s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data, + 32, 32, 24, 32 * 3, + 0xFF, 0xFF00, 0xFF0000, 0x00); #else - s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data, - 32, 32, 24, 32 * 3, - 0xFF0000, 0xFF00, 0xFF, 0x00); + s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data, + 32, 32, 24, 32 * 3, + 0xFF0000, 0xFF00, 0xFF, 0x00); #endif - SDL_WM_SetIcon(s_IconSurface,0); - s_paletterefresh = 1; + SDL_WM_SetIcon(s_IconSurface,0); + s_paletterefresh = 1; - // XXX soules - can't SDL do this for us? - // if using more than 8bpp, initialize the conversion routines - if(s_curbpp > 8) { - InitBlitToHigh(s_curbpp >> 3, - s_screen->format->Rmask, - s_screen->format->Gmask, - s_screen->format->Bmask, - s_eefx, s_sponge, 0); + // XXX soules - can't SDL do this for us? + // if using more than 8bpp, initialize the conversion routines + if(s_curbpp > 8) { + InitBlitToHigh(s_curbpp >> 3, + s_screen->format->Rmask, + s_screen->format->Gmask, + s_screen->format->Bmask, + s_eefx, s_sponge, 0); #ifdef OPENGL - if(s_useOpenGL) - { - int openGLip; - g_config->getOption("SDL.OpenGLip", &openGLip); + if(s_useOpenGL) + { + int openGLip; + g_config->getOption("SDL.OpenGLip", &openGLip); - if(!InitOpenGL(NOFFSET, 256 - (s_clipSides ? 8 : 0), - s_srendline, s_erendline + 1, - s_exs, s_eys, s_eefx, - openGLip, xstretch, ystretch, s_screen)) - { - FCEUD_PrintError("Error initializing OpenGL."); - KillVideo(); - return -1; - } - } + if(!InitOpenGL(NOFFSET, 256 - (s_clipSides ? 8 : 0), + s_srendline, s_erendline + 1, + s_exs, s_eys, s_eefx, + openGLip, xstretch, ystretch, s_screen)) + { + FCEUD_PrintError("Error initializing OpenGL."); + KillVideo(); + return -1; + } + } #endif - } - return 0; + } + return 0; } /** * Toggles the full-screen display. */ -void -ToggleFS() +void ToggleFS() { // pause while we we are making the switch - bool paused = FCEUI_EmulationPaused(); - if(!paused) - FCEUI_ToggleEmulationPause(); + bool paused = FCEUI_EmulationPaused(); + if(!paused) + FCEUI_ToggleEmulationPause(); - int error, fullscreen = s_fullscreen; + int error, fullscreen = s_fullscreen; - // shut down the current video system - KillVideo(); + // shut down the current video system + KillVideo(); - // flip the fullscreen flag - g_config->setOption("SDL.Fullscreen", !fullscreen); + // flip the fullscreen flag + g_config->setOption("SDL.Fullscreen", !fullscreen); #ifdef _GTK - if(noGui == 0) - { - if(!fullscreen) - showGui(0); - else - showGui(1); - } + if(noGui == 0) + { + if(!fullscreen) + showGui(0); + else + showGui(1); + } #endif - // try to initialize the video - error = InitVideo(GameInfo); - if(error) { - // if we fail, just continue with what worked before - g_config->setOption("SDL.Fullscreen", fullscreen); - InitVideo(GameInfo); - } - // if we paused to make the switch; unpause - if(!paused) - FCEUI_ToggleEmulationPause(); + // try to initialize the video + error = InitVideo(GameInfo); + if(error) { + // if we fail, just continue with what worked before + g_config->setOption("SDL.Fullscreen", fullscreen); + InitVideo(GameInfo); + } + // if we paused to make the switch; unpause + if(!paused) + FCEUI_ToggleEmulationPause(); } static SDL_Color s_psdl[256]; @@ -542,11 +535,11 @@ FCEUD_SetPalette(uint8 index, uint8 g, uint8 b) { - s_psdl[index].r = r; - s_psdl[index].g = g; - s_psdl[index].b = b; + s_psdl[index].r = r; + s_psdl[index].g = g; + s_psdl[index].b = b; - s_paletterefresh = 1; + s_paletterefresh = 1; } /** @@ -554,33 +547,33 @@ FCEUD_SetPalette(uint8 index, */ void FCEUD_GetPalette(uint8 index, - uint8 *r, - uint8 *g, - uint8 *b) + uint8 *r, + uint8 *g, + uint8 *b) { - *r = s_psdl[index].r; - *g = s_psdl[index].g; - *b = s_psdl[index].b; + *r = s_psdl[index].r; + *g = s_psdl[index].g; + *b = s_psdl[index].b; } /** * Pushes the palette structure into the underlying video subsystem. */ -static void -RedoPalette() +static void RedoPalette() { #ifdef OPENGL - if(s_useOpenGL) - SetOpenGLPalette((uint8*)s_psdl); - else + if(s_useOpenGL) + SetOpenGLPalette((uint8*)s_psdl); + else #endif - { - if(s_curbpp > 8) { - SetPaletteBlitToHigh((uint8*)s_psdl); - } else { - SDL_SetPalette(s_screen, SDL_PHYSPAL, s_psdl, 0, 256); - } - } + { + if(s_curbpp > 8) { + SetPaletteBlitToHigh((uint8*)s_psdl); + } else + { + SDL_SetPalette(s_screen, SDL_PHYSPAL, s_psdl, 0, 256); + } + } } // XXX soules - console lock/unlock unimplemented? @@ -597,102 +590,102 @@ void UnlockConsole(){} void BlitScreen(uint8 *XBuf) { - SDL_Surface *TmpScreen; - uint8 *dest; - int xo = 0, yo = 0; + SDL_Surface *TmpScreen; + uint8 *dest; + int xo = 0, yo = 0; - if(!s_screen) { - return; - } + if(!s_screen) { + return; + } - // refresh the palette if required - if(s_paletterefresh) { - RedoPalette(); - s_paletterefresh = 0; - } + // refresh the palette if required + if(s_paletterefresh) { + RedoPalette(); + s_paletterefresh = 0; + } #ifdef OPENGL - // OpenGL is handled separately - if(s_useOpenGL) { - BlitOpenGL(XBuf); - return; - } + // OpenGL is handled separately + if(s_useOpenGL) { + BlitOpenGL(XBuf); + return; + } #endif - // XXX soules - not entirely sure why this is being done yet - XBuf += s_srendline * 256; + // XXX soules - not entirely sure why this is being done yet + XBuf += s_srendline * 256; - if(s_BlitBuf) { - TmpScreen = s_BlitBuf; - } else { - TmpScreen = s_screen; - } + if(s_BlitBuf) { + TmpScreen = s_BlitBuf; + } else { + TmpScreen = s_screen; + } - // lock the display, if necessary - if(SDL_MUSTLOCK(TmpScreen)) { - if(SDL_LockSurface(TmpScreen) < 0) { - return; - } - } + // lock the display, if necessary + if(SDL_MUSTLOCK(TmpScreen)) { + if(SDL_LockSurface(TmpScreen) < 0) { + return; + } + } - dest = (uint8*)TmpScreen->pixels; + dest = (uint8*)TmpScreen->pixels; - if(s_fullscreen) { - xo = (int)(((TmpScreen->w - NWIDTH * s_exs)) / 2); - dest += xo * (s_curbpp >> 3); - if(TmpScreen->h > (s_tlines * s_eys)) { - yo = (int)((TmpScreen->h - s_tlines * s_eys) / 2); - dest += yo * TmpScreen->pitch; - } - } + if(s_fullscreen) { + xo = (int)(((TmpScreen->w - NWIDTH * s_exs)) / 2); + dest += xo * (s_curbpp >> 3); + if(TmpScreen->h > (s_tlines * s_eys)) { + yo = (int)((TmpScreen->h - s_tlines * s_eys) / 2); + dest += yo * TmpScreen->pitch; + } + } - // XXX soules - again, I'm surprised SDL can't handle this - // perform the blit, converting bpp if necessary - if(s_curbpp > 8) { - if(s_BlitBuf) { - Blit8ToHigh(XBuf + NOFFSET, dest, NWIDTH, s_tlines, - TmpScreen->pitch, 1, 1); - } else { - Blit8ToHigh(XBuf + NOFFSET, dest, NWIDTH, s_tlines, - TmpScreen->pitch, (int)s_exs, (int)s_eys); - } - } else { - if(s_BlitBuf) { - Blit8To8(XBuf + NOFFSET, dest, NWIDTH, s_tlines, - TmpScreen->pitch, 1, 1, 0, s_sponge); - } else { - Blit8To8(XBuf + NOFFSET, dest, NWIDTH, s_tlines, - TmpScreen->pitch, (int)s_exs, (int)s_eys, - s_eefx, s_sponge); - } - } + // XXX soules - again, I'm surprised SDL can't handle this + // perform the blit, converting bpp if necessary + if(s_curbpp > 8) { + if(s_BlitBuf) { + Blit8ToHigh(XBuf + NOFFSET, dest, NWIDTH, s_tlines, + TmpScreen->pitch, 1, 1); + } else { + Blit8ToHigh(XBuf + NOFFSET, dest, NWIDTH, s_tlines, + TmpScreen->pitch, (int)s_exs, (int)s_eys); + } + } else { + if(s_BlitBuf) { + Blit8To8(XBuf + NOFFSET, dest, NWIDTH, s_tlines, + TmpScreen->pitch, 1, 1, 0, s_sponge); + } else { + Blit8To8(XBuf + NOFFSET, dest, NWIDTH, s_tlines, + TmpScreen->pitch, (int)s_exs, (int)s_eys, + s_eefx, s_sponge); + } + } - // unlock the display, if necessary - if(SDL_MUSTLOCK(TmpScreen)) { - SDL_UnlockSurface(TmpScreen); - } + // unlock the display, if necessary + if(SDL_MUSTLOCK(TmpScreen)) { + SDL_UnlockSurface(TmpScreen); + } - // if we have a hardware video buffer, do a fast video->video copy - if(s_BlitBuf) { - SDL_Rect srect; - SDL_Rect drect; + // if we have a hardware video buffer, do a fast video->video copy + if(s_BlitBuf) { + SDL_Rect srect; + SDL_Rect drect; - srect.x = 0; - srect.y = 0; - srect.w = NWIDTH; - srect.h = s_tlines; + srect.x = 0; + srect.y = 0; + srect.w = NWIDTH; + srect.h = s_tlines; - drect.x = 0; - drect.y = 0; - drect.w = (Uint16)(s_exs * NWIDTH); - drect.h = (Uint16)(s_eys * s_tlines); + drect.x = 0; + drect.y = 0; + drect.w = (Uint16)(s_exs * NWIDTH); + drect.h = (Uint16)(s_eys * s_tlines); - SDL_BlitSurface(s_BlitBuf, &srect, s_screen, &drect); - } + SDL_BlitSurface(s_BlitBuf, &srect, s_screen, &drect); + } - // ensure that the display is updated - SDL_UpdateRect(s_screen, xo, yo, - (Uint32)(NWIDTH * s_exs), (Uint32)(s_tlines * s_eys)); + // ensure that the display is updated + SDL_UpdateRect(s_screen, xo, yo, + (Uint32)(NWIDTH * s_exs), (Uint32)(s_tlines * s_eys)); #ifdef CREATE_AVI #if 0 /* PAL INTO NTSC HACK */ @@ -769,9 +762,9 @@ BlitScreen(uint8 *XBuf) #endif // have to flip the displayed buffer in the case of double buffering - if(s_screen->flags & SDL_DOUBLEBUF) { - SDL_Flip(s_screen); - } + if(s_screen->flags & SDL_DOUBLEBUF) { + SDL_Flip(s_screen); + } } /** @@ -780,15 +773,15 @@ BlitScreen(uint8 *XBuf) */ uint32 PtoV(uint16 x, - uint16 y) + uint16 y) { - y = (uint16)((double)y / s_eys); - x = (uint16)((double)x / s_exs); - if(s_clipSides) { - x += 8; - } - y += s_srendline; - return (x | (y << 16)); + y = (uint16)((double)y / s_eys); + x = (uint16)((double)x / s_exs); + if(s_clipSides) { + x += 8; + } + y += s_srendline; + return (x | (y << 16)); } bool enableHUDrecording = false; diff --git a/src/drivers/sdl/sdl.cpp b/src/drivers/sdl/sdl.cpp index 6caaba87..5d6a1f66 100644 --- a/src/drivers/sdl/sdl.cpp +++ b/src/drivers/sdl/sdl.cpp @@ -59,7 +59,7 @@ int closeFinishedMovie = 0; int CloseGame(void); -static int inited = 0; +static int inited = 0; int eoptions=0;