Subversion Repositories Kolibri OS

Rev

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

Rev 662 Rev 673
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2007. 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: 662 $
8
$Revision: 673 $
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
           mov [handle], eax
359
           mov [handle], eax
360
           cmp word [flags], LOAD_FROM_FILE
360
           cmp word [flags], LOAD_FROM_FILE
361
           jne @F
361
           jne @F
362
 
362
 
363
           stdcall load_file, [src]
363
           stdcall load_file, [src]
364
           test eax, eax
364
           test eax, eax
365
           jz .fail
365
           jz .fail
366
           mov [src], eax
366
           mov [src], eax
367
@@:
367
@@:
368
           push ebx
368
           push ebx
369
           push esi
369
           push esi
370
           push edi
370
           push edi
371
 
371
 
372
           mov eax, [CURRENT_TASK]
372
           mov eax, [CURRENT_TASK]
373
           shl eax, 5
373
           shl eax, 5
374
           mov eax, [CURRENT_TASK+eax+4]
374
           mov eax, [CURRENT_TASK+eax+4]
375
           mov ebx, [src]
375
           mov ebx, [src]
376
           mov ecx, [flags]
376
           mov ecx, [flags]
377
           call [create_cursor]    ;eax, ebx, ecx
377
           call [create_cursor]    ;eax, ebx, ecx
378
           mov [handle], eax
378
           mov [handle], eax
379
 
379
 
380
           cmp word [flags], LOAD_FROM_FILE
380
           cmp word [flags], LOAD_FROM_FILE
381
           jne .exit
381
           jne .exit
382
           stdcall kernel_free, [src]
382
           stdcall kernel_free, [src]
383
.exit:
383
.exit:
384
           pop edi
384
           pop edi
385
           pop esi
385
           pop esi
386
           pop ebx
386
           pop ebx
387
.fail:
387
.fail:
388
           mov eax, [handle]
388
           mov eax, [handle]
389
           ret
389
           ret
390
endp
390
endp
391
 
391
 
392
align 4
392
align 4
393
proc delete_cursor stdcall, hcursor:dword
393
proc delete_cursor stdcall, hcursor:dword
394
           locals
394
           locals
395
             hsrv       dd ?
395
             hsrv       dd ?
396
             io_code    dd ?
396
             io_code    dd ?
397
             input      dd ?
397
             input      dd ?
398
             inp_size   dd ?
398
             inp_size   dd ?
399
             output     dd ?
399
             output     dd ?
400
             out_size   dd ?
400
             out_size   dd ?
401
           endl
401
           endl
402
 
402
 
403
           mov esi, [hcursor]
403
           mov esi, [hcursor]
404
           cmp [esi+CURSOR.magic], 'CURS'
404
           cmp [esi+CURSOR.magic], 'CURS'
405
           jne .fail
405
           jne .fail
406
;           cmp [esi+CURSOR.size], CURSOR_SIZE
406
;           cmp [esi+CURSOR.size], CURSOR_SIZE
407
;           jne .fail
407
;           jne .fail
408
 
408
 
409
           mov ebx, [CURRENT_TASK]
409
           mov ebx, [CURRENT_TASK]
410
           shl ebx, 5
410
           shl ebx, 5
411
           mov ebx, [CURRENT_TASK+ebx+4]
411
           mov ebx, [CURRENT_TASK+ebx+4]
412
           cmp ebx, [esi+CURSOR.pid]
412
           cmp ebx, [esi+CURSOR.pid]
413
           jne .fail
413
           jne .fail
414
 
414
 
415
           mov ebx, [current_slot]
415
           mov ebx, [current_slot]
416
           cmp esi, [ebx+APPDATA.cursor]
416
           cmp esi, [ebx+APPDATA.cursor]
417
           jne @F
417
           jne @F
418
           mov eax, [def_cursor]
418
           mov eax, [def_cursor]
419
           mov [ebx+APPDATA.cursor], eax
419
           mov [ebx+APPDATA.cursor], eax
