Exemplo n.º 1
0
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 );
}
Exemplo n.º 2
0
void  main()

{
   int   message[8], flag;
   char  string[6];

   gl_apid = appl_init();

   if (! _app) {
        menu_register (gl_apid, "  Super Server");
        evnt_timer (1000, 0);
      }

   if (! rsrc_load ("IND.RSC")) {
        form_alert (1, "[1][ |   Cannot find IND.RSC !   ][ Cancel ]");
        terminate();   return;
      }

   get_path();

   if (initialise_windows (4, ICONIFY) == 0) {
        leave_windows();   rsrc_free();   terminate();
        return;
      }

   if (get_version (string) > 0) {
        form_alert (1, 
                "[1][ |   STiK is not loaded,    | |      or corrupted !][ Cancel ]");
        leave_windows();   rsrc_free();   terminate();
        return;
      }
   change_freestring (START, ST_VERS,  -1, string, 5);
   change_freestring (START, SS_VERS,  -1, version, 5);

   set_api_struct();

   if (init_modules() == 0) {
        leave_windows();   rsrc_free();   terminate();
        return;
      }
   set_callbacks (CB_EVENT, (FUNC) check_modules, (FUNC) 0L);

   init_configs();

   graf_mouse (ARROW, NULL);

   if (_app) {
        do_some_work();
        while (! exit_inetd) {
             evnt_mesag (message);
             message_handler (message);
             while ((flag = operate_events()) >= 0);
             if (flag == -4)
                  exit_inetd = TRUE;
           }
      }
     else {
        FOREVER {
             evnt_mesag (message);
             message_handler (message);
           }
      }

   if (strings)   Mfree (strings);

   terminate_modules();

   leave_windows();

   rsrc_free();

   appl_exit();
 }
Exemplo n.º 3
0
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 );
}