Loads the configured bios rom file into PS2 memory. PS2 memory must be allocated prior to this method being called. Remarks: This function does not fail if rom1 or rom2 files are missing, since none are explicitly required for most emulation tasks. Exceptions: BadStream - Thrown if the primary bios file (usually .bin) is not found, corrupted, etc.
| 315 | // BadStream - Thrown if the primary bios file (usually .bin) is not found, corrupted, etc. |
| 316 | // |
| 317 | bool LoadBIOS() |
| 318 | { |
| 319 | pxAssertMsg(eeMem->ROM, "PS2 system memory has not been initialized yet."); |
| 320 | |
| 321 | std::string path = EmuConfig.FullpathToBios(); |
| 322 | if (path.empty() || !FileSystem::FileExists(path.c_str())) |
| 323 | { |
| 324 | if (!path.empty()) |
| 325 | { |
| 326 | Console.Warning("Configured BIOS '%s' does not exist, trying to find an alternative.", |
| 327 | EmuConfig.BaseFilenames.Bios.c_str()); |
| 328 | } |
| 329 | |
| 330 | path = FindBiosImage(); |
| 331 | if (path.empty()) |
| 332 | return false; |
| 333 | } |
| 334 | |
| 335 | auto fp = FileSystem::OpenManagedCFile(path.c_str(), "rb"); |
| 336 | if (!fp) |
| 337 | return false; |
| 338 | |
| 339 | const s64 filesize = FileSystem::FSize64(fp.get()); |
| 340 | if (filesize <= 0) |
| 341 | return false; |
| 342 | |
| 343 | LoadBiosVersion(fp.get(), BiosVersion, BiosDescription, BiosRegion, BiosZone, BiosSerial); |
| 344 | |
| 345 | BiosRom.resize(Ps2MemSize::Rom); |
| 346 | |
| 347 | if (FileSystem::FSeek64(fp.get(), 0, SEEK_SET) || |
| 348 | std::fread(BiosRom.data(), static_cast<size_t>(std::min<s64>(Ps2MemSize::Rom, filesize)), 1, fp.get()) != 1) |
| 349 | { |
| 350 | return false; |
| 351 | } |
| 352 | |
| 353 | // If file is less than 2mb it doesn't have an OSD (Devel consoles) |
| 354 | // So skip HLEing OSDSys Param stuff |
| 355 | if (filesize < 2465792) |
| 356 | NoOSD = true; |
| 357 | else |
| 358 | NoOSD = false; |
| 359 | |
| 360 | BiosChecksum = 0; |
| 361 | ChecksumIt(BiosChecksum, 0, Ps2MemSize::Rom); |
| 362 | BiosPath = std::move(path); |
| 363 | |
| 364 | //injectIRX("host.irx"); //not fully tested; still buggy |
| 365 | |
| 366 | LoadExtraRom("rom1", Ps2MemSize::Rom, Ps2MemSize::Rom1); |
| 367 | LoadExtraRom("rom2", Ps2MemSize::Rom + Ps2MemSize::Rom1, Ps2MemSize::Rom2); |
| 368 | return true; |
| 369 | } |
| 370 | |
| 371 | void CopyBIOSToMemory() |
| 372 | { |
no test coverage detected