home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Sound / Player / MCDPL121.LHA / MCDPlayer / Source / mcdplayer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-21  |  24.0 KB  |  694 lines

  1. #include "mcdplayer.h"
  2. #include "scsistuff.h"
  3.  
  4. extern struct Window *ProgWnd;
  5. extern struct Window *ListWnd;
  6.  
  7. void SCMD_ReadTitleTime( int settimer )
  8.     {
  9.     static SCSICMD10 command =
  10.         {
  11.         SCSI_CMD_READSUBCHANNEL,
  12.         0,
  13.         0x40,
  14.         0,
  15.         PAD,
  16.         PAD,
  17.         0,
  18.         0,0,
  19.         PAD
  20.         };
  21.  
  22.     int err;
  23.     int microsleft = 950000;
  24.     int addr;
  25.     int slen;
  26.     char Buffer[20];
  27.  
  28.     if (SetNextTitle == 1)
  29.         {
  30.         if (Program[ActProgTitle][ActProg]) SCMD_PlayAudio( ActProgTitle+1 );
  31.         SetNextTitle = 0;
  32.         };
  33.  
  34.     command.b2 = 0x40;
  35.     command.b3 = 1;
  36.     command.b6 = 0;
  37.  
  38.     command.b7 = 255;
  39.     command.b8 = 255;
  40.  
  41.     if ((err = DoScsiCmd ((UBYTE *) scsi_data, MAX_DATA_LEN,
  42.                           (UBYTE *) &command, sizeof (command),
  43.                           (SCSIF_READ | SCSIF_AUTOSENSE))) != 0)
  44.         {
  45.         if (ActStat!=0)
  46.             {
  47.             ActStat=0;
  48.             CleanMainWnd();
  49.             if (ProgWnd){CloseProgWindow();ExitLists(2);}
  50.             if (ListWnd){CloseListWindow();ExitTitleList(2);}
  51.             };
  52.         }
  53.     else if ((scsi_data[1] == 0x11) || (scsi_data[1] == 0x12))
  54.         {
  55.         if (ActStat==0)
  56.             {
  57.             SCMD_ReadTOC();
  58.             };
  59.         if (scsi_data[1]==0x11)
  60.             {
  61.             if (ActStat!=1)
  62.                 {
  63.                 DrawPlaySymb( 1 );
  64.                 DrawPrgmSymb( (ActProg!=-1)?1:0 );
  65.                 SetDispStat();
  66.                 };
  67.             ActStat=1;
  68.             }
  69.         else
  70.             {
  71.             if (ActStat!=3)
  72.                 {
  73.                 DrawPlaySymb( 3 );
  74.                 DrawPrgmSymb( (ActProg!=-1)?1:0 );
  75.                 SetDispStat();
  76.                 };
  77.             ActStat=3;
  78.             };
  79.         SetAPen( MainWnd->RPort, 2 );
  80.         SetBPen( MainWnd->RPort, 1 );
  81.  
  82.         if (scsi_data[6]!=ActTitle)
  83.             {
  84.             ActTitle = scsi_data[6];
  85.             InputTitleStat = 0;
  86.             if (ActProg==-1) ActProgTitle = ActTitle;
  87.             sprintf(Buffer, "%02d", ActTitle);
  88.             Move( MainWnd->RPort, 25, 37+offy );
  89.             Text( MainWnd->RPort, Buffer, 2 );
  90.  
  91.             SetAPen( MainWnd->RPort, 1 );
  92.             RectFill( MainWnd->RPort, 25, 52+offy, 258, 64+offy );
  93.             SetAPen( MainWnd->RPort, 2 );
  94.             Move( MainWnd->RPort, 25, 61+offy );
  95.             slen = strlen(TOC_Title[ActTitle-1]);
  96.             Text( MainWnd->RPort, TOC_Title[ActTitle-1], (slen>29)? 29 : slen );
  97.             SetDispStat();
  98.             SetAPen( MainWnd->RPort, 2 );
  99.             };
  100.  
  101.       sprintf(Buffer, "%02d", scsi_data[7]);
  102.    Move( MainWnd->RPort, 52, 37+offy );
  103.    Text( MainWnd->RPort, Buffer, 2 );
  104.  
  105.       if (NewTimer)
  106.          addr = ((scsi_data[16] << 24) | (scsi_data[15] << 16) | (scsi_data[14] << 8) | (scsi_data[13]) );
  107.       else
  108.          addr = ((scsi_data[12] << 24) | (scsi_data[13] << 16) | (scsi_data[14] << 8) | (scsi_data[15]) );
  109.  
  110.       sprintf(Buffer, "%02d", addr/75/60 );
  111.    Move( MainWnd->RPort, 80, 37+offy );
  112.    Text( MainWnd->RPort, Buffer, 2 );
  113.  
  114.         sprintf(Buffer, "%02d", (addr/75)%60 );
  115.    Move( MainWnd->RPort, 99, 37+offy );
  116.    Text( MainWnd->RPort, Buffer, 2 );
  117.  
  118.         microsleft = (ActStat==1)?((75 - addr%75)*13333 + 1000):999000;
  119.       if (NewTimer)
  120.          addr = ((scsi_data[12] << 16) | (scsi_data[11] << 16) | (scsi_data[10] << 8) | (scsi_data[9]) );
  121.       else
  122.          addr = ((scsi_data[8] << 16) | (scsi_data[9] << 16) | (scsi_data[10] << 8) | (scsi_data[11]) );
  123.  
  124.         sprintf(Buffer, "%02d", addr/75/60 );
  125.    Move( MainWnd->RPort, 168, 37+offy );
  126.    Text( MainWnd->RPort, Buffer, 2 );
  127.  
  128.         sprintf(Buffer, "%02d", (addr/75)%60 );
  129.    Move( MainWnd->RPort, 187, 37+offy );
  130.    Text( MainWnd->RPort, Buffer, 2 );
  131.  
  132.         addr = TOC_Addr[scsi_data[6]]-addr;
  133.         if ((addr<80) && (ActProg!=-1))
  134.             {
  135.             microsleft = ((addr<75)?addr:74)*13333 + 100;
  136.             SetNextTitle = 1;
  137.             };
  138.         sprintf(Buffer, "%02d", addr/75/60 );
  139.    Move( MainWnd->RPort, 124, 37+offy );
  140.    Text( MainWnd->RPort, Buffer, 2 );
  141.  
  142.         sprintf(Buffer, "%02d", (addr/75)%60 );
  143.    Move( MainWnd->RPort, 143, 37+offy );
  144.    Text( MainWnd->RPort, Buffer, 2 );
  145.         }
  146.     else if (ActStat != 2)
  147.         {
  148.         if (ActStat==0)
  149.             SCMD_ReadTOC();
  150.         if ((ActStat==1)&&(ActProg!=-1)&&(Program[ActProgTitle][ActProg]!=0))
  151.             {
  152.             SCMD_PlayAudio( ActProgTitle+1 );
  153.             }
  154.         else
  155.             {        
  156.             ActTitle = 0;
  157.             InputTitleStat = 0;
  158.             ActProgTitle = 0;
  159.             DrawPlaySymb( 0 );
  160.             SetDispStat();
  161.             DrawPrgmSymb( (ActProg!=-1)?1:0 );
  162.             SetBPen( MainWnd->RPort, 1 );
  163.             SetAPen( MainWnd->RPort, 1 );
  164.             RectFill( MainWnd->RPort, 25, 52+offy, 258, 64+offy );
  165.             SetAPen( MainWnd->RPort, 2 );
  166.             Move( MainWnd->RPort, 25, 61+offy );
  167.             slen = strlen(TOC_CDTitle);
  168.             Text( MainWnd->RPort, TOC_CDTitle, (slen>29)?29:slen );
  169.  
  170.             Buffer[0]='0';
  171.             Buffer[1]='0';
  172.  
  173.        Move( MainWnd->RPort, 25, 37+offy );
  174.        Text( MainWnd->RPort, Buffer, 2 );
  175.  
  176.        Move( MainWnd->RPort, 52, 37+offy );
  177.        Text( MainWnd->RPort, Buffer, 2 );
  178.  
  179.        Move( MainWnd->RPort, 80, 37+offy );
  180.        Text( MainWnd->RPort, Buffer, 2 );
  181.  
  182.        Move( MainWnd->RPort, 99, 37+offy );
  183.        Text( MainWnd->RPort, Buffer, 2 );
  184.  
  185.        Move( MainWnd->RPort, 168, 37+offy );
  186.        Text( MainWnd->RPort, Buffer, 2 );
  187.  
  188.        Move( MainWnd->RPort, 187, 37+offy );
  189.        Text( MainWnd->RPort, Buffer, 2 );
  190.  
  191.        Move( MainWnd->RPort, 124, 37+offy );
  192.        Text( MainWnd->RPort, Buffer, 2 );
  193.  
  194.        Move( MainWnd->RPort, 143, 37+offy );
  195.        Text( MainWnd->RPort, Buffer, 2 );
  196.        };
  197.         ActStat = 2;
  198.         };
  199.     if (settimer)
  200.         {
  201.         TimerIO->tr_node.io_Command = TR_ADDREQUEST;
  202.         TimerIO->tr_time.tv_secs    = 0;
  203.         TimerIO->tr_time.tv_micro   = microsleft;
  204.         SendIO((struct IORequest *)TimerIO);
  205.         };
  206.     }
  207.  
  208. int SetDispStat( void )
  209.     {
  210.     char  DispStat[20];
  211.     int i;
  212.  
  213.     for (i=0; i<20; i++) DispStat[i] = 0;
  214.     if (ActProg==-1)
  215.         {
  216.         for (i=ActTitle; (i<=TOC_NumTracks) && (i<20); i++)
  217.             DispStat[i-1] = 1;
  218.         }
  219.     else
  220.         {
  221.         for (i=ActProgTitle; Program[i-1][ActProg]!=0; i++)
  222.             {
  223.             if (Program[i-1][ActProg]<19)
  224.                 {
  225.                 DispStat[Program[i-1][ActProg]-1] = 1;
  226.                 }
  227.             else DispStat[19]=1;
  228.             }
  229.         }
  230.     for (i=0; i<20; i++)
  231.         {
  232.         SetAPen( MainWnd->RPort, 1+DispStat[i]*2 );
  233.         Move( MainWnd->RPort, 25+7*i, 65+offy );
  234.         Draw( MainWnd->RPort, 30+7*i, 65+offy );
  235.         Move( MainWnd->RPort, 25+7*i, 71+offy );
  236.         Draw( MainWnd->RPort, 30+7*i, 71+offy );
  237.         };
  238.     }
  239.  
  240.  
  241. void SCSI_Exit( void )
  242.     {
  243.     if (io_ptr)
  244.         {
  245.         CloseDevice ((struct IORequest *) io_ptr);
  246.         DeleteStdIO (io_ptr);
  247.         }
  248.     if (mp_ptr)
  249.         DeletePort (mp_ptr);
  250.     if (scsi_sense)
  251.         FreeMem (scsi_sense, SENSE_LEN);
  252.  
  253.     if (toc_buf)
  254.         FreeMem (toc_buf, MAX_TOC_LEN);
  255.  
  256.     if (scsi_data)
  257.         FreeMem (scsi_data, MAX_DATA_LEN);
  258.     }
  259.  
  260. char SCSI_Init (void)
  261.     {
  262.     if ((scsi_data = (UBYTE *) AllocMem (MAX_DATA_LEN, MEMF_CHIP | MEMF_CLEAR)) == NULL)
  263.         {
  264.         ErrorMsg( "AllocMem failed." );
  265.         return FALSE;
  266.         }
  267.  
  268.     if ((toc_buf = (UBYTE *) AllocMem (MAX_TOC_LEN, MEMF_CHIP)) == NULL)
  269.         {
  270.         ErrorMsg( "AllocMem failed." );
  271.         return FALSE;
  272.         }
  273.  
  274.     if ((scsi_sense = (UBYTE *) AllocMem (SENSE_LEN, MEMF_CHIP || MEMF_CLEAR)) == NULL)
  275.         {
  276.         ErrorMsg( "AllocMem failed." );
  277.         return FALSE;
  278.         }
  279.     if ((mp_ptr = (MSGPORT *) CreatePort (NULL, 0)) == NULL)
  280.         {
  281.         ErrorMsg( "CreatePort failed." );
  282.         return FALSE;
  283.         }
  284.     if ((io_ptr = (IOSTDREQ *) CreateStdIO (mp_ptr)) == NULL)
  285.         {
  286.         ErrorMsg( "CreateStdIO failed." );
  287.         return FALSE;
  288.         }
  289.     if (OpenDevice (scsi_dev, scsi_id, (struct IORequest *) io_ptr, 0) != 0)
  290.         {
  291.         ErrorMsg( "Can't open SCSI device.\n- Bad devicename?\n-Bad SCSI-ID?" );
  292.         return FALSE;
  293.         }
  294.     return TRUE;
  295.     }
  296.  
  297. int MakeCxObj( CxObj *broker, int nr, char *FiltStr )
  298.     {
  299.     if (filter[nr] = CxFilter( FiltStr ))
  300.         {
  301.         AttachCxObj(broker, filter[nr]);
  302.         if (sender[nr] = CxSender(BrokerMP, 1L))
  303.             {
  304.             AttachCxObj(filter[nr], sender[nr] );
  305.             if (translate[nr] = CxTranslate(NULL))
  306.                 {
  307.                 AttachCxObj(filter[nr], translate[nr]);
  308.                 return( CxObjError( filter[nr] ) );
  309.                 }
  310.             }
  311.         }
  312.     return( 1 );
  313.     }
  314.  
  315. int GetToolTypes(int argc, char **argv)
  316.     {
  317.     int err = 0;
  318.     char **ttarray = ArgArrayInit(argc,argv);
  319.  
  320.     if ( ! ( CxBase = OpenLibrary( "commodities.library", 37L )))
  321.         return( 3L );
  322.  
  323.     strcpy(&scsi_dev,ArgString( ttarray, "SCSI_DEV", "scsi.device" ));
  324.     scsi_id  = ArgInt( ttarray, "SCSI_ID", 1 );
  325.     strcpy(&SongPath,ArgString( ttarray, "SONGPATH", "" ));
  326.     WndPosition = ArgInt( ttarray, "WND_POS", 0 );
  327.     strcpy( FontName, ArgString( ttarray, "FONTNAME", "MCDP_DOT.font" ));
  328.     Wnd_X = ArgInt( ttarray, "XPOS",-1);
  329.     Wnd_Y = ArgInt( ttarray, "YPOS",-1);
  330.     NewTimer = ArgInt( ttarray, "NEWTIMER",-1);
  331.     newbroker.nb_Pro = (BYTE)ArgInt(ttarray, "CX_PRIORITY", 0);
  332.     ArgArrayDone();
  333.  
  334.     if (BrokerMP = CreateMsgPort())
  335.         {
  336.         newbroker.nb_Port = BrokerMP;
  337.         cxsigflag = 1L << BrokerMP->mp_SigBit;
  338. /*      hotkey = ArgString(ttarray, "CX_POPKEY", "rawkey control lalt <");
  339.         PopUp = ArgString(ttarray, "CX_POPUP", "Yes"); */
  340.         if (broker = CxBroker(&newbroker, NULL))
  341.             {
  342.             err+= MakeCxObj( broker,  0, "control lalt numericpad 0");
  343.             err+= MakeCxObj( broker,  1, "control lalt numericpad 1");
  344.             err+= MakeCxObj( broker,  2, "control lalt numericpad 2");
  345.             err+= MakeCxObj( broker,  3, "control lalt numericpad 3");
  346.             err+= MakeCxObj( broker,  4, "control lalt numericpad 4");
  347.             err+= MakeCxObj( broker,  5, "control lalt numericpad 5");
  348.             err+= MakeCxObj( broker,  6, "control lalt numericpad 6");
  349.             err+= MakeCxObj( broker,  7, "control lalt numericpad 7");
  350.             err+= MakeCxObj( broker,  8, "control lalt numericpad 8");
  351.             err+= MakeCxObj( broker,  9, "control lalt numericpad 9");
  352.             err+= MakeCxObj( broker, 10, "control lalt numericpad .");
  353.             err+= MakeCxObj( broker, 11, "control lalt shift numericpad enter");
  354.             err+= MakeCxObj( broker, 12, "control lalt numericpad /");
  355.             err+= MakeCxObj( broker, 13, "control lalt numericpad *");
  356.             err+= MakeCxObj( broker, 14, "control lalt numericpad -upstroke -");
  357.             err+= MakeCxObj( broker, 15, "control lalt numericpad +");
  358.             err+= MakeCxObj( broker, 16, "control lalt numericpad enter");
  359.             if (err==0)
  360.                 {
  361.                 ActivateCxObj(broker, 1L);
  362.                 return( 0L );
  363.                 }
  364.             }
  365.         }
  366.     ErrorMsg( "Couldn't setup Commodity" );
  367.     return( 2L );
  368.     }
  369.  
  370. void CleanUp( void )
  371.     {
  372.     CxMsg *msg;
  373.  
  374.     if ( DObj ) FreeDiskObject( DObj );
  375.     if (ListWnd)
  376.        {
  377.        ExitTitleList(2);
  378.        CloseListWindow();
  379.     }
  380.     if (ProgWnd)
  381.        {
  382.        ExitLists(2);
  383.        CloseProgWindow();
  384.     }
  385.     if ( broker ) DeleteCxObjAll(broker);
  386.     if ( BrokerMP )
  387.        {
  388.         while (msg = (CxMsg *)GetMsg(BrokerMP))
  389.             ReplyMsg((struct Message *)msg);
  390.         DeletePort( BrokerMP );
  391.        };
  392.     if ( CxBase ) CloseLibrary( CxBase );
  393.     }
  394.  
  395. ProcessCxMsg( CxMsg *msg )
  396.     {
  397.     ULONG msgid, msgtype;
  398.     int   nr;
  399.  
  400.     msgid = CxMsgID( msg );
  401.     msgtype = CxMsgType( msg );
  402.  
  403.     switch(msgtype)
  404.         {
  405.         case CXM_IEVENT:
  406.             if (msgid == 1L)
  407.                 {
  408.                 nr = 0;
  409.                 switch (((struct InputEvent *)CxMsgData(msg))->ie_Code)
  410.                     {
  411.                     case 67:
  412.                         if (ActStat!=1) SCMD_PlayAudio( 1 );
  413.                         break;
  414.                     case 60:
  415.                         SCMD_Stop();
  416.                         break;
  417.                     case 74:
  418.                         if (ActStat==1) SCMD_PlayAudio( ActProgTitle-1 );
  419.                         break;
  420.                     case 94:
  421.                         if (ActStat==1) SCMD_PlayAudio( ActProgTitle+1 );
  422.                         break;
  423.                     case 93:
  424.                         ActProg=-1;
  425.                         DrawPrgmSymb( 0 );
  426.                         InputTitleStat = 1;
  427.                         SetAPen( MainWnd->RPort, 2 );
  428.                         SetBPen( MainWnd->RPort, 1 );
  429.                         Move( MainWnd->RPort, 25, 37+offy );
  430.                         Text( MainWnd->RPort, "__", 2 );
  431.                         break;
  432.                     case 15:
  433.                         nr = 10;
  434.                         break;
  435.                     case 29:
  436.                         nr = 1; 
  437.                         break;
  438.                     case 30:
  439.                         nr = 2;
  440.                         break;
  441.                     case 31:
  442.                         nr = 3; 
  443.                         break;
  444.                     case 45:
  445.                         nr = 4; 
  446.                         break;
  447.                     case 46:
  448.                         nr = 5; 
  449.                         break;
  450.                     case 47:
  451.                         nr = 6; 
  452.                         break;
  453.                     case 61:
  454.                         nr = 7; 
  455.                         break;
  456.                     case 62:
  457.                         nr = 8; 
  458.                         break;
  459.                     case 63:
  460.                         nr = 9; 
  461.                         break;
  462.                     case 92:
  463.                         SCMD_Eject();
  464.                         break;
  465.                     }
  466.                 if (nr!=0)
  467.                     {
  468.                     switch( InputTitleStat )
  469.                         {
  470.                         char a;
  471.                         case 0:
  472.                             SCMD_PlayAudio( nr );
  473.                             break;
  474.                         case 1:
  475.                             if (nr < 10)
  476.                                 {
  477.                                 InputTitle = nr*10;
  478.                                 }
  479.                             else InputTitle = 0;
  480.                             a = (InputTitle/10)+48;
  481.                             SetAPen( MainWnd->RPort, 2 );
  482.                             SetBPen( MainWnd->RPort, 1 );
  483.                             Move( MainWnd->RPort, 25, 37+offy );
  484.                             Text( MainWnd->RPort, &a, 1 );
  485.                             InputTitleStat = 2;
  486.                             break;
  487.                         case 2:
  488.                             if (nr < 10)
  489.                                 {
  490.                                 InputTitle += nr;
  491.                                 };
  492.                             InputTitleStat = 0;
  493.                             SCMD_PlayAudio( InputTitle );
  494.                             break;
  495.                         }
  496.                     }
  497.                 };
  498.             break;
  499.         case CXM_COMMAND:
  500.             switch(msgid)
  501.                 {
  502.                 case CXCMD_DISABLE:
  503.                     ActivateCxObj(broker, 0L);
  504.                     break;
  505.                 case CXCMD_ENABLE:
  506.                     ActivateCxObj(broker, 1L);
  507.                     break;
  508.                 case CXCMD_DISAPPEAR:
  509.                     break;
  510.                 case CXCMD_APPEAR:
  511.                     break;
  512.                 case CXCMD_UNIQUE:
  513.                     break;
  514.                 case CXCMD_KILL:
  515.                     Wait( 1<<TimerMP->mp_SigBit );
  516.                     GetMsg(TimerMP);
  517.                SCSI_Exit();
  518.                     TimerExit();
  519.                     CleanUp();
  520.                     CloseMainWnd();
  521.                exit(0);
  522.                     break;
  523.                 };
  524.             break;
  525.         };
  526.     ReplyMsg((struct Message *)msg);
  527.     }
  528.  
  529. main (int argc, char **argv)
  530.     {
  531.     ULONG  GClass;
  532.     USHORT GCode;
  533.     UWORD  GQual;
  534.     ULONG  GTimeS;
  535.     ULONG  GTimeM;
  536.     struct Gadget *GList = 0l;
  537.     WORD   GMouseY;
  538.     ULONG  Signal;
  539.     struct IntuiMessage  *msg;
  540.     CxMsg *cxmsg;
  541.  
  542.     int j = 0, i = 0;
  543.     int returnvalue = 0;
  544.     int RefreshTimer = 8;
  545.  
  546.     GetToolTypes(argc,argv);
  547.  
  548.     if (SCSI_Init() && TimerInit())
  549.         {
  550.         if (OpenMainWnd(WndPosition,Wnd_X,Wnd_Y)==0)
  551.             {
  552.             SCMD_ReadTitleTime(1);
  553.             for(;;)
  554.                 {
  555.                 Signal = (1<<MainWnd->UserPort->mp_SigBit) | (1<<TimerMP->mp_SigBit) | cxsigflag;
  556.                 if (ListWnd) Signal = Signal | (1<<ListWnd->UserPort->mp_SigBit);
  557.                 if (ProgWnd) Signal = Signal | (1<<ProgWnd->UserPort->mp_SigBit);
  558.                 Signal = Wait( Signal );
  559.                 if (Signal & (1<<TimerMP->mp_SigBit))
  560.                     {
  561.                     GetMsg(TimerMP);
  562.                     SCMD_ReadTitleTime(1);
  563.                     };
  564.                 if (Signal & cxsigflag)
  565.                     {
  566.                         while ( cxmsg = (CxMsg *)GetMsg(BrokerMP))
  567.                          ProcessCxMsg( cxmsg );
  568.                     };
  569.  
  570.                 if (ListWnd) if (Signal & (1<<ListWnd->UserPort->mp_SigBit)) Handle_ListInput();
  571.                 if (ProgWnd) if (Signal & (1<<ProgWnd->UserPort->mp_SigBit)) Handle_ProgInput();
  572.  
  573.                 if (Signal & (1<<MainWnd->UserPort->mp_SigBit))
  574.                     {
  575.                     while ( msg = (struct IntuiMessage *) GetMsg( MainWnd->UserPort ) )
  576.                         {
  577.                         GClass  = msg->Class;
  578.                         GCode   = msg->Code;
  579.                         GQual   = msg->Qualifier;
  580.                         if (GClass & (GADGETDOWN | GADGETUP | MOUSEMOVE) )
  581.                             GList   = (struct Gadget *) msg->IAddress;
  582.                         GMouseY = msg->MouseY;
  583.                         GTimeS  = msg->Seconds;
  584.                         GTimeM  = msg->Micros;
  585.                         ReplyMsg(msg);
  586.  
  587.                          switch (GClass)
  588.                          {
  589.                            case IDCMP_CLOSEWINDOW :
  590.                                 Wait( 1<<TimerMP->mp_SigBit );
  591.                                 GetMsg(TimerMP);
  592.                                 SCSI_Exit();
  593.                                 TimerExit();
  594.                                 CleanUp();
  595.                                 CloseMainWnd();
  596.                       exit(0);
  597.                       break;
  598.                   case IDCMP_GADGETUP    :
  599.                                 switch (GList->GadgetID)
  600.                                     {
  601.                                     case 19: ActProg=-1;
  602.                                              DrawPrgmSymb( 0 );
  603.                                              InputTitleStat = 1;
  604.                                              SetAPen( MainWnd->RPort, 2 );
  605.                                              SetBPen( MainWnd->RPort, 1 );
  606.                                              Move( MainWnd->RPort, 25, 37+offy );
  607.                                              Text( MainWnd->RPort, "__", 2 );
  608.                                              break;
  609.                                     case 20: if (!ListWnd) TitleList();
  610.                                              else WindowToFront(ListWnd);
  611.                                              ShowCDTitle();
  612.                                              break;
  613.                                     case 21: if (!ProgWnd) ProgList();
  614.                                              else WindowToFront(ListWnd);
  615.                                              break;
  616.                                     case 22: if (ActProg==-1)
  617.                                                  {
  618.                                                  ActProg = 0;
  619.                                                  DrawPrgmSymb( 1 );
  620.                                                  }
  621.                                              break;
  622.                                     case 23: if (ActStat==3)
  623.                                                  {
  624.                                                  SCMD_PauseResume();
  625.                                                  }
  626.                                              else if (ActStat!=1) SCMD_PlayAudio( 1 );
  627.                                              break;
  628.                                     case 24: SCMD_PauseResume();
  629.                                              break;
  630.                                     case 25: SCMD_Stop();
  631.                                              break;
  632.                                     case 26: if (ActStat==1) SCMD_PlayAudio( ActProgTitle-1 );
  633.                                              break;
  634.                                     case 27: if (ActStat==1) SCMD_PlayAudio( ActProgTitle+1 );
  635.                                              break;
  636.                                     case 28: if (ActStat==1) SCMD_Jump( -750 );
  637.                                              break;
  638.                                     case 29: if (ActStat==1) SCMD_Jump( 750 );
  639.                                              break;
  640.                                     case 30: SCMD_Eject();
  641.                                              break;
  642.                                     default: if ((ActProg==-1)&&(GList->GadgetID < 19))
  643.                                                  {
  644.                                                  switch( InputTitleStat )
  645.                                                      {
  646.                                                      char a;
  647.                                                      case 0:
  648.                                                          SCMD_PlayAudio( GList->GadgetID+1 );
  649.                                                          break;
  650.                                                      case 1:
  651.                                                          if (GList->GadgetID < 9)
  652.                                                              {
  653.                                                              InputTitle = (GList->GadgetID+1)*10;
  654.                                                              }
  655.                                                          else InputTitle = 0;
  656.                                                          a = (InputTitle/10)+48;
  657.                                                          SetAPen( MainWnd->RPort, 2 );
  658.                                                          SetBPen( MainWnd->RPort, 1 );
  659.                                                          Move( MainWnd->RPort, 25, 37+offy );
  660.                                                          Text( MainWnd->RPort, &a, 1 );
  661.                                                          InputTitleStat = 2;
  662.                                                          break;
  663.                                                      case 2:
  664.                                                          if (GList->GadgetID < 9)
  665.                                                              {
  666.                                                              InputTitle += GList->GadgetID+1;
  667.                                                              };
  668.                                                          InputTitleStat = 0;
  669.                                                          SCMD_PlayAudio( InputTitle );
  670.                                                          break;
  671.                                                      }
  672.                                                  }
  673.                                              else if ((ActProg!=-1)&&(GList->GadgetID < 8))
  674.                                                  {
  675.                                                  ActProg = GList->GadgetID + 1;
  676.                                                  }
  677.                                              break;
  678.                                     };
  679.                                 SCMD_ReadTitleTime(0);
  680.                                 RefreshTimer = 8;
  681.                       break;
  682.                   };
  683.               };
  684.                     };
  685.                 };
  686.             };
  687.         }
  688.     SCSI_Exit();
  689.     TimerExit();
  690.     CleanUp();
  691.     CloseMainWnd();
  692.     exit( 0 );
  693.     }
  694.