Subversion Repositories Kolibri OS

Rev

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

Rev 1161 Rev 1206
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
7
 
8
$Revision: 983 $
8
$Revision: 1206 $
9
 
9
 
10
 
10
 
11
LOAD_FROM_FILE  equ 0
11
LOAD_FROM_FILE  equ 0
12
LOAD_FROM_MEM   equ 1
12
LOAD_FROM_MEM   equ 1
13
LOAD_INDIRECT   equ 2
13
LOAD_INDIRECT   equ 2
14
LOAD_SYSTEM     equ 3
14
LOAD_SYSTEM     equ 3
15
 
15
 
16
struc BITMAPINFOHEADER {
16
struc BITMAPINFOHEADER {
17
  .biSize          dd ? ; DWORD
17
  .biSize          dd ? ; DWORD
18
  .biWidth         dd ? ; LONG
18
  .biWidth         dd ? ; LONG
19
  .biHeight        dd ? ; LONG
19
  .biHeight        dd ? ; LONG
20
  .biPlanes        dw ? ; WORD
20
  .biPlanes        dw ? ; WORD
21
  .biBitCount      dw ? ; WORD
21
  .biBitCount      dw ? ; WORD
22
  .biCompression   dd ? ; DWORD
22
  .biCompression   dd ? ; DWORD
23
  .biSizeImage     dd ? ; DWORD
23
  .biSizeImage     dd ? ; DWORD
24
  .biXPelsPerMeter dd ? ; LONG
24
  .biXPelsPerMeter dd ? ; LONG
25
  .biYPelsPerMeter dd ? ; LONG
25
  .biYPelsPerMeter dd ? ; LONG
26
  .biClrUsed       dd ? ; DWORD
26
  .biClrUsed       dd ? ; DWORD
27
  .biClrImportant  dd ? ; DWORD
27
  .biClrImportant  dd ? ; DWORD
28
}
28
}
29
 
29
 
30
virtual at 0
30
virtual at 0
31
  BI BITMAPINFOHEADER
31
  BI BITMAPINFOHEADER
32
end virtual
32
end virtual
33
 
33
 
34
align 4
34
align 4
35
proc vesa_init_cursor stdcall, dst:dword, src:dword
35
proc vesa_init_cursor stdcall, dst:dword, src:dword
36
           locals
36
           locals
37
             rBase    dd ?
37
             rBase    dd ?
38
             pQuad    dd ?
38
             pQuad    dd ?
39
             pBits    dd ?
39
             pBits    dd ?
40
             pAnd     dd ?
40
             pAnd     dd ?
41
             width    dd ?
41
             width    dd ?
42
             height   dd ?
42
             height   dd ?
43
             counter  dd ?
43
             counter  dd ?
44
           endl
44
           endl
45
 
45
 
46
           mov esi, [src]
46
           mov esi, [src]
47
           add esi,[esi+18]
47
           add esi,[esi+18]
48
           mov eax,esi
48
           mov eax,esi
49
 
49
 
50
           cmp [esi+BI.biBitCount], 24
50
           cmp [esi+BI.biBitCount], 24
51
           je .img_24
51
           je .img_24
52
           cmp [esi+BI.biBitCount], 8
52
           cmp [esi+BI.biBitCount], 8
53
           je .img_8
53
           je .img_8
54
           cmp [esi+BI.biBitCount], 4
54
           cmp [esi+BI.biBitCount], 4
55
           je .img_4
55
           je .img_4
56
 
56
 
57
.img_2:
57
.img_2:
58
           add eax, [esi]
58
           add eax, [esi]
59
           mov [pQuad],eax
59
           mov [pQuad],eax
60
           add eax,8
60
           add eax,8
61
           mov [pBits],eax
61
           mov [pBits],eax
62
           add eax, 128
62
           add eax, 128
63
           mov [pAnd],eax
63
           mov [pAnd],eax
64
           mov eax,[esi+4]
64
           mov eax,[esi+4]
65
           mov [width],eax
65
           mov [width],eax
66
           mov ebx,[esi+8]
66
           mov ebx,[esi+8]
67
           shr ebx,1
67
           shr ebx,1
68
           mov [height],ebx
68
           mov [height],ebx
69
 
69
 
70
           mov edi, [dst]
70
           mov edi, [dst]
71
           add edi, 32*31*4
71
           add edi, 32*31*4
72
           mov [rBase],edi
72
           mov [rBase],edi
73
 
73
 
74
           mov esi,[pQuad]
74
           mov esi,[pQuad]
75
.l21:
75
.l21:
76
           mov ebx, [pBits]
76
           mov ebx, [pBits]
77
           mov ebx, [ebx]
77
           mov ebx, [ebx]
78
           bswap ebx
78
           bswap ebx
79
           mov eax, [pAnd]
79
           mov eax, [pAnd]
80
           mov eax, [eax]
80
           mov eax, [eax]
81
           bswap eax
81
           bswap eax
82
           mov [counter], 32
82
           mov [counter], 32
83
@@:
83
@@:
84
           xor edx, edx
84
           xor edx, edx
85
           shl eax,1
85
           shl eax,1
86
           setc dl
86
           setc dl
87
           dec edx
87
           dec edx
88
 
88
 
89
           xor ecx, ecx
89
           xor ecx, ecx
90
           shl ebx,1
90
           shl ebx,1
91
           setc cl
91
           setc cl
92
           mov ecx, [esi+ecx*4]
92
           mov ecx, [esi+ecx*4]
93
           and ecx, edx
93
           and ecx, edx
94
           and edx, 0xFF000000
