Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
687 gluk 1
; <--- description --->
2
; compiler:     FASM 1.67.23
3
; name:         Mouse Emulation For KolibriOS
4
; version:      0.8
5
; last update:  03/10/2007
6
; written by:   Zlobny_Gluk
7
; e-mail:       umbrosia@land.ru
8
 
9
 
10
; <--- include all KolibriOS stuff --->
11
;include "lang.inc"
12
include "MACROS.INC"
13
 
14
 
15
; <--- start of KolibriOS application --->
16
MEOS_APP_START
17
 
18
 
19
; <--- start of code --->
20
CODE
21
 
22
  start:
23
 
24
  ;set an waiting mask
25
   mcall 40,10b
26
 
27
 
28
  wait_event_one:
29
 
30
    call checkspeed
31
 
32
 
33
    mov eax,66
34
    mov ebx,3
35
    int 0x40
36
    test eax,0x80
37
    jnz wait_event_two
38
 
39
    cmp ebp,1
40
    je unset_hotkeys
41
 
42
 
43
    mov eax,5
44
    mov ebx,10
45
    int 0x40
46
 
47
    jmp wait_event_one
48
 
49
 
50
  wait_event_two:
51
    cmp ebp,0
52
    je set_hotkeys
53
    mov ebp,1
54
    mov eax,10
55
    int 0x40
56
 
57
    cmp eax, 2			   ; if event == 2
58
    jmp key			   ; jump to key handler
59
 
60
    jmp wait_event_one		   ; else return to the start of main cycle
61
 
62
 
63
 
64
  key:				   ; key event handler
65
    mov eax, 2			   ; get key code
66
    int 0x40
67
    cmp al,2
68
    je mousewriteli
69
    jmp wait_event_one
70
 
71
 
72
 
73
  set_hotkeys:
74
 
75
 
76
    mov eax,66
77
    mov ebx,4
78
    mov cl,79d
79
    mov edx,0
80
    int 0x40
81
 
82
    mov eax,66
83
    mov ebx,4
84
    mov cl,80
85
    mov edx,0
86
    int 0x40
87
 
88
    mov eax,66
89
    mov ebx,4
90
    mov cl,81
91
    mov edx,0
92
    int 0x40
93
 
94
    mov eax,66
95
    mov ebx,4
96
    mov cl,75
97
    mov edx,0
98
    int 0x40
99
 
100
    mov eax,66
101
    mov ebx,4
102
    mov cl,76
103
    mov edx,0
104
    int 0x40
105
 
106
    mov eax,66
107
    mov ebx,4
108
    mov cl,77
109
    mov edx,0
110
    int 0x40
111
 
112
    mov eax,66
113
    mov ebx,4
114
    mov cl,71
115
    mov edx,0
116
    int 0x40
117
 
118
    mov eax,66
119
    mov ebx,4
120
    mov cl,72
121
    mov edx,0
122
    int 0x40
123
 
124
    mov eax,66
125
    mov ebx,4
126
    mov cl,73
127
    mov edx,0
128
    int 0x40
129
 
130
 
131
  mov ebp,1
132
 
133
  jmp wait_event_two
134
 
135
 
136
  unset_hotkeys:
137
 
138
 
139
    mov eax,66
140
    mov ebx,5
141
    mov cl,79
142
    mov edx,0
143
    int 0x40
144
 
145
    mov eax,66
146
    mov ebx,5
147
    mov cl,80
148
    mov edx,0
149
    int 0x40
150
 
151
    mov eax,66
152
    mov ebx,5
153
    mov cl,81
154
    mov edx,0
155
    int 0x40
156
 
157
    mov eax,66
158
    mov ebx,5
159
    mov cl,75
160
    mov edx,0
161
    int 0x40
162
 
163
    mov eax,66
164
    mov ebx,5
165
    mov cl,76
166
    mov edx,0
167
    int 0x40
168
 
169
    mov eax,66
170
    mov ebx,5
171
    mov cl,77
172
    mov edx,0
173
    int 0x40
174
 
175
    mov eax,66
176
    mov ebx,5
177
    mov cl,71
178
    mov edx,0
179
    int 0x40
180
 
181
    mov eax,66
182
    mov ebx,5
183
    mov cl,72
184
    mov edx,0
185
    int 0x40
186
 
187
    mov eax,66
188
    mov ebx,5
189
    mov cl,73
190
    mov edx,0
191
    int 0x40
192
 
193
 
194
    xor ebp,ebp
195
 
196
  jmp wait_event_one
197
 
198
checkspeed:
199
   mov eax,18
200
   mov ebx,19
201
   xor ecx,ecx
202
   int 0x40
203
   mov esi,eax
204
ret
205
 
206
 
207
  mouseread:
208
 
209
    ;numchecking
210
    mov eax,66
211
    mov ebx,3
212
    int 0x40
213
    test eax,0x80
214
    jz wait_event_one
215
 
216
    ;mousereading
217
    mov eax,37
218
    mov ebx,0
219
    int 0x40
220
    add edx,eax
221
 
222
 
223
  sravn:
224
    xor ebx,ebx
225
    xor edi,edi
226
 
227
 
228
    real:
229
    mov ebx,edx
230
    mov edi,ebx
231
    shr ebx,16 ; get x1
232
    shl edi,16 ; get y1
233
    shr edi,16
234
 
235
    nullli:
236
    add ebx,16
