Atari CD-ROM support
authorPatrice Mandin <patmandin@gmail.com>
Sat, 27 Sep 2003 08:20:26 +0000
changeset 7246b3dfe0198bb
parent 723 1e8865a3e127
child 725 9ee05fe728df
Atari CD-ROM support
README.MiNT
configure.in
src/cdrom/Makefile.am
src/cdrom/mint/Makefile.am
src/cdrom/mint/SDL_syscdrom.c
     1.1 --- a/README.MiNT	Wed Sep 24 21:45:27 2003 +0000
     1.2 +++ b/README.MiNT	Sat Sep 27 08:20:26 2003 +0000
     1.3 @@ -48,13 +48,11 @@
     1.4  Mouse (XBIOS, GEM, Ikbd)
     1.5  Video (XBIOS (Fullscreen), GEM (Windowed and Fullscreen))
     1.6  Timer (VBL vector, GNU pth library)
     1.7 -Joystick and joypad support (Ikbd, Hardware)
     1.8 -Audio support (Hardware, XBIOS, GSXB, MCSN, STFA, /dev/audio if threads enabled)
     1.9 -Threads support (Multitasking OS only via GNU pth library)
    1.10 -Shared object support (using LDG library from http://ldg.atari.org/)
    1.11 -
    1.12 -- What is missing:
    1.13 -CDROM support (Metados, /dev/cdrom)
    1.14 +Joystick and joypad (Ikbd, Hardware)
    1.15 +Audio (Hardware, XBIOS, GSXB, MCSN, STFA, /dev/audio if threads enabled)
    1.16 +Threads (Multitasking OS only via GNU pth library)
    1.17 +Shared object loader (using LDG library from http://ldg.atari.org/)
    1.18 +Audio CD (MetaDOS)
    1.19  
    1.20  - Driver combinations:
    1.21  Video	Kbd	Mouse	Timer	Joystick
     2.1 --- a/configure.in	Wed Sep 24 21:45:27 2003 +0000
     2.2 +++ b/configure.in	Sat Sep 27 08:20:26 2003 +0000
     2.3 @@ -2503,8 +2503,8 @@
     2.4          fi
     2.5          # Set up files for the cdrom library
     2.6          if test x$enable_cdrom = xyes; then
     2.7 -            CDROM_SUBDIRS="$CDROM_SUBDIRS dummy"
     2.8 -            CDROM_DRIVERS="$CDROM_DRIVERS dummy/libcdrom_dummy.la"
     2.9 +            CDROM_SUBDIRS="$CDROM_SUBDIRS mint"
    2.10 +            CDROM_DRIVERS="$CDROM_DRIVERS mint/libcdrom_mint.la"
    2.11          fi
    2.12          # Set up files for the thread library
    2.13          if test x$enable_threads = xyes; then
    2.14 @@ -2765,6 +2765,7 @@
    2.15  src/cdrom/linux/Makefile
    2.16  src/cdrom/macos/Makefile
    2.17  src/cdrom/macosx/Makefile
    2.18 +src/cdrom/mint/Makefile
    2.19  src/cdrom/openbsd/Makefile
    2.20  src/cdrom/osf/Makefile
    2.21  src/cdrom/qnx/Makefile
     3.1 --- a/src/cdrom/Makefile.am	Wed Sep 24 21:45:27 2003 +0000
     3.2 +++ b/src/cdrom/Makefile.am	Sat Sep 27 08:20:26 2003 +0000
     3.3 @@ -15,6 +15,7 @@
     3.4  	linux	\
     3.5  	macos	\
     3.6  	macosx	\
     3.7 +	mint \
     3.8  	openbsd	\
     3.9  	osf	\
    3.10  	qnx	\
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/cdrom/mint/Makefile.am	Sat Sep 27 08:20:26 2003 +0000
     4.3 @@ -0,0 +1,8 @@
     4.4 +
     4.5 +## Makefile.am for the MiNT+MetaDOS cdrom driver for SDL
     4.6 +
     4.7 +noinst_LTLIBRARIES = libcdrom_mint.la
     4.8 +libcdrom_mint_la_SOURCES = $(SRCS)
     4.9 +
    4.10 +# The SDL cdrom driver sources
    4.11 +SRCS =  SDL_syscdrom.c
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/cdrom/mint/SDL_syscdrom.c	Sat Sep 27 08:20:26 2003 +0000
     5.3 @@ -0,0 +1,465 @@
     5.4 +/*
     5.5 +    SDL - Simple DirectMedia Layer
     5.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
     5.7 +
     5.8 +    This library is free software; you can redistribute it and/or
     5.9 +    modify it under the terms of the GNU Library General Public
    5.10 +    License as published by the Free Software Foundation; either
    5.11 +    version 2 of the License, or (at your option) any later version.
    5.12 +
    5.13 +    This library is distributed in the hope that it will be useful,
    5.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.16 +    Library General Public License for more details.
    5.17 +
    5.18 +    You should have received a copy of the GNU Library General Public
    5.19 +    License along with this library; if not, write to the Free
    5.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    5.21 +
    5.22 +    Sam Lantinga
    5.23 +    slouken@libsdl.org
    5.24 +*/
    5.25 +
    5.26 +#ifdef SAVE_RCSID
    5.27 +static char rcsid =
    5.28 + "@(#) $Id$";
    5.29 +#endif
    5.30 +
    5.31 +/*
    5.32 +	Atari MetaDOS CD-ROM functions
    5.33 +
    5.34 +	Patrice Mandin
    5.35 +*/
    5.36 +
    5.37 +#include <errno.h>
    5.38 +#include <stdio.h>
    5.39 +#include <stdlib.h>
    5.40 +#include <string.h>
    5.41 +
    5.42 +#include <cdromio.h>
    5.43 +#include <metados.h>
    5.44 +
    5.45 +#include "SDL_error.h"
    5.46 +#include "SDL_cdrom.h"
    5.47 +#include "SDL_syscdrom.h"
    5.48 +
    5.49 +
    5.50 +/* The maximum number of CD-ROM drives we'll detect */
    5.51 +#define MAX_DRIVES	32	
    5.52 +
    5.53 +/* Type of CD-ROM drive */
    5.54 +#define DRIVE_TYPE_NOCD	-1
    5.55 +#define DRIVE_TYPE_STANDARD	0
    5.56 +#define DRIVE_TYPE_CDAR	1
    5.57 +
    5.58 +typedef struct {
    5.59 +	int	type;					/* Standard, or old CDAR-type CD drive ? */
    5.60 +	unsigned char device[3];	/* Physical device letter + ':' + '\0' */
    5.61 +	metaopen_t	metaopen;		/* Infos on opened drive */
    5.62 +} metados_drive_t;
    5.63 +
    5.64 +static metados_drive_t metados_drives[MAX_DRIVES];
    5.65 +
    5.66 +/* The system-dependent CD control functions */
    5.67 +static const char *SDL_SYS_CDName(int drive);
    5.68 +static int SDL_SYS_CDOpen(int drive);
    5.69 +static void SDL_SYS_CDClose(SDL_CD *cdrom);
    5.70 +static int SDL_SYS_CDioctl(int id, int command, void *arg);
    5.71 +
    5.72 +/* Commands using ioctl() */
    5.73 +static int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
    5.74 +static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
    5.75 +static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
    5.76 +static int SDL_SYS_CDPause(SDL_CD *cdrom);
    5.77 +static int SDL_SYS_CDResume(SDL_CD *cdrom);
    5.78 +static int SDL_SYS_CDStop(SDL_CD *cdrom);
    5.79 +static int SDL_SYS_CDEject(SDL_CD *cdrom);
    5.80 +
    5.81 +/* Commands using Meta*() CDAR functions */
    5.82 +static int SDL_SYS_CD_BcdToBinary(int value);
    5.83 +static int SDL_SYS_CDGetTOC_CDAR(SDL_CD *cdrom);
    5.84 +static CDstatus SDL_SYS_CDStatus_CDAR(SDL_CD *cdrom, int *position);
    5.85 +
    5.86 +int SDL_SYS_CDInit(void)
    5.87 +{
    5.88 +	metainit_t	metainit={0,0,0,0};
    5.89 +	metaopen_t	metaopen;
    5.90 +	int i, handle;
    5.91 +
    5.92 +	Metainit(&metainit);
    5.93 +	if (metainit.version == NULL) {
    5.94 +#ifdef DEBUG_CDROM
    5.95 +		fprintf(stderr, "MetaDOS not installed\n");
    5.96 +#endif
    5.97 +		return -1;
    5.98 +	}
    5.99 +
   5.100 +	if (metainit.drives_map == 0) {
   5.101 +#ifdef DEBUG_CDROM
   5.102 +		fprintf(stderr, "No MetaDOS devices present\n");
   5.103 +#endif
   5.104 +		return -1;
   5.105 +	}
   5.106 +
   5.107 +	SDL_numcds = 0;
   5.108 +	
   5.109 +	for (i='A'; i<='Z'; i++) {
   5.110 +		metados_drives[SDL_numcds].type = DRIVE_TYPE_NOCD;
   5.111 +		metados_drives[SDL_numcds].device[0] = 0;
   5.112 +		metados_drives[SDL_numcds].device[1] = ':';
   5.113 +		metados_drives[SDL_numcds].device[2] = 0;
   5.114 +
   5.115 +		if (metainit.drives_map & (1<<(i-'A'))) {
   5.116 +			handle = Metaopen(i, &metaopen);
   5.117 +			if (handle == 0) {
   5.118 +
   5.119 +				if ( (metaopen.name[0]=='C') && (metaopen.name[1]=='D') &&
   5.120 +					(metaopen.name[2]=='A') && (metaopen.name[3]=='R')) {
   5.121 +					/* Drive compatible with CDAR */
   5.122 +					metados_drives[SDL_numcds].type = DRIVE_TYPE_CDAR;
   5.123 +					metados_drives[SDL_numcds].device[0] = i;
   5.124 +					++SDL_numcds;
   5.125 +				} else {
   5.126 +					/* Check for a CD-ROM device */
   5.127 +					if ((Metastatus(i, NULL) & 0x7fff) >= 0) {
   5.128 +						/* Drive compatible with new ioctl functions */
   5.129 +						metados_drives[SDL_numcds].type = DRIVE_TYPE_STANDARD;
   5.130 +						metados_drives[SDL_numcds].device[0] = i;
   5.131 +						++SDL_numcds;
   5.132 +					}
   5.133 +				}
   5.134 +
   5.135 +				Metaclose(i);
   5.136 +			}
   5.137 +		}
   5.138 +	}
   5.139 +
   5.140 +	/* Fill in our driver capabilities */
   5.141 +	SDL_CDcaps.Name = SDL_SYS_CDName;
   5.142 +	SDL_CDcaps.Open = SDL_SYS_CDOpen;
   5.143 +	SDL_CDcaps.Close = SDL_SYS_CDClose;
   5.144 +
   5.145 +	SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
   5.146 +	SDL_CDcaps.Status = SDL_SYS_CDStatus;
   5.147 +	SDL_CDcaps.Play = SDL_SYS_CDPlay;
   5.148 +	SDL_CDcaps.Pause = SDL_SYS_CDPause;
   5.149 +	SDL_CDcaps.Resume = SDL_SYS_CDResume;
   5.150 +	SDL_CDcaps.Stop = SDL_SYS_CDStop;
   5.151 +	SDL_CDcaps.Eject = SDL_SYS_CDEject;
   5.152 +
   5.153 +	return 0;
   5.154 +}
   5.155 +
   5.156 +void SDL_SYS_CDQuit(void)
   5.157 +{
   5.158 +	SDL_numcds = 0;
   5.159 +}
   5.160 +
   5.161 +static const char *SDL_SYS_CDName(int drive)
   5.162 +{
   5.163 +	return(metados_drives[drive].device);
   5.164 +}
   5.165 +
   5.166 +static int SDL_SYS_CDOpen(int drive)
   5.167 +{
   5.168 +	int handle;
   5.169 +
   5.170 +	handle = Metaopen(metados_drives[drive].device[0], &(metados_drives[drive].metaopen));
   5.171 +	if (handle == 0) {
   5.172 +		return drive;
   5.173 +	}
   5.174 +
   5.175 +	return -1;
   5.176 +}
   5.177 +
   5.178 +static void SDL_SYS_CDClose(SDL_CD *cdrom)
   5.179 +{
   5.180 +	Metaclose(metados_drives[cdrom->id].device[0]);
   5.181 +}
   5.182 +
   5.183 +static int SDL_SYS_CDioctl(int id, int command, void *arg)
   5.184 +{
   5.185 +	int retval;
   5.186 +
   5.187 +	retval = Metaioctl(metados_drives[id].device[0], METADOS_IOCTL_MAGIC, command, arg);
   5.188 +	if ( retval < 0 ) {
   5.189 +		SDL_SetError("ioctl() error: %s", strerror(errno));
   5.190 +	}
   5.191 +	return(retval);
   5.192 +}
   5.193 +
   5.194 +static int SDL_SYS_CD_BcdToBinary(int value)
   5.195 +{
   5.196 +	int tmp;
   5.197 +	
   5.198 +	tmp = (value>>4) & 0xf;	
   5.199 +	return (tmp*10)+(value & 0xf);
   5.200 +}
   5.201 +
   5.202 +static int SDL_SYS_CDGetTOC_CDAR(SDL_CD *cdrom)
   5.203 +{
   5.204 +	int errorcode, i, minute, second, frame;
   5.205 +	metatocentry_t *toc_entries;
   5.206 +	metadiscinfo_t	disc_info;
   5.207 +
   5.208 +	/* First, read disc info */
   5.209 +	errorcode = Metadiscinfo(metados_drives[cdrom->id].device[0], &disc_info);
   5.210 +	if (errorcode<0) {
   5.211 +#ifdef DEBUG_CDROM
   5.212 +		fprintf(stderr, "Can not read disc info\n");
   5.213 +#endif
   5.214 +		return -1;
   5.215 +	}
   5.216 +	
   5.217 +	cdrom->numtracks = disc_info.last - disc_info.first + 1;
   5.218 +
   5.219 +	/* Then read toc entries for tracks */
   5.220 +	toc_entries = (metatocentry_t *)malloc(100*sizeof(metatocentry_t));
   5.221 +	if (toc_entries == NULL) {
   5.222 +#ifdef DEBUG_CDROM
   5.223 +		fprintf(stderr, "Can not allocate memory for TOC entries\n");
   5.224 +#endif
   5.225 +		return -1;
   5.226 +	}
   5.227 +
   5.228 +	errorcode = Metagettoc(metados_drives[cdrom->id].device[0], 0, toc_entries);
   5.229 +	if (errorcode<0) {
   5.230 +#ifdef DEBUG_CDROM
   5.231 +		fprintf(stderr, "Can not read TOC\n");
   5.232 +#endif
   5.233 +		free(toc_entries);
   5.234 +		return -1;
   5.235 +	}
   5.236 +
   5.237 +	i=0;
   5.238 +	for (;;) {
   5.239 +		if ((toc_entries[i].track==0) && (toc_entries[i].minute==0) && 
   5.240 +			(toc_entries[i].second==0) && (toc_entries[i].frame==0)
   5.241 +			) {
   5.242 +			break;
   5.243 +		}
   5.244 +
   5.245 +		if (toc_entries[i].track == CDROM_LEADOUT_CDAR) {
   5.246 +			cdrom->track[i].id = CDROM_LEADOUT;
   5.247 +		} else {
   5.248 +			cdrom->track[i].id = toc_entries[i].track;
   5.249 +		}
   5.250 +		if (disc_info.disctype == 0) {
   5.251 +			cdrom->track[i].type = SDL_AUDIO_TRACK;
   5.252 +		} else {
   5.253 +			cdrom->track[i].type = SDL_DATA_TRACK;
   5.254 +		}
   5.255 +		minute = SDL_SYS_CD_BcdToBinary(toc_entries[i].minute);
   5.256 +		second = SDL_SYS_CD_BcdToBinary(toc_entries[i].second);
   5.257 +		frame = SDL_SYS_CD_BcdToBinary(toc_entries[i].frame);
   5.258 +		cdrom->track[i].offset = MSF_TO_FRAMES(minute, second, frame);
   5.259 +
   5.260 +		if ( i > 0 ) {
   5.261 +			cdrom->track[i-1].length = cdrom->track[i].offset - cdrom->track[i-1].offset;
   5.262 +		}
   5.263 +
   5.264 +		++i;
   5.265 +	}
   5.266 +
   5.267 +	free(toc_entries);
   5.268 +	return 0;
   5.269 +}
   5.270 +
   5.271 +static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
   5.272 +{
   5.273 +	int i,okay;
   5.274 +	struct cdrom_tochdr toc;
   5.275 +	struct cdrom_tocentry entry;
   5.276 +
   5.277 +	/* CDAR compatible drive ? */
   5.278 +	if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
   5.279 +		return SDL_SYS_CDGetTOC_CDAR(cdrom);
   5.280 +	}
   5.281 +
   5.282 +	/* Use standard ioctl() */	
   5.283 +	if (SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCHDR, &toc)<0) {
   5.284 +		return -1;
   5.285 +	}
   5.286 +
   5.287 +	cdrom->numtracks = toc.cdth_trk1-toc.cdth_trk0+1;
   5.288 +	if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
   5.289 +		cdrom->numtracks = SDL_MAX_TRACKS;
   5.290 +	}
   5.291 +
   5.292 +	/* Read all the track TOC entries */
   5.293 +	okay=1;
   5.294 +	for ( i=0; i<=cdrom->numtracks; ++i ) {
   5.295 +		if ( i == cdrom->numtracks ) {
   5.296 +			cdrom->track[i].id = CDROM_LEADOUT;
   5.297 +		} else {
   5.298 +			cdrom->track[i].id = toc.cdth_trk0+i;
   5.299 +		}
   5.300 +		entry.cdte_track = cdrom->track[i].id;
   5.301 +		entry.cdte_format = CDROM_MSF;
   5.302 +		if ( SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCENTRY, &entry) < 0 ) {
   5.303 +			okay=0;
   5.304 +			break;
   5.305 +		} else {
   5.306 +			if ( entry.cdte_ctrl & CDROM_DATA_TRACK ) {
   5.307 +				cdrom->track[i].type = SDL_DATA_TRACK;
   5.308 +			} else {
   5.309 +				cdrom->track[i].type = SDL_AUDIO_TRACK;
   5.310 +			}
   5.311 +			cdrom->track[i].offset = MSF_TO_FRAMES(
   5.312 +				entry.cdte_addr.msf.minute,
   5.313 +				entry.cdte_addr.msf.second,
   5.314 +				entry.cdte_addr.msf.frame);
   5.315 +				cdrom->track[i].length = 0;
   5.316 +			if ( i > 0 ) {
   5.317 +				cdrom->track[i-1].length = cdrom->track[i].offset-cdrom->track[i-1].offset;
   5.318 +			}
   5.319 +		}
   5.320 +	}
   5.321 +
   5.322 +	return(okay ? 0 : -1);
   5.323 +}
   5.324 +
   5.325 +/* Get CD-ROM status */
   5.326 +static CDstatus SDL_SYS_CDStatus_CDAR(SDL_CD *cdrom, int *position)
   5.327 +{
   5.328 +	return CD_ERROR;
   5.329 +}
   5.330 +
   5.331 +static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
   5.332 +{
   5.333 +	CDstatus status;
   5.334 +	struct cdrom_tochdr toc;
   5.335 +	struct cdrom_subchnl info;
   5.336 +
   5.337 +	/* CDAR compatible drive ? */
   5.338 +	if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
   5.339 +		return SDL_SYS_CDStatus_CDAR(cdrom, position);
   5.340 +	}
   5.341 +
   5.342 +	/* Standard ioctl */
   5.343 +	info.cdsc_format = CDROM_MSF;
   5.344 +	if ( SDL_SYS_CDioctl(cdrom->id, CDROMSUBCHNL, &info) < 0 ) {
   5.345 +		status = CD_TRAYEMPTY;
   5.346 +	} else {
   5.347 +		switch (info.cdsc_audiostatus) {
   5.348 +			case CDROM_AUDIO_INVALID:
   5.349 +			case CDROM_AUDIO_NO_STATUS:
   5.350 +				/* Try to determine if there's a CD available */
   5.351 +				if (SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCHDR, &toc)==0) {
   5.352 +					status = CD_STOPPED;
   5.353 +				} else {
   5.354 +					status = CD_TRAYEMPTY;
   5.355 +				}
   5.356 +				break;
   5.357 +			case CDROM_AUDIO_COMPLETED:
   5.358 +				status = CD_STOPPED;
   5.359 +				break;
   5.360 +			case CDROM_AUDIO_PLAY:
   5.361 +				status = CD_PLAYING;
   5.362 +				break;
   5.363 +			case CDROM_AUDIO_PAUSED:
   5.364 +				/* Workaround buggy CD-ROM drive */
   5.365 +				if ( info.cdsc_trk == CDROM_LEADOUT ) {
   5.366 +					status = CD_STOPPED;
   5.367 +				} else {
   5.368 +					status = CD_PAUSED;
   5.369 +				}
   5.370 +				break;
   5.371 +			default:
   5.372 +				status = CD_ERROR;
   5.373 +				break;
   5.374 +		}
   5.375 +	}
   5.376 +	if ( position ) {
   5.377 +		if ( status == CD_PLAYING || (status == CD_PAUSED) ) {
   5.378 +			*position = MSF_TO_FRAMES(
   5.379 +					info.cdsc_absaddr.msf.minute,
   5.380 +					info.cdsc_absaddr.msf.second,
   5.381 +					info.cdsc_absaddr.msf.frame);
   5.382 +		} else {
   5.383 +			*position = 0;
   5.384 +		}
   5.385 +	}
   5.386 +	return(status);
   5.387 +}
   5.388 +
   5.389 +/* Start play */
   5.390 +static int SDL_SYS_CDPlay_CDAR(SDL_CD *cdrom, int start, int length)
   5.391 +{
   5.392 +	struct cdrom_msf playtime;
   5.393 +
   5.394 +	FRAMES_TO_MSF(start,
   5.395 +	   &playtime.cdmsf_min0, &playtime.cdmsf_sec0, &playtime.cdmsf_frame0);
   5.396 +	FRAMES_TO_MSF(start+length,
   5.397 +	   &playtime.cdmsf_min1, &playtime.cdmsf_sec1, &playtime.cdmsf_frame1);
   5.398 +
   5.399 +	return Metasetsongtime(metados_drives[cdrom->id].device[0], 0,
   5.400 +		(playtime.cdmsf_min0<<16)|(playtime.cdmsf_sec0<<8)|(playtime.cdmsf_frame0),
   5.401 +		(playtime.cdmsf_min1<<16)|(playtime.cdmsf_sec1<<8)|(playtime.cdmsf_frame1)
   5.402 +	);
   5.403 +}
   5.404 +
   5.405 +static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
   5.406 +{
   5.407 +	struct cdrom_msf playtime;
   5.408 +
   5.409 +	/* CDAR compatible drive ? */
   5.410 +	if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
   5.411 +		return SDL_SYS_CDPlay_CDAR(cdrom, start, length);
   5.412 +	}
   5.413 +
   5.414 +	FRAMES_TO_MSF(start,
   5.415 +	   &playtime.cdmsf_min0, &playtime.cdmsf_sec0, &playtime.cdmsf_frame0);
   5.416 +	FRAMES_TO_MSF(start+length,
   5.417 +	   &playtime.cdmsf_min1, &playtime.cdmsf_sec1, &playtime.cdmsf_frame1);
   5.418 +#ifdef DEBUG_CDROM
   5.419 +  fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n",
   5.420 +	playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0,
   5.421 +	playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1);
   5.422 +#endif
   5.423 +	return(SDL_SYS_CDioctl(cdrom->id, CDROMPLAYMSF, &playtime));
   5.424 +}
   5.425 +
   5.426 +/* Pause play */
   5.427 +static int SDL_SYS_CDPause(SDL_CD *cdrom)
   5.428 +{
   5.429 +	/* CDAR compatible drive ? */
   5.430 +	if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
   5.431 +		return -1;
   5.432 +	}
   5.433 +
   5.434 +	return(SDL_SYS_CDioctl(cdrom->id, CDROMPAUSE, 0));
   5.435 +}
   5.436 +
   5.437 +/* Resume play */
   5.438 +static int SDL_SYS_CDResume(SDL_CD *cdrom)
   5.439 +{
   5.440 +	/* CDAR compatible drive ? */
   5.441 +	if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
   5.442 +		return -1;
   5.443 +	}
   5.444 +
   5.445 +	return(SDL_SYS_CDioctl(cdrom->id, CDROMRESUME, 0));
   5.446 +}
   5.447 +
   5.448 +/* Stop play */
   5.449 +static int SDL_SYS_CDStop(SDL_CD *cdrom)
   5.450 +{
   5.451 +	/* CDAR compatible drive ? */
   5.452 +	if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
   5.453 +		return Metastopaudio(metados_drives[cdrom->id].device[0]);
   5.454 +	}
   5.455 +
   5.456 +	return(SDL_SYS_CDioctl(cdrom->id, CDROMSTOP, 0));
   5.457 +}
   5.458 +
   5.459 +/* Eject the CD-ROM */
   5.460 +static int SDL_SYS_CDEject(SDL_CD *cdrom)
   5.461 +{
   5.462 +	/* CDAR compatible drive ? */
   5.463 +	if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
   5.464 +		return -1;
   5.465 +	}
   5.466 +
   5.467 +	return(SDL_SYS_CDioctl(cdrom->id, CDROMEJECT, 0));
   5.468 +}