Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!uxc.cso.uiuc.edu!uxc.cso.uiuc.edu!ux1.cso.uiuc.edu!uxe.cso.uiuc.edu!mcdonald From: mcdonald@uxe.cso.uiuc.edu Newsgroups: comp.sys.ibm.pc Subject: Re: Why are bitmap save/restores so slo Message-ID: <110200005@uxe.cso.uiuc.edu> Date: 18 Sep 89 14:14:00 GMT References: <3776@titan.camcon.co.uk> Lines: 47 Nf-ID: #R:titan.camcon.co.uk:3776:uxe.cso.uiuc.edu:110200005:000:1742 Nf-From: uxe.cso.uiuc.edu!mcdonald Sep 18 09:14:00 1989 >mcdonald@uxe.cso.uiuc.edu <110200003@uxe.cso.uiuc.edu> : >- >-There are extremely efficient ways of copying areas from region >-to another of video memory. And, to copy to or from ordinary memory, >-retaining the planar maps, is very fast indeed. So is drawing >-lines or circles or text in a fixed color. The programmer just has >-to understand how it works and choose an efficient way to do it. >Okay. Any tips on how to do this? To copy from one part of EGA/VGA memory to another you first realize that it is stored (in C) as unsigned char screen[480][640]; that is first the upper left corner, then proceeding across the screen, then down. To copy a region from one place in screen memory to another, just write code to copy the bytes. In C, you might want to use memcpy or memmove. In assembler, use the byte string move instructions. This is done with the control registers of the EGA/VGA in their normal state as set by a bios call to set mode 16 or 18. For example, to copy the top two rows to the 3rd and forth rows: char far *p1; char far *p2; int i,j; p1 = (char far *)0xa000000; p2 = p1 + 1280; for(i = 0; i < 1280; i++)*p2++ = *p1++; (Now for the weird part!!!!! You can replace *p2++ = *p1++ with *p2++ = - *p1++ or *p2++ = *p1++ +12345; and it will still work. Each byte operation in C copies all four bit planes.) To read the color bitplanes to or from ordinary memory, you copy each individual plane one at a time.This requires diddling the IO registers. It is complicated enough that you will need to read a book to see how to set them. Once set, however, the graphics memory behaves just like ordinary memory (no four bytes copied at once). Just be sure to return the registers to normal. Doug MCDonald