rnd-20041124-1-src
authorHolger Schemel <info@artsoft.org>
Wed, 24 Nov 2004 00:57:28 +0000 (01:57 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:48:20 +0000 (10:48 +0200)
src/cartoons.c
src/conftime.h
src/files.c
src/game_em/game_em.h
src/game_em/tab_generate.c
src/init.c
src/libgame/image.c
src/libgame/image.h
src/tools.c
src/tools.h

index fd53e502a2e955124eaf9c656cb0b721cf83a11a..55c36b5b56f0f08b493d3243786cbcadb657fe80 100644 (file)
@@ -74,7 +74,7 @@ void InitToons()
   for (i=0; i < num_toons; i++)
   {
     int graphic = IMG_TOON_1 + i;
   for (i=0; i < num_toons; i++)
   {
     int graphic = IMG_TOON_1 + i;
-    struct FileInfo *image = getImageListEntry(graphic);
+    struct FileInfo *image = getImageListEntryFromImageID(graphic);
 
     toons[i].bitmap = graphic_info[graphic].bitmap;
 
 
     toons[i].bitmap = graphic_info[graphic].bitmap;
 
index cfb6f7ffc54c1ea65b7556402646502af1cee63e..6b86fe8b71f51661b540def90b9e53d096d0b415 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2004-11-22 02:34]"
+#define COMPILE_DATE_STRING "[2004-11-24 01:32]"
index f1c17f8e63af7eee082ea04cdbb067d6cc5af975..abcf15d20761100b5e14479b9a3acc7985349a7f 100644 (file)
@@ -2104,7 +2104,7 @@ void CopyNativeLevel_EM_to_RND(struct LevelInfo *level)
   level->field[ply2->x_initial - 1][ply2->y_initial - 1] = EL_PLAYER_2;
   level->field[ply1->x_initial - 1][ply1->y_initial - 1] = EL_PLAYER_1;
 
   level->field[ply2->x_initial - 1][ply2->y_initial - 1] = EL_PLAYER_2;
   level->field[ply1->x_initial - 1][ply1->y_initial - 1] = EL_PLAYER_1;
 
-#if 1
+#if 0
   printf("::: native Emerald Mine file version: %d\n", level_em->file_version);
 #endif
 }
   printf("::: native Emerald Mine file version: %d\n", level_em->file_version);
 #endif
 }
index 725d808c6ded0891a710af261ca191322afc2434..f28005234177a03d32523d132b7be34bd3e48481 100644 (file)
@@ -28,7 +28,7 @@ extern void UpdateEngineValues(int, int);
 extern void DrawGameDoorValues_EM(int, int, int, int);
 extern int getGameFrameDelay_EM(int);
 extern void PlayLevelSound_EM(int, int, int, int);
 extern void DrawGameDoorValues_EM(int, int, int, int);
 extern int getGameFrameDelay_EM(int);
 extern void PlayLevelSound_EM(int, int, int, int);
-extern void InitGraphicsInfoEM(void);
+extern void InitGraphicInfo_EM(void);
 
 
 /* ========================================================================= */
 
 
 /* ========================================================================= */
index a72fed83c54f4d3e70a27f1fc1ce33942480a079..a35bbd5cfea29318c6fb76e6261776555a732869 100644 (file)
@@ -4493,7 +4493,7 @@ void create_obj_graphics_info_em()
     }
   }
 
     }
   }
 
-  InitGraphicsInfoEM();
+  InitGraphicInfo_EM();
 }
 
 void create_spr()
 }
 
 void create_spr()
index 67d5810244ff0cead679165d83a8803bc69a1dc9..b02d08838168225d8a80c012f2a72a0eb2f1d59b 100644 (file)
@@ -258,12 +258,19 @@ void InitElementSmallImages()
   for (i = 0; element_to_special_graphic[i].element > -1; i++)
     InitElementSmallImagesScaledUp(element_to_special_graphic[i].graphic);
 
   for (i = 0; element_to_special_graphic[i].element > -1; i++)
     InitElementSmallImagesScaledUp(element_to_special_graphic[i].graphic);
 
