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

📄 mm_file.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 5 页
字号:
//                  [1] MM_INDEX_CONVERT_DIR2DISC, convert file index from
//                      directory to disc view
//                  [2] MM_INDEX_CONVERT_DISC2DIR, convert file index from
//                      disc to directory view
//                  [3] MM_INDEX_CONVERT_ABS2REL_DIR_LIST, convert cursor index
//                      from absolute to relative coordinate (directory list)
//                  [4] MM_INDEX_CONVERT_REL2ABS_DIR_LIST, convert cursor index
//                      from relative to absolute coordinate (directory list)
//                  [5] MM_INDEX_CONVERT_ABS2REL_FILE_LIST, convert cursor index
//                      from absolute to relative coordinate (file list)
//                  [6] MM_INDEX_CONVERT_REL2ABS_FILE_LIST, convert cursor index
//                      from relative to absolute coordinate (file list)
//                  bDir, specify the desired directory index, from '0'
//                  bIndex, specify the desired file index, from '0'
//  Return      :   the file index after this conversion
//  Side Effect :
//  Global      :   _dwMMTemp2
// **************************************************************************
WORD MM_IndexConvert(BYTE bMode, BYTE bDir, WORD wIndex)
{
    if(bMode < MM_INDEX_CONVERT_GROUP1) // means GROUP0: file index convert
    {
        // Calculate the final index after this conversion
        switch(bMode)
        {
        case    MM_INDEX_CONVERT_DIR2DISC:
            // Get 1st file index (in disc view) of current directory, index from '0'
            _dwMMTemp2=_MM_GetDir1stID(bDir);
            return (_dwMMTemp2+wIndex);
			
        case    MM_INDEX_CONVERT_DISC2DIR:
            // Get 1st file index (in disc view) of current directory, index from '0'
            _dwMMTemp2=_MM_GetDir1stID(bDir);
            return (wIndex-_dwMMTemp2);
			
        case    MM_INDEX_CONVERT_DIR2DISC_BY_FILTER:
            // Otherwise, go following procedure to do calculation
            _dwMMTemp2=0;
            for(_dwMMTemp5=0; _dwMMTemp5<bDir; _dwMMTemp5++)
            {
                _dwMMTemp2+=__pMMFilterFilesOfDir[_dwMMTemp5];
            }
            return (_dwMMTemp2+wIndex);
            
        default:
            break;
        }
    }
    else if(bMode < MM_INDEX_CONVERT_GROUP2) // means GROUP1: cursor index convert
    {
        // Calculate the final cursor index after the conversion
        switch(bMode)
        {
			// convert cursor index from absolute to relative coordinate within directory list
        case    MM_INDEX_CONVERT_ABS2REL_DIR_LIST:
            if(wIndex==0)
            {
                // Notice: always return current active directory ID if @ ROOT
                // nothing need to do, becasuse it's alwasy "ROOT"
                //return wIndex;
                return bDir;
            }
            else
            {
                if(__pMMVolumeDirTree[bDir].bParentID != 0x0) // 0x0=ROOT, so UP_DIR exist
                {
                    if(wIndex==1) // @ UP_DIR position
                    {
                        // Don't modify active directory ID if @ UP_DIR
                        return bDir;
                    }
                    else  // @ non-UP_DIR position
                    {
                        // final index = input index + current level's 1st sub-directory ID - ROOT - UP_DIR
                        // Notice: current level's 1st sub-directory ID =
                        //         1st sub-directory ID of desired directory's parent
                        _dwMMTemp5=__pMMVolumeDirTree[bDir].bParentID; // get parent ID first
                        return (wIndex + __pMMVolumeDirTree[_dwMMTemp5].b1stSubDirID - 2); // 2 = ROOT + UP_DIR
                    }
                }
                else // no UP_DIR exist
                {
                    // final index = index + ROOT's 1st sub-directory ID (0x1) - ROOT
                    return (wIndex);
                }
            }
			
			// convert cursor index from relative to absolute coordinate within directory list
        case    MM_INDEX_CONVERT_REL2ABS_DIR_LIST:
            if(wIndex==0)
            {
                // nothing need to do, becasuse it's alwasy "ROOT"
                return wIndex;
            }
            else
            {
                if(__pMMVolumeDirTree[bDir].bParentID != 0x0) // 0x0=ROOT, so UP_DIR exist
                {
                    if(wIndex==1) // @ UP_DIR position
                    {
                        return 1;
                    }
                    else
                    {
                        // final index = input index - current level's 1st sub-directory ID + ROOT + UP_DIR
                        // Notice: current level's 1st sub-directory ID =
                        //         1st sub-directory ID of desired directory's parent
                        _dwMMTemp5=__pMMVolumeDirTree[bDir].bParentID; // get parent ID first
                        return (wIndex + 2 - __pMMVolumeDirTree[_dwMMTemp5].b1stSubDirID); // 2 = ROOT + UP_DIR
                    }
                }
                else // no UP_DIR exist
                {
                    // final index = index - ROOT's 1st sub-directory ID (0x1) + ROOT
                    return (wIndex);
                }
            }
            break;
			
			// convert cursor index from absolute to relative coordinate within file list window
			// Notice: only valid on file index
        case    MM_INDEX_CONVERT_ABS2REL_FILE_LIST:
            // input index - desired directory's sub-directory NO
            return  (wIndex-__pMMVolumeDirTree[bDir].bNoOfSubDir);
			
			// convert cursor index from relative to absolute coordinate within file list window
			// Notice: only valid on file index
        case    MM_INDEX_CONVERT_REL2ABS_FILE_LIST:
            // input index + desired directory's sub-directory NO
            return  (wIndex+__pMMVolumeDirTree[bDir].bNoOfSubDir);
			
        default:
            break;
        }		
    }
	
    return wIndex;
}

//#######################################################################
//  Function    :   _MM_QueryInfo1
//  Description :
//  Parameters  :   bQueryID,
//                  wParam
//  Return      :
//  Changed     :
//  Side Effect :
//  Notice      :   Collect the cases don't care directory ID
//  Global      :   _dwMMTemp2, _dwMMTemp7
//#######################################################################
WORD _MM_QueryInfo1(BYTE bQueryID, WORD wParam)
{
    WORD wTemp;
    // Step 1: process the cases which are independent of active/ playing directory ID
    switch(bQueryID)
    {
		// LLY2.81, using another method to implement this case to enhance performance
		// Because, don't call _MM_GetDir1stID() again
		// LLY0.84, search un-support char
		// TRUE: input ASCII code is a unknown char
		// FALSE: input ASCII code can be recognized
    case    MM_QUERY_UNKNOWN_CHAR:
        // Keep input ASCII code into wTemp, and using it to do comparsion
        // To reduce the code while comparsion procedure
        wTemp=(WORD)wParam;
        if( (wTemp>=48 && wTemp<=57) ||   // '0' ~ '9'
            (wTemp>=65 && wTemp<=90) ||   // 'a' ~ 'z'
            (wTemp>=97 && wTemp<=122) ||  // 'A' ~ 'Z'
            (wTemp==32) ||  // ' '
            (wTemp==43) ||  // '+'
            (wTemp==45) ||  // '-'
            (wTemp==46) ||  // '.'
            (wTemp==47) ||  // '/'
            (wTemp==58) ||  // ':'
            (wTemp==95) ||  // '_'
            (wTemp==39) )  // "'"
            return FALSE;
        else
            return TRUE;
		
    default:
        break;
    }
	
    // LLY.172q, default return FALSE if there is no match-case
    return FALSE;
}

//  *********************************************************************
//  Function    :   _MM_QueryInfo2
//  Description :   Same as _QueryInfo w/o reference 2nd parameter
//                  to reduce the SRAM
//  Argument    :   bQueryID, the desired query ID
//  Return      :   The correspond information of the desired query ID
//  Side Effect :
//  Global      :   _dwMMTemp2/ _dwMMTemp5
//  Notice      :   Collect the cases independent of directory/ file index
//  *********************************************************************
WORD _MM_QueryInfo2(BYTE bQueryID, WORD wDirID)
{
    switch(bQueryID)
    {
    case    MM_QUERY2_TOTAL_ITEM_OF_DIRPAGE:
        if(_bMMParentID == UNEXIST_DIR)
            return 1;
        return (1 + _bMMExistUpDir + __pMMVolumeDirTree[_bMMParentID].bNoOfSubDir);
		
    case    MM_QUERY2_TOTAL_SORT_FILTER_ITEM:
        return (__pMMFilterFilesOfDir[wDirID] + __pMMVolumeDirTree[wDirID].bNoOfSubDir);
    default:
        break;
    }
    return  FALSE;
}

