/***********************************************************
-* Rocks'n'Diamonds -- McDuffin Strikes Back! *
+* Rocks'n'Diamonds -- McDuffin Strikes Back! *
*----------------------------------------------------------*
-* (c) 1995-98 Artsoft Entertainment *
-* Holger Schemel *
-* Oststrasse 11a *
-* 33604 Bielefeld *
-* phone: ++49 +521 290471 *
-* email: aeglos@valinor.owl.de *
+* (c) 1995-2001 Artsoft Entertainment *
+* Holger Schemel *
+* Detmolder Strasse 189 *
+* 33604 Bielefeld *
+* Germany *
+* e-mail: info@artsoft.org *
*----------------------------------------------------------*
-* tools.c *
+* tools.c *
***********************************************************/
-#include <stdarg.h>
-
-#ifdef __FreeBSD__
-#include <machine/joystick.h>
-#endif
+#include "libgame/libgame.h"
#include "tools.h"
#include "game.h"
#include "events.h"
-#include "sound.h"
-#include "misc.h"
-#include "buttons.h"
-#include "joystick.h"
#include "cartoons.h"
#include "network.h"
+#include "tape.h"
-#ifdef MSDOS
+#if defined(PLATFORM_MSDOS)
extern boolean wait_for_vsync;
#endif
}
}
+void RedrawPlayfield(boolean force_redraw, int x, int y, int width, int height)
+{
+ if (game_status == PLAYING)
+ {
+ if (force_redraw)
+ {
+ x = gfx.sx - TILEX;
+ y = gfx.sy - TILEY;
+ width = gfx.sxsize + 2 * TILEX;
+ height = gfx.sysize + 2 * TILEY;
+ }
+
+ if (force_redraw || setup.direct_draw)
+ {
+ int xx, yy;
+ int x1 = (x - SX) / TILEX, y1 = (y - SY) / TILEY;
+ int x2 = (x - SX + width) / TILEX, y2 = (y - SY + height) / TILEY;
+
+ if (setup.direct_draw)
+ SetDrawtoField(DRAW_BACKBUFFER);
+
+ for(xx=BX1; xx<=BX2; xx++)
+ for(yy=BY1; yy<=BY2; yy++)
+ if (xx >= x1 && xx <= x2 && yy >= y1 && yy <= y2)
+ DrawScreenField(xx, yy);
+ DrawAllPlayers();
+
+ if (setup.direct_draw)
+ SetDrawtoField(DRAW_DIRECT);
+ }
+
+ if (setup.soft_scrolling)
+ {
+ int fx = FX, fy = FY;
+
+ fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
+ fy += (ScreenMovDir & (MV_UP|MV_DOWN) ? ScreenGfxPos : 0);
+
+ BlitBitmap(fieldbuffer, backbuffer, fx,fy, SXSIZE,SYSIZE, SX,SY);
+ }
+ }
+
+ BlitBitmap(drawto, window, x, y, width, height, x, y);
+}
+
void BackToFront()
{
int x,y;
- DrawBuffer buffer = (drawto_field == window ? backbuffer : drawto_field);
+ DrawBuffer *buffer = (drawto_field == window ? backbuffer : drawto_field);
if (setup.direct_draw && game_status == PLAYING)
redraw_mask &= ~REDRAW_MAIN;
if (redraw_mask & REDRAW_FIELD)
redraw_mask &= ~REDRAW_TILES;
- if (!redraw_mask)
+ if (redraw_mask == REDRAW_NONE)
return;
-
-
- if (1 && game_status == PLAYING)
+ if (global.fps_slowdown && game_status == PLAYING)
{
- static boolean last_frame_skipped = 0;
- int fps_slowdown_factor = 2;
- boolean skip_even_when_not_scrolling = 1;
+ static boolean last_frame_skipped = FALSE;
+ boolean skip_even_when_not_scrolling = TRUE;
boolean just_scrolling = (ScreenMovDir != 0);
- boolean p = 0;
+ boolean verbose = FALSE;
- /*
- printf("ScreenMovDir = %d\n", ScreenMovDir);
- */
-
- /*
- printf("ScreenGfxPos = %d\n", ScreenGfxPos);
- */
-
- if (fps_slowdown_factor > 1 &&
- (FrameCounter % fps_slowdown_factor) &&
+ if (global.fps_slowdown_factor > 1 &&
+ (FrameCounter % global.fps_slowdown_factor) &&
(just_scrolling || skip_even_when_not_scrolling))
{
redraw_mask &= ~REDRAW_MAIN;
- if (p)
- printf("FRAME SKIPPED\n");
+ last_frame_skipped = TRUE;
- last_frame_skipped = 1;
+ if (verbose)
+ printf("FRAME SKIPPED\n");
}
else
{
if (last_frame_skipped)
redraw_mask |= REDRAW_FIELD;
- last_frame_skipped = 0;
+ last_frame_skipped = FALSE;
- if (p)
+ if (verbose)
printf("frame not skipped\n");
}
}
-
-
/* synchronize X11 graphics at this point; if we would synchronize the
display immediately after the buffer switching (after the XFlush),
this could mean that we have to wait for the graphics to complete,
if (redraw_mask & REDRAW_FPS) /* display frames per second */
{
char text[100];
+ char info1[100];
- sprintf(text, "%.1f fps", global.frames_per_second);
- DrawTextExt(window, gc, SX, SY, text, FS_SMALL, FC_YELLOW);
+ sprintf(info1, " (only every %d. frame)", global.fps_slowdown_factor);
+ if (!global.fps_slowdown)
+ info1[0] = '\0';
+
+ sprintf(text, "%.1f fps%s", global.frames_per_second, info1);
+ DrawTextExt(window, SX, SY, text, FS_SMALL, FC_YELLOW);
}
FlushDisplay();
for(y=0; y<MAX_BUF_YSIZE; y++)
redraw[x][y] = 0;
redraw_tiles = 0;
- redraw_mask = 0;
+ redraw_mask = REDRAW_NONE;
}
void FadeToFront()
redraw_mask |= REDRAW_FIELD;
}
-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, gc, (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, ...)
+void MarkTileDirty(int x, int y)
{
- char buffer[FULL_SXSIZE / FONT5_XSIZE + 10];
- va_list ap;
+ int xx = redraw_x1 + x;
+ int yy = redraw_y1 + y;
- va_start(ap, format);
- vsprintf(buffer, format, ap);
- va_end(ap);
+ if (!redraw[xx][yy])
+ redraw_tiles++;
- DrawText(SX + x, SY + y, buffer, FS_SMALL, font_type);
+ redraw[xx][yy] = TRUE;
+ redraw_mask |= REDRAW_TILES;
}
-void DrawText(int x, int y, char *text, int font_size, int font_type)
+void SetBorderElement()
{
- 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);
+ int x, y;
- if (font_type == FC_SPECIAL3)
- font_start += (FONT4_YSIZE - FONT2_YSIZE) * FONT_LINES_PER_FONT;
+ BorderElement = EL_LEERRAUM;
- while (*text)
+ for(y=0; y<lev_fieldy && BorderElement == EL_LEERRAUM; y++)
{
- 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)
+ for(x=0; x<lev_fieldx; x++)
{
- 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 (!IS_MASSIVE(Feld[x][y]))
+ BorderElement = EL_BETON;
- 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);
+ if (y != 0 && y != lev_fieldy - 1 && x != lev_fieldx - 1)
+ x = lev_fieldx - 2;
}
-
- x += font_width;
}
}
if (Store[last_jx][last_jy] && IS_DRAWABLE(last_element))
{
DrawLevelElement(last_jx, last_jy, Store[last_jx][last_jy]);
- DrawLevelFieldThruMask(last_jx, last_jy);
+ if (last_element == EL_DYNAMITE_ACTIVE)
+ DrawDynamite(last_jx, last_jy);
+ else
+ DrawLevelFieldThruMask(last_jx, last_jy);
}
else if (last_element == EL_DYNAMITE_ACTIVE)
DrawDynamite(last_jx, last_jy);
DrawLevelElement(jx, jy, Store[jx][jy]);
else if (!IS_ACTIVE_BOMB(element))
DrawLevelField(jx, jy);
+ else
+ DrawLevelElement(jx, jy, EL_LEERRAUM);
/* draw player himself */
}
#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)
MarkTileDirty(x,y);
}
-void DrawGraphicThruMaskExt(DrawBuffer d, int dest_x, int dest_y, int graphic)
+void DrawGraphicThruMaskExt(DrawBuffer *d, int dest_x, int dest_y, int graphic)
{
int tile = graphic;
int bitmap_nr;
int src_x, src_y;
- Bitmap src_bitmap;
+ Bitmap *src_bitmap;
GC drawing_gc;
if (graphic == GFX_LEERRAUM)
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);
}
else
{
#if DEBUG
-#ifndef USE_SDL_LIBRARY
+#ifndef TARGET_SDL
printf("DrawGraphicThruMask(): tile '%d' needs clipping!\n", tile);
#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 getMiniGraphicSource(int graphic, Bitmap *bitmap, int *x, int *y)
+void getMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y)
{
if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
{
}
}
-void DrawMiniGraphicExt(DrawBuffer d, GC gc, int x, int y, int graphic)
+void DrawMiniGraphicExt(DrawBuffer *d, int x, int y, int graphic)
{
- Bitmap bitmap;
+ Bitmap *bitmap;
int src_x, src_y;
getMiniGraphicSource(graphic, &bitmap, &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
{
#if DEBUG
-#ifndef USE_SDL_LIBRARY
+#ifndef TARGET_SDL
printf("DrawGraphicShifted(): tile '%d' needs clipping!\n", tile);
#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);
}
}
else if ((element == EL_FELSBROCKEN ||
element == EL_SP_ZONK ||
element == EL_BD_ROCK ||
- IS_GEM(element)) && !cut_mode)
+ element == EL_SP_INFOTRON ||
+ IS_GEM(element))
+ && !cut_mode)
{
if (uy >= lev_fieldy-1 || !IS_BELT(Feld[ux][uy+1]))
{
}
}
else if (element == EL_MAGIC_WALL_EMPTY ||
+ element == EL_MAGIC_WALL_EMPTYING ||
element == EL_MAGIC_WALL_BD_EMPTY ||
+ element == EL_MAGIC_WALL_BD_EMPTYING ||
element == EL_MAGIC_WALL_FULL ||
element == EL_MAGIC_WALL_BD_FULL)
{
graphic += 3 + getGraphicAnimationPhase(4, 4, ANIM_REVERSE);
}
- else if (IS_AMOEBOID(element))
+ else if (IS_AMOEBOID(element) || element == EL_AMOEBA_DRIPPING)
{
graphic = (element == EL_AMOEBE_TOT ? GFX_AMOEBE_TOT : GFX_AMOEBE_LEBT);
graphic += (x + 2 * y + 4) % 4;
void DrawScreenField(int x, int y)
{
int ux = LEVELX(x), uy = LEVELY(y);
- int element;
+ int element, content;
if (!IN_LEV_FIELD(ux, uy))
{
}
element = Feld[ux][uy];
+ content = Store[ux][uy];
if (IS_MOVING(ux, uy))
{
int horiz_move = (MovDir[ux][uy] == MV_LEFT || MovDir[ux][uy] == MV_RIGHT);
boolean cut_mode = NO_CUTTING;
- if (Store[ux][uy] == EL_MORAST_LEER ||
- Store[ux][uy] == EL_MAGIC_WALL_EMPTY ||
- Store[ux][uy] == EL_MAGIC_WALL_BD_EMPTY ||
- Store[ux][uy] == EL_AMOEBE_NASS)
+ if (element == EL_QUICKSAND_EMPTYING ||
+ element == EL_MAGIC_WALL_EMPTYING ||
+ element == EL_MAGIC_WALL_BD_EMPTYING ||
+ element == EL_AMOEBA_DRIPPING)
cut_mode = CUT_ABOVE;
- else if (Store[ux][uy] == EL_MORAST_VOLL ||
- Store[ux][uy] == EL_MAGIC_WALL_FULL ||
- Store[ux][uy] == EL_MAGIC_WALL_BD_FULL)
+ else if (element == EL_QUICKSAND_FILLING ||
+ element == EL_MAGIC_WALL_FILLING ||
+ element == EL_MAGIC_WALL_BD_FILLING)
cut_mode = CUT_BELOW;
if (cut_mode == CUT_ABOVE)
- DrawScreenElementShifted(x, y, 0, 0, Store[ux][uy], NO_CUTTING);
+ DrawScreenElementShifted(x, y, 0, 0, element, NO_CUTTING);
else
DrawScreenElement(x, y, EL_LEERRAUM);
if (horiz_move)
DrawScreenElementShifted(x, y, MovPos[ux][uy], 0, element, NO_CUTTING);
- else
+ else if (cut_mode == NO_CUTTING)
DrawScreenElementShifted(x, y, 0, MovPos[ux][uy], element, cut_mode);
+ else
+ DrawScreenElementShifted(x, y, 0, MovPos[ux][uy], content, cut_mode);
- if (Store[ux][uy] == EL_SALZSAEURE)
+ if (content == EL_SALZSAEURE)
DrawLevelElementThruMask(ux, uy + 1, EL_SALZSAEURE);
}
else if (IS_BLOCKED(ux, uy))
int sx, sy;
int horiz_move;
boolean cut_mode = NO_CUTTING;
+ int element_old, content_old;
Blocked2Moving(ux, uy, &oldx, &oldy);
sx = SCREENX(oldx);
horiz_move = (MovDir[oldx][oldy] == MV_LEFT ||
MovDir[oldx][oldy] == MV_RIGHT);
- if (Store[oldx][oldy] == EL_MORAST_LEER ||
- Store[oldx][oldy] == EL_MAGIC_WALL_EMPTY ||
- Store[oldx][oldy] == EL_MAGIC_WALL_BD_EMPTY ||
- Store[oldx][oldy] == EL_AMOEBE_NASS)
+ element_old = Feld[oldx][oldy];
+ content_old = Store[oldx][oldy];
+
+ if (element_old == EL_QUICKSAND_EMPTYING ||
+ element_old == EL_MAGIC_WALL_EMPTYING ||
+ element_old == EL_MAGIC_WALL_BD_EMPTYING ||
+ element_old == EL_AMOEBA_DRIPPING)
cut_mode = CUT_ABOVE;
DrawScreenElement(x, y, EL_LEERRAUM);
- element = Feld[oldx][oldy];
if (horiz_move)
- DrawScreenElementShifted(sx,sy, MovPos[oldx][oldy],0,element,NO_CUTTING);
+ DrawScreenElementShifted(sx, sy, MovPos[oldx][oldy], 0, element_old,
+ NO_CUTTING);
+ else if (cut_mode == NO_CUTTING)
+ DrawScreenElementShifted(sx, sy, 0, MovPos[oldx][oldy], element_old,
+ cut_mode);
else
- DrawScreenElementShifted(sx,sy, 0,MovPos[oldx][oldy],element,cut_mode);
+ DrawScreenElementShifted(sx, sy, 0, MovPos[oldx][oldy], content_old,
+ cut_mode);
}
else if (IS_DRAWABLE(element))
DrawScreenElement(x, y, element);
return 0;
}
+#define MAX_REQUEST_LINES 13
+#define MAX_REQUEST_LINE_LEN 7
+
boolean Request(char *text, unsigned int req_state)
{
int mx, my, ty, result = -1;
unsigned int old_door_state;
-#if !defined(MSDOS) && !defined(WIN32)
+#if defined(PLATFORM_UNIX)
/* pause network game while waiting for request to answer */
if (options.network &&
game_status == PLAYING &&
ClearRectangle(drawto, DX, DY, DXSIZE, DYSIZE);
/* write text for request */
- for(ty=0; ty<13; ty++)
+ for(ty=0; ty < MAX_REQUEST_LINES; ty++)
{
+ char text_line[MAX_REQUEST_LINE_LEN + 1];
int tx, tl, tc;
- char txt[256];
if (!*text)
break;
- for(tl=0,tx=0; tx<7; tl++,tx++)
+ for(tl=0,tx=0; tx < MAX_REQUEST_LINE_LEN; tl++,tx++)
{
tc = *(text + tx);
- if (!tc || tc == 32)
+ if (!tc || tc == ' ')
break;
}
+
if (!tl)
{
text++;
ty--;
continue;
}
- sprintf(txt, text);
- txt[tl] = 0;
- DrawTextExt(drawto, gc,
- DX + 51 - (tl * 14)/2, DY + 8 + ty * 16,
- txt, FS_SMALL, FC_YELLOW);
- text += tl + (tc == 32 ? 1 : 0);
+
+ strncpy(text_line, text, tl);
+ text_line[tl] = 0;
+
+ DrawTextExt(drawto, DX + 50 - (tl * 14)/2, DY + 8 + ty * 16,
+ text_line, FS_SMALL, FC_YELLOW);
+
+ text += tl + (tc == ' ' ? 1 : 0);
}
if (req_state & REQ_ASK)
case EVENT_KEYPRESS:
switch(GetEventKey((KeyEvent *)&event, TRUE))
{
- case KEY_Return:
+ case KSYM_Return:
result = 1;
break;
- case KEY_Escape:
+ case KSYM_Escape:
result = 0;
break;
break;
case EVENT_KEYRELEASE:
- key_joystick_mapping = 0;
+ ClearPlayerAction();
break;
default:
RemapAllGadgets();
-#if !defined(MSDOS) && !defined(WIN32)
+#if defined(PLATFORM_UNIX)
/* continue network game after request */
if (options.network &&
game_status == PLAYING &&
unsigned int GetDoorState()
{
- return(MoveDoor(DOOR_GET_STATE));
+ return MoveDoor(DOOR_GET_STATE);
+}
+
+unsigned int SetDoorState(unsigned int door_state)
+{
+ return MoveDoor(door_state | DOOR_SET_STATE);
}
unsigned int MoveDoor(unsigned int door_state)
if (door_state == DOOR_GET_STATE)
return(door1 | door2);
+ if (door_state & DOOR_SET_STATE)
+ {
+ if (door_state & DOOR_ACTION_1)
+ door1 = door_state & DOOR_ACTION_1;
+ if (door_state & DOOR_ACTION_2)
+ door2 = door_state & DOOR_ACTION_2;
+
+ return(door1 | door2);
+ }
+
if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1)
door_state &= ~DOOR_OPEN_1;
else if (door1 == DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1)
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);
redraw_mask |= REDRAW_ALL;
}
-#ifndef USE_SDL_LIBRARY
-int ReadPixel(DrawBuffer d, int x, int y)
+#ifndef TARGET_SDL
+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);
}
};
-static void DoNotDisplayInfoText(void *ptr)
-{
- return;
-}
-
void CreateToolButtons()
{
int i;
for (i=0; i<NUM_TOOL_BUTTONS; i++)
{
- Bitmap gd_bitmap = pix[PIX_DOOR];
- Bitmap deco_bitmap = None;
+ Bitmap *gd_bitmap = pix[PIX_DOOR];
+ Bitmap *deco_bitmap = None;
int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
struct GadgetInfo *gi;
unsigned long event_mask;
GDI_DECORATION_SHIFTING, 1, 1,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK_ACTION, HandleToolButtons,
- GDI_CALLBACK_INFO, DoNotDisplayInfoText,
GDI_END);
if (gi == NULL)
request_gadget_id = gi->custom_id;
}
+int get_next_element(int element)
+{
+ switch(element)
+ {
+ case EL_QUICKSAND_FILLING: return EL_MORAST_VOLL;
+ case EL_QUICKSAND_EMPTYING: return EL_MORAST_LEER;
+ case EL_MAGIC_WALL_FILLING: return EL_MAGIC_WALL_FULL;
+ case EL_MAGIC_WALL_EMPTYING: return EL_MAGIC_WALL_EMPTY;
+ case EL_MAGIC_WALL_BD_FILLING: return EL_MAGIC_WALL_BD_FULL;
+ case EL_MAGIC_WALL_BD_EMPTYING: return EL_MAGIC_WALL_BD_EMPTY;
+ case EL_AMOEBA_DRIPPING: return EL_AMOEBE_NASS;
+
+ default: return element;
+ }
+}
+
int el2gfx(int element)
{
switch(element)
case EL_DIAMANT: return GFX_DIAMANT;
case EL_MORAST_LEER: return GFX_MORAST_LEER;
case EL_MORAST_VOLL: return GFX_MORAST_VOLL;
+ case EL_QUICKSAND_EMPTYING: return GFX_MORAST_LEER;
case EL_TROPFEN: return GFX_TROPFEN;
case EL_BOMBE: return GFX_BOMBE;
case EL_MAGIC_WALL_OFF: return GFX_MAGIC_WALL_OFF;
case EL_MAGIC_WALL_EMPTY: return GFX_MAGIC_WALL_EMPTY;
+ case EL_MAGIC_WALL_EMPTYING:return GFX_MAGIC_WALL_EMPTY;
case EL_MAGIC_WALL_FULL: return GFX_MAGIC_WALL_FULL;
case EL_MAGIC_WALL_DEAD: return GFX_MAGIC_WALL_DEAD;
case EL_SALZSAEURE: return GFX_SALZSAEURE;
case EL_AMOEBE_VOLL: return GFX_AMOEBE_VOLL;
case EL_AMOEBE_BD: return GFX_AMOEBE_BD;
case EL_AMOEBA2DIAM: return GFX_AMOEBA2DIAM;
+ case EL_AMOEBA_DRIPPING: return GFX_AMOEBE_NASS;
case EL_KOKOSNUSS: return GFX_KOKOSNUSS;
case EL_LIFE: return GFX_LIFE;
case EL_LIFE_ASYNC: return GFX_LIFE_ASYNC;
case EL_MAMPFER2: return GFX_MAMPFER2;
case EL_MAGIC_WALL_BD_OFF: return GFX_MAGIC_WALL_BD_OFF;
case EL_MAGIC_WALL_BD_EMPTY:return GFX_MAGIC_WALL_BD_EMPTY;
+ case EL_MAGIC_WALL_BD_EMPTYING:return GFX_MAGIC_WALL_BD_EMPTY;
case EL_MAGIC_WALL_BD_FULL: return GFX_MAGIC_WALL_BD_FULL;
case EL_MAGIC_WALL_BD_DEAD: return GFX_MAGIC_WALL_BD_DEAD;
case EL_DYNABOMB_ACTIVE_1: return GFX_DYNABOMB;