-  /* initialize images from dynamic configuration */
+  /* initialize images from dynamic configuration (may be elements or other) */
+#if 1
+  for (i = 0; i < num_property_mappings; i++)
+    InitElementSmallImagesScaledUp(property_mapping[i].artwork_index);
+#else
+  /* !!! THIS DOES NOT WORK -- "artwork_index" is graphic, not element !!! */
+  /* !!! ALSO, non-element graphics might need scaling-up !!! */
   for (i = 0; i < num_property_mappings; i++)
     if (property_mapping[i].artwork_index < MAX_NUM_ELEMENTS)
       InitElementSmallImagesScaledUp(property_mapping[i].artwork_index);
   for (i = 0; i < num_property_mappings; i++)
     if (property_mapping[i].artwork_index < MAX_NUM_ELEMENTS)
       InitElementSmallImagesScaledUp(property_mapping[i].artwork_index);
+#endif
 
 
-#if 1
+#if 0
   /* !!! FIX THIS (CHANGE TO USING NORMAL ELEMENT GRAPHIC DEFINITIONS) !!! */
   for (i = IMG_EMC_OBJECT; i <= IMG_EMC_SPRITE; i++)
     InitElementSmallImagesScaledUp(i);
   /* !!! FIX THIS (CHANGE TO USING NORMAL ELEMENT GRAPHIC DEFINITIONS) !!! */
   for (i = IMG_EMC_OBJECT; i <= IMG_EMC_SPRITE; i++)
     InitElementSmallImagesScaledUp(i);
