rnd-20000815-2-src
authorHolger Schemel <info@artsoft.org>
Tue, 15 Aug 2000 18:33:49 +0000 (20:33 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:34:50 +0000 (10:34 +0200)
12 files changed:
src/files.c
src/game.c
src/init.c
src/joystick.h
src/main.c
src/main.h
src/msdos.h
src/screens.c
src/sdl.h
src/system.c
src/system.h
src/x11.h

index f1872c68512544ce4385b77813f2fd0faa24b864..37210cd7ecc37b2631f1d21ad805375e2dc3eb95 100644 (file)
@@ -1078,39 +1078,40 @@ void SaveScore(int level_nr)
 #define SETUP_TOKEN_TEAM_MODE          10
 #define SETUP_TOKEN_HANDICAP           11
 #define SETUP_TOKEN_TIME_LIMIT         12
+#define SETUP_TOKEN_FULLSCREEN         13
 
 /* player setup */
-#define SETUP_TOKEN_USE_JOYSTICK       13
-#define SETUP_TOKEN_JOY_DEVICE_NAME    14
-#define SETUP_TOKEN_JOY_XLEFT          15
-#define SETUP_TOKEN_JOY_XMIDDLE                16
-#define SETUP_TOKEN_JOY_XRIGHT         17
-#define SETUP_TOKEN_JOY_YUPPER         18
-#define SETUP_TOKEN_JOY_YMIDDLE                19
-#define SETUP_TOKEN_JOY_YLOWER         20
-#define SETUP_TOKEN_JOY_SNAP           21
-#define SETUP_TOKEN_JOY_BOMB           22
-#define SETUP_TOKEN_KEY_LEFT           23
-#define SETUP_TOKEN_KEY_RIGHT          24
-#define SETUP_TOKEN_KEY_UP             25
-#define SETUP_TOKEN_KEY_DOWN           26
-#define SETUP_TOKEN_KEY_SNAP           27
-#define SETUP_TOKEN_KEY_BOMB           28
+#define SETUP_TOKEN_USE_JOYSTICK       14
+#define SETUP_TOKEN_JOY_DEVICE_NAME    15
+#define SETUP_TOKEN_JOY_XLEFT          16
+#define SETUP_TOKEN_JOY_XMIDDLE                17
+#define SETUP_TOKEN_JOY_XRIGHT         18
+#define SETUP_TOKEN_JOY_YUPPER         19
+#define SETUP_TOKEN_JOY_YMIDDLE                20
+#define SETUP_TOKEN_JOY_YLOWER         21
+#define SETUP_TOKEN_JOY_SNAP           22
+#define SETUP_TOKEN_JOY_BOMB           23
+#define SETUP_TOKEN_KEY_LEFT           24
+#define SETUP_TOKEN_KEY_RIGHT          25
+#define SETUP_TOKEN_KEY_UP             26
+#define SETUP_TOKEN_KEY_DOWN           27
+#define SETUP_TOKEN_KEY_SNAP           28
+#define SETUP_TOKEN_KEY_BOMB           29
 
 /* level directory info */
-#define LEVELINFO_TOKEN_NAME           29
-#define LEVELINFO_TOKEN_NAME_SHORT     30
-#define LEVELINFO_TOKEN_NAME_SORTING   31
-#define LEVELINFO_TOKEN_AUTHOR         32
-#define LEVELINFO_TOKEN_IMPORTED_FROM  33
-#define LEVELINFO_TOKEN_LEVELS         34
-#define LEVELINFO_TOKEN_FIRST_LEVEL    35
-#define LEVELINFO_TOKEN_SORT_PRIORITY  36
-#define LEVELINFO_TOKEN_LEVEL_GROUP    37
-#define LEVELINFO_TOKEN_READONLY       38
+#define LEVELINFO_TOKEN_NAME           30
+#define LEVELINFO_TOKEN_NAME_SHORT     31
+#define LEVELINFO_TOKEN_NAME_SORTING   32
+#define LEVELINFO_TOKEN_AUTHOR         33
+#define LEVELINFO_TOKEN_IMPORTED_FROM  34
+#define LEVELINFO_TOKEN_LEVELS         35
+#define LEVELINFO_TOKEN_FIRST_LEVEL    36
+#define LEVELINFO_TOKEN_SORT_PRIORITY  37
+#define LEVELINFO_TOKEN_LEVEL_GROUP    38
+#define LEVELINFO_TOKEN_READONLY       39
 
 #define FIRST_GLOBAL_SETUP_TOKEN       SETUP_TOKEN_PLAYER_NAME
-#define LAST_GLOBAL_SETUP_TOKEN                SETUP_TOKEN_TIME_LIMIT
+#define LAST_GLOBAL_SETUP_TOKEN                SETUP_TOKEN_FULLSCREEN
 
 #define FIRST_PLAYER_SETUP_TOKEN       SETUP_TOKEN_USE_JOYSTICK
 #define LAST_PLAYER_SETUP_TOKEN                SETUP_TOKEN_KEY_BOMB
@@ -1154,6 +1155,7 @@ static struct
   { TYPE_SWITCH,  &si.team_mode,       "team_mode"                     },
   { TYPE_SWITCH,  &si.handicap,                "handicap"                      },
   { TYPE_SWITCH,  &si.time_limit,      "time_limit"                    },
+  { TYPE_SWITCH,  &si.fullscreen,      "fullscreen"                    },
 
   /* player setup */
   { TYPE_BOOLEAN, &sii.use_joystick,   ".use_joystick"                 },
@@ -1527,6 +1529,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->team_mode = FALSE;
   si->handicap = TRUE;
   si->time_limit = TRUE;
+  si->fullscreen = FALSE;
 
   for (i=0; i<MAX_PLAYERS; i++)
   {
@@ -2077,7 +2080,7 @@ static void checkSeriesInfo()
   level_directory = getPath2((leveldir_current->user_defined ?
                              getUserLevelDir("") :
                              options.level_directory),
-                            leveldir_current->filename);
+                            leveldir_current->fullpath);
 
   if ((dir = opendir(level_directory)) == NULL)
   {
index fa5942ffe86851c95d0a37863dbcddebedcedf5e..4e716e3e9cf894b0f5d36099f07aae4526c4fbd6 100644 (file)
@@ -176,6 +176,9 @@ void GetPlayerConfig()
     setup.sound_music = FALSE;
   }
 
+  if (!fullscreen_available)
+    setup.fullscreen = FALSE;
+
   setup.sound_simple = setup.sound;
 
   InitJoysticks();
index 114f61c01aedfa9e6b610e0fa63e513a6520dc02..7d97072ef0ac2b236aafdbc5019135e943632810 100644 (file)
@@ -45,7 +45,8 @@ struct IconFileInfo
 static int sound_process_id = 0;
 #endif
 
-static void InitLevelAndPlayerInfo(void);
+static void InitPlayerInfo(void);
+static void InitLevelInfo(void);
 static void InitNetworkServer(void);
 static void InitDisplay(void);
 static void InitSound(void);
@@ -74,6 +75,8 @@ void OpenAll(int argc, char *argv[])
     exit(0);
   }
 
