Subversion Repositories Kolibri OS

Rev

Rev 425 | Rev 593 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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