94
           and edx, 0xFF000000
95
           or edx, ecx
95
           or edx, ecx
96
           mov [edi], edx
96
           mov [edi], edx
97
 
97
 
98
           add edi, 4
98
           add edi, 4
99
           dec [counter]
99
           dec [counter]
100
           jnz @B
100
           jnz @B
101
 
101
 
102
           add [pBits], 4
102
           add [pBits], 4
103
           add [pAnd], 4
103
           add [pAnd], 4
104
           mov edi,[rBase]
104
           mov edi,[rBase]
105
           sub edi,128
105
           sub edi,128
106
           mov [rBase],edi
106
           mov [rBase],edi
107
           sub [height],1
107
           sub [height],1
108
           jnz .l21
108
           jnz .l21
109
           ret
109
           ret
110
 
110
 
111
.img_4:
111
.img_4:
112
           add eax, [esi]
112
           add eax, [esi]
113
           mov [pQuad],eax
113
           mov [pQuad],eax
114
           add eax,64
114
           add eax,64
115
           mov [pBits],eax
115
           mov [pBits],eax
116
           add eax, 0x200
116
           add eax, 0x200
117
           mov [pAnd],eax
117
           mov [pAnd],eax
118
           mov eax,[esi+4]
118
           mov eax,[esi+4]
119
           mov [width],eax
119
           mov [width],eax
120
           mov ebx,[esi+8]
120
           mov ebx,[esi+8]
121
           shr ebx,1
121
           shr ebx,1
122
           mov [height],ebx
122
           mov [height],ebx
123
 
123
 
124
           mov edi, [dst]
124
           mov edi, [dst]
125
           add edi, 32*31*4
125
           add edi, 32*31*4
126
           mov [rBase],edi
126
           mov [rBase],edi
127
 
127
 
128
           mov esi,[pQuad]
128
           mov esi,[pQuad]
129
           mov ebx, [pBits]
129
           mov ebx, [pBits]
130
.l4:
130
.l4:
131
           mov eax, [pAnd]
131
           mov eax, [pAnd]
132
           mov eax, [eax]
132
           mov eax, [eax]
133
           bswap eax
133
           bswap eax
134
           mov [counter], 16
134
           mov [counter], 16
135
@@:
135
@@:
136
           xor edx, edx
136
           xor edx, edx
137
           shl eax,1
137
           shl eax,1
138
           setc dl
138
           setc dl
139
           dec edx
139
           dec edx
140
 
140
 
141
           movzx ecx, byte [ebx]
141
           movzx ecx, byte [ebx]
142
           and cl, 0xF0
142
           and cl, 0xF0
143
           shr ecx, 2
143
           shr ecx, 2
144
           mov ecx, [esi+ecx]
144
           mov ecx, [esi+ecx]
145
           and ecx, edx
145
           and ecx, edx
146
           and edx, 0xFF000000
146
           and edx, 0xFF000000
147
           or edx, ecx
147
           or edx, ecx
148
           mov [edi], edx
148
           mov [edi], edx
149
 
149
 
150
           xor edx, edx
150
           xor edx, edx
151
           shl eax,1
151
           shl eax,1
152
           setc dl
152
           setc dl
153
           dec edx
153
           dec edx
154
 
154
 
155
           movzx ecx, byte [ebx]
155
           movzx ecx, byte [ebx]
156
           and cl, 0x0F
156
           and cl, 0x0F
157
           mov ecx, [esi+ecx*4]
157
           mov ecx, [esi+ecx*4]
158
           and ecx, edx
158
           and ecx, edx
159
           and edx, 0xFF000000
159
           and edx, 0xFF000000
160
           or edx, ecx
160
           or edx, ecx
161
           mov [edi+4], edx
161
           mov [edi+4], edx
162
 
162
 
163
           inc ebx
163
           inc ebx
164
           add edi, 8
164
           add edi, 8
165
           dec [counter]
165
           dec [counter]
166
           jnz @B
166
           jnz @B
167
 
167
 
168
           add [pAnd], 4
168
           add [pAnd], 4
169
           mov edi,[rBase]
169
           mov edi,[rBase]
170
           sub edi,128
170
           sub edi,128
171
           mov [rBase],edi
171
           mov [rBase],edi
172
           sub [height],1
172
           sub [height],1
173
           jnz .l4
173
           jnz .l4
174
           ret
174
           ret
175
.img_8:
175
.img_8:
176
           add eax, [esi]
176
           add eax, [esi]
177
           mov [pQuad],eax
177
           mov [pQuad],eax
178
           add eax,1024
178
           add eax,1024
179
           mov [pBits],eax
179
           mov [pBits],eax
180
           add eax, 1024
180
           add eax, 1024
181
           mov [pAnd],eax
181
           mov [pAnd],eax
182
           mov eax,[esi+4]
182
           mov eax,[esi+4]
183
           mov [width],eax
183
           mov [width],eax
184
           mov ebx,[esi+8]
184
           mov ebx,[esi+8]
185
           shr ebx,1
185
           shr ebx,1
186
           mov [height],ebx
186
           mov [height],ebx
187
 
187
 
188
           mov edi, [dst]
188
           mov edi, [dst]
189
           add edi, 32*31*4
189
           add edi, 32*31*4
190
           mov [rBase],edi
190
           mov [rBase],edi
191
 
191
 
192
           mov esi,[pQuad]
192
           mov esi,[pQuad]
193
           mov ebx, [pBits]
193
           mov ebx, [pBits]
194
.l81:
194
.l81:
195
           mov eax, [pAnd]
