Exemplo n.º 1
0
//Init mainly means allocate
//Reset is called before first run
//Init is called olny once
//When Init is called , cpu interface and all plugins configurations myst be finished
//Plugins/Cpu core must not change after this call is made.
bool Init_DC()
{
	if (dc_inited)
		return true;

	if(settings.dynarec.Enable)
	{
		sh4_cpu=Get_Sh4Recompiler();
		log("Using Recompiler\n");
	}
	else
	{
		sh4_cpu=Get_Sh4Interpreter();
		log("Using Interpreter\n");
	}
	
	if (!plugins_Load())
		return false;

    if (!plugins_Init())
    { 
        //log("Emulation thread : Plugin init failed\n"); 	
        plugins_Term();
        return false;
    }
    
    sh4_cpu->Init();


    mem_Init();
    pvr_Init();
    aica_Init();
    mem_map_defualt();


	dc_inited=true;
	return true;
}
Exemplo n.º 2
0
int kernel_Init(const char *name)
{
    printf("Engine Initializing V %d.%d.%d\n", K_VERS_1, K_VERS_2, K_VERS_3);

    if(mem_Init())
    {
		printf("\tFailed to load memory manager\n");
		return 1;
	}

    kernel_Set_Defaults();
    kernel_SetPaths();

    if(file_Init(kernel_GetPath("PTH_FileLog")))
	{
		printf("\tFailed to load file manager\n");
		return 1;
	}

    #ifndef NO_LOG
    kernel_Main.log = file_Open(kernel_GetPath("PTH_Log"), "w");

    if(kernel_Main.log == NULL)
    {
        printf("\nKernel log failed to load.\n");
        return 1;
    }
    #endif

    #ifdef NO_LOG
    printf("File logging disabled.\n");
    #endif

    file_Log(ker_Log(), 1, "Engine: %d.%d.%d\n", K_VERS_1, K_VERS_2, K_VERS_3);

	mth_FillAngles();

	srand((unsigned int)time(NULL));

    if(kernel_Init_SDL())
        return 1;

    SDL_WM_SetCaption(name, name);

	ker_Report_Video();

	surf_Init(kernel_GetPath("PTH_Textures"));

	if(control_Init(kernel_Main.control_Flags))
	{
		printf("\tFailed to load controls\n");
		return 1;
	}

	if(font_Init(kernel_GetPath("PTH_Fonts")))
	{
		return 1;
	}

	font_Load("Arial.ttf", 11, 1);
	font_Load("Arial.ttf", 13, 1);

	if(kernel_Setup_BaseState())
	{
	    printf("\tFailed to set up kernel gamestate\n");
        return 1;
	}

    puts("Complete");
	return 0;
}
Exemplo n.º 3
0
int dc_init(int argc,wchar* argv[])
{
	setbuf(stdin,0);
	setbuf(stdout,0);
	setbuf(stderr,0);
	if (!_vmem_reserve())
	{
		printf("Failed to alloc mem\n");
		return -1;
	}

#if !defined(TARGET_NO_WEBUI)
	webui_thd.Start();
#endif

	if(ParseCommandLine(argc,argv))
	{
		return 69;
	}
	if(!cfgOpen())
	{
		msgboxf("Unable to open config file",MBX_ICONERROR);
		return -4;
	}
	LoadSettings();
#ifndef _ANDROID
	os_CreateWindow();
#endif

	int rv= 0;

#if HOST_OS != OS_DARWIN
    #define DATA_PATH "/data/"
#else
    #define DATA_PATH "/"
#endif
    
	if (settings.bios.UseReios || !LoadRomFiles(GetPath(DATA_PATH)))
	{
		if (!LoadHle(GetPath(DATA_PATH)))
			return -3;
		else
			printf("Did not load bios, using reios\n");
	}

#if FEAT_SHREC != DYNAREC_NONE
	if(settings.dynarec.Enable)
	{
		Get_Sh4Recompiler(&sh4_cpu);
		printf("Using Recompiler\n");
	}
	else
#endif
	{
		Get_Sh4Interpreter(&sh4_cpu);
		printf("Using Interpreter\n");
	}
	
  InitAudio();

	sh4_cpu.Init();
	mem_Init();

	plugins_Init();
	
	mem_map_default();

#ifndef _ANDROID
	mcfg_CreateDevices();
#else
    mcfg_CreateDevices();
#endif

	plugins_Reset(false);
	mem_Reset(false);
	

	sh4_cpu.Reset(false);
	
	return rv;
}
Exemplo n.º 4
0
int dc_init(int argc,wchar* argv[])
{
	setbuf(stdin,0);
	setbuf(stdout,0);
	setbuf(stderr,0);
	if (!_vmem_reserve())
	{
		printf("Failed to alloc mem\n");
		return -1;
	}

	if(ParseCommandLine(argc,argv))
	{
		return 69;
	}

	if(!cfgOpen())
	{
		msgboxf("Unable to open config file",MBX_ICONERROR);
		return -4;
	}
	LoadSettings();

#ifndef _ANDROID
	os_CreateWindow();
#endif

	int rv= 0;


	if (!LoadRomFiles(GetPath("/data/")))
	{
		return -3;
	}

#if !defined(HOST_NO_REC)
	if(settings.dynarec.Enable)
	{
		Get_Sh4Recompiler(&sh4_cpu);
		printf("Using Recompiler\n");
	}
	else
#endif
	{
		Get_Sh4Interpreter(&sh4_cpu);
		printf("Using Interpreter\n");
	}
	
	  void InitAudio();
  InitAudio();

	sh4_cpu.Init();
	mem_Init();

	plugins_Init();
	
	mem_map_default();

	mcfg_CreateDevices();

	plugins_Reset(false);
	mem_Reset(false);
	

	sh4_cpu.Reset(false);
	
	return rv;
}
Exemplo n.º 5
0
int initEverything( void )
{
#ifndef _DEBUG
	logFile = SDL_RWFromFile( "log.txt", "w" );
	if( logFile != NULL ) {
		SDL_LogSetOutputFunction( LogOutput, NULL );
	}
#endif

	// memory first, won't be used everywhere at first so lets keep the initial allocation low, 64 MB
	mem_Init( 64 * 1024 * 1024 );

	/* then SDL */
	SDL_SetMainReady( );
	if( SDL_Init( SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS ) != 0 ) {
		SDL_LogError( SDL_LOG_CATEGORY_APPLICATION, SDL_GetError( ) );
		return -1;
	}
	SDL_LogInfo( SDL_LOG_CATEGORY_APPLICATION, "SDL successfully initialized" );
	atexit( cleanUp );

	// set up opengl
	// try opening and parsing the config file
	int majorVersion;
	int minorVersion;
	int redSize;
	int greenSize;
	int blueSize;
	int depthSize;

	void* oglCFGFile = cfg_OpenFile( "opengl.cfg" );
	cfg_GetInt( oglCFGFile, "MAJOR", 3, &majorVersion );
	cfg_GetInt( oglCFGFile, "MINOR", 3, &minorVersion );
	cfg_GetInt( oglCFGFile, "RED_SIZE", 8, &redSize );
	cfg_GetInt( oglCFGFile, "GREEN_SIZE", 8, &greenSize );
	cfg_GetInt( oglCFGFile, "BLUE_SIZE", 8, &blueSize );
	cfg_GetInt( oglCFGFile, "DEPTH_SIZE", 16, &depthSize );
	cfg_CloseFile( oglCFGFile );

	majorVersion = 2;
	minorVersion = 1;
	// want the core functionality
	SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
	SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, majorVersion );
	SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, minorVersion );
	// want 8 bits minimum per color
	SDL_GL_SetAttribute( SDL_GL_RED_SIZE, redSize );
    SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, greenSize );
    SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, blueSize );
	// want 16 bit depth buffer
    SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, depthSize );
	// want it to be double buffered
    SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

	window = SDL_CreateWindow( windowName, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
		WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL );
	if( window == NULL ) {
		SDL_LogError( SDL_LOG_CATEGORY_VIDEO, SDL_GetError( ) );
		return -1;
	}
	SDL_LogInfo( SDL_LOG_CATEGORY_APPLICATION, "SDL OpenGL window successfully created" );

	/* Load and create images */
	if( gfx_Init( window ) < 0 ) {
		return -1;
	}
	SDL_LogInfo( SDL_LOG_CATEGORY_APPLICATION, "Rendering successfully initialized" );

	/* Load and create sounds and music */
	if( initMixer( ) < 0 ) {
		return -1;
	}
	SDL_LogInfo( SDL_LOG_CATEGORY_APPLICATION, "Mixer successfully initialized" );

	cam_Init( );
	cam_SetProjectionMatrices( window );
	SDL_LogInfo( SDL_LOG_CATEGORY_APPLICATION, "Cameras successfully initialized" );

	loadAllResources( );

	return 0;
}