Subversion Repositories Kolibri OS

Rev

Rev 379 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
425 victor 1
$Revision: 425 $
1 ha 2
sys_cd_audio:
3
 
4
     cmp  word [cdbase],word 0
5
     jnz  @f
6
     mov  eax,1
7
     ret
8
   @@:
9
 
10
     ; eax=1 cdplay at ebx 0x00FFSSMM
11
     ; eax=2 get tracklist size of ecx to [ebx]
12
     ; eax=3 stop/pause playing
13
 
14
     cmp  eax,1
15
     jnz  nocdp
16
     call sys_cdplay
17
     ret
18
   nocdp:
19
 
20
     cmp eax,2
21
     jnz nocdtl
379 serge 22
     mov edi,[TASK_BASE]
115 poddubny 23
     add edi,TASKDATA.mem_start
1 ha 24
     add ebx,[edi]
25
     call sys_cdtracklist
26
     ret
27
   nocdtl:
28
 
29
     cmp eax,3
30
     jnz nocdpause
31
     call sys_cdpause
32
     ret
33
   nocdpause:
34
 
35
     mov eax,0xffffff01
36
     ret
37
 
38
 
39
 
40
sys_cd_atapi_command:
41
 
42
     pushad
43
 
44
     mov  dx,word [cdbase]
45
     add  dx,6
46
     mov  ax,word [cdid]
47
     out  dx,al
48
     mov  esi,10
49
     call delay_ms
50
     mov  dx,word [cdbase]
51
     add  dx,7
52
     in   al,dx
53
     and  al,0x80
54
     cmp  al,0
55
     jnz  res
56
     jmp  cdl6
57
   res:
58
     mov dx,word [cdbase]
59
     add dx,7
60
     mov al,0x8
61
     out dx,al
62
     mov dx,word [cdbase]
63
     add dx,0x206
64
     mov al,0xe
65
     out dx,al
66
     mov  esi,1
67
     call delay_ms
68
     mov dx,word [cdbase]
69
     add dx,0x206
70
     mov al,0x8
71
     out dx,al
72
     mov  esi,30
73
     call delay_ms
74
     xor  cx,cx
75
   cdl5:
76
     inc  cx
77
     cmp  cx,10
78
     jz   cdl6
79
     mov  dx,word [cdbase]
80
     add  dx,7
81
     in   al,dx
82
     and  al,0x88
83
     cmp  al,0x00
84
     jz   cdl5
85
     mov  esi,100
86
     call delay_ms
87
     jmp  cdl5
88
   cdl6:
89
     mov dx,word [cdbase]
90
     add dx,4
91
     mov al,0
92
     out dx,al
93
     mov dx,word [cdbase]
94
     add dx,5
95
     mov al,0
96
     out dx,al
97
     mov dx,word [cdbase]
98
     add dx,7
99
     mov al,0xec
100
     out dx,al
101
     mov  esi,5
102
     call delay_ms
103
     mov dx,word [cdbase]
104
     add dx,1
105
     mov al,0
106
     out dx,al
107
     add dx,1
108
     mov al,0
109
     out dx,al
110
     add dx,1
111
     mov al,0
112
     out dx,al
113
     add dx,1
114
     mov al,0
115
     out dx,al
116
     add dx,1
117
     mov al,128
118
     out dx,al
119
     add dx,2
120
     mov al,0xa0
121
     out dx,al
122
     xor  cx,cx
123
     mov  dx,word [cdbase]
124
     add  dx,7
125
   cdl1:
126
     inc  cx
127
     cmp  cx,100
128
     jz   cdl2
129
     in   al,dx
130
     and  ax,0x88
131
     cmp  al,0x8
132
     jz   cdl2
133
     mov  esi,2
134
     call delay_ms
135
     jmp  cdl1
136
   cdl2:
137
 
138
     popad
139
     ret
140
 
141
 
142
sys_cdplay:
143
 
144
     mov  ax,5
145
     push ax
146
     push ebx
147
   cdplay:
148
     call sys_cd_atapi_command
149
     cli
150
     mov  dx,word [cdbase]
151
     mov  ax,0x0047
152
     out  dx,ax
153
     mov  al,1
154
     mov  ah,[esp+0] ; min xx
155
     out  dx,ax
156
     mov  ax,[esp+1] ; fr sec
157
     out  dx,ax
158
     mov  ax,256+99
159
     out  dx,ax
160
     mov  ax,0x0001
161
     out  dx,ax
162
     mov  ax,0x0000
163
     out  dx,ax
164
     mov  esi,10
165
     call delay_ms
166
     sti
167
     add  dx,7
168
     in   al,dx
169
     test al,1
170
     jz   cdplayok
171
     mov  ax,[esp+4]
172
     dec  ax
173
     mov  [esp+4],ax
174
     cmp  ax,0
175
     jz   cdplayfail
176
     jmp  cdplay
177
   cdplayfail:
178
   cdplayok:
179
     pop  ebx
180
     pop  ax
181
     xor  eax, eax
182
     ret
183
 
184
 
185
sys_cdtracklist:
186
 
187
     push ebx
188
   tcdplay:
189
     call sys_cd_atapi_command
190
     mov  dx,word [cdbase]
191
     mov  ax,0x43+2*256
192
     out  dx,ax
193
     mov  ax,0x0
194
     out  dx,ax
195
     mov  ax,0x0
196
     out  dx,ax
197
     mov  ax,0x0
198
     out  dx,ax
199
     mov  ax,200
200
     out  dx,ax
201
     mov  ax,0x0
202
     out  dx,ax
203
     in   al,dx
204
     mov  cx,1000
205
     mov  dx,word [cdbase]
206
     add  dx,7
207
     cld
208
   cdtrnwewait:
209
     mov  esi,10
210
     call delay_ms
211
     in   al,dx
212
     and  al,128
213
     cmp  al,0
214
     jz   cdtrl1
215
     loop cdtrnwewait
216
   cdtrl1:
217
     ; read the result
218
     mov  ecx,[esp+0]
219
     mov  dx,word [cdbase]
220
   cdtrread:
221
     add  dx,7
222
     in   al,dx
223
     and  al,8
224
     cmp  al,8
225
     jnz  cdtrdone
226
     sub  dx,7
227
     in   ax,dx
228
     mov  [ecx],ax
229
     add  ecx,2
230
     jmp  cdtrread
231
   cdtrdone:
232
     pop  ecx
233
     xor  eax, eax
234
     ret
235
 
236
 
237
sys_cdpause:
238
 
239
     call sys_cd_atapi_command
240
 
241
     mov  dx,word [cdbase]
242
     mov  ax,0x004B
243
     out  dx,ax
244
     mov  ax,0
245
     out  dx,ax
246
     mov  ax,0
247
     out  dx,ax
248
     mov  ax,0
249
     out  dx,ax
250
     mov  ax,0
251
     out  dx,ax
252
     mov  ax,0
253
     out  dx,ax
254
 
255
     mov  esi,10
256
     call delay_ms
257
     add  dx,7
258
     in   al,dx
259
 
260
     xor  eax, eax
261
     ret
262