]> Shamusworld >> Repos - virtualjaguar/blob - src/cdintf.cpp
Initial refactoring of CD interface backend code.
[virtualjaguar] / src / cdintf.cpp
1 //
2 // OS agnostic CDROM interface functions
3 //
4 // by James L. Hammons
5 //
6 // This file is basically a shell to keep the front-end clean and also pull in the
7 // appropriate back-end code depending on which target is being compiled for.
8 //
9
10 #include "cdintf.h"                                                             // Every OS has to implement these
11
12 #include <cdio/cdio.h>                                                  // Now using OS agnostic CD access routines!
13 #include "log.h"
14
15 // Not any more!
16 #if 0
17
18 // OS dependent implementations
19
20 #if defined(__GCCWIN32__)
21
22 #include "cdintf_win32.cpp"
23
24 #elif defined(__GCCUNIX__)
25         #if defined(_OSX_)
26
27 #include "cdintf_osx.cpp"
28
29         #else
30
31 #include "cdintf_linux.cpp"
32
33         #endif
34 #endif
35
36 #endif
37
38 /*
39 static void TestCDIO(void)
40 {
41         // See what (if anything) is installed.
42         CdIo_t * p_cdio = cdio_open(0, DRIVER_DEVICE);
43         driver_id_t driver_id;
44
45         if (p_cdio != NULL)
46         {
47                 WriteLog("CDIO: The driver selected is %s.\n", cdio_get_driver_name(p_cdio));
48                 WriteLog("CDIO: The default device for this driver is %s.\n\n", cdio_get_default_device(p_cdio));
49                 cdio_destroy(p_cdio);
50         }
51         else
52         {
53                 WriteLog("CDIO: A suitable CD-ROM driver was not found.\n\n");
54         }
55 }
56 */
57
58 //
59 // *** OK, here's where we're going to attempt to put the platform agnostic CD interface ***
60 //
61
62 static CdIo_t * cdioPtr = NULL;
63
64 bool CDIntfInit(void)
65 {
66         cdioPtr = cdio_open(NULL, DRIVER_DEVICE);
67
68         if (cdioPtr == NULL)
69         {
70                 WriteLog("CDINTF: No suitable CD-ROM driver found.\n");
71                 return false;
72         }
73
74         return true;
75 }
76
77 void CDIntfDone(void)
78 {
79         WriteLog("CDINTF: Shutting down CD-ROM subsystem.\n");
80
81         if (cdioPtr)
82                 cdio_destroy(cdioPtr);
83 }
84
85 bool CDIntfReadBlock(uint32 sector, uint8 * buffer)
86 {
87         // !!! FIX !!!
88         WriteLog("CDINTF: ReadBlock unimplemented!\n");
89         return false;
90 }
91
92 uint32 CDIntfGetNumSessions(void)
93 {
94         // !!! FIX !!!
95         // Still need relevant code here... !!! FIX !!!
96         return 2;
97 }
98
99 void CDIntfSelectDrive(uint32 driveNum)
100 {
101         // !!! FIX !!!
102         WriteLog("CDINTF: SelectDrive unimplemented!\n");
103 }
104
105 uint32 CDIntfGetCurrentDrive(void)
106 {
107         // !!! FIX !!!
108         WriteLog("CDINTF: GetCurrentDrive unimplemented!\n");
109         return 0;
110 }
111
112 const uint8 * CDIntfGetDriveName(uint32 driveNum)
113 {
114         // driveNum is currently ignored... !!! FIX !!!
115
116         uint8 * driveName = (uint8 *)cdio_get_default_device(cdioPtr);
117         WriteLog("CDINTF: The drive name for the current driver is %s.\n", driveName);
118
119         return driveName;
120 }
121
122 uint8 CDIntfGetSessionInfo(uint32 session, uint32 offset)
123 {
124         // !!! FIX !!!
125         WriteLog("CDINTF: GetSessionInfo unimplemented!\n");
126         return 0xFF;
127 }
128
129 uint8 CDIntfGetTrackInfo(uint32 track, uint32 offset)
130 {
131         // !!! FIX !!!
132         WriteLog("CDINTF: GetTrackInfo unimplemented!\n");
133         return 0xFF;
134 }