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>
86 }
89 {
92 #ifndef WIN32
100 #else
102 #endif
104 }
123 }
124 }
125 }
144 }
145 }
165 }
167 }
168 }
175 }
177 }
181 {
187 }
195 }
197 // build wad directory
203 wad_t w;
208 }
213 }
219 }
231 }
237 }
239 //fclose(h);
246 }
255 }
259 }
266 }
267 }
273 }
287 }
291 }
297 }
298 }
299 }
300 }
301 }
302 }
305 }
307 // allocate resources
308 // (called from M_startup)
316 }
318 // load resource
335 }
348 }
350 // get resource id
357 }
359 // get resource id
365 }
369 }
371 // get sprite id
385 }
388 }
392 }
407 }
409 }
416 }
417 }
419 // reads bytes from file until CR
429 }
431 i++;
432 }
434 }
436 // reads bytes from file until NUL
446 }
448 i++;
449 }
451 }
453 map_block_t blk;
458 map_header_t hdr;
467 }
474 }
478 }
485 }
486 }
487 }
488 }
490 }
491 }
493 /*void F_freemus(void) {
495 int i;
497 if(!pat) return;
498 S_stopmusic();
499 free(pat);free(patp);
500 for(i=0;i<inum;++i) if(dmi[i]!=NULL) free(dmi[i]);
501 free(dmi);
502 pat=NULL;
504 }
505 */
507 /*void F_loadmus(char n[8]) {
508 int r,i,j;
509 FILE *h;
510 int o;
511 struct{
512 char id[4];
513 byte ver,pat;
514 word psz;
515 }d;
516 struct{byte t;char n[13];word r;}di;
518 if((r=F_findres(n))==-1) return;
519 fseek(h=wadh[wad[r].f],wad[r].o,SEEK_SET);
520 myfread(&d,1,sizeof(d),h);
521 if(memcmp(d.id,"DMM",4)!=0) return;
522 if(!(pat=malloc(d.psz<<2))) return;
523 myfread(pat,1,d.psz<<2,h);
524 myfread(&seqn,1,1,h);if(seqn) myfread(seq,1,seqn,h);
525 inum=0;myfread(&inum,1,1,h);
526 if(!(dmi=malloc(inum*4))) {free(pat);pat=NULL;return;}
527 if(!(patp=malloc((word)d.pat*32))) {free(pat);free(dmi);pat=NULL;return;}
528 for(i=0;i<inum;++i) {
529 dmi[i]=NULL;
530 myfread(&di,1,16,h);o=ftell(h);
531 for(r=0;r<12;++r) if(di.n[r]=='.') di.n[r]=0;
532 if((r=F_findres(di.n))==-1) continue;
533 if(!(dmi[i]=malloc(wad[r].l+8))) continue;
534 memset(dmi[i],0,16);
535 F_loadres(r,dmi[i],0,2);
536 F_loadres(r,(int*)dmi[i]+1,2,2);
537 F_loadres(r,(int*)dmi[i]+2,4,2);
538 F_loadres(r,(int*)dmi[i]+3,6,2);
539 F_loadres(r,(int*)dmi[i]+4,8,wad[r].l-8);
540 fseek(h,o,SEEK_SET);
541 }
542 for(i=r=0,j=(word)d.pat<<3;i<j;++i) {
543 patp[i]=r<<2;
544 while(pat[r++].v!=0x80);
545 }
546 }
547 */