Subversion Repositories Kolibri OS

Rev

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

Rev 2436 Rev 2438
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;  VESA20.INC                                                  ;;
6
;;  VESA20.INC                                                  ;;
7
;;                                                              ;;
7
;;                                                              ;;
8
;;  Vesa 2.0 functions for MenuetOS                             ;;
8
;;  Vesa 2.0 functions for MenuetOS                             ;;
9
;;                                                              ;;
9
;;                                                              ;;
10
;;  Copyright 2002 Ville Turjanmaa                              ;;
10
;;  Copyright 2002 Ville Turjanmaa                              ;;
11
;;  Alexey, kgaz@crosswindws.net                                ;;
11
;;  Alexey, kgaz@crosswindws.net                                ;;
12
;;  - Voodoo compatible graphics                                ;;
12
;;  - Voodoo compatible graphics                                ;;
13
;;  Juan M. Caravaca                                            ;;
13
;;  Juan M. Caravaca                                            ;;
14
;;  - Graphics optimimizations eg. drawline                     ;;
14
;;  - Graphics optimimizations eg. drawline                     ;;
15
;;                                                              ;;
15
;;                                                              ;;
16
;;  See file COPYING for details                                ;;
16
;;  See file COPYING for details                                ;;
17
;;                                                              ;;
17
;;                                                              ;;
18
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
18
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19
 
19
 
20
$Revision: 2436 $
20
$Revision: 2438 $
21
 
21
 
22
 
22
 
23
; If you're planning to write your own video driver I suggest
23
; If you're planning to write your own video driver I suggest
24
; you replace the VESA12.INC file and see those instructions.
24
; you replace the VESA12.INC file and see those instructions.
25
 
25
 
26
;Screen_Max_X             equ     0xfe00
26
;Screen_Max_X             equ     0xfe00
27
;Screen_Max_Y            equ     0xfe04
27
;Screen_Max_Y            equ     0xfe04
28
;BytesPerScanLine        equ     0xfe08
28
;BytesPerScanLine        equ     0xfe08
29
;LFBAddress              equ     0xfe80
29
;LFBAddress              equ     0xfe80
30
;ScreenBPP               equ     0xfbf1
30
;ScreenBPP               equ     0xfbf1
31
 
31
 
32
 
32
 
33
 
33
 
34
;-----------------------------------------------------------------------------
34
;-----------------------------------------------------------------------------
35
; getpixel
35
; getpixel
36
;
36
;
37
; in:
37
; in:
38
; eax = x coordinate
38
; eax = x coordinate
39
; ebx = y coordinate
39
; ebx = y coordinate
40
;
40
;
41
; ret:
41
; ret:
42
; ecx = 00 RR GG BB
42
; ecx = 00 RR GG BB
43
;-----------------------------------------------------------------------------
43
;-----------------------------------------------------------------------------
44
align 4
44
align 4
45
getpixel:
45
getpixel:
46
        push    eax ebx edx edi
46
        push    eax ebx edx edi
47
        call    dword [GETPIXEL]
47
        call    dword [GETPIXEL]
48
        pop     edi edx ebx eax
48
        pop     edi edx ebx eax
49
        ret
49
        ret
50
;-----------------------------------------------------------------------------
50
;-----------------------------------------------------------------------------
51
align 4
51
align 4
52
Vesa20_getpixel24:
52
Vesa20_getpixel24:
53
; eax = x
53
; eax = x
54
; ebx = y
54
; ebx = y
55
;--------------------------------------
55
;--------------------------------------
56
; check mouse area for putpixel
56
; check mouse area for putpixel
57
        test    ecx, 0x04000000  ; don't load to mouseunder area
57
        test    ecx, 0x04000000  ; don't load to mouseunder area
58
        jnz     .no_mouseunder
58
        jnz     .no_mouseunder
59
        call    [_display.check_m_pixel]
59
        call    [_display.check_m_pixel]
60
        test    ecx, ecx        ;0xff000000
60
        test    ecx, ecx        ;0xff000000
61
        jnz     @f
61
        jnz     @f
62
.no_mouseunder:
62
.no_mouseunder:
63
;--------------------------------------
63
;--------------------------------------
64
        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
64
        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
65
        lea     edi, [eax+eax*2]; edi = x*3
65
        lea     edi, [eax+eax*2]; edi = x*3
66
        add     edi, ebx      ; edi = x*3+(y*y multiplier)
66
        add     edi, ebx      ; edi = x*3+(y*y multiplier)
67
        mov     ecx, [LFB_BASE+edi]
67
        mov     ecx, [LFB_BASE+edi]
68
;--------------------------------------
68
;--------------------------------------
69
align 4
69
align 4
70
@@:
70
@@:
71
        and     ecx, 0xffffff
71
        and     ecx, 0xffffff
72
        ret
72
        ret
73
;-----------------------------------------------------------------------------
73
;-----------------------------------------------------------------------------
74
align 4
74
align 4
75
Vesa20_getpixel32:
75
Vesa20_getpixel32:
76
;--------------------------------------
76
;--------------------------------------
77
; check mouse area for putpixel
77
; check mouse area for putpixel
78
        test    ecx, 0x04000000  ; don't load to mouseunder area
78
        test    ecx, 0x04000000  ; don't load to mouseunder area
79
        jnz     .no_mouseunder
79
        jnz     .no_mouseunder
80
        call    [_display.check_m_pixel]
80
        call    [_display.check_m_pixel]
81
        test    ecx, ecx        ;0xff000000
81
        test    ecx, ecx        ;0xff000000
82
        jnz     @f
82
        jnz     @f
83
.no_mouseunder:
83
.no_mouseunder:
84
;--------------------------------------
84
;--------------------------------------
85
        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
85
        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
86
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
86
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
87
        mov     ecx, [LFB_BASE+edi]
87
        mov     ecx, [LFB_BASE+edi]
88
;--------------------------------------
88
;--------------------------------------
89
align 4
89
align 4
90
@@:
90
@@:
91
        and     ecx, 0xffffff
91
        and     ecx, 0xffffff
92
        ret
92
        ret
93
;-----------------------------------------------------------------------------
93
;-----------------------------------------------------------------------------
94
virtual at esp
94
virtual at esp
95
 putimg:
95
 putimg:
96
   .real_sx        dd ?
96
   .real_sx        dd ?
97
   .real_sy        dd ?
97
   .real_sy        dd ?
98
   .image_sx       dd ?
98
   .image_sx       dd ?
99
   .image_sy       dd ?
99
   .image_sy       dd ?
100
   .image_cx       dd ?
100
   .image_cx       dd ?
101
   .image_cy       dd ?
101
   .image_cy       dd ?
102
   .pti            dd ?
102
   .pti            dd ?
103
   .abs_cx         dd ?
103
   .abs_cx         dd ?
104
   .abs_cy         dd ?
104
   .abs_cy         dd ?
105
   .line_increment dd ?
105
   .line_increment dd ?
106
   .winmap_newline dd ?
106
   .winmap_newline dd ?
107
   .screen_newline dd ?
107
   .screen_newline dd ?
108
   .real_sx_and_abs_cx dd ?
108
   .real_sx_and_abs_cx dd ?
109
   .real_sy_and_abs_cy dd ?
109
   .real_sy_and_abs_cy dd ?
110
   .stack_data = 4*14
110
   .stack_data = 4*14
111
   .edi         dd      ?
111
   .edi         dd      ?
112
   .esi         dd      ?
112
   .esi         dd      ?
113
   .ebp         dd      ?
113
   .ebp         dd      ?
114
   .esp         dd      ?
114
   .esp         dd      ?
115
   .ebx         dd      ?
115
   .ebx         dd      ?
116
   .edx         dd      ?
116
   .edx         dd      ?
117
   .ecx         dd      ?
117
   .ecx         dd      ?
118
   .eax         dd      ?
118
   .eax         dd      ?
119
   .ret_addr    dd      ?
119
   .ret_addr    dd      ?
120
   .arg_0       dd      ?
120
   .arg_0       dd      ?
121
end virtual
121
end virtual
122
;-----------------------------------------------------------------------------
122
;-----------------------------------------------------------------------------
123
align 16
123
align 16
124
; ebx = pointer
124
; ebx = pointer
125
; ecx = size [x|y]
125
; ecx = size [x|y]
126
; edx = coordinates [x|y]
126
; edx = coordinates [x|y]
127
; ebp = pointer to 'get' function
127
; ebp = pointer to 'get' function
128
; esi = pointer to 'init' function
128
; esi = pointer to 'init' function
129
; edi = parameter for 'get' function
129
; edi = parameter for 'get' function
130
vesa20_putimage:
130
vesa20_putimage:
131
        pushad
131
        pushad
132
        sub     esp, putimg.stack_data
132
        sub     esp, putimg.stack_data
133
; save pointer to image
133
; save pointer to image
134
        mov     [putimg.pti], ebx
134
        mov     [putimg.pti], ebx
135
; unpack the size
135
; unpack the size
136
        mov     eax, ecx
136
        mov     eax, ecx
137
        and     ecx, 0xFFFF
137
        and     ecx, 0xFFFF
138
        shr     eax, 16
138
        shr     eax, 16
139
        mov     [putimg.image_sx], eax
139
        mov     [putimg.image_sx], eax
140
        mov     [putimg.image_sy], ecx
140
        mov     [putimg.image_sy], ecx
141
; unpack the coordinates
141
; unpack the coordinates
142
        mov     eax, edx
142
        mov     eax, edx
143
        and     edx, 0xFFFF
143
        and     edx, 0xFFFF
144
        shr     eax, 16
144
        shr     eax, 16
145
        mov     [putimg.image_cx], eax
145
        mov     [putimg.image_cx], eax
146
        mov     [putimg.image_cy], edx
146
        mov     [putimg.image_cy], edx
147
; calculate absolute (i.e. screen) coordinates
147
; calculate absolute (i.e. screen) coordinates
148
        mov     eax, [TASK_BASE]
148
        mov     eax, [TASK_BASE]
149
        mov     ebx, [eax-twdw + WDATA.box.left]
149
        mov     ebx, [eax-twdw + WDATA.box.left]
150
        add     ebx, [putimg.image_cx]
150
        add     ebx, [putimg.image_cx]
151
        mov     [putimg.abs_cx], ebx
151
        mov     [putimg.abs_cx], ebx
152
        mov     ebx, [eax-twdw + WDATA.box.top]
152
        mov     ebx, [eax-twdw + WDATA.box.top]
153
        add     ebx, [putimg.image_cy]
153
        add     ebx, [putimg.image_cy]
154
        mov     [putimg.abs_cy], ebx
154
        mov     [putimg.abs_cy], ebx
155
; real_sx = MIN(wnd_sx-image_cx, image_sx);
155
; real_sx = MIN(wnd_sx-image_cx, image_sx);
156
        mov     ebx, [eax-twdw + WDATA.box.width]; ebx = wnd_sx
156
        mov     ebx, [eax-twdw + WDATA.box.width]; ebx = wnd_sx
157
; \begin{diamond}[20.08.2006]
157
; \begin{diamond}[20.08.2006]
158
; note that WDATA.box.width is one pixel less than real window x-size
158
; note that WDATA.box.width is one pixel less than real window x-size
159
        inc     ebx
159
        inc     ebx
160
; \end{diamond}[20.08.2006]
160
; \end{diamond}[20.08.2006]
161
        sub     ebx, [putimg.image_cx]
161
        sub     ebx, [putimg.image_cx]
162
        ja      @f
162
        ja      @f
163
        add     esp, putimg.stack_data
163
        add     esp, putimg.stack_data
164
        popad
164
        popad
165
        ret
165
        ret
166
;--------------------------------------
166
;--------------------------------------
167
align 4
167
align 4
168
@@:
168
@@:
169
        cmp     ebx, [putimg.image_sx]
169
        cmp     ebx, [putimg.image_sx]
170
        jbe     .end_x
170
        jbe     .end_x
171
        mov     ebx, [putimg.image_sx]
171
        mov     ebx, [putimg.image_sx]
172
;--------------------------------------
172
;--------------------------------------
173
align 4
173
align 4
174
.end_x:
174
.end_x:
175
        mov     [putimg.real_sx], ebx
175
        mov     [putimg.real_sx], ebx
176
; init real_sy
176
; init real_sy
177
        mov     ebx, [eax-twdw + WDATA.box.height]; ebx = wnd_sy
177
        mov     ebx, [eax-twdw + WDATA.box.height]; ebx = wnd_sy
178
; \begin{diamond}[20.08.2006]
178
; \begin{diamond}[20.08.2006]
179
        inc     ebx
179
        inc     ebx
180
; \end{diamond}[20.08.2006]
180
; \end{diamond}[20.08.2006]
181
        sub     ebx, [putimg.image_cy]
181
        sub     ebx, [putimg.image_cy]
182
        ja      @f
182
        ja      @f
183
        add     esp, putimg.stack_data
183
        add     esp, putimg.stack_data
184
        popad
184
        popad
185
        ret
185
        ret
186
;--------------------------------------
186
;--------------------------------------
187
align 4
187
align 4
188
@@:
188
@@:
189
        cmp     ebx, [putimg.image_sy]
189
        cmp     ebx, [putimg.image_sy]
190
        jbe     .end_y
190
        jbe     .end_y
191
        mov     ebx, [putimg.image_sy]
191
        mov     ebx, [putimg.image_sy]
192
;--------------------------------------
192
;--------------------------------------
193
align 4
193
align 4
194
.end_y:
194
.end_y:
195
        mov     [putimg.real_sy], ebx
195
        mov     [putimg.real_sy], ebx
196
; line increment
196
; line increment
197
        mov     eax, [putimg.image_sx]
197
        mov     eax, [putimg.image_sx]
198
        mov     ecx, [putimg.real_sx]
198
        mov     ecx, [putimg.real_sx]
199
        sub     eax, ecx
199
        sub     eax, ecx
200
;;     imul    eax, [putimg.source_bpp]
200
;;     imul    eax, [putimg.source_bpp]
201
;     lea     eax, [eax + eax * 2]
201
;     lea     eax, [eax + eax * 2]
202
        call    esi
202
        call    esi
203
        add     eax, [putimg.arg_0]
203
        add     eax, [putimg.arg_0]
204
        mov     [putimg.line_increment], eax
204
        mov     [putimg.line_increment], eax
205
; winmap new line increment
205
; winmap new line increment
206
        mov     eax, [Screen_Max_X]
206
        mov     eax, [Screen_Max_X]
207
        inc     eax
207
        inc     eax
208
        sub     eax, [putimg.real_sx]
208
        sub     eax, [putimg.real_sx]
209
        mov     [putimg.winmap_newline], eax
209
        mov     [putimg.winmap_newline], eax
210
; screen new line increment
210
; screen new line increment
211
        mov     eax, [BytesPerScanLine]
211
        mov     eax, [BytesPerScanLine]
212
        movzx   ebx, byte [ScreenBPP]
212
        movzx   ebx, byte [ScreenBPP]
213
        shr     ebx, 3
213
        shr     ebx, 3
214
        imul    ecx, ebx
214
        imul    ecx, ebx
215
        sub     eax, ecx
215
        sub     eax, ecx
216
        mov     [putimg.screen_newline], eax
