Subversion Repositories Kolibri OS

Rev

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

Rev 3749 Rev 5098
1
;
1
;
2
;   KolibriOS system mixer. Version 0.2
2
;   KolibriOS system mixer. Version 0.2
3
;
3
;
4
;   Author:         Asper
4
;   Author:         Asper
5
;   Date of issue:  15.08.2010
5
;   Date of issue:  15.08.2010
6
;   Compiler:       FASM
6
;   Compiler:       FASM
7
;   Target:         KolibriOS
7
;   Target:         KolibriOS
8
;
8
;
9
 
9
 
10
use32
10
use32
11
        org     0x0
11
        org     0x0
12
 
12
 
13
        db      'MENUET01'      ; 8 byte id
13
        db      'MENUET01'      ; 8 byte id
14
        dd      38              ; required os
14
        dd      38              ; required os
15
        dd      STARTAPP        ; program start
15
        dd      STARTAPP        ; program start
16
        dd      I_END           ; program image size
16
        dd      I_END           ; program image size
17
        dd      I_MEM           ; required amount of memory
17
        dd      I_MEM           ; required amount of memory
18
        dd      I_MEM           ; stack heap
18
        dd      I_MEM           ; stack heap
19
        dd      0x0, 0x0
19
        dd      0x0, 0x0
20
 
20
 
21
include 'aspAPI.inc'
21
include 'aspapi.INC'
22
include '../../macros.inc'
22
include '../../macros.inc'
23
;include 'string.inc'
23
;include 'string.inc'
24
 
24
 
25
 
25
 
26
;include 'debug.inc'
26
;include 'debug.inc'
27
 
27
 
28
DEBUG    equ 0 ;1
28
DEBUG    equ 0 ;1
29
 
29
 
30
SRV_GETVERSION        equ  0
30
SRV_GETVERSION        equ  0
31
DEV_PLAY              equ  1
31
DEV_PLAY              equ  1
32
DEV_STOP              equ  2
32
DEV_STOP              equ  2
33
DEV_CALLBACK          equ  3
33
DEV_CALLBACK          equ  3
34
DEV_SET_BUFF          equ  4
34
DEV_SET_BUFF          equ  4
35
DEV_NOTIFY            equ  5
35
DEV_NOTIFY            equ  5
36
DEV_SET_MASTERVOL     equ  6
36
DEV_SET_MASTERVOL     equ  6
37
DEV_GET_MASTERVOL     equ  7
37
DEV_GET_MASTERVOL     equ  7
38
DEV_GET_INFO          equ  8
38
DEV_GET_INFO          equ  8
39
 
39
 
40
 
40
 
41
;C_UNKNOWN     equ ?
41
;C_UNKNOWN     equ ?
42
C_BLACK        equ 0x000000
42
C_BLACK        equ 0x000000
43
C_GREY         equ 0xB0B0B0    ; 0xC0C0C0
43
C_GREY         equ 0xB0B0B0    ; 0xC0C0C0
44
C_BLUE         equ 0x1070D0
44
C_BLUE         equ 0x1070D0
45
C_GREEN        equ 0x70D010
45
C_GREEN        equ 0x70D010
46
C_RED          equ 0xD01010
46
C_RED          equ 0xD01010
47
C_ORANGE       equ 0xD07010
47
C_ORANGE       equ 0xD07010
48
C_YELLOW       equ 0xE0E010
48
C_YELLOW       equ 0xE0E010
49
C_PURPLE       equ 0x7010D0
49
C_PURPLE       equ 0x7010D0
50
C_PINK         equ 0xFF00FF
50
C_PINK         equ 0xFF00FF
51
;C_RESERVED     equ ?
51
;C_RESERVED     equ ?
52
C_WHITE        equ 0xFFFFFF
52
C_WHITE        equ 0xFFFFFF
53
;C_OTHER        equ ?
53
;C_OTHER        equ ?
54
 
54
 
55
 
55
 
56
C_KEYCOLOR1   equ 0x0050D250 ; Control button color 1
56
C_KEYCOLOR1   equ 0x0050D250 ; Control button color 1
57
C_KEYCOLOR2   equ 0x00CBE1E1 ; Control button color 2
57
C_KEYCOLOR2   equ 0x00CBE1E1 ; Control button color 2
58
C_TEXTCOLOR   equ 0x80000000 ; Button caption color
58
C_TEXTCOLOR   equ 0x80000000 ; Button caption color
59
BUT_W         equ 20
59
BUT_W         equ 20
60
BUT_H         equ 20
60
BUT_H         equ 20
61
;WIN_X         equ 30000 ; I hope nobody has screen
61
;WIN_X         equ 30000 ; I hope nobody has screen
62
;WIN_Y         equ 30000 ; with such a big resolution :)
62
;WIN_Y         equ 30000 ; with such a big resolution :)
63
WIN_W         equ 250;390
63
WIN_W         equ 250;390
64
WIN_H         equ 180
64
WIN_H         equ 180
65
WIN_COLOR     equ 0x505050 ;0x0099BB
65
WIN_COLOR     equ 0x505050 ;0x0099BB
66
WIN_X_CENTER  equ WIN_W/2
66
WIN_X_CENTER  equ WIN_W/2
67
 
67
 
68
FIRST_CTRL_BUTTON_ID  equ 7
68
FIRST_CTRL_BUTTON_ID  equ 7
69
MAX_CONTROLS_NUM equ 15 ;  Bad bounding :/
69
MAX_CONTROLS_NUM equ 15 ;  Bad bounding :/
70
 
70
 
71
struc CONTROL
71
struc CONTROL
72
{
72
{
73
  .level dw ?
73
  .level dw ?
74
  .num_steps dw ?
74
  .num_steps dw ?
75
}
75
}
76
 
76
 
