Subversion Repositories Kolibri OS

Rev

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

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