#include <stdio.h>
#include <stdlib.h>
#include <string.h>
FILE *infile;
FILE *outfile;

void error( const char* msg );

int main(int argc, char *argv[])
{
    unsigned int size,i,byte,pbyte,temp;
    
    if (argc < 3){
        printf("Usage:  %s infile outfile\n",argv[0]);
        return 1;
    }
    if (!(infile = fopen(argv[1],"rb"))) error("Could not open in in file.");
    if (!(outfile = fopen(argv[2],"wb"))) error("Could not open in in file.");
    fseek(infile,0,SEEK_END);
    size = ftell(infile);
    rewind(infile);
    
    pbyte = 0;
    for(i=0; (i<size);i++) {
        byte = fgetc(infile);
        temp = (((byte-pbyte)&0xFF)+80)&0xFF;
        fputc(temp,outfile);
        pbyte = byte;
    }

    puts("done");
    fclose(outfile);
    fclose(infile);

    exit(0);
}


void error( const char* msg ) {
    printf("\nError: %s\n",msg);
    exit(1);
}
    
    
    