+  InitPlayerInfo();
+
   InitCounter();
   InitSound();
   InitSoundServer();
@@ -94,7 +97,7 @@ void OpenAll(int argc, char *argv[])
   InitGfx();
   InitElementProperties();     /* initializes IS_CHAR() for el2gfx() */
 
-  InitLevelAndPlayerInfo();
+  InitLevelInfo();
   InitGadgets();               /* needs to know number of level series */
 
   DrawMainMenu();
@@ -102,7 +105,7 @@ void OpenAll(int argc, char *argv[])
   InitNetworkServer();
 }
 
-void InitLevelAndPlayerInfo()
+void InitPlayerInfo()
 {
   int i;
 
@@ -117,8 +120,12 @@ void InitLevelAndPlayerInfo()
 
   local_player->connected = TRUE;
 
-  LoadLevelInfo();                             /* global level info */
   LoadSetup();                                 /* global setup info */
+}
+
+void InitLevelInfo()
+{
+  LoadLevelInfo();                             /* global level info */
   LoadLevelSetup_LastSeries();                 /* last played series info */
   LoadLevelSetup_SeriesInfo();                 /* last played level info */
 }
@@ -158,14 +165,14 @@ void InitSound()
 
   if (SDL_Init(SDL_INIT_AUDIO) < 0)
   {
-    Error(ERR_WARN, "SDL_Init() failed: %s\n", SDL_GetError());
+    Error(ERR_WARN, "SDL_Init() failed: %s", SDL_GetError());
     sound_status = SOUND_OFF;
     return;
   }
 
   if (Mix_OpenAudio(22050, AUDIO_S16, 2, 256) < 0)
   {
-    Error(ERR_WARN, "Mix_OpenAudio() failed: %s\n", SDL_GetError());
+    Error(ERR_WARN, "Mix_OpenAudio() failed: %s", SDL_GetError());
     sound_status = SOUND_OFF;
     return;
   }
