Mercurial > sdl-ios-xcode
annotate src/cdrom/bsdi/SDL_syscdrom.c @ 1661:281d3f4870e5 SDL-1.3
Moved DirectInput joystick code to 1.3 branch
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 21 May 2006 17:27:13 +0000 |
parents | 92947e3a18db |
children | 782fd950bd46 c121d94672cb a1b03ba2fcd0 |
rev | line source |
---|---|
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
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:
252
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
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:
252
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
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:
252
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
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:
252
diff
changeset
|
13 Lesser General Public License for more details. |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
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:
252
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:
252
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:
252
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
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:
178
diff
changeset
|
20 slouken@libsdl.org |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
22 #include "SDL_config.h" |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
1635
92947e3a18db
Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
24 #ifdef SDL_CDROM_BSDI |
92947e3a18db
Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
25 |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 /* |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 * Functions for system-level CD-ROM audio control for BSD/OS 4.x |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 * This started life out as a copy of the freebsd/SDL_cdrom.c file but was |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 * heavily modified. Works for standard (MMC) SCSI and ATAPI CDrom drives. |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 * |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 * Steven Schultz - sms@to.gd-es.com |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #include <sys/types.h> |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 #include <sys/stat.h> |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 #include <fcntl.h> |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 #include <err.h> |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #include <unistd.h> |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 #include <sys/ioctl.h> |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 #include </sys/dev/scsi/scsi.h> |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 #include </sys/dev/scsi/scsi_ioctl.h> |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 #include "SDL_cdrom.h" |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
44 #include "../SDL_syscdrom.h" |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 /* |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 * The msf_to_frame and frame_to_msf were yanked from libcdrom and inlined |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 * here so that -lcdrom doesn't have to be dragged in for something so simple. |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 #define FRAMES_PER_SECOND 75 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 #define FRAMES_PER_MINUTE (FRAMES_PER_SECOND * 60) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 int |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 msf_to_frame(int minute, int second, int frame) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 return(minute * FRAMES_PER_MINUTE + second * FRAMES_PER_SECOND + frame); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 void |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 frame_to_msf(int frame, int *minp, int *secp, int *framep) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 *minp = frame / FRAMES_PER_MINUTE; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 *secp = (frame % FRAMES_PER_MINUTE) / FRAMES_PER_SECOND; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 *framep = frame % FRAMES_PER_SECOND; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 /* The maximum number of CD-ROM drives we'll detect */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 #define MAX_DRIVES 16 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 /* A list of available CD-ROM drives */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 static char *SDL_cdlist[MAX_DRIVES]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 static dev_t SDL_cdmode[MAX_DRIVES]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 /* The system-dependent CD control functions */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 static const char *SDL_SYS_CDName(int drive); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 static int SDL_SYS_CDOpen(int drive); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 static int SDL_SYS_CDPause(SDL_CD *cdrom); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 static int SDL_SYS_CDResume(SDL_CD *cdrom); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 static int SDL_SYS_CDStop(SDL_CD *cdrom); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 static int SDL_SYS_CDEject(SDL_CD *cdrom); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 static void SDL_SYS_CDClose(SDL_CD *cdrom); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 typedef struct scsi_cdb cdb_t; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 static int scsi_cmd(int fd, |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 struct scsi_cdb *cdb, |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 int cdblen, |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 int rw, |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 caddr_t data, |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 int datalen, |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 struct scsi_user_cdb *sus) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 int scsistatus; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 unsigned char *cp; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 struct scsi_user_cdb suc; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 /* safety checks */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 if (!cdb) return(-1); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 if (rw != SUC_READ && rw != SUC_WRITE) return(-1); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 suc.suc_flags = rw; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 suc.suc_cdblen = cdblen; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 bcopy(cdb, suc.suc_cdb, cdblen); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 suc.suc_datalen = datalen; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 suc.suc_data = data; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 suc.suc_timeout = 10; /* 10 secs max for TUR or SENSE */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 if (ioctl(fd, SCSIRAWCDB, &suc) == -1) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 return(-11); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 scsistatus = suc.suc_sus.sus_status; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 cp = suc.suc_sus.sus_sense; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 /* |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 * If a place to copy the sense data back to has been provided then the |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 * caller is responsible for checking the errors and printing any information |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 * out if the status was not successful. |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 if (scsistatus != 0 && !sus) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 fprintf(stderr,"scsistatus = %x cmd = %x\n", |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 scsistatus, cdb[0]); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 fprintf(stderr, "sense %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 cp[6], cp[7], cp[8], cp[9], cp[10], cp[11], |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 cp[12], cp[13], cp[14], cp[15]); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 return(1); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 if (sus) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 bcopy(&suc, sus, sizeof (struct scsi_user_cdb)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 if (scsistatus) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 return(1); /* Return non-zero for unsuccessful status */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 return(0); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 /* request vendor brand and model */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 unsigned char *Inquiry(int fd) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 static struct scsi_cdb6 cdb = |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 0x12, |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 0, 0, 0, |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 56, |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 0 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 }; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 static unsigned char Inqbuffer[56]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 if (scsi_cmd(fd, (cdb_t *)&cdb, 6, SUC_READ, Inqbuffer, |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 sizeof(Inqbuffer), 0)) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 return("\377"); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 return(Inqbuffer); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 #define ADD_SENSECODE 12 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 #define ADD_SC_QUALIFIER 13 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 int TestForMedium(int fd) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 int sts, asc, ascq; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 struct scsi_user_cdb sus; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 static struct scsi_cdb6 cdb = |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 CMD_TEST_UNIT_READY, /* command */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 0, /* reserved */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 0, /* reserved */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 0, /* reserved */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 0, /* reserved */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 0 /* reserved */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 }; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 again: sts = scsi_cmd(fd, (cdb_t *)&cdb, 6, SUC_READ, 0, 0, &sus); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 asc = sus.suc_sus.sus_sense[ADD_SENSECODE]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 ascq = sus.suc_sus.sus_sense[ADD_SC_QUALIFIER]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 if (asc == 0x3a && ascq == 0x0) /* no medium */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 return(0); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 if (asc == 0x28 && ascq == 0x0) /* medium changed */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 goto again; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 if (asc == 0x4 && ascq == 0x1 ) /* coming ready */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 sleep(2); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 goto again; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 return(1); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 /* Check a drive to see if it is a CD-ROM */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 static int CheckDrive(char *drive, struct stat *stbuf) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 int is_cd = 0, cdfd; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 char *p; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 /* If it doesn't exist, return -1 */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 if ( stat(drive, stbuf) < 0 ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 return(-1); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 /* If it does exist, verify that it's an available CD-ROM */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 cdfd = open(drive, (O_RDONLY|O_EXCL|O_NONBLOCK), 0); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 if ( cdfd >= 0 ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 p = Inquiry(cdfd); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 if (*p == TYPE_ROM) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 is_cd = 1; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 close(cdfd); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 return(is_cd); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 /* Add a CD-ROM drive to our list of valid drives */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 static void AddDrive(char *drive, struct stat *stbuf) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 int i; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 if ( SDL_numcds < MAX_DRIVES ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 /* Check to make sure it's not already in our list. |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 This can happen when we see a drive via symbolic link. |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 for ( i=0; i<SDL_numcds; ++i ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 if ( stbuf->st_rdev == SDL_cdmode[i] ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 #ifdef DEBUG_CDROM |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 fprintf(stderr, "Duplicate drive detected: %s == %s\n", drive, SDL_cdlist[i]); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 #endif |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 return; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 /* Add this drive to our list */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 i = SDL_numcds; |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
230 SDL_cdlist[i] = SDL_strdup(drive); |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 if ( SDL_cdlist[i] == NULL ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 SDL_OutOfMemory(); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 return; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 SDL_cdmode[i] = stbuf->st_rdev; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 ++SDL_numcds; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 #ifdef DEBUG_CDROM |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 #endif |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 int SDL_SYS_CDInit(void) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 /* checklist: /dev/rsr?c */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 static char *checklist[] = { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 "?0 rsr?", NULL |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 }; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 char *SDLcdrom; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 int i, j, exists; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 char drive[32]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 struct stat stbuf; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 /* Fill in our driver capabilities */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 SDL_CDcaps.Name = SDL_SYS_CDName; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 SDL_CDcaps.Open = SDL_SYS_CDOpen; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 SDL_CDcaps.Status = SDL_SYS_CDStatus; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 SDL_CDcaps.Play = SDL_SYS_CDPlay; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 SDL_CDcaps.Pause = SDL_SYS_CDPause; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 SDL_CDcaps.Resume = SDL_SYS_CDResume; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 SDL_CDcaps.Stop = SDL_SYS_CDStop; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 SDL_CDcaps.Eject = SDL_SYS_CDEject; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 SDL_CDcaps.Close = SDL_SYS_CDClose; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 /* 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
|
267 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 if ( SDLcdrom != NULL ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 char *cdpath, *delim; |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
270 size_t len = SDL_strlen(SDLcdrom)+1; |
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
271 cdpath = SDL_stack_alloc(char, len); |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 if ( cdpath != NULL ) { |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
273 SDL_strlcpy(cdpath, SDLcdrom, len); |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 SDLcdrom = cdpath; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 do { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
276 delim = SDL_strchr(SDLcdrom, ':'); |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 if ( delim ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 *delim++ = '\0'; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 AddDrive(SDLcdrom, &stbuf); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 if ( delim ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 SDLcdrom = delim; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 } else { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 SDLcdrom = NULL; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 } while ( SDLcdrom ); |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
289 SDL_stack_free(cdpath); |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 /* If we found our drives, there's nothing left to do */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 if ( SDL_numcds > 0 ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 return(0); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 /* Scan the system for CD-ROM drives */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 for ( i=0; checklist[i]; ++i ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 if ( checklist[i][0] == '?' ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 char *insert; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 exists = 1; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 for ( j=checklist[i][1]; exists; ++j ) { |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
304 SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%sc", &checklist[i][3]); |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
305 insert = SDL_strchr(drive, '?'); |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 if ( insert != NULL ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 *insert = j; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 switch (CheckDrive(drive, &stbuf)) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 /* Drive exists and is a CD-ROM */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 case 1: |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 AddDrive(drive, &stbuf); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 break; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 /* Drive exists, but isn't a CD-ROM */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 case 0: |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 break; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 /* Drive doesn't exist */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 case -1: |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 exists = 0; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 break; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 } else { |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
324 SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", checklist[i]); |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 if ( CheckDrive(drive, &stbuf) > 0 ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 AddDrive(drive, &stbuf); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 return(0); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 static const char *SDL_SYS_CDName(int drive) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 return(SDL_cdlist[drive]); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 static int SDL_SYS_CDOpen(int drive) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 return(open(SDL_cdlist[drive], O_RDONLY | O_NONBLOCK | O_EXCL, 0)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 u_char cdb[10], buf[4], *p, *toc; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 struct scsi_user_cdb sus; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 int i, sts, first_track, last_track, ntracks, toc_size; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 bzero(cdb, sizeof (cdb)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 cdb[0] = 0x43; /* Read TOC */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 cdb[1] = 0x2; /* MSF */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 cdb[8] = 4; /* size TOC header */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 sts = scsi_cmd(cdrom->id, (cdb_t *)cdb, 10, SUC_READ, buf, 4, &sus); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 if (sts < 0) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 return(-1); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 first_track = buf[2]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 last_track = buf[3]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 ntracks = last_track - first_track + 1; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 cdrom->numtracks = ntracks; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 toc_size = 4 + (ntracks + 1) * 8; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
361 toc = (u_char *)SDL_malloc(toc_size); |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 if (toc == NULL) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 return(-1); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 bzero(cdb, sizeof (cdb)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 cdb[0] = 0x43; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 cdb[1] = 0x2; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 cdb[6] = first_track; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 cdb[7] = toc_size >> 8; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 cdb[8] = toc_size & 0xff; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 sts = scsi_cmd(cdrom->id, (cdb_t *)cdb, 10, SUC_READ, toc, toc_size, |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 &sus); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 if (sts < 0) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
374 SDL_free(toc); |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 return(-1); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 for (i = 0, p = toc+4; i <= ntracks; i++, p+= 8) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 if (i == ntracks) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 cdrom->track[i].id = 0xAA; /* Leadout */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 else |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 cdrom->track[i].id = first_track + i; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 if (p[1] & 0x20) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 cdrom->track[i].type = SDL_DATA_TRACK; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 else |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 cdrom->track[i].type = SDL_AUDIO_TRACK; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 cdrom->track[i].offset = msf_to_frame(p[5], p[6], p[7]); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 cdrom->track[i].length = 0; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 if (i > 0) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 cdrom->track[i-1].length = cdrom->track[i].offset - |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 cdrom->track[i-1].offset; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
394 SDL_free(toc); |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 return(0); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 /* Get CD-ROM status */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 CDstatus status; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 u_char cdb[10], buf[16]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 int sts; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 struct scsi_user_cdb sus; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 bzero(cdb, sizeof (cdb)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 cdb[0] = 0x42; /* read subq */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 cdb[1] = 0x2; /* MSF */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 cdb[2] = 0x40; /* q channel */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 cdb[3] = 1; /* current pos */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 cdb[7] = sizeof (buf) >> 8; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 cdb[8] = sizeof (buf) & 0xff; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 sts = scsi_cmd(cdrom->id, (cdb_t *)cdb, 10, SUC_READ, buf, sizeof (buf), |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 &sus); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 if (sts < 0) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 return(-1); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 if (sts) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 if (TestForMedium(cdrom->id) == 0) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 status = CD_TRAYEMPTY; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 else |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 status = CD_ERROR; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 else |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 switch (buf[1]) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 case 0x11: |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 status = CD_PLAYING; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 break; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 case 0x12: |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 status = CD_PAUSED; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 break; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 case 0x13: |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 case 0x14: |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 case 0x15: |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 status = CD_STOPPED; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 break; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 default: |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
440 status = CD_ERROR; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 break; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 if (position) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 if ( status == CD_PLAYING || (status == CD_PAUSED) ) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 *position = msf_to_frame(buf[9], buf[10], buf[11]); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 else |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 *position = 0; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 return(status); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 /* Start play */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 u_char cdb[10]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 int sts, minute, second, frame, eminute, esecond, eframe; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 struct scsi_user_cdb sus; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 bzero(cdb, sizeof(cdb)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 cdb[0] = 0x47; /* Play */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 frame_to_msf(start, &minute, &second, &frame); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 frame_to_msf(start + length, &eminute, &esecond, &eframe); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 cdb[3] = minute; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 cdb[4] = second; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 cdb[5] = frame; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 cdb[6] = eminute; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
469 cdb[7] = esecond; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
470 cdb[8] = eframe; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 sts = scsi_cmd(cdrom->id, (cdb_t *)cdb, 10, SUC_READ, 0, 0, &sus); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 return(sts); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 static int |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 pauseresume(SDL_CD *cdrom, int flag) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 u_char cdb[10]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 struct scsi_user_cdb sus; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 bzero(cdb, sizeof (cdb)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 cdb[0] = 0x4b; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 cdb[8] = flag & 0x1; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 return(scsi_cmd(cdrom->id, (cdb_t *)cdb, 10, SUC_READ, 0, 0, &sus)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 /* Pause play */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 static int SDL_SYS_CDPause(SDL_CD *cdrom) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 return(pauseresume(cdrom, 0)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 /* Resume play */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 static int SDL_SYS_CDResume(SDL_CD *cdrom) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 return(pauseresume(cdrom, 1)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
498 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
499 /* Stop play */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
500 static int SDL_SYS_CDStop(SDL_CD *cdrom) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
501 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 u_char cdb[6]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 struct scsi_user_cdb sus; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
504 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 bzero(cdb, sizeof (cdb)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 cdb[0] = 0x1b; /* stop */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 cdb[1] = 1; /* immediate */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 return(scsi_cmd(cdrom->id, (cdb_t *)cdb, 6, SUC_READ, 0, 0, &sus)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 /* Eject the CD-ROM */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 static int SDL_SYS_CDEject(SDL_CD *cdrom) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 u_char cdb[6]; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 struct scsi_user_cdb sus; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 bzero(cdb, sizeof (cdb)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 cdb[0] = 0x1b; /* stop */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 cdb[1] = 1; /* immediate */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 cdb[4] = 2; /* eject */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 return(scsi_cmd(cdrom->id, (cdb_t *)cdb, 6, SUC_READ, 0, 0, &sus)); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 /* Close the CD-ROM handle */ |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 static void SDL_SYS_CDClose(SDL_CD *cdrom) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
527 close(cdrom->id); |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
528 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 void SDL_SYS_CDQuit(void) |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 int i; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
533 |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
534 if ( SDL_numcds > 0 ) { |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 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
|
536 SDL_free(SDL_cdlist[i]); |
178
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
537 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
538 } |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
539 SDL_numcds = 0; |
1fc1a101bf23
Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
540 } |
1635
92947e3a18db
Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
541 |
92947e3a18db
Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
542 #endif /* SDL_CDROM_BSDI */ |