RAMPROG.C
上传用户:wldzsoft
上传日期:2022-01-17
资源大小:21k
文件大小:93k
源码类别:

mpeg/mp3

开发平台:

Objective-C

  1. //LR_CountNum  bit7-bit4
  2. //DirFlag: bit7:logo  bit 6 XX ,bi5 play wav flag  bit4 LR end flag bit 3:first subDir bit 2 second subDir,   
  3. //         bit 1 say point bit 0 return after say point                 bit 6 0x40 
  4. //SoundFlag  bit7:REC <logo  bit 6 del ,bi5 beep bit4 rec bit 3: off bit 2封键,    bit 1 0  0x03 
  5. //
  6. /*
  7. The most important is that make sure CS always fix High level, while use Cirrus CS42L51.
  8. (FM I2C at Rom code will make Codec CS pin goes to low)
  9. If codec CS goes to low, then need to initial codec again.
  10. */
  11. //battery test
  12. #include <option.h>
  13. #include <SMI51.h>
  14. #include <struct.h>
  15. #include <local.h>
  16. #include <local1.h>
  17. #include <protyp.h>
  18. #include <fusb.h>
  19. #include <UI.h>
  20. #include <fat.H>  
  21. #include <sd.h>
  22. #include <sdcmd.h>
  23. #include <isp_def.h>
  24. void Disk23SectorAddr2BlockPage0(BYTE);
  25. void ProcessVolumeUpDownISP(void);
  26. void fmGetMemChannel();
  27. void fatCheckFreeSize();
  28. void ShowRemainCapacity(void);
  29. void EndRecordISP();
  30. void lcdlcmOff();
  31. void LoadSettingISP();
  32. void PLLTurnOff();
  33. void PLLTurnOn();
  34. void CheckCardInISP(void);
  35. void Process_ScanFileISP(void);
  36. void ChkCARDInOut0ISP(void);
  37. void ProcessTimeoutEventISP(void);
  38. void dispShowFileNameId3TagISP(BYTE);
  39. void I2CVolumeControlISP();
  40. //void SelectFolderCountDown();
  41. //void SelectFolderCountUp();
  42. void FolderFunctionNumberTest();//ok
  43. void FolderFunctionNumberTest1();//ok
  44. void LRtest1();
  45. void DispFolderStudeLevel();
  46. void DispFolderNumber(BYTE FolderNumber);
  47. void DispFolderFunctionNumber(BYTE FolderFunctionNumber);
  48. void SelectFolderCountUpDown();
  49. void ShowBATISP();
  50. BYTE USBDISKISP();
  51. void logoSound();
  52. void fatSetRecordDirFileNameISP(void);
  53. #if(S_SupportFM)
  54. void FM_SeekISP(void);
  55. #endif
  56. void PlayKeyIsp();
  57. void PlayRECFunction();
  58. void ReturnUpFold(void );
  59. void EndSound();
  60. void LowSound();
  61. //void ReturnRoot();
  62. void OffProcess();
  63. void DelWavAll();
  64. void RecProcess();
  65. void InWav();
  66. void WavToMp3();
  67. void InLastLevel();
  68. void FolderStudeLevelUp();
  69. void FolderStudeLevelDown();
  70. void StopREC();
  71. void Delone();
  72. void FolderCountUpDownProcess();
  73. ////////////(GM24)add below //BE is no this issue 
  74. CBYTE T_MoveBufIndexISP[4]={10,11,12,8};
  75. void Read4PlaneTemp1ISP(void)
  76. {
  77.     for(gFPlane=0;gFPlane<4;gFPlane++)
  78.     {
  79.     g16PBA=gx16SrcBlock0;  
  80.     FlashCopyRead(T_MoveBufIndexISP[gFPlane]);   
  81.     }  
  82.     gFPlane=0;
  83. }
  84. void  Write2kTempPage1ISP(void)
  85. {    
  86.     //bit first;
  87.     BYTE first;
  88.     first=1;
  89.     for(gFPlane=0;gFPlane<4;gFPlane++)
  90.     {
  91.         g16PBA=gx16DesBlock0;  
  92.         SET_LINKDIR(T_MoveBufIndexISP[gFPlane]);   
  93.         FlashProgPage2k(first,0xc5);
  94.         ALL_LINK_MOVX;
  95.         first=0;
  96.     }
  97.     FLASHCLE(0x10);
  98.     while (FlashReady);
  99.     while (FlashBusy);
  100.     //FLASHCLE(0x70);
  101.     //gbProgramFail=FLASHRD_FDATA() & SET_BIT0;
  102.     FCEOFF();
  103.     gFPlane=0;
  104. }              
  105. void MoveTempPage2kISP(void)
  106. {
  107. //gxCopyBufPtr=COPY_BUF_PTR4_A; //(J)C_COPY_BUF_PTR4_A=0x00 => use 0xD000
  108. //gbSaveLink=1;
  109. //SaveLinkData(); //(J)if need 2K buffer from 0xD000 => save link data
  110. gx16SrcBlock0=F_LoadTempBlockPBA();
  111. gx16DesBlock0=gx16SrcBlock0;
  112. gBlockPageLo=F_LoadTempDataPage();
  113. //gxBackupPlane=F_LoadTempChildPage();
  114.     Read4PlaneTemp1ISP();
  115.     
  116.     //SetTempBlockLinkData();
  117.     /*
  118.     PB_FLASH[Spr1]=C_TempBlockID|gxTempPageCnt2; //(J)set link data for temp block
  119.     PB_FLASH[Spr2]=gxBackupPlane;
  120.     gx16SrcBlock1=F_LoadTempBlockLBA();
  121.     PB_FLASH[Spr3]=XW_2_XB(gx16SrcBlock1)[1];
  122.     PB_FLASH[Spr4]=XW_2_XB(gx16SrcBlock1)[0];
  123.   */
  124.   PB_FLASH[Spr1]=C_TempBlockID|F_LoadTempPageCnt(); //(J)set link data for temp block
  125.     //PB_FLASH[Spr2]=gxBackupPlane;
  126.     PB_FLASH[Spr2]=F_LoadTempChildPage();
  127.     gx16SrcBlock1=F_LoadTempBlockLBA();
  128.     PB_FLASH[Spr3]=XW_2_XB(gx16SrcBlock1)[1];
  129.     PB_FLASH[Spr4]=XW_2_XB(gx16SrcBlock1)[0];
  130.     
  131.     g16BlockPage=F_LoadTempBlockPagePtr();
  132.     Write2kTempPage1ISP(); 
  133.     
  134.     //RestoLinkData(); 
  135.     //gbSaveLink=0; 
  136.     
  137.     g16BlockPage=F_LoadTempBlockPagePtr();
  138.     F_SaveTempDataPage(gBlockPageLo);
  139.     g16BlockPage++;
  140.     F_SaveTempBlockPagePtr(g16BlockPage);
  141. }
  142. void OrderTempDataPageISP(void)
  143. {
  144. if(!gTempBlockPtr)
  145. {//(J)first temp page is cleared=>move ptr1 to ptr0 for further use
  146. ShiftTempPageData();
  147. }//(J)gTempBlockPtr=0 now
  148. else
  149. gTempBlockPtr=0;
  150. if(F_LoadTempBlockPagePtr()>=(gx16PagePerBlock-2))
  151. { //(J)temp block full=>copy temp page to new temp block
  152. CheckInitNewTempBlock();
  153. }
  154. else 
  155. { //(J)move to last page and update linke data with temp page count
  156. MoveTempPage2kISP();
  157. }
  158. }
  159. void CheckInitNewTempBlockISP(void)
  160. {
  161. if(F_LoadTempBlockPagePtr()>=(gx16PagePerBlock-2))
  162.     {
  163.      gx16SrcBlock0=F_LoadTempBlockPBA();
  164. gbProgramFail=1;
  165. while(gbProgramFail)
  166. {
  167.      PopSpareBlock2();
  168.         gx16DesBlock0=g16PBA;   
  169.         BUF_HOST;
  170. PB_FLASH[FSA_H]=0x00;
  171. //gxCopyBufPtr=COPY_BUF_PTR4_A; //(J)C_COPY_BUF_PTR4_A=0x00 => use 0xD000
  172.         //gbSaveLink=1;
  173.      //SaveLinkData(); //(J)if need 2K buffer from 0xD000 => save link data
  174.         
  175.         Ncopyflag=1;
  176.         /////////////////////////////////////////////////////////////////////////// 
  177.         gbProgramFail=gbProgramFail2=0;
  178.     gTempBlockPtr=0;  
  179.     while(gTempBlockPtr<F_LoadTempPageCnt()) 
  180.     {
  181.         gBlockPageLo=F_LoadTempDataPage();
  182.         Read4PlaneTemp1ISP();
  183.         
  184.         PB_FLASH[Spr1]=C_TempBlockID|F_LoadTempPageCnt(); //(J)set link data for temp block
  185.     PB_FLASH[Spr2]=F_LoadTempChildPage();
  186.     gx16SrcBlock1=F_LoadTempBlockLBA();
  187.     PB_FLASH[Spr3]=XW_2_XB(gx16SrcBlock1)[1];
  188.     PB_FLASH[Spr4]=XW_2_XB(gx16SrcBlock1)[0];
  189.         
  190.         gBlockPageLo=gTempBlockPtr;
  191.         Write2kTempPage1ISP();
  192.         F_SaveTempDataPage(gTempBlockPtr);
  193.            
  194.         gTempBlockPtr++;
  195.         gbProgramFail2 |= gbProgramFail;
  196.     }//(J)gTempBlockPtr=F_LoadTempPageCnt()
  197.     gbProgramFail=gbProgramFail2;
  198.         /////////////////////////////////////////////////////////////////////////
  199.         Ncopyflag=0;
  200.         
  201.         //RestoLinkData();
  202.      //gbSaveLink=0;
  203.     
  204.         if(gbProgramFail)
  205.         {
  206.             g16PBA=gx16DesBlock0;
  207.             if(!AGAND || AGAND_PROGFAIL(1))
  208.             {
  209.                 MarkBadBlock(11);  
  210.                 gbProgramFail=1;
  211.             }
  212.             else               
  213.              gbProgramFail=0; 
  214.         }
  215.     }
  216.     ALL_LINK_MOVX;
  217.     ALL_BUF_MOVX;
  218.     PB_FLASH[FSA_H]=0;
  219.     
  220.     F_SaveTempBlockPBA(gx16DesBlock0);
  221.     F_SaveTempBlockPagePtr(gTempBlockPtr);
  222.     
  223.     g16PBA=gx16SrcBlock0; //(J)erase old temp block
  224.     FlashErase();
  225.     if(EraseFail)  
  226.      MarkBadBlock(9);
  227.     else                   
  228.      PushSpareBlock(0x00);
  229. }
  230. }
  231. void CleanTempBlockPageISP(void)
  232. {
  233.     SaveSprArea();
  234.     F_SaveTempBlockLBA(0xffff);
  235. F_DecTempPageCnt();
  236. gbMatchTempBlock=0;
  237. if(F_LoadTempPageCnt())
  238. {
  239. OrderTempDataPageISP();
  240. }
  241. else
  242. {
  243. //(J)need back up page and block here
  244. //g16BlockPage=F_LoadTempBlockPagePtr();
  245. //if(g16BlockPage>=(gx16PagePerBlock-1))
  246. //{
  247. g16PBA=F_LoadTempBlockPBA();
  248.         FlashErase();
  249.         if(EraseFail) MarkBadBlock(10);
  250.         else            PushSpareBlock(0x00); 
  251.         
  252.      gbWithTempBlock=0;
  253. //}
  254. //else
  255. /*
  256. {
  257. ProgramEmptyTempPage();
  258. g16BlockPage++;
  259. F_SaveTempBlockPagePtr(g16BlockPage);
  260. }
  261. */
  262. }
  263. XB_FOption1[gM16Ptr]=Option1; 
  264. RestoSprArea();   
  265. }
  266. ////////////(GM24)add above
  267. void ReadLinkTableISP(void)
  268. {
  269. if(gbNotFisrtM16)
  270. gxBackUpTempPage=gxTempPageCnt0;
  271. ReadLinkTableROM();
  272. if(gbNotFisrtM16)
  273. gxTempPageCnt0=gxBackUpTempPage;
  274. }
  275. void CheckChangeNewTempBlockISP(void)
  276. {
  277. RESET_FLASH();
  278.     if(!gbWithTempBlock)
  279.     {
  280.      PopSpareBlock2(); 
  281.      gTempBlockPtr=0;
  282.     F_SaveTempBlockPBA(g16PBA);
  283.     F_SaveTempBlockLBA(g16LBA);
  284.     F_SaveTempBlockPagePtr(0);
  285.     F_SaveTempPageCnt(0);
  286.     
  287.      gbWithTempBlock=1;
  288.     }
  289.     else 
  290.     { //(J)change temp block
  291.      if(F_LoadTempBlockPagePtr()>=gx16PagePerBlock)
  292.      CheckInitNewTempBlock();
  293.     }
  294.     
  295. XB_FOption1[gM16Ptr]=Option1; 
  296. }
  297. //(GM2) time base 1 min
  298. CBYTE AUTOOFFTABISP[]={ 
  299.     1, //2
  300.     19, //20
  301.     29, //30
  302.     59, //60
  303.     255
  304. };
  305. void ClrAutoOffTmrISP()
  306. {
  307. ClrAutoOffTmr();
  308.     gxAutoOffMin=0;
  309. }
  310. //(GM2) time base 500(ms)
  311. CBYTE BLTIMERTABISP[]={6,10,20,0};
  312. extern CBYTE MENUTIMERTAB[];
  313. void BackLightOnISP()
  314. {
  315.     M_BackLightLed1On;
  316.     BL_TIMER=BLTIMERTABISP[XB_ADJ_BLTimer];  
  317.     if(XB_MENULayer[0]==1)
  318.      MENU_TIMER=10|0x80;
  319.     else
  320.      MENU_TIMER=MENUTIMERTAB[XB_ADJ_BLTimer]*2 | 0x80;
  321. void swCheckCodeID(void)
  322. {
  323. if(gxNewCodeID!=gxSwapCodeID)
  324. {
  325. gxSwapCodeID=gxNewCodeID;
  326. EA=0;
  327. LoadRsvPage(C_SwapCodeOffset+(gxNewCodeID*6),BUF0xC400,6);
  328. EA=1;
  329. }
  330. }
  331. void Unicode2Big5ISP(void)
  332. {
  333. #if 0
  334. gxNewCodeID=0; //(J)call Unicode2Big5ISP()
  335.     swCheckCodeID();
  336. CALLADDR((CBYTE*)0xc406);
  337. #endif
  338. }
  339. void ProcessLanguageSetISP(void)
  340. {
  341. #if 0
  342.     //XB_ADJ_Language=lang;
  343.     gx16LangMsgOffset=(WORD)XB_ADJ_Language*C_LanguageMenuMsgNum;
  344.     gxUnicodeTabIndex=T_LanguageCode[XB_ADJ_Language];
  345.     MOVESRAM_XX(gxarFileName,gxarFileNameBuf,128); //(J)backup unicode filename
  346.     if(gxarFileName[1]&1)
  347.     {
  348.      //Unicode2Big5(&gxarFileName);
  349.      gxTemp0=0;
  350.      Unicode2Big5ISP();
  351.     }
  352.     if(gbPlayMode)
  353. {
  354. if((XB_File_CurrentType==WMAFILE)&&M_ChkWithId3Tag)
  355. {
  356. MOVESRAM_XX(gxarWMATag,gxarWMATagBuf,128);
  357.      gxTemp0=1;
  358. Unicode2Big5ISP();
  359. }
  360. }
  361. #endif
  362. }  
  363. void RAMProgISP(void)
  364. {  
  365. gxDispPtr=0;
  366. gxFlagReg3=0;
  367. CodeI2C_CS_LOW;
  368. gxSwapCodeID=0;
  369.     SystemInit();
  370. #if(S_SupportSegLcd)
  371. lcdInitialHT1621();
  372. #endif         
  373. #if(S_SupportMemoryCard)
  374. OPT02 |= bit4;
  375. #else
  376. OPT02 &=~bit4;
  377. #endif
  378. #if(S_SupportAudioADC)
  379. P1IO=0x03;
  380. P3IO=0xB9;
  381. M_AudioADCPowerDown;
  382. #endif
  383.      PB_HOST[I2CSEL]=0x7F;
  384. //yu5        PB_HOST[FMI2C]=0xF8;
  385. M_PowerLEDOn;
  386. if (PB_HOST[0x04]&SET_BIT1)
  387.     {
  388.      SYSTEM_PWR_OFF; //(J)P37=0  
  389.      //JM=>PB_DC2DC[DC2DC_Ctrl0]&=~bit0; //(J)switch to LDO1.8V
  390.         //JM=>PB_DC2DC[DC2DC_Ctrl1]&=~bit0;
  391.         //M_EnableLDO18; //regulator power on
  392.         WaitStateOff;
  393.         CPUWAIT=0;
  394.         SET_USBMode;
  395.         CPUCLK_PHY;
  396.         PLL_OFF;
  397.         XB_FUSBBASE[FUSB_TST_EP]=0;
  398.         XB_FUSBBASE[FUSB_PHY_TMS] &= ~SET_BIT0;
  399.         gxWin2kCnt=0;
  400.         gxUsbTempCnt=0;
  401.         USBinit(1);
  402.         GUI_USBDISK();
  403.         while (1)
  404.         {
  405. /*
  406.          if(!KEYHOLD)
  407. {
  408. CLR_nWPRO1; //(J)all Flash LUN write protect by hardware
  409. nWPRO=0x00; //(J)all Flash LUN write protect
  410. }
  411. else
  412. */
  413. {
  414. SET_nWPRO1; //(J)
  415. nWPRO=0xFF; //(J)Flash LUN write protect by SoftWPROBYTE
  416. }
  417.             if ((USBDISKISP()==2) && (SPEEDID))
  418.             {
  419.                 SET_USBGUIFlag;
  420.                 if (XB_USBCMDIN<2) XB_USBCMDIN++;
  421.             }
  422.             
  423. #if(S_SupportForceMP3)
  424.             if(M_ChkForceMp3Mode)
  425.             {
  426.              XB_FUSBBASE[FUSB_TST_EP]|=bit6;
  427.              XB_FUSBBASE[FUSB_PHY_TMS]|=bit0;
  428.              XB_FUSBBASE[FUSB_MAIN]|=0x08;
  429.              break;
  430.             }
  431. #endif            
  432.         }
  433.     }
  434.     
  435.     //MP3 loop
  436.     {
  437.     
  438. CLR_USBMode;
  439. PB_HOST[ISR_CTL]&=~USB_INT;
  440. PB_HOST[ISR_CTL]&=~CARDCD_INT;
  441.     PB_HOST[ADC3BIT_CTRL]=0x00;
  442.     delayclk(2);
  443.     if(PB_HOST[ADC3BIT_CTRL]<6)
  444.      return;
  445.      if (!(PB_HOST[0x04]&SET_BIT1))
  446.      {
  447.      SYSTEM_PWR_ON;   //(J)P37=1;//battery power on
  448.      M_EnableLDO18;//M_DisableLDO18; //(G)regulator power down, power control for demo board
  449. }
  450.     
  451. if(S_CS42L51||S_SupportAudioADC)
  452.          PB_DC2DC[DC2DC_Ctrl0]|=bit0; //(G)enable IIS_CLK to CODEC or audio ADC
  453.         //JM=>PB_DC2DC[DC2DC_Ctrl0]|=bit0; //(J)switch to DCDC1.8V
  454.         //JM=>PB_DC2DC[DC2DC_Ctrl1]|=bit0;
  455.         
  456.         WaitStateOn;  
  457. CPUWAIT=1;
  458.         UI_Loop();
  459.     }
  460. }
  461. void DispPlayIcon()
  462. {//swep
  463. gxNewCodeID=5;
  464. swCheckCodeID();
  465. CALLADDR((CBYTE*)0xc415);
  466. }
  467. #if 0
  468. //20060801_Jash
  469. //###################################################
  470. void dispShowPlaySymbol(void)
  471. {
  472. if(!(M_ChkLowBattery))
  473. {
  474. #if(S_SupportLcm)
  475. LCM_yp=1;
  476. LCM_xp=100;
  477. LoadRsvPage(USEROFFSET+C_IconPictureOffset+1,BUF0xE000,1);
  478. lcmSetPageAddress(LCM_yp,LCM_xp); 
  479. gxIconOffset=(gxPlaySymbolNum*8)+16*3;
  480. MOVERAM_LCM(&XB_BUF0xE000[gxIconOffset],8);
  481. #endif
  482. }
  483. }
  484. void dispCheckShowPlaySymbol(void)
  485. {
  486. gxPlaySymbolNum=0;
  487. if(M_ChkSkipMode)
  488. {
  489. if(gxKeyMinderBuf&bit2)
  490. {
  491. gxPlaySymbolNum=4;
  492. }
  493. else
  494. {
  495. gxPlaySymbolNum=5;
  496. }
  497. }
  498. else if(!gbStopMode)
  499. {
  500. gxPlaySymbolNum=XB_PlayMode-1;
  501. }
  502. if((!gbStopMode)&&(gxPlaySymbolNum<6))
  503. {
  504. dispShowPlaySymbol();
  505. }
  506. }
  507. #endif
  508. /////////////////////////////(GM25)add below
  509. #if(!S_CS42L51)
  510. CBYTE C_DSPVolumeValue[]=
  511. {
  512. 0,
  513. 0x91,0x96,0x9B,0xA0,0xA5,
  514. 0xAA,0xAF,0xB4,0xB9,0xBE,
  515. 0xC3,0xC8,0xCD,0xD2,0xD7,
  516. 0xDC,0xE1,0xE6,0xEB,0xF0,
  517. 0xF4,0xF7,0xFA,0xFB,0xFE
  518. };
  519. #endif
  520. void EQVolumeControl(BYTE eq)
  521. {
  522. #if(S_CS42L51)
  523. if (((XB_MENULayer[0]==4)&&(XB_MENULayer[2]==0))||!gxRampVolume)
  524. {
  525. gxibVolume.SBYTE.B0=gxVolumeBias;
  526.     if(eq)
  527.     {
  528. gxibVolume.SBYTE.B0-=gxEQCompensation;
  529. }
  530. gxibVolume.SBYTE.B1=gxibVolume.SBYTE.B0;
  531. Wait_DataFin();
  532. WRITE_DSPIO(0x46,gxibVolume.INTEGER); 
  533. }
  534. I2CVolumeControlISP();
  535. #else
  536. gxTemp0=eq;
  537. gxNewCodeID=3;
  538. swCheckCodeID();
  539. CALLADDR((CBYTE*)0xc415);
  540.     
  541. #endif
  542. }
  543. /////////////////////////////(GM25) add above
  544. #if(S_CS42L51)
  545. CBYTE  C_DACVolumeValue[]={ 0x0,
  546. 0x6d,0x74,0x7b,0x82,0x89,
  547. 0x8f,0x95,0x9b,0xa1,0xa7,
  548. 0xac,0xb1,0xb6,0xbb,0xc0,
  549. 0xc4,0xc8,0xcc,0xd0,0xd4,
  550. 0xd8,0xdb,0xde,0xe1,0xe4};
  551. #endif
  552. //void I2CVolumeControlISP(BYTE volume)
  553. void I2CVolumeControlISP(void)
  554. #if(!S_CS42L51) 
  555. gxNewCodeID=3;
  556. swCheckCodeID();
  557. CALLADDR((CBYTE*)0xc412);
  558. #else 
  559. //xdata IntegerByte ibVolume;
  560. //gxRampVolume=volume;
  561.     
  562. gxibVolume.SBYTE.B1=0xff-gxRampVolume;
  563. gxibVolume.SBYTE.B0=0xff-gxRampVolume;     
  564.     Wait_DataFin(); //(J)wait DSP complete data transfer
  565. //if(volume)
  566. if(gxRampVolume)
  567. {
  568. WRITE_DSPIO(0x46,gxibVolume.INTEGER);
  569. if(!M_ChkRampUpToVolume) //(GM25)
  570. {
  571. if(gxRampVolume==C_DSPVolumeValue[1])
  572. CodeI2C_CS_LOW;
  573. }
  574. /*
  575. else
  576. {
  577. if(gxRampVolume==C_DSPVolumeValue[4]) //0xAA, for ramp up
  578. CodeI2C_CS_LOW;
  579. }
  580. */
  581. }
  582. else
  583. CodeI2C_CS_HIGH;
  584. //WRITE_DSPIO(0x46,0xfefe);
  585. #endif
  586. }
  587. void ResetCodecISP()
  588. {
  589. i2cInitialCS42L51(0);
  590. gxRampVolume=0;
  591.     I2CVolumeControlISP();  
  592. }
  593. void RampDownToMuteISP(void)
  594. {
  595. gxNewCodeID=3;
  596. swCheckCodeID();
  597. CALLADDR((CBYTE*)0xc40f);
  598. }
  599. void dispShowFileNameId3TagISP(BYTE bShowId3Tag)
  600. {
  601. #if 0
  602. gxTemp0=bShowId3Tag;
  603. gxNewCodeID=2; //(J)call lyrSeekLyricISP()
  604. swCheckCodeID();
  605. CALLADDR((CBYTE*)0xc412);
  606. #endif
  607. }
  608. void SelPlayFileISP(BYTE PrePlay)
  609.     gxPrePlay=PrePlay;
  610.     
  611. if(ChkPLLOff) //(GM2)
  612. PLLTurnOn();
  613.     RampDownToMuteISP();
  614.     gxNewCodeID=0; //call SelPlayFileISP() in swap code 0
  615. swCheckCodeID();
  616. CALLADDR((CBYTE*)0xc400);
  617. #if 0//(S_SupportLcm)               
  618. if(!M_ChkLowBattery) //(GM7)
  619. {
  620. if((XB_MENULayer[0]==7)||(!XB_MENULayer[0] && !XB_MENULayer[1]))
  621. dispShowFileNameId3Tag(0);
  622. }
  623. #endif
  624. }
  625. #define MaxSenseline 0
  626. void KeyboardScanISP(void)
  627. {
  628. BYTE u8CompareData;
  629. if (!(M_ChkDebounceMode))
  630. {
  631. XSFR1 |= bit2; //(J)active key pad internal pull high
  632. delayclk(50);
  633. gxSenseXorData=~PB_HOST[Key_Pad]; //(J)read key pad status and reverse value for convinience
  634. XSFR1 &= ~bit2;
  635. gxSenseXorData^=gxKeyMinderBuf; //(J)detect key status change, gxSenseXorData=current key status
  636. if (gxSenseXorData) //(J)    gxKeyMinderBuf=last confirmed key status
  637. { //key status change
  638. M_SetDebounceMode; //(J)enter debounce mode and initial debounce counter
  639. gKeyDebounceCnt=0;
  640. gxLevelHoldCnt=0;
  641. gxSenseConfirmData=gxSenseXorData;
  642. }
  643. }
  644. else
  645. {
  646. gKeyDebounceCnt++;
  647. if(gKeyDebounceCnt>=3) //(J)6*5.5ms wait debounce duration
  648. {
  649.    M_ClrDebounceMode;
  650.   
  651.    XSFR1 |= bit2;
  652. delayclk(50);
  653.    gxSenseXorData=~PB_HOST[Key_Pad];
  654.    XSFR1 &= ~bit2;
  655. gxSenseXorData^=gxKeyMinderBuf;
  656.     if (gxSenseXorData)
  657.    { //(J)key status change
  658.     if (gxSenseConfirmData==gxSenseXorData) //(J)double confirm key change status after debounce mode
  659.     {
  660.        gxKeyCode=0;
  661.        u8CompareData=0x01;
  662.        while ((!(u8CompareData&gxSenseXorData))&&(u8CompareData!=MaxSenseline))
  663.        { //(J)calculate key code
  664.         gxKeyCode++; //get keycode
  665.         u8CompareData=u8CompareData<<1;
  666.        }
  667.        if(u8CompareData & gxKeyMinderBuf)
  668.        { //(J)key change by realase key
  669.         M_ClrPlayKeyFunction;
  670.         if((gxKeyCode==C_PrevKey)||(gxKeyCode==C_NextKey))
  671.          {
  672.          if(M_ChkSkipMode)
  673.          {
  674.          M_ClrSkipMode;
  675.          M_SetFileReadInit;
  676.          M_SetPlayBackEnd; //(J)to trigger fatFileReadInit()
  677.          if(!gbPauseMode) //(GM32)
  678.          M_SetRampUpToVolume;
  679.          //gLedOnCnt=10;
  680.          //gLedOffCnt=120;         
  681.          }
  682.          else
  683.          {
  684.          if(M_ChkSkipLevelHoldKey)
  685.        M_ClrSkipLevelHoldKey;
  686.        else
  687.        M_SetPlayKeyFunction; //(J)active key if the key function is triggered by rising edge
  688.        }
  689.        }
  690. else if((gxKeyCode==C_PlayKey)||(gxKeyCode==C_StopKey)||(gxKeyCode==C_ABKey))       
  691.        {
  692.        if(M_ChkSkipLevelHoldKey)
  693.        M_ClrSkipLevelHoldKey;
  694.        else if(M_ChkStopKeyFunction) //(GM4)avoid M_SetPlayKeyFunction after press play key for stop
  695.        M_ClrStopKeyFunction;
  696.        else
  697.        M_SetPlayKeyFunction;
  698.        }
  699.        }
  700.        else
  701.        { //(J)key change by press key
  702.        M_SetPlayKeyFunction; //(J)active key if the key is triggered by falling edge
  703.       
  704.        //20060719_Jash
  705. #if(S_SupportFM)
  706.        if(gbFMMode)
  707.        {
  708.        if(XB_FM_RunSeek==3)
  709.        {
  710.        XB_FM_RunSeek=0; //clear seek mode
  711.        M_ClrPlayKeyFunction;
  712.        M_SetSkipLevelHoldKey;
  713.        }
  714.        }
  715. #endif       
  716.       
  717. if((gxKeyCode==C_PrevKey)||(gxKeyCode==C_NextKey)||(gxKeyCode==C_PlayKey)||(gxKeyCode==C_StopKey)||(gxKeyCode==C_ABKey))   
  718.         {
  719.          M_ClrPlayKeyFunction;
  720.        }
  721.        }
  722.     gxKeyMinderBuf=gxKeyMinderBuf^u8CompareData;
  723.             }
  724.     else
  725.     {
  726.    M_ClrDebounceMode; //invalid key
  727.    M_ClrPlayKeyFunction;
  728.     }
  729.    }
  730.    else
  731.    {
  732.      M_ClrDebounceMode; //invalid key
  733.      M_ClrPlayKeyFunction;
  734.    }
  735. }
  736. }
  737. }
  738. void dispShowFontISP()
  739. {
  740. /* if(gbFMMode||gbRecordMode)
  741. {
  742. dispShowFontROM();
  743. }
  744. else
  745. {
  746. gxNewCodeID=2;
  747. swCheckCodeID();
  748. CALLADDR((CBYTE*)0xc403);
  749. if(gbPlayMode&&XB_PlayStep&&(XB_File_CurrentType != WAVFILE)) //(G) avoid 320kbps WMA format audio output is not continuous 
  750. {
  751. if(M_ChkSkipMode)
  752. return;
  753. //Process_PLAY2();
  754. if(!M_ChkPlayBackEnd)
  755.     {
  756.         while(!MP3_Read1Sector())  
  757.         {
  758.          dspTriggerRead();    
  759.          if(M_ChkPlayBackEnd)
  760.          break;
  761.         }
  762.         dspTriggerRead();
  763.     }
  764. }
  765. */
  766. }
  767. void dispShowLyricISP(BYTE u8LyricIndex)
  768. {
  769. #if 0
  770. gxTemp0=u8LyricIndex;
  771. gxNewCodeID=2;
  772. swCheckCodeID();
  773. CALLADDR((CBYTE*)0xc406);
  774. #endif
  775. }
  776. void SwitchFatParameterISP(void)
  777. {
  778. gxNewCodeID=0;
  779. swCheckCodeID();
  780. CALLADDR((CBYTE*)0xc412);
  781. }
  782. #if(!S_CS42L51)
  783. void EnableHardwareMute(void)
  784. {
  785. CodeI2C_CS_HIGH; //(G) eliminate noise as stopping 
  786.     delayclk(250);
  787.     delayclk(250);
  788.     delayclk(250);
  789.     delayclk(250);
  790.     delayclk(250);
  791.     PB_DAC[DAC_PowerCtrl]=0x0c;
  792. }
  793. #endif
  794. void ChkCARDInOutISP(void)
  795. {
  796. #if(S_SupportMemoryCard)
  797.     //if((CardDetect)||(!(gbPlayMode|gbRecordMode)&&(!CardDetect)))
  798.     if((CardDetect)||((XB_PlayMode < C_FilePlayMode)&&(!CardDetect)))
  799.     { //(J)only sense card insert when no song is playing
  800.         CheckCardInISP();
  801.         if(XB_New_Card_State != XB_Now_Card_State )
  802.         {
  803.             XB_Now_Card_State=XB_New_Card_State;
  804. if((gbPlayMode|gbRecordMode)&&(gxMp3Storage))
  805. { //(J)playing card
  806. #if(!S_CS42L51) //(GM22)
  807. EnableHardwareMute();
  808. #endif
  809. Process_STOP();
  810. //while (ReadDSP_DMA_CTRbit());
  811.              //Disable_DSP();
  812. }
  813.         //XB_GUI_FLAG=gui;
  814.         
  815. #if(S_CombineStor)
  816. if(XB_Now_Card_State)
  817. { //(J)insert card
  818. gxarDiskStatus[gxMp3Storage]=XB_DiskStatus; //(GM26)
  819. gxarDiskErrorCode[gxMp3Storage]=gDiskErrorCode;
  820. gxMp3Storage=1;
  821. Process_ScanFileISP();
  822. gxScanFreeSizeflag[gxMp3Storage]=0; //(GM1)
  823. XW_TotalFile[0]=gx16arTotalFile[0][0]+gx16arTotalFile[1][0];
  824.      XW_TotalFile[1]=gx16arTotalFile[0][1]+gx16arTotalFile[1][1];
  825.      uiClearPlayedFlag();
  826.     
  827.      if(gx16arTotalFile[0][XB_FileType])
  828.     { //(J)nand FAT is good
  829.      gxMp3Storage=0;
  830.      SwitchFatParameterISP();
  831.     }
  832.     
  833.      XB_GUI_FLAG = 0;
  834. ResetCodecISP();
  835. ClrMenuLayer(); //(GM7)avoid not in main screen
  836.         GotoSelFileMode();
  837.         
  838. }
  839. else
  840. { //(J)remove card
  841. XW_TotalFile[0]=gx16arTotalFile[0][0];
  842.      XW_TotalFile[1]=gx16arTotalFile[0][1];
  843. if(gxMp3Storage==1)
  844. {
  845. //(GM22)
  846. //if(gbPlayMode)
  847. //Process_STOP();
  848. gxMp3Storage=0;
  849. SwitchFatParameterISP();
  850.      gx16PlayIndex=0; //(J)reset play index for nand
  851.     
  852.      XB_GUI_FLAG = 0;
  853. ResetCodecISP();
  854. ClrMenuLayer(); //(GM22)
  855. GotoSelFileMode();
  856. }
  857. else
  858. {
  859. if(XW_TotalFile[XB_FileType]) //(GM7)
  860. {
  861. if (!XB_MENULayer[0] && !XB_MENULayer[1])
  862. uiUpdateMainDisplay(bit3); //(J)just update total song display
  863. }
  864. else
  865. GotoSelFileMode();
  866.      }
  867. }
  868. #else
  869. Process_ScanFileISP();
  870. uiClearPlayedFlag();
  871. gxScanFreeSizeflag[gxMp3Storage]=0; //(GM1)
  872. XB_GUI_FLAG = 0;
  873.             ResetCodecISP();
  874.             GotoSelFileMode();     
  875. #endif
  876.         }
  877.     }
  878. #endif    
  879. }
  880. /***********************yu5*******************************/
  881. void IR_receive()
  882. {
  883. XBYTE i;
  884. // byte_temp0=PB_HOST[FMI2C];//yu1123 FM_DO_HIGH;
  885. // delayclk(200);
  886. // if(!(byte_temp0 &= SET_BIT0))//yu1123 if(!(FM_DO_CH)) FM_DO_HIGH_IR;
  887. FM_CLK_IR_D0_HIGH;
  888. delayclk(200);
  889. byte_temp=PB_HOST[FMI2C];
  890. if(!(byte_temp & SET_BIT1)) //yu5 FM_DO_HIGH  PB_HOST[FMI2C] |= SET_BIT0
  891. gxNewCodeID=6;
  892. swCheckCodeID();
  893. CALLADDR((CBYTE*)0xc403);  
  894. /*
  895. delayclk(50);
  896. IR_CLK_LOW;
  897. delayclk(250);
  898. delayclk(20);
  899. IR_CLK_HIGH;
  900. delayclk(250);
  901. delayclk(20);
  902. IR_CLK_LOW;
  903. delayclk(250);
  904. delayclk(20);
  905. IR_CLK_HIGH;
  906. for(i=0;i<8;i++)
  907. {
  908. byte_temp=PB_HOST[FMI2C];
  909. if(!(byte_temp & SET_BIT1))
  910.    IR_DATACnt=IR_DATACnt|SET_BIT0;
  911.    if(i!=7)
  912. IR_DATACnt=IR_DATACnt<<1;
  913.    delayclk(250);
  914. delayclk(20);
  915.    IR_CLK_LOW;
  916.    delayclk(250);
  917. delayclk(20);
  918. IR_CLK_HIGH;
  919. }
  920. IR_CLK_HIGH; //data is over
  921. IR_DATA=1;    */
  922. }    
  923. }
  924. /***********************yu5*******************************/
  925. void TimeoutEventISP(void)
  926. {
  927. //20060808_Jash check if DSP enable I2S, then release DAC Reset pin.
  928. /* //(j) mark
  929. #if(!S_CS42L51)
  930. if(M_ChkRampUpToVolume)
  931. {
  932. if(READ_DSPIO(0x4e))
  933. {
  934. PB_DAC[DAC_PowerCtrl]=0x0d; //(J)enable LR channel of internal DAC
  935. }
  936. }
  937. #endif
  938. */
  939. if(T1Flag) //(J)check timer1 flag(timebase=11ms)
  940. {
  941. T1Flag=0;
  942. gx5P5mSCnt++;
  943. gx5P5mSCnt0++;
  944. if(!(XSFR1&bit6))
  945. { //(J)if sysclock/2
  946. gx5P5mSCnt++;
  947. gx5P5mSCnt0++;
  948. }
  949. }
  950. if(gx5P5mSCnt>=2) //(J)timebase = 11ms
  951. {
  952. gx5P5mSCnt=0;
  953. /***********************yu5*******************************/
  954. IR_receive();
  955. if(IR_DATACnt)
  956. {
  957. SelectFolderCount=(IR_DATACnt>>4)&0x0F;
  958. SelectFolderCount=(SelectFolderCount-1)*3;
  959. SelectFolderCount+=IR_DATACnt&0x0F;
  960. if((SelectFolderCount)>36)//14
  961. {
  962. SelectFolderCount=1;
  963. }
  964. FolderCountUpDownProcess();
  965. LastST=0;
  966. LastMC=0;
  967. LastSC=0;
  968. IR_DATACnt=0;
  969. }
  970. /***********************yu5*******************************/
  971. lcdUpdateSegLcdDisplay();   
  972. if(!M_ChkLowBattery) //(GM7)
  973. KeyboardScanISP();
  974. if (gxKeyMinderBuf) BackLightOnISP();
  975.     //else  INTTEMP &= ~KEY_INT;
  976. /*     
  977.     if(gxKeyMinderBuf&(bit4+bit5)) //(J)for volume key
  978. MENU_TIMER=1|0x80;
  979. */    
  980.      XB_GUI_FLAG=1;
  981. //yu5 ChkCARDInOutISP();
  982. #if(!S_CS42L51)
  983. M_SetEnableRampUpVolume;
  984. if(M_ChkRampUpToVolume&&M_ChkEnableRampUpVolume)   
  985. #else
  986.   if(M_ChkRampUpToVolume)
  987. #endif
  988. {
  989. if(!gxRampVolume)
  990. {
  991. #if(S_CS42L51)
  992. WRITE_DSPIO(0x46,0x0A0A); //(GM25)C_CODECVolumeBias
  993. #endif
  994. if(!XB_FileType&&!gbFMMode) //(GM20)
  995. {
  996. WRITE_DSPIO(0x44,XB_ADJ_EQMode);
  997. EQVolumeControl(XB_ADJ_EQMode); //(GM25)
  998. }
  999. }
  1000. #if(S_CS42L51)
  1001. gxTempR=C_DACVolumeValue[XB_ADJ_CurrentV];
  1002. #else
  1003. gxTempR=C_DSPVolumeValue[XB_ADJ_CurrentV]; //(GM25)
  1004. #endif
  1005. if(gxRampVolume<gxTempR)
  1006. {
  1007. /*
  1008. if((gxTempR-gxRampVolume)>5)
  1009. {
  1010. if(XB_FileType||(gxRampVolume>0xC0))
  1011. gxRampVolume++;
  1012. else
  1013. gxRampVolume+=5;
  1014. }
  1015. else
  1016. gxRampVolume++;
  1017. */
  1018. gxRampVolume=gxTempR;
  1019. }
  1020. else
  1021. {
  1022. M_ClrRampUpToVolume;
  1023. gxRampVolume=gxTempR;
  1024. #if(!S_CS42L51)
  1025. CodeI2C_CS_LOW;
  1026. #endif
  1027. }
  1028. //I2CVolumeControlISP();
  1029. EQVolumeControl(XB_ADJ_EQMode);//(GM25)
  1030. }
  1031. if(AutoOffTmrH>=6) //(GM2) AutoOffTmrH++ time base 10(s) 
  1032. {
  1033. AutoOffTmrH=0;
  1034. gxAutoOffMin++;
  1035. }
  1036. //(GM2) around 5(s)
  1037. if(AutoOffTmrL==10) 
  1038. {
  1039.     if((gbSelectFileMode||gbStopMode)&&ChkPLLOn)
  1040.         PLLTurnOff();
  1041.     }
  1042. P1IO=0x33;
  1043. //yu4 P14=1;
  1044. P15=1;
  1045. P1IO=0x13; //yu4 P1IO=0x03;
  1046. P3IO=0xB8; //yu4 P3IO=0xB9;
  1047. //Set input mode
  1048. if(SoundFlag&0x10)//rec mode
  1049. {
  1050. if(SoundFlag&0x80)
  1051. P31=1; //yu4 P30=1;
  1052. else
  1053. P31=0; //yu4 P30=0;
  1054. }
  1055. else
  1056. {
  1057. P31=1; //yu4 P30=1;
  1058. } /*yu3
  1059. if((P14==1)&&(PressIO_Key&0x01))
  1060. {//SC 
  1061. SCtest();
  1062. DispFolderFunctionNumber(1);
  1063. } *///yu3
  1064. if((P15==1)&&(PressIO_Key&0x02))
  1065. {//MC 
  1066. FolderFunctionNumberFlag=3;
  1067. FolderFunctionNumberTest1();
  1068. DispFolderFunctionNumber(3);
  1069. }
  1070. if((P17==1)&&(PressIO_Key&0x04)) //yu2 key6
  1071. {//LR 
  1072. LRtest1();
  1073. DispFolderFunctionNumber(4);
  1074. } /*yu3
  1075. if((P31==1)&&(PressIO_Key&0x08))
  1076. {//ST 
  1077. STtest();
  1078. DispFolderFunctionNumber(2);
  1079. }  *///yu3
  1080. if((P36==1)&&(PressIO_Key&0x10))
  1081. {
  1082. }
  1083. if(
  1084.    ((gxKeyMinderBuf&(bit0+bit1+bit2+bit3+bit4+bit5)))||((P15==0)||(P17==0)|| (0==P36)  )    //yu3
  1085. //yu3    ((P31==0)||(P14==0)||(P15==0)||(P17==0)|| (0==P36)  )
  1086.   )
  1087. //if((gxKeyMinderBuf&(bit0+bit1+bit2+bit3+bit4+bit5))&&(KEYHOLD))
  1088. {
  1089. if(!M_ChkFMAutoScan) //(GM8)
  1090. gxLevelHoldCnt++;
  1091. if(!P15||!P17||!P36)
  1092. {
  1093. //if(DirFlag&0x80)
  1094. if(SoundFlag&0x04)
  1095. gxLevelHoldCnt=0;
  1096. if(gxLevelHoldCnt>1)
  1097. {
  1098. gxLevelHoldCnt=0;
  1099. BackLightOnISP();
  1100. //else
  1101. if((P15==0))//&&(0==PressIO_Key&0x02)
  1102. {//MC 
  1103. PressIO_Key=0x02;
  1104. }
  1105. if((P17==0))//&&(0==PressIO_Key&0x04)
  1106. {//LR 
  1107. PressIO_Key=0x04;
  1108. }
  1109. /*yu3 if((P31==0))//&&(0==PressIO_Key&0x08)
  1110. {//ST 
  1111. PressIO_Key=0x08;
  1112. } *///yu3
  1113. if((P36==0))//&&(0==PressIO_Key&0x10)
  1114. {//Play REC 
  1115. ProcessVolumeUpDownISP();//PressIO_Key=0x10;
  1116. }
  1117. }
  1118. }
  1119. if(gxKeyMinderBuf&bit1)
  1120. {
  1121. if(gxLevelHoldCnt>50) //(J)check play key level hold for about 2 seconds 
  1122. {
  1123. FolderStudeLevelDown();gxLevelHoldCnt=0;
  1124. }
  1125. }
  1126. else if(gxKeyMinderBuf&bit5)
  1127. {
  1128. if(gxLevelHoldCnt>50) //(J)check play key level hold for about 2 seconds 
  1129. {
  1130. FolderStudeLevelUp();gxLevelHoldCnt=0;
  1131. }
  1132. }
  1133. else 
  1134. {
  1135. //////////////////////////(GM4)
  1136. //////////////////////////
  1137. if(gxKeyMinderBuf&bit0) //(J)check play key level hold for about 2 seconds 
  1138. {
  1139. if(gxLevelHoldCnt>50)
  1140. {
  1141. {
  1142. gxLevelHoldCnt=0;
  1143. EndSound();
  1144. //M_SetPowerOff;
  1145. }
  1146. }
  1147. }
  1148. /*
  1149. else if(gxLevelHoldCnt>2)
  1150. {
  1151. if(gxKeyMinderBuf&bit5)
  1152. { //volume up
  1153. gxLevelHoldCnt=0;
  1154. ProcessVolumeUpDownISP();
  1155. }
  1156. }
  1157. */
  1158. }
  1159. }
  1160. else
  1161. {
  1162. gxLevelHoldCnt=0;
  1163. M_ClrSkipLevelHoldKey;
  1164. M_ClrPowerOff;
  1165. }
  1166. }
  1167. }
  1168. void I2CPowerDownISP()
  1169. {
  1170. #if(S_CS42L51)
  1171.     CodecI2COut(0x02,0xef);
  1172.     CodeI2C_CS_LOW;
  1173. #else
  1174.     PB_DAC[DAC_PowerCtrl]=0x02; //disable LR channel of internal DAC and Power down DAC
  1175. #endif
  1176. }
  1177. void GUI_VolumeISP()
  1178. {
  1179. gxNewCodeID=5;
  1180. swCheckCodeID();
  1181. CALLADDR((CBYTE*)0xc418);
  1182. }
  1183. void ProcessVolumeUpDownISP(void)
  1184. {
  1185. if(XB_ADJ_CurrentV<25)
  1186.          XB_ADJ_CurrentV++;
  1187.          else
  1188.          XB_ADJ_CurrentV=0;
  1189. if(XB_PlayMode>C_FileSelectMode)
  1190. {
  1191. gxRampVolume=C_DSPVolumeValue[XB_ADJ_CurrentV]; //(GM25)
  1192. I2CVolumeControlISP();
  1193. }
  1194. GUI_VolumeISP();
  1195. }
  1196. #if(S_SupportFM)
  1197. void GUI_FM_ShowChanISP()
  1198. {
  1199. gxNewCodeID=1;
  1200. swCheckCodeID();
  1201. CALLADDR((CBYTE*)0xc406);
  1202. }
  1203. #endif
  1204. #if(S_SupportFM)
  1205. void FM_SeekISP(void)
  1206. gxNewCodeID=1;
  1207. swCheckCodeID();
  1208. CALLADDR((CBYTE*)0xc400);
  1209.     GUI_FM_ShowChanISP();
  1210. }
  1211. #endif
  1212. void FMStandbyISP()
  1213. {
  1214. }
  1215. CBYTE CB_MENUNUM2ISP[]={
  1216.     1,  // MP3
  1217.     1,  // WAV
  1218. 1,  // FM
  1219. 1, // voice record
  1220. 1, // FM record
  1221.     7,  // SETTING (J)there are 7 options under seeting
  1222.     2,  // RECORd
  1223.     1  // FM
  1224. };
  1225. CBYTE CB_MENUNUM3ISP[]=  {
  1226.     7, //EQ
  1227.     5, //REPEAT
  1228.     3, //LCD
  1229.     19, //LANGUAGE
  1230.     0, //delete
  1231.     6, //AUTO OFF
  1232.     3, //select drive
  1233.     4, //BACKLIGHT
  1234.     6, //CONTRAST
  1235. };
  1236. CBYTE CB_FIGINDEX3ISP[]=  {
  1237.     0x10,  //(J)the offset of the first picture of EQ option                                                                                                                                                                                                                                                                                                                                                                                                                                                             
  1238.     0x17,  //(J)the offset of the first picture of REPEAT                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  1239.     0x1c,  //(J)the offset of the first picture of Screen                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  1240.     0x29,  //(J)the offset of the first picture of Language                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  1241.     40,  //(J)the offset of the first picture of DELETE => this is a fake one for no picture for delete option                                                                                                                                                                                                                                                                                                                                                                                                         
  1242.     0x3f,  //(J)the offset of the first picture of auto Power Off time 
  1243.     0x3c, //   the offset of the first picture of select deivce
  1244.     0x25,  //(J)the offset of the first picture of backlight time     
  1245.     0x1f  //(J)the offset of the first picture of Contrast option  
  1246. };
  1247. /////////////////////////////////////////(GM3)
  1248. CBYTE T_ContrastValue[]={18,20,24,28,32};
  1249. void ShowSelMenuISP()
  1250. {
  1251. #if (S_SupportLcm)  
  1252.     if ( XB_MENULayer[2] == 8)     //contrast
  1253.     {
  1254. if(XB_MENULayer[3]<5)
  1255. gxTemp0=XB_MENULayer[3];
  1256. else
  1257. gxTemp0=XB_ADJ_Contrast;    
  1258.     
  1259.         lcmWriteCmd(0x81);             //BRIGHTNESS CONTROLL
  1260.         lcmWriteCmd(T_ContrastValue[gxTemp0]);//BRIGHTNESS CONTROLL
  1261.     }
  1262.     
  1263.     GUI_ShowMenu(XB_MENULayer[3]+CB_FIGINDEX3[XB_MENULayer[2]]);
  1264. #endif
  1265. }      
  1266.                        
  1267. /////////////////////////////////////////(GM3)
  1268. void MP3PlayStartISP(void)
  1269. {
  1270. gxNewCodeID=6;
  1271.     swCheckCodeID();
  1272. CALLADDR((CBYTE*)0xc400);
  1273. if(XB_File_CurrentType==WMAFILE)
  1274. {
  1275. if(M_ChkWithId3Tag)
  1276. {
  1277. MOVESRAM_XX(gxarWMATagBuf,gxarWMATag,128);
  1278.      gxTemp0=1;
  1279. Unicode2Big5ISP();
  1280. XB_StringPtr=0; //(GM27)
  1281. }
  1282. }
  1283. #if(!S_CS42L51)
  1284. M_ClrEnableRampUpVolume;
  1285. // gx10P10mSCnt1=0;
  1286. #endif
  1287. }
  1288. void SELFILEISP(void)
  1289. {
  1290. //RampDownToMuteISP();
  1291. if(!XB_NoFile&&(!gbPauseMode))
  1292.     {
  1293.      RampDownToMuteISP();
  1294.         gxNewCodeID=0; //(J)call ForwardFileISP()
  1295.         if(gxTemp0)  
  1296.         {
  1297.          //(J)call BackwardFileISP();
  1298. swCheckCodeID();
  1299. CALLADDR((CBYTE*)0xc409);
  1300. M_SetBackwardFile;
  1301.         }
  1302.         else      
  1303.         {
  1304.          //(J)call ForwardFileISP();
  1305. swCheckCodeID();
  1306. CALLADDR((CBYTE*)0xc40C);
  1307. M_ClrBackwardFile;
  1308.         }
  1309.         SelPlayFile(SET_BIT1 | SET_BIT0);
  1310.         if(gbPlayMode)   
  1311.         {
  1312.          if(XB_File_CurrentType==C_SubDir)
  1313.          {
  1314.          SET_PLAYMODE(C_FileSelectMode);
  1315.          M_ClrDataFormatError;
  1316.          }
  1317.          else
  1318.          MP3PlayStartISP();
  1319.         }
  1320.     }
  1321. }
  1322. /**/
  1323. void FFKeyProcISP()
  1324.     switch (XB_MENULayer[0])
  1325.     {
  1326.         case 0:
  1327.         
  1328.          gxTemp0=0;
  1329.             SELFILEISP();
  1330.             
  1331.             //SELFILE(0);
  1332.             break;
  1333.             
  1334. //        case 1: //volumn control
  1335. //            break;
  1336.         case 2: 
  1337.             if(XB_MENULayer[1]<7)
  1338.              XB_MENULayer[1]++;
  1339.             else
  1340.              XB_MENULayer[1]=0;
  1341.             
  1342.             
  1343.             if ((XB_MENULayer[1] == 1) && !WithREC) XB_MENULayer[1]++; //(J)No Recorder function => skip Voice Playback option
  1344.             if ((XB_MENULayer[1] == 2) && !WithFM) XB_MENULayer[1]++; //(J)No FM function => skip FM record option
  1345.             if ((XB_MENULayer[1] == 3) && !WithREC) XB_MENULayer[1]++; //(J)No Recorder function => skip Voice record option
  1346.             if ((XB_MENULayer[1] == 4) && !WithFM) XB_MENULayer[1]++; //(J)No FM function => skip FM record option
  1347.             if (WithREC&&(XB_MENULayer[1] >= 7)) XB_MENULayer[1]=0; //(J)Add this line if EXIT option is not needed
  1348.             ;//GUI_ShowMenu(XB_MENULayer[1]);
  1349.             break;
  1350.             
  1351.         case 3: 
  1352.             XB_MENULayer[2]++;
  1353. #if((S_CombineStor)||(!S_SupportMemoryCard))
  1354.             if(XB_MENULayer[2]==6) XB_MENULayer[2]++; //(J)check if need skip device select
  1355. #endif            
  1356.             if (XB_MENULayer[2]>= CB_MENUNUM2[XB_MENULayer[1]]) //(J)check boundary of Menu layer 2 
  1357.              XB_MENULayer[2]=0;
  1358.             
  1359.            // GUI_ShowMenu(XB_MENULayer[2]+C_FirstSettingPicture); //(J)Show picture for current option
  1360.             break;    
  1361.             
  1362.         case 4: 
  1363.             XB_MENULayer[3]++;
  1364.             if (XB_MENULayer[3]>=CB_MENUNUM3ISP[XB_MENULayer[2]]) //(J)Check boundary of Menu layer 3 
  1365.              XB_MENULayer[3]=0;
  1366.             
  1367.             if (XB_MENULayer[2]==0) //(J)for real time change EQ effect when different EQ is selected 
  1368.             {
  1369.              if(XB_MENULayer[3]<6)
  1370. gxTempR=XB_MENULayer[3];
  1371. else
  1372. gxTempR=XB_ADJ_EQMode;
  1373. if(!XB_FileType&&!gbFMMode) //(GM20)
  1374. {
  1375. WRITE_DSPIO(0x44,gxTempR);
  1376. EQVolumeControl(gxTempR);//(GM25)
  1377. }
  1378.             }
  1379.             
  1380.             //ShowSelMenuISP();
  1381.             break;  
  1382.             
  1383. //        case 5:   
  1384. //            break;
  1385.                  
  1386. //        case 6:
  1387. //            break;
  1388.             
  1389.         case 7:  //DELETE
  1390.             //ForwardFile();
  1391.             gxNewCodeID=0; //(J)call ForwardFileISP();//(GM6)
  1392.          swCheckCodeID();
  1393. CALLADDR((CBYTE*)0xc40C);
  1394.             SelPlayFile(SET_BIT1);
  1395.             break;    
  1396. //        case 8:
  1397.             //FORMAT
  1398. //            break;
  1399.             
  1400.         case 9:
  1401.             //wait key
  1402.             //WaitKeyProcess();
  1403.             break;    
  1404.              
  1405.         case 10:
  1406. #if(S_SupportFM)
  1407.             //FM
  1408.             //XB_FM_RunSeek=1;
  1409.             gxFMSeekDir=1;
  1410.             FM_SeekISP();
  1411. #endif
  1412.             break;  
  1413.             
  1414. //        case 11:
  1415. // RECORD
  1416. //          break;
  1417.     }   
  1418. }
  1419.  
  1420. void BFKeyProcISP()
  1421. {
  1422.     switch (XB_MENULayer[0])
  1423.     {
  1424.         case 0:
  1425.             gxTemp0=1;
  1426.             SELFILEISP();
  1427.             //SELFILE(1);
  1428.             break;
  1429.   
  1430.         case 2: 
  1431.             if(XB_MENULayer[1])
  1432.              XB_MENULayer[1]--;
  1433.             else
  1434.              XB_MENULayer[1]=7;
  1435.             
  1436.             if (XB_MENULayer[1] == 7) XB_MENULayer[1]--; //(J)if you don't need EXIT option
  1437.             if ((XB_MENULayer[1] == 4) && !WithFM) XB_MENULayer[1]--; //(J)No FM => No FM record option
  1438.             if ((XB_MENULayer[1] == 3) && !WithREC)  XB_MENULayer[1]--; //(J)No Record => No Voice Record option
  1439.             if ((XB_MENULayer[1] == 2) && !WithFM)  XB_MENULayer[1]--; //(J)No FM => No FM option
  1440.             if ((XB_MENULayer[1] == 1) && !WithREC) XB_MENULayer[1]--; //(J)No Record => No Voice Playback option
  1441. //GUI_ShowMenu(XB_MENULayer[1]);
  1442.             break;
  1443.             
  1444.         case 3: 
  1445.             XB_MENULayer[2]--;
  1446.             if (XB_MENULayer[2] >= CB_MENUNUM2[XB_MENULayer[1]]) XB_MENULayer[2]=CB_MENUNUM2[XB_MENULayer[1]]-1;
  1447. #if((S_CombineStor)||(!S_SupportMemoryCard))
  1448.             if(XB_MENULayer[2]==6) XB_MENULayer[2]--; //(J)check if need skip device select
  1449. #endif     
  1450.             //GUI_ShowMenu(XB_MENULayer[2]+C_FirstSettingPicture);
  1451.             break;  
  1452.               
  1453.         case 4: 
  1454.             XB_MENULayer[3]--;
  1455.             if (XB_MENULayer[3] >= CB_MENUNUM3ISP[XB_MENULayer[2]]) XB_MENULayer[3]=CB_MENUNUM3ISP[XB_MENULayer[2]]-1;
  1456.             if (XB_MENULayer[2]==0) //(J)for real time change EQ effect when different EQ is selected 
  1457.             {
  1458.              if(XB_MENULayer[3]<6)
  1459. gxTempR=XB_MENULayer[3];
  1460. else
  1461. gxTempR=XB_ADJ_EQMode;
  1462. if(!XB_FileType&&!gbFMMode) //(GM20)
  1463. {
  1464. WRITE_DSPIO(0x44,gxTempR);
  1465. EQVolumeControl(gxTempR);//(GM25)
  1466. }
  1467.             }
  1468.             //ShowSelMenuISP();
  1469.             break;  
  1470.             
  1471. //        case 5: 
  1472. //            break;  
  1473.             
  1474. //        case 6:
  1475. //            break;    
  1476.             
  1477.         case 7:  //DELETE
  1478.             //BackwardFile();
  1479.             gxNewCodeID=0; //(J)call BackwardFileISP();//(GM6)
  1480. swCheckCodeID();
  1481. CALLADDR((CBYTE*)0xc409);
  1482.             SelPlayFile(SET_BIT1);
  1483.             break;
  1484.             
  1485. //        case 8:
  1486.             //FORMAT
  1487. //            break;
  1488.         case 9:
  1489.             //wait key
  1490.           //  WaitKeyProcess();
  1491.             break;  
  1492.             
  1493.         case 10:
  1494. #if(S_SupportFM)
  1495.             //FM
  1496.             //XB_FM_RunSeek=1;
  1497.             gxFMSeekDir=0;
  1498.             FM_SeekISP();
  1499. #endif
  1500.             break; 
  1501. //        case 11:
  1502.             //RECORD
  1503. //            break;
  1504.     }
  1505. }
  1506. void REC_return()
  1507. {
  1508. if( (SoundFlag&0x10)||(DirFlag&0x20) )
  1509. {
  1510. StopREC();
  1511. {
  1512. WavToMp3();
  1513. InLastLevel();
  1514. DirFlag&=0xdf;
  1515. }
  1516. }
  1517. }
  1518. void BaseSCMCST()
  1519. {
  1520. REC_return();
  1521. SelectFolderCountUpDown();
  1522. //root ok
  1523. InLastLevel();
  1524. LR_CountNum=0;
  1525. }
  1526. void MoveFile()
  1527. {
  1528. FFKeyProcISP();
  1529. if(gxarFileName[2]=='.')
  1530. FFKeyProcISP();
  1531. }
  1532. void FolderFunctionNumberTest()//ok
  1533. {
  1534. if(FolderFunctionNumberFlag==1)
  1535. FunctionTest=LastST;
  1536. if(FolderFunctionNumberFlag==2)
  1537. FunctionTest=LastSC;
  1538. /*
  1539. if(FolderFunctionNumberFlag==3)
  1540. FunctionTest=LastMC;
  1541. */
  1542. #if 1
  1543. BaseSCMCST();
  1544. while(1)
  1545. {
  1546. if(FolderFunctionNumberFlag==1)
  1547. {
  1548.     if((gxarFileName[2]=='S')&&(gxarFileName[3]=='T') )
  1549. break;
  1550. else
  1551. FFKeyProcISP();
  1552. }
  1553. if(FolderFunctionNumberFlag==2)
  1554. {
  1555.     if((gxarFileName[2]=='S')&&(gxarFileName[3]=='O') )
  1556. break;
  1557. else
  1558. FFKeyProcISP();
  1559. }
  1560. }
  1561. PlayKeyIsp();//play nusic
  1562. //autoplay
  1563. //FunctionTest=gx16CurrentDirFileIndex;
  1564. FunctionTest|=0x80;
  1565. #else
  1566. if(0==(FunctionTest&0x80))
  1567. {
  1568. BaseSCMCST();
  1569. while(1)
  1570. {
  1571. if(FolderFunctionNumberFlag==1)
  1572. {
  1573.     if((gxarFileName[2]=='S')&&(gxarFileName[3]=='T') )
  1574. break;
  1575. else
  1576. FFKeyProcISP();
  1577. }
  1578. if(FolderFunctionNumberFlag==2)
  1579. {
  1580.     if((gxarFileName[2]=='S')&&(gxarFileName[3]=='C') )
  1581. break;
  1582. else
  1583. FFKeyProcISP();
  1584. }
  1585. if(FolderFunctionNumberFlag==3)
  1586. {
  1587.     if((gxarFileName[2]=='M')&&(gxarFileName[3]=='C') )
  1588. break;
  1589. else
  1590. FFKeyProcISP();
  1591. }
  1592. }
  1593. PlayKeyIsp();//in sc fold
  1594. DirFlag|=0x04;
  1595. if(FunctionTest&0x7f )
  1596. {
  1597. while(gxarFileName[3]!='0'+( FunctionTest&0x0f)  )
  1598. FFKeyProcISP();//last point
  1599.  MoveFile();
  1600. }
  1601. FunctionTest=gx16CurrentDirFileIndex;
  1602. PlayKeyIsp();//play nusic
  1603. FunctionTest|=0x80;//0x80 now is sc
  1604. }
  1605. else
  1606. {
  1607. FFKeyProcISP();
  1608. FunctionTest=gx16CurrentDirFileIndex;
  1609. FunctionTest|=0x80;
  1610. }
  1611. #endif
  1612. if(FolderFunctionNumberFlag==1)
  1613. LastST=FunctionTest;
  1614. if(FolderFunctionNumberFlag==2)
  1615. LastSC=FunctionTest;
  1616. if(FolderFunctionNumberFlag==3)
  1617. LastMC=FunctionTest;
  1618. }
  1619. void FolderFunctionNumberTest1()//ok
  1620. {
  1621. // if(FolderFunctionNumberFlag==3)
  1622. FunctionTest=LastMC;
  1623. if(0==(FunctionTest&0x80))
  1624. {
  1625. REC_return();
  1626. SelectFolderCountUpDown();
  1627. //root ok
  1628. LR_CountNum=0;
  1629. // BaseSCMCST();
  1630. while(1)
  1631. {
  1632. {
  1633.     if((gxarFileName[2]=='B')&&(gxarFileName[3]=='T') )
  1634. break;
  1635. else
  1636. FFKeyProcISP();
  1637. }
  1638. }
  1639. PlayKeyIsp();//in BMT/MC fold
  1640. DirFlag|=0x08;
  1641. if(FunctionTest&0x7f )
  1642. {
  1643. while(gxarFileName[3]!='0'+( FunctionTest&0x0f)  )
  1644. FFKeyProcISP();//last point
  1645.  MoveFile();
  1646. }
  1647. FunctionTest=gx16CurrentDirFileIndex;
  1648. PlayKeyIsp();//play nusic
  1649. FunctionTest|=0x80;//0x80 now is sc
  1650. }
  1651. else
  1652. {
  1653. FFKeyProcISP();
  1654. FunctionTest=gx16CurrentDirFileIndex;
  1655. FunctionTest|=0x80;
  1656. }
  1657. LastMC=FunctionTest;
  1658. }
  1659. void LRtest1()//ok
  1660. {
  1661. FunctionTest=LastLR;
  1662. BaseSCMCST();
  1663. // LR fold
  1664. while(1)
  1665. {
  1666. if((gxarFileName[2]=='L')&&(gxarFileName[3]=='R') )
  1667. break;
  1668. else
  1669. FFKeyProcISP();
  1670. }
  1671. PlayKeyIsp();//in lr fold
  1672. DirFlag|=0x04;
  1673. //LR_CountNum|=0x40;
  1674. if(0==(FunctionTest&0x80))
  1675. {
  1676. PlayKeyIsp();//play nusic
  1677. FunctionTest=1;
  1678. FunctionTest|=0x80;//0x80 now is sc
  1679. //LR_CountNum=1;
  1680. LR_CountNum|=0x40;
  1681. }
  1682. else
  1683. {
  1684. if(FunctionTest&0x7f )
  1685. {
  1686. if((  1+(FunctionTest&0x0f)   )==(gx16TotalSubDirInCurrentDir+gx16TotalPlayFileInCurrentDir))
  1687. { LastMC=0;
  1688. FunctionTest=0;
  1689. }
  1690. while(gxarFileName[5]!='0'+( FunctionTest&0x0f)+1  )
  1691. FFKeyProcISP();//last point
  1692. }
  1693. PlayKeyIsp();//play nusic
  1694. FunctionTest=gx16CurrentDirFileIndex;
  1695. FunctionTest|=0x80;
  1696. LR_CountNum|=0x40;
  1697. }
  1698. LastLR=FunctionTest;
  1699. }
  1700. #if 0
  1701. void LRtest()//ok
  1702. {//LR start
  1703. #if 0
  1704. BaseSCMCST();
  1705. // sc等 fold
  1706. while(1)
  1707. {
  1708. if((gxarFileName[2]=='L')&&(gxarFileName[3]=='R') )
  1709. break;
  1710. else
  1711. FFKeyProcISP();
  1712. }
  1713. PlayKeyIsp();//in lr fold
  1714. PlayKeyIsp();//play nusic
  1715. DirFlag|=0x04;
  1716. LR_CountNum=1;
  1717. LR_CountNum|=0x80;//80
  1718. #endif
  1719. }
  1720. void LRtestNext()//ok
  1721. {
  1722. #if 0
  1723. XBYTE temp0;
  1724. //root
  1725. WavToMp3();//InMP3();
  1726. //root ok
  1727. InLastLevel();
  1728. while(gxarFileName[3]!='R')
  1729. FFKeyProcISP();
  1730. PlayKeyIsp();//in LR fold
  1731. //enter                                next LR file
  1732. if(DirFlag&0x10)
  1733. {
  1734. //DirFlag&=0xef;
  1735. SoundFlag=0;
  1736. DirFlag&=0x4c;
  1737. }
  1738. else
  1739. {
  1740. //change level
  1741. //enter LR
  1742. while(gx16CurrentDirFileIndex<(LR_CountNum&0x0f) )
  1743. {
  1744. FFKeyProcISP();
  1745. }
  1746. PlayKeyIsp();//play nusic
  1747. LR_CountNum=LR_CountNum&0x0f;
  1748. LR_CountNum|=0x40;
  1749. if(gx16TotalPlayFileInCurrentDir==(LR_CountNum&0x0f))
  1750. {
  1751. DirFlag|=0x10;
  1752. }
  1753. }
  1754. DirFlag|=0x04;
  1755. #endif
  1756. }
  1757. #endif
  1758. void MENUKeyProcISP()
  1759.     switch (XB_MENULayer[0])
  1760.     {
  1761.         case 0:
  1762. case 10:
  1763. if(M_ChkFMAutoScan) //(GM8)
  1764. {
  1765. /*
  1766. XB_FM_SeekDir=1;
  1767. XB_FM_RunSeek=2;
  1768. lcmClearLCM();
  1769. M_ClrFMAutoScan;
  1770. */
  1771. }
  1772. else
  1773. {
  1774.             ClrMenuLayer();
  1775.             XB_MENULayer[0]=2;
  1776.             GUI_ShowMenu(XB_MENULayer[1]);
  1777.         }
  1778.             break;
  1779.         case 1:
  1780.             GotoMainPorg();
  1781.             break;
  1782.             
  1783.         case 2: 
  1784.             switch (XB_MENULayer[1])
  1785.             {
  1786.                 case 0: //mp3 play
  1787.                     //PLL_ON;
  1788.                     PLLTurnOn();
  1789.   if (XB_FileType||gbFMMode)
  1790.                     { 
  1791. //yu5                     FMStandbyISP();                  
  1792.                         gx16PlayIndex=0;   
  1793.                         XB_FileType=0;
  1794.                      ClrMenuLayer(); 
  1795.                      i2cInitialCS42L51(0);
  1796.                      if(gbDirMode)
  1797.     {
  1798. gx16PlayDirIndex=0; //(J)start from root dir
  1799.      fatInitDirMode();
  1800.      gx16CurrentDirFileIndex=0;
  1801.     }
  1802.     SET_PLAYMODE(C_FileSelectMode);
  1803.                      GotoSelFileMode();
  1804.                     }
  1805.                     else
  1806.                      GotoMainPorg();
  1807.                     break;
  1808.                     
  1809.                 case 1: //wav play
  1810.                     //PLL_ON;
  1811.                     PLLTurnOn();
  1812.                 if (!XB_FileType||gbFMMode)
  1813.                     {
  1814. //yu5                     FMStandbyISP();  
  1815.                         gx16PlayIndex=0;   
  1816.                         XB_FileType=1;
  1817.                         ClrMenuLayer(); 
  1818.                     i2cInitialCS42L51(0);
  1819.                     GotoSelFileMode();
  1820.                     }
  1821.                     else
  1822.                    GotoMainPorg();
  1823.                     break;
  1824.                     
  1825.                 case 2:  //FM
  1826. /*
  1827.                  //PLL_ON;
  1828.                  PLLTurnOn();
  1829.                     gxNewCodeID=1; //(G) call FMProcedure
  1830. swCheckCodeID();
  1831. CALLADDR((CBYTE*)0xc415);
  1832. */
  1833.                     break;
  1834.                                         
  1835.                 case 3: //record
  1836.                 case 4: //record
  1837.                  //PLL_ON;
  1838.                  PLLTurnOn();
  1839.                  gxNewCodeID=3; //(G)call RecordProcedure()
  1840. swCheckCodeID();
  1841. CALLADDR((CBYTE*)0xc403);                    
  1842. if (gbSelectFileMode) //(G)if with gDiskErrorCode
  1843. {
  1844. RampDownToMuteISP();
  1845. i2cInitialCS42L51(0);
  1846. #if(S_SupportFM)
  1847. if(gbFMMode)
  1848. FMStandbyISP();
  1849. #endif
  1850. }
  1851. #if(!S_SupportAudioADC)
  1852. else
  1853. {
  1854. gxRampVolume=C_DSPVolumeValue[XB_ADJ_CurrentV]; //(GM25)
  1855. I2CVolumeControlISP();
  1856. CodeI2C_CS_LOW;
  1857. }
  1858. #endif
  1859.                     break;    
  1860. case 5: //setting
  1861.                     XB_MENULayer[0]=3;  
  1862.                     GUI_ShowMenu(C_FirstSettingPicture);
  1863.                     break;
  1864. /*                    
  1865.                 case 6://Show Version
  1866. XB_MENULayer[0]=9;
  1867. GUI_ShowMenu1(C_VersionPageOffset);
  1868. //lcmClearLCM();
  1869. //fatCheckFreeSize(); //(GM1)
  1870. //gxTemp0=0;
  1871. //ShowRemainCapacity();
  1872. break;
  1873. default:
  1874.             GotoMainPorg();
  1875. break;     
  1876. */
  1877.             } 
  1878.             break;
  1879.             
  1880.         case 3: 
  1881.             XB_MENULayer[0]=4;  
  1882.             switch (XB_MENULayer[2])
  1883.             {
  1884. /*
  1885.                 case 0:  //EQ SETTING
  1886.                     XB_MENULayer[3]=XB_ADJ_EQMode;   
  1887.                     ShowSelMenuISP();
  1888.                     break;
  1889.                 case 1:  //REPEAT
  1890.                     XB_MENULayer[3]=gxRepeatMode; 
  1891.                     ShowSelMenuISP();
  1892.                     break;
  1893.                 case 2:  //LCD
  1894.                     XB_MENULayer[3]=0;
  1895.                     ShowSelMenuISP();
  1896.                     break;
  1897.                 case 3:  //LANGUAGE
  1898.                     XB_MENULayer[3]=XB_ADJ_Language;//(GM3)
  1899.                     ShowSelMenuISP();
  1900.                     break;
  1901. */
  1902.                 case 4:  //DELETE
  1903.                  if((gbFMMode)||(XB_NoFile))
  1904. {
  1905. GotoMainPorg();
  1906. }
  1907. else
  1908. {
  1909. gxNewCodeID=5; // call InitDelProcessISP() //(GM4)
  1910. swCheckCodeID();
  1911. CALLADDR((CBYTE*)0xc400);    
  1912.          
  1913.      SelPlayFile(SET_BIT1);
  1914.                     }
  1915.                     break;    
  1916.  /*                                            
  1917.                 case 5:  //AUTO OFF
  1918.                     XB_MENULayer[3]=XB_ADJ_AutoOff; 
  1919.                     ShowSelMenuISP();
  1920.                     break;
  1921. case 6:
  1922.                     XB_MENULayer[3]=gxMp3Storage; 
  1923.                     ShowSelMenuISP();                       
  1924. break;
  1925.                 case 7:  //exit
  1926.                     GotoMainPorg();
  1927.                     break;
  1928. */
  1929.             } 
  1930.             
  1931.             break;    
  1932.               
  1933.         case 4: 
  1934.          if(XB_MENULayer[3]>=(CB_MENUNUM3ISP[XB_MENULayer[2]]-1)) //(J)for exit item
  1935.      {
  1936.      GotoMainPorg();
  1937.      }
  1938.      else
  1939.      {
  1940.             switch (XB_MENULayer[2])
  1941.             {
  1942. /*
  1943.                 case 0:  //EQ SETTING
  1944.                     ProcessEQSet(XB_MENULayer[3]);
  1945.                     GotoMainPorg();
  1946.                     break;
  1947.                 case 1:  //REPEAT
  1948.                     ProcessRepeatSet(XB_MENULayer[3]);
  1949.                     GotoMainPorg();
  1950.                     break;
  1951.                 case 2:  //LCD
  1952.                     if (XB_MENULayer[3]==1)
  1953.                     {
  1954.                         XB_MENULayer[2]=7;
  1955.                         XB_MENULayer[3]=XB_ADJ_BLTimer; 
  1956.                         if(XB_MENULayer[3]>2) XB_MENULayer[3]=0; 
  1957.                     }
  1958.                     else if (XB_MENULayer[3]==0)
  1959.                     {
  1960.                         XB_MENULayer[2]=8;
  1961.                         XB_MENULayer[3]=XB_ADJ_Contrast;  
  1962. if(XB_MENULayer[3]>4) XB_MENULayer[3]=0;
  1963.                     }
  1964.                     ShowSelMenuISP();
  1965.                     break;
  1966.                     
  1967.                 case 3:  //LANGUAGE
  1968.                  XB_ADJ_Language=XB_MENULayer[3];
  1969.                     ProcessLanguageSetISP();//(GM3)
  1970.                     GotoMainPorg();
  1971.                     break;
  1972. */                     
  1973.                 case 4:  //DELETE
  1974.                  break;
  1975.                 
  1976. /*
  1977.                 case 5:  //AUTO OFF
  1978.                     ProcessAutoOffSet(XB_MENULayer[3]);
  1979.                     GotoMainPorg();
  1980.                     break;
  1981.                 case 6: //select device
  1982.                  if(gxMp3Storage!=XB_MENULayer[3])
  1983.                  {
  1984.                  gxMp3Storage=XB_MENULayer[3];
  1985.                  Process_STOP();
  1986.                  CHG_MediaType(gxMp3Storage);
  1987.     XB_GUI_FLAG=1;
  1988.                  ChkCARDInOut0ISP();
  1989.                  //ChkCARDInOut0(1);
  1990.                  //gxScanFreeSizeflag[gxMp3Storage]=0;//(GM1)
  1991.                  //fatCheckFreeSize();
  1992.                  }
  1993.                  else
  1994.                  GotoMainPorg();
  1995.                  break;    
  1996.                 case 7:  //BACKLIGHT
  1997.                     ProcessBLSet(XB_MENULayer[3]);
  1998.                     GotoMainPorg();
  1999.                     break;
  2000.                 case 8:  //CONTRAST
  2001.                     ProcessContrastSet(XB_MENULayer[3]);
  2002.                     GotoMainPorg();
  2003.                     break;     
  2004. */
  2005.             } 
  2006.         }
  2007.             break; 
  2008.             
  2009. //        case 5:
  2010. //            break;
  2011. //        case 6:
  2012. //            break;
  2013.         case 7:     //DELETE
  2014.          if(XB_File_CurrentType!=C_SubDir)
  2015.          {
  2016. /*(G)move to DeleteProcedure()
  2017. #if(S_SupportMemoryCard)
  2018.         if((gxMp3Storage==1)&&(!nCardWPRO))
  2019.         {
  2020.          LCM_xp=0;
  2021.      LCM_yp=0;
  2022.          GUI_ShowSmallString((XBYTE*)(Str_SDWriteProtect));
  2023.          delay500ms();
  2024.          delay500ms();
  2025.          LCM_xp=0;
  2026.          GUI_ShowSmallString((XBYTE*)(Str_Space));
  2027.          LCM_xp=0;
  2028.          GUI_ShowSmallString((XBYTE*)(T_AskDelete));
  2029.         }
  2030.         else
  2031. #endif         
  2032. */
  2033.         {
  2034. gxNewCodeID=5; //(G) call DeleteProcedure
  2035. swCheckCodeID();
  2036. CALLADDR((CBYTE*)0xc403);
  2037. }
  2038.             if(XB_NoFile)
  2039.             {
  2040.                 GotoMainPorg();
  2041.             }
  2042.             else
  2043.             {
  2044. #if(S_CombineStor)
  2045. gxNewCodeID=0; //(GM6)call ChkSwitchFatParameter
  2046. swCheckCodeID();
  2047. CALLADDR((CBYTE*)0xc415);
  2048. #endif             
  2049.                 SelPlayFile(SET_BIT1);        
  2050.             }
  2051.         }
  2052.             break;
  2053. //        case 8:
  2054.             //FORMAT
  2055. //            break;
  2056.         case 9:
  2057.             //wait key
  2058. //            WaitKeyProcess();
  2059.             break;    
  2060. //        case 10:
  2061.             //FM
  2062. //            GotoMainPorg();
  2063. //            break; 
  2064. //        case 11:
  2065.             //RECORD
  2066. //            break;
  2067.         }      
  2068. }
  2069. void UpdateCMPCNT()
  2070. {
  2071.     if(XB_PLL_MODE>=10)
  2072.      CMPCNT=CB_CMPCNT_Code1[XB_PLL_MODE-9];
  2073. }
  2074. void StopBase()
  2075. {
  2076. if( gbPlayMode || gbPauseMode)
  2077. StopKeyProc();
  2078. }
  2079. void SelectFolderCountUpDown()
  2080. {
  2081. SoundFlag=0;
  2082. //Play music
  2083. //stop key
  2084. StopBase();
  2085. /*
  2086. if( gbPlayMode || gbPauseMode)
  2087. {
  2088. //lcmClearLCM();
  2089. StopKeyProc();
  2090. // M_SetStopKeyFunction;
  2091. }
  2092. */
  2093. //stop music
  2094. //to ..
  2095. if(DirFlag&0x04)
  2096. {
  2097. DirFlag&=0xFB;
  2098. ReturnUpFold();
  2099. }
  2100. //return folder1 st sc
  2101. if(DirFlag&0x40)
  2102. {
  2103. DirFlag&=0xbf;
  2104. ReturnUpFold();
  2105. }
  2106. //return ABC
  2107. if(DirFlag&0x08)
  2108. {
  2109. DirFlag&=0xf7;
  2110. ReturnUpFold();
  2111. }
  2112. //return root  level 1-12
  2113. DirFlag=0;
  2114. LastST&=0x7f;
  2115. LastMC&=0x7f;
  2116. LastSC&=0x7f;
  2117. LastLR&=0x7f;
  2118. }
  2119. void InLastLevel()
  2120. {
  2121. //in common
  2122. DispFolderNumber(SelectFolderCount);
  2123. gxTempR=(SelectFolderCount-1)/3+1;
  2124. if(gxTempR<10)
  2125. {
  2126. while(gxarFileName[6]!=('0'+gxTempR ) )
  2127. FFKeyProcISP();
  2128. }
  2129. else if(gxTempR==10)
  2130. {
  2131. while(gxarFileName[6]!='A'  )
  2132. FFKeyProcISP();
  2133. }
  2134. else if(gxTempR==11)
  2135. {
  2136. while(gxarFileName[6]!='B' )
  2137. FFKeyProcISP();
  2138. }
  2139. else if(gxTempR==12)
  2140. {
  2141. while(gxarFileName[6]!='C'  )
  2142. FFKeyProcISP();
  2143. }
  2144. PlayKeyIsp();//in level 1-12
  2145. DirFlag|=0x40;
  2146. gxTempR=(SelectFolderCount-1)%3+1;
  2147. {
  2148. if(gxTempR==1)
  2149. {
  2150. while(gxarFileName[6]!='1'  )
  2151. FFKeyProcISP();
  2152. }
  2153. else if(gxTempR==2)
  2154. {
  2155. while(gxarFileName[6]!='2' )
  2156. FFKeyProcISP();
  2157. }
  2158. else// if(gxTempR==3)
  2159. {
  2160. while(gxarFileName[6]!='3'  )
  2161. FFKeyProcISP();
  2162. }
  2163. //while(gxarFileName[9]!='A'+gxTempR  )
  2164. //FFKeyProcISP();
  2165. }
  2166. PlayKeyIsp();
  2167. DirFlag|=0x08;
  2168. }
  2169. void FolderCountUpDownProcess()
  2170. {
  2171. REC_return();
  2172. /*
  2173. if( (SoundFlag&0x10)||(DirFlag&0x20) )
  2174. {
  2175. SoundFlag=0;
  2176. DirFlag=0;
  2177. LR_CountNum&=0x0f;
  2178. }
  2179. */
  2180. LR_CountNum=0;
  2181. SelectFolderCountUpDown();
  2182. InLastLevel();//SelectFolderCountUpBase();
  2183. DispFolderFunctionNumber(5);
  2184. }
  2185. void Process_sayPoint()
  2186. {
  2187. }
  2188. void ReturnUpFold()
  2189. {
  2190. while(gxarFileName[2]!='.')
  2191. BFKeyProcISP();
  2192. PlayKeyIsp();
  2193. }
  2194. void PlayKeyFunctionISP(void)
  2195. {
  2196. if(SoundFlag&0x04)
  2197. {
  2198. gxKeyCode=0;
  2199. return;
  2200. }
  2201. if (M_ChkPlayKeyFunction)
  2202.     {
  2203.      M_ClrPlayKeyFunction;
  2204.         ClrAutoOffTmrISP(); //(J)reset all power off counter AutoOffTmrH,AutoOffTmrL
  2205. if(DirFlag&0x80)DirFlag&=0x7f;
  2206. /*
  2207. if((gxKeyCode==C_NextKey)||(gxKeyCode==C_PrevKey))
  2208. {
  2209. REC_return();
  2210. if( (SoundFlag&0x10)||(DirFlag&0x20) )
  2211. {
  2212. SoundFlag=0;
  2213. DirFlag=0;
  2214. LR_CountNum&=0x0f;
  2215. }
  2216. }
  2217. */
  2218.        
  2219.         
  2220.         switch(gxKeyCode)
  2221.         {
  2222. /*
  2223.             case C_HoldKey: //(J)Key lock => do nothing
  2224.                 break;  
  2225.  */               
  2226.             case C_RepeatKey:
  2227. if( gbPlayMode || gbPauseMode)
  2228. {
  2229. StopKeyProc(); //repeat  one
  2230. MP3PlayStartISP();
  2231. }
  2232.                break;  
  2233.                 
  2234.             case C_PlayKey:
  2235. if( (XB_File_CurrentType==C_SubDir)||(gbRecordMode) )
  2236. ;
  2237. else
  2238. PlayKeyIsp();
  2239.                 break;
  2240. /*                
  2241.             case C_StopKey:
  2242.                 StopKeyProc();
  2243.                 break;
  2244. */                
  2245.             case C_NextKey:
  2246. FolderFunctionNumberFlag=1;
  2247. FolderFunctionNumberTest();
  2248. DispFolderFunctionNumber(2);
  2249.                 break;
  2250.                 
  2251.             case C_PrevKey:
  2252. FolderFunctionNumberFlag=2;
  2253. FolderFunctionNumberTest();
  2254. DispFolderFunctionNumber(1);
  2255.                 break;
  2256. //SelectFolderCountDown();
  2257.              case C_VolumeUpKey:
  2258. /*
  2259. if(SoundFlag&0x02)
  2260. {
  2261. //SoundFlag&=0xfd;
  2262. LR_CountNum|=0x10;
  2263. }
  2264. else
  2265. */
  2266. {
  2267. DirFlag=0;PressIO_Key=0;
  2268. LR_CountNum=0;
  2269. SoundFlag&=0x1f;
  2270. }
  2271.   PlayRECFunction();
  2272.                break;
  2273.                 
  2274.                 
  2275.             case RecordingKey: //Use for menu
  2276. LR_CountNum=0;
  2277. if(SoundFlag&0x10)
  2278. {
  2279. PlayKeyIsp();//REC stop
  2280. SoundFlag=0;
  2281. DirFlag=0x20;//WAV 状态 
  2282. DispFolderFunctionNumber(5);
  2283. }
  2284. else
  2285. {
  2286. DirFlag=0;
  2287. SoundFlag=0x40;//
  2288. DelWavAll();
  2289. DispFolderFunctionNumber(6);
  2290. }
  2291.                 break;
  2292.              
  2293.             default:
  2294.              break;
  2295.         }
  2296.     }
  2297. }
  2298. //###################################################
  2299. void lyrSeekLyricISP(void)
  2300. {
  2301. #if 0
  2302. gxNewCodeID=2; //(J)call lyrSeekLyricISP()
  2303. swCheckCodeID();
  2304. CALLADDR((CBYTE*)0xc400);
  2305. #endif
  2306. }
  2307. void fatFileSeekISP(void)
  2308. {
  2309. gxNewCodeID=2;
  2310. swCheckCodeID();
  2311. CALLADDR((CBYTE*)0xc40f);
  2312. }
  2313. void fatFileReadInitISP(void)
  2314. {
  2315. if(M_ChkFileReadInit)
  2316.     {
  2317.      M_ClrFileReadInit;
  2318.      fatFileSeekISP();
  2319.      lyrSeekLyricISP();
  2320. }
  2321.     else if(XB_ABMode==2)
  2322.     {
  2323. #if(!S_CS42L51)   
  2324.      RampDownToMuteISP();//(GM22)* for DAC
  2325.      M_SetRampUpToVolume;
  2326. #endif
  2327. gxPlayTimeMin=gxPlayTimeMinA;
  2328.         gxPlayTimeSec=gxPlayTimeSecA;
  2329.         if (!XB_MENULayer[0] && !XB_MENULayer[1])
  2330.         {
  2331. /*
  2332.         if(XB_File_CurrentType==WAVFILE)
  2333.         {
  2334. uiUpdateMainDisplay((bit1+bit2));
  2335. LCM_yp=PofTime; //(GM12)
  2336. LCM_xp=AofTime;
  2337.      dispShowChar(CB_ASC[(gxPlayTimeHour%10)]);
  2338. }
  2339. else
  2340.          uiUpdateMainDisplay(bit1);
  2341. */
  2342.     }
  2343.         fatFileSeekISP();
  2344.         lyrSeekLyricISP();
  2345.     }
  2346. else
  2347.     {
  2348.         RampDownToMuteISP();
  2349.         if(gxRepeatMode<3)
  2350.         {
  2351.          //if(gxRepeatMode!=1)
  2352.             if((gxRepeatMode!=1)||M_ChkDataFormatError)//(N)_M 1 for repeate mode == 1
  2353.             {
  2354.              M_SetCallByFileInit;
  2355.              if(M_ChkBackwardFile) //(N)_M 1
  2356.              {
  2357.              gxNewCodeID=0; //call BackwardFileISP()
  2358. swCheckCodeID();
  2359. CALLADDR((CBYTE*)0xc409);             
  2360.              }
  2361.              else
  2362.              {
  2363.          //JM=>ForwardFile();  
  2364.          gxNewCodeID=0; //(J)call ForwardFileISP()
  2365. swCheckCodeID();
  2366. CALLADDR((CBYTE*)0xc40C);
  2367. }
  2368.          M_ClrCallByFileInit;
  2369.         }
  2370.         }
  2371.         else
  2372.         {  //RANDOM PLAY
  2373.             //JM=>uiRandomSelectSong();
  2374.             gxNewCodeID=0; //(J)call uiRandomSelectSongISP()
  2375. swCheckCodeID();
  2376. CALLADDR((CBYTE*)0xc40F);
  2377.         } 
  2378.         
  2379.         if(((!gxRepeatMode) && ((((!gbDirMode)||(XB_FileType==1))&&(gx16PlayIndex==0))||(gbDirMode&&(gx16CurrentDirFileIndex==0)))||(gx16DataFormatErrorCnt>=XW_TotalFile[XB_FileType]))) //(N)_M 1
  2380.         {
  2381.          gx16DataFormatErrorCnt=0; //(N)_M 1
  2382.          if(XB_MENULayer[0] || XB_MENULayer[1]) //(GM15)
  2383.          SET_PLAYMODE(C_FileSelectMode);
  2384.          else
  2385.          GotoSelFileMode();
  2386.         
  2387.          //JM=>M_ClrDataFormatError; //(J)this line will cause problem when only one error song in storage
  2388.         }
  2389.         else
  2390.         {
  2391.             SelPlayFile(SET_BIT1 | SET_BIT0);
  2392.             MP3PlayStartISP();
  2393.         }
  2394.     }
  2395. }
  2396. void GotoMainPorgISP()
  2397. {
  2398. if (XB_MENULayer[0]==4) //(GM7)
  2399. {
  2400. gxNewCodeID=2; //(G) call CheckEQandContrast()
  2401. swCheckCodeID();
  2402. CALLADDR((CBYTE*)0xc409);
  2403. if(gxReturnValue) //(GM25)
  2404. EQVolumeControl(XB_ADJ_EQMode);
  2405. }
  2406.     ClrMenuLayer();
  2407.    // lcmClearLCM();
  2408.     //JM=>GUI_SHOWBAT();
  2409. if(gbFMMode)
  2410. {
  2411. /*
  2412. M_ClrFMAutoScan; //(GM8)*
  2413. XB_MENULayer[0]=10;  //GOTO FM MODE
  2414.     SET_PLAYMODE(C_FMMode);
  2415. GUI_FM_ShowChanISP();
  2416. */
  2417. }
  2418. else if (gbRecordMode) //(GM9)
  2419. {
  2420. /*
  2421. XB_MENULayer[0]=11;
  2422. uiUpdateMainDisplay(bit1+bit2+bit3+bit4+bit7);
  2423. LCM_yp=PofTime; //(GM12)
  2424. LCM_xp=AofTime;
  2425.      dispShowChar(CB_ASC[(gxPlayTimeHour%10)]);
  2426. LCM_xp=0;
  2427.         LCM_yp=2;
  2428. GUI_ShowString((XBYTE*)(&gxarFileName[2]),0 );
  2429. gxTemp0=1;
  2430. ShowRemainCapacity();
  2431. */
  2432. }
  2433. else
  2434. {
  2435.     if (XB_NoFile)
  2436.     {
  2437.         NoFileProcess();
  2438.     }
  2439.     else if ( gbSelectFileMode )
  2440.     {
  2441.         //JM=>uiUpdateMainDisplay((bit1+bit3));  
  2442.         
  2443.         SelPlayFile(SET_BIT1 | SET_BIT0); 
  2444.     }
  2445.     else if ( gbPlayMode || gbPauseMode)
  2446.     {
  2447. /*
  2448.      if(XB_FileType) //(GM12)*
  2449.      {
  2450.      uiUpdateMainDisplay(bit1+bit2+bit3+bit4);
  2451.      LCM_yp=PofTime;
  2452. LCM_xp=AofTime;
  2453.      dispShowChar(CB_ASC[(gxPlayTimeHour%10)]);
  2454.      }
  2455.      else
  2456.      {
  2457.          uiUpdateMainDisplay((bit1+bit3+bit4));  
  2458.         }
  2459.         if(M_ChkDisplayingLyric)
  2460.         {
  2461.          if(gxTimeTagCnt)
  2462.          {
  2463.          gxStringPTR=0;
  2464.          dispShowLyric(gxarId3Tag[(gxTimeTagCnt&0x7f)-1]);
  2465.          }
  2466.         }
  2467.         else
  2468.         {
  2469.         if((MP3BITREG&(bit2+bit3))&&(!M_ChkWithLyric)) //(J)check play mode or pause mode
  2470. {
  2471. dispShowFileNameId3Tag(M_ChkWithId3Tag);
  2472. }
  2473. else
  2474. {
  2475. dispShowFileNameId3Tag(0);
  2476. }
  2477. }
  2478. */
  2479.     }
  2480. }
  2481. }   
  2482. void GUI_PLAY2ISP()
  2483. {
  2484.     XB_chgclock=0;
  2485. if(gx16BitRate)
  2486. {
  2487.     if(gx16PlayTempCnt>=gx16BitRate)
  2488.     {
  2489.         gx16PlayTempCnt-=gx16BitRate;
  2490.         AddTime();
  2491.         gxPlayTimeSecBak++;
  2492.         if(gxPlayTimeSecBak>60)
  2493.         {
  2494.          gxPlayTimeSecBak=0;
  2495.          gxPlayTimeMinBak++;
  2496.          if(gxPlayTimeMinBak>3)
  2497.          {
  2498. gxPlayTimeMinBak=0;
  2499. if(FolderStudeLevel<101)
  2500. FolderStudeLevel++;
  2501. else
  2502. FolderStudeLevel=0;
  2503.     }
  2504.            
  2505.        }
  2506.        }
  2507.    } 
  2508. }
  2509. /**/
  2510. void Process_PLAYIsp()
  2511. {  
  2512. XBYTE temp=0;
  2513.     if(M_ChkSkipMode)
  2514. return;
  2515. if(!M_ChkPlayBackEnd)
  2516.      {
  2517.         while(!MP3_Read1Sector())  
  2518.         {
  2519.          dspTriggerRead();    
  2520.          if(M_ChkPlayBackEnd)
  2521.          break;
  2522.         }
  2523.         
  2524.         dspTriggerRead();
  2525.         if(!M_ChkPlayBackEnd)
  2526.         {
  2527.             dspTriggerRead();
  2528.             GUI_PLAY2ISP();
  2529.         }
  2530. }
  2531. if(M_ChkPlayBackEnd)
  2532.      {
  2533.      if(DirFlag&0x80)
  2534. {
  2535. //DirFlag&=0x7f;
  2536. }
  2537. else
  2538. {
  2539. /*
  2540. if(XB_FileType==1)
  2541. {
  2542. Process_STOP();
  2543. Delone();
  2544. }
  2545. */
  2546. if(LastST&0x80)//0x80 now is sc
  2547. {
  2548. StopKeyProc(); //repeat  one
  2549. temp=1;
  2550. #if 0
  2551. LastST+=0x01;
  2552. if((gx16TotalPlayFileInCurrentDir+1)==(LastST&0x0f))
  2553. LastST=0x81;
  2554. #endif
  2555. }
  2556. if(LastSC&0x80)//0x80 now is sc
  2557. {
  2558. StopKeyProc(); //repeat  one
  2559. temp=1;
  2560. #if 0
  2561. LastSC+=0x01;
  2562. if((gx16TotalPlayFileInCurrentDir+1)==(LastSC&0x0f))
  2563. LastSC=0x81;
  2564. #endif
  2565. }
  2566. if(LastLR&0x80)//0x80 now is sc
  2567. {
  2568. #if 1
  2569. //LastLR+=0x01;
  2570. if((gx16TotalPlayFileInCurrentDir+1)==(LastLR&0x0f))
  2571. LastLR=0x0;
  2572. #endif
  2573. }
  2574. if(LastMC&0x80)//0x80 now is sc
  2575. {
  2576. #if 1
  2577. LastMC+=0x01;
  2578. if((gx16TotalPlayFileInCurrentDir+1)==(LastMC&0x0f))
  2579. LastMC=0x81;
  2580. #endif
  2581. }
  2582. if(DirFlag&0x02)
  2583. {//play hello end Play 分数
  2584. Process_STOP();
  2585. temp=1;
  2586. Process_sayPoint();
  2587. DirFlag&=0xfd;
  2588. DirFlag|=0x01;
  2589. }
  2590.      else if(DirFlag&0x01)
  2591. {
  2592. Process_STOP();
  2593. ReturnUpFold();
  2594. DirFlag&=0xfe;
  2595. //root ok
  2596. //
  2597. InLastLevel();//SelectFolderCountUpBase();
  2598. temp=1;
  2599. //SoundFlag&=0xfd;
  2600. }
  2601.      if(SoundFlag&0x20)
  2602. {
  2603.    Process_STOP();
  2604.    SoundFlag&=0xdf;
  2605. RecProcess(); 
  2606. temp=1;
  2607. SoundFlag&=0xfb;
  2608. SoundFlag|=0x10;
  2609. }
  2610. if(SoundFlag&0x08)
  2611. {
  2612.    //Process_STOP();
  2613.    //SoundFlag&=0xdf;
  2614. //M_SetPowerOff;
  2615.  OffProcess();
  2616. temp=1;
  2617. }
  2618. /*
  2619. if(LR_CountNum&0x80)
  2620. {//play next
  2621. LR_CountNum&=0x7f;
  2622. LR_CountNum|=0x40;
  2623. LR_CountNum++;
  2624. }
  2625. else  */
  2626. if(LR_CountNum&0x40)
  2627. {//
  2628. //Process_STOP();
  2629. DirFlag&=0xfb;
  2630. LR_CountNum&=0xbf;
  2631. LR_CountNum|=0x20;
  2632. Process_STOP();
  2633. SoundFlag|=0x40;
  2634. DelWavAll();//先删
  2635. temp=1;
  2636. DirFlag&=0xf0;
  2637. }
  2638. else if(LR_CountNum&0x10)
  2639. {//LRtestNext
  2640. Process_STOP();
  2641. LR_CountNum&=0x0f;
  2642. LR_CountNum++;
  2643. // LRtestNext();
  2644. temp=1;
  2645. }
  2646. if(temp==0)//else
  2647. {
  2648.         CLR_IsLastSector;
  2649. CLR_IsLastSectorAB;
  2650.         M_ClrPlayBackEnd; 
  2651.         fatFileReadInit();
  2652. if(LastMC&0x80)//0x80 now is sc
  2653. {
  2654. if((gx16CurrentDirFileIndex+1)==(gx16TotalSubDirInCurrentDir+gx16TotalPlayFileInCurrentDir))
  2655. LastMC=0;
  2656. else
  2657. LastMC=gx16CurrentDirFileIndex|0x80;
  2658. }
  2659. #if 0
  2660. if(LastST&0x80)//0x80 now is sc
  2661. {
  2662. if((gx16CurrentDirFileIndex+1)==(gx16TotalSubDirInCurrentDir+gx16TotalPlayFileInCurrentDir))
  2663. LastST=0;
  2664. else
  2665. LastST=gx16CurrentDirFileIndex|0x80;
  2666. }
  2667. if(LastSC&0x80)//0x80 now is sc
  2668. {
  2669. if((gx16CurrentDirFileIndex+1)==(gx16TotalSubDirInCurrentDir+gx16TotalPlayFileInCurrentDir))
  2670. LastSC=0;
  2671. else
  2672. LastSC=gx16CurrentDirFileIndex|0x80;
  2673. }
  2674. #endif
  2675. }
  2676. }
  2677.      }
  2678. }
  2679. /**/
  2680. void UI_LoopISP(void)
  2681. {
  2682. XSFR2|=(bit2+bit3);
  2683. PB_HOST[I2CSEL]=0x7F;
  2684. #if(S_CS42L51)
  2685.     gbWithDspVolumeControl=0; //(J)to disable codec I2C control in ROM code 
  2686.     WithREC=1;
  2687.     PB_DAC[DAC_PowerCtrl]=0x02; //disable LR channel of internal DAC and Power down DAC
  2688. #else
  2689.     gbWithDspVolumeControl=1;
  2690.     
  2691. #if(S_SupportAudioADC) //(G)REC and FM function use Audio ADC
  2692. WithREC=1;
  2693. WithFM=1;
  2694. //P1IO=73;
  2695. //M_AudioADCPowerDown;
  2696. #else
  2697. WithREC=0;
  2698. WithFM=0;
  2699. #endif
  2700. EnableHardwareMute(); //(GM22)
  2701.     //PB_DAC[DAC_PowerCtrl]=0x0c; //(J)enable LR channel of internal DAC 
  2702.     PB_DAC[DAC_GainCtrl]=0;
  2703.     
  2704. #endif
  2705. UI_INIT();
  2706. ClrAutoOffTmrISP(); //(GM2)
  2707. #if(S_SupportFM)
  2708. FMStandbyISP();
  2709. #endif
  2710. #if(S_ActiveDirMode)
  2711.     gbDirMode=1;
  2712. #else
  2713. gbDirMode=0;
  2714. #endif    
  2715. gxPlayTimeMinBak=0;
  2716. gxPlayTimeSecBak=0;  
  2717. gxRepCountMode=0;
  2718.     fatSetRecordDirFileName();
  2719.     XB_GUI_FLAG=1;
  2720.     ChkCARDInOut0ISP();
  2721.     M_BackLightLed1On;
  2722.     
  2723.     //(GM3)
  2724.     gxTemp4=BUF0xE000;
  2725.     LoadSettingISP();
  2726. //    SelectFolderCount=4;
  2727.     if((XW_TotalFile[XB_FileType])&&(gx16PlayIndex>=gx16arTotalFile[0][XB_FileType]))
  2728.     {
  2729.      gxMp3Storage=1;
  2730. SwitchFatParameterISP();
  2731.     }
  2732.    /* 
  2733.     lcmWriteCmd(0x81);              //(GM23)
  2734.     lcmWriteCmd(T_ContrastValue[XB_ADJ_Contrast]);
  2735.    */ 
  2736.     gx16LangMsgOffset=XB_ADJ_Language*C_LanguageMenuMsgNum;
  2737.     gxUnicodeTabIndex=T_LanguageCode[XB_ADJ_Language];
  2738. GotoSelFileMode(); //(GM14)
  2739. DispFolderNumber(SelectFolderCount);//ok
  2740. ShowBATISP();
  2741. //FolderStudeLevel=40;
  2742. DispFolderStudeLevel();
  2743. GUI_VolumeISP();
  2744. LastST=0;
  2745. LastMC=0;
  2746. LastSC=0;
  2747. LastLR=0;
  2748. SoundFlag=0x80;
  2749. RecProcess(); 
  2750. P1IO=0x03;
  2751. P3IO=0xf9;
  2752. PB_HOST[I2CSEL]=0x7F;
  2753. //yu5        PB_HOST[FMI2C]=0xFA;
  2754. //Power_LED_ON;//on 功放
  2755. //TestInc();
  2756. P14=0; //yu4LCM_RESET_LOW; //yu4
  2757. Start_ISP:
  2758.     while (1)
  2759.     {
  2760.      if (PB_HOST[0x04]&SET_BIT1)
  2761.      {
  2762. #if(S_SupportForceMP3)
  2763.      if(!M_ChkForceMp3Mode)
  2764. #endif
  2765.      {
  2766.      if(gbPlayMode)
  2767.      {
  2768. #if(!S_CS42L51) //(GM22)
  2769. EnableHardwareMute();
  2770. #endif     
  2771.      Process_STOP();
  2772.      }
  2773.     
  2774.      //if(gbRecordMode)
  2775.      // fatCloseFile();
  2776.      if(gbRecordMode)
  2777. EndRecordISP(); 
  2778.     
  2779. #if(S_SupportFM)
  2780.     if(gbFMMode)
  2781.   FMStandbyISP();
  2782. #endif    
  2783.     
  2784.      SaveSetting(BUF0xE000);
  2785.     
  2786. I2CPowerDownISP();
  2787. M_EnableLDO18; //(G)avoid initial USB fail
  2788.      SWITCH_CLK(SYSCLK1+DIV1+WAITS);
  2789.      RESET_CPU();
  2790.      }
  2791.     
  2792.      }
  2793. #if(S_SupportForceMP3)     
  2794.     else
  2795.     {
  2796.      if(M_ChkForceMp3Mode)
  2797.      {
  2798.      M_ClrForceMp3Mode;
  2799.      }
  2800.     }
  2801. #endif     
  2802.     
  2803.         //(J)Jacky's loop below////////////////////////////////////////////////////////////////
  2804.      TimeoutEventISP(); //20060801
  2805.      ProcessTimeoutEventISP();
  2806.      PlayKeyFunctionISP();
  2807.      //(J)Jacky's loop above////////////////////////////////////////////////////////////////
  2808. if(SoundFlag&0x40)
  2809. {
  2810. if((XB_FileType==1)&&(XB_NoFile))
  2811. {//del wav ok
  2812.    SoundFlag&=0xbf;
  2813. //Play beep
  2814. WavToMp3();
  2815. while(gxarFileName[2]!='C')
  2816. BFKeyProcISP();
  2817. PlayKeyIsp();
  2818. while(gxarFileName[3]!='B')//need change BBB beep
  2819. FFKeyProcISP();
  2820. PlayKeyIsp();
  2821. DirFlag|=0x08;
  2822. SoundFlag|=0x20;
  2823.   
  2824.   
  2825. }
  2826. }
  2827.      if(XB_PlayMode>= C_FilePlayMode)
  2828.      ClrAutoOffTmrISP();
  2829.         if (gbPlayMode)
  2830.         {
  2831. #if(S_SupportMemoryCard)        
  2832. if(!(CardDetect&&gxMp3Storage)) //(GM22)
  2833. #endif
  2834.      if(M_ChkPlayBackEnd)
  2835. {
  2836. if(DirFlag&0x80)
  2837. {
  2838. Process_STOP();
  2839. //ReturnUpFold();//ReturnRoot();//common
  2840. DirFlag=0x08;
  2841. //while(1);
  2842. FolderCountUpDownProcess();
  2843. goto Start_ISP;
  2844. }
  2845. }
  2846.              Process_PLAYIsp();//Process_PLAY2();
  2847.             
  2848.             XSFR1 |= bit2;
  2849. delayclk(50);
  2850.             if (!M_ChkPlayBackEnd&&(MENU_TIMER<=0x80)&&(PB_HOST[Key_Pad]==0xFF)&&(!M_ChkRampUpToVolume))
  2851. {
  2852. if(gbPlayMode)
  2853. {
  2854. FLASHAOFF;
  2855. ChgDiv1();
  2856.     EX0=1;
  2857.         PCON = 1;
  2858.               EX0=0;
  2859.               ChgDiv2();
  2860.   FLASHAON;
  2861. #if(S_SupportMemoryCard)   
  2862. if(!(CardDetect&&gxMp3Storage)) //(GM22)
  2863. #endif
  2864.              Process_PLAYIsp();//Process_PLAY2();
  2865. }
  2866. }
  2867. XSFR1 &= ~bit2;
  2868.         }
  2869.         else if(gbRecordMode)
  2870.         {
  2871.          gxTemp0=MP3FlashPtr; //(J)backup MP3FlashPtr for further check
  2872.             Process_Record();
  2873.             if(gxTemp0!=MP3FlashPtr)
  2874.             { //(J)data write happen=>check if need to update free space information
  2875.              if(!gxClusterSectorIndex)
  2876. {
  2877. gx32arTotalFreeClusterNum[gxMp3Storage]--;
  2878. }
  2879. if((XB_MENULayer[0]==1)&&M_ChkUpdateTimeDisplay) //(GM9)
  2880. M_ClrUpdateTimeDisplay;
  2881.             }
  2882.             if (gDiskErrorCode&0x0f)
  2883.             {
  2884.                 //RESET_BUF();
  2885.                 //fatCloseFile();
  2886.                 EndRecordISP(); //(GM6)
  2887.      //i2cInitialCS42L51ISP(0);
  2888.                 ErrorMenu(gDiskErrorCode&0x0f);
  2889.                 M_ClrUpdateTimeDisplay;
  2890.             }
  2891.         }
  2892. #if(S_SupportFM)
  2893.         else if (gbFMMode)
  2894.         {
  2895.             if((XB_FM_RunSeek)&&(XB_FM_RunSeek!=3)) //XB_FM_RunSeek=3 means in prepare to leave FM seek mode.
  2896.             {
  2897.              gxFMSeekDir=2;
  2898.                 FM_SeekISP();
  2899.             }
  2900.         }
  2901. #endif
  2902.         //if(!gbRecordMode) //20060803_Jash
  2903.         //if(!gbRecordMode&&(!M_ChkLowBattery)) //(GM7)
  2904.         if(!M_ChkLowBattery) //(GM9)
  2905.         {
  2906.             GUI_RET();
  2907.         } 
  2908.         //JM=>PowerDownControl();
  2909.     }
  2910. }
  2911. void SET_CARDTO()
  2912. {
  2913.   if(USBMode)   TimeOutCnt=1500/100;
  2914.   else          TimeOutCnt=1500/250;
  2915.    TimeOut=0;
  2916. }
  2917. void CheckCardInISP(void)
  2918. {
  2919. #if(S_SupportMemoryCard)
  2920. XBYTE u8ClkSet;
  2921.     {
  2922.         if(!CardDetect && !XB_Now_Card_State ) OldCardDetect=~CardDetect;
  2923.         if(OldCardDetect!=CardDetect)           giCardDebounce++;
  2924.         else                                     giCardDebounce=0;
  2925.         if(giCardDebounce>3)
  2926.         {
  2927.             giCardDebounce=0;    
  2928.             OldCardDetect=CardDetect;
  2929.             if(CardDetect)   CardOut();
  2930.             else if (!XB_Now_Card_State)
  2931.             {
  2932.              u8ClkSet=PB_HOST[CLK_SEL];
  2933.              CPUCLK_SYSCLK1;
  2934.                 MediaClkOn;
  2935.                 CARD_PWR_ON;
  2936.                 //JM=>delay500ms();
  2937.                 delayclk(250);
  2938.                 delayclk(250);
  2939.                 if(cardInit(C_ST_SD)) 
  2940.                 {
  2941.                  SET_LUN(C_ST_SD);
  2942.                 }
  2943.                 else
  2944.                 {
  2945.                     CardOut();
  2946.                     TempFCTL4 &= 0xfc;
  2947.     WRITE_FLASH_FCTL4(TempFCTL4);
  2948.                  MediaClkOff;
  2949.                     ErrorCode = 1;
  2950.                 }
  2951.     PB_HOST[CLK_SEL]=u8ClkSet;
  2952.    
  2953.             }
  2954.         }
  2955.     }
  2956. #endif    
  2957. }
  2958. void ChkCARDInOut0ISP(void)
  2959. {
  2960.     AllInit();
  2961.     
  2962. #if(S_SupportMemoryCard)
  2963.     if(WithCard && !CardDetect)
  2964.     {
  2965.         while(!XB_Now_Card_State && !ErrorCode)
  2966.         {
  2967.             CheckCardInISP();
  2968.             if(XB_New_Card_State != XB_Now_Card_State )
  2969.                 XB_Now_Card_State=XB_New_Card_State;
  2970.         }
  2971.     }
  2972. #endif    
  2973.     
  2974. #if(S_SupportMemoryCard&&S_CombineStor)
  2975. for(gxMp3Storage=0;gxMp3Storage<2;gxMp3Storage++)
  2976. {
  2977.      Process_ScanFileISP();
  2978.      gxScanFreeSizeflag[gxMp3Storage]=0;  //(GM1)
  2979.     }
  2980.    
  2981.     XW_TotalFile[0]=gx16arTotalFile[0][0]+gx16arTotalFile[1][0];
  2982.     XW_TotalFile[1]=gx16arTotalFile[0][1]+gx16arTotalFile[1][1];
  2983.     uiClearPlayedFlag();
  2984.     if(gx16arTotalFile[0][XB_FileType]||(gx16arTotalFile[1][XB_FileType]==0))
  2985. { //(J)nand FAT is good
  2986. gxMp3Storage=0;
  2987. SwitchFatParameterISP();
  2988. }
  2989. #else
  2990. Process_ScanFileISP();
  2991. gxScanFreeSizeflag[gxMp3Storage]=0;  //(GM1)
  2992. uiClearPlayedFlag();    
  2993. #endif
  2994.     gx16PlayIndex=0;
  2995.     XB_FileType=0;
  2996.     XB_GUI_FLAG=0;
  2997.     
  2998.     ResetCodecISP();
  2999.     
  3000.     //JM=>GotoSelFileMode();
  3001. }
  3002. void Process_ScanFileISP(void)
  3003. {
  3004. gxNewCodeID=5;
  3005. swCheckCodeID();
  3006. CALLADDR((CBYTE*)0xc406);
  3007. }   
  3008. //#include <sdinit.c>  
  3009. #include <sdcmd.c>
  3010. BYTE cardInitISP(BYTE u8Lun)
  3011. {
  3012. gxTemp0=u8Lun;
  3013. #if(S_SupportMemoryCard)
  3014. gxNewCodeID=4; //(G) call InitSD
  3015. swCheckCodeID();
  3016. CALLADDR((CBYTE*)0xc400);
  3017. if(gxReturnValue)
  3018. return 0;
  3019. else
  3020. return 1;
  3021. /*
  3022. if(InitSD())
  3023. return 0;
  3024. else
  3025. return 1;
  3026. */
  3027. #endif
  3028. }
  3029. void cardRead10ISP()
  3030. {
  3031. #if(S_SupportMemoryCard)
  3032. if(gxActiveStorageType == C_ST_SD)
  3033. {
  3034. SD_READ_10_fun();
  3035. }
  3036. #endif
  3037. }
  3038. void cardWrite10ISP()
  3039. {
  3040. #if(S_SupportMemoryCard)
  3041. if(gxActiveStorageType == C_ST_SD)
  3042. {
  3043. if(g32SectorAddr>=XL_LBASectors[C_MaxLUNInFlash+2]) //(G)Fix cardcopytest will exceed LBA issue
  3044.      ErrorCode=1;
  3045.     
  3046. SD_WRITE_10_fun();
  3047. }
  3048. #endif
  3049. }
  3050. /*
  3051. void fatCheckFreeSize()
  3052. {
  3053. gxNewCodeID=3;
  3054. swCheckCodeID();
  3055. CALLADDR((CBYTE*)0xc40c);
  3056. }
  3057. */
  3058. void ShowRemainCapacity(void)
  3059. {
  3060. /*
  3061. gxNewCodeID=3;
  3062. swCheckCodeID();
  3063. CALLADDR((CBYTE*)0xc409);
  3064. */
  3065. }
  3066. void EndRecordISP()
  3067. {  
  3068. gxNewCodeID=3;
  3069. swCheckCodeID();
  3070. CALLADDR((CBYTE*)0xc406);
  3071. #if(S_SupportFM)
  3072. FMStandbyISP();
  3073. #endif
  3074.     i2cInitialCS42L51(0);
  3075. }
  3076. BYTE USBDISKISP()
  3077. {
  3078. CheckCardIn();
  3079. gxNewCodeID=0;
  3080. swCheckCodeID();
  3081. CALLADDR((CBYTE*)0xc403);
  3082.     return gxReturnValue;
  3083. }
  3084. void PLLTurnOff()
  3085. {
  3086. SWITCH_CLK(SYSCLK1+DIV1+WAITS);
  3087. MS5=0; //(G)avoid MS5 > CPUCLK_SYSCLK1 CMPCNT (46)
  3088. DSP_CLK_SYSCLK1;
  3089. PLL_OFF;
  3090. }
  3091. void PLLTurnOn()
  3092. {
  3093. PLL_ON;
  3094. delayclk(100);
  3095. delayclk(100);
  3096. delayclk(100);
  3097. DSP_CLK_PLLCLK;
  3098. }
  3099. void LoadSettingISP()
  3100. {
  3101. gxNewCodeID=1;
  3102. swCheckCodeID();
  3103. CALLADDR((CBYTE*)0xc40c);
  3104.    
  3105. }
  3106. void ProcessTimeoutEventISP(void)
  3107. {
  3108. bit bSelectId3Tag;
  3109. //(GM2)
  3110. //if(((AutoOffTmrH>AUTOOFFTAB[XB_ADJ_AutoOff]) && (XB_PlayMode < C_FilePlayMode))
  3111. if(((gxAutoOffMin > 24) && (XB_PlayMode < C_FilePlayMode))//AUTOOFFTABISP[XB_ADJ_AutoOff]
  3112.    ||(M_ChkPowerOff)   )//(J)press playkey for 22mS*100 to power off )
  3113. {
  3114. OffProcess();
  3115. }
  3116. gxTempR=0;
  3117. if(gbPlayMode) //
  3118. {
  3119. if(gx16DspOffsetTime>=4)
  3120. {
  3121. gx16DspOffsetTime-=4;
  3122.      gxTempR=1;
  3123. gx5P5mSCnt0=0;
  3124.     }
  3125. }
  3126. else
  3127. {
  3128. if(   ( !(XSFR1&bit6)&&(gx5P5mSCnt0>=46) )    ||(gx5P5mSCnt0>=92))
  3129. {         
  3130. gx5P5mSCnt0=0;
  3131.      gxTempR=1;
  3132. }
  3133. }
  3134. if(gxTempR) //(J)timebase = around 500ms, (500/5.46)
  3135. {
  3136. gx5P5mSCnt0=0;
  3137. // ShowBATISP();
  3138. if(!M_ChkLowBattery) //
  3139. {
  3140. DispPlayIcon();
  3141. }
  3142. //if(!XB_MENULayer[0])
  3143. if(!(PB_HOST[0x04]&SET_BIT1)) //(GM7)
  3144. {
  3145. if(!XB_MENULayer[0]||((XB_MENULayer[0]==10)&&!M_ChkFMAutoScan)||(XB_MENULayer[0]==11))
  3146. {
  3147. if(!gbStopMode&&!M_ChkLowBattery)
  3148. {
  3149. uiUpdateMainDisplay(bit0);
  3150. gxTemp0=PB_HOST[ADC3BIT_CTRL];
  3151. ShowBATISP();
  3152. if(PB_HOST[ADC3BIT_CTRL]<5)
  3153. {
  3154. M_SetPowerOff;
  3155. OffProcess();//LowSound();
  3156. }
  3157. }
  3158. }
  3159. }
  3160. if(M_ChkRecoverNormalDisplay)
  3161. {
  3162. M_ClrRecoverNormalDisplay;
  3163. GotoMainPorg();
  3164. MENU_TIMER=0;
  3165. }
  3166. if(M_ChkLowBattery)
  3167. {
  3168. if(gxLowBatteryCnt>=10) //(J)10 seconds
  3169. M_SetPowerOff;
  3170. else
  3171. gxLowBatteryCnt++;
  3172. if(gbPlayMode||gbPauseMode) //(GM7)
  3173. {
  3174. #if(!S_CS42L51) //(GM22)
  3175. EnableHardwareMute();
  3176. #endif
  3177. Process_STOP();
  3178. }
  3179. else if(gbRecordMode)
  3180. {
  3181. EndRecordISP();
  3182. SET_PLAYMODE(C_FileSelectMode);
  3183. }
  3184. /*
  3185. else if(gbFMMode)
  3186. {
  3187. FMStandbyISP();
  3188. SET_PLAYMODE(C_FileSelectMode);
  3189. }
  3190. */
  3191. }
  3192. else
  3193. {
  3194. gxLowBatteryCnt=0;
  3195. }
  3196. //----Pause Blink----
  3197.     gbIconOnOff=~gbIconOnOff;
  3198. #if 0
  3199. if(WithLCM)
  3200. {    
  3201.         //if (!XB_MENULayer[0] && !XB_MENULayer[1]&&(!gbFMMode))
  3202.         if (!XB_MENULayer[0] && !XB_MENULayer[1]&&(!gbFMMode)&&(!M_ChkLowBattery)) //(GM7)
  3203.         {
  3204.         if((!M_ChkDisplayingLyric)&&gbIconOnOff)
  3205.         {
  3206.          if((MP3BITREG&bit0)==0)
  3207.          {
  3208.          if((MP3BITREG&(bit2+bit3))&&(!M_ChkWithLyric)) //(J)check play mode or pause mode
  3209.          {
  3210.          //dispShowFileNameId3Tag(M_ChkWithId3Tag);
  3211.          bSelectId3Tag=M_ChkWithId3Tag;
  3212.          }
  3213.          else
  3214.          {
  3215.          //dispShowFileNameId3Tag(0);
  3216.          bSelectId3Tag=0;
  3217.          }
  3218.         
  3219.          if(bSelectId3Tag)
  3220.          {
  3221.          //if (gxarFileName[XB_StringPtr+2]>=0x80)
  3222.          if ((gxarId3Tag[XB_StringPtr+2]>=0x80)&&(gxUnicodeTabIndex<=4)&&(gxUnicodeTabIndex!=C_ENG))  //(GM14)
  3223.          XB_StringPtr+=2;
  3224.         else                                       
  3225.          XB_StringPtr+=1;
  3226.         
  3227.         if (gxarId3Tag[XB_StringPtr+2]==0)       
  3228.          XB_StringPtr=0;
  3229.          }
  3230.          else
  3231.          {
  3232.          if(gxarFileName[0]>(LCM_WIDTH/8))
  3233.          {
  3234.          //if (gxarFileName[XB_StringPtr+2]>=0x80)
  3235.          if ((gxarFileName[XB_StringPtr+2]>=0x80)&&(gxUnicodeTabIndex<=4)&&(gxUnicodeTabIndex!=C_ENG))  //(GM14)
  3236.          XB_StringPtr+=2;
  3237.          else                                       
  3238.          XB_StringPtr+=1;
  3239.         
  3240.          if (gxarFileName[XB_StringPtr+2]==0)       
  3241.          XB_StringPtr=0;
  3242.         }
  3243.         }
  3244.         }
  3245.         }
  3246.     }
  3247. }
  3248. #endif
  3249. }
  3250. if(M_ChkUpdateTimeDisplay)
  3251. {
  3252. M_ClrUpdateTimeDisplay;
  3253. if((XB_File_CurrentType==WAVFILE)||gbRecordMode)
  3254. {
  3255. if( (2<gxPlayTimeSec)&&(SoundFlag&0x04) )SoundFlag&=0xfb;//解封键 
  3256. if(  (1<gxPlayTimeSec)&&gbRecordMode 
  3257.    &&(SoundFlag&0x80)
  3258.   )
  3259. {
  3260. PlayKeyIsp();//REC stop
  3261. SoundFlag&=0x7f;
  3262. WavToMp3();//in common
  3263. logoSound();
  3264. DirFlag&=0xbf;
  3265. //say hello
  3266. }
  3267. if(  (10<gxPlayTimeMin)&&gbRecordMode 
  3268.    )
  3269. {
  3270. PlayKeyIsp();//REC stop
  3271. SoundFlag=0;
  3272. DirFlag=0x20;//WAV 状态 
  3273. }
  3274. if(  (9==gxPlayTimeSec)&&gbRecordMode 
  3275.    &&(SoundFlag&0x10&&(LR_CountNum&0x20))
  3276.   )
  3277. {
  3278. DirFlag&=0xbf;
  3279. LR_CountNum&=0xdf;
  3280. PlayRECFunction();
  3281. LR_CountNum|=0x10;
  3282. SoundFlag&=0xef;
  3283. SoundFlag|=0x02;
  3284. }
  3285. /*
  3286. LCM_yp=PofTime; //(GM12)
  3287. LCM_xp=AofTime;
  3288.      dispShowChar(CB_ASC[(gxPlayTimeHour%10)]);
  3289. if(gbRecordMode) //(GM9)
  3290. {
  3291. gxTemp0=1;
  3292. ShowRemainCapacity();
  3293. }
  3294. */
  3295. }
  3296. else
  3297. {
  3298.          //uiUpdateMainDisplay(bit1);
  3299.          }
  3300.     }
  3301.     
  3302. bit dspTriggerReadISP()
  3303. {
  3304. #if(S_SupportMemoryCard)  //(GM22)
  3305. if(CardDetect&&gxMp3Storage)
  3306. return 0;  
  3307. #endif
  3308.      if ( ReadDSP_DMA_STATUS() & SET_BIT1 )
  3309.      // if (READ_DSPIO(0x4f) & SET_BIT0)
  3310.      {
  3311.         if (gxDspDataReadyCnt)
  3312.         {
  3313.              if(!P32) GET_INT(DSP_INT);
  3314.             INTTEMP &= ~DSP_INT;
  3315.             
  3316.             if(XB_File_CurrentType==WMAFILE) //(J)for WMA random point playback
  3317.             {
  3318.              gx16TempCnt=gx32PlaySectorIndex;
  3319.          WRITE_DSPIO(0x47,gx16TempCnt);
  3320.          gx16TempCnt=gx32PlaySectorIndex>>16;
  3321.          WRITE_DSPIO(0x45,gx16TempCnt);
  3322.          gx32PlaySectorIndex++;
  3323.          }
  3324.          
  3325.                  
  3326.             DSPHOSTON=1;
  3327.             WRITE_DSP_LEN(0x00,0xff,0xff);
  3328.             NowBufDirH =  CB_BufHostTable[HostPtr];   //READ
  3329.             BUF_SWITCH;
  3330.             PB_HOST[DSPBufAct] = CB_BBit_Table[HostPtr];  //READ
  3331.             DSP_DMA_ON_READ(0x09);
  3332.             DSP_DMA_READ_DONE();
  3333.             ///Jacky add below/////
  3334.             if((gx32PlaySectorIndex>(gx32ID3V2ASFHeaderLength/512))||(XB_File_CurrentType!=WMAFILE)) //(N)_M 2
  3335.      gx16PlayTempCnt+=512; //(J)512 bytes to DSP
  3336.      ///Jacky add above/////
  3337.             if (!XB_PlayStep)
  3338.             {
  3339.                 return 1;
  3340.                 //ChangeRate();
  3341.             }
  3342.         }
  3343.     }
  3344.     return 0;
  3345. }
  3346. CBYTE T_AdpcmDirNameISP[10]=
  3347. {
  3348. 8,0,'C','O','M','M','E','N','T',' '
  3349. };
  3350. CBYTE T_WaveFileNameISP[12]=
  3351. {
  3352. 'V','O','I','C','E','0','0','0','.','W','A','V'
  3353. }; //"";VOICEXXX.WAV
  3354. void fatSetRecordDirFileNameISP(void)
  3355. {
  3356. BYTE i;
  3357. for(i=0;i<10;i++)
  3358. gxarRecordDirName[i]=T_AdpcmDirNameISP[i];
  3359. gxarRecordFileName[0]=12;
  3360. gxarRecordFileName[1]=0;
  3361. for(i=0;i<12;i++)
  3362. gxarRecordFileName[i+2]=T_WaveFileNameISP[i];
  3363. gxarRecordFileExt[0]='W';
  3364. gxarRecordFileExt[1]='A';
  3365. gxarRecordFileExt[2]='V';
  3366. }
  3367. void ShowBATISP()
  3368. {
  3369. gxNewCodeID=5;
  3370. swCheckCodeID();
  3371. CALLADDR((CBYTE*)0xc409);
  3372. }
  3373. void uiUpdateMainDisplayISP(BYTE u8UpdateMask)
  3374. {
  3375. }
  3376. #if (S_SupportSegLcd)
  3377. //(J)for HT1621 segment LCD
  3378. #define M_LcdOutputDataEnable PB_HOST[LCMMode] &= ~SET_BIT0;
  3379. #define M_LcdOutputDataDisable PB_HOST[LCMMode] |=  SET_BIT0;
  3380. #define M_EnableSerialLcdIF PB_HOST[SPI_LCM_CTRL] |= SET_BIT7;
  3381. #define M_DisableSerialLcdIF PB_HOST[SPI_LCM_CTRL] &= ~SET_BIT7;
  3382. #define LCD_CS_HIGH PB_HOST[SPI_LCM_CTRL] |= SET_BIT6;     
  3383. #define LCD_CS_LOW PB_HOST[SPI_LCM_CTRL] &= ~SET_BIT6;     
  3384. #define LCD_RD_HIGH PB_HOST[SPI_LCM_CTRL] |= SET_BIT2; 
  3385. #define LCD_RD_LOW PB_HOST[SPI_LCM_CTRL] &= ~SET_BIT2;
  3386. #define LCD_WR_HIGH PB_HOST[SPI_LCM_CTRL] |= SET_BIT3;   
  3387. #define LCD_WR_LOW PB_HOST[SPI_LCM_CTRL] &= ~SET_BIT3;  
  3388. #define LCD_DATA_HIGH PB_HOST[SPI_LCM_CTRL] |= SET_BIT4; 
  3389. #define LCD_DATA_LOW PB_HOST[SPI_LCM_CTRL] &= ~SET_BIT4;
  3390. #define CHK_LCD_DATA (PB_HOST[SPI_LCM_CTRL] & SET_BIT0)
  3391. void lcdDelayBusClock(void)
  3392. {
  3393. XBYTE i;
  3394. for(i=0;i<5;i++);
  3395. }
  3396. void lcdWrite4bitsHT1621(void)
  3397. {
  3398. M_LcdOutputDataEnable
  3399. LCD_WR_LOW
  3400. for(gTempReg=0;gTempReg<4;gTempReg++)
  3401. {
  3402.        if(gxLcdData&0x01) 
  3403.    {
  3404.    LCD_DATA_HIGH
  3405.    }
  3406.    else 
  3407.    {
  3408.    LCD_DATA_LOW
  3409.    }
  3410.   
  3411.    gxLcdData=gxLcdData>>1;
  3412.    LCD_WR_LOW
  3413.    lcdDelayBusClock();
  3414.    LCD_WR_HIGH
  3415.    lcdDelayBusClock();
  3416. }
  3417. LCD_DATA_HIGH
  3418. }
  3419. void lcdSetCommandHT1621(void)
  3420. {
  3421. M_LcdOutputDataEnable
  3422. for(gTempReg=0;gTempReg<9;gTempReg++)
  3423. {
  3424.    if(gxLcdCommand&0x80) 
  3425.    {
  3426.    LCD_DATA_HIGH
  3427. }
  3428.    else 
  3429.    {
  3430.    LCD_DATA_LOW
  3431.    }
  3432.   
  3433.    gxLcdCommand=gxLcdCommand<<1;
  3434.   
  3435.    LCD_WR_LOW
  3436.    lcdDelayBusClock();
  3437.   
  3438.    LCD_WR_HIGH
  3439.    lcdDelayBusClock();
  3440. }
  3441. }
  3442. void lcdInitialReadWriteHT1621(void)
  3443. {
  3444. XBYTE i;
  3445. M_LcdOutputDataEnable
  3446. gxLcdAddress=gxLcdAddress|gxLcdMode;
  3447.   
  3448. for(i=0;i<9;i++)
  3449. {
  3450.    if(gxLcdAddress&0x80) 
  3451.    {
  3452.    LCD_DATA_HIGH
  3453. }
  3454.    else 
  3455.    {
  3456.    LCD_DATA_LOW
  3457.    }
  3458.   
  3459.    if (i==3) 
  3460.    {
  3461.    LCD_DATA_LOW
  3462.    }
  3463.    else gxLcdAddress=gxLcdAddress<<1;
  3464.   
  3465.    LCD_WR_LOW
  3466.    lcdDelayBusClock();
  3467.   
  3468.    LCD_WR_HIGH
  3469.    lcdDelayBusClock();
  3470. }
  3471. LCD_DATA_HIGH
  3472. }
  3473. void lcdSetModeID(void)
  3474. {
  3475. XBYTE i;
  3476. M_LcdOutputDataEnable
  3477. for(i=0;i<3;i++)
  3478. {
  3479.    if(gxLcdMode&0x80) 
  3480.    {
  3481.    LCD_DATA_HIGH
  3482. }
  3483.    else 
  3484.    {
  3485.    LCD_DATA_LOW
  3486.    }
  3487.   
  3488.    gxLcdMode=gxLcdMode<<1;
  3489.    LCD_WR_LOW
  3490.    lcdDelayBusClock();
  3491.   
  3492.    LCD_WR_HIGH
  3493.    lcdDelayBusClock();
  3494. }
  3495. }
  3496. void lcdSelectHT1621(void)
  3497. {
  3498.     LCD_CS_LOW
  3499. lcdDelayBusClock();
  3500. }
  3501. void lcdDeselectHT1621(void)
  3502. {
  3503. LCD_CS_HIGH
  3504. lcdDelayBusClock();
  3505. }
  3506. void lcdClearAllBuffer(void)
  3507. {
  3508.   for(gTempReg=0;gTempReg<32;gTempReg++)
  3509.      XB_SegLcdBuf[gTempReg]=0x00;
  3510. }
  3511. void lcdUpdateSegLcdDisplay(void)
  3512. {
  3513. XBYTE i;
  3514. lcdSelectHT1621();
  3515. gxLcdMode=Write_Mode;
  3516. gxLcdAddress=0x00;
  3517. lcdInitialReadWriteHT1621();
  3518.    for(i=0;i<32;i++)
  3519.    {
  3520.    gxLcdData=XB_SegLcdBuf[i];
  3521.      lcdWrite4bitsHT1621();
  3522.     }
  3523.    lcdDeselectHT1621();
  3524. }
  3525. void lcdInitialHT1621(void)
  3526. {
  3527. PB_HOST[SPI_LCM_CTRL]=0xff; //(J)initial signal state and select SPI for LCD
  3528. lcdDelayBusClock();
  3529. M_EnableSerialLcdIF  
  3530. lcdSelectHT1621();
  3531. gxLcdMode=Command_Mode;
  3532.    lcdSetModeID(); //enter command mode
  3533.    gxLcdCommand=EnableHT1621;
  3534. lcdSetCommandHT1621(); //enable ht1621 system clock
  3535. gxLcdCommand=Disable_Timer;
  3536.    lcdSetCommandHT1621(); //disable timer
  3537.    gxLcdCommand=Disable_WDT;
  3538.    lcdSetCommandHT1621(); //disable watch dog
  3539.    gxLcdCommand=Disable_IRQ;
  3540.    lcdSetCommandHT1621(); //disable IRQ output
  3541.    gxLcdCommand=Bias3_4COM;
  3542.    lcdSetCommandHT1621(); //1/3 bias 4 duty 
  3543.    lcdDeselectHT1621();
  3544.   
  3545.    lcdClearAllBuffer(); //clear all lcd buffer
  3546.    lcdUpdateSegLcdDisplay();
  3547.   
  3548.    //----turn on LCD----
  3549. lcdSelectHT1621();
  3550. gxLcdMode=Command_Mode;
  3551.    lcdSetModeID();
  3552.    gxLcdCommand=LCD_On;
  3553.    lcdSetCommandHT1621();
  3554.    lcdDeselectHT1621();
  3555. //----display init status----
  3556. }
  3557. //(J)for HT1621 segmant LCD
  3558. /**/
  3559. void DispFolderFunctionNumber(BYTE FolderFunctionNumber)
  3560. {
  3561. if(FolderFunctionNumber!=4)
  3562. LR_CountNum=0;
  3563. PressIO_Key=0;
  3564. gxTemp0=FolderFunctionNumber;
  3565. gxNewCodeID=5;
  3566. swCheckCodeID();
  3567. CALLADDR((CBYTE*)0xc40c);
  3568. }
  3569. void FolderStudeLevelUp()
  3570. {
  3571. if(FolderStudeLevel<101)
  3572. {
  3573. FolderStudeLevel++;
  3574. DispFolderStudeLevel();
  3575. }
  3576. // XB_ADJ_Contrast=FolderStudeLevel;
  3577. }
  3578. void FolderStudeLevelDown()
  3579. {
  3580. if(FolderStudeLevel>0)
  3581. {
  3582. FolderStudeLevel--;
  3583. DispFolderStudeLevel();
  3584. }
  3585. // XB_ADJ_Contrast=FolderStudeLevel;
  3586. }
  3587. void DispFolderStudeLevel()
  3588. {
  3589. gxTemp0=FolderStudeLevel;
  3590. gxNewCodeID=5;
  3591. swCheckCodeID();
  3592. CALLADDR((CBYTE*)0xc40f);
  3593. }
  3594. void DispFolderNumber(BYTE FolderNumber)
  3595. {
  3596. gxTemp0=FolderNumber;
  3597. gxNewCodeID=5;
  3598. swCheckCodeID();
  3599. CALLADDR((CBYTE*)0xc412);           
  3600. }
  3601. void PlayKeyIsp()
  3602. {
  3603. //////////////////////////////////////(GM2)
  3604. if((!XB_MENULayer[0] && !XB_MENULayer[1])&&ChkPLLOff)
  3605. {
  3606. PLLTurnOn();
  3607. {
  3608. if(XB_PLL_MODE<10)
  3609. SWITCH_CLK(PLLCLK+DIV2+WAITS);
  3610. else
  3611. SWITCH_CLK(PLLCLK+DIV4+WAITS);
  3612. UpdateCMPCNT(); //(GM2)*
  3613. }
  3614. }
  3615. //////////////////////////////////////////(GM1) for EndRecord   
  3616.              if(XB_MENULayer[0]==11) 
  3617.              {
  3618.             EndRecordISP();
  3619.             XB_FileType=1;
  3620.             //gx16PlayIndex=XW_TotalFile[XB_FileType]-1;
  3621.             GotoSelFileMode();
  3622.             GotoMainPorg();
  3623.         }
  3624.         else
  3625.         {
  3626. ////////////////////////////////////////
  3627. if((gbSelectFileMode)&&(!XB_NoFile)&&(XB_File_CurrentType!=C_SubDir)&&(!XB_MENULayer[0]))
  3628. MP3PlayStartISP();
  3629. else
  3630. {
  3631. if (XB_MENULayer[0]==4) //(GM7)
  3632. {
  3633. gxNewCodeID=2; //(G) call CheckEQandContrastForPlaykey
  3634. swCheckCodeID();
  3635. CALLADDR((CBYTE*)0xc40c);
  3636. if(gxReturnValue) //(GM25)
  3637. EQVolumeControl(XB_ADJ_EQMode);
  3638.         }
  3639.         else if ((XB_MENULayer[0]==10)) //(GM8)
  3640.         {
  3641. /*
  3642.                     XB_FM_MEM++;
  3643.                             
  3644.                     gxNewCodeID=1; //call fmGetMemChannelISP
  3645. swCheckCodeID();
  3646. CALLADDR((CBYTE*)0xc40F);
  3647. #if(S_SupportAudioADC)
  3648. CodeI2C_CS_LOW;
  3649. #endif
  3650. */
  3651.                     }
  3652.         
  3653.                  PLAYKeyProc();
  3654. /*                
  3655. LCM_yp=1;
  3656. LCM_xp=70;
  3657. dispShowChar(CB_ASC[gx16PlayDirIndex/10]); 
  3658. dispShowChar(CB_ASC[gx16PlayDirIndex%10]);
  3659. */
  3660. if(!XB_MENULayer[0])
  3661. {
  3662.              if(gbPlayMode)
  3663.              M_SetRampUpToVolume;
  3664. #if(!S_CS42L51)              //(GM32)
  3665.             else if(gbPauseMode)
  3666. RampDownToMuteISP();
  3667. #endif
  3668. }
  3669.                  }
  3670.                  }
  3671. }
  3672. void logoSound()
  3673. {
  3674. while(gxarFileName[2]!='C')
  3675. FFKeyProcISP();
  3676. PlayKeyIsp();
  3677. while(gxarFileName[2]!='H')
  3678. FFKeyProcISP();
  3679. DirFlag|=0x88;
  3680. // DirFlag|=0x80;
  3681. // DirFlag|=0x08;
  3682. PlayKeyIsp();
  3683. }
  3684. /*
  3685. void ReturnRoot()
  3686. {
  3687. while(gxarFileName[2]!='.')
  3688. BFKeyProcISP();
  3689. PlayKeyIsp();//common
  3690. }
  3691. */
  3692. void EndSound()
  3693. {
  3694. //root
  3695. if(SoundFlag&0x10)//rec mode
  3696. {
  3697. StopREC();
  3698. }
  3699. if(XB_FileType==0)
  3700. InWav();
  3701. WavToMp3();
  3702. while(gxarFileName[2]!='C')
  3703. BFKeyProcISP();
  3704. PlayKeyIsp();
  3705. while(gxarFileName[3]!='Y')//bye
  3706. FFKeyProcISP();
  3707. SoundFlag=0x08;
  3708. DirFlag=0;
  3709. PlayKeyIsp();
  3710. //SoundFlag|=0x04;
  3711. DispFolderFunctionNumber(5);
  3712. }
  3713. void LowSound()
  3714. {
  3715. /*
  3716. if(SoundFlag&0x01)return;
  3717. SelectFolderCountUpDown();
  3718. SoundFlag=0;
  3719. DirFlag=0;
  3720. while(gxarFileName[2]!='C')//Low
  3721. FFKeyProcISP();
  3722. PlayKeyIsp();
  3723. while(gxarFileName[5]!='O')
  3724. FFKeyProcISP();
  3725. SoundFlag=0x08;
  3726. PlayKeyIsp();
  3727. SoundFlag|=0x04;//封键 
  3728. */
  3729. }
  3730. void InWav()
  3731. {
  3732. LastST&=0x7f;
  3733. LastMC&=0x7f;
  3734. LastSC&=0x7f;
  3735. MENUKeyProcISP();
  3736. FFKeyProcISP();
  3737. MENUKeyProcISP();//in wav
  3738. }
  3739. void StopREC()
  3740. {
  3741. if(SoundFlag&0x10)
  3742. {
  3743. PlayKeyIsp();//REC stop
  3744. SoundFlag&=0xaf;
  3745. }
  3746. }
  3747. void PlayRECFunction()
  3748. {
  3749. StopREC();
  3750. InWav();
  3751. PlayKeyIsp();
  3752. DirFlag|=0x20; // play rec
  3753. //REC_PLAY();//SelFunction();
  3754. }
  3755. void OffProcess()
  3756. {
  3757. gxTempR=(FolderStudeLevel/10)<<4;
  3758. gxTempR&=0xf0;
  3759. gxTempR|=0x02;//SelectFolderCount&0x0f;
  3760. XB_ADJ_Contrast=gxTempR;
  3761.         SaveSetting(BUF0xE000);
  3762. //del wav
  3763. Delone();
  3764. // dispShowChar(CB_ASC[XB_ADJ_Contrast&0x0f]);
  3765. // while(1);
  3766. gxNewCodeID=3;
  3767. swCheckCodeID();
  3768. CALLADDR((CBYTE*)0xc41b);
  3769.        SYSTEM_PWR_OFF; //(J)P37=0
  3770.         RESET_CPU();
  3771. }
  3772. void MENUBASE()
  3773. {
  3774.   MENUKeyProcISP();
  3775. FFKeyProcISP();
  3776. FFKeyProcISP();
  3777. FFKeyProcISP();
  3778. }
  3779. void DelWavBase()
  3780. {
  3781. MENUBASE();
  3782. /* MENUKeyProcISP();
  3783. FFKeyProcISP();
  3784. FFKeyProcISP();
  3785. FFKeyProcISP();
  3786. */
  3787. FFKeyProcISP();
  3788. FFKeyProcISP();
  3789. MENUBASE();
  3790. /* MENUKeyProcISP();
  3791. FFKeyProcISP();
  3792. FFKeyProcISP();
  3793. FFKeyProcISP();
  3794. */
  3795. FFKeyProcISP();
  3796. MENUKeyProcISP();//del
  3797. MENUKeyProcISP();//del ok
  3798. }
  3799. void Delone()
  3800. {
  3801. SoundFlag|=0x04;//封键 
  3802. InWav();
  3803. //while(1)
  3804. {
  3805. FFKeyProcISP();
  3806. if(gxarFileName[9]!='0')
  3807. {
  3808. DelWavBase();
  3809.                 while( gxarFileName[9]!='0')
  3810.                 MENUKeyProcISP();//del ok
  3811.                 if(gxarFileName[9]=='0')
  3812.                 {
  3813.                 PlayKeyIsp();
  3814.                 PlayKeyIsp();
  3815.                 StopKeyProc();
  3816.                 }
  3817.                 
  3818. }
  3819. }
  3820. SoundFlag&=0xfb;
  3821. }
  3822. void DelWavAll()
  3823. {
  3824. SoundFlag|=0x04;//封键 
  3825. InWav();
  3826. DelWavBase();
  3827.                 while(!XB_NoFile)
  3828.                 MENUKeyProcISP();//del ok
  3829. }
  3830. void RecProcess()
  3831. {
  3832. MENUBASE();
  3833. /* MENUKeyProcISP();
  3834. FFKeyProcISP();
  3835. FFKeyProcISP();
  3836. FFKeyProcISP();
  3837. */
  3838. MENUKeyProcISP();//rec        
  3839. }
  3840. void WavToMp3()
  3841. {
  3842. StopBase();
  3843. MENUKeyProcISP();
  3844. MENUKeyProcISP();
  3845. }