Subversion Repositories Kolibri OS

Rev

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

Rev 4288 Rev 4423
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2012. 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: 4288 $
8
$Revision: 4423 $
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
struct  BITMAPINFOHEADER
16
struct  BITMAPINFOHEADER
17
        Size                    dd ?
17
        Size                    dd ?
18
        Width                   dd ?
18
        Width                   dd ?
19
        Height                  dd ?
19
        Height                  dd ?
20
        Planes                  dw ?
20
        Planes                  dw ?
21
        BitCount                dw ?
21
        BitCount                dw ?
22
        Compression             dd ?
22
        Compression             dd ?
23
        SizeImage               dd ?
23
        SizeImage               dd ?
24
        XPelsPerMeter           dd ?
24
        XPelsPerMeter           dd ?
25
        YPelsPerMeter           dd ?
25
        YPelsPerMeter           dd ?
26
        ClrUsed                 dd ?
26
        ClrUsed                 dd ?
27
        ClrImportant            dd ?
27
        ClrImportant            dd ?
28
ends
28
ends
29
;------------------------------------------------------------------------------
29
;------------------------------------------------------------------------------
30
align 4
30
align 4
31
proc init_cursor stdcall, dst:dword, src:dword
31
proc init_cursor stdcall, dst:dword, src:dword
32
           locals
32
           locals
33
             rBase    dd ?
33
             rBase    dd ?
34
             pQuad    dd ?
34
             pQuad    dd ?
35
             pBits    dd ?
35
             pBits    dd ?
36
             pAnd     dd ?
36
             pAnd     dd ?
37
             width    dd ?
37
             width    dd ?
38
             height   dd ?
38
             height   dd ?
39
             counter  dd ?
39
             counter  dd ?
40
           endl
40
           endl
41
 
41
 
42
        mov     esi, [src]
42
        mov     esi, [src]
43
        add     esi, [esi+18]
43
        add     esi, [esi+18]
44
        mov     eax, esi
44
        mov     eax, esi
45
 
45
 
46
        cmp     [esi+BITMAPINFOHEADER.BitCount], 24
46
        cmp     [esi+BITMAPINFOHEADER.BitCount], 24
47
        je      .img_24
47
        je      .img_24
48
        cmp     [esi+BITMAPINFOHEADER.BitCount], 8
48
        cmp     [esi+BITMAPINFOHEADER.BitCount], 8
49
        je      .img_8
49
        je      .img_8
50
        cmp     [esi+BITMAPINFOHEADER.BitCount], 4
50
        cmp     [esi+BITMAPINFOHEADER.BitCount], 4
51
        je      .img_4
51
        je      .img_4
52
;--------------------------------------
52
;--------------------------------------
53
align 4
53
align 4
54
.img_2:
54
.img_2:
55
        add     eax, [esi]
55
        add     eax, [esi]
56
        mov     [pQuad], eax
56
        mov     [pQuad], eax
57
        add     eax, 8
57
        add     eax, 8
58
        mov     [pBits], eax
58
        mov     [pBits], eax
59
        add     eax, 128
59
        add     eax, 128
60
        mov     [pAnd], eax
60
        mov     [pAnd], eax
61
        mov     eax, [esi+4]
61
        mov     eax, [esi+4]
62
        mov     [width], eax
62
        mov     [width], eax
63
        mov     ebx, [esi+8]
63
        mov     ebx, [esi+8]
64
        shr     ebx, 1
64
        shr     ebx, 1
65
        mov     [height], ebx
65
        mov     [height], ebx
66
 
66
 
67
        mov     edi, [dst]
67
        mov     edi, [dst]
68
        add     edi, 32*31*4
68
        add     edi, 32*31*4
69
        mov     [rBase], edi
69
        mov     [rBase], edi
70
 
70
 
71
        mov     esi, [pQuad]
71
        mov     esi, [pQuad]
72
;--------------------------------------
72
;--------------------------------------
73
align 4
73
align 4
74
.l21:
74
.l21:
75
        mov     ebx, [pBits]
75
        mov     ebx, [pBits]
76
        mov     ebx, [ebx]
76
        mov     ebx, [ebx]
77
        bswap   ebx
77
        bswap   ebx
78
        mov     eax, [pAnd]
78
        mov     eax, [pAnd]
79
        mov     eax, [eax]
79
        mov     eax, [eax]
80
        bswap   eax
80
        bswap   eax
81
        mov     [counter], 32
81
        mov     [counter], 32
82
;--------------------------------------
82
;--------------------------------------
83
align 4
83
align 4
84
@@:
84
@@:
85
        xor     edx, edx
85
        xor     edx, edx
86
        shl     eax, 1
86
        shl     eax, 1
87
        setc    dl
87
        setc    dl
88
        dec     edx
88
        dec     edx
89
 
89
 
90
        xor     ecx, ecx
90
        xor     ecx, ecx
91
        shl     ebx, 1
91
        shl     ebx, 1
92
        setc    cl
92
        setc    cl
93
        mov     ecx, [esi+ecx*4]
93
        mov     ecx, [esi+ecx*4]
94
        and     ecx, edx
94
        and     ecx, edx
95
        and     edx, 0xFF000000
95
        and     edx, 0xFF000000
96
        or      edx, ecx
96
        or      edx, ecx
97
        mov     [edi], edx
97
        mov     [edi], edx
98
 
98
 
99
        add     edi, 4
99
        add     edi, 4
100
        dec     [counter]
100
        dec     [counter]
101
        jnz     @B
101
        jnz     @B
102
 
102
 
103
        add     [pBits], 4
103
        add     [pBits], 4
104
        add     [pAnd], 4
104
        add     [pAnd], 4
105
        mov     edi, [rBase]
105
        mov     edi, [rBase]
106
        sub     edi, 128
106
        sub     edi, 128
107
        mov     [rBase], edi
107
        mov     [rBase], edi
108
        sub     [height], 1
108
        sub     [height], 1
109
        jnz     .l21
109
        jnz     .l21
110
        ret
110
        ret
111
;--------------------------------------
111
;--------------------------------------
112
align 4
112
align 4
113
.img_4:
113
.img_4:
114
        add     eax, [esi]
114
        add     eax, [esi]
115
        mov     [pQuad], eax
115
        mov     [pQuad], eax
116
        add     eax, 64
116
        add     eax, 64
117
        mov     [pBits], eax
117
        mov     [pBits], eax
118
        add     eax, 0x200
118
        add     eax, 0x200
119
        mov     [pAnd], eax
119
        mov     [pAnd], eax
120
        mov     eax, [esi+4]
120
        mov     eax, [esi+4]
121
        mov     [width], eax
121
        mov     [width], eax
122
        mov     ebx, [esi+8]
122
        mov     ebx, [esi+8]
123
        shr     ebx, 1
123
        shr     ebx, 1
124
        mov     [height], ebx
124
        mov     [height], ebx
125
 
125
 
126
        mov     edi, [dst]
126
        mov     edi, [dst]
127
        add     edi, 32*31*4
127
        add     edi, 32*31*4
128
        mov     [rBase], edi
128
        mov     [rBase], edi
129
 
129
 
130
        mov     esi, [pQuad]
130
        mov     esi, [pQuad]
131
        mov     ebx, [pBits]
131
        mov     ebx, [pBits]
132
;--------------------------------------
132
;--------------------------------------
133
align 4
133
align 4
134
.l4:
134
.l4:
135
        mov     eax, [pAnd]
135
        mov     eax, [pAnd]
136
        mov     eax, [eax]
136
        mov     eax, [eax]
137
        bswap   eax
137
        bswap   eax
138
        mov     [counter], 16
138
        mov     [counter], 16
139
;--------------------------------------
139
;--------------------------------------
140
align 4
140
align 4
141
@@:
141
@@:
142
        xor     edx, edx
