Subversion Repositories Kolibri OS

Rev

Rev 9941 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9941 Rev 9958
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2023. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2023. 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: 9941 $
8
$Revision: 9958 $
9
 
9
 
10
 
10
 
11
LOAD_FROM_FILE  = 0
11
LOAD_FROM_FILE  = 0
12
LOAD_FROM_MEM   = 1
12
LOAD_FROM_MEM   = 1
13
LOAD_INDIRECT   = 2
13
LOAD_INDIRECT   = 2
14
LOAD_SYSTEM     = 3
14
LOAD_SYSTEM     = 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
        mov     ebx, [ebx + APPDATA.window]
297
        mov     ebx, [ebx + APPDATA.window]
298
        xchg    eax, [ebx + WDATA.cursor]
298
        xchg    eax, [ebx + WDATA.cursor]
299
        jmp     .end
299
        jmp     .end
300
;--------------------------------------
300
;--------------------------------------
301
align 4
301
align 4
302
.fail:
302
.fail:
303
        mov     eax, [def_cursor]
303
        mov     eax, [def_cursor]
304
        mov     ebx, [current_slot]
304
        mov     ebx, [current_slot]
305
        mov     ebx, [ebx + APPDATA.window]
305
        mov     ebx, [ebx + APPDATA.window]
306
        xchg    eax, [ebx + WDATA.cursor]
306
        xchg    eax, [ebx + WDATA.cursor]
307
align 4
307
align 4
308
.end:
308
.end:
309
        mov     [redrawmouse_unconditional], 1
309
        mov     [redrawmouse_unconditional], 1
310
        call    __sys_draw_pointer
310
        call    __sys_draw_pointer
311
        ret
311
        ret
312
endp
312
endp
313
;------------------------------------------------------------------------------
313
;------------------------------------------------------------------------------
314
align 4
314
align 4
315
; param
315
; param
316
;  eax= pid
316
;  eax= pid
317
;  ebx= src
317
;  ebx= src
318
;  ecx= flags
318
;  ecx= flags
319
 
319
 
320
create_cursor:
320
create_cursor:
321
.src     equ esp
321
.src     equ esp
322
.flags   equ esp+4
322
.flags   equ esp+4
323
.hcursor equ esp+8
323
.hcursor equ esp+8
324
 
324
 
325
        sub     esp, 4         ;space for .hcursor
325
        sub     esp, 4         ;space for .hcursor
326
        push    ecx
326
        push    ecx
327
        push    ebx
327
        push    ebx
328
 
328
 
329
        mov     ebx, eax
329
        mov     ebx, eax
330
        mov     eax, sizeof.CURSOR
330
        mov     eax, sizeof.CURSOR
331
        call    create_kernel_object
331
        call    create_kernel_object
332
        test    eax, eax
332
        test    eax, eax
333
        jz      .fail
333
        jz      .fail
334
 
334
 
335
        mov     [.hcursor], eax
335
        mov     [.hcursor], eax
336
 
336
 
337
        xor     ebx, ebx
337
        xor     ebx, ebx
338
        mov     [eax + CURSOR.magic], 'CURS'
338
        mov     [eax + CURSOR.magic], 'CURS'
339
        mov     [eax + CURSOR.destroy], destroy_cursor
339
        mov     [eax + CURSOR.destroy], destroy_cursor
340
        mov     [eax + CURSOR.hot_x], ebx
340
        mov     [eax + CURSOR.hot_x], ebx
341
        mov     [eax + CURSOR.hot_y], ebx
341
        mov     [eax + CURSOR.hot_y], ebx
342
 
342
 
343
        stdcall kernel_alloc, PAGE_SIZE
343
        stdcall kernel_alloc, PAGE_SIZE
344
        test    eax, eax
344
        test    eax, eax
345
        jz      .fail
345
        jz      .fail
346
 
346
 
347
        mov     edi, [.hcursor]
347
        mov     edi, [.hcursor]
348
        mov     [edi + CURSOR.base], eax
348
        mov     [edi + CURSOR.base], eax
349
 
349
 
350
        mov     esi, [.src]
350
        mov     esi, [.src]
351
        mov     ebx, [.flags]
351
        mov     ebx, [.flags]
352
        cmp     bx, LOAD_INDIRECT
352
        cmp     bx, LOAD_INDIRECT
353
        je      .indirect
353
        je      .indirect
354
 
354
 
355
        movzx   ecx, word [esi+10]
355
        movzx   ecx, word [esi+10]
356
        movzx   edx, word [esi+12]
356
        movzx   edx, word [esi+12]
357
        mov     [edi + CURSOR.hot_x], ecx
357
        mov     [edi + CURSOR.hot_x], ecx
358
        mov     [edi + CURSOR.hot_y], edx
358
        mov     [edi + CURSOR.hot_y], edx
359
 
359
 
360
        stdcall init_cursor, eax, esi
360
        stdcall init_cursor, eax, esi
361
 
361
 
362
align 4
362
align 4
363
.add_cursor:
363
.add_cursor:
364
        mov     ecx, [.hcursor]
364
        mov     ecx, [.hcursor]
365
        lea     ecx, [ecx + CURSOR.list_next]
365
        lea     ecx, [ecx + CURSOR.list_next]
366
        lea     edx, [_display.cr_list.next]
366
        lea     edx, [_display.cr_list.next]
367
 
367
 
368
        pushfd
368
        pushfd
369
        cli
369
        cli
370
        list_add ecx, edx   ;list_add_tail(new, head)
370
        list_add ecx, edx   ;list_add_tail(new, head)
371
        popfd
371
        popfd
372
 
372
 
373
        mov     eax, [.hcursor]
373
        mov     eax, [.hcursor]
374
        cmp     [_display.init_cursor], 0
374
        cmp     [_display.init_cursor], 0
375
        je      .fail
375
        je      .fail
376
 
376
 
377
        push    eax
377
        push    eax
378
        call    [_display.init_cursor]
378
        call    [_display.init_cursor]
379
        add     esp, 4
379
        add     esp, 4
380
 
380
 
381
        mov     eax, [.hcursor]
381
        mov     eax, [.hcursor]
382
;--------------------------------------
382
;--------------------------------------
383
align 4
383
align 4
384
.fail:
384
.fail:
385
        add     esp, 12
385
        add     esp, 12
386
        ret
386
        ret
387
;--------------------------------------
387
;--------------------------------------
388
align 4
388
align 4
389
.indirect:
389
.indirect:
390
        shr     ebx, 16
390
        shr     ebx, 16
391
        movzx   ecx, bh
391
        movzx   ecx, bh
392
        movzx   edx, bl
392
        movzx   edx, bl
393
        mov     [edi + CURSOR.hot_x], ecx
393
        mov     [edi + CURSOR.hot_x], ecx
394
        mov     [edi + CURSOR.hot_y], edx
394
        mov     [edi + CURSOR.hot_y], edx
395
 
395
 
396
        xchg    edi, eax
396
        xchg    edi, eax
397
        mov     ecx, PAGE_SIZE/4
397
        mov     ecx, PAGE_SIZE/4
398
        cld
398
        cld
399
        rep movsd
399
        rep movsd
400
        jmp     .add_cursor
400
        jmp     .add_cursor
401
;------------------------------------------------------------------------------
401
;------------------------------------------------------------------------------
402
align 4
402
align 4
403
proc load_cursor stdcall, src:dword, flags:dword
403
proc load_cursor stdcall, src:dword, flags:dword
404
           locals
404
           locals
405
             handle  dd ?
405
             handle  dd ?
406
           endl
406
           endl
407
 
407
 
408
        xor     eax, eax
408
        xor     eax, eax
409
        cmp     [create_cursor], eax
409
        cmp     [create_cursor], eax
410
        je      .fail2
410
        je      .fail2
411
 
411
 
412
        mov     [handle], eax
412
        mov     [handle], eax
413
        cmp     word [flags], LOAD_FROM_FILE
413
        cmp     word [flags], LOAD_FROM_FILE
414
        jne     @F
414
        jne     @F
415
 
415
 
416
        stdcall load_file, [src]
416
        stdcall load_file, [src]
417
        test    eax, eax
417
        test    eax, eax
418
        jz      .fail
418
        jz      .fail
419
        mov     [src], eax
419
        mov     [src], eax
420
;--------------------------------------
420
;--------------------------------------
421
align 4
421
align 4
422
@@:
422
@@:
423
        push    ebx
423
        push    ebx
424
        push    esi
424
        push    esi
425
        push    edi
425
        push    edi
426
 
426
 
427
        mov     eax, [current_slot]
427
        mov     eax, [current_slot]
428
        mov     eax, [eax + APPDATA.tid]
428
        mov     eax, [eax + APPDATA.tid]
429
        mov     ebx, [src]
429
        mov     ebx, [src]
430
        mov     ecx, [flags]
430
        mov     ecx, [flags]
431
        call    create_cursor    ;eax, ebx, ecx
431
        call    create_cursor    ;eax, ebx, ecx
432
        mov     [handle], eax
432
        mov     [handle], eax
433
 
433
 
434
        cmp     word [flags], LOAD_FROM_FILE
434
        cmp     word [flags], LOAD_FROM_FILE
435
        jne     .exit
435
        jne     .exit
436
        stdcall kernel_free, [src]
436
        stdcall kernel_free, [src]
437
;--------------------------------------
437
;--------------------------------------
438
align 4
438
align 4
439
.exit:
439
.exit:
440
        pop     edi
440
        pop     edi
441
        pop     esi
441
        pop     esi