420
@@:
420
@@:
421
           mov eax, [hcursor]
421
           mov eax, [hcursor]
422
           call [eax+APPOBJ.destroy]
422
           call [eax+APPOBJ.destroy]
423
.fail:
423
.fail:
424
           ret
424
           ret
425
endp
425
endp
426
 
426
 
427
; param
427
; param
428
;  eax= cursor
428
;  eax= cursor
429
 
429
 
430
align 4
430
align 4
431
destroy_cursor:
431
destroy_cursor:
432
 
432
 
433
           push eax
433
           push eax
434
           stdcall kernel_free, [eax+CURSOR.base]
434
           stdcall kernel_free, [eax+CURSOR.base]
435
           pop eax
435
           pop eax
436
 
436
 
437
           call destroy_kernel_object
437
           call destroy_kernel_object
438
           ret
438
           ret
439
 
439
 
440
align 4
440
align 4
441
select_cursor:
441
select_cursor:
442
 
442
 
443
           ret 4
443
           ret 4
444
 
444
 
445
align 4
445
align 4
446
proc init_cursors
446
proc init_cursors
-
 
447
 
447
           cmp [SCR_MODE],word 0x13
448
           cmp [SCR_MODE],word 0x13
448
           jbe .fail
449
           jbe .fail
-
 
450
 
-
 
451
           test word [SCR_MODE], 0x4000
-
 
452
           jz .fail
449
 
453
 
450
           movzx eax, byte [ScreenBPP]
454
           movzx eax, byte [ScreenBPP]
451
           mov ebx, [BytesPerScanLine]
455
           mov ebx, [BytesPerScanLine]
452
           cmp eax, 32
456
           cmp eax, 32
453
           jne @F
457
           jne @F
454
           sub ebx, 128
458
           sub ebx, 128
455
           jmp .init
459
           jmp .init
456
@@:
460
@@:
457
           cmp eax, 24
461
           cmp eax, 24
458
           jne .fail
462
           jne .fail
459
           sub ebx, 96
463
           sub ebx, 96
460
.init:
464
.init:
461
           mov [cur_def_interl], ebx
465
           mov [cur_def_interl], ebx
462
 
466
 
463
           stdcall load_driver, szHwMouse
467
           stdcall load_driver, szHwMouse
464
           mov [hw_cursor], eax
468
           mov [hw_cursor], eax
465
           test eax, eax
469
           test eax, eax
466
           jz .sw_mouse
470
           jz .sw_mouse
467
 
471
 
468
           stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
472
           stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
469
           mov [def_cursor], eax
473
           mov [def_cursor], eax
470
           ret
474
           ret
471
.sw_mouse:
475
.sw_mouse:
472
           mov [create_cursor], vesa_cursor
476
           mov [create_cursor], vesa_cursor
473
 
477
 
474
           stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
478
           stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
475
           mov [def_cursor], eax
479
           mov [def_cursor], eax
476
 
480
 
477
           mov ecx, [ScreenWidth]
481
           mov ecx, [ScreenWidth]
478
           mov edx, [ScreenHeight]
482
           mov edx, [ScreenHeight]
479
           inc ecx
483
           inc ecx
480
           inc edx
484
           inc edx
481
           mov [scr_width], ecx
485
           mov [scr_width], ecx
482
           mov [scr_height], edx
486
           mov [scr_height], edx
483
 
487
 
484
           movzx ebx, byte [ScreenBPP]
488
           movzx ebx, byte [ScreenBPP]
485
           cmp ebx, 32
489
           cmp ebx, 32
486
           jne @F
490
           jne @F
487
 
491
 
488
 
492
 
489
           mov dword [select_hw_cursor], select_cursor
493
           mov dword [select_hw_cursor], select_cursor
490
           mov dword [set_hw_cursor], cursor_32
494
           mov dword [set_hw_cursor], cursor_32
491
           mov dword [hw_restore], restore_32
495
           mov dword [hw_restore], restore_32
492
           ret
496
           ret
493
@@:
497
@@:
494
           mov dword [select_hw_cursor], select_cursor
498
           mov dword [select_hw_cursor], select_cursor
495
           mov dword [set_hw_cursor], cursor_24
499
           mov dword [set_hw_cursor], cursor_24
496
           mov dword [hw_restore], restore_24
500
           mov dword [hw_restore], restore_24
497
           ret
501
           ret
498
.fail:
502
.fail:
499
           xor eax, eax
503
           xor eax, eax
500
           mov dword [select_hw_cursor], eax
504
           mov dword [select_hw_cursor], eax
501
           mov dword [set_hw_cursor], eax
505
           mov dword [set_hw_cursor], eax
502
           mov dword [hw_restore], eax
506
           mov dword [hw_restore], eax
503
           ret
507
           ret
504
endp
508
endp
505
 
509
 
506
align 4
510
align 4
507
proc restore_24 stdcall, x:dword, y:dword
511
proc restore_24 stdcall, x:dword, y:dword
508
           locals
512
           locals
509
             w  dd ?
513
             w  dd ?
510
           endl
514
           endl
511
 
515
 
512
           mov edi, [cur_saved_base]
516
           mov edi, [cur_saved_base]
513
           mov edx, [cur_saved_h]
517
           mov edx, [cur_saved_h]
514
           mov ebx, [cur_saved_interl]
518
           mov ebx, [cur_saved_interl]
515
           test edx, edx
519
           test edx, edx
516
           jz  .ret
520
           jz  .ret
517
 
521
 
518
           mov esi, cur_saved_data
522
           mov esi, cur_saved_data
519
@@:
523
@@:
520
           mov ecx, [cur_saved_w]
524
           mov ecx, [cur_saved_w]
521
           lea ecx, [ecx+ecx*2]
525
           lea ecx, [ecx+ecx*2]
522
           rep movsb
526
           rep movsb
523
           add edi, ebx
527
           add edi, ebx
524
           dec edx
528
           dec edx
525
           jnz @B
529
           jnz @B
526
.ret:
530
.ret:
527
           ret
531
           ret
528
endp
532
endp
529
 
533
 
530
align 4
534
align 4
531
proc restore_32 stdcall, x:dword, y:dword
535
proc restore_32 stdcall, x:dword, y:dword
532
           locals
536
           locals
533
             w  dd ?
537
             w  dd ?
534
           endl
538
           endl
535
 
539
 
536
           mov edi, [cur_saved_base]
540
           mov edi, [cur_saved_base]
537
           mov edx, [cur_saved_h]
541
           mov edx, [cur_saved_h]
538
           mov ebx, [cur_saved_interl]
542
           mov ebx, [cur_saved_interl]
539
           test edx, edx
543
           test edx, edx
540
           jz  .ret
544
           jz  .ret
541
 
545
 
542
           mov esi, cur_saved_data
546
           mov esi, cur_saved_data
543
@@:
547
@@:
544
           mov ecx, [cur_saved_w]
548
           mov ecx, [cur_saved_w]
545
           rep movsd
549
           rep movsd
546
           add edi, ebx
550
           add edi, ebx
547
           dec edx
551
           dec edx
548
           jnz @B
552
           jnz @B
549
.ret:
553
.ret:
550
           ret
554
           ret
551
endp
555
endp
552
 
556
 
553
align 4
557
align 4
554
proc cursor_24 stdcall, hcursor:dword, x:dword, y:dword
558
proc cursor_24 stdcall, hcursor:dword, x:dword, y:dword
555
           locals
559
           locals
556
             w      dd ?
560
             w      dd ?
557
             h      dd ?
561
             h      dd ?
558
             st     dd ?
562
             st     dd ?
559
             _dx     dd ?
563
             _dx     dd ?
560
             _dy     dd ?
564
             _dy     dd ?
561
           endl
565
           endl
562
 
566
 
563
           mov esi, [hcursor]
567
           mov esi, [hcursor]
564
           mov ecx, [x]
568
           mov ecx, [x]
565
           mov eax, [y]
569
           mov eax, [y]
566
           mov ebx, [BytesPerScanLine]
570
           mov ebx, [BytesPerScanLine]
567
 
571
 
568
           xor edx, edx
572
           xor edx, edx
569
           sub ecx, [esi+CURSOR.hot_x]
573
           sub ecx, [esi+CURSOR.hot_x]
570
           mov [x], ecx
574
           mov [x], ecx
571
           sets dl
575
           sets dl
572
           dec edx
576
           dec edx
573
           and ecx, edx       ;clip x to 0<=x
577
           and ecx, edx       ;clip x to 0<=x
574
           mov edi, ecx
578
           mov edi, ecx
575
           sub edi, [x]
579
           sub edi, [x]
576
           mov [_dx], edi
580
           mov [_dx], edi
577
 
581
 
578
           xor edx, edx
582
           xor edx, edx
579
           sub eax, [esi+CURSOR.hot_y]
583
           sub eax, [esi+CURSOR.hot_y]
580
           mov [y], eax
584
           mov [y], eax
581
           sets dl
585
           sets dl
582
           dec edx
586
           dec edx
583
           and eax, edx       ;clip y to 0<=y
587
           and eax, edx       ;clip y to 0<=y
584
           mov edi, eax
588
           mov edi, eax
585
           sub edi, [y]
589
           sub edi, [y]
586
           mov [_dy], edi
590
           mov [_dy], edi
587
 
591
 
588
           mul ebx
592
           mul ebx
589
           lea esi, [ecx+ecx*2]
593
           lea esi, [ecx+ecx*2]
590
           add esi, [LFBAddress]
594
           add esi, [LFBAddress]
591
           add esi, eax
595
           add esi, eax
592
           mov [cur_saved_base],esi
596
           mov [cur_saved_base],esi
593
 
597
 
594
           mov edi, [scr_width]
598
           mov edi, [scr_width]
595
           mov edx, [scr_height]
599
           mov edx, [scr_height]
596
           mov eax, 32
600
           mov eax, 32
597
 
601
 
598
           sub edi, ecx
602
           sub edi, ecx
599
           cmp edi, eax
603
           cmp edi, eax
600
           jng @F
604
           jng @F
601
           mov edi, eax
605
           mov edi, eax
602
@@:
606
@@:
603
           sub edi, [_dx]
607
           sub edi, [_dx]
604
 
608
 
605
           sub edx, [y]
609
           sub edx, [y]
606
           cmp edx, eax
610
           cmp edx, eax
607
           jng @F
611
           jng @F
608
           mov edx, eax
612
           mov edx, eax
609
@@:
613
@@:
610
           sub edx, [_dy]
614
           sub edx, [_dy]
611
 
615
 
612
           mov [w], edi
616
           mov [w], edi
613
           mov [h], edx
617
           mov [h], edx
614
           mov [cur_saved_w], edi
618
           mov [cur_saved_w], edi
615
           mov [cur_saved_h], edx
619
           mov [cur_saved_h], edx
616
 
620
 
617
           sub eax, edi
621
           sub eax, edi
618
           shl eax, 2       ;lea eax, [eax+eax*2]
622
           shl eax, 2       ;lea eax, [eax+eax*2]
619
           lea edi, [edi+edi*2]
623
           lea edi, [edi+edi*2]
620
           sub ebx, edi
624
           sub ebx, edi
621
           mov [cur_saved_interl], ebx
625
           mov [cur_saved_interl], ebx
622
 
626
 
623
           mov edi, cur_saved_data
627
           mov edi, cur_saved_data
624
@@:
628
@@:
625
           mov ecx, [w]
629
           mov ecx, [w]
626
           lea ecx, [ecx+ecx*2]
630
           lea ecx, [ecx+ecx*2]
627
           rep movsb
631
           rep movsb
628
           add esi, ebx
