home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / midas / s3minfo.c < prev    next >
C/C++ Source or Header  |  1994-08-06  |  4KB  |  101 lines

  1. /*      S3MINFO.C
  2.  *
  3.  * S3M info displayer
  4.  *
  5.  * Copyright 1994 Petteri Kangaslampi and Jarno Paananen
  6.  *
  7.  * This file is part of the MIDAS Sound System, and may only be
  8.  * used, modified and distributed under the terms of the MIDAS
  9.  * Sound System license, LICENSE.TXT. By continuing to use,
  10.  * modify or distribute this file you indicate that you have
  11.  * read the license and understand and accept it fully.
  12. */
  13.  
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <conio.h>
  18. #include "midas.h"
  19.  
  20. ushort          *iptrs;
  21.  
  22.  
  23. int main(int argc, char *argv[])
  24. {
  25.     FILE        *f;
  26.     s3mHeader   s3mh;
  27.     s3mInstHdr  s3mi;
  28.     int         i;
  29.     unsigned    uu;
  30.  
  31.     printf("S3MINFO v1.00, Copyright 1994 Petteri Kangaslampi &"
  32.            " Jarno Paananen\n\n");
  33.  
  34.     if ( argc != 2 )
  35.     {
  36.         puts("Usage: S3MINFO <s3mname>");
  37.         exit(EXIT_SUCCESS);
  38.     }
  39.  
  40.     f = fopen(argv[1], "rb");
  41.     fread(&s3mh, sizeof(s3mHeader), 1, f);
  42.     printf("Song name: %s\n", (char*) &s3mh.name[0]);
  43.     printf("File type: %i\n", (int) s3mh.type);
  44.     printf("Song length: %i\n", (int) s3mh.songLength);
  45.     printf("Number of instruments: %i\n", (int) s3mh.numInsts);
  46.     printf("Number of patterns: %i\n", (int) s3mh.numPatts);
  47.     printf("Flags:\n");
  48.     printf("\tST2 vibrato: %i\n", (int) s3mh.flags.st2Vibrato & 1);
  49.     printf("\tST2 tempo: %i\n", (int) s3mh.flags.st2Tempo & 1);
  50.     printf("\tProTracker slides: %i\n", (int) s3mh.flags.ptSlides & 1);
  51.     printf("\t0-vol optimizations: %i\n", (int) s3mh.flags.zeroVolOpt & 1);
  52.     printf("\tProTracker limits: %i\n", (int) s3mh.flags.ptLimits & 1);
  53.     printf("\tEnable filter/sfx: %i\n", (int) s3mh.flags.filter & 1);
  54.     printf("Tracker version: 0x%X\n", (int) s3mh.trackerVer);
  55.     printf("File format version: %i\n", (int) s3mh.formatVer);
  56.     printf("Master volume: %i\n", (int) s3mh.masterVol);
  57.     printf("Initial speed: %i\n", (int) s3mh.speed);
  58.     printf("Initial tempo: %i\n", (int) s3mh.tempo);
  59.     printf("Master multiplier: %i\n", (int) s3mh.masterMult & 15);
  60.     printf("Stereo: %i\n", (int) (s3mh.masterMult >> 4) & 1);
  61.     printf("Channel settings:");
  62.     for ( i = 0; i < 32; i++ )
  63.         printf("%X, ", s3mh.chanSettings[i]);
  64.     printf("\n\n");
  65.  
  66.     uu = 0x60 + 2 * ((s3mh.songLength + 1) / 2);
  67.     printf("Instrument pointers start: %u\n\n", uu);
  68.     fseek(f, (ulong) uu, SEEK_SET);
  69.     iptrs = malloc(2 * s3mh.numInsts);
  70.     fread(iptrs, 2*s3mh.numInsts, 1, f);
  71.  
  72.     for ( i = 0; i < s3mh.numInsts; i++ )
  73.     {
  74.         fseek(f, iptrs[i] * 16L, SEEK_SET);
  75.         fread(&s3mi, sizeof(s3mInstrument), 1, f);
  76.         printf("Instrument %i, file pos %u\n", i, (unsigned) iptrs[i]);
  77.         printf("\tType: %i\n", (int) s3mi.type);
  78.         printf("\tDOS filename: %s\n", (char*) &s3mi.dosName[0]);
  79.         printf("\tParagraph ptr to data: %u\n", (unsigned) s3mi.samplePtr);
  80.         printf("\tSample length: %lu\n", (ulong) s3mi.length);
  81.         printf("\tSample loop start: %lu\n", (ulong) s3mi.loopStart);
  82.         printf("\tSample loop end: %lu\n", (ulong) s3mi.loopEnd);
  83.         printf("\tVolume: %i\n", (int) s3mi.volume);
  84.         printf("\tInstrument disk: %i\n", (int) s3mi.disk);
  85.         printf("\tPacking: %i\n", (int) s3mi.pack);
  86.         printf("\tFlags:\n");
  87.         printf("\t\tLooping: %i\n", (int) s3mi.flags & 1);
  88.         printf("\t\tStereo: %i\n", (int) (s3mi.flags >> 1) & 1);
  89.         printf("\t\t16-bit: %i\n", (int) (s3mi.flags >> 2) & 1);
  90.         printf("\tC2 sampling freq: %lu\n", (ulong) s3mi.c2Rate);
  91.         printf("\tGUS memory position: %u\n", (unsigned) s3mi.gusPos);
  92.         printf("\tInt:512: %i\n", (int) s3mi.int512);
  93.         printf("\tInt:lastused: %i\n", (int) s3mi.intLastUsed);
  94.         printf("\tName: %s\n\n", (char*) &s3mi.name[0]);
  95.     }
  96.  
  97.     fclose(f);
  98.  
  99.     return 0;
  100. }
  101.