Version of Robotron arcade game using LPC1768, a Gameduino shield, a serial EEPROM (for high scores), two microswitch joysticks and two buttons plus a box to put it in. 20 levels of mayhem.
Dependencies: 25LCxxx_SPI CommonTypes Gameduino mbed
Diff: GameRobotRic.cpp
- Revision:
- 3:a6a0cd726ca0
- Parent:
- 2:bb0f631a6068
- Child:
- 4:673eb9735d44
--- a/GameRobotRic.cpp Thu Jun 06 20:11:28 2013 +0000 +++ b/GameRobotRic.cpp Fri Jun 07 20:29:59 2013 +0000 @@ -18,6 +18,9 @@ #include "HighScoreEntry.h" // for getting player's name for high score table #endif +// Define following for debugging messages to serial port. +#define CHATTY + // Number of lives player starts with. #define START_LIVES 5 @@ -29,6 +32,9 @@ // Address of EEPROM set using A0, A1 and A2 pins. #define ADDRESS_OF_EEPROM 0 +// Serial link to PC over USB cable. Globally accessible. +Serial pc( USBTX, USBRX ); + /**************************/ /* CHECK FOR A HIGH SCORE */ /**************************/ @@ -55,12 +61,12 @@ /*****************/ // This NEVER exits. void GameRobotRic::Play( void ) { + #ifdef CHATTY + pc.puts( "Program has restarted!\r\n" ); + #endif // Make a digital output for use as the Gameduino chip select pin. Deselect it. DigitalOut gameduinoCS( p8 ); gameduinoCS = 1; - // Make a digital output for use as the Gameduino chip select pin. Deselect it. - DigitalOut eepromCS( p14 ); - eepromCS = 1; // Initialise an SPI link for communications with Gameduino and the serial EEPROM. // This is different from how the Maple version of RobotRic did it. It used an // I2C EEPROM. @@ -72,7 +78,7 @@ spi.frequency( 8000000 ); // Set SPI format to use. // Use 8 bits per SPI frame. - // Use SPI mode 0. + // Use SPI mode 0. Clock normally low. Data captured on rising edge. spi.format( 8, 0 ); // Make a Gameduino and pass SPI link and digital output for chip select. Gameduino gd( &spi, &gameduinoCS ); @@ -94,7 +100,7 @@ // enemies are both J type and so collisions between players and enemies are not detected. gd.wr( Gameduino::JK_MODE, 0 ); // Initialise serial EEPROM object which is on same SPI bus as the Gameduino. - SPIEEPROM eeprom( &spi, &eepromCS ); + Ser25LCxxx eeprom( &spi, p14, 32768, 64 ); // Create a high score table that uses the EEPROM. HighScoreTable highScores( &eeprom ); // Start on the attract level. @@ -125,9 +131,9 @@ // Refetch level. level = levels.GetLevel( levelNumber ); } -#if 0 // Pass reference to high score table. level->SetHighScores( &highScores ); +#if 0 // Set player that is playing the level. level->SetPlayer( &player ); #endif