delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/19/14:04:22

Newsgroups: comp.os.msdos.djgpp,comp.ai.games
From: "A. Jans-Beken" <jabe AT oce DOT nl>
Subject: Allegro: Faster blitting possible?
Message-ID: <347312B7.40FA@oce.nl>
Sender: news AT oce DOT nl (The Daily News @ nntp01.oce.nl)
Cc: shawn AT talula DOT demon DOT co DOT uk
Organization: Océ-Nederland B.V.
Mime-Version: 1.0
Date: Wed, 19 Nov 1997 16:24:23 GMT
Lines: 34
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Maybe I have an idea to speed-up blitting in Allegro. If someone has
implemented this already: Please send me a copy.

In a game that I am working on I have to blit a lot of tiles (small
squares that combined in a smart manner look like a map). In a lot of
cases I have to update the contents of a tile. I noticed that the
difference between old tile contents and new tile contents is often
minimal.

As an example, think of a bullet from a tank to a target. The bullet is
very small in relation to a tile but to draw a nice animated movement a
have to blit the tile several times (something like):

L01 BLIT(tile_gfx,tile_buf);
L02 SPRITE_BLIT(sprite_gfx,tile_buf);
L03 ...
L04 BLIT(tile_buf,screen);

I think that it may be faster (in line L04) to first compare the
new_tile contents to the old_tile contents. This would look like this:
  
    First rebuild the old tile (or store it somewhere)...
L01 BLIT(tile_gfx,old_tile_buf);
L02 SPRITE_BLIT(old_sprite_gfx,old_tile_buf);
L03 ...
    Second build the new tile
L04 BLIT(tile_gfx,new_tile_buf);
L05 SPRITE_BLIT(new_sprite_gfx,new_tile_buf);
L06 ...
    result contains only different pixels->rest is transparant.
L07 COMPARE(new_tile_buf,old_tile_buf,result_tile_buf);
L08 SPRITE_BLIT(result_tile_buf,screen);

What is your opinion?

- Raw text -


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