cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/21/10:11:52

Message-ID: <380E497E.273EE838@connect.ab.ca>
Date: Wed, 20 Oct 1999 23:00:14 +0000
From: Tom Fjellstrom <tomcf AT connect DOT ab DOT ca>
X-Mailer: Mozilla 4.61 [en] (Win95; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Plague of the slow 'blit' routine :)
NNTP-Posting-Host: ts1680.connect.ab.ca
X-Trace: 20 Oct 1999 22:55:24 -0600, ts1680.connect.ab.ca
Lines: 62
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I've been playing around with mode 13h, and the
only thing I've been really stuck on is my 'blit'
routine. Suffice it to say it is extremely slow.
It may have to do with '__djgpp_nearptr_enable()'ing
before blit and '__djgpp_nearptr_disable()'ing after,
for every bitmap (but that is only required when reading
or writing to the gfx card memory. as far as i know),
because i haven't thought of an efficient enough way
to distinguish between a memory 'bitmap', and a system
'bitmap' (the screen). (i.e.: there may be a sub bitmap of the screen)
If there is something I haven't thought of I'm sure some one
can lend a hand. :)

so here is my blit routine so far and (maybe) necessary info:

#define ENABLE() do { if(!enabled) { __djgpp_nearptr_enable(); enabled =
1; } } while(0)
#define DISABLE() do { if(enabled) { __djgpp_nearptr_disable(); enabled
= 0; } } while(0)
#define put_pixel(bmp,x,y,c) (bmp)->dat[((y) << 8) + ((y) << 6) + (x)] =
(c)

typedef struct BITMAP {
 int w,h;
 /* should add clip rect. */
 char *dat;
} BITMAP;

void blit(BITMAP *src, BITMAP *dest, int srcw, int srch, int x, int y)
{
 register int i,j;
 if(!src || !dest || !srcw || !srch) return;
 if((x+srcw>dest->w) || (y+srch>dest->h)) return;

 ENABLE();

 for(i=0; i!=srch+1; i++) {
  if(y+i>dest->h) break;
  for(j=0; j!=srcw+1; j++) {
   if((x+j) > dest->w) break;
   put_pixel(dest, j, i, src->dat[(i << 8) + (i << 6) + j]);
  }
 }

 DISABLE();
}

One last thing. Could this be speed up with an equivalent of allegro's
'read_bmp_line' and 'write_bmp_line'? (I think they're called that)

thanks in advance for any help.

--

"An Optimist will say the glass is half full,
 A Pessimist will say the glass is half empty,
 A Canadian will say Waiter!"

Tom Fjellstrom
tomcf AT connect DOT ab DOT ca


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019