77
; widget node for parsing
77
; widget node for parsing
78
;struc HDA_GNODE
78
;struc HDA_GNODE
79
;{
79
;{
80
;  .nid                dw ?    ;NID of this widget
80
;  .nid                dw ?    ;NID of this widget
81
;  .nconns             dw ?    ;number of input connections
81
;  .nconns             dw ?    ;number of input connections
82
;  .conn_list          dd ?
82
;  .conn_list          dd ?
83
;  .slist              dw ?    ;temporay list
83
;  .slist              dw ?    ;temporay list
84
;                      dw ?
84
;                      dw ?
85
;
85
;
86
;  .wid_caps           dd ?    ;widget capabilities
86
;  .wid_caps           dd ?    ;widget capabilities
87
;  .type               db ?    ;widget type
87
;  .type               db ?    ;widget type
88
;  .pin_ctl            db ?    ;pin controls
88
;  .pin_ctl            db ?    ;pin controls
89
;  .checked            db ?    ;the flag indicates that the node is already parsed
89
;  .checked            db ?    ;the flag indicates that the node is already parsed
90
;  .pin_caps           dd ?    ;pin widget capabilities
90
;  .pin_caps           dd ?    ;pin widget capabilities
91
;  .def_cfg            dd ?    ;default configuration
91
;  .def_cfg            dd ?    ;default configuration
92
;  .amp_out_caps       dd ?    ;AMP out capabilities
92
;  .amp_out_caps       dd ?    ;AMP out capabilities
93
;  .amp_in_caps        dd ?    ;AMP in capabilities
93
;  .amp_in_caps        dd ?    ;AMP in capabilities
94
;  .next               dd ? ;        struct list_head list
94
;  .next               dd ? ;        struct list_head list
95
;  .sizeof:
95
;  .sizeof:
96
;}
96
;}
97
 
97
 
98
;virtual at 0
98
;virtual at 0
99
;  HDA_GNODE  HDA_GNODE
99
;  HDA_GNODE  HDA_GNODE
100
;end virtual
100
;end virtual
101
 
101
 
102
STARTAPP:
102
STARTAPP:
103
        ; Initialize memory
103
        ; Initialize memory
104
;        mcall   68, 11
104
;        mcall   68, 11
105
;        or      eax,eax
105
;        or      eax,eax
106
;        jz      close_app
106
;        jz      close_app
107
 
107
 
108
 
108
 
109
        ; Load sound system driver
109
        ; Load sound system driver
110
        mov     eax, 68
110
        mov     eax, 68
111
        mov     ebx, 16
111
        mov     ebx, 16
112
        mov     ecx, drivername
112
        mov     ecx, drivername
113
        int     0x40
113
        int     0x40
114
        mov     [hDriver], eax
114
        mov     [hDriver], eax
115
        test    eax, eax
115
        test    eax, eax
116
        jnz     @f
116
        jnz     @f
117
loaderr:
117
loaderr:
118
        if DEBUG
118
        if DEBUG
119
                print   "Can't load driver"
119
                print   "Can't load driver"
120
        end if
120
        end if
121
        jmp     close_app
121
        jmp     close_app
122
  @@:
122
  @@:
123
        mov     [is_hda], 1
123
        mov     [is_hda], 1
124
        call    GetDriverVer
124
        call    GetDriverVer
125
        mov     eax, [driver_ver]
125
        mov     eax, [driver_ver]
126
        cmp     ax, 0x11DA
126
        cmp     ax, 0x11DA
127
        je      @f
127
        je      @f
128
        mov     [is_hda], 0
128
        mov     [is_hda], 0
129
  @@:
129
  @@:
130
        cmp     [is_hda], 0
130
        cmp     [is_hda], 0
131
        je      .init_ac97_controls
131
        je      .init_ac97_controls
132
        ; Init volume controls
132
        ; Init volume controls
133
        stdcall GetMasterVol, 0
133
        stdcall GetMasterVol, 0
134
        mov     ebx, eax
134
        mov     ebx, eax
135
        mov     [LVolume.level], ax
135
        mov     [LVolume.level], ax
136
        shr     eax, 16
136
        shr     eax, 16
137
        mov     [LVolume.num_steps], ax
137
        mov     [LVolume.num_steps], ax
138
        stdcall GetMasterVol, 1
138
        stdcall GetMasterVol, 1
139
        mov     [RVolume.level], ax
139
        mov     [RVolume.level], ax
140
        shr     eax, 16
140
        shr     eax, 16
141
        mov     [RVolume.num_steps], ax
141
        mov     [RVolume.num_steps], ax
142
        jmp     .controls_init_complete
142
        jmp     .controls_init_complete
143
        ; Asper: temporary workaround on ac97 codecs [
143
        ; Asper: temporary workaround on ac97 codecs [
144
  .init_ac97_controls:        ;jmp     @f
144
  .init_ac97_controls:        ;jmp     @f
145
        mov     [is_hda], 0
145
        mov     [is_hda], 0
146
        mov     [LVolume.num_steps], 31
146
        mov     [LVolume.num_steps], 31
147
        mov     [RVolume.num_steps], 31
147
        mov     [RVolume.num_steps], 31
148
        mov     ax, [LVolume.level]
148
        mov     ax, [LVolume.level]
149
        call    convert_ac97_volume_to_level
149
        call    convert_ac97_volume_to_level
150
        mov     [LVolume.level], ax
150
        mov     [LVolume.level], ax
151
        mov     [RVolume.level], ax
151
        mov     [RVolume.level], ax
152
        ; Asper: temporary workaround on ac97 codecs ]
152
        ; Asper: temporary workaround on ac97 codecs ]
153
  .controls_init_complete:
153
  .controls_init_complete:
154
        if DEBUG
154
        if DEBUG
155
                print   "Left level"
155
                print   "Left level"
156
                movzx   eax, [LVolume.level]
