Subversion Repositories Kolibri OS

Rev

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

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