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

DVD

开发平台:

C/C++

  1. /*
  2. * Terry,2003/8/20 06:43PM
  3. * This file is about password.
  4. */
  5. #if defined(SDRAM_16Mb_Mode)//&&defined(NEW_STYLE_SETUP)//zhaoyanhua add 2003-11-10 16:33
  6. #include "memmap.h"
  7. #include "memmap0.h"
  8. #endif
  9. const BYTE Custm_Password[PASSWORD_TOTAL_DIGITAL]=SUPER_PASSWORD;      //defined in user_init.h, Jeff 20020606
  10. #ifdef PULIANG_PASSWORD     //yaowh add 04-12-22
  11. #define REGION_CODE_PSW             {IRC_8,IRC_2,IRC_0,IRC_0}
  12. #define FIRM_WARE_VER_PSW           {IRC_UP,IRC_DOWN,IRC_LEFT,IRC_RIGHT}
  13. #define SUPER_PASSWORD              {IRC_1,IRC_0,IRC_0,IRC_4}
  14. BYTE custm_count_1 = 0;
  15. BYTE custm_count_2 = 0;
  16. const BYTE Custm_Password_1[4]=FIRM_WARE_VER_PSW;
  17. const BYTE Custm_Password_2[4]=REGION_CODE_PSW;
  18. extern void osd_print_region2(t_osd_region *p, const char *s0, BYTE y_start,BYTE x_start);
  19. #endif
  20. #ifdef  USER_VERSION_INFORMATION//eastech
  21. #define VERSION_INFORMATION {IRC_1,IRC_2,IRC_3}
  22. const BYTE Custm_version[3]=VERSION_INFORMATION;
  23. BYTE    temp_data[4];
  24. BYTE    enter_display_flag=0;
  25. #define VERSION_INFORMATION_STRING  "VER 040727 1"
  26. BYTE version_count=0;
  27. #endif
  28. #ifdef  MIDI_EJECT_PASSWORD   //ouyang add for eject password 2004-11-20 15:10
  29. #define MIDI_OPEN_PASSWORD {IRC_6,IRC_6,IRC_7,IRC_7}
  30. const BYTE midi_open_password[4]=MIDI_OPEN_PASSWORD;
  31. BYTE    temp_num[4];
  32. //BYTE    enter_display_flag=0;
  33. BYTE midi_open_count=0;
  34. #endif
  35. #ifdef AD_TCL//2004-3-22 12:55 lijd
  36. const BYTE inter_Pass[4]=INTER_PASSWORD;      //defined in user_init.h, Jeff 20020606
  37. const BYTE macro_Pass[4]=MACRO_PASSWORD;      //defined in user_init.h, Jeff 20020606
  38. BYTE inter_count = 0;
  39. BYTE macro_count = 0;
  40. #endif
  41. #ifdef SUPPORT_PASSWD2
  42. const BYTE Custm_Password1[4]=SUPER_PASSWORD1;//defined in user_init.h, Jeff 20020606
  43. #endif
  44. #ifdef QSI_PLATFORM //qsi: added by johnson 20040713
  45. void display_custm_menu(void);
  46. enum {
  47.     VER_SHOW_VIA_NORMAL=0,
  48.     VER_SHOW_VIA_SPECIAL, // for internal
  49.     VER_SHOW_MAX
  50. };
  51. static BYTE version_show_entry;
  52. BYTE is_show_full_qsi_version(void)
  53. {
  54.     return(version_show_entry==VER_SHOW_VIA_SPECIAL);
  55. }
  56. void display_custm_menu_full(void)
  57. {
  58.     version_show_entry = VER_SHOW_VIA_SPECIAL;
  59.     //display_custm_menu();
  60.     setup_ShowCUSTMMsg();
  61. }
  62. #endif
  63. //#define SUPPORT_PASSWD3 //for testing
  64. #ifdef SUPPORT_PASSWD3
  65. #ifndef SUPER_PASSWORD3
  66. #define SUPER_PASSWORD3              {IRC_1,IRC_5,IRC_9,IRC_7}   //define super password when open tray
  67. #endif
  68. UINT8 setup_audio_mode,custm_count3=0;
  69. const BYTE Custm_Password3[4]=SUPER_PASSWORD3;//defined in user_init.h, Jeff 20020606
  70. #endif
  71. #ifdef WATCH_LOADER_ID
  72. const BYTE Loader_Password[4]={IRC_1,IRC_2,IRC_3,IRC_4};     //defined in user_init.h, Jeff 20020606
  73. #endif
  74. #ifdef DVD_SERVO
  75. extern const BYTE Servo_Password[8];                // kernel/hwif.c
  76. extern BYTE *GetServoCodeVersion();
  77. #endif
  78. #if defined (SUPPORT_SPG_GAME) && !defined (DVDRELEASE) && defined (SPG_ICE)                
  79. const BYTE ICE_Password[4]={IRC_9,IRC_9,IRC_9,IRC_2};
  80. static BYTE ICEId_count=0;
  81. #endif
  82. BYTE custm_count = 0;
  83. #ifdef SUPPORT_PASSWD2
  84. BYTE custm_count1 = 0;
  85. BYTE only_disp_setup_menu = 0;
  86. #endif
  87. #ifdef DVD_SERVO
  88. BYTE servo_count=0;  //Jeff 20030818
  89. #endif
  90. #ifdef WATCH_LOADER_ID
  91. static BYTE LoaderId_count=0;
  92. #endif
  93. //=============================================
  94. //for DVD_SETUP_REENG   //added by JS   //20040728
  95. #ifdef DVD_SETUP_REENG
  96. void display_custm_menu(void)
  97. {            
  98.     //printf("display_custm_menun");
  99.     full_scrn=(SETUP|CUSTM);
  100.     read_custm_setup_select();
  101.     
  102. #if defined(SDRAM_16Mb_Mode)//&&defined(NEW_STYLE_SETUP)
  103.             //NOTE:
  104.             //when SDRAM_16M_Mode,ShowTitle() may destroyed 
  105.             // OSD memory. So must evaluate osd_base_addr again.
  106.             //zhaoyanhua add 2003-11-10 17:06
  107.             regs0->osd_base_addr=OSD_BASE_USE_ADDR;//P_BIDIR_LUMA;
  108. #endif    
  109.     
  110.     ShowSetupPage(0);
  111. //Maoyong added for IR U/D/L/R/Sel proc func setting 2004-9-24 9:12
  112.     SetFullscrnCmdFuncPtr( setup_func_up, setup_func_down, setup_func_left,
  113.                            setup_func_right,  setup_func_select);
  114. }
  115. #else    
  116. void display_custm_menu(void)
  117. {            
  118.     index_y=3;
  119.     full_scrn=(SETUP|CUSTM);
  120.     read_custm_setup_select();
  121. #if defined(SDRAM_16Mb_Mode)//&&defined(NEW_STYLE_SETUP)
  122.             //NOTE:
  123.             //when SDRAM_16M_Mode,ShowTitle() may destroyed 
  124.             // OSD memory. So must evaluate osd_base_addr again.
  125.             //zhaoyanhua add 2003-11-10 17:06
  126.             regs0->osd_base_addr=OSD_BASE_USE_ADDR;//P_BIDIR_LUMA;
  127. #endif
  128.     
  129. #ifdef SETUP_TAB
  130. #ifdef SOFT_MENU//Modifed by ChenZhao on 2004-9-11 13:58 WP
  131. osd_init_setup();
  132. ShowSetupPage(REFRESH_CUSTM);
  133. #else
  134.     ShowSetupPage(1);
  135. #endif   
  136.     
  137.             
  138. #else
  139.     ShowSetupPage();
  140. #endif
  141.     //Maoyong added for IR U/D/L/R/Sel proc func setting 2004-9-24 9:12
  142.     SetFullscrnCmdFuncPtr( setup_func_up, setup_func_down, setup_func_left,
  143.                            setup_func_right,  setup_func_select); 
  144. #ifdef SUPPORT_PASSWD2         
  145.     custm_count1=0;
  146. #endif    
  147.     custm_count=0;
  148. }
  149. #endif  //endo of DVD_SETUP_REENG
  150.                                                        
  151. static inline void standard_chk_password(UINT8 rx)
  152. {
  153.     if( (play_state==VCD_STATE_IDLE)||(play_state==VCD_STATE_OPEN) ) 
  154.     {
  155.         if (full_scrn&SETUP) 
  156.         {
  157.             custm_count=0;
  158. #ifdef SUPPORT_PASSWD2     
  159.             custm_count1=0;
  160. #endif
  161.         }
  162.         if(rx==Custm_Password[custm_count]) 
  163.         {
  164.             custm_count++;
  165.             if(custm_count>=PASSWORD_TOTAL_DIGITAL) 
  166.             {
  167. #ifdef QSI_PLATFORM //qsi: added by johnson 20040713
  168.                 version_show_entry=VER_SHOW_VIA_NORMAL;
  169. #endif
  170.                 display_custm_menu();
  171.                 return;
  172.             }
  173.          }
  174. #ifdef AD_TCL    //2004-3-22 12:57 lijd 
  175.         else if (rx==inter_Pass[inter_count])
  176.             {
  177.                 inter_count++;
  178.                 if(inter_count>=4) 
  179.                 {
  180.                     psprintf(linebuf,INTER_VER);           
  181.                     strcpy(RegionValStr[REGION2], linebuf);
  182.                     PrintOsdMsg(STR_OS_SPACE, REGION2, 1, 1);
  183.                     inter_count=0;
  184.                     return;
  185.                 }
  186.             }
  187.         else if (rx==macro_Pass[macro_count])
  188.             {
  189.                 macro_count++;
  190.                 if(macro_count>=4) 
  191.                 {
  192.                     psprintf(linebuf,MACRO_VER);           
  193.                     strcpy(RegionValStr[REGION2], linebuf);
  194.                     PrintOsdMsg(STR_OS_SPACE, REGION2, 1, 1);
  195.                     macro_count=0;
  196.                     return;
  197.                 }
  198.             }
  199. #endif
  200.         else 
  201.         {
  202.             #ifdef AD_TCL//2004-3-22 14:51 lijd
  203.         macro_count=0;
  204.             inter_count=0;
  205.             #endif
  206.             custm_count=0;
  207.         }
  208.         
  209. #ifdef SUPPORT_PASSWD2        
  210.         if(rx==Custm_Password1[custm_count1]) 
  211.         {
  212.             custm_count1++;
  213.             if(custm_count1>=4) 
  214.             {                
  215. #ifdef QSI_PLATFORM //qsi: added by johnson 20040713
  216.                 version_show_entry=VER_SHOW_VIA_SPECIAL;
  217. #endif
  218.                 display_custm_menu();
  219.                 only_disp_setup_menu=1;
  220.                 return;
  221.             }
  222.         } else 
  223.         {
  224.             custm_count1=0;
  225.         }
  226.         
  227.         if(only_disp_setup_menu==1)
  228.         {
  229.             ExitSetupPage(1);
  230.             only_disp_setup_menu = 0;
  231.         }
  232. #endif
  233. #ifdef SUPPORT_PASSWD3
  234.         if( full_scrn==(SETUP|CUSTM) )
  235.         {
  236.             if(rx==Custm_Password3[custm_count3]) 
  237.             {
  238.                 custm_count3++;
  239.                 if(custm_count3>=4) 
  240.                 {
  241.                     setup_audio_mode=1;
  242.                         chg_audio_default_mode();
  243.                 }
  244.             } else 
  245.             {
  246.                 custm_count3=0;
  247.             }
  248.     }
  249. #endif
  250. #ifdef DVD_SERVO
  251.         if(rx==Servo_Password[servo_count]) { //Jeff 20030818
  252.             servo_count++;
  253.             if(servo_count>=8) {
  254.                 servo_count=0;
  255.                 psprintf(RegionValStr[REGION2], "%s", GetServoCodeVersion());
  256.                 PrintOsdMsg(STR_OS_SPACE, REGION2, 10, 1);
  257.                 return;
  258.             }
  259.         } else {
  260.             servo_count=0;
  261.         }
  262. #endif
  263.         #ifdef WATCH_LOADER_ID                
  264.         if(rx==Loader_Password[LoaderId_count]) {
  265.         
  266.             extern char Loader_ID[28];//kenny 2002/11/22
  267.             
  268.             LoaderId_count++;
  269.             if(LoaderId_count>=4) {
  270.                 LoaderId_count=0;
  271.                                         
  272.                 psprintf(RegionValStr[REGION3], "LOADER ID: %s", &Loader_ID[0]);
  273.                 PrintOsdMsg(STR_OS_SPACE, REGION3, 0, 1);
  274.                 
  275.                 return;
  276.             }
  277.         } else {
  278.             LoaderId_count=0;
  279.         }
  280.         #endif //#ifdef WATCH_LOADER_ID
  281.         #if defined (SUPPORT_SPG_GAME) && !defined (DVDRELEASE) && defined (SPG_ICE)               
  282.         if(rx==ICE_Password[ICEId_count]) {
  283.             extern void FS_ICEMainLoop();
  284.           
  285.             ICEId_count++;
  286.             if(ICEId_count>=4) {
  287.                 ICEId_count=0;
  288.                 FS_ICEMainLoop();                     
  289.                 return;
  290.             }
  291.         } else {
  292.             ICEId_count=0;
  293.         }
  294.         #endif //#ifdef WATCH_LOADER_ID
  295.     } //if( (play_state==VCD_STATE_IDLE)||(play_state==VCD_STATE_OPEN) )
  296. }
  297. #ifdef PULIANG_PASSWORD     //yaowh add 04-12-22
  298. static inline void puliang_chk_password(UINT8 rx)
  299. {
  300.     if ( (rx==Custm_Password[custm_count])&&(full_scrn&SETUP) )
  301.     {
  302.         custm_count++;
  303.         if(custm_count>=4) 
  304.         {
  305.             display_custm_menu();
  306.             return;
  307.         }
  308.     }
  309.     else if( (rx==Custm_Password_1[custm_count_1])&&(play_state==VCD_STATE_OPEN) )
  310.     {
  311.         custm_count_1++;
  312.         if(custm_count_1>=4) 
  313.         {
  314.             PrintOsdMsg(FIRM_WARE_VER , REGION1, 0, 0);
  315.             return;
  316.         }
  317.     }             
  318.     else if( (rx==Custm_Password_2[custm_count_2])&&(play_state==VCD_STATE_OPEN) )
  319.     {
  320.         custm_count_2++;
  321.         if(custm_count_2>=4) 
  322.         {
  323.             PrintOsdMsg(REGION_CODE , REGION1, 0, 0);
  324.             return;
  325.         }
  326.     }
  327.     else 
  328.     {
  329.         custm_count_1=0;
  330.         custm_count_2=0;
  331.         custm_count=0;
  332.     }
  333. }
  334. #endif  //#ifdef puliang_password
  335. static inline void eastech_chk_password(UINT8 rx)
  336. {
  337. #ifdef EASTECH_PASSWORD
  338.     //printf("enter2n");
  339.     //printf("enter_display_flag= %xn",enter_display_flag);
  340.     //printf("------------n");
  341.     //printf("play_state= %xn",play_state);
  342.     if( (play_state==VCD_STATE_OPEN)&&(enter_display_flag)) //||(play_state==VCD_STATE_OPEN) ) 
  343.     {
  344.         //printf("enter-------------1n");
  345.            if (full_scrn&SETUP) 
  346.             {
  347.                     custm_count=0;
  348.             }
  349.            if(custm_count==0)
  350.            {
  351.             temp_data[0]=0;
  352.             temp_data[1]=0;
  353.             temp_data[2]=0;
  354.             temp_data[3]=0;
  355.            }
  356.         temp_data[custm_count]=rx;
  357.         custm_count++;
  358.         if(temp_data[0]==Custm_version[0] && 
  359.         temp_data[1]==Custm_version[1] && 
  360.         temp_data[2]==Custm_version[2])
  361.         {
  362.             psprintf(linebuf,"%s %d ",VERSION_INFORMATION_STRING,UserSet.P_RCD);
  363.             //psprintf(linebuf,VERSION_INFORMATION_STRING);        
  364.             strcpy(RegionValStr[REGION2], linebuf);
  365.             PrintOsdMsg(STR_OS_SPACE, REGION2, 1, 1);
  366.             timeout_osd[REGION2]= 3*OSD_TIMEOUT;            
  367.             custm_count=0;
  368.             enter_display_flag=0;
  369.             return;
  370.         }
  371.         if(temp_data[0]==Custm_Password[0] && 
  372.         temp_data[1]==Custm_Password[1] && 
  373.         temp_data[2]==Custm_Password[2]&&
  374.         temp_data[3]==Custm_Password[3])
  375.         {
  376.             display_custm_menu();
  377.             enter_display_flag=0;
  378.             custm_count=0;
  379.                     return;
  380.         }
  381.         if(custm_count>4)
  382.         {
  383.             custm_count=0;
  384.             enter_display_flag=0;
  385.         }
  386.         return;
  387.     }
  388. #endif//#ifdef EASTECH_PASSWORD
  389. }
  390.  #ifdef MIDI_EJECT_PASSWORD    //ouyang add for eject password 2004-11-20 15:10
  391.      
  392. UINT8 midi_open_pwd_start = 0;
  393. UINT8 midi_open_pwd_finished = 0;    
  394. static inline int midi_eject_chk_password(UINT8 rx)
  395. {
  396.     if(midi_open_pwd_start)
  397.     {
  398.            if (full_scrn&SETUP) 
  399.             {
  400.              midi_open_count=0;
  401.             }
  402.            if(midi_open_count==0)
  403.            {
  404.             temp_num[0]=0;
  405.             temp_num[1]=0;
  406.             temp_num[2]=0;
  407.             temp_num[3]=0;
  408.            }
  409.             temp_num[midi_open_count]=rx;
  410.            if( rx != IRC_EJECT )
  411.             midi_open_count++;
  412.             else
  413.              midi_open_count=0;
  414. printf("========temp_num================= %d %d %d %d =====n",temp_num[0],temp_num[1],temp_num[2],temp_num[3]);
  415. printf("========midi_open_password ====== %d %d %d %d =====n",midi_open_password[0],midi_open_password[1],midi_open_password[2],midi_open_password[3]);
  416.         if(temp_num[0]==midi_open_password[0] && 
  417.         temp_num[1]==midi_open_password[1] && 
  418.         temp_num[2]==midi_open_password[2]&&
  419.         temp_num[3]==midi_open_password[3])
  420.         {
  421.             if( rx == IRC_SELECT ){
  422.             //enter_display_flag=0;
  423.             midi_open_pwd_finished=1;
  424.             ircmd_eject_toggle();
  425.             midi_open_count=0;
  426.             return 0;
  427.        }            
  428.         }else
  429.         {
  430.             extern void CleanSysMessage(BYTE);
  431. //            extern void osd_Clear_Region(BYTE reg, BYTE bkColor);
  432.             if( rx == IRC_SELECT ){//xlluo modify here 11:16 2004-12-21
  433.                 midi_open_pwd_start     =0;    
  434.                 midi_open_pwd_finished  =0; 
  435.                 midi_open_count=0;
  436.                 CleanSysMessage(1);
  437.                }     
  438.         }
  439.         if(midi_open_count>4)
  440.         {
  441.             midi_open_count=0;
  442.             //enter_display_flag=0;
  443.         }
  444. //        return 1;
  445.     }
  446.     return 1;
  447. }
  448. #endif//#ifdef MIDI_EJECT_PASSWORD    //ouyang add for eject password 2004-11-20 15:10
  449. void chk_password(UINT8 rx)
  450. {
  451. #ifdef PASSWORD
  452. #if defined( EASTECH_PASSWORD )
  453.         eastech_chk_password(rx);
  454.     #elif defined(PULIANG_PASSWORD)     //yaowh add 04-12-22
  455.         puliang_chk_password(rx);
  456.     #elif defined( MIDI_EJECT_PASSWORD )   //ouyang add for eject password 2004-11-20 15:10
  457.         if (!midi_eject_chk_password(rx)) return;
  458.         standard_chk_password(rx);        //ouyang 2004-12-3 11:39
  459.     #else
  460.         standard_chk_password(rx);
  461.     #endif
  462. #endif //#ifdef PASSWORD
  463.     safe_srn_off();
  464.     if(old_key==rx)
  465.     {
  466.         UINT16 stmp = regs0->rtc_15_0;
  467.         int diff = stmp-timestamp_key;
  468.         #ifdef Ti3001_OSD_UI_1      // AMP osd timeout=2*OSD_TIMEOUT //jason 2-10-4 15:34
  469.         if (diff < OSD_TIMEOUT*2)
  470.         #elif defined(NEW_UART_COMMAND)
  471.         if(diff< OSD_TIMEOUT*2)
  472.         #else
  473.         if (diff < OSD_TIMEOUT)
  474.         #endif
  475.         {
  476.             if(action_click)
  477.                 timestamp_key = regs0->rtc_15_0;
  478.             action_click=1;
  479.             //printf("actionn");
  480.         }else
  481.         {
  482.             timestamp_key = regs0->rtc_15_0;
  483.             action_click=0;
  484.             //printf("action time outn");
  485.         }
  486.     }else
  487.     {
  488.         timestamp_key = regs0->rtc_15_0;
  489.         action_click=0;
  490.         //printf("difference keyn");
  491.     }
  492.     #ifndef IR_TOOL
  493.     #ifdef IR_DBG
  494.     printf("nn-----IR input, rx:%x ,cmd:%s -----n",rx,irc_func_str[rx]);
  495.     #endif
  496.     #endif
  497.     if(system_state!=SYSTEM_IDLE)
  498.     {
  499.         ircmd_pre_paser(rx);
  500.     }
  501.     old_key=(BYTE)rx;
  502. }