156
                movzx   eax, [LVolume.level]
157
                dph     eax
157
                dph     eax
158
                newline
158
                newline
159
                print   "Left num_steps"
159
                print   "Left num_steps"
160
                movzx   eax, [LVolume.num_steps]
160
                movzx   eax, [LVolume.num_steps]
161
                dph     eax
161
                dph     eax
162
                newline
162
                newline
163
                print   "Right level"
163
                print   "Right level"
164
                movzx   eax, [RVolume.level]
164
                movzx   eax, [RVolume.level]
165
                dph     eax
165
                dph     eax
166
                newline
166
                newline
167
                print   "Right num_steps"
167
                print   "Right num_steps"
168
                movzx   eax, [RVolume.num_steps]
168
                movzx   eax, [RVolume.num_steps]
169
                dph     eax
169
                dph     eax
170
                newline
170
                newline
171
        end if
171
        end if
172
 
172
 
173
        mcall   66, 1, 1  ; Set keyboard mode to get scancodes.
173
        mcall   66, 1, 1  ; Set keyboard mode to get scancodes.
174
 
174
 
175
        mcall   37,0
175
        mcall   37,0
176
        mov     cx,ax
176
        mov     cx,ax
177
        shl     ecx,16
177
        shl     ecx,16
178
        mov     cx,WIN_H
178
        mov     cx,WIN_H
179
        mov     ebx,eax
179
        mov     ebx,eax
180
        mov     bx,WIN_W
180
        mov     bx,WIN_W
181
 
181
 
182
red:
182
red:
183
        call    draw_window
183
        call    draw_window
184
 
184
 
185
still:
185
still:
186
        mcall   10               ; Wait for an event in the queue.
186
        mcall   10               ; Wait for an event in the queue.
187
 
187
 
188
        cmp     al,1                  ; redraw request ?
188
        cmp     al,1                  ; redraw request ?
189
        jz      red
189
        jz      red
190
        cmp     al,2                  ; key in buffer ?
190
        cmp     al,2                  ; key in buffer ?
191
        jz      key
191
        jz      key
192
        cmp     al,3                  ; button in buffer ?
192
        cmp     al,3                  ; button in buffer ?
193
        jz      button
193
        jz      button
194
 
194
 
195
        jmp     still
195
        jmp     still
196
 
196
 
197
key:
197
key:
198
        mcall   2
198
        mcall   2
199
 
199
 
200
        cmp     ah, 1 ;Esc
200
        cmp     ah, 1 ;Esc
201
        je      close_app
201
        je      close_app
202
 
202
 
203
;        cmp     ah, 5  ; '4'
203
;        cmp     ah, 5  ; '4'
204
;        jne     @f
204
;        jne     @f
205
;        stdcall GetMasterVol, 0
205
;        stdcall GetMasterVol, 0
206
;        jmp     still
206
;        jmp     still
207
;       @@:
207
;       @@:
208
;
208
;
209
;        cmp     ah, 6  ; '5'
209
;        cmp     ah, 6  ; '5'
210
;        jne     @f
210
;        jne     @f
211
;        stdcall GetMasterVol, 1
211
;        stdcall GetMasterVol, 1
212
;        jmp     still
212
;        jmp     still
213
;       @@:
213
;       @@:
214
 
214
 
215
;        cmp     ah, 8  ; '7'
215
;        cmp     ah, 8  ; '7'
216
;        jne     @f
216
;        jne     @f
217
;        call    GetDriverVer
217
;        call    GetDriverVer
218
;        jmp     still
218
;        jmp     still
219
;       @@:
219
;       @@:
220
 
220
 
221
        ;Left channel Up
221
        ;Left channel Up
222
        cmp     ah, 71  ; 'Home'
222
        cmp     ah, 71  ; 'Home'
223
        jne     @f
223
        jne     @f
224
        movzx   eax, [LVolume.level]
224
        movzx   eax, [LVolume.level]
225
        inc     ax
225
        inc     ax
226
        cmp     ax, [LVolume.num_steps]
226
        cmp     ax, [LVolume.num_steps]
227
        jg      still
227
        jg      still
228
        mov     [LVolume.level], ax
228
        mov     [LVolume.level], ax
229
        call    convert_level_to_ac97_volume ;Asper: temporary workaround on ac97
229
        call    convert_level_to_ac97_volume ;Asper: temporary workaround on ac97
230
        stdcall SetMasterVol, 0, eax
230
        stdcall SetMasterVol, 0, eax
231
        jmp     red
231
        jmp     red
232
       @@:
232
       @@:
233
 
233
 
234
        ;Left channel Down
234
        ;Left channel Down
235
        cmp     ah, 79  ; 'End'
235
        cmp     ah, 79  ; 'End'
236
        jne     @f
236
        jne     @f
237
        movzx   eax, [LVolume.level]
237
        movzx   eax, [LVolume.level]
238
        dec     ax
238
        dec     ax
239
        cmp     ax, 0
239
        cmp     ax, 0
240
        jl      still
240
        jl      still
241
        mov     [LVolume.level], ax
241
        mov     [LVolume.level], ax
242
        call    convert_level_to_ac97_volume ;Asper: temporary workaround on ac97
242
        call    convert_level_to_ac97_volume ;Asper: temporary workaround on ac97
243
        stdcall SetMasterVol, 0, eax
243
        stdcall SetMasterVol, 0, eax
244
        jmp     red
244
        jmp     red
245
       @@:
245
       @@:
246
 
246
 
247
        ;Right channel Up
247
        ;Right channel Up
248
        cmp     ah, 73  ; 'PageUp'
248
        cmp     ah, 73  ; 'PageUp'
249
        jne     @f
249
        jne     @f
250
        movzx   eax, [RVolume.level]
250
        movzx   eax, [RVolume.level]
251
        inc     ax
