BOOL initialise_direct_sound ( void ) { static int direct_sound_initialised = FALSE; if ( !direct_sound_initialised ) { if ( dsound_initialise () ) { register_exit_function ( dsound_release_objects ); register_post_activate_message_function ( dsound_restore_objects ); direct_sound_initialised = TRUE; set_fpu_rounding_mode_zero (); return ( TRUE ); } else { return ( FALSE ); } } return ( TRUE ); }
BOOL initialise_graphics_rendering_system ( void ) { initialise_direct_3d (); initialise_texture_system (); set_fpu_rounding_mode_zero (); return ( TRUE ); }
int main(int m_argc, char **m_argv) { int terminated; SDL_Event evert; argc = m_argc; argv = m_argv; // // Initialise SDL // atexit(SDL_Quit); if( SDL_Init(SDL_INIT_EVERYTHING) != 0 ) { debug_fatal("Unable to initialise SDL: %s", SDL_GetError()); return 1; } // // Install our own exception handler! // initialise_application_exception_handler (); // // Set the current directory to where the executable is located // set_application_current_directory (); // // Unlink the debug.log file here. // unlink ( "debug.log" ); system_thread_id = SDL_ThreadID (); application_debug_fatal = FALSE; application_active = TRUE; // // Initialise the memory statistics // initialise_memory_totals (); if ( !initialise_windows ( 1 ) ) { deinitialise_windows (); return ( FALSE ); } number_user_message_functions = 0; number_system_message_functions = 0; register_system_message_function ( SDL_USEREVENT, call_user_function_routine ); // register_system_message_function ( WM_SETCURSOR, windows_cursor_routine ); register_system_message_function ( SDL_VIDEOEXPOSE, windows_paint_routine ); register_system_message_function ( SDL_VIDEORESIZE, windows_sizemove_routine ); register_system_message_function ( SDL_SYSWMEVENT, windows_systemcommand_routine ); register_system_message_function ( SDL_QUIT, windows_close_request_routine ); initialise_cdrom_system (); initialise_system_thread_calling_function (); exit_message_id = get_unique_message_id (); register_user_message_function ( exit_message_id, windows_exit_routine ); // // The graphics / 3d / 2d systems need the maths fpu to round to zero // set_fpu_rounding_mode_zero (); set_fpu_exceptions (); initialise_event_system (); initialise_timers_system (); initialise_file_system (); terminated = FALSE; application_thread_handle = (SDL_Thread *) SDL_CreateThread ( start_application, NULL ); application_thread_id = SDL_GetThreadID ( application_thread_handle ); // SetThreadPriority ( GetCurrentThread (), THREAD_PRIORITY_ABOVE_NORMAL ); while(SDL_WaitEvent( &evert )) { if(!application_window_proc(&evert)) { generate_keyboard_events ( &evert ); generate_mouse_events ( &evert ); } } return ( 0 ); }
void start_application ( void ) { int string, count, argc; char strings[32][64], *argv[32], *ptr; SetThreadPriority ( GetCurrentThread (), THREAD_PRIORITY_NORMAL ); strcpy ( &strings[0][0], "APPLICATION" ); argv[0] = &strings[0][0]; ptr = main_command_line; count = 0; string = 1; while ( *ptr != '\0' ) { while ( ( *ptr != ' ' ) && ( *ptr != '\0' ) ) { strings[string][count] = *ptr; count++; ptr++; } if ( *ptr == ' ' ) { ptr++; } strings[string][count] = '\0'; argv[string] = &strings[string][0]; count = 0; string++; } argc = string; // // The graphics / 3d / 2d systems need the maths fpu to round to zero // set_fpu_rounding_mode_zero (); set_fpu_exceptions (); application_main ( argc, argv ); }
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; int terminated; // // Initialise DCOM // CoInitializeEx ( NULL, COINIT_MULTITHREADED ); // // Install our own exception handler! // initialise_application_exception_handler (); // // Set the current directory to where the executable is located // set_application_current_directory (); // // Unlink the debug.log file here. // unlink ( "debug.log" ); system_thread_id = GetCurrentThreadId (); application_debug_fatal = FALSE; application_active = TRUE; // // Initialise the memory statistics // initialise_memory_totals (); if ( !initialise_windows ( hInstance, nCmdShow ) ) { deinitialise_windows (); return ( FALSE ); } application_instance = hInstance; number_user_message_functions = 0; number_system_message_functions = 0; number_pre_activate_message_functions = 0; number_post_activate_message_functions = 0; register_system_message_function ( WM_USER, call_user_function_routine ); register_system_message_function ( WM_SETCURSOR, windows_cursor_routine ); register_system_message_function ( WM_ACTIVATE, call_pre_activate_function_routine ); register_system_message_function ( WM_ACTIVATEAPP, call_post_activate_function_routine ); register_system_message_function ( WM_PAINT, windows_paint_routine ); register_system_message_function ( WM_MOVE, windows_sizemove_routine ); register_system_message_function ( WM_SYSCOMMAND, windows_systemcommand_routine ); register_system_message_function ( WM_CLOSE, windows_close_request_routine ); initialise_cdrom_system (); initialise_system_thread_calling_function (); exit_message_id = get_unique_message_id (); register_user_message_function ( exit_message_id, windows_exit_routine ); // // The graphics / 3d / 2d systems need the maths fpu to round to zero // set_fpu_rounding_mode_zero (); set_fpu_exceptions (); initialise_event_system (); initialise_timers_system (); initialise_file_system (); main_command_line = lpCmdLine; terminated = FALSE; application_thread_handle = CreateThread ( (LPSECURITY_ATTRIBUTES) NULL, 0, (LPTHREAD_START_ROUTINE) start_application, 0, 0, &application_thread_id ); SetThreadPriority ( GetCurrentThread (), THREAD_PRIORITY_ABOVE_NORMAL ); while ( !terminated ) { DWORD message_index, object_count; HANDLE handle_array[2]; object_count = 0; if ( keyboard_handle ) { handle_array[object_count] = keyboard_handle; object_count++; } if ( mouse_handle ) { handle_array[object_count] = mouse_handle; object_count++; } message_index = MsgWaitForMultipleObjects( object_count, handle_array, 0, INFINITE, QS_ALLINPUT); // message_index = MsgWaitForMultipleObjects( object_count, handle_array, 0, 100, QS_ALLINPUT); if ( ( message_index >= object_count ) || ( message_index == WAIT_TIMEOUT ) ) { // // Default windows messaging // while ( PeekMessage ( &msg, NULL, 0, 0, PM_REMOVE ) ) { if ( msg.message == WM_QUIT ) { terminated = TRUE; } else { TranslateMessage(&msg); DispatchMessage(&msg); } } } else { if ( handle_array[message_index] == keyboard_handle ) { generate_keyboard_events (); } else if ( handle_array[message_index] == mouse_handle ) { generate_mouse_events (); } } } CoUninitialize (); return ( msg.wParam ); }
void full_initialise_game (void) { char buffer [1024]; //////////////////////////////////////// // // WARNING! INITIALISATION ORDER IS CRITICAL // // NOTE : MEMORY BLOCK SYSTEM CONSTRAINTS; // DO NOT USE REGISTER_EXIT_FUNCTION // FOR DEINITIALISATION. // //////////////////////////////////////// //////////////////////////////////////// // // INITIALISE GRAPHICS FILES // //////////////////////////////////////// { char buffer[256]; #if ( OEM_3DLABS_VERSION ) sprintf ( buffer, "3DLabs Demonstration version" ); #else sprintf ( buffer, "%s: %d. %d. %d %s", get_trans ("Version"), MAJOR_VERSION, DATA_VERSION, MINOR_VERSION, BUILD_TYPE ); #endif set_ui_object_text (version_text, buffer); // add_to_pop_up_list ( buffer, init_screen_message_area, NULL, 0, UI_FONT_ARIAL_14, ui_colour_white ); } if ( ( !get_global_graphics_files_installed () ) || command_line_new_graphics ) { float file_count, percentage; int graphics_count_to_convert; char buffer [256]; file_count = 0; graphics_count_to_convert = get_uninstalled_graphics_file_count ( GRAPHICS_CONVERSION_SECOND_PASS ); if ( graphics_count_to_convert ) { debug_log ( "First time graphics conversion" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("First Time Graphics Conversion")); set_ui_object_text (initialising_text, buffer); while (!install_graphics_files (GRAPHICS_CONVERSION_SECOND_PASS)) { file_count ++; percentage = (file_count / graphics_count_to_convert) * 100.0; sprintf ( buffer, "%s...%s %.0f%%", get_trans ("Loading"), get_trans ("First Time Graphics Conversion"), percentage ); set_ui_object_text (initialising_text, buffer); set_ui_object_redraw (init_screen, TRUE); ui_force_update (); } sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("First Time Graphics Conversion")); set_ui_object_text (initialising_text, buffer); } } save_global_options_data (); debug_log ( "Opening graphics files" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("Graphics")); set_ui_object_text (initialising_text, buffer); ui_force_update (); mopen_all_graphics_files (GRAPHICS_CONVERSION_SECOND_PASS); // // Check Apache Havoc FFP files exist // check_apache_havoc_ffp_files (); //////////////////////////////////////// // // STATE IF APHAVOC INSTALLED // //////////////////////////////////////// #if !DEMO_VERSION if (get_global_apache_havoc_installed ()) { char buffer [256]; sprintf (buffer, "Apache Havoc: %s", get_trans ("MP_INSTALLED")); set_ui_object_text (ah_installed_text, buffer); process_ingame_text_object_size (ah_installed_text, NULL, NULL, 0, RESIZE_OPTION_FIXED_BUTTON); ui_force_update (); } #else set_global_apache_havoc_installed (FALSE); #endif //////////////////////////////////////// // // INITIALISE MATHS LIBRARY // //////////////////////////////////////// debug_log ( "Initialising maths library" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("Maths")); set_ui_object_text (initialising_text, buffer); ui_force_update (); initialise_maths_library (); //////////////////////////////////////// // // INITIALISE CD PLAYER // //////////////////////////////////////// debug_log ( "Initialising CD audio" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("CD Rom")); set_ui_object_text (initialising_text, buffer); ui_force_update (); capture_cd_audio_device (); #ifdef COMMERCIAL #if !DEMO_VERSION #if ( LANGUAGE != LANGUAGE_SPANISH ) // if ( !check_cd_for_80_minutes () ) // { // // debug_fatal ("Unable to find the Enemy Engaged RAH66 Comanche Vs KA52 Hokum CD\n\nPlease insert the CD and try again ..."); // } #endif #endif #endif //////////////////////////////////////// // // INITIALISE JOYSTICK // //////////////////////////////////////// debug_log ( "Initialising joysticks" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("Joystick")); set_ui_object_text (initialising_text, buffer); ui_force_update (); initialise_joysticks (); //////////////////////////////////////// // // INITIALISE UPDATE FUNCTIONS // //////////////////////////////////////// debug_log ( "Initialising update function list" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("Update")); set_ui_object_text (initialising_text, buffer); ui_force_update (); initialise_update_function_list (); //////////////////////////////////////// // // INITIALISE DIRECT PLAY // //////////////////////////////////////// debug_log ( "Initialising direct play" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("Comms System")); set_ui_object_text (initialising_text, buffer); ui_force_update (); direct_play_initialise_system (); // // Register the application for any lobbies // direct_play_register_application ( "COMANCHE HOKUM", "cohokum.exe" ); //////////////////////////////////////// // // INITIALISE COMMS // //////////////////////////////////////// // // DEPENDENCY: initialise_comms BEFORE initialise_entity_system // debug_log ( "Initialising comms manager" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("Comms System")); set_ui_object_text (initialising_text, buffer); ui_force_update (); initialise_comms_manager (); initialise_comms (); initialise_comms_debug (); //////////////////////////////////////// // // INITIALISE 3D SYSTEM // //////////////////////////////////////// debug_log ( "Initialising 3d system" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("3D System")); set_ui_object_text (initialising_text, buffer); ui_force_update (); initialise_application_3d_system (); initialise_terrain_database (); set_fpu_rounding_mode_zero (); //////////////////////////////////////// // // INITIALISE FILE TAG SYSTEM // //////////////////////////////////////// debug_log ( "Installing file tag system" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("Tag System")); set_ui_object_text (initialising_text, buffer); ui_force_update (); initialise_file_tag_system (); //////////////////////////////////////// // // INITIALISE USER-INTERFACE // //////////////////////////////////////// debug_log ( "Initialising ui menus" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("UI Manager")); set_ui_object_text (initialising_text, buffer); ui_force_update (); initialise_ui_menus (); //////////////////////////////////////// // // INITIALISE ENTITY SYSTEM // //////////////////////////////////////// debug_log ( "Initialising entity system" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("System Manager")); set_ui_object_text (initialising_text, buffer); ui_force_update (); initialise_entity_system (125000); //////////////////////////////////////// // // INITIALISE AI SYSTEM // //////////////////////////////////////// debug_log ( "Initialising ai system" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("AI System")); set_ui_object_text (initialising_text, buffer); ui_force_update (); initialise_ai_system (); //////////////////////////////////////// // // INITIALISE USER DEFINED KEYS // //////////////////////////////////////// debug_log ( "Initialising user defined events" ); initialise_user_defined_events (); //////////////////////////////////////// // // INITIALISE PLAYER LIST // //////////////////////////////////////// debug_log ( "Initialising player list" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("Players")); set_ui_object_text (initialising_text, buffer); ui_force_update (); load_player_list (); //////////////////////////////////////// // // INITIALISE MEDAL / PROMOTION NAME DATABASE // //////////////////////////////////////// initialise_medal_and_promotion_names (); //////////////////////////////////////// // // INITIALISE SOUND SYSTEM // //////////////////////////////////////// debug_log ( "Initialising sound system" ); sprintf (buffer, "%s...%s", get_trans ("Loading"), get_trans ("Sound System")); set_ui_object_text (initialising_text, buffer); ui_force_update (); initialise_application_sound_system (); initialise_game_initialisation_phases (); debug_log ( "Finished Full initialise" ); set_ui_object_text ( initialising_text, get_trans ("Finished Initialisation") ); ui_force_update (); // play_avi ( "wenesday.avi", 0 ); }