Subversion Repositories Kolibri OS

Rev

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

Rev 2652 Rev 3069
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: 2652 $
8
$Revision: 3069 $
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
        ret
298
        ret
299
;--------------------------------------
299
;--------------------------------------
300
align 4
300
align 4
301
.fail:
301
.fail:
302
        mov     eax, [def_cursor]
302
        mov     eax, [def_cursor]
303
        mov     ebx, [current_slot]
303
        mov     ebx, [current_slot]
304
        xchg    eax, [ebx+APPDATA.cursor]
304
        xchg    eax, [ebx+APPDATA.cursor]
305
        ret
305
        ret
306
endp
306
endp
307
;------------------------------------------------------------------------------
307
;------------------------------------------------------------------------------
308
align 4
308
align 4
309
; param
309
; param
310
;  eax= pid
310
;  eax= pid
311
;  ebx= src
311
;  ebx= src
312
;  ecx= flags
312
;  ecx= flags
313
 
313
 
314
create_cursor:
314
create_cursor:
315
.src     equ esp
315
.src     equ esp
316
.flags   equ esp+4
316
.flags   equ esp+4
317
.hcursor equ esp+8
317
.hcursor equ esp+8
318
 
318
 
319
        sub     esp, 4         ;space for .hcursor
319
        sub     esp, 4         ;space for .hcursor
320
        push    ecx
320
        push    ecx
321
        push    ebx
321
        push    ebx
322
 
322
 
323
        mov     ebx, eax
323
        mov     ebx, eax
324
        mov     eax, sizeof.CURSOR
324
        mov     eax, sizeof.CURSOR
325
        call    create_kernel_object
325
        call    create_kernel_object
326
        test    eax, eax
326
        test    eax, eax
327
        jz      .fail
327
        jz      .fail
328
 
328
 
329
        mov     [.hcursor], eax
329
        mov     [.hcursor], eax
330
 
330
 
331
        xor     ebx, ebx
331
        xor     ebx, ebx
332
        mov     [eax+CURSOR.magic], 'CURS'
332
        mov     [eax+CURSOR.magic], 'CURS'
333
        mov     [eax+CURSOR.destroy], destroy_cursor
333
        mov     [eax+CURSOR.destroy], destroy_cursor
334
        mov     [eax+CURSOR.hot_x], ebx
334
        mov     [eax+CURSOR.hot_x], ebx
335
        mov     [eax+CURSOR.hot_y], ebx
335
        mov     [eax+CURSOR.hot_y], ebx
336
 
336
 
337
        stdcall kernel_alloc, 0x1000
337
        stdcall kernel_alloc, 0x1000
338
        test    eax, eax
338
        test    eax, eax
339
        jz      .fail
339
        jz      .fail
340
 
340
 
341
        mov     edi, [.hcursor]
341
        mov     edi, [.hcursor]
342
        mov     [edi+CURSOR.base], eax
342
        mov     [edi+CURSOR.base], eax
343
 
343
 
344
        mov     esi, [.src]
344
        mov     esi, [.src]
345
        mov     ebx, [.flags]
345
        mov     ebx, [.flags]
346
        cmp     bx, LOAD_INDIRECT
346
        cmp     bx, LOAD_INDIRECT
347
        je      .indirect
347
        je      .indirect
348
 
348
 
349
        movzx   ecx, word [esi+10]
349
        movzx   ecx, word [esi+10]
350
        movzx   edx, word [esi+12]
350
        movzx   edx, word [esi+12]
351
        mov     [edi+CURSOR.hot_x], ecx
351
        mov     [edi+CURSOR.hot_x], ecx
352
        mov     [edi+CURSOR.hot_y], edx
352
        mov     [edi+CURSOR.hot_y], edx
353
 
353
 
354
        stdcall init_cursor, eax, esi
354
        stdcall init_cursor, eax, esi
355
 
355
 
356
align 4
356
align 4
357
.add_cursor:
357
.add_cursor:
358
        mov     ecx, [.hcursor]
358
        mov     ecx, [.hcursor]
359
        lea     ecx, [ecx+CURSOR.list_next]
359
        lea     ecx, [ecx+CURSOR.list_next]
360
        lea     edx, [_display.cr_list.next]
360
        lea     edx, [_display.cr_list.next]
361
 
361
 
362
        pushfd
362
        pushfd
363
        cli
363
        cli
364
        list_add ecx, edx   ;list_add_tail(new, head)
364
        list_add ecx, edx   ;list_add_tail(new, head)
365
        popfd
365
        popfd
366
 
366
 
367
        mov     eax, [.hcursor]
367
        mov     eax, [.hcursor]
368
        cmp     [_display.init_cursor], 0
368
        cmp     [_display.init_cursor], 0
369
        je      .fail
369
        je      .fail
370
 
370
 
371
        push    eax
371
        push    eax
372
        call    [_display.init_cursor]
372
        call    [_display.init_cursor]
373
        add     esp, 4
373
        add     esp, 4
374
 
374
 
375
        mov     eax, [.hcursor]
375
        mov     eax, [.hcursor]
376
;--------------------------------------
376
;--------------------------------------
377
align 4
377
align 4
378
.fail:
378
.fail:
379
        add     esp, 12
379
        add     esp, 12
380
        ret
380
        ret
381
;--------------------------------------
381
;--------------------------------------
382
align 4
382
align 4
383
.indirect:
383
.indirect:
384
        shr     ebx, 16
384
        shr     ebx, 16
385
        movzx   ecx, bh
385
        movzx   ecx, bh
386
        movzx   edx, bl
386
        movzx   edx, bl
387
        mov     [edi+CURSOR.hot_x], ecx
387
        mov     [edi+CURSOR.hot_x], ecx
388
        mov     [edi+CURSOR.hot_y], edx
388
        mov     [edi+CURSOR.hot_y], edx