@@ -294,7 +301,7 @@ void InitJoysticks()
 
     if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
     {
-      Error(ERR_EXIT, "SDL_Init() failed: %s\n", SDL_GetError());
+      Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
       return;
     }
   }
@@ -390,7 +397,7 @@ void InitDisplay()
 #ifdef USE_SDL_LIBRARY
   /* initialize SDL video */
   if (SDL_Init(SDL_INIT_VIDEO) < 0)
-    Error(ERR_EXIT, "SDL_Init() failed: %s\n", SDL_GetError());
+    Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
 
   /* automatically cleanup SDL stuff after exit() */
   atexit(SDL_Quit);
@@ -446,10 +453,15 @@ void InitWindow(int argc, char *argv[])
 {
 #ifdef USE_SDL_LIBRARY
   /* open SDL video output device (window or fullscreen mode) */
+#if 0
   if ((window = SDL_SetVideoMode(WIN_XSIZE, WIN_YSIZE, WIN_SDL_DEPTH,
                                 SDL_HWSURFACE))
       == NULL)
-    Error(ERR_EXIT, "SDL_SetVideoMode() failed: %s\n", SDL_GetError());
+    Error(ERR_EXIT, "SDL_SetVideoMode() failed: %s", SDL_GetError());
+#else
+  if (!SetVideoMode())
+    Error(ERR_EXIT, "setting video mode failed");
+#endif
 
   /* set window and icon title */
   SDL_WM_SetCaption(WINDOW_TITLE_STRING, WINDOW_TITLE_STRING);
@@ -700,11 +712,11 @@ void InitGfx()
 #endif
 #endif
 
-  LoadGfx(PIX_SMALLFONT,&pic[PIX_SMALLFONT]);
-  DrawInitText(WINDOW_TITLE_STRING,20,FC_YELLOW);
-  DrawInitText(COPYRIGHT_STRING,50,FC_RED);
+  LoadGfx(PIX_SMALLFONT, &pic[PIX_SMALLFONT]);
+  DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
+  DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
 #ifdef MSDOS
-  DrawInitText("MSDOS version done by Guido Schulz",210,FC_BLUE);
+  DrawInitText(PROGRAM_DOS_PORT_STRING, 210, FC_BLUE);
   rest(200);
 #endif /* MSDOS */
   DrawInitText("Loading graphics:",120,FC_GREEN);
@@ -725,10 +737,10 @@ void InitGfx()
                                            WIN_XSIZE, WIN_YSIZE,
                                            WIN_SDL_DEPTH, 0, 0, 0, 0))
       == NULL)
-    Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s\n", SDL_GetError());
+    Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
 
   if ((pix[PIX_DB_BACK] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
-    Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
+    Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
 
   SDL_FreeSurface(sdl_image_tmp);
 
@@ -737,10 +749,10 @@ void InitGfx()
                                            3 * DXSIZE, DYSIZE + VYSIZE,
                                            WIN_SDL_DEPTH, 0, 0, 0, 0))
       == NULL)
-    Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s\n", SDL_GetError());
+    Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
 
   if ((pix[PIX_DB_DOOR] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
-    Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
+    Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
 
   SDL_FreeSurface(sdl_image_tmp);
 
@@ -749,10 +761,10 @@ void InitGfx()
                                            FXSIZE, FYSIZE,
                                            WIN_SDL_DEPTH, 0, 0, 0, 0))
       == NULL)