216
        mov     [putimg.screen_newline], eax
217
; pointer to image
217
; pointer to image
218
        mov     esi, [putimg.pti]
218
        mov     esi, [putimg.pti]
219
; pointer to screen
219
; pointer to screen
220
        mov     edx, [putimg.abs_cy]
220
        mov     edx, [putimg.abs_cy]
221
        imul    edx, [BytesPerScanLine]
221
        imul    edx, [BytesPerScanLine]
222
        mov     eax, [putimg.abs_cx]
222
        mov     eax, [putimg.abs_cx]
223
        movzx   ebx, byte [ScreenBPP]
223
        movzx   ebx, byte [ScreenBPP]
224
        shr     ebx, 3
224
        shr     ebx, 3
225
        imul    eax, ebx
225
        imul    eax, ebx
226
        add     edx, eax
226
        add     edx, eax
227
; pointer to pixel map
227
; pointer to pixel map
228
        mov     eax, [putimg.abs_cy]
228
        mov     eax, [putimg.abs_cy]
229
        imul    eax, [Screen_Max_X]
229
        imul    eax, [Screen_Max_X]
230
        add     eax, [putimg.abs_cy]
230
        add     eax, [putimg.abs_cy]
231
        add     eax, [putimg.abs_cx]
231
        add     eax, [putimg.abs_cx]
232
        add     eax, [_WinMapAddress]
232
        add     eax, [_WinMapAddress]
233
        xchg    eax, ebp
233
        xchg    eax, ebp
234
;--------------------------------------
234
;--------------------------------------
235
        mov     ecx, [putimg.real_sx]
235
        mov     ecx, [putimg.real_sx]
236
        add     ecx, [putimg.abs_cx]
236
        add     ecx, [putimg.abs_cx]
237
        mov     [putimg.real_sx_and_abs_cx], ecx
237
        mov     [putimg.real_sx_and_abs_cx], ecx
238
        mov     ecx, [putimg.real_sy]
238
        mov     ecx, [putimg.real_sy]
239
        add     ecx, [putimg.abs_cy]
239
        add     ecx, [putimg.abs_cy]
240
        mov     [putimg.real_sy_and_abs_cy], ecx
240
        mov     [putimg.real_sy_and_abs_cy], ecx
241
;--------------------------------------
241
;--------------------------------------
242
; get process number
242
; get process number
243
        mov     ebx, [CURRENT_TASK]
243
        mov     ebx, [CURRENT_TASK]
244
        cmp     byte [ScreenBPP], 32
244
        cmp     byte [ScreenBPP], 32
245
        je      put_image_end_32
245
        je      put_image_end_32
246
;--------------------------------------
246
;--------------------------------------
247
put_image_end_24:
247
put_image_end_24:
248
        mov     edi, [putimg.real_sy]
248
        mov     edi, [putimg.real_sy]
249
        cmp     [_display.select_cursor], 0
249
        cmp     [_display.select_cursor], 0
250
        jne     put_image_end_24_new
250
        jne     put_image_end_24_new
251
;--------------------------------------
251
;--------------------------------------
252
align 4
252
align 4
253
.new_line:
253
.new_line:
254
        mov     ecx, [putimg.real_sx]
254
        mov     ecx, [putimg.real_sx]
255
;--------------------------------------
255
;--------------------------------------
256
align 4
256
align 4
257
.new_x:
257
.new_x:
258
        push    [putimg.edi]
258
        push    [putimg.edi]
259
        mov     eax, [putimg.ebp+4]
259
        mov     eax, [putimg.ebp+4]
260
        call    eax
260
        call    eax
261
        cmp     [ebp], bl
261
        cmp     [ebp], bl
262
        jne     .skip
262
        jne     .skip
263
;--------------------------------------
263
;--------------------------------------
264
        push    ecx
264
        push    ecx
265
 
265
 
266
        neg     ecx
266
        neg     ecx
267
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
267
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
268
        shl     ecx, 16
268
        shl     ecx, 16
269
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
269
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
270
        sub     ecx, edi
270
        sub     ecx, edi
271
 
271
 
272
; check mouse area for putpixel
272
; check mouse area for putpixel
273
        call    check_mouse_area_for_putpixel
273
        call    check_mouse_area_for_putpixel
274
        pop     ecx
274
        pop     ecx
275
; store to real LFB
275
; store to real LFB
276
        mov     [LFB_BASE+edx], ax
276
        mov     [LFB_BASE+edx], ax
277
        shr     eax, 16
277
        shr     eax, 16
278
        mov     [LFB_BASE+edx+2], al
278
        mov     [LFB_BASE+edx+2], al
279
;--------------------------------------
279
;--------------------------------------
280
align 4
280
align 4
281
.skip:
281
.skip:
282
        add     edx, 3
282
        add     edx, 3
283
        inc     ebp
283
        inc     ebp
284
        dec     ecx
284
        dec     ecx
285
        jnz     .new_x
285
        jnz     .new_x
286
 
286
 
287
        add     esi, [putimg.line_increment]
287
        add     esi, [putimg.line_increment]
288
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
288
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
289
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
289
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
290
 
290
 
291
        cmp     [putimg.ebp], putimage_get1bpp
291
        cmp     [putimg.ebp], putimage_get1bpp
292
        jz      .correct
292
        jz      .correct
293
        cmp     [putimg.ebp], putimage_get2bpp
293
        cmp     [putimg.ebp], putimage_get2bpp
294
        jz      .correct
294
        jz      .correct
295
        cmp     [putimg.ebp], putimage_get4bpp
295
        cmp     [putimg.ebp], putimage_get4bpp
296
        jnz     @f
296
        jnz     @f
297
;--------------------------------------
297
;--------------------------------------
298
align 4
298
align 4
299
.correct:
299
.correct:
300
        mov     eax, [putimg.edi]
300
        mov     eax, [putimg.edi]
301
        mov     byte [eax], 80h
301
        mov     byte [eax], 80h
302
;--------------------------------------
302
;--------------------------------------
303
align 4
303
align 4
304
@@:
304
@@:
305
        dec     edi
305
        dec     edi
306
        jnz     .new_line
306
        jnz     .new_line
307
;--------------------------------------
307
;--------------------------------------
308
align 4
308
align 4
309
.finish:
309
.finish:
310
        add     esp, putimg.stack_data
310
        add     esp, putimg.stack_data
311
        popad
311
        popad
312
        ret
312
        ret
313
;--------------------------------------
313
;--------------------------------------
314
align 4
314
align 4
315
put_image_end_24_new:
315
put_image_end_24_new:
316
;--------------------------------------
316
;--------------------------------------
317
align 4
317
align 4
318
.new_line:
318
.new_line:
319
        mov     ecx, [putimg.real_sx]
319
        mov     ecx, [putimg.real_sx]
320
;--------------------------------------
320
;--------------------------------------
321
align 4
321
align 4
322
.new_x:
322
.new_x:
323
        push    [putimg.edi]
323
        push    [putimg.edi]
324
        mov     eax, [putimg.ebp+4]
324
        mov     eax, [putimg.ebp+4]
325
        call    eax
325
        call    eax
326
        cmp     [ebp], bl
326
        cmp     [ebp], bl
327
        jne     .skip
327
        jne     .skip
328
;--------------------------------------
328
;--------------------------------------
329
        push    ecx
329
        push    ecx
330
        mov     ecx, [putimg.real_sy_and_abs_cy + 4]
330
        mov     ecx, [putimg.real_sy_and_abs_cy + 4]
331
        sub     ecx, edi
331
        sub     ecx, edi
332
;--------------------------------------
332
;--------------------------------------
333
; check for Y
333
; check for Y
334
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
334
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
335
        jb      .no_mouse_area
335
        jb      .no_mouse_area
336
 
336
 
337
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
337
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
338
        jae     .no_mouse_area
338
        jae     .no_mouse_area
339
 
339
 
340
        rol     ecx, 16
340
        rol     ecx, 16
341
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
341
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
342
        sub     ecx, [esp]
342
        sub     ecx, [esp]
343
;--------------------------------------
343
;--------------------------------------
344
; check for X
344
; check for X
345
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
345
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
346
        jb      .no_mouse_area
346
        jb      .no_mouse_area
347
 
347
 
348
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
348
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
349
        jae     .no_mouse_area
349
        jae     .no_mouse_area
350
;--------------------------------------
350
;--------------------------------------
351
; check mouse area for putpixel
351
; check mouse area for putpixel
352
        call    check_mouse_area_for_putpixel_new.1
352
        call    check_mouse_area_for_putpixel_new.1
353
;--------------------------------------
353
;--------------------------------------
354
align 4
354
align 4
355
.no_mouse_area:
355
.no_mouse_area:
356
        pop     ecx
356
        pop     ecx
357
; store to real LFB
357
; store to real LFB
358
        mov     [LFB_BASE+edx], ax
358
        mov     [LFB_BASE+edx], ax
359
        shr     eax, 16
359
        shr     eax, 16
360
        mov     [LFB_BASE+edx+2], al
360
        mov     [LFB_BASE+edx+2], al
361
;--------------------------------------
361
;--------------------------------------
362
align 4
362
align 4
363
.skip:
363
.skip:
364
        add     edx, 3
364
        add     edx, 3
365
        inc     ebp
365
        inc     ebp
366
        dec     ecx
366
        dec     ecx
367
        jnz     .new_x
367
        jnz     .new_x
368
 
368
 
369
        add     esi, [putimg.line_increment]
369
        add     esi, [putimg.line_increment]
370
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
370
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
371
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
371
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
372
 
372
 
373
        cmp     [putimg.ebp], putimage_get1bpp
373
        cmp     [putimg.ebp], putimage_get1bpp
374
        jz      .correct
374
        jz      .correct
375
        cmp     [putimg.ebp], putimage_get2bpp
375
        cmp     [putimg.ebp], putimage_get2bpp
376
        jz      .correct
376
        jz      .correct
377
        cmp     [putimg.ebp], putimage_get4bpp
377
        cmp     [putimg.ebp], putimage_get4bpp
378
        jnz     @f
378
        jnz     @f
379
;--------------------------------------
379
;--------------------------------------
380
align 4
380
align 4
381
.correct:
381
.correct:
382
        mov     eax, [putimg.edi]
382
        mov     eax, [putimg.edi]
383
        mov     byte [eax], 80h
383
        mov     byte [eax], 80h
384
;--------------------------------------
384
;--------------------------------------
385
align 4
385
align 4
386
@@:
386
@@:
387
        dec     edi
387
        dec     edi
388
        jnz     .new_line
388
        jnz     .new_line
389
        jmp     put_image_end_24.finish
389
        jmp     put_image_end_24.finish
390
;------------------------------------------------------------------------------
390
;------------------------------------------------------------------------------
391
align 4
391
align 4
392
put_image_end_32:
392
put_image_end_32:
393
        mov     edi, [putimg.real_sy]
393
        mov     edi, [putimg.real_sy]
394
        cmp     [_display.select_cursor], 0
394
        cmp     [_display.select_cursor], 0
395
        jne     put_image_end_32_new
395
        jne     put_image_end_32_new
396
;--------------------------------------
396
;--------------------------------------
397
align 4
397
align 4
398
.new_line:
398
.new_line:
399
        mov     ecx, [putimg.real_sx]
399
        mov     ecx, [putimg.real_sx]
400
;--------------------------------------
400
;--------------------------------------
401
align 4
401
align 4
402
.new_x:
402
.new_x:
403
        push    [putimg.edi]
403
        push    [putimg.edi]
404
        mov     eax, [putimg.ebp+4]
404
        mov     eax, [putimg.ebp+4]
405
        call    eax
405
        call    eax
406
        cmp     [ebp], bl
406
        cmp     [ebp], bl
407
        jne     .skip
407
        jne     .skip
408
;--------------------------------------
408
;--------------------------------------
409
        push    ecx
409
        push    ecx
410
 
410
 
411
        neg     ecx
411
        neg     ecx
412
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
412
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
413
        shl     ecx, 16
413
        shl     ecx, 16
414
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
414
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
415
        sub     ecx, edi
415
        sub     ecx, edi
416
 
416
 
417
; check mouse area for putpixel
417
; check mouse area for putpixel
418
        call    check_mouse_area_for_putpixel
418
        call    check_mouse_area_for_putpixel
419
        pop     ecx
419
        pop     ecx
420
; store to real LFB
420
; store to real LFB
421
        mov     [LFB_BASE+edx], eax
421
        mov     [LFB_BASE+edx], eax
422
;--------------------------------------
422
;--------------------------------------
423
align 4
423
align 4
424
.skip:
424
.skip:
425
        add     edx, 4
425
        add     edx, 4
426
        inc     ebp
426
        inc     ebp
427
        dec     ecx
427
        dec     ecx
428
        jnz     .new_x
428
        jnz     .new_x
429
 
429
 
430
        add     esi, [putimg.line_increment]
430
        add     esi, [putimg.line_increment]
431
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
431
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
432
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
432
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
433
 
433
 
434
        cmp     [putimg.ebp], putimage_get1bpp
434
        cmp     [putimg.ebp], putimage_get1bpp
435
        jz      .correct
435
        jz      .correct
436
        cmp     [putimg.ebp], putimage_get2bpp
436
        cmp     [putimg.ebp], putimage_get2bpp
437
        jz      .correct
437
        jz      .correct
438
        cmp     [putimg.ebp], putimage_get4bpp
438
        cmp     [putimg.ebp], putimage_get4bpp
439
        jnz     @f
439
        jnz     @f
440
;--------------------------------------
440
;--------------------------------------
441
align 4
441
align 4
442
.correct:
442
.correct:
443
        mov     eax, [putimg.edi]
443
        mov     eax, [putimg.edi]
444
        mov     byte [eax], 80h
444
        mov     byte [eax], 80h
445
;--------------------------------------
445
;--------------------------------------
446
align 4
446
align 4
447
@@:
447
@@:
448
        dec     edi
448
        dec     edi
449
        jnz     .new_line
449
        jnz     .new_line
450
;--------------------------------------
450
;--------------------------------------
451
align 4
451
align 4
452
.finish:
452
.finish:
453
        add     esp, putimg.stack_data
453
        add     esp, putimg.stack_data
454
        popad
454
        popad
455
        cmp     [SCR_MODE], dword 0x12
455
        cmp     [SCR_MODE], dword 0x12
456
        jne     @f
456
        jne     @f
457
        call    VGA__putimage
457
        call    VGA__putimage
458
;--------------------------------------
458
;--------------------------------------
459
align 4
459
align 4
460
@@:
460
@@:
461
        mov     [EGA_counter], 1
461
        mov     [EGA_counter], 1
462
        ret
462
        ret
463
;--------------------------------------
463
;--------------------------------------
464
align 4
464
align 4
465
put_image_end_32_new:
465
put_image_end_32_new:
466
;--------------------------------------
466
;--------------------------------------
467
align 4
467
align 4
468
.new_line:
468
.new_line:
469
        mov     ecx, [putimg.real_sx]
469
        mov     ecx, [putimg.real_sx]
470
;--------------------------------------
470
;--------------------------------------
471
align 4
471
align 4
472
.new_x:
472
.new_x:
473
        push    [putimg.edi]
473
        push    [putimg.edi]
474
        mov     eax, [putimg.ebp+4]