251
        inc     ax
252
        cmp     ax, [RVolume.num_steps]
252
        cmp     ax, [RVolume.num_steps]
253
        jg      still
253
        jg      still
254
        mov     [RVolume.level], ax
254
        mov     [RVolume.level], ax
255
        call    convert_level_to_ac97_volume ;Asper: temporary workaround on ac97
255
        call    convert_level_to_ac97_volume ;Asper: temporary workaround on ac97
256
        movzx   edx, [is_hda]
256
        movzx   edx, [is_hda]
257
        stdcall SetMasterVol, edx, eax
257
        stdcall SetMasterVol, edx, eax
258
        jmp     red
258
        jmp     red
259
       @@:
259
       @@:
260
 
260
 
261
        ;Right channel Down
261
        ;Right channel Down
262
        cmp     ah, 81  ; 'PageDown'
262
        cmp     ah, 81  ; 'PageDown'
263
        jne     @f
263
        jne     @f
264
        movzx   eax, [RVolume.level]
264
        movzx   eax, [RVolume.level]
265
        dec     ax
265
        dec     ax
266
        cmp     ax, 0
266
        cmp     ax, 0
267
        jl      still
267
        jl      still
268
        mov     [RVolume.level], ax
268
        mov     [RVolume.level], ax
269
        call    convert_level_to_ac97_volume ;Asper: temporary workaround on ac97
269
        call    convert_level_to_ac97_volume ;Asper: temporary workaround on ac97
270
    .RVdown:
270
    .RVdown:
271
        movzx   edx, [is_hda]
271
        movzx   edx, [is_hda]
272
        stdcall SetMasterVol, edx, eax
272
        stdcall SetMasterVol, edx, eax
273
        jmp     red
273
        jmp     red
274
       @@:
274
       @@:
275
 
275
 
276
        jmp     still
276
        jmp     still
277
 
277
 
278
button:
278
button:
279
        mcall   17             ; Get pressed button code
279
        mcall   17             ; Get pressed button code
280
        cmp     ah, 1               ; Test x button
280
        cmp     ah, 1               ; Test x button
281
        je      close_app
281
        je      close_app
282
        jmp     still
282
        jmp     still
283
 
283
 
284
 
284
 
285
draw_window:
285
draw_window:
286
        ;start_draw_window WIN_X,WIN_Y,WIN_W,WIN_H,WIN_COLOR,caption;, 12;labellen-labelt
286
        ;start_draw_window WIN_X,WIN_Y,WIN_W,WIN_H,WIN_COLOR,caption;, 12;labellen-labelt
287
        mcall   0,,,34000000h+WIN_COLOR,,caption
287
        mcall   0,,,34000000h+WIN_COLOR,,caption
288
 
288
 
289
 
289
 
290
        stdcall draw_button,  WIN_X_CENTER-BUT_W-55, 30+BUT_H*0,BUT_W,BUT_H,2,C_PINK,aNoText,0,0
290
        stdcall draw_button,  WIN_X_CENTER-BUT_W-55, 30+BUT_H*0,BUT_W,BUT_H,2,C_PINK,aNoText,0,0
291
        stdcall draw_button,  WIN_X_CENTER-BUT_W-55, 30+BUT_H*1+10,BUT_W,BUT_H,3,C_GREEN,aNoText,0,0
291
        stdcall draw_button,  WIN_X_CENTER-BUT_W-55, 30+BUT_H*1+10,BUT_W,BUT_H,3,C_GREEN,aNoText,0,0
292
        stdcall draw_button,  WIN_X_CENTER-BUT_W-55, 30+BUT_H*2+20,BUT_W,BUT_H,4,C_BLUE,aNoText,0,0
292
        stdcall draw_button,  WIN_X_CENTER-BUT_W-55, 30+BUT_H*2+20,BUT_W,BUT_H,4,C_BLUE,aNoText,0,0
293
 
293
 
294
        stdcall draw_button,  WIN_X_CENTER-BUT_W/2+55, 30+BUT_H*0,BUT_W,BUT_H,5,C_GREY,aNoText,0,0
294
        stdcall draw_button,  WIN_X_CENTER-BUT_W/2+55, 30+BUT_H*0,BUT_W,BUT_H,5,C_GREY,aNoText,0,0
295
        stdcall draw_button,  WIN_X_CENTER-BUT_W/2+55, 30+BUT_H*1+10,BUT_W,BUT_H,6,C_BLACK,aNoText,0,0
295
        stdcall draw_button,  WIN_X_CENTER-BUT_W/2+55, 30+BUT_H*1+10,BUT_W,BUT_H,6,C_BLACK,aNoText,0,0
296
        stdcall draw_button,  WIN_X_CENTER-BUT_W/2+55, 30+BUT_H*2+20,BUT_W,BUT_H,7,C_ORANGE,aNoText,0,0
296
        stdcall draw_button,  WIN_X_CENTER-BUT_W/2+55, 30+BUT_H*2+20,BUT_W,BUT_H,7,C_ORANGE,aNoText,0,0
297
 
297
 
298
        movzx   eax, [LVolume.level]
298
        movzx   eax, [LVolume.level]
299
        movzx   edx, [LVolume.num_steps]
299
        movzx   edx, [LVolume.num_steps]
300
        stdcall draw_volume_control, WIN_X_CENTER-BUT_W-25, 20, 110, aLVolume, C_BLACK, eax, edx
300
        stdcall draw_volume_control, WIN_X_CENTER-BUT_W-25, 20, 110, aLVolume, C_BLACK, eax, edx
301
        movzx   eax, [RVolume.level]
301
        movzx   eax, [RVolume.level]
302
        movzx   edx, [RVolume.num_steps]
302
        movzx   edx, [RVolume.num_steps]
