#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
{ 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" },
si->team_mode = FALSE;
si->handicap = TRUE;
si->time_limit = TRUE;
+ si->fullscreen = FALSE;
for (i=0; i<MAX_PLAYERS; i++)
{
level_directory = getPath2((leveldir_current->user_defined ?
getUserLevelDir("") :
options.level_directory),
- leveldir_current->filename);
+ leveldir_current->fullpath);
if ((dir = opendir(level_directory)) == NULL)
{
setup.sound_music = FALSE;
}
+ if (!fullscreen_available)
+ setup.fullscreen = FALSE;
+
setup.sound_simple = setup.sound;
InitJoysticks();
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);
exit(0);
}
+ InitPlayerInfo();
+
InitCounter();
InitSound();
InitSoundServer();
InitGfx();
InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */
- InitLevelAndPlayerInfo();
+ InitLevelInfo();
InitGadgets(); /* needs to know number of level series */
DrawMainMenu();
InitNetworkServer();
}
-void InitLevelAndPlayerInfo()
+void InitPlayerInfo()
{
int i;
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 */
}
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;
}
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;
}
}
#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);
{
#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);
#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);
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);
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);
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);
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);
#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);
}
#endif
-#ifdef MSDOS
+#if defined(MSDOS) || defined(WIN32)
dumpErrorFile();
#endif
/* values for the joystick */
#define JOYSTICK_OFF 0
#define JOYSTICK_AVAILABLE 1
+
#ifdef __FreeBSD__
#include <machine/joystick.h>
#define DEV_JOYSTICK_0 "/dev/joy0"
int AnyJoystickButton(void);
#endif
-
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];
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;
boolean team_mode;
boolean handicap;
boolean time_limit;
+ boolean fullscreen;
struct SetupInputInfo input[MAX_PLAYERS];
};
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;
#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"
* 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
void XAutoRepeatOn(Display *);
void XAutoRepeatOff(Display *);
void NetworkServer(int, int);
+
+#endif /* MSDOS_H */
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()
/* 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();
#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:" },
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)
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)
#include "mixer.h"
#endif
+
+/* system dependent definitions */
+
+#define PLATFORM_STRING "SDL"
+#define FULLSCREEN_STATUS FULLSCREEN_AVAILABLE
+
+
/* SDL type definitions */
typedef SDL_Surface *Bitmap;
***********************************************************/
#include "main.h"
+#include "misc.h"
+#include "tools.h"
inline void ClearRectangle(Bitmap bitmap, int x, int y, int width, int height)
{
}
/* execute all pending screen drawing operations */
-inline void FlushDisplay()
+inline void FlushDisplay(void)
{
#ifndef USE_SDL_LIBRARY
XFlush(display);
}
/* 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,
#endif
}
-inline void KeyboardAutoRepeatOff()
+inline void KeyboardAutoRepeatOff(void)
{
#ifdef USE_SDL_LIBRARY
SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
#endif
}
-inline boolean PendingEvent()
+inline boolean PendingEvent(void)
{
#ifdef USE_SDL_LIBRARY
return (SDL_PollEvent(NULL) ? TRUE : FALSE);
#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
#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)
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 */
#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;