474
        mov     eax, [putimg.ebp+4]
475
        call    eax
475
        call    eax
476
        cmp     [ebp], bl
476
        cmp     [ebp], bl
477
        jne     .skip
477
        jne     .skip
478
;--------------------------------------
478
;--------------------------------------
479
        push    ecx
479
        push    ecx
480
        mov     ecx, [putimg.real_sy_and_abs_cy + 4]
480
        mov     ecx, [putimg.real_sy_and_abs_cy + 4]
481
        sub     ecx, edi
481
        sub     ecx, edi
482
;--------------------------------------
482
;--------------------------------------
483
; check for Y
483
; check for Y
484
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
484
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
485
        jb      .no_mouse_area
485
        jb      .no_mouse_area
486
 
486
 
487
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
487
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
488
        jae     .no_mouse_area
488
        jae     .no_mouse_area
489
 
489
 
490
        rol     ecx, 16
490
        rol     ecx, 16
491
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
491
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
492
        sub     ecx, [esp]
492
        sub     ecx, [esp]
493
;--------------------------------------
493
;--------------------------------------
494
; check for X
494
; check for X
495
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
495
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
496
        jb      .no_mouse_area
496
        jb      .no_mouse_area
497
 
497
 
498
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
498
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
499
        jae     .no_mouse_area
499
        jae     .no_mouse_area
500
;--------------------------------------
500
;--------------------------------------
501
; check mouse area for putpixel
501
; check mouse area for putpixel
502
        call    check_mouse_area_for_putpixel_new.1
502
        call    check_mouse_area_for_putpixel_new.1
503
;--------------------------------------
503
;--------------------------------------
504
align 4
504
align 4
505
.no_mouse_area:
505
.no_mouse_area:
506
        pop     ecx
506
        pop     ecx
507
; store to real LFB
507
; store to real LFB
508
        mov     [LFB_BASE+edx], eax
508
        mov     [LFB_BASE+edx], eax
509
;--------------------------------------
509
;--------------------------------------
510
align 4
510
align 4
511
.skip:
511
.skip:
512
        add     edx, 4
512
        add     edx, 4
513
        inc     ebp
513
        inc     ebp
514
        dec     ecx
514
        dec     ecx
515
        jnz     .new_x
515
        jnz     .new_x
516
 
516
 
517
        add     esi, [putimg.line_increment]
517
        add     esi, [putimg.line_increment]
518
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
518
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
519
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
519
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
520
 
520
 
521
        cmp     [putimg.ebp], putimage_get1bpp
521
        cmp     [putimg.ebp], putimage_get1bpp
522
        jz      .correct
522
        jz      .correct
523
        cmp     [putimg.ebp], putimage_get2bpp
523
        cmp     [putimg.ebp], putimage_get2bpp
524
        jz      .correct
524
        jz      .correct
525
        cmp     [putimg.ebp], putimage_get4bpp
525
        cmp     [putimg.ebp], putimage_get4bpp
526
        jnz     @f
526
        jnz     @f
527
;--------------------------------------
527
;--------------------------------------
528
align 4
528
align 4
529
.correct:
529
.correct:
530
        mov     eax, [putimg.edi]
530
        mov     eax, [putimg.edi]
531
        mov     byte [eax], 80h
531
        mov     byte [eax], 80h
532
;--------------------------------------
532
;--------------------------------------
533
align 4
533
align 4
534
@@:
534
@@:
535
        dec     edi
535
        dec     edi
536
        jnz     .new_line
536
        jnz     .new_line
537
        jmp     put_image_end_32.finish
537
        jmp     put_image_end_32.finish
538
;------------------------------------------------------------------------------
538
;------------------------------------------------------------------------------
539
align 4
539
align 4
540
__sys_putpixel:
540
__sys_putpixel:
541
 
541
 
542
; eax = x coordinate
542
; eax = x coordinate
543
; ebx = y coordinate
543
; ebx = y coordinate
544
; ecx = ?? RR GG BB    ; 0x01000000 negation
544
; ecx = ?? RR GG BB    ; 0x01000000 negation
545
                       ; 0x02000000 used for draw_rectangle without top line
545
                       ; 0x02000000 used for draw_rectangle without top line
546
                       ;            for example drawwindow_III and drawwindow_IV
546
                       ;            for example drawwindow_III and drawwindow_IV
547
; edi = 0x00000001 force
547
; edi = 0x00000001 force
548
 
548
 
549
;;;        mov  [novesachecksum], dword 0
549
;;;        mov  [novesachecksum], dword 0
550
        pushad
550
        pushad
551
        cmp     [Screen_Max_X], eax
551
        cmp     [Screen_Max_X], eax
552
        jb      .exit
552
        jb      .exit
553
        cmp     [Screen_Max_Y], ebx
553
        cmp     [Screen_Max_Y], ebx
554
        jb      .exit
554
        jb      .exit
555
        test    edi, 1           ; force ?
555
        test    edi, 1           ; force ?
556
        jnz     .forced
556
        jnz     .forced
557
 
557
 
558
; not forced:
558
; not forced:
559
 
-
 
560
        push    eax
-
 
561
        mov     edx, [_display.width]; screen x size
559
        mov     edx, [d_width_calc_area + ebx*4]
562
        imul    edx, ebx
-
 
563
        add     eax, [_WinMapAddress]
560
        add     edx, [_WinMapAddress]
564
        movzx   edx, byte [eax+edx]
561
        movzx   edx, byte [eax+edx]
565
        cmp     edx, [CURRENT_TASK]
562
        cmp     edx, [CURRENT_TASK]
566
        pop     eax
-
 
567
        jne     .exit
563
        jne     .exit
568
;--------------------------------------
564
;--------------------------------------
569
align 4
565
align 4
570
.forced:
566
.forced:
571
; check if negation
567
; check if negation
572
        test    ecx, 0x01000000
568
        test    ecx, 0x01000000
573
        jz      .noneg
569
        jz      .noneg
574
 
570
 
575
        call    getpixel
571
        call    getpixel
576
        not     ecx
572
        not     ecx
577
 
573
 
578
        rol     ecx, 8
574
        rol     ecx, 8
579
        mov     cl, [esp+32-8+3]
575
        mov     cl, [esp+32-8+3]
580
        ror     ecx, 8
576
        ror     ecx, 8
581
        mov     [esp+32-8], ecx
577
        mov     [esp+32-8], ecx
582
;--------------------------------------
578
;--------------------------------------
583
align 4
579
align 4
584
.noneg:
580
.noneg:
585
; OK to set pixel
581
; OK to set pixel
586
        call    dword [PUTPIXEL]; call the real put_pixel function
582
        call    dword [PUTPIXEL]; call the real put_pixel function
587
;--------------------------------------
583
;--------------------------------------
588
align 4
584
align 4
589
.exit:
585
.exit:
590
        popad
586
        popad
591
        ret
587
        ret
592
;-----------------------------------------------------------------------------
588
;-----------------------------------------------------------------------------
593
align 4
589
align 4
594
Vesa20_putpixel24:
590
Vesa20_putpixel24:
595
; eax = x
591
; eax = x
596
; ebx = y
592
; ebx = y
597
        mov     ecx, eax
593
        mov     ecx, eax
598
        shl     ecx, 16
594
        shl     ecx, 16
599
        mov     cx, bx
595
        mov     cx, bx
600
 
596
 
601
        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
597
        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
602
        lea     edi, [eax+eax*2]; edi = x*3
598
        lea     edi, [eax+eax*2]; edi = x*3
603
        mov     eax, [esp+32-8+4]
599
        mov     eax, [esp+32-8+4]
604
;--------------------------------------
600
;--------------------------------------
605
; check mouse area for putpixel
601
; check mouse area for putpixel
606
        test    eax, 0x04000000
602
        test    eax, 0x04000000
607
        jnz     @f
603
        jnz     @f
608
        call    check_mouse_area_for_putpixel
604
        call    check_mouse_area_for_putpixel
609
;--------------------------------------
605
;--------------------------------------
610
align 4
606
align 4
611
@@:
607
@@:
612
; store to real LFB
608
; store to real LFB
613
        mov     [LFB_BASE+ebx+edi], ax
609
        mov     [LFB_BASE+ebx+edi], ax
614
        shr     eax, 16
610
        shr     eax, 16
615
        mov     [LFB_BASE+ebx+edi+2], al
611
        mov     [LFB_BASE+ebx+edi+2], al
616
        ret
612
        ret
617
;-----------------------------------------------------------------------------
613
;-----------------------------------------------------------------------------
618
align 4
614
align 4
619
Vesa20_putpixel24_new:
615
Vesa20_putpixel24_new:
620
; eax = x
616
; eax = x
621
; ebx = y
617
; ebx = y
622
        mov     ecx, eax
618
        mov     ecx, eax
623
        shl     ecx, 16
619
        shl     ecx, 16
624
        mov     cx, bx
620
        mov     cx, bx
625
 
621
 
626
        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
622
        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
627
        lea     edi, [eax+eax*2]; edi = x*3
623
        lea     edi, [eax+eax*2]; edi = x*3
628
        mov     eax, [esp+32-8+4]
624
        mov     eax, [esp+32-8+4]
629
;--------------------------------------
625
;--------------------------------------
630
; check mouse area for putpixel
626
; check mouse area for putpixel
631
        test    eax, 0x04000000
627
        test    eax, 0x04000000
632
        jnz     @f
628
        jnz     @f
633
;--------------------------------------
629
;--------------------------------------
634
; check for Y
630
; check for Y
635
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
631
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
636
        jb      @f
632
        jb      @f
637
 
633
 
638
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
634
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
639
        jae     @f
635
        jae     @f
640
 
636
 
641
        rol     ecx, 16
637
        rol     ecx, 16
642
;--------------------------------------
638
;--------------------------------------
643
; check for X
639
; check for X
644
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
640
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
645
        jb      @f
641
        jb      @f
646
 
642
 
647
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
643
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
648
        jae     @f
644
        jae     @f
649
 
645
 
650
        call    check_mouse_area_for_putpixel_new.1
646
        call    check_mouse_area_for_putpixel_new.1
651
;--------------------------------------
647
;--------------------------------------
652
align 4
648
align 4
653
@@:
649
@@:
654
; store to real LFB
650
; store to real LFB
655
        mov     [LFB_BASE+ebx+edi], ax
651
        mov     [LFB_BASE+ebx+edi], ax
656
        shr     eax, 16
652
        shr     eax, 16
657
        mov     [LFB_BASE+ebx+edi+2], al
653
        mov     [LFB_BASE+ebx+edi+2], al
658
        ret
654
        ret
659
;-----------------------------------------------------------------------------
655
;-----------------------------------------------------------------------------
660
align 4
656
align 4
661
Vesa20_putpixel32:
657
Vesa20_putpixel32:
662
; eax = x
658
; eax = x
663
; ebx = y
659
; ebx = y
664
        mov     ecx, eax
660
        mov     ecx, eax
665
        shl     ecx, 16
661
        shl     ecx, 16
666
        mov     cx, bx
662
        mov     cx, bx
667
 
663
 
668
        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
664
        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
669
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
665
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
670
        mov     eax, [esp+32-8+4]; eax = color
666
        mov     eax, [esp+32-8+4]; eax = color
671
;--------------------------------------
667
;--------------------------------------
672
; check mouse area for putpixel
668
; check mouse area for putpixel
673
        test    eax, 0x04000000
669
        test    eax, 0x04000000
674
        jnz     @f
670
        jnz     @f
675
        call    check_mouse_area_for_putpixel
671
        call    check_mouse_area_for_putpixel
676
;--------------------------------------
672
;--------------------------------------
677
align 4
673
align 4
678
@@:
674
@@:
679
        and     eax, 0xffffff
675
        and     eax, 0xffffff
680
; store to real LFB
676
; store to real LFB
681
        mov     [LFB_BASE+edi], eax
677
        mov     [LFB_BASE+edi], eax
682
        ret
678
        ret
683
;-----------------------------------------------------------------------------
679
;-----------------------------------------------------------------------------
684
align 4
680
align 4
685
Vesa20_putpixel32_new:
681
Vesa20_putpixel32_new:
686
; eax = x
682
; eax = x
687
; ebx = y
683
; ebx = y
688
        mov     ecx, eax
684
        mov     ecx, eax
689
        shl     ecx, 16
685
        shl     ecx, 16
690
        mov     cx, bx
686
        mov     cx, bx
691
 
687
 
692
        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
688
        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
693
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
689
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
694
        mov     eax, [esp+32-8+4]; eax = color
690
        mov     eax, [esp+32-8+4]; eax = color
695
;--------------------------------------
691
;--------------------------------------
696
; check mouse area for putpixel
692
; check mouse area for putpixel
697
        test    eax, 0x04000000
693
        test    eax, 0x04000000
698
        jnz     @f
694
        jnz     @f
699
;--------------------------------------
695
;--------------------------------------
700
; check for Y
696
; check for Y
701
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
697
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
702
        jb      @f
698
        jb      @f
703
 
699
 
704
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
700
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
705
        jae     @f
701
        jae     @f
706
 
702
 
707
        rol     ecx, 16
703
        rol     ecx, 16
708
;--------------------------------------
704
;--------------------------------------
709
; check for X
705
; check for X
710
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
706
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
711
        jb      @f
707
        jb      @f
712
 
708
 
713
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
709
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
714
        jae     @f
710
        jae     @f
715
 
711
 
716
        call    check_mouse_area_for_putpixel_new.1
712
        call    check_mouse_area_for_putpixel_new.1
717
;--------------------------------------
713
;--------------------------------------
718
align 4
714
align 4
719
@@:
715
@@:
720
        and     eax, 0xffffff
716
        and     eax, 0xffffff
721
; store to real LFB
717
; store to real LFB
722
        mov     [LFB_BASE+edi], eax
718
        mov     [LFB_BASE+edi], eax
723
        ret
719
        ret
724
;-----------------------------------------------------------------------------
720
;-----------------------------------------------------------------------------
725
align 4
721
align 4
726
calculate_edi:
722
calculate_edi:
727
        mov     edi, ebx
723
        mov     edi, ebx
728
        imul    edi, [Screen_Max_X]
724
        imul    edi, [Screen_Max_X]
729
        add     edi, ebx
725
        add     edi, ebx
730
        add     edi, eax
726
        add     edi, eax
731
        ret
727
        ret
732
;-----------------------------------------------------------------------------
728
;-----------------------------------------------------------------------------
733
; DRAWLINE
729
; DRAWLINE
734
;-----------------------------------------------------------------------------
730
;-----------------------------------------------------------------------------
735
align 4
731
align 4
736
__sys_draw_line:
732
__sys_draw_line:
737
; draw a line
733
; draw a line
738
; eax = HIWORD = x1
734
; eax = HIWORD = x1
739
;       LOWORD = x2
735
;       LOWORD = x2
740
; ebx = HIWORD = y1
736
; ebx = HIWORD = y1
741
;       LOWORD = y2
737
;       LOWORD = y2
742
; ecx = color
738
; ecx = color
743
; edi = force ?
739
; edi = force ?
744
        pusha
740
        pusha
745
 
741
 
