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 Pseudocode
/* Signal module for Railroad HandCar arcade game */ /* Set DDR port T byte to input, M byte to output */ /* Set port AD I/O bits and initialize PWM module */ InitializePorts Accepts nothing, returns nothing Set port T to input and port M to output Set port T values all low Initialize port AD to all digital output + 1 analog input Set the 1 analog input port value high Initialize the PWM ports (T0-T2) /* Pulse enable (port M0) to signal jumping motor */ PulseEnable Accepts nothing, returns nothing Set port M bit 0 high Wait for 100 msec Set port M bit 0 low /* Set start indicator LED ON (State != 0) or OFF */ void ReadyLED(char State) { Accepts a char, returns nothing If the char is high (non-zero) Set port M bit 4 high Else Set port M bit 4 low /* Check whether penny inserted; LO means present */ CheckForPenny Accepts nothing, returns a char (boolean) Return whether port T bit 7 is low /* Sound the game chime for OnTime amount of time */ SoundHorn Accepts an unsigned int, returns nothing Set port AD bit 1 low Wait the indicated duration Set port AD bit 1 high /* Beep (sound game chime) at indicated frequency */ Beep Accepts a char, returns nothing For the number of times indicated Sound the game horn for constant time Wait for an equivalent constant time /* Check whether 'start' button has been pressed */ CheckStartButton Accepts nothing, returns a char (boolean) Return whether port T bit 3 is low /* Get the current handle position (range 0-1023) */ HandlePosition Accepts nothing, returns a short Return the analog value at port AD pin 0 } /* Set port M5 HI or LO to direct puppet handpump */ Pump Accepts a char, returns nothing If the indicated direction is up Set port M bit 5 high Else Set port M bit 5 low /* Set PWM scroll speed on port T0 & adjust range */ SetScrollSpeed Accepts and unsigned int, returns nothing If the speed indicated is non-zero Set PWM duty on port T bit 0 to speed / 2 + 25 /* Place villain within servo range from position */ PlaceVillain Accepts an unsigned char, returns nothing Set PWM duty on port T bit 1 to the indicated position /* Check whether the hand car is over an obstacle */ AtObstacle Accepts nothing, returns a char (boolean) Return whether port T bit 6 is low /* Set port M1 HI or LO to direct motor direction */ void Jump(char Direction) { Accepts a char, returns nothing If the indicated direction is up Set port M bit 1 high Else Set port M bit 1 low Pulse the enable line on port M } /* Check whether a jump or landing event occurred */ GetJumpEvent Accepts nothing, returns a char (state) If port T bit 4 or bit 5 is high Set the jump state to down Else Set the jump state to up If the jump state is the same as last time Return NO_EVENT Set the old state to the jump state If the jump state is up return JUMPED Else return LANDED /* Set port M2 LO to vibrate handle for collision */ void VibrateHandle(char Signal) { Accepts a char, returns nothing If the indicated signal is on Set port M bit 2 high Else Set port M bit 2 low /* Dispense SWAG for the specified length of time */ DispenseSWAG Accepts nothing, returns nothing Set port M bit 3 high Wait a constant amount of time Set port M bit 3 low