Subversion Repositories Kolibri OS

Rev

Rev 551 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 551 Rev 10009
Line 1... Line 1...
1
;
1
;
2
;    Ok, this is the sceleton that MENUET 0.01 understands.
2
;    Ok, this is the sceleton that MENUET 0.01 understands.
3
;    Do not change the header bits for now. Compile with nasm.
3
;    Do not change the header bits for now. Compile with nasm.
4
;
4
;
Line 5... Line -...
5
 
-
 
6
include 'lang.inc'
5
 
Line 7... Line 6...
7
include '..\..\..\macros.inc'
6
include '..\..\..\macros.inc'
8
 
7
 
9
use32
8
use32
Line 15... Line 14...
15
 dd	0x1000        ; required memory
14
 dd     0x1000        ; required memory
16
 dd	0x1000        ; esp
15
 dd     0x1000        ; esp
17
 dd	0x0 , 0x0     ; I_Param , I_Path
16
 dd     0x0 , 0x0     ; I_Param , I_Path
Line -... Line 17...
-
 
17
 
-
 
18
 
-
 
19
MIDI_PORT = 0x330
-
 
20
 
-
 
21
midisp: dw      MIDI_PORT + 1
-
 
22
mididp: dw      MIDI_PORT
18
 
23
 
-
 
24
 
-
 
25
START:
-
 
26
        mov     dx, word[midisp]
-
 
27
        mov     cx, word[mididp]
-
 
28
        mcall   46, 0
-
 
29
 
-
 
30
        test    eax, eax
Line 19... Line 31...
19
 
31
        jne     exit
20
START:
32
 
Line 21... Line 33...
21
 
33
 
Line 28... Line 40...
28
    mcall
40
        mcall
Line 29... Line 41...
29
 
41
 
30
    cmp    eax,1
42
        cmp     eax, 1
31
    jz     red
43
        jz      red
32
    cmp    eax,3
-
 
33
    jz     button
44
        cmp     eax, 3
Line 34... Line 45...
34
    jmp    still
45
        jnz     still
35
 
46
 
36
  button:
47
        ;button:
Line 37... Line 48...
37
    mov  eax,17
48
        mov     eax, 17
38
    mcall
49
        mcall
Line 39... Line 50...
39
 
50
 
40
    cmp  al,byte 0
51
        cmp     al, 0
41
    jnz  still
-
 
42
 
-
 
43
    cmp  ah,1
-
 
44
    jnz  noexit
-
 
45
 
-
 
Line 46... Line 52...
46
    mov  eax,0xffffffff
52
        jnz  still
47
    mcall
53
 
Line 48... Line 54...
48
 
54
        cmp     ah, 1
49
  noexit:
55
        jz      exit
50
 
-
 
51
    cmp  ah,2
-
 
Line 52... Line 56...
52
    jz   note1
56
 
53
 
57
        cmp     ah, 2
Line 54... Line 58...
54
    mov  eax,20   ; reset midi device
58
        jz      .play_note
Line 55... Line -...
55
    mov  ebx,1
-
 
56
    mov  ecx,0
-
 
57
    mcall
59
 
Line 58... Line 60...
58
 
60
        ; reset midi device
Line 59... Line 61...
59
    cmp  eax,0
61
        call    midi_reset
60
    jz   noe1
-
 
61
 
62
 
62
    call printerror
-
 
63
 
63
        cmp     eax, 0    ; check error code
64
  noe1:
64
        jz      still
65
 
65
 
-
 
66
        call    printerror
66
    jmp  still
67
 
67
 
68
        jmp     still
68
  note1:
69
 
-
 
70
.play_note:
69
 
71
 
70
    mov  eax,50
72
        mov     eax, 50
71
 
73
.nn:
Line 72... Line 74...
72
  nn:
74
        mov     ebx, 100
Line 73... Line 75...
73
 
75
        call    noteout
74
    mov  ebx,100
76
        pusha
75
    call noteout
77
 
-
 
78
        mov     eax, 5
76
    pusha
79
        mov     ebx, 8
77
    mov  eax,5
80
        mcall
78
    mov  ebx,8
81
 
-
 
82
        popa
79
    mcall
83
        mov     ebx, 0
80
    popa
84
;    call noteout
81
    mov  ebx,0
85
 
Line 82... Line 86...
82
;    call noteout
86
        add     eax, 3
Line 83... Line 87...
83
 
87
 
84
    add  eax,3
88
        mov     ebx, 100
85
 
89
        call    noteout
Line 86... Line 90...
86
    mov  ebx,100
90
        pusha
Line -... Line 91...
-
 
91
 
-
 
92
        mov     eax, 5
-
 
93
        mov     ebx, 8
