X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=2b1b7931420cc5d8f66cd702400d2b4db57bf917;hb=ee0895b12e544444db37febb1242bcc8a72d6ad8;hp=70604f2a9392854cd4bda2dc4fc30ad16bcb6105;hpb=93806fb4c23f4b6ef58d9562e908a1b89ece869d;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 70604f2a..2b1b7931 100644 --- a/src/init.c +++ b/src/init.c @@ -1,7 +1,7 @@ /*********************************************************** * Rocks'n'Diamonds -- McDuffin Strikes Back! * *----------------------------------------------------------* -* (c) 1995-2001 Artsoft Entertainment * +* (c) 1995-2002 Artsoft Entertainment * * Holger Schemel * * Detmolder Strasse 189 * * 33604 Bielefeld * @@ -23,33 +23,68 @@ #include "files.h" #include "network.h" #include "netserv.h" +#include "cartoons.h" +#include "config.h" + +#include "conf_e2g.c" /* include auto-generated data structure definitions */ + static char *image_filename[NUM_PICTURES] = { +#if 0 + "RocksScreen.pcx", + "RocksDoor.pcx", + "RocksToons.pcx", + "RocksFontBig.pcx", + "RocksFontSmall.pcx", + "RocksFontMedium.pcx", + "RocksFontEM.pcx" +#else "RocksScreen.pcx", + "RocksElements.pcx", "RocksDoor.pcx", "RocksHeroes.pcx", "RocksToons.pcx", "RocksSP.pcx", "RocksDC.pcx", "RocksMore.pcx", - "RocksFont.pcx", - "RocksFont2.pcx", - "RocksFont3.pcx" + "RocksFontBig.pcx", + "RocksFontSmall.pcx", + "RocksFontMedium.pcx", + "RocksFontEM.pcx" +#endif }; +static Bitmap *bitmap_font_initial = NULL; + +static void InitGlobal(void); +static void InitSetup(void); static void InitPlayerInfo(void); static void InitLevelInfo(void); +static void InitArtworkInfo(void); +static void InitLevelArtworkInfo(void); static void InitNetworkServer(void); +static void InitArtworkConfig(void); +static void InitImages(void); +static void InitMixer(void); static void InitSound(void); +static void InitMusic(void); static void InitGfx(void); -static void InitCustomGraphics(void); static void InitGfxBackground(void); static void InitGadgets(void); static void InitElementProperties(void); +static void InitElementInfo(void); +static void InitGraphicInfo(void); +static void InitSoundInfo(); +static void Execute_Command(char *); void OpenAll(void) { + InitGlobal(); /* initialize some global variables */ + + if (options.execute_command) + Execute_Command(options.execute_command); + if (options.serveronly) { #if defined(PLATFORM_UNIX) @@ -61,15 +96,19 @@ void OpenAll(void) } InitProgramInfo(UNIX_USERDATA_DIRECTORY, - PROGRAM_TITLE_STRING, WINDOW_TITLE_STRING, + PROGRAM_TITLE_STRING, getWindowTitleString(), ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME, MSDOS_POINTER_FILENAME, COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL); + InitSetup(); InitPlayerInfo(); + InitArtworkInfo(); /* needed before loading gfx, sound & music */ + InitArtworkConfig(); /* needed before forking sound child process */ + InitMixer(); InitCounter(); - InitSound(); + InitJoysticks(); InitRND(NEW_RANDOMIZE); @@ -79,21 +118,46 @@ void OpenAll(void) InitEventFilter(FilterMouseMotionEvents); + InitElementProperties(); + InitElementInfo(); + InitGfx(); - InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */ InitLevelInfo(); - InitGadgets(); /* needs to know number of level series */ + InitLevelArtworkInfo(); - InitCustomGraphics(); + InitImages(); /* needs to know current level directory */ + InitSound(); /* needs to know current level directory */ + InitMusic(); /* needs to know current level directory */ InitGfxBackground(); + + if (global.autoplay_leveldir) + { + AutoPlayTape(); + return; + } + DrawMainMenu(); InitNetworkServer(); } -void InitPlayerInfo() +static void InitGlobal() +{ + global.autoplay_leveldir = NULL; + + global.frames_per_second = 0; + global.fps_slowdown = FALSE; + global.fps_slowdown_factor = 1; +} + +static void InitSetup() +{ + LoadSetup(); /* global setup info */ +} + +static void InitPlayerInfo() { int i; @@ -104,17 +168,31 @@ void InitPlayerInfo() stored_player[i].connected = FALSE; local_player->connected = TRUE; - - LoadSetup(); /* global setup info */ } -void InitLevelInfo() +static void InitLevelInfo() { LoadLevelInfo(); /* global level info */ LoadLevelSetup_LastSeries(); /* last played series info */ LoadLevelSetup_SeriesInfo(); /* last played level info */ } +static void InitArtworkInfo() +{ + LoadArtworkInfo(); +} + +static void InitArtworkConfig() +{ + InitImageList(image_config, image_config_suffix, NUM_IMAGE_FILES); + InitSoundList(sound_config, sound_config_suffix, NUM_SOUND_FILES); +} + +void InitLevelArtworkInfo() +{ + LoadLevelArtworkInfo(); +} + void InitNetworkServer() { #if defined(PLATFORM_UNIX) @@ -138,38 +216,69 @@ void InitNetworkServer() #endif } -void InitSound() +static void InitMixer() { - int i; - OpenAudio(); + StartMixer(); +} - for(i=0; iidentifier); + ReinitializeSounds(); +} + +static void InitMusic() +{ + InitReloadCustomMusic(artwork.mus_current->identifier); + ReinitializeMusic(); +} + +static void InitTileClipmasks() +{ +#if 0 #if defined(TARGET_X11) - GC copy_clipmask_gc; XGCValues clip_gc_values; unsigned long clip_gc_valuemask; -#endif #if defined(TARGET_X11_NATIVE) + +#if 0 + GC copy_clipmask_gc; + static struct { int start; @@ -223,10 +332,13 @@ void InitTileClipmasks() }; #endif +#endif /* TARGET_X11_NATIVE */ +#endif /* TARGET_X11 */ + int i; /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */ - for(i=0; iclip_mask, - clip_gc_valuemask, &clip_gc_values); + tile_clip_gc = XCreateGC(display, window->drawable, + clip_gc_valuemask, &clip_gc_values); - clip_gc_values.graphics_exposures = False; - clip_gc_valuemask = GCGraphicsExposures; - tile_clip_gc = - XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values); - - for(i=0; iclip_mask) { @@ -255,26 +361,35 @@ void InitTileClipmasks() clip_gc_values.clip_mask = pix[i]->clip_mask; clip_gc_valuemask = GCGraphicsExposures | GCClipMask; pix[i]->stored_clip_gc = XCreateGC(display, window->drawable, - clip_gc_valuemask,&clip_gc_values); + clip_gc_valuemask, &clip_gc_values); } } +#endif #if defined(TARGET_X11_NATIVE) + +#if 0 + /* create graphic context structures needed for clipping */ + clip_gc_values.graphics_exposures = False; + clip_gc_valuemask = GCGraphicsExposures; + copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask, + clip_gc_valuemask, &clip_gc_values); + /* create only those clipping Pixmaps we really need */ - for(i=0; tile_needs_clipping[i].start>=0; i++) + for (i=0; tile_needs_clipping[i].start>=0; i++) { int j; - for(j=0; jclip_mask; + getGraphicSource(graphic, &src_bitmap, &src_x, &src_y); + src_pixmap = src_bitmap->clip_mask; tile_clipmask[tile] = XCreatePixmap(display, window->drawable, TILEX, TILEY, 1); @@ -283,19 +398,54 @@ void InitTileClipmasks() src_x, src_y, TILEX, TILEY, 0, 0); } } + + XFreeGC(display, copy_clipmask_gc); +#endif + #endif /* TARGET_X11_NATIVE */ #endif /* TARGET_X11 */ +#endif } -void InitGfx() +void FreeTileClipmasks() { - char *filename; +#if 0 +#if defined(TARGET_X11) int i; - /* initialize some global variables */ - global.frames_per_second = 0; - global.fps_slowdown = FALSE; - global.fps_slowdown_factor = 1; + for (i=0; istored_clip_gc) + { + XFreeGC(display, pix[i]->stored_clip_gc); + pix[i]->stored_clip_gc = None; + } + } +#endif + +#endif /* TARGET_X11 */ +#endif +} + +void InitGfx() +{ +#if 0 + int i; +#endif /* initialize screen properties */ InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE, @@ -305,180 +455,720 @@ void InitGfx() InitGfxScrollbufferInfo(FXSIZE, FYSIZE); /* create additional image buffers for double-buffering */ - pix[PIX_DB_DOOR] = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH); - pix[PIX_DB_FIELD] = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH); + bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH); + bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH); - filename = getImageFilename(image_filename[PIX_SMALLFONT]); - if ((pix_default[PIX_SMALLFONT] = LoadImage(filename)) == NULL) - Error(ERR_EXIT, "LoadImage() failed: %s", GetError()); - pix_custom[PIX_SMALLFONT] = NULL; - pix[PIX_SMALLFONT] = pix_default[PIX_SMALLFONT]; +#if 0 + pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]); - InitFontInfo(NULL, NULL, pix[PIX_SMALLFONT]); + InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL); +#else + bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]); + + InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL); +#endif DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW); DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED); -#if defined(PLATFORM_MSDOS) - DrawInitText(PROGRAM_DOS_PORT_STRING, 210, FC_BLUE); - rest(200); -#endif - DrawInitText("Loading graphics:",120,FC_GREEN); - for(i=0; iidentifier; + char *snd_new_identifier = artwork.snd_current->identifier; + char *mus_new_identifier = artwork.mus_current->identifier; + boolean redraw_screen = FALSE; + + if (leveldir_current_identifier == NULL) + leveldir_current_identifier = leveldir_current->identifier; + #if 0 - int i; + printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier, + leveldir_current->graphics_set); + printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier, + leveldir_current->identifier); +#endif - for(i=0; i '%s' ('%s')\n", + artwork.gfx_current_identifier, artwork.gfx_current->filename); + printf("sounds --> '%s' ('%s')\n", + artwork.snd_current_identifier, artwork.snd_current->filename); + printf("music --> '%s' ('%s')\n", + artwork.mus_current_identifier, artwork.mus_current->filename); +#endif + + /* leveldir_current may be invalid (level group, parent link) */ + if (!validLevelSeries(leveldir_current)) + return; + +#if 0 + printf("--> '%s'\n", artwork.gfx_current_identifier); +#endif + + /* when a new level series was selected, check if there was a change + in custom artwork stored in level series directory */ + if (leveldir_current_identifier != leveldir_current->identifier) { - Bitmap *new_pic = - pix_custom[i] = LoadImage(image_filename[i]); + char *identifier_old = leveldir_current_identifier; + char *identifier_new = leveldir_current->identifier; + + if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) != + getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new)) + gfx_new_identifier = identifier_new; + if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) != + getTreeInfoFromIdentifier(artwork.snd_first, identifier_new)) + snd_new_identifier = identifier_new; + if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) != + getTreeInfoFromIdentifier(artwork.mus_first, identifier_new)) + mus_new_identifier = identifier_new; + + leveldir_current_identifier = leveldir_current->identifier; } + + /* custom level artwork configured in level series configuration file + always overrides custom level artwork stored in level series directory + and (level independant) custom artwork configured in setup menue */ + if (leveldir_current->graphics_set != NULL) + gfx_new_identifier = leveldir_current->graphics_set; + if (leveldir_current->sounds_set != NULL) + snd_new_identifier = leveldir_current->sounds_set; + if (leveldir_current->music_set != NULL) + mus_new_identifier = leveldir_current->music_set; + + if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 || + last_override_level_graphics != setup.override_level_graphics) + { +#if 1 + printf("RELOADING GRAPHICS '%s' -> '%s' (-> '%s')\n", + artwork.gfx_current_identifier, + artwork.gfx_current->identifier, + gfx_new_identifier); #endif -} -void InitCustomGraphics() -{ + setLevelArtworkDir(artwork.gfx_first); + + ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE); + + ReloadCustomImages(); + ReinitializeGraphics(); + + FreeTileClipmasks(); + InitTileClipmasks(); + #if 0 - static char *filename = NULL; + artwork.gfx_current_identifier = gfx_new_identifier; +#else + artwork.gfx_current_identifier = artwork.gfx_current->identifier; +#endif + last_override_level_graphics = setup.override_level_graphics; - /* look for optional directory ~/./graphics */ - filename = getPath2(getUserDataDir(), GRAPHICS_DIRECTORY); - if (access(dir, F_OK) == 0) - { + redraw_screen = TRUE; } + if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 || + last_override_level_sounds != setup.override_level_sounds) + { +#if 1 + printf("RELOADING SOUNDS '%s' -> '%s' (-> '%s')\n", + artwork.snd_current_identifier, + snd_new_identifier, + artwork.snd_current->identifier); +#endif + + /* set artwork path to send it to the sound server process */ + setLevelArtworkDir(artwork.snd_first); + InitReloadCustomSounds(snd_new_identifier); + ReinitializeSounds(); + +#if 0 + artwork.snd_current_identifier = snd_new_identifier; +#else + artwork.snd_current_identifier = artwork.snd_current->identifier; +#endif + last_override_level_sounds = setup.override_level_sounds; -(leveldir_current->user_defined ? - getUserLevelDir("") : - options.level_directory), - leveldir_current->fullpath, - basename); + redraw_screen = TRUE; + } + if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 || + last_override_level_music != setup.override_level_music) + { + /* set artwork path to send it to the sound server process */ + setLevelArtworkDir(artwork.mus_first); + InitReloadCustomMusic(mus_new_identifier); + ReinitializeMusic(); - filename = getPath3((leveldir_current->user_defined ? - getUserLevelDir("") : - options.level_directory), - leveldir_current->fullpath, - basename); +#if 0 + artwork.mus_current_identifier = mus_new_identifier; +#else + artwork.mus_current_identifier = artwork.mus_current->identifier; #endif -} + last_override_level_music = setup.override_level_music; -void InitGfxBackground() -{ - int x, y; + redraw_screen = TRUE; + } - drawto = backbuffer; - fieldbuffer = pix[PIX_DB_FIELD]; - SetDrawtoField(DRAW_BACKBUFFER); + if (redraw_screen) + { + InitGfxBackground(); - BlitBitmap(pix[PIX_BACK], backbuffer, 0,0, WIN_XSIZE,WIN_YSIZE, 0,0); - ClearRectangle(backbuffer, REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE); - ClearRectangle(pix[PIX_DB_DOOR], 0,0, 3*DXSIZE,DYSIZE+VYSIZE); + /* force redraw of (open or closed) door graphics */ + SetDoorState(DOOR_OPEN_ALL); + CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY); + } - for(x=0; x -1) + { + int element = element_to_graphic[i].element; + int direction = element_to_graphic[i].direction; + int action = element_to_graphic[i].action; + int graphic = element_to_graphic[i].graphic; + + if (action < 0) + action = ACTION_DEFAULT; + + if (direction > -1) + { + direction = MV_DIR_BIT(direction); + + element_info[element].direction_graphic[action][direction] = graphic; + } + else + element_info[element].graphic[action] = graphic; + + i++; + } + + /* now set all '-1' values to element specific default values */ + for (i=0; iwidth : TILEX) / TILEX; + int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY; + + graphic_info[graphic].bitmap = src_bitmap; + + graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX; + graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY; + graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET]; + graphic_info[graphic].offset_y = 0; + + /* animation frames are ordered vertically instead of horizontally */ + if (parameter[GFX_ARG_VERTICAL]) + { + graphic_info[graphic].offset_x = 0; + graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET]; + } + + /* optionally, the x and y offset of frames can be specified directly */ + if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE) + graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET]; + if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE) + graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET]; + + /* automatically determine correct number of frames, if not defined */ + if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE) + graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES]; + else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL]) + graphic_info[graphic].anim_frames = num_xtiles; + else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL]) + graphic_info[graphic].anim_frames = num_ytiles; + else + graphic_info[graphic].anim_frames = 1; + + graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY]; + if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */ + graphic_info[graphic].anim_delay = 1; + + /* set mode for animation frame order */ + if (parameter[GFX_ARG_MODE_LOOP]) + graphic_info[graphic].anim_mode = ANIM_LOOP; + else if (parameter[GFX_ARG_MODE_LINEAR]) + graphic_info[graphic].anim_mode = ANIM_LINEAR; + else if (parameter[GFX_ARG_MODE_PINGPONG]) + graphic_info[graphic].anim_mode = ANIM_PINGPONG; + else if (parameter[GFX_ARG_MODE_PINGPONG2]) + graphic_info[graphic].anim_mode = ANIM_PINGPONG2; + else if (parameter[GFX_ARG_MODE_RANDOM]) + graphic_info[graphic].anim_mode = ANIM_RANDOM; + else if (graphic_info[graphic].anim_frames > 1) + graphic_info[graphic].anim_mode = ANIM_LOOP; + else + graphic_info[graphic].anim_mode = ANIM_NONE; + + /* set additional flag to play animation frames in reverse order */ + if (parameter[GFX_ARG_MODE_REVERSE]) + graphic_info[graphic].anim_mode |= ANIM_REVERSE; + + /* set first frame of animation after determining animation mode */ + graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME]; + + /* automatically determine correct start frame, if not defined */ + if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE) + graphic_info[graphic].anim_start_frame = 0; + else if (graphic_info[graphic].anim_mode & ANIM_REVERSE) + graphic_info[graphic].anim_start_frame = + graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1; + + /* animation synchronized with global frame counter, not move position */ + graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC]; + + /* set global_sync for all animations with undefined "animation action" */ + if (parameter[GFX_ARG_GLOBAL_SYNC] == ARG_UNDEFINED_VALUE) + graphic_info[graphic].anim_global_sync = + (action == ACTION_DEFAULT ? TRUE : FALSE); + + /* "linear" animations are never globally synchronized */ + if (parameter[GFX_ARG_MODE_LINEAR]) + graphic_info[graphic].anim_global_sync = FALSE; +} + +static void InitGraphicInfo() +{ + static boolean clipmasks_initialized = FALSE; + static int gfx_action[NUM_IMAGE_FILES]; + int i; +#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) + Pixmap src_pixmap; + XGCValues clip_gc_values; + unsigned long clip_gc_valuemask; + GC copy_clipmask_gc = None; +#endif + + image_files = getCurrentImageList(); + + /* set temporary graphics action field to default value */ + for (i=0; i -1) + { + int action = element_to_graphic[i].action; + int graphic = element_to_graphic[i].graphic; + + if (action == -1) + action = ACTION_DEFAULT; + + gfx_action[graphic] = action; + + i++; + } + +#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) + if (clipmasks_initialized) + { + for (i=0; i src_bitmap->width || + src_y + TILEY > src_bitmap->height) + { + Error(ERR_RETURN_LINE, "-"); + Error(ERR_RETURN, "warning: error found in config file:"); + Error(ERR_RETURN, "- config file: '%s'", + getImageConfigFilename()); + Error(ERR_RETURN, "- config token: '%s'", + getTokenFromImageID(i)); + Error(ERR_RETURN, "- image file: '%s'", + src_bitmap->source_filename); + Error(ERR_RETURN, + "error: first animation frame out of bounds (%d, %d)", + src_x, src_y); + Error(ERR_RETURN, "custom graphic rejected for this element/action"); + Error(ERR_RETURN_LINE, "-"); + + set_graphic_parameters(i, gfx_action[i], + image_files[i].default_parameter); + } + + last_frame = graphic_info[i].anim_frames - 1; + getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y); + if (src_x < 0 || src_y < 0 || + src_x + TILEX > src_bitmap->width || + src_y + TILEY > src_bitmap->height) + { + Error(ERR_RETURN_LINE, "-"); + Error(ERR_RETURN, "warning: error found in config file:"); + Error(ERR_RETURN, "- config file: '%s'", + getImageConfigFilename()); + Error(ERR_RETURN, "- config token: '%s'", + getTokenFromImageID(i)); + Error(ERR_RETURN, "- image file: '%s'", + src_bitmap->source_filename); + Error(ERR_RETURN, + "error: last animation frame (%d) out of bounds (%d, %d)", + last_frame, src_x, src_y); + Error(ERR_RETURN, "custom graphic rejected for this element/action"); + Error(ERR_RETURN_LINE, "-"); + + set_graphic_parameters(i, gfx_action[i], + image_files[i].default_parameter); + } + +#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) + /* currently we need only a tile clip mask from the first frame */ + getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y); + + if (copy_clipmask_gc == None) + { + clip_gc_values.graphics_exposures = False; + clip_gc_valuemask = GCGraphicsExposures; + copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask, + clip_gc_valuemask, &clip_gc_values); + } + + graphic_info[i].clip_mask = + XCreatePixmap(display, window->drawable, TILEX, TILEY, 1); + + src_pixmap = src_bitmap->clip_mask; + XCopyArea(display, src_pixmap, graphic_info[i].clip_mask, + copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0); + + clip_gc_values.graphics_exposures = False; + clip_gc_values.clip_mask = graphic_info[i].clip_mask; + clip_gc_valuemask = GCGraphicsExposures | GCClipMask; + graphic_info[i].clip_gc = + XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values); +#endif + } + +#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) + if (copy_clipmask_gc) + XFreeGC(display, copy_clipmask_gc); +#endif + + clipmasks_initialized = TRUE; +} + +static void set_sound_parameters(int sound, int *parameter) +{ + /* explicit loop mode setting in configuration overrides default value */ + if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE) + sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP]; +} + +static void InitSoundInfo() +{ + int sound_effect_properties[NUM_SOUND_FILES]; + int i, j; + + sound_files = getCurrentSoundList(); + + /* initialize sound effect for all elements to "no sound" */ + for (i=0; i