Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
205 heavyiron 1
;
2
;    INFRARED
3
;
4
;    Compile with FASM for Menuet
5
;
6
 
7
use32
8
 
9
                org     0x0
10
 
11
                db      'MENUET01'              ; 8 byte id
12
                dd      1                       ; 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      0, 0
18
 
19
 
20
include 'macros.inc'
21
 
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
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
86
 
87
red:
88
        call    draw_window
89
 
90
still:
91
 
92
    mov  eax,10                 ; wait here for event
93
    int  0x40
94
        dec     eax
95
        jz      red
96
        dec     eax
97
        dec     eax
98
        jnz     readir
99
 
100
  button:                       ; button
101
    mov  al,17                  ; get id
102
    int  0x40
103
 
104
; we have only one button, close
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
 
117
    or   eax,-1                 ; close this program
118
    int  0x40
119
 
120
pos dd 0x0
121
 
122
cdplayer:
123
        dd      7
124
        dd      0
125
        dd      0
126
        dd      0
127
        dd      0
128
        db      '/RD/1/CDP',0
129
 
130
  readir:
131
    mov  eax,42
132
    mov  ebx,4
133
    int  0x40
134
 
135
    cmp  ebx,80
136
    jne  nocd
137
 
138
    mov  eax,70
139
    mov  ebx,cdplayer
140
    int  0x40
141
 
142
 
143
  nocd:
144
 
145
    push ebx
146
    mov  eax,[pos]
147
    add  eax,1
148
    cmp  eax,10*20+1
149
    jb   noeaxz
150
    mov  esi,text+10*4
151
    mov  edi,text
152
    mov  ecx,10*21*4
153
    cld
154
    rep  movsb
155
    mov  eax,13
156
    mov  ebx,20*65536+260
157
    mov  ecx,22*65536+220
158
    mov  edx,[wcolor]
159
    int  0x40
160
    mov  eax,10*19+1
161
  noeaxz:
162
    mov  [pos],eax
163
    pop  ebx
164
    and  ebx,0xff
165
    call draw_data
166
    jmp  still
167
 
168
 
169
 
170
 
171
draw_data:
172
 
173
    pusha
174
 
175
    xchg eax,ebx
176
 
177
    mov  ecx,10
178
    shl  ebx,2
179
    mov  esi,3
180
  newnum:
181
    xor  edx,edx
182
    div  ecx
183
    add  edx,48
184
    mov  [ebx+text-1],dl
185
    dec  ebx
186
    dec  esi
187
    jnz  newnum
188
 
189
    call draw_text
190
 
191
    popa
192
 
193
    ret
194
 
195
 
196
irqtable:
197
 
198
    dd  0x3f8+0x01000000   ;  +  01 = read byte,  02 read word
199
    dd  0
200
 
201
 
202
 
203
;   *********************************************
204
;   *******  WINDOW DEFINITIONS AND DRAW ********
205
;   *********************************************
206
 
207
 
208
draw_window:
209
 
210
    mov  eax,12                    ; function 12:tell os about windowdraw
211
    mov  ebx,1                     ; 1, start of draw
212
    int  0x40
213
 
214
                                   ; DRAW WINDOW
215
    mov  eax,0                     ; function 0 : define and draw window
216
    mov  ebx,100*65536+300         ; [x start] *65536 + [x size]
217
    mov  ecx,100*65536+250         ; [y start] *65536 + [y size]
218
    mov  edx,[wcolor]              ; color of work area RRGGBB,8->color
219
    mov  edi,labelt                ; caption string
220
    int  0x40
221
 
222
;                                   ; WINDOW LABEL
223
;    mov  eax,4                     ; function 4 : write text to window
224
;    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
225
;    mov  ecx,0x00ffffff            ; color of text RRGGBB
226
;    mov  edx,labelt                ; pointer to text beginning
227
;    mov  esi,labellen-labelt       ; text length
228
;    int  0x40
229
 
230
                                   ; CLOSE BUTTON
231
;    mov  eax,8                     ; function 8 : define and draw button
232
;    mov  ebx,(300-19)*65536+12     ; [x start] *65536 + [x size]
233
;    mov  ecx,5*65536+12            ; [y start] *65536 + [y size]
234
;    mov  edx,1                     ; button id
235
;    mov  esi,0x5599cc              ; button color RRGGBB
236
;    int  0x40
237
 
238
draw_text:
239
 
240
    mov  ebx,25*65536+35           ; draw info text with function 4
241
    mov  ecx,0xffffff
242
    mov  edx,text
243
    mov  esi,40
244
    mov  edi,20
245
  newline:
246
    mov  eax,4
247
    int  0x40
248
    add  ebx,10
249
    add  edx,esi
250
    dec  edi
251
    jne  newline
252
 
253
    mov  eax,12
254
    mov  ebx,2
255
    int  0x40
256
 
257
    ret
258
 
259
 
260
; DATA AREA
261
 
262
wcolor  dd  0x13000000
263
 
264
labelt  db  'INFRARED RECEIVER FOR IRMAN IN COM 1',0
265
 
266
text:
267
 
268
I_END: