From: Holger Schemel Date: Tue, 15 Aug 2000 18:33:49 +0000 (+0200) Subject: rnd-20000815-2-src X-Git-Tag: 2.0.0^2~47 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=f7b1cff56121f72c25e1da08f53958ddab27ce75 rnd-20000815-2-src --- diff --git a/src/files.c b/src/files.c index f1872c68..37210cd7 100644 --- a/src/files.c +++ b/src/files.c @@ -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; iuser_defined ? getUserLevelDir("") : options.level_directory), - leveldir_current->filename); + leveldir_current->fullpath); if ((dir = opendir(level_directory)) == NULL) { diff --git a/src/game.c b/src/game.c index fa5942ff..4e716e3e 100644 --- a/src/game.c +++ b/src/game.c @@ -176,6 +176,9 @@ void GetPlayerConfig() setup.sound_music = FALSE; } + if (!fullscreen_available) + setup.fullscreen = FALSE; + setup.sound_simple = setup.sound; InitJoysticks(); diff --git a/src/init.c b/src/init.c index 114f61c0..7d97072e 100644 --- a/src/init.c +++ b/src/init.c @@ -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 diff --git a/src/joystick.h b/src/joystick.h index 64fd0069..06854359 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -19,6 +19,7 @@ /* values for the joystick */ #define JOYSTICK_OFF 0 #define JOYSTICK_AVAILABLE 1 + #ifdef __FreeBSD__ #include #define DEV_JOYSTICK_0 "/dev/joy0" @@ -89,4 +90,3 @@ int AnyJoystick(void); int AnyJoystickButton(void); #endif - diff --git a/src/main.c b/src/main.c index 7c51c2b6..b00e20a2 100644 --- a/src/main.c +++ b/src/main.c @@ -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; diff --git a/src/main.h b/src/main.h index acef2406..568e5c0e 100644 --- a/src/main.h +++ b/src/main.h @@ -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" diff --git a/src/msdos.h b/src/msdos.h index a67fe229..ce86234e 100644 --- a/src/msdos.h +++ b/src/msdos.h @@ -12,9 +12,17 @@ * msdos.h * ***********************************************************/ +#ifndef MSDOS_H +#define MSDOS_H + #include #include + +/* 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 */ diff --git a/src/screens.c b/src/screens.c index 2e206e21..d6ecb554 100644 --- a/src/screens.c +++ b/src/screens.c @@ -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) diff --git a/src/sdl.h b/src/sdl.h index 0b39620d..3c9ee80c 100644 --- a/src/sdl.h +++ b/src/sdl.h @@ -25,6 +25,13 @@ #include "mixer.h" #endif + +/* system dependent definitions */ + +#define PLATFORM_STRING "SDL" +#define FULLSCREEN_STATUS FULLSCREEN_AVAILABLE + + /* SDL type definitions */ typedef SDL_Surface *Bitmap; diff --git a/src/system.c b/src/system.c index cd713c97..b34fcd9a 100644 --- a/src/system.c +++ b/src/system.c @@ -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 diff --git a/src/system.h b/src/system.h index 3ccdbb6a..06d7a147 100644 --- a/src/system.h +++ b/src/system.h @@ -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 */ diff --git a/src/x11.h b/src/x11.h index e0e32dbb..d2f74adc 100644 --- a/src/x11.h +++ b/src/x11.h @@ -28,6 +28,16 @@ #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;