2 // OS specific CDROM interface (linux)
4 // by James L. Hammons and Niels Wagenaar
6 // NOTE : This CD-ROM code *could* work with other UN*X related OS. However,
7 // we/I are not sure on this matter.
9 // This is very experimental and I have the feeling that this won't even compile.
10 // Hell, I don't even have a Linux dev system (broken) or Jaguar CD releases to
13 // Big thanks to the DOSBOX team which provided us with great knowlegde about
14 // CD-ROM access and Linux/UN*X.
17 // *** OS dependent CDROM stuffola ***
20 #include <linux/cdrom.h>
21 #include <sys/ioctl.h>
23 #include <sys/types.h>
25 // *** End OS dependent ***
29 // *** Virtual Jaguar dependent ***
30 //#include "SDL.h" // Yes, we use SDL for initializing the CD-ROM and
31 // // give us access to certain CD-ROM states. But not just yet.
33 // *** SDL CD-ROM dependent *** // Not yet needed!
34 // SDL_CD *cdrom; // Our variable for SDL CD-ROM access.
35 // CDstatus status; // Let us get our status.
38 // *** Local variables ***
39 char device_name[512] ; // Devicename, for example /dev/cdrom
42 // Linux support functions
43 // OS specific implementation of OS agnostic functions
48 // Setting device_name to /deb/cdrom. /dev/cdrom is the default CD-ROM
49 // drive on most UN*X systems. Well, I think it is.
51 // In the future we can probably use SDL for getting CDROM states and
52 // CD-ROM specific information.
53 strcpy(device_name, "/dev/cdrom");
55 // Let us open the device_name and check if we can open the CD-ROM.
56 int cdrom_fd = open(device_name, O_RDONLY | O_NONBLOCK);
60 // CD-ROM isn't accessable.
61 // Write the error in the log file and return false.
62 WriteLog("CDINTF: CDIntfInit - Unable to open CDROM!\n");
67 // CD-ROM is accessable.
68 // Write the success in the log file and return true.
69 WriteLog("CDINTF: CDIntfInit - Succesfully opened CDROM!\n");
78 // Just in case : closing device_name.
79 WriteLog("CDINTF: CDIntfDone - Closing CDROM!\n");
83 bool CDIntfReadBlock(uint32 sector, uint8 * buffer)
85 unsigned int buflen = CD_FRAMESIZE_RAW; // Raw read, 2352 bytes per sector
86 //unsigned char *buf = new unsigned int[buflen]; // DOSBOX, do we need this?
88 struct cdrom_read cdrom_read;
90 // Let us open the device_name and check if we can open the CD-ROM.
91 int cdrom_fd = open(device_name, O_RDONLY | O_NONBLOCK);
94 // CD-ROM isn't accessable.
95 // Write the error in the log file and return false.
96 WriteLog("CDINTF: CDIntfReadBlock - Unable to open CDROM!\n");
100 // Setting up the cdrom_read struct :
101 cdrom_read.cdread_lba = sector; // Which sector to read.
102 cdrom_read.cdread_bufaddr = (char*)buffer; // Where to put the data (?)
103 cdrom_read.cdread_buflen = buflen; // 2352 bytes/sector -> RAW read
105 // Let us read the content we want. -1 (false) when it didn't work.
106 ret = ioctl(cdrom_fd, CDROMREADRAW, &cdrom_read);
111 // The following was taken from DOSBOX. After reading the content, they write
112 // back the information from buf (based upon the size of buflen) to buffer.
113 // I think that this is not needed. *fingers crossed*
115 // MEM_BlockWrite(buffer, buf, buflen);
118 // Uncomment the following for debug reasons.
120 // WriteLog("CDINTF: CDIntfReadBlock - Reading sector %d!\n", sector);
126 uint32 CDIntfGetNumSessions(void)
128 // Still need relevant code here...
132 void CDIntfSelectDrive(uint32 driveNum)
134 WriteLog("CDINTF: SelectDrive unimplemented!\n");
137 uint32 CDIntfGetCurrentDrive(void)
139 WriteLog("CDINTF: GetCurrentDrive unimplemented!\n");
143 const uint8 * CDIntfGetDriveName(uint32)
145 WriteLog("CDINTF: GetDriveName unimplemented!\n");
149 uint8 CDIntfGetSessionInfo(uint32 session, uint32 offset)
151 WriteLog("CDINTF: GetSessionInfo unimplemented!\n");
155 uint8 CDIntfGetTrackInfo(uint32 track, uint32 offset)
157 WriteLog("CDINTF: GetTrackInfo unimplemented!\n");