Subversion Repositories Kolibri OS

Rev

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

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