Subversion Repositories Kolibri OS

Rev

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

Rev 928 Rev 996
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2007. 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: 928 $
20
$Revision: 996 $
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
 
26
 
27
;*************************************************
27
;*************************************************
28
; getpixel
28
; getpixel
29
;
29
;
30
; in:
30
; in:
31
; eax = x coordinate
31
; eax = x coordinate
32
; ebx = y coordinate
32
; ebx = y coordinate
33
;
33
;
34
; ret:
34
; ret:
35
; ecx = 00 RR GG BB
35
; ecx = 00 RR GG BB
36
 
36
 
37
getpixel:
37
getpixel:
38
     push    eax ebx edx edi
38
     push    eax ebx edx edi
39
     call    [get_pixel]
39
     call    [get_pixel]
40
     pop     edi edx ebx eax
40
     pop     edi edx ebx eax
41
     ret
41
     ret
42
 
42
 
43
Vesa20_getpixel24:
43
Vesa20_getpixel24:
44
; eax = x
44
; eax = x
45
; ebx = y
45
; ebx = y
46
     imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
46
     imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
47
     lea     edi, [eax+eax*2] ; edi = x*3
47
     lea     edi, [eax+eax*2] ; edi = x*3
48
     add     edi, ebx         ; edi = x*3+(y*y multiplier)
48
     add     edi, ebx         ; edi = x*3+(y*y multiplier)
49
if SHADOWFB
49
if SHADOWFB
50
     mov     ecx, [SHADOWFB+edi]
50
     mov     ecx, [SHADOWFB+edi]
51
else
51
else
52
     mov     ecx, [LFB_BASE+edi]
52
     mov     ecx, [LFB_BASE+edi]
53
end if
53
end if
54
     and     ecx, 0xffffff
54
     and     ecx, 0xffffff
55
     ret
55
     ret
56
 
56
 
57
Vesa20_getpixel32:
57
Vesa20_getpixel32:
58
     imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
58
     imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
59
     lea     edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
59
     lea     edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
60
if SHADOWFB
60
if SHADOWFB
61
     mov     ecx, [SHADOWFB+edi]
61
     mov     ecx, [SHADOWFB+edi]
62
else
62
else
63
     mov     ecx, [LFB_BASE+edi]
63
     mov     ecx, [LFB_BASE+edi]
64
end if
64
end if
65
     and     ecx, 0xffffff
65
     and     ecx, 0xffffff
66
     ret
66
     ret
67
 
67
 
68
;*************************************************
68
;*************************************************
69
 
69
 
70
virtual at esp
70
virtual at esp
71
 putimg:
71
 putimg:
72
   .real_sx        dd ?
72
   .real_sx        dd ?
73
   .real_sy        dd ?
73
   .real_sy        dd ?
74
   .image_sx       dd ?
74
   .image_sx       dd ?
75
   .image_sy       dd ?
75
   .image_sy       dd ?
76
   .image_cx       dd ?
76
   .image_cx       dd ?
77
   .image_cy       dd ?
77
   .image_cy       dd ?
78
   .pti            dd ?
78
   .pti            dd ?
79
   .abs_cx         dd ?
79
   .abs_cx         dd ?
80
   .abs_cy         dd ?
80
   .abs_cy         dd ?
81
   .line_increment dd ?
81
   .line_increment dd ?
82
   .winmap_newline dd ?
82
   .winmap_newline dd ?
83
   .screen_newline dd ?
83
   .screen_newline dd ?
84
   .stack_data = 4*12
84
   .stack_data = 4*12
85
   .edi         dd      ?
85
   .edi         dd      ?
86
   .esi         dd      ?
86
   .esi         dd      ?
87
   .ebp         dd      ?
87
   .ebp         dd      ?
88
   .esp         dd      ?
88
   .esp         dd      ?
89
   .ebx         dd      ?
89
   .ebx         dd      ?
90
   .edx         dd      ?
90
   .edx         dd      ?
91
   .ecx         dd      ?
91
   .ecx         dd      ?
92
   .eax         dd      ?
92
   .eax         dd      ?
93
   .ret_addr    dd      ?
93
   .ret_addr    dd      ?
94
   .arg_0       dd      ?
94
   .arg_0       dd      ?
95
end virtual
95
end virtual
96
 
96
 
97
align 16
97
align 16
98
; ebx = pointer
98
; ebx = pointer
99
; ecx = size [x|y]
99
; ecx = size [x|y]
100
; edx = coordinates [x|y]
100
; edx = coordinates [x|y]
101
; ebp = pointer to 'get' function
101
; ebp = pointer to 'get' function
102
; esi = pointer to 'init' function
102
; esi = pointer to 'init' function
103
; edi = parameter for 'get' function
103
; edi = parameter for 'get' function
104
 
104
 
105
vesa20_putimage:
105
vesa20_putimage:
106
     pushad
106
     pushad
107
     call    [disable_mouse]
107
     call    [disable_mouse]
108
     sub     esp, putimg.stack_data
108
     sub     esp, putimg.stack_data
109
; save pointer to image
109
; save pointer to image
110
     mov     [putimg.pti], ebx
110
     mov     [putimg.pti], ebx
111
; unpack the size
111
; unpack the size
112
     mov     eax, ecx
112
     mov     eax, ecx
113
     and     ecx, 0xFFFF
113
     and     ecx, 0xFFFF
114
     shr     eax, 16
114
     shr     eax, 16
115
     mov     [putimg.image_sx], eax
115
     mov     [putimg.image_sx], eax
116
     mov     [putimg.image_sy], ecx
116
     mov     [putimg.image_sy], ecx
117
; unpack the coordinates
117
; unpack the coordinates
118
     mov     eax, edx
118
     mov     eax, edx
119
     and     edx, 0xFFFF
119
     and     edx, 0xFFFF
120
     shr     eax, 16
120
     shr     eax, 16
121
     mov     [putimg.image_cx], eax
121
     mov     [putimg.image_cx], eax
122
     mov     [putimg.image_cy], edx
122
     mov     [putimg.image_cy], edx
123
; calculate absolute (i.e. screen) coordinates
123
; calculate absolute (i.e. screen) coordinates
124
     mov     eax, [TASK_BASE]
124
     mov     eax, [TASK_BASE]
125
     mov     ebx, [eax-twdw + WDATA.box.left]
125
     mov     ebx, [eax-twdw + WDATA.box.left]
126
     add     ebx, [putimg.image_cx]
126
     add     ebx, [putimg.image_cx]
127
     mov     [putimg.abs_cx], ebx
127
     mov     [putimg.abs_cx], ebx
128
     mov     ebx, [eax-twdw + WDATA.box.top]
128
     mov     ebx, [eax-twdw + WDATA.box.top]
129
     add     ebx, [putimg.image_cy]
129
     add     ebx, [putimg.image_cy]
130
     mov     [putimg.abs_cy], ebx
130
     mov     [putimg.abs_cy], ebx
131
; real_sx = MIN(wnd_sx-image_cx, image_sx);
131
; real_sx = MIN(wnd_sx-image_cx, image_sx);
132
     mov     ebx, [eax-twdw + WDATA.box.width] ; ebx = wnd_sx
132
     mov     ebx, [eax-twdw + WDATA.box.width] ; ebx = wnd_sx
133
; \begin{diamond}[20.08.2006]
133
; \begin{diamond}[20.08.2006]
134
; note that WDATA.box.width is one pixel less than real window x-size
134
; note that WDATA.box.width is one pixel less than real window x-size
135
     inc     ebx
135
     inc     ebx
136
; \end{diamond}[20.08.2006]
136
; \end{diamond}[20.08.2006]
137
     sub     ebx, [putimg.image_cx]
137
     sub     ebx, [putimg.image_cx]
138
     ja      @f
138
     ja      @f
139
     add     esp, putimg.stack_data
139
     add     esp, putimg.stack_data
140
     popad
140
     popad
141
     ret
141
     ret
142
@@:
142
@@:
143
     cmp     ebx, [putimg.image_sx]
143
     cmp     ebx, [putimg.image_sx]
144
     jbe     .end_x
144
     jbe     .end_x
145
     mov     ebx, [putimg.image_sx]
145
     mov     ebx, [putimg.image_sx]
146
.end_x:
146
.end_x:
147
     mov     [putimg.real_sx], ebx
147
     mov     [putimg.real_sx], ebx
148
; init real_sy
148
; init real_sy
149
     mov     ebx, [eax-twdw + WDATA.box.height] ; ebx = wnd_sy
149
     mov     ebx, [eax-twdw + WDATA.box.height] ; ebx = wnd_sy
150
; \begin{diamond}[20.08.2006]
150
; \begin{diamond}[20.08.2006]
151
     inc     ebx
151
     inc     ebx
152
; \end{diamond}[20.08.2006]
152
; \end{diamond}[20.08.2006]
153
     sub     ebx, [putimg.image_cy]
153
     sub     ebx, [putimg.image_cy]
154
     ja      @f
154
     ja      @f
155
     add     esp, putimg.stack_data
155
     add     esp, putimg.stack_data
156
     popad
156
     popad
157
     ret
157
     ret
158
@@:
158
@@:
159
     cmp     ebx, [putimg.image_sy]
159
     cmp     ebx, [putimg.image_sy]
160
     jbe     .end_y
160
     jbe     .end_y
161
     mov     ebx, [putimg.image_sy]
161
     mov     ebx, [putimg.image_sy]
162
.end_y:
162
.end_y:
163
     mov     [putimg.real_sy], ebx
163
     mov     [putimg.real_sy], ebx
164
; line increment
164
; line increment
165
     mov     eax, [putimg.image_sx]
165
     mov     eax, [putimg.image_sx]
166
     mov     ecx, [putimg.real_sx]
166
     mov     ecx, [putimg.real_sx]
167
     sub     eax, ecx
167
     sub     eax, ecx
168
;;     imul    eax, [putimg.source_bpp]
168
;;     imul    eax, [putimg.source_bpp]
169
;     lea     eax, [eax + eax * 2]
169
;     lea     eax, [eax + eax * 2]
170
     call    esi
