Exemple #1
0
void emu_Deinit(void)
{
	// save SRAM
	if ((currentConfig.EmuOpt & 1) && SRam.changed) {
		emu_SaveLoadGame(0, 1);
		SRam.changed = 0;
	}

	if (!(currentConfig.EmuOpt & 0x20)) {
		FILE *f = fopen(PicoConfigFile, "r+b");
		if (!f) emu_WriteConfig(0);
		else {
			// if we already have config, reload it, except last ROM
			fseek(f, sizeof(currentConfig.lastRomFile), SEEK_SET);
			fread(&currentConfig.EmuOpt, 1, sizeof(currentConfig) - sizeof(currentConfig.lastRomFile), f);
			fseek(f, 0, SEEK_SET);
			fwrite(&currentConfig, 1, sizeof(currentConfig), f);
			fflush(f);
			fclose(f);
		}
	}

	PicoExit();
}
Exemple #2
0
void handleOptionsMenu(void)
{

	BOOL isSelected = FALSE;
	int menuOption = 0;
		
	emu_ReadConfig();
	gp2x_video_RGB_setscaling(320, 240);
	textClear();
	while(!isSelected) {
		int clock = currentConfig.CPUclock;
		int frameskip = currentConfig.Frameskip;
		int videomode = currentConfig.videoMode;
		int vol = currentConfig.volume;
		unsigned long pad = gp2x_joystick_read(0);
		
		gp2x_printf(0, 1, 1, "Potator2x 1.0 by Normmatt\n\n");
		
		gp2x_printf(0, 15, 15 + 2*8, "videoMode      %s",videoMode);
		gp2x_printf(0, 15, 15 + 3*8, "show_fps       %d",currentConfig.show_fps);
		gp2x_printf(0, 15, 15 + 4*8, "enable_sound   %d",currentConfig.enable_sound);
		gp2x_printf(0, 15, 15 + 5*8, "SoundRate      %d",currentConfig.SoundRate);
		gp2x_printf(0, 15, 15 + 6*8, "Frameskip      %d",currentConfig.Frameskip);
		gp2x_printf(0, 15, 15 + 7*8, "CPUclock       %d",clocklist[currentConfig.CPUclock]);
		gp2x_printf(0, 15, 15 + 8*8, "volume         %d",currentConfig.volume);
		gp2x_printf(0, 15, 15 + 9*8, "Save and Exit");
		gp2x_printf(0, 15, 15 + 10*8, "Exit");

		gp2x_printf(0, 170, 1, "MenuOption = %d",menuOption);

		gp2x_printf(0, 0, (31 + (menuOption*8)), "->");

		gp2x_video_RGB_flip(0);

		if(pad & GP2X_RIGHT) {
			if(menuOption == OPTION_VIDEOMODE) if(videomode < 2) currentConfig.videoMode++;
			if(menuOption == OPTION_SHOWFPS) if(currentConfig.show_fps==0) currentConfig.show_fps=1; else currentConfig.show_fps=0;
			if(menuOption == OPTION_ENABLESOUND) if(currentConfig.enable_sound==0) currentConfig.enable_sound=1; else currentConfig.enable_sound=0;
			if(menuOption == OPTION_SOUNDRATE) currentConfig.SoundRate*=2;
			if(menuOption == OPTION_FRAMESKIP) if (frameskip < 9) frameskip++;
			if(menuOption == OPTION_CPUCLOCK) if(clock < sizeof(clocklist)) clock++;
			if(menuOption == OPTION_VOLUME) if (vol < 255) vol+= (pad & GP2X_RIGHT) ? 1 : 0;
		}
			
		if(pad & GP2X_LEFT) {
			if(menuOption == OPTION_VIDEOMODE) if(videomode > 0) currentConfig.videoMode--;
			if(menuOption == OPTION_SHOWFPS) if(currentConfig.show_fps==0) currentConfig.show_fps=1; else currentConfig.show_fps=0;
			if(menuOption == OPTION_ENABLESOUND) if(currentConfig.enable_sound==0) currentConfig.enable_sound=1; else currentConfig.enable_sound=0;
			if(menuOption == OPTION_SOUNDRATE) currentConfig.SoundRate/=2;
			if(menuOption == OPTION_FRAMESKIP) if (frameskip > 0) frameskip--;
			if(menuOption == OPTION_CPUCLOCK) if(clock > 0) clock--;
			if(menuOption == OPTION_VOLUME) if (vol > 0) vol-= (pad & GP2X_LEFT) ? 1 : 0;
		}
			
		if(pad & GP2X_DOWN) {
			menuOption++;
			textClear();
		}
			
		if(pad & GP2X_UP) {
			menuOption--;
			textClear();
		}

		if(pad & GP2X_VOL_DOWN) if(pad & GP2X_START)
			exitMenu();
			
		if(pad & GP2X_X) {
			switch(menuOption){
			  case OPTION_SAVEEXIT: 
				  emu_WriteConfig(); 
				  return;
			  case OPTION_EXIT: 
				  //gp2x_sound_rate(currentConfig.SoundRate); 
				  return;
			  default: break;
			}
		}

		switch(currentConfig.videoMode)
		{
			case 0: sprintf(videoMode,"Slow"); break;
			case 1: sprintf(videoMode,"Quick"); break;
			case 2: sprintf(videoMode,"Full Screen"); break;
			default: sprintf(videoMode,""); break;
		}

		if(currentConfig.SoundRate <= 11025) currentConfig.SoundRate = 11025;
		if(currentConfig.SoundRate >= 44100) currentConfig.SoundRate = 44100;

		currentConfig.Frameskip = frameskip;
		currentConfig.CPUclock  = clock;

		currentConfig.volume = vol;

		if(menuOption < 0) menuOption = 0;			
		if(menuOption > 8) menuOption = 8;
		
		while(pad == gp2x_joystick_read(0));
		pad = gp2x_joystick_read(0);

		textClear();
	}
}