1 /** 2 * @file tecnoballz.h 3 * @brief Base of all classes, and main static methods of the game 4 * @created 2002-08-18 5 * @date 2014-09-29 6 * @copyright 1991-2014 TLK Games 7 * @author Bruno Ethvignot 8 * @version $Revision: 29 $ 9 */ 10 /* 11 * copyright (c) 1991-2014 TLK Games all rights reserved 12 * $Id: tecnoballz.h 29 2014-09-30 10:15:55Z bruno.ethvignot@gmail.com $ 13 * 14 * TecnoballZ is free software; you can redistribute it and/or modify 15 * it under the terms of the GNU General Public License as published by 16 * the Free Software Foundation; either version 3 of the License, or 17 * (at your option) any later version. 18 * 19 * TecnoballZ is distributed in the hope that it will be useful, but 20 * WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License 25 * along with this program; if not, write to the Free Software 26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 27 * MA 02110-1301, USA. 28 */ 29 #include <errno.h> 30 #include <fcntl.h> 31 #include <iostream> 32 #include <math.h> 33 #include <stdexcept> 34 #include <stdio.h> 35 #include <stdlib.h> 36 #include <string.h> 37 #include <sys/stat.h> 38 #include <sys/types.h> 39 #ifdef WIN32 40 #include <io.h> 41 #include "SDL/SDL.h" 42 #else 43 #include <unistd.h> 44 #include <sys/time.h> 45 #include <sys/utsname.h> 46 #include <pthread.h> 47 #include <unistd.h> 48 #include "SDL/SDL.h" 49 #endif 50 #include "../include/configfile.h" 51 #include "config.h" 52 #ifndef __TECNOBALLZ__ 53 #define __TECNOBALLZ__ 54 55 #if !defined(PACKAGE_STRING) 56 #define PACKAGE_STRING "TECNOBALLZ 0.93.1" 57 #endif 58 #define TECNOBALLZ_VERSION PACKAGE_STRING " (2014-09-30)" 59 60 61 /** Force bytes copy (SPARC unaligned memory access) */ 62 /* #define BYTES_COPY */ 63 #ifndef SCOREFILE 64 #define SCOREFILE "tecnoball" 65 #endif 66 #ifndef PREFIX 67 #define PREFIX "" 68 #endif 69 70 71 /** PlayStation Portable port, PSP is a handheld game console released 72 * and currently manufactured by Sony Computer Entertainment */ 73 /* #define TECNOBALLZ_PSP */ 74 /** GP2X port, GP2X is an open-source, 75 * Linux-based handheld video game console */ 76 /* #define TECNOBALLZ_GP2X */ 77 #ifdef TECNOBALLZ_GP2X 78 #undef TECNOBALLZ_PSP 79 #define TECNOBALLZ_HANDHELD_CONSOLE 80 #endif 81 #ifdef TECNOBALLZ_PSP 82 #undef TECNOBALLZ_GP2X 83 #define TECNOBALLZ_HANDHELD_CONSOLE 84 #endif 85 86 class tecnoballz; 87 class configfile; 88 class handler_high_score; 89 class handler_resources; 90 class handler_levels; 91 class handler_display; 92 class handler_keyboard; 93 #ifndef SOUNDISOFF 94 class handler_audio; 95 #endif 96 class list_sprites; 97 class handler_players; 98 class supervisor_bricks_level; 99 class supervisor_shop; 100 class supervisor_guards_level; 101 class supervisor_main_menu; 102 class supervisor_map_editor; 103 class bitmap_data; 104 class offscreen_surface; 105 106 const Sint32 SINUS_MASK = 511; 107 const Sint32 SINUS_DECA = 7; 108 class tecnoballz 109 { 110 public: 111 112 /** Different phases of the game */ 113 typedef enum 114 { 115 BRICKS_LEVEL = 1, 116 SHOP, 117 GUARDS_LEVEL, 118 MAIN_MENU, 119 MAP_EDITOR, 120 LEAVE_TECNOBALLZ 121 } 122 GAME_PHASE; 123 /** Different levels of difficulty */ 124 typedef enum 125 { 126 DIFFICULTY_EASY = 1, 127 DIFFICULTY_NORMAL, 128 DIFFICULTY_MEDIUM, 129 DIFFICULTY_HARD 130 } 131 DIFFICULTIES_ENUM; 132 133 public: 134 /** 4 levels of difficulty */ 135 static const Uint32 MAX_OF_DIFFICULTY_LEVELS = 4; 136 137 public: 138 /** True if verbose enable */ 139 static bool is_verbose; 140 /** Force 4 colors tiles set in bricks level */ 141 static bool force_4_colors_tiles; 142 /** 1=320x240 or 2=640x480 pixels */ 143 static Uint32 resolution; 144 /** True if static background tiles with bricks and ejectors 145 * draw inside. False if bricks and ejectors are sprites */ 146 static bool has_background; 147 /** Control paddle with absolute mouse position */ 148 static bool absolute_mouse_positioning; 149 static Sint32 arg_jumper; 150 151 protected: 152 /* object number */ 153 Uint32 object_num; 154 155 /* 156 * static members 157 */ 158 159 /** Current number of objects */ 160 static Uint32 objects_counter; 161 /** Counter the number of frames */ 162 static Uint32 frame_counter; 163 /** Random counting variable */ 164 static Sint32 random_counter; 165 /** Current phase of the game 166 * BRICKS_LEVEL, SHOP, GUARDS_LEVEL, 167 * MAIN_MENU, or MAP_EDITOR */ 168 static Uint32 current_phase; 169 /** Difficulty with which an average player may complete a game 170 * 1: easy; 2:normal 3:medium; 4:hard */ 171 static Sint32 difficulty_level; 172 /** If true then leaves the game definitively */ 173 static bool is_exit_game; 174 /** If true cheat mode is enabled. Before everything in the menu, 175 * the six names must be 040670. Also the cheat mode must be enabled 176 * in the shop. You can moving the pointer to the top left screen 177 * corner, and type [E], [T], [B] and [ENTER]. 178 */ 179 static bool is_enabled_cheat_mode; 180 /** True if six names of menu initialized to 040670 */ 181 static bool birth_flag; 182 /** Number of initial lifes */ 183 static Sint32 initial_num_of_lifes; 184 /** Number of players from 1 to 6 */ 185 static Sint32 number_of_players; 186 static const char nomprefix[]; 187 static handler_high_score *high_score; 188 /** Handler of the files resources */ 189 static handler_resources *resources; 190 static handler_levels *ptLev_data; 191 #ifndef SOUNDISOFF 192 static handler_audio *audio; 193 #endif 194 static handler_display *display; 195 static handler_keyboard *keyboard; 196 static list_sprites *sprites; 197 static handler_players *current_player; 198 static Sint16 *table_cosL; 199 static Sint16 *table_sinL; 200 /** A bitmap containing the current images of sprites */ 201 static bitmap_data *sprites_bitmap; 202 /** The main offscreen surface of the game */ 203 static offscreen_surface *game_screen; 204 static offscreen_surface *background_screen; 205 static configfile *config_file; 206 207 public: 208 static void first_init (configfile * pConf); 209 static void game_begin (); 210 static void release_all_objects (configfile * pConf); 211 static void integer_to_ascii (Sint32 value, Uint32 padding, char *str); 212 tecnoballz (); 213 virtual ~tecnoballz (); 214 void object_init (); 215 void object_free (); 216 void int_to_big_endian (Uint32 *, Uint32 *); 217 void big_endian_to_int (Uint32 *, Uint32 *); 218 }; 219 #endif 220