Fixed saves and save states not working correctly on Windows
This commit is contained in:
parent
4bf391b1c8
commit
0b1e2784cd
@ -227,7 +227,7 @@ static bool dump_section(FILE *f, const void *src, uint32_t size)
|
|||||||
/* Todo: we need a sane and protable save state format. */
|
/* Todo: we need a sane and protable save state format. */
|
||||||
int GB_save_state(GB_gameboy_t *gb, const char *path)
|
int GB_save_state(GB_gameboy_t *gb, const char *path)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(path, "w");
|
FILE *f = fopen(path, "wb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ int GB_load_state(GB_gameboy_t *gb, const char *path)
|
|||||||
/* Every unread value should be kept the same. */
|
/* Every unread value should be kept the same. */
|
||||||
memcpy(&save, gb, sizeof(save));
|
memcpy(&save, gb, sizeof(save));
|
||||||
|
|
||||||
FILE *f = fopen(path, "r");
|
FILE *f = fopen(path, "rb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
@ -370,7 +370,7 @@ int GB_save_battery(GB_gameboy_t *gb, const char *path)
|
|||||||
{
|
{
|
||||||
if (!gb->cartridge_type->has_battery) return 0; // Nothing to save.
|
if (!gb->cartridge_type->has_battery) return 0; // Nothing to save.
|
||||||
if (gb->mbc_ram_size == 0 && !gb->cartridge_type->has_rtc) return 0; /* Claims to have battery, but has no RAM or RTC */
|
if (gb->mbc_ram_size == 0 && !gb->cartridge_type->has_rtc) return 0; /* Claims to have battery, but has no RAM or RTC */
|
||||||
FILE *f = fopen(path, "w");
|
FILE *f = fopen(path, "wb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
@ -399,7 +399,7 @@ int GB_save_battery(GB_gameboy_t *gb, const char *path)
|
|||||||
/* Loading will silently stop if the format is incomplete */
|
/* Loading will silently stop if the format is incomplete */
|
||||||
void GB_load_battery(GB_gameboy_t *gb, const char *path)
|
void GB_load_battery(GB_gameboy_t *gb, const char *path)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(path, "r");
|
FILE *f = fopen(path, "rb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user