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