442
        pop     ebx
442
        pop     ebx
443
;--------------------------------------
443
;--------------------------------------
444
align 4
444
align 4
445
.fail:
445
.fail:
446
        mov     eax, [handle]
446
        mov     eax, [handle]
447
;--------------------------------------
447
;--------------------------------------
448
align 4
448
align 4
449
.fail2:
449
.fail2:
450
        ret
450
        ret
451
endp
451
endp
452
;------------------------------------------------------------------------------
452
;------------------------------------------------------------------------------
453
align 4
453
align 4
454
proc delete_cursor stdcall, hcursor:dword
454
proc delete_cursor stdcall, hcursor:dword
455
 
455
 
456
;        DEBUGF 1,'K : delete_cursor %x\n', [hcursor]
456
;        DEBUGF 1,'K : delete_cursor %x\n', [hcursor]
457
 
457
 
458
        mov     esi, [hcursor]
458
        mov     esi, [hcursor]
459
 
459
 
460
        cmp     [esi + CURSOR.magic], 'CURS'
460
        cmp     [esi + CURSOR.magic], 'CURS'
461
        jne     .fail
461
        jne     .fail
462
 
462
 
463
        mov     ebx, [current_slot]
463
        mov     ebx, [current_slot]
464
        mov     ebx, [ebx + APPDATA.tid]
464
        mov     ebx, [ebx + APPDATA.tid]
465
        cmp     ebx, [esi + CURSOR.pid]
465
        cmp     ebx, [esi + CURSOR.pid]
466
        jne     .fail
466
        jne     .fail
467
 
467
 
468
        mov     ebx, [current_slot]
468
        mov     ebx, [current_slot]
469
        mov     ebx, [ebx + APPDATA.window]
469
        mov     ebx, [ebx + APPDATA.window]
470
        cmp     esi, [ebx + WDATA.cursor]
470
        cmp     esi, [ebx + WDATA.cursor]
471
        jne     @F
471
        jne     @F
472
        mov     eax, [def_cursor]
472
        mov     eax, [def_cursor]
473
        mov     [ebx + WDATA.cursor], eax
473
        mov     [ebx + WDATA.cursor], eax
474
;--------------------------------------
474
;--------------------------------------
475
align 4
475
align 4
476
@@:
476
@@:
477
        mov     eax, [hcursor]
477
        mov     eax, [hcursor]
478
        call    [eax + APPOBJ.destroy]
478
        call    [eax + APPOBJ.destroy]
479
;--------------------------------------
479
;--------------------------------------
480
align 4
480
align 4
481
.fail:
481
.fail:
482
        ret
482
        ret
483
endp
483
endp
484
;------------------------------------------------------------------------------
484
;------------------------------------------------------------------------------
485
align 4
485
align 4
486
; param
486
; param
487
;  eax= cursor
487
;  eax= cursor
488
destroy_cursor:
488
destroy_cursor:
489
 
489
 
490
        push    eax
490
        push    eax
491
        stdcall kernel_free, [eax + CURSOR.base]
491
        stdcall kernel_free, [eax + CURSOR.base]
492
 
492
 
493
        mov     eax, [esp]
493
        mov     eax, [esp]
494
        lea     eax, [eax + CURSOR.list_next]
494
        lea     eax, [eax + CURSOR.list_next]
495
 
495
 
496
        pushfd
496
        pushfd
497
        cli
497
        cli
498
        list_del eax
498
        list_del eax
499
        popfd
499
        popfd
500
 
500
 
501
        pop     eax
501
        pop     eax
502
        call    destroy_kernel_object
502
        call    destroy_kernel_object
503
        ret
503
        ret
504
;------------------------------------------------------------------------------
504
;------------------------------------------------------------------------------
505
align 4
505
align 4
506
select_cursor:
506
select_cursor:
507
        mov     eax, [esp + 4]
507
        mov     eax, [esp + 4]
508
        mov     [_display.cursor], eax
508
        mov     [_display.cursor], eax
509
        ret     4
509
        ret     4
510
;------------------------------------------------------------------------------
510
;------------------------------------------------------------------------------
511
align 4
511
align 4
512
proc restore_24 stdcall, x:dword, y:dword
512
proc restore_24 stdcall, x:dword, y:dword
513
 
513
 
514
        push    ebx
514
        push    ebx
515
 
515
 
516
        mov     ebx, [cur_saved_base]
516
        mov     ebx, [cur_saved_base]
517
        mov     edx, [cur.h]
517
        mov     edx, [cur.h]
518
        test    edx, edx
518
        test    edx, edx
519
        jz      .ret
519
        jz      .ret
520
 
520
 
521
        push    esi
521
        push    esi
522
        push    edi
522
        push    edi
523
 
523
 
524
        mov     esi, cur_saved_data
524
        mov     esi, cur_saved_data
525
        mov     ecx, [cur.w]
525
        mov     ecx, [cur.w]
526
        lea     ecx, [ecx + ecx*2]
526
        lea     ecx, [ecx + ecx*2]
527
        push    ecx
527
        push    ecx
528
;--------------------------------------
528
;--------------------------------------
529
align 4
529
align 4
530
@@:
530
@@:
531
        mov     edi, ebx
531
        mov     edi, ebx
532
        add     ebx, [_display.lfb_pitch]
532
        add     ebx, [_display.lfb_pitch]
533
 
533
 
534
        mov     ecx, [esp]
534
        mov     ecx, [esp]
535
        rep movsb
535
        rep movsb
536
        dec     edx
536
        dec     edx
537
        jnz     @B
537
        jnz     @B
538
 
538
 
539
        pop     ecx
539
        pop     ecx
540
        pop     edi
540
        pop     edi
541
        pop     esi
541
        pop     esi
542
;--------------------------------------
542
;--------------------------------------
543
align 4
543
align 4
544
.ret:
544
.ret:
545
        pop     ebx
545
        pop     ebx
546
        ret
546
        ret
547
endp
547
endp
548
;------------------------------------------------------------------------------
548
;------------------------------------------------------------------------------
549
align 4
549
align 4
550
proc restore_32 stdcall, x:dword, y:dword
550
proc restore_32 stdcall, x:dword, y:dword
551
 
551
 
552
        push    ebx
552
        push    ebx
553
 
553
 
554
        mov     ebx, [cur_saved_base]
554
        mov     ebx, [cur_saved_base]
555
        mov     edx, [cur.h]
555
        mov     edx, [cur.h]
556
        test    edx, edx
556
        test    edx, edx
557
        jz      .ret
557
        jz      .ret
558
 
558
 
559
        push    esi
559
        push    esi
560
        push    edi
560
        push    edi
561
 
561
 
562
        mov     esi, cur_saved_data
562
        mov     esi, cur_saved_data
563
;--------------------------------------
563
;--------------------------------------
564
align 4
564
align 4
565
@@:
565
@@:
566
        mov     edi, ebx
566
        mov     edi, ebx
567
        add     ebx, [_display.lfb_pitch]
567
        add     ebx, [_display.lfb_pitch]
568
 
568
 
569
        mov     ecx, [cur.w]
569
        mov     ecx, [cur.w]
570
        rep movsd
570
        rep movsd
571
        dec     edx
571
        dec     edx
572
        jnz     @B
572
        jnz     @B
573
 
573
 
574
        pop     edi
574
        pop     edi
575
        pop     esi
575
        pop     esi
576
 
576
 
577
;--------------------------------------
577
;--------------------------------------
578
align 4
578
align 4
579
.ret:
579
.ret:
580
        pop     ebx
580
        pop     ebx
581
        ret
581
        ret
582
endp
582
endp
583
;------------------------------------------------------------------------------
583
;------------------------------------------------------------------------------
584
align 4
584
align 4
585
proc restore_16 stdcall, x:dword, y:dword
585
proc restore_16 stdcall, x:dword, y:dword
586
 
586
 
587
        push    ebx
587
        push    ebx
588
 
588
 
589
        mov     ebx, [cur_saved_base]
589
        mov     ebx, [cur_saved_base]
590
        mov     edx, [cur.h]
590
        mov     edx, [cur.h]
591
        test    edx, edx
591
        test    edx, edx
592
        jz      .ret
592
        jz      .ret
593
 
593
 
594
        push    esi
594
        push    esi
595
        push    edi
595
        push    edi
596
 
596
 
597
        mov     esi, cur_saved_data
597
        mov     esi, cur_saved_data
598
;--------------------------------------
598
;--------------------------------------
599
align 4
599
align 4
600
@@:
600
@@:
601
        mov     edi, ebx
601
        mov     edi, ebx
602
        add     ebx, [_display.lfb_pitch]
602
        add     ebx, [_display.lfb_pitch]
603
 
603
 
604
        mov     ecx, [cur.w]
604
        mov     ecx, [cur.w]
605
        rep movsw
605
        rep movsw
606
        dec     edx
606
        dec     edx
607
        jnz     @B
607
        jnz     @B
608
 
608
 
609
        pop     edi
609
        pop     edi
610
        pop     esi
610
        pop     esi
611
 
611
 
612
;--------------------------------------
612
;--------------------------------------
613
align 4
613
align 4
614
.ret:
614
.ret:
615
        pop     ebx
615
        pop     ebx
616
        ret
616
        ret
617
endp
617
endp
618
;------------------------------------------------------------------------------
618
;------------------------------------------------------------------------------
619
align 4
619
align 4
620
proc VGA_restore_32 stdcall, x:dword, y:dword
620
proc VGA_restore_32 stdcall, x:dword, y:dword
621
 
621
 
