/*===========================================================================
FILE: Boxman.c
SERVICES: Boxman Game Application
GENERAL DESCRIPTION: Boxman Game Main Control Program
INITIALIZATION AND SEQUENCING REQUIREMENTS:
BREW must be initialized.
(c) COPYRIGHT 2003,2004 Hisense Incorporated.
All Rights Reserved.
Hisense Proprietary
===========================================================================*/
/*===============================================================================
$DateTime: 2004/02/10 17:12:00 $
$Author: whb $
$Change: 000001 $
EDIT HISTORY FOR FILE
This section contains comments describing changes made to the module.
Notice that changes are listed in reverse chronological order.
when who what, where, why
---------- --- ---------------------------------------------------------
02/18/2004 whb add select stage function
02/12/2004 whb Initial Version
=============================================================================== */
/*===============================================================================
INCLUDES DEFINITIONS
=============================================================================== */
#include "AEEModGen.h"
#include "AEEAppGen.h"
#include "AEEShell.h"
#include "Boxman.bid" //save app id
#include "AEENet.h"
#include "AEEFile.h"
#include "AEEMenu.h"
#include "AEEStdLib.h"
#include "AEEImage.h"
#include "AEEText.h"
#include "AEEDisp.h"
#include "Boxman_res.h" //necessary resource
#include "Boxman.h"
#include "upimage.h"
//...
/*===============================================================================
Macro definitions
=============================================================================== */
#define STATE_NULL 0
#define STATE_MAINMENU 1
#define STATE_RUNGAME 2
#define STATE_SUCCESS 3
#define STATE_QUIT 4
#define STATE_SELSTAGE 5
#define UPCBMPGetU32(bytePtr) ( (U32) (((bytePtr)[3] <<24) + ((bytePtr)[2] <<16)+((bytePtr)[1] <<8)+(bytePtr)[0]) )
#define MAX_SOFTKEY_CHARS 8
#define SOFTKEY_BACKGROUND_COLOR MAKE_RGB(192, 192, 192)
#define kMAPPath "map"
#define kFilePrefix "map"
#define kMaxFileNameLength 64
#define kColorClearGray 0xC0C0C000
#define kColorClearLightYellow 0xC0FFFF00
#define kColorClearBlack 0x00000000
#define kColorClearDialogBox kColorClearBlack
#define kColorClearDialogBackground kColorClearLightYellow
/*===============================================================================
structure definitions
=============================================================================== */
typedef unsigned char U8; /* unsigned 8 bit integer */
typedef unsigned short U16; /* unsigned 16 bit integer */
typedef unsigned long U32; /* unsigned 32 bit integer */
typedef signed char S8; /* signed 8 bit integer */
typedef signed short S16; /* signed 16 bit integer */
typedef signed long S32; /* signed 32 bit integer */
typedef struct _Boxman_type
{
AEEApplet a;
AEERect m_nClntAreaRect;
AEERect m_nSoftkeyAreaRect;
uint16 m_nScrWidth;
uint16 m_nScrHeight;
uint16 m_nLineHeight; //Normal font
uint16 m_nLargeLineHeight; //Larege font
IBitmap* m_pSuspendBitmap;
S16 m_ManX; /* record the position of the Man*/
S16 m_ManY;
U8 *m_pMap; /* pointer to the map*/
U8 m_Arrived; /* how many boxes have been on the dest*/
U8 m_BoxNum; /* the number of boxes*/
U8 m_nState;
void *m_pObj;
U8 m_nCurMap;
}CBoxman;
/*===============================================================================
Function Prototypes
=============================================================================== */
static boolean Boxman_HandleEvent(CBoxman * pApp,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static boolean Boxman_InitAppData(CBoxman * pApp);
static void Boxman_FreeAppData(CBoxman * pApp);
static void Boxman_ReleaseObj(void ** ppObj);
static boolean Boxman_Start(CBoxman * pApp);
static boolean Boxman_Stop(CBoxman * pApp);
static boolean Boxman_Suspend(CBoxman * pApp);
static boolean Boxman_Resume(CBoxman * pApp);
static boolean Boxman_HandleKey(CBoxman * pApp,
uint16 wParam,
uint32 dwParam);
static boolean Boxman_HandleCommand(CBoxman * pApp,
uint16 wParam,
uint32 dwParam);
static boolean Boxman_Notify(CBoxman *pApp,uint16 w,uint32 dw);
static boolean Boxman_DisplayMainMenu(CBoxman * pApp);
static boolean Boxman_MainMenuHandleKey(CBoxman * pApp,
uint16 wParam,
uint32 dwParam);
static boolean Boxman_MainMenuHandleCommand(CBoxman * pApp,
uint16 wParam,
uint32 dwParam);
static boolean Boxman_GameStart(CBoxman * pApp);
static boolean Boxman_GameHandleKey(CBoxman * pApp,
uint16 wParam,
uint32 dwParam);
static boolean Boxman_DisplaySuccess(CBoxman * pApp);
static boolean Boxman_SuccessHandleKey(CBoxman * pApp,
uint16 wParam,
uint32 dwParam);
static boolean Boxman_DisplayQuit(CBoxman * pApp);
static boolean Boxman_QuitHandleKey(CBoxman * pApp,
uint16 wParam,
uint32 dwParam);
static boolean Boxman_SelectStage(CBoxman * pApp);
static boolean Boxman_SelectStageHandleKey(CBoxman * pApp,
uint16 wParam,
uint32 dwParam);
/* general drawing routines */
static void Boxman_ClearDisplay(CBoxman* pApp);
static void Boxman_CheckScreen(CBoxman* pApp);
static void DevBitBlt(CBoxman* pApp,
S16 destX, S16 destY,
S16 width, S16 height,
S16 srcX, S16 srcY,
const unsigned char * imageData, S32 imageLen);
static void Boxman_DrawMan(CBoxman* pApp,S16 x,S16 y);
static void Boxman_DrawWall(CBoxman* pApp,S16 x,S16 y);
static void Boxman_DrawBG(CBoxman* pApp,S16 x,S16 y);
static void Boxman_DrawBox(CBoxman* pApp,S16 x,S16 y);
static void Boxman_DrawDest(CBoxman* pApp,S16 x,S16 y);
static boolean Boxman_ReadMap(CBoxman * pApp,U8 mapId);
static void Boxman_makePathnameFromID(char* filename, U8 mapId);
static U32 Boxman_Itoa(U8* buffer, S32 eger);
static void DevDrawDialog(CBoxman * pApp,const AECHAR *szText);
#if defined(BREW_STATIC_APP)
static int BoxmanMod_CreateInstance(AEECLSID ClsId,
IShell *pIShell,
IModule *po,
void **ppObj);
static int Boxman_Load(IShell *ps,
void *pHelpers,
IModule **pMod);
PFNMODENTRY Boxman_GetModInfo(IShell *ps,
AEECLSID **ppClasses,
AEEAppInfo **pApps,
uint16 *pnApps,
uint16 *pwMinPriv);
#endif //BREW_STATIC_APP
/*===========================================================================
STATIC/LOCAL DATA
===========================================================================*/
#if defined(BREW_STATIC_APP)
static const AEEAppInfo gaiBoxman = {
AEECLSID_APP_Boxman,//new class
Boxman_RES_FILE, //resource file name
IDS_Boxman_TITLE, //app title
0,0,0,0,
AFLAG_TOOL //app type
};
#endif //BREW_STATIC