UiPlayCommon.c
上传用户:hjhsjcl
上传日期:2020-09-25
资源大小:11378k
文件大小:67k
源码类别:

压缩解压

开发平台:

C++ Builder

  1. /*==========================================================================
  2. Copyright (c) 2004 ALi Corporation. All Rights Reserved
  3. File: UiPlayCommon.c
  4. content: common function for UiPlay & UiFileList
  5. History: Created by TNE 2005/6/1
  6. ==========================================================================*/
  7. #define _UI_PLAY_COM_H_
  8. #include <DP8051XP.H>
  9. #include "TypeDef.h"
  10. #include "Const.h"
  11. #include "Reg5661.h"
  12. #include "Common.h"
  13. #include "UiCommon.h"
  14. #include "SysStrDef.h"
  15. #include "UiSysStr.h"
  16. #include "OledString.h"
  17. #include "Key.h"
  18. #include "SaveSetting.h"
  19. #include "Playback.h"
  20. #include "NandFlash.h"
  21. #include "Idma.h"
  22. #include "UiPlay.h"
  23. #include "FileSystem.h"
  24. #include "ExtCodec.h"
  25. #include "IntCodec.h"
  26. #include "UiPlayCommon.h"
  27. #include "ClassDataBase.h"
  28. #include "UiClassList.h"
  29. #include "OLED.h"
  30. #include "IconDefine.h"
  31. #include "UiPlayDel.h"
  32. #if(USE_STEP_UP_CONVERTER)
  33. #include "StepUp.h"
  34. #endif
  35. #if(_PM_MENU_==1 || _PM_VD_MENU_)
  36. #include "UiPlayMenu.h"
  37. #elif(_PM_MENU_==2)
  38. #include "UiPlayMenu2.h"
  39. #endif
  40. #if(UI_CUSTOM_EQ_WITH_COMP) //Walace060907#4 start
  41. #define FADE_TARGET_DSP_GAIN gxwTargetDspGain
  42. #else
  43. #define FADE_TARGET_DSP_GAIN P0_095_dB
  44. #endif //Walace060907#4 start
  45. ////////////////////////////////////////////////////////////////////////////////////
  46. /////////////////////////////////  Ui Header End ///////////////////////////////////
  47. /////Add for EQ////    
  48. //Jeff_051116 start //tne 2006/01/16
  49. #if(_PM_PLAY_PRC_|(_PM_MENU_==1))
  50. #if(UI_USE_USER_EQ)
  51. #if(UI_CUSTOM_EQ_WITH_COMP)
  52. //Walace060510#1
  53. //Walace060702#1 start
  54. #if(UI_EQ_ALL_USE_PA_COMP) 
  55. #define EQ_VAL_NORMAL N6dB          
  56. #define EQ_VAL_ADPCM_NORMAL A_N07_7dB 
  57. #else
  58. #define EQ_VAL_NORMAL P0dB      //Walace060823#2  //Walace060907#4
  59. #define EQ_VAL_ADPCM_NORMAL A_P00_0dB
  60. #endif
  61. //Walace060702#1 end
  62. //normal -6dB
  63. CWORD cwEQTable[16]=
  64. {
  65. N12dB,N11_5dB, N11dB,N10dB,N9dB,N8dB,N7dB,
  66. N6dB,
  67. N5dB,N4dB,N3dB,N2dB,N1_5dB,N1dB,N0_5dB,P0dB
  68. };
  69. CBYTE cbAdpcmEQTable[8]=
  70. {
  71. //Walace060902#4 start
  72. /* 
  73. A_P02_2dB,
  74. A_P00_0dB,
  75. A_N02_2dB,
  76. A_N05_0dB,
  77. A_N05_0dB,
  78. A_N07_7dB,
  79. A_N10_5dB,
  80. A_N14_0dB,
  81. */
  82. A_N14_0dB,
  83. A_N10_5dB,
  84. A_N07_7dB,
  85. A_N05_0dB,
  86. A_N05_0dB,
  87. A_N02_2dB,
  88. A_P00_0dB,
  89. A_P02_2dB
  90. //Walace060902#4 end
  91. };
  92. #else //#if(UI_CUSTOM_EQ_WITH_COMP)
  93. //normal
  94. //Walace060510#1 start
  95. #define EQ_VAL_NORMAL P0dB      //Walace060823#2    //Walace060907#4        
  96. #define EQ_VAL_ADPCM_NORMAL A_P00_0dB
  97. //Walace060510#1 end
  98. CWORD cwEQTable[16]=
  99. {
  100. N6dB,N5_5dB, N5dB,N4dB,N3dB,N2dB,N1dB,
  101. P0dB,
  102. P1dB,P2dB,P3dB,P4dB,P4_5dB,P5dB,P5_5dB,P6dB
  103. };
  104. CBYTE cbAdpcmEQTable[8]=
  105. {
  106. //Walace060902#4 start
  107. /*
  108. A_P07_7dB,
  109. A_P05_0dB,
  110. A_P02_2dB,
  111. A_P00_0dB,
  112. A_P00_0dB,
  113. A_N02_2dB,
  114. A_N05_0dB,
  115. A_N07_7dB
  116. */
  117. A_N07_7dB,
  118. A_N05_0dB,
  119. A_N02_2dB,
  120. A_P00_0dB,
  121. A_P00_0dB,
  122. A_P02_2dB,
  123. A_P05_0dB,
  124. A_P07_7dB
  125. //Walace060902#4 end
  126. };
  127. #endif
  128. #endif
  129. #if(UI_EQ_CUSTOM)
  130. #if(UI_CUSTOM_EQ_WITH_COMP)  //Custom EQ with compensation --> Normal  - 6dB
  131.     
  132. CWORD cwDspVal_EQ[5][10]=
  133. {
  134. //     Frequency Band 
  135. //     1       2       3         4       5        6       7      8         9         10
  136. //     50    100     200    400     800   1600  3200  6400   12800   25600
  137. {N10dB,N10dB,N6dB,N7_5dB,N6dB,N6dB,N7dB,N7dB,N7dB,N7dB}, //POP
  138. {N3dB,N3dB,N4_5dB,N6_5dB,N7dB,N6dB,N4dB,N2dB,N1dB,N1dB}, //ROCK
  139. {N6dB,N6dB,N6dB,N6dB,N6dB,N6dB,N6dB,N10dB,N10dB,N10dB}, //CLASSIC //Walace060308#1
  140. {N2dB,N2dB,N5dB,N6dB,N7dB,N6dB,N2dB,P0dB,P0dB,P0dB}, //JAZZ  //Walace060308#1
  141. {N1dB,N1dB,N1dB,N1dB,N3dB,N6dB,N9dB,N10dB,N11dB,N11dB}, //BASS
  142. };
  143. #if(_PM_DVR_|PLAY_SUPPORT_WAV) //Nick060629#1
  144. //                          1       2       3     4      (5+6)/2      (7+8)/2    (9+10)/2
  145. // Frequency Band 64   160   400  1000     2500          6250         15625 
  146. //Walace060607#5 start
  147. CWORD cwAdpcmVal_EQ[5][10]=
  148. {
  149. {A_N10_5dB, A_N10_5dB, A_N02_2dB, A_N02_2dB, A_N05_0dB, A_N05_0dB, A_N05_0dB, A_N05_0dB, A_N05_0dB, A_N05_0dB}, //POP
  150. {A_N02_2dB, A_N02_2dB, A_N05_0dB, A_N07_7dB, A_N07_7dB, A_N07_7dB, A_N05_0dB, A_N02_2dB, A_P00_0dB, A_P00_0dB}, //ROCK
  151. {A_N07_7dB, A_N07_7dB, A_N07_7dB, A_N07_7dB, A_N07_7dB, A_N10_5dB, A_N14_0dB, A_N14_0dB, A_N14_0dB, A_N14_0dB}, //CLASSIC  
  152. {A_N05_0dB, A_N05_0dB, A_N07_7dB, A_N10_5dB, A_N10_5dB, A_N07_7dB, A_N05_0dB, A_N02_2dB, A_P00_0dB, A_P00_0dB}, //JAZZ
  153. {A_N02_2dB, A_N02_2dB, A_N02_2dB, A_N05_0dB, A_N05_0dB, A_N14_0dB, A_N14_0dB, A_N14_0dB, A_N14_0dB, A_N14_0dB}, //BASS
  154. };
  155. //Walace060607#5 end
  156. #endif
  157. #else
  158. CWORD cwDspVal_EQ[5][10]=
  159. {
  160. //     Frequency Band 
  161. //     1       2       3         4       5        6       7      8         9         10
  162. //     50    100     200    400     800   1600  3200  6400   12800   25600
  163. {N1dB,N1dB,P3dB,P1_5dB,P3dB,P3dB,P2dB,P2dB,P2dB,P2dB}, //POP
  164. {P4dB,P4dB,P2_5dB,P0_5dB,P0dB,P1dB,P3dB,P5dB,P6dB,P6dB}, //ROCK
  165. {P0dB,P0dB,P0dB,P0dB,P0dB,P0dB,P0dB,N4dB,N4dB,N4dB}, //CLASSIC //Walace060308#1
  166. {P3dB,P3dB,P0dB,N1dB,N2dB,N1dB,P3dB,P5dB,P5dB,P5dB}, //JAZZ  //Walace060308#1
  167. {P5dB,P5dB,P5dB,P5dB,P3dB,P0dB,N3dB,N4dB,N5dB,N5dB}, //BASS
  168. };
  169. #if(_PM_DVR_|PLAY_SUPPORT_WAV) //Nick060629#1
  170. //Walace060607#5 start
  171. CWORD cwAdpcmVal_EQ[5][10]=
  172. {
  173. {A_N02_2dB, A_N02_2dB, A_P05_0dB, A_P05_0dB, A_P02_2dB, A_P02_2dB, A_P02_2dB, A_P02_2dB, A_P02_2dB, A_P02_2dB}, //POP
  174. {A_P05_0dB, A_P05_0dB, A_P02_2dB, A_P00_0dB, A_P00_0dB, A_P00_0dB, A_P02_2dB, A_P05_0dB, A_P07_7dB, A_P07_7dB}, //ROCK
  175. {A_P00_0dB, A_P00_0dB, A_P00_0dB, A_P00_0dB, A_P00_0dB, A_N02_2dB, A_N05_0dB, A_N07_7dB, A_N07_7dB, A_N07_7dB}, //CLASSIC  
  176. {A_P02_2dB, A_P02_2dB, A_P00_0dB, A_N02_2dB, A_N02_2dB, A_P00_0dB, A_P02_2dB, A_P05_0dB, A_P07_7dB, A_P07_7dB}, //JAZZ
  177. {A_P05_0dB, A_P05_0dB, A_P05_0dB, A_P02_2dB, A_P02_2dB, A_N05_0dB, A_N05_0dB, A_N05_0dB, A_N05_0dB, A_N05_0dB}, //BASS
  178. };
  179. //                          1       2       3     4      (5+6)/2      (7+8)/2    (9+10)/2
  180. // Frequency Band 64   160   400  1000     2500          6250         15625 
  181. /*
  182. CWORD cwAdpcmVal_EQ[5][10]=
  183. {
  184. {A_N02_2dB, A_P05_0dB, A_P05_0dB, A_P02_2dB, A_N05_0dB, A_N05_0dB, A_N05_0dB, A_N05_0dB, A_N05_0dB, A_N05_0dB}, //POP
  185. {A_P10_5dB, A_P00_0dB, A_N02_2dB, A_N02_2dB, A_P00_0dB, A_P00_0dB, A_P07_7dB, A_P07_7dB, A_P14_0dB, A_P14_0dB}, //ROCK
  186. {A_P02_2dB, A_P02_2dB, A_P02_2dB, A_P00_0dB, A_N05_0dB, A_N05_0dB, A_N05_0dB, A_N05_0dB, A_N05_0dB, A_N05_0dB}, //CLASSIC  
  187. {A_N02_2dB, A_N02_2dB, A_P00_0dB, A_P02_2dB, A_P10_5dB, A_P10_5dB, A_P10_5dB, A_P10_5dB, A_P05_0dB, A_P05_0dB}, //JAZZ
  188. {A_P05_0dB, A_P02_2dB, A_N02_2dB, A_N02_2dB, A_N02_2dB, A_N02_2dB, A_N02_2dB, A_N02_2dB, A_N02_2dB, A_N02_2dB}, //BASS
  189. };
  190. */
  191. //Walace060607#5 end
  192. #endif
  193. #endif //#if(UI_CUSTOM_EQ_WITH_COMP)  
  194. #endif //(UI_EQ_CUSTOM)
  195. #if(UI_EQ_CUSTOM)
  196. void UiSetEqGain(WORD wEqMode) large// 050907 WHH #
  197. {
  198. WORD wDecadMode;
  199. BYTE bNum;
  200.     
  201. #if(!FIVEKEY)
  202. XWORD gxwSwapoutMode = 0x01;
  203. IdmaPioDmxW(&gxwSwapoutMode,DSP_SWAP_OUT,1,DSP_W16);
  204. #endif
  205. wDecadMode = 0; 
  206. #if(_PM_DVR_|PLAY_SUPPORT_WAV) //Nick060629#1  
  207. if((gxbMusicType&M_MAIN_TYPE)!=M_WAV)
  208. #endif
  209. { IdmaPioDmxW(&wDecadMode,DSP_DECAY_MODE_ADDR,1,DSP_W16); }
  210. wDecadMode=EQ_USER;
  211. IdmaPioDmxW(&wDecadMode,DSP_EQ_ADDR,1,DSP_W16);
  212. #define wEQvalTemp wDecadMode
  213. for(bNum = 0; bNum<10; bNum ++)
  214. {
  215. #if(_PM_DVR_|PLAY_SUPPORT_WAV) //Nick060629#1
  216. if((gxbMusicType&M_MAIN_TYPE)==M_WAV)
  217. {
  218. if(wEqMode==EQ_NORMAL)
  219. {
  220. wEQvalTemp=EQ_VAL_ADPCM_NORMAL;
  221. IdmaPioDmxW(&wEQvalTemp,DSP_USER_EQ_LV1_ADDR+(bNum),1,DSP_W16);
  222. }
  223. #if(UI_USE_USER_EQ)
  224. else if(wEqMode==EQ_USER)
  225. {
  226. /* //Walace060607#5 start
  227. if(gxbUserDefEq[bNum>>1]==0x0F)
  228. wEQvalTemp=0x0F;
  229. else if(gxbUserDefEq[bNum>>1]==0x00)
  230. wEQvalTemp=0x03;
  231. else if(gxbUserDefEq[bNum>>1]<=0x07)
  232. wEQvalTemp=gxbUserDefEq[bNum>>1]+2;
  233. else
  234. wEQvalTemp=gxbUserDefEq[bNum>>1]-1;
  235. */
  236. wEQvalTemp=(WORD)cbAdpcmEQTable[(gxbUserDefEq[bNum>>1]>>1)];
  237. //Walace060607#5 end
  238. IdmaPioDmxW(&wEQvalTemp,DSP_USER_EQ_LV1_ADDR+(bNum),1,DSP_W16);
  239. }
  240. #endif
  241. else
  242. {
  243. IdmaPioDmxW(&cwAdpcmVal_EQ[wEqMode-1][bNum],DSP_USER_EQ_LV1_ADDR+(bNum),1,DSP_W16);
  244. }
  245. }
  246. else
  247. #endif
  248. {
  249. if(wEqMode==EQ_NORMAL)
  250. {
  251. wEQvalTemp=EQ_VAL_NORMAL;
  252. IdmaPioDmxW(&wEQvalTemp,DSP_USER_EQ_LV1_ADDR+(bNum),1,DSP_W16);
  253. }
  254. #if(UI_USE_USER_EQ)
  255. else if(wEqMode==EQ_USER)
  256. {
  257. wEQvalTemp=cwEQTable[gxbUserDefEq[bNum>>1]];
  258. IdmaPioDmxW(&wEQvalTemp,DSP_USER_EQ_LV1_ADDR+(bNum),1,DSP_W16);
  259. }
  260. #endif
  261. else
  262. {
  263. IdmaPioDmxW(&cwDspVal_EQ[wEqMode-1][bNum],DSP_USER_EQ_LV1_ADDR+(bNum),1,DSP_W16); 
  264. }
  265. }
  266. }
  267. #if(UI_CUSTOM_EQ_WITH_COMP) //Walace060402#1 start //Walace060406#1
  268. wEQvalTemp=gxwEqMode;
  269. gxwEqMode=wEqMode;
  270. CdcSetPaGain(gxbVolume); //tne 2006/12/26 #1
  271. gxwEqMode=wEQvalTemp;
  272. #endif
  273. #undef wEQvalTemp
  274. }
  275. #else
  276. void UiSetEqGain(WORD wEqMode) large// 050907 WHH #
  277. {
  278. WORD wDecadMode;
  279. BYTE bNum;
  280. #if(UI_CUSTOM_EQ_WITH_COMP)  //Walace060406#1
  281. WORD wEQvalTemp;
  282. #endif
  283. #if(!FIVEKEY)
  284. XWORD gxwSwapoutMode = 0x01;
  285. IdmaPioDmxW(&gxwSwapoutMode,DSP_SWAP_OUT,1,DSP_W16);
  286. #endif
  287.      wDecadMode = 0;  // EQ undecad, set 1 to enable decademode if required.
  288.     
  289. #if(_PM_DVR_|PLAY_SUPPORT_WAV) //Nick060629#1  
  290. if((gxbMusicType&M_MAIN_TYPE)!=M_WAV)
  291. #endif
  292. { IdmaPioDmxW(&wDecadMode,DSP_DECAY_MODE_ADDR,1,DSP_W16); }
  293.  
  294. IdmaPioDmxW(&wEqMode,DSP_EQ_ADDR,1,DSP_W16);
  295. #if(UI_CUSTOM_EQ_WITH_COMP)  //Walace060406#1
  296. wEQvalTemp=gxwEqMode;
  297. gxwEqMode=wEqMode;
  298. CdcSetPaGain(gxbVolume); //tne 2006/12/26 #1
  299. gxwEqMode=wEQvalTemp;
  300. #endif
  301. #if(UI_USE_USER_EQ)
  302. if(wEqMode!=EQ_USER)
  303. #endif
  304. return;
  305. //Walace060127#2 end 
  306. #if(UI_USE_USER_EQ)
  307. #define wEQvalTemp wDecadMode
  308. #if(_PM_DVR_|PLAY_SUPPORT_WAV) //Nick060629#1
  309. if((gxbMusicType&M_MAIN_TYPE)==M_WAV)
  310. {
  311. #if(UI_USE_USER_EQ)
  312. for(bNum = 0; bNum<10; bNum ++)
  313. {
  314. //Walace060607#5 start
  315. /*
  316. if(gxbUserDefEq[bNum>>1]==0x0F)
  317. wEQvalTemp=0x0F;
  318. else if(gxbUserDefEq[bNum>>1]==0x00)
  319. wEQvalTemp=0x03;
  320. else if(gxbUserDefEq[bNum>>1]<=0x07)
  321. wEQvalTemp=gxbUserDefEq[bNum>>1]+2;
  322. else
  323. wEQvalTemp=gxbUserDefEq[bNum>>1]-1;
  324. */
  325. wEQvalTemp=(WORD)cbAdpcmEQTable[(gxbUserDefEq[bNum>>1]>>1)];
  326. //Walace060607#5 start
  327. IdmaPioDmxW(&wEQvalTemp,DSP_USER_EQ_LV1_ADDR+(bNum),1,DSP_W16);
  328. }
  329. #endif
  330. }
  331. else
  332. #endif
  333. {
  334. for(bNum = 0; bNum<10; bNum ++)
  335. {
  336. wEQvalTemp=cwEQTable[gxbUserDefEq[bNum>>1]];
  337. IdmaPioDmxW(&wEQvalTemp,DSP_USER_EQ_LV1_ADDR+(bNum),1,DSP_W16);
  338. }
  339. }
  340. #undef wEQvalTemp
  341. #endif //#if(UI_EQ_CUSTOM|UI_USE_USER_EQ)
  342. }
  343. #endif //#if(UI_EQ_CUSTOM)
  344. #endif //#if(!(_PM_PLAY_DEL_|_PM_DIR_DEL_|_PM_VIDEO_))
  345. /////////////////////
  346. //   Jeff_051116 end
  347. /////////////////////
  348. //Walace060926#1 VideoResume
  349. #if(!(_PM_PLAY_DEL_ |_PM_DIR_DEL_|_PM_VD_PLAY_))
  350. void UiRndPlayInit(void) large
  351. {
  352. gxbRndOffset=(BYTE)gxdwNowTime;
  353. if(gxwCurrentFileNum<=gxbRndOffset)
  354. { gxwRndSeed=gxwCurrentFileNum+1023-gxbRndOffset; }
  355. else
  356. { gxwRndSeed=gxwCurrentFileNum-gxbRndOffset; }
  357. //gxwRndSeed=1;
  358. gxwRndListIndex=0;
  359. }
  360. #endif
  361. #if(_PM_PLAY_PRC_|_PM_VD_PLAY_) //(_PM_VIDEO_&!_PM_VD_MENU_))  // Jeff070125 #5
  362. // to get a random play list num
  363. // If fGetNext==TRUE , get the next song number
  364. // If fGetNext==FALSE, get the prev song number
  365. WORD UiGetRndPlayNum(bit fGetNext) large
  366. {
  367. WORD wCurrentNum;
  368. while(1)
  369. {
  370. //to get 1024 random number, bit0 xor bit3 , and then  put it to bit 10, right shift 1 bit
  371. if(fGetNext)
  372. { gxwRndSeed=(gxwRndSeed|(((gxwRndSeed^(gxwRndSeed>>3))&0x01)<<10))>>1; }
  373. //{ gxwRndSeed=(gxwRndSeed|(((gxwRndSeed&0x01)^((gxwRndSeed&0x08)>>3))<<10))>>1; }
  374. else
  375. {
  376. gxwRndSeed=gxwRndSeed<<1;
  377. gxwRndSeed=gxwRndSeed|((gxwRndSeed>>10)^(gxwRndSeed>>3)&0x01);
  378. //gxwRndSeed=gxwRndSeed|(((gxwRndSeed&0x400)>>10)^((gxwRndSeed&0x08)>>3));
  379. gxwRndSeed=gxwRndSeed&0x3FF;
  380. }
  381. wCurrentNum=gxwRndSeed+gxbRndOffset;
  382. if(wCurrentNum>=1024) wCurrentNum-=1023;
  383. if(wCurrentNum<=gxwNumTotalFiles)
  384. return wCurrentNum;
  385. }
  386. }
  387. #endif
  388. #if(!(_PM_PLAY_DEL_|_PM_DIR_DEL_|_PM_VIDEO_|_PM_PLAY_PRC_))
  389. void UiGoIntroMode(void) large
  390. {
  391. gfIntroPlaying=INTRO_PLAY;
  392. gxdwLastFileSize=0; //cancel resume
  393. #if(!_PM_SLS_)
  394. UiShowIntroString();
  395. #endif
  396. gxwCurrentPlayTime=0;
  397. //gxdwCurrentLrcTime=0; //tne 2006/02/10 #1 //Walace060226#remove
  398. gfFirstResume=FALSE; //tne 2006/01/14 #2
  399. }
  400. #endif
  401. #if(!(_PM_PLAY_DEL_|_PM_DIR_DEL_|_PM_VIDEO_|_PM_PLAY_PRC_))
  402. void UiCancelIntroMode(void) large
  403. {
  404. gfIntroPlaying=INTRO_NOP;
  405. gxbIntroMode=0;
  406. gxdwLastFileSec=0; //cancel resume function
  407. }
  408. #endif
  409. //Walace060531#1 PlayProcess
  410. /* //tne 2007/01/15 #1 move to UiCommon.c
  411. #if(UI_USE_ALARM_DISPLAY &!(_PM_PLAY_DEL_|_PM_DIR_DEL_|_PM_VIDEO_|_PM_PLAY_PRC_))
  412. extern XBYTE fUiTagHidden;
  413. #if(!_PM_SLS_) //Walace060830#3
  414. API void UiShowWakeUp(void) large
  415. */
  416. //tne 2007/01/06 #1 start
  417. #if(_PM_MENU_|_PM_VD_MENU_)
  418. void UiDrawBasicMusicMenu(void) large
  419. {
  420. UiShowLargeBackground(5,IM_BROWSER_BG_03_S1); //tne 2007/01/10 #2
  421. StrShowSysString(SYS_STR_MENU, LCD_AUTO_CENTER_COL,ITEM_START_ROW-ITEM_ROW_OFF);
  422. UiShowNormalTitleInfo();
  423. }
  424. #endif
  425. #if(_PM_MENU_|_PM_VD_MENU_)
  426. void UiShowMusicMenuText(void) large
  427. {
  428. BYTE bI,bJ;
  429. UiClearAllMenuItem();
  430. if(gxbUiMenuMainStates==MUSIC_MENU_MAIN_START_NUM)
  431. {
  432. bI=0;
  433. }
  434. else
  435. {
  436. bI=1;
  437. gfTransparent=TRUE;
  438. UI_SHOW_MENU_TITLE_ITEM_STRING(cbMenuTitleStr[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM]);
  439. gfTransparent=FALSE;
  440. }
  441. #if(_PM_PLAY_)
  442. PeFillDspBuf();
  443. #endif
  444. switch(gxbUiMenuMainStates)
  445. {
  446. #if(_PM_PLAY_ && UI_PLAY_USER_EQ_EDIT)
  447. case UI_USER_EQ_MENU:
  448. UiDrawUserDefEq();
  449. break;
  450. #endif
  451. /* //remove by tne 2007/01/06 #1
  452. case UI_SLIDE_SHOW: //Walace060220#1 use 
  453. UiDrawSlideShow();
  454. break;
  455. case UI_INTRO_MENU:
  456. UiDrawIntro();
  457. break;
  458. */
  459. default:
  460. //tne 2007/01/06 #1 start
  461. #define TOTAL_MENU_ITEM_NUM (cbMenuMaxItemNum[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM])
  462. #define TOTAL_DISP_ITEM_NUM (ITEM_NUM_OPAGE-bI)
  463. if(TOTAL_MENU_ITEM_NUM>=TOTAL_DISP_ITEM_NUM)
  464. {
  465. if((gxbUiMenuSubStates+TOTAL_DISP_ITEM_NUM)>TOTAL_MENU_ITEM_NUM) //Last page
  466. gxbMenuDispLine=TOTAL_DISP_ITEM_NUM-(TOTAL_MENU_ITEM_NUM-gxbUiMenuSubStates);
  467. else
  468. gxbMenuDispLine=0;
  469. }
  470. else
  471. {
  472. gxbMenuDispLine=gxbUiMenuSubStates;
  473. }
  474. for(bJ=0;( (bJ<TOTAL_DISP_ITEM_NUM) && (bJ<TOTAL_MENU_ITEM_NUM) );bJ++)
  475. {
  476. #if(_PM_PLAY_)
  477. PeFillDspBuf();
  478. #endif
  479. UiShowMenuItem( bJ,
  480. IM_EXPLORE_BUTTON_CLEAR_STRING,
  481. IM_ITEM_UNSELECT,
  482. pcbMenuListStr[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM][gxbUiMenuSubStates-gxbMenuDispLine+bJ]);
  483. }
  484. UiShowMenuItem(gxbMenuDispLine,IM_EXPLORE_BUTTON_01,IM_ITEM_SELECT,pcbMenuListStr[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM][gxbUiMenuSubStates]);
  485. #if(_PM_PLAY_)
  486. PeFillDspBuf();
  487. #endif
  488. #undef TOTAL_DISP_ITEM_NUM
  489. #undef TOTAL_MENU_ITEM_NUM
  490. //tne 2007/01/06 #1 end    
  491. break;
  492.   }
  493. }
  494. #endif
  495. #if(_PM_MENU_)
  496. void UiDrawUDefEqSel(void)
  497. {
  498. UiClearUDefEqSel();
  499. gxbSelUserDefEq=gxbUiMenuSubStates;
  500. UiShowUDefEqSel();
  501. }
  502. #endif
  503. /* //remove by tne 2007/01/06 #1
  504. void UiDrawSlideShow(void)
  505. {
  506. OledClearArea((OLED_MAX_COL-16)/2,ITEM_START_ROW+ITEM_ROW_OFF+PAGE1,16,PAGE1);
  507.   OledShowNumber(gxbUiMenuSubStates,(OLED_MAX_COL-16)/2,ITEM_START_ROW+ITEM_ROW_OFF+PAGE1,2);
  508. #if(UI_USE_PROGRESS_BAR)
  509.    ShowProgress((OLED_MAX_COL-PROGRESS_MAX)/2,(ITEM_START_ROW+ITEM_ROW_OFF*2),(((WORD)gxbUiMenuSubStates*PROGRESS_MAX)/(MENU_SLIDE_SHOW_ITEM_NUM-1)));
  510. #endif
  511. }
  512. */
  513.    
  514. #if(_PM_MENU_|_PM_VD_MENU_)
  515. void UiNextMenuItem(void) large
  516. {
  517. BYTE bI;
  518. #if(_PM_MENU_)
  519. PeFillDspBuf(); //Larry070310#4
  520. #endif
  521.           
  522. switch(gxbUiMenuMainStates)
  523. {
  524. #if(_PM_PLAY_ && UI_PLAY_USER_EQ_EDIT)
  525. case UI_USER_EQ_MENU:
  526. if(gfUserEqStartEdit)
  527. {
  528. if(gxbSelUserDefEq==5)
  529. UiEditUdefEq(UI_EDIT_ALL_EQ_UP);
  530. else
  531. UiEditUdefEq(UI_EDIT_EQ_UP);
  532. }
  533. else
  534. {
  535. if( gxbUiMenuSubStates>=(cbMenuMaxItemNum[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM]-1) ) //over max
  536. gxbUiMenuSubStates=0;
  537. else
  538. gxbUiMenuSubStates++;
  539. UiDrawUDefEqSel();
  540. }
  541. break;
  542. #endif
  543. /* //remove by tne 2007/01/06 #1
  544. case UI_SLIDE_SHOW:
  545. if( gxbUiMenuSubStates>=(cbMenuMaxItemNum[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM]-1) ) //over max
  546. gxbUiMenuSubStates=0;
  547. else
  548. gxbUiMenuSubStates++;
  549. UiDrawSlideShow();
  550. break;
  551. */
  552. default:
  553. UiShowMenuItem( gxbMenuDispLine,
  554. IM_EXPLORE_BUTTON_CLEAR_STRING,
  555. IM_ITEM_UNSELECT,
  556. pcbMenuListStr[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM][gxbUiMenuSubStates]);
  557. if(gxbUiMenuMainStates==MUSIC_MENU_MAIN_START_NUM)
  558. bI=0;
  559. else
  560. bI=1;
  561. if( gxbUiMenuSubStates>=(cbMenuMaxItemNum[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM]-1) ) //over max
  562. {
  563. gxbUiMenuSubStates=0;
  564. if(cbMenuMaxItemNum[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM]>(ITEM_NUM_OPAGE-bI)) //not only 1 page
  565. {
  566. UiShowMusicMenuText();
  567. break;
  568. }
  569. else
  570. gxbMenuDispLine=0;
  571. }
  572. else
  573. {
  574. gxbUiMenuSubStates++;
  575. if(gxbMenuDispLine>=(ITEM_NUM_OPAGE-bI-1))
  576. {
  577. UiMoveOneLine( ITEM_SEL_START_COL,
  578. ITEM_START_ROW+ITEM_ROW_OFF*bI,
  579. ITEM_COL_WIDTH,
  580. ITEM_NUM_OPAGE-bI-1,
  581. UI_FILE_LIST_UP);
  582. }
  583. else
  584. { gxbMenuDispLine++; }
  585. }
  586. UiShowMenuItem( gxbMenuDispLine,
  587. IM_EXPLORE_BUTTON_01,
  588. IM_ITEM_SELECT,
  589. pcbMenuListStr[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM][gxbUiMenuSubStates]);
  590. }
  591. #if(_PM_MENU_==1)
  592. UiSelectItemControl();
  593. #endif
  594. }
  595. void UiPrevMenuItem(void) large
  596. {
  597. BYTE bI;
  598. #if(_PM_MENU_)
  599. PeFillDspBuf();  // Larry070310#4
  600. #endif
  601. switch(gxbUiMenuMainStates)
  602. {
  603. #if(_PM_PLAY_ && UI_PLAY_USER_EQ_EDIT)
  604. case UI_USER_EQ_MENU:
  605. if(gfUserEqStartEdit)
  606. {
  607. if(gxbSelUserDefEq==5)
  608. UiEditUdefEq(UI_EDIT_ALL_EQ_DOWN);
  609. else
  610. UiEditUdefEq(UI_EDIT_EQ_DOWN);
  611. }
  612. else
  613. {
  614. if(gxbUiMenuSubStates==0)
  615. gxbUiMenuSubStates=(cbMenuMaxItemNum[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM]-1);
  616. else
  617. gxbUiMenuSubStates--;
  618. UiDrawUDefEqSel();
  619. }
  620. break;
  621. #endif
  622. /* //remove by tne 2007/01/06 #1
  623. case UI_SLIDE_SHOW:
  624. if(gxbUiMenuSubStates==0)
  625. gxbUiMenuSubStates=(cbMenuMaxItemNum[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM]-1);
  626. else
  627. gxbUiMenuSubStates--;
  628. UiDrawSlideShow();
  629. break;
  630. */
  631. default:
  632. UiShowMenuItem( gxbMenuDispLine,
  633. IM_EXPLORE_BUTTON_CLEAR_STRING,
  634. IM_ITEM_UNSELECT,
  635. pcbMenuListStr[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM][gxbUiMenuSubStates]);
  636. if(gxbUiMenuMainStates==MUSIC_MENU_MAIN_START_NUM)
  637. bI=0;
  638. else
  639. bI=1;
  640. if(gxbUiMenuSubStates==0)
  641. {
  642. gxbUiMenuSubStates=(cbMenuMaxItemNum[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM]-1);
  643. if(cbMenuMaxItemNum[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM]>(ITEM_NUM_OPAGE-bI)) //not only 1 page
  644. {
  645. UiShowMusicMenuText();
  646. break;
  647. }
  648. else
  649. gxbMenuDispLine=(cbMenuMaxItemNum[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM]-1);
  650. }
  651. else
  652. {
  653. gxbUiMenuSubStates--;
  654. if(gxbMenuDispLine==0)
  655. {
  656. UiMoveOneLine( ITEM_SEL_START_COL,
  657. ITEM_START_ROW+ITEM_ROW_OFF*bI,
  658. ITEM_COL_WIDTH,
  659. ITEM_NUM_OPAGE-bI-1,
  660. UI_FILE_LIST_DOWN);
  661. }
  662. else
  663. { gxbMenuDispLine--; }
  664. }
  665. UiShowMenuItem( gxbMenuDispLine,
  666. IM_EXPLORE_BUTTON_01,
  667. IM_ITEM_SELECT,
  668. pcbMenuListStr[gxbUiMenuMainStates-MUSIC_MENU_MAIN_START_NUM][gxbUiMenuSubStates]);
  669. }
  670. #if(_PM_MENU_==1)
  671. UiSelectItemControl();
  672. #endif
  673. }
  674. #endif
  675. //tne 2007/01/06 #1
  676. #if(USE_LYRIC_DISPLAY &!(_PM_PLAY_DEL_|_PM_DIR_DEL_|_PM_VIDEO_|_PM_PLAY_PRC_))
  677. extern XBYTE fUiTagHidden;
  678. void UiPlayLyricControl(void)
  679. {
  680. #if(UI_LYRIC_TYPE_CENTER)
  681. if((gxbMusicType&M_LYRICS_FLAG)&&((gxbSysState==S_PE_PLAY)||(gxbSysState==S_PE_PAUSE)))
  682. #else
  683. if(gxbMusicType&M_LYRICS_FLAG) // Lyrics Exist
  684. #endif
  685. #if(_PM_MENU_|_PM_FLIST_|_PM_CLIST_|_PM_SLS_)
  686. {
  687. if( (gxbLrcState==LRC_STS_FORCE_DISP_STR)||(gxbLrcState==LRC_STS_DISP_STR) )
  688. {
  689. //tne 2005/08/11
  690. UiKeepLastLyric();
  691. LcdSetLyricDone();
  692.          }
  693. }
  694. #else
  695. {
  696. //tne 2005/08/11
  697. if( ((gxbLrcState==LRC_STS_FORCE_DISP_STR)||(gxbLrcState==LRC_STS_DISP_STR)) && (fUiTagHidden) )// show menu, skip this lyric
  698. {
  699. UiKeepLastLyric();
  700. LcdSetLyricDone();
  701. }
  702. else if(gxbLrcState==LRC_STS_FORCE_DISP_STR) // scroll lyric speed up
  703. {
  704. if(gxbLcdLyricStatus==LCD_LYRIC_SCROLL_DONE) //tne lcd scroll2
  705. LcdShowLyrics();
  706. else
  707. LcdScrollLyric();
  708. }
  709. }
  710. #endif
  711. }
  712. #endif
  713. /* //Walace060911#1 Remove to UiCommon.c
  714. #if(!(_PM_CLIST_|_PM_VD_MENU_))
  715. WORD UiGetFileNumInDir(struct FILE_INF_DATA xdata *stOldFileInf,struct FILE_INF_DATA xdata *stNewFileInf) large
  716. {
  717. #define dwOldFileDirSec stOldFileInf->dwDirSec[stOldFileInf->bPathDepth]
  718. #define dwNewFileDirSec stNewFileInf->dwDirSec[stNewFileInf->bPathDepth]
  719. #define wOldFileDirOffset stOldFileInf->wDirOffset[stOldFileInf->bPathDepth]
  720. #define wNewFileDirOffset stNewFileInf->wDirOffset[stNewFileInf->bPathDepth]
  721. WORD wFileNum;
  722. if(!FsOpenFile(FIRST_PLAYBACK_IN_DIR))
  723. { return 0; }
  724. wFileNum=1;
  725. //while(stUiFileListData.dwFileStartClu!=stFsFileInf.dwFileStartClu)
  726. while( (dwOldFileDirSec!=dwNewFileDirSec) || (wOldFileDirOffset!=wNewFileDirOffset) )
  727. {
  728. if(FsOpenFile(NEXT_PLAYBACK_IN_DIR))
  729. wFileNum++;
  730. else
  731. return 0; //not found file.. bug??
  732. }
  733. return wFileNum;
  734. #undef dwOldFileDirSec
  735. #undef dwNewFileDirSec
  736. #undef wOldFileDirOffset
  737. #undef wNewFileDirOffset
  738. }
  739. //jump playback file from stOldFileInf->stNewFileInf
  740. //Please set gxbFileNumSearchMode before calling the function
  741. //After calling the function, stOldFileInf would equal stNewFileInf
  742. //and one of the struct must be stUiFileListData (In UiGetFileListNum function)
  743. void UiCountCurtFileNum(struct FILE_INF_DATA xdata *stOldFileInf,struct FILE_INF_DATA xdata *stNewFileInf) large
  744. {
  745. BOOL fRet;//,fTheSameDir; // Walace051026 #3
  746. #if(!_PM_PLAY_DEL_) //It always speed up in play-del-module
  747. //SetSysSpeed(0x02);
  748. #endif
  749. gpstFileIndex=stOldFileInf;
  750.         // Walace051026 #3
  751. //fTheSameDir=(stOldFileInf->dwDirStartSec==stNewFileInf->dwDirStartSec);
  752. if(gxbFileNumSearchMode==FNUM_SEARCH_RESET_MODE)
  753. {
  754. FsOpenFile(FIRST_PLAYBACK);
  755. gxwCurtFileInAll=1;
  756. gxwCurtFileInDir=1;
  757. }
  758. while(1)
  759. {
  760. if(stOldFileInf->dwDirStartSec==stNewFileInf->dwDirStartSec) //the same dir
  761. {
  762. //if(stOldFileInf->dwFileStartClu==stNewFileInf->dwFileStartClu) //the same file
  763. if( (stOldFileInf->dwDirSec[stOldFileInf->bPathDepth]==stNewFileInf->dwDirSec[stNewFileInf->bPathDepth]) &&
  764. (stOldFileInf->wDirOffset[stOldFileInf->bPathDepth]==stNewFileInf->wDirOffset[stNewFileInf->bPathDepth]) )
  765. break;
  766. //if((gxbFileNumSearchMode==FNUM_SEARCH_RESET_MODE) || (gxbFileNumSearchMode==FNUM_SEARCH_NEXT_MODE))
  767. if(gxbFileNumSearchMode<=FNUM_SEARCH_NEXT_MODE)
  768. gxwCurtFileInDir++;
  769. else
  770. gxwCurtFileInDir--;
  771. }
  772. //if((gxbFileNumSearchMode==FNUM_SEARCH_RESET_MODE) || (gxbFileNumSearchMode==FNUM_SEARCH_NEXT_MODE))
  773. if(gxbFileNumSearchMode<=FNUM_SEARCH_NEXT_MODE)
  774. {
  775. fRet=FsOpenFile(NEXT_PLAYBACK);
  776. gxwCurtFileInAll++;
  777. }
  778. else
  779. {
  780. fRet=FsOpenFile(PREV_PLAYBACK);
  781. gxwCurtFileInAll--;
  782. }
  783. if(!fRet) //if faile, it is a bug??
  784. { break; }
  785. }
  786.         // Walace051026 #3
  787. //if(!fTheSameDir) //not the same dir, re-count file num in dir
  788. {
  789. UiGetFileListNum();
  790. gxwCurtFileInDir=UiGetFileNumInDir(stOldFileInf,stNewFileInf);
  791. FsOpenFile(RELOAD_FILE_NAME);
  792. }
  793. gxwFileNumInFileList=gxwTotalDirInDir+gxwCurtFileInDir;
  794. if(gfPlayAutoSearchFile)
  795. {
  796. gxwCurrentFileNum=gxwCurtFileInAll;
  797. gxwNumTotalFiles=gxwTotalFileInAll;
  798.                 // Walace051026 #3
  799. }
  800. else
  801. {
  802. gxwCurrentFileNum=gxwCurtFileInDir;
  803. gxwNumTotalFiles=gxwTotalFileInDir;
  804. }
  805. #if(!_PM_PLAY_DEL_)
  806. //SetSysSpeed(0x08);
  807. #endif
  808. }
  809. #endif
  810. */
  811. //tne 2005/08/10
  812. //You should let stUiFileListData==stFsFileInf and load ext code before calling this function
  813. #if(_PM_PLAY_PRC_&UI_DISP_DIR_NAME)
  814. void UiGetCurtDirName(void) large
  815. {
  816. BYTE bI;
  817. gpstFileIndex=&stUiFileListData;
  818. if(gpstFileIndex->bPathDepth>0)
  819. {
  820. FsChangeDir(RESTORE_DIR);
  821. FsOpenFile(RELOAD_DIR_NAME); //Load dir name
  822. if(gxbLongFileName[1]==0) //only short file name
  823. {
  824. gxbDispDirNameBuf[0]=STRING_TYPE_ASCII;
  825. gxbDispDirNameBuf[1]=11; //tne 2006/05/05 #1
  826. for(bI=0;bI<11;bI++)
  827. gxbDispDirNameBuf[bI+2]=gxbFileName[bI];
  828. }
  829. else
  830. {
  831. for(bI=0;bI<16;bI++)
  832. gxbDispDirNameBuf[bI]=gxbLongFileName[bI];
  833. if(gxbDispDirNameBuf[1]>14)
  834. gxbDispDirNameBuf[1]=14;
  835. }
  836. stUiFileListData=stFsFileInf;
  837. FsOpenFile(RELOAD_FILE_NAME);
  838. }
  839. else //root
  840. { gxbDispDirNameBuf[1]=0; } //set 0 for display root
  841. }
  842. #endif
  843. //tne 2005/08/11
  844. #if((_PM_SLS_|(_PM_PLAY_&!_PM_PLAY_PRC_))&USE_LYRIC_DISPLAY)
  845. void UiKeepLastLyric(void) large
  846. {
  847. BYTE bI;
  848. if(gxbLrcString[1]>OLED_MAX_SEGS)
  849. {
  850. if(gxbLrcString[1]>=gcbLryicStrLen)
  851. {
  852. if(!LcdChkCjkCutWord(gxbLrcString+2,gcbLryicStrLen))
  853. gxbLrcString[gcbLryicStrLen+1]=' ';
  854. }
  855. gxbLastLyrcBuf[1]=OLED_MAX_SEGS;
  856. for(bI=2;bI<OLED_MAX_SEGS+2;bI++)
  857. gxbLastLyrcBuf[bI]=gxbLrcString[bI+(gxbLrcString[1]-OLED_MAX_SEGS)];
  858. //tne 2006/02/24
  859. if(!LcdChkCjkCutWord(gxbLrcString+2,gxbLrcString[1]-OLED_MAX_SEGS))
  860. gxbLastLyrcBuf[2]=' ';
  861. }
  862. else
  863. {
  864. for(bI=1;bI<=(gxbLrcString[1]+1);bI++)
  865. gxbLastLyrcBuf[bI]=gxbLrcString[bI];
  866. }
  867. }
  868. #endif
  869. #if((_PM_PLAY_&!_PM_PLAY_PRC_)|_PM_SLS_)
  870. void UiPlayGetResumeTime(void) large
  871. {
  872. //tne 2005/08/19
  873. if((gxbSysState!=S_PE_STOP) && (gxbSysState!=S_PE_WAIT) )
  874. { //vicky070319#3
  875. if(gxbMusicProcState==MUSIC_PROC_BODY)
  876. {
  877. gxdwLastFileSec = gdwFileSector - (PeReptAdjust()>>8); //Vicky051128#2
  878. gxdwLastFileSize = gpstFileIndex->dwFileTotalSector;
  879. IdmaPioDmxR(DSP_FRAME_ADDR,&gxdwLastFrameNum,2,DSP_W16); //Get frame number
  880. }
  881. }
  882. }
  883. #endif
  884. // Walace050927 for bug00055
  885. #if((_PM_PLAY_|_PM_SLS_)&(FADE_IN_OUT_MODE==0))
  886. void UiSetVolFadeOut(void) large
  887. {     
  888. CdcSetPaGain(FADEOUT_VOL); // Walace051005 //tne 2006/12/26 #1
  889.        if(gxbLastErrCode==ERR_NO_ERROR) // no scroll if error happend
  890.        {
  891. while(gdwFileSector<=(gpstFileIndex->dwFileTotalSector))
  892. {
  893. PlayEngine(P_NOP);    
  894. UiDispCtrl(UI_SCROLL_DISPLAY); // Scrolling
  895. #if(!EXT_ADC | !EXT_DAC | !EXT_PA)
  896. if(gxbTargetVolume==gxbLastVolume)
  897. return;
  898. else
  899. //IntCdcSetPaGainTask(FALSE);
  900. CdcSetPaGainTask(PA_TASK_UNIMMEDIATE|PA_TASK_DELAY);  //Walace060525#4 //tne 2006/12/26 #1
  901. #endif
  902. }
  903.        }
  904. }
  905. #endif
  906. //vicky050528
  907. #if(_PM_PLAY_MAIN_) //Walace060210
  908. #if(!USE_NEW_FF_PLAY) //vicky061001#1
  909. BYTE CalFramNum(void) large //vicky050602#3 Stereo DEC
  910. {
  911. XBYTE bval;
  912. //Vicky051028#3
  913. //bval=(WORD)10 *512*2/(gxwPacketSize*2);
  914. bval=5120/gxwPacketSize;
  915. if(!(gxbMusicFeature&MF_STEREO))  //Vicky051028#3
  916. bval>>=1;
  917. /*
  918. switch(gxwSampleRate)
  919. {
  920. case 8000:
  921. bval=4;
  922. break;
  923. case 11025:
  924. bval=5;
  925. break;
  926. case 16000:
  927. bval=8;
  928. break;
  929. case 22050:
  930. bval=11;
  931. break;
  932. case 32000:
  933. bval=16;
  934. break;
  935. case 44100:
  936. bval=22;
  937. break;
  938. default:
  939. bval=5;
  940. break;
  941. }
  942. if(gfStereo)
  943. bval<<=1;
  944. */
  945. return bval;
  946. }
  947. #endif //End
  948. #endif
  949. #if(_PM_PLAY_PRC_&!_PM_DVR_& UI_USE_CLASS_LIST)
  950. void UiCdbSearchData(BYTE bSearchType) large
  951. {
  952. BYTE bI,bJ,bCommand;
  953. WORD wTotalMusicInClass;
  954. wTotalMusicInClass=gxwTotalFileInClass;
  955. if(gxbPlayClassMode!=P_CLASS_MODE_TITLE)
  956. {
  957. if( (bSearchType==CDB_SEARCH_FIRST_TITLE) || (bSearchType==CDB_SEARCH_LAST_TITLE) )
  958. {
  959. if(bSearchType==CDB_SEARCH_FIRST_TITLE)
  960. bCommand=CDB_SEARCH_ENTER;
  961. else //if(bSearchType==CDB_SEARCH_LAST_TITLE)
  962. bCommand=CDB_SEARCH_ENTER_LAST;
  963. if( (!gfPlayAutoSearchFile) || (gxbPlayClassMode==P_CLASS_MODE_ALBUM) )
  964. { bJ=1; } //Dir repeat or Album First would jump 1 level in database
  965. else
  966. {
  967. if(gxbPlayClassMode==P_CLASS_MODE_GENRE)
  968. bJ=3; //Genre First would jump 3 level in database
  969. else //gxbPlayClassMode==P_CLASS_MODE_ARTIST
  970. bJ=2; //Artist First would jump 2 level in database
  971. }
  972. for(bI=0;bI<bJ;bI++)
  973. CdbSearchData(CDB_SEARCH_BACK);
  974. for(bI=0;bI<bJ;bI++)
  975. {
  976. wTotalMusicInClass=stCdbClassInfo_wTotalChild;
  977. CdbSearchData(bCommand);
  978. }
  979. goto FINISH_SEARCH;
  980. }
  981. else if( (gfPlayAutoSearchFile) && (gxbPlayClassMode!=P_CLASS_MODE_ALBUM) )
  982. {
  983. #define dwCdbWhichPoint (*(DWORD *)((&*(DWORD *)(&stCdbClassInfo)) + ((bSearchType&CDB_SEARCH_WAY)>>4)))
  984. //if( (bSearchType==CDB_SEARCH_NEXT) && (stCdbClassInfo.dwNextPoint==CDB_NULL_POINT) ) ||
  985. //   (bSearchType==CDB_SEARCH_PREV) && (stCdbClassInfo.dwPrePoint==CDB_NULL_POINT) )
  986. if(dwCdbWhichPoint==CDB_NULL_POINT)
  987. {
  988. if(bSearchType==CDB_SEARCH_NEXT)
  989. bCommand=CDB_SEARCH_ENTER;
  990. else //if(bSearchType==CDB_SEARCH_PREV)
  991. bCommand=CDB_SEARCH_ENTER_LAST;
  992. CdbSearchData(CDB_SEARCH_BACK); //Album level
  993. if(dwCdbWhichPoint==CDB_NULL_POINT) //&&(gxbPlayClassMode==P_CLASS_MODE_GENRE)
  994. {
  995. CdbSearchData(CDB_SEARCH_BACK); //Artist level
  996. //Higher level UI should control here, not send Next command if no file
  997. CdbSearchData(bSearchType); //Next or Prive Artist
  998. CdbSearchData(bCommand); //Album Level
  999. }
  1000. else
  1001. { CdbSearchData(bSearchType); } //Next or Priv Album
  1002. wTotalMusicInClass=stCdbClassInfo_wTotalChild;
  1003. CdbSearchData(bCommand); //Title Level
  1004. goto FINISH_SEARCH;
  1005. }
  1006. #undef dwCdbWhichPoint
  1007. }
  1008. }
  1009. //P_CLASS_MODE_TITLE or Next, Prev normal search
  1010. CdbSearchData(bSearchType);
  1011. FINISH_SEARCH:
  1012. //Count File Number
  1013. gxwTotalFileInClass=wTotalMusicInClass;
  1014. switch(bSearchType)
  1015. {
  1016. case CDB_SEARCH_FIRST_TITLE:
  1017. if(gfPlayAutoSearchFile)
  1018. gxwCurtFileInAllClass=1;
  1019. else
  1020. gxwCurtFileInAllClass=gxwCurtFileInAllClass-gxwCurtFileInClass+1;
  1021. gxwCurtFileInClass=1;
  1022. break;
  1023. case CDB_SEARCH_LAST_TITLE:
  1024. if(gfPlayAutoSearchFile)
  1025. gxwCurtFileInAllClass=gxwTotalFileInAllClass;
  1026. else
  1027. gxwCurtFileInAllClass=gxwCurtFileInAllClass+gxwTotalFileInClass-gxwCurtFileInClass;
  1028. gxwCurtFileInClass=gxwTotalFileInClass;
  1029. break;
  1030. case CDB_SEARCH_NEXT:
  1031. if(stCdbClassInfo.dwPrePoint==CDB_NULL_POINT) //change album in autosearch mode
  1032. gxwCurtFileInClass=1;
  1033. else
  1034. gxwCurtFileInClass++;
  1035. gxwCurtFileInAllClass++;
  1036. break;
  1037. case CDB_SEARCH_PREV:
  1038. if(stCdbClassInfo.dwNextPoint==CDB_NULL_POINT) //change album in autosearch mode
  1039. gxwCurtFileInClass=gxwTotalFileInClass;
  1040. else
  1041. gxwCurtFileInClass--;
  1042. gxwCurtFileInAllClass--;
  1043. break;
  1044. }
  1045. }
  1046. #endif
  1047. #if( (((_PM_PLAY_PRC_|_PM_CLIST_) &!_PM_DVR_)| _PM_PLAY_DEL_ |_PM_DIR_DEL_) & UI_USE_CLASS_LIST )
  1048. void UiCopyCdbSt2FsSt(void) large
  1049. {
  1050. gpstFileIndex->bPathDepth=stCdbClassInfo.bDepth;
  1051. gpstFileIndex->dwDirSec[stCdbClassInfo.bDepth]=stCdbClassInfo.dwDirSec;
  1052. gpstFileIndex->wDirOffset[stCdbClassInfo.bDepth]=stCdbClassInfo.wDirOff;
  1053. gpstFileIndex->dwDirStartSec=stCdbClassInfo.dwDirStartSec;
  1054. }
  1055. #endif
  1056. #if( (((_PM_PLAY_PRC_|_PM_CLIST_) &!_PM_DVR_)| _PM_PLAY_DEL_|_PM_DIR_DEL_) & UI_USE_CLASS_LIST )
  1057. void UiOpenClassFile(void) large
  1058. {
  1059. #if(CDB_OPTION_SAVE_DIR_INFO)
  1060. WORD wDirInfNum;
  1061. PBYTE pbDirInfo;
  1062. #endif
  1063. gpstFileIndex=&stFsFileInf;
  1064. UiCopyCdbSt2FsSt();
  1065. #if(CDB_OPTION_SAVE_DIR_INFO)
  1066. wDirInfNum=stCdbClassInfo.wDirInfoNum;
  1067. while(stFsFileInf.bPathDepth>0)
  1068. {
  1069. stFsFileInf.bPathDepth--;
  1070. #if(_PM_PLAY_DEL_ |_PM_DIR_DEL_)
  1071. NandPrivateEn(); //tne CDB for SD
  1072. #endif
  1073. pbDirInfo=CdbLoadDirInfo(wDirInfNum);
  1074. #if(_PM_PLAY_DEL_ |_PM_DIR_DEL_)
  1075. NandPrivateDis(); //tne CDB for SD
  1076. #endif
  1077. stFsFileInf.dwDirSec[stFsFileInf.bPathDepth]=(*(DWORD *)(pbDirInfo+CDB_DIR_INF_DIR_SEC_ADD));
  1078. stFsFileInf.wDirOffset[stFsFileInf.bPathDepth]=(*(WORD *)(pbDirInfo+CDB_DIR_INF_DIR_OFF_ADD));
  1079. wDirInfNum=(*(WORD *)(pbDirInfo+CDB_DIR_INF_PRE_DIR_INF_ADD));
  1080. }
  1081. stFsFileInf.bPathDepth=stCdbClassInfo.bDepth;
  1082. #endif
  1083. FsOpenFile(RELOAD_FILE_NAME);
  1084. }
  1085. #endif
  1086. #if((_PM_PLAY_PRC_&!_PM_DVR_)|_PM_FLIST_|_PM_CLIST_)
  1087. void UiSetPeStop(void) large
  1088. {
  1089. CdcCtrl(CDC_PLAYBACK_PAUSE);
  1090. gdwFileSector=0;
  1091. gxdwMcuSampleNum=0;
  1092. gxbLrcState=LRC_STS_NONE;
  1093. //gxbSysState=S_PE_WAIT;
  1094. gxdwLastFileSec = 0;
  1095. gxbAbRepeatSts=AB_REPT_RESET;
  1096. gfFirstResume=FALSE; //tne 2005/11/21 #1
  1097. }
  1098. #endif
  1099. //#if( (_PM_FLIST_|_PM_CLIST_) & !_PM_DVR_ & UI_USE_CLASS_LIST)
  1100. #if(0) //tne 2007/01/24 #2
  1101. void UiGoSelectListMenu(void) large
  1102. {
  1103. gxbUiMenuMainStates=UI_SEL_LIST_MENU;
  1104. // WHH #14 301_070107(start)
  1105. UiShowLargeBackground(5,IM_BROWSER_BG_S1); //tne 2007/01/10 #2
  1106. StrShowSysString(SYS_STR_ITEM_START_SEL_LIST,UI_FILST_SELECT_TITLE_COL_START,UI_FILST_SELECT_TITLE_ROW_START);
  1107. if(gxbModuleState==MODULE_PLAY_CLIST)
  1108. {
  1109. OledShowIconNew(1,IM_MAINMENU_BUTTON_01 ,0,UI_FILST_SELECT_ROW_START+UI_FILST_SELECT_ROW_DIFF);
  1110. OledShowIconNew(1, IM_EXPLORE_ICON_02_GROUP_SELECT,UI_FILST_SELECT_COL_START,UI_FILST_SELECT_ROW_START+1+UI_FILST_SELECT_ROW_DIFF);
  1111. OledShowIconNew(1,IM_EXPLORE_ICON_02_FILE,UI_FILST_SELECT_COL_START,UI_FILST_SELECT_ROW_START+1);
  1112. }
  1113. else  if(gxbModuleState==MODULE_PLAY_FLIST)
  1114. {
  1115. OledShowIconNew(1,IM_MAINMENU_BUTTON_01 ,0,UI_FILST_SELECT_ROW_START);
  1116. OledShowIconNew(1, IM_EXPLORE_ICON_02_GROUP,UI_FILST_SELECT_COL_START,UI_FILST_SELECT_ROW_START+1+UI_FILST_SELECT_ROW_DIFF);
  1117. OledShowIconNew(1,IM_EXPLORE_ICON_02_FILE_SELECT,UI_FILST_SELECT_COL_START,UI_FILST_SELECT_ROW_START+1);
  1118. }
  1119. gfTransparent=TRUE;
  1120. StrShowSysString(SYS_STR_SEL_FILE_BROWSE,UI_FILST_SELECT_COL_START+18,UI_FILST_SELECT_ROW_START+1);
  1121. StrShowSysString(SYS_STR_SEL_CLASSIFICATION,UI_FILST_SELECT_COL_START+18,UI_FILST_SELECT_ROW_START+1+UI_FILST_SELECT_ROW_DIFF);
  1122. gfTransparent=FALSE;
  1123. // WHH #14 301_070107(end)
  1124. /*OLED_CLEAR_ALL();
  1125. OledShowIcon(ICON_LAB_CLASS,WORD0,LINE0);
  1126. OledShowIcon(ICON_FBS_MODEL_FILE,WORD0,LINE1);
  1127. OledShowIcon(ICON_FBS_MODEL_CLASS,WORD0,LINE2);
  1128. StrShowSysString(SYS_STR_ITEM_START_SEL_LIST,WORD1,LINE0);
  1129. StrShowSysString(SYS_STR_SEL_FILE_BROWSE,WORD1,LINE1); //tne 2005/12/29 #6
  1130. StrShowSysString(SYS_STR_SEL_CLASSIFICATION,WORD1,LINE2); //tne 2005/12/29 #6
  1131. OledReverse(WORD0,LINE2PIXEL(gxbUiMenuSubStates+1),OLED_MAX_COL,LINE1);*/
  1132. }
  1133. void UiDispSelectListMenu(void) large
  1134. {
  1135. // WHH #14 301_070107(start)
  1136. OledShowIconNew(1,IM_EXPLORE_BUTTON_CLEAR_ALL ,0,UI_FILST_SELECT_ROW_START+gxbUiMenuSubStates*UI_FILST_SELECT_ROW_DIFF);
  1137. gfTransparent=TRUE;
  1138. if(gxbUiMenuSubStates)
  1139. {
  1140. OledShowIconNew(1, IM_EXPLORE_ICON_02_GROUP,UI_FILST_SELECT_COL_START,UI_FILST_SELECT_ROW_START+1+UI_FILST_SELECT_ROW_DIFF);
  1141. StrShowSysString(SYS_STR_SEL_CLASSIFICATION,UI_FILST_SELECT_COL_START+20,UI_FILST_SELECT_ROW_START+1+UI_FILST_SELECT_ROW_DIFF);
  1142. }
  1143. else
  1144. {
  1145. OledShowIconNew(1,IM_EXPLORE_ICON_02_FILE,UI_FILST_SELECT_COL_START,UI_FILST_SELECT_ROW_START+1);
  1146. StrShowSysString(SYS_STR_SEL_FILE_BROWSE,UI_FILST_SELECT_COL_START+20,UI_FILST_SELECT_ROW_START+1);
  1147. }
  1148. gxbUiMenuSubStates ^= 0x01;
  1149. OledShowIconNew(1,IM_MAINMENU_BUTTON_01 ,0,UI_FILST_SELECT_ROW_START+gxbUiMenuSubStates*UI_FILST_SELECT_ROW_DIFF);
  1150. if(gxbUiMenuSubStates)
  1151. {
  1152. OledShowIconNew(1,IM_EXPLORE_ICON_02_GROUP_SELECT,UI_FILST_SELECT_COL_START,UI_FILST_SELECT_ROW_START+1+UI_FILST_SELECT_ROW_DIFF);
  1153. StrShowSysString(SYS_STR_SEL_CLASSIFICATION,UI_FILST_SELECT_COL_START+20,UI_FILST_SELECT_ROW_START+1+UI_FILST_SELECT_ROW_DIFF);
  1154. }
  1155. else
  1156. {
  1157. OledShowIconNew(1,IM_EXPLORE_ICON_02_FILE_SELECT,UI_FILST_SELECT_COL_START,UI_FILST_SELECT_ROW_START+1);
  1158. StrShowSysString(SYS_STR_SEL_FILE_BROWSE,UI_FILST_SELECT_COL_START+20,UI_FILST_SELECT_ROW_START+1);
  1159. }
  1160. gfTransparent=FALSE;
  1161. // WHH #14 301_070107(end)
  1162. //LcdReverse(2,0,4,MAX_COLNUM+1);
  1163. /*
  1164. gxbUiMenuSubStates ^= 0x01;
  1165. OledReverse(WORD0,LINE1,OLED_MAX_COL,LINE1); //Walace051229#1
  1166. OledReverse(WORD0,LINE2,OLED_MAX_COL,LINE1);*/
  1167. }
  1168. #endif
  1169. #if(_PM_PLAY_PRC_& !_PM_DVR_& UI_USE_CLASS_LIST)
  1170. void UiStartPlayClassFile(void) large
  1171. {
  1172. UiOpenClassFile();
  1173. stUiFileListData=stFsFileInf;
  1174. UiSetPeStop();
  1175. //PeStart();
  1176. }
  1177. #endif
  1178. #if(_PM_PLAY_PRC_)
  1179. BYTE UiSelectRandMusic(BYTE bPeCommand) large
  1180. {
  1181. WORD wRndNum,wI;
  1182. if(bPeCommand==P_NEXT)
  1183. { wRndNum=UiGetRndPlayNum(UI_RND_PLAY_NEXT); }
  1184. else
  1185. { wRndNum=UiGetRndPlayNum(UI_RND_PLAY_PREV); }
  1186. if(wRndNum>=gxwCurrentFileNum)
  1187. gxbFileNumSearchMode=FNUM_SEARCH_NEXT_MODE;
  1188. else
  1189. gxbFileNumSearchMode=FNUM_SEARCH_PREV_MODE;
  1190. gpstFileIndex=&stFsFileInf;
  1191. #if(!_PM_DVR_&UI_USE_CLASS_LIST)
  1192. if(gxbPlayClassMode==P_CLASS_MODE_FILE)
  1193. #endif
  1194. {
  1195. PlayEngine(P_RND_FIRST);
  1196. for(wI=1;wI<wRndNum;wI++)
  1197. PlayEngine(P_RND_NEXT);
  1198. bPeCommand=P_RND_START;
  1199. }
  1200. #if(!_PM_DVR_&UI_USE_CLASS_LIST)
  1201. else
  1202. {
  1203. UiCdbSearchData(CDB_SEARCH_FIRST_TITLE);
  1204. for(wI=1;wI<wRndNum;wI++)
  1205. UiCdbSearchData(CDB_SEARCH_NEXT);
  1206. gxwCurrentFileNum=wRndNum;
  1207. UiStartPlayClassFile();
  1208. bPeCommand=P_RESTART;
  1209. }
  1210. #endif
  1211. gfChangeMusic=TRUE;
  1212. return bPeCommand;
  1213. }
  1214. #endif
  1215. #if(_PM_PLAY_PRC_)
  1216. BYTE UiSelectNextMusic(BYTE bPeCommand) large
  1217. {
  1218. #if(!_PM_DVR_&UI_USE_CLASS_LIST)
  1219. if(gxbPlayClassMode==P_CLASS_MODE_FILE)
  1220. #endif
  1221. {
  1222. if(bPeCommand==P_NEXT)
  1223. {
  1224. if(gxwCurrentFileNum>=gxwNumTotalFiles)
  1225. bPeCommand=P_FIRST;
  1226. }
  1227. else //if(bPeCommand==P_PREV)
  1228. {
  1229. if(gxwCurrentFileNum==1)
  1230. bPeCommand=P_LAST;
  1231. }
  1232. }
  1233. #if(!_PM_DVR_&UI_USE_CLASS_LIST)
  1234. else
  1235. {
  1236. if(bPeCommand==P_NEXT)
  1237. {
  1238. if(gxwCurrentFileNum>=gxwNumTotalFiles)
  1239. {
  1240. UiCdbSearchData(CDB_SEARCH_FIRST_TITLE);
  1241. gxwCurrentFileNum=1;
  1242. }
  1243. else
  1244. {
  1245. UiCdbSearchData(CDB_SEARCH_NEXT);
  1246. gxwCurrentFileNum++;
  1247. }
  1248. }
  1249. else //if(bPeCommand==P_PREV)
  1250. {
  1251. if(gxwCurrentFileNum==1)
  1252. {
  1253. UiCdbSearchData(CDB_SEARCH_LAST_TITLE);
  1254. gxwCurrentFileNum=gxwNumTotalFiles;
  1255. }
  1256. else
  1257. {
  1258. UiCdbSearchData(CDB_SEARCH_PREV);
  1259. gxwCurrentFileNum--;
  1260. }
  1261. }
  1262. UiStartPlayClassFile();
  1263. bPeCommand=P_RESTART;
  1264. gfChangeMusic=TRUE;
  1265. }
  1266. #endif
  1267. return bPeCommand;
  1268. }
  1269. #endif
  1270. //tne dir del
  1271. #if( (_PM_DIR_DEL_|_PM_PLAY_DEL_) & (UI_USE_CLASS_LIST) )
  1272. //if(gxbPlayClassMode!=P_CLASS_MODE_FILE)
  1273. void UiCountClassAfterDel(PWORD pwTotalFileInClass, PWORD pwCurtFileInClass, PWORD pwCurtFileInAllClass) large
  1274. {
  1275. DWORD dwOldCdbAddPoint;
  1276. dwOldCdbAddPoint=gdwCdbAddPoint;
  1277. #if(_PM_PLAY_DEL_)
  1278. gxwTotalFileInAll--;
  1279. #endif
  1280. if(gxbModuleState==MODULE_PLAY_CLIST) //Walace060607#1 PlayProcess
  1281. gdwCdbAddPoint=gdwOldDelCdbAddPoint;
  1282. CdbGetClassHeader(gdwCdbAddPoint);
  1283. *pwCurtFileInClass=stCdbClassInfo.wItemNum;
  1284. *pwCurtFileInAllClass=stCdbClassInfo.wItemNum;
  1285. if(gxbPlayClassMode==P_CLASS_MODE_TITLE)
  1286. {
  1287. gxwTotalFileInAllClass=CdbGetDataBaseHeader(CDB_HEADER_TITLE_NUM_ADD);
  1288. *pwTotalFileInClass=gxwTotalFileInAllClass;
  1289. }
  1290. else
  1291. {
  1292. CdbSearchData(CDB_SEARCH_BACK);
  1293. *pwTotalFileInClass=stCdbClassInfo_wTotalMusic;
  1294. switch(gxbPlayClassMode)
  1295. {
  1296. case P_CLASS_MODE_ALBUM:
  1297. gxwTotalFileInAllClass=stCdbClassInfo_wTotalMusic;
  1298. break;
  1299. case P_CLASS_MODE_GENRE:
  1300. while(stCdbClassInfo.dwPrePoint!=CDB_NULL_POINT)
  1301. {
  1302. CdbSearchData(CDB_SEARCH_PREV);
  1303. *pwCurtFileInAllClass += stCdbClassInfo_wTotalMusic;
  1304. }
  1305. CdbSearchData(CDB_SEARCH_BACK);
  1306. case P_CLASS_MODE_ARTIST:
  1307. while(stCdbClassInfo.dwPrePoint!=CDB_NULL_POINT)
  1308. {
  1309. CdbSearchData(CDB_SEARCH_PREV);
  1310. *pwCurtFileInAllClass += stCdbClassInfo_wTotalMusic;
  1311. }
  1312. CdbSearchData(CDB_SEARCH_BACK);
  1313. gxwTotalFileInAllClass=stCdbClassInfo_wTotalMusic;
  1314. break;
  1315. }
  1316. }
  1317. gdwCdbAddPoint=dwOldCdbAddPoint;
  1318. CdbGetClassHeader(gdwCdbAddPoint);
  1319. }
  1320. #endif
  1321. #if( (_PM_DIR_DEL_|_PM_PLAY_DEL_) & (UI_USE_CLASS_LIST) )
  1322. //if(gxbPlayClassMode==P_CLASS_MODE_FILE)
  1323. void UiCountFileAfterDelClass(void) large
  1324. {
  1325. WORD wOldTotalFileInClass,wOldCirtFileInClass;
  1326. #if(_PM_PLAY_DEL_)
  1327. gxwTotalFileInAll--;
  1328. #endif
  1329. wOldTotalFileInClass=gxwTotalFileInClass; //gxwTotalFileInDir
  1330. wOldCirtFileInClass=gxwCurtFileInClass; //gxwCurtFileInDir
  1331. //point to an impossible sector,UiCountCurtFileNum will detect "Different dir"
  1332. //let UiCountCurtFileNum to force getting file number
  1333. //it's safe because we set gxbFileNumSearchMode=FNUM_SEARCH_RESET_MODE
  1334. stUiFileListData.dwDirStartSec=0;
  1335. gxbFileNumSearchMode=FNUM_SEARCH_RESET_MODE;
  1336. UiCountCurtFileNum(&stUiFileListData,&stFsFileInf);
  1337. gxwOldDelTotalFileInClass=gxwTotalFileInDir; //gxwTotalFileInClass
  1338. gxwOldDelCurtFileInClass=gxwCurtFileInDir; //gxwCurtFileInClass
  1339. gxwTotalFileInClass=wOldTotalFileInClass;
  1340. gxwCurtFileInClass=wOldCirtFileInClass;
  1341. }
  1342. #endif
  1343. //David051130#4 start
  1344. #if(_PM_PLAY_|_PM_SLS_)
  1345. /*--------------------------------------------------------------------------
  1346. Description:
  1347. Let DSP process fade out,  wait it finish or not
  1348. Arguments:
  1349. wDspFadeCmd
  1350. the command that send to dsp (check const.c "Dsp Fade in/out command" for details)
  1351. fWait
  1352. TRUE:  wait until dsp finish
  1353. FALSE:  no waiting
  1354. Global arguments:
  1355. None
  1356. Returns: 
  1357. None
  1358. --------------------------------------------------------------------------*/
  1359. //Vicky060112#2 Updated
  1360. void UiDspFade(WORD wDspFadeCmd,BOOL fWait) //Walace061228#CodeSize
  1361. {
  1362. WORD wTimeOut,wDspVal;
  1363. //Vicky060112#2
  1364. BYTE bClkDiv;
  1365. bClkDiv=obCLKMCUDIVF; 
  1366. //#if(USE_STEP_UP_CONVERTER)
  1367. McuClockDivfAdjust(0x08);// WHH #1 061017
  1368. //#else
  1369. // obCLKMCUDIVF=0x08;
  1370. //#endif 
  1371. //End
  1372. #ifdef FADEIN_LOWRATEMUSIC //Vicky060127#2
  1373. gxbRecOption&=~PLAY_LOWRATE_FADEIN_CHECK; //Vicky060127#2 
  1374. #endif
  1375. //Vicky060127#1
  1376. if(wDspFadeCmd&DSP_FADE_OUT_EN)
  1377. {
  1378. wDspVal=FALSE;
  1379. IdmaPioDmxW(&wDspVal, DSP_MUTE_PA_ADDR, 1, DSP_W16);
  1380. gxbRecOption|=PLAY_CHECK_MUTEPA;
  1381. }
  1382. //End
  1383. if( ((gxbMusicType&M_MAIN_TYPE)==M_WMA_2)
  1384. || ((gxbMusicType&M_MAIN_TYPE)==M_WMA_4)
  1385. || ((gxbMusicType&M_MAIN_TYPE)==M_WMA_6)
  1386. )
  1387. {
  1388. if(fWait)
  1389. {
  1390. if(wDspFadeCmd&DSP_FADE_OUT_EN)
  1391. {
  1392. IdmaPioDmxR(DSP_GAIN_ADDR,&wDspVal,1,DSP_W16);
  1393. while(wDspVal>0)
  1394. {
  1395. if(wDspVal>0x1000)
  1396. wDspVal-=0x1000;
  1397. else
  1398. wDspVal=0;
  1399. IdmaPioDmxW(&wDspVal,DSP_GAIN_ADDR,1,DSP_W16);
  1400. for(wTimeOut=0;wTimeOut<800;wTimeOut++) {}
  1401. }
  1402. //Since Low Rate WMA Decoder does not have  dsp Fade Out Feauter. Smoothly Adjust Digital Gain
  1403. }
  1404. else //Fade In
  1405. {
  1406. wDspVal=0;
  1407. while(wDspVal<FADE_TARGET_DSP_GAIN) //Walace060907#4
  1408. {
  1409. if((wDspVal+=0x1000)>FADE_TARGET_DSP_GAIN )  //Walace060907#4
  1410. wDspVal=FADE_TARGET_DSP_GAIN; //Walace060907#4
  1411. IdmaPioDmxW(&wDspVal,DSP_GAIN_ADDR,1,DSP_W16);
  1412. for(wTimeOut=0;wTimeOut<800;wTimeOut++) {}
  1413. }
  1414. }
  1415. }
  1416. else
  1417. {
  1418. if(wDspFadeCmd&DSP_FADE_OUT_EN)
  1419. wDspVal=0;
  1420. else
  1421. wDspVal=FADE_TARGET_DSP_GAIN;  //Walace060907#4
  1422. IdmaPioDmxW(&wDspVal,DSP_GAIN_ADDR,1,DSP_W16);
  1423. //Vicky060127#2
  1424. #ifdef FADEIN_LOWRATEMUSIC
  1425. if(wDspFadeCmd&DSP_FADE_IN_EN)
  1426. {
  1427. gxbRecOption|=PLAY_LOWRATE_FADEIN_CHECK;
  1428. }
  1429. #endif
  1430. //End
  1431. }
  1432. }
  1433. else
  1434. {
  1435. IdmaPioDmxW(&wDspFadeCmd,DSP_FADE_ADDR,1,DSP_W16);
  1436. if(fWait)
  1437. {
  1438. //wTimeOut=0x8FFF;
  1439. //0xA80=>measured with Scope  [126ms: 48K domain (14.7Mhz)]; [137ms: 44.1k domain (13.6Mhz)]
  1440. wTimeOut=0xA80;   //Vicky060109#4
  1441. while(wTimeOut)
  1442. {
  1443. /*
  1444. if(wDspFadeCmd&DSP_FADE_OUT_EN)
  1445. {
  1446. //#define wDspVal wTimeOut
  1447. IdmaPioDmxR(DSP_FADE_ADDR,&wDspVal,1,DSP_W16);
  1448. if((wDspVal&DSP_FADE_OUT_EN))
  1449. {
  1450. IdmaPioDmxR(DSP_OUT_BUF_EMPTY,&wDspVal,1,DSP_W16);
  1451. if(wDspVal)
  1452. {
  1453. obGPIOADAT&=~0x20; //Vicky Debug Fade Out
  1454. return;
  1455. }
  1456. }
  1457. //#undef wDspVal
  1458. }
  1459. /*/
  1460. /*
  1461. LCD_CTRL_EN();//bk
  1462. LcdShowTitleNum(wTimeOut,2,80,5);//test
  1463. LCD_CTRL_DIS();
  1464. */
  1465. if(UiCheckDspFadeDone())
  1466. {
  1467.  break;
  1468. }  
  1469. wTimeOut--;
  1470. }
  1471. /*
  1472. while(1)
  1473. {
  1474. IdmaPioDmxR(0x1fda,&wDspFadeCmd,1,DSP_W16);
  1475. if(wDspFadeCmd!=0)
  1476. {
  1477. while(1);
  1478. }
  1479. IdmaPioDmxR(DSP_OUT_BUF_EMPTY,&wDspFadeCmd,1,DSP_W16);
  1480. if(wDspFadeCmd)
  1481.   break;
  1482. }
  1483. */
  1484. }
  1485. }
  1486. //#if(USE_STEP_UP_CONVERTER)
  1487. McuClockDivfAdjust(bClkDiv);// WHH #1 061017
  1488. //#else
  1489. //obCLKMCUDIVF=bClkDiv; //Vicky060112#2
  1490. //#endif
  1491. }
  1492. #if(!_PM_PLAY_PRC_)
  1493. /*--------------------------------------------------------------------------
  1494. Description:
  1495. Check Dsp in buffer empty
  1496. Arguments:
  1497. Global arguments:
  1498. None
  1499. Returns: 
  1500. TRUE: In buffer emptty
  1501. FALSE: In buffer not empty
  1502. --------------------------------------------------------------------------*/
  1503. BOOL UiCheckDspInBufEmpty(WORD wNum) large //vicky061028#2
  1504. {
  1505. #if(1)
  1506. XWORD wRemaindata;
  1507. wRemaindata=PeReptAdjust();
  1508. if(wRemaindata<wNum)
  1509. return TRUE;
  1510. else
  1511. return FALSE;
  1512. #else
  1513. XWORD xwDspW,xwDspR;
  1514. IdmaPioDmxR(DSP_IN_W_IDX_ADDR,&xwDspW,1,DSP_W16);
  1515. IdmaPioDmxR(DSP_IN_R_IDX_ADDR,&xwDspR,1,DSP_W16);
  1516. if( ((xwDspW>=xwDspR) && ((xwDspW-xwDspR)<wNum)) ||
  1517. ((xwDspW<xwDspR) && ((1024+xwDspW-xwDspR)<wNum))
  1518.   )
  1519.   return TRUE;
  1520. else 
  1521. return FALSE;
  1522. #endif
  1523. }
  1524. #endif
  1525. /*--------------------------------------------------------------------------
  1526. Description:
  1527. Check Dsp Fading done
  1528. Arguments:
  1529. None
  1530. Global arguments:
  1531. None
  1532. Returns: 
  1533. bFadeDone:  fade in/out done status
  1534. 0: fading
  1535. 1: fade in done
  1536. 2: fade out done
  1537. --------------------------------------------------------------------------*/
  1538. //Vicky060112#2
  1539. BYTE UiCheckDspFadeDone(void) large
  1540. {
  1541. XWORD xwDspVal;
  1542. // XDWORD xdwTemp;
  1543. /*
  1544. LCD_CTRL_EN();
  1545. //IdmaPioDmxR(0x0c4a,&xwDspVal,1,DSP_W16);//bk
  1546. //LcdShowTitleNum(xwDspVal,6,0,5);//test
  1547. //IdmaPioDmxR(0x0c4b,&xwDspVal,1,DSP_W16);
  1548. //LcdShowTitleNum(xwDspVal,6,40,5);//test
  1549. //IdmaPioDmxR(DSP_FADE_ADDR,&xwDspVal,1,DSP_W16);
  1550. //LcdShowTitleNum(xdwTemp,6,0,10);//test
  1551. IdmaPioDmxR(0x1fdb,&xwDspVal,1,DSP_W16);
  1552. LcdShowTitleNum(xwDspVal,6,0,5);//test
  1553. IdmaPioDmxR(0x1fdc,&xwDspVal,1,DSP_W16);
  1554. LcdShowTitleNum(xwDspVal,6,40,5);//test
  1555. IdmaPioDmxR(0x1fdd,&xwDspVal,1,DSP_W16);
  1556. LcdShowTitleNum(xwDspVal,6,80,5);//test
  1557. LCD_CTRL_DIS();
  1558. */
  1559. if( ((gxbMusicType&M_MAIN_TYPE)==M_WMA_2)
  1560. || ((gxbMusicType&M_MAIN_TYPE)==M_WMA_4)
  1561. || ((gxbMusicType&M_MAIN_TYPE)==M_WMA_6)
  1562. )
  1563. {
  1564. IdmaPioDmxR(DSP_GAIN_ADDR,&xwDspVal,1,DSP_W16);
  1565. if(xwDspVal==0)
  1566. return 0x02;
  1567. else if(xwDspVal>=FADE_TARGET_DSP_GAIN);  //Walace060907#4
  1568. return 0x01;
  1569. }
  1570. else
  1571. {
  1572. IdmaPioDmxR(DSP_FADE_ADDR,&xwDspVal,1,DSP_W16);
  1573. return (xwDspVal & DSP_FADE_DONE)>>14;
  1574. }
  1575. }
  1576. //End
  1577. //Vicky051219#2
  1578. //Vicky060109#2
  1579. /*
  1580. BYTE UiSetFadeUnit(void) large
  1581. {
  1582. XBYTE bFadOutUnit;
  1583. switch(gxwSampleRate)
  1584. {
  1585. case 8000:
  1586. bFadOutUnit=16; //;
  1587. if(gxwByteRate<=100)  //equal or less than 8Kbps
  1588. bFadOutUnit=30; //8;
  1589. else if(gxwByteRate<=300) //equal or less than 24Kbps
  1590. bFadOutUnit=24; //6;
  1591. break;
  1592. case 11025:
  1593. case 12000:
  1594. bFadOutUnit=12; // 3;
  1595. if(gxwByteRate<=100)  //equal or less than 8Kbps
  1596. bFadOutUnit=24; // 6;
  1597. else if(gxwByteRate<=300)  //equal or less than 24Kbps)
  1598. bFadOutUnit=16; // 4;
  1599. break;
  1600. default:  bFadOutUnit=3;
  1601. }
  1602. return bFadOutUnit;
  1603. }
  1604. */
  1605. //Vicky060112#2 Updated
  1606. #if(_PM_PLAY_MAIN_|_PM_DVR_MAIN_)
  1607. void UiFWFadeOut(void)   //valid only Set "FADE_IN_OUT_MODE=1" //Walace061228#CodeSize
  1608. {
  1609. #if(!(_PM_PLAY_DEL_|_PM_DIR_DEL_))
  1610. BYTE bVol;
  1611. XWORD wcnt;
  1612. XWORD wDspVal;
  1613. /*
  1614. BYTE bVol;
  1615. for(bVol=gxbVolume; bVol>=1;bVol--)    
  1616. {
  1617. IntCdcSetPaGain(bVol);
  1618. IntCdcSetPaGainTask(TRUE);
  1619. }
  1620. */
  1621. //Vicky060112#2
  1622. BYTE bClkDiv;
  1623. bClkDiv=obCLKMCUDIVF; 
  1624. //#if(USE_STEP_UP_CONVERTER)
  1625. McuClockDivfAdjust(0x08);// WHH #1 061017
  1626. //#else
  1627. // obCLKMCUDIVF=0x08;
  1628. //#endif 
  1629. //End
  1630. wcnt=230; //From Max -> Min : Cost 230->25+5 ms,460->50+5ms
  1631. for(bVol=gxbLastVolume; bVol>FADEOUT_VOL;bVol--)     //Walace060402#2
  1632. {
  1633. IdmaPioDmxR(DSP_OUT_BUF_EMPTY,&wDspVal,1,DSP_W16);
  1634. if(wDspVal)
  1635. {
  1636. //IntCdcSetPaGain(FADEOUT_VOL); //tne 2006/07/03 #1
  1637. gxbTargetVolume=FADEOUT_VOL; //tne 2006/07/03 #1
  1638. CdcSetPaGainTask(PA_TASK_IMMEDIATE|PA_TASK_NO_EQ_ADJ); //tne 2006/07/03 #1 //tne 2006/12/26 #1
  1639. break;
  1640. //IntCdcSetPaGain(bVol); //tne 2006/07/03 #1
  1641. gxbTargetVolume=bVol; //tne 2006/07/03 #1
  1642. for(wDspVal=0;wDspVal<wcnt;wDspVal++) {}
  1643. CdcSetPaGainTask(PA_TASK_IMMEDIATE|PA_TASK_NO_EQ_ADJ); //tne 2006/07/03 #1 //tne 2006/12/26 #1
  1644. }
  1645. #endif
  1646. //#if(USE_STEP_UP_CONVERTER)
  1647. McuClockDivfAdjust(bClkDiv);// WHH #1 061017
  1648. //#else
  1649. // obCLKMCUDIVF=bClkDiv;
  1650. //#endif
  1651. }
  1652. #endif
  1653. //Vicky060109#2 //Vicky060112#2 Updated
  1654. #if(!_PM_PLAY_PRC_)
  1655. BOOL UiGetFadePoint(void)  //Walace061228#CodeSize
  1656. {
  1657. XWORD wDSPval,wSamples;
  1658. if((gxwSampleRate>=44100 )&& ((gxbMusicType&M_MAIN_TYPE)<=M_WMA_6))
  1659. return TRUE;
  1660. IdmaPioDmxR(DSP_OUT_W_IDX_ADDR,&wDSPval,1,DSP_W16); //Get out buffer Write Index
  1661. if(gxwOBWI==wDSPval)
  1662. {
  1663. if(gxbOBWICnt<20) //Vicky60117 Debug POP across file
  1664. {
  1665. gxbOBWICnt++;
  1666. }
  1667. else
  1668. {
  1669. if(gxwSampleRate>22050)
  1670. return TRUE;
  1671. else
  1672. {
  1673. wSamples=gxwSampleRate/1000*50; // gxwSampleRate*90 //Vicky60117 Debug POP across file
  1674. //wSamples=10000; //Vicky60117 Debug POP across file
  1675. if(gxbMusicFeature&MF_STEREO)
  1676. wSamples<<=1;
  1677. IdmaPioDmxR(DSP_OUT_R_IDX_ADDR,&wDSPval,1,DSP_W16);
  1678. if( ( (gxwOBWI>=wDSPval) && ((gxwOBWI-wDSPval)<(wSamples)) ) 
  1679. || ((gxwOBWI<wDSPval) && ((4096+gxwOBWI-wDSPval)<(wSamples)))
  1680. )
  1681. {
  1682. return TRUE;
  1683. }
  1684. }
  1685. }
  1686. }
  1687. else
  1688. {
  1689. gxwOBWI=wDSPval;
  1690. gxbOBWICnt=0;
  1691. }
  1692. return FALSE;
  1693. }
  1694. #endif
  1695. //End
  1696. #endif
  1697. //End
  1698. //tne 2005/11/07
  1699. //check unicode tag (odd string length error)
  1700. #if(_PM_PLAY_PRC_&!_PM_DVR_)
  1701. void UiCheckTag(void) large
  1702. {
  1703. #if(USE_TAG_DISPLAY)
  1704. BYTE bI; //tne 2005/12/24
  1705. /* //Remove by tne 512 tag
  1706. code PBYTE pbTagPoint[]=
  1707. {
  1708. gxbTagTitle,
  1709. gxbTagArtist,
  1710. gxbTagAlbum,
  1711. };
  1712. for(bI=0;bI<3;bI++)
  1713. {
  1714. if( (pbTagPoint[bI][0]==STRING_TYPE_UNICODE) && (pbTagPoint[bI][1]&0x01) )
  1715. {
  1716. pbTagPoint[bI][1]++;
  1717. pbTagPoint[bI][(pbTagPoint[bI][1])+1]=0x00;
  1718. }
  1719. if(pbTagPoint[bI][1]>=254)
  1720. pbTagPoint[bI][1]=252;
  1721. //tne 2005/12/24/// Display nothing if only space in the string
  1722. bJ=2;
  1723. while(1)
  1724. {
  1725. if(pbTagPoint[bI][0]==STRING_TYPE_UNICODE)
  1726. {
  1727. if( (pbTagPoint[bI][bJ]!=0x20) || (pbTagPoint[bI][bJ+1]!=0x00) )
  1728. break;
  1729. bJ += 2;
  1730. }
  1731. else
  1732. {
  1733. if(pbTagPoint[bI][bJ]!=0x20)
  1734. break;
  1735. bJ++;
  1736. }
  1737. if(bJ>=pbTagPoint[bI][1]+2)
  1738. {
  1739. pbTagPoint[bI][1]=0;
  1740. break;
  1741. }
  1742. }
  1743. //////////////////////////////
  1744. }
  1745. */
  1746. //tne 2006/01/15 #1 //tne 512 tag
  1747. for(bI=0;bI<LCD_TAG_TOTAL_NUMBER;bI++)
  1748. {
  1749. if(gxwNameBufLen[bI]!=0)
  1750. return;
  1751. }
  1752. gxbMusicType &= (~M_SUB_TYPE); //Clean Tag Informatin
  1753. /////////////////////
  1754. #endif
  1755. }
  1756. #endif
  1757. //Vicky060223#1
  1758. #if(!(_PM_PLAY_DEL_|_PM_DIR_DEL_|_PM_VIDEO_|_PM_PLAY_PRC_))
  1759. BOOL UiAbReachB(void)  //Walace061228#CodeSize
  1760. {
  1761. XWORD wNum;
  1762. //Vicky060703#1
  1763. BOOL fGet;
  1764. fGet=FALSE;
  1765. //End
  1766. if(gxbPlayVar & AB_WAIT_BFINISH)
  1767. {
  1768. if(gxwUiLastBitRate>128)
  1769. wNum=512;
  1770. else if(gxwUiLastBitRate>=20)
  1771. wNum=256;
  1772. else
  1773. wNum=72;
  1774. if(UiCheckDspInBufEmpty(wNum))
  1775. fGet=TRUE;
  1776. //Vicky060703#1
  1777. IdmaPioDmxR(DSP_DSP_10MS_H_ADDR,&gxdwCurrentLrcTime,2,DSP_W16); //get 0.01 sec
  1778. if( ((gxbMusicType&M_MAIN_TYPE)<=M_WMA_6) &&(gxwByteRate<250) && (gxdwCurrentLrcTime>gxdwSecReptB) )
  1779. fGet=TRUE;
  1780. if(fGet) 
  1781. //End
  1782. {
  1783. #if(FADE_IN_OUT_MODE==1)
  1784. if((UiCheckDspFadeDone()!=0x02) &&(gxbSysState==S_PE_PLAY) ) //if fade out done, won't do it again
  1785. {
  1786. UiDspFade((DSP_FADE_OUT_EN|DSP_FADE_1_UNIT),TRUE);
  1787. }
  1788. #endif
  1789. //Vicky060224#1
  1790. gxbPlayVar&=~AB_WAIT_BFINISH;
  1791. return TRUE;
  1792. /*
  1793. IdmaPioDmxR(DSP_OUT_BUF_EMPTY,&wDspVal,1,DSP_W16);
  1794. if(wDspVal)
  1795. {
  1796. gxbPlayVar&=~AB_WAIT_BFINISH;
  1797. return TRUE;
  1798. }
  1799. */
  1800. }
  1801. }
  1802. else
  1803. {
  1804. if(gdwFileSector>gxdwFileSectorReptB) 
  1805. gxbPlayVar|=AB_WAIT_BFINISH;
  1806. }
  1807. return FALSE;
  1808. }
  1809. #endif
  1810. //End
  1811. #if(_PM_PLAY_PRC_)
  1812. void UiPeStartStartCallBack(void)
  1813. {
  1814. BYTE  bSubModule;
  1815. gxbLastErrCode=ERR_NO_ERROR; //Walace061024#2
  1816. bSubModule = (gxbModuleState&MODULE_SUB);
  1817. switch(gxbModuleState&MODULE_MASTER)
  1818. {
  1819. case MODULE_PLAY:
  1820. case MODULE_PLAY_MENU:
  1821. case MODULE_PLAY_FLIST:
  1822. if(gxbPlayClassMode==P_CLASS_MODE_FILE)
  1823. {
  1824. if(bSubModule==MODULE_FILE_DEL)
  1825. break;
  1826.         gfFillDspBufEn=FALSE;
  1827. UiCountCurtFileNum(&stUiFileListData,&stFsFileInf);
  1828. #if(_PM_DVR_)
  1829. stFsFileInf=stUiFileListData;//tne 2006/06/15
  1830. #endif
  1831. #if(UI_DISP_DIR_NAME)
  1832. UiGetCurtDirName();
  1833. #endif
  1834. }
  1835. break;
  1836. case MODULE_PLAY_CLIST:
  1837. break;
  1838. default:
  1839. break;
  1840. }
  1841. gxbPeDispCmd=UI_PE_START_START;
  1842. }
  1843. #endif
  1844. #if(_PM_PLAY_PRC_)
  1845. void UiPeStartEndCallBack(void)
  1846. {
  1847. WORD wDspVal;
  1848. BYTE  bSubModule;
  1849. bSubModule = (gxbModuleState&MODULE_SUB);
  1850. if(gxbErrCode!=ERR_NO_ERROR) //Walace061024#3
  1851. return ;
  1852. gxbAbRepeatSts=AB_REPT_RESET;
  1853. #if(!_PM_DVR_)
  1854. UiCheckTag();
  1855. #endif
  1856.        IdmaPioDmxW(&gxw3DMode,DSP_3D_ADDR,1,DSP_W16);
  1857.        UiSetEqGain(gxwEqMode);
  1858.   
  1859. switch(gxbModuleState&MODULE_MASTER)
  1860. {
  1861. case MODULE_PLAY:
  1862. break;
  1863. case MODULE_PLAY_MENU:
  1864. wDspVal=gxbUiMenuSubStates;
  1865. switch(gxbUiMenuMainStates)
  1866. {
  1867. case UI_EQ_MENU: //Walace060402#1
  1868. case UI_USER_EQ_MENU:  //Walace060402#1              
  1869.               UiSetEqGain(wDspVal);  //Walace060127#2
  1870. break;
  1871.   
  1872. case UI_3D_MENU:
  1873. //Vicky060303#1
  1874. DetermineDspClock(gxbPlaybackRate, wDspVal);
  1875. IdmaPioDmxW(&wDspVal,DSP_3D_ADDR,1,DSP_W16);
  1876. break;
  1877. //#endif //tne 2006/01/16
  1878. case UI_PLAYBACK_RATE_MENU:
  1879. PeSetPlaybackRate(wDspVal);
  1880. break;
  1881. }
  1882. break;
  1883. case MODULE_PLAY_FLIST:
  1884. if(bSubModule==MODULE_FILE_DEL)
  1885. break;
  1886. gxwFileNumInFileList=gxwCurtFileInDir+gxwTotalDirInDir;
  1887. gxwOldTotalDirInDir=gxwTotalDirInDir;
  1888. gxwOldTotalFileInDir=gxwTotalFileInDir;
  1889. break;
  1890.        case MODULE_PLAY_CLIST:
  1891. if(bSubModule==MODULE_FILE_DEL)
  1892. break;
  1893. //gxwOldCurtFileInClass=gxwCurtFileInClass;
  1894. //gxwOldTotalFileInClass=gxwTotalFileInClass;
  1895. //gdwOldCdbAddPoint=gdwCdbAddPoint;
  1896.    
  1897.     break;
  1898. default:
  1899. break;
  1900. }
  1901. #if(USE_LYRIC_DISPLAY)
  1902. gxbLcdLyricStatus=LCD_LYRIC_SCROLL_DONE; // set done to show first lyric
  1903. gxbLastLyrcBuf[1]=0; //tne 2005/08/11
  1904. #endif
  1905. gxwUiLastBitRate=0; //display zero after change music
  1906. if(!gfFirstResume) //tne 2005/08/19
  1907. {
  1908.         gxwCurrentPlayTime=0; //set 0 for intro mode
  1909.         gxwLastPlayTime=0;         //vicky061113#1
  1910. //gxdwCurrentLrcTime=0; //tne 2006/02/10 #1 //Walace060226#remove
  1911. //Vicky061001#1 start 
  1912. #if(USE_NEW_FF_PLAY)
  1913. if( (gxbFastPlaySts&PLAY_DIRECTION)==PLAY_REW)
  1914. {
  1915. gxwCurrentPlayTime=gxwMusicTotalTime;
  1916. if(gxwCurrentPlayTime>FB_ACROSS_SKIP_TIME)
  1917. gxwCurrentPlayTime-=FB_ACROSS_SKIP_TIME;
  1918. }
  1919. #endif
  1920. //Vicky061001#1 end
  1921. }
  1922. gfFillDspBufEn=TRUE;
  1923. gxbPeDispCmd=UI_PE_START_END;
  1924. }
  1925. #endif
  1926. #if(_PM_PLAY_|_PM_SLS_)
  1927. void UiPeStopCallBack(void)
  1928. {
  1929. gxbLastErrCode=gxbErrCode; //Walace070116#6
  1930. LoadExtendMemCode();  //Walace070109#2
  1931. if(gxbErrCode==ERR_NO_ERROR) //Walace070116#6
  1932. gxbErrCode=gxbLastErrCode;
  1933. UiRndPlayInit();
  1934. gfFillDspBufEn=FALSE;
  1935. if(!gfPwOffStop) 
  1936. gxwCurrentPlayTime=0;
  1937. gxbPeDispCmd=UI_PE_STOP;
  1938. }
  1939. #endif
  1940. #if(!(_PM_PLAY_PRC_|_PM_PLAY_DEL_|_PM_DIR_DEL_|_PM_VIDEO_))
  1941. void UiPePlayUpdateCallBack(void)
  1942. {
  1943. gxbPeDispCmd=UI_PE_PLAY_UPDATE;
  1944. }
  1945. #endif
  1946. //function move here by tne 2006/08/16 #1
  1947. #if(_PM_PLAY_MAIN_ || _PM_DVR_MAIN_)
  1948. void UiShowPlayTime(void)
  1949. {
  1950. #if(UI_DISP_MUSIC_INF)
  1951. BYTE bTimeNum ;
  1952. // WHH #13 301_070105(start)
  1953. bTimeNum=(BYTE)( (gxwCurrentPlayTime%3600)/60); //Show Minutes //vicky060525#1
  1954. OledShowNumber(bTimeNum,91,64,2);
  1955. bTimeNum=(BYTE)(gxwCurrentPlayTime%60); //Show Second
  1956. OledShowNumber(bTimeNum,110,64,2);
  1957. OledShowIconNew(1,IM_MUSIC_SMALLNUMBER_COLON,102,64);
  1958. //bTimeNum=(BYTE)( (gxwCurrentPlayTime%3600)/60); //Show Minutes //vicky060525#1
  1959. //OledShowNumber(bTimeNum,50,PAGE2,2);  //Walace060322#3
  1960. //bTimeNum=(BYTE)(gxwCurrentPlayTime%60); //Show Second
  1961. //OledShowNumber(bTimeNum,66,PAGE2,2);  //Walace060322#3
  1962. // WHH #13 301_070105(start)
  1963. //draw progress bar
  1964. #if(UI_USE_PROGRESS_BAR)  //Walace060525#1 dword to caculate 
  1965. if(gxwMusicTotalTime!=0) //Walace060815#1
  1966. bTimeNum = ((DWORD)gxwCurrentPlayTime*PROGRESS_MAX)/(DWORD)gxwMusicTotalTime ;
  1967. else
  1968. bTimeNum=0;
  1969. // WHH #13 301_070105
  1970.       // ShowProgress(11,25,bTimeNum);       
  1971.        ShowProgress(28,147,bTimeNum); 
  1972. #endif // UI_USE_PROGRESS_BAR
  1973. #endif
  1974. }
  1975. #endif
  1976. //tne 2006/08/16 #1 //end
  1977. //Walace061011 PlayProcess 
  1978. #if(!(_PM_PLAY_PRC_|_PM_PLAY_DEL_|_PM_DIR_DEL_|_PM_VIDEO_))
  1979. void LoadPlayProcess(BYTE bProcessCmd)
  1980. {
  1981. SetSysSpeed(SYS_SPEED_UP_UI);
  1982. gxbPlayProcessCmd=bProcessCmd;
  1983. KeepMemory(KEEP_MEMORY);
  1984. #if(_PM_DVR_)
  1985. LoadProgram(PM_DVR_PRC,NORMAL_CODE);  
  1986. #else
  1987. LoadProgram(PM_PLAY_PRC,NORMAL_CODE);  
  1988. #endif
  1989. }
  1990. #endif
  1991. //vicky061001#1
  1992. #if( (_PM_PLAY_|_PM_DVR_|_PM_SLS_)&&!(_PM_PLAY_DEL_|_PM_DIR_DEL_|_PM_PLAY_PRC_) )
  1993. //vicky061113#2 update start
  1994. void UIAcrossPre(void)  
  1995. {
  1996. //OledShowNumber(31 , 60, LINE3, 2); //V debug only  
  1997. if((gfDspCtrlCdc) &&(gxbSysState==S_PE_PLAY) && (gxbMusicProcState==MUSIC_PROC_BODY )) //Walace060822#4
  1998. {
  1999. //vicky061001#1
  2000. if( ( (gxbDSPDataCnt&DATA_RESTART) &&(gxbDSPDataCnt&DATA_SENT_NUM) )  ||
  2001. ( !(gxbDSPDataCnt&DATA_RESTART)&& ((gxbDSPDataCnt&DATA_SENT_NUM)>=3) /*&&((gdwFileSector<<9) >= (gxdwFirstPackLoc+1536))*/) )
  2002. {
  2003. PlayEngine(P_FF_X2);
  2004. //OledShowNumber(32 , 60, LINE3, 2); //V debug only  
  2005. }
  2006. }
  2007. }
  2008. //vicky061113#2 update  end
  2009. #endif
  2010. //Walace060821#1
  2011. #if((_PM_PLAY_&!_PM_PLAY_PRC_)|_PM_SLS_)
  2012. void UiCheckFadeout()
  2013. {
  2014. #if(FADE_IN_OUT_MODE==0)
  2015. UiSetVolFadeOut();
  2016. #elif(FADE_IN_OUT_MODE==1)
  2017. if((UiCheckDspFadeDone()!=0x02) &&(gxbSysState==S_PE_PLAY) ) //if fade out done, won't do it again
  2018. {
  2019. UiDspFade((DSP_FADE_OUT_EN|DSP_FADE_1_UNIT),TRUE);//Vicky060119
  2020. }
  2021. #endif
  2022. }
  2023. #endif
  2024. //function add by tne 2006/08/16 #1
  2025. #if(!(_PM_PLAY_DEL_|_PM_DIR_DEL_|_PM_VIDEO_|_PM_PLAY_PRC_))
  2026. API BYTE UiNormalChMusicStartJob(BYTE bPeCommand) large
  2027. {
  2028. //Walace060821#1
  2029. //#if(_PM_PLAY_MAIN_ || _PM_DVR_MAIN_)
  2030. // UiShowLastPlayTime(); //tne 2006/07/07 #1
  2031. //#endif
  2032. switch(gxbRepeatMode)
  2033. {
  2034. case NO_REPEAT:
  2035. //
  2036. #if(USE_NEW_FF_PLAY)  //Vicky061001#1
  2037. if( ( ((gxbFastPlaySts&PLAY_DIRECTION)==PLAY_FF) && (gxwCurrentFileNum>=gxwNumTotalFiles) )||
  2038. ( ((gxbFastPlaySts&PLAY_DIRECTION)==PLAY_REW) && (gxwCurrentFileNum<=1) )  )
  2039. {
  2040. bPeCommand=P_STOP;
  2041. break;
  2042. }
  2043. #else
  2044. if(gxwCurrentFileNum>=gxwNumTotalFiles)
  2045. {
  2046. bPeCommand=P_STOP;
  2047. break;
  2048. }
  2049. #endif
  2050. case RND_ALL_REPEAT:
  2051. case ALL_REPEAT:
  2052. bPeCommand=P_NEXT;
  2053. #if(UI_USE_FF_PLAY) //Vicky061001#1
  2054. if((gxbFastPlaySts&PLAY_DIRECTION)==PLAY_REW)
  2055. bPeCommand=P_PREV;
  2056. #endif
  2057. break;
  2058. case SINGLE_REPEAT:
  2059. bPeCommand=P_RESTART;
  2060. //gfChangeMusic=TRUE; //tne 2006/02/15 #1
  2061. break;
  2062. #if(UI_USE_RND_PLAY_ONE_EN)
  2063. case RND_REPEAT:
  2064. gxwRndListIndex++;
  2065. if(gxwRndListIndex>=gxwNumTotalFiles)
  2066. { bPeCommand=P_STOP; }
  2067. else
  2068. {
  2069. bPeCommand=P_NEXT;
  2070. #if(UI_USE_FF_PLAY) //Vicky061001#1
  2071. if((gxbFastPlaySts&PLAY_DIRECTION)==PLAY_REW)
  2072. bPeCommand=P_PREV;
  2073. #endif
  2074. }
  2075. break;
  2076. #endif
  2077. }
  2078. gxbAbRepeatSts=AB_REPT_RESET; // not support AB repeat across two music
  2079. gxdwLastFileSize = 0;
  2080. #if((USE_NEW_FF_PLAY &  !UI_USE_FB_ACROSS) || (UI_USE_FF_PLAY& !USE_NEW_FF_PLAY) ) //Vicky061001#1
  2081. gxbFastPlaySts=PLAY_SPEED_NORMAL;
  2082. #endif
  2083. return bPeCommand;
  2084. }
  2085. #endif
  2086. #if(_PM_PLAY_MAIN_ || _PM_DVR_MAIN_)
  2087. //tne 2006/07/07 #1
  2088. void UiShowLastPlayTime(void) large
  2089. {
  2090. #if(UI_DISP_MUSIC_INF)
  2091. //#define TIME_DEBUG  //vicky060810#2
  2092. #ifdef TIME_DEBUG
  2093. XWORD wtemp; 
  2094. #endif
  2095. if(fUiTagHidden) return;//Walace060821#1
  2096. if(gxbSysState==S_PE_PLAY) 
  2097. {
  2098. gxbLcdCounter=0;
  2099. #ifdef TIME_DEBUG
  2100. while(1)
  2101. #else
  2102. while(gxbLcdCounter<=UI_SHW_LAST_PLAY_DELAY_TIME)
  2103. #endif
  2104. {
  2105. IdmaPioDmxR(DSP_DSP_SEC_ADDR,&gxwCurrentPlayTime,1,DSP_W16);
  2106. UiShowPlayTime();
  2107. #ifdef TIME_DEBUG
  2108. IdmaPioDmxR(DSP_DSP_10MS_H_ADDR,&wtemp,1,DSP_W16);
  2109. OledShowNumber(wtemp, 0, LINE3, 4);
  2110. IdmaPioDmxR(DSP_DSP_10MS_L_ADDR,&wtemp,1,DSP_W16);
  2111. OledShowNumber(wtemp, 40, LINE3, 4);
  2112. IdmaPioDmxR(DSP_FRAME_ADDR,&wtemp,1,DSP_W16);
  2113. OledShowNumber(wtemp, 0, LINE3+8, 4);
  2114. IdmaPioDmxR(DSP_FRAME_ADDR+1,&wtemp,1,DSP_W16);
  2115. OledShowNumber(wtemp, 40, LINE3+8, 4);
  2116. #endif
  2117. }
  2118. }
  2119. #endif
  2120. }
  2121. #endif
  2122. //Vicky070105#3
  2123. #if((_PM_PLAY_&!_PM_PLAY_PRC_)|_PM_SLS_)
  2124. void UiCheckNandRestore(XBYTE bState) 
  2125. {
  2126. //Nick061120 start //NandRestore start //Walace061221#1
  2127. #if(NAND_ECC_DEBUG) 
  2128. if((gxbRestoreBlkNum || (gxwTimeToScanPM > SCAN_PM_DURATION)) && 
  2129. (gfChangeMusic)&&gfMLCMode) //Nick061204
  2130. #else
  2131. if((gxbRestoreBlkNum || (gxwTimeToScanPM > SCAN_PM_DURATION)) && 
  2132. (gfChangeMusic || gxbSysState==S_PE_PAUSE||gxbSysState==S_PE_WAIT)&&gfMLCMode) //Nick061204
  2133. #endif
  2134. {
  2135. //LCD_CTRL_DIS(); //Walace061126#1
  2136. gxbModuleState=bState;
  2137. //Nick061204 start
  2138. if(gxwTimeToScanPM > SCAN_PM_DURATION)
  2139. gxbRestoreCMD |= PM_SCAN;
  2140. else
  2141. gxbRestoreCMD = FullStep;
  2142. //Nick061204 end
  2143. if( !( (bState==MODULE_DVR)||(bState==MODULE_PLAY)))
  2144. KeepMemory(KEEP_MEMORY) ;
  2145. LoadProgram(PM_PLAY_DATA_RTN_RESTORE, BASIC_CODE_ONLY);
  2146. //Nick061120 end //NandRestore end
  2147. }
  2148. #endif
  2149. //
  2150. //vicky070424#1 start
  2151. #if(_PM_PLAY_PRC_|(_PM_MENU_==1) )
  2152. //Vicky060303#1  //Vicky060303#2 Update
  2153. void PeSetPlaybackRate(BYTE bRate)  //Renshuo050217#A 
  2154. {
  2155. WORD wDspVal;
  2156. //DetermineDspClock();  //determine DSP clock by global setting
  2157. DetermineDspClock(bRate, gxw3DMode);
  2158. switch(gxbMusicType&M_MAIN_TYPE)   
  2159. {
  2160. case M_MP3:
  2161. case M_MP2:
  2162. case M_MP1: //Vicky051028#1
  2163. case M_WAV:
  2164. case M_AAC: //David050612#3
  2165. SetSysSpeed(SYS_SPEED_NORMAL); //Nick060629#1
  2166. switch(bRate)
  2167. {
  2168. case 0:   // 1.00X
  2169. wDspVal =PLAY_RATE_100;
  2170. break;
  2171. case 1: // 1.14X
  2172. wDspVal = PLAY_RATE_114;
  2173. break;
  2174. case 2: // 1.33X
  2175. wDspVal = PLAY_RATE_133;
  2176. SetSysSpeed(0x06);//Nick060629#1 speed up MCU to fill in-buffer for high bit rate PCM
  2177. break;
  2178. case 3: // 0.67X
  2179. wDspVal = PLAY_RATE_067;
  2180. break;
  2181. case 4: // 0.80X
  2182. wDspVal = PLAY_RATE_080;
  2183. break;
  2184. //vick070424#1
  2185. case 5:
  2186. wDspVal=PLAY_RATE_050;
  2187. case 6:
  2188. wDspVal=PLAY_RATE_060;
  2189. break;
  2190. case 7:
  2191. wDspVal=PLAY_RATE_070;
  2192. break;
  2193. case 8:
  2194. wDspVal=PLAY_RATE_090;
  2195. break;
  2196. case 9:
  2197. wDspVal=PLAY_RATE_120;
  2198. break;
  2199. case 10:
  2200. wDspVal=PLAY_RATE_140;
  2201. SetSysSpeed(0x06);//Nick060629#1 speed up MCU to fill in-buffer for high bit rate PCM
  2202. break;
  2203. case 11:
  2204. wDspVal=PLAY_RATE_160;
  2205. SetSysSpeed(0x06);//Nick060629#1 speed up MCU to fill in-buffer for high bit rate PCM
  2206. break;
  2207. //End
  2208. }
  2209.      IdmaPioDmxW(&wDspVal,0x1fe6,1,DSP_W16);
  2210. break;
  2211. }
  2212. return;
  2213. }
  2214. #endif
  2215. #if(_PM_PLAY_|_PM_SLS_)
  2216. //Renshuo050217#A start //Vicky060303#1 updated : Add two Arguments
  2217. /*--------------------------------------------------------------------------
  2218. Description:
  2219. Because DSP clock is determined by user setting, music type....,
  2220. a function is created to handle it (according to global variable setting).
  2221. Arguments:
  2222. Global arguments:
  2223. Returns: 
  2224. --------------------------------------------------------------------------*/
  2225. void DetermineDspClock(XBYTE bPlayRate,XWORD w3DMode )  //Walace061228#CodeSize
  2226. {
  2227. obCLKDSPDIVF = 0x02;
  2228. switch(gxbMusicType&M_MAIN_TYPE) //Vicky051028#1
  2229. {
  2230. case M_WMA_UNKNOWN:
  2231. case M_WMA_1:
  2232. case M_WMA_2:
  2233. case M_WMA_3:
  2234. case M_WMA_4:
  2235. case M_WMA_5:
  2236. case M_WMA_6:
  2237.  //Vicky051209#1
  2238.        #if(ENABLE_FLUSH)
  2239.        if(gxbDSPFlush&FLUSH_FLAG)// if(gfNeedFlush)
  2240. obCLKDSPDIVF = FLUSH_DSPCLK; 
  2241. #endif
  2242.         //End 
  2243.         
  2244. //David051207 Start
  2245. if(gxwSampleRate>=44100)
  2246. obCLKDSPDIVF = 0x01;
  2247. //End
  2248. if(w3DMode == SOUND_3D_ON)
  2249.               {
  2250. if(gxwSampleRate > 16000) //for low Fs, don't raise clk, or DSP<->CODEC will halt //Renshuo050218#Y
  2251.            obCLKDSPDIVF = 0x01; 
  2252. if( (gfDrm) && (gxwSampleRate==44100) &&  (gxwByteRate>=2000) ) //Vicky060601#1
  2253. obCLKDSPDIVF = 0x00;
  2254.                  }
  2255. break;
  2256. case M_MP3:
  2257. case M_MP2:
  2258. case M_MP1:
  2259.  //For Power Consumption, Speed down DSP Clk //Vicky070313
  2260. if( (gxwByteRate<=1600) && (w3DMode !=SOUND_3D_ON) )     // 128Kbps(=128/8*100)
  2261. {
  2262. obCLKDSPDIVF = 0x03; //vicky070426#1
  2263. }
  2264. //end
  2265. switch(bPlayRate)
  2266. {
  2267. case 1: // 1.14 X
  2268. case 2: // 1.33 X
  2269. case 4:  //0.8 x
  2270. //vicky070424#1
  2271. case 8: //0.9x
  2272. case 9: // 1.2x
  2273. case 10: // 1.4x
  2274. case 11: // 1.6x
  2275. //End
  2276. if(gxwSampleRate > 16000) //for low Fs, don't raise clk, or DSP<->CODEC will halt //Renshuo050218#Y
  2277. obCLKDSPDIVF = 0x01;
  2278. //Vicky060106#1
  2279. if( 
  2280. ( (gxwByteRate>=2000)|| (gxbMusicFeature&MF_VBR) ) //Vicky060627#1 fix noise (3D on + Playrate+>=160Kbps(=160/8*100) )
  2281. &&  (gxwSampleRate >= 44100)
  2282. //&&(w3DMode == SOUND_3D_ON)
  2283. //&&  (bPlayRate >= 2)  //Vicky060303#1 
  2284. )
  2285. obCLKDSPDIVF=0x00; //48Khz:73Mhz,,44.1Khz:67Mhz
  2286. //End
  2287. break;
  2288. }
  2289. //Vicky060630#1
  2290. if((gxwSampleRate >= 44100)&& (gxwByteRate>=4000)) //More than 44.1Khz and 320Kbps
  2291. obCLKDSPDIVF = 0x00;
  2292. break;
  2293. case M_WAV:   //Vicky050527
  2294. if(gxwSampleRate > 24000) //for low Fs, don't raise clk, or DSP<->CODEC will halt //Renshuo050218#Y
  2295. obCLKDSPDIVF = 0x02; //vicky050606#1
  2296. else
  2297. obCLKDSPDIVF = 0x06;   // divide 8 //147(135)/8=18.375(16.875)Mhz
  2298. //Vicky060428
  2299. if(w3DMode == SOUND_3D_ON)
  2300.        {
  2301. if(gxwSampleRate > 16000) //for low Fs, don't raise clk, or DSP<->CODEC will halt //Renshuo050218#Y
  2302.         obCLKDSPDIVF = 0x01;
  2303.                  }
  2304. switch(bPlayRate)
  2305. {
  2306. case 1: // 1.14 X
  2307. case 2: // 1.33 X
  2308. case 4: //0.8 x
  2309. //vicky070424#1
  2310. case 8: //0.9x
  2311. case 9: // 1.2x
  2312. case 10: // 1.4x
  2313. case 11: // 1.6x
  2314. //End
  2315. obCLKDSPDIVF = 0x01;
  2316. if(gxwSampleRate > 16000) //for low Fs, don't raise clk, or DSP<->CODEC will halt //Renshuo050218#Y
  2317. obCLKDSPDIVF=0x00; //48Khz:73Mhz,,44.1Khz:67Mhz
  2318. break;
  2319. }
  2320. break;
  2321. }
  2322. }
  2323. //Renshuo050217#A end
  2324. #endif
  2325. //vicky070424#1 end