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 <conio.h>
26 #include <malloc.h>
27 //#include <dos.h>
28 #include <string.h>
29 #include <stdlib.h>
30 //#include <sys\stat.h>
34 //#include "snddrv.h"
42 #include <sys/stat.h>
95 }
98 {
101 #ifndef WIN32
109 #else
111 #endif
113 }
127 }
128 }
148 }
169 }
176 }
178 }
182 {
188 }
192 // build wad directory
198 wad_t w;
215 }
216 //fclose(h);
220 if((wadh[i]=h=fopen(wads[i], "rb"))==NULL) //if((wadh[i]=h=open(wads[i],O_RDONLY|O_BINARY))==-1)
232 }
234 }
248 }
249 }
250 }
253 }
255 // allocate resources
256 // (called from M_startup)
264 }
266 // load resource
283 }
296 }
298 // get resource id
305 }
307 // get resource id
313 }
317 }
319 // get sprite id
333 }
336 }
340 }
355 }
357 }
364 }
365 }
367 // reads bytes from file until CR
377 }
379 }
381 // reads bytes from file until NUL
391 }
393 }
395 map_block_t blk;
401 map_header_t hdr;
422 }
424 }
426 /*void F_freemus(void) {
428 int i;
430 if(!pat) return;
431 S_stopmusic();
432 free(pat);free(patp);
433 for(i=0;i<inum;++i) if(dmi[i]!=NULL) free(dmi[i]);
434 free(dmi);
435 pat=NULL;
437 }
438 */
440 /*void F_loadmus(char n[8]) {
441 int r,i,j;
442 FILE *h;
443 int o;
444 struct{
445 char id[4];
446 byte ver,pat;
447 word psz;
448 }d;
449 struct{byte t;char n[13];word r;}di;
451 if((r=F_findres(n))==-1) return;
452 fseek(h=wadh[wad[r].f],wad[r].o,SEEK_SET);
453 myfread(&d,1,sizeof(d),h);
454 if(memcmp(d.id,"DMM",4)!=0) return;
455 if(!(pat=malloc(d.psz<<2))) return;
456 myfread(pat,1,d.psz<<2,h);
457 myfread(&seqn,1,1,h);if(seqn) myfread(seq,1,seqn,h);
458 inum=0;myfread(&inum,1,1,h);
459 if(!(dmi=malloc(inum*4))) {free(pat);pat=NULL;return;}
460 if(!(patp=malloc((word)d.pat*32))) {free(pat);free(dmi);pat=NULL;return;}
461 for(i=0;i<inum;++i) {
462 dmi[i]=NULL;
463 myfread(&di,1,16,h);o=ftell(h);
464 for(r=0;r<12;++r) if(di.n[r]=='.') di.n[r]=0;
465 if((r=F_findres(di.n))==-1) continue;
466 if(!(dmi[i]=malloc(wad[r].l+8))) continue;
467 memset(dmi[i],0,16);
468 F_loadres(r,dmi[i],0,2);
469 F_loadres(r,(int*)dmi[i]+1,2,2);
470 F_loadres(r,(int*)dmi[i]+2,4,2);
471 F_loadres(r,(int*)dmi[i]+3,6,2);
472 F_loadres(r,(int*)dmi[i]+4,8,wad[r].l-8);
473 fseek(h,o,SEEK_SET);
474 }
475 for(i=r=0,j=(word)d.pat<<3;i<j;++i) {
476 patp[i]=r<<2;
477 while(pat[r++].v!=0x80);
478 }
479 }
480 */