⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enhanced_selector_next_for_ape.c

📁 MP3 整个 SDK
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
*******************************************************************************
*                File selector 
*            enhanced library
*
*        (c) Copyright, Actions Co,Ld.                             
*             All Right Reserved                          
*
*******************************************************************************
*/ 
#include "actos.h"
#include "enhanced.h"
#include "debug.h"

extern  handle  fpPlaylist;         //playlist handle    
extern  BYTE    fselPLOrCommonDir;  //playlist or common operation
extern  BYTE    fselType;      //Type of select,  Music or voice.
extern  BYTE    fselError;    // store error id;
extern  WORD    fselFileNo;   //file no
#ifdef __APE_SUPPORT
extern  WORD    fselFileNo_APE;    //Number of current file no with total APE parts of current and last in ape file
extern  BYTE    Curfilename[12];
extern  BYTE    CurApe_TotalNo;
#endif
extern  BYTE    fselExtNo; //Number of current file ext name..
extern  char    fselDiskLetter;
extern  WORD    fselRandCount;

extern  WORD    fselTotal;  //Total of current select file
extern  BYTE    fselDirLayer;  //dir  layer
extern  BYTE    fselDirNo[TOTALDIRLAYER];    //Number of current valid directory

extern  BYTE    fselMode;   //opened file selector mode
extern  WORD    PlaylistCurItem;    //1 ~ ClassItemTotal
extern  WORD    ClassItemTotal; //the total of the same class songs
extern  BYTE    PlayListFileName[12]; //the opened file name of playlist

#pragma memory=constseg(MOC_EH_FSL2)
/* music: mp3, wma, asf, wmv
 * voice: act, wav
 */
#ifdef __OGG_SUPPORT 
    const char ExtMusic2[][4] = {"MP3", "WMA", "ASF", "WMV", "OGG", "APE"};
#endif    
#ifndef __OGG_SUPPORT 
    const char ExtMusic2[][4] = {"MP3", "WMA", "ASF", "WMV", "APE"};
#endif        
const char APEExt2[] = "APE";
const char ExtVoice2[][4] = {"WAV", "ACT"};
const char RootName2[] = {":"};
const char IgnoreExt2[4] = {"*  "};

const char ExtDsc2[][4] = {"JPG","BMP","GIF"};
const char ExtTxt2[][4] = {"TXT"};
const char ExtAmv2[][4] = {"AMV"};

#pragma memory=default
#pragma memory=dataseg(MOD_EH_FSL2)
char    m_szTemp[12];
#pragma memory=default

extern WORD  GetFileTotal(char *strDir,  BOOL bCheckValidDir);
extern WORD  GetFileTotalCur_Ape();
extern BOOL SelectAPENext(char* strFile);

#pragma codeseg(MO_EH_FSL2)
/********************************************************************************
* Description : Initialize the the file selector parament.
*
* Arguments  : 
*            type: music or voice
             mode: 6 kinds mode
* Returns     :
*            TRUE:    Successful
*            FALSE:    Fail, detail information in fselError
* Notes       :  Should select path in the case of only file name is invalid 
*
********************************************************************************/
void Init(unsigned char type,  BYTE mode)
{
    BYTE    i;
    
    fselType = type;
    fselDirLayer = 0;
    fselMode = mode;
    for(i=0; i<TOTALDIRLAYER; i++)
        fselDirNo[i] = 0;
    fselFileNo = 0;
#ifdef __APE_SUPPORT
    fselFileNo_APE = 0;
    CurApe_TotalNo = 0;
#endif
    fselExtNo = 0;
    fselError = 0;
    fselTotal = 0;
    //return root dir
    FS_CD(":");
}