237
    cmp ebx,65535
238
    jg xmin
239
    sub ebx,15
240
 
241
    add edi,16
242
    cmp edi,65535
243
    jg ymin
244
    sub edi,15
245
 
246
    razr:
247
    mov eax,14
248
    int 0x40
249
 
250
 
251
    mov ecx,eax
252
    shr eax,16 ; get x2
253
    shl ecx,16 ; get y2
254
    shr ecx,16
255
 
256
    rightdownli:
257
    cmp eax,ebx
258
    jl xmax
259
    cmp ecx,edi
260
    jl ymax
261
 
262
 
263
  mousewrite:
264
    mov eax,18
265
    mov ebx,19
266
    mov ecx,4
267
    int 0x40
268
  jmp wait_event_one
269
 
270
  xmax:
271
 
272
    dec eax
273
    dec ebx
274
    dec edi
275
    shl eax,16
276
    add edi,eax
277
    mov edx,edi
278
    jmp sravn
279
 
280
  xmin:
281
 
282
    mov edx,edi
283
    jmp sravn
284
 
285
 
286
  ymax:
287
 
288
    dec ecx
289
    dec ebx
290
 
291
    shl ebx,16
292
    mov edi,ebx
293
    add edi,ecx
294
    mov edx,edi
295
    jmp sravn
296
 
297
  ymin:
298
    shl ebx,16
299
    mov edx,ebx
300
    shr ebx,16
301
    jmp sravn
302
 
303
 
304
 
305
 
306
 
307
 
308
 
309
  mousewriteli:
310
    cmp ah,79
311
    je keyone
312
    cmp ah,80
313
    je keytwo
314
    cmp ah,81
315
    je keythree
316
    cmp ah,75
317
    je keyfour
318
    cmp ah,77
319
    je keysix
320
    cmp ah,71
321
    je keyseven
322
    cmp ah,72
323
    je keyeight
324
    cmp ah,73
325
    je keynine
326
    cmp ah,76
327
    je keyfive
328
 
329
  jmp wait_event_one
330
 
331
 
332
;how_much_time:
333
;mov eax,26
334
;mov ebx,9
335
;int 0x40
336
;push eax
337
;ret
338
 
339
 
340
;oldkeyvsyakoe!
341
;incesi:
342
;inc esi
343
;ret
344
 
345
;nullesi:
346
;xor esi, esi
347
;ret
348
 
349
 
350
;oldkey:
351
;cmp ah, bh
352
;je incesi
353
;cmp ah, bh
354
;jne nullesi
355
;ret
356
 
357
 
358
keyone:
359
 
360
;call oldkey
361
xor edx,edx
362
call left
363
call down
364
xor ah,ah
365
mov bh,79
366
jmp mouseread
367
 
368
keytwo:
369
 
370
;call oldkey
371
xor edx,edx
372
call down
373
call down
374
xor ah,ah
375
mov bh,80
376
jmp mouseread
377
 
378
keythree:
379
 
380
;call oldkey
381
xor edx,edx
382
call right
383
call down
384
xor ah,ah
385
mov bh,81
386
jmp mouseread
387
 
388
keyfour:
389
 
390
;call oldkey
391
xor edx,edx
392
call left
393
call left
394
xor ah,ah
395
mov bh,75
396
jmp mouseread
397
 
398
keysix:
399
 
400
;call oldkey
401
xor edx,edx
402
call right
403
call right
404
xor ah,ah
405
mov bh,77
406
jmp mouseread
407
 
408
keyseven:
409
 
410
;call oldkey
411
xor edx,edx
412
call left
413
call up
414
xor ah,ah
415
mov bh,71
416
jmp mouseread
417
 
418
keyeight:
419
 
420
;call oldkey
421
xor edx,edx
422
call up
423
call up
424
xor ah,ah
425
mov bh,72
426
jmp mouseread
427
 
428
keynine:
429
 
430
;call oldkey
431
xor edx,edx
432
call right
433
call up
434
xor ah,ah
435
mov bh,73
436
jmp mouseread
437
 
438
keyfive:
439
 
440
 mcall 18, 19, 5, 1
441
 mov eax,5
442
 mov ebx,1
443
 int 0x40
444
 mcall 18, 19, 5, 0
445
jmp wait_event_one
446
 
447
 
448
 
449
 
450
left:
451
mov eax,esi
452
 
453
leftstart:
454
dec eax
455
sub edx,65536
456
cmp eax,0
457
ja leftstart
458
ret
459
 
460
 
461
right:
462
mov eax,esi
463
 
464
rightstart:
465
dec eax
466
add edx,65536
467
cmp eax,0
468
ja rightstart
469
ret
470
 
471
 
472
down:
473
mov eax,esi
474
 
475
downstart:
476
dec eax
477
add edx,1
478
cmp eax,0
479
ja downstart
480
ret
481
 
482
 
483
up:
484
mov eax,esi
485
 
486
upstart:
487
dec eax
488
sub edx,1
489
cmp eax,0
490
ja upstart
491
ret
492
 
493
 
494
 
495
 
496
 
497
 
498
 
499
 
500
 
501
 
502
 
503
; <--- initialised data --->
504
DATA
505
 
506
 
507
; <--- uninitialised data --->
508
UDATA
509
 
510
 
511
MEOS_APP_END
512
; <--- end of KolibriOS application --->
513
; ZG