622
        push    ebx
622
        push    ebx
623
 
623
 
624
        mov     ebx, [cur_saved_base]
624
        mov     ebx, [cur_saved_base]
625
        mov     edx, [cur.h]
625
        mov     edx, [cur.h]
626
        test    edx, edx
626
        test    edx, edx
627
        jz      .ret
627
        jz      .ret
628
 
628
 
629
        push    esi
629
        push    esi
630
        push    edi
630
        push    edi
631
 
631
 
632
        mov     esi, cur_saved_data
632
        mov     esi, cur_saved_data
633
        mov     edi, ebx
633
        mov     edi, ebx
634
        push    [cur.w]
634
        push    [cur.w]
635
        push    [cur.top];[y]
635
        push    [cur.top];[y]
636
        push    [cur.left];[x]
636
        push    [cur.left];[x]
637
        ;mov     eax, [cur.top]
637
        ;mov     eax, [cur.top]
638
        ;add     [esp + 4], eax
638
        ;add     [esp + 4], eax
639
        ;mov     eax, [cur.left]
639
        ;mov     eax, [cur.left]
640
        ;add     [esp], eax
640
        ;add     [esp], eax
641
;--------------------------------------
641
;--------------------------------------
642
align 4
642
align 4
643
@@:
643
@@:
644
        mov     ecx, [esi]
644
        mov     ecx, [esi]
645
        add     esi, 4
645
        add     esi, 4
646
 
646
 
647
        ;mov     eax, [esp]
647
        ;mov     eax, [esp]
648
        ;sub     eax, [x]
648
        ;sub     eax, [x]
649
        ;shl     eax, 2 ; *4
649
        ;shl     eax, 2 ; *4
650
        ;mov     [edi + eax], ecx
650
        ;mov     [edi + eax], ecx
651
 
651
 
652
        mov     eax, [esp]
652
        mov     eax, [esp]
653
        mov     ebx, [esp + 4]
653
        mov     ebx, [esp + 4]
654
 
654
 
655
        push    edx  edi
655
        push    edx  edi
656
        mov     edi, 1
656
        mov     edi, 1
657
        or      ecx, 0x04000000
657
        or      ecx, 0x04000000
658
        call    __sys_putpixel
658
        call    __sys_putpixel
659
        pop     edi edx
659
        pop     edi edx
660
        add     dword[esp], 1
660
        add     dword[esp], 1
661
        dec     dword[esp + 8]
661
        dec     dword[esp + 8]
662
        jnz     @b
662
        jnz     @b
663
 
663
 
664
        mov     eax, [cur.w]
664
        mov     eax, [cur.w]
665
        mov     ecx, [cur.left];[x]
665
        mov     ecx, [cur.left];[x]
666
        ;add     ecx, [cur.left]
666
        ;add     ecx, [cur.left]
667
        mov     [esp + 8], eax
667
        mov     [esp + 8], eax
668
 
668
 
669
        mov     dword[esp], ecx
669
        mov     dword[esp], ecx
670
 
670
 
671
        inc     dword[esp + 4]
671
        inc     dword[esp + 4]
672
        ;add     edi, [_display.lfb_pitch]
672
        ;add     edi, [_display.lfb_pitch]
673
        dec     edx
673
        dec     edx
674
        jnz     @b
674
        jnz     @b
675
 
675
 
676
        add     esp, 4*3
676
        add     esp, 4*3
677
 
677
 
678
        pop     edi
678
        pop     edi
679
        pop     esi
679
        pop     esi
680
;--------------------------------------
680
;--------------------------------------
681
align 4
681
align 4
682
.ret:
682
.ret:
683
        pop     ebx
683
        pop     ebx
684
        ret
684
        ret
685
endp
685
endp
686
;------------------------------------------------------------------------------
686
;------------------------------------------------------------------------------
687
align 4
687
align 4
688
proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
688
proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
689
           locals
689
           locals
690
             h      dd ?
690
             h      dd ?
691
             _dx     dd ?
691
             _dx     dd ?
692
             _dy     dd ?
692
             _dy     dd ?
693
           endl
693
           endl
694
 
694
 
695
        mov     esi, [hcursor]
695
        mov     esi, [hcursor]
696
        mov     ecx, [x]
696
        mov     ecx, [x]
697
        mov     eax, [y]
697
        mov     eax, [y]
698
;        mov     ebx, [BytesPerScanLine]
698
;        mov     ebx, [BytesPerScanLine]
699
 
699
 
700
        xor     edx, edx
700
        xor     edx, edx
701
        sub     ecx, [esi + CURSOR.hot_x]
701
        sub     ecx, [esi + CURSOR.hot_x]
702
        lea     ebx, [ecx + 32-1]
702
        lea     ebx, [ecx + 32-1]
703
        mov     [x], ecx
703
        mov     [x], ecx
704
        sets    dl
704
        sets    dl
705
        dec     edx
705
        dec     edx
706
        and     ecx, edx      ;clip x to 0<=x
706
        and     ecx, edx      ;clip x to 0<=x
707
        mov     [cur.left], ecx
707
        mov     [cur.left], ecx
708
        mov     edi, ecx
708
        mov     edi, ecx
709
        sub     edi, [x]
709
        sub     edi, [x]
710
        mov     [_dx], edi
710
        mov     [_dx], edi
711
 
711
 
712
        xor     edx, edx
712
        xor     edx, edx
713
        sub     eax, [esi + CURSOR.hot_y]
713
        sub     eax, [esi + CURSOR.hot_y]
714
        lea     edi, [eax+32-1]
714
        lea     edi, [eax+32-1]
715
        mov     [y], eax
715
        mov     [y], eax
716
        sets    dl
716
        sets    dl
717
        dec     edx
717
        dec     edx
718
        and     eax, edx      ;clip y to 0<=y
718
        and     eax, edx      ;clip y to 0<=y
719
        mov     [cur.top], eax
719
        mov     [cur.top], eax
720
        mov     edx, eax
720
        mov     edx, eax
721
        sub     edx, [y]
721
        sub     edx, [y]
722
        mov     [_dy], edx
722
        mov     [_dy], edx
723
 
723
 
724
;        mul     dword [BytesPerScanLine]
724
;        mul     dword [BytesPerScanLine]
725
        mov     eax, [BPSLine_calc_area + eax*4]
725
        mov     eax, [BPSLine_calc_area + eax*4]
726
        lea     edx, [LFB_BASE + ecx*3]
726
        lea     edx, [LFB_BASE + ecx*3]
727
        add     edx, eax
727
        add     edx, eax
728
        mov     [cur_saved_base], edx
728
        mov     [cur_saved_base], edx
729
 
729
 
730
        cmp     ebx, [_display.width]
730
        cmp     ebx, [_display.width]
731
        jb      @F
731
        jb      @F
732
        mov     ebx, [_display.width]
732
        mov     ebx, [_display.width]
733
;--------------------------------------
733
;--------------------------------------
734
align 4
734
align 4
735
@@:
735
@@:
736
        cmp     edi, [_display.height]
736
        cmp     edi, [_display.height]
737
        jb      @F
737
        jb      @F
738
        mov     edi, [_display.height]
738
        mov     edi, [_display.height]
739
;--------------------------------------
739
;--------------------------------------
740
align 4
740
align 4
741
@@:
741
@@:
742
 
742
 
743
        sub     ebx, [x]
743
        sub     ebx, [x]
744
        sub     edi, [y]
744
        sub     edi, [y]
745
        sub     ebx, [_dx]
745
        sub     ebx, [_dx]
746
        sub     edi, [_dy]
746
        sub     edi, [_dy]
747
 
747
 
748
        mov     [cur.w], ebx
748
        mov     [cur.w], ebx
749
        mov     [cur.h], edi
749
        mov     [cur.h], edi
750
        mov     [h], edi
750
        mov     [h], edi
751
 
751
 
752
        mov     eax, edi
752
        mov     eax, edi
753
        mov     edi, cur_saved_data
753
        mov     edi, cur_saved_data
754
;--------------------------------------
754
;--------------------------------------
755
align 4
755
align 4
756
@@:
756
@@:
757
        mov     esi, edx
757
        mov     esi, edx
758
        add     edx, [_display.lfb_pitch]
758
        add     edx, [_display.lfb_pitch]
759
        mov     ecx, [cur.w]
759
        mov     ecx, [cur.w]
760
        lea     ecx, [ecx + ecx*2]
760
        lea     ecx, [ecx + ecx*2]
761
        rep movsb
761
        rep movsb
762
        dec     eax
762
        dec     eax
763
        jnz     @B
763
        jnz     @B
764
 
764
 
765
;draw cursor
765
;draw cursor
766
        mov     ebx, [cur_saved_base]
766
        mov     ebx, [cur_saved_base]
767
        mov     eax, [_dy]
767
        mov     eax, [_dy]
768
        shl     eax, 5
768
        shl     eax, 5
769
        add     eax, [_dx]
769
        add     eax, [_dx]
770
 
770
 
771
        mov     esi, [hcursor]
771
        mov     esi, [hcursor]
772
        mov     esi, [esi + CURSOR.base]
772
        mov     esi, [esi + CURSOR.base]
773
        lea     edx, [esi + eax*4]
773
        lea     edx, [esi + eax*4]
774
;--------------------------------------
774
;--------------------------------------
775
align 4
775
align 4
776
.row:
776
.row:
777
        mov     ecx, [cur.w]
777
        mov     ecx, [cur.w]
778
        mov     esi, edx
778
        mov     esi, edx
779
        mov     edi, ebx
779
        mov     edi, ebx
780
        add     edx, 32*4
780
        add     edx, 32*4
781
        add     ebx, [_display.lfb_pitch]
781
        add     ebx, [_display.lfb_pitch]
782
;--------------------------------------
782
;--------------------------------------
783
align 4
783
align 4
784
.pix:
784
.pix:
785
        lodsd
785
        lodsd
786
        test    eax, 0xFF000000
786
        test    eax, 0xFF000000
787
        jz      @F
787
        jz      @F
788
        mov     [edi], ax
788
        mov     [edi], ax
789
        shr     eax, 16
789
        shr     eax, 16
790
        mov     [edi+2], al
790
        mov     [edi+2], al
791
;--------------------------------------
791
;--------------------------------------
792
align 4
792
align 4
793
@@:
793
@@:
794
        add     edi, 3
794
        add     edi, 3
795
        dec     ecx
795
        dec     ecx
796
        jnz     .pix
796
        jnz     .pix
797
 
797
 
798
        dec     [h]
798
        dec     [h]
799
        jnz     .row
799
        jnz     .row
800
        ret
800
        ret
801
endp
801
endp
802
;------------------------------------------------------------------------------
802
;------------------------------------------------------------------------------
803
align 4
803
align 4
804
proc move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
804
proc move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
805
           locals
805
           locals
806
             h      dd ?
806
             h      dd ?
807
             _dx     dd ?
807
             _dx     dd ?
808
             _dy     dd ?
808
             _dy     dd ?
809
           endl
809
           endl
810
 
810
 
811
        mov     esi, [hcursor]
811
        mov     esi, [hcursor]
812
        mov     ecx, [x]
812
        mov     ecx, [x]
813
        mov     eax, [y]
813
        mov     eax, [y]
814
 
814
 
815
        xor     edx, edx
815
        xor     edx, edx
816
        sub     ecx, [esi + CURSOR.hot_x]
816
        sub     ecx, [esi + CURSOR.hot_x]
817
        lea     ebx, [ecx+32-1]
817
        lea     ebx, [ecx+32-1]
818
        mov     [x], ecx
818
        mov     [x], ecx
819
        sets    dl
819
        sets    dl
820
        dec     edx
820
        dec     edx
821
        and     ecx, edx      ;clip x to 0<=x
821
        and     ecx, edx      ;clip x to 0<=x
822
        mov     [cur.left], ecx
822
        mov     [cur.left], ecx
823
        mov     edi, ecx
823
        mov     edi, ecx
824
        sub     edi, [x]
824
        sub     edi, [x]
825
        mov     [_dx], edi
825
        mov     [_dx], edi
826
 
826
 
827
        xor     edx, edx
827
        xor     edx, edx
828
        sub     eax, [esi + CURSOR.hot_y]
828
        sub     eax, [esi + CURSOR.hot_y]
829
        lea     edi, [eax+32-1]
829
        lea     edi, [eax+32-1]
830
        mov     [y], eax
830
        mov     [y], eax
831
        sets    dl
831
        sets    dl
832
        dec     edx
832
        dec     edx
833
        and     eax, edx      ;clip y to 0<=y
833
        and     eax, edx      ;clip y to 0<=y
834
        mov     [cur.top], eax
834
        mov     [cur.top], eax
835
        mov     edx, eax
835
        mov     edx, eax
836
        sub     edx, [y]
836
        sub     edx, [y]
837
        mov     [_dy], edx
837
        mov     [_dy], edx
838
 
838
 
839
;        mul     dword [BytesPerScanLine]
839
;        mul     dword [BytesPerScanLine]
840
        mov     eax, [BPSLine_calc_area+eax*4]
840
        mov     eax, [BPSLine_calc_area+eax*4]
841
        lea     edx, [LFB_BASE + eax + ecx*4]
841
        lea     edx, [LFB_BASE + eax + ecx*4]
842
        mov     [cur_saved_base], edx
842
        mov     [cur_saved_base], edx
843
 
843
 
844
        cmp     ebx, [_display.width]
844
        cmp     ebx, [_display.width]
845
        jb      @F
845
        jb      @F
846
        mov     ebx, [_display.width]
846
        mov     ebx, [_display.width]
847
;--------------------------------------
847
;--------------------------------------
848
align 4
848
align 4
849
@@:
849
@@:
850
        cmp     edi, [_display.height]
850
        cmp     edi, [_display.height]
851
        jb      @F
851
        jb      @F
852
        mov     edi, [_display.height]
852
        mov     edi, [_display.height]
853
;--------------------------------------
853
;--------------------------------------
854
align 4
854
align 4
855
@@:
855
@@:
856
        sub     ebx, [x]
856
        sub     ebx, [x]
857
        sub     edi, [y]
857
        sub     edi, [y]
858
        sub     ebx, [_dx]
858
        sub     ebx, [_dx]
859
        sub     edi, [_dy]
859
        sub     edi, [_dy]
860
 
860
 
861
        mov     [cur.w], ebx
861
        mov     [cur.w], ebx
862
        mov     [cur.h], edi
862
        mov     [cur.h], edi
863
        mov     [h], edi
863
        mov     [h], edi
864
 
864
 
865
        mov     eax, edi
865
        mov     eax, edi
866
        mov     edi, cur_saved_data
866
        mov     edi, cur_saved_data
867
;--------------------------------------
867
;--------------------------------------
868
align 4
868
align 4
869
@@:
869
@@:
870
        mov     esi, edx
870
        mov     esi, edx
871
        add     edx, [_display.lfb_pitch]
871
        add     edx, [_display.lfb_pitch]
872
        mov     ecx, [cur.w]
872
        mov     ecx, [cur.w]
873
        rep movsd
873
        rep movsd
874
        dec     eax
874
        dec     eax
875
        jnz     @B
875
        jnz     @B
876
 
876
 
877
;draw cursor
877
;draw cursor
878
        mov     ebx, [cur_saved_base]
878
        mov     ebx, [cur_saved_base]
879
        mov     eax, [_dy]
879
        mov     eax, [_dy]
880
        shl     eax, 5
880
        shl     eax, 5
881
        add     eax, [_dx]
881
        add     eax, [_dx]
882
 
882
 
883
        mov     esi, [hcursor]
883
        mov     esi, [hcursor]
884
        mov     esi, [esi + CURSOR.base]
884
        mov     esi, [esi + CURSOR.base]
885
        lea     edx, [esi+eax*4]
885
        lea     edx, [esi+eax*4]
886
;--------------------------------------
886
;--------------------------------------
887
align 4
887
align 4
888
.row:
888
.row:
889
        mov     ecx, [cur.w]
889
        mov     ecx, [cur.w]
890
        mov     esi, edx
890
        mov     esi, edx
891
        mov     edi, ebx
891
        mov     edi, ebx
892
        add     edx, 32*4
892
        add     edx, 32*4
893
        add     ebx, [_display.lfb_pitch]
893
        add     ebx, [_display.lfb_pitch]
894
;--------------------------------------
894
;--------------------------------------
895
align 4
895
align 4
896
.pix:
896
.pix:
897
        lodsd
897
        lodsd
898
        test    eax, 0xFF000000
898
        test    eax, 0xFF000000
899
        jz      @F
899
        jz      @F
900
        mov     [edi], eax
900
        mov     [edi], eax
901
;--------------------------------------
901
;--------------------------------------
902
align 4
902
align 4
903
@@:
903
@@:
904
        add     edi, 4
904
        add     edi, 4
905
        dec     ecx
905
        dec     ecx
906
        jnz     .pix
906
        jnz     .pix
907
 
907
 
908
        dec     [h]
908
        dec     [h]
909
        jnz     .row
909
        jnz     .row
910
        ret
910
        ret
911
endp
911
endp
912
;------------------------------------------------------------------------------
912
;------------------------------------------------------------------------------
913
align 4
913
align 4
914
proc move_cursor_16 stdcall, hcursor:dword, x:dword, y:dword
914
proc move_cursor_16 stdcall, hcursor:dword, x:dword, y:dword
915
           locals
915
           locals
916
             h      dd ?
916
             h      dd ?
917
             _dx     dd ?
917
             _dx     dd ?
918
             _dy     dd ?
918
             _dy     dd ?
919
           endl
919
           endl
920
 
920
 
921
        mov     esi, [hcursor]
921
        mov     esi, [hcursor]
922
        mov     ecx, [x]
922
        mov     ecx, [x]
923
        mov     eax, [y]
923
        mov     eax, [y]
924
 
924
 
925
        xor     edx, edx
925
        xor     edx, edx
926
        sub     ecx, [esi + CURSOR.hot_x]
926
        sub     ecx, [esi + CURSOR.hot_x]
927
        lea     ebx, [ecx + 32-1]
927
        lea     ebx, [ecx + 32-1]
928
        mov     [x], ecx
928
        mov     [x], ecx
929
        sets    dl
929
        sets    dl
930
        dec     edx
930
        dec     edx
931
        and     ecx, edx      ;clip x to 0<=x
931
        and     ecx, edx      ;clip x to 0<=x
932
        mov     [cur.left], ecx
932
        mov     [cur.left], ecx
933
        mov     edi, ecx
933
        mov     edi, ecx
934
        sub     edi, [x]
934
        sub     edi, [x]
935
        mov     [_dx], edi
935
        mov     [_dx], edi
936
 
936
 
937
        xor     edx, edx
937
        xor     edx, edx
938
        sub     eax, [esi + CURSOR.hot_y]
938
        sub     eax, [esi + CURSOR.hot_y]
