Subversion Repositories Kolibri OS

Rev

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

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