home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / dos / prg / dsik205 / dsik.dat / EXAMPLES / SETUP.C < prev    next >
C/C++ Source or Header  |  1995-04-10  |  18KB  |  602 lines

  1. /****************************************************************************
  2. *
  3. *                   Digital Sound Interface Kit (DSIK)
  4. *                            Version 2.00
  5. *
  6. *                           by Carlos Hasan
  7. *
  8. * Filename:     setup.c
  9. * Version:      Revision 1.0
  10. *
  11. * Language:     WATCOM C
  12. * Environment:  IBM PC (DOS/4GW)
  13. *
  14. * Description:  Standalone Soundcard setup program.
  15. *
  16. * Revision History:
  17. * ----------------
  18. *
  19. * Revision 1.0  94/12/01  20:35:50  chv
  20. * Initial revision
  21. *
  22. ****************************************************************************/
  23.  
  24. #include <io.h>
  25. #include <fcntl.h>
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29. #include <conio.h>
  30. #include <i86.h>
  31. #include "audio.h"
  32.  
  33. /*------------------- Soundcard Configurations ----------------------------*/
  34.  
  35. #define NUMDRIVERS  (sizeof(DriversTable)/sizeof(DRIVER))
  36.  
  37. typedef struct {
  38.     char    *FileName;
  39.     char    *DriverName;
  40.     char    *HelpText;
  41.     int     DevId;
  42.     int     Modes;
  43.     int     Port;
  44.     int     IrqLine;
  45.     int     DmaChannel;
  46.     int     SampleRate;
  47.     int     PortTable[8],IrqTable[16],DmaTable[8];
  48. } DRIVER;
  49.  
  50. DRIVER DriversTable[] = {
  51.       { "NONE.DRV", "No sound",
  52.         "Do not use any sound",
  53.         ID_NONE, AF_8BITS | AF_MONO, 0x000, 0, 0, 0,
  54.         { 0, 0xFFFF },
  55.         { 0, 0xFFFF },
  56.         { 0, 0xFFFF } },
  57.  
  58.       { "SB.DRV", "Sound Blaster",
  59.         "Plain Sound Blaster or compatible",
  60.         ID_SB, AF_8BITS | AF_MONO, 0x220, 7, 1, 22050,
  61.         { 0x210, 0x220, 0x230, 0x240, 0x250, 0x260, 0xFFFF },
  62.         { 2, 3, 5, 7, 0xFFFF },
  63.         { 1, 0xFFFF } },
  64.  
  65.       { "SB.DRV", "Sound Blaster 2.01",
  66.         "Sound Blaster 2.01 or compatible",
  67.         ID_SB201, AF_8BITS | AF_MONO, 0x220, 7, 1, 44100,
  68.         { 0x210, 0x220, 0x230, 0x240, 0x250, 0x260, 0xFFFF },
  69.         { 2, 3, 5, 7, 0xFFFF },
  70.         { 1, 0xFFFF } },
  71.  
  72.       { "SB.DRV", "Sound Blaster Pro",
  73.         "Sound Blaster Pro, Sound Galaxy Pro or compatible",
  74.         ID_SBPRO, AF_8BITS | AF_STEREO, 0x220, 5, 1, 22050,
  75.         { 0x210, 0x220, 0x230, 0x240, 0x250, 0x260, 0xFFFF },
  76.         { 2, 3, 5, 7, 0xFFFF },
  77.         { 0, 1, 3, 0xFFFF } },
  78.  
  79.       { "SB.DRV", "Sound Blaster 16/16ASP",
  80.         "Sound Blaster 16/16ASP, Wave Blaster or Sound Blaster AWE32",
  81.         ID_SB16, AF_16BITS | AF_STEREO, 0x220, 5, 5, 44100,
  82.         { 0x220, 0x240, 0x260, 0x280, 0xFFFF },
  83.         { 2, 5, 7, 10, 0xFFFF },
  84.         { 0, 1, 3, 5, 6, 7, 0xFFFF } },
  85.  
  86.       { "PAS.DRV", "Pro Audio Spectrum",
  87.         "Media Vision Pro Audio Spectrum or compatible",
  88.         ID_PAS, AF_8BITS | AF_STEREO, 0x388, 7, 1, 44100,
  89.         { 0x388, 0x384, 0x38C, 0x288, 0xFFFF },
  90.         { 2, 3, 5, 7, 10, 11, 12, 13, 15, 0xFFFF },
  91.         { 0, 1, 3, 5, 6, 7, 0xFFFF } },
  92.  
  93.       { "PAS.DRV", "Pro Audio Spectrum+",
  94.         "Media Vision Pro Audio Spectrum Plus or compatible",
  95.         ID_PASPLUS, AF_8BITS | AF_STEREO, 0x388, 7, 1, 44100,
  96.         { 0x388, 0x384, 0x38C, 0x288, 0xFFFF },
  97.         { 2, 3, 5, 7, 10, 11, 12, 13, 15, 0xFFFF },
  98.         { 0, 1, 3, 5, 6, 7, 0xFFFF } },
  99.  
  100.       { "PAS.DRV", "Pro Audio Spectrum 16",
  101.         "Pro Audio Spectrum 16, Logitech SoundMan 16 or compatible",
  102.         ID_PAS16, AF_16BITS | AF_STEREO, 0x388, 7, 1, 44100,
  103.         { 0x388, 0x384, 0x38C, 0x288, 0xFFFF },
  104.         { 2, 3, 5, 7, 10, 11, 12, 13, 15, 0xFFFF },
  105.         { 0, 1, 3, 5, 6, 7, 0xFFFF } },
  106.  
  107.       { "WSS.DRV", "Windows Sound System",
  108.         "Windows Sound System, Audiotrix Pro or compatible",
  109.         ID_WSS, AF_16BITS | AF_STEREO, 0x530, 7, 1, 44100,
  110.         { 0x530, 0x604, 0xE80, 0xF40, 0xFFFF },
  111.         { 7, 9, 10, 11, 0xFFFF },
  112.         { 0, 1, 3, 0xFFFF } },
  113.  
  114.       { "GUS.DRV", "Gravis UltraSound",
  115.         "Advanced Gravis UltraSound, UltraSound Max or compatible",
  116.         ID_GUS, AF_16BITS | AF_STEREO, 0x220, 11, 1, 0,
  117.         { 0x210, 0x220, 0x230, 0x240, 0x250, 0x260, 0xFFFF },
  118.         { 2, 3, 5, 7, 11, 12, 15, 0xFFFF },
  119.         { 1, 3, 5, 6, 7, 0xFFFF } }
  120. };
  121.  
  122. /*-------------------- Screen Menu Configurations -------------------------*/
  123.  
  124. #define MENU_SELECTCARD     0
  125. #define MENU_SAVEEXIT       1
  126.  
  127. #define TITLELEN            32
  128. #define MAXITEMS            16
  129. #define ITEMLEN             32
  130. #define HELPLEN             80
  131.  
  132. typedef struct {
  133.     int     Line;
  134.     char    Title[TITLELEN];
  135.     char    ItemsText[MAXITEMS][ITEMLEN];
  136.     char    HelpText[MAXITEMS][HELPLEN];
  137. } MENU;
  138.  
  139. MENU MainMenu = {
  140.     0, "Main Menu",
  141.     { "Select playback device", "Save and Exit" },
  142.     { "Select Music and SFX playback device",
  143.       "Save SETUP file and exit to DOS" } };
  144.  
  145. MENU QuaMenu = {
  146.     2, "Select Sound Quality",
  147.     { "Low Quality", "Medium Quality", "Normal Quality",
  148.       "High Quality", "Very High Quality" },
  149.     { "Select Low Quality (386/20)",
  150.       "Select Medium Quality (386/33)",
  151.       "Select Normal Quality (486/33)",
  152.       "Select High Quality (486/66)",
  153.       "Select Very High Quality (Pentium)" } };
  154.  
  155. /* This table of strings should be customized by the user */
  156. char *TextTable[] = {
  157.     "SETUP.CFG",
  158.     "Digital Sound Interface Kit (DSIK) Setup Version 2.00",
  159.     "Copyright (C) 1993-95 Carlos Hasan",
  160.     "Accept",
  161.     "Exit",
  162.     "Select Playback Device",
  163.     "Select Base I/O Port",
  164.     "Select Base I/O Port %03X hex",
  165.     "Select IRQ Interrupt Line",
  166.     "Select IRQ Interrupt Line %d",
  167.     "Select DMA Channel",
  168.     "Select DMA Channel %d",
  169.     "Setup file saved. Please run PLAY.EXE to play modules.",
  170.     "Error saving Setup file!",
  171.     "Setup aborted."
  172. };
  173.  
  174. /* This table of sampling rates should be modified too */
  175. int RatesTable[] = {
  176.     16000, 19025, 22050, 33075, 44100 };
  177.  
  178. /*------------------------- Keyboard Routines -----------------------------*/
  179.  
  180. #define KB_ESC      0x001B
  181. #define KB_ENTER    0x000D
  182. #define KB_UP       0x4800
  183. #define KB_DOWN     0x5000
  184.  
  185. int ReadKey(void)
  186. {
  187.     int c;
  188.     if (!(c = getch())) c = getch()<<8;
  189.     return c;
  190. }
  191.  
  192. /*---------------------- Setup I/O File Routines --------------------------*/
  193.  
  194. /* NOTE: I do not want to link all the sound system here, so I must
  195.          rewrite the setup file routines again. There is no problem
  196.          with the detection routine.
  197.  */
  198.  
  199. /****************************************************************************
  200. *
  201. * Function:     dLoadSetup
  202. * Parameters:   SC          - soundcard structure
  203. *               Filename    - full config path filename
  204. *
  205. * Returns:      Zero value on success.
  206. *
  207. * Description:  Load the soundcard configuration parameters.
  208. *
  209. ****************************************************************************/
  210.  
  211. int dLoadSetup(SoundCard *SC, char *Filename)
  212. {
  213.     int Handle;
  214.     if ((Handle = open(Filename,O_RDONLY|O_BINARY)) < 0)
  215.         return 1;
  216.     if (read(Handle,SC,sizeof(SoundCard)) != sizeof(SoundCard)) {
  217.         close(Handle);
  218.         return 1;
  219.     }
  220.     close(Handle);
  221.     return 0;
  222. }
  223.  
  224. /****************************************************************************
  225. *
  226. * Function:     dSaveSetup
  227. * Parameters:   SC          - soundcard structure
  228. *               Filename    - full config path filename
  229. *
  230. * Returns:      Zero value on success.
  231. *
  232. * Description:  Save the soundcard configuration parameters.
  233. *
  234. ****************************************************************************/
  235.  
  236. int dSaveSetup(SoundCard *SC, char *Filename)
  237. {
  238.     int Handle;
  239.     if ((Handle = open(Filename,O_CREAT|O_WRONLY|O_BINARY,S_IRWXU)) < 0)
  240.         return 1;
  241.     if (write(Handle,SC,sizeof(SoundCard)) != sizeof(SoundCard)) {
  242.         close(Handle);
  243.         return 1;
  244.     }
  245.     close(Handle);
  246.     return 0;
  247. }
  248.  
  249. /*-------------------- Text Screen Mode Routines --------------------------*/
  250.  
  251. void SetTextMode(void)
  252. {
  253.     union REGS r;
  254.     r.h.ah = 0x00;
  255.     r.h.al = 0x03;
  256.     int386(0x10,&r,&r);
  257. }
  258.  
  259. void SetPalette(int index, int red, int green, int blue)
  260. {
  261.     outp(0x3c8,index);
  262.     outp(0x3c9,red);
  263.     outp(0x3c9,green);
  264.     outp(0x3c9,blue);
  265. }
  266.  
  267. void WaitVertRetrace(void)
  268. {
  269.     while (inp(0x3da) & 0x08) ;
  270.     while (!(inp(0x3da) & 0x08)) ;
  271. }
  272.  
  273. void HideCursor(void)
  274. {
  275.     outpw(0x3d4,0x100a);
  276.     outpw(0x3d4,0x100b);
  277. }
  278.  
  279. void DrawRect(int x, int y, int width, int height, int c, int color)
  280. {
  281.     char *ptr = (char*)(0xb8000+((x+80*y)<<1));
  282.     int i,j;
  283.     for (j = 0; j < height; j++) {
  284.         for (i = 0; i < width; i++) {
  285.             *ptr++ = c;
  286.             *ptr++ = color;
  287.         }
  288.         ptr += (80-width)<<1;
  289.     }
  290. }
  291.  
  292. void DrawFrame(int x, int y, int width, int height, int color)
  293. {
  294.     static char frame[] = { 0xda,0xbf,0xc0,0xd9,0xc4,0xb3,0xc3,0xb4,0x20 };
  295.     char *ptr = (char*)(0xb8000+((x+80*y)<<1));
  296.     int i,j;
  297.  
  298.     *ptr++ = frame[0];
  299.     *ptr++ = color;
  300.     for (i = 0; i < width; i++) {
  301.         *ptr++ = frame[4];
  302.         *ptr++ = color;
  303.     }
  304.     *ptr++ = frame[1];
  305.     *ptr++ = color;
  306.     ptr += (78-width)<<1;
  307.  
  308.     *ptr++ = frame[5];
  309.     *ptr++ = color;
  310.     for (i = 0; i < width; i++) {
  311.         *ptr++ = frame[8];
  312.         *ptr++ = color;
  313.     }
  314.     *ptr++ = frame[5];
  315.     *ptr++ = color;
  316.     ptr += (78-width)<<1;
  317.  
  318.     *ptr++ = frame[6];
  319.     *ptr++ = color;
  320.     for (i = 0; i < width; i++) {
  321.         *ptr++ = frame[4];
  322.         *ptr++ = color;
  323.     }
  324.     *ptr++ = frame[7];
  325.     *ptr++ = color;
  326.     ptr += (78-width)<<1;
  327.  
  328.     for (j = 0; j < height; j++) {
  329.         *ptr++ = frame[5];
  330.         *ptr++ = color;
  331.         for (i = 0; i < width; i++) {
  332.             *ptr++ = frame[8];
  333.             *ptr++ = color;
  334.         }
  335.         *ptr++ = frame[5];
  336.         *ptr++ = color;
  337.         ptr += (78-width)<<1;
  338.     }
  339.  
  340.     *ptr++ = frame[6];
  341.     *ptr++ = color;
  342.     for (i = 0; i < width; i++) {
  343.         *ptr++ = frame[4];
  344.         *ptr++ = color;
  345.     }
  346.     *ptr++ = frame[7];
  347.     *ptr++ = color;
  348.     ptr += (78-width)<<1;
  349.  
  350.     *ptr++ = frame[5];
  351.     *ptr++ = color;
  352.     for (i = 0; i < width; i++) {
  353.         *ptr++ = frame[8];
  354.         *ptr++ = color;
  355.     }
  356.     *ptr++ = frame[5];
  357.     *ptr++ = color;
  358.     ptr += (78-width)<<1;
  359.  
  360.     *ptr++ = frame[2];
  361.     *ptr++ = color;
  362.     for (i = 0; i < width; i++) {
  363.         *ptr++ = frame[4];
  364.         *ptr++ = color;
  365.     }
  366.     *ptr++ = frame[3];
  367.     *ptr++ = color;
  368.     ptr += (78-width)<<1;
  369. }
  370.  
  371. void DrawText(int x, int y, char *text, int color)
  372. {
  373.     char *ptr = (char*)(0xb8000+((x+80*y)<<1));
  374.     while (*text) {
  375.         *ptr++ = *text++;
  376.         *ptr++ = color;
  377.     }
  378. }
  379.  
  380. void DrawCenterText(int y, char *text, int color)
  381. {
  382.     DrawText((80-strlen(text))>>1,y,text,color);
  383. }
  384.  
  385. /*--------------------------- Menu Routines -------------------------------*/
  386.  
  387. void DrawMenu(MENU *menu)
  388. {
  389.     int x,y,width,height;
  390.     int i,j;
  391.     width = strlen(menu->Title);
  392.     if ((j = 10+strlen(TextTable[3])+strlen(TextTable[4])) > width)
  393.         width = j;
  394.     for (i = height = 0; i < MAXITEMS; i++, height++) {
  395.         if (!(j = strlen(menu->ItemsText[i]))) break;
  396.         if (j > width) width = j;
  397.     }
  398.     width += 4;
  399.     x = (78-width)>>1;
  400.     y = 2+((14-height)>>1);
  401.     DrawRect(x+1,y+1,width+3,height+6,0xb0,0x37);
  402.     DrawFrame(x,y,width,height,0x1b);
  403.     DrawRect(x+1,y+1,width,1,0x20,0x71);
  404.     DrawText(x+1+((width-strlen(menu->Title))>>1),y+1,menu->Title,0x71);
  405.     DrawText(x+2,y+4+height,"ENTER",0x1a);
  406.     DrawText(x+7,y+4+height,"=",0x1b);
  407.     DrawText(x+8,y+4+height,TextTable[3],0x1f);
  408.     DrawText(x-4+width-strlen(TextTable[4]),y+4+height,"ESC",0x1a);
  409.     DrawText(x-1+width-strlen(TextTable[4]),y+4+height,"=",0x1b);
  410.     DrawText(x+width-strlen(TextTable[4]),y+4+height,TextTable[4],0x1f);
  411.     for (i = 0; i < height; i++) {
  412.         if (menu->Line == i) DrawRect(x+1,y+i+3,width,1,0x20,0x71);
  413.         DrawText(x+3,y+i+3,menu->ItemsText[i],(menu->Line == i)?0x71:0x1f);
  414.     }
  415.     DrawRect(0,24,80,1,0x20,0x3b);
  416.     DrawText(1,24,menu->HelpText[menu->Line],0x3b);
  417. }
  418.  
  419. int ExecMenu(MENU *menu)
  420. {
  421.     int n,key;
  422.     for (n = 0; n < MAXITEMS; n++)
  423.         if (!strlen(menu->ItemsText[n])) break;
  424.     if (n <= 1) return 0;
  425.     for (;;) {
  426.         WaitVertRetrace();
  427.         DrawRect(0,2,80,22,0xb1,0x37);
  428.         DrawMenu(menu);
  429.         if ((key = ReadKey()) == KB_ESC) break;
  430.         switch (key) {
  431.             case KB_ENTER:
  432.                 return menu->Line;
  433.                 break;
  434.             case KB_UP:
  435.                 (menu->Line)--;
  436.                 if (menu->Line < 0) (menu->Line)++;
  437.                 break;
  438.             case KB_DOWN:
  439.                 (menu->Line)++;
  440.                 if (menu->Line >= n) (menu->Line)--;
  441.                 break;
  442.         }
  443.     }
  444.     return -1;
  445. }
  446.  
  447. /*------------------- Select Soundcard Menu Routines ----------------------*/
  448.  
  449. #define MAXDRIVERS ((MAXITEMS>NUMDRIVERS)?NUMDRIVERS:MAXITEMS)
  450.  
  451. MENU *MakeDeviceMenu(MENU *menu, SoundCard *SC)
  452. {
  453.     DRIVER *drv;
  454.     int i;
  455.     memset(menu,0,sizeof(MENU));
  456.     strncpy(menu->Title,TextTable[5],TITLELEN);
  457.     for (drv = DriversTable, i = 0; i < MAXDRIVERS; drv++, i++) {
  458.         strncpy(menu->ItemsText[i],drv->DriverName,ITEMLEN);
  459.         strncpy(menu->HelpText[i],drv->HelpText,HELPLEN);
  460.         if (SC->ID == drv->DevId) menu->Line = i;
  461.     }
  462.     return menu;
  463. }
  464.  
  465. MENU *MakePortMenu(MENU *menu, SoundCard *SC)
  466. {
  467.     DRIVER *drv;
  468.     int i,j;
  469.     memset(menu,0,sizeof(MENU));
  470.     strncpy(menu->Title,TextTable[6],TITLELEN);
  471.     for (drv = DriversTable, i = 0; i < MAXDRIVERS; drv++, i++)
  472.         if (SC->ID == drv->DevId) break;
  473.     for (i = 0; (i < MAXITEMS) && ((j = drv->PortTable[i]) != 0xFFFF); i++) {
  474.         _bprintf(menu->ItemsText[i],ITEMLEN,"%03X",j);
  475.         _bprintf(menu->HelpText[i],HELPLEN,TextTable[7],j);
  476.         if (SC->Port == j) menu->Line = i;
  477.     }
  478.     return menu;
  479. }
  480.  
  481. MENU *MakeIrqMenu(MENU *menu, SoundCard *SC)
  482. {
  483.     DRIVER *drv;
  484.     int i,j;
  485.     memset(menu,0,sizeof(MENU));
  486.     strncpy(menu->Title,TextTable[8],TITLELEN);
  487.     for (drv = DriversTable, i = 0; i < MAXDRIVERS; drv++, i++)
  488.         if (SC->ID == drv->DevId) break;
  489.     for (i = 0; (i < MAXITEMS) && ((j = drv->IrqTable[i]) != 0xFFFF); i++) {
  490.         _bprintf(menu->ItemsText[i],ITEMLEN,"IRQ %d",j);
  491.         _bprintf(menu->HelpText[i],HELPLEN,TextTable[9],j);
  492.         if (SC->IrqLine == j) menu->Line = i;
  493.     }
  494.     return menu;
  495. }
  496.  
  497. MENU *MakeDmaMenu(MENU *menu, SoundCard *SC)
  498. {
  499.     DRIVER *drv;
  500.     int i,j;
  501.     memset(menu,0,sizeof(MENU));
  502.     strncpy(menu->Title,TextTable[10],TITLELEN);
  503.     for (drv = DriversTable, i = 0; i < MAXDRIVERS; drv++, i++)
  504.         if (SC->ID == drv->DevId) break;
  505.     for (i = 0; (i < MAXITEMS) && ((j = drv->DmaTable[i]) != 0xFFFF); i++) {
  506.         _bprintf(menu->ItemsText[i],ITEMLEN,"DMA %d",j);
  507.         _bprintf(menu->HelpText[i],HELPLEN,TextTable[11],j);
  508.         if (SC->DmaChannel == j) menu->Line = i;
  509.     }
  510.     return menu;
  511. }
  512.  
  513. int SelectSoundCard(SoundCard *SC)
  514. {
  515.     MENU menu;
  516.     DRIVER *drv;
  517.  
  518.     if (ExecMenu(MakeDeviceMenu(&menu,SC)) < 0) return 1;
  519.     drv = &DriversTable[menu.Line];
  520.     if (SC->ID != drv->DevId) {
  521.         SC->Port = drv->Port;
  522.         SC->IrqLine = drv->IrqLine;
  523.         SC->DmaChannel = drv->DmaChannel;
  524.     }
  525.     SC->ID = drv->DevId;
  526.     SC->Modes = drv->Modes;
  527.     if (ExecMenu(MakePortMenu(&menu,SC)) < 0) return 1;
  528.     SC->Port = drv->Port = drv->PortTable[menu.Line];
  529.     if (ExecMenu(MakeIrqMenu(&menu,SC)) < 0) return 1;
  530.     SC->IrqLine = drv->IrqLine = drv->IrqTable[menu.Line];
  531.     if (ExecMenu(MakeDmaMenu(&menu,SC)) < 0) return 1;
  532.     SC->DmaChannel = drv->DmaChannel = drv->DmaTable[menu.Line];
  533.     if (drv->SampleRate) {
  534.         if (ExecMenu(&QuaMenu) < 0) return 1;
  535.         if ((SC->SampleRate = RatesTable[QuaMenu.Line]) > drv->SampleRate)
  536.             SC->SampleRate = drv->SampleRate;
  537.     }
  538.     else {
  539.         SC->SampleRate = 44100;
  540.     }
  541.     return 0;
  542. }
  543.  
  544. /*-------------------- Save and Exit Menu Routines ------------------------*/
  545.  
  546. int SaveAndExit(SoundCard *SC, char *Filename)
  547. {
  548.     int I;
  549.     for (I = 0; I < NUMDRIVERS; I++)
  550.         if (SC->ID == DriversTable[I].DevId)
  551.             strncpy(SC->DriverName,DriversTable[I].FileName,
  552.                     sizeof(SC->DriverName));
  553.     return dSaveSetup(SC,Filename);
  554. }
  555.  
  556. /*----------------------- Setup Main Program ------------------------------*/
  557.  
  558. void SetupProgram(SoundCard *SC)
  559. {
  560.     SetTextMode();
  561.     HideCursor();
  562.     SetPalette(1,1,4,16);
  563.     SetPalette(3,4,6,26);
  564.     DrawRect(0,2,80,22,0xb1,0x37);
  565.     DrawRect(0,0,80,4,0x20,0x3b);
  566.     DrawCenterText(0,TextTable[1],0x3b);
  567.     DrawCenterText(1,TextTable[2],0x3b);
  568.     if (dLoadSetup(SC,TextTable[0])) {
  569.         memset(SC,0,sizeof(SoundCard));
  570.         dAutoDetect(SC);
  571.     }
  572.     for (;;) {
  573.         if (ExecMenu(&MainMenu) < 0) {
  574.             MainMenu.Line = MENU_SELECTCARD;
  575.             break;
  576.         }
  577.         if (MainMenu.Line == MENU_SELECTCARD) {
  578.             if (SelectSoundCard(SC)) break;
  579.         }
  580.         else if (MainMenu.Line == MENU_SAVEEXIT) {
  581.             break;
  582.         }
  583.         MainMenu.Line = MENU_SAVEEXIT;
  584.     }
  585.     SetTextMode();
  586.     if (MainMenu.Line == MENU_SAVEEXIT) {
  587.         printf("%s\n", SaveAndExit(SC,TextTable[0]) ?
  588.             TextTable[13] : TextTable[12]);
  589.     }
  590.     else {
  591.         printf("%s\n",TextTable[14]);
  592.     }
  593. }
  594.  
  595.  
  596. int main(int argc, char *argv[])
  597. {
  598.     SoundCard SC;
  599.     SetupProgram(&SC);
  600.     return EXIT_SUCCESS;
  601. }
  602.