From 7ca71203f06581dc470b67066e3558985e439862 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 19 Jan 2014 20:17:14 +0000 Subject: [PATCH] Classic: in debugging builds, add cvar debug_maskdrawmode. git-svn-id: https://svn.eduke32.com/eduke32@4261 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/baselayer.h | 5 ++ polymer/eduke32/build/src/baselayer.c | 3 ++ polymer/eduke32/build/src/engine.c | 61 ++++++++++++++++++++++- 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/polymer/eduke32/build/include/baselayer.h b/polymer/eduke32/build/include/baselayer.h index 45e1bb4fa..f6b774f0d 100644 --- a/polymer/eduke32/build/include/baselayer.h +++ b/polymer/eduke32/build/include/baselayer.h @@ -12,6 +12,11 @@ extern "C" { #endif +#ifdef DEBUGGINGAIDS +# define DEBUG_MASK_DRAWING +extern int32_t g_maskDrawMode; +#endif + extern char quitevent, appactive; extern int32_t vsync; diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index c2d930260..037e54705 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -423,6 +423,9 @@ int32_t baselayer_init(void) #ifdef DEBUGGINGAIDS { "debug1","debug counter",(void *) &debug1, CVAR_FLOAT, -100000, 100000 }, { "debug2","debug counter",(void *) &debug2, CVAR_FLOAT, -100000, 100000 }, +#endif +#ifdef DEBUG_MASK_DRAWING + { "debug_maskdrawmode", "Show mask draw orders: 0:none, 1:EDuke32, 2:Duke3D", (void *)&g_maskDrawMode, CVAR_INT, 0, 2 }, #endif }; diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 6218a8349..7da1dd00d 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -9194,12 +9194,32 @@ static inline int32_t sameside(_equation *eq, _point2d *p1, _point2d *p2 return (0); } +#ifdef DEBUG_MASK_DRAWING +int32_t g_maskDrawMode = 0; +#endif // // drawmasks // void drawmasks(void) { +#ifdef DEBUG_MASK_DRAWING + static struct { + int16_t di; // &32768: &32767 is tspriteptr[], else thewall[] index + int16_t i; // sprite[] or wall[] index + } debugmask[MAXWALLSB + MAXSPRITESONSCREEN + 1]; + + int32_t dmasknum = 0; + +# define debugmask_add(dispidx, idx) do { \ + if (g_maskDrawMode && getrendermode()==REND_CLASSIC) { \ + debugmask[dmasknum].di = dispidx; \ + debugmask[dmasknum++].i = idx; \ + } \ + } while (0) +#else +# define debugmask_add(dispidx, idx) do {} while (0) +#endif int32_t i, modelp=0; for (i=spritesortcnt-1; i>=0; i--) @@ -9350,7 +9370,11 @@ killsprite: const int32_t w = (getrendermode()==REND_POLYMER) ? maskwall[maskwallcnt-1] : thewall[maskwall[maskwallcnt-1]]; - const int32_t otherside_spr_first = (getrendermode() == REND_CLASSIC); + const int32_t otherside_spr_first = (getrendermode() == REND_CLASSIC) +#ifdef DEBUG_MASK_DRAWING + && (g_maskDrawMode <= 1) +#endif + ; maskwallcnt--; @@ -9386,12 +9410,14 @@ killsprite: (sameside(&p1eq, &middle, &spr) && sameside(&p2eq, &middle, &spr)))) { + debugmask_add(i | 32768, tspriteptr[i]->owner); drawsprite(i); tspriteptr[i] = NULL; } } } + debugmask_add(maskwall[maskwallcnt], thewall[maskwall[maskwallcnt]]); drawmaskwall(maskwallcnt); } @@ -9399,7 +9425,10 @@ killsprite: { spritesortcnt--; if (tspriteptr[spritesortcnt] != NULL) + { + debugmask_add(spritesortcnt | 32768, tspriteptr[spritesortcnt]->owner); drawsprite(spritesortcnt); + } } } @@ -9407,6 +9436,36 @@ killsprite: if (getrendermode() == REND_POLYMER) polymer_drawmasks(); #endif +#ifdef DEBUG_MASK_DRAWING + if (g_maskDrawMode && getrendermode() == REND_CLASSIC) + { + for (i=0; i>8, sy = ydim/2 + 8; + // XXX: printext256 really ought to do bound checking on the + // x/y coords! + sx = clamp(sx, 0, xdim-8*Bstrlen(numstr)-1); + printext256(sx, sy, 241, 0, numstr, 0); + } + else + { + int32_t sx = xb1[di] + (xb2[di]-xb1[di])/2, sy = ydim/2; + sx = clamp(sx, 0, xdim-8*Bstrlen(numstr)-1); + printext256(sx, sy, 31, 0, numstr, 0); + } + } + } +#endif indrawroomsandmasks = 0; enddrawing(); //}}}