removing lots of unused code
[drnoksnes] / platform / sdlv.cpp
index 39f68fe..7504231 100644 (file)
@@ -7,7 +7,6 @@
 
 #include "snes9x.h"
 #include "platform.h"
-#include "display.h"
 #include "gfx.h"
 #include "ppu.h"
 #include "sdlv.h"
@@ -129,13 +128,11 @@ static void setupVideoSurface()
        if (gameHeight > GUI.Height || gameWidth > GUI.Width)
                DIE("Video is larger than window size!");
 
-       const ScalerFactory* sFactory =
-               searchForScaler(Settings.SixteenBit ? 16 : 8, gameWidth, gameHeight);
+       const ScalerFactory* sFactory = searchForScaler(16, gameWidth, gameHeight);
+
+       screen = SDL_SetVideoMode(GUI.Width, GUI.Height, 16,
+               SDL_SWSURFACE | (Config.fullscreen ? SDL_FULLSCREEN : 0));
 
-       screen = SDL_SetVideoMode(GUI.Width, GUI.Height,
-                                                               Settings.SixteenBit ? 16 : 8,
-                                                               SDL_SWSURFACE |
-                                                               (Config.fullscreen ? SDL_FULLSCREEN : 0));
        if (!screen)
                DIE("SDL_SetVideoMode: %s", SDL_GetError());
        
@@ -144,18 +141,19 @@ static void setupVideoSurface()
        scaler = sFactory->instantiate(screen, gameWidth, gameHeight);
 
        // Each scaler may have its own pitch
-       GFX.RealPitch = GFX.Pitch = scaler->getDrawBufferPitch();
-       GFX.ZPitch = GFX.Pitch / 2; // gfx & tile.cpp depend on this, unfortunately.
-       GFX.PixSize = screen->format->BitsPerPixel / 8;
-       
+       GFX.Pitch = scaler->getDrawBufferPitch();
+       GFX.ZPitch = GFX.Pitch / 2;
+       // gfx & tile.cpp depend on the zbuffer pitch being always half of the color buffer pitch.
+       // Which is a pity, since the color buffer might be much larger.
+
        GFX.Screen = scaler->getDrawBuffer();
        GFX.SubScreen = (uint8 *) malloc(GFX.Pitch * IMAGE_HEIGHT);
        GFX.ZBuffer =  (uint8 *) malloc(GFX.ZPitch * IMAGE_HEIGHT);
        GFX.SubZBuffer = (uint8 *) malloc(GFX.ZPitch * IMAGE_HEIGHT);
 
        GFX.Delta = (GFX.SubScreen - GFX.Screen) >> 1;
-       GFX.PPL = GFX.Pitch >> 1;
-       GFX.PPLx2 = GFX.Pitch;
+       GFX.DepthDelta = GFX.SubZBuffer - GFX.ZBuffer;
+       GFX.PPL = GFX.Pitch / (screen->format->BitsPerPixel / 8);
 
        scaler->getRenderedGUIArea(GUI.RenderX, GUI.RenderY, GUI.RenderW, GUI.RenderH);
        scaler->getRatio(GUI.ScaleX, GUI.ScaleY);
@@ -176,8 +174,7 @@ static void drawOnscreenControls()
        if (Config.touchscreenShow) {
                scaler->pause();
                SDL_FillRect(screen, NULL, 0);
-               S9xInputScreenDraw(Settings.SixteenBit ? 2 : 1,
-                                                       screen->pixels, screen->pitch);
+               S9xInputScreenDraw(screen->pixels, screen->pitch);
                SDL_Flip(screen);
                scaler->resume();
        }
@@ -206,7 +203,7 @@ void S9xVideoToggleFullscreen()
        drawOnscreenControls();
 }
 
-void processVideoEvent(const SDL_Event& event)
+bool videoEventFilter(const SDL_Event& event)
 {
        // If we're in power save mode, and this is a defocus event, quit.
        if (Config.saver) {
@@ -214,30 +211,15 @@ void processVideoEvent(const SDL_Event& event)
                   (event.active.state & SDL_APPINPUTFOCUS) &&
                   !event.active.gain) {
                        S9xDoAction(kActionQuit);
-                       return;
+                       return true;
                }
        }
 
        // Forward video event to the active scaler, if any.
        if (scaler)
-               scaler->filter(event);
-}
-
-// This is here for completeness, but palette mode is mostly useless (slow).
-void S9xSetPalette ()
-{
-       if (Settings.SixteenBit) return;
-       
-       SDL_Color colors[256];
-       int brightness = IPPU.MaxBrightness *138;
-       for (int i = 0; i < 256; i++)
-       {
-               colors[i].r = ((PPU.CGDATA[i] >> 0) & 0x1F) * brightness;
-               colors[i].g = ((PPU.CGDATA[i] >> 5) & 0x1F) * brightness;
-               colors[i].b = ((PPU.CGDATA[i] >> 10) & 0x1F) * brightness;
-       }
-       
-       SDL_SetColors(screen, colors, 0, 256);
+               return scaler->filter(event);
+       else
+               return false;
 }
 
 /** Called before rendering a frame.
@@ -245,15 +227,26 @@ void S9xSetPalette ()
        while initializing video output.
        @return TRUE if we should render the frame.
  */
-bool8_32 S9xInitUpdate ()
+bool8 S9xInitUpdate ()
 {
        scaler->prepare();
 
        return TRUE;
 }
 
-/** Called after rendering a frame. */
-bool8_32 S9xDeinitUpdate (int width, int height, bool8_32 sixteenBit)
+/** Called once a complete SNES screen has been rendered into the GFX.Screen
+       memory buffer.
+
+       Now is your chance to copy the SNES rendered screen to the
+       host computer's screen memory. The problem is that you have to cope with
+       different sized SNES rendered screens. Width is always 256, unless you're
+       supporting SNES hi-res. screen modes (Settings.SupportHiRes is TRUE), in
+       which case it can be 256 or 512. The height parameter can be either 224 or
+       239 if you're only supporting SNES lo-res. screen modes, or 224, 239, 448 or
+       478 if hi-res. SNES screen modes are being supported.
+ */
+// TODO Above.
+bool8 S9xDeinitUpdate (int width, int height)
 {
        scaler->finish();