Commit | Line | Data |
---|---|---|
cf76e892 JPM |
1 | // |
2 | // OS agnostic CDROM interface functions | |
3 | // | |
4 | // by James Hammons | |
5 | // (C) 2010 Underground Software | |
6 | // | |
7 | // JLH = James Hammons <jlhamm@acm.org> | |
8 | // JPM = Jean-Paul Mari <djipi.mari@gmail.com> | |
9 | // | |
10 | // Who When What | |
11 | // --- ---------- ------------------------------------------------------------ | |
12 | // JLH 01/16/2010 Created this log ;-) | |
13 | // JPM 06/15/2016 Visual Studio support | |
14 | // | |
15 | ||
16 | // | |
17 | // This now uses the supposedly cross-platform libcdio to do the necessary | |
18 | // low-level CD twiddling we need that libsdl can't do currently. Jury is | |
19 | // still out on whether or not to make this a conditional compilation or not. | |
20 | // | |
21 | ||
22 | // Comment this out if you don't have libcdio installed | |
23 | // (Actually, this is defined in the Makefile to prevent having to edit | |
24 | // things too damn much. Jury is still out whether or not to make this | |
25 | // change permanent.) | |
26 | //#define HAVE_LIB_CDIO | |
27 | ||
28 | #include "cdintf.h" // Every OS has to implement these | |
29 | ||
30 | #ifdef HAVE_LIB_CDIO | |
31 | #include <cdio/cdio.h> // Now using OS agnostic CD access routines! | |
32 | #endif | |
33 | #include "log.h" | |
34 | ||
35 | ||
36 | /* | |
37 | static void TestCDIO(void) | |
38 | { | |
39 | // See what (if anything) is installed. | |
40 | CdIo_t * p_cdio = cdio_open(0, DRIVER_DEVICE); | |
41 | driver_id_t driver_id; | |
42 | ||
43 | if (p_cdio != NULL) | |
44 | { | |
45 | WriteLog("CDIO: The driver selected is %s.\n", cdio_get_driver_name(p_cdio)); | |
46 | WriteLog("CDIO: The default device for this driver is %s.\n\n", cdio_get_default_device(p_cdio)); | |
47 | cdio_destroy(p_cdio); | |
48 | } | |
49 | else | |
50 | { | |
51 | WriteLog("CDIO: A suitable CD-ROM driver was not found.\n\n"); | |
52 | } | |
53 | } | |
54 | */ | |
55 | ||
56 | // | |
57 | // *** OK, here's where we're going to attempt to put the platform agnostic CD interface *** | |
58 | // | |
59 | ||
60 | #ifdef HAVE_LIB_CDIO | |
61 | static CdIo_t * cdioPtr = NULL; | |
62 | #endif | |
63 | ||
64 | ||
65 | bool CDIntfInit(void) | |
66 | { | |
67 | #ifdef HAVE_LIB_CDIO | |
68 | cdioPtr = cdio_open(NULL, DRIVER_DEVICE); | |
69 | ||
70 | if (cdioPtr == NULL) | |
71 | { | |
72 | #endif | |
73 | WriteLog("CDINTF: No suitable CD-ROM driver found.\n"); | |
74 | return false; | |
75 | #ifdef HAVE_LIB_CDIO | |
76 | } | |
77 | ||
78 | WriteLog("CDINTF: Successfully opened CD-ROM interface.\n"); | |
79 | ||
80 | return true; | |
81 | #endif | |
82 | } | |
83 | ||
84 | ||
85 | void CDIntfDone(void) | |
86 | { | |
87 | WriteLog("CDINTF: Shutting down CD-ROM subsystem.\n"); | |
88 | ||
89 | #ifdef HAVE_LIB_CDIO | |
90 | if (cdioPtr) | |
91 | cdio_destroy(cdioPtr); | |
92 | #endif | |
93 | } | |
94 | ||
95 | ||
96 | bool CDIntfReadBlock(uint32_t sector, uint8_t * buffer) | |
97 | { | |
98 | #ifdef _MSC_VER | |
99 | #pragma message("Warning: !!! FIX !!! CDIntfReadBlock not implemented!") | |
100 | #else | |
101 | #warning "!!! FIX !!! CDIntfReadBlock not implemented!" | |
102 | #endif // _MSC_VER | |
103 | // !!! FIX !!! | |
104 | WriteLog("CDINTF: ReadBlock unimplemented!\n"); | |
105 | return false; | |
106 | } | |
107 | ||
108 | ||
109 | uint32_t CDIntfGetNumSessions(void) | |
110 | { | |
111 | #ifdef _MSC_VER | |
112 | #pragma message("Warning: !!! FIX !!! CDIntfGetNumSessions not implemented!") | |
113 | #else | |
114 | #warning "!!! FIX !!! CDIntfGetNumSessions not implemented!" | |
115 | #endif // _MSC_VER | |
116 | // !!! FIX !!! | |
117 | // Still need relevant code here... !!! FIX !!! | |
118 | return 2; | |
119 | } | |
120 | ||
121 | ||
122 | void CDIntfSelectDrive(uint32_t driveNum) | |
123 | { | |
124 | #ifdef _MSC_VER | |
125 | #pragma message("Warning: !!! FIX !!! CDIntfSelectDrive not implemented!") | |
126 | #else | |
127 | #warning "!!! FIX !!! CDIntfSelectDrive not implemented!" | |
128 | #endif // _MSC_VER | |
129 | // !!! FIX !!! | |
130 | WriteLog("CDINTF: SelectDrive unimplemented!\n"); | |
131 | } | |
132 | ||
133 | ||
134 | uint32_t CDIntfGetCurrentDrive(void) | |
135 | { | |
136 | #ifdef _MSC_VER | |
137 | #pragma message("Warning: !!! FIX !!! CDIntfGetCurrentDrive not implemented!") | |
138 | #else | |
139 | #warning "!!! FIX !!! CDIntfGetCurrentDrive not implemented!" | |
140 | #endif // _MSC_VER | |
141 | // !!! FIX !!! | |
142 | WriteLog("CDINTF: GetCurrentDrive unimplemented!\n"); | |
143 | return 0; | |
144 | } | |
145 | ||
146 | ||
147 | const uint8_t * CDIntfGetDriveName(uint32_t driveNum) | |
148 | { | |
149 | #ifdef _MSC_VER | |
150 | #pragma message("Warning: !!! FIX !!! CDIntfGetDriveName driveNum is currently ignored!") | |
151 | #else | |
152 | #warning "!!! FIX !!! CDIntfGetDriveName driveNum is currently ignored!" | |
153 | #endif // _MSC_VER | |
154 | // driveNum is currently ignored... !!! FIX !!! | |
155 | ||
156 | #ifdef HAVE_LIB_CDIO | |
157 | uint8_t * driveName = (uint8_t *)cdio_get_default_device(cdioPtr); | |
158 | WriteLog("CDINTF: The drive name for the current driver is %s.\n", driveName); | |
159 | ||
160 | return driveName; | |
161 | #else | |
162 | return (uint8_t *)"NONE"; | |
163 | #endif | |
164 | } | |
165 | ||
166 | ||
167 | uint8_t CDIntfGetSessionInfo(uint32_t session, uint32_t offset) | |
168 | { | |
169 | #ifdef _MSC_VER | |
170 | #pragma message("Warning: !!! FIX !!! CDIntfGetSessionInfo not implemented!") | |
171 | #else | |
172 | #warning "!!! FIX !!! CDIntfGetSessionInfo not implemented!" | |
173 | #endif // _MSC_VER | |
174 | // !!! FIX !!! | |
175 | WriteLog("CDINTF: GetSessionInfo unimplemented!\n"); | |
176 | return 0xFF; | |
177 | } | |
178 | ||
179 | ||
180 | uint8_t CDIntfGetTrackInfo(uint32_t track, uint32_t offset) | |
181 | { | |
182 | #ifdef _MSC_VER | |
183 | #pragma message("Warning: !!! FIX !!! CDIntfTrackInfo not implemented!") | |
184 | #else | |
185 | #warning "!!! FIX !!! CDIntfTrackInfo not implemented!" | |
186 | #endif // _MSC_VER | |
187 | // !!! FIX !!! | |
188 | WriteLog("CDINTF: GetTrackInfo unimplemented!\n"); | |
189 | return 0xFF; | |
190 | } | |
191 |