RAMPROG.C
上传用户:wldzsoft
上传日期:2022-01-17
资源大小:21k
文件大小:93k
- //LR_CountNum bit7-bit4
- //DirFlag: bit7:logo bit 6 XX ,bi5 play wav flag bit4 LR end flag bit 3:first subDir bit 2 second subDir,
- // bit 1 say point bit 0 return after say point bit 6 0x40
- //SoundFlag bit7:REC <logo bit 6 del ,bi5 beep bit4 rec bit 3: off bit 2封键, bit 1 0 0x03
- //
- /*
- The most important is that make sure CS always fix High level, while use Cirrus CS42L51.
- (FM I2C at Rom code will make Codec CS pin goes to low)
- If codec CS goes to low, then need to initial codec again.
- */
- //battery test
- #include <option.h>
- #include <SMI51.h>
- #include <struct.h>
- #include <local.h>
- #include <local1.h>
- #include <protyp.h>
- #include <fusb.h>
- #include <UI.h>
- #include <fat.H>
- #include <sd.h>
- #include <sdcmd.h>
- #include <isp_def.h>
- void Disk23SectorAddr2BlockPage0(BYTE);
- void ProcessVolumeUpDownISP(void);
- void fmGetMemChannel();
- void fatCheckFreeSize();
- void ShowRemainCapacity(void);
- void EndRecordISP();
- void lcdlcmOff();
- void LoadSettingISP();
- void PLLTurnOff();
- void PLLTurnOn();
- void CheckCardInISP(void);
- void Process_ScanFileISP(void);
- void ChkCARDInOut0ISP(void);
- void ProcessTimeoutEventISP(void);
- void dispShowFileNameId3TagISP(BYTE);
- void I2CVolumeControlISP();
- //void SelectFolderCountDown();
- //void SelectFolderCountUp();
- void FolderFunctionNumberTest();//ok
- void FolderFunctionNumberTest1();//ok
- void LRtest1();
- void DispFolderStudeLevel();
- void DispFolderNumber(BYTE FolderNumber);
- void DispFolderFunctionNumber(BYTE FolderFunctionNumber);
- void SelectFolderCountUpDown();
- void ShowBATISP();
- BYTE USBDISKISP();
- void logoSound();
- void fatSetRecordDirFileNameISP(void);
- #if(S_SupportFM)
- void FM_SeekISP(void);
- #endif
- void PlayKeyIsp();
- void PlayRECFunction();
- void ReturnUpFold(void );
- void EndSound();
- void LowSound();
- //void ReturnRoot();
- void OffProcess();
- void DelWavAll();
- void RecProcess();
- void InWav();
- void WavToMp3();
- void InLastLevel();
- void FolderStudeLevelUp();
- void FolderStudeLevelDown();
- void StopREC();
- void Delone();
- void FolderCountUpDownProcess();
- ////////////(GM24)add below //BE is no this issue
- CBYTE T_MoveBufIndexISP[4]={10,11,12,8};
- void Read4PlaneTemp1ISP(void)
- {
- for(gFPlane=0;gFPlane<4;gFPlane++)
- {
- g16PBA=gx16SrcBlock0;
- FlashCopyRead(T_MoveBufIndexISP[gFPlane]);
- }
- gFPlane=0;
- }
- void Write2kTempPage1ISP(void)
- {
- //bit first;
- BYTE first;
- first=1;
- for(gFPlane=0;gFPlane<4;gFPlane++)
- {
- g16PBA=gx16DesBlock0;
- SET_LINKDIR(T_MoveBufIndexISP[gFPlane]);
- FlashProgPage2k(first,0xc5);
- ALL_LINK_MOVX;
- first=0;
- }
- FLASHCLE(0x10);
- while (FlashReady);
- while (FlashBusy);
- //FLASHCLE(0x70);
- //gbProgramFail=FLASHRD_FDATA() & SET_BIT0;
- FCEOFF();
- gFPlane=0;
- }
- void MoveTempPage2kISP(void)
- {
- //gxCopyBufPtr=COPY_BUF_PTR4_A; //(J)C_COPY_BUF_PTR4_A=0x00 => use 0xD000
- //gbSaveLink=1;
- //SaveLinkData(); //(J)if need 2K buffer from 0xD000 => save link data
-
- gx16SrcBlock0=F_LoadTempBlockPBA();
- gx16DesBlock0=gx16SrcBlock0;
-
- gBlockPageLo=F_LoadTempDataPage();
- //gxBackupPlane=F_LoadTempChildPage();
- Read4PlaneTemp1ISP();
-
- //SetTempBlockLinkData();
- /*
- PB_FLASH[Spr1]=C_TempBlockID|gxTempPageCnt2; //(J)set link data for temp block
- PB_FLASH[Spr2]=gxBackupPlane;
- gx16SrcBlock1=F_LoadTempBlockLBA();
- PB_FLASH[Spr3]=XW_2_XB(gx16SrcBlock1)[1];
- PB_FLASH[Spr4]=XW_2_XB(gx16SrcBlock1)[0];
- */
- PB_FLASH[Spr1]=C_TempBlockID|F_LoadTempPageCnt(); //(J)set link data for temp block
- //PB_FLASH[Spr2]=gxBackupPlane;
- PB_FLASH[Spr2]=F_LoadTempChildPage();
- gx16SrcBlock1=F_LoadTempBlockLBA();
- PB_FLASH[Spr3]=XW_2_XB(gx16SrcBlock1)[1];
- PB_FLASH[Spr4]=XW_2_XB(gx16SrcBlock1)[0];
-
- g16BlockPage=F_LoadTempBlockPagePtr();
- Write2kTempPage1ISP();
-
- //RestoLinkData();
- //gbSaveLink=0;
-
- g16BlockPage=F_LoadTempBlockPagePtr();
- F_SaveTempDataPage(gBlockPageLo);
- g16BlockPage++;
- F_SaveTempBlockPagePtr(g16BlockPage);
- }
- void OrderTempDataPageISP(void)
- {
- if(!gTempBlockPtr)
- {//(J)first temp page is cleared=>move ptr1 to ptr0 for further use
- ShiftTempPageData();
- }//(J)gTempBlockPtr=0 now
- else
- gTempBlockPtr=0;
-
- if(F_LoadTempBlockPagePtr()>=(gx16PagePerBlock-2))
- { //(J)temp block full=>copy temp page to new temp block
- CheckInitNewTempBlock();
- }
- else
- { //(J)move to last page and update linke data with temp page count
- MoveTempPage2kISP();
- }
- }
- void CheckInitNewTempBlockISP(void)
- {
- if(F_LoadTempBlockPagePtr()>=(gx16PagePerBlock-2))
- {
- gx16SrcBlock0=F_LoadTempBlockPBA();
- gbProgramFail=1;
- while(gbProgramFail)
- {
- PopSpareBlock2();
- gx16DesBlock0=g16PBA;
- BUF_HOST;
- PB_FLASH[FSA_H]=0x00;
- //gxCopyBufPtr=COPY_BUF_PTR4_A; //(J)C_COPY_BUF_PTR4_A=0x00 => use 0xD000
-
- //gbSaveLink=1;
- //SaveLinkData(); //(J)if need 2K buffer from 0xD000 => save link data
-
- Ncopyflag=1;
- ///////////////////////////////////////////////////////////////////////////
- gbProgramFail=gbProgramFail2=0;
- gTempBlockPtr=0;
- while(gTempBlockPtr<F_LoadTempPageCnt())
- {
- gBlockPageLo=F_LoadTempDataPage();
- Read4PlaneTemp1ISP();
-
- PB_FLASH[Spr1]=C_TempBlockID|F_LoadTempPageCnt(); //(J)set link data for temp block
- PB_FLASH[Spr2]=F_LoadTempChildPage();
- gx16SrcBlock1=F_LoadTempBlockLBA();
- PB_FLASH[Spr3]=XW_2_XB(gx16SrcBlock1)[1];
- PB_FLASH[Spr4]=XW_2_XB(gx16SrcBlock1)[0];
-
- gBlockPageLo=gTempBlockPtr;
- Write2kTempPage1ISP();
- F_SaveTempDataPage(gTempBlockPtr);
-
- gTempBlockPtr++;
-
- gbProgramFail2 |= gbProgramFail;
- }//(J)gTempBlockPtr=F_LoadTempPageCnt()
-
- gbProgramFail=gbProgramFail2;
- /////////////////////////////////////////////////////////////////////////
- Ncopyflag=0;
-
- //RestoLinkData();
- //gbSaveLink=0;
-
- if(gbProgramFail)
- {
- g16PBA=gx16DesBlock0;
- if(!AGAND || AGAND_PROGFAIL(1))
- {
- MarkBadBlock(11);
- gbProgramFail=1;
- }
- else
- gbProgramFail=0;
- }
- }
- ALL_LINK_MOVX;
- ALL_BUF_MOVX;
- PB_FLASH[FSA_H]=0;
-
- F_SaveTempBlockPBA(gx16DesBlock0);
- F_SaveTempBlockPagePtr(gTempBlockPtr);
-
- g16PBA=gx16SrcBlock0; //(J)erase old temp block
- FlashErase();
-
- if(EraseFail)
- MarkBadBlock(9);
- else
- PushSpareBlock(0x00);
- }
- }
- void CleanTempBlockPageISP(void)
- {
- SaveSprArea();
- F_SaveTempBlockLBA(0xffff);
- F_DecTempPageCnt();
- gbMatchTempBlock=0;
-
- if(F_LoadTempPageCnt())
- {
- OrderTempDataPageISP();
- }
- else
- {
- //(J)need back up page and block here
- //g16BlockPage=F_LoadTempBlockPagePtr();
- //if(g16BlockPage>=(gx16PagePerBlock-1))
- //{
- g16PBA=F_LoadTempBlockPBA();
- FlashErase();
- if(EraseFail) MarkBadBlock(10);
- else PushSpareBlock(0x00);
-
- gbWithTempBlock=0;
- //}
- //else
- /*
- {
- ProgramEmptyTempPage();
- g16BlockPage++;
- F_SaveTempBlockPagePtr(g16BlockPage);
- }
- */
- }
-
- XB_FOption1[gM16Ptr]=Option1;
- RestoSprArea();
- }
- ////////////(GM24)add above
- void ReadLinkTableISP(void)
- {
- if(gbNotFisrtM16)
- gxBackUpTempPage=gxTempPageCnt0;
-
- ReadLinkTableROM();
-
- if(gbNotFisrtM16)
- gxTempPageCnt0=gxBackUpTempPage;
- }
- void CheckChangeNewTempBlockISP(void)
- {
- RESET_FLASH();
- if(!gbWithTempBlock)
- {
- PopSpareBlock2();
- gTempBlockPtr=0;
- F_SaveTempBlockPBA(g16PBA);
- F_SaveTempBlockLBA(g16LBA);
- F_SaveTempBlockPagePtr(0);
- F_SaveTempPageCnt(0);
-
- gbWithTempBlock=1;
- }
- else
- { //(J)change temp block
- if(F_LoadTempBlockPagePtr()>=gx16PagePerBlock)
- CheckInitNewTempBlock();
- }
-
- XB_FOption1[gM16Ptr]=Option1;
- }
- //(GM2) time base 1 min
- CBYTE AUTOOFFTABISP[]={
- 1, //2
- 19, //20
- 29, //30
- 59, //60
- 255
- };
- void ClrAutoOffTmrISP()
- {
- ClrAutoOffTmr();
- gxAutoOffMin=0;
- }
- //(GM2) time base 500(ms)
- CBYTE BLTIMERTABISP[]={6,10,20,0};
- extern CBYTE MENUTIMERTAB[];
- void BackLightOnISP()
- {
- M_BackLightLed1On;
- BL_TIMER=BLTIMERTABISP[XB_ADJ_BLTimer];
- if(XB_MENULayer[0]==1)
- MENU_TIMER=10|0x80;
- else
- MENU_TIMER=MENUTIMERTAB[XB_ADJ_BLTimer]*2 | 0x80;
- }
- void swCheckCodeID(void)
- {
- if(gxNewCodeID!=gxSwapCodeID)
- {
- gxSwapCodeID=gxNewCodeID;
- EA=0;
- LoadRsvPage(C_SwapCodeOffset+(gxNewCodeID*6),BUF0xC400,6);
- EA=1;
- }
- }
- void Unicode2Big5ISP(void)
- {
- #if 0
- gxNewCodeID=0; //(J)call Unicode2Big5ISP()
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc406);
- #endif
- }
- void ProcessLanguageSetISP(void)
- {
- #if 0
- //XB_ADJ_Language=lang;
- gx16LangMsgOffset=(WORD)XB_ADJ_Language*C_LanguageMenuMsgNum;
- gxUnicodeTabIndex=T_LanguageCode[XB_ADJ_Language];
- MOVESRAM_XX(gxarFileName,gxarFileNameBuf,128); //(J)backup unicode filename
- if(gxarFileName[1]&1)
- {
- //Unicode2Big5(&gxarFileName);
- gxTemp0=0;
- Unicode2Big5ISP();
- }
- if(gbPlayMode)
- {
- if((XB_File_CurrentType==WMAFILE)&&M_ChkWithId3Tag)
- {
- MOVESRAM_XX(gxarWMATag,gxarWMATagBuf,128);
- gxTemp0=1;
- Unicode2Big5ISP();
- }
- }
- #endif
- }
- void RAMProgISP(void)
- {
- gxDispPtr=0;
- gxFlagReg3=0;
- CodeI2C_CS_LOW;
- gxSwapCodeID=0;
- SystemInit();
- #if(S_SupportSegLcd)
- lcdInitialHT1621();
- #endif
- #if(S_SupportMemoryCard)
- OPT02 |= bit4;
- #else
- OPT02 &=~bit4;
- #endif
- #if(S_SupportAudioADC)
- P1IO=0x03;
- P3IO=0xB9;
- M_AudioADCPowerDown;
- #endif
- PB_HOST[I2CSEL]=0x7F;
- //yu5 PB_HOST[FMI2C]=0xF8;
- M_PowerLEDOn;
-
- if (PB_HOST[0x04]&SET_BIT1)
- {
- SYSTEM_PWR_OFF; //(J)P37=0
- //JM=>PB_DC2DC[DC2DC_Ctrl0]&=~bit0; //(J)switch to LDO1.8V
- //JM=>PB_DC2DC[DC2DC_Ctrl1]&=~bit0;
- //M_EnableLDO18; //regulator power on
- WaitStateOff;
- CPUWAIT=0;
- SET_USBMode;
- CPUCLK_PHY;
- PLL_OFF;
- XB_FUSBBASE[FUSB_TST_EP]=0;
- XB_FUSBBASE[FUSB_PHY_TMS] &= ~SET_BIT0;
- gxWin2kCnt=0;
- gxUsbTempCnt=0;
- USBinit(1);
- GUI_USBDISK();
- while (1)
- {
- /*
- if(!KEYHOLD)
- {
- CLR_nWPRO1; //(J)all Flash LUN write protect by hardware
- nWPRO=0x00; //(J)all Flash LUN write protect
- }
- else
- */
- {
- SET_nWPRO1; //(J)
- nWPRO=0xFF; //(J)Flash LUN write protect by SoftWPROBYTE
- }
-
- if ((USBDISKISP()==2) && (SPEEDID))
- {
- SET_USBGUIFlag;
- if (XB_USBCMDIN<2) XB_USBCMDIN++;
- }
-
- #if(S_SupportForceMP3)
- if(M_ChkForceMp3Mode)
- {
- XB_FUSBBASE[FUSB_TST_EP]|=bit6;
- XB_FUSBBASE[FUSB_PHY_TMS]|=bit0;
- XB_FUSBBASE[FUSB_MAIN]|=0x08;
- break;
- }
- #endif
- }
- }
-
- //MP3 loop
- {
-
- CLR_USBMode;
- PB_HOST[ISR_CTL]&=~USB_INT;
- PB_HOST[ISR_CTL]&=~CARDCD_INT;
- PB_HOST[ADC3BIT_CTRL]=0x00;
- delayclk(2);
- if(PB_HOST[ADC3BIT_CTRL]<6)
- return;
- if (!(PB_HOST[0x04]&SET_BIT1))
- {
- SYSTEM_PWR_ON; //(J)P37=1;//battery power on
- M_EnableLDO18;//M_DisableLDO18; //(G)regulator power down, power control for demo board
- }
-
- if(S_CS42L51||S_SupportAudioADC)
- PB_DC2DC[DC2DC_Ctrl0]|=bit0; //(G)enable IIS_CLK to CODEC or audio ADC
- //JM=>PB_DC2DC[DC2DC_Ctrl0]|=bit0; //(J)switch to DCDC1.8V
- //JM=>PB_DC2DC[DC2DC_Ctrl1]|=bit0;
-
- WaitStateOn;
- CPUWAIT=1;
-
- UI_Loop();
- }
- }
- void DispPlayIcon()
- {//swep
- gxNewCodeID=5;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc415);
- }
- #if 0
- //20060801_Jash
- //###################################################
- void dispShowPlaySymbol(void)
- {
- if(!(M_ChkLowBattery))
- {
- #if(S_SupportLcm)
- LCM_yp=1;
- LCM_xp=100;
- LoadRsvPage(USEROFFSET+C_IconPictureOffset+1,BUF0xE000,1);
- lcmSetPageAddress(LCM_yp,LCM_xp);
- gxIconOffset=(gxPlaySymbolNum*8)+16*3;
- MOVERAM_LCM(&XB_BUF0xE000[gxIconOffset],8);
- #endif
- }
- }
- void dispCheckShowPlaySymbol(void)
- {
- gxPlaySymbolNum=0;
- if(M_ChkSkipMode)
- {
- if(gxKeyMinderBuf&bit2)
- {
- gxPlaySymbolNum=4;
- }
- else
- {
- gxPlaySymbolNum=5;
- }
- }
- else if(!gbStopMode)
- {
- gxPlaySymbolNum=XB_PlayMode-1;
- }
-
- if((!gbStopMode)&&(gxPlaySymbolNum<6))
- {
- dispShowPlaySymbol();
- }
- }
- #endif
- /////////////////////////////(GM25)add below
- #if(!S_CS42L51)
- CBYTE C_DSPVolumeValue[]=
- {
- 0,
- 0x91,0x96,0x9B,0xA0,0xA5,
- 0xAA,0xAF,0xB4,0xB9,0xBE,
- 0xC3,0xC8,0xCD,0xD2,0xD7,
- 0xDC,0xE1,0xE6,0xEB,0xF0,
- 0xF4,0xF7,0xFA,0xFB,0xFE
- };
- #endif
- void EQVolumeControl(BYTE eq)
- {
- #if(S_CS42L51)
-
- if (((XB_MENULayer[0]==4)&&(XB_MENULayer[2]==0))||!gxRampVolume)
- {
- gxibVolume.SBYTE.B0=gxVolumeBias;
- if(eq)
- {
- gxibVolume.SBYTE.B0-=gxEQCompensation;
- }
- gxibVolume.SBYTE.B1=gxibVolume.SBYTE.B0;
- Wait_DataFin();
- WRITE_DSPIO(0x46,gxibVolume.INTEGER);
- }
-
- I2CVolumeControlISP();
- #else
- gxTemp0=eq;
- gxNewCodeID=3;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc415);
-
- #endif
- }
- /////////////////////////////(GM25) add above
- #if(S_CS42L51)
- CBYTE C_DACVolumeValue[]={ 0x0,
- 0x6d,0x74,0x7b,0x82,0x89,
- 0x8f,0x95,0x9b,0xa1,0xa7,
- 0xac,0xb1,0xb6,0xbb,0xc0,
- 0xc4,0xc8,0xcc,0xd0,0xd4,
- 0xd8,0xdb,0xde,0xe1,0xe4};
- #endif
- //void I2CVolumeControlISP(BYTE volume)
- void I2CVolumeControlISP(void)
- {
- #if(!S_CS42L51)
- gxNewCodeID=3;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc412);
- #else
- //xdata IntegerByte ibVolume;
- //gxRampVolume=volume;
-
- gxibVolume.SBYTE.B1=0xff-gxRampVolume;
- gxibVolume.SBYTE.B0=0xff-gxRampVolume;
- Wait_DataFin(); //(J)wait DSP complete data transfer
- //if(volume)
- if(gxRampVolume)
- {
- WRITE_DSPIO(0x46,gxibVolume.INTEGER);
- if(!M_ChkRampUpToVolume) //(GM25)
- {
- if(gxRampVolume==C_DSPVolumeValue[1])
- CodeI2C_CS_LOW;
- }
- /*
- else
- {
- if(gxRampVolume==C_DSPVolumeValue[4]) //0xAA, for ramp up
- CodeI2C_CS_LOW;
- }
- */
- }
- else
- CodeI2C_CS_HIGH;
- //WRITE_DSPIO(0x46,0xfefe);
- #endif
- }
- void ResetCodecISP()
- {
- i2cInitialCS42L51(0);
- gxRampVolume=0;
- I2CVolumeControlISP();
- }
- void RampDownToMuteISP(void)
- {
- gxNewCodeID=3;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc40f);
- }
- void dispShowFileNameId3TagISP(BYTE bShowId3Tag)
- {
- #if 0
- gxTemp0=bShowId3Tag;
-
- gxNewCodeID=2; //(J)call lyrSeekLyricISP()
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc412);
- #endif
- }
- void SelPlayFileISP(BYTE PrePlay)
- {
- gxPrePlay=PrePlay;
-
- if(ChkPLLOff) //(GM2)
- PLLTurnOn();
- RampDownToMuteISP();
- gxNewCodeID=0; //call SelPlayFileISP() in swap code 0
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc400);
- #if 0//(S_SupportLcm)
- if(!M_ChkLowBattery) //(GM7)
- {
- if((XB_MENULayer[0]==7)||(!XB_MENULayer[0] && !XB_MENULayer[1]))
- dispShowFileNameId3Tag(0);
- }
- #endif
- }
- #define MaxSenseline 0
- void KeyboardScanISP(void)
- {
- BYTE u8CompareData;
-
- if (!(M_ChkDebounceMode))
- {
- XSFR1 |= bit2; //(J)active key pad internal pull high
- delayclk(50);
- gxSenseXorData=~PB_HOST[Key_Pad]; //(J)read key pad status and reverse value for convinience
- XSFR1 &= ~bit2;
- gxSenseXorData^=gxKeyMinderBuf; //(J)detect key status change, gxSenseXorData=current key status
- if (gxSenseXorData) //(J) gxKeyMinderBuf=last confirmed key status
- { //key status change
- M_SetDebounceMode; //(J)enter debounce mode and initial debounce counter
- gKeyDebounceCnt=0;
- gxLevelHoldCnt=0;
- gxSenseConfirmData=gxSenseXorData;
- }
- }
- else
- {
- gKeyDebounceCnt++;
- if(gKeyDebounceCnt>=3) //(J)6*5.5ms wait debounce duration
- {
- M_ClrDebounceMode;
-
- XSFR1 |= bit2;
- delayclk(50);
- gxSenseXorData=~PB_HOST[Key_Pad];
- XSFR1 &= ~bit2;
- gxSenseXorData^=gxKeyMinderBuf;
- if (gxSenseXorData)
- { //(J)key status change
- if (gxSenseConfirmData==gxSenseXorData) //(J)double confirm key change status after debounce mode
- {
- gxKeyCode=0;
- u8CompareData=0x01;
-
- while ((!(u8CompareData&gxSenseXorData))&&(u8CompareData!=MaxSenseline))
- { //(J)calculate key code
- gxKeyCode++; //get keycode
- u8CompareData=u8CompareData<<1;
- }
-
- if(u8CompareData & gxKeyMinderBuf)
- { //(J)key change by realase key
- M_ClrPlayKeyFunction;
- if((gxKeyCode==C_PrevKey)||(gxKeyCode==C_NextKey))
- {
- if(M_ChkSkipMode)
- {
- M_ClrSkipMode;
- M_SetFileReadInit;
- M_SetPlayBackEnd; //(J)to trigger fatFileReadInit()
- if(!gbPauseMode) //(GM32)
- M_SetRampUpToVolume;
- //gLedOnCnt=10;
- //gLedOffCnt=120;
- }
- else
- {
- if(M_ChkSkipLevelHoldKey)
- M_ClrSkipLevelHoldKey;
- else
- M_SetPlayKeyFunction; //(J)active key if the key function is triggered by rising edge
- }
- }
- else if((gxKeyCode==C_PlayKey)||(gxKeyCode==C_StopKey)||(gxKeyCode==C_ABKey))
- {
- if(M_ChkSkipLevelHoldKey)
- M_ClrSkipLevelHoldKey;
- else if(M_ChkStopKeyFunction) //(GM4)avoid M_SetPlayKeyFunction after press play key for stop
- M_ClrStopKeyFunction;
- else
- M_SetPlayKeyFunction;
- }
- }
- else
- { //(J)key change by press key
- M_SetPlayKeyFunction; //(J)active key if the key is triggered by falling edge
-
- //20060719_Jash
- #if(S_SupportFM)
- if(gbFMMode)
- {
- if(XB_FM_RunSeek==3)
- {
- XB_FM_RunSeek=0; //clear seek mode
- M_ClrPlayKeyFunction;
- M_SetSkipLevelHoldKey;
- }
- }
- #endif
-
- if((gxKeyCode==C_PrevKey)||(gxKeyCode==C_NextKey)||(gxKeyCode==C_PlayKey)||(gxKeyCode==C_StopKey)||(gxKeyCode==C_ABKey))
- {
- M_ClrPlayKeyFunction;
- }
- }
- gxKeyMinderBuf=gxKeyMinderBuf^u8CompareData;
- }
- else
- {
- M_ClrDebounceMode; //invalid key
- M_ClrPlayKeyFunction;
- }
- }
- else
- {
- M_ClrDebounceMode; //invalid key
- M_ClrPlayKeyFunction;
- }
- }
- }
- }
- void dispShowFontISP()
- {
- /* if(gbFMMode||gbRecordMode)
- {
- dispShowFontROM();
- }
- else
- {
- gxNewCodeID=2;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc403);
-
- if(gbPlayMode&&XB_PlayStep&&(XB_File_CurrentType != WAVFILE)) //(G) avoid 320kbps WMA format audio output is not continuous
- {
- if(M_ChkSkipMode)
- return;
- //Process_PLAY2();
- if(!M_ChkPlayBackEnd)
- {
- while(!MP3_Read1Sector())
- {
- dspTriggerRead();
- if(M_ChkPlayBackEnd)
- break;
- }
- dspTriggerRead();
- }
- }
- */
- }
- void dispShowLyricISP(BYTE u8LyricIndex)
- {
- #if 0
- gxTemp0=u8LyricIndex;
-
- gxNewCodeID=2;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc406);
- #endif
- }
- void SwitchFatParameterISP(void)
- {
- gxNewCodeID=0;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc412);
- }
- #if(!S_CS42L51)
- void EnableHardwareMute(void)
- {
- CodeI2C_CS_HIGH; //(G) eliminate noise as stopping
- delayclk(250);
- delayclk(250);
- delayclk(250);
- delayclk(250);
- delayclk(250);
- PB_DAC[DAC_PowerCtrl]=0x0c;
- }
- #endif
- void ChkCARDInOutISP(void)
- {
- #if(S_SupportMemoryCard)
- //if((CardDetect)||(!(gbPlayMode|gbRecordMode)&&(!CardDetect)))
- if((CardDetect)||((XB_PlayMode < C_FilePlayMode)&&(!CardDetect)))
- { //(J)only sense card insert when no song is playing
- CheckCardInISP();
- if(XB_New_Card_State != XB_Now_Card_State )
- {
- XB_Now_Card_State=XB_New_Card_State;
-
- if((gbPlayMode|gbRecordMode)&&(gxMp3Storage))
- { //(J)playing card
- #if(!S_CS42L51) //(GM22)
- EnableHardwareMute();
- #endif
- Process_STOP();
- //while (ReadDSP_DMA_CTRbit());
- //Disable_DSP();
- }
- //XB_GUI_FLAG=gui;
-
- #if(S_CombineStor)
-
- if(XB_Now_Card_State)
- { //(J)insert card
-
- gxarDiskStatus[gxMp3Storage]=XB_DiskStatus; //(GM26)
- gxarDiskErrorCode[gxMp3Storage]=gDiskErrorCode;
-
- gxMp3Storage=1;
- Process_ScanFileISP();
- gxScanFreeSizeflag[gxMp3Storage]=0; //(GM1)
- XW_TotalFile[0]=gx16arTotalFile[0][0]+gx16arTotalFile[1][0];
- XW_TotalFile[1]=gx16arTotalFile[0][1]+gx16arTotalFile[1][1];
- uiClearPlayedFlag();
-
- if(gx16arTotalFile[0][XB_FileType])
- { //(J)nand FAT is good
- gxMp3Storage=0;
- SwitchFatParameterISP();
- }
-
- XB_GUI_FLAG = 0;
- ResetCodecISP();
- ClrMenuLayer(); //(GM7)avoid not in main screen
- GotoSelFileMode();
-
- }
- else
- { //(J)remove card
- XW_TotalFile[0]=gx16arTotalFile[0][0];
- XW_TotalFile[1]=gx16arTotalFile[0][1];
- if(gxMp3Storage==1)
- {
- //(GM22)
- //if(gbPlayMode)
- //Process_STOP();
- gxMp3Storage=0;
- SwitchFatParameterISP();
- gx16PlayIndex=0; //(J)reset play index for nand
-
- XB_GUI_FLAG = 0;
- ResetCodecISP();
- ClrMenuLayer(); //(GM22)
- GotoSelFileMode();
- }
- else
- {
- if(XW_TotalFile[XB_FileType]) //(GM7)
- {
- if (!XB_MENULayer[0] && !XB_MENULayer[1])
- uiUpdateMainDisplay(bit3); //(J)just update total song display
- }
- else
- GotoSelFileMode();
- }
- }
- #else
- Process_ScanFileISP();
- uiClearPlayedFlag();
- gxScanFreeSizeflag[gxMp3Storage]=0; //(GM1)
-
- XB_GUI_FLAG = 0;
- ResetCodecISP();
- GotoSelFileMode();
- #endif
- }
- }
- #endif
- }
- /***********************yu5*******************************/
- void IR_receive()
- {
- XBYTE i;
- // byte_temp0=PB_HOST[FMI2C];//yu1123 FM_DO_HIGH;
- // delayclk(200);
- // if(!(byte_temp0 &= SET_BIT0))//yu1123 if(!(FM_DO_CH)) FM_DO_HIGH_IR;
- FM_CLK_IR_D0_HIGH;
- delayclk(200);
- byte_temp=PB_HOST[FMI2C];
- if(!(byte_temp & SET_BIT1)) //yu5 FM_DO_HIGH PB_HOST[FMI2C] |= SET_BIT0
- {
- gxNewCodeID=6;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc403);
- /*
- delayclk(50);
- IR_CLK_LOW;
- delayclk(250);
- delayclk(20);
- IR_CLK_HIGH;
- delayclk(250);
- delayclk(20);
- IR_CLK_LOW;
- delayclk(250);
- delayclk(20);
- IR_CLK_HIGH;
- for(i=0;i<8;i++)
- {
- byte_temp=PB_HOST[FMI2C];
- if(!(byte_temp & SET_BIT1))
- IR_DATACnt=IR_DATACnt|SET_BIT0;
- if(i!=7)
- IR_DATACnt=IR_DATACnt<<1;
- delayclk(250);
- delayclk(20);
- IR_CLK_LOW;
- delayclk(250);
- delayclk(20);
- IR_CLK_HIGH;
- }
- IR_CLK_HIGH; //data is over
- IR_DATA=1; */
- }
- }
- /***********************yu5*******************************/
- void TimeoutEventISP(void)
- {
- //20060808_Jash check if DSP enable I2S, then release DAC Reset pin.
- /* //(j) mark
- #if(!S_CS42L51)
- if(M_ChkRampUpToVolume)
- {
- if(READ_DSPIO(0x4e))
- {
- PB_DAC[DAC_PowerCtrl]=0x0d; //(J)enable LR channel of internal DAC
- }
- }
- #endif
- */
- if(T1Flag) //(J)check timer1 flag(timebase=11ms)
- {
- T1Flag=0;
- gx5P5mSCnt++;
- gx5P5mSCnt0++;
- if(!(XSFR1&bit6))
- { //(J)if sysclock/2
- gx5P5mSCnt++;
- gx5P5mSCnt0++;
- }
- }
-
- if(gx5P5mSCnt>=2) //(J)timebase = 11ms
- {
- gx5P5mSCnt=0;
- /***********************yu5*******************************/
- IR_receive();
- if(IR_DATACnt)
- {
- SelectFolderCount=(IR_DATACnt>>4)&0x0F;
- SelectFolderCount=(SelectFolderCount-1)*3;
- SelectFolderCount+=IR_DATACnt&0x0F;
-
- if((SelectFolderCount)>36)//14
- {
- SelectFolderCount=1;
- }
- FolderCountUpDownProcess();
- LastST=0;
- LastMC=0;
- LastSC=0;
- IR_DATACnt=0;
- }
- /***********************yu5*******************************/
- lcdUpdateSegLcdDisplay();
- if(!M_ChkLowBattery) //(GM7)
- KeyboardScanISP();
-
- if (gxKeyMinderBuf) BackLightOnISP();
- //else INTTEMP &= ~KEY_INT;
- /*
- if(gxKeyMinderBuf&(bit4+bit5)) //(J)for volume key
- MENU_TIMER=1|0x80;
- */
- XB_GUI_FLAG=1;
- //yu5 ChkCARDInOutISP();
-
- #if(!S_CS42L51)
- M_SetEnableRampUpVolume;
-
- if(M_ChkRampUpToVolume&&M_ChkEnableRampUpVolume)
- #else
- if(M_ChkRampUpToVolume)
- #endif
- {
- if(!gxRampVolume)
- {
- #if(S_CS42L51)
- WRITE_DSPIO(0x46,0x0A0A); //(GM25)C_CODECVolumeBias
- #endif
- if(!XB_FileType&&!gbFMMode) //(GM20)
- {
- WRITE_DSPIO(0x44,XB_ADJ_EQMode);
- EQVolumeControl(XB_ADJ_EQMode); //(GM25)
- }
- }
- #if(S_CS42L51)
- gxTempR=C_DACVolumeValue[XB_ADJ_CurrentV];
- #else
- gxTempR=C_DSPVolumeValue[XB_ADJ_CurrentV]; //(GM25)
- #endif
- if(gxRampVolume<gxTempR)
- {
- /*
- if((gxTempR-gxRampVolume)>5)
- {
- if(XB_FileType||(gxRampVolume>0xC0))
- gxRampVolume++;
- else
- gxRampVolume+=5;
- }
- else
- gxRampVolume++;
- */
- gxRampVolume=gxTempR;
- }
- else
- {
- M_ClrRampUpToVolume;
- gxRampVolume=gxTempR;
- #if(!S_CS42L51)
- CodeI2C_CS_LOW;
- #endif
- }
- //I2CVolumeControlISP();
- EQVolumeControl(XB_ADJ_EQMode);//(GM25)
-
- }
-
- if(AutoOffTmrH>=6) //(GM2) AutoOffTmrH++ time base 10(s)
- {
- AutoOffTmrH=0;
- gxAutoOffMin++;
- }
- //(GM2) around 5(s)
- if(AutoOffTmrL==10)
- {
- if((gbSelectFileMode||gbStopMode)&&ChkPLLOn)
- PLLTurnOff();
- }
-
-
-
- P1IO=0x33;
- //yu4 P14=1;
- P15=1;
- P1IO=0x13; //yu4 P1IO=0x03;
- P3IO=0xB8; //yu4 P3IO=0xB9;
- //Set input mode
- if(SoundFlag&0x10)//rec mode
- {
- if(SoundFlag&0x80)
- P31=1; //yu4 P30=1;
- else
- P31=0; //yu4 P30=0;
- }
- else
- {
- P31=1; //yu4 P30=1;
- } /*yu3
- if((P14==1)&&(PressIO_Key&0x01))
- {//SC
- SCtest();
- DispFolderFunctionNumber(1);
- } *///yu3
- if((P15==1)&&(PressIO_Key&0x02))
- {//MC
- FolderFunctionNumberFlag=3;
- FolderFunctionNumberTest1();
- DispFolderFunctionNumber(3);
- }
- if((P17==1)&&(PressIO_Key&0x04)) //yu2 key6
- {//LR
- LRtest1();
- DispFolderFunctionNumber(4);
- } /*yu3
- if((P31==1)&&(PressIO_Key&0x08))
- {//ST
- STtest();
- DispFolderFunctionNumber(2);
- } *///yu3
- if((P36==1)&&(PressIO_Key&0x10))
- {
- }
- if(
- ((gxKeyMinderBuf&(bit0+bit1+bit2+bit3+bit4+bit5)))||((P15==0)||(P17==0)|| (0==P36) ) //yu3
- //yu3 ((P31==0)||(P14==0)||(P15==0)||(P17==0)|| (0==P36) )
- )
- //if((gxKeyMinderBuf&(bit0+bit1+bit2+bit3+bit4+bit5))&&(KEYHOLD))
- {
- if(!M_ChkFMAutoScan) //(GM8)
- gxLevelHoldCnt++;
-
- if(!P15||!P17||!P36)
- {
- //if(DirFlag&0x80)
- if(SoundFlag&0x04)
- gxLevelHoldCnt=0;
- if(gxLevelHoldCnt>1)
- {
- gxLevelHoldCnt=0;
- BackLightOnISP();
-
- //else
- if((P15==0))//&&(0==PressIO_Key&0x02)
- {//MC
- PressIO_Key=0x02;
- }
- if((P17==0))//&&(0==PressIO_Key&0x04)
- {//LR
- PressIO_Key=0x04;
- }
- /*yu3 if((P31==0))//&&(0==PressIO_Key&0x08)
- {//ST
- PressIO_Key=0x08;
- } *///yu3
- if((P36==0))//&&(0==PressIO_Key&0x10)
- {//Play REC
- ProcessVolumeUpDownISP();//PressIO_Key=0x10;
- }
- }
- }
- if(gxKeyMinderBuf&bit1)
- {
- if(gxLevelHoldCnt>50) //(J)check play key level hold for about 2 seconds
- {
- FolderStudeLevelDown();gxLevelHoldCnt=0;
- }
- }
- else if(gxKeyMinderBuf&bit5)
- {
- if(gxLevelHoldCnt>50) //(J)check play key level hold for about 2 seconds
- {
-
- FolderStudeLevelUp();gxLevelHoldCnt=0;
-
- }
- }
- else
- {
- //////////////////////////(GM4)
- //////////////////////////
- if(gxKeyMinderBuf&bit0) //(J)check play key level hold for about 2 seconds
- {
-
- if(gxLevelHoldCnt>50)
- {
- {
- gxLevelHoldCnt=0;
- EndSound();
- //M_SetPowerOff;
- }
- }
- }
- /*
- else if(gxLevelHoldCnt>2)
- {
- if(gxKeyMinderBuf&bit5)
- { //volume up
- gxLevelHoldCnt=0;
- ProcessVolumeUpDownISP();
- }
- }
- */
- }
- }
- else
- {
- gxLevelHoldCnt=0;
- M_ClrSkipLevelHoldKey;
- M_ClrPowerOff;
- }
- }
- }
- void I2CPowerDownISP()
- {
- #if(S_CS42L51)
- CodecI2COut(0x02,0xef);
- CodeI2C_CS_LOW;
- #else
- PB_DAC[DAC_PowerCtrl]=0x02; //disable LR channel of internal DAC and Power down DAC
- #endif
- }
- void GUI_VolumeISP()
- {
- gxNewCodeID=5;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc418);
- }
- void ProcessVolumeUpDownISP(void)
- {
- if(XB_ADJ_CurrentV<25)
- XB_ADJ_CurrentV++;
- else
- XB_ADJ_CurrentV=0;
- if(XB_PlayMode>C_FileSelectMode)
- {
- gxRampVolume=C_DSPVolumeValue[XB_ADJ_CurrentV]; //(GM25)
- I2CVolumeControlISP();
- }
- GUI_VolumeISP();
- }
- #if(S_SupportFM)
- void GUI_FM_ShowChanISP()
- {
- gxNewCodeID=1;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc406);
- }
- #endif
- #if(S_SupportFM)
- void FM_SeekISP(void)
- {
- gxNewCodeID=1;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc400);
- GUI_FM_ShowChanISP();
- }
- #endif
- void FMStandbyISP()
- {
- }
- CBYTE CB_MENUNUM2ISP[]={
- 1, // MP3
- 1, // WAV
- 1, // FM
- 1, // voice record
- 1, // FM record
- 7, // SETTING (J)there are 7 options under seeting
- 2, // RECORd
- 1 // FM
- };
- CBYTE CB_MENUNUM3ISP[]= {
- 7, //EQ
- 5, //REPEAT
- 3, //LCD
- 19, //LANGUAGE
- 0, //delete
- 6, //AUTO OFF
- 3, //select drive
- 4, //BACKLIGHT
- 6, //CONTRAST
- };
- CBYTE CB_FIGINDEX3ISP[]= {
- 0x10, //(J)the offset of the first picture of EQ option
- 0x17, //(J)the offset of the first picture of REPEAT
- 0x1c, //(J)the offset of the first picture of Screen
- 0x29, //(J)the offset of the first picture of Language
- 40, //(J)the offset of the first picture of DELETE => this is a fake one for no picture for delete option
- 0x3f, //(J)the offset of the first picture of auto Power Off time
- 0x3c, // the offset of the first picture of select deivce
- 0x25, //(J)the offset of the first picture of backlight time
- 0x1f //(J)the offset of the first picture of Contrast option
- };
- /////////////////////////////////////////(GM3)
- CBYTE T_ContrastValue[]={18,20,24,28,32};
- void ShowSelMenuISP()
- {
- #if (S_SupportLcm)
- if ( XB_MENULayer[2] == 8) //contrast
- {
- if(XB_MENULayer[3]<5)
- gxTemp0=XB_MENULayer[3];
- else
- gxTemp0=XB_ADJ_Contrast;
-
- lcmWriteCmd(0x81); //BRIGHTNESS CONTROLL
- lcmWriteCmd(T_ContrastValue[gxTemp0]);//BRIGHTNESS CONTROLL
- }
-
- GUI_ShowMenu(XB_MENULayer[3]+CB_FIGINDEX3[XB_MENULayer[2]]);
- #endif
- }
-
- /////////////////////////////////////////(GM3)
- void MP3PlayStartISP(void)
- {
- gxNewCodeID=6;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc400);
-
- if(XB_File_CurrentType==WMAFILE)
- {
- if(M_ChkWithId3Tag)
- {
- MOVESRAM_XX(gxarWMATagBuf,gxarWMATag,128);
- gxTemp0=1;
- Unicode2Big5ISP();
- XB_StringPtr=0; //(GM27)
- }
- }
- #if(!S_CS42L51)
- M_ClrEnableRampUpVolume;
- // gx10P10mSCnt1=0;
- #endif
- }
- void SELFILEISP(void)
- {
- //RampDownToMuteISP();
-
- if(!XB_NoFile&&(!gbPauseMode))
- {
- RampDownToMuteISP();
- gxNewCodeID=0; //(J)call ForwardFileISP()
- if(gxTemp0)
- {
- //(J)call BackwardFileISP();
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc409);
- M_SetBackwardFile;
- }
- else
- {
- //(J)call ForwardFileISP();
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc40C);
- M_ClrBackwardFile;
- }
-
- SelPlayFile(SET_BIT1 | SET_BIT0);
-
- if(gbPlayMode)
- {
- if(XB_File_CurrentType==C_SubDir)
- {
- SET_PLAYMODE(C_FileSelectMode);
- M_ClrDataFormatError;
- }
- else
- MP3PlayStartISP();
- }
- }
- }
- /**/
- void FFKeyProcISP()
- {
- switch (XB_MENULayer[0])
- {
- case 0:
-
- gxTemp0=0;
- SELFILEISP();
-
- //SELFILE(0);
- break;
-
- // case 1: //volumn control
- // break;
- case 2:
- if(XB_MENULayer[1]<7)
- XB_MENULayer[1]++;
- else
- XB_MENULayer[1]=0;
-
-
- if ((XB_MENULayer[1] == 1) && !WithREC) XB_MENULayer[1]++; //(J)No Recorder function => skip Voice Playback option
- if ((XB_MENULayer[1] == 2) && !WithFM) XB_MENULayer[1]++; //(J)No FM function => skip FM record option
- if ((XB_MENULayer[1] == 3) && !WithREC) XB_MENULayer[1]++; //(J)No Recorder function => skip Voice record option
- if ((XB_MENULayer[1] == 4) && !WithFM) XB_MENULayer[1]++; //(J)No FM function => skip FM record option
- if (WithREC&&(XB_MENULayer[1] >= 7)) XB_MENULayer[1]=0; //(J)Add this line if EXIT option is not needed
- ;//GUI_ShowMenu(XB_MENULayer[1]);
- break;
-
- case 3:
- XB_MENULayer[2]++;
- #if((S_CombineStor)||(!S_SupportMemoryCard))
- if(XB_MENULayer[2]==6) XB_MENULayer[2]++; //(J)check if need skip device select
- #endif
- if (XB_MENULayer[2]>= CB_MENUNUM2[XB_MENULayer[1]]) //(J)check boundary of Menu layer 2
- XB_MENULayer[2]=0;
-
- // GUI_ShowMenu(XB_MENULayer[2]+C_FirstSettingPicture); //(J)Show picture for current option
- break;
-
- case 4:
- XB_MENULayer[3]++;
- if (XB_MENULayer[3]>=CB_MENUNUM3ISP[XB_MENULayer[2]]) //(J)Check boundary of Menu layer 3
- XB_MENULayer[3]=0;
-
- if (XB_MENULayer[2]==0) //(J)for real time change EQ effect when different EQ is selected
- {
- if(XB_MENULayer[3]<6)
- gxTempR=XB_MENULayer[3];
- else
- gxTempR=XB_ADJ_EQMode;
-
- if(!XB_FileType&&!gbFMMode) //(GM20)
- {
- WRITE_DSPIO(0x44,gxTempR);
- EQVolumeControl(gxTempR);//(GM25)
- }
- }
-
- //ShowSelMenuISP();
- break;
-
- // case 5:
- // break;
-
- // case 6:
- // break;
-
- case 7: //DELETE
- //ForwardFile();
- gxNewCodeID=0; //(J)call ForwardFileISP();//(GM6)
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc40C);
- SelPlayFile(SET_BIT1);
- break;
- // case 8:
- //FORMAT
- // break;
-
- case 9:
- //wait key
- //WaitKeyProcess();
- break;
-
- case 10:
- #if(S_SupportFM)
- //FM
- //XB_FM_RunSeek=1;
- gxFMSeekDir=1;
- FM_SeekISP();
- #endif
- break;
-
- // case 11:
- // RECORD
- // break;
- }
- }
-
- void BFKeyProcISP()
- {
- switch (XB_MENULayer[0])
- {
- case 0:
- gxTemp0=1;
- SELFILEISP();
- //SELFILE(1);
- break;
-
- case 2:
- if(XB_MENULayer[1])
- XB_MENULayer[1]--;
- else
- XB_MENULayer[1]=7;
-
- if (XB_MENULayer[1] == 7) XB_MENULayer[1]--; //(J)if you don't need EXIT option
- if ((XB_MENULayer[1] == 4) && !WithFM) XB_MENULayer[1]--; //(J)No FM => No FM record option
- if ((XB_MENULayer[1] == 3) && !WithREC) XB_MENULayer[1]--; //(J)No Record => No Voice Record option
- if ((XB_MENULayer[1] == 2) && !WithFM) XB_MENULayer[1]--; //(J)No FM => No FM option
- if ((XB_MENULayer[1] == 1) && !WithREC) XB_MENULayer[1]--; //(J)No Record => No Voice Playback option
-
- //GUI_ShowMenu(XB_MENULayer[1]);
- break;
-
- case 3:
- XB_MENULayer[2]--;
- if (XB_MENULayer[2] >= CB_MENUNUM2[XB_MENULayer[1]]) XB_MENULayer[2]=CB_MENUNUM2[XB_MENULayer[1]]-1;
- #if((S_CombineStor)||(!S_SupportMemoryCard))
- if(XB_MENULayer[2]==6) XB_MENULayer[2]--; //(J)check if need skip device select
- #endif
- //GUI_ShowMenu(XB_MENULayer[2]+C_FirstSettingPicture);
- break;
-
- case 4:
- XB_MENULayer[3]--;
- if (XB_MENULayer[3] >= CB_MENUNUM3ISP[XB_MENULayer[2]]) XB_MENULayer[3]=CB_MENUNUM3ISP[XB_MENULayer[2]]-1;
- if (XB_MENULayer[2]==0) //(J)for real time change EQ effect when different EQ is selected
- {
- if(XB_MENULayer[3]<6)
- gxTempR=XB_MENULayer[3];
- else
- gxTempR=XB_ADJ_EQMode;
- if(!XB_FileType&&!gbFMMode) //(GM20)
- {
- WRITE_DSPIO(0x44,gxTempR);
- EQVolumeControl(gxTempR);//(GM25)
- }
- }
- //ShowSelMenuISP();
- break;
-
- // case 5:
- // break;
-
- // case 6:
- // break;
-
- case 7: //DELETE
- //BackwardFile();
- gxNewCodeID=0; //(J)call BackwardFileISP();//(GM6)
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc409);
- SelPlayFile(SET_BIT1);
- break;
-
- // case 8:
- //FORMAT
- // break;
- case 9:
- //wait key
- // WaitKeyProcess();
- break;
-
- case 10:
- #if(S_SupportFM)
- //FM
- //XB_FM_RunSeek=1;
- gxFMSeekDir=0;
- FM_SeekISP();
- #endif
- break;
- // case 11:
- //RECORD
- // break;
- }
- }
- void REC_return()
- {
- if( (SoundFlag&0x10)||(DirFlag&0x20) )
- {
- StopREC();
- {
- WavToMp3();
- InLastLevel();
- DirFlag&=0xdf;
- }
- }
- }
- void BaseSCMCST()
- {
-
- REC_return();
- SelectFolderCountUpDown();
- //root ok
- InLastLevel();
- LR_CountNum=0;
- }
- void MoveFile()
- {
- FFKeyProcISP();
- if(gxarFileName[2]=='.')
- FFKeyProcISP();
- }
- void FolderFunctionNumberTest()//ok
- {
- if(FolderFunctionNumberFlag==1)
- FunctionTest=LastST;
- if(FolderFunctionNumberFlag==2)
- FunctionTest=LastSC;
- /*
- if(FolderFunctionNumberFlag==3)
- FunctionTest=LastMC;
- */
- #if 1
- BaseSCMCST();
- while(1)
- {
- if(FolderFunctionNumberFlag==1)
- {
- if((gxarFileName[2]=='S')&&(gxarFileName[3]=='T') )
- break;
- else
- FFKeyProcISP();
- }
- if(FolderFunctionNumberFlag==2)
- {
- if((gxarFileName[2]=='S')&&(gxarFileName[3]=='O') )
- break;
- else
- FFKeyProcISP();
- }
- }
- PlayKeyIsp();//play nusic
- //autoplay
- //FunctionTest=gx16CurrentDirFileIndex;
- FunctionTest|=0x80;
- #else
- if(0==(FunctionTest&0x80))
- {
- BaseSCMCST();
- while(1)
- {
- if(FolderFunctionNumberFlag==1)
- {
- if((gxarFileName[2]=='S')&&(gxarFileName[3]=='T') )
- break;
- else
- FFKeyProcISP();
- }
- if(FolderFunctionNumberFlag==2)
- {
- if((gxarFileName[2]=='S')&&(gxarFileName[3]=='C') )
- break;
- else
- FFKeyProcISP();
- }
- if(FolderFunctionNumberFlag==3)
- {
- if((gxarFileName[2]=='M')&&(gxarFileName[3]=='C') )
- break;
- else
- FFKeyProcISP();
- }
- }
- PlayKeyIsp();//in sc fold
- DirFlag|=0x04;
- if(FunctionTest&0x7f )
- {
- while(gxarFileName[3]!='0'+( FunctionTest&0x0f) )
- FFKeyProcISP();//last point
- MoveFile();
-
- }
- FunctionTest=gx16CurrentDirFileIndex;
- PlayKeyIsp();//play nusic
- FunctionTest|=0x80;//0x80 now is sc
- }
- else
- {
- FFKeyProcISP();
- FunctionTest=gx16CurrentDirFileIndex;
- FunctionTest|=0x80;
- }
- #endif
- if(FolderFunctionNumberFlag==1)
- LastST=FunctionTest;
- if(FolderFunctionNumberFlag==2)
- LastSC=FunctionTest;
- if(FolderFunctionNumberFlag==3)
- LastMC=FunctionTest;
- }
- void FolderFunctionNumberTest1()//ok
- {
- // if(FolderFunctionNumberFlag==3)
- FunctionTest=LastMC;
- if(0==(FunctionTest&0x80))
- {
- REC_return();
- SelectFolderCountUpDown();
- //root ok
- LR_CountNum=0;
- // BaseSCMCST();
- while(1)
- {
- {
- if((gxarFileName[2]=='B')&&(gxarFileName[3]=='T') )
- break;
- else
- FFKeyProcISP();
- }
- }
- PlayKeyIsp();//in BMT/MC fold
- DirFlag|=0x08;
- if(FunctionTest&0x7f )
- {
- while(gxarFileName[3]!='0'+( FunctionTest&0x0f) )
- FFKeyProcISP();//last point
- MoveFile();
-
- }
- FunctionTest=gx16CurrentDirFileIndex;
- PlayKeyIsp();//play nusic
- FunctionTest|=0x80;//0x80 now is sc
- }
- else
- {
- FFKeyProcISP();
- FunctionTest=gx16CurrentDirFileIndex;
- FunctionTest|=0x80;
- }
- LastMC=FunctionTest;
- }
- void LRtest1()//ok
- {
- FunctionTest=LastLR;
- BaseSCMCST();
-
- // LR fold
- while(1)
- {
- if((gxarFileName[2]=='L')&&(gxarFileName[3]=='R') )
- break;
- else
- FFKeyProcISP();
- }
- PlayKeyIsp();//in lr fold
- DirFlag|=0x04;
- //LR_CountNum|=0x40;
-
- if(0==(FunctionTest&0x80))
- {
-
- PlayKeyIsp();//play nusic
- FunctionTest=1;
- FunctionTest|=0x80;//0x80 now is sc
- //LR_CountNum=1;
- LR_CountNum|=0x40;
-
- }
- else
- {
- if(FunctionTest&0x7f )
- {
- if(( 1+(FunctionTest&0x0f) )==(gx16TotalSubDirInCurrentDir+gx16TotalPlayFileInCurrentDir))
- { LastMC=0;
- FunctionTest=0;
- }
- while(gxarFileName[5]!='0'+( FunctionTest&0x0f)+1 )
- FFKeyProcISP();//last point
- }
- PlayKeyIsp();//play nusic
- FunctionTest=gx16CurrentDirFileIndex;
- FunctionTest|=0x80;
- LR_CountNum|=0x40;
- }
- LastLR=FunctionTest;
- }
- #if 0
- void LRtest()//ok
- {//LR start
- #if 0
- BaseSCMCST();
- // sc等 fold
- while(1)
- {
- if((gxarFileName[2]=='L')&&(gxarFileName[3]=='R') )
- break;
- else
- FFKeyProcISP();
- }
- PlayKeyIsp();//in lr fold
- PlayKeyIsp();//play nusic
- DirFlag|=0x04;
- LR_CountNum=1;
- LR_CountNum|=0x80;//80
- #endif
- }
- void LRtestNext()//ok
- {
- #if 0
- XBYTE temp0;
- //root
- WavToMp3();//InMP3();
- //root ok
- InLastLevel();
- while(gxarFileName[3]!='R')
- FFKeyProcISP();
-
- PlayKeyIsp();//in LR fold
- //enter next LR file
- if(DirFlag&0x10)
- {
- //DirFlag&=0xef;
- SoundFlag=0;
- DirFlag&=0x4c;
- }
- else
- {
- //change level
- //enter LR
- while(gx16CurrentDirFileIndex<(LR_CountNum&0x0f) )
- {
- FFKeyProcISP();
-
- }
-
-
- PlayKeyIsp();//play nusic
- LR_CountNum=LR_CountNum&0x0f;
- LR_CountNum|=0x40;
-
- if(gx16TotalPlayFileInCurrentDir==(LR_CountNum&0x0f))
- {
- DirFlag|=0x10;
- }
- }
- DirFlag|=0x04;
- #endif
- }
- #endif
- void MENUKeyProcISP()
- {
- switch (XB_MENULayer[0])
- {
- case 0:
- case 10:
- if(M_ChkFMAutoScan) //(GM8)
- {
- /*
- XB_FM_SeekDir=1;
- XB_FM_RunSeek=2;
- lcmClearLCM();
- M_ClrFMAutoScan;
- */
- }
- else
- {
- ClrMenuLayer();
- XB_MENULayer[0]=2;
- GUI_ShowMenu(XB_MENULayer[1]);
- }
- break;
- case 1:
- GotoMainPorg();
- break;
-
- case 2:
- switch (XB_MENULayer[1])
- {
- case 0: //mp3 play
- //PLL_ON;
- PLLTurnOn();
- if (XB_FileType||gbFMMode)
- {
- //yu5 FMStandbyISP();
- gx16PlayIndex=0;
- XB_FileType=0;
- ClrMenuLayer();
- i2cInitialCS42L51(0);
- if(gbDirMode)
- {
- gx16PlayDirIndex=0; //(J)start from root dir
- fatInitDirMode();
- gx16CurrentDirFileIndex=0;
- }
- SET_PLAYMODE(C_FileSelectMode);
- GotoSelFileMode();
- }
- else
- GotoMainPorg();
- break;
-
- case 1: //wav play
- //PLL_ON;
- PLLTurnOn();
- if (!XB_FileType||gbFMMode)
- {
- //yu5 FMStandbyISP();
- gx16PlayIndex=0;
- XB_FileType=1;
- ClrMenuLayer();
- i2cInitialCS42L51(0);
- GotoSelFileMode();
- }
- else
- GotoMainPorg();
- break;
-
- case 2: //FM
- /*
- //PLL_ON;
- PLLTurnOn();
- gxNewCodeID=1; //(G) call FMProcedure
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc415);
- */
- break;
-
- case 3: //record
- case 4: //record
- //PLL_ON;
- PLLTurnOn();
-
- gxNewCodeID=3; //(G)call RecordProcedure()
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc403);
- if (gbSelectFileMode) //(G)if with gDiskErrorCode
- {
- RampDownToMuteISP();
- i2cInitialCS42L51(0);
- #if(S_SupportFM)
- if(gbFMMode)
- FMStandbyISP();
- #endif
- }
- #if(!S_SupportAudioADC)
- else
- {
- gxRampVolume=C_DSPVolumeValue[XB_ADJ_CurrentV]; //(GM25)
- I2CVolumeControlISP();
- CodeI2C_CS_LOW;
- }
- #endif
- break;
- case 5: //setting
- XB_MENULayer[0]=3;
- GUI_ShowMenu(C_FirstSettingPicture);
- break;
- /*
- case 6://Show Version
- XB_MENULayer[0]=9;
- GUI_ShowMenu1(C_VersionPageOffset);
-
- //lcmClearLCM();
- //fatCheckFreeSize(); //(GM1)
- //gxTemp0=0;
- //ShowRemainCapacity();
-
- break;
-
- default:
- GotoMainPorg();
- break;
- */
- }
- break;
-
- case 3:
- XB_MENULayer[0]=4;
- switch (XB_MENULayer[2])
- {
- /*
- case 0: //EQ SETTING
- XB_MENULayer[3]=XB_ADJ_EQMode;
- ShowSelMenuISP();
- break;
- case 1: //REPEAT
- XB_MENULayer[3]=gxRepeatMode;
- ShowSelMenuISP();
- break;
- case 2: //LCD
- XB_MENULayer[3]=0;
- ShowSelMenuISP();
- break;
- case 3: //LANGUAGE
- XB_MENULayer[3]=XB_ADJ_Language;//(GM3)
- ShowSelMenuISP();
- break;
- */
- case 4: //DELETE
- if((gbFMMode)||(XB_NoFile))
- {
- GotoMainPorg();
- }
- else
- {
- gxNewCodeID=5; // call InitDelProcessISP() //(GM4)
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc400);
-
- SelPlayFile(SET_BIT1);
- }
- break;
- /*
- case 5: //AUTO OFF
- XB_MENULayer[3]=XB_ADJ_AutoOff;
- ShowSelMenuISP();
- break;
- case 6:
- XB_MENULayer[3]=gxMp3Storage;
- ShowSelMenuISP();
- break;
-
- case 7: //exit
- GotoMainPorg();
- break;
- */
- }
-
- break;
-
- case 4:
- if(XB_MENULayer[3]>=(CB_MENUNUM3ISP[XB_MENULayer[2]]-1)) //(J)for exit item
- {
- GotoMainPorg();
- }
- else
- {
- switch (XB_MENULayer[2])
- {
- /*
- case 0: //EQ SETTING
- ProcessEQSet(XB_MENULayer[3]);
- GotoMainPorg();
- break;
- case 1: //REPEAT
- ProcessRepeatSet(XB_MENULayer[3]);
- GotoMainPorg();
- break;
- case 2: //LCD
- if (XB_MENULayer[3]==1)
- {
- XB_MENULayer[2]=7;
- XB_MENULayer[3]=XB_ADJ_BLTimer;
- if(XB_MENULayer[3]>2) XB_MENULayer[3]=0;
- }
- else if (XB_MENULayer[3]==0)
- {
- XB_MENULayer[2]=8;
- XB_MENULayer[3]=XB_ADJ_Contrast;
- if(XB_MENULayer[3]>4) XB_MENULayer[3]=0;
- }
- ShowSelMenuISP();
- break;
-
- case 3: //LANGUAGE
- XB_ADJ_Language=XB_MENULayer[3];
- ProcessLanguageSetISP();//(GM3)
- GotoMainPorg();
- break;
- */
- case 4: //DELETE
- break;
-
- /*
- case 5: //AUTO OFF
- ProcessAutoOffSet(XB_MENULayer[3]);
- GotoMainPorg();
- break;
- case 6: //select device
- if(gxMp3Storage!=XB_MENULayer[3])
- {
- gxMp3Storage=XB_MENULayer[3];
- Process_STOP();
- CHG_MediaType(gxMp3Storage);
- XB_GUI_FLAG=1;
- ChkCARDInOut0ISP();
- //ChkCARDInOut0(1);
- //gxScanFreeSizeflag[gxMp3Storage]=0;//(GM1)
- //fatCheckFreeSize();
- }
- else
- GotoMainPorg();
- break;
- case 7: //BACKLIGHT
- ProcessBLSet(XB_MENULayer[3]);
- GotoMainPorg();
- break;
- case 8: //CONTRAST
- ProcessContrastSet(XB_MENULayer[3]);
- GotoMainPorg();
- break;
- */
- }
- }
- break;
-
- // case 5:
- // break;
- // case 6:
- // break;
- case 7: //DELETE
- if(XB_File_CurrentType!=C_SubDir)
- {
- /*(G)move to DeleteProcedure()
- #if(S_SupportMemoryCard)
- if((gxMp3Storage==1)&&(!nCardWPRO))
- {
- LCM_xp=0;
- LCM_yp=0;
- GUI_ShowSmallString((XBYTE*)(Str_SDWriteProtect));
- delay500ms();
- delay500ms();
- LCM_xp=0;
- GUI_ShowSmallString((XBYTE*)(Str_Space));
- LCM_xp=0;
- GUI_ShowSmallString((XBYTE*)(T_AskDelete));
- }
- else
- #endif
- */
- {
- gxNewCodeID=5; //(G) call DeleteProcedure
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc403);
- }
-
- if(XB_NoFile)
- {
- GotoMainPorg();
- }
- else
- {
- #if(S_CombineStor)
- gxNewCodeID=0; //(GM6)call ChkSwitchFatParameter
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc415);
- #endif
- SelPlayFile(SET_BIT1);
- }
- }
- break;
- // case 8:
- //FORMAT
- // break;
- case 9:
- //wait key
- // WaitKeyProcess();
- break;
- // case 10:
- //FM
- // GotoMainPorg();
- // break;
- // case 11:
- //RECORD
- // break;
- }
- }
- void UpdateCMPCNT()
- {
- if(XB_PLL_MODE>=10)
- CMPCNT=CB_CMPCNT_Code1[XB_PLL_MODE-9];
- }
- void StopBase()
- {
- if( gbPlayMode || gbPauseMode)
- StopKeyProc();
- }
- void SelectFolderCountUpDown()
- {
- SoundFlag=0;
- //Play music
- //stop key
- StopBase();
- /*
- if( gbPlayMode || gbPauseMode)
- {
- //lcmClearLCM();
- StopKeyProc();
- // M_SetStopKeyFunction;
- }
- */
- //stop music
- //to ..
- if(DirFlag&0x04)
- {
- DirFlag&=0xFB;
- ReturnUpFold();
- }
- //return folder1 st sc
- if(DirFlag&0x40)
- {
- DirFlag&=0xbf;
- ReturnUpFold();
- }
- //return ABC
- if(DirFlag&0x08)
- {
- DirFlag&=0xf7;
- ReturnUpFold();
- }
- //return root level 1-12
- DirFlag=0;
- LastST&=0x7f;
- LastMC&=0x7f;
- LastSC&=0x7f;
- LastLR&=0x7f;
- }
- void InLastLevel()
- {
- //in common
- DispFolderNumber(SelectFolderCount);
- gxTempR=(SelectFolderCount-1)/3+1;
- if(gxTempR<10)
- {
- while(gxarFileName[6]!=('0'+gxTempR ) )
- FFKeyProcISP();
- }
- else if(gxTempR==10)
- {
- while(gxarFileName[6]!='A' )
- FFKeyProcISP();
- }
- else if(gxTempR==11)
- {
- while(gxarFileName[6]!='B' )
- FFKeyProcISP();
- }
- else if(gxTempR==12)
- {
- while(gxarFileName[6]!='C' )
- FFKeyProcISP();
- }
- PlayKeyIsp();//in level 1-12
- DirFlag|=0x40;
- gxTempR=(SelectFolderCount-1)%3+1;
- {
- if(gxTempR==1)
- {
- while(gxarFileName[6]!='1' )
- FFKeyProcISP();
- }
- else if(gxTempR==2)
- {
- while(gxarFileName[6]!='2' )
- FFKeyProcISP();
- }
- else// if(gxTempR==3)
- {
- while(gxarFileName[6]!='3' )
- FFKeyProcISP();
- }
- //while(gxarFileName[9]!='A'+gxTempR )
- //FFKeyProcISP();
- }
- PlayKeyIsp();
- DirFlag|=0x08;
- }
- void FolderCountUpDownProcess()
- {
- REC_return();
- /*
- if( (SoundFlag&0x10)||(DirFlag&0x20) )
- {
- SoundFlag=0;
- DirFlag=0;
- LR_CountNum&=0x0f;
- }
- */
- LR_CountNum=0;
- SelectFolderCountUpDown();
- InLastLevel();//SelectFolderCountUpBase();
- DispFolderFunctionNumber(5);
- }
- void Process_sayPoint()
- {
- }
- void ReturnUpFold()
- {
- while(gxarFileName[2]!='.')
- BFKeyProcISP();
- PlayKeyIsp();
- }
- void PlayKeyFunctionISP(void)
- {
- if(SoundFlag&0x04)
- {
- gxKeyCode=0;
- return;
- }
- if (M_ChkPlayKeyFunction)
- {
- M_ClrPlayKeyFunction;
- ClrAutoOffTmrISP(); //(J)reset all power off counter AutoOffTmrH,AutoOffTmrL
- if(DirFlag&0x80)DirFlag&=0x7f;
- /*
- if((gxKeyCode==C_NextKey)||(gxKeyCode==C_PrevKey))
- {
- REC_return();
- if( (SoundFlag&0x10)||(DirFlag&0x20) )
- {
- SoundFlag=0;
- DirFlag=0;
- LR_CountNum&=0x0f;
- }
- }
- */
-
-
- switch(gxKeyCode)
- {
- /*
- case C_HoldKey: //(J)Key lock => do nothing
- break;
- */
- case C_RepeatKey:
- if( gbPlayMode || gbPauseMode)
- {
- StopKeyProc(); //repeat one
- MP3PlayStartISP();
- }
- break;
-
- case C_PlayKey:
- if( (XB_File_CurrentType==C_SubDir)||(gbRecordMode) )
- ;
- else
- PlayKeyIsp();
- break;
- /*
- case C_StopKey:
- StopKeyProc();
- break;
- */
- case C_NextKey:
- FolderFunctionNumberFlag=1;
- FolderFunctionNumberTest();
- DispFolderFunctionNumber(2);
- break;
-
- case C_PrevKey:
- FolderFunctionNumberFlag=2;
- FolderFunctionNumberTest();
- DispFolderFunctionNumber(1);
- break;
- //SelectFolderCountDown();
- case C_VolumeUpKey:
- /*
- if(SoundFlag&0x02)
- {
- //SoundFlag&=0xfd;
- LR_CountNum|=0x10;
-
- }
- else
- */
- {
- DirFlag=0;PressIO_Key=0;
- LR_CountNum=0;
- SoundFlag&=0x1f;
-
- }
- PlayRECFunction();
- break;
-
-
- case RecordingKey: //Use for menu
- LR_CountNum=0;
- if(SoundFlag&0x10)
- {
- PlayKeyIsp();//REC stop
- SoundFlag=0;
- DirFlag=0x20;//WAV 状态
- DispFolderFunctionNumber(5);
- }
- else
- {
- DirFlag=0;
- SoundFlag=0x40;//
- DelWavAll();
- DispFolderFunctionNumber(6);
- }
- break;
-
- default:
- break;
- }
- }
- }
- //###################################################
- void lyrSeekLyricISP(void)
- {
- #if 0
- gxNewCodeID=2; //(J)call lyrSeekLyricISP()
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc400);
- #endif
- }
- void fatFileSeekISP(void)
- {
- gxNewCodeID=2;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc40f);
-
- }
- void fatFileReadInitISP(void)
- {
- if(M_ChkFileReadInit)
- {
- M_ClrFileReadInit;
- fatFileSeekISP();
- lyrSeekLyricISP();
- }
- else if(XB_ABMode==2)
- {
- #if(!S_CS42L51)
- RampDownToMuteISP();//(GM22)* for DAC
- M_SetRampUpToVolume;
- #endif
- gxPlayTimeMin=gxPlayTimeMinA;
- gxPlayTimeSec=gxPlayTimeSecA;
- if (!XB_MENULayer[0] && !XB_MENULayer[1])
- {
- /*
- if(XB_File_CurrentType==WAVFILE)
- {
- uiUpdateMainDisplay((bit1+bit2));
- LCM_yp=PofTime; //(GM12)
- LCM_xp=AofTime;
- dispShowChar(CB_ASC[(gxPlayTimeHour%10)]);
- }
- else
- uiUpdateMainDisplay(bit1);
- */
- }
- fatFileSeekISP();
- lyrSeekLyricISP();
- }
- else
- {
- RampDownToMuteISP();
- if(gxRepeatMode<3)
- {
- //if(gxRepeatMode!=1)
- if((gxRepeatMode!=1)||M_ChkDataFormatError)//(N)_M 1 for repeate mode == 1
- {
- M_SetCallByFileInit;
- if(M_ChkBackwardFile) //(N)_M 1
- {
- gxNewCodeID=0; //call BackwardFileISP()
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc409);
- }
- else
- {
- //JM=>ForwardFile();
- gxNewCodeID=0; //(J)call ForwardFileISP()
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc40C);
- }
- M_ClrCallByFileInit;
- }
- }
- else
- { //RANDOM PLAY
- //JM=>uiRandomSelectSong();
- gxNewCodeID=0; //(J)call uiRandomSelectSongISP()
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc40F);
- }
-
- if(((!gxRepeatMode) && ((((!gbDirMode)||(XB_FileType==1))&&(gx16PlayIndex==0))||(gbDirMode&&(gx16CurrentDirFileIndex==0)))||(gx16DataFormatErrorCnt>=XW_TotalFile[XB_FileType]))) //(N)_M 1
- {
- gx16DataFormatErrorCnt=0; //(N)_M 1
- if(XB_MENULayer[0] || XB_MENULayer[1]) //(GM15)
- SET_PLAYMODE(C_FileSelectMode);
- else
- GotoSelFileMode();
-
- //JM=>M_ClrDataFormatError; //(J)this line will cause problem when only one error song in storage
- }
- else
- {
- SelPlayFile(SET_BIT1 | SET_BIT0);
- MP3PlayStartISP();
- }
- }
- }
- void GotoMainPorgISP()
- {
- if (XB_MENULayer[0]==4) //(GM7)
- {
- gxNewCodeID=2; //(G) call CheckEQandContrast()
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc409);
- if(gxReturnValue) //(GM25)
- EQVolumeControl(XB_ADJ_EQMode);
- }
-
- ClrMenuLayer();
- // lcmClearLCM();
- //JM=>GUI_SHOWBAT();
-
- if(gbFMMode)
- {
- /*
- M_ClrFMAutoScan; //(GM8)*
- XB_MENULayer[0]=10; //GOTO FM MODE
- SET_PLAYMODE(C_FMMode);
- GUI_FM_ShowChanISP();
- */
- }
- else if (gbRecordMode) //(GM9)
- {
- /*
- XB_MENULayer[0]=11;
- uiUpdateMainDisplay(bit1+bit2+bit3+bit4+bit7);
- LCM_yp=PofTime; //(GM12)
- LCM_xp=AofTime;
- dispShowChar(CB_ASC[(gxPlayTimeHour%10)]);
- LCM_xp=0;
- LCM_yp=2;
- GUI_ShowString((XBYTE*)(&gxarFileName[2]),0 );
- gxTemp0=1;
- ShowRemainCapacity();
- */
- }
- else
- {
- if (XB_NoFile)
- {
- NoFileProcess();
- }
- else if ( gbSelectFileMode )
- {
- //JM=>uiUpdateMainDisplay((bit1+bit3));
-
- SelPlayFile(SET_BIT1 | SET_BIT0);
- }
- else if ( gbPlayMode || gbPauseMode)
- {
- /*
- if(XB_FileType) //(GM12)*
- {
- uiUpdateMainDisplay(bit1+bit2+bit3+bit4);
- LCM_yp=PofTime;
- LCM_xp=AofTime;
- dispShowChar(CB_ASC[(gxPlayTimeHour%10)]);
- }
- else
- {
- uiUpdateMainDisplay((bit1+bit3+bit4));
- }
- if(M_ChkDisplayingLyric)
- {
- if(gxTimeTagCnt)
- {
- gxStringPTR=0;
- dispShowLyric(gxarId3Tag[(gxTimeTagCnt&0x7f)-1]);
- }
- }
- else
- {
- if((MP3BITREG&(bit2+bit3))&&(!M_ChkWithLyric)) //(J)check play mode or pause mode
- {
- dispShowFileNameId3Tag(M_ChkWithId3Tag);
- }
- else
- {
- dispShowFileNameId3Tag(0);
- }
- }
- */
- }
- }
- }
- void GUI_PLAY2ISP()
- {
- XB_chgclock=0;
- if(gx16BitRate)
- {
- if(gx16PlayTempCnt>=gx16BitRate)
- {
- gx16PlayTempCnt-=gx16BitRate;
- AddTime();
- gxPlayTimeSecBak++;
- if(gxPlayTimeSecBak>60)
- {
- gxPlayTimeSecBak=0;
- gxPlayTimeMinBak++;
- if(gxPlayTimeMinBak>3)
- {
- gxPlayTimeMinBak=0;
- if(FolderStudeLevel<101)
- FolderStudeLevel++;
- else
- FolderStudeLevel=0;
- }
-
- }
- }
- }
- }
- /**/
- void Process_PLAYIsp()
- {
- XBYTE temp=0;
- if(M_ChkSkipMode)
- return;
-
- if(!M_ChkPlayBackEnd)
- {
- while(!MP3_Read1Sector())
- {
- dspTriggerRead();
- if(M_ChkPlayBackEnd)
- break;
- }
-
- dspTriggerRead();
- if(!M_ChkPlayBackEnd)
- {
- dspTriggerRead();
- GUI_PLAY2ISP();
- }
- }
- if(M_ChkPlayBackEnd)
- {
- if(DirFlag&0x80)
- {
- //DirFlag&=0x7f;
- }
- else
- {
- /*
- if(XB_FileType==1)
- {
- Process_STOP();
- Delone();
- }
- */
- if(LastST&0x80)//0x80 now is sc
- {
- StopKeyProc(); //repeat one
- temp=1;
- #if 0
- LastST+=0x01;
- if((gx16TotalPlayFileInCurrentDir+1)==(LastST&0x0f))
- LastST=0x81;
- #endif
- }
- if(LastSC&0x80)//0x80 now is sc
- {
- StopKeyProc(); //repeat one
- temp=1;
- #if 0
- LastSC+=0x01;
- if((gx16TotalPlayFileInCurrentDir+1)==(LastSC&0x0f))
- LastSC=0x81;
- #endif
- }
- if(LastLR&0x80)//0x80 now is sc
- {
- #if 1
- //LastLR+=0x01;
- if((gx16TotalPlayFileInCurrentDir+1)==(LastLR&0x0f))
- LastLR=0x0;
- #endif
- }
- if(LastMC&0x80)//0x80 now is sc
- {
- #if 1
- LastMC+=0x01;
- if((gx16TotalPlayFileInCurrentDir+1)==(LastMC&0x0f))
- LastMC=0x81;
- #endif
- }
-
- if(DirFlag&0x02)
- {//play hello end Play 分数
- Process_STOP();
- temp=1;
- Process_sayPoint();
- DirFlag&=0xfd;
- DirFlag|=0x01;
- }
- else if(DirFlag&0x01)
- {
- Process_STOP();
- ReturnUpFold();
- DirFlag&=0xfe;
- //root ok
- //
- InLastLevel();//SelectFolderCountUpBase();
- temp=1;
- //SoundFlag&=0xfd;
- }
- if(SoundFlag&0x20)
- {
- Process_STOP();
- SoundFlag&=0xdf;
- RecProcess();
- temp=1;
-
- SoundFlag&=0xfb;
- SoundFlag|=0x10;
- }
- if(SoundFlag&0x08)
- {
- //Process_STOP();
- //SoundFlag&=0xdf;
- //M_SetPowerOff;
- OffProcess();
- temp=1;
-
- }
- /*
- if(LR_CountNum&0x80)
- {//play next
- LR_CountNum&=0x7f;
- LR_CountNum|=0x40;
- LR_CountNum++;
- }
- else */
- if(LR_CountNum&0x40)
- {//
- //Process_STOP();
- DirFlag&=0xfb;
- LR_CountNum&=0xbf;
- LR_CountNum|=0x20;
- Process_STOP();
- SoundFlag|=0x40;
- DelWavAll();//先删
- temp=1;
-
- DirFlag&=0xf0;
-
- }
- else if(LR_CountNum&0x10)
- {//LRtestNext
- Process_STOP();
- LR_CountNum&=0x0f;
- LR_CountNum++;
- // LRtestNext();
- temp=1;
- }
- if(temp==0)//else
- {
- CLR_IsLastSector;
- CLR_IsLastSectorAB;
- M_ClrPlayBackEnd;
- fatFileReadInit();
- if(LastMC&0x80)//0x80 now is sc
- {
- if((gx16CurrentDirFileIndex+1)==(gx16TotalSubDirInCurrentDir+gx16TotalPlayFileInCurrentDir))
- LastMC=0;
-
- else
- LastMC=gx16CurrentDirFileIndex|0x80;
- }
- #if 0
- if(LastST&0x80)//0x80 now is sc
- {
- if((gx16CurrentDirFileIndex+1)==(gx16TotalSubDirInCurrentDir+gx16TotalPlayFileInCurrentDir))
- LastST=0;
-
- else
- LastST=gx16CurrentDirFileIndex|0x80;
- }
- if(LastSC&0x80)//0x80 now is sc
- {
- if((gx16CurrentDirFileIndex+1)==(gx16TotalSubDirInCurrentDir+gx16TotalPlayFileInCurrentDir))
- LastSC=0;
-
- else
- LastSC=gx16CurrentDirFileIndex|0x80;
- }
- #endif
- }
- }
- }
- }
- /**/
- void UI_LoopISP(void)
- {
- XSFR2|=(bit2+bit3);
- PB_HOST[I2CSEL]=0x7F;
- #if(S_CS42L51)
- gbWithDspVolumeControl=0; //(J)to disable codec I2C control in ROM code
- WithREC=1;
- PB_DAC[DAC_PowerCtrl]=0x02; //disable LR channel of internal DAC and Power down DAC
- #else
- gbWithDspVolumeControl=1;
-
- #if(S_SupportAudioADC) //(G)REC and FM function use Audio ADC
- WithREC=1;
- WithFM=1;
- //P1IO=73;
- //M_AudioADCPowerDown;
- #else
- WithREC=0;
- WithFM=0;
- #endif
- EnableHardwareMute(); //(GM22)
- //PB_DAC[DAC_PowerCtrl]=0x0c; //(J)enable LR channel of internal DAC
- PB_DAC[DAC_GainCtrl]=0;
-
- #endif
- UI_INIT();
- ClrAutoOffTmrISP(); //(GM2)
- #if(S_SupportFM)
- FMStandbyISP();
- #endif
- #if(S_ActiveDirMode)
- gbDirMode=1;
- #else
- gbDirMode=0;
- #endif
- gxPlayTimeMinBak=0;
- gxPlayTimeSecBak=0;
- gxRepCountMode=0;
- fatSetRecordDirFileName();
- XB_GUI_FLAG=1;
- ChkCARDInOut0ISP();
-
- M_BackLightLed1On;
-
- //(GM3)
- gxTemp4=BUF0xE000;
- LoadSettingISP();
- // SelectFolderCount=4;
- if((XW_TotalFile[XB_FileType])&&(gx16PlayIndex>=gx16arTotalFile[0][XB_FileType]))
- {
- gxMp3Storage=1;
- SwitchFatParameterISP();
- }
- /*
- lcmWriteCmd(0x81); //(GM23)
- lcmWriteCmd(T_ContrastValue[XB_ADJ_Contrast]);
- */
- gx16LangMsgOffset=XB_ADJ_Language*C_LanguageMenuMsgNum;
- gxUnicodeTabIndex=T_LanguageCode[XB_ADJ_Language];
- GotoSelFileMode(); //(GM14)
- DispFolderNumber(SelectFolderCount);//ok
- ShowBATISP();
- //FolderStudeLevel=40;
- DispFolderStudeLevel();
- GUI_VolumeISP();
- LastST=0;
- LastMC=0;
- LastSC=0;
- LastLR=0;
- SoundFlag=0x80;
- RecProcess();
- P1IO=0x03;
- P3IO=0xf9;
- PB_HOST[I2CSEL]=0x7F;
- //yu5 PB_HOST[FMI2C]=0xFA;
- //Power_LED_ON;//on 功放
- //TestInc();
- P14=0; //yu4LCM_RESET_LOW; //yu4
- Start_ISP:
- while (1)
- {
- if (PB_HOST[0x04]&SET_BIT1)
- {
- #if(S_SupportForceMP3)
- if(!M_ChkForceMp3Mode)
- #endif
- {
- if(gbPlayMode)
- {
- #if(!S_CS42L51) //(GM22)
- EnableHardwareMute();
- #endif
- Process_STOP();
- }
-
- //if(gbRecordMode)
- // fatCloseFile();
- if(gbRecordMode)
- EndRecordISP();
-
- #if(S_SupportFM)
- if(gbFMMode)
- FMStandbyISP();
- #endif
-
- SaveSetting(BUF0xE000);
-
- I2CPowerDownISP();
- M_EnableLDO18; //(G)avoid initial USB fail
- SWITCH_CLK(SYSCLK1+DIV1+WAITS);
- RESET_CPU();
- }
-
- }
- #if(S_SupportForceMP3)
- else
- {
- if(M_ChkForceMp3Mode)
- {
- M_ClrForceMp3Mode;
- }
- }
- #endif
-
- //(J)Jacky's loop below////////////////////////////////////////////////////////////////
- TimeoutEventISP(); //20060801
- ProcessTimeoutEventISP();
- PlayKeyFunctionISP();
- //(J)Jacky's loop above////////////////////////////////////////////////////////////////
- if(SoundFlag&0x40)
- {
- if((XB_FileType==1)&&(XB_NoFile))
- {//del wav ok
- SoundFlag&=0xbf;
- //Play beep
-
- WavToMp3();
- while(gxarFileName[2]!='C')
- BFKeyProcISP();
- PlayKeyIsp();
-
- while(gxarFileName[3]!='B')//need change BBB beep
- FFKeyProcISP();
- PlayKeyIsp();
- DirFlag|=0x08;
- SoundFlag|=0x20;
-
-
-
-
-
- }
- }
- if(XB_PlayMode>= C_FilePlayMode)
- ClrAutoOffTmrISP();
- if (gbPlayMode)
- {
- #if(S_SupportMemoryCard)
- if(!(CardDetect&&gxMp3Storage)) //(GM22)
- #endif
- if(M_ChkPlayBackEnd)
- {
- if(DirFlag&0x80)
- {
- Process_STOP();
- //ReturnUpFold();//ReturnRoot();//common
- DirFlag=0x08;
- //while(1);
- FolderCountUpDownProcess();
- goto Start_ISP;
-
- }
- }
- Process_PLAYIsp();//Process_PLAY2();
-
- XSFR1 |= bit2;
- delayclk(50);
-
- if (!M_ChkPlayBackEnd&&(MENU_TIMER<=0x80)&&(PB_HOST[Key_Pad]==0xFF)&&(!M_ChkRampUpToVolume))
- {
- if(gbPlayMode)
- {
- FLASHAOFF;
- ChgDiv1();
- EX0=1;
- PCON = 1;
- EX0=0;
- ChgDiv2();
- FLASHAON;
- #if(S_SupportMemoryCard)
- if(!(CardDetect&&gxMp3Storage)) //(GM22)
- #endif
- Process_PLAYIsp();//Process_PLAY2();
- }
-
- }
- XSFR1 &= ~bit2;
- }
- else if(gbRecordMode)
- {
- gxTemp0=MP3FlashPtr; //(J)backup MP3FlashPtr for further check
- Process_Record();
- if(gxTemp0!=MP3FlashPtr)
- { //(J)data write happen=>check if need to update free space information
- if(!gxClusterSectorIndex)
- {
- gx32arTotalFreeClusterNum[gxMp3Storage]--;
- }
-
- if((XB_MENULayer[0]==1)&&M_ChkUpdateTimeDisplay) //(GM9)
- M_ClrUpdateTimeDisplay;
- }
- if (gDiskErrorCode&0x0f)
- {
- //RESET_BUF();
- //fatCloseFile();
- EndRecordISP(); //(GM6)
- //i2cInitialCS42L51ISP(0);
- ErrorMenu(gDiskErrorCode&0x0f);
- M_ClrUpdateTimeDisplay;
- }
- }
- #if(S_SupportFM)
- else if (gbFMMode)
- {
- if((XB_FM_RunSeek)&&(XB_FM_RunSeek!=3)) //XB_FM_RunSeek=3 means in prepare to leave FM seek mode.
- {
- gxFMSeekDir=2;
- FM_SeekISP();
- }
- }
- #endif
- //if(!gbRecordMode) //20060803_Jash
- //if(!gbRecordMode&&(!M_ChkLowBattery)) //(GM7)
- if(!M_ChkLowBattery) //(GM9)
- {
- GUI_RET();
- }
- //JM=>PowerDownControl();
- }
- }
- void SET_CARDTO()
- {
- if(USBMode) TimeOutCnt=1500/100;
- else TimeOutCnt=1500/250;
- TimeOut=0;
- }
- void CheckCardInISP(void)
- {
- #if(S_SupportMemoryCard)
- XBYTE u8ClkSet;
-
- {
- if(!CardDetect && !XB_Now_Card_State ) OldCardDetect=~CardDetect;
- if(OldCardDetect!=CardDetect) giCardDebounce++;
- else giCardDebounce=0;
- if(giCardDebounce>3)
- {
- giCardDebounce=0;
- OldCardDetect=CardDetect;
- if(CardDetect) CardOut();
- else if (!XB_Now_Card_State)
- {
- u8ClkSet=PB_HOST[CLK_SEL];
- CPUCLK_SYSCLK1;
- MediaClkOn;
- CARD_PWR_ON;
- //JM=>delay500ms();
- delayclk(250);
- delayclk(250);
- if(cardInit(C_ST_SD))
- {
- SET_LUN(C_ST_SD);
- }
- else
- {
- CardOut();
- TempFCTL4 &= 0xfc;
- WRITE_FLASH_FCTL4(TempFCTL4);
- MediaClkOff;
- ErrorCode = 1;
- }
- PB_HOST[CLK_SEL]=u8ClkSet;
-
- }
- }
- }
- #endif
- }
- void ChkCARDInOut0ISP(void)
- {
- AllInit();
-
- #if(S_SupportMemoryCard)
- if(WithCard && !CardDetect)
- {
- while(!XB_Now_Card_State && !ErrorCode)
- {
- CheckCardInISP();
- if(XB_New_Card_State != XB_Now_Card_State )
- XB_Now_Card_State=XB_New_Card_State;
- }
- }
- #endif
-
- #if(S_SupportMemoryCard&&S_CombineStor)
- for(gxMp3Storage=0;gxMp3Storage<2;gxMp3Storage++)
- {
- Process_ScanFileISP();
- gxScanFreeSizeflag[gxMp3Storage]=0; //(GM1)
- }
-
- XW_TotalFile[0]=gx16arTotalFile[0][0]+gx16arTotalFile[1][0];
- XW_TotalFile[1]=gx16arTotalFile[0][1]+gx16arTotalFile[1][1];
- uiClearPlayedFlag();
- if(gx16arTotalFile[0][XB_FileType]||(gx16arTotalFile[1][XB_FileType]==0))
- { //(J)nand FAT is good
- gxMp3Storage=0;
- SwitchFatParameterISP();
- }
- #else
- Process_ScanFileISP();
- gxScanFreeSizeflag[gxMp3Storage]=0; //(GM1)
- uiClearPlayedFlag();
- #endif
- gx16PlayIndex=0;
- XB_FileType=0;
- XB_GUI_FLAG=0;
-
- ResetCodecISP();
-
- //JM=>GotoSelFileMode();
- }
- void Process_ScanFileISP(void)
- {
- gxNewCodeID=5;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc406);
- }
- //#include <sdinit.c>
- #include <sdcmd.c>
- BYTE cardInitISP(BYTE u8Lun)
- {
- gxTemp0=u8Lun;
- #if(S_SupportMemoryCard)
-
- gxNewCodeID=4; //(G) call InitSD
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc400);
- if(gxReturnValue)
- return 0;
- else
- return 1;
- /*
- if(InitSD())
- return 0;
- else
- return 1;
- */
- #endif
- }
- void cardRead10ISP()
- {
- #if(S_SupportMemoryCard)
- if(gxActiveStorageType == C_ST_SD)
- {
- SD_READ_10_fun();
- }
- #endif
- }
- void cardWrite10ISP()
- {
- #if(S_SupportMemoryCard)
- if(gxActiveStorageType == C_ST_SD)
- {
- if(g32SectorAddr>=XL_LBASectors[C_MaxLUNInFlash+2]) //(G)Fix cardcopytest will exceed LBA issue
- ErrorCode=1;
-
- SD_WRITE_10_fun();
- }
- #endif
- }
- /*
- void fatCheckFreeSize()
- {
- gxNewCodeID=3;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc40c);
- }
- */
- void ShowRemainCapacity(void)
- {
- /*
- gxNewCodeID=3;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc409);
- */
- }
- void EndRecordISP()
- {
- gxNewCodeID=3;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc406);
- #if(S_SupportFM)
- FMStandbyISP();
- #endif
- i2cInitialCS42L51(0);
- }
- BYTE USBDISKISP()
- {
- CheckCardIn();
- gxNewCodeID=0;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc403);
-
- return gxReturnValue;
- }
- void PLLTurnOff()
- {
- SWITCH_CLK(SYSCLK1+DIV1+WAITS);
- MS5=0; //(G)avoid MS5 > CPUCLK_SYSCLK1 CMPCNT (46)
- DSP_CLK_SYSCLK1;
- PLL_OFF;
- }
- void PLLTurnOn()
- {
- PLL_ON;
- delayclk(100);
- delayclk(100);
- delayclk(100);
- DSP_CLK_PLLCLK;
- }
- void LoadSettingISP()
- {
- gxNewCodeID=1;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc40c);
-
- }
- void ProcessTimeoutEventISP(void)
- {
- bit bSelectId3Tag;
-
- //(GM2)
- //if(((AutoOffTmrH>AUTOOFFTAB[XB_ADJ_AutoOff]) && (XB_PlayMode < C_FilePlayMode))
- if(((gxAutoOffMin > 24) && (XB_PlayMode < C_FilePlayMode))//AUTOOFFTABISP[XB_ADJ_AutoOff]
- ||(M_ChkPowerOff) )//(J)press playkey for 22mS*100 to power off )
- {
- OffProcess();
- }
-
- gxTempR=0;
- if(gbPlayMode) //
- {
- if(gx16DspOffsetTime>=4)
- {
- gx16DspOffsetTime-=4;
- gxTempR=1;
- gx5P5mSCnt0=0;
- }
- }
- else
- {
- if( ( !(XSFR1&bit6)&&(gx5P5mSCnt0>=46) ) ||(gx5P5mSCnt0>=92))
- {
- gx5P5mSCnt0=0;
- gxTempR=1;
- }
- }
- if(gxTempR) //(J)timebase = around 500ms, (500/5.46)
- {
- gx5P5mSCnt0=0;
- // ShowBATISP();
- if(!M_ChkLowBattery) //
- {
- DispPlayIcon();
- }
-
- //if(!XB_MENULayer[0])
- if(!(PB_HOST[0x04]&SET_BIT1)) //(GM7)
- {
- if(!XB_MENULayer[0]||((XB_MENULayer[0]==10)&&!M_ChkFMAutoScan)||(XB_MENULayer[0]==11))
- {
- if(!gbStopMode&&!M_ChkLowBattery)
- {
- uiUpdateMainDisplay(bit0);
- gxTemp0=PB_HOST[ADC3BIT_CTRL];
- ShowBATISP();
- if(PB_HOST[ADC3BIT_CTRL]<5)
- {
- M_SetPowerOff;
- OffProcess();//LowSound();
- }
-
- }
- }
- }
- if(M_ChkRecoverNormalDisplay)
- {
- M_ClrRecoverNormalDisplay;
- GotoMainPorg();
- MENU_TIMER=0;
- }
-
- if(M_ChkLowBattery)
- {
- if(gxLowBatteryCnt>=10) //(J)10 seconds
- M_SetPowerOff;
- else
- gxLowBatteryCnt++;
- if(gbPlayMode||gbPauseMode) //(GM7)
- {
- #if(!S_CS42L51) //(GM22)
- EnableHardwareMute();
- #endif
- Process_STOP();
- }
- else if(gbRecordMode)
- {
- EndRecordISP();
- SET_PLAYMODE(C_FileSelectMode);
- }
- /*
- else if(gbFMMode)
- {
- FMStandbyISP();
- SET_PLAYMODE(C_FileSelectMode);
- }
- */
-
- }
- else
- {
- gxLowBatteryCnt=0;
- }
- //----Pause Blink----
- gbIconOnOff=~gbIconOnOff;
- #if 0
- if(WithLCM)
- {
- //if (!XB_MENULayer[0] && !XB_MENULayer[1]&&(!gbFMMode))
- if (!XB_MENULayer[0] && !XB_MENULayer[1]&&(!gbFMMode)&&(!M_ChkLowBattery)) //(GM7)
- {
- if((!M_ChkDisplayingLyric)&&gbIconOnOff)
- {
- if((MP3BITREG&bit0)==0)
- {
- if((MP3BITREG&(bit2+bit3))&&(!M_ChkWithLyric)) //(J)check play mode or pause mode
- {
- //dispShowFileNameId3Tag(M_ChkWithId3Tag);
- bSelectId3Tag=M_ChkWithId3Tag;
- }
- else
- {
- //dispShowFileNameId3Tag(0);
- bSelectId3Tag=0;
- }
-
- if(bSelectId3Tag)
- {
- //if (gxarFileName[XB_StringPtr+2]>=0x80)
- if ((gxarId3Tag[XB_StringPtr+2]>=0x80)&&(gxUnicodeTabIndex<=4)&&(gxUnicodeTabIndex!=C_ENG)) //(GM14)
- XB_StringPtr+=2;
- else
- XB_StringPtr+=1;
-
- if (gxarId3Tag[XB_StringPtr+2]==0)
- XB_StringPtr=0;
- }
- else
- {
- if(gxarFileName[0]>(LCM_WIDTH/8))
- {
- //if (gxarFileName[XB_StringPtr+2]>=0x80)
- if ((gxarFileName[XB_StringPtr+2]>=0x80)&&(gxUnicodeTabIndex<=4)&&(gxUnicodeTabIndex!=C_ENG)) //(GM14)
- XB_StringPtr+=2;
- else
- XB_StringPtr+=1;
-
- if (gxarFileName[XB_StringPtr+2]==0)
- XB_StringPtr=0;
- }
- }
- }
- }
- }
- }
- #endif
- }
- if(M_ChkUpdateTimeDisplay)
- {
-
- M_ClrUpdateTimeDisplay;
- if((XB_File_CurrentType==WAVFILE)||gbRecordMode)
- {
- if( (2<gxPlayTimeSec)&&(SoundFlag&0x04) )SoundFlag&=0xfb;//解封键
- if( (1<gxPlayTimeSec)&&gbRecordMode
- &&(SoundFlag&0x80)
- )
- {
- PlayKeyIsp();//REC stop
- SoundFlag&=0x7f;
- WavToMp3();//in common
- logoSound();
- DirFlag&=0xbf;
- //say hello
- }
- if( (10<gxPlayTimeMin)&&gbRecordMode
- )
- {
- PlayKeyIsp();//REC stop
- SoundFlag=0;
- DirFlag=0x20;//WAV 状态
- }
- if( (9==gxPlayTimeSec)&&gbRecordMode
- &&(SoundFlag&0x10&&(LR_CountNum&0x20))
- )
- {
- DirFlag&=0xbf;
- LR_CountNum&=0xdf;
- PlayRECFunction();
- LR_CountNum|=0x10;
- SoundFlag&=0xef;
- SoundFlag|=0x02;
-
- }
- /*
- LCM_yp=PofTime; //(GM12)
- LCM_xp=AofTime;
- dispShowChar(CB_ASC[(gxPlayTimeHour%10)]);
- if(gbRecordMode) //(GM9)
- {
- gxTemp0=1;
- ShowRemainCapacity();
- }
- */
- }
- else
- {
- //uiUpdateMainDisplay(bit1);
- }
- }
-
- }
- bit dspTriggerReadISP()
- {
- #if(S_SupportMemoryCard) //(GM22)
- if(CardDetect&&gxMp3Storage)
- return 0;
- #endif
- if ( ReadDSP_DMA_STATUS() & SET_BIT1 )
- // if (READ_DSPIO(0x4f) & SET_BIT0)
- {
- if (gxDspDataReadyCnt)
- {
- if(!P32) GET_INT(DSP_INT);
- INTTEMP &= ~DSP_INT;
-
- if(XB_File_CurrentType==WMAFILE) //(J)for WMA random point playback
- {
- gx16TempCnt=gx32PlaySectorIndex;
- WRITE_DSPIO(0x47,gx16TempCnt);
- gx16TempCnt=gx32PlaySectorIndex>>16;
- WRITE_DSPIO(0x45,gx16TempCnt);
- gx32PlaySectorIndex++;
- }
-
-
- DSPHOSTON=1;
- WRITE_DSP_LEN(0x00,0xff,0xff);
- NowBufDirH = CB_BufHostTable[HostPtr]; //READ
- BUF_SWITCH;
- PB_HOST[DSPBufAct] = CB_BBit_Table[HostPtr]; //READ
- DSP_DMA_ON_READ(0x09);
- DSP_DMA_READ_DONE();
- ///Jacky add below/////
- if((gx32PlaySectorIndex>(gx32ID3V2ASFHeaderLength/512))||(XB_File_CurrentType!=WMAFILE)) //(N)_M 2
- gx16PlayTempCnt+=512; //(J)512 bytes to DSP
- ///Jacky add above/////
- if (!XB_PlayStep)
- {
- return 1;
- //ChangeRate();
- }
- }
- }
- return 0;
- }
- CBYTE T_AdpcmDirNameISP[10]=
- {
- 8,0,'C','O','M','M','E','N','T',' '
- };
- CBYTE T_WaveFileNameISP[12]=
- {
- 'V','O','I','C','E','0','0','0','.','W','A','V'
- }; //"";VOICEXXX.WAV
- void fatSetRecordDirFileNameISP(void)
- {
- BYTE i;
- for(i=0;i<10;i++)
- gxarRecordDirName[i]=T_AdpcmDirNameISP[i];
-
- gxarRecordFileName[0]=12;
- gxarRecordFileName[1]=0;
- for(i=0;i<12;i++)
- gxarRecordFileName[i+2]=T_WaveFileNameISP[i];
-
- gxarRecordFileExt[0]='W';
- gxarRecordFileExt[1]='A';
- gxarRecordFileExt[2]='V';
- }
- void ShowBATISP()
- {
- gxNewCodeID=5;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc409);
- }
- void uiUpdateMainDisplayISP(BYTE u8UpdateMask)
- {
- }
- #if (S_SupportSegLcd)
- //(J)for HT1621 segment LCD
- #define M_LcdOutputDataEnable PB_HOST[LCMMode] &= ~SET_BIT0;
- #define M_LcdOutputDataDisable PB_HOST[LCMMode] |= SET_BIT0;
- #define M_EnableSerialLcdIF PB_HOST[SPI_LCM_CTRL] |= SET_BIT7;
- #define M_DisableSerialLcdIF PB_HOST[SPI_LCM_CTRL] &= ~SET_BIT7;
- #define LCD_CS_HIGH PB_HOST[SPI_LCM_CTRL] |= SET_BIT6;
- #define LCD_CS_LOW PB_HOST[SPI_LCM_CTRL] &= ~SET_BIT6;
- #define LCD_RD_HIGH PB_HOST[SPI_LCM_CTRL] |= SET_BIT2;
- #define LCD_RD_LOW PB_HOST[SPI_LCM_CTRL] &= ~SET_BIT2;
- #define LCD_WR_HIGH PB_HOST[SPI_LCM_CTRL] |= SET_BIT3;
- #define LCD_WR_LOW PB_HOST[SPI_LCM_CTRL] &= ~SET_BIT3;
- #define LCD_DATA_HIGH PB_HOST[SPI_LCM_CTRL] |= SET_BIT4;
- #define LCD_DATA_LOW PB_HOST[SPI_LCM_CTRL] &= ~SET_BIT4;
- #define CHK_LCD_DATA (PB_HOST[SPI_LCM_CTRL] & SET_BIT0)
- void lcdDelayBusClock(void)
- {
- XBYTE i;
- for(i=0;i<5;i++);
- }
- void lcdWrite4bitsHT1621(void)
- {
- M_LcdOutputDataEnable
- LCD_WR_LOW
-
- for(gTempReg=0;gTempReg<4;gTempReg++)
- {
- if(gxLcdData&0x01)
- {
- LCD_DATA_HIGH
- }
- else
- {
- LCD_DATA_LOW
- }
-
- gxLcdData=gxLcdData>>1;
- LCD_WR_LOW
- lcdDelayBusClock();
- LCD_WR_HIGH
- lcdDelayBusClock();
- }
- LCD_DATA_HIGH
- }
- void lcdSetCommandHT1621(void)
- {
- M_LcdOutputDataEnable
- for(gTempReg=0;gTempReg<9;gTempReg++)
- {
- if(gxLcdCommand&0x80)
- {
- LCD_DATA_HIGH
- }
- else
- {
- LCD_DATA_LOW
- }
-
- gxLcdCommand=gxLcdCommand<<1;
-
- LCD_WR_LOW
- lcdDelayBusClock();
-
- LCD_WR_HIGH
- lcdDelayBusClock();
- }
- }
- void lcdInitialReadWriteHT1621(void)
- {
- XBYTE i;
-
- M_LcdOutputDataEnable
- gxLcdAddress=gxLcdAddress|gxLcdMode;
-
- for(i=0;i<9;i++)
- {
- if(gxLcdAddress&0x80)
- {
- LCD_DATA_HIGH
- }
- else
- {
- LCD_DATA_LOW
- }
-
- if (i==3)
- {
- LCD_DATA_LOW
- }
- else gxLcdAddress=gxLcdAddress<<1;
-
- LCD_WR_LOW
- lcdDelayBusClock();
-
- LCD_WR_HIGH
- lcdDelayBusClock();
- }
- LCD_DATA_HIGH
- }
- void lcdSetModeID(void)
- {
- XBYTE i;
-
- M_LcdOutputDataEnable
- for(i=0;i<3;i++)
- {
- if(gxLcdMode&0x80)
- {
- LCD_DATA_HIGH
- }
- else
- {
- LCD_DATA_LOW
- }
-
- gxLcdMode=gxLcdMode<<1;
- LCD_WR_LOW
- lcdDelayBusClock();
-
- LCD_WR_HIGH
- lcdDelayBusClock();
- }
- }
- void lcdSelectHT1621(void)
- {
- LCD_CS_LOW
- lcdDelayBusClock();
- }
- void lcdDeselectHT1621(void)
- {
- LCD_CS_HIGH
- lcdDelayBusClock();
- }
- void lcdClearAllBuffer(void)
- {
- for(gTempReg=0;gTempReg<32;gTempReg++)
- XB_SegLcdBuf[gTempReg]=0x00;
- }
- void lcdUpdateSegLcdDisplay(void)
- {
- XBYTE i;
-
- lcdSelectHT1621();
- gxLcdMode=Write_Mode;
- gxLcdAddress=0x00;
- lcdInitialReadWriteHT1621();
- for(i=0;i<32;i++)
- {
- gxLcdData=XB_SegLcdBuf[i];
- lcdWrite4bitsHT1621();
- }
- lcdDeselectHT1621();
- }
- void lcdInitialHT1621(void)
- {
- PB_HOST[SPI_LCM_CTRL]=0xff; //(J)initial signal state and select SPI for LCD
- lcdDelayBusClock();
- M_EnableSerialLcdIF
- lcdSelectHT1621();
- gxLcdMode=Command_Mode;
- lcdSetModeID(); //enter command mode
- gxLcdCommand=EnableHT1621;
- lcdSetCommandHT1621(); //enable ht1621 system clock
- gxLcdCommand=Disable_Timer;
- lcdSetCommandHT1621(); //disable timer
- gxLcdCommand=Disable_WDT;
- lcdSetCommandHT1621(); //disable watch dog
- gxLcdCommand=Disable_IRQ;
- lcdSetCommandHT1621(); //disable IRQ output
- gxLcdCommand=Bias3_4COM;
- lcdSetCommandHT1621(); //1/3 bias 4 duty
- lcdDeselectHT1621();
-
- lcdClearAllBuffer(); //clear all lcd buffer
- lcdUpdateSegLcdDisplay();
-
- //----turn on LCD----
- lcdSelectHT1621();
- gxLcdMode=Command_Mode;
- lcdSetModeID();
- gxLcdCommand=LCD_On;
- lcdSetCommandHT1621();
- lcdDeselectHT1621();
- //----display init status----
- }
- //(J)for HT1621 segmant LCD
- /**/
- void DispFolderFunctionNumber(BYTE FolderFunctionNumber)
- {
- if(FolderFunctionNumber!=4)
- LR_CountNum=0;
- PressIO_Key=0;
- gxTemp0=FolderFunctionNumber;
- gxNewCodeID=5;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc40c);
- }
- void FolderStudeLevelUp()
- {
- if(FolderStudeLevel<101)
- {
- FolderStudeLevel++;
- DispFolderStudeLevel();
- }
- // XB_ADJ_Contrast=FolderStudeLevel;
- }
- void FolderStudeLevelDown()
- {
- if(FolderStudeLevel>0)
- {
- FolderStudeLevel--;
- DispFolderStudeLevel();
- }
- // XB_ADJ_Contrast=FolderStudeLevel;
- }
- void DispFolderStudeLevel()
- {
- gxTemp0=FolderStudeLevel;
- gxNewCodeID=5;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc40f);
- }
- void DispFolderNumber(BYTE FolderNumber)
- {
- gxTemp0=FolderNumber;
- gxNewCodeID=5;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc412);
- }
- void PlayKeyIsp()
- {
- //////////////////////////////////////(GM2)
- if((!XB_MENULayer[0] && !XB_MENULayer[1])&&ChkPLLOff)
- {
- PLLTurnOn();
- {
- if(XB_PLL_MODE<10)
- SWITCH_CLK(PLLCLK+DIV2+WAITS);
- else
- SWITCH_CLK(PLLCLK+DIV4+WAITS);
-
- UpdateCMPCNT(); //(GM2)*
- }
- }
- //////////////////////////////////////////(GM1) for EndRecord
- if(XB_MENULayer[0]==11)
- {
- EndRecordISP();
- XB_FileType=1;
- //gx16PlayIndex=XW_TotalFile[XB_FileType]-1;
- GotoSelFileMode();
- GotoMainPorg();
- }
- else
- {
- ////////////////////////////////////////
- if((gbSelectFileMode)&&(!XB_NoFile)&&(XB_File_CurrentType!=C_SubDir)&&(!XB_MENULayer[0]))
- MP3PlayStartISP();
- else
- {
- if (XB_MENULayer[0]==4) //(GM7)
- {
- gxNewCodeID=2; //(G) call CheckEQandContrastForPlaykey
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc40c);
- if(gxReturnValue) //(GM25)
- EQVolumeControl(XB_ADJ_EQMode);
-
- }
- else if ((XB_MENULayer[0]==10)) //(GM8)
- {
- /*
- XB_FM_MEM++;
-
- gxNewCodeID=1; //call fmGetMemChannelISP
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc40F);
- #if(S_SupportAudioADC)
- CodeI2C_CS_LOW;
- #endif
- */
- }
-
- PLAYKeyProc();
- /*
- LCM_yp=1;
- LCM_xp=70;
- dispShowChar(CB_ASC[gx16PlayDirIndex/10]);
- dispShowChar(CB_ASC[gx16PlayDirIndex%10]);
- */
- if(!XB_MENULayer[0])
- {
- if(gbPlayMode)
- M_SetRampUpToVolume;
- #if(!S_CS42L51) //(GM32)
- else if(gbPauseMode)
- RampDownToMuteISP();
- #endif
- }
- }
- }
- }
- void logoSound()
- {
- while(gxarFileName[2]!='C')
- FFKeyProcISP();
-
- PlayKeyIsp();
- while(gxarFileName[2]!='H')
- FFKeyProcISP();
- DirFlag|=0x88;
- // DirFlag|=0x80;
- // DirFlag|=0x08;
- PlayKeyIsp();
- }
- /*
- void ReturnRoot()
- {
- while(gxarFileName[2]!='.')
- BFKeyProcISP();
- PlayKeyIsp();//common
- }
- */
- void EndSound()
- {
- //root
- if(SoundFlag&0x10)//rec mode
- {
- StopREC();
- }
- if(XB_FileType==0)
- InWav();
- WavToMp3();
- while(gxarFileName[2]!='C')
- BFKeyProcISP();
-
- PlayKeyIsp();
- while(gxarFileName[3]!='Y')//bye
- FFKeyProcISP();
- SoundFlag=0x08;
- DirFlag=0;
- PlayKeyIsp();
- //SoundFlag|=0x04;
- DispFolderFunctionNumber(5);
- }
- void LowSound()
- {
- /*
- if(SoundFlag&0x01)return;
- SelectFolderCountUpDown();
- SoundFlag=0;
- DirFlag=0;
- while(gxarFileName[2]!='C')//Low
- FFKeyProcISP();
-
- PlayKeyIsp();
- while(gxarFileName[5]!='O')
- FFKeyProcISP();
- SoundFlag=0x08;
- PlayKeyIsp();
- SoundFlag|=0x04;//封键
- */
- }
- void InWav()
- {
- LastST&=0x7f;
- LastMC&=0x7f;
- LastSC&=0x7f;
- MENUKeyProcISP();
- FFKeyProcISP();
- MENUKeyProcISP();//in wav
- }
- void StopREC()
- {
- if(SoundFlag&0x10)
- {
- PlayKeyIsp();//REC stop
- SoundFlag&=0xaf;
- }
- }
- void PlayRECFunction()
- {
- StopREC();
- InWav();
- PlayKeyIsp();
- DirFlag|=0x20; // play rec
- //REC_PLAY();//SelFunction();
- }
- void OffProcess()
- {
- gxTempR=(FolderStudeLevel/10)<<4;
- gxTempR&=0xf0;
- gxTempR|=0x02;//SelectFolderCount&0x0f;
- XB_ADJ_Contrast=gxTempR;
- SaveSetting(BUF0xE000);
- //del wav
- Delone();
- // dispShowChar(CB_ASC[XB_ADJ_Contrast&0x0f]);
- // while(1);
- gxNewCodeID=3;
- swCheckCodeID();
- CALLADDR((CBYTE*)0xc41b);
- SYSTEM_PWR_OFF; //(J)P37=0
- RESET_CPU();
- }
- void MENUBASE()
- {
- MENUKeyProcISP();
- FFKeyProcISP();
- FFKeyProcISP();
- FFKeyProcISP();
- }
- void DelWavBase()
- {
- MENUBASE();
- /* MENUKeyProcISP();
- FFKeyProcISP();
- FFKeyProcISP();
- FFKeyProcISP();
- */
- FFKeyProcISP();
- FFKeyProcISP();
- MENUBASE();
- /* MENUKeyProcISP();
- FFKeyProcISP();
- FFKeyProcISP();
- FFKeyProcISP();
- */
- FFKeyProcISP();
- MENUKeyProcISP();//del
- MENUKeyProcISP();//del ok
- }
- void Delone()
- {
- SoundFlag|=0x04;//封键
- InWav();
- //while(1)
- {
- FFKeyProcISP();
- if(gxarFileName[9]!='0')
- {
- DelWavBase();
- while( gxarFileName[9]!='0')
- MENUKeyProcISP();//del ok
- if(gxarFileName[9]=='0')
- {
- PlayKeyIsp();
- PlayKeyIsp();
- StopKeyProc();
- }
-
- }
- }
- SoundFlag&=0xfb;
- }
- void DelWavAll()
- {
- SoundFlag|=0x04;//封键
- InWav();
- DelWavBase();
- while(!XB_NoFile)
- MENUKeyProcISP();//del ok
- }
- void RecProcess()
- {
- MENUBASE();
- /* MENUKeyProcISP();
- FFKeyProcISP();
- FFKeyProcISP();
- FFKeyProcISP();
- */
- MENUKeyProcISP();//rec
- }
- void WavToMp3()
- {
- StopBase();
- MENUKeyProcISP();
- MENUKeyProcISP();
- }