389
 
389
 
390
        xchg    edi, eax
390
        xchg    edi, eax
391
        mov     ecx, 1024
391
        mov     ecx, 1024
392
        cld
392
        cld
393
        rep movsd
393
        rep movsd
394
        jmp     .add_cursor
394
        jmp     .add_cursor
395
;------------------------------------------------------------------------------
395
;------------------------------------------------------------------------------
396
align 4
396
align 4
397
proc load_cursor stdcall, src:dword, flags:dword
397
proc load_cursor stdcall, src:dword, flags:dword
398
           locals
398
           locals
399
             handle  dd ?
399
             handle  dd ?
400
           endl
400
           endl
401
 
401
 
402
        xor     eax, eax
402
        xor     eax, eax
403
        cmp     [create_cursor], eax
403
        cmp     [create_cursor], eax
404
        je      .fail2
404
        je      .fail2
405
 
405
 
406
        mov     [handle], eax
406
        mov     [handle], eax
407
        cmp     word [flags], LOAD_FROM_FILE
407
        cmp     word [flags], LOAD_FROM_FILE
408
        jne     @F
408
        jne     @F
409
 
409
 
410
        stdcall load_file, [src]
410
        stdcall load_file, [src]
411
        test    eax, eax
411
        test    eax, eax
412
        jz      .fail
412
        jz      .fail
413
        mov     [src], eax
413
        mov     [src], eax
414
;--------------------------------------
414
;--------------------------------------
415
align 4
415
align 4
416
@@:
416
@@:
417
        push    ebx
417
        push    ebx
418
        push    esi
418
        push    esi
419
        push    edi
419
        push    edi
420
 
420
 
421
        mov     eax, [CURRENT_TASK]
421
        mov     eax, [CURRENT_TASK]
422
        shl     eax, 5
422
        shl     eax, 5
423
        mov     eax, [CURRENT_TASK+eax+4]
423
        mov     eax, [CURRENT_TASK+eax+4]
424
        mov     ebx, [src]
424
        mov     ebx, [src]
425
        mov     ecx, [flags]
425
        mov     ecx, [flags]
426
        call    create_cursor    ;eax, ebx, ecx
426
        call    create_cursor    ;eax, ebx, ecx
427
        mov     [handle], eax
427
        mov     [handle], eax
428
 
428
 
429
        cmp     word [flags], LOAD_FROM_FILE
429
        cmp     word [flags], LOAD_FROM_FILE
430
        jne     .exit
430
        jne     .exit
431
        stdcall kernel_free, [src]
431
        stdcall kernel_free, [src]
432
;--------------------------------------
432
;--------------------------------------
433
align 4
433
align 4
434
.exit:
434
.exit:
435
        pop     edi
435
        pop     edi
436
        pop     esi
436
        pop     esi
437
        pop     ebx
437
        pop     ebx
438
;--------------------------------------
438
;--------------------------------------
439
align 4
439
align 4
440
.fail:
440
.fail:
441
        mov     eax, [handle]
441
        mov     eax, [handle]
442
;--------------------------------------
442
;--------------------------------------
443
align 4
443
align 4
444
.fail2:
444
.fail2:
445
        ret
445
        ret
446
endp
446
endp
447
;------------------------------------------------------------------------------
447
;------------------------------------------------------------------------------
448
align 4
448
align 4
449
proc delete_cursor stdcall, hcursor:dword
449
proc delete_cursor stdcall, hcursor:dword
450
           locals
-
 
451
             hsrv       dd ?
-
 
-
 
450
 
452
             io_code    dd ?
451
;        DEBUGF 1,'K : delete_cursor %x\n', [hcursor]
453
             input      dd ?
-
 
454
             inp_size   dd ?
-
 
455
             output     dd ?
-
 
456
             out_size   dd ?
-
 
457
           endl
-
 
458
 
452
 
-
 
453
        mov     esi, [hcursor]
459
        mov     esi, [hcursor]
454
 
460
        cmp     [esi+CURSOR.magic], 'CURS'
455
        cmp     [esi+CURSOR.magic], 'CURS'
461
        jne     .fail
456
        jne     .fail
462
 
457
 
463
        mov     ebx, [CURRENT_TASK]
458
        mov     ebx, [CURRENT_TASK]
464
        shl     ebx, 5
459
        shl     ebx, 5
465
        mov     ebx, [CURRENT_TASK+ebx+4]
460
        mov     ebx, [CURRENT_TASK+ebx+4]
466
        cmp     ebx, [esi+CURSOR.pid]
461
        cmp     ebx, [esi+CURSOR.pid]
467
        jne     .fail
462
        jne     .fail
468
 
463
 
469
        mov     ebx, [current_slot]
464
        mov     ebx, [current_slot]
470
        cmp     esi, [ebx+APPDATA.cursor]
465
        cmp     esi, [ebx+APPDATA.cursor]
471
        jne     @F
466
        jne     @F
472
        mov     eax, [def_cursor]
467
        mov     eax, [def_cursor]
473
        mov     [ebx+APPDATA.cursor], eax
468
        mov     [ebx+APPDATA.cursor], eax
474
;--------------------------------------
469
;--------------------------------------
475
align 4
470
align 4
476
@@:
471
@@:
477
        mov     eax, [hcursor]
472
        mov     eax, [hcursor]
478
        call    [eax+APPOBJ.destroy]
473
        call    [eax+APPOBJ.destroy]
479
;--------------------------------------
474
;--------------------------------------
480
align 4
475
align 4
481
.fail:
476
.fail:
482
        ret
477
        ret
483
endp
478
endp
484
;------------------------------------------------------------------------------
479
;------------------------------------------------------------------------------
485
align 4
480
align 4
486
; param
481
; param
487
;  eax= cursor
482
;  eax= cursor
488
destroy_cursor:
483
destroy_cursor:
489
 
