X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=4f0206e36d8b86a21447332f2829f59295bdf67e;hb=d798911a09cd2a58ccb0378f4a94e6d44b3e0039;hp=36545249731128e0bf8c7556043a3272a118c9e3;hpb=0e571d5d795b7ab85fd0f57f0a9e71295dac86f2;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 36545249..4f0206e3 100644 --- a/src/tools.c +++ b/src/tools.c @@ -360,10 +360,12 @@ static int getLevelFromScreenY_SP(int sy) static int getLevelFromScreenX_MM(int sx) { +#if 0 int level_xsize = level.native_mm_level->fieldx; int full_xsize = level_xsize * TILESIZE_VAR; sx -= (full_xsize < SXSIZE ? (SXSIZE - full_xsize) / 2 : 0); +#endif int px = sx - SX; int lx = px / TILESIZE_VAR; @@ -373,10 +375,12 @@ static int getLevelFromScreenX_MM(int sx) static int getLevelFromScreenY_MM(int sy) { +#if 0 int level_ysize = level.native_mm_level->fieldy; int full_ysize = level_ysize * TILESIZE_VAR; sy -= (full_ysize < SYSIZE ? (SYSIZE - full_ysize) / 2 : 0); +#endif int py = sy - SY; int ly = py / TILESIZE_VAR; @@ -412,6 +416,7 @@ void DumpTile(int x, int y) { int sx = SCREENX(x); int sy = SCREENY(y); + char *token_name; printf_line("-", 79); printf("Field Info: SCREEN(%d, %d), LEVEL(%d, %d)\n", sx, sy, x, y); @@ -425,8 +430,9 @@ void DumpTile(int x, int y) return; } - printf(" Feld: %d\t['%s']\n", Feld[x][y], - element_info[Feld[x][y]].token_name); + token_name = element_info[Feld[x][y]].token_name; + + printf(" Feld: %d\t['%s']\n", Feld[x][y], token_name); printf(" Back: %s\n", print_if_not_empty(Back[x][y])); printf(" Store: %s\n", print_if_not_empty(Store[x][y])); printf(" Store2: %s\n", print_if_not_empty(Store2[x][y])); @@ -1354,6 +1360,10 @@ void SetBorderElement() BorderElement = EL_EMPTY; + /* the MM game engine does not use a visible border element */ + if (level.game_engine_type == GAME_ENGINE_TYPE_MM) + return; + for (y = 0; y < lev_fieldy && BorderElement == EL_EMPTY; y++) { for (x = 0; x < lev_fieldx; x++) @@ -1367,9 +1377,10 @@ void SetBorderElement() } } -void FloodFillLevel(int from_x, int from_y, int fill_element, - short field[MAX_LEV_FIELDX][MAX_LEV_FIELDY], - int max_fieldx, int max_fieldy) +void FloodFillLevelExt(int from_x, int from_y, int fill_element, + int max_array_fieldx, int max_array_fieldy, + short field[max_array_fieldx][max_array_fieldy], + int max_fieldx, int max_fieldy) { int i,x,y; int old_element; @@ -1394,12 +1405,22 @@ void FloodFillLevel(int from_x, int from_y, int fill_element, y = from_y + check[i][1]; if (IN_FIELD(x, y, max_fieldx, max_fieldy) && field[x][y] == old_element) - FloodFillLevel(x, y, fill_element, field, max_fieldx, max_fieldy); + FloodFillLevelExt(x, y, fill_element, max_array_fieldx, max_array_fieldy, + field, max_fieldx, max_fieldy); } safety--; } +void FloodFillLevel(int from_x, int from_y, int fill_element, + short field[MAX_LEV_FIELDX][MAX_LEV_FIELDY], + int max_fieldx, int max_fieldy) +{ + FloodFillLevelExt(from_x, from_y, fill_element, + MAX_LEV_FIELDX, MAX_LEV_FIELDY, field, + max_fieldx, max_fieldy); +} + void SetRandomAnimationValue(int x, int y) { gfx.anim_random_frame = GfxRandom[x][y]; @@ -1625,6 +1646,14 @@ void DrawSizedGraphic(int x, int y, int graphic, int frame, int tilesize) MarkTileDirty(x / tilesize, y / tilesize); } +void DrawSizedGraphicThruMask(int x, int y, int graphic, int frame, + int tilesize) +{ + DrawSizedGraphicThruMaskExt(drawto, SX + x * tilesize, SY + y * tilesize, + graphic, frame, tilesize); + MarkTileDirty(x / tilesize, y / tilesize); +} + void DrawSizedGraphicExt(DrawBuffer *d, int x, int y, int graphic, int frame, int tilesize) { @@ -1635,6 +1664,16 @@ void DrawSizedGraphicExt(DrawBuffer *d, int x, int y, int graphic, int frame, BlitBitmap(src_bitmap, d, src_x, src_y, tilesize, tilesize, x, y); } +void DrawSizedGraphicThruMaskExt(DrawBuffer *d, int x, int y, int graphic, + int frame, int tilesize) +{ + Bitmap *src_bitmap; + int src_x, src_y; + + getSizedGraphicSource(graphic, frame, tilesize, &src_bitmap, &src_x, &src_y); + BlitBitmapMasked(src_bitmap, d, src_x, src_y, tilesize, tilesize, x, y); +} + void DrawMiniGraphic(int x, int y, int graphic) { DrawMiniGraphicExt(drawto, SX + x * MINI_TILEX,SY + y * MINI_TILEY, graphic); @@ -2446,8 +2485,8 @@ void DrawLevelField(int x, int y) } } -void DrawSizedWall_MM(int dst_x, int dst_y, int element, int tilesize, - int (*el2img_function)(int)) +static void DrawSizedWallExt_MM(int dst_x, int dst_y, int element, int tilesize, + int (*el2img_function)(int), boolean masked) { int element_base = map_mm_wall_element(element); int element_bits = (IS_DF_WALL(element) ? @@ -2467,28 +2506,58 @@ void DrawSizedWall_MM(int dst_x, int dst_y, int element, int tilesize, int dst_draw_y = dst_y + (i / 2) * tilesize_draw; if (element_bits & (1 << i)) - BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize_draw, tilesize_draw, - dst_draw_x, dst_draw_y); + { + if (masked) + BlitBitmapMasked(src_bitmap, drawto, src_x, src_y, + tilesize_draw, tilesize_draw, dst_draw_x, dst_draw_y); + else + BlitBitmap(src_bitmap, drawto, src_x, src_y, + tilesize_draw, tilesize_draw, dst_draw_x, dst_draw_y); + } else - ClearRectangle(drawto, dst_x, dst_y, tilesize_draw, tilesize_draw); + { + if (!masked) + ClearRectangle(drawto, dst_draw_x, dst_draw_y, + tilesize_draw, tilesize_draw); + } } } -void DrawSizedElement(int x, int y, int element, int tilesize) +void DrawSizedWall_MM(int dst_x, int dst_y, int element, int tilesize, + int (*el2img_function)(int)) +{ + DrawSizedWallExt_MM(dst_x, dst_y, element, tilesize, el2img_function, FALSE); +} + +void DrawSizedElementExt(int x, int y, int element, int tilesize, + boolean masked) { if (IS_MM_WALL(element)) { - DrawSizedWall_MM(SX + x * tilesize, SY + y * tilesize, - element, tilesize, el2edimg); + DrawSizedWallExt_MM(SX + x * tilesize, SY + y * tilesize, + element, tilesize, el2edimg, masked); } else { int graphic = el2edimg(element); - DrawSizedGraphic(x, y, graphic, 0, tilesize); + if (masked) + DrawSizedGraphicThruMask(x, y, graphic, 0, tilesize); + else + DrawSizedGraphic(x, y, graphic, 0, tilesize); } } +void DrawSizedElement(int x, int y, int element, int tilesize) +{ + DrawSizedElementExt(x, y, element, tilesize, FALSE); +} + +void DrawSizedElementThruMask(int x, int y, int element, int tilesize) +{ + DrawSizedElementExt(x, y, element, tilesize, TRUE); +} + void DrawMiniElement(int x, int y, int element) { int graphic; @@ -7354,6 +7423,21 @@ int map_mm_wall_element(int element) element); } +int map_mm_wall_element_editor(int element) +{ + switch (element) + { + case EL_MM_STEEL_WALL: return EL_MM_STEEL_WALL_START; + case EL_MM_WOODEN_WALL: return EL_MM_WOODEN_WALL_START; + case EL_MM_ICE_WALL: return EL_MM_ICE_WALL_START; + case EL_MM_AMOEBA_WALL: return EL_MM_AMOEBA_WALL_START; + case EL_DF_STEEL_WALL: return EL_DF_STEEL_WALL_START; + case EL_DF_WOODEN_WALL: return EL_DF_WOODEN_WALL_START; + + default: return element; + } +} + int get_next_element(int element) { switch (element)