home *** CD-ROM | disk | FTP | other *** search
/ Fujiology Archive / fujiology_archive_v1_0.iso / !FALCON / ABSTRACT / MEGPL116.ZIP / MGPL-116 / REPLAY / USE-MGT.C < prev    next >
C/C++ Source or Header  |  1995-08-22  |  4KB  |  154 lines

  1. /************************************************************/
  2. /*                                                */
  3. /*        De l'utilisation du Replay DSP MegaTracker        */
  4. /*                                                */
  5. /*        Of Use of the MegaTracker DSP Replay            */
  6. /*                                                */
  7. /*        Par Simplet / FATAL DESIGN                    */
  8. /*                                                */
  9. /************************************************************/
  10.  
  11. #include <tos.h>
  12. #include <screen.h>
  13. #include <unpack.h>
  14. #include <mgt-play.h>
  15.  
  16. #define MAXSIZE 350000
  17. #define MODNAME "E:\\SNDTRACK\\DEPACK\\CCITY12.MGT"
  18.  
  19. void main(void);
  20.  
  21. void main(void)
  22. {
  23.     long        adr,length;
  24.     int        dummy,handle,freq_div = 1;
  25.     char        tch;
  26.     DTA        *buf;
  27.     char        packers[6][17]    =
  28.     {"Unpacked...","Atomik 3.5...",
  29.     "Speedpacker 3...","Pack Ice 2.4...",
  30.     "Powerpacker 2...","Sentry 2.0..."};
  31.  
  32.     Cconws(CLEAR_HOME);
  33.     Cconws("MegaTrackerâ„¢ v1.1 DSP-Replay Routine by Simplet / FATAL DESIGN\r\n");
  34.     Cconws("--------------------------------------------------------------\r\n\n");
  35.  
  36.     Cconws("Allocating Memory...");
  37.  
  38.     adr=Malloc(MAXSIZE);
  39.     if (adr<=0)
  40.         {
  41.         Cconws("Error!\r\n");
  42.         Cconws("Not enough Memory!\r\n");
  43.         Cconws("Press any key...");
  44.         Crawcin();exit();
  45.         }
  46.     
  47.     Cconws("Ok!\r\nLoading Module...");
  48.  
  49.     dummy=Fsfirst(MODNAME,0);
  50.     buf=Fgetdta();
  51.     length=buf->d_length;
  52.     
  53.     if ((dummy!=0) || (length > MAXSIZE))
  54.         {
  55.         if (dummy!=0) Cconws("Disk Error!\r\n");
  56.         else    Cconws("Not enough Memory to load!\r\n");
  57.         Cconws("Press any key...");
  58.         Crawcin();exit();
  59.         }
  60.  
  61.     handle=Fopen(MODNAME,FO_READ);
  62.  
  63.     dummy=Unpack_Detect_Disk(handle,MAXSIZE);
  64.  
  65.     if (dummy<0)
  66.         {
  67.         Fclose(handle);
  68.         switch (dummy)
  69.             {
  70.             case -1:    Cconws("Unavailable packer!\r\n");break;
  71.             case -2:    Cconws("Not enough Memory to unpack!\r\n");break;
  72.             }
  73.             Cconws("Press any key...");
  74.             Crawcin();exit();
  75.         }
  76.     else    {
  77.         Fread(handle,length,adr);
  78.         Fclose(handle);
  79.         if (dummy==0) Cconws("Unpacked!");
  80.         else {
  81.             Cconws("Ok!\r\nUnpacking ");
  82.             Cconws(packers[dummy]);
  83.             Unpack_All(adr,length);
  84.             Cconws("Ok!");
  85.             }
  86.         }
  87.  
  88.     Cconws("\r\nInitialising Module and Samples...");
  89.  
  90.     dummy=MGTK_Init_Module_Samples(adr,adr+MAXSIZE);
  91.     if (dummy!=0)
  92.         {
  93.         Cconws("Error!\r\n");
  94.         switch (dummy)
  95.             {
  96.             case -1:    Cconws("This is not a MegaTracker module!\r\n");break;
  97.             case -2:    Cconws("Not enough workspace to depack tracks!\r\n");break;
  98.             case -3:    Cconws("Not enough workspace to prepare samples!\r\n");break;
  99.             case -4:    Cconws("No samples in this module!\r\n");break;
  100.             }
  101.         Cconws("Press any key...");
  102.         Crawcin();exit();
  103.         }
  104.  
  105.     Cconws("Ok!\r\nInitialising DSP Program...");
  106.  
  107.     dummy=MGTK_Init_DSP();
  108.     if (dummy!=0)
  109.         {
  110.         Cconws("Error!\r\n");
  111.         Cconws("DSP Program couldn't be loaded!\r\n");
  112.         Cconws("Press any key...");
  113.         Crawcin();exit();
  114.         }
  115.  
  116.     Cconws("Ok!\r\n\n");
  117.  
  118.     MGTK_Save_Sound();
  119.     MGTK_Init_Sound();
  120.     MGTK_Set_Replay_Frequency(freq_div);
  121.     MGTK_Restart_Loop=-1;
  122.     MGTK_Play_Music(0);
  123.  
  124.     Cconws("You can use the following keys :\r\n");
  125.     Cconws("  - or + for previous or next music\r\n");
  126.     Cconws("  ( or ) for previous or next music position\r\n");
  127.     Cconws("  / or * for previous or next replay frequency\r\n");
  128.     Cconws("  L for play, P for pause, S for stop\r\n");
  129.     Cconws("  Space to quit\r\n");
  130.  
  131.     do
  132.         {
  133.         tch=Crawcin();
  134.         switch ( tch-32*((97<=tch) && (tch<=122)) )
  135.             {
  136.             case    '-':    MGTK_Previous_Music();break;
  137.             case '+':    MGTK_Next_Music();break;
  138.             case    '(':    MGTK_Previous_Position();break;
  139.             case ')':    MGTK_Next_Position();break;
  140.             case '/':    if (freq_div>1)
  141.                     MGTK_Set_Replay_Frequency(--freq_div);break;
  142.             case '*':    if (freq_div<5)
  143.                     MGTK_Set_Replay_Frequency(++freq_div);break;
  144.             case    'L':    MGTK_Play_Music(0);break;
  145.             case    'P':    MGTK_Pause_Music();break;
  146.             case    'S':    MGTK_Stop_Music();break;
  147.             }
  148.         }
  149.     while (tch!=*" ");
  150.         
  151.     MGTK_Stop_Music();
  152.     MGTK_Restore_Sound();
  153. }
  154.