int SaveSRDFile3 (const char *file_name_c_a)
{
	FONTCHARACTER file_name_f[30];
	char file_name_c[30];
	int file_h;
	CalZDM();
	
	sprintf (file_name_c,"\\\\crd0\\ZDM\\%s",file_name_c_a);

	CharToFonts3(file_name_c,file_name_f);
	
	Bfile_DeleteFile (file_name_f);
	Bfile_CreateFile (file_name_f,
	zdmroute.size * sizeof(ZDMPOINT) + sizeof (ZDMROUTE));
	file_h = Bfile_OpenFile (file_name_f,_OPENMODE_WRITE);
	
	Bfile_SeekFile (file_h,0);
	Bfile_WriteFile (file_h,&zdmroute,sizeof(ZDMROUTE));
	
	Bfile_SeekFile (file_h,sizeof(ZDMROUTE));
	Bfile_WriteFile (file_h,zdmroute.set,zdmroute.size * sizeof(ZDMPOINT));

	Bfile_CloseFile (file_h);
	return 0;	
}
示例#2
0
int memory_createfile(char *adresse, int size)
{
  FONTCHARACTER *adr = memory_char2font(adresse);
  int i = Bfile_CreateFile(adr,size);
  if(i<0) memory_error("createfile()","CreateFile()",i);

  free(adr);
  return i;
}
void SaveIniSRDFile3()
{
	int ptr = -1;
	int ln;
	Bfile_DeleteFile(IniSRDFile);
	ln=strlen(setup_data.zdmroute_name);
	if(ln==0)
		return;
	if (Bfile_CreateFile(IniSRDFile, ln) < 0) //Error("创建文件失败") ;
		return;
	//	else Error("创建文件OK") ;
	ptr = Bfile_OpenFile(IniSRDFile, _OPENMODE_WRITE) ;  // Bfile_OpenFile : 打开一个现有的文件。
	if (ptr >= 0) {
		Bfile_WriteFile(ptr, setup_data.zdmroute_name, ln) ;
		Bfile_CloseFile(ptr) ;
	}
}
示例#4
0
int memory_save(char *adresse, void *data, int l)
{
  FONTCHARACTER *adr = memory_char2font(adresse);
  int x=0, handle;

  if(memory_exists(adresse)) x = Bfile_DeleteFile(adr);
  if(x<0) { memory_error("save()","DeleteFile()",x); free(adr); return x; }
  x = Bfile_CreateFile(adr,l+1);
  if(x<0) { memory_error("save()","CreateFile()",x); free(adr); return x; }
  handle = Bfile_OpenFile(adr,0x02);
  if(handle<0) { memory_error("save()","OpenFile()",handle); free(adr); return handle; }
  x = memory_writefile(handle,data,l);
  if(x<0) { memory_error("save()","WriteFile()",x); free(adr); return x; }
  memory_closefile(handle);

  free(adr);
  return 0;
}
示例#5
0
文件: set.c 项目: justid/Zoolu
int WriteINI(int file_ptr,int pos,char* Write,BYTE delay,BOOL init)
{
	int bytesfree ;

	if  (init ==  TRUE) {
		filesize = Bfile_GetFileSize(file_ptr) ;
		if (filesize < 0){
			DebugS("获取文件大小\n失败! ") ;
			return -1 ;
		}
	
		write_ptr = malloc( filesize ) ;
		if (write_ptr == NULL){
			DebugS("内存分配失败! ") ;
			return -1 ;
		}
		//Reopen and read the whole file
		file_ptr = Reopen(file_ptr) ;
		Bfile_ReadFile(file_ptr,write_ptr,filesize,-1) ;

		//Delete the file
		Bfile_CloseFile(file_ptr) ;
		//9750下无法使用Bfile_GetMediaFree,获取的闪存剩余字节总为0
		Bfile_DeleteFile(configfile) ;
	}
	
	
	memodify(write_ptr, pos, Write) ;


	if (delay == NOW) {
		//Recreate the file
		if (Bfile_CreateFile(configfile, filesize) < 0) {
			DebugS("创建文件失败\n请重新上传 ") ;
			return -1 ;
		}
		file_ptr = Reopen(file_ptr) ;
		Bfile_WriteFile(file_ptr,write_ptr,filesize) ;
		if (write_ptr != NULL) free(write_ptr) ;
	}
	return Reopen(file_ptr) ;
}
示例#6
0
int SavePMFile (const char *file_name_c_a)
{
	FONTCHARACTER file_name_f[30];
	char file_name_c[30];
	int file_h;
	sprintf (file_name_c,"\\\\crd0\\PM\\%s",file_name_c_a);

	PMCharToFont(file_name_c,file_name_f);
	
	Bfile_DeleteFile (file_name_f);
	Bfile_CreateFile (file_name_f,
	pmroute.size * sizeof(PMPOINT) + sizeof (PMROUTE));
	file_h = Bfile_OpenFile (file_name_f,_OPENMODE_WRITE);
	
	Bfile_SeekFile (file_h,0);
	Bfile_WriteFile (file_h,&pmroute,sizeof(PMROUTE));
	
	Bfile_SeekFile (file_h,sizeof(JDFROUTE));
	Bfile_WriteFile (file_h,pmroute.set,pmroute.size * sizeof(JDFPOINT));

	Bfile_CloseFile (file_h);
	return 0;	
}
示例#7
0
文件: set.c 项目: justid/Zoolu
int upgradeINI(double version, int file_ptr, int pos)
{
void* rebuff_ptr = NULL;
void* buff_prev = NULL;
void* buff_next = NULL;

int size ;
int bytesfree ;
char* Addto ;
BYTE insert_flag = FALSE ;
char Addto113[] = "Current_PLD = \\;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n" ;
char Addto117[] = "Current_YS = EMP ;\r\nYS1 =  XYF ;\r\nYS2 = BBBB ;\r\nYS3 = CCCC ;\r\nYS4 = DDDD ;\r\nYS5 = EEEE ;\r\nYS6 = FFFF ;\r\nYS7 = GGGG ;\r\nYS8 = HHHH ;\r\n\r\n" ;
char Addto1171[] = "XLTYPE =     1.000 ;\r\nPJMODE =     1.000 ;\r\n" ;
char Addto1172[] = "Current_HP =  EMP ;" ;
char Addto119[] = "\r\n\r\nCurrent_SD = EMP ;\r\nSD1 = AAAA ;\r\nSD2 = BBBB ;\r\nSD3 = CCCC ;\r\nSD4 = DDDD ;\r\nSD5 = EEEE ;\r\nSD6 = FFFF ;\r\nSD7 = GGGG ;\r\nSD8 = HHHH ;" ;

Warning("升级中..",2) ;
file_ptr = Reopen(file_ptr) ;

if (version == 1.11){
	Addto = Addto113 ;
	WriteINI(file_ptr, pos, "Version =     1.130 ;",NOW,TRUE) ;
} else if (version == 1.13){
	Addto = Addto117 ;
	WriteINI(file_ptr, pos, "Version =     1.170 ;",NOW,TRUE) ;	
} else if (version == 1.17){
	Addto = Addto1171 ;
	WriteINI(file_ptr, pos, "Version =     1.171 ;",NOW,TRUE) ;
	insert_flag = TRUE ;	
} else if (version == 1.171){
	Addto = Addto1172 ;
	WriteINI(file_ptr, pos, "Version =     1.172 ;",NOW,TRUE) ;
} else if (version == 1.172){
	Addto = Addto119 ;
	WriteINI(file_ptr, pos, "Version =     1.190 ;",NOW,TRUE) ;
} else {
	Warning("错误的版本号!",2) ;
	return FALSE ;
}

//增加ini文件大小
size = Bfile_GetFileSize(file_ptr) ;
rebuff_ptr = calloc( size+ strlen(Addto),sizeof(char)) ;
if (insert_flag == TRUE){
		buff_prev = calloc( allset.fpos.sk,sizeof(char)) ;	
		buff_next = calloc( size-allset.fpos.sk,sizeof(char)) ;
		if (buff_prev == NULL || buff_next == NULL){
			if (rebuff_ptr != NULL) free(rebuff_ptr) ;
			DebugS("申请内存失败!") ;
			return FALSE ;
		}
}
else if (rebuff_ptr == NULL){
	DebugS("申请内存失败!") ;
	return FALSE ;
}
if (insert_flag == TRUE){
	Bfile_ReadFile(file_ptr,buff_prev,allset.fpos.sk ,-1) ;	//读取前半部分
	Bfile_ReadFile(file_ptr,buff_next,size-allset.fpos.sk ,-1) ;	//读取后半部分	
}
else Bfile_ReadFile(file_ptr,rebuff_ptr,size ,-1) ;

Bfile_CloseFile(file_ptr) ;
Bfile_DeleteFile(configfile) ;


if (Bfile_CreateFile(configfile, size+strlen(Addto)) < 0) {
	if (rebuff_ptr != NULL)	free(rebuff_ptr) ;
	if (buff_prev != NULL)	free(buff_prev) ;
	if (buff_next != NULL)	free(buff_next) ;
	DebugS("创建文件失败\n请重新上传 ") ;
	return FALSE ;
}
file_ptr = Reopen(file_ptr) ;
if (insert_flag == TRUE) {
	strncat(rebuff_ptr,buff_prev,strlen(buff_prev)) ;		//拼接
	strncat(rebuff_ptr,Addto,strlen(Addto)) ;	
	strncat(rebuff_ptr,buff_next,strlen(buff_next)) ;		
}
else strncat(rebuff_ptr,Addto,strlen(Addto)) ;
Bfile_WriteFile(file_ptr,rebuff_ptr,size+strlen(Addto)) ;
		
if (rebuff_ptr != NULL)	free(rebuff_ptr) ;
if (buff_prev != NULL)	free(buff_prev) ;
if (buff_next != NULL)	free(buff_next) ;

Bfile_CloseFile(file_ptr) ;

return TRUE ;	
}
示例#8
0
int AddIn_main(int isAppli, unsigned short OptionNum)
{
    SaveData dataToSave;
    int i;
    Game_Data data;
	// variables for fps calculation
    unsigned int fps = 0, frame = 0, tempsOrigine = RTC_GetTicks();
	// char string to display the fps
    unsigned char fps_text[8] = {0};
	// rand initialisation
    srand(RTC_GetTicks());

    // Key init
    data.shift_latch_value = 0;
    data.alpha_latch_value = 0;

    data.entry_highscores = NULL;
    data.entry_highscores = malloc(sizeof(float) * 6);
    if(data.entry_highscores == NULL)
        switch_to_state(OUT_OF_MEMORY, &data);


    data.entry_difficulties = NULL;
    data.entry_difficulties = malloc(sizeof(char*) * 6);
    if(data.entry_difficulties == NULL)
        switch_to_state(OUT_OF_MEMORY, &data);
    load_difficulty_names(data.entry_difficulties);


    loadDataFromSave(&data);
    switch_to_state(TITLE, &data);

    {
        char machin[] = "0";
        machin[0] = GetMPU() + '0';
        locate(1,1);
        Print(machin);
        GetKey(&i);

    }

    while(KeyUp(K_EXIT)){ // main loop
        // fps
        if(RTC_GetTicks() - tempsOrigine >= 32 )// if 1/4 seconds elapsed
        {
            fps = frame*4;
            frame = 0;
            tempsOrigine = RTC_GetTicks();
        }
        frame++;


        update(&data);
        draw(&data);

	// printing debug information

	// updating the screen
        ML_display_vram();
        ML_clear_vram();

        Sleep(1/0.06);
    }

    for(i = 0; i < 6; ++i)
        dataToSave.highscores[i] = data.entry_highscores[i];
    Bfile_CreateFile(filename, filesize);
    data.fileHandle = Bfile_OpenFile(filename, _OPENMODE_WRITE);
    if(data.fileHandle >= 0) {
        Bfile_WriteFile(data.fileHandle, &dataToSave, filesize);
        Bfile_CloseFile(data.fileHandle);
    }

    free(data.entry_highscores);

    return 1;
}