X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_mm%2Fmm_tools.c;h=d4bb5d37553ae80e1c72032f91e2cfc5146f281a;hb=f11f733c9a676d117a70ce117b4ecc3cfdb16be9;hp=d7f4326e19ed2fd6ed5f4351701ba83c042ce3f5;hpb=9844da8056347b71669ce3b5bccb4cd01caa71b3;p=rocksndiamonds.git diff --git a/src/game_mm/mm_tools.c b/src/game_mm/mm_tools.c index d7f4326e..d4bb5d37 100644 --- a/src/game_mm/mm_tools.c +++ b/src/game_mm/mm_tools.c @@ -75,7 +75,9 @@ void DrawGraphic_MM(int x, int y, int graphic) } #endif - DrawGraphicExt_MM(drawto_field, cFX + x * TILEX, cFY + y * TILEY, graphic); + int frame = getGraphicAnimationFrameXY(graphic, x, y); + + DrawGraphicAnimation_MM(x, y, graphic, frame); MarkTileDirty(x, y); } @@ -90,7 +92,7 @@ void DrawGraphicExt_MM(DrawBuffer *d, int x, int y, int graphic) BlitBitmap(bitmap, d, src_x, src_y, TILEX, TILEY, x, y); } -void DrawGraphicThruMask_MM(int x, int y, int graphic) +void DrawGraphicThruMask_MM(int x, int y, int graphic, int frame) { #if DEBUG if (!IN_SCR_FIELD(x,y)) @@ -104,13 +106,13 @@ void DrawGraphicThruMask_MM(int x, int y, int graphic) #endif DrawGraphicThruMaskExt_MM(drawto_field, cFX + x * TILEX, cFY + y * TILEY, - graphic); + graphic, frame); MarkTileDirty(x,y); } void DrawGraphicThruMaskExt_MM(DrawBuffer *d, int dest_x, int dest_y, - int graphic) + int graphic, int frame) { int src_x, src_y; Bitmap *src_bitmap; @@ -118,7 +120,7 @@ void DrawGraphicThruMaskExt_MM(DrawBuffer *d, int dest_x, int dest_y, if (graphic == IMG_EMPTY) return; - getGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y); + getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX, TILEY, dest_x, dest_y); } @@ -260,12 +262,6 @@ void DrawGraphicShifted_MM(int x,int y, int dx,int dy, int graphic, MarkTileDirty(x,y); } -void DrawGraphicShiftedThruMask_MM(int x,int y, int dx,int dy, int graphic, - int cut_mode) -{ - DrawGraphicShifted_MM(x, y, dx, dy, graphic, cut_mode, USE_MASKING); -} - void DrawScreenElementExt_MM(int x, int y, int dx, int dy, int element, int cut_mode, int mask_mode) { @@ -290,7 +286,7 @@ void DrawScreenElementExt_MM(int x, int y, int dx, int dy, int element, if (dx || dy) DrawGraphicShifted_MM(x, y, dx, dy, graphic, cut_mode, mask_mode); else if (mask_mode == USE_MASKING) - DrawGraphicThruMask_MM(x, y, graphic); + DrawGraphicThruMask_MM(x, y, graphic, 0); else DrawGraphic_MM(x, y, graphic); } @@ -309,38 +305,11 @@ void DrawScreenElementShifted_MM(int x, int y, int dx, int dy, int element, DrawScreenElementExt_MM(x, y, dx, dy, element, cut_mode, NO_MASKING); } -void DrawLevelElementShifted_MM(int x, int y, int dx, int dy, int element, - int cut_mode) -{ - DrawLevelElementExt_MM(x, y, dx, dy, element, cut_mode, NO_MASKING); -} - -void DrawScreenElementThruMask_MM(int x, int y, int element) -{ - DrawScreenElementExt_MM(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); -} - -void DrawLevelElementThruMask_MM(int x, int y, int element) -{ - DrawLevelElementExt_MM(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); -} - -void DrawLevelFieldThruMask_MM(int x, int y) -{ - DrawLevelElementExt_MM(x, y, 0, 0, Tile[x][y], NO_CUTTING, USE_MASKING); -} - void DrawScreenElement_MM(int x, int y, int element) { DrawScreenElementExt_MM(x, y, 0, 0, element, NO_CUTTING, NO_MASKING); } -void DrawLevelElement_MM(int x, int y, int element) -{ - if (IN_LEV_FIELD(x, y) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawScreenElement_MM(SCREENX(x), SCREENY(y), element); -} - void DrawScreenField_MM(int x, int y) { int element = Tile[x][y]; @@ -617,17 +586,6 @@ static void DrawMicroLevelExt_MM(int xpos, int ypos) } #endif -void DrawMiniLevel_MM(int size_x, int size_y, int scroll_x, int scroll_y) -{ - int x, y; - - for (x = 0; x < size_x; x++) - for (y = 0; y < size_y; y++) - DrawMiniElementOrWall_MM(x, y, scroll_x, scroll_y); - - redraw_mask |= REDRAW_FIELD; -} - // ---------------------------------------------------------------------------- // XSN @@ -648,12 +606,18 @@ void DrawMiniLevel_MM(int size_x, int size_y, int scroll_x, int scroll_y) #define XSN_CHANGE_DELAY 30 #define XSN_CHANGE_FACTOR 3 #define XSN_ALPHA_DEFAULT XSN_ALPHA_VALUE(95) +#define XSN_ALPHA_VISIBLE XSN_ALPHA_VALUE(50) #define XSN_DEBUG_STEPS 5 static byte xsn_bits_0[] = { 0x05, 0x02, 0x05 }; static byte xsn_bits_1[] = { 0x22, 0x6b, 0x14, 0x2a, 0x14, 0x6b, 0x22 }; static byte xsn_bits_2[] = { 0x14, 0x08, 0x49, 0x36, 0x49, 0x08, 0x14 }; +char debug_xsn_mode[] = { 76,101,116,32,105,116,32,115,110,111,119,33,0 }; + +void setHideSetupEntry(void *); +void removeHideSetupEntry(void *); + static struct { int size; @@ -702,6 +666,8 @@ struct Xsn struct XsnItem items[XSN_MAX_ITEMS]; Bitmap *bitmap; + + int alpha; }; static struct Xsn xsn = { 0 }; @@ -842,7 +808,7 @@ static void xsn_update_item(int nr) BlitBitmapMasked(xsn.bitmap, xsn.bitmap, xpos1, xsn.max_height, xsize, xsn.max_height, xpos1, 0); - SDLSetAlpha(surface_masked, TRUE, XSN_ALPHA_DEFAULT); + SDLSetAlpha(surface_masked, TRUE, xsn.alpha); for (i = xpos1; i < xpos2; i++) xsn.height[i] = MIN(xsn.height[i] + shrink, xsn.area_ysize - 1); @@ -891,16 +857,11 @@ static void DrawTileCursor_Xsn(int draw_target) static boolean started = FALSE; static boolean active = FALSE; static boolean debug = FALSE; - static unsigned int check_delay = 0; - static unsigned int start_delay = 0; - static unsigned int growth_delay = 0; - static unsigned int update_delay = 0; - static unsigned int change_delay = 0; - static unsigned int check_delay_value = XSN_CHECK_DELAY * 1000; - static unsigned int start_delay_value = 0; - static unsigned int growth_delay_value = 0; - static unsigned int update_delay_value = 0; - static unsigned int change_delay_value = 0; + static DelayCounter check_delay = { XSN_CHECK_DELAY * 1000 }; + static DelayCounter start_delay = { 0 }; + static DelayCounter growth_delay = { 0 }; + static DelayCounter update_delay = { 0 }; + static DelayCounter change_delay = { 0 }; static int percent = 0; static int debug_value = 0; boolean reinitialize = FALSE; @@ -910,10 +871,27 @@ static void DrawTileCursor_Xsn(int draw_target) if (draw_target != DRAW_TO_SCREEN) return; - if (DelayReached(&check_delay, check_delay_value)) + if (DelayReached(&check_delay)) { percent = (debug ? debug_value * 100 / XSN_DEBUG_STEPS : xsn_percent()); + + if (debug) + setup.debug.xsn_percent = percent; + + if (setup.debug.xsn_mode != AUTO) + percent = setup.debug.xsn_percent; + + setup.debug.xsn_percent = percent; + active = (percent > 0); + + if ((active && !active_last) || setup.debug.xsn_mode != AUTO) + removeHideSetupEntry(&setup.debug.xsn_mode); + else if (!active && active_last) + setHideSetupEntry(&setup.debug.xsn_mode); + + if (setup.debug.xsn_mode == FALSE) + active = FALSE; } else if (tile_cursor.xsn_debug) { @@ -921,24 +899,15 @@ static void DrawTileCursor_Xsn(int draw_target) debug = TRUE; active = FALSE; - DelayReached(&check_delay, 0); + ResetDelayCounter(&check_delay); + setup.debug.xsn_mode = (debug_value > 0); tile_cursor.xsn_debug = FALSE; } if (!active) return; - if (!active_last) - { - start_delay_value = (debug ? 0 : XSN_RND(XSN_START_DELAY * 2) * 1000); - started = FALSE; - - DelayReached(&start_delay, 0); - - reinitialize = TRUE; - } - if (!initialized) { xsn.area_xsize = gfx.win_xsize; @@ -978,6 +947,17 @@ static void DrawTileCursor_Xsn(int draw_target) initialized = TRUE; } + if (!active_last) + { + start_delay.value = (debug || setup.debug.xsn_mode == TRUE ? 0 : + (XSN_START_DELAY + XSN_RND(XSN_START_DELAY)) * 1000); + started = FALSE; + + ResetDelayCounter(&start_delay); + + reinitialize = TRUE; + } + if (reinitialize) { xsn.num_items = 0; @@ -991,6 +971,8 @@ static void DrawTileCursor_Xsn(int draw_target) xsn.change_type = 0; xsn.change_dir = 0; + xsn.alpha = XSN_ALPHA_DEFAULT; + for (i = 0; i < xsn.max_items; i++) xsn_init_item(i); } @@ -1021,8 +1003,8 @@ static void DrawTileCursor_Xsn(int draw_target) SDL_SetColorKey(surface_masked, SET_TRANSPARENT_PIXEL, SDL_MapRGB(surface_masked->format, 0x00, 0x00, 0x00)); - SDLSetAlpha(surface, TRUE, XSN_ALPHA_DEFAULT); - SDLSetAlpha(surface_masked, TRUE, XSN_ALPHA_DEFAULT); + SDLSetAlpha(surface, TRUE, xsn.alpha); + SDLSetAlpha(surface_masked, TRUE, xsn.alpha); SDLCreateBitmapTextures(xsn.bitmap); @@ -1043,40 +1025,54 @@ static void DrawTileCursor_Xsn(int draw_target) if (!started) { - if (!DelayReached(&start_delay, start_delay_value)) + if (!DelayReached(&start_delay)) return; - update_delay_value = XSN_UPDATE_DELAY; - growth_delay_value = XSN_GROWTH_DELAY * 1000; - change_delay_value = XSN_CHANGE_DELAY * 1000; + update_delay.value = XSN_UPDATE_DELAY; + growth_delay.value = XSN_GROWTH_DELAY * 1000; + change_delay.value = XSN_CHANGE_DELAY * 1000; - DelayReached(&growth_delay, 0); - DelayReached(&update_delay, 0); - DelayReached(&change_delay, 0); + ResetDelayCounter(&growth_delay); + ResetDelayCounter(&update_delay); + ResetDelayCounter(&change_delay); started = TRUE; } if (xsn.num_items < xsn.max_items) { - if (DelayReached(&growth_delay, growth_delay_value)) + if (DelayReached(&growth_delay)) { xsn.num_items += XSN_RND(XSN_GROWTH_RATE * 2); xsn.num_items = MIN(xsn.num_items, xsn.max_items); } } - if (DelayReached(&update_delay, update_delay_value)) + if (DelayReached(&update_delay)) { for (i = 0; i < xsn.num_items; i++) xsn_update_item(i); } - if (DelayReached(&change_delay, change_delay_value)) + if (DelayReached(&change_delay)) { xsn_update_change(); - change_delay_value = xsn.change_delay * 1000; + change_delay.value = xsn.change_delay * 1000; + } + + int xsn_alpha_dx = (gfx.mouse_y > xsn.area_ysize - xsn.max_height ? + (xsn.alpha > XSN_ALPHA_VISIBLE ? -1 : 0) : + (xsn.alpha < XSN_ALPHA_DEFAULT ? +1 : 0)); + + if (xsn_alpha_dx != 0) + { + xsn.alpha += xsn_alpha_dx; + + SDLSetAlpha(xsn.bitmap->surface_masked, TRUE, xsn.alpha); + + SDLFreeBitmapTextures(xsn.bitmap); + SDLCreateBitmapTextures(xsn.bitmap); } BlitToScreenMasked(xsn.bitmap, 0, 0, xsn.area_xsize, xsn.max_height, @@ -1293,16 +1289,7 @@ static int map_element(int element) int el2gfx(int element) { - element = map_element(element); - - switch (element) - { - case EL_LIGHTBALL: - return IMG_MM_LIGHTBALL_RED + RND(3); - - default: - return el2img_mm(element); - } + return el2img_mm(map_element(element)); } void RedrawPlayfield_MM(void)