1 /*
2 Copyright (C) Prikol Software 1996-1997
3 Copyright (C) Aleksey Volynskov 1996-1997
4 Copyright (C) <ARembo@gmail.com> 2011
6 This file is part of the Doom2D:Rembo project.
8 Doom2D:Rembo is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as
10 published by the Free Software Foundation.
12 Doom2D:Rembo is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see <http://www.gnu.org/licenses/> or
19 write to the Free Software Foundation, Inc.,
20 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
24 #include <stdio.h>
25 #include <string.h>
26 #include <stdlib.h>
27 #include <sys/stat.h>
51 map_block_t blk;
75 }
80 #ifndef WIN32
88 #else
90 #endif
92 }
111 }
112 }
113 }
132 }
133 }
153 }
155 }
156 }
163 }
165 }
173 }
175 // build wad directory
181 wad_t w;
186 }
191 }
197 }
209 }
215 }
217 //fclose(h);
224 }
233 }
237 }
244 }
245 }
251 }
265 }
269 }
275 }
276 }
277 }
278 }
279 }
280 }
283 }
285 // allocate resources
286 // (called from M_startup)
294 }
296 // load resource
313 }
315 /*
316 // unused
317 void F_saveres(int r, void *p, dword o, dword l) {
318 FILE* fh = wadh[wad[r].f];
319 int oo = ftell(fh);
320 if (fseek(fh, wad[r].o + o, SEEK_SET) != 0) {
321 ERR_fatal("Ошибка при чтении файла");
322 }
323 myfwrite(p, l, 1, fh);
324 fseek(fh, oo, SEEK_SET);
325 }
326 */
328 // get resource id
334 }
335 }
337 }
339 // get resource id
344 }
346 }
350 }
352 // get sprite id
366 }
369 }
373 }
388 }
390 }
397 }
398 }
400 // reads bytes from file until CR
410 }
412 i++;
413 }
415 }
417 /*
418 // unused
419 // reads bytes from file until NUL
420 void F_readstrz (FILE* h,char *s,int m) {
421 int i = 0;
422 size_t len = 0;
423 static char c = 0;
424 while (i < m) {
425 c = 0;
426 len = myfreadc(&c, 1, 1, h);
427 if (len == 0 || c == 0) {
428 break;
429 }
430 s[i] = c;
431 i++;
432 }
433 s[i] = 0;
434 }
435 */
440 map_header_t hdr;
449 }
456 }
460 }
467 }
468 }
469 }
470 }
472 }
473 }
475 /*void F_freemus(void) {
477 int i;
479 if(!pat) return;
480 S_stopmusic();
481 free(pat);free(patp);
482 for(i=0;i<inum;++i) if(dmi[i]!=NULL) free(dmi[i]);
483 free(dmi);
484 pat=NULL;
486 }
487 */
489 /*void F_loadmus(char n[8]) {
490 int r,i,j;
491 FILE *h;
492 int o;
493 struct{
494 char id[4];
495 byte ver,pat;
496 word psz;
497 }d;
498 struct{byte t;char n[13];word r;}di;
500 if((r=F_findres(n))==-1) return;
501 fseek(h=wadh[wad[r].f],wad[r].o,SEEK_SET);
502 myfread(&d,1,sizeof(d),h);
503 if(memcmp(d.id,"DMM",4)!=0) return;
504 if(!(pat=malloc(d.psz<<2))) return;
505 myfread(pat,1,d.psz<<2,h);
506 myfread(&seqn,1,1,h);if(seqn) myfread(seq,1,seqn,h);
507 inum=0;myfread(&inum,1,1,h);
508 if(!(dmi=malloc(inum*4))) {free(pat);pat=NULL;return;}
509 if(!(patp=malloc((word)d.pat*32))) {free(pat);free(dmi);pat=NULL;return;}
510 for(i=0;i<inum;++i) {
511 dmi[i]=NULL;
512 myfread(&di,1,16,h);o=ftell(h);
513 for(r=0;r<12;++r) if(di.n[r]=='.') di.n[r]=0;
514 if((r=F_findres(di.n))==-1) continue;
515 if(!(dmi[i]=malloc(wad[r].l+8))) continue;
516 memset(dmi[i],0,16);
517 F_loadres(r,dmi[i],0,2);
518 F_loadres(r,(int*)dmi[i]+1,2,2);
519 F_loadres(r,(int*)dmi[i]+2,4,2);
520 F_loadres(r,(int*)dmi[i]+3,6,2);
521 F_loadres(r,(int*)dmi[i]+4,8,wad[r].l-8);
522 fseek(h,o,SEEK_SET);
523 }
524 for(i=r=0,j=(word)d.pat<<3;i<j;++i) {
525 patp[i]=r<<2;
526 while(pat[r++].v!=0x80);
527 }
528 }
529 */