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

Revision:
4:673eb9735d44
Parent:
0:5fa232ee5fdf
Child:
14:46a353b2a8e8
--- a/HighScoreEntry.cpp	Fri Jun 07 20:29:59 2013 +0000
+++ b/HighScoreEntry.cpp	Sat Jun 08 11:24:05 2013 +0000
@@ -8,14 +8,12 @@
 
 #include "HighScoreEntry.h"
 #include "Gameduino.h"       // Gameduino stuff
-#if 0
-    #include "GDExtra.h"         // more Gameduino stuff
-    #include "GDConst.h"         // Gameduino constants
-    #include "CharBlocks.h"      // blocks of characters in program memory
-    #include "CharFrame.h"       // for drawing frames made of characters
-    #include "CharCodes.h"       // character codes
-    #include "FrameCounter.h"    // counter updated every vertical flyback
-#endif
+#include "GDExtra.h"         // more Gameduino stuff
+#include "GDConst.h"         // Gameduino constants
+#include "FrameCounter.h"    // counter updated every vertical flyback
+#include "CharBlocks.h"      // blocks of characters in program memory
+#include "CharFrame.h"       // for drawing frames made of characters
+#include "CharCodes.h"       // character codes
 
 /***************/
 /* CONSTRUCTOR */
@@ -36,8 +34,8 @@
 /*********************/
 // Pass pointer to place to store name in name.
 // Pass pointer to controls to read in controls.
-#if 0
-void HighScoreEntry::GetName( PlayerName *name, PanelControls *controls ) {
+// Pass pointer to Gameduino to display on in gd.
+void HighScoreEntry::GetName( PlayerName *name, PanelControls *controls, Gameduino *gd ) {
   UInt16 inputs;
   UInt8 countdown = 0;
   char *curPtr;
@@ -46,9 +44,9 @@
     name->Name[ i ] = 'A';
   }
   // Draw screen.
-  DrawScreen();
+  DrawScreen( gd );
   // Wait until player releases all controls.
-  WaitControls( controls, false );
+  WaitControls( gd, controls, false );
   // Start at leftmost character.
   cursorPos = 0;
   // Loop until cursor moves beyond rightmost character.
@@ -84,90 +82,86 @@
         if( cursorPos > 0 ) {
           cursorPos--;
           // Wait until all controls released.
-          WaitControls( controls, false );
+          WaitControls( gd, controls, false );
         }
       }
       else if( inputs & PanelControls::Right1 ) {
         // Joystick right moves cursor forwards.
         cursorPos++;
         // Wait until all controls released.
-        WaitControls( controls, false );
+        WaitControls( gd, controls, false );
       }
     }
     else {
       countdown--;
     }
     // Wait for vertical flyback. Then draw name and do animation.
-    GD.waitvblank();
+    gd->waitvblank();
     FrameCounter++;
-    DrawName( name );
-    Animate();
+    DrawName( gd, name );
+    Animate( gd );
   }
   // Wait until player releases all controls before returning.
-  WaitControls( controls, false );
+  WaitControls( gd, controls, false );
 }
-#endif
 
 /*********************/
 /* WAIT FOR CONTROLS */
 /*********************/
+// Pass pointer to Gameduino to display on in gd.
 // Pass pointer to controls to read in controls.
 // Pass true in waitActivate to wait for a control to be used.
 // Pass false to wait for release.
-#if 0
-void HighScoreEntry::WaitControls( PanelControls *controls, bool waitActivate ) {
-  boolean released = false;
+void HighScoreEntry::WaitControls( Gameduino *gd, PanelControls *controls, bool waitActivate ) {
+  bool released = false;
   UInt16 inputs;
   while( ! released ) {
     controls->Read();
     inputs = controls->GetInputs();
     released = ( waitActivate ? ( inputs != 0 ) : ( inputs == 0 ) );
     if( ! released ) {
-      GD.waitvblank();
+      gd->waitvblank();
       FrameCounter++;
-      Animate();
+      Animate( gd );
     }
   }
 }
-#endif
 
 /*******************/
 /* DRAW THE SCREEN */
 /*******************/
-void HighScoreEntry::DrawScreen( void ) {
-#if 0
-  GD.waitvblank();
+// Pass pointer to Gameduino to draw on in gd.
+void HighScoreEntry::DrawScreen( Gameduino *gd ) {
+  gd->waitvblank();
   // Clear the screen to zero characters.
-  GD.fill( RAM_PIC, 0, RAM_PIC_SIZE );
+  gd->fill( Gameduino::RAM_PIC, 0, RAM_PIC_SIZE );
   // Turn off all the sprites.
   for( UInt16 s = 0; s < SPRITE_COUNT; ++s ) {
-    GD.sprite( s, 0, 400, 0, 0 );
+    gd->sprite( s, 0, 400, 0, 0 );
   }
   // Draw border around screen.
-  CharFrame::Draw( 0, 0, VISIBLE_CHAR_WIDTH, VISIBLE_CHAR_HEIGHT );
+  CharFrame::Draw( gd, 0, 0, VISIBLE_CHAR_WIDTH, VISIBLE_CHAR_HEIGHT );
   // Draw logo.
-  GDExtra::WriteProgCharBlock( 2, 2, CharBlocks::EnterNameInstructionText );
-#endif
+  GDExtra::WriteProgCharBlock( gd, 2, 2, CharBlocks::EnterNameInstructionText );
 }
 
 /********************************/
 /* DRAW THE NAME AND THE CURSOR */
 /********************************/
+// Pass pointer to Gameduino to draw on in gd.
 // Pass player name in name.
-void HighScoreEntry::DrawName( PlayerName *name ) {
-#if 0
-  GD.putstr( 21, 11, name->Name );
-  UInt16 address = RAM_PIC + 12 * SCREEN_CHAR_WIDTH + 21;
+void HighScoreEntry::DrawName( Gameduino *gd, PlayerName *name ) {
+  gd->putstr( 21, 11, name->Name );
+  UInt16 address = Gameduino::RAM_PIC + 12 * SCREEN_CHAR_WIDTH + 21;
   for( UInt8 i = 0; i < PlayerName::Length; ++i ) {
-    GD.wr( address, ( i == cursorPos ) ? ArrowUp : ' ' );
+    gd->wr( address, ( i == cursorPos ) ? ArrowUp : ' ' );
     address++;
   }
-#endif
 }
 
 /********************/
 /* UPDATE ANIMATION */
 /********************/
-void HighScoreEntry::Animate( void ) {
+// Pass pointer to Gameduino to display on in gd.
+void HighScoreEntry::Animate( Gameduino *gd ) {
 }
-