Subversion Repositories Kolibri OS

Rev

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

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