Subversion Repositories Kolibri OS

Rev

Rev 9715 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9715 Rev 9910
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2022. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2023. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
6
;;  PLAYNOTE.INC                    version 1.1  22 November 2003  ;;
6
;;  PLAYNOTE.INC                    version 1.1  22 November 2003  ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;  Player Notes for Speaker PC                                    ;;
8
;;  Player Notes for Speaker PC                                    ;;
Line 14... Line 14...
14
;;                                                                 ;;
14
;;                                                                 ;;
15
;;  Note: playnote.txt                                             ;;
15
;;  Note: playnote.txt                                             ;;
16
;;                                                                 ;;
16
;;                                                                 ;;
17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 18... Line 18...
18
 
18
 
Line 19... Line 19...
19
$Revision: 9715 $
19
$Revision: 9910 $
20
 
20
 
Line 21... Line 21...
21
align 4
21
align 4
22
sound_interface:
22
sound_interface:
Line 23... Line 23...
23
 
23
 
24
        cmp     eax, ebx                        ; this is subfunction #55 ?
24
        cmp     eax, ebx                        ; this is subfunction #55 ?
Line 25... Line 25...
25
        jne     retFunc55                       ; if no then return.
25
        jne     .ret                            ; if no then return.
26
 
26
 
27
        cmp     byte [sound_flag], 0
27
        cmp     byte [sound_flag], 0
Line 28... Line 28...
28
        jne     retFunc55
28
        jne     .ret
29
 
29
 
30
        movzx   eax, byte [countDelayNote]
30
        movzx   eax, byte [countDelayNote]
31
        or      al, al                          ; player is busy ?
31
        or      al, al                          ; player is busy ?
32
        jnz     retFunc55                       ; return counter delay Note
32
        jnz     .ret                            ; return counter delay Note
33
 
33
 
34
        mov     [memAdrNote], esi;edx
34
        mov     [memAdrNote], esi;edx
Line 35... Line 35...
35
        call    get_pid
35
        call    get_pid
36
        mov     [pidProcessNote], eax
36
        mov     [pidProcessNote], eax
37
        xor     eax, eax                       ; Ok!  EAX = 0
37
        xor     eax, eax                        ; Ok!  EAX = 0
Line 53... Line 53...
53
 
53
 
54
playNote:
54
playNote:
55
;      jmp   NotPlayNotes
55
;      jmp   NotPlayNotes
56
        mov     esi, [memAdrNote]
56
        mov     esi, [memAdrNote]
57
        or      esi, esi         ; ESI = 0 ?  - OFF Notes Play ?
57
        or      esi, esi         ; ESI = 0 ?  - OFF Notes Play ?
58
        jz      NotPlayNotes     ; if ESI = 0   -> ignore play pocedure
58
        jz      .NotPlayNotes    ; if ESI = 0   -> ignore play pocedure
59
        cmp     eax, [count_timer_Note]
59
        cmp     eax, [count_timer_Note]
60
        jb      NotPlayNotes
60
        jb      .NotPlayNotes
61
        push    eax
61
        push    eax
62
        inc     eax
62
        inc     eax
63
        mov     [count_timer_Note], eax
63
        mov     [count_timer_Note], eax
64
        mov     al, [countDelayNote]
64
        mov     al, [countDelayNote]
65
        dec     al               ; decrement counter Delay for Playing Note
65
        dec     al               ; decrement counter Delay for Playing Note
66
        jz      NewLoadNote@Delay
66
        jz      .NewLoadNote@Delay
67
        cmp     al, 0xFF         ; this is first Note Play ?
67
        cmp     al, 0xFF         ; this is first Note Play ?
68
        jne     NextDelayNote
68
        jne     .NextDelayNote
69
      ;This is FIRST Note, save counter channel 2 chip 8253
69
        ;This is FIRST Note, save counter channel 2 chip 8253
70
        mov     al, 0xB6         ; control byte to timer chip 8253
70
        mov     al, 0xB6         ; control byte to timer chip 8253
71
        out     0x43, al         ; Send it to the control port chip 8253
71
        out     0x43, al         ; Send it to the control port chip 8253
72
        in      al, 0x42         ; Read Lower byte counter channel 2 chip 8253
72
        in      al, 0x42         ; Read Lower byte counter channel 2 chip 8253
73
        mov     ah, al           ; AH = Lower byte counter channel 2
73
        mov     ah, al           ; AH = Lower byte counter channel 2
74
        in      al, 0x42         ; Read Upper byte counter channel 2 chip 8253
74
        in      al, 0x42         ; Read Upper byte counter channel 2 chip 8253
75
        mov     [mem8253r42], ax ; Save counter channel 2 timer chip 8253
75
        mov     [mem8253r42], ax ; Save counter channel 2 timer chip 8253
76
   NewLoadNote@Delay:
76
   .NewLoadNote@Delay:
77
        cld
77
        cld
78
;      lodsb                      ; load AL - counter Delay
78
;      lodsb                      ; load AL - counter Delay
79
        call    ReadNoteByte
79
        call    ReadNoteByte
80
        or      al, al           ; THE END ?
80
        or      al, al           ; THE END ?
81
        jz      EndPlayNote
81
        jz      .EndPlayNote
82
        cmp     al, 0x81
82
        cmp     al, 0x81
83
        jnc     NoteforOctave
83
        jnc     .NoteforOctave
84
        mov     [countDelayNote], al
84
        mov     [countDelayNote], al
85
;      lodsw                      ; load AX - counter for Note!
85
;      lodsw                      ; load AX - counter for Note!
86
        call    ReadNoteByte
86
        call    ReadNoteByte
87
        mov     ah, al
87
        mov     ah, al
88
        call    ReadNoteByte
88
        call    ReadNoteByte
89
        xchg    al, ah
89
        xchg    al, ah
Line 90... Line 90...
90
        jmp     pokeNote
90
        jmp     .pokeNote
91
 
91
 
92
   EndPlayNote:                  ; THE END Play Notes!
92
   .EndPlayNote:                 ; THE END Play Notes!
93
        in      al, 0x61         ; Get contents of system port B chip 8255
93
        in      al, 0x61         ; Get contents of system port B chip 8255
94
        and     al, 0xFC         ; Turn OFF timer and speaker
94
        and     al, 0xFC         ; Turn OFF timer and speaker
95
        out     0x61, al         ; Send out new values to port B chip 8255
95
        out     0x61, al         ; Send out new values to port B chip 8255
96
        mov     ax, [mem8253r42] ; memorize counter channel 2 timer chip 8253
96
        mov     ax, [mem8253r42] ; memorize counter channel 2 timer chip 8253
97
        xchg    al, ah           ; reverse byte in word
97
        xchg    al, ah           ; reverse byte in word
98
        out     0x42, al         ; restore Lower byte counter channel 2
98
        out     0x42, al         ; restore Lower byte counter channel 2
99
        mov     al, ah           ; AL = Upper byte counter channel 2
99
        mov     al, ah           ; AL = Upper byte counter channel 2
100
        out     0x42, al         ; restore Upper byte channel 2
100
        out     0x42, al         ; restore Upper byte channel 2
101
        xor     eax, eax         ; EAX = 0
101
        xor     eax, eax         ; EAX = 0
102
        mov     [memAdrNote], eax; clear header control Delay-Note string
102
        mov     [memAdrNote], eax; clear header control Delay-Note string
103
   NextDelayNote:
103
   .NextDelayNote:
104
        mov     [countDelayNote], al; save new counter delay Note
104
        mov     [countDelayNote], al; save new counter delay Note
105
        pop     eax
105
        pop     eax
Line 106... Line 106...
106
   NotPlayNotes:
106
   .NotPlayNotes:
107
        RET
107
        ret
108
 
108
 
109
   NoteforOctave:
109
   .NoteforOctave:
110
        sub     al, 0x81         ; correction value for delay Note
110
        sub     al, 0x81         ; correction value for delay Note
111
        mov     [countDelayNote], al; save counter delay this new Note
111
        mov     [countDelayNote], al; save counter delay this new Note
112
;      lodsb                      ; load pack control code
112
;      lodsb                      ; load pack control code
113
        call    ReadNoteByte
113
        call    ReadNoteByte
114
        cmp     al, 0xFF         ; this is PAUSE ?
114
        cmp     al, 0xFF         ; this is PAUSE ?
115
        jne     packCode         ; no, this is PACK CODE
115
        jne     .packCode        ; no, this is PACK CODE
116
        in      al, 0x61         ; Get contents of system port B chip 8255
116
        in      al, 0x61         ; Get contents of system port B chip 8255
Line 117... Line 117...
117
        and     al, 0xFC         ; Turn OFF timer and speaker
117
        and     al, 0xFC         ; Turn OFF timer and speaker
118
        out     0x61, al         ; Send out new values to port B chip 8255
118
        out     0x61, al         ; Send out new values to port B chip 8255
119
        jmp     saveESI
119
        jmp     .saveESI
120
 
120
 
121
   packCode:
121
   .packCode:
122
        mov     cl, al           ; save code
122
        mov     cl, al           ; save code
123
        and     al, 0xF          ; clear upper bits
123
        and     al, 0xF          ; clear upper bits
124
        dec     al               ; correction
124
        dec     al               ; correction
125
        add     al, al           ; transform number to offset constant
125
        add     al, al           ; transform number to offset constant
126
        movsx   eax, al          ; EAX - offset
126
        movsx   eax, al          ; EAX - offset
127
        add     eax, dword kontrOctave; EAX - address from constant
127
        add     eax, dword kontrOctave; EAX - address from constant
128
        mov     ax, [eax]        ; read constant
128
        mov     ax, [eax]        ; read constant
129
        shr     cl, 4            ; transform for number Octave
129
        shr     cl, 4            ; transform for number Octave
130
        shr     ax, cl           ; calculate from Note this Octave!
130
        shr     ax, cl           ; calculate from Note this Octave!
131
   pokeNote:
131
   .pokeNote:
132
        out     0x42, al         ; Lower byte Out to channel 2 timer chip 8253
132
        out     0x42, al         ; Lower byte Out to channel 2 timer chip 8253
133
        mov     al, ah
133
        mov     al, ah
134
        out     0x42, al         ; Upper byte Out to channel 2 timer chip 8253
134
        out     0x42, al         ; Upper byte Out to channel 2 timer chip 8253
135
        in      al, 0x61         ; Get contents of system port B chip 8255
135
        in      al, 0x61         ; Get contents of system port B chip 8255
136
        or      al, 3            ; Turn ON timer and speaker
136
        or      al, 3            ; Turn ON timer and speaker
137
        out     0x61, al         ; Send out new values to port B chip 8255
137
        out     0x61, al         ; Send out new values to port B chip 8255
-
 
138
   .saveESI:
138
   saveESI:
139
;      mov   [memAdrNote], esi    ; save new header control Delay-Note string
139
;      mov   [memAdrNote], esi    ; save new header control Delay-Note string
140
        pop     eax
140
        pop     eax
141
        ret
141
        RET
142
 
142
ReadNoteByte:
143
ReadNoteByte: