annotate cue.c @ 2089:0db3af42dd72

Fix some byte order stuff for audio tracks
author Michael Pavone <pavone@retrodev.com>
date Sun, 06 Feb 2022 13:51:49 -0800
parents bafb757e1cd2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2059
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include <ctype.h>
2074
c5323c02dde4 Fix windows build error
Michael Pavone <pavone@retrodev.com>
parents: 2062
diff changeset
2 #include <string.h>
2059
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 #include "system.h"
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 #include "util.h"
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 static char* cmd_start(char *cur)
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 while (*cur && isblank(*cur))
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 cur++;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 return cur;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 static char* next_line(char *cur)
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 while (*cur && *cur != '\n')
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 cur++;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 if (*cur) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 return cur + 1;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 return NULL;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 static uint32_t timecode_to_lba(char *timecode)
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29 {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 char *end;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 int seconds = 0, frames = 0;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 int minutes = strtol(timecode, &end, 10);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33 if (end) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 timecode = end + 1;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35 seconds = strtol(timecode, &end, 10);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
36 if (end) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 timecode = end + 1;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38 frames = strtol(timecode, NULL, 10);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
40 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41 seconds += minutes * 60;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
42 return seconds * 75 + frames;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45
2080
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
46 enum {
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
47 FAKE_DATA = 1,
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
48 FAKE_AUDIO,
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
49 };
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
50
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
51 static uint8_t bin_seek(system_media *media, uint32_t sector)
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
52 {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
53 media->cur_sector = sector;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
54 uint32_t lba = sector;
2089
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
55 uint32_t track;
2080
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
56 for (track = 0; track < media->num_tracks; track++)
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
57 {
2080
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
58 if (lba < media->tracks[track].fake_pregap) {
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
59 media->in_fake_pregap = media->tracks[track].type == TRACK_DATA ? FAKE_DATA : FAKE_AUDIO;
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
60 break;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
61 }
2080
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
62 lba -= media->tracks[track].fake_pregap;
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
63 if (lba < media->tracks[track].start_lba) {
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
64 media->in_fake_pregap = media->tracks[track].type == TRACK_DATA ? FAKE_DATA : FAKE_AUDIO;
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
65 break;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
66 }
2080
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
67 if (lba < media->tracks[track].end_lba) {
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
68 media->in_fake_pregap = 0;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
69 break;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
70 }
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
71 }
2089
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
72 if (track < media->num_tracks) {
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
73 media->cur_track = track;
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
74 }
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
75 if (!media->in_fake_pregap) {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
76 fseek(media->f, lba * 2352, SEEK_SET);
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
77 }
2080
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
78 return track;
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
79 }
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
80
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
81 static uint8_t fake_read(uint32_t sector, uint32_t offset)
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
82 {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
83 if (!offset || (offset >= 16)) {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
84 return 0;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
85 //TODO: error detection and correction bytes
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
86 } else if (offset < 12) {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
87 return 0xFF;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
88 } else if (offset == 12) {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
89 uint32_t minute = (sector / 75) / 60;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
90 return (minute % 10) | ((minute / 10 ) << 4);
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
91 } else if (offset == 13) {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
92 uint32_t seconds = (sector / 75) % 60;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
93 return (seconds % 10) | ((seconds / 10 ) << 4);
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
94 } else if (offset == 14) {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
95 uint32_t frames = sector % 75;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
96 return (frames % 10) | ((frames / 10 ) << 4);
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
97 } else {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
98 return 1;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
99 }
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
100 }
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
101
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
102 static uint8_t bin_read(system_media *media, uint32_t offset)
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
103 {
2080
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
104 if (media->in_fake_pregap == FAKE_DATA) {
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
105 return fake_read(media->cur_sector, offset);
2080
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
106 } else if (media->in_fake_pregap == FAKE_AUDIO) {
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
107 return 0;
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
108 } else {
2089
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
109 if (media->tracks[media->cur_track].need_swap) {
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
110 if (offset & 1) {
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
111 return media->byte_storage;
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
112 }
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
113 media->byte_storage = fgetc(media->f);
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
114 }
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
115 return fgetc(media->f);
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
116 }
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
117 }
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
118
2080
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
119 static uint8_t iso_seek(system_media *media, uint32_t sector)
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
120 {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
121 media->cur_sector = sector;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
122 if (sector < (2 * 75)) {
2080
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
123 media->in_fake_pregap = FAKE_DATA;
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
124 } else {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
125 media->in_fake_pregap = 0;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
126 fseek(media->f, (sector - 2 * 75) * 2048, SEEK_SET);
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
127 }
2080
bafb757e1cd2 Implement CD audio
Michael Pavone <pavone@retrodev.com>
parents: 2079
diff changeset
128 return 0;
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
129 }
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
130
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
131 static uint8_t iso_read(system_media *media, uint32_t offset)
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
132 {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
133 if (media->in_fake_pregap || offset < 16 || offset > (2048 + 16)) {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
134 return fake_read(media->cur_sector, offset);
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
135 } else {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
136 return fgetc(media->f);
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
137 }
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
138 }
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
139
2059
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
140 uint8_t parse_cue(system_media *media)
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
141 {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
142 char *line = media->buffer;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
143 media->num_tracks = 0;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
144 do {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
145 char *cmd = cmd_start(line);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
146 if (cmd) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
147 if (startswith(cmd, "TRACK ")) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
148 media->num_tracks++;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
149 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
150 line = next_line(cmd);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
151 } else {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
152 line = NULL;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
153 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
154 } while (line);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
155 track_info *tracks = calloc(sizeof(track_info), media->num_tracks);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
156 media->tracks = tracks;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
157 line = media->buffer;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
158 int track = -1;
2089
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
159 uint8_t audio_byte_swap = 0;
2059
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
160 do {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
161 char *cmd = cmd_start(line);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
162 if (cmd) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
163 if (startswith(cmd, "TRACK ")) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
164 track++;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
165 cmd += 6;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
166 char *end;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
167 int file_track = strtol(cmd, &end, 10);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
168 if (file_track != (track + 1)) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
169 warning("Expected track %d, but found track %d in CUE sheet\n", track + 1, file_track);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
170 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
171 cmd = cmd_start(end);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
172 if (cmd) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
173 tracks[track].type = startswith(cmd, "AUDIO") ? TRACK_AUDIO : TRACK_DATA;
2089
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
174 tracks[track].need_swap = tracks[track].type == TRACK_AUDIO && audio_byte_swap;
2059
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
175 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
176 } else if (startswith(cmd, "FILE ")) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
177 if (media->f) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
178 warning("CUE sheets with multiple FILE commands are not supported\n");
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
179 } else {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
180 cmd += 5;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
181 cmd = strchr(cmd, '"');
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
182 if (cmd) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
183 cmd++;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
184 char *end = strchr(cmd, '"');
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
185 if (end) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
186 char *fname;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
187 //TODO: zipped BIN/CUE support
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
188 if (is_absolute_path(cmd)) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
189 fname = malloc(end-cmd + 1);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
190 memcpy(fname, cmd, end-cmd);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
191 fname[end-cmd] = 0;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
192 } else {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
193 size_t dirlen = strlen(media->dir);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
194 fname = malloc(dirlen + 1 + (end-cmd) + 1);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
195 memcpy(fname, media->dir, dirlen);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
196 fname[dirlen] = PATH_SEP[0];
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
197 memcpy(fname + dirlen + 1, cmd, end-cmd);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
198 fname[dirlen + 1 + (end-cmd)] = 0;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
199 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
200 media->f = fopen(fname, "rb");
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
201 if (!media->f) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
202 fatal_error("Failed to open %s specified by FILE command in CUE sheet %s.%s\n", fname, media->name, media->extension);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
203 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
204 free(fname);
2089
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
205 for (end++; *end && *end != '\n' && *end != '\r'; end++)
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
206 {
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
207 if (!isspace(*end)) {
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
208 if (startswith(end, "BINARY")) {
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
209 audio_byte_swap = 0;
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
210 } else if (startswith(end, "MOTOROLA")) {
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
211 audio_byte_swap = 1;
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
212 } else {
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
213 warning("Unsupported FILE type in CUE sheet. Only BINARY and MOTOROLA are supported\n");
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
214 }
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
215 break;
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
216 }
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
217 }
2059
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
218 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
219 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
220 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
221 } else if (track >= 0) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
222 if (startswith(cmd, "PREGAP ")) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
223 tracks[track].fake_pregap = timecode_to_lba(cmd + 7);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
224 } else if (startswith(cmd, "INDEX ")) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
225 char *after;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
226 int index = strtol(cmd + 6, &after, 10);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
227 if (!index) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
228 tracks[track].pregap_lba = timecode_to_lba(after);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
229 } else if (index == 1) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
230 tracks[track].start_lba = timecode_to_lba(after);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
231 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
232 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
233 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
234 if (cmd) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
235 line = next_line(cmd);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
236 } else {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
237 line = NULL;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
238 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
239 } else {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
240 line = NULL;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
241 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
242 } while (line);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
243 for (uint32_t i = 0; i < (media->num_tracks - 1); i++)
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
244 {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
245 uint32_t next = i + 1;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
246 tracks[i].end_lba = tracks[next].pregap_lba ? tracks[next].pregap_lba : tracks[next].start_lba;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
247 }
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
248 if (media->f) {
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
249 //end of last track is implicitly defined by file size
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
250 tracks[media->num_tracks-1].end_lba = file_size(media->f) / 2352;
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
251 //replace cue sheet with first sector
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
252 free(media->buffer);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
253 media->buffer = calloc(2048, 1);
2089
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
254 if (tracks[0].type == TRACK_DATA) {
2062
07ed42bd7b4c Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents: 2061
diff changeset
255 // if the first track is a data track, don't trust the CUE sheet and look at the MM:SS:FF from first sector
07ed42bd7b4c Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents: 2061
diff changeset
256 uint8_t msf[3];
07ed42bd7b4c Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents: 2061
diff changeset
257 fseek(media->f, 12, SEEK_SET);
07ed42bd7b4c Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents: 2061
diff changeset
258 if (sizeof(msf) == fread(msf, 1, sizeof(msf), media->f)) {
07ed42bd7b4c Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents: 2061
diff changeset
259 tracks[0].fake_pregap = msf[2] + (msf[0] * 60 + msf[1]) * 75;
07ed42bd7b4c Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents: 2061
diff changeset
260 }
2089
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
261 } else if (!tracks[0].start_lba && !tracks[0].fake_pregap) {
0db3af42dd72 Fix some byte order stuff for audio tracks
Michael Pavone <pavone@retrodev.com>
parents: 2080
diff changeset
262 tracks[0].fake_pregap = 2 * 75;
2062
07ed42bd7b4c Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents: 2061
diff changeset
263 }
07ed42bd7b4c Some progress on CDC and CDD emulation. Now passes first 3 "CDC INIT" tests in mcd-verificator
Michael Pavone <pavone@retrodev.com>
parents: 2061
diff changeset
264
2059
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
265 fseek(media->f, 16, SEEK_SET);
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
266 media->size = fread(media->buffer, 1, 2048, media->f);
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
267 media->seek = bin_seek;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
268 media->read = bin_read;
2059
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
269 }
2061
7c1760b5b3e5 Implemented basic TOC functionality of CDD MCU
Michael Pavone <pavone@retrodev.com>
parents: 2059
diff changeset
270 uint8_t valid = tracks > 0 && media->f != NULL;
7c1760b5b3e5 Implemented basic TOC functionality of CDD MCU
Michael Pavone <pavone@retrodev.com>
parents: 2059
diff changeset
271 media->type = valid ? MEDIA_CDROM : MEDIA_CART;
7c1760b5b3e5 Implemented basic TOC functionality of CDD MCU
Michael Pavone <pavone@retrodev.com>
parents: 2059
diff changeset
272 return valid;
2059
6399a776e981 Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
273 }
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
274
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
275 uint32_t make_iso_media(system_media *media, const char *filename)
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
276 {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
277 media->f = fopen(filename, "rb");
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
278 if (!media->f) {
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
279 return 0;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
280 }
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
281 media->buffer = calloc(2048, 1);
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
282 media->size = fread(media->buffer, 1, 2048, media->f);
2079
5a2b759f6b2d BIOS doesn't like it if TOC read happens too quickly
Michael Pavone <pavone@retrodev.com>
parents: 2076
diff changeset
283 media->num_tracks = 1;
5a2b759f6b2d BIOS doesn't like it if TOC read happens too quickly
Michael Pavone <pavone@retrodev.com>
parents: 2076
diff changeset
284 media->tracks = calloc(sizeof(track_info), 1);
2076
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
285 media->tracks[0] = (track_info){
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
286 .fake_pregap = 2 * 75,
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
287 .start_lba = 0,
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
288 .end_lba = file_size(media->f),
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
289 .type = TRACK_DATA
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
290 };
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
291 media->type = MEDIA_CDROM;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
292 media->seek = iso_seek;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
293 media->read = iso_read;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
294 return media->size;
3f29e2726522 Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents: 2074
diff changeset
295 }