195
           mov eax, [pAnd]
196
           mov eax, [eax]
196
           mov eax, [eax]
197
           bswap eax
197
           bswap eax
198
           mov [counter], 32
198
           mov [counter], 32
199
@@:
199
@@:
200
           xor edx, edx
200
           xor edx, edx
201
           shl eax,1
201
           shl eax,1
202
           setc dl
202
           setc dl
203
           dec edx
203
           dec edx
204
 
204
 
205
           movzx ecx,  byte [ebx]
205
           movzx ecx,  byte [ebx]
206
           mov ecx, [esi+ecx*4]
206
           mov ecx, [esi+ecx*4]
207
           and ecx, edx
207
           and ecx, edx
208
           and edx, 0xFF000000
208
           and edx, 0xFF000000
209
           or edx, ecx
209
           or edx, ecx
210
           mov [edi], edx
210
           mov [edi], edx
211
 
211
 
212
           inc ebx
212
           inc ebx
213
           add edi, 4
213
           add edi, 4
214
           dec [counter]
214
           dec [counter]
215
           jnz @B
215
           jnz @B
216
 
216
 
217
           add [pAnd], 4
217
           add [pAnd], 4
218
           mov edi,[rBase]
218
           mov edi,[rBase]
219
           sub edi,128
219
           sub edi,128
220
           mov [rBase],edi
220
           mov [rBase],edi
221
           sub [height],1
221
           sub [height],1
222
           jnz .l81
222
           jnz .l81
223
           ret
223
           ret
224
.img_24:
224
.img_24:
225
           add eax, [esi]
225
           add eax, [esi]
226
           mov [pQuad],eax
226
           mov [pQuad],eax
227
           add eax, 0xC00
227
           add eax, 0xC00
228
           mov [pAnd],eax
228
           mov [pAnd],eax
229
           mov eax,[esi+BI.biWidth]
229
           mov eax,[esi+BI.biWidth]
230
           mov [width],eax
230
           mov [width],eax
231
           mov ebx,[esi+BI.biHeight]
231
           mov ebx,[esi+BI.biHeight]
232
           shr ebx,1
232
           shr ebx,1
233
           mov [height],ebx
233
           mov [height],ebx
234
 
234
 
235
           mov edi, [dst]
235
           mov edi, [dst]
236
           add edi, 32*31*4
236
           add edi, 32*31*4
237
           mov [rBase],edi
237
           mov [rBase],edi
238
 
238
 
239
           mov esi,[pAnd]
239
           mov esi,[pAnd]
240
           mov ebx, [pQuad]
240
           mov ebx, [pQuad]
241
.row_24:
241
.row_24:
242
           mov eax, [esi]
242
           mov eax, [esi]
243
           bswap eax
243
           bswap eax
244
           mov [counter], 32
244
           mov [counter], 32
245
@@:
245
@@:
246
           xor edx, edx
246
           xor edx, edx
247
           shl eax,1
247
           shl eax,1
248
           setc dl
248
           setc dl
249
           dec edx
249
           dec edx
250
 
250
 
251
           mov ecx, [ebx]
251
           mov ecx, [ebx]
252
           and ecx, 0x00FFFFFF
252
           and ecx, 0x00FFFFFF
253
           and ecx, edx
253
           and ecx, edx
254
           and edx, 0xFF000000
254
           and edx, 0xFF000000
255
           or edx, ecx
255
           or edx, ecx
256
           mov [edi], edx
256
           mov [edi], edx
257
           add ebx, 3
257
           add ebx, 3
258
           add edi, 4
258
           add edi, 4
259
           dec [counter]
259
           dec [counter]
260
           jnz @B
260
           jnz @B
261
 
261
 
262
           add esi, 4
262
           add esi, 4
263
           mov edi,[rBase]
263
           mov edi,[rBase]
264
           sub edi,128
264
           sub edi,128
265
           mov [rBase],edi
265
           mov [rBase],edi
266
           sub [height],1
266
           sub [height],1
267
           jnz .row_24
267
           jnz .row_24
268
           ret
268
           ret
269
endp
269
endp
270
 
270
 
271
align 4
271
align 4
272
proc set_cursor stdcall, hcursor:dword
272
proc set_cursor stdcall, hcursor:dword
273
           mov eax, [hcursor]
273
           mov eax, [hcursor]
274
           cmp [eax+CURSOR.magic], 'CURS'
274
           cmp [eax+CURSOR.magic], 'CURS'
275
           jne .fail
275
           jne .fail
276
;           cmp [eax+CURSOR.size], CURSOR_SIZE
276
;           cmp [eax+CURSOR.size], CURSOR_SIZE
277
;           jne .fail
277
;           jne .fail
278
           mov ebx, [current_slot]
278
           mov ebx, [current_slot]
279
           xchg eax, [ebx+APPDATA.cursor]
279
           xchg eax, [ebx+APPDATA.cursor]
280
           ret
280
           ret
281
.fail:
281
.fail:
282
           mov eax, [def_cursor]
282
           mov eax, [def_cursor]
283
           mov ebx, [current_slot]
283
           mov ebx, [current_slot]
284
           xchg eax, [ebx+APPDATA.cursor]
284
           xchg eax, [ebx+APPDATA.cursor]
285
           ret
285
           ret
286
endp
286
endp
287
 
287
 
288
; param
288
; param
289
;  eax= pid
289
;  eax= pid
290
;  ebx= src
290
;  ebx= src
291
;  ecx= flags
291
;  ecx= flags
292
 
292
 
293
vesa_cursor:
293
vesa_cursor:
294
.src     equ esp
294
.src     equ esp
295
.flags   equ esp+4
295
.flags   equ esp+4
296
.hcursor equ esp+8
296
.hcursor equ esp+8
297
 
297
 
298
           sub esp, 4          ;space for .hcursor
298
           sub esp, 4          ;space for .hcursor
299
           push ecx
299
           push ecx
300
           push ebx
300
           push ebx
301
 
301
 
302
           mov ebx, eax
302
           mov ebx, eax
303
           mov eax, CURSOR_SIZE
303
           mov eax, CURSOR_SIZE
304
           call create_kernel_object
304
           call create_kernel_object
305
           test eax, eax
305
           test eax, eax
306
           jz .fail
306
           jz .fail
307
 
307
 
308
           mov [.hcursor],eax
308
           mov [.hcursor],eax
309
 
309
 
310
           xor ebx, ebx
310
           xor ebx, ebx
311
           mov [eax+CURSOR.magic], 'CURS'
311
           mov [eax+CURSOR.magic], 'CURS'
312
           mov [eax+CURSOR.destroy], destroy_cursor
312
           mov [eax+CURSOR.destroy], destroy_cursor
313
           mov [eax+CURSOR.hot_x], ebx
313
           mov [eax+CURSOR.hot_x], ebx
314
           mov [eax+CURSOR.hot_y], ebx
314
           mov [eax+CURSOR.hot_y], ebx
315
 
315
 
316
           stdcall kernel_alloc, 0x1000
316
           stdcall kernel_alloc, 0x1000
317
           test eax, eax
317
           test eax, eax
318
           jz .fail
318
           jz .fail
319
 
319
 
320
           mov edi, [.hcursor]
320
           mov edi, [.hcursor]
321
           mov [edi+CURSOR.base], eax
321
           mov [edi+CURSOR.base], eax
322
 
322
 
323
           mov esi, [.src]
323
           mov esi, [.src]
324
           mov ebx, [.flags]
324
           mov ebx, [.flags]
325
           cmp bx, LOAD_INDIRECT
325
           cmp bx, LOAD_INDIRECT
326
           je .indirect
326
           je .indirect
327
 
327
 
328
           movzx ecx, word [esi+10]
328
           movzx ecx, word [esi+10]
329
           movzx edx, word [esi+12]
329
           movzx edx, word [esi+12]
330
           mov [edi+CURSOR.hot_x], ecx
330
           mov [edi+CURSOR.hot_x], ecx
331
           mov [edi+CURSOR.hot_y], edx
331
           mov [edi+CURSOR.hot_y], edx
332
 
332
 
333
           stdcall vesa_init_cursor, eax, esi
333
           stdcall vesa_init_cursor, eax, esi
334
           mov eax, [.hcursor]
334
           mov eax, [.hcursor]
335
.fail:
335
.fail:
336
           add esp, 12
336
           add esp, 12
337
           ret
337
           ret
338
.indirect:
338
.indirect:
339
           shr ebx, 16
339
           shr ebx, 16
340
           movzx ecx, bh
340
           movzx ecx, bh
341
           movzx edx, bl
341
           movzx edx, bl
342
           mov [eax+CURSOR.hot_x], ecx
342
           mov [eax+CURSOR.hot_x], ecx
343
           mov [eax+CURSOR.hot_y], edx
343
           mov [eax+CURSOR.hot_y], edx
344
 
344
 
345
           xchg edi, eax
345
           xchg edi, eax
346
           mov ecx, 1024
346
           mov ecx, 1024
347
           cld
347
           cld
348
           rep movsd
348
           rep movsd
349
           add esp, 12
349
           add esp, 12
350
           ret
350
           ret
351
 
351
 
352
align 4
352
align 4
353
proc load_cursor stdcall, src:dword, flags:dword
353
proc load_cursor stdcall, src:dword, flags:dword
354
           locals
354
           locals
355
             handle  dd ?
355
             handle  dd ?
356
           endl
356
           endl
357
 
357
 
358
           xor eax, eax
358
           xor eax, eax
359
           cmp [create_cursor], eax
359
           cmp [create_cursor], eax
360
           je .fail2
360
           je .fail2
361
 
361
 
362
           mov [handle], eax
362
           mov [handle], eax
363
           cmp word [flags], LOAD_FROM_FILE
363
           cmp word [flags], LOAD_FROM_FILE
364
           jne @F
364
           jne @F
365
 
365
 
366
           stdcall load_file, [src]
366
           stdcall load_file, [src]
367
           test eax, eax
367
           test eax, eax
368
           jz .fail
368
           jz .fail
369
           mov [src], eax
369
           mov [src], eax
370
@@:
370
@@:
371
           push ebx
371
           push ebx
372
           push esi
372
           push esi
373
           push edi
373
           push edi
374
 
374
 
375
           mov eax, [CURRENT_TASK]
375
           mov eax, [CURRENT_TASK]
376
           shl eax, 5
376
           shl eax, 5
377
           mov eax, [CURRENT_TASK+eax+4]
377
           mov eax, [CURRENT_TASK+eax+4]
378
           mov ebx, [src]
378
           mov ebx, [src]
379
           mov ecx, [flags]
379
           mov ecx, [flags]
380
           call [create_cursor]    ;eax, ebx, ecx
380
           call [create_cursor]    ;eax, ebx, ecx
381
           mov [handle], eax
381
           mov [handle], eax
382
 
382
 
383
           cmp word [flags], LOAD_FROM_FILE
383
           cmp word [flags], LOAD_FROM_FILE
