Expanded possibilities for level authors: RLE- and Texture-cache accepts textures bigger than 64x64, only limit being Texture width must be equal height; Increased maximum amount of Segments from 900 to 9000 - not dynamically allocating them, yet

This commit is contained in:
zicodxx 2011-04-22 10:33:04 +02:00
parent 89ef310ec6
commit 10aca9a9fe
5 changed files with 86 additions and 54 deletions

View file

@ -352,9 +352,8 @@ void rle_cache_init()
int i;
for (i=0; i<MAX_CACHE_BITMAPS; i++ ) {
rle_cache[i].rle_bitmap = NULL;
rle_cache[i].expanded_bitmap = gr_create_bitmap( 64, 64 );
rle_cache[i].expanded_bitmap = NULL;
rle_cache[i].last_used = 0;
Assert( rle_cache[i].expanded_bitmap != NULL );
}
rle_cache_initialized = 1;
}
@ -428,8 +427,10 @@ grs_bitmap * rle_expand_texture( grs_bitmap * bmp )
}
}
Assert(bmp->bm_w<=64 && bmp->bm_h<=64); //dest buffer is 64x64
rle_misses++;
if (rle_cache[least_recently_used].expanded_bitmap != NULL)
gr_free_bitmap(rle_cache[least_recently_used].expanded_bitmap);
rle_cache[least_recently_used].expanded_bitmap = gr_create_bitmap(bmp->bm_w, bmp->bm_h);
rle_expand_texture_sub( bmp, rle_cache[least_recently_used].expanded_bitmap );
rle_cache[least_recently_used].rle_bitmap = bmp;
rle_cache[least_recently_used].last_used = rle_counter;

View file

@ -1,5 +1,9 @@
D2X-Rebirth Changelog
20110422
--------
2d/rle.c, SConstruct, main/segment.h, main/texmerge.c: Expanded possibilities for level authors: RLE- and Texture-cache accepts textures bigger than 64x64, only limit being Texture width must be equal height; Increased maximum amount of Segments from 900 to 9000 - not dynamically allocating them, yet
20110421
--------
main/net_ipx.c, main/net_udp.c: When leaving game and still sending extras, don't forget to update the timer so we won't get stuck in an infinite loop

View file

