ab39a62c3909ca93a753929c157fa3eb9c6739f4
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"
94 }
107 }
108 }
130 }
151 }
158 }
160 }
164 {
170 }
174 // build wad directory
180 wad_t w;
197 }
198 //fclose(h);
202 if((wadh[i]=h=fopen(wads[i], "rb"))==NULL) //if((wadh[i]=h=open(wads[i],O_RDONLY|O_BINARY))==-1)
214 }
216 }
230 }
231 }
232 }
235 }
237 // allocate resources
238 // (called from M_startup)
246 }
248 // load resource
265 }
278 }
280 // get resource id
287 }
289 // get resource id
295 }
299 }
301 // get sprite id
315 }
318 }
322 }
337 }
339 }
346 }
347 }
349 // reads bytes from file until CR
359 }
361 }
363 // reads bytes from file until NUL
373 }
375 }
377 map_block_t blk;
383 map_header_t hdr;
404 }
406 }
408 /*void F_freemus(void) {
410 int i;
412 if(!pat) return;
413 S_stopmusic();
414 free(pat);free(patp);
415 for(i=0;i<inum;++i) if(dmi[i]!=NULL) free(dmi[i]);
416 free(dmi);
417 pat=NULL;
419 }
420 */
422 /*void F_loadmus(char n[8]) {
423 int r,i,j;
424 FILE *h;
425 int o;
426 struct{
427 char id[4];
428 byte ver,pat;
429 word psz;
430 }d;
431 struct{byte t;char n[13];word r;}di;
433 if((r=F_findres(n))==-1) return;
434 fseek(h=wadh[wad[r].f],wad[r].o,SEEK_SET);
435 myfread(&d,1,sizeof(d),h);
436 if(memcmp(d.id,"DMM",4)!=0) return;
437 if(!(pat=malloc(d.psz<<2))) return;
438 myfread(pat,1,d.psz<<2,h);
439 myfread(&seqn,1,1,h);if(seqn) myfread(seq,1,seqn,h);
440 inum=0;myfread(&inum,1,1,h);
441 if(!(dmi=malloc(inum*4))) {free(pat);pat=NULL;return;}
442 if(!(patp=malloc((word)d.pat*32))) {free(pat);free(dmi);pat=NULL;return;}
443 for(i=0;i<inum;++i) {
444 dmi[i]=NULL;
445 myfread(&di,1,16,h);o=ftell(h);
446 for(r=0;r<12;++r) if(di.n[r]=='.') di.n[r]=0;
447 if((r=F_findres(di.n))==-1) continue;
448 if(!(dmi[i]=malloc(wad[r].l+8))) continue;
449 memset(dmi[i],0,16);
450 F_loadres(r,dmi[i],0,2);
451 F_loadres(r,(int*)dmi[i]+1,2,2);
452 F_loadres(r,(int*)dmi[i]+2,4,2);
453 F_loadres(r,(int*)dmi[i]+3,6,2);
454 F_loadres(r,(int*)dmi[i]+4,8,wad[r].l-8);
455 fseek(h,o,SEEK_SET);
456 }
457 for(i=r=0,j=(word)d.pat<<3;i<j;++i) {
458 patp[i]=r<<2;
459 while(pat[r++].v!=0x80);
460 }
461 }
462 */