Beispiel #1
0
int main(void)
{
	struct timeval tval; // timing
	int thissec = 0, frames_done = 0;

	gp2x_init();

	for (;;)
	{
		gettimeofday(&tval, 0);

		if(thissec != tval.tv_sec)
		{
			thissec = tval.tv_sec;

			printf("frames_done: %i\n", frames_done);
			frames_done = 0;
		}


		//gp2x_video_wait_vsync();
		//usleep(1); // sleeps a minimum of ~20ms
		//gp2x_video_flip(); // can be called ~430000 times/sec
		spend_cycles(1000);
		frames_done++;
	}

}
Beispiel #2
0
/* GP2X Video Init */
void gp2x_video_init(void) {

	/* Video and Sound Init */
	gp2x_init(1000,8,DEFAULT_SAMPLE_RATE,16,0,60);
   	
   	/* Set MAME Palette */
   	gp2x_mame_palette();
}
Beispiel #3
0
int main(int argc, char **argv)
{
	gp2x_init(1000,
		16,	// bpp
		44100,	// sound freq
		16,	// 16-bit sound
		1,	// stereo
		60,	// unused (must not be zero!)
		1	// solid font?
		);
	gp2x_video_YUV_setparts(0,-1,-1,-1,319,239);
	gp2x_video_RGB_setwindows(0x10,0x10,0x10,0x10,319,239);
	do_it();
	do_it_image();
	return 0;
}
Beispiel #4
0
int main (int argc, char **argv)
{
	FILE *f;

	/* GP2X Initialization */
	gp2x_init(1000,8,22050,16,0,60);

	/* Show intro screen */
	gp2x_intro_screen();

	/* Initialize list of available games */
	game_list_init(argc);
	if (game_num_avail==0)
	{
		gp2x_gamelist_text_out(35, 110, "ERROR: NO AVAILABLE GAMES FOUND");
		gp2x_video_flip();
		gp2x_joystick_press(0);
		gp2x_exit();
	}

	/* Read default configuration */
	f=fopen("frontend/mame.cfg","r");
	if (f) {
		fscanf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&gp2x_freq,&gp2x_video_depth,&gp2x_video_aspect,&gp2x_video_sync,
		&gp2x_frameskip,&gp2x_sound,&gp2x_clock_cpu,&gp2x_clock_sound,&gp2x_cpu_cores,&gp2x_ramtweaks,&last_game_selected,&gp2x_cheat,&gp2x_volume);
		fclose(f);
	}
	
	/* Select Game */
	select_game(playemu,playgame); 

	/* Write default configuration */
	f=fopen("frontend/mame.cfg","w");
	if (f) {
		fprintf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",gp2x_freq,gp2x_video_depth,gp2x_video_aspect,gp2x_video_sync,
		gp2x_frameskip,gp2x_sound,gp2x_clock_cpu,gp2x_clock_sound,gp2x_cpu_cores,gp2x_ramtweaks,last_game_selected,gp2x_cheat,gp2x_volume);
		fclose(f);
		sync();
	}
	
	/* Execute Game */
	execute_game (playemu,playgame);
	
	exit (0);
}
Beispiel #5
0
int main(int argc, char *argv[])
{
	g_argv = argv;

	emu_ReadConfig(0, 0);
	gp2x_init();
	if (currentConfig.EmuOpt&0x10) {
		int ret = mmuhack();
		printf("squidge hack code finished and returned %i\n", ret); fflush(stdout);
		mmuhack_status = ret;
	}
	cpuctrl_init();
	// Reset940(1);
	// Pause940(1);
	if (currentConfig.EmuOpt&0x100) {
		printf("setting RAM timings.. "); fflush(stdout);
		// craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2
		set_RAM_Timings(6, 4, 1, 1, 1, 2, 2);
		printf("done.\n"); fflush(stdout);
	}
	emu_Init();
	menu_init();

	engineState = PGS_Menu;

	if (argc > 1)
		parse_cmd_line(argc, argv);

	for (;;)
	{
		switch (engineState)
		{
			case PGS_Menu:
				menu_loop();
				break;

			case PGS_ReloadRom:
				if (emu_ReloadRom())
					engineState = PGS_Running;
				else {
					printf("PGS_ReloadRom == 0\n");
					engineState = PGS_Menu;
				}
				break;

			case PGS_RestartRun:
				engineState = PGS_Running;

			case PGS_Running:
				emu_Loop();
				break;

			case PGS_Quit:
				goto endloop;

			default:
				printf("engine got into unknown state (%i), exitting\n", engineState);
				goto endloop;
		}
	}

	endloop:

	emu_Deinit();
	cpuctrl_deinit();
	gp2x_deinit();
	if(mmuhack_status)
		mmuunhack();

	return 0;
}
Beispiel #6
0
u32 Gdl_init(char* appTitle, u32 width, u32 height) // open you a framebuffer
{   
	#ifndef GP32
		HEIGHT = height; WIDTH = width;
	#endif
	
    inikey();

	#ifdef GP32
		gp_enableCache();
		screenRefreshRate = height;
		currentFrequency = width;
		gpSetCpuSpeed(currentFrequency);
		screenBuffer[0] = (clDeep*)FRAMEBUFFER1;
		screenBuffer[1] = (clDeep*)FRAMEBUFFER2;
		screenBufferEnd[0] = &( (screenBuffer[0])[(320*240)-1] );
		screenBufferEnd[1] = &( (screenBuffer[1])[(320*240)-1] );
		pixel =  screenBuffer[nflip];

		currentFps = gp_initFramebuffer(screenRefreshRate);

		gp_initRTC();
		shell.set(-1,-1,24,14);
		shell.print("@0g@1d@0l @1i@0n@1i@0t @2ok\n");
		//printlr("current fps : %i",currentFps);
	#endif

    #ifdef useSdl
    	if(SDL_Init (SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0)
        {  fprintf (stderr, "sdl init error (%s)\n",SDL_GetError()); return 0;
    	}

    	screen = SDL_SetVideoMode (WIDTH, HEIGHT, deepByte, SDL_SWSURFACE/*|SDL_NOFRAME*/ );// SDL_SWSURFACE)/;

    	if(!screen)
        {	fprintf (stderr, "error on set %ix%i.%i video mode (%s)\n",
                      WIDTH,HEIGHT,deepByte,SDL_GetError()); return 0;
    	}
        SDL_WM_SetCaption(appName,0);
	   //SDL_ShowCursor(SDL_DISABLE);
    
    	if(SDL_NumJoysticks() > 0)
        {	joy = SDL_JoystickOpen(0);
    		if(!joy)
            {	fprintf (stderr, "sdl link to joystick error (%s)\n",SDL_GetError()); return 0;
    		}
    	}

    	pixel = (clDeep*)(screen->pixels);
    	SDL_UnlockSurface(screen);
   	#endif
   	
   	#ifdef useRlyeh
   	       gp2x_init(1000, deepByte, 11025,16,1,60);
           pixel = gp2x_screen15;
   	#endif
   	
   	#ifdef usePtc
           fwidth  = WIDTH;
           fheight = HEIGHT;
           pixel = (clDeep*)malloc(WIDTH*HEIGHT*4);
   	       
		   if(!ptc_open(appTitle,&fwidth,&fheight))
		   {	showMsg("cannot render the backbuffer :|\n\nneed a minimum of :\n\t* 16b color deep\n\t* direct X 5 or more",appTitle);
				Gdl_exit();
		   }

   	       ptc_iniMsgCallBack(&Gdl_processMsg);
   	#endif

	#ifndef GP32
		#ifdef startAppWithFullPower
		   Gdl_setAppPower(1);
		 #else
		   Gdl_setAppPower(0);
		#endif   
	#endif
   	//atexit (Gdl_exit);
   	fullBlitLimit();
    return 1;
}
extern "C" int android_main  (int argc, char **argv)
{
	FILE *f;

	__android_log_print(ANDROID_LOG_DEBUG, "libMAME4all.so", "init iOS frontend");
	//printf("init iOS frontend\n");
/*
	mkdir(get_documents_path("iOS"), 0755);
	mkdir(get_documents_path("cfg"), 0755);
	mkdir(get_documents_path("hi"), 0755);
*/
	__android_log_print(ANDROID_LOG_DEBUG, "libMAME4all.so", "creados directorios");

	/* GP2X Initialization */
	gp2x_init(1000,8,22050,16,0,60);

	//hack: por defecto lentos van a 11000
	m4all_sound = 4;
	m4all_video_depth = 16;

	if(m4all_HiSpecs)
	{
		m4all_clock_cpu= 100;
		m4all_clock_sound= 100;
		m4all_buttons=2;
		m4all_sound=12;
	}

	/* Show intro screen */
	gp2x_intro_screen();

	/* Initialize list of available games */
	game_list_init(argc);

	/*
	if (game_num_avail==0)
	{   while(true){
		gp2x_gamelist_text_out(35, 110, "ERROR: NO AVAILABLE GAMES FOUND");
		gp2x_video_flip();
		gp2x_joystick_press(0);
		//gp2x_exit();
		sleep(1);}
		exit(0);
	}
    */

	while(true)
	{
	/* Read default configuration */
	f=fopen(get_documents_path("frontend/mame_v2.cfg"),"r");
	if (f) {
		fscanf(f,"%d",&last_game_selected);
		fclose(f);
	}
	
	/* Select Game */
	select_game(playemu,playgame); 

	/* Write default configuration */
	f=fopen(get_documents_path("frontend/mame_v2.cfg"),"w");
	if (f) {
		fprintf(f,"%d",last_game_selected);
		fclose(f);
		sync();
	}
	
	/* Execute Game */
	execute_game (playemu,playgame);


	}
	exit (0);
}
Beispiel #8
0
int main(int argc, char *argv[])
#endif
{
#ifndef IPHONE
#if defined(ARM_ARCH)
	ChangeWorkingDirectory(argv[0]);
	getcwd(gamepath, 256);
#else
#if defined(__WIN32__)
	if(argc == 1)
		strncpy(gamepath,"E:\\ps1",256);
	else
		strncpy(gamepath,argv[1],256);
#else
	strncpy(gamepath,ROM_PREFIX,256);
#endif
#endif
#endif

#ifdef PSP
	sprintf(gamepath,"");
#endif

#ifdef IPHONE
	sprintf(gamepath,"");
#endif

	memset(&Config, 0, sizeof(PsxConfig));
	Config.PsxAuto = 1;
	Config.Cdda = 1;
	Config.Xa = 0;
#ifdef DYNAREC
	Config.Cpu = 0;
#else
	Config.Cpu = 1;
#endif

#ifdef WITH_HLE
	Config.HLE = 1;
#else
	Config.HLE = 0;
#endif

	Config.Mdec = 0;
	Config.PsxOut = 0;
	Config.PsxType = 0;
	Config.QKeys = 0;
	Config.RCntFix = 0;
	Config.Sio = 0;
	Config.SpuIrq = 1;
	Config.VSyncWA = 0;

#if defined(PSP) || defined(SDL) || defined(IPHONE)
    	sprintf(Config.BiosDir, "%s/Media/ROMs/PSX/", appworkdir);
	sprintf(Config.Bios, "scph1001.bin");
	sprintf(Config.Mcd1, "mcd001.mcr");
	sprintf(Config.Mcd2, "mcd002.mcr");
#else
	sprintf(Config.BiosDir, PSX4ALL_STR, gamepath);
	sprintf(Config.Bios, "/bios/scph1000.bin");
	sprintf(Config.Mcd1, "%s/memory_card/mcd001.mcr", gamepath);
	sprintf(Config.Mcd2, "%s/memory_card/mcd002.mcr", gamepath);
	
#endif
	gp2x_init(900, 16, 11025, 16, 1, 60, 1);
#ifndef GP2X
	gp2x_video_flip_single();
#endif

#ifdef IPHONE
	u32 loadsvs = 0;
	linesInterlace_user = preferences.interlace;
	skipCount = skipCountTablePhone[preferences.frameSkip];
	skipRate = skipRateTablePhone[preferences.frameSkip];   
	iSoundMuted = preferences.muted;
	Config.Cdda = preferences.muted;
	Config.Xa = preferences.muted;
#ifdef WITH_HLE
	Config.HLE = !preferences.bios;
#else
	Config.HLE = 0;
#endif
	if( (!strcasecmp(filename + (strlen(filename)-4), FORMAT_SV )) )
	{
		u32 pos;
		loadsvs = 1;
		sprintf(svsfilename, PSX4ALL_STR, filename);
		sprintf(iphonefile, PSX4ALL_STR, filename);
		pos = strlen(iphonefile)-18;
		iphonefile[pos] = '\0';
		packfile = iphonefile;
	}
	else
	{
		loadsvs = 0;
		sprintf(iphonefile, PSX4ALL_STR, filename);
		packfile = iphonefile;
	}

	gp2x_video_RGB_clearscreen16();
	LoadCdBios = 0;

	if (SysInit() == -1)
	{
		gp2x_deinit();
		return 0;
	}

	if (InitComponents() == -1)
	{
		gp2x_deinit();
		return 0;
	}

	SysReset();
	CheckCdrom();

	if( Config.HLE )
	{
		LoadCdBios = 0;
		if( LoadCdrom() == -1 )
		{
			gp2x_printf(NULL, 120, 120, PSX4ALL_LDD);
			gp2x_video_flip();
			gp2x_timer_delay(2000);
			gp2x_video_RGB_clearscreen16();
			return 0;
		}
	}
	
	if (loadsvs) {
		if( LoadState(svsfilename) == -1 )
		{
			gp2x_printf(NULL, 120, 120,  PSX4ALL_LSF);
			gp2x_video_flip();
			gp2x_timer_delay(2000);
			gp2x_video_RGB_clearscreen16();

			psxShutdown();
			CloseComponents();
			
			gp2x_deinit();
			pthread_exit(NULL);
		}
	}

	psx4all_emulating=1;
	psx4all_prof_start(PROFILER_TOTAL);
	psxCpu->Execute();
	psx4all_prof_end(PROFILER_TOTAL);
	psx4all_emulating=0;

	psx4all_prof_show();
#else
	if( 0 != SelectGame() )
	{
		psx4all_emulating=1;
		psx4all_prof_start(PROFILER_TOTAL);
		psxCpu->Execute();
		psx4all_prof_end(PROFILER_TOTAL);
		psx4all_emulating=0;

		psx4all_prof_show();
	}
#endif
	gp2x_deinit();

	return 0;
}
Beispiel #9
0
int main(int argc, char *argv[])
{
	gp2x_init(1000, 16, 11025,16,1,60, 1);
	gp2x_sound_volume(100,100);

	screen16 = (unsigned short *)gp2x_video_RGB[0].screen;

	int i,j;
	char temp[255];

	FILE *in = NULL;
    
    if(argc <= 1) {
		printf("\nnot enough arguments\n");
		//return(TRUE);
	} else {
	
		// the hard-core UI, a command line:
		for (i=0; (i < argc || argv[i] != NULL); i++) {
		
			if(strcmp(argv[i], "--double") == 0) {
				//screen_size = 1;
			}
			if(strcmp(argv[i], "--color white") == 0) {
				supervision_set_colour_scheme(COLOUR_SCHEME_DEFAULT);
			}
			if(strcmp(argv[i], "--color amber") == 0) {
				supervision_set_colour_scheme(COLOUR_SCHEME_AMBER);
			}
			if(strcmp(argv[i], "--color green") == 0) {
				supervision_set_colour_scheme(COLOUR_SCHEME_GREEN);
			}
			if(strcmp(argv[i], "--color blue") == 0) {
				supervision_set_colour_scheme(COLOUR_SCHEME_BLUE);
			}
		}
	
		romname = strdup(argv[1]);
		in = fopen(romname, "r");
	
		if(in == NULL) {
			printf("The file %s doesn't exist.\n",romname);
			exit(0);
		}
		fflush(in);
		fclose(in);
	}
		
	supervision_init(); //Init the emulator

	getRunDir();

	if(romname!=NULL){
		loadROM(romname);
		supervision_load((u8*)buffer, (uint32)buffer_size);
	} else {
		handleFileMenu(); // File menu
	}

	emu_ReadConfig();

	gp2x_sound_volume(255,255);
	gp2x_sound_pause(0);

	while(1)
	{
	  CheckKeys();

	  while(!paused)
	  {
		 CheckKeys(); //key control

		 controls_update();

		 switch(currentConfig.videoMode){
			case 0: 
				supervision_exec((int16*)screenbuffer,1);

				for(j=0; j < 160; j++) 
		 			gp2x_memcpy(screen16+(80+(j+40)*320),screenbuffer+(j * 160),160*2);
				break;
			case 1: 
				supervision_exec2((int16*)screen16,1); 
				break;
			case 2: 
				supervision_exec3((int16*)screen16,1);
				break;
			default: break;
		 }

		 /*gp2x_video_waitvsync();

		 sprintf(temp,"FPS: %3d", FPS);
		 gp2x_printf(NULL,0,0,temp);
		 ++svFrm;*/

		 gp2x_video_RGB_flip(0);


		 controls_reset();
	  }
	}
	supervision_done(); //shutsdown the system
	gp2x_deinit();
}
Beispiel #10
0
int main(int argc, char *argv[])
{
    char *rom_name;



#ifdef __AMIGA__
    BPTR file_lock = GetProgramDir();
    SetProgramDir(file_lock);
#endif
	signal(SIGSEGV, catch_me);

#ifdef WII
	//   SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE);

	fatInitDefault();
#endif

    cf_init(); /* must be the first thing to do */
    cf_init_cmd_line();
    cf_open_file(NULL); /* Open Default configuration file */

    rom_name=cf_parse_cmd_line(argc,argv);

    /* print effect/blitter list if asked by user */
    if (!strcmp(CF_STR(cf_get_item_by_name("effect")),"help")) {
	print_effect_list();
	exit(0);
    }
    if (!strcmp(CF_STR(cf_get_item_by_name("blitter")),"help")) {
	print_blitter_list();
	exit(0);
    }

	init_sdl();

/* GP2X stuff */
#ifdef GP2X
    gp2x_init();
#endif
    if (gn_init_skin()!=SDL_TRUE) {
	    printf("Can't load skin...\n");
            exit(1);
    }    

	reset_frame_skip();

    if (conf.debug) conf.sound=0;

/* Launch the specified game, or the rom browser if no game was specified*/
	if (!rom_name) {
	//	rom_browser_menu();
		run_menu();
		printf("GAME %s\n",conf.game);
		if (conf.game==NULL) return 0;
	} else {

		if (init_game(rom_name)!=SDL_TRUE) {
			printf("Can't init %s...\n",rom_name);
            exit(1);
		}    
	}

	/* If asked, do a .gno dump and exit*/
    if (CF_BOOL(cf_get_item_by_name("dump"))) {
        char dump[8+4+1];
        sprintf(dump,"%s.gno",rom_name);
        dr_save_gno(&memory.rom,dump);
        close_game();
        return 0;
    }

    if (conf.debug)
	    debug_loop();
    else
	    main_loop();

    close_game();

    return 0;
}
Beispiel #11
0
void real_main (int argc, char **argv)
{
#ifdef USE_SDL
    SDL_Init (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK 
#if !defined(NO_SOUND) && !defined(GP2X)
 			| SDL_INIT_AUDIO
#endif
	);
#endif
	getcwd(launchDir,250);
    /* PocketUAE prefs */
    default_prefs_uae (&currprefs);
    default_prefs();
#ifdef GP2X
    gp2x_init(argc, argv);
#endif
		// Set everthing to default and clear HD settings
		SetDefaultMenuSettings(1);
    loadconfig (1);

    if (! graphics_setup ()) {
		exit (1);
    }

    rtarea_init ();

	hardfile_install();

    if (! setup_sound ()) {
		write_log ("Sound driver unavailable: Sound output disabled\n");
		produce_sound = 0;
    }
    init_joystick ();

	int err = gui_init ();
	if (err == -1) {
	    write_log ("Failed to initialize the GUI\n");
	} else if (err == -2) {
	    exit (0);
	}
    if (sound_available && produce_sound > 1 && ! init_audio ()) {
		write_log ("Sound driver unavailable: Sound output disabled\n");
		produce_sound = 0;
    }

    /* Install resident module to get 8MB chipmem, if requested */
    rtarea_setup ();

    keybuf_init (); /* Must come after init_joystick */

#ifdef USE_AUTOCONFIG
    expansion_init ();
#endif

    memory_init ();

    filesys_install (); 
    native2amiga_install ();

    custom_init (); /* Must come after memory_init */
    DISK_init ();

    m68k_init(0);
    gui_update ();

#ifdef GP2X
    switch_to_hw_sdl(1);
#endif
	{
		start_program ();
	}
    leave_program ();
}
extern "C" int mimain (int argc, char **argv)
{
	FILE *f;


	printf("init iOS frontend\n");
	/* GP2X Initialization */
	gp2x_init(1000,8,22050,16,0,60);

	//hack: por defecto lentos van a 11000
	if(!safe_render_path)
	{
		iOS_sound = global_sound;
		iOS_video_depth = 8;
	}
	else
	{
		iOS_sound = global_sound;
		iOS_video_depth = 16;
	}

	if(isIpad)
	{
		iOS_clock_cpu= 100;
		iOS_clock_sound= 100;
		iOS_buttons=2;
		iOS_sound=global_sound;
	}

	/* Show intro screen */
	gp2x_intro_screen();

    local_manufacturer = global_manufacturer;
    local_clones = global_clones;
    local_filter = global_filter;
    local_category = global_category;
    local_year = global_year;
    
	/* Initialize list of available games */
	game_list_init(argc);

	/*
	if (game_num_avail==0)
	{   while(true){
		gp2x_gamelist_text_out(35, 110, "ERROR: NO AVAILABLE GAMES FOUND");
		gp2x_video_flip();
		gp2x_joystick_press(0);
		//gp2x_exit();
		sleep(1);}
		exit(0);
	}
    */

	while(true)
	{
	/* Read default configuration */
	f=fopen(get_documents_path("iOS/mame_v2.cfg"),"r");
	if (f) {
		fscanf(f,"%d",&last_game_selected);
		fclose(f);
	}
	
	/* Select Game */
	select_game(playemu,playgame); 

	/* Write default configuration */
	f=fopen(get_documents_path("iOS/mame_v2.cfg"),"w");
	if (f) {
		fprintf(f,"%d",last_game_selected);
		fclose(f);
		sync();
	}
	
	/* Execute Game */
	execute_game (playemu,playgame);



	}
	exit (0);
}
Beispiel #13
0
void real_main (int argc, char **argv)
{
	int numb;
	char pattern[100];
	char txt[100];
#ifdef USE_SDL
    SDL_Init (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK 
#if !defined(NO_SOUND) && !defined(GP2X)
 			| SDL_INIT_AUDIO
#endif
	);
#endif
  // Initialize timebase
  g_uae_epoch = read_processor_time();
  syncbase = 1000000; // Microseconds

	//------------------------------------------
	//just safe the game conf file for later use
	//------------------------------------------
	if (argc > 1)
	{
		if (strlen(argv[1]) < 255)
		{
			strcpy(uae4all_game_conf_file0, argv[1]);

			strcpy(uae4all_game_conf_file1, argv[1]);
			strcpy(uae4all_game_conf_file2, argv[1]);
			strcpy(uae4all_game_conf_file3, argv[1]);
			strcpy(uae4all_game_conf_file4, argv[1]);
			strcpy(uae4all_game_conf_file5, argv[1]);
			strcpy(uae4all_game_conf_file6, argv[1]);
			strcpy(uae4all_game_conf_file7, argv[1]);
			getNumber(uae4all_game_conf_file0, "disk 1 of %", &numb);

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file1, pattern, '2');

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file2, pattern, '3');

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file3, pattern, '4');

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file4, pattern, '5');

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file5, pattern, '6');

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file6, pattern, '7');

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file7, pattern, '8');

		}
	}

	getcwd(launchDir,250);
    /* PocketUAE prefs */
    default_prefs_uae (&currprefs);
    default_prefs();
