Subversion Repositories Kolibri OS

Rev

Rev 551 | Show entire file | Ignore 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
10
 org	0x0
9
 org    0x0
11
 db	'MENUET01'    ; header
10
 db     'MENUET01'    ; header
12
 dd	0x01	      ; header version
11
 dd     0x01          ; header version
13
 dd	START	      ; entry point
12
 dd     START         ; entry point
14
 dd	I_END	      ; image size
13
 dd     I_END         ; image size
15
 dd	0x1000        ; required memory
14
 dd     0x1000        ; required memory
-
 
15
 dd     0x1000        ; esp
-
 
16
 dd     0x0 , 0x0     ; I_Param , I_Path
-
 
17
 
-
 
18
 
-
 
19
MIDI_PORT = 0x330
-
 
20
 
Line 16... Line 21...
16
 dd	0x1000        ; esp
21
midisp: dw      MIDI_PORT + 1
-
 
22
mididp: dw      MIDI_PORT
-
 
23
 
-
 
24
 
-
 
25
START:
-
 
26
        mov     dx, word[midisp]
-
 
27
        mov     cx, word[mididp]
-
 
28
        mcall   46, 0
Line 17... Line 29...
17
 dd	0x0 , 0x0     ; I_Param , I_Path
29
 
18
 
30
        test    eax, eax
Line 19... Line 31...
19
 
31
        jne     exit
Line 20... Line 32...
20
START:
32
 
21
 
33
 
Line 22... Line 34...
22
  red:
34
  red:
23
    call  draw_window
35
    call  draw_window
24
 
36
 
25
still:
-
 
26
 
37
still:
Line 27... Line 38...
27
    mov       eax,10                 ; redraw ?
38
 
28
    mcall
39
        mov     eax, 10          ; redraw ?
29
 
40
        mcall
Line 30... Line 41...
30
    cmp    eax,1
41
 
31
    jz     red
42
        cmp     eax, 1
Line 32... Line 43...
32
    cmp    eax,3
43
        jz      red
33
    jz     button
44
        cmp     eax, 3
Line 34... Line 45...
34
    jmp    still
45
        jnz     still
35
 
46
 
Line 36... Line 47...
36
  button:
47
        ;button:
-
 
48
        mov     eax, 17
Line 37... Line 49...
37
    mov  eax,17
49
        mcall
38
    mcall
50
 
Line 39... Line 51...
39
 
51
        cmp     al, 0
40
    cmp  al,byte 0
-
 
41
    jnz  still
-
 
42
 
-
 
Line 43... Line 52...
43
    cmp  ah,1
52
        jnz  still
44
    jnz  noexit
-
 
Line 45... Line 53...
45
 
53
 
Line -... Line 54...
-
 
54
        cmp     ah, 1
46
    mov  eax,0xffffffff
55
        jz      exit
-
 
56
 
-
 
57
        cmp     ah, 2
-
 
58
        jz      .play_note
Line -... Line 59...
-
 
59
 
-
 
60
        ; reset midi device
47
    mcall
61
        call    midi_reset
Line -... Line 62...
-
 
62
 
-
 
63
        cmp     eax, 0    ; check error code
48
 
64
        jz      still
Line 49... Line 65...
49
  noexit:
65
 
Line -... Line 66...
-
 
66
        call    printerror
-
 
67
 
-
 
68
        jmp     still
-
 
69
 
-
 
70
.play_note:
-
 
71
 
50
 
72
        mov     eax, 50
Line 51... Line -...
51
    cmp  ah,2
-
 
52
    jz   note1
-
 
53
 
-
 
54
    mov  eax,20   ; reset midi device
-
 
55
    mov  ebx,1
-
 
56
    mov  ecx,0
-
 
57
    mcall
73
.nn:
58
 
74
        mov     ebx, 100
59
    cmp  eax,0
75
        call    noteout
Line 60... Line 76...
60
    jz   noe1
76
        pusha
Line 61... Line -...
61
 
-
 
62
    call printerror
-
 
63
 
-
 
64
  noe1:
77
 
65
 
-
 
66
    jmp  still
-
 
67
 
-
 
68
  note1:
78
        mov     eax, 5
69
 
79
        mov     ebx, 8
70
    mov  eax,50
-
 
71
 
-
 
Line 72... Line -...
72
  nn:
-
 
73
 
80
        mcall
74
    mov  ebx,100
-
 
Line -... Line 81...
-
 
81
 
75
    call noteout
82
        popa
Line 76... Line 83...
76
    pusha
83
        mov     ebx, 0
Line 77... Line 84...
77
    mov  eax,5
84
;    call noteout
Line 78... Line 85...
78
    mov  ebx,8
85
 
79
    mcall
86
        add     eax, 3
80
    popa
87
 
81
    mov  ebx,0
88
        mov     ebx, 100
82
;    call noteout
89
        call    noteout
83
 
90
        pusha
84
    add  eax,3
91
 
85
 
92
        mov     eax, 5
86
    mov  ebx,100
93
        mov     ebx, 8
87
    call noteout
94
        mcall
