mirror of
https://github.com/SourMesen/Mesen2.git
synced 2024-06-23 14:43:43 -04:00
Refactoring: Renamed "bios" to "firmware"
This commit is contained in:
parent
aa5e26855c
commit
71ddf2bf1c
|
@ -1,59 +0,0 @@
|
|||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "Console.h"
|
||||
#include "NotificationManager.h"
|
||||
#include "../Utilities/FolderUtilities.h"
|
||||
|
||||
struct MissingBiosMessage
|
||||
{
|
||||
const char* Filename;
|
||||
CoprocessorType BiosType;
|
||||
uint32_t Size;
|
||||
};
|
||||
|
||||
class BiosHelper
|
||||
{
|
||||
private:
|
||||
static bool AttemptLoadDspBios(string combinedFilename, string splitFilenameProgram, string splitFilenameData, vector<uint8_t> &programRom, vector<uint8_t> &dataRom, uint32_t programSize, uint32_t dataSize)
|
||||
{
|
||||
VirtualFile combinedBios(FolderUtilities::CombinePath(FolderUtilities::GetBiosFolder(), combinedFilename));
|
||||
if(combinedBios.GetSize() == programSize + dataSize) {
|
||||
vector<uint8_t> biosData;
|
||||
combinedBios.ReadFile(biosData);
|
||||
programRom.insert(programRom.end(), biosData.begin(), biosData.begin() + programSize);
|
||||
dataRom.insert(dataRom.end(), biosData.begin() + programSize, biosData.end());
|
||||
return true;
|
||||
} else {
|
||||
VirtualFile splitBiosProg(FolderUtilities::CombinePath(FolderUtilities::GetBiosFolder(), splitFilenameProgram));
|
||||
VirtualFile splitBiosData(FolderUtilities::CombinePath(FolderUtilities::GetBiosFolder(), splitFilenameData));
|
||||
|
||||
if(splitBiosProg.GetSize() == programSize && splitBiosData.GetSize() == dataSize) {
|
||||
splitBiosProg.ReadFile(programRom);
|
||||
splitBiosData.ReadFile(dataRom);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public:
|
||||
static bool LoadDspBios(Console *console, CoprocessorType coprocessorType, string combinedFilename, string splitFilenameProgram, string splitFilenameData, vector<uint8_t> &programRom, vector<uint8_t> &dataRom, uint32_t programSize = 0x1800, uint32_t dataSize = 0x800)
|
||||
{
|
||||
if(AttemptLoadDspBios(combinedFilename, splitFilenameProgram, splitFilenameData, programRom, dataRom, programSize, dataSize)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MissingBiosMessage msg;
|
||||
msg.Filename = combinedFilename.c_str();
|
||||
msg.BiosType = coprocessorType;
|
||||
msg.Size = programSize + dataSize;
|
||||
console->GetNotificationManager()->SendNotification(ConsoleNotificationType::MissingBios, &msg);
|
||||
|
||||
//Try again in case the user selected a valid bios file
|
||||
if(AttemptLoadDspBios(combinedFilename, splitFilenameProgram, splitFilenameData, programRom, dataRom, programSize, dataSize)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MessageManager::DisplayMessage("Error", "Could not find BIOS file for DSP: " + combinedFilename);
|
||||
return false;
|
||||
}
|
||||
};
|
|
@ -51,7 +51,7 @@
|
|||
<ClInclude Include="BaseRenderer.h" />
|
||||
<ClInclude Include="BaseSoundManager.h" />
|
||||
<ClInclude Include="BaseVideoFilter.h" />
|
||||
<ClInclude Include="BiosHelper.h" />
|
||||
<ClInclude Include="FirmwareHelper.h" />
|
||||
<ClInclude Include="blargg_common.h" />
|
||||
<ClInclude Include="blargg_config.h" />
|
||||
<ClInclude Include="blargg_endian.h" />
|
||||
|
|
|
@ -302,7 +302,7 @@
|
|||
<ClInclude Include="NecDspTypes.h">
|
||||
<Filter>SNES\Coprocessors</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BiosHelper.h">
|
||||
<ClInclude Include="FirmwareHelper.h">
|
||||
<Filter>Misc</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
|
|
59
Core/FirmwareHelper.h
Normal file
59
Core/FirmwareHelper.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "Console.h"
|
||||
#include "NotificationManager.h"
|
||||
#include "../Utilities/FolderUtilities.h"
|
||||
|
||||
struct MissingFirmwareMessage
|
||||
{
|
||||
const char* Filename;
|
||||
CoprocessorType FirmwareType;
|
||||
uint32_t Size;
|
||||
};
|
||||
|
||||
class FirmwareHelper
|
||||
{
|
||||
private:
|
||||
static bool AttemptLoadDspFirmware(string combinedFilename, string splitFilenameProgram, string splitFilenameData, vector<uint8_t> &programRom, vector<uint8_t> &dataRom, uint32_t programSize, uint32_t dataSize)
|
||||
{
|
||||
VirtualFile combinedFirmware(FolderUtilities::CombinePath(FolderUtilities::GetFirmwareFolder(), combinedFilename));
|
||||
if(combinedFirmware.GetSize() == programSize + dataSize) {
|
||||
vector<uint8_t> firmwareData;
|
||||
combinedFirmware.ReadFile(firmwareData);
|
||||
programRom.insert(programRom.end(), firmwareData.begin(), firmwareData.begin() + programSize);
|
||||
dataRom.insert(dataRom.end(), firmwareData.begin() + programSize, firmwareData.end());
|
||||
return true;
|
||||
} else {
|
||||
VirtualFile splitFirmwareProg(FolderUtilities::CombinePath(FolderUtilities::GetFirmwareFolder(), splitFilenameProgram));
|
||||
VirtualFile splitFirmwareData(FolderUtilities::CombinePath(FolderUtilities::GetFirmwareFolder(), splitFilenameData));
|
||||
|
||||
if(splitFirmwareProg.GetSize() == programSize && splitFirmwareData.GetSize() == dataSize) {
|
||||
splitFirmwareProg.ReadFile(programRom);
|
||||
splitFirmwareData.ReadFile(dataRom);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public:
|
||||
static bool LoadDspFirmware(Console *console, CoprocessorType coprocessorType, string combinedFilename, string splitFilenameProgram, string splitFilenameData, vector<uint8_t> &programRom, vector<uint8_t> &dataRom, uint32_t programSize = 0x1800, uint32_t dataSize = 0x800)
|
||||
{
|
||||
if(AttemptLoadDspFirmware(combinedFilename, splitFilenameProgram, splitFilenameData, programRom, dataRom, programSize, dataSize)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MissingFirmwareMessage msg;
|
||||
msg.Filename = combinedFilename.c_str();
|
||||
msg.FirmwareType = coprocessorType;
|
||||
msg.Size = programSize + dataSize;
|
||||
console->GetNotificationManager()->SendNotification(ConsoleNotificationType::MissingFirmware, &msg);
|
||||
|
||||
//Try again in case the user selected a valid firmware file
|
||||
if(AttemptLoadDspFirmware(combinedFilename, splitFilenameProgram, splitFilenameData, programRom, dataRom, programSize, dataSize)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MessageManager::DisplayMessage("Error", "Could not find firmware file for DSP: " + combinedFilename);
|
||||
return false;
|
||||
}
|
||||
};
|
|
@ -18,7 +18,7 @@ enum class ConsoleNotificationType
|
|||
BeforeEmulationStop = 12,
|
||||
ViewerRefresh = 13,
|
||||
EventViewerRefresh = 14,
|
||||
MissingBios = 15
|
||||
MissingFirmware = 15
|
||||
};
|
||||
|
||||
class INotificationListener
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "MessageManager.h"
|
||||
#include "EmuSettings.h"
|
||||
#include "RamHandler.h"
|
||||
#include "BiosHelper.h"
|
||||
#include "FirmwareHelper.h"
|
||||
#include "../Utilities/FolderUtilities.h"
|
||||
|
||||
NecDsp::NecDsp(CoprocessorType type, Console* console, vector<uint8_t> &programRom, vector<uint8_t> &dataRom)
|
||||
|
@ -75,20 +75,20 @@ NecDsp::NecDsp(CoprocessorType type, Console* console, vector<uint8_t> &programR
|
|||
|
||||
NecDsp* NecDsp::InitCoprocessor(CoprocessorType type, Console *console)
|
||||
{
|
||||
bool biosLoaded = false;
|
||||
bool firmwareLoaded = false;
|
||||
vector<uint8_t> programRom;
|
||||
vector<uint8_t> dataRom;
|
||||
switch(type) {
|
||||
case CoprocessorType::DSP1: biosLoaded = BiosHelper::LoadDspBios(console, type, "dsp1.rom", "dsp1.program.rom", "dsp1.data.rom", programRom, dataRom); break;
|
||||
case CoprocessorType::DSP1B: biosLoaded = BiosHelper::LoadDspBios(console, type, "dsp1b.rom", "dsp1b.program.rom", "dsp1b.data.rom", programRom, dataRom); break;
|
||||
case CoprocessorType::DSP2: biosLoaded = BiosHelper::LoadDspBios(console, type, "dsp2.rom", "dsp2.program.rom", "dsp2.data.rom", programRom, dataRom); break;
|
||||
case CoprocessorType::DSP3: biosLoaded = BiosHelper::LoadDspBios(console, type, "dsp3.rom", "dsp3.program.rom", "dsp3.data.rom", programRom, dataRom); break;
|
||||
case CoprocessorType::DSP4: biosLoaded = BiosHelper::LoadDspBios(console, type, "dsp4.rom", "dsp4.program.rom", "dsp4.data.rom", programRom, dataRom); break;
|
||||
case CoprocessorType::ST010: biosLoaded = BiosHelper::LoadDspBios(console, type, "st010.rom", "st010.program.rom", "st010.data.rom", programRom, dataRom, 0xC000, 0x1000); break;
|
||||
case CoprocessorType::ST011: biosLoaded = BiosHelper::LoadDspBios(console, type, "st011.rom", "st011.program.rom", "st011.data.rom", programRom, dataRom, 0xC000, 0x1000); break;
|
||||
case CoprocessorType::DSP1: firmwareLoaded = FirmwareHelper::LoadDspFirmware(console, type, "dsp1.rom", "dsp1.program.rom", "dsp1.data.rom", programRom, dataRom); break;
|
||||
case CoprocessorType::DSP1B: firmwareLoaded = FirmwareHelper::LoadDspFirmware(console, type, "dsp1b.rom", "dsp1b.program.rom", "dsp1b.data.rom", programRom, dataRom); break;
|
||||
case CoprocessorType::DSP2: firmwareLoaded = FirmwareHelper::LoadDspFirmware(console, type, "dsp2.rom", "dsp2.program.rom", "dsp2.data.rom", programRom, dataRom); break;
|
||||
case CoprocessorType::DSP3: firmwareLoaded = FirmwareHelper::LoadDspFirmware(console, type, "dsp3.rom", "dsp3.program.rom", "dsp3.data.rom", programRom, dataRom); break;
|
||||
case CoprocessorType::DSP4: firmwareLoaded = FirmwareHelper::LoadDspFirmware(console, type, "dsp4.rom", "dsp4.program.rom", "dsp4.data.rom", programRom, dataRom); break;
|
||||
case CoprocessorType::ST010: firmwareLoaded = FirmwareHelper::LoadDspFirmware(console, type, "st010.rom", "st010.program.rom", "st010.data.rom", programRom, dataRom, 0xC000, 0x1000); break;
|
||||
case CoprocessorType::ST011: firmwareLoaded = FirmwareHelper::LoadDspFirmware(console, type, "st011.rom", "st011.program.rom", "st011.data.rom", programRom, dataRom, 0xC000, 0x1000); break;
|
||||
}
|
||||
|
||||
if(!biosLoaded) {
|
||||
if(!firmwareLoaded) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ private:
|
|||
void Load(uint8_t dest, uint16_t value);
|
||||
uint16_t GetSourceValue(uint8_t source);
|
||||
|
||||
static bool LoadBios(Console *console, string combinedFilename, string splitFilenameProgram, string splitFilenameData, vector<uint8_t> &programRom, vector<uint8_t> &dataRom, uint32_t programSize, uint32_t dataSize);
|
||||
static bool LoadFirmware(Console *console, string combinedFilename, string splitFilenameProgram, string splitFilenameData, vector<uint8_t> &programRom, vector<uint8_t> &dataRom, uint32_t programSize, uint32_t dataSize);
|
||||
|
||||
NecDsp(CoprocessorType type, Console* console, vector<uint8_t> &programRom, vector<uint8_t> &dataRom);
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ namespace Mesen.GUI.Config
|
|||
public static string WaveFolder { get { return GetFolder(DefaultWaveFolder, Config.Preferences.WaveFolder, Config.Preferences.OverrideWaveFolder); } }
|
||||
|
||||
public static string DebuggerFolder { get { return GetFolder(Path.Combine(ConfigManager.HomeFolder, "Debugger"), null, false); } }
|
||||
public static string BiosFolder { get { return GetFolder(Path.Combine(ConfigManager.HomeFolder, "Bios"), null, false); } }
|
||||
public static string FirmwareFolder { get { return GetFolder(Path.Combine(ConfigManager.HomeFolder, "Firmware"), null, false); } }
|
||||
public static string DownloadFolder { get { return GetFolder(Path.Combine(ConfigManager.HomeFolder, "Downloads"), null, false); } }
|
||||
public static string BackupFolder { get { return GetFolder(Path.Combine(ConfigManager.HomeFolder, "Backups"), null, false); } }
|
||||
public static string TestFolder { get { return GetFolder(Path.Combine(ConfigManager.HomeFolder, "Tests"), null, false); } }
|
||||
|
|
|
@ -689,8 +689,8 @@
|
|||
<Message ID="ClearHistory">Clear History</Message>
|
||||
<Message ID="LastFolderUsed">Last Folder Used</Message>
|
||||
|
||||
<Message ID="BiosNotFound">This game requires a firmware file for the {0} chip.

 Filename: {1}
 Size: {2} bytes

Would you like to select it now?</Message>
|
||||
<Message ID="BiosMismatch">The selected file does not match the firmware required for this chip ({0}).

Firmware SHA-256:
{1}

Selected file's SHA-256:
{2}

Would you like to use this file anyway?</Message>
|
||||
<Message ID="FirmwareNotFound">This game requires a firmware file for the {0} chip.

 Filename: {1}
 Size: {2} bytes

Would you like to select it now?</Message>
|
||||
<Message ID="FirmwareMismatch">The selected file does not match the firmware required for this chip ({0}).

Firmware SHA-256:
{1}

Selected file's SHA-256:
{2}

Would you like to use this file anyway?</Message>
|
||||
|
||||
<Message ID="MouseModeEnabled">Mouse mode enabled - press ESC or pause to release the cursor.</Message>
|
||||
<Message ID="BandaiMicrophone">Bandai Microphone</Message>
|
||||
|
|
|
@ -168,10 +168,10 @@ namespace Mesen.GUI.Forms
|
|||
}));
|
||||
break;
|
||||
|
||||
case ConsoleNotificationType.MissingBios:
|
||||
case ConsoleNotificationType.MissingFirmware:
|
||||
this.Invoke((Action)(() => {
|
||||
MissingBiosMessage msg = (MissingBiosMessage)Marshal.PtrToStructure(e.Parameter, typeof(MissingBiosMessage));
|
||||
BiosHelper.RequestBiosFile(msg);
|
||||
MissingFirmwareMessage msg = (MissingFirmwareMessage)Marshal.PtrToStructure(e.Parameter, typeof(MissingFirmwareMessage));
|
||||
FirmwareHelper.RequestFirmwareFile(msg);
|
||||
}));
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -178,10 +178,10 @@ namespace Mesen.GUI
|
|||
CX4
|
||||
}
|
||||
|
||||
public struct MissingBiosMessage
|
||||
public struct MissingFirmwareMessage
|
||||
{
|
||||
public IntPtr Filename;
|
||||
public CoprocessorType BiosType;
|
||||
public CoprocessorType FirmwareType;
|
||||
public UInt32 Size;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,6 @@ namespace Mesen.GUI
|
|||
BeforeEmulationStop = 12,
|
||||
ViewerRefresh = 13,
|
||||
EventViewerRefresh = 14,
|
||||
MissingBios = 15
|
||||
MissingFirmware = 15
|
||||
}
|
||||
}
|
||||
|
|
|
@ -812,7 +812,7 @@
|
|||
<Compile Include="RuntimeChecker.cs" />
|
||||
<Compile Include="SingleInstance.cs" />
|
||||
<Compile Include="Utilities\ArchiveHelper.cs" />
|
||||
<Compile Include="Utilities\BiosHelper.cs" />
|
||||
<Compile Include="Utilities\FirmwareHelper.cs" />
|
||||
<Compile Include="Utilities\CommandLineHelper.cs" />
|
||||
<Compile Include="Utilities\FolderHelper.cs" />
|
||||
<Compile Include="Utilities\HexConverter.cs" />
|
||||
|
|
|
@ -11,7 +11,7 @@ using System.Windows.Forms;
|
|||
|
||||
namespace Mesen.GUI.Utilities
|
||||
{
|
||||
public static class BiosHelper
|
||||
public static class FirmwareHelper
|
||||
{
|
||||
private static string GetFileHash(string filename)
|
||||
{
|
||||
|
@ -44,20 +44,20 @@ namespace Mesen.GUI.Utilities
|
|||
throw new Exception("Unexpected coprocessor type");
|
||||
}
|
||||
|
||||
public static void RequestBiosFile(MissingBiosMessage msg)
|
||||
public static void RequestFirmwareFile(MissingFirmwareMessage msg)
|
||||
{
|
||||
string filename = Utf8Marshaler.GetStringFromIntPtr(msg.Filename);
|
||||
if(MesenMsgBox.Show("BiosNotFound", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, msg.BiosType.ToString(), filename, msg.Size.ToString()) == DialogResult.OK) {
|
||||
if(MesenMsgBox.Show("FirmwareNotFound", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, msg.FirmwareType.ToString(), filename, msg.Size.ToString()) == DialogResult.OK) {
|
||||
using(OpenFileDialog ofd = new OpenFileDialog()) {
|
||||
ofd.SetFilter(ResourceHelper.GetMessage("FilterAll"));
|
||||
if(ofd.ShowDialog(Application.OpenForms[0]) == DialogResult.OK) {
|
||||
if(GetFileHash(ofd.FileName) != GetExpectedHash(msg.BiosType)) {
|
||||
if(MesenMsgBox.Show("BiosMismatch", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, msg.BiosType.ToString(), GetFileHash(ofd.FileName), GetExpectedHash(msg.BiosType)) != DialogResult.OK) {
|
||||
if(GetFileHash(ofd.FileName) != GetExpectedHash(msg.FirmwareType)) {
|
||||
if(MesenMsgBox.Show("FirmwareMismatch", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, msg.FirmwareType.ToString(), GetFileHash(ofd.FileName), GetExpectedHash(msg.FirmwareType)) != DialogResult.OK) {
|
||||
//Files don't match and user cancelled the action
|
||||
return;
|
||||
}
|
||||
}
|
||||
File.Copy(ofd.FileName, Path.Combine(ConfigManager.BiosFolder, filename));
|
||||
File.Copy(ofd.FileName, Path.Combine(ConfigManager.FirmwareFolder, filename));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ namespace fs = std::experimental::filesystem;
|
|||
string FolderUtilities::_homeFolder = "";
|
||||
string FolderUtilities::_saveFolderOverride = "";
|
||||
string FolderUtilities::_saveStateFolderOverride = "";
|
||||
string FolderUtilities::_biosFolderOverride = "";
|
||||
string FolderUtilities::_firmwareFolderOverride = "";
|
||||
string FolderUtilities::_screenshotFolderOverride = "";
|
||||
vector<string> FolderUtilities::_gameFolders = vector<string>();
|
||||
|
||||
|
@ -75,13 +75,13 @@ string FolderUtilities::GetSaveFolder()
|
|||
return folder;
|
||||
}
|
||||
|
||||
string FolderUtilities::GetBiosFolder()
|
||||
string FolderUtilities::GetFirmwareFolder()
|
||||
{
|
||||
string folder;
|
||||
if(_biosFolderOverride.empty()) {
|
||||
folder = CombinePath(GetHomeFolder(), "Bios");
|
||||
if(_firmwareFolderOverride.empty()) {
|
||||
folder = CombinePath(GetHomeFolder(), "Firmware");
|
||||
} else {
|
||||
folder = _biosFolderOverride;
|
||||
folder = _firmwareFolderOverride;
|
||||
}
|
||||
CreateFolder(folder);
|
||||
return folder;
|
||||
|
|
|
@ -9,7 +9,7 @@ private:
|
|||
static string _homeFolder;
|
||||
static string _saveFolderOverride;
|
||||
static string _saveStateFolderOverride;
|
||||
static string _biosFolderOverride;
|
||||
static string _firmwareFolderOverride;
|
||||
static string _screenshotFolderOverride;
|
||||
static vector<string> _gameFolders;
|
||||
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
static vector<string> GetKnownGameFolders();
|
||||
|
||||
static string GetSaveFolder();
|
||||
static string GetBiosFolder();
|
||||
static string GetFirmwareFolder();
|
||||
static string GetSaveStateFolder();
|
||||
static string GetScreenshotFolder();
|
||||
static string GetHdPackFolder();
|
||||
|
|
Loading…
Reference in a new issue