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>
87 }
90 {
93 #ifndef WIN32
101 #else
103 #endif
105 }
124 }
125 }
126 }
145 }
146 }
166 }
168 }
169 }
176 }
178 }
182 {
188 }
192 // build wad directory
198 wad_t w;
203 }
208 }
214 }
226 }
232 }
234 //fclose(h);
241 }
250 }
254 }
261 }
262 }
268 }
282 }
286 }
292 }
293 }
294 }
295 }
296 }
297 }
300 }
302 // allocate resources
303 // (called from M_startup)
311 }
313 // load resource
330 }
343 }
345 // get resource id
352 }
354 // get resource id
360 }
364 }
366 // get sprite id
380 }
383 }
387 }
402 }
404 }
411 }
412 }
414 // reads bytes from file until CR
424 }
426 i++;
427 }
429 }
431 // reads bytes from file until NUL
441 }
443 i++;
444 }
446 }
448 map_block_t blk;
453 map_header_t hdr;
462 }
469 }
473 }
480 }
481 }
482 }
483 }
485 }
486 }
488 /*void F_freemus(void) {
490 int i;
492 if(!pat) return;
493 S_stopmusic();
494 free(pat);free(patp);
495 for(i=0;i<inum;++i) if(dmi[i]!=NULL) free(dmi[i]);
496 free(dmi);
497 pat=NULL;
499 }
500 */
502 /*void F_loadmus(char n[8]) {
503 int r,i,j;
504 FILE *h;
505 int o;
506 struct{
507 char id[4];
508 byte ver,pat;
509 word psz;
510 }d;
511 struct{byte t;char n[13];word r;}di;
513 if((r=F_findres(n))==-1) return;
514 fseek(h=wadh[wad[r].f],wad[r].o,SEEK_SET);
515 myfread(&d,1,sizeof(d),h);
516 if(memcmp(d.id,"DMM",4)!=0) return;
517 if(!(pat=malloc(d.psz<<2))) return;
518 myfread(pat,1,d.psz<<2,h);
519 myfread(&seqn,1,1,h);if(seqn) myfread(seq,1,seqn,h);
520 inum=0;myfread(&inum,1,1,h);
521 if(!(dmi=malloc(inum*4))) {free(pat);pat=NULL;return;}
522 if(!(patp=malloc((word)d.pat*32))) {free(pat);free(dmi);pat=NULL;return;}
523 for(i=0;i<inum;++i) {
524 dmi[i]=NULL;
525 myfread(&di,1,16,h);o=ftell(h);
526 for(r=0;r<12;++r) if(di.n[r]=='.') di.n[r]=0;
527 if((r=F_findres(di.n))==-1) continue;
528 if(!(dmi[i]=malloc(wad[r].l+8))) continue;
529 memset(dmi[i],0,16);
530 F_loadres(r,dmi[i],0,2);
531 F_loadres(r,(int*)dmi[i]+1,2,2);
532 F_loadres(r,(int*)dmi[i]+2,4,2);
533 F_loadres(r,(int*)dmi[i]+3,6,2);
534 F_loadres(r,(int*)dmi[i]+4,8,wad[r].l-8);
535 fseek(h,o,SEEK_SET);
536 }
537 for(i=r=0,j=(word)d.pat<<3;i<j;++i) {
538 patp[i]=r<<2;
539 while(pat[r++].v!=0x80);
540 }
541 }
542 */