};
struct AnimInfo *anim = &toon[toon_nr];
int anim_bitmap_nr = (toon_nr < 6 ? PIX_TOONS : PIX_HEROES);
- Bitmap anim_bitmap = pix_masked[anim_bitmap_nr];
- GC anim_clip_gc = clip_gc[anim_bitmap_nr];
+ Bitmap anim_bitmap = pix[anim_bitmap_nr];
+ GC anim_clip_gc = pix[anim_bitmap_nr]->stored_clip_gc;
if (restart)
{
/* special method to avoid flickering interference with BackToFront() */
BlitBitmap(backbuffer, pix[PIX_DB_DOOR], dest_x-pad_x, dest_y-pad_y,
width+2*pad_x, height+2*pad_y, buf_x, buf_y);
- SetClipOrigin(toon_clip_gc, dest_x-src_x, dest_y-src_y);
+ SetClipOrigin(toon_bitmap, toon_clip_gc, dest_x-src_x, dest_y-src_y);
BlitBitmapMasked(toon_bitmap, backbuffer,
src_x, src_y, width, height, dest_x, dest_y);
BlitBitmap(backbuffer, window, dest_x-pad_x, dest_y-pad_y,
/* normal method, causing flickering interference with BackToFront() */
BlitBitmap(backbuffer, pix[PIX_DB_DOOR], dest_x-pad_x, dest_y-pad_y,
width+2*pad_x, height+2*pad_y, buf_x, buf_y);
- SetClipOrigin(toon_clip_gc, buf_x-src_x+pad_x, buf_y-src_y+pad_y);
+ SetClipOrigin(toon_bitmap,toon_clip_gc, buf_x-src_x+pad_x,buf_y-src_y+pad_y);
BlitBitmapMasked(toon_bitmap, pix[PIX_DB_DOOR],
src_x, src_y, width, height, buf_x+pad_x, buf_y+pad_y);
BlitBitmap(pix[PIX_DB_DOOR], window, buf_x, buf_y,
DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
/* draw mouse button brush elements */
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
el2gfx(new_element1));
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
el2gfx(new_element2));
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
el2gfx(new_element3));
if (button == 1)
{
new_element1 = element;
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
el2gfx(new_element1));
}
else if (button == 2)
{
new_element2 = element;
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
el2gfx(new_element2));
}
else
{
new_element3 = element;
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
el2gfx(new_element3));
}
}
else
{
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
gi->x + sx * MINI_TILEX,
gi->y + sy * MINI_TILEY,
el2gfx(new_element));
- DrawMiniGraphicExt(window, gc,
+ DrawMiniGraphicExt(window,
gi->x + sx * MINI_TILEX,
gi->y + sy * MINI_TILEY,
el2gfx(new_element));
int2str(level_nr, 2), FS_SMALL, FC_YELLOW);
else
{
- DrawTextExt(drawto, gc, DX + XX_EMERALDS, DY + YY_EMERALDS,
+ DrawTextExt(drawto, DX + XX_EMERALDS, DY + YY_EMERALDS,
int2str(level_nr, 3), FS_SMALL, FC_SPECIAL3);
BlitBitmap(drawto, drawto,
DX + XX_EMERALDS, DY + YY_EMERALDS + 1,
RemoveField(x, y);
player->key[key_nr] = TRUE;
RaiseScoreElement(EL_SCHLUESSEL);
- DrawMiniGraphicExt(drawto, gc,
- DX_KEYS+key_nr*MINI_TILEX, DY_KEYS,
- GFX_SCHLUESSEL1+key_nr);
- DrawMiniGraphicExt(window, gc,
- DX_KEYS+key_nr*MINI_TILEX, DY_KEYS,
- GFX_SCHLUESSEL1+key_nr);
+ DrawMiniGraphicExt(drawto, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS,
+ GFX_SCHLUESSEL1 + key_nr);
+ DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS,
+ GFX_SCHLUESSEL1 + key_nr);
PlaySoundLevel(x, y, SND_PONG);
break;
}
RemoveField(x, y);
player->key[key_nr] = TRUE;
RaiseScoreElement(EL_SCHLUESSEL);
- DrawMiniGraphicExt(drawto, gc,
- DX_KEYS+key_nr*MINI_TILEX, DY_KEYS,
- GFX_SCHLUESSEL1+key_nr);
- DrawMiniGraphicExt(window, gc,
- DX_KEYS+key_nr*MINI_TILEX, DY_KEYS,
- GFX_SCHLUESSEL1+key_nr);
+ DrawMiniGraphicExt(drawto, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS,
+ GFX_SCHLUESSEL1 + key_nr);
+ DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS,
+ GFX_SCHLUESSEL1 + key_nr);
PlaySoundLevel(x, y, SND_PONG);
break;
}
ICON_TITLE_STRING, x11_icon_filename, x11_iconmask_filename,
msdos_pointer_filename);
- InitScrollbufferSize(FXSIZE, FYSIZE); /* (only needed for MS-DOS code) */
-
InitVideoDisplay();
InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
setup.fullscreen);
{ -1, 0 }
};
+ /* initialize playfield properties */
+
+ InitPlayfieldInfo(SX, SY, SXSIZE, SYSIZE,
+ REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
+ InitDoor1Info(DX, DY, DXSIZE, DYSIZE);
+ InitDoor2Info(VX, VY, VXSIZE, VYSIZE);
+ InitScrollbufferInfo(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);
LoadGfx(PIX_SMALLFONT, &pic[PIX_SMALLFONT]);
+ InitFontInfo(NULL, NULL, pix[PIX_SMALLFONT]);
+
DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
#if defined(PLATFORM_MSDOS)
if (i != PIX_SMALLFONT)
LoadGfx(i,&pic[i]);
+ InitFontInfo(pix[PIX_BIGFONT], pix[PIX_MEDIUMFONT], pix[PIX_SMALLFONT]);
+
/* create additional image buffers for masking of graphics */
#if defined(TARGET_SDL)
clip_gc_values.graphics_exposures = False;
clip_gc_valuemask = GCGraphicsExposures;
copy_clipmask_gc =
- XCreateGC(display, clipmask[PIX_BACK], clip_gc_valuemask, &clip_gc_values);
+ XCreateGC(display, pix[PIX_BACK]->clip_mask,
+ clip_gc_valuemask, &clip_gc_values);
clip_gc_values.graphics_exposures = False;
clip_gc_valuemask = GCGraphicsExposures;
tile_clip_gc =
- XCreateGC(display, window, clip_gc_valuemask, &clip_gc_values);
+ XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
for(i=0; i<NUM_BITMAPS; i++)
{
- if (clipmask[i])
+ if (pix[i]->clip_mask)
{
clip_gc_values.graphics_exposures = False;
- clip_gc_values.clip_mask = clipmask[i];
+ clip_gc_values.clip_mask = pix[i]->clip_mask;
clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
- clip_gc[i] = XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values);
+ pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
+ clip_gc_valuemask,&clip_gc_values);
}
}
Pixmap src_pixmap;
getGraphicSource(graphic, &pixmap_nr, &src_x, &src_y);
- src_pixmap = clipmask[pixmap_nr];
+ src_pixmap = pix[pixmap_nr]->clip_mask;
- tile_clipmask[tile] = XCreatePixmap(display, window, TILEX,TILEY, 1);
+ tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
+ TILEX, TILEY, 1);
- XCopyArea(display,src_pixmap,tile_clipmask[tile],copy_clipmask_gc,
- src_x,src_y, TILEX,TILEY, 0,0);
+ XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
+ src_x, src_y, TILEX, TILEY, 0, 0);
}
}
rest(100);
#endif
+ pix[pos] = CreateBitmapStruct();
+
#if defined(TARGET_SDL)
/* load image to temporary surface */
if ((sdl_image_tmp = IMG_Load(filename)) == NULL)
#else /* !TARGET_SDL */
- pcx_err = Read_PCX_to_Pixmap(display, window, gc, filename,
- &pix[pos], &clipmask[pos]);
+ pcx_err = Read_PCX_to_Pixmap(display, window->drawable, window->gc,
+ filename,
+ &pix[pos]->drawable, &pix[pos]->clip_mask);
switch(pcx_err)
{
case PCX_Success:
break;
}
- if (!pix[pos])
+ if (!pix[pos]->drawable)
Error(ERR_EXIT, "cannot get graphics for '%s'", pic->picture_filename);
+#if 0
/* setting pix_masked[] to pix[] allows BlitBitmapMasked() to always
use pix_masked[], although they are the same when not using SDL */
pix_masked[pos] = pix[pos];
+#endif
#endif /* !TARGET_SDL */
}
#if defined(TARGET_X11)
/* check if clip mask was correctly created */
- if (pic->picture_with_mask && !clipmask[pos])
+ if (pic->picture_with_mask && !pix[pos]->clip_mask)
Error(ERR_EXIT, "cannot get clipmask for '%s'", pic->picture_filename);
#endif
}
#endif
for(i=0; i<NUM_BITMAPS; i++)
- {
- if (pix[i])
- FreeBitmap(pix[i]);
-
-#if defined(TARGET_SDL)
- FreeBitmap(pix_masked[i]);
-#else
- if (clipmask[i])
- FreeBitmap(clipmask[i]);
- if (clip_gc[i])
- XFreeGC(display, clip_gc[i]);
-#endif
- }
+ FreeBitmap(pix[i]);
#if defined(TARGET_SDL)
KeyboardAutoRepeatOn();
#else
+
+#if 0
if (gc)
XFreeGC(display, gc);
+#endif
if (display)
{
BITMAP *bitmap = NULL;
if (gfx_capabilities & GFX_HW_VRAM_BLIT &&
- width == video.scrollbuffer_width && height == video.scrollbuffer_height)
+ width == playfield.scrollbuffer_width &&
+ height == playfield.scrollbuffer_height)
bitmap = create_video_bitmap(width, height);
if (bitmap == NULL)
return success;
}
-inline void SDLCopyArea(SDL_Surface *src_surface, SDL_Surface *dst_surface,
+inline void SDLCopyArea(Bitmap src_bitmap, Bitmap dst_bitmap,
int src_x, int src_y,
int width, int height,
- int dst_x, int dst_y)
+ int dst_x, int dst_y, int copy_mode)
{
- SDL_Surface *surface = (dst_surface == window ? backbuffer : dst_surface);
+ Bitmap real_dst_bitmap = (dst_bitmap == window ? backbuffer : dst_bitmap);
SDL_Rect src_rect, dst_rect;
src_rect.x = src_x;
dst_rect.w = width;
dst_rect.h = height;
- if (src_surface != backbuffer || dst_surface != window)
- SDL_BlitSurface(src_surface, &src_rect, surface, &dst_rect);
+ if (src_bitmap != backbuffer || dst_bitmap != window)
+ SDL_BlitSurface((copy_mode == SDLCOPYAREA_MASKED ?
+ src_bitmap->surface_masked : src_bitmap->surface),
+ &src_rect, real_dst_bitmap->surface, &dst_rect);
- if (dst_surface == window)
- SDL_UpdateRect(backbuffer, dst_x, dst_y, width, height);
+ if (dst_bitmap == window)
+ SDL_UpdateRect(backbuffer->surface, dst_x, dst_y, width, height);
}
-inline void SDLFillRectangle(SDL_Surface *dst_surface, int x, int y,
+inline void SDLFillRectangle(Bitmap dst_bitmap, int x, int y,
int width, int height, unsigned int color)
{
- SDL_Surface *surface = (dst_surface == window ? backbuffer : dst_surface);
+ Bitmap real_dst_bitmap = (dst_bitmap == window ? backbuffer : dst_bitmap);
SDL_Rect rect;
unsigned int color_r = (color >> 16) && 0xff;
unsigned int color_g = (color >> 8) && 0xff;
rect.w = width;
rect.h = height;
- SDL_FillRect(surface, &rect,
- SDL_MapRGB(surface->format, color_r, color_g, color_b));
+ SDL_FillRect(real_dst_bitmap->surface, &rect,
+ SDL_MapRGB(real_dst_bitmap->surface->format,
+ color_r, color_g, color_b));
- if (dst_surface == window)
- SDL_UpdateRect(backbuffer, x, y, width, height);
+ if (dst_bitmap == window)
+ SDL_UpdateRect(backbuffer->surface, x, y, width, height);
}
inline void SDLDrawSimpleLine(SDL_Surface *surface, int from_x, int from_y,
#define SURFACE_FLAGS (SDL_SWSURFACE)
+#define SDLCOPYAREA_OPAQUE 0
+#define SDLCOPYAREA_MASKED 1
/* system dependent definitions */
#define FULLSCREEN_STATUS FULLSCREEN_AVAILABLE
+/* structure definitions */
+
+struct SDLSurfaceInfo
+{
+ SDL_Surface *surface;
+ SDL_Surface *surface_masked;
+};
+
+
/* SDL type definitions */
-typedef SDL_Surface *Bitmap;
-typedef SDL_Surface *DrawWindow;
-typedef SDL_Surface *DrawBuffer;
+typedef struct SDLSurfaceInfo *Bitmap;
+typedef struct SDLSurfaceInfo *DrawBuffer;
+typedef struct SDLSurfaceInfo *DrawWindow;
typedef SDLKey Key;
inline void SDLInitVideoDisplay(void);
inline void SDLInitVideoBuffer(DrawBuffer *, DrawWindow *, boolean);
inline boolean SDLSetVideoMode(DrawBuffer *, boolean);
-inline void SDLCopyArea(SDL_Surface *, SDL_Surface *,
- int, int, int, int, int, int);
-inline void SDLFillRectangle(SDL_Surface *, int, int, int, int, unsigned int);
+inline void SDLCopyArea(Bitmap, Bitmap, int, int, int, int, int, int, int);
+inline void SDLFillRectangle(Bitmap, int, int, int, int, unsigned int);
inline void SDLDrawSimpleLine(SDL_Surface *, int, int, int, int, unsigned int);
inline boolean SDLOpenAudio(void);
#include "libgame.h"
+
/* ========================================================================= */
-/* internal variables */
+/* exported variables */
/* ========================================================================= */
+struct ProgramInfo program;
+struct OptionInfo options;
+struct VideoSystemInfo video;
+struct AudioSystemInfo audio;
+struct PlayfieldInfo playfield;
+
Display *display = NULL;
Visual *visual = NULL;
int screen = 0;
Colormap cmap = None;
-DrawWindow window = None;
-DrawBuffer backbuffer = None;
-GC gc = None;
+DrawWindow window = NULL;
+DrawBuffer backbuffer = NULL;
+DrawBuffer drawto = NULL;
-int FrameCounter = 0;
+int redraw_mask;
+int redraw_tiles;
-
-/* ========================================================================= */
-/* exported variables */
-/* ========================================================================= */
-
-struct ProgramInfo program;
-struct VideoSystemInfo video;
-struct AudioSystemInfo audio;
-struct OptionInfo options;
+int FrameCounter = 0;
/* ========================================================================= */
/* video functions */
/* ========================================================================= */
-inline static int GetRealDepth(int depth)
-{
- return (depth == DEFAULT_DEPTH ? video.default_depth : depth);
-}
-
inline void InitProgramInfo(char *command_name, char *program_title,
char *window_title, char *icon_title,
char *x11_icon_filename,
program.msdos_pointer_filename = msdos_pointer_filename;
}
-inline void InitScrollbufferSize(int scrollbuffer_width,
+inline void InitPlayfieldInfo(int sx, int sy, int sxsize, int sysize,
+ int real_sx, int real_sy,
+ int full_sxsize, int full_sysize)
+{
+ playfield.sx = sx;
+ playfield.sy = sy;
+ playfield.sxsize = sxsize;
+ playfield.sysize = sysize;
+ playfield.real_sx = real_sx;
+ playfield.real_sy = real_sy;
+ playfield.full_sxsize = full_sxsize;
+ playfield.full_sysize = full_sysize;
+}
+
+inline void InitDoor1Info(int dx, int dy, int dxsize, int dysize)
+{
+ playfield.dx = dx;
+ playfield.dy = dy;
+ playfield.dxsize = dxsize;
+ playfield.dysize = dysize;
+}
+
+inline void InitDoor2Info(int vx, int vy, int vxsize, int vysize)
+{
+ playfield.vx = vx;
+ playfield.vy = vy;
+ playfield.vxsize = vxsize;
+ playfield.vysize = vysize;
+}
+
+inline void InitScrollbufferInfo(int scrollbuffer_width,
int scrollbuffer_height)
{
/* currently only used by MSDOS code to alloc VRAM buffer, if available */
- video.scrollbuffer_width = scrollbuffer_width;
- video.scrollbuffer_height = scrollbuffer_height;
+ playfield.scrollbuffer_width = scrollbuffer_width;
+ playfield.scrollbuffer_height = scrollbuffer_height;
+}
+
+inline static int GetRealDepth(int depth)
+{
+ return (depth == DEFAULT_DEPTH ? video.default_depth : depth);
}
inline void InitVideoDisplay(void)
#endif
}
+inline Bitmap CreateBitmapStruct(void)
+{
+#ifdef TARGET_SDL
+ return checked_calloc(sizeof(struct SDLSurfaceInfo));
+#else
+ return checked_calloc(sizeof(struct X11DrawableInfo));
+#endif
+}
+
inline Bitmap CreateBitmap(int width, int height, int depth)
{
+ Bitmap new_bitmap = CreateBitmapStruct();
int real_depth = GetRealDepth(depth);
#ifdef TARGET_SDL
SDL_FreeSurface(surface_tmp);
- return surface_native;
+ new_bitmap->surface = surface_native;
#else
Pixmap pixmap;
- if (!(pixmap = XCreatePixmap(display, window, width, height, real_depth)))
+ if (!(pixmap = XCreatePixmap(display, window->drawable,
+ width, height, real_depth)))
Error(ERR_EXIT, "cannot create pixmap");
- return pixmap;
+ new_bitmap->drawable = pixmap;
#endif
+
+ if (window == NULL)
+ Error(ERR_EXIT, "Window GC needed for Bitmap -- create Window first");
+ new_bitmap->gc = window->gc;
+
+ return new_bitmap;
}
inline void FreeBitmap(Bitmap bitmap)
{
+ if (bitmap == NULL)
+ return;
+
#ifdef TARGET_SDL
- SDL_FreeSurface(bitmap);
+ if (bitmap->surface)
+ SDL_FreeSurface(bitmap->surface);
+ if (bitmap->surface_masked)
+ SDL_FreeSurface(bitmap->surface_masked);
#else
- XFreePixmap(display, bitmap);
+ if (bitmap->drawable)
+ XFreePixmap(display, bitmap->drawable);
+ if (bitmap->clip_mask)
+ XFreePixmap(display, bitmap->clip_mask);
+ if (bitmap->stored_clip_gc)
+ XFreeGC(display, bitmap->stored_clip_gc);
#endif
+
+ free(bitmap);
}
-inline void ClearRectangle(Bitmap bitmap, int x, int y, int width, int height)
+inline void CloseWindow(DrawWindow window)
{
-#ifdef TARGET_SDL
- SDLFillRectangle(bitmap, x, y, width, height, 0x000000);
-#else
- XFillRectangle(display, bitmap, gc, x, y, width, height);
+#ifdef TARGET_X11
+ if (window->drawable)
+ {
+ XUnmapWindow(display, window->drawable);
+ XDestroyWindow(display, window->drawable);
+ }
+ if (window->gc)
+ XFreeGC(display, window->gc);
#endif
}
{
#ifdef TARGET_SDL
SDLCopyArea(src_bitmap, dst_bitmap,
- src_x, src_y, width, height, dst_x, dst_y);
+ src_x, src_y, width, height, dst_x, dst_y, SDLCOPYAREA_OPAQUE);
+#else
+ XCopyArea(display, src_bitmap->drawable, dst_bitmap->drawable,
+ dst_bitmap->gc, src_x, src_y, width, height, dst_x, dst_y);
+#endif
+}
+
+inline void ClearRectangle(Bitmap bitmap, int x, int y, int width, int height)
+{
+#ifdef TARGET_SDL
+ SDLFillRectangle(bitmap, x, y, width, height, 0x000000);
#else
- XCopyArea(display, src_bitmap, dst_bitmap, gc,
- src_x, src_y, width, height, dst_x, dst_y);
+ XFillRectangle(display, bitmap->drawable, bitmap->gc, x, y, width, height);
#endif
}
+#if 0
#ifndef TARGET_SDL
static GC last_clip_gc = 0; /* needed for XCopyArea() through clip mask */
#endif
+#endif
-inline void SetClipMask(GC clip_gc, Pixmap clip_pixmap)
+inline void SetClipMask(Bitmap bitmap, GC clip_gc, Pixmap clip_pixmap)
{
-#ifndef TARGET_SDL
- XSetClipMask(display, clip_gc, clip_pixmap);
+#ifdef TARGET_X11
+ if (clip_gc)
+ {
+ bitmap->clip_gc = clip_gc;
+ XSetClipMask(display, bitmap->clip_gc, clip_pixmap);
+ }
+#if 0
last_clip_gc = clip_gc;
#endif
+#endif
}
-inline void SetClipOrigin(GC clip_gc, int clip_x, int clip_y)
+inline void SetClipOrigin(Bitmap bitmap, GC clip_gc, int clip_x, int clip_y)
{
-#ifndef TARGET_SDL
- XSetClipOrigin(display, clip_gc, clip_x, clip_y);
+#ifdef TARGET_X11
+ if (clip_gc)
+ {
+ bitmap->clip_gc = clip_gc;
+ XSetClipOrigin(display, bitmap->clip_gc, clip_x, clip_y);
+ }
+#if 0
last_clip_gc = clip_gc;
#endif
+#endif
}
inline void BlitBitmapMasked(Bitmap src_bitmap, Bitmap dst_bitmap,
{
#ifdef TARGET_SDL
SDLCopyArea(src_bitmap, dst_bitmap,
- src_x, src_y, width, height, dst_x, dst_y);
+ src_x, src_y, width, height, dst_x, dst_y, SDLCOPYAREA_MASKED);
#else
- XCopyArea(display, src_bitmap, dst_bitmap, last_clip_gc,
- src_x, src_y, width, height, dst_x, dst_y);
+ XCopyArea(display, src_bitmap->drawable, dst_bitmap->drawable,
+ src_bitmap->clip_gc, src_x, src_y, width, height, dst_x, dst_y);
#endif
}
int to_x, int to_y)
{
#ifdef TARGET_SDL
- SDLDrawSimpleLine(bitmap, from_x, from_y, to_x, to_y, 0xffffff);
+ SDLDrawSimpleLine(bitmap->drawable, from_x, from_y, to_x, to_y, 0xffffff);
#else
- XSetForeground(display, gc, WhitePixel(display, screen));
- XDrawLine(display, bitmap, gc, from_x, from_y, to_x, to_y);
- XSetForeground(display, gc, BlackPixel(display, screen));
+ XSetForeground(display, bitmap->gc, WhitePixel(display, screen));
+ XDrawLine(display, bitmap->drawable, bitmap->gc, from_x, from_y, to_x, to_y);
+ XSetForeground(display, bitmap->gc, BlackPixel(display, screen));
#endif
}
#ifdef TARGET_SDL
return TRUE;
#else
- DrawWindow root, child;
+ Window root, child;
int root_x, root_y;
unsigned int mask;
int win_x, win_y;
/* if XQueryPointer() returns False, the pointer
is not on the same screen as the specified window */
- return XQueryPointer(display, window, &root, &child, &root_x, &root_y,
- &win_x, &win_y, &mask);
+ return XQueryPointer(display, window->drawable, &root, &child,
+ &root_x, &root_y, &win_x, &win_y, &mask);
#endif
}
#if defined(TARGET_SDL)
return TRUE; /* the only possible message here is SDL_QUIT */
#elif defined(PLATFORM_UNIX)
- if ((event->window == window) &&
+ if ((event->window == window->drawable) &&
(event->data.l[0] == XInternAtom(display, "WM_DELETE_WINDOW", FALSE)))
return TRUE;
#endif
#define FULLSCREEN_AVAILABLE TRUE
+/* values for redraw_mask */
+#define REDRAW_ALL (1 << 0)
+#define REDRAW_FIELD (1 << 1)
+#define REDRAW_TILES (1 << 2)
+#define REDRAW_DOOR_1 (1 << 3)
+#define REDRAW_VIDEO_1 (1 << 4)
+#define REDRAW_VIDEO_2 (1 << 5)
+#define REDRAW_VIDEO_3 (1 << 6)
+#define REDRAW_MICROLEVEL (1 << 7)
+#define REDRAW_FROM_BACKBUFFER (1 << 8)
+#define REDRAW_DOOR_2 (REDRAW_VIDEO_1 | \
+ REDRAW_VIDEO_2 | \
+ REDRAW_VIDEO_3)
+#define REDRAW_DOOR_3 (1 << 9)
+#define REDRAW_DOORS (REDRAW_DOOR_1 | \
+ REDRAW_DOOR_2 | \
+ REDRAW_DOOR_3)
+#define REDRAW_MAIN (REDRAW_FIELD | \
+ REDRAW_TILES | \
+ REDRAW_MICROLEVEL)
+#define REDRAW_FPS (1 << 10)
+#define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2)
+
+
/* type definitions */
typedef int (*EventFilter)(const Event *);
char *msdos_pointer_filename;
};
+struct OptionInfo
+{
+ char *display_name;
+ char *server_host;
+ int server_port;
+ char *ro_base_directory;
+ char *rw_base_directory;
+ char *level_directory;
+ boolean serveronly;
+ boolean network;
+ boolean verbose;
+ boolean debug;
+};
+
struct VideoSystemInfo
{
int default_depth;
int width, height, depth;
- int scrollbuffer_width, scrollbuffer_height;
boolean fullscreen_available;
boolean fullscreen_enabled;
};
int device_fd;
};
-struct OptionInfo
+struct PlayfieldInfo
{
- char *display_name;
- char *server_host;
- int server_port;
- char *ro_base_directory;
- char *rw_base_directory;
- char *level_directory;
- boolean serveronly;
- boolean network;
- boolean verbose;
- boolean debug;
+ int sx, sy;
+ int sxsize, sysize;
+ int real_sx, real_sy;
+ int full_sxsize, full_sysize;
+ int scrollbuffer_width, scrollbuffer_height;
+
+ int dx, dy;
+ int dxsize, dysize;
+
+ int vx, vy;
+ int vxsize, vysize;
};
/* ========================================================================= */
extern struct ProgramInfo program;
+extern struct OptionInfo options;
extern struct VideoSystemInfo video;
extern struct AudioSystemInfo audio;
-extern struct OptionInfo options;
-
-
-/* declarations of internal variables */
+extern struct PlayfieldInfo playfield;
extern Display *display;
extern Visual *visual;
extern DrawWindow window;
extern DrawBuffer backbuffer;
-extern GC gc;
+extern DrawBuffer drawto;
+
+extern int redraw_mask;
+extern int redraw_tiles;
extern int FrameCounter;
inline void InitProgramInfo(char *, char *, char *, char *, char *, char *,
char *);
-inline void InitScrollbufferSize(int, int);
+
+inline void InitPlayfieldInfo(int, int, int, int, int, int, int, int);
+inline void InitDoor1Info(int, int, int, int);
+inline void InitDoor2Info(int, int, int, int);
+inline void InitScrollbufferInfo(int, int);
+
inline void InitVideoDisplay(void);
inline void InitVideoBuffer(DrawBuffer *,DrawWindow *, int, int, int, boolean);
+inline Bitmap CreateBitmapStruct(void);
inline Bitmap CreateBitmap(int, int, int);
inline void FreeBitmap(Bitmap);
-inline void ClearRectangle(Bitmap, int, int, int, int);
inline void BlitBitmap(Bitmap, Bitmap, int, int, int, int, int, int);
-inline void SetClipMask(GC, Pixmap);
-inline void SetClipOrigin(GC, int, int);
+inline void ClearRectangle(Bitmap, int, int, int, int);
+inline void SetClipMask(Bitmap, GC, Pixmap);
+inline void SetClipOrigin(Bitmap, GC, int, int);
inline void BlitBitmapMasked(Bitmap, Bitmap, int, int, int, int, int, int);
inline void DrawSimpleWhiteLine(Bitmap, int, int, int, int);
inline void FlushDisplay(void);
#include "libgame.h"
+#if 1
#include "main_TMP.h"
+#endif
+
+
+/* ========================================================================= */
+/* exported variables */
+/* ========================================================================= */
+
+struct FontInfo font;
+
+
+/* ========================================================================= */
+/* font functions */
+/* ========================================================================= */
+
+void InitFontInfo(Bitmap bitmap_big, Bitmap bitmap_medium,
+ Bitmap bitmap_small)
+{
+ font.bitmap_big = bitmap_big;
+ font.bitmap_medium = bitmap_medium;
+ font.bitmap_small = bitmap_small;
+}
int getFontWidth(int font_size, int font_type)
{
void DrawInitText(char *text, int ypos, int color)
{
- if (window && pix[PIX_SMALLFONT])
+ if (window && font.bitmap_small)
{
- ClearRectangle(window, 0, ypos, WIN_XSIZE, FONT2_YSIZE);
- DrawTextExt(window, gc, (WIN_XSIZE - strlen(text) * FONT2_XSIZE)/2,
+ ClearRectangle(window, 0, ypos, video.width, FONT2_YSIZE);
+ DrawTextExt(window, (video.width - strlen(text) * FONT2_XSIZE)/2,
ypos, text, FS_SMALL, color);
FlushDisplay();
}
void DrawTextFCentered(int y, int font_type, char *format, ...)
{
- char buffer[FULL_SXSIZE / FONT5_XSIZE + 10];
+ char buffer[MAX_OUTPUT_LINESIZE + 1];
int font_width = getFontWidth(FS_SMALL, font_type);
va_list ap;
vsprintf(buffer, format, ap);
va_end(ap);
- DrawText(SX + (SXSIZE - strlen(buffer) * font_width) / 2, SY + y,
- buffer, FS_SMALL, font_type);
+ DrawText(playfield.sx + (playfield.sxsize - strlen(buffer) * font_width) / 2,
+ playfield.sy + y, buffer, FS_SMALL, font_type);
}
void DrawTextF(int x, int y, int font_type, char *format, ...)
{
- char buffer[FULL_SXSIZE / FONT5_XSIZE + 10];
+ char buffer[MAX_OUTPUT_LINESIZE + 1];
va_list ap;
va_start(ap, format);
vsprintf(buffer, format, ap);
va_end(ap);
- DrawText(SX + x, SY + y, buffer, FS_SMALL, font_type);
+ DrawText(playfield.sx + x, playfield.sy + y, buffer, FS_SMALL, font_type);
}
void DrawText(int x, int y, char *text, int font_size, int font_type)
{
- DrawTextExt(drawto, gc, x, y, text, font_size, font_type);
+ DrawTextExt(drawto, x, y, text, font_size, font_type);
- if (x < DX)
+ if (x < playfield.dx)
redraw_mask |= REDRAW_FIELD;
- else if (y < VY)
+ else if (y < playfield.vy)
redraw_mask |= REDRAW_DOOR_1;
}
-void DrawTextExt(DrawBuffer d, GC gc, int x, int y,
+void DrawTextExt(DrawBuffer bitmap, int x, int y,
char *text, int font_size, int font_type)
{
+ Bitmap font_bitmap;
int font_width, font_height, font_start;
- int font_bitmap;
boolean print_inverse = FALSE;
if (font_size != FS_SMALL && font_size != FS_BIG && font_size != FS_MEDIUM)
font_width = getFontWidth(font_size, font_type);
font_height = getFontHeight(font_size, font_type);
- font_bitmap = (font_size == FS_BIG ? PIX_BIGFONT :
- font_size == FS_MEDIUM ? PIX_MEDIUMFONT :
- PIX_SMALLFONT);
+ font_bitmap = (font_size == FS_BIG ? font.bitmap_big :
+ font_size == FS_MEDIUM ? font.bitmap_medium :
+ font.bitmap_small);
font_start = (font_type * (font_size == FS_BIG ? FONT1_YSIZE :
font_size == FS_MEDIUM ? FONT6_YSIZE :
FONT2_YSIZE) *
if (print_inverse)
{
- BlitBitmap(pix[font_bitmap], d,
+ BlitBitmap(font_bitmap, bitmap,
FONT_CHARS_PER_LINE * font_width,
3 * font_height + font_start,
font_width, font_height, x, y);
- SetClipOrigin(clip_gc[font_bitmap], dest_x - src_x, dest_y - src_y);
- BlitBitmapMasked(pix_masked[font_bitmap], d,
+ SetClipOrigin(font_bitmap, font_bitmap->stored_clip_gc,
+ dest_x - src_x, dest_y - src_y);
+ BlitBitmapMasked(font_bitmap, bitmap,
0, 0, font_width, font_height, dest_x, dest_y);
}
else
- BlitBitmap(pix[font_bitmap], d,
+ BlitBitmap(font_bitmap, bitmap,
src_x, src_y, font_width, font_height, dest_x, dest_y);
}
#include "libgame.h"
+/* font types */
+#define FS_SMALL 0
+#define FS_BIG 1
+#define FS_MEDIUM 2
+
+/* font colors */
+#define FC_RED 0
+#define FC_BLUE 1
+#define FC_GREEN 2
+#define FC_YELLOW 3
+#define FC_SPECIAL1 4
+#define FC_SPECIAL2 5
+#define FC_SPECIAL3 6
+
+/* font graphics definitions */
+#define FONT1_XSIZE 32
+#define FONT1_YSIZE 32
+#define FONT2_XSIZE 14
+#define FONT2_YSIZE 14
+#define FONT3_XSIZE 11
+#define FONT3_YSIZE 14
+#define FONT4_XSIZE 16
+#define FONT4_YSIZE 16
+#define FONT5_XSIZE 10
+#define FONT5_YSIZE 14
+#define FONT6_XSIZE 16
+#define FONT6_YSIZE 32
+
+#define FONT_CHARS_PER_LINE 16
+#define FONT_LINES_PER_FONT 4
+
+/* text output definitions */
+#define MAX_OUTPUT_LINESIZE 256
+
+/* font structure definitions */
+
+struct FontInfo
+{
+ Bitmap bitmap_big, bitmap_medium, bitmap_small;
+};
+
+
+void InitFontInfo(Bitmap, Bitmap, Bitmap);
int getFontWidth(int, int);
int getFontHeight(int, int);
void DrawInitText(char *, int, int);
void DrawTextF(int, int, int, char *, ...);
void DrawTextFCentered(int, int, char *, ...);
void DrawText(int, int, char *, int, int);
-void DrawTextExt(DrawBuffer, GC, int, int, char *, int, int);
+void DrawTextExt(DrawBuffer, int, int, char *, int, int);
#endif /* TEXT_H */
{
*window = X11InitWindow();
- XMapWindow(display, *window);
+ XMapWindow(display, (*window)->drawable);
FlushDisplay();
/* create additional (off-screen) buffer for double-buffering */
static DrawWindow X11InitWindow()
{
- Window window;
+ DrawWindow new_window = CreateBitmapStruct();
unsigned int border_width = 4;
XGCValues gc_values;
unsigned long gc_valuemask;
win_xpos = (screen_width - width) / 2;
win_ypos = (screen_height - height) / 2;
- window = XCreateSimpleWindow(display, RootWindow(display, screen),
- win_xpos, win_ypos, width, height, border_width,
- pen_fg, pen_bg);
+ new_window->drawable = XCreateSimpleWindow(display,
+ RootWindow(display, screen),
+ win_xpos, win_ypos,
+ width, height, border_width,
+ pen_fg, pen_bg);
#if !defined(PLATFORM_MSDOS)
proto_atom = XInternAtom(display, "WM_PROTOCOLS", FALSE);
delete_atom = XInternAtom(display, "WM_DELETE_WINDOW", FALSE);
if ((proto_atom != None) && (delete_atom != None))
- XChangeProperty(display, window, proto_atom, XA_ATOM, 32,
+ XChangeProperty(display, new_window->drawable, proto_atom, XA_ATOM, 32,
PropModePrepend, (unsigned char *) &delete_atom, 1);
#if 0
options.ro_base_directory, GRAPHICS_DIRECTORY,
icon_pic.picture_filename);
#endif
- XReadBitmapFile(display, window, program.x11_icon_filename,
+ XReadBitmapFile(display, new_window->drawable, program.x11_icon_filename,
&icon_width, &icon_height,
&icon_pixmap, &icon_hot_x, &icon_hot_y);
if (!icon_pixmap)
options.ro_base_directory, GRAPHICS_DIRECTORY,
icon_pic.picturemask_filename);
#endif
- XReadBitmapFile(display, window, program.x11_iconmask_filename,
+ XReadBitmapFile(display, new_window->drawable, program.x11_iconmask_filename,
&icon_width, &icon_height,
&iconmask_pixmap, &icon_hot_x, &icon_hot_y);
if (!iconmask_pixmap)
class_hints.res_name = program.command_name;
class_hints.res_class = program.program_title;
- XSetWMProperties(display, window, &windowName, &iconName,
+ XSetWMProperties(display, new_window->drawable, &windowName, &iconName,
NULL, 0, &size_hints, &wm_hints,
&class_hints);
ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
PointerMotionHintMask | KeyPressMask | KeyReleaseMask;
- XSelectInput(display, window, window_event_mask);
+ XSelectInput(display, new_window->drawable, window_event_mask);
#endif
/* create GC for drawing with window depth and background color (black) */
gc_values.foreground = pen_bg;
gc_values.background = pen_bg;
gc_valuemask = GCGraphicsExposures | GCForeground | GCBackground;
- gc = XCreateGC(display, window, gc_valuemask, &gc_values);
+ new_window->gc =
+ XCreateGC(display, new_window->drawable, gc_valuemask, &gc_values);
- return window;
+ return new_window;
}
#endif /* TARGET_X11 */
#define FULLSCREEN_STATUS FULLSCREEN_NOT_AVAILABLE
+/* structure definitions */
+
+struct X11DrawableInfo
+{
+ Drawable drawable;
+ Drawable clip_mask;
+ GC gc; /* GC for normal drawing (inheritated from 'window') */
+ GC stored_clip_gc; /* GC for masked drawing (used for whole Pixmap) */
+ GC clip_gc; /* can be 'stored_clip_gc' or one-tile-only clip GC */
+};
+
+
/* X11 type definitions */
-typedef Pixmap Bitmap;
-typedef Window DrawWindow;
-typedef Drawable DrawBuffer;
+typedef struct X11DrawableInfo *Bitmap;
+typedef struct X11DrawableInfo *DrawWindow;
+typedef struct X11DrawableInfo *DrawBuffer;
typedef KeySym Key;
GC gc;
#endif
-GC clip_gc[NUM_BITMAPS], tile_clip_gc;
+#if 0
+GC clip_gc[NUM_BITMAPS];
+#endif
+GC tile_clip_gc;
Bitmap pix[NUM_BITMAPS];
-Bitmap pix_masked[NUM_BITMAPS], tile_masked[NUM_TILES];
-Pixmap clipmask[NUM_BITMAPS], tile_clipmask[NUM_TILES];
+#if 0
+Bitmap pix_masked[NUM_BITMAPS];
+#endif
+Bitmap tile_masked[NUM_TILES];
+#if 0
+Pixmap clipmask[NUM_BITMAPS];
+#endif
+Pixmap tile_clipmask[NUM_TILES];
-DrawBuffer drawto, drawto_field, fieldbuffer;
+#if 0
+DrawBuffer drawto;
+#endif
+
+DrawBuffer drawto_field, fieldbuffer;
#if 0
Colormap cmap;
#endif
boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
int redraw_x1 = 0, redraw_y1 = 0;
+
+#if 0
int redraw_mask;
int redraw_tiles;
+#endif
short Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
short Ur[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
extern GC gc;
#endif
-extern GC clip_gc[], tile_clip_gc;
+#if 0
+extern GC clip_gc[];
+#endif
+extern GC tile_clip_gc;
extern Bitmap pix[];
-extern Bitmap pix_masked[], tile_masked[];
-extern Pixmap clipmask[], tile_clipmask[];
+#if 0
+extern Bitmap pix_masked[];
+#endif
+extern Bitmap tile_masked[];
+#if 0
+extern Pixmap clipmask[];
+#endif
+extern Pixmap tile_clipmask[];
-extern DrawBuffer drawto, drawto_field, fieldbuffer;
+#if 0
+extern DrawBuffer drawto;
+#endif
+extern DrawBuffer drawto_field, fieldbuffer;
#if 0
extern Colormap cmap;
#endif
extern boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
extern int redraw_x1, redraw_y1;
+
+#if 0
extern int redraw_mask;
extern int redraw_tiles;
+#endif
extern short Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
extern short Ur[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
#define MICROLEV_XPOS (SX + (SXSIZE - MICROLEV_XSIZE) / 2)
#define MICROLEV_YPOS (SX + 12 * TILEY - MICRO_TILEY)
#define MICROLABEL_YPOS (MICROLEV_YPOS + MICROLEV_YSIZE + 7)
+
+#if 0
#define FONT1_XSIZE 32
#define FONT1_YSIZE 32
#define FONT2_XSIZE 14
#define FONT5_YSIZE 14
#define FONT6_XSIZE 16
#define FONT6_YSIZE 32
+#endif
#define GFX_STARTX SX
#define GFX_STARTY SY
#define MINI_MORE_PER_LINE 16
#define MICRO_MORE_PER_LINE 16
+#if 0
#define FONT_CHARS_PER_LINE 16
#define FONT_LINES_PER_FONT 4
+#endif
/* game elements:
** 0 - 499: real elements, stored in level file
#define MV_UP (1 << 2)
#define MV_DOWN (1 << 3)
+#if 0
/* font types */
#define FS_SMALL 0
#define FS_BIG 1
#define FC_SPECIAL1 4
#define FC_SPECIAL2 5
#define FC_SPECIAL3 6
+#endif
/* values for game_status */
#define EXITGAME 0
#define MB_MIDDLEBUTTON 2
#define MB_RIGHTBUTTON 3
+#if 0
/* values for redraw_mask */
#define REDRAW_ALL (1 << 0)
#define REDRAW_FIELD (1 << 1)
REDRAW_MICROLEVEL)
#define REDRAW_FPS (1 << 10)
#define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2)
+#endif
/* areas in bitmap PIX_DOOR */
/* meaning in PIX_DB_DOOR: (3 PAGEs)
level_nr = new_level_nr;
- DrawTextExt(drawto, gc, SX + 11 * 32, SY + 3 * 32,
+ DrawTextExt(drawto, SX + 11 * 32, SY + 3 * 32,
int2str(level_nr, 3), FS_BIG, font_color);
- DrawTextExt(window, gc, SX + 11 * 32, SY + 3 * 32,
+ DrawTextExt(window, SX + 11 * 32, SY + 3 * 32,
int2str(level_nr, 3), FS_BIG, font_color);
LoadLevel(level_nr);
}
j++;
- DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame);
+ DrawGraphicExt(drawto, xstart, ystart+(i-start)*ystep, graphic+frame);
i++;
}
setup.player_name[xpos] = ascii;
setup.player_name[xpos + 1] = 0;
xpos++;
- DrawTextExt(drawto, gc, SX + 6*32, SY + ypos*32,
+ DrawTextExt(drawto, SX + 6*32, SY + ypos*32,
setup.player_name, FS_BIG, FC_YELLOW);
- DrawTextExt(window, gc, SX + 6*32, SY + ypos*32,
+ DrawTextExt(window, SX + 6*32, SY + ypos*32,
setup.player_name, FS_BIG, FC_YELLOW);
DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
}
info1[0] = '\0';
sprintf(text, "%.1f fps%s", global.frames_per_second, info1);
- DrawTextExt(window, gc, SX, SY, text, FS_SMALL, FC_YELLOW);
+ DrawTextExt(window, SX, SY, text, FS_SMALL, FC_YELLOW);
}
FlushDisplay();
if (window && pix[PIX_SMALLFONT])
{
ClearRectangle(window, 0, ypos, WIN_XSIZE, FONT2_YSIZE);
- DrawTextExt(window, gc, (WIN_XSIZE - strlen(text) * FONT2_XSIZE)/2,
+ DrawTextExt(window, (WIN_XSIZE - strlen(text) * FONT2_XSIZE)/2,
ypos, text, FS_SMALL, color);
FlushDisplay();
}
}
#endif
- DrawGraphicExt(drawto_field, gc, FX + x*TILEX, FY + y*TILEY, graphic);
+ DrawGraphicExt(drawto_field, FX + x*TILEX, FY + y*TILEY, graphic);
MarkTileDirty(x,y);
}
-void DrawGraphicExt(DrawBuffer d, GC gc, int x, int y, int graphic)
+void DrawGraphicExt(DrawBuffer bitmap, int x, int y, int graphic)
{
int bitmap_nr;
int src_x, src_y;
getGraphicSource(graphic, &bitmap_nr, &src_x, &src_y);
- BlitBitmap(pix[bitmap_nr], d, src_x, src_y, TILEX, TILEY, x, y);
+ BlitBitmap(pix[bitmap_nr], bitmap, src_x, src_y, TILEX, TILEY, x, y);
}
void DrawGraphicThruMask(int x, int y, int graphic)
return;
getGraphicSource(graphic, &bitmap_nr, &src_x, &src_y);
- src_bitmap = pix_masked[bitmap_nr];
- drawing_gc = clip_gc[bitmap_nr];
+ src_bitmap = pix[bitmap_nr];
+ drawing_gc = pix[bitmap_nr]->stored_clip_gc;
if (tile_clipmask[tile] != None)
{
- SetClipMask(tile_clip_gc, tile_clipmask[tile]);
- SetClipOrigin(tile_clip_gc, dest_x, dest_y);
+ SetClipMask(src_bitmap, tile_clip_gc, tile_clipmask[tile]);
+ SetClipOrigin(src_bitmap, tile_clip_gc, dest_x, dest_y);
BlitBitmapMasked(src_bitmap, d,
src_x, src_y, TILEX, TILEY, dest_x, dest_y);
}
#endif
#endif
- SetClipOrigin(drawing_gc, dest_x-src_x, dest_y-src_y);
+ SetClipOrigin(src_bitmap, drawing_gc, dest_x-src_x, dest_y-src_y);
BlitBitmapMasked(src_bitmap, d,
src_x, src_y, TILEX, TILEY, dest_x, dest_y);
}
void DrawMiniGraphic(int x, int y, int graphic)
{
- DrawMiniGraphicExt(drawto,gc, SX + x*MINI_TILEX, SY + y*MINI_TILEY, graphic);
+ DrawMiniGraphicExt(drawto, SX + x*MINI_TILEX, SY + y*MINI_TILEY, graphic);
MarkTileDirty(x/2, y/2);
}
}
}
-void DrawMiniGraphicExt(DrawBuffer d, GC gc, int x, int y, int graphic)
+void DrawMiniGraphicExt(DrawBuffer d, int x, int y, int graphic)
{
Bitmap bitmap;
int src_x, src_y;
int src_x, src_y, dest_x, dest_y;
int tile = graphic;
int bitmap_nr;
+ Bitmap src_bitmap;
GC drawing_gc;
if (graphic < 0)
}
getGraphicSource(graphic, &bitmap_nr, &src_x, &src_y);
- drawing_gc = clip_gc[bitmap_nr];
+ src_bitmap = pix[bitmap_nr];
+ drawing_gc = pix[bitmap_nr]->stored_clip_gc;
src_x += cx;
src_y += cy;
{
if (tile_clipmask[tile] != None)
{
- SetClipMask(tile_clip_gc, tile_clipmask[tile]);
- SetClipOrigin(tile_clip_gc, dest_x, dest_y);
- BlitBitmapMasked(pix_masked[bitmap_nr], drawto_field,
+ SetClipMask(src_bitmap, tile_clip_gc, tile_clipmask[tile]);
+ SetClipOrigin(src_bitmap, tile_clip_gc, dest_x, dest_y);
+ BlitBitmapMasked(src_bitmap, drawto_field,
src_x, src_y, TILEX, TILEY, dest_x, dest_y);
}
else
#endif
#endif
- SetClipOrigin(drawing_gc, dest_x - src_x, dest_y - src_y);
- BlitBitmapMasked(pix_masked[bitmap_nr], drawto_field,
+ SetClipOrigin(src_bitmap, drawing_gc, dest_x - src_x, dest_y - src_y);
+ BlitBitmapMasked(src_bitmap, drawto_field,
src_x, src_y, width, height, dest_x, dest_y);
}
}
}
sprintf(txt, text);
txt[tl] = 0;
- DrawTextExt(drawto, gc,
- DX + 51 - (tl * 14)/2, DY + 8 + ty * 16,
+ DrawTextExt(drawto, DX + 51 - (tl * 14)/2, DY + 8 + ty * 16,
txt, FS_SMALL, FC_YELLOW);
text += tl + (tc == 32 ? 1 : 0);
}
for(x=start; x<=DXSIZE; x+=stepsize)
{
+ Bitmap bitmap = pix[PIX_DOOR];
+ GC gc = bitmap->stored_clip_gc;
+
WaitUntilDelayReached(&door_delay, door_delay_value);
if (door_state & DOOR_ACTION_1)
ClearRectangle(drawto, DX, DY + DYSIZE - i/2, DXSIZE,i/2);
- SetClipOrigin(clip_gc[PIX_DOOR], DX - i, (DY + j) - DOOR_GFX_PAGEY1);
- BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+ SetClipOrigin(bitmap, gc, DX - i, (DY + j) - DOOR_GFX_PAGEY1);
+ BlitBitmapMasked(bitmap, drawto,
DXSIZE, DOOR_GFX_PAGEY1, i, 77,
DX + DXSIZE - i, DY + j);
- BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+ BlitBitmapMasked(bitmap, drawto,
DXSIZE, DOOR_GFX_PAGEY1 + 140, i, 63,
DX + DXSIZE - i, DY + 140 + j);
- SetClipOrigin(clip_gc[PIX_DOOR],
- DX - DXSIZE + i, DY - (DOOR_GFX_PAGEY1 + j));
- BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+ SetClipOrigin(bitmap, gc, DX - DXSIZE + i, DY - (DOOR_GFX_PAGEY1 + j));
+ BlitBitmapMasked(bitmap, drawto,
DXSIZE - i, DOOR_GFX_PAGEY1 + j, i, 77 - j,
DX, DY);
- BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+ BlitBitmapMasked(bitmap, drawto,
DXSIZE-i, DOOR_GFX_PAGEY1 + 140, i, 63,
DX, DY + 140 - j);
- BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+ BlitBitmapMasked(bitmap, drawto,
DXSIZE - i, DOOR_GFX_PAGEY1 + 77, i, 63,
DX, DY + 77 - j);
- BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+ BlitBitmapMasked(bitmap, drawto,
DXSIZE - i, DOOR_GFX_PAGEY1 + 203, i, 77,
DX, DY + 203 - j);
- SetClipOrigin(clip_gc[PIX_DOOR], DX - i, (DY + j) - DOOR_GFX_PAGEY1);
- BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+ SetClipOrigin(bitmap, gc, DX - i, (DY + j) - DOOR_GFX_PAGEY1);
+ BlitBitmapMasked(bitmap, drawto,
DXSIZE, DOOR_GFX_PAGEY1 + 77, i, 63,
DX + DXSIZE - i, DY + 77 + j);
- BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+ BlitBitmapMasked(bitmap, drawto,
DXSIZE, DOOR_GFX_PAGEY1 + 203, i, 77 - j,
DX + DXSIZE - i, DY + 203 + j);
ClearRectangle(drawto, VX, VY + VYSIZE-i/2, VXSIZE, i/2);
- SetClipOrigin(clip_gc[PIX_DOOR], VX - i, (VY + j) - DOOR_GFX_PAGEY2);
- BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+ SetClipOrigin(bitmap, gc, VX - i, (VY + j) - DOOR_GFX_PAGEY2);
+ BlitBitmapMasked(bitmap, drawto,
VXSIZE, DOOR_GFX_PAGEY2, i, VYSIZE / 2,
VX + VXSIZE-i, VY+j);
- SetClipOrigin(clip_gc[PIX_DOOR],
+ SetClipOrigin(bitmap, gc,
VX - VXSIZE + i, VY - (DOOR_GFX_PAGEY2 + j));
- BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+ BlitBitmapMasked(bitmap, drawto,
VXSIZE - i, DOOR_GFX_PAGEY2 + j, i, VYSIZE / 2 - j,
VX, VY);
- BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+ BlitBitmapMasked(bitmap, drawto,
VXSIZE - i, DOOR_GFX_PAGEY2 + VYSIZE / 2,
i, VYSIZE / 2, VX, VY + VYSIZE / 2 - j);
- SetClipOrigin(clip_gc[PIX_DOOR], VX - i, (VY + j) - DOOR_GFX_PAGEY2);
- BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+ SetClipOrigin(bitmap, gc, VX - i, (VY + j) - DOOR_GFX_PAGEY2);
+ BlitBitmapMasked(bitmap, drawto,
VXSIZE, DOOR_GFX_PAGEY2 + VYSIZE / 2,
i, VYSIZE / 2 - j,
VX + VXSIZE - i, VY + VYSIZE / 2 + j);
}
#ifndef TARGET_SDL
-int ReadPixel(DrawBuffer d, int x, int y)
+int ReadPixel(DrawBuffer bitmap, int x, int y)
{
XImage *pixel_image;
unsigned long pixel_value;
- pixel_image = XGetImage(display, d, x, y, 1, 1, AllPlanes, ZPixmap);
+ pixel_image = XGetImage(display, bitmap->drawable,
+ x, y, 1, 1, AllPlanes, ZPixmap);
pixel_value = XGetPixel(pixel_image, 0, 0);
XDestroyImage(pixel_image);
void DrawGraphicAnimationThruMask(int, int, int, int, int, int);
void getGraphicSource(int, int *, int *, int *);
void DrawGraphic(int, int, int);
-void DrawGraphicExt(DrawBuffer, GC, int, int, int);
+void DrawGraphicExt(DrawBuffer, int, int, int);
void DrawGraphicThruMask(int, int, int);
void DrawGraphicThruMaskExt(DrawBuffer, int, int, int);
void DrawMiniGraphic(int, int, int);
void getMiniGraphicSource(int, Bitmap *, int *, int *);
-void DrawMiniGraphicExt(DrawBuffer, GC, int, int, int);
+void DrawMiniGraphicExt(DrawBuffer, int, int, int);
void DrawGraphicShifted(int, int, int, int, int, int, int);
void DrawGraphicShiftedThruMask(int, int, int, int, int, int);
void DrawScreenElementExt(int, int, int, int, int, int, int);