comparison src/cdrom/dc/SDL_syscdrom.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
30 30
31 #include "SDL_cdrom.h" 31 #include "SDL_cdrom.h"
32 #include "../SDL_syscdrom.h" 32 #include "../SDL_syscdrom.h"
33 33
34 /* The system-dependent CD control functions */ 34 /* The system-dependent CD control functions */
35 static const char *SDL_SYS_CDName (int drive); 35 static const char *SDL_SYS_CDName(int drive);
36 static int SDL_SYS_CDOpen (int drive); 36 static int SDL_SYS_CDOpen(int drive);
37 static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); 37 static int SDL_SYS_CDGetTOC(SDL_CD * cdrom);
38 static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); 38 static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position);
39 static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); 39 static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length);
40 static int SDL_SYS_CDPause (SDL_CD * cdrom); 40 static int SDL_SYS_CDPause(SDL_CD * cdrom);
41 static int SDL_SYS_CDResume (SDL_CD * cdrom); 41 static int SDL_SYS_CDResume(SDL_CD * cdrom);
42 static int SDL_SYS_CDStop (SDL_CD * cdrom); 42 static int SDL_SYS_CDStop(SDL_CD * cdrom);
43 static int SDL_SYS_CDEject (SDL_CD * cdrom); 43 static int SDL_SYS_CDEject(SDL_CD * cdrom);
44 static void SDL_SYS_CDClose (SDL_CD * cdrom); 44 static void SDL_SYS_CDClose(SDL_CD * cdrom);
45 45
46 46
47 int 47 int
48 SDL_SYS_CDInit (void) 48 SDL_SYS_CDInit(void)
49 { 49 {
50 /* Fill in our driver capabilities */ 50 /* Fill in our driver capabilities */
51 SDL_CDcaps.Name = SDL_SYS_CDName; 51 SDL_CDcaps.Name = SDL_SYS_CDName;
52 SDL_CDcaps.Open = SDL_SYS_CDOpen; 52 SDL_CDcaps.Open = SDL_SYS_CDOpen;
53 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; 53 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
61 61
62 return (0); 62 return (0);
63 } 63 }
64 64
65 static const char * 65 static const char *
66 SDL_SYS_CDName (int drive) 66 SDL_SYS_CDName(int drive)
67 { 67 {
68 return "/cd"; 68 return "/cd";
69 } 69 }
70 70
71 static int 71 static int
72 SDL_SYS_CDOpen (int drive) 72 SDL_SYS_CDOpen(int drive)
73 { 73 {
74 return (drive); 74 return (drive);
75 } 75 }
76 76
77 #define TRACK_CDDA 0 77 #define TRACK_CDDA 0
78 static int 78 static int
79 SDL_SYS_CDGetTOC (SDL_CD * cdrom) 79 SDL_SYS_CDGetTOC(SDL_CD * cdrom)
80 { 80 {
81 CDROM_TOC toc; 81 CDROM_TOC toc;
82 int ret, i; 82 int ret, i;
83 83
84 ret = cdrom_read_toc (&toc, 0); 84 ret = cdrom_read_toc(&toc, 0);
85 if (ret != ERR_OK) { 85 if (ret != ERR_OK) {
86 return -1; 86 return -1;
87 } 87 }
88 88
89 cdrom->numtracks = TOC_TRACK (toc.last) - TOC_TRACK (toc.first) + 1; 89 cdrom->numtracks = TOC_TRACK(toc.last) - TOC_TRACK(toc.first) + 1;
90 for (i = 0; i < cdrom->numtracks; i++) { 90 for (i = 0; i < cdrom->numtracks; i++) {
91 unsigned long entry = toc.entry[i]; 91 unsigned long entry = toc.entry[i];
92 cdrom->track[i].id = i + 1; 92 cdrom->track[i].id = i + 1;
93 cdrom->track[i].type = 93 cdrom->track[i].type =
94 (TOC_CTRL (toc.entry[i]) == 94 (TOC_CTRL(toc.entry[i]) ==
95 TRACK_CDDA) ? SDL_AUDIO_TRACK : SDL_DATA_TRACK; 95 TRACK_CDDA) ? SDL_AUDIO_TRACK : SDL_DATA_TRACK;
96 cdrom->track[i].offset = TOC_LBA (entry) - 150; 96 cdrom->track[i].offset = TOC_LBA(entry) - 150;
97 cdrom->track[i].length = 97 cdrom->track[i].length =
98 TOC_LBA ((i + 1 < 98 TOC_LBA((i + 1 <
99 toc.last) ? toc.entry[i + 1] : toc.leadout_sector) - 99 toc.last) ? toc.entry[i + 1] : toc.leadout_sector) -
100 TOC_LBA (entry); 100 TOC_LBA(entry);
101 } 101 }
102 102
103 return 0; 103 return 0;
104 } 104 }
105 105
106 /* Get CD-ROM status */ 106 /* Get CD-ROM status */
107 static CDstatus 107 static CDstatus
108 SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) 108 SDL_SYS_CDStatus(SDL_CD * cdrom, int *position)
109 { 109 {
110 int ret, dc_status, disc_type; 110 int ret, dc_status, disc_type;
111 111
112 ret = cdrom_get_status (&dc_status, &disc_type); 112 ret = cdrom_get_status(&dc_status, &disc_type);
113 if (ret != ERR_OK) 113 if (ret != ERR_OK)
114 return CD_ERROR; 114 return CD_ERROR;
115 115
116 switch (dc_status) { 116 switch (dc_status) {
117 // case CD_STATUS_BUSY: 117 // case CD_STATUS_BUSY:
131 } 131 }
132 } 132 }
133 133
134 /* Start play */ 134 /* Start play */
135 static int 135 static int
136 SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) 136 SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length)
137 { 137 {
138 int ret = 138 int ret =
139 cdrom_cdda_play (start - 150, start - 150 + length, 1, CDDA_SECTORS); 139 cdrom_cdda_play(start - 150, start - 150 + length, 1, CDDA_SECTORS);
140 return ret == ERR_OK ? 0 : -1; 140 return ret == ERR_OK ? 0 : -1;
141 } 141 }
142 142
143 /* Pause play */ 143 /* Pause play */
144 static int 144 static int
145 SDL_SYS_CDPause (SDL_CD * cdrom) 145 SDL_SYS_CDPause(SDL_CD * cdrom)
146 { 146 {
147 int ret = cdrom_cdda_pause (); 147 int ret = cdrom_cdda_pause();
148 return ret == ERR_OK ? 0 : -1; 148 return ret == ERR_OK ? 0 : -1;
149 } 149 }
150 150
151 /* Resume play */ 151 /* Resume play */
152 static int 152 static int
153 SDL_SYS_CDResume (SDL_CD * cdrom) 153 SDL_SYS_CDResume(SDL_CD * cdrom)
154 { 154 {
155 int ret = cdrom_cdda_resume (); 155 int ret = cdrom_cdda_resume();
156 return ret == ERR_OK ? 0 : -1; 156 return ret == ERR_OK ? 0 : -1;
157 } 157 }
158 158
159 /* Stop play */ 159 /* Stop play */
160 static int 160 static int
161 SDL_SYS_CDStop (SDL_CD * cdrom) 161 SDL_SYS_CDStop(SDL_CD * cdrom)
162 { 162 {
163 int ret = cdrom_spin_down (); 163 int ret = cdrom_spin_down();
164 return ret == ERR_OK ? 0 : -1; 164 return ret == ERR_OK ? 0 : -1;
165 } 165 }
166 166
167 /* Eject the CD-ROM */ 167 /* Eject the CD-ROM */
168 static int 168 static int
169 SDL_SYS_CDEject (SDL_CD * cdrom) 169 SDL_SYS_CDEject(SDL_CD * cdrom)
170 { 170 {
171 return -1; 171 return -1;
172 } 172 }
173 173
174 /* Close the CD-ROM handle */ 174 /* Close the CD-ROM handle */
175 static void 175 static void
176 SDL_SYS_CDClose (SDL_CD * cdrom) 176 SDL_SYS_CDClose(SDL_CD * cdrom)
177 { 177 {
178 } 178 }
179 179
180 void 180 void
181 SDL_SYS_CDQuit (void) 181 SDL_SYS_CDQuit(void)
182 { 182 {
183 183
184 } 184 }
185 185
186 #endif /* SDL_CDROM_DC */ 186 #endif /* SDL_CDROM_DC */