142
        xor     edx, edx
143
        shl     eax, 1
143
        shl     eax, 1
144
        setc    dl
144
        setc    dl
145
        dec     edx
145
        dec     edx
146
 
146
 
147
        movzx   ecx, byte [ebx]
147
        movzx   ecx, byte [ebx]
148
        and     cl, 0xF0
148
        and     cl, 0xF0
149
        shr     ecx, 2
149
        shr     ecx, 2
150
        mov     ecx, [esi+ecx]
150
        mov     ecx, [esi+ecx]
151
        and     ecx, edx
151
        and     ecx, edx
152
        and     edx, 0xFF000000
152
        and     edx, 0xFF000000
153
        or      edx, ecx
153
        or      edx, ecx
154
        mov     [edi], edx
154
        mov     [edi], edx
155
 
155
 
156
        xor     edx, edx
156
        xor     edx, edx
157
        shl     eax, 1
157
        shl     eax, 1
158
        setc    dl
158
        setc    dl
159
        dec     edx
159
        dec     edx
160
 
160
 
161
        movzx   ecx, byte [ebx]
161
        movzx   ecx, byte [ebx]
162
        and     cl, 0x0F
162
        and     cl, 0x0F
163
        mov     ecx, [esi+ecx*4]
163
        mov     ecx, [esi+ecx*4]
164
        and     ecx, edx
164
        and     ecx, edx
165
        and     edx, 0xFF000000
165
        and     edx, 0xFF000000
166
        or      edx, ecx
166
        or      edx, ecx
167
        mov     [edi+4], edx
167
        mov     [edi+4], edx
168
 
168
 
169
        inc     ebx
169
        inc     ebx
170
        add     edi, 8
170
        add     edi, 8
171
        dec     [counter]
171
        dec     [counter]
172
        jnz     @B
172
        jnz     @B
173
 
173
 
174
        add     [pAnd], 4
174
        add     [pAnd], 4
175
        mov     edi, [rBase]
175
        mov     edi, [rBase]
176
        sub     edi, 128
176
        sub     edi, 128
177
        mov     [rBase], edi
177
        mov     [rBase], edi
178
        sub     [height], 1
178
        sub     [height], 1
179
        jnz     .l4
179
        jnz     .l4
180
        ret
180
        ret
181
;--------------------------------------
181
;--------------------------------------
182
align 4
182
align 4
183
.img_8:
183
.img_8:
184
        add     eax, [esi]
184
        add     eax, [esi]
185
        mov     [pQuad], eax
185
        mov     [pQuad], eax
186
        add     eax, 1024
186
        add     eax, 1024
187
        mov     [pBits], eax
187
        mov     [pBits], eax
188
        add     eax, 1024
188
        add     eax, 1024
189
        mov     [pAnd], eax
189
        mov     [pAnd], eax
190
        mov     eax, [esi+4]
190
        mov     eax, [esi+4]
191
        mov     [width], eax
191
        mov     [width], eax
192
        mov     ebx, [esi+8]
192
        mov     ebx, [esi+8]
193
        shr     ebx, 1
193
        shr     ebx, 1
194
        mov     [height], ebx
194
        mov     [height], ebx
195
 
195
 
196
        mov     edi, [dst]
196
        mov     edi, [dst]
197
        add     edi, 32*31*4
197
        add     edi, 32*31*4
198
        mov     [rBase], edi
198
        mov     [rBase], edi
199
 
199
 
200
        mov     esi, [pQuad]
200
        mov     esi, [pQuad]
201
        mov     ebx, [pBits]
201
        mov     ebx, [pBits]
202
;--------------------------------------
202
;--------------------------------------
203
align 4
203
align 4
204
.l81:
204
.l81:
205
        mov     eax, [pAnd]
205
        mov     eax, [pAnd]
206
        mov     eax, [eax]
206
        mov     eax, [eax]
207
        bswap   eax
207
        bswap   eax
208
        mov     [counter], 32
208
        mov     [counter], 32
209
;--------------------------------------
209
;--------------------------------------
210
align 4
210
align 4
211
@@:
211
@@:
212
        xor     edx, edx
212
        xor     edx, edx
213
        shl     eax, 1
213
        shl     eax, 1
214
        setc    dl
214
        setc    dl
215
        dec     edx
215
        dec     edx
216
 
216
 
217
        movzx   ecx, byte [ebx]
217
        movzx   ecx, byte [ebx]
218
        mov     ecx, [esi+ecx*4]
218
        mov     ecx, [esi+ecx*4]
219
        and     ecx, edx
219
        and     ecx, edx
220
        and     edx, 0xFF000000
220
        and     edx, 0xFF000000
221
        or      edx, ecx
221
        or      edx, ecx
222
        mov     [edi], edx
222
        mov     [edi], edx
223
 
223
 
224
        inc     ebx
224
        inc     ebx
225
        add     edi, 4
225
        add     edi, 4
226
        dec     [counter]
226
        dec     [counter]
227
        jnz     @B
227
        jnz     @B
228
 
228
 
229
        add     [pAnd], 4
229
        add     [pAnd], 4
230
        mov     edi, [rBase]
230
        mov     edi, [rBase]
231
        sub     edi, 128
231
        sub     edi, 128
232
        mov     [rBase], edi
232
        mov     [rBase], edi
233
        sub     [height], 1
233
        sub     [height], 1
234
        jnz     .l81
234
        jnz     .l81
235
        ret
235
        ret
236
;--------------------------------------
236
;--------------------------------------
237
align 4
237
align 4
238
.img_24:
238
.img_24:
239
        add     eax, [esi]
239
        add     eax, [esi]
240
        mov     [pQuad], eax
240
        mov     [pQuad], eax
241
        add     eax, 0xC00
241
        add     eax, 0xC00
242
        mov     [pAnd], eax
242
        mov     [pAnd], eax
243
        mov     eax, [esi+BITMAPINFOHEADER.Width]
243
        mov     eax, [esi+BITMAPINFOHEADER.Width]
244
        mov     [width], eax
244
        mov     [width], eax
245
        mov     ebx, [esi+BITMAPINFOHEADER.Height]
245
        mov     ebx, [esi+BITMAPINFOHEADER.Height]
246
        shr     ebx, 1
246
        shr     ebx, 1
247
        mov     [height], ebx
247
        mov     [height], ebx
248
 
248
 
249
        mov     edi, [dst]
249
        mov     edi, [dst]
250
        add     edi, 32*31*4
250
        add     edi, 32*31*4
251
        mov     [rBase], edi
251
        mov     [rBase], edi
252
 
252
 
253
        mov     esi, [pAnd]
253
        mov     esi, [pAnd]
254
        mov     ebx, [pQuad]
254
        mov     ebx, [pQuad]
255
;--------------------------------------
255
;--------------------------------------
256
align 4
256
align 4
257
.row_24:
257
.row_24:
258
        mov     eax, [esi]
258
        mov     eax, [esi]
259
        bswap   eax
259
        bswap   eax
260
        mov     [counter], 32
260
        mov     [counter], 32
261
;--------------------------------------
261
;--------------------------------------
262
align 4
262
align 4
263
@@:
263
@@:
264
        xor     edx, edx
264
        xor     edx, edx
265
        shl     eax, 1
265
        shl     eax, 1
266
        setc    dl
266
        setc    dl
267
        dec     edx
267
        dec     edx
268
 
268
 
269
        mov     ecx, [ebx]
269
        mov     ecx, [ebx]
270
        and     ecx, 0x00FFFFFF
270
        and     ecx, 0x00FFFFFF
271
        and     ecx, edx
271
        and     ecx, edx
272
        and     edx, 0xFF000000
272
        and     edx, 0xFF000000
273
        or      edx, ecx
273
        or      edx, ecx
274
        mov     [edi], edx
274
        mov     [edi], edx
275
        add     ebx, 3
