📄 fmanager.c
字号:
////////////////////////////////////////////////////////////
// ***** Big Modification History Area *****
// LLY.274p, some big modification:
// [1] Rename all MP3 relative info. because module name has changed !!
// - Module Name w/ "FM_" as it's prefix.
// (1) General case : only rename "MP3_" as "FM_"
// (2) Special case : do a little modification for APIs name
// . MP3_CheckMP3Disc() --> FM_CheckPlayableDisc()
// . _MP3_Prepare() --> _FM_PrepareInfo()
// - Variables Name:
// . __cMP3AlbumList[] --> __strFMDirList[]
// . _cMP3SongList[] --> _strFMSongList[]
// . _dwSongTOC[] --> _dwFMFileTOC[]
// . __pMP3NameList --> __pFMNameList
// . __bMP3Page --> __wFMMenuPage
// . _wSongsOfAlbum --> _wFMFilesOfDir
// . __wTotalAlbums --> __wFMTotalDirs;
// . __wTotalSongs --> __wFMTotalFiles;
// . __bMP3MenuID --> __bFMMenuID
// . __bMP3Page.wAlbumIndex --> __wFMMenuPage.wDirIndex
// . MP3Log --> FileLog
// . MP3_PAGE_BEGIN_ID --> _bMenuPage_1stID
// . MP3_PAGE_END_ID --> _bMenuPage_lastID
// - Define Name
// . MP3_MENU_NONE --> FM_MENU_NONE
// . MP3_MENU_ALBUM --> FM_MENU_ALBUM
// . MP3_MENU_SONG --> FM_MENU_FILE
// . MP3_MAX_ALBUM_NO --> FM_MAX_DIR_NO
// . MP3_MAX_SONG_NO --> FM_MAX_FILE_NO_ONE_TITLE
// . MP3_MAX_STRING_LENGTH --> FM_MAX_STRING_LENGTH
// . MP3_NAME_DIR --> FM_CONVERT_DIRNAME
// . MP3_NAME_SONG --> FM_CONVERT_FILENAME
// . MP3_GET_ALBUM_INDEX --> FM_QUERY_DIR_INDEX
// . MP3_1STITEM_OF_PAGE --> FM_QUERY_1STITEM_OF_PAGE
// . MP3_LASTITEM_OF_PAGE --> FM_QUERY_LASTITEM_OF_PAGE
// . MP3_IS_CURRENT_PAGE --> FM_QUERY_CURRENT_PAGE
// . MP3_ALBUM_PAGE --> FM_PREPARE_DIRPAGE
// . MP3_SONG_PAGE --> FM_PREPARE_FILEPAGE
// . MP3_NEW_PAGE --> FM_PREPARE_NEWPAGE
// . MP3_NEXT_PAGE --> FM_PREPARE_NEXTPAGE
// . MP3_PREV_PAGE --> FM_PREPARE_PREVPAGE
// . MP3_NEXT_ALBUM --> FM_PREPARE_NEXT_DIRPAGE
// . MP3_PREV_ALBUM --> FM_PREPARE_PREV_DIRPAGE
// . MP3_SUPPORT_JUMP_ALBUM --> SUPPORT_JUMP_ONE_DIR_FOLDER
// . MP3_NO_SELECTION --> NO_SELECTION_FOR_MENUPAGE
// . CONVERT_MP3_NAME --> CONVERT_UNKNOWN_NAME
// [2] Remove _FM_ChangePage() because it's unnecessary.
// And _FM_ChangePage(MP3_CURRENT_PAGE, XXX) can be replaced with
// _QueryInfo(MP3_IS_CURRENT_PAGE)
// LLY2.80, Remove some un-necessary code, ex.
// [1] Define
// - VCD_SYSTEM
// - W_MP3
// - USE_DRAM_BUFFER
// [2] Variables
// - _bMenuPage_1stID
// - _bMenuPage_lastID
// [3] MENUPAGEINFO structure, some variables from WORD to BYTE unit
// - wNOofItems --> bNOofItems
// - wTotalPages --> bTotalPages
// - wPageIndex --> bPageIndex
// [4] Rename some global variables to meet CT908 UI requirement
// - __strFMDirList --> __pFMDirNameList
// - __strFMFileList --> __pFMFileNameList
// - _dwFMFileTOC --> _pFMFileTOC
// - _wFMFilesOfDir --> __pwFMFilesOfDir
// - __wFMMenuPage.wDirInex --> __bFMActiveDir
// - __wFMTotalDirs --> __bFMTotalDirs
// - bLoc --> __pFMDirLoc
// LLY2.80, re-adjust the define name and let it be readability
// LLY2.81,
// [1] Remove active/ selection info. within MENUPAGEINFO
// - __wFMMenuPage.wHighLight --> __FMActiveCursor.wIndex
// - __wFMMenuPage.wSelection --> __FMSelectCursor.wIndex
// Let selection cursor be same as active cursor while support only one cursor case
// The operation:
// - Light selection cursor:
// update active info. first, then update selection info. later
// ie. selection info. means last active info.
// - Light active cursor:
// update selection info. first, then update active info. later
// ie. active info. means last selection info.
// Thus, F/W can increase the code's readability
// (ie. less #ifdef/ #else/ #endif SUPPORT_RUNTIME_SELECTION_ACTION)
// [2] Remove some un-necessary code
// - FM_PREPARE_NEWPAGE
// [3] Remove wOverflow info. within MENUPAGEINFO,
// Because nobody refer it after modifying KEY_LEFT/ KEY_RIGHT procedure
// [4] Transfer the coordinate from disc view to directory
// - disc view: the file index is continue from 1st directory's 1st file
// to last directory's last file
// - directory view: always index from '0' for 1st file of each directory
// - related variables: __wFMActiveCursor.wIndex/ __wFMSelectCursor.wIndex/ __wFMMenuPage.w1stID
// [5] Splite _QueryInfo() into three APIs:
// - _QueryInfo(bQueryID, wParam) -- only relative to file index
// - _FM_QueryInfo2(bQueryID) -- independent of directory/ file index
// - _FM_QueryInfo3(bQueryID, bDir, wParam) -- relative to directory/ file index together
// LLY0.83b-2,
// [1] Add the control procedure for CT908 UI
// LLY0.86, add FM_CLEAR_BACKGROUND for _FM_InitialMenu() reference
// LLY0.86-2,
// [1] Re-adjust program mode relative procedure to meet new program mode (>=WinDVD0.86)
// - Maintain __bProgramCurrentIndex & __bProgamMaxEntry
// while insert or delete entry
// - Index from '1' for __ProgIdxList[].wSubIndex
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
// ****** All necessary including files Area ******
#include "winav.h"
#include <string.h>
#include "CTString.h"
#include "input.h"
#include "cdinfo.h"
#include "cc.h"
#include "osd.h"
#include "fmanager.h" // "mp3.h"
#include "utl.h"
#include "isr.h"
#include "servo.h"
#include "monitor.h" // LLY.276
#include "setup.h"
#include "w99av.h"
#include "chips.h"
#include "hal.h"
#include "linear.h"
#include "thumb.h" // LLY2.80
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
// ****** Some MP3 feature Define Area ******
// [1] Debug mode info. for JPEG/ MP3 playing
#ifdef SUPPORT_PRINTF
// [1-1] If define it, it will output message while parsing/ decoding fail
//#define _DEBUG_JPEG_PLAYING_FAIL
// [1-2] If define it, it will output idle mode info.
//#define _DEBUG_JPEG_IDLE
// [1-3] If define it, it will output message while handle postpond key
//#define _DEBUG_POSTPOND_KEY
// [1-4] If define it, it will output message for progressive JPEG decoding
//#define _DEBUG_PROGRESSIVE_JPEG
// [1-5] If define it, it will output message for two buffer control reference
//#define _DEBUG_TWO_BUFFER
// [1-6] If define it, it will output message for normal decode or re-decode mode
//#define _DEBUG_DECODING_MODE
// [1-7] If undefine it, F/W will use two buffer for JPEG decoding
//#undef JPEG_SINGLE_BUFFER
// [1-8] If define it, F/W will shorten the playing range, ie. end = begin + 50
// Notice: Can't enable it for JPEG file
// Otherwise, it wll cause JPEG decoding not finish.
//#define _DEBUG_SHORTEN_PLAY_RANGE
#endif // #ifdef SUPPORT_PRINTF
// [2] If define it, it will enable ERROR_CONCEAL mechanism
#define ERROR_CONCEAL
// [3] If define it, it will support JPEG flip feature
//#define SUPPORT_JPEG_FLIP
// [4] if define it, in the ERROR_CONCEAL mode -- LLY.275a
// F/W will re-decode the current item while decoding error,
// Otherwise, it will go next item directly
#define REDECODE_CURRENT_ITEM
// [5] DVD_160Micky, add define for enable/disable MP3 track number during detection
// define it, will show MP3 tracks number during detection
#define SHOW_MP3TRACK_LOADING_STATUS
// wyc2.30, add define to select file name format.
//#define SUPPORT_CONVERT_FILE_NAME
// [7] If define it, it will support rotate JPEG 180 degree while press KEY_UP/KEY_DOWN -- LLY.278a-1
// Otherwise, those key is invalid
// Notice: This feature will be disable automatically while enable "#define SUPPORT_JPEG_FLIP"
// Becasue, it share the same key
//#define SUPPORT_ROTATE_180
#ifdef SUPPORT_JPEG_FLIP
#undef SUPPORT_ROTATE_180
#endif // #ifdef SUPPORT_JPEG_FLIP
// [8] If define it, it will convert the unknown name into "MP3XXX" or "JPGXXX"
// Otherwise, it will display "_" to present the unknown char
// wyc2.36, move this define to customer.h
//#define CONVERT_UNKNOWN_NAME
// [9] If define it, F/W will discard the empty directory -- LLY2.80
// Otherwise, the empty directory will be always kept
// wyc2.27, can decide enable it or not.
//#define DISCARD_EMPTY_DIRECTORY
// wyc1.24, add one define for enable / disable JPG related debug information.
//#define JPG_DEBUG_INFO
//////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// ****** Some global define Area (Only for FMANAGER module internal usage) ******
// [1] DRAM temp buffer area -- DVD_156Micky
//LLY2.80, rename it as FM_DIR_NAME_BUFFER_ADDR
//#define W99AV_FREE_DRAM_START 0x2200 // shared with "write pixel command" buffer
// [2] Define "R/W DRAM burst mode" relative info.
#define BURST_UNIT 4
// [3] For OSD_Trigger usage
#define MP3_SKIP_SECTORS 20 // about skip 20 sectors, about 2.5 seconds
/////////////////////////////////////////////////////////////
// ***** Internal Function Prototype Area *****
void _FM_ConvertName(BYTE bType, WORD wIndex);
BYTE _FM_PrepareInfo(void);
//void _FM_InitialJPGStatus(void);
void _FM_IdleCheck(void); //LLY.274p-2
WORD _QueryInfo(BYTE bQueryID, WORD wParam);
WORD _FM_QueryInfo2(BYTE bQueryID); // LLY2.81
//BYTE _FM_QueryInfo3(BYTE bQueryID, BYTE bDir, WORD wParam); // LLY2.81 //--CoCo1.21, remove not used function
BYTE _FM_FilterKey(BYTE bKey); //LLY.274p-3
BYTE _FM_UpdateMenuInfo(BYTE bKey);// LLY2.80 , WORD wTrackNO);
BYTE _FM_KeyAction(BYTE bKey); //LLY2.80 , WORD wTrackNO);
BYTE _FM_PostpondKey(BYTE bKey); // LLY.276
WORD _FM_IndexConvert(BYTE bMode, BYTE bDir, WORD wIndex); // LLY2.81
#ifdef SUPPORT_FM_BUTTONS //CoCo1.21
BYTE _FM_ButtonAction(void); // LLY0.83b-2
#endif //SUPPORT_FM_BUTTONS
void _FM_SimulateChangeDir(void); // LLY0.86-2
void _FM_RecoverCursorToFileList(void); //CoCo1.10
void _FM_EnterThumbMode(void); //CoCo1.21
void _FM_CancelDisplayMode(void); //CoCo1.21
void _FM_ChangeActiveCursorAsSelectCursor(void); //CoCo1.21
void _FM_JPEGChangeToNext(void); //CoCo1.22
void _FM_JPEGRedecode(void); //CoCo1.22
WORD _FM_GetNoneJPEGItems(void); //CoCo1.25
// wyc2.27, function to discard empty dirs
BYTE _FM_ExistEmptyFolder(void);
#ifdef JPG_DEBUG_INFO
void _FM_DebugInfo(void); //CoCo1.22a, for JPEG debug
extern void _ShowDebug();
#endif
//////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// ****** Global Variable Declared Area ******
#ifndef NO_MP3
// [1] File Log structure
// [G-19bytes]
FILE_LOG FileLog;
// [2] The information of one display menu page
// It indicate the first directory index/ or first file index
// which is used to be displayed in the current page.
// (1). While in directory menu selection state,
// use 1stID to access __pFMDirNameList[] to get the name information.
// (2) While in file menu selection state,
// use 1stID to access __pFMFileNameList[] to get the name information.
// use bAlbumIndex to access __pFMDirNameList[] to get current album name information.
// [G-13bytes]
//MENUPAGEINFO __wFMMenuPage; //--CoCo1.21, remove it because no one use __wFMMenuPage
// [3] The name of directories
// It keeps each directory's name stored.
// Use index 0 to access the 1st directory info,
// and index 1 to access the 2nd directory info, ... etc.
// [G-3bytes]
// LLY2.80, use "Directory Name structure"
//PFILENAMEINFO __pFMDirNameList;
PDIRNAMEINFO __pFMDirNameList;
// [4] The name of files
// It keeps each file's name stored.
// Use index 0 to access the 1st file info,
// and index 1 to access the 2nd file info, ... etc.
// [G-3bytes]
PFILENAMEINFO __pFMFileNameList;
// [5] A pointer to directory name array or file name array
// [G-3bytes]
// LLY2.80, it's unnecessary to give the default value
PFILENAMEINFO __pFMNameList; // NULL;
// [6] Store the start sector of each directory
// the size is max_directory_no*3(bytes)=150*3=450(bytes)
// LLY.172r-1, use __bPool[] instead of SRAM (reduce SRAM 450 bytes)
// [G-3bytes]
//BYTE *bLoc;
PDIR_LOC _pFMDirLoc;
// [7] Indicate current display Menu format -- None/ Directory/ File Menu
// store current file manager menu state
// CT9928AF solution:
// * __bFMMenuID = FM_MENU_NONE, leave File Manager control menu
// * __bFMMenuID < FM_MENU_FILE, currently in directory selection list.
// * __bFMMenuID >= FM_MENU_FILE, currently in file selection list.
// CT908 solution:
// * __bFMMenuID = FM_MENU_NONE, leave File Manager control menu
// * __bFMMenuID = FM_MENU_NORMAL, within File Manager control menu
// * __bFMMenuID = FM_MENU_EDITPROG, within input program menu
// * __bFMMenuID = FM_MENU_PROGLIST, within program list menu
// [G-1bytes]
// LLY2.80, remove the initial action to INITIAL_Variables_PowerON()
BYTE __bFMMenuID; // =FM_MENU_NONE;
// [8] Keep page index range
// [G-2bytes]
// LLY2.80, those two variables seems un-necessary now.
// Or, they are only used for debug mode
//BYTE _bMenuPage_1stID=0;
//BYTE _bMenuPage_lastID=0;
// [8-1] Keep current active/open directory ID, index from '0' -- LLY2.80
BYTE __bFMActiveDir;
// [8-2] Keep current playing directory ID, index from '0' -- LLY2.81
BYTE __bFMPlayingDir;
// wyc1.05, add a new variable to record the next going directory, purpose is to moving highlight between directories when issuing KEY_UP/KEY_DOWN.
// [8-3] Keep the next to go directory ID, index from '0' -- WYC1.05
BYTE __bFMNextActiveDir;
// wyc1.05, add a new variable to record the type of moving cursor across boundary. One is KEY_NEXT/KEY_PREVher is KEY_UP/KEY_DOWN.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -