diff -u ./xgame.c ../Mk11/xgame.c --- ./xgame.c Wed Nov 18 10:53:16 1998 +++ ../Mk11/xgame.c Wed Nov 18 10:45:57 1998 @@ -1320,6 +1320,55 @@ + void +XgameDrawSpriteArea(struct XgameWindow *win, int xcen, int ycen, + int srcx, int srcy, int xsize, int ysize, int spritenr) { + struct XgameSprite *thissprite; + int xorig,yorig; + int xmul,ymul; + GC *gcused; + + if (win->skipdraw) return; + + thissprite=&(win->sprite[spritenr]); + xorig = xcen - thissprite->xcenter; + yorig = ycen - thissprite->ycenter; + xsize+= xorig; + ysize+= yorig; + + /*** Scale. Note that begin,end are scaled instead of begin,size. + *** Otherwise, tiles could not be laid seamlessly, because + *** scaled(begin+size) != scaled(begin)+scaled(size) ***/ + xorig = (xorig*(xmul=win->xmul)) / XgameScaleFixDiv; + yorig = (yorig*(ymul=win->ymul)) / XgameScaleFixDiv; + srcx = (srcx * xmul ) / XgameScaleFixDiv; + srcy = (srcy * ymul ) / XgameScaleFixDiv; + xsize = (xsize* xmul ) / XgameScaleFixDiv; + ysize = (ysize* ymul ) / XgameScaleFixDiv; + xsize-= xorig; + ysize-= yorig; + + /*** choose/init GC ***/ + if (!thissprite->mask) { + gcused = &(win->tilegc); + } else { + XSetClipOrigin(win->pdisplay, win->spritegc, xorig,yorig); + XSetClipMask(win->pdisplay, win->spritegc, thissprite->mask); + gcused = &(win->spritegc); + } + + if (win->drawtobuffer) { + XCopyArea(win->pdisplay, thissprite->pixmap,win->buffer, + *gcused, srcx, srcy, xsize, ysize, xorig, yorig ); + XgameAddRect(win->bufrectlist, xorig,yorig, xsize,ysize); + XgameAddRect(win->bgrectlist, xorig,yorig, xsize,ysize); + } else if (win->background) { + XCopyArea(win->pdisplay, thissprite->pixmap, win->background, + *gcused, srcx, srcy, xsize, ysize, xorig, yorig ); + XgameAddBGRects(win,win->bgrectlist, xorig,yorig, xsize,ysize); + } +} + void XgameDrawSprite(struct XgameWindow *win, int xcen, int ycen, int spritenr) { diff -u ./xgame.h ../Mk11/xgame.h --- ./xgame.h Wed Nov 18 10:45:47 1998 +++ ../Mk11/xgame.h Wed Nov 18 10:45:58 1998 @@ -11,6 +11,8 @@ *** *** Thanks to Aaron Digulla for the original extended key support patch. * + * Patchlevel2: New function XgameDrawSpriteArea + * Patchlevel1: mouse offset bug fixed * New in 0.95: * Deleted XgameClear/ShowSprite, they did not seem useful enough to * warrant the amount of duplicated code. @@ -131,7 +133,8 @@ #include /* #include */ -/* #include "xpm.h" */ +/*#include "xpm.h"*/ + #include #include "vroot.h" @@ -547,9 +550,21 @@ /*** drawing pixmaps ***/ void +XgameDrawSpriteArea(struct XgameWindow *win, int xcen, int ycen, + int srcx, int srcy, int xsize, int ysize, int spritenr); + /*** Copy part of pixmap to given coords xcen,ycen, denoting the position + *** where the center of the sprite should appear. Transparency is used + *** when sprite has a mask. The rectangular area within the sprite given + *** by (srcx, srcy)...(srcx+xsize, srcy+ysize) is copied to + *** the topleft coordinates (xcen-spritexcenter, ycen-spriteycenter). The + *** spritecenter coordinates are either (0,0) or equal to the hotspot + *** coordinates as were found in the sprite's XPM file. + ***/ + + void XgameDrawSprite(struct XgameWindow *win, int xcen,int ycen,int spritenr); - /*** Write pixmap at given center coords, using transparency when sprite - *** has a mask. + /*** Equivalent to XgameDrawSpriteArea(win,xcen,ycen, 0,0, + *** spritexsize,spriteysize, spritenr). ***/