@@ -468,8 +475,10 @@ void InitElementGraphicInfo()
     if ((action > -1 || direction > -1 || crumbled == TRUE) &&
        base_graphic != -1)
     {
     if ((action > -1 || direction > -1 || crumbled == TRUE) &&
        base_graphic != -1)
     {
-      boolean base_redefined = getImageListEntry(base_graphic)->redefined;
-      boolean act_dir_redefined = getImageListEntry(graphic)->redefined;
+      boolean base_redefined =
+       getImageListEntryFromImageID(base_graphic)->redefined;
+      boolean act_dir_redefined =
+       getImageListEntryFromImageID(graphic)->redefined;
 
       /* if the base graphic ("emerald", for example) has been redefined,
         but not the action graphic ("emerald.falling", for example), do not
 
       /* if the base graphic ("emerald", for example) has been redefined,
         but not the action graphic ("emerald.falling", for example), do not
@@ -851,8 +860,10 @@ void InitElementSpecialGraphicInfo()
     int special = element_to_special_graphic[i].special;
     int graphic = element_to_special_graphic[i].graphic;
     int base_graphic = el2baseimg(element);
     int special = element_to_special_graphic[i].special;
     int graphic = element_to_special_graphic[i].graphic;
     int base_graphic = el2baseimg(element);
-    boolean base_redefined = getImageListEntry(base_graphic)->redefined;
-    boolean special_redefined = getImageListEntry(graphic)->redefined;
+    boolean base_redefined =
+      getImageListEntryFromImageID(base_graphic)->redefined;
+    boolean special_redefined =
+      getImageListEntryFromImageID(graphic)->redefined;
 
     /* if the base graphic ("emerald", for example) has been redefined,
        but not the special graphic ("emerald.EDITOR", for example), do not
 
     /* if the base graphic ("emerald", for example) has been redefined,
        but not the special graphic ("emerald.EDITOR", for example), do not
@@ -899,9 +910,27 @@ static int get_element_from_token(char *token)
   return -1;
 }
 
   return -1;
 }
 
-static void set_graphic_parameters(int graphic, char **parameter_raw)
+static int get_scaled_graphic_width(int graphic)
 {
 {
-  Bitmap *src_bitmap = getBitmapFromImageID(graphic);
+  int original_width = getOriginalImageWidthFromImageID(graphic);
+  int scale_up_factor = graphic_info[graphic].scale_up_factor;
+
+  return original_width * scale_up_factor;
+}
+
+static int get_scaled_graphic_height(int graphic)
+{
+  int original_height = getOriginalImageHeightFromImageID(graphic);
+  int scale_up_factor = graphic_info[graphic].scale_up_factor;
+
+  return original_height * scale_up_factor;
+}
+
+static void set_graphic_parameters(int graphic, int graphic_copy_from)
+{
+  struct FileInfo *image = getImageListEntryFromImageID(graphic_copy_from);
+  char **parameter_raw = image->parameter;
+  Bitmap *src_bitmap = getBitmapFromImageID(graphic_copy_from);
   int parameter[NUM_GFX_ARGS];
   int anim_frames_per_row = 1, anim_frames_per_col = 1;
   int anim_frames_per_line = 1;
   int parameter[NUM_GFX_ARGS];
   int anim_frames_per_row = 1, anim_frames_per_col = 1;
   int anim_frames_per_line = 1;
@@ -964,10 +993,9 @@ static void set_graphic_parameters(int graphic, char **parameter_raw)
 
   if (src_bitmap)
   {
 
   if (src_bitmap)
   {
-    /* bitmap is not scaled at this stage, so calculate final size */
-    int scale_up_factor = graphic_info[graphic].scale_up_factor;
-    int src_bitmap_width  = src_bitmap->width  * scale_up_factor;
-    int src_bitmap_height = src_bitmap->height * scale_up_factor;
+    /* get final bitmap size (with scaling, but without small images) */
+    int src_bitmap_width  = get_scaled_graphic_width(graphic);
+    int src_bitmap_height = get_scaled_graphic_height(graphic);
 
     anim_frames_per_row = src_bitmap_width  / graphic_info[graphic].width;
     anim_frames_per_col = src_bitmap_height / graphic_info[graphic].height;
 
     anim_frames_per_row = src_bitmap_width  / graphic_info[graphic].width;
     anim_frames_per_col = src_bitmap_height / graphic_info[graphic].height;
@@ -1094,8 +1122,6 @@ static void set_graphic_parameters(int graphic, char **parameter_raw)
 static void InitGraphicInfo()
 {
   int fallback_graphic = IMG_CHAR_EXCLAM;
 static void InitGraphicInfo()
 {
   int fallback_graphic = IMG_CHAR_EXCLAM;
-  struct FileInfo *fallback_image = getImageListEntry(fallback_graphic);
-  Bitmap *fallback_bitmap = getBitmapFromImageID(fallback_graphic);
   int num_images = getImageListSize();
   int i;
 
   int num_images = getImageListSize();
   int i;
 
@@ -1133,11 +1159,10 @@ static void InitGraphicInfo()
 
   for (i = 0; i < num_images; i++)
   {
 
   for (i = 0; i < num_images; i++)
   {
-    struct FileInfo *image = getImageListEntry(i);
     Bitmap *src_bitmap;
     int src_x, src_y;
     int first_frame, last_frame;
     Bitmap *src_bitmap;
     int src_x, src_y;
     int first_frame, last_frame;
-    int scale_up_factor, src_bitmap_width, src_bitmap_height;
+    int src_bitmap_width, src_bitmap_height;
 
 #if 0
     printf("::: image: '%s' [%d]\n", image->token, i);
 
 #if 0
     printf("::: image: '%s' [%d]\n", image->token, i);
@@ -1149,17 +1174,16 @@ static void InitGraphicInfo()
           getTokenFromImageID(i));
 #endif
 
           getTokenFromImageID(i));
 #endif
 
-    set_graphic_parameters(i, image->parameter);
+    set_graphic_parameters(i, i);
 
     /* now check if no animation frames are outside of the loaded image */
 
     if (graphic_info[i].bitmap == NULL)
       continue;                /* skip check for optional images that are undefined */
 
 
     /* now check if no animation frames are outside of the loaded image */
 
     if (graphic_info[i].bitmap == NULL)
       continue;                /* skip check for optional images that are undefined */
 
-    /* bitmap is not scaled at this stage, so calculate final size */
-    scale_up_factor = graphic_info[i].scale_up_factor;
-    src_bitmap_width  = graphic_info[i].bitmap->width  * scale_up_factor;
-    src_bitmap_height = graphic_info[i].bitmap->height * scale_up_factor;
+    /* get final bitmap size (with scaling, but without small images) */
+    src_bitmap_width  = get_scaled_graphic_width(i);
+    src_bitmap_height = get_scaled_graphic_height(i);
 
     first_frame = 0;
     getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
 
     first_frame = 0;
     getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
@@ -1190,8 +1214,7 @@ static void InitGraphicInfo()
       Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic");
       Error(ERR_RETURN_LINE, "-");
 
       Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic");
       Error(ERR_RETURN_LINE, "-");
 
-      set_graphic_parameters(i, fallback_image->default_parameter);
-      graphic_info[i].bitmap = fallback_bitmap;
+      set_graphic_parameters(i, fallback_graphic);
     }
 
     last_frame = graphic_info[i].anim_frames - 1;
     }
 
     last_frame = graphic_info[i].anim_frames - 1;
@@ -1219,8 +1242,7 @@ static void InitGraphicInfo()
       Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic");
       Error(ERR_RETURN_LINE, "-");
 
       Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic");
       Error(ERR_RETURN_LINE, "-");
 
-      set_graphic_parameters(i, fallback_image->default_parameter);
-      graphic_info[i].bitmap = fallback_bitmap;
+      set_graphic_parameters(i, fallback_graphic);
     }
 
 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
     }
 
 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