Line 87... Line 94...
87
    call noteout
94
        mcall
Line 88... Line 95...
88
    pusha
95
 
Line 147... Line 154...
147
    popa
154
        popa
148
    ret
155
        ret
Line 149... Line 156...
149
 
156
 
150
 
-
 
151
noteout:
157
 
Line 152... Line 158...
152
 
158
noteout:
153
    pusha
159
        pusha
Line 154... Line -...
154
 
-
 
155
    push ebx
-
 
156
    push eax
160
 
157
 
-
 
158
    mov  eax,20
161
        push    ebx
159
    mov  ebx,2
162
        push    eax
160
    mov  ecx,0x9f
163
 
161
    mcall
-
 
162
    mov  eax,20
164
        mov     ecx, 0x9f
163
    mov  ebx,2
165
        call    midi_output_byte
164
    pop  ecx
166
 
165
    mcall
167
        pop     ecx
Line 166... Line 168...
166
    mov  eax,20
168
        call    midi_output_byte
167
    mov  ebx,2
169
 
Line 168... Line 170...
168
    pop  ecx
170
        pop     ecx
Line 169... Line -...
169
    mcall
-
 
170
 
171
        call    midi_output_byte
171
    cmp  eax,0
172
 
172
    jz   noe2
173
        cmp     eax, 0
Line 173... Line 174...
173
 
174
        jz      @f
Line 174... Line 175...
174
    call printerror
175
 
175
 
176
        call    printerror
176
  noe2:
177
 
177
 
178
@@:
178
    popa
179
        popa
179
    ret
180
        ret
Line 180... Line 181...
180
 
181
 
181
printerror:
182
printerror:
182
 
183
 
183
    mov       eax,dword 4
184
        mov     eax, 4
184
    mov       ebx,15*65536+85
185
        mov     ebx, 15*65536+85
185
     mov       ecx,0x000000
186
        mov     ecx, 0x000000
Line 186... Line 187...
186
     mov       edx,error1
187
        mov     edx, error1
Line -... Line 188...
-
 
188
        mov     esi, errorlen1-error1
-
 
189
        mcall
-
 
190
 
-
 
191
        mov     eax, 4
-
 
192
        mov     ebx, 15*65536+95
-
 
193
        mov     ecx, 0x000000
-
 
194
        mov     edx, error2
-
 
195
        mov     esi, errorlen2-error2
-
 
196
        mcall
-
 
197
 
-
 
198
        ret
-
 
199
 
-
 
200
; MPU401 interface
-
 
201
 
-
 
202
midi_reset:
-
 
203
@@:
-
 
204
        ; reset device
-
 
205
        call    is_output
-
 
206
        test    al, al
-
 
207
        jnz     @b
-
 
208
        mov     dx, word [midisp]
-
 
209
        mov     al, 0xff
-
 
210
        out     dx, al
-
 
211
@@:
-
 
212
        mov     dx, word [midisp]
-
 
213
        mov     al, 0xff
-
 
214
        out     dx, al
-
 
215
        call    is_input
-
 
216
        test    al, al
-
 
217
        jnz     @b
-
 
218
        call    get_mpu_in
-
 
219
        cmp     al, 0xfe
-
 
220
        jnz     @b
-
 
221
@@:
-
 
222
        call    is_output
-
 
223
        test    al, al
-
 
224
        jnz     @b
-
 
225
        mov     dx, word [midisp]
-
 
226
        mov     al, 0x3f
-
 
227
        out     dx, al
-
 
228
        ret
-
 
229
 
-
 
230
midi_output_byte:
-
 
231
        ; output byte
-
 
232
@@:
-
 
233
        call    get_mpu_in
-
 
234
        call    is_output
-
 
235
        test    al, al
-
 
236
        jnz     @b
-
 
237
        mov     al, cl
-
 
238
        call    put_mpu_out
-
 
239
        ret
-
 
240
 
-
 
241
is_input:
-
 
242
        push    edx
-
 
243
        mov     dx, word [midisp]
-
 
244
        in      al, dx
-
 
245
        and     al, 0x80
-
 
246
        pop     edx
-
 
247
        ret
-
 
248
 
-
 
249
is_output:
-
 
250
        push    edx
-
 
251
        mov     dx, word [midisp]
-
 
252
        in      al, dx
-
 
253
        and     al, 0x40
-
 
254
        pop     edx
-
 
255
        ret
-
 
256
 
-
 
257
get_mpu_in:
-
 
258
        push    edx
-
 
259
        mov     dx, word [mididp]
-
 
260
        in      al, dx
-
 
261
        pop     edx
Line 187... Line 262...
187
    mov       esi,errorlen1-error1
262
        ret
Line 188... Line 263...
188
    mcall
263