home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Vectronix 2
/
VECTRONIX2.iso
/
FILES_07
/
MIDNIGHT.ZIP
/
MIDNIGHT
/
UTIL
/
CONV_SND.C
next >
Wrap
C/C++ Source or Header
|
1993-01-11
|
1KB
|
62 lines
#include <stdio.h>
#include <stdlib.h>
#include <tos.h>
#include <ext.h>
#include <string.h>
#include <portab.h>
void main( int argc, char **argv )
{
FILE *f1,*f2;
long fh;
long size,i;
UWORD c,pos;
UBYTE *p;
if( argc<2 ) return;
f1= fopen( argv[1],"rb" );
f2= fopen( "CONV_SND.SH","w" );
if( !f1 || !f2 )
{ fclose( f1 );
fclose( f2 );
return;
}
fh= fileno( f1 );
size= Fseek( 0,fh,2 );
Fseek( 0,fh,0 );
p= (UBYTE*)Malloc( size );
if( !p ) goto ex;
Fread( fh,size,p );
fprintf( f2,"/* Daten von: %s */\n\nUWORD name[] =\n\t{",argv[1] );
if( !(Kbshift(-1)&0x1) )
for( pos=i=0;i<size+1;i++,pos&=15 )
{ if( pos==0 ) fprintf( f2,"\n\t\t" );
c= ((c<<8)&0xff00)|(Kbshift(-1)&0x2?(-p[i]&0xff):p[i]);
if( pos++ & 1 )
{ fprintf( f2,"0x%04X",c );
if( size-i>1 ) fprintf( f2,"," );
}
}
else
for( pos=0,i=size-1;i>=-1;i--,pos&=15 )
{ if( pos==0 ) fprintf( f2,"\n\t\t" );
c= (c<<8)|p[i];
if( pos++ & 1 )
{ fprintf( f2,"0x%04X",c );
if( i>1 ) fprintf( f2,"," );
}
}
fprintf( f2,"\n\t};\n\nSND_str Name = { ((UBYTE*)&name),NULL,\
((UBYTE*)&name)+%ld,7000,1 };\n",size );
Mfree( p );
ex: fclose(f2);
fclose(f1);
}