The space invaders replica (SIR) is console game project written in C++ programming language. The SIR is targeting and works on Outrageous Circuits RETRO game console developer platform. The game is written in C++ programming language using MBED online IDE and compiler.
DisplayN18.h@0:7dfc10b70a77, 2015-01-25 (annotated)
- Committer:
- mitko
- Date:
- Sun Jan 25 09:14:58 2015 +0000
- Revision:
- 0:7dfc10b70a77
The space invaders replica (SIR) is console game project written in C++ programming language. The SIR is targeting and works on Outrageous Circuits RETRO game console developer platform. The game is written in C++ programming language using MBED onli
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mitko | 0:7dfc10b70a77 | 1 | #include "mbed.h" |
mitko | 0:7dfc10b70a77 | 2 | |
mitko | 0:7dfc10b70a77 | 3 | #pragma once |
mitko | 0:7dfc10b70a77 | 4 | |
mitko | 0:7dfc10b70a77 | 5 | class DisplayN18 { |
mitko | 0:7dfc10b70a77 | 6 | static const unsigned char STEP = 4; |
mitko | 0:7dfc10b70a77 | 7 | |
mitko | 0:7dfc10b70a77 | 8 | DigitalOut resetPin; |
mitko | 0:7dfc10b70a77 | 9 | DigitalOut backlightPin; |
mitko | 0:7dfc10b70a77 | 10 | DigitalOut rsPin; |
mitko | 0:7dfc10b70a77 | 11 | DigitalOut csPin; |
mitko | 0:7dfc10b70a77 | 12 | SPI spi; |
mitko | 0:7dfc10b70a77 | 13 | |
mitko | 0:7dfc10b70a77 | 14 | void writeCommand(unsigned char command); |
mitko | 0:7dfc10b70a77 | 15 | void writeData(unsigned char data); |
mitko | 0:7dfc10b70a77 | 16 | void writeData(const unsigned char* data, unsigned int length); |
mitko | 0:7dfc10b70a77 | 17 | |
mitko | 0:7dfc10b70a77 | 18 | void reset(); |
mitko | 0:7dfc10b70a77 | 19 | void initialize(); |
mitko | 0:7dfc10b70a77 | 20 | void setClippingArea(unsigned char x, unsigned char y, unsigned char width, unsigned char height); |
mitko | 0:7dfc10b70a77 | 21 | |
mitko | 0:7dfc10b70a77 | 22 | public: |
mitko | 0:7dfc10b70a77 | 23 | DisplayN18(); |
mitko | 0:7dfc10b70a77 | 24 | |
mitko | 0:7dfc10b70a77 | 25 | /**White*/ |
mitko | 0:7dfc10b70a77 | 26 | static const uint16_t White; |
mitko | 0:7dfc10b70a77 | 27 | |
mitko | 0:7dfc10b70a77 | 28 | /**Silver*/ |
mitko | 0:7dfc10b70a77 | 29 | static const uint16_t Silver; |
mitko | 0:7dfc10b70a77 | 30 | |
mitko | 0:7dfc10b70a77 | 31 | /**Gray*/ |
mitko | 0:7dfc10b70a77 | 32 | static const uint16_t Gray; |
mitko | 0:7dfc10b70a77 | 33 | |
mitko | 0:7dfc10b70a77 | 34 | /**Black*/ |
mitko | 0:7dfc10b70a77 | 35 | static const uint16_t Black; |
mitko | 0:7dfc10b70a77 | 36 | |
mitko | 0:7dfc10b70a77 | 37 | /**Red*/ |
mitko | 0:7dfc10b70a77 | 38 | static const uint16_t Red; |
mitko | 0:7dfc10b70a77 | 39 | |
mitko | 0:7dfc10b70a77 | 40 | /**Maroon*/ |
mitko | 0:7dfc10b70a77 | 41 | static const uint16_t Maroon; |
mitko | 0:7dfc10b70a77 | 42 | |
mitko | 0:7dfc10b70a77 | 43 | /**Yellow*/ |
mitko | 0:7dfc10b70a77 | 44 | static const uint16_t Yellow; |
mitko | 0:7dfc10b70a77 | 45 | |
mitko | 0:7dfc10b70a77 | 46 | /**Olive*/ |
mitko | 0:7dfc10b70a77 | 47 | static const uint16_t Olive; |
mitko | 0:7dfc10b70a77 | 48 | |
mitko | 0:7dfc10b70a77 | 49 | /**Lime*/ |
mitko | 0:7dfc10b70a77 | 50 | static const uint16_t Lime; |
mitko | 0:7dfc10b70a77 | 51 | |
mitko | 0:7dfc10b70a77 | 52 | /**Green*/ |
mitko | 0:7dfc10b70a77 | 53 | static const uint16_t Green; |
mitko | 0:7dfc10b70a77 | 54 | |
mitko | 0:7dfc10b70a77 | 55 | /**Aqua*/ |
mitko | 0:7dfc10b70a77 | 56 | static const uint16_t Aqua; |
mitko | 0:7dfc10b70a77 | 57 | |
mitko | 0:7dfc10b70a77 | 58 | /**Teal*/ |
mitko | 0:7dfc10b70a77 | 59 | static const uint16_t Teal; |
mitko | 0:7dfc10b70a77 | 60 | |
mitko | 0:7dfc10b70a77 | 61 | /**Blue*/ |
mitko | 0:7dfc10b70a77 | 62 | static const uint16_t Blue; |
mitko | 0:7dfc10b70a77 | 63 | |
mitko | 0:7dfc10b70a77 | 64 | /**Navy*/ |
mitko | 0:7dfc10b70a77 | 65 | static const uint16_t Navy; |
mitko | 0:7dfc10b70a77 | 66 | |
mitko | 0:7dfc10b70a77 | 67 | /**Fuchsia*/ |
mitko | 0:7dfc10b70a77 | 68 | static const uint16_t Fuchsia; |
mitko | 0:7dfc10b70a77 | 69 | |
mitko | 0:7dfc10b70a77 | 70 | /**Purple*/ |
mitko | 0:7dfc10b70a77 | 71 | static const uint16_t Purple; |
mitko | 0:7dfc10b70a77 | 72 | |
mitko | 0:7dfc10b70a77 | 73 | static const unsigned int WIDTH = 160; |
mitko | 0:7dfc10b70a77 | 74 | static const unsigned int HEIGHT = 128; |
mitko | 0:7dfc10b70a77 | 75 | static const unsigned char CHAR_WIDTH = 5; |
mitko | 0:7dfc10b70a77 | 76 | static const unsigned char CHAR_HEIGHT = 8; |
mitko | 0:7dfc10b70a77 | 77 | static const unsigned char CHAR_SPACING = 1; |
mitko | 0:7dfc10b70a77 | 78 | |
mitko | 0:7dfc10b70a77 | 79 | static unsigned short rgbToShort(unsigned char r, unsigned char g, unsigned char b); |
mitko | 0:7dfc10b70a77 | 80 | |
mitko | 0:7dfc10b70a77 | 81 | void clear(unsigned short backColor = 0x0000); |
mitko | 0:7dfc10b70a77 | 82 | void draw(const unsigned short* data, int x, int y, int width, int height); |
mitko | 0:7dfc10b70a77 | 83 | void setPixel(int x, int y, unsigned short foreColor); |
mitko | 0:7dfc10b70a77 | 84 | |
mitko | 0:7dfc10b70a77 | 85 | void fillRect(int x, int y, int width, int height, unsigned short foreColor); |
mitko | 0:7dfc10b70a77 | 86 | void drawRect(int x, int y, int width, int height, unsigned short foreColor); |
mitko | 0:7dfc10b70a77 | 87 | |
mitko | 0:7dfc10b70a77 | 88 | void fillCircle(int x, int y, int radius, unsigned short foreColor); |
mitko | 0:7dfc10b70a77 | 89 | void drawCircle(int x, int y, int radius, unsigned short foreColor); |
mitko | 0:7dfc10b70a77 | 90 | |
mitko | 0:7dfc10b70a77 | 91 | void drawLine(int x0, int y0, int x1, int y1, unsigned short foreColor); |
mitko | 0:7dfc10b70a77 | 92 | |
mitko | 0:7dfc10b70a77 | 93 | void drawCharacter(int x, int y, const char character, unsigned short foreColor, unsigned short backColor, unsigned char fontSize = 1); |
mitko | 0:7dfc10b70a77 | 94 | void drawString(int x, int y, const char* str, unsigned short foreColor, unsigned short backColor, unsigned char fontSize = 1); |
mitko | 0:7dfc10b70a77 | 95 | }; |