484
 
490
        push    eax
485
        push    eax
491
        stdcall kernel_free, [eax+CURSOR.base]
486
        stdcall kernel_free, [eax+CURSOR.base]
492
 
487
 
493
        mov     eax, [esp]
488
        mov     eax, [esp]
494
        lea     eax, [eax+CURSOR.list_next]
489
        lea     eax, [eax+CURSOR.list_next]
495
 
490
 
496
        pushfd
491
        pushfd
497
        cli
492
        cli
498
        list_del eax
493
        list_del eax
499
        popfd
494
        popfd
500
 
495
 
501
        pop     eax
496
        pop     eax
502
        call    destroy_kernel_object
497
        call    destroy_kernel_object
503
        ret
498
        ret
504
;------------------------------------------------------------------------------
499
;------------------------------------------------------------------------------
505
align 4
500
align 4
506
select_cursor:
501
select_cursor:
507
        mov     eax, [esp+4]
502
        mov     eax, [esp+4]
508
        mov     [_display.cursor], eax
503
        mov     [_display.cursor], eax
509
        ret     4
504
        ret     4
510
;------------------------------------------------------------------------------
505
;------------------------------------------------------------------------------
511
align 4
506
align 4
512
proc restore_24 stdcall, x:dword, y:dword
507
proc restore_24 stdcall, x:dword, y:dword
513
 
508
 
514
        push    ebx
509
        push    ebx
515
 
510
 
516
        mov     ebx, [cur_saved_base]
511
        mov     ebx, [cur_saved_base]
517
        mov     edx, [cur.h]
512
        mov     edx, [cur.h]
518
        test    edx, edx
513
        test    edx, edx
519
        jz      .ret
514
        jz      .ret
520
 
515
 
521
        push    esi
516
        push    esi
522
        push    edi
517
        push    edi
523
 
518
 
524
        mov     esi, cur_saved_data
519
        mov     esi, cur_saved_data
525
        mov     ecx, [cur.w]
520
        mov     ecx, [cur.w]
526
        lea     ecx, [ecx+ecx*2]
521
        lea     ecx, [ecx+ecx*2]
527
        push    ecx
522
        push    ecx
528
;--------------------------------------
523
;--------------------------------------
529
align 4
524
align 4
530
@@:
525
@@:
531
        mov     edi, ebx
526
        mov     edi, ebx
532
        add     ebx, [BytesPerScanLine]
527
        add     ebx, [BytesPerScanLine]
533
 
528
 
534
        mov     ecx, [esp]
529
        mov     ecx, [esp]
535
        rep movsb
530
        rep movsb
536
        dec     edx
531
        dec     edx
537
        jnz     @B
532
        jnz     @B
538
 
533
 
539
        pop     ecx
534
        pop     ecx
540
        pop     edi
535
        pop     edi
541
        pop     esi
536
        pop     esi
542
;--------------------------------------
537
;--------------------------------------
543
align 4
538
align 4
544
.ret:
539
.ret:
545
        pop     ebx
540
        pop     ebx
546
        ret
541
        ret
547
endp
542
endp
548
;------------------------------------------------------------------------------
543
;------------------------------------------------------------------------------
549
align 4
544
align 4
550
proc restore_32 stdcall, x:dword, y:dword
545
proc restore_32 stdcall, x:dword, y:dword
551
 
546
 
552
        push    ebx
547
        push    ebx
553
 
548
 
554
        mov     ebx, [cur_saved_base]
549
        mov     ebx, [cur_saved_base]
555
        mov     edx, [cur.h]
550
        mov     edx, [cur.h]
556
        test    edx, edx
551
        test    edx, edx
557
        jz      .ret
552
        jz      .ret
558
 
553
 
559
        push    esi
554
        push    esi
560
        push    edi
555
        push    edi
561
 
556
 
562
        mov     esi, cur_saved_data
557
        mov     esi, cur_saved_data
563
;--------------------------------------
558
;--------------------------------------
564
align 4
559
align 4
565
@@:
560
@@:
566
        mov     edi, ebx
561
        mov     edi, ebx
567
        add     ebx, [BytesPerScanLine]
562
        add     ebx, [BytesPerScanLine]
568
 
563
 
569
        mov     ecx, [cur.w]
564
        mov     ecx, [cur.w]
570
        rep movsd
565
        rep movsd
571
        dec     edx
566
        dec     edx
572
        jnz     @B
567
        jnz     @B
573
 
568
 
574
        pop     edi
569
        pop     edi
575
;--------------------------------------
570
;--------------------------------------
576
align 4
571
align 4
577
.ret:
572
.ret:
578
        pop     esi
573
        pop     esi
579
        pop     ebx
574
        pop     ebx
580
        ret
575
        ret
581
endp
576
endp
582
;------------------------------------------------------------------------------
577
;------------------------------------------------------------------------------
583
align 4
578
align 4
584
proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
579
proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
585
           locals
580
           locals
586
             h      dd ?
581
             h      dd ?
587
             _dx     dd ?
582
             _dx     dd ?
588
             _dy     dd ?
583
             _dy     dd ?
589
           endl
584
           endl
590
 
585
 
591
        mov     esi, [hcursor]
586
        mov     esi, [hcursor]
592
        mov     ecx, [x]
587
        mov     ecx, [x]
593
        mov     eax, [y]
588
        mov     eax, [y]
594
;        mov     ebx, [BytesPerScanLine]
589
;        mov     ebx, [BytesPerScanLine]
595
 
590
 
596
        xor     edx, edx
591
        xor     edx, edx
597
        sub     ecx, [esi+CURSOR.hot_x]
592
        sub     ecx, [esi+CURSOR.hot_x]
598
        lea     ebx, [ecx+32-1]
593
        lea     ebx, [ecx+32-1]
599
        mov     [x], ecx
