-#define COMPILE_DATE_STRING "[2003-01-27 02:43]"
+#define COMPILE_DATE_STRING "[2003-01-27 04:33]"
if (game.magic_wall_active)
{
- boolean sieb = FALSE;
int jx = local_player->jx, jy = local_player->jy;
/* play the element sound at the position nearest to the player */
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 InitGfxBackground(void);
-static void InitGadgets(void);
-static void InitElementProperties(void);
-static void InitElementGraphicInfo(void);
-static void InitElementSoundInfo(void);
-static void InitGraphicInfo(void);
+static void InitGlobal();
+static void InitSetup();
+static void InitPlayerInfo();
+static void InitLevelInfo();
+static void InitArtworkInfo();
+static void InitLevelArtworkInfo();
+static void InitNetworkServer();
+static void InitArtworkConfig();
+static void InitImages();
+static void InitMixer();
+static void InitSound();
+static void InitMusic();
+static void InitGfx();
+static void InitGfxBackground();
+static void InitGadgets();
+static void InitElementImages();
+static void InitElementGraphicInfo();
+static void InitElementSoundInfo();
+static void InitElementProperties();
+static void InitGraphicInfo();
static void InitSoundInfo();
static void Execute_Command(char *);
-void OpenAll(void)
+void OpenAll()
{
InitGlobal(); /* initialize some global variables */
/* !!! TEST ONLY !!! */
+ if (0)
{
Bitmap *tst_bitmap = graphic_info[IMG_SAND].bitmap;
Bitmap *tmp_bitmap = ZoomBitmap(tst_bitmap,
FreeBitmap(tmp_bitmap);
}
+
+ if (1)
+ {
+ printf("CREATING SMALL IMAGES...\n");
+
+#if 1
+ InitElementImages();
+#else
+ CreateImageWithSmallImages(IMG_SAND);
+ CreateImageWithSmallImages(IMG_SAND);
+#endif
+
+ printf("DONE!\n");
+ }
}
static void ReinitializeSounds()
gadgets_initialized = TRUE;
}
+void InitElementImages()
+{
+ struct PropertyMapping *property_mapping = getImageListPropertyMapping();
+ int num_property_mappings = getImageListPropertyMappingSize();
+ int i;
+
+ /* initialize images from static configuration */
+ for (i=0; element_to_graphic[i].element > -1; i++)
+ CreateImageWithSmallImages(element_to_graphic[i].graphic);
+
+ /* initialize images from dynamic configuration */
+ for (i=0; i < num_property_mappings; i++)
+ CreateImageWithSmallImages(property_mapping[i].artwork_index);
+}
+
void InitElementGraphicInfo()
{
struct PropertyMapping *property_mapping = getImageListPropertyMapping();
int num_references;
Bitmap *bitmap;
+ boolean contains_small_images;
};
typedef struct ImageInfo ImageInfo;
img_info->source_filename = getStringCopy(filename);
+ img_info->contains_small_images = FALSE;
+
return img_info;
}
&image_info->dynamic_file_list[list_pos]);
}
+static ImageInfo *getImageInfoEntryFromImageID(int pos)
+{
+ int num_list_entries = image_info->num_file_list_entries;
+ int list_pos = (pos < num_list_entries ? pos : pos - num_list_entries);
+ ImageInfo **img_info =
+ (ImageInfo **)(pos < num_list_entries ? image_info->artwork_list :
+ image_info->dynamic_artwork_list);
+
+ return img_info[list_pos];
+}
+
Bitmap *getBitmapFromImageID(int pos)
{
+#if 0
int num_list_entries = image_info->num_file_list_entries;
int list_pos = (pos < num_list_entries ? pos : pos - num_list_entries);
ImageInfo **img_info =
image_info->dynamic_artwork_list);
return (img_info[list_pos] != NULL ? img_info[list_pos]->bitmap : NULL);
+#else
+ ImageInfo *img_info = getImageInfoEntryFromImageID(pos);
+
+ return (img_info != NULL ? img_info->bitmap : NULL);
+#endif
}
char *getTokenFromImageID(int graphic)
image_info->free_artwork = FreeImage;
}
-void dumpImages()
-{
- struct ListNode *node;
-
- if (image_info->content_list == NULL)
- return;
-
- for (node = image_info->content_list; node != NULL; node = node->next)
- {
- ImageInfo *img_info = (ImageInfo *)node->content;
-
- printf("---> '%s' [%d]\n",
- img_info->source_filename,
- img_info->num_references);
- }
-}
-
void ReloadCustomImages()
{
#if 0
LoadArtworkConfig(image_info);
ReloadCustomArtworkList(image_info);
+}
+
+void CreateImageWithSmallImages(int pos)
+{
+ ImageInfo *img_info = getImageInfoEntryFromImageID(pos);
+
+ if (img_info == NULL || img_info->contains_small_images)
+ return;
+
+ printf(" creating small image for '%s'\n", img_info->source_filename);
+
+ CreateBitmapWithSmallBitmaps(img_info->bitmap);
- dumpImages();
+ img_info->contains_small_images = TRUE;
}
void FreeAllImages()
struct PropertyMapping *getImageListPropertyMapping();
void InitImageList(struct ConfigInfo *, int, struct ConfigInfo *,
char **, char **, char **);
+
void ReloadCustomImages();
+void CreateImageWithSmallImages(int);
+
void FreeAllImages();
#endif /* IMAGE_H */
void SDLZoomBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap)
{
+ SDL_Surface *sdl_surface_tmp;
int dst_width = dst_bitmap->width;
int dst_height = dst_bitmap->height;
+ /* throw away old destination surface */
SDL_FreeSurface(dst_bitmap->surface);
- dst_bitmap->surface = zoomSurface(src_bitmap->surface, dst_width,dst_height);
+ /* create zoomed temporary surface from source surface */
+ sdl_surface_tmp = zoomSurface(src_bitmap->surface, dst_width, dst_height);
+
+ /* create native format destination surface from zoomed temporary surface */
+ dst_bitmap->surface = SDL_DisplayFormat(sdl_surface_tmp);
+
+ /* free temporary surface */
+ SDL_FreeSurface(sdl_surface_tmp);
}
bitmap->surface_masked = NULL;
#else
/* The X11 version seems to have a memory leak here -- although
- "XFreePixmap()" is called, the correspondig memory seems not
+ "XFreePixmap()" is called, the corresponding memory seems not
to be freed (according to "ps"). The SDL version apparently
does not have this problem. */
return dst_bitmap;
}
+void CreateBitmapWithSmallBitmaps(Bitmap *src_bitmap)
+{
+ Bitmap *tmp_bitmap, *tmp_bitmap_2, *tmp_bitmap_4, *tmp_bitmap_8;
+ int src_width, src_height;
+ int tmp_width, tmp_height;
+
+ src_width = src_bitmap->width;
+ src_height = src_bitmap->height;
+
+ tmp_width = src_width;
+ tmp_height = src_height + src_height / 2;
+
+ tmp_bitmap = CreateBitmap(tmp_width, tmp_height, DEFAULT_DEPTH);
+
+ tmp_bitmap_2 = ZoomBitmap(src_bitmap, src_width / 2, src_height / 2);
+ tmp_bitmap_4 = ZoomBitmap(src_bitmap, src_width / 4, src_height / 4);
+ tmp_bitmap_8 = ZoomBitmap(src_bitmap, src_width / 8, src_height / 8);
+
+ BlitBitmap(src_bitmap, tmp_bitmap, 0, 0, src_width, src_height, 0, 0);
+ BlitBitmap(tmp_bitmap_2, tmp_bitmap, 0, 0, src_width / 2, src_height / 2,
+ 0, src_height);
+ BlitBitmap(tmp_bitmap_4, tmp_bitmap, 0, 0, src_width / 4, src_height / 4,
+ src_width / 2, src_height);
+ BlitBitmap(tmp_bitmap_8, tmp_bitmap, 0, 0, src_width / 8, src_height / 8,
+ 3 * src_width / 4, src_height);
+
+ FreeBitmap(tmp_bitmap_2);
+ FreeBitmap(tmp_bitmap_4);
+ FreeBitmap(tmp_bitmap_8);
+
+#ifdef TARGET_SDL
+ src_bitmap->surface = tmp_bitmap->surface;
+ tmp_bitmap->surface = NULL;
+#else
+ src_bitmap->drawable = tmp_bitmap->drawable;
+ tmp_bitmap->drawable = None;
+#endif
+
+ src_bitmap->height = tmp_bitmap->height;
+
+ FreeBitmap(tmp_bitmap);
+}
+
/* ========================================================================= */
/* audio functions */
void ReloadCustomImage(Bitmap *, char *);
Bitmap *ZoomBitmap(Bitmap *, int, int);
+void CreateBitmapWithSmallBitmaps(Bitmap *);
inline void OpenAudio(void);
inline void CloseAudio(void);