| 138 | FILE *fp; |
| 139 | |
| 140 | DISABLE_WARNING_UNREACHABLE_CODE |
| 141 | |
| 142 | int |
| 143 | main(int argc, char *argv[]) |
| 144 | { |
| 145 | int i, j, number_of_rows, number_in_final_row; |
| 146 | uchar *c; |
| 147 | char tilefile_full_path[256] = { 0 }; |
| 148 | |
| 149 | if (argc != 2) { |
| 150 | Fprintf(stderr, "usage: %s outfile.bmp\n", argv[0]); |
| 151 | exit(EXIT_FAILURE); |
| 152 | } else if (argv[1] == 0 || strlen(argv[1]) >= sizeof bmpname - 1) { |
| 153 | Fprintf(stderr, "invalid output bmp file name %s, aborting.\n", |
| 154 | argv[0]); |
| 155 | exit(EXIT_FAILURE); |
| 156 | } else { |
| 157 | strcpy(bmpname, argv[1]); |
| 158 | } |
| 159 | |
| 160 | objects_globals_init(); |
| 161 | monst_globals_init(); |
| 162 | |
| 163 | /* tilefileset = (TILE_X == 64) ? 2 : (TILE_X == 32) ? 1 : 0; */ |
| 164 | tilefileset = 0; |
| 165 | if (!examine_tilefiles()) { |
| 166 | Fprintf(stderr, "unable to open all of the tile files, aborting.\n"); |
| 167 | exit(EXIT_FAILURE); |
| 168 | } |
| 169 | for (i = 0; i < SIZE(tilecnt); ++i) |
| 170 | magictileno += tilecnt[i]; |
| 171 | /* count monsters twice for grayscale variation */ |
| 172 | magictileno += tilecnt[0]; |
| 173 | |
| 174 | max_x = TILE_X * max_tiles_in_row; |
| 175 | max_y = ((TILE_Y * magictileno) / max_tiles_in_row) + TILE_Y; |
| 176 | bmpsize = (sizeof bmp - sizeof bmp.packtile) |
| 177 | + (max_y * (max_x * sizeof(uchar))); |
| 178 | newbmp = malloc(bmpsize); |
| 179 | if (!newbmp) { |
| 180 | printf("memory allocation failure, %d %d, aborting.\n", |
| 181 | bmpsize, magictileno); |
| 182 | exit(EXIT_FAILURE); |
| 183 | } |
| 184 | tiles_counted = 0; |
| 185 | xoffset = yoffset = 0; |
| 186 | initflag = 0; |
| 187 | filenum = 0; |
| 188 | pass = 0; |
| 189 | fp = fopen(bmpname, "wb"); |
| 190 | if (!fp) { |
| 191 | printf("Error creating tile file %s, aborting.\n", bmpname); |
| 192 | exit(EXIT_FAILURE); |
| 193 | } |
| 194 | while (pass < 4) { |
| 195 | filenum = pass % SIZE(tilefilenames[tilefileset]); |
| 196 | if (!set_tilefile_path(relative_tiledir, |
| 197 | tilefilenames[tilefileset][filenum], |
nothing calls this directly
no test coverage detected