303
        stdcall draw_volume_control, WIN_X_CENTER+25, 20, 110, aRVolume, C_BLACK, eax, edx
303
        stdcall draw_volume_control, WIN_X_CENTER+25, 20, 110, aRVolume, C_BLACK, eax, edx
304
 
304
 
305
        stdcall rectangle, WIN_X_CENTER-BUT_W-56, 29+BUT_H*0, BUT_W+2, BUT_H+2, C_BLACK
305
        stdcall rectangle, WIN_X_CENTER-BUT_W-56, 29+BUT_H*0, BUT_W+2, BUT_H+2, C_BLACK
306
        stdcall rectangle, WIN_X_CENTER-BUT_W-56, 29+BUT_H*1+10, BUT_W+2, BUT_H+2, C_BLACK
306
        stdcall rectangle, WIN_X_CENTER-BUT_W-56, 29+BUT_H*1+10, BUT_W+2, BUT_H+2, C_BLACK
307
        stdcall rectangle, WIN_X_CENTER-BUT_W-56, 29+BUT_H*2+20, BUT_W+2, BUT_H+2, C_BLACK
307
        stdcall rectangle, WIN_X_CENTER-BUT_W-56, 29+BUT_H*2+20, BUT_W+2, BUT_H+2, C_BLACK
308
 
308
 
309
        stdcall rectangle, WIN_X_CENTER-BUT_W/2+54, 29+BUT_H*0, BUT_W+2, BUT_H+2, C_BLACK
309
        stdcall rectangle, WIN_X_CENTER-BUT_W/2+54, 29+BUT_H*0, BUT_W+2, BUT_H+2, C_BLACK
310
        stdcall rectangle, WIN_X_CENTER-BUT_W/2+54, 29+BUT_H*1+10, BUT_W+2, BUT_H+2, C_GREEN
310
        stdcall rectangle, WIN_X_CENTER-BUT_W/2+54, 29+BUT_H*1+10, BUT_W+2, BUT_H+2, C_GREEN
311
        stdcall rectangle, WIN_X_CENTER-BUT_W/2+54, 29+BUT_H*2+20, BUT_W+2, BUT_H+2, C_BLACK
311
        stdcall rectangle, WIN_X_CENTER-BUT_W/2+54, 29+BUT_H*2+20, BUT_W+2, BUT_H+2, C_BLACK
312
 
312
 
313
        stdcall rectangle, WIN_X_CENTER-BUT_W-57, 28+BUT_H*0, BUT_W+4, BUT_H+4, C_PINK
313
        stdcall rectangle, WIN_X_CENTER-BUT_W-57, 28+BUT_H*0, BUT_W+4, BUT_H+4, C_PINK
314
        stdcall rectangle, WIN_X_CENTER-BUT_W-57, 28+BUT_H*1+10, BUT_W+4, BUT_H+4, C_GREEN
314
        stdcall rectangle, WIN_X_CENTER-BUT_W-57, 28+BUT_H*1+10, BUT_W+4, BUT_H+4, C_GREEN
315
        stdcall rectangle, WIN_X_CENTER-BUT_W-57, 28+BUT_H*2+20, BUT_W+4, BUT_H+4, C_BLUE
315
        stdcall rectangle, WIN_X_CENTER-BUT_W-57, 28+BUT_H*2+20, BUT_W+4, BUT_H+4, C_BLUE
316
 
316
 
317
        stdcall rectangle, WIN_X_CENTER-BUT_W/2+53, 28+BUT_H*0, BUT_W+4, BUT_H+4, C_GREY
317
        stdcall rectangle, WIN_X_CENTER-BUT_W/2+53, 28+BUT_H*0, BUT_W+4, BUT_H+4, C_GREY
318
        stdcall rectangle, WIN_X_CENTER-BUT_W/2+53, 28+BUT_H*1+10, BUT_W+4, BUT_H+4, C_BLACK;
318
        stdcall rectangle, WIN_X_CENTER-BUT_W/2+53, 28+BUT_H*1+10, BUT_W+4, BUT_H+4, C_BLACK;
319
        stdcall rectangle, WIN_X_CENTER-BUT_W/2+53, 28+BUT_H*2+20, BUT_W+4, BUT_H+4, C_ORANGE
319
        stdcall rectangle, WIN_X_CENTER-BUT_W/2+53, 28+BUT_H*2+20, BUT_W+4, BUT_H+4, C_ORANGE
320
 
320
 
321
 
321
 
322
        end_draw_window
322
        end_draw_window
323
ret
323
ret
324
 
324
 
325
 
325
 
326
 
326
 
327
proc draw_volume_control stdcall, x:dword, y:dword, ysize:dword, name:dword, textcolor:dword, step:dword, max_steps:dword
327
proc draw_volume_control stdcall, x:dword, y:dword, ysize:dword, name:dword, textcolor:dword, step:dword, max_steps:dword
328
        mov     ebx, [x]
328
        mov     ebx, [x]
329
        mov     edx, [y]
329
        mov     edx, [y]
330
        mov     eax, [ysize]
330
        mov     eax, [ysize]
331
        stdcall bar, ebx, edx, 10, eax, C_GREEN
331
        stdcall bar, ebx, edx, 10, eax, C_GREEN
332
        mov     ecx, [max_steps]
332
        mov     ecx, [max_steps]
333
        cmp     ecx, [step]
333
        cmp     ecx, [step]
334
        je      .l2
334
        je      .l2
335
 
335
 
336
        push    eax  edx
336
        push    eax  edx
337
        mov     cl,  byte [max_steps]
337
        mov     cl,  byte [max_steps]
338
        test    cl, cl
338
        test    cl, cl
339
        jnz     @f
339
        jnz     @f
340
        mov     ecx, [ysize]
340
        mov     ecx, [ysize]
341
        jmp     .l1
341
        jmp     .l1
342
  @@:
342
  @@:
