MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / LoadExtraRom

Function LoadExtraRom

pcsx2/ps2/BiosTools.cpp:214–241  ·  view source on GitHub ↗

Attempts to load a BIOS rom sub-component, by trying multiple combinations of base filename and extension. The bios specified in the user's configuration is used as the base. Parameters: ext - extension of the sub-component to load. Valid options are rom1 and rom2.

Source from the content-addressed store, hash-verified

212// ext - extension of the sub-component to load. Valid options are rom1 and rom2.
213//
214static void LoadExtraRom(const char* ext, u32 offset, u32 size)
215{
216 // Try first a basic extension concatenation (normally results in something like name.bin.rom1)
217 std::string Bios1(StringUtil::StdStringFromFormat("%s.%s", BiosPath.c_str(), ext));
218
219 s64 filesize;
220 if ((filesize = FileSystem::GetPathFileSize(Bios1.c_str())) <= 0)
221 {
222 // Try the name properly extensioned next (name.rom1)
223 Bios1 = Path::ReplaceExtension(BiosPath, ext);
224 if ((filesize = FileSystem::GetPathFileSize(Bios1.c_str())) <= 0)
225 {
226 Console.WriteLn(Color_Gray, "BIOS %s module not found, skipping...", ext);
227 return;
228 }
229 }
230
231 BiosRom.resize(offset + size);
232
233 auto fp = FileSystem::OpenManagedCFileTryIgnoreCase(Bios1.c_str(), "rb");
234 if (!fp || std::fread(&BiosRom[offset], static_cast<size_t>(std::min<s64>(size, filesize)), 1, fp.get()) != 1)
235 {
236 Console.Warning("BIOS Warning: %s could not be read (permission denied?)", ext);
237 return;
238 }
239 // Checksum for ROM1, ROM2? Rama says no, Gigaherz says yes. I'm not sure either way. --air
240 //ChecksumIt( BiosChecksum, dest );
241}
242
243static void LoadIrx(const std::string& filename, u8* dest, size_t maxSize)
244{

Callers 1

LoadBIOSFunction · 0.85

Calls 6

StdStringFromFormatFunction · 0.85
c_strMethod · 0.45
WriteLnMethod · 0.45
resizeMethod · 0.45
getMethod · 0.45
WarningMethod · 0.45

Tested by

no test coverage detected