Subversion Repositories Kolibri OS

Rev

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

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