Unload MSU-1 files on reset

This commit is contained in:
qwertymodo 2016-12-06 21:19:23 -08:00
parent c240cd3634
commit 907cf3efa8
4 changed files with 18 additions and 8 deletions

View File

@ -295,6 +295,7 @@ void S9xReset (void)
S9xResetPPU(); S9xResetPPU();
S9xResetDMA(); S9xResetDMA();
S9xResetAPU(); S9xResetAPU();
S9xResetMSU();
if (Settings.DSP) if (Settings.DSP)
S9xResetDSP(); S9xResetDSP();
@ -331,6 +332,7 @@ void S9xSoftReset (void)
S9xSoftResetPPU(); S9xSoftResetPPU();
S9xResetDMA(); S9xResetDMA();
S9xSoftResetAPU(); S9xSoftResetAPU();
S9xResetMSU();
if (Settings.DSP) if (Settings.DSP)
S9xResetDSP(); S9xResetDSP();

View File

@ -1275,12 +1275,6 @@ static bool8 is_GNEXT_Add_On (const uint8 *data, uint32 size)
return (FALSE); return (FALSE);
} }
static bool8 MsuRomExists (void)
{
struct stat buf;
return (stat(S9xGetFilename(".msu", ROMFILENAME_DIR), &buf) == 0);
}
int CMemory::ScoreHiROM (bool8 skip_header, int32 romoff) int CMemory::ScoreHiROM (bool8 skip_header, int32 romoff)
{ {
uint8 *buf = ROM + 0xff00 + romoff + (skip_header ? 0x200 : 0); uint8 *buf = ROM + 0xff00 + romoff + (skip_header ? 0x200 : 0);
@ -2547,7 +2541,7 @@ void CMemory::InitROM (void)
} }
// MSU1 // MSU1
Settings.MSU1 = MsuRomExists(); Settings.MSU1 = S9xMSU1ROMExists();
//// Map memory and calculate checksum //// Map memory and calculate checksum

View File

@ -251,7 +251,7 @@ bool DataOpen()
return dataFile.is_open(); return dataFile.is_open();
} }
void S9xMSU1Init(void) void S9xResetMSU(void)
{ {
MSU1.MSU1_STATUS = 0; MSU1.MSU1_STATUS = 0;
MSU1.MSU1_DATA_SEEK = 0; MSU1.MSU1_DATA_SEEK = 0;
@ -277,9 +277,21 @@ void S9xMSU1Init(void)
if (audioFile.is_open()) if (audioFile.is_open())
audioFile.close(); audioFile.close();
Settings.MSU1 = S9xMSU1ROMExists();
}
void S9xMSU1Init(void)
{
S9xResetMSU();
DataOpen(); DataOpen();
} }
bool S9xMSU1ROMExists(void)
{
struct stat buf;
return (stat(S9xGetFilename(".msu", ROMFILENAME_DIR), &buf) == 0);
}
void S9xMSU1Generate(int sample_count) void S9xMSU1Generate(int sample_count)
{ {
partial_samples += 441000 * sample_count; partial_samples += 441000 * sample_count;

2
msu1.h
View File

@ -226,7 +226,9 @@ enum SMSU1_CMD {
extern struct SMSU1 MSU1; extern struct SMSU1 MSU1;
void S9xResetMSU(void);
void S9xMSU1Init(void); void S9xMSU1Init(void);
bool S9xMSU1ROMExists(void);
void S9xMSU1Generate(int sample_count); void S9xMSU1Generate(int sample_count);
uint8 S9xMSU1ReadPort(int port); uint8 S9xMSU1ReadPort(int port);
void S9xMSU1WritePort(int port, uint8 byte); void S9xMSU1WritePort(int port, uint8 byte);