275
        add     ebx, 3
276
        add     edi, 4
276
        add     edi, 4
277
        dec     [counter]
277
        dec     [counter]
278
        jnz     @B
278
        jnz     @B
279
 
279
 
280
        add     esi, 4
280
        add     esi, 4
281
        mov     edi, [rBase]
281
        mov     edi, [rBase]
282
        sub     edi, 128
282
        sub     edi, 128
283
        mov     [rBase], edi
283
        mov     [rBase], edi
284
        sub     [height], 1
284
        sub     [height], 1
285
        jnz     .row_24
285
        jnz     .row_24
286
        ret
286
        ret
287
endp
287
endp
288
;------------------------------------------------------------------------------
288
;------------------------------------------------------------------------------
289
align 4
289
align 4
290
proc set_cursor stdcall, hcursor:dword
290
proc set_cursor stdcall, hcursor:dword
291
        mov     eax, [hcursor]
291
        mov     eax, [hcursor]
292
        cmp     [eax+CURSOR.magic], 'CURS'
292
        cmp     [eax+CURSOR.magic], 'CURS'
293
        jne     .fail
293
        jne     .fail
294
;           cmp [eax+CURSOR.size], CURSOR_SIZE
294
;           cmp [eax+CURSOR.size], CURSOR_SIZE
295
;           jne .fail
295
;           jne .fail
296
        mov     ebx, [current_slot]
296
        mov     ebx, [current_slot]
297
        xchg    eax, [ebx+APPDATA.cursor]
297
        xchg    eax, [ebx+APPDATA.cursor]
-
 
298
        mov     [redrawmouse_unconditional], 1
-
 
299
        call    __sys_draw_pointer
298
        ret
300
        ret
299
;--------------------------------------
301
;--------------------------------------
300
align 4
302
align 4
301
.fail:
303
.fail:
302
        mov     eax, [def_cursor]
304
        mov     eax, [def_cursor]
303
        mov     ebx, [current_slot]
305
        mov     ebx, [current_slot]
304
        xchg    eax, [ebx+APPDATA.cursor]
306
        xchg    eax, [ebx+APPDATA.cursor]
305
        ret
307
        ret
306
endp
308
endp
307
;------------------------------------------------------------------------------
309
;------------------------------------------------------------------------------
308
align 4
310
align 4
309
; param
311
; param
310
;  eax= pid
312
;  eax= pid
311
;  ebx= src
313
;  ebx= src
312
;  ecx= flags
314
;  ecx= flags
313
 
315
 
314
create_cursor:
316
create_cursor:
315
.src     equ esp
317
.src     equ esp
316
.flags   equ esp+4
318
.flags   equ esp+4
317
.hcursor equ esp+8
319
.hcursor equ esp+8
318
 
320
 
319
        sub     esp, 4         ;space for .hcursor
321
        sub     esp, 4         ;space for .hcursor
320
        push    ecx
322
        push    ecx
321
        push    ebx
323
        push    ebx
322
 
324
 
323
        mov     ebx, eax
325
        mov     ebx, eax
324
        mov     eax, sizeof.CURSOR
326
        mov     eax, sizeof.CURSOR
325
        call    create_kernel_object
327
        call    create_kernel_object
326
        test    eax, eax
328
        test    eax, eax
327
        jz      .fail
329
        jz      .fail
328
 
330
 
329
        mov     [.hcursor], eax
331
        mov     [.hcursor], eax
330
 
332
 
331
        xor     ebx, ebx
333
        xor     ebx, ebx
332
        mov     [eax+CURSOR.magic], 'CURS'
334
        mov     [eax+CURSOR.magic], 'CURS'
333
        mov     [eax+CURSOR.destroy], destroy_cursor
335
        mov     [eax+CURSOR.destroy], destroy_cursor
334
        mov     [eax+CURSOR.hot_x], ebx
336
        mov     [eax+CURSOR.hot_x], ebx
335
        mov     [eax+CURSOR.hot_y], ebx
337
        mov     [eax+CURSOR.hot_y], ebx
336
 
338
 
337
        stdcall kernel_alloc, 0x1000
339
        stdcall kernel_alloc, 0x1000
338
        test    eax, eax
340
        test    eax, eax
339
        jz      .fail
341
        jz      .fail
340
 
342
 
341
        mov     edi, [.hcursor]
343
        mov     edi, [.hcursor]
342
        mov     [edi+CURSOR.base], eax
344
        mov     [edi+CURSOR.base], eax
343
 
345
 
344
        mov     esi, [.src]
346
        mov     esi, [.src]
345
        mov     ebx, [.flags]
347
        mov     ebx, [.flags]
346
        cmp     bx, LOAD_INDIRECT
348
        cmp     bx, LOAD_INDIRECT
347
        je      .indirect
349
        je      .indirect
348
 
350
 
349
        movzx   ecx, word [esi+10]
351
        movzx   ecx, word [esi+10]
350
        movzx   edx, word [esi+12]
352
        movzx   edx, word [esi+12]
351
        mov     [edi+CURSOR.hot_x], ecx
353
        mov     [edi+CURSOR.hot_x], ecx
352
        mov     [edi+CURSOR.hot_y], edx
354
        mov     [edi+CURSOR.hot_y], edx
353
 
355
 
354
        stdcall init_cursor, eax, esi
356
        stdcall init_cursor, eax, esi
355
 
357
 
356
align 4
358
align 4
357
.add_cursor:
359
.add_cursor:
358
        mov     ecx, [.hcursor]
360
        mov     ecx, [.hcursor]
359
        lea     ecx, [ecx+CURSOR.list_next]
361
        lea     ecx, [ecx+CURSOR.list_next]
360
        lea     edx, [_display.cr_list.next]
362
        lea     edx, [_display.cr_list.next]
361
 
363
 
362
        pushfd
364
        pushfd
363
        cli
365
        cli
364
        list_add ecx, edx   ;list_add_tail(new, head)
366
        list_add ecx, edx   ;list_add_tail(new, head)
365
        popfd
367
        popfd
366
 
368
 
367
        mov     eax, [.hcursor]
369
        mov     eax, [.hcursor]
368
        cmp     [_display.init_cursor], 0
370
        cmp     [_display.init_cursor], 0
369
        je      .fail
371
        je      .fail
370
 
372
 
371
        push    eax
373
        push    eax
372
        call    [_display.init_cursor]
374
        call    [_display.init_cursor]
373
        add     esp, 4
375
        add     esp, 4
374
 
376
 
375
        mov     eax, [.hcursor]
377
        mov     eax, [.hcursor]
376
;--------------------------------------
378
;--------------------------------------
377
align 4
379
align 4
378
.fail:
380
.fail:
379
        add     esp, 12
381
        add     esp, 12
380
        ret
382
        ret
381
;--------------------------------------
383
;--------------------------------------
382
align 4
384
align 4
383
.indirect:
385
.indirect:
384
        shr     ebx, 16
386
        shr     ebx, 16
385
        movzx   ecx, bh
387
        movzx   ecx, bh
386
        movzx   edx, bl
388
        movzx   edx, bl
387
        mov     [edi+CURSOR.hot_x], ecx
389
        mov     [edi+CURSOR.hot_x], ecx
388
        mov     [edi+CURSOR.hot_y], edx
390
        mov     [edi+CURSOR.hot_y], edx
389
 
391
 
390
        xchg    edi, eax
392
        xchg    edi, eax
391
        mov     ecx, 1024
393
        mov     ecx, 1024
392
        cld
394
        cld
393
        rep movsd
395
        rep movsd
394
        jmp     .add_cursor
396
        jmp     .add_cursor
395
;------------------------------------------------------------------------------
397
;------------------------------------------------------------------------------
396
align 4
398
align 4
397
proc load_cursor stdcall, src:dword, flags:dword
399
proc load_cursor stdcall, src:dword, flags:dword
398
           locals
