Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
;    INFRARED
3
;
4
;    Compile with FASM for Menuet
5
;
6
 
7
use32
8
 
9
                org     0x0
10
 
11
                db      'MENUET00'              ; 8 byte id
12
                dd      56                      ; required os
13
                dd      START                   ; program start
14
                dd      I_END                   ; program image size
15
                dd      0x1000                  ; required amount of memory
16
                dd      0x1000                  ; esp = 0x7FFF0
17
                dd      0x00000000              ; reserved=no extended header
18
 
19
 
20
include 'lang.inc'
21
include 'macros.inc'
22
 
23
START:                          ; start of execution
24
 
25
    call draw_window            ; at first, draw the window
26
 
27
    call set_variables
28
 
29
still:
30
 
31
    mov  eax,10                 ; wait here for event
32
    int  0x40
33
 
34
    cmp  eax,1                  ; redraw request ?
35
    je   red
36
    cmp  eax,2                  ; key in buffer ?
37
    je   key
38
    cmp  eax,3                  ; button in buffer ?
39
    je   button
40
    cmp  eax,16+4
41
    je   readir
42
 
43
    jmp  still
44
 
45
pos dd 0x0
46
 
47
cdplayer db  'CDPLAY     '
48
 
49
  readir:
50
    mov  eax,42
51
    mov  ebx,4
52
    int  0x40
53
 
54
    cmp  ebx,80
55
    jne  nocd
56
 
57
    mov  eax,19
58
    mov  ebx,cdplayer
59
    mov  ecx,0
60
    int  0x40
61
 
62
 
63
  nocd:
64
 
65
    push ebx
66
    mov  eax,[pos]
67
    add  eax,1
68
    cmp  eax,10*20+1
69
    jb   noeaxz
70
    mov  esi,text+10*4
71
    mov  edi,text
72
    mov  ecx,10*21*4
73
    cld
74
    rep  movsb
75
    mov  eax,13
76
    mov  ebx,20*65536+260
77
    mov  ecx,22*65536+220
78
    mov  edx,[wcolor]
79
    int  0x40
80
    mov  eax,10*19+1
81
  noeaxz:
82
    mov  [pos],eax
83
    pop  ebx
84
    and  ebx,0xff
85
    call draw_data
86
    jmp  still
87
 
88
  red:                          ; redraw
89
    call draw_window
90
    jmp  still
91
 
92
  key:                          ; key
93
    mov  eax,2                  ; just read it and ignore
94
    int  0x40
95
    jmp  still
96
 
97
  button:                       ; button
98
    mov  eax,17                 ; get id
99
    int  0x40
100
 
101
    cmp  ah,1                   ; button id=1 ?
102
    jne  noclose
103
 
104
    mov  eax,45                 ; free irq
105
    mov  ebx,1
106
    mov  ecx,4
107
    int  0x40
108
 
109
    mov  eax,46                 ; free ports 0x3f0-0x3ff
110
    mov  ebx,1
111
    mov  ecx,0x3f0
112
    mov  edx,0x3ff
113
    int  0x40
114
 
115
    mov  eax,-1                 ; close this program
116
    int  0x40
117
  noclose:
118
 
119
    jmp  still
120
 
121
 
122
 
123
draw_data:
124
 
125
    pusha
126
 
127
    xchg eax,ebx
128
 
129
    mov  ecx,10
130
    shl  ebx,2
131
    mov  esi,3
132
  newnum:
133
    xor  edx,edx
134
    div  ecx
135
    add  edx,48
136
    mov  [ebx+text-1],dl
137
    dec  ebx
138
    dec  esi
139
    jnz  newnum
140
 
141
    call draw_text
142
 
143
    popa
144
 
145
    ret
146
 
147
 
148
irqtable:
149
 
150
    dd  0x3f8+0x01000000   ;  +  01 = read byte,  02 read word
151
    dd  0
152
    dd  0
153
    dd  0
154
    dd  0
155
    dd  0
156
    dd  0
157
    dd  0
158
    dd  0
159
    dd  0
160
    dd  0
161
    dd  0
162
    dd  0
163
    dd  0
164
    dd  0
165
    dd  0
166
 
167
 
168
 
169
set_variables:
170
 
171
 
172
    pusha
173
 
174
    mov  eax,46           ; reserve ports 0x3f0 - 0x3ff
175
    mov  ebx,0
176
    mov  ecx,0x3f0
177
    mov  edx,0x3ff
178
    int  0x40
179
 
180
    mov  eax,45           ; reserve irq 4
