Subversion Repositories Kolibri OS

Rev

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

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