170
     call    esi
171
     add     eax, [putimg.arg_0]
171
     add     eax, [putimg.arg_0]
172
     mov     [putimg.line_increment], eax
172
     mov     [putimg.line_increment], eax
173
; winmap new line increment
173
; winmap new line increment
174
     mov     eax, [Screen_Max_X]
174
     mov     eax, [Screen_Max_X]
175
     inc     eax
175
     inc     eax
176
     sub     eax, [putimg.real_sx]
176
     sub     eax, [putimg.real_sx]
177
     mov     [putimg.winmap_newline], eax
177
     mov     [putimg.winmap_newline], eax
178
; screen new line increment
178
; screen new line increment
179
     mov     eax, [BytesPerScanLine]
179
     mov     eax, [BytesPerScanLine]
180
     mov     ebx, [ScreenBPP]
180
     mov     ebx, [ScreenBPP]
181
     shr     ebx, 3
181
     shr     ebx, 3
182
     imul    ecx, ebx
182
     imul    ecx, ebx
183
     sub     eax, ecx
183
     sub     eax, ecx
184
     mov     [putimg.screen_newline], eax
184
     mov     [putimg.screen_newline], eax
185
; pointer to image
185
; pointer to image
186
     mov     esi, [putimg.pti]
186
     mov     esi, [putimg.pti]
187
; pointer to screen
187
; pointer to screen
188
     mov     edx, [putimg.abs_cy]
188
     mov     edx, [putimg.abs_cy]
189
     imul    edx, [BytesPerScanLine]
189
     imul    edx, [BytesPerScanLine]
190
     mov     eax, [putimg.abs_cx]
190
     mov     eax, [putimg.abs_cx]
191
     mov     ebx, [ScreenBPP]
191
     mov     ebx, [ScreenBPP]
192
     shr     ebx, 3
192
     shr     ebx, 3
193
     imul    eax, ebx
193
     imul    eax, ebx
194
     add     edx, eax
194
     add     edx, eax
195
; pointer to pixel map
195
; pointer to pixel map
196
     mov     eax, [putimg.abs_cy]
196
     mov     eax, [putimg.abs_cy]
197
     imul    eax, [Screen_Max_X]
197
     imul    eax, [Screen_Max_X]
198
     add     eax, [putimg.abs_cy]
198
     add     eax, [putimg.abs_cy]
199
     add     eax, [putimg.abs_cx]
199
     add     eax, [putimg.abs_cx]
200
     add     eax, [_display_data]
200
     add     eax, [_display_data]
201
     xchg    eax, ebp
201
     xchg    eax, ebp
202
; get process number
202
; get process number
203
     mov     ebx, [CURRENT_TASK]
203
     mov     ebx, [CURRENT_TASK]
204
     cmp     byte [ScreenBPP], 32
204
     cmp     byte [ScreenBPP], 32
205
     je      put_image_end_32
205
     je      put_image_end_32
206
;put_image_end_24:
206
;put_image_end_24:
207
     mov     edi, [putimg.real_sy]
207
     mov     edi, [putimg.real_sy]
208
align   4
208
align   4
209
.new_line:
209
.new_line:
210
     mov     ecx, [putimg.real_sx]
210
     mov     ecx, [putimg.real_sx]
211
;     push    ebp edx
211
;     push    ebp edx
212
align   4
212
align   4
213
.new_x:
213
.new_x:
214
     push    [putimg.edi]
214
     push    [putimg.edi]
215
     mov     eax, [putimg.ebp+4]
215
     mov     eax, [putimg.ebp+4]
216
     call    eax
216
     call    eax
217
     cmp     [ebp], bl
217
     cmp     [ebp], bl
218
     jne     .skip
218
     jne     .skip
219
;     mov     eax, [esi]        ; eax = RRBBGGRR
219
;     mov     eax, [esi]        ; eax = RRBBGGRR
220
if SHADOWFB
220
if SHADOWFB
221
     mov     [SHADOWFB+edx], ax
221
     mov     [SHADOWFB+edx], ax
222
end if
222
end if
223
     mov     [LFB_BASE+edx], ax
223
     mov     [LFB_BASE+edx], ax
224
     shr     eax, 16
224
     shr     eax, 16
225
if SHADOWFB
225
if SHADOWFB
226
     mov     [SHADOWFB+edx+2], al
226
     mov     [SHADOWFB+edx+2], al
227
end if
227
end if
228
     mov     [LFB_BASE+edx+2], al
228
     mov     [LFB_BASE+edx+2], al
229
.skip:
229
.skip:
230
;     add     esi, 3 ;[putimg.source_bpp]
230
;     add     esi, 3 ;[putimg.source_bpp]
231
     add     edx, 3
231
     add     edx, 3
232
     inc     ebp
232
     inc     ebp
233
     dec     ecx
233
     dec     ecx
234
     jnz     .new_x
234
     jnz     .new_x
235
;     pop     edx ebp
235
;     pop     edx ebp
236
     add     esi, [putimg.line_increment]
236
     add     esi, [putimg.line_increment]
237
     add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
237
     add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
238
     add     ebp, [putimg.winmap_newline] ;[Screen_Max_X]
238
     add     ebp, [putimg.winmap_newline] ;[Screen_Max_X]
239
;     inc     ebp
239
;     inc     ebp
240
     cmp     [putimg.ebp], putimage_get1bpp
240
     cmp     [putimg.ebp], putimage_get1bpp
241
     jz      .correct
241
     jz      .correct
242
     cmp     [putimg.ebp], putimage_get4bpp
242
     cmp     [putimg.ebp], putimage_get4bpp
243
     jnz     @f
243
     jnz     @f
244
.correct:
244
.correct:
245
     mov     eax, [putimg.edi]
245
     mov     eax, [putimg.edi]
246
     mov     byte [eax], 80h
246
     mov     byte [eax], 80h
247
@@:
247
@@:
248
     dec     edi
248
     dec     edi
249
     jnz     .new_line
249
     jnz     .new_line
250
.finish:
250
.finish:
251
     add     esp, putimg.stack_data
251
     add     esp, putimg.stack_data
252
     popad
252
     popad
253
     ret
253
     ret
254
 
254
 
255
put_image_end_32:
255
put_image_end_32:
256
     mov     edi, [putimg.real_sy]
256
     mov     edi, [putimg.real_sy]
257
align   4
257
align   4
258
.new_line:
258
.new_line:
259
     mov     ecx, [putimg.real_sx]
259
     mov     ecx, [putimg.real_sx]
260
;     push    ebp edx
260
;     push    ebp edx
261
align   4
261
align   4
262
.new_x:
262
.new_x:
263
     push    [putimg.edi]
263
     push    [putimg.edi]
264
     mov     eax, [putimg.ebp+4]
264
     mov     eax, [putimg.ebp+4]
265
     call    eax
265
     call    eax
266
     cmp     [ebp], bl
266
     cmp     [ebp], bl
267
     jne     .skip
267
     jne     .skip
268
;     mov     eax, [esi]        ; ecx = RRBBGGRR
268
;     mov     eax, [esi]        ; ecx = RRBBGGRR
269
if SHADOWFB
269
if SHADOWFB
270
     mov     [SHADOWFB+edx], eax
270
     mov     [SHADOWFB+edx], eax
271
end if
271
end if
272
     mov     [LFB_BASE+edx], eax
272
     mov     [LFB_BASE+edx], eax
273
.skip:
273
.skip:
274
;     add     esi, [putimg.source_bpp]
274
;     add     esi, [putimg.source_bpp]
275
     add     edx, 4
275
     add     edx, 4
276
     inc     ebp
276
     inc     ebp
277
     dec     ecx
277
     dec     ecx
278
     jnz     .new_x
278
     jnz     .new_x
279
;     pop     edx ebp
279
;     pop     edx ebp
280
     add     esi, [putimg.line_increment]
280
     add     esi, [putimg.line_increment]
281
     add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
281
     add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
282
     add     ebp, [putimg.winmap_newline] ;[Screen_Max_X]
282
     add     ebp, [putimg.winmap_newline] ;[Screen_Max_X]
283
;     inc     ebp
283
;     inc     ebp
284
     cmp     [putimg.ebp], putimage_get1bpp
284
     cmp     [putimg.ebp], putimage_get1bpp
285
     jz      .correct
285
     jz      .correct
286
     cmp     [putimg.ebp], putimage_get4bpp
286
     cmp     [putimg.ebp], putimage_get4bpp
287
     jnz     @f
287
     jnz     @f
288
.correct:
288
.correct:
289
     mov     eax, [putimg.edi]
289
     mov     eax, [putimg.edi]
290
     mov     byte [eax], 80h
290
     mov     byte [eax], 80h
291
@@:
291
@@:
292
     dec     edi
292
     dec     edi
293
     jnz     .new_line
293
     jnz     .new_line
294
.finish:
294
.finish:
295
     add     esp, putimg.stack_data
295
     add     esp, putimg.stack_data
296
     popad
296
     popad
297
     call   VGA__putimage
297
     call   VGA__putimage
298
     mov     [EGA_counter],1
298
     mov     [EGA_counter],1
299
     ret
299
     ret
300
 
300
 
301
 
301
 
302
;*************************************************
302
;*************************************************
303
align 4
303
align 4
304
__sys_putpixel:
304
__sys_putpixel:
305
 
305
 
306
; eax = x coordinate
306
; eax = x coordinate
307
; ebx = y coordinate
307
; ebx = y coordinate
308
; ecx = ?? RR GG BB    ; 0x01000000 negation
308
; ecx = ?? RR GG BB    ; 0x01000000 negation
309
; edi = 0x00000001 force
309
; edi = 0x00000001 force
310
 
310
 
311
;;;        mov  [novesachecksum], dword 0
311
;;;        mov  [novesachecksum], dword 0
312
     pushad
312
     pushad
313
     test  edi,1                 ; force ?
