/***********************************************************
-* 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-2000 Artsoft Entertainment *
+* Holger Schemel *
+* Detmolder Strasse 189 *
+* 33604 Bielefeld *
+* Germany *
+* e-mail: info@artsoft.org *
*----------------------------------------------------------*
-* init.c *
+* init.c *
***********************************************************/
#include <signal.h>
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,
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;
}
}
+
+ num_bg_loops = LoadMusic();
}
void InitSoundServer()
#endif /* !TARGET_SDL */
}
-void InitDisplay()
-{
- InitVideoDisplay();
- InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
- setup.fullscreen);
-}
-
void InitGfx()
{
int i;
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' */
- 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
-
-#else /* !TARGET_SDL */
-
+#if defined(TARGET_X11)
/* create graphic context structures needed for clipping */
clip_gc_values.graphics_exposures = False;
clip_gc_valuemask = GCGraphicsExposures;
src_x, src_y, TILEX, TILEY, 0, 0);
}
}
-
-#endif /* !TARGET_SDL */
+#endif /* TARGET_X11 */
}
void InitGfxBackground()
{
int i;
-#if defined(TARGET_SDL)
StopSounds();
FreeSounds(NUM_SOUNDS);
-#else
+
+#if !defined(TARGET_SDL)
if (audio.soundserver_pid)
- {
- StopSounds();
kill(audio.soundserver_pid, SIGTERM);
- FreeSounds(NUM_SOUNDS);
- }
#endif
for(i=0; i<NUM_BITMAPS; i++)
FreeBitmap(pix[i]);
-#if defined(TARGET_SDL)
KeyboardAutoRepeatOn();
-#else
-#if 0
- if (gc)
- XFreeGC(display, gc);
-#endif
+ CloseVideoDisplay();
- if (display)
- {
- KeyboardAutoRepeatOn();
- XCloseDisplay(display);
- }
-#endif
-
-#if !defined(PLATFORM_UNIX)
- dumpErrorFile();
-#endif
+ ClosePlatformDependantStuff();
exit(exit_value);
}