#include <PalmOS.h>
#include <DLServer.h>
#include <FeatureMgr.h>
#include <TapWave.h>
#include "host.h"
#include "CompatibleGameRsc.h"
Compounds | |
struct | App |
struct | AppJoystickInput |
Defines | |
#define | ObjectBitmapFirst 2000 |
#define | ObjectBitmapCount 2 |
#define | rotateLeftKey keyBitHard1 |
#define | rotateRightKey keyBitHard2 |
#define | shootKey keyBitHard3 |
#define | thrustKey keyBitHard4 |
#define | keysAllowedMask (rotateLeftKey | rotateRightKey | shootKey | thrustKey ) |
#define | GameMenuResume 0 |
#define | GameMenuExit 1 |
#define | GameMenuCount 2 |
#define | screenTopLeftXOffset 0 |
#define | screenTopLeftYOffset 0 |
Functions | |
void | HostMaskKeys () |
Mask the keys to reduce keyDownEvents from being sent. | |
void | HostUnmaskKeys () |
Unmask the keys so they can generate events again. | |
void | HostNewScreenBuffer (short int buffer_width, short int buffer_height) |
Create an offscreen buffer of the requested size. | |
void | HostOpenScreenBuffer (void) |
Set draws to occur at the screen buffer. | |
void | HostDrawBuffer (short int destX, short int destY, short int sourceX, short int sourceY, short int sourceWidth, short int sourceHeight) |
int | HostGetBitmapWidth (int bitmapNumber) |
Get the width of the Palm bitmap. | |
int | HostGetBitmapHeight (int bitmapNumber) |
Get the height of the Palm bitmap. | |
void | FastDrawPicture (int picture, int x, int y) |
Draw the picture directly to the offscreen buffer. | |
void | HostDrawObject (int bitmapNumber, short int x, short int y) |
Draw an object at a specified location and mode. | |
void | HostDrawGameMenu (int left, int top, int width, int height) |
Draw the game menu visible while the game is paused. | |
void | HostCloseScreenBuffer (void) |
Stop draws to the screen buffer. | |
Int32 | TimeUntillNextPeriod (void) |
void | MainFormResize (FormType *formP) |
Resize the form to fit the screen. | |
Boolean | MainFormHandleEvent (EventType *eventP) |
The MainForm event handler. | |
Boolean | AppHandleEvent (EventType *eventP) |
Handle frmLoadEvents by loading the right app form and setting it's form event handler callback. | |
void | AppEventLoop (void) |
The event loop for the aplication. | |
Err | AppLoadGraphics (App *app) |
Load the graphic resources needed for the game. | |
Err | AppStart (App *app) |
Obtain and configure resources needed to start the game. | |
void | AppStop (App *app) |
Cleanup the app by releasing and restoring all resources. | |
UInt32 | PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) |
The main entry point for the application. | |
Variables | |
const char | GameMenuText [GameMenuCount][7] |
App | GameApp |
Boolean | TapWaveSupport |
Int32 | InputFormats [] = {twInputJoyX, twInputJoyY} |
const RGBColorType | ColorGameMenu = { 0, 239, 211, 16 } |
This file also provides a TapWave look and feel to the game. This code runs like a TapWave app, and can override the game's wishes to provide a best handheld interpretation of the game.
This file is in C like most Palm programs. It interacts with game.cpp to show how to work with C++ programs.
Glossary
game cycle: Everything needed to advance the game one step. This includes taking input, moving all world objects, triggering events, collision detection, and drawing.
offscreen buffer: A set of pixels not used by the screen. The graphics are composed there and when done, made visible by the screen, by copying them, or sometimes by pointing the screen hardware to them.
landscape mode: The screen placed into 480x320 mode. No status bar is visible. The Palm coordinate system remains 240x160 (low density).
game menu: A UI system to control or configure the game. The method used draws over game in the offscreen buffer. An alternative is to use the Palm Menu system, but if so, be careful not to draw the game which would overwrite the menus.
Palm bitmaps: Bitmaps in a native Palm format. Typically created from BMP files with pilrc or pasted into Constructor and stored in the app's PRC. Bitmaps can have alternate color depths and resolutions and are collectively called a bitmap family. The most appropriate family member is drawn. The Palm API usually uses the hardware acceleration when possible.
|
The event loop for the aplication. The primary functions is to wait until the next game cycle and then call the game to do it's thing. But all other device input and activity is processed here too, like switching apps, turning off the device, alarms, and so on. |
|
Handle frmLoadEvents by loading the right app form and setting it's form event handler callback. All Palm UI forms need to set their event handler callback here. |
|
Load the graphic resources needed for the game. Load the graphics into memory. Custom blitting info is setup if needed too. This version uses Palm native bitmaps for storage and drawing ease. |
|
Obtain and configure resources needed to start the game. Sets the screen to 16 bit color mode.
|
|
Cleanup the app by releasing and restoring all resources. Frees the screen buffer. Releases all graphics. Restores the keys. Closes all open forms. |
|
Draw the picture directly to the offscreen buffer. This is a private function called when customBlitting is true. It is intended as an example of how to get at the offscreen buffer's bits.
|
|
Stop draws to the screen buffer.
|
|
Draw the game menu visible while the game is paused. Usually called by the game when it knows it is paused. This function is in the Host side so it can use the Palm OS fonts and drawing API.
|
|
Draw an object at a specified location and mode. HostOpenScreenBuffer must be called first.
|
|
Get the height of the Palm bitmap. The result is in the Palm coordinate system (low density (160x160)).
|
|
Get the width of the Palm bitmap. The result is in the Palm coordinate system (low density (160x160)).
|
|
Mask the keys to reduce keyDownEvents from being sent. This app does not use the events but polls the keys instead. This also sets up the joystick for analog polling.
|
|
Create an offscreen buffer of the requested size. Any existing buffer is freed. This buffer is also freed by AppStop before the app exits.
|
|
Set draws to occur at the screen buffer.
|
|
Unmask the keys so they can generate events again. Also, closes the joystick so it can generate events again.
|
|
The MainForm event handler.
|
|
Resize the form to fit the screen. Check if screen is a different size and adjust the form and it's active area gadget (which acts as it's view), to match. If TapWave APIs are present, use them to set the screen to full landscape width.
|
|
The main entry point for the application. All Palm applications start at PilotMain. |
|
Initial value: { "Resume", "Exit" } |
|
Array of input information the app is interested in. Other values like buttons could also be included here. NOTE: This structure must be four bytes aligned because it is used by ARM based API. |
|
Set to true if TapWave support is detected. This means that those APIs can be used to widen the screen and read the joystick. |