]> Shamusworld >> Repos - virtualjaguar/blob - src/cdintf.cpp
45b6be2eac3aecfa510dfa2f05c1e10789be3653
[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 bool CDIntfInit(void)
63 {
64 #ifdef HAVE_LIB_CDIO
65         cdioPtr = cdio_open(NULL, DRIVER_DEVICE);
66
67         if (cdioPtr == NULL)
68         {
69 #endif
70                 WriteLog("CDINTF: No suitable CD-ROM driver found.\n");
71                 return false;
72 #ifdef HAVE_LIB_CDIO
73         }
74
75         WriteLog("CDINTF: Successfully opened CD-ROM interface.\n");
76
77         return true;
78 #endif
79 }
80
81 void CDIntfDone(void)
82 {
83         WriteLog("CDINTF: Shutting down CD-ROM subsystem.\n");
84
85 #ifdef HAVE_LIB_CDIO
86         if (cdioPtr)
87                 cdio_destroy(cdioPtr);
88 #endif
89 }
90
91 bool CDIntfReadBlock(uint32_t sector, uint8_t * buffer)
92 {
93 #warning "!!! FIX !!! CDIntfReadBlock not implemented!"
94         // !!! FIX !!!
95         WriteLog("CDINTF: ReadBlock unimplemented!\n");
96         return false;
97 }
98
99 uint32_t CDIntfGetNumSessions(void)
100 {
101 #warning "!!! FIX !!! CDIntfGetNumSessions not implemented!"
102         // !!! FIX !!!
103         // Still need relevant code here... !!! FIX !!!
104         return 2;
105 }
106
107 void CDIntfSelectDrive(uint32_t driveNum)
108 {
109 #warning "!!! FIX !!! CDIntfSelectDrive not implemented!"
110         // !!! FIX !!!
111         WriteLog("CDINTF: SelectDrive unimplemented!\n");
112 }
113
114 uint32_t CDIntfGetCurrentDrive(void)
115 {
116 #warning "!!! FIX !!! CDIntfGetCurrentDrive not implemented!"
117         // !!! FIX !!!
118         WriteLog("CDINTF: GetCurrentDrive unimplemented!\n");
119         return 0;
120 }
121
122 const uint8_t * CDIntfGetDriveName(uint32_t driveNum)
123 {
124 #warning "!!! FIX !!! CDIntfGetDriveName driveNum is currently ignored!"
125         // driveNum is currently ignored... !!! FIX !!!
126
127 #ifdef HAVE_LIB_CDIO
128         uint8_t * driveName = (uint8_t *)cdio_get_default_device(cdioPtr);
129         WriteLog("CDINTF: The drive name for the current driver is %s.\n", driveName);
130
131         return driveName;
132 #else
133         return (uint8_t *)"NONE";
134 #endif
135 }
136
137 uint8_t CDIntfGetSessionInfo(uint32_t session, uint32_t offset)
138 {
139 #warning "!!! FIX !!! CDIntfGetSessionInfo not implemented!"
140         // !!! FIX !!!
141         WriteLog("CDINTF: GetSessionInfo unimplemented!\n");
142         return 0xFF;
143 }
144
145 uint8_t CDIntfGetTrackInfo(uint32_t track, uint32_t offset)
146 {
147 #warning "!!! FIX !!! CDIntfTrackInfo not implemented!"
148         // !!! FIX !!!
149         WriteLog("CDINTF: GetTrackInfo unimplemented!\n");
150         return 0xFF;
151 }