@@ -1698,6 +1720,8 @@ static void ReinitializeGraphics()
   InitElementSmallImages();            /* scale images to all needed sizes */
   InitFontGraphicInfo();               /* initialize text drawing functions */
 
   InitElementSmallImages();            /* scale images to all needed sizes */
   InitFontGraphicInfo();               /* initialize text drawing functions */
 
+  InitGraphicInfo_EM();                        /* graphic mapping for EM engine */
+
   SetMainBackgroundImage(IMG_BACKGROUND);
   SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
 
   SetMainBackgroundImage(IMG_BACKGROUND);
   SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
 
index 72e9580cc0ce1f09136302a1e157c126f99ac2b2..1475fe1e45ce4592daa77197704e9d005f5ac1c5 100644 (file)
@@ -820,7 +820,12 @@ struct ImageInfo
   int num_references;
 
   Bitmap *bitmap;
   int num_references;
 
   Bitmap *bitmap;
-  boolean contains_small_images;
+
+  int original_width;                  /* original image file width */
+  int original_height;                 /* original image file height */
+
+  boolean contains_small_images;       /* set after adding small images */
+  boolean scaled_up;                   /* set after scaling up */
 };
 typedef struct ImageInfo ImageInfo;
 
 };
 typedef struct ImageInfo ImageInfo;
 
@@ -846,7 +851,11 @@ static void *Load_PCX(char *filename)
 
   img_info->source_filename = getStringCopy(filename);
 
 
   img_info->source_filename = getStringCopy(filename);
 
+  img_info->original_width  = img_info->bitmap->width;
+  img_info->original_height = img_info->bitmap->height;
+
   img_info->contains_small_images = FALSE;
   img_info->contains_small_images = FALSE;
+  img_info->scaled_up = FALSE;
 
   return img_info;
 }
 
   return img_info;
 }
@@ -873,7 +882,7 @@ int getImageListSize()
          image_info->num_dynamic_file_list_entries);
 }
 
          image_info->num_dynamic_file_list_entries);
 }
 
