Subversion Repositories Kolibri OS

Rev

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

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