[Project64] Do not save on eeprom if read only

This commit is contained in:
zilmar 2016-12-13 06:13:10 +11:00
parent df36516c6d
commit 43ed20d59c
2 changed files with 15 additions and 10 deletions

View File

@ -185,10 +185,6 @@ void CEeprom::ReadFrom(uint8_t * Buffer, int32_t line)
void CEeprom::WriteTo(uint8_t * Buffer, int32_t line) void CEeprom::WriteTo(uint8_t * Buffer, int32_t line)
{ {
if (m_ReadOnly)
{
return;
}
int32_t i; int32_t i;
if (!m_File.IsOpen()) if (!m_File.IsOpen())
@ -199,6 +195,9 @@ void CEeprom::WriteTo(uint8_t * Buffer, int32_t line)
{ {
m_EEPROM[line * 8 + i] = Buffer[i]; m_EEPROM[line * 8 + i] = Buffer[i];
} }
m_File.Seek(line * 8, CFile::begin); if (!m_ReadOnly)
m_File.Write(Buffer, 8); {
m_File.Seek(line * 8, CFile::begin);
m_File.Write(Buffer, 8);
}
} }

View File

@ -163,8 +163,11 @@ void CFlashram::WriteToFlashCommand(uint32_t FlashRAM_Command)
{ {
return; return;
} }
m_File.Seek(m_FlashRAM_Offset, CFile::begin); if (!m_ReadOnly)
m_File.Write(EmptyBlock, sizeof(EmptyBlock)); {
m_File.Seek(m_FlashRAM_Offset, CFile::begin);
m_File.Write(EmptyBlock, sizeof(EmptyBlock));
}
break; break;
case FLASHRAM_MODE_WRITE: case FLASHRAM_MODE_WRITE:
if (!m_File.IsOpen() && !LoadFlashram()) if (!m_File.IsOpen() && !LoadFlashram())
@ -178,8 +181,11 @@ void CFlashram::WriteToFlashCommand(uint32_t FlashRAM_Command)
memset(FlipBuffer, 0, sizeof(FlipBuffer)); memset(FlipBuffer, 0, sizeof(FlipBuffer));
memcpy(&FlipBuffer[0], FlashRamPointer, sizeof(EmptyBlock)); memcpy(&FlipBuffer[0], FlashRamPointer, sizeof(EmptyBlock));
m_File.Seek(m_FlashRAM_Offset, CFile::begin); if (!m_ReadOnly)
m_File.Write(FlipBuffer, sizeof(EmptyBlock)); {
m_File.Seek(m_FlashRAM_Offset, CFile::begin);
m_File.Write(FlipBuffer, sizeof(EmptyBlock));
}
} }
break; break;
default: default: