From 10aca9a9fe899dba7ce3166ef6d51a6908eec5fe Mon Sep 17 00:00:00 2001 From: zicodxx Date: Fri, 22 Apr 2011 10:33:04 +0200 Subject: [PATCH] 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 --- 2d/rle.c | 7 +-- CHANGELOG.txt | 4 ++ SConstruct | 1 - main/segment.h | 9 +--- main/texmerge.c | 119 +++++++++++++++++++++++++++++++----------------- 5 files changed, 86 insertions(+), 54 deletions(-) diff --git a/2d/rle.c b/2d/rle.c index d26d44ca4..b6867c781 100644 --- a/2d/rle.c +++ b/2d/rle.c @@ -352,9 +352,8 @@ void rle_cache_init() int i; for (i=0; ibm_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; diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 8064d1144..0c2c4363a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 diff --git a/SConstruct b/SConstruct index f69940ce6..fc5ae0db5 100644 --- a/SConstruct +++ b/SConstruct @@ -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', diff --git a/main/segment.h b/main/segment.h index 7da77a22e..9db76f8ee 100644 --- a/main/segment.h +++ b/main/segment.h @@ -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 diff --git a/main/texmerge.c b/main/texmerge.c index 204e3c50c..42958385c 100644 --- a/main/texmerge.c +++ b/main/texmerge.c @@ -68,12 +68,7 @@ int texmerge_init(int num_cached_textures) num_cache_entries = MAX_NUM_CACHE_BITMAPS; for (i=0; ibm_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; ybm_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