23 static void expand_misc(
char **newlayout,
int i,
int j,
char **layout);
24 static void expand_wall(
char **newlayout,
int i,
int j,
char **layout,
int xsize,
int ysize);
25 static void expand_door(
char **newlayout,
int i,
int j,
char **layout,
int xsize,
int ysize);
39 char **
expand2x(
char **layout,
int xsize,
int ysize) {
41 int nxsize = xsize*2-1;
42 int nysize = ysize*2-1;
45 char **newlayout = (
char **)calloc(
sizeof(
char *), nxsize);
46 for (i = 0; i < nxsize; i++) {
47 newlayout[i] = (
char *)calloc(
sizeof(
char), nysize);
50 for (i = 0; i < xsize; i++) {
51 for (j = 0; j < ysize; j++) {
52 switch (layout[i][j]) {
68 for (i = 0; i < xsize; i++) {
89 static void expand_misc(
char **newlayout,
int i,
int j,
char **layout) {
90 newlayout[i*2][j*2] = layout[i][j];
115 static int calc_pattern(
char ch,
char **layout,
int i,
int j,
int xsize,
int ysize) {
118 if (i+1 < xsize && layout[i+1][j] == ch)
122 if (layout[i][j+1] == ch)
124 if (i+1 < xsize && layout[i+1][j+1] == ch)
146 static void expand_wall(
char **newlayout,
int i,
int j,
char **layout,
int xsize,
int ysize) {
147 int wall_pattern =
calc_pattern(
'#', layout, i, j, xsize, ysize);
148 int door_pattern =
calc_pattern(
'D', layout, i, j, xsize, ysize);
149 int both_pattern = wall_pattern|door_pattern;
151 newlayout[i*2][j*2] =
'#';
153 if (both_pattern&1) {
155 newlayout[i*2+1][j*2] = layout[i+1][j];
160 if (both_pattern&2) {
162 newlayout[i*2][j*2+1] = layout[i][j+1];
165 if (wall_pattern == 7) {
168 newlayout[i*2+1][j*2+1] =
'#';
188 static void expand_door(
char **newlayout,
int i,
int j,
char **layout,
int xsize,
int ysize) {
189 int wall_pattern =
calc_pattern(
'#', layout, i, j, xsize, ysize);
190 int door_pattern =
calc_pattern(
'D', layout, i, j, xsize, ysize);
196 if (wall_pattern&3) {
197 join_pattern = wall_pattern;
199 join_pattern = door_pattern;
202 newlayout[i*2][j*2] =
'D';
204 if (join_pattern&1) {
206 newlayout[i*2+1][j*2] =
'D';
211 if (join_pattern&2) {
213 newlayout[i*2][j*2+1] =
'D';
static void expand_wall(char **newlayout, int i, int j, char **layout, int xsize, int ysize)
static int calc_pattern(char ch, char **layout, int i, int j, int xsize, int ysize)
char ** expand2x(char **layout, int xsize, int ysize)
static void expand_door(char **newlayout, int i, int j, char **layout, int xsize, int ysize)
static void expand_misc(char **newlayout, int i, int j, char **layout)