384
           jne .exit
384
           jne .exit
385
           stdcall kernel_free, [src]
385
           stdcall kernel_free, [src]
386
.exit:
386
.exit:
387
           pop edi
387
           pop edi
388
           pop esi
388
           pop esi
389
           pop ebx
389
           pop ebx
390
.fail:
390
.fail:
391
           mov eax, [handle]
391
           mov eax, [handle]
392
.fail2:
392
.fail2:
393
           ret
393
           ret
394
endp
394
endp
395
 
395
 
396
align 4
396
align 4
397
proc delete_cursor stdcall, hcursor:dword
397
proc delete_cursor stdcall, hcursor:dword
398
           locals
398
           locals
399
             hsrv       dd ?
399
             hsrv       dd ?
400
             io_code    dd ?
400
             io_code    dd ?
401
             input      dd ?
401
             input      dd ?
402
             inp_size   dd ?
402
             inp_size   dd ?
403
             output     dd ?
403
             output     dd ?
404
             out_size   dd ?
404
             out_size   dd ?
405
           endl
405
           endl
406
 
406
 
407
           mov esi, [hcursor]
407
           mov esi, [hcursor]
408
           cmp [esi+CURSOR.magic], 'CURS'
408
           cmp [esi+CURSOR.magic], 'CURS'
409
           jne .fail
409
           jne .fail
410
;           cmp [esi+CURSOR.size], CURSOR_SIZE
410
;           cmp [esi+CURSOR.size], CURSOR_SIZE
411
;           jne .fail
411
;           jne .fail
412
 
412
 
413
           mov ebx, [CURRENT_TASK]
413
           mov ebx, [CURRENT_TASK]
414
           shl ebx, 5
414
           shl ebx, 5
415
           mov ebx, [CURRENT_TASK+ebx+4]
415
           mov ebx, [CURRENT_TASK+ebx+4]
416
           cmp ebx, [esi+CURSOR.pid]
416
           cmp ebx, [esi+CURSOR.pid]
417
           jne .fail
417
           jne .fail
418
 
418
 
419
           mov ebx, [current_slot]
419
           mov ebx, [current_slot]
420
           cmp esi, [ebx+APPDATA.cursor]
420
           cmp esi, [ebx+APPDATA.cursor]
421
           jne @F
421
           jne @F
422
           mov eax, [def_cursor]
422
           mov eax, [def_cursor]
423
           mov [ebx+APPDATA.cursor], eax
423
           mov [ebx+APPDATA.cursor], eax
424
@@:
424
@@:
425
           mov eax, [hcursor]
425
           mov eax, [hcursor]
426
           call [eax+APPOBJ.destroy]
426
           call [eax+APPOBJ.destroy]
427
.fail:
427
.fail:
428
           ret
428
           ret
429
endp
429
endp
430
 
430
 
431
; param
431
; param
432
;  eax= cursor
432
;  eax= cursor
433
 
433
 
434
align 4
434
align 4
435
destroy_cursor:
435
destroy_cursor:
436
 
436
 
437
           push eax
437
           push eax
438
           stdcall kernel_free, [eax+CURSOR.base]
438
           stdcall kernel_free, [eax+CURSOR.base]
439
           pop eax
439
           pop eax
440
 
440
 
441
           call destroy_kernel_object
441
           call destroy_kernel_object
442
           ret
442
           ret
443
 
443
 
444
align 4
444
align 4
445
select_cursor:
445
select_cursor:
446
 
446
 
447
           ret 4
447
           ret 4
448
 
448
 
449
align 4
449
align 4
450
proc init_cursors
450
proc init_cursors
451
 
451
 
452
           cmp [SCR_MODE],word 0x13
452
           cmp [SCR_MODE],word 0x13
453
           jbe .fail
453
           jbe .fail
454
 
454
 
455
           test word [SCR_MODE], 0x4000
455
           test word [SCR_MODE], 0x4000
456
           jz .fail
456
           jz .fail
457
 
457
 
458
           movzx eax, byte [ScreenBPP]
458
           movzx eax, byte [ScreenBPP]
459
           mov ebx, [BytesPerScanLine]
459
           mov ebx, [BytesPerScanLine]
460
           cmp eax, 32
460
           cmp eax, 32
461
           jne @F
461
           jne @F
462
           sub ebx, 128
462
           sub ebx, 128
463
           jmp .init
463
           jmp .init
464
@@:
464
@@:
465
           cmp eax, 24
465
           cmp eax, 24
466
           jne .fail
466
           jne .fail
467
           sub ebx, 96
467
           sub ebx, 96
468
.init:
468
.init:
469
           mov [cur_def_interl], ebx
469
           mov [cur_def_interl], ebx
470
 
470
 
471
           stdcall load_driver, szHwMouse
471
           stdcall load_driver, szHwMouse
472
           mov [hw_cursor], eax
472
           mov [hw_cursor], eax
473
           test eax, eax
473
           test eax, eax
474
           jz .sw_mouse
474
           jz .sw_mouse
475
 
475
 
476
           stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
476
           stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
477
           mov [def_cursor], eax
477
           mov [def_cursor], eax
478
           ret
478
           ret
479
.sw_mouse:
479
.sw_mouse:
480
           mov [create_cursor], vesa_cursor
480
           mov [create_cursor], vesa_cursor
481
 
481
 
482
           stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
482
           stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
483
           mov [def_cursor], eax
483
           mov [def_cursor], eax
484
 
484
 
485
           mov ecx, [Screen_Max_X]
485
           mov ecx, [Screen_Max_X]
