I'll just post the code...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//static const char* input_vmv="C:\\GAMES\\VirtuaNes\\Bat_Lezard.vmv";
//static const char* output_fmv="C:\\GAMES\\fam510\\lezard-batman.fmv";
static const char* famtasia_string="Family Emulator \"Famtasia\" Ver5.1";
int main(int argc, char** argv)
{
if(argc<3)
{
printf("usage: convert <input_vmv_file> <output_fmv_file>\n");
exit(0);
}
FILE* f_in=fopen(argv[1], "rb");
if(!f_in)
{
perror("fopen\n");
exit(0);
}
FILE* f_out=fopen(argv[2], "wb");
if(!f_out)
{
perror("fopen\n");
exit(0);
}
long rerecord_count;
long ctr_data_offset;
long num_samples;
unsigned char ctr_flags;
fseek(f_in, 0x10, SEEK_SET);
fread(&ctr_flags, 1, 1, f_in);
fseek(f_in, 0x1c, SEEK_SET);
fread(&rerecord_count, 1, 4, f_in);
fseek(f_in, 0x34, SEEK_SET);
fread(&ctr_data_offset, 1, 4, f_in);
fread(&num_samples, 1, 4, f_in);
fwrite("FMV\x1a\x00", 1, 5, f_out);
if(ctr_flags&0x02)
{
fwrite("\xc0", 1, 1, f_out);
num_samples<<=1;
}
else
{
fwrite("\x80", 1, 1, f_out);
}
fwrite("\x00\x00\x00\x00", 1, 4, f_out);
fwrite(&rerecord_count, 1, 4, f_out);
fwrite("\x00\x00", 1, 2, f_out);
unsigned char buf[0x1000];
memset(buf, 0, 0x1000);
strcpy((char*)buf, famtasia_string);
fwrite(buf, 1, 0x80, f_out);
fseek(f_in, ctr_data_offset, SEEK_SET);
long i;
for(i=0; i<num_samples; )
{
long n=(num_samples-i)>0x1000 ? 0x1000 : (num_samples-i);
fread(buf, 1, n, f_in);
long x;
for(x=0; x<n; ++x)
{
unsigned char c=0;
if(buf[x]&0x80) c|=0x01;
if(buf[x]&0x40) c|=0x02;
if(buf[x]&0x10) c|=0x04;
if(buf[x]&0x20) c|=0x08;
if(buf[x]&0x02) c|=0x10;
if(buf[x]&0x01) c|=0x20;
if(buf[x]&0x04) c|=0x40;
if(buf[x]&0x08) c|=0x80;
buf[x]=c;
}
fwrite(buf, 1, n, f_out);
i+=n;
}
fclose(f_out);
fclose(f_in);
return 0;
}