Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


compiled bitmap's format


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Tuan   Members   -  Reputation: 122

Like
Likes
Like

Posted 02 December 1999 - 06:05 PM

Could anyone show me what is the compiled bitmap's format to get the fastest blitting?
Thanx.

Sponsor:

#2 Gromit   Members   -  Reputation: 144

Like
Likes
Like

Posted 02 December 1999 - 06:05 PM

Do you actually mean 'compiled bitmaps' or 'Runtime Length Encoded' (RLE) bitmaps?

- An RLE bitmap, is a form of compression, but I believe that when using them, you can speed up your bliting (i think). It gets its compression by only storing pixels that are different from the one next to it.

- A compiled bitmap, is one that you converted to pure code and is including into your make file. It will usually be an ASM file for greater speed. This function will work only in 8bit mode I believe. You can download the read the original article for this at
http://www.xgames3d.com/articles/csprite/areadcsp.htm

Hope this helped.

code:

int Compile_Sprite_WASM (sprite_ptr the_sprite, char *spritename) {
int i, x, y, offset, offset1, offset2, offset3, bitmap_offset;

FILE *outfile;
char byte1, byte2, byte3, byte4;
char *filename;
unsigned char *bitmap;
filename = strdup(spritename);
strcat(filename, ".ASM");

if((outfile = fopen(filename,"wt")) == NULL){
printf("Could not open output file %s\n", filename);
return(1);
};

fprintf(outfile,".386p\n");
fprintf(outfile," NAME %s\n", spritename);
fprintf(outfile,"DGROUP GROUP CONST,CONST2,_DATA,_BSS\n");
fprintf(outfile,"_TEXT SEGMENT PARA PUBLIC USE32 'CODE'\n");
fprintf(outfile," ASSUME CS:_TEXT ,DS : DGROUP,SS : DGROUP\n");

for (i=0; i < the_sprite->num_frames; i++) fprintf(outfile," PUBLIC %s_%d_\n", spritename, i);
for (i=0; i < the_sprite->num_frames; i++) {
fprintf(outfile,"%s_%d_: push ECX\n", spritename, i);
fprintf(outfile," mov ECX,EDX\n");
fprintf(outfile," shl ECX,08H\n");
fprintf(outfile," shl EDX,06H\n");
fprintf(outfile," add EBX,ECX\n");
fprintf(outfile," add EDX,EBX\n");
fprintf(outfile," add EAX,EDX\n");
bitmap_offset = 0;
bitmap = the_sprite->frames[i];

for (y = 0; y < the_sprite->height; y++) {
offset = y * 320;
x = 0;

while (x < the_sprite->width) {
if (*(bitmap + bitmap_offset) != 0) {
byte1 = *(bitmap + bitmap_offset);
offset1 = offset;
bitmap_offset++;
offset++;
x++;
if ((*(bitmap + bitmap_offset) != 0) && (x < the_sprite->width)) {
byte2 = *(bitmap + bitmap_offset);
offset2 = offset;
bitmap_offset++;
offset++;
x++;
if ((*(bitmap + bitmap_offset) != 0) && (x < the_sprite->width)) {
byte3 = *(bitmap + bitmap_offset);
offset3 = offset;
bitmap_offset++;
offset++;
x++;
if ((*(bitmap + bitmap_offset) != 0) && (x < the_sprite->width)) {
byte4 = *(bitmap + bitmap_offset);
fprintf(outfile," mov dword ptr +0x%x[EAX],0x%02x%02x%02x%02xH\n", offset1, byte4, byte3, byte2, byte1);
}
else {
fprintf(outfile," mov word ptr +0x%x[EAX],0x%02x%02xH\n", offset1, byte2, byte1);
fprintf(outfile," mov byte ptr +0x%x[EAX],0x%02xH\n", offset3, byte3);
}
}
else {
fprintf(outfile," mov word ptr +0x%x[EAX],0x%02x%02xH\n", offset1, byte2, byte1);
}
}
else {
fprintf(outfile," mov byte ptr +0x%x[EAX],0x%02xH\n", offset1, byte1);
}
}
else {
bitmap_offset++;
offset++;
x++;
}
}; // end while x
}; // end for y
fprintf(outfile," pop ECX\n");
fprintf(outfile," ret\n");
fprintf(outfile," nop\n");
}; // end for frames

fprintf(outfile,"_TEXT ENDS\n\n");
fprintf(outfile,"CONST SEGMENT DWORD PUBLIC USE32 'DATA'\n");
fprintf(outfile,"CONST ENDS\n\n");
fprintf(outfile,"CONST2 SEGMENT DWORD PUBLIC USE32 'DATA'\n");
fprintf(outfile,"CONST2 ENDS\n\n");
fprintf(outfile,"_DATA SEGMENT DWORD PUBLIC USE32 'DATA'\n");
fprintf(outfile,"_DATA ENDS\n\n");
fprintf(outfile,"_BSS SEGMENT DWORD PUBLIC USE32 'BSS'\n");
fprintf(outfile,"_BSS ENDS\n\n");
fprintf(outfile," END");
fclose(outfile);
return(0);
};


[This message has been edited by Gromit (edited December 03, 1999).]





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS