GameSimu.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:96k
- #ifndef _MMI_GAME_C_ss
- #define _MMI_GAME_C_ss
- #if defined(__GAME_SIMU__)
- #include "GameSimuProts.h" //KP Jerry add on 2007-4-19
- #include "game_simu_release.h"
- #include "Lcd_if.h"
- #include "USBDeviceGprot.h"
- #include "USBDeviceDefs.h"
- #include "USBDeviceGexdcl.h"
- #include "CommonScreens.h"
- #include "MainMenuDef.h"
- // for MMI
- #include "fs_type.h"
- #include "FileMgr.h"
- #include "FileManagerGProt.h"
- #include "FileManagerDef.h"
- #include "Conversions.h"
- #include "fs_errcode.h"
- //#include "EBookDefs.h"
- #define GAME_SEARCH_GB_STR "*.gb"
- #define GAME_SEARCH_GBC_STR "*.gbc"
- #define GAME_SEARCH_NES_STR "*.nes"
- #define GAME_GB_FILE_EXT ".gb"
- #define GAME_GBC_FILE_EXT ".gbc"
- #define GAME_NES_FILE_EXT ".nes"
- #define GAME_DOWNLOADED_PATH ":\Game\"
- #define MAX_DWNL_GAME_PATH_LEN (60)
- #define MAX_GAME_NAME_LENGTH 60
- #define GAME_LIST_MAX_SETTINGS_MEM_TYPE 11
- typedef enum
- {
- GAME_CARD_MEMORY = 0,
- GAME_PHONE_MEMORY,
- GAME_MAX_MEMORY
- } game_memory_type_enum;
- typedef enum
- {
- GAME_FRM_SEARCH_DEFAULT = 0,
- GAME_FRM_SEARCH_GB,
- GAME_FRM_SEARCH_GBC,
- GAME_FRM_SEARCH_NES,
- GAME_FRM_SEARCH_MAX
- } game_list_frm_search_type_enum;
- ////////////////////////////////
- S8 memory_type_selected;
- S8 auto_gen_game_list;
- U8 game_simu_fmgr_filter;
- U8 game_simu_long_key_press = 0x00;
- U8 game_simu_play_audio_poweron = 0;
- extern pBOOL IsBackHistory;
- ////////////////////////////////
- //U8 file_path_buf[(FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH];
- U8 game_simu_search_type_path;
- typedef struct
- {
- S32 inlineHighligtItemSelectMemory;
- // S32 inlineHighligtItemSelectAutoGen;
- } GAME_SIMU_SET_CNTX;
- typedef struct
- {
- U8 *game_list_settings_memory_type[2];
- // U8 *game_list_settings_auto_gen[2];
- } game_simu_app_cntx;
- typedef struct
- {
- BOOL bLCDState; // 0:竖屏, 1:横屏
- BOOL bVolu; // 1:on 0:off
- }gamesimu_settings_struct;
- typedef enum
- {
- MMI_GAMESIMU_SETTING_LCD,
- MMI_GAMESIMU_SETTING_AUD,
- MMI_GAMESIMU_SETTING_ITEM_COUNT
- } mmi_gamesimu_setting_inline_enum;
- typedef struct
- {
- /* strings for inline selection display */
- UI_string_type lcd_str[2];
- UI_string_type aud_str[2];
- S32 lcd_selected;
- S32 aud_selected;
- /* inline selection item */
- InlineItem inline_game_items[MMI_GAMESIMU_SETTING_ITEM_COUNT *2]; /* one for caption, one for selection */
- } mmi_gamesimu_cntx_struct;
- GAME_SIMU_SET_CNTX g_game_simu_set_cntx;
- game_simu_app_cntx g_game_simu_app_cntx;
- game_simu_app_cntx *g_game_simu_app_cntx_p = &g_game_simu_app_cntx;
- gamesimu_settings_struct game_simu_settings;
- mmi_gamesimu_cntx_struct gamesimu_cntx;
- void game_list_entry_settings(void);
- void mmi_entry_game_list_screen(void);
- //void mmi_gamesimu_highlight_help(void);
- void mmi_gamesimu_entry_help_screen(void);
- void mmi_gamesimu_store_setting(void);
- static void mmi_gamesimu_entry_setting_screen(void);
- /****************************************************************************
- * Macro
- *****************************************************************************/
- #define GAME_SIMU_SWITCH(index, func_ptr)
- {
- SetLeftSoftkeyFunction(func_ptr,KEY_EVENT_UP);
- SetKeyHandler(func_ptr, KEY_RIGHT_ARROW,KEY_EVENT_DOWN);
- }
- //====================================================================================================================//
- //====================================================================================================================//
- //==================================================游戏模拟器开放源代码==============================================//
- //====================================================================================================================//
- //====================================================================================================================//
- extern void debug_uart_output_data( const char *pu8_format_str, ... );
- extern void printfbuf(U8 *pu8_buf, U32 u32_len);
- extern void ShowTimeMs(kal_char *u8_str, U32 u32_time1, U32 u32_time2); // DRV_Reg32(KEY_REGISTER_TIME)
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 一、按键接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- //=============================游戏按键位定义(有键按下时为1)=============================//
- // MENU ESC MUTE|TOPR TOPL OK SELECT | Y X B A | RIGHT LEFT DOWN UP //
- // 高位0000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 低位 //
- // 作 者: 北京英晔科技 //
- //=======================================================================================//
- U32 u32_g_keypad_value; // 按键键值
- //===================================游戏按键寄存器定义==================================//
- // 说 明: 根据手机硬件的不同各按键对应寄存器以及位不同,需要在此定义 //
- // 作 者: 北京英晔科技 //
- //=======================================================================================//
- #define KEY_REGISTER_TIME 0x80200230
- #define KEY_REGISTER_LOW 0x80110004
- #define KEY_REGISTER_MID 0x80110008
- #define KEY_REGISTER_HIG 0x8011000c
- #if defined(__P02_QVGA__)
- const U16 KEY_PUB_LSK = (~(0x0001));
- const U16 KEY_LEFT = (~(0x0002));
- const U16 KEY_UP = (~(0x0004));
- const U16 KEY_PUB_RSK = (~(0x0008));
- const U16 KEY_PUB_VOLUP = (~(0x0010));
- //(~(0x0020));
- //(~(0x0040));
- const U16 KEY_PUB_CALL = (~(0x0080));
- const U16 KEY_DOWN = (~(0x0100));
- const U16 KEY_PUB_OK = (~(0x0200));
- const U16 KEY_RIGHT = (~(0x0400));
- const U16 KEY_PUB_VOLDOWN = (~(0x0800));
- //(~(0x1000));
- //(~(0x2000));
- const U16 KEY_PUB_1 = (~(0x4000));
- const U16 KEY_PUB_4 = (~(0x8000));
- const U16 KEY_PUB_7 = (~(0x0001));
- const U16 KEY_PUB_STAR = (~(0x0002));
- const U16 KEY_PUB_CAMERA = (~(0x0004));
- //(~(0x0008));
- //(~(0x0010));
- const U16 KEY_PUB_2 = (~(0x0020));
- const U16 KEY_PUB_5 = (~(0x0040));
- const U16 KEY_PUB_8 = (~(0x0080));
- const U16 KEY_PUB_0 = (~(0x0100));
- //(~(0x0200));
- //(~(0x0400));
- //(~(0x0800));
- const U16 KEY_PUB_3 = (~(0x1000));
- const U16 KEY_PUB_6 = (~(0x2000));
- const U16 KEY_PUB_9 = (~(0x4000));
- const U16 KEY_PUB_WELL = (~(0x8000));
- //(~(0x0001));
- //(~(0x0002));
- //(~(0x0004));
- //(~(0x0008));
- //(~(0x0010));
- //(~(0x0020));
- //(~(0x0040));
- //(~(0x0080));
- //(~(0x0100));
- const U16 KEY_PUB_ESC = (~(0x0200));
- const U32 REGISTER_PUB_LSK = KEY_REGISTER_LOW;
- const U32 REGISTER_LEFT = KEY_REGISTER_LOW;
- const U32 REGISTER_UP = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_RSK = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_VOLUP = KEY_REGISTER_LOW;
- //
- //
- const U32 REGISTER_PUB_CALL = KEY_REGISTER_LOW;
- const U32 REGISTER_DOWN = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_OK = KEY_REGISTER_LOW;
- const U32 REGISTER_RIGHT = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_VOLDOWN = KEY_REGISTER_LOW;
- //
- //
- const U32 REGISTER_PUB_1 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_4 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_7 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_STAR = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_CAMERA = KEY_REGISTER_MID;
- //
- //
- const U32 REGISTER_PUB_2 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_5 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_8 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_0 = KEY_REGISTER_MID;
- //
- //
- //
- const U32 REGISTER_PUB_3 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_6 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_9 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_WELL = KEY_REGISTER_MID;
- //
- //
- //
- //
- //
- //
- //
- //
- //
- const U32 REGISTER_PUB_ESC = KEY_REGISTER_HIG;
- #elif defined(__P08_QVGA__)
- const U16 KEY_PUB_LSK = (~(0x0001));
- const U16 KEY_LEFT = (~(0x0002));
- const U16 KEY_UP = (~(0x0004));
- const U16 KEY_PUB_RSK = (~(0x0008));
- //(~(0x0010));
- //(~(0x0020));
- //(~(0x0040));
- const U16 KEY_PUB_CALL = (~(0x0080));
- const U16 KEY_DOWN = (~(0x0100));
- const U16 KEY_PUB_OK = (~(0x0200));
- const U16 KEY_RIGHT = (~(0x0400));
- //(~(0x0800));
- //(~(0x1000));
- //(~(0x2000));
- const U16 KEY_PUB_1 = (~(0x4000));
- const U16 KEY_PUB_4 = (~(0x8000));
- const U16 KEY_PUB_7 = (~(0x0001));
- const U16 KEY_PUB_STAR = (~(0x0002));
- const U16 KEY_PUB_VOLUP = (~(0x0004));
- //(~(0x0008));
- //(~(0x0010));
- const U16 KEY_PUB_2 = (~(0x0020));
- const U16 KEY_PUB_5 = (~(0x0040));
- const U16 KEY_PUB_8 = (~(0x0080));
- const U16 KEY_PUB_0 = (~(0x0100));
- const U16 KEY_PUB_VOLDOWN = (~(0x0200));
- //(~(0x0400));
- //(~(0x0800));
- const U16 KEY_PUB_3 = (~(0x1000));
- const U16 KEY_PUB_6 = (~(0x2000));
- const U16 KEY_PUB_9 = (~(0x4000));
- const U16 KEY_PUB_WELL = (~(0x8000));
- const U16 KEY_PUB_CAMERA = (~(0x0001));
- //(~(0x0002));
- //(~(0x0004));
- //(~(0x0008));
- //(~(0x0010));
- //(~(0x0020));
- //(~(0x0040));
- //(~(0x0080));
- //(~(0x0100));
- const U16 KEY_PUB_ESC = (~(0x0200));
- const U32 REGISTER_PUB_LSK = KEY_REGISTER_LOW;
- const U32 REGISTER_LEFT = KEY_REGISTER_LOW;
- const U32 REGISTER_UP = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_RSK = KEY_REGISTER_LOW;
- //
- //
- //
- const U32 REGISTER_PUB_CALL = KEY_REGISTER_LOW;
- const U32 REGISTER_DOWN = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_OK = KEY_REGISTER_LOW;
- const U32 REGISTER_RIGHT = KEY_REGISTER_LOW;
- //
- //
- //
- const U32 REGISTER_PUB_1 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_4 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_7 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_STAR = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_VOLUP = KEY_REGISTER_MID;
- //
- //
- const U32 REGISTER_PUB_2 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_5 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_8 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_0 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_VOLDOWN = KEY_REGISTER_MID;
- //
- //
- const U32 REGISTER_PUB_3 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_6 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_9 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_WELL = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_CAMERA = KEY_REGISTER_HIG;
- //
- //
- //
- //
- //
- //
- //
- //
- const U32 REGISTER_PUB_ESC = KEY_REGISTER_HIG;
- #elif defined(__S03_QVGA__)
- const U16 KEY_PUB_1 = (~(0x0001));
- const U16 KEY_PUB_2 = (~(0x0002));
- const U16 KEY_PUB_3 = (~(0x0004));
- const U16 KEY_PUB_4 = (~(0x0008));
- const U16 KEY_PUB_VOLUP = (~(0x0010));
- //(~(0x0020));
- //(~(0x0040));
- const U16 KEY_PUB_6 = (~(0x0080));
- const U16 KEY_PUB_7 = (~(0x0100));
- const U16 KEY_PUB_8 = (~(0x0200));
- const U16 KEY_PUB_9 = (~(0x0400));
- const U16 KEY_PUB_VOLDOWN = (~(0x0800));
- //(~(0x1000));
- //(~(0x2000));
- const U16 KEY_PUB_STAR = (~(0x4000));
- const U16 KEY_PUB_0 = (~(0x8000));
- const U16 KEY_PUB_WELL = (~(0x0001));
- const U16 KEY_PUB_5 = (~(0x0002));
- const U16 KEY_PUB_CAMERA = (~(0x0004));
- //(~(0x0008));
- //(~(0x0010));
- const U16 KEY_UP = (~(0x0020));
- const U16 KEY_DOWN = (~(0x0040));
- const U16 KEY_LEFT = (~(0x0080));
- const U16 KEY_RIGHT = (~(0x0100));
- //(~(0x0200));
- //(~(0x0400));
- //(~(0x0800));
- const U16 KEY_PUB_OK = (~(0x1000));
- const U16 KEY_PUB_LSK = (~(0x2000));
- const U16 KEY_PUB_RSK = (~(0x4000));
- //(~(0x8000));
- //(~(0x0001));
- //(~(0x0002));
- //(~(0x0004));
- //(~(0x0008));
- const U16 KEY_PUB_CALL = (~(0x0010));
- //(~(0x0020));
- //(~(0x0040));
- //(~(0x0080));
- //(~(0x0100));
- const U16 KEY_PUB_ESC = (~(0x0200));
- const U32 REGISTER_PUB_1 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_2 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_3 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_4 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_VOLUP = KEY_REGISTER_LOW;
- //
- //
- const U32 REGISTER_PUB_6 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_7 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_8 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_9 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_VOLDOWN = KEY_REGISTER_LOW;
- //
- //
- const U32 REGISTER_PUB_STAR = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_0 = KEY_REGISTER_LOW;
- const U32 REGISTER_PUB_WELL = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_5 = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_CAMERA = KEY_REGISTER_MID;
- //
- //
- const U32 REGISTER_UP = KEY_REGISTER_MID;
- const U32 REGISTER_DOWN = KEY_REGISTER_MID;
- const U32 REGISTER_LEFT = KEY_REGISTER_MID;
- const U32 REGISTER_RIGHT = KEY_REGISTER_MID;
- //
- //
- //
- const U32 REGISTER_PUB_OK = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_LSK = KEY_REGISTER_MID;
- const U32 REGISTER_PUB_RSK = KEY_REGISTER_MID;
- //
- //
- //
- //
- //
- const U32 REGISTER_PUB_CALL = KEY_REGISTER_HIG;
- //
- //
- //
- //
- const U32 REGISTER_PUB_ESC = KEY_REGISTER_HIG;
- #endif
- //KP Jerry add on 2007-4-9 start
- U16 KEY_PUB_UP;
- U16 KEY_PUB_DOWN;
- U16 KEY_PUB_LEFT;
- U16 KEY_PUB_RIGHT;
- U32 REGISTER_PUB_UP;
- U32 REGISTER_PUB_DOWN;
- U32 REGISTER_PUB_LEFT;
- U32 REGISTER_PUB_RIGHT;
- //KP Jerry add on 2007-4-9 end
- void GameSimuInitSetKeyValue(U8 lcd_state)
- {
- U32 TempUp, TempDown, TempLeft, TempRight;
-
- KEY_PUB_UP = (lcd_state == 0) ? KEY_UP : KEY_LEFT;
- KEY_PUB_DOWN = (lcd_state == 0) ? KEY_DOWN : KEY_RIGHT;
- KEY_PUB_LEFT = (lcd_state == 0) ? KEY_LEFT : KEY_DOWN;
- KEY_PUB_RIGHT = (lcd_state == 0) ? KEY_RIGHT : KEY_UP;
-
- REGISTER_PUB_UP = (lcd_state == 0) ? REGISTER_UP : REGISTER_LEFT;
- REGISTER_PUB_DOWN = (lcd_state == 0) ? REGISTER_DOWN : REGISTER_RIGHT;
- REGISTER_PUB_LEFT = (lcd_state == 0) ? REGISTER_LEFT : REGISTER_DOWN;
- REGISTER_PUB_RIGHT = (lcd_state == 0) ? REGISTER_RIGHT : REGISTER_UP;
- }
- void GameSimulatorState()
- {
-
- GameSimulatorInterface_LcdRotate();
- GameSimuInitSetKeyValue(GameSimulatorInterface_GetLCDStatus());
- }
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 二、显示接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- U8 *pu8_g_lcd_buffer; // 游戏显示数据缓冲区首地址
- U32 u32_g_lcd_buflen; // 游戏显示数据缓冲区大小
- U32 u32_g_lcd_width; // 显示缓冲区宽度
- U32 u32_g_lcd_height; // 显示缓冲区高度
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 三、声音接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- U8 u8_g_sound_playflag=0; // 声音播放标志
- U8 *pu8_g_sound_bufstart; // 声音数据缓冲区首地址
- U32 u32_g_sound_bufsize; // 声音缓冲区大小
- U8 *pu8_g_sound_out_ptr; // 声音播出指针
- U8 *pu8_g_sound_in_ptr; // 声音写入指针
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 四、手柄接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- U8 *pu8_g_uart_rx_buf; // 串口接收缓冲区首地址
- U32 u32_g_uart_rx_buf_size; // 串口接收缓冲区大小
- U16 u16_g_uart_rx_in; // 串口接收缓冲区写入偏移
- U32 u32_g_uart_portx; // 手柄通讯使用的串口号
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 五、游戏文件接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- U8 *pu8_g_game_rom; // 游戏文件加载到内存的首地址
- U32 u32_g_game_file_size; // 加载游戏文件的大小
- U8 u8_g_game_type; // 游戏类型
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 六、存档提档接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- U32 *pu32_g_game_save_buf; // 游戏存档/提档内存的首地址
- U32 u32_g_game_save_buf_size; // 游戏存档/提档内存的大小
- U32 u32_g_game_save_status; // 游戏存档/提档状态字
- void bra_view_create_view(void)
- {
- }
- void bra_send_request(char *mychar)
- {
- }
- void GameSimuSetKeyValue1ByLongPress(void)
- {
- game_simu_long_key_press |= 0x01;
- }
- void GameSimuSetKeyValue2ByLongPress(void)
- {
- game_simu_long_key_press |= 0x02;
- }
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 一、按键接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- //==========================================================================================//
- // 函 数 名: GameSimuKeyValue //
- // 入 参: - //
- // 出 参: - //
- // 返 回 值: - //
- // 功 能: 模拟向u32_g_keypad_value变量中配置手机按键 //
- // 作 者: 纪诚 //
- //==========================================================================================//
- void GameSimuKeyValue(void)
- {
- u32_g_keypad_value = 0;
- //debug_uart_output_data("nu32_g_keypad_value = %d n", u32_g_keypad_value);
- if(!(DRV_Reg32(REGISTER_PUB_UP)&(~KEY_PUB_UP)))
- u32_g_keypad_value |= 0x0001;
- if(!(DRV_Reg32(REGISTER_PUB_DOWN)&(~KEY_PUB_DOWN)))
- u32_g_keypad_value |= 0x0002;
- if(!(DRV_Reg32(REGISTER_PUB_LEFT)&(~KEY_PUB_LEFT)))
- u32_g_keypad_value |= 0x0004;
- if(!(DRV_Reg32(REGISTER_PUB_RIGHT)&(~KEY_PUB_RIGHT)))
- u32_g_keypad_value |= 0x0008;
- if(!(DRV_Reg32(REGISTER_PUB_5)&(~KEY_PUB_5)))//A
- u32_g_keypad_value |= 0x0010;
- if(!(DRV_Reg32(REGISTER_PUB_6)&(~KEY_PUB_6)))//B
- u32_g_keypad_value |= 0x0020;
- if(!(DRV_Reg32(REGISTER_PUB_8)&(~KEY_PUB_8)))//X
- u32_g_keypad_value |= 0x0040;
- if(!(DRV_Reg32(REGISTER_PUB_9)&(~KEY_PUB_9)))//Y
- u32_g_keypad_value |= 0x0080;
- if( (!(DRV_Reg32(REGISTER_PUB_0)&(~KEY_PUB_0))) || (!(DRV_Reg32(REGISTER_PUB_CALL)&(~KEY_PUB_CALL))) )//SELECT
- u32_g_keypad_value |= 0x0100;
- if( (!(DRV_Reg32(REGISTER_PUB_WELL)&(~KEY_PUB_WELL))) || (!(DRV_Reg32(REGISTER_PUB_OK)&(~KEY_PUB_OK))) )//OK
- u32_g_keypad_value |= 0x0200;
- if(!(DRV_Reg32(REGISTER_PUB_2)&(~KEY_PUB_2)))//TOPL
- u32_g_keypad_value |= 0x0400;
- if(!(DRV_Reg32(REGISTER_PUB_3)&(~KEY_PUB_3)))//TOPR
- u32_g_keypad_value |= 0x0800;
- if(!(DRV_Reg32(REGISTER_PUB_RSK)&(~KEY_PUB_RSK)))//ESC
- u32_g_keypad_value |= 0x2000;
- if(!(DRV_Reg32(REGISTER_PUB_1)&(~KEY_PUB_1)))//MUTE
- u32_g_keypad_value |= 0x1000;
- if(!(DRV_Reg32(REGISTER_PUB_LSK)&(~KEY_PUB_LSK)))//MENU
- u32_g_keypad_value |= 0x4000;
- if(!(DRV_Reg32(REGISTER_PUB_VOLUP)&(~KEY_PUB_VOLUP)))//VOLUP
- {
- if (game_simu_long_key_press & 0x01)
- u32_g_keypad_value |= 0x0040; //X
- else
- u32_g_keypad_value |= 0x0010; //A
- }
- else if(game_simu_long_key_press & 0x01)
- {
- game_simu_long_key_press &= (~(0x01));
- }
-
- if(!(DRV_Reg32(REGISTER_PUB_VOLDOWN)&(~KEY_PUB_VOLDOWN)))//VOLDOWN
- {
- if (game_simu_long_key_press & 0x02)
- u32_g_keypad_value |= 0x0080; //Y
- else
- u32_g_keypad_value |= 0x0020; //B
- }
- else if(game_simu_long_key_press & 0x02)
- {
- game_simu_long_key_press &= (~(0x02));
- }
- debug_uart_output_data("nGameSimuKeyValue:u32_g_keypad_value = %x n", u32_g_keypad_value);
- }
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 二、显示接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- extern U8 gdi_base_layer_buffer_pool[];
- //==========================================================================================//
- // 函 数 名: GameSimuLcdUpdate_Init //
- // 入 参: - //
- // 出 参: - //
- // 返 回 值: - //
- // 功 能: 刷屏初始化 //
- // 作 者: 纪诚 //
- //==========================================================================================//
- void GameSimuLcdUpdate_Init(void)
- {
- pu8_g_lcd_buffer = (U8 *)gdi_base_layer_buffer_pool;
- u32_g_lcd_width = LCD_WIDTH;
- u32_g_lcd_height = LCD_HEIGHT;
- u32_g_lcd_buflen = LCD_WIDTH*LCD_HEIGHT*2;
- // 禁止LCD休眠
- TurnOnBacklight(0);
- /* avoid status bar */
- entry_full_screen();
- gdi_layer_blt_ext(GDI_LAYER_MAIN_BASE_LAYER_HANDLE, 0, 0, 0,
- #ifdef GDI_6_LAYERS
- 0, 0,
- #endif
- 0, 0, LCD_WIDTH-1, LCD_HEIGHT-1);
- lcd_power_up();
- gdi_layer_lock_frame_buffer();
- }
- //==========================================================================================//
- // 函 数 名: GameSimuLcdUpdate_Terminate //
- // 入 参: - //
- // 出 参: - //
- // 返 回 值: - //
- // 功 能: 刷屏初始化 //
- // 作 者: 纪诚 //
- //==========================================================================================//
- void GameSimuLcdUpdate_Terminate(void)
- {
- gdi_layer_unlock_frame_buffer();
- lcd_power_down();
- // 禁止LCD休眠
- TurnOffBacklight();
- }
- //==========================================================================================//
- // 函 数 名: GameSimuLcdUpdateone //
- // 入 参: - //
- // 出 参: - //
- // 返 回 值: - //
- // 功 能: 完成刷一屏的动作 //
- // 作 者: 纪诚 //
- //==========================================================================================//
- void GameSimuLcdUpdateone(void)
- {
- START_LCD_TRANSFER;
- }
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 三、声音接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- #define C16_SOUND_BUFFER_SIZE 0x10000
- U8 u8_g_sound_buffer[C16_SOUND_BUFFER_SIZE];
- //==========================================================================================//
- // 函 数 名: GameSimuAudio_Open //
- // 入 参: - //
- // 出 参: - //
- // 返 回 值: - //
- // 功 能: 打开AUDIO任务 //
- // 作 者: 纪诚 //
- //==========================================================================================//
- void GameSimuAudio_Open( void )
- {
- u8_g_sound_playflag = 1;
- pu8_g_sound_bufstart = (U8 *)u8_g_sound_buffer;
- u32_g_sound_bufsize = C16_SOUND_BUFFER_SIZE;
- pu8_g_sound_in_ptr = pu8_g_sound_out_ptr = pu8_g_sound_bufstart;
- switch(u8_g_game_type)
- {
- case GAME_SIMU_TYPE_GB:
- case GAME_SIMU_TYPE_GBC:
- mdi_audio_play_string(pu8_g_sound_bufstart, u32_g_sound_bufsize, MDI_FORMAT_PCM_16K, DEVICE_AUDIO_PLAY_INFINITE, NULL, NULL);
- break;
- case GAME_SIMU_TYPE_NES:
- mdi_audio_play_string(pu8_g_sound_bufstart, u32_g_sound_bufsize, MDI_FORMAT_PCM_8K, DEVICE_AUDIO_PLAY_INFINITE, NULL, NULL);
- break;
- default:
- break;
- }
- }
- //==========================================================================================//
- // 函 数 名: GameSimuAudio_Close //
- // 入 参: - //
- // 出 参: - //
- // 返 回 值: - //
- // 功 能: 关闭AUDIO任务 //
- // 作 者: 纪诚 //
- //==========================================================================================//
- void GameSimuAudio_Close(void)
- {
- u8_g_sound_playflag = 0;
- mdi_audio_stop_string();
- }
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 四、手柄接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- #define C32_GAME_SIMU_UART_RX_BUF_SIZE 2048
- U8 u8_game_simu_uart_rx_buf[C32_GAME_SIMU_UART_RX_BUF_SIZE];
- //==========================================================================================//
- // 函 数 名: GameSimuUartFIFO //
- // 入 参: - //
- // 出 参: - //
- // 返 回 值: - //
- // 功 能: 接收串口数据,放到串口的FIFO中 //
- // 作 者: 王险峰 //
- //==========================================================================================//
- void GameSimuUartFIFO(UART_PORT port)
- {
- U8 u8_tmp_buf[100];
- U8 u8_status = 0;
- U32 u32_read_length = 0;
- U16 u16_i = 0;
- U8 *pu8_buf_ptr;
- U8 *pu8_buf_end_ptr;
- // 从串口获得数据
- u32_read_length = UART_GetBytes(u32_g_uart_portx, u8_tmp_buf, 100, &u8_status, MOD_L4C);
- // 将数据写到 FIFO 中
- pu8_buf_ptr = pu8_g_uart_rx_buf + u16_g_uart_rx_in;
- pu8_buf_end_ptr = pu8_g_uart_rx_buf + u32_g_uart_rx_buf_size;
- for( u16_i = 0 ; u16_i < u32_read_length ; u16_i ++ )
- {
- *pu8_buf_ptr++ = u8_tmp_buf[u16_i];
- if( pu8_buf_ptr == pu8_buf_end_ptr ) pu8_buf_ptr = pu8_g_uart_rx_buf;
- }
- // 调整写入指针
- u16_g_uart_rx_in = (pu8_buf_ptr-pu8_g_uart_rx_buf);
- }
- //==========================================================================================//
- // 函 数 名: GameSimeUartInit //
- // 入 参: - //
- // 出 参: - //
- // 返 回 值: - //
- // 功 能: 初始化串口相关变量, 并注册串口接收CALLBACK函数 //
- // 作 者: 王险峰 //
- //==========================================================================================//
- extern kal_bool UART_Open(UART_PORT port, module_type owner);
- extern void UART_Close(UART_PORT port, module_type ownerid);
- void GameSimeUartInit(void)
- {
- // 设置串口接口变量初值
- pu8_g_uart_rx_buf = u8_game_simu_uart_rx_buf;
- u32_g_uart_rx_buf_size = C32_GAME_SIMU_UART_RX_BUF_SIZE;
- u16_g_uart_rx_in = 0;
- // 设置使用的串口
- u32_g_uart_portx = uart_port1;
- UART_Close(u32_g_uart_portx, MOD_L4C);
- UART_Open(u32_g_uart_portx, MOD_L4C);
- // 串口接收缓冲区清0
- memset( u8_game_simu_uart_rx_buf, 0, C32_GAME_SIMU_UART_RX_BUF_SIZE );
- // 设置串口接收回调函数
- if (MMIUSB_GET_FLAG(MMIUSB_MASK_IS_CONNECT) != MMI_TRUE)
- UART_Register_RX_cb(u32_g_uart_portx, MOD_L4C, GameSimuUartFIFO);
- }
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 五、游戏文件接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- //#define C32_GAME_ROM_BUFFER_SIZE (0X400000-(0x0030d000+0x0002a024)) // 游戏ROM BUFFER大小
- #define C32_GAME_ROM_BUFFER_SIZE (1024*1024) // 游戏ROM BUFFER大小
- //#define C32_GAME_ROM_BUFFER_SIZE (300*1024*1) // 游戏ROM BUFFER大小
- #pragma arm section zidata = "game_simu_rom"
- __align(4)
- U8 u8_g_game_rom[C32_GAME_ROM_BUFFER_SIZE];
- #pragma arm section zidata
- #define MAX_FILE_NAME_WIDTH 128
- //U16 u16_g_game_file_name[]=L"e:\Game\Super Gryzor.nes";
- //U16 u16_g_game_file_name[]=L"e:\Game\super mario bros.gbc";
- U16 file_path_buf[(FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH];
- // U16 u16_g_game_file_name[]=L"c:\test.nes";
- //==========================================================================================//
- // 函 数 名: GameSimuLoadFileToRam //
- // 入 参: - //
- // 出 参: - //
- // 返 回 值: 0-游戏文件长度大于BUFFER长度不能玩 //
- // 1-游戏可以正常运行下去 //
- // 功 能: 打开游戏文件读文件并判断长度 //
- // 作 者: 纪诚 //
- //==========================================================================================//
- BOOL GameSimuLoadFileToRam( void )
- {
- U32 u32_read_size;
- U32 u32_file_size;
- FS_HANDLE fh_gbc_rom_file;
- // ROM指针初始化
- pu8_g_game_rom = (kal_uint8 *)u8_g_game_rom;
- // 读出ROM文件
- //if( (fh_gbc_rom_file = FS_Open( u16_g_game_file_name, FS_READ_ONLY)) <0 )
- if( (fh_gbc_rom_file = FS_Open( file_path_buf, FS_READ_ONLY)) <0 )
- {
- debug_uart_output_data("n file can't open!");
- return (0);
- }
- FS_GetFileSize(fh_gbc_rom_file, &u32_file_size);
- if(u32_file_size <= C32_GAME_ROM_BUFFER_SIZE)
- {
- FS_Read(fh_gbc_rom_file, pu8_g_game_rom, u32_file_size, (UINT*)&u32_g_game_file_size );
- FS_Close(fh_gbc_rom_file);
- return (1);
- }
- else
- {
- FS_Close(fh_gbc_rom_file);
- debug_uart_output_data("n file too big!");
- return (0);
- }
- }
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 六、存档提档接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- // =============================================================================
- // 功 能: 游戏存档初始化
- // 作 者: 纪诚
- // =============================================================================
- void GameSimuSaveInit(void)
- {
- pu32_g_game_save_buf = (U32 *)u8_g_sound_buffer;
- u32_g_game_save_buf_size = (U32)C16_SOUND_BUFFER_SIZE;
- }
- // =============================================================================
- // 功 能: 获得游戏存档文件名
- // 入 参: u16_x_game_file 当前游戏文件
- // u16_x_save_suffix存档文件后缀名
- // 出 参: u16_x_game_file 当前游戏文件
- // 返回值: -
- // 作 者: 徐 杰
- // =============================================================================
- void GameSimuSaveFileName ( U16 *u16_x_game_file, U16 *u16_x_save_suffix, U16 *u16_x_save_file)
- {
- U16 u16_char;
- memcpy ( (S8*)u16_x_save_file, (S8*)u16_x_game_file, MAX_FILE_NAME_WIDTH );
- // 指向后缀处
- while ( *u16_x_save_file )
- u16_x_save_file ++;
- while ( ( *u16_x_save_file ) != 0x2e )
- u16_x_save_file --;
- u16_x_save_file ++;
- // 修改后缀
- u16_char = *u16_x_save_suffix ++;
- while ( u16_char )
- {
- *u16_x_save_file ++ = u16_char;
- u16_char = *u16_x_save_suffix ++;
- }
- *u16_x_save_file = u16_char;
- }
- // =============================================================================
- // 功 能: 存档Buf到文件
- // 入 参: u8_x_buf 存档Buf地址
- // u32_x_buf_size 存档Buf大小
- // u16_x_game_file 当前游戏文件
- // u16_x_save_suffix存档文件后缀名
- // 返回值: 0 失败
- // 1 成功
- // 作 者: 徐 杰
- // =============================================================================
- U8 GameSimuSaveFile ( U8 *u8_x_buf, U32 u32_x_buf_size, U16 *u16_x_game_file, U8 u8_x_game_type )
- {
- U16 u16_save_file [ MAX_FILE_NAME_WIDTH / 2 ];
- U32 u32_write_size;
- FS_HANDLE fh_save_file;
- switch(u8_x_game_type)
- {
- case GAME_SIMU_TYPE_GB:
- // 获得存档文件名
- GameSimuSaveFileName ( u16_x_game_file, L"gb0", u16_save_file);
- break;
- case GAME_SIMU_TYPE_GBC:
- // 获得存档文件名
- GameSimuSaveFileName ( u16_x_game_file, L"gf0", u16_save_file);
- break;
- case GAME_SIMU_TYPE_NES:
- // 获得存档文件名
- GameSimuSaveFileName ( u16_x_game_file, L"nf0", u16_save_file);
- break;
- default:
- break;
- }
- fh_save_file = FS_Open ( u16_save_file, FS_CREATE );
- if ( fh_save_file == NULL)
- return 0;
- FS_Write ( fh_save_file, u8_x_buf, u32_x_buf_size, (UINT*)&u32_write_size );
- FS_SetAttributes(u16_save_file, FS_ATTR_HIDDEN); //KP Jerry add on 2007-4-14
- FS_Close ( fh_save_file );
- if ( u32_x_buf_size != u32_write_size)
- return 0;
- else
- return 1;
- }
- // =============================================================================
- // 功 能: 从文件读取存档Buf
- // 入 参: u32_x_buf_size 存档Buf大小
- // u16_x_game_file 当前游戏文件
- // u16_x_save_suffix存档文件后缀名
- // 出 参: u8_x_buf 存档Buf地址
- // 返回值: 0 失败
- // 1 成功
- // 作 者: 徐 杰
- // =============================================================================
- U8 GameSimuLoadFile ( U8 *u8_x_buf, U32 u32_x_buf_size, U16 *u16_x_game_file, U8 u8_x_game_type )
- {
- U16 u16_save_file [ MAX_FILE_NAME_WIDTH / 2 ];
- U32 u32_read_size;
- FS_HANDLE fh_save_file;
- switch(u8_x_game_type)
- {
- case GAME_SIMU_TYPE_GB:
- // 获得存档文件名
- GameSimuSaveFileName ( u16_x_game_file, L"gb0", u16_save_file);
- break;
- case GAME_SIMU_TYPE_GBC:
- // 获得存档文件名
- GameSimuSaveFileName ( u16_x_game_file, L"gf0", u16_save_file);
- break;
- case GAME_SIMU_TYPE_NES:
- // 获得存档文件名
- GameSimuSaveFileName ( u16_x_game_file, L"nf0", u16_save_file);
- break;
- default:
- break;
- }
- fh_save_file = FS_Open ( u16_save_file, FS_READ_ONLY );
- if ( fh_save_file == NULL)
- return 0;
- FS_Read ( fh_save_file, u8_x_buf, u32_x_buf_size, (UINT*)&u32_read_size );
- FS_Close ( fh_save_file );
- if ( u32_x_buf_size != u32_read_size)
- return 0;
- else
- return 1;
- }
- //======================================================================================================================//
- //======================================================================================================================//
- //=========================================== 七、窗口接口 ======================================//
- //======================================================================================================================//
- //======================================================================================================================//
- //==========================================================================================//
- // 函 数 mmi_game_simu_pause_msg_hdlr //
- // 入 参:- //
- // 出 参:- //
- // 返 回 值:- //
- // 功 能:在游戏运行期间, 如果有会导致切换出游戏窗口的消息到来的时候, 请使用这个函数//
- // 暂停游戏, 再处理完这个消息后, 会自动继续游戏. //
- // 作 者:王险峰 //
- //==========================================================================================//
- void mmi_game_simu_pause_msg_hdlr(void)
- {
- debug_uart_output_data("n PAUSE");
- // 游戏暂停
- ClearProtocolEventHandler(MSG_ID_CUSTOM2_CUSTOM1);
- GameSimulatorInterface_Pause();
- // 恢复LCD刷新设置
- GameSimuLcdUpdate_Terminate();
- /* Don't store temp user information */
- //game_simu_settings.bLCDState = GameSimulatorInterface_GetLCDStatus();
- //game_simu_settings.bVolu = u8_g_sound_playflag;
- game_simu_play_audio_poweron = 0;
- //mmi_gamesimu_store_setting();
- // 关闭声音任务
- GameSimuAudio_Close();
- //
- UART_dafault_rx_cb(u32_g_uart_portx);
- }
- //==========================================================================================//
- // 函 数 名:mmi_game_simu_exit_msg_hdlr //
- // 入 参:- //
- // 出 参:- //
- // 返 回 值:- //
- // 功 能:在游戏运行期间, 如果有希望终止游戏的消息到来的时候, 请使用这个函数退出游戏//
- // 作 者:王险峰 //
- //==========================================================================================//
- static U8 mmi_game_simu_exit_msg_hdlr(void *inMsg)
- {
- debug_uart_output_data("n STOP");
- // 游戏模拟器终止
- GameSimulatorInterface_Terminate();
- // debug_uart_output_data("n first byte = %x",*u8_g_game_rom);
- // debug_uart_output_data("n first byte = %x",*(u8_g_game_rom+1024*1024-4));
- memset(u8_g_game_rom,0,C32_GAME_ROM_BUFFER_SIZE);
- // debug_uart_output_data("n first byte = %x",*u8_g_game_rom);
- // debug_uart_output_data("n first byte = %x",*(u8_g_game_rom+1024*1024-4));
-
- }
- //==========================================================================================//
- // 函 数 名: SendMsgToMMI //
- // 入 参: u32_x_msg_id 需要发送的消息ID //
- // 出 参: - //
- // 返 回 值: - //
- // 功 能: 给MMI消息队列发消息 //
- // 作 者: 王险峰 //
- //==========================================================================================//
- void SendMsgToMMI(U32 u32_x_msg_id)
- {
- ilm_struct *send_ilm;
- send_ilm = allocate_ilm(MOD_MMI);
- send_ilm->src_mod_id = MOD_MMI;
- send_ilm->dest_mod_id = MOD_MMI;
- send_ilm->msg_id = u32_x_msg_id;
- msg_send_ext_queue(send_ilm);
- }
- static U8 mmi_gamesimu_post_interrupt_hdlr(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetInterruptPopupDisplay(POPUP_ALL_ON);
- return FALSE;
- }
- static U8 mmi_gamesimu_sms_interrupt_hdlr(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetInterruptPopupDisplay(POPUP_ALL_OFF);
- return FALSE;
- }
- //void key_scan();//测试键值属于那个寄存器,通过trace打印出来
- //==========================================================================================//
- // 函 数 名: GameSimuRun //
- // 入 参: - //
- // 出 参: - //
- // 返 回 值: - //
- // 功 能: 处理游戏RUN消息,运行一帧游戏 //
- // 作 者: 王险峰 //
- //==========================================================================================//
- void GameSimuRun(void)
- {
- U32 u32_game_run_return_flag;
- //key_scan();
- // 模拟获得键值
- GameSimuKeyValue();
- // 仿真器运行一次
- u32_game_run_return_flag = GameSimulatorInterface_Run();
- // 刷屏
- if((u32_game_run_return_flag&GAME_SIMU_UPDATE_BIT))
- GameSimuLcdUpdateone();
- // 继续运行
- if((u32_game_run_return_flag&GAME_SIMU_RUNING_BIT))
- SendMsgToMMI(MSG_ID_CUSTOM2_CUSTOM1);
- // 停止运行
- if(!(u32_game_run_return_flag&GAME_SIMU_RUNING_BIT))
- GoBackHistory();
- // 存档
- if((u32_g_game_save_status&GAME_SIMU_SAVE_REQ_BIT))
- {
- //GameSimuSaveFile((U8 *)pu32_g_game_save_buf,u32_g_game_save_buf_size,u16_g_game_file_name,u8_g_game_type);
- GameSimuSaveFile((U8 *)pu32_g_game_save_buf,u32_g_game_save_buf_size,file_path_buf,u8_g_game_type);
- u32_g_game_save_status = GAME_SIMU_SAVE_RSP_BIT;
- }
- // 提档
- if((u32_g_game_save_status&GAME_SIMU_LOAD_REQ_BIT))
- {
- //if(GameSimuLoadFile((U8 *)pu32_g_game_save_buf,u32_g_game_save_buf_size,u16_g_game_file_name,u8_g_game_type))
- if(GameSimuLoadFile((U8 *)pu32_g_game_save_buf,u32_g_game_save_buf_size,file_path_buf,u8_g_game_type))
- u32_g_game_save_status = GAME_SIMU_LOAD_RSP_BIT;
- }
- }
- //==========================================================================================//
- // 函 数 名: EntryGameSimu //
- // 入 参: - //
- // 出 参: - //
- // 返 回 值: - //
- // 功 能: 游戏窗口,处理游戏于MMI消息的交互 //
- // 作 者: 王险峰 //
- //==========================================================================================//
- void EntryGameSimu(void)
- {
- ilm_struct *send_ilm;
- PsFuncPtr pf_game_simu_run;
- debug_uart_output_data(" entry EntryGameSimu n");
- GameSimuInitSetKeyValue(game_simu_settings.bLCDState);
- if (GameSimulatorInterface_GetLCDStatus() != game_simu_settings.bLCDState)
- {
- GameSimulatorInterface_LcdRotate();
- }
- // 注册游戏窗口ID号、和重入和退出的函数操作。
- EntryNewScreen(SCR_ID_GAMESIMU_RUN, mmi_game_simu_pause_msg_hdlr, EntryGameSimu, NULL);
- SetDelScrnIDCallbackHandler(SCR_ID_GAMESIMU_RUN, mmi_game_simu_exit_msg_hdlr);
- pf_game_simu_run = (PsFuncPtr)GameSimuRun;
- // SMS短消息处理
- SetInterruptEventHandler(
- mmi_gamesimu_sms_interrupt_hdlr,
- mmi_gamesimu_post_interrupt_hdlr,
- PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND );
- SetInterruptEventHandler(
- mmi_gamesimu_sms_interrupt_hdlr,
- mmi_gamesimu_post_interrupt_hdlr,
- PRT_MSG_ID_MMI_SMS_STATUS_REPORT_IND);
- SetInterruptEventHandler(
- mmi_gamesimu_sms_interrupt_hdlr,
- mmi_gamesimu_post_interrupt_hdlr,
- PRT_MSG_ID_MMI_SMS_MSG_WAITING_IND );
- // T卡插拔处理
- SetInterruptEventHandler(
- mmi_gamesimu_sms_interrupt_hdlr,
- mmi_gamesimu_post_interrupt_hdlr,
- MSG_ID_FMT_MMI_CARD_PLUG_IN_IND );
- SetInterruptEventHandler(
- mmi_gamesimu_sms_interrupt_hdlr,
- mmi_gamesimu_post_interrupt_hdlr,
- MSG_ID_FMT_MMI_CARD_PLUG_OUT_IND );
- // 注册游戏消息处理函数
- SetProtocolEventHandler(pf_game_simu_run, MSG_ID_CUSTOM2_CUSTOM1);
- //u8_g_game_type = GAME_SIMU_TYPE_GBC;
- //u8_g_game_type = GAME_SIMU_TYPE_NES;
- // 显示初始化
- GameSimuLcdUpdate_Init();
- // 游戏ROM初始化
- GameSimuLoadFileToRam();
- // 声音初始化
- GameSimuAudio_Open();
- GameSimulatorInterface_SetSound(game_simu_settings.bVolu);
- // 初始化串口, 并注册串口接收CALLBACK函数
- GameSimeUartInit();
- // 存档提档初始化
- GameSimuSaveInit();
- // 清除游戏运行中按键定义的HANDLER的处理
- ClearAllKeyHandler();
- // 注册音量调节按键HANDLER处理
- //SetKeyHandler(mmi_gfx_volume_up, KEY_VOL_UP, KEY_EVENT_DOWN);
- //SetKeyHandler(mmi_gfx_volume_down, KEY_VOL_DOWN, KEY_EVENT_DOWN);
- SetKeyHandler(mmi_gfx_volume_up, KEY_2, KEY_EVENT_DOWN);
- SetKeyHandler(mmi_gfx_volume_down, KEY_3, KEY_EVENT_DOWN);
-
- SetKeyHandler(GameSimuSetKeyValue1ByLongPress, KEY_VOL_UP, KEY_EVENT_LONG_PRESS);
- SetKeyHandler(GameSimuSetKeyValue2ByLongPress, KEY_VOL_DOWN, KEY_EVENT_LONG_PRESS);
- // ferz add on 2007-03-30
- SetKeyHandler(GameSimulatorState, KEY_STAR, KEY_EVENT_UP);
- SetKeyHandler(GameSimulatorState, KEY_CAMERA, KEY_EVENT_UP);
- // ferz add end
-
- // 游戏模拟器初始化
- {
- U32 initValue = GameSimulatorInterface_Init();
- debug_uart_output_data(" initValue = %d ", initValue);
- if (initValue != GAME_SIMU_INIT_OK)
- {
- GoBackHistory();
- if (initValue == GAME_SIMU_INIT_PARA_ERR)
- DisplayPopup((PU8) GetString(STR_ID_GAME_SIMU_INTERFACE_ERROR), IMG_GLOBAL_INFO, 1, 2000, MESSAGE_TONE);
- else if (initValue == GAME_SIMU_INIT_FILE_ERR)
- DisplayPopup((PU8) GetString(STR_ID_GAME_FILE_ERROR), IMG_GLOBAL_INFO, 1, 2000, MESSAGE_TONE);
- else if (initValue == GAME_SIMU_INIT_NOT_SUPPORT)
- DisplayPopup((PU8) GetString(STR_ID_GAME_FILE_TYPE_ERROR), IMG_GLOBAL_INFO, 1, 2000, MESSAGE_TONE);
- }
- else SendMsgToMMI(MSG_ID_CUSTOM2_CUSTOM1);
- }
- #if 0
- if( GameSimulatorInterface_Init() != GAME_SIMU_INIT_OK)
- {
- GoBackHistory();
- }
- #endif
- // 发送游戏模拟器启动消息
- //else SendMsgToMMI(MSG_ID_CUSTOM2_CUSTOM1);
- }
- void InitGameSimuEntryListApp()
- {
- SetHiliteHandler(MENU_ID_GAME_RFS_OPTION_LIMITED, mmi_game_simu_highlight_refresh_game_list);
- SetHiliteHandler(MENU_ID_GAME_SETTINGS_LIMITED, mmi_game_simu_highlight_game_data_settings);
- SetHiliteHandler(MENU_ID_GAME_LIST_PLAY, mmi_game_simu_highlight_play);
- SetHiliteHandler(MENU_ID_GAME_LIST_RFS_OPTION, mmi_game_simu_highlight_refresh_game_list);
- SetHiliteHandler(MENU_ID_GAME_LIST_SETTINGS, mmi_game_simu_highlight_game_data_settings);
- // SetHiliteHandler(MENU_ID_GAME_SIMU_HELP, mmi_gamesimu_highlight_help);
- //SetHiliteHandler(MENU_ID_GAME_LIST_INFO, mmi_game_simu_higlight_game_info);
- //SetHiliteHandler(MENU_ID_GAME_LIST_DELETE, mmi_game_simu_highlight_delete_game);
- //SetHiliteHandler(MENU_ID_GAME_LIST_DELETE_ALL, mmi_game_simu_highlight_delete_all);
- // SetHiliteHandler(MENU_ID_GAME_LIST_HELP, mmi_game_simu_highlight_help);
- game_simu_frm_init();
- }
- ///////////////////////////////////////
- /*****************************************************************************
- * FUNCTION
- * ebr_show_limit_book_shelf_option
- * DESCRIPTION
- * Options for Limited Book Shelf
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void game_simu_show_limit_option(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- U16 nNumofItem;
- U16 nStrItemList[MAX_SUB_MENUS];
- U16 nImgIltemList[MAX_SUB_MENUS];
- U8 *hintList[MAX_SUB_MENUS];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_GAMESIMU_OPTION, NULL, game_simu_show_limit_option, NULL);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_GAMESIMU_OPTION);
-
- nNumofItem = GetNumOfChild(MENU_ID_GAME_LIMITED_GAME_LIST_OPTION);
- GetSequenceStringIds(MENU_ID_GAME_LIMITED_GAME_LIST_OPTION, nStrItemList);
- GetSequenceImageIds(MENU_ID_GAME_LIMITED_GAME_LIST_OPTION, nImgIltemList);
- SetParentHandler(MENU_ID_GAME_LIMITED_GAME_LIST_OPTION);
- debug_uart_output_data("n nNumofItem = %d", nNumofItem);
- /* Construct List To Show Hint */
- ConstructHintsList(MENU_ID_GAME_LIMITED_GAME_LIST_OPTION, hintList);
- RegisterHighlightHandler(ExecuteCurrHiliteHandler);
- ShowCategory52Screen(
- STR_GLOBAL_OPTIONS,
- //GetRootTitleIcon(MAIN_MENU_EBOOK_MENUID),
- MAIN_MENU_TITLE_FUNANDGAMES_ICON,
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- nNumofItem,
- nStrItemList,
- (U16*) gIndexIconsImageList,
- hintList,
- 0,
- 0,
- guiBuffer);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- void game_list_exit_settings(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- history Scr;
- S16 nHistory = 0;
- U16 size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- CloseCategory57Screen();
- /* Scr.scrnID = GAME_LIST_SETTINGS_SCREEN_ID;
- CloseCategory57Screen();
- Scr.entryFuncPtr = game_list_entry_settings;
- pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) & nHistory);
- GetCategoryHistory(Scr.guiBuffer);
- size = (U16) GetCategory57DataSize();
- GetCategory57Data((U8*) Scr.inputBuffer);
- AddNHistory(Scr, size);*/
- }
- void game_list_frm_get_default_settings_value(void)
- {
- S16 error;
-
- ReadValue(NVRAM_GAME_LIST_MEMORY_TYPE_ID, &g_game_simu_set_cntx.inlineHighligtItemSelectMemory, DS_BYTE, &error);
- // ReadValue(NVRAM_GAME_LIST_AUTO_GEN_ID, &g_game_simu_set_cntx.inlineHighligtItemSelectAutoGen, DS_BYTE, &error);
- return;
- }
- void game_simu_fill_settings_inline_edit_struct(void *pInlineStruct)
- {
- S16 i = 0;
- U8 status = 0;
- InlineItem *InlineStruct = (InlineItem*) pInlineStruct;
- g_game_simu_app_cntx_p->game_list_settings_memory_type[0] = (U8*) GetString(STR_ID_GAME_SIMU_STORAGE_PHONE);
- g_game_simu_app_cntx_p->game_list_settings_memory_type[1] = (U8*) GetString(STR_ID_GAME_SIMU_STORAGE_CARD);
- // g_game_simu_app_cntx_p->game_list_settings_auto_gen[0] = (U8*) GetString(STR_ID_GAME_SIMU_UPDATE_YES);
- // g_game_simu_app_cntx_p->game_list_settings_auto_gen[1] = (U8*) GetString(STR_ID_GAME_SIMU_UPDATE_NO);
- SetInlineItemActivation(&InlineStruct[0], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
- SetInlineItemCaption(&InlineStruct[0], (PU8) (U8*) GetString(STR_ID_GAME_SIMU_STORAGE));
- // SetInlineItemActivation(&InlineStruct[2], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
- // SetInlineItemCaption(&InlineStruct[2], (PU8) (U8*) GetString(STR_ID_GAME_SIMU_UPDATE_QUE));
- SetInlineItemActivation(&InlineStruct[1], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
- SetInlineItemSelect(
- &InlineStruct[1],
- 2,
- g_game_simu_app_cntx_p->game_list_settings_memory_type,
- (S32*) &(g_game_simu_set_cntx.inlineHighligtItemSelectMemory) /* CurrSelect */ );
- // SetInlineItemActivation(&InlineStruct[3], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
- // SetInlineItemSelect(
- // &InlineStruct[3],
- // 2,
- // g_game_simu_app_cntx_p->game_list_settings_auto_gen,
- // (S32*) &(g_game_simu_set_cntx.inlineHighligtItemSelectAutoGen) /* CurrSelect */ );
- }
- MMI_BOOL mmi_game_list_is_memory_type_changed(S8 memoryType)
- {
- // if (g_curr_book_cntx_p->g_nfo_book_struct.memory_type == memoryType)
- {
- return MMI_FALSE;
- }
- // else
- {
- // return MMI_TRUE;
- }
- }
- void game_simu_frm_set_settings_and_save_in_nvram(void)
- {
- S16 error;
- // WriteValue(NVRAM_GAME_LIST_AUTO_GEN_ID, &g_game_simu_set_cntx.inlineHighligtItemSelectAutoGen, DS_BYTE, &error);
- WriteValue(NVRAM_GAME_LIST_MEMORY_TYPE_ID, &(g_game_simu_set_cntx.inlineHighligtItemSelectMemory), DS_BYTE, &error);
- }
- void game_simu_entry_settings_done_hndlr(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- game_simu_frm_set_settings_and_save_in_nvram();
- // DeleteUptoScrID(GAME_LIST_SETTINGS_SCREEN_ID);
- DeleteUptoScrID(SCR_FMGR_EXPLORER);
- IsBackHistory = MMI_TRUE;
- DisplayPopupCallBack(
- (PU8) GetString(STR_GLOBAL_DONE),
- IMG_GLOBAL_ACTIVATED,
- 1,
- UI_POPUP_NOTIFYDURATION_TIME,
- SUCCESS_TONE,
- mmi_entry_game_list_screen);
- }
- void game_list_settings_confirm_pop_up(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- DisplayConfirm(
- STR_GLOBAL_YES,
- IMG_GLOBAL_YES,
- STR_GLOBAL_NO,
- IMG_GLOBAL_NO,
- get_string(STR_GLOBAL_SAVE),
- IMG_GLOBAL_QUESTION,
- WARNING_TONE);
- SetLeftSoftkeyFunction(game_simu_entry_settings_done_hndlr, KEY_EVENT_UP);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- }
- void game_list_entry_settings(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer = NULL;
- U8 status;
- U8 *inputBuffer;
- U16 nNumofItem = 2; /* Stores no of children in the submenu */
- U16 inputBufferSize;
- U16 gIndexIconsImageList_local[] =
- {
- IMG_GLOBAL_L1,
- 0 //,
- // IMG_GLOBAL_L2,
- // 0
- };
-
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_fmgr_get_exist_storage_inline_list(NULL, &status, NULL, NULL);
- EntryNewScreen(GAME_LIST_SETTINGS_SCREEN_ID, game_list_exit_settings, game_list_entry_settings, NULL);
- InitializeCategory57Screen();
-
- guiBuffer = GetCurrGuiBuffer(GAME_LIST_SETTINGS_SCREEN_ID);
- inputBuffer = GetCurrNInputBuffer(GAME_LIST_SETTINGS_SCREEN_ID, &inputBufferSize); /* added for inline edit history */
- if (inputBuffer != NULL)
- {
- SetCategory57Data(wgui_inline_items, nNumofItem, inputBuffer);
- }
- else
- {
- //ClearHighlightHandler();
- /* Get the Default value from NVRAM */
- game_list_frm_get_default_settings_value();
- }
- game_simu_fill_settings_inline_edit_struct((void*)&wgui_inline_items);
- //RegisterHighlightHandler(NULL);
- if (mmi_game_list_is_memory_type_changed(memory_type_selected) && GetInlineDoneFlag(guiBuffer) == 0)
- {
- SetInlineDoneFlag(guiBuffer);
- }
-
- ShowCategory57Screen(
- STR_GLOBAL_SAVE,
- //GetRootTitleIcon(MAIN_MENU_EXTRA_MENUID),
- MAIN_MENU_TITLE_FUNANDGAMES_ICON,
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_DONE,
- IMG_GLOBAL_BACK,
- nNumofItem,
- (U16*) gIndexIconsImageList_local,
- wgui_inline_items,
- 0,
- guiBuffer);
-
- /* Register function for right soft key */
- SetCategory57RightSoftkeyFunctions(game_list_settings_confirm_pop_up, GoBackHistory);
- }
- S8 *game_frm_get_file_path(S8 memory_type_selected, game_list_frm_search_type_enum search_type_path)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 file_path_in_ascii[MAX_DWNL_GAME_PATH_LEN];
- static S8 file_path[MAX_DWNL_GAME_PATH_LEN * ENCODING_LENGTH];
- static game_list_frm_search_type_enum prev_search_type_path = GAME_FRM_SEARCH_MAX;
- static S8 prev_memory_type_selected = 0;
- S8 div_path;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- // if (prev_memory_type_selected == memory_type_selected && prev_search_type_path == search_type_path)
- // {
- // return file_path;
- // }
- if (g_game_simu_set_cntx.inlineHighligtItemSelectMemory == 0)
- div_path = (S8)MMI_PUBLIC_DRV;
- else
- div_path = (S8)MMI_CARD_DRV;
-
- switch (search_type_path)
- {
- case GAME_FRM_SEARCH_GB:
- sprintf((char*)file_path_in_ascii, "%c%s%s", div_path, GAME_DOWNLOADED_PATH, GAME_SEARCH_GB_STR);
- break;
- case GAME_FRM_SEARCH_GBC:
- sprintf((char*)file_path_in_ascii, "%c%s%s", div_path, GAME_DOWNLOADED_PATH, GAME_SEARCH_GBC_STR);
- break;
- case GAME_FRM_SEARCH_NES:
- sprintf((char*)file_path_in_ascii, "%c%s%s", div_path, GAME_DOWNLOADED_PATH, GAME_SEARCH_NES_STR);
- break;
- default:
- sprintf((char*)file_path_in_ascii, "%c%s", div_path, GAME_DOWNLOADED_PATH);
- break;
- }
- AnsiiToUnicodeString((PS8) file_path, file_path_in_ascii);
- // prev_memory_type_selected = memory_type_selected;
- // prev_search_type_path = search_type_path;
- return file_path;
- }
- void game_simu_set_selected_file_name(FMGR_FILE_INFO_STRUCT *file_info)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 tmp_path_buf[(FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(file_path_buf, 0, (FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- if (file_info->is_short)
- {
- memset(tmp_path_buf, 0, (FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- mmi_chset_mixed_text_to_ucs2_str(
- (U8*) tmp_path_buf,
- (FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH,
- (U8*) file_info->file_name,
- g_chset_text_encoding);
- pfnUnicodeStrcpy((S8*) file_path_buf, (S8*) game_frm_get_file_path(g_game_simu_set_cntx.inlineHighligtItemSelectMemory, GAME_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((S8*) file_path_buf, (S8*) tmp_path_buf);
- }
- else
- {
- pfnUnicodeStrcpy((S8*) file_path_buf, (S8*) game_frm_get_file_path(g_game_simu_set_cntx.inlineHighligtItemSelectMemory, GAME_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((S8*) file_path_buf, (S8*) file_info->file_name);
- }
- }
- void game_simu_please_wait_actual_screen(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_GAMESIMU_WAITSCREEN, NULL, NULL, NULL);
- ClearHighlightHandler();
- /* ShowCategory151Screen(0, 0, 0, 0, 0, 0, (PU8)GetString(STR_ID_GAME_SIMU_WAIT_STRING), 0, NULL); */
- ShowCategory66Screen(
- (U16) STR_ID_GAME_SIMU_GAME_LIST,
- MAIN_MENU_TITLE_FUNANDGAMES_ICON,
- 0,
- 0,
- 0,
- 0,
- (U8*) GetString(STR_ID_GAME_SIMU_WAIT_STRING),
- IMG_GLOBAL_PROGRESS,
- NULL);
- /* ShowCategory9Screen(wait_string, wait_image_id, NULL); */
- ClearAllKeyHandler();
- }
- void game_simu_entry_refresh_game_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_entry_game_list_screen();
- DisplayPopup(
- (PU8) GetString(STR_ID_GAME_LIST_RES_OPTION), //need update
- IMG_GLOBAL_ACTIVATED,
- 1,
- UI_POPUP_NOTIFYDURATION_TIME,
- SUCCESS_TONE);
- // if (IsScreenPresent(SCR_FMGR_APP_FILE_OPTION))
- // {
- // DeleteNScrId(SCR_FMGR_APP_FILE_OPTION);
- // }
- // else
- // {
- // DeleteNScrId(EBOOK_OPEN_OPTION_SCREENID); //need update
- // }
- }
- void game_simu_entry_play(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FMGR_FILE_INFO_STRUCT file_info;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
- ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
- mmi_fmgr_kernel_get_file_info(mmi_fmgr_kernel_get_cur_idx(), &file_info);
- game_simu_set_selected_file_name(&file_info);
- //
- EntryGameSimu();
- return;
- }
- void mmi_game_simu_highlight_play(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
-
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(game_simu_entry_play, KEY_EVENT_UP);
- SetKeyHandler(game_simu_entry_play, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- void mmi_game_simu_highlight_refresh_game_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* 1 Change left soft key icon and label */
- ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
- /* 2 Change right soft key icon and label */
- ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
- /* 3 Register function for left soft key */
- SetLeftSoftkeyFunction(mmi_entry_game_list_screen, KEY_EVENT_UP);
- /* 4 Register function for right soft key */
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- }
- void mmi_game_simu_highlight_game_data_settings(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
- ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
- SetLeftSoftkeyFunction(game_list_entry_settings, KEY_EVENT_UP);
- SetKeyHandler(game_list_entry_settings, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- // g_ebook_app_cntx_p->ebr_set_local_setting_flag = 0;
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- #if 0
- void mmi_game_simu_higlight_game_info(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
- ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
- // SetLeftSoftkeyFunction(ebr_entry_book_info, KEY_EVENT_UP);
- // SetKeyHandler(ebr_entry_book_info, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- }
- void mmi_game_simu_highlight_delete_game(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
- ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
- // SetLeftSoftkeyFunction(ebr_entry_delete_book_popup, KEY_EVENT_UP);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- }
- void mmi_game_simu_highlight_delete_all(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
- ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- highlight_fmgr_delete_all_file();
- }
- void mmi_game_simu_highlight_help(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
- ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
- // SetLeftSoftkeyFunction(ebr_entry_help, KEY_EVENT_UP);
- // SetKeyHandler(ebr_entry_help, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- }
- #endif
- ///////////////////////////
- S32 game_simu_frm_get_total_file(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FS_HANDLE fh_cur;
- FS_DOSDirEntry file_info;
- UI_character_type filename[MAX_GAME_NAME_LENGTH];
- U8 count = 0;
- S8 path[MAX_DWNL_GAME_PATH_LEN * ENCODING_LENGTH];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy(
- (S8*) path,
- (S8*) game_frm_get_file_path((S8)g_game_simu_set_cntx.inlineHighligtItemSelectMemory, game_simu_search_type_path));
- if ((fh_cur = FS_FindFirst(
- (const WCHAR*)path,
- 0,
- 0,
- &file_info,
- (U16*) filename,
- MAX_GAME_NAME_LENGTH * ENCODING_LENGTH)) >= 0)
- {
- do
- {
- if (!(file_info.Attributes & FS_ATTR_DIR))
- {
- count++;
- break;
- }
- } while ((FS_FindNext(fh_cur, &file_info, (U16*) filename, MAX_GAME_NAME_LENGTH * ENCODING_LENGTH) ==
- FS_NO_ERROR));
- FS_FindClose(fh_cur);
- }
- return count;
- }
- U16 mmi_game_simu_get_menuId(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 count_no_of_game_file;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- count_no_of_game_file = game_simu_frm_get_total_file();
- debug_uart_output_data("ncount_no_of_game_file = %dn", count_no_of_game_file);
- // ebr_frm_write_default_value_for_nfo_id_in_nvram();
- if (count_no_of_game_file <= 0)
- {
- return MENU_ID_GAME_LIMITED_GAME_LIST_OPTION;
- }
- else
- {
- return MENU_ID_GAME_GAME_LIST_OPTION;
- }
- }
- S8 *game_list_frm_get_path_for_game(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return game_frm_get_file_path(memory_type_selected, GAME_FRM_SEARCH_DEFAULT);
- }
- void game_list_file_callback(void *fullname, int is_short)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- GoBackHistory();
- }
- #if 0
- void game_simu_is_drive_letter_valid(void)
- {
- S16 error;
- S8 div_path;
- S8 memory_type_selected;
- MMI_BOOL status;
- ReadValue(NVRAM_GAME_LIST_MEMORY_TYPE_ID, (void *)&g_game_simu_set_cntx.inlineHighligtItemSelectMemory, DS_BYTE, &error);
- if (g_game_simu_set_cntx.inlineHighligtItemSelectMemory == 0)
- memory_type_selected = (S8)MMI_PUBLIC_DRV;
- else
- memory_type_selected = (S8)MMI_CARD_DRV;
- status = mmi_fmgr_is_drive_letter_valid(memory_type_selected);
-
- if (status && FS_GetDevStatus(memory_type_selected, FS_MOUNT_STATE_ENUM) == FS_NO_ERROR)
- {
- return ;
- }
- else
- {
- memory_type_selected = MMI_PUBLIC_DRV;
- g_game_simu_set_cntx.inlineHighligtItemSelectMemory = 0;
- WriteValue(NVRAM_GAME_LIST_MEMORY_TYPE_ID, &(g_game_simu_set_cntx.inlineHighligtItemSelectMemory), DS_BYTE, &error);
- return ;
- }
- }
- #endif
- void mmi_entry_game_list_screen(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FMGR_FILTER filter;
- S16 local_nfo_id;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* DeleteScreenIfPresent(SCR_ID_GAMESIMU_LIST); */
- switch(game_simu_fmgr_filter)
- {
- case FMGR_TYPE_GAME_GB:
- game_simu_search_type_path = GAME_FRM_SEARCH_GB;
- break;
-
- case FMGR_TYPE_GAME_GBC:
- game_simu_search_type_path = GAME_FRM_SEARCH_GBC;
- break;
-
- case FMGR_TYPE_GAME_NES:
- game_simu_search_type_path = GAME_FRM_SEARCH_NES;
- break;
-
- default:
- game_simu_search_type_path = GAME_FRM_SEARCH_DEFAULT;
- break;
- }
-
- game_simu_please_wait_actual_screen();
- FMGR_FILTER_INIT(&filter);
- FMGR_FILTER_SET(&filter, game_simu_fmgr_filter);
- mmi_fmgr_select_path_and_enter(
- APP_GAMESIMU,
- FMGR_SELECT_BROWSE,
- filter,
- (PS8) game_list_frm_get_path_for_game(),
- game_list_file_callback);
-
- DeleteScreenIfPresent(SCR_ID_GAMESIMU_WAITSCREEN);
- ClearKeyHandler(KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- void game_simu_frm_check_is_game_folder_created(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 tmp_str[MAX_DWNL_GAME_PATH_LEN];
- S8 game_folder_path[MAX_DWNL_GAME_PATH_LEN * ENCODING_LENGTH];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- sprintf(tmp_str, "%c%s", MMI_CARD_DRV, GAME_DOWNLOADED_PATH);
- AnsiiToUnicodeString((S8*) game_folder_path, (S8*) tmp_str);
- FS_CreateDir((PU16) game_folder_path);
- sprintf(tmp_str, "%c%s", MMI_PUBLIC_DRV, GAME_DOWNLOADED_PATH);
- AnsiiToUnicodeString((S8*) game_folder_path, (S8*) tmp_str);
- FS_CreateDir((PU16) game_folder_path);
- }
- game_memory_type_enum game_simu_frm_get_memory_type_selected(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 memory_type_selected;
- S16 error;
- MMI_BOOL status;
-
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ReadValue(NVRAM_GAME_LIST_MEMORY_TYPE_ID, &(g_game_simu_set_cntx.inlineHighligtItemSelectMemory), DS_BYTE, &error);
- if (g_game_simu_set_cntx.inlineHighligtItemSelectMemory == 0)
- {
- memory_type_selected = MMI_PUBLIC_DRV;
- }
- else
- {
- memory_type_selected = MMI_CARD_DRV;
- }
- status = mmi_fmgr_is_drive_letter_valid(memory_type_selected);
-
- if (status && FS_GetDevStatus(memory_type_selected, FS_MOUNT_STATE_ENUM) == FS_NO_ERROR)
- {
- return memory_type_selected;
- }
- else
- {
- memory_type_selected = MMI_PUBLIC_DRV;
- g_game_simu_set_cntx.inlineHighligtItemSelectMemory = 0;
- WriteValue(NVRAM_GAME_LIST_MEMORY_TYPE_ID, &(g_game_simu_set_cntx.inlineHighligtItemSelectMemory), DS_BYTE, &error);
- }
-
- return memory_type_selected;
-
- }
- void game_simu_frm_init(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- // g_curr_book_cntx_p->state_recursive_conversion = EBR_FRM_NO_CONVERSION;
- // ReadValue(NVRAM_GAME_LIST_AUTO_GEN_ID, &g_game_simu_set_cntx.inlineHighligtItemSelectAutoGen, DS_BYTE, &error);
- ReadValue(NVRAM_GAME_LIST_MEMORY_TYPE_ID, &g_game_simu_set_cntx.inlineHighligtItemSelectMemory, DS_BYTE, &error);
- // if (g_game_simu_set_cntx.inlineHighligtItemSelectAutoGen < 0 || g_game_simu_set_cntx.inlineHighligtItemSelectAutoGen > 1)
- // {
- // g_game_simu_set_cntx.inlineHighligtItemSelectAutoGen= 0;
- // WriteValue(NVRAM_GAME_LIST_AUTO_GEN_ID, &g_game_simu_set_cntx.inlineHighligtItemSelectAutoGen, DS_BYTE, &error);
- // }
-
- if (g_game_simu_set_cntx.inlineHighligtItemSelectMemory < 0 || g_game_simu_set_cntx.inlineHighligtItemSelectMemory > 1)
- {
- g_game_simu_set_cntx.inlineHighligtItemSelectMemory = 0;
- WriteValue(NVRAM_GAME_LIST_MEMORY_TYPE_ID, &(g_game_simu_set_cntx.inlineHighligtItemSelectMemory), DS_BYTE, &error);
- }
- game_simu_frm_check_is_game_folder_created();
- game_simu_frm_get_memory_type_selected();
- }
- //KP Jerry add on 2007-4-14 start
- /*****************************************************************************
- * FUNCTION
- * mmi_gamesimu_load_setting
- * DESCRIPTION
- * load gamesimu setting from NVRAM
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_gamesimu_load_setting(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ReadValue(NVRAM_GAME_SIMU_LCD_STATE_ID, &game_simu_settings.bLCDState, DS_BYTE, &error);
- /* if not init, init as HORIZONTAL */
- if (game_simu_settings.bLCDState == 0xff)
- {
- game_simu_settings.bLCDState = TRUE;
- WriteValue(NVRAM_GAME_SIMU_LCD_STATE_ID, &game_simu_settings.bLCDState, DS_BYTE, &error);
- }
- ReadValue(NVRAM_GAME_SIMU_AUDIO_ID, &game_simu_settings.bVolu, DS_BYTE, &error);
- /* if not init, init as OFF */
- if (game_simu_settings.bVolu == 0xff)
- {
- game_simu_settings.bVolu = TRUE;
- WriteValue(NVRAM_GAME_SIMU_AUDIO_ID, &game_simu_settings.bVolu, DS_BYTE, &error);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_gamesimu_exit_setting_screen
- * DESCRIPTION
- * exit point for gamesimu setting screen
- * PARAMETERS
- * void
- * viud(?) [IN]
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_gamesimu_exit_setting_screen(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 inputBufferSize;
- history h;
- S16 nHistory = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- h.scrnID = SCR_ID_GAMESIMU_SETTING;
- CloseCategory57Screen();
- h.entryFuncPtr = mmi_gamesimu_entry_setting_screen;
- pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
- GetCategory57History(h.guiBuffer);
- inputBufferSize = (U16) GetCategory57DataSize();
- GetCategory57Data((U8*) h.inputBuffer);
- AddNHistory(h, inputBufferSize);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_gamesimu_store_setting
- * DESCRIPTION
- * store gamesimu setting back to NVRAM
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_gamesimu_store_setting(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- WriteValue(NVRAM_GAME_SIMU_LCD_STATE_ID, &game_simu_settings.bLCDState, DS_BYTE, &error);
- WriteValue(NVRAM_GAME_SIMU_AUDIO_ID, &game_simu_settings.bVolu, DS_BYTE, &error);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_gamesimu_setting_done_hdlr
- * DESCRIPTION
- * done hdlr for game setting
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_gamesimu_setting_done_hdlr(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* game effect */
- game_simu_settings.bLCDState = gamesimu_cntx.lcd_selected;
- game_simu_settings.bVolu = gamesimu_cntx.aud_selected;
- mmi_gamesimu_store_setting();
- DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, SUCCESS_TONE);
- DeleteNHistory(1);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_gamesimu_setting_highlight_hdlr
- * DESCRIPTION
- * highlight hdlr
- * PARAMETERS
- * index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_gamesimu_setting_highlight_hdlr(S32 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
- SetCategory57LeftSoftkeyFunction(mmi_gamesimu_setting_done_hdlr);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_gamesimu_entry_setting_screen
- * DESCRIPTION
- * entry point for gamesimu setting screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_gamesimu_entry_setting_screen(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- U8 *inputBuffer;
- U16 inputBufferSize;
- S32 item_offset = 0;
- MMI_ID_TYPE item_icons[] =
- {
- IMG_ID_GAME_SETTING_VIB,// FOR LCD STATE SMALL ICON
- 0,
- IMG_ID_GAME_SETTING_AUD, // FOR AUDIO SMALL ICON
- 0,
- };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* load setting */
- mmi_gamesimu_load_setting();
- EntryNewScreen(SCR_ID_GAMESIMU_SETTING, mmi_gamesimu_exit_setting_screen, NULL, NULL);
- /*****************************************************************************
- * Game simu
- *****************************************************************************/
- /* TRUE (1) is on */
- gamesimu_cntx.lcd_selected = game_simu_settings.bLCDState;
- gamesimu_cntx.aud_selected = game_simu_settings.bVolu;
-
- gamesimu_cntx.lcd_str[0] = (UI_string_type) GetString((U16) (STR_ID_GAME_SIMU_LCD_V));
- gamesimu_cntx.lcd_str[1] = (UI_string_type) GetString((U16) (STR_ID_GAME_SIMU_LCD_H));
-
- gamesimu_cntx.aud_str[0] = (UI_string_type) GetString((U16) (STR_GLOBAL_OFF));
- gamesimu_cntx.aud_str[1] = (UI_string_type) GetString((U16) (STR_GLOBAL_ON));
- memset((void*)gamesimu_cntx.inline_game_items, 0, sizeof(InlineItem) * MMI_GAMESIMU_SETTING_ITEM_COUNT * 2);
- InitializeCategory57Screen();
- /* game simu LCD */
- SetInlineItemCaption(
- &gamesimu_cntx.inline_game_items[item_offset++],
- (PU8) GetString((U16) (STR_ID_GAME_SIMU_LCD_STATE)));
- SetInlineItemActivation(&gamesimu_cntx.inline_game_items[item_offset], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
- SetInlineItemSelect(
- &gamesimu_cntx.inline_game_items[item_offset++],
- 2,
- (U8 **) gamesimu_cntx.lcd_str,
- &gamesimu_cntx.lcd_selected);
- /* game simu audio */
- SetInlineItemCaption(
- &gamesimu_cntx.inline_game_items[item_offset++],
- (PU8) GetString((U16) (STR_ID_GAME_SIMU_VOL_SWITCH)));
- SetInlineItemActivation(&gamesimu_cntx.inline_game_items[item_offset], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
- SetInlineItemSelect(
- &gamesimu_cntx.inline_game_items[item_offset++],
- 2,
- (U8 **) gamesimu_cntx.aud_str,
- &gamesimu_cntx.aud_selected);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_GAMESIMU_SETTING);
- inputBuffer = GetCurrNInputBuffer(SCR_ID_GAMESIMU_SETTING, &inputBufferSize);
- if (inputBuffer != NULL)
- {
- SetCategory57Data(gamesimu_cntx.inline_game_items, MMI_GAMESIMU_SETTING_ITEM_COUNT * 2, inputBuffer);
- }
- RegisterHighlightHandler(mmi_gamesimu_setting_highlight_hdlr);
- /* show category */
- ShowCategory57Screen(
- STR_ID_GAME_SETTING,
- MAIN_MENU_TITLE_FUNANDGAMES_ICON,
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- item_offset,
- item_icons,
- gamesimu_cntx.inline_game_items,
- 0,
- guiBuffer);
- /* set key hdlr */
- SetCategory57LeftSoftkeyFunction(mmi_gamesimu_setting_done_hdlr);
- SetCategory57RightSoftkeyFunctions(GoBackHistory, GoBackHistory);
- DisableCategory57ScreenDone();
- }
- //KP Jerry add on 2007-4-14 end
- /*****************************************************************************
- * FUNCTION
- * mmi_gamesimu_highlight_hdlr
- * DESCRIPTION
- * highlight hdlr for games
- * PARAMETERS
- * index [IN] Highlighted index
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_gamesimu_highlight_hdlr(S32 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (index)
- {
- /*
- case index:
- {
- SetLeftSoftkeyFunction(EntryGameSimu,KEY_EVENT_UP);
- SetKeyHandler(EntryGameSimu, KEY_RIGHT_ARROW,KEY_EVENT_DOWN);
- }
- break;
- */
- //GAME_SWITCH(GAME_SIMU_TYPE_GB, EntryGameSimu);
- //GAME_SWITCH(GAME_SIMU_TYPE_GBC, EntryGameSimu);
- //GAME_SWITCH(GAME_SIMU_TYPE_NES, EntryGameSimu);
- #ifdef __GAME_SIMU_E_GB__
- case GAME_SIMU_TYPE_GB:
- {
- game_simu_fmgr_filter = FMGR_TYPE_GAME_GB;
- u8_g_game_type = GAME_SIMU_TYPE_GB;
- //mmi_entry_game_list_screen();
- //goto SETKEYHANDLE;
- //GAME_SIMU_SWITCH(GAME_SIMU_TYPE_GB, mmi_entry_game_list_screen);
- //EntryGameSimu();
- break;
- }
- #endif
- #ifdef __GAME_SIMU_E_GBC__
- case GAME_SIMU_TYPE_GBC:
- {
- game_simu_fmgr_filter = FMGR_TYPE_GAME_GBC;
- u8_g_game_type = GAME_SIMU_TYPE_GBC;
- //mmi_entry_game_list_screen();
- //goto SETKEYHANDLE;
- //GAME_SIMU_SWITCH(GAME_SIMU_TYPE_GBC, mmi_entry_game_list_screen);
- //EntryGameSimu();
- break;
- }
- #endif
- #ifdef __GAME_SIMU_E_NES__
- case GAME_SIMU_TYPE_NES:
- {
- game_simu_fmgr_filter = FMGR_TYPE_GAME_NES;
- u8_g_game_type = GAME_SIMU_TYPE_NES;
- //mmi_entry_game_list_screen();
- //goto SETKEYHANDLE;
- //GAME_SIMU_SWITCH(FMGR_TYPE_GAME_NES, mmi_entry_game_list_screen);
- //EntryGameSimu();
- break;
- }
- #endif
- case GAME_SIMU_SETTING:
- SetLeftSoftkeyFunction(mmi_gamesimu_entry_setting_screen,KEY_EVENT_UP);
- SetKeyHandler(mmi_gamesimu_entry_setting_screen, KEY_RIGHT_ARROW,KEY_EVENT_DOWN);
- return;
-
- case GAME_SIMU_HELP:
- SetLeftSoftkeyFunction(mmi_gamesimu_entry_help_screen,KEY_EVENT_UP);
- SetKeyHandler(mmi_gamesimu_entry_help_screen, KEY_RIGHT_ARROW,KEY_EVENT_DOWN);
- return;
- default:
- /* shall not enter here */
- MMI_ASSERT(0);
- break;
- }
- GAME_SIMU_SWITCH(u8_g_game_type, mmi_entry_game_list_screen);
- //SETKEYHANDLE:
- // SetLeftSoftkeyFunction(mmi_entry_game_list_screen,KEY_EVENT_UP);
- // SetKeyHandler(mmi_entry_game_list_screen, KEY_RIGHT_ARROW,KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_gamesimu_entry_game_list
- * DESCRIPTION
- * entry game app screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_gamesimu_entry_game_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- UI_time t;
- U16 menu_str[GAME_SIMU_LIST_COUNT];
- U16 menu_img[GAME_SIMU_LIST_COUNT];
- U16 index = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- debug_uart_output_data(" n entry game list n");
- #ifdef __GAME_SIMU_E_GB__
- menu_str[index] = STR_ID_GAME_SIMU_E_GB;
- menu_img[index++] = IMG_GLOBAL_L1;
- #endif
- #ifdef __GAME_SIMU_E_GBC__
- menu_str[index] = STR_ID_GAME_SIMU_E_GBC;
- menu_img[index++] = IMG_GLOBAL_L2;
- #endif
- #ifdef __GAME_SIMU_E_NES__
- menu_str[index] = STR_ID_GAME_SIMU_E_NES;
- menu_img[index++] = IMG_GLOBAL_L3;
- #endif
- menu_str[index] = STR_ID_GAME_SIMU_SETTING;
- menu_img[index++] = IMG_GLOBAL_L4;
-
- menu_str[index] = STR_ID_GAME_SIMU_HELP_TITLE;
- menu_img[index++] = IMG_GLOBAL_L5;
- /* Set random seed */
- GetDateTime(&t);
- srand(t.nMin);
- EntryNewScreen(SCR_ID_GAMESIMU_LIST, NULL, mmi_gamesimu_entry_game_list, NULL);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_GAMESIMU_LIST);
- RegisterHighlightHandler(mmi_gamesimu_highlight_hdlr);
- ShowCategory15Screen(
- STR_ID_GAME_SIMU,
- MAIN_MENU_TITLE_FUNANDGAMES_ICON,
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- index,
- menu_str,
- menu_img,
- 1,
- 0,
- guiBuffer);
- debug_uart_output_data(" n entry ShowCategory15Screen() n");
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- mmi_gamesimu_load_setting();
- }
- void mmi_gamesimu_entry_help_screen(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- PS8 buffer;
- S32 bufferSize;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_GAMESIMU_HELP, NULL, mmi_gamesimu_entry_help_screen, NULL);
- buffer = GetString(STR_ID_GAME_SIMU_HELP);
- bufferSize = pfnUnicodeStrlen(buffer);
- ShowCategory74Screen(
- STR_ID_GAME_SIMU_HELP_TITLE,
- MAIN_MENU_TITLE_FUNANDGAMES_ICON,
- 0,
- 0,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- (PU8) buffer,
- bufferSize,
- NULL);
- /* go back to game menu */
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- }
- #if 0
- void mmi_gamesimu_highlight_help(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_gamesimu_entry_help_screen, KEY_EVENT_UP);
- SetKeyHandler(mmi_gamesimu_entry_help_screen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- }
- #endif
- /*****************************************************************************
- * FUNCTION
- * mmi_gamesimu_highlight_app
- * DESCRIPTION
- * highlight game app menitem
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_gamesimu_highlight_app(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_gamesimu_entry_game_list, KEY_EVENT_UP);
- SetKeyHandler(mmi_gamesimu_entry_game_list, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- }
- //KP Jerry add on 2007-4-14 start
- void mmi_gameply_entry_player_screen_from_file(PS8 filename, fmgr_filter_type_enum filtertype)
- {
- //memcpy(file_path_buf, filename, sizeof(filename));
- memset(file_path_buf, 0, sizeof(file_path_buf));
- pfnUnicodeStrcpy((PS8)file_path_buf, filename);
- switch (filtertype)
- {
- case FMGR_TYPE_GAME_GB:
- u8_g_game_type = GAME_SIMU_TYPE_GB;
- break;
- case FMGR_TYPE_GAME_GBC:
- u8_g_game_type = GAME_SIMU_TYPE_GBC;
- break;
- case FMGR_TYPE_GAME_NES:
- u8_g_game_type = GAME_SIMU_TYPE_NES;
- break;
- default:
- return;
- }
- #ifdef DEBUG_TEST
- debug_uart_output_data("n u8_g_game_type = %d n", u8_g_game_type);
- #endif
- EntryGameSimu();
- }
- //KP Jerry add on 2007-4-14 end
- #endif/* defined(__GAME_SIMU__)*/
- #endif