632
           add esi, ebx
629
           dec edx
633
           dec edx
630
           jnz @B
634
           jnz @B
631
 
635
 
632
;draw cursor
636
;draw cursor
633
           mov edx, eax
637
           mov edx, eax
634
           mov edi, [cur_saved_base]
638
           mov edi, [cur_saved_base]
635
           mov eax, [_dy]
639
           mov eax, [_dy]
636
           shl eax, 5
640
           shl eax, 5
637
           add eax, [_dx]
641
           add eax, [_dx]
638
           shl eax, 2
642
           shl eax, 2
639
 
643
 
640
           mov esi, [hcursor]
644
           mov esi, [hcursor]
641
           mov esi, [esi+CURSOR.base]
645
           mov esi, [esi+CURSOR.base]
642
           add esi, eax
646
           add esi, eax
643
.row:
647
.row:
644
           mov ecx, [w]
648
           mov ecx, [w]
645
.pix:
649
.pix:
646
           lodsd
650
           lodsd
647
           test eax, 0xFF000000
651
           test eax, 0xFF000000
648
           jz @F
652
           jz @F
649
 
653
 
650
           mov word [edi], ax
654
           mov word [edi], ax
651
           shr eax, 16
655
           shr eax, 16
652
           mov [edi+2],al
656
           mov [edi+2],al
653
@@:
657
@@:
654
           add edi, 3
658
           add edi, 3
655
           dec ecx
659
           dec ecx
656
           jnz .pix
660
           jnz .pix
657
 
661
 
658
           add esi, edx
662
           add esi, edx
659
           add edi, ebx
663
           add edi, ebx
660
           dec [h]
664
           dec [h]
661
           jnz .row
665
           jnz .row
662
           ret
666
           ret
663
endp
667
endp
664
 
668
 
665
align 4
669
align 4
666
proc cursor_32 stdcall, hcursor:dword, x:dword, y:dword
670
proc cursor_32 stdcall, hcursor:dword, x:dword, y:dword
667
           locals
671
           locals
668
             w      dd ?
672
             w      dd ?
669
             h      dd ?
673
             h      dd ?
670
             st     dd ?
674
             st     dd ?
671
             _dx     dd ?
675
             _dx     dd ?
672
             _dy     dd ?
676
             _dy     dd ?
673
           endl
677
           endl
674
 
678
 
675
           mov esi, [hcursor]
679
           mov esi, [hcursor]
676
           mov ecx, [x]
680
           mov ecx, [x]
677
           mov eax, [y]
681
           mov eax, [y]
678
           mov ebx, [BytesPerScanLine]
682
           mov ebx, [BytesPerScanLine]
679
 
683
 
680
           xor edx, edx
684
           xor edx, edx
681
           sub ecx, [esi+CURSOR.hot_x]
685
           sub ecx, [esi+CURSOR.hot_x]
682
           mov [x], ecx
686
           mov [x], ecx
683
           sets dl
687
           sets dl
684
           dec edx
688
           dec edx
685
           and ecx, edx       ;clip x to 0<=x
689
           and ecx, edx       ;clip x to 0<=x
686
           mov edi, ecx
690
           mov edi, ecx
687
           sub edi, [x]
691
           sub edi, [x]
688
           mov [_dx], edi
692
           mov [_dx], edi
689
 
693
 
690
           xor edx, edx
694
           xor edx, edx
691
           sub eax, [esi+CURSOR.hot_y]
695
           sub eax, [esi+CURSOR.hot_y]
692
           mov [y], eax
696
           mov [y], eax
693
           sets dl
697
           sets dl
694
           dec edx
698
           dec edx
695
           and eax, edx       ;clip y to 0<=y
699
           and eax, edx       ;clip y to 0<=y
696
           mov edi, eax
700
           mov edi, eax
697
           sub edi, [y]
701
           sub edi, [y]
698
           mov [_dy], edi
702
           mov [_dy], edi
699
 
703
 
700
           mul ebx
704
           mul ebx
701
           lea esi, [eax+ecx*4]
705
           lea esi, [eax+ecx*4]
702
           add esi, [LFBAddress]
706
           add esi, [LFBAddress]
703
           mov [cur_saved_base],esi
707
           mov [cur_saved_base],esi
704
 
708
 
705
           mov edi, [scr_width]
709
           mov edi, [scr_width]
706
           mov edx, [scr_height]
710
           mov edx, [scr_height]
707
           mov eax, 32
711
           mov eax, 32
708
 
712
 
709
           sub edi, ecx
713
           sub edi, ecx
710
           cmp edi, eax
714
           cmp edi, eax
711
           jng @F
715
           jng @F
712
           mov edi, eax
716
           mov edi, eax
713
@@:
717
@@:
714
           sub edi, [_dx]
718
           sub edi, [_dx]
715
 
719
 
716
           sub edx, [y]
720
           sub edx, [y]
717
           cmp edx, eax
721
           cmp edx, eax
718
           jng @F
722
           jng @F
719
           mov edx, eax
723
           mov edx, eax
720
@@:
724
@@:
721
           sub edx, [_dy]
725
           sub edx, [_dy]
722
 
726
 
723
           mov [w], edi
727
           mov [w], edi
724
           mov [h], edx
728
           mov [h], edx
725
           mov [cur_saved_w], edi
729
           mov [cur_saved_w], edi
726
           mov [cur_saved_h], edx
730
           mov [cur_saved_h], edx
727
 
731
 
728
           sub eax, edi
732
           sub eax, edi
729
           shl eax, 2
733
           shl eax, 2
730
           shl edi, 2
734
           shl edi, 2
731
           sub ebx, edi
735
           sub ebx, edi
732
           mov [cur_saved_interl], ebx
736
           mov [cur_saved_interl], ebx
733
 
737
 
734
           mov edi, cur_saved_data
738
           mov edi, cur_saved_data
735
@@:
739
@@:
736
           mov ecx, [w]
740
           mov ecx, [w]
737
           rep movsd
741
           rep movsd
738
           add esi, ebx
742
           add esi, ebx
739
           dec edx
743
           dec edx
740
           jnz @B
744
           jnz @B
741
 
745
 
742
;draw cursor
746
;draw cursor
743
           mov edx, eax
747
           mov edx, eax
744
           mov edi, [cur_saved_base]
748
           mov edi, [cur_saved_base]
745
           mov eax, [_dy]
749
           mov eax, [_dy]
746
           shl eax, 5
750
           shl eax, 5
747
           add eax, [_dx]
751
           add eax, [_dx]
748
           shl eax, 2
752
           shl eax, 2
749
 
753
 
750
           mov esi, [hcursor]
754
           mov esi, [hcursor]
751
           mov esi, [esi+CURSOR.base]
755
           mov esi, [esi+CURSOR.base]
752
           add esi, eax
756
           add esi, eax
753
.row:
757
.row:
754
           mov ecx, [w]
758
           mov ecx, [w]
755
.pix:
759
.pix:
756
           lodsd
760
           lodsd
757
           test eax, 0xFF000000
761
           test eax, 0xFF000000
758
           jz @F
762
           jz @F
759
           mov [edi], eax
763
           mov [edi], eax
760
@@:
764
@@:
761
           add edi, 4
765
           add edi, 4
762
           dec ecx
766
           dec ecx
763
           jnz .pix
767
           jnz .pix
764
           add esi, edx
768
           add esi, edx
765
           add edi, ebx
769
           add edi, ebx
766
           dec [h]
770
           dec [h]
767
           jnz .row
771
           jnz .row
768
           ret
772
           ret
769
endp
773
endp
770
 
774
 
771
align 4
775
align 4
772
def_arrow:
776
def_arrow:
773
  file 'arrow.cur'
777
  file 'arrow.cur'
774
>
778
>
775
>
779
>
776
>
780
>
777
>
781
>