343
        div     cl
343
        div     cl
344
        mov     cl,  byte [step]
344
        mov     cl,  byte [step]
345
        mul     cl
345
        mul     cl
346
        mov     ecx, [ysize]
346
        mov     ecx, [ysize]
347
        sub     ecx, eax
347
        sub     ecx, eax
348
  .l1:
348
  .l1:
349
        pop     edx  eax
349
        pop     edx  eax
350
        stdcall bar, ebx, edx, 10, ecx, C_RED
350
        stdcall bar, ebx, edx, 10, ecx, C_RED
351
  .l2:
351
  .l2:
352
        dec     ebx
352
        dec     ebx
353
        dec     edx
353
        dec     edx
354
        inc     eax
354
        inc     eax
355
        stdcall rectangle, ebx, edx, 11, eax, C_BLACK
355
        stdcall rectangle, ebx, edx, 11, eax, C_BLACK
356
 
356
 
357
 
357
 
358
        add     edx, eax
358
        add     edx, eax
359
        add     edx, 10
359
        add     edx, 10
360
        sub     ebx, 8
360
        sub     ebx, 8
361
        stdcall outtextxy, ebx, edx, [name], 0, C_GREEN or 0x80000000
361
        stdcall outtextxy, ebx, edx, [name], 0, C_GREEN or 0x80000000
362
        ret
362
        ret
363
endp
363
endp
364
 
364
 
365
;____________________________________
365
;____________________________________
366
GetDriverVer:
366
GetDriverVer:
367
        push    ebx ecx
367
        push    ebx ecx
368
        mov     [ioctl_code], SRV_GETVERSION
368
        mov     [ioctl_code], SRV_GETVERSION
369
        and     [inp_size], 0
369
        and     [inp_size], 0
370
        mov     [outp_size], 4
370
        mov     [outp_size], 4
371
        mov     [output], driver_ver
371
        mov     [output], driver_ver
372
        mcall   68,17,ioctl
372
        mcall   68,17,ioctl
373
        test    eax, eax
373
        test    eax, eax
374
        jnz     loaderr
374
        jnz     loaderr
375
        if DEBUG
375
        if DEBUG
376
                push    eax
376
                push    eax
377
                dps     "1.) Driver version = "
377
                dps     "1.) Driver version = "
378
                dph     [driver_ver]
378
                dph     [driver_ver]
379
                newline
379
                newline
380
                pop     eax
380
                pop     eax
381
        end if
381
        end if
382
        pop     ecx ebx
382
        pop     ecx ebx
383
ret
383
ret
384
 
384
 
385
;____________________________________
385
;____________________________________
386
Stop:
386
Stop:
387
        and     [ioctl_code], DEV_STOP
387
        and     [ioctl_code], DEV_STOP
388
        and     [inp_size], 4
388
        and     [inp_size], 4
389
        mov     [input], 0 ;? stream
389
        mov     [input], 0 ;? stream
390
        mov     [outp_size], 0
390
        mov     [outp_size], 0
391
        mov     [output], 0
391
        mov     [output], 0
392
        mcall   68,17,ioctl
392
        mcall   68,17,ioctl
393
        test    eax, eax
393
        test    eax, eax
394
        jnz     loaderr
394
        jnz     loaderr
395
        if DEBUG
395
        if DEBUG
396
                print   "Stop device"
396
                print   "Stop device"
397
        end if
397
        end if
398
ret
398
ret
399
 
399
 
400
;____________________________________
400
;____________________________________
401
proc GetMasterVol stdcall, channel:dword
401
proc GetMasterVol stdcall, channel:dword
402
        push    ebx ecx
402
        push    ebx ecx
403
        mov     [ioctl_code], DEV_GET_MASTERVOL
403
        mov     [ioctl_code], DEV_GET_MASTERVOL
404
        mov     [inp_size], 1
404
        mov     [inp_size], 1
405
        mov     eax, [channel]
405
        mov     eax, [channel]
406
        mov     [input], eax
406
        mov     [input], eax
407
        mov     [outp_size], 4
407
        mov     [outp_size], 4
408
        mov     [output], master_vol
408
        mov     [output], master_vol
409
        mcall   68,17,ioctl
409
        mcall   68,17,ioctl
410
        if DEBUG
410
        if DEBUG
411
                push    eax
411
                push    eax
412
                dps     "Get Master volume = "
412
                dps     "Get Master volume = "
413
                dph     [master_vol]
413
                dph     [master_vol]
414
                newline
414
                newline
415
                pop     eax
415
                pop     eax
416
        end if
416
        end if
417
        mov     eax, [master_vol]
417
        mov     eax, [master_vol]
418
        pop     ecx ebx
418
        pop     ecx ebx
419
ret
419
ret
420
endp
420
endp
421
;____________________________________
421
;____________________________________
422
proc SetMasterVol stdcall, channel:dword, val:dword
422
proc SetMasterVol stdcall, channel:dword, val:dword
423
        push    ebx ecx
423
        push    ebx ecx
424
        mov     [ioctl_code], DEV_SET_MASTERVOL
424
        mov     [ioctl_code], DEV_SET_MASTERVOL
425
        mov     [inp_size], 4
425
        mov     [inp_size], 4
426
        mov     eax, [channel]
426
        mov     eax, [channel]
427
        shl     eax, 24
427
        shl     eax, 24
428
        or      eax, [val]
428
        or      eax, [val]
429
        mov     [master_vol], eax
429
        mov     [master_vol], eax
430
        mov     [input], master_vol
430
        mov     [input], master_vol
431
        mov     [outp_size], 0
431
        mov     [outp_size], 0
432
        mcall   68,17,ioctl
432
        mcall   68,17,ioctl
433
        if DEBUG
433
        if DEBUG
434
                push    eax
434
                push    eax
