Subversion Repositories Kolibri OS

Rev

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

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