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 <dos.h>
27 #include <string.h>
28 #include <stdlib.h>
29 //#include <sys\stat.h>
33 //#include "snddrv.h"
41 #include <sys/stat.h>
94 }
97 {
100 #ifndef WIN32
108 #else
110 #endif
112 }
126 }
127 }
147 }
168 }
175 }
177 }
181 {
187 }
191 // build wad directory
197 wad_t w;
214 }
215 //fclose(h);
219 if((wadh[i]=h=fopen(wads[i], "rb"))==NULL) //if((wadh[i]=h=open(wads[i],O_RDONLY|O_BINARY))==-1)
231 }
233 }
247 }
248 }
249 }
252 }
254 // allocate resources
255 // (called from M_startup)
263 }
265 // load resource
282 }
295 }
297 // get resource id
304 }
306 // get resource id
312 }
316 }
318 // get sprite id
332 }
335 }
339 }
354 }
356 }
363 }
364 }
366 // reads bytes from file until CR
376 }
378 }
380 // reads bytes from file until NUL
390 }
392 }
394 map_block_t blk;
400 map_header_t hdr;
421 }
423 }
425 /*void F_freemus(void) {
427 int i;
429 if(!pat) return;
430 S_stopmusic();
431 free(pat);free(patp);
432 for(i=0;i<inum;++i) if(dmi[i]!=NULL) free(dmi[i]);
433 free(dmi);
434 pat=NULL;
436 }
437 */
439 /*void F_loadmus(char n[8]) {
440 int r,i,j;
441 FILE *h;
442 int o;
443 struct{
444 char id[4];
445 byte ver,pat;
446 word psz;
447 }d;
448 struct{byte t;char n[13];word r;}di;
450 if((r=F_findres(n))==-1) return;
451 fseek(h=wadh[wad[r].f],wad[r].o,SEEK_SET);
452 myfread(&d,1,sizeof(d),h);
453 if(memcmp(d.id,"DMM",4)!=0) return;
454 if(!(pat=malloc(d.psz<<2))) return;
455 myfread(pat,1,d.psz<<2,h);
456 myfread(&seqn,1,1,h);if(seqn) myfread(seq,1,seqn,h);
457 inum=0;myfread(&inum,1,1,h);
458 if(!(dmi=malloc(inum*4))) {free(pat);pat=NULL;return;}
459 if(!(patp=malloc((word)d.pat*32))) {free(pat);free(dmi);pat=NULL;return;}
460 for(i=0;i<inum;++i) {
461 dmi[i]=NULL;
462 myfread(&di,1,16,h);o=ftell(h);
463 for(r=0;r<12;++r) if(di.n[r]=='.') di.n[r]=0;
464 if((r=F_findres(di.n))==-1) continue;
465 if(!(dmi[i]=malloc(wad[r].l+8))) continue;
466 memset(dmi[i],0,16);
467 F_loadres(r,dmi[i],0,2);
468 F_loadres(r,(int*)dmi[i]+1,2,2);
469 F_loadres(r,(int*)dmi[i]+2,4,2);
470 F_loadres(r,(int*)dmi[i]+3,6,2);
471 F_loadres(r,(int*)dmi[i]+4,8,wad[r].l-8);
472 fseek(h,o,SEEK_SET);
473 }
474 for(i=r=0,j=(word)d.pat<<3;i<j;++i) {
475 patp[i]=r<<2;
476 while(pat[r++].v!=0x80);
477 }
478 }
479 */