GameFramework.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:64k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  * Filename:
  37.  * ---------
  38.  *  GameFramework.c
  39.  *
  40.  * Project:
  41.  * --------
  42.  *  Maui
  43.  *
  44.  * Description:
  45.  * ------------
  46.  *  Game Framework
  47.  *
  48.  * Author:
  49.  * -------
  50.  * -------
  51.  *
  52.  *============================================================================
  53.  *             HISTORY
  54.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  55.  *------------------------------------------------------------------------------
  56.  * removed!
  57.  *
  58.  * removed!
  59.  * removed!
  60.  * removed!
  61.  *
  62.  * removed!
  63.  * removed!
  64.  * removed!
  65.  *
  66.  * removed!
  67.  * removed!
  68.  * removed!
  69.  *
  70.  * removed!
  71.  * removed!
  72.  * removed!
  73.  *
  74.  * removed!
  75.  * removed!
  76.  * removed!
  77.  *
  78.  * removed!
  79.  * removed!
  80.  * removed!
  81.  *
  82.  * removed!
  83.  * removed!
  84.  * removed!
  85.  *
  86.  * removed!
  87.  * removed!
  88.  * removed!
  89.  *
  90.  * removed!
  91.  * removed!
  92.  * removed!
  93.  *
  94.  * removed!
  95.  * removed!
  96.  * removed!
  97.  *
  98.  * removed!
  99.  * removed!
  100.  * removed!
  101.  *
  102.  * removed!
  103.  * removed!
  104.  * removed!
  105.  *
  106.  * removed!
  107.  * removed!
  108.  * removed!
  109.  *
  110.  * removed!
  111.  * removed!
  112.  * removed!
  113.  *
  114.  * removed!
  115.  * removed!
  116.  * removed!
  117.  *
  118.  * removed!
  119.  * removed!
  120.  * removed!
  121.  *
  122.  * removed!
  123.  * removed!
  124.  * removed!
  125.  *
  126.  * removed!
  127.  * removed!
  128.  * removed!
  129.  *
  130.  * removed!
  131.  * removed!
  132.  * removed!
  133.  *
  134.  * removed!
  135.  * removed!
  136.  * removed!
  137.  *
  138.  * removed!
  139.  * removed!
  140.  * removed!
  141.  *
  142.  * removed!
  143.  * removed!
  144.  * removed!
  145.  *
  146.  * removed!
  147.  * removed!
  148.  * removed!
  149.  *
  150.  * removed!
  151.  * removed!
  152.  * removed!
  153.  *
  154.  *------------------------------------------------------------------------------
  155.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  156.  *============================================================================
  157.  ****************************************************************************/
  158. #include "MMI_features.h"
  159. #ifdef __MMI_GAME__
  160. #include "GlobalConstants.h"
  161. #include "GlobalDefs.h"
  162. #include "gui.h"
  163. #include "HistoryGprot.h"
  164. #include "Unicodexdcl.h"
  165. #include "NVRAMType.h"
  166. #include "NVRAMProt.h"
  167. #include "NVRAMEnum.h"
  168. #include "MiscFunctions.h"
  169. #include "AudioInc.h"
  170. #include "SettingProfile.h"     /* game sound level define */
  171. #include "mdi_datatype.h"
  172. #include "mdi_audio.h"
  173. #include "GameFramework.h"
  174. #include "GameDefs.h"   /* game id's and effect flag */
  175. #include "ProfileGprots.h"      /* set audio volume fucntion */
  176. #include "gpioInc.h"    /* set audio volume fucntion */
  177. #include "gdi_include.h"
  178. #include "wgui_categories_multimedia.h" /* for gameover screen's empty category */
  179. #include "CommonScreens.h"      /* popup */
  180. #include "KeyBrd.h"     /* for keypad tone related interface */
  181. #include "DebugInitDef.h"
  182. #include "MainMenuDef.h"
  183. #ifdef __MMI_TOUCH_SCREEN__
  184. #include "wgui_touch_screen.h"
  185. #endif 
  186. #ifdef __MMI_SUBLCD__
  187. #include "SubLCDHistoryGprot.h"
  188. #endif 
  189. #ifndef __MTK_TARGET__
  190. #include "SubLCDHistoryGprot.h"
  191. #endif 
  192. /****************************************************************************
  193. * Local Function                                                      
  194. *****************************************************************************/
  195. void mmi_gfx_exit_game(void);
  196. void mmi_gfx_enter_game(void);
  197. void mmi_gfx_new_game(void);
  198. void mmi_gfx_resume_game(void);
  199. void mmi_gfx_store_grade(void);
  200. void mmi_gfx_exit_gameover_screen(void);
  201. void mmi_gfx_entry_gameover_screen(void);
  202. void mmi_gfx_set_game_level(void);
  203. void mmi_gfx_set_level_highlight_hdlr(S32 index);
  204. void mmi_gfx_entry_level_screen(void);
  205. void mmi_gfx_entry_help_screen(void);
  206. void mmi_gfx_reset_grade(void);
  207. void mmi_gfx_entry_grade_screen(void);
  208. void mmi_gfx_menu_hilight_hdlr(S32 index);
  209. void mmi_gfx_entry_menu_screen(void);
  210. #ifdef __MMI_SUBLCD__
  211. void mmi_gfx_entry_sublcd_screen(void);
  212. #endif 
  213. /****************************************************************************
  214. * Local Variable                                                      
  215. *****************************************************************************/
  216. mmi_gfx_cntx_struct g_gfx_cntx;
  217. __align(2)
  218.      const U8 g_gfx_audio_gameover[862] = 
  219.      {
  220.          0x4D, 0x54, 0x68, 0x64, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x03, 0xC0, 0x4D, 0x54, 0x72,
  221.          0x6B, 0x00, 0x00, 0x03, 0x48, 0x00, 0xFF, 0x02, 0x16, 0x43, 0x6F, 0x70, 0x79, 0x72, 0x69, 0x67,
  222.          0x68, 0x74, 0x20, 0x63, 0x20, 0x32, 0x30, 0x30, 0x33, 0x20, 0x62, 0x79, 0x20, 0x43, 0x43, 0x00,
  223.          0xFF, 0x01, 0x02, 0x43, 0x43, 0x00, 0xFF, 0x58, 0x04, 0x04, 0x02, 0x18, 0x08, 0x00, 0xFF, 0x59,
  224.          0x02, 0x00, 0x00, 0x00, 0xFF, 0x51, 0x03, 0x06, 0xA0, 0x67, 0x00, 0xC0, 0x44, 0x00, 0xB0, 0x07,
  225.          0x7C, 0x00, 0x90, 0x40, 0x67, 0x00, 0xC1, 0x3D, 0x00, 0xB1, 0x07, 0x58, 0x00, 0x91, 0x28, 0x7C,
  226.          0x00, 0x34, 0x7F, 0x00, 0xC2, 0x64, 0x00, 0xB2, 0x07, 0x3C, 0x00, 0xC3, 0x13, 0x00, 0xB3, 0x07,
  227.          0x68, 0x00, 0x93, 0x32, 0x7A, 0x81, 0x70, 0x32, 0x00, 0x00, 0x31, 0x6F, 0x81, 0x70, 0x31, 0x00,
  228.          0x00, 0x90, 0x40, 0x00, 0x00, 0x3F, 0x5A, 0x00, 0x92, 0x43, 0x7D, 0x00, 0x40, 0x7D, 0x00, 0x3B,
  229.          0x7C, 0x00, 0x93, 0x30, 0x6E, 0x81, 0x70, 0x30, 0x00, 0x00, 0x2F, 0x6C, 0x81, 0x70, 0x2F, 0x00,
  230.          0x00, 0x90, 0x3F, 0x00, 0x00, 0x40, 0x50, 0x00, 0x93, 0x32, 0x7A, 0x81, 0x70, 0x32, 0x00, 0x00,
  231.          0x31, 0x74, 0x81, 0x70, 0x31, 0x00, 0x00, 0x90, 0x40, 0x00, 0x00, 0x92, 0x3B, 0x00, 0x00, 0x43,
  232.          0x00, 0x00, 0x40, 0x00, 0x00, 0x90, 0x42, 0x7C, 0x00, 0x92, 0x43, 0x7C, 0x00, 0x40, 0x7C, 0x00,
  233.          0x3B, 0x6F, 0x00, 0x93, 0x30, 0x74, 0x81, 0x70, 0x30, 0x00, 0x00, 0x2F, 0x72, 0x81, 0x70, 0x2F,
  234.          0x00, 0x00, 0x92, 0x3B, 0x00, 0x00, 0x91, 0x28, 0x00, 0x00, 0x90, 0x42, 0x00, 0x00, 0x91, 0x34,
  235.          0x00, 0x00, 0x92, 0x40, 0x00, 0x00, 0x43, 0x00, 0x00, 0x90, 0x43, 0x53, 0x00, 0x91, 0x37, 0x7C,
  236.          0x00, 0x2B, 0x7C, 0x00, 0x93, 0x32, 0x7C, 0x81, 0x70, 0x32, 0x00, 0x00, 0x31, 0x72, 0x81, 0x70,
  237.          0x31, 0x00, 0x00, 0x90, 0x43, 0x00, 0x00, 0x42, 0x6F, 0x00, 0x92, 0x3F, 0x7F, 0x00, 0x42, 0x7F,
  238.          0x00, 0x3B, 0x7C, 0x00, 0x93, 0x30, 0x72, 0x81, 0x70, 0x30, 0x00, 0x00, 0x2F, 0x73, 0x81, 0x70,
  239.          0x2F, 0x00, 0x00, 0x90, 0x42, 0x00, 0x00, 0x43, 0x53, 0x00, 0x93, 0x32, 0x7C, 0x28, 0xFF, 0x51,
  240.          0x03, 0x06, 0xA0, 0x67, 0x28, 0xFF, 0x51, 0x03, 0x06, 0xA8, 0x4C, 0x28, 0xFF, 0x51, 0x03, 0x06,
  241.          0xC0, 0x6E, 0x50, 0xFF, 0x51, 0x03, 0x06, 0xD0, 0xE6, 0x28, 0xFF, 0x51, 0x03, 0x06, 0xEA, 0x34,
  242.          0x00, 0x93, 0x32, 0x00, 0x00, 0x31, 0x73, 0x28, 0xFF, 0x51, 0x03, 0x07, 0x04, 0x41, 0x28, 0xFF,
  243.          0x51, 0x03, 0x07, 0x0D, 0x1B, 0x28, 0xFF, 0x51, 0x03, 0x07, 0x16, 0x0C, 0x28, 0xFF, 0x51, 0x03,
  244.          0x07, 0x28, 0x33, 0x28, 0xFF, 0x51, 0x03, 0x07, 0x3A, 0xB8, 0x28, 0xFF, 0x51, 0x03, 0x07, 0x4D,
  245.          0x9E, 0x00, 0x93, 0x31, 0x00, 0x00, 0x90, 0x43, 0x00, 0x00, 0x92, 0x3B, 0x00, 0x00, 0x3F, 0x00,
  246.          0x00, 0x42, 0x00, 0x00, 0x90, 0x45, 0x53, 0x00, 0x92, 0x42, 0x7F, 0x00, 0x3F, 0x7F, 0x00, 0x3B,
  247.          0x6F, 0x00, 0x93, 0x30, 0x71, 0x28, 0xFF, 0x51, 0x03, 0x07, 0x60, 0xE7, 0x28, 0xFF, 0x51, 0x03,
  248.          0x07, 0x74, 0x97, 0x50, 0xFF, 0x51, 0x03, 0x07, 0x88, 0xB2, 0x50, 0xFF, 0x51, 0x03, 0x07, 0xA7,
  249.          0xA8, 0x00, 0x93, 0x30, 0x00, 0x00, 0x2F, 0x72, 0x28, 0xFF, 0x51, 0x03, 0x07, 0xB2, 0x33, 0x78,
  250.          0xFF, 0x51, 0x03, 0x07, 0xBC, 0xDB, 0x28, 0xFF, 0x51, 0x03, 0x07, 0xC7, 0xA1, 0x28, 0xFF, 0x51,
  251.          0x03, 0x07, 0xD2, 0x85, 0x00, 0x93, 0x2F, 0x00, 0x00, 0x92, 0x3B, 0x00, 0x00, 0x91, 0x37, 0x00,
  252.          0x00, 0x90, 0x45, 0x00, 0x00, 0x91, 0x2B, 0x00, 0x00, 0x92, 0x3F, 0x00, 0x00, 0x42, 0x00, 0x00,
  253.          0x90, 0x47, 0x67, 0x00, 0x91, 0x3B, 0x7D, 0x00, 0x2F, 0x7D, 0x00, 0x93, 0x32, 0x7C, 0x50, 0xFF,
  254.          0x51, 0x03, 0x07, 0xDD, 0x88, 0x28, 0xFF, 0x51, 0x03, 0x07, 0xE8, 0xAA, 0x78, 0x93, 0x32, 0x00,
  255.          0x00, 0x31, 0x73, 0x28, 0xFF, 0x51, 0x03, 0x07, 0xF3, 0xEB, 0x28, 0xFF, 0x51, 0x03, 0x07, 0xFF,
  256.          0x4D, 0x78, 0xFF, 0x51, 0x03, 0x08, 0x0A, 0xD0, 0x28, 0x93, 0x31, 0x00, 0x00, 0x90, 0x47, 0x00,
  257.          0x00, 0x45, 0x7C, 0x00, 0x92, 0x42, 0x7F, 0x00, 0x3E, 0x7D, 0x00, 0x3C, 0x7D, 0x00, 0x93, 0x30,
  258.          0x73, 0x28, 0xFF, 0x51, 0x03, 0x08, 0x16, 0x73, 0x78, 0xFF, 0x51, 0x03, 0x08, 0x22, 0x39, 0x50,
  259.          0xFF, 0x51, 0x03, 0x08, 0x2E, 0x21, 0x00, 0x93, 0x30, 0x00, 0x00, 0x2F, 0x73, 0x50, 0xFF, 0x51,
  260.          0x03, 0x08, 0x3A, 0x2C, 0x78, 0xFF, 0x51, 0x03, 0x08, 0x46, 0x5B, 0x28, 0xFF, 0x51, 0x03, 0x08,
  261.          0x52, 0xAF, 0x00, 0x93, 0x2F, 0x00, 0x00, 0x90, 0x45, 0x00, 0x00, 0x43, 0x52, 0x00, 0x93, 0x32,
  262.          0x7C, 0x78, 0xFF, 0x51, 0x03, 0x08, 0x5F, 0x27, 0x78, 0x93, 0x32, 0x00, 0x00, 0x31, 0x6F, 0x28,
  263.          0xFF, 0x51, 0x03, 0x08, 0x6B, 0xC4, 0x81, 0x48, 0x93, 0x31, 0x00, 0x00, 0x90, 0x43, 0x00, 0x00,
  264.          0x92, 0x3C, 0x00, 0x00, 0x42, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x90, 0x42, 0x67, 0x00, 0x92, 0x42,
  265.          0x7F, 0x00, 0x3E, 0x7D, 0x00, 0x3C, 0x7D, 0x00, 0x93, 0x30, 0x72, 0x50, 0xFF, 0x51, 0x03, 0x08,
  266.          0x78, 0x88, 0x78, 0xFF, 0x51, 0x03, 0x08, 0x85, 0x73, 0x28, 0x93, 0x30, 0x00, 0x00, 0x2F, 0x72,
  267.          0x81, 0x20, 0xFF, 0x51, 0x03, 0x08, 0x9F, 0xC1, 0x50, 0x93, 0x2F, 0x00, 0x00, 0x92, 0x3C, 0x00,
  268.          0x00, 0x91, 0x3B, 0x00, 0x00, 0x90, 0x42, 0x00, 0x00, 0x91, 0x2F, 0x00, 0x00, 0x92, 0x3E, 0x00,
  269.          0x00, 0x42, 0x00, 0x00, 0x90, 0x40, 0x5A, 0x00, 0x91, 0x2B, 0x7C, 0x00, 0x37, 0x7F, 0x00, 0x93,
  270.          0x34, 0x7C, 0x00, 0x2F, 0x7C, 0x28, 0xFF, 0x51, 0x03, 0x08, 0xAD, 0x25, 0x82, 0x40, 0xFF, 0x51,
  271.          0x03, 0x08, 0xBA, 0xB2, 0x82, 0x40, 0xFF, 0x51, 0x03, 0x08, 0xC8, 0x6B, 0x82, 0x18, 0x93, 0x2F,
  272.          0x00, 0x00, 0x91, 0x37, 0x00, 0x00, 0x93, 0x34, 0x00, 0x00, 0x90, 0x40, 0x00, 0x10, 0x91, 0x2B,
  273.          0x00, 0x87, 0x30, 0xFF, 0x51, 0x03, 0x06, 0x63, 0xC8, 0x00, 0xFF, 0x2F, 0x00
  274.      };
  275. __align(2)
  276.      const U8 g_gfx_audio_complete[310] = 
  277.      {
  278.          0x4D, 0x54, 0x68, 0x64, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x03, 0xC0, 0x4D, 0x54, 0x72,
  279.          0x6B, 0x00, 0x00, 0x01, 0x20, 0x00, 0xFF, 0x02, 0x16, 0x43, 0x6F, 0x70, 0x79, 0x72, 0x69, 0x67,
  280.          0x68, 0x74, 0x20, 0x63, 0x20, 0x32, 0x30, 0x30, 0x33, 0x20, 0x62, 0x79, 0x20, 0x43, 0x43, 0x00,
  281.          0xFF, 0x01, 0x02, 0x43, 0x43, 0x00, 0xFF, 0x58, 0x04, 0x04, 0x02, 0x18, 0x08, 0x00, 0xFF, 0x59,
  282.          0x02, 0x00, 0x00, 0x00, 0xFF, 0x51, 0x03, 0x08, 0xE3, 0x7C, 0x00, 0xC0, 0x0A, 0x00, 0xB0, 0x07,
  283.          0x74, 0x00, 0x90, 0x4F, 0x52, 0x00, 0xC1, 0x72, 0x00, 0xB1, 0x07, 0x6C, 0x00, 0x91, 0x30, 0x7C,
  284.          0x81, 0x70, 0x90, 0x4F, 0x00, 0x00, 0x4D, 0x5A, 0x81, 0x70, 0x4D, 0x00, 0x00, 0x91, 0x30, 0x00,
  285.          0x00, 0x90, 0x4C, 0x5A, 0x00, 0x91, 0x37, 0x6F, 0x81, 0x70, 0x90, 0x4C, 0x00, 0x00, 0x4F, 0x6F,
  286.          0x81, 0x70, 0x4F, 0x00, 0x00, 0x91, 0x37, 0x00, 0x00, 0x90, 0x54, 0x7C, 0x00, 0x91, 0x3C, 0x6F,
  287.          0x83, 0x60, 0x3C, 0x00, 0x00, 0x90, 0x54, 0x00, 0x00, 0x4F, 0x7C, 0x00, 0x91, 0x3E, 0x6F, 0x83,
  288.          0x60, 0x3E, 0x00, 0x00, 0x90, 0x4F, 0x00, 0x00, 0x4F, 0x67, 0x00, 0x91, 0x40, 0x6F, 0x81, 0x70,
  289.          0x90, 0x4F, 0x00, 0x00, 0x4D, 0x67, 0x81, 0x70, 0x4D, 0x00, 0x00, 0x91, 0x40, 0x00, 0x00, 0x90,
  290.          0x4C, 0x5A, 0x00, 0x91, 0x3E, 0x67, 0x81, 0x70, 0x90, 0x4C, 0x00, 0x00, 0x4F, 0x52, 0x00, 0x4D,
  291.          0x50, 0x81, 0x70, 0x4D, 0x00, 0x00, 0x4F, 0x00, 0x00, 0x91, 0x3E, 0x00, 0x00, 0x90, 0x54, 0x5A,
  292.          0x00, 0x91, 0x3C, 0x6F, 0x83, 0x60, 0x3C, 0x00, 0x00, 0x90, 0x54, 0x00, 0x00, 0x4F, 0x6F, 0x00,
  293.          0x91, 0x37, 0x6F, 0x83, 0x60, 0x37, 0x00, 0x00, 0x90, 0x4F, 0x00, 0x00, 0x54, 0x64, 0x00, 0x48,
  294.          0x64, 0x00, 0x4C, 0x64, 0x00, 0x4F, 0x64, 0x00, 0x91, 0x43, 0x64, 0x00, 0x40, 0x64, 0x00, 0x48,
  295.          0x64, 0x00, 0x3C, 0x64, 0x87, 0x40, 0x3C, 0x00, 0x00, 0x90, 0x54, 0x00, 0x00, 0x91, 0x43, 0x00,
  296.          0x00, 0x90, 0x48, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x4F, 0x00, 0x00, 0x91, 0x40, 0x00, 0x00, 0x48,
  297.          0x00, 0x00, 0xFF, 0x2F, 0x00
  298.      };
  299.  #ifdef __MMI_GAME_MULTICHANNEL_SOUND__
  300. __align(2)
  301.      const U8 g_gfx_Dummy_background_midi[94] = 
  302.      {
  303.          0x4D, 0x54, 0x68, 0x64, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x03, 0xC0, 0x4D, 0x54,
  304.          0x72, 0x6B, 0x00, 0x00, 0x00, 0x48, 0x00, 0xFF, 0x02, 0x16, 0x43, 0x6F, 0x70, 0x79, 0x72, 0x69,
  305.          0x67, 0x68, 0x74, 0x20, 0x63, 0x20, 0x32, 0x30, 0x30, 0x35, 0x20, 0x62, 0x79, 0x20, 0x43, 0x43,
  306.          0x00, 0xFF, 0x01, 0x02, 0x43, 0x43, 0x00, 0xFF, 0x58, 0x04, 0x04, 0x02, 0x18, 0x08, 0x00, 0xFF,
  307.          0x59, 0x02, 0x00, 0x00, 0x00, 0xFF, 0x51, 0x03, 0x09, 0x27, 0xC0, 0x00, 0xC0, 0x00, 0x00, 0xB0,
  308.          0x07, 0x00, 0x00, 0x90, 0x32, 0x01, 0x9E, 0x00, 0x32, 0x00, 0x00, 0xFF, 0x2F, 0x00
  309.              /*
  310.               * 0x4D,0x54,0x68,0x64,0x00,0x00,0x00,0x06,
  311.               * 0x00,0x00,0x00,0x01,0x03,0xC0,0x4D,0x54,
  312.               * 0x72,0x6B,0x00,0x00,0x01,0x13,0x00,0xFF,
  313.               * 0x02,0x16,0x43,0x6F,0x70,0x79,0x72,0x69,
  314.               * 0x67,0x68,0x74,0x20,0x63,0x20,0x32,0x30,
  315.               * 0x30,0x33,0x20,0x62,0x79,0x20,0x43,0x43,
  316.               * 0x00,0xFF,0x01,0x02,0x43,0x43,0x00,0xFF,
  317.               * 0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xFF,
  318.               * 0x59,0x02,0x00,0x00,0x00,0xFF,0x51,0x03,
  319.               * 0x09,0x27,0xC0,0x00,0xC0,0x47,0x00,0x90,
  320.               * 0x4A,0x5A,0x00,0x45,0x6F,0x81,0x70,0x45,
  321.               * 0x00,0x00,0x4A,0x00,0x00,0x4A,0x67,0x00,
  322.               * 0x45,0x6F,0x81,0x70,0x45,0x00,0x00,0x4A,
  323.               * 0x00,0x00,0x4A,0x53,0x00,0x45,0x67,0x81,
  324.               * 0x70,0x45,0x00,0x00,0x4A,0x00,0x00,0x4A,
  325.               * 0x67,0x00,0x45,0x7C,0x81,0x70,0x45,0x00,
  326.               * 0x00,0x4A,0x00,0x00,0x48,0x5A,0x00,0x43,
  327.               * 0x6F,0x81,0x70,0x43,0x00,0x00,0x48,0x00,
  328.               * 0x81,0x70,0x48,0x67,0x00,0x43,0x7C,0x81,
  329.               * 0x70,0x43,0x00,0x00,0x48,0x00,0x81,0x70,
  330.               * 0x4A,0x6F,0x00,0x45,0x7C,0x81,0x70,0x45,
  331.               * 0x00,0x00,0x4A,0x00,0x81,0x70,0x4A,0x5A,
  332.               * 0x00,0x45,0x7C,0x81,0x70,0x45,0x00,0x00,
  333.               * 0x4A,0x00,0x81,0x70,0x4D,0x53,0x00,0x48,
  334.               * 0x5A,0x87,0x40,0x48,0x00,0x00,0x4D,0x00,
  335.               * 0x00,0x4F,0x52,0x00,0x4A,0x52,0x81,0x70,
  336.               * 0x4A,0x00,0x00,0x4F,0x00,0x00,0x51,0x50,
  337.               * 0x00,0x4C,0x5A,0x81,0x70,0x4C,0x00,0x00,
  338.               * 0x51,0x00,0x00,0x4F,0x5A,0x00,0x4A,0x5A,
  339.               * 0x81,0x70,0x4A,0x00,0x00,0x4F,0x00,0x00,
  340.               * 0x4D,0x5A,0x00,0x48,0x5A,0x81,0x70,0x48,
  341.               * 0x00,0x00,0x4D,0x00,0x00,0x4A,0x67,0x00,
  342.               * 0x45,0x67,0x81,0x70,0x45,0x00,0x00,0x4A,
  343.               * 0x00,0x81,0x70,0x48,0x5A,0x00,0x43,0x67,
  344.               * 0x81,0x70,0x43,0x00,0x00,0x48,0x00,0x81,
  345.               * 0x70,0x4A,0x67,0x00,0x45,0x7C,0x87,0x40,
  346.               * 0x45,0x00,0x00,0x4A,0x00,0x00,0xFF,0x2F,
  347.               * 0x00,
  348.               */
  349.      };
  350. S32 dummy_background_midi = 0;
  351.  #endif /* __MMI_GAME_MULTICHANNEL_SOUND__ */ 
  352. /****************************************************************************
  353. * Global Function                                                      
  354. *****************************************************************************/
  355. extern void UI_enable_alignment_timers(void);
  356. extern void UI_disable_alignment_timers(void);
  357. extern void AudioStopReq(U16 soundId);
  358. extern U16 GetCurKeypadTone(void);
  359. /****************************************************************************
  360. * Golbal Variable                                                       
  361. *****************************************************************************/
  362. extern BOOL r2lMMIFlag;
  363. /****************************************************************************
  364. * Enter Game(New/Resume), Exit Game                                                  
  365. *****************************************************************************/
  366. /*****************************************************************************
  367.  * FUNCTION
  368.  *  mmi_gfx_volume_up
  369.  * DESCRIPTION
  370.  *  Set game volume up
  371.  * PARAMETERS
  372.  *  void
  373.  * RETURNS
  374.  *  void
  375.  *****************************************************************************/
  376. void mmi_gfx_volume_up(void)
  377. {
  378.     /*----------------------------------------------------------------*/
  379.     /* Local Variables                                                */
  380.     /*----------------------------------------------------------------*/
  381.     /*----------------------------------------------------------------*/
  382.     /* Code Body                                                      */
  383.     /*----------------------------------------------------------------*/
  384.     if (GFX.aud_volume < LEVEL7)
  385.     {
  386.         GFX.aud_volume++;
  387.     }
  388.     mdi_audio_set_volume(MDI_VOLUME_MEDIA, GFX.aud_volume);
  389. }
  390. /*****************************************************************************
  391.  * FUNCTION
  392.  *  mmi_gfx_volume_down
  393.  * DESCRIPTION
  394.  *  Set game volume down
  395.  * PARAMETERS
  396.  *  void
  397.  * RETURNS
  398.  *  void
  399.  *****************************************************************************/
  400. void mmi_gfx_volume_down(void)
  401. {
  402.     /*----------------------------------------------------------------*/
  403.     /* Local Variables                                                */
  404.     /*----------------------------------------------------------------*/
  405.     /*----------------------------------------------------------------*/
  406.     /* Code Body                                                      */
  407.     /*----------------------------------------------------------------*/
  408.     if (GFX.aud_volume > LEVEL1)
  409.     {
  410.         GFX.aud_volume--;
  411.     }
  412.     mdi_audio_set_volume(MDI_VOLUME_MEDIA, GFX.aud_volume);
  413. }
  414. /*****************************************************************************
  415.  * FUNCTION
  416.  *  mmi_gfx_exit_game
  417.  * DESCRIPTION
  418.  *  Called by game when exit the game. usually called by the MMI framework
  419.  * PARAMETERS
  420.  *  void
  421.  * RETURNS
  422.  *  void
  423.  *****************************************************************************/
  424. void mmi_gfx_exit_game(void)
  425. {
  426.     /*----------------------------------------------------------------*/
  427.     /* Local Variables                                                */
  428.     /*----------------------------------------------------------------*/
  429.     S16 error;
  430.     /*----------------------------------------------------------------*/
  431.     /* Code Body                                                      */
  432.     /*----------------------------------------------------------------*/
  433.     PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "*---[GameFramework.c] Exit game: %s---*n",
  434.                          GetString(GFX.game_data.game_str_id)));
  435.     UI_enable_alignment_timers();
  436.     GFX.game_data.exit_game_func_ptr(); /* call this funtion to stop and exit game */
  437. #ifdef __MTK_TARGET__
  438.     mmi_frm_set_key_handle_in_high_frequency(MMI_FALSE);
  439. #endif 
  440.     /* re-enable the keypad tone */
  441.     if (GFX.game_data.is_keypad_audio_enable == FALSE)
  442.     {
  443.         mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_ENABLED);
  444.     }
  445.     /* stop all playing audio and vibration */
  446.     mdi_audio_stop_string();
  447.     VibratorOff();
  448.     /* resume background play */
  449.     mdi_audio_resume_background_play();
  450. #ifdef __MMI_SUBLCD__
  451.     /* resume sublcd */
  452.     GoBackSubLCDHistory();
  453. #endif /* __MMI_SUBLCD__ */ 
  454.     /* write volume setting */
  455.     WriteValue(NVRAM_GFX_AUDIO_VOLUMN, &GFX.aud_volume, DS_BYTE, &error);
  456.     /* let MMI can sleep */
  457.     TurnOffBacklight();
  458. #ifdef __MMI_GAME_MULTICHANNEL_SOUND__
  459. #ifdef __MMI_BT_AUDIO_VIA_SCO__
  460.     if(GFX.is_background_music_on)
  461.     {
  462.         mmi_profiles_bt_enable_sco_timeout();
  463.     }
  464. #endif /* __MMI_BT_AUDIO_VIA_SCO__ */
  465. #endif /* __MMI_GAME_MULTICHANNEL_SOUND__ */
  466. }
  467. /*****************************************************************************
  468.  * FUNCTION
  469.  *  mmi_gfx_enter_game
  470.  * DESCRIPTION
  471.  *  Enter the game
  472.  * PARAMETERS
  473.  *  void
  474.  * RETURNS
  475.  *  void
  476.  *****************************************************************************/
  477. void mmi_gfx_enter_game(void)
  478. {
  479.     /*----------------------------------------------------------------*/
  480.     /* Local Variables                                                */
  481.     /*----------------------------------------------------------------*/
  482.     S16 error;
  483.     /*----------------------------------------------------------------*/
  484.     /* Code Body                                                      */
  485.     /*----------------------------------------------------------------*/
  486.     EntryNewScreen(GFX_GAME_SCREEN, mmi_gfx_exit_game, NULL, NULL);
  487.     /* reset clip */
  488.     gdi_layer_reset_clip();
  489.     gdi_layer_reset_text_clip();
  490.     /* entry full screen app */
  491.     entry_full_screen();
  492.     /* disable the keypad tone */
  493.     if (GFX.game_data.is_keypad_audio_enable == FALSE)
  494.     {
  495.         /* force all playing keypad tone off */
  496.         AudioStopReq(GetCurKeypadTone());
  497.         mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_DISABLED);
  498.     }
  499.     /* read volume setting */
  500.     ReadValue(NVRAM_GFX_AUDIO_VOLUMN, &GFX.aud_volume, DS_BYTE, &error);
  501.     if (GFX.aud_volume == 0xff)
  502.     {
  503.         GFX.aud_volume = LEVEL4;
  504.     }
  505. #ifdef __MMI_GAME_MULTICHANNEL_SOUND__
  506.     mdi_audio_set_volume(MDI_VOLUME_MEDIA, GFX.aud_volume);
  507. #ifdef __MMI_BT_AUDIO_VIA_SCO__
  508.     if(GFX.is_background_music_on)
  509.     {
  510.         mmi_profiles_bt_disable_sco_timeout();
  511.     }
  512. #endif /* __MMI_BT_AUDIO_VIA_SCO__ */
  513. #endif /* __MMI_GAME_MULTICHANNEL_SOUND__ */ 
  514.     GFX.is_first_time_enter_gameover = TRUE;    /* first time enter */
  515.     /* suspend background play */
  516.     mdi_audio_suspend_background_play();
  517.     ClearInputEventHandler(MMI_DEVICE_ALL);
  518.     clear_category_screen_key_handlers();
  519.     SetKeyHandler(GoBackHistory, KEY_LSK, KEY_EVENT_UP);
  520.     SetKeyHandler(GoBackHistory, KEY_RSK, KEY_EVENT_UP);
  521.     SetKeyHandler(mmi_gfx_volume_up, KEY_VOL_UP, KEY_EVENT_DOWN);
  522.     SetKeyHandler(mmi_gfx_volume_down, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  523.     /* reset clip */
  524.     gui_reset_text_clip();
  525.     gui_reset_clip();
  526.     /* 
  527.      * This is used to solve a very rare situation. When playing a IMELODY 
  528.      * with backlight on/off, and the screen previous to this screen is a 
  529.      * horizontal screen. Before enter this screen, the IMELODY turn off the
  530.      * backlight. While exit previous screen, the layer rotate back to normal
  531.      * size and the content is not correct. So when calling TurnOnBacklight, 
  532.      * LCD is in sleepin state and draw wrong content to LCD.
  533.      * So we need to clear the buffer first to avoid this situation.
  534.      */
  535.     gdi_layer_clear(GDI_COLOR_BLACK);
  536.     /* stop MMI sleep */
  537.     TurnOnBacklight(0);
  538. #ifdef __MMI_SUBLCD__
  539.     /* draw game icon on sublcd */
  540.     ForceSubLCDScreen(mmi_gfx_entry_sublcd_screen);
  541. #endif /* __MMI_SUBLCD__ */ 
  542.     /*
  543.      * fill background with white color - 
  544.      * for display smaller game on bigger LCM that will have clear background 
  545.      */
  546.     gui_fill_rectangle(0, 0, UI_device_width - 1, UI_device_height - 1, gui_color(255, 255, 255));
  547.     /* lock and blt, this may force full screen region will be blt when enter game */
  548.     gdi_layer_lock_frame_buffer();
  549.     gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
  550.     gdi_layer_unlock_frame_buffer();
  551.     /* disalbe align timer and enter game */
  552.     UI_disable_alignment_timers();
  553. #ifdef __MTK_TARGET__
  554.     mmi_frm_set_key_handle_in_high_frequency(MMI_TRUE);
  555. #endif 
  556.     GFX.is_resume_game = TRUE;
  557.     PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "*---[GameFramework.c] Enter game: %s---*n",
  558.                          GetString(GFX.game_data.game_str_id)));
  559.     GFX.game_data.enter_game_func_ptr();
  560. }
  561. /*****************************************************************************
  562.  * FUNCTION
  563.  *  mmi_gfx_new_game
  564.  * DESCRIPTION
  565.  *  Enter new game
  566.  * PARAMETERS
  567.  *  void
  568.  * RETURNS
  569.  *  void
  570.  *****************************************************************************/
  571. void mmi_gfx_new_game(void)
  572. {
  573.     /*----------------------------------------------------------------*/
  574.     /* Local Variables                                                */
  575.     /*----------------------------------------------------------------*/
  576.     /*----------------------------------------------------------------*/
  577.     /* Code Body                                                      */
  578.     /*----------------------------------------------------------------*/
  579.     /* reset new game flag */
  580.     *(GFX.game_data.is_new_game) = TRUE;
  581.     mmi_gfx_enter_game();
  582. }
  583. /*****************************************************************************
  584.  * FUNCTION
  585.  *  mmi_gfx_resume_game
  586.  * DESCRIPTION
  587.  *  Enter resume game
  588.  * PARAMETERS
  589.  *  void
  590.  * RETURNS
  591.  *  void
  592.  *****************************************************************************/
  593. void mmi_gfx_resume_game(void)
  594. {
  595.     /*----------------------------------------------------------------*/
  596.     /* Local Variables                                                */
  597.     /*----------------------------------------------------------------*/
  598.     /*----------------------------------------------------------------*/
  599.     /* Code Body                                                      */
  600.     /*----------------------------------------------------------------*/
  601.     *(GFX.game_data.is_new_game) = FALSE;
  602.     mmi_gfx_enter_game();
  603. }
  604. /***************************************************************************
  605. *  Gameover Screen                                            
  606. ***************************************************************************/
  607. /*****************************************************************************
  608.  * FUNCTION
  609.  *  mmi_gfx_store_grade
  610.  * DESCRIPTION
  611.  *  Calculate best grade, write into NVRAM
  612.  * PARAMETERS
  613.  *  void
  614.  * RETURNS
  615.  *  void
  616.  *****************************************************************************/
  617. void mmi_gfx_store_grade(void)
  618. {
  619.     /*----------------------------------------------------------------*/
  620.     /* Local Variables                                                */
  621.     /*----------------------------------------------------------------*/
  622.     S16 error = 0;
  623.     U16 grade = 0;
  624.     U16 best_grade = 0;
  625.     U16 i;
  626.     /*----------------------------------------------------------------*/
  627.     /* Code Body                                                      */
  628.     /*----------------------------------------------------------------*/
  629.     /* if only have one level */
  630.     if (GFX.game_data.level_count == 1)
  631.     {
  632.         ReadValue((U8) (GFX.game_data.grade_nvram_id_list[0]), (void*)&grade, DS_SHORT, &error);
  633.         /* first time write in grade */
  634.         if (grade == 0xffff)
  635.         {
  636.             WriteValue((U8) (GFX.game_data.grade_nvram_id_list[0]), GFX.game_data.grade_value_ptr, DS_SHORT, &error);
  637.             return;
  638.         }
  639.         /* compare to get best grade */
  640.         best_grade = GFX.game_data.best_grade_func_ptr(grade, *(GFX.game_data.grade_value_ptr));
  641.         /* write back best grade to NVRAM */
  642.         WriteValue((U8) (GFX.game_data.grade_nvram_id_list[0]), &best_grade, DS_SHORT, &error);
  643.         return;
  644.     }
  645.     for (i = 0; i < GFX.game_data.level_count; i++)
  646.     {
  647.         /* if current grade equal to index */
  648.         if (i == (*(GFX.game_data.level_index_ptr)))
  649.         {
  650.             ReadValue((U8) (GFX.game_data.grade_nvram_id_list[i]), (void*)&grade, DS_SHORT, &error);
  651.             /* first time write in grade */
  652.             if (grade == 0xffff)
  653.             {
  654.                 WriteValue(
  655.                     (U8) (GFX.game_data.grade_nvram_id_list[i]),
  656.                     GFX.game_data.grade_value_ptr,
  657.                     DS_SHORT,
  658.                     &error);
  659.                 return;
  660.             }
  661.             /* compare to get best grade */
  662.             best_grade = GFX.game_data.best_grade_func_ptr(grade, *(GFX.game_data.grade_value_ptr));
  663.             /* write back best grade to NVRAM */
  664.             WriteValue((U8) (GFX.game_data.grade_nvram_id_list[i]), &best_grade, DS_SHORT, &error);
  665.             return;
  666.         }
  667.     }
  668. }
  669. /*****************************************************************************
  670.  * FUNCTION
  671.  *  mmi_gfx_exit_gameover_screen
  672.  * DESCRIPTION
  673.  *  Exit gameover screen
  674.  * PARAMETERS
  675.  *  void
  676.  * RETURNS
  677.  *  void
  678.  *****************************************************************************/
  679. void mmi_gfx_exit_gameover_screen(void)
  680. {
  681.     /*----------------------------------------------------------------*/
  682.     /* Local Variables                                                */
  683.     /*----------------------------------------------------------------*/
  684.     /*----------------------------------------------------------------*/
  685.     /* Code Body                                                      */
  686.     /*----------------------------------------------------------------*/
  687.     /* stop all playing audio and vibration */
  688.     VibratorOff();
  689.     mdi_audio_stop_string();
  690.     /* resume if there is background playing */
  691.     mdi_audio_resume_background_play();
  692. }
  693. /*****************************************************************************
  694.  * FUNCTION
  695.  *  mmi_gfx_entry_gameover_screen
  696.  * DESCRIPTION
  697.  *  Entry of gameover screen
  698.  * PARAMETERS
  699.  *  void
  700.  * RETURNS
  701.  *  void
  702.  *****************************************************************************/
  703. void mmi_gfx_entry_gameover_screen(void)
  704. {
  705.     /*----------------------------------------------------------------*/
  706.     /* Local Variables                                                */
  707.     /*----------------------------------------------------------------*/
  708.     U8 *guiBuffer;  /* Buffer holding history data */
  709.     /*----------------------------------------------------------------*/
  710.     /* Code Body                                                      */
  711.     /*----------------------------------------------------------------*/
  712.     /* entry full screen app */
  713.     entry_full_screen();
  714.     EntryNewScreen(GFX_GAMEOVER_SCREEN, mmi_gfx_exit_gameover_screen, mmi_gfx_entry_gameover_screen, NULL);
  715.     /* check if is frist time enter, or re-enter because interrupt */
  716.     guiBuffer = GetCurrGuiBuffer(GFX_GAMEOVER_SCREEN);
  717.     /* not first time enter */
  718.     if (guiBuffer != NULL)
  719.     {
  720.         GFX.is_first_time_enter_gameover = FALSE;
  721.     }
  722.     /* suspend background play */
  723.     mdi_audio_suspend_background_play();
  724.     /* store best grade */
  725.     mmi_gfx_store_grade();
  726.     ShowCategory221Screen(
  727.         0,
  728.         0,                                      /* caption */
  729.         STR_GLOBAL_OK,
  730.         IMG_GLOBAL_OK,                          /* LSK */
  731.         0,
  732.         0,                                      /* RSK */
  733.         GDI_COLOR_WHITE,
  734.         GFX.game_data.draw_gameover_func_ptr);  /* redraw callback */
  735.     /* go back to game menu */
  736.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  737.     /* gameover will go back to first menuitem */
  738.     GFX.is_gameover = TRUE;
  739.     SetLeftSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  740. }
  741. /*****************************************************************************
  742.  * FUNCTION
  743.  *  mmi_gfx_draw_gameover_screen
  744.  * DESCRIPTION
  745.  *  draw gameover screen
  746.  * PARAMETERS
  747.  *  text_img_id     [IN]        Text image id
  748.  *  box_img_id      [IN]        Box image id
  749.  *  pic_img_id      [IN]        Picture image id
  750.  *  score           [IN]        Score
  751.  * RETURNS
  752.  *  void
  753.  *****************************************************************************/
  754. void mmi_gfx_draw_gameover_screen(U16 text_img_id, U16 box_img_id, U16 pic_img_id, S32 score)
  755. {
  756.     /*----------------------------------------------------------------*/
  757.     /* Local Variables                                                */
  758.     /*----------------------------------------------------------------*/
  759.     U8 buffer[64];
  760.     U8 buffer_UCS2[64];
  761.     S32 text_image_width;
  762.     S32 text_image_height;
  763.     S32 box_image_width;
  764.     S32 box_image_height;
  765.     S32 pic_image_width;
  766.     S32 pic_image_height;
  767.     S32 text_image_offset_y;
  768.     S32 box_image_offset_y;
  769.     S32 pic_image_offset_y;
  770.     S32 score_str_offset_y;
  771.     S32 score_str_offset_x;
  772.     S32 str_width;
  773.     S32 str_height;
  774.     S32 spacing;
  775.     /*----------------------------------------------------------------*/
  776.     /* Code Body                                                      */
  777.     /*----------------------------------------------------------------*/
  778.     gui_reset_clip();
  779.     gui_reset_text_clip();
  780.     gui_set_font(&MMI_medium_font);
  781.     /* get image size */
  782.     gui_measure_image(get_image(text_img_id), &text_image_width, &text_image_height);
  783.     gui_measure_image(get_image(box_img_id), &box_image_width, &box_image_height);
  784.     gui_measure_image(get_image(pic_img_id), &pic_image_width, &pic_image_height);
  785.     spacing =
  786.         (UI_device_height - MMI_button_bar_height - (text_image_height + box_image_height + pic_image_height)) >> 2;
  787.     text_image_offset_y = spacing;
  788.     box_image_offset_y = text_image_offset_y + text_image_height + spacing;
  789.     pic_image_offset_y = box_image_offset_y + box_image_height + spacing;
  790.     gui_show_transparent_image(
  791.         (UI_device_width - text_image_width) >> 1,
  792.         text_image_offset_y,
  793.         get_image(text_img_id),
  794.         0);
  795.     gui_show_transparent_image((UI_device_width - box_image_width) >> 1, box_image_offset_y, get_image(box_img_id), 0);
  796.     gui_show_transparent_image((UI_device_width - pic_image_width) >> 1, pic_image_offset_y, get_image(pic_img_id), 0);
  797.     sprintf((PS8) buffer, "%d", (S16) score);
  798.     AnsiiToUnicodeString((PS8) buffer_UCS2, (PS8) buffer);
  799.     gui_measure_string((UI_string_type) buffer_UCS2, &str_width, &str_height);
  800.     score_str_offset_x = (UI_device_width - str_width) >> 1;
  801.     score_str_offset_y = box_image_offset_y + ((box_image_height - str_height) >> 1);
  802.     gui_set_text_color(gui_color(0, 0, 0));
  803.     if (r2lMMIFlag)
  804.     {
  805.         gui_move_text_cursor(score_str_offset_x + str_width, score_str_offset_y);
  806.     }
  807.     else
  808.     {
  809.         gui_move_text_cursor(score_str_offset_x, score_str_offset_y);
  810.     }
  811.     gui_print_text((UI_string_type) buffer_UCS2);
  812.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
  813. }
  814. /***************************************************************************
  815. *  Game Level Screen                                    
  816. ***************************************************************************/
  817. /*****************************************************************************
  818.  * FUNCTION
  819.  *  mmi_gfx_set_game_level
  820.  * DESCRIPTION
  821.  *  Set game level in the NVRAM
  822.  * PARAMETERS
  823.  *  void
  824.  * RETURNS
  825.  *  void
  826.  *****************************************************************************/
  827. void mmi_gfx_set_game_level(void)
  828. {
  829.     /*----------------------------------------------------------------*/
  830.     /* Local Variables                                                */
  831.     /*----------------------------------------------------------------*/
  832.     S16 error;
  833.     /*----------------------------------------------------------------*/
  834.     /* Code Body                                                      */
  835.     /*----------------------------------------------------------------*/
  836.     (*(GFX.game_data.level_index_ptr)) = (U8) GFX.hilight_index;
  837.     WriteValue(GFX.game_data.level_nvram_id, GFX.game_data.level_index_ptr, DS_BYTE, &error);
  838.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, GAME_NOTIFYDURATION, SUCCESS_TONE);
  839.     DeleteUptoScrID(GFX_MENU_SCREEN);
  840.     *(GFX.game_data.is_new_game) = TRUE;
  841.     GFX.is_level_changed = TRUE;
  842. }
  843. // KP Jerry add for game type on 2007-3-22 start
  844. /***************************************************************************
  845. *  Game Type Screen                                    
  846. ***************************************************************************/
  847. /*****************************************************************************
  848.  * FUNCTION
  849.  *  mmi_gfx_set_game_type
  850.  * DESCRIPTION
  851.  *  Set game type in the NVRAM
  852.  * PARAMETERS
  853.  *  void
  854.  * RETURNS
  855.  *  void
  856.  *****************************************************************************/
  857. void mmi_gfx_set_game_type(void)
  858. {
  859.     /*----------------------------------------------------------------*/
  860.     /* Local Variables                                                */
  861.     /*----------------------------------------------------------------*/
  862.     S16 error;
  863.     /*----------------------------------------------------------------*/
  864.     /* Code Body                                                      */
  865.     /*----------------------------------------------------------------*/
  866.     (*(GFX.game_data.type_index_ptr)) = (U8) GFX.hilight_index;
  867.     WriteValue(GFX.game_data.type_nvram_id, GFX.game_data.type_index_ptr, DS_BYTE, &error);
  868.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, GAME_NOTIFYDURATION, SUCCESS_TONE);
  869.     DeleteUptoScrID(GFX_MENU_SCREEN);
  870.     *(GFX.game_data.is_new_game) = TRUE;
  871.     GFX.is_type_changed = TRUE;
  872. }
  873. // KP Jerry add for game type on 2007-3-22 end
  874. /*****************************************************************************
  875.  * FUNCTION
  876.  *  mmi_gfx_set_level_highlight_hdlr
  877.  * DESCRIPTION
  878.  *  Get current hilight index
  879.  * PARAMETERS
  880.  *  index       [IN]        Hilight index
  881.  * RETURNS
  882.  *  void
  883.  *****************************************************************************/
  884. void mmi_gfx_set_level_highlight_hdlr(S32 index)
  885. {
  886.     /*----------------------------------------------------------------*/
  887.     /* Local Variables                                                */
  888.     /*----------------------------------------------------------------*/
  889.     /*----------------------------------------------------------------*/
  890.     /* Code Body                                                      */
  891.     /*----------------------------------------------------------------*/
  892.     GFX.hilight_index = index;
  893. }
  894. // KP Jerry add for game type on 2007-3-22 start
  895. /*****************************************************************************
  896.  * FUNCTION
  897.  *  mmi_gfx_set_level_highlight_hdlr
  898.  * DESCRIPTION
  899.  *  Get current hilight index
  900.  * PARAMETERS
  901.  *  index       [IN]        Hilight index
  902.  * RETURNS
  903.  *  void
  904.  *****************************************************************************/
  905. void mmi_gfx_set_type_highlight_hdlr(S32 index)
  906. {
  907.     /*----------------------------------------------------------------*/
  908.     /* Local Variables                                                */
  909.     /*----------------------------------------------------------------*/
  910.     /*----------------------------------------------------------------*/
  911.     /* Code Body                                                      */
  912.     /*----------------------------------------------------------------*/
  913.     GFX.hilight_index = index;
  914. }
  915. // KP Jerry add for game type on 2007-3-22 end
  916. /*****************************************************************************
  917.  * FUNCTION
  918.  *  mmi_gfx_entry_level_screen
  919.  * DESCRIPTION
  920.  *  Entry level screen
  921.  * PARAMETERS
  922.  *  void
  923.  * RETURNS
  924.  *  void
  925.  *****************************************************************************/
  926. void mmi_gfx_entry_level_screen(void)
  927. {
  928.     /*----------------------------------------------------------------*/
  929.     /* Local Variables                                                */
  930.     /*----------------------------------------------------------------*/
  931.     U8 *guiBuffer;  /* Buffer holding history data */
  932.     U16 i;
  933.     U16 level_str_list[GFX_MAX_LEVEL_COUNT];
  934.     /*----------------------------------------------------------------*/
  935.     /* Code Body                                                      */
  936.     /*----------------------------------------------------------------*/
  937.     EntryNewScreen(GFX_LEVEL_SCREEN, NULL, mmi_gfx_entry_level_screen, NULL);
  938.     for (i = 0; i < GFX.game_data.level_count; i++)
  939.     {
  940.         level_str_list[i] = GFX.game_data.level_str_id_list[i];
  941.     }
  942.     guiBuffer = GetCurrGuiBuffer(GFX_LEVEL_SCREEN);
  943.     RegisterHighlightHandler(mmi_gfx_set_level_highlight_hdlr);
  944.     ShowCategory11Screen(
  945.         GFX.game_data.game_str_id,
  946.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  947.         STR_GLOBAL_OK,
  948.         IMG_GLOBAL_OK,
  949.         STR_GLOBAL_BACK,
  950.         IMG_GLOBAL_BACK,
  951.         GFX.game_data.level_count,
  952.         level_str_list,
  953.         *(GFX.game_data.level_index_ptr),
  954.         guiBuffer);
  955.     /* go back to game menu */
  956.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  957.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  958.     SetLeftSoftkeyFunction(mmi_gfx_set_game_level, KEY_EVENT_UP);
  959. }
  960. // KP Jerry add for game type on 2007-3-22 start
  961. /***************************************************************************
  962. *  Game type Menu                                 
  963. ***************************************************************************/
  964. /*****************************************************************************
  965.  * FUNCTION
  966.  *  mmi_gfx_entry_level_screen
  967.  * DESCRIPTION
  968.  *  Entry level screen
  969.  * PARAMETERS
  970.  *  void
  971.  * RETURNS
  972.  *  void
  973.  *****************************************************************************/
  974. void mmi_gfx_entry_type_screen(void)
  975. {
  976.     /*----------------------------------------------------------------*/
  977.     /* Local Variables                                                */
  978.     /*----------------------------------------------------------------*/
  979.     U8 *guiBuffer;  /* Buffer holding history data */
  980.     U16 i;
  981.     U16 type_str_list[GFX_MAX_TYPE_COUNT];
  982.     /*----------------------------------------------------------------*/
  983.     /* Code Body                                                      */
  984.     /*----------------------------------------------------------------*/
  985.     EntryNewScreen(GFX_TYPE_SCREEN, NULL, mmi_gfx_entry_type_screen, NULL);
  986.     for (i = 0; i < GFX.game_data.type_count; i++)
  987.     {
  988.         type_str_list[i] = GFX.game_data.type_str_id_list[i];
  989.     }
  990.     guiBuffer = GetCurrGuiBuffer(GFX_TYPE_SCREEN);
  991.     RegisterHighlightHandler(mmi_gfx_set_type_highlight_hdlr);
  992.     ShowCategory11Screen(
  993.         GFX.game_data.game_str_id,
  994.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  995.         STR_GLOBAL_OK,
  996.         IMG_GLOBAL_OK,
  997.         STR_GLOBAL_BACK,
  998.         IMG_GLOBAL_BACK,
  999.         GFX.game_data.type_count,
  1000.         type_str_list,
  1001.         *(GFX.game_data.type_index_ptr),
  1002.         guiBuffer);
  1003.     /* go back to game menu */
  1004.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1005.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1006.     SetLeftSoftkeyFunction(mmi_gfx_set_game_type, KEY_EVENT_UP);
  1007. }
  1008. // KP Jerry add for game type on 2007-3-22 end
  1009. /***************************************************************************
  1010. *  Game Help Menu                                 
  1011. ***************************************************************************/
  1012. /*****************************************************************************
  1013.  * FUNCTION
  1014.  *  mmi_gfx_entry_help_screen
  1015.  * DESCRIPTION
  1016.  *  Entry help screen
  1017.  * PARAMETERS
  1018.  *  void
  1019.  * RETURNS
  1020.  *  void
  1021.  *****************************************************************************/
  1022. void mmi_gfx_entry_help_screen(void)
  1023. {
  1024.     /*----------------------------------------------------------------*/
  1025.     /* Local Variables                                                */
  1026.     /*----------------------------------------------------------------*/
  1027.     PS8 buffer;
  1028.     S32 bufferSize;
  1029.     /*----------------------------------------------------------------*/
  1030.     /* Code Body                                                      */
  1031.     /*----------------------------------------------------------------*/
  1032.     EntryNewScreen(GFX_HELP_SCREEN, NULL, mmi_gfx_entry_help_screen, NULL);
  1033.     buffer = GetString(GFX.game_data.help_str_id);
  1034.     bufferSize = pfnUnicodeStrlen(buffer);
  1035.     ShowCategory74Screen(
  1036.         GFX.game_data.menu_help_str_id,
  1037.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  1038.         0,
  1039.         0,
  1040.         STR_GLOBAL_BACK,
  1041.         IMG_GLOBAL_BACK,
  1042.         (PU8) buffer,
  1043.         bufferSize,
  1044.         NULL);
  1045.     /* go back to game menu */
  1046.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1047.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1048. }
  1049. /***************************************************************************
  1050. *  Game Grade Menu                                
  1051. ***************************************************************************/
  1052. /*****************************************************************************
  1053.  * FUNCTION
  1054.  *  mmi_gfx_reset_grade
  1055.  * DESCRIPTION
  1056.  *  Reset all grade in NVRAM
  1057.  * PARAMETERS
  1058.  *  void
  1059.  * RETURNS
  1060.  *  void
  1061.  *****************************************************************************/
  1062. void mmi_gfx_reset_grade(void)
  1063. {
  1064.     /*----------------------------------------------------------------*/
  1065.     /* Local Variables                                                */
  1066.     /*----------------------------------------------------------------*/
  1067.     U16 rest_score = 0;
  1068.     S16 error;
  1069.     U8 *display_str_ptr;
  1070.     U16 i;
  1071.     /*----------------------------------------------------------------*/
  1072.     /* Code Body                                                      */
  1073.     /*----------------------------------------------------------------*/
  1074.     for (i = 0; i < GFX.game_data.level_count; i++)
  1075.     {
  1076.         WriteValue((U8) (GFX.game_data.grade_nvram_id_list[i]), &rest_score, DS_SHORT, &error);
  1077.     }
  1078.     display_str_ptr = (PU8) GetString(STR_GLOBAL_DONE);
  1079.     DisplayPopup(display_str_ptr, IMG_GLOBAL_ACTIVATED, 1, GAME_NOTIFYDURATION, SUCCESS_TONE);
  1080.     DeleteUptoScrID(GFX_MENU_SCREEN);
  1081. }
  1082. /*****************************************************************************
  1083.  * FUNCTION
  1084.  *  mmi_gfx_entry_grade_screen
  1085.  * DESCRIPTION
  1086.  *  Entry point of grade screen
  1087.  * PARAMETERS
  1088.  *  void
  1089.  * RETURNS
  1090.  *  void
  1091.  *****************************************************************************/
  1092. void mmi_gfx_entry_grade_screen(void)
  1093. {
  1094.     /*----------------------------------------------------------------*/
  1095.     /* Local Variables                                                */
  1096.     /*----------------------------------------------------------------*/
  1097.     U8 i;
  1098.     U16 data;
  1099.     S16 error;
  1100.     U8 *guiBuffer;
  1101.     S8 *gameLevelList[MAX_SUB_MENUS];
  1102.     U8 buffer[MAX_SUB_MENU_SIZE];
  1103.     U8 buffer_UCS2[MAX_SUB_MENU_SIZE];
  1104.     /*----------------------------------------------------------------*/
  1105.     /* Code Body                                                      */
  1106.     /*----------------------------------------------------------------*/
  1107.     EntryNewScreen(GFX_GRADE_SCREEN, NULL, mmi_gfx_entry_grade_screen, NULL);
  1108.     guiBuffer = GetCurrGuiBuffer(GFX_GRADE_SCREEN);
  1109.     for (i = 0; i < GFX.game_data.level_count; i++)
  1110.     {
  1111.         gameLevelList[i] = (PS8) GetString(GFX.game_data.level_str_id_list[i]);
  1112.         /* score string */
  1113.         ReadValue((U8) GFX.game_data.grade_nvram_id_list[i], &data, DS_SHORT, &error);
  1114.         if (data == 0xffff)
  1115.         {
  1116.             data = 0;
  1117.             WriteValue((U8) GFX.game_data.grade_nvram_id_list[i], &data, DS_SHORT, &error);
  1118.         }
  1119.         sprintf((PS8) buffer, "%d", data);
  1120.         AnsiiToUnicodeString((PS8) buffer_UCS2, (PS8) buffer);
  1121.         pfnUnicodeStrcpy((PS8) subMenuDataPtrs[i], (PS8) buffer_UCS2);
  1122.     }
  1123.     ShowCategory153Screen(
  1124.         GFX.game_data.game_str_id,
  1125.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  1126.         STR_GAME_RESET,
  1127.         0,
  1128.         STR_GLOBAL_BACK,
  1129.         IMG_GLOBAL_BACK,
  1130.         GFX.game_data.level_count,
  1131.         (U8 **) gameLevelList,
  1132.         subMenuDataPtrs,
  1133.         0,
  1134.         guiBuffer);
  1135. #ifdef __MMI_TOUCH_SCREEN__
  1136.     /* disable the click resopnse which returns ok! */
  1137.     wgui_register_list_item_selected_callback_all(UI_dummy_function);
  1138. #endif /* __MMI_TOUCH_SCREEN__ */ 
  1139.     SetLeftSoftkeyFunction(mmi_gfx_reset_grade, KEY_EVENT_UP);
  1140.     /* go back to game menu */
  1141.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1142.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1143. }
  1144. /***************************************************************************
  1145. *  Game Main Menu                              
  1146. ***************************************************************************/
  1147. /*****************************************************************************
  1148.  * FUNCTION
  1149.  *  mmi_gfx_menu_hilight_hdlr
  1150.  * DESCRIPTION
  1151.  *  Game menu screen hilight handler
  1152.  * PARAMETERS
  1153.  *  index       [IN]        Hilight index
  1154.  * RETURNS
  1155.  *  void
  1156.  *****************************************************************************/
  1157. void mmi_gfx_menu_hilight_hdlr(S32 index)
  1158. {
  1159.     /*----------------------------------------------------------------*/
  1160.     /* Local Variables                                                */
  1161.     /*----------------------------------------------------------------*/
  1162.     S32 i = 0;
  1163.     /*----------------------------------------------------------------*/
  1164.     /* Code Body                                                      */
  1165.     /*----------------------------------------------------------------*/
  1166.     if ((*(GFX.game_data.is_new_game)) == FALSE)
  1167.     {
  1168.         /* Resume game */
  1169.         if (GFX.game_data.menu_resume_str_id != 0)  /* has level menu */
  1170.         {
  1171.             if (index == i)
  1172.             {
  1173.                 SetLeftSoftkeyFunction(mmi_gfx_resume_game, KEY_EVENT_UP);
  1174.                 ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1175.             }
  1176.             i++;
  1177.         }
  1178.     }
  1179.     /* new game menu item */
  1180.     if (index == i) /* new game [REQUIRED] */
  1181.     {
  1182.         SetLeftSoftkeyFunction(mmi_gfx_new_game, KEY_EVENT_UP);
  1183.         ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1184.     }
  1185.     /* has level menu item */
  1186.     if (GFX.game_data.menu_level_str_id != 0)
  1187.     {
  1188.         i++;
  1189.         if (index == i)
  1190.         {
  1191.             SetLeftSoftkeyFunction(mmi_gfx_entry_level_screen, KEY_EVENT_UP);
  1192.             SetKeyHandler(mmi_gfx_entry_level_screen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1193.         }
  1194.     }
  1195. // KP Jerry add for game type on 2007-3-22 start
  1196.      /* has type menu item */
  1197.     if (GFX.game_data.menu_type_str_id != 0)
  1198.     {
  1199.         i++;
  1200.         if (index == i)
  1201.         {
  1202.             SetLeftSoftkeyFunction(mmi_gfx_entry_type_screen, KEY_EVENT_UP);
  1203.             SetKeyHandler(mmi_gfx_entry_type_screen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1204.         }
  1205.     }
  1206. // KP Jerry add for game type on 2007-3-22 end
  1207.     /* has grade menu item */
  1208.     if (GFX.game_data.menu_grade_str_id != 0)
  1209.     {
  1210.         i++;
  1211.         if (index == i)
  1212.         {
  1213.             SetLeftSoftkeyFunction(mmi_gfx_entry_grade_screen, KEY_EVENT_UP);
  1214.             SetKeyHandler(mmi_gfx_entry_grade_screen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1215.         }
  1216.     }
  1217.     /* has help menu item */
  1218.     if (GFX.game_data.menu_help_str_id != 0)
  1219.     {
  1220.         i++;
  1221.         if (index == i)
  1222.         {
  1223.             SetLeftSoftkeyFunction(mmi_gfx_entry_help_screen, KEY_EVENT_UP);
  1224.             SetKeyHandler(mmi_gfx_entry_help_screen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1225.         }
  1226.     }
  1227. }
  1228. /*****************************************************************************
  1229.  * FUNCTION
  1230.  *  mmi_gfx_entry_menu_screen
  1231.  * DESCRIPTION
  1232.  *  Game menu screen entry point
  1233.  * PARAMETERS
  1234.  *  void
  1235.  * RETURNS
  1236.  *  void
  1237.  *****************************************************************************/
  1238. void mmi_gfx_entry_menu_screen(void)
  1239. {
  1240.     /*----------------------------------------------------------------*/
  1241.     /* Local Variables                                                */
  1242.     /*----------------------------------------------------------------*/
  1243.     U8 *guiBuffer;                              /* Buffer holding history data */
  1244.     U16 menu_str_list[GFX_MAX_MENU_ITEM_COUNT]; /* Stores the strings id of submenus returned */
  1245.     U16 menu_img_list[GFX_MAX_MENU_ITEM_COUNT] = {IMG_GLOBAL_L1, IMG_GLOBAL_L2, IMG_GLOBAL_L3,
  1246.         IMG_GLOBAL_L4, IMG_GLOBAL_L5, IMG_GLOBAL_L6,
  1247.         IMG_GLOBAL_L7, IMG_GLOBAL_L8, IMG_GLOBAL_L9
  1248.     };
  1249.     U16 i = 0;
  1250.     S16 error;
  1251.     U8 data;
  1252.     U8 datatemp;     //KP Jerry add on 2007-3-23
  1253.     /*----------------------------------------------------------------*/
  1254.     /* Code Body                                                      */
  1255.     /*----------------------------------------------------------------*/
  1256.     EntryNewScreen(GFX_MENU_SCREEN, NULL, mmi_gfx_entry_menu_screen, NULL);
  1257.     guiBuffer = GetCurrGuiBuffer(GFX_MENU_SCREEN);
  1258.     /* load level */
  1259.     if (GFX.game_data.menu_level_str_id != 0)
  1260.     {
  1261.         ReadValue(GFX.game_data.level_nvram_id, &data, DS_BYTE, &error);
  1262. datatemp= data;     //KP Jerry add on 2007-3-23
  1263.         if (data == 0xFF)
  1264.         {
  1265.             /* init */
  1266.             *GFX.game_data.level_index_ptr = 0;
  1267.         }
  1268.         else
  1269.         {
  1270.             *GFX.game_data.level_index_ptr = data;
  1271.         }
  1272.     }
  1273.     /* if change level, set selection back to first */
  1274.     if (GFX.is_level_changed)
  1275.     {
  1276.         if (guiBuffer != NULL)
  1277.         {
  1278.             guiBuffer[0] = 0;
  1279.         }
  1280.         GFX.is_level_changed = FALSE;
  1281.     }
  1282. //KP Jerry add for vsmj type on 2007-3-21 start
  1283.      /* load type */
  1284.     if (GFX.game_data.menu_type_str_id != 0)
  1285.     {
  1286.         ReadValue(GFX.game_data.type_nvram_id, &data, DS_BYTE, &error);
  1287. datatemp= data;
  1288.         if (data == 0xFF)
  1289.         {
  1290.             /* init */
  1291.             *GFX.game_data.type_index_ptr = 0;
  1292.         }
  1293.         else
  1294.         {
  1295.             *GFX.game_data.type_index_ptr = data;
  1296.         }
  1297.     }
  1298.     /* if change type, set selection back to first */
  1299.     if (GFX.is_type_changed)
  1300.     {
  1301.         if (guiBuffer != NULL)
  1302.         {
  1303.             guiBuffer[0] = 0;
  1304.         }
  1305.         GFX.is_type_changed = FALSE;
  1306.     }
  1307. //KP Jerry add for vsmj type on 2007-3-21 end
  1308.     /* if gameover, back to first selection */
  1309.     if (GFX.is_gameover)
  1310.     {
  1311.         if (guiBuffer != NULL)
  1312.         {
  1313.             guiBuffer[0] = 0;
  1314.         }
  1315.         GFX.is_gameover = FALSE;
  1316.     }
  1317.     if (GFX.is_resume_game == TRUE)
  1318.     {
  1319.         if (guiBuffer != NULL)
  1320.         {
  1321.             guiBuffer[0] = 0;
  1322.         }
  1323.         GFX.is_resume_game = FALSE;
  1324.     }
  1325.     if ((*(GFX.game_data.is_new_game)) == FALSE)
  1326.     {
  1327.         menu_str_list[i++] = GFX.game_data.menu_resume_str_id;
  1328.     }
  1329.     menu_str_list[i++] = GFX.game_data.menu_new_str_id;
  1330.     if (GFX.game_data.menu_level_str_id != 0)
  1331.     {
  1332.         menu_str_list[i++] = GFX.game_data.menu_level_str_id;
  1333.     }
  1334. //KP Jerry add for vsmj type on 2007-3-21 start
  1335.      if (GFX.game_data.menu_type_str_id != 0)
  1336.     {
  1337.         menu_str_list[i++] = GFX.game_data.menu_type_str_id;
  1338.     }
  1339. //KP Jerry add for vsmj type on 2007-3-21 end
  1340.     menu_str_list[i++] = GFX.game_data.menu_grade_str_id;
  1341.     menu_str_list[i++] = GFX.game_data.menu_help_str_id;
  1342.     RegisterHighlightHandler(mmi_gfx_menu_hilight_hdlr);
  1343.     ShowCategory15Screen(
  1344.         GFX.game_data.game_str_id,
  1345.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  1346.         STR_GLOBAL_OK,
  1347.         IMG_GLOBAL_OK,
  1348.         STR_GLOBAL_BACK,
  1349.         IMG_GLOBAL_BACK,
  1350.         i,
  1351.         menu_str_list,
  1352.         menu_img_list,
  1353.         LIST_MENU,
  1354.         0,
  1355.         guiBuffer);
  1356.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1357.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1358. }
  1359. /*****************************************************************************
  1360.  * FUNCTION
  1361.  *  mmi_gfx_store_setting
  1362.  * DESCRIPTION
  1363.  *  store game setting back to NVRAM
  1364.  * PARAMETERS
  1365.  *  void
  1366.  * RETURNS
  1367.  *  void
  1368.  *****************************************************************************/
  1369. void mmi_gfx_store_setting(void)
  1370. {
  1371.     /*----------------------------------------------------------------*/
  1372.     /* Local Variables                                                */
  1373.     /*----------------------------------------------------------------*/
  1374.     S16 error;
  1375.     /*----------------------------------------------------------------*/
  1376.     /* Code Body                                                      */
  1377.     /*----------------------------------------------------------------*/
  1378. #ifdef __MMI_GAME_MULTICHANNEL_SOUND__
  1379.     WriteValue(NVRAM_GFX_BACKGROUND_MUSIC_SETTING, &GFX.is_background_music_on, DS_BYTE, &error);
  1380.     WriteValue(NVRAM_GFX_SOUND_EFFECT_SETTING, &GFX.is_sound_effect_on, DS_BYTE, &error);
  1381. #else /* __MMI_GAME_MULTICHANNEL_SOUND__ */ 
  1382.     WriteValue(NVRAM_GFX_AUDIO_SETTING, &GFX.is_aud_on, DS_BYTE, &error);
  1383. #endif /* __MMI_GAME_MULTICHANNEL_SOUND__ */ 
  1384.     WriteValue(NVRAM_GFX_VIBRATION_SETTING, &GFX.is_vib_on, DS_BYTE, &error);
  1385. }
  1386. /*****************************************************************************
  1387.  * FUNCTION
  1388.  *  mmi_gfx_load_setting
  1389.  * DESCRIPTION
  1390.  *  load game setting from NVRAM
  1391.  * PARAMETERS
  1392.  *  void
  1393.  * RETURNS
  1394.  *  void
  1395.  *****************************************************************************/
  1396. void mmi_gfx_load_setting(void)
  1397. {
  1398.     /*----------------------------------------------------------------*/
  1399.     /* Local Variables                                                */
  1400.     /*----------------------------------------------------------------*/
  1401.     S16 error;
  1402.     /*----------------------------------------------------------------*/
  1403.     /* Code Body                                                      */
  1404.     /*----------------------------------------------------------------*/
  1405. #ifdef __MMI_GAME_MULTICHANNEL_SOUND__
  1406.     ReadValue(NVRAM_GFX_BACKGROUND_MUSIC_SETTING, &GFX.is_background_music_on, DS_BYTE, &error);
  1407.     /* GFX.is_background_music_on = 0xff; */
  1408.     /* if not init, init as ON */
  1409.     if (GFX.is_background_music_on == 0xff)
  1410.     {
  1411.         GFX.is_background_music_on = TRUE;
  1412.         WriteValue(NVRAM_GFX_BACKGROUND_MUSIC_SETTING, &GFX.is_background_music_on, DS_BYTE, &error);
  1413.     }
  1414.     ReadValue(NVRAM_GFX_SOUND_EFFECT_SETTING, &GFX.is_sound_effect_on, DS_BYTE, &error);
  1415.     /* GFX.is_sound_effect_on = 0xff; */
  1416.     /* if not init, init as ON */
  1417.     if (GFX.is_sound_effect_on == 0xff)
  1418.     {
  1419.         GFX.is_sound_effect_on = TRUE;
  1420.         WriteValue(NVRAM_GFX_SOUND_EFFECT_SETTING, &GFX.is_sound_effect_on, DS_BYTE, &error);
  1421.     }
  1422. #else /* __MMI_GAME_MULTICHANNEL_SOUND__ */ 
  1423.     ReadValue(NVRAM_GFX_AUDIO_SETTING, &GFX.is_aud_on, DS_BYTE, &error);
  1424.     /* if not init, init as ON */
  1425.     if (GFX.is_aud_on == 0xff)
  1426.     {
  1427.         GFX.is_aud_on = TRUE;
  1428.         WriteValue(NVRAM_GFX_AUDIO_SETTING, &GFX.is_aud_on, DS_BYTE, &error);
  1429.     }
  1430. #endif /* __MMI_GAME_MULTICHANNEL_SOUND__ */ 
  1431.     ReadValue(NVRAM_GFX_VIBRATION_SETTING, &GFX.is_vib_on, DS_BYTE, &error);
  1432.     /* if not init, init as ON */
  1433.     if (GFX.is_vib_on == 0xff)
  1434.     {
  1435.         GFX.is_vib_on = TRUE;
  1436.         WriteValue(NVRAM_GFX_VIBRATION_SETTING, &GFX.is_vib_on, DS_BYTE, &error);
  1437.     }
  1438. }
  1439. /*****************************************************************************
  1440.  * FUNCTION
  1441.  *  mmi_gfx_is_aud_on
  1442.  * DESCRIPTION
  1443.  *  is audio on
  1444.  * PARAMETERS
  1445.  *  void
  1446.  * RETURNS
  1447.  * BOOL
  1448.  *****************************************************************************/
  1449. BOOL mmi_gfx_is_aud_on(void)
  1450. {
  1451.     /*----------------------------------------------------------------*/
  1452.     /* Local Variables                                                */
  1453.     /*----------------------------------------------------------------*/
  1454.     /*----------------------------------------------------------------*/
  1455.     /* Code Body                                                      */
  1456.     /*----------------------------------------------------------------*/
  1457. #ifdef __MMI_GAME_MULTICHANNEL_SOUND__
  1458.     return GFX.is_sound_effect_on;
  1459. #else 
  1460.     return GFX.is_aud_on;
  1461. #endif 
  1462. }
  1463. /*****************************************************************************
  1464.  * FUNCTION
  1465.  *  mmi_gfx_is_vib_on
  1466.  * DESCRIPTION
  1467.  *  is vibration on
  1468.  * PARAMETERS
  1469.  *  void
  1470.  * RETURNS
  1471.  * BOOL
  1472.  *****************************************************************************/
  1473. BOOL mmi_gfx_is_vib_on(void)
  1474. {
  1475.     /*----------------------------------------------------------------*/
  1476.     /* Local Variables                                                */
  1477.     /*----------------------------------------------------------------*/
  1478.     /*----------------------------------------------------------------*/
  1479.     /* Code Body                                                      */
  1480.     /*----------------------------------------------------------------*/
  1481.     return GFX.is_vib_on;
  1482. }
  1483. /*****************************************************************************
  1484.  * FUNCTION
  1485.  *  mmi_gfx_get_audio_vol
  1486.  * DESCRIPTION
  1487.  *  get audio volume
  1488.  * PARAMETERS
  1489.  *  void
  1490.  * RETURNS
  1491.  * BOOL
  1492.  *****************************************************************************/
  1493. U8 mmi_gfx_get_audio_vol(void)
  1494. {
  1495.     /*----------------------------------------------------------------*/
  1496.     /* Local Variables                                                */
  1497.     /*----------------------------------------------------------------*/
  1498.     /*----------------------------------------------------------------*/
  1499.     /* Code Body                                                      */
  1500.     /*----------------------------------------------------------------*/
  1501.     return GFX.aud_volume;
  1502. }
  1503. #ifdef __MMI_SUBLCD__
  1504. /*****************************************************************************
  1505.  * FUNCTION
  1506.  *  mmi_gfx_entry_sublcd_screen
  1507.  * DESCRIPTION
  1508.  *  entry sublcd
  1509.  * PARAMETERS
  1510.  *  void
  1511.  * RETURNS
  1512.  *  void
  1513.  * BOOL
  1514.  *****************************************************************************/
  1515. void mmi_gfx_entry_sublcd_screen(void)
  1516. {
  1517.     /*----------------------------------------------------------------*/
  1518.     /* Local Variables                                                */
  1519.     /*----------------------------------------------------------------*/
  1520.     /*----------------------------------------------------------------*/
  1521.     /* Code Body                                                      */
  1522.     /*----------------------------------------------------------------*/
  1523.     ExecSubLCDCurrExitHandler();
  1524.     ShowCategory332Screen(IMG_ID_GAME_SUBLCD_ICON);
  1525. }
  1526. #endif /* __MMI_SUBLCD__ */ 
  1527. #endif /* __MMI_GAME__ */