/[projet1]/public/pc/tools/oric/4k8/4k8towav.c
Defence Force logotype

Contents of /public/pc/tools/oric/4k8/4k8towav.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1186 - (show annotations)
Wed Sep 17 20:44:27 2014 UTC (5 years ago) by Jylam
File MIME type: text/plain
File size: 1290 byte(s)
Fix gcc warnings

1 #include <stdio.h>
2 #include <stdlib.h>
3
4 FILE *fd, *fd2;
5 struct {
6 char sig[4];
7 int riff_size;
8 char datasig[4];
9 char fmtsig[4];
10 int fmtsize;
11 short tag;
12 short channels;
13 int freq;
14 int bytes_per_sec;
15 short byte_per_sample;
16 short bits_per_sample;
17 char samplesig[4];
18 int length;
19 } sample_riff= {"RIFF",0,"WAVE","fmt ",16,1,1,4800,4800,1,8,"data",0};
20
21 int main(int argc,char *argv[])
22 {
23 int i,c,size;
24
25 if (argc!=3) {
26 printf("Usage: oric2wav <tape_image> <wav_file>\n");
27 exit(1);
28 }
29 fd=fopen(argv[1],"rb");
30 if (fd==NULL) {
31 printf("Unable to open %s\n",argv[1]);
32 exit(1);
33 }
34 fd2=fopen(argv[2],"wb");
35 if (fd2==NULL) {
36 printf("Unable to open %s\n",argv[2]);
37 exit(1);
38 }
39 fseek(fd,0,SEEK_END); size=ftell(fd); fseek(fd,0,SEEK_SET);
40 sample_riff.length=size*8;
41 sample_riff.riff_size=sample_riff.length+36;
42 fwrite(&sample_riff,1,sizeof(sample_riff),fd2);
43 for(i=0;i<size;i++) {
44 c=fgetc(fd);
45 fputc(c&0x80?0xE0:0x20,fd2);
46 fputc(c&0x40?0xE0:0x20,fd2);
47 fputc(c&0x20?0xE0:0x20,fd2);
48 fputc(c&0x10?0xE0:0x20,fd2);
49 fputc(c&0x08?0xE0:0x20,fd2);
50 fputc(c&0x04?0xE0:0x20,fd2);
51 fputc(c&0x02?0xE0:0x20,fd2);
52 fputc(c&0x01?0xE0:0x20,fd2);
53 }
54 return 0;
55 }
56

  ViewVC Help
Powered by ViewVC 1.1.26