Subversion Repositories Kolibri OS

Rev

Rev 431 | Rev 802 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ha 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
431 serge 3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
1 ha 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
 
593 mikedld 19
$Revision: 593 $
20
 
21
 
1 ha 22
kontrOctave      dw  0x4742, 0x4342, 0x3F7C, 0x3BEC, 0x388F, 0x3562
23
                 dw  0x3264, 0x2F8F, 0x2CE4, 0x2A5F, 0x2802, 0x25BF
24
memAdrNote       dd  0
25
pidProcessNote   dd  0
26
slotProcessNote  dd  0
27
count_timer_Note dd  1
28
mem8253r42       dw  0
29
countDelayNote   db  0
30
 
31
playNote:
32
;      jmp   NotPlayNotes
33
      mov   esi, [memAdrNote]
34
      or    esi, esi             ; ESI = 0 ?  - OFF Notes Play ?
35
       jz   NotPlayNotes         ; if ESI = 0   -> ignore play pocedure
36
      cmp   eax, [count_timer_Note]
37
       jb   NotPlayNotes
38
      push  eax
39
      inc   eax
40
      mov   [count_timer_Note], eax
41
      mov   al,  [countDelayNote]
42
      dec   al                   ; decrement counter Delay for Playing Note
43
       jz   NewLoadNote@Delay
44
      cmp   al, 0xFF             ; this is first Note Play ?
45
       jne  NextDelayNote
46
      ;This is FIRST Note, save counter channel 2 chip 8253
47
      mov   al, 0xB6             ; control byte to timer chip 8253
48
      out   0x43, al             ; Send it to the control port chip 8253
49
      in    al, 0x42             ; Read Lower byte counter channel 2 chip 8253
50
      mov   ah, al               ; AH = Lower byte counter channel 2
51
      in    al, 0x42             ; Read Upper byte counter channel 2 chip 8253
52
      mov   [mem8253r42], ax     ; Save counter channel 2 timer chip 8253
53
   NewLoadNote@Delay:
54
      cld
55
;      lodsb                      ; load AL - counter Delay
56
      call  ReadNoteByte
57
      or    al, al               ; THE END ?
58
       jz   EndPlayNote
59
      cmp   al, 0x81
60
       jnc  NoteforOctave
61
      mov   [countDelayNote], al
62
;      lodsw                      ; load AX - counter for Note!
63
      call ReadNoteByte
64
      mov  ah,al
65
      call ReadNoteByte
66
      xchg al,ah
67
      jmp  pokeNote
68
 
69
   EndPlayNote:                  ; THE END Play Notes!
70
      in    al, 0x61             ; Get contents of system port B chip 8255
71
      and   al, 0xFC             ; Turn OFF timer and speaker
72
      out   0x61, al             ; Send out new values to port B chip 8255
73
      mov   ax, [mem8253r42]     ; memorize counter channel 2 timer chip 8253
74
      xchg  al, ah               ; reverse byte in word
75
      out   0x42, al             ; restore Lower byte counter channel 2
76
      mov   al, ah               ; AL = Upper byte counter channel 2
77
      out   0x42, al             ; restore Upper byte channel 2
78
      xor   eax, eax             ; EAX = 0
79
      mov   [memAdrNote], eax    ; clear header control Delay-Note string
80
   NextDelayNote:
81
      mov   [countDelayNote], al ; save new counter delay Note
82
      pop   eax
83
   NotPlayNotes:
84
        RET
85
 
86
   NoteforOctave:
87
      sub   al, 0x81             ; correction value for delay Note
88
      mov   [countDelayNote], al ; save counter delay this new Note
89
;      lodsb                      ; load pack control code
90
      call  ReadNoteByte
91
      cmp   al, 0xFF             ; this is PAUSE ?
92
       jne  packCode             ; no, this is PACK CODE
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
      jmp  saveESI
97
 
98
   packCode:
99
      mov   cl, al               ; save code
100
      and   al, 0xF              ; clear upper bits
101
      dec   al                   ; correction
102
      add   al, al               ; transform number to offset constant
103
      movsx eax, al              ; EAX - offset
104
      add   eax, dword kontrOctave ; EAX - address from constant
105
      mov   ax, [eax]            ; read constant
106
      shr   cl, 4                ; transform for number Octave
107
      shr   ax, cl               ; calculate from Note this Octave!
108
   pokeNote:
109
      out   0x42, al             ; Lower byte Out to channel 2 timer chip 8253
110
      mov   al, ah
111
      out   0x42, al             ; Upper byte Out to channel 2 timer chip 8253
112
      in    al, 0x61             ; Get contents of system port B chip 8255
113
      or    al, 3                ; Turn ON timer and speaker
114
      out   0x61, al             ; Send out new values to port B chip 8255
115
   saveESI:
116
;      mov   [memAdrNote], esi    ; save new header control Delay-Note string
117
      pop   eax
118
        RET
119
ReadNoteByte:
120
;result:
121
;  al - note
122
      push  eax
123
      push  ebx
124
      push  ecx
125
      push  edx
126
      mov   eax,[pidProcessNote]
127
      call  pid_to_slot
128
      test  eax,eax
129
      jz    .failed
130
      lea   ebx,[esp+12]
131
      mov   ecx,1
132
      mov   edx,[memAdrNote]
133
      inc   [memAdrNote]
134
      call  read_process_memory
431 serge 135
.failed:
1 ha 136
      pop   edx
137
      pop   ecx
138
      pop   ebx
139
      pop   eax
431 serge 140
      ret
1 ha 141
;-------------------  END CODE  -------------------