endif
ifeq ($(TARGET),allegro)
-SYS_CFLAGS = -DTARGET_X11 -I$(CROSS_PATH_MSDOS)/include
+SYS_CFLAGS = -DTARGET_ALLEGRO -I$(CROSS_PATH_MSDOS)/include
SYS_LDFLAGS = -lalleg
endif
if (!pix[pos]->drawable)
Error(ERR_EXIT, "cannot get graphics for '%s'", pic->picture_filename);
+ pix[pos]->gc = window->gc;
+
#if 0
/* setting pix_masked[] to pix[] allows BlitBitmapMasked() to always
use pix_masked[], although they are the same when not using SDL */
keyboard_auto_repeat = FALSE;
}
+void AllegroDrawLine(Drawable d, int from_x, int from_y, int to_x, int to_y,
+ Pixel color)
+{
+ boolean mouse_off = FALSE;
+
+ if ((BITMAP *)d == video_bitmap)
+ {
+ int dx = AllegroDefaultScreen().x;
+ int dy = AllegroDefaultScreen().y;
+ int x1, y1, x2, y2;
+
+ from_x += dx;
+ from_y += dy;
+ to_x += dx;
+ to_y += dy;
+
+ x1 = (from_x < to_x ? from_x : to_x);
+ y1 = (from_y < to_y ? from_y : to_y);
+ x2 = (from_x < to_x ? to_x : from_x);
+ y2 = (from_y < to_y ? to_y : from_y);
+
+ freeze_mouse_flag = TRUE;
+ mouse_off = hide_mouse(display, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
+ }
+
+ line((BITMAP *)d, from_x, from_y, to_x, to_y, color);
+
+ if (mouse_off)
+ unhide_mouse(display);
+
+ freeze_mouse_flag = FALSE;
+}
+
Bool MSDOSOpenAudio(void)
{
return allegro_init_audio();
#define MapNotify 19
#define ClientMessage 33
+#define LineSolid 0
+#define LineOnOffDash 1
+#define LineDoubleDash 2
+
+#define CapNotLast 0
+#define CapButt 1
+#define CapRound 2
+#define CapProjecting 3
+
+#define JoinMiter 0
+#define JoinRound 1
+#define JoinBevel 2
+
#define GCForeground (1L << 2)
#define GCBackground (1L << 3)
+#define GCLineWidth (1L << 4)
+#define GCLineStyle (1L << 5)
+#define GCCapStyle (1L << 6)
+#define GCJoinStyle (1L << 7)
#define GCGraphicsExposures (1L << 16)
#define GCClipMask (1L << 19)
int clip_x_origin; /* x origin for clipping */
int clip_y_origin; /* y origin for clipping */
unsigned long value_mask;
+ int line_width; /* line width */
+ int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
+ int cap_style; /* CapNotLast, CapButt,
+ CapRound, CapProjecting */
+ int join_style; /* JoinMiter, JoinRound, JoinBevel */
+
} XGCValues;
typedef struct
void XAutoRepeatOn(Display *);
void XAutoRepeatOff(Display *);
+void AllegroDrawLine(Drawable, int, int, int, int, Pixel);
+
Bool MSDOSOpenAudio(void);
void MSDOSCloseAudio(void);
#define PLATFORM_UNIX
#endif
-/* define additional keywords for several Unix platforms */
+/* ========================================================================= */
+/* define additional keywords for MS-DOS platform */
+/* ========================================================================= */
+
+#if defined(PLATFORM_MSDOS)
+
+#ifndef TARGET_ALLEGRO
+#define TARGET_ALLEGRO
+#endif
+
+#ifndef TARGET_X11
+#define TARGET_X11
+#endif
+
+#endif
+
+/* ========================================================================= */
+/* define additional keywords for several Unix platforms */
+/* ========================================================================= */
+
+#if defined(PLATFORM_UNIX) && defined(TARGET_X11)
+#define TARGET_X11_NATIVE
+#endif
#if defined(linux)
#define PLATFORM_LINUX
#if defined(TARGET_SDL)
+/* ========================================================================= */
+/* video functions */
+/* ========================================================================= */
+
inline void SDLInitVideoDisplay(void)
{
/* initialize SDL video */
SDL_MapRGB(surface->format, color_r, color_g, color_b));
}
+inline void SDLDrawLine(SDL_Surface *surface, int from_x, int from_y,
+ int to_x, int to_y, Uint32 color)
+{
+ sge_Line(surface, from_x, from_y, to_x, to_y, color);
+}
+
+#if 0
+inline void SDLDrawLines(SDL_Surface *surface, struct XY *points,
+ int num_points, Uint32 color)
+{
+ int i, x, y;
+ int line_width = 4;
+
+ for (i=0; i<num_points - 1; i++)
+ {
+ for (x=0; x<line_width; x++)
+ {
+ for (y=0; y<line_width; y++)
+ {
+ int dx = x - line_width / 2;
+ int dy = y - line_width / 2;
+
+ if ((x == 0 && y == 0) ||
+ (x == 0 && y == line_width - 1) ||
+ (x == line_width - 1 && y == 0) ||
+ (x == line_width - 1 && y == line_width - 1))
+ continue;
+
+ sge_Line(surface, points[i].x + dx, points[i].y + dy,
+ points[i+1].x + dx, points[i+1].y + dy, color);
+ }
+ }
+ }
+}
+#endif
+
+
+/* ========================================================================= */
+/* The following functions have been taken from the SGE library */
+/* (SDL Graphics Extension Library) by Anders Lindström */
+/* http://www.etek.chalmers.se/~e8cal1/sge/index.html */
+/* ========================================================================= */
+
+void _PutPixel(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
+{
+ if (x >= 0 && x <= surface->w - 1 && y >= 0 && y <= surface->h - 1)
+ {
+ switch (surface->format->BytesPerPixel)
+ {
+ case 1:
+ {
+ /* Assuming 8-bpp */
+ *((Uint8 *)surface->pixels + y*surface->pitch + x) = color;
+ }
+ break;
+
+ case 2:
+ {
+ /* Probably 15-bpp or 16-bpp */
+ *((Uint16 *)surface->pixels + y*surface->pitch/2 + x) = color;
+ }
+ break;
+
+ case 3:
+ {
+ /* Slow 24-bpp mode, usually not used */
+ Uint8 *pix;
+ int shift;
+
+ /* Gack - slow, but endian correct */
+ pix = (Uint8 *)surface->pixels + y * surface->pitch + x*3;
+ shift = surface->format->Rshift;
+ *(pix+shift/8) = color>>shift;
+ shift = surface->format->Gshift;
+ *(pix+shift/8) = color>>shift;
+ shift = surface->format->Bshift;
+ *(pix+shift/8) = color>>shift;
+ }
+ break;
+
+ case 4:
+ {
+ /* Probably 32-bpp */
+ *((Uint32 *)surface->pixels + y*surface->pitch/4 + x) = color;
+ }
+ break;
+ }
+ }
+}
+
+void _PutPixelRGB(SDL_Surface *surface, Sint16 x, Sint16 y,
+ Uint8 R, Uint8 G, Uint8 B)
+{
+ _PutPixel(surface, x, y, SDL_MapRGB(surface->format, R, G, B));
+}
+
+void _PutPixel8(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
+{
+ *((Uint8 *)surface->pixels + y*surface->pitch + x) = color;
+}
+
+void _PutPixel16(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
+{
+ *((Uint16 *)surface->pixels + y*surface->pitch/2 + x) = color;
+}
+
+void _PutPixel24(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
+{
+ Uint8 *pix;
+ int shift;
+
+ /* Gack - slow, but endian correct */
+ pix = (Uint8 *)surface->pixels + y * surface->pitch + x*3;
+ shift = surface->format->Rshift;
+ *(pix+shift/8) = color>>shift;
+ shift = surface->format->Gshift;
+ *(pix+shift/8) = color>>shift;
+ shift = surface->format->Bshift;
+ *(pix+shift/8) = color>>shift;
+}
+
+void _PutPixel32(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
+{
+ *((Uint32 *)surface->pixels + y*surface->pitch/4 + x) = color;
+}
+
+void _PutPixelX(SDL_Surface *dest,Sint16 x,Sint16 y,Uint32 color)
+{
+ switch (dest->format->BytesPerPixel)
+ {
+ case 1:
+ *((Uint8 *)dest->pixels + y*dest->pitch + x) = color;
+ break;
+
+ case 2:
+ *((Uint16 *)dest->pixels + y*dest->pitch/2 + x) = color;
+ break;
+
+ case 3:
+ _PutPixel24(dest,x,y,color);
+ break;
+
+ case 4:
+ *((Uint32 *)dest->pixels + y*dest->pitch/4 + x) = color;
+ break;
+ }
+}
+
+void sge_PutPixel(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
+{
+ if (SDL_MUSTLOCK(surface))
+ {
+ if (SDL_LockSurface(surface) < 0)
+ {
+ return;
+ }
+ }
+
+ _PutPixel(surface, x, y, color);
+
+ if (SDL_MUSTLOCK(surface))
+ {
+ SDL_UnlockSurface(surface);
+ }
+}
+
+void sge_PutPixelRGB(SDL_Surface *surface, Sint16 x, Sint16 y,
+ Uint8 R, Uint8 G, Uint8 B)
+{
+ sge_PutPixel(surface, x, y, SDL_MapRGB(surface->format, R, G, B));
+}
+
+Sint32 sge_CalcYPitch(SDL_Surface *dest, Sint16 y)
+{
+ if (y >= 0 && y <= dest->h - 1)
+ {
+ switch (dest->format->BytesPerPixel)
+ {
+ case 1:
+ return y*dest->pitch;
+ break;
+
+ case 2:
+ return y*dest->pitch/2;
+ break;
+
+ case 3:
+ return y*dest->pitch;
+ break;
+
+ case 4:
+ return y*dest->pitch/4;
+ break;
+ }
+ }
+
+ return -1;
+}
+
+void sge_pPutPixel(SDL_Surface *surface, Sint16 x, Sint32 ypitch, Uint32 color)
+{
+ if (x >= 0 && x <= surface->w - 1 && ypitch >= 0)
+ {
+ switch (surface->format->BytesPerPixel)
+ {
+ case 1:
+ {
+ /* Assuming 8-bpp */
+ *((Uint8 *)surface->pixels + ypitch + x) = color;
+ }
+ break;
+
+ case 2:
+ {
+ /* Probably 15-bpp or 16-bpp */
+ *((Uint16 *)surface->pixels + ypitch + x) = color;
+ }
+ break;
+
+ case 3:
+ {
+ /* Slow 24-bpp mode, usually not used */
+ Uint8 *pix;
+ int shift;
+
+ /* Gack - slow, but endian correct */
+ pix = (Uint8 *)surface->pixels + ypitch + x*3;
+ shift = surface->format->Rshift;
+ *(pix+shift/8) = color>>shift;
+ shift = surface->format->Gshift;
+ *(pix+shift/8) = color>>shift;
+ shift = surface->format->Bshift;
+ *(pix+shift/8) = color>>shift;
+ }
+ break;
+
+ case 4:
+ {
+ /* Probably 32-bpp */
+ *((Uint32 *)surface->pixels + ypitch + x) = color;
+ }
+ break;
+ }
+ }
+}
+
+void sge_HLine(SDL_Surface *Surface, Sint16 x1, Sint16 x2, Sint16 y,
+ Uint32 Color)
+{
+ SDL_Rect l;
+
+ if (SDL_MUSTLOCK(Surface))
+ {
+ if (SDL_LockSurface(Surface) < 0)
+ {
+ return;
+ }
+ }
+
+ if (x1 > x2)
+ {
+ Sint16 tmp = x1;
+ x1 = x2;
+ x2 = tmp;
+ }
+
+ /* Do the clipping */
+ if (y < 0 || y > Surface->h - 1 || x1 > Surface->w - 1 || x2 < 0)
+ return;
+ if (x1 < 0)
+ x1 = 0;
+ if (x2 > Surface->w - 1)
+ x2 = Surface->w - 1;
+
+ l.x = x1;
+ l.y = y;
+ l.w = x2 - x1 + 1;
+ l.h = 1;
+
+ SDL_FillRect(Surface, &l, Color);
+
+ if (SDL_MUSTLOCK(Surface))
+ {
+ SDL_UnlockSurface(Surface);
+ }
+}
+
+void sge_HLineRGB(SDL_Surface *Surface, Sint16 x1, Sint16 x2, Sint16 y,
+ Uint8 R, Uint8 G, Uint8 B)
+{
+ sge_HLine(Surface, x1, x2, y, SDL_MapRGB(Surface->format, R, G, B));
+}
+
+void _HLine(SDL_Surface *Surface, Sint16 x1, Sint16 x2, Sint16 y, Uint32 Color)
+{
+ SDL_Rect l;
+
+ if (x1 > x2)
+ {
+ Sint16 tmp = x1;
+ x1 = x2;
+ x2 = tmp;
+ }
+
+ /* Do the clipping */
+ if (y < 0 || y > Surface->h - 1 || x1 > Surface->w - 1 || x2 < 0)
+ return;
+ if (x1 < 0)
+ x1 = 0;
+ if (x2 > Surface->w - 1)
+ x2 = Surface->w - 1;
+
+ l.x = x1;
+ l.y = y;
+ l.w = x2 - x1 + 1;
+ l.h = 1;
+
+ SDL_FillRect(Surface, &l, Color);
+}
+
+void sge_VLine(SDL_Surface *Surface, Sint16 x, Sint16 y1, Sint16 y2,
+ Uint32 Color)
+{
+ SDL_Rect l;
+
+ if (SDL_MUSTLOCK(Surface))
+ {
+ if (SDL_LockSurface(Surface) < 0)
+ {
+ return;
+ }
+ }
+
+ if (y1 > y2)
+ {
+ Sint16 tmp = y1;
+ y1 = y2;
+ y2 = tmp;
+ }
+
+ /* Do the clipping */
+ if (x < 0 || x > Surface->w - 1 || y1 > Surface->h - 1 || y2 < 0)
+ return;
+ if (y1 < 0)
+ y1 = 0;
+ if (y2 > Surface->h - 1)
+ y2 = Surface->h - 1;
+
+ l.x = x;
+ l.y = y1;
+ l.w = 1;
+ l.h = y2 - y1 + 1;
+
+ SDL_FillRect(Surface, &l, Color);
+
+ if (SDL_MUSTLOCK(Surface))
+ {
+ SDL_UnlockSurface(Surface);
+ }
+}
+
+void sge_VLineRGB(SDL_Surface *Surface, Sint16 x, Sint16 y1, Sint16 y2,
+ Uint8 R, Uint8 G, Uint8 B)
+{
+ sge_VLine(Surface, x, y1, y2, SDL_MapRGB(Surface->format, R, G, B));
+}
+
+void _VLine(SDL_Surface *Surface, Sint16 x, Sint16 y1, Sint16 y2, Uint32 Color)
+{
+ SDL_Rect l;
+
+ if (y1 > y2)
+ {
+ Sint16 tmp = y1;
+ y1 = y2;
+ y2 = tmp;
+ }
+
+ /* Do the clipping */
+ if (x < 0 || x > Surface->w - 1 || y1 > Surface->h - 1 || y2 < 0)
+ return;
+ if (y1 < 0)
+ y1 = 0;
+ if (y2 > Surface->h - 1)
+ y2 = Surface->h - 1;
+
+ l.x = x;
+ l.y = y1;
+ l.w = 1;
+ l.h = y2 - y1 + 1;
+
+ SDL_FillRect(Surface, &l, Color);
+}
+
+void sge_DoLine(SDL_Surface *Surface, Sint16 x1, Sint16 y1,
+ Sint16 x2, Sint16 y2, Uint32 Color,
+ void Callback(SDL_Surface *Surf, Sint16 X, Sint16 Y,
+ Uint32 Color))
+{
+ Sint16 dx, dy, sdx, sdy, x, y, px, py;
+
+ dx = x2 - x1;
+ dy = y2 - y1;
+
+ sdx = (dx < 0) ? -1 : 1;
+ sdy = (dy < 0) ? -1 : 1;
+
+ dx = sdx * dx + 1;
+ dy = sdy * dy + 1;
+
+ x = y = 0;
+
+ px = x1;
+ py = y1;
+
+ if (dx >= dy)
+ {
+ for (x = 0; x < dx; x++)
+ {
+ Callback(Surface, px, py, Color);
+
+ y += dy;
+ if (y >= dx)
+ {
+ y -= dx;
+ py += sdy;
+ }
+
+ px += sdx;
+ }
+ }
+ else
+ {
+ for (y = 0; y < dy; y++)
+ {
+ Callback(Surface, px, py, Color);
+
+ x += dx;
+ if (x >= dy)
+ {
+ x -= dy;
+ px += sdx;
+ }
+
+ py += sdy;
+ }
+ }
+}
+
+void sge_DoLineRGB(SDL_Surface *Surface, Sint16 X1, Sint16 Y1,
+ Sint16 X2, Sint16 Y2, Uint8 R, Uint8 G, Uint8 B,
+ void Callback(SDL_Surface *Surf, Sint16 X, Sint16 Y,
+ Uint32 Color))
+{
+ sge_DoLine(Surface, X1, Y1, X2, Y2,
+ SDL_MapRGB(Surface->format, R, G, B), Callback);
+}
+
+void sge_Line(SDL_Surface *Surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
+ Uint32 Color)
+{
+ if (SDL_MUSTLOCK(Surface))
+ {
+ if (SDL_LockSurface(Surface) < 0)
+ return;
+ }
+
+ /* Draw the line */
+ sge_DoLine(Surface, x1, y1, x2, y2, Color, _PutPixel);
+
+ /* unlock the display */
+ if (SDL_MUSTLOCK(Surface))
+ {
+ SDL_UnlockSurface(Surface);
+ }
+}
+
+void sge_LineRGB(SDL_Surface *Surface, Sint16 x1, Sint16 y1, Sint16 x2,
+ Sint16 y2, Uint8 R, Uint8 G, Uint8 B)
+{
+ sge_Line(Surface, x1, y1, x2, y2, SDL_MapRGB(Surface->format, R, G, B));
+}
+
+
+/* ========================================================================= */
+/* audio functions */
+/* ========================================================================= */
+
inline boolean SDLOpenAudio(void)
{
if (SDL_Init(SDL_INIT_AUDIO) < 0)
typedef struct SDLSurfaceInfo *Bitmap;
typedef struct SDLSurfaceInfo *DrawBuffer;
typedef struct SDLSurfaceInfo *DrawWindow;
+typedef Uint32 Pixel;
typedef SDLKey Key;
GC stored_clip_gc;
};
+struct XY
+{
+ short x, y;
+};
+
/* SDL symbol definitions */
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 void SDLDrawLine(SDL_Surface *, int, int, int, int, Uint32);
+/* functions from SGE library */
+void sge_Line(SDL_Surface *, Sint16, Sint16, Sint16, Sint16, Uint32);
inline boolean SDLOpenAudio(void);
inline void SDLCloseAudio(void);
#else
Pixmap pixmap;
- if (!(pixmap = XCreatePixmap(display, window->drawable,
- width, height, real_depth)))
+ if ((pixmap = XCreatePixmap(display, window->drawable,
+ width, height, real_depth))
+ == None)
Error(ERR_EXIT, "cannot create pixmap");
+
new_bitmap->drawable = pixmap;
if (window == NULL)
Error(ERR_EXIT, "Window GC needed for Bitmap -- create Window first");
+
new_bitmap->gc = window->gc;
+ new_bitmap->line_gc[0] = window->line_gc[0];
+ new_bitmap->line_gc[1] = window->line_gc[1];
#endif
return new_bitmap;
#endif
}
+#if !defined(TARGET_X11_NATIVE)
+inline void DrawLine(Bitmap bitmap, int from_x, int from_y,
+ int to_x, int to_y, Pixel pixel, int line_width)
+{
+ int x, y;
+
+ for (x=0; x<line_width; x++)
+ {
+ for (y=0; y<line_width; y++)
+ {
+ int dx = x - line_width / 2;
+ int dy = y - line_width / 2;
+
+ if ((x == 0 && y == 0) ||
+ (x == 0 && y == line_width - 1) ||
+ (x == line_width - 1 && y == 0) ||
+ (x == line_width - 1 && y == line_width - 1))
+ continue;
+
+#if defined(TARGET_SDL)
+ sge_Line(bitmap->surface,
+ from_x + dx, from_y + dy, to_x + dx, to_y + dy, pixel);
+#elif defined(TARGET_ALLEGRO)
+ AllegroDrawLine(bitmap->drawable, from_x + dx, from_y + dy,
+ to_x + dx, to_y + dy, pixel);
+#endif
+ }
+ }
+}
+#endif
+
+inline void DrawLines(Bitmap bitmap, struct XY *points, int num_points,
+ Pixel pixel)
+{
+#if !defined(TARGET_X11_NATIVE)
+ int line_width = 4;
+ int i;
+
+ for (i=0; i<num_points - 1; i++)
+ DrawLine(bitmap, points[i].x, points[i].y,
+ points[i + 1].x, points[i + 1].y, pixel, line_width);
+
+ /*
+ SDLDrawLines(bitmap->surface, points, num_points, pixel);
+ */
+#else
+ XSetForeground(display, bitmap->line_gc[1], pixel);
+ XDrawLines(display, bitmap->drawable, bitmap->line_gc[1],
+ (XPoint *)points, num_points, CoordModeOrigin);
+ /*
+ XSetForeground(display, gc, BlackPixel(display, screen));
+ */
+#endif
+}
+
+inline Pixel GetPixelFromRGB(Bitmap bitmap, unsigned int color_r,
+ unsigned int color_g, unsigned int color_b)
+{
+ Pixel pixel;
+
+#if defined(TARGET_SDL)
+ pixel = SDL_MapRGB(bitmap->surface->format, color_r, color_g, color_b);
+#elif defined(TARGET_X11_NATIVE)
+ XColor xcolor;
+
+ xcolor.flags = DoRed | DoGreen | DoBlue;
+ xcolor.red = (color_r << 8);
+ xcolor.green = (color_g << 8);
+ xcolor.blue = (color_b << 8);
+ XAllocColor(display, cmap, &xcolor);
+ pixel = xcolor.pixel;
+#endif
+
+ return pixel;
+}
+
+inline Pixel GetPixelFromRGBcompact(Bitmap bitmap, unsigned int color)
+{
+ unsigned int color_r = (color >> 16) & 0xff;
+ unsigned int color_g = (color >> 8) & 0xff;
+ unsigned int color_b = (color >> 0) & 0xff;
+
+ return GetPixelFromRGB(bitmap, color_r, color_g, color_b);
+}
+
/* execute all pending screen drawing operations */
inline void FlushDisplay(void)
{
#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_MICROLABEL (1 << 8)
+#define REDRAW_FROM_BACKBUFFER (1 << 9)
#define REDRAW_DOOR_2 (REDRAW_VIDEO_1 | \
REDRAW_VIDEO_2 | \
REDRAW_VIDEO_3)
-#define REDRAW_DOOR_3 (1 << 9)
+#define REDRAW_DOOR_3 (1 << 10)
#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 REDRAW_FPS (1 << 11)
#define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2)
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 DrawLines(Bitmap, struct XY *, int, Pixel);
+inline Pixel GetPixelFromRGB(Bitmap, unsigned int, unsigned int, unsigned int);
+inline Pixel GetPixelFromRGBcompact(Bitmap, unsigned int);
+
inline void FlushDisplay(void);
inline void SyncDisplay(void);
inline void KeyboardAutoRepeatOn(void);
unsigned long pen_fg = WhitePixel(display,screen);
unsigned long pen_bg = BlackPixel(display,screen);
const int width = video.width, height = video.height;
+ int i;
#if 0
#if !defined(PLATFORM_MSDOS)
new_window->gc =
XCreateGC(display, new_window->drawable, gc_valuemask, &gc_values);
+ /* create GCs for line drawing (black and white) */
+ for(i=0; i<2; i++)
+ {
+ gc_values.graphics_exposures = False;
+ gc_values.foreground = (i ? pen_fg : pen_bg);
+ gc_values.background = pen_bg;
+ gc_values.line_width = 4;
+ gc_values.line_style = LineSolid;
+ gc_values.cap_style = CapRound;
+ gc_values.join_style = JoinRound;
+
+ gc_valuemask = GCGraphicsExposures | GCForeground | GCBackground |
+ GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle;
+ new_window->line_gc[i] =
+ XCreateGC(display, new_window->drawable, gc_valuemask, &gc_values);
+ }
+
return new_window;
}
typedef struct X11DrawableInfo *Bitmap;
typedef struct X11DrawableInfo *DrawWindow;
typedef struct X11DrawableInfo *DrawBuffer;
+/* "Pixel" is already defined in X11/Intrinsic.h */
typedef KeySym Key;
Drawable drawable;
Drawable clip_mask;
GC gc; /* GC for normal drawing (inheritated from 'window') */
+ GC line_gc[2]; /* GC for foreground and background line drawing */
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 */
};
+struct XY
+{
+ short x, y;
+};
+
/* X11 symbol definitions */
#include "events.h"
#include "joystick.h"
-#if 0
-#if defined(PLATFORM_MSDOS)
-#include <fcntl.h>
-#endif
-#endif
-
-#if 0
-DrawWindow window = None;
-DrawBuffer backbuffer;
-GC gc;
-#endif
-
-#if 0
-GC clip_gc[NUM_BITMAPS];
-#endif
GC tile_clip_gc;
Bitmap pix[NUM_BITMAPS];
-#if 0
-Bitmap pix_masked[NUM_BITMAPS];
-
-Bitmap tile_masked[NUM_TILES];
-
-Pixmap clipmask[NUM_BITMAPS];
-#endif
Pixmap tile_clipmask[NUM_TILES];
-
-#if 0
-DrawBuffer drawto;
-#endif
-
DrawBuffer drawto_field, fieldbuffer;
-#if 0
-Colormap cmap;
-#endif
-
-#if 0
-char *sound_device_name = AUDIO_DEVICE;
-#endif
int joystick_device = 0;
char *joystick_device_name[MAX_PLAYERS] =
DEV_JOYSTICK_3
};
-#if 0
-char *program_name = NULL;
-#endif
-
int game_status = MAINMENU;
boolean level_editor_test_game = FALSE;
boolean network_playing = FALSE;
-#if 0
-int button_status = MB_NOT_PRESSED;
-boolean motion_status = FALSE;
-#endif
-
int key_joystick_mapping = 0;
int global_joystick_status = JOYSTICK_STATUS;
int joystick_status = JOYSTICK_STATUS;
-#if 0
-boolean fullscreen_available = FULLSCREEN_STATUS;
-boolean fullscreen_enabled = FALSE;
-#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];
short MovPos[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
int ZX,ZY, ExitX,ExitY;
int AllPlayersGone;
-#if 0
-int FrameCounter;
-#endif
-
int TimeFrames, TimePlayed, TimeLeft;
boolean network_player_action_received = FALSE;
-#if 0
-struct LevelDirInfo *leveldir_first = NULL, *leveldir_current = NULL;
-#endif
struct LevelInfo level;
struct PlayerInfo stored_player[MAX_PLAYERS], *local_player = NULL;
struct HiScore highscore[MAX_SCORE_ENTRIES];
-#if 0
-struct SampleInfo Sound[NUM_SOUNDS];
-#endif
struct TapeInfo tape;
-
-#if 0
-struct OptionInfo options;
-#endif
-
struct SetupInfo setup;
struct GameInfo game;
-
-#if 0
-struct VideoSystemInfo video;
-struct AudioSystemInfo audio;
-#endif
-
struct GlobalInfo global;
/* data needed for playing sounds */
int num_element_info = sizeof(element_info)/sizeof(char *);
-
-#if 0
-
-/* +-----------------------------------------------------------------------+ */
-/* | SDL TEST STUFF | */
-/* +-----------------------------------------------------------------------+ */
-
-#if defined(TARGET_SDL)
-
-SDL_Surface *sdl_screen, *sdl_image_tmp, *sdl_image, *sdl_image_masked;
-SDL_Surface *sdl_image2_tmp, *sdl_image2, *sdl_image2_masked;
-
-void TEST_SDL_BLIT_RECT(int x, int y)
-{
- SDL_Rect rect_src, rect_dst;
-
- SDLCopyArea(pix_masked[PIX_HEROES], window,
- 8 * TILEX, 8 * TILEY, TILEX, TILEY, x, y);
- return;
-
- rect_src.x = 8 * TILEX;
- rect_src.y = 8 * TILEY;
- rect_src.w = TILEX;
- rect_src.h = TILEY;
-
- rect_dst.x = x;
- rect_dst.y = y;
- rect_dst.w = TILEX;
- rect_dst.h = TILEY;
-
- SDL_BlitSurface(sdl_image2_masked, &rect_src, sdl_screen, &rect_dst);
- SDL_UpdateRect(sdl_screen, x, y, TILEX, TILEY);
-}
-
-void TEST_SDL_INIT_DISPLAY()
-{
- SDL_Rect rect_src, rect_dst;
-
- if (SDL_Init(SDL_INIT_VIDEO) < 0)
- {
- fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
- exit(1);
- }
-
- /* automatically cleanup SDL stuff after exit() */
- atexit(SDL_Quit);
-
- if ((sdl_screen = SDL_SetVideoMode(WIN_XSIZE, WIN_YSIZE, 16, SDL_HWSURFACE))
- == NULL)
- {
- fprintf(stderr, "SDL_SetVideoMode() failed: %s\n", SDL_GetError());
- exit(1);
- }
-
- SDL_WM_SetCaption(WINDOW_TITLE_STRING, WINDOW_TITLE_STRING);
-
- if ((sdl_image_tmp = IMG_Load("graphics/RocksScreen.pcx")) == NULL)
- {
- fprintf(stderr, "IMG_Load() failed: %s\n", SDL_GetError());
- exit(1);
- }
-
- sdl_image = SDL_DisplayFormat(sdl_image_tmp);
-
- SDL_SetColorKey(sdl_image_tmp, SDL_SRCCOLORKEY,
- SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
- sdl_image_masked = SDL_DisplayFormat(sdl_image_tmp);
-
- SDL_FreeSurface(sdl_image_tmp);
-
- if ((sdl_image2_tmp = IMG_Load("graphics/RocksHeroes.pcx")) == NULL)
- {
- fprintf(stderr, "IMG_Load() failed: %s\n", SDL_GetError());
- exit(1);
- }
-
- sdl_image2 = SDL_DisplayFormat(sdl_image2_tmp);
- SDL_FreeSurface(sdl_image2_tmp);
-
- sdl_image2_masked = SDL_DisplayFormat(sdl_image2);
- SDL_SetColorKey(sdl_image2_masked, SDL_SRCCOLORKEY,
- SDL_MapRGB(sdl_image2_masked->format, 0x00, 0x00, 0x00));
-
- rect_src.x = 0;
- rect_src.y = 0;
- rect_src.w = sdl_image->w;
- rect_src.h = sdl_image->h;
-
- rect_dst.x = 0;
- rect_dst.y = 0;
- rect_dst.w = sdl_image->w;
- rect_dst.h = sdl_image->h;
-
- SDL_BlitSurface(sdl_image, &rect_src, sdl_screen, &rect_dst);
-
- /*
- SDL_UpdateRect(sdl_screen, 0, 0, WIN_XSIZE, WIN_YSIZE);
- */
- /*
- SDL_UpdateRect(sdl_screen, 0, 0, 0, 0);
- */
- SDL_Flip(sdl_screen);
-
- /*
- SDL_Delay(5000);
- */
-}
-
-void TEST_SDL_EVENT_LOOP()
-{
- int quit_loop = 0;
-
- SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
-
- /*
- while (!quit_loop && SDL_WaitEvent(&event) >=0)
- */
-
- while (!quit_loop)
- {
- SDL_Event event;
-
- if (SDL_PollEvent(&event))
- {
- /* hier werden die Ereignisse behandelt */
- switch(event.type)
- {
- case SDL_QUIT:
- {
- quit_loop = 1;
- break;
- }
-
- case SDL_MOUSEBUTTONDOWN:
- {
- int x = event.button.x;
- int y = event.button.y;
-
- SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE);
-
- TEST_SDL_BLIT_RECT(x, y);
-
- printf("SDL_MOUSEBUTTONDOWN(%d, %d)\n", x, y);
- break;
- }
-
- case SDL_MOUSEBUTTONUP:
- {
- int x = event.button.x;
- int y = event.button.y;
-
- SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
-
- printf("SDL_MOUSEBUTTONUP(%d, %d)\n", x, y);
- break;
- }
-
- case SDL_MOUSEMOTION:
- {
- int x = event.motion.x;
- int y = event.motion.y;
-
- TEST_SDL_BLIT_RECT(x, y);
-
- printf("SDL_MOUSEMOTION(%d, %d)\n", x, y);
- break;
- }
-
- default:
- break;
- }
- }
-
- if (!SDL_PollEvent(NULL)) /* delay only if no pending events */
- {
- printf("waiting...\n");
- Delay(100);
- }
- }
-
- SDL_FreeSurface(sdl_image);
- SDL_Quit();
-}
-
-#define SCREEN_WIDTH 640
-#define SCREEN_HEIGHT 480
-
-void WatchJoysticks()
-{
- SDL_Surface *screen;
- const char *name;
- int i, done;
- SDL_Event event;
- int x, y, draw;
- SDL_Rect axis_area[2];
- int joystick_nr = 0;
- SDL_Joystick *joystick = Get_SDL_Joystick(joystick_nr);
-
- /* Set a video mode to display joystick axis position */
- screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, 0);
- if ( screen == NULL ) {
- fprintf(stderr, "Couldn't set video mode: %s\n",SDL_GetError());
- return;
- }
-
- /* Print info about the joysticks we are watching */
- for (i=0; i<2; i++)
- {
- joystick = Get_SDL_Joystick(i);
-
- name = SDL_JoystickName(i);
- printf("Watching joystick %d: (%s)\n", i,
- name ? name : "Unknown Joystick");
- printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
- SDL_JoystickNumAxes(joystick),
- SDL_JoystickNumHats(joystick),
- SDL_JoystickNumBalls(joystick),
- SDL_JoystickNumButtons(joystick));
- }
-
- /* Initialize drawing rectangles */
- memset(axis_area, 0, (sizeof axis_area));
- draw = 0;
-
- /* Loop, getting joystick events! */
- done = 0;
- while ( ! done ) {
- while ( SDL_PollEvent(&event) ) {
- switch (event.type) {
- case SDL_JOYAXISMOTION:
- joystick_nr = event.jaxis.which;
- printf("Joystick %d axis %d value: %d\n",
- event.jaxis.which,
- event.jaxis.axis,
- event.jaxis.value);
- break;
- case SDL_JOYHATMOTION:
- joystick_nr = event.jaxis.which;
- printf("Joystick %d hat %d value:",
- event.jhat.which,
- event.jhat.hat);
- if ( event.jhat.value == SDL_HAT_CENTERED )
- printf(" centered");
- if ( event.jhat.value & SDL_HAT_UP )
- printf(" up");
- if ( event.jhat.value & SDL_HAT_RIGHT )
- printf(" right");
- if ( event.jhat.value & SDL_HAT_DOWN )
- printf(" down");
- if ( event.jhat.value & SDL_HAT_LEFT )
- printf(" left");
- printf("\n");
- break;
- case SDL_JOYBALLMOTION:
- joystick_nr = event.jaxis.which;
- printf("Joystick %d ball %d delta: (%d,%d)\n",
- event.jball.which,
- event.jball.ball,
- event.jball.xrel,
- event.jball.yrel);
- break;
- case SDL_JOYBUTTONDOWN:
- joystick_nr = event.jaxis.which;
- printf("Joystick %d button %d down\n",
- event.jbutton.which,
- event.jbutton.button);
- break;
- case SDL_JOYBUTTONUP:
- joystick_nr = event.jaxis.which;
- printf("Joystick %d button %d up\n",
- event.jbutton.which,
- event.jbutton.button);
- break;
- case SDL_KEYDOWN:
- if ( event.key.keysym.sym != SDLK_ESCAPE ) {
- break;
- }
- /* Fall through to signal quit */
- case SDL_QUIT:
- done = 1;
- break;
- default:
- break;
- }
- }
-
- joystick = Get_SDL_Joystick(joystick_nr);
-
- /* Update visual joystick state */
- for ( i=0; i<SDL_JoystickNumButtons(joystick); ++i ) {
- SDL_Rect area;
-
- area.x = i*34;
- area.y = SCREEN_HEIGHT-34;
- area.w = 32;
- area.h = 32;
- if (SDL_JoystickGetButton(joystick, i) == SDL_PRESSED) {
- SDL_FillRect(screen, &area, 0xFFFF);
- } else {
- SDL_FillRect(screen, &area, 0x0000);
- }
- SDL_UpdateRects(screen, 1, &area);
- }
-
- /* Erase previous axes */
- SDL_FillRect(screen, &axis_area[draw], 0x0000);
-
- /* Draw the X/Y axis */
- draw = !draw;
- x = (((int)SDL_JoystickGetAxis(joystick, 0))+32768);
- x *= SCREEN_WIDTH;
- x /= 65535;
- if ( x < 0 ) {
- x = 0;
- } else
- if ( x > (SCREEN_WIDTH-16) ) {
- x = SCREEN_WIDTH-16;
- }
- y = (((int)SDL_JoystickGetAxis(joystick, 1))+32768);
- y *= SCREEN_HEIGHT;
- y /= 65535;
- if ( y < 0 ) {
- y = 0;
- } else
- if ( y > (SCREEN_HEIGHT-16) ) {
- y = SCREEN_HEIGHT-16;
- }
- axis_area[draw].x = (Sint16)x;
- axis_area[draw].y = (Sint16)y;
- axis_area[draw].w = 16;
- axis_area[draw].h = 16;
- SDL_FillRect(screen, &axis_area[draw], 0xFFFF);
-
- SDL_UpdateRects(screen, 2, axis_area);
- }
-}
-
-void TEST_SDL_JOYSTICK()
-{
- const char *name;
- int i;
-
- /* Initialize SDL (Note: video is required to start event loop) */
- if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0 )
- {
- fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
- exit(1);
- }
-
- /* Print information about the joysticks */
- printf("There are %d joysticks attached\n", SDL_NumJoysticks());
- for ( i=0; i<SDL_NumJoysticks(); ++i )
- {
- name = SDL_JoystickName(i);
- printf("Joystick %d: %s\n",i,name ? name : "Unknown Joystick");
- }
-
- for (i=0; i<2; i++)
- {
- if (!Open_SDL_Joystick(i))
- printf("Couldn't open joystick %d: %s\n", i, SDL_GetError());
- }
-
- WatchJoysticks();
-
- for (i=0; i<2; i++)
- Close_SDL_Joystick(i);
-
- SDL_QuitSubSystem(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK);
-}
-
-#endif /* TARGET_SDL */
-
-/* +-----------------------------------------------------------------------+ */
-/* | SDL TEST STUFF | */
-/* +-----------------------------------------------------------------------+ */
-
-#endif
-
-
+/* ========================================================================= */
+/* main() */
+/* ========================================================================= */
int main(int argc, char *argv[])
{
-#if 0
- program_name = (strrchr(argv[0],'/') ? strrchr(argv[0],'/') + 1 : argv[0]);
-#endif
-
InitCommandName(argv[0]);
InitExitFunction(CloseAllAndExit);
InitPlatformDependantStuff();
-#if 0
-#if defined(PLATFORM_MSDOS)
- _fmode = O_BINARY;
-#endif
-#endif
-
-#if 1
GetOptions(argv);
OpenAll();
-#endif
-
-#if 0
-#ifdef TARGET_SDL
- /*
- TEST_SDL_BLIT_RECT((WIN_XSIZE - TILEX)/2, (WIN_YSIZE - TILEY)/2);
- TEST_SDL_EVENT_LOOP();
- */
- TEST_SDL_JOYSTICK();
- exit(0);
-#endif
-#endif
EventLoop();
CloseAllAndExit(0);
#include "libgame/libgame.h"
-#ifndef FALSE
-#define FALSE 0
-#define TRUE (!FALSE)
-#endif
-
#define WIN_XSIZE 672
#define WIN_YSIZE 560
#define WIN_SDL_DEPTH 16 /* !!! change this !!! */
#define MAX_PLAYERS 4
-#if 0
-#ifndef MIN
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#endif
-#ifndef MAX
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#endif
-#ifndef ABS
-#define ABS(a) ((a) < 0 ? -(a) : (a))
-#endif
-#ifndef SIGN
-#define SIGN(a) ((a) < 0 ? -1 : ((a)>0 ? 1 : 0))
-#endif
-#endif
-
#define SCREENX(a) ((a) - scroll_x)
#define SCREENY(a) ((a) - scroll_y)
#define LEVELX(a) ((a) + scroll_x)
#define GAME_FRAME_DELAY 20 /* frame delay in milliseconds */
#define FFWD_FRAME_DELAY 10 /* 200% speed for fast forward */
#define FRAMES_PER_SECOND (1000 / GAME_FRAME_DELAY)
-#if 0
-#define GADGET_FRAME_DELAY 150 /* delay between gadget actions */
-#endif
#define MICROLEVEL_SCROLL_DELAY 50 /* delay for scrolling micro level */
#define MICROLEVEL_LABEL_DELAY 250 /* delay for micro level label */
int fps_slowdown_factor;
};
-#if 0
-extern DrawWindow window;
-extern DrawBuffer backbuffer;
-extern GC gc;
-#endif
-
-#if 0
-extern GC clip_gc[];
-#endif
extern GC tile_clip_gc;
extern Bitmap pix[];
-#if 0
-extern Bitmap pix_masked[];
-
-extern Bitmap tile_masked[];
-
-extern Pixmap clipmask[];
-#endif
extern Pixmap tile_clipmask[];
-
-#if 0
-extern DrawBuffer drawto;
-#endif
extern DrawBuffer drawto_field, fieldbuffer;
-#if 0
-extern Colormap cmap;
-#endif
-
-#if 0
-extern char *sound_device_name;
-#endif
extern int joystick_device;
extern char *joystick_device_name[];
-#if 0
-extern char *program_name;
-#endif
-
extern int game_status;
extern boolean level_editor_test_game;
extern boolean network_playing;
-#if 0
-extern int button_status;
-extern boolean motion_status;
-#endif
-
extern int key_joystick_mapping;
extern int global_joystick_status, joystick_status;
-#if 0
-extern boolean fullscreen_available;
-extern boolean fullscreen_enabled;
-#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];
extern short MovPos[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
extern int ZX,ZY, ExitX,ExitY;
extern int AllPlayersGone;
-#if 0
-extern int FrameCounter;
-#endif
-
extern int TimeFrames, TimePlayed, TimeLeft;
extern boolean SiebAktiv;
extern int SiebCount;
extern boolean network_player_action_received;
-#if 0
-extern struct LevelDirInfo *leveldir_first, *leveldir_current;
-#endif
extern struct LevelInfo level;
extern struct PlayerInfo stored_player[], *local_player;
extern struct HiScore highscore[];
extern struct TapeInfo tape;
-#if 0
-extern struct SampleInfo Sound[];
-#endif
extern struct JoystickInfo joystick[];
-
-#if 0
-extern struct OptionInfo options;
-#endif
-
extern struct SetupInfo setup;
extern struct GameInfo game;
-
-#if 0
-extern struct VideoSystemInfo video;
-extern struct AudioSystemInfo audio;
-#endif
-
extern struct GlobalInfo global;
extern char *sound_name[];
#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 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
-#endif
-
#define GFX_STARTX SX
#define GFX_STARTY SY
#define MINI_GFX_STARTX SX
#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
** 500 - 699: flag elements, only used at runtime
#define MV_UP (1 << 2)
#define MV_DOWN (1 << 3)
-#if 0
-/* 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
-#endif
-
/* values for game_status */
#define EXITGAME 0
#define MAINMENU 1
#define SETUPINPUT 9
#define CALIBRATION 10
-#if 0
-#ifndef RO_GAME_DIR
-#define RO_GAME_DIR "."
-#endif
-
-#ifndef RW_GAME_DIR
-#define RW_GAME_DIR "."
-#endif
-
-#define RO_BASE_PATH RO_GAME_DIR
-#define RW_BASE_PATH RW_GAME_DIR
-
-#define GRAPHICS_DIRECTORY "graphics"
-#define SOUNDS_DIRECTORY "sounds"
-#define LEVELS_DIRECTORY "levels"
-#define TAPES_DIRECTORY "tapes"
-#define SCORES_DIRECTORY "scores"
-#endif
-
#define PROGRAM_VERSION_STRING "1.5.0"
#define PROGRAM_TITLE_STRING "Rocks'n'Diamonds"
#define PROGRAM_AUTHOR_STRING "Holger Schemel"
#define X11_ICONMASK_FILENAME "rocks_iconmask.xbm"
#define MSDOS_POINTER_FILENAME "mouse.pcx"
-#if 0
-/* default name for empty highscore entry */
-#define EMPTY_PLAYER_NAME "no name"
-
-/* default name for unknown player names */
-#define ANONYMOUS_NAME "anonymous"
-
-/* default name for new levels */
-#define NAMELESS_LEVEL_NAME "nameless level"
-#endif
-
-#if 0
-/* values for button_status */
-#define MB_NOT_PRESSED FALSE
-#define MB_RELEASED FALSE
-#define MB_PRESSED TRUE
-#define MB_MENU_CHOICE FALSE
-#define MB_MENU_MARK TRUE
-#define MB_MENU_INITIALIZE (-1)
-#define MB_LEFTBUTTON 1
-#define MB_MIDDLEBUTTON 2
-#define MB_RIGHTBUTTON 3
-#endif
-
-#if 0
-/* 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)
-#endif
-
-#if 0
-/* areas in bitmap PIX_DOOR */
-/* meaning in PIX_DB_DOOR: (3 PAGEs)
- PAGEX1: 1. buffer for DOOR_1
- PAGEX2: 2. buffer for DOOR_1
- PAGEX3: buffer for animations
-*/
-
-#define DOOR_GFX_PAGESIZE DXSIZE
-#define DOOR_GFX_PAGEX1 (0 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX2 (1 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX3 (2 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX4 (3 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX5 (4 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX6 (5 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX7 (6 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX8 (7 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEY1 0
-#define DOOR_GFX_PAGEY2 DYSIZE
-#endif
-
/* for DrawGraphicAnimation() [tools.c] and AnimateToon() [cartoons.c] */
#define ANIM_NORMAL 0
#define ANIM_OSCILLATE 1
redraw_mask |= REDRAW_FIELD;
}
-
-#if 0
-int getFontWidth(int font_size, int font_type)
-{
- return (font_size == FS_BIG ? FONT1_XSIZE :
- font_size == FS_MEDIUM ? FONT6_XSIZE :
- font_type == FC_SPECIAL1 ? FONT3_XSIZE :
- font_type == FC_SPECIAL2 ? FONT4_XSIZE :
- font_type == FC_SPECIAL3 ? FONT5_XSIZE :
- FONT2_XSIZE);
-}
-
-int getFontHeight(int font_size, int font_type)
-{
- return (font_size == FS_BIG ? FONT1_YSIZE :
- font_size == FS_MEDIUM ? FONT6_YSIZE :
- font_type == FC_SPECIAL1 ? FONT3_YSIZE :
- font_type == FC_SPECIAL2 ? FONT4_YSIZE :
- font_type == FC_SPECIAL3 ? FONT5_YSIZE :
- FONT2_YSIZE);
-}
-
-void DrawInitText(char *text, int ypos, int color)
-{
- if (window && pix[PIX_SMALLFONT])
- {
- ClearRectangle(window, 0, ypos, WIN_XSIZE, FONT2_YSIZE);
- DrawTextExt(window, (WIN_XSIZE - 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];
- int font_width = getFontWidth(FS_SMALL, font_type);
- va_list ap;
-
- va_start(ap, format);
- vsprintf(buffer, format, ap);
- va_end(ap);
-
- DrawText(SX + (SXSIZE - strlen(buffer) * font_width) / 2, 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];
- va_list ap;
-
- va_start(ap, format);
- vsprintf(buffer, format, ap);
- va_end(ap);
-
- DrawText(SX + x, 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);
-
- if (x < DX)
- redraw_mask |= REDRAW_FIELD;
- else if (y < VY)
- redraw_mask |= REDRAW_DOOR_1;
-}
-
-void DrawTextExt(DrawBuffer d, GC gc, int x, int y,
- char *text, int font_size, int font_type)
-{
- 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_size = FS_SMALL;
- if (font_type < FC_RED || font_type > FC_SPECIAL3)
- font_type = FC_RED;
-
- 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_start = (font_type * (font_size == FS_BIG ? FONT1_YSIZE :
- font_size == FS_MEDIUM ? FONT6_YSIZE :
- FONT2_YSIZE) *
- FONT_LINES_PER_FONT);
-
- if (font_type == FC_SPECIAL3)
- font_start += (FONT4_YSIZE - FONT2_YSIZE) * FONT_LINES_PER_FONT;
-
- while (*text)
- {
- char c = *text++;
-
- if (c == '~' && font_size == FS_SMALL)
- {
- print_inverse = TRUE;
- continue;
- }
-
- if (c >= 'a' && c <= 'z')
- c = 'A' + (c - 'a');
- else if (c == 'ä' || c == 'Ä')
- c = 91;
- else if (c == 'ö' || c == 'Ö')
- c = 92;
- else if (c == 'ü' || c == 'Ü')
- c = 93;
-
- if (c >= 32 && c <= 95)
- {
- int src_x = ((c - 32) % FONT_CHARS_PER_LINE) * font_width;
- int src_y = ((c - 32) / FONT_CHARS_PER_LINE) * font_height + font_start;
- int dest_x = x, dest_y = y;
-
- if (print_inverse)
- {
- BlitBitmap(pix[font_bitmap], d,
- 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,
- 0, 0, font_width, font_height, dest_x, dest_y);
- }
- else
- BlitBitmap(pix[font_bitmap], d,
- src_x, src_y, font_width, font_height, dest_x, dest_y);
- }
-
- x += font_width;
- }
-}
-#endif
-
-
void MarkTileDirty(int x, int y)
{
int xx = redraw_x1 + x;
void FadeToFront();
void ClearWindow();
-#if 0
-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);
-#endif
-
void MarkTileDirty(int, int);
void SetBorderElement();