void loader_init(char *s) { char *name, *p; romfile = s; rom_load(); vid_settitle(rom.name); name = strdup(base(romfile)); p = (char *) strchr(name, '.'); if (p) *p = 0; sramfile = malloc(strlen(savedir) + strlen(name) + 7); sprintf(sramfile, "%s%s.sav", savedir, name); rtcfile = malloc(strlen(savedir) + strlen(name) + 7); sprintf(rtcfile, "%s%s.rtc", savedir, name); printf("Loading sramfile: %s\n", sramfile); printf("Loading rtcfile: %s\n", rtcfile); sram_load(); rtc_load(); }
void loader_init(char *s) { char *name, *p; DIR* dir; printf("%s - %s\n",s,savedir); // sys_checkdir(savedir, 1); /* needs to be writable */ dir=opendir(savedir); if(!dir) { mkdir(savedir,0); printf("Savedir created!"); } else closedir(dir); romfile = s; printf("Loading rom...\n"); rom_load(); printf("Rom loaded!\n"); vid_settitle(rom.name); if (savename && *savename) { if (savename[0] == '-' && savename[1] == 0) name = ldup(rom.name); else name = strdup(savename); } else if (romfile && *base(romfile) && strcmp(romfile, "-")) { name = strdup(base(romfile)); p = strchr(name, '.'); if (p) *p = 0; } else name = ldup(rom.name); // name=rom.name; saveprefix = malloc(strlen(savedir) + strlen(name) + 2); sprintf(saveprefix, "%s/%s", savedir, name); sramfile = malloc(strlen(saveprefix) + 5); strcpy(sramfile, saveprefix); strcat(sramfile, ".sav"); rtcfile = malloc(strlen(saveprefix) + 5); strcpy(rtcfile, saveprefix); strcat(rtcfile, ".rtc"); printf("before sram / rtc load ..."); sram_load(); rtc_load(); printf(" done\n"); // atexit(cleanup); }
void loader_init(char *s) { char *name, *p; sys_checkdir(savedir, 1); /* needs to be writable */ romfile = s; rom_load(); vid_settitle(rom.name); if (savename && *savename) { if (savename[0] == '-' && savename[1] == 0) name = ldup(rom.name); else name = strdup(savename); } else if (romfile && *base(romfile) && strcmp(romfile, "-")) { name = strdup(base(romfile)); p = strchr(name, '.'); if (p) *p = 0; } else name = ldup(rom.name); saveprefix = malloc(strlen(savedir) + strlen(name) + 2); sprintf(saveprefix, "%s/%s", savedir, name); sramfile = malloc(strlen(saveprefix) + 5); strcpy(sramfile, saveprefix); strcat(sramfile, ".sav"); rtcfile = malloc(strlen(saveprefix) + 5); strcpy(rtcfile, saveprefix); strcat(rtcfile, ".rtc"); sram_load(); rtc_load(); atexit(cleanup); }
void loader_init(char *s) { char *name, *p; #ifndef __PALM__ // sys_checkdir(savedir, 1); /* needs to be writable */ #endif sprintf(rtcfile, "%s.rtc", s); romfile = s; rom_load(); #if 0 //ndef __PALM__ vid_settitle(rom.name); if (savename && *savename) { if (savename[0] == '-' && savename[1] == 0) name = ldup(rom.name); else name = strdup(savename); } else if (romfile && *base(romfile) && strcmp(romfile, "-")) { name = strdup(base(romfile)); p = (char*)strchr(name, '.'); if (p) *p = 0; } else name = ldup(rom.name); saveprefix = ljz_malloc(strlen(savedir) + strlen(name) + 2); sprintf(saveprefix, "%s/%s", savedir, name); sramfile = ljz_malloc(strlen(saveprefix) + 5); strcpy(sramfile, saveprefix); strcat(sramfile, ".sav"); rtcfile = ljz_malloc(strlen(saveprefix) + 5); strcpy(rtcfile, saveprefix); strcat(rtcfile, ".rtc"); #endif // sram_load(); #ifndef __PALM__ //init rtc /*if (rtc)*/ { time_t ltime; struct tm *Tm; unsigned long i; //february is always 28,.... unsigned long month_len[12]={31,28,31,30,31,30,31,31,30,31,30,31}; ltime=time(NULL); Tm=localtime(<ime); rtc.d=(int)Tm->tm_wday; for (i=0;i<Tm->tm_mon;i++) { rtc.d+=month_len[i]; } rtc.h=(int)Tm->tm_hour; rtc.m=(int)Tm->tm_min; rtc.s=(int)Tm->tm_sec; rtc.t=(int)0; /* { char tmp[16]; sprintf(tmp,"%d-%d-%d-%d-%d",rtc.d,rtc.h,rtc.m,rtc.s,rtc.t); menu_inform(tmp); }*/ } rtc_load(); //atexit(cleanup); #else if (rtc.batt) { /* struct tm *localTime; time_t long_time; //Get the system time time(&long_time); localTime = localtime(&long_time); //date is an ofs from 01 Jan 1900 00:00:00 rtc.d=localTime->tm_yday; rtc.h=localTime->tm_hour; rtc.m=localTime->tm_min; rtc.s=localTime->tm_sec;*/ rtc.t=0; rtc.stop=0; rtc.carry=0; while (rtc.t >= 60) rtc.t -= 60; while (rtc.s >= 60) rtc.s -= 60; while (rtc.m >= 60) rtc.m -= 60; while (rtc.h >= 24) rtc.h -= 24; while (rtc.d >= 365) rtc.d -= 365; rtc.stop &= 1; rtc.carry &= 1; //if (rt) rt = (time(0) - rt) * 60; //if (syncrtc) while (rt-- > 0) rtc_tick(); } #endif }