rsm_util.h
上传用户:poi891205
上传日期:2013-07-15
资源大小:9745k
文件大小:41k
源码类别:

DVD

开发平台:

C/C++

  1. /*
  2. *  Terry,2003/8/7 12:23AM
  3. *  reduce function
  4. *  Maoyong,2004.02.20 15:41PM
  5.    To divide POWER_RESUME, RECORD_KEY, SAME_DISC_RESUME for no confusion
  6.     POWER_RESUME:     when power down, record the current playing pos. 
  7.     RECORD_KEY:       when push RECORD, record the current playing pos
  8.     SAME_DISC_RESUME: when TRAY OUT,  record the current playing pos
  9.    Maoyong, 2004.03.05 13:22
  10.       To move record resume relative functions from  "sysmain2.c" to this file 
  11.    Maoyong  2004.03.18 for combinaton usage
  12.    Maoyong  2004.04.07 fix bug: When shut down power supply, the next same type disc not recorded will do resume play,
  13.                        which is wrong.
  14. */
  15. #ifdef DISC_ID_IN_FLASH
  16. //#include "io_uart0.h"
  17. //#include "UartComm.h"
  18. //static char debug_buffer[64]; //for debugging purpose
  19. extern int      FlashRead(UINT32 iStartAddr, BYTE *pBuf, UINT32 iLen);
  20. extern int      FlashWrite(UINT32 iStartAddr, BYTE *pBuf, UINT32 iLen);
  21. #define TOTAL_RESUME  20    //Number of disc resume 
  22. #define SIZE_PER_ID      64   // Number of bytes storage reserved for disc resume
  23. #define SETUP_MENU_BASE   0 
  24. #define DVD_INFO_BASE   128
  25. #define CDROM_INFO_BASE 180
  26. #define CDDA_INFO_BASE  200
  27. #define VCD_INFO_BASE   220
  28. #define DVD_DISC_INFO  244
  29. #define CDDA_DISC_INFO 248
  30. #define VCD_DISC_INFO  252
  31. typedef struct {
  32. BYTE disc_id[4];
  33. BYTE disc_info[SIZE_PER_ID];
  34. }DISC_RESUME_INFO;
  35. //index table of the disc resume. It will store the latest TOTAL_RESUME  disc
  36. BYTE disc_resume_index[TOTAL_RESUME];
  37. //store the information to flash for resume together with
  38. //array[TOTAL_RESUME+1] stores the disc resume index table.
  39. //array[TOTAL_RESUME+2] and array[TOTAL_RESUME+3] stores the setup information 
  40. #ifdef SETUP_IN_FLASH
  41. DISC_RESUME_INFO disc_resume[TOTAL_RESUME+3]; 
  42. #else
  43. DISC_RESUME_INFO disc_resume[TOTAL_RESUME+1]; 
  44. #endif 
  45. //current index
  46. int current_resume = 0;
  47. #endif 
  48. #ifdef CHECK_RECORD_DISK_PARENT_LVL //Maoyong 2004.03.04
  49. extern void setup_CheckPasswd(void); 
  50. extern int user_input_pwd;
  51. extern void ShowPasswordGUI(void);
  52. #ifdef NEW_PARENTAL_GUI//zhaoyanhua add 2003-11-28 19:50
  53. extern void ExitParentalGUI(void);
  54. #endif
  55. #endif
  56. #ifdef RECORD_KEY//zhaoyanhua add 03-11-6 15:27
  57. extern void osd_DrawRegionString(BYTE xStart, BYTE yStart, const BYTE *str, BYTE fontColor, BYTE bkColor, BYTE r);
  58. extern void osd_init_record(void);
  59. extern void osd_init(void);
  60. #define FAST2NORM    0x01<<0
  61. #define PAUSE2NORM   0x01<<1
  62. #define SLOW2NORM    0x01<<2
  63. #define REALPLAY     1
  64. //#define TRANSFER     0//nono 2004-2-17 18:05
  65. extern void chg2normal_play(UINT8 md,UINT8 realplay);
  66. extern void run_pause_setting(void);
  67. #endif
  68. #ifdef  DYNAMIC_SPECTRUM //zhaoyanhua add 03-11-6 15:26
  69. extern void Show3dspectrum(void); 
  70. #endif
  71. #ifdef SAME_DISC_RESUME
  72. extern BYTE same_disc_onoff;
  73. #endif
  74. /*
  75. #ifndef DVDRELEASE
  76. //#define RSM_DBG       1
  77. #endif
  78. #ifndef RSM_DBG
  79. #undef printf
  80. #undef print_block
  81. #define printf(f, a...) do {} while (0)
  82. #define print_block(x,y) do {} while (0)
  83. #endif*/
  84. int is_cdg_disc(int show)
  85. {
  86. #ifdef SUPPORT_CDG
  87.     if( (cd_type_loaded==CDDA) && (cd_subtype==CD_DA) && bReadSubChannel && CDG_IsCDGNow())
  88.     {
  89.        if(show) invalid_key();  
  90.        return 1;
  91.     }else
  92. #endif        
  93.        return 0;
  94. }
  95. /*
  96.  Maoyong changed for resume function define, compile will not give error message
  97.  */
  98. #if !defined(SAME_DISC_RESUME) && !defined(POWER_RESUME) && !defined(RECORD_KEY)
  99. void  save_cmp_disc_info(UINT32 info1){ if(info1){} }//terry,2004/4/8 05:36PM
  100. #endif
  101. /*========================================================================
  102.  basic I2C read and write function for public use in this file
  103.  =========================================================================*/
  104. /*
  105. *  i2c device addr : a0 
  106. */
  107. void ReadFromI2cA0(UINT16 iAddr,BYTE *bBuffer,UINT16 len)
  108. {
  109. #ifndef DISC_ID_IN_FLASH
  110.        memset(bBuffer,0,len);
  111. if(ReadFromI2c(0xa0, iAddr,bBuffer, len) >=0 )
  112. {//sucess
  113.     printf("read flash data:n");
  114. print_block(bBuffer,len);
  115. }else
  116. {
  117. printf("read flash errorn");
  118. }
  119. #else//#ifndef DISC_ID_IN_FLASH
  120. int result,i,j,k;
  121. BYTE *p;
  122. //       memset(bBuffer,0,len);
  123.       
  124.     i = sizeof(disc_resume);
  125.        if (iAddr >= DVD_INFO_BASE)       
  126.        {
  127.     
  128.               if ((iAddr >= DVD_INFO_BASE) && (iAddr <DVD_DISC_INFO))
  129.               {
  130.                      if ((iAddr >= DVD_INFO_BASE) && (iAddr <CDROM_INFO_BASE))   
  131. j = iAddr - DVD_INFO_BASE;
  132.                      else  if ((iAddr >= CDROM_INFO_BASE) && (iAddr <CDDA_INFO_BASE))   
  133. j = iAddr - CDROM_INFO_BASE;
  134.               else if ((iAddr >= CDDA_INFO_BASE) && (iAddr <VCD_INFO_BASE))   
  135. j = iAddr - CDDA_INFO_BASE;
  136.       else if ((iAddr >= VCD_INFO_BASE) && (iAddr <DVD_DISC_INFO))   
  137. j = iAddr - VCD_INFO_BASE;
  138.           
  139. result = FlashRead(FLASH_START_ADDR,disc_resume,i);
  140. p= &disc_resume[current_resume].disc_info;
  141. p+= j;
  142.        for (k=0; k<len;k++) *bBuffer++ = *p++;
  143.        //memcpy(bBuffer,&disc_resume[current_resume].disc_info+j,len);
  144.               }
  145.               else 
  146.               {
  147.                  result = FlashRead(FLASH_START_ADDR,disc_resume,i);
  148.                  p= &disc_resume[current_resume].disc_id;
  149.        for (k=0; k<len;k++) *bBuffer++ = *p++;
  150.       // memcpy(bBuffer,&disc_resume[current_resume].disc_id,len);
  151.  }
  152.        }
  153.        else
  154.        {
  155.  #ifdef SETUP_IN_FLASH
  156.               result = FlashRead(FLASH_START_ADDR, disc_resume,i);
  157.          for (k=0; k<len;k++)
  158.          {
  159. j=iAddr+k;
  160.          p=&disc_resume[TOTAL_RESUME+1].disc_info;
  161.         
  162.   if (j>=(SETUP_MENU_BASE+SIZE_PER_ID)) 
  163.   //Wrap around for the next 64 (SIZE_PER_ID) bytes for setup
  164.   {
  165.   j-= SIZE_PER_ID;
  166.   p=&disc_resume[TOTAL_RESUME+2].disc_info;
  167.   }
  168.                                           
  169.          *bBuffer++ = *(p+j);
  170.          }
  171.   #else
  172.              result = ReadFromI2c(0xa0, iAddr,bBuffer, len);
  173. #endif
  174.        }
  175. if(result >=0 )
  176. {//sucess
  177.     printf("read flash data:n");
  178. print_block(bBuffer,len);
  179. }else
  180. {
  181. printf("read flash errorn");
  182. }
  183. #endif//#ifndef DISC_ID_IN_FLASH
  184. }
  185. /*
  186. *  i2c device addr : a0 , read UINT32 parameter
  187. */
  188. int ReadFromI2cA0_32(UINT16 iAddr,BYTE *bBuffer,UINT16 len)
  189. {
  190. UINT32 v=0;
  191. #ifndef DISC_ID_IN_FLASH
  192. if(ReadFromI2c(0xa0, iAddr,bBuffer, len) >=0 )
  193. {//sucess
  194.     printf("read flash data:n");
  195. print_block(bBuffer,len);
  196. if(len == 4) v = getUINT32_li(bBuffer);
  197. else v = getUINT16_li(bBuffer);
  198. }else
  199. {
  200. printf("read flash errorn");
  201. }
  202. #else//#ifndef DISC_ID_IN_FLASH
  203.        int result, i,j,k;
  204. BYTE *p;
  205. // memset(bBuffer,0,len);
  206.         
  207.     if (iAddr >= DVD_INFO_BASE)       
  208.        {
  209.         i = sizeof(disc_resume);
  210.               if ((iAddr >= DVD_INFO_BASE) && (iAddr <DVD_DISC_INFO))
  211.               {
  212.                    if ((iAddr >= DVD_INFO_BASE) && (iAddr <CDROM_INFO_BASE))   
  213. j = iAddr - DVD_INFO_BASE;
  214. else if ((iAddr >= CDROM_INFO_BASE) && (iAddr <CDDA_INFO_BASE))   
  215. j = iAddr - CDROM_INFO_BASE;
  216.               else if ((iAddr >= CDDA_INFO_BASE) && (iAddr <VCD_INFO_BASE))   
  217. j = iAddr - CDDA_INFO_BASE;
  218.       else if ((iAddr >= VCD_INFO_BASE) && (iAddr <DVD_DISC_INFO))   
  219. j = iAddr - VCD_INFO_BASE;
  220.   result = FlashRead(FLASH_START_ADDR,disc_resume,i);
  221. p= &disc_resume[current_resume].disc_info;
  222. p +=j;
  223.        for (k=0; k<len;k++) *(bBuffer+k) = *p++;
  224. //        memcpy(bBuffer,&disc_resume[current_resume].disc_info+j,len);
  225.               }
  226.               else
  227.               {
  228.                  result = FlashRead(FLASH_START_ADDR,disc_resume,i);
  229.                  p= &disc_resume[current_resume].disc_id;
  230.        for (k=0; k<len;k++) *(bBuffer+k) = *p++;
  231. //        memcpy(bBuffer,&disc_resume[current_resume].disc_id,len);
  232.  }
  233.        }
  234.        else
  235.        {
  236.              result = ReadFromI2c(0xa0, iAddr,bBuffer, len);
  237.        }
  238.        
  239. if(result >=0 )
  240. {//sucess
  241.             printf("read flash data:n");
  242. print_block(bBuffer,len);
  243. if(len == 4) v = getUINT32_li(bBuffer);
  244. else v = getUINT16_li(bBuffer);
  245. }else
  246. {
  247. printf("read flash errorn");
  248. }
  249. #endif//#ifndef DISC_ID_IN_FLASH
  250. return v;
  251. }
  252. /*
  253. *  i2c device addr : a0 , write function
  254. */
  255. void WriteToI2cA0(int iAddr,BYTE *bData,int len)
  256. {
  257. #ifndef DISC_ID_IN_FLASH
  258.     //printf("i2c,iAddr:%d len:%dn",iAddr,len);
  259. if( WriteToI2c(0xa0,iAddr,bData,len) < 0 )
  260. {//write fail
  261. printf("!!!!  ========  write flash error  ======== !!!!!n");
  262. }
  263. #else//#ifndef DISC_ID_IN_FLASH
  264.        int result,i,j,k;
  265.        BYTE *p, *q;
  266.        i = sizeof(disc_resume);
  267.  
  268.         if (iAddr >= DVD_INFO_BASE)       
  269.        {
  270.              if ((iAddr >= DVD_INFO_BASE) && (iAddr <DVD_DISC_INFO))
  271.               {
  272.     if ((iAddr >= DVD_INFO_BASE) && (iAddr <CDROM_INFO_BASE))   
  273. j = iAddr - DVD_INFO_BASE;
  274.       else if ((iAddr >= CDROM_INFO_BASE) && (iAddr <CDDA_INFO_BASE))   
  275. j = iAddr - CDROM_INFO_BASE;
  276.               else if ((iAddr >= CDDA_INFO_BASE) && (iAddr <VCD_INFO_BASE))   
  277. j = iAddr - CDDA_INFO_BASE;
  278.       else if ((iAddr >= VCD_INFO_BASE) && (iAddr <DVD_DISC_INFO))   
  279. j = iAddr - VCD_INFO_BASE;
  280.   
  281. FlashEraseSector(FLASH_ERASE_SECTOR);
  282. //    memcpy(&disc_resume[current_resume].disc_info+j,bData,len);
  283. p= &disc_resume[current_resume].disc_info;
  284. p += j;
  285.        for (k=0; k<len;k++) *p++ = *bData++;
  286. result = FlashWrite(FLASH_START_ADDR,disc_resume,i); 
  287.           
  288.               }
  289.               else
  290.               {
  291. FlashEraseSector(FLASH_ERASE_SECTOR);
  292. p= &disc_resume[current_resume].disc_id;
  293.        for (k=0; k<len;k++) *p++ = *bData++;
  294. // memcpy(&disc_resume[current_resume].disc_id,bData,len);
  295. //update disc_resume_index;
  296. p= &disc_resume[TOTAL_RESUME].disc_id;
  297. q= disc_resume_index;
  298.        for (k=0; k<sizeof(disc_resume_index);k++) *p++ = *q++;
  299. //    memcpy(&disc_resume[TOTAL_RESUME].disc_id,disc_resume_index,sizeof(disc_resume_index));
  300. result = FlashWrite(FLASH_START_ADDR,disc_resume,i); 
  301.     
  302.                }
  303.        }
  304.        else
  305.        {
  306. #ifdef SETUP_IN_FLASH
  307. FlashEraseSector(FLASH_ERASE_SECTOR);
  308.          for (k=0; k<len;k++)
  309.          {
  310. j=iAddr+k;
  311.          p=&disc_resume[TOTAL_RESUME+1].disc_info;
  312.         
  313.   if (j>=(SETUP_MENU_BASE+SIZE_PER_ID)) 
  314.   //Wrap around for the next 64 (SIZE_PER_ID) bytes for setup
  315.   {
  316.   j-= SIZE_PER_ID;
  317.   p=&disc_resume[TOTAL_RESUME+2].disc_info;
  318.   }
  319.                                           
  320.          *(p+j)=*bData++;
  321.          }
  322.          result = FlashWrite(FLASH_START_ADDR,disc_resume,i);
  323. #else
  324.                    result = WriteToI2c(0xa0,iAddr,bData,len) ;
  325. #endif     
  326.        }
  327.        
  328. if( result < 0 )
  329. {//write fail
  330. printf("!!!!  ========  write flash error  ======== !!!!!n");
  331. }
  332. #endif//#ifndef DISC_ID_IN_FLASH
  333. }
  334. #ifdef  RECORD_PER_SECOND //Maoyong add pre-def condition 2004.02.20 
  335. /*
  336. *  power resume function for record every secode
  337. */   
  338. static inline void power_rsm_ps_RsmInfo2Flash(int clr)
  339. {
  340.     static BYTE savetemparry[50];
  341.     BYTE    *p;             
  342.     
  343.     //printf("!!!run save_tuner_setup ,size:%dn",sizeof(pDSV->rsm_info[0]));
  344.     #ifdef SUPPORT_FILE_SYSTEM_MODE
  345. if ((cd_type_loaded == CDROM) && (GetCurrentFileType() == CDROM_MPG)) 
  346. return ;
  347. #endif
  348.     if( is_menu() || clr )
  349.     {
  350. resumeMSF = 0;
  351. resumeTRK = 0;
  352. pFsJpeg->fsnav_dir_now = 0;
  353. pFsJpeg->fsnav_trk_now = 0;
  354. myTime=0;
  355.     }else
  356.     {
  357.         if(cd_type_loaded!=CDDVD)
  358.         {
  359.             resumeMSF = s_msf&0x00ffffff;
  360.             resumeTRK = cd_trk_now;
  361.             if( (cd_type_loaded==CDROM)&&( !Is_MP3_STATE() ) ) 
  362.             {  //Jeff 20021114//nono 20021123 modified
  363. resumeMSF = 0; //we only support MP3, not contain JPEG/Game
  364.                 
  365.             }
  366.         }
  367.         else
  368.         {
  369.             resumeMSF = 1;
  370.             if(play_state!=VCD_STATE_STOP)//20021014
  371. RSM_save(0xff,0);
  372.         }        
  373.     }
  374.   if(cd_type_loaded==CDDVD)
  375.    {
  376.      int k; 
  377.      int changlen=0;
  378.      BYTE first_flag=1;
  379.      p=(BYTE *)&pDSV->rsm_info[0];    
  380.      for(k=(sizeof(pDSV->rsm_info[0])-1);k>=0;k--)
  381.         {
  382.           if(savetemparry[k] != p[k])
  383.              {
  384.                 if(first_flag)
  385.                 {
  386.                     first_flag=0;
  387.                     changlen=k;
  388.                 }
  389.              }
  390.            savetemparry[k]=p[k];
  391.         }
  392.      WriteToI2cA0(128,p,changlen+1);
  393.      //printf("len=%dn",changlen+1);
  394.      first_flag=(BYTE)resumeMSF; //in dvd mode resumeMSF only use flag!
  395.     WriteToI2cA0(128+sizeof(pDSV->rsm_info[0])+sizeof(resumeTRK),(BYTE *)&first_flag, sizeof(first_flag));
  396.       
  397.   }
  398.   else
  399.    {   
  400.      printf("resumeTRK=%dn",resumeTRK);
  401.      WriteToI2cA0(128+sizeof(pDSV->rsm_info[0]),(BYTE *)&resumeTRK, sizeof(resumeTRK));
  402.      printf("resumeMSF:%xn",resumeMSF);
  403.      WriteToI2cA0(128+sizeof(pDSV->rsm_info[0])+sizeof(resumeTRK),(BYTE *)&resumeMSF, sizeof(resumeMSF));
  404.     
  405.      printf("fsnav_dir_now:%dn", pFsJpeg->fsnav_dir_now);
  406.      //it only cdrom need record
  407.      if(cd_type_loaded==CDROM)
  408.      {
  409.         WriteToI2cA0(128 + sizeof(pDSV->rsm_info[0]) + sizeof(resumeTRK) + sizeof(resumeMSF), 
  410. (BYTE *)&(pFsJpeg->fsnav_dir_now), sizeof(pFsJpeg->fsnav_dir_now));
  411.      printf("fsnav_trk_now:%dn", pFsJpeg->fsnav_trk_now);
  412.     
  413.          WriteToI2cA0(128 + sizeof(pDSV->rsm_info[0]) + sizeof(resumeTRK) + sizeof(resumeMSF) + sizeof(pFsJpeg->fsnav_dir_now), 
  414. (BYTE *)&(pFsJpeg->fsnav_trk_now), sizeof(pFsJpeg->fsnav_trk_now));
  415.      printf("myTime:%dn", myTime);
  416.     
  417.          WriteToI2cA0(128 + sizeof(pDSV->rsm_info[0]) + sizeof(resumeTRK) + sizeof(resumeMSF) + sizeof(pFsJpeg->fsnav_dir_now) + sizeof(pFsJpeg->fsnav_trk_now), 
  418. (BYTE *)&myTime, sizeof(myTime));
  419.        }
  420.    }
  421. }
  422. #endif //end #ifdef  RECORD_PER_SECOND
  423. #ifndef DISC_ID_IN_FLASH //put them at the beginning
  424. /*========================================================================
  425.  record resume play func's save and load realized functions prototypes
  426.  =========================================================================*/
  427. /*
  428. *  last memory function
  429. */
  430. #define SETUP_MENU_BASE   0
  431. #define DVD_INFO_BASE   128
  432. #define CDROM_INFO_BASE 180
  433. #define CDDA_INFO_BASE  200
  434. #define VCD_INFO_BASE   220
  435. //Maoyong 2004.04.07 for all resume use
  436. #define DVD_DISC_INFO  244
  437. #define CDDA_DISC_INFO 248
  438. #define VCD_DISC_INFO  252
  439. #endif //#ifndef DISC_ID_IN_FLASH
  440. #ifdef POWER_RESUME
  441. /**********************************************************************************************
  442. Function : To identify whether the current MP3 disc is the one played last time
  443. return 1 : yes
  444.        0 : no
  445. Created by caiyh , 17:03 , Nov 5th , 2004
  446. **********************************************************************************************/
  447. UINT8 IsTheSameMP3 ( void )
  448. {
  449. UINT32 fsnav_dir_now = 0 , 
  450.        fsnav_trk_now = 0 ,
  451.        first_mp3_entry = 0 ,
  452.        MSFFlag = 0 ,
  453.        msf = 0 ;
  454. BYTE  v [ 4 ] ;
  455. fsnav_dir_now = ReadFromI2cA0_32 ( CDROM_INFO_BASE , v , sizeof( pFsJpeg -> fsnav_dir_now ) ) ;
  456. fsnav_trk_now = ReadFromI2cA0_32 ( CDROM_INFO_BASE + sizeof( pFsJpeg -> fsnav_dir_now ) ,
  457. v , sizeof( pFsJpeg -> fsnav_trk_now ) ) ;
  458. MSFFlag = ReadFromI2cA0_32 ( CDROM_INFO_BASE + sizeof( pFsJpeg -> fsnav_dir_now ) 
  459.   + sizeof( pFsJpeg -> fsnav_trk_now ) , v , sizeof( MSFFlag ) ) ;
  460. /* read the information recorded from i2c ,
  461.    annotated by caiyh , 17:03 , Nov 5th , 2004 */
  462. first_mp3_entry = pFsJpeg -> Dir_entry [ fsnav_dir_now ] ;
  463. fsnav_trk_now += first_mp3_entry ;
  464. msf = iso9660_file [ fsnav_trk_now ] . loc ;
  465. if ( msf == MSFFlag )
  466. return 1 ;
  467. else 
  468. return 0 ;
  469. /* according to the dir and trk recorded in i2c, to find the msf specified ,
  470.    and compare the current msf with the one read from i2c ,
  471.    annotated by caiyh , 17:03 , Nov 5th , 2004 */
  472. }
  473. /**************************************************************
  474. Function : read the parameters about MP3 resume
  475. para = 0 : dir
  476.        1 : trk
  477.        2 : msf
  478.        3 : myTime
  479. return : the value of dir trk msf or myTime
  480. Created by caiyh , 09:24 , Nov 22nd , 2004
  481. **************************************************************/
  482. UINT32 ReadSameMP3Para ( UINT8 para )
  483. {
  484. UINT32 result = 0 ;
  485. BYTE v [ 4 ] ;
  486. if ( para <=2 )
  487. result = ReadFromI2cA0_32 ( CDROM_INFO_BASE + para * 2 , v , 2 ) ;
  488. else if ( para == 3 )
  489. result = ReadFromI2cA0_32 ( CDROM_INFO_BASE + 8 , v , 4 ) ;
  490. // read parameter of mp3 resume from i2c , annotated by caiyh , 09:24 , Nov 22nd , 2004
  491. return result ;
  492. }
  493. /*********************************************************
  494. Function : clear msf about MP3 resume
  495. Created by caiyh , 09:34 , Nov 22nd , 2004
  496. *********************************************************/
  497. void ClrSameMP3Flag ( void )
  498. {
  499. UINT32 MSFFlag = 0 ;
  500. WriteToI2cA0 ( CDROM_INFO_BASE + 4 , ( BYTE * ) & MSFFlag , sizeof ( MSFFlag ) ) ;
  501. // clear msf of mp3 resume in i2c , annotated by caiyh , 09:34 , Nov 22nd , 2004
  502. }
  503. #endif   // POWER_RESUME
  504. #if defined (POWER_RESUME)|| defined(SAME_DISC_RESUME)|| defined(RECORD_KEY)
  505. void clr_rsm_info(void)
  506. {//terry,2003/8/13 01:21AM    
  507.     if( is_menu() || is_cdg_disc(0) || (pe_run==0) ||(cd_type_loaded==CDROM) || ((disp_trk_now==0)&&(cd_type_loaded!=CDDVD))  )
  508.     {
  509.         printf("clr rsm info: %d %d %d %dn",is_menu(),is_cdg_disc(0),pe_run,disp_trk_now);
  510.         resumeMSF = 0;
  511.         resumeTRK = 0;
  512.         pFsJpeg->fsnav_dir_now=0;
  513.         pFsJpeg->fsnav_trk_now=0;
  514.         myTime=0;
  515.         
  516.     }
  517. }
  518. static inline void same_disc_RsmInfo2Flash(int clr)
  519. {
  520.     BYTE    *p;
  521. #if defined(POWER_RESUME) || defined(SAME_DISC_RESUME)
  522. UINT32 MSFFlag = 0 ;
  523. #endif   // POWER_RESUME , added by caiyh , 15:55 , Nov 5th , 2004
  524.     if(clr){}//freyman just for warning message
  525.     
  526.     if(cd_type_loaded==CDUNKNOWN) return;
  527.     resumeMSF = s_msf&0x00ffffff;
  528.     resumeTRK = cd_trk_now;
  529.     
  530. #ifdef POWER_RESUME
  531.     if(Is_MP3_STATE()==0)   // don't clear the resume info of mp3 , added by caiyh , 10:53 , Nov 2nd , 2004
  532. #endif   // POWER_RESUME
  533.     clr_rsm_info(); //terry,2003/8/13 01:21AM       
  534.     //#ifdef RECORD_KEY//zhaoyanhua 03-11-2 18:56  //Mark by maoyong 2004.04.07
  535.     //write DISC INFO to I2C
  536.     UINT32 info1;
  537.     int pos= 0;
  538.     
  539.     if(cd_type_loaded==CDDVD) 
  540.      pos = DVD_DISC_INFO;
  541.     else if (cd_type_loaded==CDDA) 
  542.     #ifdef ONLY_PRE_DISC_RESUME
  543.         pos = DVD_DISC_INFO;
  544.     #else    
  545.      pos = CDDA_DISC_INFO;
  546.     #endif
  547.     else if (cd_type_loaded!=CDROM)
  548.     #ifdef ONLY_PRE_DISC_RESUME 
  549.         pos = DVD_DISC_INFO;
  550.     #else    
  551.      pos = VCD_DISC_INFO;
  552.     #endif
  553.     #ifdef POWER_RESUME
  554.      else if(Is_MP3_STATE()==0)   /* to add the function of mp3 power resume , 
  555.              added by caiyh , 11:05 , Nov 2nd , 2004 */
  556.     #else
  557.     else 
  558.     #endif   // POWER_RESUME
  559.      return;    
  560.     //Res=check_cdtype();
  561.     if(cd_type_loaded!=CDDVD)
  562. info1=M2I(gettrkmsf_leadout()); //get from sysmain2.c
  563.     else//CDDVD
  564.     info1 = same_disc_vob11_pos;    //search_file("VTS_01_1.VOB"); //get from atapi_if728.c
  565. WriteToI2cA0(pos,(BYTE *)&info1,sizeof(info1));
  566.          
  567.     //#endif
  568.   
  569.     
  570.     {
  571.         printf("save rsm infon");
  572.         
  573.         p=(BYTE *)&pDSV->rsm_info[0];
  574.         if(cd_type_loaded!=CDDVD)
  575.         {
  576.             if(cd_type_loaded==CDROM) 
  577.             {//we only support MP3, not contain JPEG/Game
  578.                 if(Is_MP3_STATE()==0) resumeMSF = 0;
  579.                 
  580.                 printf("fsnav_dir_now:%dn",pFsJpeg->fsnav_dir_now);
  581.                 printf("fsnav_trk_now:%dn",pFsJpeg->fsnav_trk_now);
  582.                 printf("myTime:%dn", myTime);
  583.                 
  584.                 WriteToI2cA0(CDROM_INFO_BASE,(BYTE *)&pFsJpeg->fsnav_dir_now, sizeof(pFsJpeg->fsnav_dir_now));
  585.                 WriteToI2cA0(CDROM_INFO_BASE+sizeof(pFsJpeg->fsnav_dir_now),(BYTE *)&pFsJpeg->fsnav_trk_now, sizeof(pFsJpeg->fsnav_trk_now));
  586.                              
  587.                 MSFFlag = mp3_file_msf ( pFsJpeg -> fsnav_trk_now ) ;
  588.                 // get the msf of current trk , added by caiyh , 15:55 , Nov 5th , 2004
  589.                 
  590.                 WriteToI2cA0 ( CDROM_INFO_BASE + sizeof(pFsJpeg->fsnav_dir_now)
  591.                  + sizeof ( pFsJpeg -> fsnav_trk_now ) , ( BYTE * ) & MSFFlag ,
  592.                  sizeof(MSFFlag));
  593.                 // write the msf of current trk to i2c , added by caiyh , 15:55 , Nov 5th , 2004
  594.             
  595.                 WriteToI2cA0 ( CDROM_INFO_BASE + sizeof ( pFsJpeg -> fsnav_dir_now ) 
  596.                  + sizeof ( pFsJpeg -> fsnav_trk_now ) + sizeof ( MSFFlag ) , 
  597.                  ( BYTE * ) & myTime , sizeof ( myTime ) ) ;
  598. // write the myTime of current trk to i2c , modified by caiyh , 17:57 , Nov 16th , 2004
  599.             
  600.              printf("MSFFlag:%dn", MSFFlag);
  601.             }else
  602.             {
  603.                 int pos;
  604.                 
  605.                 if(cd_type_loaded==CDDA) pos=CDDA_INFO_BASE;
  606.                 else pos=VCD_INFO_BASE;
  607.                 
  608.                 printf("resumeMSF:%xn",resumeMSF);
  609.                 WriteToI2cA0(pos,(BYTE *)&resumeTRK, sizeof(resumeTRK));
  610.                 WriteToI2cA0(pos+sizeof(resumeTRK),(BYTE *)&resumeMSF, sizeof(resumeMSF));
  611.             }
  612.         }else
  613.         {
  614.             //resumeMSF = 1;//terry 2003-8-12 14:20
  615.             if(play_state!=VCD_STATE_STOP)
  616.                 RSM_save(0xff,0);
  617.             
  618.             clr_rsm_info();//terry,2003/8/13 01:21AM    
  619.             printf("resumeMSF:%dn",resumeMSF);
  620.             WriteToI2cA0(DVD_INFO_BASE,p, sizeof(pDSV->rsm_info[0]));            
  621.             WriteToI2cA0(DVD_INFO_BASE+sizeof(pDSV->rsm_info[0]),(BYTE *)&resumeMSF, sizeof(resumeMSF));
  622.     
  623.      // psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_TTN:%xn",pDSV->rsm_info[0].dRSM_TTN);
  624.      // UART0_puts(debug_buffer);
  625.      // psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_PTTN:%xn",pDSV->rsm_info[0].dRSM_PTTN);
  626.      // UART0_puts(debug_buffer);
  627.      // psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_AGLN:%xn",pDSV->rsm_info[0].dRSM_AGLN);
  628.      // UART0_puts(debug_buffer);
  629.      // psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_ASTN:%xn",pDSV->rsm_info[0].dRSM_ASTN);
  630.      // UART0_puts(debug_buffer);
  631.      // psprintf(debug_buffer,"resumeMSF:%xn",resumeMSF);    
  632.      // UART0_puts(debug_buffer);
  633.         }
  634.         }
  635.     }
  636.     
  637. static inline void same_disc_LoadRsmInfo(void)
  638.     {
  639.     BYTE    *p,v[4];
  640.     printf("reading...n");
  641.     p=(BYTE *)&pDSV->rsm_info[0];
  642.     
  643.     if(cd_type_loaded==CDDVD)
  644.     {
  645.       ReadFromI2cA0(DVD_INFO_BASE,p, sizeof(pDSV->rsm_info[0]));
  646.       ReadFromI2cA0(DVD_INFO_BASE+sizeof(pDSV->rsm_info[0]),(BYTE *)&resumeMSF, sizeof(resumeMSF));
  647.       
  648.       printf("pDSV->rsm_info[i].dRSM_TTN:%xn",pDSV->rsm_info[0].dRSM_TTN);
  649.       printf("pDSV->rsm_info[i].dRSM_PTTN:%xn",pDSV->rsm_info[0].dRSM_PTTN);
  650.       printf("pDSV->rsm_info[i].dRSM_AGLN:%xn",pDSV->rsm_info[0].dRSM_AGLN);
  651.       printf("pDSV->rsm_info[i].dRSM_ASTN:%xn",pDSV->rsm_info[0].dRSM_ASTN);
  652.       printf("Read resumeMSF:%x size %d %dn",resumeMSF,sizeof(pDSV->rsm_info[0]),sizeof(resumeMSF));    
  653.    //   psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_TTN:%xn",pDSV->rsm_info[0].dRSM_TTN);
  654.    //   UART0_puts(debug_buffer);
  655.    //   psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_PTTN:%xn",pDSV->rsm_info[0].dRSM_PTTN);
  656.    //   UART0_puts(debug_buffer);
  657.    //   psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_AGLN:%xn",pDSV->rsm_info[0].dRSM_AGLN);
  658.    //   UART0_puts(debug_buffer);
  659.    //   psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_ASTN:%xn",pDSV->rsm_info[0].dRSM_ASTN);
  660.    //   UART0_puts(debug_buffer);
  661.    //   psprintf(debug_buffer,"Read resumeMSF:%x size %d %dn",resumeMSF,sizeof(pDSV->rsm_info[0]),sizeof(resumeMSF));    
  662.    //   UART0_puts(debug_buffer);
  663.       
  664.     }else if(cd_type_loaded==CDROM)
  665.     {
  666.       resume_fsnav_dir = ReadFromI2cA0_32(CDROM_INFO_BASE,v, sizeof(resume_fsnav_dir));       
  667.       resume_fsnav_trk = ReadFromI2cA0_32(CDROM_INFO_BASE+sizeof(pFsJpeg->fsnav_dir_now),v, sizeof(resume_fsnav_trk));
  668.       myTime = ReadFromI2cA0_32(CDROM_INFO_BASE+sizeof(pFsJpeg->fsnav_dir_now) + sizeof(resume_fsnav_trk),v, sizeof(myTime));
  669.             
  670.       printf("resume_fsnav_dir:%dn",resume_fsnav_dir);
  671.       printf("resume_fsnav_trk:%dn",resume_fsnav_trk);
  672.     printf("myTime:%dn", myTime);
  673. }else
  674.     {
  675.       int pos;
  676.         
  677.       if(cd_type_loaded==CDDA) pos = CDDA_INFO_BASE;
  678.       else pos = VCD_INFO_BASE;
  679.       ReadFromI2cA0(pos,&resumeTRK, sizeof(resumeTRK));
  680.       printf("resumeTRK:%xn",resumeTRK);
  681.       resumeMSF = ReadFromI2cA0_32(pos+sizeof(resumeTRK),v, sizeof(resumeMSF));
  682.       printf("resumeMSF:%x %x %x %x %xn",resumeMSF,v[0],v[1],v[2],v[3]);
  683.     }
  684.     }
  685. void  save_cmp_disc_info(UINT32 info1)
  686.     {
  687.     UINT8 v[4];
  688.     UINT32 rom_info1;
  689.     int pos;
  690. #ifdef DISC_ID_IN_FLASH    
  691.     int i,j,index_match,first_empty_indx;
  692.     
  693.   #endif
  694.     
  695. printf("save & compare disc info ,inn");
  696. printf("info1:%xn",info1);
  697.     if(cd_type_loaded==CDDVD) 
  698.     pos = DVD_DISC_INFO;
  699.     else if (cd_type_loaded==CDDA)
  700.     #ifdef ONLY_PRE_DISC_RESUME
  701.      pos = DVD_DISC_INFO;
  702.     #else 
  703.      pos = CDDA_DISC_INFO;
  704.     #endif
  705.     else if (cd_type_loaded!=CDROM)
  706.     #ifdef ONLY_PRE_DISC_RESUME 
  707.      pos = DVD_DISC_INFO;
  708.     #else  
  709.      pos = VCD_DISC_INFO;
  710.     #endif 
  711.     else return;
  712. #ifndef DISC_ID_IN_FLASH
  713. rom_info1 = ReadFromI2cA0_32(pos,v,sizeof(rom_info1));
  714. //rom_info2 = ReadFromI2cA0_32(pos+sizeof(rom_info1),v,sizeof(rom_info2));
  715. //if( (rom_info1==info1)&&(rom_info2==info2) ) 
  716. if(rom_info1==info1) 
  717. {
  718.     same_disc_flag=1;
  719. }else
  720. {
  721.     resumeMSF=0;
  722.     same_disc_flag=0;
  723.     //Maoyong changed 2004.04.07. record disc info just in record action not after reading disc.
  724. //#ifndef RECORD_KEY
  725. //NOTE:
  726. //must mask it,else cause record error.    
  727.     //WriteToI2cA0(pos,(BYTE *)&info1,sizeof(info1));
  728. //#endif
  729.     //WriteToI2cA0(pos+sizeof(info1),(BYTE *)&info1,sizeof(info2));
  730. }
  731. #else//#ifndef DISC_ID_IN_FLASH
  732.    current_resume = TOTAL_RESUME;
  733.    //just to read in the disc_resume_index table store in disc_resume[TOTAL_RESUME]
  734.    rom_info1 = ReadFromI2cA0_32(pos,v,sizeof(rom_info1));
  735.    memcpy(disc_resume_index,&disc_resume[current_resume].disc_id,sizeof(disc_resume_index));
  736.    // reset disc_resume_index for the first time usage
  737.    if ((disc_resume_index[0]==disc_resume_index[1]) || 
  738.     (disc_resume_index[0]<0) ||
  739.      (disc_resume_index[0]>= TOTAL_RESUME))
  740.     {
  741.     for (i=0; i<TOTAL_RESUME; i++)
  742.     disc_resume_index[i] = 0xff;
  743.     }
  744.    index_match = 0;
  745.    first_empty_indx = -1;
  746.    current_resume = 0;
  747. // find the current index to the disc resume information
  748.    for (i=0; i<TOTAL_RESUME; i++)
  749.    {
  750.        //empty index, use it to store resume information  
  751.     if ((disc_resume_index[i]<0) || (disc_resume_index[i]>= TOTAL_RESUME))
  752.     {
  753.     current_resume = i;
  754.     break;
  755.     }
  756.     //compare disc information with the current disc resume
  757.     current_resume = disc_resume_index[i];
  758.     rom_info1 = ReadFromI2cA0_32(pos,v,sizeof(rom_info1));
  759.        //disc information not matches the current disc resume, continue.
  760.    if(rom_info1==0)
  761.    {
  762.    if (first_empty_indx <0)
  763.    first_empty_indx = i;
  764. continue;
  765.    }
  766.       //disc information mateces current disc resume
  767. if(rom_info1==info1) 
  768. {
  769. index_match = 1;
  770. break;
  771. }
  772.    }
  773.    //if none of the disc resume information matches the disc information, 
  774.   // use first exmpty index as current resume index
  775.    if ((index_match ==0) && (first_empty_indx >=0))
  776.    {
  777.     i = first_empty_indx;
  778.     current_resume = disc_resume_index[i];
  779.    }
  780.    if (i==TOTAL_RESUME) --i;
  781. // the first index in the disc resume points to the current resume
  782. //shift the disc resume index up by 1.
  783.    if (i>0)
  784.    {
  785.     for (j=i;j>0;j--)
  786.     {
  787.     disc_resume_index[j]=disc_resume_index[j-1];
  788.     }
  789.    }
  790.    disc_resume_index[0]=current_resume;
  791.    
  792.   if(rom_info1==info1) 
  793.   {
  794.          same_disc_flag=1;
  795.    }
  796.    else 
  797.   {
  798.     resumeMSF=0;
  799.     same_disc_flag=0;
  800.   }
  801.    
  802.     
  803. #endif//#ifndef DISC_ID_IN_FLASH
  804. }
  805. #ifdef POLLING_10MS_SAVE_RESUME //Maoyong 2004.03.01
  806. extern BYTE  rsm_I2c_write_cnt;
  807. //Note: Just for DVD Disc resume info save
  808. #define RSM_INFO_SIZE   sizeof(same_disc_vob11_pos)
  809. #define RSM_MSF_SIZE sizeof(resumeMSF)
  810. #define RSM_DSV_SIZE sizeof(pDSV->rsm_info[0])
  811. void polling_10ms_save_rsm(void)
  812. {
  813. if(rsm_I2c_write_cnt <  DVD_RSM_WRITE_SIZE)
  814. {
  815. if( rsm_I2c_write_cnt < RSM_INFO_SIZE )
  816. WriteToI2cA0(DVD_DISC_INFO + rsm_I2c_write_cnt,(BYTE *)&same_disc_vob11_pos + rsm_I2c_write_cnt, 1);
  817. else if( rsm_I2c_write_cnt < (RSM_INFO_SIZE + RSM_DSV_SIZE))
  818. WriteToI2cA0(DVD_INFO_BASE + rsm_I2c_write_cnt- RSM_INFO_SIZE, 
  819.              (BYTE *)&pDSV->rsm_info[0] + rsm_I2c_write_cnt - RSM_INFO_SIZE, 
  820.              1);
  821. else
  822. WriteToI2cA0(DVD_INFO_BASE + rsm_I2c_write_cnt - RSM_INFO_SIZE,
  823.  (BYTE *) &resumeMSF + rsm_I2c_write_cnt - RSM_INFO_SIZE - RSM_DSV_SIZE,
  824.  1);
  825. rsm_I2c_write_cnt++;
  826. }
  827. }
  828. #endif //end ifdef POLLING_10MS_SAVE_RESUME
  829. #else //else #if defined (POWER_RESUME)|| defined(SAME_DISC_RESUME)||defined (RECORD_KEY)
  830. static inline void basic_RsmInfo2Flash(int clr)
  831. {
  832.     BYTE    *p;             
  833.     
  834.     printf("!!!run save_tuner_setup ,size:%dn",sizeof(pDSV->rsm_info[0]));
  835.     if( is_menu() || clr )
  836.     {
  837. resumeMSF = 0;
  838. resumeTRK = 0;
  839. pFsJpeg->fsnav_dir_now = 0;
  840. pFsJpeg->fsnav_trk_now = 0;
  841. myTime=0;
  842.     }else
  843.     {
  844.         if(cd_type_loaded!=CDDVD)
  845.         {
  846.             resumeMSF = s_msf&0x00ffffff;
  847.             resumeTRK = cd_trk_now;
  848.             if( (cd_type_loaded==CDROM)&&( !Is_MP3_STATE() ) ) { //Jeff 20021114//nono 20021123 modified
  849.                 //we only support MP3, not contain JPEG/Game
  850.                 resumeMSF = 0;
  851.             }
  852.         }else
  853.         {
  854.             resumeMSF = 1;
  855.             if(play_state!=VCD_STATE_STOP)//20021014
  856. RSM_save(0xff,0);
  857.         }        
  858.     }
  859.     p=(BYTE *)&pDSV->rsm_info[0];    
  860.     WriteToI2cA0(128,p, sizeof(pDSV->rsm_info[0]));
  861.     
  862.     WriteToI2cA0(128+sizeof(pDSV->rsm_info[0]),(BYTE *)&resumeTRK, sizeof(resumeTRK));
  863.     printf("resumeMSF:%xn",resumeMSF);
  864.     
  865.     WriteToI2cA0(128+sizeof(pDSV->rsm_info[0])+sizeof(resumeTRK),(BYTE *)&resumeMSF, sizeof(resumeMSF));
  866.     printf("save rsm msf failn");
  867.     
  868.     printf("fsnav_dir_now:%dn", pFsJpeg->fsnav_dir_now);
  869.     WriteToI2cA0(128 + sizeof(pDSV->rsm_info[0]) + sizeof(resumeTRK) + sizeof(resumeMSF), 
  870. (BYTE *)&(pFsJpeg->fsnav_dir_now), sizeof(pFsJpeg->fsnav_dir_now));
  871.     
  872.     printf("fsnav_trk_now:%dn", pFsJpeg->fsnav_trk_now);
  873.     WriteToI2cA0(128 + sizeof(pDSV->rsm_info[0]) + sizeof(resumeTRK) + sizeof(resumeMSF) + sizeof(pFsJpeg->fsnav_dir_now), 
  874. (BYTE *)&(pFsJpeg->fsnav_trk_now), sizeof(pFsJpeg->fsnav_trk_now));
  875.     
  876.     //Jeff 20020902
  877.     printf("myTime:%dn", myTime);
  878.     WriteToI2cA0(128 + sizeof(pDSV->rsm_info[0]) + sizeof(resumeTRK) + sizeof(resumeMSF) + sizeof(pFsJpeg->fsnav_dir_now) + sizeof(pFsJpeg->fsnav_trk_now), 
  879. (BYTE *)&myTime, sizeof(myTime));
  880.     
  881. }
  882. static inline void basic_LoadRsmInfo(void)
  883. {
  884.     BYTE    *p,v[4];            
  885.     printf("reading...n"); 
  886.     
  887.     p=(BYTE *)&pDSV->rsm_info[0];    
  888.     ReadFromI2cA0(128,p, sizeof(pDSV->rsm_info[0]));
  889.     {
  890.         printf("pDSV->rsm_info[i].dRSM_TTN:%xn",pDSV->rsm_info[0].dRSM_TTN);
  891.         printf("pDSV->rsm_info[i].dRSM_PTTN:%xn",pDSV->rsm_info[0].dRSM_PTTN);
  892.         printf("pDSV->rsm_info[i].dRSM_AGLN:%xn",pDSV->rsm_info[0].dRSM_AGLN);
  893.         printf("pDSV->rsm_info[i].dRSM_ASTN:%xn",pDSV->rsm_info[0].dRSM_ASTN);
  894.     }
  895.     
  896.     ReadFromI2cA0(128+sizeof(pDSV->rsm_info[0]),&resumeTRK, sizeof(resumeTRK));
  897.     {
  898.         printf("resumeTRK:%xn",resumeTRK);     
  899.     }
  900.     
  901.     resumeMSF = ReadFromI2cA0_32(128+sizeof(pDSV->rsm_info[0])+sizeof(resumeTRK),v, sizeof(resumeMSF));
  902.     {
  903.         printf("resumeMSF:%x %x %x %x %xn",resumeMSF,v[0],v[1],v[2],v[3]);             
  904.     }      
  905.     resume_fsnav_dir = ReadFromI2cA0_32(128 + sizeof(pDSV->rsm_info[0]) + sizeof(resumeTRK) + sizeof(resumeMSF),
  906. v, sizeof(resume_fsnav_dir));
  907.     {
  908.         printf("resume_fsnav_dir:%dn",resume_fsnav_dir);               
  909.     }      
  910.     resume_fsnav_trk = ReadFromI2cA0_32(128 + sizeof(pDSV->rsm_info[0]) + sizeof(resumeTRK) + sizeof(resumeMSF) + sizeof(pFsJpeg->fsnav_dir_now),
  911. v, sizeof(resume_fsnav_trk));
  912.     {
  913.         printf("resume_fsnav_trk:%dn",resume_fsnav_trk);               
  914.     }
  915.     
  916.     myTime = ReadFromI2cA0_32(128 + sizeof(pDSV->rsm_info[0]) + sizeof(resumeTRK) + sizeof(resumeMSF) + sizeof(pFsJpeg->fsnav_dir_now) + sizeof(resume_fsnav_trk),
  917. v, sizeof(myTime));
  918.     {
  919.      printf("myTime:%dn",myTime);               
  920.     }
  921. }
  922. #endif //#if defined (POWER_RESUME)|| defined(SAME_DISC_RESUME)||(RECORD_KEY)
  923. /*
  924. record per second,we only recode the changed content!
  925. and we also distinguish cd type
  926. */   
  927. void RsmInfo2Flash(int clr)
  928. {
  929. #ifdef RECORD_PER_SECOND //lijinhai   2-12-4 9:49
  930.     power_rsm_ps_RsmInfo2Flash(clr);
  931. #elif defined(SAME_DISC_RESUME) || defined(POWER_RESUME) || defined(RECORD_KEY)
  932.     same_disc_RsmInfo2Flash(clr);    
  933. #else
  934.     basic_RsmInfo2Flash(clr);
  935. #endif    
  936. }
  937. void LoadRsmInfo(void)
  938.     //goto_active=1;//terry,2004/3/2 11:56AM
  939. #if defined (SAME_DISC_RESUME) || defined(POWER_RESUME) || defined(RECORD_KEY)
  940.     same_disc_LoadRsmInfo();
  941. #else
  942.     basic_LoadRsmInfo();
  943. #endif    
  944. }
  945. /*========================================================================
  946.  record resume util funcs for flow control in sysmain2.c SYSTEM_READ_TITLE
  947.  =========================================================================*/
  948. #ifdef RECORD_KEY
  949. /*
  950.  * FUNC Descrition:
  951.  *     to check if user has entered "RECORD" 
  952.  *     only enter"RECORD" key,then play from the recorded point.
  953.  *     else excute its corresponding function.
  954.  *
  955.  *  RETURN:
  956.  *     1:   entered RECORD 
  957.  *     0:   other key
  958.  *  
  959.  *  zhaoyanhua  2003-11-29 20:12
  960.  *
  961.  */
  962. static inline BYTE CheckRecordKey(void)
  963. {
  964.     BYTE iRes = 0;
  965.     
  966. //NOTE:
  967. // if you want change the RECORD_OSD_SHOW_TIME value, 
  968. // must change it in file ir_parser.c at the same time.
  969. //zhaoyanhua  2003-12-12 15:18
  970. #define RECORD_OSD_SHOW_TIME  14  
  971.  
  972. //to avoid SPECTRUM effect OSD    
  973. #ifdef DYNAMIC_SPECTRUM  
  974.     BYTE tempDisp = bEqDisplay;
  975. #endif    
  976.     //if the disc has recorded,Show OSD and do some operation.
  977.     //NOTE:
  978.     // use the flag "same_disc_flag" to calculate the time(6S)
  979.     // (14-2) *500ms = 6s   
  980.     osd_init_record();
  981.     //show strings.
  982.     #ifdef NINTAUS_OSD_STR
  983.     psprintf(linebuf,"%s",_OsdMessegeFont1[osd_font_mode][STR_OS_RECORD_1]);
  984.     osd_DrawRegionString(2,0,linebuf,0x0a,0,0);//3-11-21 9:25张宇P
  985.     psprintf(linebuf,"%s",_OsdMessegeFont1[osd_font_mode][STR_OS_RECORD_2 ]);
  986.     osd_DrawRegionString(2,7,linebuf,0x0a,0,0);//3-11-21 9:25张宇P
  987.     psprintf(linebuf,"%s",_OsdMessegeFont1[osd_font_mode][STR_OS_RECORD_3]);
  988.     osd_DrawRegionString(2,14,linebuf,0x0a,0,0);//3-11-21 9:25张宇P
  989.     #else//NINTAUS_OSD_STR
  990.     psprintf(linebuf,"%s",_OsdMessegeFont1[osd_font_mode][STR_OS_RECORD_1SENTENCE]);
  991.     osd_DrawRegionString(2,0,linebuf,0x0a,0,0);//3-11-21 9:25张宇P
  992.     psprintf(linebuf,"%s",_OsdMessegeFont1[osd_font_mode][STR_OS_RECORD_2SENTENCE]);
  993.     osd_DrawRegionString(2,7,linebuf,0x0a,0,0);//3-11-21 9:25张宇P
  994.     psprintf(linebuf,"%s",_OsdMessegeFont1[osd_font_mode][STR_OS_RECORD_3SENTENCE]);
  995.     osd_DrawRegionString(2,14,linebuf,0x0a,0,0);//3-11-21 9:25张宇P
  996.     #endif//NINTAUS_OSD_STR                         
  997.                                     
  998. #ifndef MODIFY_RECORD_KEY//20040217                                 
  999.     run_pause_setting();//pause                             
  1000. #endif//MODIFY_RECORD_KEY
  1001.                                     
  1002.     while(same_disc_flag > 0)
  1003.     {
  1004.         polling();
  1005.         if(same_disc_flag == RECORD_OSD_SHOW_TIME)     
  1006.             break;
  1007.     }
  1008.                                     
  1009. #ifdef DYNAMIC_SPECTRUM//zhaoyanhua add 2003-12-2 22:25
  1010.     bEqDisplay = tempDisp;
  1011.     if(bEqDisplay)
  1012.         Show3dspectrum();
  1013.     else
  1014. #endif  
  1015.     osd_init();
  1016.     
  1017. #ifdef MODIFY_RECORD_KEY//20040217
  1018.     //chg2normal_play(PAUSE2NORM,TRANSFER);
  1019. #else//MODIFY_RECORD_KEY
  1020.     chg2normal_play(FAST2NORM|PAUSE2NORM|SLOW2NORM,REALPLAY);
  1021. #endif//MODIFY_RECORD_KEY
  1022.     
  1023.     if(same_disc_flag == RECORD_OSD_SHOW_TIME)
  1024.     {    
  1025.         same_disc_flag = 0;
  1026.         iRes = 0;
  1027.     }
  1028.     else
  1029.         iRes = 1;
  1030.     
  1031.     return iRes;                                    
  1032. }
  1033. #endif  //end   #ifdef  REOCRD_KEY
  1034. #ifdef  CHECK_RECORD_DISK_PARENT_LVL
  1035. /****************************************************************
  1036.  *  do DVD-VIDEO disk level control for a recorded disc.
  1037.  *  RETURN:
  1038.  *     1: Disc not need do level control or Level is same as user set,
  1039.  *        or input a correct password
  1040.  *     0: Level is not same as user set and input a incorrect password
  1041.  *  Maoyong 2004.02.20  16:38 
  1042.  ****************************************************************/
  1043. BYTE CheckDiscParentLvl(void)
  1044. {
  1045.     BYTE iRes = 1;
  1046.     
  1047.     //check If no need to do Level Control
  1048.     if(cd_type_loaded != CDDVD)
  1049.         return iRes;
  1050.     else 
  1051.     {
  1052.     #ifdef DVD_AUDIO        //do level check just for DVD video
  1053.         if(dAMG_LSN != 0)   
  1054.             return iRes;                    
  1055. #endif
  1056.         if(pDSV->rsm_info[0].dRSM_PTL_LVL <= UserSet.ParentalLvl)
  1057.             return iRes;
  1058.     }   
  1059.        
  1060.     UserSet.parental_ststus=0;
  1061.     setup_CheckPasswd();
  1062.              
  1063.     //password error!                                                                                                                                                   
  1064.     if(UserSet.parental_ststus == 0)    
  1065.     {
  1066.      printf("-------sys_cmd = %d, system_state = %d-------------n", sys_cmd, system_state);
  1067.      //Maoyong 2004.03.06, IRC_POWER/IRC_EJECT special process
  1068. if(user_input_pwd ==2)
  1069. {
  1070. user_input_pwd = 0;
  1071. //make not to change to SYSTEM_BRWOSE.  In fact, ignore POWER key.
  1072. system_state = SYSTEM_OPEN;
  1073. sys_cmd = 0;
  1074. }
  1075.      else
  1076.      { sys_cmd = 0;
  1077.      system_state = SYSTEM_STOP;
  1078.      play_state = VCD_STATE_STOP;    
  1079.      ircmd_stop();         
  1080.      }
  1081.      iRes = 0;   
  1082.     }
  1083.     return iRes;            
  1084. }                                                    
  1085. #endif  //end #ifdef CHECK_RECORD_DISK_PARENT_LVL 2004.02.20 maoyong
  1086. /****************************************************************
  1087.  *  check if recorded disc need to do record resume action.
  1088.  *  RETURN:
  1089.  *     0:  Not need,    
  1090.  *     1:   Yes, need
  1091.  *  Maoyong 2004.02.20  16:38
  1092.  ***************************************************************/ 
  1093. BYTE CheckIfRealRsm(void)
  1094. {
  1095. #ifdef DVD_AUDIO//nono 2004-2-25 0:40
  1096.     if( (cd_type_loaded==CDDVD) && (dAMG_LSN!=0) )
  1097.         return 0;
  1098. #endif //DVD_AUDIO
  1099. #ifdef RECORD_KEY
  1100. if(CheckRecordKey())
  1101. return 1;
  1102. else
  1103. return 0;
  1104. #else
  1105. return 1; //No record key, direct do resume play
  1106. #endif //RECORD_KEY 
  1107. }
  1108. /****************************************************************
  1109.  *  check if the disc is recorded and if need to do record resume. 
  1110.  *  RETURN:
  1111.  *     0:   should not load rsm
  1112.  *     1:   need to load 
  1113.  *  Maoyong 2004.02.20  16:38
  1114.  ****************************************************************/
  1115. BYTE CheckLoadRsmInfo(void)
  1116. {
  1117. #if !defined(POWER_RESUME)&& !defined(SAME_DISC_RESUME)&& !defined (RECORD_KEY)
  1118. return 0;
  1119. #endif
  1120. //for some customers, has eject record, but not need to choose if en/dis resume play 
  1121. //in setup Menu, but this case is rarely used.
  1122. #if defined(NOT_SHOW_SAME_DISC_RESUME)&&defined(SAME_DISC_RESUME)
  1123. same_disc_onoff = 1;
  1124. #endif
  1125. #ifdef SAME_DISC_RESUME
  1126. same_disc_onoff = 1;
  1127. #endif
  1128. /*===========================================================================
  1129. The folling pre-compile condition is for basic usage.
  1130. (1)RECORD KEY: You need not to check same_disc_onoff. resume play is controlled
  1131.    by user. It can be treated as highest level
  1132. (2)POWER_RESUME: you can add "same_disc_onoff" constrict by your own definiton
  1133. Please don't change sequence!
  1134. So, please use your owe definition to make combination of different resum func.
  1135. =============================================================================*/
  1136. #if defined(RECORD_KEY) //if has "Record" on IR Panel, control resume by "Record" Key
  1137. if(same_disc_flag)
  1138. #elif defined(POWER_RESUME) && defined(SAME_DISC_RESUME) //power+eject Out Record
  1139.     if(same_disc_flag && same_disc_onoff)
  1140.     #elif defined(POWER_RESUME) //just use power record. maybe seldom used dependently
  1141.     if(same_disc_flag)
  1142. #elif defined(SAME_DISC_RESUME) //just use eject out record
  1143.     if(same_disc_flag && same_disc_onoff)
  1144. #endif
  1145.     {
  1146.      if(CheckIfRealRsm())
  1147.      return 1;    
  1148.     }    
  1149.     return 0;
  1150. void RecordRsmPlay(void)
  1151. {
  1152. if( (resumeMSF<0x3fffffff)&&(resumeMSF>0) )
  1153.     {
  1154.          //terry,2003/8/13 01:01AM
  1155.          sys_cmd=CMD_FUNC|CMD_FUNC_RESUME;
  1156.          #ifdef RECORD_KEY         //fengjl add 3-12-7 15:03
  1157.          PrintOsdMsg(STR_OS_RECORD_RESUME,REGION1,2,0);
  1158.          #else
  1159.          OSD1000ISP_STATUS(OSDISP_RESUME, OSDIR_GLOBAL);
  1160.          PrintOsdMsg(STR_OS_RESUME,REGION1,2,0);
  1161.          #endif
  1162.          printf("======= system CMD_FUNC_RESUME========n");                                    
  1163.     }
  1164. }