Mercurial > sdl-ios-xcode
annotate src/cdrom/SDL_cdrom.c @ 4157:baf615f9f2a0 SDL-1.2
Date: Thu, 16 Oct 2008 20:27:34 +0400
From: "Ilya Kasnacheev" <ilya.kasnacheev@gmail.com>
To: sdl@lists.libsdl.org
Subject: [SDL] SDL for Windows CE: a few GAPI patches
Hi *!
I've just ported a POWDER roguelike ( http://www.zincland.com/powder/ ) to
Windows CE (PDAs, Windows Mobile/Pocket PC). To do that, I had to get libsdl
working. Thanks for the awesome project files, it built without a hitch.
Nevertheless, I've found quite a few bugs in Windows CE (GAPI) SDL
implementation, which I've solved and now present as a serie of patches.
I'll try carefully annotate them. Please annotate them so I can work
toward accepting
them into the main source tree since without them SDL isn't really working on
Windows CE (I wonder why nobody fixed them before, btw: why isn't SDL popular as
a way to develop Windows CE games? Where are no ports?)
These changes can't be considered flawless, but they can be considered working
because I've yet to hear complains about things I fixed and POWDER build for
Windows CE is now considered stable.
Note: my comments start with !!, delete them before applying.
diff -bru SDL-1.2.13/src/video/gapi/SDL_gapivideo.c
SDL-1.2.13-new/src/video/gapi/SDL_gapivideo.c
--- SDL-1.2.13/src/video/gapi/SDL_gapivideo.c 2007-12-31
07:48:00.000000000 +0300
+++ SDL-1.2.13-new/src/video/gapi/SDL_gapivideo.c 2008-10-16
20:02:11.000000000 +0400
@@ -643,6 +643,7 @@
}
gapi->userOrientation = SDL_ORIENTATION_UP;
+ gapi->systemOrientation = SDL_ORIENTATION_UP;
video->flags = SDL_FULLSCREEN; /* Clear flags, GAPI supports
fullscreen only */
/* GAPI or VGA? */
@@ -661,18 +662,21 @@
}
/* detect user landscape mode */
- if( (width > height) && (GetSystemMetrics(SM_CXSCREEN) <
GetSystemMetrics(SM_CYSCREEN)))
+ if( (width > height) && (gapi->gxProperties.cxWidth <
gapi->gxProperties.cyHeight))
gapi->userOrientation = SDL_ORIENTATION_RIGHT;
+ if(GetSystemMetrics(SM_CYSCREEN) < GetSystemMetrics(SM_CXSCREEN))
+ gapi->systemOrientation = SDL_ORIENTATION_RIGHT;
+
/* shall we apply hires fix? for example when we do not use
hires resource */
gapi->hiresFix = 0;
- if( gapi->userOrientation == SDL_ORIENTATION_RIGHT )
+ if( gapi->systemOrientation == gapi->userOrientation )
{
- if( (width > GetSystemMetrics(SM_CYSCREEN)) || (height
> GetSystemMetrics(SM_CXSCREEN)))
+ if( (width > GetSystemMetrics(SM_CXSCREEN)) || (height
> GetSystemMetrics(SM_CYSCREEN)))
gapi->hiresFix = 1;
} else
- if( (width > GetSystemMetrics(SM_CXSCREEN)) || (height
> GetSystemMetrics(SM_CYSCREEN)))
- if( !((width == GetSystemMetrics(SM_CYSCREEN))
&& (height == GetSystemMetrics(SM_CXSCREEN)))) // user portrait,
device landscape
+ if( (width > GetSystemMetrics(SM_CYSCREEN)) || (height
> GetSystemMetrics(SM_CXSCREEN)))
+// if( !((width == gapi->gxProperties.cyHeight)
&& (height == gapi->gxProperties.cxWidth))) // user portrait, device
landscape
gapi->hiresFix = 1;
switch( gapi->userOrientation )
!! It used to query system metrics which return dimensions according to screen
!! orientation, which can really be portrait, left landscape or right landscape.
!! This is presumably incorrect because we couldn't care less about user mode
!! dimensions - all we want are the GAPI framebuffer dimensions, which
only match
!! user dimensions in one of possible orientations.
!! There's a fair dose of cargo cult programming involved in this fix, but it
!! used to work only in one orientation (portrait for PDAs, where frame-buffer
!! have same orientation as user screen), and now it works on all orientations.
@@ -742,21 +746,30 @@
WIN_FlushMessageQueue();
/* Open GAPI display */
- if( !gapi->useVga && this->hidden->useGXOpenDisplay )
+ if( !gapi->useVga && this->hidden->useGXOpenDisplay &&
!this->hidden->alreadyGXOpened )
+ {
+ this->hidden->alreadyGXOpened = 1;
if( !gapi->gxFunc.GXOpenDisplay(SDL_Window, GX_FULLSCREEN) )
{
SDL_SetError("Couldn't initialize GAPI");
return(NULL);
}
+ }
#if REPORT_VIDEO_INFO
printf("Video properties:\n");
printf("display bpp: %d\n", gapi->gxProperties.cBPP);
printf("display width: %d\n", gapi->gxProperties.cxWidth);
printf("display height: %d\n", gapi->gxProperties.cyHeight);
+ printf("system display width: %d\n", GetSystemMetrics(SM_CXSCREEN));
+ printf("system display height: %d\n", GetSystemMetrics(SM_CYSCREEN));
printf("x pitch: %d\n", gapi->gxProperties.cbxPitch);
printf("y pitch: %d\n", gapi->gxProperties.cbyPitch);
printf("gapi flags: 0x%x\n", gapi->gxProperties.ffFormat);
+ printf("user orientation: %d\n", gapi->userOrientation);
+ printf("system orientation: %d\n", gapi->userOrientation);
+ printf("gapi orientation: %d\n", gapi->gapiOrientation);
+
if( !gapi->useVga && this->hidden->useGXOpenDisplay && gapi->needUpdate)
{
!! Previous version used to call gapi->gxFunc.GXOpenDisplay each time the video
!! mode would be changed. You shouldn't, because this call has a
meaning "Lock the
!! GAPI framebuffer, designate it as busy", so the second call will fail (it is
!! already locked/busy).
!! Testing might not find that because most programs set up the video mode only
!! once, but POWDER does this once in a while, so it crashed when in
320x240 mode
!! (640x480 mode doesn't use that code, it worked fine).
diff -bru SDL-1.2.13/src/video/gapi/SDL_gapivideo.h
SDL-1.2.13-new/src/video/gapi/SDL_gapivideo.h
--- SDL-1.2.13/src/video/gapi/SDL_gapivideo.h 2007-12-31
07:48:00.000000000 +0300
+++ SDL-1.2.13-new/src/video/gapi/SDL_gapivideo.h 2008-10-16
20:02:11.000000000 +0400
@@ -132,12 +132,17 @@
#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */
int SDL_nummodes[NUM_MODELISTS];
SDL_Rect **SDL_modelist[NUM_MODELISTS];
+ // The orientation of the video mode user wants to get
+ // Probably restricted to UP and RIGHT
enum SDL_ScreenOrientation userOrientation;
int invert;
char hiresFix; // using hires mode without defining hires resource
// --------------
int useGXOpenDisplay; /* use GXOpenDispplay */
+ int alreadyGXOpened;
int w, h;
+ // The orientation of GAPI framebuffer.
+ // Never changes on the same device.
enum SDL_ScreenOrientation gapiOrientation;
void *buffer; // may be 8, 16, 24, 32 bpp
@@ -153,6 +158,10 @@
int startOffset; // in bytes
int useVga;
int suspended; // do not pu anything into video memory
+ // The orientation of the system, as defined by SM_CXSCREEN
and SM_CYSCREEN
+ // User can change it by using 'screen layout' in system options
+ // Restricted to UP or RIGHT
+ enum SDL_ScreenOrientation systemOrientation;
};
!! This is a flag variable, see the previous comment
!! And yet another orientation: now we have to keep three of them in mind.
diff -bru SDL-1.2.13/src/video/wincommon/SDL_sysevents.c
SDL-1.2.13-new/src/video/wincommon/SDL_sysevents.c
--- SDL-1.2.13/src/video/wincommon/SDL_sysevents.c 2007-12-31
07:48:02.000000000 +0300
+++ SDL-1.2.13-new/src/video/wincommon/SDL_sysevents.c 2008-10-16
20:02:12.000000000 +0400
@@ -160,10 +160,22 @@
#endif */
}
break;
+ // FIXME: Older version used just SDL_VideoSurface->(w, h)
+ // w and h are "clipped" while x and y are "raw", which caused
+ // x in former and y in latter case to be clipped in a
wrong direction,
+ // thus offsetting the coordinate on 2 x clip pixels
+ // (like, 128 for 640 -> 512 clipping).
+ // We will now try to extract and use raw values.
+ // The way to do that RIGHT is do
(orientation-dependent) clipping before
+ // doing this transform, but it's hardly possible.
+
+ // SEE SDL_mouse.c /ClipOffset to understand these calculations.
case SDL_ORIENTATION_RIGHT:
if (!SDL_VideoSurface)
break;
- rotatedX = SDL_VideoSurface->w - *y;
+ rotatedX = (2 *
((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/
+ SDL_VideoSurface->format->BytesPerPixel))
+ + SDL_VideoSurface->w - *y;
rotatedY = *x;
*x = rotatedX;
*y = rotatedY;
@@ -172,7 +184,8 @@
if (!SDL_VideoSurface)
break;
rotatedX = *y;
- rotatedY = SDL_VideoSurface->h - *x;
+ rotatedY = (2 *
(SDL_VideoSurface->offset/SDL_VideoSurface->pitch))
+ + SDL_VideoSurface->h - *x;
*x = rotatedX;
*y = rotatedY;
break;
!! That's the trickest part, hence the long comment.
!! GAPI would really support only 320x240 or 640x480 mode, if application
!! requested the different screen size (as POWDER did, wishing
256x192), then SDL
!! is going to grab the first mode that fits the requested, and pad the screen
!! with black bars (as they do with wide-screen films).
!! It would also get, say, 240x320 mode, and to turn it into 256x192 it would
!! need to rotate mouse clicks.
!! It worked, but one bug slipped through: it would receive mouse clicks
!! unpadded, then rotate them, and then pad the black bars. The
problem is: rotate
!! is done by GAPI driver while padding is done by SDL core. SDL core
doesn't know
!! anything about rotating, so it would pad one of dimensions incorrectly.
I understand that some of my claims (or code) might seem unbacked, but you can
always grab the POWDER binary, compile your own libsdl with one or more of
those fixes turned off, and see how weird it would misbehave. I can even supply
you with those custom builds of libsdl if you don't want to set up the build
environment for windows ce, you'll just need a PDA or a smartphone with it.
I plan to take care of SDL on Windows CE as long as I maintain the POWDER port.
POWDER is good for that because it:
Employs both padded (with centered image, black bars) and unpadded
(image occupies full screen) graphics; initializes video more than
once; uses both 320x240 and 640x480 video; uses both stylus and
buttons.
There's still a list of unresolved issues which I'm planning to fix:
1) Arrow buttons on PDA return weird scancodes compared to PC, this
caused the game to misbehave before I've fixed that. You can see it on
those diagrams:
http://wrar.name/upload/powder-htc.png
http://wrar.name/upload/powder-pda.png
2) SDL (or underlying windows) doesn't care to rotate arrow presses
when we're in a low-res GAPI mode, but it will rotate them in VGA mode
(because of different screen orientations, the same arrow buttons can
suddently mean different directions). Solution: we should stick to
GAPI user orientation (the orientation the program supposedly wants)
and rotate the keys on our own.
_______________________________________________
SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 07 Nov 2008 04:15:36 +0000 |
parents | d910939febfa |
children | 782fd950bd46 c121d94672cb a1b03ba2fcd0 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* This is the CD-audio control API for Simple DirectMedia Layer */ | |
25 | |
26 #include "SDL_cdrom.h" | |
27 #include "SDL_syscdrom.h" | |
28 | |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
29 #if !defined(__MACOS__) |
0 | 30 #define CLIP_FRAMES 10 /* Some CD-ROMs won't go all the way */ |
31 #endif | |
32 | |
33 static int SDL_cdinitted = 0; | |
34 static SDL_CD *default_cdrom; | |
35 | |
36 /* The system level CD-ROM control functions */ | |
37 struct CDcaps SDL_CDcaps = { | |
38 NULL, /* Name */ | |
39 NULL, /* Open */ | |
40 NULL, /* GetTOC */ | |
41 NULL, /* Status */ | |
42 NULL, /* Play */ | |
43 NULL, /* Pause */ | |
44 NULL, /* Resume */ | |
45 NULL, /* Stop */ | |
46 NULL, /* Eject */ | |
47 NULL, /* Close */ | |
48 }; | |
49 int SDL_numcds; | |
50 | |
51 int SDL_CDROMInit(void) | |
52 { | |
53 int retval; | |
54 | |
55 SDL_numcds = 0; | |
56 retval = SDL_SYS_CDInit(); | |
57 if ( retval == 0 ) { | |
58 SDL_cdinitted = 1; | |
59 } | |
60 default_cdrom = NULL; | |
61 return(retval); | |
62 } | |
63 | |
64 /* Check to see if the CD-ROM subsystem has been initialized */ | |
65 static int CheckInit(int check_cdrom, SDL_CD **cdrom) | |
66 { | |
67 int okay; | |
68 | |
69 okay = SDL_cdinitted; | |
70 if ( check_cdrom && (*cdrom == NULL) ) { | |
71 *cdrom = default_cdrom; | |
72 if ( *cdrom == NULL ) { | |
73 SDL_SetError("CD-ROM not opened"); | |
74 okay = 0; | |
75 } | |
76 } | |
77 if ( ! SDL_cdinitted ) { | |
78 SDL_SetError("CD-ROM subsystem not initialized"); | |
79 } | |
80 return(okay); | |
81 } | |
82 | |
83 int SDL_CDNumDrives(void) | |
84 { | |
85 if ( ! CheckInit(0, NULL) ) { | |
86 return(-1); | |
87 } | |
88 return(SDL_numcds); | |
89 } | |
90 | |
91 const char *SDL_CDName(int drive) | |
92 { | |
93 if ( ! CheckInit(0, NULL) ) { | |
94 return(NULL); | |
95 } | |
96 if ( drive >= SDL_numcds ) { | |
97 SDL_SetError("Invalid CD-ROM drive index"); | |
98 return(NULL); | |
99 } | |
100 if ( SDL_CDcaps.Name ) { | |
101 return(SDL_CDcaps.Name(drive)); | |
102 } else { | |
103 return(""); | |
104 } | |
105 } | |
106 | |
107 SDL_CD *SDL_CDOpen(int drive) | |
108 { | |
109 struct SDL_CD *cdrom; | |
110 | |
111 if ( ! CheckInit(0, NULL) ) { | |
112 return(NULL); | |
113 } | |
114 if ( drive >= SDL_numcds ) { | |
115 SDL_SetError("Invalid CD-ROM drive index"); | |
116 return(NULL); | |
117 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
118 cdrom = (SDL_CD *)SDL_malloc(sizeof(*cdrom)); |
0 | 119 if ( cdrom == NULL ) { |
120 SDL_OutOfMemory(); | |
121 return(NULL); | |
122 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
123 SDL_memset(cdrom, 0, sizeof(*cdrom)); |
0 | 124 cdrom->id = SDL_CDcaps.Open(drive); |
125 if ( cdrom->id < 0 ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
126 SDL_free(cdrom); |
0 | 127 return(NULL); |
128 } | |
129 default_cdrom = cdrom; | |
130 return(cdrom); | |
131 } | |
132 | |
133 CDstatus SDL_CDStatus(SDL_CD *cdrom) | |
134 { | |
135 CDstatus status; | |
136 int i; | |
137 Uint32 position; | |
138 | |
139 /* Check if the CD-ROM subsystem has been initialized */ | |
140 if ( ! CheckInit(1, &cdrom) ) { | |
141 return(CD_ERROR); | |
142 } | |
143 | |
144 /* Get the current status of the drive */ | |
145 cdrom->numtracks = 0; | |
146 cdrom->cur_track = 0; | |
147 cdrom->cur_frame = 0; | |
148 status = SDL_CDcaps.Status(cdrom, &i); | |
149 position = (Uint32)i; | |
150 cdrom->status = status; | |
151 | |
152 /* Get the table of contents, if there's a CD available */ | |
153 if ( CD_INDRIVE(status) ) { | |
154 if ( SDL_CDcaps.GetTOC(cdrom) < 0 ) { | |
155 status = CD_ERROR; | |
156 } | |
157 /* If the drive is playing, get current play position */ | |
158 if ( (status == CD_PLAYING) || (status == CD_PAUSED) ) { | |
159 for ( i=1; cdrom->track[i].offset <= position; ++i ) { | |
160 /* Keep looking */; | |
161 } | |
162 #ifdef DEBUG_CDROM | |
163 fprintf(stderr, "Current position: %d, track = %d (offset is %d)\n", | |
164 position, i-1, cdrom->track[i-1].offset); | |
165 #endif | |
166 cdrom->cur_track = i-1; | |
167 position -= cdrom->track[cdrom->cur_track].offset; | |
168 cdrom->cur_frame = position; | |
169 } | |
170 } | |
171 return(status); | |
172 } | |
173 | |
174 int SDL_CDPlayTracks(SDL_CD *cdrom, | |
175 int strack, int sframe, int ntracks, int nframes) | |
176 { | |
177 int etrack, eframe; | |
178 int start, length; | |
179 | |
180 /* Check if the CD-ROM subsystem has been initialized */ | |
181 if ( ! CheckInit(1, &cdrom) ) { | |
182 return(CD_ERROR); | |
183 } | |
184 | |
185 /* Determine the starting and ending tracks */ | |
186 if ( (strack < 0) || (strack >= cdrom->numtracks) ) { | |
187 SDL_SetError("Invalid starting track"); | |
188 return(CD_ERROR); | |
189 } | |
190 if ( ! ntracks && ! nframes ) { | |
191 etrack = cdrom->numtracks; | |
192 eframe = 0; | |
193 } else { | |
194 etrack = strack+ntracks; | |
195 if ( etrack == strack ) { | |
196 eframe = sframe + nframes; | |
197 } else { | |
198 eframe = nframes; | |
199 } | |
200 } | |
201 if ( etrack > cdrom->numtracks ) { | |
202 SDL_SetError("Invalid play length"); | |
203 return(CD_ERROR); | |
204 } | |
205 | |
206 /* Skip data tracks and verify frame offsets */ | |
207 while ( (strack <= etrack) && | |
208 (cdrom->track[strack].type == SDL_DATA_TRACK) ) { | |
209 ++strack; | |
210 } | |
211 if ( sframe >= (int)cdrom->track[strack].length ) { | |
212 SDL_SetError("Invalid starting frame for track %d", strack); | |
213 return(CD_ERROR); | |
214 } | |
215 while ( (etrack > strack) && | |
216 (cdrom->track[etrack-1].type == SDL_DATA_TRACK) ) { | |
217 --etrack; | |
218 } | |
219 if ( eframe > (int)cdrom->track[etrack].length ) { | |
220 SDL_SetError("Invalid ending frame for track %d", etrack); | |
221 return(CD_ERROR); | |
222 } | |
223 | |
224 /* Determine start frame and play length */ | |
225 start = (cdrom->track[strack].offset+sframe); | |
226 length = (cdrom->track[etrack].offset+eframe)-start; | |
227 #ifdef CLIP_FRAMES | |
228 /* I've never seen this necessary, but xmcd does it.. */ | |
229 length -= CLIP_FRAMES; /* CLIP_FRAMES == 10 */ | |
230 #endif | |
231 if ( length < 0 ) { | |
232 return(0); | |
233 } | |
234 | |
235 /* Play! */ | |
236 #ifdef DEBUG_CDROM | |
237 fprintf(stderr, "Playing %d frames at offset %d\n", length, start); | |
238 #endif | |
239 return(SDL_CDcaps.Play(cdrom, start, length)); | |
240 } | |
241 | |
242 int SDL_CDPlay(SDL_CD *cdrom, int sframe, int length) | |
243 { | |
244 /* Check if the CD-ROM subsystem has been initialized */ | |
245 if ( ! CheckInit(1, &cdrom) ) { | |
246 return(CD_ERROR); | |
247 } | |
248 | |
249 return(SDL_CDcaps.Play(cdrom, sframe, length)); | |
250 } | |
251 | |
252 int SDL_CDPause(SDL_CD *cdrom) | |
253 { | |
254 CDstatus status; | |
255 int retval; | |
256 | |
257 /* Check if the CD-ROM subsystem has been initialized */ | |
258 if ( ! CheckInit(1, &cdrom) ) { | |
259 return(CD_ERROR); | |
260 } | |
261 | |
262 status = SDL_CDcaps.Status(cdrom, NULL); | |
263 switch (status) { | |
264 case CD_PLAYING: | |
265 retval = SDL_CDcaps.Pause(cdrom); | |
266 break; | |
267 default: | |
268 retval = 0; | |
269 break; | |
270 } | |
271 return(retval); | |
272 } | |
273 | |
274 int SDL_CDResume(SDL_CD *cdrom) | |
275 { | |
276 CDstatus status; | |
277 int retval; | |
278 | |
279 /* Check if the CD-ROM subsystem has been initialized */ | |
280 if ( ! CheckInit(1, &cdrom) ) { | |
281 return(CD_ERROR); | |
282 } | |
283 | |
284 status = SDL_CDcaps.Status(cdrom, NULL); | |
285 switch (status) { | |
286 case CD_PAUSED: | |
287 retval = SDL_CDcaps.Resume(cdrom); | |
288 default: | |
289 retval = 0; | |
290 break; | |
291 } | |
292 return(retval); | |
293 } | |
294 | |
295 int SDL_CDStop(SDL_CD *cdrom) | |
296 { | |
297 CDstatus status; | |
298 int retval; | |
299 | |
300 /* Check if the CD-ROM subsystem has been initialized */ | |
301 if ( ! CheckInit(1, &cdrom) ) { | |
302 return(CD_ERROR); | |
303 } | |
304 | |
305 status = SDL_CDcaps.Status(cdrom, NULL); | |
306 switch (status) { | |
307 case CD_PLAYING: | |
308 case CD_PAUSED: | |
309 retval = SDL_CDcaps.Stop(cdrom); | |
310 default: | |
311 retval = 0; | |
312 break; | |
313 } | |
314 return(retval); | |
315 } | |
316 | |
317 int SDL_CDEject(SDL_CD *cdrom) | |
318 { | |
319 /* Check if the CD-ROM subsystem has been initialized */ | |
320 if ( ! CheckInit(1, &cdrom) ) { | |
321 return(CD_ERROR); | |
322 } | |
323 return(SDL_CDcaps.Eject(cdrom)); | |
324 } | |
325 | |
326 void SDL_CDClose(SDL_CD *cdrom) | |
327 { | |
328 /* Check if the CD-ROM subsystem has been initialized */ | |
329 if ( ! CheckInit(1, &cdrom) ) { | |
330 return; | |
331 } | |
332 SDL_CDcaps.Close(cdrom); | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
333 SDL_free(cdrom); |
0 | 334 default_cdrom = NULL; |
335 } | |
336 | |
337 void SDL_CDROMQuit(void) | |
338 { | |
339 SDL_SYS_CDQuit(); | |
340 SDL_cdinitted = 0; | |
341 } |