예제 #1
0
void fillList(void)
{
	textClear();
	int i;
	int curFile = 0;
	DIR *dir = opendir(".");
		
	if(dir)
    {
       struct dirent *ent;
       while((ent = readdir(dir)) != NULL)
       {
           sprintf(FileList[curFile].fName,"%s",ent->d_name);
           if(ent->d_type==DT_DIR)
             FileList[curFile].fType = FT_DIR;
           else
             FileList[curFile].fType = FT_FILE;

		   FileList[curFile].isRunable = !strcasestr(FileList[curFile].fName, ".sv");
		   ++curFile;
        }
        closedir(dir);
		
		/*struct dirent **namelist;
	    int i,k,l,n;

	    n = scandir(".", &namelist, 0, alphasort);
	    if (n < 0) printf("scandir");

		for(i=0;i<n-1;i++)
		{
		   l=strlen(namelist[i]->d_name);
		   if(namelist[i]->d_type==DT_DIR)
             FileList[curFile].fType = FT_DIR;
           else
             FileList[curFile].fType = FT_FILE;
		   strncat (FileList[curFile].fName, namelist[i]->d_name, strlen(namelist[i]->d_name));
		   ++curFile;

		   FileList[curFile].isRunable = !strcasestr(FileList[curFile].fName, ".sv");
		}
		closedir(dir);*/
    }
    else
    {
       gp2x_printf(0,10,2,"Error opening directory\n");
       gp2x_video_RGB_flip(0);
    }
		
	fileCounter = curFile;
}
예제 #2
0
파일: watara.c 프로젝트: gameblabla/potator
int	sv_saveState(char *statepath, int id)
{
	FILE* fp;
	char newPath[256];

	strcpy(newPath,statepath);
	sprintf(newPath+strlen(newPath)-3,".s%d",id);

#ifdef GP2X
	gp2x_printf(0,10,220,"newPath = %s",newPath);
	gp2x_video_RGB_flip(0);
#endif
#ifdef NDS
	iprintf("\nnewPath = %s",newPath);
#endif

	#ifdef HOME_SUPPORT
	char tmp[256];
	snprintf(tmp, sizeof(tmp), "%s/.potator/%s", getenv("HOME"), newPath);
	snprintf(newPath, sizeof(newPath), "%s", tmp);
	printf("%s \n", newPath);
	#endif
	fp=fopen(newPath,"wb");

	if (fp) {
		fwrite(&m6502_registers, 1, sizeof(m6502_registers), fp);
		fwrite(memorymap_programRom, 1, sizeof(memorymap_programRom), fp);
		fwrite(memorymap_lowerRam, 1, 0x2000, fp);
		fwrite(memorymap_upperRam, 1, 0x2000, fp);
		fwrite(memorymap_lowerRomBank, 1, sizeof(memorymap_lowerRomBank), fp);
		fwrite(memorymap_upperRomBank, 1, sizeof(memorymap_upperRomBank), fp);
		fwrite(memorymap_regs, 1, 0x2000, fp);
		fflush(fp);
		fclose(fp);
#ifdef GP2X
		sync();
#endif
	}

#ifdef GP2X
	sleep(1);
#endif

	return(1);
}
예제 #3
0
파일: main.c 프로젝트: ST3ALth/Potator-Core
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();
}
예제 #4
0
void handleMainMenu(void)
{

	BOOL isSelected = FALSE;
	int menuOption = 0;
		
	textClear();
	gp2x_video_RGB_setscaling(320, 240);
	while(!isSelected) {
		unsigned long pad = gp2x_joystick_read(0);
		printMenuOptions();
		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 == MMOPTION_SAVESTATE) || (menuOption == MMOPTION_LOADSTATE))
				saveSlot++;
		}
			
		if(pad & GP2X_LEFT) {
			if((menuOption == MMOPTION_SAVESTATE) || (menuOption == MMOPTION_LOADSTATE))
				saveSlot--;
		}
			
		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 MMOPTION_CONTINUE: RESIZE(); textClear(); return;
			  case MMOPTION_RESTART: RESIZE(); supervision_reset(); textClear(); return;
			  case MMOPTION_SELECTOR: handleFileMenu(); return;
			  case MMOPTION_OPTIONS: handleOptionsMenu(); textClear(); return;
			  case MMOPTION_SAVESTATE: sv_saveState(romname,saveSlot); textClear();return;
			  case MMOPTION_LOADSTATE: sv_loadState(romname,saveSlot); textClear();return;
			  case MMOPTION_EXIT: exitMenu(); break;
			  default: return;
			}
		}

		/*if(pad & GP2X_B) {
			textClear(); 
			return;
		}*/
		
		if(menuOption < 0) menuOption = 0;			
		if(menuOption > 6) menuOption = 6;

		if(saveSlot < 0) saveSlot = 0;
		if(saveSlot > 9) saveSlot = 9;
		
		while(pad == gp2x_joystick_read(0));
		pad = gp2x_joystick_read(0);

		textClear();
	}
}
예제 #5
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();
	}
}
예제 #6
0
void handleFileMenu(void)
{

	BOOL isSelected = FALSE;
	s32 curFile = 0;
	int virtualFile = 0;
		
	fillList();
	textClear();
	while(!isSelected) {
		unsigned long pad = gp2x_joystick_read(0);
		printList(curFile);
		gp2x_printf(0, 170, 1, "VirtualFile = %d",virtualFile);
		gp2x_printf(0, 170, 10, "File Count = %d",fileCounter);

		if(FileList[virtualFile].isRunable){
			gp2x_default_font.fg = 0x6700;
			gp2x_printf(NULL, 0, (33 + (virtualFile*8)), "->");
		} else {
			gp2x_default_font.fg = 0xFFFF;
			gp2x_printf(NULL, 0, (33 + (virtualFile*8)), "->");
		}

		gp2x_default_font.fg = 0xFFFF;
			
		if(curFile)
			gp2x_printf(NULL, 200, 22, "^\n|");
			
		if((curFile + 18 != fileCounter) && fileCounter > 19)
			gp2x_printf(NULL, 200, 200, "|\nv");

		gp2x_video_RGB_flip(0);
			
		if(pad & GP2X_RIGHT) {
			virtualFile += 5;
			if(virtualFile > 18)
				curFile += virtualFile - 18;
			textClear();
		}
			
		if(pad & GP2X_LEFT) {
			virtualFile -= 5;
			if(virtualFile < 0)
				curFile += virtualFile;
			textClear();
		}
			
		if(pad & GP2X_DOWN) {
			virtualFile++;
			textClear();
		}
			
		if(pad & GP2X_UP) {
			virtualFile--;
			textClear();
		}

		if(pad & GP2X_VOL_DOWN) if(pad & GP2X_START) 
			exitMenu();
			
		if(pad & GP2X_X) {
			if(FileList[curFile + virtualFile].fType == FT_DIR) {
				chdir(FileList[curFile + virtualFile].fName);
				fillList();
				virtualFile = curFile = 0;
			} else if(FileList[curFile + virtualFile].isRunable) {
				//textClear();
				//gp2x_printf(0, 1, 1, "Loading...\n\n%s", FileList[curFile + virtualFile].fName);
				//gp2x_video_RGB_flip(0);
				RESIZE();
				loadROM(FileList[curFile + virtualFile].fName);
				textClear();
				supervision_load((u8*)buffer, (uint32)buffer_size);
				textClear();
				return;
			}
		}

		//if(pad & GP2X_A) return;
		
		if(virtualFile < 0) {
			virtualFile = 0;
			--curFile;
			if(curFile < 0)
				curFile = 0;
		}
			
		if(fileCounter < 19) {
			if(virtualFile >= fileCounter)
				virtualFile = fileCounter-1;
		} else {
			if(virtualFile > 18) {
				virtualFile = 18;
				++curFile;
				if(curFile + 18 > fileCounter)
					curFile = fileCounter - 19;
			}
		}
		
		while(pad == gp2x_joystick_read(0));
		pad = gp2x_joystick_read(0);

		textClear();
	}
}