1 /*
2   Simple DirectMedia Layer
3   Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
4 
5   This software is provided 'as-is', without any express or implied
6   warranty.  In no event will the authors be held liable for any damages
7   arising from the use of this software.
8 
9   Permission is granted to anyone to use this software for any purpose,
10   including commercial applications, and to alter it and redistribute it
11   freely, subject to the following restrictions:
12 
13   1. The origin of this software must not be misrepresented; you must not
14      claim that you wrote the original software. If you use this software
15      in a product, an acknowledgment in the product documentation would be
16      appreciated but is not required.
17   2. Altered source versions must be plainly marked as such, and must not be
18      misrepresented as being the original software.
19   3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 /* These headers are from sdl12-compat, and are intended to give just enough
23 functionality to let you build an SDL-1.2-based project without having the
24 real SDL-1.2 available to you. */
25 
26 #ifndef _SDL_cdrom_h
27 #define _SDL_cdrom_h
28 
29 #include "SDL_stdinc.h"
30 #include "SDL_error.h"
31 
32 #include "begin_code.h"
33 
34 #define SDL_MAX_TRACKS 99
35 
36 typedef enum CDstatus
37 {
38     CD_TRAYEMPTY,
39     CD_STOPPED,
40     CD_PLAYING,
41     CD_PAUSED,
42     CD_ERROR = -1
43 } CDstatus;
44 
45 typedef struct SDL_CDtrack
46 {
47     Uint8 id;
48     Uint8 type;
49     Uint16 unused;
50     Uint32 length;
51     Uint32 offset;
52 } SDL_CDtrack;
53 
54 typedef struct SDL_CD
55 {
56     int id;
57     CDstatus status;
58     int numtracks;
59     int cur_track;
60     int cur_frame;
61     SDL_CDtrack track[SDL_MAX_TRACKS+1];
62 } SDL_CD;
63 
64 #define SDL_AUDIO_TRACK 0x00
65 #define SDL_DATA_TRACK 0x04
66 #define CD_INDRIVE(status) (status > CD_TRAYEMPTY)
67 #define CD_FPS 75
68 
69 #define FRAMES_TO_MSF(f, M,S,F) { \
70     int value = f; \
71     *(F) = value % CD_FPS; \
72     value /= CD_FPS; \
73     *(S) = value % 60; \
74     value /= 60; \
75     *(M) = value; \
76 }
77 
78 #define MSF_TO_FRAMES(M, S, F) ((M) * 60 * CD_FPS + (S) * CD_FPS + (F))
79 
80 extern DECLSPEC int SDLCALL SDL_CDNumDrives(void);
81 extern DECLSPEC const char * SDLCALL SDL_CDName(int drive);
82 extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive);
83 extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom);
84 extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom, int start_track, int start_frame, int ntracks, int nframes);
85 extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length);
86 extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom);
87 extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom);
88 extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom);
89 extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom);
90 extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom);
91 
92 #include "close_code.h"
93 
94 #endif
95 
96