Restructure bmread.c for merging

This commit is contained in:
Kp 2013-11-10 03:31:22 +00:00
parent 1932647fb1
commit 0b34e37a5e
2 changed files with 25 additions and 33 deletions

View file

@ -119,7 +119,7 @@ static int crit_flag; //flag if this is a destroyed eclip
static int tmap1_flag; //flag if this is used as tmap_num (not tmap_num2) static int tmap1_flag; //flag if this is used as tmap_num (not tmap_num2)
static int num_sounds=0; static int num_sounds=0;
int linenum;
//------------------- Useful macros and variables --------------- //------------------- Useful macros and variables ---------------
@ -135,7 +135,7 @@ void remove_char( char * s, char c )
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
int compute_average_pixel(grs_bitmap *new) int compute_average_pixel(grs_bitmap *n)
{ {
int row, column, color; int row, column, color;
// char *pptr; // char *pptr;
@ -145,17 +145,17 @@ int compute_average_pixel(grs_bitmap *new)
total_green = 0; total_green = 0;
total_blue = 0; total_blue = 0;
for (row=0; row<new->bm_h; row++) for (row=0; row<n->bm_h; row++)
for (column=0; column<new->bm_w; column++) { for (column=0; column<n->bm_w; column++) {
color = gr_gpixel (new, column, row); color = gr_gpixel (n, column, row);
total_red += gr_palette[color*3]; total_red += gr_palette[color*3];
total_green += gr_palette[color*3+1]; total_green += gr_palette[color*3+1];
total_blue += gr_palette[color*3+2]; total_blue += gr_palette[color*3+2];
} }
total_red /= (new->bm_h * new->bm_w); total_red /= (n->bm_h * n->bm_w);
total_green /= (new->bm_h * new->bm_w); total_green /= (n->bm_h * n->bm_w);
total_blue /= (new->bm_h * new->bm_w); total_blue /= (n->bm_h * n->bm_w);
return BM_XRGB(total_red/2, total_green/2, total_blue/2); return BM_XRGB(total_red/2, total_green/2, total_blue/2);
} }
@ -167,7 +167,7 @@ int compute_average_pixel(grs_bitmap *new)
static bitmap_index bm_load_sub(int skip, char * filename ) static bitmap_index bm_load_sub(int skip, char * filename )
{ {
bitmap_index bitmap_num; bitmap_index bitmap_num;
grs_bitmap * new; grs_bitmap * n;
ubyte newpal[256*3]; ubyte newpal[256*3];
int iff_error; //reference parm to avoid warning message int iff_error; //reference parm to avoid warning message
char fname[20]; char fname[20];
@ -185,21 +185,21 @@ static bitmap_index bm_load_sub(int skip, char * filename )
return bitmap_num; return bitmap_num;
} }
MALLOC( new, grs_bitmap, 1 ); MALLOC( n, grs_bitmap, 1 );
iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal); iff_error = iff_read_bitmap(filename,n,BM_LINEAR,newpal);
if (iff_error != IFF_NO_ERROR) { if (iff_error != IFF_NO_ERROR) {
Error("File %s - IFF error: %s",filename,iff_errormsg(iff_error)); Error("File %s - IFF error: %s",filename,iff_errormsg(iff_error));
} }
if ( iff_has_transparency ) if ( iff_has_transparency )
gr_remap_bitmap_good( new, newpal, iff_transparent_color, SuperX ); gr_remap_bitmap_good( n, newpal, iff_transparent_color, SuperX );
else else
gr_remap_bitmap_good( new, newpal, -1, SuperX ); gr_remap_bitmap_good( n, newpal, -1, SuperX );
new->avg_color = compute_average_pixel(new); n->avg_color = compute_average_pixel(n);
bitmap_num = piggy_register_bitmap( new, fname, 0 ); bitmap_num = piggy_register_bitmap( n, fname, 0 );
d_free( new ); d_free( n );
return bitmap_num; return bitmap_num;
} }
@ -260,7 +260,7 @@ static void ab_load(int skip, char * filename, bitmap_index bmp[], int *nframes
int ds_load(int skip, const char * filename ) { int ds_load(int skip, const char * filename ) {
int i; int i;
PHYSFS_file * cfp; PHYSFS_file * cfp;
digi_sound new; digi_sound n;
char fname[20]; char fname[20];
char rawname[100]; char rawname[100];
@ -281,22 +281,16 @@ int ds_load(int skip, const char * filename ) {
cfp = PHYSFSX_openReadBuffered(rawname); cfp = PHYSFSX_openReadBuffered(rawname);
if (cfp!=NULL) { if (cfp!=NULL) {
#ifdef ALLEGRO n.length = PHYSFS_fileLength( cfp );
new.len = PHYSFS_fileLength( cfp ); MALLOC( n.data, ubyte, n.length );
MALLOC( new.data, ubyte, new.len ); PHYSFS_read( cfp, n.data, 1, n.length );
PHYSFS_read( cfp, new.data, 1, new.len );
#else
new.length = PHYSFS_fileLength( cfp );
MALLOC( new.data, ubyte, new.length );
PHYSFS_read( cfp, new.data, 1, new.length );
#endif
PHYSFS_close(cfp); PHYSFS_close(cfp);
new.bits = 8; n.bits = 8;
new.freq = 11025; n.freq = 11025;
} else { } else {
return 255; return 255;
} }
i = piggy_register_sound( &new, fname, 0 ); i = piggy_register_sound( &n, fname, 0 );
return i; return i;
} }
@ -334,8 +328,6 @@ static int get_int()
#define LINEBUF_SIZE 600 #define LINEBUF_SIZE 600
int linenum;
//----------------------------------------------------------------- //-----------------------------------------------------------------
// Initializes all properties and bitmaps from BITMAPS.TBL file. // Initializes all properties and bitmaps from BITMAPS.TBL file.
int gamedata_read_tbl(int pc_shareware) int gamedata_read_tbl(int pc_shareware)

View file

@ -76,7 +76,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define MAX_BITMAPS_PER_BRUSH 30 #define MAX_BITMAPS_PER_BRUSH 30
short N_ObjBitmapPtrs=0; static short N_ObjBitmapPtrs=0;
static int Num_robot_ais = 0; static int Num_robot_ais = 0;
int TmapList[MAX_TEXTURES]; int TmapList[MAX_TEXTURES];
char Powerup_names[MAX_POWERUP_TYPES][POWERUP_NAME_LENGTH]; char Powerup_names[MAX_POWERUP_TYPES][POWERUP_NAME_LENGTH];
@ -492,6 +492,7 @@ int gamedata_read_tbl(int pc_shareware)
IFTOK("$COCKPIT") bm_flag = BM_COCKPIT; IFTOK("$COCKPIT") bm_flag = BM_COCKPIT;
else IFTOK("$GAUGES") {bm_flag = BM_GAUGES; clip_count = 0;} else IFTOK("$GAUGES") {bm_flag = BM_GAUGES; clip_count = 0;}
else IFTOK("$GAUGES_HIRES"){bm_flag = BM_GAUGES_HIRES; clip_count = 0;} else IFTOK("$GAUGES_HIRES"){bm_flag = BM_GAUGES_HIRES; clip_count = 0;}
else IFTOK("$ALIAS") bm_read_alias();
else IFTOK("$SOUND") bm_read_sound(skip, pc_shareware); else IFTOK("$SOUND") bm_read_sound(skip, pc_shareware);
else IFTOK("$DOOR_ANIMS") bm_flag = BM_WALL_ANIMS; else IFTOK("$DOOR_ANIMS") bm_flag = BM_WALL_ANIMS;
else IFTOK("$WALL_ANIMS") bm_flag = BM_WALL_ANIMS; else IFTOK("$WALL_ANIMS") bm_flag = BM_WALL_ANIMS;
@ -501,7 +502,6 @@ int gamedata_read_tbl(int pc_shareware)
else IFTOK("$WCLIP") {bm_flag = BM_WCLIP; vlighting = 0; clip_count = 0; wall_explodes = wall_blastable = 0; wall_open_sound=wall_close_sound=-1; tmap1_flag=0; wall_hidden=0;} else IFTOK("$WCLIP") {bm_flag = BM_WCLIP; vlighting = 0; clip_count = 0; wall_explodes = wall_blastable = 0; wall_open_sound=wall_close_sound=-1; tmap1_flag=0; wall_hidden=0;}
else IFTOK("$EFFECTS") {bm_flag = BM_EFFECTS; clip_num = 0;} else IFTOK("$EFFECTS") {bm_flag = BM_EFFECTS; clip_num = 0;}
else IFTOK("$ALIAS") bm_read_alias();
#ifdef EDITOR #ifdef EDITOR
else IFTOK("!METALS_FLAG") TextureMetals = texture_count; else IFTOK("!METALS_FLAG") TextureMetals = texture_count;