#ifdef GP2X
    gp2x_init(argc, argv);
#endif
		// Set everthing to default and clear HD settings
		SetDefaultMenuSettings(1);
    loadconfig (1);

    if (! graphics_setup ()) {
		exit (1);
    }

    rtarea_init ();

	hardfile_install();

    if (! setup_sound ()) {
		write_log ("Sound driver unavailable: Sound output disabled\n");
		produce_sound = 0;
    }
    init_joystick ();

	int err = gui_init ();
	if (err == -1) {
	    write_log ("Failed to initialize the GUI\n");
	} else if (err == -2) {
	    exit (0);
	}
    if (sound_available && produce_sound > 1 && ! init_audio ()) {
		write_log ("Sound driver unavailable: Sound output disabled\n");
		produce_sound = 0;
    }

    /* Install resident module to get 8MB chipmem, if requested */
    rtarea_setup ();

    keybuf_init (); /* Must come after init_joystick */

#ifdef USE_AUTOCONFIG
    expansion_init ();
#endif

    memory_init ();

    filesys_install (); 
    native2amiga_install ();

    custom_init (); /* Must come after memory_init */
    DISK_init ();

    m68k_init(0);
    gui_update ();

#ifdef GP2X
    switch_to_hw_sdl(1);
#endif
	{
		start_program ();
	}
    leave_program ();
}