-struct FileInfo *getImageListEntry(int pos)
+struct FileInfo *getImageListEntryFromImageID(int pos)
 {
   int num_list_entries = image_info->num_file_list_entries;
   int list_pos = (pos < num_list_entries ? pos : pos - num_list_entries);
 {
   int num_list_entries = image_info->num_file_list_entries;
   int list_pos = (pos < num_list_entries ? pos : pos - num_list_entries);
@@ -895,33 +904,30 @@ static ImageInfo *getImageInfoEntryFromImageID(int pos)
 
 Bitmap *getBitmapFromImageID(int 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 =
-    (ImageInfo **)(pos < num_list_entries ? image_info->artwork_list :
-                  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);
   ImageInfo *img_info = getImageInfoEntryFromImageID(pos);
 
   return (img_info != NULL ? img_info->bitmap : NULL);
-#endif
 }
 
 }
 
-char *getTokenFromImageID(int graphic)
+int getOriginalImageWidthFromImageID(int pos)
 {
 {
-#if 0
-  /* !!! this does not work for dynamic artwork (crash!) !!! */
-  struct FileInfo *file_list = (struct FileInfo *)image_info->file_list;
+  ImageInfo *img_info = getImageInfoEntryFromImageID(pos);
+
+  return (img_info != NULL ? img_info->original_width : 0);
+}
+
+int getOriginalImageHeightFromImageID(int pos)
+{
+  ImageInfo *img_info = getImageInfoEntryFromImageID(pos);
+
+  return (img_info != NULL ? img_info->original_height : 0);
+}
 
 
-  return file_list[graphic].token;
-#else
-  struct FileInfo *file_list = getImageListEntry(graphic);
+char *getTokenFromImageID(int graphic)
+{
+  struct FileInfo *file_list = getImageListEntryFromImageID(graphic);
 
   return (file_list != NULL ? file_list->token : NULL);
 
   return (file_list != NULL ? file_list->token : NULL);
-#endif
 }
 
 int getImageIDFromToken(char *token)
 }
 
 int getImageIDFromToken(char *token)
@@ -1047,6 +1053,7 @@ void CreateImageWithSmallImages(int pos, int zoom_factor)
   CreateBitmapWithSmallBitmaps(img_info->bitmap, zoom_factor);
 
   img_info->contains_small_images = TRUE;
   CreateBitmapWithSmallBitmaps(img_info->bitmap, zoom_factor);
 
   img_info->contains_small_images = TRUE;
+  img_info->scaled_up = TRUE;
 
 #if 0
   if (zoom_factor)
 
 #if 0
   if (zoom_factor)
index 1b98bbf65d003a8780034c4d575cf704a354136c..3a2ac2023158aed2ddfb9f60c51d3bc9a87ce232 100644 (file)
@@ -77,8 +77,10 @@ int Read_PCX_to_Pixmap(Display *, Window, GC, char *, Pixmap *, Pixmap *);
 #endif /* TARGET_X11 */
 
 int getImageListSize();
 #endif /* TARGET_X11 */
 
 int getImageListSize();
-struct FileInfo *getImageListEntry(int);
+struct FileInfo *getImageListEntryFromImageID(int);
 Bitmap *getBitmapFromImageID(int);
 Bitmap *getBitmapFromImageID(int);
+int getOriginalImageWidthFromImageID(int);
+int getOriginalImageHeightFromImageID(int);
 char *getTokenFromImageID(int);
 int getImageIDFromToken(char *);
 char *getImageConfigFilename();
 char *getTokenFromImageID(int);
 int getImageIDFromToken(char *);
 char *getImageConfigFilename();
index 57294eebd9451ae18f8d15615ca0359617b6dd7e..ba053b0da21884c8f637258f9f037ec649fc32ef 100644 (file)
@@ -5305,7 +5305,7 @@ unsigned int InitRND(long seed)
     return InitEngineRND(seed);
 }
 
     return InitEngineRND(seed);
 }
 
-void InitGraphicsInfoEM(void)
+void InitGraphicInfo_EM(void)
 {
   int mapping_EM_to_RND_element[TILE_MAX];
   int mapping_EM_to_RND_action[TILE_MAX];
 {
   int mapping_EM_to_RND_element[TILE_MAX];
   int mapping_EM_to_RND_action[TILE_MAX];
@@ -5515,11 +5515,6 @@ void InitGraphicsInfoEM(void)
        int cx = ABS(dx) * TILEX / 8;
        int cy = ABS(dy) * TILEY / 8;
 
        int cx = ABS(dx) * TILEX / 8;
        int cy = ABS(dy) * TILEY / 8;
 
-#if 0
-       if (i == Yemerald_sB)
-         printf("::: %d: ...\n", j);
-#endif
-
        if (backside)           /* tile where movement starts */
        {
          if (dx < 0 || dy < 0)
        if (backside)           /* tile where movement starts */
        {
          if (dx < 0 || dy < 0)
index f79e84f0923ce24882e1bdeddc97bf547e717a38..18c196f11fd8b060984f0c381e728fee10bad7a9 100644 (file)
@@ -151,5 +151,6 @@ int el2edimg(int);
 int el2preimg(int);
 
 unsigned int InitRND(long);
 int el2preimg(int);
 
 unsigned int InitRND(long);
+void InitGraphicInfo_EM(void);
 
 #endif /* TOOLS_H */
 
 #endif /* TOOLS_H */