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

Function cdvdReadConfig

pcsx2/CDVD/CDVD.cpp:319–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319s32 cdvdReadConfig(u8* config)
320{
321 // make sure its in read mode
322 if (cdvd.CReadWrite != 0)
323 {
324 config[0] = 0x80;
325 memset(&config[1], 0x00, 15);
326 return 1;
327 }
328 // check if block index is in bounds
329 else if (cdvd.CBlockIndex >= cdvd.CNumBlocks)
330 return 1;
331 else if (
332 ((cdvd.COffset == 0) && (cdvd.CBlockIndex >= 4)) ||
333 ((cdvd.COffset == 1) && (cdvd.CBlockIndex >= 2)) ||
334 ((cdvd.COffset == 2) && (cdvd.CBlockIndex >= 7)))
335 {
336 memset(config, 0, 16);
337 return 0;
338 }
339
340 // get config data
341 const NVMLayout* nvmLayout = getNvmLayout();
342 switch (cdvd.COffset)
343 {
344 case 0:
345 cdvdReadNVM(config, nvmLayout->config0 + ((cdvd.CBlockIndex++) * 16), 16);
346 break;
347 case 2:
348 cdvdReadNVM(config, nvmLayout->config2 + ((cdvd.CBlockIndex++) * 16), 16);
349 break;
350 default:
351 {
352 cdvdReadNVM(config, nvmLayout->config1 + (cdvd.CBlockIndex * 16), 16);
353 if (cdvd.CBlockIndex == 1 && (NoOSD || VMManager::Internal::WasFastBooted()))
354 {
355 // HACK: Set the "initialized" flag when fast booting, otherwise some games crash (e.g. Jak 1).
356 config[2] |= 0x80;
357 }
358
359 cdvd.CBlockIndex++;
360 }
361 break;
362 }
363 return 0;
364}
365s32 cdvdWriteConfig(const u8* config)
366{
367 // make sure its in write mode && the block index is in bounds

Callers 1

cdvdWrite16Function · 0.85

Calls 2

getNvmLayoutFunction · 0.85
cdvdReadNVMFunction · 0.85

Tested by

no test coverage detected