486
           mov edx, [Screen_Max_Y]
486
           mov edx, [Screen_Max_Y]
487
           inc ecx
487
           inc ecx
488
           inc edx
488
           inc edx
489
           mov [scr_width], ecx
489
           mov [scr_width], ecx
490
           mov [scr_height], edx
490
           mov [scr_height], edx
491
 
491
 
492
           movzx ebx, byte [ScreenBPP]
492
           movzx ebx, byte [ScreenBPP]
493
           cmp ebx, 32
493
           cmp ebx, 32
494
           jne @F
494
           jne @F
495
 
495
 
496
 
496
 
497
           mov dword [select_hw_cursor], select_cursor
497
           mov dword [select_hw_cursor], select_cursor
498
           mov dword [set_hw_cursor], cursor_32
498
           mov dword [set_hw_cursor], cursor_32
499
           mov dword [hw_restore], restore_32
499
           mov dword [hw_restore], restore_32
500
           ret
500
           ret
501
@@:
501
@@:
502
           mov dword [select_hw_cursor], select_cursor
502
           mov dword [select_hw_cursor], select_cursor
503
           mov dword [set_hw_cursor], cursor_24
503
           mov dword [set_hw_cursor], cursor_24
504
           mov dword [hw_restore], restore_24
504
           mov dword [hw_restore], restore_24
505
           ret
505
           ret
506
.fail:
506
.fail:
507
           xor eax, eax
507
           xor eax, eax
508
           mov dword [select_hw_cursor], eax
508
           mov dword [select_hw_cursor], eax
509
           mov dword [set_hw_cursor], eax
509
           mov dword [set_hw_cursor], eax
510
           mov dword [hw_restore], eax
510
           mov dword [hw_restore], eax
511
           ret
511
           ret
512
endp
512
endp
513
 
513
 
514
align 4
514
align 4
515
proc restore_24 stdcall, x:dword, y:dword
515
proc restore_24 stdcall, x:dword, y:dword
516
           locals
516
           locals
517
             w  dd ?
517
             w  dd ?
518
           endl
518
           endl
519
 
519
 
520
           mov edi, [cur_saved_base]
520
           mov edi, [cur_saved_base]
521
           mov edx, [cur_saved_h]
521
           mov edx, [cur_saved_h]
522
           mov ebx, [cur_saved_interl]
522
           mov ebx, [cur_saved_interl]
523
           test edx, edx
523
           test edx, edx
524
           jz  .ret
524
           jz  .ret
525
 
525
 
526
           mov esi, cur_saved_data
526
           mov esi, cur_saved_data
527
@@:
527
@@:
528
           mov ecx, [cur_saved_w]
528
           mov ecx, [cur_saved_w]
529
           lea ecx, [ecx+ecx*2]
529
           lea ecx, [ecx+ecx*2]
530
           rep movsb
530
           rep movsb
531
           add edi, ebx
531
           add edi, ebx
532
           dec edx
532
           dec edx
533
           jnz @B
533
           jnz @B
534
.ret:
534
.ret:
535
           ret
535
           ret
536
endp
536
endp
537
 
537
 
538
align 4
538
align 4
539
proc restore_32 stdcall, x:dword, y:dword
539
proc restore_32 stdcall, x:dword, y:dword
540
           locals
540
           locals
541
             w  dd ?
541
             w  dd ?
542
           endl
542
           endl
543
 
543
 
544
           mov edi, [cur_saved_base]
544
           mov edi, [cur_saved_base]
545
           mov edx, [cur_saved_h]
545
           mov edx, [cur_saved_h]
546
           mov ebx, [cur_saved_interl]
546
           mov ebx, [cur_saved_interl]
547
           test edx, edx
547
           test edx, edx
548
           jz  .ret
548
           jz  .ret
549
 
549
 
550
           mov esi, cur_saved_data
550
           mov esi, cur_saved_data
551
@@:
551
@@:
552
           mov ecx, [cur_saved_w]
552
           mov ecx, [cur_saved_w]
553
           rep movsd
553
           rep movsd
554
           add edi, ebx
554
           add edi, ebx
555
           dec edx
555
           dec edx
556
           jnz @B
556
           jnz @B
557
.ret:
557
.ret:
558
           ret
558
           ret
559
endp
559
endp
560
 
560
 
561
align 4
561
align 4
562
proc cursor_24 stdcall, hcursor:dword, x:dword, y:dword
562
proc cursor_24 stdcall, hcursor:dword, x:dword, y:dword
563
           locals
563
           locals
564
             w      dd ?
564
             w      dd ?
565
             h      dd ?
565
             h      dd ?
566
             st     dd ?
566
             st     dd ?
567
             _dx     dd ?
567
             _dx     dd ?
568
             _dy     dd ?
568
             _dy     dd ?
569
           endl
569
           endl
570
 
570
 
571
           mov esi, [hcursor]
571
           mov esi, [hcursor]
572
           mov ecx, [x]
572
           mov ecx, [x]
573
           mov eax, [y]
573
           mov eax, [y]
574
           mov ebx, [BytesPerScanLine]
574
           mov ebx, [BytesPerScanLine]
575
 
575
 
576
           xor edx, edx
576
           xor edx, edx
577
           sub ecx, [esi+CURSOR.hot_x]
577
           sub ecx, [esi+CURSOR.hot_x]
578
           mov [x], ecx
578
           mov [x], ecx
579
           sets dl
579
           sets dl
580
           dec edx
580
           dec edx
581
           and ecx, edx       ;clip x to 0<=x
581
           and ecx, edx       ;clip x to 0<=x
