From 2b2be071d4f62938ea73b7d9aaaa0fee7b42872c Mon Sep 17 00:00:00 2001 From: helixhorned Date: Mon, 13 Aug 2012 18:25:37 +0000 Subject: [PATCH] High-level TROR drawing: clean up how things are passed around. git-svn-id: https://svn.eduke32.com/eduke32@2880 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 5 +++-- polymer/eduke32/build/include/editor.h | 2 +- polymer/eduke32/build/src/build.c | 6 +++--- polymer/eduke32/build/src/engine.c | 10 ++++++++-- polymer/eduke32/source/astub.c | 11 ++++++++--- polymer/eduke32/source/game.c | 18 +++--------------- polymer/eduke32/source/game.h | 5 ----- polymer/eduke32/source/premap.c | 3 +-- 8 files changed, 27 insertions(+), 33 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 6b1249ce1..81846779f 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -132,12 +132,13 @@ static inline int32_t yax_waltosecmask(int32_t walclipmask) return ((walclipmask&1)<<9) | ((walclipmask&64)<<5); } void yax_preparedrawrooms(void); -void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectnum, int32_t didmirror); +void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t), + int16_t sectnum, int32_t didmirror, int32_t smoothr); # define YAX_SKIPSECTOR(i) if (graysectbitmap[(i)>>3]&(1<<((i)&7))) continue # define YAX_SKIPWALL(i) if (graywallbitmap[(i)>>3]&(1<<((i)&7))) continue #else # define yax_preparedrawrooms() -# define yax_drawrooms(ExtAnalyzeSprites, horiz, sectnum, didmirror) +# define yax_drawrooms(SpriteAnimFunc, sectnum, didmirror, smoothr) # define YAX_SKIPSECTOR(i) (i)=(i) # define YAX_SKIPWALL(i) (i)=(i) #endif diff --git a/polymer/eduke32/build/include/editor.h b/polymer/eduke32/build/include/editor.h index 7ad52e471..ce50c0b6b 100644 --- a/polymer/eduke32/build/include/editor.h +++ b/polymer/eduke32/build/include/editor.h @@ -158,7 +158,7 @@ extern int32_t ExtInit(void); extern int32_t ExtPreInit(int32_t argc,const char **argv); extern void ExtUnInit(void); extern void ExtPreCheckKeys(void); -extern void ExtAnalyzeSprites(void); +extern void ExtAnalyzeSprites(int32_t, int32_t, int32_t, int32_t); extern void ExtCheckKeys(void); extern void ExtPreLoadMap(void); extern void ExtSetupMapFilename(const char *mapname); diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 76242fbf3..2f48eb7ab 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -467,9 +467,9 @@ void M32_DrawRoomsAndMasks(void) { yax_preparedrawrooms(); drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); - yax_drawrooms(ExtAnalyzeSprites, horiz, cursectnum, 0); + yax_drawrooms(ExtAnalyzeSprites, cursectnum, 0, 0); - ExtAnalyzeSprites(); + ExtAnalyzeSprites(0,0,0,0); drawmasks(); M32_ResetFakeRORTiles(); @@ -478,7 +478,7 @@ void M32_DrawRoomsAndMasks(void) { polymer_editorpick(); drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); - ExtAnalyzeSprites(); + ExtAnalyzeSprites(0,0,0,0); drawmasks(); M32_ResetFakeRORTiles(); } diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 772346452..5c49b9add 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -204,6 +204,7 @@ static void scansector(int16_t sectnum); static void draw_rainbow_background(void); int16_t editstatus = 0; +static int32_t global100horiz; // (-100..300)-scale horiz (the one passed to drawrooms) ////////// YAX ////////// @@ -838,10 +839,13 @@ void yax_preparedrawrooms(void) } } -void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectnum, int32_t didmirror) +void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t), + int16_t sectnum, int32_t didmirror, int32_t smoothr) { static uint8_t havebunch[YAX_MAXBUNCHES>>3]; + const int32_t horiz = global100horiz; + int32_t i, j, k, lev, cf, nmp; int32_t bnchcnt, bnchnum[2] = {0,0}, maxlev[2]; int16_t ourbunch[2] = {-1,-1}, osectnum=sectnum; @@ -1052,7 +1056,7 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn yax_globallev-YAX_MAXDRAWS, j, k, spritesortcnt, (double)(1000*(gethiticks()-t))/hitickspersec); - ExtAnalyzeSprites(); + SpriteAnimFunc(globalposx, globalposy, globalang, smoothr); drawmasks(); } @@ -8259,6 +8263,8 @@ int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, globalposx = daposx; globalposy = daposy; globalposz = daposz; globalang = (daang&2047); + global100horiz = dahoriz; + // xdimenscale is scale(xdimen,yxaspect,320); // normalization by viewingrange so that center-of-aim doesn't depend on it globalhoriz = mulscale16(dahoriz-100,divscale16(xdimenscale,viewingrange))+(ydimen>>1); diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 031db583e..4bb1a6a33 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -2808,7 +2808,7 @@ static void ExtSE40Draw(int32_t spnum,int32_t x,int32_t y,int32_t z,int16_t a,in } drawrooms(x+offx,y+offy,z+offz,a,h,sprite[floor2].sectnum); - ExtAnalyzeSprites(); + ExtAnalyzeSprites(0,0,0,0); drawmasks(); M32_ResetFakeRORTiles(); @@ -2834,7 +2834,7 @@ static void ExtSE40Draw(int32_t spnum,int32_t x,int32_t y,int32_t z,int16_t a,in // Now re-draw drawrooms(x+offx,y+offy,z+offz,a,h,sprite[floor2].sectnum); - ExtAnalyzeSprites(); + ExtAnalyzeSprites(0,0,0,0); drawmasks(); M32_ResetFakeRORTiles(); } @@ -10874,12 +10874,17 @@ void ExtPreCheckKeys(void) // just before drawrooms enddrawing(); //}}} } -void ExtAnalyzeSprites(void) +void ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothr) { int32_t i, k; spritetype *tspr; int32_t frames=0, sh; + UNREFERENCED_PARAMETER(ourx); + UNREFERENCED_PARAMETER(oury); + UNREFERENCED_PARAMETER(oura); + UNREFERENCED_PARAMETER(smoothr); + for (i=0,tspr=&tsprite[0]; i>3]&(1<<(MIRROR&7))) @@ -3393,8 +3385,7 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, i yax_preparedrawrooms(); didmirror = drawrooms(tposx,tposy,z,tang,horiz,g_mirrorSector[i]+MAXSECTORS); - g_yax_smoothratio = smoothratio; - yax_drawrooms(G_AnalyzeSprites, horiz, g_mirrorSector[i], didmirror); + yax_drawrooms(G_DoSpriteAnimations, g_mirrorSector[i], didmirror, smoothratio); } #ifdef USE_OPENGL else @@ -3470,8 +3461,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) #endif yax_preparedrawrooms(); drawrooms(s->x,s->y,s->z-(4<<8),ud.cameraang,s->yvel,s->sectnum); - g_yax_smoothratio = smoothratio; - yax_drawrooms(G_AnalyzeSprites, s->yvel, s->sectnum, 0); + yax_drawrooms(G_DoSpriteAnimations, s->sectnum, 0, smoothratio); G_DoSpriteAnimations(s->x,s->y,ud.cameraang,smoothratio); drawmasks(); } @@ -3684,9 +3674,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) yax_preparedrawrooms(); drawrooms(ud.camera.x,ud.camera.y,ud.camera.z,ud.cameraang,ud.camerahoriz,ud.camerasect); - g_yax_smoothratio = smoothratio; - yax_drawrooms(G_AnalyzeSprites, ud.camerahoriz, ud.camerasect, 0); - + yax_drawrooms(G_DoSpriteAnimations, ud.camerasect, 0, smoothratio); // dupe the sprites touching the portal to the other sector diff --git a/polymer/eduke32/source/game.h b/polymer/eduke32/source/game.h index e62a0490c..3f12a41ef 100644 --- a/polymer/eduke32/source/game.h +++ b/polymer/eduke32/source/game.h @@ -242,8 +242,6 @@ extern int8_t g_noFloorPal[MAXPALOOKUPS]; extern user_defs ud; -//extern int32_t g_yax_smoothratio; - int32_t A_CheckInventorySprite(spritetype *s); int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int32_t s_pn,int32_t s_s,int32_t s_xr,int32_t s_yr,int32_t s_a,int32_t s_ve,int32_t s_zv,int32_t s_ow,int32_t s_ss); int32_t A_Spawn(int32_t j,int32_t pn); @@ -290,9 +288,6 @@ void G_HandleLocalKeys(void); void G_HandleSpecialKeys(void); void G_PrintGameQuotes(void); //void G_SE40(int32_t smoothratio); -#ifdef YAX_ENABLE -void G_AnalyzeSprites(void); -#endif void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b); void G_SetStatusBarScale(int32_t sc); void G_Shutdown(void); diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 63f92fd64..614c27a1d 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -572,8 +572,7 @@ void G_SetupCamTile(int32_t i,int32_t wn) yax_preparedrawrooms(); drawrooms(SX,SY,SZ,SA,100+sprite[i].shade,SECT); - // g_yax_smoothratio? - yax_drawrooms(G_AnalyzeSprites, 100+sprite[i].shade, SECT, 0); + yax_drawrooms(G_DoSpriteAnimations, SECT, 0, 65536); display_mirror = 1; G_DoSpriteAnimations(SX,SY,SA,65536L);