📄 enhanced_selector_prev_for_ape.c
字号:
/*
*******************************************************************************
* File selector
* enhanced library
*
* (c) Copyright, Actions Co,Ld.
* All Right Reserved
*
*******************************************************************************
*/
#pragma codeseg(MO_EH_FSL)
#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 fileoffset; //the file seek index
extern BYTE PlaylistTotal; //the total of the same class songs
extern BYTE PlaylistStart; //the begin number of the same class songs
extern BYTE PlaylistClassTotal; //the total class of the playlist file
extern BYTE PlaylistClass; //the current class of the playlist file
extern BYTE PlayListFileName[12]; //the opened file name of playlist
#pragma memory=constseg(MOC_EH_FSL)
/* music: mp3, wma, asf, wmv
* voice: act, wav
*/
const char APEExt1[] = "APE";
#ifdef __OGG_SUPPORT
const char ExtMusic1[][4] = {"MP3", "WMA", "ASF", "WMV", "OGG", "APE"};
#endif
#ifndef __OGG_SUPPORT
const char ExtMusic1[][4] = {"MP3", "WMA", "ASF", "WMV", "APE"};
#endif
const char ExtVoice1[][4] = {"WAV", "ACT"};
const char RootName1[] = {":"};
const char IgnoreExt1[4] = {"* "};
const char ExtAmv1[][4] = {"AMV"};
const char ExtDsc1[][4] = {"JPG","BMP","GIF"};
const char ExtTxt1[][4] = {"TXT"};
#pragma memory=default
#pragma memory=dataseg(MOD_EH_FSL)
char m_szTemp1[12];
#pragma memory=default
extern WORD GetFileTotalCur(BOOL bCheckValidDir);
extern WORD GetFileTotal(char *strDir, BOOL bCheckValidDir);
extern BOOL SelectAPENext(char* strFile);
extern BOOL FS_LASTDir(char *strDir);
void _ClearWatchDog()
{
output8(REG4E_RTC_WATCH_DOG, input8(REG4E_RTC_WATCH_DOG) | 0x08);
}
/********************************************************************************
* 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 Init1(unsigned char type, BYTE mode)
{
fselType = type;
fselDirLayer = 0;
fselMode = mode;
//for(i=0; i<TOTALDIRLAYER; i++)
// fselDirNo[i] = 0;
memset(fselDirNo, 0 , TOTALDIRLAYER);
fselFileNo = 0;
fselExtNo = 0;
#ifdef __APE_SUPPORT
fselFileNo_APE = 0;
CurApe_TotalNo = 0;
#endif
fselError = 0;
fselTotal = 0;
//return root dir
FS_CD(RootName1);
}
/********************************************************************************
* Description : Seek to the next file extend name
*
* Arguments : none
* Returns :
TRUE: Successful
FALSE: fail.
* Notes : None
*
********************************************************************************/
bool ToNextExt1(void)
{
fselExtNo ++;
// output8(REG4E_RTC_WATCH_DOG, input8(REG4E_RTC_WATCH_DOG) | 0x08);
_ClearWatchDog();
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 * GetExtBuf1(void)
{
// output8(0x4e,input8(0x4e)|0x8);
_ClearWatchDog();
if ( fselType == FSEL_TYPE_MUSIC)
return ExtMusic1[fselExtNo];
else if( fselType == FSEL_TYPE_VOICE)
return ExtVoice1[fselExtNo];
else if( fselType == FSEL_TYPE_DSC)
return ExtDsc1[fselExtNo];
else if(fselType == FSEL_TYPE_AMV)
return ExtAmv1[fselExtNo];
else
return ExtTxt1[fselExtNo];
}
/********************************************************************************
* Description : select the next file and get the file name
*
* Arguments :
* Returns :
* Notes :
*
********************************************************************************/
BOOL SelectNext1(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(GetExtBuf1(), APEExt1, 3))
{
if(SelectAPENext(Curfilename))
{
strcpy(strFile,Curfilename);
return TRUE;
}
goto _SelectNext;
}
#endif
if( FS_Dir(strFile, GetExtBuf1(), temp))
{
*(strFile+11) ='\0';
//#ifdef __APE_SUPPORT
// strcpy(Curfilename,strFile);
//#endif
fselFileNo ++;
return TRUE;
}
_SelectNext:
while( ToNextExt1())
{
#ifdef __APE_SUPPORT
if(!memcmp(GetExtBuf1(), APEExt1, 3))
{
if(SelectAPENext(Curfilename))
{
strcpy(strFile,Curfilename);
return TRUE;
}
continue;
}
#endif
if( FS_Dir(strFile, GetExtBuf1(), 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 file name according to number in current directory
*
* Arguments :
* strFile: file name
* Num : File number in currect directory
* Returns :
* TRUE: Successful
* FALSE: Fail, detail information in fselError.
* Notes : None
*
********************************************************************************/
BOOL fselGetByNO1( char *strFile, const WORD Num)
{
if( (Num > fselTotal)||(Num == 0))
{
fselError = FSEL_ERR_OUTOF;
return FALSE;
}
fselFileNo = 0;
fselExtNo = 0;
#ifdef __APE_SUPPORT
fselFileNo_APE = 0;
CurApe_TotalNo = 0;
#endif
while (Num>fselFileNo)
{
// output8(REG4E_RTC_WATCH_DOG, input8(REG4E_RTC_WATCH_DOG) | 0x08);
_ClearWatchDog();
if(!SelectNext1(strFile))
{
return FALSE;
}
}
return TRUE;
}
/********************************************************************************
* Description : select the next file and get the file name
*
* Arguments :
strFile: Dos 8.3 file name of selected
* Returns :
TRUE: Successful
FALSE: Fail, detail information in fselError
* Notes : don't rewind
*
********************************************************************************/
BOOL SelectPrev(char* strFile)
{
// handle the case of end,
if (fselFileNo == 1)
{
fselError = FSEL_ERR_OUTOF;
return FALSE;
}
if (fselFileNo == 0)
fselFileNo= fselTotal;
else
fselFileNo--;
if(fselGetByNO1(strFile, fselFileNo))
{
return TRUE;
}
fselError = FSEL_ERR_FAIL;
return FALSE;
}
/********************************************************************************
* 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 ToDirEntry1(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, IgnoreExt1, 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, IgnoreExt1, FS_DIR_DIR_CONT))
{
fselError = FSEL_ERR_OUTOF;
return FALSE;
}
temp++;
}
// output8(0x4e,input8(0x4e)|0x8);
_ClearWatchDog();
return TRUE;
}
/********************************************************************************
* Description : Select the prev of current select directory
*
* Arguments : none
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -