Subversion Repositories Kolibri OS

Rev

Rev 431 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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