@ -69,7 +69,6 @@ common_sources = [
'2d/rect.c',
'2d/rle.c',
'2d/scalec.c',
'2d/tmerge.c',
'3d/clipper.c',
'3d/draw.c',
'3d/globvars.c',

View file

@ -46,13 +46,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define WBACK 4
#define WFRONT 5
#if defined(SHAREWARE)
# define MAX_SEGMENTS 800
# define MAX_SEGMENT_VERTICES 2800
#else
# define MAX_SEGMENTS 900
# define MAX_SEGMENT_VERTICES 3600
#endif
#define MAX_SEGMENTS 9000
#define MAX_SEGMENT_VERTICES (4*MAX_SEGMENTS)
//normal everyday vertices

View file

@ -68,12 +68,7 @@ int texmerge_init(int num_cached_textures)
num_cache_entries = MAX_NUM_CACHE_BITMAPS;
for (i=0; i<num_cache_entries; i++ ) {
// Make temp tmap for use when combining
Cache[i].bitmap = gr_create_bitmap( 64, 64 );
//if (get_selector( Cache[i].bitmap->bm_data, 64*64, &Cache[i].bitmap->bm_selector))
// Error( "ERROR ALLOCATING CACHE BITMAP'S SELECTORS!!!!" );
Cache[i].bitmap = NULL;
Cache[i].last_frame_used = -1;
Cache[i].top_bmp = NULL;
Cache[i].bottom_bmp = NULL;
@ -151,12 +146,18 @@ grs_bitmap * texmerge_get_cached_bitmap( int tmap_bottom, int tmap_top )
PIGGY_PAGE_IN(Textures[tmap_bottom]);
}
Assert( piggy_page_flushed == 0 );
if (bitmap_bottom->bm_w != bitmap_bottom->bm_h || bitmap_top->bm_w != bitmap_top->bm_h)
Error("Texture width != texture height!\n");
if (bitmap_bottom->bm_w != bitmap_top->bm_w || bitmap_bottom->bm_h != bitmap_top->bm_h)
Error("Top and Bottom textures have different size!\n");
if (Cache[least_recently_used].bitmap != NULL)
gr_free_bitmap(Cache[least_recently_used].bitmap);
Cache[least_recently_used].bitmap = gr_create_bitmap(bitmap_bottom->bm_w, bitmap_bottom->bm_h);
#ifdef OGL
ogl_freebmtexture(Cache[least_recently_used].bitmap);
#endif
if (bitmap_top->bm_flags & BM_FLAG_SUPER_TRANSPARENT) {
merge_textures_super_xparent( orient, bitmap_bottom, bitmap_top, Cache[least_recently_used].bitmap->bm_data );
Cache[least_recently_used].bitmap->bm_flags = BM_FLAG_TRANSPARENT;
@ -177,7 +178,8 @@ grs_bitmap * texmerge_get_cached_bitmap( int tmap_bottom, int tmap_top )
void merge_textures_new( int type, grs_bitmap * bottom_bmp, grs_bitmap * top_bmp, ubyte * dest_data )
{
ubyte * top_data, *bottom_data;
ubyte * top_data, *bottom_data, c = 0;
int x, y, wh;
if ( top_bmp->bm_flags & BM_FLAG_RLE )
top_bmp = rle_expand_texture(top_bmp);
@ -187,31 +189,56 @@ void merge_textures_new( int type, grs_bitmap * bottom_bmp, grs_bitmap * top_bmp
top_data = top_bmp->bm_data;
bottom_data = bottom_bmp->bm_data;
wh = bottom_bmp->bm_w;
switch( type ) {
case 0:
// Normal
gr_merge_textures( bottom_data, top_data, dest_data );
break;
case 1:
gr_merge_textures_1( bottom_data, top_data, dest_data );
break;
case 2:
gr_merge_textures_2( bottom_data, top_data, dest_data );
break;
case 3:
gr_merge_textures_3( bottom_data, top_data, dest_data );
break;
case 0:
// Normal
for (y=0; y<wh; y++ )
for (x=0; x<wh; x++ ) {
c = top_data[ wh*y+x ];
if (c==TRANSPARENCY_COLOR)
c = bottom_data[ wh*y+x ];
*dest_data++ = c;
}
break;
case 1:
for (y=0; y<wh; y++ )
for (x=0; x<wh; x++ )
{
c = top_data[ wh*x+((wh-1)-y) ];
if (c==TRANSPARENCY_COLOR)
c = bottom_data[ wh*y+x ];
*dest_data++ = c;
}
break;
case 2:
for (y=0; y<wh; y++ )
for (x=0; x<wh; x++ )
{
c = top_data[ wh*((wh-1)-y)+((wh-1)-x) ];
if (c==TRANSPARENCY_COLOR)
c = bottom_data[ wh*y+x ];
*dest_data++ = c;
}
break;
case 3:
for (y=0; y<wh; y++ )
for (x=0; x<wh; x++ )
{
c = top_data[ wh*((wh-1)-x)+y ];
if (c==TRANSPARENCY_COLOR)
c = bottom_data[ wh*y+x ];
*dest_data++ = c;
}
break;
}
}
void merge_textures_super_xparent( int type, grs_bitmap * bottom_bmp, grs_bitmap * top_bmp, ubyte * dest_data )
{
ubyte c;
int x,y;
ubyte * top_data, *bottom_data;
ubyte * top_data, *bottom_data, c = 0;
int x, y, wh;
if ( top_bmp->bm_flags & BM_FLAG_RLE )
top_bmp = rle_expand_texture(top_bmp);
@ -221,15 +248,18 @@ void merge_textures_super_xparent( int type, grs_bitmap * bottom_bmp, grs_bitmap
top_data = top_bmp->bm_data;
bottom_data = bottom_bmp->bm_data;
wh = bottom_bmp->bm_w;
switch( type ) {
switch( type )
{
case 0:
// Normal
for (y=0; y<64; y++ )
for (x=0; x<64; x++ ) {
c = top_data[ 64*y+x ];
for (y=0; y<wh; y++ )
for (x=0; x<wh; x++ )
{
c = top_data[ wh*y+x ];
if (c==TRANSPARENCY_COLOR)
c = bottom_data[ 64*y+x ];
c = bottom_data[ wh*y+x ];
else if (c==254)
c = TRANSPARENCY_COLOR;
*dest_data++ = c;
@ -237,11 +267,12 @@ void merge_textures_super_xparent( int type, grs_bitmap * bottom_bmp, grs_bitmap
break;
case 1:
//
for (y=0; y<64; y++ )
for (x=0; x<64; x++ ) {
c = top_data[ 64*x+(63-y) ];
for (y=0; y<wh; y++ )
for (x=0; x<wh; x++ )
{
c = top_data[ wh*x+((wh-1)-y) ];
if (c==TRANSPARENCY_COLOR)
c = bottom_data[ 64*y+x ];
c = bottom_data[ wh*y+x ];
else if (c==254)
c = TRANSPARENCY_COLOR;
*dest_data++ = c;
@ -249,11 +280,12 @@ void merge_textures_super_xparent( int type, grs_bitmap * bottom_bmp, grs_bitmap
break;
case 2:
// Normal
for (y=0; y<64; y++ )
for (x=0; x<64; x++ ) {
c = top_data[ 64*(63-y)+(63-x) ];
for (y=0; y<wh; y++ )
for (x=0; x<wh; x++ )
{
c = top_data[ wh*((wh-1)-y)+((wh-1)-x) ];
if (c==TRANSPARENCY_COLOR)
c = bottom_data[ 64*y+x ];
c = bottom_data[ wh*y+x ];
else if (c==254)
c = TRANSPARENCY_COLOR;
*dest_data++ = c;
@ -261,11 +293,12 @@ void merge_textures_super_xparent( int type, grs_bitmap * bottom_bmp, grs_bitmap
break;
case 3:
// Normal
for (y=0; y<64; y++ )
for (x=0; x<64; x++ ) {
c = top_data[ 64*(63-x)+y ];
for (y=0; y<wh; y++ )
for (x=0; x<wh; x++ )
{
c = top_data[ wh*((wh-1)-x)+y ];
if (c==TRANSPARENCY_COLOR)
c = bottom_data[ 64*y+x ];
c = bottom_data[ wh*y+x ];
else if (c==254)
c = TRANSPARENCY_COLOR;
*dest_data++ = c;