| 317 | } |
| 318 | |
| 319 | s32 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 | } |
| 365 | s32 cdvdWriteConfig(const u8* config) |
| 366 | { |
| 367 | // make sure its in write mode && the block index is in bounds |
no test coverage detected