582
           mov edi, ecx
582
           mov edi, ecx
583
           sub edi, [x]
583
           sub edi, [x]
584
           mov [_dx], edi
584
           mov [_dx], edi
585
 
585
 
586
           xor edx, edx
586
           xor edx, edx
587
           sub eax, [esi+CURSOR.hot_y]
587
           sub eax, [esi+CURSOR.hot_y]
588
           mov [y], eax
588
           mov [y], eax
589
           sets dl
589
           sets dl
590
           dec edx
590
           dec edx
591
           and eax, edx       ;clip y to 0<=y
591
           and eax, edx       ;clip y to 0<=y
592
           mov edi, eax
592
           mov edi, eax
593
           sub edi, [y]
593
           sub edi, [y]
594
           mov [_dy], edi
594
           mov [_dy], edi
595
 
595
 
596
           mul ebx
596
           mul ebx
597
           lea esi, [ecx+ecx*2]
597
           lea esi, [ecx+ecx*2]
598
           add esi, [LFBAddress]
598
           add esi, [LFBAddress]
599
           add esi, eax
599
           add esi, eax
600
           mov [cur_saved_base],esi
600
           mov [cur_saved_base],esi
601
 
601
 
602
           mov edi, [scr_width]
602
           mov edi, [scr_width]
603
           mov edx, [scr_height]
603
           mov edx, [scr_height]
604
           mov eax, 32
604
           mov eax, 32
605
 
605
 
606
           sub edi, ecx
606
           sub edi, ecx
607
           cmp edi, eax
607
           cmp edi, eax
608
           jng @F
608
           jng @F
609
           mov edi, eax
609
           mov edi, eax
610
@@:
610
@@:
611
           sub edi, [_dx]
611
           sub edi, [_dx]
612
 
612
 
613
           sub edx, [y]
613
           sub edx, [y]
614
           cmp edx, eax
614
           cmp edx, eax
615
           jng @F
615
           jng @F
616
           mov edx, eax
616
           mov edx, eax
617
@@:
617
@@:
618
           sub edx, [_dy]
618
           sub edx, [_dy]
619
 
619
 
620
           mov [w], edi
620
           mov [w], edi
621
           mov [h], edx
621
           mov [h], edx
622
           mov [cur_saved_w], edi
622
           mov [cur_saved_w], edi
623
           mov [cur_saved_h], edx
623
           mov [cur_saved_h], edx
624
 
624
 
625
           sub eax, edi
625
           sub eax, edi
626
           shl eax, 2       ;lea eax, [eax+eax*2]
626
           shl eax, 2       ;lea eax, [eax+eax*2]
627
           lea edi, [edi+edi*2]
627
           lea edi, [edi+edi*2]
628
           sub ebx, edi
628
           sub ebx, edi
629
           mov [cur_saved_interl], ebx
629
           mov [cur_saved_interl], ebx
630
 
630
 
631
           mov edi, cur_saved_data
631
           mov edi, cur_saved_data
632
@@:
632
@@:
633
           mov ecx, [w]
633
           mov ecx, [w]
634
           lea ecx, [ecx+ecx*2]
634
           lea ecx, [ecx+ecx*2]
635
           rep movsb
635
           rep movsb
636
           add esi, ebx
636
           add esi, ebx
637
           dec edx
637
           dec edx
638
           jnz @B
638
           jnz @B
639
 
639
 
640
;draw cursor
640
;draw cursor
641
           mov edx, eax
641
           mov edx, eax
642
           mov edi, [cur_saved_base]
642
           mov edi, [cur_saved_base]
643
           mov eax, [_dy]
643
           mov eax, [_dy]
644
           shl eax, 5
644
           shl eax, 5
645
           add eax, [_dx]
645
           add eax, [_dx]
646
           shl eax, 2
646
           shl eax, 2
647
 
647
 
648
           mov esi, [hcursor]
648
           mov esi, [hcursor]
649
           mov esi, [esi+CURSOR.base]
649
           mov esi, [esi+CURSOR.base]
650
           add esi, eax
650
           add esi, eax
651
.row:
651
.row:
652
           mov ecx, [w]
652
           mov ecx, [w]
653
.pix:
653
.pix:
654
           lodsd
654
           lodsd
655
           test eax, 0xFF000000
655
           test eax, 0xFF000000
656
           jz @F
656
           jz @F
657
 
657
 
658
           mov word [edi], ax
658
           mov word [edi], ax
659
           shr eax, 16
659
           shr eax, 16
660
           mov [edi+2],al
660
           mov [edi+2],al
661
@@:
661
@@:
662
           add edi, 3
662
           add edi, 3
663
           dec ecx
663
           dec ecx
664
           jnz .pix
664
           jnz .pix
665
 
665
 
666
           add esi, edx
666
           add esi, edx
667
           add edi, ebx
667
           add edi, ebx
668
           dec [h]
668
           dec [h]
669
           jnz .row
669
           jnz .row
670
           ret
670
           ret
671
endp
671
endp
672
 
672
 
673
align 4
673
align 4
674
proc cursor_32 stdcall, hcursor:dword, x:dword, y:dword
674
proc cursor_32 stdcall, hcursor:dword, x:dword, y:dword
675
           locals
675
           locals
676
             w      dd ?
676
             w      dd ?
677
             h      dd ?
677
             h      dd ?
678
             st     dd ?
678
             st     dd ?
679
             _dx     dd ?
679
             _dx     dd ?
680
             _dy     dd ?
680
             _dy     dd ?
681
           endl
681
           endl