313
     test  edi,1                 ; force ?
314
     jnz   .forced
314
     jnz   .forced
315
; not forced:
315
; not forced:
316
     push  ecx               ; save 24th bit in case negative pixel wanted
316
     push  ecx               ; save 24th bit in case negative pixel wanted
317
     call  checkpixel
317
     call  checkpixel
318
     test  ecx,ecx
318
     test  ecx,ecx
319
     pop   ecx
319
     pop   ecx
320
     jnz   .exit
320
     jnz   .exit
321
.forced:
321
.forced:
322
     cmp   [Screen_Max_X], eax
322
     cmp   [Screen_Max_X], eax
323
     jb    .exit
323
     jb    .exit
324
     cmp   [Screen_Max_Y], ebx
324
     cmp   [Screen_Max_Y], ebx
325
     jb    .exit
325
     jb    .exit
326
.ok:
326
.ok:
327
; check if negation
327
; check if negation
328
     test  ecx,0x01000000
328
     test  ecx,0x01000000
329
     jz    .noneg
329
     jz    .noneg
330
     call  getpixel
330
     call  getpixel
331
     not   ecx
331
     not   ecx
332
     mov   [esp+32-8],ecx
332
     mov   [esp+32-8],ecx
333
.noneg:
333
.noneg:
334
; OK to set pixel
334
; OK to set pixel
335
     call  [put_pixel]    ; call the real put_pixel function
335
     call  [put_pixel]    ; call the real put_pixel function
336
.exit:
336
.exit:
337
     popad
337
     popad
338
     ret
338
     ret
339
 
339
 
340
align 4
340
align 4
341
Vesa20_putpixel24:
341
Vesa20_putpixel24:
342
; eax = x
342
; eax = x
343
; ebx = y
343
; ebx = y
344
     imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
344
     imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
345
     lea     edi, [eax+eax*2]  ; edi = x*3
345
     lea     edi, [eax+eax*2]  ; edi = x*3
346
     mov     eax, [esp+32-8+4]
346
     mov     eax, [esp+32-8+4]
347
if SHADOWFB
347
if SHADOWFB
348
     mov     [SHADOWFB+ebx+edi], ax
348
     mov     [SHADOWFB+ebx+edi], ax
349
end if
349
end if
350
     mov     [LFB_BASE+ebx+edi], ax
350
     mov     [LFB_BASE+ebx+edi], ax
351
     shr     eax, 16
351
     shr     eax, 16
352
if SHADOWFB
352
if SHADOWFB
353
     mov     [SHADOWFB+ebx+edi+2], al
353
     mov     [SHADOWFB+ebx+edi+2], al
354
end if
354
end if
355
     mov     [LFB_BASE+ebx+edi+2], al
355
     mov     [LFB_BASE+ebx+edi+2], al
356
     ret
356
     ret
357
 
357
 
358
 
358
 
359
align 4
359
align 4
360
Vesa20_putpixel32:
360
Vesa20_putpixel32:
361
; eax = x
361
; eax = x
362
; ebx = y
362
; ebx = y
363
     imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
363
     imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
364
     lea     edi, [ebx+eax*4]  ; edi = x*4+(y*y multiplier)
364
     lea     edi, [ebx+eax*4]  ; edi = x*4+(y*y multiplier)
365
     mov     eax, [esp+32-8+4] ; eax = color
365
     mov     eax, [esp+32-8+4] ; eax = color
366
if SHADOWFB
366
if SHADOWFB
367
     mov     [SHADOWFB+edi], eax
367
     mov     [SHADOWFB+edi], eax
368
end if
368
end if
369
     mov     [LFB_BASE+edi], eax
369
     mov     [LFB_BASE+edi], eax
370
     ret
370
     ret
371
 
371
 
372
;*************************************************
372
;*************************************************
373
 
373
 
374
;align 4
374
;align 4
375
calculate_edi:
375
calculate_edi:
376
     mov     edi, ebx
376
     mov     edi, ebx
377
     imul    edi, [Screen_Max_X]
377
     imul    edi, [Screen_Max_X]
378
     add     edi, ebx
378
     add     edi, ebx
379
     add     edi, eax
379
     add     edi, eax
380
     ret
380
     ret
381
 
381
 
382
;*************************************************
382
;*************************************************
383
 
383
 
384
; DRAWLINE
384
; DRAWLINE
385
 
385
 
386
align 4
386
align 4
387
__sys_draw_line:
387
__sys_draw_line:
388
;     inc   [mouse_pause]
388
;     inc   [mouse_pause]
389
     call    [disable_mouse]
389
     call    [disable_mouse]
390
 
390
 
391
; draw a line
391
; draw a line
392
; eax = HIWORD = x1
392
; eax = HIWORD = x1
393
;       LOWORD = x2
393
;       LOWORD = x2
394
; ebx = HIWORD = y1
394
; ebx = HIWORD = y1
395
;       LOWORD = y2
395
;       LOWORD = y2
396
; ecx = color
396
; ecx = color
397
; edi = force ?
397
; edi = force ?
398
        pusha
398
        pusha
399
 
399
 
400
dl_x1 equ esp+20
400
dl_x1 equ esp+20
401
dl_y1 equ esp+16
401
dl_y1 equ esp+16
402
dl_x2 equ esp+12
402
dl_x2 equ esp+12
403
dl_y2 equ esp+8
403
dl_y2 equ esp+8
404
dl_dx equ esp+4
404
dl_dx equ esp+4
405
dl_dy equ esp+0
405
dl_dy equ esp+0
406
 
406
 
407
     xor     edx, edx      ; clear edx
407
     xor     edx, edx      ; clear edx
408
     xor     esi, esi      ; unpack arguments
408
     xor     esi, esi      ; unpack arguments
409
     xor     ebp, ebp
409
     xor     ebp, ebp
410
     mov     si, ax        ; esi = x2
410
     mov     si, ax        ; esi = x2
411
     mov     bp, bx        ; ebp = y2
411
     mov     bp, bx        ; ebp = y2
412
     shr     eax, 16       ; eax = x1
412
     shr     eax, 16       ; eax = x1
413
     shr     ebx, 16       ; ebx = y1
413
     shr     ebx, 16       ; ebx = y1
414
     push    eax           ; save x1
414
     push    eax           ; save x1
415
     push    ebx           ; save y1
415
     push    ebx           ; save y1
416
     push    esi           ; save x2
416
     push    esi           ; save x2
417
     push    ebp           ; save y2
417
     push    ebp           ; save y2
418
; checking x-axis...
418
; checking x-axis...
419
     sub     esi, eax      ; esi = x2-x1
419
     sub     esi, eax      ; esi = x2-x1
420
     push    esi           ; save y2-y1
420
     push    esi           ; save y2-y1
421
     jl      .x2lx1        ; is x2 less than x1 ?
421
     jl      .x2lx1        ; is x2 less than x1 ?
422
     jg      .no_vline     ; x1 > x2 ?
422
     jg      .no_vline     ; x1 > x2 ?
423
     mov     edx, ebp      ; else (if x1=x2)
423
     mov     edx, ebp      ; else (if x1=x2)
424
     call    vline
424
     call    vline
425
     push    edx    ; necessary to rightly restore stack frame at .exit
425
     push    edx    ; necessary to rightly restore stack frame at .exit
426
     jmp     .exit
426
     jmp     .exit
427
.x2lx1:
427
.x2lx1:
428
     neg     esi            ; get esi absolute value
428
     neg     esi            ; get esi absolute value
429
.no_vline:
429
.no_vline:
430
; checking y-axis...
430
; checking y-axis...
431
     sub     ebp, ebx       ; ebp = y2-y1
431
     sub     ebp, ebx       ; ebp = y2-y1
432
     push    ebp            ; save y2-y1
432
     push    ebp            ; save y2-y1
433
     jl      .y2ly1         ; is y2 less than y1 ?
433
     jl      .y2ly1         ; is y2 less than y1 ?
434
     jg      .no_hline      ; y1 > y2 ?
434
     jg      .no_hline      ; y1 > y2 ?
435
     mov     edx, [dl_x2]   ; else (if y1=y2)
435
     mov     edx, [dl_x2]   ; else (if y1=y2)
436
     call    hline
436
     call    hline
437
     jmp     .exit
437
     jmp     .exit
438
 
438
 
439
.y2ly1:
439
.y2ly1:
440
     neg     ebp            ; get ebp absolute value
440
     neg     ebp            ; get ebp absolute value
441
.no_hline:
441
.no_hline:
442
     cmp     ebp, esi
442
     cmp     ebp, esi
443
     jle     .x_rules       ; |y2-y1| < |x2-x1|  ?
443
     jle     .x_rules       ; |y2-y1| < |x2-x1|  ?
444
     cmp     [dl_y2], ebx   ; make sure y1 is at the begining
444
     cmp     [dl_y2], ebx   ; make sure y1 is at the begining
445
     jge     .no_reverse1
445
     jge     .no_reverse1
446
     neg     dword [dl_dx]
446
     neg     dword [dl_dx]
447
     mov     edx, [dl_x2]
447
     mov     edx, [dl_x2]
448
     mov     [dl_x2], eax
448
     mov     [dl_x2], eax
449
     mov     [dl_x1], edx
449
     mov     [dl_x1], edx
450
     mov     edx, [dl_y2]
450
     mov     edx, [dl_y2]
451
     mov     [dl_y2], ebx
451
     mov     [dl_y2], ebx
452
     mov     [dl_y1], edx
452
     mov     [dl_y1], edx
453
.no_reverse1:
453
.no_reverse1:
454
     mov     eax, [dl_dx]
454
     mov     eax, [dl_dx]
455
     cdq                    ; extend eax sing to edx
455
     cdq                    ; extend eax sing to edx
456
     shl     eax, 16        ; using 16bit fix-point maths
456
     shl     eax, 16        ; using 16bit fix-point maths
457
     idiv    ebp            ; eax = ((x2-x1)*65536)/(y2-y1)
