/***********************************************************
-* Rocks'n'Diamonds -- McDuffin Strikes Back! *
+* Rocks'n'Diamonds -- McDuffin Strikes Back! *
*----------------------------------------------------------*
-* (c) 1995-98 Artsoft Entertainment *
-* Holger Schemel *
-* Oststrasse 11a *
-* 33604 Bielefeld *
-* phone: ++49 +521 290471 *
-* email: aeglos@valinor.owl.de *
+* (c) 1995-2001 Artsoft Entertainment *
+* Holger Schemel *
+* Detmolder Strasse 189 *
+* 33604 Bielefeld *
+* Germany *
+* e-mail: info@artsoft.org *
*----------------------------------------------------------*
-* init.c *
+* init.c *
***********************************************************/
-#include <signal.h>
-
#include "libgame/libgame.h"
#include "init.h"
static void InitLevelInfo(void);
static void InitNetworkServer(void);
static void InitSound(void);
-static void InitSoundServer(void);
-static void InitDisplay(void);
static void InitGfx(void);
static void InitGfxBackground(void);
static void InitGadgets(void);
void OpenAll(void)
{
-#if !defined(PLATFORM_UNIX)
- initErrorFile();
-#endif
-
if (options.serveronly)
{
#if defined(PLATFORM_UNIX)
NetworkServer(options.server_port, options.serveronly);
#else
- Error(ERR_WARN, "networking not supported in Windows version");
+ Error(ERR_WARN, "networking only supported in Unix version");
#endif
-
- /* never reached */
- exit(0);
+ exit(0); /* never reached */
}
InitProgramInfo(UNIX_USERDATA_DIRECTORY,
InitCounter();
InitSound();
- InitSoundServer();
InitJoysticks();
InitRND(NEW_RANDOMIZE);
- signal(SIGINT, CloseAllAndExit);
- signal(SIGTERM, CloseAllAndExit);
+ InitVideoDisplay();
+ InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
+ setup.fullscreen);
- InitDisplay();
InitEventFilter(FilterMouseMotionEvents);
InitGfx();
{
int i;
- OpenAudio(&audio);
-
- AllocSoundArray(NUM_SOUNDS);
+ OpenAudio();
for(i=0; i<NUM_SOUNDS; i++)
{
- if (!LoadSound(i, sound_name[i]))
+ if (!LoadSound(sound_name[i]))
{
audio.sound_available = FALSE;
audio.loops_available = FALSE;
return;
}
}
-}
-
-void InitSoundServer()
-{
- if (!audio.sound_available)
- return;
-
-#if !defined(TARGET_SDL)
-#if defined(PLATFORM_UNIX)
-
- if (pipe(audio.soundserver_pipe) < 0)
- {
- Error(ERR_WARN, "cannot create pipe - no sounds");
- audio.sound_available = FALSE;
- return;
- }
- if ((audio.soundserver_pid = fork()) < 0)
- {
- Error(ERR_WARN, "cannot create sound server process - no sounds");
- audio.sound_available = FALSE;
- return;
- }
+ num_bg_loops = LoadMusic();
- if (audio.soundserver_pid == 0) /* we are child */
- {
- SoundServer();
-
- /* never reached */
- exit(0);
- }
- else /* we are parent */
- close(audio.soundserver_pipe[0]); /* no reading from pipe needed */
-
-#else /* !PLATFORM_UNIX */
-
- SoundServer();
-
-#endif /* !PLATFORM_UNIX */
-#endif /* !TARGET_SDL */
+ StartSoundserver();
}
void InitJoysticks()
#endif /* !TARGET_SDL */
}
-void InitDisplay()
-{
- InitVideoDisplay();
- InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
- setup.fullscreen);
-}
-
void InitGfx()
{
int i;
};
#endif
-#ifdef TARGET_X11
+#if defined(TARGET_X11_NATIVE)
static struct
{
int start;
InitFontInfo(pix[PIX_BIGFONT], pix[PIX_MEDIUMFONT], pix[PIX_SMALLFONT]);
- /* create additional image buffers for masking of graphics */
-
-#if defined(TARGET_SDL)
-
-#if 0
- /* initialize surface array to 'NULL' */
+ /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
for(i=0; i<NUM_TILES; i++)
- tile_masked[i] = NULL;
-
- /* create only those masked surfaces we really need */
- for(i=0; tile_needs_clipping[i].start>=0; i++)
- {
- for(j=0; j<tile_needs_clipping[i].count; j++)
- {
- SDL_Surface *sdl_image_tmp;
- int tile = tile_needs_clipping[i].start + j;
- int graphic = tile;
- int src_x, src_y;
- int bitmap_nr;
- Bitmap src_bitmap;
-
- getGraphicSource(graphic, &bitmap_nr, &src_x, &src_y);
- src_bitmap = pix[bitmap_nr];
-
- /* create surface for masked tile graphic */
- 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", 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", SDL_GetError());
-
- SDL_FreeSurface(sdl_image_tmp);
-
- BlitBitmap(src_bitmap, tile_masked[tile], src_x,src_y, TILEX,TILEY, 0,0);
- }
- }
-#endif
+ tile_clipmask[i] = None;
-#else /* !TARGET_SDL */
+#if defined(TARGET_X11)
+ /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
+ often very slow when preparing a masked XCopyArea() for big Pixmaps.
+ To prevent this, create small (tile-sized) mask Pixmaps which will then
+ be set much faster with XSetClipOrigin() and speed things up a lot. */
/* create graphic context structures needed for clipping */
clip_gc_values.graphics_exposures = False;
}
}
- /* initialize pixmap array to Pixmap 'None' */
- for(i=0; i<NUM_TILES; i++)
- tile_clipmask[i] = None;
-
+#if defined(TARGET_X11_NATIVE)
/* create only those clipping Pixmaps we really need */
for(i=0; tile_needs_clipping[i].start>=0; i++)
{
src_x, src_y, TILEX, TILEY, 0, 0);
}
}
-
-#endif /* !TARGET_SDL */
+#endif /* TARGET_X11_NATIVE */
+#endif /* TARGET_X11 */
}
void InitGfxBackground()
EL_AMOEBE_BD,
EL_MORAST_VOLL,
EL_MORAST_LEER,
+ EL_QUICKSAND_FILLING,
+ EL_QUICKSAND_EMPTYING,
EL_MAGIC_WALL_OFF,
EL_MAGIC_WALL_EMPTY,
EL_MAGIC_WALL_FULL,
EL_EDELSTEIN_GELB,
EL_EDELSTEIN_ROT,
EL_EDELSTEIN_LILA,
- EL_DIAMANT,
- EL_SP_INFOTRON
+ EL_DIAMANT
};
static int ep_gem_num = sizeof(ep_gem)/sizeof(int);
{
int i;
-#if defined(TARGET_SDL)
StopSounds();
FreeSounds(NUM_SOUNDS);
-#else
- if (audio.soundserver_pid)
- {
- StopSounds();
- kill(audio.soundserver_pid, SIGTERM);
- FreeSounds(NUM_SOUNDS);
- }
-#endif
+ CloseAudio();
for(i=0; i<NUM_BITMAPS; i++)
FreeBitmap(pix[i]);
+ CloseVideoDisplay();
-#if defined(TARGET_SDL)
- KeyboardAutoRepeatOn();
-#else
-
-#if 0
- if (gc)
- XFreeGC(display, gc);
-#endif
-
- if (display)
- {
- KeyboardAutoRepeatOn();
- XCloseDisplay(display);
- }
-#endif
-
-#if !defined(PLATFORM_UNIX)
- dumpErrorFile();
-#endif
+ ClosePlatformDependantStuff();
exit(exit_value);
}