435
                dps     "Set Master volume = "
435
                dps     "Set Master volume = "
436
                dph     [val]
436
                dph     [val]
437
                dps     "    ch = "
437
                dps     "    ch = "
438
                dph     [channel]
438
                dph     [channel]
439
                newline
439
                newline
440
                pop     eax
440
                pop     eax
441
        end if
441
        end if
442
        pop     ecx ebx
442
        pop     ecx ebx
443
ret
443
ret
444
endp
444
endp
445
 
445
 
446
;____________________________________
446
;____________________________________
447
;GetDevInfo: ; Get pins configurations or controls
447
;GetDevInfo: ; Get pins configurations or controls
448
;        mov     [ioctl_code], DEV_GET_INFO
448
;        mov     [ioctl_code], DEV_GET_INFO
449
;        and     [inp_size], 0
449
;        and     [inp_size], 0
450
;        mov     [outp_size], 9*4
450
;        mov     [outp_size], 9*4
451
;        mov     [output], ctrl_info
451
;        mov     [output], ctrl_info
452
;        mcall   68,17,ioctl
452
;        mcall   68,17,ioctl
453
;        if DEBUG
453
;        if DEBUG
454
;                push    eax
454
;                push    eax
455
;                print   "CTRL_INFO"
455
;                print   "CTRL_INFO"
456
;                dps     ".pci_cmd = "
456
;                dps     ".pci_cmd = "
457
;                dph     [ctrl_info]
457
;                dph     [ctrl_info]
458
;                newline
458
;                newline
459
;                dps     ".irq = "
459
;                dps     ".irq = "
460
;                dph     [ctrl_info+4]
460
;                dph     [ctrl_info+4]
461
;                newline
461
;                newline
462
;                ;dps     ".glob_cntrl = "
462
;                ;dps     ".glob_cntrl = "
463
;                dps     ".VIA_REG_OFFSET_CONTROL = "
463
;                dps     ".VIA_REG_OFFSET_CONTROL = "
464
;                dph     [ctrl_info+8]
464
;                dph     [ctrl_info+8]
465
;                newline
465
;                newline
466
;                ;dps     ".glob_sta = "
466
;                ;dps     ".glob_sta = "
467
;                dps     ".VIA_REG_OFFSET_STATUS = "
467
;                dps     ".VIA_REG_OFFSET_STATUS = "
468
;                dph     [ctrl_info+12]
468
;                dph     [ctrl_info+12]
469
;                newline
469
;                newline
470
;                ;dps     ".codec_io_base = "
470
;                ;dps     ".codec_io_base = "
471
;                dps     ".VIA_REG_OFFSET_TABLE_PTR = "
471
;                dps     ".VIA_REG_OFFSET_TABLE_PTR = "
472
;                dph     [ctrl_info+16]
472
;                dph     [ctrl_info+16]
473
;                newline
473
;                newline
474
;                dps     ".ctrl_io_base = "
474
;                dps     ".ctrl_io_base = "
475
;                dph     [ctrl_info+20]
475
;                dph     [ctrl_info+20]
476
;                newline
476
;                newline
477
;                ;dps     ".codec_mem_base = "
477
;                ;dps     ".codec_mem_base = "
478
;                dps     ".VIA_REG_OFFSET_STOP_IDX = "
478
;                dps     ".VIA_REG_OFFSET_STOP_IDX = "
479
;                dph     [ctrl_info+24]
479
;                dph     [ctrl_info+24]
480
;                newline
480
;                newline
481
;                ;dps     ".ctrl_mem_base = "
481
;                ;dps     ".ctrl_mem_base = "
482
;                dps     ".VIA_REG_OFFSET_CURR_COUNT = "
482
;                dps     ".VIA_REG_OFFSET_CURR_COUNT = "
483
;                dph     [ctrl_info+28]
483
;                dph     [ctrl_info+28]
484
;                newline
484
;                newline
485
;                dps     ".codec_id = "
485
;                dps     ".codec_id = "
486
;                dph     [ctrl_info+32]
486
;                dph     [ctrl_info+32]
487
;                newline
487
;                newline
488
;                pop     eax
488
;                pop     eax
489
;        end if
489
;        end if
490
;ret
490
;ret
491
 
491
 
492
 
492
 
493
convert_level_to_ac97_volume:
493
convert_level_to_ac97_volume:
494
        push   ebx ecx edx
494
        push   ebx ecx edx
495
        cmp    [is_hda], 0
495
        cmp    [is_hda], 0
496
        jne    .not_ac97
496
        jne    .not_ac97
497
 
497
 
498
        mov     [LVolume.level], ax
498
        mov     [LVolume.level], ax
499
        mov     [RVolume.level], ax
499
        mov     [RVolume.level], ax
500
 
500
 
501
        mov    bx, ax
501
        mov    bx, ax
502
        mov    ax, [LVolume.num_steps]
502
        mov    ax, [LVolume.num_steps]
503
        sub    ax, bx
503
        sub    ax, bx
504
        mov    cx, 150
504
        mov    cx, 150
505
        mul    cx
505
        mul    cx
506
        neg    eax
506
        neg    eax
507
  .not_ac97:
507
  .not_ac97:
508
        pop    edx ecx ebx
508
        pop    edx ecx ebx
509
ret
509
ret
510
 
510
 
511
 
511
 
512
convert_ac97_volume_to_level:
512
convert_ac97_volume_to_level:
513
        push   ebx ecx edx
513
        push   ebx ecx edx
514
        cmp    [is_hda], 0
514
        cmp    [is_hda], 0
515
        jne    .not_ac97
515
        jne    .not_ac97
516
 
516
 
517
        neg    eax
517
        neg    eax
518
        mov    cx, 150
518
        mov    cx, 150
519
        div    cx
519
        div    cx
520
        mov    bx, ax
520
        mov    bx, ax