457
     idiv    ebp            ; eax = ((x2-x1)*65536)/(y2-y1)
458
     mov     edx, ebp       ; edx = counter (number of pixels to draw)
458
     mov     edx, ebp       ; edx = counter (number of pixels to draw)
459
     mov     ebp, 1 *65536  ; <<16   ; ebp = dy = 1.0
459
     mov     ebp, 1 *65536  ; <<16   ; ebp = dy = 1.0
460
     mov     esi, eax       ; esi = dx
460
     mov     esi, eax       ; esi = dx
461
     jmp     .y_rules
461
     jmp     .y_rules
462
 
462
 
463
.x_rules:
463
.x_rules:
464
     cmp     [dl_x2], eax    ; make sure x1 is at the begining
464
     cmp     [dl_x2], eax    ; make sure x1 is at the begining
465
     jge     .no_reverse2
465
     jge     .no_reverse2
466
     neg     dword [dl_dy]
466
     neg     dword [dl_dy]
467
     mov     edx, [dl_x2]
467
     mov     edx, [dl_x2]
468
     mov     [dl_x2], eax
468
     mov     [dl_x2], eax
469
     mov     [dl_x1], edx
469
     mov     [dl_x1], edx
470
     mov     edx, [dl_y2]
470
     mov     edx, [dl_y2]
471
     mov     [dl_y2], ebx
471
     mov     [dl_y2], ebx
472
     mov     [dl_y1], edx
472
     mov     [dl_y1], edx
473
.no_reverse2:
473
.no_reverse2:
474
     xor     edx, edx
474
     xor     edx, edx
475
     mov     eax, [dl_dy]
475
     mov     eax, [dl_dy]
476
     cdq                    ; extend eax sing to edx
476
     cdq                    ; extend eax sing to edx
477
     shl     eax, 16        ; using 16bit fix-point maths
477
     shl     eax, 16        ; using 16bit fix-point maths
478
     idiv    esi            ; eax = ((y2-y1)*65536)/(x2-x1)
478
     idiv    esi            ; eax = ((y2-y1)*65536)/(x2-x1)
479
     mov     edx, esi       ; edx = counter (number of pixels to draw)
479
     mov     edx, esi       ; edx = counter (number of pixels to draw)
480
     mov     esi, 1 *65536  ;<< 16   ; esi = dx = 1.0
480
     mov     esi, 1 *65536  ;<< 16   ; esi = dx = 1.0
481
     mov     ebp, eax       ; ebp = dy
481
     mov     ebp, eax       ; ebp = dy
482
.y_rules:
482
.y_rules:
483
     mov     eax, [dl_x1]
483
     mov     eax, [dl_x1]
484
     mov     ebx, [dl_y1]
484
     mov     ebx, [dl_y1]
485
     shl     eax, 16
485
     shl     eax, 16
486
     shl     ebx, 16
486
     shl     ebx, 16
487
align 4
487
align 4
488
.draw:
488
.draw:
489
     push    eax ebx
489
     push    eax ebx
490
     shr     eax, 16
490
     shr     eax, 16
491
     shr     ebx, 16
491
     shr     ebx, 16
492
     call    [putpixel]
492
     call    [putpixel]
493
     pop     ebx eax
493
     pop     ebx eax
494
     add     ebx, ebp        ; y = y+dy
494
     add     ebx, ebp        ; y = y+dy
495
     add     eax, esi        ; x = x+dx
495
     add     eax, esi        ; x = x+dx
496
     dec     edx
496
     dec     edx
497
     jnz     .draw
497
     jnz     .draw
498
; force last drawn pixel to be at (x2,y2)
498
; force last drawn pixel to be at (x2,y2)
499
     mov     eax, [dl_x2]
499
     mov     eax, [dl_x2]
500
     mov     ebx, [dl_y2]
500
     mov     ebx, [dl_y2]
501
     call    [putpixel]
501
     call    [putpixel]
502
.exit:
502
.exit:
503
     add     esp, 6*4
503
     add     esp, 6*4
504
     popa
504
     popa
505
;     dec   [mouse_pause]
505
;     dec   [mouse_pause]
506
     call   [draw_pointer]
506
     call   [draw_pointer]
507
     ret
507
     ret
508
 
508
 
509
 
509
 
510
hline:
510
hline:
511
; draw an horizontal line
511
; draw an horizontal line
512
; eax = x1
512
; eax = x1
513
; edx = x2
513
; edx = x2
514
; ebx = y
514
; ebx = y
515
; ecx = color
515
; ecx = color
516
; edi = force ?
516
; edi = force ?
517
     push    eax edx
517
     push    eax edx
518
     cmp     edx, eax      ; make sure x2 is above x1
518
     cmp     edx, eax      ; make sure x2 is above x1
519
     jge     @f
519
     jge     @f
520
     xchg    eax, edx
520
     xchg    eax, edx
521
align   4
521
align   4
522
@@:
522
@@:
523
     call    [putpixel]
523
     call    [putpixel]
524
     inc     eax
524
     inc     eax
525
     cmp     eax, edx
525
     cmp     eax, edx
526
     jle     @b
526
     jle     @b
527
     pop     edx eax
527
     pop     edx eax
528
     ret
528
     ret
529
 
529
 
530
 
530
 
531
vline:
531
vline:
532
; draw a vertical line
532
; draw a vertical line
533
; eax = x
533
; eax = x
534
; ebx = y1
534
; ebx = y1
535
; edx = y2
535
; edx = y2
536
; ecx = color
536
; ecx = color
537
; edi = force ?
537
; edi = force ?
538
     push    ebx edx
538
     push    ebx edx
539
     cmp     edx, ebx      ; make sure y2 is above y1
539
     cmp     edx, ebx      ; make sure y2 is above y1
540
     jge     @f
540
     jge     @f
541
     xchg    ebx, edx
541
     xchg    ebx, edx
542
align   4
542
align   4
543
@@:
543
@@:
544
     call    [putpixel]
544
     call    [putpixel]
545
     inc     ebx
545
     inc     ebx
546
     cmp     ebx, edx
546
     cmp     ebx, edx
547
     jle     @b
547
     jle     @b
548
     pop     edx ebx
548
     pop     edx ebx
549
     ret
549
     ret
550
 
550
 
551
 
551
 
552
;*************************************************
552
;*************************************************
553
 
553
 
554
 
554
 
555
virtual at esp
555
virtual at esp
556
drbar:
556
drbar:
557
     .bar_sx       dd ?
557
     .bar_sx       dd ?
558
     .bar_sy       dd ?
558
     .bar_sy       dd ?
559
     .bar_cx       dd ?
559
     .bar_cx       dd ?
560
     .bar_cy       dd ?
560
     .bar_cy       dd ?
561
     .abs_cx       dd ?
561
     .abs_cx       dd ?
562
     .abs_cy       dd ?
562
     .abs_cy       dd ?
563
     .real_sx      dd ?
563
     .real_sx      dd ?
564
     .real_sy      dd ?
564
     .real_sy      dd ?
565
     .color        dd ?
565
     .color        dd ?
566
     .line_inc_scr dd ?
566
     .line_inc_scr dd ?
567
     .line_inc_map dd ?
567
     .line_inc_map dd ?
568
     .stack_data = 4*11
568
     .stack_data = 4*11
569
end virtual
569
end virtual
570
 
570
 
571
align 4
571
align 4
572
; eax   cx
572
; eax   cx
573
; ebx   cy
573
; ebx   cy
574
; ecx   xe
574
; ecx   xe
575
; edx   ye
575
; edx   ye
576
; edi   color
576
; edi   color
-
 
577
_vesa20_drawbar:
577
vesa20_drawbar:
578
vesa20_drawbar:
578
     pushad
579
     pushad
579
     call    [disable_mouse]
580
     call    [disable_mouse]
580
     sub     esp, drbar.stack_data
581
     sub     esp, drbar.stack_data
581
     mov     [drbar.color], edi
582
     mov     [drbar.color], edi
582
     sub     edx, ebx
583
     sub     edx, ebx
583
     jle     .exit          ;// mike.dld, 2005-01-29
584
     jle     .exit          ;// mike.dld, 2005-01-29
584
     sub     ecx, eax
585
     sub     ecx, eax
585
     jle     .exit          ;// mike.dld, 2005-01-29
586
     jle     .exit          ;// mike.dld, 2005-01-29
586
     mov     [drbar.bar_sy], edx
587
     mov     [drbar.bar_sy], edx
587
     mov     [drbar.bar_sx], ecx
588
     mov     [drbar.bar_sx], ecx
588
     mov     [drbar.bar_cx], eax
589
     mov     [drbar.bar_cx], eax
589
     mov     [drbar.bar_cy], ebx
590
     mov     [drbar.bar_cy], ebx
590
     mov     edi, [TASK_BASE]
591
     mov     edi, [TASK_BASE]
591
     add     eax, [edi-twdw + WDATA.box.left] ; win_cx
592
     add     eax, [edi-twdw + WDATA.box.left] ; win_cx
592
     add     ebx, [edi-twdw + WDATA.box.top] ; win_cy
593
     add     ebx, [edi-twdw + WDATA.box.top] ; win_cy
593
     mov     [drbar.abs_cx], eax
594
     mov     [drbar.abs_cx], eax
594
     mov     [drbar.abs_cy], ebx
595
     mov     [drbar.abs_cy], ebx
595
; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
596
; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
596
     mov     ebx, [edi-twdw + WDATA.box.width] ; ebx = wnd_sx
597
     mov     ebx, [edi-twdw + WDATA.box.width] ; ebx = wnd_sx
597
; \begin{diamond}[20.08.2006]
598
; \begin{diamond}[20.08.2006]
598
; note that WDATA.box.width is one pixel less than real window x-size
599
; note that WDATA.box.width is one pixel less than real window x-size
599
     inc     ebx
600
     inc     ebx
600
; \end{diamond}[20.08.2006]
601
; \end{diamond}[20.08.2006]
601
     sub     ebx, [drbar.bar_cx]