400
           locals
399
             handle  dd ?
401
             handle  dd ?
400
           endl
402
           endl
401
 
403
 
402
        xor     eax, eax
404
        xor     eax, eax
403
        cmp     [create_cursor], eax
405
        cmp     [create_cursor], eax
404
        je      .fail2
406
        je      .fail2
405
 
407
 
406
        mov     [handle], eax
408
        mov     [handle], eax
407
        cmp     word [flags], LOAD_FROM_FILE
409
        cmp     word [flags], LOAD_FROM_FILE
408
        jne     @F
410
        jne     @F
409
 
411
 
410
        stdcall load_file, [src]
412
        stdcall load_file, [src]
411
        test    eax, eax
413
        test    eax, eax
412
        jz      .fail
414
        jz      .fail
413
        mov     [src], eax
415
        mov     [src], eax
414
;--------------------------------------
416
;--------------------------------------
415
align 4
417
align 4
416
@@:
418
@@:
417
        push    ebx
419
        push    ebx
418
        push    esi
420
        push    esi
419
        push    edi
421
        push    edi
420
 
422
 
421
        mov     eax, [CURRENT_TASK]
423
        mov     eax, [CURRENT_TASK]
422
        shl     eax, 5
424
        shl     eax, 5
423
        mov     eax, [CURRENT_TASK+eax+4]
425
        mov     eax, [CURRENT_TASK+eax+4]
424
        mov     ebx, [src]
426
        mov     ebx, [src]
425
        mov     ecx, [flags]
427
        mov     ecx, [flags]
426
        call    create_cursor    ;eax, ebx, ecx
428
        call    create_cursor    ;eax, ebx, ecx
427
        mov     [handle], eax
429
        mov     [handle], eax
428
 
430
 
429
        cmp     word [flags], LOAD_FROM_FILE
431
        cmp     word [flags], LOAD_FROM_FILE
430
        jne     .exit
432
        jne     .exit
431
        stdcall kernel_free, [src]
433
        stdcall kernel_free, [src]
432
;--------------------------------------
434
;--------------------------------------
433
align 4
435
align 4
434
.exit:
436
.exit:
435
        pop     edi
437
        pop     edi
436
        pop     esi
438
        pop     esi
437
        pop     ebx
439
        pop     ebx
438
;--------------------------------------
440
;--------------------------------------
439
align 4
441
align 4
440
.fail:
442
.fail:
441
        mov     eax, [handle]
443
        mov     eax, [handle]
442
;--------------------------------------
444
;--------------------------------------
443
align 4
445
align 4
444
.fail2:
446
.fail2:
445
        ret
447
        ret
446
endp
448
endp
447
;------------------------------------------------------------------------------
449
;------------------------------------------------------------------------------
448
align 4
450
align 4
449
proc delete_cursor stdcall, hcursor:dword
451
proc delete_cursor stdcall, hcursor:dword
450
 
452
 
451
;        DEBUGF 1,'K : delete_cursor %x\n', [hcursor]
453
;        DEBUGF 1,'K : delete_cursor %x\n', [hcursor]
452
 
454
 
453
        mov     esi, [hcursor]
455
        mov     esi, [hcursor]
454
 
456
 
455
        cmp     [esi+CURSOR.magic], 'CURS'
457
        cmp     [esi+CURSOR.magic], 'CURS'
456
        jne     .fail
458
        jne     .fail
457
 
459
 
458
        mov     ebx, [CURRENT_TASK]
460
        mov     ebx, [CURRENT_TASK]
459
        shl     ebx, 5
461
        shl     ebx, 5
460
        mov     ebx, [CURRENT_TASK+ebx+4]
462
        mov     ebx, [CURRENT_TASK+ebx+4]
461
        cmp     ebx, [esi+CURSOR.pid]
463
        cmp     ebx, [esi+CURSOR.pid]
462
        jne     .fail
464
        jne     .fail
463
 
465
 
464
        mov     ebx, [current_slot]
466
        mov     ebx, [current_slot]
465
        cmp     esi, [ebx+APPDATA.cursor]
467
        cmp     esi, [ebx+APPDATA.cursor]
466
        jne     @F
468
        jne     @F
467
        mov     eax, [def_cursor]
469
        mov     eax, [def_cursor]
468
        mov     [ebx+APPDATA.cursor], eax
470
        mov     [ebx+APPDATA.cursor], eax
469
;--------------------------------------
471
;--------------------------------------
470
align 4
472
align 4
471
@@:
473
@@:
472
        mov     eax, [hcursor]
474
        mov     eax, [hcursor]
473
        call    [eax+APPOBJ.destroy]
475
        call    [eax+APPOBJ.destroy]
474
;--------------------------------------
476
;--------------------------------------
475
align 4
477
align 4
476
.fail:
478
.fail:
477
        ret
479
        ret
478
endp
480
endp
479
;------------------------------------------------------------------------------
481
;------------------------------------------------------------------------------
480
align 4
482
align 4
481
; param
483
; param
482
;  eax= cursor
484
;  eax= cursor
483
destroy_cursor:
485
destroy_cursor:
484
 
486
 
485
        push    eax
487
        push    eax
486
        stdcall kernel_free, [eax+CURSOR.base]
488
        stdcall kernel_free, [eax+CURSOR.base]
487
 
489
 
488
        mov     eax, [esp]
490
        mov     eax, [esp]
489
        lea     eax, [eax+CURSOR.list_next]
491
        lea     eax, [eax+CURSOR.list_next]
490
 
492
 
491
        pushfd
493
        pushfd
492
        cli
494
        cli
493
        list_del eax
495
        list_del eax
494
        popfd
496
        popfd
495
 
497
 
496
        pop     eax
498
        pop     eax
497
        call    destroy_kernel_object
499
        call    destroy_kernel_object
498
        ret
500
        ret
499
;------------------------------------------------------------------------------
501
;------------------------------------------------------------------------------
500
align 4
502
align 4
501
select_cursor:
503
select_cursor:
502
        mov     eax, [esp+4]
504
        mov     eax, [esp+4]
503
        mov     [_display.cursor], eax
505
        mov     [_display.cursor], eax
504
        ret     4
506
        ret     4
505
;------------------------------------------------------------------------------
507
;------------------------------------------------------------------------------
506
align 4
508
align 4
507
proc restore_24 stdcall, x:dword, y:dword
509
proc restore_24 stdcall, x:dword, y:dword
508
 
510
 
509
        push    ebx
511
        push    ebx
510
 
512
 
511
        mov     ebx, [cur_saved_base]
513
        mov     ebx, [cur_saved_base]
512
        mov     edx, [cur.h]
514
        mov     edx, [cur.h]
513
        test    edx, edx
515
        test    edx, edx
514
        jz      .ret
516
        jz      .ret
515
 
517
 
516
        push    esi
518
        push    esi
517
        push    edi
519
        push    edi
518
 
520
 
519
        mov     esi, cur_saved_data
521
        mov     esi, cur_saved_data
520
        mov     ecx, [cur.w]
522
        mov     ecx, [cur.w]
521
        lea     ecx, [ecx+ecx*2]
523
        lea     ecx, [ecx+ecx*2]
522
        push    ecx
524
        push    ecx
523
;--------------------------------------
525
;--------------------------------------
524
align 4
526
align 4
525
@@:
527
@@:
526
        mov     edi, ebx
528
        mov     edi, ebx
527
        add     ebx, [_display.pitch]
529
        add     ebx, [_display.pitch]
528
 
530
 
529
        mov     ecx, [esp]
531
        mov     ecx, [esp]
530
        rep movsb
532
        rep movsb
531
        dec     edx
533
        dec     edx
532
        jnz     @B
534
        jnz     @B
533
 
535
 
534
        pop     ecx
536
        pop     ecx
