home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / mt / mt.c < prev    next >
C/C++ Source or Header  |  1990-04-01  |  5KB  |  138 lines

  1. /* mt.c    root module for 8 track sequencer/editor */
  2. /* `MIDI Sequencing In C', Jim Conger, M&T Books, 1989 */
  3.  
  4. #include <stdio.h>          /* compiler library files */
  5. #include <conio.h>
  6. #include <stdlib.h>
  7.  
  8. #include "standard.h"       /* header files */
  9. #include "screenf.h"
  10. #include "mpu401.h"
  11.  
  12. #define ALLOCATE            /* Because ALLOCATE is defined, all header data */
  13. #include "mt.h"             /* is stored at the beginning of this module. */
  14. #include "video.h"          /* See mt.h for example use of ALLOCATE. */
  15. #include "filefunc.h"
  16. #include "mtsc.h"
  17. #include "mtdeclar.h"
  18.  
  19. /* main() controls MT's primary menu and directs execution to all other */
  20. /* parts of the program */
  21.  
  22. void
  23. main(void)
  24. {
  25.     int status, pick, lastpick, ans, i;
  26.     char buf[17], nbuf[10];
  27.  
  28.     clearscreen(BWC);
  29.     writeword("Loading M T  - Eight track MIDI Sequencer and Editor.", 
  30.         14, 3, BWC);
  31.     writeword("Version 1.3.       Jim Conger 2/89", 25, 5, BWC);
  32.     writeword("PLEASE do not distribute copies of this software.",
  33.         16, 8, BWC);
  34.     writeword("Order `MIDI Sequencing In C' for program, source code, user's",
  35.         10, 10, BWC);
  36.     writeword("guide and documentation.  Contact M&T Books, 501 Galveston Dr.",
  37.         10, 11, BWC);
  38.     writeword("Redwood City, Calif, 94063.  Phone 800-533-4372 to order.\n\n",
  39.         10, 12, BWC);
  40.     writeword("In California 800-356-2002.  8AM to 5PM Pacific Standard Time.\n\n",
  41.         10, 13, BWC);
  42.     
  43.     
  44.     getcwd(g_prodir, 50);           /* put current directory name in dir */
  45.     strcpy(g_songdir, g_prodir);    /* start with directory to program area */
  46.  
  47.     status = load_video_data("install.dat");
  48.     if (!status){
  49.         writeword("Video data file install.dat not found - run INSTALL.", 
  50.             5, 20, BWC);
  51.         exit(0);
  52.     }
  53.     
  54.     loadscrn(g_chain, NSCREEN, "mt");       /* load screens into memory */
  55.     g_free_memory = free_memory();
  56.     printf("\nFree memory = %d K bytes.", g_free_memory);
  57.     
  58.     init_edit_param();                      /* initialize data */
  59.     init_tracks();
  60.  
  61.     writeword("Hit any key to start...", 28, 21, BWC);
  62.     wait_for_key();
  63.  
  64.  
  65. /* Put the primary menu on the screen, plus current settings */
  66. /* Loop to and from dependent program segments based on selection */
  67.  
  68.     pick = 0;
  69.     while(1){
  70.         clearscreen(g_norm_attrib);     /* clear screen, display main menu */
  71.         fdispchain(g_chain[1], 1, g_norm_attrib, g_text_mode);
  72.         
  73.                                 /* put directory and song name on screen */
  74.         writeword(g_songdir, 47, 8, g_emph_attrib);
  75.         writeword(g_filename, 47, 9, g_emph_attrib);
  76.         writeword(g_songtitle, 26, 18, g_emph_attrib);
  77.         
  78.         lastpick = pick;         /* cursor selection of command */
  79.         pick = movescrn(g_text_mode, mt1, pick, NPARAM1 - 1, g_norm_attrib,
  80.             g_cursor_attrib); 
  81.         switch(pick){
  82.         case(0):                            /* drive */
  83.             getdrive(g_prodir, g_songdir);
  84.             break;
  85.         case(1):                            /* load */
  86.             load_song();
  87.             break;
  88.         case(2):                            /* edit */
  89.             edit_menu();
  90.             break;
  91.         case(3):                            /* record */
  92.             record_menu();
  93.             break;
  94.         case(4):                            /* title */
  95.             getstr(g_text_char_v - 1, "Enter title ->", g_songtitle, 
  96.                 TITLE_WIDE - 1, g_norm_attrib);
  97.             break;
  98.         case(5):                            /* save */
  99.             save_song();
  100.             break;
  101.         case(6):                            /* clear */
  102.             writeword("Are you sure you want to erase all track data in memory? (Y/N)->",
  103.                 1, g_text_char_v - 1, g_norm_attrib);
  104.             ans = getche();
  105.             if (toupper(ans) == 'Y'){
  106.                 erase_all();
  107.                 strcpy(g_songtitle, " ");
  108.                 strcpy(g_filename, "NO_NAME.SNG");
  109.                 init_tracks();
  110.             }
  111.             break;
  112.         case(7):                            /* import */
  113.             import_menu();
  114.             break;
  115.         case(8):                            /* help */
  116.             help_control();
  117.             break;
  118.         case(-2):                           /* esc key */
  119.         case(NPARAM1 - 1):                  /* quit */
  120.             writeword("Don't forget to SAVE data.  Quit? (Y/N) "
  121.                     ,1 , g_text_char_v - 1, g_norm_attrib);
  122.             ans = getche();
  123.             if(toupper(ans) != 'Y'){
  124.                 pick = lastpick;
  125.                 break;
  126.             }
  127.             else{
  128.                 clearscreen(BWC);
  129.                 exit(0);
  130.             }
  131.         default:
  132.             writerr("Use arrow keys to move cursor, ret to select.",
  133.                 g_text_char_v - 1, g_norm_attrib, g_emph_attrib);
  134.             pick = lastpick;
  135.         }
  136.     }
  137. }
  138.