⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 games_cargador.c

📁 几个嵌入式手机平台小游戏c源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
#ifdef __cplusplus
extern "C" {
#endif


/*==================================================================================================

    MODULE NAME : module-filename.c

    GENERAL DESCRIPTION
        General description of this grouping of functions.

    TECHFAITH Telecom Confidential Proprietary
    (c) Copyright 2002 by TECHFAITH Telecom Corp. All Rights Reserved.
====================================================================================================

    Revision History
   
    Modification                  Tracking
    Date         Author           Number      Description of changes
    ----------   --------------   ---------   -----------------------------------------------------------------------------------
    MM/DD/YYYY   name of author   crxxxxx     Brief description of changes made

    03/03/2003   Steven Lai      PP00132      Change some popup timer from absolute number to default value 
    03/01/2003   Steven Lai      PC00009      Restructure Games app
    03/13/2003   Steven Lai      PP00159      Removed some useless code

    04/25/2003   Steven Lai      P000166      Changed the values of rowNum and colNum from fixed number to results 
                                              of formula, so the same code can fit to different screen size
                                              
    03-05-29   Chenyu          P000466      Display  the picture of  game  cargoder animation   & fix sublcd   display

    03-06-3   Chenyu           P00502       Fix game tetris
    03-06-24  Chenyu           P00666     Fix bugs of games
                                       - 1.in game cargador, missed call will stop animation.
                                       - 2.in game help incoming missed call, softkey display wrong.
                                       - 3.it can't exit highscroe by press "Back"
                                       - 4.it can't back exit game by press "CLR"

    07/02/2003   Steven Lai       C000662     Add a sound-switch for Games App
                                              replace all the App_change_state() with Games_change_state()
                                              fixed some bugs

    07/11/2003   Steven Lai       P000887     1. Stop the guy's action if the user didn't press key for a while
                                              2. Replace some reduplicated levels with new ones (cargador)
                                              3. When user press any key, stop the audio

    03-09-10       lixingbo          C001812      Add the touch function
    03-10-22       lixingbo          P001790       Modify the path of the cargador game.
    02/24/2004   lixingbo           p002467    Modify the game for dolphin.
    03/22/2004   chouwangyun   p002678          modify cargador softkey display game problem
    03/29/2004   lixingbo           p002775    Modify the some bug  for dolphin.
    04/14/2004   lixingbo           p002994    Modify some bug for dolphin.
    04/24/2004   lixingbo           p005089    Modify some bugs.
    09/18/2004   lixingbo           p006238    Fix the bug that wrong paint after call rejected.
    06/25/2004   lixingbo           p006416    Fix the bug that the start no sound  when select level.
    07/12/2004   MengJianghong    P006956 Fix bug can't switch ime after input digital .
    08/17/2004   caoyanqing         p007800    The game isnot in the center of the display interface in cargador game.
    Self-documenting Code
    Describe/explain low-level design of this module and/or group of funtions and/or specific
    funtion that are hard to understand by reading code and thus requires detail description.
    Free format !
        
====================================================================================================
    INCLUDE FILES
==================================================================================================*/
    
#include "APP_include.h"
#include "TP_Operator.h"    
#include "MENU_main.h"
#include "MENU_item.h"    
#include "GAMES_main.h"
#include "GAMES_cargador_path.h"

#ifdef GAMES_CARGADOR

#include <stdlib.h>
#include "uhapi.h"
#include "SP_volume.h"
#include "SP_audio.h"
#include "Ds_lcd.h"
#include "EDITOR_type.h"
#include "GAMES_cargador.h"
#include "product.h"

/*==================================================================================================
    GLOBAL FUNCTION PROTOTYPES
==================================================================================================*/
extern OP_BOOLEAN SearchRoute(PosType start,PosType end);
/*==================================================================================================
/*==================================================================================================
    LOCAL FUNCTION PROTOTYPES
==================================================================================================*/
void APP_Cargador_entry(void);
void App_Cargador_exit(void);
void App_Cargador_handler ( OPUS_EVENT_ENUM_TYPE   event, 
                                 void                   *pMess, 
                                 OP_BOOLEAN             *handle );

static OP_BOOLEAN cargador_route_move();
static OP_BOOLEAN cargador_pen_process(OP_INT16 x,OP_INT16 y);
static void APP_Cargador_select(void);
static void APP_Cargador_Init(void);
static OP_BOOLEAN popup_numeditor_handler
(   DS_POPUP_STATE_ENUM_T state,
    OP_INT32              event
);
static void cargador_pop_msg_processing(void);
static void onKeyPress(void  *pMess);
static void level_data_process(void);
static OP_BOOLEAN MoveTo(OP_INT8 byx,OP_INT8 byy);
static void DrawSquare(OP_INT8 col, OP_INT8 row, RM_RESOURCE_ID_T bitmapid);
static void RePaint(void);
static void Rollback(void);
static void ShowLevelPassed(void);

static OP_UINT8 style_state=0;
/*==================================================================================================
    LOCAL CONSTANTS
==================================================================================================*/
#define    MAX_LEVEL       80
//#define    SQUARELENGTH    16
#define    RECTWIDTH      22
#define    RECTHEIGHT     20

#if (PROJECT_ID == ODIN_PROJECT)
#define    rowNum          9
#elif defined(PACIFIC_VERSION)
//#ifdef  PACIFIC_VERSION
#define    rowNum          10
#else
#define    rowNum          9
#endif

#define    colNum          (LCD_MAX_X / RECTWIDTH)

#define    MAX_STRING_LENGTH       100

#define    MAX_MOVEMENT_COUNT      10

#define    GREEN_BLOCK                   4     /* The block that can be moved.*/
#define    YELLOW_BLOCK                 6    /*  The block that can be moved.*/

/*==================================================================================================
    LOCAL TYPEDEFS - Structure, Union, Enumerations...etc
==================================================================================================*/

/* Popup Numbe Editor definitions */
DS_POPUP_NUMEDITOR_T  select_level_editor = 
{
    "Input the level No.:",
    PMPT_TEXT_INPUT_LEVEL,
    "level number",
    PMPT_TEXT_INPUT_LEVEL,
    "",
    2,
    0,
    0
};


/*==================================================================================================
    LOCAL MACROS
==================================================================================================*/
/*
 * description of this macro, if needed. - Remember self documenting code
 */

/*==================================================================================================
    LOCAL VARIABLES
==================================================================================================*/

/*
 *  The date structure for the map of this game:
 *  The map is stored in a rowNum * colNum array, the value of each item may be 0, 1, 2, 3, 4, 6, 8, and 9.
 *    0:  the blank area within the wall
 *    1:  the position of the little guy
 *    2:  the destination for the boxs
 *    3:  3 = 1+2, means the guy is standing on the destination position
 *    4:  the box that should be push
 *    6:  6 = 2+4, means the box has reached the destination
 *    8:  the wall
 *    9:  out of the wall
 */


static OP_UINT8 Old_Box[rowNum][colNum];

static OP_UINT8 route[rowNum*colNum];

static OP_UINT8 select_level;
static OP_INT8   pathstep=0;
static OP_UINT8 current_level;
static OP_UINT8 current_width, current_height;
static OP_INT16 xoffset,yoffset;


static DIRECTION state;        /* status of the guy */
static OP_UINT8 MX, MY;            /* current position of the guy */
static OP_UINT8 Old_MX,  Old_MY, Old_State;    /* previous position of the guy */
static OP_BOOLEAN canRollBack=OP_FALSE;
static OP_UINT8 cargador_enter_pmpt[30]={0};
static OP_UINT8 level_buffer[6]={0};
static OP_BOOLEAN call_come_in_editor = OP_FALSE;

static RM_SOUND_ID_T sound_list[]=
{
    RES_SOUND_0010,  /* Cargador opening song */
    RES_SOUND_0013,  /* block is moved */
    RES_SOUND_0014,  /* block isn't moved */
    RES_SOUND_0010,  /* level passed */
};

static OP_BOOLEAN inGame;
static OP_BOOLEAN gamePause=OP_FALSE;

static OP_UINT8   guy_moved_count = 0;

#include "GAMES_cargador.map"

/*==================================================================================================
    GLOBAL VARIABLES
==================================================================================================*/
OP_UINT8 Current_Box[rowNum][colNum];  
extern APP_GAMES_STRUCTURE_NAME_T   gamesApp_data;
extern APP_SUBSTATE_STRUCTURE_NAME_T games_substate;
extern PathElem CargadorPath[rowNum*colNum];
extern OP_INT8 CargadorCurPath;


/*==================================================================================================
    LOCAL FUNCTIONS
==================================================================================================*/

/*==================================================================================================
    FUNCTION: APP_Cargador_entry

    DESCRIPTION:
        Description of this specific function.

    ARGUMENTS PASSED:

    RETURN VALUE:

    IMPORTANT NOTES:
    
==================================================================================================*/
void APP_Cargador_entry(void)
{
    gamePause = OP_FALSE;
    gamesApp_data.popupwin=OP_NULL;
    inGame=OP_FALSE;
    op_memset(level_buffer,0x0, sizeof(level_buffer));
    if (RM_GetFeature(FEATURE_GAME_CARGADOR_LEVEL, &current_level) 
                       != RM_SUCCESS)
    {
        op_debug(DEBUG_HIGH, "\n FATAL ERROR fail in read nv item : FEATURE_GAME_CARGADOR_LEVEL\n"); 
        current_level=0;
    }

    switch(gamesApp_data.app.cur_state)
    {
        case APP_GAMES_CARGADOR_RESUME:
            APP_Cargador_Init();
            break;
        case APP_GAMES_CARGADOR_SELECT:
            APP_Cargador_select();
            break;
        default:
            break;
    }
    op_debug(DEBUG_LOW,"CAR:APP_Cargador_entry\n");
    
}

/*==================================================================================================
    FUNCTION: App_Cargador_exit

    DESCRIPTION:
        Description of this specific function.

    ARGUMENTS PASSED:

    RETURN VALUE:

    IMPORTANT NOTES:

==================================================================================================*/
void App_Cargador_exit(void)
{
    OPUS_Stop_Timer(OPUS_TIMER_GAME_TIMING);

    if(gamesApp_data.popupwin)
    {
        close_old_popup();
    }
    ds_set_softkeys_rm(PMPT_SKEY_EMPTY, PMPT_SKEY_EMPTY, PMPT_SKEY_EMPTY); /* to make the update area include skey area*/
    if(RM_SetFeature(FEATURE_GAME_CARGADOR_LEVEL, &current_level)
                                 != RM_SUCCESS)
    {
         op_debug(DEBUG_HIGH, "\n FATAL ERROR fail in write nv item : FEATURE_GAME_CARGADOR_LEVEL\n"); 
    }
    SP_Audio_stop();
    call_come_in_editor = OP_FALSE;
    op_debug(DEBUG_LOW,"CAR:App_Cargador_exit\n");
}


/*==================================================================================================
    FUNCTION: app_Cargador_handler

    DESCRIPTION:
        Description of this specific function.

    ARGUMENTS PASSED:

    RETURN VALUE:

    IMPORTANT NOTES:

==================================================================================================*/
void    
App_Cargador_handler
( 
    OPUS_EVENT_ENUM_TYPE   event, 
    void                   *pMess, 
    OP_BOOLEAN             *handle 
)
{
    KEYEVENT_STRUCT *pKey;
    TPO_OPERATION_PARAM_STRUCTURE_T *pOperation_param;
    TP_PEN_EVENT_STRUCTURE_T  *pPen;
    EDITOR_ANYAPP_INTERFACE_NAME_T * result;
    static OP_INT16 penx,peny;
    OP_UINT8 temp[3] = {0};

    *handle = OP_TRUE;
    
    switch (event)
    {
          case OPUS_INTERNAL_EDITOR_DONE :
                op_debug(DEBUG_MED,"EDITOR_FINISHED!!!!!");
                gamePause = OP_FALSE;
                result = (EDITOR_ANYAPP_INTERFACE_NAME_T *)pMess;
                switch(result->editor_back)
                {
                case EDITOR_RET_OK: /*Notify you the user press OK key */
                    UtoA(temp, result->result);
                    select_level = (OP_UINT8)op_atoi((char *)temp);
                    op_debug(DEBUG_LOW,"select level is:%d\n", select_level);
                    level_data_process();
                    break;
                  /* fall through intentionally */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -