Skeeball Racer Header

/************************************************************************

ME218A Project: SkeeBall Racer

Date: Fall Quarter 2007

Team Members: Derrick Jue, Ji Heun Lee, Stephanie Lue, Nathan Parkhill

File Name: Skeeball_Racer.h

Description: SkeeBall Racer Header File

************************************************************************/

 

/**** InitializeGame #defines ****/

 

#define PORTM_INIT      0x00

#define PORTT_INIT      0x00

#define DATADIRECTIONM_INIT   0x00

#define DATADIRECTIONT_INIT   0x18

#define AD_INIT               "IIIIIIIA"

 

/**** CheckforPenny #defines ****/

 

#define PENNY_BIT    0x02  // BIT1HI

#define PENNY_FOUND  0x00

 

/**** OnYourMarksGetSetGo #defines ****/

 

#define VALID_START 1

#define FALSE_START 0  

 

#define START_ENGINE_WAIT_TIME 1

#define ON_YOUR_MARKS_WAIT_TIME 2

#define GET_SET_WAIT_TIME 1

 

 

/**** Ball Launcher #defines ****/

#define BALL_LAUNCHER_BIT    0x04 // BIT2HI

#define BALL_NOT_LAUNCHED    0x00

 

 

 

/**** SetDifficulty #defines ****/

 

#define EASY 1

#define MEDIUM 2

#define HARD 3

 

#define EASY_HI 400

#define MEDIUM_HI 650

 

#define EASY_PACER_SPEED 73

#define MEDIUM_PACER_SPEED 78

#define HARD_PACER_SPEED 82

 

#define USER_START_SPEED 70

 

#define EASY_SHOTS_LEFT 9

#define MEDIUM_SHOTS_LEFT 8

#define HARD_SHOTS_LEFT 7

 

 

 

 

 

 

 

/****** Penny Sensor #defines ******/

#define NO_PENNY 0x00

#define NO_PENNY_FOUND 0

#define PENNY_BIT_HI BIT0HI

#define PENNY_BIT_LO BIT0LO

 

 

/****** Difficulty Sensor ********/

#define DIFFICULTY_PIN 0

#define DIFFICULTY_PIN_BIT 0x01

 

/******* Winner, laps left ******/

#define PACER_WINS  0

#define PLAYER_WINS 1

#define PACER_TOTAL_LAPS 3

#define PLAYER_TOTAL_LAPS 3

#define NO_LAPS_LEFT 0

 

/****************************** speed control trigger ****************************/

 

 

#define SLOW_DOWN_SWITCH_BIT 0x08

#define SMALL_SPEED_UP_SWITCH_BIT 0x10

#define LARGE_SPEED_UP_SWITCH_BIT 0x20

 

#define SLOW_DOWN_HIT 0x00

#define SMALL_SPEED_UP_HIT 0x00

#define LARGE_SPEED_UP_HIT 0x00  

 

/********** Finish switch bits *************/

#define PACER_FINISH_BIT 0x80  // HI Signal = switch hit

#define PLAYER_FINISH_BIT 0x40

#define PACER_NOT_FINISHED 0x00

#define PLAYER_NOT_FINISHED 0x00

#define PLAYER_LAP_NOT_FINISHED 0x00

#define PACER_LAP_NOT_FINISHED 0x00

#define DEBOUNCE_TIME 500 // in milliseconds

 

 

/****************************** speed increment / decrement ****************************/

#define SLOW_DOWN_DECREMENT 5

#define SMALL_SPEED_UP_INCREMENT 5

#define LARGE_SPEED_UP_INCREMENT 10

 

#define MAX_DUTY_CYCLE 100

#define PWMS12_20000US 0x5096

#define SPEEDOMETER_ZERO 3

/************************** Dispense Goodies ****************************/

#define SWAG_MOTOR_BIT 0x10 // bit 4 hi

#define SWAG_MOTOR_BIT_LO 0xEF // bit 4 lo

#define SWAG_SWITCH_BIT 0x20 // bit 5 hi

#define SWAG_SWITCH_NOT_TRIGGERED 0x00

#define SWITCH_DEBOUNCE_TIME 100  //unit in milliseconds

 

/************************** Vibrate Throttle    *************************/

 

#define SMALL_SPEED_UP_FEEDBACK 500

#define LARGE_SPEED_UP_FEEDBACK 1000

#define VIBRATE_THROTTLE_HI 0x08 // bit3hi

#define VIBRATE_THROTTLE_LO 0xF7 // bit3lo

 

 

 

/************************** Reset   *************************/

 

#define PACER_TO_START_SPEED 90

#define PLAYER_TO_START_SPEED     90

#define STOP 0

 

 

/************************** function prototypes *************************/

 

void InitializeGame(void);

void CheckforPenny(void);

unsigned char CheckStart(unsigned int WaitTime);

unsigned char SetDifficulty(void);

unsigned char RunRace(void);

void StartPacer(unsigned char pacerspeed);

void ShowShotsLeft(unsigned char shotsleft);

void ShowLapsLeft(unsigned char lapsleft);

void UserCarSpeed(unsigned char usermotorspeed);

 

void GameOver(unsigned int winner);

void DispenseGoodies(unsigned int winner);

void Reset(unsigned int winner);

 

 

Back to Pseudo Code

Back to the Starting Line