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

Function parseccd

src/blkdev_cdimage.cpp:1661–1793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1659#endif
1660
1661static int parseccd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img, const TCHAR *curdir, const TCHAR *ocurdir)
1662{
1663 int mode;
1664 int num, tracknum, trackmode;
1665 int adr, control, lba;
1666 bool gotlba;
1667 struct cdtoc *t;
1668 struct zfile *zimg, *zsub;
1669 TCHAR fname[MAX_DPATH];
1670
1671 write_log (_T("CCD TOC: '%s'\n"), img);
1672 _tcscpy (fname, zfile_getname(zcue));
1673 TCHAR *ext = _tcsrchr (fname, '.');
1674 if (ext)
1675 *ext = 0;
1676 _tcscat (fname, _T(".img"));
1677 zimg = zfile_fopen (fname, _T("rb"), ZFD_NORMAL);
1678 if (!zimg) {
1679 write_log (_T("CCD: can't open '%s'\n"), fname);
1680 return 0;
1681 }
1682 ext = _tcsrchr (fname, '.');
1683 if (ext)
1684 *ext = 0;
1685 _tcscat (fname, _T(".sub"));
1686 zsub = zfile_fopen (fname, _T("rb"), ZFD_NORMAL);
1687 if (zsub)
1688 write_log (_T("CCD: '%s' detected\n"), fname);
1689
1690 if (curdir)
1691 my_setcurrentdir(ocurdir, NULL);
1692
1693 num = -1;
1694 mode = -1;
1695 for (;;) {
1696 TCHAR buf[MAX_DPATH], *p;
1697 if (!zfile_fgets (buf, sizeof buf / sizeof (TCHAR), zcue))
1698 break;
1699 p = buf;
1700 skipspace (&p);
1701 if (!_tcsnicmp (p, _T("[DISC]"), 6)) {
1702 mode = 1;
1703 } else if (!_tcsnicmp (p, _T("[ENTRY "), 7)) {
1704 t = NULL;
1705 mode = 2;
1706 num = readval (p + 7);
1707 if (num < 0)
1708 break;
1709 adr = control = -1;
1710 gotlba = false;
1711 } else if (!_tcsnicmp (p, _T("[TRACK "), 7)) {
1712 mode = 3;
1713 tracknum = readval (p + 7);
1714 trackmode = -1;
1715 if (tracknum <= 0 || tracknum > 99)
1716 break;
1717 t = &cdu->toc[tracknum - 1];
1718 }

Callers 1

parse_imageFunction · 0.85

Calls 9

zfile_getnameFunction · 0.85
zfile_fopenFunction · 0.85
my_setcurrentdirFunction · 0.85
zfile_fgetsFunction · 0.85
skipspaceFunction · 0.85
readvalFunction · 0.85
zfile_dupFunction · 0.85
zfile_fcloseFunction · 0.85
write_logFunction · 0.70

Tested by

no test coverage detected