From: "Johan Venter" Newsgroups: comp.os.msdos.djgpp References: <380EF520 DOT C2FAE759 AT connect DOT ab DOT ca> Subject: Re: Plague of the slow 'blit' routine :) Lines: 45 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Message-ID: Date: Fri, 22 Oct 1999 11:18:24 +1000 NNTP-Posting-Host: 139.134.163.34 X-Trace: newsfeeds.bigpond.com 940586727 139.134.163.34 (Fri, 22 Oct 1999 20:05:27 EST) NNTP-Posting-Date: Fri, 22 Oct 1999 20:05:27 EST Organization: Telstra BigPond Internet Services (http://www.bigpond.com) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Tom Fjellstrom wrote in message news:380EF520 DOT C2FAE759 AT connect DOT ab DOT ca... > The only way I have thought of determining that a bitmap is in video memory > is too add a variable to the bitmap struct when creating it to indicate > whether > or not it is in video memory. If that is the only safe way of doing it I > guess i'll have to. A suggestion if I may: Do you have a global 'screen' bitmap which always contains a pointer to the video memory? If so, try something like this: void blit(BITMAP *src, BITMAP *dest, int from_x, int from_y, int to_x, int to_y) { int source_address = src->dat + (from_y*src->w+from_x); int dest_address = dest->dat + (to_y*dest->w+to_x); /* maybe add some clipping here */ if (dest->dat == screen->dat) { /* DO A FAR POINTER BLIT TO SCREEN */ } else { /* DO A memcpy */ } } Note: 1. Code written very fast. 2. Code untested. 3. Not even sure code will compile. Hopefully you get the point though, -- Johan Venter ICQ 3643877 - jventer AT writeme DOT com The TPU DJGPP Interest Group - http://surf.to/djgppig The RSXNTDJ 1.5 HOWTO - http://surf.to/rsxntdj