annotate src/cdrom/bsdi/SDL_syscdrom.c @ 1675:d33dcfc3fde7 SDL-1.3

Overlay functions are being replaced by YUV textures. If the driver doesn't support YUV textures, they can be emulated by backing the texture with an RGB texture and using the software conversion routines. Note that it doesn't make sense to lock a portion of a YV12 texture, since you'd need to return three pixel pointers and pitch values instead of the one that's available through the API. I'm guessing that's one of the reasons DirectX 9 doesn't support this format at all.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 11 Jun 2006 07:30:16 +0000
parents 4da1ee79c9af
children
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
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
55 msf_to_frame(int minute, int second, int frame)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
56 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
57 return (minute * FRAMES_PER_MINUTE + second * FRAMES_PER_SECOND + frame);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
58 }
178
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
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
61 frame_to_msf(int frame, int *minp, int *secp, int *framep)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
62 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
63 *minp = frame / FRAMES_PER_MINUTE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
64 *secp = (frame % FRAMES_PER_MINUTE) / FRAMES_PER_SECOND;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
65 *framep = frame % FRAMES_PER_SECOND;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
66 }
178
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 */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
69 #define MAX_DRIVES 16
178
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 */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
76 static const char *SDL_SYS_CDName(int drive);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
77 static int SDL_SYS_CDOpen(int drive);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
78 static int SDL_SYS_CDGetTOC(SDL_CD * cdrom);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
79 static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
80 static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
81 static int SDL_SYS_CDPause(SDL_CD * cdrom);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
82 static int SDL_SYS_CDResume(SDL_CD * cdrom);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
83 static int SDL_SYS_CDStop(SDL_CD * cdrom);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
84 static int SDL_SYS_CDEject(SDL_CD * cdrom);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
85 static void SDL_SYS_CDClose(SDL_CD * cdrom);
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
87 typedef struct scsi_cdb cdb_t;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
89 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
90 scsi_cmd(int fd,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
91 struct scsi_cdb *cdb,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
92 int cdblen,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
93 int rw, caddr_t data, int datalen, struct scsi_user_cdb *sus)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
94 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
95 int scsistatus;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
96 unsigned char *cp;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
97 struct scsi_user_cdb suc;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 /* safety checks */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
100 if (!cdb)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
101 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
102 if (rw != SUC_READ && rw != SUC_WRITE)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
103 return (-1);
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
105 suc.suc_flags = rw;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
106 suc.suc_cdblen = cdblen;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
107 bcopy(cdb, suc.suc_cdb, cdblen);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
108 suc.suc_datalen = datalen;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
109 suc.suc_data = data;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
110 suc.suc_timeout = 10; /* 10 secs max for TUR or SENSE */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
111 if (ioctl(fd, SCSIRAWCDB, &suc) == -1)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
112 return (-11);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
113 scsistatus = suc.suc_sus.sus_status;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
114 cp = suc.suc_sus.sus_sense;
178
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 */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
121 if (scsistatus != 0 && !sus) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
122 fprintf(stderr, "scsistatus = %x cmd = %x\n", scsistatus, cdb[0]);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
123 fprintf(stderr,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
124 "sense %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
125 cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7],
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
126 cp[8], cp[9], cp[10], cp[11], cp[12], cp[13], cp[14], cp[15]);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
127 return (1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
128 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
129 if (sus)
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
130 bcopy(&suc, sus, sizeof(struct scsi_user_cdb));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
131 if (scsistatus)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
132 return (1); /* Return non-zero for unsuccessful status */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
133 return (0);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
134 }
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 /* request vendor brand and model */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
137 unsigned char *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
138 Inquiry(int fd)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
139 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
140 static struct scsi_cdb6 cdb = {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
141 0x12,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
142 0, 0, 0,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
143 56,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
144 0
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
145 };
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
146 static unsigned char Inqbuffer[56];
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
148 if (scsi_cmd(fd, (cdb_t *) & cdb, 6, SUC_READ, Inqbuffer,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
149 sizeof(Inqbuffer), 0))
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
150 return ("\377");
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
151 return (Inqbuffer);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
152 }
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 #define ADD_SENSECODE 12
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 #define ADD_SC_QUALIFIER 13
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
157 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
158 TestForMedium(int fd)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
159 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
160 int sts, asc, ascq;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
161 struct scsi_user_cdb sus;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
162 static struct scsi_cdb6 cdb = {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
163 CMD_TEST_UNIT_READY, /* command */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
164 0, /* reserved */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
165 0, /* reserved */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
166 0, /* reserved */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
167 0, /* reserved */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
168 0 /* reserved */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
169 };
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
171 again:sts = scsi_cmd(fd, (cdb_t *) & cdb, 6, SUC_READ, 0, 0, &sus);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
172 asc = sus.suc_sus.sus_sense[ADD_SENSECODE];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
173 ascq = sus.suc_sus.sus_sense[ADD_SC_QUALIFIER];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
174 if (asc == 0x3a && ascq == 0x0) /* no medium */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
175 return (0);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
176 if (asc == 0x28 && ascq == 0x0) /* medium changed */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
177 goto again;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
178 if (asc == 0x4 && ascq == 0x1) { /* coming ready */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
179 sleep(2);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
180 goto again;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
181 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
182 return (1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
183 }
178
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 /* Check a drive to see if it is a CD-ROM */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
186 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
187 CheckDrive(char *drive, struct stat *stbuf)
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
189 int is_cd = 0, cdfd;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
190 char *p;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
192 /* If it doesn't exist, return -1 */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
193 if (stat(drive, stbuf) < 0) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
194 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
195 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
196
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
197 /* If it does exist, verify that it's an available CD-ROM */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
198 cdfd = open(drive, (O_RDONLY | O_EXCL | O_NONBLOCK), 0);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
199 if (cdfd >= 0) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
200 p = Inquiry(cdfd);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
201 if (*p == TYPE_ROM)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
202 is_cd = 1;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
203 close(cdfd);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
204 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
205 return (is_cd);
178
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
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 /* Add a CD-ROM drive to our list of valid drives */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
209 static void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
210 AddDrive(char *drive, struct stat *stbuf)
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
212 int i;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
214 if (SDL_numcds < MAX_DRIVES) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
215 /* Check to make sure it's not already in our list.
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
216 This can happen when we see a drive via symbolic link.
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
217 */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
218 for (i = 0; i < SDL_numcds; ++i) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
219 if (stbuf->st_rdev == SDL_cdmode[i]) {
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 #ifdef DEBUG_CDROM
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
221 fprintf(stderr, "Duplicate drive detected: %s == %s\n",
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
222 drive, SDL_cdlist[i]);
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 #endif
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
224 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
225 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
226 }
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
228 /* Add this drive to our list */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
229 i = SDL_numcds;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
230 SDL_cdlist[i] = SDL_strdup(drive);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
231 if (SDL_cdlist[i] == NULL) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
232 SDL_OutOfMemory();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
233 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
234 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
235 SDL_cdmode[i] = stbuf->st_rdev;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
236 ++SDL_numcds;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 #ifdef DEBUG_CDROM
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
238 fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 #endif
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
240 }
178
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
243 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
244 SDL_SYS_CDInit(void)
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
246 /* checklist: /dev/rsr?c */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
247 static char *checklist[] = {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
248 "?0 rsr?", NULL
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
249 };
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
250 char *SDLcdrom;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
251 int i, j, exists;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
252 char drive[32];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
253 struct stat stbuf;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
255 /* Fill in our driver capabilities */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
256 SDL_CDcaps.Name = SDL_SYS_CDName;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
257 SDL_CDcaps.Open = SDL_SYS_CDOpen;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
258 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
259 SDL_CDcaps.Status = SDL_SYS_CDStatus;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
260 SDL_CDcaps.Play = SDL_SYS_CDPlay;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
261 SDL_CDcaps.Pause = SDL_SYS_CDPause;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
262 SDL_CDcaps.Resume = SDL_SYS_CDResume;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
263 SDL_CDcaps.Stop = SDL_SYS_CDStop;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
264 SDL_CDcaps.Eject = SDL_SYS_CDEject;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
265 SDL_CDcaps.Close = SDL_SYS_CDClose;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
267 /* Look in the environment for our CD-ROM drive list */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
268 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
269 if (SDLcdrom != NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
270 char *cdpath, *delim;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
271 size_t len = SDL_strlen(SDLcdrom) + 1;
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
272 cdpath = SDL_stack_alloc(char, len);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
273 if (cdpath != NULL) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
274 SDL_strlcpy(cdpath, SDLcdrom, len);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
275 SDLcdrom = cdpath;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
276 do {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
277 delim = SDL_strchr(SDLcdrom, ':');
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
278 if (delim) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
279 *delim++ = '\0';
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
280 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
281 if (CheckDrive(SDLcdrom, &stbuf) > 0) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
282 AddDrive(SDLcdrom, &stbuf);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
283 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
284 if (delim) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
285 SDLcdrom = delim;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
286 } else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
287 SDLcdrom = NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
288 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
289 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
290 while (SDLcdrom);
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
291 SDL_stack_free(cdpath);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
292 }
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
294 /* If we found our drives, there's nothing left to do */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
295 if (SDL_numcds > 0) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
296 return (0);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
297 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
298 }
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
300 /* Scan the system for CD-ROM drives */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
301 for (i = 0; checklist[i]; ++i) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
302 if (checklist[i][0] == '?') {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
303 char *insert;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
304 exists = 1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
305 for (j = checklist[i][1]; exists; ++j) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
306 SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%sc",
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
307 &checklist[i][3]);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
308 insert = SDL_strchr(drive, '?');
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
309 if (insert != NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
310 *insert = j;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
311 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
312 switch (CheckDrive(drive, &stbuf)) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
313 /* Drive exists and is a CD-ROM */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
314 case 1:
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
315 AddDrive(drive, &stbuf);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
316 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
317 /* Drive exists, but isn't a CD-ROM */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
318 case 0:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
319 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
320 /* Drive doesn't exist */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
321 case -1:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
322 exists = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
323 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
324 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
325 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
326 } else {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
327 SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s",
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
328 checklist[i]);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
329 if (CheckDrive(drive, &stbuf) > 0) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
330 AddDrive(drive, &stbuf);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
331 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
332 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
333 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
334 return (0);
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 }
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
337 static const char *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
338 SDL_SYS_CDName(int drive)
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
340 return (SDL_cdlist[drive]);
178
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
343 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
344 SDL_SYS_CDOpen(int drive)
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
346 return (open(SDL_cdlist[drive], O_RDONLY | O_NONBLOCK | O_EXCL, 0));
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 }
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
349 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
350 SDL_SYS_CDGetTOC(SDL_CD * cdrom)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
351 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
352 u_char cdb[10], buf[4], *p, *toc;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
353 struct scsi_user_cdb sus;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
354 int i, sts, first_track, last_track, ntracks, toc_size;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
356 bzero(cdb, sizeof(cdb));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
357 cdb[0] = 0x43; /* Read TOC */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
358 cdb[1] = 0x2; /* MSF */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
359 cdb[8] = 4; /* size TOC header */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
360 sts = scsi_cmd(cdrom->id, (cdb_t *) cdb, 10, SUC_READ, buf, 4, &sus);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
361 if (sts < 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
362 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
363 first_track = buf[2];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
364 last_track = buf[3];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
365 ntracks = last_track - first_track + 1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
366 cdrom->numtracks = ntracks;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
367 toc_size = 4 + (ntracks + 1) * 8;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
368 toc = (u_char *) SDL_malloc(toc_size);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
369 if (toc == NULL)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
370 return (-1);
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
371 bzero(cdb, sizeof(cdb));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
372 cdb[0] = 0x43;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
373 cdb[1] = 0x2;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
374 cdb[6] = first_track;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
375 cdb[7] = toc_size >> 8;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
376 cdb[8] = toc_size & 0xff;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
377 sts = scsi_cmd(cdrom->id, (cdb_t *) cdb, 10, SUC_READ, toc, toc_size,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
378 &sus);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
379 if (sts < 0) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
380 SDL_free(toc);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
381 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
382 }
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
384 for (i = 0, p = toc + 4; i <= ntracks; i++, p += 8) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
385 if (i == ntracks)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
386 cdrom->track[i].id = 0xAA; /* Leadout */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
387 else
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
388 cdrom->track[i].id = first_track + i;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
389 if (p[1] & 0x20)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
390 cdrom->track[i].type = SDL_DATA_TRACK;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
391 else
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
392 cdrom->track[i].type = SDL_AUDIO_TRACK;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
393 cdrom->track[i].offset = msf_to_frame(p[5], p[6], p[7]);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
394 cdrom->track[i].length = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
395 if (i > 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
396 cdrom->track[i - 1].length = cdrom->track[i].offset -
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
397 cdrom->track[i - 1].offset;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
398 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
399 SDL_free(toc);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
400 return (0);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
401 }
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 /* Get CD-ROM status */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
404 static CDstatus
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
405 SDL_SYS_CDStatus(SDL_CD * cdrom, int *position)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
406 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
407 CDstatus status;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
408 u_char cdb[10], buf[16];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
409 int sts;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
410 struct scsi_user_cdb sus;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
412 bzero(cdb, sizeof(cdb));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
413 cdb[0] = 0x42; /* read subq */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
414 cdb[1] = 0x2; /* MSF */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
415 cdb[2] = 0x40; /* q channel */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
416 cdb[3] = 1; /* current pos */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
417 cdb[7] = sizeof(buf) >> 8;
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
418 cdb[8] = sizeof(buf) & 0xff;
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
419 sts = scsi_cmd(cdrom->id, (cdb_t *) cdb, 10, SUC_READ, buf, sizeof(buf),
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
420 &sus);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
421 if (sts < 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
422 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
423 if (sts) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
424 if (TestForMedium(cdrom->id) == 0)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
425 status = CD_TRAYEMPTY;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
426 else
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
427 status = CD_ERROR;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
428 } else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
429 switch (buf[1]) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
430 case 0x11:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
431 status = CD_PLAYING;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
432 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
433 case 0x12:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
434 status = CD_PAUSED;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
435 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
436 case 0x13:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
437 case 0x14:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
438 case 0x15:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
439 status = CD_STOPPED;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
440 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
441 default:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
442 status = CD_ERROR;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
443 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
444 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
445 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
446 if (position) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
447 if (status == CD_PLAYING || (status == CD_PAUSED))
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
448 *position = msf_to_frame(buf[9], buf[10], buf[11]);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
449 else
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
450 *position = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
451 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
452 return (status);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
453 }
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 /* Start play */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
456 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
457 SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
458 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
459 u_char cdb[10];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
460 int sts, minute, second, frame, eminute, esecond, eframe;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
461 struct scsi_user_cdb sus;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
463 bzero(cdb, sizeof(cdb));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
464 cdb[0] = 0x47; /* Play */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
465 frame_to_msf(start, &minute, &second, &frame);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
466 frame_to_msf(start + length, &eminute, &esecond, &eframe);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
467 cdb[3] = minute;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
468 cdb[4] = second;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
469 cdb[5] = frame;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
470 cdb[6] = eminute;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
471 cdb[7] = esecond;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
472 cdb[8] = eframe;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
473 sts = scsi_cmd(cdrom->id, (cdb_t *) cdb, 10, SUC_READ, 0, 0, &sus);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
474 return (sts);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
475 }
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
477 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
478 pauseresume(SDL_CD * cdrom, int flag)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
479 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
480 u_char cdb[10];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
481 struct scsi_user_cdb sus;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
483 bzero(cdb, sizeof(cdb));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
484 cdb[0] = 0x4b;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
485 cdb[8] = flag & 0x1;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
486 return (scsi_cmd(cdrom->id, (cdb_t *) cdb, 10, SUC_READ, 0, 0, &sus));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
487 }
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 /* Pause play */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
490 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
491 SDL_SYS_CDPause(SDL_CD * cdrom)
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
493 return (pauseresume(cdrom, 0));
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 }
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 /* Resume play */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
497 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
498 SDL_SYS_CDResume(SDL_CD * cdrom)
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
500 return (pauseresume(cdrom, 1));
178
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
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 /* Stop play */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
504 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
505 SDL_SYS_CDStop(SDL_CD * cdrom)
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
507 u_char cdb[6];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
508 struct scsi_user_cdb sus;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
510 bzero(cdb, sizeof(cdb));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
511 cdb[0] = 0x1b; /* stop */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
512 cdb[1] = 1; /* immediate */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
513 return (scsi_cmd(cdrom->id, (cdb_t *) cdb, 6, SUC_READ, 0, 0, &sus));
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514 }
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516 /* Eject the CD-ROM */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
517 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
518 SDL_SYS_CDEject(SDL_CD * cdrom)
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
520 u_char cdb[6];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
521 struct scsi_user_cdb sus;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
523 bzero(cdb, sizeof(cdb));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
524 cdb[0] = 0x1b; /* stop */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
525 cdb[1] = 1; /* immediate */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
526 cdb[4] = 2; /* eject */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
527 return (scsi_cmd(cdrom->id, (cdb_t *) cdb, 6, SUC_READ, 0, 0, &sus));
178
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 /* Close the CD-ROM handle */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
531 static void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
532 SDL_SYS_CDClose(SDL_CD * cdrom)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
533 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
534 close(cdrom->id);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
535 }
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
537 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
538 SDL_SYS_CDQuit(void)
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
540 int i;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
542 if (SDL_numcds > 0) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
543 for (i = 0; i < SDL_numcds; ++i) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
544 SDL_free(SDL_cdlist[i]);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
545 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
546 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
547 SDL_numcds = 0;
178
1fc1a101bf23 Added CD-ROM support for BSD/OS (thanks Steven!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548 }
1635
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
549
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
550 #endif /* SDL_CDROM_BSDI */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
551 /* vi: set ts=4 sw=4 expandtab: */