PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)
Dependents: YATTT sd_map_test cPong SnowDemo ... more
PokittoLib
Library for programming Pokitto hardware
How to Use
- Import this library to online compiler (see button "import" on the right hand side
- DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
- Change My_settings.h according to your project
- Start coding!
POKITTO_CORE/PokittoGlobs.h@71:531419862202, 2019-12-25 (annotated)
- Committer:
- Pokitto
- Date:
- Wed Dec 25 23:59:52 2019 +0000
- Revision:
- 71:531419862202
- Parent:
- 66:6281a40d73e6
Changed Mode2 C++ refresh code (graphical errors)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pokitto | 31:f4b9b85c7b62 | 1 | /**************************************************************************/ |
Pokitto | 31:f4b9b85c7b62 | 2 | /*! |
Pokitto | 31:f4b9b85c7b62 | 3 | @file PokittoGlobs.h |
Pokitto | 31:f4b9b85c7b62 | 4 | @author Jonne Valola |
Pokitto | 31:f4b9b85c7b62 | 5 | |
Pokitto | 31:f4b9b85c7b62 | 6 | @section LICENSE |
Pokitto | 31:f4b9b85c7b62 | 7 | |
Pokitto | 31:f4b9b85c7b62 | 8 | Software License Agreement (BSD License) |
Pokitto | 31:f4b9b85c7b62 | 9 | |
Pokitto | 31:f4b9b85c7b62 | 10 | Copyright (c) 2016, Jonne Valola |
Pokitto | 31:f4b9b85c7b62 | 11 | All rights reserved. |
Pokitto | 31:f4b9b85c7b62 | 12 | |
Pokitto | 31:f4b9b85c7b62 | 13 | Redistribution and use in source and binary forms, with or without |
Pokitto | 31:f4b9b85c7b62 | 14 | modification, are permitted provided that the following conditions are met: |
Pokitto | 31:f4b9b85c7b62 | 15 | 1. Redistributions of source code must retain the above copyright |
Pokitto | 31:f4b9b85c7b62 | 16 | notice, this list of conditions and the following disclaimer. |
Pokitto | 31:f4b9b85c7b62 | 17 | 2. Redistributions in binary form must reproduce the above copyright |
Pokitto | 31:f4b9b85c7b62 | 18 | notice, this list of conditions and the following disclaimer in the |
Pokitto | 31:f4b9b85c7b62 | 19 | documentation and/or other materials provided with the distribution. |
Pokitto | 31:f4b9b85c7b62 | 20 | 3. Neither the name of the copyright holders nor the |
Pokitto | 31:f4b9b85c7b62 | 21 | names of its contributors may be used to endorse or promote products |
Pokitto | 31:f4b9b85c7b62 | 22 | derived from this software without specific prior written permission. |
Pokitto | 31:f4b9b85c7b62 | 23 | |
Pokitto | 31:f4b9b85c7b62 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY |
Pokitto | 31:f4b9b85c7b62 | 25 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Pokitto | 31:f4b9b85c7b62 | 26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Pokitto | 31:f4b9b85c7b62 | 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY |
Pokitto | 31:f4b9b85c7b62 | 28 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
Pokitto | 31:f4b9b85c7b62 | 29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Pokitto | 31:f4b9b85c7b62 | 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
Pokitto | 31:f4b9b85c7b62 | 31 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Pokitto | 31:f4b9b85c7b62 | 32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Pokitto | 31:f4b9b85c7b62 | 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Pokitto | 31:f4b9b85c7b62 | 34 | */ |
Pokitto | 31:f4b9b85c7b62 | 35 | /**************************************************************************/ |
Pokitto | 31:f4b9b85c7b62 | 36 | |
Pokitto | 31:f4b9b85c7b62 | 37 | #ifndef POKITTO_GLOBS_H |
Pokitto | 31:f4b9b85c7b62 | 38 | #define POKITTO_GLOBS_H |
Pokitto | 31:f4b9b85c7b62 | 39 | |
Pokitto | 31:f4b9b85c7b62 | 40 | #include <stdint.h> |
Pokitto | 31:f4b9b85c7b62 | 41 | |
Pokitto | 31:f4b9b85c7b62 | 42 | #ifdef POK_SIM |
Pokitto | 31:f4b9b85c7b62 | 43 | #include "SimLCD.h" |
Pokitto | 31:f4b9b85c7b62 | 44 | #include "SimSound.h" |
Pokitto | 31:f4b9b85c7b62 | 45 | #include "PokittoSimulator.h" |
Pokitto | 31:f4b9b85c7b62 | 46 | #else |
Pokitto | 31:f4b9b85c7b62 | 47 | #include "mbed.h" |
Pokitto | 31:f4b9b85c7b62 | 48 | #include "HWLCD.h" |
Pokitto | 31:f4b9b85c7b62 | 49 | #include "HWSound.h" |
Pokitto | 31:f4b9b85c7b62 | 50 | #endif // POK_SIM |
Pokitto | 31:f4b9b85c7b62 | 51 | |
Pokitto | 31:f4b9b85c7b62 | 52 | extern int random(int); |
Pokitto | 31:f4b9b85c7b62 | 53 | extern int random(int,int); |
Pokitto | 31:f4b9b85c7b62 | 54 | |
Pokitto | 31:f4b9b85c7b62 | 55 | #define HIGH 1 |
Pokitto | 31:f4b9b85c7b62 | 56 | #define LOW 0 |
Pokitto | 31:f4b9b85c7b62 | 57 | |
Pokitto | 31:f4b9b85c7b62 | 58 | #define swapWT(type, a, b) \ |
Pokitto | 31:f4b9b85c7b62 | 59 | { \ |
Pokitto | 31:f4b9b85c7b62 | 60 | type _t_; \ |
Pokitto | 31:f4b9b85c7b62 | 61 | _t_ = a; \ |
Pokitto | 31:f4b9b85c7b62 | 62 | a = b; \ |
Pokitto | 31:f4b9b85c7b62 | 63 | b = _t_; \ |
Pokitto | 31:f4b9b85c7b62 | 64 | } |
Pokitto | 31:f4b9b85c7b62 | 65 | |
Pokitto | 31:f4b9b85c7b62 | 66 | #define SAMPLE_RATE POK_AUD_FREQ //was 16000, was 57000 |
Pokitto | 31:f4b9b85c7b62 | 67 | #define NUMFRAMES 570 //1 ms before refresh was 357 |
Pokitto | 31:f4b9b85c7b62 | 68 | |
Pokitto | 31:f4b9b85c7b62 | 69 | |
Pokitto | 31:f4b9b85c7b62 | 70 | // TODO: move these into some suitable place |
Pokitto | 31:f4b9b85c7b62 | 71 | extern void fakeISR(); |
Pokitto | 31:f4b9b85c7b62 | 72 | extern void audio_IRQ(); |
Pokitto | 31:f4b9b85c7b62 | 73 | extern void update_SDAudioStream(); |
Pokitto | 31:f4b9b85c7b62 | 74 | extern uint16_t soundbyte; |
Pokitto | 31:f4b9b85c7b62 | 75 | |
Pokitto | 31:f4b9b85c7b62 | 76 | #if POK_STREAMING_MUSIC |
Pokitto | 31:f4b9b85c7b62 | 77 | #define SPEAKER 3 |
Pokitto | 31:f4b9b85c7b62 | 78 | // #define BUFFER_SIZE 512 //5120 // was 256 |
Pokitto | 66:6281a40d73e6 | 79 | #if POK_HIGH_RAM == HIGH_RAM_MUSIC |
Pokitto | 66:6281a40d73e6 | 80 | extern unsigned char *buffers[]; |
Pokitto | 66:6281a40d73e6 | 81 | #else |
Pokitto | 31:f4b9b85c7b62 | 82 | extern unsigned char buffers[][BUFFER_SIZE]; |
Pokitto | 66:6281a40d73e6 | 83 | #endif |
Pokitto | 31:f4b9b85c7b62 | 84 | extern volatile int currentBuffer, oldBuffer; |
Pokitto | 31:f4b9b85c7b62 | 85 | extern volatile int bufindex, vol; |
Pokitto | 31:f4b9b85c7b62 | 86 | extern volatile unsigned char * currentPtr; |
Pokitto | 31:f4b9b85c7b62 | 87 | extern volatile unsigned char * endPtr; |
Pokitto | 31:f4b9b85c7b62 | 88 | extern int8_t streamvol; |
Pokitto | 31:f4b9b85c7b62 | 89 | extern uint32_t streamcounter; |
Pokitto | 31:f4b9b85c7b62 | 90 | extern uint8_t streamstep; |
Pokitto | 31:f4b9b85c7b62 | 91 | #endif |
Pokitto | 31:f4b9b85c7b62 | 92 | |
Pokitto | 31:f4b9b85c7b62 | 93 | #endif // POKITTO_GLOBS_H |
Pokitto | 31:f4b9b85c7b62 | 94 | |
Pokitto | 31:f4b9b85c7b62 | 95 |