535
        pop     edi
537
        pop     edi
536
        pop     esi
538
        pop     esi
537
;--------------------------------------
539
;--------------------------------------
538
align 4
540
align 4
539
.ret:
541
.ret:
540
        pop     ebx
542
        pop     ebx
541
        ret
543
        ret
542
endp
544
endp
543
;------------------------------------------------------------------------------
545
;------------------------------------------------------------------------------
544
align 4
546
align 4
545
proc restore_32 stdcall, x:dword, y:dword
547
proc restore_32 stdcall, x:dword, y:dword
546
 
548
 
547
        push    ebx
549
        push    ebx
548
 
550
 
549
        mov     ebx, [cur_saved_base]
551
        mov     ebx, [cur_saved_base]
550
        mov     edx, [cur.h]
552
        mov     edx, [cur.h]
551
        test    edx, edx
553
        test    edx, edx
552
        jz      .ret
554
        jz      .ret
553
 
555
 
554
        push    esi
556
        push    esi
555
        push    edi
557
        push    edi
556
 
558
 
557
        mov     esi, cur_saved_data
559
        mov     esi, cur_saved_data
558
;--------------------------------------
560
;--------------------------------------
559
align 4
561
align 4
560
@@:
562
@@:
561
        mov     edi, ebx
563
        mov     edi, ebx
562
        add     ebx, [_display.pitch]
564
        add     ebx, [_display.pitch]
563
 
565
 
564
        mov     ecx, [cur.w]
566
        mov     ecx, [cur.w]
565
        rep movsd
567
        rep movsd
566
        dec     edx
568
        dec     edx
567
        jnz     @B
569
        jnz     @B
568
 
570
 
569
        pop     edi
571
        pop     edi
570
;--------------------------------------
572
;--------------------------------------
571
align 4
573
align 4
572
.ret:
574
.ret:
573
        pop     esi
575
        pop     esi
574
        pop     ebx
576
        pop     ebx
575
        ret
577
        ret
576
endp
578
endp
577
;------------------------------------------------------------------------------
579
;------------------------------------------------------------------------------
578
align 4
580
align 4
579
proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
581
proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
580
           locals
582
           locals
581
             h      dd ?
583
             h      dd ?
582
             _dx     dd ?
584
             _dx     dd ?
583
             _dy     dd ?
585
             _dy     dd ?
584
           endl
586
           endl
585
 
587
 
586
        mov     esi, [hcursor]
588
        mov     esi, [hcursor]
587
        mov     ecx, [x]
589
        mov     ecx, [x]
588
        mov     eax, [y]
590
        mov     eax, [y]
589
;        mov     ebx, [BytesPerScanLine]
591
;        mov     ebx, [BytesPerScanLine]
590
 
592
 
591
        xor     edx, edx
593
        xor     edx, edx
592
        sub     ecx, [esi+CURSOR.hot_x]
594
        sub     ecx, [esi+CURSOR.hot_x]
593
        lea     ebx, [ecx+32-1]
595
        lea     ebx, [ecx+32-1]
594
        mov     [x], ecx
596
        mov     [x], ecx
595
        sets    dl
597
        sets    dl
596
        dec     edx
598
        dec     edx
597
        and     ecx, edx      ;clip x to 0<=x
599
        and     ecx, edx      ;clip x to 0<=x
598
        mov     [cur.left], ecx
600
        mov     [cur.left], ecx
599
        mov     edi, ecx
601
        mov     edi, ecx
600
        sub     edi, [x]
602
        sub     edi, [x]
601
        mov     [_dx], edi
603
        mov     [_dx], edi
602
 
604
 
603
        xor     edx, edx
605
        xor     edx, edx
604
        sub     eax, [esi+CURSOR.hot_y]
606
        sub     eax, [esi+CURSOR.hot_y]
605
        lea     edi, [eax+32-1]
607
        lea     edi, [eax+32-1]
606
        mov     [y], eax
608
        mov     [y], eax
607
        sets    dl
609
        sets    dl
608
        dec     edx
610
        dec     edx
609
        and     eax, edx      ;clip y to 0<=y
611
        and     eax, edx      ;clip y to 0<=y
610
        mov     [cur.top], eax
612
        mov     [cur.top], eax
611
        mov     edx, eax
613
        mov     edx, eax
612
        sub     edx, [y]
614
        sub     edx, [y]
613
        mov     [_dy], edx
615
        mov     [_dy], edx
614
 
616
 
615
;        mul     dword [BytesPerScanLine]
617
;        mul     dword [BytesPerScanLine]
616
        mov     eax, [BPSLine_calc_area+eax*4]
618
        mov     eax, [BPSLine_calc_area+eax*4]
617
        lea     edx, [LFB_BASE+ecx*3]
619
        lea     edx, [LFB_BASE+ecx*3]
618
        add     edx, eax
620
        add     edx, eax
619
        mov     [cur_saved_base], edx
621
        mov     [cur_saved_base], edx
620
 
622
 
621
        cmp     ebx, [_display.width]
623
        cmp     ebx, [_display.width]
622
        jb      @F
624
        jb      @F
623
        mov     ebx, [_display.width]
625
        mov     ebx, [_display.width]
624
        dec     ebx
626
        dec     ebx
625
;--------------------------------------
627
;--------------------------------------
626
align 4
628
align 4
627
@@:
629
@@:
628
        cmp     edi, [_display.height]
630
        cmp     edi, [_display.height]
629
        jb      @F
631
        jb      @F
630
        mov     edi, [_display.height]
632
        mov     edi, [_display.height]
631
        dec     edi
633
        dec     edi
632
;--------------------------------------
634
;--------------------------------------
633
align 4
635
align 4
634
@@:
636
@@:
635
        mov     [cur.right], ebx
637
        mov     [cur.right], ebx
636
        mov     [cur.bottom], edi
638
        mov     [cur.bottom], edi
637
 
639
 
638
        sub     ebx, [x]
640
        sub     ebx, [x]
639
        sub     edi, [y]
641
        sub     edi, [y]
640
        inc     ebx
642
        inc     ebx
641
        inc     edi
643
        inc     edi
642
        sub     ebx, [_dx]
644
        sub     ebx, [_dx]
643
        sub     edi, [_dy]
645
        sub     edi, [_dy]
644
 
646
 
645
        mov     [cur.w], ebx
647
        mov     [cur.w], ebx
646
        mov     [cur.h], edi
648
        mov     [cur.h], edi
647
        mov     [h], edi
649
        mov     [h], edi
648
 
650
 
649
        mov     eax, edi
651
        mov     eax, edi
650
        mov     edi, cur_saved_data
652
        mov     edi, cur_saved_data
651
;--------------------------------------
653
;--------------------------------------
652
align 4
654
align 4
653
@@:
655
@@:
654
        mov     esi, edx
656
        mov     esi, edx
655
        add     edx, [_display.pitch]
657
        add     edx, [_display.pitch]
656
        mov     ecx, [cur.w]
658
        mov     ecx, [cur.w]
657
        lea     ecx, [ecx+ecx*2]
659
        lea     ecx, [ecx+ecx*2]
658
        rep movsb
660
        rep movsb
659
        dec     eax
661
        dec     eax
660
        jnz     @B
662
        jnz     @B
661
 
663
 
662
;draw cursor
664
;draw cursor
663
        mov     ebx, [cur_saved_base]
665
        mov     ebx, [cur_saved_base]
664
        mov     eax, [_dy]
666
        mov     eax, [_dy]
665
        shl     eax, 5
667
        shl     eax, 5
666
        add     eax, [_dx]
668
        add     eax, [_dx]
667
 
669
 
668
        mov     esi, [hcursor]
670
        mov     esi, [hcursor]
669
        mov     esi, [esi+CURSOR.base]
671
        mov     esi, [esi+CURSOR.base]