602
     sub     ebx, [drbar.bar_cx]
602
     ja      @f
603
     ja      @f
603
.exit:                       ;// mike.dld, 2005-01-29
604
.exit:                       ;// mike.dld, 2005-01-29
604
     add     esp, drbar.stack_data
605
     add     esp, drbar.stack_data
605
     popad
606
     popad
606
     xor     eax, eax
607
     xor     eax, eax
607
     inc     eax
608
     inc     eax
608
     ret
609
     ret
609
@@:
610
@@:
610
     cmp     ebx, [drbar.bar_sx]
611
     cmp     ebx, [drbar.bar_sx]
611
     jbe     .end_x
612
     jbe     .end_x
612
     mov     ebx, [drbar.bar_sx]
613
     mov     ebx, [drbar.bar_sx]
613
.end_x:
614
.end_x:
614
     mov     [drbar.real_sx], ebx
615
     mov     [drbar.real_sx], ebx
615
; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
616
; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
616
     mov     ebx, [edi-twdw + WDATA.box.height] ; ebx = wnd_sy
617
     mov     ebx, [edi-twdw + WDATA.box.height] ; ebx = wnd_sy
617
; \begin{diamond}[20.08.2006]
618
; \begin{diamond}[20.08.2006]
618
     inc     ebx
619
     inc     ebx
619
; \end{diamond}
620
; \end{diamond}
620
     sub     ebx, [drbar.bar_cy]
621
     sub     ebx, [drbar.bar_cy]
621
     ja      @f
622
     ja      @f
622
     add     esp, drbar.stack_data
623
     add     esp, drbar.stack_data
623
     popad
624
     popad
624
     xor     eax, eax
625
     xor     eax, eax
625
     inc     eax
626
     inc     eax
626
     ret
627
     ret
627
@@:
628
@@:
628
     cmp     ebx, [drbar.bar_sy]
629
     cmp     ebx, [drbar.bar_sy]
629
     jbe     .end_y
630
     jbe     .end_y
630
     mov     ebx, [drbar.bar_sy]
631
     mov     ebx, [drbar.bar_sy]
631
.end_y:
632
.end_y:
632
     mov     [drbar.real_sy], ebx
633
     mov     [drbar.real_sy], ebx
633
; line_inc_map
634
; line_inc_map
634
     mov     eax, [Screen_Max_X]
635
     mov     eax, [Screen_Max_X]
635
     sub     eax, [drbar.real_sx]
636
     sub     eax, [drbar.real_sx]
636
     inc     eax
637
     inc     eax
637
     mov     [drbar.line_inc_map], eax
638
     mov     [drbar.line_inc_map], eax
638
; line_inc_scr
639
; line_inc_scr
639
     mov     eax, [drbar.real_sx]
640
     mov     eax, [drbar.real_sx]
640
     mov     ebx, [ScreenBPP]
641
     mov     ebx, [ScreenBPP]
641
     shr     ebx, 3
642
     shr     ebx, 3
642
     imul    eax, ebx
643
     imul    eax, ebx
643
     neg     eax
644
     neg     eax
644
     add     eax, [BytesPerScanLine]
645
     add     eax, [BytesPerScanLine]
645
     mov     [drbar.line_inc_scr], eax
646
     mov     [drbar.line_inc_scr], eax
646
; pointer to screen
647
; pointer to screen
647
     mov     edx, [drbar.abs_cy]
648
     mov     edx, [drbar.abs_cy]
648
     imul    edx, [BytesPerScanLine]
649
     imul    edx, [BytesPerScanLine]
649
     mov     eax, [drbar.abs_cx]
650
     mov     eax, [drbar.abs_cx]
650
;     mov    ebx, [ScreenBPP]
651
;     mov    ebx, [ScreenBPP]
651
;     shr     ebx, 3
652
;     shr     ebx, 3
652
     imul    eax, ebx
653
     imul    eax, ebx
653
     add     edx, eax
654
     add     edx, eax
654
; pointer to pixel map
655
; pointer to pixel map
655
     mov     eax, [drbar.abs_cy]
656
     mov     eax, [drbar.abs_cy]
656
     imul    eax, [Screen_Max_X]
657
     imul    eax, [Screen_Max_X]
657
     add     eax, [drbar.abs_cy]
658
     add     eax, [drbar.abs_cy]
658
     add     eax, [drbar.abs_cx]
659
     add     eax, [drbar.abs_cx]
659
     add     eax, [_display_data]
660
     add     eax, [_display_data]
660
     xchg    eax, ebp
661
     xchg    eax, ebp
661
; get process number
662
; get process number
662
     mov     ebx, [CURRENT_TASK]
663
     mov     ebx, [CURRENT_TASK]
663
     cmp     byte [ScreenBPP], 24
664
     cmp     byte [ScreenBPP], 24
664
     jne     draw_bar_end_32
665
     jne     draw_bar_end_32
665
draw_bar_end_24:
666
draw_bar_end_24:
666
     mov     eax, [drbar.color]    ;; BBGGRR00
667
     mov     eax, [drbar.color]    ;; BBGGRR00
667
     mov     bh, al                ;; bh  = BB
668
     mov     bh, al                ;; bh  = BB
668
     shr     eax, 8                ;; eax = RRGG
669
     shr     eax, 8                ;; eax = RRGG
669
; eax - color high   RRGG
670
; eax - color high   RRGG
670
; bl - process num
671
; bl - process num
671
; bh - color low    BB
672
; bh - color low    BB
672
; ecx - temp
673
; ecx - temp
673
; edx - pointer to screen
674
; edx - pointer to screen
674
; esi - counter
675
; esi - counter
675
; edi - counter
676
; edi - counter
676
     mov     esi, [drbar.real_sy]
677
     mov     esi, [drbar.real_sy]
677
align   4
678
align   4
678
.new_y:
679
.new_y:
679
     mov     edi, [drbar.real_sx]
680
     mov     edi, [drbar.real_sx]
680
align   4
681
align   4
681
.new_x:
682
.new_x:
682
     cmp     byte [ebp], bl
683
     cmp     byte [ebp], bl
683
     jne     .skip
684
     jne     .skip
684
if SHADOWFB
685
if SHADOWFB
685
     mov     [SHADOWFB+edx], bh
686
     mov     [SHADOWFB+edx], bh
686
     mov     [SHADOWFB+edx + 1], ax
687
     mov     [SHADOWFB+edx + 1], ax
687
end if
688
end if
688
     mov     [LFB_BASE+edx], bh
689
     mov     [LFB_BASE+edx], bh
689
     mov     [LFB_BASE+edx + 1], ax
690
     mov     [LFB_BASE+edx + 1], ax
690
.skip:
691
.skip:
691
; add pixel
692
; add pixel
692
     add     edx, 3
693
     add     edx, 3
693
     inc     ebp
694
     inc     ebp
694
     dec     edi
695
     dec     edi
695
     jnz     .new_x
696
     jnz     .new_x
696
; add line
697
; add line
697
     add     edx, [drbar.line_inc_scr]
698
     add     edx, [drbar.line_inc_scr]
698
     add     ebp, [drbar.line_inc_map]
699
     add     ebp, [drbar.line_inc_map]
699
;  drawing gradient bars
700
;  drawing gradient bars
700
     test    eax, 0x00800000
701
     test    eax, 0x00800000
701
     jz      @f
702
     jz      @f
702
     test    bh, bh
703
     test    bh, bh
703
     jz      @f
704
     jz      @f
704
     dec     bh
705
     dec     bh
705
@@:
706
@@:
706
; 
707
; 
707
     dec     esi
708
     dec     esi
708
     jnz     .new_y
709
     jnz     .new_y
709
     add     esp, drbar.stack_data
710
     add     esp, drbar.stack_data
710
     popad
711
     popad
711
     xor     eax, eax
712
     xor     eax, eax
712
     ret
713
     ret
713
 
714
 
714
draw_bar_end_32:
715
draw_bar_end_32:
715
     mov     eax, [drbar.color]    ;; BBGGRR00
716
     mov     eax, [drbar.color]    ;; BBGGRR00
716
     mov     esi, [drbar.real_sy]
717
     mov     esi, [drbar.real_sy]
717
align   4
718
align   4
718
.new_y:
719
.new_y:
719
     mov     edi, [drbar.real_sx]
720
     mov     edi, [drbar.real_sx]
720
align   4
721
align   4
721
.new_x:
722
.new_x:
722
     cmp     byte [ebp], bl
723
     cmp     byte [ebp], bl
723
     jne     .skip
724
     jne     .skip
724
if SHADOWFB
725
if SHADOWFB
725
     mov     [SHADOWFB+edx], eax
726
     mov     [SHADOWFB+edx], eax
726
end if
727
end if
727
     mov     [LFB_BASE+edx], eax
728
     mov     [LFB_BASE+edx], eax
728
.skip:
729
.skip:
729
; add pixel
730
; add pixel
730
     add     edx, 4
731
     add     edx, 4
731
     inc     ebp
732
     inc     ebp
732
     dec     edi
733
     dec     edi
733
     jnz     .new_x
734
     jnz     .new_x
734
; add line
735
; add line
735
     add     edx, [drbar.line_inc_scr]
736
     add     edx, [drbar.line_inc_scr]
736
     add     ebp, [drbar.line_inc_map]
737
     add     ebp, [drbar.line_inc_map]
737
;  drawing gradient bars
738
;  drawing gradient bars
738
     test    eax, 0x80000000
739
     test    eax, 0x80000000
739
     jz      @f
740
     jz      @f
740
     test    al, al
741
     test    al, al
741
     jz      @f
742
     jz      @f
742
     dec     al
743
     dec     al
743
@@:
744
@@:
744
; 
745
; 
745
     dec     esi
746
     dec     esi
746
     jnz     .new_y
747
     jnz     .new_y
747
     add     esp, drbar.stack_data
748
     add     esp, drbar.stack_data
748
     popad
749
     popad
749
     call    VGA_draw_bar
