Ejemplo n.º 1
0
Archivo: stdio.c Proyecto: Jaxo/yaxx
/*---------------------------------------------------------------------jfputs-+
|                                                                             |
+----------------------------------------------------------------------------*/
int jfputs(const char * psz, JFILE * pFile)
{
   int ret = 0;
   int length = strlen(psz);

   if ((length > 0) && (jfwrite(psz, 1, length, pFile) == 0)) ret = JEOF;
   return ret;
}
Ejemplo n.º 2
0
void save_config_glob(char * path)
{
	memcpy(setting2.custom_palette,m_pal16[PAL_CUSTOM_GLOBAL], sizeof(word)*3*4);

	//__android_log_print(ANDROID_LOG_DEBUG, "org.rin", "path in save_config_glob: %s",path);

	jfile  fd = jfopen(env_game_thread, path, JF_MODE_NEW | JF_MODE_OVERWRITE | JF_MODE_WRITE, NULL, 0);
	if(!fd)
	{
		return;
	}


	jfwrite(env_game_thread, fd, &setting2, sizeof(setting2));
	jfclose(env_game_thread, fd);
}
Ejemplo n.º 3
0
void save_config(char * path)
{
	
	char tmp[PATH_MAX];
	if(!rom_get_loaded())
	{
	    return;
	}
	else
	{
		if(rom_has_battery())
		{
			save_sram(get_sram(), rom_get_info()->ram_size,SramPath);
		}
	}

	
	memcpy(setting.custom_palette,m_pal16[PAL_CUSTOM_LOCAL], sizeof(word)*3*4);

	//__android_log_print(ANDROID_LOG_DEBUG, "org.rin", "path in save_config: %s",path);
	int i;
	for(i=0; i<sizeof(SETTING); i++){
		if ( *((byte*)&setting+i) != *((byte*)&tmpsetting+i) )
			break;
	}
	if (i>=sizeof(SETTING))
		return;


	jfile fd = jfopen(env_game_thread, path, JF_MODE_NEW | JF_MODE_OVERWRITE | JF_MODE_WRITE, NULL, 0);
	
	if(!fd)
	{
		return;
	}

	jfwrite(env_game_thread, fd, &setting, sizeof(setting));
	jfclose(env_game_thread, fd);

	tmpsetting = setting;
}
Ejemplo n.º 4
0
int save_sram(byte *buf,int size, char * path)
{
	const int sram_tbl[]={1,1,1,4,16,8};
	

	/*char *p = strrchr(SavePath, '.');
	if (!strcmp(p,".gz")){
		if(!setting.compress)
			remove_file(SavePath);
	}else{
		if(setting.compress)*/
			//remove_file(path);
	/*}
	
	sprintf(SavePath, "%sSAVE/%s.sav", RinPath, RomName);
	if (setting.compress) 
	{
		strcat(SavePath, ".gz");
		FILE * fd = fopen(SavePath, "w");
		if (!fd)
			return 0;
	
		int sram_size = 0x2000 * sram_tbl[size];

		if ((rom_get_info()->cart_type>=0x0f) && (rom_get_info()->cart_type<=0x13))
		{
			int tmp = renderer_get_timer_state();
			memcpy(buf+sram_size, &tmp, sizeof(int));
			sram_size += sizeof(int);
		}

		cheat_decreate_cheat_map();
		gzCreate(fd, buf, sram_size);
		fclose(fd);
		cheat_create_cheat_map();
	}else
	{
		FILE * fd = fopen(path, "w");
		if(!fd)
		{
			return 0;
		}

		cheat_decreate_cheat_map();
		fwrite(buf, 0x2000*sram_tbl[size],1,fd);
		if ((rom_get_info()->cart_type>=0x0f)
		 && (rom_get_info()->cart_type<=0x13)){
			int tmp = renderer_get_timer_state();
			fwrite( &tmp, sizeof(int),1,fd);
		}
		fclose(fd);
		cheat_create_cheat_map();

	}*/
	cheat_decreate_cheat_map();
	
	int tmp;
	
	jfile fd = jfopen(env_game_thread, path, JF_MODE_OVERWRITE | JF_MODE_NEW | JF_MODE_WRITE, NULL,  0);
	cheat_decreate_cheat_map();
	
	jfwrite(env_game_thread,fd, buf, 0x2000*sram_tbl[size]);
	
	if ((rom_get_info()->cart_type>=0x0f)
		&& (rom_get_info()->cart_type<=0x13)){
		int tmp = renderer_get_timer_state();
		jfwrite( env_game_thread, fd, &tmp, sizeof(int));
	}
	jfclose(env_game_thread, fd);
	cheat_create_cheat_map();
		
	return 1;
}
Ejemplo n.º 5
0
int state_save(char* path)
{
	size_t size = gb_save_state(NULL);
	byte *buf = (byte*)malloc(size);
	if (!buf)
	{
		return 0;
	}
	gb_save_state(buf);

	jfile fd = jfopen(env_game_thread, path, JF_MODE_WRITE | JF_MODE_OVERWRITE | JF_MODE_NEW, NULL, 0);
	
	if(fd)
	{
		jfwrite(env_game_thread, fd, buf, size);
		jfclose(env_game_thread, fd);
	}
	
	free(buf);
	
	char tmp[PATH_MAX];
	if(rom_has_battery())
	{
		sprintf(tmp, "%s.sram.gz", RomPath);
		save_sram(get_sram(), rom_get_info()->ram_size,tmp);
	}
	
	return size;
	
	//char temp[PATH_MAX];
	
	//int ret;

/*	if (0)//setting.compress)
	{
		sprintf(temp,"%s.gz",path);

		FILE * fd = fopen(temp, "w");
		if (fd<0){
			free(buf);
			return 0;
		}

		ret = gzCreate(fd, buf, size);
		fclose(fd);
		free(buf);
		
		if (!ret)
		{
			remove(temp);
			return 0;
		}
	}
	else
	{
		FILE * fd = fopen(path, "w");
		if (fd<0)
		{
			free(buf);
			return 0;
		}

		ret = fwrite(buf, size,1 ,fd);
		fclose(fd);
		free(buf);

		if (ret!=1){
			remove(path);
			return 0;
		}else{
			//strcat(path, ".gz");
			//remove_file(path);
		}
		return ret;
	}*/
}