670
        lea     edx, [esi+eax*4]
672
        lea     edx, [esi+eax*4]
671
;--------------------------------------
673
;--------------------------------------
672
align 4
674
align 4
673
.row:
675
.row:
674
        mov     ecx, [cur.w]
676
        mov     ecx, [cur.w]
675
        mov     esi, edx
677
        mov     esi, edx
676
        mov     edi, ebx
678
        mov     edi, ebx
677
        add     edx, 32*4
679
        add     edx, 32*4
678
        add     ebx, [_display.pitch]
680
        add     ebx, [_display.pitch]
679
;--------------------------------------
681
;--------------------------------------
680
align 4
682
align 4
681
.pix:
683
.pix:
682
        lodsd
684
        lodsd
683
        test    eax, 0xFF000000
685
        test    eax, 0xFF000000
684
        jz      @F
686
        jz      @F
685
        mov     [edi], ax
687
        mov     [edi], ax
686
        shr     eax, 16
688
        shr     eax, 16
687
        mov     [edi+2], al
689
        mov     [edi+2], al
688
;--------------------------------------
690
;--------------------------------------
689
align 4
691
align 4
690
@@:
692
@@:
691
        add     edi, 3
693
        add     edi, 3
692
        dec     ecx
694
        dec     ecx
693
        jnz     .pix
695
        jnz     .pix
694
 
696
 
695
        dec     [h]
697
        dec     [h]
696
        jnz     .row
698
        jnz     .row
697
        ret
699
        ret
698
endp
700
endp
699
;------------------------------------------------------------------------------
701
;------------------------------------------------------------------------------
700
align 4
702
align 4
701
proc move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
703
proc move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
702
           locals
704
           locals
703
             h      dd ?
705
             h      dd ?
704
             _dx     dd ?
706
             _dx     dd ?
705
             _dy     dd ?
707
             _dy     dd ?
706
           endl
708
           endl
707
 
709
 
708
        mov     esi, [hcursor]
710
        mov     esi, [hcursor]
709
        mov     ecx, [x]
711
        mov     ecx, [x]
710
        mov     eax, [y]
712
        mov     eax, [y]
711
 
713
 
712
        xor     edx, edx
714
        xor     edx, edx
713
        sub     ecx, [esi+CURSOR.hot_x]
715
        sub     ecx, [esi+CURSOR.hot_x]
714
        lea     ebx, [ecx+32-1]
716
        lea     ebx, [ecx+32-1]
715
        mov     [x], ecx
717
        mov     [x], ecx
716
        sets    dl
718
        sets    dl
717
        dec     edx
719
        dec     edx
718
        and     ecx, edx      ;clip x to 0<=x
720
        and     ecx, edx      ;clip x to 0<=x
719
        mov     [cur.left], ecx
721
        mov     [cur.left], ecx
720
        mov     edi, ecx
722
        mov     edi, ecx
721
        sub     edi, [x]
723
        sub     edi, [x]
722
        mov     [_dx], edi
724
        mov     [_dx], edi
723
 
725
 
724
        xor     edx, edx
726
        xor     edx, edx
725
        sub     eax, [esi+CURSOR.hot_y]
727
        sub     eax, [esi+CURSOR.hot_y]
726
        lea     edi, [eax+32-1]
728
        lea     edi, [eax+32-1]
727
        mov     [y], eax
729
        mov     [y], eax
728
        sets    dl
730
        sets    dl
729
        dec     edx
731
        dec     edx
730
        and     eax, edx      ;clip y to 0<=y
732
        and     eax, edx      ;clip y to 0<=y
731
        mov     [cur.top], eax
733
        mov     [cur.top], eax
732
        mov     edx, eax
734
        mov     edx, eax
733
        sub     edx, [y]
735
        sub     edx, [y]
734
        mov     [_dy], edx
736
        mov     [_dy], edx
735
 
737
 
736
;        mul     dword [BytesPerScanLine]
738
;        mul     dword [BytesPerScanLine]
737
        mov     eax, [BPSLine_calc_area+eax*4]
739
        mov     eax, [BPSLine_calc_area+eax*4]
738
        lea     edx, [LFB_BASE+eax+ecx*4]
740
        lea     edx, [LFB_BASE+eax+ecx*4]
739
        mov     [cur_saved_base], edx
741
        mov     [cur_saved_base], edx
740
 
742
 
741
        cmp     ebx, [_display.width]
743
        cmp     ebx, [_display.width]
742
        jb      @F
744
        jb      @F
743
        mov     ebx, [_display.width]
745
        mov     ebx, [_display.width]
744
        dec     ebx
746
        dec     ebx
745
;--------------------------------------
747
;--------------------------------------
746
align 4
748
align 4
747
@@:
749
@@:
748
        cmp     edi, [_display.height]
750
        cmp     edi, [_display.height]
749
        jb      @F
751
        jb      @F
750
        mov     edi, [_display.height]
752
        mov     edi, [_display.height]
751
        dec     edi
753
        dec     edi
752
;--------------------------------------
754
;--------------------------------------
753
align 4
755
align 4
754
@@:
756
@@:
755
        mov     [cur.right], ebx
757
        mov     [cur.right], ebx
756
        mov     [cur.bottom], edi
758
        mov     [cur.bottom], edi
757
 
759
 
758
        sub     ebx, [x]
760
        sub     ebx, [x]
759
        sub     edi, [y]
761
        sub     edi, [y]
760
        inc     ebx
762
        inc     ebx
761
        inc     edi
763
        inc     edi
762
        sub     ebx, [_dx]
764
        sub     ebx, [_dx]
763
        sub     edi, [_dy]
765
        sub     edi, [_dy]
764
 
766
 
765
        mov     [cur.w], ebx
767
        mov     [cur.w], ebx
766
        mov     [cur.h], edi
768
        mov     [cur.h], edi
767
        mov     [h], edi
769
        mov     [h], edi
768
 
770
 
769
        mov     eax, edi
771
        mov     eax, edi
770
        mov     edi, cur_saved_data
772
        mov     edi, cur_saved_data
771
;--------------------------------------
773
;--------------------------------------
772
align 4
774
align 4
773
@@:
775
@@:
774
        mov     esi, edx
776
        mov     esi, edx
775
        add     edx, [_display.pitch]
777
        add     edx, [_display.pitch]
776
        mov     ecx, [cur.w]
778
        mov     ecx, [cur.w]
777
        rep movsd
779
        rep movsd
778
        dec     eax
780
        dec     eax
779
        jnz     @B
781
        jnz     @B
780
 
782
 
781
;draw cursor
783
;draw cursor
782
        mov     ebx, [cur_saved_base]
784
        mov     ebx, [cur_saved_base]
783
        mov     eax, [_dy]
785
        mov     eax, [_dy]
784
        shl     eax, 5
786
        shl     eax, 5
785
        add     eax, [_dx]
787
        add     eax, [_dx]
786
 
788
 
787
        mov     esi, [hcursor]
789
        mov     esi, [hcursor]
788
        mov     esi, [esi+CURSOR.base]
790
        mov     esi, [esi+CURSOR.base]
789
        lea     edx, [esi+eax*4]
791
        lea     edx, [esi+eax*4]
790
;--------------------------------------
792
;--------------------------------------
791
align 4
793
align 4
792
.row:
794
.row:
793
        mov     ecx, [cur.w]
795
        mov     ecx, [cur.w]
794
        mov     esi, edx
796
        mov     esi, edx
795
        mov     edi, ebx
797
        mov     edi, ebx
796
        add     edx, 32*4
798
        add     edx, 32*4
797
        add     ebx, [_display.pitch]
799
        add     ebx, [_display.pitch]
798
;--------------------------------------
800
;--------------------------------------
799
align 4
801
align 4
800
.pix:
802
.pix:
801
        lodsd
803
        lodsd
