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
CharFrame.cpp@2:bb0f631a6068, 2013-06-06 (annotated)
- Committer:
- RichardE
- Date:
- Thu Jun 06 20:11:28 2013 +0000
- Revision:
- 2:bb0f631a6068
- Child:
- 16:d0b142ba4362
More code brought in from Maple version. Now uses fancy character set and displays Robotric logo. Started re-writing I2C EEPROM code as SPI EEPROM code since now using an SPI EEPROM but not finished yet.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RichardE | 2:bb0f631a6068 | 1 | /* |
RichardE | 2:bb0f631a6068 | 2 | * SOURCE FILE : CharFrame.cpp |
RichardE | 2:bb0f631a6068 | 3 | * |
RichardE | 2:bb0f631a6068 | 4 | * For drawing rectangular frames using characters. |
RichardE | 2:bb0f631a6068 | 5 | * |
RichardE | 2:bb0f631a6068 | 6 | */ |
RichardE | 2:bb0f631a6068 | 7 | |
RichardE | 2:bb0f631a6068 | 8 | #include "CharFrame.h" |
RichardE | 2:bb0f631a6068 | 9 | #include "GDConst.h" // a few Gameduino constants |
RichardE | 2:bb0f631a6068 | 10 | #include "CharCodes.h" // character set codes |
RichardE | 2:bb0f631a6068 | 11 | |
RichardE | 2:bb0f631a6068 | 12 | /****************/ |
RichardE | 2:bb0f631a6068 | 13 | /* DRAW A FRAME */ |
RichardE | 2:bb0f631a6068 | 14 | /****************/ |
RichardE | 2:bb0f631a6068 | 15 | // Pass Gameduino to draw on in gd. |
RichardE | 2:bb0f631a6068 | 16 | // Pass x coordinate of top left in x. |
RichardE | 2:bb0f631a6068 | 17 | // Pass y coordinate of top left in y. |
RichardE | 2:bb0f631a6068 | 18 | // Pass width in w. |
RichardE | 2:bb0f631a6068 | 19 | // Pass height in h. |
RichardE | 2:bb0f631a6068 | 20 | void CharFrame::Draw( Gameduino *gd, UInt8 x, UInt8 y, UInt8 w, UInt8 h ) { |
RichardE | 2:bb0f631a6068 | 21 | // Calculate address for top left. |
RichardE | 2:bb0f631a6068 | 22 | unsigned int rowStart = Gameduino::RAM_PIC + y * SCREEN_CHAR_WIDTH + x; |
RichardE | 2:bb0f631a6068 | 23 | unsigned int address = rowStart; |
RichardE | 2:bb0f631a6068 | 24 | UInt8 count; |
RichardE | 2:bb0f631a6068 | 25 | // Draw top left corner. |
RichardE | 2:bb0f631a6068 | 26 | gd->wr( address++, TopLeft ); |
RichardE | 2:bb0f631a6068 | 27 | // Draw top edge. |
RichardE | 2:bb0f631a6068 | 28 | if( w > 2 ) { |
RichardE | 2:bb0f631a6068 | 29 | for( count = w - 2; count > 0; --count ) { |
RichardE | 2:bb0f631a6068 | 30 | gd->wr( address++, Top ); |
RichardE | 2:bb0f631a6068 | 31 | } |
RichardE | 2:bb0f631a6068 | 32 | } |
RichardE | 2:bb0f631a6068 | 33 | // Draw top right corner. |
RichardE | 2:bb0f631a6068 | 34 | gd->wr( address, TopRight ); |
RichardE | 2:bb0f631a6068 | 35 | // Draw left and right edges. |
RichardE | 2:bb0f631a6068 | 36 | rowStart += SCREEN_CHAR_WIDTH; |
RichardE | 2:bb0f631a6068 | 37 | if( h > 2 ) { |
RichardE | 2:bb0f631a6068 | 38 | for( count = h - 2; count > 0; --count ) { |
RichardE | 2:bb0f631a6068 | 39 | gd->wr( rowStart, Left ); |
RichardE | 2:bb0f631a6068 | 40 | gd->wr( rowStart + w - 1, Right ); |
RichardE | 2:bb0f631a6068 | 41 | rowStart += SCREEN_CHAR_WIDTH; |
RichardE | 2:bb0f631a6068 | 42 | } |
RichardE | 2:bb0f631a6068 | 43 | } |
RichardE | 2:bb0f631a6068 | 44 | // Draw bottom edge. |
RichardE | 2:bb0f631a6068 | 45 | address = rowStart; |
RichardE | 2:bb0f631a6068 | 46 | // Draw bottom left corner. |
RichardE | 2:bb0f631a6068 | 47 | gd->wr( address++, BottomLeft ); |
RichardE | 2:bb0f631a6068 | 48 | // Draw bottom edge. |
RichardE | 2:bb0f631a6068 | 49 | if( w > 2 ) { |
RichardE | 2:bb0f631a6068 | 50 | for( count = w - 2; count > 0; --count ) { |
RichardE | 2:bb0f631a6068 | 51 | gd->wr( address++, Bottom ); |
RichardE | 2:bb0f631a6068 | 52 | } |
RichardE | 2:bb0f631a6068 | 53 | } |
RichardE | 2:bb0f631a6068 | 54 | // Draw bottom right corner. |
RichardE | 2:bb0f631a6068 | 55 | gd->wr( address, BottomRight ); |
RichardE | 2:bb0f631a6068 | 56 | } |
RichardE | 2:bb0f631a6068 | 57 |