Rev 9709 | Rev 9941 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9709 | Rev 9715 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2022. 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 | ;; VGA.INC ;; |
6 | ;; VGA.INC ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; 640x480 mode 0x12 VGA functions for MenuetOS ;; |
8 | ;; 640x480 mode 0x12 VGA functions for MenuetOS ;; |
9 | ;; ;; |
9 | ;; ;; |
10 | ;; Paul Butcher, paul.butcher@asa.co.uk ;; |
10 | ;; Paul Butcher, paul.butcher@asa.co.uk ;; |
11 | ;; ;; |
11 | ;; ;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
13 | 13 | ||
14 | $Revision: 9709 $ |
14 | $Revision: 9715 $ |
15 | 15 | ||
16 | ;------------------------------------------------------------------------------ |
16 | ;------------------------------------------------------------------------------ |
17 | align 4 |
17 | align 4 |
18 | paletteVGA: |
18 | paletteVGA: |
19 | 19 | ||
20 | ;16 colour palette |
20 | ;16 colour palette |
21 | mov dx, 0x3c8 |
21 | mov dx, 0x3c8 |
22 | mov al, 0 |
22 | mov al, 0 |
23 | out dx, al |
23 | out dx, al |
24 | 24 | ||
25 | mov ecx, 16 |
25 | mov ecx, 16 |
26 | mov dx, 0x3c9 |
26 | mov dx, 0x3c9 |
27 | xor eax, eax |
27 | xor eax, eax |
28 | ;-------------------------------------- |
28 | ;-------------------------------------- |
29 | align 4 |
29 | align 4 |
30 | palvganew: |
30 | palvganew: |
31 | mov al, 0 |
31 | mov al, 0 |
32 | test ah, 4 |
32 | test ah, 4 |
33 | jz palvgalbl1 |
33 | jz palvgalbl1 |
34 | add al, 31 |
34 | add al, 31 |
35 | test ah, 8 |
35 | test ah, 8 |
36 | jz palvgalbl1 |
36 | jz palvgalbl1 |
37 | add al, 32 |
37 | add al, 32 |
38 | ;-------------------------------------- |
38 | ;-------------------------------------- |
39 | align 4 |
39 | align 4 |
40 | palvgalbl1: |
40 | palvgalbl1: |
41 | out dx, al; red 0,31 or 63 |
41 | out dx, al; red 0,31 or 63 |
42 | mov al, 0 |
42 | mov al, 0 |
43 | test ah, 2 |
43 | test ah, 2 |
44 | jz palvgalbl2 |
44 | jz palvgalbl2 |
45 | add al, 31 |
45 | add al, 31 |
46 | test ah, 8 |
46 | test ah, 8 |
47 | jz palvgalbl2 |
47 | jz palvgalbl2 |
48 | add al, 32 |
48 | add al, 32 |
49 | ;-------------------------------------- |
49 | ;-------------------------------------- |
50 | align 4 |
50 | align 4 |
51 | palvgalbl2: |
51 | palvgalbl2: |
52 | out dx, al; blue 0,31 or 63 |
52 | out dx, al; blue 0,31 or 63 |
53 | mov al, 0 |
53 | mov al, 0 |
54 | test ah, 1 |
54 | test ah, 1 |
55 | jz palvgalbl3 |
55 | jz palvgalbl3 |
56 | add al, 31 |
56 | add al, 31 |
57 | test ah, 8 |
57 | test ah, 8 |
58 | jz palvgalbl3 |
58 | jz palvgalbl3 |
59 | add al, 32 |
59 | add al, 32 |
60 | ;-------------------------------------- |
60 | ;-------------------------------------- |
61 | align 4 |
61 | align 4 |
62 | palvgalbl3: |
62 | palvgalbl3: |
63 | out dx, al; green 0,31 or 63 |
63 | out dx, al; green 0,31 or 63 |
64 | add ah, 1 |
64 | add ah, 1 |
65 | loop palvganew |
65 | loop palvganew |
66 | ; mov dx, 3ceh |
66 | ; mov dx, 3ceh |
67 | ; mov ax, 0005h |
67 | ; mov ax, 0005h |
68 | ; out dx, ax |
68 | ; out dx, ax |
69 | ret |
69 | ret |
70 | ;------------------------------------------------------------------------------ |
70 | ;------------------------------------------------------------------------------ |
71 | align 4 |
71 | align 4 |
72 | palette320x200: |
72 | palette320x200: |
73 | mov edx, 0x3c8 |
73 | mov edx, 0x3c8 |
74 | xor eax, eax |
74 | xor eax, eax |
75 | out dx, al |
75 | out dx, al |
76 | mov ecx, 256 |
76 | mov ecx, 256 |
77 | mov edx, 0x3c9 |
77 | mov edx, 0x3c9 |
78 | xor eax, eax |
78 | xor eax, eax |
79 | ;-------------------------------------- |
79 | ;-------------------------------------- |
80 | align 4 |
80 | align 4 |
81 | palnew: |
81 | palnew: |
82 | mov al, 0 |
82 | mov al, 0 |
83 | test ah, 64 |
83 | test ah, 64 |
84 | jz pallbl1 |
84 | jz pallbl1 |
85 | add al, 21 |
85 | add al, 21 |
86 | ;-------------------------------------- |
86 | ;-------------------------------------- |
87 | align 4 |
87 | align 4 |
88 | pallbl1: |
88 | pallbl1: |
89 | test ah, 128 |
89 | test ah, 128 |
90 | jz pallbl2 |
90 | jz pallbl2 |
91 | add al, 42 |
91 | add al, 42 |
92 | ;-------------------------------------- |
92 | ;-------------------------------------- |
93 | align 4 |
93 | align 4 |
94 | pallbl2: |
94 | pallbl2: |
95 | out dx, al |
95 | out dx, al |
96 | mov al, 0 |
96 | mov al, 0 |
97 | test ah, 8 |
97 | test ah, 8 |
98 | jz pallbl3 |
98 | jz pallbl3 |
99 | add al, 8 |
99 | add al, 8 |
100 | ;-------------------------------------- |
100 | ;-------------------------------------- |
101 | align 4 |
101 | align 4 |
102 | pallbl3: |
102 | pallbl3: |
103 | test ah, 16 |
103 | test ah, 16 |
104 | jz pallbl4 |
104 | jz pallbl4 |
105 | add al, 15 |
105 | add al, 15 |
106 | ;-------------------------------------- |
106 | ;-------------------------------------- |
107 | align 4 |
107 | align 4 |
108 | pallbl4: |
108 | pallbl4: |
109 | test ah, 32 |
109 | test ah, 32 |
110 | jz pallbl5 |
110 | jz pallbl5 |
111 | add al, 40 |
111 | add al, 40 |
112 | ;-------------------------------------- |
112 | ;-------------------------------------- |
113 | align 4 |
113 | align 4 |
114 | pallbl5: |
114 | pallbl5: |
115 | out dx, al |
115 | out dx, al |
116 | mov al, 0 |
116 | mov al, 0 |
117 | test ah, 1 |
117 | test ah, 1 |
118 | jz pallbl6 |
118 | jz pallbl6 |
119 | add al, 8 |
119 | add al, 8 |
120 | ;-------------------------------------- |
120 | ;-------------------------------------- |
121 | align 4 |
121 | align 4 |
122 | pallbl6: |
122 | pallbl6: |
123 | test ah, 2 |
123 | test ah, 2 |
124 | jz pallbl7 |
124 | jz pallbl7 |
125 | add al, 15 |
125 | add al, 15 |
126 | ;-------------------------------------- |
126 | ;-------------------------------------- |
127 | align 4 |
127 | align 4 |
128 | pallbl7: |
128 | pallbl7: |
129 | test ah, 4 |
129 | test ah, 4 |
130 | jz pallbl8 |
130 | jz pallbl8 |
131 | add al, 40 |
131 | add al, 40 |
132 | ;-------------------------------------- |
132 | ;-------------------------------------- |
133 | align 4 |
133 | align 4 |
134 | pallbl8: |
134 | pallbl8: |
135 | out dx, al |
135 | out dx, al |
136 | add ah, 1 |
136 | add ah, 1 |
137 | loop palnew |
137 | loop palnew |
138 | ret |
138 | ret |
139 | ;------------------------------------------------------------------------------ |
139 | ;------------------------------------------------------------------------------ |
140 | align 4 |
140 | align 4 |
141 | uglobal |
141 | uglobal |
142 | novesachecksum dd 0x0 |
142 | novesachecksum dd 0x0 |
143 | EGA_counter db 0 |
143 | EGA_counter db 0 |
144 | VGA_drawing_screen db 0 |
144 | VGA_drawing_screen db 0 |
145 | VGA_8_pixels: |
145 | VGA_8_pixels: |
146 | rb 16 |
146 | rb 16 |
147 | temp: |
147 | temp: |
148 | .cx dd 0 |
148 | .cx dd 0 |
149 | endg |
149 | endg |
150 | ;------------------------------------------------------------------------------ |
150 | ;------------------------------------------------------------------------------ |
151 | align 4 |
151 | align 4 |
152 | checkVga_N13: |
152 | checkVga_N13: |
153 | cmp [SCR_MODE], 0x13 |
153 | cmp [SCR_MODE], 0x13 |
154 | jne @f |
154 | jne @f |
155 | 155 | ||
156 | pushad |
156 | pushad |
157 | cmp [EGA_counter], 1 |
157 | cmp [EGA_counter], 1 |
158 | je novesal |
158 | je novesal |
159 | mov ecx, [MOUSE_X] |
159 | mov ecx, [MOUSE_X] |
160 | cmp ecx, [novesachecksum] |
160 | cmp ecx, [novesachecksum] |
161 | jne novesal |
161 | jne novesal |
162 | popad |
162 | popad |
163 | ;-------------------------------------- |
163 | ;-------------------------------------- |
164 | align 4 |
164 | align 4 |
165 | @@: |
165 | @@: |
166 | ret |
166 | ret |
167 | ;-------------------------------------- |
167 | ;-------------------------------------- |
168 | align 4 |
168 | align 4 |
169 | novesal: |
169 | novesal: |
170 | mov [novesachecksum], ecx |
170 | mov [novesachecksum], ecx |
171 | xor ecx, ecx ;mov ecx, 0 |
171 | xor ecx, ecx ;mov ecx, 0 |
172 | movzx eax, word [MOUSE_Y] |
172 | movzx eax, word [MOUSE_Y] |
173 | cmp eax, 100 |
173 | cmp eax, 100 |
174 | jge m13l3 |
174 | jge m13l3 |
175 | mov eax, 100 |
175 | mov eax, 100 |
176 | ;-------------------------------------- |
176 | ;-------------------------------------- |
177 | align 4 |
177 | align 4 |
178 | m13l3: |
178 | m13l3: |
179 | cmp eax, 480-100 |
179 | cmp eax, 480-100 |
180 | jbe m13l4 |
180 | jbe m13l4 |
181 | mov eax, 480-100 |
181 | mov eax, 480-100 |
182 | ;-------------------------------------- |
182 | ;-------------------------------------- |
183 | align 4 |
183 | align 4 |
184 | m13l4: |
184 | m13l4: |
185 | sub eax, 100 |
185 | sub eax, 100 |
186 | imul eax, 640*4 |
186 | imul eax, 640*4 |
187 | add ecx, eax |
187 | add ecx, eax |
188 | movzx eax, word [MOUSE_X] |
188 | movzx eax, word [MOUSE_X] |
189 | cmp eax, 160 |
189 | cmp eax, 160 |
190 | jge m13l1 |
190 | jge m13l1 |
191 | mov eax, 160 |
191 | mov eax, 160 |
192 | ;-------------------------------------- |
192 | ;-------------------------------------- |
193 | align 4 |
193 | align 4 |
194 | m13l1: |
194 | m13l1: |
195 | cmp eax, 640-160 |
195 | cmp eax, 640-160 |
196 | jbe m13l2 |
196 | jbe m13l2 |
197 | mov eax, 640-160 |
197 | mov eax, 640-160 |
198 | ;-------------------------------------- |
198 | ;-------------------------------------- |
199 | align 4 |
199 | align 4 |
200 | m13l2: |
200 | m13l2: |
201 | sub eax, 160 |
201 | sub eax, 160 |
202 | shl eax, 2 |
202 | shl eax, 2 |
203 | add ecx, eax |
203 | add ecx, eax |
204 | mov esi, [LFBAddress] |
204 | mov esi, [LFBAddress] |
205 | add esi, ecx |
205 | add esi, ecx |
206 | mov edi, VGABasePtr |
206 | mov edi, VGABasePtr |
207 | mov edx, 200 |
207 | mov edx, 200 |
208 | mov ecx, 320 |
208 | mov ecx, 320 |
209 | cld |
209 | cld |
210 | ;-------------------------------------- |
210 | ;-------------------------------------- |
211 | align 4 |
211 | align 4 |
212 | m13pix: |
212 | m13pix: |
213 | lodsd |
213 | lodsd |
214 | test eax, eax |
214 | test eax, eax |
215 | jz .save_pixel |
215 | jz .save_pixel |
216 | push eax |
216 | push eax |
217 | mov ebx, eax |
217 | mov ebx, eax |
218 | and eax, (128+64+32) ; blue |
218 | and eax, (128+64+32) ; blue |
219 | shr eax, 5 |
219 | shr eax, 5 |
220 | and ebx, (128+64+32)*256; green |
220 | and ebx, (128+64+32)*256; green |
221 | shr ebx, 8+2 |
221 | shr ebx, 8+2 |
222 | add eax, ebx |
222 | add eax, ebx |
223 | pop ebx |
223 | pop ebx |
224 | and ebx, (128+64)*256*256; red |
224 | and ebx, (128+64)*256*256; red |
225 | shr ebx, 8+8 |
225 | shr ebx, 8+8 |
226 | add eax, ebx |
226 | add eax, ebx |
227 | ;-------------------------------------- |
227 | ;-------------------------------------- |
228 | align 4 |
228 | align 4 |
229 | .save_pixel: |
229 | .save_pixel: |
230 | stosb |
230 | stosb |
231 | loop m13pix |
231 | loop m13pix |
232 | mov ecx, 320 |
232 | mov ecx, 320 |
233 | add esi, 4*(640-320) |
233 | add esi, 4*(640-320) |
234 | dec edx |
234 | dec edx |
235 | jnz m13pix |
235 | jnz m13pix |
236 | mov [EGA_counter], 0 |
236 | mov [EGA_counter], 0 |
237 | popad |
237 | popad |
238 | ret |
238 | ret |
239 | ;------------------------------------------------------------------------------ |
239 | ;------------------------------------------------------------------------------ |
240 | align 4 |
240 | align 4 |
241 | VGA_drawbackground: |
241 | VGA_drawbackground: |
242 | ; draw all |
242 | ; draw all |
243 | pushad |
243 | pushad |
244 | mov esi, [LFBAddress] |
244 | mov esi, [LFBAddress] |
245 | mov edi, VGABasePtr |
245 | mov edi, VGABasePtr |
246 | mov ebx, 640/32; 640*480/(8*4) |
246 | mov ebx, 640/32; 640*480/(8*4) |
247 | mov edx, 480 |
247 | mov edx, 480 |
248 | ;-------------------------------------- |
248 | ;-------------------------------------- |
249 | align 4 |
249 | align 4 |
250 | @@: |
250 | @@: |
251 | push ebx edx esi edi |
251 | push ebx edx esi edi |
252 | shl edx, 9 |
252 | shl edx, 9 |
253 | lea edx, [edx+edx*4] |
253 | lea edx, [edx + edx*4] |
254 | add esi, edx |
254 | add esi, edx |
255 | shr edx, 5 |
255 | shr edx, 5 |
256 | add edi, edx |
256 | add edi, edx |
257 | call VGA_draw_long_line |
257 | call VGA_draw_long_line |
258 | pop edi esi edx ebx |
258 | pop edi esi edx ebx |
259 | dec edx |
259 | dec edx |
260 | jnz @r |
260 | jnz @r |
261 | call VGA_draw_long_line_1 |
261 | call VGA_draw_long_line_1 |
262 | popad |
262 | popad |
263 | ret |
263 | ret |
264 | ;------------------------------------------------------------------------------ |
264 | ;------------------------------------------------------------------------------ |
265 | align 4 |
265 | align 4 |
266 | VGA_draw_long_line: |
266 | VGA_draw_long_line: |
267 | mov dx, 3ceh |
267 | mov dx, 3ceh |
268 | mov ax, 0ff08h |
268 | mov ax, 0ff08h |
269 | cli |
269 | cli |
270 | out dx, ax |
270 | out dx, ax |
271 | mov ax, 0005h |
271 | mov ax, 0005h |
272 | out dx, ax |
272 | out dx, ax |
273 | ;-------------------------------------- |
273 | ;-------------------------------------- |
274 | align 4 |
274 | align 4 |
275 | m12pix: |
275 | m12pix: |
276 | call VGA_draw_32_pixels |
276 | call VGA_draw_32_pixels |
277 | dec ebx |
277 | dec ebx |
278 | jnz m12pix |
278 | jnz m12pix |
279 | mov dx, 3c4h |
279 | mov dx, 3c4h |
280 | mov ax, 0ff02h |
280 | mov ax, 0ff02h |
281 | out dx, ax |
281 | out dx, ax |
282 | mov dx, 3ceh |
282 | mov dx, 3ceh |
283 | mov ax, 0205h |
283 | mov ax, 0205h |
284 | out dx, ax |
284 | out dx, ax |
285 | mov dx, 3ceh |
285 | mov dx, 3ceh |
286 | mov al, 08h |
286 | mov al, 08h |
287 | out dx, al |
287 | out dx, al |
288 | sti |
288 | sti |
289 | ret |
289 | ret |
290 | ;------------------------------------------------------------------------------ |
290 | ;------------------------------------------------------------------------------ |
291 | align 4 |
291 | align 4 |
292 | VGA_draw_32_pixels: |
292 | VGA_draw_32_pixels: |
293 | xor eax, eax |
293 | xor eax, eax |
294 | mov ebp, VGA_8_pixels |
294 | mov ebp, VGA_8_pixels |
295 | mov [ebp], eax |
295 | mov [ebp], eax |
296 | mov [ebp+4], eax |
296 | mov [ebp+4], eax |
297 | mov [ebp+8], eax |
297 | mov [ebp+8], eax |
298 | mov [ebp+12], eax |
298 | mov [ebp+12], eax |
299 | mov ch, 4 |
299 | mov ch, 4 |
300 | ;-------------------------------------- |
300 | ;-------------------------------------- |
301 | align 4 |
301 | align 4 |
302 | .main_loop: |
302 | .main_loop: |
303 | mov cl, 8 |
303 | mov cl, 8 |
304 | ;-------------------------------------- |
304 | ;-------------------------------------- |
305 | align 4 |
305 | align 4 |
306 | .convert_pixels_to_VGA: |
306 | .convert_pixels_to_VGA: |
307 | lodsd ; eax = 24bit colour |
307 | lodsd ; eax = 24bit colour |
308 | test eax, eax |
308 | test eax, eax |
309 | jz .end |
309 | jz .end |
310 | rol eax, 8 |
310 | rol eax, 8 |
311 | mov al, ch |
311 | mov al, ch |
312 | ror eax, 8 |
312 | ror eax, 8 |
313 | mov ch, 1 |
313 | mov ch, 1 |
314 | dec cl |
314 | dec cl |
315 | shl ch, cl |
315 | shl ch, cl |
316 | cmp al, 85 |
316 | cmp al, 85 |
317 | jbe .p13green |
317 | jbe .p13green |
318 | or [ebp], ch |
318 | or [ebp], ch |
319 | cmp al, 170 |
319 | cmp al, 170 |
320 | jbe .p13green |
320 | jbe .p13green |
321 | or [ebp+12], ch |
321 | or [ebp+12], ch |
322 | ;-------------------------------------- |
322 | ;-------------------------------------- |
323 | align 4 |
323 | align 4 |
324 | .p13green: |
324 | .p13green: |
325 | cmp ah, 85 |
325 | cmp ah, 85 |
326 | jbe .p13red |
326 | jbe .p13red |
327 | or [ebp+4], ch |
327 | or [ebp+4], ch |
328 | cmp ah, 170 |
328 | cmp ah, 170 |
329 | jbe .p13red |
329 | jbe .p13red |
330 | or [ebp+12], ch |
330 | or [ebp+12], ch |
331 | ;-------------------------------------- |
331 | ;-------------------------------------- |
332 | align 4 |
332 | align 4 |
333 | .p13red: |
333 | .p13red: |
334 | shr eax, 8 |
334 | shr eax, 8 |
335 | cmp ah, 85 |
335 | cmp ah, 85 |
336 | jbe .p13cont |
336 | jbe .p13cont |
337 | or [ebp+8], ch |
337 | or [ebp+8], ch |
338 | cmp ah, 170 |
338 | cmp ah, 170 |
339 | jbe .p13cont |
339 | jbe .p13cont |
340 | or [ebp+12], ch |
340 | or [ebp+12], ch |
341 | ;-------------------------------------- |
341 | ;-------------------------------------- |
342 | align 4 |
342 | align 4 |
343 | .p13cont: |
343 | .p13cont: |
344 | ror eax, 8 |
344 | ror eax, 8 |
345 | mov ch, ah |
345 | mov ch, ah |
346 | inc cl |
346 | inc cl |
347 | ;-------------------------------------- |
347 | ;-------------------------------------- |
348 | align 4 |
348 | align 4 |
349 | .end: |
349 | .end: |
350 | dec cl |
350 | dec cl |
351 | jnz .convert_pixels_to_VGA |
351 | jnz .convert_pixels_to_VGA |
352 | inc ebp |
352 | inc ebp |
353 | dec ch |
353 | dec ch |
354 | jnz .main_loop |
354 | jnz .main_loop |
355 | push esi |
355 | push esi |
356 | sub ebp, 4 |
356 | sub ebp, 4 |
357 | mov esi, ebp |
357 | mov esi, ebp |
358 | mov dx, 3c4h |
358 | mov dx, 3c4h |
359 | mov ah, 1h |
359 | mov ah, 1h |
360 | ;-------------------------------------- |
360 | ;-------------------------------------- |
361 | align 4 |
361 | align 4 |
362 | @@: |
362 | @@: |
363 | mov al, 02h |
363 | mov al, 02h |
364 | out dx, ax |
364 | out dx, ax |
365 | xchg ax, bp |
365 | xchg ax, bp |
366 | lodsd |
366 | lodsd |
367 | mov [edi], eax |
367 | mov [edi], eax |
368 | xchg ax, bp |
368 | xchg ax, bp |
369 | shl ah, 1 |
369 | shl ah, 1 |
370 | cmp ah, 10h |
370 | cmp ah, 10h |
371 | jnz @r |
371 | jnz @r |
372 | add edi, 4 |
372 | add edi, 4 |
373 | pop esi |
373 | pop esi |
374 | ret |
374 | ret |
375 | ;------------------------------------------------------------------------------ |
375 | ;------------------------------------------------------------------------------ |
376 | align 4 |
376 | align 4 |
377 | VGA_putpixel: |
377 | VGA_putpixel: |
378 | ; eax = x |
378 | ; eax = x |
379 | ; ebx = y |
379 | ; ebx = y |
380 | mov ecx, eax |
380 | mov ecx, eax |
381 | mov eax, [esp+32-8+4] ; color |
381 | mov eax, [esp + 32-8+4] ; color |
382 | ;-------------------------------------- |
382 | ;-------------------------------------- |
383 | ; check for hardware cursor |
383 | ; check for hardware cursor |
384 | cmp [_display.select_cursor], select_cursor |
384 | cmp [_display.select_cursor], select_cursor |
385 | je @f |
385 | je @f |
386 | cmp [_display.select_cursor], 0 |
386 | cmp [_display.select_cursor], 0 |
387 | jne .no_mouseunder |
387 | jne .no_mouseunder |
388 | ;-------------------------------------- |
388 | ;-------------------------------------- |
389 | align 4 |
389 | align 4 |
390 | @@: |
390 | @@: |
391 | push ecx |
391 | push ecx |
392 | shl ecx, 16 |
392 | shl ecx, 16 |
393 | mov cx, bx |
393 | mov cx, bx |
394 | ; check mouse area for putpixel |
394 | ; check mouse area for putpixel |
395 | test eax, 0x04000000 |
395 | test eax, 0x04000000 |
396 | jnz @f |
396 | jnz @f |
397 | call [_display.check_mouse] |
397 | call [_display.check_mouse] |
398 | ;-------------------------------------- |
398 | ;-------------------------------------- |
399 | align 4 |
399 | align 4 |
400 | @@: |
400 | @@: |
401 | pop ecx |
401 | pop ecx |
402 | ;-------------------------------------- |
402 | ;-------------------------------------- |
403 | align 4 |
403 | align 4 |
404 | .no_mouseunder: |
404 | .no_mouseunder: |
405 | shl ebx, 9 |
405 | shl ebx, 9 |
406 | lea ebx, [ebx+ebx*4] ; multiply by 5 |
406 | lea ebx, [ebx + ebx*4] ; multiply by 5 |
407 | lea edx, [ebx+ecx*4] ; + x*BytesPerPixel (Vesa2.0 32) |
407 | lea edx, [ebx + ecx*4] ; + x*BytesPerPixel (Vesa2.0 32) |
408 | mov edi, edx |
408 | mov edi, edx |
409 | add edi, [LFBAddress] ; + LFB address |
409 | add edi, [LFBAddress] ; + LFB address |
410 | mov [edi], eax ; write to LFB for Vesa2.0 |
410 | mov [edi], eax ; write to LFB for Vesa2.0 |
411 | shr edx, 5 ; change BytesPerPixel to 1/8 |
411 | shr edx, 5 ; change BytesPerPixel to 1/8 |
412 | mov edi, edx |
412 | mov edi, edx |
413 | add edi, VGABasePtr ; address of pixel in VGA area |
413 | add edi, VGABasePtr ; address of pixel in VGA area |
414 | and ecx, 0x07 ; bit no. (modulo 8) |
414 | and ecx, 0x07 ; bit no. (modulo 8) |
415 | pushfd |
415 | pushfd |
416 | ; edi = address, eax = 24bit colour, ecx = bit no. (modulo 8) |
416 | ; edi = address, eax = 24bit colour, ecx = bit no. (modulo 8) |
417 | xor edx, edx |
417 | xor edx, edx |
418 | test eax, eax |
418 | test eax, eax |
419 | jz .p13cont |
419 | jz .p13cont |
420 | cmp al, 85 |
420 | cmp al, 85 |
421 | jbe .p13green |
421 | jbe .p13green |
422 | or dl, 0x01 |
422 | or dl, 0x01 |
423 | cmp al, 170 |
423 | cmp al, 170 |
424 | jbe .p13green |
424 | jbe .p13green |
425 | or dl, 0x08 |
425 | or dl, 0x08 |
426 | ;-------------------------------------- |
426 | ;-------------------------------------- |
427 | align 4 |
427 | align 4 |
428 | .p13green: |
428 | .p13green: |
429 | cmp ah, 85 |
429 | cmp ah, 85 |
430 | jbe .p13red |
430 | jbe .p13red |
431 | or dl, 0x02 |
431 | or dl, 0x02 |
432 | cmp ah, 170 |
432 | cmp ah, 170 |
433 | jbe .p13red |
433 | jbe .p13red |
434 | or dl, 0x08 |
434 | or dl, 0x08 |
435 | ;-------------------------------------- |
435 | ;-------------------------------------- |
436 | align 4 |
436 | align 4 |
437 | .p13red: |
437 | .p13red: |
438 | shr eax, 8 |
438 | shr eax, 8 |
439 | cmp ah, 85 |
439 | cmp ah, 85 |
440 | jbe .p13cont |
440 | jbe .p13cont |
441 | or dl, 0x04 |
441 | or dl, 0x04 |
442 | cmp ah, 170 |
442 | cmp ah, 170 |
443 | jbe .p13cont |
443 | jbe .p13cont |
444 | or dl, 0x08 |
444 | or dl, 0x08 |
445 | ;-------------------------------------- |
445 | ;-------------------------------------- |
446 | align 4 |
446 | align 4 |
447 | .p13cont: |
447 | .p13cont: |
448 | ror edx, 8 |
448 | ror edx, 8 |
449 | inc cl |
449 | inc cl |
450 | xor eax, eax |
450 | xor eax, eax |
451 | inc ah |
451 | inc ah |
452 | shr ax, cl |
452 | shr ax, cl |
453 | mov dx, 3cfh |
453 | mov dx, 3cfh |
454 | cli |
454 | cli |
455 | out dx, al |
455 | out dx, al |
456 | mov al, [edi] ; dummy read |
456 | mov al, [edi] ; dummy read |
457 | rol edx, 8 |
457 | rol edx, 8 |
458 | mov [edi], dl |
458 | mov [edi], dl |
459 | popfd |
459 | popfd |
460 | ret |
460 | ret |
461 | ;------------------------------------------------------------------------------ |
461 | ;------------------------------------------------------------------------------ |
462 | align 4 |
462 | align 4 |
463 | VGA__putimage: |
463 | VGA__putimage: |
464 | ; ecx = size [x|y] |
464 | ; ecx = size [x|y] |
465 | ; edx = coordinates [x|y] |
465 | ; edx = coordinates [x|y] |
466 | pushad |
466 | pushad |
467 | rol edx, 16 |
467 | rol edx, 16 |
468 | movzx eax, dx |
468 | movzx eax, dx |
469 | rol edx, 16 |
469 | rol edx, 16 |
470 | movzx ebx, dx |
470 | movzx ebx, dx |
471 | movzx edx, cx |
471 | movzx edx, cx |
472 | rol ecx, 16 |
472 | rol ecx, 16 |
473 | movzx ecx, cx |
473 | movzx ecx, cx |
474 | call VGA_draw_bar_1 |
474 | call VGA_draw_bar_1 |
475 | popad |
475 | popad |
476 | ret |
476 | ret |
477 | ;------------------------------------------------------------------------------ |
477 | ;------------------------------------------------------------------------------ |
478 | align 4 |
478 | align 4 |
479 | VGA_draw_bar: |
479 | VGA_draw_bar: |
480 | ; eax cx |
480 | ; eax cx |
481 | ; ebx cy |
481 | ; ebx cy |
482 | ; ecx xe |
482 | ; ecx xe |
483 | ; edx ye |
483 | ; edx ye |
484 | pushad |
484 | pushad |
485 | sub ecx, eax |
485 | sub ecx, eax |
486 | sub edx, ebx |
486 | sub edx, ebx |
487 | and eax, 0xffff |
487 | and eax, 0xffff |
488 | and ebx, 0xffff |
488 | and ebx, 0xffff |
489 | and ecx, 0xffff |
489 | and ecx, 0xffff |
490 | and edx, 0xffff |
490 | and edx, 0xffff |
491 | call VGA_draw_bar_1 |
491 | call VGA_draw_bar_1 |
492 | popad |
492 | popad |
493 | ret |
493 | ret |
494 | ;------------------------------------------------------------------------------ |
494 | ;------------------------------------------------------------------------------ |
495 | align 4 |
495 | align 4 |
496 | VGA_draw_bar_1: |
496 | VGA_draw_bar_1: |
497 | mov [temp.cx], eax |
497 | mov [temp.cx], eax |
498 | mov eax, [current_slot_idx] |
498 | mov eax, [current_slot_idx] |
499 | shl eax, 5 |
499 | shl eax, BSF sizeof.WDATA |
500 | add ebx, [eax+window_data+WDATA.box.top] |
500 | add ebx, [window_data + eax + WDATA.box.top] |
501 | mov eax, [eax+window_data+WDATA.box.left] |
501 | mov eax, [window_data + eax + WDATA.box.left] |
502 | add eax, [temp.cx] |
502 | add eax, [temp.cx] |
503 | and eax, 0xfff8 |
503 | and eax, 0xfff8 |
504 | shl ebx, 9 |
504 | shl ebx, 9 |
505 | lea ebx, [ebx+ebx*4] ; multiply by 5 |
505 | lea ebx, [ebx + ebx*4] ; multiply by 5 |
506 | lea ebx, [ebx+eax*4] ; + x*BytesPerPixel (Vesa2.0 32) |
506 | lea ebx, [ebx + eax*4] ; + x*BytesPerPixel (Vesa2.0 32) |
507 | mov esi, ebx |
507 | mov esi, ebx |
508 | add esi, [LFBAddress] ; + LFB address |
508 | add esi, [LFBAddress] ; + LFB address |
509 | shr ebx, 5 ; change BytesPerPixel to 1/8 |
509 | shr ebx, 5 ; change BytesPerPixel to 1/8 |
510 | mov edi, ebx |
510 | mov edi, ebx |
511 | add edi, VGABasePtr ; address of pixel in VGA area |
511 | add edi, VGABasePtr ; address of pixel in VGA area |
512 | mov ebx, ecx |
512 | mov ebx, ecx |
513 | shr ebx, 5 |
513 | shr ebx, 5 |
514 | inc ebx |
514 | inc ebx |
515 | ;-------------------------------------- |
515 | ;-------------------------------------- |
516 | align 4 |
516 | align 4 |
517 | .main_loop: |
517 | .main_loop: |
518 | call VGA_draw_long_line_1 |
518 | call VGA_draw_long_line_1 |
519 | dec edx |
519 | dec edx |
520 | jnz .main_loop |
520 | jnz .main_loop |
521 | call VGA_draw_long_line_1 |
521 | call VGA_draw_long_line_1 |
522 | ret |
522 | ret |
523 | ;------------------------------------------------------------------------------ |
523 | ;------------------------------------------------------------------------------ |
524 | align 4 |
524 | align 4 |
525 | VGA_draw_long_line_1: |
525 | VGA_draw_long_line_1: |
526 | push ebx edx esi edi |
526 | push ebx edx esi edi |
527 | shl edx, 9 |
527 | shl edx, 9 |
528 | lea edx, [edx+edx*4] |
528 | lea edx, [edx + edx*4] |
529 | add esi, edx |
529 | add esi, edx |
530 | shr edx, 5 |
530 | shr edx, 5 |
531 | add edi, edx |
531 | add edi, edx |
532 | call VGA_draw_long_line |
532 | call VGA_draw_long_line |
533 | pop edi esi edx ebx |
533 | pop edi esi edx ebx |
534 | ret |
534 | ret |
535 | ;------------------------------------------------------------------------------ |
535 | ;------------------------------------------------------------------------------ |