Platform library for RETRO
Retro.h@0:6f26c31d8573, 2015-03-01 (annotated)
- Committer:
- Architect
- Date:
- Sun Mar 01 05:29:45 2015 +0000
- Revision:
- 0:6f26c31d8573
RetroPlatform Library for RETRO gaming system
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Architect | 0:6f26c31d8573 | 1 | /* |
Architect | 0:6f26c31d8573 | 2 | * (C) Copyright 2015 Valentin Ivanov. All rights reserved. |
Architect | 0:6f26c31d8573 | 3 | * |
Architect | 0:6f26c31d8573 | 4 | * This file is part of the RetroPlatform Library |
Architect | 0:6f26c31d8573 | 5 | * |
Architect | 0:6f26c31d8573 | 6 | * The RetroPlatform Library is free software: you can redistribute it and/or modify |
Architect | 0:6f26c31d8573 | 7 | * it under the terms of the GNU Lesser General Public License as published by |
Architect | 0:6f26c31d8573 | 8 | * the Free Software Foundation, either version 3 of the License, or |
Architect | 0:6f26c31d8573 | 9 | * (at your option) any later version. |
Architect | 0:6f26c31d8573 | 10 | * |
Architect | 0:6f26c31d8573 | 11 | * This program is distributed in the hope that it will be useful, |
Architect | 0:6f26c31d8573 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Architect | 0:6f26c31d8573 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Architect | 0:6f26c31d8573 | 14 | * GNU Lesser General Public License for more details. |
Architect | 0:6f26c31d8573 | 15 | * |
Architect | 0:6f26c31d8573 | 16 | * You should have received a copy of the GNU Lesser General Public License |
Architect | 0:6f26c31d8573 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/> |
Architect | 0:6f26c31d8573 | 18 | * |
Architect | 0:6f26c31d8573 | 19 | * This library is inspired by Gamebuino Library (http://gamebuino.com) |
Architect | 0:6f26c31d8573 | 20 | * from Aurélien Rodot. |
Architect | 0:6f26c31d8573 | 21 | */ |
Architect | 0:6f26c31d8573 | 22 | #ifndef __RETRO_H__ |
Architect | 0:6f26c31d8573 | 23 | #define __RETRO_H__ |
Architect | 0:6f26c31d8573 | 24 | |
Architect | 0:6f26c31d8573 | 25 | #include "mbed.h" |
Architect | 0:6f26c31d8573 | 26 | #include "Sound.h" |
Architect | 0:6f26c31d8573 | 27 | #include "Display.h" |
Architect | 0:6f26c31d8573 | 28 | #include "Color565.h" |
Architect | 0:6f26c31d8573 | 29 | |
Architect | 0:6f26c31d8573 | 30 | #define LCDWIDTH 160 |
Architect | 0:6f26c31d8573 | 31 | #define LCDHEIGHT 128 |
Architect | 0:6f26c31d8573 | 32 | |
Architect | 0:6f26c31d8573 | 33 | #define BTN_LEFT 0 |
Architect | 0:6f26c31d8573 | 34 | #define BTN_RIGHT 1 |
Architect | 0:6f26c31d8573 | 35 | #define BTN_DOWN 2 |
Architect | 0:6f26c31d8573 | 36 | #define BTN_UP 3 |
Architect | 0:6f26c31d8573 | 37 | #define BTN_ROBOT 4 |
Architect | 0:6f26c31d8573 | 38 | #define BTN_SHIP 5 |
Architect | 0:6f26c31d8573 | 39 | |
Architect | 0:6f26c31d8573 | 40 | #define NUM_BTN 6 |
Architect | 0:6f26c31d8573 | 41 | |
Architect | 0:6f26c31d8573 | 42 | class Retro |
Architect | 0:6f26c31d8573 | 43 | { |
Architect | 0:6f26c31d8573 | 44 | private: |
Architect | 0:6f26c31d8573 | 45 | |
Architect | 0:6f26c31d8573 | 46 | uint32_t frameStartUs, frameEndUs; |
Architect | 0:6f26c31d8573 | 47 | |
Architect | 0:6f26c31d8573 | 48 | private: |
Architect | 0:6f26c31d8573 | 49 | static DigitalIn pin[NUM_BTN]; |
Architect | 0:6f26c31d8573 | 50 | uint8_t _state[NUM_BTN]; |
Architect | 0:6f26c31d8573 | 51 | |
Architect | 0:6f26c31d8573 | 52 | public: |
Architect | 0:6f26c31d8573 | 53 | uint32_t timePerFrame; |
Architect | 0:6f26c31d8573 | 54 | uint32_t frameDurationUs; |
Architect | 0:6f26c31d8573 | 55 | |
Architect | 0:6f26c31d8573 | 56 | Sound sound; |
Architect | 0:6f26c31d8573 | 57 | Display display; |
Architect | 0:6f26c31d8573 | 58 | |
Architect | 0:6f26c31d8573 | 59 | DigitalOut leftEye; |
Architect | 0:6f26c31d8573 | 60 | DigitalOut rightEye; |
Architect | 0:6f26c31d8573 | 61 | |
Architect | 0:6f26c31d8573 | 62 | public: |
Architect | 0:6f26c31d8573 | 63 | Retro(); |
Architect | 0:6f26c31d8573 | 64 | void initialize(); |
Architect | 0:6f26c31d8573 | 65 | bool update(); |
Architect | 0:6f26c31d8573 | 66 | |
Architect | 0:6f26c31d8573 | 67 | void setFrameRate(uint8_t fps); |
Architect | 0:6f26c31d8573 | 68 | static bool collideCheck( int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); |
Architect | 0:6f26c31d8573 | 69 | |
Architect | 0:6f26c31d8573 | 70 | void playOK(); |
Architect | 0:6f26c31d8573 | 71 | void playCancel(); |
Architect | 0:6f26c31d8573 | 72 | void playTick(); |
Architect | 0:6f26c31d8573 | 73 | |
Architect | 0:6f26c31d8573 | 74 | void readButtons(); |
Architect | 0:6f26c31d8573 | 75 | bool pressed(uint8_t button); |
Architect | 0:6f26c31d8573 | 76 | bool released(uint8_t button); |
Architect | 0:6f26c31d8573 | 77 | bool held(uint8_t button, uint8_t time); |
Architect | 0:6f26c31d8573 | 78 | bool repeat(uint8_t button, uint8_t period); |
Architect | 0:6f26c31d8573 | 79 | uint8_t timeHeld(uint8_t button); |
Architect | 0:6f26c31d8573 | 80 | |
Architect | 0:6f26c31d8573 | 81 | }; |
Architect | 0:6f26c31d8573 | 82 | |
Architect | 0:6f26c31d8573 | 83 | |
Architect | 0:6f26c31d8573 | 84 | uint8_t max(uint8_t val1, uint8_t val2 ); |
Architect | 0:6f26c31d8573 | 85 | uint8_t min(uint8_t val1, uint8_t val2 ); |
Architect | 0:6f26c31d8573 | 86 | |
Architect | 0:6f26c31d8573 | 87 | #endif //__RETRO_H__ |