Game Logic
Software Design
The Pinball Soccer game uses embedded software programmed on a C32 microcontroller. The software is written in C, and was organized into modules to improve development, team collaboration and debugging.
Module Descriptions
The following modules provided the basic functionality of the Soccer Pinball experience
- Main Program.C - Runs all the subprograms, handles the gameplay loop, and scoring
- ConfigureInitialize.C (.H)- Defines the configuration of the various ports as inputs and outputs, and their use as analog, digital, or PWM channels. It also initializes the timers, PWM and scoreboard display.
- IO_Definitions.H - Defines constants for referencing the pins on the C32
- Constants.H - Defines useful constants for the operation of the machine, such as the length of a game, and the speed of the swag dispensing motor.
- Scoreboard (.H & .C) - Provides all functions for using the scoreboard, including the initialize, increment score and decrement time functions
- FlipperMotor.C - Provides functions for actuating the flippers...i.e. push, pull, and turn off
- PennyModule.C - Contains the wait for penny function
- EventChecker.C (.H) - Scans the inputs to determine whether an event has occured that requires responding to.
Main Program Process Flow
Start
Configure and initialize everything
Game loop
Wait for penny
Start game
Play loop
Check events
Respond to event
End play loop
Check score and dispense prize
Reset game
End game loop
End
Microcontroller I/O
Port M
0 - opponent goal sensor input
1 - player goal sensor input
2 - penny coin sensor input
3 - goalie direction output
4 - prize dispenser enable output
5 - right flipper direction output
Port AD
0 - difficulty potentiometer analog input
1 - sound output control signal
2 - goalie direction change input (limit switches and 2nd player button)
3 - left flipper button input
4 - right flipper button input
5 - left flipper enable output
6 - left flipper direction output
7 - right flipper enable output
Port T
0 - Goalie speed (PWM)
1-2 - unused PWM
3 - scoreboard clock pulse output
4 - opponent score output
5 - time ones digit output
6 - time tens digit output
7 - player score output