Rev 2288 | Rev 9715 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2288 | clevermous | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
2455 | mario79 | 3 | ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
2288 | clevermous | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;; PLAYNOTE.INC version 1.1 22 November 2003 ;; |
||
7 | ;; ;; |
||
8 | ;; Player Notes for Speaker PC ;; |
||
9 | ;; subfunction #55 from function #55 Menuet OS ;; |
||
10 | ;; ;; |
||
11 | ;; Copyright 2003 VaStaNi ;; |
||
12 | ;; vastani@ukr.net ;; |
||
13 | ;; >>>- SIMPLY - QUICKLY - SHORTLY -<<< ;; |
||
14 | ;; ;; |
||
15 | ;; Note: playnote.txt ;; |
||
16 | ;; ;; |
||
17 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
18 | |||
19 | $Revision: 2455 $ |
||
20 | |||
21 | align 4 |
||
22 | sound_interface: |
||
23 | |||
24 | cmp eax, ebx ; this is subfunction #55 ? |
||
25 | jne retFunc55 ; if no then return. |
||
26 | |||
27 | cmp byte [sound_flag], 0 |
||
28 | jne retFunc55 |
||
29 | |||
30 | movzx eax, byte [countDelayNote] |
||
31 | or al, al ; player is busy ? |
||
32 | jnz retFunc55 ; return counter delay Note |
||
33 | |||
34 | mov [memAdrNote], esi;edx |
||
35 | call get_pid |
||
36 | mov [pidProcessNote], eax |
||
37 | xor eax, eax ; Ok! EAX = 0 |
||
38 | retFunc55: |
||
39 | mov [esp+32], eax ; return value EAX for application |
||
40 | ret |
||
41 | |||
42 | iglobal |
||
43 | align 4 |
||
44 | kontrOctave dw 0x4742, 0x4342, 0x3F7C, 0x3BEC, 0x388F, 0x3562 |
||
45 | dw 0x3264, 0x2F8F, 0x2CE4, 0x2A5F, 0x2802, 0x25BF |
||
46 | memAdrNote dd 0 |
||
47 | pidProcessNote dd 0 |
||
48 | slotProcessNote dd 0 |
||
49 | count_timer_Note dd 1 |
||
50 | mem8253r42 dw 0 |
||
51 | countDelayNote db 0 |
||
52 | endg |
||
53 | |||
54 | playNote: |
||
55 | ; jmp NotPlayNotes |
||
56 | mov esi, [memAdrNote] |
||
57 | or esi, esi ; ESI = 0 ? - OFF Notes Play ? |
||
58 | jz NotPlayNotes ; if ESI = 0 -> ignore play pocedure |
||
59 | cmp eax, [count_timer_Note] |
||
60 | jb NotPlayNotes |
||
61 | push eax |
||
62 | inc eax |
||
63 | mov [count_timer_Note], eax |
||
64 | mov al, [countDelayNote] |
||
65 | dec al ; decrement counter Delay for Playing Note |
||
66 | jz NewLoadNote@Delay |
||
67 | cmp al, 0xFF ; this is first Note Play ? |
||
68 | jne NextDelayNote |
||
69 | ;This is FIRST Note, save counter channel 2 chip 8253 |
||
70 | mov al, 0xB6 ; control byte to timer 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 |
||
73 | mov ah, al ; AH = Lower byte counter channel 2 |
||
74 | in al, 0x42 ; Read Upper byte counter channel 2 chip 8253 |
||
75 | mov [mem8253r42], ax ; Save counter channel 2 timer chip 8253 |
||
76 | NewLoadNote@Delay: |
||
77 | cld |
||
78 | ; lodsb ; load AL - counter Delay |
||
79 | call ReadNoteByte |
||
80 | or al, al ; THE END ? |
||
81 | jz EndPlayNote |
||
82 | cmp al, 0x81 |
||
83 | jnc NoteforOctave |
||
84 | mov [countDelayNote], al |
||
85 | ; lodsw ; load AX - counter for Note! |
||
86 | call ReadNoteByte |
||
87 | mov ah, al |
||
88 | call ReadNoteByte |
||
89 | xchg al, ah |
||
90 | jmp pokeNote |
||
91 | |||
92 | EndPlayNote: ; THE END Play Notes! |
||
93 | in al, 0x61 ; Get contents of system port B chip 8255 |
||
94 | and al, 0xFC ; Turn OFF timer and speaker |
||
95 | out 0x61, al ; Send out new values to port B chip 8255 |
||
96 | mov ax, [mem8253r42] ; memorize counter channel 2 timer chip 8253 |
||
97 | xchg al, ah ; reverse byte in word |
||
98 | out 0x42, al ; restore Lower byte counter channel 2 |
||
99 | mov al, ah ; AL = Upper byte counter channel 2 |
||
100 | out 0x42, al ; restore Upper byte channel 2 |
||
101 | xor eax, eax ; EAX = 0 |
||
102 | mov [memAdrNote], eax; clear header control Delay-Note string |
||
103 | NextDelayNote: |
||
104 | mov [countDelayNote], al; save new counter delay Note |
||
105 | pop eax |
||
106 | NotPlayNotes: |
||
107 | RET |
||
108 | |||
109 | NoteforOctave: |
||
110 | sub al, 0x81 ; correction value for delay Note |
||
111 | mov [countDelayNote], al; save counter delay this new Note |
||
112 | ; lodsb ; load pack control code |
||
113 | call ReadNoteByte |
||
114 | cmp al, 0xFF ; this is PAUSE ? |
||
115 | jne packCode ; no, this is PACK CODE |
||
116 | in al, 0x61 ; Get contents of system port B chip 8255 |
||
117 | and al, 0xFC ; Turn OFF timer and speaker |
||
118 | out 0x61, al ; Send out new values to port B chip 8255 |
||
119 | jmp saveESI |
||
120 | |||
121 | packCode: |
||
122 | mov cl, al ; save code |
||
123 | and al, 0xF ; clear upper bits |
||
124 | dec al ; correction |
||
125 | add al, al ; transform number to offset constant |
||
126 | movsx eax, al ; EAX - offset |
||
127 | add eax, dword kontrOctave; EAX - address from constant |
||
128 | mov ax, [eax] ; read constant |
||
129 | shr cl, 4 ; transform for number Octave |
||
130 | shr ax, cl ; calculate from Note this Octave! |
||
131 | pokeNote: |
||
132 | out 0x42, al ; Lower byte Out to channel 2 timer chip 8253 |
||
133 | mov al, ah |
||
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 |
||
136 | or al, 3 ; Turn ON timer and speaker |
||
137 | out 0x61, al ; Send out new values to port B chip 8255 |
||
138 | saveESI: |
||
139 | ; mov [memAdrNote], esi ; save new header control Delay-Note string |
||
140 | pop eax |
||
141 | RET |
||
142 | ReadNoteByte: |
||
143 | ;result: |
||
144 | ; al - note |
||
145 | push eax |
||
146 | push ecx |
||
147 | push edx |
||
148 | push esi |
||
149 | |||
150 | mov eax, [pidProcessNote] |
||
151 | call pid_to_slot |
||
152 | test eax, eax |
||
153 | jz .failed |
||
154 | lea ecx, [esp+12] |
||
155 | mov edx, 1 |
||
156 | mov esi, [memAdrNote] |
||
157 | inc [memAdrNote] |
||
158 | |||
159 | call read_process_memory |
||
160 | .failed: |
||
161 | pop esi |
||
162 | pop edx |
||
163 | pop ecx |
||
164 | pop eax |
||
165 | ret |
||
166 | ;------------------- END CODE -------------------><><<> |