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