From 0a4548db9446355a8487f5c3e767960f8773e74f Mon Sep 17 00:00:00 2001 From: viciious Date: Sun, 18 Jun 2023 18:52:44 +0300 Subject: [PATCH] Code refactoring --- r_local.h | 2 +- r_main.c | 2 +- r_phase2.c | 5 ++--- r_phase6.c | 4 ---- r_phase7.c | 14 ++++++++------ 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/r_local.h b/r_local.h index 32d622b00b..b5536a18d9 100644 --- a/r_local.h +++ b/r_local.h @@ -569,7 +569,7 @@ typedef struct visplane_s #define MAXVISPLANES 32 extern visplane_t *visplanes/*[MAXVISPLANES]*/, *lastvisplane; -extern uint16_t *gsortedvisplanes; +extern uint32_t *gsortedvisplanes; void R_MarkOpenPlane(visplane_t* pl) ATTR_DATA_CACHE_ALIGN diff --git a/r_main.c b/r_main.c index 4651ffc18b..cafcadfe33 100644 --- a/r_main.c +++ b/r_main.c @@ -60,7 +60,7 @@ const uint16_t visplane0open[SCREENWIDTH+2] = { 0 }; #define NUM_VISPLANES_BUCKETS 32 static visplane_t **visplanes_hash; -uint16_t *gsortedvisplanes; +uint32_t *gsortedvisplanes; /* */ /* sprites */ diff --git a/r_phase2.c b/r_phase2.c index 4d59d614e3..565915dab0 100644 --- a/r_phase2.c +++ b/r_phase2.c @@ -508,7 +508,6 @@ void Mars_Sec_R_WallPrep(void) viswall_t *first, *verylast; uint32_t clipbounds_[SCREENWIDTH/2+1]; uint16_t *clipbounds = (uint16_t *)clipbounds_; - int ready = 1; R_InitClipBounds(clipbounds_); @@ -531,7 +530,8 @@ void Mars_Sec_R_WallPrep(void) nextsegs = verylast - first; } - for (last = first + nextsegs; segl < last; segl++) + last = first + nextsegs; + for (; segl < last; segl++) { #ifdef MARS Mars_ClearCacheLine(seglex); @@ -539,7 +539,6 @@ void Mars_Sec_R_WallPrep(void) R_SegLoop(segl, clipbounds, seglex->floorheight, seglex->floornewheight, seglex->ceilnewheight); seglex++; - MARS_SYS_COMM8 = ready++; } } } diff --git a/r_phase6.c b/r_phase6.c index b58a0d3cb1..a1ce95b1da 100644 --- a/r_phase6.c +++ b/r_phase6.c @@ -293,10 +293,6 @@ void R_SegCommands(void) unsigned actionbits; viswall_t* segl = viswalls + i; -#ifdef MARS - if (MARS_SYS_COMM8 <= i) - continue; -#endif if (segl->start > segl->stop) continue; diff --git a/r_phase7.c b/r_phase7.c index 8c585e0672..b519c0d5c6 100644 --- a/r_phase7.c +++ b/r_phase7.c @@ -276,7 +276,7 @@ static void R_DrawPlanes2(void) localplane_t lpl; visplane_t* pl; int extralight; - uint16_t *sortedvisplanes = gsortedvisplanes; + uint16_t *sortedvisplanes = (uint16_t *)gsortedvisplanes; boolean nomips = detailmode < detmode_mipmaps; #ifdef MARS @@ -362,7 +362,7 @@ static void R_DrawPlanes2(void) #ifdef MARS static void Mars_R_SplitPlanes(void) ATTR_DATA_CACHE_ALIGN; -static void Mars_R_SortPlanes(uint16_t *sortedvisplanes) ATTR_DATA_CACHE_ALIGN; +static void Mars_R_SortPlanes(void) ATTR_DATA_CACHE_ALIGN; void Mars_Sec_R_DrawPlanes(void) { @@ -424,10 +424,11 @@ static void Mars_R_SplitPlanes(void) // sort visplanes by flatnum so that texture data // has a better chance to stay in the CPU cache -static void Mars_R_SortPlanes(uint16_t *sortbuf) +static void Mars_R_SortPlanes(void) { int i, numplanes; visplane_t* pl; + uint16_t *sortbuf = (uint16_t *)gsortedvisplanes; i = 0; numplanes = 0; @@ -440,13 +441,13 @@ static void Mars_R_SortPlanes(uint16_t *sortbuf) i += 2; } - D_isort((int*)sortbuf, numplanes); + D_isort((int *)gsortedvisplanes, numplanes); } void R_PreDrawPlanes(void) { int numplanes; - uint16_t *sortbuf = gsortedvisplanes; + uint16_t *sortbuf = (uint16_t *)gsortedvisplanes; Mars_ClearCacheLine(&lastvisplane); Mars_ClearCacheLine(sortbuf); @@ -459,7 +460,8 @@ void R_PreDrawPlanes(void) Mars_ClearCacheLines(visplanes, (numplanes * sizeof(visplane_t) + 31) / 16); Mars_R_SplitPlanes(); - Mars_R_SortPlanes(sortbuf); + + Mars_R_SortPlanes(); } }