X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=f7a67afb42b0a9a3a9a1e345923ed77c08eaf1c4;hb=6269ea8e89e9dea338b286bc6cb3a48388a43ad7;hp=521328f605ebde34d6f8730fc897602423cde02a;hpb=49221e59bff18cdfbef8c877b588280266ae5037;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 521328f6..f7a67afb 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1,14 +1,14 @@ /*********************************************************** -* 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 @@ -85,7 +85,7 @@ void SetDrawtoField(int mode) 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; @@ -352,147 +352,36 @@ void ClearWindow() redraw_mask |= REDRAW_FIELD; } - -#if 0 -int getFontWidth(int font_size, int font_type) +void MarkTileDirty(int x, int y) { - 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 xx = redraw_x1 + x; + int yy = redraw_y1 + y; -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); -} + if (!redraw[xx][yy]) + redraw_tiles++; -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(); - } + redraw[xx][yy] = TRUE; + redraw_mask |= REDRAW_TILES; } -void DrawTextFCentered(int y, int font_type, char *format, ...) +void SetBorderElement() { - 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); + 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= '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= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN) { @@ -995,9 +884,9 @@ void getMiniGraphicSource(int graphic, Bitmap *bitmap, int *x, int *y) } } -void DrawMiniGraphicExt(DrawBuffer d, 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); @@ -1012,7 +901,7 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, int src_x, src_y, dest_x, dest_y; int tile = graphic; int bitmap_nr; - Bitmap src_bitmap; + Bitmap *src_bitmap; GC drawing_gc; if (graphic < 0) @@ -1447,7 +1336,7 @@ void DrawLevelElement(int x, int y, int element) void DrawScreenField(int x, int y) { int ux = LEVELX(x), uy = LEVELY(y); - int element; + int element, content; if (!IN_LEV_FIELD(ux, uy)) { @@ -1461,33 +1350,44 @@ void DrawScreenField(int x, int y) } 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 || + content == EL_MAGIC_WALL_EMPTY || + content == EL_MAGIC_WALL_BD_EMPTY || + content == EL_AMOEBE_NASS) 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 || + content == EL_MAGIC_WALL_FULL || + content == EL_MAGIC_WALL_BD_FULL) cut_mode = CUT_BELOW; if (cut_mode == CUT_ABOVE) - DrawScreenElementShifted(x, y, 0, 0, Store[ux][uy], NO_CUTTING); + { + if (element == EL_QUICKSAND_EMPTYING) + DrawScreenElementShifted(x, y, 0, 0, element, NO_CUTTING); + else + DrawScreenElementShifted(x, y, 0, 0, content, NO_CUTTING); + } else DrawScreenElement(x, y, EL_LEERRAUM); if (horiz_move) DrawScreenElementShifted(x, y, MovPos[ux][uy], 0, element, NO_CUTTING); else - DrawScreenElementShifted(x, y, 0, MovPos[ux][uy], element, cut_mode); + { + if (element == EL_QUICKSAND_FILLING || element == EL_QUICKSAND_EMPTYING) + DrawScreenElementShifted(x, y, 0, MovPos[ux][uy], content, cut_mode); + else + DrawScreenElementShifted(x, y, 0, MovPos[ux][uy], element, cut_mode); + } - if (Store[ux][uy] == EL_SALZSAEURE) + if (content == EL_SALZSAEURE) DrawLevelElementThruMask(ux, uy + 1, EL_SALZSAEURE); } else if (IS_BLOCKED(ux, uy)) @@ -1496,6 +1396,7 @@ void DrawScreenField(int x, int y) int sx, sy; int horiz_move; boolean cut_mode = NO_CUTTING; + int element_old, content_old; Blocked2Moving(ux, uy, &oldx, &oldy); sx = SCREENX(oldx); @@ -1503,19 +1404,29 @@ void DrawScreenField(int x, int y) 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 || + content_old == EL_MAGIC_WALL_EMPTY || + content_old == EL_MAGIC_WALL_BD_EMPTY || + content_old == EL_AMOEBE_NASS) 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 - DrawScreenElementShifted(sx,sy, 0,MovPos[oldx][oldy],element,cut_mode); + { + if (element_old == EL_QUICKSAND_EMPTYING) + DrawScreenElementShifted(sx, sy, 0, MovPos[oldx][oldy], content_old, + cut_mode); + else + DrawScreenElementShifted(sx, sy, 0, MovPos[oldx][oldy], element_old, + cut_mode); + } } else if (IS_DRAWABLE(element)) DrawScreenElement(x, y, element); @@ -2139,7 +2050,7 @@ unsigned int MoveDoor(unsigned int door_state) for(x=start; x<=DXSIZE; x+=stepsize) { - Bitmap bitmap = pix[PIX_DOOR]; + Bitmap *bitmap = pix[PIX_DOOR]; GC gc = bitmap->stored_clip_gc; WaitUntilDelayReached(&door_delay, door_delay_value); @@ -2257,7 +2168,7 @@ void UndrawSpecialEditorDoor() } #ifndef TARGET_SDL -int ReadPixel(DrawBuffer bitmap, int x, int y) +int ReadPixel(DrawBuffer *bitmap, int x, int y) { XImage *pixel_image; unsigned long pixel_value; @@ -2386,8 +2297,8 @@ void CreateToolButtons() for (i=0; i