939
        lea     edi, [eax + 32-1]
939
        lea     edi, [eax + 32-1]
940
        mov     [y], eax
940
        mov     [y], eax
941
        sets    dl
941
        sets    dl
942
        dec     edx
942
        dec     edx
943
        and     eax, edx      ;clip y to 0<=y
943
        and     eax, edx      ;clip y to 0<=y
944
        mov     [cur.top], eax
944
        mov     [cur.top], eax
945
        mov     edx, eax
945
        mov     edx, eax
946
        sub     edx, [y]
946
        sub     edx, [y]
947
        mov     [_dy], edx
947
        mov     [_dy], edx
948
 
948
 
949
;        mul     dword [BytesPerScanLine]
949
;        mul     dword [BytesPerScanLine]
950
        mov     eax, [BPSLine_calc_area + eax*4]
950
        mov     eax, [BPSLine_calc_area + eax*4]
951
        lea     edx, [LFB_BASE + eax + ecx*2]
951
        lea     edx, [LFB_BASE + eax + ecx*2]
952
        mov     [cur_saved_base], edx
952
        mov     [cur_saved_base], edx
953
 
953
 
954
        cmp     ebx, [_display.width]
954
        cmp     ebx, [_display.width]
955
        jb      @F
955
        jb      @F
956
        mov     ebx, [_display.width]
956
        mov     ebx, [_display.width]
957
;--------------------------------------
957
;--------------------------------------
958
align 4
958
align 4
959
@@:
959
@@:
960
        cmp     edi, [_display.height]
960
        cmp     edi, [_display.height]
961
        jb      @F
961
        jb      @F
962
        mov     edi, [_display.height]
962
        mov     edi, [_display.height]
963
;--------------------------------------
963
;--------------------------------------
964
align 4
964
align 4
965
@@:
965
@@:
966
        sub     ebx, [x]
966
        sub     ebx, [x]
967
        sub     edi, [y]
967
        sub     edi, [y]
968
        sub     ebx, [_dx]
968
        sub     ebx, [_dx]
969
        sub     edi, [_dy]
969
        sub     edi, [_dy]
970
 
970
 
971
        mov     [cur.w], ebx
971
        mov     [cur.w], ebx
972
        mov     [cur.h], edi
972
        mov     [cur.h], edi
973
        mov     [h], edi
973
        mov     [h], edi
974
 
974
 
975
        mov     eax, edi
975
        mov     eax, edi
976
        mov     edi, cur_saved_data
976
        mov     edi, cur_saved_data
977
;--------------------------------------
977
;--------------------------------------
978
align 4
978
align 4
979
@@:
979
@@:
980
        mov     esi, edx
980
        mov     esi, edx
981
        add     edx, [_display.lfb_pitch]
981
        add     edx, [_display.lfb_pitch]
982
        mov     ecx, [cur.w]
982
        mov     ecx, [cur.w]
983
 
983
 
984
        rep movsw
984
        rep movsw
985
        dec     eax
985
        dec     eax
986
        jnz     @B
986
        jnz     @B
987
 
987
 
988
;draw cursor
988
;draw cursor
989
        mov     ebx, [cur_saved_base]
989
        mov     ebx, [cur_saved_base]
990
        mov     eax, [_dy]
990
        mov     eax, [_dy]
991
        shl     eax, 5
991
        shl     eax, 5
992
        add     eax, [_dx]
992
        add     eax, [_dx]
993
 
993
 
994
        mov     esi, [hcursor]
994
        mov     esi, [hcursor]
995
        mov     esi, [esi + CURSOR.base]
995
        mov     esi, [esi + CURSOR.base]
996
        lea     edx, [esi + eax*4]
996
        lea     edx, [esi + eax*4]
997
;--------------------------------------
997
;--------------------------------------
998
align 4
998
align 4
999
.row:
999
.row:
1000
        mov     ecx, [cur.w]
1000
        mov     ecx, [cur.w]
1001
        mov     esi, edx
1001
        mov     esi, edx
1002
        mov     edi, ebx
1002
        mov     edi, ebx
1003
        add     edx, 32*4
1003
        add     edx, 32*4
1004
        add     ebx, [_display.lfb_pitch]
1004
        add     ebx, [_display.lfb_pitch]
1005
;--------------------------------------
1005
;--------------------------------------
1006
align 4
1006
align 4
1007
.pix:
1007
.pix:
1008
        lodsd
1008
        lodsd
1009
        test    eax, 0xFF000000
1009
        test    eax, 0xFF000000
1010
        jz      @F
1010
        jz      @F
1011
; convert to 16 bpp and store to real LFB
1011
; convert to 16 bpp and store to real LFB
1012
        and     eax, 00000000111110001111110011111000b
1012
        and     eax, 00000000111110001111110011111000b
1013
        shr     ah, 2
1013
        shr     ah, 2
1014
        shr     ax, 3
1014
        shr     ax, 3
1015
        ror     eax, 8
1015
        ror     eax, 8
1016
        add     al, ah
1016
        add     al, ah
1017
        rol     eax, 8
1017
        rol     eax, 8
1018
        mov     [edi], ax
1018
        mov     [edi], ax
1019
;--------------------------------------
1019
;--------------------------------------
1020
align 4
1020
align 4
1021
@@:
1021
@@:
1022
        add     edi, 2
1022
        add     edi, 2
1023
        dec     ecx
1023
        dec     ecx
1024
        jnz     .pix
1024
        jnz     .pix
1025
 
1025
 
1026
        dec     [h]
1026
        dec     [h]
1027
        jnz     .row
1027
        jnz     .row
1028
        ret
1028
        ret
1029
endp
1029
endp
1030
 
1030
 
1031
;------------------------------------------------------------------------------
1031
;------------------------------------------------------------------------------
1032
align 4
1032
align 4
1033
proc VGA_move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
1033
proc VGA_move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
1034
           locals
1034
           locals
1035
             h      dd ?
1035
             h      dd ?
1036
             _dx     dd ?
1036
             _dx     dd ?
1037
             _dy     dd ?
1037
             _dy     dd ?
1038
             bg_ptr dd ?
1038
             bg_ptr dd ?
1039
             tmp_x  dd ?
1039
             tmp_x  dd ?
1040
             tmp_y  dd ?
1040
             tmp_y  dd ?
1041
           endl
1041
           endl
1042
 
1042
 
1043
        mov     esi, [hcursor]
1043
        mov     esi, [hcursor]
1044
        mov     ecx, [x]
1044
        mov     ecx, [x]
1045
        mov     eax, [y]
1045
        mov     eax, [y]
1046
 
1046
 
1047
        xor     edx, edx
1047
        xor     edx, edx
1048
        sub     ecx, [esi + CURSOR.hot_x]
1048
        sub     ecx, [esi + CURSOR.hot_x]
1049
        lea     ebx, [ecx+32-1]
1049
        lea     ebx, [ecx+32-1]
1050
        mov     [x], ecx
1050
        mov     [x], ecx
1051
        sets    dl
1051
        sets    dl
1052
        dec     edx
1052
        dec     edx
1053
        and     ecx, edx      ;clip x to 0<=x
1053
        and     ecx, edx      ;clip x to 0<=x
1054
        mov     [cur.left], ecx
1054
        mov     [cur.left], ecx
1055
        mov     edi, ecx
1055
        mov     edi, ecx
1056
        sub     edi, [x]
1056
        sub     edi, [x]
1057
        mov     [_dx], edi
1057
        mov     [_dx], edi
1058
 
1058
 
1059
        xor     edx, edx
1059
        xor     edx, edx
1060
        sub     eax, [esi + CURSOR.hot_y]
1060
        sub     eax, [esi + CURSOR.hot_y]
1061
        lea     edi, [eax+32-1]
1061
        lea     edi, [eax+32-1]
1062
        mov     [y], eax
1062
        mov     [y], eax
1063
        sets    dl
1063
        sets    dl
1064
        dec     edx
1064
        dec     edx
1065
        and     eax, edx      ;clip y to 0<=y
1065
        and     eax, edx      ;clip y to 0<=y
1066
        mov     [cur.top], eax
1066
        mov     [cur.top], eax
1067
        mov     edx, eax
1067
        mov     edx, eax
1068
        sub     edx, [y]
1068
        sub     edx, [y]
1069
        mov     [_dy], edx
1069
        mov     [_dy], edx
1070
 
1070
 
1071
        mov     [tmp_x], ecx
1071
        mov     [tmp_x], ecx
1072
        mov     [tmp_y], eax
1072
        mov     [tmp_y], eax
1073
        mov     eax, [BPSLine_calc_area+eax*4]
1073
        mov     eax, [BPSLine_calc_area+eax*4]
1074
        lea     edx, [LFB_BASE + eax + ecx*4]
1074
        lea     edx, [LFB_BASE + eax + ecx*4]
1075
        mov     [cur_saved_base], edx
1075
        mov     [cur_saved_base], edx
1076
 
1076
 
1077
        cmp     ebx, [_display.width]
1077
        cmp     ebx, [_display.width]
1078
        jb      @F
1078
        jb      @F
1079
        mov     ebx, [_display.width]
1079
        mov     ebx, [_display.width]
1080
;--------------------------------------
1080
;--------------------------------------
1081
align 4
1081
align 4
1082
@@:
1082
@@:
1083
        cmp     edi, [_display.height]
1083
        cmp     edi, [_display.height]
1084
        jb      @F
1084
        jb      @F
1085
        mov     edi, [_display.height]
1085
        mov     edi, [_display.height]
1086
;--------------------------------------
1086
;--------------------------------------
1087
align 4
1087
align 4
1088
@@:
1088
@@:
1089
        sub     ebx, [x]
1089
        sub     ebx, [x]
1090
        sub     edi, [y]
1090
        sub     edi, [y]
1091
        sub     ebx, [_dx]
1091
        sub     ebx, [_dx]
1092
        sub     edi, [_dy]
1092
        sub     edi, [_dy]
1093
 
1093
 
1094
        mov     [cur.w], ebx
1094
        mov     [cur.w], ebx
1095
        mov     [cur.h], edi
1095
        mov     [cur.h], edi
1096
        mov     [h], edi
1096
        mov     [h], edi
1097
 
1097
 
1098
        mov     eax, edi
1098
        mov     eax, edi
1099
        mov     edi, cur_saved_data
1099
        mov     edi, cur_saved_data
1100
 
1100
 
1101
        xor     ecx, ecx
1101
        xor     ecx, ecx
1102
        mov     eax, ecx
1102
        mov     eax, ecx
1103
;--------------------------------------
1103
;--------------------------------------
1104
align 4
1104
align 4
1105
@@:
1105
@@:
1106
        ; get and save pixel background
1106
        ; get and save pixel background
1107
        push    eax ecx ebx edx
1107
        push    eax ecx ebx edx
1108
        add     eax, [tmp_x]
1108
        add     eax, [tmp_x]
1109
        mov     ebx, ecx
1109
        mov     ebx, ecx
1110
        add     ebx, [tmp_y]
1110
        add     ebx, [tmp_y]
1111
        push    edi
1111
        push    edi
1112
 
1112
 
1113
        or      ecx, 0x04000000
1113
        or      ecx, 0x04000000
1114
        call    [GETPIXEL]
1114
        call    [GETPIXEL]
1115
 
1115
 
1116
        pop     edi
1116
        pop     edi
1117
        ;and     ecx, 0x00ffffff
1117
        ;and     ecx, 0x00ffffff
1118
        mov     [edi], ecx
1118
        mov     [edi], ecx
1119
        add     edi, 4
1119
        add     edi, 4
1120
 
1120
 
1121
        pop     edx ebx ecx eax
1121
        pop     edx ebx ecx eax
1122
        inc     eax
1122
        inc     eax
1123
        cmp     eax, [cur.w]
1123
        cmp     eax, [cur.w]
1124
        jb      @b
1124
        jb      @b
1125
        xor     eax, eax
1125
        xor     eax, eax
1126
        inc     ecx
1126
        inc     ecx
1127
        cmp     ecx, [h]
1127
        cmp     ecx, [h]
1128
        jb      @B
1128
        jb      @B
1129
 
1129
 
1130
;draw cursor
1130
;draw cursor
1131
        mov     ebx, [cur_saved_base]
1131
        mov     ebx, [cur_saved_base]
1132
        mov     eax, [_dy]
1132
        mov     eax, [_dy]
1133
        shl     eax, 5
1133
        shl     eax, 5
1134
        add     eax, [_dx]
1134
        add     eax, [_dx]
1135
 
1135
 
1136
        mov     esi, [hcursor]
1136
        mov     esi, [hcursor]
1137
        mov     esi, [esi + CURSOR.base]
1137
        mov     esi, [esi + CURSOR.base]
1138
        lea     edx, [esi+eax*4]
1138
        lea     edx, [esi+eax*4]
1139
        mov     [bg_ptr], cur_saved_data
1139
        mov     [bg_ptr], cur_saved_data
1140
 
1140
 
1141
        mov     [_dy], 0
1141
        mov     [_dy], 0
1142
;--------------------------------------
1142
;--------------------------------------
1143
align 4
1143
align 4
1144
.row:
1144
.row:
1145
        mov     [_dx], 0
1145
        mov     [_dx], 0
1146
        mov     ecx, [cur.w]
1146
        mov     ecx, [cur.w]
1147
        mov     esi, edx  ; cursor image base
1147
        mov     esi, edx  ; cursor image base
1148
        mov     edi, ebx
1148
        mov     edi, ebx
1149
        add     edx, 32*4
1149
        add     edx, 32*4
1150
        add     ebx, [_display.lfb_pitch]
1150
        add     ebx, [_display.lfb_pitch]
1151
;--------------------------------------
1151
;--------------------------------------
1152
align 4
1152
align 4
1153
.pix:
1153
.pix:
1154
        ; get pixel cursor
1154
        ; get pixel cursor
1155
        lodsd
1155
        lodsd
1156
        test    eax, 0xFF000000
1156
        test    eax, 0xFF000000
1157
        jz      @F
1157
        jz      @F
1158
        mov     [edi], eax
1158
        mov     [edi], eax
1159
 
1159
 
1160
        pusha
1160
        pusha
1161
        mov     edi, 1 ; force
1161
        mov     edi, 1 ; force
1162
        mov     ecx, eax ; color
1162
        mov     ecx, eax ; color
1163
        and     ecx, 0x00ffffff
1163
        and     ecx, 0x00ffffff
1164
        or      ecx, 0x04000000
1164
        or      ecx, 0x04000000
1165
        mov     eax, [x]
1165
        mov     eax, [x]
1166
        mov     ebx, [y]
1166
        mov     ebx, [y]
1167
        add     eax, [_dx]
1167
        add     eax, [_dx]
1168
        add     ebx, [_dy]
1168
        add     ebx, [_dy]
1169
        call    __sys_putpixel
1169
        call    __sys_putpixel
1170
        popa
1170
        popa
1171
;--------------------------------------
1171
;--------------------------------------
1172
align 4
1172
align 4
1173
@@:
1173
@@:
1174
        inc     [_dx]
1174
        inc     [_dx]
1175
        add     edi, 4
1175
        add     edi, 4
1176
        dec     ecx
1176
        dec     ecx
1177
        jnz     .pix
1177
        jnz     .pix
1178
 
1178
 
1179
        inc     [_dy]
1179
        inc     [_dy]
1180
        dec     [h]
1180
        dec     [h]
1181
        jnz     .row
1181
        jnz     .row
1182
        ret
1182
        ret
1183
endp
1183
endp
1184
 
1184
 
1185
;------------------------------------------------------------------------------
1185
;------------------------------------------------------------------------------
1186
align 4
1186
align 4
1187
check_mouse_area_for_getpixel_new:
1187
check_mouse_area_for_getpixel_new:
1188
; in:
1188
; in:
1189
; eax = x
1189
; eax = x
1190
; ebx = y
1190
; ebx = y
1191
; out:
1191
; out:
1192
; ecx = new color
1192
; ecx = new color
1193
;--------------------------------------
1193
;--------------------------------------
1194
; check for Y
1194
; check for Y
1195
        cmp     bx, [Y_UNDER_subtraction_CUR_hot_y]
1195
        cmp     bx, [Y_UNDER_subtraction_CUR_hot_y]
1196
        jb      .no_mouse_area
1196
        jb      .no_mouse_area
1197
 
1197
 
1198
        cmp     bx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1198
        cmp     bx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1199
        jae     .no_mouse_area
1199
        jae     .no_mouse_area
1200
;--------------------------------------
1200
;--------------------------------------
1201
; check for X
1201
; check for X
1202
        cmp     ax, [X_UNDER_subtraction_CUR_hot_x]
1202
        cmp     ax, [X_UNDER_subtraction_CUR_hot_x]
1203
        jb      .no_mouse_area
1203
        jb      .no_mouse_area
1204
 
1204
 
1205
        cmp     ax, [X_UNDER_sub_CUR_hot_x_add_curh]
1205
        cmp     ax, [X_UNDER_sub_CUR_hot_x_add_curh]
1206
        jae     .no_mouse_area
1206
        jae     .no_mouse_area
1207
;--------------------------------------
1207
;--------------------------------------
1208
        push    eax ebx
1208
        push    eax ebx
1209
; offset X
1209
; offset X
1210
        movzx   ecx, word [X_UNDER_subtraction_CUR_hot_x]
1210
        movzx   ecx, word [X_UNDER_subtraction_CUR_hot_x]
1211
        sub     eax, ecx        ; x1
1211
        sub     eax, ecx        ; x1
1212
; offset Y
1212
; offset Y
1213
        movzx   ecx, word [Y_UNDER_subtraction_CUR_hot_y]
1213
        movzx   ecx, word [Y_UNDER_subtraction_CUR_hot_y]
1214
        sub     ebx, ecx        ; y1
1214
        sub     ebx, ecx        ; y1
1215
;--------------------------------------
1215
;--------------------------------------
1216
; ebx = offset y
1216
; ebx = offset y
1217
; eax = offset x
1217
; eax = offset x
1218
        imul    ebx, [cur.w]     ;y
1218
        imul    ebx, [cur.w]     ;y
1219
        add     eax, ebx
1219
        add     eax, ebx
1220
        mov     ebx, eax
1220
        mov     ebx, eax
1221
        shl     eax, 2
1221
        shl     eax, 2
1222
        cmp     byte [_display.bits_per_pixel], 32
1222
        cmp     byte [_display.bits_per_pixel], 32
1223
        je      @f
1223
        je      @f
1224
        sub     eax, ebx
1224
        sub     eax, ebx
1225
        cmp     byte [_display.bits_per_pixel], 24
1225
        cmp     byte [_display.bits_per_pixel], 24
1226
        je      @f
1226
        je      @f
1227
        sub     eax, ebx
1227
        sub     eax, ebx
1228
        add     eax, cur_saved_data
