+2004-08-16
+ * fixed big memory leak in function "CreateBitmapWithSmallBitmaps()"
+ (which creates scaled down graphics for level editor and preview);
+ there's still a memory leak somewhere in the artwork handling code
+ * added "scale image up" functionality to X11 version of zoom function
+
2004-08-07
* fixed bug in gadget code which caused reset of CEs in level editor
(example: pressing 'b' [grab brush] on CE config page erased values)
-#define COMPILE_DATE_STRING "[2004-08-16 00:11]"
+#define COMPILE_DATE_STRING "[2004-08-16 03:09]"
+
+#if defined(TARGET_X11)
+
/* 2000-08-10T16:43:50Z
*
* cave data structures
}
cave_list = 0;
}
+
+#endif
+
+#if defined(TARGET_X11)
+
/* 2000-08-20T09:41:18Z
*
* identify all emerald mine caves and turn them into v6 format.
for(y = 0; y < HEIGHT; y++) for(x = 0; x < WIDTH; x++) Next[y][x] = Cave[y][x];
for(y = 0; y < HEIGHT; y++) for(x = 0; x < WIDTH; x++) Draw[y][x] = Cave[y][x];
}
+
+#endif
+
+#if defined(TARGET_X11)
+
/* 2000-08-13T14:36:17Z
*
* graphics manipulation crap
}
XSetClipMask(display, screenGC, None);
}
+
+#endif
+
+#if defined(TARGET_X11)
+
/* 2000-08-10T18:03:54Z
*
* open X11 display and sound
#if 1
static Bitmap *pcxBitmaps[4];
+static Bitmap *pcxBitmapsX2[4];
#endif
#if 0
ttlmaskBitmap = pcxBitmaps[3]->clip_mask;
#endif
+#if 0
+ for (i = 0; i < 4; i++)
+ pcxBitmapsX2[i] = ZoomBitmap(pcxBitmaps[i],
+ pcxBitmaps[i]->width * 2,
+ pcxBitmaps[i]->height * 2);
+
+ objBitmap = pcxBitmapsX2[0];
+ botBitmap = pcxBitmapsX2[1];
+ sprBitmap = pcxBitmapsX2[2];
+ ttlBitmap = pcxBitmapsX2[3];
+
+ objPixmap = pcxBitmapsX2[0]->drawable;
+ botPixmap = pcxBitmapsX2[1]->drawable;
+ sprPixmap = pcxBitmapsX2[2]->drawable;
+ ttlPixmap = pcxBitmapsX2[3]->drawable;
+ objmaskBitmap = pcxBitmapsX2[0]->clip_mask;
+ botmaskBitmap = pcxBitmapsX2[1]->clip_mask;
+ sprmaskBitmap = pcxBitmapsX2[2]->clip_mask;
+ ttlmaskBitmap = pcxBitmapsX2[3]->clip_mask;
+#endif
+
#if 1
screenBitmap = CreateBitmap(22 * TILEX, 14 * TILEY, DEFAULT_DEPTH);
scoreBitmap = CreateBitmap(20 * TILEX, SCOREY, DEFAULT_DEPTH);
if(colourmap != privateColourmap) XFreeColors(display, colourmap, pixels, npixels, 0);
return(1); /* non-zero for success */
}
+
+#endif
+
+#if defined(TARGET_X11)
+
/* 2000-08-13T15:29:40Z
*
* handle input from x11 and keyboard and joystick
input_esc = 0;
for(i = 0; i < 1; i++) if(keymatrix[escKeyCode[i] >> 3] & 1 << (escKeyCode[i] & 7)) input_esc = 1;
}
+
+#endif
+
+#if defined(TARGET_X11)
+
/* Emerald Mine
*
* David Tritscher
fprintf(stderr, "%s %s\n", "Fault occured while attempting to", description);
abort();
}
+
+#else
+
+int em_main()
+{
+ /* temporary dummy until X11->SDL conversion finished */
+ return 0;
+}
+
+#endif
+
+#if defined(TARGET_X11)
+
/* 2000-08-10T17:39:15Z
*
* handle sounds in emerald mine
}
#endif /* defined(PLATFORM_LINUX) || defined(PLATFORM_BSD) */
+
+#endif
+#if defined(TARGET_X11)
+
/* first part of synchro.
*
* game logic for players.
}
}
}
+
+#endif
+#if defined(TARGET_X11)
+
/* second part of synchro.
*
* game logic for monsters.
void *temp = Cave; Cave = Next; Next = Draw; Draw = temp; /* triple buffering */
}
}
+
+#endif
+#if defined(TARGET_X11)
+
/* third part of synchro.
*
* handle global elements.
Next[y][x] = Cave[y][x];
}
}
+
+#endif
+
+#if defined(TARGET_X11)
+
/* 2000-04-19T13:26:05Z
*
* construct some tables to be included directly in emerald mine source.
create_spr();
create_ttl();
}
+
+#endif
+
+#if defined(TARGET_X11)
+
/* 2000-08-10T04:29:10Z
*
* generate ulaw<->linear conversion tables to be included
}
#endif /* defined(PLATFORM_LINUX) || defined(PLATFORM_BSD) */
+
+#endif
-----------------------------------------------------------------------------
ZoomPixmap
- Important note: The scaling code currently only supports scaling down the
- image by a power of 2 -- scaling up is currently not supported at all!
+ Important note: The scaling code currently only supports scaling of the image
+ up or down by a power of 2 -- other scaling factors currently not supported!
-----------------------------------------------------------------------------
*/
byte *src_ptr, *dst_ptr;
int bits_per_pixel;
int bytes_per_pixel;
- int x, y, i;
+ int x, y, xx, yy, i;
+#if 1
+ boolean scale_down = (src_width > dst_width);
+ int zoom_factor;
+#else
int zoom_factor = src_width / dst_width; /* currently very limited! */
+#endif
int row_skip, col_skip;
- /* adjust source image size to integer multiple of destination image size */
- src_width = dst_width * zoom_factor;
- src_height = dst_height * zoom_factor;
+ if (scale_down)
+ {
+ zoom_factor = src_width / dst_width;
+
+ /* adjust source image size to integer multiple of destination size */
+ src_width = dst_width * zoom_factor;
+ src_height = dst_height * zoom_factor;
+ }
+ else
+ {
+ zoom_factor = dst_width / src_width;
+
+ /* no adjustment needed when scaling up (some pixels may be left blank) */
+ }
/* copy source pixmap to temporary image */
src_ximage = XGetImage(display, src_pixmap, 0, 0, src_width, src_height,
src_ptr = (byte *)src_ximage->data;
dst_ptr = (byte *)dst_ximage->data;
- col_skip = (zoom_factor - 1) * bytes_per_pixel;
- row_skip = col_skip * src_width;
+ if (scale_down)
+ {
+ col_skip = (zoom_factor - 1) * bytes_per_pixel;
+ row_skip = col_skip * src_width;
+
+ /* scale image down by scaling factor 'zoom_factor' */
+ for (y = 0; y < src_height; y += zoom_factor, src_ptr += row_skip)
+ for (x = 0; x < src_width; x += zoom_factor, src_ptr += col_skip)
+ for (i = 0; i < bytes_per_pixel; i++)
+ *dst_ptr++ = *src_ptr++;
+ }
+ else
+ {
+ row_skip = src_width * bytes_per_pixel;
+
+ /* scale image up by scaling factor 'zoom_factor' */
+ for (y = 0; y < src_height; y++)
+ {
+ for (yy = 0; yy < zoom_factor; yy++)
+ {
+ if (yy > 0)
+ src_ptr -= row_skip;
+
+ for (x = 0; x < src_width; x++)
+ {
+ for (xx = 0; xx < zoom_factor; xx++)
+ for (i = 0; i < bytes_per_pixel; i++)
+ *dst_ptr++ = *(src_ptr + i);
- /* scale image down by scaling factor 'zoom_factor' */
- for (y = 0; y < src_height; y += zoom_factor, src_ptr += row_skip)
- for (x = 0; x < src_width; x += zoom_factor, src_ptr += col_skip)
- for (i = 0; i < bytes_per_pixel; i++)
- *dst_ptr++ = *src_ptr++;
+ src_ptr += i;
+ }
+ }
+ }
+ }
/* copy scaled image to destination pixmap */
XPutImage(display, dst_pixmap, gc, dst_ximage, 0, 0, 0, 0,
-----------------------------------------------------------------------------
zoomSurface()
- Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
+ Zooms a 32bit or 8bit 'src' surface to newly created 'dst' surface.
'zoomx' and 'zoomy' are scaling factors for width and height.
- If 'smooth' is 1 then the destination 32bit surface is anti-aliased.
If the surface is not 8bit or 32bit RGBA/ABGR it will be converted
into a 32bit RGBA format on the fly.
-----------------------------------------------------------------------------
void CreateBitmapWithSmallBitmaps(Bitmap *src_bitmap)
{
+ Bitmap swap_bitmap;
Bitmap *tmp_bitmap, *tmp_bitmap_2, *tmp_bitmap_8;
int src_width, src_height;
int tmp_width, tmp_height;
FreeBitmap(tmp_bitmap_2);
FreeBitmap(tmp_bitmap_8);
+#if 0
+
#if defined(TARGET_SDL)
/* !!! what about the old src_bitmap->surface ??? FIX ME !!! */
src_bitmap->surface = tmp_bitmap->surface;
/* !!! see above !!! */
src_bitmap->drawable = tmp_bitmap->drawable;
tmp_bitmap->drawable = None;
+#endif
+
+#else
+
+#if defined(TARGET_SDL)
+ swap_bitmap.surface = src_bitmap->surface;
+ src_bitmap->surface = tmp_bitmap->surface;
+ tmp_bitmap->surface = swap_bitmap.surface;
+#else
+ swap_bitmap.drawable = src_bitmap->drawable;
+ src_bitmap->drawable = tmp_bitmap->drawable;
+ tmp_bitmap->drawable = swap_bitmap.drawable;
+#endif
+
#endif
src_bitmap->height = tmp_bitmap->height;