/* * Expands a layout by 2x in each dimension. * H. S. Teoh * -------------------------------------------------------------------------- * $Id: expand2x.c,v 1.2 2006/08/13 17:16:03 elmex dead $ * * ALGORITHM * * ... (TBW) */ #include /* just in case */ #include /* use compiler to do sanity check */ /* PROTOTYPES */ static void expand_misc(char **newlayout, int i, int j, char **layout, int xsize, int ysize); static void expand_wall(char **newlayout, int i, int j, char **layout, int xsize, int ysize); static void expand_door(char **newlayout, int i, int j, char **layout, int xsize, int ysize); /* FUNCTIONS */ char **expand2x(char **layout, int xsize, int ysize) { int i,j; int nxsize = xsize*2 - 1; int nysize = ysize*2 - 1; /* Allocate new layout */ char **newlayout = (char **)calloc(sizeof(char*), nxsize); for (i=0; i X \0 * \0 \0 */ static void expand_misc(char **newlayout, int i, int j, char **layout, int xsize, int ysize) { newlayout[i*2][j*2] = layout[i][j]; /* (Note: no need to reset rest of 2x2 area to \0 because calloc does that * for us.) */ } /* Returns a bitmap that represents which squares on the right and bottom * edges of a square (i,j) match the given character: * 1 match on (i+1, j) * 2 match on (i, j+1) * 4 match on (i+1, j+1) * and the possible combinations thereof. */ static int calc_pattern(char ch, char **layout, int i, int j, int xsize, int ysize) { int pattern = 0; if (i+1