750
     call    VGA_draw_bar
750
     xor     eax, eax
751
     xor     eax, eax
751
     mov     [EGA_counter],1
752
     mov     [EGA_counter],1
752
     ret
753
     ret
753
 
754
 
754
 
755
 
755
vesa20_drawbackground_tiled:
756
vesa20_drawbackground_tiled:
756
        call    [disable_mouse]
757
        call    [disable_mouse]
757
        pushad
758
        pushad
758
; External loop for all y from start to end
759
; External loop for all y from start to end
759
        mov     ebx, [draw_data+32+RECT.top]    ; y start
760
        mov     ebx, [draw_data+32+RECT.top]    ; y start
760
dp2:
761
dp2:
761
        mov     ebp, [draw_data+32+RECT.left]   ; x start
762
        mov     ebp, [draw_data+32+RECT.left]   ; x start
762
; 1) Calculate pointers in display_data (does pixel belong to OS thread?) [ebp]
763
; 1) Calculate pointers in display_data (does pixel belong to OS thread?) [ebp]
763
;                       and LFB data (output for our function) [edi]
764
;                       and LFB data (output for our function) [edi]
764
        mov     eax, [BytesPerScanLine]
765
        mov     eax, [BytesPerScanLine]
765
        mul     ebx
766
        mul     ebx
766
        xchg    ebp, eax
767
        xchg    ebp, eax
767
        add     ebp, eax
768
        add     ebp, eax
768
        add     ebp, eax
769
        add     ebp, eax
769
        add     ebp, eax
770
        add     ebp, eax
770
        cmp     byte [ScreenBPP], 24    ; 24 or 32 bpp ? - x size
771
        cmp     byte [ScreenBPP], 24    ; 24 or 32 bpp ? - x size
771
        jz      @f
772
        jz      @f
772
        add     ebp, eax
773
        add     ebp, eax
773
@@:
774
@@:
774
       ; add     ebp, LFB_BASE
775
       ; add     ebp, LFB_BASE
775
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
776
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
776
        call    calculate_edi
777
        call    calculate_edi
777
        xchg    edi, ebp
778
        xchg    edi, ebp
778
 
779
 
779
        add ebp, [_display_data]
780
        add ebp, [_display_data]
780
 
781
 
781
; Now eax=x, ebx=y, edi->output, ebp=offset in display_data
782
; Now eax=x, ebx=y, edi->output, ebp=offset in display_data
782
; 2) Calculate offset in background memory block
783
; 2) Calculate offset in background memory block
783
        push    eax
784
        push    eax
784
        xor     edx, edx
785
        xor     edx, edx
785
        mov     eax, ebx
786
        mov     eax, ebx
786
        div     dword [BgrDataHeight]   ; edx := y mod BgrDataHeight
787
        div     dword [BgrDataHeight]   ; edx := y mod BgrDataHeight
787
        pop     eax
788
        pop     eax
788
        push    eax
789
        push    eax
789
        mov     ecx, [BgrDataWidth]
790
        mov     ecx, [BgrDataWidth]
790
        mov     esi, edx
791
        mov     esi, edx
791
        imul    esi, ecx                ; esi := (y mod BgrDataHeight) * BgrDataWidth
792
        imul    esi, ecx                ; esi := (y mod BgrDataHeight) * BgrDataWidth
792
        xor     edx, edx
793
        xor     edx, edx
793
        div     ecx             ; edx := x mod BgrDataWidth
794
        div     ecx             ; edx := x mod BgrDataWidth
794
        sub     ecx, edx
795
        sub     ecx, edx
795
        add     esi, edx        ; esi := (y mod BgrDataHeight)*BgrDataWidth + (x mod BgrDataWidth)
796
        add     esi, edx        ; esi := (y mod BgrDataHeight)*BgrDataWidth + (x mod BgrDataWidth)
796
        pop     eax
797
        pop     eax
797
        lea     esi, [esi*3]
798
        lea     esi, [esi*3]
798
        add     esi, [img_background]
799
        add     esi, [img_background]
799
        xor     edx, edx
800
        xor     edx, edx
800
        inc     edx
801
        inc     edx
801
; 3) Loop through redraw rectangle and copy background data
802
; 3) Loop through redraw rectangle and copy background data
802
; Registers meaning:
803
; Registers meaning:
803
; eax = x, ebx = y (screen coordinates)
804
; eax = x, ebx = y (screen coordinates)
804
; ecx = deltax - number of pixels left in current tile block
805
; ecx = deltax - number of pixels left in current tile block
805
; edx = 1
806
; edx = 1
806
; esi -> bgr memory, edi -> output
807
; esi -> bgr memory, edi -> output
807
; ebp = offset in display_data
808
; ebp = offset in display_data
808
dp3:
809
dp3:
809
        cmp     [ebp], dl
810
        cmp     [ebp], dl
810
        jnz     nbgp
811
        jnz     nbgp
811
        movsb
812
        movsb
812
        movsb
813
        movsb
813
        movsb
814
        movsb
814
        jmp     @f
815
        jmp     @f
815
nbgp:
816
nbgp:
816
        add     esi, 3
817
        add     esi, 3
817
        add     edi, 3
818
        add     edi, 3
818
@@:
819
@@:
819
        cmp     byte [ScreenBPP], 25    ; 24 or 32 bpp?
820
        cmp     byte [ScreenBPP], 25    ; 24 or 32 bpp?
820
        sbb     edi, -1         ; +1 for 32 bpp
821
        sbb     edi, -1         ; +1 for 32 bpp
821
; I do not use 'inc eax' because this is slightly slower then 'add eax,1'
822
; I do not use 'inc eax' because this is slightly slower then 'add eax,1'
822
        add     ebp, edx
823
        add     ebp, edx
823
        add     eax, edx
824
        add     eax, edx
824
        cmp     eax, [draw_data+32+RECT.right]
825
        cmp     eax, [draw_data+32+RECT.right]
825
        ja      dp4
826
        ja      dp4
826
        sub     ecx, edx
827
        sub     ecx, edx
827
        jnz     dp3
828
        jnz     dp3
828
; next tile block on x-axis
829
; next tile block on x-axis
829
        mov     ecx, [BgrDataWidth]
830
        mov     ecx, [BgrDataWidth]
830
        sub     esi, ecx
831
        sub     esi, ecx
831
        sub     esi, ecx
832
        sub     esi, ecx
832
        sub     esi, ecx
833
        sub     esi, ecx
833
        jmp     dp3
834
        jmp     dp3
834
dp4:
835
dp4:
835
; next scan line
836
; next scan line
836
        inc     ebx
837
        inc     ebx
837
        cmp     ebx, [draw_data+32+RECT.bottom]
838
        cmp     ebx, [draw_data+32+RECT.bottom]
838
        jbe     dp2
839
        jbe     dp2
839
        popad
840
        popad
840
        mov     [EGA_counter], 1
841
        mov     [EGA_counter], 1
841
        call    VGA_drawbackground
842
        call    VGA_drawbackground
842
        ret
843
        ret
843
 
844
 
844
; ----------
845
; ----------
845
 
846
 
846
 
847
 
847
vesa20_drawbackground_stretch:
848
vesa20_drawbackground_stretch:
848
        call    [disable_mouse]
849
        call    [disable_mouse]
849
        pushad
850
        pushad
850
; Helper variables
851
; Helper variables
851
; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1)
852
; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1)
852
        mov     eax, [BgrDataWidth]
853
        mov     eax, [BgrDataWidth]
853
        dec     eax
854
        dec     eax
854
        xor     edx, edx
855
        xor     edx, edx
855
        div     dword [Screen_Max_X]
856
        div     dword [Screen_Max_X]
856
        push    eax     ; high
857
        push    eax     ; high
857
        xor     eax, eax
858
        xor     eax, eax
858
        div     dword [Screen_Max_X]
859
        div     dword [Screen_Max_X]
859
        push    eax     ; low
860
        push    eax     ; low
860
; the same for height
861
; the same for height
861
        mov     eax, [BgrDataHeight]
862
        mov     eax, [BgrDataHeight]
862
        dec     eax
863
        dec     eax
863
        xor     edx, edx
864
        xor     edx, edx
864
        div     dword [Screen_Max_Y]
865
        div     dword [Screen_Max_Y]
865
        push    eax     ; high
866
        push    eax     ; high
866
        xor     eax, eax
867
        xor     eax, eax
867
        div     dword [Screen_Max_Y]
868
        div     dword [Screen_Max_Y]
868
        push    eax     ; low
869
        push    eax     ; low
869
; External loop for all y from start to end
870
; External loop for all y from start to end
870
        mov     ebx, [draw_data+32+RECT.top]    ; y start
871
        mov     ebx, [draw_data+32+RECT.top]    ; y start
871
        mov     ebp, [draw_data+32+RECT.left]   ; x start
872
        mov     ebp, [draw_data+32+RECT.left]   ; x start
872
; 1) Calculate pointers in display_data (does pixel belong to OS thread?) [ebp]
873
; 1) Calculate pointers in display_data (does pixel belong to OS thread?) [ebp]
873
;                       and LFB data (output for our function) [edi]
874
;                       and LFB data (output for our function) [edi]
874
        mov     eax, [BytesPerScanLine]
875
        mov     eax, [BytesPerScanLine]
875
        mul     ebx
876
        mul     ebx
876
        xchg    ebp, eax
877
        xchg    ebp, eax
877
        add     ebp, eax
878
        add     ebp, eax
878
        add     ebp, eax
879
        add     ebp, eax
879
        add     ebp, eax
880
        add     ebp, eax
880
        cmp     byte [ScreenBPP], 24    ; 24 or 32 bpp ? - x size
881
        cmp     byte [ScreenBPP], 24    ; 24 or 32 bpp ? - x size
881
        jz      @f
882
        jz      @f
882
        add     ebp, eax
883
        add     ebp, eax
883
@@:
884
@@:
884
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
885
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
885
        call    calculate_edi
886
        call    calculate_edi
