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