comparison src/cdrom/dc/SDL_syscdrom.c @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents 92947e3a18db
children 99210400e8b9
comparison
equal deleted inserted replaced
1894:c69cee13dd76 1895:c121d94672cb
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 SDL_SYS_CDInit(void) 47 int
48 SDL_SYS_CDInit(void)
48 { 49 {
49 /* Fill in our driver capabilities */ 50 /* Fill in our driver capabilities */
50 SDL_CDcaps.Name = SDL_SYS_CDName; 51 SDL_CDcaps.Name = SDL_SYS_CDName;
51 SDL_CDcaps.Open = SDL_SYS_CDOpen; 52 SDL_CDcaps.Open = SDL_SYS_CDOpen;
52 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; 53 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
53 SDL_CDcaps.Status = SDL_SYS_CDStatus; 54 SDL_CDcaps.Status = SDL_SYS_CDStatus;
54 SDL_CDcaps.Play = SDL_SYS_CDPlay; 55 SDL_CDcaps.Play = SDL_SYS_CDPlay;
55 SDL_CDcaps.Pause = SDL_SYS_CDPause; 56 SDL_CDcaps.Pause = SDL_SYS_CDPause;
56 SDL_CDcaps.Resume = SDL_SYS_CDResume; 57 SDL_CDcaps.Resume = SDL_SYS_CDResume;
57 SDL_CDcaps.Stop = SDL_SYS_CDStop; 58 SDL_CDcaps.Stop = SDL_SYS_CDStop;
58 SDL_CDcaps.Eject = SDL_SYS_CDEject; 59 SDL_CDcaps.Eject = SDL_SYS_CDEject;
59 SDL_CDcaps.Close = SDL_SYS_CDClose; 60 SDL_CDcaps.Close = SDL_SYS_CDClose;
60 61
61 return(0); 62 return (0);
62 } 63 }
63 64
64 static const char *SDL_SYS_CDName(int drive) 65 static const char *
66 SDL_SYS_CDName(int drive)
65 { 67 {
66 return "/cd"; 68 return "/cd";
67 } 69 }
68 70
69 static int SDL_SYS_CDOpen(int drive) 71 static int
72 SDL_SYS_CDOpen(int drive)
70 { 73 {
71 return(drive); 74 return (drive);
72 } 75 }
73 76
74 #define TRACK_CDDA 0 77 #define TRACK_CDDA 0
75 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom) 78 static int
79 SDL_SYS_CDGetTOC(SDL_CD * cdrom)
76 { 80 {
77 CDROM_TOC toc; 81 CDROM_TOC toc;
78 int ret,i; 82 int ret, i;
79 83
80 ret = cdrom_read_toc(&toc,0); 84 ret = cdrom_read_toc(&toc, 0);
81 if (ret!=ERR_OK) { 85 if (ret != ERR_OK) {
82 return -1; 86 return -1;
83 } 87 }
84 88
85 cdrom->numtracks = TOC_TRACK(toc.last)-TOC_TRACK(toc.first)+1; 89 cdrom->numtracks = TOC_TRACK(toc.last) - TOC_TRACK(toc.first) + 1;
86 for(i=0;i<cdrom->numtracks;i++) { 90 for (i = 0; i < cdrom->numtracks; i++) {
87 unsigned long entry = toc.entry[i]; 91 unsigned long entry = toc.entry[i];
88 cdrom->track[i].id = i+1; 92 cdrom->track[i].id = i + 1;
89 cdrom->track[i].type = (TOC_CTRL(toc.entry[i])==TRACK_CDDA)?SDL_AUDIO_TRACK:SDL_DATA_TRACK; 93 cdrom->track[i].type =
90 cdrom->track[i].offset = TOC_LBA(entry)-150; 94 (TOC_CTRL(toc.entry[i]) ==
91 cdrom->track[i].length = TOC_LBA((i+1<toc.last)?toc.entry[i+1]:toc.leadout_sector)-TOC_LBA(entry); 95 TRACK_CDDA) ? SDL_AUDIO_TRACK : SDL_DATA_TRACK;
92 } 96 cdrom->track[i].offset = TOC_LBA(entry) - 150;
97 cdrom->track[i].length =
98 TOC_LBA((i + 1 <
99 toc.last) ? toc.entry[i + 1] : toc.leadout_sector) -
100 TOC_LBA(entry);
101 }
93 102
94 return 0; 103 return 0;
95 } 104 }
96 105
97 /* Get CD-ROM status */ 106 /* Get CD-ROM status */
98 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position) 107 static CDstatus
108 SDL_SYS_CDStatus(SDL_CD * cdrom, int *position)
99 { 109 {
100 int ret,dc_status,disc_type; 110 int ret, dc_status, disc_type;
101 111
102 ret = cdrom_get_status(&dc_status,&disc_type); 112 ret = cdrom_get_status(&dc_status, &disc_type);
103 if (ret!=ERR_OK) return CD_ERROR; 113 if (ret != ERR_OK)
114 return CD_ERROR;
104 115
105 switch(dc_status) { 116 switch (dc_status) {
106 // case CD_STATUS_BUSY: 117 // case CD_STATUS_BUSY:
107 case CD_STATUS_PAUSED: 118 case CD_STATUS_PAUSED:
108 return CD_PAUSED; 119 return CD_PAUSED;
109 case CD_STATUS_STANDBY: 120 case CD_STATUS_STANDBY:
110 return CD_STOPPED; 121 return CD_STOPPED;
111 case CD_STATUS_PLAYING: 122 case CD_STATUS_PLAYING:
112 return CD_PLAYING; 123 return CD_PLAYING;
113 // case CD_STATUS_SEEKING: 124 // case CD_STATUS_SEEKING:
114 // case CD_STATUS_SCANING: 125 // case CD_STATUS_SCANING:
115 case CD_STATUS_OPEN: 126 case CD_STATUS_OPEN:
116 case CD_STATUS_NO_DISC: 127 case CD_STATUS_NO_DISC:
117 return CD_TRAYEMPTY; 128 return CD_TRAYEMPTY;
118 default: 129 default:
119 return CD_ERROR; 130 return CD_ERROR;
120 } 131 }
121 } 132 }
122 133
123 /* Start play */ 134 /* Start play */
124 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) 135 static int
136 SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length)
125 { 137 {
126 int ret = cdrom_cdda_play(start-150,start-150+length,1,CDDA_SECTORS); 138 int ret =
127 return ret==ERR_OK?0:-1; 139 cdrom_cdda_play(start - 150, start - 150 + length, 1, CDDA_SECTORS);
140 return ret == ERR_OK ? 0 : -1;
128 } 141 }
129 142
130 /* Pause play */ 143 /* Pause play */
131 static int SDL_SYS_CDPause(SDL_CD *cdrom) 144 static int
145 SDL_SYS_CDPause(SDL_CD * cdrom)
132 { 146 {
133 int ret=cdrom_cdda_pause(); 147 int ret = cdrom_cdda_pause();
134 return ret==ERR_OK?0:-1; 148 return ret == ERR_OK ? 0 : -1;
135 } 149 }
136 150
137 /* Resume play */ 151 /* Resume play */
138 static int SDL_SYS_CDResume(SDL_CD *cdrom) 152 static int
153 SDL_SYS_CDResume(SDL_CD * cdrom)
139 { 154 {
140 int ret=cdrom_cdda_resume(); 155 int ret = cdrom_cdda_resume();
141 return ret==ERR_OK?0:-1; 156 return ret == ERR_OK ? 0 : -1;
142 } 157 }
143 158
144 /* Stop play */ 159 /* Stop play */
145 static int SDL_SYS_CDStop(SDL_CD *cdrom) 160 static int
161 SDL_SYS_CDStop(SDL_CD * cdrom)
146 { 162 {
147 int ret=cdrom_spin_down(); 163 int ret = cdrom_spin_down();
148 return ret==ERR_OK?0:-1; 164 return ret == ERR_OK ? 0 : -1;
149 } 165 }
150 166
151 /* Eject the CD-ROM */ 167 /* Eject the CD-ROM */
152 static int SDL_SYS_CDEject(SDL_CD *cdrom) 168 static int
169 SDL_SYS_CDEject(SDL_CD * cdrom)
153 { 170 {
154 return -1; 171 return -1;
155 } 172 }
156 173
157 /* Close the CD-ROM handle */ 174 /* Close the CD-ROM handle */
158 static void SDL_SYS_CDClose(SDL_CD *cdrom) 175 static void
176 SDL_SYS_CDClose(SDL_CD * cdrom)
159 { 177 {
160 } 178 }
161 179
162 void SDL_SYS_CDQuit(void) 180 void
181 SDL_SYS_CDQuit(void)
163 { 182 {
164 183
165 } 184 }
166 185
167 #endif /* SDL_CDROM_DC */ 186 #endif /* SDL_CDROM_DC */
187 /* vi: set ts=4 sw=4 expandtab: */