annotate src/cdrom/mint/SDL_syscdrom.c @ 724:6b3dfe0198bb

Atari CD-ROM support
author Patrice Mandin <patmandin@gmail.com>
date Sat, 27 Sep 2003 08:20:26 +0000
parents
children cb1208fcd946
rev   line source
724
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1 /*
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
4
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
9
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
13 Library General Public License for more details.
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
14
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
18
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
19 Sam Lantinga
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
20 slouken@libsdl.org
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
21 */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
22
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
23 #ifdef SAVE_RCSID
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
24 static char rcsid =
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
25 "@(#) $Id$";
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
26 #endif
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
27
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
28 /*
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
29 Atari MetaDOS CD-ROM functions
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
30
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
31 Patrice Mandin
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
32 */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
33
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
34 #include <errno.h>
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
35 #include <stdio.h>
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
36 #include <stdlib.h>
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
37 #include <string.h>
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
38
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
39 #include <cdromio.h>
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
40 #include <metados.h>
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
41
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
42 #include "SDL_error.h"
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
43 #include "SDL_cdrom.h"
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
44 #include "SDL_syscdrom.h"
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
45
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
46
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
47 /* The maximum number of CD-ROM drives we'll detect */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
48 #define MAX_DRIVES 32
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
49
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
50 /* Type of CD-ROM drive */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
51 #define DRIVE_TYPE_NOCD -1
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
52 #define DRIVE_TYPE_STANDARD 0
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
53 #define DRIVE_TYPE_CDAR 1
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
54
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
55 typedef struct {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
56 int type; /* Standard, or old CDAR-type CD drive ? */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
57 unsigned char device[3]; /* Physical device letter + ':' + '\0' */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
58 metaopen_t metaopen; /* Infos on opened drive */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
59 } metados_drive_t;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
60
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
61 static metados_drive_t metados_drives[MAX_DRIVES];
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
62
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
63 /* The system-dependent CD control functions */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
64 static const char *SDL_SYS_CDName(int drive);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
65 static int SDL_SYS_CDOpen(int drive);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
66 static void SDL_SYS_CDClose(SDL_CD *cdrom);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
67 static int SDL_SYS_CDioctl(int id, int command, void *arg);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
68
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
69 /* Commands using ioctl() */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
70 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
71 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
72 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
73 static int SDL_SYS_CDPause(SDL_CD *cdrom);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
74 static int SDL_SYS_CDResume(SDL_CD *cdrom);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
75 static int SDL_SYS_CDStop(SDL_CD *cdrom);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
76 static int SDL_SYS_CDEject(SDL_CD *cdrom);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
77
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
78 /* Commands using Meta*() CDAR functions */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
79 static int SDL_SYS_CD_BcdToBinary(int value);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
80 static int SDL_SYS_CDGetTOC_CDAR(SDL_CD *cdrom);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
81 static CDstatus SDL_SYS_CDStatus_CDAR(SDL_CD *cdrom, int *position);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
82
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
83 int SDL_SYS_CDInit(void)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
84 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
85 metainit_t metainit={0,0,0,0};
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
86 metaopen_t metaopen;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
87 int i, handle;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
88
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
89 Metainit(&metainit);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
90 if (metainit.version == NULL) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
91 #ifdef DEBUG_CDROM
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
92 fprintf(stderr, "MetaDOS not installed\n");
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
93 #endif
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
94 return -1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
95 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
96
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
97 if (metainit.drives_map == 0) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
98 #ifdef DEBUG_CDROM
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
99 fprintf(stderr, "No MetaDOS devices present\n");
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
100 #endif
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
101 return -1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
102 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
103
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
104 SDL_numcds = 0;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
105
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
106 for (i='A'; i<='Z'; i++) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
107 metados_drives[SDL_numcds].type = DRIVE_TYPE_NOCD;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
108 metados_drives[SDL_numcds].device[0] = 0;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
109 metados_drives[SDL_numcds].device[1] = ':';
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
110 metados_drives[SDL_numcds].device[2] = 0;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
111
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
112 if (metainit.drives_map & (1<<(i-'A'))) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
113 handle = Metaopen(i, &metaopen);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
114 if (handle == 0) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
115
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
116 if ( (metaopen.name[0]=='C') && (metaopen.name[1]=='D') &&
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
117 (metaopen.name[2]=='A') && (metaopen.name[3]=='R')) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
118 /* Drive compatible with CDAR */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
119 metados_drives[SDL_numcds].type = DRIVE_TYPE_CDAR;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
120 metados_drives[SDL_numcds].device[0] = i;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
121 ++SDL_numcds;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
122 } else {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
123 /* Check for a CD-ROM device */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
124 if ((Metastatus(i, NULL) & 0x7fff) >= 0) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
125 /* Drive compatible with new ioctl functions */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
126 metados_drives[SDL_numcds].type = DRIVE_TYPE_STANDARD;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
127 metados_drives[SDL_numcds].device[0] = i;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
128 ++SDL_numcds;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
129 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
130 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
131
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
132 Metaclose(i);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
133 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
134 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
135 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
136
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
137 /* Fill in our driver capabilities */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
138 SDL_CDcaps.Name = SDL_SYS_CDName;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
139 SDL_CDcaps.Open = SDL_SYS_CDOpen;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
140 SDL_CDcaps.Close = SDL_SYS_CDClose;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
141
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
142 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
143 SDL_CDcaps.Status = SDL_SYS_CDStatus;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
144 SDL_CDcaps.Play = SDL_SYS_CDPlay;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
145 SDL_CDcaps.Pause = SDL_SYS_CDPause;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
146 SDL_CDcaps.Resume = SDL_SYS_CDResume;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
147 SDL_CDcaps.Stop = SDL_SYS_CDStop;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
148 SDL_CDcaps.Eject = SDL_SYS_CDEject;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
149
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
150 return 0;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
151 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
152
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
153 void SDL_SYS_CDQuit(void)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
154 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
155 SDL_numcds = 0;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
156 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
157
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
158 static const char *SDL_SYS_CDName(int drive)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
159 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
160 return(metados_drives[drive].device);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
161 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
162
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
163 static int SDL_SYS_CDOpen(int drive)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
164 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
165 int handle;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
166
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
167 handle = Metaopen(metados_drives[drive].device[0], &(metados_drives[drive].metaopen));
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
168 if (handle == 0) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
169 return drive;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
170 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
171
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
172 return -1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
173 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
174
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
175 static void SDL_SYS_CDClose(SDL_CD *cdrom)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
176 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
177 Metaclose(metados_drives[cdrom->id].device[0]);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
178 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
179
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
180 static int SDL_SYS_CDioctl(int id, int command, void *arg)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
181 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
182 int retval;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
183
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
184 retval = Metaioctl(metados_drives[id].device[0], METADOS_IOCTL_MAGIC, command, arg);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
185 if ( retval < 0 ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
186 SDL_SetError("ioctl() error: %s", strerror(errno));
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
187 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
188 return(retval);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
189 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
190
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
191 static int SDL_SYS_CD_BcdToBinary(int value)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
192 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
193 int tmp;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
194
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
195 tmp = (value>>4) & 0xf;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
196 return (tmp*10)+(value & 0xf);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
197 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
198
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
199 static int SDL_SYS_CDGetTOC_CDAR(SDL_CD *cdrom)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
200 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
201 int errorcode, i, minute, second, frame;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
202 metatocentry_t *toc_entries;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
203 metadiscinfo_t disc_info;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
204
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
205 /* First, read disc info */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
206 errorcode = Metadiscinfo(metados_drives[cdrom->id].device[0], &disc_info);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
207 if (errorcode<0) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
208 #ifdef DEBUG_CDROM
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
209 fprintf(stderr, "Can not read disc info\n");
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
210 #endif
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
211 return -1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
212 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
213
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
214 cdrom->numtracks = disc_info.last - disc_info.first + 1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
215
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
216 /* Then read toc entries for tracks */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
217 toc_entries = (metatocentry_t *)malloc(100*sizeof(metatocentry_t));
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
218 if (toc_entries == NULL) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
219 #ifdef DEBUG_CDROM
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
220 fprintf(stderr, "Can not allocate memory for TOC entries\n");
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
221 #endif
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
222 return -1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
223 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
224
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
225 errorcode = Metagettoc(metados_drives[cdrom->id].device[0], 0, toc_entries);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
226 if (errorcode<0) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
227 #ifdef DEBUG_CDROM
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
228 fprintf(stderr, "Can not read TOC\n");
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
229 #endif
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
230 free(toc_entries);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
231 return -1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
232 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
233
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
234 i=0;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
235 for (;;) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
236 if ((toc_entries[i].track==0) && (toc_entries[i].minute==0) &&
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
237 (toc_entries[i].second==0) && (toc_entries[i].frame==0)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
238 ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
239 break;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
240 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
241
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
242 if (toc_entries[i].track == CDROM_LEADOUT_CDAR) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
243 cdrom->track[i].id = CDROM_LEADOUT;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
244 } else {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
245 cdrom->track[i].id = toc_entries[i].track;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
246 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
247 if (disc_info.disctype == 0) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
248 cdrom->track[i].type = SDL_AUDIO_TRACK;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
249 } else {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
250 cdrom->track[i].type = SDL_DATA_TRACK;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
251 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
252 minute = SDL_SYS_CD_BcdToBinary(toc_entries[i].minute);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
253 second = SDL_SYS_CD_BcdToBinary(toc_entries[i].second);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
254 frame = SDL_SYS_CD_BcdToBinary(toc_entries[i].frame);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
255 cdrom->track[i].offset = MSF_TO_FRAMES(minute, second, frame);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
256
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
257 if ( i > 0 ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
258 cdrom->track[i-1].length = cdrom->track[i].offset - cdrom->track[i-1].offset;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
259 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
260
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
261 ++i;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
262 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
263
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
264 free(toc_entries);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
265 return 0;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
266 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
267
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
268 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
269 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
270 int i,okay;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
271 struct cdrom_tochdr toc;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
272 struct cdrom_tocentry entry;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
273
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
274 /* CDAR compatible drive ? */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
275 if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
276 return SDL_SYS_CDGetTOC_CDAR(cdrom);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
277 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
278
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
279 /* Use standard ioctl() */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
280 if (SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCHDR, &toc)<0) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
281 return -1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
282 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
283
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
284 cdrom->numtracks = toc.cdth_trk1-toc.cdth_trk0+1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
285 if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
286 cdrom->numtracks = SDL_MAX_TRACKS;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
287 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
288
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
289 /* Read all the track TOC entries */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
290 okay=1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
291 for ( i=0; i<=cdrom->numtracks; ++i ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
292 if ( i == cdrom->numtracks ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
293 cdrom->track[i].id = CDROM_LEADOUT;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
294 } else {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
295 cdrom->track[i].id = toc.cdth_trk0+i;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
296 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
297 entry.cdte_track = cdrom->track[i].id;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
298 entry.cdte_format = CDROM_MSF;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
299 if ( SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCENTRY, &entry) < 0 ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
300 okay=0;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
301 break;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
302 } else {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
303 if ( entry.cdte_ctrl & CDROM_DATA_TRACK ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
304 cdrom->track[i].type = SDL_DATA_TRACK;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
305 } else {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
306 cdrom->track[i].type = SDL_AUDIO_TRACK;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
307 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
308 cdrom->track[i].offset = MSF_TO_FRAMES(
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
309 entry.cdte_addr.msf.minute,
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
310 entry.cdte_addr.msf.second,
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
311 entry.cdte_addr.msf.frame);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
312 cdrom->track[i].length = 0;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
313 if ( i > 0 ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
314 cdrom->track[i-1].length = cdrom->track[i].offset-cdrom->track[i-1].offset;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
315 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
316 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
317 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
318
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
319 return(okay ? 0 : -1);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
320 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
321
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
322 /* Get CD-ROM status */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
323 static CDstatus SDL_SYS_CDStatus_CDAR(SDL_CD *cdrom, int *position)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
324 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
325 return CD_ERROR;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
326 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
327
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
328 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
329 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
330 CDstatus status;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
331 struct cdrom_tochdr toc;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
332 struct cdrom_subchnl info;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
333
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
334 /* CDAR compatible drive ? */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
335 if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
336 return SDL_SYS_CDStatus_CDAR(cdrom, position);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
337 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
338
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
339 /* Standard ioctl */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
340 info.cdsc_format = CDROM_MSF;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
341 if ( SDL_SYS_CDioctl(cdrom->id, CDROMSUBCHNL, &info) < 0 ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
342 status = CD_TRAYEMPTY;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
343 } else {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
344 switch (info.cdsc_audiostatus) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
345 case CDROM_AUDIO_INVALID:
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
346 case CDROM_AUDIO_NO_STATUS:
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
347 /* Try to determine if there's a CD available */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
348 if (SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCHDR, &toc)==0) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
349 status = CD_STOPPED;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
350 } else {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
351 status = CD_TRAYEMPTY;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
352 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
353 break;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
354 case CDROM_AUDIO_COMPLETED:
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
355 status = CD_STOPPED;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
356 break;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
357 case CDROM_AUDIO_PLAY:
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
358 status = CD_PLAYING;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
359 break;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
360 case CDROM_AUDIO_PAUSED:
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
361 /* Workaround buggy CD-ROM drive */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
362 if ( info.cdsc_trk == CDROM_LEADOUT ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
363 status = CD_STOPPED;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
364 } else {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
365 status = CD_PAUSED;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
366 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
367 break;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
368 default:
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
369 status = CD_ERROR;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
370 break;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
371 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
372 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
373 if ( position ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
374 if ( status == CD_PLAYING || (status == CD_PAUSED) ) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
375 *position = MSF_TO_FRAMES(
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
376 info.cdsc_absaddr.msf.minute,
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
377 info.cdsc_absaddr.msf.second,
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
378 info.cdsc_absaddr.msf.frame);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
379 } else {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
380 *position = 0;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
381 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
382 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
383 return(status);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
384 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
385
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
386 /* Start play */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
387 static int SDL_SYS_CDPlay_CDAR(SDL_CD *cdrom, int start, int length)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
388 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
389 struct cdrom_msf playtime;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
390
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
391 FRAMES_TO_MSF(start,
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
392 &playtime.cdmsf_min0, &playtime.cdmsf_sec0, &playtime.cdmsf_frame0);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
393 FRAMES_TO_MSF(start+length,
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
394 &playtime.cdmsf_min1, &playtime.cdmsf_sec1, &playtime.cdmsf_frame1);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
395
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
396 return Metasetsongtime(metados_drives[cdrom->id].device[0], 0,
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
397 (playtime.cdmsf_min0<<16)|(playtime.cdmsf_sec0<<8)|(playtime.cdmsf_frame0),
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
398 (playtime.cdmsf_min1<<16)|(playtime.cdmsf_sec1<<8)|(playtime.cdmsf_frame1)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
399 );
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
400 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
401
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
402 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
403 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
404 struct cdrom_msf playtime;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
405
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
406 /* CDAR compatible drive ? */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
407 if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
408 return SDL_SYS_CDPlay_CDAR(cdrom, start, length);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
409 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
410
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
411 FRAMES_TO_MSF(start,
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
412 &playtime.cdmsf_min0, &playtime.cdmsf_sec0, &playtime.cdmsf_frame0);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
413 FRAMES_TO_MSF(start+length,
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
414 &playtime.cdmsf_min1, &playtime.cdmsf_sec1, &playtime.cdmsf_frame1);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
415 #ifdef DEBUG_CDROM
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
416 fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n",
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
417 playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0,
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
418 playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
419 #endif
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
420 return(SDL_SYS_CDioctl(cdrom->id, CDROMPLAYMSF, &playtime));
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
421 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
422
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
423 /* Pause play */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
424 static int SDL_SYS_CDPause(SDL_CD *cdrom)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
425 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
426 /* CDAR compatible drive ? */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
427 if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
428 return -1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
429 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
430
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
431 return(SDL_SYS_CDioctl(cdrom->id, CDROMPAUSE, 0));
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
432 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
433
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
434 /* Resume play */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
435 static int SDL_SYS_CDResume(SDL_CD *cdrom)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
436 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
437 /* CDAR compatible drive ? */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
438 if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
439 return -1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
440 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
441
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
442 return(SDL_SYS_CDioctl(cdrom->id, CDROMRESUME, 0));
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
443 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
444
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
445 /* Stop play */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
446 static int SDL_SYS_CDStop(SDL_CD *cdrom)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
447 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
448 /* CDAR compatible drive ? */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
449 if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
450 return Metastopaudio(metados_drives[cdrom->id].device[0]);
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
451 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
452
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
453 return(SDL_SYS_CDioctl(cdrom->id, CDROMSTOP, 0));
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
454 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
455
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
456 /* Eject the CD-ROM */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
457 static int SDL_SYS_CDEject(SDL_CD *cdrom)
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
458 {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
459 /* CDAR compatible drive ? */
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
460 if (metados_drives[cdrom->id].type == DRIVE_TYPE_CDAR) {
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
461 return -1;
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
462 }
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
463
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
464 return(SDL_SYS_CDioctl(cdrom->id, CDROMEJECT, 0));
6b3dfe0198bb Atari CD-ROM support
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
465 }