use correct save directory.
This commit is contained in:
parent
ad485d434a
commit
41484cd73c
45
gba_memory.c
45
gba_memory.c
|
@ -376,14 +376,6 @@ u32 gbc_sound_update = 0;
|
||||||
// If the GBC audio waveform is modified:
|
// If the GBC audio waveform is modified:
|
||||||
u32 gbc_sound_wave_update = 0;
|
u32 gbc_sound_wave_update = 0;
|
||||||
|
|
||||||
// If the backup space is written (only update once this hits 0)
|
|
||||||
u32 backup_update = 0;
|
|
||||||
|
|
||||||
// Write out backup file this many cycles after the most recent
|
|
||||||
// backup write.
|
|
||||||
const u32 write_backup_delay = 10;
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
BACKUP_SRAM,
|
BACKUP_SRAM,
|
||||||
|
@ -569,7 +561,6 @@ void function_cc write_eeprom(u32 address, u32 value)
|
||||||
eeprom_counter++;
|
eeprom_counter++;
|
||||||
if(eeprom_counter == 64)
|
if(eeprom_counter == 64)
|
||||||
{
|
{
|
||||||
backup_update = write_backup_delay;
|
|
||||||
eeprom_counter = 0;
|
eeprom_counter = 0;
|
||||||
eeprom_mode = EEPROM_WRITE_FOOTER_MODE;
|
eeprom_mode = EEPROM_WRITE_FOOTER_MODE;
|
||||||
}
|
}
|
||||||
|
@ -1619,7 +1610,6 @@ void function_cc write_backup(u32 address, u32 value)
|
||||||
memset(gamepak_backup, 0xFF, 1024 * 64);
|
memset(gamepak_backup, 0xFF, 1024 * 64);
|
||||||
else
|
else
|
||||||
memset(gamepak_backup, 0xFF, 1024 * 128);
|
memset(gamepak_backup, 0xFF, 1024 * 128);
|
||||||
backup_update = write_backup_delay;
|
|
||||||
flash_mode = FLASH_BASE_MODE;
|
flash_mode = FLASH_BASE_MODE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1646,7 +1636,6 @@ void function_cc write_backup(u32 address, u32 value)
|
||||||
{
|
{
|
||||||
// Erase sector
|
// Erase sector
|
||||||
memset(flash_bank_ptr + (address & 0xF000), 0xFF, 1024 * 4);
|
memset(flash_bank_ptr + (address & 0xF000), 0xFF, 1024 * 4);
|
||||||
backup_update = write_backup_delay;
|
|
||||||
flash_mode = FLASH_BASE_MODE;
|
flash_mode = FLASH_BASE_MODE;
|
||||||
flash_command_position = 0;
|
flash_command_position = 0;
|
||||||
}
|
}
|
||||||
|
@ -1664,7 +1653,6 @@ void function_cc write_backup(u32 address, u32 value)
|
||||||
if((flash_command_position == 0) && (flash_mode == FLASH_WRITE_MODE))
|
if((flash_command_position == 0) && (flash_mode == FLASH_WRITE_MODE))
|
||||||
{
|
{
|
||||||
// Write value to flash ROM
|
// Write value to flash ROM
|
||||||
backup_update = write_backup_delay;
|
|
||||||
flash_bank_ptr[address] = value;
|
flash_bank_ptr[address] = value;
|
||||||
flash_mode = FLASH_BASE_MODE;
|
flash_mode = FLASH_BASE_MODE;
|
||||||
}
|
}
|
||||||
|
@ -1673,7 +1661,6 @@ void function_cc write_backup(u32 address, u32 value)
|
||||||
if(backup_type == BACKUP_SRAM)
|
if(backup_type == BACKUP_SRAM)
|
||||||
{
|
{
|
||||||
// Write value to SRAM
|
// Write value to SRAM
|
||||||
backup_update = write_backup_delay;
|
|
||||||
// Hit 64KB territory?
|
// Hit 64KB territory?
|
||||||
if(address >= 0x8000)
|
if(address >= 0x8000)
|
||||||
sram_size = SRAM_SIZE_64KB;
|
sram_size = SRAM_SIZE_64KB;
|
||||||
|
@ -2205,18 +2192,6 @@ u32 save_backup(char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_backup()
|
void update_backup()
|
||||||
{
|
|
||||||
if(backup_update != (write_backup_delay + 1))
|
|
||||||
backup_update--;
|
|
||||||
|
|
||||||
if(backup_update == 0)
|
|
||||||
{
|
|
||||||
save_backup(backup_filename);
|
|
||||||
backup_update = write_backup_delay + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void update_backup_force()
|
|
||||||
{
|
{
|
||||||
save_backup(backup_filename);
|
save_backup(backup_filename);
|
||||||
}
|
}
|
||||||
|
@ -2421,6 +2396,7 @@ char gamepak_filename[512];
|
||||||
u32 load_gamepak(const char *name)
|
u32 load_gamepak(const char *name)
|
||||||
{
|
{
|
||||||
char cheats_filename[256];
|
char cheats_filename[256];
|
||||||
|
char *p;
|
||||||
|
|
||||||
s32 file_size = load_gamepak_raw(name);
|
s32 file_size = load_gamepak_raw(name);
|
||||||
|
|
||||||
|
@ -2433,14 +2409,16 @@ u32 load_gamepak(const char *name)
|
||||||
strncpy(gamepak_filename, name, sizeof(gamepak_filename));
|
strncpy(gamepak_filename, name, sizeof(gamepak_filename));
|
||||||
gamepak_filename[sizeof(gamepak_filename) - 1] = 0;
|
gamepak_filename[sizeof(gamepak_filename) - 1] = 0;
|
||||||
|
|
||||||
make_rpath(backup_filename, sizeof(backup_filename), ".sav");
|
p = strrchr(gamepak_filename, PATH_SEPARATOR_CHAR);
|
||||||
if (!load_backup(backup_filename))
|
if (p == NULL)
|
||||||
{
|
p = gamepak_filename;
|
||||||
// try path used by older versions
|
|
||||||
strcpy(backup_filename, name);
|
snprintf(backup_filename, sizeof(backup_filename), "%s/%s", save_path, p);
|
||||||
change_ext(gamepak_filename, backup_filename, ".sav");
|
p = strrchr(backup_filename, '.');
|
||||||
|
if (p != NULL)
|
||||||
|
strcpy(p, ".sav");
|
||||||
|
|
||||||
load_backup(backup_filename);
|
load_backup(backup_filename);
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(gamepak_title, gamepak_rom + 0xA0, 12);
|
memcpy(gamepak_title, gamepak_rom + 0xA0, 12);
|
||||||
memcpy(gamepak_code, gamepak_rom + 0xAC, 4);
|
memcpy(gamepak_code, gamepak_rom + 0xAC, 4);
|
||||||
|
@ -2450,9 +2428,6 @@ u32 load_gamepak(const char *name)
|
||||||
gamepak_maker[2] = 0;
|
gamepak_maker[2] = 0;
|
||||||
|
|
||||||
load_game_config(gamepak_title, gamepak_code, gamepak_maker);
|
load_game_config(gamepak_title, gamepak_code, gamepak_maker);
|
||||||
#ifndef __LIBRETRO__
|
|
||||||
load_game_config_file();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
change_ext(gamepak_filename, cheats_filename, ".cht");
|
change_ext(gamepak_filename, cheats_filename, ".cht");
|
||||||
add_cheats(cheats_filename);
|
add_cheats(cheats_filename);
|
||||||
|
|
|
@ -179,7 +179,6 @@ u32 load_gamepak(const char *name);
|
||||||
u32 load_backup(char *name);
|
u32 load_backup(char *name);
|
||||||
s32 load_bios(char *name);
|
s32 load_bios(char *name);
|
||||||
void update_backup();
|
void update_backup();
|
||||||
void update_backup_force();
|
|
||||||
void init_memory();
|
void init_memory();
|
||||||
void init_gamepak_buffer();
|
void init_gamepak_buffer();
|
||||||
void memory_term(void);
|
void memory_term(void);
|
||||||
|
|
33
libretro.c
33
libretro.c
|
@ -188,13 +188,13 @@ void retro_cheat_set(unsigned index, bool enabled, const char* code) {}
|
||||||
void error_msg(const char* text)
|
void error_msg(const char* text)
|
||||||
{
|
{
|
||||||
if (log_cb)
|
if (log_cb)
|
||||||
log_cb(RETRO_LOG_ERROR, text);
|
log_cb(RETRO_LOG_ERROR, "[gpSP]: %s\n", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void info_msg(const char* text)
|
void info_msg(const char* text)
|
||||||
{
|
{
|
||||||
if (log_cb)
|
if (log_cb)
|
||||||
log_cb(RETRO_LOG_INFO, text);
|
log_cb(RETRO_LOG_INFO, "[gpSP]: %s\n", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void extract_directory(char* buf, const char* path, size_t size)
|
static void extract_directory(char* buf, const char* path, size_t size)
|
||||||
|
@ -217,11 +217,7 @@ bool retro_load_game(const struct retro_game_info* info)
|
||||||
|
|
||||||
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
|
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
|
||||||
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
|
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
|
||||||
{
|
info_msg("RGB565 is not supported.");
|
||||||
if (log_cb)
|
|
||||||
log_cb(RETRO_LOG_INFO, "[TempGBA]: 0RGB1555 is not supported.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
extract_directory(main_path, info->path, sizeof(main_path));
|
extract_directory(main_path, info->path, sizeof(main_path));
|
||||||
|
|
||||||
|
@ -233,34 +229,29 @@ bool retro_load_game(const struct retro_game_info* info)
|
||||||
strncat(filename_bios, "/gba_bios.bin", sizeof(filename_bios));
|
strncat(filename_bios, "/gba_bios.bin", sizeof(filename_bios));
|
||||||
|
|
||||||
|
|
||||||
// if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir)
|
if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir)
|
||||||
// strncpy(dir_save, dir, sizeof(dir_save));
|
strncpy(save_path, dir, sizeof(save_path));
|
||||||
// else
|
else
|
||||||
// strncpy(dir_save, main_path, sizeof(dir_save));
|
strncpy(save_path, main_path, sizeof(save_path));
|
||||||
|
|
||||||
// strncat(dir_save, "/",sizeof(dir_save));
|
|
||||||
|
|
||||||
// strncat(main_path, "/",sizeof(main_path));
|
|
||||||
|
|
||||||
if (load_bios(filename_bios) != 0)
|
if (load_bios(filename_bios) != 0)
|
||||||
{
|
{
|
||||||
error_msg("Could not load BIOS image file.\n");
|
error_msg("Could not load BIOS image file.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bios_rom[0] != 0x18)
|
if (bios_rom[0] != 0x18)
|
||||||
{
|
{
|
||||||
info_msg("You have an incorrect BIOS image.\n");
|
info_msg("You have an incorrect BIOS image.");
|
||||||
info_msg("While many games will work fine, some will not. It\n");
|
info_msg("While many games will work fine, some will not.");
|
||||||
info_msg("is strongly recommended that you obtain the\n");
|
info_msg("It is strongly recommended that you obtain the correct BIOS file.");
|
||||||
info_msg("correct BIOS file.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gamepak_filename[0] = 0;
|
gamepak_filename[0] = 0;
|
||||||
|
|
||||||
if (load_gamepak(info->path) != 0)
|
if (load_gamepak(info->path) != 0)
|
||||||
{
|
{
|
||||||
error_msg("Could not load the game file.\n");
|
error_msg("Could not load the game file.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
main.c
16
main.c
|
@ -75,6 +75,7 @@ u32 synchronize_flag = 1;
|
||||||
|
|
||||||
u32 update_backup_flag = 1;
|
u32 update_backup_flag = 1;
|
||||||
char main_path[512];
|
char main_path[512];
|
||||||
|
char save_path[512];
|
||||||
|
|
||||||
void trigger_ext_event();
|
void trigger_ext_event();
|
||||||
|
|
||||||
|
@ -532,7 +533,7 @@ void synchronize()
|
||||||
void quit()
|
void quit()
|
||||||
{
|
{
|
||||||
if(!update_backup_flag)
|
if(!update_backup_flag)
|
||||||
update_backup_force();
|
update_backup();
|
||||||
|
|
||||||
sound_exit();
|
sound_exit();
|
||||||
}
|
}
|
||||||
|
@ -587,19 +588,6 @@ void change_ext(const char *src, char *buffer, const char *extension)
|
||||||
strcpy(dot_position, extension);
|
strcpy(dot_position, extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make path: <main_path>/<romname>.<ext>
|
|
||||||
void make_rpath(char *buff, size_t size, const char *ext)
|
|
||||||
{
|
|
||||||
char *p = strrchr(gamepak_filename, PATH_SEPARATOR_CHAR);
|
|
||||||
if (p == NULL)
|
|
||||||
p = gamepak_filename;
|
|
||||||
|
|
||||||
snprintf(buff, size, "%s/%s", main_path, p);
|
|
||||||
p = strrchr(buff, '.');
|
|
||||||
if (p != NULL)
|
|
||||||
strcpy(p, ext);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define main_savestate_builder(type) \
|
#define main_savestate_builder(type) \
|
||||||
void main_##type##_savestate(void) \
|
void main_##type##_savestate(void) \
|
||||||
{ \
|
{ \
|
||||||
|
|
2
main.h
2
main.h
|
@ -84,6 +84,7 @@ extern u32 flush_ram_count;
|
||||||
extern u64 base_timestamp;
|
extern u64 base_timestamp;
|
||||||
|
|
||||||
extern char main_path[512];
|
extern char main_path[512];
|
||||||
|
extern char save_path[512];
|
||||||
|
|
||||||
extern u32 update_backup_flag;
|
extern u32 update_backup_flag;
|
||||||
|
|
||||||
|
@ -119,7 +120,6 @@ extern u32 max_frameskip;
|
||||||
extern u32 num_skipped_frames;
|
extern u32 num_skipped_frames;
|
||||||
|
|
||||||
void change_ext(const char *src, char *buffer, const char *extension);
|
void change_ext(const char *src, char *buffer, const char *extension);
|
||||||
void make_rpath(char *buff, size_t size, const char *ext);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue