read qcode */
| 444 | |
| 445 | /* read qcode */ |
| 446 | static int ioctl_command_qcode(int unitnum, uae_u8* buf, int sector, bool all) |
| 447 | { |
| 448 | struct dev_info_ioctl* ciw = unitisopen(unitnum); |
| 449 | if (!ciw) |
| 450 | return 0; |
| 451 | |
| 452 | if (all) |
| 453 | return 0; |
| 454 | |
| 455 | memset(buf, 0, SUBQ_SIZE); |
| 456 | uae_u8* p = buf; |
| 457 | |
| 458 | int status = AUDIO_STATUS_NO_STATUS; |
| 459 | if (ciw->cda.cdda_play) { |
| 460 | status = AUDIO_STATUS_IN_PROGRESS; |
| 461 | if (ciw->cda.cdda_paused) |
| 462 | status = AUDIO_STATUS_PAUSED; |
| 463 | } else if (ciw->cda.cdda_play_finished) { |
| 464 | status = AUDIO_STATUS_PLAY_COMPLETE; |
| 465 | } |
| 466 | |
| 467 | p[1] = status; |
| 468 | p[3] = 12; |
| 469 | p = buf + 4; |
| 470 | |
| 471 | int pos = (sector < 0) ? ciw->cda.cd_last_pos : sector; |
| 472 | |
| 473 | int trk = cdtracknumber(&ciw->di.toc, pos); |
| 474 | if (trk < 0) |
| 475 | return 0; |
| 476 | |
| 477 | int start = 0; |
| 478 | int end = INT_MAX; |
| 479 | for (int i = ciw->di.toc.first_track; i <= ciw->di.toc.last_track; ++i) { |
| 480 | struct cd_toc* t = &ciw->di.toc.toc[i]; |
| 481 | if (t->point != i) |
| 482 | continue; |
| 483 | start = t->paddress; |
| 484 | if (i < ciw->di.toc.last_track) { |
| 485 | struct cd_toc* tn = &ciw->di.toc.toc[i + 1]; |
| 486 | end = tn->paddress; |
| 487 | } |
| 488 | if (pos >= start && pos < end) { |
| 489 | p[0] = (t->control << 4) | (t->adr << 0); |
| 490 | p[1] = tobcd(i); |
| 491 | p[2] = tobcd(1); |
| 492 | int msf = lsn2msf(pos); |
| 493 | tolongbcd(p + 7, msf); |
| 494 | msf = lsn2msf(pos - start - 150); |
| 495 | tolongbcd(p + 3, msf); |
| 496 | return 1; |
| 497 | } |
| 498 | } |
| 499 | return 0; |
| 500 | } |
| 501 | |
| 502 | static int ioctl_command_rawread(int unitnum, uae_u8* data, int sector, int size, int sectorsize, uae_u32 extra) |
| 503 | { |
nothing calls this directly
no test coverage detected