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