594
        mov     [x], ecx
600
        sets    dl
595
        sets    dl
601
        dec     edx
596
        dec     edx
602
        and     ecx, edx      ;clip x to 0<=x
597
        and     ecx, edx      ;clip x to 0<=x
603
        mov     [cur.left], ecx
598
        mov     [cur.left], ecx
604
        mov     edi, ecx
599
        mov     edi, ecx
605
        sub     edi, [x]
600
        sub     edi, [x]
606
        mov     [_dx], edi
601
        mov     [_dx], edi
607
 
602
 
608
        xor     edx, edx
603
        xor     edx, edx
609
        sub     eax, [esi+CURSOR.hot_y]
604
        sub     eax, [esi+CURSOR.hot_y]
610
        lea     edi, [eax+32-1]
605
        lea     edi, [eax+32-1]
611
        mov     [y], eax
606
        mov     [y], eax
612
        sets    dl
607
        sets    dl
613
        dec     edx
608
        dec     edx
614
        and     eax, edx      ;clip y to 0<=y
609
        and     eax, edx      ;clip y to 0<=y
615
        mov     [cur.top], eax
610
        mov     [cur.top], eax
616
        mov     edx, eax
611
        mov     edx, eax
617
        sub     edx, [y]
612
        sub     edx, [y]
618
        mov     [_dy], edx
613
        mov     [_dy], edx
619
 
614
 
620
;        mul     dword [BytesPerScanLine]
615
;        mul     dword [BytesPerScanLine]
621
        mov     eax, [BPSLine_calc_area+eax*4]
616
        mov     eax, [BPSLine_calc_area+eax*4]
622
        lea     edx, [LFB_BASE+ecx*3]
617
        lea     edx, [LFB_BASE+ecx*3]
623
        add     edx, eax
618
        add     edx, eax
624
        mov     [cur_saved_base], edx
619
        mov     [cur_saved_base], edx
625
 
620
 
626
        cmp     ebx, [Screen_Max_X]
621
        cmp     ebx, [Screen_Max_X]
627
        jbe     @F
622
        jbe     @F
628
        mov     ebx, [Screen_Max_X]
623
        mov     ebx, [Screen_Max_X]
629
;--------------------------------------
624
;--------------------------------------
630
align 4
625
align 4
631
@@:
626
@@:
632
        cmp     edi, [Screen_Max_Y]
627
        cmp     edi, [Screen_Max_Y]
633
        jbe     @F
628
        jbe     @F
634
        mov     edi, [Screen_Max_Y]
629
        mov     edi, [Screen_Max_Y]
635
;--------------------------------------
630
;--------------------------------------
636
align 4
631
align 4
637
@@:
632
@@:
638
        mov     [cur.right], ebx
633
        mov     [cur.right], ebx
639
        mov     [cur.bottom], edi
634
        mov     [cur.bottom], edi
640
 
635
 
641
        sub     ebx, [x]
636
        sub     ebx, [x]
642
        sub     edi, [y]
637
        sub     edi, [y]
643
        inc     ebx
638
        inc     ebx
644
        inc     edi
639
        inc     edi
645
        sub     ebx, [_dx]
640
        sub     ebx, [_dx]
646
        sub     edi, [_dy]
641
        sub     edi, [_dy]
647
 
642
 
648
        mov     [cur.w], ebx
643
        mov     [cur.w], ebx
649
        mov     [cur.h], edi
644
        mov     [cur.h], edi
650
        mov     [h], edi
645
        mov     [h], edi
651
 
646
 
652
        mov     eax, edi
647
        mov     eax, edi
653
        mov     edi, cur_saved_data
648
        mov     edi, cur_saved_data
654
;--------------------------------------
649
;--------------------------------------
655
align 4
650
align 4
656
@@:
651
@@:
657
        mov     esi, edx
652
        mov     esi, edx
658
        add     edx, [BytesPerScanLine]
653
        add     edx, [BytesPerScanLine]
659
        mov     ecx, [cur.w]
654
        mov     ecx, [cur.w]
660
        lea     ecx, [ecx+ecx*2]
655
        lea     ecx, [ecx+ecx*2]
661
        rep movsb
656
        rep movsb
662
        dec     eax
657
        dec     eax
663
        jnz     @B
658
        jnz     @B
664
 
659
 
665
;draw cursor
660
;draw cursor
666
        mov     ebx, [cur_saved_base]
661
        mov     ebx, [cur_saved_base]
667
        mov     eax, [_dy]
662
        mov     eax, [_dy]
668
        shl     eax, 5
663
        shl     eax, 5
669
        add     eax, [_dx]
664
        add     eax, [_dx]
670
 
665
 
671
        mov     esi, [hcursor]
666
        mov     esi, [hcursor]
672
        mov     esi, [esi+CURSOR.base]
667
        mov     esi, [esi+CURSOR.base]
673
        lea     edx, [esi+eax*4]
668
        lea     edx, [esi+eax*4]
674
;--------------------------------------
669
;--------------------------------------
675
align 4
670
align 4
676
.row:
671
.row:
677
        mov     ecx, [cur.w]
672
        mov     ecx, [cur.w]
678
        mov     esi, edx
673
        mov     esi, edx
679
        mov     edi, ebx
674
        mov     edi, ebx
680
        add     edx, 32*4
675
        add     edx, 32*4
681
        add     ebx, [BytesPerScanLine]
676
        add     ebx, [BytesPerScanLine]
682
;--------------------------------------
677
;--------------------------------------
683
align 4
678
align 4
684
.pix:
679
.pix:
685
        lodsd
680
        lodsd
686
        test    eax, 0xFF000000
681
        test    eax, 0xFF000000
687
        jz      @F
682
        jz      @F
688
        mov     [edi], ax
683
        mov     [edi], ax
689
        shr     eax, 16
