2011-10-14 23:38:50 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2023-04-08 23:24:05 +02:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2023. All rights reserved. ;;
|
2011-10-14 23:38:50 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;; PLAYNOTE.INC version 1.1 22 November 2003 ;;
|
|
|
|
;; ;;
|
|
|
|
;; Player Notes for Speaker PC ;;
|
|
|
|
;; subfunction #55 from function #55 Menuet OS ;;
|
|
|
|
;; ;;
|
|
|
|
;; Copyright 2003 VaStaNi ;;
|
|
|
|
;; vastani@ukr.net ;;
|
|
|
|
;; >>>- SIMPLY - QUICKLY - SHORTLY -<<< ;;
|
|
|
|
;; ;;
|
|
|
|
;; Note: playnote.txt ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
|
|
align 4
|
|
|
|
sound_interface:
|
|
|
|
|
|
|
|
cmp eax, ebx ; this is subfunction #55 ?
|
2023-04-08 23:24:05 +02:00
|
|
|
jne .ret ; if no then return.
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
cmp byte [sound_flag], 0
|
2023-04-08 23:24:05 +02:00
|
|
|
jne .ret
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
movzx eax, byte [countDelayNote]
|
|
|
|
or al, al ; player is busy ?
|
2023-04-08 23:24:05 +02:00
|
|
|
jnz .ret ; return counter delay Note
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
mov [memAdrNote], esi;edx
|
|
|
|
call get_pid
|
|
|
|
mov [pidProcessNote], eax
|
2023-04-08 23:24:05 +02:00
|
|
|
xor eax, eax ; Ok! EAX = 0
|
|
|
|
.ret:
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax ; return value EAX for application
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
iglobal
|
|
|
|
align 4
|
|
|
|
kontrOctave dw 0x4742, 0x4342, 0x3F7C, 0x3BEC, 0x388F, 0x3562
|
|
|
|
dw 0x3264, 0x2F8F, 0x2CE4, 0x2A5F, 0x2802, 0x25BF
|
|
|
|
memAdrNote dd 0
|
|
|
|
pidProcessNote dd 0
|
|
|
|
slotProcessNote dd 0
|
|
|
|
count_timer_Note dd 1
|
|
|
|
mem8253r42 dw 0
|
|
|
|
countDelayNote db 0
|
|
|
|
endg
|
|
|
|
|
|
|
|
playNote:
|
|
|
|
; jmp NotPlayNotes
|
|
|
|
mov esi, [memAdrNote]
|
|
|
|
or esi, esi ; ESI = 0 ? - OFF Notes Play ?
|
2023-04-08 23:24:05 +02:00
|
|
|
jz .NotPlayNotes ; if ESI = 0 -> ignore play pocedure
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp eax, [count_timer_Note]
|
2023-04-08 23:24:05 +02:00
|
|
|
jb .NotPlayNotes
|
2011-10-14 23:38:50 +02:00
|
|
|
push eax
|
|
|
|
inc eax
|
|
|
|
mov [count_timer_Note], eax
|
|
|
|
mov al, [countDelayNote]
|
|
|
|
dec al ; decrement counter Delay for Playing Note
|
2023-04-08 23:24:05 +02:00
|
|
|
jz .NewLoadNote@Delay
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp al, 0xFF ; this is first Note Play ?
|
2023-04-08 23:24:05 +02:00
|
|
|
jne .NextDelayNote
|
|
|
|
;This is FIRST Note, save counter channel 2 chip 8253
|
2011-10-14 23:38:50 +02:00
|
|
|
mov al, 0xB6 ; control byte to timer chip 8253
|
|
|
|
out 0x43, al ; Send it to the control port chip 8253
|
|
|
|
in al, 0x42 ; Read Lower byte counter channel 2 chip 8253
|
|
|
|
mov ah, al ; AH = Lower byte counter channel 2
|
|
|
|
in al, 0x42 ; Read Upper byte counter channel 2 chip 8253
|
|
|
|
mov [mem8253r42], ax ; Save counter channel 2 timer chip 8253
|
2023-04-08 23:24:05 +02:00
|
|
|
.NewLoadNote@Delay:
|
2011-10-14 23:38:50 +02:00
|
|
|
cld
|
|
|
|
; lodsb ; load AL - counter Delay
|
|
|
|
call ReadNoteByte
|
|
|
|
or al, al ; THE END ?
|
2023-04-08 23:24:05 +02:00
|
|
|
jz .EndPlayNote
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp al, 0x81
|
2023-04-08 23:24:05 +02:00
|
|
|
jnc .NoteforOctave
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [countDelayNote], al
|
|
|
|
; lodsw ; load AX - counter for Note!
|
|
|
|
call ReadNoteByte
|
|
|
|
mov ah, al
|
|
|
|
call ReadNoteByte
|
|
|
|
xchg al, ah
|
2023-04-08 23:24:05 +02:00
|
|
|
jmp .pokeNote
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2023-04-08 23:24:05 +02:00
|
|
|
.EndPlayNote: ; THE END Play Notes!
|
2011-10-14 23:38:50 +02:00
|
|
|
in al, 0x61 ; Get contents of system port B chip 8255
|
|
|
|
and al, 0xFC ; Turn OFF timer and speaker
|
|
|
|
out 0x61, al ; Send out new values to port B chip 8255
|
|
|
|
mov ax, [mem8253r42] ; memorize counter channel 2 timer chip 8253
|
|
|
|
xchg al, ah ; reverse byte in word
|
|
|
|
out 0x42, al ; restore Lower byte counter channel 2
|
|
|
|
mov al, ah ; AL = Upper byte counter channel 2
|
|
|
|
out 0x42, al ; restore Upper byte channel 2
|
|
|
|
xor eax, eax ; EAX = 0
|
|
|
|
mov [memAdrNote], eax; clear header control Delay-Note string
|
2023-04-08 23:24:05 +02:00
|
|
|
.NextDelayNote:
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [countDelayNote], al; save new counter delay Note
|
|
|
|
pop eax
|
2023-04-08 23:24:05 +02:00
|
|
|
.NotPlayNotes:
|
|
|
|
ret
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2023-04-08 23:24:05 +02:00
|
|
|
.NoteforOctave:
|
2011-10-14 23:38:50 +02:00
|
|
|
sub al, 0x81 ; correction value for delay Note
|
|
|
|
mov [countDelayNote], al; save counter delay this new Note
|
|
|
|
; lodsb ; load pack control code
|
|
|
|
call ReadNoteByte
|
|
|
|
cmp al, 0xFF ; this is PAUSE ?
|
2023-04-08 23:24:05 +02:00
|
|
|
jne .packCode ; no, this is PACK CODE
|
2011-10-14 23:38:50 +02:00
|
|
|
in al, 0x61 ; Get contents of system port B chip 8255
|
|
|
|
and al, 0xFC ; Turn OFF timer and speaker
|
|
|
|
out 0x61, al ; Send out new values to port B chip 8255
|
2023-04-08 23:24:05 +02:00
|
|
|
jmp .saveESI
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2023-04-08 23:24:05 +02:00
|
|
|
.packCode:
|
2011-10-14 23:38:50 +02:00
|
|
|
mov cl, al ; save code
|
|
|
|
and al, 0xF ; clear upper bits
|
|
|
|
dec al ; correction
|
|
|
|
add al, al ; transform number to offset constant
|
|
|
|
movsx eax, al ; EAX - offset
|
|
|
|
add eax, dword kontrOctave; EAX - address from constant
|
|
|
|
mov ax, [eax] ; read constant
|
|
|
|
shr cl, 4 ; transform for number Octave
|
|
|
|
shr ax, cl ; calculate from Note this Octave!
|
2023-04-08 23:24:05 +02:00
|
|
|
.pokeNote:
|
2011-10-14 23:38:50 +02:00
|
|
|
out 0x42, al ; Lower byte Out to channel 2 timer chip 8253
|
|
|
|
mov al, ah
|
|
|
|
out 0x42, al ; Upper byte Out to channel 2 timer chip 8253
|
|
|
|
in al, 0x61 ; Get contents of system port B chip 8255
|
|
|
|
or al, 3 ; Turn ON timer and speaker
|
|
|
|
out 0x61, al ; Send out new values to port B chip 8255
|
2023-04-08 23:24:05 +02:00
|
|
|
.saveESI:
|
2011-10-14 23:38:50 +02:00
|
|
|
; mov [memAdrNote], esi ; save new header control Delay-Note string
|
|
|
|
pop eax
|
2023-04-08 23:24:05 +02:00
|
|
|
ret
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
ReadNoteByte:
|
|
|
|
;result:
|
|
|
|
; al - note
|
|
|
|
push eax
|
|
|
|
push ecx
|
|
|
|
push edx
|
|
|
|
push esi
|
|
|
|
|
|
|
|
mov eax, [pidProcessNote]
|
|
|
|
call pid_to_slot
|
|
|
|
test eax, eax
|
|
|
|
jz .failed
|
|
|
|
lea ecx, [esp+12]
|
|
|
|
mov edx, 1
|
|
|
|
mov esi, [memAdrNote]
|
|
|
|
inc [memAdrNote]
|
|
|
|
|
|
|
|
call read_process_memory
|
|
|
|
.failed:
|
|
|
|
pop esi
|
|
|
|
pop edx
|
|
|
|
pop ecx
|
|
|
|
pop eax
|
|
|
|
ret
|
|
|
|
;------------------- END CODE -------------------
|