1/*
2    SDL - Simple DirectMedia Layer
3    Copyright (C) 1997-2012 Sam Lantinga
4
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public
7    License as published by the Free Software Foundation; either
8    version 2 of the License, or (at your option) any later version.
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
13    Library General Public License for more details.
14
15    You should have received a copy of the GNU Library General Public
16    License along with this library; if not, write to the Free
17    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19    Sam Lantinga
20    slouken@libsdl.org
21*/
22#include "SDL_config.h"
23
24/* This is the MacOS specific header for the SDL CD-ROM API
25   Contributed by Matt Slot
26 */
27
28/* AppleCD Control calls */
29#define kVerifyTheDisc   	  5		/* Returns noErr if there is disc inserted */
30#define kEjectTheDisc   	  7		/* Eject disc from drive */
31#define kUserEject    		 80		/* Enable/disable the CD-ROM eject button */
32#define kReadTOC    		100		/* Extract various TOC information from the disc */
33#define kReadQ   			101		/* Extract Q subcode info for the current track */
34#define kAudioTrackSearch   103		/* Start playback from the indicated position */
35#define kAudioPlay    		104		/* Start playback from the indicated position */
36#define kAudioPause    		105		/* Pause/continue the playback */
37#define kAudioStop    		106		/* Stop playback at the indicated position */
38#define kAudioStatus    	107		/* Return audio play status */
39#define kAudioControl    	109		/* Set the output volume for the audio channels */
40#define kReadAudioVolume   	112		/* Get the output volume for the audio channels */
41#define kSetTrackList   	122		/* Set the track program for the audio CD to play */
42#define kGetTrackList   	123		/* Get the track program the audio CD is playing */
43#define kGetTrackIndex   	124		/* Get the track index the audio CD is playing */
44#define kSetPlayMode   		125		/* Set the audio tracks play mode */
45#define kGetPlayMode   		126		/* Get the audio tracks play mode */
46
47/* AppleCD Status calls */
48#define kGetDriveType   	 96		/* Get the type of the physical CD-ROM drive */
49#define kWhoIsThere    		 97		/* Get a bitmap of SCSI IDs the driver controls */
50#define kGetBlockSize    	 98		/* Get current block size of the CD-ROM drive */
51
52/* AppleCD other constants */
53#define kBlockPosition    	  0		/* Position at the specified logical block number */
54#define kAbsMSFPosition    	  1		/* Position at the specified Min/Sec/Frame (in BCD) */
55#define kTrackPosition    	  2		/* Position at the specified track number (in BCD) */
56#define kIndexPosition    	  3		/* Position at the nth track in program (in BCD) */
57
58#define kMutedPlayMode   	  0		/* Play the audio track with no output */
59#define kStereoPlayMode   	  9		/* Play the audio track in normal stereo */
60
61#define kControlFieldMask  	0x0D	/* Bits 3,2,0 in the nibble */
62#define kDataTrackMask   	0x04	/* Indicates Data Track */
63
64#define kGetTrackRange    	  1		/* Query TOC for track numbers */
65#define kGetLeadOutArea    	  2		/* Query TOC for "Lead Out" end of audio data */
66#define kGetTrackEntries   	  3		/* Query TOC for track starts and data types */
67
68#define kStatusPlaying		  0		/* Audio Play operation in progress */
69#define kStatusPaused		  1		/* CD-ROM device in Hold Track ("Pause") state */
70#define kStatusMuted		  2		/* MUTING-ON operation in progress */
71#define kStatusDone			  3		/* Audio Play completed */
72#define kStatusError		  4		/* Error occurred during audio play operation */
73#define kStatusStopped		  5		/* Audio play operation not requested */
74
75#define kPlayModeSequential	  0		/*  Play tracks in order */
76#define kPlayModeShuffled	  1		/* Play tracks randomly */
77#define kPlayModeProgrammed   2		/* Use custom playlist */
78
79/* AppleCD Gestalt selectors */
80#define kGestaltAudioCDSelector    'aucd'
81#define kDriverVersion52   		0x00000520
82#define kDriverVersion51   		0x00000510
83#define kDriverVersion50   		0x00000500
84
85/* Drive type constants */
86#define kDriveAppleCD_SC   				  1
87#define kDriveAppleCD_SCPlus_or_150   	  2
88#define kDriveAppleCD_300_or_300Plus   	  3
89
90/* Misc constants */
91#define kFirstSCSIDevice   	 -33
92#define kLastSCSIDevice    	 -40
93
94#if PRAGMA_STRUCT_ALIGN
95	#pragma options align=mac68k
96#endif
97
98/* AppleCD driver parameter block */
99typedef struct CDCntrlParam {
100	QElemPtr				qLink;
101	short					qType;
102	short					ioTrap;
103	Ptr						ioCmdAddr;
104	IOCompletionUPP			ioCompletion;
105	OSErr					ioResult;
106	StringPtr				ioNamePtr;
107	short					ioVRefNum;
108	short					ioCRefNum;
109	short					csCode;
110
111	union {
112		long				longs[6];
113		short				words[11];
114		unsigned char		bytes[22];
115		struct {
116			unsigned char	status;
117			unsigned char	play;
118			unsigned char	control;
119			unsigned char	minute;
120			unsigned char	second;
121			unsigned char	frame;
122			} cd;
123		} csParam;
124
125	} CDCntrlParam, *CDCntrlParamPtr;
126
127typedef union CDTrackData {
128	long				value;			/* Treat as a longword value */
129	struct {
130		unsigned char	reserved : 4;	/* Unused by AppleCD driver  */
131		unsigned char	control : 4;	/* Track flags (data track?) */
132		unsigned char	min;			/* Start of track (BCD)      */
133		unsigned char	sec;			/* Start of track (BCD)      */
134		unsigned char	frame;			/* Start of track (BCD)      */
135		} entry;						/* Broken into fields        */
136	} CDTrackData, *CDTrackPtr;
137
138#if PRAGMA_STRUCT_ALIGN
139	#pragma options align=reset
140#endif
141