746
dl_x1 equ esp+20
742
dl_x1 equ esp+20
747
dl_y1 equ esp+16
743
dl_y1 equ esp+16
748
dl_x2 equ esp+12
744
dl_x2 equ esp+12
749
dl_y2 equ esp+8
745
dl_y2 equ esp+8
750
dl_dx equ esp+4
746
dl_dx equ esp+4
751
dl_dy equ esp+0
747
dl_dy equ esp+0
752
 
748
 
753
        xor     edx, edx   ; clear edx
749
        xor     edx, edx   ; clear edx
754
        xor     esi, esi   ; unpack arguments
750
        xor     esi, esi   ; unpack arguments
755
        xor     ebp, ebp
751
        xor     ebp, ebp
756
        mov     si, ax     ; esi = x2
752
        mov     si, ax     ; esi = x2
757
        mov     bp, bx     ; ebp = y2
753
        mov     bp, bx     ; ebp = y2
758
        shr     eax, 16    ; eax = x1
754
        shr     eax, 16    ; eax = x1
759
        shr     ebx, 16    ; ebx = y1
755
        shr     ebx, 16    ; ebx = y1
760
        push    eax        ; save x1
756
        push    eax        ; save x1
761
        push    ebx        ; save y1
757
        push    ebx        ; save y1
762
        push    esi        ; save x2
758
        push    esi        ; save x2
763
        push    ebp        ; save y2
759
        push    ebp        ; save y2
764
; checking x-axis...
760
; checking x-axis...
765
        sub     esi, eax   ; esi = x2-x1
761
        sub     esi, eax   ; esi = x2-x1
766
        push    esi        ; save y2-y1
762
        push    esi        ; save y2-y1
767
        jl      .x2lx1     ; is x2 less than x1 ?
763
        jl      .x2lx1     ; is x2 less than x1 ?
768
        jg      .no_vline  ; x1 > x2 ?
764
        jg      .no_vline  ; x1 > x2 ?
769
        mov     edx, ebp   ; else (if x1=x2)
765
        mov     edx, ebp   ; else (if x1=x2)
770
        call    vline
766
        call    vline
771
        push    edx ; necessary to rightly restore stack frame at .exit
767
        push    edx ; necessary to rightly restore stack frame at .exit
772
        jmp     .exit
768
        jmp     .exit
773
;--------------------------------------
769
;--------------------------------------
774
align 4
770
align 4
775
.x2lx1:
771
.x2lx1:
776
        neg     esi         ; get esi absolute value
772
        neg     esi         ; get esi absolute value
777
;--------------------------------------
773
;--------------------------------------
778
align 4
774
align 4
779
.no_vline:
775
.no_vline:
780
; checking y-axis...
776
; checking y-axis...
781
        sub     ebp, ebx    ; ebp = y2-y1
777
        sub     ebp, ebx    ; ebp = y2-y1
782
        push    ebp         ; save y2-y1
778
        push    ebp         ; save y2-y1
783
        jl      .y2ly1      ; is y2 less than y1 ?
779
        jl      .y2ly1      ; is y2 less than y1 ?
784
        jg      .no_hline   ; y1 > y2 ?
780
        jg      .no_hline   ; y1 > y2 ?
785
        mov     edx, [dl_x2]; else (if y1=y2)
781
        mov     edx, [dl_x2]; else (if y1=y2)
786
        call    hline
782
        call    hline
787
        jmp     .exit
783
        jmp     .exit
788
;--------------------------------------
784
;--------------------------------------
789
align 4
785
align 4
790
.y2ly1:
786
.y2ly1:
791
        neg     ebp         ; get ebp absolute value
787
        neg     ebp         ; get ebp absolute value
792
;--------------------------------------
788
;--------------------------------------
793
align 4
789
align 4
794
.no_hline:
790
.no_hline:
795
        cmp     ebp, esi
791
        cmp     ebp, esi
796
        jle     .x_rules    ; |y2-y1| < |x2-x1|  ?
792
        jle     .x_rules    ; |y2-y1| < |x2-x1|  ?
797
        cmp     [dl_y2], ebx; make sure y1 is at the begining
793
        cmp     [dl_y2], ebx; make sure y1 is at the begining
798
        jge     .no_reverse1
794
        jge     .no_reverse1
799
        neg     dword [dl_dx]
795
        neg     dword [dl_dx]
800
        mov     edx, [dl_x2]
796
        mov     edx, [dl_x2]
801
        mov     [dl_x2], eax
797
        mov     [dl_x2], eax
802
        mov     [dl_x1], edx
798
        mov     [dl_x1], edx
803
        mov     edx, [dl_y2]
799
        mov     edx, [dl_y2]
804
        mov     [dl_y2], ebx
800
        mov     [dl_y2], ebx
805
        mov     [dl_y1], edx
801
        mov     [dl_y1], edx
806
;--------------------------------------
802
;--------------------------------------
807
align 4
803
align 4
808
.no_reverse1:
804
.no_reverse1:
809
        mov     eax, [dl_dx]
805
        mov     eax, [dl_dx]
810
        cdq                 ; extend eax sing to edx
806
        cdq                 ; extend eax sing to edx
811
        shl     eax, 16     ; using 16bit fix-point maths
807
        shl     eax, 16     ; using 16bit fix-point maths
812
        idiv    ebp         ; eax = ((x2-x1)*65536)/(y2-y1)
808
        idiv    ebp         ; eax = ((x2-x1)*65536)/(y2-y1)
813
;--------------------------------------
809
;--------------------------------------
814
; correction for the remainder of the division
810
; correction for the remainder of the division
815
        shl     edx, 1
811
        shl     edx, 1
816
        cmp     ebp, edx
812
        cmp     ebp, edx
817
        jb      @f
813
        jb      @f
818
        inc     eax
814
        inc     eax
819
;--------------------------------------
815
;--------------------------------------
820
align 4
816
align 4
821
@@:
817
@@:
822
;--------------------------------------
818
;--------------------------------------
823
        mov     edx, ebp    ; edx = counter (number of pixels to draw)
819
        mov     edx, ebp    ; edx = counter (number of pixels to draw)
824
        mov     ebp, 1 *65536; <<16   ; ebp = dy = 1.0
820
        mov     ebp, 1 *65536; <<16   ; ebp = dy = 1.0
825
        mov     esi, eax    ; esi = dx
821
        mov     esi, eax    ; esi = dx
826
        jmp     .y_rules
822
        jmp     .y_rules
827
;--------------------------------------
823
;--------------------------------------
828
align 4
824
align 4
829
.x_rules:
825
.x_rules:
830
        cmp     [dl_x2], eax ; make sure x1 is at the begining
826
        cmp     [dl_x2], eax ; make sure x1 is at the begining
831
        jge     .no_reverse2
827
        jge     .no_reverse2
832
        neg     dword [dl_dy]
828
        neg     dword [dl_dy]
833
        mov     edx, [dl_x2]
829
        mov     edx, [dl_x2]
834
        mov     [dl_x2], eax
830
        mov     [dl_x2], eax
835
        mov     [dl_x1], edx
831
        mov     [dl_x1], edx
836
        mov     edx, [dl_y2]
832
        mov     edx, [dl_y2]
837
        mov     [dl_y2], ebx
833
        mov     [dl_y2], ebx
838
        mov     [dl_y1], edx
834
        mov     [dl_y1], edx
839
;--------------------------------------
835
;--------------------------------------
840
align 4
836
align 4
841
.no_reverse2:
837
.no_reverse2:
842
        xor     edx, edx
838
        xor     edx, edx
843
        mov     eax, [dl_dy]
839
        mov     eax, [dl_dy]
844
        cdq                 ; extend eax sing to edx
840
        cdq                 ; extend eax sing to edx
845
        shl     eax, 16     ; using 16bit fix-point maths
841
        shl     eax, 16     ; using 16bit fix-point maths
846
        idiv    esi         ; eax = ((y2-y1)*65536)/(x2-x1)
842
        idiv    esi         ; eax = ((y2-y1)*65536)/(x2-x1)
847
;--------------------------------------
843
;--------------------------------------
848
; correction for the remainder of the division
844
; correction for the remainder of the division
849
        shl     edx, 1
845
        shl     edx, 1
850
        cmp     esi, edx
846
        cmp     esi, edx
851
        jb      @f
847
        jb      @f
852
        inc     eax
848
        inc     eax
853
;--------------------------------------
849
;--------------------------------------
854
align 4
850
align 4
855
@@:
851
@@:
856
;--------------------------------------
852
;--------------------------------------
857
        mov     edx, esi    ; edx = counter (number of pixels to draw)
853
        mov     edx, esi    ; edx = counter (number of pixels to draw)
858
        mov     esi, 1 *65536;<< 16   ; esi = dx = 1.0
854
        mov     esi, 1 *65536;<< 16   ; esi = dx = 1.0
859
        mov     ebp, eax    ; ebp = dy
855
        mov     ebp, eax    ; ebp = dy
860
;--------------------------------------
856
;--------------------------------------
861
align 4
857
align 4
862
.y_rules:
858
.y_rules:
863
        mov     eax, [dl_x1]
859
        mov     eax, [dl_x1]
864
        mov     ebx, [dl_y1]
860
        mov     ebx, [dl_y1]
865
        shl     eax, 16
861
        shl     eax, 16
866
        shl     ebx, 16
862
        shl     ebx, 16
867
;-----------------------------------------------------------------------------
863
;-----------------------------------------------------------------------------
868
align 4
864
align 4
869
.draw:
865
.draw:
870
        push    eax ebx
866
        push    eax ebx
871
;--------------------------------------
867
;--------------------------------------
872
; correction for the remainder of the division
868
; correction for the remainder of the division
873
        test    ah, 0x80
869
        test    ah, 0x80
874
        jz      @f
870
        jz      @f
875
        add     eax, 1 shl 16
871
        add     eax, 1 shl 16
876
;--------------------------------------
872
;--------------------------------------
877
align 4
873
align 4
878
@@:
874
@@:
879
;--------------------------------------
875
;--------------------------------------
880
        shr     eax, 16
876
        shr     eax, 16
881
;--------------------------------------
877
;--------------------------------------
882
; correction for the remainder of the division
878
; correction for the remainder of the division
883
        test    bh, 0x80
879
        test    bh, 0x80
884
        jz      @f
880
        jz      @f
885
        add     ebx, 1 shl 16
881
        add     ebx, 1 shl 16
886
;--------------------------------------
882
;--------------------------------------
887
align 4
883
align 4
888
@@:
884
@@:
889
;--------------------------------------
885
;--------------------------------------
890
        shr     ebx, 16
886
        shr     ebx, 16
891
        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
887
        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
892
        call    [putpixel]
888
        call    [putpixel]
893
        pop     ebx eax
889
        pop     ebx eax
894
        add     ebx, ebp     ; y = y+dy
890
        add     ebx, ebp     ; y = y+dy
895
        add     eax, esi     ; x = x+dx
891
        add     eax, esi     ; x = x+dx
896
        dec     edx
892
        dec     edx
897
        jnz     .draw
893
        jnz     .draw
898
; force last drawn pixel to be at (x2,y2)
894
; force last drawn pixel to be at (x2,y2)
899
        mov     eax, [dl_x2]
895
        mov     eax, [dl_x2]
900
        mov     ebx, [dl_y2]
896
        mov     ebx, [dl_y2]
901
        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
897
        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
902
        call    [putpixel]
898
        call    [putpixel]
903
;--------------------------------------
899
;--------------------------------------
904
align 4
900
align 4
905
.exit:
901
.exit:
906
        add     esp, 6*4
902
        add     esp, 6*4
907
        popa
903
        popa
908
;        call    [draw_pointer]
904
;        call    [draw_pointer]
909
        ret
905
        ret
910
;------------------------------------------------------------------------------
906
;------------------------------------------------------------------------------
911
align 4
907
align 4
912
hline:
908
hline:
913
; draw an horizontal line
909
; draw an horizontal line
914
; eax = x1
910
; eax = x1
915
; edx = x2
911
; edx = x2
916
; ebx = y
912
; ebx = y
917
; ecx = color
913
; ecx = color
918
; edi = force ?
914
; edi = force ?
919
        push    eax edx
915
        push    eax edx
920
        cmp     edx, eax   ; make sure x2 is above x1
916
        cmp     edx, eax   ; make sure x2 is above x1
921
        jge     @f
917
        jge     @f
922
        xchg    eax, edx
918
        xchg    eax, edx
923
;--------------------------------------
919
;--------------------------------------
924
align 4
920
align 4
925
@@:
921
@@:
926
        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
922
        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
927
        call    [putpixel]
923
        call    [putpixel]
928
        inc     eax
924
        inc     eax
929
        cmp     eax, edx
925
        cmp     eax, edx
930
        jle     @b
926
        jle     @b
931
        pop     edx eax
927
        pop     edx eax
932
        ret
928
        ret
933
;------------------------------------------------------------------------------
929
;------------------------------------------------------------------------------
934
align 4
930
align 4
935
vline:
931
vline:
936
; draw a vertical line
932
; draw a vertical line
937
; eax = x
933
; eax = x
938
; ebx = y1
934
; ebx = y1
939
; edx = y2
935
; edx = y2
940
; ecx = color
936
; ecx = color
941
; edi = force ?
937
; edi = force ?
942
        push    ebx edx
938
        push    ebx edx
943
        cmp     edx, ebx   ; make sure y2 is above y1
939
        cmp     edx, ebx   ; make sure y2 is above y1
944
        jge     @f
940
        jge     @f
945
        xchg    ebx, edx
941
        xchg    ebx, edx
946
;--------------------------------------
942
;--------------------------------------
947
align 4
943
align 4
948
@@:
944
@@:
949
        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
945
        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
950
        call    [putpixel]
946
        call    [putpixel]
951
        inc     ebx
947
        inc     ebx
952
        cmp     ebx, edx
948
        cmp     ebx, edx
953
        jle     @b
949
        jle     @b
954
        pop     edx ebx
950
        pop     edx ebx
955
        ret
951
        ret
956
;------------------------------------------------------------------------------
952
;------------------------------------------------------------------------------
957
align 4
953
align 4
958
virtual at esp
954
virtual at esp
959
drbar:
955
drbar:
960
     .bar_sx       dd ?
956
     .bar_sx       dd ?
961
     .bar_sy       dd ?
957
     .bar_sy       dd ?
962
     .bar_cx       dd ?
958
     .bar_cx       dd ?
963
     .bar_cy       dd ?
959
     .bar_cy       dd ?
964
     .abs_cx       dd ?
960
     .abs_cx       dd ?
965
     .abs_cy       dd ?
961
     .abs_cy       dd ?
966
     .real_sx      dd ?
962
     .real_sx      dd ?
967
     .real_sy      dd ?
963
     .real_sy      dd ?
968
     .color        dd ?
964
     .color        dd ?
969
     .line_inc_scr dd ?
965
     .line_inc_scr dd ?
970
     .line_inc_map dd ?
966
     .line_inc_map dd ?
971
     .real_sx_and_abs_cx dd ?
967
     .real_sx_and_abs_cx dd ?
972
     .real_sy_and_abs_cy dd ?
968
     .real_sy_and_abs_cy dd ?
973
     .stack_data = 4*13
969
     .stack_data = 4*13
974
end virtual
970
end virtual
975
;--------------------------------------
971
;--------------------------------------
976
align 4
972
align 4
977
; eax   cx
973
; eax   cx
978
; ebx   cy
974
; ebx   cy
979
; ecx   xe
975
; ecx   xe
980
; edx   ye
976
; edx   ye
981
; edi   color
977
; edi   color
982
vesa20_drawbar:
978
vesa20_drawbar:
983
        pushad
979
        pushad
984
        sub     esp, drbar.stack_data
980
        sub     esp, drbar.stack_data
985
        mov     [drbar.color], edi
981
        mov     [drbar.color], edi
986
        sub     edx, ebx
982
        sub     edx, ebx
987
        jle     .exit       ;// mike.dld, 2005-01-29
983
        jle     .exit       ;// mike.dld, 2005-01-29
988
        sub     ecx, eax
984
        sub     ecx, eax
989
        jle     .exit       ;// mike.dld, 2005-01-29
985
        jle     .exit       ;// mike.dld, 2005-01-29
990
        mov     [drbar.bar_sy], edx
986
        mov     [drbar.bar_sy], edx
991
        mov     [drbar.bar_sx], ecx
987
        mov     [drbar.bar_sx], ecx
992
        mov     [drbar.bar_cx], eax
988
        mov     [drbar.bar_cx], eax
993
        mov     [drbar.bar_cy], ebx
989
        mov     [drbar.bar_cy], ebx
994
        mov     edi, [TASK_BASE]
990
        mov     edi, [TASK_BASE]
995
        add     eax, [edi-twdw + WDATA.box.left]; win_cx
991
        add     eax, [edi-twdw + WDATA.box.left]; win_cx
996
        add     ebx, [edi-twdw + WDATA.box.top]; win_cy
992
        add     ebx, [edi-twdw + WDATA.box.top]; win_cy
997
        mov     [drbar.abs_cx], eax
993
        mov     [drbar.abs_cx], eax
998
        mov     [drbar.abs_cy], ebx
994
        mov     [drbar.abs_cy], ebx
999
; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
995
; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
1000
        mov     ebx, [edi-twdw + WDATA.box.width]; ebx = wnd_sx
996
        mov     ebx, [edi-twdw + WDATA.box.width]; ebx = wnd_sx
1001
; \begin{diamond}[20.08.2006]
997
; \begin{diamond}[20.08.2006]
1002
; note that WDATA.box.width is one pixel less than real window x-size
998
; note that WDATA.box.width is one pixel less than real window x-size
1003
        inc     ebx
999
        inc     ebx
1004
; \end{diamond}[20.08.2006]
1000
; \end{diamond}[20.08.2006]
1005
        sub     ebx, [drbar.bar_cx]
1001
        sub     ebx, [drbar.bar_cx]
1006
        ja      @f
1002
        ja      @f
1007
;--------------------------------------
1003
;--------------------------------------
1008
align 4
1004
align 4
1009
.exit:                       ;// mike.dld, 2005-01-29
1005
.exit:                       ;// mike.dld, 2005-01-29
1010
        add     esp, drbar.stack_data
1006
        add     esp, drbar.stack_data
1011
        popad
1007
        popad
1012
        xor     eax, eax
1008
        xor     eax, eax
1013
        inc     eax
1009
        inc     eax
1014
        ret
1010
        ret
1015
;--------------------------------------
1011
;--------------------------------------
1016
align 4
1012
align 4
1017
@@:
1013
@@:
1018
        cmp     ebx, [drbar.bar_sx]
1014
        cmp     ebx, [drbar.bar_sx]
1019
        jbe     .end_x
1015
        jbe     .end_x
1020
        mov     ebx, [drbar.bar_sx]
1016
        mov     ebx, [drbar.bar_sx]
1021
;--------------------------------------
1017
;--------------------------------------
1022
align 4
1018
align 4
1023
.end_x:
1019
.end_x:
1024
        mov     [drbar.real_sx], ebx
1020
        mov     [drbar.real_sx], ebx
1025
; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
1021
; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
1026
        mov     ebx, [edi-twdw + WDATA.box.height]; ebx = wnd_sy
1022
        mov     ebx, [edi-twdw + WDATA.box.height]; ebx = wnd_sy
1027
; \begin{diamond}[20.08.2006]
1023
; \begin{diamond}[20.08.2006]
1028
        inc     ebx
1024
        inc     ebx
1029
; \end{diamond}
1025
; \end{diamond}
1030
        sub     ebx, [drbar.bar_cy]
1026
        sub     ebx, [drbar.bar_cy]
1031
        ja      @f
1027
        ja      @f
1032
        add     esp, drbar.stack_data
1028
        add     esp, drbar.stack_data
1033
        popad
1029
        popad
1034
        xor     eax, eax
1030
        xor     eax, eax
1035
        inc     eax
1031
        inc     eax
1036
        ret
1032
        ret
1037
;--------------------------------------
1033
;--------------------------------------
1038
align 4
1034
align 4
1039
@@:
1035
@@:
1040
        cmp     ebx, [drbar.bar_sy]
1036
        cmp     ebx, [drbar.bar_sy]
1041
        jbe     .end_y
1037
        jbe     .end_y
1042
        mov     ebx, [drbar.bar_sy]
1038
        mov     ebx, [drbar.bar_sy]
1043
;--------------------------------------
1039
;--------------------------------------
1044
align 4
1040
align 4
1045
.end_y:
1041
.end_y:
1046
        mov     [drbar.real_sy], ebx
1042
        mov     [drbar.real_sy], ebx
1047
; line_inc_map
1043
; line_inc_map
1048
        mov     eax, [Screen_Max_X]
1044
        mov     eax, [Screen_Max_X]
1049
        sub     eax, [drbar.real_sx]
1045
        sub     eax, [drbar.real_sx]
1050
        inc     eax
1046
        inc     eax
1051
        mov     [drbar.line_inc_map], eax
1047
        mov     [drbar.line_inc_map], eax
1052
; line_inc_scr
1048
; line_inc_scr
1053
        mov     eax, [drbar.real_sx]
1049
        mov     eax, [drbar.real_sx]
1054
        movzx   ebx, byte [ScreenBPP]
1050
        movzx   ebx, byte [ScreenBPP]
1055
        shr     ebx, 3
1051
        shr     ebx, 3
1056
        imul    eax, ebx
1052
        imul    eax, ebx
1057
        neg     eax
1053
        neg     eax
1058
        add     eax, [BytesPerScanLine]
1054
        add     eax, [BytesPerScanLine]
1059
        mov     [drbar.line_inc_scr], eax
1055
        mov     [drbar.line_inc_scr], eax
1060
; pointer to screen
1056
; pointer to screen
1061
        mov     edx, [drbar.abs_cy]
1057
        mov     edx, [drbar.abs_cy]
1062
        imul    edx, [BytesPerScanLine]
1058
        imul    edx, [BytesPerScanLine]
1063
        mov     eax, [drbar.abs_cx]
1059
        mov     eax, [drbar.abs_cx]
1064
;     movzx   ebx, byte [ScreenBPP]
1060
;     movzx   ebx, byte [ScreenBPP]
1065
;     shr     ebx, 3
1061
;     shr     ebx, 3
1066
        imul    eax, ebx
1062
        imul    eax, ebx
1067
        add     edx, eax
1063
        add     edx, eax
1068
; pointer to pixel map
1064
; pointer to pixel map
1069
        mov     eax, [drbar.abs_cy]
1065
        mov     eax, [drbar.abs_cy]
1070
        imul    eax, [Screen_Max_X]
1066
        imul    eax, [Screen_Max_X]
1071
        add     eax, [drbar.abs_cy]
1067
        add     eax, [drbar.abs_cy]
1072
        add     eax, [drbar.abs_cx]
1068
        add     eax, [drbar.abs_cx]
1073
        add     eax, [_WinMapAddress]
1069
        add     eax, [_WinMapAddress]
1074
        xchg    eax, ebp
1070
        xchg    eax, ebp
1075
;--------------------------------------
1071
;--------------------------------------
1076
        mov     ebx, [drbar.real_sx]
1072
        mov     ebx, [drbar.real_sx]
1077
        add     ebx, [drbar.abs_cx]
1073
        add     ebx, [drbar.abs_cx]
1078
        mov     [drbar.real_sx_and_abs_cx], ebx
1074
        mov     [drbar.real_sx_and_abs_cx], ebx
1079
        mov     ebx, [drbar.real_sy]
1075
        mov     ebx, [drbar.real_sy]
1080
        add     ebx, [drbar.abs_cy]
1076
        add     ebx, [drbar.abs_cy]
1081
        mov     [drbar.real_sy_and_abs_cy], ebx
1077
        mov     [drbar.real_sy_and_abs_cy], ebx
1082
 
1078
 
1083
        add     edx, LFB_BASE
1079
        add     edx, LFB_BASE
1084
;--------------------------------------
1080
;--------------------------------------
1085
; get process number
1081
; get process number
1086
        mov     ebx, [CURRENT_TASK]
1082
        mov     ebx, [CURRENT_TASK]
1087
        cmp     byte [ScreenBPP], 24
1083
        cmp     byte [ScreenBPP], 24
1088
        jne     draw_bar_end_32
1084
        jne     draw_bar_end_32
1089
;--------------------------------------
1085
;--------------------------------------
1090
align 4
1086
align 4
1091
draw_bar_end_24:
1087
draw_bar_end_24:
1092
        mov     eax, [drbar.color] ;; BBGGRR00
1088
        mov     eax, [drbar.color] ;; BBGGRR00
1093
        mov     bh, al             ;; bh  = BB
1089
        mov     bh, al             ;; bh  = BB
1094
        shr     eax, 8             ;; eax = RRGG
1090
        shr     eax, 8             ;; eax = RRGG
1095
; eax - color high   RRGG
1091
; eax - color high   RRGG
1096
; bl - process num
1092
; bl - process num
1097
; bh - color low    BB
1093
; bh - color low    BB
1098
; ecx - temp
1094
; ecx - temp
1099
; edx - pointer to screen
1095
; edx - pointer to screen
1100
; esi - counter
1096
; esi - counter
1101
; edi - counter
1097
; edi - counter
1102
        mov     esi, [drbar.real_sy]
1098
        mov     esi, [drbar.real_sy]
1103
        cmp     [_display.select_cursor], 0
1099
        cmp     [_display.select_cursor], 0
1104
        jne     draw_bar_end_24_new
1100
        jne     draw_bar_end_24_new
1105
;--------------------------------------
1101
;--------------------------------------
1106
align 4
1102
align 4
1107
.new_y:
1103
.new_y:
1108
        mov     edi, [drbar.real_sx]
1104
        mov     edi, [drbar.real_sx]
1109
;--------------------------------------
1105
;--------------------------------------
1110
align 4
1106
align 4
1111
.new_x:
1107
.new_x:
1112
        cmp     byte [ebp], bl
1108
        cmp     byte [ebp], bl
1113
        jne     .skip
1109
        jne     .skip
1114
;--------------------------------------
1110
;--------------------------------------
1115
        push    eax
1111
        push    eax
1116
 
1112
 
1117
        mov     ecx, [drbar.real_sx_and_abs_cx + 4]
1113
        mov     ecx, [drbar.real_sx_and_abs_cx + 4]
1118
        sub     ecx, edi
1114
        sub     ecx, edi
1119
        shl     ecx, 16
1115
        shl     ecx, 16
1120
        add     ecx, [drbar.real_sy_and_abs_cy + 4]
1116
        add     ecx, [drbar.real_sy_and_abs_cy + 4]
1121
        sub     ecx, esi
1117
        sub     ecx, esi
1122
 
1118
 
1123
        shl     eax, 8
1119
        shl     eax, 8
1124
        mov     al, bh
1120
        mov     al, bh
1125
; check mouse area for putpixel
1121
; check mouse area for putpixel
1126
        call    check_mouse_area_for_putpixel
1122
        call    check_mouse_area_for_putpixel
1127
; store to real LFB
1123
; store to real LFB
1128
        mov     [edx], ax
1124
        mov     [edx], ax
1129
        shr     eax, 16
1125
        shr     eax, 16
1130
        mov     [edx + 2], al
1126
        mov     [edx + 2], al
1131
        pop     eax
1127
        pop     eax
1132
;--------------------------------------
1128
;--------------------------------------
1133
align 4
1129
align 4
1134
.skip:
1130
.skip:
1135
; add pixel
1131
; add pixel
1136
        add     edx, 3
1132
        add     edx, 3
1137
        inc     ebp
1133
        inc     ebp
1138
        dec     edi
1134
        dec     edi
1139
        jnz     .new_x
1135
        jnz     .new_x
1140
; add line
1136
; add line
1141
        add     edx, [drbar.line_inc_scr]
1137
        add     edx, [drbar.line_inc_scr]
1142
        add     ebp, [drbar.line_inc_map]
1138
        add     ebp, [drbar.line_inc_map]
1143
;  drawing gradient bars
1139
;  drawing gradient bars
1144
        test    eax, 0x00800000
1140
        test    eax, 0x00800000
1145
        jz      @f
1141
        jz      @f
1146
        test    bh, bh
1142
        test    bh, bh
1147
        jz      @f
1143
        jz      @f
1148
        dec     bh
1144
        dec     bh
1149
;--------------------------------------
1145
;--------------------------------------
1150
align 4
1146
align 4
1151
@@:
1147
@@:
1152
; 
1148
; 
1153
        dec     esi
1149
        dec     esi
1154
        jnz     .new_y
1150
        jnz     .new_y
1155
;--------------------------------------
1151
;--------------------------------------
1156
align 4
1152
align 4
1157
.end:
1153
.end:
1158
        add     esp, drbar.stack_data
1154
        add     esp, drbar.stack_data
1159
        popad
1155
        popad
1160
        xor     eax, eax
1156
        xor     eax, eax
1161
        ret
1157
        ret
1162
;--------------------------------------
1158
;--------------------------------------
1163
align 4
1159
align 4
1164
draw_bar_end_24_new:
1160
draw_bar_end_24_new:
1165
;--------------------------------------
1161
;--------------------------------------
1166
align 4
1162
align 4
1167
.new_y:
1163
.new_y:
1168
        mov     edi, [drbar.real_sx]
1164
        mov     edi, [drbar.real_sx]
1169
;--------------------------------------
1165
;--------------------------------------
1170
align 4
1166
align 4
1171
.new_x:
1167
.new_x:
1172
        cmp     byte [ebp], bl
1168
        cmp     byte [ebp], bl
1173
        jne     .skip
1169
        jne     .skip
1174
;--------------------------------------
1170
;--------------------------------------
1175
        mov     ecx, [drbar.real_sy_and_abs_cy]
1171
        mov     ecx, [drbar.real_sy_and_abs_cy]
1176
        sub     ecx, esi
1172
        sub     ecx, esi
1177
;--------------------------------------
1173
;--------------------------------------
1178
; check for Y
1174
; check for Y
1179
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
1175
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
1180
        jb      .no_mouse_area
1176
        jb      .no_mouse_area
1181
 
1177
 
1182
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1178
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1183
        jae     .no_mouse_area
1179
        jae     .no_mouse_area
1184
 
1180
 
1185
        rol     ecx, 16
1181
        rol     ecx, 16
1186
        add     ecx, [drbar.real_sx_and_abs_cx]
1182
        add     ecx, [drbar.real_sx_and_abs_cx]
1187
        sub     ecx, edi
1183
        sub     ecx, edi
1188
;--------------------------------------
1184
;--------------------------------------
1189
; check for X
1185
; check for X
1190
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
1186
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
1191
        jb      .no_mouse_area
1187
        jb      .no_mouse_area
1192
 
1188
 
1193
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1189
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1194
        jae     .no_mouse_area
1190
        jae     .no_mouse_area
1195
;--------------------------------------
1191
;--------------------------------------
1196
; check mouse area for putpixel
1192
; check mouse area for putpixel
1197
        push    eax
1193
        push    eax
1198
 
1194
 
1199
        shl     eax, 8
1195
        shl     eax, 8
1200
        mov     al, bh
1196
        mov     al, bh
1201
 
1197
 
1202
        call    check_mouse_area_for_putpixel_new.1
1198
        call    check_mouse_area_for_putpixel_new.1
1203
; store to real LFB
1199
; store to real LFB
1204
        mov     [edx], ax
1200
        mov     [edx], ax
1205
        shr     eax, 16
1201
        shr     eax, 16
1206
        mov     [edx + 2], al
1202
        mov     [edx + 2], al
1207
        pop     eax
1203
        pop     eax
1208
        jmp     .skip
1204
        jmp     .skip
1209
; store to real LFB
1205
; store to real LFB
1210
;--------------------------------------
1206
;--------------------------------------
1211
align 4
1207
align 4
1212
.no_mouse_area:
1208
.no_mouse_area:
1213
        mov     [edx], bh
1209
        mov     [edx], bh
1214
        mov     [edx + 1], ax
1210
        mov     [edx + 1], ax
1215
;--------------------------------------
1211
;--------------------------------------
1216
align 4
1212
align 4
1217
.skip:
1213
.skip:
1218
; add pixel
1214
; add pixel
1219
        add     edx, 3
1215
        add     edx, 3
1220
        inc     ebp
1216
        inc     ebp
1221
        dec     edi
1217
        dec     edi
1222
        jnz     .new_x
1218
        jnz     .new_x
1223
; add line
1219
; add line
1224
        add     edx, [drbar.line_inc_scr]
1220
        add     edx, [drbar.line_inc_scr]
1225
        add     ebp, [drbar.line_inc_map]
1221
        add     ebp, [drbar.line_inc_map]
1226
;  drawing gradient bars
1222
;  drawing gradient bars
1227
        test    eax, 0x00800000
1223
        test    eax, 0x00800000
1228
        jz      @f
1224
        jz      @f
1229
        test    bh, bh
1225
        test    bh, bh
1230
        jz      @f
1226
        jz      @f
1231
        dec     bh
1227
        dec     bh
1232
;--------------------------------------
1228
;--------------------------------------
1233
align 4
1229
align 4
1234
@@:
1230
@@:
1235
; 
1231
; 
1236
        dec     esi
1232
        dec     esi
1237
        jnz     .new_y
1233
        jnz     .new_y
1238
        jmp     draw_bar_end_24.end
1234
        jmp     draw_bar_end_24.end
1239
;--------------------------------------
1235
;--------------------------------------
1240
align 4
1236
align 4
1241
draw_bar_end_32:
1237
draw_bar_end_32:
1242
        mov     eax, [drbar.color] ;; BBGGRR00
1238
        mov     eax, [drbar.color] ;; BBGGRR00
1243
        mov     esi, [drbar.real_sy]
1239
        mov     esi, [drbar.real_sy]
1244
        cmp     [_display.select_cursor], 0
1240
        cmp     [_display.select_cursor], 0
1245
        jne     draw_bar_end_32_new
1241
        jne     draw_bar_end_32_new
1246
;--------------------------------------
1242
;--------------------------------------
1247
align 4
1243
align 4
1248
.new_y:
1244
.new_y:
1249
        mov     edi, [drbar.real_sx]
1245
        mov     edi, [drbar.real_sx]
1250
;--------------------------------------
1246
;--------------------------------------
1251
align 4
1247
align 4
1252
.new_x:
1248
.new_x:
1253
        cmp     byte [ebp], bl
1249
        cmp     byte [ebp], bl
1254
        jne     .skip
1250
        jne     .skip
1255
;--------------------------------------
1251
;--------------------------------------
1256
        push    eax
1252
        push    eax
1257
 
1253
 
1258
        mov     ecx, [drbar.real_sx_and_abs_cx + 4]
1254
        mov     ecx, [drbar.real_sx_and_abs_cx + 4]
1259
        sub     ecx, edi
1255
        sub     ecx, edi
1260
        shl     ecx, 16
1256
        shl     ecx, 16
1261
        add     ecx, [drbar.real_sy_and_abs_cy + 4]
1257
        add     ecx, [drbar.real_sy_and_abs_cy + 4]
1262
        sub     ecx, esi
1258
        sub     ecx, esi
1263
 
1259
 
1264
; check mouse area for putpixel
1260
; check mouse area for putpixel
1265
        call    check_mouse_area_for_putpixel
1261
        call    check_mouse_area_for_putpixel
1266
; store to real LFB
1262
; store to real LFB
1267
        mov     [edx], eax
1263
        mov     [edx], eax
1268
        pop     eax
1264
        pop     eax
1269
;--------------------------------------
1265
;--------------------------------------
1270
align 4
1266
align 4
1271
.skip:
1267
.skip:
1272
; add pixel
1268
; add pixel
1273
        add     edx, 4
1269
        add     edx, 4
1274
        inc     ebp
1270
        inc     ebp
1275
        dec     edi
1271
        dec     edi
1276
        jnz     .new_x
1272
        jnz     .new_x
1277
; add line
1273
; add line
1278
        add     edx, [drbar.line_inc_scr]
1274
        add     edx, [drbar.line_inc_scr]
1279
        add     ebp, [drbar.line_inc_map]
1275
        add     ebp, [drbar.line_inc_map]
1280
;  drawing gradient bars
1276
;  drawing gradient bars
1281
        test    eax, 0x80000000
1277
        test    eax, 0x80000000
1282
        jz      @f
1278
        jz      @f
1283
        test    al, al
1279
        test    al, al
1284
        jz      @f
1280
        jz      @f
1285
        dec     al
1281
        dec     al
1286
;--------------------------------------
1282
;--------------------------------------
1287
align 4
1283
align 4
1288
@@:
1284
@@:
1289
; 
1285
; 
1290
        dec     esi
1286
        dec     esi
1291
        jnz     .new_y
1287
        jnz     .new_y
1292
;--------------------------------------
1288
;--------------------------------------
1293
align 4
1289
align 4
1294
.end:
1290
.end:
1295
        add     esp, drbar.stack_data
1291
        add     esp, drbar.stack_data
1296
        popad
1292
        popad
1297
        cmp     [SCR_MODE], dword 0x12
1293
        cmp     [SCR_MODE], dword 0x12
1298
        jne     @f
1294
        jne     @f
1299
        call    VGA_draw_bar
1295
        call    VGA_draw_bar
1300
;--------------------------------------
1296
;--------------------------------------
1301
align 4
1297
align 4
1302
@@:
1298
@@:
1303
        xor     eax, eax
1299
        xor     eax, eax
1304
        mov     [EGA_counter], 1
1300
        mov     [EGA_counter], 1
1305
        ret
1301
        ret
1306
;--------------------------------------
1302
;--------------------------------------
1307
align 4
1303
align 4
1308
draw_bar_end_32_new:
1304
draw_bar_end_32_new:
1309
;--------------------------------------
1305
;--------------------------------------
1310
align 4
1306
align 4
1311
.new_y:
1307
.new_y:
1312
        mov     edi, [drbar.real_sx]
1308
        mov     edi, [drbar.real_sx]
1313
;--------------------------------------
1309
;--------------------------------------
1314
align 4
1310
align 4
1315
.new_x:
1311
.new_x:
1316
        cmp     byte [ebp], bl
1312
        cmp     byte [ebp], bl
1317
        jne     .skip
1313
        jne     .skip
1318
;--------------------------------------
1314
;--------------------------------------
1319
        mov     ecx, [drbar.real_sy_and_abs_cy]
1315
        mov     ecx, [drbar.real_sy_and_abs_cy]
1320
        sub     ecx, esi
1316
        sub     ecx, esi
1321
;--------------------------------------
1317
;--------------------------------------
1322
; check for Y
1318
; check for Y
1323
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
1319
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
1324
        jb      .no_mouse_area
1320
        jb      .no_mouse_area
1325
 
1321
 
1326
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1322
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1327
        jae     .no_mouse_area
1323
        jae     .no_mouse_area
1328
 
1324
 
1329
        rol     ecx, 16
1325
        rol     ecx, 16
1330
        add     ecx, [drbar.real_sx_and_abs_cx]
1326
        add     ecx, [drbar.real_sx_and_abs_cx]
1331
        sub     ecx, edi
1327
        sub     ecx, edi
1332
;--------------------------------------
1328
;--------------------------------------
1333
; check for X
1329
; check for X
1334
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
1330
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
1335
        jb      .no_mouse_area
1331
        jb      .no_mouse_area
1336
 
1332
 
1337
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1333
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1338
        jae     .no_mouse_area
1334
        jae     .no_mouse_area
1339
;--------------------------------------
1335
;--------------------------------------
1340
; check mouse area for putpixel
1336
; check mouse area for putpixel
1341
        push    eax
1337
        push    eax
1342
        call    check_mouse_area_for_putpixel_new.1
1338
        call    check_mouse_area_for_putpixel_new.1
1343
        mov     [edx], eax
1339
        mov     [edx], eax
1344
        pop     eax
1340
        pop     eax
1345
        jmp     .skip
1341
        jmp     .skip
1346
; store to real LFB
1342
; store to real LFB
1347
;--------------------------------------
1343
;--------------------------------------
1348
align 4
1344
align 4
1349
.no_mouse_area:
1345
.no_mouse_area:
1350
        mov     [edx], eax
1346
        mov     [edx], eax
1351
;--------------------------------------
1347
;--------------------------------------
1352
align 4
1348
align 4
1353
.skip:
1349
.skip:
1354
; add pixel
1350
; add pixel
1355
        add     edx, 4
1351
        add     edx, 4
1356
        inc     ebp
1352
        inc     ebp
1357
        dec     edi
1353
        dec     edi
1358
        jnz     .new_x
1354
        jnz     .new_x
1359
; add line
1355
; add line
1360
        add     edx, [drbar.line_inc_scr]
1356
        add     edx, [drbar.line_inc_scr]
1361
        add     ebp, [drbar.line_inc_map]
1357
        add     ebp, [drbar.line_inc_map]
1362
;  drawing gradient bars
1358
;  drawing gradient bars
1363
        test    eax, 0x80000000
1359
        test    eax, 0x80000000
1364
        jz      @f
1360
        jz      @f
1365
        test    al, al
1361
        test    al, al
1366
        jz      @f
1362
        jz      @f
1367
        dec     al
1363
        dec     al
1368
;--------------------------------------
1364
;--------------------------------------
1369
align 4
1365
align 4
1370
@@:
1366
@@:
1371
; 
1367
; 
1372
        dec     esi
1368
        dec     esi
1373
        jnz     .new_y
1369
        jnz     .new_y
1374
        jmp     draw_bar_end_32.end
1370
        jmp     draw_bar_end_32.end
1375
;------------------------------------------------------------------------------
1371
;------------------------------------------------------------------------------
1376
align 4
1372
align 4
1377
vesa20_drawbackground_tiled:
1373
vesa20_drawbackground_tiled:
1378
        pushad
1374
        pushad
1379
; External loop for all y from start to end
1375
; External loop for all y from start to end
1380
        mov     ebx, [draw_data+32+RECT.top]    ; y start
1376
        mov     ebx, [draw_data+32+RECT.top]    ; y start
1381
;--------------------------------------
1377
;--------------------------------------
1382
align 4
1378
align 4
1383
dp2:
1379
dp2:
1384
        mov     ebp, [draw_data+32+RECT.left]   ; x start
1380
        mov     ebp, [draw_data+32+RECT.left]   ; x start
1385
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
1381
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
1386
;                       and LFB data (output for our function) [edi]
1382
;                       and LFB data (output for our function) [edi]
1387
        mov     eax, [BytesPerScanLine]
1383
        mov     eax, [BytesPerScanLine]
1388
        mul     ebx
1384
        mul     ebx
1389
        xchg    ebp, eax
1385
        xchg    ebp, eax
1390
        add     ebp, eax
1386
        add     ebp, eax
1391
        add     ebp, eax
1387
        add     ebp, eax
1392
        add     ebp, eax
1388
        add     ebp, eax
1393
        cmp     [ScreenBPP], byte 24    ; 24 or 32 bpp ? - x size
1389
        cmp     [ScreenBPP], byte 24    ; 24 or 32 bpp ? - x size
1394
        jz      @f
1390
        jz      @f
1395
        add     ebp, eax
1391
        add     ebp, eax
1396
;--------------------------------------
1392
;--------------------------------------
1397
align 4
1393
align 4
1398
@@:
1394
@@:
1399
        add     ebp, LFB_BASE
1395
        add     ebp, LFB_BASE
1400
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1396
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1401
        call    calculate_edi
1397
        call    calculate_edi
1402
        xchg    edi, ebp
1398
        xchg    edi, ebp
1403
        add     ebp, [_WinMapAddress]
1399
        add     ebp, [_WinMapAddress]
1404
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
1400
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
1405
; 2) Calculate offset in background memory block
1401
; 2) Calculate offset in background memory block
1406
        push    eax
1402
        push    eax
1407
        xor     edx, edx
1403
        xor     edx, edx
1408
        mov     eax, ebx
1404
        mov     eax, ebx
1409
        div     dword [BgrDataHeight]   ; edx := y mod BgrDataHeight
1405
        div     dword [BgrDataHeight]   ; edx := y mod BgrDataHeight
1410
        pop     eax
1406
        pop     eax
1411
        push    eax
1407
        push    eax
1412
        mov     ecx, [BgrDataWidth]
1408
        mov     ecx, [BgrDataWidth]
1413
        mov     esi, edx
1409
        mov     esi, edx
1414
        imul    esi, ecx                ; esi := (y mod BgrDataHeight) * BgrDataWidth
1410
        imul    esi, ecx                ; esi := (y mod BgrDataHeight) * BgrDataWidth
1415
        xor     edx, edx
1411
        xor     edx, edx
1416
        div     ecx             ; edx := x mod BgrDataWidth
1412
        div     ecx             ; edx := x mod BgrDataWidth
1417
        sub     ecx, edx
1413
        sub     ecx, edx
1418
        add     esi, edx        ; esi := (y mod BgrDataHeight)*BgrDataWidth + (x mod BgrDataWidth)
1414
        add     esi, edx        ; esi := (y mod BgrDataHeight)*BgrDataWidth + (x mod BgrDataWidth)
1419
        pop     eax
1415
        pop     eax
1420
        lea     esi, [esi*3]
1416
        lea     esi, [esi*3]
1421
        add     esi, [img_background]
1417
        add     esi, [img_background]
1422
        xor     edx, edx
1418
        xor     edx, edx
1423
        inc     edx
1419
        inc     edx
