/*************************************************************************** * NAMES.C: Print the patch names from a bulk DX7 dump. * Daniel Barrett, 2-14-89. * * Usage: names [-h] filename * The "-h" option is for some bulk dumps that have extra * header bytes on them. If the size of your dump file is * 4108 bytes, use -h. If it is not (usually 4096 bytes), * then don't use -h. * * Source code and executable binary 100% Public Domain * * Compiled and tested under UNIX, AmigaDOS, and MS-DOS. To * compile the MS-DOS version, you must uncomment the line * "#define MSDOS." You might also have to do this for the * Atari ST computer, but I am not sure. ***************************************************************************/ #include /* #define MSDOS */ /* Uncomment to compile under MS-DOS. */ #define OFFSET 112L #define PATCHSIZE 128 #define NUMPATCHES 32 #define HEADER 16L #define NOHEADER 6L #define TAILER 6L #define CURRENT_POSITION 1 #define NAMELEN 10 #define FAIL 0 #define SUCCESS 1 main(argc, argv) int argc; char *argv[]; { FILE *fp; int i; if (argc < 2) { printf("Names V1.0, by Daniel J. Barrett. "); printf("100%% Public Domain!\n"); printf("Extract patchnames from a DX7 data dump.\n\n"); printf("Usage: Names [-h] dxbank_file\n"); printf("Use `-h' only if dxbank_file size=4108 bytes.\n"); exit(1); } else if ((argc == 3) && (!strcmp(argv[1], "-h"))) { #ifdef MSDOS if ((fp = fopen(argv[2], "rb")) == NULL) #else if ((fp = fopen(argv[2], "r")) == NULL) #endif printf("Cannot open file %s\n", argv[1]), exit(1); Skip(fp, HEADER); } else { #ifdef MSDOS if ((fp = fopen(argv[1], "rb")) == NULL) #else if ((fp = fopen(argv[1], "r")) == NULL) #endif printf("Cannot open file %s\n", argv[1]), exit(1); Skip(fp, NOHEADER); } i = 1; while (ShowNames(fp, i++)) ; fclose(fp); } Skip(fp, amount) FILE *fp; long amount; { if (fseek(fp, amount, CURRENT_POSITION)) printf("skip failed\n"), exit(1); } int ShowNames(fp, i) FILE *fp; int i; { char patchName[NAMELEN+1]; if (fseek(fp, OFFSET, CURRENT_POSITION)) return(FAIL); if (fgets(patchName, sizeof(patchName), fp) == NULL) return(FAIL); printf("%3d: %s\n", i, patchName); if (fseek(fp, TAILER, CURRENT_POSITION)) return(FAIL); return(SUCCESS); }