521
        mov    ax, [LVolume.num_steps]
521
        mov    ax, [LVolume.num_steps]
522
        sub    ax, bx
522
        sub    ax, bx
523
  .not_ac97:
523
  .not_ac97:
524
        pop    edx ecx ebx
524
        pop    edx ecx ebx
525
ret
525
ret
526
 
526
 
527
 
527
 
528
close_app:
528
close_app:
529
        or      eax, -1
529
        or      eax, -1
530
        int     0x40
530
        int     0x40
531
;____________________________________
531
;____________________________________
532
caption db 'Sound Mixer',0
532
caption db 'Sound Mixer',0
533
drivername db 'SOUND',0
533
drivername db 'SOUND',0
534
 
534
 
535
;aRamdisk db '/rd/1/',0
535
;aRamdisk db '/rd/1/',0
536
 
536
 
537
;aStartDriver db 'Start driver',0
537
;aStartDriver db 'Start driver',0
538
;aStop        db 'Stop',0
538
;aStop        db 'Stop',0
539
;aGetMVol     db 'Get Master Volume',0
539
;aGetMVol     db 'Get Master Volume',0
540
;aSetMVol    db 'Set Master Volume',0
540
;aSetMVol    db 'Set Master Volume',0
541
;aGetDevInfo  db 'Get device info',0
541
;aGetDevInfo  db 'Get device info',0
542
aNoText      db 0
542
aNoText      db 0
543
 
543
 
544
aLVolume     db 'Left',0
544
aLVolume     db 'Left',0
545
aRVolume     db 'Right',0
545
aRVolume     db 'Right',0
546
 
546
 
547
; Jack types
547
; Jack types
548
;aLineOut     db 'Line Out',0
548
;aLineOut     db 'Line Out',0
549
;aSpeaker     db 'Speaker',0
549
;aSpeaker     db 'Speaker',0
550
;aHPOut       db 'HP Out',0
550
;aHPOut       db 'HP Out',0
551
;aSideSpk     db '',0
551
;aSideSpk     db '',0
552
;aCD          db 'CD',0
552
;aCD          db 'CD',0
553
;aSPDIFOut    db 'SPDIF Out',0
553
;aSPDIFOut    db 'SPDIF Out',0
554
;aDigitalOut  db 'Digital Out',0
554
;aDigitalOut  db 'Digital Out',0
555
;aModemLine   db 'Modem Line',0
555
;aModemLine   db 'Modem Line',0
556
;aModemHand   db 'Modem Hand',0
556
;aModemHand   db 'Modem Hand',0
557
;aLineIn      db 'Line In',0
557
;aLineIn      db 'Line In',0
558
;aAUX         db 'AUX',0
558
;aAUX         db 'AUX',0
559
;aMic         db 'Mic',0
559
;aMic         db 'Mic',0
560
;aTelephony   db 'Telephony',0
560
;aTelephony   db 'Telephony',0
561
;aSPDIFIn     db 'SPDIF In',0
561
;aSPDIFIn     db 'SPDIF In',0
562
;aDigitalIn   db 'Digital In',0
562
;aDigitalIn   db 'Digital In',0
563
;aReserved    db 'Reserved',0
563
;aReserved    db 'Reserved',0
564
;aOther       db 'Other',0
564
;aOther       db 'Other',0
565
 
565
 
566
;Jack locations
566
;Jack locations
567
;base
567
;base
568
;aNA          db 'N/A',0
568
;aNA          db 'N/A',0
569
;aRear        db 'Rear',0
569
;aRear        db 'Rear',0
570
;aFront       db 'Front',0
570
;aFront       db 'Front',0
571
;aLeft        db 'Left',0
571
;aLeft        db 'Left',0
572
;aRight       db 'Right',0
572
;aRight       db 'Right',0
573
;aTop         db 'Top',0
573
;aTop         db 'Top',0
574
;aBottom      db 'Bottom',0
574
;aBottom      db 'Bottom',0
575
;special
575
;special
576
;aRearPanel   db 'Rear Panel',0
576
;aRearPanel   db 'Rear Panel',0
577
;aDriveBar    db 'Drive Bar',0
577
;aDriveBar    db 'Drive Bar',0
578
;aRiser       db 'Riser',0
578
;aRiser       db 'Riser',0
579
;aHDMI        db 'HDMI',0
579
;aHDMI        db 'HDMI',0
580
;aATAPI       db 'ATAPI',0
580
;aATAPI       db 'ATAPI',0
581
;aMobileIn    db 'Mobile-In',0
581
;aMobileIn    db 'Mobile-In',0
582
;aMobileOut   db 'Mobile-Out',0
582
;aMobileOut   db 'Mobile-Out',0
583
 
583
 
584
 
584
 
585
I_END:
585
I_END:
586
 
586
 
587
align 4
587
align 4
588
ioctl:
588
ioctl:
589
hDriver         rd 1
589
hDriver         rd 1
590
ioctl_code      rd 1
590
ioctl_code      rd 1
591
input           rd 1
591
input           rd 1
592
inp_size        rd 1
592
inp_size        rd 1
593
output          rd 1
593
output          rd 1
594
outp_size       rd 1
594
outp_size       rd 1
595
 
595
 
596
driver_ver      rd 1
596
driver_ver      rd 1
597
master_vol      rd 1
597
master_vol      rd 1
598
 
598
 
599
;ctrl_info       rd 9
599
;ctrl_info       rd 9
600
 
600
 
601
is_hda          rb 1
601
is_hda          rb 1
602
 
602
 
603
LVolume CONTROL
603
LVolume CONTROL
604
RVolume CONTROL
604
RVolume CONTROL
605
 
605
 
606
align 4
606
align 4
607
rb 2048 ; stack
607
rb 2048 ; stack
608
I_MEM:
608
I_MEM: