SRC_DIR = src
MAKE_CMD = $(MAKE) -C $(SRC_DIR)
-DEFAULT_TARGET = x11
-# DEFAULT_TARGET = sdl
+# DEFAULT_TARGET = x11
+DEFAULT_TARGET = sdl
all:
@$(MAKE_CMD) TARGET=$(DEFAULT_TARGET)
-#define COMPILE_DATE_STRING "[2003-04-03 21:08]"
+#define COMPILE_DATE_STRING "[2003-04-03 23:55]"
else
{
DrawTextExt(drawto, DX + XX_EMERALDS, DY + YY_EMERALDS,
- int2str(level_nr, 3), FONT_LEVEL_NUMBER, FONT_OPAQUE);
+ int2str(level_nr, 3), FONT_LEVEL_NUMBER, BLIT_OPAQUE);
BlitBitmap(drawto, drawto,
DX + XX_EMERALDS, DY + YY_EMERALDS + 1,
getFontWidth(FONT_LEVEL_NUMBER) * 3,
/* gadget text value */
DrawTextExt(drawto,
gi->x + border, gi->y + border, text,
- font_type, FONT_MASKED);
+ font_type, BLIT_MASKED);
cursor_letter = gi->text.value[gi->text.cursor_position];
cursor_string[0] = '~';
DrawTextExt(drawto,
gi->x + border + gi->text.cursor_position * font_width,
gi->y + border, cursor_string,
- font_type, FONT_MASKED);
+ font_type, BLIT_MASKED);
}
break;
/* gadget text value */
DrawTextExt(drawto, gi->x + border, gi->y + border, text,
- font_type, FONT_MASKED);
+ font_type, BLIT_MASKED);
if (pressed)
{
{
if (i == gi->selectbox.current_index)
{
- DrawRectangle(drawto,
+ FillRectangle(drawto,
gi->selectbox.x + border,
gi->selectbox.y + border + i * font_height,
gi->selectbox.width - 2 * border, font_height,
DrawTextExt(drawto,
gi->selectbox.x + border,
gi->selectbox.y + border + i * font_height, text,
- font_type, FONT_MASKED);
+ font_type, BLIT_MASKED);
}
redraw_selectbox = TRUE;
if (!getFontChar(font_nr, '|', &src_x, &src_y))
Error(ERR_EXIT, "selectbox gadget incomplete (cannot get cursor)");
+ src_x += font_width / 2;
+ src_y += font_height / 2;
gi->selectbox.reverse_color = GetPixel(font->bitmap, src_x, src_y);
/* always start with closed selectbox */
if (last_x != gi->event.x || last_y != gi->event.y)
changed_position = TRUE;
}
+ else if (gi->type & GD_TYPE_SELECTBOX)
+ {
+ int old_index = gi->selectbox.current_index;
+
+ /* if mouse moving inside activated selectbox, select value */
+ if (my >= gi->selectbox.y && my < gi->selectbox.y + gi->selectbox.height)
+ gi->selectbox.current_index =
+ (my - gi->selectbox.y - gi->border.size) /
+ getFontWidth(gi->selectbox.font_type);
+
+ if (gi->selectbox.current_index < 0)
+ gi->selectbox.current_index = 0;
+ else if (gi->selectbox.current_index > gi->selectbox.num_values - 1)
+ gi->selectbox.current_index = gi->selectbox.num_values - 1;
+
+ if (gi->selectbox.current_index != old_index)
+ DrawGadget(gi, DG_PRESSED, DG_DIRECT);
+ }
}
/* handle gadget popup info text */
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 copy_mode)
+ int dst_x, int dst_y, int mask_mode)
{
Bitmap *real_dst_bitmap = (dst_bitmap == window ? backbuffer : dst_bitmap);
SDL_Rect src_rect, dst_rect;
dst_rect.h = height;
if (src_bitmap != backbuffer || dst_bitmap != window)
- SDL_BlitSurface((copy_mode == SDLCOPYAREA_MASKED ?
+ SDL_BlitSurface((mask_mode == BLIT_MASKED ?
src_bitmap->surface_masked : src_bitmap->surface),
&src_rect, real_dst_bitmap->surface, &dst_rect);
}
inline void SDLFillRectangle(Bitmap *dst_bitmap, int x, int y,
- int width, int height, unsigned int color)
+ int width, int height, Uint32 color)
{
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;
- unsigned int color_b = (color >> 0) && 0xff;
+#if 0
+ unsigned int color_r = (color >> 16) & 0xff;
+ unsigned int color_g = (color >> 8) & 0xff;
+ unsigned int color_b = (color >> 0) & 0xff;
+#endif
#ifdef FULLSCREEN_BUG
if (dst_bitmap == backbuffer || dst_bitmap == window)
rect.w = width;
rect.h = height;
+#if 1
+ SDL_FillRect(real_dst_bitmap->surface, &rect, color);
+#else
SDL_FillRect(real_dst_bitmap->surface, &rect,
SDL_MapRGB(real_dst_bitmap->surface->format,
color_r, color_g, color_b));
+#endif
if (dst_bitmap == window)
SDL_UpdateRect(backbuffer->surface, x, y, width, height);
}
inline void SDLDrawSimpleLine(Bitmap *dst_bitmap, int from_x, int from_y,
- int to_x, int to_y, unsigned int color)
+ int to_x, int to_y, Uint32 color)
{
SDL_Surface *surface = dst_bitmap->surface;
SDL_Rect rect;
+#if 0
unsigned int color_r = (color >> 16) & 0xff;
unsigned int color_g = (color >> 8) & 0xff;
unsigned int color_b = (color >> 0) & 0xff;
+#endif
if (from_x > to_x)
swap_numbers(&from_x, &to_x);
}
#endif
+#if 1
+ SDL_FillRect(surface, &rect, color);
+#else
SDL_FillRect(surface, &rect,
SDL_MapRGB(surface->format, color_r, color_g, color_b));
+#endif
}
inline void SDLDrawLine(Bitmap *dst_bitmap, int from_x, int from_y,
#define SURFACE_FLAGS (SDL_SWSURFACE)
-#define SDLCOPYAREA_OPAQUE 0
-#define SDLCOPYAREA_MASKED 1
-
/* system dependent definitions */
#define TARGET_STRING "SDL"
#define None 0L
+#define BlackPixel(d, s) 0x000000
+#define WhitePixel(d, s) 0xffffff
+
#define EVENT_BUTTONPRESS SDL_MOUSEBUTTONDOWN
#define EVENT_BUTTONRELEASE SDL_MOUSEBUTTONUP
#define EVENT_MOTIONNOTIFY SDL_MOUSEMOTION
inline void SDLInitVideoBuffer(DrawBuffer **, DrawWindow **, boolean);
inline boolean SDLSetVideoMode(DrawBuffer **, boolean);
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(Bitmap *, int, int, int, int, unsigned int);
+inline void SDLFillRectangle(Bitmap *, int, int, int, int, Uint32);
+inline void SDLDrawSimpleLine(Bitmap *, int, int, int, int, Uint32);
inline void SDLDrawLine(Bitmap *, int, int, int, int, Uint32);
inline Pixel SDLGetPixel(Bitmap *, int, int);
return (depth == DEFAULT_DEPTH ? video.default_depth : depth);
}
+inline static void sysFillRectangle(Bitmap *bitmap, int x, int y,
+ int width, int height, Pixel color)
+{
+#ifdef TARGET_SDL
+ SDLFillRectangle(bitmap, x, y, width, height, color);
+#else
+ X11FillRectangle(bitmap, x, y, width, height, color);
+#endif
+}
+
+inline static void sysCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap,
+ int src_x, int src_y, int width, int height,
+ int dst_x, int dst_y, int mask_mode)
+{
+#ifdef TARGET_SDL
+ SDLCopyArea(src_bitmap, dst_bitmap,
+ src_x, src_y, width, height, dst_x, dst_y, mask_mode);
+#else
+ X11CopyArea(src_bitmap, dst_bitmap,
+ src_x, src_y, width, height, dst_x, dst_y, mask_mode);
+#endif
+}
+
inline void InitVideoDisplay(void)
{
#if defined(TARGET_SDL)
}
inline void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap,
- int src_x, int src_y,
- int width, int height,
+ int src_x, int src_y, int width, int height,
int dst_x, int dst_y)
{
if (DrawingDeactivated(dst_x, dst_y, width, height))
return;
-#ifdef TARGET_SDL
- SDLCopyArea(src_bitmap, dst_bitmap,
- 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
+ sysCopyArea(src_bitmap, dst_bitmap, src_x, src_y, width, height,
+ dst_x, dst_y, BLIT_OPAQUE);
}
-inline void DrawRectangle(Bitmap *bitmap, int x, int y, int width, int height,
+inline void FillRectangle(Bitmap *bitmap, int x, int y, int width, int height,
Pixel color)
{
if (DrawingDeactivated(x, y, width, height))
return;
-#ifdef TARGET_SDL
- SDLFillRectangle(bitmap, x, y, width, height, color);
-#else
- XSetForeground(display, bitmap->gc, color);
- XFillRectangle(display, bitmap->drawable, bitmap->gc, x, y, width, height);
- XSetForeground(display, bitmap->gc, BlackPixel(display, screen));
-#endif
+ sysFillRectangle(bitmap, x, y, width, height, color);
}
-#if 1
-inline void ClearRectangle(Bitmap *bitmap, int x, int y, int width, int height)
-{
-#ifdef TARGET_SDL
- DrawRectangle(bitmap, x, y, width, height, 0x000000);
-#else
- DrawRectangle(bitmap, x, y, width, height, 0x000000);
-#endif
-}
-#else
inline void ClearRectangle(Bitmap *bitmap, int x, int y, int width, int height)
{
- if (DrawingDeactivated(x, y, width, height))
- return;
-
-#ifdef TARGET_SDL
- SDLFillRectangle(bitmap, x, y, width, height, 0x000000);
-#else
- XFillRectangle(display, bitmap->drawable, bitmap->gc, x, y, width, height);
-#endif
+ FillRectangle(bitmap, x, y, width, height, BlackPixel(display, screen));
}
-#endif
inline void ClearRectangleOnBackground(Bitmap *bitmap, int x, int y,
int width, int height)
if (DrawingDeactivated(dst_x, dst_y, width, height))
return;
-#ifdef TARGET_SDL
- SDLCopyArea(src_bitmap, dst_bitmap,
- src_x, src_y, width, height, dst_x, dst_y, SDLCOPYAREA_MASKED);
-#else
- XCopyArea(display, src_bitmap->drawable, dst_bitmap->drawable,
- src_bitmap->clip_gc, src_x, src_y, width, height, dst_x, dst_y);
-#endif
+ sysCopyArea(src_bitmap, dst_bitmap, src_x, src_y, width, height,
+ dst_x, dst_y, BLIT_MASKED);
}
inline void BlitBitmapOnBackground(Bitmap *src_bitmap, Bitmap *dst_bitmap,
#else
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
}
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
}
#elif defined(TARGET_ALLEGRO)
return AllegroGetPixel(bitmap->drawable, x, y);
#else
- unsigned long pixel_value;
- XImage *pixel_image;
-
- pixel_image = XGetImage(display, bitmap->drawable, x, y, 1, 1,
- AllPlanes, ZPixmap);
- pixel_value = XGetPixel(pixel_image, 0, 0);
-
- XDestroyImage(pixel_image);
-
- return pixel_value;
+ return X11GetPixel(bitmap, x, y);
#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);
+ return SDL_MapRGB(bitmap->surface->format, color_r, color_g, color_b);
#elif defined(TARGET_ALLEGRO)
- pixel = AllegroAllocColorCell(color_r << 8, color_g << 8, color_b << 8);
-#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;
+ return AllegroAllocColorCell(color_r << 8, color_g << 8, color_b << 8);
+#else
+ return X11GetPixelFromRGB(color_r, color_g, color_b);
#endif
-
- return pixel;
}
inline Pixel GetPixelFromRGBcompact(Bitmap *bitmap, unsigned int color)
#define DEFAULT_DEPTH 0
+#define BLIT_OPAQUE 0
+#define BLIT_MASKED 1
+
#define FULLSCREEN_NOT_AVAILABLE FALSE
#define FULLSCREEN_AVAILABLE TRUE
inline Bitmap *CreateBitmap(int, int, int);
inline void FreeBitmap(Bitmap *);
inline void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
-inline void DrawRectangle(Bitmap *, int, int, int, int, Pixel);
+inline void FillRectangle(Bitmap *, int, int, int, int, Pixel);
inline void ClearRectangle(Bitmap *, int, int, int, int);
inline void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
inline void SetClipMask(Bitmap *, GC, Pixmap);
ClearRectangle(window, 0, ypos, video.width, getFontHeight(font_nr));
DrawTextExt(window, (video.width - text_width) / 2, ypos, text, font_nr,
- FONT_OPAQUE);
+ BLIT_OPAQUE);
FlushDisplay();
}
}
void DrawText(int x, int y, char *text, int font_nr)
{
- int mask_mode = FONT_OPAQUE;
+ int mask_mode = BLIT_OPAQUE;
if (DrawingOnBackground(x, y))
- mask_mode = FONT_MASKED;
+ mask_mode = BLIT_MASKED;
DrawTextExt(drawto, x, y, text, font_nr, mask_mode);
else if (c == '\\') /* bad luck ... */
c = '/';
-#if 1
if (getFontChar(font_nr, c, &src_x, &src_y))
{
-#else
- if ((c >= 32 && c <= 95) || c == '°' || c == '´' || c == '|')
- {
- int src_x= font->src_x + ((c - 32) % FONT_CHARS_PER_LINE) * font->width;
- int src_y= font->src_y + ((c - 32) / FONT_CHARS_PER_LINE) * font->height;
-
- if (c == '°' || c == '´' || c == '|') /* map '°' and 'TM' signs */
- {
- src_x = font->src_x + FONT_CHARS_PER_LINE * font->width;
- src_y = font->src_y + (c == '°' ? 1 : c == '´' ? 2 : 3) * font->height;
- }
-#endif
-
if (print_inverse) /* special mode for text gadgets */
{
/* first step: draw solid colored rectangle (use "cursor" character) */
BlitBitmapMasked(font->bitmap, dst_bitmap,
0, 0, font->width, font->height, dst_x, dst_y);
}
- else if (mask_mode == FONT_MASKED)
+ else if (mask_mode == BLIT_MASKED)
{
/* clear font character background */
ClearRectangleOnBackground(dst_bitmap, dst_x, dst_y,
#define FONT_CHARS_PER_LINE 16
#define FONT_LINES_PER_FONT 4
-#define FONT_OPAQUE 0
-#define FONT_MASKED 1
-
/* text output definitions */
#define MAX_OUTPUT_LINESIZE 1024
return new_bitmap;
}
+inline void X11CopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap,
+ int src_x, int src_y, int width, int height,
+ int dst_x, int dst_y, int mask_mode)
+{
+ XCopyArea(display, src_bitmap->drawable, dst_bitmap->drawable,
+ (mask_mode == BLIT_MASKED ? src_bitmap->clip_gc : dst_bitmap->gc),
+ src_x, src_y, width, height, dst_x, dst_y);
+}
+
+inline void X11FillRectangle(Bitmap *bitmap, int x, int y,
+ int width, int height, Pixel color)
+{
+ XSetForeground(display, bitmap->gc, color);
+ XFillRectangle(display, bitmap->drawable, bitmap->gc, x, y, width, height);
+}
+
+inline Pixel X11GetPixel(Bitmap *bitmap, int x, int y)
+{
+ unsigned long pixel_value;
+ XImage *pixel_image;
+
+ pixel_image = XGetImage(display, bitmap->drawable, x, y, 1, 1,
+ AllPlanes, ZPixmap);
+ pixel_value = XGetPixel(pixel_image, 0, 0);
+
+ XDestroyImage(pixel_image);
+
+ return pixel_value;
+}
+
+inline Pixel X11GetPixelFromRGB(unsigned int color_r, unsigned int color_g,
+ unsigned int color_b)
+{
+ XColor xcolor;
+ Pixel pixel;
+
+ 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;
+
+ return pixel;
+}
+
#endif /* TARGET_X11 */
inline void X11InitVideoBuffer(DrawBuffer **, DrawWindow **);
void X11ZoomBitmap(Bitmap *, Bitmap *);
-
Bitmap *X11LoadImage(char *);
+inline void X11CopyArea(Bitmap *, Bitmap *, int, int, int, int, int, int, int);
+inline void X11FillRectangle(Bitmap *, int, int, int, int, Pixel);
+inline Pixel X11GetPixel(Bitmap *, int, int);
+inline Pixel X11GetPixelFromRGB(unsigned int, unsigned int, unsigned int);
+
#endif /* X11_H */
info1[0] = '\0';
sprintf(text, "%.1f fps%s", global.frames_per_second, info1);
- DrawTextExt(window, SX, SY, text, FONT_TEXT_2, FONT_OPAQUE);
+ DrawTextExt(window, SX, SY, text, FONT_TEXT_2, BLIT_OPAQUE);
}
FlushDisplay();