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

Function sys_command_cd_toc

src/blkdev.cpp:914–958  ·  view source on GitHub ↗

read table of contents */

Source from the content-addressed store, hash-verified

912
913/* read table of contents */
914int sys_command_cd_toc (int unitnum, struct cd_toc_head *th)
915{
916 int v;
917 if (failunit (unitnum))
918 return 0;
919 if (!getsem (unitnum))
920 return 0;
921 if (state[unitnum].device_func->toc == NULL) {
922 uae_u8 buf[4 + 8 * 103];
923 int size = sizeof buf;
924 uae_u8 cmd [10] = { 0x43,0,0,0,0,0,0,(uae_u8)(size>>8),(uae_u8)(size&0xff),0};
925 v = do_scsi(unitnum, cmd, sizeof cmd, buf, size);
926 if (v > 0) {
927 th->first_track = buf[2];
928 th->last_track = buf[3];
929 th->tracks = th->last_track - th->first_track + 1;
930 th->firstaddress = 0;
931 th->points = th->tracks + 1;
932 int len = (buf[0] << 8) | buf[1];
933 uae_u8 *p = buf + 4;
934 if ((th->tracks + 1) * 8 > len) {
935 freesem(unitnum);
936 return 0;
937 }
938 struct cd_toc *t = &th->toc[th->first_track];
939 for (int i = th->first_track; i <= th->last_track; i++) {
940 t->adr = p[1] >> 4;
941 t->control = p[1] & 15;
942 t->point = t->track = p[2];
943 t->paddress = (p[5] << 16) | (p[6] << 8) | (p[7] << 0);
944 p += 8;
945 t++;
946 }
947 th->lastaddress = (p[5] << 16) | (p[6] << 8) | (p[7] << 0);
948 t->track = t->point = 0xaa;
949 th->first_track_offset = 0;
950 th->last_track_offset = th->last_track;
951 v = 1;
952 }
953 } else {
954 v = state[unitnum].device_func->toc (unitnum, th);
955 }
956 freesem (unitnum);
957 return v;
958}
959
960/* read one cd sector */
961int sys_command_cd_read (int unitnum, uae_u8 *data, int block, int size)

Callers 6

get_cdrom_tocFunction · 0.85
dev_do_io_cdFunction · 0.85
gettocFunction · 0.85
scsi_cd_emulateFunction · 0.85
get_tocFunction · 0.85
get_tocFunction · 0.85

Calls 4

failunitFunction · 0.85
getsemFunction · 0.85
do_scsiFunction · 0.85
freesemFunction · 0.85

Tested by

no test coverage detected