Browse Source

removed some more compiler warnings

master
Sven Oliver Moll 6 months ago
parent
commit
20399e282a
2 changed files with 62 additions and 29 deletions
  1. +37
    -8
      makewav.c
  2. +25
    -21
      makewav.h

+ 37
- 8
makewav.c View File

@@ -37,6 +37,28 @@ unsigned char buffer[260],
float flength,
wavFlength;

void freadall( void *b, size_t size, FILE *f )
{
char *c = (char*)b;
size_t pos = 0;
size_t dread = 0;

for( pos = 0; pos < size; pos += size )
{
dread = fread( c + pos, 1, size - pos, f );
if( dread == 0 )
{
break;
}
}
if( pos != size )
{
fprintf( stderr, "short read: could only get %u bytes out of %u\n",
(unsigned int)pos, (unsigned int)size );
exit( 2 );
}
}

void processByte( streambuffer_t *buffer, unsigned char pByte, int mode )
{
int p;
@@ -69,7 +91,7 @@ void getPage(unsigned int page, int display)
printf("%02x\b\b",page);
}
fseek(binFile,(long) page * 256,SEEK_SET);
fread(buffer,256,1,binFile);
freadall(buffer,256,binFile);
}

unsigned char setVolume(unsigned int amplitude, int volume)
@@ -319,10 +341,15 @@ int processParms( int argc, char *argv[], struct parmFlags *parms )
fprintf(stderr,"Illegal start address!\n");
exit(1);
}
if (sscanf(*argv,"s%2hhx%2hhx",&parms->startHi,&parms->startLo) == EOF)
{
fprintf(stderr,"Illegal start address!\n");
exit(1);
unsigned int start;
if (sscanf(*argv,"s%04x",&start) == EOF)
{
fprintf(stderr,"Illegal start address!\n");
exit(1);
}
parms->startHi = (start >> 8) & 0xff;
parms->startLo = start & 0xff;
}
parms->sflag = 1;
break;
@@ -679,10 +706,12 @@ int main( int argc, char *argv[] )
char answer;

fprintf(stderr,"Warning! %d .wav files will be created, Continue? (Y/N)", parms.binFileCount);
scanf("%c",&answer);
if (answer != 'y' && answer != 'Y')
while( scanf("%c",&answer) < 1 )
{
exit(1);
if (answer != 'y' && answer != 'Y')
{
exit(1);
}
}
}

@@ -734,7 +763,7 @@ int main( int argc, char *argv[] )
fseek(binFile,0,SEEK_END);
fsize = ftell(binFile);
fseek(binFile,0,SEEK_SET);
fread(fileBuffer,fsize,1,binFile);
freadall(fileBuffer,fsize,binFile);
if (parms.tflag == 's' && fsize != 8448 && fsize != 6144 && fsize != 2048 && fsize != 4096 && fsize != 32767)
{
fprintf(stderr,"Invalid file size for Supercharger, skipping\n");

+ 25
- 21
makewav.h View File

@@ -45,9 +45,13 @@
#define DISPLAY_DETAILS 3

#define _MAX_FNAME 256
#ifndef _MAX_PATH
#define _MAX_PATH 256
#endif
#define _MAX_DIR 256
#ifndef _MAX_DRIVE
#define _MAX_DRIVE 256
#endif
#define _MAX_EXT 256

typedef unsigned long int dd;
@@ -78,7 +82,7 @@ struct parmFlags
float clearingSeconds;
float hlength;
char wavFileName[_MAX_FNAME+5];
char fullPath[_MAX_PATH];
char fullPath[_MAX_PATH+5];
char *audioDevName;

struct qnode *binFileQ;
@@ -89,32 +93,32 @@ struct parmFlags
};

char bankSwitchList[][5] =
{"2K", "CV", "4K", "28SC", "F8SC", "28", "F8", "FE",
"3F", "E0", "FA", "2A", "3A", "FANR", "2ANR", "3ANR",
"46SC","F6SC", "26SC", "36SC", "46", "F6", "26", "36",
"E7", "E7NR", "F4SC", "24SC", "34SC", "44SC", "F4", "24",
"34", "44", "MB", ""};
{"2K", "CV", "4K", "28SC", "F8SC", "28", "F8", "FE",
"3F", "E0", "FA", "2A", "3A", "FANR", "2ANR", "3ANR",
"46SC", "F6SC", "26SC", "36SC", "46", "F6", "26", "36",
"E7", "E7NR", "F4SC", "24SC", "34SC", "44SC", "F4", "24",
"34", "44", "MB", ""};

unsigned int controlByteList[] =
{0xCA, 0xEA, 0xC8, 0xF6, 0xE6, 0xD6, 0xC6, 0xCC,
0xCE, 0xC1, 0xE0, 0xF0, 0x60, 0xC0, 0xD0, 0x40,
0x74, 0xE4, 0xF4, 0x64, 0x54, 0xC4, 0xD4, 0x44,
0xE3, 0xC3, 0xE2, 0xF2, 0x62, 0x72, 0xC2, 0xD2,
0x42, 0x52, 0xC9, 0x00};
{0xCA, 0xEA, 0xC8, 0xF6, 0xE6, 0xD6, 0xC6, 0xCC,
0xCE, 0xC1, 0xE0, 0xF0, 0x60, 0xC0, 0xD0, 0x40,
0x74, 0xE4, 0xF4, 0x64, 0x54, 0xC4, 0xD4, 0x44,
0xE3, 0xC3, 0xE2, 0xF2, 0x62, 0x72, 0xC2, 0xD2,
0x42, 0x52, 0xC9, 0x00};

int fileSizeList[] =
{2048, 2048, 4096, 8192, 8192, 8192, 8192, 8192,
8192, 8192, 12288, 12288, 12288, 12288, 12288, 12288,
16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384,
16384, 16384, 32768, 32768, 32768, 32768, 32768, 32768,
32768, 32768, 65536, 0};
{ 2048, 2048, 4096, 8192, 8192, 8192, 8192, 8192,
8192, 8192, 12288, 12288, 12288, 12288, 12288, 12288,
16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384,
16384, 16384, 32768, 32768, 32768, 32768, 32768, 32768,
32768, 32768, 65536, 0};

int startPageList[] =
{7, 7, 15, 31, 15, 31, 15, 15,
31, 31, 15, 31, 47, 15, 31, 47,
63, 15, 31, 47, 63, 15, 31, 47,
63, 63, 15, 31, 47, 63, 15, 31,
47, 63, 15, 0};
{ 7, 7, 15, 31, 15, 31, 15, 15,
31, 31, 15, 31, 47, 15, 31, 47,
63, 15, 31, 47, 63, 15, 31, 47,
63, 63, 15, 31, 47, 63, 15, 31,
47, 63, 15, 0};

unsigned char clearingToneLength[2] = {26, 51};
unsigned char clearingTone[256];

Loading…
Cancel
Save