Emulation of the 1970's Chip-8 machine. The emulator has 7 games that are unmodified from the original Chip-8 format.
Chip8Emulator.h@0:bc3f11b1b41f, 2015-02-08 (annotated)
- Committer:
- taylorza
- Date:
- Sun Feb 08 01:58:57 2015 +0000
- Revision:
- 0:bc3f11b1b41f
Chip-8 Emulator
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
taylorza | 0:bc3f11b1b41f | 1 | #include "LCD_ST7735.h" |
taylorza | 0:bc3f11b1b41f | 2 | #include "Bitmap1bpp.h" |
taylorza | 0:bc3f11b1b41f | 3 | |
taylorza | 0:bc3f11b1b41f | 4 | #ifndef __CHIP8EMULATOR_H__ |
taylorza | 0:bc3f11b1b41f | 5 | #define __CHIP8EMULATOR_H__ |
taylorza | 0:bc3f11b1b41f | 6 | |
taylorza | 0:bc3f11b1b41f | 7 | class Chip8Emulator |
taylorza | 0:bc3f11b1b41f | 8 | { |
taylorza | 0:bc3f11b1b41f | 9 | public: |
taylorza | 0:bc3f11b1b41f | 10 | Chip8Emulator(LCD_ST7735 &screen, const uint8_t *program, uint16_t programSize, uint8_t leftKey, uint8_t rightKey, uint8_t upKey, uint8_t downKey, uint8_t fireKey, uint8_t startKey); |
taylorza | 0:bc3f11b1b41f | 11 | void run(); |
taylorza | 0:bc3f11b1b41f | 12 | |
taylorza | 0:bc3f11b1b41f | 13 | private: |
taylorza | 0:bc3f11b1b41f | 14 | uint8_t rnd(); |
taylorza | 0:bc3f11b1b41f | 15 | bool isKeyPressed(uint8_t key); |
taylorza | 0:bc3f11b1b41f | 16 | uint8_t getKeyPressed(); |
taylorza | 0:bc3f11b1b41f | 17 | void plot(int x, int y, uint8_t pattern); |
taylorza | 0:bc3f11b1b41f | 18 | |
taylorza | 0:bc3f11b1b41f | 19 | private: |
taylorza | 0:bc3f11b1b41f | 20 | Bitmap1bpp _bmp; |
taylorza | 0:bc3f11b1b41f | 21 | LCD_ST7735 &_screen; |
taylorza | 0:bc3f11b1b41f | 22 | uint8_t _delay; |
taylorza | 0:bc3f11b1b41f | 23 | uint8_t _sound; |
taylorza | 0:bc3f11b1b41f | 24 | uint16_t _pc; |
taylorza | 0:bc3f11b1b41f | 25 | uint16_t _sp; |
taylorza | 0:bc3f11b1b41f | 26 | uint16_t _i; |
taylorza | 0:bc3f11b1b41f | 27 | uint8_t _memory[4096]; |
taylorza | 0:bc3f11b1b41f | 28 | uint16_t _stack[16]; |
taylorza | 0:bc3f11b1b41f | 29 | uint8_t _registers[16]; |
taylorza | 0:bc3f11b1b41f | 30 | |
taylorza | 0:bc3f11b1b41f | 31 | uint8_t _leftKey; |
taylorza | 0:bc3f11b1b41f | 32 | uint8_t _rightKey; |
taylorza | 0:bc3f11b1b41f | 33 | uint8_t _upKey; |
taylorza | 0:bc3f11b1b41f | 34 | uint8_t _downKey; |
taylorza | 0:bc3f11b1b41f | 35 | uint8_t _fireKey; |
taylorza | 0:bc3f11b1b41f | 36 | uint8_t _startKey; |
taylorza | 0:bc3f11b1b41f | 37 | |
taylorza | 0:bc3f11b1b41f | 38 | private: |
taylorza | 0:bc3f11b1b41f | 39 | static const int OFFSET_X = 16; |
taylorza | 0:bc3f11b1b41f | 40 | static const int OFFSET_Y = 32; |
taylorza | 0:bc3f11b1b41f | 41 | |
taylorza | 0:bc3f11b1b41f | 42 | static const uint8_t _font[]; |
taylorza | 0:bc3f11b1b41f | 43 | }; |
taylorza | 0:bc3f11b1b41f | 44 | |
taylorza | 0:bc3f11b1b41f | 45 | #endif //__CHIP8EMULATOR_H__ |