comparison cdimage.c @ 2149:9209858b2f74

Fix a couple of bugs in the TOC file parser
author Michael Pavone <pavone@retrodev.com>
date Sat, 26 Mar 2022 23:05:08 -0700
parents 67f20f9188b0
children a8af8d898a7c
comparison
equal deleted inserted replaced
2148:2da377ea932f 2149:9209858b2f74
53 } 53 }
54 54
55 static uint32_t timecode_to_lba(char *timecode) 55 static uint32_t timecode_to_lba(char *timecode)
56 { 56 {
57 char *end; 57 char *end;
58 int seconds = 0, frames = 0; 58 int seconds = 0, minutes = 0;
59 int minutes = strtol(timecode, &end, 10); 59 int frames = strtol(timecode, &end, 10);
60 if (end) { 60 if (end && *end == ':') {
61 timecode = end + 1; 61 timecode = end + 1;
62 seconds = strtol(timecode, &end, 10); 62 seconds = frames;
63 if (end) { 63 frames = strtol(timecode, &end, 10);
64 if (end && *end == ':') {
65 minutes = seconds;
66 seconds = frames;
64 timecode = end + 1; 67 timecode = end + 1;
65 frames = strtol(timecode, NULL, 10); 68 frames = strtol(timecode, NULL, 10);
66 } 69 }
67 } 70 }
68 seconds += minutes * 60; 71 seconds += minutes * 60;
469 } 472 }
470 if (!is_datafile) { 473 if (!is_datafile) {
471 if (isdigit(*cmd)) { 474 if (isdigit(*cmd)) {
472 uint32_t start = timecode_to_lba(cmd); 475 uint32_t start = timecode_to_lba(cmd);
473 tracks[track].file_offset += start * tracks[track].sector_bytes; 476 tracks[track].file_offset += start * tracks[track].sector_bytes;
474 cmd = next_blank(cmd); 477 cmd = cmd_start_sameline(cmd);
475 } 478 }
476 } 479 }
477 if (isdigit(*cmd)) { 480 if (isdigit(*cmd)) {
478 uint32_t length = timecode_to_lba(cmd); 481 uint32_t length = timecode_to_lba(cmd);
479 tracks[track].end_lba += length; 482 tracks[track].end_lba += length;