684
        shr     eax, 16
690
        mov     [edi+2], al
685
        mov     [edi+2], al
691
;--------------------------------------
686
;--------------------------------------
692
align 4
687
align 4
693
@@:
688
@@:
694
        add     edi, 3
689
        add     edi, 3
695
        dec     ecx
690
        dec     ecx
696
        jnz     .pix
691
        jnz     .pix
697
 
692
 
698
        dec     [h]
693
        dec     [h]
699
        jnz     .row
694
        jnz     .row
700
        ret
695
        ret
701
endp
696
endp
702
;------------------------------------------------------------------------------
697
;------------------------------------------------------------------------------
703
align 4
698
align 4
704
proc move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
699
proc move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
705
           locals
700
           locals
706
             h      dd ?
701
             h      dd ?
707
             _dx     dd ?
702
             _dx     dd ?
708
             _dy     dd ?
703
             _dy     dd ?
709
           endl
704
           endl
710
 
705
 
711
        mov     esi, [hcursor]
706
        mov     esi, [hcursor]
712
        mov     ecx, [x]
707
        mov     ecx, [x]
713
        mov     eax, [y]
708
        mov     eax, [y]
714
 
709
 
715
        xor     edx, edx
710
        xor     edx, edx
716
        sub     ecx, [esi+CURSOR.hot_x]
711
        sub     ecx, [esi+CURSOR.hot_x]
717
        lea     ebx, [ecx+32-1]
712
        lea     ebx, [ecx+32-1]
718
        mov     [x], ecx
713
        mov     [x], ecx
719
        sets    dl
714
        sets    dl
720
        dec     edx
715
        dec     edx
721
        and     ecx, edx      ;clip x to 0<=x
716
        and     ecx, edx      ;clip x to 0<=x
722
        mov     [cur.left], ecx
717
        mov     [cur.left], ecx
723
        mov     edi, ecx
718
        mov     edi, ecx
724
        sub     edi, [x]
719
        sub     edi, [x]
725
        mov     [_dx], edi
720
        mov     [_dx], edi
726
 
721
 
727
        xor     edx, edx
722
        xor     edx, edx
728
        sub     eax, [esi+CURSOR.hot_y]
723
        sub     eax, [esi+CURSOR.hot_y]
729
        lea     edi, [eax+32-1]
724
        lea     edi, [eax+32-1]
730
        mov     [y], eax
725
        mov     [y], eax
731
        sets    dl
726
        sets    dl
732
        dec     edx
727
        dec     edx
733
        and     eax, edx      ;clip y to 0<=y
728
        and     eax, edx      ;clip y to 0<=y
734
        mov     [cur.top], eax
729
        mov     [cur.top], eax
735
        mov     edx, eax
730
        mov     edx, eax
736
        sub     edx, [y]
731
        sub     edx, [y]
737
        mov     [_dy], edx
732
        mov     [_dy], edx
738
 
733
 
739
;        mul     dword [BytesPerScanLine]
734
;        mul     dword [BytesPerScanLine]
740
        mov     eax, [BPSLine_calc_area+eax*4]
735
        mov     eax, [BPSLine_calc_area+eax*4]
741
        lea     edx, [LFB_BASE+eax+ecx*4]
736
        lea     edx, [LFB_BASE+eax+ecx*4]
742
        mov     [cur_saved_base], edx
737
        mov     [cur_saved_base], edx
743
 
738
 
744
        cmp     ebx, [Screen_Max_X]
739
        cmp     ebx, [Screen_Max_X]
745
        jbe     @F
740
        jbe     @F
746
        mov     ebx, [Screen_Max_X]
741
        mov     ebx, [Screen_Max_X]
747
;--------------------------------------
742
;--------------------------------------
748
align 4
743
align 4
749
@@:
744
@@:
750
        cmp     edi, [Screen_Max_Y]
745
        cmp     edi, [Screen_Max_Y]
751
        jbe     @F
746
        jbe     @F
752
        mov     edi, [Screen_Max_Y]
747
        mov     edi, [Screen_Max_Y]
753
;--------------------------------------
748
;--------------------------------------
754
align 4
749
align 4
755
@@:
750
@@:
756
        mov     [cur.right], ebx
751
        mov     [cur.right], ebx
757
        mov     [cur.bottom], edi
752
        mov     [cur.bottom], edi
758
 
753
 
759
        sub     ebx, [x]
754
        sub     ebx, [x]
760
        sub     edi, [y]
755
        sub     edi, [y]
761
        inc     ebx
756
        inc     ebx
762
        inc     edi
757
        inc     edi
763
        sub     ebx, [_dx]
758
        sub     ebx, [_dx]
764
        sub     edi, [_dy]
759
        sub     edi, [_dy]
765
 
760
 
766
        mov     [cur.w], ebx
761
        mov     [cur.w], ebx
767
        mov     [cur.h], edi
762
        mov     [cur.h], edi
768
        mov     [h], edi
763
        mov     [h], edi
769
 
764
 
770
        mov     eax, edi
765
        mov     eax, edi
771
        mov     edi, cur_saved_data
766
        mov     edi, cur_saved_data
772
;--------------------------------------
767
;--------------------------------------
773
align 4
768
align 4
774
@@:
769
@@:
775
        mov     esi, edx
770
        mov     esi, edx
776
        add     edx, [BytesPerScanLine]
771
        add     edx, [BytesPerScanLine]
777
        mov     ecx, [cur.w]
772
        mov     ecx, [cur.w]
778
        rep movsd
773
        rep movsd
779
        dec     eax
774
        dec     eax
780
        jnz     @B
775
        jnz     @B
781
 
776
 
782
;draw cursor
777
;draw cursor
783
        mov     ebx, [cur_saved_base]
778
        mov     ebx, [cur_saved_base]
784
        mov     eax, [_dy]
779
        mov     eax, [_dy]
