]> icculus.org git repositories - btb/d2x.git/blob - arch/sdl/cdrom.c
copied from d1x
[btb/d2x.git] / arch / sdl / cdrom.c
1 /*
2  * $Source: /cvs/cvsroot/d2x/arch/sdl/cdrom.c,v $
3  * $Revision: 1.1 $
4  * $Author: bradleyb $
5  * $Date: 2001-10-25 08:25:34 $
6  *
7  * DPH: This is the file where all the stub functions go.
8  * The aim is to have nothing in here, eventually
9  *
10  * $Log: not supported by cvs2svn $
11  * Revision 1.3  2001/01/29 13:53:28  bradleyb
12  * Fixed build, minor fixes
13  *
14  */
15
16 #ifdef HAVE_CONFIG_H
17 #include <conf.h>
18 #endif
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <SDL/SDL.h>
23 #include <SDL/SDL_cdrom.h>
24 #include "pstypes.h"
25 #include "error.h"
26 #include "args.h"
27
28
29 static SDL_CD *s_cd = NULL;
30 extern int Redbook_playing;
31 static int initialised = 0;
32
33 void RBAExit()
34 {
35   if (initialised)
36   {
37         SDL_CDClose(s_cd);
38   }
39 }
40
41 void RBAInit()
42 {
43         if (initialised) return;
44         if (FindArg("-nocdrom")) return; 
45
46         if (SDL_Init(SDL_INIT_CDROM) < 0)
47         {
48                 Warning("SDL library initialisation failed: %s.",SDL_GetError());
49                 return;
50         }
51
52         if (SDL_CDNumDrives() == 0)
53         {
54                 Warning("No cdrom drives found!\n");
55                 return;
56         }
57         s_cd = SDL_CDOpen(0);
58         atexit(RBAExit);
59         initialised = 1;
60 }
61
62 int RBAEnabled()
63 {
64  return 1;
65 }
66
67 void RBARegisterCD()
68 {
69
70 }
71
72 int RBAPlayTrack(int a)
73 {
74  if (!initialised) return -1;
75
76  if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) {
77          SDL_CDPlayTracks(s_cd, a-1, 0, 0, 0);
78  }
79  return a;
80  
81 }
82
83 void RBAStop()
84 {
85   if (!initialised) return;
86   SDL_CDStop(s_cd);
87 }
88
89 void RBASetVolume(int a)
90 {
91
92 }
93
94 void RBAPause()
95 {
96   if (!initialised) return;
97   SDL_CDPause(s_cd);
98 }
99
100 void RBAResume()
101 {
102   if (!initialised) return;
103   SDL_CDResume(s_cd);
104 }
105
106 int RBAGetNumberOfTracks()
107 {
108   if (!initialised) return -1;
109  SDL_CDStatus(s_cd);
110  return s_cd->numtracks;
111 }
112
113 int RBAPlayTracks(int tracknum,int something)
114 {
115   if (!initialised) return -1;
116  if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) {
117          SDL_CDPlayTracks(s_cd, tracknum-1, 0, 0, 0);
118  }
119  return tracknum;
120 }
121
122 int RBAGetTrackNum()
123 {
124   if (!initialised) return -1;
125  SDL_CDStatus(s_cd);
126  return s_cd->cur_track;
127 }
128
129 int RBAPeekPlayStatus()
130 {
131  return 1;
132 }
133
134 int CD_blast_mixer()
135 {
136  return 0;
137 }