1 /* 2 * Seven Kingdoms: Ancient Adversaries 3 * 4 * Copyright 1997,1998 Enlight Software Ltd. 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * 19 */ 20 21 //Filename : OSYS.H 22 //Description : Header file for Game class 23 24 #ifndef __OSYS_H 25 #define __OSYS_H 26 27 #include <ALL.h> 28 #include <stdint.h> 29 30 //------ Define common data buffer size ------// 31 32 enum { COMMON_DATA_BUF_SIZE = 64*1024 }; // keep a 64K common buffer for all temporary memory storage like reading files temporarily into memory 33 34 //-------------- define constant ------------// 35 36 #define FRAMES_PER_DAY 10 // no. of frames per day 37 38 #define MAX_SCENARIO_PATH 2 39 40 41 //------------ sys_flag --------------// 42 43 enum { SYS_PREGAME=0, SYS_RUN }; 44 45 //--------- game version ---------// 46 47 enum { VERSION_FULL, 48 VERSION_DEMO, 49 VERSION_MULTIPLAYER_ONLY }; 50 51 //--------- Define info modes --------// 52 53 enum { VIEW_MODE_COUNT=10 }; 54 55 enum { MODE_NORMAL, 56 MODE_NATION, 57 MODE_TOWN, 58 MODE_ECONOMY, 59 MODE_TRADE, 60 MODE_MILITARY, 61 MODE_TECH, 62 MODE_SPY, 63 MODE_RANK, 64 MODE_NEWS_LOG, 65 MODE_AI_ACTION, 66 }; 67 68 //### begin alex 11/8 ###// 69 //------------------ define debug_seed_status_flag ----------------// 70 enum { NO_DEBUG_SYN = 0, 71 DEBUG_SYN_LOAD_AND_COMPARE_ONCE, 72 DEBUG_SYN_AUTO_SAVE, 73 DEBUG_SYN_AUTO_LOAD, 74 }; 75 //#### end alex 11/8 ####// 76 77 enum KeyEventType : int; 78 79 //-------- Define class Sys -----------// 80 81 class Sys 82 { 83 public: 84 char game_version; // VERSION_??? 85 86 char sys_flag; 87 char init_flag; 88 char signal_exit_flag; // 0 - not exiting; 1 - exit to OS; 2 - exit to main menu 89 char need_redraw_flag; // set to 1 if task switched back. After redraw, clear it 90 char toggle_full_screen_flag; 91 char cheat_enabled_flag; 92 char user_pause_flag; 93 char disp_fps_flag; 94 95 char view_mode; // the view mode can be MODE_??? 96 97 char map_need_redraw; 98 char zoom_need_redraw; 99 100 //------ frame related vars -----// 101 102 int day_frame_count; 103 uint32_t next_frame_time; // next frame's time for maintaining a specific game speed 104 105 //----- multiplayer vars ----// 106 107 char is_mp_game; 108 uint32_t frame_count; // frame count, for is_sync_frame only 109 char is_sync_frame; // whether sync should take place at the current frame (for handling one sync per n frames) 110 char mp_save_flag; // indicate a request to save game in multi-player game 111 uint32_t mp_save_frame; // save game in which frame 112 113 //---- continous key string -----// 114 115 enum { MAX_KEY_STR = 10 }; // Maximum 10 different key string 116 117 int key_str_pos[MAX_KEY_STR]; // for detecting cheating codes 118 119 //-------- statistic --------// 120 121 uint32_t last_second_time; 122 int frames_in_this_second; 123 int frames_per_second; // the actual frames per second 124 125 //------- file paths -------// 126 127 char cdrom_drive; 128 129 char dir_config[FilePath::MAX_FILE_PATH]; 130 char dir_image[FilePath::MAX_FILE_PATH]; 131 char dir_encyc[FilePath::MAX_FILE_PATH]; 132 char dir_encyc2[FilePath::MAX_FILE_PATH]; 133 char dir_music[FilePath::MAX_FILE_PATH]; 134 char dir_movie[FilePath::MAX_FILE_PATH]; 135 char dir_tutorial[FilePath::MAX_FILE_PATH]; 136 137 union 138 { 139 char dir_scenario[FilePath::MAX_FILE_PATH]; 140 char dir_scenario_path[MAX_SCENARIO_PATH][FilePath::MAX_FILE_PATH]; 141 }; 142 143 //------- other vars --------// 144 145 char* common_data_buf; 146 char debug_session; 147 char testing_session; 148 149 public: 150 Sys(); 151 ~Sys(); 152 153 int init(); 154 void deinit(); 155 void deinit_directx(); 156 void deinit_objects(); 157 158 void run(int=0); 159 void yield(); 160 void yield_wsock_msg(); 161 162 void set_speed(int frameSpeed, int remoteCall=0); 163 void set_view_mode(int viewMode, int viewingNationRecno=0, int viewingSpyRecno=0); 164 // ##### begin Gilbert 22/10 #######// 165 void disp_view_mode(int observeMode=0); 166 // ##### end Gilbert 22/10 #######// 167 void capture_screen(); 168 169 void disp_frame(); 170 void blt_virtual_buf(); 171 172 void pause(); 173 void unpause(); 174 175 void show_error_dialog(const char *formatStr, ...); 176 177 void mp_request_save(uint32_t frame); 178 void mp_clear_request_save(); 179 180 //-------------- single player syn. game testing functions --------------// 181 void sp_create_seed_file(char *filename); 182 void sp_close_seed_file(); 183 void sp_load_seed_file(); 184 void sp_record_match_seed(); 185 void sp_record_seed(); 186 void sp_write_seed(); 187 void sp_compare_seed(); 188 void sp_seed_pos_reset(); 189 void sp_seed_pos_set(int pos); 190 191 //---- for setting game directories ----// 192 193 int set_config_dir(); 194 int chdir_to_game_dir(); 195 int set_game_dir(); 196 int set_one_dir(const char* checkFileName, const char* defaultDir, char* trueDir); 197 198 //-------- for load/save games --------// 199 200 int write_file(File* filePtr); 201 int read_file(File* filePtr); 202 void save_game(); 203 void load_game(); 204 205 private: 206 int init_directx(); 207 int init_objects(); 208 209 void main_loop(int); 210 void detect(); 211 void process(); 212 213 void disp_button(); 214 void detect_button(); 215 216 void disp_view(); 217 void update_view(); 218 void detect_view(); 219 220 void disp_map(); 221 void disp_zoom(); 222 223 int should_next_frame(); 224 int is_mp_sync( int *unreadyPlayerFlag ); 225 void auto_save(); 226 227 void disp_frames_per_second(); 228 229 void process_key(unsigned scanCode, unsigned skeyState); 230 231 void detect_letter_key(unsigned scanCode, unsigned skeyState); 232 void detect_function_key(unsigned scanCode, unsigned skeyState); 233 void detect_cheat_key(unsigned scanCode, unsigned skeyState); 234 int detect_debug_cheat_key(unsigned scanCode, unsigned skeyState); 235 int detect_set_speed(unsigned scanCode, unsigned skeyState); 236 237 int detect_key_str(int keyStrId, const KeyEventType* keyStr); 238 }; 239 240 extern Sys sys; 241 #ifdef DEBUG 242 extern char debug2_enable_flag; 243 extern File seedCompareFile; 244 //### begin alex 11/8 ###// 245 extern char debug_seed_status_flag; 246 //#### end alex 11/8 ####// 247 extern int debug_sim_game_type; 248 #endif 249 250 //-------------------------------------// 251 252 #endif 253 254 255