785
        shl     eax, 5
780
        shl     eax, 5
786
        add     eax, [_dx]
781
        add     eax, [_dx]
787
 
782
 
788
        mov     esi, [hcursor]
783
        mov     esi, [hcursor]
789
        mov     esi, [esi+CURSOR.base]
784
        mov     esi, [esi+CURSOR.base]
790
        lea     edx, [esi+eax*4]
785
        lea     edx, [esi+eax*4]
791
;--------------------------------------
786
;--------------------------------------
792
align 4
787
align 4
793
.row:
788
.row:
794
        mov     ecx, [cur.w]
789
        mov     ecx, [cur.w]
795
        mov     esi, edx
790
        mov     esi, edx
796
        mov     edi, ebx
791
        mov     edi, ebx
797
        add     edx, 32*4
792
        add     edx, 32*4
798
        add     ebx, [BytesPerScanLine]
793
        add     ebx, [BytesPerScanLine]
799
;--------------------------------------
794
;--------------------------------------
800
align 4
795
align 4
801
.pix:
796
.pix:
802
        lodsd
797
        lodsd
803
        test    eax, 0xFF000000
798
        test    eax, 0xFF000000
804
        jz      @F
799
        jz      @F
805
        mov     [edi], eax
800
        mov     [edi], eax
806
;--------------------------------------
801
;--------------------------------------
807
align 4
802
align 4
808
@@:
803
@@:
809
        add     edi, 4
804
        add     edi, 4
810
        dec     ecx
805
        dec     ecx
811
        jnz     .pix
806
        jnz     .pix
812
 
807
 
813
        dec     [h]
808
        dec     [h]
814
        jnz     .row
809
        jnz     .row
815
        ret
810
        ret
816
endp
811
endp
817
;------------------------------------------------------------------------------
812
;------------------------------------------------------------------------------
818
align 4
813
align 4
819
check_mouse_area_for_getpixel_new:
814
check_mouse_area_for_getpixel_new:
820
; in:
815
; in:
821
; eax = x
816
; eax = x
822
; ebx = y
817
; ebx = y
823
; out:
818
; out:
824
; ecx = new color
819
; ecx = new color
825
;--------------------------------------
820
;--------------------------------------
826
; check for Y
821
; check for Y
827
        cmp     bx, [Y_UNDER_subtraction_CUR_hot_y]
822
        cmp     bx, [Y_UNDER_subtraction_CUR_hot_y]
828
        jb      .no_mouse_area
823
        jb      .no_mouse_area
829
 
824
 
830
        cmp     bx, [Y_UNDER_sub_CUR_hot_y_add_curh]
825
        cmp     bx, [Y_UNDER_sub_CUR_hot_y_add_curh]
831
        jae     .no_mouse_area
826
        jae     .no_mouse_area
832
;--------------------------------------
827
;--------------------------------------
833
; check for X
828
; check for X
834
        cmp     ax, [X_UNDER_subtraction_CUR_hot_x]
829
        cmp     ax, [X_UNDER_subtraction_CUR_hot_x]
835
        jb      .no_mouse_area
830
        jb      .no_mouse_area
836
 
831
 
837
        cmp     ax, [X_UNDER_sub_CUR_hot_x_add_curh]
832
        cmp     ax, [X_UNDER_sub_CUR_hot_x_add_curh]
838
        jae     .no_mouse_area
833
        jae     .no_mouse_area
839
;--------------------------------------
834
;--------------------------------------
840
        push    eax ebx
835
        push    eax ebx
841
; offset X
836
; offset X
842
        movzx   ecx, word [X_UNDER_subtraction_CUR_hot_x]
837
        movzx   ecx, word [X_UNDER_subtraction_CUR_hot_x]
843
        sub     eax, ecx        ; x1
838
        sub     eax, ecx        ; x1
844
; offset Y
839
; offset Y
845
        movzx   ecx, word [Y_UNDER_subtraction_CUR_hot_y]
840
        movzx   ecx, word [Y_UNDER_subtraction_CUR_hot_y]
846
        sub     ebx, ecx        ; y1
841
        sub     ebx, ecx        ; y1
847
;--------------------------------------
842
;--------------------------------------
848
; ebx = offset y
843
; ebx = offset y
849
; eax = offset x
844
; eax = offset x
850
        imul    ebx, [cur.w]     ;y
845
        imul    ebx, [cur.w]     ;y
851
        add     eax, ebx
846
        add     eax, ebx
852
        mov     ebx, eax
847
        mov     ebx, eax
853
        shl     eax, 2
848
        shl     eax, 2
854
        cmp     [ScreenBPP], byte 32
849
        cmp     [ScreenBPP], byte 32
855
        je      @f
850
        je      @f
856
        sub     eax, ebx
851
        sub     eax, ebx
857
;--------------------------------------
852
;--------------------------------------
858
align 4
853
align 4
859
@@:
854
@@:
860
        add     eax, cur_saved_data
855
        add     eax, cur_saved_data
861
        mov     ecx, [eax]
856
        mov     ecx, [eax]
862
        and     ecx, 0xffffff
857
        and     ecx, 0xffffff
863
        add     ecx, 0xff000000
858
        add     ecx, 0xff000000
864
        pop     ebx eax
859
        pop     ebx eax
865
        ret
860
        ret
866
;--------------------------------------
861
;--------------------------------------
867
align 4
862
align 4
868
.no_mouse_area:
863
.no_mouse_area:
869
        xor     ecx, ecx
864
        xor     ecx, ecx
870
        ret
865
        ret