-    Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s\n", SDL_GetError());
+    Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
 
   if ((pix[PIX_DB_FIELD] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
-    Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
+    Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
 
   SDL_FreeSurface(sdl_image_tmp);
 
@@ -778,13 +790,13 @@ void InitGfx()
       if ((sdl_image_tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, TILEX, TILEY,
                                                WIN_SDL_DEPTH, 0, 0, 0, 0))
          == NULL)
-       Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s\n", SDL_GetError());
+       Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
 
       /* create native transparent surface for current image */
       SDL_SetColorKey(sdl_image_tmp, SDL_SRCCOLORKEY,
                      SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
       if ((tile_masked[tile] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
-       Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
+       Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
 
       SDL_FreeSurface(sdl_image_tmp);
 
@@ -912,17 +924,17 @@ void LoadGfx(int pos, struct PictureFileInfo *pic)
 #ifdef USE_SDL_LIBRARY
     /* load image to temporary surface */
     if ((sdl_image_tmp = IMG_Load(filename)) == NULL)
-      Error(ERR_EXIT, "IMG_Load() failed: %s\n", SDL_GetError());
+      Error(ERR_EXIT, "IMG_Load() failed: %s", SDL_GetError());
 
     /* create native non-transparent surface for current image */
     if ((pix[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
-      Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
+      Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
 
     /* create native transparent surface for current image */
     SDL_SetColorKey(sdl_image_tmp, SDL_SRCCOLORKEY,
                    SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
     if ((pix_masked[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
-      Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
+      Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
 
     /* free temporary surface */
     SDL_FreeSurface(sdl_image_tmp);
@@ -2254,7 +2266,7 @@ void CloseAllAndExit(int exit_value)
   }
 #endif
 
-#ifdef MSDOS
+#if defined(MSDOS) || defined(WIN32)
   dumpErrorFile();
 #endif
 
index 64fd00690bf2e106baa661f10de0619a67d82fdd..068543595f6802233a75e78e77323dd7390e8c8e 100644 (file)
@@ -19,6 +19,7 @@
 /* values for the joystick */
 #define JOYSTICK_OFF           0
 #define        JOYSTICK_AVAILABLE      1
+
 #ifdef __FreeBSD__
 #include <machine/joystick.h>
 #define DEV_JOYSTICK_0         "/dev/joy0"
@@ -89,4 +90,3 @@ int AnyJoystick(void);
 int AnyJoystickButton(void);
 
 #endif
-
index 7c51c2b6810683cee41230f8c2dc72f1691a2835..b00e20a28ef67f89800e2897503ce700ea369f4c 100644 (file)
@@ -26,7 +26,7 @@
 Display        *display;
 Visual        *visual;
 int            screen;
-DrawWindow     window;
+DrawWindow     window = None;
 GC             gc, clip_gc[NUM_BITMAPS], tile_clip_gc;
 Bitmap         pix[NUM_BITMAPS];
 Bitmap         pix_masked[NUM_BITMAPS], tile_masked[NUM_TILES];
@@ -63,6 +63,8 @@ int           global_joystick_status = JOYSTICK_STATUS;
 int            joystick_status = JOYSTICK_STATUS;
 int            sound_status = SOUND_STATUS;
 boolean                sound_loops_allowed = FALSE;
+boolean                fullscreen_available = FULLSCREEN_STATUS;
+boolean                fullscreen_enabled = FALSE;
 
 boolean                redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
 int            redraw_x1 = 0, redraw_y1 = 0;
index acef24060cc39544b56dd7b6989eba756ca6288e..568e5c0eba1f1bc97bf6c99b1b59a9e3a6d3b68f 100644 (file)
@@ -294,6 +294,7 @@ struct SetupInfo
   boolean team_mode;
   boolean handicap;
   boolean time_limit;
+  boolean fullscreen;
 
   struct SetupInputInfo input[MAX_PLAYERS];
 };
@@ -478,6 +479,8 @@ extern int          key_joystick_mapping;
 extern int             global_joystick_status, joystick_status;
 extern int             sound_status;
 extern boolean         sound_loops_allowed;
+extern boolean         fullscreen_available;
+extern boolean         fullscreen_enabled;
 
 extern boolean         redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
 extern int             redraw_x1, redraw_y1;
@@ -1649,15 +1652,14 @@ extern char             *element_info[];
 #define TAPES_DIRECTORY                "tapes"
 #define SCORES_DIRECTORY       "scores"
 
-#ifdef USE_SDL_LIBRARY
-#define PROGRAM_VERSION_STRING "1.4.0 SDL"
-#else
-#define PROGRAM_VERSION_STRING "1.4.0"
-#endif
+#define PROGRAM_VERSION_STRING "1.5.0"
 #define PROGRAM_TITLE_STRING   "Rocks'n'Diamonds"
 #define PROGRAM_AUTHOR_STRING  "Holger Schemel"
-#define WINDOW_TITLE_STRING    PROGRAM_TITLE_STRING " " PROGRAM_VERSION_STRING
-#define COPYRIGHT_STRING       "Copyright ^1995-2000 by " PROGRAM_AUTHOR_STRING
+#define PROGRAM_RIGHTS_STRING  "Copyright ^1995-2000 by"
+#define PROGRAM_DOS_PORT_STRING        "DOS port done by Guido Schulz"
+#define PROGRAM_IDENT_STRING   PROGRAM_VERSION_STRING " " PLATFORM_STRING
+#define WINDOW_TITLE_STRING    PROGRAM_TITLE_STRING " " PROGRAM_IDENT_STRING
+#define WINDOW_SUBTITLE_STRING PROGRAM_RIGHTS_STRING " " PROGRAM_AUTHOR_STRING
 
 /* default name for empty highscore entry */
 #define EMPTY_PLAYER_NAME      "no name"
index a67fe2297a86b3b5335eb7ecc7b38176d5b31cdd..ce86234e85e33f83331565e04006008b9a28e1aa 100644 (file)
 *  msdos.h                                                 *
 ***********************************************************/
 
+#ifndef MSDOS_H
+#define MSDOS_H
+
 #include <allegro.h>
 #include <time.h>
 
+
+/* system dependent definitions */
+
+#define PLATFORM_STRING                "DOS"
+
 /* allegro defines TRUE as -1 */
 #ifdef TRUE
 #undef TRUE
@@ -713,3 +721,5 @@ Bool XQueryPointer(Display *, Window, Window *, Window *, int *, int *,
 void XAutoRepeatOn(Display *);
 void XAutoRepeatOff(Display *);
 void NetworkServer(int, int);
+
+#endif /* MSDOS_H */
index 2e206e2186ec05dffb3366cb2eed227a9e436bae..d6ecb554bb3fc24f06e3988bc459b8c117d76e7d 100644 (file)
@@ -60,7 +60,7 @@ void DrawHeadline()
   int x = SX + (SXSIZE - strlen(PROGRAM_TITLE_STRING) * FONT1_XSIZE) / 2;
 
   DrawText(x, SY + 8, PROGRAM_TITLE_STRING, FS_BIG, FC_YELLOW);
-  DrawTextFCentered(46, FC_RED, COPYRIGHT_STRING);
+  DrawTextFCentered(46, FC_RED, WINDOW_SUBTITLE_STRING);
 }
 
 void DrawMainMenu()
@@ -84,6 +84,9 @@ void DrawMainMenu()
   /* needed if last screen was the editor screen */
   UndrawSpecialEditorDoor();
 
+  /* needed if last screen was the setup screen and fullscreen state changed */
+  ChangeVideoModeIfNeeded();
+
   /* map gadgets for main menu screen */
   MapTapeButtons();
 
@@ -1283,7 +1286,10 @@ void DrawSetupScreen()
 #endif
     { &setup.scroll_delay,     "Scroll Delay:" },
     { &setup.soft_scrolling,   "Soft Scroll.:" },
+#if 0
     { &setup.fading,           "Fading:"       },
+#endif
+    { &setup.fullscreen,       "Fullscreen:"   },
     { &setup.quick_doors,      "Quick Doors:"  },
     { &setup.autorecord,       "Auto-Record:"  },
     { &setup.team_mode,                "Team-Mode:"    },
@@ -1480,6 +1486,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
        setup.soft_scrolling = !setup.soft_scrolling;
       }
+#if 0
       else if (y==8)
       {
        if (setup.fading)
@@ -1488,6 +1495,15 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
        setup.fading = !setup.fading;
       }
+#endif
+      else if (y==8 && fullscreen_available)
+      {
+       if (setup.fullscreen)
+         DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
+       else
+         DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
+       setup.fullscreen = !setup.fullscreen;
+      }
       else if (y==9)
       {
        if (setup.quick_doors)
index 0b39620d1b1946c20a72454a74f2290676c76389..3c9ee80c679273eecdcc5311c948ab09ae3b9efa 100644 (file)
--- a/src/sdl.h
+++ b/src/sdl.h
 #include "mixer.h"
 #endif
 
+
+/* system dependent definitions */
+
+#define PLATFORM_STRING                "SDL"
+#define FULLSCREEN_STATUS      FULLSCREEN_AVAILABLE
+
+
 /* SDL type definitions */
 
 typedef SDL_Surface           *Bitmap;
index cd713c97e1962c95cfe82d357c8230462b4e8445..b34fcd9a1e3b738469b9e513e16d43058cefabc9 100644 (file)
@@ -13,6 +13,8 @@
 ***********************************************************/
 
 #include "main.h"
+#include "misc.h"
+#include "tools.h"
 
 inline void ClearRectangle(Bitmap bitmap, int x, int y, int width, int height)
 {
@@ -84,7 +86,7 @@ inline void DrawSimpleWhiteLine(Bitmap bitmap, int from_x, int from_y,
 }
 
 /* execute all pending screen drawing operations */
-inline void FlushDisplay()
+inline void FlushDisplay(void)
 {
 #ifndef USE_SDL_LIBRARY
   XFlush(display);
@@ -92,14 +94,14 @@ inline void FlushDisplay()
 }
 
 /* execute and wait for all pending screen drawing operations */
-inline void SyncDisplay()
+inline void SyncDisplay(void)
 {
 #ifndef USE_SDL_LIBRARY
   XSync(display, FALSE);
 #endif
 }
 
-inline void KeyboardAutoRepeatOn()
+inline void KeyboardAutoRepeatOn(void)
 {
 #ifdef USE_SDL_LIBRARY
   SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2,
@@ -110,7 +112,7 @@ inline void KeyboardAutoRepeatOn()
 #endif
 }
 
-inline void KeyboardAutoRepeatOff()
+inline void KeyboardAutoRepeatOff(void)
 {
 #ifdef USE_SDL_LIBRARY
   SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
@@ -137,7 +139,7 @@ inline boolean PointerInWindow(DrawWindow window)
 #endif
 }
 
-inline boolean PendingEvent()
+inline boolean PendingEvent(void)
 {
 #ifdef USE_SDL_LIBRARY
   return (SDL_PollEvent(NULL) ? TRUE : FALSE);
@@ -183,7 +185,90 @@ inline Key GetEventKey(KeyEvent *event, boolean with_modifiers)
 #endif
 }
 
-inline void dummy()
+inline boolean SetVideoMode(void)
+{
+  boolean success = TRUE;
+
+#ifdef USE_SDL_LIBRARY
+  if (setup.fullscreen && !fullscreen_enabled && fullscreen_available)
+  {
+    /* switch display to fullscreen mode, if available */
+    DrawWindow window_old = window;
+    DrawWindow window_new;
+
+    if ((window_new = SDL_SetVideoMode(WIN_XSIZE, WIN_YSIZE, WIN_SDL_DEPTH,
+                                      SDL_HWSURFACE|SDL_FULLSCREEN))
+       == NULL)
+    {
+      /* switching display to fullscreen mode failed */
+      Error(ERR_WARN, "SDL_SetVideoMode() failed: %s", SDL_GetError());
+
+      /* do not try it again */
+      fullscreen_available = FALSE;
+      success = FALSE;
+    }
+    else
+    {
+      if (window_old)
+       SDL_FreeSurface(window_old);
+      window = window_new;
+
+      fullscreen_enabled = TRUE;
+      success = TRUE;
+    }
+  }
+
+  if ((!setup.fullscreen && fullscreen_enabled) || !window)
+  {
+    /* switch display to window mode */
+    DrawWindow window_old = window;
+    DrawWindow window_new;
+
+    if ((window_new = SDL_SetVideoMode(WIN_XSIZE, WIN_YSIZE, WIN_SDL_DEPTH,
+                                      SDL_HWSURFACE))
+       == NULL)
+    {
+      /* switching display to window mode failed -- should not happen */
+      Error(ERR_WARN, "SDL_SetVideoMode() failed: %s", SDL_GetError());
+
+      success = FALSE;
+    }
+    else
+    {
+      if (window_old)
+       SDL_FreeSurface(window_old);
+      window = window_new;
+
+      fullscreen_enabled = FALSE;
+      success = TRUE;
+    }
+  }
+#else
+  if (setup.fullscreen && fullscreen_available)
+  {
+    Error(ERR_WARN, "fullscreen not available in X11 version");
+
+    /* display error message only once */
+    fullscreen_available = FALSE;
+
+    success = FALSE;
+  }
+#endif
+
+  return success;
+}
+
+inline void ChangeVideoModeIfNeeded(void)
+{
+#ifdef USE_SDL_LIBRARY
+  if ((setup.fullscreen && !fullscreen_enabled && fullscreen_available) ||
+      (!setup.fullscreen && fullscreen_enabled))
+    SetVideoMode();
+  SetDrawtoField(DRAW_BACKBUFFER);
+#endif
+}
+
+inline void dummy(void)
 {
 #ifdef USE_SDL_LIBRARY
 #else
index 3ccdbb6a17219235c0945763c752783fafbe2947..06d7a14796992e325852a2921681b34cd74f04f6 100644 (file)
@@ -28,6 +28,9 @@
 #include "msdos.h"
 #endif
 
+#define FULLSCREEN_NOT_AVAILABLE       FALSE
+#define FULLSCREEN_AVAILABLE           TRUE
+
 #if defined(USE_SDL_LIBRARY)
 #include "sdl.h"
 #elif defined(USE_X11_LIBRARY)
@@ -41,15 +44,18 @@ inline void SetClipOrigin(GC, int, int);
 inline void BlitBitmapMasked(Bitmap, Bitmap, int, int, int, int, int, int);
 inline void DrawSimpleWhiteLine(Bitmap, int, int, int, int);
 
-inline void FlushDisplay();
-inline void SyncDisplay();
-inline void KeyboardAutoRepeatOn();
-inline void KeyboardAutoRepeatOff();
+inline void FlushDisplay(void);
+inline void SyncDisplay(void);
+inline void KeyboardAutoRepeatOn(void);
+inline void KeyboardAutoRepeatOff(void);
 inline boolean PointerInWindow(DrawWindow);
 
-inline boolean PendingEvent();
+inline boolean PendingEvent(void);
 inline void NextEvent(Event *event);
 
 inline Key GetEventKey(KeyEvent *, boolean);
 
+inline boolean SetVideoMode(void);
+inline void ChangeVideoModeIfNeeded(void);
+
 #endif /* SYSTEM_H */
index e0e32dbbc1234da4e5a1916ff3b297742dda119a..d2f74adc49c05d289b5bfed9a7e1fb0416676f7a 100644 (file)
--- a/src/x11.h
+++ b/src/x11.h
 #endif /* !MSDOS */
 
 
+/* system dependent definitions */
+
+/* DOS version has already defined "PLATFORM_STRING" */
+#ifndef PLATFORM_STRING
+#define PLATFORM_STRING                "X11"
+#endif
+
+#define FULLSCREEN_STATUS      FULLSCREEN_NOT_AVAILABLE
+
+
 /* X11 type definitions */
 
 typedef Pixmap                 Bitmap;