88
    pusha
95
 
89
    mov  eax,5
96
        popa
90
    mov  ebx,8
97
        mov     ebx, 0
91
    mcall
98
;    call noteout
92
    popa
99
 
93
    mov  ebx,0
100
        add     eax, 4
94
;    call noteout
101
 
95
 
102
        inc     eax
96
    add  eax,4
103
        cmp     eax, 90
97
 
104
        jbe     .nn
98
    inc  eax
105
 
99
    cmp  eax,90
106
        jmp     still
100
    jbe  nn
107
 
101
 
108
exit:
102
    jmp  still
109
        mcall   -1
103
 
110
 
104
 
111
 
105
draw_window:
112
draw_window:
106
 
113
 
107
    pusha
114
        pusha
108
 
115
 
109
    mov       eax,12                    ; tell os about redraw
116
        mov     eax, 12                    ; tell os about redraw
110
    mov       ebx,1
117
        mov     ebx, 1
111
    mcall
118
        mcall
112
 
119
 
113
    mov       eax,0                     ; define and draw window
120
        mov     eax, 0                     ; define and draw window
114
    mov       ebx,20*65536+250
121
        mov     ebx, 20*65536+250
Line 115... Line 122...
115
    mov       ecx,20*65536+120
122
        mov     ecx, 20*65536+120
116
    mov       edx,0x14ffffff
123
        mov     edx, 0x14ffffff
Line 117... Line 124...
117
    mov       edi,title
124
        mov     edi, title
-
 
125
        mcall
-
 
126
 
-
 
127
        mov     eax, 8
-
 
128
        mov     ebx, 10*65536+200          ; button start x & size
Line 118... Line 129...
118
    mcall
129
        mov     ecx, 40 *65536+17          ; button start y & size
-
 
130
        mov     edx, 2                     ; button number
Line 119... Line 131...
119
 
131
        mov     esi, 0x4060b0              ; button color
120
    mov       eax,8
132
        mcall
Line 121... Line -...
121
    mov       ebx,10*65536+200          ; button start x & size
-
 
122
    mov       ecx,40 *65536+17          ; button start y & size
-
 
123
    mov       edx,2                     ; button number
-
 
124
    mov       esi,0x4060b0              ; button color
-
 
125
    mcall
-
 
126
 
-
 
127
    mov       ecx,60 *65536+17          ; button start y & size
133
 
128
    mov       edx,3                     ; button number
-
 
129
    mcall
-
 
130
 
-
 
131
    mov       eax,4
-
 
132
    mov       ebx,25*65536+45
-
 
133
    mov       ecx,dword 0xffffff
-
 
134
    mov       edx,buttont
-
 
135
    mov       esi,buttontlen-buttont
134
        mov     ecx, 60 *65536+17          ; button start y & size
Line -... Line 135...
-
 
135
        mov     edx, 3                     ; button number
136
    mcall
136
        mcall
Line 137... Line 137...
137
 
137
 
Line -... Line 138...
-
 
138
        mov     eax, 4
138
    mov       ebx,25*65536+65
139
        mov     ebx, 25*65536+45
139
    mov       edx,buttont2
140
        mov     ecx, dword 0xffffff
Line 140... Line 141...
140
    mov       esi,buttontlen2-buttont2
141
        mov     edx, buttont
Line 141... Line 142...
141
    mcall
142
        mov     esi, buttontlen-buttont
142
 
143
        mcall
143
    mov       eax,12                    ; tell os about redraw end
144
 
144
    mov       ebx,2
145
        mov     ebx, 25*65536+65
145
    mcall
146
        mov     edx, buttont2
146
 
147
        mov     esi, buttontlen2-buttont2
147
    popa
148
        mcall
148
    ret
149
 
149
 
150
        mov     eax, 12                    ; tell os about redraw end
150
 
151
        mov     ebx, 2
151
noteout:
152
        mcall
152
 
153
 
153
    pusha
154
        popa
-
 
155
        ret
-
 
156
 
-
 
157
 
-
 
158
noteout:
-
 
159
        pusha
-
 
160
 
-
 
161
        push    ebx
-
 
162
        push    eax
-
 
163
 
-
 
164
        mov     ecx, 0x9f
-
 
165
        call    midi_output_byte
-
 
166
 
-
 
167
        pop     ecx
-
 
168
        call    midi_output_byte
-
 
169
 
-
 
170
        pop     ecx
-
 
171
        call    midi_output_byte
-
 
172
 
-
 
173
        cmp     eax, 0
-
 
174
        jz      @f
-
 
175
 
-
 
176
        call    printerror
-
 
177
 
-
 
178
@@:
-
 
179
        popa
-
 
180
        ret
-
 
181
 
-
 
182
printerror:
-
 
183
 
-
 
184
        mov     eax, 4
-
 
185
        mov     ebx, 15*65536+85
-
 
186
        mov     ecx, 0x000000
-
 
187
        mov     edx, error1
-
 
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
 
Line 154... Line -...
154
 
-
 
Line 155... Line 230...
155
    push ebx
230
midi_output_byte: