Subversion Repositories Kolibri OS

Rev

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

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