]> Shamusworld >> Repos - stargem2/blobdiff - src/video.cpp
Added config file key bindings, general code cleanup
[stargem2] / src / video.cpp
index 363896aedf910c8cffd4026fbc33c0fcd60eb4a6..da960c8c61b8b86aed4389c81b127acf0fce259b 100755 (executable)
@@ -152,6 +152,9 @@ WriteLog("\n");//*/
 //needed? Dunno. Mebbe an SDL function instead?
 //     memset(scrBuffer, 0x00, VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT * sizeof(uint32));
 
+       if (settings.fullscreen)
+               SDL_ShowCursor(SDL_DISABLE);
+
 #ifdef TEST_ALPHA_BLENDING
 //Here's some code to test alpha blending...
 //Well whaddya know, it works. :-)
@@ -184,172 +187,9 @@ void VideoDone(void)
 
 //     SDL_JoystickClose(joystick);
        SDL_FreeSurface(surface);
-//     SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER);
        SDL_Quit();
 }
 
-
-
-#if 0
-///
-
-#include "SDL.h"
-#include <string.h>    // Why??? (for memset, etc... Lazy!) Dunno why, but this just strikes me as wrong...
-#include <malloc.h>
-#include "sdlemu_opengl.h"
-#include "types.h"
-#include "log.h"
-#include "settings.h"
-#include "video.h"
-
-// External global variables
-
-SDL_Surface * surface, * mainSurface;
-Uint32 mainSurfaceFlags;
-uint8 * backbuffer;
-SDL_Joystick * joystick;
-uint8 color[16];
-uint32 palette[256];
-
-//
-// Prime SDL and create surfaces
-//
-bool InitVideo(void)
-{
-       // Set up SDL library
-       if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE) < 0)
-       {
-               WriteLog("Video: Could not initialize the SDL library: %s\n", SDL_GetError());
-               return false;
-       }
-
-       // Get proper info about the platform we're running on...
-       const SDL_VideoInfo * info = SDL_GetVideoInfo();
-
-       if (!info)
-       {
-               WriteLog("Video: SDL is unable to get the video info: %s\n", SDL_GetError());
-               return false;
-       }
-
-       if (1)//(vjs.useOpenGL)
-       {
-               mainSurfaceFlags = SDL_HWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF | SDL_OPENGL;
-               SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-       }
-       else
-       {
-               if (info->hw_available)
-               {
-                       mainSurfaceFlags = SDL_HWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF;
-                       WriteLog("Video: Hardware available...\n");
-               }
-
-               if (info->blit_hw)
-               {
-                       mainSurfaceFlags |= SDL_HWACCEL;
-                       WriteLog("Video: Hardware blit available...\n");
-               }
-       }
-
-//     if (vjs.fullscreen)
-//             mainSurfaceFlags |= SDL_FULLSCREEN;
-
-       if (0)//(!vjs.useOpenGL)
-               mainSurface = SDL_SetVideoMode(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT, 32, mainSurfaceFlags);
-       else
-               mainSurface = SDL_SetVideoMode(VIRTUAL_SCREEN_WIDTH * 2, VIRTUAL_SCREEN_HEIGHT * 2, 32, mainSurfaceFlags);
-
-       if (mainSurface == NULL)
-       {
-               WriteLog("Video: SDL is unable to set the video mode: %s\n", SDL_GetError());
-               return false;
-       }
-
-       SDL_WM_SetCaption("StarGem2", "StarGem2");
-
-       // Create the primary SDL display (8 BPP, palettized)
-//     surface = SDL_CreateRGBSurface(SDL_SWSURFACE, VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT,
-//             8, 0, 0, 0, 0);
-       // Create the primary SDL display (32 BPP)
-       surface = SDL_CreateRGBSurface(SDL_SWSURFACE, VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT, 32,
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
-               0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF
-#else
-               0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000
-#endif
-               );
-/*WriteLog("Video: Created secondary surface with attributes:\n\n");
-WriteLog("\tWidth, height: %u x %u\n", surface->w, surface->h);
-WriteLog("\t        Pitch: %u\n", surface->pitch);
-WriteLog("\t      Palette: %08X\n", surface->format->palette);
-WriteLog("\t          BPP: %u\n", surface->format->BitsPerPixel);
-WriteLog("\t      BytesPP: %u\n", surface->format->BytesPerPixel);
-WriteLog("\t        RMask: %08X\n", surface->format->Rmask);
-WriteLog("\t        GMask: %08X\n", surface->format->Gmask);
-WriteLog("\t        BMask: %08X\n", surface->format->Bmask);
-WriteLog("\t        AMask: %08X\n", surface->format->Amask);
-WriteLog("\n");//*/
-
-       if (surface == NULL)
-       {
-               WriteLog("Video: Could not create primary SDL surface: %s\n", SDL_GetError());
-               return false;
-       }
-
-       // Initialize Williams' palette (RGB coded as: 3 bits red, 3 bits green, 2 bits blue)
-       for(uint32 i=0; i<256; i++)
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
-               palette[i] = (((i & 0x01) * 33 + ((i & 0x02) >> 1) * 71 + ((i & 0x04) >> 2) * 151) << 24)
-                       | ((((i & 0x08) >> 3) * 33 + ((i & 0x10) >> 4) * 71 + ((i & 0x20) >> 5) * 151) << 16)
-                       | ((((i & 0x40) >> 6) * 71 + ((i & 0x80) >> 7) * 151) << 8) | 0xFF;//*/
-#else
-               palette[i] = ((i & 0x01) * 33 + ((i & 0x02) >> 1) * 71 + ((i & 0x04) >> 2) * 151)
-                       | ((((i & 0x08) >> 3) * 33 + ((i & 0x10) >> 4) * 71 + ((i & 0x20) >> 5) * 151) << 8)
-                       | ((((i & 0x40) >> 6) * 71 + ((i & 0x80) >> 7) * 151) << 16) | 0xFF000000;//*/
-#endif
-
-//     if (vjs.useOpenGL)
-       if (1)
-//Should make another setting here, for either linear or nearest (instead of just picking one)
-//And we have! ;-) Not... ;-(
-//             sdlemu_init_opengl(surface, 1/*method*/, 2/*size*/, 0);//vjs.glFilter/*texture type (linear, nearest)*/);
-               sdlemu_init_opengl(surface, mainSurface, 1 /*method*/,
-                       0 /*vjs.glFilter /texture type (linear, nearest)*/,
-                       0 /* Automatic bpp selection based upon src */);
-
-       // Initialize Joystick support under SDL
-/*     if (1)//(vjs.useJoystick)
-       {
-               if (SDL_NumJoysticks() <= 0)
-               {
-                       vjs.useJoystick = false;
-                       WriteLog("Video: No joystick(s) or joypad(s) detected on your system. Using keyboard...\n");
-               }
-               else
-               {
-                       if ((joystick = SDL_JoystickOpen(vjs.joyport)) == 0)
-                       {
-                               vjs.useJoystick = false;
-                               WriteLog("Video: Unable to open a Joystick on port: %d\n", (int)vjs.joyport);
-                       }
-                       else
-                               WriteLog("Video: Using: %s\n", SDL_JoystickName(vjs.joyport));
-               }
-       }*/
-
-       // Set up the backbuffer
-       backbuffer = (uint8 *)malloc(320 * 240 * sizeof(uint8));
-       memset(backbuffer, 0x00, VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT * sizeof(uint8));
-
-       WriteLog("Video: Successfully initialized.\n");
-       return true;
-}
-
-#endif
-
-
-
 //
 // Render the backbuffer to the primary screen surface
 //
