home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI04.ARJ / ictari.04 / C / SOURCE.SEQ / SAM_SE17.C < prev    next >
Text File  |  1992-12-21  |  34KB  |  1,198 lines

  1. /************************************************************************/
  2. /*               STEreo SAMPLE SEQUENCING SYSTEM V1.10beta              */
  3. /*                       written by PHAZE Shift                         */
  4. /*                                                                      */
  5. /*                         C-Source Code ONLY                           */
  6. /*            must be linked with assembled machine code file           */
  7. /*                        © Ian Hancock 19/11/92                        */
  8. /************************************************************************/
  9.  
  10. /***************************** INCLUDE FILES ****************************/
  11. #include    <osbind.h>
  12. #include    <stddef.h>
  13. #include    <errno.h>
  14. #include     <stdio.h>
  15. #include     <stdlib.h>
  16. #include     <string.h>
  17. #include    <dos.h>
  18. #include     <aes.h>
  19. #include     <vdi.h>
  20. #include     "seqmed.h"
  21. /************************* FUNCTION PROTOTYPES **************************/
  22. char *Sample_load(char wholename[80]);
  23. void handle_dialog(OBJECT *dlog);
  24. void initialise(void);
  25. void deinitialise(void);
  26. void waiting(int time);
  27. int direct(int lineno);
  28. void Sample_save(char wholename[80], int sam);
  29. void loaddat(OBJECT *dlog,int a,int b,short x,short y,short w,short h,char nom[30],short mode,int sam);
  30. void Sequence_save(char wholename[80],short mode);
  31. void Sequence_load(char wholename[80],short mode);
  32. void set_button(OBJECT *tree,int parent,int button);
  33. int playing(int lineno);
  34. void recording(void);
  35. void Sample_list(int lineno2);
  36. void cls(void);
  37. void seq_display(int lineno);
  38. void editing(int lineno);
  39. int get_end(void);
  40. /***************************** FILE STRUCTURES **************************/
  41. struct file {            /* Audio Visual Research 1st 30 bytes of header*/
  42.     char    ident[4];
  43.     char    name[8];
  44.     short stereo;
  45.     short resolution;
  46.     short sign;
  47.     short loop;
  48.     short midi;
  49.     int speed;
  50.     int length;
  51. } avr;
  52. struct seq {            /* my sequence file header */
  53.     char    ident[19];    /* id code */
  54.     char    samples;        /* no of samples used */
  55.     unsigned int slength;    /* length of sequence file */
  56.     unsigned int size[18];    /* length of each sample */
  57. } amazinge;
  58. /**************************** GLOBAL VARIABLES **************************/
  59. char *sam_start[19];    /* array of pointers to samples in memory */
  60. int space = 32000;    /* memory allocated for sequence in bytes */
  61. long error;        /* return val from proggy, or negative (error) */
  62. char count = -1;    /* number of samples in memory minus 1 */
  63. unsigned short int *sequence, *buffer;    /* pointers to the sequence and */
  64.                                 /* buffer area */
  65. short vdi;    /* Virtual Device Number */
  66. char pathname[70] = "A:\*.*";        /* File path */
  67. char key[] = "()/*7894561230.E";
  68. /********************************* PROGRAM ******************************/
  69. int main(void)
  70. {
  71. OBJECT *dlog;
  72.  
  73.     initialise();
  74.     
  75.     rsrc_gaddr(R_TREE,SEQ,&dlog);        /* get address of form in dlog */
  76.     handle_dialog(dlog);            /* main loop */
  77.     
  78.     deinitialise();
  79.     return EXIT_SUCCESS;
  80. }
  81. /****************** SET UP GEM - LOAD RSC. ALLOCATE MEMORY **************/
  82. void initialise(void)
  83. {
  84. short work_in[11]={1,1,1,1,1,1,1,1,1,1,2};
  85. short work_out[57];
  86. short junk;
  87. short screenx,screeny,screenw,screenh;
  88.     
  89.     if (appl_init())    /* open aes application */
  90.         exit(EXIT_FAILURE);
  91.     vdi = graf_handle(&junk, &junk, &junk, &junk);    /* get temp. vdi no */
  92.     v_opnvwk(work_in, &vdi, work_out);    /* update vdi id number */
  93.     if (!vdi)
  94.         exit(EXIT_FAILURE);        /* vdi failure */
  95.         
  96.     if (Getrez() == 2)
  97.     {
  98.         if (!rsrc_load("seqhigh.RSC"))    /* load resource file */
  99.         {
  100.             form_alert(1,"[3][RESOURCE FILE ERROR][ QUIT ]");
  101.             exit(EXIT_FAILURE);
  102.         }
  103.     }
  104.     else if (Getrez() == 0)
  105.     {
  106.         form_alert(1,"[3][SORRY MEDIUM | OR HIGH RES. ONLY][ QUIT ]");
  107.         exit(EXIT_FAILURE);
  108.     }
  109.     else
  110.     {
  111.         if (!rsrc_load("seqmed.RSC"))    /* load resource file */
  112.         {
  113.             form_alert(1,"[3][RESOURCE FILE ERROR][ QUIT ]");
  114.             exit(EXIT_FAILURE);
  115.         }
  116.     }
  117.     wind_get(DESK,WF_WORKXYWH,&screenx,&screeny,&screenw,&screenh);
  118.         /* get screen size co-ords */
  119.     graf_mouse(ARROW,NULL);    /* put mouse on screen */
  120.  
  121.     if ((sequence = malloc(space)) == NULL)    /* sample bank memory */
  122.     {
  123.         form_alert(1,"[3][ OUT OF MEMORY ERROR | CANNOT INSTALL !][ CANCEL ]");
  124.         exit(EXIT_FAILURE);
  125.     }
  126.     if ((buffer = malloc(32000)) == NULL)    /* sample bank memory */
  127.     {
  128.         form_alert(1,"[3][ OUT OF MEMORY ERROR | CANNOT INSTALL !][ CANCEL ]");
  129.         exit(EXIT_FAILURE);
  130.     }
  131.     /* ⇧ allocate space bytes for sequence and buffer */
  132.     *(sequence+3) = 0xffff;    /* put end of sequence flag in sequence */
  133.     count = -1;    /* no samples in memory */
  134.     Click(0);        /* MC- turn off keyclick + bell */
  135. }
  136. /*********************** SHUT DOWN - CLOSE WORK BASE ********************/
  137. void deinitialise(void)
  138. {
  139.     rsrc_free();        /* free up resource file */
  140.     v_clsvwk(vdi);        /* close work station */
  141.     appl_exit();        /* close aes application */
  142.     Click(7);            /* MC- restore keyclick and bell */
  143. }
  144. /***************************** MAIN SUB-ROUTINE *************************/
  145. void handle_dialog(OBJECT *dlog)
  146. {
  147.     char ok;            /* response from keyboard */
  148.     short x,y,w,h;        /* screen co-ords */
  149.     char *path;        /* pointer to pathname (file path) */
  150.     int but, cnt;        /* but = what button pressed */
  151.     int lineno = 0;    /* line position in sequence */
  152.     int lineno2 = 0;    /* line position in sample list */
  153.     int radio = DMSAM;    /* set list mode to sample list */
  154.     int an_error;        /* set to 1 or 2 if a record error occurs */
  155.     
  156.     path = &pathname[0];        /* set pointer to start of pathname */
  157.     set_button(dlog,DMODE,radio);    /* set radio button to highlight sample */
  158.     
  159.     form_center(dlog,&x,&y,&w,&h);    /* get centre form on screen co-ords */
  160.     form_dial(FMD_START,0,0,0,0,x,y,w,h);    /* grow from 0,0,0,0 */
  161.     form_dial(FMD_GROW,x+w/2,y+h/2,0,0,x,y,w,h); /* do grow */
  162.     objc_draw(dlog,ROOT,MAX_DEPTH,x,y,w,h);        /* draw form */
  163.     but = DRECORD;        /* but initialised (so it won't exit */
  164.     while (but != DBYE)    /* if not clicked on exit */
  165.     {
  166.         set_button(dlog,DMODE,radio);        /* highlight right radio but */
  167.         while (Crawio(0x00ff) != 0);
  168.  
  169.         but = form_do(dlog, 0);        /* let user interact */
  170.         vs_curaddress(vdi, 10, 15);    /* set cursor to top of box */
  171.         STOP();    /* MC clears sound chip incase exit */
  172.         switch (but)    /* what button was pressed */
  173.         {
  174.             case DTEST:    /* test mode */
  175.                 printf("***** TEST ***** NON-SAMPLE KEY TO STOP   ");
  176.                 TEST(&sam_start[0], count);    /* MC */
  177.                 STOP();    /* MC */
  178.                 break;
  179.             
  180.             case DPLAY:    /* play mode */
  181.                 printf("***** PLAY *****                          ");
  182.                 lineno = playing(lineno);   /* MC - return current line */
  183.                 if (lineno < 0)    /* occasionally = -1; CORRECTION */
  184.                     lineno = 0;
  185.                 break;
  186.  
  187.             case DRECORD:    /* recording mode */
  188.                 if (*(sequence+3) == 0xffff)    /* if seq. is empty */
  189.                     ok = 1;
  190.                 else        /* else ask if you want to wipe */
  191.                 {
  192.                     ok = form_alert(1,"[3][ CLEAR CURRENT MIX !][ YES | NO ]");
  193.                 }
  194.                 if (ok == 1)
  195.                 {
  196.                     vs_curaddress(vdi, 10, 15);    /* set cursor */
  197.                     printf("***** RECORD ***** NON-SAMPLE KEY STOPS   ");
  198.                     recording();    /* C sets up record and calls MC */
  199.                     lineno = 0;    /* reset line position to start of seq. */
  200.                 }
  201.                 break;
  202.  
  203.             case DODUB:    /* dubbing mode */
  204.                 /* if not an empty seq. and not on start line pos */
  205.                 if (*(sequence+3) != 0xffff && lineno != 0)
  206.                 {
  207.                     ok = form_alert(1,"[2][ WIPE FROM CURRENT TO END !][ YES | NO ]");
  208.                     if (ok == 1)
  209.                     {
  210.                         vs_curaddress(vdi, 10, 15);
  211.                         printf("***** DUBBING ***** NON-SAMPLE KEY STOPS  ");
  212.                         if (an_error = RECORD(&sam_start[0],count,sequence+lineno,space-(lineno*2),0))    /* MC */
  213.                         {
  214.                             vs_curaddress(vdi, 10, 15);
  215.                             if (an_error == 2)
  216.                                 form_alert(1,"[3][ OUT OF MEMORY IN SEQUENCE FILE ! | ADVISE SAVING YOUR SEQUENCE | AND RESTART ! ][ OK ]");
  217.                             else
  218.                                 form_alert(1,"[3][ OUT OF TIME | 65535 UNITS ONLY !!! ][ SORRY ]");                            
  219.                         }
  220.                         STOP();    /* MC */
  221.                         lineno = 0;    /* reset line pos to start */
  222.                     }
  223.                 }
  224.                 break;
  225.                 
  226.             case DMIX:    /* mixing mode */
  227.                 printf("***** MIXING ***** NON-SAMPLE KEY STOPS  ");
  228.                 editing(lineno);    /* C - calls MC */
  229.                 break;
  230.                 
  231.             case DDIRECT:    /* direct editing of seq. */
  232.                 Click(6);
  233.                 if (radio == DMSEQ)        /* if in seq. list mode */
  234.                     lineno = direct(lineno);
  235.                 Click(0);
  236.                 break;
  237.                 
  238.             case DUP:        /* up cursor */
  239.                 if (radio == DMSEQ && lineno-2 >= 0) /* if in seq mode and can go up */
  240.                     lineno -= 2;
  241.                 else if (radio == DMSAM && lineno2-1 >= 0) /* if in sam mode and can go up */
  242.                     lineno2--;
  243.                 break;
  244.             
  245.             case DDOWN:    /* down cursor */
  246.                 if (radio == DMSEQ && lineno+2 <= get_end())
  247.                     lineno += 2;
  248.                 else if (radio == DMSAM && lineno2+1 <= count)
  249.                     lineno2++;
  250.                 break;
  251.             
  252.             case DFUP:    /* jump 7 lines up cursor */
  253.                 if (radio == DMSEQ && lineno-14 >= 0)
  254.                     lineno -= 14;
  255.                 else if (radio == DMSEQ)
  256.                     lineno = 0;
  257.                 else if (radio == DMSAM && lineno2-7 >= 0)
  258.                     lineno2 -= 7;
  259.                 else if (radio == DMSAM)
  260.                     lineno2 = 0;
  261.                 break;
  262.                 
  263.             case DFDOWN:    /* jump 7 lines down cursor */
  264.                 if (radio == DMSEQ && lineno+14 <= get_end())
  265.                     lineno += 14;
  266.                 else if (radio == DMSEQ)
  267.                     lineno = get_end();
  268.                 else if (radio == DMSAM && lineno2+7 <= count)
  269.                     lineno2 += 7;
  270.                 else if (radio == DMSAM && count >= 0)
  271.                     lineno2 = count;
  272.                 break;
  273.                 
  274.             case DTOP:    /* scroll to top cursor */
  275.                 if (radio == DMSEQ)
  276.                     lineno = 0;
  277.                 else
  278.                     lineno2 = 0;
  279.                 break;
  280.                 
  281.             case DBOTTOM:    /* scroll to bottom cursor */
  282.                 if (radio == DMSEQ)
  283.                     lineno = get_end();
  284.                 else if (count >= 0)
  285.                     lineno2 = count;
  286.                 break;
  287.                 
  288.             case DLSAM:    /* load a sample file */
  289.                 strmfe(path,path,"AVR");    /* add AVR extension to path */
  290.                 if (count < 15)
  291.                     loaddat(dlog,ROOT,MAX_DEPTH,x,y,w,h,"LOAD SAMPLE",0,0);
  292.                 break;
  293.  
  294.             case DDEL:
  295.                 if (count > 0 && *(sequence+3) == 0xffff)
  296.                 {
  297.                     ok = form_alert(1,"[3][ DELETE A DISK FILE | OR THE CURRENT SAMPLE | IN MEMORY !][ SAMPLE | FILE | CANCEL ]");
  298.                     if (ok == 1)
  299.                     {
  300.                         free(sam_start[lineno2]);
  301.                         while (lineno2 < 17)
  302.                             sam_start[lineno2] = sam_start[++lineno2];
  303.                         count--;
  304.                         lineno2 = 0;
  305.                     }
  306.                     else if (ok == 2)
  307.                     {
  308.                         strmfe(path,path,"*");
  309.                         loaddat(dlog,ROOT,MAX_DEPTH,x,y,w,h,"DELETE A FILE",6,0);
  310.                     }
  311.                 }
  312.                 else
  313.                 {
  314.                     strmfe(path,path,"*");
  315.                     loaddat(dlog,ROOT,MAX_DEPTH,x,y,w,h,"DELETE A FILE",6,0);
  316.                 }
  317.                 break;
  318.             
  319.             case DHEAD:
  320.                 strmfe(path,path,"*");
  321.                 loaddat(dlog,ROOT,MAX_DEPTH,x,y,w,h,"HEAD A FILE",7,0);
  322.                 break;
  323.             
  324.             
  325.             case DSSAM:    /* save a sample file */
  326.                 if (count >= 0)
  327.                 {
  328.                     strmfe(path,path,"AVR");
  329.                     loaddat(dlog,ROOT,MAX_DEPTH,x,y,w,h,"SAVE SAMPLE",5,lineno2);
  330.                 }
  331.                 break;
  332.             
  333.             case DMSEQ:    /* set to sequence list mode */
  334.                 radio = DMSEQ;    /* make radio button change next loop */
  335.                 but = DCLS;    /* make it redraw the list box */
  336.                 break;
  337.                 
  338.             case DMSAM:    /* set to sample mode */
  339.                 but = DCLS;    /* as above */
  340.                 radio = DMSAM;
  341.                 break;
  342.                 
  343.             case DSSEQ:    /* save a sequence */
  344.                 if (count >= 0 && *(sequence+3) != 0xffff)
  345.                 {
  346.                     lineno = lineno2 = 0; /* reset line pos */
  347.                     objc_draw(dlog, DCLS, 1,x,y,w,h);    /* clear list box */
  348.                     ok = form_alert(1,"[2][ SAVE FILE !][ ALL | MIX | CANCEL ]");
  349.                     if (ok == 1)
  350.                     {
  351.                         strmfe(path,path,"SEQ");    /* set path extension */
  352.                         loaddat(dlog,ROOT,MAX_DEPTH,x,y,w,h,"SAVE MIX AND SAMPLES",1,0);
  353.                     }
  354.                     else if (ok == 2)
  355.                     {
  356.                         strmfe(path,path,"MIX");
  357.                         loaddat(dlog,ROOT,MAX_DEPTH,x,y,w,h,"SAVE MIX ONLY",2,0);
  358.                     }
  359.                 }
  360.                 else
  361.                 {
  362.                     form_alert(1,"[1][ YOU CAN'T SAVE A SEQUENCE | WITHOUT A MIX !][ CANCEL ]");
  363.                 }
  364.                 break;
  365.             
  366.             case DLSEQ:    /* load a sequence */
  367.                 lineno = lineno2 = 0;
  368.                 objc_draw(dlog, DCLS, 1,x,y,w,h);
  369.                 ok = form_alert(1,"[2][ LOAD FILE !][ ALL | MIX | CANCEL ]");
  370.                 if (ok == 1)
  371.                 {
  372.                     strmfe(path,path,"SEQ");
  373.                     loaddat(dlog,ROOT,MAX_DEPTH,x,y,w,h,"LOAD MIX AND SAMPLES",3,0);
  374.                 }
  375.                 else if (ok == 2)
  376.                 {
  377.                     strmfe(path,path,"MIX");
  378.                     loaddat(dlog,ROOT,MAX_DEPTH,x,y,w,h,"LOAD MIX ONLY",4,0);
  379.                 }
  380.                 break;
  381.  
  382.             case DAC:        /* all clear */
  383.                 ok = form_alert(2,"[2][ CLEAR EVERYTHING !][ YES | NO ]");
  384.                 if (ok == 1)
  385.                 {
  386.                     for (cnt=0; cnt <= count; cnt++)
  387.                         free(sam_start[cnt]);
  388.                     count = -1;
  389.                     *(sequence+3) = 0xffff;
  390.                     lineno = lineno2 = 0;
  391.                 }
  392.                 break;
  393.                 
  394.             case DCLRMIX:    /* clear the mix */
  395.                 ok = form_alert(1,"[2][ CLEAR MIX - ONLY !][ YES | NO ]");
  396.                 if (ok == 1)
  397.                 {
  398.                     *(sequence+3) = 0xffff;
  399.                     lineno = 0;
  400.                 }
  401.                 break;
  402.                 
  403.             case DPANIC:    /* maybe help mode */
  404. form_alert(1,"[1][   WRITTEN BY I.D.HANCOCK | USING HISOFT'S LATTICE C V5 |------------------------------|'look for the ridiculous in |everything and you'll find it'][ SMILE ! BE HAPPY ! ]");
  405.                 break;
  406.                 
  407.             case DBYE: /* do you wana leave */
  408.                 ok = form_alert(1,"[3][ LEAVING ME !! | |  GOODBYE !][ NOPE | YES ]");
  409.                 if (ok == 1)
  410.                 {
  411.                     dlog[but].ob_state&=~SELECTED;    /* de-select exit button */
  412.                     objc_draw(dlog, but, 1,x,y,w,h);    /* redraw button (object)*/
  413.                     but = DPANIC;
  414.                 }
  415.                 break;
  416.                 
  417.             break;        
  418.         }
  419.         dlog[but].ob_state&=~SELECTED;    /* de-select exit button */
  420.         objc_draw(dlog, but, 1,x,y,w,h);    /* redraw button (object)*/
  421.  
  422.         if (radio == DMSAM)            /* update active list */
  423.             Sample_list(lineno2);
  424.         else
  425.             seq_display(lineno);
  426.  
  427.     }    /* loop, or exit */
  428.     form_dial(FMD_SHRINK,x+w/2,y+h/2,0,0,x,y,w,h);    /* close form */
  429.     form_dial(FMD_FINISH,0,0,0,0,x,y,w,h);
  430.     dlog[but].ob_state&=~SELECTED;    /* de-select exit button */
  431. }
  432. /************************** SORT OUT RADIO BUTTONS **********************/
  433. void set_button(OBJECT *tree,int parent,int button)
  434. {
  435.     int b;
  436.     
  437.     for (b=tree[parent].ob_head; b!=parent; b=tree[b].ob_next)
  438.         if (b==button)
  439.             tree[b].ob_state|=SELECTED;
  440.         else
  441.             tree[b].ob_state&=~SELECTED;
  442. }
  443. /************************* DIRECT EDIT ROUTINE **************************/
  444. int direct(int lineno)
  445. {
  446. unsigned short int *contents;
  447. char ok = '©';    /* keyboard input */
  448. int difference;    /* amount to shuffle other items by (+ or -) */
  449.  
  450.     contents = sequence;    /* point contents to start of sequence */
  451.     contents += lineno;        /* add line pos. to contents */
  452.                         /* note lineno = 2*line displace on screen */
  453.     difference = *contents;    /* set difference to current time */
  454.     
  455.     if (lineno != get_end() && lineno != 0)    /* if not at start or end item */
  456.     {
  457.         vs_curaddress(vdi, 11, 15);
  458.         printf("'+' INCREASE DELAY. '-' DECREASE DELAY.   ");
  459.         vs_curaddress(vdi, 12, 15);
  460.         printf("SPACE - CHANGE TIME WITH SHUFFLE          ");
  461.         vs_curaddress(vdi, 13, 15);
  462.         printf("N - CHANGE TIME WITHOUT SHUFFLE.          ");
  463.         vs_curaddress(vdi, 14, 15);
  464.         printf("X - DELETE WITHOUT SHUFFLE.               ");
  465.         vs_curaddress(vdi, 15, 15);
  466.         printf("D - DELETE WITH SHUFFLE.                  ");
  467.         vs_curaddress(vdi, 16, 15);
  468.         printf("Q - CANCEL.                               ");
  469.  
  470.         while ((ok = Bconin(2)) == '+' || ok == '-')
  471.         {
  472.             vs_curaddress(vdi, 10, 15);
  473.  
  474.             if (ok == '+' && *contents + 1 < *(contents+2))
  475.                 *contents += 1;    /* increase time if within bounds */
  476.             if (ok == '-' && *contents - 1 > *(contents-2))
  477.                 *contents -= 1;    /* decrease as above */
  478.         
  479.             printf("%4d =  %5d    -    %2d                 ", (lineno/2), *contents, *(contents+3));
  480.         }
  481.     }
  482.     else if (lineno != 0)    /* if not at start */
  483.     {
  484.         vs_curaddress(vdi, 11, 15);
  485.         printf("'+' INCREASE DELAY. '-' DECREASE DELAY.   ");
  486.         vs_curaddress(vdi, 12, 15);
  487.         printf("N - CHANGE TIME WITHOUT SHUFFLE.          ");
  488.         vs_curaddress(vdi, 13, 15);
  489.         printf("X - DELETE WITHOUT SHUFFLE.               ");
  490.         vs_curaddress(vdi, 14, 15);
  491.         printf("Q - CANCEL.                               ");
  492.         vs_curaddress(vdi, 15, 15);
  493.         printf("                                          ");
  494.         vs_curaddress(vdi, 16, 15);
  495.         printf("                                          ");
  496.         
  497.         while ((ok = Bconin(2)) == '+' || ok == '-')
  498.         {
  499.             vs_curaddress(vdi, 10, 15);
  500.  
  501.             if (ok == '+' && *contents + 1 < 0xffff)
  502.                 *contents += 1;    /* increase time if within bounds */
  503.             if (ok == '-' && *contents - 1 > *(contents-2))
  504.                 *contents -= 1;    /* decrease as above */
  505.         
  506.             printf("%4d =  %5d    -    %2d                 ", (lineno/2), *contents, *(contents+3));
  507.         }
  508.         if (ok != 'n' && ok != 'N' && ok != 'x' && ok != 'X')
  509.             ok = 'q';
  510.     }
  511.     else if (lineno == 0 && *(sequence+3) != 0xffff)    /* if its the start item */
  512.     {
  513.         vs_curaddress(vdi, 11, 15);
  514.         printf("D - DELETE WITH SHUFFLE.                  ");
  515.         vs_curaddress(vdi, 12, 15);
  516.         printf("Q - CANCEL.                               ");
  517.         vs_curaddress(vdi, 13, 15);
  518.         printf("                                          ");
  519.         vs_curaddress(vdi, 14, 15);
  520.         printf("                                          ");
  521.         vs_curaddress(vdi, 15, 15);
  522.         printf("                                          ");
  523.         vs_curaddress(vdi, 16, 15);
  524.         printf("                                          ");
  525.  
  526.         ok = Bconin(2);
  527.         if (ok != 'D' && ok != 'd')
  528.             ok = '©';
  529.     }
  530. /**********  do alteration or not !! **********/    
  531.     if (ok == ' ')
  532.     {
  533.         difference = *contents - difference; /* calc difference */
  534.         contents += 2;    /* inc. to next time in sequence */
  535.         while (*contents != 0xffff)    /* until end flag */
  536.         {
  537.             *contents += difference;    /* add difference to item (shuffle) */
  538.             contents += 2;    /* inc. to next time */
  539.         }
  540.     }
  541.     else if (ok == 'N' || ok == 'n')
  542.     {}
  543.     else if (ok == 'D' || ok == 'd')
  544.     {
  545.         DELETE(sequence+lineno);    /* MC routine */
  546.         contents = sequence+lineno;    /* set up and shuffle */
  547.         difference -= *contents;
  548.         while (*contents != 0xffff)
  549.         {
  550.             *contents += difference;
  551.             contents += 2;
  552.         }
  553.     }
  554.     else if (ok == 'X' || ok == 'x')
  555.     {
  556.         DELETE(sequence+lineno);    /* MC */
  557.         if (lineno != 0)
  558.             lineno -= 2;
  559.     }
  560.     else if (ok != '©')
  561.         *contents = difference;    /* restore old time value */
  562.     
  563.     return (lineno);
  564. }
  565. /************************* DISPLAY SEQUENCE INFO ************************/
  566. void seq_display(int lineno)
  567. {
  568. unsigned short int *contents;
  569. int line = 0;    /* on screen cursor positioning displacement */
  570.  
  571.     vs_curaddress(vdi, 10, 15);
  572.             
  573.     contents = sequence;    /* pointer to start of sequence */
  574.     contents += 3;            /* point to second time */
  575.     contents += lineno;        /* add displacement */
  576.     while (*contents != 0xffff && line < 7)    /* until seq. end or 7 lines printed */
  577.     {
  578.         vs_curaddress(vdi, 10+line, 15);
  579.         printf("%4d =  %5d    -    %2d                 ", (lineno/2)+line, *(contents-3), *contents);
  580.         contents += 2;        /* inc. by 1 item */
  581.         line++;            /* inc. by one screen line */
  582.     }
  583.     if (line != 7)        /* if all lines not used, blank rest */
  584.     {
  585.         while (line < 7)
  586.         {
  587.             vs_curaddress(vdi, 10+line, 15);
  588.             printf("                                          ");
  589.             line++;
  590.         }
  591.     }
  592. }
  593. /******* GET END DISPLACEMENT (address) FROM START OF SEQUENCE **********/
  594. int get_end(void)
  595. {
  596. int contents = 3;
  597.  
  598.     while (*(sequence+contents) != 0xffff)    /* loop till end flag */
  599.         contents += 2;    /* inc. by one item */
  600.     if (contents == 3)    /* if == 3 then no seq. */
  601.         return (0);
  602.     return (contents-5); /* -3 for initial, -2 for flag pos */
  603. }
  604. /************************* FILE SELECTOR ROUTINE ************************/
  605. void loaddat(OBJECT *dlog,int a,int b,short x,short y,short w,short h,char nom[30],short mode,int sam)
  606. {
  607. char wholename[80];
  608. char filename[13] = "";    /* blank off filename bit */
  609. char *aname, thename[9];
  610. char *memory;
  611. char ok;
  612. long size;
  613. int quit = 0;
  614. short ok_clicked;
  615. char *n, *p, *strrchr();
  616. struct file *xp;
  617. struct DISKINFO info;
  618. FILE*fp;
  619. long int start;
  620.  
  621.     aname = &thename[0];
  622.     xp = &avr;
  623.     n = &nom[0];    /* title for item selector */
  624.  
  625.     vs_curaddress(vdi, 10, 15);
  626.      if (fsel_exinput(pathname, filename, &ok_clicked, n) && ok_clicked)
  627.      {
  628.         objc_draw(dlog,a,b,x,y,w,h);    /* re-draw form */
  629.           
  630.           graf_mouse(HOURGLASS, NULL);
  631.           strcpy(wholename, pathname);
  632.           if (p = strrchr(wholename, '\\'))
  633.           {
  634.                strcpy(p+1, filename);
  635.             switch (mode)
  636.             {
  637.                 case 0:
  638.                     if (count < 17)
  639.                     {
  640.                         sam_start[++count] = Sample_load(wholename);
  641.                         if (*sam_start[count] == NULL)
  642.                         count--;
  643.                     }
  644.                     else
  645.                     {
  646.                         form_alert(1,"[1][ TOO MANY SAMPLES ! | MAXIMUM 16 ONLY !][ OK ]");
  647.                     }
  648.                      break;
  649.                      
  650.                  case 1:
  651.                      Sequence_save(wholename,0);
  652.                      break;
  653.                      
  654.                  case 2:
  655.                      Sequence_save(wholename,1);
  656.                      break;
  657.                      
  658.                  case 3:
  659.                      Sequence_load(wholename,0);
  660.                      break;
  661.                      
  662.                  case 4:
  663.                      Sequence_load(wholename,1);
  664.                      break;
  665.  
  666.                 case 5:
  667.                     Sample_save(wholename, sam);
  668.                     break;
  669.                      
  670.                  case 6:    /* delete file */
  671.                      printf("** DELETE  %.12s (Y/N) **",filename);
  672.                      ok = Bconin(2);
  673.                      if (ok == 'y' || ok == 'Y')
  674.                      {
  675.                          if (remove(wholename) != 0)
  676.                             form_alert(1,"[3][ CAN'T DELETE FILE ! ][ CANCEL ]");
  677.                     }
  678.                     break;
  679.                     
  680.                 case 7:    /* head a sample with avr format */
  681.                     vs_curaddress(vdi, 10, 15);
  682.                     
  683.                     xp = &avr;
  684.                     
  685.                     if (fp = fopen(wholename, "rb"))    /* open seq file READ only */
  686.                     {
  687.                         if (fseek(fp,0L,SEEK_END) !=0)
  688.                             form_alert(1,"[3][ FILE NOT VALID !][ CANCEL ]");
  689.                         start = ftell(fp);
  690.                         rewind(fp);
  691.                         if ((memory = calloc(start+130,1)) == NULL) /* sample bank memory */
  692.                         {
  693.                             form_alert(1,"[3][ RAN OUT OF MEMORY ERROR !!!][ CANCEL ]");
  694.                             return;
  695.                         }
  696.                         fread(xp,1,4,fp);
  697.                         rewind(fp);
  698.                         if (strncmp("2BIT",avr.ident,4) == 0)
  699.                         {    
  700.                             printf("***** AN AVR SAMPLE FILE !! *****");
  701.                                 waiting(800);
  702.                             fread(memory,1,start,fp);
  703.                             start -= 128;
  704.                         }
  705.                         else
  706.                         {
  707.                             memory += 128;
  708.                             fread(memory,1,start,fp);
  709.                             memory -= 128;
  710.                         }
  711.                         fclose(fp);
  712.                     }
  713.                     else
  714.                     {
  715.                         form_alert(1,"[3][ NO FILE SORRY !][ CANCEL ]");
  716.                         graf_mouse(ARROW, NULL);
  717.                         return;
  718.                     }
  719.                     /* file fine */
  720.  
  721.                     vs_curaddress(vdi, 10, 15);
  722.                             
  723.                     printf("*Creates an 8-BIT AVR STANDARD Header.*");
  724.                     vs_curaddress(vdi, 12, 15);
  725.                     printf("NOTE: This is the sample name -"); 
  726.                     vs_curaddress(vdi, 13, 15);
  727.                     printf("        NOT the FILENAME !!!!");
  728.                     vs_curaddress(vdi, 14, 15);
  729.                     printf("NAME: (MAX 8 CHARS, NO SPACES) ->");
  730.                     Click(7); /* key clk on */
  731.                     ok = 0;
  732.                     while (ok == 0)
  733.                     {
  734.                         while (ok <= 7 && (aname[ok] = Crawcin()) != 13 )
  735.                         {
  736.                             if (aname[ok] < '0' || aname[ok] > 'z')
  737.                                 putchar('\7');
  738.                             else
  739.                             {
  740.                                 putchar(aname[ok]);
  741.                                 ok++;
  742.                             }
  743.                         }
  744.                     }
  745.                     if (ok < 7)
  746.                         aname[ok] = 0;
  747.                     Click(0); /* key clk off */
  748.  
  749.                     strncpy(avr.ident, "2BIT",4);
  750.                     p = &avr.name[0];
  751.                     memset(p,0,26);
  752.                     strncpy(p, aname, 8);
  753.                             
  754.                     ok = form_alert(1,"[2][ SAMPLE TYPE ][ MONO | STEREO ]");
  755.  
  756.                     if (ok == 2)
  757.                         avr.stereo = 0xffff;
  758.                     
  759.                     ok = form_alert(1,"[2][ SAMPLE TYPE ][ SIGNED | UNSIGNED ]");
  760.     
  761.                     if (ok == 1)
  762.                         avr.sign = 0xffff;
  763.                                 
  764.                     ok = form_alert(1,"[2][ SAMPLE PLAY MODE ][ ONCE | LOOPED ]");
  765.                     if (ok == 2)
  766.                         avr.loop = 0xffff;
  767.                     avr.midi = 0xffff;
  768.                     avr.resolution = 0x0008;
  769.                                 
  770.                     ok = form_alert(2,"[2][ PLAYBACK FREQUENCY | IN Khz ][ 6 | 12 | OTHER ]");
  771.                     if (ok == 3)
  772.                     {
  773.                         ok = form_alert(1,"[2][ PLAYBACK FREQUENCY | IN Khz ][ 25 | 50 ]");
  774.                         ok += 2;
  775.                     }
  776.                     if (ok == 4)
  777.                         avr.speed = 0xff00c800;
  778.                     else if (ok == 2)
  779.                         avr.speed = 0xff0030fa;
  780.                     else if (ok == 3)
  781.                         avr.speed = 0xff006400;
  782.                     else
  783.                         avr.speed = 0xff00187d;
  784.                     avr.length = start;
  785.                     memset(memory,0,128);
  786.                     memcpy(memory, xp, 30);
  787.                     
  788.                     ok = form_alert(1,"[2][ SAVE CHANGES IN THE |  SELECTED FILE ? | NOTE: This overwrites | the existing file. ][ YES | NO ]");
  789.     
  790.                     if (ok == 2)
  791.                         quit = 1;
  792.  
  793.                     objc_draw(dlog,DCLS,1,x,y,w,h);    /* re-draw form */
  794.                     if (getdfs(wholename[0]-0x40,&info) == 0)
  795.                         size = (long)info.free*info.spc*info.bps;
  796.                     while (size < start+150 && quit == 0)
  797.                     {
  798. ok = form_alert(2,"[3][ NOT ENOUGH SPACE FREE | ON THE DISK. | INSERT ANOTHER DISK ?][ YES | NO ]");
  799.                         if (ok == 2)
  800.                             quit = 1;
  801.                         else
  802.                             if (getdfs(wholename[0]-0x40,&info) == 0)
  803.                                 size = (long)info.free*info.spc*info.bps;
  804.                     }
  805.                     while (quit == 0)
  806.                     {
  807.                         if (fp = fopen(wholename, "wb"))
  808.                         {
  809.                             if (fwrite(memory,1,start+128,fp) != start+128)
  810.                             {
  811.                                 form_alert(1,"[3][ DISK FULL | FILE NOT SAVED !][ CANCEL ]");
  812.                                 fclose(fp);
  813.                                 if (remove(wholename) != 0)
  814.                                 {
  815.                                     form_alert(1,"[3][ CAN'T DELETE FILE ! ][ CANCEL ]");
  816.                                 }
  817.                                 quit = 1;
  818.                             }
  819.                             else
  820.                             {
  821.                                 quit = 1;
  822.                                 fclose(fp);
  823.                             }
  824.                         }
  825.                         else
  826.                         {
  827.                             ok = form_alert(1,"[3][ DISK WRITE PROTECTED ! ][ RETRY | CANCEL ]");
  828.                             if (ok == 2)
  829.                                 quit = 1;
  830.                         }
  831.                     }
  832.                     free(memory);
  833.                     break;
  834.                     
  835.                  break;
  836.              }
  837.           }
  838.           graf_mouse(ARROW, NULL);
  839.      }
  840.      else
  841.         objc_draw(dlog,a,b,x,y,w,h);    /* re-draw form */
  842. }
  843. /************************** SAVE A SAMPLE FROM MEMORY ******************/
  844. void Sample_save(char wholename[80], int sam)
  845. {
  846. FILE*fp;
  847. struct file *p;
  848.  
  849.     p = &avr;    /* pointer to avr structure */
  850.  
  851.     memcpy (p, sam_start[sam], 30);    /* put header in avr struc */
  852.     vs_curaddress(vdi, 10, 15);
  853.  
  854.     if (fp = fopen(wholename, "wb"))    /* write file */
  855.     {
  856.         if (fwrite(sam_start[sam], 1,(128+avr.length), fp) == 128+avr.length)
  857.             fclose(fp);                        /* close it */
  858.         else
  859.         {
  860.             form_alert(1,"[3][ DISK FULL | FILE NOT SAVED ][ CANCEL ]");
  861.             fclose(fp);
  862.             if (remove(wholename) != 0)
  863.             {
  864.                 form_alert(1,"[3][ CAN'T DELETE FILE ! ][ CANCEL ]");
  865.             }
  866.         }
  867.     }
  868.     else
  869.         form_alert(1,"[3][ DISK WRITE PROTECTED !][ CANCEL ]");
  870. }
  871. /************** SAVE SEQUENCE OR ALL DEPENDING ON MODE ******************/
  872. void Sequence_save(char wholename[80], short mode)
  873. {
  874. FILE*fp;
  875. char *pointer;
  876. int cnt = 0;
  877. int fault = 0;
  878. struct file *p;
  879. struct seq *mp;    /* 96 byte header */
  880.  
  881.     mp = &amazinge;
  882.     p = &avr;
  883.     errno = 0;    /* reset file error flag */
  884.     
  885.     if (fp = fopen(wholename, "wb"))    /* open seq file write only */
  886.     {
  887.         pointer = &amazinge.ident[0];
  888.         if (mode == 0)
  889.             strcpy(pointer, "PHAZESHIFT_SEQUENCE");
  890.         else
  891.             strcpy(pointer, "PHAZESHIFT_MIX_ONLY");
  892.             
  893.         amazinge.slength = get_end()+10;
  894.         amazinge.samples = count;
  895.         
  896.         if (mode == 0)
  897.         {
  898.             while (cnt <= count)
  899.             {    
  900.                 memcpy (p, sam_start[cnt], 30);
  901.                 amazinge.size[cnt++] = ((avr.length+128)/2)*2;
  902.             }
  903.             while (cnt <= 17)
  904.                 amazinge.size[cnt++] = 0;
  905.             
  906.             if (fwrite(mp, 1, 96, fp) != 96)
  907.                 fault = 1;
  908.             if (!fault)
  909.             {
  910.                 cnt = 0;
  911.                 while (cnt <= count)
  912.                 {
  913.                     pointer = sam_start[cnt];
  914.                     if (fwrite(pointer, 1, amazinge.size[cnt], fp) != amazinge.size[cnt])
  915.                         fault = 1;
  916.                     cnt++;
  917.                 }
  918.             }
  919.         }
  920.         else
  921.         {
  922.             if (fwrite(mp, 1, 24, fp) != 24)
  923.                 fault = 1;
  924.         }
  925.         if (fwrite(sequence, 2, amazinge.slength, fp) != amazinge.slength)
  926.             fault = 1;
  927.         
  928.         if (fclose(fp) != 0)
  929.             fault = 1;
  930.     }
  931.     else
  932.         fault = 1;
  933.     if (fault == 1)
  934.     {
  935.         if (errno == ENOSPC)
  936.         {
  937.             form_alert(1,"[3][ DISK FULL | FILE NOT SAVED ][ CANCEL ]");
  938.             if (remove(wholename) != 0)
  939.             {
  940.                 form_alert(1,"[3][ CAN'T DELETE FILE ! ][ CANCEL ]");
  941.             }
  942.         }
  943.         else
  944.             form_alert(1,"[3][ DISK WRITE PROTECTED !][ CANCEL ]");
  945.     }
  946. }
  947. /************** LOAD SEQUENCE OR ALL DEPENDING ON MODE ******************/
  948. void Sequence_load(char wholename[80], short mode)
  949. {
  950. FILE*fp;
  951. char *pointer, *memory;
  952. int cnt = 0;
  953. int sam_len;
  954. struct seq *mp;    /* 96 byte header */
  955.  
  956.     mp = &amazinge;
  957.     errno = 0;    /* reset file error flag */
  958.     
  959.     if (fp = fopen(wholename, "rb"))    /* open seq file read only */
  960.     {
  961.         pointer = &amazinge.ident[0];
  962.         if (mode == 0)
  963.         {
  964.             fread(mp, 1, 96, fp);    /* read it in */
  965.             
  966.             if (!(strncmp("PHAZESHIFT_SEQUENCE",pointer,19)))
  967.             {
  968.                 /* valid file format */
  969.                 for (cnt=0; cnt <= count; cnt++)
  970.                     free(sam_start[cnt]);
  971.                 count = amazinge.samples;
  972.                 cnt = 0;
  973.                 while (cnt <= count)
  974.                 {    
  975.                     sam_len = amazinge.size[cnt];
  976.                     if ((memory = malloc(sam_len)) == NULL) /* sample bank memory */
  977.                     {
  978.                         form_alert(1,"[3][ RAN OUT OF MEMORY ERROR !!!][ CANCEL ]");
  979.                         count = cnt-1;
  980.                         fclose(fp);
  981.                     }
  982.                     else
  983.                     {
  984.                     fread(memory, 1, (amazinge.size[cnt]), fp); /* read it in */
  985.                     sam_start[cnt++] = memory;
  986.                     }
  987.                 }
  988.                 fread(sequence, 2, (amazinge.slength), fp);
  989.             }
  990.             else
  991.             {
  992.                 form_alert(1,"[1][ NOT A VALID | MIX & SAMPLE FILE | ERROR !!! ][ CANCEL ]");
  993.             }
  994.         }
  995.         else
  996.         {
  997.             fread(mp, 1, 24, fp);
  998.             if (!(strncmp("PHAZESHIFT_MIX_ONLY",pointer,19)))
  999.             {
  1000.                 if (count >= amazinge.samples)
  1001.                     fread(sequence, 2, (amazinge.slength), fp);
  1002.                 else
  1003.                 {
  1004.                     form_alert(1,"[1][ NOT ENOUGH SAMPLES | IN MEMORY !!!][ CANCEL ]");
  1005.                 }
  1006.             }
  1007.             else
  1008.             {
  1009.                 form_alert(1,"[1][ NOT A VALID | MIX ONLY FILE | ERROR !!! ][ CANCEL ]");
  1010.             }
  1011.         }
  1012.         fclose(fp);
  1013.     }
  1014.     else
  1015.     {
  1016.         form_alert(1,"[1][ FILE DOES NOT EXIST ! ][ CANCEL ]");
  1017.     }
  1018. }
  1019. /******************** LIST SAMPLES THAT ARE LOADED **********************/
  1020. void Sample_list(int lineno2)
  1021. {
  1022. int cnt;
  1023. int line = 0;
  1024. struct file *p;
  1025.  
  1026.     p = &avr;
  1027.     cnt = lineno2;
  1028.  
  1029.     while (cnt <= count && line < 7)
  1030.     {    
  1031.         memcpy (p, sam_start[cnt], 30);
  1032.         vs_curaddress(vdi, 10+line, 15);
  1033.         printf("%8.8s.", &avr.name[0]);
  1034.         printf(" - %2d: %c", cnt, key[cnt]);
  1035.         if (avr.stereo == 0)
  1036.             printf(" MONO  ");
  1037.         else
  1038.             printf(" STEreo");
  1039.         if (avr.loop == 0)
  1040.             printf(" ONCE");
  1041.         else
  1042.             printf(" LOOP");
  1043.         avr.speed &= 0xffffff; 
  1044.         printf(" %d Hz  ", avr.speed);
  1045.         cnt++;
  1046.         line++;
  1047.     }
  1048.     if (line != 7)
  1049.     {
  1050.         while (line < 7)
  1051.         {
  1052.             vs_curaddress(vdi, 10+line, 15);
  1053.             printf("                                         ");
  1054.             line++;
  1055.         }
  1056.     }
  1057. }
  1058. /******************** LOAD A SAMPLE TO MEMORY BANK **********************/
  1059. char *Sample_load(char wholename[80])
  1060. {
  1061. FILE*fp;
  1062. char A;
  1063. char *pointer, *memory;
  1064. int sam_len;
  1065. struct file *p;
  1066.  
  1067.     memory = &A;
  1068.     *memory = 10;
  1069.     p = &avr;
  1070.     errno = 0;    /* reset file error flag */
  1071.  
  1072.     if (fp = fopen(wholename, "rb"))    /* open sound file */
  1073.     {
  1074.         fread(p, 1, 30, fp);    /* read it in */
  1075.         fclose(fp);                        /* close it */
  1076.     }
  1077.     else
  1078.     {
  1079.         form_alert(1,"[1][ FILE DOES NOT EXIST ! ][ CANCEL ]");
  1080.         *memory = NULL;
  1081.         return (memory);
  1082.     }
  1083. /* header loaded now test it as a 2-bit sytems file */
  1084.     
  1085.     pointer = avr.ident;
  1086.     if (strncmp("2BIT",pointer,4) != 0)
  1087.     {    
  1088.         form_alert(1,"[1][ NOT AN AVR SAMPLE FILE ! ][ CANCEL ]");
  1089.         *memory = NULL;
  1090.         return(memory);
  1091.     }
  1092.     sam_len = avr.length;    
  1093.     if ((memory = malloc(sam_len+128)) == NULL)    /* sample bank memory */
  1094.     {
  1095.         form_alert(1,"[3][ RAN OUT OF MEMORY ERROR !!!][ CANCEL ]");
  1096.  
  1097.         memory = &A;
  1098.         *memory = NULL;
  1099.         return(memory);    /* NOT enough memory SORRY */
  1100.     }
  1101.     fp = fopen(wholename, "rb");    /* open sound file */
  1102.     if (fread(memory, 1, (sam_len+128), fp) != sam_len+128)    /* read it in */
  1103.     {
  1104.         form_alert(1,"[1][ FILE TOO SMALL | ACCORDING TO HEADER ! ][ CANCEL ]");
  1105.         free(memory);
  1106.         memory = &A;
  1107.         *memory = NULL;
  1108.     }
  1109.     fclose(fp);                        /* close it */
  1110.     if (avr.sign == 0x0000 && *memory != NULL)
  1111.     {
  1112.         SIGN_IT(memory);
  1113.         avr.sign = 0xffff;
  1114.     }
  1115.     
  1116.     return(memory);
  1117. }
  1118. /********************** SIMPLE DELAY ROUTINE ****************************/
  1119. void waiting(int time)
  1120. {
  1121. int wt;
  1122.     time *= 500;
  1123.     for (wt=0; wt < time; wt++)
  1124.         wt = wt;
  1125. }
  1126. /******************* SET UP AND CALL MC RECORD ROUTINE ******************/
  1127. void recording(void) 
  1128. {
  1129. unsigned short int *contents;
  1130. int an_error;
  1131. int difference;
  1132.     contents = sequence;
  1133.  
  1134.     if (an_error = RECORD(&sam_start[0],count,sequence,space,1))
  1135.     {
  1136.         if (an_error == 2)
  1137.             form_alert(1,"[3][ OUT OF MEMORY | IN SEQUENCE FILE ! | ADVISE SAVING SEQUENCE | AND RESTART ! ][ OK ]");
  1138.         else
  1139.             form_alert(1,"[3][ OUT OF TIME | 65535 UNITS ONLY !!! ][ SORRY ]");
  1140.     }
  1141.     STOP();
  1142.     difference = *contents - 1;
  1143.     while (*contents != 0xffff)
  1144.     {
  1145.         *contents -= difference;
  1146.         contents += 2;
  1147.     }
  1148. }
  1149. /******************* SET UP AND CALL MC PLAY ROUTINE ********************/
  1150. int playing(int lineno)
  1151. {
  1152. int finish = 1;
  1153.  
  1154.     if (*(sequence+3) == 0xffff)
  1155.         return (lineno);
  1156.     PLAY(&sam_start[0],sequence+lineno,space,&finish);
  1157.     vs_curaddress(vdi, 10, 32);
  1158.     printf("ANY KEY TO STOP !");
  1159.     while (Crawio(0x00ff) != 0);
  1160.     while (finish != 0 && Crawio(0x00ff) == 0)
  1161.     {}
  1162.     Vbl_Remove();
  1163.     if (finish != 0)
  1164.     {
  1165.         STOP();
  1166.         return (((finish-2)*2)+lineno);
  1167.     }
  1168.     return (0);
  1169. }
  1170. /******************* SET UP AND CALL MC EDIT ROUTINE ********************/
  1171. void editing(int lineno)
  1172. {
  1173. char ok;
  1174. int an_error;
  1175.  
  1176.     if (*(sequence+3) != 0xffff)
  1177.     {
  1178.         if (an_error = EDIT(&sam_start[0],count,sequence+lineno,32000,buffer))
  1179.         {
  1180.             if (an_error == 2)
  1181.                 form_alert(1,"[3][ OUT OF MEMORY | IN MIX MERGE BUFFER !!! | 8000 KEY PRESSES MAX ! ][ MUPPET ]");
  1182.             else
  1183.                 form_alert(1,"[3][ OUT OF TIME | 65535 UNITS ONLY !!! ][ SORRY ]");
  1184.         }
  1185.         STOP();
  1186.         ok = form_alert(1,"[2][ DO YOU WANT TO KEEP | CHANGES ? ][ YES | NO ]");
  1187.         if (ok == 1)
  1188.         {
  1189.             if (MERGE_BUFFER(sequence,space,buffer))
  1190.             {
  1191.                 form_alert(1,"[3][ OUT OF MEMORY IN SEQ FILE | NOT ALL MIXING MERGED ! | ADVISE SAVING SEQUENCE | AND RESTARTING !! ][ OK ]");
  1192.             }
  1193.             vs_curaddress(vdi, 11, 15);
  1194.             printf("..DONE                                ");
  1195.         }
  1196.     }
  1197. }
  1198. /******************************** EOF ***********************************/