1424
; 3) Loop through redraw rectangle and copy background data
1420
; 3) Loop through redraw rectangle and copy background data
1425
; Registers meaning:
1421
; Registers meaning:
1426
; eax = x, ebx = y (screen coordinates)
1422
; eax = x, ebx = y (screen coordinates)
1427
; ecx = deltax - number of pixels left in current tile block
1423
; ecx = deltax - number of pixels left in current tile block
1428
; edx = 1
1424
; edx = 1
1429
; esi -> bgr memory, edi -> output
1425
; esi -> bgr memory, edi -> output
1430
; ebp = offset in WinMapAddress
1426
; ebp = offset in WinMapAddress
1431
;--------------------------------------
1427
;--------------------------------------
1432
align 4
1428
align 4
1433
dp3:
1429
dp3:
1434
        cmp     [ebp], dl
1430
        cmp     [ebp], dl
1435
        jnz     nbgp
1431
        jnz     nbgp
1436
;--------------------------------------
1432
;--------------------------------------
1437
        push    eax ecx
1433
        push    eax ecx
1438
 
1434
 
1439
        mov     ecx, eax
1435
        mov     ecx, eax
1440
        shl     ecx, 16
1436
        shl     ecx, 16
1441
        add     ecx, ebx
1437
        add     ecx, ebx
1442
 
1438
 
1443
        mov     eax, [esi]
1439
        mov     eax, [esi]
1444
        and     eax, 0xffffff
1440
        and     eax, 0xffffff
1445
; check mouse area for putpixel
1441
; check mouse area for putpixel
1446
        call    [_display.check_mouse]
1442
        call    [_display.check_mouse]
1447
; store to real LFB
1443
; store to real LFB
1448
        mov     [edi], ax
1444
        mov     [edi], ax
1449
        shr     eax, 16
1445
        shr     eax, 16
1450
        mov     [edi+2], al
1446
        mov     [edi+2], al
1451
 
1447
 
1452
        pop     ecx eax
1448
        pop     ecx eax
1453
;--------------------------------------
1449
;--------------------------------------
1454
align 4
1450
align 4
1455
nbgp:
1451
nbgp:
1456
        add     esi, 3
1452
        add     esi, 3
1457
        add     edi, 3
1453
        add     edi, 3
1458
;--------------------------------------
1454
;--------------------------------------
1459
align 4
1455
align 4
1460
@@:
1456
@@:
1461
        cmp     [ScreenBPP], byte 25    ; 24 or 32 bpp?
1457
        cmp     [ScreenBPP], byte 25    ; 24 or 32 bpp?
1462
        sbb     edi, -1         ; +1 for 32 bpp
1458
        sbb     edi, -1         ; +1 for 32 bpp
1463
; I do not use 'inc eax' because this is slightly slower then 'add eax,1'
1459
; I do not use 'inc eax' because this is slightly slower then 'add eax,1'
1464
        add     ebp, edx
1460
        add     ebp, edx
1465
        add     eax, edx
1461
        add     eax, edx
1466
        cmp     eax, [draw_data+32+RECT.right]
1462
        cmp     eax, [draw_data+32+RECT.right]
1467
        ja      dp4
1463
        ja      dp4
1468
        sub     ecx, edx
1464
        sub     ecx, edx
1469
        jnz     dp3
1465
        jnz     dp3
1470
; next tile block on x-axis
1466
; next tile block on x-axis
1471
        mov     ecx, [BgrDataWidth]
1467
        mov     ecx, [BgrDataWidth]
1472
        sub     esi, ecx
1468
        sub     esi, ecx
1473
        sub     esi, ecx
1469
        sub     esi, ecx
1474
        sub     esi, ecx
1470
        sub     esi, ecx
1475
        jmp     dp3
1471
        jmp     dp3
1476
;--------------------------------------
1472
;--------------------------------------
1477
align 4
1473
align 4
1478
dp4:
1474
dp4:
1479
; next scan line
1475
; next scan line
1480
        inc     ebx
1476
        inc     ebx
1481
        cmp     ebx, [draw_data+32+RECT.bottom]
1477
        cmp     ebx, [draw_data+32+RECT.bottom]
1482
        jbe     dp2
1478
        jbe     dp2
1483
        popad
1479
        popad
1484
        mov     [EGA_counter], 1
1480
        mov     [EGA_counter], 1
1485
        cmp     [SCR_MODE], dword 0x12
1481
        cmp     [SCR_MODE], dword 0x12
1486
        jne     @f
1482
        jne     @f
1487
        call    VGA_drawbackground
1483
        call    VGA_drawbackground
1488
;--------------------------------------
1484
;--------------------------------------
1489
align 4
1485
align 4
1490
@@:
1486
@@:
1491
        ret
1487
        ret
1492
;------------------------------------------------------------------------------
1488
;------------------------------------------------------------------------------
1493
align 4
1489
align 4
1494
vesa20_drawbackground_stretch:
1490
vesa20_drawbackground_stretch:
1495
        pushad
1491
        pushad
1496
; Helper variables
1492
; Helper variables
1497
; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1)
1493
; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1)
1498
        mov     eax, [BgrDataWidth]
1494
        mov     eax, [BgrDataWidth]
1499
        dec     eax
1495
        dec     eax
1500
        xor     edx, edx
1496
        xor     edx, edx
1501
        div     dword [Screen_Max_X]
1497
        div     dword [Screen_Max_X]
1502
        push    eax     ; high
1498
        push    eax     ; high
1503
        xor     eax, eax
1499
        xor     eax, eax
1504
        div     dword [Screen_Max_X]
1500
        div     dword [Screen_Max_X]
1505
        push    eax     ; low
1501
        push    eax     ; low
1506
; the same for height
1502
; the same for height
1507
        mov     eax, [BgrDataHeight]
1503
        mov     eax, [BgrDataHeight]
1508
        dec     eax
1504
        dec     eax
1509
        xor     edx, edx
1505
        xor     edx, edx
1510
        div     dword [Screen_Max_Y]
1506
        div     dword [Screen_Max_Y]
1511
        push    eax     ; high
1507
        push    eax     ; high
1512
        xor     eax, eax
1508
        xor     eax, eax
1513
        div     dword [Screen_Max_Y]
1509
        div     dword [Screen_Max_Y]
1514
        push    eax     ; low
1510
        push    eax     ; low
1515
; External loop for all y from start to end
1511
; External loop for all y from start to end
1516
        mov     ebx, [draw_data+32+RECT.top]    ; y start
1512
        mov     ebx, [draw_data+32+RECT.top]    ; y start
1517
        mov     ebp, [draw_data+32+RECT.left]   ; x start
1513
        mov     ebp, [draw_data+32+RECT.left]   ; x start
1518
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
1514
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
1519
;                       and LFB data (output for our function) [edi]
1515
;                       and LFB data (output for our function) [edi]
1520
        mov     eax, [BytesPerScanLine]
1516
        mov     eax, [BytesPerScanLine]
1521
        mul     ebx
1517
        mul     ebx
1522
        xchg    ebp, eax
1518
        xchg    ebp, eax
1523
        add     ebp, eax
1519
        add     ebp, eax
1524
        add     ebp, eax
1520
        add     ebp, eax
1525
        add     ebp, eax
1521
        add     ebp, eax
1526
        cmp     [ScreenBPP], byte 24    ; 24 or 32 bpp ? - x size
1522
        cmp     [ScreenBPP], byte 24    ; 24 or 32 bpp ? - x size
1527
        jz      @f
1523
        jz      @f
1528
        add     ebp, eax
1524
        add     ebp, eax
1529
;--------------------------------------
1525
;--------------------------------------
1530
align 4
1526
align 4
1531
@@:
1527
@@:
1532
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1528
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1533
        call    calculate_edi
1529
        call    calculate_edi
1534
        xchg    edi, ebp
1530
        xchg    edi, ebp
1535
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
1531
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
1536
        push    ebx
1532
        push    ebx
1537
        push    eax
1533
        push    eax
1538
; 2) Calculate offset in background memory block
1534
; 2) Calculate offset in background memory block
1539
        mov     eax, ebx
1535
        mov     eax, ebx
1540
        imul    ebx, dword [esp+12]
1536
        imul    ebx, dword [esp+12]
1541
        mul     dword [esp+8]
1537
        mul     dword [esp+8]
1542
        add     edx, ebx        ; edx:eax = y * 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
1538
        add     edx, ebx        ; edx:eax = y * 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
1543
        mov     esi, edx
1539
        mov     esi, edx
1544
        imul    esi, [BgrDataWidth]
1540
        imul    esi, [BgrDataWidth]
1545
        push    edx
1541
        push    edx
1546
        push    eax
1542
        push    eax
1547
        mov     eax, [esp+8]
1543
        mov     eax, [esp+8]
1548
        mul     dword [esp+28]
1544
        mul     dword [esp+28]
1549
        push    eax
1545
        push    eax
1550
        mov     eax, [esp+12]
1546
        mov     eax, [esp+12]
1551
        mul     dword [esp+28]
1547
        mul     dword [esp+28]
1552
        add     [esp], edx
1548
        add     [esp], edx
1553
        pop     edx             ; edx:eax = x * 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
1549
        pop     edx             ; edx:eax = x * 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
1554
        add     esi, edx
1550
        add     esi, edx
1555
        lea     esi, [esi*3]
1551
        lea     esi, [esi*3]
1556
        add     esi, [img_background]
1552
        add     esi, [img_background]
1557
        push    eax
1553
        push    eax
1558
        push    edx
1554
        push    edx
1559
        push    esi
1555
        push    esi
1560
; 3) Smooth horizontal
1556
; 3) Smooth horizontal
1561
;--------------------------------------
1557
;--------------------------------------
1562
align 4
1558
align 4
1563
bgr_resmooth0:
1559
bgr_resmooth0:
1564
        mov     ecx, [esp+8]
1560
        mov     ecx, [esp+8]
1565
        mov     edx, [esp+4]
1561
        mov     edx, [esp+4]
1566
        mov     esi, [esp]
1562
        mov     esi, [esp]
1567
        push    edi
1563
        push    edi
1568
        mov     edi, bgr_cur_line
1564
        mov     edi, bgr_cur_line
1569
        call    smooth_line
1565
        call    smooth_line
1570
;--------------------------------------
1566
;--------------------------------------
1571
align 4
1567
align 4
1572
bgr_resmooth1:
1568
bgr_resmooth1:
1573
        mov     eax, [esp+16+4]
1569
        mov     eax, [esp+16+4]
1574
        inc     eax
1570
        inc     eax
1575
        cmp     eax, [BgrDataHeight]
1571
        cmp     eax, [BgrDataHeight]
1576
        jae     bgr.no2nd
1572
        jae     bgr.no2nd
1577
        mov     ecx, [esp+8+4]
1573
        mov     ecx, [esp+8+4]
1578
        mov     edx, [esp+4+4]
1574
        mov     edx, [esp+4+4]
1579
        mov     esi, [esp+4]
1575
        mov     esi, [esp+4]
1580
        add     esi, [BgrDataWidth]
1576
        add     esi, [BgrDataWidth]
1581
        add     esi, [BgrDataWidth]
1577
        add     esi, [BgrDataWidth]
1582
        add     esi, [BgrDataWidth]
1578
        add     esi, [BgrDataWidth]
1583
        mov     edi, bgr_next_line
1579
        mov     edi, bgr_next_line
1584
        call    smooth_line
1580
        call    smooth_line
1585
;--------------------------------------
1581
;--------------------------------------
1586
align 4
1582
align 4
1587
bgr.no2nd:
1583
bgr.no2nd:
1588
        pop     edi
1584
        pop     edi
1589
;--------------------------------------
1585
;--------------------------------------
1590
align 4
1586
align 4
1591
sdp3:
1587
sdp3:
1592
        xor     esi, esi
1588
        xor     esi, esi
1593
        mov     ecx, [esp+12]
1589
        mov     ecx, [esp+12]
1594
; 4) Loop through redraw rectangle and copy background data
1590
; 4) Loop through redraw rectangle and copy background data
1595
; Registers meaning:
1591
; Registers meaning:
1596
; esi = offset in current line, edi -> output
1592
; esi = offset in current line, edi -> output
1597
; ebp = offset in WinMapAddress
1593
; ebp = offset in WinMapAddress
1598
; dword [esp] = offset in bgr data
1594
; dword [esp] = offset in bgr data
1599
; qword [esp+4] = x * 2^32 * (BgrDataWidth-1) / (ScreenWidth-1)
1595
; qword [esp+4] = x * 2^32 * (BgrDataWidth-1) / (ScreenWidth-1)
1600
; qword [esp+12] = y * 2^32 * (BgrDataHeight-1) / (ScreenHeight-1)
1596
; qword [esp+12] = y * 2^32 * (BgrDataHeight-1) / (ScreenHeight-1)
1601
; dword [esp+20] = x
1597
; dword [esp+20] = x
1602
; dword [esp+24] = y
1598
; dword [esp+24] = y
1603
; precalculated constants:
1599
; precalculated constants:
1604
; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
1600
; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
1605
; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
1601
; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
1606
;--------------------------------------
1602
;--------------------------------------
1607
align 4
1603
align 4
1608
sdp3a:
1604
sdp3a:
1609
        mov     eax, [_WinMapAddress]
1605
        mov     eax, [_WinMapAddress]
1610
        cmp     [ebp+eax], byte 1
1606
        cmp     [ebp+eax], byte 1
1611
        jnz     snbgp
1607
        jnz     snbgp
1612
        mov     eax, [bgr_cur_line+esi]
1608
        mov     eax, [bgr_cur_line+esi]
1613
        test    ecx, ecx
1609
        test    ecx, ecx
1614
        jz      .novert
1610
        jz      .novert
1615
        mov     ebx, [bgr_next_line+esi]
1611
        mov     ebx, [bgr_next_line+esi]
1616
        call    [overlapping_of_points_ptr]
1612
        call    [overlapping_of_points_ptr]
1617
;--------------------------------------
1613
;--------------------------------------
1618
align 4
1614
align 4
1619
.novert:
1615
.novert:
1620
        push    ecx
1616
        push    ecx
1621
        mov     ecx, [esp+20+4]        ;x
1617
        mov     ecx, [esp+20+4]        ;x
1622
        shl     ecx, 16
1618
        shl     ecx, 16
1623
        add     ecx, [esp+24+4]        ;y
1619
        add     ecx, [esp+24+4]        ;y
1624
; check mouse area for putpixel
1620
; check mouse area for putpixel
1625
        call    [_display.check_mouse]
1621
        call    [_display.check_mouse]
1626
; store to real LFB
1622
; store to real LFB
1627
        mov     [LFB_BASE+edi], ax
1623
        mov     [LFB_BASE+edi], ax
1628
        shr     eax, 16
1624
        shr     eax, 16
1629
        mov     [LFB_BASE+edi+2], al
1625
        mov     [LFB_BASE+edi+2], al
1630
        pop     ecx
1626
        pop     ecx
1631
;--------------------------------------
1627
;--------------------------------------
1632
align 4
1628
align 4
1633
snbgp:
1629
snbgp:
1634
        cmp     [ScreenBPP], byte 25
1630
        cmp     [ScreenBPP], byte 25
1635
        sbb     edi, -4
