// номер трека, первый сектор, количество секторов,тип диска,путь к файлу
int rip_sec(tn, first, nsec, type, dst_file){
int secbyte, istep ;
int nwritesec = 10 ;
uint8 secbuf[23520];
double result ;
double size_iso, write_iso;
int percent = 0;
int percentlast = 0;
int readi = 0 ;
if (type == 4) {
secbyte = 2048;
}
if (type != 4){
secbyte = 2352;
}
cdrom_set_sector_size (secbyte);
for (istep=0; istep <= nsec; istep += 10) {
if ( istep > nsec ) nwritesec = nsec % 10 ;
while (cdrom_read_sectors(CMD_DMAREAD,secbuf,first+istep,nwritesec) != ERR_OK){
readi++ ;
if (readi > 10 )
{
ds_printf("DS_ERROR: GD-ROM read error\n");
return CMD_ERROR;
}
ds_printf("GD-ROM read error. Attempt %d\n",readi);
}
readi = 0;
if (fwrite(secbuf,secbyte,nwritesec, dst_file) !=nwritesec){
ds_printf("DS_ERROR: Error write to file\n");
return CMD_ERROR;
}
if (istep != 0){
write_iso = (int) (istep*secbyte);
size_iso = (int) (nsec * secbyte);
if ((percent = (int) (write_iso * 100 / size_iso)) != percentlast) {
percentlast = percent;
result = istep*secbyte;
result = result/1024000;
result = ((int)(result*100 + 0.5))/100.0;
ds_printf("%d%% %4.2f MB\n",percent,result);
}
}
return CMD_OK;
}