1228
        add     eax, cur_saved_data
1229
        mov     ecx, [eax]
1229
        mov     ecx, [eax]
1230
        shl     ecx, 3
1230
        shl     ecx, 3
1231
        ror     ecx, 8
1231
        ror     ecx, 8
1232
        shl     cx, 2
1232
        shl     cx, 2
1233
        ror     ecx, 8
1233
        ror     ecx, 8
1234
        shl     cl, 3
1234
        shl     cl, 3
1235
        rol     ecx, 16
1235
        rol     ecx, 16
1236
        or      ecx, 0xff000000
1236
        or      ecx, 0xff000000
1237
        pop     ebx eax
1237
        pop     ebx eax
1238
        ret
1238
        ret
1239
 
1239
 
1240
;--------------------------------------
1240
;--------------------------------------
1241
align 4
1241
align 4
1242
@@:
1242
@@:
1243
        add     eax, cur_saved_data
1243
        add     eax, cur_saved_data
1244
        mov     ecx, [eax]
1244
        mov     ecx, [eax]
1245
        or      ecx, 0xff000000
1245
        or      ecx, 0xff000000
1246
        pop     ebx eax
1246
        pop     ebx eax
1247
        ret
1247
        ret
1248
;--------------------------------------
1248
;--------------------------------------
1249
align 4
1249
align 4
1250
.no_mouse_area:
1250
.no_mouse_area:
1251
        xor     ecx, ecx
1251
        xor     ecx, ecx
1252
        ret
1252
        ret
1253
;-----------------------------------------------------------------------------
1253
;-----------------------------------------------------------------------------
1254
align 4
1254
align 4
1255
check_mouse_area_for_putpixel_new:
1255
check_mouse_area_for_putpixel_new:
1256
; in:
1256
; in:
1257
; ecx = x shl 16 + y
1257
; ecx = x shl 16 + y
1258
; eax = color
1258
; eax = color
1259
; out:
1259
; out:
1260
; eax = new color
1260
; eax = new color
1261
;--------------------------------------
1261
;--------------------------------------
1262
; check for Y
1262
; check for Y
1263
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1263
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1264
        jae     .no_mouse_area
1264
        jae     .no_mouse_area
1265
 
1265
 
1266
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1266
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1267
        jb      .no_mouse_area
1267
        jb      .no_mouse_area
1268
 
1268
 
1269
        rol     ecx, 16
1269
        rol     ecx, 16
1270
;--------------------------------------
1270
;--------------------------------------
1271
; check for X
1271
; check for X
1272
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1272
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1273
        jae     .no_mouse_area
1273
        jae     .no_mouse_area
1274
 
1274
 
1275
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
1275
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
1276
        jb      .no_mouse_area
1276
        jb      .no_mouse_area
1277
 
1277
 
1278
        ror     ecx, 16
1278
        ror     ecx, 16
1279
;--------------------------------------
1279
;--------------------------------------
1280
align 4
1280
align 4
1281
.1:
1281
.1:
1282
        push    eax
1282
        push    eax
1283
;--------------------------------------
1283
;--------------------------------------
1284
; ecx = (offset x) shl 16 + (offset y)
1284
; ecx = (offset x) shl 16 + (offset y)
1285
        push    ebx
1285
        push    ebx
1286
        mov     ebx, ecx
1286
        mov     ebx, ecx
1287
        shr     ebx, 16        ; x
1287
        shr     ebx, 16        ; x
1288
        and     ecx, 0xffff    ; y
1288
        and     ecx, 0xffff    ; y
1289
 
1289
 
1290
        cmp     ecx, [cur.h]
1290
        cmp     ecx, [cur.h]
1291
        jae     @f
1291
        jae     @f
1292
 
1292
 
1293
        cmp     ebx, [cur.w]
1293
        cmp     ebx, [cur.w]
1294
        jb      .ok
1294
        jb      .ok
1295
;--------------------------------------
1295
;--------------------------------------
1296
align 4
1296
align 4
1297
@@:
1297
@@:
1298
;        DEBUGF  1, "K : SHIT HAPPENS: %x %x \n", ecx,ebx
1298
;        DEBUGF  1, "K : SHIT HAPPENS: %x %x \n", ecx,ebx
1299
        pop     ebx
1299
        pop     ebx
1300
        jmp     .sh   ; SORRY! SHIT HAPPENS!
1300
        jmp     .sh   ; SORRY! SHIT HAPPENS!
1301
;--------------------------------------
1301
;--------------------------------------
1302
align 4
1302
align 4
1303
.ok:
1303
.ok:
1304
; ecx = offset y
1304
; ecx = offset y
1305
; ebx = offset x
1305
; ebx = offset x
1306
        push    ebx ecx
1306
        push    ebx ecx
1307
        imul    ecx, [cur.w]    ;y
1307
        imul    ecx, [cur.w]    ;y
1308
        add     ecx, ebx
1308
        add     ecx, ebx
1309
        mov     ebx, ecx
1309
        mov     ebx, ecx
1310
        shl     ecx, 2
1310
        shl     ecx, 2
1311
        cmp     byte [_display.bits_per_pixel], 16
1311
        cmp     byte [_display.bits_per_pixel], 16
1312
        je      .16
1312
        je      .16
1313
        cmp     byte [_display.bits_per_pixel], 24
1313
        cmp     byte [_display.bits_per_pixel], 24
1314
        je      .24
1314
        je      .24
1315
        and     eax, 0xFFFFFF
1315
        and     eax, 0xFFFFFF
1316
        mov     [ecx + cur_saved_data], eax   ;store new color  to
1316
        mov     [ecx + cur_saved_data], eax   ;store new color  to
1317
        jmp     @f
1317
        jmp     @f
1318
;--------------------------------------
1318
;--------------------------------------
1319
align 4
1319
align 4
1320
.16:
1320
.16:
1321
        sub     ecx, ebx
1321
        sub     ecx, ebx
1322
        sub     ecx, ebx
1322
        sub     ecx, ebx
1323
; convert to 16 bpp and store to real LFB
1323
; convert to 16 bpp and store to real LFB
1324
        and     eax, 00000000111110001111110011111000b
1324
        and     eax, 00000000111110001111110011111000b
1325
        shr     ah, 2
1325
        shr     ah, 2
1326
        shr     ax, 3
1326
        shr     ax, 3
1327
        ror     eax, 8
1327
        ror     eax, 8
1328
        add     al, ah
1328
        add     al, ah
1329
        rol     eax, 8
1329
        rol     eax, 8
1330
        mov     [ecx + cur_saved_data], ax      ;store new color  to
1330
        mov     [ecx + cur_saved_data], ax      ;store new color  to
1331
        jmp     @f
1331
        jmp     @f
1332
;--------------------------------------
1332
;--------------------------------------
1333
align 4
1333
align 4
1334
.24:
1334
.24:
1335
        sub     ecx, ebx
1335
        sub     ecx, ebx
1336
        mov     [ecx + cur_saved_data], ax      ;store new color  to
1336
        mov     [ecx + cur_saved_data], ax      ;store new color  to
1337
        shr     eax, 16
1337
        shr     eax, 16
1338
        mov     [ecx + cur_saved_data + 2], al  ;store new color  to
1338
        mov     [ecx + cur_saved_data + 2], al  ;store new color  to
1339
;--------------------------------------
1339
;--------------------------------------
1340
align 4
1340
align 4
1341
@@:
1341
@@:
1342
        pop     ecx ebx
1342
        pop     ecx ebx
1343
 
1343
 
1344
        shl     ecx, 5
1344
        shl     ecx, 5
1345
        add     ecx, ebx
1345
        add     ecx, ebx
1346
 
1346
 
1347
        mov     eax, [current_cursor]
1347
        mov     eax, [current_cursor]
1348
        mov     eax, [eax + CURSOR.base]
1348
        mov     eax, [eax + CURSOR.base]
1349
        lea     eax, [eax + ecx*4]
1349
        lea     eax, [eax + ecx*4]
1350
        mov     eax, [eax]
1350
        mov     eax, [eax]
1351
 
1351
 
1352
        pop     ebx
1352
        pop     ebx
1353
 
1353
 
1354
        test    eax, 0xFF000000
1354
        test    eax, 0xFF000000
1355
        jz      @f
1355
        jz      @f
1356
 
1356
 
1357
        add     esp, 4
1357
        add     esp, 4
1358
        ret
1358
        ret
1359
;--------------------------------------
1359
;--------------------------------------
1360
align 4
1360
align 4
1361
.sh:
1361
.sh:
1362
        mov     ecx, -1
1362
        mov     ecx, -1
1363
;--------------------------------------
1363
;--------------------------------------
1364
align 4
1364
align 4
1365
@@:
1365
@@:
1366
        pop     eax
1366
        pop     eax
1367
;--------------------------------------
1367
;--------------------------------------
1368
align 4
1368
align 4
1369
.no_mouse_area:
1369
.no_mouse_area:
1370
        ret
1370
        ret
1371
;------------------------------------------------------------------------------
1371
;------------------------------------------------------------------------------
1372
align 4
1372
align 4
1373
get_display:
1373
get_display:
1374
        mov     eax, _display
1374
        mov     eax, _display
1375
        ret
1375
        ret
1376
;------------------------------------------------------------------------------
1376
;------------------------------------------------------------------------------
1377
align 4
1377
align 4
1378
init_display:
1378
init_display:
1379
        xor     eax, eax
1379
        xor     eax, eax
1380
        mov     edi, _display
1380
        mov     edi, _display