//#######################################################################
//  Function    :   MM_PreparePage
//  Description :   Prepare the display menu page info.
//  Parameters  :   bPageID, the desired menu page style
//                  wParam
//  Return      :
//  Changed     :
//  Side Effect :
//  Global      :   _dwMMTemp2, _dwMMTemp1
//#######################################################################
// LLY2.81, implement new code to meet CT908 UI requirement
void MM_PreparePage(BYTE bPageID, WORD wDirID, BYTE bMMExtFilterMode, BYTE bMMSortMethod)
{
    // Step 1: Prepare the necessary info while draw one page
    switch(bPageID)
    {
    case    MM_PREPARE_FILEPAGE:
        // Update final parent directory ID
        // wyc2.38a-909s, add parameter wDirID in function.
        _bMMParentID=__pMMVolumeDirTree[wDirID].bParentID;
		
        // Update if exist UP-directory
        if(_bMMParentID == UNEXIST_DIR) // current directory is "ROOT"
            _bMMExistUpDir=FALSE;
        else if(_bMMParentID == 0x0) // current directory at 1st level of directory tree
            _bMMExistUpDir=FALSE;
        else // others, ie. current directory at >= 2nd level of directory tree
            _bMMExistUpDir=TRUE;
		
        _dwMMLastRelID = 0xFFFFFFFF;
        _dwMMLastAbsID = 0xFFFFFFFF;
        // wyc0.67, need to sore file gere before display file name.
        _MM_SortFilterFiles(wDirID, bMMExtFilterMode, bMMSortMethod);
        break;
		
    case    MM_PREPARE_PROGLIST:
        for(_dwMMTemp7=0; _dwMMTemp7<__bProgramMaxEntry; _dwMMTemp7++)
        {
            // Get desired item's index w/ disc view
            // Notice: __ProgIdxList[].wSubIndex index from '1'
            //         but the index from '0' within FMANAGER module
            _dwMMTemp2 = MM_ID_RelativeToAbsolute(__ProgIdxList[_dwMMTemp7].bMainIndex, (WORD)(__ProgIdxList[_dwMMTemp7].wSubIndex-1));
			
            strncpy(__pMMProgContent[_dwMMTemp7].cName, __pMMFileRecordStart[_dwMMTemp2].FileName.cName, sizeof(FILENAMEINFO)-1);
            __pMMProgContent[_dwMMTemp7].bExtID = __pMMFileRecordStart[_dwMMTemp2].FileName.bExtID;
        }
        break;
    default:
        break;
    }	
}

//#######################################################################
//  Function    :   MM_ParseDirFiles
//  Description :   This function will parse the files in dir by bFileType. For example, can use bFileType
//                  to select MP3 only. The file record will put in __pMMFileRecord.
//  Parameters  :   bDirID: The dir to parsee files. bFileType: The variable to record supported files.
//              :   wFileIndex: The specific file index to parse in dir.
//  Return      :   TRUE: Mean file parsed OK. FALSE: Mean no files or parse failed.
//  Side Effect :
//#######################################################################
BYTE MM_ParseDirFiles(WORD wDirID, BYTE bFileType, WORD wFileIndex)
{
    // wyc2.53-909P,
    if (bFileType == 0)
        return FALSE;
    //MM_PreparePage(MM_PREPARE_FILEPAGE,__MMSelectCursor.wDirID, bFileType, __bMMSortMethod);
    MM_PreparePage(MM_PREPARE_FILEPAGE, wDirID, bFileType, __bMMSortMethod);
    if (wFileIndex > __pMMFilterFilesOfDir[wDirID])
        return FALSE;
    if (__pMMFilterFilesOfDir[wDirID] != 0)
    {
        MM_TriggerDumping(MM_ID_RelativeToAbsolute(wDirID, wFileIndex), __pMMFilterFilesOfDir[wDirID]);
        return TRUE;
    }
    else 
        return FALSE;
}

//#######################################################################
//  Function    :   _MM_PrepareInfo
//  Description :   Prepare the all playable files relative information
//                  - the total directory name list : __pMMDirNameList

⌨️ 快捷键说明

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