Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7423 | leency | 1 | ;--------------------; |
2 | ; MACROS.INC ; |
||
3 | ;--------------------; |
||
4 | |||
5 | macro __mov reg,a { ; mike.dld |
||
6 | if ~a eq |
||
7 | mov reg,a |
||
8 | end if |
||
9 | } |
||
10 | |||
11 | macro mcall a,b,c,d,e,f { ; mike.dld |
||
12 | __mov eax,a |
||
13 | __mov ebx,b |
||
14 | __mov ecx,c |
||
15 | __mov edx,d |
||
16 | __mov esi,e |
||
17 | __mov edi,f |
||
18 | int 0x40 |
||
19 | } |
||
20 | |||
21 | ;--------------------; |
||
22 | ; ASCL.INC ; |
||
23 | ;--------------------; |
||
24 | |||
25 | macro words2reg reg,hiword,lowword |
||
26 | { |
||
27 | if hiword eq |
||
28 | if lowword eq |
||
29 | ; not changes |
||
30 | else |
||
31 | if lowword eqtype 12 |
||
32 | and reg,dword 0xffff0000 |
||
33 | add reg,dword lowword |
||
34 | else |
||
35 | and reg,dword 0xffff0000 |
||
36 | add reg,dword lowword |
||
37 | end if |
||
38 | end if |
||
39 | else |
||
40 | if lowword eq |
||
41 | if hiword eqtype 12 |
||
42 | and reg,dword 0x0000ffff |
||
43 | add reg,dword hiword*65536 |
||
44 | else |
||
45 | shl reg,16 |
||
46 | add reg,dword hiword |
||
47 | ror reg,16 |
||
48 | end if |
||
49 | else |
||
50 | if lowword eqtype 12 & hiword eqtype 12 |
||
51 | if lowword eq 0 & hiword eq 0 |
||
52 | xor reg,reg |
||
53 | else |
||
54 | mov reg,dword hiword*65536+lowword |
||
55 | end if |
||
56 | else |
||
57 | mov reg,dword hiword |
||
58 | shl reg,16 |
||
59 | add reg,dword lowword |
||
60 | end if |
||
61 | end if |
||
62 | end if |
||
63 | } |
||
64 | |||
65 | ;--------------------; |
||
66 | ; MOSUZIT.INC ; |
||
67 | ;--------------------; |
||
68 | |||
69 | ;WriteTextToWindow |
||
70 | macro Text xStart,yStart,rgbColor,pText,nTextLen |
||
71 | { |
||
72 | words2reg ebx, xStart, yStart |
||
73 | mov ecx, rgbColor |
||
74 | mov edx, pText |
||
75 | mov esi, nTextLen |
||
76 | mov eax, 4 |
||
77 | int 0x40 |
||
78 | } |
||
79 | |||
80 | ;DisplayNumber |
||
81 | macro Number xStart,yStart,nPrintType,noOfDigits,Data,rgbColor |
||
82 | { |
||
83 | words2reg edx,xStart,yStart |
||
84 | words2reg ebx,noOfDigits,nPrintType |
||
85 | mov ecx,Data |
||
86 | mov esi,rgbColor |
||
87 | mov eax,47 |
||
88 | int 0x40 |
||
89 | } |
||
90 | |||
91 | macro DrawLine xStart,xEnd,yStart,yEnd,rgbColor |
||
92 | { |
||
93 | words2reg ebx,xStart,xEnd |
||
94 | words2reg ecx,yStart,yEnd |
||
95 | mov edx,rgbColor |
||
96 | mov eax,38 |
||
97 | int 0x40 |
||
98 | } |
||
99 | ;******************************************************** |
||
100 | macro Extracteax temp,fromBit,bitCount,dest |
||
101 | { |
||
102 | mov temp, eax |
||
103 | shr temp, fromBit |
||
104 | and temp, (1 shl bitCount - 1) |
||
105 | mov dest, temp |
||
106 | } |
||
107 | ;******************************************************** |
||
108 | ;********* AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM ********* |
||
109 | ;******************************************************** |
||
110 | extract_bits: ;11xA is sync |
||
111 | ;Defined as the following: |
||
112 | ; b1s ; standard |
||
113 | ; b1l ; layer |
||
114 | ; crc ; CRC protection |
||
115 | |||
116 | ; Bita ; Bitrate |
||
117 | ; sam ; Sampling rate |
||
118 | ; pad ; Padding |
||
119 | ; priv ; Private bit |
||
120 | |||
121 | ; shan ; Channel mode |
||
122 | ; modx ; Mode extention |
||
123 | ; copy ; Copyright |
||
124 | ; orig ; Original |
||
125 | ; emph ; Emphasis |
||
126 | |||
127 | ;--------------------- Standard (BB) |
||
128 | Extracteax ebx, 11, 2, [b1s] |
||
129 | ;--------------------- Layer (CC) |
||
130 | Extracteax ebx, 9, 2, [b1l] |
||
131 | ;--------------------- CRC (D) |
||
132 | Extracteax ebx, 8, 1, [crc] |
||
133 | ;--------------------- Bitrate (EEEE) |
||
134 | Extracteax ebx, 20, 4, [Bita] |
||
135 | ;--------------------- Sample Rate (FF) |
||
136 | Extracteax ebx, 18, 2, [sam] |
||
137 | ;--------------------- padding (G) |
||
138 | Extracteax ebx, 17, 1, [pad] |
||
139 | ;--------------------- Private bit (H) |
||
140 | Extracteax ebx, 16, 1, [priv] |
||
141 | ;--------------------- Channels (II) |
||
142 | Extracteax ebx, 30, 2, [shan] |
||
143 | ;--------------------- Mode ext (JJ) |
||
144 | Extracteax ebx, 28, 2, [modx] |
||
145 | ;--------------------- Copyright (K) |
||
146 | Extracteax ebx, 27, 1, [copy] |
||
147 | ;--------------------- Original (L) |
||
148 | Extracteax ebx, 26, 1, [orig] |
||
149 | ;--------------------- Emphasis (MM) |
||
150 | Extracteax ebx, 24, 2, [emph] |
||
151 | |||
152 | ret |
||
153 | ;******************************************************** |
||
154 | decode_standard: |
||
155 | |||
156 | comp0: |
||
157 | cmp [b1s], 00b |
||
158 | je S25 |
||
159 | |||
160 | comp1: |
||
161 | cmp [b1s], 01b ; unknown |
||
162 | je S25 |
||
163 | |||
164 | comp2: |
||
165 | cmp [b1s], 10b |
||
166 | je S20 |
||
167 | |||
168 | comp3: |
||
169 | cmp [b1s], 11b |
||
170 | je S10 |
||
171 | |||
172 | jmp S000 |
||
173 | |||
174 | ;----- |
||
175 | |||
176 | S25: |
||
177 | mov [S1], 2 |
||
178 | mov [S2], 5 |
||
179 | mov [id], 3 ;lowest freq |
||
180 | jmp S000 |
||
181 | |||
182 | S20: |
||
183 | mov [S1], 2 |
||
184 | mov [S2], 0 |
||
185 | mov [id], 2 ;low freq |
||
186 | jmp S000 |
||
187 | |||
188 | S10: |
||
189 | mov [S1], 1 |
||
190 | mov [S2], 0 |
||
191 | mov [id], 1 ;hi freq |
||
192 | jmp S000 |
||
193 | |||
194 | S000: |
||
195 | |||
196 | ret |
||
197 | |||
198 | ;******************************************************** |
||
199 | |||
200 | decode_layer: |
||
201 | |||
202 | com0: |
||
203 | cmp [b1l], 00b |
||
204 | je L3 ; unknown |
||
205 | |||
206 | com1: |
||
207 | cmp [b1l], 01b |
||
208 | je L3 |
||
209 | |||
210 | com2: |
||
211 | cmp [b1l], 10b |
||
212 | je L2 |
||
213 | |||
214 | com3: |
||
215 | cmp [b1l], 11b |
||
216 | je L1 |
||
217 | |||
218 | jmp L000 |
||
219 | |||
220 | ;----- |
||
221 | |||
222 | L3: |
||
223 | mov [La], 3 |
||
224 | jmp L000 |
||
225 | |||
226 | L2: |
||
227 | mov [La], 2 |
||
228 | jmp L000 |
||
229 | |||
230 | L1: |
||
231 | mov [La], 1 |
||
232 | jmp L000 |
||
233 | |||
234 | L000: |
||
235 | |||
236 | ret |
||
237 | |||
238 | ;******************************************************** |
||
239 | |||
240 | decode_channels: |
||
241 | |||
242 | co0: |
||
243 | cmp [shan], 00b |
||
244 | je C4 |
||
245 | |||
246 | co1: |
||
247 | cmp [shan], 01b |
||
248 | je C3 |
||
249 | |||
250 | co2: |
||
251 | cmp [shan], 10b |
||
252 | je C2 |
||
253 | |||
254 | co3: |
||
255 | cmp [shan], 11b |
||
256 | je C1 |
||
257 | |||
258 | jmp C000 |
||
259 | |||
260 | ;----- |
||
261 | C4: |
||
262 | mov [K], 4 ;00=Stereo |
||
263 | jmp C000 |
||
264 | |||
265 | C3: |
||
266 | mov [K], 3 ;01=Joint stereo |
||
267 | jmp C000 |
||
268 | |||
269 | C2: |
||
270 | mov [K], 2 ;10=Dual Channel |
||
271 | jmp C000 |
||
272 | |||
273 | C1: |
||
274 | mov [K], 1 ;11=Single Channel (Mono) |
||
275 | jmp C000 |
||
276 | |||
277 | C000: |
||
278 | |||
279 | ret |
||
280 | ;******************************************************** |
||
281 | ;-------------------------- |
||
282 | ; decode_samplerate |
||
283 | ;-------------------------- |
||
284 | decode_samplerate: |
||
285 | push eax |
||
286 | push ecx |
||
287 | |||
288 | mov eax, [sam] |
||
289 | mov eax, [freq + eax*4] |
||
290 | mov ecx, [b1s] |
||
291 | cmp cl, 01 ; bad frequency |
||
292 | jnz ok |
||
293 | |||
294 | ok: |
||
295 | cmp cl, 0 |
||
296 | jz @f |
||
297 | dec cl |
||
298 | @@: |
||
299 | shl eax, cl |
||
300 | mov [SR], eax |
||
301 | |||
302 | pop ecx |
||
303 | pop eax |
||
304 | ret |
||
305 | |||
306 | ;******************************************************** |
||
307 | ;-------------------------- |
||
308 | ; decode_bitrate |
||
309 | ;-------------------------- |
||
310 | decode_bitrate: |
||
311 | push eax |
||
312 | push ebx |
||
313 | mov eax,[b1s] |
||
314 | and eax,1 |
||
315 | shl eax,4 |
||
316 | lea eax,[eax*3] |
||
317 | mov ebx,[b1l] |
||
318 | dec ebx |
||
319 | shl ebx, 4 |
||
320 | add eax, ebx |
||
321 | add eax,[Bita] |
||
322 | movzx eax,byte[Bitrate+eax] |
||
323 | shl eax,3 |
||
324 | mov [BR],eax |
||
325 | pop ebx |
||
326 | pop eax |
||
327 | ret |
||
328 | |||
329 | ;******************************************************** |
||
330 | |||
331 | calculate_time_frame_count: |
||
332 | |||
333 | ;----------------------------duration |
||
334 | xor eax, eax |
||
335 | xor ebx, ebx |
||
336 | xor ecx, ecx |
||
337 | xor edx, edx |
||
338 | |||
339 | mov ebx, dword[BR] |
||
340 | imul ebx, 125 |
||
341 | ; result in ebx |
||
342 | |||
343 | |||
344 | mov eax, dword[size] |
||
345 | |||
346 | div ebx |
||
347 | |||
348 | |||
349 | mov dword[time], eax |
||
350 | ;---------------------------frame size |
||
351 | |||
352 | xor eax, eax |
||
353 | xor ebx, ebx |
||
354 | xor ecx, ecx |
||
355 | xor edx, edx |
||
356 | |||
357 | cmp [S1], 1 |
||
358 | je MP1 |
||
359 | cmp [S1], 2 |
||
360 | je MP2 |
||
361 | |||
362 | MP1: |
||
363 | |||
364 | mov eax, dword [BR] |
||
365 | imul eax, 144000 |
||
366 | ; result in eax |
||
367 | |||
368 | |||
369 | mov ebx, dword[SR] |
||
370 | |||
371 | div ebx |
||
372 | |||
373 | add eax, dword [pad] |
||
374 | |||
375 | mov dword[frames], eax |
||
376 | |||
377 | jmp exx |
||
378 | |||
379 | MP2: |
||
380 | |||
381 | mov eax, dword [BR] |
||
382 | imul eax, 72000 |
||
383 | ; result in eax |
||
384 | |||
385 | |||
386 | mov ebx, dword[SR] |
||
387 | |||
388 | div ebx |
||
389 | |||
390 | add eax, dword [pad] |
||
391 | |||
392 | mov dword[frames], eax |
||
393 | |||
394 | exx: |
||
395 | ;--------------------------quantity of frames |
||
396 | xor eax, eax |
||
397 | xor ebx, ebx |
||
398 | xor ecx, ecx |
||
399 | xor edx, edx |
||
400 | |||
401 | mov eax, dword[size] |
||
402 | mov ebx, dword[frames] |
||
403 | div ebx |
||
404 | mov dword[framecount], eax |
||
405 | |||
406 | ret |
||
407 | |||
408 | ;-------------------------- |
||
409 | ; header_check |
||
410 | ; eax = проверяемый заголовок |
||
411 | ;-------------------------- |
||
412 | Header_Check: |
||
413 | |||
414 | push ebx |
||
415 | mov ebx, eax |
||
416 | |||
417 | ; Проверяем 11 бит в начале фрейма |
||
418 | and eax, 0E0FFh |
||
419 | cmp eax, 0E0FFh |
||
420 | jnz bad |
||
421 | |||
422 | ; Проверяем версию MPEG |
||
423 | mov eax, ebx |
||
424 | and eax, 1800h |
||
425 | cmp eax, 0800h |
||
426 | jz bad |
||
427 | |||
428 | ; Проверяем layer |
||
429 | mov eax, ebx |
||
430 | test eax, 0600h |
||
431 | jz bad |
||
432 | |||
433 | ; Проверяем битрейт |
||
434 | mov eax, ebx |
||
435 | and eax, 0F00000h |
||
436 | cmp eax, 0F00000h |
||
437 | jz bad |
||
438 | test eax, eax |
||
439 | jz bad |
||
440 | |||
441 | ; Проверяем частоту |
||
442 | mov eax, ebx |
||
443 | and eax, 0C0000h |
||
444 | cmp eax, 0C0000h |
||
445 | jz bad |
||
446 | .end_test: |
||
447 | xor eax, eax |
||
448 | pop ebx |
||
449 | ret |
||
450 | |||
451 | bad: |
||
452 | mov eax, 1 |
||
453 | pop ebx |
||
454 | ret |
||
455 | |||
456 | |||
457 | ;=========================== |
||
458 | Win2Dos: |
||
459 | ;=========================== |
||
460 | jcxz .no_chars |
||
461 | push esi |
||
462 | push edi |
||
463 | push ecx |
||
464 | mov edi, esi |
||
465 | cld |
||
466 | .next_char: |
||
467 | lodsb |
||
468 | cmp al, 0xC0 |
||
469 | jae .rus |
||
470 | cmp al, 0xA8 |
||
471 | jnz @f |
||
472 | mov al, 0xF0 |
||
473 | @@: |
||
474 | cmp al, 0xB8 |
||
475 | jnz @f |
||
476 | mov al, 0xF1 |
||
477 | @@: |
||
478 | jmp .char_ready |
||
479 | .rus: |
||
480 | cmp al, 0xF0 |
||
481 | jae @f |
||
482 | sub al, 48 |
||
483 | @@: |
||
484 | sub al, 16 |
||
485 | .char_ready: |
||
486 | stosb |
||
487 | dec ecx |
||
488 | jnz .next_char |
||
489 | |||
490 | pop ecx |
||
491 | pop edi |
||
492 | pop esi |
||
493 | .no_chars: |
||
494 | ret |