From e9a2ad8e81bf0e14cc74ea38e03ac15e2e222633 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Fri, 11 Nov 2011 15:39:23 +0000 Subject: [PATCH] =?UTF-8?q?Tilemap:=20Support=20for=20x-flipped=20and=20xy?= =?UTF-8?q?-flipped=20(180=C2=B0)=20tiles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1864 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/tiles.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++-- src/tiles.h | 7 +++++ 2 files changed, 91 insertions(+), 3 deletions(-) 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