871
;-----------------------------------------------------------------------------
866
;-----------------------------------------------------------------------------
872
align 4
867
align 4
873
check_mouse_area_for_putpixel_new:
868
check_mouse_area_for_putpixel_new:
874
; in:
869
; in:
875
; ecx = x shl 16 + y
870
; ecx = x shl 16 + y
876
; eax = color
871
; eax = color
877
; out:
872
; out:
878
; eax = new color
873
; eax = new color
879
;--------------------------------------
874
;--------------------------------------
880
; check for Y
875
; check for Y
881
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
876
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
882
        jae     .no_mouse_area
877
        jae     .no_mouse_area
883
 
878
 
884
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
879
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
885
        jb      .no_mouse_area
880
        jb      .no_mouse_area
886
 
881
 
887
        rol     ecx, 16
882
        rol     ecx, 16
888
;--------------------------------------
883
;--------------------------------------
889
; check for X
884
; check for X
890
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
885
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
891
        jae     .no_mouse_area
886
        jae     .no_mouse_area
892
 
887
 
893
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
888
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
894
        jb      .no_mouse_area
889
        jb      .no_mouse_area
895
 
890
 
896
        ror     ecx, 16
891
        ror     ecx, 16
897
;--------------------------------------
892
;--------------------------------------
898
align 4
893
align 4
899
.1:
894
.1:
900
        push    eax
895
        push    eax
901
;--------------------------------------
896
;--------------------------------------
902
; ecx = (offset x) shl 16 + (offset y)
897
; ecx = (offset x) shl 16 + (offset y)
903
        push    ebx
898
        push    ebx
904
        mov     ebx, ecx
899
        mov     ebx, ecx
905
        shr     ebx, 16        ; x
900
        shr     ebx, 16        ; x
906
        and     ecx, 0xffff    ; y
901
        and     ecx, 0xffff    ; y
907
 
902
 
908
        cmp     ecx, [cur.h]
903
        cmp     ecx, [cur.h]
909
        jae     @f
904
        jae     @f
910
 
905
 
911
        cmp     ebx, [cur.w]
906
        cmp     ebx, [cur.w]
912
        jb      .ok
907
        jb      .ok
913
;--------------------------------------
908
;--------------------------------------
914
align 4
909
align 4
915
@@:
910
@@:
916
;        DEBUGF  1, "K : SHIT HAPPENS: %x %x \n", ecx,ebx
911
;        DEBUGF  1, "K : SHIT HAPPENS: %x %x \n", ecx,ebx
917
        pop     ebx
912
        pop     ebx
918
        jmp     .sh   ; SORRY! SHIT HAPPENS!
913
        jmp     .sh   ; SORRY! SHIT HAPPENS!
919
;--------------------------------------
914
;--------------------------------------
920
align 4
915
align 4
921
.ok:
916
.ok:
922
; ecx = offset y
917
; ecx = offset y
923
; ebx = offset x
918
; ebx = offset x
924
        push    ebx ecx
919
        push    ebx ecx
925
        imul    ecx, [cur.w]    ;y
920
        imul    ecx, [cur.w]    ;y
926
        add     ecx, ebx
921
        add     ecx, ebx
927
        mov     ebx, ecx
922
        mov     ebx, ecx
928
        shl     ecx, 2
923
        shl     ecx, 2
929
        cmp     [ScreenBPP], byte 24
924
        cmp     [ScreenBPP], byte 24
930
        je      .24
925
        je      .24
931
        and     eax, 0xFFFFFF
926
        and     eax, 0xFFFFFF
932
        mov     [ecx + cur_saved_data], eax   ;store new color  to
927
        mov     [ecx + cur_saved_data], eax   ;store new color  to
933
        jmp     @f
928
        jmp     @f
934
;--------------------------------------
929
;--------------------------------------
935
align 4
930
align 4
936
.24:
931
.24:
937
        sub     ecx, ebx
932
        sub     ecx, ebx
938
        mov     [ecx + cur_saved_data], ax      ;store new color  to
933
        mov     [ecx + cur_saved_data], ax      ;store new color  to
939
        shr     eax, 16
934
        shr     eax, 16
940
        mov     [ecx + cur_saved_data + 2], al  ;store new color  to
935
        mov     [ecx + cur_saved_data + 2], al  ;store new color  to
941
;--------------------------------------
936
;--------------------------------------
942
align 4
937
align 4
943
@@:
938
@@:
944
        pop     ecx ebx
939
        pop     ecx ebx
945
 
940
 
946
        shl     ecx, 5
941
        shl     ecx, 5
947
        add     ecx, ebx
942
        add     ecx, ebx
948
 
943
 
949
        mov     eax, [current_cursor]
944
        mov     eax, [current_cursor]
950
        mov     eax, [eax+CURSOR.base]
945
        mov     eax, [eax+CURSOR.base]
951
        lea     eax, [eax+ecx*4]
946
        lea     eax, [eax+ecx*4]
952
        mov     eax, [eax]
947
        mov     eax, [eax]
953
 
948
 
954
        pop     ebx
949
        pop     ebx
955
 
950
 
956
        test    eax, 0xFF000000
951
        test    eax, 0xFF000000
957
        jz      @f
952
        jz      @f
958
 
953
 
959
        add     esp, 4
954
        add     esp, 4
960
        ret
955
        ret
961
;--------------------------------------
956
;--------------------------------------
962
align 4
957
align 4
963
.sh:
958
.sh:
964
        mov     ecx, -1
959
        mov     ecx, -1
965
;--------------------------------------
960
;--------------------------------------
966
align 4
961
align 4
967
@@:
962
@@:
968
        pop     eax
963
        pop     eax
969
;--------------------------------------
964
;--------------------------------------
970
align 4
965
align 4
971
.no_mouse_area:
966
.no_mouse_area:
972
        ret
967
        ret
973
;------------------------------------------------------------------------------
968
;------------------------------------------------------------------------------
974
align 4
969
align 4
975
get_display:
970
get_display:
976
        mov     eax, _display
971
        mov     eax, _display
977
        ret
972
        ret
