X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=52f64b144287a478879204f3e4603de41ca97c85;hb=998be01ad92a672b69b11e24d472f6c0c076817f;hp=61e1bac133ce0f63ba0183b775097a5d5515a4b3;hpb=da14f69fd95c7bd5a0d70cdf4935af06f1f20a04;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 61e1bac1..52f64b14 100644 --- a/src/tools.c +++ b/src/tools.c @@ -25,6 +25,7 @@ #include "joystick.h" #include "cartoons.h" #include "network.h" +#include "tape.h" #if defined(PLATFORM_MSDOS) extern boolean wait_for_vsync; @@ -247,7 +248,7 @@ void BackToFront() info1[0] = '\0'; sprintf(text, "%.1f fps%s", global.frames_per_second, info1); - DrawTextExt(window, gc, SX, SY, text, FS_SMALL, FC_YELLOW); + DrawTextExt(window, SX, SY, text, FS_SMALL, FC_YELLOW); } FlushDisplay(); @@ -351,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, gc, (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; xstored_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); } @@ -935,7 +825,7 @@ void DrawGraphicThruMaskExt(DrawBuffer d, int dest_x, int dest_y, int graphic) #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); } @@ -943,7 +833,7 @@ void DrawGraphicThruMaskExt(DrawBuffer d, int dest_x, int dest_y, int graphic) 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); } @@ -994,7 +884,7 @@ void getMiniGraphicSource(int graphic, Bitmap *bitmap, int *x, int *y) } } -void DrawMiniGraphicExt(DrawBuffer d, GC gc, int x, int y, int graphic) +void DrawMiniGraphicExt(DrawBuffer d, int x, int y, int graphic) { Bitmap bitmap; int src_x, src_y; @@ -1011,6 +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; GC drawing_gc; if (graphic < 0) @@ -1084,7 +975,8 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, } 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; @@ -1105,9 +997,9 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, { 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 @@ -1118,8 +1010,8 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, #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); } } @@ -1875,8 +1767,7 @@ boolean Request(char *text, unsigned int req_state) } sprintf(txt, text); txt[tl] = 0; - DrawTextExt(drawto, gc, - DX + 51 - (tl * 14)/2, DY + 8 + ty * 16, + DrawTextExt(drawto, DX + 51 - (tl * 14)/2, DY + 8 + ty * 16, txt, FS_SMALL, FC_YELLOW); text += tl + (tc == 32 ? 1 : 0); } @@ -2137,6 +2028,9 @@ unsigned int MoveDoor(unsigned int door_state) 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) @@ -2150,33 +2044,32 @@ unsigned int MoveDoor(unsigned int door_state) 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); @@ -2194,21 +2087,21 @@ unsigned int MoveDoor(unsigned int door_state) 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); @@ -2253,12 +2146,13 @@ void UndrawSpecialEditorDoor() } #ifndef TARGET_SDL -int ReadPixel(DrawBuffer d, int x, int y) +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);