@@ -380,77 +220,7 @@ SDL_BlitSurface(someAlphaSurface, NULL, surface, &dstRect);
     }
 }
 
-//
-// Render the backbuffer to the primary screen surface
-//
-void RenderScreenBuffer2(void)
-{
 #if 0
-//WriteLog("Video: Blitting a %u x %u surface to the main surface...", surface->w, surface->h);
-       if (SDL_MUSTLOCK(surface))
-               while (SDL_LockSurface(surface) < 0)
-                       SDL_Delay(10);
-
-//This *does* ignore the screen's actual pitch... !!! FIX !!!
-       uint32 * screen = (uint32 *)surface->pixels;
-       for(int i=0; i<320*240; i++)
-               screen[i] = palette[color[scrBuffer[i]]];
-//WriteLog("[blitted backbuffer]...");
-
-       if (SDL_MUSTLOCK(surface))
-               SDL_UnlockSurface(surface);
-#endif
-
-       if (settings.useOpenGL)
-               sdlemu_draw_texture(mainSurface, surface, 1/*1=GL_QUADS*/);
-       else
-       {
-               SDL_BlitSurface(surface, NULL, mainSurface, NULL);
-               SDL_Flip(mainSurface);
-    }
-//WriteLog("done.\n");
-}
-
-/*
-//
-// Resize the main SDL screen & backbuffer
-//
-void ResizeScreen(uint32 width, uint32 height)
-{
-       char window_title[256];
-
-       SDL_FreeSurface(surface);
-       surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 16,
-               0x7C00, 0x03E0, 0x001F, 0);
-
-       if (surface == NULL)
-       {
-               WriteLog("Video: Could not create primary SDL surface: %s", SDL_GetError());
-               exit(1);
-       }
-
-       if (vjs.useOpenGL)
-               // This seems to work well for resizing (i.e., changes in the pixel width)...
-               sdlemu_resize_texture(surface, mainSurface, vjs.glFilter);
-       else
-       {
-               mainSurface = SDL_SetVideoMode(width, height, 16, mainSurfaceFlags);
-
-               if (mainSurface == NULL)
-               {
-                       WriteLog("Video: SDL is unable to set the video mode: %s\n", SDL_GetError());
-                       exit(1);
-               }
-       }
-
-       sWriteLog(window_title, "Virtual Jaguar (%i x %i)", (int)width, (int)height);
-       SDL_WM_SetCaption(window_title, window_title);
-
-       // This seems to work well for resizing (i.e., changes in the pixel width)...
-//     if (vjs.useOpenGL)
-//             sdlemu_resize_texture(surface, mainSurface);
-}
-
 //
 // Fullscreen <-> window switching
 //
@@ -473,4 +243,4 @@ void ToggleFullscreen(void)
 
        SDL_WM_SetCaption("Virtual Jaguar", "Virtual Jaguar");
 }
-*/
+#endif