mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-12-27 19:51:48 +01:00
using fliestream
This commit is contained in:
parent
6652a76f30
commit
d1076a911e
@ -539,19 +539,19 @@ static void config_default(void)
|
|||||||
|
|
||||||
static void bram_load(void)
|
static void bram_load(void)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
RFILE *fp;
|
||||||
|
|
||||||
/* automatically load internal backup RAM */
|
/* automatically load internal backup RAM */
|
||||||
switch (region_code)
|
switch (region_code)
|
||||||
{
|
{
|
||||||
case REGION_JAPAN_NTSC:
|
case REGION_JAPAN_NTSC:
|
||||||
fp = fopen(CD_BRAM_JP, "rb");
|
fp = filestream_open(CD_BRAM_JP, RFILE_MODE_READ, -1);
|
||||||
break;
|
break;
|
||||||
case REGION_EUROPE:
|
case REGION_EUROPE:
|
||||||
fp = fopen(CD_BRAM_EU, "rb");
|
fp = filestream_open(CD_BRAM_EU, RFILE_MODE_READ, -1);
|
||||||
break;
|
break;
|
||||||
case REGION_USA:
|
case REGION_USA:
|
||||||
fp = fopen(CD_BRAM_US, "rb");
|
fp = filestream_open(CD_BRAM_US, RFILE_MODE_READ, -1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -559,8 +559,8 @@ static void bram_load(void)
|
|||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fread(scd.bram, 0x2000, 1, fp);
|
filestream_read(fp, scd.bram, 0x2000);
|
||||||
fclose(fp);
|
filestream_close(fp);
|
||||||
|
|
||||||
/* update CRC */
|
/* update CRC */
|
||||||
brm_crc[0] = crc32(0, scd.bram, 0x2000);
|
brm_crc[0] = crc32(0, scd.bram, 0x2000);
|
||||||
@ -591,7 +591,7 @@ static void bram_load(void)
|
|||||||
/* automatically load cartridge backup RAM (if enabled) */
|
/* automatically load cartridge backup RAM (if enabled) */
|
||||||
if (scd.cartridge.id)
|
if (scd.cartridge.id)
|
||||||
{
|
{
|
||||||
fp = fopen(CART_BRAM, "rb");
|
fp = filestream_open(CART_BRAM, RFILE_MODE_READ, -1);
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
int filesize = scd.cartridge.mask + 1;
|
int filesize = scd.cartridge.mask + 1;
|
||||||
@ -600,7 +600,7 @@ static void bram_load(void)
|
|||||||
/* Read into buffer (2k blocks) */
|
/* Read into buffer (2k blocks) */
|
||||||
while (filesize > CHUNKSIZE)
|
while (filesize > CHUNKSIZE)
|
||||||
{
|
{
|
||||||
fread(scd.cartridge.area + done, CHUNKSIZE, 1, fp);
|
filestream_read(fp, scd.cartridge.area + done, CHUNKSIZE);
|
||||||
done += CHUNKSIZE;
|
done += CHUNKSIZE;
|
||||||
filesize -= CHUNKSIZE;
|
filesize -= CHUNKSIZE;
|
||||||
}
|
}
|
||||||
@ -608,11 +608,11 @@ static void bram_load(void)
|
|||||||
/* Read remaining bytes */
|
/* Read remaining bytes */
|
||||||
if (filesize)
|
if (filesize)
|
||||||
{
|
{
|
||||||
fread(scd.cartridge.area + done, filesize, 1, fp);
|
filestream_read(fp, scd.cartridge.area + done, filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close file */
|
/* close file */
|
||||||
fclose(fp);
|
filestream_close(fp);
|
||||||
|
|
||||||
/* update CRC */
|
/* update CRC */
|
||||||
brm_crc[1] = crc32(0, scd.cartridge.area, scd.cartridge.mask + 1);
|
brm_crc[1] = crc32(0, scd.cartridge.area, scd.cartridge.mask + 1);
|
||||||
@ -636,7 +636,7 @@ static void bram_load(void)
|
|||||||
|
|
||||||
static void bram_save(void)
|
static void bram_save(void)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
RFILE *fp;
|
||||||
|
|
||||||
/* verify that internal backup RAM has been modified */
|
/* verify that internal backup RAM has been modified */
|
||||||
if (crc32(0, scd.bram, 0x2000) != brm_crc[0])
|
if (crc32(0, scd.bram, 0x2000) != brm_crc[0])
|
||||||
@ -647,13 +647,13 @@ static void bram_save(void)
|
|||||||
switch (region_code)
|
switch (region_code)
|
||||||
{
|
{
|
||||||
case REGION_JAPAN_NTSC:
|
case REGION_JAPAN_NTSC:
|
||||||
fp = fopen(CD_BRAM_JP, "wb");
|
fp = filestream_open(CD_BRAM_JP, RFILE_MODE_WRITE, -1);
|
||||||
break;
|
break;
|
||||||
case REGION_EUROPE:
|
case REGION_EUROPE:
|
||||||
fp = fopen(CD_BRAM_EU, "wb");
|
fp = filestream_open(CD_BRAM_EU, RFILE_MODE_WRITE, -1);
|
||||||
break;
|
break;
|
||||||
case REGION_USA:
|
case REGION_USA:
|
||||||
fp = fopen(CD_BRAM_US, "wb");
|
fp = filestream_open(CD_BRAM_US, RFILE_MODE_WRITE, -1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -661,8 +661,8 @@ static void bram_save(void)
|
|||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fwrite(scd.bram, 0x2000, 1, fp);
|
filestream_write(fp, scd.bram, 0x2000);
|
||||||
fclose(fp);
|
filestream_close(fp);
|
||||||
|
|
||||||
/* update CRC */
|
/* update CRC */
|
||||||
brm_crc[0] = crc32(0, scd.bram, 0x2000);
|
brm_crc[0] = crc32(0, scd.bram, 0x2000);
|
||||||
@ -676,7 +676,7 @@ static void bram_save(void)
|
|||||||
/* check if it is correctly formatted before saving */
|
/* check if it is correctly formatted before saving */
|
||||||
if (!memcmp(scd.cartridge.area + scd.cartridge.mask + 1 - 0x20, brm_format + 0x20, 0x20))
|
if (!memcmp(scd.cartridge.area + scd.cartridge.mask + 1 - 0x20, brm_format + 0x20, 0x20))
|
||||||
{
|
{
|
||||||
fp = fopen(CART_BRAM, "wb");
|
fp = filestream_open(CART_BRAM, RFILE_MODE_WRITE, -1);
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
int filesize = scd.cartridge.mask + 1;
|
int filesize = scd.cartridge.mask + 1;
|
||||||
@ -685,7 +685,7 @@ static void bram_save(void)
|
|||||||
/* Write to file (2k blocks) */
|
/* Write to file (2k blocks) */
|
||||||
while (filesize > CHUNKSIZE)
|
while (filesize > CHUNKSIZE)
|
||||||
{
|
{
|
||||||
fwrite(scd.cartridge.area + done, CHUNKSIZE, 1, fp);
|
filestream_write(fp, scd.cartridge.area + done, CHUNKSIZE);
|
||||||
done += CHUNKSIZE;
|
done += CHUNKSIZE;
|
||||||
filesize -= CHUNKSIZE;
|
filesize -= CHUNKSIZE;
|
||||||
}
|
}
|
||||||
@ -693,11 +693,11 @@ static void bram_save(void)
|
|||||||
/* Write remaining bytes */
|
/* Write remaining bytes */
|
||||||
if (filesize)
|
if (filesize)
|
||||||
{
|
{
|
||||||
fwrite(scd.cartridge.area + done, filesize, 1, fp);
|
filestream_write(fp, scd.cartridge.area + done, filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close file */
|
/* Close file */
|
||||||
fclose(fp);
|
filestream_close(fp);
|
||||||
|
|
||||||
/* update CRC */
|
/* update CRC */
|
||||||
brm_crc[1] = crc32(0, scd.cartridge.area, scd.cartridge.mask + 1);
|
brm_crc[1] = crc32(0, scd.cartridge.area, scd.cartridge.mask + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user