/********************************************************************************
* Description : Initialize the FSEL module
*
* Arguments  :
            type:   Select type,  is FSEL_TYPE_MUSIC or FSEL_TYPE_VOICE
*            mode: Select mode, is FSEL_ALL_SEQUENCE or  FSEL_ALL_REPEATONE ...
*            DirLevel: Directory deep level, 0 or 1 now.
*
* Returns     :
*            TRUE: Successful,
*            FALSE: Fail, detail information in fselError.
* Notes       :Must call it before call other fsel Module functions
*
********************************************************************************/
BOOL fselInit(unsigned char type,  BYTE mode, BYTE  PlayListOrCommonDir, BYTE    CardOrFlash)
{    
    fselDiskLetter = 0x00;
    
    if ( CardOrFlash == 'C' )
    {
        if ( !DRV_ActiveDrive('C', 1) )
            goto DiskError;
        fselDiskLetter = 'C';
    } 
    else if ( CardOrFlash == 'H' )
    {
        if ( !DRV_ActiveDrive('H', 1) )
            goto DiskError;
        fselDiskLetter = 'H'; 
    }
    else 
    {
DiskError:    
        fselError = FSEL_ERR_DISK;
        return FALSE;
    }
    
    if(!FS_Init()) 
    {
        fselError = FSEL_ERR_FS;
        return FALSE;
    }
    
    Init(type,mode);
    
    if  (PlayListOrCommonDir == FSEL_TYPE_COMMONDIR)
    {
        fselPLOrCommonDir = FSEL_TYPE_COMMONDIR;
        return TRUE;
    }
    else if (PlayListOrCommonDir == FSEL_TYPE_PLAYLIST)
    {
        fselPLOrCommonDir = FSEL_TYPE_PLAYLIST;
    }
    else
    {
        return FALSE;
    }
    return TRUE;
}

/********************************************************************************
* Description : Get a random number
*
* Arguments  : None
* Returns     :  
            Random number
* Notes       :  None
*
********************************************************************************/
WORD Random(void)
{                   
    sfr RTCTimeLo = 0x45;
    sfr RTCControl = 0x43;
    RTCControl |= 0x08;

    fselRandCount = (*(WORD *)fselRandCount + RTCTimeLo)&0x3fff;
    return fselRandCount;
}

/********************************************************************************
* Description : Seek to the next file extend name 
*
* Arguments  : none
* Returns     :
            TRUE: Successful
            FALSE: fail.
* Notes       :  None
*
********************************************************************************/
bool ToNextExt(void)
{
    fselExtNo ++;
    output8(REG4E_RTC_WATCH_DOG, input8(REG4E_RTC_WATCH_DOG) | 0x08);  
    if ( fselType == FSEL_TYPE_MUSIC)
    {
        if (fselExtNo>=FSEL_MUSIC_EXTNUM)
        {
            fselExtNo = 0;
            return FALSE;
        }
    }
   else if(fselType == FSEL_TYPE_VOICE)

    {
      if (fselExtNo>=FSEL_VOICE_EXTNUM)
        {
            fselExtNo = 0;
            return FALSE;
        }
    }

   else if(fselType == FSEL_TYPE_DSC)

     {
      if(fselExtNo>=FSEL_DSC_EXTNUM)

        {
             fselExtNo = 0;
            return FALSE;
        }

     }
   else if(fselType == FSEL_TYPE_AMV)
     {
      if(fselExtNo>=FSEL_AMV_EXTNUM)

        {
             fselExtNo = 0;
            return FALSE;
        }

     }
   else if(fselType == FSEL_TYPE_TXT)
     {
      if(fselExtNo>=FSEL_TXT_EXTNUM)

        {
             fselExtNo = 0;
            return FALSE;
        }

     }
    return TRUE;    
}
/********************************************************************************
* Description : Get name buffer of current extend 
*
* Arguments  :  None
* Returns     :  the buffer of current file extend name
* Notes       :     None
*
********************************************************************************/
char * GetExtBuf(void)
{
    output8(0x4e,input8(0x4e)|0x8);
    if ( fselType == FSEL_TYPE_MUSIC)
        return ExtMusic2[fselExtNo];
    else if( fselType == FSEL_TYPE_VOICE)
        return ExtVoice2[fselExtNo];
    else if( fselType == FSEL_TYPE_DSC)
        return ExtDsc2[fselExtNo];
    else if(fselType == FSEL_TYPE_AMV)
        return ExtAmv2[fselExtNo];
    else 
        return ExtTxt2[fselExtNo];        
}
/********************************************************************************
* Description : seek to  specify Directory Entry 
*
* Arguments  : 
*        strDir: Dos 8.3 Directory name
*            num: number of the Directory Entry to seek
*
* Returns     :
*            TRUE: Successful
*            FALSE: Fail,  detail information in fselError
* Notes       : 
*
********************************************************************************/
BOOL ToDirEntry(char *strDir, const WORD Num)
{
   WORD temp;
    if(Num>FSEL_MAX_DIRNUM)
    {
        fselError = FSEL_ERR_OUTOF;
        return FALSE;
    }
    
    if ( Num < 1)
    {
        fselError = FSEL_ERR_OUTOF;
        return FALSE;
    }
    
    memset(strDir,0x00,12);
    if (!FS_Dir(strDir,  IgnoreExt2, FS_DIR_DIR))
    {
        fselError = FSEL_ERR_OUTOF;
        return FALSE;
    }
    if (Num ==1)
        return TRUE;

    ///seek to the specify directory entry
    temp = 2;
    while ( temp <= Num)
    {
        if (!FS_Dir(strDir,  IgnoreExt2, FS_DIR_DIR_CONT))
        {
            fselError = FSEL_ERR_OUTOF;
            return FALSE;
        }
        temp++;           
    }
    output8(0x4e,input8(0x4e)|0x8);
    return TRUE;
}
/********************************************************************************
* Description : select the next file and get the file name
*
* Arguments  : 
* Returns     :
* Notes       : 
*
********************************************************************************/
BOOL SelectNext(char* strFile)
{
    BYTE temp;

    // handle the case of end, 
    if (fselFileNo == fselTotal)
    {
        fselError = FSEL_ERR_OUTOF;
        return FALSE;
    }

    //search the file by current file ext name.
    if (fselFileNo == 0)
        temp = FS_DIR_FILE;
    else
        temp = FS_DIR_FILE_CONT;
#ifdef __APE_SUPPORT
    if( !memcmp(GetExtBuf(), APEExt2, 3))
    {
	    if(SelectAPENext(strFile))
			return TRUE;
		goto _SelectNext;
    }
#endif
    if( FS_Dir(strFile,  GetExtBuf(), temp))
    {
        *(strFile+11) ='\0';
#ifdef __APE_SUPPORT
       strcpy(Curfilename,strFile);
#endif
       fselFileNo ++;            
        return TRUE;
    }
_SelectNext:

    while( ToNextExt())
    {
#ifdef __APE_SUPPORT
		if(!memcmp(GetExtBuf(), APEExt2, 3))
		{
			if(SelectAPENext(strFile))
				return TRUE;
			continue;
		}
#endif
		if( FS_Dir(strFile,  GetExtBuf(), FS_DIR_FILE))
        {
            *(strFile+11) ='\0';
#ifdef __APE_SUPPORT
            strcpy(Curfilename,strFile);
#endif
            fselFileNo ++;            
            return TRUE;
        }
    }
    fselError = FSEL_ERR_FAIL;
    return FALSE;
}
/********************************************************************************
* Description : Select the next directory of current select directory
*
* Arguments  : 
*                 strDir: Dos 8.3 directory name of the next.
*
* Returns     : 
*    TRUE:  success.
*    FALSE: fail, detail info store in fselError.
* Notes       :  None
*
********************************************************************************/
BOOL fselNextDir(char *strDir)
{
    WORD wtemp;
    wtemp = fselDirNo[fselDirLayer];
    wtemp ++;
    if (! ToDirEntry(strDir, wtemp))
    {
        return FALSE;
    }
    fselDirNo[fselDirLayer] = wtemp;
    return TRUE;
}
/********************************************************************************
* Description : Get the total of files in the current directory entry
* Arguments  : 
*            strDir: Dos 8.3 directory name
*            bCheckValidDir: if check valid directory only
* Returns     :
*            The file total of current directory when bCheckValidDir = FALSE
            or Vaild BOOL flag when bCheckValidDir = TRUE
* Notes       : None
*
********************************************************************************/
WORD  GetFileTotalCur(BOOL bCheckValidDir)
{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -