Subversion Repositories Kolibri OS

Rev

Rev 996 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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