886
        xchg    edi, ebp
887
        xchg    edi, ebp
887
; Now eax=x, ebx=y, edi->output, ebp=offset in display_data
888
; Now eax=x, ebx=y, edi->output, ebp=offset in display_data
888
        push    ebx
889
        push    ebx
889
        push    eax
890
        push    eax
890
; 2) Calculate offset in background memory block
891
; 2) Calculate offset in background memory block
891
        mov     eax, ebx
892
        mov     eax, ebx
892
        imul    ebx, dword [esp+12]
893
        imul    ebx, dword [esp+12]
893
        mul     dword [esp+8]
894
        mul     dword [esp+8]
894
        add     edx, ebx        ; edx:eax = y * 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
895
        add     edx, ebx        ; edx:eax = y * 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
895
        mov     esi, edx
896
        mov     esi, edx
896
        imul    esi, [BgrDataWidth]
897
        imul    esi, [BgrDataWidth]
897
        push    edx
898
        push    edx
898
        push    eax
899
        push    eax
899
        mov     eax, [esp+8]
900
        mov     eax, [esp+8]
900
        mul     dword [esp+28]
901
        mul     dword [esp+28]
901
        push    eax
902
        push    eax
902
        mov     eax, [esp+12]
903
        mov     eax, [esp+12]
903
        mul     dword [esp+28]
904
        mul     dword [esp+28]
904
        add     [esp], edx
905
        add     [esp], edx
905
        pop     edx             ; edx:eax = x * 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
906
        pop     edx             ; edx:eax = x * 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
906
        add     esi, edx
907
        add     esi, edx
907
        lea     esi, [esi*3]
908
        lea     esi, [esi*3]
908
        add     esi, [img_background]
909
        add     esi, [img_background]
909
        push    eax
910
        push    eax
910
        push    edx
911
        push    edx
911
        push    esi
912
        push    esi
912
; 3) Smooth horizontal
913
; 3) Smooth horizontal
913
bgr_resmooth0:
914
bgr_resmooth0:
914
        mov     ecx, [esp+8]
915
        mov     ecx, [esp+8]
915
        mov     edx, [esp+4]
916
        mov     edx, [esp+4]
916
        mov     esi, [esp]
917
        mov     esi, [esp]
917
        push    edi
918
        push    edi
918
        mov     edi, bgr_cur_line
919
        mov     edi, bgr_cur_line
919
        call    smooth_line
920
        call    smooth_line
920
bgr_resmooth1:
921
bgr_resmooth1:
921
        mov     eax, [esp+16+4]
922
        mov     eax, [esp+16+4]
922
        inc     eax
923
        inc     eax
923
        cmp     eax, [BgrDataHeight]
924
        cmp     eax, [BgrDataHeight]
924
        jae     bgr.no2nd
925
        jae     bgr.no2nd
925
        mov     ecx, [esp+8+4]
926
        mov     ecx, [esp+8+4]
926
        mov     edx, [esp+4+4]
927
        mov     edx, [esp+4+4]
927
        mov     esi, [esp+4]
928
        mov     esi, [esp+4]
928
        add     esi, [BgrDataWidth]
929
        add     esi, [BgrDataWidth]
929
        add     esi, [BgrDataWidth]
930
        add     esi, [BgrDataWidth]
930
        add     esi, [BgrDataWidth]
931
        add     esi, [BgrDataWidth]
931
        mov     edi, bgr_next_line
932
        mov     edi, bgr_next_line
932
        call    smooth_line
933
        call    smooth_line
933
bgr.no2nd:
934
bgr.no2nd:
934
        pop     edi
935
        pop     edi
935
sdp3:
936
sdp3:
936
        xor     esi, esi
937
        xor     esi, esi
937
        mov     ecx, [esp+12]
938
        mov     ecx, [esp+12]
938
; 4) Loop through redraw rectangle and copy background data
939
; 4) Loop through redraw rectangle and copy background data
939
; Registers meaning:
940
; Registers meaning:
940
; esi = offset in current line, edi -> output
941
; esi = offset in current line, edi -> output
941
; ebp = offset in display_data
942
; ebp = offset in display_data
942
; dword [esp] = offset in bgr data
943
; dword [esp] = offset in bgr data
943
; qword [esp+4] = x * 2^32 * (BgrDataWidth-1) / (ScreenWidth-1)
944
; qword [esp+4] = x * 2^32 * (BgrDataWidth-1) / (ScreenWidth-1)
944
; qword [esp+12] = y * 2^32 * (BgrDataHeight-1) / (ScreenHeight-1)
945
; qword [esp+12] = y * 2^32 * (BgrDataHeight-1) / (ScreenHeight-1)
945
; dword [esp+20] = x
946
; dword [esp+20] = x
946
; dword [esp+24] = y
947
; dword [esp+24] = y
947
; precalculated constants:
948
; precalculated constants:
948
; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
949
; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
949
; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
950
; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
950
sdp3a:
951
sdp3a:
951
        mov eax, [_display_data]
952
        mov eax, [_display_data]
952
        cmp     [ebp+eax], byte 1
953
        cmp     [ebp+eax], byte 1
953
        jnz     snbgp
954
        jnz     snbgp
954
        mov     eax, [bgr_cur_line+esi]
955
        mov     eax, [bgr_cur_line+esi]
955
        test    ecx, ecx
956
        test    ecx, ecx
956
        jz      .novert
957
        jz      .novert
957
        mov     ebx, [bgr_next_line+esi]
958
        mov     ebx, [bgr_next_line+esi]
958
        call    [overlapping_of_points_ptr]
959
        call    [overlapping_of_points_ptr]
959
.novert:
960
.novert:
960
if SHADOWFB
961
if SHADOWFB
961
        mov     [SHADOWFB+edi], ax
962
        mov     [SHADOWFB+edi], ax
962
end if
963
end if
963
        mov     [LFB_BASE+edi], ax
964
        mov     [LFB_BASE+edi], ax
964
        shr     eax, 16
965
        shr     eax, 16
965
if SHADOWFB
966
if SHADOWFB
966
        mov     [SHADOWFB+edi+2], al
967
        mov     [SHADOWFB+edi+2], al
967
end if
968
end if
968
        mov     [LFB_BASE+edi+2], al
969
        mov     [LFB_BASE+edi+2], al
969
snbgp:
970
snbgp:
970
        cmp     byte [ScreenBPP], 25
971
        cmp     byte [ScreenBPP], 25
971
        sbb     edi, -4
972
        sbb     edi, -4
972
        add     ebp, 1
973
        add     ebp, 1
973
        mov     eax, [esp+20]
974
        mov     eax, [esp+20]
974
        add     eax, 1
975
        add     eax, 1
975
        mov     [esp+20], eax
976
        mov     [esp+20], eax
976
        add     esi, 4
977
        add     esi, 4
977
        cmp     eax, [draw_data+32+RECT.right]
978
        cmp     eax, [draw_data+32+RECT.right]
978
        jbe     sdp3a
979
        jbe     sdp3a
979
sdp4:
980
sdp4:
980
; next y
981
; next y
981
        mov     ebx, [esp+24]
982
        mov     ebx, [esp+24]
982
        add     ebx, 1
983
        add     ebx, 1
983
        mov     [esp+24], ebx
984
        mov     [esp+24], ebx
984
        cmp     ebx, [draw_data+32+RECT.bottom]
985
        cmp     ebx, [draw_data+32+RECT.bottom]
985
        ja      sdpdone
986
        ja      sdpdone
986
; advance edi, ebp to next scan line
987
; advance edi, ebp to next scan line
987
        sub     eax, [draw_data+32+RECT.left]
988
        sub     eax, [draw_data+32+RECT.left]
988
        sub     ebp, eax
989
        sub     ebp, eax
989
        add     ebp, [Screen_Max_X]
990
        add     ebp, [Screen_Max_X]
990
        add     ebp, 1
991
        add     ebp, 1
991
        sub     edi, eax
992
        sub     edi, eax
992
        sub     edi, eax
993
        sub     edi, eax
993
        sub     edi, eax
994
        sub     edi, eax
994
        cmp     byte [ScreenBPP], 24
995
        cmp     byte [ScreenBPP], 24
995
        jz      @f
996
        jz      @f
996
        sub     edi, eax
997
        sub     edi, eax
997
@@:
998
@@:
998
        add     edi, [BytesPerScanLine]
999
        add     edi, [BytesPerScanLine]
999
; restore ecx,edx; advance esi to next background line
1000
; restore ecx,edx; advance esi to next background line
1000
        mov     eax, [esp+28]
1001
        mov     eax, [esp+28]
1001
        mov     ebx, [esp+32]
1002
        mov     ebx, [esp+32]
1002
        add     [esp+12], eax
1003
        add     [esp+12], eax
1003
        mov     eax, [esp+16]
1004
        mov     eax, [esp+16]
1004
        adc     [esp+16], ebx
1005
        adc     [esp+16], ebx
1005
        sub     eax, [esp+16]
1006
        sub     eax, [esp+16]
1006
        mov     ebx, eax
1007
        mov     ebx, eax
1007
        lea     eax, [eax*3]
1008
        lea     eax, [eax*3]
1008
        imul    eax, [BgrDataWidth]
1009
        imul    eax, [BgrDataWidth]
1009
        sub     [esp], eax
1010
        sub     [esp], eax
1010
        mov     eax, [draw_data+32+RECT.left]
1011
        mov     eax, [draw_data+32+RECT.left]
1011
        mov     [esp+20], eax
1012
        mov     [esp+20], eax
1012
        test    ebx, ebx
1013
        test    ebx, ebx
1013
        jz      sdp3
1014
        jz      sdp3
1014
        cmp     ebx, -1
1015
        cmp     ebx, -1
1015
        jnz     bgr_resmooth0
1016
        jnz     bgr_resmooth0
1016
        push    edi
1017
        push    edi
1017
        mov     esi, bgr_next_line
1018
        mov     esi, bgr_next_line
1018
        mov     edi, bgr_cur_line
