[comp.sys.handhelds] coversion program for Sad

zimmer@calvin.tmc.edu (Andrew Zimmerman) (09/26/90)

This program will convert a memory scan dump of the 48sx to the format
used by SAD 1.01.  (SAD 1.01 is a great program)

#include <stdio.h>
#include <ctype.h>

FILE *infp;
FILE *outfp;

char rom[524288];
main(argc,argv)
    int argc;
    char *argv[];
{
    int address;
    int chkaddress;
    int nibble[17];
    int n1;
    int i;

    if(argc < 2)
    {
        infp = stdin;
    }
    else
    {
        infp = fopen(argv[1],"r");
    }
    if(argc < 3)
    {
        outfp = stdout;
    }
    else
    {
        outfp = fopen(argv[2],"w");
    }

    chkaddress = 0;
    while(fscanf(infp,"%05X:",&address) != EOF)
    {
        if(address != chkaddress)
        {
            fprintf(stderr,"[%05X] != [%05X]\n",chkaddress,address);
        }
        chkaddress += 16;
        for(i=0; i < 16; i ++)
        {
            fscanf(infp,"%1X",&n1);
            fprintf(outfp,"%c",n1);
        }
    }
}


Andrew
zimmer@calvin.stanford.edu