X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ftools.c;h=55a28fc40d0cf13ef90ec1df29c3910bb15e5661;hp=b563b9318c16a897fd2700442b0e1c5bfa034285;hb=9eb4ba2e639c16c6a5e72ddaeabfb455a85c66bf;hpb=5eabbc4d089dcf4de6ddcc78159efd6a9ecef978 diff --git a/src/tools.c b/src/tools.c index b563b931..55a28fc4 100644 --- a/src/tools.c +++ b/src/tools.c @@ -192,17 +192,197 @@ static char *print_if_not_empty(int element) return s; } -void DumpTile(int x, int y) +int correctLevelPosX_EM(int lx) { - int sx = SCREENX(x); - int sy = SCREENY(y); + lx -= 1; + lx -= (BorderElement != EL_EMPTY ? 1 : 0); - if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + return lx; +} + +int correctLevelPosY_EM(int ly) +{ + ly -= 1; + ly -= (BorderElement != EL_EMPTY ? 1 : 0); + + return ly; +} + +static int getFieldbufferOffsetX_RND() +{ + int full_lev_fieldx = lev_fieldx + (BorderElement != EL_EMPTY ? 2 : 0); + int dx = (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); + int dx_var = dx * TILESIZE_VAR / TILESIZE; + int fx = FX; + + if (EVEN(SCR_FIELDX)) { - x--; - y--; + int ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var; + + if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR) + fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR; + else + fx += (dx_var > 0 ? TILEX_VAR : 0); + } + else + { + fx += dx_var; + } + + if (full_lev_fieldx <= SCR_FIELDX) + { + if (EVEN(SCR_FIELDX)) + fx = 2 * TILEX_VAR - (ODD(lev_fieldx) ? TILEX_VAR / 2 : 0); + else + fx = 2 * TILEX_VAR - (EVEN(lev_fieldx) ? TILEX_VAR / 2 : 0); } + return fx; +} + +static int getFieldbufferOffsetY_RND() +{ + int full_lev_fieldy = lev_fieldy + (BorderElement != EL_EMPTY ? 2 : 0); + int dy = (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); + int dy_var = dy * TILESIZE_VAR / TILESIZE; + int fy = FY; + + if (EVEN(SCR_FIELDY)) + { + int ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy_var; + + if (ffy < SBY_Lower * TILEY_VAR + TILEY_VAR / 2 + TILEY_VAR) + fy += dy_var - MIN(ffy, TILEY_VAR / 2) + TILEY_VAR; + else + fy += (dy_var > 0 ? TILEY_VAR : 0); + } + else + { + fy += dy_var; + } + + if (full_lev_fieldy <= SCR_FIELDY) + { + if (EVEN(SCR_FIELDY)) + fy = 2 * TILEY_VAR - (ODD(lev_fieldy) ? TILEY_VAR / 2 : 0); + else + fy = 2 * TILEY_VAR - (EVEN(lev_fieldy) ? TILEY_VAR / 2 : 0); + } + + return fy; +} + +static int getLevelFromScreenX_RND(int sx) +{ + int fx = getFieldbufferOffsetX_RND(); + int dx = fx - FX; + int px = sx - SX; + int lx = LEVELX((px + dx) / TILESIZE_VAR); + + return lx; +} + +static int getLevelFromScreenY_RND(int sy) +{ + int fy = getFieldbufferOffsetY_RND(); + int dy = fy - FY; + int py = sy - SY; + int ly = LEVELY((py + dy) / TILESIZE_VAR); + + return ly; +} + +static int getLevelFromScreenX_EM(int sx) +{ + int level_xsize = level.native_em_level->lev->width; + int full_xsize = level_xsize * TILESIZE_VAR; + + sx -= (full_xsize < SXSIZE ? (SXSIZE - full_xsize) / 2 : 0); + + int fx = getFieldbufferOffsetX_EM(); + int dx = fx; + int px = sx - SX; + int lx = LEVELX((px + dx) / TILESIZE_VAR); + + lx = correctLevelPosX_EM(lx); + + return lx; +} + +static int getLevelFromScreenY_EM(int sy) +{ + int level_ysize = level.native_em_level->lev->height; + int full_ysize = level_ysize * TILESIZE_VAR; + + sy -= (full_ysize < SYSIZE ? (SYSIZE - full_ysize) / 2 : 0); + + int fy = getFieldbufferOffsetY_EM(); + int dy = fy; + int py = sy - SY; + int ly = LEVELY((py + dy) / TILESIZE_VAR); + + ly = correctLevelPosY_EM(ly); + + return ly; +} + +static int getLevelFromScreenX_SP(int sx) +{ + int menBorder = setup.sp_show_border_elements; + int level_xsize = level.native_sp_level->width; + int full_xsize = (level_xsize - (menBorder ? 0 : 1)) * TILESIZE_VAR; + + sx += (full_xsize < SXSIZE ? (SXSIZE - full_xsize) / 2 : 0); + + int fx = getFieldbufferOffsetX_SP(); + int dx = fx - FX; + int px = sx - SX; + int lx = LEVELX((px + dx) / TILESIZE_VAR); + + return lx; +} + +static int getLevelFromScreenY_SP(int sy) +{ + int menBorder = setup.sp_show_border_elements; + int level_ysize = level.native_sp_level->height; + int full_ysize = (level_ysize - (menBorder ? 0 : 1)) * TILESIZE_VAR; + + sy += (full_ysize < SYSIZE ? (SYSIZE - full_ysize) / 2 : 0); + + int fy = getFieldbufferOffsetY_SP(); + int dy = fy - FY; + int py = sy - SY; + int ly = LEVELY((py + dy) / TILESIZE_VAR); + + return ly; +} + +int getLevelFromScreenX(int x) +{ + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + return getLevelFromScreenX_EM(x); + if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + return getLevelFromScreenX_SP(x); + else + return getLevelFromScreenX_RND(x); +} + +int getLevelFromScreenY(int y) +{ + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + return getLevelFromScreenY_EM(y); + if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + return getLevelFromScreenY_SP(y); + else + return getLevelFromScreenY_RND(y); +} + +void DumpTile(int x, int y) +{ + int sx = SCREENX(x); + int sy = SCREENY(y); + printf_line("-", 79); printf("Field Info: SCREEN(%d, %d), LEVEL(%d, %d)\n", sx, sy, x, y); printf_line("-", 79); @@ -229,9 +409,18 @@ void DumpTile(int x, int y) printf(" GfxElement: %d\n", GfxElement[x][y]); printf(" GfxAction: %d\n", GfxAction[x][y]); printf(" GfxFrame: %d [%d]\n", GfxFrame[x][y], FrameCounter); + printf(" Player x/y: %d, %d\n", local_player->jx, local_player->jy); printf("\n"); } +void DumpTileFromScreen(int sx, int sy) +{ + int lx = getLevelFromScreenX(sx); + int ly = getLevelFromScreenY(sy); + + DumpTile(lx, ly); +} + void SetDrawtoField(int mode) { if (mode == DRAW_TO_FIELDBUFFER) @@ -410,58 +599,8 @@ void DrawMaskedBorderToTarget(int draw_target) void BlitScreenToBitmap_RND(Bitmap *target_bitmap) { - int fx = FX, fy = FY; - int full_lev_fieldx = lev_fieldx + (BorderElement != EL_EMPTY ? 2 : 0); - int full_lev_fieldy = lev_fieldy + (BorderElement != EL_EMPTY ? 2 : 0); - - int dx = (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); - int dy = (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); - int dx_var = dx * TILESIZE_VAR / TILESIZE; - int dy_var = dy * TILESIZE_VAR / TILESIZE; - int ffx, ffy; - - ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var; - ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy_var; - - if (EVEN(SCR_FIELDX)) - { - if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR) - fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR; - else - fx += (dx_var > 0 ? TILEX_VAR : 0); - } - else - { - fx += dx_var; - } - - if (EVEN(SCR_FIELDY)) - { - if (ffy < SBY_Lower * TILEY_VAR + TILEY_VAR / 2 + TILEY_VAR) - fy += dy_var - MIN(ffy, TILEY_VAR / 2) + TILEY_VAR; - else - fy += (dy_var > 0 ? TILEY_VAR : 0); - } - else - { - fy += dy_var; - } - - if (full_lev_fieldx <= SCR_FIELDX) - { - if (EVEN(SCR_FIELDX)) - fx = 2 * TILEX_VAR - (ODD(lev_fieldx) ? TILEX_VAR / 2 : 0); - else - fx = 2 * TILEX_VAR - (EVEN(lev_fieldx) ? TILEX_VAR / 2 : 0); - } - - if (full_lev_fieldy <= SCR_FIELDY) - { - if (EVEN(SCR_FIELDY)) - fy = 2 * TILEY_VAR - (ODD(lev_fieldy) ? TILEY_VAR / 2 : 0); - else - fy = 2 * TILEY_VAR - (EVEN(lev_fieldy) ? TILEY_VAR / 2 : 0); - } + int fx = getFieldbufferOffsetX_RND(); + int fy = getFieldbufferOffsetY_RND(); BlitBitmap(drawto_field, target_bitmap, fx, fy, SXSIZE, SYSIZE, SX, SY); } @@ -620,6 +759,13 @@ void BackToFront() y2 = MAX(y2, EY + EYSIZE); } + // make sure that at least one pixel is blitted, and inside the screen + // (else nothing is blitted, causing the animations not to be updated) + x1 = MIN(MAX(0, x1), WIN_XSIZE - 1); + y1 = MIN(MAX(0, y1), WIN_YSIZE - 1); + x2 = MIN(MAX(1, x2), WIN_XSIZE); + y2 = MIN(MAX(1, y2), WIN_YSIZE); + BlitBitmap(backbuffer, window, x1, y1, x2 - x1, y2 - y1, x1, y1); } @@ -787,6 +933,10 @@ void FadeIn(int fade_mask) FADE_SXSIZE = FULL_SXSIZE; FADE_SYSIZE = FULL_SYSIZE; + if (game_status == GAME_MODE_PLAYING && + strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS)) + SetOverlayActive(TRUE); + SetScreenStates_AfterFadingIn(); // force update of global animation status in case of rapid screen changes @@ -802,6 +952,8 @@ void FadeOut(int fade_mask) SetScreenStates_BeforeFadingOut(); + SetOverlayActive(FALSE); + #if 0 DrawMaskedBorder(REDRAW_ALL); #endif @@ -1219,52 +1371,64 @@ int getGraphicAnimationFrame(int graphic, int sync_frame) sync_frame); } -void getSizedGraphicSourceExt(int graphic, int frame, int tilesize, - Bitmap **bitmap, int *x, int *y, - boolean get_backside) +void getGraphicSourceBitmap(int graphic, int tilesize, Bitmap **bitmap) { struct GraphicInfo *g = &graphic_info[graphic]; - Bitmap *src_bitmap = g->bitmap; - int src_x = g->src_x + (get_backside ? g->offset2_x : 0); - int src_y = g->src_y + (get_backside ? g->offset2_y : 0); int tilesize_capped = MIN(MAX(1, tilesize), TILESIZE); - // if no in-game graphics defined, always use standard graphic size - if (g->bitmaps[IMG_BITMAP_GAME] == NULL) - tilesize = TILESIZE; - if (tilesize == gfx.standard_tile_size) - src_bitmap = g->bitmaps[IMG_BITMAP_STANDARD]; + *bitmap = g->bitmaps[IMG_BITMAP_STANDARD]; else if (tilesize == game.tile_size) - src_bitmap = g->bitmaps[IMG_BITMAP_GAME]; + *bitmap = g->bitmaps[IMG_BITMAP_GAME]; else - src_bitmap = g->bitmaps[IMG_BITMAP_1x1 - log_2(tilesize_capped)]; + *bitmap = g->bitmaps[IMG_BITMAP_1x1 - log_2(tilesize_capped)]; +} + +void getGraphicSourceXY(int graphic, int frame, int *x, int *y, + boolean get_backside) +{ + struct GraphicInfo *g = &graphic_info[graphic]; + int src_x = g->src_x + (get_backside ? g->offset2_x : 0); + int src_y = g->src_y + (get_backside ? g->offset2_y : 0); if (g->offset_y == 0) /* frames are ordered horizontally */ { int max_width = g->anim_frames_per_line * g->width; int pos = (src_y / g->height) * max_width + src_x + frame * g->offset_x; - src_x = pos % max_width; - src_y = src_y % g->height + pos / max_width * g->height; + *x = pos % max_width; + *y = src_y % g->height + pos / max_width * g->height; } else if (g->offset_x == 0) /* frames are ordered vertically */ { int max_height = g->anim_frames_per_line * g->height; int pos = (src_x / g->width) * max_height + src_y + frame * g->offset_y; - src_x = src_x % g->width + pos / max_height * g->width; - src_y = pos % max_height; + *x = src_x % g->width + pos / max_height * g->width; + *y = pos % max_height; } else /* frames are ordered diagonally */ { - src_x = src_x + frame * g->offset_x; - src_y = src_y + frame * g->offset_y; + *x = src_x + frame * g->offset_x; + *y = src_y + frame * g->offset_y; } +} + +void getSizedGraphicSourceExt(int graphic, int frame, int tilesize, + Bitmap **bitmap, int *x, int *y, + boolean get_backside) +{ + struct GraphicInfo *g = &graphic_info[graphic]; - *bitmap = src_bitmap; - *x = src_x * tilesize / g->tile_size; - *y = src_y * tilesize / g->tile_size; + // if no in-game graphics defined, always use standard graphic size + if (g->bitmaps[IMG_BITMAP_GAME] == NULL) + tilesize = TILESIZE; + + getGraphicSourceBitmap(graphic, tilesize, bitmap); + getGraphicSourceXY(graphic, frame, x, y, get_backside); + + *x = *x * tilesize / g->tile_size; + *y = *y * tilesize / g->tile_size; } void getFixedGraphicSourceExt(int graphic, int frame, Bitmap **bitmap, @@ -1294,40 +1458,8 @@ void getMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) inline static void getGraphicSourceExt(int graphic, int frame, Bitmap **bitmap, int *x, int *y, boolean get_backside) { - struct GraphicInfo *g = &graphic_info[graphic]; - int src_x = g->src_x + (get_backside ? g->offset2_x : 0); - int src_y = g->src_y + (get_backside ? g->offset2_y : 0); - - if (TILESIZE_VAR != TILESIZE) - return getSizedGraphicSourceExt(graphic, frame, TILESIZE_VAR, bitmap, x, y, - get_backside); - - *bitmap = g->bitmap; - - if (g->offset_y == 0) /* frames are ordered horizontally */ - { - int max_width = g->anim_frames_per_line * g->width; - int pos = (src_y / g->height) * max_width + src_x + frame * g->offset_x; - - *x = pos % max_width; - *y = src_y % g->height + pos / max_width * g->height; - } - else if (g->offset_x == 0) /* frames are ordered vertically */ - { - int max_height = g->anim_frames_per_line * g->height; - int pos = (src_x / g->width) * max_height + src_y + frame * g->offset_y; - - *x = src_x % g->width + pos / max_height * g->width; - *y = pos % max_height; - } - else /* frames are ordered diagonally */ - { - *x = src_x + frame * g->offset_x; - *y = src_y + frame * g->offset_y; - } - - *x = *x * TILESIZE_VAR / g->tile_size; - *y = *y * TILESIZE_VAR / g->tile_size; + getSizedGraphicSourceExt(graphic, frame, TILESIZE_VAR, bitmap, x, y, + get_backside); } void getGraphicSource(int graphic, int frame, Bitmap **bitmap, int *x, int *y) @@ -1780,6 +1912,9 @@ static void DrawLevelFieldCrumbledInnerCorners(int x, int y, int dx, int dy, int width, height, cx, cy; int sx = SCREENX(x), sy = SCREENY(y); int crumbled_border_size = graphic_info[graphic].border_size; + int crumbled_tile_size = graphic_info[graphic].tile_size; + int crumbled_border_size_var = + crumbled_border_size * TILESIZE_VAR / crumbled_tile_size; int i; getGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y); @@ -1807,8 +1942,8 @@ static void DrawLevelFieldCrumbledInnerCorners(int x, int y, int dx, int dy, getGraphicSource(graphic, 1, &src_bitmap, &src_x, &src_y); - width = crumbled_border_size * TILESIZE_VAR / TILESIZE; - height = crumbled_border_size * TILESIZE_VAR / TILESIZE; + width = crumbled_border_size_var; + height = crumbled_border_size_var; cx = (dx > 0 ? TILESIZE_VAR - width : 0); cy = (dy > 0 ? TILESIZE_VAR - height : 0); @@ -1824,7 +1959,9 @@ static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame, int width, height, bx, by, cx, cy; int sx = SCREENX(x), sy = SCREENY(y); int crumbled_border_size = graphic_info[graphic].border_size; - int crumbled_border_size_var = crumbled_border_size * TILESIZE_VAR / TILESIZE; + int crumbled_tile_size = graphic_info[graphic].tile_size; + int crumbled_border_size_var = + crumbled_border_size * TILESIZE_VAR / crumbled_tile_size; int crumbled_border_pos_var = TILESIZE_VAR - crumbled_border_size_var; int i; @@ -1843,7 +1980,7 @@ static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame, /* (remaining middle border part must be at least as big as corner part) */ if (!(graphic_info[graphic].style & STYLE_ACCURATE_BORDERS) || - crumbled_border_size >= TILESIZE / 3) + crumbled_border_size_var >= TILESIZE_VAR / 3) return; /* correct corners of crumbled border, if needed */ @@ -1911,12 +2048,12 @@ static void DrawLevelFieldCrumbledExt(int x, int y, int graphic, int frame) element = TILE_GFX_ELEMENT(x, y); - /* crumble field itself */ - if (IS_CRUMBLED_TILE(x, y, element)) + if (IS_CRUMBLED_TILE(x, y, element)) /* crumble field itself */ { if (!IN_SCR_FIELD(sx, sy)) return; + /* crumble field borders towards direct neighbour fields */ for (i = 0; i < 4; i++) { int xx = x + xy[i][0]; @@ -1934,6 +2071,7 @@ static void DrawLevelFieldCrumbledExt(int x, int y, int graphic, int frame) DrawLevelFieldCrumbledBorders(x, y, graphic, frame, i); } + /* crumble inner field corners towards corner neighbour fields */ if ((graphic_info[graphic].style & STYLE_INNER_CORNERS) && graphic_info[graphic].anim_frames == 2) { @@ -1948,8 +2086,9 @@ static void DrawLevelFieldCrumbledExt(int x, int y, int graphic, int frame) MarkTileDirty(sx, sy); } - else /* center field not crumbled -- crumble neighbour fields */ + else /* center field is not crumbled -- crumble neighbour fields */ { + /* crumble field borders of direct neighbour fields */ for (i = 0; i < 4; i++) { int xx = x + xy[i][0]; @@ -1975,6 +2114,37 @@ static void DrawLevelFieldCrumbledExt(int x, int y, int graphic, int frame) MarkTileDirty(sxx, syy); } + + /* crumble inner field corners of corner neighbour fields */ + for (i = 0; i < 4; i++) + { + int dx = (i & 1 ? +1 : -1); + int dy = (i & 2 ? +1 : -1); + int xx = x + dx; + int yy = y + dy; + int sxx = sx + dx; + int syy = sy + dy; + + if (!IN_LEV_FIELD(xx, yy) || + !IN_SCR_FIELD(sxx, syy)) + continue; + + if (Feld[xx][yy] == EL_ELEMENT_SNAPPING) + continue; + + element = TILE_GFX_ELEMENT(xx, yy); + + if (!IS_CRUMBLED_TILE(xx, yy, element)) + continue; + + graphic = el_act2crm(element, ACTION_DEFAULT); + + if ((graphic_info[graphic].style & STYLE_INNER_CORNERS) && + graphic_info[graphic].anim_frames == 2) + DrawLevelFieldCrumbledInnerCorners(xx, yy, -dx, -dy, graphic); + + MarkTileDirty(sxx, syy); + } } } @@ -2024,6 +2194,7 @@ void DrawLevelFieldCrumbledNeighbours(int x, int y) }; int i; + /* crumble direct neighbour fields (required for field borders) */ for (i = 0; i < 4; i++) { int xx = x + xy[i][0]; @@ -2039,6 +2210,30 @@ void DrawLevelFieldCrumbledNeighbours(int x, int y) DrawLevelField(xx, yy); } + + /* crumble corner neighbour fields (required for inner field corners) */ + for (i = 0; i < 4; i++) + { + int dx = (i & 1 ? +1 : -1); + int dy = (i & 2 ? +1 : -1); + int xx = x + dx; + int yy = y + dy; + int sxx = sx + dx; + int syy = sy + dy; + + if (!IN_LEV_FIELD(xx, yy) || + !IN_SCR_FIELD(sxx, syy) || + !GFX_CRUMBLED(Feld[xx][yy]) || + IS_MOVING(xx, yy)) + continue; + + int element = TILE_GFX_ELEMENT(xx, yy); + int graphic = el_act2crm(element, ACTION_DEFAULT); + + if ((graphic_info[graphic].style & STYLE_INNER_CORNERS) && + graphic_info[graphic].anim_frames == 2) + DrawLevelField(xx, yy); + } } static int getBorderElement(int x, int y) @@ -2140,6 +2335,10 @@ void DrawScreenField(int x, int y) int newly = ly + (dir == MV_UP ? -1 : dir == MV_DOWN ? +1 : 0); DrawLevelElementThruMask(newlx, newly, EL_ACID); + + // prevent target field from being drawn again (but without masking) + // (this would happen if target field is scanned after moving element) + Stop[newlx][newly] = TRUE; } } else if (IS_BLOCKED(lx, ly)) @@ -3685,7 +3884,10 @@ static int RequestHandleEvents(unsigned int req_state) } case EVENT_KEYPRESS: - switch (GetEventKey((KeyEvent *)&event, TRUE)) + { + Key key = GetEventKey((KeyEvent *)&event, TRUE); + + switch (key) { case KSYM_space: if (req_state & REQ_CONFIRM) @@ -3707,12 +3909,15 @@ static int RequestHandleEvents(unsigned int req_state) break; default: + HandleKeysDebug(key); break; } if (req_state & REQ_PLAYER) result = 0; + break; + } case EVENT_KEYRELEASE: ClearPlayerAction(); @@ -4019,10 +4224,19 @@ static boolean RequestEnvelope(char *text, unsigned int req_state) boolean Request(char *text, unsigned int req_state) { + boolean overlay_active = GetOverlayActive(); + boolean result; + + SetOverlayActive(FALSE); + if (global.use_envelope_request) - return RequestEnvelope(text, req_state); + result = RequestEnvelope(text, req_state); else - return RequestDoor(text, req_state); + result = RequestDoor(text, req_state); + + SetOverlayActive(overlay_active); + + return result; } static int compareDoorPartOrderInfo(const void *object1, const void *object2) @@ -4474,7 +4688,8 @@ unsigned int MoveDoor(unsigned int door_state) int sync_frame = kk_door * door_delay_value; int frame = getGraphicAnimationFrame(dpc->graphic, sync_frame); - getGraphicSource(dpc->graphic, frame, &bitmap, &g_src_x, &g_src_y); + getFixedGraphicSource(dpc->graphic, frame, &bitmap, + &g_src_x, &g_src_y); } // draw door panel @@ -7278,6 +7493,7 @@ inline static void set_crumbled_graphics_EM(struct GraphicInfo_EM *g_em, &g_em->crumbled_src_x, &g_em->crumbled_src_y); g_em->crumbled_border_size = graphic_info[crumbled].border_size; + g_em->crumbled_tile_size = graphic_info[crumbled].tile_size; g_em->has_crumbled_graphics = TRUE; } @@ -7287,6 +7503,7 @@ inline static void set_crumbled_graphics_EM(struct GraphicInfo_EM *g_em, g_em->crumbled_src_x = 0; g_em->crumbled_src_y = 0; g_em->crumbled_border_size = 0; + g_em->crumbled_tile_size = 0; g_em->has_crumbled_graphics = FALSE; } @@ -8046,42 +8263,38 @@ void CheckSaveEngineSnapshot_EM(byte action[MAX_PLAYERS], int frame, boolean any_player_snapping, boolean any_player_dropping) { - static boolean player_was_waiting = TRUE; - if (frame == 0 && !any_player_dropping) { - if (!player_was_waiting) + if (!local_player->was_waiting) { - if (!SaveEngineSnapshotToList()) + if (!CheckSaveEngineSnapshotToList()) return; - player_was_waiting = TRUE; + local_player->was_waiting = TRUE; } } else if (any_player_moving || any_player_snapping || any_player_dropping) { - player_was_waiting = FALSE; + local_player->was_waiting = FALSE; } } void CheckSaveEngineSnapshot_SP(boolean murphy_is_waiting, boolean murphy_is_dropping) { - static boolean player_was_waiting = TRUE; - if (murphy_is_waiting) { - if (!player_was_waiting) + if (!local_player->was_waiting) { - if (!SaveEngineSnapshotToList()) + if (!CheckSaveEngineSnapshotToList()) return; - player_was_waiting = TRUE; + local_player->was_waiting = TRUE; } } else { - player_was_waiting = FALSE; + local_player->was_waiting = FALSE; } } @@ -8192,7 +8405,37 @@ void PlayMenuMusicExt(int music) void PlayMenuMusic() { - PlayMenuMusicExt(menu.music[game_status]); + char *curr_music = getCurrentlyPlayingMusicFilename(); + char *next_music = getMusicListEntry(menu.music[game_status])->filename; + + if (!strEqual(curr_music, next_music)) + PlayMenuMusicExt(menu.music[game_status]); +} + +void PlayMenuSoundsAndMusic() +{ + PlayMenuSound(); + PlayMenuMusic(); +} + +static void FadeMenuSounds() +{ + FadeSounds(); +} + +static void FadeMenuMusic() +{ + char *curr_music = getCurrentlyPlayingMusicFilename(); + char *next_music = getMusicListEntry(menu.music[game_status])->filename; + + if (!strEqual(curr_music, next_music)) + FadeMusic(); +} + +void FadeMenuSoundsAndMusic() +{ + FadeMenuSounds(); + FadeMenuMusic(); } void PlaySoundActivating() @@ -8301,6 +8544,9 @@ void SetAnimStatus(int anim_status_new) void SetGameStatus(int game_status_new) { + if (game_status_new != game_status) + game_status_last_screen = game_status; + game_status = game_status_new; SetAnimStatus(game_status_new);