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

Function command_toc

src/blkdev_cdimage.cpp:1282–1341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1280}
1281
1282static int command_toc (int unitnum, struct cd_toc_head *th)
1283{
1284 struct cdunit *cdu = unitisopen (unitnum);
1285 if (!cdu)
1286 return 0;
1287
1288 int i;
1289
1290 memset (&cdu->di.toc, 0, sizeof (struct cd_toc_head));
1291 if (!cdu->tracks)
1292 return 0;
1293
1294 memset (th, 0, sizeof (struct cd_toc_head));
1295 struct cd_toc *toc = &th->toc[0];
1296 th->first_track = 1;
1297 th->last_track = cdu->tracks;
1298 th->points = cdu->tracks + 3;
1299 th->tracks = cdu->tracks;
1300 th->firstaddress = 0;
1301 th->lastaddress = cdu->toc[cdu->tracks].address;
1302
1303 uae_u8 ctrl_mask = 4;
1304 for (int i = 0; i < cdu->tracks; i++) {
1305 if (!(cdu->toc[i].ctrl & 4))
1306 ctrl_mask = 0x00;
1307 }
1308
1309 toc->adr = 1;
1310 toc->control = ctrl_mask;
1311 toc->point = 0xa0;
1312 toc->track = th->first_track;
1313 toc++;
1314
1315 th->first_track_offset = 1;
1316 for (i = 0; i < cdu->tracks; i++) {
1317 toc->adr = cdu->toc[i].adr;
1318 toc->control = cdu->toc[i].ctrl;
1319 toc->track = i + 1;
1320 toc->point = i + 1;
1321 toc->paddress = cdu->toc[i].address;
1322 toc++;
1323 }
1324
1325 th->last_track_offset = cdu->tracks;
1326 toc->adr = 1;
1327 toc->control = ctrl_mask;
1328 toc->point = 0xa1;
1329 toc->track = th->last_track;
1330 toc->paddress = th->lastaddress;
1331 toc++;
1332
1333 toc->adr = 1;
1334 toc->control = ctrl_mask;
1335 toc->point = 0xa2;
1336 toc->paddress = th->lastaddress;
1337 toc++;
1338
1339 memcpy (&cdu->di.toc, th, sizeof (struct cd_toc_head));

Callers 1

info_deviceFunction · 0.85

Calls 1

unitisopenFunction · 0.70

Tested by

no test coverage detected