home *** CD-ROM | disk | FTP | other *** search
/ Audio 4.94 - Over 11,000 Files / audio-11000.iso / msdos / edit / modtech / modtest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-16  |  2.6 KB  |  111 lines

  1. #include <dos.h>
  2. #include <fcntl.h>
  3. #include <io.h>
  4. #include <stdio.h>
  5. #include <conio.h>
  6. #include <process.h>
  7.  
  8. /*
  9. This was compiled with TurboC. Other C is similar
  10. Module must be a 31 instrument one
  11. */
  12.  
  13. /* The data definitions */
  14.  
  15. typedef unsigned int UWORD;
  16. typedef unsigned char BYTE;
  17.  
  18. typedef struct {
  19.     char firstbyte;
  20.         char secndbyte;
  21.         BYTE thirdbyte;
  22.         UWORD samp0,samp1,samp2,samp3,samp4,samp5,samp6,samp7;
  23.         UWORD samp8,samp9,samp10,samp11,samp12,samp13,samp14,samp15;
  24.         UWORD samp16,samp17,samp18,samp19,samp20,samp21,samp22,samp23;
  25.         UWORD samp24,samp25,samp26,samp27,samp28,samp29,samp30,samp31;
  26.         BYTE trailer1,trailer2,trailer3,trailer4;
  27. } MPSTRUCT;
  28.  
  29. MPSTRUCT mppat = { 'M','P',
  30.                 0,               /* 0 = speaker, 7 = S Blaster  etc.. etc..*/
  31.         0,0,0,0,0,0,0,0,
  32.         0,0,0,0,0,0,0,0,
  33.         0,0,0,0,0,0,0,0,
  34.         0,0,0,0,0,0,0,0,
  35.                 0,               /* Start with pattern 0 */
  36.                 0,               /* Play whole song */
  37.                 1,               /* 1 = 12Mhz+,  0 = 10Mhz+ */
  38.                 0                /* All samples in Module are <64k (0x80 otherwise) */
  39.         };
  40.  
  41.  
  42.  
  43. main ()
  44. {
  45.     union REGS inregs,outregs;
  46.     int i,fd;
  47.  
  48.     if ((fd = open("themodel.mod", (O_RDONLY | O_BINARY) )) == -1 )
  49.             {
  50.                 printf("Module not found!\n");
  51.                 exit(1);
  52.             }
  53.  
  54.     allocmem(0x2840/16+1,&mppat.samp0);     /* Samples start at 0x2840 */
  55.     read(fd,MK_FP(mppat.samp0,0),0x2840);
  56.  
  57.     allocmem(6700/16+1,&mppat.samp1);
  58.     read(fd,MK_FP(mppat.samp1,0),6700);
  59.  
  60.     allocmem(7000/16+1,&mppat.samp2);
  61.     read(fd,MK_FP(mppat.samp2,0),7000);
  62.  
  63.     allocmem(5900/16+1,&mppat.samp3);
  64.     read(fd,MK_FP(mppat.samp3,0),5900);
  65.  
  66.     allocmem(8000/16+1,&mppat.samp4);
  67.     read(fd,MK_FP(mppat.samp4,0),8000);
  68.  
  69.  allocmem(20230/16+1,&mppat.samp5);
  70.     read(fd,MK_FP(mppat.samp5,0),20230);
  71.  
  72. allocmem(2300/16+1,&mppat.samp6);
  73.     read(fd,MK_FP(mppat.samp6,0),2300);
  74.  
  75. allocmem(9900/16+1,&mppat.samp7);
  76.     read(fd,MK_FP(mppat.samp7,0),9900);
  77.  
  78.  allocmem(6200/16+1,&mppat.samp8);
  79.     read(fd,MK_FP(mppat.samp8,0),6200);
  80.  
  81.  
  82.     close(fd);
  83.     inregs.x.dx = FP_SEG(&mppat);
  84.     inregs.x.cx = FP_OFF(&mppat);
  85.     inregs.x.ax = 0x8220;
  86.     int86(0x2f,&inregs,&outregs);
  87.  
  88.     switch (outregs.x.ax)
  89.         {
  90.         case 0x5722: break;
  91.  
  92.         case 0x2000:
  93.             printf("Error: Modres doesn't like something about the structure\n");
  94.             exit(2);
  95.  
  96.         default:
  97.             printf("Modres not installed!\n");
  98.             exit(1);
  99.         }
  100.  
  101. /** DO SOMETHING INTERESTING HERE ** AS LONG AS IT DOESN'T INVOLVE DISKS ***/
  102.  
  103.     inregs.x.ax = 0;
  104.     int86(0x16,&inregs,&outregs);   /* Wait for a key */
  105.  
  106.     inregs.x.ax = 0x8227;
  107.     inregs.x.bx = 0x0003;
  108.     int86(0x2f,&inregs,&outregs);
  109.     exit(0);
  110. }
  111.