1631
        sbb     edi, -4
1636
        add     ebp, 1
1632
        add     ebp, 1
1637
        mov     eax, [esp+20]
1633
        mov     eax, [esp+20]
1638
        add     eax, 1
1634
        add     eax, 1
1639
        mov     [esp+20], eax
1635
        mov     [esp+20], eax
1640
        add     esi, 4
1636
        add     esi, 4
1641
        cmp     eax, [draw_data+32+RECT.right]
1637
        cmp     eax, [draw_data+32+RECT.right]
1642
        jbe     sdp3a
1638
        jbe     sdp3a
1643
;--------------------------------------
1639
;--------------------------------------
1644
align 4
1640
align 4
1645
sdp4:
1641
sdp4:
1646
; next y
1642
; next y
1647
        mov     ebx, [esp+24]
1643
        mov     ebx, [esp+24]
1648
        add     ebx, 1
1644
        add     ebx, 1
1649
        mov     [esp+24], ebx
1645
        mov     [esp+24], ebx
1650
        cmp     ebx, [draw_data+32+RECT.bottom]
1646
        cmp     ebx, [draw_data+32+RECT.bottom]
1651
        ja      sdpdone
1647
        ja      sdpdone
1652
; advance edi, ebp to next scan line
1648
; advance edi, ebp to next scan line
1653
        sub     eax, [draw_data+32+RECT.left]
1649
        sub     eax, [draw_data+32+RECT.left]
1654
        sub     ebp, eax
1650
        sub     ebp, eax
1655
        add     ebp, [Screen_Max_X]
1651
        add     ebp, [Screen_Max_X]
1656
        add     ebp, 1
1652
        add     ebp, 1
1657
        sub     edi, eax
1653
        sub     edi, eax
1658
        sub     edi, eax
1654
        sub     edi, eax
1659
        sub     edi, eax
1655
        sub     edi, eax
1660
        cmp     [ScreenBPP], byte 24
1656
        cmp     [ScreenBPP], byte 24
1661
        jz      @f
1657
        jz      @f
1662
        sub     edi, eax
1658
        sub     edi, eax
1663
;--------------------------------------
1659
;--------------------------------------
1664
align 4
1660
align 4
1665
@@:
1661
@@:
1666
        add     edi, [BytesPerScanLine]
1662
        add     edi, [BytesPerScanLine]
1667
; restore ecx,edx; advance esi to next background line
1663
; restore ecx,edx; advance esi to next background line
1668
        mov     eax, [esp+28]
1664
        mov     eax, [esp+28]
1669
        mov     ebx, [esp+32]
1665
        mov     ebx, [esp+32]
1670
        add     [esp+12], eax
1666
        add     [esp+12], eax
1671
        mov     eax, [esp+16]
1667
        mov     eax, [esp+16]
1672
        adc     [esp+16], ebx
1668
        adc     [esp+16], ebx
1673
        sub     eax, [esp+16]
1669
        sub     eax, [esp+16]
1674
        mov     ebx, eax
1670
        mov     ebx, eax
1675
        lea     eax, [eax*3]
1671
        lea     eax, [eax*3]
1676
        imul    eax, [BgrDataWidth]
1672
        imul    eax, [BgrDataWidth]
1677
        sub     [esp], eax
1673
        sub     [esp], eax
1678
        mov     eax, [draw_data+32+RECT.left]
1674
        mov     eax, [draw_data+32+RECT.left]
1679
        mov     [esp+20], eax
1675
        mov     [esp+20], eax
1680
        test    ebx, ebx
1676
        test    ebx, ebx
1681
        jz      sdp3
1677
        jz      sdp3
1682
        cmp     ebx, -1
1678
        cmp     ebx, -1
1683
        jnz     bgr_resmooth0
1679
        jnz     bgr_resmooth0
1684
        push    edi
1680
        push    edi
1685
        mov     esi, bgr_next_line
1681
        mov     esi, bgr_next_line
1686
        mov     edi, bgr_cur_line
1682
        mov     edi, bgr_cur_line
1687
        mov     ecx, [Screen_Max_X]
1683
        mov     ecx, [Screen_Max_X]
1688
        inc     ecx
1684
        inc     ecx
1689
        rep movsd
1685
        rep movsd
1690
        jmp     bgr_resmooth1
1686
        jmp     bgr_resmooth1
1691
;--------------------------------------
1687
;--------------------------------------
1692
align 4
1688
align 4
1693
sdpdone:
1689
sdpdone:
1694
        add     esp, 44
1690
        add     esp, 44
1695
        popad
1691
        popad
1696
        mov     [EGA_counter], 1
1692
        mov     [EGA_counter], 1
1697
        cmp     [SCR_MODE], dword 0x12
1693
        cmp     [SCR_MODE], dword 0x12
1698
        jne     @f
1694
        jne     @f
1699
        call    VGA_drawbackground
1695
        call    VGA_drawbackground
1700
;--------------------------------------
1696
;--------------------------------------
1701
align 4
1697
align 4
1702
@@:
1698
@@:
1703
        ret
1699
        ret
1704
 
1700
 
1705
uglobal
1701
uglobal
1706
;--------------------------------------
1702
;--------------------------------------
1707
align 4
1703
align 4
1708
bgr_cur_line    rd      1920    ; maximum width of screen
1704
bgr_cur_line    rd      1920    ; maximum width of screen
1709
bgr_next_line   rd      1920
1705
bgr_next_line   rd      1920
1710
;--------------------------------------
1706
;--------------------------------------
1711
endg
1707
endg
1712
;--------------------------------------
1708
;--------------------------------------
1713
align 4
1709
align 4
1714
smooth_line:
1710
smooth_line:
1715
        mov     al, [esi+2]
1711
        mov     al, [esi+2]
1716
        shl     eax, 16
1712
        shl     eax, 16
1717
        mov     ax, [esi]
1713
        mov     ax, [esi]
1718
        test    ecx, ecx
1714
        test    ecx, ecx
1719
        jz      @f
1715
        jz      @f
1720
        mov     ebx, [esi+2]
1716
        mov     ebx, [esi+2]
1721
        shr     ebx, 8
1717
        shr     ebx, 8
1722
        call    [overlapping_of_points_ptr]
1718
        call    [overlapping_of_points_ptr]
1723
;--------------------------------------
1719
;--------------------------------------
1724
align 4
1720
align 4
1725
@@:
1721
@@:
1726
        stosd
1722
        stosd
1727
        mov     eax, [esp+20+8]
1723
        mov     eax, [esp+20+8]
1728
        add     eax, 1
1724
        add     eax, 1
1729
        mov     [esp+20+8], eax
1725
        mov     [esp+20+8], eax
1730
        cmp     eax, [draw_data+32+RECT.right]
1726
        cmp     eax, [draw_data+32+RECT.right]
1731
        ja      @f
1727
        ja      @f
1732
        add     ecx, [esp+36+8]
1728
        add     ecx, [esp+36+8]
1733
        mov     eax, edx
1729
        mov     eax, edx
1734
        adc     edx, [esp+40+8]
1730
        adc     edx, [esp+40+8]
1735
        sub     eax, edx
1731
        sub     eax, edx
1736
        lea     eax, [eax*3]
1732
        lea     eax, [eax*3]
1737
        sub     esi, eax
1733
        sub     esi, eax
1738
        jmp     smooth_line
1734
        jmp     smooth_line
1739
;--------------------------------------
1735
;--------------------------------------
1740
align 4
1736
align 4
1741
@@:
1737
@@:
1742
        mov     eax, [draw_data+32+RECT.left]
1738
        mov     eax, [draw_data+32+RECT.left]
1743
        mov     [esp+20+8], eax
1739
        mov     [esp+20+8], eax
1744
        ret
1740
        ret
1745
;------------------------------------------------------------------------------
1741
;------------------------------------------------------------------------------
1746
align 16
1742
align 16
1747
overlapping_of_points:
1743
overlapping_of_points:
1748
if 0
1744
if 0
1749
; this version of procedure works, but is slower than next version
1745
; this version of procedure works, but is slower than next version
1750
        push    ecx edx
1746
        push    ecx edx
1751
        mov     edx, eax
1747
        mov     edx, eax
1752
        push    esi
1748
        push    esi
1753
        shr     ecx, 24
1749
        shr     ecx, 24
1754
        mov     esi, ecx
1750
        mov     esi, ecx
1755
        mov     ecx, ebx
1751
        mov     ecx, ebx
1756
        movzx   ebx, dl
1752
        movzx   ebx, dl
1757
        movzx   eax, cl
1753
        movzx   eax, cl
1758
        sub     eax, ebx
1754
        sub     eax, ebx
1759
        movzx   ebx, dh
1755
        movzx   ebx, dh
1760
        imul    eax, esi
1756
        imul    eax, esi
1761
        add     dl, ah
1757
        add     dl, ah
1762
        movzx   eax, ch
1758
        movzx   eax, ch
1763
        sub     eax, ebx
1759
        sub     eax, ebx
1764
        imul    eax, esi
1760
        imul    eax, esi
1765
        add     dh, ah
1761
        add     dh, ah
1766
        ror     ecx, 16
1762
        ror     ecx, 16
1767
        ror     edx, 16
1763
        ror     edx, 16
1768
        movzx   eax, cl
1764
        movzx   eax, cl
1769
        movzx   ebx, dl
1765
        movzx   ebx, dl
1770
        sub     eax, ebx
1766
        sub     eax, ebx
1771
        imul    eax, esi
1767
        imul    eax, esi
1772
        pop     esi
1768
        pop     esi
1773
        add     dl, ah
1769
        add     dl, ah
1774
        mov     eax, edx
1770
        mov     eax, edx
1775
        pop     edx
1771
        pop     edx
1776
        ror     eax, 16
1772
        ror     eax, 16
1777
        pop     ecx
1773
        pop     ecx
1778
        ret
1774
        ret
1779
else
1775
else
1780
        push    ecx edx
1776
        push    ecx edx
1781
        mov     edx, eax
1777
        mov     edx, eax
1782
        push    esi
1778
        push    esi
1783
        shr     ecx, 26
1779
        shr     ecx, 26
1784
        mov     esi, ecx
1780
        mov     esi, ecx
1785
        mov     ecx, ebx
1781
        mov     ecx, ebx
1786
        shl     esi, 9
1782
        shl     esi, 9
1787
        movzx   ebx, dl
1783
        movzx   ebx, dl
1788
        movzx   eax, cl
1784
        movzx   eax, cl
1789
        sub     eax, ebx
1785
        sub     eax, ebx
1790
        movzx   ebx, dh
1786
        movzx   ebx, dh
1791
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
1787
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
1792
        movzx   eax, ch
1788
        movzx   eax, ch
1793
        sub     eax, ebx
1789
        sub     eax, ebx
1794
        add     dh, [BgrAuxTable+(eax+0x100)+esi]
1790
        add     dh, [BgrAuxTable+(eax+0x100)+esi]
1795
        ror     ecx, 16
1791
        ror     ecx, 16
1796
        ror     edx, 16
1792
        ror     edx, 16
1797
        movzx   eax, cl
1793
        movzx   eax, cl
1798
        movzx   ebx, dl
1794
        movzx   ebx, dl
1799
        sub     eax, ebx
1795
        sub     eax, ebx
1800
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
1796
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
1801
        pop     esi
1797
        pop     esi
1802
        mov     eax, edx
1798
        mov     eax, edx
1803
        pop     edx
1799
        pop     edx
1804
        ror     eax, 16
1800
        ror     eax, 16
1805
        pop     ecx
1801
        pop     ecx
1806
        ret
1802
        ret
1807
end if
1803
end if
1808
 
1804
 
1809
iglobal
1805
iglobal
1810
;--------------------------------------
1806
;--------------------------------------
1811
align 4
1807
align 4
1812
overlapping_of_points_ptr       dd      overlapping_of_points
1808
overlapping_of_points_ptr       dd      overlapping_of_points
1813
;--------------------------------------
1809
;--------------------------------------
1814
endg
1810
endg
1815
;------------------------------------------------------------------------------
1811
;------------------------------------------------------------------------------
1816
align 4
1812
align 4
1817
init_background:
1813
init_background:
1818
        mov     edi, BgrAuxTable
1814
        mov     edi, BgrAuxTable
1819
        xor     edx, edx
1815
        xor     edx, edx
1820
;--------------------------------------
1816
;--------------------------------------
1821
align 4
1817
align 4
1822
.loop2:
1818
.loop2:
1823
        mov     eax, edx
1819
        mov     eax, edx
1824
        shl     eax, 8
1820
        shl     eax, 8
1825
        neg     eax
1821
        neg     eax
1826
        mov     ecx, 0x200
1822
        mov     ecx, 0x200
1827
;--------------------------------------
1823
;--------------------------------------
1828
align 4
1824
align 4
1829
.loop1:
1825
.loop1:
1830
        mov     byte [edi], ah
1826
        mov     byte [edi], ah
1831
        inc     edi
1827
        inc     edi
1832
        add     eax, edx
1828
        add     eax, edx
1833
        loop    .loop1
1829
        loop    .loop1
1834
        add     dl, 4
1830
        add     dl, 4
1835
        jnz     .loop2
1831
        jnz     .loop2
1836
        test    byte [cpu_caps+(CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8)
1832
        test    byte [cpu_caps+(CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8)
1837
        jz      @f
1833
        jz      @f
1838
        mov     [overlapping_of_points_ptr], overlapping_of_points_mmx
1834
        mov     [overlapping_of_points_ptr], overlapping_of_points_mmx
1839
;--------------------------------------
1835
;--------------------------------------
1840
align 4
1836
align 4
1841
@@:
1837
@@:
1842
        ret
1838
        ret
1843
;------------------------------------------------------------------------------
1839
;------------------------------------------------------------------------------
1844
align 16
1840
align 16
1845
overlapping_of_points_mmx:
1841
overlapping_of_points_mmx:
1846
        movd    mm0, eax
1842
        movd    mm0, eax
1847
        movd    mm4, eax
1843
        movd    mm4, eax
1848
        movd    mm1, ebx
1844
        movd    mm1, ebx
1849
        pxor    mm2, mm2
1845
        pxor    mm2, mm2
1850
        punpcklbw mm0, mm2
1846
        punpcklbw mm0, mm2
1851
        punpcklbw mm1, mm2
1847
        punpcklbw mm1, mm2
1852
        psubw   mm1, mm0
1848
        psubw   mm1, mm0
1853
        movd    mm3, ecx
1849
        movd    mm3, ecx
1854
        psrld   mm3, 24
1850
        psrld   mm3, 24
1855
        packuswb mm3, mm3
1851
        packuswb mm3, mm3
1856
        packuswb mm3, mm3
1852
        packuswb mm3, mm3
1857
        pmullw  mm1, mm3
1853
        pmullw  mm1, mm3
1858
        psrlw   mm1, 8
1854
        psrlw   mm1, 8
1859
        packuswb mm1, mm2
1855
        packuswb mm1, mm2
1860
        paddb   mm4, mm1
1856
        paddb   mm4, mm1
1861
        movd    eax, mm4
1857
        movd    eax, mm4
1862
        ret
1858
        ret
1863
;------------------------------------------------------------------------------
1859
;------------------------------------------------------------------------------