802
        test    eax, 0xFF000000
804
        test    eax, 0xFF000000
803
        jz      @F
805
        jz      @F
804
        mov     [edi], eax
806
        mov     [edi], eax
805
;--------------------------------------
807
;--------------------------------------
806
align 4
808
align 4
807
@@:
809
@@:
808
        add     edi, 4
810
        add     edi, 4
809
        dec     ecx
811
        dec     ecx
810
        jnz     .pix
812
        jnz     .pix
811
 
813
 
812
        dec     [h]
814
        dec     [h]
813
        jnz     .row
815
        jnz     .row
814
        ret
816
        ret
815
endp
817
endp
816
;------------------------------------------------------------------------------
818
;------------------------------------------------------------------------------
817
align 4
819
align 4
818
check_mouse_area_for_getpixel_new:
820
check_mouse_area_for_getpixel_new:
819
; in:
821
; in:
820
; eax = x
822
; eax = x
821
; ebx = y
823
; ebx = y
822
; out:
824
; out:
823
; ecx = new color
825
; ecx = new color
824
;--------------------------------------
826
;--------------------------------------
825
; check for Y
827
; check for Y
826
        cmp     bx, [Y_UNDER_subtraction_CUR_hot_y]
828
        cmp     bx, [Y_UNDER_subtraction_CUR_hot_y]
827
        jb      .no_mouse_area
829
        jb      .no_mouse_area
828
 
830
 
829
        cmp     bx, [Y_UNDER_sub_CUR_hot_y_add_curh]
831
        cmp     bx, [Y_UNDER_sub_CUR_hot_y_add_curh]
830
        jae     .no_mouse_area
832
        jae     .no_mouse_area
831
;--------------------------------------
833
;--------------------------------------
832
; check for X
834
; check for X
833
        cmp     ax, [X_UNDER_subtraction_CUR_hot_x]
835
        cmp     ax, [X_UNDER_subtraction_CUR_hot_x]
834
        jb      .no_mouse_area
836
        jb      .no_mouse_area
835
 
837
 
836
        cmp     ax, [X_UNDER_sub_CUR_hot_x_add_curh]
838
        cmp     ax, [X_UNDER_sub_CUR_hot_x_add_curh]
837
        jae     .no_mouse_area
839
        jae     .no_mouse_area
838
;--------------------------------------
840
;--------------------------------------
839
        push    eax ebx
841
        push    eax ebx
840
; offset X
842
; offset X
841
        movzx   ecx, word [X_UNDER_subtraction_CUR_hot_x]
843
        movzx   ecx, word [X_UNDER_subtraction_CUR_hot_x]
842
        sub     eax, ecx        ; x1
844
        sub     eax, ecx        ; x1
843
; offset Y
845
; offset Y
844
        movzx   ecx, word [Y_UNDER_subtraction_CUR_hot_y]
846
        movzx   ecx, word [Y_UNDER_subtraction_CUR_hot_y]
845
        sub     ebx, ecx        ; y1
847
        sub     ebx, ecx        ; y1
846
;--------------------------------------
848
;--------------------------------------
847
; ebx = offset y
849
; ebx = offset y
848
; eax = offset x
850
; eax = offset x
849
        imul    ebx, [cur.w]     ;y
851
        imul    ebx, [cur.w]     ;y
850
        add     eax, ebx
852
        add     eax, ebx
851
        mov     ebx, eax
853
        mov     ebx, eax
852
        shl     eax, 2
854
        shl     eax, 2
853
        cmp     byte [_display.bpp], 32
855
        cmp     byte [_display.bpp], 32
854
        je      @f
856
        je      @f
855
        sub     eax, ebx
857
        sub     eax, ebx
856
;--------------------------------------
858
;--------------------------------------
857
align 4
859
align 4
858
@@:
860
@@:
859
        add     eax, cur_saved_data
861
        add     eax, cur_saved_data
860
        mov     ecx, [eax]
862
        mov     ecx, [eax]
861
        and     ecx, 0xffffff
863
        and     ecx, 0xffffff
862
        add     ecx, 0xff000000
864
        add     ecx, 0xff000000
863
        pop     ebx eax
865
        pop     ebx eax
864
        ret
866
        ret
865
;--------------------------------------
867
;--------------------------------------
866
align 4
868
align 4
867
.no_mouse_area:
869
.no_mouse_area:
868
        xor     ecx, ecx
870
        xor     ecx, ecx
869
        ret
871
        ret
870
;-----------------------------------------------------------------------------
872
;-----------------------------------------------------------------------------
871
align 4
873
align 4
872
check_mouse_area_for_putpixel_new:
874
check_mouse_area_for_putpixel_new:
873
; in:
875
; in:
874
; ecx = x shl 16 + y
876
; ecx = x shl 16 + y
875
; eax = color
877
; eax = color
876
; out:
878
; out:
877
; eax = new color
879
; eax = new color
878
;--------------------------------------
880
;--------------------------------------
879
; check for Y
881
; check for Y
880
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
882
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
881
        jae     .no_mouse_area
883
        jae     .no_mouse_area
882
 
884
 
883
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
885
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
884
        jb      .no_mouse_area
886
        jb      .no_mouse_area
885
 
887
 
886
        rol     ecx, 16
888
        rol     ecx, 16
887
;--------------------------------------
889
;--------------------------------------
888
; check for X
890
; check for X
889
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
891
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
890
        jae     .no_mouse_area
892
        jae     .no_mouse_area
891
 
893
 
892
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
894
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
893
        jb      .no_mouse_area
895
        jb      .no_mouse_area
894
 
896
 
895
        ror     ecx, 16
897
        ror     ecx, 16
896
;--------------------------------------
898
;--------------------------------------
897
align 4
899
align 4
898
.1:
900
.1:
899
        push    eax
901
        push    eax
900
;--------------------------------------
902
;--------------------------------------
901
; ecx = (offset x) shl 16 + (offset y)
903
; ecx = (offset x) shl 16 + (offset y)
902
        push    ebx
904
        push    ebx
903
        mov     ebx, ecx
905
        mov     ebx, ecx
904
        shr     ebx, 16        ; x
906
        shr     ebx, 16        ; x
905
        and     ecx, 0xffff    ; y
907
        and     ecx, 0xffff    ; y
906
 
908
 
907
        cmp     ecx, [cur.h]
909
        cmp     ecx, [cur.h]
908
        jae     @f
910
        jae     @f
909
 
911
 
910
        cmp     ebx, [cur.w]
912
        cmp     ebx, [cur.w]
911
        jb      .ok
913
        jb      .ok
912
;--------------------------------------
914
;--------------------------------------
913
align 4
915
align 4
914
@@:
916
@@:
915
;        DEBUGF  1, "K : SHIT HAPPENS: %x %x \n", ecx,ebx
917
;        DEBUGF  1, "K : SHIT HAPPENS: %x %x \n", ecx,ebx
916
        pop     ebx
918
        pop     ebx
917
        jmp     .sh   ; SORRY! SHIT HAPPENS!
919
        jmp     .sh   ; SORRY! SHIT HAPPENS!
918
;--------------------------------------
920
;--------------------------------------
919
align 4
921
align 4
920
.ok:
922
.ok:
921
; ecx = offset y
923
; ecx = offset y
922
; ebx = offset x
924
; ebx = offset x
923
        push    ebx ecx
925
        push    ebx ecx
924
        imul    ecx, [cur.w]    ;y
926
        imul    ecx, [cur.w]    ;y
925
        add     ecx, ebx
927
        add     ecx, ebx
926
        mov     ebx, ecx
928
        mov     ebx, ecx
927
        shl     ecx, 2
929
        shl     ecx, 2
928
        cmp     byte [_display.bpp], 24
930
        cmp     byte [_display.bpp], 24
929
        je      .24
931
        je      .24
