MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / ioctl_command_qcode

Function ioctl_command_qcode

src/osdep/blkdev_ioctl.cpp:446–500  ·  view source on GitHub ↗

read qcode */

Source from the content-addressed store, hash-verified

444
445/* read qcode */
446static 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
502static int ioctl_command_rawread(int unitnum, uae_u8* data, int sector, int size, int sectorsize, uae_u32 extra)
503{

Callers

nothing calls this directly

Calls 7

cdtracknumberFunction · 0.85
lsn2msfFunction · 0.85
tolongbcdFunction · 0.85
msf2lsnFunction · 0.85
unitisopenFunction · 0.70
sub_deinterleaveFunction · 0.70
tobcdFunction · 0.50

Tested by

no test coverage detected