978
;------------------------------------------------------------------------------
973
;------------------------------------------------------------------------------
979
align 4
974
align 4
980
init_display:
975
init_display:
981
        xor     eax, eax
976
        xor     eax, eax
982
        mov     edi, _display
977
        mov     edi, _display
983
 
978
 
984
        mov     [edi+display_t.init_cursor], eax
979
        mov     [edi+display_t.init_cursor], eax
985
        mov     [edi+display_t.select_cursor], eax
980
        mov     [edi+display_t.select_cursor], eax
986
        mov     [edi+display_t.show_cursor], eax
981
        mov     [edi+display_t.show_cursor], eax
987
        mov     [edi+display_t.move_cursor], eax
982
        mov     [edi+display_t.move_cursor], eax
988
        mov     [edi+display_t.restore_cursor], eax
983
        mov     [edi+display_t.restore_cursor], eax
989
 
984
 
990
        lea     ecx, [edi+display_t.cr_list.next]
985
        lea     ecx, [edi+display_t.cr_list.next]
991
        mov     [edi+display_t.cr_list.next], ecx
986
        mov     [edi+display_t.cr_list.next], ecx
992
        mov     [edi+display_t.cr_list.prev], ecx
987
        mov     [edi+display_t.cr_list.prev], ecx
993
 
988
 
994
        cmp     [SCR_MODE], word 0x13
989
        cmp     [SCR_MODE], word 0x13
995
        jbe     .fail
990
        jbe     .fail
996
 
991
 
997
        test    word [SCR_MODE], 0x4000
992
        test    word [SCR_MODE], 0x4000
998
        jz      .fail
993
        jz      .fail
999
;        jmp      .fail
994
;        jmp      .fail
1000
 
995
 
1001
        mov     ebx, restore_32
996
        mov     ebx, restore_32
1002
        mov     ecx, move_cursor_32
997
        mov     ecx, move_cursor_32
1003
        movzx   eax, byte [ScreenBPP]
998
        movzx   eax, byte [ScreenBPP]
1004
        cmp     eax, 32
999
        cmp     eax, 32
1005
        je      @F
1000
        je      @F
1006
 
1001
 
1007
        mov     ebx, restore_24
1002
        mov     ebx, restore_24
1008
        mov     ecx, move_cursor_24
1003
        mov     ecx, move_cursor_24
1009
        cmp     eax, 24
1004
        cmp     eax, 24
1010
        jne     .fail
1005
        jne     .fail
1011
;--------------------------------------
1006
;--------------------------------------
1012
align 4
1007
align 4
1013
@@:
1008
@@:
1014
        mov     [_display.select_cursor], select_cursor
1009
        mov     [_display.select_cursor], select_cursor
1015
        mov     [_display.move_cursor], ecx
1010
        mov     [_display.move_cursor], ecx
1016
        mov     [_display.restore_cursor], ebx
1011
        mov     [_display.restore_cursor], ebx
1017
        mov     [_display.check_mouse], check_mouse_area_for_putpixel_new
1012
        mov     [_display.check_mouse], check_mouse_area_for_putpixel_new
1018
        mov     [_display.check_m_pixel], check_mouse_area_for_getpixel_new
1013
        mov     [_display.check_m_pixel], check_mouse_area_for_getpixel_new
1019
 
1014
 
1020
        cmp     [PUTPIXEL], dword VGA_putpixel
1015
        cmp     [PUTPIXEL], dword VGA_putpixel
1021
        je      @f
1016
        je      @f
1022
        cmp     [ScreenBPP], byte 32
1017
        cmp     [ScreenBPP], byte 32
1023
        je      .32
1018
        je      .32
1024
        mov     [PUTPIXEL], dword Vesa20_putpixel24_new
1019
        mov     [PUTPIXEL], dword Vesa20_putpixel24_new
1025
        jmp     @f
1020
        jmp     @f
1026
;--------------------------------------
1021
;--------------------------------------
1027
align 4
1022
align 4
1028
.32:
1023
.32:
1029
        mov     [PUTPIXEL], dword Vesa20_putpixel32_new
1024
        mov     [PUTPIXEL], dword Vesa20_putpixel32_new
1030
;--------------------------------------
1025
;--------------------------------------
1031
align 4
1026
align 4
1032
@@:
1027
@@:
1033
        stdcall load_cursor, clock_arrow, dword LOAD_FROM_MEM
1028
        stdcall load_cursor, clock_arrow, dword LOAD_FROM_MEM
1034
        mov     [def_cursor_clock], eax
1029
        mov     [def_cursor_clock], eax
1035
        stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
1030
        stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
1036
        mov     [def_cursor], eax
1031
        mov     [def_cursor], eax
1037
        ret
1032
        ret
1038
;--------------------------------------
1033
;--------------------------------------
1039
align 4
1034
align 4
1040
.fail:
1035
.fail:
1041
        xor     eax, eax
1036
        xor     eax, eax
1042
        mov     [_display.select_cursor], eax
1037
        mov     [_display.select_cursor], eax
1043
        mov     [_display.move_cursor], eax
1038
        mov     [_display.move_cursor], eax
1044
        ret
1039
        ret
1045
;------------------------------------------------------------------------------
1040
;------------------------------------------------------------------------------
1046
align 4
1041
align 4
1047
def_arrow:
1042
def_arrow:
1048
  file 'arrow.cur'
1043
  file 'arrow.cur'
1049
;------------------------------------------------------------------------------
1044
;------------------------------------------------------------------------------
1050
align 4
1045
align 4
1051
clock_arrow:
1046
clock_arrow:
1052
  file 'arrow_clock.cur'
1047
  file 'arrow_clock.cur'
1053
;------------------------------------------------------------------------------
1048
;------------------------------------------------------------------------------
1054
>
1049
>
1055
>
1050
>
1056
>
1051
>
1057
>
1052
>