181
    mov  ebx,0
182
    mov  ecx,4
183
    int  0x40
184
 
185
    mov  eax,46           ; reserve ports 0x3f0-0x3ff
186
    mov  ebx,0
187
    mov  ecx,0x3f0
188
    mov  edx,0x3ff
189
    int  0x40
190
 
191
    mov  eax,44           ; set read ports for irq 4
192
    mov  ebx,irqtable
193
    mov  ecx,4
194
    int  0x40
195
 
196
    mov  cx,0x3f3+8
197
    mov  bl,0x80
198
    mov  eax,43
199
    int  0x40
200
 
201
    mov  cx,0x3f1+8
202
    mov  bl,0
203
    mov  eax,43
204
    int  0x40
205
 
206
    mov  cx,0x3f0+8
207
    mov  bl,0x30 / 4
208
    mov  eax,43
209
    int  0x40
210
 
211
    mov  cx,0x3f3+8
212
    mov  bl,3
213
    mov  eax,43
214
    int  0x40
215
 
216
    mov  cx,0x3f4+8
217
    mov  bl,0xB
218
    mov  eax,43
219
    int  0x40
220
 
221
    mov  cx,0x3f1+8
222
    mov  bl,1
223
    mov  eax,43
224
    int  0x40
225
 
226
    mov  eax,5
227
    mov  ebx,100
228
    int  0x40
229
 
230
    mov  cx,0x3f8
231
    mov  bl,'I'
232
    mov  eax,43
233
    int  0x40
234
 
235
    mov  eax,5
236
    mov  ebx,10
237
    int  0x40
238
 
239
    mov  cx,0x3f8
240
    mov  bl,'R'
241
    mov  eax,43
242
    int  0x40
243
 
244
    mov  eax,40                                 ; get com 1 data with irq 4
245
    mov  ebx,0000000000010000b shl 16 + 111b
246
    int  0x40
247
 
248
    popa
249
 
250
    ret
251
 
252
 
253
;   *********************************************
254
;   *******  WINDOW DEFINITIONS AND DRAW ********
255
;   *********************************************
256
 
257
 
258
draw_window:
259
 
260
    mov  eax,12                    ; function 12:tell os about windowdraw
261
    mov  ebx,1                     ; 1, start of draw
262
    int  0x40
263
 
264
                                   ; DRAW WINDOW
265
    mov  eax,0                     ; function 0 : define and draw window
266
    mov  ebx,100*65536+300         ; [x start] *65536 + [x size]
267
    mov  ecx,100*65536+250         ; [y start] *65536 + [y size]
268
    mov  edx,[wcolor]              ; color of work area RRGGBB,8->color
269
    mov  esi,0x8099bbff            ; color of grab bar  RRGGBB,8->color glide
270
    mov  edi,0x00ffffff            ; color of frames    RRGGBB
271
    int  0x40
272
 
273
                                   ; WINDOW LABEL
274
    mov  eax,4                     ; function 4 : write text to window
275
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
276
    mov  ecx,0x00ffffff            ; color of text RRGGBB
277
    mov  edx,labelt                ; pointer to text beginning
278
    mov  esi,labellen-labelt       ; text length
279
    int  0x40
280
 
281
                                   ; CLOSE BUTTON
282
    mov  eax,8                     ; function 8 : define and draw button
283
    mov  ebx,(300-19)*65536+12     ; [x start] *65536 + [x size]
284
    mov  ecx,5*65536+12            ; [y start] *65536 + [y size]
285
    mov  edx,1                     ; button id
286
    mov  esi,0x5599cc              ; button color RRGGBB
287
;    int  0x40
288
 
289
    call draw_text
290
 
291
    mov  eax,12
292
    mov  ebx,2
293
    int  0x40
294
 
295
    ret
296
 
297
draw_text:
298
 
299
    pusha
300
 
301
    mov  ebx,25*65536+35           ; draw info text with function 4
302
    mov  ecx,0xffffff
303
    mov  edx,text
304
    mov  esi,40
305
    mov  edi,20
306
  newline:
307
    mov  eax,4
308
    int  0x40
309
    add  ebx,10
310
    add  edx,40
311
    dec  edi
312
    jne  newline
313
 
314
    popa
315
 
316
    ret
317
 
318
 
319
 
320
; DATA AREA
321
 
322
wcolor  dd  0x03000000
323
 
324
labelt  db  'INFRARED RECEIVER FOR IRMAN IN COM 1'
325
labellen:
326
 
327
text:
328
 
329
I_END:
330