1381
 
1381
 
1382
        mov     [edi + display_t.init_cursor], eax
1382
        mov     [edi + display_t.init_cursor], eax
1383
        mov     [edi + display_t.select_cursor], eax
1383
        mov     [edi + display_t.select_cursor], eax
1384
        mov     [edi + display_t.show_cursor], eax
1384
        mov     [edi + display_t.show_cursor], eax
1385
        mov     [edi + display_t.move_cursor], eax
1385
        mov     [edi + display_t.move_cursor], eax
1386
        mov     [edi + display_t.restore_cursor], eax
1386
        mov     [edi + display_t.restore_cursor], eax
1387
 
1387
 
1388
        lea     ecx, [edi + display_t.cr_list.next]
1388
        lea     ecx, [edi + display_t.cr_list.next]
1389
        mov     [edi + display_t.cr_list.next], ecx
1389
        mov     [edi + display_t.cr_list.next], ecx
1390
        mov     [edi + display_t.cr_list.prev], ecx
1390
        mov     [edi + display_t.cr_list.prev], ecx
1391
 
-
 
1392
if ~defined UEFI
1391
 
1393
        cmp     [SCR_MODE], word 0x12
1392
        cmp     [SCR_MODE], word 0x12
1394
        jne     .not_vga
1393
        jne     .not_vga
1395
        ; TODO
1394
        ; TODO
1396
        mov     ebx, VGA_restore_32
1395
        mov     ebx, VGA_restore_32
1397
        mov     ecx, VGA_move_cursor_32
1396
        mov     ecx, VGA_move_cursor_32
1398
        mov     edx, VGA_putpixel
1397
        mov     edx, VGA_putpixel
1399
        jmp     .set
1398
        jmp     .set
1400
 
1399
 
1401
.not_vga:
1400
.not_vga:
1402
        test    word [SCR_MODE], 0x4000
1401
        test    word [SCR_MODE], 0x4000
1403
        jnz     .not_ega
1402
        jnz     .not_ega
1404
 
1403
 
1405
        mov     ebx, restore_32
1404
        mov     ebx, restore_32
1406
        mov     ecx, move_cursor_32
1405
        mov     ecx, move_cursor_32
1407
        mov     edx, Vesa20_putpixel32_new
1406
        mov     edx, Vesa20_putpixel32_new
1408
        mov     eax, [_display.bits_per_pixel]
1407
        mov     eax, [_display.bits_per_pixel]
1409
        jmp     .set
1408
        jmp     .set
1410
 
1409
 
1411
.not_ega:
1410
.not_ega:
1412
end if
-
 
1413
        mov     ebx, restore_32
1411
        mov     ebx, restore_32
1414
        mov     ecx, move_cursor_32
1412
        mov     ecx, move_cursor_32
1415
        mov     edx, Vesa20_putpixel32_new
1413
        mov     edx, Vesa20_putpixel32_new
1416
        mov     eax, [_display.bits_per_pixel]
1414
        mov     eax, [_display.bits_per_pixel]
1417
 
1415
 
1418
        cmp     al, 32
1416
        cmp     al, 32
1419
        jne     .not_32bpp
1417
        jne     .not_32bpp
1420
 
1418
 
1421
.set:
1419
.set:
1422
        mov     [_display.select_cursor], select_cursor
1420
        mov     [_display.select_cursor], select_cursor
1423
        mov     [_display.move_cursor], ecx
1421
        mov     [_display.move_cursor], ecx
1424
        mov     [_display.restore_cursor], ebx
1422
        mov     [_display.restore_cursor], ebx
1425
        ;mov     [_display.check_mouse], check_mouse_area_for_putpixel_new
1423
        ;mov     [_display.check_mouse], check_mouse_area_for_putpixel_new
1426
        ;mov     [_display.check_m_pixel], check_mouse_area_for_getpixel_new
1424
        ;mov     [_display.check_m_pixel], check_mouse_area_for_getpixel_new
1427
 
1425
 
1428
        mov     [PUTPIXEL], edx
1426
        mov     [PUTPIXEL], edx
1429
 
1427
 
1430
        stdcall load_cursor, def_hresize, dword LOAD_FROM_MEM
1428
        stdcall load_cursor, def_hresize, dword LOAD_FROM_MEM
1431
        mov     [def_cursor_hresize], eax
1429
        mov     [def_cursor_hresize], eax
1432
        stdcall load_cursor, def_vresize, dword LOAD_FROM_MEM
1430
        stdcall load_cursor, def_vresize, dword LOAD_FROM_MEM
1433
        mov     [def_cursor_vresize], eax
1431
        mov     [def_cursor_vresize], eax
1434
        stdcall load_cursor, def_dresize1, dword LOAD_FROM_MEM
1432
        stdcall load_cursor, def_dresize1, dword LOAD_FROM_MEM
1435
        mov     [def_cursor_dresize1], eax
1433
        mov     [def_cursor_dresize1], eax
1436
        stdcall load_cursor, def_dresize2, dword LOAD_FROM_MEM
1434
        stdcall load_cursor, def_dresize2, dword LOAD_FROM_MEM
1437
        mov     [def_cursor_dresize2], eax
1435
        mov     [def_cursor_dresize2], eax
1438
 
1436
 
1439
        stdcall load_cursor, clock_arrow, dword LOAD_FROM_MEM
1437
        stdcall load_cursor, clock_arrow, dword LOAD_FROM_MEM
1440
        mov     [def_cursor_clock], eax
1438
        mov     [def_cursor_clock], eax
1441
        stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
1439
        stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
1442
        mov     [def_cursor], eax
1440
        mov     [def_cursor], eax
1443
        ret
1441
        ret
1444
 
1442
 
1445
.not_32bpp:
1443
.not_32bpp:
1446
        cmp     al, 24
1444
        cmp     al, 24
1447
        jne     .not_24bpp
1445
        jne     .not_24bpp
1448
 
1446
 
1449
        mov     ebx, restore_24
1447
        mov     ebx, restore_24
1450
        mov     ecx, move_cursor_24
1448
        mov     ecx, move_cursor_24
1451
        mov     edx, Vesa20_putpixel24_new
1449
        mov     edx, Vesa20_putpixel24_new
1452
        jmp     .set
1450
        jmp     .set
1453
 
1451
 
1454
.not_24bpp:
1452
.not_24bpp:
1455
        cmp     al, 16
1453
        cmp     al, 16
1456
        jne     .not_16bpp
1454
        jne     .not_16bpp
1457
        mov     ebx, restore_16
1455
        mov     ebx, restore_16
1458
        mov     ecx, move_cursor_16
1456
        mov     ecx, move_cursor_16
1459
        mov     edx, Vesa20_putpixel16_new
1457
        mov     edx, Vesa20_putpixel16_new
1460
        jmp     .set
1458
        jmp     .set
1461
 
1459
 
1462
.not_16bpp:
1460
.not_16bpp:
1463
;        cmp     al, 15
1461
;        cmp     al, 15
1464
;        jne     .fail
1462
;        jne     .fail
1465
;        mov     ebx, restore_15
1463
;        mov     ebx, restore_15
1466
;        mov     ecx, move_cursor_15
1464
;        mov     ecx, move_cursor_15
1467
;        mov     edx, Vesa20_putpixel15_new
1465
;        mov     edx, Vesa20_putpixel15_new
1468
;        jmp     .set
1466
;        jmp     .set
1469
.fail:
1467
.fail:
1470
        ;xor     eax, eax
1468
        ;xor     eax, eax
1471
        ;mov     [_display.select_cursor], eax
1469
        ;mov     [_display.select_cursor], eax
1472
        ;mov     [_display.move_cursor], eax
1470
        ;mov     [_display.move_cursor], eax
1473
        ret
1471
        ret
1474
;------------------------------------------------------------------------------
1472
;------------------------------------------------------------------------------
1475
align 4
1473
align 4
1476
def_arrow:
1474
def_arrow:
1477
  file 'arrow.cur'
1475
  file 'arrow.cur'
1478
;------------------------------------------------------------------------------
1476
;------------------------------------------------------------------------------
1479
align 4
1477
align 4
1480
def_hresize:
1478
def_hresize:
1481
  file 'hresize.cur'
1479
  file 'hresize.cur'
1482
;------------------------------------------------------------------------------
1480
;------------------------------------------------------------------------------
1483
align 4
1481
align 4
1484
def_vresize:
1482
def_vresize:
1485
  file 'vresize.cur'
1483
  file 'vresize.cur'
1486
;------------------------------------------------------------------------------
1484
;------------------------------------------------------------------------------
1487
align 4
1485
align 4
1488
def_dresize1:
1486
def_dresize1:
1489
  file 'dresize1.cur'
1487
  file 'dresize1.cur'
1490
;------------------------------------------------------------------------------
1488
;------------------------------------------------------------------------------
1491
align 4
1489
align 4
1492
def_dresize2:
1490
def_dresize2:
1493
  file 'dresize2.cur'
1491
  file 'dresize2.cur'
1494
;------------------------------------------------------------------------------
1492
;------------------------------------------------------------------------------
1495
align 4
1493
align 4
1496
clock_arrow:
1494
clock_arrow:
1497
  file 'arrow_clock.cur'
1495
  file 'arrow_clock.cur'
1498
;------------------------------------------------------------------------------
1496
;------------------------------------------------------------------------------
1499
>
1497
>
1500
>
1498
>
1501
>
1499
>
1502
>
1500
>
1503
>
1501
>
1504
>
1502
>
1505
>
1503
>
1506
>
1504
>