static VACTION time_con_keymap(POBJECT_HEAD pObj, UINT32 key) { VACTION act; SYSTEM_DATA* p_sys_data=sys_data_get(); date_time dt; INT32 hoffset, moffset; UINT8 save; INT32 ret1,ret2; switch(key) { case V_KEY_UP: act = VACT_CURSOR_UP; break; case V_KEY_DOWN: act = VACT_CURSOR_DOWN; break; case V_KEY_EXIT: case V_KEY_MENU: act = VACT_CLOSE; win_time_get_input(); if(p_sys_data->local_time.buseGMT) { sys_data_gmtoffset_2_hmoffset(&hoffset, &moffset); set_STC_offset( hoffset, moffset, 0); get_UTC(&dt); set_STC_time(&dt); enable_time_parse(); } else { ret1 = api_check_valid_date(win_time_local_time.year,win_time_local_time.month,win_time_local_time.day); if(ret1 != 0 || win_time_local_time.hour>23 || win_time_local_time.min>=60) { win_compopup_init(WIN_POPUP_TYPE_OKNO); win_compopup_set_msg(NULL,NULL,RS_MSG_INVALID_INPUT_CONTINUE); win_compopup_set_frame(GET_MID_L(300),GET_MID_T(100),320,100); if(win_compopup_open_ext(&save) == WIN_POP_CHOICE_YES) act = VACT_PASS; else act = VACT_CLOSE; } else { set_STC_offset(0,0,0); set_STC_time(&win_time_local_time); p_sys_data->local_time.GMToffset_count = 23; disable_time_parse(); } } break; case V_KEY_ENTER: act = VACT_ENTER; break; default: act = VACT_PASS; break; } return act; }
static PRESULT tetris_key_proc(UINT32 vkey, UINT8 key_repeat_cnt, UINT8 key_status) { UINT8 back_saved; PRESULT ret = PROC_LOOP; if (key_status == PAN_KEY_PRESSED) { switch (vkey) { case V_KEY_UP: ChangeShape(&x, &y, &CurrentShape, &Status); break; case V_KEY_DOWN: GoDown(&x, &y, &CurrentShape, &Status); if (key_repeat_cnt == 0) { /* speed up drop speed */ osal_timer_set(GAME_CYCLIC_ID, 100); speed_up = TRUE; } break; case V_KEY_LEFT: GoLeft(&x, &y, &CurrentShape, &Status); break; case V_KEY_RIGHT: GoRight(&x, &y, &CurrentShape, &Status); break; case V_KEY_ENTER: if (playing == TRUE) { osal_timer_activate(GAME_CYCLIC_ID, FALSE); win_compopup_init(WIN_POPUP_TYPE_OK); win_compopup_set_frame(GET_MID_L(170), GET_MID_T(130), 170, 130); win_compopup_set_msg(NULL, NULL, RS_PAUSE); win_compopup_open_ext(&back_saved); osal_timer_activate(GAME_CYCLIC_ID, TRUE); } break; case V_KEY_MENU: case V_KEY_EXIT: if (playing == TRUE) { osal_timer_activate(GAME_CYCLIC_ID, FALSE); win_compopup_init(WIN_POPUP_TYPE_OKNO); //win_compopup_set_frame(GET_MID_L(250), GET_MID_T(130), 250, 130); win_compopup_set_frame(GET_MID_L(250), GET_MID_T(130), 320, 130); win_compopup_set_msg(NULL, NULL, RS_GAME_MSG_DO_YOU_QUIT); if (win_compopup_open_ext(&back_saved) == WIN_POP_CHOICE_YES) { playing = FALSE; tetris_init(); update_status(Speed, Erasered, TotalMark); tetris_redraw_main(); tetris_redraw_preview(); OSD_SetAttr((POBJECT_HEAD)&txt_start, C_ATTR_ACTIVE); OSD_ChangeFocus((POBJECT_HEAD)&game_con, 1, \ C_UPDATE_FOCUS | C_DRAW_SIGN_EVN_FLG); } else { osal_timer_activate(GAME_CYCLIC_ID, TRUE); } } break; default: ret = PROC_PASS; } } else if (key_status == PAN_KEY_RELEASE) { normal_speed(); } return ret; }
static PRESULT par_item_con_callback(POBJECT_HEAD pObj, VEVENT event, UINT32 param1, UINT32 param2) { PRESULT ret = PROC_PASS; UINT8 unact,input,save; UINT8 id = OSD_GetObjID(pObj); SYSTEM_DATA* p_sys_data=sys_data_get(); switch(event) { case EVN_FOCUS_PRE_GET: break; case EVN_FOCUS_PRE_LOSE: break; case EVN_UNKNOWN_ACTION: unact = (VACTION)(param1>>16) ; if(unact == VACT_DECREASE) { win_par_left_key(pObj,id); } else if(unact == VACT_INCREASE) { win_par_right_key(pObj,id); } else if(unact <= VACT_NUM_9) { if((g_PL_Input_Status==TRUE)&&(g_PL_Input_Bit_Number==3)) { if(id==MENU_PARENTAL_PASSWORD) { win_pl_input_number(0,(UINT8)(unact-VACT_NUM_0)); win_pl_set_password_str(0); win_par_switch_confirm(TRUE); g_PL_Input_Bit_Number=0; g_PL_Input_Status=FALSE; win_pl_password_value[1]=0; win_pl_set_password_str(1); OSD_ChangeFocus((POBJECT_HEAD)&win_parental_con,MENU_PARENTAL_PASSWORD2,C_UPDATE_ALL); OSD_DrawObject((POBJECT_HEAD)&par_item_con3, C_UPDATE_ALL); OSD_TrackObject((POBJECT_HEAD)&par_item_con4,C_UPDATE_ALL); } else { win_pl_input_number(1,(UINT8)(unact-VACT_NUM_0)); if(win_pl_password_value[0]==win_pl_password_value[1]) { win_pl_set_password_str(1); OSD_TrackObject(pObj,C_UPDATE_ALL); win_compopup_init(WIN_POPUP_TYPE_OK); win_compopup_set_msg(NULL,NULL,RS_MSG_CHANGE_PASSWORD_SUCCESS); win_compopup_set_frame(GET_MID_L(550),GET_MID_T(220),550,200); win_compopup_open_ext(&save); p_sys_data->menu_password=win_pl_password_value[0]; return PROC_LEAVE; } else { g_PL_Input_Bit_Number=0; g_PL_Input_Status=FALSE; win_pl_password_value[1]=0; win_pl_set_password_str(1); OSD_TrackObject(pObj,C_UPDATE_ALL); } } } else { win_pl_input_number(id-MENU_PARENTAL_PASSWORD,(UINT8)(unact-VACT_NUM_0)); win_pl_set_password_str(id-MENU_PARENTAL_PASSWORD); OSD_TrackObject(pObj,C_UPDATE_ALL); } } ret = PROC_LOOP; break; } return ret; }
static BOOL GoDown(INT16 *x, INT16 *y, INT8 *CurrentShape, INT8 *Status) { INT8 AllAreOne = 1, removed_lines = 0; INT8 i, j, r, l, rr, ll; UINT8 back_saved; if (Possible(*x, (*y) + 1, *CurrentShape, *Status)) { hide(*x, *y, *CurrentShape, *Status); (*y)++; show(*x, *y, *CurrentShape, *Status, BLOCK_ACTIVE); return TRUE; } normal_speed(); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { back[i + *y][j + *x] += shape[*CurrentShape][*Status][i][j]; } } for (r = 1; r < MAXY; r++)//20 { for (l = 2; l < 2 + MAXX; l++)//13 { if (back[r][l] == 0) { AllAreOne = 0; } } if (AllAreOne == 1) { for (rr = r; rr > 0; rr--) { for (ll = 2; ll < 2 + MAXX; ll++) { back[rr][ll] = back[rr - 1][ll]; } } for (ll = 2; ll < 2 + MAXX; ll++) { back[0][ll] = 0; }//the upper line will be all zero which represented the line is blank Erasered++; if((!(Erasered % 30)) && (Speed < 10)) { Speed++; osal_timer_set(GAME_CYCLIC_ID, TimeDelay[Speed - 1]); } removed_lines++; } AllAreOne = 1; } show(*x, *y, *CurrentShape, *Status, BLOCK_INACTIVE); //sunk the button CreateNewShape(x, y, CurrentShape, Status); if (!Possible(*x, *y, *CurrentShape, *Status)) { playing = FALSE; osal_timer_activate(GAME_CYCLIC_ID, FALSE); win_compopup_init(WIN_POPUP_TYPE_OK); win_compopup_set_frame(GET_MID_L(250), GET_MID_T(130), 250, 130); win_compopup_set_msg(NULL, NULL, RS_GAME_SORRY_YOU_LOST); win_compopup_open_ext(&back_saved); tetris_init(); update_status(Speed, Erasered, TotalMark); tetris_redraw_main(); tetris_redraw_preview(); OSD_SetAttr((POBJECT_HEAD)&txt_start, C_ATTR_ACTIVE); OSD_ChangeFocus((POBJECT_HEAD)&game_con, 1, \ C_UPDATE_FOCUS | C_DRAW_SIGN_EVN_FLG); } TotalMark += (Speed + 1) * (10 + removed_lines - 1) * removed_lines; update_status(Speed, Erasered, TotalMark); if (removed_lines > 0) { tetris_redraw_main(); } if (playing == TRUE) { show(*x, *y, *CurrentShape, *Status, BLOCK_ACTIVE); } return FALSE; }
static void hddfmt_start() { UINT8 back_saved; win_popup_choice_t choice; UINT8 mode; struct dvr_HDD_info hdd_info; char volume_name[48]; char osd_name[48]; char hint[64]; BOOL ret; disk_format_mode_num = get_fsystem_installed(disk_mode, 8); //sprintf(temp, "%s", disk_mode[input]); storage_index_to_osd_string((UINT8)hddfmt_cur_volume,osd_name); sprintf(hint, "Are you sure to format the %s?", osd_name); if(disk_format_mode_num == 1) { win_compopup_init(WIN_POPUP_TYPE_OKNO); win_compopup_set_btnstr_ext(0, disk_mode[0]); win_compopup_set_default_choice(WIN_POP_CHOICE_NO); } else if(disk_format_mode_num == 2) { win_compopup_init(WIN_POPUP_TYPE_OKNOCANCLE); win_compopup_set_btnstr_ext(0, disk_mode[0]); win_compopup_set_btnstr_ext(1, disk_mode[1]); win_compopup_set_default_choice(WIN_POP_CHOICE_CANCEL); } win_compopup_set_msg(hint, NULL, 0); choice = win_compopup_open_ext(&back_saved); if(((disk_format_mode_num == 1) && (choice == WIN_POP_CHOICE_YES)) || ((disk_format_mode_num == 2) && ((choice == WIN_POP_CHOICE_YES) || (choice == WIN_POP_CHOICE_NO)))) { if(choice == WIN_POP_CHOICE_YES) mode = 1; else mode = 2; storage_index2volume((UINT8)hddfmt_cur_volume,volume_name); storage_add_parent_dir(volume_name); win_compopup_init(WIN_POPUP_TYPE_SMSG); win_compopup_set_frame(GET_MID_L(286), GET_MID_T(130), 286, 130); win_compopup_set_msg_ext("formating wait!",NULL,0); win_compopup_open_ext(&back_saved); ret = pvr_format_multi_hdd(mode, volume_name); win_compopup_smsg_restoreback(); if(!ret) { win_compopup_init(WIN_POPUP_TYPE_OK); sprintf(hint, "Format %s error?", osd_name); win_compopup_set_msg(hint, NULL, 0); win_compopup_set_default_choice(WIN_POP_CHOICE_CANCEL); win_compopup_open_ext(&back_saved); return; } if(STRCMP((char *)pvr_get_mout_prefix(), volume_name)==0) { if(pvr_get_HDD_info(&hdd_info)) { api_pvr_check_level(&hdd_info); ap_clear_all_message();//or usb reflash msg maybe send fail pvr_evnt_callback(0, PVR_HDD_FORMATTED); } } win_hddfmt_draw_disk_infor(); } }