Newsgroups: comp.os.msdos.djgpp,comp.ai.games From: "A. Jans-Beken" Subject: Allegro: Faster blitting possible? Content-Type: text/plain; charset=us-ascii Message-ID: <347312B7.40FA@oce.nl> Sender: news AT oce DOT nl (The Daily News @ nntp01.oce.nl) Content-Transfer-Encoding: 7bit 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 Precedence: bulk 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?