930
        and     eax, 0xFFFFFF
932
        and     eax, 0xFFFFFF
931
        mov     [ecx + cur_saved_data], eax   ;store new color  to
933
        mov     [ecx + cur_saved_data], eax   ;store new color  to
932
        jmp     @f
934
        jmp     @f
933
;--------------------------------------
935
;--------------------------------------
934
align 4
936
align 4
935
.24:
937
.24:
936
        sub     ecx, ebx
938
        sub     ecx, ebx
937
        mov     [ecx + cur_saved_data], ax      ;store new color  to
939
        mov     [ecx + cur_saved_data], ax      ;store new color  to
938
        shr     eax, 16
940
        shr     eax, 16
939
        mov     [ecx + cur_saved_data + 2], al  ;store new color  to
941
        mov     [ecx + cur_saved_data + 2], al  ;store new color  to
940
;--------------------------------------
942
;--------------------------------------
941
align 4
943
align 4
942
@@:
944
@@:
943
        pop     ecx ebx
945
        pop     ecx ebx
944
 
946
 
945
        shl     ecx, 5
947
        shl     ecx, 5
946
        add     ecx, ebx
948
        add     ecx, ebx
947
 
949
 
948
        mov     eax, [current_cursor]
950
        mov     eax, [current_cursor]
949
        mov     eax, [eax+CURSOR.base]
951
        mov     eax, [eax+CURSOR.base]
950
        lea     eax, [eax+ecx*4]
952
        lea     eax, [eax+ecx*4]
951
        mov     eax, [eax]
953
        mov     eax, [eax]
952
 
954
 
953
        pop     ebx
955
        pop     ebx
954
 
956
 
955
        test    eax, 0xFF000000
957
        test    eax, 0xFF000000
956
        jz      @f
958
        jz      @f
957
 
959
 
958
        add     esp, 4
960
        add     esp, 4
959
        ret
961
        ret
960
;--------------------------------------
962
;--------------------------------------
961
align 4
963
align 4
962
.sh:
964
.sh:
963
        mov     ecx, -1
965
        mov     ecx, -1
964
;--------------------------------------
966
;--------------------------------------
965
align 4
967
align 4
966
@@:
968
@@:
967
        pop     eax
969
        pop     eax
968
;--------------------------------------
970
;--------------------------------------
969
align 4
971
align 4
970
.no_mouse_area:
972
.no_mouse_area:
971
        ret
973
        ret
972
;------------------------------------------------------------------------------
974
;------------------------------------------------------------------------------
973
align 4
975
align 4
974
get_display:
976
get_display:
975
        mov     eax, _display
977
        mov     eax, _display
976
        ret
978
        ret
977
;------------------------------------------------------------------------------
979
;------------------------------------------------------------------------------
978
align 4
980
align 4
979
init_display:
981
init_display:
980
        xor     eax, eax
982
        xor     eax, eax
981
        mov     edi, _display
983
        mov     edi, _display
982
 
984
 
983
        mov     [edi+display_t.init_cursor], eax
985
        mov     [edi+display_t.init_cursor], eax
984
        mov     [edi+display_t.select_cursor], eax
986
        mov     [edi+display_t.select_cursor], eax
985
        mov     [edi+display_t.show_cursor], eax
987
        mov     [edi+display_t.show_cursor], eax
986
        mov     [edi+display_t.move_cursor], eax
988
        mov     [edi+display_t.move_cursor], eax
987
        mov     [edi+display_t.restore_cursor], eax
989
        mov     [edi+display_t.restore_cursor], eax
988
 
990
 
989
        lea     ecx, [edi+display_t.cr_list.next]
991
        lea     ecx, [edi+display_t.cr_list.next]
990
        mov     [edi+display_t.cr_list.next], ecx
992
        mov     [edi+display_t.cr_list.next], ecx
991
        mov     [edi+display_t.cr_list.prev], ecx
993
        mov     [edi+display_t.cr_list.prev], ecx
992
 
994
 
993
        cmp     [SCR_MODE], word 0x13
995
        cmp     [SCR_MODE], word 0x13
994
        jbe     .fail
996
        jbe     .fail
995
 
997
 
996
        test    word [SCR_MODE], 0x4000
998
        test    word [SCR_MODE], 0x4000
997
        jz      .fail
999
        jz      .fail
998
 
1000
 
999
        mov     ebx, restore_32
1001
        mov     ebx, restore_32
1000
        mov     ecx, move_cursor_32
1002
        mov     ecx, move_cursor_32
1001
        mov     edx, Vesa20_putpixel32_new
1003
        mov     edx, Vesa20_putpixel32_new
1002
        mov     eax, [_display.bpp]
1004
        mov     eax, [_display.bpp]
1003
        cmp     al, 32
1005
        cmp     al, 32
1004
        jne     .24
1006
        jne     .24
1005
 
1007
 
1006
.set:
1008
.set:
1007
        mov     [_display.select_cursor], select_cursor
1009
        mov     [_display.select_cursor], select_cursor
1008
        mov     [_display.move_cursor], ecx
1010
        mov     [_display.move_cursor], ecx
1009
        mov     [_display.restore_cursor], ebx
1011
        mov     [_display.restore_cursor], ebx
1010
        mov     [_display.check_mouse], check_mouse_area_for_putpixel_new
1012
        mov     [_display.check_mouse], check_mouse_area_for_putpixel_new
1011
        mov     [_display.check_m_pixel], check_mouse_area_for_getpixel_new
1013
        mov     [_display.check_m_pixel], check_mouse_area_for_getpixel_new
1012
 
1014
 
1013
        cmp     [PUTPIXEL], dword VGA_putpixel
1015
        cmp     [PUTPIXEL], dword VGA_putpixel
1014
        je      @f
1016
        je      @f
1015
        mov     [PUTPIXEL], edx
1017
        mov     [PUTPIXEL], edx
1016
@@:
1018
@@:
1017
        stdcall load_cursor, clock_arrow, dword LOAD_FROM_MEM
1019
        stdcall load_cursor, clock_arrow, dword LOAD_FROM_MEM
1018
        mov     [def_cursor_clock], eax
1020
        mov     [def_cursor_clock], eax
1019
        stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
1021
        stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
1020
        mov     [def_cursor], eax
1022
        mov     [def_cursor], eax
1021
        ret
1023
        ret
1022
 
1024
 
1023
.24:
1025
.24:
1024
        mov     ebx, restore_24
1026
        mov     ebx, restore_24
1025
        mov     ecx, move_cursor_24
1027
        mov     ecx, move_cursor_24
1026
        mov     edx, Vesa20_putpixel24_new
1028
        mov     edx, Vesa20_putpixel24_new
1027
        cmp     al, 24
1029
        cmp     al, 24
1028
        je      .set
1030
        je      .set
1029
 
1031
 
1030
.fail:
1032
.fail:
1031
        xor     eax, eax
1033
        xor     eax, eax
1032
        mov     [_display.select_cursor], eax
1034
        mov     [_display.select_cursor], eax
1033
        mov     [_display.move_cursor], eax
1035
        mov     [_display.move_cursor], eax
1034
        ret
1036
        ret
1035
;------------------------------------------------------------------------------
1037
;------------------------------------------------------------------------------
1036
align 4
1038
align 4
1037
def_arrow:
1039
def_arrow:
1038
  file 'arrow.cur'
1040
  file 'arrow.cur'
1039
;------------------------------------------------------------------------------
1041
;------------------------------------------------------------------------------
1040
align 4
1042
align 4
1041
clock_arrow:
1043
clock_arrow:
1042
  file 'arrow_clock.cur'
1044
  file 'arrow_clock.cur'
1043
;------------------------------------------------------------------------------
1045
;------------------------------------------------------------------------------
1044
>
1046
>
1045
>
1047
>
1046
>
1048
>
1047
>
1049
>