Rev 82 | Rev 115 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ha | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; VGA.INC ;; |
||
4 | ;; ;; |
||
5 | ;; 640x480 mode 0x12 VGA functions for MenuetOS ;; |
||
6 | ;; ;; |
||
7 | ;; Paul Butcher, paul.butcher@asa.co.uk ;; |
||
8 | ;; ;; |
||
9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
10 | |||
11 | |||
12 | |||
13 | paletteVGA: |
||
14 | |||
15 | ;16 colour palette |
||
16 | mov dx,0x3c8 |
||
17 | mov al,0 |
||
18 | out dx,al |
||
19 | |||
20 | mov ecx,16 |
||
21 | mov dx,0x3c9 |
||
22 | xor eax,eax |
||
23 | |||
24 | palvganew: |
||
25 | |||
26 | mov al,0 |
||
27 | test ah,4 |
||
28 | jz palvgalbl1 |
||
29 | add al,31 |
||
30 | test ah,8 |
||
31 | jz palvgalbl1 |
||
32 | add al,32 |
||
33 | palvgalbl1: |
||
34 | out dx,al ; red 0,31 or 63 |
||
35 | mov al,0 |
||
36 | test ah,2 |
||
37 | jz palvgalbl2 |
||
38 | add al,31 |
||
39 | test ah,8 |
||
40 | jz palvgalbl2 |
||
41 | add al,32 |
||
42 | palvgalbl2: |
||
43 | out dx,al ; blue 0,31 or 63 |
||
44 | mov al,0 |
||
45 | test ah,1 |
||
46 | jz palvgalbl3 |
||
47 | add al,31 |
||
48 | test ah,8 |
||
49 | jz palvgalbl3 |
||
50 | add al,32 |
||
51 | palvgalbl3: |
||
52 | out dx,al ; green 0,31 or 63 |
||
53 | add ah,1 |
||
54 | loop palvganew |
||
55 | |||
56 | ret |
||
57 | |||
58 | |||
59 | vga_putimage: |
||
33 | mario79 | 60 | ; pushad |
61 | call [disable_mouse] |
||
1 | ha | 62 | push ebp ; |
63 | push esi ; |
||
64 | push edi ; |
||
65 | |||
66 | push eax ; |
||
67 | push ebx ; +8 [ptrImage] |
||
68 | push ecx ; +4 [BH] |
||
69 | push edx ; +0 [xy] |
||
70 | |||
71 | movzx eax,word [esp+2] ; eax:=x |
||
72 | movzx ebx,word [esp+0] ; ebx:=y |
||
73 | mov ecx,[0x3010] ; |
||
74 | add eax,[ecx-twdw] ; eax+=Xwin |
||
75 | add ebx,[ecx-twdw+4] ; ebx+=Ywin |
||
76 | mov ecx,ebx ; ecx = y+Ywin |
||
77 | mov edx,eax ; edx = x+Xwin |
||
78 | |||
79 | imul ebx, 640*4 ; (y+Ywin)*BytesPerScanLine |
||
80 | shl eax,2 ; (x+Xwin)*BytesPerPixel |
||
81 | add eax,ebx ; |
||
82 | mov edi,eax ; store copy |
||
83 | add eax,[0xfe80] ; +AddrLFB |
||
84 | ;entry point in LFB >> EAX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrLFB |
||
85 | |||
86 | shr edi,5 ; change from 4 to 1/8 BytesPerPixel |
||
87 | add edi,0xa0000 ; + VGABasePtr |
||
88 | ;VGA start address >> EDI:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrVGA |
||
89 | |||
90 | mov ebx, [0xfe00] ; ScreenXSize |
||
91 | inc ebx ; +1 |
||
92 | imul ebx,ecx ; *(y+Ywin) |
||
93 | mov ebp, ebx ; |
||
94 | add ebp, edx ; +(x+Xwin) |
||
95 | add ebp, WinMapAddress ; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer |
||
96 | |||
97 | mov esi,[esp+8] ; esi:=AddrImg |
||
98 | movzx ecx,word [esp+6] ; ecx:=B |
||
99 | movzx ebx,word [esp+4] ; ebx:=H |
||
100 | |||
101 | ; check limits while draw ? |
||
102 | |||
103 | push ecx ; B |
||
104 | push eax ; LFB address |
||
105 | |||
106 | mov eax,[0x3010] |
||
107 | mov ecx,[eax+draw_data-0x3000+0] |
||
108 | cmp ecx,0 |
||
109 | jnz dbcblimitlset_vga |
||
110 | |||
111 | mov ecx,[eax+draw_data-0x3000+4] |
||
112 | cmp ecx,0 |
||
113 | jnz dbcblimitlset_vga |
||
114 | |||
115 | mov ecx,[eax+draw_data-0x3000+8] |
||
116 | cmp ecx,[0xfe00] ; ecx <> Screen X size |
||
117 | jnz dbcblimitlset_vga |
||
118 | |||
119 | mov ecx,[eax+draw_data-0x3000+12] |
||
120 | cmp ecx,[0xfe04] ; ecx <> Screen Y size |
||
121 | jnz dbcblimitlset_vga |
||
122 | |||
123 | pop eax ; LFB address |
||
124 | pop ecx ; B |
||
125 | |||
126 | push dword 0 |
||
127 | |||
128 | jmp pimvga |
||
129 | |||
130 | dbcblimitlset_vga: |
||
131 | |||
132 | pop eax ; LFB address |
||
133 | pop ecx ; B |
||
134 | |||
135 | push dword 1 |
||
136 | |||
137 | pimvga: |
||
138 | push edi |
||
139 | push esi |
||
140 | push eax ; LFB address |
||
141 | push ecx ; B |
||
142 | push ebx ; H |
||
143 | push edx ; x+Xwin |
||
144 | |||
102 | poddubny | 145 | mov ebx,[0x3000] |
1 | ha | 146 | mov bh,[esp+6*4] |
147 | |||
148 | cld |
||
149 | |||
150 | npvga: |
||
151 | |||
152 | cmp bl,[ds:ebp] |
||
153 | jnz impvgano |
||
154 | |||
155 | ; cmp bh,0 |
||
156 | ; jz impvgayes |
||
157 | |||
158 | ; call voodoodbcplimit |
||
159 | ; jnz impvgano |
||
160 | |||
161 | ; impvgayes: |
||
162 | |||
163 | push eax ; LFB address |
||
164 | push ebx ; app no. |
||
165 | push ecx ; B |
||
166 | push edx ; x+Xwin |
||
167 | |||
168 | mov edx,[esi] ; color |
||
169 | mov [eax],dx |
||
170 | shr edx,16 |
||
171 | mov [eax+2],dl |
||
172 | |||
173 | mov eax,[esi] ; color |
||
174 | mov ecx,[esp] ; x+Xwin |
||
175 | and ecx,0x07 ; modulo 8 |
||
176 | call setvgapixel ; eax=color, ecx=x%8, edi=VGA address |
||
177 | |||
178 | pop edx |
||
179 | pop ecx |
||
180 | pop ebx |
||
181 | pop eax |
||
182 | |||
183 | impvgano: |
||
184 | |||
185 | add esi,3 ; esi+=3 ptrImage+=3 |
||
186 | add eax,4 ; eax+=4 LFBaddr +=4 |
||
187 | inc ebp |
||
188 | inc edx ; x+Xwin+n |
||
189 | |||
190 | test edx,0x07 ; test modulo 8 |
||
191 | jnz impvgacont |
||
192 | inc edi |
||
193 | |||
194 | impvgacont: |
||
195 | dec ecx ; B-- |
||
196 | jnz npvga |
||
197 | |||
198 | pop edx |
||
199 | pop ebx |
||
200 | pop ecx |
||
201 | pop eax |
||
202 | pop esi |
||
203 | pop edi |
||
204 | |||
205 | add edi,640/8 ; add one VGA line |
||
206 | add eax,640*4 ; add one LFB line |
||
207 | |||
208 | sub ebp, ecx ; -B |
||
209 | add ebp, [0xfe00] ; |
||
210 | inc ebp ; ptrBuffer:=ptrBuffer-B+Screen_Xsize+1 |
||
211 | |||
212 | push ecx |
||
213 | lea ecx,[ecx+ecx*2] ; |
||
214 | add esi,ecx ; ptrImage:=ptrImage+B*3 |
||
215 | pop ecx |
||
216 | |||
217 | dec ebx ; H-- |
||
82 | halyavin | 218 | jnz pimvga |
1 | ha | 219 | |
220 | add esp,4 ; jump saved limit byte |
||
221 | pop edx |
||
222 | pop ecx |
||
223 | pop ebx |
||
224 | pop eax |
||
225 | pop edi |
||
226 | pop esi |
||
227 | pop ebp |
||
33 | mario79 | 228 | |
229 | ; call [draw_pointer] |
||
230 | ; call [disable_mouse] |
||
231 | ; popad |
||
1 | ha | 232 | ret |
233 | |||
234 | |||
235 | VGA_putpixel: |
||
236 | |||
237 | ; eax = x |
||
238 | ; ebx = y |
||
239 | |||
240 | mov ecx,eax |
||
241 | mov eax, [esp+32-8+4] ; color |
||
242 | |||
243 | imul ebx, 640*4 ; y*BytesPerLine (Vesa2.0 32) |
||
244 | lea edx, [ebx+ecx*4] ; + x*BytesPerPixel (Vesa2.0 32) |
||
245 | |||
246 | mov edi,edx |
||
247 | add edi, [0xfe80] ; + LFB address |
||
248 | mov [edi], eax ; write to LFB for Vesa2.0 |
||
249 | |||
250 | shr edx,5 ; change BytesPerPixel to 1/8 |
||
251 | mov edi,edx |
||
252 | add edi, 0x0a0000 ; address of pixel in VGA area |
||
253 | |||
254 | and ecx,0x07 ; bit no. (modulo 8) |
||
255 | |||
256 | setvgapixel: |
||
102 | poddubny | 257 | pushfd |
33 | mario79 | 258 | cli |
1 | ha | 259 | ; edi = address, eax = 24bit colour, ecx = bit no. (modulo 8) |
260 | |||
261 | push eax |
||
262 | mov ebx,eax ; color |
||
263 | |||
264 | ;mov al,0x08 |
||
265 | ;mov dx,0x03ce |
||
266 | ;out dx,al ; select GDC bit mask register |
||
267 | |||
268 | inc cl |
||
269 | mov ax, 0x100 |
||
270 | shr ax,cl |
||
271 | mov dx,0x03cf |
||
272 | out dx,al ; set bit mask for pixel |
||
273 | |||
274 | mov dl,0 |
||
275 | mov eax,ebx |
||
276 | and eax,0x000000ff ; blue |
||
277 | cmp eax,85 |
||
278 | jle p13green |
||
279 | or dl,0x01 |
||
280 | cmp eax,170 |
||
281 | jle p13green |
||
282 | or dl,0x08 |
||
283 | |||
284 | p13green: |
||
285 | and ebx,0x0000ff00 ; green |
||
286 | cmp ebx,85*256 |
||
287 | jle p13red |
||
288 | or dl,0x02 |
||
289 | cmp ebx,170*256 |
||
290 | jle p13red |
||
291 | or dl,0x08 |
||
292 | |||
293 | p13red: |
||
294 | pop ebx |
||
295 | and ebx,0x00ff0000 ; red |
||
296 | cmp ebx,85*256*256 |
||
297 | jle p13cont |
||
298 | or dl,0x04 |
||
299 | cmp ebx,170*256*256 |
||
300 | jle p13cont |
||
301 | or dl,0x08 |
||
302 | |||
303 | p13cont: |
||
304 | mov al,[edi] ; dummy read |
||
305 | mov [edi],dl |
||
306 | |||
102 | poddubny | 307 | popfd |
1 | ha | 308 | ret |
309 | |||
310 | |||
311 | vga_drawbar: |
||
33 | mario79 | 312 | ; pushad |
313 | call [disable_mouse] |
||
1 | ha | 314 | sub edx,ebx ; edx:=Yend-Ystart=H |
315 | sub ecx,eax ; ecx:=Xend-Xstat=B |
||
316 | |||
317 | push ebp ; +24 |
||
318 | push esi ; +20 |
||
319 | push edi ; +16 |
||
320 | push eax ; +12 |
||
321 | push ebx ; +8 |
||
322 | push ecx ; +4 |
||
323 | push edx ; +0 |
||
324 | |||
325 | mov ecx,[0x3010] ; |
||
326 | add eax,[ecx-twdw] ; eax:=Xwin+x |
||
327 | add ebx,[ecx-twdw+4] ; ebx:=Ywin+y |
||
328 | mov ecx, eax ; ecx:=(x+Xwin) |
||
329 | mov edx, ebx ; edx:=(y+Ywin) |
||
330 | |||
331 | imul ebx, 640/8 ; |
||
332 | mov edi, ebx ; edi:=BytesPerScanLine*(y+Ywin) |
||
333 | shr eax, 3 ; |
||
334 | add edi, eax ; + (x+Xwin)*BytesPerPixel |
||
335 | add edi,0xa0000 ; + VGAbaseaddress |
||
336 | |||
337 | mov eax, [0xfe00] ; ScreenXSize |
||
338 | inc eax ; +1 |
||
339 | imul eax,edx ; *(y+Ywin) |
||
340 | mov ebp, eax ; |
||
341 | add ebp, ecx ; +(x+Win) |
||
342 | add ebp, WinMapAddress ; +AddrBuffer |
||
343 | |||
344 | mov eax, [0xfe08] ; BytesPerScanLine - LFB |
||
345 | mul edx ; *(y+Ywin) |
||
346 | mov esi,eax |
||
347 | add esi,ecx |
||
348 | add esi,ecx |
||
349 | add esi,ecx |
||
350 | add esi,ecx ; + 4*(x+Xwin) |
||
351 | add esi,[0xfe80] ; +AddrLFB |
||
352 | |||
353 | ; edi:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel + AddrVGA |
||
354 | ; esi:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel + AddrLFB |
||
355 | ; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer |
||
356 | |||
357 | ; x size |
||
358 | |||
359 | mov eax,[esp+4] ; B [esp+4] |
||
360 | mov ebx,[esp+0] ; H |
||
361 | |||
362 | mov edx,[esp+16] ; color |
||
363 | test edx,0x80000000 |
||
364 | jz nodbglvga |
||
365 | |||
366 | ; no color glide for VGA - set to half glide |
||
367 | shr ebx,1 ; H/2 |
||
368 | sub edx,ebx |
||
369 | mov [esp+16],edx |
||
370 | mov ebx,[esp+0] ; reset to H |
||
371 | |||
372 | nodbglvga: |
||
373 | ; check limits ? |
||
374 | |||
375 | push eax |
||
376 | push ecx |
||
377 | |||
378 | mov eax,[0x3010] |
||
379 | |||
380 | mov ecx,[eax+draw_data-0x3000+0] |
||
381 | cmp ecx,0 |
||
382 | jnz dbcblimitlset_vga2 |
||
383 | |||
384 | mov ecx,[eax+draw_data-0x3000+4] |
||
385 | cmp ecx,0 |
||
386 | jnz dbcblimitlset_vga2 |
||
387 | |||
388 | mov ecx,[eax+draw_data-0x3000+8] |
||
389 | cmp ecx,[0xfe00] |
||
390 | jnz dbcblimitlset_vga2 |
||
391 | |||
392 | mov ecx,[eax+draw_data-0x3000+12] |
||
393 | cmp ecx,[0xfe04] |
||
394 | jnz dbcblimitlset_vga2 |
||
395 | |||
396 | pop ecx |
||
397 | pop eax |
||
398 | |||
399 | push dword 0 |
||
400 | |||
401 | jmp dbnewpivga |
||
402 | |||
403 | dbcblimitlset_vga2: |
||
404 | |||
405 | pop ecx ; x+Xwin |
||
406 | pop eax ; B |
||
407 | |||
408 | push dword 1 |
||
409 | |||
410 | dbnewpivga: |
||
411 | |||
412 | push eax; B |
||
413 | push ebx ; H |
||
414 | push edi |
||
415 | push esi |
||
416 | push ecx ; x+Xwin |
||
417 | |||
102 | poddubny | 418 | mov ebx,[0x3000] |
1 | ha | 419 | |
420 | cld |
||
421 | |||
422 | dbnpvga: |
||
423 | |||
424 | mov dl,[ds:ebp] |
||
425 | |||
426 | cmp dl,bl |
||
427 | jnz dbimpvgano |
||
428 | |||
429 | ; mov edx,[esp+5*4] ; check limit? |
||
430 | ; cmp edx,0 |
||
431 | ; jz dbimpvgayes |
||
432 | |||
433 | ; call voodoodbcplimit |
||
434 | ; jnz dbimpvgano |
||
435 | |||
436 | ; dbimpvgayes: |
||
437 | |||
438 | push eax ; B |
||
439 | push ebx |
||
440 | push ecx ; x+Xwin |
||
441 | |||
442 | mov eax,[esp+12+20+16+4] ; color |
||
443 | mov ebx,eax |
||
444 | |||
445 | mov [esi],bx ; write LFB pixel |
||
446 | shr ebx,16 |
||
447 | mov [esi+2],bl |
||
448 | |||
449 | and ecx,0x07 ; modulo 8 |
||
450 | call setvgapixel ; eax=color, ecx=x%8, edi=VGA address |
||
451 | |||
452 | pop ecx |
||
453 | pop ebx |
||
454 | pop eax |
||
455 | |||
456 | dbimpvgano: |
||
457 | |||
458 | add esi,4 ; ptrLFB+=4 |
||
459 | inc ebp ; address buffer |
||
460 | inc ecx ; x posn++ |
||
461 | test ecx,0x07 ; test modulo 8 |
||
462 | jnz dbvgacont |
||
463 | inc edi ; VGA screen ptr++ |
||
464 | |||
465 | dbvgacont: |
||
466 | dec eax ; B-- NB ecx in Vesa20 fn? |
||
467 | jnz dbnpvga |
||
468 | |||
469 | dbnpvgad: |
||
470 | |||
471 | pop ecx |
||
472 | pop esi |
||
473 | pop edi |
||
474 | pop ebx |
||
475 | pop eax |
||
476 | |||
477 | add esi,[0xfe08] ; ptrLFB+=BytesPerScanLine |
||
478 | add edi,640/8 ; ptrScreen+=BytesPerScanLine |
||
479 | |||
480 | add ebp,[0xfe00] ; |
||
481 | sub ebp, eax ; was ecx in vesa20 fn? |
||
482 | inc ebp ; ptrBuffer:=ptrBuffer-B+BytesPerLine+1 |
||
483 | |||
484 | dec ebx ; H-- |
||
485 | jz nodbnewpivga ; H<>0 |
||
486 | |||
487 | jmp dbnewpivga |
||
488 | |||
489 | nodbnewpivga: |
||
490 | |||
491 | add esp,7*4 ; NB includes limit check flag |
||
492 | ;pop ebx |
||
493 | ;pop eax |
||
494 | ;pop edi |
||
495 | ;pop esi |
||
496 | pop ebp |
||
497 | |||
498 | ;pop edx |
||
499 | ;pop ecx |
||
33 | mario79 | 500 | ; popad |
1 | ha | 501 | ret |
502 | |||
503 | |||
504 | vga_drawbackground_tiled: |
||
33 | mario79 | 505 | call [disable_mouse] |
1 | ha | 506 | push ebp |
507 | push eax |
||
508 | push ebx |
||
509 | push ecx |
||
510 | push edx |
||
511 | |||
512 | mov edx,dword [0x400000-8] ; B |
||
513 | add edx,dword [WinMapAddress-8] ; +B |
||
514 | add edx,dword [WinMapAddress-8] ; +B |
||
515 | push edx |
||
516 | |||
517 | mov eax,[draw_data+32+0] ; x start:=(x+Xwin) |
||
518 | mov ebx,[draw_data+32+4] ; y start:=(y+Ywin) |
||
519 | mov ecx,eax |
||
520 | mov edx,ebx |
||
521 | |||
522 | imul edx, 640*4 ; (y+Ywin)*BytesPerScanLine |
||
523 | shl ecx,2 ; (x+Xwin)*BytesPerPixel |
||
524 | add ecx,edx ; |
||
525 | mov ebp,ecx ; store copy |
||
526 | add ecx,[0xfe80] ; +AddrLFB |
||
527 | ;entry point in LFB >> ECX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+Addr |
||
528 | |||
529 | shr ebp,5 ; change from 4 to 1/8 BytesPerPixel |
||
530 | add ebp,0xa0000 ; + VGABasePtr |
||
531 | ;VGA start address >> EBP:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrV |
||
532 | |||
533 | |||
534 | call calculate_edi |
||
535 | |||
536 | dp3vga: ; MAIN LOOP |
||
537 | |||
538 | cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1) |
||
539 | je ybgpvga |
||
540 | |||
541 | jmp nbgpvga |
||
542 | |||
543 | ybgpvga: |
||
544 | |||
545 | push eax ; x |
||
546 | push ebx ; y |
||
547 | push ecx ; LFB address |
||
548 | |||
549 | mov ecx,dword [WinMapAddress-8] ; B |
||
550 | xor edx,edx ; edx:=0 |
||
551 | div ecx ; Xstart/B |
||
552 | |||
553 | ; eax=Int(qn) edx:=Rem |
||
554 | |||
555 | lea esi,[edx+edx*2] ; esi:=edx*3 |
||
556 | |||
557 | mov ecx,dword [WinMapAddress-4] ; ecx:=H |
||
558 | mov eax,[esp+4] ; eax:=Ystart |
||
559 | xor edx,edx ; |
||
560 | div ecx ; Ystart/H |
||
561 | |||
562 | mov eax,edx ; eax:=Rem |
||
563 | xor edx,edx ; |
||
564 | mov ebx,[esp+12] ; ebx:=B*3 |
||
565 | mul ebx ; |
||
566 | add esi,eax ; |
||
567 | |||
568 | mov eax,[esi+0x300000] ; color |
||
569 | and eax,0xffffff |
||
570 | |||
571 | mov ecx, [esp] ; LFB address |
||
572 | mov ebx,eax ; copy color |
||
573 | mov [ecx],bx |
||
574 | shr ebx,16 |
||
575 | mov [ecx+2],bl |
||
576 | |||
577 | xchg edi, ebp |
||
578 | mov ecx,[esp+8] ; x position |
||
579 | and ecx,0x07 ; x modulo 8 |
||
580 | call setvgapixel ; eax=color, ecx=x%8, edi=VGA address |
||
581 | xchg ebp, edi |
||
582 | |||
583 | pop ecx |
||
584 | pop ebx |
||
585 | pop eax |
||
586 | |||
587 | nbgpvga: |
||
588 | |||
589 | inc eax ; x++ |
||
590 | cmp eax,[draw_data+32+8] ; X > xend? |
||
591 | jg nodp3vga |
||
592 | |||
593 | test eax,0x07 ; x test modulo 8 |
||
594 | jnz hook1vga |
||
595 | inc ebp ; VGA address++ |
||
596 | |||
597 | hook1vga: |
||
598 | add ecx,4 ; LFB address += 4 |
||
599 | inc edi ; ptrBuffer++ |
||
600 | add esi,3 ; ptrImage+=3 |
||
601 | jmp dp3vga |
||
602 | |||
603 | nodp3vga: |
||
604 | |||
605 | mov eax,[draw_data+32+0] ; x+Xwin |
||
606 | inc ebx ; y position |
||
607 | mov ecx,eax |
||
608 | mov edx,ebx |
||
609 | |||
610 | imul edx, 640*4 ; (y+Ywin)*BytesPerScanLine |
||
611 | shl ecx,2 ; (x+Xwin)*BytesPerPixel |
||
612 | add ecx,edx ; |
||
613 | mov ebp,ecx ; store copy |
||
614 | add ecx,[0xfe80] ; +AddrLFB |
||
615 | ;entry point in LFB >> ECX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+Addr |
||
616 | |||
617 | |||
618 | shr ebp,5 ; change from 4 to 1/8 BytesPerPixel |
||
619 | add ebp,0xa0000 ; + VGABasePtr |
||
620 | ;VGA start address >> EBP:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrV |
||
621 | |||
622 | |||
623 | call calculate_edi |
||
624 | |||
625 | cmp ebx,[draw_data+32+12] ; Y > yend |
||
626 | jg dp4vga |
||
627 | |||
628 | jmp dp3vga |
||
629 | |||
630 | dp4vga: |
||
631 | |||
632 | add esp,4 |
||
633 | |||
634 | pop edx |
||
635 | pop ecx |
||
636 | pop ebx |
||
637 | pop eax |
||
638 | pop ebp |
||
639 | |||
640 | ret |
||
641 | |||
642 | ; ---------- |
||
643 | |||
644 | |||
645 | |||
646 | vga_drawbackground_stretch: |
||
33 | mario79 | 647 | call [disable_mouse] |
1 | ha | 648 | |
649 | push ebp |
||
650 | push eax |
||
651 | push ebx |
||
652 | push ecx |
||
653 | push edx |
||
654 | |||
655 | mov edx,dword [WinMapAddress-8] ; B |
||
656 | add edx,dword [WinMapAddress-8] ; +B |
||
657 | add edx,dword [WinMapAddress-8] ; +B |
||
658 | push edx |
||
659 | |||
660 | mov eax,[draw_data+32+0] ; x start:=(x+Xwin) |
||
661 | mov ebx,[draw_data+32+4] ; y start:=(y+Ywin) |
||
662 | mov ecx,eax |
||
663 | mov edx,ebx |
||
664 | |||
665 | imul edx, 640*4 ; (y+Ywin)*BytesPerScanLine |
||
666 | shl ecx,2 ; (x+Xwin)*BytesPerPixel |
||
667 | add ecx,edx ; |
||
668 | mov ebp,ecx ; store copy |
||
669 | add ecx,[0xfe80] ; +AddrLFB |
||
670 | ;entry point in LFB >> ECX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+Addr |
||
671 | |||
672 | shr ebp,5 ; change from 4 to 1/8 BytesPerPixel |
||
673 | add ebp,0xa0000 ; + VGABasePtr |
||
674 | ;VGA start address >> EBP:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrV |
||
675 | |||
676 | |||
677 | call calculate_edi |
||
678 | |||
679 | sdp3vga: ; MAIN LOOP |
||
680 | |||
681 | cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1) |
||
682 | je sybgpvga |
||
683 | |||
684 | jmp snbgpvga |
||
685 | |||
686 | sybgpvga: |
||
687 | |||
688 | push eax ; x |
||
689 | push ebx ; y |
||
690 | push ecx ; LFB address |
||
691 | |||
692 | mov eax,dword [WinMapAddress-8] ; B |
||
693 | xor edx,edx |
||
694 | mov ebx,[esp+8] ; Xstart |
||
695 | mul ebx ; B*Xstart |
||
696 | xor edx,edx |
||
697 | mov ebx,[0xfe00] ; x screen width |
||
698 | div ebx ; B*Xstart/xwidth |
||
699 | lea esi,[eax+eax*2] ; *3 |
||
700 | mov eax,dword [WinMapAddress-4] ; H |
||
701 | xor edx,edx |
||
702 | mov ebx,[esp+4] ; Ystart |
||
703 | mul ebx ; H*Ystart |
||
704 | xor edx,edx |
||
705 | mov ebx,[0xfe04] ; y screen height |
||
706 | div ebx ; H*Ystart/yheight |
||
707 | |||
708 | xor edx,edx |
||
709 | mov ebx,[esp+12] ; B*3 |
||
710 | mul ebx ; |
||
711 | add esi,eax |
||
712 | mov eax,[esi+0x300000] ; color |
||
713 | and eax,0xffffff |
||
714 | |||
715 | mov ecx, [esp] ; LFB address |
||
716 | mov ebx,eax ; copy color |
||
717 | mov [ecx],bx |
||
718 | shr ebx,16 |
||
719 | mov [ecx+2],bl |
||
720 | |||
721 | xchg edi, ebp |
||
722 | mov ecx,[esp+8] ; x position |
||
723 | and ecx,0x07 ; x modulo 8 |
||
724 | call setvgapixel ; eax=color, ecx=x%8, edi=VGA address |
||
725 | xchg ebp, edi ; ebp+=3 |
||
726 | |||
727 | pop ecx |
||
728 | pop ebx |
||
729 | pop eax |
||
730 | |||
731 | snbgpvga: |
||
732 | |||
733 | inc eax ; x++ |
||
734 | cmp eax,[draw_data+32+8] ; X > xend? |
||
735 | jg snodp3vga |
||
736 | |||
737 | test eax,0x07 ; x test modulo 8 |
||
738 | jnz shook1vga |
||
739 | inc ebp ; VGA address++ |
||
740 | |||
741 | shook1vga: |
||
742 | add ecx,4 ; LFB address += 4 |
||
743 | inc edi ; ptrBuffer++ |
||
744 | add esi,3 ; ptrImage+=3 |
||
745 | jmp sdp3vga |
||
746 | |||
747 | snodp3vga: |
||
748 | |||
749 | mov eax,[draw_data+32+0] ; x+Xwin |
||
750 | inc ebx ; y position |
||
751 | mov ecx,eax |
||
752 | mov edx,ebx |
||
753 | |||
754 | imul edx, 640*4 ; (y+Ywin)*BytesPerScanLine |
||
755 | shl ecx,2 ; (x+Xwin)*BytesPerPixel |
||
756 | add ecx,edx ; |
||
757 | mov ebp,ecx ; store copy |
||
758 | add ecx,[0xfe80] ; +AddrLFB |
||
759 | ;entry point in LFB >> ECX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+Addr |
||
760 | |||
761 | |||
762 | shr ebp,5 ; change from 4 to 1/8 BytesPerPixel |
||
763 | add ebp,0xa0000 ; + VGABasePtr |
||
764 | ;VGA start address >> EBP:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+A |
||
765 | |||
766 | |||
767 | call calculate_edi |
||
768 | |||
769 | cmp ebx,[draw_data+32+12] ; Y > yend |
||
770 | jg sdp4vga |
||
771 | |||
772 | jmp sdp3vga |
||
773 | |||
774 | sdp4vga: |
||
775 | |||
776 | add esp,4 |
||
777 | |||
778 | pop edx |
||
779 | pop ecx |
||
780 | pop ebx |
||
781 | pop eax |
||
782 | pop ebp |
||
783 | |||
784 | ret>>>>> |
||
785 |