Mercurial > sdl-ios-xcode
annotate src/cdrom/beos/SDL_syscdrom.cc @ 1439:4d3bb026cd16
Fixed warnings in -pedantic mode
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 26 Feb 2006 05:02:14 +0000 |
parents | 376665398b25 |
children | 3a8920cc822b |
rev | line source |
---|---|
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
13 Lesser General Public License for more details. |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
153
diff
changeset
|
20 slouken@libsdl.org |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
1403
376665398b25
Catch the C++ and Objective C sources too...
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 /* Functions for system-level CD-ROM audio control on BeOS |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 (not completely implemented yet) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #include <sys/types.h> |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include <sys/stat.h> |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #include <unistd.h> |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #include <scsi.h> |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 #include <Directory.h> |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #include <Entry.h> |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 #include <Path.h> |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 #include "SDL_cdrom.h" |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 extern "C" { |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
39 #include "../SDL_syscdrom.h" |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 /* Constants to help us get at the SCSI table-of-contents info */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 #define CD_NUMTRACKS(toc) toc.toc_data[3] |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 #define CD_TRACK(toc, track) (&toc.toc_data[6+(track)*8]) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 #define CD_TRACK_N(toc, track) CD_TRACK(toc, track)[0] |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 #define CD_TRACK_M(toc, track) CD_TRACK(toc, track)[3] |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 #define CD_TRACK_S(toc, track) CD_TRACK(toc, track)[4] |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 #define CD_TRACK_F(toc, track) CD_TRACK(toc, track)[5] |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 /* Constants to help us get at the SCSI position info */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 #define POS_TRACK(pos) pos.position[6] |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 #define POS_ABS_M(pos) pos.position[9] |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 #define POS_ABS_S(pos) pos.position[10] |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 #define POS_ABS_F(pos) pos.position[11] |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 #define POS_REL_M(pos) pos.position[13] |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 #define POS_REL_S(pos) pos.position[14] |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 #define POS_REL_F(pos) pos.position[15] |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 /* The maximum number of CD-ROM drives we'll detect */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 #define MAX_DRIVES 16 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 /* A list of available CD-ROM drives */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 static char *SDL_cdlist[MAX_DRIVES]; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 /* The system-dependent CD control functions */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 static const char *SDL_SYS_CDName(int drive); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 static int SDL_SYS_CDOpen(int drive); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 static int SDL_SYS_CDPause(SDL_CD *cdrom); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 static int SDL_SYS_CDResume(SDL_CD *cdrom); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 static int SDL_SYS_CDStop(SDL_CD *cdrom); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 static int SDL_SYS_CDEject(SDL_CD *cdrom); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 static void SDL_SYS_CDClose(SDL_CD *cdrom); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 int try_dir(const char *directory); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 /* Check a drive to see if it is a CD-ROM */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 static int CheckDrive(char *drive) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 struct stat stbuf; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 int is_cd, cdfd; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 device_geometry info; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 /* If it doesn't exist, return -1 */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 if ( stat(drive, &stbuf) < 0 ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 return(-1); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 /* If it does exist, verify that it's an available CD-ROM */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 is_cd = 0; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 cdfd = open(drive, 0); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 if ( cdfd >= 0 ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 if ( ioctl(cdfd, B_GET_GEOMETRY, &info) == B_NO_ERROR ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 if ( info.device_type == B_CD ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 is_cd = 1; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 close(cdfd); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 } else { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 /* This can happen when the drive is open .. (?) */; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 is_cd = 1; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 return(is_cd); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 /* Add a CD-ROM drive to our list of valid drives */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 static void AddDrive(char *drive) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 int i; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 if ( SDL_numcds < MAX_DRIVES ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 /* Add this drive to our list */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 i = SDL_numcds; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
116 SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 if ( SDL_cdlist[i] == NULL ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 SDL_OutOfMemory(); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 return; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
121 SDL_strcpy(SDL_cdlist[i], drive); |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 ++SDL_numcds; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 #ifdef CDROM_DEBUG |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 #endif |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 /* IDE bus scanning magic */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 enum { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 IDE_GET_DEVICES_INFO = B_DEVICE_OP_CODES_END + 50, |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 }; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 struct ide_ctrl_info { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 bool ide_0_present; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 bool ide_0_master_present; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 bool ide_0_slave_present; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 int ide_0_master_type; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 int ide_0_slave_type; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 bool ide_1_present; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 bool ide_1_master_present; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 bool ide_1_slave_present; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 int ide_1_master_type; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 int ide_1_slave_type; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 }; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 int SDL_SYS_CDInit(void) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 char *SDLcdrom; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 int raw_fd; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 struct ide_ctrl_info info; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 /* Fill in our driver capabilities */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 SDL_CDcaps.Name = SDL_SYS_CDName; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 SDL_CDcaps.Open = SDL_SYS_CDOpen; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 SDL_CDcaps.Status = SDL_SYS_CDStatus; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 SDL_CDcaps.Play = SDL_SYS_CDPlay; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 SDL_CDcaps.Pause = SDL_SYS_CDPause; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 SDL_CDcaps.Resume = SDL_SYS_CDResume; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 SDL_CDcaps.Stop = SDL_SYS_CDStop; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 SDL_CDcaps.Eject = SDL_SYS_CDEject; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 SDL_CDcaps.Close = SDL_SYS_CDClose; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 /* Look in the environment for our CD-ROM drive list */ |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
165 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 if ( SDLcdrom != NULL ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 char *cdpath, *delim; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
168 cdpath = (char *)SDL_malloc(SDL_strlen(SDLcdrom)+1); |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 if ( cdpath != NULL ) { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
170 SDL_strcpy(cdpath, SDLcdrom); |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 SDLcdrom = cdpath; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 do { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
173 delim = SDL_strchr(SDLcdrom, ':'); |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 if ( delim ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 *delim++ = '\0'; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 if ( CheckDrive(SDLcdrom) > 0 ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 AddDrive(SDLcdrom); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 if ( delim ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 SDLcdrom = delim; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 } else { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 SDLcdrom = NULL; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 } while ( SDLcdrom ); |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
186 SDL_free(cdpath); |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 /* If we found our drives, there's nothing left to do */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 if ( SDL_numcds > 0 ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 return(0); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 /* Scan the system for CD-ROM drives */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 try_dir("/dev/disk"); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 return 0; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 int try_dir(const char *directory) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 BDirectory dir; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 dir.SetTo(directory); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 if(dir.InitCheck() != B_NO_ERROR) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 return false; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 dir.Rewind(); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 BEntry entry; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 while(dir.GetNextEntry(&entry) >= 0) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 BPath path; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 const char *name; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 entry_ref e; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 if(entry.GetPath(&path) != B_NO_ERROR) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 continue; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 name = path.Path(); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 if(entry.GetRef(&e) != B_NO_ERROR) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 continue; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 if(entry.IsDirectory()) { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
223 if(SDL_strcmp(e.name, "floppy") == 0) |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 continue; /* ignore floppy (it is not silent) */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 int devfd = try_dir(name); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 if(devfd >= 0) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 return devfd; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 else { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 int devfd; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 device_geometry g; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
233 if(SDL_strcmp(e.name, "raw") != 0) |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 continue; /* ignore partitions */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 devfd = open(name, O_RDONLY); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 if(devfd < 0) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 continue; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 if(ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 if(g.device_type == B_CD) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 AddDrive(strdup(name)); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 close(devfd); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 return B_ERROR; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 /* General ioctl() CD-ROM command function */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 static int SDL_SYS_CDioctl(int index, int command, void *arg) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 int okay; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 int fd; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 okay = 0; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 fd = open(SDL_cdlist[index], 0); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 if ( fd >= 0 ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 if ( ioctl(fd, command, arg) == B_NO_ERROR ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 okay = 1; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 close(fd); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 return(okay ? 0 : -1); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 static const char *SDL_SYS_CDName(int drive) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 return(SDL_cdlist[drive]); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 static int SDL_SYS_CDOpen(int drive) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 return(drive); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 int i; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 scsi_toc toc; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 if ( SDL_SYS_CDioctl(cdrom->id, B_SCSI_GET_TOC, &toc) == 0 ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 cdrom->numtracks = CD_NUMTRACKS(toc); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 if ( cdrom->numtracks > SDL_MAX_TRACKS ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 cdrom->numtracks = SDL_MAX_TRACKS; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 for ( i=0; i<=cdrom->numtracks; ++i ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 cdrom->track[i].id = CD_TRACK_N(toc, i); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 /* FIXME: How do we tell on BeOS? */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 cdrom->track[i].type = SDL_AUDIO_TRACK; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 cdrom->track[i].offset = MSF_TO_FRAMES( |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 CD_TRACK_M(toc, i), |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 CD_TRACK_S(toc, i), |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 CD_TRACK_F(toc, i)); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 cdrom->track[i].length = 0; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 if ( i > 0 ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 cdrom->track[i-1].length = |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 cdrom->track[i].offset- |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 cdrom->track[i-1].offset; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 return(0); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 } else { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 return(-1); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 /* Get CD-ROM status */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 CDstatus status; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 int fd; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 int cur_frame; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 scsi_position pos; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 fd = open(SDL_cdlist[cdrom->id], 0); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 cur_frame = 0; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 if ( fd >= 0 ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 if ( ioctl(fd, B_SCSI_GET_POSITION, &pos) == B_NO_ERROR ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 cur_frame = MSF_TO_FRAMES( |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 POS_ABS_M(pos), POS_ABS_S(pos), POS_ABS_F(pos)); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 if ( ! pos.position[1] || (pos.position[1] >= 0x13) || |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 ((pos.position[1] == 0x12) && (!pos.position[6])) ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 status = CD_STOPPED; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 } else |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 if ( pos.position[1] == 0x11 ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 status = CD_PLAYING; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 } else { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 status = CD_PAUSED; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 close(fd); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 } else { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 status = CD_TRAYEMPTY; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 if ( position ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 *position = cur_frame; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 return(status); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 /* Start play */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 int okay; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 int fd; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 scsi_play_position pos; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 okay = 0; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 fd = open(SDL_cdlist[cdrom->id], 0); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 if ( fd >= 0 ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 FRAMES_TO_MSF(start, &pos.start_m, &pos.start_s, &pos.start_f); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 FRAMES_TO_MSF(start+length, &pos.end_m, &pos.end_s, &pos.end_f); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 if ( ioctl(fd, B_SCSI_PLAY_POSITION, &pos) == B_NO_ERROR ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 okay = 1; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 close(fd); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 return(okay ? 0 : -1); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 /* Pause play */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 static int SDL_SYS_CDPause(SDL_CD *cdrom) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_PAUSE_AUDIO, 0)); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 /* Resume play */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 static int SDL_SYS_CDResume(SDL_CD *cdrom) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_RESUME_AUDIO, 0)); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 /* Stop play */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 static int SDL_SYS_CDStop(SDL_CD *cdrom) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_STOP_AUDIO, 0)); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 /* Eject the CD-ROM */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 static int SDL_SYS_CDEject(SDL_CD *cdrom) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_EJECT, 0)); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 /* Close the CD-ROM handle */ |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 static void SDL_SYS_CDClose(SDL_CD *cdrom) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 close(cdrom->id); |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 void SDL_SYS_CDQuit(void) |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 int i; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 if ( SDL_numcds > 0 ) { |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 for ( i=0; i<SDL_numcds; ++i ) { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
401 SDL_free(SDL_cdlist[i]); |
153
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 SDL_numcds = 0; |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 } |
2839f45bdba0
Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 |