PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Committer:
Pokitto
Date:
Tue Jan 30 10:41:47 2018 +0000
Revision:
31:f4b9b85c7b62
Sound output improvements added:  louder, clearer, faster!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pokitto 31:f4b9b85c7b62 1 #ifndef GBCOMPATIBILITY_H
Pokitto 31:f4b9b85c7b62 2 #define GBCOMPATIBILITY_H
Pokitto 31:f4b9b85c7b62 3
Pokitto 31:f4b9b85c7b62 4 /*
Pokitto 31:f4b9b85c7b62 5 * (C) Copyright 2014 Aurélien Rodot. All rights reserved.
Pokitto 31:f4b9b85c7b62 6 *
Pokitto 31:f4b9b85c7b62 7 * This file is part of the Gamebuino Library (http://gamebuino.com)
Pokitto 31:f4b9b85c7b62 8 *
Pokitto 31:f4b9b85c7b62 9 * The Gamebuino Library is free software: you can redistribute it and/or modify
Pokitto 31:f4b9b85c7b62 10 * it under the terms of the GNU Lesser General Public License as published by
Pokitto 31:f4b9b85c7b62 11 * the Free Software Foundation, either version 3 of the License, or
Pokitto 31:f4b9b85c7b62 12 * (at your option) any later version.
Pokitto 31:f4b9b85c7b62 13 *
Pokitto 31:f4b9b85c7b62 14 * This program is distributed in the hope that it will be useful,
Pokitto 31:f4b9b85c7b62 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Pokitto 31:f4b9b85c7b62 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Pokitto 31:f4b9b85c7b62 17 * GNU Lesser General Public License for more details.
Pokitto 31:f4b9b85c7b62 18 *
Pokitto 31:f4b9b85c7b62 19 * You should have received a copy of the GNU Lesser General Public License
Pokitto 31:f4b9b85c7b62 20 * along with this program. If not, see <http://www.gnu.org/licenses/>
Pokitto 31:f4b9b85c7b62 21 */
Pokitto 31:f4b9b85c7b62 22
Pokitto 31:f4b9b85c7b62 23
Pokitto 31:f4b9b85c7b62 24
Pokitto 31:f4b9b85c7b62 25 #ifndef SETTINGS_C
Pokitto 31:f4b9b85c7b62 26 #define SETTINGS_C
Pokitto 31:f4b9b85c7b62 27
Pokitto 31:f4b9b85c7b62 28 #include "binary.h"
Pokitto 31:f4b9b85c7b62 29
Pokitto 31:f4b9b85c7b62 30 #define _BV(bit) (1 << (bit)) //jonne
Pokitto 31:f4b9b85c7b62 31
Pokitto 31:f4b9b85c7b62 32 #define NOROT 0
Pokitto 31:f4b9b85c7b62 33 #define ROTCCW 1
Pokitto 31:f4b9b85c7b62 34 #define ROT180 2
Pokitto 31:f4b9b85c7b62 35 #define ROTCW 3
Pokitto 31:f4b9b85c7b62 36
Pokitto 31:f4b9b85c7b62 37 //colors
Pokitto 31:f4b9b85c7b62 38 #define WHITE 0
Pokitto 31:f4b9b85c7b62 39 #define BLACK 1
Pokitto 31:f4b9b85c7b62 40 #define GRAY 2
Pokitto 31:f4b9b85c7b62 41 #define INVERT 255
Pokitto 31:f4b9b85c7b62 42
Pokitto 31:f4b9b85c7b62 43 //for extended bitmap function :
Pokitto 31:f4b9b85c7b62 44 #define NOROT 0
Pokitto 31:f4b9b85c7b62 45 #define ROTCCW 1
Pokitto 31:f4b9b85c7b62 46 #define ROT180 2
Pokitto 31:f4b9b85c7b62 47 #define ROTCW 3
Pokitto 31:f4b9b85c7b62 48 #define NOFLIP 0
Pokitto 31:f4b9b85c7b62 49 #define FLIPH 1
Pokitto 31:f4b9b85c7b62 50 #define FLIPV 2
Pokitto 31:f4b9b85c7b62 51 #define FLIPVH 3
Pokitto 31:f4b9b85c7b62 52
Pokitto 31:f4b9b85c7b62 53
Pokitto 31:f4b9b85c7b62 54
Pokitto 31:f4b9b85c7b62 55
Pokitto 31:f4b9b85c7b62 56 //SETTINGS YOU CAN EDIT
Pokitto 31:f4b9b85c7b62 57
Pokitto 31:f4b9b85c7b62 58 #define NUM_CHANNELS 1 //number of sound channels, between 0 and 4
Pokitto 31:f4b9b85c7b62 59 #define DISPLAY_ROT NOROT //set to NOROT, ROTCCW, ROT180 or ROTCW. Can be used to play in portrait mode.
Pokitto 31:f4b9b85c7b62 60 #define ENABLE_GUI 1 //enable menu, keyboard, pop-up, volume adjust functions
Pokitto 31:f4b9b85c7b62 61 #define ENABLE_BITMAPS 1 //will replace bitmaps with rectangles if disabled
Pokitto 31:f4b9b85c7b62 62 #define ENABLE_GRAYSCALE 1 //allows the use of the GRAY color
Pokitto 31:f4b9b85c7b62 63 #define EXTENDED_NOTE_RANGE 0 //allows the use of notes above A 5... please avoid that they sound really bad
Pokitto 31:f4b9b85c7b62 64
Pokitto 31:f4b9b85c7b62 65 //not really useful
Pokitto 31:f4b9b85c7b62 66 #define ENABLE_BATTERY 1 //disable battery monitoring
Pokitto 31:f4b9b85c7b62 67 #define ENABLE_BACKLIGHT 1 //disable automatic back-light
Pokitto 31:f4b9b85c7b62 68
Pokitto 31:f4b9b85c7b62 69 //IT'S STRONGLY ADVISED TO LEAVE THE FOLLOWING SETTINGS ALONE
Pokitto 31:f4b9b85c7b62 70
Pokitto 31:f4b9b85c7b62 71 //defaults values of settings which can be adjusted on each Gamebuino using settings.hex
Pokitto 31:f4b9b85c7b62 72 #define SCR_CONTRAST 60
Pokitto 31:f4b9b85c7b62 73 #define START_MENU_TIMER 255 //40 = 40 frames (2sec) before start menu is skipped, 0 = no start menu, 255 = start menu until you press A
Pokitto 31:f4b9b85c7b62 74
Pokitto 31:f4b9b85c7b62 75 //addresses of settings stored in the program memory
Pokitto 31:f4b9b85c7b62 76 #define SETTINGS_PAGE ((const char *)(0x7800-128))
Pokitto 31:f4b9b85c7b62 77 #define SETTINGS_TOKEN 0xC001
Pokitto 31:f4b9b85c7b62 78 #define OFFSET_CURRENTGAME 2
Pokitto 31:f4b9b85c7b62 79 #define OFFSET_USERNAME 11
Pokitto 31:f4b9b85c7b62 80 #define USERNAME_LENGTH 10
Pokitto 31:f4b9b85c7b62 81 #define OFFSET_CONTRAST 22
Pokitto 31:f4b9b85c7b62 82 #define OFFSET_BACKLIGHT_MIN 23
Pokitto 31:f4b9b85c7b62 83 #define OFFSET_BACKLIGHT_MAX 24
Pokitto 31:f4b9b85c7b62 84 #define OFFSET_LIGHT_MIN 25
Pokitto 31:f4b9b85c7b62 85 #define OFFSET_LIGHT_MAX 27
Pokitto 31:f4b9b85c7b62 86 #define OFFSET_VOLUME_MAX 29
Pokitto 31:f4b9b85c7b62 87 #define OFFSET_VOLUME_DEFAULT 30
Pokitto 31:f4b9b85c7b62 88 #define OFFSET_START_MENU_TIMER 31
Pokitto 31:f4b9b85c7b62 89 #define OFFSET_BATTERY_CRITIC 32
Pokitto 31:f4b9b85c7b62 90 #define OFFSET_BATTERY_LOW 34
Pokitto 31:f4b9b85c7b62 91 #define OFFSET_BATTERY_MED 36
Pokitto 31:f4b9b85c7b62 92 #define OFFSET_BATTERY_FULL 38
Pokitto 31:f4b9b85c7b62 93
Pokitto 31:f4b9b85c7b62 94 //GUI
Pokitto 31:f4b9b85c7b62 95 #define KEYBOARD_W 16
Pokitto 31:f4b9b85c7b62 96 #define KEYBOARD_H 8
Pokitto 31:f4b9b85c7b62 97
Pokitto 31:f4b9b85c7b62 98 //sound
Pokitto 31:f4b9b85c7b62 99 #define VOLUME_CHANNEL_MAX 255/NUM_CHANNELS/7/9 //7=instrument volume 9=note volume
Pokitto 31:f4b9b85c7b62 100
Pokitto 31:f4b9b85c7b62 101 //battery voltage monitor
Pokitto 31:f4b9b85c7b62 102 #define BAT_PIN 6 //was A6
Pokitto 31:f4b9b85c7b62 103 #define NUM_LVL 4
Pokitto 31:f4b9b85c7b62 104 #define BAT_LVL_CRITIC 3500
Pokitto 31:f4b9b85c7b62 105 #define BAT_LVL_LOW 3550
Pokitto 31:f4b9b85c7b62 106 #define BAT_LVL_MED 3700
Pokitto 31:f4b9b85c7b62 107 #define BAT_LVL_FULL 3900
Pokitto 31:f4b9b85c7b62 108
Pokitto 31:f4b9b85c7b62 109 //SD card
Pokitto 31:f4b9b85c7b62 110 #define SD_CS 10
Pokitto 31:f4b9b85c7b62 111
Pokitto 31:f4b9b85c7b62 112 //screens back light
Pokitto 31:f4b9b85c7b62 113 #define BACKLIGHT_PIN 5
Pokitto 31:f4b9b85c7b62 114 //auto back-light levels
Pokitto 31:f4b9b85c7b62 115 #define BACKLIGHT_MIN 0
Pokitto 31:f4b9b85c7b62 116 #define BACKLIGHT_MAX 255
Pokitto 31:f4b9b85c7b62 117
Pokitto 31:f4b9b85c7b62 118 //ambient light sensor
Pokitto 31:f4b9b85c7b62 119 #define AMBIENTLIGHT_PIN A7
Pokitto 31:f4b9b85c7b62 120 //auto back-light levels
Pokitto 31:f4b9b85c7b62 121 #define AMBIENTLIGHT_MIN 800 //800
Pokitto 31:f4b9b85c7b62 122 #define AMBIENTLIGHT_MAX 980 //1000
Pokitto 31:f4b9b85c7b62 123 #define AMBIENTLIGHT_SMOOTHING 16
Pokitto 31:f4b9b85c7b62 124
Pokitto 31:f4b9b85c7b62 125 //number of buttons
Pokitto 31:f4b9b85c7b62 126 #define NUM_BTN 7
Pokitto 31:f4b9b85c7b62 127 //buttons ID
Pokitto 31:f4b9b85c7b62 128 #if DISPLAY_ROT == 0
Pokitto 31:f4b9b85c7b62 129 #define BTN_UP 1
Pokitto 31:f4b9b85c7b62 130 #define BTN_RIGHT 2
Pokitto 31:f4b9b85c7b62 131 #define BTN_DOWN 3
Pokitto 31:f4b9b85c7b62 132 #define BTN_LEFT 0
Pokitto 31:f4b9b85c7b62 133 #elif DISPLAY_ROT == ROTCCW
Pokitto 31:f4b9b85c7b62 134 #define BTN_UP 2
Pokitto 31:f4b9b85c7b62 135 #define BTN_RIGHT 3
Pokitto 31:f4b9b85c7b62 136 #define BTN_DOWN 0
Pokitto 31:f4b9b85c7b62 137 #define BTN_LEFT 1
Pokitto 31:f4b9b85c7b62 138 #elif DISPLAY_ROT == ROT180
Pokitto 31:f4b9b85c7b62 139 #define BTN_UP 3
Pokitto 31:f4b9b85c7b62 140 #define BTN_RIGHT 0
Pokitto 31:f4b9b85c7b62 141 #define BTN_DOWN 1
Pokitto 31:f4b9b85c7b62 142 #define BTN_LEFT 2
Pokitto 31:f4b9b85c7b62 143 #elif DISPLAY_ROT == ROTCW
Pokitto 31:f4b9b85c7b62 144 #define BTN_UP 0
Pokitto 31:f4b9b85c7b62 145 #define BTN_RIGHT 1
Pokitto 31:f4b9b85c7b62 146 #define BTN_DOWN 2
Pokitto 31:f4b9b85c7b62 147 #define BTN_LEFT 3
Pokitto 31:f4b9b85c7b62 148 #endif
Pokitto 31:f4b9b85c7b62 149 #define BTN_A 4
Pokitto 31:f4b9b85c7b62 150 #define BTN_B 5
Pokitto 31:f4b9b85c7b62 151 #define BTN_C 6
Pokitto 31:f4b9b85c7b62 152
Pokitto 31:f4b9b85c7b62 153 #define BTN_LEFT_PIN 0
Pokitto 31:f4b9b85c7b62 154 #define BTN_UP_PIN 1
Pokitto 31:f4b9b85c7b62 155 #define BTN_RIGHT_PIN 2
Pokitto 31:f4b9b85c7b62 156 #define BTN_DOWN_PIN 3
Pokitto 31:f4b9b85c7b62 157 #define BTN_A_PIN 4
Pokitto 31:f4b9b85c7b62 158 #define BTN_B_PIN 5
Pokitto 31:f4b9b85c7b62 159 #define BTN_C_PIN 6
Pokitto 31:f4b9b85c7b62 160
Pokitto 31:f4b9b85c7b62 161
Pokitto 31:f4b9b85c7b62 162
Pokitto 31:f4b9b85c7b62 163 #endif /* */
Pokitto 31:f4b9b85c7b62 164
Pokitto 31:f4b9b85c7b62 165 const uint16_t startupSound[] = {0x0005,0x3089,0x208,0x238,0x7849,0x1468,0x0000};
Pokitto 31:f4b9b85c7b62 166
Pokitto 31:f4b9b85c7b62 167 const uint8_t gamebuinoLogo[] =
Pokitto 31:f4b9b85c7b62 168 {
Pokitto 31:f4b9b85c7b62 169 84,10, //width and height
Pokitto 31:f4b9b85c7b62 170 B00000011, B11100001, B10000001, B10000110, B01111111, B00111110, B00011000, B01101101, B10000011, B00001111, B00001111,
Pokitto 31:f4b9b85c7b62 171 B00001110, B00000001, B10000011, B10000110, B01100000, B00110011, B00011000, B01101101, B11000011, B00011001, B10001111,
Pokitto 31:f4b9b85c7b62 172 B00011000, B00000011, B11000011, B10001110, B01100000, B00110011, B00011000, B01101101, B11100011, B00110000, B11001111,
Pokitto 31:f4b9b85c7b62 173 B00011000, B00000011, B11000011, B10011110, B01100000, B00110110, B00110000, B11001101, B11100011, B01100000, B11001111,
Pokitto 31:f4b9b85c7b62 174 B00110000, B00000110, B11000111, B10011110, B01111110, B00111110, B00110000, B11001101, B10110011, B01100000, B11001111,
Pokitto 31:f4b9b85c7b62 175 B00110000, B00001100, B11000110, B11110110, B01100000, B00110011, B00110000, B11011001, B10110110, B01100000, B11001111,
Pokitto 31:f4b9b85c7b62 176 B00110011, B11001111, B11001100, B11110110, B01100000, B01100001, B10110000, B11011011, B00011110, B01100000, B11001111,
Pokitto 31:f4b9b85c7b62 177 B00110000, B11011000, B01101100, B11100110, B11000000, B01100001, B10110000, B11011011, B00011110, B01100001, B10001111,
Pokitto 31:f4b9b85c7b62 178 B00011001, B10011000, B01101100, B11000110, B11000000, B01100011, B10110001, B10011011, B00001110, B00110011, B00001111,
Pokitto 31:f4b9b85c7b62 179 B00001111, B10110000, B01111000, B11000110, B11111111, B01111110, B00011111, B00011011, B00000110, B00011110, B00001111,
Pokitto 31:f4b9b85c7b62 180 };
Pokitto 31:f4b9b85c7b62 181
Pokitto 31:f4b9b85c7b62 182 #endif // GBCOMPATIBILITY_H
Pokitto 31:f4b9b85c7b62 183
Pokitto 31:f4b9b85c7b62 184