diff --git a/src/tiles.c b/src/tiles.c index 40b6d2c1..10e8edc2 100644 --- a/src/tiles.c +++ b/src/tiles.c @@ -195,7 +195,25 @@ int Tile_is_same(int t1, int t2) } /// -int Tile_is_same_y(int t1, int t2) +int Tile_is_same_flipped_x(int t1, int t2) +{ + byte *bmp1,*bmp2; + int y, x; + + bmp1 = Main_backups->Pages->Image[Main_current_layer].Pixels+(TILE_Y(t1))*Main_image_width+(TILE_X(t1)); + bmp2 = Main_backups->Pages->Image[Main_current_layer].Pixels+(TILE_Y(t2))*Main_image_width+(TILE_X(t2)+Snap_width-1); + + for (y=0; y < Snap_height; y++) + { + for (x=0; x < Snap_width; x++) + if (*(bmp1+y*Main_image_width+x) != *(bmp2+y*Main_image_width-x)) + return 0; + } + return 1; +} + +/// +int Tile_is_same_flipped_y(int t1, int t2) { byte *bmp1,*bmp2; int y; @@ -211,6 +229,25 @@ int Tile_is_same_y(int t1, int t2) return 1; } + +/// +int Tile_is_same_flipped_xy(int t1, int t2) +{ + byte *bmp1,*bmp2; + int y, x; + + bmp1 = Main_backups->Pages->Image[Main_current_layer].Pixels+(TILE_Y(t1))*Main_image_width+(TILE_X(t1)); + bmp2 = Main_backups->Pages->Image[Main_current_layer].Pixels+(TILE_Y(t2)+Snap_height-1)*Main_image_width+(TILE_X(t2)+Snap_width-1); + + for (y=0; y < Snap_height; y++) + { + for (x=0; x < Snap_width; x++) + if (*(bmp1+y*Main_image_width+x) != *(bmp2-y*Main_image_width-x)) + return 0; + } + return 1; +} + /// Create or update a tilemap based on current screen pixels. void Tilemap_create(void) { @@ -293,7 +330,7 @@ void Tilemap_create(void) for (ref_tile=0; ref_tile