CODE
Signaling Module: [Header File] [Pseudocode] [C Code] Timing Module: [Header File] [Pseudocode] [C Code] Pinout: [Pinout Diagram] |
Game Play Module: [Header File] [Pseudocode] [C Code] Main Module: [Header File] [Pseudocode] [C Code] |
Signaling Header File
/* Signal header for Railroad Handcar arcade game */ /**************************************************/ /* Defines */ /**************************************************/ /* Set a full (IO port) byte to high or low state */ #define BYTELO 0x00 #define BYTEHI 0xFF /* Do jump signal ports read UP or DN (HI or LO)? */ #define UP 0 #define DN 1 /* Define the 2 states for the handle vibrations */ #define OFF 0 #define ON 1 /* Valid return states for GetJumpEvent function */ #define NO_EVENT 0 #define JUMPED 1 #define LANDED 2 /* Duration (in msec) to sound horn during a beep */ #define BEEP_TIME 500 /* Duration (in msec) to dispense Cheez Whiz SWAG */ #define SWAG_TIME 1500 /**************************************************/ /* Prototypes */ /**************************************************/ /* Set DDR port T byte to input, M byte to output */ /* Set port AD I/O bits and initialize PWM module */ void InitializePorts(void); /* Pulse enable (port M0) to send signal to motor */ void PulseEnable(void); /* Set start indicator LED ON (State != 0) or OFF */ void ReadyLED(char State); /* Check whether penny inserted; LO means present */ char CheckForPenny(void); /* Sound the game chime for OnTime amount of time */ void SoundHorn(unsigned int OnTime); /* Beep (sound game chime) at indicated frequency */ void Beep(char NumTimes); /* Check whether 'start' button has been pressed */ char CheckStartButton(void); /* Get the current handle position (range 0-1023) */ short HandlePosition(void); /* Set port M5 HI or LO to direct puppet handpump */ void Pump(char Direction); /* Set (inverted) PWM on port T0 for scroll speed */ void SetScrollSpeed(unsigned int speed); /* Place villain within servo range from position */ void PlaceVillain(unsigned char position); /* Check whether the hand car is over an obstacle */ char AtObstacle(void); /* Set port M1 HI or LO to direct motor direction */ void Jump(char Direction); /* Check whether a jump or landing event occurred */ char GetJumpEvent(void); /* Set port M2 LO to vibrate handle for collision */ void VibrateHandle(char signal); /* Dispense SWAG for the specified length of time */ void DispenseSWAG(void);