1019
        mov     edi, bgr_cur_line
1019
        mov     ecx, [Screen_Max_X]
1020
        mov     ecx, [Screen_Max_X]
1020
        inc     ecx
1021
        inc     ecx
1021
        rep     movsd
1022
        rep     movsd
1022
        jmp     bgr_resmooth1
1023
        jmp     bgr_resmooth1
1023
sdpdone:
1024
sdpdone:
1024
        add     esp, 44
1025
        add     esp, 44
1025
        popad
1026
        popad
1026
        mov     [EGA_counter],1
1027
        mov     [EGA_counter],1
1027
        call    VGA_drawbackground
1028
        call    VGA_drawbackground
1028
        ret
1029
        ret
1029
 
1030
 
1030
uglobal
1031
uglobal
1031
align 4
1032
align 4
1032
bgr_cur_line    rd      1280    ; maximum width of screen
1033
bgr_cur_line    rd      1280    ; maximum width of screen
1033
bgr_next_line   rd      1280
1034
bgr_next_line   rd      1280
1034
endg
1035
endg
1035
 
1036
 
1036
smooth_line:
1037
smooth_line:
1037
        mov     al, [esi+2]
1038
        mov     al, [esi+2]
1038
        shl     eax, 16
1039
        shl     eax, 16
1039
        mov     ax, [esi]
1040
        mov     ax, [esi]
1040
        test    ecx, ecx
1041
        test    ecx, ecx
1041
        jz      @f
1042
        jz      @f
1042
        mov     ebx, [esi+2]
1043
        mov     ebx, [esi+2]
1043
        shr     ebx, 8
1044
        shr     ebx, 8
1044
        call    [overlapping_of_points_ptr]
1045
        call    [overlapping_of_points_ptr]
1045
@@:
1046
@@:
1046
        stosd
1047
        stosd
1047
        mov     eax, [esp+20+8]
1048
        mov     eax, [esp+20+8]
1048
        add     eax, 1
1049
        add     eax, 1
1049
        mov     [esp+20+8], eax
1050
        mov     [esp+20+8], eax
1050
        cmp     eax, [draw_data+32+RECT.right]
1051
        cmp     eax, [draw_data+32+RECT.right]
1051
        ja      @f
1052
        ja      @f
1052
        add     ecx, [esp+36+8]
1053
        add     ecx, [esp+36+8]
1053
        mov     eax, edx
1054
        mov     eax, edx
1054
        adc     edx, [esp+40+8]
1055
        adc     edx, [esp+40+8]
1055
        sub     eax, edx
1056
        sub     eax, edx
1056
        lea     eax, [eax*3]
1057
        lea     eax, [eax*3]
1057
        sub     esi, eax
1058
        sub     esi, eax
1058
        jmp     smooth_line
1059
        jmp     smooth_line
1059
@@:
1060
@@:
1060
        mov     eax, [draw_data+32+RECT.left]
1061
        mov     eax, [draw_data+32+RECT.left]
1061
        mov     [esp+20+8], eax
1062
        mov     [esp+20+8], eax
1062
        ret
1063
        ret
1063
 
1064
 
1064
align 16
1065
align 16
1065
overlapping_of_points:
1066
overlapping_of_points:
1066
if 0
1067
if 0
1067
; this version of procedure works, but is slower than next version
1068
; this version of procedure works, but is slower than next version
1068
        push    ecx edx
1069
        push    ecx edx
1069
        mov     edx, eax
1070
        mov     edx, eax
1070
        push    esi
1071
        push    esi
1071
        shr     ecx, 24
1072
        shr     ecx, 24
1072
        mov     esi, ecx
1073
        mov     esi, ecx
1073
        mov     ecx, ebx
1074
        mov     ecx, ebx
1074
        movzx   ebx, dl
1075
        movzx   ebx, dl
1075
        movzx   eax, cl
1076
        movzx   eax, cl
1076
        sub     eax, ebx
1077
        sub     eax, ebx
1077
        movzx   ebx, dh
1078
        movzx   ebx, dh
1078
        imul    eax, esi
1079
        imul    eax, esi
1079
        add     dl, ah
1080
        add     dl, ah
1080
        movzx   eax, ch
1081
        movzx   eax, ch
1081
        sub     eax, ebx
1082
        sub     eax, ebx
1082
        imul    eax, esi
1083
        imul    eax, esi
1083
        add     dh, ah
1084
        add     dh, ah
1084
        ror     ecx, 16
1085
        ror     ecx, 16
1085
        ror     edx, 16
1086
        ror     edx, 16
1086
        movzx   eax, cl
1087
        movzx   eax, cl
1087
        movzx   ebx, dl
1088
        movzx   ebx, dl
1088
        sub     eax, ebx
1089
        sub     eax, ebx
1089
        imul    eax, esi
1090
        imul    eax, esi
1090
        pop     esi
1091
        pop     esi
1091
        add     dl, ah
1092
        add     dl, ah
1092
        mov     eax, edx
1093
        mov     eax, edx
1093
        pop     edx
1094
        pop     edx
1094
        ror     eax, 16
1095
        ror     eax, 16
1095
        pop     ecx
1096
        pop     ecx
1096
        ret
1097
        ret
1097
else
1098
else
1098
        push    ecx edx
1099
        push    ecx edx
1099
        mov     edx, eax
1100
        mov     edx, eax
1100
        push    esi
1101
        push    esi
1101
        shr     ecx, 26
1102
        shr     ecx, 26
1102
        mov     esi, ecx
1103
        mov     esi, ecx
1103
        mov     ecx, ebx
1104
        mov     ecx, ebx
1104
        shl     esi, 9
1105
        shl     esi, 9
1105
        movzx   ebx, dl
1106
        movzx   ebx, dl
1106
        movzx   eax, cl
1107
        movzx   eax, cl
1107
        sub     eax, ebx
1108
        sub     eax, ebx
1108
        movzx   ebx, dh
1109
        movzx   ebx, dh
1109
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
1110
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
1110
        movzx   eax, ch
1111
        movzx   eax, ch
1111
        sub     eax, ebx
1112
        sub     eax, ebx
1112
        add     dh, [BgrAuxTable+(eax+0x100)+esi]
1113
        add     dh, [BgrAuxTable+(eax+0x100)+esi]
1113
        ror     ecx, 16
1114
        ror     ecx, 16
1114
        ror     edx, 16
1115
        ror     edx, 16
1115
        movzx   eax, cl
1116
        movzx   eax, cl
1116
        movzx   ebx, dl
1117
        movzx   ebx, dl
1117
        sub     eax, ebx
1118
        sub     eax, ebx
1118
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
1119
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
1119
        pop     esi
1120
        pop     esi
1120
        mov     eax, edx
1121
        mov     eax, edx
1121
        pop     edx
1122
        pop     edx
1122
        ror     eax, 16
1123
        ror     eax, 16
1123
        pop     ecx
1124
        pop     ecx
1124
        ret
1125
        ret
1125
end if
1126
end if
1126
 
1127
 
1127
iglobal
1128
iglobal
1128
align 4
1129
align 4
1129
overlapping_of_points_ptr       dd      overlapping_of_points
1130
overlapping_of_points_ptr       dd      overlapping_of_points
1130
endg
1131
endg
1131
 
1132
 
1132
init_background:
1133
init_background:
1133
        mov     edi, BgrAuxTable
1134
        mov     edi, BgrAuxTable
1134
        xor     edx, edx
1135
        xor     edx, edx
1135
.loop2:
1136
.loop2:
1136
        mov     eax, edx
1137
        mov     eax, edx
1137
        shl     eax, 8
1138
        shl     eax, 8
1138
        neg     eax
1139
        neg     eax
1139
        mov     ecx, 0x200
1140
        mov     ecx, 0x200
1140
.loop1:
1141
.loop1:
1141
        mov     byte [edi], ah
1142
        mov     byte [edi], ah
1142
        inc     edi
1143
        inc     edi
1143
        add     eax, edx
1144
        add     eax, edx
1144
        loop    .loop1
1145
        loop    .loop1
1145
        add     dl, 4
1146
        add     dl, 4
1146
        jnz     .loop2
1147
        jnz     .loop2
1147
        test    byte [cpu_caps+(CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8)
1148
        test    byte [cpu_caps+(CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8)
1148
        jz      @f
1149
        jz      @f
1149
        mov     [overlapping_of_points_ptr], overlapping_of_points_mmx
1150
        mov     [overlapping_of_points_ptr], overlapping_of_points_mmx
1150
@@:
1151
@@:
1151
        ret
1152
        ret
1152
 
1153
 
1153
align 16
1154
align 16
1154
overlapping_of_points_mmx:
1155
overlapping_of_points_mmx:
1155
        movd    mm0, eax
1156
        movd    mm0, eax
1156
        movd    mm4, eax
1157
        movd    mm4, eax
1157
        movd    mm1, ebx
1158
        movd    mm1, ebx
1158
        pxor    mm2, mm2
1159
        pxor    mm2, mm2
1159
        punpcklbw mm0, mm2
1160
        punpcklbw mm0, mm2
1160
        punpcklbw mm1, mm2
1161
        punpcklbw mm1, mm2
1161
        psubw   mm1, mm0
1162
        psubw   mm1, mm0
1162
        movd    mm3, ecx
1163
        movd    mm3, ecx
1163
        psrld   mm3, 24
1164
        psrld   mm3, 24
1164
        packuswb mm3, mm3
1165
        packuswb mm3, mm3
1165
        packuswb mm3, mm3
1166
        packuswb mm3, mm3
1166
        pmullw  mm1, mm3
1167
        pmullw  mm1, mm3
1167
        psrlw   mm1, 8
1168
        psrlw   mm1, 8
1168
        packuswb mm1, mm2
1169
        packuswb mm1, mm2
1169
        paddb   mm4, mm1
1170
        paddb   mm4, mm1
1170
        movd    eax, mm4
1171
        movd    eax, mm4
1171
        ret
1172
        ret