Subversion Repositories Kolibri OS

Rev

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

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