682
 
682
 
683
           mov esi, [hcursor]
683
           mov esi, [hcursor]
684
           mov ecx, [x]
684
           mov ecx, [x]
685
           mov eax, [y]
685
           mov eax, [y]
686
           mov ebx, [BytesPerScanLine]
686
           mov ebx, [BytesPerScanLine]
687
 
687
 
688
           xor edx, edx
688
           xor edx, edx
689
           sub ecx, [esi+CURSOR.hot_x]
689
           sub ecx, [esi+CURSOR.hot_x]
690
           mov [x], ecx
690
           mov [x], ecx
691
           sets dl
691
           sets dl
692
           dec edx
692
           dec edx
693
           and ecx, edx       ;clip x to 0<=x
693
           and ecx, edx       ;clip x to 0<=x
694
           mov edi, ecx
694
           mov edi, ecx
695
           sub edi, [x]
695
           sub edi, [x]
696
           mov [_dx], edi
696
           mov [_dx], edi
697
 
697
 
698
           xor edx, edx
698
           xor edx, edx
699
           sub eax, [esi+CURSOR.hot_y]
699
           sub eax, [esi+CURSOR.hot_y]
700
           mov [y], eax
700
           mov [y], eax
701
           sets dl
701
           sets dl
702
           dec edx
702
           dec edx
703
           and eax, edx       ;clip y to 0<=y
703
           and eax, edx       ;clip y to 0<=y
704
           mov edi, eax
704
           mov edi, eax
705
           sub edi, [y]
705
           sub edi, [y]
706
           mov [_dy], edi
706
           mov [_dy], edi
707
 
707
 
708
           mul ebx
708
           mul ebx
709
           lea esi, [eax+ecx*4]
709
           lea esi, [eax+ecx*4]
710
           add esi, [LFBAddress]
710
           add esi, [LFBAddress]
711
           mov [cur_saved_base],esi
711
           mov [cur_saved_base],esi
712
 
712
 
713
           mov edi, [scr_width]
713
           mov edi, [scr_width]
714
           mov edx, [scr_height]
714
           mov edx, [scr_height]
715
           mov eax, 32
715
           mov eax, 32
716
 
716
 
717
           sub edi, ecx
717
           sub edi, ecx
718
           cmp edi, eax
718
           cmp edi, eax
719
           jng @F
719
           jng @F
720
           mov edi, eax
720
           mov edi, eax
721
@@:
721
@@:
722
           sub edi, [_dx]
722
           sub edi, [_dx]
723
 
723
 
724
           sub edx, [y]
724
           sub edx, [y]
725
           cmp edx, eax
725
           cmp edx, eax
726
           jng @F
726
           jng @F
727
           mov edx, eax
727
           mov edx, eax
728
@@:
728
@@:
729
           sub edx, [_dy]
729
           sub edx, [_dy]
730
 
730
 
731
           mov [w], edi
731
           mov [w], edi
732
           mov [h], edx
732
           mov [h], edx
733
           mov [cur_saved_w], edi
733
           mov [cur_saved_w], edi
734
           mov [cur_saved_h], edx
734
           mov [cur_saved_h], edx
735
 
735
 
736
           sub eax, edi
736
           sub eax, edi
737
           shl eax, 2
737
           shl eax, 2
738
           shl edi, 2
738
           shl edi, 2
739
           sub ebx, edi
739
           sub ebx, edi
740
           mov [cur_saved_interl], ebx
740
           mov [cur_saved_interl], ebx
741
 
741
 
742
           mov edi, cur_saved_data
742
           mov edi, cur_saved_data
743
@@:
743
@@:
744
           mov ecx, [w]
744
           mov ecx, [w]
745
           rep movsd
745
           rep movsd
746
           add esi, ebx
746
           add esi, ebx
747
           dec edx
747
           dec edx
748
           jnz @B
748
           jnz @B
749
 
749
 
750
;draw cursor
750
;draw cursor
751
           mov edx, eax
751
           mov edx, eax
752
           mov edi, [cur_saved_base]
752
           mov edi, [cur_saved_base]
753
           mov eax, [_dy]
753
           mov eax, [_dy]
754
           shl eax, 5
754
           shl eax, 5
755
           add eax, [_dx]
755
           add eax, [_dx]
756
           shl eax, 2
756
           shl eax, 2
757
 
757
 
758
           mov esi, [hcursor]
758
           mov esi, [hcursor]
759
           mov esi, [esi+CURSOR.base]
759
           mov esi, [esi+CURSOR.base]
760
           add esi, eax
760
           add esi, eax
761
.row:
761
.row:
762
           mov ecx, [w]
762
           mov ecx, [w]
763
.pix:
763
.pix:
764
           lodsd
764
           lodsd
765
           test eax, 0xFF000000
765
           test eax, 0xFF000000
766
           jz @F
766
           jz @F
767
           mov [edi], eax
767
           mov [edi], eax
768
@@:
768
@@:
769
           add edi, 4
769
           add edi, 4
770
           dec ecx
770
           dec ecx
771
           jnz .pix
771
           jnz .pix
772
           add esi, edx
772
           add esi, edx
773
           add edi, ebx
773
           add edi, ebx
774
           dec [h]
774
           dec [h]
775
           jnz .row
775
           jnz .row
776
           ret
776
           ret
777
endp
777
endp
778
 
778
 
779
align 4
779
align 4
780
def_arrow:
780
def_arrow:
781
  file 'arrow.cur'
781
  file 'arrow.cur'
782
>
782
>
783
>
783
>
784
>
784
>
785
>
785
>