src/lib/util/chdcd.c
| r14536 | r14537 | |
| 140 | 140 | length in bytes of the data and the offset in |
| 141 | 141 | bytes to where the data starts in the file. |
| 142 | 142 | -------------------------------------------------*/ |
| 143 | | static UINT32 parse_wav_sample(char *filename, UINT32 *dataoffs) |
| 143 | static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs) |
| 144 | 144 | { |
| 145 | 145 | unsigned long offset = 0; |
| 146 | 146 | UINT32 length, rate, filesize; |
| r14536 | r14537 | |
| 387 | 387 | index1 = read_uint64(infile); |
| 388 | 388 | index2 = read_uint64(infile); |
| 389 | 389 | |
| 390 | | //printf("Track %d: sector size %d mode %x index0 %llx index1 %llx index2 %llx (pregap %d sectors, length %d sectors)\n", track, size, mode, index0, index1, index2, (UINT32)(index1-index0)/size, (UINT32)(index2-index1)/size); |
| 391 | | // outinfo.track[track-1].fname.cpy(path.cstr()).cat(tocfname); |
| 392 | | strncpy(outinfo.track[track-1].fname, path.cstr(), 256); |
| 393 | | strncat(outinfo.track[track-1].fname, tocfname, 256); |
| 390 | // printf("Track %d: sector size %d mode %x index0 %llx index1 %llx index2 %llx (pregap %d sectors, length %d sectors)\n", track, size, mode, index0, index1, index2, (UINT32)(index1-index0)/size, (UINT32)(index2-index1)/size); |
| 391 | outinfo.track[track-1].fname.cpy(path).cat(tocfname); |
| 394 | 392 | outinfo.track[track-1].offset = offset + (UINT32)(index1-index0); |
| 395 | 393 | outinfo.track[track-1].idx0offs = 0; |
| 396 | 394 | outinfo.track[track-1].idx1offs = 0; |
| r14536 | r14537 | |
| 540 | 538 | } while(tok!=NULL && (strrchr(tok,'"')-tok !=(strlen(tok)-1))); |
| 541 | 539 | name = name.delchr('"'); |
| 542 | 540 | } |
| 543 | | strncpy(outinfo.track[trknum].fname, path.cstr(), 256); |
| 544 | | strncat(outinfo.track[trknum].fname, name, 256); |
| 541 | outinfo.track[trknum].fname.cpy(path).cat(name); |
| 545 | 542 | |
| 546 | 543 | sz=get_file_size(outinfo.track[trknum].fname); |
| 547 | 544 | |
| r14536 | r14537 | |
| 590 | 587 | FILE *infile; |
| 591 | 588 | int i, trknum; |
| 592 | 589 | static char token[512]; |
| 593 | | static char lastfname[256]; |
| 590 | astring lastfname; |
| 594 | 591 | UINT32 wavlen, wavoffs; |
| 595 | 592 | astring path = astring(tocfname); |
| 596 | 593 | |
| r14536 | r14537 | |
| 626 | 623 | TOKENIZE |
| 627 | 624 | |
| 628 | 625 | /* keep the filename */ |
| 629 | | strncpy(lastfname, path.cstr(), 256); |
| 630 | | strncat(lastfname, token, 256); |
| 626 | lastfname.cpy(path).cat(token); |
| 631 | 627 | |
| 632 | 628 | /* get the file type */ |
| 633 | 629 | TOKENIZE |
| r14536 | r14537 | |
| 652 | 648 | if (err != FILERR_NONE) printf("holy moley!\n"); |
| 653 | 649 | else core_fclose(fhand); |
| 654 | 650 | |
| 655 | | printf("ERROR: couldn't read [%s] or not a valid .WAV\n", lastfname); |
| 651 | printf("ERROR: couldn't read [%s] or not a valid .WAV\n", lastfname.cstr()); |
| 656 | 652 | return CHDERR_FILE_NOT_FOUND; |
| 657 | 653 | } |
| 658 | 654 | } |
| r14536 | r14537 | |
| 690 | 686 | outinfo.track[trknum].idx0offs = -1; |
| 691 | 687 | outinfo.track[trknum].idx1offs = 0; |
| 692 | 688 | |
| 693 | | strncpy(outinfo.track[trknum].fname, lastfname, 256); // default filename to the last one |
| 689 | outinfo.track[trknum].fname.cpy(lastfname); // default filename to the last one |
| 694 | 690 | |
| 695 | 691 | // printf("trk %d: fname %s offset %d\n", trknum, outinfo.track[trknum].fname.cstr(), outinfo.track[trknum].offset); |
| 696 | 692 | |
| r14536 | r14537 | |
| 778 | 774 | if (trknum == (outtoc.numtrks-1)) |
| 779 | 775 | { |
| 780 | 776 | /* if we have the same filename as the last track, do it that way */ |
| 781 | | if (outinfo.track[trknum].fname == outinfo.track[trknum-1].fname) |
| 777 | if (trknum != 0 && outinfo.track[trknum].fname == outinfo.track[trknum-1].fname) |
| 782 | 778 | { |
| 783 | | tlen = get_file_size(outinfo.track[trknum].fname); |
| 779 | tlen = get_file_size(outinfo.track[trknum].fname.cstr()); |
| 784 | 780 | if (tlen == 0) |
| 785 | 781 | { |
| 786 | | printf("ERROR: couldn't find bin file [%s]\n", outinfo.track[trknum-1].fname); |
| 782 | printf("ERROR: couldn't find bin file [%s]\n", outinfo.track[trknum-1].fname.cstr()); |
| 787 | 783 | return CHDERR_FILE_NOT_FOUND; |
| 788 | 784 | } |
| 789 | 785 | outinfo.track[trknum].offset = outinfo.track[trknum-1].offset + outtoc.tracks[trknum-1].frames * (outtoc.tracks[trknum-1].datasize + outtoc.tracks[trknum-1].subsize); |
| r14536 | r14537 | |
| 794 | 790 | tlen = get_file_size(outinfo.track[trknum].fname); |
| 795 | 791 | if (tlen == 0) |
| 796 | 792 | { |
| 797 | | printf("ERROR: couldn't find bin file [%s]\n", outinfo.track[trknum-1].fname); |
| 793 | printf("ERROR: couldn't find bin file [%s]\n", outinfo.track[trknum-1].fname.cstr()); |
| 798 | 794 | return CHDERR_FILE_NOT_FOUND; |
| 799 | 795 | } |
| 800 | 796 | tlen /= (outtoc.tracks[trknum].datasize + outtoc.tracks[trknum].subsize); |
| r14536 | r14537 | |
| 829 | 825 | tlen = get_file_size(outinfo.track[trknum].fname); |
| 830 | 826 | if (tlen == 0) |
| 831 | 827 | { |
| 832 | | printf("ERROR: couldn't find bin file [%s]\n", outinfo.track[trknum].fname); |
| 828 | printf("ERROR: couldn't find bin file [%s]\n", outinfo.track[trknum].fname.cstr()); |
| 833 | 829 | return CHDERR_FILE_NOT_FOUND; |
| 834 | 830 | } |
| 835 | 831 | tlen /= (outtoc.tracks[trknum].datasize + outtoc.tracks[trknum].subsize); |
| r14536 | r14537 | |
| 912 | 908 | TOKENIZE |
| 913 | 909 | |
| 914 | 910 | /* keep the filename */ |
| 915 | | strncpy(outinfo.track[trknum].fname, path.cstr(), 256); |
| 916 | | strncat(outinfo.track[trknum].fname, token, 256); |
| 911 | outinfo.track[trknum].fname.cpy(path).cat(token); |
| 917 | 912 | |
| 918 | 913 | /* get either the offset or the length */ |
| 919 | 914 | TOKENIZE |