Home ||| Hardware Design ||| Software Design ||| Media ||| Member Task Distribution ||| High Level Design ||| Results ||| References ||| Conclusion
Software Design
The goal behind the software was to design assembly language functions that directly handled reading and writing to registers, initializing timers, initializing interrupts, handling interrupts, setting up timers, reading and writing to our memory mapped IO devices, and other tasks that couldn’t be done with C code.
The idea was to encapsulate the major tasks into functions that could easily be called from C. Some of our functions included a call to print out the Welcome screen, to print out the Player Bet Screen, to print out the Player/Dealer Hands and Scores, to print out the screen (and incorporate the animation), to play a music selection for a particular screen, to get the Controller input, etc.
All of our screen functions were broken into two main parts: writing the data values to the Text and Graphics region, and incorporating a wait stage (using timers) so the screen would stay visible. The functions to play music used timers and interrupts: at the start of the music function, a general purpose timer was enabled again to generate interrupts and the initial frequency to play was written. Each time the interrupt was handled, it was cleared, and depending on a counter value and the type of even the music was being played for, a different frequency would be played.
The C program was responsible for managing what was currently displayed on the screen, what music should be playing, retrieving input from the user at the appropriate times, and managing the blackjack game. An issue that came up was how to best read in the controller input. The assembly function that retrieved the results worked out fine, but our initial idea of just placing that function it in a loop didn’t work because each button press would cover many iterations of the loop. Our solution was to incorporate delay right after reading the input so that one button press would result in an event that could be seen by the user.
Flow Chart
Initialize Graphics Display, interrupts, timers, data structures (player state, deck, etc.)
Play the music for the welcome Screen as well as the Welcome Screen
Loop forever
Reinitialize if restarting – (initialize data structures, play welcome music, print welcome Screen)Shuffle the deck if necessary
Reset player and dealer data for the beginning of the Hand
Get Bet from Player
Draw the cards and update the screen with this information
Loop while player can still hit and hasn’t decided to stand, and didn’t decide to restart
Get Player input, take action based on input
If not restarting and if the player bustedUpdate game info, print out player loses screen and play correct music
Else if not restarting
Dealer draws cards until has at least 17
If Dealer total > Player TotalUpdate game info, print out player loses screen and play correct music
If Dealer total == Player totalUpdate game info, print out player ties screen and play correct music
If Dealer total < Player totalUpdate game info, print out player wins screen and play correct music
If Player has no more money
Set flag to restart game again, print out “No More Money” screen and play the correct music